@travisennis/acai 0.0.5 → 0.0.7
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 +190 -19
- package/bin/acai-wrapper.js +26 -0
- package/dist/agent/index.d.ts +132 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +434 -0
- package/dist/api/exa/index.js +1 -1
- package/dist/cli.d.ts +4 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +67 -40
- 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 +54 -0
- package/dist/commands/application-log-command.d.ts +1 -1
- package/dist/commands/application-log-command.d.ts.map +1 -1
- package/dist/commands/application-log-command.js +18 -20
- package/dist/commands/clear-command.d.ts +1 -1
- package/dist/commands/clear-command.d.ts.map +1 -1
- package/dist/commands/clear-command.js +7 -3
- package/dist/commands/compact-command.d.ts.map +1 -1
- package/dist/commands/compact-command.js +9 -5
- 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 +124 -0
- package/dist/commands/copy-command.d.ts.map +1 -1
- package/dist/commands/copy-command.js +14 -5
- package/dist/commands/edit-command.d.ts +1 -1
- package/dist/commands/edit-command.d.ts.map +1 -1
- package/dist/commands/edit-command.js +21 -34
- package/dist/commands/edit-prompt-command.d.ts +1 -1
- package/dist/commands/edit-prompt-command.d.ts.map +1 -1
- package/dist/commands/edit-prompt-command.js +18 -15
- package/dist/commands/exit-command.d.ts +1 -4
- package/dist/commands/exit-command.d.ts.map +1 -1
- package/dist/commands/exit-command.js +9 -5
- package/dist/commands/files-command.d.ts +1 -1
- package/dist/commands/files-command.d.ts.map +1 -1
- package/dist/commands/files-command.js +20 -16
- package/dist/commands/generate-rules-command.d.ts +1 -1
- package/dist/commands/generate-rules-command.d.ts.map +1 -1
- package/dist/commands/generate-rules-command.js +307 -39
- 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 +191 -0
- package/dist/commands/health-command.d.ts +1 -1
- package/dist/commands/health-command.d.ts.map +1 -1
- package/dist/commands/health-command.js +49 -27
- package/dist/commands/help-command.d.ts +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +25 -5
- 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 +458 -0
- package/dist/commands/init-command.d.ts +1 -1
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/init-command.js +40 -22
- package/dist/commands/last-log-command.d.ts +1 -1
- package/dist/commands/last-log-command.d.ts.map +1 -1
- package/dist/commands/last-log-command.js +15 -15
- 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 +35 -0
- package/dist/commands/list-tools-command.d.ts.map +1 -1
- package/dist/commands/list-tools-command.js +61 -21
- package/dist/commands/manager.d.ts +9 -4
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +64 -39
- package/dist/commands/model-command.d.ts.map +1 -1
- package/dist/commands/model-command.js +201 -66
- package/dist/commands/paste-command.d.ts +1 -1
- package/dist/commands/paste-command.d.ts.map +1 -1
- package/dist/commands/paste-command.js +23 -9
- 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 +109 -0
- package/dist/commands/prompt-command.d.ts +19 -1
- package/dist/commands/prompt-command.d.ts.map +1 -1
- package/dist/commands/prompt-command.js +191 -98
- 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 +55 -0
- package/dist/commands/reset-command.d.ts +1 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/reset-command.js +8 -5
- package/dist/commands/rules-command.d.ts +1 -1
- package/dist/commands/rules-command.d.ts.map +1 -1
- package/dist/commands/rules-command.js +25 -22
- package/dist/commands/save-command.d.ts +1 -1
- package/dist/commands/save-command.d.ts.map +1 -1
- package/dist/commands/save-command.js +8 -3
- package/dist/commands/shell-command.d.ts.map +1 -1
- package/dist/commands/shell-command.js +45 -24
- package/dist/commands/types.d.ts +9 -7
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/usage-command.d.ts +1 -1
- package/dist/commands/usage-command.d.ts.map +1 -1
- package/dist/commands/usage-command.js +18 -7
- package/dist/config.d.ts +21 -11
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +90 -63
- package/dist/execution/index.d.ts +17 -2
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +62 -20
- package/dist/formatting.d.ts +127 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +201 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +263 -102
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +47 -18
- package/dist/mentions.d.ts +2 -1
- package/dist/mentions.d.ts.map +1 -1
- package/dist/mentions.js +16 -1
- package/dist/messages.d.ts +11 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +122 -21
- 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 +1 -0
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/index.js +1 -0
- package/dist/models/ai-config.d.ts +4 -2
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +12 -2
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/anthropic-provider.js +3 -67
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/deepseek-provider.js +0 -2
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/google-provider.js +0 -3
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.js +0 -1
- package/dist/models/manager.d.ts +2 -1
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +26 -2
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +0 -4
- package/dist/models/openrouter-provider.d.ts +16 -22
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +175 -236
- package/dist/models/providers.d.ts +4 -14
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +1 -57
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +0 -2
- package/dist/prompts.d.ts +10 -4
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +447 -70
- package/dist/repl/project-status-line.d.ts +3 -0
- package/dist/repl/project-status-line.d.ts.map +1 -0
- package/dist/repl/project-status-line.js +61 -0
- package/dist/repl/tool-call-repair.d.ts.map +1 -1
- package/dist/repl/tool-call-repair.js +8 -4
- package/dist/repl-new.d.ts +51 -0
- package/dist/repl-new.d.ts.map +1 -0
- package/dist/repl-new.js +354 -0
- package/dist/skills.d.ts +20 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +192 -0
- package/dist/terminal/control.d.ts +55 -0
- package/dist/terminal/control.d.ts.map +1 -0
- package/dist/terminal/control.js +109 -0
- package/dist/terminal/default-theme.d.ts +1 -1
- package/dist/terminal/default-theme.d.ts.map +1 -1
- package/dist/terminal/default-theme.js +24 -28
- package/dist/terminal/formatting.d.ts +23 -25
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +35 -52
- package/dist/terminal/highlight/index.d.ts.map +1 -1
- package/dist/terminal/highlight/index.js +3 -6
- package/dist/terminal/highlight/theme.d.ts.map +1 -1
- package/dist/terminal/highlight/theme.js +2 -6
- package/dist/terminal/index.d.ts +2 -94
- package/dist/terminal/index.d.ts.map +1 -1
- package/dist/terminal/index.js +2 -370
- package/dist/terminal/markdown.js +10 -5
- package/dist/terminal/select-prompt.d.ts +2 -2
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +47 -39
- package/dist/terminal/strip-ansi.js +4 -4
- package/dist/terminal/table/cell.d.ts +114 -0
- package/dist/terminal/table/cell.d.ts.map +1 -0
- package/dist/terminal/table/cell.js +407 -0
- package/dist/terminal/table/debug.d.ts +15 -0
- package/dist/terminal/table/debug.d.ts.map +1 -0
- package/dist/terminal/table/debug.js +32 -0
- package/dist/terminal/table/index.d.ts +3 -0
- package/dist/terminal/table/index.d.ts.map +1 -0
- package/dist/terminal/table/index.js +2 -0
- package/dist/terminal/table/layout-manager.d.ts +27 -0
- package/dist/terminal/table/layout-manager.d.ts.map +1 -0
- package/dist/terminal/table/layout-manager.js +257 -0
- package/dist/terminal/table/table.d.ts +9 -0
- package/dist/terminal/table/table.d.ts.map +1 -0
- package/dist/terminal/table/table.js +97 -0
- package/dist/terminal/table/utils.d.ts +63 -0
- package/dist/terminal/table/utils.d.ts.map +1 -0
- package/dist/terminal/table/utils.js +326 -0
- package/dist/tokens/threshold.d.ts +20 -0
- package/dist/tokens/threshold.d.ts.map +1 -0
- package/dist/tokens/threshold.js +67 -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 +285 -0
- package/dist/tools/agent.d.ts +16 -5
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/agent.js +86 -59
- package/dist/tools/bash.d.ts +23 -12
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +243 -128
- package/dist/tools/batch.d.ts +34 -0
- package/dist/tools/batch.d.ts.map +1 -0
- package/dist/tools/batch.js +174 -0
- package/dist/tools/code-interpreter.d.ts +21 -9
- package/dist/tools/code-interpreter.d.ts.map +1 -1
- package/dist/tools/code-interpreter.js +151 -134
- package/dist/tools/delete-file.d.ts +17 -10
- package/dist/tools/delete-file.d.ts.map +1 -1
- package/dist/tools/delete-file.js +60 -97
- package/dist/tools/directory-tree.d.ts +17 -12
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +57 -48
- package/dist/tools/dynamic-tool-loader.d.ts +16 -10
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +122 -130
- package/dist/tools/dynamic-tool-parser.d.ts +1 -0
- package/dist/tools/dynamic-tool-parser.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-parser.js +1 -0
- package/dist/tools/edit-file.d.ts +35 -15
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +127 -114
- package/dist/tools/glob.d.ts +36 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +154 -0
- package/dist/tools/grep.d.ts +73 -12
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +425 -165
- package/dist/tools/index.d.ts +220 -126
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +284 -135
- package/dist/tools/llm-edit-fixer.d.ts +24 -0
- package/dist/tools/llm-edit-fixer.d.ts.map +1 -0
- package/dist/tools/llm-edit-fixer.js +136 -0
- package/dist/tools/move-file.d.ts +19 -7
- package/dist/tools/move-file.d.ts.map +1 -1
- package/dist/tools/move-file.js +48 -34
- package/dist/tools/read-file.d.ts +47 -9
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +84 -70
- package/dist/tools/read-multiple-files.d.ts +17 -6
- package/dist/tools/read-multiple-files.d.ts.map +1 -1
- package/dist/tools/read-multiple-files.js +132 -72
- package/dist/tools/save-file.d.ts +45 -12
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +76 -101
- package/dist/tools/think.d.ts +15 -7
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +34 -20
- package/dist/tools/types.d.ts +8 -10
- package/dist/tools/types.d.ts.map +1 -1
- 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 +11 -4
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +39 -38
- package/dist/tools/web-search.d.ts +15 -6
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +64 -31
- 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/box.d.ts +20 -0
- package/dist/tui/components/box.d.ts.map +1 -0
- package/dist/tui/components/box.js +81 -0
- package/dist/tui/components/editor.d.ts +106 -0
- package/dist/tui/components/editor.d.ts.map +1 -0
- package/dist/tui/components/editor.js +1220 -0
- package/dist/tui/components/footer.d.ts +12 -0
- package/dist/tui/components/footer.d.ts.map +1 -0
- package/dist/tui/components/footer.js +209 -0
- package/dist/tui/components/header.d.ts +21 -0
- package/dist/tui/components/header.d.ts.map +1 -0
- package/dist/tui/components/header.js +63 -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 +23 -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 +106 -0
- package/dist/tui/components/markdown.d.ts.map +1 -0
- package/dist/tui/components/markdown.js +586 -0
- package/dist/tui/components/modal.d.ts +29 -0
- package/dist/tui/components/modal.d.ts.map +1 -0
- package/dist/tui/components/modal.js +263 -0
- package/dist/tui/components/progress-bar.d.ts +19 -0
- package/dist/tui/components/progress-bar.d.ts.map +1 -0
- package/dist/tui/components/progress-bar.js +78 -0
- package/dist/tui/components/prompt-status.d.ts +17 -0
- package/dist/tui/components/prompt-status.d.ts.map +1 -0
- package/dist/tui/components/prompt-status.js +26 -0
- package/dist/tui/components/select-list.d.ts +48 -0
- package/dist/tui/components/select-list.d.ts.map +1 -0
- package/dist/tui/components/select-list.js +207 -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/table.d.ts +27 -0
- package/dist/tui/components/table.d.ts.map +1 -0
- package/dist/tui/components/table.js +125 -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 +33 -0
- package/dist/tui/components/tool-execution.d.ts +21 -0
- package/dist/tui/components/tool-execution.d.ts.map +1 -0
- package/dist/tui/components/tool-execution.js +161 -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 +23 -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 +18 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +22 -0
- package/dist/tui/terminal.d.ts +38 -0
- package/dist/tui/terminal.d.ts.map +1 -0
- package/dist/tui/terminal.js +94 -0
- package/dist/tui/tui.d.ts +69 -0
- package/dist/tui/tui.d.ts.map +1 -0
- package/dist/tui/tui.js +204 -0
- package/dist/tui/utils.d.ts +24 -0
- package/dist/tui/utils.d.ts.map +1 -0
- package/dist/tui/utils.js +111 -0
- package/dist/utils/bash.d.ts +7 -0
- package/dist/utils/bash.d.ts.map +1 -0
- package/dist/{tools/bash-utils.js → utils/bash.js} +31 -12
- package/dist/utils/{filesystem.d.ts → filesystem/operations.d.ts} +1 -1
- package/dist/utils/filesystem/operations.d.ts.map +1 -0
- package/dist/utils/filesystem/security.d.ts +9 -0
- package/dist/utils/filesystem/security.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.js → utils/filesystem/security.js} +93 -21
- package/dist/utils/funcs.d.ts +6 -0
- package/dist/utils/funcs.d.ts.map +1 -0
- package/dist/utils/funcs.js +6 -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/{tools/git-utils.d.ts → utils/git.d.ts} +1 -1
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/{tools/git-utils.js → utils/git.js} +0 -6
- package/dist/utils/glob.js +1 -1
- 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/{zod-utils.d.ts → zod.d.ts} +1 -1
- package/dist/utils/zod.d.ts.map +1 -0
- package/package.json +21 -21
- package/dist/conversation-analyzer.d.ts +0 -11
- package/dist/conversation-analyzer.d.ts.map +0 -1
- package/dist/conversation-analyzer.js +0 -88
- package/dist/repl/display-tool-messages.d.ts +0 -4
- package/dist/repl/display-tool-messages.d.ts.map +0 -1
- package/dist/repl/display-tool-messages.js +0 -55
- package/dist/repl/display-tool-use.d.ts +0 -14
- package/dist/repl/display-tool-use.d.ts.map +0 -1
- package/dist/repl/display-tool-use.js +0 -63
- package/dist/repl/get-prompt-header.d.ts +0 -8
- package/dist/repl/get-prompt-header.d.ts.map +0 -1
- package/dist/repl/get-prompt-header.js +0 -38
- package/dist/repl-prompt.d.ts +0 -15
- package/dist/repl-prompt.d.ts.map +0 -1
- package/dist/repl-prompt.js +0 -147
- package/dist/repl.d.ts +0 -31
- package/dist/repl.d.ts.map +0 -1
- package/dist/repl.js +0 -310
- package/dist/terminal/checkbox-prompt.d.ts +0 -36
- package/dist/terminal/checkbox-prompt.d.ts.map +0 -1
- package/dist/terminal/checkbox-prompt.js +0 -362
- package/dist/terminal/editor-prompt.d.ts +0 -10
- package/dist/terminal/editor-prompt.d.ts.map +0 -1
- package/dist/terminal/editor-prompt.js +0 -61
- package/dist/terminal/errors.d.ts +0 -19
- package/dist/terminal/errors.d.ts.map +0 -1
- package/dist/terminal/errors.js +0 -37
- package/dist/terminal/input-prompt.d.ts +0 -16
- package/dist/terminal/input-prompt.d.ts.map +0 -1
- package/dist/terminal/input-prompt.js +0 -181
- package/dist/terminal/search-prompt.d.ts +0 -20
- package/dist/terminal/search-prompt.d.ts.map +0 -1
- package/dist/terminal/search-prompt.js +0 -279
- package/dist/terminal/types.d.ts +0 -35
- package/dist/terminal/types.d.ts.map +0 -1
- package/dist/terminal/types.js +0 -1
- package/dist/tokens/manage-output.d.ts +0 -34
- package/dist/tokens/manage-output.d.ts.map +0 -1
- package/dist/tokens/manage-output.js +0 -44
- package/dist/tool-executor.d.ts +0 -28
- package/dist/tool-executor.d.ts.map +0 -1
- package/dist/tool-executor.js +0 -74
- package/dist/tools/bash-utils.d.ts +0 -7
- package/dist/tools/bash-utils.d.ts.map +0 -1
- package/dist/tools/file-editing-utils.d.ts +0 -2
- package/dist/tools/file-editing-utils.d.ts.map +0 -1
- package/dist/tools/file-editing-utils.js +0 -135
- package/dist/tools/filesystem-utils.d.ts +0 -7
- package/dist/tools/filesystem-utils.d.ts.map +0 -1
- package/dist/tools/git-utils.d.ts.map +0 -1
- package/dist/utils/filesystem.d.ts.map +0 -1
- package/dist/utils/zod-utils.d.ts.map +0 -1
- /package/dist/utils/{filesystem.js → filesystem/operations.js} +0 -0
- /package/dist/utils/{zod-utils.js → zod.js} +0 -0
|
@@ -3,8 +3,8 @@ 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, TokenLimitExceededError, } from "../tokens/threshold.js";
|
|
8
8
|
export const CodeInterpreterTool = {
|
|
9
9
|
name: "codeInterpreter",
|
|
10
10
|
};
|
|
@@ -24,143 +24,160 @@ import { functionName } from '../source/path/to/module.ts';
|
|
|
24
24
|
The interpreter supports ES Modules with TypeScript files directly.
|
|
25
25
|
|
|
26
26
|
Timeout defaults to 5 seconds and can be extended up to 60 seconds.`;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
// Handle abort signal by killing the child process
|
|
94
|
-
if (abortSignal) {
|
|
95
|
-
abortSignal.addEventListener("abort", () => {
|
|
96
|
-
try {
|
|
97
|
-
child.kill("SIGKILL");
|
|
98
|
-
}
|
|
99
|
-
catch { }
|
|
100
|
-
throw new Error("Code interpretation aborted during execution");
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
let stdout = "";
|
|
104
|
-
let stderr = "";
|
|
105
|
-
let timedOut = false;
|
|
106
|
-
const timer = setTimeout(() => {
|
|
107
|
-
timedOut = true;
|
|
108
|
-
try {
|
|
109
|
-
child.kill("SIGKILL");
|
|
110
|
-
}
|
|
111
|
-
catch { }
|
|
112
|
-
}, timeoutMs);
|
|
113
|
-
child.stdout.setEncoding("utf8");
|
|
114
|
-
child.stderr.setEncoding("utf8");
|
|
115
|
-
child.stdout.on("data", (chunk) => {
|
|
116
|
-
stdout += String(chunk);
|
|
117
|
-
});
|
|
118
|
-
child.stderr.on("data", (chunk) => {
|
|
119
|
-
stderr += String(chunk);
|
|
120
|
-
});
|
|
121
|
-
const completed = await new Promise((resolve, reject) => {
|
|
122
|
-
child.on("error", (err) => reject(err));
|
|
123
|
-
child.on("close", (code, signal) => resolve({ code, signal }));
|
|
124
|
-
});
|
|
125
|
-
clearTimeout(timer);
|
|
126
|
-
// Cleanup temp file/directory
|
|
127
|
-
await rm(scriptPath, { force: true });
|
|
128
|
-
await rm(tmpBase, { force: true, recursive: true });
|
|
129
|
-
if (timedOut) {
|
|
130
|
-
throw new Error("Script timed out");
|
|
131
|
-
}
|
|
132
|
-
if (completed.code === null) {
|
|
133
|
-
throw new Error(`Process terminated by signal ${completed.signal ?? "unknown"}`);
|
|
134
|
-
}
|
|
135
|
-
if (completed.code !== 0) {
|
|
136
|
-
const message = `Process exited with code ${completed.code}. Stderr:\n${stderr.trim()}`;
|
|
137
|
-
throw new Error(message);
|
|
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
|
+
"--allow-net",
|
|
73
|
+
scriptPath,
|
|
74
|
+
];
|
|
75
|
+
const child = spawn(process.execPath, args, {
|
|
76
|
+
cwd: workingDirectory,
|
|
77
|
+
// do not rely solely on spawn's timeout; we implement manual timeout below
|
|
78
|
+
stdio: "pipe",
|
|
79
|
+
env: Object.assign({}, process.env, {
|
|
80
|
+
// biome-ignore lint/style/useNamingConvention: Environment variable keys are uppercase by convention
|
|
81
|
+
NO_COLOR: "true",
|
|
82
|
+
// biome-ignore lint/style/useNamingConvention: Environment variable keys are uppercase by convention
|
|
83
|
+
NODE_OPTIONS: "",
|
|
84
|
+
// biome-ignore lint/style/useNamingConvention: Environment variable keys are uppercase by convention
|
|
85
|
+
ACAI_CODE_INTERPRETER: "true",
|
|
86
|
+
}),
|
|
87
|
+
});
|
|
88
|
+
// Handle abort signal by killing the child process
|
|
89
|
+
if (abortSignal) {
|
|
90
|
+
const abortHandler = () => {
|
|
91
|
+
try {
|
|
92
|
+
child.kill("SIGKILL");
|
|
138
93
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
94
|
+
catch { }
|
|
95
|
+
throw new Error("Code interpretation aborted during execution");
|
|
96
|
+
};
|
|
97
|
+
abortSignal.addEventListener("abort", abortHandler);
|
|
98
|
+
}
|
|
99
|
+
let stdout = "";
|
|
100
|
+
let stderr = "";
|
|
101
|
+
let timedOut = false;
|
|
102
|
+
const timer = setTimeout(() => {
|
|
103
|
+
timedOut = true;
|
|
104
|
+
try {
|
|
105
|
+
child.kill("SIGKILL");
|
|
150
106
|
}
|
|
151
|
-
catch
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
107
|
+
catch { }
|
|
108
|
+
}, timeoutMs);
|
|
109
|
+
child.stdout.setEncoding("utf8");
|
|
110
|
+
child.stderr.setEncoding("utf8");
|
|
111
|
+
child.stdout.on("data", (chunk) => {
|
|
112
|
+
stdout += String(chunk);
|
|
113
|
+
});
|
|
114
|
+
child.stderr.on("data", (chunk) => {
|
|
115
|
+
stderr += String(chunk);
|
|
116
|
+
});
|
|
117
|
+
const completed = await new Promise((resolve, reject) => {
|
|
118
|
+
child.on("error", (err) => reject(err));
|
|
119
|
+
child.on("close", (code, signal) => resolve({ code, signal }));
|
|
120
|
+
});
|
|
121
|
+
clearTimeout(timer);
|
|
122
|
+
// Cleanup temp file/directory
|
|
123
|
+
await rm(scriptPath, { force: true });
|
|
124
|
+
await rm(tmpBase, { force: true, recursive: true });
|
|
125
|
+
if (timedOut) {
|
|
126
|
+
throw new Error("Script timed out");
|
|
127
|
+
}
|
|
128
|
+
if (completed.code === null) {
|
|
129
|
+
throw new Error(`Process terminated by signal ${completed.signal ?? "unknown"}`);
|
|
130
|
+
}
|
|
131
|
+
if (completed.code !== 0) {
|
|
132
|
+
const message = `Process exited with code ${completed.code}. Stderr:\n${stderr.trim()}`;
|
|
133
|
+
throw new Error(message);
|
|
134
|
+
}
|
|
135
|
+
const result = {
|
|
136
|
+
stdout: stdout.trim(),
|
|
137
|
+
stderr: stderr.trim(),
|
|
138
|
+
exitCode: completed.code ?? -1,
|
|
139
|
+
};
|
|
140
|
+
const resultJson = JSON.stringify(result, null, 2);
|
|
141
|
+
try {
|
|
142
|
+
const managedResult = await manageTokenLimit(resultJson, tokenCounter, "CodeInterpreter", "Reduce script complexity or output size");
|
|
143
|
+
yield {
|
|
144
|
+
name: CodeInterpreterTool.name,
|
|
145
|
+
event: "tool-completion",
|
|
146
|
+
id: toolCallId,
|
|
147
|
+
data: `Completed successfully${managedResult.tokenCount > 0 ? ` (${managedResult.tokenCount} tokens)` : ""}`,
|
|
148
|
+
};
|
|
149
|
+
yield managedResult.content;
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
if (error instanceof TokenLimitExceededError) {
|
|
153
|
+
yield {
|
|
154
|
+
name: CodeInterpreterTool.name,
|
|
157
155
|
event: "tool-error",
|
|
158
156
|
id: toolCallId,
|
|
159
|
-
data:
|
|
160
|
-
}
|
|
161
|
-
|
|
157
|
+
data: error.message,
|
|
158
|
+
};
|
|
159
|
+
yield error.message;
|
|
160
|
+
return;
|
|
162
161
|
}
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
throw error;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
const errorMessage = err.name === "ETIMEDOUT" ||
|
|
167
|
+
err.message.includes("timed out")
|
|
168
|
+
? "Script timed out"
|
|
169
|
+
: err.message;
|
|
170
|
+
yield {
|
|
171
|
+
name: CodeInterpreterTool.name,
|
|
172
|
+
event: "tool-error",
|
|
173
|
+
id: toolCallId,
|
|
174
|
+
data: errorMessage,
|
|
175
|
+
};
|
|
176
|
+
yield errorMessage;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
toolDef,
|
|
181
|
+
execute,
|
|
165
182
|
};
|
|
166
183
|
};
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
1
|
+
import type { ToolCallOptions } from "ai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import type { ToolResult } from "./types.ts";
|
|
4
4
|
export declare const DeleteFileTool: {
|
|
5
5
|
name: "deleteFile";
|
|
6
6
|
};
|
|
7
|
-
|
|
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, }: {
|
|
8
12
|
workingDir: string;
|
|
9
|
-
|
|
10
|
-
sendData?: SendData;
|
|
11
|
-
toolExecutor?: ToolExecutor;
|
|
13
|
+
allowedDirs?: string[];
|
|
12
14
|
}) => Promise<{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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>;
|
|
16
22
|
}>;
|
|
23
|
+
export {};
|
|
17
24
|
//# sourceMappingURL=delete-file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-file.d.ts","sourceRoot":"","sources":["../../source/tools/delete-file.ts"],"names":[],"mappings":"
|
|
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;AASxB,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;;;;;;;gCAUyB,qBAAqB,+BACZ,eAAe,GAC3C,cAAc,CAAC,UAAU,CAAC;EAmEhC,CAAC"}
|
|
@@ -1,114 +1,77 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
|
-
import { tool } from "ai";
|
|
4
3
|
import { z } from "zod";
|
|
4
|
+
import { config } from "../config.js";
|
|
5
|
+
import { clearProjectStatusCache } from "../repl/project-status-line.js";
|
|
5
6
|
import style from "../terminal/style.js";
|
|
6
|
-
import { joinWorkingDir, validatePath } from "
|
|
7
|
+
import { joinWorkingDir, validateFileNotReadOnly, validatePath, } from "../utils/filesystem/security.js";
|
|
7
8
|
export const DeleteFileTool = {
|
|
8
9
|
name: "deleteFile",
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
const inputSchema = z.object({
|
|
12
|
+
path: z.string().describe("Absolute path to the file to delete"),
|
|
13
|
+
});
|
|
14
|
+
export const createDeleteFileTool = async ({ workingDir, allowedDirs, }) => {
|
|
15
|
+
const allowedDirectory = allowedDirs ?? [workingDir];
|
|
12
16
|
return {
|
|
13
|
-
|
|
14
|
-
description: "Delete a file permanently.",
|
|
15
|
-
inputSchema
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// Check if execution has been aborted
|
|
17
|
+
toolDef: {
|
|
18
|
+
description: "Delete a file permanently. Only deletes files within allowed directories.",
|
|
19
|
+
inputSchema,
|
|
20
|
+
},
|
|
21
|
+
async *execute({ path: userPath }, { toolCallId, abortSignal }) {
|
|
22
|
+
try {
|
|
20
23
|
if (abortSignal?.aborted) {
|
|
21
24
|
throw new Error("File deletion aborted");
|
|
22
25
|
}
|
|
23
|
-
|
|
26
|
+
yield {
|
|
27
|
+
name: DeleteFileTool.name,
|
|
24
28
|
id: toolCallId,
|
|
25
29
|
event: "tool-init",
|
|
26
|
-
data:
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (abortSignal?.aborted) {
|
|
36
|
-
throw new Error("File deletion aborted before stat");
|
|
37
|
-
}
|
|
38
|
-
// Ensure it's a file, not a directory
|
|
39
|
-
const stats = await fs.stat(filePath);
|
|
40
|
-
if (stats.isDirectory()) {
|
|
41
|
-
throw new Error(`Path is a directory, not a file: ${filePath}`);
|
|
42
|
-
}
|
|
43
|
-
if (terminal) {
|
|
44
|
-
terminal.writeln(`\n${style.red.bold("●")} Proposing file deletion: ${style.cyan(userPath)}`);
|
|
45
|
-
terminal.lineBreak();
|
|
46
|
-
terminal.writeln("This action cannot be undone.");
|
|
47
|
-
terminal.lineBreak();
|
|
48
|
-
let userResponse;
|
|
49
|
-
if (toolExecutor) {
|
|
50
|
-
const ctx = {
|
|
51
|
-
toolName: DeleteFileTool.name,
|
|
52
|
-
toolCallId,
|
|
53
|
-
message: "What would you like to do with this deletion?",
|
|
54
|
-
choices: {
|
|
55
|
-
accept: "Accept this deletion",
|
|
56
|
-
acceptAll: "Accept all future deletions (including this)",
|
|
57
|
-
reject: "Reject this deletion",
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
try {
|
|
61
|
-
userResponse = await toolExecutor.ask(ctx, { abortSignal });
|
|
62
|
-
}
|
|
63
|
-
catch (e) {
|
|
64
|
-
if (e.name === "AbortError") {
|
|
65
|
-
throw new Error("File deletion aborted during user input");
|
|
66
|
-
}
|
|
67
|
-
throw e;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const { result: userChoice, reason } = userResponse ?? {
|
|
71
|
-
result: "accept",
|
|
72
|
-
};
|
|
73
|
-
terminal.lineBreak();
|
|
74
|
-
if (userChoice === "accept-all") {
|
|
75
|
-
terminal.writeln(style.yellow("✓ Auto-accept mode enabled for all deletions"));
|
|
76
|
-
terminal.lineBreak();
|
|
77
|
-
}
|
|
78
|
-
if (userChoice === "reject") {
|
|
79
|
-
terminal.lineBreak();
|
|
80
|
-
const rejectionReason = reason || "No reason provided";
|
|
81
|
-
sendData?.({
|
|
82
|
-
id: toolCallId,
|
|
83
|
-
event: "tool-completion",
|
|
84
|
-
data: `Deletion rejected by user. Reason: ${rejectionReason}`,
|
|
85
|
-
});
|
|
86
|
-
return `The user rejected this deletion. Reason: ${rejectionReason}`;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
// Pre-side-effect check
|
|
90
|
-
if (abortSignal?.aborted) {
|
|
91
|
-
throw new Error("File deletion aborted before unlink");
|
|
92
|
-
}
|
|
93
|
-
// Delete the file with signal
|
|
94
|
-
await fs.unlink(filePath);
|
|
95
|
-
sendData?.({
|
|
96
|
-
id: toolCallId,
|
|
97
|
-
event: "tool-completion",
|
|
98
|
-
data: "File deleted successfully",
|
|
99
|
-
});
|
|
100
|
-
return `Successfully deleted ${filePath}`;
|
|
30
|
+
data: `${style.cyan(userPath)}`,
|
|
31
|
+
};
|
|
32
|
+
const filePath = await validatePath(joinWorkingDir(userPath, workingDir), allowedDirectory, { abortSignal });
|
|
33
|
+
// Check if file is read-only
|
|
34
|
+
const projectConfig = await config.getConfig();
|
|
35
|
+
validateFileNotReadOnly(filePath, projectConfig, workingDir);
|
|
36
|
+
// Check if file exists before attempting delete
|
|
37
|
+
if (!existsSync(filePath)) {
|
|
38
|
+
throw new Error(`File not found: ${filePath}`);
|
|
101
39
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
40
|
+
// Pre-check for stat
|
|
41
|
+
if (abortSignal?.aborted) {
|
|
42
|
+
throw new Error("File deletion aborted before stat");
|
|
43
|
+
}
|
|
44
|
+
// Ensure it's a file, not a directory
|
|
45
|
+
const stats = await fs.stat(filePath);
|
|
46
|
+
if (stats.isDirectory()) {
|
|
47
|
+
throw new Error(`Path is a directory, not a file: ${filePath}`);
|
|
48
|
+
}
|
|
49
|
+
// Pre-side-effect check
|
|
50
|
+
if (abortSignal?.aborted) {
|
|
51
|
+
throw new Error("File deletion aborted before unlink");
|
|
110
52
|
}
|
|
111
|
-
|
|
112
|
-
|
|
53
|
+
// Delete the file with signal
|
|
54
|
+
await fs.unlink(filePath);
|
|
55
|
+
yield {
|
|
56
|
+
name: DeleteFileTool.name,
|
|
57
|
+
id: toolCallId,
|
|
58
|
+
event: "tool-completion",
|
|
59
|
+
data: "File deleted",
|
|
60
|
+
};
|
|
61
|
+
// Clear project status cache since file operations change git status
|
|
62
|
+
clearProjectStatusCache();
|
|
63
|
+
yield `Successfully deleted ${filePath}`;
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
const errorMessage = error.message;
|
|
67
|
+
yield {
|
|
68
|
+
name: DeleteFileTool.name,
|
|
69
|
+
id: toolCallId,
|
|
70
|
+
event: "tool-error",
|
|
71
|
+
data: errorMessage,
|
|
72
|
+
};
|
|
73
|
+
yield errorMessage;
|
|
74
|
+
}
|
|
75
|
+
},
|
|
113
76
|
};
|
|
114
77
|
};
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
+
import type { ToolCallOptions } from "ai";
|
|
2
|
+
import { z } from "zod";
|
|
1
3
|
import type { TokenCounter } from "../tokens/counter.ts";
|
|
2
|
-
import type {
|
|
4
|
+
import type { ToolResult } from "./types.ts";
|
|
3
5
|
export declare const DirectoryTreeTool: {
|
|
4
6
|
name: "directoryTree";
|
|
5
7
|
};
|
|
6
|
-
|
|
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, }: {
|
|
7
13
|
workingDir: string;
|
|
8
|
-
|
|
14
|
+
allowedDirs?: string[];
|
|
9
15
|
tokenCounter: TokenCounter;
|
|
10
16
|
}) => Promise<{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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>;
|
|
14
24
|
}>;
|
|
15
|
-
|
|
16
|
-
* Generates a string representation of a directory tree starting from the given path.
|
|
17
|
-
* @param dirPath - The path of the directory to generate the tree for.
|
|
18
|
-
* @returns A Promise that resolves to a string representation of the directory tree.
|
|
19
|
-
*/
|
|
20
|
-
export declare function directoryTree(dirPath: string): Promise<string>;
|
|
25
|
+
export {};
|
|
21
26
|
//# sourceMappingURL=directory-tree.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory-tree.d.ts","sourceRoot":"","sources":["../../source/tools/directory-tree.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"directory-tree.d.ts","sourceRoot":"","sources":["../../source/tools/directory-tree.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAOzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,eAAO,MAAM,iBAAiB;;CAE7B,CAAC;AAEF,QAAA,MAAM,WAAW;;iBAEf,CAAC;AAEH,KAAK,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAE5D,eAAO,MAAM,uBAAuB,GAAU,4CAI3C;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;CAC5B;;;;;;;sBASe,wBAAwB,+BACL,eAAe,GAC3C,cAAc,CAAC,UAAU,CAAC;EAyEhC,CAAC"}
|