@travisennis/acai 0.0.7 → 0.0.9
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 +76 -27
- package/dist/agent/index.d.ts +21 -25
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +145 -103
- package/dist/cli.d.ts +2 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +23 -17
- 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} +57 -96
- 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 +35 -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 +122 -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 +230 -0
- package/dist/commands/session/types.d.ts +20 -0
- package/dist/commands/session/types.d.ts.map +1 -0
- package/dist/commands/session/types.js +7 -0
- package/dist/commands/share/html-renderer.d.ts +25 -0
- package/dist/commands/share/html-renderer.d.ts.map +1 -0
- package/dist/commands/share/html-renderer.js +384 -0
- package/dist/commands/share/index.d.ts +3 -0
- package/dist/commands/share/index.d.ts.map +1 -0
- package/dist/commands/share/index.js +122 -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 +194 -95
- 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 +14 -10
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +39 -0
- package/dist/models/opencode-zen-provider.d.ts +24 -0
- package/dist/models/opencode-zen-provider.d.ts.map +1 -0
- package/dist/models/opencode-zen-provider.js +94 -0
- package/dist/models/openrouter-provider.d.ts +35 -29
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +108 -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 +12 -2
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +74 -411
- 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 +18 -4
- package/dist/repl-new.d.ts.map +1 -1
- package/dist/repl-new.js +256 -43
- 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} +62 -14
- package/dist/skills.d.ts +0 -4
- package/dist/skills.d.ts.map +1 -1
- package/dist/skills.js +100 -59
- package/dist/stdin.d.ts +9 -0
- package/dist/stdin.d.ts.map +1 -0
- package/dist/stdin.js +26 -0
- package/dist/terminal/control.d.ts +1 -0
- package/dist/terminal/control.d.ts.map +1 -1
- package/dist/terminal/control.js +29 -6
- 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 +104 -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 +6 -2
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +166 -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 +64 -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/editor-launcher.d.ts +13 -0
- package/dist/tui/editor-launcher.d.ts.map +1 -0
- package/dist/tui/editor-launcher.js +39 -0
- package/dist/tui/index.d.ts +7 -3
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +3 -2
- package/dist/tui/terminal.d.ts +29 -2
- package/dist/tui/terminal.d.ts.map +1 -1
- package/dist/tui/terminal.js +153 -28
- package/dist/tui/tui.d.ts +2 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +39 -29
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +2 -3
- package/dist/utils/filesystem/security.d.ts.map +1 -1
- package/dist/utils/filesystem/security.js +4 -1
- 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
package/dist/agent/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { NoOutputGeneratedError, streamText, } from "ai";
|
|
1
|
+
import { generateText, InvalidToolInputError, NoOutputGeneratedError, NoSuchToolError, Output, streamText, tool, } from "ai";
|
|
2
2
|
import { config } from "../config.js";
|
|
3
3
|
import { logger } from "../logger.js";
|
|
4
4
|
import { AiConfig } from "../models/ai-config.js";
|
|
5
|
-
import { isToolMessage } from "../tools/types.js";
|
|
6
|
-
import { isAsyncIterable } from "../utils/iterables.js";
|
|
7
5
|
export class Agent {
|
|
8
6
|
opts;
|
|
9
7
|
_state;
|
|
@@ -20,10 +18,10 @@ export class Agent {
|
|
|
20
18
|
return this.abortController.signal;
|
|
21
19
|
}
|
|
22
20
|
async *run(args) {
|
|
23
|
-
const { modelManager,
|
|
21
|
+
const { modelManager, sessionManager, tokenTracker, maxIterations = (await config.getConfig()).loop.maxIterations, maxRetries = 2, } = this.opts;
|
|
24
22
|
this.resetState();
|
|
25
23
|
this._state.timestamps.start = performance.now();
|
|
26
|
-
const { systemPrompt, input,
|
|
24
|
+
const { systemPrompt, input, tools, activeTools, abortSignal } = args;
|
|
27
25
|
const langModel = modelManager.getModel("repl");
|
|
28
26
|
const modelConfig = modelManager.getModelMetadata("repl");
|
|
29
27
|
const aiConfig = new AiConfig({
|
|
@@ -63,22 +61,34 @@ export class Agent {
|
|
|
63
61
|
model: langModel,
|
|
64
62
|
maxOutputTokens: aiConfig.maxOutputTokens(),
|
|
65
63
|
system: systemPrompt,
|
|
66
|
-
messages:
|
|
64
|
+
messages: sessionManager.get(),
|
|
67
65
|
temperature: aiConfig.temperature(),
|
|
68
66
|
topP: aiConfig.topP(),
|
|
69
67
|
maxRetries: 2,
|
|
70
68
|
providerOptions: aiConfig.providerOptions(),
|
|
71
|
-
tools:
|
|
69
|
+
tools: Object.fromEntries(
|
|
70
|
+
// biome-ignore lint/suspicious/noExplicitAny: temporary
|
|
71
|
+
Object.entries(tools).map((t) => [t[0], tool(t[1].toolDef)])),
|
|
72
72
|
activeTools,
|
|
73
|
-
// biome-ignore lint/style/useNamingConvention: third-party
|
|
74
|
-
experimental_repairToolCall: toolCallRepair,
|
|
73
|
+
// biome-ignore lint/style/useNamingConvention: third-party controlled
|
|
74
|
+
experimental_repairToolCall: toolCallRepair(modelManager),
|
|
75
75
|
abortSignal,
|
|
76
76
|
onAbort: ({ steps }) => {
|
|
77
77
|
logger.debug(`Aborting and processing ${steps.length} steps`);
|
|
78
78
|
steps.forEach((step) => {
|
|
79
|
-
|
|
79
|
+
sessionManager.appendResponseMessages(step.response.messages);
|
|
80
80
|
});
|
|
81
81
|
},
|
|
82
|
+
onError({ error }) {
|
|
83
|
+
if (typeof error === "object" &&
|
|
84
|
+
error != null &&
|
|
85
|
+
"message" in error) {
|
|
86
|
+
logger.error(error.message);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
logger.error(error);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
82
92
|
});
|
|
83
93
|
let accumulatedText = "";
|
|
84
94
|
let accumulatedReasoning = "";
|
|
@@ -134,11 +144,13 @@ export class Agent {
|
|
|
134
144
|
else if (chunk.type === "tool-call") {
|
|
135
145
|
const call = chunk;
|
|
136
146
|
const toolName = call.toolName;
|
|
147
|
+
const iTool = tools[toolName];
|
|
137
148
|
yield this.processToolEvent(toolsCalled, {
|
|
138
149
|
type: "tool-call-start",
|
|
139
150
|
name: toolName,
|
|
140
151
|
toolCallId: call.toolCallId,
|
|
141
|
-
|
|
152
|
+
// biome-ignore lint/suspicious/noExplicitAny: unknown
|
|
153
|
+
msg: iTool ? iTool.display(call.input) : "",
|
|
142
154
|
args: call.input,
|
|
143
155
|
});
|
|
144
156
|
if (call.invalid) {
|
|
@@ -155,88 +167,58 @@ export class Agent {
|
|
|
155
167
|
try {
|
|
156
168
|
thisStepToolCalls.push({ toolName });
|
|
157
169
|
thisStepToolResults.push({ toolName });
|
|
158
|
-
const
|
|
159
|
-
if (!
|
|
170
|
+
const iTool = tools[toolName];
|
|
171
|
+
if (!iTool) {
|
|
160
172
|
resultOutput = `No executor for tool ${toolName}`;
|
|
161
173
|
}
|
|
162
174
|
else {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
});
|
|
169
|
-
if (isAsyncIterable(output)) {
|
|
170
|
-
const toolResultValues = [];
|
|
171
|
-
for await (const value of output) {
|
|
172
|
-
if (isToolMessage(value)) {
|
|
173
|
-
if (call.toolCallId !== value.id) {
|
|
174
|
-
logger.debug(`Tool ${call.toolName} ids don't match: ${call.toolCallId} != ${value.id}`);
|
|
175
|
-
}
|
|
176
|
-
const event = value.event;
|
|
177
|
-
switch (event) {
|
|
178
|
-
case "tool-completion":
|
|
179
|
-
yield this.processToolEvent(toolsCalled, {
|
|
180
|
-
type: "tool-call-end",
|
|
181
|
-
name: value.name,
|
|
182
|
-
toolCallId: call.toolCallId,
|
|
183
|
-
msg: value.data,
|
|
184
|
-
args: call.input,
|
|
185
|
-
});
|
|
186
|
-
break;
|
|
187
|
-
case "tool-error":
|
|
188
|
-
yield this.processToolEvent(toolsCalled, {
|
|
189
|
-
type: "tool-call-error",
|
|
190
|
-
name: value.name,
|
|
191
|
-
toolCallId: call.toolCallId,
|
|
192
|
-
msg: value.data,
|
|
193
|
-
args: call.input,
|
|
194
|
-
});
|
|
195
|
-
break;
|
|
196
|
-
case "tool-update":
|
|
197
|
-
yield this.processToolEvent(toolsCalled, {
|
|
198
|
-
type: "tool-call-update",
|
|
199
|
-
name: value.name,
|
|
200
|
-
toolCallId: call.toolCallId,
|
|
201
|
-
msg: value.data,
|
|
202
|
-
args: call.input,
|
|
203
|
-
});
|
|
204
|
-
break;
|
|
205
|
-
case "tool-init":
|
|
206
|
-
yield this.processToolEvent(toolsCalled, {
|
|
207
|
-
type: "tool-call-init",
|
|
208
|
-
name: value.name,
|
|
209
|
-
toolCallId: call.toolCallId,
|
|
210
|
-
msg: value.data,
|
|
211
|
-
args: call.input,
|
|
212
|
-
});
|
|
213
|
-
break;
|
|
214
|
-
default:
|
|
215
|
-
event;
|
|
216
|
-
logger.debug(`Unhandled tool message event: ${event}`);
|
|
217
|
-
break;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
toolResultValues.push(value);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
const finalValue = toolResultValues.length > 0
|
|
225
|
-
? toolResultValues.at(-1)
|
|
226
|
-
: undefined;
|
|
227
|
-
resultOutput = formatToolResult(finalValue);
|
|
175
|
+
// Pre-validate tool input to catch malformed JSON early
|
|
176
|
+
if (typeof call.input === "string") {
|
|
177
|
+
// If input is a string, try to validate it's proper JSON
|
|
178
|
+
try {
|
|
179
|
+
JSON.parse(call.input);
|
|
228
180
|
}
|
|
229
|
-
|
|
230
|
-
|
|
181
|
+
catch {
|
|
182
|
+
// Malformed JSON detected - emit error and skip execution
|
|
183
|
+
const errorMsg = `Invalid tool input: malformed JSON. Received: "${call.input.slice(0, 50)}${call.input.length > 50 ? "..." : ""}". Expected a JSON object.`;
|
|
231
184
|
yield this.processToolEvent(toolsCalled, {
|
|
232
|
-
type: "tool-call-
|
|
233
|
-
name:
|
|
185
|
+
type: "tool-call-error",
|
|
186
|
+
name: toolName,
|
|
234
187
|
toolCallId: call.toolCallId,
|
|
235
|
-
msg:
|
|
188
|
+
msg: errorMsg,
|
|
236
189
|
args: null,
|
|
237
190
|
});
|
|
191
|
+
continue;
|
|
238
192
|
}
|
|
239
193
|
}
|
|
194
|
+
else if (call.input === null || call.input === undefined) {
|
|
195
|
+
// Null/undefined input
|
|
196
|
+
const errorMsg = "Invalid tool input: received null/undefined. Expected a JSON object matching the schema.";
|
|
197
|
+
yield this.processToolEvent(toolsCalled, {
|
|
198
|
+
type: "tool-call-error",
|
|
199
|
+
name: toolName,
|
|
200
|
+
toolCallId: call.toolCallId,
|
|
201
|
+
msg: errorMsg,
|
|
202
|
+
args: null,
|
|
203
|
+
});
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const toolExec = iTool.execute;
|
|
207
|
+
try {
|
|
208
|
+
const output = await toolExec(call.input, {
|
|
209
|
+
toolCallId: call.toolCallId,
|
|
210
|
+
messages: sessionManager.get(),
|
|
211
|
+
abortSignal,
|
|
212
|
+
});
|
|
213
|
+
resultOutput = formatToolResult(output);
|
|
214
|
+
yield this.processToolEvent(toolsCalled, {
|
|
215
|
+
type: "tool-call-end",
|
|
216
|
+
name: call.toolName,
|
|
217
|
+
toolCallId: call.toolCallId,
|
|
218
|
+
msg: resultOutput,
|
|
219
|
+
args: call.input,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
240
222
|
catch (err) {
|
|
241
223
|
resultOutput = `Tool error: ${err instanceof Error ? err.message : String(err)}`;
|
|
242
224
|
yield this.processToolEvent(toolsCalled, {
|
|
@@ -278,21 +260,23 @@ export class Agent {
|
|
|
278
260
|
// Get response and tool calls
|
|
279
261
|
const response = await result.response;
|
|
280
262
|
const responseMessages = response.messages;
|
|
281
|
-
|
|
263
|
+
sessionManager.appendResponseMessages(responseMessages);
|
|
282
264
|
const stepUsage = await result.usage;
|
|
283
265
|
this._state.usage.inputTokens = stepUsage.inputTokens ?? 0;
|
|
284
266
|
this._state.usage.outputTokens = stepUsage.outputTokens ?? 0;
|
|
285
267
|
this._state.usage.totalTokens = stepUsage.totalTokens ?? 0;
|
|
286
|
-
this._state.usage.cachedInputTokens =
|
|
287
|
-
|
|
288
|
-
|
|
268
|
+
this._state.usage.cachedInputTokens =
|
|
269
|
+
stepUsage.inputTokenDetails.cacheReadTokens ?? 0;
|
|
270
|
+
this._state.usage.reasoningTokens =
|
|
271
|
+
stepUsage.outputTokenDetails.reasoningTokens ?? 0;
|
|
272
|
+
sessionManager.setContextWindow(stepUsage.totalTokens ?? 0);
|
|
289
273
|
this._state.totalUsage.inputTokens += stepUsage.inputTokens ?? 0;
|
|
290
274
|
this._state.totalUsage.outputTokens += stepUsage.outputTokens ?? 0;
|
|
291
275
|
this._state.totalUsage.totalTokens += stepUsage.totalTokens ?? 0;
|
|
292
276
|
this._state.totalUsage.cachedInputTokens +=
|
|
293
|
-
stepUsage.
|
|
277
|
+
stepUsage.inputTokenDetails.cacheReadTokens ?? 0;
|
|
294
278
|
this._state.totalUsage.reasoningTokens +=
|
|
295
|
-
stepUsage.reasoningTokens ?? 0;
|
|
279
|
+
stepUsage.outputTokenDetails.reasoningTokens ?? 0;
|
|
296
280
|
// If finishReason is not tool-calls, break
|
|
297
281
|
const finishReason = await result.finishReason;
|
|
298
282
|
if (finishReason !== "tool-calls") {
|
|
@@ -302,7 +286,7 @@ export class Agent {
|
|
|
302
286
|
hasEmittedTerminalEvent = true;
|
|
303
287
|
break;
|
|
304
288
|
}
|
|
305
|
-
|
|
289
|
+
sessionManager.appendToolMessages(toolMessages);
|
|
306
290
|
// Consume the rest of the team if necessary
|
|
307
291
|
// await result.consumeStream();
|
|
308
292
|
yield {
|
|
@@ -313,18 +297,29 @@ export class Agent {
|
|
|
313
297
|
}
|
|
314
298
|
catch (error) {
|
|
315
299
|
consecutiveErrors += 1;
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
300
|
+
// Handle AI SDK invalid tool input errors gracefully
|
|
301
|
+
if (InvalidToolInputError.isInstance(error)) {
|
|
302
|
+
logger.warn(error, `Invalid tool input detected - returning error to allow recovery (attempt ${consecutiveErrors}/${maxRetries + 1})`);
|
|
303
|
+
yield {
|
|
304
|
+
type: "agent-error",
|
|
305
|
+
message: `Tool input validation failed: ${error.message}. Try again with valid arguments.`,
|
|
306
|
+
};
|
|
307
|
+
// Continue loop to allow user to provide corrected input
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
logger.error(error, // Log the full error object
|
|
311
|
+
`Error on manual agent loop streamText (attempt ${consecutiveErrors}/${maxRetries + 1})`);
|
|
312
|
+
const errorMsg = error.message.length > 100
|
|
313
|
+
? `${error.message.slice(0, 100)}...`
|
|
314
|
+
: error.message;
|
|
315
|
+
yield {
|
|
316
|
+
type: "agent-error",
|
|
317
|
+
message: errorMsg,
|
|
318
|
+
};
|
|
319
|
+
if (NoOutputGeneratedError.isInstance(error)) {
|
|
320
|
+
hasEmittedTerminalEvent = true;
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
328
323
|
}
|
|
329
324
|
// Break loop if we exceed max retries
|
|
330
325
|
if (consecutiveErrors > maxRetries) {
|
|
@@ -356,7 +351,7 @@ export class Agent {
|
|
|
356
351
|
}
|
|
357
352
|
resetState() {
|
|
358
353
|
const { modelManager,
|
|
359
|
-
//
|
|
354
|
+
// sessionManager,
|
|
360
355
|
} = this.opts;
|
|
361
356
|
this._state = {
|
|
362
357
|
modelId: modelManager.getModel("repl").modelId,
|
|
@@ -367,6 +362,15 @@ export class Agent {
|
|
|
367
362
|
totalTokens: 0,
|
|
368
363
|
reasoningTokens: 0,
|
|
369
364
|
cachedInputTokens: 0,
|
|
365
|
+
inputTokenDetails: {
|
|
366
|
+
noCacheTokens: 0,
|
|
367
|
+
cacheReadTokens: 0,
|
|
368
|
+
cacheWriteTokens: 0,
|
|
369
|
+
},
|
|
370
|
+
outputTokenDetails: {
|
|
371
|
+
textTokens: 0,
|
|
372
|
+
reasoningTokens: 0,
|
|
373
|
+
},
|
|
370
374
|
},
|
|
371
375
|
totalUsage: {
|
|
372
376
|
inputTokens: 0,
|
|
@@ -374,6 +378,15 @@ export class Agent {
|
|
|
374
378
|
totalTokens: 0,
|
|
375
379
|
reasoningTokens: 0,
|
|
376
380
|
cachedInputTokens: 0,
|
|
381
|
+
inputTokenDetails: {
|
|
382
|
+
noCacheTokens: 0,
|
|
383
|
+
cacheReadTokens: 0,
|
|
384
|
+
cacheWriteTokens: 0,
|
|
385
|
+
},
|
|
386
|
+
outputTokenDetails: {
|
|
387
|
+
textTokens: 0,
|
|
388
|
+
reasoningTokens: 0,
|
|
389
|
+
},
|
|
377
390
|
},
|
|
378
391
|
steps: [],
|
|
379
392
|
timestamps: {
|
|
@@ -432,3 +445,32 @@ function formatToolResult(value) {
|
|
|
432
445
|
}
|
|
433
446
|
return String(value);
|
|
434
447
|
}
|
|
448
|
+
const toolCallRepair = (modelManager) => {
|
|
449
|
+
const fn = async ({ toolCall, tools, inputSchema, error, }) => {
|
|
450
|
+
if (NoSuchToolError.isInstance(error)) {
|
|
451
|
+
return null; // do not attempt to fix invalid tool names
|
|
452
|
+
}
|
|
453
|
+
const tool = tools[toolCall.toolName];
|
|
454
|
+
try {
|
|
455
|
+
const { output: repairedArgs } = await generateText({
|
|
456
|
+
model: modelManager.getModel("tool-repair"),
|
|
457
|
+
output: Output.object({
|
|
458
|
+
schema: tool.inputSchema,
|
|
459
|
+
}),
|
|
460
|
+
prompt: [
|
|
461
|
+
`The model tried to call the tool "${toolCall.toolName}" with the following arguments:`,
|
|
462
|
+
JSON.stringify(toolCall.input),
|
|
463
|
+
"The tool accepts the following schema:",
|
|
464
|
+
JSON.stringify(inputSchema(toolCall)),
|
|
465
|
+
"Please fix the arguments.",
|
|
466
|
+
].join("\n"),
|
|
467
|
+
});
|
|
468
|
+
return { ...toolCall, args: JSON.stringify(repairedArgs) };
|
|
469
|
+
}
|
|
470
|
+
catch (err) {
|
|
471
|
+
logger.error(err, `Failed to repair tool call: ${toolCall.toolName}.`);
|
|
472
|
+
return null;
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
return fn;
|
|
476
|
+
};
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { WorkspaceContext } from "./index.ts";
|
|
2
|
-
import type { MessageHistory } from "./messages.ts";
|
|
3
2
|
import type { ModelManager } from "./models/manager.js";
|
|
4
3
|
import type { PromptManager } from "./prompts/manager.ts";
|
|
4
|
+
import type { SessionManager } from "./sessions/manager.ts";
|
|
5
5
|
import type { TokenCounter } from "./tokens/counter.ts";
|
|
6
6
|
import type { TokenTracker } from "./tokens/tracker.ts";
|
|
7
7
|
interface CliOptions {
|
|
8
|
-
messageHistory:
|
|
8
|
+
messageHistory: SessionManager;
|
|
9
9
|
promptManager: PromptManager;
|
|
10
10
|
modelManager: ModelManager;
|
|
11
11
|
tokenTracker: TokenTracker;
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../source/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../source/cli.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQxD,UAAU,UAAU;IAClB,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,EAAE,aAAa,CAAC;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,gBAAgB,CAAC;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAUD,qBAAa,GAAG;IACd,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,aAAa,CAAU;gBACnB,OAAO,EAAE,UAAU;IAKzB,GAAG;CAuHV"}
|
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { generateText, NoSuchToolError, Output, stepCountIs, tool, } from "ai";
|
|
2
2
|
import { logger } from "./logger.js";
|
|
3
3
|
import { AiConfig } from "./models/ai-config.js";
|
|
4
4
|
import { systemPrompt } from "./prompts.js";
|
|
5
5
|
import { BashTool } from "./tools/bash.js";
|
|
6
|
-
import { CodeInterpreterTool } from "./tools/code-interpreter.js";
|
|
7
6
|
import { EditFileTool } from "./tools/edit-file.js";
|
|
8
7
|
import { GlobTool } from "./tools/glob.js";
|
|
9
8
|
import { GrepTool } from "./tools/grep.js";
|
|
10
|
-
import {
|
|
9
|
+
import { initTools } from "./tools/index.js";
|
|
11
10
|
import { ReadFileTool } from "./tools/read-file.js";
|
|
12
11
|
const activeTools = [
|
|
13
12
|
EditFileTool.name,
|
|
@@ -15,7 +14,6 @@ const activeTools = [
|
|
|
15
14
|
BashTool.name,
|
|
16
15
|
GrepTool.name,
|
|
17
16
|
GlobTool.name,
|
|
18
|
-
CodeInterpreterTool.name,
|
|
19
17
|
];
|
|
20
18
|
export class Cli {
|
|
21
19
|
options;
|
|
@@ -25,7 +23,7 @@ export class Cli {
|
|
|
25
23
|
this.skillsEnabled = options.skillsEnabled ?? true;
|
|
26
24
|
}
|
|
27
25
|
async run() {
|
|
28
|
-
const { promptManager, modelManager, tokenTracker, messageHistory
|
|
26
|
+
const { promptManager, modelManager, tokenTracker, messageHistory } = this.options;
|
|
29
27
|
const abortController = new AbortController();
|
|
30
28
|
const { signal } = abortController;
|
|
31
29
|
const cb = () => {
|
|
@@ -38,18 +36,17 @@ export class Cli {
|
|
|
38
36
|
const userPrompt = promptManager.get();
|
|
39
37
|
const userMsg = promptManager.getUserMessage();
|
|
40
38
|
messageHistory.appendUserMessage(userMsg);
|
|
41
|
-
const
|
|
42
|
-
type: "cli",
|
|
39
|
+
const finalSystemPromptResult = await systemPrompt({
|
|
43
40
|
activeTools,
|
|
44
41
|
allowedDirs: this.options.workspace.allowedDirs,
|
|
45
42
|
skillsEnabled: this.skillsEnabled,
|
|
46
43
|
});
|
|
44
|
+
const finalSystemPrompt = finalSystemPromptResult.prompt;
|
|
47
45
|
const aiConfig = new AiConfig({
|
|
48
46
|
modelMetadata: modelConfig,
|
|
49
47
|
prompt: userPrompt,
|
|
50
48
|
});
|
|
51
|
-
const tools = await
|
|
52
|
-
tokenCounter,
|
|
49
|
+
const tools = await initTools({
|
|
53
50
|
workspace: this.options.workspace,
|
|
54
51
|
});
|
|
55
52
|
// Cleanup function to remove signal handler
|
|
@@ -64,10 +61,16 @@ export class Cli {
|
|
|
64
61
|
messages: messageHistory.get(),
|
|
65
62
|
temperature: aiConfig.temperature(),
|
|
66
63
|
topP: aiConfig.topP(),
|
|
67
|
-
stopWhen: stepCountIs(
|
|
64
|
+
stopWhen: stepCountIs(200),
|
|
68
65
|
maxRetries: 2,
|
|
69
66
|
providerOptions: aiConfig.providerOptions(),
|
|
70
|
-
tools: tools.
|
|
67
|
+
tools: Object.fromEntries(Object.entries(tools).map((t) => [
|
|
68
|
+
t[0],
|
|
69
|
+
tool({
|
|
70
|
+
...t[1]["toolDef"],
|
|
71
|
+
execute: t[1]["execute"],
|
|
72
|
+
}),
|
|
73
|
+
])),
|
|
71
74
|
activeTools,
|
|
72
75
|
// biome-ignore lint/style/useNamingConvention: third-party controlled
|
|
73
76
|
experimental_repairToolCall: toolCallRepair(modelManager),
|
|
@@ -78,18 +81,19 @@ export class Cli {
|
|
|
78
81
|
}
|
|
79
82
|
// this tracks the usage of every step in the call to streamText. it's a cumulative usage.
|
|
80
83
|
tokenTracker.trackUsage("cli", result.usage);
|
|
81
|
-
messageHistory.save();
|
|
84
|
+
await messageHistory.save();
|
|
82
85
|
process.stdout.end(result.text.endsWith("\n") ? result.text : `${result.text}\n`);
|
|
83
86
|
cleanup();
|
|
84
87
|
}
|
|
85
88
|
catch (e) {
|
|
86
89
|
// Always cleanup signal handler
|
|
87
90
|
cleanup();
|
|
88
|
-
// Check if it's an abort error
|
|
89
|
-
const isAbortError = e instanceof Error &&
|
|
91
|
+
// Check if it's an abort error or if the signal was aborted
|
|
92
|
+
const isAbortError = (e instanceof Error &&
|
|
90
93
|
(e.name === "AbortError" ||
|
|
91
94
|
e.message.includes("aborted") ||
|
|
92
|
-
e.message.includes("No output generated"))
|
|
95
|
+
e.message.includes("No output generated"))) ||
|
|
96
|
+
signal.aborted;
|
|
93
97
|
if (isAbortError) {
|
|
94
98
|
logger.info("CLI execution interrupted by user");
|
|
95
99
|
// Try to save message history before exiting
|
|
@@ -121,9 +125,11 @@ const toolCallRepair = (modelManager) => {
|
|
|
121
125
|
}
|
|
122
126
|
const tool = tools[toolCall.toolName];
|
|
123
127
|
try {
|
|
124
|
-
const {
|
|
128
|
+
const { output: repairedArgs } = await generateText({
|
|
125
129
|
model: modelManager.getModel("tool-repair"),
|
|
126
|
-
|
|
130
|
+
output: Output.object({
|
|
131
|
+
schema: tool.inputSchema,
|
|
132
|
+
}),
|
|
127
133
|
prompt: [
|
|
128
134
|
`The model tried to call the tool "${toolCall.toolName}" with the following arguments:`,
|
|
129
135
|
JSON.stringify(toolCall.input),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/add-directory/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/D,eAAO,MAAM,mBAAmB,GAAI,gBAEjC,cAAc,KAAG,WAwFnB,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { Text } from "../tui/index.js";
|
|
1
|
+
import style from "../../terminal/style.js";
|
|
2
|
+
import { Text } from "../../tui/index.js";
|
|
3
|
+
import { resolveDirectoryPath, validateDirectory } from "./utils.js";
|
|
5
4
|
export const addDirectoryCommand = ({ workspace, }) => {
|
|
6
5
|
return {
|
|
7
6
|
command: "/add-directory",
|
|
@@ -18,23 +17,20 @@ export const addDirectoryCommand = ({ workspace, }) => {
|
|
|
18
17
|
return "continue";
|
|
19
18
|
}
|
|
20
19
|
try {
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
if (!stats.isDirectory()) {
|
|
20
|
+
const resolvedPath = resolveDirectoryPath(directoryPath);
|
|
21
|
+
const isValid = await validateDirectory(resolvedPath);
|
|
22
|
+
if (!isValid) {
|
|
25
23
|
container.addChild(new Text(style.red(`Path is not a directory: ${resolvedPath}`), 1, 0));
|
|
26
24
|
tui.requestRender();
|
|
27
25
|
editor.setText("");
|
|
28
26
|
return "continue";
|
|
29
27
|
}
|
|
30
|
-
// Check if directory is already in the list
|
|
31
28
|
if (workspace.allowedDirs.includes(resolvedPath)) {
|
|
32
29
|
container.addChild(new Text(style.yellow(`Directory already in allowed list: ${resolvedPath}`), 1, 0));
|
|
33
30
|
tui.requestRender();
|
|
34
31
|
editor.setText("");
|
|
35
32
|
return "continue";
|
|
36
33
|
}
|
|
37
|
-
// Add the directory to the workspace
|
|
38
34
|
workspace.allowedDirs.push(resolvedPath);
|
|
39
35
|
container.addChild(new Text(`Added directory to allowed list: ${style.blue(resolvedPath)}`, 1, 0));
|
|
40
36
|
container.addChild(new Text(`Current allowed directories: ${style.blue(workspace.allowedDirs.join(", "))}`, 2, 0));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../source/commands/add-directory/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,gBAAgB,CAAC;CAC7B;AAED,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../source/commands/add-directory/utils.ts"],"names":[],"mappings":"AAGA,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQzE;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5D"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
export async function validateDirectory(dirPath) {
|
|
4
|
+
try {
|
|
5
|
+
const resolvedPath = path.resolve(dirPath);
|
|
6
|
+
const stats = await fs.stat(resolvedPath);
|
|
7
|
+
return stats.isDirectory();
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function resolveDirectoryPath(dirPath) {
|
|
14
|
+
return path.resolve(dirPath);
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/clear/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/D,eAAO,MAAM,YAAY,GAAI,UAAU,cAAc,KAAG,WAmBvD,CAAC"}
|
|
@@ -4,8 +4,6 @@ export const clearCommand = (_options) => {
|
|
|
4
4
|
description: "Clears the terminal screen.",
|
|
5
5
|
getSubCommands: () => Promise.resolve([]),
|
|
6
6
|
async handle(_args, { tui, container, editor, }) {
|
|
7
|
-
// In TUI mode, we can't clear the screen like terminal.clear()
|
|
8
|
-
// Instead, we'll just clear the input and show a message
|
|
9
7
|
container.clear();
|
|
10
8
|
tui.requestRender();
|
|
11
9
|
editor.setText("");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/copy/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/D,wBAAgB,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG,WAAW,CAmDhE"}
|