@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,36 +1,120 @@
1
+ import fs from "node:fs";
2
+ import tty from "node:tty";
1
3
  /**
2
4
  * Real terminal using process.stdin/stdout
5
+ *
6
+ * When useTty is true (for piped stdin scenarios), input is read from /dev/tty
7
+ * instead of process.stdin, allowing interactive input after piped content.
3
8
  */
4
9
  export class ProcessTerminal {
5
10
  wasRaw = false;
6
11
  sigintHandler;
7
- inputHandler;
8
- resizeHandler;
12
+ boundInputListener;
13
+ boundResizeListener;
9
14
  stopped = false;
15
+ inExternalMode = false;
16
+ resumeCallback;
17
+ inputStream;
18
+ ttyFd;
19
+ useTty;
20
+ constructor(options = {}) {
21
+ this.useTty = options.useTty ?? false;
22
+ this.inputStream = process.stdin;
23
+ }
24
+ handleSigCont = () => {
25
+ if (this.inExternalMode) {
26
+ this.exitExternalMode();
27
+ }
28
+ };
10
29
  start(onInput, onResize) {
11
- this.inputHandler = onInput;
12
- this.resizeHandler = onResize;
13
- if (!process.stdin.isTTY || !process.stdout.isTTY) {
30
+ if (this.useTty) {
31
+ try {
32
+ this.ttyFd = fs.openSync("/dev/tty", "r");
33
+ this.inputStream = new tty.ReadStream(this.ttyFd);
34
+ }
35
+ catch {
36
+ throw new Error("Cannot open /dev/tty for interactive input");
37
+ }
38
+ }
39
+ else {
40
+ this.inputStream = process.stdin;
41
+ }
42
+ if (!this.inputStream.isTTY || !process.stdout.isTTY) {
14
43
  throw new Error("Terminal requires TTY environment");
15
44
  }
16
- // Save previous state and enable raw mode
17
- this.wasRaw = process.stdin.isRaw ?? false;
18
- if (process.stdin.setRawMode) {
19
- process.stdin.setRawMode(true);
45
+ this.wasRaw = this.inputStream.isRaw ?? false;
46
+ if (this.inputStream.setRawMode) {
47
+ this.inputStream.setRawMode(true);
20
48
  }
21
- process.stdin.setEncoding("utf8");
22
- process.stdin.resume();
49
+ this.inputStream.setEncoding("utf8");
50
+ this.inputStream.resume();
23
51
  // Enable bracketed paste mode - terminal will wrap pastes in \x1b[200~ ... \x1b[201~
24
52
  process.stdout.write("\x1b[?2004h");
25
- // Set up event handlers with proper binding and type conversion
26
- process.stdin.on("data", (data) => {
27
- this.inputHandler?.(typeof data === "string" ? data : data.toString("utf8"));
53
+ // Create bound listeners so we can properly remove them later
54
+ this.boundInputListener = (data) => {
55
+ onInput(typeof data === "string" ? data : data.toString("utf8"));
56
+ };
57
+ this.boundResizeListener = () => {
58
+ onResize();
59
+ };
60
+ this.attachListeners();
61
+ this.sigintHandler = () => {
62
+ // Let the custom editor.onCtrlC handler in NewRepl handle Ctrl+C
63
+ // This prevents a race condition where stop() gets called without the exit message
64
+ };
65
+ process.on("SIGINT", this.sigintHandler);
66
+ process.on("SIGCONT", this.handleSigCont);
67
+ process.on("SIGTERM", () => this.stop());
68
+ process.on("SIGHUP", () => this.stop());
69
+ this.setupCrashCleanup();
70
+ }
71
+ attachListeners() {
72
+ if (this.boundInputListener) {
73
+ this.inputStream.on("data", this.boundInputListener);
74
+ }
75
+ if (this.boundResizeListener) {
76
+ process.stdout.on("resize", this.boundResizeListener);
77
+ }
78
+ }
79
+ detachListeners() {
80
+ if (this.boundInputListener) {
81
+ this.inputStream.removeListener("data", this.boundInputListener);
82
+ }
83
+ if (this.boundResizeListener) {
84
+ process.stdout.removeListener("resize", this.boundResizeListener);
85
+ }
86
+ }
87
+ setupCrashCleanup() {
88
+ process.on("exit", () => {
89
+ process.stdout.write("\x1b[?25h");
90
+ process.stdout.write("\x1b[?2004l");
91
+ process.stdout.write("\x1b[0m");
92
+ if (this.inputStream.setRawMode) {
93
+ this.inputStream.setRawMode(this.wasRaw);
94
+ }
95
+ this.closeTtyFd();
28
96
  });
29
- process.stdout.on("resize", () => {
30
- this.resizeHandler?.();
97
+ process.on("uncaughtException", (error) => {
98
+ process.stdout.write("\x1b[?25h");
99
+ process.stdout.write("\x1b[?2004l");
100
+ process.stdout.write("\x1b[0m");
101
+ if (this.inputStream.setRawMode) {
102
+ this.inputStream.setRawMode(this.wasRaw);
103
+ }
104
+ this.closeTtyFd();
105
+ throw error;
31
106
  });
32
- this.sigintHandler = () => this.stop();
33
- process.on("SIGINT", this.sigintHandler);
107
+ }
108
+ closeTtyFd() {
109
+ if (this.ttyFd !== undefined) {
110
+ try {
111
+ fs.closeSync(this.ttyFd);
112
+ }
113
+ catch {
114
+ // Ignore close errors
115
+ }
116
+ this.ttyFd = undefined;
117
+ }
34
118
  }
35
119
  stop() {
36
120
  if (this.stopped)
@@ -38,23 +122,25 @@ export class ProcessTerminal {
38
122
  this.stopped = true;
39
123
  if (this.sigintHandler) {
40
124
  process.off("SIGINT", this.sigintHandler);
125
+ this.sigintHandler = undefined;
41
126
  }
42
127
  // Disable bracketed paste mode
43
128
  process.stdout.write("\x1b[?2004l");
44
- // Remove event handlers
45
- if (this.inputHandler) {
46
- process.stdin.removeListener("data", this.inputHandler);
47
- this.inputHandler = undefined;
129
+ // Remove event handlers using the exact references that were added
130
+ if (this.boundInputListener) {
131
+ this.inputStream.removeListener("data", this.boundInputListener);
132
+ this.boundInputListener = undefined;
48
133
  }
49
- if (this.resizeHandler) {
50
- process.stdout.removeListener("resize", this.resizeHandler);
51
- this.resizeHandler = undefined;
134
+ if (this.boundResizeListener) {
135
+ process.stdout.removeListener("resize", this.boundResizeListener);
136
+ this.boundResizeListener = undefined;
52
137
  }
53
- process.stdin.pause();
138
+ this.inputStream.pause();
54
139
  // Restore raw mode state
55
- if (process.stdin.setRawMode) {
56
- process.stdin.setRawMode(this.wasRaw);
140
+ if (this.inputStream.setRawMode) {
141
+ this.inputStream.setRawMode(this.wasRaw);
57
142
  }
143
+ this.closeTtyFd();
58
144
  }
59
145
  write(data) {
60
146
  process.stdout.write(data);
@@ -91,4 +177,43 @@ export class ProcessTerminal {
91
177
  clearScreen() {
92
178
  process.stdout.write("\x1b[2J\x1b[H"); // Clear screen and move to home (1,1)
93
179
  }
180
+ enterExternalMode() {
181
+ if (this.inExternalMode || this.stopped)
182
+ return;
183
+ this.inExternalMode = true;
184
+ this.detachListeners();
185
+ this.inputStream.pause();
186
+ if (this.inputStream.setRawMode) {
187
+ this.inputStream.setRawMode(false);
188
+ }
189
+ process.stdout.write("\x1b[0m");
190
+ process.stdout.write("\x1b[?25h");
191
+ process.stdout.write("\x1b[?2004l");
192
+ }
193
+ exitExternalMode() {
194
+ if (!this.inExternalMode || this.stopped)
195
+ return;
196
+ this.inExternalMode = false;
197
+ if (this.inputStream.setRawMode) {
198
+ this.inputStream.setRawMode(true);
199
+ }
200
+ this.inputStream.setEncoding("utf8");
201
+ this.inputStream.resume();
202
+ process.stdout.write("\x1b[?2004h");
203
+ process.stdout.write("\x1b[?25l");
204
+ this.attachListeners();
205
+ if (this.resumeCallback) {
206
+ this.resumeCallback();
207
+ }
208
+ }
209
+ background() {
210
+ this.enterExternalMode();
211
+ process.kill(process.pid, "SIGSTOP");
212
+ }
213
+ isInExternalMode() {
214
+ return this.inExternalMode;
215
+ }
216
+ onResume(callback) {
217
+ this.resumeCallback = callback;
218
+ }
94
219
  }
package/dist/tui/tui.d.ts CHANGED
@@ -46,11 +46,13 @@ export declare class TUI extends Container {
46
46
  private isRendering;
47
47
  private renderAgain;
48
48
  private activeModal;
49
+ onCtrlC?: () => void;
49
50
  constructor(terminal: Terminal);
50
51
  setFocus(component: Component | null): void;
51
52
  start(): void;
52
53
  stop(): void;
53
54
  requestRender(): void;
55
+ private inBracketedPaste;
54
56
  private handleInput;
55
57
  private doRender;
56
58
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../../source/tui/tui.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEhC;;OAEG;IACH,WAAW,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC;;;;OAIG;IACH,iBAAiB,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;CAC/C;AAED,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB;;GAEG;AACH,qBAAa,SAAU,YAAW,SAAS;IACzC,QAAQ,EAAE,SAAS,EAAE,CAAM;IAE3B,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAIpC,WAAW,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAOvC,KAAK,IAAI,IAAI;IAIb,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;CAOhC;AAED;;GAEG;AAGH,qBAAa,GAAI,SAAQ,SAAS;IAChC,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,gBAAgB,CAA0B;IAClD,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAsB;gBAE7B,QAAQ,EAAE,QAAQ;IAK9B,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI;IAI3C,KAAK,IAAI,IAAI;IASb,IAAI,IAAI,IAAI;IAKZ,aAAa,IAAI,IAAI;IAarB,OAAO,CAAC,WAAW;IAwBnB,OAAO,CAAC,QAAQ;IAgGhB;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAK7B;;OAEG;IACH,SAAS,IAAI,IAAI;IAKjB;;OAEG;IACH,aAAa,IAAI,OAAO;CAGzB"}
1
+ {"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../../source/tui/tui.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEhC;;OAEG;IACH,WAAW,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC;;;;OAIG;IACH,iBAAiB,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;CAC/C;AAED,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB;;GAEG;AACH,qBAAa,SAAU,YAAW,SAAS;IACzC,QAAQ,EAAE,SAAS,EAAE,CAAM;IAE3B,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAIpC,WAAW,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAOvC,KAAK,IAAI,IAAI;IAIb,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;CAGhC;AAED;;GAEG;AAGH,qBAAa,GAAI,SAAQ,SAAS;IAChC,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,gBAAgB,CAA0B;IAClD,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAsB;IAElC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;gBAEhB,QAAQ,EAAE,QAAQ;IAK9B,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI;IAI3C,KAAK,IAAI,IAAI;IAUb,IAAI,IAAI,IAAI;IAKZ,aAAa,IAAI,IAAI;IAarB,OAAO,CAAC,gBAAgB,CAAS;IAEjC,OAAO,CAAC,WAAW;IA6CnB,OAAO,CAAC,QAAQ;IA0FhB;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAK7B;;OAEG;IACH,SAAS,IAAI,IAAI;IAKjB;;OAEG;IACH,aAAa,IAAI,OAAO;CAGzB"}
package/dist/tui/tui.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Minimal TUI implementation with differential rendering
3
3
  */
4
- import { getTerminalSize } from "../terminal/formatting.js";
4
+ import { getTerminalSize, isCtrlC, isCtrlZ, isEscape, } from "../terminal/control.js";
5
5
  import style from "../terminal/style.js";
6
6
  import { visibleWidth } from "./utils.js";
7
7
  export { visibleWidth };
@@ -23,11 +23,7 @@ export class Container {
23
23
  this.children = [];
24
24
  }
25
25
  render(width) {
26
- const lines = [];
27
- for (const child of this.children) {
28
- lines.push(...child.render(width));
29
- }
30
- return lines;
26
+ return this.children.flatMap((child) => child.render(width));
31
27
  }
32
28
  }
33
29
  /**
@@ -41,6 +37,7 @@ export class TUI extends Container {
41
37
  isRendering = false;
42
38
  renderAgain = false;
43
39
  activeModal = null;
40
+ onCtrlC;
44
41
  constructor(terminal) {
45
42
  super();
46
43
  this.terminal = terminal;
@@ -50,6 +47,7 @@ export class TUI extends Container {
50
47
  }
51
48
  start() {
52
49
  this.terminal.start((data) => this.handleInput(data), () => this.requestRender());
50
+ this.terminal.onResume(() => this.requestRender());
53
51
  this.terminal.hideCursor();
54
52
  this.requestRender();
55
53
  }
@@ -70,15 +68,34 @@ export class TUI extends Container {
70
68
  this.doRender();
71
69
  });
72
70
  }
71
+ inBracketedPaste = false;
73
72
  handleInput(data) {
73
+ if (data.includes("\x1b[200~")) {
74
+ this.inBracketedPaste = true;
75
+ }
76
+ if (data.includes("\x1b[201~")) {
77
+ this.inBracketedPaste = false;
78
+ }
79
+ // Handle Ctrl+Z - background the process (POSIX only)
80
+ if (isCtrlZ(data) &&
81
+ !this.inBracketedPaste &&
82
+ process.platform !== "win32") {
83
+ this.terminal.background();
84
+ return;
85
+ }
74
86
  // Handle Ctrl+C globally - exit the application
75
- if (data.charCodeAt(0) === 3) {
87
+ if (isCtrlC(data)) {
76
88
  console.info("\nCtrl+C pressed - exiting...");
77
- this.stop();
78
- process.exit(0);
89
+ if (this.onCtrlC) {
90
+ this.onCtrlC();
91
+ }
92
+ else {
93
+ this.stop();
94
+ process.exit(0);
95
+ }
79
96
  }
80
97
  // Handle Escape key to close modal if one is active
81
- if (data === "\x1b" && this.activeModal) {
98
+ if (isEscape(data) && this.activeModal) {
82
99
  this.hideModal();
83
100
  return;
84
101
  }
@@ -102,39 +119,32 @@ export class TUI extends Container {
102
119
  const width = this.terminal.columns;
103
120
  // Render all components to get new lines
104
121
  const newLines = this.render(width);
105
- // Always do full re-render for simplicity and reliability
106
- // This ensures that previous content is properly cleared
107
- let buffer = "\x1b[?2026h"; // Begin synchronized output
108
- buffer += "\x1b[3J\x1b[2J\x1b[H"; // Clear scrollback, screen, and home
109
- for (let i = 0; i < newLines.length; i++) {
110
- if (i > 0)
111
- buffer += "\r\n";
112
- buffer += newLines[i];
113
- }
122
+ // Build output buffer using array join (more efficient than string concat)
123
+ const bufferParts = [
124
+ "\x1b[?2026h", // Begin synchronized output
125
+ "\x1b[3J\x1b[2J\x1b[H", // Clear scrollback, screen, and home
126
+ newLines.join("\r\n"),
127
+ ];
114
128
  // Render modal on top if active
115
129
  if (this.activeModal) {
116
130
  const modalLines = this.activeModal.render(width);
117
131
  // Render backdrop first if modal has backdrop
118
132
  if (this.activeModal.backdrop) {
119
133
  const backdropLine = style.bgRgb(0, 0, 0)(" ".repeat(width));
120
- const { columns } = getTerminalSize(); // 24
121
- for (let i = 0; i < columns; i++) {
122
- // Cover entire terminal
123
- buffer += `\x1b[${i + 1};1H`;
124
- buffer += backdropLine;
134
+ const { rows } = getTerminalSize();
135
+ for (let i = 0; i < rows; i++) {
136
+ bufferParts.push(`\x1b[${i + 1};1H`, backdropLine);
125
137
  }
126
138
  }
127
139
  // Render modal content
128
140
  for (let i = 0; i < modalLines.length; i++) {
129
141
  if (modalLines[i]) {
130
- // Position cursor and overwrite existing content
131
- buffer += `\x1b[${i + 1};1H`;
132
- buffer += modalLines[i];
142
+ bufferParts.push(`\x1b[${i + 1};1H`, modalLines[i]);
133
143
  }
134
144
  }
135
145
  }
136
- buffer += "\x1b[?2026l"; // End synchronized output
137
- this.terminal.write(buffer);
146
+ bufferParts.push("\x1b[?2026l"); // End synchronized output
147
+ this.terminal.write(bufferParts.join(""));
138
148
  }
139
149
  finally {
140
150
  this.isRendering = false;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../source/tui/utils.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AA4BD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,SAAQ,GACf,MAAM,CA+DR;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAC7B,MAAM,CASR"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../source/tui/utils.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AA4BD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,SAAQ,GACf,MAAM,CA+DR;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAC7B,MAAM,CASR"}
package/dist/tui/utils.js CHANGED
@@ -1,6 +1,5 @@
1
+ import { getSegmenter } from "../terminal/segmenter.js";
1
2
  import stringWidth from "../terminal/string-width.js";
2
- // Grapheme segmenter for proper Unicode iteration (handles emojis, etc.)
3
- const segmenter = new Intl.Segmenter();
4
3
  /**
5
4
  * Calculate the visible width of a string in terminal columns.
6
5
  * This correctly handles:
@@ -67,7 +66,7 @@ export function truncateToWidth(text, maxWidth, ellipsis = "...") {
67
66
  }
68
67
  // Segment this non-ANSI portion into graphemes
69
68
  const textPortion = text.slice(i, end);
70
- for (const seg of segmenter.segment(textPortion)) {
69
+ for (const seg of getSegmenter().segment(textPortion)) {
71
70
  segments.push({ type: "grapheme", value: seg.segment });
72
71
  }
73
72
  i = end;
@@ -1 +1 @@
1
- {"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../../source/utils/filesystem/security.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAsCrD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAK3E;AAoCD,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EAAE,GACpB,OAAO,CAIT;AAGD,wBAAsB,YAAY,CAChC,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,MAAM,GAAG,MAAM,EAAE,EACnC,OAAO,GAAE;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,WAAW,CAAA;CAAO,GACtE,OAAO,CAAC,MAAM,CAAC,CA6HjB;AA8BD,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,MAAM,GACjB,IAAI,CAIN"}
1
+ {"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../../source/utils/filesystem/security.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAsCrD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAK3E;AAoCD,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EAAE,GACpB,OAAO,CAIT;AAGD,wBAAsB,YAAY,CAChC,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,MAAM,GAAG,MAAM,EAAE,EACnC,OAAO,GAAE;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,WAAW,CAAA;CAAO,GACtE,OAAO,CAAC,MAAM,CAAC,CAiIjB;AA8BD,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,MAAM,GACjB,IAAI,CAIN"}
@@ -116,8 +116,11 @@ export async function validatePath(requestedPath, allowedDirectory, options = {}
116
116
  return rel === "" || (!rel.startsWith("..") && !path.isAbsolute(rel));
117
117
  });
118
118
  };
119
+ // Resolve symlinks in ancestors of the requested path for accurate comparison
120
+ // This handles cases like /tmp -> /private/tmp on macOS
121
+ const resolvedRequested = resolveExistingAncestorSync(normalizedRequested);
119
122
  // Check intended path is within any allowed directory
120
- if (!isWithinAllowed(normalizedRequested)) {
123
+ if (!isWithinAllowed(resolvedRequested)) {
121
124
  throw new Error(`Access denied - path outside allowed directories: ${absolute} not in any of ${allowedDirectories.join(", ")}`);
122
125
  }
123
126
  let validatedPath;
@@ -0,0 +1,11 @@
1
+ type YamlValue = string | number | boolean | null | YamlObject | YamlValue[];
2
+ type YamlObject = {
3
+ [key: string]: YamlValue;
4
+ };
5
+ export declare function parseYaml(input: string): YamlObject;
6
+ export declare function parseFrontMatter(markdown: string): {
7
+ data: YamlObject;
8
+ content: string;
9
+ };
10
+ export {};
11
+ //# sourceMappingURL=yaml.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../source/utils/yaml.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,UAAU,GAAG,SAAS,EAAE,CAAC;AAC7E,KAAK,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAE/C,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CA0DnD;AA2JD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG;IAClD,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAwBA"}
@@ -0,0 +1,207 @@
1
+ export function parseYaml(input) {
2
+ const lines = input.split("\n");
3
+ const result = {};
4
+ let i = 0;
5
+ while (i < lines.length) {
6
+ const line = lines[i];
7
+ const trimmed = line.trim();
8
+ // Skip empty lines and comments
9
+ if (!trimmed || trimmed.startsWith("#")) {
10
+ i++;
11
+ continue;
12
+ }
13
+ // Check for key-value pair
14
+ const colonIndex = line.indexOf(":");
15
+ if (colonIndex === -1) {
16
+ i++;
17
+ continue;
18
+ }
19
+ const indent = getIndent(line);
20
+ const key = line.slice(0, colonIndex).trim();
21
+ const afterColon = line.slice(colonIndex + 1).trim();
22
+ if (afterColon) {
23
+ // Inline value
24
+ result[key] = parseValue(afterColon);
25
+ i++;
26
+ }
27
+ else {
28
+ // Check next line for nested content
29
+ i++;
30
+ if (i < lines.length) {
31
+ const nextLine = lines[i];
32
+ const nextIndent = getIndent(nextLine);
33
+ const nextTrimmed = nextLine.trim();
34
+ if (nextTrimmed.startsWith("-")) {
35
+ // Array
36
+ const [arr, newIndex] = parseArray(lines, i, nextIndent);
37
+ result[key] = arr;
38
+ i = newIndex;
39
+ }
40
+ else if (nextIndent > indent && nextTrimmed.includes(":")) {
41
+ // Nested object
42
+ const [obj, newIndex] = parseObject(lines, i, nextIndent);
43
+ result[key] = obj;
44
+ i = newIndex;
45
+ }
46
+ else {
47
+ result[key] = null;
48
+ }
49
+ }
50
+ else {
51
+ result[key] = null;
52
+ }
53
+ }
54
+ }
55
+ return result;
56
+ }
57
+ function parseObject(lines, start, baseIndent) {
58
+ const obj = {};
59
+ let i = start;
60
+ while (i < lines.length) {
61
+ const line = lines[i];
62
+ const indent = getIndent(line);
63
+ const trimmed = line.trim();
64
+ if (!trimmed || trimmed.startsWith("#")) {
65
+ i++;
66
+ continue;
67
+ }
68
+ if (indent < baseIndent) {
69
+ break;
70
+ }
71
+ if (indent === baseIndent) {
72
+ const colonIndex = line.indexOf(":");
73
+ if (colonIndex === -1) {
74
+ i++;
75
+ continue;
76
+ }
77
+ const key = line.slice(0, colonIndex).trim();
78
+ const afterColon = line.slice(colonIndex + 1).trim();
79
+ if (afterColon) {
80
+ obj[key] = parseValue(afterColon);
81
+ i++;
82
+ }
83
+ else {
84
+ i++;
85
+ if (i < lines.length) {
86
+ const nextLine = lines[i];
87
+ const nextIndent = getIndent(nextLine);
88
+ const nextTrimmed = nextLine.trim();
89
+ if (nextTrimmed.startsWith("-")) {
90
+ const [arr, newIndex] = parseArray(lines, i, nextIndent);
91
+ obj[key] = arr;
92
+ i = newIndex;
93
+ }
94
+ else if (nextIndent > indent && nextTrimmed.includes(":")) {
95
+ const [nested, newIndex] = parseObject(lines, i, nextIndent);
96
+ obj[key] = nested;
97
+ i = newIndex;
98
+ }
99
+ else {
100
+ obj[key] = null;
101
+ }
102
+ }
103
+ else {
104
+ obj[key] = null;
105
+ }
106
+ }
107
+ }
108
+ else {
109
+ i++;
110
+ }
111
+ }
112
+ return [obj, i];
113
+ }
114
+ function parseArray(lines, start, baseIndent) {
115
+ const arr = [];
116
+ let i = start;
117
+ while (i < lines.length) {
118
+ const line = lines[i];
119
+ const indent = getIndent(line);
120
+ const trimmed = line.trim();
121
+ if (!trimmed || trimmed.startsWith("#")) {
122
+ i++;
123
+ continue;
124
+ }
125
+ if (indent < baseIndent) {
126
+ break;
127
+ }
128
+ if (indent === baseIndent && trimmed.startsWith("-")) {
129
+ const afterDash = trimmed.slice(1).trim();
130
+ if (afterDash) {
131
+ // Inline array item
132
+ arr.push(parseValue(afterDash));
133
+ i++;
134
+ }
135
+ else {
136
+ // Check next line for nested content
137
+ i++;
138
+ if (i < lines.length) {
139
+ const nextLine = lines[i];
140
+ const nextIndent = getIndent(nextLine);
141
+ const nextTrimmed = nextLine.trim();
142
+ if (nextTrimmed.includes(":")) {
143
+ const [obj, newIndex] = parseObject(lines, i, nextIndent);
144
+ arr.push(obj);
145
+ i = newIndex;
146
+ }
147
+ else {
148
+ i++;
149
+ }
150
+ }
151
+ }
152
+ }
153
+ else {
154
+ i++;
155
+ }
156
+ }
157
+ return [arr, i];
158
+ }
159
+ function parseValue(value) {
160
+ // Handle quoted strings
161
+ if ((value.startsWith('"') && value.endsWith('"')) ||
162
+ (value.startsWith("'") && value.endsWith("'"))) {
163
+ return value.slice(1, -1);
164
+ }
165
+ // Handle booleans
166
+ if (value === "true")
167
+ return true;
168
+ if (value === "false")
169
+ return false;
170
+ // Handle null
171
+ if (value === "null" || value === "~")
172
+ return null;
173
+ // Handle numbers
174
+ if (/^-?\d+$/.test(value)) {
175
+ return Number.parseInt(value, 10);
176
+ }
177
+ if (/^-?\d+\.\d+$/.test(value)) {
178
+ return Number.parseFloat(value);
179
+ }
180
+ // Default to string
181
+ return value;
182
+ }
183
+ function getIndent(line) {
184
+ const match = line.match(/^(\s*)/);
185
+ return match ? match[1].length : 0;
186
+ }
187
+ // Helper function to extract and parse Yaml front matter from markdown
188
+ export function parseFrontMatter(markdown) {
189
+ const lines = markdown.split("\n");
190
+ if (lines[0] !== "---") {
191
+ return { data: {}, content: markdown };
192
+ }
193
+ let endIndex = -1;
194
+ for (let i = 1; i < lines.length; i++) {
195
+ if (lines[i] === "---" || lines[i] === "...") {
196
+ endIndex = i;
197
+ break;
198
+ }
199
+ }
200
+ if (endIndex === -1) {
201
+ return { data: {}, content: markdown };
202
+ }
203
+ const yamlContent = lines.slice(1, endIndex).join("\n");
204
+ const data = parseYaml(yamlContent);
205
+ const content = lines.slice(endIndex + 1).join("\n");
206
+ return { data, content };
207
+ }
@@ -1,4 +1,5 @@
1
1
  import { ZodType } from "zod";
2
2
  export declare function isZodSchema(obj: unknown): obj is ZodType<unknown>;
3
3
  export declare function zodToJsonSchema(schema: ZodType<unknown>): Record<string, unknown>;
4
+ export declare const convertNullString: (value: unknown) => unknown;
4
5
  //# sourceMappingURL=zod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../source/utils/zod.ts"],"names":[],"mappings":"AAAA,OAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEjC,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAEjE;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,GACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzB"}
1
+ {"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../source/utils/zod.ts"],"names":[],"mappings":"AAAA,OAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEjC,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAEjE;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,GACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzB;AAID,eAAO,MAAM,iBAAiB,GAAI,OAAO,OAAO,KAAG,OAgBlD,CAAC"}
package/dist/utils/zod.js CHANGED
@@ -5,3 +5,20 @@ export function isZodSchema(obj) {
5
5
  export function zodToJsonSchema(schema) {
6
6
  return z.toJSONSchema(schema);
7
7
  }
8
+ // Many models do not reliably pass null to optional tool fields. Instead they pass "null", "None", "undefined", or empty strings.
9
+ // This function will coerce all of those values into null.
10
+ export const convertNullString = (value) => {
11
+ if (typeof value === "undefined") {
12
+ return null;
13
+ }
14
+ if (typeof value === "string") {
15
+ const trimmed = value.trim();
16
+ if (trimmed.toLowerCase() === "null" ||
17
+ trimmed.toLowerCase() === "none" ||
18
+ trimmed.toLowerCase() === "undefined" ||
19
+ trimmed === "") {
20
+ return null;
21
+ }
22
+ }
23
+ return value;
24
+ };