@travisennis/acai 0.0.7 → 0.0.9

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 (486) hide show
  1. package/README.md +76 -27
  2. package/dist/agent/index.d.ts +21 -25
  3. package/dist/agent/index.d.ts.map +1 -1
  4. package/dist/agent/index.js +145 -103
  5. package/dist/cli.d.ts +2 -2
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/cli.js +23 -17
  8. package/dist/commands/add-directory/index.d.ts +3 -0
  9. package/dist/commands/add-directory/index.d.ts.map +1 -0
  10. package/dist/commands/{add-directory-command.js → add-directory/index.js} +6 -10
  11. package/dist/commands/add-directory/types.d.ts +6 -0
  12. package/dist/commands/add-directory/types.d.ts.map +1 -0
  13. package/dist/commands/add-directory/types.js +1 -0
  14. package/dist/commands/add-directory/utils.d.ts +3 -0
  15. package/dist/commands/add-directory/utils.d.ts.map +1 -0
  16. package/dist/commands/add-directory/utils.js +15 -0
  17. package/dist/commands/clear/index.d.ts +3 -0
  18. package/dist/commands/clear/index.d.ts.map +1 -0
  19. package/dist/commands/{clear-command.js → clear/index.js} +0 -2
  20. package/dist/commands/copy/index.d.ts +3 -0
  21. package/dist/commands/copy/index.d.ts.map +1 -0
  22. package/dist/commands/{copy-command.js → copy/index.js} +4 -26
  23. package/dist/commands/copy/types.d.ts +3 -0
  24. package/dist/commands/copy/types.d.ts.map +1 -0
  25. package/dist/commands/copy/types.js +1 -0
  26. package/dist/commands/copy/utils.d.ts +3 -0
  27. package/dist/commands/copy/utils.d.ts.map +1 -0
  28. package/dist/commands/copy/utils.js +22 -0
  29. package/dist/commands/{exit-command.d.ts → exit/index.d.ts} +4 -4
  30. package/dist/commands/exit/index.d.ts.map +1 -0
  31. package/dist/commands/exit/index.js +21 -0
  32. package/dist/commands/exit/types.d.ts +8 -0
  33. package/dist/commands/exit/types.d.ts.map +1 -0
  34. package/dist/commands/exit/types.js +1 -0
  35. package/dist/commands/exit/utils.d.ts +2 -0
  36. package/dist/commands/exit/utils.d.ts.map +1 -0
  37. package/dist/commands/exit/utils.js +13 -0
  38. package/dist/commands/generate-rules/index.d.ts +3 -0
  39. package/dist/commands/generate-rules/index.d.ts.map +1 -0
  40. package/dist/commands/{generate-rules-command.js → generate-rules/index.js} +57 -96
  41. package/dist/commands/generate-rules/utils.d.ts +5 -0
  42. package/dist/commands/generate-rules/utils.d.ts.map +1 -0
  43. package/dist/commands/generate-rules/utils.js +25 -0
  44. package/dist/commands/handoff/index.d.ts +3 -0
  45. package/dist/commands/handoff/index.d.ts.map +1 -0
  46. package/dist/commands/handoff/index.js +97 -0
  47. package/dist/commands/handoff/utils.d.ts +4 -0
  48. package/dist/commands/handoff/utils.d.ts.map +1 -0
  49. package/dist/commands/{handoff-command.js → handoff/utils.js} +24 -92
  50. package/dist/commands/health/index.d.ts +3 -0
  51. package/dist/commands/health/index.d.ts.map +1 -0
  52. package/dist/commands/health/index.js +56 -0
  53. package/dist/commands/health/utils.d.ts +15 -0
  54. package/dist/commands/health/utils.d.ts.map +1 -0
  55. package/dist/commands/health/utils.js +52 -0
  56. package/dist/commands/{help-command.d.ts → help/index.d.ts} +2 -2
  57. package/dist/commands/help/index.d.ts.map +1 -0
  58. package/dist/commands/{help-command.js → help/index.js} +1 -1
  59. package/dist/commands/history/index.d.ts +3 -0
  60. package/dist/commands/history/index.d.ts.map +1 -0
  61. package/dist/commands/{history-command.js → history/index.js} +16 -100
  62. package/dist/commands/history/types.d.ts +11 -0
  63. package/dist/commands/history/types.d.ts.map +1 -0
  64. package/dist/commands/history/types.js +1 -0
  65. package/dist/commands/history/utils.d.ts +4 -0
  66. package/dist/commands/history/utils.d.ts.map +1 -0
  67. package/dist/commands/history/utils.js +86 -0
  68. package/dist/commands/init/index.d.ts +3 -0
  69. package/dist/commands/init/index.d.ts.map +1 -0
  70. package/dist/commands/{init-command.js → init/index.js} +16 -7
  71. package/dist/commands/init-project/index.d.ts +3 -0
  72. package/dist/commands/init-project/index.d.ts.map +1 -0
  73. package/dist/commands/init-project/index.js +51 -0
  74. package/dist/commands/init-project/utils.d.ts +9 -0
  75. package/dist/commands/init-project/utils.d.ts.map +1 -0
  76. package/dist/commands/init-project/utils.js +43 -0
  77. package/dist/commands/list-directories/index.d.ts +3 -0
  78. package/dist/commands/list-directories/index.d.ts.map +1 -0
  79. package/dist/commands/{list-directories-command.js → list-directories/index.js} +1 -1
  80. package/dist/commands/list-tools/index.d.ts +3 -0
  81. package/dist/commands/list-tools/index.d.ts.map +1 -0
  82. package/dist/commands/{list-tools-command.js → list-tools/index.js} +4 -16
  83. package/dist/commands/manager.d.ts +2 -2
  84. package/dist/commands/manager.d.ts.map +1 -1
  85. package/dist/commands/manager.js +35 -43
  86. package/dist/commands/model/index.d.ts +3 -0
  87. package/dist/commands/model/index.d.ts.map +1 -0
  88. package/dist/commands/{model-command.js → model/index.js} +15 -52
  89. package/dist/commands/model/utils.d.ts +3 -0
  90. package/dist/commands/model/utils.d.ts.map +1 -0
  91. package/dist/commands/model/utils.js +5 -0
  92. package/dist/commands/{paste-command.d.ts → paste/index.d.ts} +2 -2
  93. package/dist/commands/paste/index.d.ts.map +1 -0
  94. package/dist/commands/{paste-command.js → paste/index.js} +6 -111
  95. package/dist/commands/paste/utils.d.ts +5 -0
  96. package/dist/commands/paste/utils.d.ts.map +1 -0
  97. package/dist/commands/paste/utils.js +86 -0
  98. package/dist/commands/pickup/index.d.ts +3 -0
  99. package/dist/commands/pickup/index.d.ts.map +1 -0
  100. package/dist/commands/pickup/index.js +138 -0
  101. package/dist/commands/pickup/types.d.ts +6 -0
  102. package/dist/commands/pickup/types.d.ts.map +1 -0
  103. package/dist/commands/pickup/types.js +1 -0
  104. package/dist/commands/pickup/utils.d.ts +7 -0
  105. package/dist/commands/pickup/utils.d.ts.map +1 -0
  106. package/dist/commands/pickup/utils.js +56 -0
  107. package/dist/commands/prompt/index.d.ts +5 -0
  108. package/dist/commands/prompt/index.d.ts.map +1 -0
  109. package/dist/commands/prompt/index.js +122 -0
  110. package/dist/commands/prompt/types.d.ts +15 -0
  111. package/dist/commands/prompt/types.d.ts.map +1 -0
  112. package/dist/commands/prompt/types.js +1 -0
  113. package/dist/commands/prompt/utils.d.ts +12 -0
  114. package/dist/commands/prompt/utils.d.ts.map +1 -0
  115. package/dist/commands/prompt/utils.js +107 -0
  116. package/dist/commands/remove-directory/index.d.ts +3 -0
  117. package/dist/commands/remove-directory/index.d.ts.map +1 -0
  118. package/dist/commands/{remove-directory-command.js → remove-directory/index.js} +2 -2
  119. package/dist/commands/reset/index.d.ts +3 -0
  120. package/dist/commands/reset/index.d.ts.map +1 -0
  121. package/dist/commands/{reset-command.js → reset/index.js} +7 -2
  122. package/dist/commands/reset/types.d.ts +1 -0
  123. package/dist/commands/reset/types.d.ts.map +1 -0
  124. package/dist/commands/reset/types.js +3 -0
  125. package/dist/commands/resources/index.d.ts +3 -0
  126. package/dist/commands/resources/index.d.ts.map +1 -0
  127. package/dist/commands/resources/index.js +84 -0
  128. package/dist/commands/review/index.d.ts +3 -0
  129. package/dist/commands/review/index.d.ts.map +1 -0
  130. package/dist/commands/review/index.js +126 -0
  131. package/dist/commands/review/types.d.ts +12 -0
  132. package/dist/commands/review/types.d.ts.map +1 -0
  133. package/dist/commands/review/types.js +1 -0
  134. package/dist/commands/review/utils.d.ts +4 -0
  135. package/dist/commands/review/utils.d.ts.map +1 -0
  136. package/dist/commands/review/utils.js +87 -0
  137. package/dist/commands/save/index.d.ts +3 -0
  138. package/dist/commands/save/index.d.ts.map +1 -0
  139. package/dist/commands/{save-command.js → save/index.js} +3 -3
  140. package/dist/commands/session/index.d.ts +3 -0
  141. package/dist/commands/session/index.d.ts.map +1 -0
  142. package/dist/commands/session/index.js +230 -0
  143. package/dist/commands/session/types.d.ts +20 -0
  144. package/dist/commands/session/types.d.ts.map +1 -0
  145. package/dist/commands/session/types.js +7 -0
  146. package/dist/commands/share/html-renderer.d.ts +25 -0
  147. package/dist/commands/share/html-renderer.d.ts.map +1 -0
  148. package/dist/commands/share/html-renderer.js +384 -0
  149. package/dist/commands/share/index.d.ts +3 -0
  150. package/dist/commands/share/index.d.ts.map +1 -0
  151. package/dist/commands/share/index.js +122 -0
  152. package/dist/commands/shell/index.d.ts +3 -0
  153. package/dist/commands/shell/index.d.ts.map +1 -0
  154. package/dist/commands/{shell-command.js → shell/index.js} +3 -3
  155. package/dist/commands/types.d.ts +2 -2
  156. package/dist/commands/types.d.ts.map +1 -1
  157. package/dist/config.d.ts +25 -7
  158. package/dist/config.d.ts.map +1 -1
  159. package/dist/config.js +45 -20
  160. package/dist/dedent.d.ts.map +1 -1
  161. package/dist/dedent.js +7 -7
  162. package/dist/execution/index.d.ts +1 -0
  163. package/dist/execution/index.d.ts.map +1 -1
  164. package/dist/execution/index.js +60 -64
  165. package/dist/formatting.d.ts +27 -0
  166. package/dist/formatting.d.ts.map +1 -1
  167. package/dist/formatting.js +40 -0
  168. package/dist/index.d.ts.map +1 -1
  169. package/dist/index.js +194 -95
  170. package/dist/logger.d.ts.map +1 -1
  171. package/dist/logger.js +4 -11
  172. package/dist/mentions.d.ts.map +1 -1
  173. package/dist/mentions.js +3 -53
  174. package/dist/middleware/audit-message.d.ts +2 -2
  175. package/dist/middleware/audit-message.d.ts.map +1 -1
  176. package/dist/middleware/audit-message.js +40 -2
  177. package/dist/middleware/cache.d.ts +2 -2
  178. package/dist/middleware/cache.d.ts.map +1 -1
  179. package/dist/middleware/cache.js +111 -27
  180. package/dist/middleware/rate-limit.d.ts +2 -2
  181. package/dist/middleware/rate-limit.d.ts.map +1 -1
  182. package/dist/middleware/rate-limit.js +1 -0
  183. package/dist/models/ai-config.d.ts.map +1 -1
  184. package/dist/models/ai-config.js +46 -29
  185. package/dist/models/anthropic-provider.d.ts +14 -13
  186. package/dist/models/anthropic-provider.d.ts.map +1 -1
  187. package/dist/models/deepseek-provider.d.ts +9 -8
  188. package/dist/models/deepseek-provider.d.ts.map +1 -1
  189. package/dist/models/google-provider.d.ts +10 -9
  190. package/dist/models/google-provider.d.ts.map +1 -1
  191. package/dist/models/groq-provider.d.ts +8 -7
  192. package/dist/models/groq-provider.d.ts.map +1 -1
  193. package/dist/models/manager.d.ts +7 -4
  194. package/dist/models/manager.d.ts.map +1 -1
  195. package/dist/models/manager.js +5 -25
  196. package/dist/models/openai-provider.d.ts +14 -10
  197. package/dist/models/openai-provider.d.ts.map +1 -1
  198. package/dist/models/openai-provider.js +39 -0
  199. package/dist/models/opencode-zen-provider.d.ts +24 -0
  200. package/dist/models/opencode-zen-provider.d.ts.map +1 -0
  201. package/dist/models/opencode-zen-provider.js +94 -0
  202. package/dist/models/openrouter-provider.d.ts +35 -29
  203. package/dist/models/openrouter-provider.d.ts.map +1 -1
  204. package/dist/models/openrouter-provider.js +108 -80
  205. package/dist/models/providers.d.ts +4 -4
  206. package/dist/models/providers.d.ts.map +1 -1
  207. package/dist/models/providers.js +7 -1
  208. package/dist/models/xai-provider.d.ts +9 -8
  209. package/dist/models/xai-provider.d.ts.map +1 -1
  210. package/dist/prompts/manager.d.ts +1 -1
  211. package/dist/prompts/manager.d.ts.map +1 -1
  212. package/dist/prompts/manager.js +1 -1
  213. package/dist/prompts.d.ts +12 -2
  214. package/dist/prompts.d.ts.map +1 -1
  215. package/dist/prompts.js +74 -411
  216. package/dist/repl/project-status.d.ts +19 -0
  217. package/dist/repl/project-status.d.ts.map +1 -0
  218. package/dist/repl/project-status.js +78 -0
  219. package/dist/repl-new.d.ts +18 -4
  220. package/dist/repl-new.d.ts.map +1 -1
  221. package/dist/repl-new.js +256 -43
  222. package/dist/{messages.d.ts → sessions/manager.d.ts} +10 -4
  223. package/dist/sessions/manager.d.ts.map +1 -0
  224. package/dist/{messages.js → sessions/manager.js} +62 -14
  225. package/dist/skills.d.ts +0 -4
  226. package/dist/skills.d.ts.map +1 -1
  227. package/dist/skills.js +100 -59
  228. package/dist/stdin.d.ts +9 -0
  229. package/dist/stdin.d.ts.map +1 -0
  230. package/dist/stdin.js +26 -0
  231. package/dist/terminal/control.d.ts +1 -0
  232. package/dist/terminal/control.d.ts.map +1 -1
  233. package/dist/terminal/control.js +29 -6
  234. package/dist/terminal/formatting.d.ts +1 -2
  235. package/dist/terminal/formatting.d.ts.map +1 -1
  236. package/dist/terminal/formatting.js +1 -2
  237. package/dist/terminal/keys.d.ts +211 -0
  238. package/dist/terminal/keys.d.ts.map +1 -0
  239. package/dist/terminal/keys.js +546 -0
  240. package/dist/terminal/segmenter.d.ts +6 -0
  241. package/dist/terminal/segmenter.d.ts.map +1 -0
  242. package/dist/terminal/segmenter.js +11 -0
  243. package/dist/terminal/select-prompt.d.ts.map +1 -1
  244. package/dist/terminal/select-prompt.js +9 -21
  245. package/dist/terminal/string-width.d.ts.map +1 -1
  246. package/dist/terminal/string-width.js +40 -21
  247. package/dist/terminal/strip-ansi.d.ts.map +1 -1
  248. package/dist/terminal/strip-ansi.js +9 -15
  249. package/dist/tokens/tracker.d.ts.map +1 -1
  250. package/dist/tokens/tracker.js +58 -16
  251. package/dist/tools/bash.d.ts +9 -11
  252. package/dist/tools/bash.d.ts.map +1 -1
  253. package/dist/tools/bash.js +104 -123
  254. package/dist/tools/directory-tree.d.ts +9 -7
  255. package/dist/tools/directory-tree.d.ts.map +1 -1
  256. package/dist/tools/directory-tree.js +89 -70
  257. package/dist/tools/dynamic-tool-loader.d.ts +22 -4
  258. package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
  259. package/dist/tools/dynamic-tool-loader.js +39 -44
  260. package/dist/tools/edit-file.d.ts +6 -16
  261. package/dist/tools/edit-file.d.ts.map +1 -1
  262. package/dist/tools/edit-file.js +19 -76
  263. package/dist/tools/glob.d.ts +15 -16
  264. package/dist/tools/glob.d.ts.map +1 -1
  265. package/dist/tools/glob.js +77 -119
  266. package/dist/tools/grep.d.ts +19 -22
  267. package/dist/tools/grep.d.ts.map +1 -1
  268. package/dist/tools/grep.js +61 -108
  269. package/dist/tools/index.d.ts +200 -179
  270. package/dist/tools/index.d.ts.map +1 -1
  271. package/dist/tools/index.js +17 -315
  272. package/dist/tools/ls.d.ts +26 -0
  273. package/dist/tools/ls.d.ts.map +1 -0
  274. package/dist/tools/ls.js +80 -0
  275. package/dist/tools/read-file.d.ts +15 -15
  276. package/dist/tools/read-file.d.ts.map +1 -1
  277. package/dist/tools/read-file.js +49 -82
  278. package/dist/tools/save-file.d.ts +4 -4
  279. package/dist/tools/save-file.d.ts.map +1 -1
  280. package/dist/tools/save-file.js +37 -66
  281. package/dist/tools/think.d.ts +4 -4
  282. package/dist/tools/think.d.ts.map +1 -1
  283. package/dist/tools/think.js +9 -38
  284. package/dist/tools/types.d.ts +5 -25
  285. package/dist/tools/types.d.ts.map +1 -1
  286. package/dist/tools/types.js +0 -9
  287. package/dist/tui/autocomplete/attachment-provider.d.ts +18 -0
  288. package/dist/tui/autocomplete/attachment-provider.d.ts.map +1 -0
  289. package/dist/tui/autocomplete/attachment-provider.js +159 -0
  290. package/dist/tui/autocomplete/base-provider.d.ts +17 -0
  291. package/dist/tui/autocomplete/base-provider.d.ts.map +1 -0
  292. package/dist/tui/autocomplete/base-provider.js +1 -0
  293. package/dist/tui/autocomplete/combined-provider.d.ts +20 -0
  294. package/dist/tui/autocomplete/combined-provider.d.ts.map +1 -0
  295. package/dist/tui/autocomplete/combined-provider.js +61 -0
  296. package/dist/tui/autocomplete/command-provider.d.ts +20 -0
  297. package/dist/tui/autocomplete/command-provider.d.ts.map +1 -0
  298. package/dist/tui/autocomplete/command-provider.js +90 -0
  299. package/dist/tui/autocomplete/file-search-provider.d.ts +16 -0
  300. package/dist/tui/autocomplete/file-search-provider.d.ts.map +1 -0
  301. package/dist/tui/autocomplete/file-search-provider.js +123 -0
  302. package/dist/tui/autocomplete/path-provider.d.ts +21 -0
  303. package/dist/tui/autocomplete/path-provider.d.ts.map +1 -0
  304. package/dist/tui/autocomplete/path-provider.js +164 -0
  305. package/dist/tui/autocomplete/utils.d.ts +16 -0
  306. package/dist/tui/autocomplete/utils.d.ts.map +1 -0
  307. package/dist/tui/autocomplete/utils.js +137 -0
  308. package/dist/tui/autocomplete.d.ts +12 -43
  309. package/dist/tui/autocomplete.d.ts.map +1 -1
  310. package/dist/tui/autocomplete.js +20 -465
  311. package/dist/tui/components/box.d.ts.map +1 -1
  312. package/dist/tui/components/box.js +16 -10
  313. package/dist/tui/components/editor.d.ts +6 -2
  314. package/dist/tui/components/editor.d.ts.map +1 -1
  315. package/dist/tui/components/editor.js +166 -107
  316. package/dist/tui/components/footer.d.ts +20 -7
  317. package/dist/tui/components/footer.d.ts.map +1 -1
  318. package/dist/tui/components/footer.js +89 -196
  319. package/dist/tui/components/input.d.ts.map +1 -1
  320. package/dist/tui/components/input.js +8 -7
  321. package/dist/tui/components/loader.d.ts +2 -1
  322. package/dist/tui/components/loader.d.ts.map +1 -1
  323. package/dist/tui/components/loader.js +7 -2
  324. package/dist/tui/components/markdown.d.ts +5 -4
  325. package/dist/tui/components/markdown.d.ts.map +1 -1
  326. package/dist/tui/components/markdown.js +51 -40
  327. package/dist/tui/components/modal.d.ts.map +1 -1
  328. package/dist/tui/components/modal.js +9 -8
  329. package/dist/tui/components/notification.d.ts +28 -0
  330. package/dist/tui/components/notification.d.ts.map +1 -0
  331. package/dist/tui/components/notification.js +64 -0
  332. package/dist/tui/components/progress-bar.d.ts.map +1 -1
  333. package/dist/tui/components/progress-bar.js +3 -15
  334. package/dist/tui/components/select-list.d.ts +0 -15
  335. package/dist/tui/components/select-list.d.ts.map +1 -1
  336. package/dist/tui/components/select-list.js +5 -28
  337. package/dist/tui/components/tool-execution.d.ts +3 -6
  338. package/dist/tui/components/tool-execution.d.ts.map +1 -1
  339. package/dist/tui/components/tool-execution.js +26 -38
  340. package/dist/tui/components/welcome.d.ts +8 -1
  341. package/dist/tui/components/welcome.d.ts.map +1 -1
  342. package/dist/tui/components/welcome.js +45 -6
  343. package/dist/tui/editor-launcher.d.ts +13 -0
  344. package/dist/tui/editor-launcher.d.ts.map +1 -0
  345. package/dist/tui/editor-launcher.js +39 -0
  346. package/dist/tui/index.d.ts +7 -3
  347. package/dist/tui/index.d.ts.map +1 -1
  348. package/dist/tui/index.js +3 -2
  349. package/dist/tui/terminal.d.ts +29 -2
  350. package/dist/tui/terminal.d.ts.map +1 -1
  351. package/dist/tui/terminal.js +153 -28
  352. package/dist/tui/tui.d.ts +2 -0
  353. package/dist/tui/tui.d.ts.map +1 -1
  354. package/dist/tui/tui.js +39 -29
  355. package/dist/tui/utils.d.ts.map +1 -1
  356. package/dist/tui/utils.js +2 -3
  357. package/dist/utils/filesystem/security.d.ts.map +1 -1
  358. package/dist/utils/filesystem/security.js +4 -1
  359. package/dist/utils/yaml.d.ts +11 -0
  360. package/dist/utils/yaml.d.ts.map +1 -0
  361. package/dist/utils/yaml.js +207 -0
  362. package/dist/utils/zod.d.ts +1 -0
  363. package/dist/utils/zod.d.ts.map +1 -1
  364. package/dist/utils/zod.js +17 -0
  365. package/package.json +31 -29
  366. package/bin/acai-wrapper.js +0 -26
  367. package/dist/api/exa/index.d.ts +0 -177
  368. package/dist/api/exa/index.d.ts.map +0 -1
  369. package/dist/api/exa/index.js +0 -439
  370. package/dist/commands/add-directory-command.d.ts +0 -3
  371. package/dist/commands/add-directory-command.d.ts.map +0 -1
  372. package/dist/commands/application-log-command.d.ts +0 -3
  373. package/dist/commands/application-log-command.d.ts.map +0 -1
  374. package/dist/commands/application-log-command.js +0 -43
  375. package/dist/commands/clear-command.d.ts +0 -3
  376. package/dist/commands/clear-command.d.ts.map +0 -1
  377. package/dist/commands/compact-command.d.ts +0 -3
  378. package/dist/commands/compact-command.d.ts.map +0 -1
  379. package/dist/commands/compact-command.js +0 -55
  380. package/dist/commands/context-command.d.ts +0 -3
  381. package/dist/commands/context-command.d.ts.map +0 -1
  382. package/dist/commands/context-command.js +0 -124
  383. package/dist/commands/copy-command.d.ts +0 -3
  384. package/dist/commands/copy-command.d.ts.map +0 -1
  385. package/dist/commands/edit-command.d.ts +0 -3
  386. package/dist/commands/edit-command.d.ts.map +0 -1
  387. package/dist/commands/edit-command.js +0 -42
  388. package/dist/commands/edit-prompt-command.d.ts +0 -3
  389. package/dist/commands/edit-prompt-command.d.ts.map +0 -1
  390. package/dist/commands/edit-prompt-command.js +0 -36
  391. package/dist/commands/exit-command.d.ts.map +0 -1
  392. package/dist/commands/exit-command.js +0 -30
  393. package/dist/commands/files-command.d.ts +0 -3
  394. package/dist/commands/files-command.d.ts.map +0 -1
  395. package/dist/commands/files-command.js +0 -68
  396. package/dist/commands/generate-rules-command.d.ts +0 -3
  397. package/dist/commands/generate-rules-command.d.ts.map +0 -1
  398. package/dist/commands/handoff-command.d.ts +0 -3
  399. package/dist/commands/handoff-command.d.ts.map +0 -1
  400. package/dist/commands/health-command.d.ts +0 -4
  401. package/dist/commands/health-command.d.ts.map +0 -1
  402. package/dist/commands/health-command.js +0 -118
  403. package/dist/commands/help-command.d.ts.map +0 -1
  404. package/dist/commands/history-command.d.ts +0 -3
  405. package/dist/commands/history-command.d.ts.map +0 -1
  406. package/dist/commands/init-command.d.ts +0 -3
  407. package/dist/commands/init-command.d.ts.map +0 -1
  408. package/dist/commands/last-log-command.d.ts +0 -3
  409. package/dist/commands/last-log-command.d.ts.map +0 -1
  410. package/dist/commands/last-log-command.js +0 -71
  411. package/dist/commands/list-directories-command.d.ts +0 -3
  412. package/dist/commands/list-directories-command.d.ts.map +0 -1
  413. package/dist/commands/list-tools-command.d.ts +0 -3
  414. package/dist/commands/list-tools-command.d.ts.map +0 -1
  415. package/dist/commands/model-command.d.ts +0 -3
  416. package/dist/commands/model-command.d.ts.map +0 -1
  417. package/dist/commands/paste-command.d.ts.map +0 -1
  418. package/dist/commands/pickup-command.d.ts +0 -3
  419. package/dist/commands/pickup-command.d.ts.map +0 -1
  420. package/dist/commands/pickup-command.js +0 -109
  421. package/dist/commands/prompt-command.d.ts +0 -21
  422. package/dist/commands/prompt-command.d.ts.map +0 -1
  423. package/dist/commands/prompt-command.js +0 -258
  424. package/dist/commands/remove-directory-command.d.ts +0 -3
  425. package/dist/commands/remove-directory-command.d.ts.map +0 -1
  426. package/dist/commands/reset-command.d.ts +0 -3
  427. package/dist/commands/reset-command.d.ts.map +0 -1
  428. package/dist/commands/rules-command.d.ts +0 -3
  429. package/dist/commands/rules-command.d.ts.map +0 -1
  430. package/dist/commands/rules-command.js +0 -73
  431. package/dist/commands/save-command.d.ts +0 -3
  432. package/dist/commands/save-command.d.ts.map +0 -1
  433. package/dist/commands/shell-command.d.ts +0 -3
  434. package/dist/commands/shell-command.d.ts.map +0 -1
  435. package/dist/commands/usage-command.d.ts +0 -3
  436. package/dist/commands/usage-command.d.ts.map +0 -1
  437. package/dist/commands/usage-command.js +0 -31
  438. package/dist/messages.d.ts.map +0 -1
  439. package/dist/repl/project-status-line.d.ts +0 -3
  440. package/dist/repl/project-status-line.d.ts.map +0 -1
  441. package/dist/repl/project-status-line.js +0 -61
  442. package/dist/repl/tool-call-repair.d.ts +0 -4
  443. package/dist/repl/tool-call-repair.d.ts.map +0 -1
  444. package/dist/repl/tool-call-repair.js +0 -54
  445. package/dist/terminal/markdown.d.ts +0 -2
  446. package/dist/terminal/markdown.d.ts.map +0 -1
  447. package/dist/terminal/markdown.js +0 -120
  448. package/dist/tokens/threshold.d.ts +0 -20
  449. package/dist/tokens/threshold.d.ts.map +0 -1
  450. package/dist/tokens/threshold.js +0 -67
  451. package/dist/tools/advanced-edit-file.d.ts +0 -69
  452. package/dist/tools/advanced-edit-file.d.ts.map +0 -1
  453. package/dist/tools/advanced-edit-file.js +0 -285
  454. package/dist/tools/agent.d.ts +0 -29
  455. package/dist/tools/agent.d.ts.map +0 -1
  456. package/dist/tools/agent.js +0 -117
  457. package/dist/tools/batch.d.ts +0 -34
  458. package/dist/tools/batch.d.ts.map +0 -1
  459. package/dist/tools/batch.js +0 -174
  460. package/dist/tools/code-interpreter.d.ts +0 -25
  461. package/dist/tools/code-interpreter.d.ts.map +0 -1
  462. package/dist/tools/code-interpreter.js +0 -183
  463. package/dist/tools/delete-file.d.ts +0 -24
  464. package/dist/tools/delete-file.d.ts.map +0 -1
  465. package/dist/tools/delete-file.js +0 -77
  466. package/dist/tools/dynamic-tool-parser.d.ts +0 -21
  467. package/dist/tools/dynamic-tool-parser.d.ts.map +0 -1
  468. package/dist/tools/dynamic-tool-parser.js +0 -22
  469. package/dist/tools/llm-edit-fixer.d.ts +0 -24
  470. package/dist/tools/llm-edit-fixer.d.ts.map +0 -1
  471. package/dist/tools/llm-edit-fixer.js +0 -136
  472. package/dist/tools/move-file.d.ts +0 -26
  473. package/dist/tools/move-file.d.ts.map +0 -1
  474. package/dist/tools/move-file.js +0 -65
  475. package/dist/tools/read-multiple-files.d.ts +0 -26
  476. package/dist/tools/read-multiple-files.d.ts.map +0 -1
  477. package/dist/tools/read-multiple-files.js +0 -196
  478. package/dist/tools/web-fetch.d.ts +0 -56
  479. package/dist/tools/web-fetch.d.ts.map +0 -1
  480. package/dist/tools/web-fetch.js +0 -247
  481. package/dist/tools/web-search.d.ts +0 -23
  482. package/dist/tools/web-search.d.ts.map +0 -1
  483. package/dist/tools/web-search.js +0 -148
  484. package/dist/tui/components/prompt-status.d.ts +0 -17
  485. package/dist/tui/components/prompt-status.d.ts.map +0 -1
  486. package/dist/tui/components/prompt-status.js +0 -26
