@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
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
2
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import { createTwoFilesPatch } from "diff";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import style from "../terminal/style.js";
|
|
6
|
+
import { joinWorkingDir, validatePath } from "./filesystem-utils.js";
|
|
7
|
+
export const AdvancedEditFileTool = {
|
|
8
|
+
name: "advancedEditFile",
|
|
9
|
+
};
|
|
10
|
+
const inputSchema = z.object({
|
|
11
|
+
path: z.string().describe("The path of the file to edit."),
|
|
12
|
+
mode: z
|
|
13
|
+
.enum(["exact", "regex", "ast"])
|
|
14
|
+
.default("exact")
|
|
15
|
+
.describe("Editing mode: exact (literal text), regex (pattern matching), or ast (AST-aware)"),
|
|
16
|
+
operations: z.array(z.object({
|
|
17
|
+
type: z
|
|
18
|
+
.enum(["replace", "insert-before", "insert-after", "delete"])
|
|
19
|
+
.describe("Type of operation to perform"),
|
|
20
|
+
pattern: z
|
|
21
|
+
.string()
|
|
22
|
+
.describe("Pattern to match (text, regex, or AST pattern depending on mode)"),
|
|
23
|
+
replacement: z
|
|
24
|
+
.string()
|
|
25
|
+
.optional()
|
|
26
|
+
.describe("Replacement text (required for replace operations)"),
|
|
27
|
+
flags: z
|
|
28
|
+
.string()
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("Regex flags for regex mode (e.g., 'g', 'i', 'm')"),
|
|
31
|
+
})),
|
|
32
|
+
astPattern: z
|
|
33
|
+
.string()
|
|
34
|
+
.optional()
|
|
35
|
+
.describe("AST-grep search pattern for AST mode (e.g., 'var $V = $VAL')"),
|
|
36
|
+
astReplacement: z
|
|
37
|
+
.string()
|
|
38
|
+
.optional()
|
|
39
|
+
.describe("AST-grep replacement pattern for AST mode (e.g., 'let $V = $VAL')"),
|
|
40
|
+
dryRun: z.boolean().default(false).describe("Show changes without writing"),
|
|
41
|
+
});
|
|
42
|
+
export const createAdvancedEditFileTool = async ({ workingDir, allowedDirs, }) => {
|
|
43
|
+
const allowedDirectory = allowedDirs ?? [workingDir];
|
|
44
|
+
return {
|
|
45
|
+
toolDef: {
|
|
46
|
+
description: "Advanced file editing with multiple modes: exact text matching, regex pattern matching, and AST-aware editing. " +
|
|
47
|
+
"Supports replace, insert-before, insert-after, and delete operations. AST mode requires ast-grep to be installed.",
|
|
48
|
+
inputSchema,
|
|
49
|
+
},
|
|
50
|
+
async *execute({ path, mode, operations, astPattern, astReplacement, dryRun, }, { toolCallId, abortSignal }) {
|
|
51
|
+
try {
|
|
52
|
+
if (abortSignal?.aborted) {
|
|
53
|
+
throw new Error("File editing aborted");
|
|
54
|
+
}
|
|
55
|
+
yield {
|
|
56
|
+
name: AdvancedEditFileTool.name,
|
|
57
|
+
id: toolCallId,
|
|
58
|
+
event: "tool-init",
|
|
59
|
+
data: `${style.cyan(path)} (mode: ${mode})`,
|
|
60
|
+
};
|
|
61
|
+
const validPath = await validatePath(joinWorkingDir(path, workingDir), allowedDirectory, { abortSignal });
|
|
62
|
+
const result = await applyAdvancedFileEdits(validPath, mode, operations, astPattern, astReplacement, dryRun, abortSignal);
|
|
63
|
+
yield {
|
|
64
|
+
name: AdvancedEditFileTool.name,
|
|
65
|
+
id: toolCallId,
|
|
66
|
+
event: "tool-completion",
|
|
67
|
+
data: `Applied ${operations.length} edits`,
|
|
68
|
+
};
|
|
69
|
+
yield result;
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
yield {
|
|
73
|
+
name: AdvancedEditFileTool.name,
|
|
74
|
+
event: "tool-error",
|
|
75
|
+
id: toolCallId,
|
|
76
|
+
data: error.message,
|
|
77
|
+
};
|
|
78
|
+
yield `Failed to edit file: ${error.message}`;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
// file editing and diffing utilities
|
|
84
|
+
function normalizeLineEndings(text) {
|
|
85
|
+
return text.replace(/\r\n/g, "\n");
|
|
86
|
+
}
|
|
87
|
+
function createUnifiedDiff(originalContent, newContent, filepath = "file") {
|
|
88
|
+
// Ensure consistent line endings for diff
|
|
89
|
+
const normalizedOriginal = normalizeLineEndings(originalContent);
|
|
90
|
+
const normalizedNew = normalizeLineEndings(newContent);
|
|
91
|
+
return createTwoFilesPatch(filepath, filepath, normalizedOriginal, normalizedNew, "original", "modified");
|
|
92
|
+
}
|
|
93
|
+
function applyExactModeEdits(content, operations) {
|
|
94
|
+
let modifiedContent = content;
|
|
95
|
+
for (const op of operations) {
|
|
96
|
+
switch (op.type) {
|
|
97
|
+
case "replace": {
|
|
98
|
+
if (!op.replacement) {
|
|
99
|
+
throw new Error("Replacement text required for replace operation");
|
|
100
|
+
}
|
|
101
|
+
// Exact text replacement (global)
|
|
102
|
+
let currentIndex = 0;
|
|
103
|
+
let matchCount = 0;
|
|
104
|
+
while (currentIndex < modifiedContent.length) {
|
|
105
|
+
const matchIndex = modifiedContent.indexOf(op.pattern, currentIndex);
|
|
106
|
+
if (matchIndex === -1) {
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
matchCount++;
|
|
110
|
+
modifiedContent =
|
|
111
|
+
modifiedContent.slice(0, matchIndex) +
|
|
112
|
+
op.replacement +
|
|
113
|
+
modifiedContent.slice(matchIndex + op.pattern.length);
|
|
114
|
+
currentIndex = matchIndex + op.replacement.length;
|
|
115
|
+
}
|
|
116
|
+
if (matchCount === 0) {
|
|
117
|
+
throw new Error(`Pattern not found in content: ${op.pattern}`);
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
case "insert-before": {
|
|
122
|
+
if (!op.replacement) {
|
|
123
|
+
throw new Error("Replacement text required for insert-before operation");
|
|
124
|
+
}
|
|
125
|
+
const beforeIndex = modifiedContent.indexOf(op.pattern);
|
|
126
|
+
if (beforeIndex === -1) {
|
|
127
|
+
throw new Error(`Pattern not found for insert-before: ${op.pattern}`);
|
|
128
|
+
}
|
|
129
|
+
modifiedContent =
|
|
130
|
+
modifiedContent.slice(0, beforeIndex) +
|
|
131
|
+
op.replacement +
|
|
132
|
+
"\n" +
|
|
133
|
+
modifiedContent.slice(beforeIndex);
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case "insert-after": {
|
|
137
|
+
if (!op.replacement) {
|
|
138
|
+
throw new Error("Replacement text required for insert-after operation");
|
|
139
|
+
}
|
|
140
|
+
const afterIndex = modifiedContent.indexOf(op.pattern);
|
|
141
|
+
if (afterIndex === -1) {
|
|
142
|
+
throw new Error(`Pattern not found for insert-after: ${op.pattern}`);
|
|
143
|
+
}
|
|
144
|
+
const insertPosition = afterIndex + op.pattern.length;
|
|
145
|
+
modifiedContent =
|
|
146
|
+
modifiedContent.slice(0, insertPosition) +
|
|
147
|
+
"\n" +
|
|
148
|
+
op.replacement +
|
|
149
|
+
modifiedContent.slice(insertPosition);
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
case "delete": {
|
|
153
|
+
// For delete operations, use line-based approach to handle newlines properly
|
|
154
|
+
const lines = modifiedContent.split("\n");
|
|
155
|
+
const filteredLines = lines.filter((line) => !line.includes(op.pattern));
|
|
156
|
+
if (filteredLines.length === lines.length) {
|
|
157
|
+
throw new Error(`Pattern not found for delete: ${op.pattern}`);
|
|
158
|
+
}
|
|
159
|
+
modifiedContent = filteredLines.join("\n");
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return modifiedContent;
|
|
165
|
+
}
|
|
166
|
+
function applyRegexModeEdits(content, operations) {
|
|
167
|
+
let modifiedContent = content;
|
|
168
|
+
for (const op of operations) {
|
|
169
|
+
const flags = op.flags || "g";
|
|
170
|
+
const regex = new RegExp(op.pattern, flags);
|
|
171
|
+
switch (op.type) {
|
|
172
|
+
case "replace":
|
|
173
|
+
if (!op.replacement) {
|
|
174
|
+
throw new Error("Replacement text required for replace operation");
|
|
175
|
+
}
|
|
176
|
+
modifiedContent = modifiedContent.replace(regex, op.replacement);
|
|
177
|
+
break;
|
|
178
|
+
case "insert-before":
|
|
179
|
+
if (!op.replacement) {
|
|
180
|
+
throw new Error("Replacement text required for insert-before operation");
|
|
181
|
+
}
|
|
182
|
+
modifiedContent = modifiedContent.replace(regex, `${op.replacement}\n$&`);
|
|
183
|
+
break;
|
|
184
|
+
case "insert-after":
|
|
185
|
+
if (!op.replacement) {
|
|
186
|
+
throw new Error("Replacement text required for insert-after operation");
|
|
187
|
+
}
|
|
188
|
+
modifiedContent = modifiedContent.replace(regex, `$&\n${op.replacement}`);
|
|
189
|
+
break;
|
|
190
|
+
case "delete":
|
|
191
|
+
modifiedContent = modifiedContent.replace(regex, "");
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return modifiedContent;
|
|
196
|
+
}
|
|
197
|
+
function applyAstModeEdits(filePath, astPattern, astReplacement, dryRun) {
|
|
198
|
+
if (!astPattern || !astReplacement) {
|
|
199
|
+
throw new Error("AST mode requires both astPattern and astReplacement");
|
|
200
|
+
}
|
|
201
|
+
try {
|
|
202
|
+
const cmd = [
|
|
203
|
+
"ast-grep",
|
|
204
|
+
"--pattern",
|
|
205
|
+
`"${astPattern}"`,
|
|
206
|
+
"--rewrite",
|
|
207
|
+
`"${astReplacement}"`,
|
|
208
|
+
dryRun ? "--dry-run" : "--write",
|
|
209
|
+
filePath,
|
|
210
|
+
].join(" ");
|
|
211
|
+
if (dryRun) {
|
|
212
|
+
const output = execSync(cmd, { encoding: "utf-8" });
|
|
213
|
+
return `AST edit preview:\n${output}`;
|
|
214
|
+
}
|
|
215
|
+
execSync(cmd, { stdio: "inherit" });
|
|
216
|
+
return `AST edit applied to ${filePath}`;
|
|
217
|
+
}
|
|
218
|
+
catch (err) {
|
|
219
|
+
throw new Error(`AST edit failed: ${err.message}`);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
export async function applyAdvancedFileEdits(filePath, mode, operations, astPattern, astReplacement, dryRun = false, abortSignal) {
|
|
223
|
+
if (abortSignal?.aborted) {
|
|
224
|
+
throw new Error("File edit operation aborted");
|
|
225
|
+
}
|
|
226
|
+
// Read file content literally with signal
|
|
227
|
+
const originalContent = await readFile(filePath, {
|
|
228
|
+
encoding: "utf-8",
|
|
229
|
+
signal: abortSignal,
|
|
230
|
+
});
|
|
231
|
+
let modifiedContent = originalContent;
|
|
232
|
+
let resultMessage = "";
|
|
233
|
+
if (mode === "ast") {
|
|
234
|
+
// AST mode uses external ast-grep tool
|
|
235
|
+
if (!astPattern || !astReplacement) {
|
|
236
|
+
throw new Error("AST mode requires both astPattern and astReplacement");
|
|
237
|
+
}
|
|
238
|
+
resultMessage = applyAstModeEdits(filePath, astPattern, astReplacement, dryRun);
|
|
239
|
+
if (dryRun) {
|
|
240
|
+
return resultMessage;
|
|
241
|
+
}
|
|
242
|
+
// For actual AST edits, read the modified content back
|
|
243
|
+
modifiedContent = await readFile(filePath, {
|
|
244
|
+
encoding: "utf-8",
|
|
245
|
+
signal: abortSignal,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
// Text-based modes (exact and regex)
|
|
250
|
+
if (operations.length === 0) {
|
|
251
|
+
throw new Error("No operations specified for text-based editing mode");
|
|
252
|
+
}
|
|
253
|
+
switch (mode) {
|
|
254
|
+
case "exact":
|
|
255
|
+
modifiedContent = applyExactModeEdits(originalContent, operations);
|
|
256
|
+
break;
|
|
257
|
+
case "regex":
|
|
258
|
+
modifiedContent = applyRegexModeEdits(originalContent, operations);
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
// Create unified diff
|
|
262
|
+
const diff = createUnifiedDiff(originalContent, modifiedContent, filePath);
|
|
263
|
+
// Format diff with appropriate number of backticks
|
|
264
|
+
let numBackticks = 3;
|
|
265
|
+
while (diff.includes("`".repeat(numBackticks))) {
|
|
266
|
+
numBackticks++;
|
|
267
|
+
}
|
|
268
|
+
resultMessage = `${"`".repeat(numBackticks)}diff\n${diff}${"`".repeat(numBackticks)}\n\n`;
|
|
269
|
+
if (!dryRun) {
|
|
270
|
+
if (abortSignal?.aborted) {
|
|
271
|
+
throw new Error("File edit operation aborted before writing");
|
|
272
|
+
}
|
|
273
|
+
// Write the modified content with signal
|
|
274
|
+
await writeFile(filePath, modifiedContent, {
|
|
275
|
+
encoding: "utf-8",
|
|
276
|
+
signal: abortSignal,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return resultMessage;
|
|
281
|
+
}
|
package/dist/tools/agent.d.ts
CHANGED
|
@@ -1,17 +1,29 @@
|
|
|
1
|
+
import { type ToolCallOptions } from "ai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import type { WorkspaceContext } from "../index.ts";
|
|
1
4
|
import type { ModelManager } from "../models/manager.ts";
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
+
import type { TokenCounter } from "../tokens/counter.ts";
|
|
6
|
+
import type { TokenTracker } from "../tokens/tracker.ts";
|
|
7
|
+
import type { ToolResult } from "./types.ts";
|
|
5
8
|
export declare const AgentTool: {
|
|
6
9
|
name: "agent";
|
|
7
10
|
};
|
|
11
|
+
declare const inputSchema: z.ZodObject<{
|
|
12
|
+
prompt: z.ZodString;
|
|
13
|
+
}, z.core.$strip>;
|
|
8
14
|
export declare const createAgentTools: (options: {
|
|
9
15
|
modelManager: ModelManager;
|
|
10
16
|
tokenTracker: TokenTracker;
|
|
11
17
|
tokenCounter: TokenCounter;
|
|
12
|
-
|
|
18
|
+
workspace: WorkspaceContext;
|
|
13
19
|
}) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
toolDef: {
|
|
21
|
+
description: string;
|
|
22
|
+
inputSchema: z.ZodObject<{
|
|
23
|
+
prompt: z.ZodString;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
};
|
|
26
|
+
execute: ({ prompt }: z.infer<typeof inputSchema>, { toolCallId, abortSignal }: ToolCallOptions) => AsyncGenerator<ToolResult>;
|
|
17
27
|
};
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../source/tools/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,eAAe,EAAE,MAAM,IAAI,CAAC;AACrE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAOzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,eAAO,MAAM,SAAS;;CAErB,CAAC;AAiCF,QAAA,MAAM,WAAW;;iBAEf,CAAC;AAEH,eAAO,MAAM,gBAAgB,GAAI,SAAS;IACxC,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,gBAAgB,CAAC;CAC7B;;;;;;;0BASe,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,+BACV,eAAe,KAC3C,cAAc,CAAC,UAAU,CAAC;CA8D9B,CAAC"}
|
package/dist/tools/agent.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { generateText, stepCountIs
|
|
2
|
-
import chalk from "chalk";
|
|
1
|
+
import { generateText, stepCountIs } from "ai";
|
|
3
2
|
import { z } from "zod";
|
|
4
3
|
import { AiConfig } from "../models/ai-config.js";
|
|
5
|
-
import
|
|
4
|
+
import style from "../terminal/style.js";
|
|
6
5
|
import { DirectoryTreeTool } from "./directory-tree.js";
|
|
6
|
+
import { GlobTool } from "./glob.js";
|
|
7
7
|
import { GrepTool } from "./grep.js";
|
|
8
8
|
import { initCliTools } from "./index.js";
|
|
9
9
|
import { ReadFileTool } from "./read-file.js";
|
|
@@ -13,18 +13,24 @@ export const AgentTool = {
|
|
|
13
13
|
};
|
|
14
14
|
const TOOLS = [
|
|
15
15
|
GrepTool.name,
|
|
16
|
-
|
|
16
|
+
GlobTool.name,
|
|
17
17
|
ReadFileTool.name,
|
|
18
18
|
ReadMultipleFilesTool.name,
|
|
19
19
|
DirectoryTreeTool.name,
|
|
20
20
|
];
|
|
21
21
|
function getToolDescription() {
|
|
22
22
|
const toolNames = TOOLS.join(", ");
|
|
23
|
-
return `Launch a new agent that has access to the following tools: ${toolNames}.
|
|
23
|
+
return `Launch a new agent that has access to the following tools: ${toolNames}. This agent is specifically designed for file discovery and code search tasks. Use the ${AgentTool.name} tool when you need to search for files or code patterns across the codebase.
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
25
|
+
Use cases:
|
|
26
|
+
- Search for files matching specific patterns (e.g., "*.ts", "**/*.test.ts") using ${GlobTool.name}
|
|
27
|
+
- Find code patterns or text within files using ${GrepTool.name}
|
|
28
|
+
- Read specific files or multiple files using ${ReadFileTool.name} and ${ReadMultipleFilesTool.name}
|
|
29
|
+
|
|
30
|
+
Important limitations:
|
|
31
|
+
- This agent cannot execute shell commands or run external tools
|
|
32
|
+
- It is focused purely on file discovery and content reading
|
|
33
|
+
- For complex operations or command execution, use the main assistant directly
|
|
28
34
|
|
|
29
35
|
Usage notes:
|
|
30
36
|
1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses
|
|
@@ -36,52 +42,62 @@ const inputSchema = z.object({
|
|
|
36
42
|
prompt: z.string().describe("The task for the agent to perform"),
|
|
37
43
|
});
|
|
38
44
|
export const createAgentTools = (options) => {
|
|
39
|
-
const { modelManager, tokenTracker, tokenCounter
|
|
45
|
+
const { modelManager, tokenTracker, tokenCounter } = options;
|
|
46
|
+
const toolDef = {
|
|
47
|
+
description: getToolDescription(),
|
|
48
|
+
inputSchema,
|
|
49
|
+
};
|
|
50
|
+
async function* execute({ prompt }, { toolCallId, abortSignal }) {
|
|
51
|
+
if (abortSignal?.aborted) {
|
|
52
|
+
throw new Error("Agent execution aborted");
|
|
53
|
+
}
|
|
54
|
+
yield {
|
|
55
|
+
name: AgentTool.name,
|
|
56
|
+
event: "tool-init",
|
|
57
|
+
id: toolCallId,
|
|
58
|
+
data: `\n${style.cyan(prompt)}`,
|
|
59
|
+
};
|
|
60
|
+
try {
|
|
61
|
+
const modelConfig = modelManager.getModelMetadata("task-agent");
|
|
62
|
+
const aiConfig = new AiConfig({
|
|
63
|
+
modelMetadata: modelConfig,
|
|
64
|
+
prompt: prompt,
|
|
65
|
+
});
|
|
66
|
+
const { text, usage } = await generateText({
|
|
67
|
+
model: modelManager.getModel("task-agent"),
|
|
68
|
+
maxOutputTokens: aiConfig.maxOutputTokens(),
|
|
69
|
+
system: "You are a code search assistant that will be given a task that will require you to search a code base to find relevant code and files.",
|
|
70
|
+
prompt: prompt,
|
|
71
|
+
temperature: aiConfig.temperature(),
|
|
72
|
+
topP: aiConfig.topP(),
|
|
73
|
+
stopWhen: stepCountIs(30),
|
|
74
|
+
providerOptions: aiConfig.providerOptions(),
|
|
75
|
+
tools: (await initCliTools({ tokenCounter, workspace: options.workspace })).toolDefs,
|
|
76
|
+
abortSignal: abortSignal,
|
|
77
|
+
// biome-ignore lint/style/useNamingConvention: third-party code
|
|
78
|
+
experimental_activeTools: [...TOOLS],
|
|
79
|
+
});
|
|
80
|
+
tokenTracker.trackUsage("task-agent", usage);
|
|
81
|
+
yield {
|
|
82
|
+
name: AgentTool.name,
|
|
83
|
+
event: "tool-completion",
|
|
84
|
+
id: toolCallId,
|
|
85
|
+
data: `Finished running the agent tool (${usage.totalTokens} tokens)`,
|
|
86
|
+
};
|
|
87
|
+
yield text;
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
yield {
|
|
91
|
+
name: AgentTool.name,
|
|
92
|
+
event: "tool-error",
|
|
93
|
+
id: toolCallId,
|
|
94
|
+
data: error.message,
|
|
95
|
+
};
|
|
96
|
+
yield error.message;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
40
99
|
return {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
inputSchema: inputSchema,
|
|
44
|
-
execute: async ({ prompt }, { abortSignal, toolCallId }) => {
|
|
45
|
-
sendData?.({
|
|
46
|
-
event: "tool-init",
|
|
47
|
-
id: toolCallId,
|
|
48
|
-
data: `Initializing agent with prompt: ${chalk.cyan(prompt)}`,
|
|
49
|
-
});
|
|
50
|
-
try {
|
|
51
|
-
const modelConfig = modelManager.getModelMetadata("task-agent");
|
|
52
|
-
const aiConfig = new AiConfig({
|
|
53
|
-
modelMetadata: modelConfig,
|
|
54
|
-
prompt: prompt,
|
|
55
|
-
});
|
|
56
|
-
const { text, usage } = await generateText({
|
|
57
|
-
model: modelManager.getModel("task-agent"),
|
|
58
|
-
maxOutputTokens: aiConfig.getMaxTokens(),
|
|
59
|
-
system: "You are a code search assistant that will be given a task that will require you to search a code base to find relevant code and files.",
|
|
60
|
-
prompt: prompt,
|
|
61
|
-
stopWhen: stepCountIs(30),
|
|
62
|
-
providerOptions: aiConfig.getProviderOptions(),
|
|
63
|
-
tools: await initCliTools({ tokenCounter }),
|
|
64
|
-
abortSignal: abortSignal,
|
|
65
|
-
// biome-ignore lint/style/useNamingConvention: third-party code
|
|
66
|
-
experimental_activeTools: [...TOOLS],
|
|
67
|
-
});
|
|
68
|
-
tokenTracker.trackUsage("task-agent", usage);
|
|
69
|
-
sendData?.({
|
|
70
|
-
event: "tool-completion",
|
|
71
|
-
id: toolCallId,
|
|
72
|
-
data: "Finished running the agent tool.",
|
|
73
|
-
});
|
|
74
|
-
return text;
|
|
75
|
-
}
|
|
76
|
-
catch (error) {
|
|
77
|
-
sendData?.({
|
|
78
|
-
event: "tool-error",
|
|
79
|
-
id: toolCallId,
|
|
80
|
-
data: "Error running agent tool.",
|
|
81
|
-
});
|
|
82
|
-
return Promise.resolve(error.message);
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
}),
|
|
100
|
+
toolDef,
|
|
101
|
+
execute,
|
|
86
102
|
};
|
|
87
103
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function validatePaths(command: string, allowedDirs: string[], cwd: string, allowedPaths?: string[]): {
|
|
2
|
+
isValid: boolean;
|
|
3
|
+
error?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const resolveCwd: (cwdInput: string | null | undefined, workingDir: string) => string;
|
|
6
|
+
export declare const isMutatingCommand: (rawCommand: string) => boolean;
|
|
7
|
+
//# sourceMappingURL=bash-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash-utils.d.ts","sourceRoot":"","sources":["../../source/tools/bash-utils.ts"],"names":[],"mappings":"AAMA,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EAAE,EACrB,GAAG,EAAE,MAAM,EACX,YAAY,CAAC,EAAE,MAAM,EAAE,GACtB;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAgFtC;AAED,eAAO,MAAM,UAAU,GACrB,UAAU,MAAM,GAAG,IAAI,GAAG,SAAS,EACnC,YAAY,MAAM,KACjB,MAiDF,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,YAAY,MAAM,KAAG,OAmHtD,CAAC"}
|