@eminent337/aery 0.1.62 → 0.1.64

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 (714) hide show
  1. package/CHANGELOG.md +0 -0
  2. package/README.md +0 -0
  3. package/docs/compaction.md +0 -0
  4. package/docs/custom-provider.md +1 -1
  5. package/docs/development.md +0 -0
  6. package/docs/docs.json +0 -0
  7. package/docs/extensions.md +18 -18
  8. package/docs/images/doom-extension.png +0 -0
  9. package/docs/images/exy.png +0 -0
  10. package/docs/images/interactive-mode.png +0 -0
  11. package/docs/images/tree-view.png +0 -0
  12. package/docs/index.md +5 -5
  13. package/docs/json.md +1 -1
  14. package/docs/keybindings.md +2 -2
  15. package/docs/models.md +2 -2
  16. package/docs/packages.md +13 -13
  17. package/docs/prompt-templates.md +0 -0
  18. package/docs/providers.md +5 -5
  19. package/docs/quickstart.md +19 -19
  20. package/docs/rpc.md +3 -3
  21. package/docs/sdk.md +1 -1
  22. package/docs/session-format.md +3 -3
  23. package/docs/sessions.md +10 -10
  24. package/docs/settings.md +7 -5
  25. package/docs/shell-aliases.md +0 -0
  26. package/docs/skills.md +2 -2
  27. package/docs/terminal-setup.md +6 -6
  28. package/docs/termux.md +3 -3
  29. package/docs/themes.md +3 -3
  30. package/docs/tmux.md +1 -1
  31. package/docs/tui.md +2 -2
  32. package/docs/usage.md +33 -33
  33. package/docs/windows.md +0 -0
  34. package/examples/README.md +0 -0
  35. package/examples/extensions/README.md +3 -3
  36. package/examples/extensions/antigravity-image-gen.ts +6 -6
  37. package/examples/extensions/auto-commit-on-exit.ts +1 -1
  38. package/examples/extensions/bash-spawn-hook.ts +1 -1
  39. package/examples/extensions/bookmark.ts +0 -0
  40. package/examples/extensions/border-status-editor.ts +0 -0
  41. package/examples/extensions/built-in-tool-renderer.ts +1 -1
  42. package/examples/extensions/claude-rules.ts +1 -1
  43. package/examples/extensions/commands.ts +1 -1
  44. package/examples/extensions/confirm-destructive.ts +0 -0
  45. package/examples/extensions/custom-compaction.ts +1 -1
  46. package/examples/extensions/custom-footer.ts +0 -0
  47. package/examples/extensions/custom-header.ts +2 -2
  48. package/examples/extensions/custom-provider-anthropic/index.ts +2 -2
  49. package/examples/extensions/custom-provider-anthropic/package-lock.json +0 -0
  50. package/examples/extensions/custom-provider-anthropic/package.json +0 -0
  51. package/examples/extensions/custom-provider-gitlab-duo/index.ts +2 -2
  52. package/examples/extensions/custom-provider-gitlab-duo/package.json +0 -0
  53. package/examples/extensions/custom-provider-gitlab-duo/test.ts +0 -0
  54. package/examples/extensions/custom-provider-qwen-cli/index.ts +1 -1
  55. package/examples/extensions/custom-provider-qwen-cli/package.json +0 -0
  56. package/examples/extensions/dirty-repo-guard.ts +0 -0
  57. package/examples/extensions/doom-overlay/README.md +2 -2
  58. package/examples/extensions/doom-overlay/doom/build/doom.js +0 -0
  59. package/examples/extensions/doom-overlay/doom/build.sh +2 -2
  60. package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +0 -0
  61. package/examples/extensions/doom-overlay/doom-component.ts +0 -0
  62. package/examples/extensions/doom-overlay/doom-engine.ts +0 -0
  63. package/examples/extensions/doom-overlay/doom-keys.ts +0 -0
  64. package/examples/extensions/doom-overlay/index.ts +1 -1
  65. package/examples/extensions/doom-overlay/wad-finder.ts +0 -0
  66. package/examples/extensions/dynamic-resources/SKILL.md +0 -0
  67. package/examples/extensions/dynamic-resources/dynamic.json +0 -0
  68. package/examples/extensions/dynamic-resources/dynamic.md +0 -0
  69. package/examples/extensions/dynamic-resources/index.ts +0 -0
  70. package/examples/extensions/dynamic-tools.ts +0 -0
  71. package/examples/extensions/event-bus.ts +0 -0
  72. package/examples/extensions/file-trigger.ts +0 -0
  73. package/examples/extensions/git-checkpoint.ts +0 -0
  74. package/examples/extensions/github-issue-autocomplete.ts +0 -0
  75. package/examples/extensions/handoff.ts +0 -0
  76. package/examples/extensions/hello.ts +0 -0
  77. package/examples/extensions/hidden-thinking-label.ts +1 -1
  78. package/examples/extensions/inline-bash.ts +2 -2
  79. package/examples/extensions/input-transform.ts +3 -3
  80. package/examples/extensions/interactive-shell.ts +1 -1
  81. package/examples/extensions/mac-system-theme.ts +2 -2
  82. package/examples/extensions/message-renderer.ts +0 -0
  83. package/examples/extensions/minimal-mode.ts +1 -1
  84. package/examples/extensions/modal-editor.ts +1 -1
  85. package/examples/extensions/model-status.ts +1 -1
  86. package/examples/extensions/notify.ts +0 -0
  87. package/examples/extensions/overlay-qa-tests.ts +1 -1
  88. package/examples/extensions/overlay-test.ts +1 -1
  89. package/examples/extensions/permission-gate.ts +0 -0
  90. package/examples/extensions/pirate.ts +1 -1
  91. package/examples/extensions/plan-mode/README.md +0 -0
  92. package/examples/extensions/plan-mode/index.ts +0 -0
  93. package/examples/extensions/plan-mode/utils.ts +0 -0
  94. package/examples/extensions/preset.ts +12 -6
  95. package/examples/extensions/prompt-customizer.ts +1 -1
  96. package/examples/extensions/protected-paths.ts +0 -0
  97. package/examples/extensions/provider-payload.ts +1 -1
  98. package/examples/extensions/qna.ts +0 -0
  99. package/examples/extensions/question.ts +0 -0
  100. package/examples/extensions/questionnaire.ts +0 -0
  101. package/examples/extensions/rainbow-editor.ts +1 -1
  102. package/examples/extensions/reload-runtime.ts +0 -0
  103. package/examples/extensions/rpc-demo.ts +1 -1
  104. package/examples/extensions/sandbox/index.ts +8 -8
  105. package/examples/extensions/sandbox/package-lock.json +0 -0
  106. package/examples/extensions/sandbox/package.json +0 -0
  107. package/examples/extensions/send-user-message.ts +0 -0
  108. package/examples/extensions/session-name.ts +0 -0
  109. package/examples/extensions/shutdown-command.ts +5 -5
  110. package/examples/extensions/snake.ts +0 -0
  111. package/examples/extensions/space-invaders.ts +0 -0
  112. package/examples/extensions/ssh.ts +2 -2
  113. package/examples/extensions/status-line.ts +0 -0
  114. package/examples/extensions/structured-output.ts +0 -0
  115. package/examples/extensions/subagent/README.md +13 -13
  116. package/examples/extensions/subagent/agents/planner.md +0 -0
  117. package/examples/extensions/subagent/agents/reviewer.md +0 -0
  118. package/examples/extensions/subagent/agents/scout.md +0 -0
  119. package/examples/extensions/subagent/agents/worker.md +0 -0
  120. package/examples/extensions/subagent/agents.ts +1 -1
  121. package/examples/extensions/subagent/index.ts +5 -5
  122. package/examples/extensions/subagent/prompts/implement-and-review.md +0 -0
  123. package/examples/extensions/subagent/prompts/implement.md +0 -0
  124. package/examples/extensions/subagent/prompts/scout-and-plan.md +0 -0
  125. package/examples/extensions/summarize.ts +0 -0
  126. package/examples/extensions/system-prompt-header.ts +0 -0
  127. package/examples/extensions/tic-tac-toe.ts +0 -0
  128. package/examples/extensions/timed-confirm.ts +0 -0
  129. package/examples/extensions/titlebar-spinner.ts +1 -1
  130. package/examples/extensions/todo.ts +0 -0
  131. package/examples/extensions/tool-override.ts +2 -2
  132. package/examples/extensions/tools.ts +1 -1
  133. package/examples/extensions/trigger-compact.ts +0 -0
  134. package/examples/extensions/truncated-tool.ts +1 -1
  135. package/examples/extensions/widget-placement.ts +0 -0
  136. package/examples/extensions/with-deps/index.ts +0 -0
  137. package/examples/extensions/with-deps/package-lock.json +0 -0
  138. package/examples/extensions/with-deps/package.json +0 -0
  139. package/examples/extensions/working-indicator.ts +4 -4
  140. package/examples/extensions/working-message-test.ts +1 -1
  141. package/examples/rpc-extension-ui.ts +0 -0
  142. package/examples/sdk/01-minimal.ts +1 -1
  143. package/examples/sdk/02-custom-model.ts +0 -0
  144. package/examples/sdk/03-custom-prompt.ts +1 -1
  145. package/examples/sdk/04-skills.ts +1 -1
  146. package/examples/sdk/05-tools.ts +0 -0
  147. package/examples/sdk/06-extensions.ts +2 -2
  148. package/examples/sdk/07-context-files.ts +0 -0
  149. package/examples/sdk/08-prompt-templates.ts +1 -1
  150. package/examples/sdk/09-api-keys-and-oauth.ts +2 -2
  151. package/examples/sdk/10-settings.ts +0 -0
  152. package/examples/sdk/11-sessions.ts +0 -0
  153. package/examples/sdk/12-full-control.ts +0 -0
  154. package/examples/sdk/13-session-runtime.ts +0 -0
  155. package/examples/sdk/README.md +1 -1
  156. package/package.json +4 -4
  157. package/dist/bun/cli.d.ts +0 -3
  158. package/dist/bun/cli.d.ts.map +0 -1
  159. package/dist/bun/cli.js +0 -8
  160. package/dist/bun/cli.js.map +0 -1
  161. package/dist/bun/register-bedrock.d.ts +0 -2
  162. package/dist/bun/register-bedrock.d.ts.map +0 -1
  163. package/dist/bun/register-bedrock.js +0 -4
  164. package/dist/bun/register-bedrock.js.map +0 -1
  165. package/dist/bun/restore-sandbox-env.d.ts +0 -13
  166. package/dist/bun/restore-sandbox-env.d.ts.map +0 -1
  167. package/dist/bun/restore-sandbox-env.js +0 -32
  168. package/dist/bun/restore-sandbox-env.js.map +0 -1
  169. package/dist/cli/args.d.ts +0 -53
  170. package/dist/cli/args.d.ts.map +0 -1
  171. package/dist/cli/args.js +0 -329
  172. package/dist/cli/args.js.map +0 -1
  173. package/dist/cli/config-selector.d.ts +0 -14
  174. package/dist/cli/config-selector.d.ts.map +0 -1
  175. package/dist/cli/config-selector.js +0 -31
  176. package/dist/cli/config-selector.js.map +0 -1
  177. package/dist/cli/file-processor.d.ts +0 -15
  178. package/dist/cli/file-processor.d.ts.map +0 -1
  179. package/dist/cli/file-processor.js +0 -83
  180. package/dist/cli/file-processor.js.map +0 -1
  181. package/dist/cli/initial-message.d.ts +0 -18
  182. package/dist/cli/initial-message.d.ts.map +0 -1
  183. package/dist/cli/initial-message.js +0 -22
  184. package/dist/cli/initial-message.js.map +0 -1
  185. package/dist/cli/list-models.d.ts +0 -9
  186. package/dist/cli/list-models.d.ts.map +0 -1
  187. package/dist/cli/list-models.js +0 -98
  188. package/dist/cli/list-models.js.map +0 -1
  189. package/dist/cli/session-picker.d.ts +0 -9
  190. package/dist/cli/session-picker.d.ts.map +0 -1
  191. package/dist/cli/session-picker.js +0 -35
  192. package/dist/cli/session-picker.js.map +0 -1
  193. package/dist/cli.d.ts +0 -3
  194. package/dist/cli.d.ts.map +0 -1
  195. package/dist/cli.js +0 -19
  196. package/dist/cli.js.map +0 -1
  197. package/dist/config.d.ts +0 -86
  198. package/dist/config.d.ts.map +0 -1
  199. package/dist/config.js +0 -332
  200. package/dist/config.js.map +0 -1
  201. package/dist/core/agent-session-runtime.d.ts +0 -117
  202. package/dist/core/agent-session-runtime.d.ts.map +0 -1
  203. package/dist/core/agent-session-runtime.js +0 -300
  204. package/dist/core/agent-session-runtime.js.map +0 -1
  205. package/dist/core/agent-session-services.d.ts +0 -86
  206. package/dist/core/agent-session-services.d.ts.map +0 -1
  207. package/dist/core/agent-session-services.js +0 -117
  208. package/dist/core/agent-session-services.js.map +0 -1
  209. package/dist/core/agent-session.d.ts +0 -595
  210. package/dist/core/agent-session.d.ts.map +0 -1
  211. package/dist/core/agent-session.js +0 -2520
  212. package/dist/core/agent-session.js.map +0 -1
  213. package/dist/core/auth-guidance.d.ts +0 -5
  214. package/dist/core/auth-guidance.d.ts.map +0 -1
  215. package/dist/core/auth-guidance.js +0 -21
  216. package/dist/core/auth-guidance.js.map +0 -1
  217. package/dist/core/auth-storage.d.ts +0 -141
  218. package/dist/core/auth-storage.d.ts.map +0 -1
  219. package/dist/core/auth-storage.js +0 -441
  220. package/dist/core/auth-storage.js.map +0 -1
  221. package/dist/core/bash-executor.d.ts +0 -32
  222. package/dist/core/bash-executor.d.ts.map +0 -1
  223. package/dist/core/bash-executor.js +0 -111
  224. package/dist/core/bash-executor.js.map +0 -1
  225. package/dist/core/compaction/branch-summarization.d.ts +0 -88
  226. package/dist/core/compaction/branch-summarization.d.ts.map +0 -1
  227. package/dist/core/compaction/branch-summarization.js +0 -243
  228. package/dist/core/compaction/branch-summarization.js.map +0 -1
  229. package/dist/core/compaction/compaction.d.ts +0 -121
  230. package/dist/core/compaction/compaction.d.ts.map +0 -1
  231. package/dist/core/compaction/compaction.js +0 -615
  232. package/dist/core/compaction/compaction.js.map +0 -1
  233. package/dist/core/compaction/index.d.ts +0 -7
  234. package/dist/core/compaction/index.d.ts.map +0 -1
  235. package/dist/core/compaction/index.js +0 -7
  236. package/dist/core/compaction/index.js.map +0 -1
  237. package/dist/core/compaction/utils.d.ts +0 -38
  238. package/dist/core/compaction/utils.d.ts.map +0 -1
  239. package/dist/core/compaction/utils.js +0 -153
  240. package/dist/core/compaction/utils.js.map +0 -1
  241. package/dist/core/defaults.d.ts +0 -3
  242. package/dist/core/defaults.d.ts.map +0 -1
  243. package/dist/core/defaults.js +0 -2
  244. package/dist/core/defaults.js.map +0 -1
  245. package/dist/core/diagnostics.d.ts +0 -15
  246. package/dist/core/diagnostics.d.ts.map +0 -1
  247. package/dist/core/diagnostics.js +0 -2
  248. package/dist/core/diagnostics.js.map +0 -1
  249. package/dist/core/event-bus.d.ts +0 -9
  250. package/dist/core/event-bus.d.ts.map +0 -1
  251. package/dist/core/event-bus.js +0 -25
  252. package/dist/core/event-bus.js.map +0 -1
  253. package/dist/core/exec.d.ts +0 -29
  254. package/dist/core/exec.d.ts.map +0 -1
  255. package/dist/core/exec.js +0 -75
  256. package/dist/core/exec.js.map +0 -1
  257. package/dist/core/export-html/ansi-to-html.d.ts +0 -22
  258. package/dist/core/export-html/ansi-to-html.d.ts.map +0 -1
  259. package/dist/core/export-html/ansi-to-html.js +0 -249
  260. package/dist/core/export-html/ansi-to-html.js.map +0 -1
  261. package/dist/core/export-html/index.d.ts +0 -37
  262. package/dist/core/export-html/index.d.ts.map +0 -1
  263. package/dist/core/export-html/index.js +0 -224
  264. package/dist/core/export-html/index.js.map +0 -1
  265. package/dist/core/export-html/template.css +0 -1022
  266. package/dist/core/export-html/template.html +0 -55
  267. package/dist/core/export-html/template.js +0 -1770
  268. package/dist/core/export-html/tool-renderer.d.ts +0 -34
  269. package/dist/core/export-html/tool-renderer.d.ts.map +0 -1
  270. package/dist/core/export-html/tool-renderer.js +0 -108
  271. package/dist/core/export-html/tool-renderer.js.map +0 -1
  272. package/dist/core/export-html/vendor/highlight.min.js +0 -1213
  273. package/dist/core/export-html/vendor/marked.min.js +0 -6
  274. package/dist/core/extensions/index.d.ts +0 -12
  275. package/dist/core/extensions/index.d.ts.map +0 -1
  276. package/dist/core/extensions/index.js +0 -9
  277. package/dist/core/extensions/index.js.map +0 -1
  278. package/dist/core/extensions/loader.d.ts +0 -25
  279. package/dist/core/extensions/loader.d.ts.map +0 -1
  280. package/dist/core/extensions/loader.js +0 -476
  281. package/dist/core/extensions/loader.js.map +0 -1
  282. package/dist/core/extensions/runner.d.ts +0 -158
  283. package/dist/core/extensions/runner.d.ts.map +0 -1
  284. package/dist/core/extensions/runner.js +0 -784
  285. package/dist/core/extensions/runner.js.map +0 -1
  286. package/dist/core/extensions/types.d.ts +0 -1153
  287. package/dist/core/extensions/types.d.ts.map +0 -1
  288. package/dist/core/extensions/types.js +0 -45
  289. package/dist/core/extensions/types.js.map +0 -1
  290. package/dist/core/extensions/wrapper.d.ts +0 -20
  291. package/dist/core/extensions/wrapper.d.ts.map +0 -1
  292. package/dist/core/extensions/wrapper.js +0 -22
  293. package/dist/core/extensions/wrapper.js.map +0 -1
  294. package/dist/core/footer-data-provider.d.ts +0 -52
  295. package/dist/core/footer-data-provider.d.ts.map +0 -1
  296. package/dist/core/footer-data-provider.js +0 -310
  297. package/dist/core/footer-data-provider.js.map +0 -1
  298. package/dist/core/index.d.ts +0 -12
  299. package/dist/core/index.d.ts.map +0 -1
  300. package/dist/core/index.js +0 -12
  301. package/dist/core/index.js.map +0 -1
  302. package/dist/core/keybindings.d.ts +0 -353
  303. package/dist/core/keybindings.d.ts.map +0 -1
  304. package/dist/core/keybindings.js +0 -295
  305. package/dist/core/keybindings.js.map +0 -1
  306. package/dist/core/messages.d.ts +0 -77
  307. package/dist/core/messages.d.ts.map +0 -1
  308. package/dist/core/messages.js +0 -123
  309. package/dist/core/messages.js.map +0 -1
  310. package/dist/core/model-registry.d.ts +0 -144
  311. package/dist/core/model-registry.d.ts.map +0 -1
  312. package/dist/core/model-registry.js +0 -699
  313. package/dist/core/model-registry.js.map +0 -1
  314. package/dist/core/model-resolver.d.ts +0 -110
  315. package/dist/core/model-resolver.d.ts.map +0 -1
  316. package/dist/core/model-resolver.js +0 -489
  317. package/dist/core/model-resolver.js.map +0 -1
  318. package/dist/core/output-guard.d.ts +0 -6
  319. package/dist/core/output-guard.d.ts.map +0 -1
  320. package/dist/core/output-guard.js +0 -59
  321. package/dist/core/output-guard.js.map +0 -1
  322. package/dist/core/package-manager.d.ts +0 -199
  323. package/dist/core/package-manager.d.ts.map +0 -1
  324. package/dist/core/package-manager.js +0 -1973
  325. package/dist/core/package-manager.js.map +0 -1
  326. package/dist/core/prompt-templates.d.ts +0 -52
  327. package/dist/core/prompt-templates.d.ts.map +0 -1
  328. package/dist/core/prompt-templates.js +0 -250
  329. package/dist/core/prompt-templates.js.map +0 -1
  330. package/dist/core/resolve-config-value.d.ts +0 -23
  331. package/dist/core/resolve-config-value.d.ts.map +0 -1
  332. package/dist/core/resolve-config-value.js +0 -126
  333. package/dist/core/resolve-config-value.js.map +0 -1
  334. package/dist/core/resource-loader.d.ts +0 -194
  335. package/dist/core/resource-loader.d.ts.map +0 -1
  336. package/dist/core/resource-loader.js +0 -727
  337. package/dist/core/resource-loader.js.map +0 -1
  338. package/dist/core/sdk.d.ts +0 -107
  339. package/dist/core/sdk.d.ts.map +0 -1
  340. package/dist/core/sdk.js +0 -274
  341. package/dist/core/sdk.js.map +0 -1
  342. package/dist/core/session-cwd.d.ts +0 -19
  343. package/dist/core/session-cwd.d.ts.map +0 -1
  344. package/dist/core/session-cwd.js +0 -38
  345. package/dist/core/session-cwd.js.map +0 -1
  346. package/dist/core/session-manager.d.ts +0 -333
  347. package/dist/core/session-manager.d.ts.map +0 -1
  348. package/dist/core/session-manager.js +0 -1109
  349. package/dist/core/session-manager.js.map +0 -1
  350. package/dist/core/settings-manager.d.ts +0 -261
  351. package/dist/core/settings-manager.d.ts.map +0 -1
  352. package/dist/core/settings-manager.js +0 -782
  353. package/dist/core/settings-manager.js.map +0 -1
  354. package/dist/core/skills.d.ts +0 -60
  355. package/dist/core/skills.d.ts.map +0 -1
  356. package/dist/core/skills.js +0 -404
  357. package/dist/core/skills.js.map +0 -1
  358. package/dist/core/slash-commands.d.ts +0 -14
  359. package/dist/core/slash-commands.d.ts.map +0 -1
  360. package/dist/core/slash-commands.js +0 -25
  361. package/dist/core/slash-commands.js.map +0 -1
  362. package/dist/core/source-info.d.ts +0 -18
  363. package/dist/core/source-info.d.ts.map +0 -1
  364. package/dist/core/source-info.js +0 -19
  365. package/dist/core/source-info.js.map +0 -1
  366. package/dist/core/system-prompt.d.ts +0 -28
  367. package/dist/core/system-prompt.d.ts.map +0 -1
  368. package/dist/core/system-prompt.js +0 -120
  369. package/dist/core/system-prompt.js.map +0 -1
  370. package/dist/core/telemetry.d.ts +0 -3
  371. package/dist/core/telemetry.d.ts.map +0 -1
  372. package/dist/core/telemetry.js +0 -9
  373. package/dist/core/telemetry.js.map +0 -1
  374. package/dist/core/timings.d.ts +0 -8
  375. package/dist/core/timings.d.ts.map +0 -1
  376. package/dist/core/timings.js +0 -31
  377. package/dist/core/timings.js.map +0 -1
  378. package/dist/core/tools/bash.d.ts +0 -68
  379. package/dist/core/tools/bash.d.ts.map +0 -1
  380. package/dist/core/tools/bash.js +0 -355
  381. package/dist/core/tools/bash.js.map +0 -1
  382. package/dist/core/tools/edit-diff.d.ts +0 -85
  383. package/dist/core/tools/edit-diff.d.ts.map +0 -1
  384. package/dist/core/tools/edit-diff.js +0 -337
  385. package/dist/core/tools/edit-diff.js.map +0 -1
  386. package/dist/core/tools/edit.d.ts +0 -49
  387. package/dist/core/tools/edit.d.ts.map +0 -1
  388. package/dist/core/tools/edit.js +0 -323
  389. package/dist/core/tools/edit.js.map +0 -1
  390. package/dist/core/tools/file-mutation-queue.d.ts +0 -6
  391. package/dist/core/tools/file-mutation-queue.d.ts.map +0 -1
  392. package/dist/core/tools/file-mutation-queue.js +0 -37
  393. package/dist/core/tools/file-mutation-queue.js.map +0 -1
  394. package/dist/core/tools/find.d.ts +0 -35
  395. package/dist/core/tools/find.d.ts.map +0 -1
  396. package/dist/core/tools/find.js +0 -298
  397. package/dist/core/tools/find.js.map +0 -1
  398. package/dist/core/tools/grep.d.ts +0 -37
  399. package/dist/core/tools/grep.d.ts.map +0 -1
  400. package/dist/core/tools/grep.js +0 -304
  401. package/dist/core/tools/grep.js.map +0 -1
  402. package/dist/core/tools/index.d.ts +0 -40
  403. package/dist/core/tools/index.d.ts.map +0 -1
  404. package/dist/core/tools/index.js +0 -112
  405. package/dist/core/tools/index.js.map +0 -1
  406. package/dist/core/tools/ls.d.ts +0 -37
  407. package/dist/core/tools/ls.d.ts.map +0 -1
  408. package/dist/core/tools/ls.js +0 -169
  409. package/dist/core/tools/ls.js.map +0 -1
  410. package/dist/core/tools/path-utils.d.ts +0 -8
  411. package/dist/core/tools/path-utils.d.ts.map +0 -1
  412. package/dist/core/tools/path-utils.js +0 -81
  413. package/dist/core/tools/path-utils.js.map +0 -1
  414. package/dist/core/tools/read.d.ts +0 -35
  415. package/dist/core/tools/read.d.ts.map +0 -1
  416. package/dist/core/tools/read.js +0 -232
  417. package/dist/core/tools/read.js.map +0 -1
  418. package/dist/core/tools/render-utils.d.ts +0 -21
  419. package/dist/core/tools/render-utils.d.ts.map +0 -1
  420. package/dist/core/tools/render-utils.js +0 -49
  421. package/dist/core/tools/render-utils.js.map +0 -1
  422. package/dist/core/tools/tool-definition-wrapper.d.ts +0 -14
  423. package/dist/core/tools/tool-definition-wrapper.d.ts.map +0 -1
  424. package/dist/core/tools/tool-definition-wrapper.js +0 -34
  425. package/dist/core/tools/tool-definition-wrapper.js.map +0 -1
  426. package/dist/core/tools/truncate.d.ts +0 -70
  427. package/dist/core/tools/truncate.d.ts.map +0 -1
  428. package/dist/core/tools/truncate.js +0 -205
  429. package/dist/core/tools/truncate.js.map +0 -1
  430. package/dist/core/tools/write.d.ts +0 -26
  431. package/dist/core/tools/write.d.ts.map +0 -1
  432. package/dist/core/tools/write.js +0 -213
  433. package/dist/core/tools/write.js.map +0 -1
  434. package/dist/index.d.ts +0 -28
  435. package/dist/index.d.ts.map +0 -1
  436. package/dist/index.js +0 -41
  437. package/dist/index.js.map +0 -1
  438. package/dist/main.d.ts +0 -12
  439. package/dist/main.d.ts.map +0 -1
  440. package/dist/main.js +0 -589
  441. package/dist/main.js.map +0 -1
  442. package/dist/migrations.d.ts +0 -33
  443. package/dist/migrations.d.ts.map +0 -1
  444. package/dist/migrations.js +0 -281
  445. package/dist/migrations.js.map +0 -1
  446. package/dist/modes/index.d.ts +0 -9
  447. package/dist/modes/index.d.ts.map +0 -1
  448. package/dist/modes/index.js +0 -8
  449. package/dist/modes/index.js.map +0 -1
  450. package/dist/modes/interactive/assets/clankolas.png +0 -0
  451. package/dist/modes/interactive/components/aery-splash.d.ts +0 -18
  452. package/dist/modes/interactive/components/aery-splash.d.ts.map +0 -1
  453. package/dist/modes/interactive/components/aery-splash.js +0 -60
  454. package/dist/modes/interactive/components/aery-splash.js.map +0 -1
  455. package/dist/modes/interactive/components/armin.d.ts +0 -34
  456. package/dist/modes/interactive/components/armin.d.ts.map +0 -1
  457. package/dist/modes/interactive/components/armin.js +0 -333
  458. package/dist/modes/interactive/components/armin.js.map +0 -1
  459. package/dist/modes/interactive/components/assistant-message.d.ts +0 -20
  460. package/dist/modes/interactive/components/assistant-message.d.ts.map +0 -1
  461. package/dist/modes/interactive/components/assistant-message.js +0 -121
  462. package/dist/modes/interactive/components/assistant-message.js.map +0 -1
  463. package/dist/modes/interactive/components/bash-execution.d.ts +0 -34
  464. package/dist/modes/interactive/components/bash-execution.d.ts.map +0 -1
  465. package/dist/modes/interactive/components/bash-execution.js +0 -175
  466. package/dist/modes/interactive/components/bash-execution.js.map +0 -1
  467. package/dist/modes/interactive/components/bordered-loader.d.ts +0 -16
  468. package/dist/modes/interactive/components/bordered-loader.d.ts.map +0 -1
  469. package/dist/modes/interactive/components/bordered-loader.js +0 -54
  470. package/dist/modes/interactive/components/bordered-loader.js.map +0 -1
  471. package/dist/modes/interactive/components/branch-summary-message.d.ts +0 -16
  472. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +0 -1
  473. package/dist/modes/interactive/components/branch-summary-message.js +0 -44
  474. package/dist/modes/interactive/components/branch-summary-message.js.map +0 -1
  475. package/dist/modes/interactive/components/compaction-summary-message.d.ts +0 -16
  476. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +0 -1
  477. package/dist/modes/interactive/components/compaction-summary-message.js +0 -45
  478. package/dist/modes/interactive/components/compaction-summary-message.js.map +0 -1
  479. package/dist/modes/interactive/components/config-selector.d.ts +0 -71
  480. package/dist/modes/interactive/components/config-selector.d.ts.map +0 -1
  481. package/dist/modes/interactive/components/config-selector.js +0 -481
  482. package/dist/modes/interactive/components/config-selector.js.map +0 -1
  483. package/dist/modes/interactive/components/countdown-timer.d.ts +0 -14
  484. package/dist/modes/interactive/components/countdown-timer.d.ts.map +0 -1
  485. package/dist/modes/interactive/components/countdown-timer.js +0 -33
  486. package/dist/modes/interactive/components/countdown-timer.js.map +0 -1
  487. package/dist/modes/interactive/components/custom-editor.d.ts +0 -21
  488. package/dist/modes/interactive/components/custom-editor.d.ts.map +0 -1
  489. package/dist/modes/interactive/components/custom-editor.js +0 -70
  490. package/dist/modes/interactive/components/custom-editor.js.map +0 -1
  491. package/dist/modes/interactive/components/custom-message.d.ts +0 -20
  492. package/dist/modes/interactive/components/custom-message.d.ts.map +0 -1
  493. package/dist/modes/interactive/components/custom-message.js +0 -79
  494. package/dist/modes/interactive/components/custom-message.js.map +0 -1
  495. package/dist/modes/interactive/components/daxnuts.d.ts +0 -23
  496. package/dist/modes/interactive/components/daxnuts.d.ts.map +0 -1
  497. package/dist/modes/interactive/components/daxnuts.js +0 -140
  498. package/dist/modes/interactive/components/daxnuts.js.map +0 -1
  499. package/dist/modes/interactive/components/diff.d.ts +0 -12
  500. package/dist/modes/interactive/components/diff.d.ts.map +0 -1
  501. package/dist/modes/interactive/components/diff.js +0 -133
  502. package/dist/modes/interactive/components/diff.js.map +0 -1
  503. package/dist/modes/interactive/components/dynamic-border.d.ts +0 -15
  504. package/dist/modes/interactive/components/dynamic-border.d.ts.map +0 -1
  505. package/dist/modes/interactive/components/dynamic-border.js +0 -21
  506. package/dist/modes/interactive/components/dynamic-border.js.map +0 -1
  507. package/dist/modes/interactive/components/earendil-announcement.d.ts +0 -5
  508. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +0 -1
  509. package/dist/modes/interactive/components/earendil-announcement.js +0 -40
  510. package/dist/modes/interactive/components/earendil-announcement.js.map +0 -1
  511. package/dist/modes/interactive/components/extension-editor.d.ts +0 -20
  512. package/dist/modes/interactive/components/extension-editor.d.ts.map +0 -1
  513. package/dist/modes/interactive/components/extension-editor.js +0 -111
  514. package/dist/modes/interactive/components/extension-editor.js.map +0 -1
  515. package/dist/modes/interactive/components/extension-input.d.ts +0 -23
  516. package/dist/modes/interactive/components/extension-input.d.ts.map +0 -1
  517. package/dist/modes/interactive/components/extension-input.js +0 -61
  518. package/dist/modes/interactive/components/extension-input.js.map +0 -1
  519. package/dist/modes/interactive/components/extension-selector.d.ts +0 -24
  520. package/dist/modes/interactive/components/extension-selector.d.ts.map +0 -1
  521. package/dist/modes/interactive/components/extension-selector.js +0 -78
  522. package/dist/modes/interactive/components/extension-selector.js.map +0 -1
  523. package/dist/modes/interactive/components/footer.d.ts +0 -27
  524. package/dist/modes/interactive/components/footer.d.ts.map +0 -1
  525. package/dist/modes/interactive/components/footer.js +0 -201
  526. package/dist/modes/interactive/components/footer.js.map +0 -1
  527. package/dist/modes/interactive/components/index.d.ts +0 -32
  528. package/dist/modes/interactive/components/index.d.ts.map +0 -1
  529. package/dist/modes/interactive/components/index.js +0 -33
  530. package/dist/modes/interactive/components/index.js.map +0 -1
  531. package/dist/modes/interactive/components/keybinding-hints.d.ts +0 -8
  532. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +0 -1
  533. package/dist/modes/interactive/components/keybinding-hints.js +0 -22
  534. package/dist/modes/interactive/components/keybinding-hints.js.map +0 -1
  535. package/dist/modes/interactive/components/login-dialog.d.ts +0 -46
  536. package/dist/modes/interactive/components/login-dialog.d.ts.map +0 -1
  537. package/dist/modes/interactive/components/login-dialog.js +0 -158
  538. package/dist/modes/interactive/components/login-dialog.js.map +0 -1
  539. package/dist/modes/interactive/components/model-selector.d.ts +0 -47
  540. package/dist/modes/interactive/components/model-selector.d.ts.map +0 -1
  541. package/dist/modes/interactive/components/model-selector.js +0 -278
  542. package/dist/modes/interactive/components/model-selector.js.map +0 -1
  543. package/dist/modes/interactive/components/oauth-selector.d.ts +0 -29
  544. package/dist/modes/interactive/components/oauth-selector.d.ts.map +0 -1
  545. package/dist/modes/interactive/components/oauth-selector.js +0 -141
  546. package/dist/modes/interactive/components/oauth-selector.js.map +0 -1
  547. package/dist/modes/interactive/components/scoped-models-selector.d.ts +0 -42
  548. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +0 -1
  549. package/dist/modes/interactive/components/scoped-models-selector.js +0 -290
  550. package/dist/modes/interactive/components/scoped-models-selector.js.map +0 -1
  551. package/dist/modes/interactive/components/session-selector-search.d.ts +0 -23
  552. package/dist/modes/interactive/components/session-selector-search.d.ts.map +0 -1
  553. package/dist/modes/interactive/components/session-selector-search.js +0 -155
  554. package/dist/modes/interactive/components/session-selector-search.js.map +0 -1
  555. package/dist/modes/interactive/components/session-selector.d.ts +0 -96
  556. package/dist/modes/interactive/components/session-selector.d.ts.map +0 -1
  557. package/dist/modes/interactive/components/session-selector.js +0 -861
  558. package/dist/modes/interactive/components/session-selector.js.map +0 -1
  559. package/dist/modes/interactive/components/settings-selector.d.ts +0 -67
  560. package/dist/modes/interactive/components/settings-selector.d.ts.map +0 -1
  561. package/dist/modes/interactive/components/settings-selector.js +0 -373
  562. package/dist/modes/interactive/components/settings-selector.js.map +0 -1
  563. package/dist/modes/interactive/components/show-images-selector.d.ts +0 -10
  564. package/dist/modes/interactive/components/show-images-selector.d.ts.map +0 -1
  565. package/dist/modes/interactive/components/show-images-selector.js +0 -39
  566. package/dist/modes/interactive/components/show-images-selector.js.map +0 -1
  567. package/dist/modes/interactive/components/skill-invocation-message.d.ts +0 -17
  568. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +0 -1
  569. package/dist/modes/interactive/components/skill-invocation-message.js +0 -47
  570. package/dist/modes/interactive/components/skill-invocation-message.js.map +0 -1
  571. package/dist/modes/interactive/components/theme-selector.d.ts +0 -11
  572. package/dist/modes/interactive/components/theme-selector.d.ts.map +0 -1
  573. package/dist/modes/interactive/components/theme-selector.js +0 -50
  574. package/dist/modes/interactive/components/theme-selector.js.map +0 -1
  575. package/dist/modes/interactive/components/thinking-selector.d.ts +0 -11
  576. package/dist/modes/interactive/components/thinking-selector.d.ts.map +0 -1
  577. package/dist/modes/interactive/components/thinking-selector.js +0 -51
  578. package/dist/modes/interactive/components/thinking-selector.js.map +0 -1
  579. package/dist/modes/interactive/components/tool-execution.d.ts +0 -63
  580. package/dist/modes/interactive/components/tool-execution.d.ts.map +0 -1
  581. package/dist/modes/interactive/components/tool-execution.js +0 -295
  582. package/dist/modes/interactive/components/tool-execution.js.map +0 -1
  583. package/dist/modes/interactive/components/tree-selector.d.ts +0 -89
  584. package/dist/modes/interactive/components/tree-selector.d.ts.map +0 -1
  585. package/dist/modes/interactive/components/tree-selector.js +0 -1092
  586. package/dist/modes/interactive/components/tree-selector.js.map +0 -1
  587. package/dist/modes/interactive/components/user-message-selector.d.ts +0 -30
  588. package/dist/modes/interactive/components/user-message-selector.d.ts.map +0 -1
  589. package/dist/modes/interactive/components/user-message-selector.js +0 -114
  590. package/dist/modes/interactive/components/user-message-selector.js.map +0 -1
  591. package/dist/modes/interactive/components/user-message.d.ts +0 -10
  592. package/dist/modes/interactive/components/user-message.d.ts.map +0 -1
  593. package/dist/modes/interactive/components/user-message.js +0 -29
  594. package/dist/modes/interactive/components/user-message.js.map +0 -1
  595. package/dist/modes/interactive/components/visual-truncate.d.ts +0 -24
  596. package/dist/modes/interactive/components/visual-truncate.d.ts.map +0 -1
  597. package/dist/modes/interactive/components/visual-truncate.js +0 -33
  598. package/dist/modes/interactive/components/visual-truncate.js.map +0 -1
  599. package/dist/modes/interactive/interactive-mode.d.ts +0 -359
  600. package/dist/modes/interactive/interactive-mode.d.ts.map +0 -1
  601. package/dist/modes/interactive/interactive-mode.js +0 -4573
  602. package/dist/modes/interactive/interactive-mode.js.map +0 -1
  603. package/dist/modes/interactive/theme/aery.json +0 -84
  604. package/dist/modes/interactive/theme/catppuccin-mocha.json +0 -81
  605. package/dist/modes/interactive/theme/dark.json +0 -85
  606. package/dist/modes/interactive/theme/dracula.json +0 -81
  607. package/dist/modes/interactive/theme/light.json +0 -84
  608. package/dist/modes/interactive/theme/nord.json +0 -81
  609. package/dist/modes/interactive/theme/theme-schema.json +0 -335
  610. package/dist/modes/interactive/theme/theme.d.ts +0 -81
  611. package/dist/modes/interactive/theme/theme.d.ts.map +0 -1
  612. package/dist/modes/interactive/theme/theme.js +0 -975
  613. package/dist/modes/interactive/theme/theme.js.map +0 -1
  614. package/dist/modes/interactive/theme/tokyo-night.json +0 -81
  615. package/dist/modes/print-mode.d.ts +0 -28
  616. package/dist/modes/print-mode.d.ts.map +0 -1
  617. package/dist/modes/print-mode.js +0 -131
  618. package/dist/modes/print-mode.js.map +0 -1
  619. package/dist/modes/rpc/jsonl.d.ts +0 -17
  620. package/dist/modes/rpc/jsonl.d.ts.map +0 -1
  621. package/dist/modes/rpc/jsonl.js +0 -49
  622. package/dist/modes/rpc/jsonl.js.map +0 -1
  623. package/dist/modes/rpc/rpc-client.d.ts +0 -224
  624. package/dist/modes/rpc/rpc-client.d.ts.map +0 -1
  625. package/dist/modes/rpc/rpc-client.js +0 -410
  626. package/dist/modes/rpc/rpc-client.js.map +0 -1
  627. package/dist/modes/rpc/rpc-mode.d.ts +0 -20
  628. package/dist/modes/rpc/rpc-mode.d.ts.map +0 -1
  629. package/dist/modes/rpc/rpc-mode.js +0 -597
  630. package/dist/modes/rpc/rpc-mode.js.map +0 -1
  631. package/dist/modes/rpc/rpc-types.d.ts +0 -419
  632. package/dist/modes/rpc/rpc-types.d.ts.map +0 -1
  633. package/dist/modes/rpc/rpc-types.js +0 -8
  634. package/dist/modes/rpc/rpc-types.js.map +0 -1
  635. package/dist/package-manager-cli.d.ts +0 -4
  636. package/dist/package-manager-cli.d.ts.map +0 -1
  637. package/dist/package-manager-cli.js +0 -468
  638. package/dist/package-manager-cli.js.map +0 -1
  639. package/dist/utils/aery-user-agent.d.ts +0 -2
  640. package/dist/utils/aery-user-agent.d.ts.map +0 -1
  641. package/dist/utils/aery-user-agent.js +0 -5
  642. package/dist/utils/aery-user-agent.js.map +0 -1
  643. package/dist/utils/changelog.d.ts +0 -21
  644. package/dist/utils/changelog.d.ts.map +0 -1
  645. package/dist/utils/changelog.js +0 -87
  646. package/dist/utils/changelog.js.map +0 -1
  647. package/dist/utils/child-process.d.ts +0 -11
  648. package/dist/utils/child-process.d.ts.map +0 -1
  649. package/dist/utils/child-process.js +0 -78
  650. package/dist/utils/child-process.js.map +0 -1
  651. package/dist/utils/clipboard-image.d.ts +0 -11
  652. package/dist/utils/clipboard-image.d.ts.map +0 -1
  653. package/dist/utils/clipboard-image.js +0 -245
  654. package/dist/utils/clipboard-image.js.map +0 -1
  655. package/dist/utils/clipboard-native.d.ts +0 -8
  656. package/dist/utils/clipboard-native.d.ts.map +0 -1
  657. package/dist/utils/clipboard-native.js +0 -14
  658. package/dist/utils/clipboard-native.js.map +0 -1
  659. package/dist/utils/clipboard.d.ts +0 -2
  660. package/dist/utils/clipboard.d.ts.map +0 -1
  661. package/dist/utils/clipboard.js +0 -110
  662. package/dist/utils/clipboard.js.map +0 -1
  663. package/dist/utils/exif-orientation.d.ts +0 -5
  664. package/dist/utils/exif-orientation.d.ts.map +0 -1
  665. package/dist/utils/exif-orientation.js +0 -158
  666. package/dist/utils/exif-orientation.js.map +0 -1
  667. package/dist/utils/frontmatter.d.ts +0 -8
  668. package/dist/utils/frontmatter.d.ts.map +0 -1
  669. package/dist/utils/frontmatter.js +0 -26
  670. package/dist/utils/frontmatter.js.map +0 -1
  671. package/dist/utils/fs-watch.d.ts +0 -5
  672. package/dist/utils/fs-watch.d.ts.map +0 -1
  673. package/dist/utils/fs-watch.js +0 -25
  674. package/dist/utils/fs-watch.js.map +0 -1
  675. package/dist/utils/git.d.ts +0 -26
  676. package/dist/utils/git.d.ts.map +0 -1
  677. package/dist/utils/git.js +0 -163
  678. package/dist/utils/git.js.map +0 -1
  679. package/dist/utils/image-convert.d.ts +0 -9
  680. package/dist/utils/image-convert.d.ts.map +0 -1
  681. package/dist/utils/image-convert.js +0 -39
  682. package/dist/utils/image-convert.js.map +0 -1
  683. package/dist/utils/image-resize.d.ts +0 -36
  684. package/dist/utils/image-resize.d.ts.map +0 -1
  685. package/dist/utils/image-resize.js +0 -137
  686. package/dist/utils/image-resize.js.map +0 -1
  687. package/dist/utils/mime.d.ts +0 -2
  688. package/dist/utils/mime.d.ts.map +0 -1
  689. package/dist/utils/mime.js +0 -26
  690. package/dist/utils/mime.js.map +0 -1
  691. package/dist/utils/paths.d.ts +0 -14
  692. package/dist/utils/paths.d.ts.map +0 -1
  693. package/dist/utils/paths.js +0 -34
  694. package/dist/utils/paths.js.map +0 -1
  695. package/dist/utils/photon.d.ts +0 -21
  696. package/dist/utils/photon.d.ts.map +0 -1
  697. package/dist/utils/photon.js +0 -121
  698. package/dist/utils/photon.js.map +0 -1
  699. package/dist/utils/shell.d.ts +0 -30
  700. package/dist/utils/shell.d.ts.map +0 -1
  701. package/dist/utils/shell.js +0 -190
  702. package/dist/utils/shell.js.map +0 -1
  703. package/dist/utils/sleep.d.ts +0 -5
  704. package/dist/utils/sleep.d.ts.map +0 -1
  705. package/dist/utils/sleep.js +0 -17
  706. package/dist/utils/sleep.js.map +0 -1
  707. package/dist/utils/tools-manager.d.ts +0 -3
  708. package/dist/utils/tools-manager.d.ts.map +0 -1
  709. package/dist/utils/tools-manager.js +0 -256
  710. package/dist/utils/tools-manager.js.map +0 -1
  711. package/dist/utils/version-check.d.ts +0 -7
  712. package/dist/utils/version-check.d.ts.map +0 -1
  713. package/dist/utils/version-check.js +0 -70
  714. package/dist/utils/version-check.js.map +0 -1
