@travisennis/acai 0.0.5 → 0.0.6

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 (311) hide show
  1. package/README.md +4 -2
  2. package/dist/agent/index.d.ts +119 -0
  3. package/dist/agent/index.d.ts.map +1 -0
  4. package/dist/agent/index.js +406 -0
  5. package/dist/agent/manual-loop.d.ts +41 -0
  6. package/dist/agent/manual-loop.d.ts.map +1 -0
  7. package/dist/agent/manual-loop.js +278 -0
  8. package/dist/cli.d.ts +2 -0
  9. package/dist/cli.d.ts.map +1 -1
  10. package/dist/cli.js +27 -33
  11. package/dist/commands/add-directory-command.d.ts +3 -0
  12. package/dist/commands/add-directory-command.d.ts.map +1 -0
  13. package/dist/commands/add-directory-command.js +85 -0
  14. package/dist/commands/application-log-command.d.ts.map +1 -1
  15. package/dist/commands/application-log-command.js +34 -0
  16. package/dist/commands/clear-command.d.ts.map +1 -1
  17. package/dist/commands/clear-command.js +8 -0
  18. package/dist/commands/compact-command.d.ts.map +1 -1
  19. package/dist/commands/compact-command.js +15 -2
  20. package/dist/commands/context-command.d.ts +3 -0
  21. package/dist/commands/context-command.d.ts.map +1 -0
  22. package/dist/commands/context-command.js +183 -0
  23. package/dist/commands/copy-command.d.ts.map +1 -1
  24. package/dist/commands/copy-command.js +28 -0
  25. package/dist/commands/edit-command.d.ts.map +1 -1
  26. package/dist/commands/edit-command.js +33 -0
  27. package/dist/commands/edit-prompt-command.d.ts.map +1 -1
  28. package/dist/commands/edit-prompt-command.js +28 -0
  29. package/dist/commands/exit-command.d.ts.map +1 -1
  30. package/dist/commands/exit-command.js +20 -0
  31. package/dist/commands/files-command.d.ts.map +1 -1
  32. package/dist/commands/files-command.js +57 -0
  33. package/dist/commands/generate-rules-command.d.ts.map +1 -1
  34. package/dist/commands/generate-rules-command.js +311 -1
  35. package/dist/commands/handoff-command.d.ts +3 -0
  36. package/dist/commands/handoff-command.d.ts.map +1 -0
  37. package/dist/commands/handoff-command.js +202 -0
  38. package/dist/commands/health-command.d.ts.map +1 -1
  39. package/dist/commands/health-command.js +119 -2
  40. package/dist/commands/help-command.d.ts.map +1 -1
  41. package/dist/commands/help-command.js +28 -0
  42. package/dist/commands/history-command.d.ts +3 -0
  43. package/dist/commands/history-command.d.ts.map +1 -0
  44. package/dist/commands/history-command.js +534 -0
  45. package/dist/commands/init-command.d.ts +1 -1
  46. package/dist/commands/init-command.d.ts.map +1 -1
  47. package/dist/commands/init-command.js +55 -18
  48. package/dist/commands/last-log-command.d.ts.map +1 -1
  49. package/dist/commands/last-log-command.js +27 -0
  50. package/dist/commands/list-directories-command.d.ts +3 -0
  51. package/dist/commands/list-directories-command.d.ts.map +1 -0
  52. package/dist/commands/list-directories-command.js +48 -0
  53. package/dist/commands/list-tools-command.d.ts.map +1 -1
  54. package/dist/commands/list-tools-command.js +66 -3
  55. package/dist/commands/manager.d.ts +15 -3
  56. package/dist/commands/manager.d.ts.map +1 -1
  57. package/dist/commands/manager.js +86 -26
  58. package/dist/commands/model-command.d.ts +22 -0
  59. package/dist/commands/model-command.d.ts.map +1 -1
  60. package/dist/commands/model-command.js +256 -0
  61. package/dist/commands/paste-command.d.ts.map +1 -1
  62. package/dist/commands/paste-command.js +92 -0
  63. package/dist/commands/pickup-command.d.ts +3 -0
  64. package/dist/commands/pickup-command.d.ts.map +1 -0
  65. package/dist/commands/pickup-command.js +161 -0
  66. package/dist/commands/prompt-command.d.ts +1 -1
  67. package/dist/commands/prompt-command.d.ts.map +1 -1
  68. package/dist/commands/prompt-command.js +117 -2
  69. package/dist/commands/remove-directory-command.d.ts +3 -0
  70. package/dist/commands/remove-directory-command.d.ts.map +1 -0
  71. package/dist/commands/remove-directory-command.js +87 -0
  72. package/dist/commands/reset-command.d.ts +1 -1
  73. package/dist/commands/reset-command.d.ts.map +1 -1
  74. package/dist/commands/reset-command.js +13 -2
  75. package/dist/commands/rules-command.d.ts.map +1 -1
  76. package/dist/commands/rules-command.js +65 -0
  77. package/dist/commands/save-command.d.ts.map +1 -1
  78. package/dist/commands/save-command.js +12 -0
  79. package/dist/commands/shell-command.d.ts.map +1 -1
  80. package/dist/commands/shell-command.js +68 -0
  81. package/dist/commands/types.d.ts +9 -4
  82. package/dist/commands/types.d.ts.map +1 -1
  83. package/dist/commands/usage-command.d.ts.map +1 -1
  84. package/dist/commands/usage-command.js +22 -0
  85. package/dist/config.d.ts +6 -7
  86. package/dist/config.d.ts.map +1 -1
  87. package/dist/config.js +23 -29
  88. package/dist/formatting.d.ts +108 -0
  89. package/dist/formatting.d.ts.map +1 -1
  90. package/dist/formatting.js +147 -0
  91. package/dist/index.d.ts +7 -2
  92. package/dist/index.d.ts.map +1 -1
  93. package/dist/index.js +140 -38
  94. package/dist/logger.d.ts.map +1 -1
  95. package/dist/logger.js +47 -18
  96. package/dist/mentions.d.ts +2 -1
  97. package/dist/mentions.d.ts.map +1 -1
  98. package/dist/mentions.js +16 -1
  99. package/dist/messages.d.ts +8 -0
  100. package/dist/messages.d.ts.map +1 -1
  101. package/dist/messages.js +56 -19
  102. package/dist/middleware/cache.d.ts +3 -0
  103. package/dist/middleware/cache.d.ts.map +1 -0
  104. package/dist/middleware/cache.js +53 -0
  105. package/dist/middleware/index.d.ts +1 -0
  106. package/dist/middleware/index.d.ts.map +1 -1
  107. package/dist/middleware/index.js +1 -0
  108. package/dist/models/ai-config.d.ts +4 -2
  109. package/dist/models/ai-config.d.ts.map +1 -1
  110. package/dist/models/ai-config.js +12 -2
  111. package/dist/models/anthropic-provider.d.ts.map +1 -1
  112. package/dist/models/anthropic-provider.js +3 -60
  113. package/dist/models/manager.d.ts +2 -1
  114. package/dist/models/manager.d.ts.map +1 -1
  115. package/dist/models/manager.js +26 -2
  116. package/dist/models/openrouter-provider.d.ts +7 -14
  117. package/dist/models/openrouter-provider.d.ts.map +1 -1
  118. package/dist/models/openrouter-provider.js +114 -169
  119. package/dist/models/providers.d.ts +1 -1
  120. package/dist/models/providers.d.ts.map +1 -1
  121. package/dist/prompts.d.ts +1 -0
  122. package/dist/prompts.d.ts.map +1 -1
  123. package/dist/prompts.js +53 -4
  124. package/dist/repl/display-tool-messages.d.ts +1 -1
  125. package/dist/repl/display-tool-messages.d.ts.map +1 -1
  126. package/dist/repl/display-tool-messages.js +47 -44
  127. package/dist/repl/get-prompt-header.d.ts.map +1 -1
  128. package/dist/repl/get-prompt-header.js +1 -30
  129. package/dist/repl/project-status-line.d.ts +2 -0
  130. package/dist/repl/project-status-line.d.ts.map +1 -0
  131. package/dist/repl/project-status-line.js +31 -0
  132. package/dist/repl/prompt.d.ts +21 -0
  133. package/dist/repl/prompt.d.ts.map +1 -0
  134. package/dist/{repl-prompt.js → repl/prompt.js} +119 -22
  135. package/dist/repl/tool-call-repair.d.ts.map +1 -1
  136. package/dist/repl/tool-call-repair.js +8 -4
  137. package/dist/repl-new.d.ts +53 -0
  138. package/dist/repl-new.d.ts.map +1 -0
  139. package/dist/repl-new.js +374 -0
  140. package/dist/repl.d.ts +3 -5
  141. package/dist/repl.d.ts.map +1 -1
  142. package/dist/repl.js +74 -166
  143. package/dist/terminal/checkbox-prompt.d.ts.map +1 -1
  144. package/dist/terminal/checkbox-prompt.js +10 -4
  145. package/dist/terminal/index.d.ts +7 -0
  146. package/dist/terminal/index.d.ts.map +1 -1
  147. package/dist/terminal/index.js +94 -0
  148. package/dist/terminal/input-prompt.d.ts +2 -1
  149. package/dist/terminal/input-prompt.d.ts.map +1 -1
  150. package/dist/terminal/markdown.js +3 -0
  151. package/dist/terminal/search-prompt.d.ts.map +1 -1
  152. package/dist/terminal/search-prompt.js +11 -10
  153. package/dist/terminal/select-prompt.d.ts +2 -2
  154. package/dist/terminal/select-prompt.d.ts.map +1 -1
  155. package/dist/terminal/select-prompt.js +47 -39
  156. package/dist/tokens/threshold.d.ts +35 -0
  157. package/dist/tokens/threshold.d.ts.map +1 -0
  158. package/dist/tokens/threshold.js +85 -0
  159. package/dist/tools/advanced-edit-file.d.ts +69 -0
  160. package/dist/tools/advanced-edit-file.d.ts.map +1 -0
  161. package/dist/tools/advanced-edit-file.js +281 -0
  162. package/dist/tools/agent.d.ts +16 -5
  163. package/dist/tools/agent.d.ts.map +1 -1
  164. package/dist/tools/agent.js +71 -58
  165. package/dist/tools/bash-utils.d.ts +1 -1
  166. package/dist/tools/bash-utils.d.ts.map +1 -1
  167. package/dist/tools/bash-utils.js +14 -6
  168. package/dist/tools/bash.d.ts +21 -12
  169. package/dist/tools/bash.d.ts.map +1 -1
  170. package/dist/tools/bash.js +88 -135
  171. package/dist/tools/code-interpreter.d.ts +21 -9
  172. package/dist/tools/code-interpreter.d.ts.map +1 -1
  173. package/dist/tools/code-interpreter.js +138 -137
  174. package/dist/tools/delete-file.d.ts +17 -10
  175. package/dist/tools/delete-file.d.ts.map +1 -1
  176. package/dist/tools/delete-file.js +51 -95
  177. package/dist/tools/directory-tree.d.ts +17 -6
  178. package/dist/tools/directory-tree.d.ts.map +1 -1
  179. package/dist/tools/directory-tree.js +47 -49
  180. package/dist/tools/dynamic-tool-loader.d.ts +18 -8
  181. package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
  182. package/dist/tools/dynamic-tool-loader.js +121 -129
  183. package/dist/tools/dynamic-tool-parser.d.ts +1 -0
  184. package/dist/tools/dynamic-tool-parser.d.ts.map +1 -1
  185. package/dist/tools/dynamic-tool-parser.js +1 -0
  186. package/dist/tools/edit-file.d.ts +35 -15
  187. package/dist/tools/edit-file.d.ts.map +1 -1
  188. package/dist/tools/edit-file.js +112 -112
  189. package/dist/tools/filesystem-utils.d.ts +2 -1
  190. package/dist/tools/filesystem-utils.d.ts.map +1 -1
  191. package/dist/tools/filesystem-utils.js +31 -17
  192. package/dist/tools/glob.d.ts +36 -0
  193. package/dist/tools/glob.d.ts.map +1 -0
  194. package/dist/tools/glob.js +143 -0
  195. package/dist/tools/grep.d.ts +73 -12
  196. package/dist/tools/grep.d.ts.map +1 -1
  197. package/dist/tools/grep.js +413 -168
  198. package/dist/tools/index.d.ts +204 -124
  199. package/dist/tools/index.d.ts.map +1 -1
  200. package/dist/tools/index.js +242 -135
  201. package/dist/tools/llm-edit-fixer.d.ts +25 -0
  202. package/dist/tools/llm-edit-fixer.d.ts.map +1 -0
  203. package/dist/tools/llm-edit-fixer.js +150 -0
  204. package/dist/tools/move-file.d.ts +19 -7
  205. package/dist/tools/move-file.d.ts.map +1 -1
  206. package/dist/tools/move-file.js +40 -33
  207. package/dist/tools/read-file.d.ts +47 -9
  208. package/dist/tools/read-file.d.ts.map +1 -1
  209. package/dist/tools/read-file.js +74 -69
  210. package/dist/tools/read-multiple-files.d.ts +17 -6
  211. package/dist/tools/read-multiple-files.d.ts.map +1 -1
  212. package/dist/tools/read-multiple-files.js +76 -73
  213. package/dist/tools/save-file.d.ts +45 -12
  214. package/dist/tools/save-file.d.ts.map +1 -1
  215. package/dist/tools/save-file.js +58 -101
  216. package/dist/tools/think.d.ts +15 -7
  217. package/dist/tools/think.d.ts.map +1 -1
  218. package/dist/tools/think.js +30 -22
  219. package/dist/tools/types.d.ts +4 -10
  220. package/dist/tools/types.d.ts.map +1 -1
  221. package/dist/tools/types.js +9 -0
  222. package/dist/tools/utils.d.ts +14 -0
  223. package/dist/tools/utils.d.ts.map +1 -0
  224. package/dist/tools/utils.js +16 -0
  225. package/dist/tools/web-fetch.d.ts +11 -4
  226. package/dist/tools/web-fetch.d.ts.map +1 -1
  227. package/dist/tools/web-fetch.js +39 -38
  228. package/dist/tools/web-search.d.ts +15 -6
  229. package/dist/tools/web-search.d.ts.map +1 -1
  230. package/dist/tools/web-search.js +50 -32
  231. package/dist/tui/autocomplete.d.ts +44 -0
  232. package/dist/tui/autocomplete.d.ts.map +1 -0
  233. package/dist/tui/autocomplete.js +466 -0
  234. package/dist/tui/components/assistant-message.d.ts +18 -0
  235. package/dist/tui/components/assistant-message.d.ts.map +1 -0
  236. package/dist/tui/components/assistant-message.js +29 -0
  237. package/dist/tui/components/editor.d.ts +51 -0
  238. package/dist/tui/components/editor.d.ts.map +1 -0
  239. package/dist/tui/components/editor.js +758 -0
  240. package/dist/tui/components/footer.d.ts +24 -0
  241. package/dist/tui/components/footer.d.ts.map +1 -0
  242. package/dist/tui/components/footer.js +197 -0
  243. package/dist/tui/components/input.d.ts +14 -0
  244. package/dist/tui/components/input.d.ts.map +1 -0
  245. package/dist/tui/components/input.js +122 -0
  246. package/dist/tui/components/loader.d.ts +19 -0
  247. package/dist/tui/components/loader.d.ts.map +1 -0
  248. package/dist/tui/components/loader.js +45 -0
  249. package/dist/tui/components/markdown.d.ts +103 -0
  250. package/dist/tui/components/markdown.d.ts.map +1 -0
  251. package/dist/tui/components/markdown.js +533 -0
  252. package/dist/tui/components/modal.d.ts +40 -0
  253. package/dist/tui/components/modal.d.ts.map +1 -0
  254. package/dist/tui/components/modal.js +292 -0
  255. package/dist/tui/components/prompt-status.d.ts +16 -0
  256. package/dist/tui/components/prompt-status.d.ts.map +1 -0
  257. package/dist/tui/components/prompt-status.js +21 -0
  258. package/dist/tui/components/select-list.d.ts +22 -0
  259. package/dist/tui/components/select-list.d.ts.map +1 -0
  260. package/dist/tui/components/select-list.js +143 -0
  261. package/dist/tui/components/spacer.d.ts +16 -0
  262. package/dist/tui/components/spacer.d.ts.map +1 -0
  263. package/dist/tui/components/spacer.js +27 -0
  264. package/dist/tui/components/text.d.ts +26 -0
  265. package/dist/tui/components/text.d.ts.map +1 -0
  266. package/dist/tui/components/text.js +143 -0
  267. package/dist/tui/components/thinking-block.d.ts +14 -0
  268. package/dist/tui/components/thinking-block.d.ts.map +1 -0
  269. package/dist/tui/components/thinking-block.js +30 -0
  270. package/dist/tui/components/tool-execution.d.ts +17 -0
  271. package/dist/tui/components/tool-execution.d.ts.map +1 -0
  272. package/dist/tui/components/tool-execution.js +153 -0
  273. package/dist/tui/components/user-message.d.ts +9 -0
  274. package/dist/tui/components/user-message.d.ts.map +1 -0
  275. package/dist/tui/components/user-message.js +21 -0
  276. package/dist/tui/components/welcome.d.ts +6 -0
  277. package/dist/tui/components/welcome.d.ts.map +1 -0
  278. package/dist/tui/components/welcome.js +30 -0
  279. package/dist/tui/index.d.ts +14 -0
  280. package/dist/tui/index.d.ts.map +1 -0
  281. package/dist/tui/index.js +18 -0
  282. package/dist/tui/terminal.d.ts +37 -0
  283. package/dist/tui/terminal.d.ts.map +1 -0
  284. package/dist/tui/terminal.js +104 -0
  285. package/dist/tui/tui.d.ts +67 -0
  286. package/dist/tui/tui.d.ts.map +1 -0
  287. package/dist/tui/tui.js +184 -0
  288. package/dist/tui/utils.d.ts +19 -0
  289. package/dist/tui/utils.d.ts.map +1 -0
  290. package/dist/tui/utils.js +31 -0
  291. package/dist/utils/generators.d.ts +3 -0
  292. package/dist/utils/generators.d.ts.map +1 -0
  293. package/dist/utils/generators.js +25 -0
  294. package/dist/utils/iterables.d.ts +2 -0
  295. package/dist/utils/iterables.d.ts.map +1 -0
  296. package/dist/utils/iterables.js +6 -0
  297. package/package.json +16 -16
  298. package/dist/conversation-analyzer.d.ts +0 -11
  299. package/dist/conversation-analyzer.d.ts.map +0 -1
  300. package/dist/conversation-analyzer.js +0 -88
  301. package/dist/repl-prompt.d.ts +0 -15
  302. package/dist/repl-prompt.d.ts.map +0 -1
  303. package/dist/tokens/manage-output.d.ts +0 -34
  304. package/dist/tokens/manage-output.d.ts.map +0 -1
  305. package/dist/tokens/manage-output.js +0 -44
  306. package/dist/tool-executor.d.ts +0 -28
  307. package/dist/tool-executor.d.ts.map +0 -1
  308. package/dist/tool-executor.js +0 -74
  309. package/dist/tools/file-editing-utils.d.ts +0 -2
  310. package/dist/tools/file-editing-utils.d.ts.map +0 -1
  311. package/dist/tools/file-editing-utils.js +0 -135
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Minimal TUI implementation with differential rendering
3
+ */
4
+ import type { Modal } from "./components/modal.ts";
5
+ import type { Terminal } from "./terminal.ts";
6
+ import { visibleWidth } from "./utils.ts";
7
+ /**
8
+ * Component interface - all components must implement this
9
+ */
10
+ export interface Component {
11
+ /**
12
+ * Render the component to lines for the given viewport width
13
+ * @param width - Current viewport width
14
+ * @returns Array of strings, each representing a line
15
+ */
16
+ render(width: number): string[];
17
+ /**
18
+ * Optional handler for keyboard input when component has focus
19
+ */
20
+ handleInput?(data: string): void;
21
+ /**
22
+ * Optional method to get cursor position relative to component
23
+ * Returns [row, col] where row is 0-indexed within component
24
+ * and col is 0-indexed column position
25
+ */
26
+ getCursorPosition?(): [number, number] | null;
27
+ }
28
+ export { visibleWidth };
29
+ /**
30
+ * Container - a component that contains other components
31
+ */
32
+ export declare class Container implements Component {
33
+ children: Component[];
34
+ addChild(component: Component): void;
35
+ removeChild(component: Component): void;
36
+ clear(): void;
37
+ render(width: number): string[];
38
+ }
39
+ /**
40
+ * TUI - Main class for managing terminal UI with differential rendering
41
+ */
42
+ export declare class TUI extends Container {
43
+ private terminal;
44
+ private focusedComponent;
45
+ private renderRequested;
46
+ private activeModal;
47
+ constructor(terminal: Terminal);
48
+ setFocus(component: Component | null): void;
49
+ start(): void;
50
+ stop(): void;
51
+ requestRender(): void;
52
+ private handleInput;
53
+ private doRender;
54
+ /**
55
+ * Show a modal dialog
56
+ */
57
+ showModal(modal: Modal): void;
58
+ /**
59
+ * Hide the active modal
60
+ */
61
+ hideModal(): void;
62
+ /**
63
+ * Check if a modal is currently active
64
+ */
65
+ isModalActive(): boolean;
66
+ }
67
+ //# sourceMappingURL=tui.d.ts.map
@@ -0,0 +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,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;IASrB,OAAO,CAAC,WAAW;IAwBnB,OAAO,CAAC,QAAQ;IAmFhB;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAK7B;;OAEG;IACH,SAAS,IAAI,IAAI;IAKjB;;OAEG;IACH,aAAa,IAAI,OAAO;CAGzB"}
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Minimal TUI implementation with differential rendering
3
+ */
4
+ import { getTerminalSize } from "../terminal/formatting.js";
5
+ import style from "../terminal/style.js";
6
+ import { visibleWidth } from "./utils.js";
7
+ export { visibleWidth };
8
+ /**
9
+ * Container - a component that contains other components
10
+ */
11
+ export class Container {
12
+ children = [];
13
+ addChild(component) {
14
+ this.children.push(component);
15
+ }
16
+ removeChild(component) {
17
+ const index = this.children.indexOf(component);
18
+ if (index !== -1) {
19
+ this.children.splice(index, 1);
20
+ }
21
+ }
22
+ clear() {
23
+ this.children = [];
24
+ }
25
+ render(width) {
26
+ const lines = [];
27
+ for (const child of this.children) {
28
+ lines.push(...child.render(width));
29
+ }
30
+ return lines;
31
+ }
32
+ }
33
+ /**
34
+ * TUI - Main class for managing terminal UI with differential rendering
35
+ */
36
+ // biome-ignore lint/style/useNamingConvention: override
37
+ export class TUI extends Container {
38
+ terminal;
39
+ focusedComponent = null;
40
+ renderRequested = false;
41
+ activeModal = null;
42
+ constructor(terminal) {
43
+ super();
44
+ this.terminal = terminal;
45
+ }
46
+ setFocus(component) {
47
+ this.focusedComponent = component;
48
+ }
49
+ start() {
50
+ this.terminal.start((data) => this.handleInput(data), () => this.requestRender());
51
+ this.terminal.hideCursor();
52
+ this.requestRender();
53
+ }
54
+ stop() {
55
+ this.terminal.showCursor();
56
+ this.terminal.stop();
57
+ }
58
+ requestRender() {
59
+ if (this.renderRequested)
60
+ return;
61
+ this.renderRequested = true;
62
+ process.nextTick(() => {
63
+ this.renderRequested = false;
64
+ this.doRender();
65
+ });
66
+ }
67
+ handleInput(data) {
68
+ // Handle Ctrl+C globally - exit the application
69
+ if (data.charCodeAt(0) === 3) {
70
+ console.log("\nCtrl+C pressed - exiting...");
71
+ this.stop();
72
+ process.exit(0);
73
+ }
74
+ // Handle Escape key to close modal if one is active
75
+ if (data === "\x1b" && this.activeModal) {
76
+ this.hideModal();
77
+ return;
78
+ }
79
+ // Pass input to active modal first, then focused component
80
+ if (this.activeModal?.handleInput) {
81
+ this.activeModal.handleInput(data);
82
+ this.requestRender();
83
+ }
84
+ else if (this.focusedComponent?.handleInput) {
85
+ this.focusedComponent.handleInput(data);
86
+ this.requestRender();
87
+ }
88
+ }
89
+ doRender() {
90
+ const width = this.terminal.columns;
91
+ // Render all components to get new lines
92
+ const newLines = this.render(width);
93
+ // Always do full re-render for simplicity and reliability
94
+ // This ensures that previous content is properly cleared
95
+ let buffer = "\x1b[?2026h"; // Begin synchronized output
96
+ buffer += "\x1b[3J\x1b[2J\x1b[H"; // Clear scrollback, screen, and home
97
+ for (let i = 0; i < newLines.length; i++) {
98
+ if (i > 0)
99
+ buffer += "\r\n";
100
+ buffer += newLines[i];
101
+ }
102
+ // Render modal on top if active
103
+ if (this.activeModal) {
104
+ const modalLines = this.activeModal.render(width);
105
+ // Render backdrop first if modal has backdrop
106
+ if (this.activeModal.backdrop) {
107
+ const backdropLine = style.bgRgb(0, 0, 0)(" ".repeat(width));
108
+ const { columns } = getTerminalSize(); // 24
109
+ for (let i = 0; i < columns; i++) {
110
+ // Cover entire terminal
111
+ buffer += `\x1b[${i + 1};1H`;
112
+ buffer += backdropLine;
113
+ }
114
+ }
115
+ // Render modal content
116
+ for (let i = 0; i < modalLines.length; i++) {
117
+ if (modalLines[i]) {
118
+ // Position cursor and overwrite existing content
119
+ buffer += `\x1b[${i + 1};1H`;
120
+ buffer += modalLines[i];
121
+ }
122
+ }
123
+ }
124
+ buffer += "\x1b[?2026l"; // End synchronized output
125
+ this.terminal.write(buffer);
126
+ }
127
+ // private positionCursor(
128
+ // componentCursorPos: [number, number] | null,
129
+ // ): void {
130
+ // if (!componentCursorPos) {
131
+ // // No cursor position from component, hide cursor
132
+ // this.terminal.hideCursor();
133
+ // return;
134
+ // }
135
+ // const [cursorRow, cursorCol] = componentCursorPos;
136
+ //
137
+ // // Calculate absolute cursor position in the terminal
138
+ // // We need to find which line in newLines corresponds to the component's cursor row
139
+ // // and then position the cursor at that line and column
140
+ //
141
+ // // Find the line offset for the focused component
142
+ // let componentStartLine = 0;
143
+ // if (this.focusedComponent) {
144
+ // // Find the line where this component starts by summing heights of previous components
145
+ // for (const child of this.children) {
146
+ // if (child === this.focusedComponent) {
147
+ // break;
148
+ // }
149
+ // // Use the already-rendered lines to calculate height, not re-render
150
+ // const childLines = child.render(this.terminal.columns);
151
+ // componentStartLine += childLines.length;
152
+ // }
153
+ // }
154
+ //
155
+ // const absoluteRow = componentStartLine + cursorRow;
156
+ // const absoluteCol = cursorCol;
157
+ //
158
+ // // Position cursor using absolute positioning
159
+ // // Move to home position first, then move down to row, then right to column
160
+ // // Note: terminal rows/columns are 1-indexed, so we add 1
161
+ // this.terminal.write(`\x1b[H\x1b[${absoluteRow + 1}B\x1b[${absoluteCol + 1}G`);
162
+ // this.terminal.showCursor();
163
+ // }
164
+ /**
165
+ * Show a modal dialog
166
+ */
167
+ showModal(modal) {
168
+ this.activeModal = modal;
169
+ this.requestRender();
170
+ }
171
+ /**
172
+ * Hide the active modal
173
+ */
174
+ hideModal() {
175
+ this.activeModal = null;
176
+ this.requestRender();
177
+ }
178
+ /**
179
+ * Check if a modal is currently active
180
+ */
181
+ isModalActive() {
182
+ return this.activeModal !== null;
183
+ }
184
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Calculate the visible width of a string in terminal columns.
3
+ * This correctly handles:
4
+ * - ANSI escape codes (ignored)
5
+ * - Emojis and wide characters (counted as 2 columns)
6
+ * - Combining characters (counted correctly)
7
+ * - Tabs (replaced with 3 spaces for consistent width)
8
+ */
9
+ export declare function visibleWidth(str: string): number;
10
+ /**
11
+ * Apply background color to a line, padding to full width.
12
+ *
13
+ * @param line - Line of text (may contain ANSI codes)
14
+ * @param width - Total width to pad to
15
+ * @param bgFn - Background color function
16
+ * @returns Line with background applied and padded to width
17
+ */
18
+ export declare function applyBackgroundToLine(line: string, width: number, bgFn: (text: string) => string): string;
19
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../source/tui/utils.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;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"}
@@ -0,0 +1,31 @@
1
+ import stringWidth from "string-width";
2
+ /**
3
+ * Calculate the visible width of a string in terminal columns.
4
+ * This correctly handles:
5
+ * - ANSI escape codes (ignored)
6
+ * - Emojis and wide characters (counted as 2 columns)
7
+ * - Combining characters (counted correctly)
8
+ * - Tabs (replaced with 3 spaces for consistent width)
9
+ */
10
+ export function visibleWidth(str) {
11
+ // Replace tabs with 3 spaces before measuring
12
+ const normalized = str.replace(/\t/g, " ");
13
+ return stringWidth(normalized);
14
+ }
15
+ /**
16
+ * Apply background color to a line, padding to full width.
17
+ *
18
+ * @param line - Line of text (may contain ANSI codes)
19
+ * @param width - Total width to pad to
20
+ * @param bgFn - Background color function
21
+ * @returns Line with background applied and padded to width
22
+ */
23
+ export function applyBackgroundToLine(line, width, bgFn) {
24
+ // Calculate padding needed
25
+ const visibleLen = visibleWidth(line);
26
+ const paddingNeeded = Math.max(0, width - visibleLen);
27
+ const padding = " ".repeat(paddingNeeded);
28
+ // Apply background to content + padding
29
+ const withPadding = line + padding;
30
+ return bgFn(withPadding);
31
+ }
@@ -0,0 +1,3 @@
1
+ export declare function exhaustGenerator<T, TReturn, TNext>(generator: Generator<T, TReturn, TNext>): TReturn;
2
+ export declare function exhaustGenerator<T, TReturn, TNext>(generator: AsyncGenerator<T, TReturn, TNext>): Promise<TReturn>;
3
+ //# sourceMappingURL=generators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generators.d.ts","sourceRoot":"","sources":["../../source/utils/generators.ts"],"names":[],"mappings":"AASA,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAChD,SAAS,EAAE,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,GACtC,OAAO,CAAC;AAGX,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAChD,SAAS,EAAE,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,GAC3C,OAAO,CAAC,OAAO,CAAC,CAAC"}
@@ -0,0 +1,25 @@
1
+ function isPromiseLike(value) {
2
+ return (typeof value === "object" &&
3
+ value !== null &&
4
+ typeof value.then === "function");
5
+ }
6
+ // biome-ignore lint/style/useNamingConvention: temp
7
+ export function exhaustGenerator(generator) {
8
+ const firstResult = generator.next();
9
+ if (isPromiseLike(firstResult)) {
10
+ const asyncGenerator = generator;
11
+ return (async () => {
12
+ let result = await firstResult;
13
+ while (!result.done) {
14
+ result = await asyncGenerator.next();
15
+ }
16
+ return result.value;
17
+ })();
18
+ }
19
+ const syncGenerator = generator;
20
+ let result = firstResult;
21
+ while (!result.done) {
22
+ result = syncGenerator.next();
23
+ }
24
+ return result.value;
25
+ }
@@ -0,0 +1,2 @@
1
+ export declare function isAsyncIterable<T>(value: unknown): value is AsyncIterable<T>;
2
+ //# sourceMappingURL=iterables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iterables.d.ts","sourceRoot":"","sources":["../../source/utils/iterables.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAAC,CAAC,CAAC,CAQ5E"}
@@ -0,0 +1,6 @@
1
+ export function isAsyncIterable(value) {
2
+ if (value === null || typeof value !== "object") {
3
+ return false;
4
+ }
5
+ return (typeof value[Symbol.asyncIterator] === "function");
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travisennis/acai",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "An AI assistant for developing software.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -48,16 +48,16 @@
48
48
  "typecheck:staged": "npm run typecheck"
49
49
  },
50
50
  "dependencies": {
51
- "@ai-sdk/anthropic": "^2.0.25",
52
- "@ai-sdk/deepseek": "^1.0.21",
53
- "@ai-sdk/google": "^2.0.18",
54
- "@ai-sdk/groq": "^2.0.23",
55
- "@ai-sdk/openai": "^2.0.46",
56
- "@ai-sdk/openai-compatible": "^1.0.20",
51
+ "@ai-sdk/anthropic": "^2.0.47",
52
+ "@ai-sdk/deepseek": "^1.0.29",
53
+ "@ai-sdk/google": "^2.0.43",
54
+ "@ai-sdk/groq": "^2.0.31",
55
+ "@ai-sdk/openai": "^2.0.72",
56
+ "@ai-sdk/openai-compatible": "^1.0.27",
57
57
  "@crosscopy/clipboard": "^0.2.8",
58
- "@openrouter/ai-sdk-provider": "^1.2.0",
58
+ "@openrouter/ai-sdk-provider": "^1.2.5",
59
59
  "@travisennis/stdlib": "^0.0.14",
60
- "ai": "^5.0.64",
60
+ "ai": "^5.0.101",
61
61
  "cheerio": "^1.1.2",
62
62
  "cli-table3": "^0.6.5",
63
63
  "diff": "^8.0.2",
@@ -65,21 +65,21 @@
65
65
  "fast-glob": "^3.3.3",
66
66
  "highlight.js": "^11.11.1",
67
67
  "jsonrepair": "^3.13.1",
68
- "marked": "16.4.0",
69
- "p-throttle": "^8.0.0",
68
+ "marked": "17.0.1",
69
+ "p-throttle": "^8.1.0",
70
70
  "parse5": "^8.0.0",
71
71
  "parse5-htmlparser2-tree-adapter": "^8.0.0",
72
- "pino": "^10.0.0",
73
- "pino-pretty": "^13.1.1",
72
+ "pino": "^10.1.0",
73
+ "pino-pretty": "^13.1.2",
74
74
  "pino-roll": "^4.0.0",
75
75
  "tiktoken": "^1.0.22",
76
- "zod": "^4.1.12"
76
+ "zod": "^4.1.13"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@ai-sdk/provider": "^2.0.0",
80
- "@biomejs/biome": "2.2.5",
80
+ "@biomejs/biome": "2.3.7",
81
81
  "@commitlint/config-conventional": "^20.0.0",
82
- "@types/node": "^24.7.1",
82
+ "@types/node": "^24.10.1",
83
83
  "c8": "^10.1.3",
84
84
  "commitlint": "^20.1.0",
85
85
  "domhandler": "^5.0.3",
@@ -1,11 +0,0 @@
1
- import { type ModelMessage } from "ai";
2
- import type { ModelManager } from "./models/manager.ts";
3
- import type { Terminal } from "./terminal/index.ts";
4
- import type { TokenTracker } from "./tokens/tracker.ts";
5
- export declare function analyzeConversation({ modelManager, messages, tokenTracker, }: {
6
- modelManager: ModelManager;
7
- messages: ModelMessage[];
8
- terminal?: Terminal | undefined;
9
- tokenTracker: TokenTracker;
10
- }): Promise<string[]>;
11
- //# sourceMappingURL=conversation-analyzer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"conversation-analyzer.d.ts","sourceRoot":"","sources":["../source/conversation-analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,IAAI,CAAC;AAGrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAyCxD,wBAAsB,mBAAmB,CAAC,EACxC,YAAY,EACZ,QAAQ,EACR,YAAY,GACb,EAAE;IACD,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAChC,YAAY,EAAE,YAAY,CAAC;CAC5B,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA0DpB"}
@@ -1,88 +0,0 @@
1
- import { generateText } from "ai";
2
- import { config } from "./config.js";
3
- import { createUserMessage } from "./messages.js";
4
- import { systemPrompt } from "./prompts.js";
5
- // Modified System Prompt
6
- const system = async () => `You are an expert analyst reviewing conversations between a coding agent and a software engineer. Your goal is to identify instances where the engineer corrected the agent's approach or understanding in a way that reveals a *generalizable principle* for improving the agent's future behavior across *different* tasks.
7
-
8
- **Your Task:**
9
- 1. Analyze the conversation provided.
10
- 2. Identify significant corrections or redirections from the engineer. Ignore minor clarifications or task-specific adjustments.
11
- 3. For each significant correction, infer a *single, concise, broadly applicable, actionable rule* (starting with 'Always' or 'Never') that captures the underlying principle the agent should follow in the future.
12
- 4. Ensure the rule is general enough to be useful in various scenarios, not just the specific context of this conversation.
13
- 5. Provide a brief, illustrative quote or example from the conversation in parentheses after the rule.
14
- 6. List only the inferred rules in Markdown bullet points. Do not include explanations, summaries, or conversational filler.
15
-
16
- **Crucially, AVOID generating rules that are:**
17
- - Overly specific to the files, functions, or variables discussed (e.g., "Always check for null in the 'processUserData' function"). Instead, generalize (e.g., "Always validate data from external sources before processing").
18
- - Merely restatements of the task requirements.
19
- - Too narrow to be useful outside the immediate context.
20
- - Related to minor typos or formatting preferences unless they represent a consistent pattern requested by the user.
21
-
22
- **Good General Rule Examples:**
23
- <examples>
24
- - Always ask for clarification if the user's request is ambiguous.
25
- - Never make assumptions about file paths without confirmation.
26
- - Always follow the user's explicitly stated formatting preferences.
27
- - Never provide incomplete code snippets without indicating they are partial.
28
- - Always check for potential null or undefined values before accessing properties.
29
- </examples>
30
-
31
- **Bad Specific Rule Examples (Avoid These):**
32
- <bad-examples>
33
- - Always use 'const' instead of 'let' for the 'userId' variable in 'auth.ts'.
34
- - Never forget to pass the 'config' object to the 'initializeDb' function.
35
- - Always add a try-catch block around the 'api.fetchData()' call in 'dataService.ts'.
36
- </bad-examples>
37
-
38
- This is the original system prompt the agent operated under:
39
- <systemPrompt>
40
- ${await systemPrompt()}
41
- </systemPrompt>`;
42
- export async function analyzeConversation({ modelManager, messages, tokenTracker, }) {
43
- const learnedRules = await config.readCachedLearnedRulesFile();
44
- // Modified User Message within analyzeConversation
45
- messages.push(createUserMessage([
46
- `Analyze this conversation based on the system instructions. Identify points where the user made significant corrections revealing general principles for agent improvement. Infer concise, broadly applicable rules (Always/Never) based *only* on these corrections.
47
-
48
- **Key Requirements:**
49
- - Focus on *generalizable* rules applicable to future, different tasks.
50
- - Avoid rules tied to the specifics of *this* conversation.
51
- - Ensure rules don't already exist in <existing-rules>.
52
- - If no *new, general* rules can be inferred, return an empty list or response.
53
- - Return *only* the Markdown list of rules, with no preamble or explanation.
54
-
55
- <existing-rules>
56
- ${learnedRules}
57
- </existing-rules>`,
58
- ]));
59
- const { text, usage } = await generateText({
60
- model: modelManager.getModel("conversation-analyzer"),
61
- maxOutputTokens: 8192,
62
- system: await system(),
63
- messages: messages,
64
- });
65
- tokenTracker.trackUsage("conversation-analyzer", usage);
66
- // Trim whitespace and check if the response is effectively empty or just whitespace
67
- const potentialRulesText = text.trim();
68
- // Basic check to prevent adding empty lines or just formatting
69
- if (!potentialRulesText || potentialRulesText.length === 0) {
70
- return []; // Return empty array if no valid rules generated
71
- }
72
- // Split into individual rules, filter out empty lines
73
- const potentialRulesList = potentialRulesText
74
- .split("\n")
75
- .map((rule) => rule.trim())
76
- .filter((rule) => rule.length > 0);
77
- if (potentialRulesList.length === 0) {
78
- return []; // Return empty array if splitting results in no rules
79
- }
80
- // Further validation could be added here (e.g., check if it starts with '- ', etc.)
81
- // before writing to the file.
82
- // Append only if there are non-empty potential rules
83
- const updatedRules = learnedRules.endsWith("\n") || learnedRules.length === 0
84
- ? `${learnedRules}${potentialRulesList.join("\n")}`
85
- : `${learnedRules}\n${potentialRulesList.join("\n")}`;
86
- await config.writeCachedLearnedRulesFile(updatedRules);
87
- return potentialRulesList; // Return the list of rules that were added
88
- }
@@ -1,15 +0,0 @@
1
- import type { CommandManager } from "./commands/manager.ts";
2
- export declare class ReplPrompt {
3
- private keypressListener?;
4
- private rl;
5
- private history;
6
- private maxHistory;
7
- constructor({ commands, history, }: {
8
- commands: CommandManager;
9
- history: string[];
10
- });
11
- input(): Promise<string>;
12
- close(): void;
13
- [Symbol.dispose](): void;
14
- }
15
- //# sourceMappingURL=repl-prompt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"repl-prompt.d.ts","sourceRoot":"","sources":["../source/repl-prompt.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAyD5D,qBAAa,UAAU;IAErB,OAAO,CAAC,gBAAgB,CAAC,CAAkC;IAC3D,OAAO,CAAC,EAAE,CAAY;IACtB,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,UAAU,CAAM;gBAEZ,EACV,QAAQ,EACR,OAAO,GACR,EAAE;QAAE,QAAQ,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE;IA4F5C,KAAK;IAoBX,KAAK;IAQL,CAAC,MAAM,CAAC,OAAO,CAAC;CAGjB"}
@@ -1,34 +0,0 @@
1
- import type { TokenCounter } from "./counter.ts";
2
- /**
3
- * Interface for options when managing output
4
- */
5
- interface ManageOutputOptions {
6
- tokenCounter: TokenCounter;
7
- threshold?: number;
8
- truncate?: boolean;
9
- }
10
- /**
11
- * Interface for the result of managing output
12
- */
13
- interface TruncatedOutput {
14
- content: string;
15
- tokenCount: number;
16
- truncated: true;
17
- warning: string;
18
- }
19
- interface Output {
20
- content: string;
21
- tokenCount: number;
22
- truncated: false;
23
- warning?: string;
24
- }
25
- type ManagedOutput = Output | TruncatedOutput;
26
- /**
27
- * Manages output by counting tokens and optionally truncating if over threshold.
28
- * @param input - The input string to manage
29
- * @param options - Configuration for management
30
- * @returns Managed output details
31
- */
32
- export declare function manageOutput(input: string, options: ManageOutputOptions): ManagedOutput;
33
- export {};
34
- //# sourceMappingURL=manage-output.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"manage-output.d.ts","sourceRoot":"","sources":["../../source/tokens/manage-output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD;;GAEG;AACH,UAAU,mBAAmB;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,MAAM;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,KAAK,aAAa,GAAG,MAAM,GAAG,eAAe,CAAC;AAE9C;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,mBAAmB,GAC3B,aAAa,CA2Cf"}
@@ -1,44 +0,0 @@
1
- /**
2
- * Manages output by counting tokens and optionally truncating if over threshold.
3
- * @param input - The input string to manage
4
- * @param options - Configuration for management
5
- * @returns Managed output details
6
- */
7
- export function manageOutput(input, options) {
8
- const { threshold = 8000, truncate = true } = options;
9
- if (!input) {
10
- return { content: input, tokenCount: 0, truncated: false };
11
- }
12
- let tokenCount;
13
- try {
14
- tokenCount = options.tokenCounter.count(input);
15
- }
16
- catch (error) {
17
- console.warn(`Token counting failed: ${error}. Using fallback.`);
18
- // Fallback: Rough estimate (4 chars ~1 token)
19
- tokenCount = Math.ceil(input.length / 4);
20
- }
21
- if (tokenCount <= threshold) {
22
- return { content: input, tokenCount, truncated: false };
23
- }
24
- const _exceededBy = tokenCount - threshold;
25
- let truncatedContent = input;
26
- let truncated = false;
27
- if (truncate) {
28
- // Simple truncation: Cut to approx threshold tokens, add ellipsis
29
- // For better UX, could be smarter (e.g., by lines for grep, preserve JSON)
30
- // But keep general for now
31
- const targetLength = threshold * 4; // Rough char estimate
32
- truncatedContent = `${input.slice(0, targetLength)}\n\n[Output truncated at ~${threshold} tokens (${_exceededBy} tokens omitted)]`;
33
- truncated = true;
34
- }
35
- const warning = truncated
36
- ? `Warning: Output exceeds token threshold (${threshold}). Tokens: ${tokenCount}. ${truncate ? "Truncated." : "Full output returned—consider summarizing."}`
37
- : undefined;
38
- return {
39
- content: truncatedContent,
40
- tokenCount,
41
- truncated,
42
- warning,
43
- };
44
- }
@@ -1,28 +0,0 @@
1
- interface AskContext {
2
- toolName: string;
3
- toolCallId: string;
4
- message: string;
5
- choices: {
6
- accept: string;
7
- acceptAll: string;
8
- reject: string;
9
- };
10
- }
11
- export type AskResponse = {
12
- result: "accept" | "accept-all";
13
- reason?: string;
14
- } | {
15
- result: "reject";
16
- reason: string;
17
- };
18
- export declare class ToolExecutor {
19
- private autoAcceptAll;
20
- private autoAcceptMap;
21
- constructor(autoAcceptAll: boolean);
22
- autoAccept(toolName: string): boolean;
23
- ask(ctx: AskContext, { abortSignal }: {
24
- abortSignal?: AbortSignal;
25
- }): Promise<AskResponse>;
26
- }
27
- export {};
28
- //# sourceMappingURL=tool-executor.d.ts.map