@travisennis/acai 0.0.7 → 0.0.8
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 +42 -25
- package/dist/agent/index.d.ts +21 -25
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +115 -104
- package/dist/cli.d.ts +2 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +21 -16
- package/dist/commands/add-directory/index.d.ts +3 -0
- package/dist/commands/add-directory/index.d.ts.map +1 -0
- package/dist/commands/{add-directory-command.js → add-directory/index.js} +6 -10
- package/dist/commands/add-directory/types.d.ts +6 -0
- package/dist/commands/add-directory/types.d.ts.map +1 -0
- package/dist/commands/add-directory/types.js +1 -0
- package/dist/commands/add-directory/utils.d.ts +3 -0
- package/dist/commands/add-directory/utils.d.ts.map +1 -0
- package/dist/commands/add-directory/utils.js +15 -0
- package/dist/commands/clear/index.d.ts +3 -0
- package/dist/commands/clear/index.d.ts.map +1 -0
- package/dist/commands/{clear-command.js → clear/index.js} +0 -2
- package/dist/commands/copy/index.d.ts +3 -0
- package/dist/commands/copy/index.d.ts.map +1 -0
- package/dist/commands/{copy-command.js → copy/index.js} +4 -26
- package/dist/commands/copy/types.d.ts +3 -0
- package/dist/commands/copy/types.d.ts.map +1 -0
- package/dist/commands/copy/types.js +1 -0
- package/dist/commands/copy/utils.d.ts +3 -0
- package/dist/commands/copy/utils.d.ts.map +1 -0
- package/dist/commands/copy/utils.js +22 -0
- package/dist/commands/{exit-command.d.ts → exit/index.d.ts} +4 -4
- package/dist/commands/exit/index.d.ts.map +1 -0
- package/dist/commands/exit/index.js +21 -0
- package/dist/commands/exit/types.d.ts +8 -0
- package/dist/commands/exit/types.d.ts.map +1 -0
- package/dist/commands/exit/types.js +1 -0
- package/dist/commands/exit/utils.d.ts +2 -0
- package/dist/commands/exit/utils.d.ts.map +1 -0
- package/dist/commands/exit/utils.js +13 -0
- package/dist/commands/generate-rules/index.d.ts +3 -0
- package/dist/commands/generate-rules/index.d.ts.map +1 -0
- package/dist/commands/{generate-rules-command.js → generate-rules/index.js} +55 -95
- package/dist/commands/generate-rules/utils.d.ts +5 -0
- package/dist/commands/generate-rules/utils.d.ts.map +1 -0
- package/dist/commands/generate-rules/utils.js +25 -0
- package/dist/commands/handoff/index.d.ts +3 -0
- package/dist/commands/handoff/index.d.ts.map +1 -0
- package/dist/commands/handoff/index.js +97 -0
- package/dist/commands/handoff/utils.d.ts +4 -0
- package/dist/commands/handoff/utils.d.ts.map +1 -0
- package/dist/commands/{handoff-command.js → handoff/utils.js} +24 -92
- package/dist/commands/health/index.d.ts +3 -0
- package/dist/commands/health/index.d.ts.map +1 -0
- package/dist/commands/health/index.js +56 -0
- package/dist/commands/health/utils.d.ts +15 -0
- package/dist/commands/health/utils.d.ts.map +1 -0
- package/dist/commands/health/utils.js +52 -0
- package/dist/commands/{help-command.d.ts → help/index.d.ts} +2 -2
- package/dist/commands/help/index.d.ts.map +1 -0
- package/dist/commands/{help-command.js → help/index.js} +1 -1
- package/dist/commands/history/index.d.ts +3 -0
- package/dist/commands/history/index.d.ts.map +1 -0
- package/dist/commands/{history-command.js → history/index.js} +16 -100
- package/dist/commands/history/types.d.ts +11 -0
- package/dist/commands/history/types.d.ts.map +1 -0
- package/dist/commands/history/types.js +1 -0
- package/dist/commands/history/utils.d.ts +4 -0
- package/dist/commands/history/utils.d.ts.map +1 -0
- package/dist/commands/history/utils.js +86 -0
- package/dist/commands/init/index.d.ts +3 -0
- package/dist/commands/init/index.d.ts.map +1 -0
- package/dist/commands/{init-command.js → init/index.js} +16 -7
- package/dist/commands/init-project/index.d.ts +3 -0
- package/dist/commands/init-project/index.d.ts.map +1 -0
- package/dist/commands/init-project/index.js +51 -0
- package/dist/commands/init-project/utils.d.ts +9 -0
- package/dist/commands/init-project/utils.d.ts.map +1 -0
- package/dist/commands/init-project/utils.js +43 -0
- package/dist/commands/list-directories/index.d.ts +3 -0
- package/dist/commands/list-directories/index.d.ts.map +1 -0
- package/dist/commands/{list-directories-command.js → list-directories/index.js} +1 -1
- package/dist/commands/list-tools/index.d.ts +3 -0
- package/dist/commands/list-tools/index.d.ts.map +1 -0
- package/dist/commands/{list-tools-command.js → list-tools/index.js} +4 -16
- package/dist/commands/manager.d.ts +2 -2
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +33 -43
- package/dist/commands/model/index.d.ts +3 -0
- package/dist/commands/model/index.d.ts.map +1 -0
- package/dist/commands/{model-command.js → model/index.js} +15 -52
- package/dist/commands/model/utils.d.ts +3 -0
- package/dist/commands/model/utils.d.ts.map +1 -0
- package/dist/commands/model/utils.js +5 -0
- package/dist/commands/{paste-command.d.ts → paste/index.d.ts} +2 -2
- package/dist/commands/paste/index.d.ts.map +1 -0
- package/dist/commands/{paste-command.js → paste/index.js} +6 -111
- package/dist/commands/paste/utils.d.ts +5 -0
- package/dist/commands/paste/utils.d.ts.map +1 -0
- package/dist/commands/paste/utils.js +86 -0
- package/dist/commands/pickup/index.d.ts +3 -0
- package/dist/commands/pickup/index.d.ts.map +1 -0
- package/dist/commands/pickup/index.js +138 -0
- package/dist/commands/pickup/types.d.ts +6 -0
- package/dist/commands/pickup/types.d.ts.map +1 -0
- package/dist/commands/pickup/types.js +1 -0
- package/dist/commands/pickup/utils.d.ts +7 -0
- package/dist/commands/pickup/utils.d.ts.map +1 -0
- package/dist/commands/pickup/utils.js +56 -0
- package/dist/commands/prompt/index.d.ts +5 -0
- package/dist/commands/prompt/index.d.ts.map +1 -0
- package/dist/commands/prompt/index.js +126 -0
- package/dist/commands/prompt/types.d.ts +15 -0
- package/dist/commands/prompt/types.d.ts.map +1 -0
- package/dist/commands/prompt/types.js +1 -0
- package/dist/commands/prompt/utils.d.ts +12 -0
- package/dist/commands/prompt/utils.d.ts.map +1 -0
- package/dist/commands/prompt/utils.js +107 -0
- package/dist/commands/remove-directory/index.d.ts +3 -0
- package/dist/commands/remove-directory/index.d.ts.map +1 -0
- package/dist/commands/{remove-directory-command.js → remove-directory/index.js} +2 -2
- package/dist/commands/reset/index.d.ts +3 -0
- package/dist/commands/reset/index.d.ts.map +1 -0
- package/dist/commands/{reset-command.js → reset/index.js} +7 -2
- package/dist/commands/reset/types.d.ts +1 -0
- package/dist/commands/reset/types.d.ts.map +1 -0
- package/dist/commands/reset/types.js +3 -0
- package/dist/commands/resources/index.d.ts +3 -0
- package/dist/commands/resources/index.d.ts.map +1 -0
- package/dist/commands/resources/index.js +84 -0
- package/dist/commands/review/index.d.ts +3 -0
- package/dist/commands/review/index.d.ts.map +1 -0
- package/dist/commands/review/index.js +126 -0
- package/dist/commands/review/types.d.ts +12 -0
- package/dist/commands/review/types.d.ts.map +1 -0
- package/dist/commands/review/types.js +1 -0
- package/dist/commands/review/utils.d.ts +4 -0
- package/dist/commands/review/utils.d.ts.map +1 -0
- package/dist/commands/review/utils.js +87 -0
- package/dist/commands/save/index.d.ts +3 -0
- package/dist/commands/save/index.d.ts.map +1 -0
- package/dist/commands/{save-command.js → save/index.js} +3 -3
- package/dist/commands/session/index.d.ts +3 -0
- package/dist/commands/session/index.d.ts.map +1 -0
- package/dist/commands/session/index.js +197 -0
- package/dist/commands/session/types.d.ts +13 -0
- package/dist/commands/session/types.d.ts.map +1 -0
- package/dist/commands/session/types.js +7 -0
- package/dist/commands/shell/index.d.ts +3 -0
- package/dist/commands/shell/index.d.ts.map +1 -0
- package/dist/commands/{shell-command.js → shell/index.js} +3 -3
- package/dist/commands/types.d.ts +2 -2
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/config.d.ts +25 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +45 -20
- package/dist/dedent.d.ts.map +1 -1
- package/dist/dedent.js +7 -7
- package/dist/execution/index.d.ts +1 -0
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +60 -64
- package/dist/formatting.d.ts +27 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +40 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +138 -75
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +4 -11
- package/dist/mentions.d.ts.map +1 -1
- package/dist/mentions.js +3 -53
- package/dist/middleware/audit-message.d.ts +2 -2
- package/dist/middleware/audit-message.d.ts.map +1 -1
- package/dist/middleware/audit-message.js +40 -2
- package/dist/middleware/cache.d.ts +2 -2
- package/dist/middleware/cache.d.ts.map +1 -1
- package/dist/middleware/cache.js +111 -27
- package/dist/middleware/rate-limit.d.ts +2 -2
- package/dist/middleware/rate-limit.d.ts.map +1 -1
- package/dist/middleware/rate-limit.js +1 -0
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +46 -29
- package/dist/models/anthropic-provider.d.ts +14 -13
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/deepseek-provider.d.ts +9 -8
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/google-provider.d.ts +10 -9
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.d.ts +8 -7
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/manager.d.ts +7 -4
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +5 -25
- package/dist/models/openai-provider.d.ts +11 -10
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/opencode-zen-provider.d.ts +23 -0
- package/dist/models/opencode-zen-provider.d.ts.map +1 -0
- package/dist/models/opencode-zen-provider.js +76 -0
- package/dist/models/openrouter-provider.d.ts +34 -29
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +95 -80
- package/dist/models/providers.d.ts +4 -4
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +7 -1
- package/dist/models/xai-provider.d.ts +9 -8
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/prompts/manager.d.ts +1 -1
- package/dist/prompts/manager.d.ts.map +1 -1
- package/dist/prompts/manager.js +1 -1
- package/dist/prompts.d.ts +0 -1
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +56 -406
- package/dist/repl/project-status.d.ts +19 -0
- package/dist/repl/project-status.d.ts.map +1 -0
- package/dist/repl/project-status.js +78 -0
- package/dist/repl-new.d.ts +15 -4
- package/dist/repl-new.d.ts.map +1 -1
- package/dist/repl-new.js +245 -42
- package/dist/{messages.d.ts → sessions/manager.d.ts} +10 -4
- package/dist/sessions/manager.d.ts.map +1 -0
- package/dist/{messages.js → sessions/manager.js} +60 -14
- package/dist/skills.d.ts +0 -4
- package/dist/skills.d.ts.map +1 -1
- package/dist/skills.js +100 -59
- package/dist/terminal/control.d.ts +1 -0
- package/dist/terminal/control.d.ts.map +1 -1
- package/dist/terminal/control.js +2 -0
- package/dist/terminal/formatting.d.ts +1 -2
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +1 -2
- package/dist/terminal/keys.d.ts +211 -0
- package/dist/terminal/keys.d.ts.map +1 -0
- package/dist/terminal/keys.js +546 -0
- package/dist/terminal/segmenter.d.ts +6 -0
- package/dist/terminal/segmenter.d.ts.map +1 -0
- package/dist/terminal/segmenter.js +11 -0
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +9 -21
- package/dist/terminal/string-width.d.ts.map +1 -1
- package/dist/terminal/string-width.js +40 -21
- package/dist/terminal/strip-ansi.d.ts.map +1 -1
- package/dist/terminal/strip-ansi.js +9 -15
- package/dist/tokens/tracker.d.ts.map +1 -1
- package/dist/tokens/tracker.js +58 -16
- package/dist/tools/bash.d.ts +9 -11
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +69 -123
- package/dist/tools/directory-tree.d.ts +9 -7
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +89 -70
- package/dist/tools/dynamic-tool-loader.d.ts +22 -4
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +39 -44
- package/dist/tools/edit-file.d.ts +6 -16
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +19 -76
- package/dist/tools/glob.d.ts +15 -16
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +77 -119
- package/dist/tools/grep.d.ts +19 -22
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +61 -108
- package/dist/tools/index.d.ts +200 -179
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +17 -315
- package/dist/tools/ls.d.ts +26 -0
- package/dist/tools/ls.d.ts.map +1 -0
- package/dist/tools/ls.js +80 -0
- package/dist/tools/read-file.d.ts +15 -15
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +49 -82
- package/dist/tools/save-file.d.ts +4 -4
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +37 -66
- package/dist/tools/think.d.ts +4 -4
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +9 -38
- package/dist/tools/types.d.ts +5 -25
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +0 -9
- package/dist/tui/autocomplete/attachment-provider.d.ts +18 -0
- package/dist/tui/autocomplete/attachment-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/attachment-provider.js +159 -0
- package/dist/tui/autocomplete/base-provider.d.ts +17 -0
- package/dist/tui/autocomplete/base-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/base-provider.js +1 -0
- package/dist/tui/autocomplete/combined-provider.d.ts +20 -0
- package/dist/tui/autocomplete/combined-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/combined-provider.js +61 -0
- package/dist/tui/autocomplete/command-provider.d.ts +20 -0
- package/dist/tui/autocomplete/command-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/command-provider.js +90 -0
- package/dist/tui/autocomplete/file-search-provider.d.ts +16 -0
- package/dist/tui/autocomplete/file-search-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/file-search-provider.js +123 -0
- package/dist/tui/autocomplete/path-provider.d.ts +21 -0
- package/dist/tui/autocomplete/path-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/path-provider.js +164 -0
- package/dist/tui/autocomplete/utils.d.ts +16 -0
- package/dist/tui/autocomplete/utils.d.ts.map +1 -0
- package/dist/tui/autocomplete/utils.js +137 -0
- package/dist/tui/autocomplete.d.ts +12 -43
- package/dist/tui/autocomplete.d.ts.map +1 -1
- package/dist/tui/autocomplete.js +20 -465
- package/dist/tui/components/box.d.ts.map +1 -1
- package/dist/tui/components/box.js +16 -10
- package/dist/tui/components/editor.d.ts +1 -2
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +148 -107
- package/dist/tui/components/footer.d.ts +20 -7
- package/dist/tui/components/footer.d.ts.map +1 -1
- package/dist/tui/components/footer.js +89 -196
- package/dist/tui/components/input.d.ts.map +1 -1
- package/dist/tui/components/input.js +8 -7
- package/dist/tui/components/loader.d.ts +2 -1
- package/dist/tui/components/loader.d.ts.map +1 -1
- package/dist/tui/components/loader.js +7 -2
- package/dist/tui/components/markdown.d.ts +5 -4
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +51 -40
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +9 -8
- package/dist/tui/components/notification.d.ts +28 -0
- package/dist/tui/components/notification.d.ts.map +1 -0
- package/dist/tui/components/notification.js +63 -0
- package/dist/tui/components/progress-bar.d.ts.map +1 -1
- package/dist/tui/components/progress-bar.js +3 -15
- package/dist/tui/components/select-list.d.ts +0 -15
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +5 -28
- package/dist/tui/components/tool-execution.d.ts +3 -6
- package/dist/tui/components/tool-execution.d.ts.map +1 -1
- package/dist/tui/components/tool-execution.js +26 -38
- package/dist/tui/components/welcome.d.ts +8 -1
- package/dist/tui/components/welcome.d.ts.map +1 -1
- package/dist/tui/components/welcome.js +45 -6
- package/dist/tui/index.d.ts +4 -2
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +2 -2
- package/dist/tui/terminal.d.ts +2 -2
- package/dist/tui/terminal.d.ts.map +1 -1
- package/dist/tui/terminal.js +23 -19
- package/dist/tui/tui.d.ts +1 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +24 -29
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +2 -3
- package/dist/utils/yaml.d.ts +11 -0
- package/dist/utils/yaml.d.ts.map +1 -0
- package/dist/utils/yaml.js +207 -0
- package/dist/utils/zod.d.ts +1 -0
- package/dist/utils/zod.d.ts.map +1 -1
- package/dist/utils/zod.js +17 -0
- package/package.json +31 -29
- package/bin/acai-wrapper.js +0 -26
- package/dist/api/exa/index.d.ts +0 -177
- package/dist/api/exa/index.d.ts.map +0 -1
- package/dist/api/exa/index.js +0 -439
- package/dist/commands/add-directory-command.d.ts +0 -3
- package/dist/commands/add-directory-command.d.ts.map +0 -1
- package/dist/commands/application-log-command.d.ts +0 -3
- package/dist/commands/application-log-command.d.ts.map +0 -1
- package/dist/commands/application-log-command.js +0 -43
- package/dist/commands/clear-command.d.ts +0 -3
- package/dist/commands/clear-command.d.ts.map +0 -1
- package/dist/commands/compact-command.d.ts +0 -3
- package/dist/commands/compact-command.d.ts.map +0 -1
- package/dist/commands/compact-command.js +0 -55
- package/dist/commands/context-command.d.ts +0 -3
- package/dist/commands/context-command.d.ts.map +0 -1
- package/dist/commands/context-command.js +0 -124
- package/dist/commands/copy-command.d.ts +0 -3
- package/dist/commands/copy-command.d.ts.map +0 -1
- package/dist/commands/edit-command.d.ts +0 -3
- package/dist/commands/edit-command.d.ts.map +0 -1
- package/dist/commands/edit-command.js +0 -42
- package/dist/commands/edit-prompt-command.d.ts +0 -3
- package/dist/commands/edit-prompt-command.d.ts.map +0 -1
- package/dist/commands/edit-prompt-command.js +0 -36
- package/dist/commands/exit-command.d.ts.map +0 -1
- package/dist/commands/exit-command.js +0 -30
- package/dist/commands/files-command.d.ts +0 -3
- package/dist/commands/files-command.d.ts.map +0 -1
- package/dist/commands/files-command.js +0 -68
- package/dist/commands/generate-rules-command.d.ts +0 -3
- package/dist/commands/generate-rules-command.d.ts.map +0 -1
- package/dist/commands/handoff-command.d.ts +0 -3
- package/dist/commands/handoff-command.d.ts.map +0 -1
- package/dist/commands/health-command.d.ts +0 -4
- package/dist/commands/health-command.d.ts.map +0 -1
- package/dist/commands/health-command.js +0 -118
- package/dist/commands/help-command.d.ts.map +0 -1
- package/dist/commands/history-command.d.ts +0 -3
- package/dist/commands/history-command.d.ts.map +0 -1
- package/dist/commands/init-command.d.ts +0 -3
- package/dist/commands/init-command.d.ts.map +0 -1
- package/dist/commands/last-log-command.d.ts +0 -3
- package/dist/commands/last-log-command.d.ts.map +0 -1
- package/dist/commands/last-log-command.js +0 -71
- package/dist/commands/list-directories-command.d.ts +0 -3
- package/dist/commands/list-directories-command.d.ts.map +0 -1
- package/dist/commands/list-tools-command.d.ts +0 -3
- package/dist/commands/list-tools-command.d.ts.map +0 -1
- package/dist/commands/model-command.d.ts +0 -3
- package/dist/commands/model-command.d.ts.map +0 -1
- package/dist/commands/paste-command.d.ts.map +0 -1
- package/dist/commands/pickup-command.d.ts +0 -3
- package/dist/commands/pickup-command.d.ts.map +0 -1
- package/dist/commands/pickup-command.js +0 -109
- package/dist/commands/prompt-command.d.ts +0 -21
- package/dist/commands/prompt-command.d.ts.map +0 -1
- package/dist/commands/prompt-command.js +0 -258
- package/dist/commands/remove-directory-command.d.ts +0 -3
- package/dist/commands/remove-directory-command.d.ts.map +0 -1
- package/dist/commands/reset-command.d.ts +0 -3
- package/dist/commands/reset-command.d.ts.map +0 -1
- package/dist/commands/rules-command.d.ts +0 -3
- package/dist/commands/rules-command.d.ts.map +0 -1
- package/dist/commands/rules-command.js +0 -73
- package/dist/commands/save-command.d.ts +0 -3
- package/dist/commands/save-command.d.ts.map +0 -1
- package/dist/commands/shell-command.d.ts +0 -3
- package/dist/commands/shell-command.d.ts.map +0 -1
- package/dist/commands/usage-command.d.ts +0 -3
- package/dist/commands/usage-command.d.ts.map +0 -1
- package/dist/commands/usage-command.js +0 -31
- package/dist/messages.d.ts.map +0 -1
- package/dist/repl/project-status-line.d.ts +0 -3
- package/dist/repl/project-status-line.d.ts.map +0 -1
- package/dist/repl/project-status-line.js +0 -61
- package/dist/repl/tool-call-repair.d.ts +0 -4
- package/dist/repl/tool-call-repair.d.ts.map +0 -1
- package/dist/repl/tool-call-repair.js +0 -54
- package/dist/terminal/markdown.d.ts +0 -2
- package/dist/terminal/markdown.d.ts.map +0 -1
- package/dist/terminal/markdown.js +0 -120
- package/dist/tokens/threshold.d.ts +0 -20
- package/dist/tokens/threshold.d.ts.map +0 -1
- package/dist/tokens/threshold.js +0 -67
- package/dist/tools/advanced-edit-file.d.ts +0 -69
- package/dist/tools/advanced-edit-file.d.ts.map +0 -1
- package/dist/tools/advanced-edit-file.js +0 -285
- package/dist/tools/agent.d.ts +0 -29
- package/dist/tools/agent.d.ts.map +0 -1
- package/dist/tools/agent.js +0 -117
- package/dist/tools/batch.d.ts +0 -34
- package/dist/tools/batch.d.ts.map +0 -1
- package/dist/tools/batch.js +0 -174
- package/dist/tools/code-interpreter.d.ts +0 -25
- package/dist/tools/code-interpreter.d.ts.map +0 -1
- package/dist/tools/code-interpreter.js +0 -183
- package/dist/tools/delete-file.d.ts +0 -24
- package/dist/tools/delete-file.d.ts.map +0 -1
- package/dist/tools/delete-file.js +0 -77
- package/dist/tools/dynamic-tool-parser.d.ts +0 -21
- package/dist/tools/dynamic-tool-parser.d.ts.map +0 -1
- package/dist/tools/dynamic-tool-parser.js +0 -22
- package/dist/tools/llm-edit-fixer.d.ts +0 -24
- package/dist/tools/llm-edit-fixer.d.ts.map +0 -1
- package/dist/tools/llm-edit-fixer.js +0 -136
- package/dist/tools/move-file.d.ts +0 -26
- package/dist/tools/move-file.d.ts.map +0 -1
- package/dist/tools/move-file.js +0 -65
- package/dist/tools/read-multiple-files.d.ts +0 -26
- package/dist/tools/read-multiple-files.d.ts.map +0 -1
- package/dist/tools/read-multiple-files.js +0 -196
- package/dist/tools/web-fetch.d.ts +0 -56
- package/dist/tools/web-fetch.d.ts.map +0 -1
- package/dist/tools/web-fetch.js +0 -247
- package/dist/tools/web-search.d.ts +0 -23
- package/dist/tools/web-search.d.ts.map +0 -1
- package/dist/tools/web-search.js +0 -148
- package/dist/tui/components/prompt-status.d.ts +0 -17
- package/dist/tui/components/prompt-status.d.ts.map +0 -1
- package/dist/tui/components/prompt-status.js +0 -26
|
@@ -1,285 +0,0 @@
|
|
|
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 { config } from "../config.js";
|
|
6
|
-
import style from "../terminal/style.js";
|
|
7
|
-
import { joinWorkingDir, validateFileNotReadOnly, validatePath, } from "../utils/filesystem/security.js";
|
|
8
|
-
export const AdvancedEditFileTool = {
|
|
9
|
-
name: "advancedEditFile",
|
|
10
|
-
};
|
|
11
|
-
const inputSchema = z.object({
|
|
12
|
-
path: z.string().describe("The path of the file to edit."),
|
|
13
|
-
mode: z
|
|
14
|
-
.enum(["exact", "regex", "ast"])
|
|
15
|
-
.default("exact")
|
|
16
|
-
.describe("Editing mode: exact (literal text), regex (pattern matching), or ast (AST-aware)"),
|
|
17
|
-
operations: z.array(z.object({
|
|
18
|
-
type: z
|
|
19
|
-
.enum(["replace", "insert-before", "insert-after", "delete"])
|
|
20
|
-
.describe("Type of operation to perform"),
|
|
21
|
-
pattern: z
|
|
22
|
-
.string()
|
|
23
|
-
.describe("Pattern to match (text, regex, or AST pattern depending on mode)"),
|
|
24
|
-
replacement: z
|
|
25
|
-
.string()
|
|
26
|
-
.optional()
|
|
27
|
-
.describe("Replacement text (required for replace operations)"),
|
|
28
|
-
flags: z
|
|
29
|
-
.string()
|
|
30
|
-
.optional()
|
|
31
|
-
.describe("Regex flags for regex mode (e.g., 'g', 'i', 'm')"),
|
|
32
|
-
})),
|
|
33
|
-
astPattern: z
|
|
34
|
-
.string()
|
|
35
|
-
.optional()
|
|
36
|
-
.describe("AST-grep search pattern for AST mode (e.g., 'var $V = $VAL')"),
|
|
37
|
-
astReplacement: z
|
|
38
|
-
.string()
|
|
39
|
-
.optional()
|
|
40
|
-
.describe("AST-grep replacement pattern for AST mode (e.g., 'let $V = $VAL')"),
|
|
41
|
-
dryRun: z.boolean().default(false).describe("Show changes without writing"),
|
|
42
|
-
});
|
|
43
|
-
export const createAdvancedEditFileTool = async ({ workingDir, allowedDirs, }) => {
|
|
44
|
-
const allowedDirectory = allowedDirs ?? [workingDir];
|
|
45
|
-
return {
|
|
46
|
-
toolDef: {
|
|
47
|
-
description: "Advanced file editing with multiple modes: exact text matching, regex pattern matching, and AST-aware editing. " +
|
|
48
|
-
"Supports replace, insert-before, insert-after, and delete operations. AST mode requires ast-grep to be installed.",
|
|
49
|
-
inputSchema,
|
|
50
|
-
},
|
|
51
|
-
async *execute({ path, mode, operations, astPattern, astReplacement, dryRun, }, { toolCallId, abortSignal }) {
|
|
52
|
-
try {
|
|
53
|
-
if (abortSignal?.aborted) {
|
|
54
|
-
throw new Error("File editing aborted");
|
|
55
|
-
}
|
|
56
|
-
yield {
|
|
57
|
-
name: AdvancedEditFileTool.name,
|
|
58
|
-
id: toolCallId,
|
|
59
|
-
event: "tool-init",
|
|
60
|
-
data: `${style.cyan(path)} (mode: ${mode})`,
|
|
61
|
-
};
|
|
62
|
-
const validPath = await validatePath(joinWorkingDir(path, workingDir), allowedDirectory, { abortSignal });
|
|
63
|
-
// Check if file is read-only
|
|
64
|
-
const projectConfig = await config.getConfig();
|
|
65
|
-
validateFileNotReadOnly(validPath, projectConfig, workingDir);
|
|
66
|
-
const result = await applyAdvancedFileEdits(validPath, mode, operations, astPattern, astReplacement, dryRun, abortSignal);
|
|
67
|
-
yield {
|
|
68
|
-
name: AdvancedEditFileTool.name,
|
|
69
|
-
id: toolCallId,
|
|
70
|
-
event: "tool-completion",
|
|
71
|
-
data: `Applied ${operations.length} edits`,
|
|
72
|
-
};
|
|
73
|
-
yield result;
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
yield {
|
|
77
|
-
name: AdvancedEditFileTool.name,
|
|
78
|
-
event: "tool-error",
|
|
79
|
-
id: toolCallId,
|
|
80
|
-
data: error.message,
|
|
81
|
-
};
|
|
82
|
-
yield `Failed to edit file: ${error.message}`;
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
// file editing and diffing utilities
|
|
88
|
-
function normalizeLineEndings(text) {
|
|
89
|
-
return text.replace(/\r\n/g, "\n");
|
|
90
|
-
}
|
|
91
|
-
function createUnifiedDiff(originalContent, newContent, filepath = "file") {
|
|
92
|
-
// Ensure consistent line endings for diff
|
|
93
|
-
const normalizedOriginal = normalizeLineEndings(originalContent);
|
|
94
|
-
const normalizedNew = normalizeLineEndings(newContent);
|
|
95
|
-
return createTwoFilesPatch(filepath, filepath, normalizedOriginal, normalizedNew, "original", "modified");
|
|
96
|
-
}
|
|
97
|
-
function applyExactModeEdits(content, operations) {
|
|
98
|
-
let modifiedContent = content;
|
|
99
|
-
for (const op of operations) {
|
|
100
|
-
switch (op.type) {
|
|
101
|
-
case "replace": {
|
|
102
|
-
if (!op.replacement) {
|
|
103
|
-
throw new Error("Replacement text required for replace operation");
|
|
104
|
-
}
|
|
105
|
-
// Exact text replacement (global)
|
|
106
|
-
let currentIndex = 0;
|
|
107
|
-
let matchCount = 0;
|
|
108
|
-
while (currentIndex < modifiedContent.length) {
|
|
109
|
-
const matchIndex = modifiedContent.indexOf(op.pattern, currentIndex);
|
|
110
|
-
if (matchIndex === -1) {
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
matchCount++;
|
|
114
|
-
modifiedContent =
|
|
115
|
-
modifiedContent.slice(0, matchIndex) +
|
|
116
|
-
op.replacement +
|
|
117
|
-
modifiedContent.slice(matchIndex + op.pattern.length);
|
|
118
|
-
currentIndex = matchIndex + op.replacement.length;
|
|
119
|
-
}
|
|
120
|
-
if (matchCount === 0) {
|
|
121
|
-
throw new Error(`Pattern not found in content: ${op.pattern}`);
|
|
122
|
-
}
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
case "insert-before": {
|
|
126
|
-
if (!op.replacement) {
|
|
127
|
-
throw new Error("Replacement text required for insert-before operation");
|
|
128
|
-
}
|
|
129
|
-
const beforeIndex = modifiedContent.indexOf(op.pattern);
|
|
130
|
-
if (beforeIndex === -1) {
|
|
131
|
-
throw new Error(`Pattern not found for insert-before: ${op.pattern}`);
|
|
132
|
-
}
|
|
133
|
-
modifiedContent =
|
|
134
|
-
modifiedContent.slice(0, beforeIndex) +
|
|
135
|
-
op.replacement +
|
|
136
|
-
"\n" +
|
|
137
|
-
modifiedContent.slice(beforeIndex);
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
case "insert-after": {
|
|
141
|
-
if (!op.replacement) {
|
|
142
|
-
throw new Error("Replacement text required for insert-after operation");
|
|
143
|
-
}
|
|
144
|
-
const afterIndex = modifiedContent.indexOf(op.pattern);
|
|
145
|
-
if (afterIndex === -1) {
|
|
146
|
-
throw new Error(`Pattern not found for insert-after: ${op.pattern}`);
|
|
147
|
-
}
|
|
148
|
-
const insertPosition = afterIndex + op.pattern.length;
|
|
149
|
-
modifiedContent =
|
|
150
|
-
modifiedContent.slice(0, insertPosition) +
|
|
151
|
-
"\n" +
|
|
152
|
-
op.replacement +
|
|
153
|
-
modifiedContent.slice(insertPosition);
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
case "delete": {
|
|
157
|
-
// For delete operations, use line-based approach to handle newlines properly
|
|
158
|
-
const lines = modifiedContent.split("\n");
|
|
159
|
-
const filteredLines = lines.filter((line) => !line.includes(op.pattern));
|
|
160
|
-
if (filteredLines.length === lines.length) {
|
|
161
|
-
throw new Error(`Pattern not found for delete: ${op.pattern}`);
|
|
162
|
-
}
|
|
163
|
-
modifiedContent = filteredLines.join("\n");
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return modifiedContent;
|
|
169
|
-
}
|
|
170
|
-
function applyRegexModeEdits(content, operations) {
|
|
171
|
-
let modifiedContent = content;
|
|
172
|
-
for (const op of operations) {
|
|
173
|
-
const flags = op.flags || "g";
|
|
174
|
-
const regex = new RegExp(op.pattern, flags);
|
|
175
|
-
switch (op.type) {
|
|
176
|
-
case "replace":
|
|
177
|
-
if (!op.replacement) {
|
|
178
|
-
throw new Error("Replacement text required for replace operation");
|
|
179
|
-
}
|
|
180
|
-
modifiedContent = modifiedContent.replace(regex, op.replacement);
|
|
181
|
-
break;
|
|
182
|
-
case "insert-before":
|
|
183
|
-
if (!op.replacement) {
|
|
184
|
-
throw new Error("Replacement text required for insert-before operation");
|
|
185
|
-
}
|
|
186
|
-
modifiedContent = modifiedContent.replace(regex, `${op.replacement}\n$&`);
|
|
187
|
-
break;
|
|
188
|
-
case "insert-after":
|
|
189
|
-
if (!op.replacement) {
|
|
190
|
-
throw new Error("Replacement text required for insert-after operation");
|
|
191
|
-
}
|
|
192
|
-
modifiedContent = modifiedContent.replace(regex, `$&\n${op.replacement}`);
|
|
193
|
-
break;
|
|
194
|
-
case "delete":
|
|
195
|
-
modifiedContent = modifiedContent.replace(regex, "");
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return modifiedContent;
|
|
200
|
-
}
|
|
201
|
-
function applyAstModeEdits(filePath, astPattern, astReplacement, dryRun) {
|
|
202
|
-
if (!astPattern || !astReplacement) {
|
|
203
|
-
throw new Error("AST mode requires both astPattern and astReplacement");
|
|
204
|
-
}
|
|
205
|
-
try {
|
|
206
|
-
const cmd = [
|
|
207
|
-
"ast-grep",
|
|
208
|
-
"--pattern",
|
|
209
|
-
`"${astPattern}"`,
|
|
210
|
-
"--rewrite",
|
|
211
|
-
`"${astReplacement}"`,
|
|
212
|
-
dryRun ? "--dry-run" : "--write",
|
|
213
|
-
filePath,
|
|
214
|
-
].join(" ");
|
|
215
|
-
if (dryRun) {
|
|
216
|
-
const output = execSync(cmd, { encoding: "utf-8" });
|
|
217
|
-
return `AST edit preview:\n${output}`;
|
|
218
|
-
}
|
|
219
|
-
execSync(cmd, { stdio: "inherit" });
|
|
220
|
-
return `AST edit applied to ${filePath}`;
|
|
221
|
-
}
|
|
222
|
-
catch (err) {
|
|
223
|
-
throw new Error(`AST edit failed: ${err.message}`);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
export async function applyAdvancedFileEdits(filePath, mode, operations, astPattern, astReplacement, dryRun = false, abortSignal) {
|
|
227
|
-
if (abortSignal?.aborted) {
|
|
228
|
-
throw new Error("File edit operation aborted");
|
|
229
|
-
}
|
|
230
|
-
// Read file content literally with signal
|
|
231
|
-
const originalContent = await readFile(filePath, {
|
|
232
|
-
encoding: "utf-8",
|
|
233
|
-
signal: abortSignal,
|
|
234
|
-
});
|
|
235
|
-
let modifiedContent = originalContent;
|
|
236
|
-
let resultMessage = "";
|
|
237
|
-
if (mode === "ast") {
|
|
238
|
-
// AST mode uses external ast-grep tool
|
|
239
|
-
if (!astPattern || !astReplacement) {
|
|
240
|
-
throw new Error("AST mode requires both astPattern and astReplacement");
|
|
241
|
-
}
|
|
242
|
-
resultMessage = applyAstModeEdits(filePath, astPattern, astReplacement, dryRun);
|
|
243
|
-
if (dryRun) {
|
|
244
|
-
return resultMessage;
|
|
245
|
-
}
|
|
246
|
-
// For actual AST edits, read the modified content back
|
|
247
|
-
modifiedContent = await readFile(filePath, {
|
|
248
|
-
encoding: "utf-8",
|
|
249
|
-
signal: abortSignal,
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
else {
|
|
253
|
-
// Text-based modes (exact and regex)
|
|
254
|
-
if (operations.length === 0) {
|
|
255
|
-
throw new Error("No operations specified for text-based editing mode");
|
|
256
|
-
}
|
|
257
|
-
switch (mode) {
|
|
258
|
-
case "exact":
|
|
259
|
-
modifiedContent = applyExactModeEdits(originalContent, operations);
|
|
260
|
-
break;
|
|
261
|
-
case "regex":
|
|
262
|
-
modifiedContent = applyRegexModeEdits(originalContent, operations);
|
|
263
|
-
break;
|
|
264
|
-
}
|
|
265
|
-
// Create unified diff
|
|
266
|
-
const diff = createUnifiedDiff(originalContent, modifiedContent, filePath);
|
|
267
|
-
// Format diff with appropriate number of backticks
|
|
268
|
-
let numBackticks = 3;
|
|
269
|
-
while (diff.includes("`".repeat(numBackticks))) {
|
|
270
|
-
numBackticks++;
|
|
271
|
-
}
|
|
272
|
-
resultMessage = `${"`".repeat(numBackticks)}diff\n${diff}${"`".repeat(numBackticks)}\n\n`;
|
|
273
|
-
if (!dryRun) {
|
|
274
|
-
if (abortSignal?.aborted) {
|
|
275
|
-
throw new Error("File edit operation aborted before writing");
|
|
276
|
-
}
|
|
277
|
-
// Write the modified content with signal
|
|
278
|
-
await writeFile(filePath, modifiedContent, {
|
|
279
|
-
encoding: "utf-8",
|
|
280
|
-
signal: abortSignal,
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
return resultMessage;
|
|
285
|
-
}
|
package/dist/tools/agent.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { type ToolCallOptions } from "ai";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import type { WorkspaceContext } from "../index.ts";
|
|
4
|
-
import type { ModelManager } from "../models/manager.ts";
|
|
5
|
-
import type { TokenCounter } from "../tokens/counter.ts";
|
|
6
|
-
import type { TokenTracker } from "../tokens/tracker.ts";
|
|
7
|
-
import type { ToolResult } from "./types.ts";
|
|
8
|
-
export declare const AgentTool: {
|
|
9
|
-
name: "agent";
|
|
10
|
-
};
|
|
11
|
-
declare const inputSchema: z.ZodObject<{
|
|
12
|
-
prompt: z.ZodString;
|
|
13
|
-
}, z.core.$strip>;
|
|
14
|
-
export declare const createAgentTools: (options: {
|
|
15
|
-
modelManager: ModelManager;
|
|
16
|
-
tokenTracker: TokenTracker;
|
|
17
|
-
tokenCounter: TokenCounter;
|
|
18
|
-
workspace: WorkspaceContext;
|
|
19
|
-
}) => {
|
|
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>;
|
|
27
|
-
};
|
|
28
|
-
export {};
|
|
29
|
-
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;CA+E9B,CAAC"}
|
package/dist/tools/agent.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { generateText, stepCountIs } from "ai";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { AiConfig } from "../models/ai-config.js";
|
|
4
|
-
import { DirectoryTreeTool } from "./directory-tree.js";
|
|
5
|
-
import { GlobTool } from "./glob.js";
|
|
6
|
-
import { GrepTool } from "./grep.js";
|
|
7
|
-
import { initCliTools } from "./index.js";
|
|
8
|
-
import { ReadFileTool } from "./read-file.js";
|
|
9
|
-
import { ReadMultipleFilesTool } from "./read-multiple-files.js";
|
|
10
|
-
export const AgentTool = {
|
|
11
|
-
name: "agent",
|
|
12
|
-
};
|
|
13
|
-
const TOOLS = [
|
|
14
|
-
GrepTool.name,
|
|
15
|
-
GlobTool.name,
|
|
16
|
-
ReadFileTool.name,
|
|
17
|
-
ReadMultipleFilesTool.name,
|
|
18
|
-
DirectoryTreeTool.name,
|
|
19
|
-
];
|
|
20
|
-
function getToolDescription() {
|
|
21
|
-
const toolNames = TOOLS.join(", ");
|
|
22
|
-
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.
|
|
23
|
-
|
|
24
|
-
Use cases:
|
|
25
|
-
- Search for files matching specific patterns (e.g., "*.ts", "**/*.test.ts") using ${GlobTool.name}
|
|
26
|
-
- Find code patterns or text within files using ${GrepTool.name}
|
|
27
|
-
- Read specific files or multiple files using ${ReadFileTool.name} and ${ReadMultipleFilesTool.name}
|
|
28
|
-
|
|
29
|
-
Important limitations:
|
|
30
|
-
- This agent cannot execute shell commands or run external tools
|
|
31
|
-
- It is focused purely on file discovery and content reading
|
|
32
|
-
- For complex operations or command execution, use the main assistant directly
|
|
33
|
-
|
|
34
|
-
Usage notes:
|
|
35
|
-
1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses
|
|
36
|
-
2. When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result.
|
|
37
|
-
3. Each agent invocation is stateless. You will not be able to send additional messages to the agent, nor will the agent be able to communicate with you outside of its final report. Therefore, your prompt should contain a highly detailed task description for the agent to perform autonomously and you should specify exactly what information the agent should return back to you in its final and only message to you.
|
|
38
|
-
4. The agent's outputs should generally be trusted.`;
|
|
39
|
-
}
|
|
40
|
-
const inputSchema = z.object({
|
|
41
|
-
prompt: z.string().describe("The task for the agent to perform"),
|
|
42
|
-
});
|
|
43
|
-
export const createAgentTools = (options) => {
|
|
44
|
-
const { modelManager, tokenTracker, tokenCounter } = options;
|
|
45
|
-
const toolDef = {
|
|
46
|
-
description: getToolDescription(),
|
|
47
|
-
inputSchema,
|
|
48
|
-
};
|
|
49
|
-
async function* execute({ prompt }, { toolCallId, abortSignal }) {
|
|
50
|
-
if (abortSignal?.aborted) {
|
|
51
|
-
throw new Error("Agent execution aborted");
|
|
52
|
-
}
|
|
53
|
-
yield {
|
|
54
|
-
name: AgentTool.name,
|
|
55
|
-
event: "tool-init",
|
|
56
|
-
id: toolCallId,
|
|
57
|
-
data: "Invoking agent...",
|
|
58
|
-
};
|
|
59
|
-
yield {
|
|
60
|
-
name: AgentTool.name,
|
|
61
|
-
event: "tool-update",
|
|
62
|
-
id: toolCallId,
|
|
63
|
-
data: `## Prompt:\n\n${prompt}`,
|
|
64
|
-
};
|
|
65
|
-
try {
|
|
66
|
-
const modelConfig = modelManager.getModelMetadata("task-agent");
|
|
67
|
-
const aiConfig = new AiConfig({
|
|
68
|
-
modelMetadata: modelConfig,
|
|
69
|
-
prompt,
|
|
70
|
-
});
|
|
71
|
-
const { text, usage } = await generateText({
|
|
72
|
-
model: modelManager.getModel("task-agent"),
|
|
73
|
-
maxOutputTokens: aiConfig.maxOutputTokens(),
|
|
74
|
-
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.",
|
|
75
|
-
prompt: prompt,
|
|
76
|
-
temperature: aiConfig.temperature(),
|
|
77
|
-
topP: aiConfig.topP(),
|
|
78
|
-
stopWhen: stepCountIs(30),
|
|
79
|
-
providerOptions: aiConfig.providerOptions(),
|
|
80
|
-
tools: (await initCliTools({
|
|
81
|
-
tokenCounter,
|
|
82
|
-
workspace: options.workspace,
|
|
83
|
-
})).toolDefs,
|
|
84
|
-
abortSignal: abortSignal,
|
|
85
|
-
// biome-ignore lint/style/useNamingConvention: third-party code
|
|
86
|
-
experimental_activeTools: [...TOOLS],
|
|
87
|
-
});
|
|
88
|
-
tokenTracker.trackUsage("task-agent", usage);
|
|
89
|
-
yield {
|
|
90
|
-
name: AgentTool.name,
|
|
91
|
-
event: "tool-update",
|
|
92
|
-
id: toolCallId,
|
|
93
|
-
data: `## Response:\n\n${text}`,
|
|
94
|
-
};
|
|
95
|
-
yield {
|
|
96
|
-
name: AgentTool.name,
|
|
97
|
-
event: "tool-completion",
|
|
98
|
-
id: toolCallId,
|
|
99
|
-
data: `Finished (${usage.totalTokens} tokens)`,
|
|
100
|
-
};
|
|
101
|
-
yield text;
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
yield {
|
|
105
|
-
name: AgentTool.name,
|
|
106
|
-
event: "tool-error",
|
|
107
|
-
id: toolCallId,
|
|
108
|
-
data: error.message,
|
|
109
|
-
};
|
|
110
|
-
yield error.message;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
toolDef,
|
|
115
|
-
execute,
|
|
116
|
-
};
|
|
117
|
-
};
|
package/dist/tools/batch.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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";
|
|
5
|
-
export declare const BatchTool: {
|
|
6
|
-
name: "batch";
|
|
7
|
-
};
|
|
8
|
-
declare const inputSchema: z.ZodObject<{
|
|
9
|
-
calls: z.ZodArray<z.ZodObject<{
|
|
10
|
-
tool: z.ZodString;
|
|
11
|
-
arguments: z.ZodRecord<z.ZodAny, z.ZodAny>;
|
|
12
|
-
id: z.ZodOptional<z.ZodString>;
|
|
13
|
-
}, z.core.$strip>>;
|
|
14
|
-
}, z.core.$strip>;
|
|
15
|
-
type BatchInputSchema = z.infer<typeof inputSchema>;
|
|
16
|
-
type ToolExecutor = (args: Record<string, unknown>, options: ToolCallOptions) => AsyncGenerator<ToolResult> | Promise<string>;
|
|
17
|
-
export declare const createBatchTool: ({ tokenCounter, executors, }: {
|
|
18
|
-
tokenCounter: TokenCounter;
|
|
19
|
-
executors: Map<string, ToolExecutor>;
|
|
20
|
-
}) => Promise<{
|
|
21
|
-
toolDef: {
|
|
22
|
-
description: string;
|
|
23
|
-
inputSchema: z.ZodObject<{
|
|
24
|
-
calls: z.ZodArray<z.ZodObject<{
|
|
25
|
-
tool: z.ZodString;
|
|
26
|
-
arguments: z.ZodRecord<z.ZodAny, z.ZodAny>;
|
|
27
|
-
id: z.ZodOptional<z.ZodString>;
|
|
28
|
-
}, z.core.$strip>>;
|
|
29
|
-
}, z.core.$strip>;
|
|
30
|
-
};
|
|
31
|
-
execute({ calls }: BatchInputSchema, { toolCallId, messages, abortSignal }: ToolCallOptions): AsyncGenerator<ToolResult>;
|
|
32
|
-
}>;
|
|
33
|
-
export {};
|
|
34
|
-
//# sourceMappingURL=batch.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../source/tools/batch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAKzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,eAAO,MAAM,SAAS;;CAErB,CAAC;AAaF,QAAA,MAAM,WAAW;;;;;;iBAMf,CAAC;AAEH,KAAK,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AACpD,KAAK,YAAY,GAAG,CAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,eAAe,KACrB,cAAc,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAElD,eAAO,MAAM,eAAe,GAAU,8BAGnC;IACD,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACtC;;;;;;;;;;;uBAQgB,gBAAgB,yCACY,eAAe,GACrD,cAAc,CAAC,UAAU,CAAC;EAkLhC,CAAC"}
|
package/dist/tools/batch.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { logger } from "../logger.js";
|
|
3
|
-
import style from "../terminal/style.js";
|
|
4
|
-
import { manageTokenLimit, TokenLimitExceededError, } from "../tokens/threshold.js";
|
|
5
|
-
export const BatchTool = {
|
|
6
|
-
name: "batch",
|
|
7
|
-
};
|
|
8
|
-
const toolCallSchema = z.object({
|
|
9
|
-
tool: z.string().describe("Name of the tool to execute"),
|
|
10
|
-
arguments: z
|
|
11
|
-
.record(z.any(), z.any())
|
|
12
|
-
.describe("Arguments to pass to the tool"),
|
|
13
|
-
id: z
|
|
14
|
-
.string()
|
|
15
|
-
.optional()
|
|
16
|
-
.describe("Optional ID for tracking this specific call"),
|
|
17
|
-
});
|
|
18
|
-
const inputSchema = z.object({
|
|
19
|
-
calls: z
|
|
20
|
-
.array(toolCallSchema)
|
|
21
|
-
.min(1)
|
|
22
|
-
.max(10)
|
|
23
|
-
.describe("Array of tool calls to execute in sequence"),
|
|
24
|
-
});
|
|
25
|
-
export const createBatchTool = async ({ tokenCounter, executors, }) => {
|
|
26
|
-
return {
|
|
27
|
-
toolDef: {
|
|
28
|
-
description: "Execute multiple tool calls in a single request. Reduces roundtrips by batching operations. Tools are executed sequentially in the order provided.",
|
|
29
|
-
inputSchema,
|
|
30
|
-
},
|
|
31
|
-
async *execute({ calls }, { toolCallId, messages, abortSignal }) {
|
|
32
|
-
try {
|
|
33
|
-
if (abortSignal?.aborted) {
|
|
34
|
-
throw new Error("Batch execution aborted");
|
|
35
|
-
}
|
|
36
|
-
const totalCalls = calls.length;
|
|
37
|
-
yield {
|
|
38
|
-
name: BatchTool.name,
|
|
39
|
-
event: "tool-init",
|
|
40
|
-
id: toolCallId,
|
|
41
|
-
data: `Starting batch execution of ${totalCalls} tool calls`,
|
|
42
|
-
};
|
|
43
|
-
const results = [];
|
|
44
|
-
for (let i = 0; i < calls.length; i++) {
|
|
45
|
-
const call = calls[i];
|
|
46
|
-
const { tool: toolName, arguments: args, id: callId } = call;
|
|
47
|
-
const callNumber = i + 1;
|
|
48
|
-
if (abortSignal?.aborted) {
|
|
49
|
-
results.push({
|
|
50
|
-
tool: toolName,
|
|
51
|
-
id: callId,
|
|
52
|
-
status: "error",
|
|
53
|
-
error: "Batch execution aborted",
|
|
54
|
-
});
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
const executor = executors.get(toolName);
|
|
58
|
-
if (!executor) {
|
|
59
|
-
results.push({
|
|
60
|
-
tool: toolName,
|
|
61
|
-
id: callId,
|
|
62
|
-
status: "error",
|
|
63
|
-
error: `Unknown tool '${toolName}'`,
|
|
64
|
-
});
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
yield {
|
|
68
|
-
name: BatchTool.name,
|
|
69
|
-
event: "tool-update",
|
|
70
|
-
id: toolCallId,
|
|
71
|
-
data: `[${callNumber}/${totalCalls}] ${style.cyan(toolName)}${callId ? ` (${callId})` : ""} ${style.dim(JSON.stringify(args).slice(0, 60))}...`,
|
|
72
|
-
};
|
|
73
|
-
try {
|
|
74
|
-
const executorResult = executor(args, {
|
|
75
|
-
toolCallId: callId || `${toolCallId}-${i}`,
|
|
76
|
-
messages,
|
|
77
|
-
abortSignal,
|
|
78
|
-
});
|
|
79
|
-
let toolOutput = "";
|
|
80
|
-
// Handle both async generators and regular async functions
|
|
81
|
-
if (typeof executorResult[Symbol.asyncIterator] === "function") {
|
|
82
|
-
// It's an async generator
|
|
83
|
-
const generator = executorResult;
|
|
84
|
-
for await (const chunk of generator) {
|
|
85
|
-
if (typeof chunk === "string") {
|
|
86
|
-
toolOutput += chunk;
|
|
87
|
-
}
|
|
88
|
-
else if (chunk.event === "tool-completion") {
|
|
89
|
-
// Capture completion message
|
|
90
|
-
toolOutput += chunk.data;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
// It's a regular async function returning a string
|
|
96
|
-
toolOutput = await executorResult;
|
|
97
|
-
}
|
|
98
|
-
results.push({
|
|
99
|
-
tool: toolName,
|
|
100
|
-
id: callId,
|
|
101
|
-
status: "success",
|
|
102
|
-
result: toolOutput,
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
107
|
-
logger.error({ error, toolName, args }, "Batch tool execution failed");
|
|
108
|
-
results.push({
|
|
109
|
-
tool: toolName,
|
|
110
|
-
id: callId,
|
|
111
|
-
status: "error",
|
|
112
|
-
error: errorMessage,
|
|
113
|
-
});
|
|
114
|
-
// Yield update for failed command
|
|
115
|
-
yield {
|
|
116
|
-
name: BatchTool.name,
|
|
117
|
-
event: "tool-update",
|
|
118
|
-
id: toolCallId,
|
|
119
|
-
data: `[${callNumber}/${totalCalls}] ${style.red("✗")} ${style.cyan(toolName)} failed: ${errorMessage.slice(0, 100)}`,
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
// Format results as JSON
|
|
124
|
-
const jsonResults = JSON.stringify(results, null, 2);
|
|
125
|
-
try {
|
|
126
|
-
const result = await manageTokenLimit(jsonResults, tokenCounter, "Batch", "Consider reducing the number of calls or using more specific tool calls");
|
|
127
|
-
// Create a more informative completion message
|
|
128
|
-
const successful = results.filter((r) => r.status === "success").length;
|
|
129
|
-
const failed = results.filter((r) => r.status === "error").length;
|
|
130
|
-
let completionMessage = `Batch execution completed: ${successful}/${totalCalls} successful`;
|
|
131
|
-
if (failed > 0) {
|
|
132
|
-
const failedTools = results
|
|
133
|
-
.filter((r) => r.status === "error")
|
|
134
|
-
.map((r) => `${r.tool}${r.id ? ` (${r.id})` : ""}`)
|
|
135
|
-
.join(", ");
|
|
136
|
-
completionMessage += `, ${failed} failed: ${failedTools}`;
|
|
137
|
-
}
|
|
138
|
-
completionMessage += ` (${result.tokenCount} tokens)`;
|
|
139
|
-
yield {
|
|
140
|
-
name: BatchTool.name,
|
|
141
|
-
event: "tool-completion",
|
|
142
|
-
id: toolCallId,
|
|
143
|
-
data: completionMessage,
|
|
144
|
-
};
|
|
145
|
-
yield result.content;
|
|
146
|
-
}
|
|
147
|
-
catch (error) {
|
|
148
|
-
if (error instanceof TokenLimitExceededError) {
|
|
149
|
-
yield {
|
|
150
|
-
name: BatchTool.name,
|
|
151
|
-
event: "tool-error",
|
|
152
|
-
id: toolCallId,
|
|
153
|
-
data: error.message,
|
|
154
|
-
};
|
|
155
|
-
yield error.message;
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
throw error;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
catch (error) {
|
|
162
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
163
|
-
logger.error({ error }, "Batch tool failed");
|
|
164
|
-
yield {
|
|
165
|
-
name: BatchTool.name,
|
|
166
|
-
event: "tool-error",
|
|
167
|
-
id: toolCallId,
|
|
168
|
-
data: errorMessage,
|
|
169
|
-
};
|
|
170
|
-
yield errorMessage;
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
};
|
|
174
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
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";
|
|
5
|
-
export declare const CodeInterpreterTool: {
|
|
6
|
-
name: "codeInterpreter";
|
|
7
|
-
};
|
|
8
|
-
declare const inputSchema: z.ZodObject<{
|
|
9
|
-
code: z.ZodString;
|
|
10
|
-
timeoutSeconds: z.ZodNullable<z.ZodNumber>;
|
|
11
|
-
}, z.core.$strip>;
|
|
12
|
-
export declare const createCodeInterpreterTool: ({ tokenCounter, }: {
|
|
13
|
-
tokenCounter: TokenCounter;
|
|
14
|
-
}) => Promise<{
|
|
15
|
-
toolDef: {
|
|
16
|
-
description: string;
|
|
17
|
-
inputSchema: z.ZodObject<{
|
|
18
|
-
code: z.ZodString;
|
|
19
|
-
timeoutSeconds: z.ZodNullable<z.ZodNumber>;
|
|
20
|
-
}, z.core.$strip>;
|
|
21
|
-
};
|
|
22
|
-
execute: ({ code, timeoutSeconds }: z.infer<typeof inputSchema>, { toolCallId, abortSignal }: ToolCallOptions) => AsyncGenerator<ToolResult>;
|
|
23
|
-
}>;
|
|
24
|
-
export {};
|
|
25
|
-
//# sourceMappingURL=code-interpreter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-interpreter.d.ts","sourceRoot":"","sources":["../../source/tools/code-interpreter.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAKzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,eAAO,MAAM,mBAAmB;;CAE/B,CAAC;AAmBF,QAAA,MAAM,WAAW;;;iBASf,CAAC;AAEH,eAAO,MAAM,yBAAyB,GAAU,mBAE7C;IACD,YAAY,EAAE,YAAY,CAAC;CAC5B;;;;;;;;wCAO6B,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,+BACxB,eAAe,KAC3C,cAAc,CAAC,UAAU,CAAC;EAoL9B,CAAC"}
|