@@ -1,232 +0,0 @@
1
- import { Text } from "@eminent337/aery-tui";
2
- import { constants } from "fs";
3
- import { access as fsAccess, readFile as fsReadFile } from "fs/promises";
4
- import { Type } from "typebox";
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,sBAAsB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,MAAM,IA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M,CAAC,KAAK,CAAC,CAAC;oBAC7B,CAAC;gBAAA,CACD,CAAC,EAAE,CAAC;YAAA,CACL,CACD,CAAC;QAAA,CACF;QACD,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE;YAChC,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;YAC1C,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,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 { Api, ImageContent, Model, TextContent } from \"@eminent337/aery-ai\";\nimport type { AgentTool } from \"@eminent337/aery-core\";\nimport { Text } from \"@eminent337/aery-tui\";\nimport { constants } from \"fs\";\nimport { access as fsAccess, readFile as fsReadFile } from \"fs/promises\";\nimport { type Static, Type } from \"typebox\";\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 "@eminent337/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,qBAAqB,CAAC;AAKrE,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 \"@eminent337/aery-ai\";\nimport { getCapabilities, getImageDimensions, imageFallback } from \"@eminent337/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 || !result.content) 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 "@eminent337/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 || !result.content)
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,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,UAAU,WAAW,CAAC,IAAa,EAAU;IAClD,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACxC,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;IAC1B,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;IACtC,CAAC;IACD,OAAO,IAAI,CAAC;AAAA,CACZ;AAED,MAAM,UAAU,GAAG,CAAC,KAAc,EAAiB;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,EAAE,CAAC;IAC7B,OAAO,IAAI,CAAC;AAAA,CACZ;AAED,MAAM,UAAU,WAAW,CAAC,IAAY,EAAU;IAC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,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YAClG,OAAO,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAAA,CACrC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;QACb,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,KAAK,eAAe,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC;IACrE,CAAC;IAED,OAAO,MAAM,CAAC;AAAA,CACd;AAOD,MAAM,UAAU,cAAc,CAAC,KAAkD,EAAU;IAC1F,OAAO,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;AAAA,CAC1C","sourcesContent":["import * as os from \"node:os\";\nimport type { ImageContent, TextContent } from \"@eminent337/aery-ai\";\nimport { getCapabilities, getImageDimensions, imageFallback } from \"@eminent337/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 || !result.content) 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 "@eminent337/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,uBAAuB,CAAC;AACvD,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 \"@eminent337/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 \"@eminent337/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"]}