@travisennis/acai 0.0.4 → 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.
- package/README.md +229 -8
- package/dist/agent/index.d.ts +119 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +406 -0
- package/dist/agent/manual-loop.d.ts +41 -0
- package/dist/agent/manual-loop.d.ts.map +1 -0
- package/dist/agent/manual-loop.js +278 -0
- package/dist/api/exa/index.d.ts +177 -0
- package/dist/api/exa/index.d.ts.map +1 -0
- package/dist/api/exa/index.js +439 -0
- package/dist/cli.d.ts +5 -2
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +27 -33
- package/dist/commands/add-directory-command.d.ts +3 -0
- package/dist/commands/add-directory-command.d.ts.map +1 -0
- package/dist/commands/add-directory-command.js +85 -0
- package/dist/commands/application-log-command.d.ts +1 -0
- package/dist/commands/application-log-command.d.ts.map +1 -0
- package/dist/commands/application-log-command.js +39 -3
- package/dist/commands/clear-command.d.ts +1 -0
- package/dist/commands/clear-command.d.ts.map +1 -0
- package/dist/commands/clear-command.js +10 -3
- package/dist/commands/compact-command.d.ts +1 -0
- package/dist/commands/compact-command.d.ts.map +1 -0
- package/dist/commands/compact-command.js +16 -3
- package/dist/commands/context-command.d.ts +3 -0
- package/dist/commands/context-command.d.ts.map +1 -0
- package/dist/commands/context-command.js +183 -0
- package/dist/commands/copy-command.d.ts +1 -0
- package/dist/commands/copy-command.d.ts.map +1 -0
- package/dist/commands/copy-command.js +31 -2
- package/dist/commands/edit-command.d.ts +1 -0
- package/dist/commands/edit-command.d.ts.map +1 -0
- package/dist/commands/edit-command.js +40 -5
- package/dist/commands/edit-prompt-command.d.ts +2 -1
- package/dist/commands/edit-prompt-command.d.ts.map +1 -0
- package/dist/commands/edit-prompt-command.js +43 -7
- package/dist/commands/exit-command.d.ts +13 -2
- package/dist/commands/exit-command.d.ts.map +1 -0
- package/dist/commands/exit-command.js +34 -2
- package/dist/commands/files-command.d.ts +1 -0
- package/dist/commands/files-command.d.ts.map +1 -0
- package/dist/commands/files-command.js +66 -8
- package/dist/commands/generate-rules-command.d.ts +1 -0
- package/dist/commands/generate-rules-command.d.ts.map +1 -0
- package/dist/commands/generate-rules-command.js +315 -4
- package/dist/commands/handoff-command.d.ts +3 -0
- package/dist/commands/handoff-command.d.ts.map +1 -0
- package/dist/commands/handoff-command.js +202 -0
- package/dist/commands/health-command.d.ts +3 -1
- package/dist/commands/health-command.d.ts.map +1 -0
- package/dist/commands/health-command.js +160 -6
- package/dist/commands/help-command.d.ts +1 -0
- package/dist/commands/help-command.d.ts.map +1 -0
- package/dist/commands/help-command.js +30 -3
- package/dist/commands/history-command.d.ts +3 -0
- package/dist/commands/history-command.d.ts.map +1 -0
- package/dist/commands/history-command.js +534 -0
- package/dist/commands/init-command.d.ts +2 -1
- package/dist/commands/init-command.d.ts.map +1 -0
- package/dist/commands/init-command.js +56 -20
- package/dist/commands/last-log-command.d.ts +1 -0
- package/dist/commands/last-log-command.d.ts.map +1 -0
- package/dist/commands/last-log-command.js +39 -17
- package/dist/commands/list-directories-command.d.ts +3 -0
- package/dist/commands/list-directories-command.d.ts.map +1 -0
- package/dist/commands/list-directories-command.js +48 -0
- package/dist/commands/list-tools-command.d.ts +3 -0
- package/dist/commands/list-tools-command.d.ts.map +1 -0
- package/dist/commands/list-tools-command.js +124 -0
- package/dist/commands/manager.d.ts +20 -3
- package/dist/commands/manager.d.ts.map +1 -0
- package/dist/commands/manager.js +123 -26
- package/dist/commands/model-command.d.ts +23 -0
- package/dist/commands/model-command.d.ts.map +1 -0
- package/dist/commands/model-command.js +261 -5
- package/dist/commands/paste-command.d.ts +1 -0
- package/dist/commands/paste-command.d.ts.map +1 -0
- package/dist/commands/paste-command.js +98 -5
- package/dist/commands/pickup-command.d.ts +3 -0
- package/dist/commands/pickup-command.d.ts.map +1 -0
- package/dist/commands/pickup-command.js +161 -0
- package/dist/commands/prompt-command.d.ts +2 -1
- package/dist/commands/prompt-command.d.ts.map +1 -0
- package/dist/commands/prompt-command.js +178 -9
- package/dist/commands/remove-directory-command.d.ts +3 -0
- package/dist/commands/remove-directory-command.d.ts.map +1 -0
- package/dist/commands/remove-directory-command.js +87 -0
- package/dist/commands/reset-command.d.ts +2 -1
- package/dist/commands/reset-command.d.ts.map +1 -0
- package/dist/commands/reset-command.js +14 -3
- package/dist/commands/rules-command.d.ts +1 -0
- package/dist/commands/rules-command.d.ts.map +1 -0
- package/dist/commands/rules-command.js +70 -3
- package/dist/commands/save-command.d.ts +1 -0
- package/dist/commands/save-command.d.ts.map +1 -0
- package/dist/commands/save-command.js +13 -1
- package/dist/commands/shell-command.d.ts +3 -0
- package/dist/commands/shell-command.d.ts.map +1 -0
- package/dist/commands/shell-command.js +128 -0
- package/dist/commands/types.d.ts +16 -8
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/usage-command.d.ts +1 -0
- package/dist/commands/usage-command.d.ts.map +1 -0
- package/dist/commands/usage-command.js +24 -3
- package/dist/config.d.ts +21 -34
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +55 -15
- package/dist/dedent.d.ts +1 -0
- package/dist/dedent.d.ts.map +1 -0
- package/dist/execution/index.d.ts +112 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +432 -0
- package/dist/formatting.d.ts +107 -10
- package/dist/formatting.d.ts.map +1 -0
- package/dist/formatting.js +150 -62
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +150 -38
- package/dist/logger.d.ts +1 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +47 -18
- package/dist/mentions.d.ts +6 -1
- package/dist/mentions.d.ts.map +1 -0
- package/dist/mentions.js +58 -11
- package/dist/messages.d.ts +16 -20
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +89 -72
- package/dist/middleware/audit-message.d.ts +1 -0
- package/dist/middleware/audit-message.d.ts.map +1 -0
- package/dist/middleware/cache.d.ts +3 -0
- package/dist/middleware/cache.d.ts.map +1 -0
- package/dist/middleware/cache.js +53 -0
- package/dist/middleware/index.d.ts +2 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +1 -0
- package/dist/middleware/rate-limit.d.ts +1 -0
- package/dist/middleware/rate-limit.d.ts.map +1 -0
- package/dist/models/ai-config.d.ts +5 -2
- package/dist/models/ai-config.d.ts.map +1 -0
- package/dist/models/ai-config.js +12 -2
- package/dist/models/anthropic-provider.d.ts +1 -0
- package/dist/models/anthropic-provider.d.ts.map +1 -0
- package/dist/models/anthropic-provider.js +3 -60
- package/dist/models/deepseek-provider.d.ts +1 -0
- package/dist/models/deepseek-provider.d.ts.map +1 -0
- package/dist/models/google-provider.d.ts +1 -0
- package/dist/models/google-provider.d.ts.map +1 -0
- package/dist/models/groq-provider.d.ts +20 -0
- package/dist/models/groq-provider.d.ts.map +1 -0
- package/dist/models/groq-provider.js +31 -0
- package/dist/models/manager.d.ts +3 -1
- package/dist/models/manager.d.ts.map +1 -0
- package/dist/models/manager.js +26 -2
- package/dist/models/openai-provider.d.ts +2 -1
- package/dist/models/openai-provider.d.ts.map +1 -0
- package/dist/models/openrouter-provider.d.ts +25 -23
- package/dist/models/openrouter-provider.d.ts.map +1 -0
- package/dist/models/openrouter-provider.js +181 -122
- package/dist/models/providers.d.ts +4 -5
- package/dist/models/providers.d.ts.map +1 -0
- package/dist/models/providers.js +7 -3
- package/dist/models/xai-provider.d.ts +1 -0
- package/dist/models/xai-provider.d.ts.map +1 -0
- package/dist/parsing.d.ts +2 -1
- package/dist/parsing.d.ts.map +1 -0
- package/dist/prompts/manager.d.ts +14 -2
- package/dist/prompts/manager.d.ts.map +1 -0
- package/dist/prompts.d.ts +2 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +65 -12
- package/dist/repl/display-tool-messages.d.ts +4 -0
- package/dist/repl/display-tool-messages.d.ts.map +1 -0
- package/dist/repl/display-tool-messages.js +58 -0
- package/dist/repl/display-tool-use.d.ts +14 -0
- package/dist/repl/display-tool-use.d.ts.map +1 -0
- package/dist/repl/display-tool-use.js +63 -0
- package/dist/repl/get-prompt-header.d.ts +8 -0
- package/dist/repl/get-prompt-header.d.ts.map +1 -0
- package/dist/repl/get-prompt-header.js +9 -0
- package/dist/repl/project-status-line.d.ts +2 -0
- package/dist/repl/project-status-line.d.ts.map +1 -0
- package/dist/repl/project-status-line.js +31 -0
- package/dist/repl/prompt.d.ts +21 -0
- package/dist/repl/prompt.d.ts.map +1 -0
- package/dist/{repl-prompt.js → repl/prompt.js} +119 -22
- package/dist/repl/tool-call-repair.d.ts +4 -0
- package/dist/repl/tool-call-repair.d.ts.map +1 -0
- package/dist/repl/tool-call-repair.js +54 -0
- package/dist/repl-new.d.ts +53 -0
- package/dist/repl-new.d.ts.map +1 -0
- package/dist/repl-new.js +374 -0
- package/dist/repl.d.ts +9 -7
- package/dist/repl.d.ts.map +1 -0
- package/dist/repl.js +142 -378
- package/dist/terminal/ansi-styles.d.ts +77 -0
- package/dist/terminal/ansi-styles.d.ts.map +1 -0
- package/dist/terminal/ansi-styles.js +215 -0
- package/dist/terminal/checkbox-prompt.d.ts +36 -0
- package/dist/terminal/checkbox-prompt.d.ts.map +1 -0
- package/dist/terminal/checkbox-prompt.js +368 -0
- package/dist/terminal/default-theme.d.ts +6 -0
- package/dist/terminal/default-theme.d.ts.map +1 -0
- package/dist/terminal/default-theme.js +182 -0
- package/dist/terminal/east-asian-width.d.ts +8 -0
- package/dist/terminal/east-asian-width.d.ts.map +1 -0
- package/dist/terminal/east-asian-width.js +409 -0
- package/dist/terminal/editor-prompt.d.ts +10 -0
- package/dist/terminal/editor-prompt.d.ts.map +1 -0
- package/dist/terminal/editor-prompt.js +61 -0
- package/dist/terminal/errors.d.ts +19 -0
- package/dist/terminal/errors.d.ts.map +1 -0
- package/dist/terminal/errors.js +37 -0
- package/dist/terminal/formatting.d.ts +1 -11
- package/dist/terminal/formatting.d.ts.map +1 -0
- package/dist/terminal/formatting.js +4 -20
- package/dist/terminal/highlight/index.d.ts +53 -0
- package/dist/terminal/highlight/index.d.ts.map +1 -0
- package/dist/terminal/highlight/index.js +90 -0
- package/dist/terminal/highlight/theme.d.ts +233 -0
- package/dist/terminal/highlight/theme.d.ts.map +1 -0
- package/dist/terminal/highlight/theme.js +83 -0
- package/dist/terminal/index.d.ts +23 -9
- package/dist/terminal/index.d.ts.map +1 -0
- package/dist/terminal/index.js +136 -126
- package/dist/terminal/input-prompt.d.ts +17 -0
- package/dist/terminal/input-prompt.d.ts.map +1 -0
- package/dist/terminal/input-prompt.js +181 -0
- package/dist/terminal/markdown-utils.d.ts +1 -0
- package/dist/terminal/markdown-utils.d.ts.map +1 -0
- package/dist/terminal/markdown.d.ts +1 -0
- package/dist/terminal/markdown.d.ts.map +1 -0
- package/dist/terminal/markdown.js +20 -12
- package/dist/terminal/search-prompt.d.ts +20 -0
- package/dist/terminal/search-prompt.d.ts.map +1 -0
- package/dist/terminal/search-prompt.js +280 -0
- package/dist/terminal/select-prompt.d.ts +26 -0
- package/dist/terminal/select-prompt.d.ts.map +1 -0
- package/dist/terminal/select-prompt.js +306 -0
- package/dist/terminal/string-width.d.ts +7 -0
- package/dist/terminal/string-width.d.ts.map +1 -0
- package/dist/terminal/string-width.js +61 -0
- package/dist/terminal/strip-ansi.d.ts +2 -0
- package/dist/terminal/strip-ansi.d.ts.map +1 -0
- package/dist/terminal/strip-ansi.js +20 -0
- package/dist/terminal/style.d.ts +191 -0
- package/dist/terminal/style.d.ts.map +1 -0
- package/dist/terminal/style.js +259 -0
- package/dist/terminal/supports-color.d.ts +1 -0
- package/dist/terminal/supports-color.d.ts.map +1 -0
- package/dist/terminal/supports-hyperlinks.d.ts +1 -3
- package/dist/terminal/supports-hyperlinks.d.ts.map +1 -0
- package/dist/terminal/supports-hyperlinks.js +1 -1
- package/dist/terminal/types.d.ts +1 -37
- package/dist/terminal/types.d.ts.map +1 -0
- package/dist/terminal/wrap-ansi.d.ts +8 -0
- package/dist/terminal/wrap-ansi.d.ts.map +1 -0
- package/dist/terminal/wrap-ansi.js +190 -0
- package/dist/{token-utils.d.ts → tokens/counter.d.ts} +1 -0
- package/dist/tokens/counter.d.ts.map +1 -0
- package/dist/{token-utils.js → tokens/counter.js} +1 -1
- package/dist/tokens/threshold.d.ts +35 -0
- package/dist/tokens/threshold.d.ts.map +1 -0
- package/dist/tokens/threshold.js +85 -0
- package/dist/{token-tracker.d.ts → tokens/tracker.d.ts} +1 -0
- package/dist/tokens/tracker.d.ts.map +1 -0
- package/dist/tools/advanced-edit-file.d.ts +69 -0
- package/dist/tools/advanced-edit-file.d.ts.map +1 -0
- package/dist/tools/advanced-edit-file.js +281 -0
- package/dist/tools/agent.d.ts +19 -7
- package/dist/tools/agent.d.ts.map +1 -0
- package/dist/tools/agent.js +70 -54
- package/dist/tools/bash-utils.d.ts +7 -0
- package/dist/tools/bash-utils.d.ts.map +1 -0
- package/dist/tools/bash-utils.js +220 -0
- package/dist/tools/bash.d.ts +25 -14
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +87 -251
- package/dist/tools/code-interpreter.d.ts +22 -10
- package/dist/tools/code-interpreter.d.ts.map +1 -0
- package/dist/tools/code-interpreter.js +146 -210
- package/dist/tools/delete-file.d.ts +18 -9
- package/dist/tools/delete-file.d.ts.map +1 -0
- package/dist/tools/delete-file.js +55 -85
- package/dist/tools/directory-tree.d.ts +26 -6
- package/dist/tools/directory-tree.d.ts.map +1 -0
- package/dist/tools/directory-tree.js +109 -28
- package/dist/tools/dynamic-tool-loader.d.ts +22 -0
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -0
- package/dist/tools/dynamic-tool-loader.js +272 -0
- package/dist/tools/dynamic-tool-parser.d.ts +21 -0
- package/dist/tools/dynamic-tool-parser.d.ts.map +1 -0
- package/dist/tools/dynamic-tool-parser.js +22 -0
- package/dist/tools/edit-file.d.ts +41 -13
- package/dist/tools/edit-file.d.ts.map +1 -0
- package/dist/tools/edit-file.js +173 -96
- package/dist/tools/filesystem-utils.d.ts +7 -21
- package/dist/tools/filesystem-utils.d.ts.map +1 -0
- package/dist/tools/filesystem-utils.js +111 -149
- package/dist/tools/git-utils.d.ts +1 -0
- package/dist/tools/git-utils.d.ts.map +1 -0
- package/dist/tools/glob.d.ts +36 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +143 -0
- package/dist/tools/grep.d.ts +76 -13
- package/dist/tools/grep.d.ts.map +1 -0
- package/dist/tools/grep.js +420 -135
- package/dist/tools/index.d.ts +207 -133
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +245 -127
- package/dist/tools/llm-edit-fixer.d.ts +25 -0
- package/dist/tools/llm-edit-fixer.d.ts.map +1 -0
- package/dist/tools/llm-edit-fixer.js +150 -0
- package/dist/tools/move-file.d.ts +20 -7
- package/dist/tools/move-file.d.ts.map +1 -0
- package/dist/tools/move-file.js +43 -29
- package/dist/tools/read-file.d.ts +49 -10
- package/dist/tools/read-file.d.ts.map +1 -0
- package/dist/tools/read-file.js +79 -67
- package/dist/tools/read-multiple-files.d.ts +19 -7
- package/dist/tools/read-multiple-files.d.ts.map +1 -0
- package/dist/tools/read-multiple-files.js +117 -33
- package/dist/tools/save-file.d.ts +46 -11
- package/dist/tools/save-file.d.ts.map +1 -0
- package/dist/tools/save-file.js +63 -78
- package/dist/tools/think.d.ts +16 -7
- package/dist/tools/think.d.ts.map +1 -0
- package/dist/tools/think.js +34 -22
- package/dist/tools/types.d.ts +18 -11
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +9 -0
- package/dist/tools/utils.d.ts +14 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +16 -0
- package/dist/tools/web-fetch.d.ts +15 -6
- package/dist/tools/web-fetch.d.ts.map +1 -0
- package/dist/tools/web-fetch.js +40 -39
- package/dist/tools/web-search.d.ts +17 -7
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +86 -33
- package/dist/tui/autocomplete.d.ts +44 -0
- package/dist/tui/autocomplete.d.ts.map +1 -0
- package/dist/tui/autocomplete.js +466 -0
- package/dist/tui/components/assistant-message.d.ts +18 -0
- package/dist/tui/components/assistant-message.d.ts.map +1 -0
- package/dist/tui/components/assistant-message.js +29 -0
- package/dist/tui/components/editor.d.ts +51 -0
- package/dist/tui/components/editor.d.ts.map +1 -0
- package/dist/tui/components/editor.js +758 -0
- package/dist/tui/components/footer.d.ts +24 -0
- package/dist/tui/components/footer.d.ts.map +1 -0
- package/dist/tui/components/footer.js +197 -0
- package/dist/tui/components/input.d.ts +14 -0
- package/dist/tui/components/input.d.ts.map +1 -0
- package/dist/tui/components/input.js +122 -0
- package/dist/tui/components/loader.d.ts +19 -0
- package/dist/tui/components/loader.d.ts.map +1 -0
- package/dist/tui/components/loader.js +45 -0
- package/dist/tui/components/markdown.d.ts +103 -0
- package/dist/tui/components/markdown.d.ts.map +1 -0
- package/dist/tui/components/markdown.js +533 -0
- package/dist/tui/components/modal.d.ts +40 -0
- package/dist/tui/components/modal.d.ts.map +1 -0
- package/dist/tui/components/modal.js +292 -0
- package/dist/tui/components/prompt-status.d.ts +16 -0
- package/dist/tui/components/prompt-status.d.ts.map +1 -0
- package/dist/tui/components/prompt-status.js +21 -0
- package/dist/tui/components/select-list.d.ts +22 -0
- package/dist/tui/components/select-list.d.ts.map +1 -0
- package/dist/tui/components/select-list.js +143 -0
- package/dist/tui/components/spacer.d.ts +16 -0
- package/dist/tui/components/spacer.d.ts.map +1 -0
- package/dist/tui/components/spacer.js +27 -0
- package/dist/tui/components/text.d.ts +26 -0
- package/dist/tui/components/text.d.ts.map +1 -0
- package/dist/tui/components/text.js +143 -0
- package/dist/tui/components/thinking-block.d.ts +14 -0
- package/dist/tui/components/thinking-block.d.ts.map +1 -0
- package/dist/tui/components/thinking-block.js +30 -0
- package/dist/tui/components/tool-execution.d.ts +17 -0
- package/dist/tui/components/tool-execution.d.ts.map +1 -0
- package/dist/tui/components/tool-execution.js +153 -0
- package/dist/tui/components/user-message.d.ts +9 -0
- package/dist/tui/components/user-message.d.ts.map +1 -0
- package/dist/tui/components/user-message.js +21 -0
- package/dist/tui/components/welcome.d.ts +6 -0
- package/dist/tui/components/welcome.d.ts.map +1 -0
- package/dist/tui/components/welcome.js +30 -0
- package/dist/tui/index.d.ts +14 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +18 -0
- package/dist/tui/terminal.d.ts +37 -0
- package/dist/tui/terminal.d.ts.map +1 -0
- package/dist/tui/terminal.js +104 -0
- package/dist/tui/tui.d.ts +67 -0
- package/dist/tui/tui.d.ts.map +1 -0
- package/dist/tui/tui.js +184 -0
- package/dist/tui/utils.d.ts +19 -0
- package/dist/tui/utils.d.ts.map +1 -0
- package/dist/tui/utils.js +31 -0
- package/dist/utils/filesystem.d.ts +23 -0
- package/dist/utils/filesystem.d.ts.map +1 -0
- package/dist/utils/filesystem.js +140 -0
- package/dist/utils/filetype-detection.d.ts +3 -0
- package/dist/utils/filetype-detection.d.ts.map +1 -0
- package/dist/utils/filetype-detection.js +112 -0
- package/dist/utils/generators.d.ts +3 -0
- package/dist/utils/generators.d.ts.map +1 -0
- package/dist/utils/generators.js +25 -0
- package/dist/utils/glob.d.ts +52 -0
- package/dist/utils/glob.d.ts.map +1 -0
- package/dist/utils/glob.js +376 -0
- package/dist/utils/ignore.d.ts +104 -0
- package/dist/utils/ignore.d.ts.map +1 -0
- package/dist/utils/ignore.js +649 -0
- package/dist/utils/iterables.d.ts +2 -0
- package/dist/utils/iterables.d.ts.map +1 -0
- package/dist/utils/iterables.js +6 -0
- package/dist/utils/process.d.ts +3 -2
- package/dist/utils/process.d.ts.map +1 -0
- package/dist/utils/process.js +17 -2
- package/dist/utils/zod-utils.d.ts +4 -0
- package/dist/utils/zod-utils.d.ts.map +1 -0
- package/dist/utils/zod-utils.js +7 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +34 -32
- package/dist/conversation-analyzer.d.ts +0 -10
- package/dist/conversation-analyzer.js +0 -88
- package/dist/repl-prompt.d.ts +0 -14
- package/dist/tools/command-validation.d.ts +0 -11
- package/dist/tools/command-validation.js +0 -45
- /package/dist/{token-tracker.js → tokens/tracker.js} +0 -0
|
@@ -3,229 +3,165 @@ import { randomUUID } from "node:crypto";
|
|
|
3
3
|
import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import process from "node:process";
|
|
6
|
-
import { tool } from "ai";
|
|
7
6
|
import { z } from "zod";
|
|
7
|
+
import { manageTokenLimit } from "../tokens/threshold.js";
|
|
8
8
|
export const CodeInterpreterTool = {
|
|
9
9
|
name: "codeInterpreter",
|
|
10
10
|
};
|
|
11
|
-
const toolDescription = `Executes
|
|
12
|
-
|
|
13
|
-
⚠️ **IMPORTANT TYPE SELECTION**:
|
|
14
|
-
- Use "JavaScript" for plain JavaScript code (no TypeScript syntax)
|
|
15
|
-
- Use "Typescript" for code containing interfaces, type annotations, generics, etc.
|
|
16
|
-
- Code type is automatically validated before execution
|
|
11
|
+
const toolDescription = `Executes Typescript code in a separate Node.js process using Node's Permission Model.
|
|
17
12
|
|
|
18
13
|
⚠️ **IMPORTANT**: This tool uses ES Modules (ESM) only.
|
|
19
14
|
- Use \`import\` statements, NOT \`require()\`
|
|
20
15
|
- Examples: \`import fs from 'node:fs'\` NOT \`const fs = require('fs')\`
|
|
21
16
|
- Add file extensions for relative imports: \`import { utils } from './utils.js'\`
|
|
22
17
|
|
|
23
|
-
These scripts are run in the \`${process.cwd}/.acai-ci-tmp\`.
|
|
18
|
+
These scripts are run in the \`${process.cwd()}/.acai-ci-tmp\`. You can import project source files using relative paths from the project root with .ts extensions:
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*/
|
|
29
|
-
function containsTypeScriptSyntax(code) {
|
|
30
|
-
// Common TypeScript patterns that don't exist in JavaScript
|
|
31
|
-
const tsPatterns = [
|
|
32
|
-
// Type annotations
|
|
33
|
-
/:\s*[a-zA-Z]\w*(?:\s*\[])?\s*(?=[,;=)])/g, // Type annotations after variables/parameters (including any, string[], etc.)
|
|
34
|
-
/:\s*\{[^}]*\}\s*(?=[,;=)])/g, // Object type annotations
|
|
35
|
-
/:\s*\([^)]*\)\s*=>/g, // Function type annotations
|
|
36
|
-
// Type declarations
|
|
37
|
-
/^\s*interface\s+\w+/gm, // Interface declarations
|
|
38
|
-
/^\s*type\s+\w+\s*=/gm, // Type aliases
|
|
39
|
-
/^\s*enum\s+\w+/gm, // Enum declarations
|
|
40
|
-
// Generic types
|
|
41
|
-
/<\s*[A-Z]\w*(?:\s*,\s*[A-Z]\w*)*\s*>/g, // Generic type parameters
|
|
42
|
-
/\w+\s*<\s*[^<>]+?\s*>/g, // Generic type usage
|
|
43
|
-
// TypeScript-specific keywords (in specific contexts)
|
|
44
|
-
/\b(?:implements|extends\s+[A-Z]\w*|readonly|private|protected|public)\b/g,
|
|
45
|
-
// Utility types
|
|
46
|
-
/\b(?:Partial|Required|Pick|Omit|Record|Exclude|Extract)\b/g,
|
|
47
|
-
];
|
|
48
|
-
return tsPatterns.some((pattern) => pattern.test(code));
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Validates that code content matches the specified type
|
|
52
|
-
*/
|
|
53
|
-
function validateCodeTypeMatch(code, specifiedType) {
|
|
54
|
-
if (!code?.trim()) {
|
|
55
|
-
return "No code provided";
|
|
56
|
-
}
|
|
57
|
-
const detectedType = containsTypeScriptSyntax(code)
|
|
58
|
-
? "Typescript"
|
|
59
|
-
: "JavaScript";
|
|
60
|
-
const expectedType = specifiedType ?? "JavaScript";
|
|
61
|
-
// If TypeScript syntax detected but JavaScript specified
|
|
62
|
-
if (detectedType === "Typescript" && expectedType === "JavaScript") {
|
|
63
|
-
return `Code contains TypeScript syntax but is specified as JavaScript. Please either:
|
|
64
|
-
1. Change type to "Typescript", or
|
|
65
|
-
2. Remove TypeScript syntax (interfaces, type annotations, generics, etc.)
|
|
20
|
+
\`\`\` typescript
|
|
21
|
+
import { functionName } from '../source/path/to/module.ts';
|
|
22
|
+
\`\`\`
|
|
66
23
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
data: {
|
|
136
|
-
primary: "Executing...",
|
|
137
|
-
secondary: [
|
|
138
|
-
`${"`".repeat(3)} ${scriptType}}\n${code.slice(0, 500)}${"`".repeat(3)}`,
|
|
139
|
-
],
|
|
140
|
-
},
|
|
141
|
-
});
|
|
142
|
-
if (code.trim().length === 0) {
|
|
143
|
-
throw new Error("No code provided");
|
|
144
|
-
}
|
|
145
|
-
const timeoutMs = Math.min(Math.max((timeoutSeconds ?? 5) * 1000, 1000), 60000);
|
|
146
|
-
const tmpBase = join(workingDirectory, ".acai-ci-tmp");
|
|
147
|
-
await mkdir(tmpBase, { recursive: true });
|
|
148
|
-
const ext = type === "JavaScript" ? ".mjs" : ".ts";
|
|
149
|
-
const scriptPath = join(tmpBase, `temp_script_${Date.now()}_${randomUUID()}${ext}`);
|
|
150
|
-
await writeFile(scriptPath, code, { encoding: "utf8" });
|
|
151
|
-
const args = [
|
|
152
|
-
"--permission",
|
|
153
|
-
`--allow-fs-read=${workingDirectory}`,
|
|
154
|
-
`--allow-fs-write=${workingDirectory}`,
|
|
155
|
-
scriptPath,
|
|
156
|
-
];
|
|
157
|
-
const child = spawn(process.execPath, args, {
|
|
158
|
-
cwd: workingDirectory,
|
|
159
|
-
// do not rely solely on spawn's timeout; we implement manual timeout below
|
|
160
|
-
stdio: "pipe",
|
|
161
|
-
env: Object.assign({}, process.env, {
|
|
162
|
-
// biome-ignore lint/style/useNamingConvention: Environment variable keys are uppercase by convention
|
|
163
|
-
NO_COLOR: "true",
|
|
164
|
-
// biome-ignore lint/style/useNamingConvention: Environment variable keys are uppercase by convention
|
|
165
|
-
NODE_OPTIONS: "",
|
|
166
|
-
}),
|
|
167
|
-
});
|
|
168
|
-
let stdout = "";
|
|
169
|
-
let stderr = "";
|
|
170
|
-
let timedOut = false;
|
|
171
|
-
const timer = setTimeout(() => {
|
|
172
|
-
timedOut = true;
|
|
173
|
-
try {
|
|
174
|
-
child.kill("SIGKILL");
|
|
175
|
-
}
|
|
176
|
-
catch { }
|
|
177
|
-
}, timeoutMs);
|
|
178
|
-
child.stdout.setEncoding("utf8");
|
|
179
|
-
child.stderr.setEncoding("utf8");
|
|
180
|
-
child.stdout.on("data", (chunk) => {
|
|
181
|
-
stdout += String(chunk);
|
|
182
|
-
});
|
|
183
|
-
child.stderr.on("data", (chunk) => {
|
|
184
|
-
stderr += String(chunk);
|
|
185
|
-
});
|
|
186
|
-
const completed = await new Promise((resolve, reject) => {
|
|
187
|
-
child.on("error", (err) => reject(err));
|
|
188
|
-
child.on("close", (code, signal) => resolve({ code, signal }));
|
|
189
|
-
});
|
|
190
|
-
clearTimeout(timer);
|
|
191
|
-
// Cleanup temp file/directory
|
|
192
|
-
await rm(scriptPath, { force: true });
|
|
193
|
-
await rm(tmpBase, { force: true, recursive: true });
|
|
194
|
-
if (timedOut) {
|
|
195
|
-
throw new Error("Script timed out");
|
|
196
|
-
}
|
|
197
|
-
if (completed.code === null) {
|
|
198
|
-
throw new Error(`Process terminated by signal ${completed.signal ?? "unknown"}`);
|
|
199
|
-
}
|
|
200
|
-
if (completed.code !== 0) {
|
|
201
|
-
const message = `Process exited with code ${completed.code}. Stderr: ${stderr.trim()}`;
|
|
202
|
-
throw new Error(message);
|
|
24
|
+
The interpreter supports ES Modules with TypeScript files directly.
|
|
25
|
+
|
|
26
|
+
Timeout defaults to 5 seconds and can be extended up to 60 seconds.`;
|
|
27
|
+
const inputSchema = z.object({
|
|
28
|
+
code: z.string().describe("The Typescript code to be executed."),
|
|
29
|
+
timeoutSeconds: z
|
|
30
|
+
.number()
|
|
31
|
+
.int()
|
|
32
|
+
.min(1)
|
|
33
|
+
.max(60)
|
|
34
|
+
.nullable()
|
|
35
|
+
.describe("Execution timeout in seconds (1-60). Default 5."),
|
|
36
|
+
});
|
|
37
|
+
export const createCodeInterpreterTool = async ({ tokenCounter, }) => {
|
|
38
|
+
const toolDef = {
|
|
39
|
+
description: toolDescription,
|
|
40
|
+
inputSchema,
|
|
41
|
+
};
|
|
42
|
+
async function* execute({ code, timeoutSeconds }, { toolCallId, abortSignal }) {
|
|
43
|
+
// Check if execution has been aborted
|
|
44
|
+
if (abortSignal?.aborted) {
|
|
45
|
+
throw new Error("Code interpretation aborted");
|
|
46
|
+
}
|
|
47
|
+
const workingDirectory = process.cwd();
|
|
48
|
+
const lines = code.split("\n");
|
|
49
|
+
try {
|
|
50
|
+
yield {
|
|
51
|
+
name: CodeInterpreterTool.name,
|
|
52
|
+
event: "tool-init",
|
|
53
|
+
id: toolCallId,
|
|
54
|
+
data: `Executing ${lines.length} lines of code.`,
|
|
55
|
+
};
|
|
56
|
+
if (code.trim().length === 0) {
|
|
57
|
+
throw new Error("No code provided");
|
|
58
|
+
}
|
|
59
|
+
if (abortSignal?.aborted) {
|
|
60
|
+
throw new Error("Code interpretation aborted before execution");
|
|
61
|
+
}
|
|
62
|
+
const timeoutMs = Math.min(Math.max((timeoutSeconds ?? 5) * 1000, 1000), 60000);
|
|
63
|
+
const tmpBase = join(workingDirectory, ".acai-ci-tmp");
|
|
64
|
+
await mkdir(tmpBase, { recursive: true });
|
|
65
|
+
const ext = ".ts";
|
|
66
|
+
const scriptPath = join(tmpBase, `temp_script_${Date.now()}_${randomUUID()}${ext}`);
|
|
67
|
+
await writeFile(scriptPath, code, { encoding: "utf8" });
|
|
68
|
+
const args = [
|
|
69
|
+
"--permission",
|
|
70
|
+
`--allow-fs-read=${workingDirectory}`,
|
|
71
|
+
`--allow-fs-write=${workingDirectory}`,
|
|
72
|
+
scriptPath,
|
|
73
|
+
];
|
|
74
|
+
const child = spawn(process.execPath, args, {
|
|
75
|
+
cwd: workingDirectory,
|
|
76
|
+
// do not rely solely on spawn's timeout; we implement manual timeout below
|
|
77
|
+
stdio: "pipe",
|
|
78
|
+
env: Object.assign({}, process.env, {
|
|
79
|
+
// biome-ignore lint/style/useNamingConvention: Environment variable keys are uppercase by convention
|
|
80
|
+
NO_COLOR: "true",
|
|
81
|
+
// biome-ignore lint/style/useNamingConvention: Environment variable keys are uppercase by convention
|
|
82
|
+
NODE_OPTIONS: "",
|
|
83
|
+
// biome-ignore lint/style/useNamingConvention: Environment variable keys are uppercase by convention
|
|
84
|
+
ACAI_CODE_INTERPRETER: "true",
|
|
85
|
+
}),
|
|
86
|
+
});
|
|
87
|
+
// Handle abort signal by killing the child process
|
|
88
|
+
if (abortSignal) {
|
|
89
|
+
const abortHandler = () => {
|
|
90
|
+
try {
|
|
91
|
+
child.kill("SIGKILL");
|
|
203
92
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
catch (err) {
|
|
217
|
-
const errorMessage = err.name === "ETIMEDOUT" ||
|
|
218
|
-
err.message.includes("timed out")
|
|
219
|
-
? "Script timed out"
|
|
220
|
-
: `Error: ${err.message}`;
|
|
221
|
-
sendData?.({
|
|
222
|
-
event: "tool-error",
|
|
223
|
-
id: toolCallId,
|
|
224
|
-
data: errorMessage,
|
|
225
|
-
});
|
|
226
|
-
return errorMessage;
|
|
93
|
+
catch { }
|
|
94
|
+
throw new Error("Code interpretation aborted during execution");
|
|
95
|
+
};
|
|
96
|
+
abortSignal.addEventListener("abort", abortHandler);
|
|
97
|
+
}
|
|
98
|
+
let stdout = "";
|
|
99
|
+
let stderr = "";
|
|
100
|
+
let timedOut = false;
|
|
101
|
+
const timer = setTimeout(() => {
|
|
102
|
+
timedOut = true;
|
|
103
|
+
try {
|
|
104
|
+
child.kill("SIGKILL");
|
|
227
105
|
}
|
|
228
|
-
|
|
229
|
-
|
|
106
|
+
catch { }
|
|
107
|
+
}, timeoutMs);
|
|
108
|
+
child.stdout.setEncoding("utf8");
|
|
109
|
+
child.stderr.setEncoding("utf8");
|
|
110
|
+
child.stdout.on("data", (chunk) => {
|
|
111
|
+
stdout += String(chunk);
|
|
112
|
+
});
|
|
113
|
+
child.stderr.on("data", (chunk) => {
|
|
114
|
+
stderr += String(chunk);
|
|
115
|
+
});
|
|
116
|
+
const completed = await new Promise((resolve, reject) => {
|
|
117
|
+
child.on("error", (err) => reject(err));
|
|
118
|
+
child.on("close", (code, signal) => resolve({ code, signal }));
|
|
119
|
+
});
|
|
120
|
+
clearTimeout(timer);
|
|
121
|
+
// Cleanup temp file/directory
|
|
122
|
+
await rm(scriptPath, { force: true });
|
|
123
|
+
await rm(tmpBase, { force: true, recursive: true });
|
|
124
|
+
if (timedOut) {
|
|
125
|
+
throw new Error("Script timed out");
|
|
126
|
+
}
|
|
127
|
+
if (completed.code === null) {
|
|
128
|
+
throw new Error(`Process terminated by signal ${completed.signal ?? "unknown"}`);
|
|
129
|
+
}
|
|
130
|
+
if (completed.code !== 0) {
|
|
131
|
+
const message = `Process exited with code ${completed.code}. Stderr:\n${stderr.trim()}`;
|
|
132
|
+
throw new Error(message);
|
|
133
|
+
}
|
|
134
|
+
const result = {
|
|
135
|
+
stdout: stdout.trim(),
|
|
136
|
+
stderr: stderr.trim(),
|
|
137
|
+
exitCode: completed.code ?? -1,
|
|
138
|
+
};
|
|
139
|
+
const resultJson = JSON.stringify(result, null, 2);
|
|
140
|
+
const managedResult = await manageTokenLimit(resultJson, tokenCounter, "CodeInterpreter", "Reduce script complexity or output size");
|
|
141
|
+
yield {
|
|
142
|
+
name: CodeInterpreterTool.name,
|
|
143
|
+
event: "tool-completion",
|
|
144
|
+
id: toolCallId,
|
|
145
|
+
data: `Completed successfully${managedResult.tokenCount > 0 ? ` (${managedResult.tokenCount} tokens)` : ""}`,
|
|
146
|
+
};
|
|
147
|
+
yield managedResult.content;
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
const errorMessage = err.name === "ETIMEDOUT" ||
|
|
151
|
+
err.message.includes("timed out")
|
|
152
|
+
? "Script timed out"
|
|
153
|
+
: err.message;
|
|
154
|
+
yield {
|
|
155
|
+
name: CodeInterpreterTool.name,
|
|
156
|
+
event: "tool-error",
|
|
157
|
+
id: toolCallId,
|
|
158
|
+
data: errorMessage,
|
|
159
|
+
};
|
|
160
|
+
yield errorMessage;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
toolDef,
|
|
165
|
+
execute,
|
|
230
166
|
};
|
|
231
167
|
};
|
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
1
|
+
import type { ToolCallOptions } from "ai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import type { ToolResult } from "./types.ts";
|
|
3
4
|
export declare const DeleteFileTool: {
|
|
4
5
|
name: "deleteFile";
|
|
5
6
|
};
|
|
6
|
-
|
|
7
|
+
declare const inputSchema: z.ZodObject<{
|
|
8
|
+
path: z.ZodString;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
type DeleteFileInputSchema = z.infer<typeof inputSchema>;
|
|
11
|
+
export declare const createDeleteFileTool: ({ workingDir, allowedDirs, }: {
|
|
7
12
|
workingDir: string;
|
|
8
|
-
|
|
9
|
-
terminal?: Terminal;
|
|
10
|
-
autoAcceptAll?: boolean;
|
|
13
|
+
allowedDirs?: string[];
|
|
11
14
|
}) => Promise<{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
toolDef: {
|
|
16
|
+
description: string;
|
|
17
|
+
inputSchema: z.ZodObject<{
|
|
18
|
+
path: z.ZodString;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
};
|
|
21
|
+
execute({ path: userPath }: DeleteFileInputSchema, { toolCallId, abortSignal }: ToolCallOptions): AsyncGenerator<ToolResult>;
|
|
15
22
|
}>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=delete-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-file.d.ts","sourceRoot":"","sources":["../../source/tools/delete-file.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,eAAO,MAAM,cAAc;;CAE1B,CAAC;AAEF,QAAA,MAAM,WAAW;;iBAEf,CAAC;AAEH,KAAK,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEzD,eAAO,MAAM,oBAAoB,GAAU,8BAGxC;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;;;;;;;gCASyB,qBAAqB,+BACZ,eAAe,GAC3C,cAAc,CAAC,UAAU,CAAC;EA2DhC,CAAC"}
|
|
@@ -1,100 +1,70 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
|
-
import { input, select } from "@inquirer/prompts";
|
|
4
|
-
import { tool } from "ai";
|
|
5
|
-
import chalk from "chalk";
|
|
6
3
|
import { z } from "zod";
|
|
4
|
+
import style from "../terminal/style.js";
|
|
7
5
|
import { joinWorkingDir, validatePath } from "./filesystem-utils.js";
|
|
8
6
|
export const DeleteFileTool = {
|
|
9
7
|
name: "deleteFile",
|
|
10
8
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const inputSchema = z.object({
|
|
10
|
+
path: z.string().describe("Absolute path to the file to delete"),
|
|
11
|
+
});
|
|
12
|
+
export const createDeleteFileTool = async ({ workingDir, allowedDirs, }) => {
|
|
13
|
+
const allowedDirectory = allowedDirs ?? [workingDir];
|
|
14
14
|
return {
|
|
15
|
-
|
|
15
|
+
toolDef: {
|
|
16
16
|
description: "Delete a file permanently.",
|
|
17
|
-
inputSchema
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
inputSchema,
|
|
18
|
+
},
|
|
19
|
+
async *execute({ path: userPath }, { toolCallId, abortSignal }) {
|
|
20
|
+
try {
|
|
21
|
+
if (abortSignal?.aborted) {
|
|
22
|
+
throw new Error("File deletion aborted");
|
|
23
|
+
}
|
|
24
|
+
yield {
|
|
25
|
+
name: DeleteFileTool.name,
|
|
22
26
|
id: toolCallId,
|
|
23
27
|
event: "tool-init",
|
|
24
|
-
data:
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
terminal.lineBreak();
|
|
40
|
-
terminal.writeln("This action cannot be undone.");
|
|
41
|
-
terminal.lineBreak();
|
|
42
|
-
let userChoice;
|
|
43
|
-
if (autoAcceptDeletes) {
|
|
44
|
-
terminal.writeln(chalk.green("✓ Auto-accepting deletions (all future deletions will be accepted)"));
|
|
45
|
-
userChoice = "accept";
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
userChoice = await select({
|
|
49
|
-
message: "What would you like to do with this file?",
|
|
50
|
-
choices: [
|
|
51
|
-
{ name: "Accept and delete this file", value: "accept" },
|
|
52
|
-
{
|
|
53
|
-
name: "Accept all future deletions (including this)",
|
|
54
|
-
value: "accept-all",
|
|
55
|
-
},
|
|
56
|
-
{ name: "Reject this deletion", value: "reject" },
|
|
57
|
-
],
|
|
58
|
-
default: "accept",
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
terminal.lineBreak();
|
|
62
|
-
if (userChoice === "accept-all") {
|
|
63
|
-
autoAcceptDeletes = true;
|
|
64
|
-
terminal.writeln(chalk.yellow("✓ Auto-accept mode enabled for all future deletions"));
|
|
65
|
-
terminal.lineBreak();
|
|
66
|
-
}
|
|
67
|
-
if (userChoice === "reject") {
|
|
68
|
-
const reason = await input({ message: "Feedback: " });
|
|
69
|
-
terminal.lineBreak();
|
|
70
|
-
sendData?.({
|
|
71
|
-
id: toolCallId,
|
|
72
|
-
event: "tool-completion",
|
|
73
|
-
data: `Deletion rejected by user. Reason: ${reason}`,
|
|
74
|
-
});
|
|
75
|
-
return `The user rejected this deletion. Reason: ${reason}`;
|
|
76
|
-
}
|
|
77
|
-
// If accepted, proceed to delete file
|
|
78
|
-
}
|
|
79
|
-
// Delete the file
|
|
80
|
-
await fs.unlink(filePath);
|
|
81
|
-
sendData?.({
|
|
82
|
-
id: toolCallId,
|
|
83
|
-
event: "tool-completion",
|
|
84
|
-
data: "File deleted successfully",
|
|
85
|
-
});
|
|
86
|
-
return `Successfully deleted ${filePath}`;
|
|
28
|
+
data: `${style.cyan(userPath)}`,
|
|
29
|
+
};
|
|
30
|
+
const filePath = await validatePath(joinWorkingDir(userPath, workingDir), allowedDirectory, { abortSignal });
|
|
31
|
+
// Check if file exists before attempting delete
|
|
32
|
+
if (!existsSync(filePath)) {
|
|
33
|
+
throw new Error(`File not found: ${filePath}`);
|
|
34
|
+
}
|
|
35
|
+
// Pre-check for stat
|
|
36
|
+
if (abortSignal?.aborted) {
|
|
37
|
+
throw new Error("File deletion aborted before stat");
|
|
38
|
+
}
|
|
39
|
+
// Ensure it's a file, not a directory
|
|
40
|
+
const stats = await fs.stat(filePath);
|
|
41
|
+
if (stats.isDirectory()) {
|
|
42
|
+
throw new Error(`Path is a directory, not a file: ${filePath}`);
|
|
87
43
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
id: toolCallId,
|
|
92
|
-
event: "tool-error",
|
|
93
|
-
data: errorMessage,
|
|
94
|
-
});
|
|
95
|
-
return errorMessage;
|
|
44
|
+
// Pre-side-effect check
|
|
45
|
+
if (abortSignal?.aborted) {
|
|
46
|
+
throw new Error("File deletion aborted before unlink");
|
|
96
47
|
}
|
|
97
|
-
|
|
98
|
-
|
|
48
|
+
// Delete the file with signal
|
|
49
|
+
await fs.unlink(filePath);
|
|
50
|
+
yield {
|
|
51
|
+
name: DeleteFileTool.name,
|
|
52
|
+
id: toolCallId,
|
|
53
|
+
event: "tool-completion",
|
|
54
|
+
data: "File deleted",
|
|
55
|
+
};
|
|
56
|
+
yield `Successfully deleted ${filePath}`;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
const errorMessage = error.message;
|
|
60
|
+
yield {
|
|
61
|
+
name: DeleteFileTool.name,
|
|
62
|
+
id: toolCallId,
|
|
63
|
+
event: "tool-error",
|
|
64
|
+
data: errorMessage,
|
|
65
|
+
};
|
|
66
|
+
yield errorMessage;
|
|
67
|
+
}
|
|
68
|
+
},
|
|
99
69
|
};
|
|
100
70
|
};
|
|
@@ -1,12 +1,32 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ToolCallOptions } from "ai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import type { TokenCounter } from "../tokens/counter.ts";
|
|
4
|
+
import type { ToolResult } from "./types.ts";
|
|
2
5
|
export declare const DirectoryTreeTool: {
|
|
3
6
|
name: "directoryTree";
|
|
4
7
|
};
|
|
5
|
-
|
|
8
|
+
declare const inputSchema: z.ZodObject<{
|
|
9
|
+
path: z.ZodString;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
type DirectoryTreeInputSchema = z.infer<typeof inputSchema>;
|
|
12
|
+
export declare const createDirectoryTreeTool: ({ workingDir, allowedDirs, tokenCounter, }: {
|
|
6
13
|
workingDir: string;
|
|
7
|
-
|
|
14
|
+
allowedDirs?: string[];
|
|
15
|
+
tokenCounter: TokenCounter;
|
|
8
16
|
}) => Promise<{
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
17
|
+
toolDef: {
|
|
18
|
+
description: string;
|
|
19
|
+
inputSchema: z.ZodObject<{
|
|
20
|
+
path: z.ZodString;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
};
|
|
23
|
+
execute({ path }: DirectoryTreeInputSchema, { toolCallId, abortSignal }: ToolCallOptions): AsyncGenerator<ToolResult>;
|
|
12
24
|
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Generates a string representation of a directory tree starting from the given path.
|
|
27
|
+
* @param dirPath - The path of the directory to generate the tree for.
|
|
28
|
+
* @returns A Promise that resolves to a string representation of the directory tree.
|
|
29
|
+
*/
|
|
30
|
+
export declare function directoryTree(dirPath: string): Promise<string>;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=directory-tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-tree.d.ts","sourceRoot":"","sources":["../../source/tools/directory-tree.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,eAAO,MAAM,iBAAiB;;CAE7B,CAAC;AAEF,QAAA,MAAM,WAAW;;iBAEf,CAAC;AAEH,KAAK,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAE5D,eAAO,MAAM,uBAAuB,GAAU,4CAI3C;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;CAC5B;;;;;;;sBASe,wBAAwB,+BACL,eAAe,GAC3C,cAAc,CAAC,UAAU,CAAC;EA+DhC,CAAC;AA8CF;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAYpE"}
|