@@ -1,25 +1,32 @@
1
1
  import { eastAsianWidth } from "./east-asian-width.js";
2
+ import { getSegmenter } from "./segmenter.js";
2
3
  import stripAnsi from "./strip-ansi.js";
3
- const segmenter = new Intl.Segmenter();
4
+ // Precompile regexes (these are already at module level, which is good)
4
5
  // Whole-cluster zero-width
5
6
  const zeroWidthClusterRegex = /^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Mark}|\p{Surrogate})+$/v;
6
7
  // Pick the base scalar if the cluster starts with Prepend/Format/Marks
7
8
  const leadingNonPrintingRegex = /^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Mark}\p{Surrogate}]+/v;
8
9
  // RGI emoji sequences
9
10
  const rgiEmojiRegex = /^\p{RGI_Emoji}$/v;
10
- function baseVisible(segment) {
11
- return segment.replace(leadingNonPrintingRegex, "");
12
- }
13
- function isZeroWidthCluster(segment) {
14
- return zeroWidthClusterRegex.test(segment);
15
- }
11
+ // Halfwidth/Fullwidth range constants
12
+ const HALFWIDTH_START = 0xff00;
13
+ const HALFWIDTH_END = 0xffef;
16
14
  function trailingHalfwidthWidth(segment, eastAsianWidthOptions) {
15
+ const len = segment.length;
16
+ if (len <= 1) {
17
+ return 0;
18
+ }
17
19
  let extra = 0;
18
- if (segment.length > 1) {
19
- for (const char of segment.slice(1)) {
20
- const codePoint = char.codePointAt(0);
21
- if (codePoint !== undefined && char >= "\\uFF00" && char <= "\\uFFEF") {
22
- extra += eastAsianWidth(codePoint, eastAsianWidthOptions);
20
+ // Use for loop with index for better performance
21
+ for (let i = 1; i < len; i++) {
22
+ const codePoint = segment.codePointAt(i);
23
+ if (codePoint !== undefined &&
24
+ codePoint >= HALFWIDTH_START &&
25
+ codePoint <= HALFWIDTH_END) {
26
+ extra += eastAsianWidth(codePoint, eastAsianWidthOptions);
27
+ // Skip next char if this was a surrogate pair
28
+ if (codePoint > 0xffff) {
29
+ i++;
23
30
  }
24
31
  }
25
32
  }
@@ -33,15 +40,17 @@ export default function stringWidth(input, options = {}) {
33
40
  let string = input;
34
41
  if (!countAnsiEscapeCodes) {
35
42
  string = stripAnsi(string);
36
- }
37
- if (string.length === 0) {
38
- return 0;
43
+ if (string.length === 0) {
44
+ return 0;
45
+ }
39
46
  }
40
47
  let width = 0;
41
48
  const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
49
+ // Use lazy segmenter initialization
50
+ const segmenter = getSegmenter();
42
51
  for (const { segment } of segmenter.segment(string)) {
43
- // Zero-width / non-printing clusters
44
- if (isZeroWidthCluster(segment)) {
52
+ // Zero-width clusters - inline test for hot path
53
+ if (zeroWidthClusterRegex.test(segment)) {
45
54
  continue;
46
55
  }
47
56
  // Emoji width logic
@@ -49,12 +58,22 @@ export default function stringWidth(input, options = {}) {
49
58
  width += 2;
50
59
  continue;
51
60
  }
52
- // Everything else: EAW of the cluster’s first visible scalar
53
- const codePoint = baseVisible(segment).codePointAt(0);
61
+ // Get first code point directly, avoiding intermediate string
62
+ const firstCodePoint = segment.codePointAt(0);
63
+ if (firstCodePoint === undefined) {
64
+ continue;
65
+ }
66
+ // Check if we need to strip leading non-printing characters
67
+ const hasLeadingNonPrinting = leadingNonPrintingRegex.test(segment);
68
+ const codePoint = hasLeadingNonPrinting
69
+ ? segment.replace(leadingNonPrintingRegex, "").codePointAt(0)
70
+ : firstCodePoint;
54
71
  if (codePoint !== undefined) {
55
72
  width += eastAsianWidth(codePoint, eastAsianWidthOptions);
56
- // Add width for trailing Halfwidth and Fullwidth Forms (e.g., ゙, ゚, ー)
57
- width += trailingHalfwidthWidth(segment, eastAsianWidthOptions);
73
+ // Only check trailing width if segment has multiple characters
74
+ if (segment.length > 1) {
75
+ width += trailingHalfwidthWidth(segment, eastAsianWidthOptions);
76
+ }
58
77
  }
59
78
  }
60
79
  return width;
@@ -1 +1 @@
1
- {"version":3,"file":"strip-ansi.d.ts","sourceRoot":"","sources":["../../source/terminal/strip-ansi.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CASxD"}
1
+ {"version":3,"file":"strip-ansi.d.ts","sourceRoot":"","sources":["../../source/terminal/strip-ansi.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKxD"}
@@ -1,20 +1,14 @@
1
- // Inline from sindresorhus/strip-ansi v7.1.0
2
- const ansiRegex = ({ onlyFirst = false } = {}) => {
3
- // Valid string terminator sequences are BEL, ESC\\, and 0x9c
4
- const St = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
5
- // OSC sequences only: ESC ] ... ST (non-greedy until the first ST)
6
- const osc = `(?:\\u001B\\][\\s\\S]*?${St})`;
7
- // CSI and related: ESC/C1, optional intermediates, optional params (supports ; and :) then final byte
8
- const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
9
- const pattern = `${osc}|${csi}`;
10
- return new RegExp(pattern, onlyFirst ? undefined : "g");
11
- };
1
+ // Pre-compile the regex outside the function to avoid recreation on every call
2
+ const ANSI_REGEX = (() => {
3
+ const St = "(?:\u0007|\u001B\u005C|\u009C)";
4
+ // biome-ignore lint/suspicious/noUselessEscapeInString: later
5
+ const osc = `(?:\u001B\][\\s\\S]*?${St})`;
6
+ const csi = "[\u001B\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
7
+ return new RegExp(`${osc}|${csi}`, "g");
8
+ })();
12
9
  export default function stripAnsi(string) {
13
10
  if (typeof string !== "string") {
14
11
  throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
15
12
  }
16
- // Even though the regex is global, we don't need to reset the `.lastIndex`
17
- // because unlike `.exec()` and `.test()`, `.replace()` does it automatically
18
- // and doing it manually has a performance penalty.
19
- return string.replace(ansiRegex(), "");
13
+ return string.replace(ANSI_REGEX, "");
20
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../../source/tokens/tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,IAAI,CAAC;AAO7C,UAAU,kBAAkB;IAC1B,KAAK,EAAE,CAAC,kBAAkB,CAAC,CAAC;CAC7B;AAED,qBAAa,YAAa,SAAQ,YAAY,CAAC,kBAAkB,CAAC;IAChE,OAAO,CAAC,MAAM,CAAoB;IAElC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,GAAG,SAAS;IAQ9D,aAAa,IAAI,kBAAkB;IAcnC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB;IAoB9C,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAY3C,YAAY;CAOb"}
1
+ {"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../../source/tokens/tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,IAAI,CAAC;AAO7C,UAAU,kBAAkB;IAC1B,KAAK,EAAE,CAAC,kBAAkB,CAAC,CAAC;CAC7B;AAED,qBAAa,YAAa,SAAQ,YAAY,CAAC,kBAAkB,CAAC;IAChE,OAAO,CAAC,MAAM,CAAoB;IAElC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,GAAG,SAAS;IAQ9D,aAAa,IAAI,kBAAkB;IA0CnC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB;IA0C9C,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAY3C,YAAY;CAOb"}
@@ -11,29 +11,71 @@ export class TokenTracker extends EventEmitter {
11
11
  }
12
12
  getTotalUsage() {
13
13
  return this.usages.reduce((acc, { usage }) => {
14
- acc.inputTokens += isNumber(usage.inputTokens) ? usage.inputTokens : 0;
15
- acc.outputTokens += isNumber(usage.outputTokens)
16
- ? usage.outputTokens
17
- : 0;
18
- acc.totalTokens += isNumber(usage.totalTokens) ? usage.totalTokens : 0;
14
+ // After AI SDK v6 upgrade, all usage is in the unified format
15
+ const inputTokens = usage.inputTokens ?? 0;
16
+ const outputTokens = usage.outputTokens ?? 0;
17
+ const totalTokens = usage.totalTokens ?? inputTokens + outputTokens;
18
+ acc.inputTokens += isNumber(inputTokens) ? inputTokens : 0;
19
+ acc.outputTokens += isNumber(outputTokens) ? outputTokens : 0;
20
+ acc.totalTokens += isNumber(totalTokens) ? totalTokens : 0;
21
+ // Input token details
22
+ acc.inputTokenDetails.noCacheTokens +=
23
+ usage.inputTokenDetails?.noCacheTokens ?? 0;
24
+ acc.inputTokenDetails.cacheReadTokens +=
25
+ usage.inputTokenDetails?.cacheReadTokens ?? 0;
26
+ acc.inputTokenDetails.cacheWriteTokens +=
27
+ usage.inputTokenDetails?.cacheWriteTokens ?? 0;
28
+ // Output token details
29
+ const v3OutputDetails = usage.outputTokenDetails;
30
+ acc.outputTokenDetails.textTokens += v3OutputDetails?.textTokens ?? 0;
31
+ acc.outputTokenDetails.reasoningTokens +=
32
+ v3OutputDetails?.reasoningTokens ?? 0;
19
33
  return acc;
20
- }, { inputTokens: 0, outputTokens: 0, totalTokens: 0 });
34
+ }, {
35
+ inputTokens: 0,
36
+ outputTokens: 0,
37
+ totalTokens: 0,
38
+ inputTokenDetails: {
39
+ noCacheTokens: 0,
40
+ cacheReadTokens: 0,
41
+ cacheWriteTokens: 0,
42
+ },
43
+ outputTokenDetails: { textTokens: 0, reasoningTokens: 0 },
44
+ });
21
45
  }
22
46
  getUsageByApp(app) {
23
47
  return this.usages
24
48
  .filter(({ tool }) => tool === app)
25
49
  .reduce((acc, { usage }) => {
26
- acc.inputTokens += isNumber(usage.inputTokens)
27
- ? usage.inputTokens
28
- : 0;
29
- acc.outputTokens += isNumber(usage.outputTokens)
30
- ? usage.outputTokens
31
- : 0;
32
- acc.totalTokens += isNumber(usage.totalTokens)
33
- ? usage.totalTokens
34
- : 0;
50
+ const inputTokens = usage.inputTokens ?? 0;
51
+ const outputTokens = usage.outputTokens ?? 0;
52
+ const totalTokens = usage.totalTokens ?? inputTokens + outputTokens;
53
+ acc.inputTokens += isNumber(inputTokens) ? inputTokens : 0;
54
+ acc.outputTokens += isNumber(outputTokens) ? outputTokens : 0;
55
+ acc.totalTokens += isNumber(totalTokens) ? totalTokens : 0;
56
+ const v3InputDetails = usage.inputTokenDetails;
57
+ acc.inputTokenDetails.cacheReadTokens +=
58
+ v3InputDetails?.cacheReadTokens ?? 0;
59
+ acc.inputTokenDetails.noCacheTokens +=
60
+ v3InputDetails?.noCacheTokens ?? 0;
61
+ acc.inputTokenDetails.cacheWriteTokens +=
62
+ v3InputDetails?.cacheWriteTokens ?? 0;
63
+ const v3OutputDetails = usage.outputTokenDetails;
64
+ acc.outputTokenDetails.textTokens += v3OutputDetails?.textTokens ?? 0;
65
+ acc.outputTokenDetails.reasoningTokens +=
66
+ v3OutputDetails?.reasoningTokens ?? 0;
35
67
  return acc;
36
- }, { inputTokens: 0, outputTokens: 0, totalTokens: 0 });
68
+ }, {
69
+ inputTokens: 0,
70
+ outputTokens: 0,
71
+ totalTokens: 0,
72
+ inputTokenDetails: {
73
+ noCacheTokens: 0,
74
+ cacheReadTokens: 0,
75
+ cacheWriteTokens: 0,
76
+ },
77
+ outputTokenDetails: { textTokens: 0, reasoningTokens: 0 },
78
+ });
37
79
  }
38
80
  getUsageBreakdown() {
39
81
  return this.usages.reduce((acc, { tool, usage }) => {
@@ -1,32 +1,30 @@
1
- import type { ToolCallOptions } from "ai";
2
1
  import { z } from "zod";
3
- import type { TokenCounter } from "../tokens/counter.ts";
4
- import type { ToolResult } from "./types.ts";
2
+ import type { ToolExecutionOptions } from "./types.ts";
5
3
  export declare const BashTool: {
6
- name: "bash";
4
+ name: "Bash";
7
5
  };
8
6
  declare const inputSchema: z.ZodObject<{
9
7
  command: z.ZodString;
10
- cwd: z.ZodNullable<z.ZodString>;
11
- timeout: z.ZodNullable<z.ZodCoercedNumber<unknown>>;
8
+ cwd: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodString>>;
9
+ timeout: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
12
10
  background: z.ZodOptional<z.ZodBoolean>;
13
11
  }, z.core.$strip>;
14
12
  type BashInputSchema = z.infer<typeof inputSchema>;
15
- export declare const createBashTool: ({ baseDir, allowedDirs, tokenCounter, }: {
13
+ export declare const createBashTool: ({ baseDir, allowedDirs, }: {
16
14
  baseDir: string;
17
15
  allowedDirs?: string[];
18
- tokenCounter: TokenCounter;
19
16
  }) => Promise<{
20
17
  toolDef: {
21
18
  description: string;
22
19
  inputSchema: z.ZodObject<{
23
20
  command: z.ZodString;
24
- cwd: z.ZodNullable<z.ZodString>;
25
- timeout: z.ZodNullable<z.ZodCoercedNumber<unknown>>;
21
+ cwd: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodString>>;
22
+ timeout: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
26
23
  background: z.ZodOptional<z.ZodBoolean>;
27
24
  }, z.core.$strip>;
28
25
  };
29
- execute({ command, cwd, timeout, background }: BashInputSchema, { toolCallId, abortSignal }: ToolCallOptions): AsyncGenerator<ToolResult>;
26
+ display({ command }: BashInputSchema): string;
27
+ execute({ command, cwd, timeout, background }: BashInputSchema, { abortSignal }: ToolExecutionOptions): Promise<string>;
30
28
  }>;
31
29
  export {};
32
30
  //# sourceMappingURL=bash.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../source/tools/bash.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAMzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,eAAO,MAAM,QAAQ;;CAEpB,CAAC;AAYF,QAAA,MAAM,WAAW;;;;;iBAoBf,CAAC;AAEH,KAAK,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEnD,eAAO,MAAM,cAAc,GAAU,yCAIlC;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;CAC5B;;;;;;;;;;mDAS4C,eAAe,+BACzB,eAAe,GAC3C,cAAc,CAAC,UAAU,CAAC;EAqJhC,CAAC"}
1
+ {"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../source/tools/bash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAqCvD,eAAO,MAAM,QAAQ;;CAEpB,CAAC;AAYF,QAAA,MAAM,WAAW;;;;;iBAkBf,CAAC;AAEH,KAAK,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEnD,eAAO,MAAM,cAAc,GAAU,2BAGlC;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;;;;;;;;;;yBAQwB,eAAe;mDAIK,eAAe,mBACrC,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EAgGrB,CAAC"}
@@ -3,10 +3,40 @@ import { z } from "zod";
3
3
  import { initExecutionEnvironment } from "../execution/index.js";
4
4
  import { logger } from "../logger.js";
5
5
  import style from "../terminal/style.js";
6
- import { manageTokenLimit, TokenLimitExceededError, } from "../tokens/threshold.js";
7
- import { isMutatingCommand, resolveCwd, validatePaths } from "../utils/bash.js";
6
+ import { resolveCwd, validatePaths } from "../utils/bash.js";
7
+ import { convertNullString } from "../utils/zod.js";
8
+ /**
9
+ * Detects git commit commands with multi-line -m messages that will fail in shell.
10
+ * Returns an error message if detected, or null if the command is safe.
11
+ */
12
+ function detectMultilineGitCommit(command) {
13
+ const trimmed = command.trim();
14
+ // Check if it's a git commit command
15
+ if (!trimmed.startsWith("git commit") && !trimmed.startsWith("git ")) {
16
+ return null;
17
+ }
18
+ // Look for -m flag with a message containing newlines
19
+ // Match patterns like: git commit -m "message\nwith\nnewlines"
20
+ // Using [\s\S] instead of [^] to match any character including newlines
21
+ const messageMatch = trimmed.match(/-m\s+["']([\s\S]*?)["']/);
22
+ if (!messageMatch) {
23
+ return null;
24
+ }
25
+ const message = messageMatch[1];
26
+ if (message.includes("\n")) {
27
+ return `Multi-line commit messages with -m flag cause shell parsing errors. Instead:
28
+ 1. Write the commit message to a temporary file (e.g., /tmp/acai/commit-msg.txt)
29
+ 2. Use: git commit -F /tmp/acai/commit-msg.txt
30
+ 3. Optionally remove the temp file after committing
31
+
32
+ Example:
33
+ First, create the file with the commit message using the write_file tool.
34
+ Then run: git commit -F /tmp/acai/commit-msg.txt`;
35
+ }
36
+ return null;
37
+ }
8
38
  export const BashTool = {
9
- name: "bash",
39
+ name: "Bash",
10
40
  };
11
41
  const installedTools = getInstalledTools();
12
42
  const toolDescription = `Execute commands in a shell. Commands can execute only within the allowed directories. Always use absolute paths.
@@ -18,19 +48,17 @@ const DEFAULT_TIMEOUT = 1.5 * 60 * 1000; // 1.5 minutes
18
48
  const inputSchema = z.object({
19
49
  command: z.string().describe("Full CLI command to execute."),
20
50
  cwd: z
21
- .string()
22
- .nullable()
51
+ .preprocess((val) => convertNullString(val), z.string().nullable())
23
52
  .describe("Working directory file path (default: project root). Must be within the project directory. Required but nullable."),
24
- timeout: z.coerce
25
- .number()
26
- .nullable()
53
+ timeout: z
54
+ .preprocess((val) => convertNullString(val), z.coerce.number().nullable())
27
55
  .describe(`Command execution timeout in milliseconds. Required but nullable. If null, the default value is ${DEFAULT_TIMEOUT}ms`),
28
56
  background: z
29
57
  .boolean()
30
58
  .optional()
31
59
  .describe("Run command in background. If true, command will run until program exit."),
32
60
  });
33
- export const createBashTool = async ({ baseDir, allowedDirs, tokenCounter, }) => {
61
+ export const createBashTool = async ({ baseDir, allowedDirs, }) => {
34
62
  const execEnv = await initExecutionEnvironment();
35
63
  const allowedDirectories = allowedDirs ?? [baseDir];
36
64
  return {
@@ -38,123 +66,76 @@ export const createBashTool = async ({ baseDir, allowedDirs, tokenCounter, }) =>
38
66
  description: toolDescription,
39
67
  inputSchema,
40
68
  },
41
- async *execute({ command, cwd, timeout, background }, { toolCallId, abortSignal }) {
42
- try {
43
- if (abortSignal?.aborted) {
44
- throw new Error("Command execution aborted");
45
- }
46
- // grok doesn't follow my instructions
47
- const safeCwd = cwd === "null" ? null : cwd;
48
- const resolvedCwd = resolveCwd(safeCwd, baseDir, allowedDirectories);
49
- const safeTimeout = timeout ?? DEFAULT_TIMEOUT;
50
- // Safety warning for potentially mutating commands
51
- const isMutating = isMutatingCommand(command);
52
- yield {
53
- name: BashTool.name,
54
- event: "tool-init",
55
- id: toolCallId,
56
- data: `${style.cyan(command)}`,
57
- };
58
- const pathValidation = validatePaths(command, allowedDirectories, resolvedCwd);
59
- if (!pathValidation.isValid) {
60
- yield {
61
- name: BashTool.name,
62
- event: "tool-error",
63
- id: toolCallId,
64
- data: pathValidation.error ?? "Unknown error.",
65
- };
66
- yield pathValidation.error ?? "Unknown error.";
67
- return;
68
- }
69
- if (abortSignal?.aborted) {
70
- throw new Error("Command execution aborted before running the command");
71
- }
72
- // Handle background execution
73
- if (background) {
74
- // Strip any existing & from command to avoid double backgrounding
75
- let processedCommand = command.trim();
76
- if (processedCommand.endsWith("&")) {
77
- logger.warn(`Stripping '&' from command since background=true: ${command}`);
78
- processedCommand = processedCommand.slice(0, -1).trim();
79
- }
80
- // Fix rg commands that don't have an explicit path
81
- processedCommand = fixRgCommand(processedCommand);
82
- const backgroundProcess = execEnv.executeCommandInBackground(processedCommand, {
83
- cwd: resolvedCwd,
84
- abortSignal,
85
- onOutput: (output) => {
86
- logger.debug({ output }, "Background command output:");
87
- },
88
- onError: (error) => {
89
- logger.debug({ error }, "Background command error:");
90
- },
91
- onExit: (code) => {
92
- logger.debug(`Background command exited with code ${code}`);
93
- },
94
- });
95
- yield {
96
- name: BashTool.name,
97
- event: "tool-completion",
98
- id: toolCallId,
99
- data: `Background process started with PID: ${backgroundProcess.pid}`,
100
- };
101
- yield `Background process started with PID: ${backgroundProcess.pid}`;
102
- }
103
- else {
104
- // Handle regular synchronous execution
105
- // Strip & if present to ensure synchronous behavior
106
- let processedCommand = command.trim();
107
- if (processedCommand.endsWith("&")) {
108
- logger.warn(`Stripping '&' from command since background=false: ${command}`);
109
- processedCommand = processedCommand.slice(0, -1).trim();
110
- }
111
- // Fix rg commands that don't have an explicit path
112
- // rg hangs when stdin is a socket and no path is given
113
- processedCommand = fixRgCommand(processedCommand);
114
- const { output, exitCode } = await execEnv.executeCommand(processedCommand, {
115
- cwd: resolvedCwd,
116
- timeout: safeTimeout,
117
- abortSignal,
118
- preserveOutputOnError: true,
119
- captureStderr: true,
120
- throwOnError: false,
121
- });
122
- try {
123
- const result = await manageTokenLimit(output, tokenCounter, "Bash", "Adjust command to return more specific results");
124
- const statusText = exitCode === 0 ? "success" : "error";
125
- yield {
126
- name: BashTool.name,
127
- event: "tool-completion",
128
- id: toolCallId,
129
- data: `${statusText}${isMutating ? " *" : ""} (${result.tokenCount} tokens)`,
130
- };
131
- yield result.content;
132
- }
133
- catch (error) {
134
- if (error instanceof TokenLimitExceededError) {
135
- yield {
136
- name: BashTool.name,
137
- event: "tool-error",
138
- id: toolCallId,
139
- data: error.message,
140
- };
141
- yield error.message;
142
- return;
143
- }
144
- throw error;
145
- }
69
+ display({ command }) {
70
+ return `\n> ${style.cyan(command)}`;
71
+ },
72
+ async execute({ command, cwd, timeout, background }, { abortSignal }) {
73
+ if (abortSignal?.aborted) {
74
+ throw new Error("Command execution aborted");
75
+ }
76
+ // grok doesn't follow my instructions
77
+ const safeCwd = cwd === "null" ? null : cwd;
78
+ const resolvedCwd = resolveCwd(safeCwd, baseDir, allowedDirectories);
79
+ const safeTimeout = timeout ?? DEFAULT_TIMEOUT;
80
+ const pathValidation = validatePaths(command, allowedDirectories, resolvedCwd);
81
+ if (!pathValidation.isValid) {
82
+ throw new Error(pathValidation.error ?? "Unknown error.");
83
+ }
84
+ // Check for multi-line git commit messages that will fail
85
+ const multilineError = detectMultilineGitCommit(command);
86
+ if (multilineError) {
87
+ throw new Error(multilineError);
88
+ }
89
+ if (abortSignal?.aborted) {
90
+ throw new Error("Command execution aborted before running the command");
91
+ }
92
+ // Handle background execution
93
+ if (background) {
94
+ // Strip any existing & from command to avoid double backgrounding
95
+ let processedCommand = command.trim();
96
+ if (processedCommand.endsWith("&")) {
97
+ logger.warn(`Stripping '&' from command since background=true: ${command}`);
98
+ processedCommand = processedCommand.slice(0, -1).trim();
146
99
  }
100
+ // Fix rg commands that don't have an explicit path
101
+ processedCommand = fixRgCommand(processedCommand);
102
+ const backgroundProcess = execEnv.executeCommandInBackground(processedCommand, {
103
+ cwd: resolvedCwd,
104
+ abortSignal,
105
+ onOutput: (output) => {
106
+ logger.debug({ output }, "Background command output:");
107
+ },
108
+ onError: (error) => {
109
+ logger.debug({ error }, "Background command error:");
110
+ },
111
+ onExit: (code) => {
112
+ logger.debug(`Background command exited with code ${code}`);
113
+ },
114
+ });
115
+ return `Background process started with PID: ${backgroundProcess.pid}`;
116
+ }
117
+ // Handle regular synchronous execution
118
+ // Strip & if present to ensure synchronous behavior
119
+ let processedCommand = command.trim();
120
+ if (processedCommand.endsWith("&")) {
121
+ logger.warn(`Stripping '&' from command since background=false: ${command}`);
122
+ processedCommand = processedCommand.slice(0, -1).trim();
147
123
  }
148
- catch (error) {
149
- logger.error(error, "Bash Tool Error:");
150
- yield {
151
- name: BashTool.name,
152
- event: "tool-error",
153
- id: toolCallId,
154
- data: error.message,
155
- };
156
- yield error.message;
124
+ // Fix rg commands that don't have an explicit path
125
+ // rg hangs when stdin is a socket and no path is given
126
+ processedCommand = fixRgCommand(processedCommand);
127
+ const { output, exitCode } = await execEnv.executeCommand(processedCommand, {
128
+ cwd: resolvedCwd,
129
+ timeout: safeTimeout,
130
+ abortSignal,
131
+ preserveOutputOnError: true,
132
+ captureStderr: true,
133
+ throwOnError: false,
134
+ });
135
+ if (exitCode !== 0) {
136
+ throw new Error(output);
157
137
  }
138
+ return output;
158
139
  },
159
140
  };
160
141
  };
@@ -1,26 +1,28 @@
1
- import type { ToolCallOptions } from "ai";
2
1
  import { z } from "zod";
3
- import type { TokenCounter } from "../tokens/counter.ts";
4
- import type { ToolResult } from "./types.ts";
2
+ import type { ToolExecutionOptions } from "./types.ts";
5
3
  export declare const DirectoryTreeTool: {
6
- name: "directoryTree";
4
+ name: "DirectoryTree";
7
5
  };
8
6
  declare const inputSchema: z.ZodObject<{
9
7
  path: z.ZodString;
8
+ maxResults: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
9
+ maxDepth: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
10
10
  }, z.core.$strip>;
11
11
  type DirectoryTreeInputSchema = z.infer<typeof inputSchema>;
12
- export declare const createDirectoryTreeTool: ({ workingDir, allowedDirs, tokenCounter, }: {
12
+ export declare const createDirectoryTreeTool: ({ workingDir, allowedDirs, }: {
13
13
  workingDir: string;
14
14
  allowedDirs?: string[];
15
- tokenCounter: TokenCounter;
16
15
  }) => Promise<{
17
16
  toolDef: {
18
17
  description: string;
19
18
  inputSchema: z.ZodObject<{
20
19
  path: z.ZodString;
20
+ maxResults: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
21
+ maxDepth: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
21
22
  }, z.core.$strip>;
22
23
  };
23
- execute({ path }: DirectoryTreeInputSchema, { toolCallId, abortSignal }: ToolCallOptions): AsyncGenerator<ToolResult>;
24
+ display({ path, maxDepth, maxResults }: DirectoryTreeInputSchema): string;
25
+ execute({ path, maxResults, maxDepth }: DirectoryTreeInputSchema, { abortSignal }: ToolExecutionOptions): Promise<string>;
24
26
  }>;
25
27
  export {};
26
28
  //# sourceMappingURL=directory-tree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"directory-tree.d.ts","sourceRoot":"","sources":["../../source/tools/directory-tree.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAOzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,eAAO,MAAM,iBAAiB;;CAE7B,CAAC;AAEF,QAAA,MAAM,WAAW;;iBAEf,CAAC;AAEH,KAAK,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAE5D,eAAO,MAAM,uBAAuB,GAAU,4CAI3C;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;CAC5B;;;;;;;sBASe,wBAAwB,+BACL,eAAe,GAC3C,cAAc,CAAC,UAAU,CAAC;EAyEhC,CAAC"}
1
+ {"version":3,"file":"directory-tree.d.ts","sourceRoot":"","sources":["../../source/tools/directory-tree.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAKvD,eAAO,MAAM,iBAAiB;;CAE7B,CAAC;AAEF,QAAA,MAAM,WAAW;;;;iBAYf,CAAC;AAEH,KAAK,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAE5D,eAAO,MAAM,uBAAuB,GAAU,8BAG3C;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;;;;;;;;;4CAO2C,wBAAwB;4CAW9B,wBAAwB,mBACvC,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EAyBrB,CAAC"}