@travisennis/acai 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +229 -8
- package/dist/agent/index.d.ts +119 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +406 -0
- package/dist/agent/manual-loop.d.ts +41 -0
- package/dist/agent/manual-loop.d.ts.map +1 -0
- package/dist/agent/manual-loop.js +278 -0
- package/dist/api/exa/index.d.ts +177 -0
- package/dist/api/exa/index.d.ts.map +1 -0
- package/dist/api/exa/index.js +439 -0
- package/dist/cli.d.ts +5 -2
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +27 -33
- package/dist/commands/add-directory-command.d.ts +3 -0
- package/dist/commands/add-directory-command.d.ts.map +1 -0
- package/dist/commands/add-directory-command.js +85 -0
- package/dist/commands/application-log-command.d.ts +1 -0
- package/dist/commands/application-log-command.d.ts.map +1 -0
- package/dist/commands/application-log-command.js +39 -3
- package/dist/commands/clear-command.d.ts +1 -0
- package/dist/commands/clear-command.d.ts.map +1 -0
- package/dist/commands/clear-command.js +10 -3
- package/dist/commands/compact-command.d.ts +1 -0
- package/dist/commands/compact-command.d.ts.map +1 -0
- package/dist/commands/compact-command.js +16 -3
- package/dist/commands/context-command.d.ts +3 -0
- package/dist/commands/context-command.d.ts.map +1 -0
- package/dist/commands/context-command.js +183 -0
- package/dist/commands/copy-command.d.ts +1 -0
- package/dist/commands/copy-command.d.ts.map +1 -0
- package/dist/commands/copy-command.js +31 -2
- package/dist/commands/edit-command.d.ts +1 -0
- package/dist/commands/edit-command.d.ts.map +1 -0
- package/dist/commands/edit-command.js +40 -5
- package/dist/commands/edit-prompt-command.d.ts +2 -1
- package/dist/commands/edit-prompt-command.d.ts.map +1 -0
- package/dist/commands/edit-prompt-command.js +43 -7
- package/dist/commands/exit-command.d.ts +13 -2
- package/dist/commands/exit-command.d.ts.map +1 -0
- package/dist/commands/exit-command.js +34 -2
- package/dist/commands/files-command.d.ts +1 -0
- package/dist/commands/files-command.d.ts.map +1 -0
- package/dist/commands/files-command.js +66 -8
- package/dist/commands/generate-rules-command.d.ts +1 -0
- package/dist/commands/generate-rules-command.d.ts.map +1 -0
- package/dist/commands/generate-rules-command.js +315 -4
- package/dist/commands/handoff-command.d.ts +3 -0
- package/dist/commands/handoff-command.d.ts.map +1 -0
- package/dist/commands/handoff-command.js +202 -0
- package/dist/commands/health-command.d.ts +3 -1
- package/dist/commands/health-command.d.ts.map +1 -0
- package/dist/commands/health-command.js +160 -6
- package/dist/commands/help-command.d.ts +1 -0
- package/dist/commands/help-command.d.ts.map +1 -0
- package/dist/commands/help-command.js +30 -3
- package/dist/commands/history-command.d.ts +3 -0
- package/dist/commands/history-command.d.ts.map +1 -0
- package/dist/commands/history-command.js +534 -0
- package/dist/commands/init-command.d.ts +2 -1
- package/dist/commands/init-command.d.ts.map +1 -0
- package/dist/commands/init-command.js +56 -20
- package/dist/commands/last-log-command.d.ts +1 -0
- package/dist/commands/last-log-command.d.ts.map +1 -0
- package/dist/commands/last-log-command.js +39 -17
- package/dist/commands/list-directories-command.d.ts +3 -0
- package/dist/commands/list-directories-command.d.ts.map +1 -0
- package/dist/commands/list-directories-command.js +48 -0
- package/dist/commands/list-tools-command.d.ts +3 -0
- package/dist/commands/list-tools-command.d.ts.map +1 -0
- package/dist/commands/list-tools-command.js +124 -0
- package/dist/commands/manager.d.ts +20 -3
- package/dist/commands/manager.d.ts.map +1 -0
- package/dist/commands/manager.js +123 -26
- package/dist/commands/model-command.d.ts +23 -0
- package/dist/commands/model-command.d.ts.map +1 -0
- package/dist/commands/model-command.js +261 -5
- package/dist/commands/paste-command.d.ts +1 -0
- package/dist/commands/paste-command.d.ts.map +1 -0
- package/dist/commands/paste-command.js +98 -5
- package/dist/commands/pickup-command.d.ts +3 -0
- package/dist/commands/pickup-command.d.ts.map +1 -0
- package/dist/commands/pickup-command.js +161 -0
- package/dist/commands/prompt-command.d.ts +2 -1
- package/dist/commands/prompt-command.d.ts.map +1 -0
- package/dist/commands/prompt-command.js +178 -9
- package/dist/commands/remove-directory-command.d.ts +3 -0
- package/dist/commands/remove-directory-command.d.ts.map +1 -0
- package/dist/commands/remove-directory-command.js +87 -0
- package/dist/commands/reset-command.d.ts +2 -1
- package/dist/commands/reset-command.d.ts.map +1 -0
- package/dist/commands/reset-command.js +14 -3
- package/dist/commands/rules-command.d.ts +1 -0
- package/dist/commands/rules-command.d.ts.map +1 -0
- package/dist/commands/rules-command.js +70 -3
- package/dist/commands/save-command.d.ts +1 -0
- package/dist/commands/save-command.d.ts.map +1 -0
- package/dist/commands/save-command.js +13 -1
- package/dist/commands/shell-command.d.ts +3 -0
- package/dist/commands/shell-command.d.ts.map +1 -0
- package/dist/commands/shell-command.js +128 -0
- package/dist/commands/types.d.ts +16 -8
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/usage-command.d.ts +1 -0
- package/dist/commands/usage-command.d.ts.map +1 -0
- package/dist/commands/usage-command.js +24 -3
- package/dist/config.d.ts +21 -34
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +55 -15
- package/dist/dedent.d.ts +1 -0
- package/dist/dedent.d.ts.map +1 -0
- package/dist/execution/index.d.ts +112 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +432 -0
- package/dist/formatting.d.ts +107 -10
- package/dist/formatting.d.ts.map +1 -0
- package/dist/formatting.js +150 -62
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +150 -38
- package/dist/logger.d.ts +1 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +47 -18
- package/dist/mentions.d.ts +6 -1
- package/dist/mentions.d.ts.map +1 -0
- package/dist/mentions.js +58 -11
- package/dist/messages.d.ts +16 -20
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +89 -72
- package/dist/middleware/audit-message.d.ts +1 -0
- package/dist/middleware/audit-message.d.ts.map +1 -0
- package/dist/middleware/cache.d.ts +3 -0
- package/dist/middleware/cache.d.ts.map +1 -0
- package/dist/middleware/cache.js +53 -0
- package/dist/middleware/index.d.ts +2 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +1 -0
- package/dist/middleware/rate-limit.d.ts +1 -0
- package/dist/middleware/rate-limit.d.ts.map +1 -0
- package/dist/models/ai-config.d.ts +5 -2
- package/dist/models/ai-config.d.ts.map +1 -0
- package/dist/models/ai-config.js +12 -2
- package/dist/models/anthropic-provider.d.ts +1 -0
- package/dist/models/anthropic-provider.d.ts.map +1 -0
- package/dist/models/anthropic-provider.js +3 -60
- package/dist/models/deepseek-provider.d.ts +1 -0
- package/dist/models/deepseek-provider.d.ts.map +1 -0
- package/dist/models/google-provider.d.ts +1 -0
- package/dist/models/google-provider.d.ts.map +1 -0
- package/dist/models/groq-provider.d.ts +20 -0
- package/dist/models/groq-provider.d.ts.map +1 -0
- package/dist/models/groq-provider.js +31 -0
- package/dist/models/manager.d.ts +3 -1
- package/dist/models/manager.d.ts.map +1 -0
- package/dist/models/manager.js +26 -2
- package/dist/models/openai-provider.d.ts +2 -1
- package/dist/models/openai-provider.d.ts.map +1 -0
- package/dist/models/openrouter-provider.d.ts +25 -23
- package/dist/models/openrouter-provider.d.ts.map +1 -0
- package/dist/models/openrouter-provider.js +181 -122
- package/dist/models/providers.d.ts +4 -5
- package/dist/models/providers.d.ts.map +1 -0
- package/dist/models/providers.js +7 -3
- package/dist/models/xai-provider.d.ts +1 -0
- package/dist/models/xai-provider.d.ts.map +1 -0
- package/dist/parsing.d.ts +2 -1
- package/dist/parsing.d.ts.map +1 -0
- package/dist/prompts/manager.d.ts +14 -2
- package/dist/prompts/manager.d.ts.map +1 -0
- package/dist/prompts.d.ts +2 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +65 -12
- package/dist/repl/display-tool-messages.d.ts +4 -0
- package/dist/repl/display-tool-messages.d.ts.map +1 -0
- package/dist/repl/display-tool-messages.js +58 -0
- package/dist/repl/display-tool-use.d.ts +14 -0
- package/dist/repl/display-tool-use.d.ts.map +1 -0
- package/dist/repl/display-tool-use.js +63 -0
- package/dist/repl/get-prompt-header.d.ts +8 -0
- package/dist/repl/get-prompt-header.d.ts.map +1 -0
- package/dist/repl/get-prompt-header.js +9 -0
- package/dist/repl/project-status-line.d.ts +2 -0
- package/dist/repl/project-status-line.d.ts.map +1 -0
- package/dist/repl/project-status-line.js +31 -0
- package/dist/repl/prompt.d.ts +21 -0
- package/dist/repl/prompt.d.ts.map +1 -0
- package/dist/{repl-prompt.js → repl/prompt.js} +119 -22
- package/dist/repl/tool-call-repair.d.ts +4 -0
- package/dist/repl/tool-call-repair.d.ts.map +1 -0
- package/dist/repl/tool-call-repair.js +54 -0
- package/dist/repl-new.d.ts +53 -0
- package/dist/repl-new.d.ts.map +1 -0
- package/dist/repl-new.js +374 -0
- package/dist/repl.d.ts +9 -7
- package/dist/repl.d.ts.map +1 -0
- package/dist/repl.js +142 -378
- package/dist/terminal/ansi-styles.d.ts +77 -0
- package/dist/terminal/ansi-styles.d.ts.map +1 -0
- package/dist/terminal/ansi-styles.js +215 -0
- package/dist/terminal/checkbox-prompt.d.ts +36 -0
- package/dist/terminal/checkbox-prompt.d.ts.map +1 -0
- package/dist/terminal/checkbox-prompt.js +368 -0
- package/dist/terminal/default-theme.d.ts +6 -0
- package/dist/terminal/default-theme.d.ts.map +1 -0
- package/dist/terminal/default-theme.js +182 -0
- package/dist/terminal/east-asian-width.d.ts +8 -0
- package/dist/terminal/east-asian-width.d.ts.map +1 -0
- package/dist/terminal/east-asian-width.js +409 -0
- package/dist/terminal/editor-prompt.d.ts +10 -0
- package/dist/terminal/editor-prompt.d.ts.map +1 -0
- package/dist/terminal/editor-prompt.js +61 -0
- package/dist/terminal/errors.d.ts +19 -0
- package/dist/terminal/errors.d.ts.map +1 -0
- package/dist/terminal/errors.js +37 -0
- package/dist/terminal/formatting.d.ts +1 -11
- package/dist/terminal/formatting.d.ts.map +1 -0
- package/dist/terminal/formatting.js +4 -20
- package/dist/terminal/highlight/index.d.ts +53 -0
- package/dist/terminal/highlight/index.d.ts.map +1 -0
- package/dist/terminal/highlight/index.js +90 -0
- package/dist/terminal/highlight/theme.d.ts +233 -0
- package/dist/terminal/highlight/theme.d.ts.map +1 -0
- package/dist/terminal/highlight/theme.js +83 -0
- package/dist/terminal/index.d.ts +23 -9
- package/dist/terminal/index.d.ts.map +1 -0
- package/dist/terminal/index.js +136 -126
- package/dist/terminal/input-prompt.d.ts +17 -0
- package/dist/terminal/input-prompt.d.ts.map +1 -0
- package/dist/terminal/input-prompt.js +181 -0
- package/dist/terminal/markdown-utils.d.ts +1 -0
- package/dist/terminal/markdown-utils.d.ts.map +1 -0
- package/dist/terminal/markdown.d.ts +1 -0
- package/dist/terminal/markdown.d.ts.map +1 -0
- package/dist/terminal/markdown.js +20 -12
- package/dist/terminal/search-prompt.d.ts +20 -0
- package/dist/terminal/search-prompt.d.ts.map +1 -0
- package/dist/terminal/search-prompt.js +280 -0
- package/dist/terminal/select-prompt.d.ts +26 -0
- package/dist/terminal/select-prompt.d.ts.map +1 -0
- package/dist/terminal/select-prompt.js +306 -0
- package/dist/terminal/string-width.d.ts +7 -0
- package/dist/terminal/string-width.d.ts.map +1 -0
- package/dist/terminal/string-width.js +61 -0
- package/dist/terminal/strip-ansi.d.ts +2 -0
- package/dist/terminal/strip-ansi.d.ts.map +1 -0
- package/dist/terminal/strip-ansi.js +20 -0
- package/dist/terminal/style.d.ts +191 -0
- package/dist/terminal/style.d.ts.map +1 -0
- package/dist/terminal/style.js +259 -0
- package/dist/terminal/supports-color.d.ts +1 -0
- package/dist/terminal/supports-color.d.ts.map +1 -0
- package/dist/terminal/supports-hyperlinks.d.ts +1 -3
- package/dist/terminal/supports-hyperlinks.d.ts.map +1 -0
- package/dist/terminal/supports-hyperlinks.js +1 -1
- package/dist/terminal/types.d.ts +1 -37
- package/dist/terminal/types.d.ts.map +1 -0
- package/dist/terminal/wrap-ansi.d.ts +8 -0
- package/dist/terminal/wrap-ansi.d.ts.map +1 -0
- package/dist/terminal/wrap-ansi.js +190 -0
- package/dist/{token-utils.d.ts → tokens/counter.d.ts} +1 -0
- package/dist/tokens/counter.d.ts.map +1 -0
- package/dist/{token-utils.js → tokens/counter.js} +1 -1
- package/dist/tokens/threshold.d.ts +35 -0
- package/dist/tokens/threshold.d.ts.map +1 -0
- package/dist/tokens/threshold.js +85 -0
- package/dist/{token-tracker.d.ts → tokens/tracker.d.ts} +1 -0
- package/dist/tokens/tracker.d.ts.map +1 -0
- package/dist/tools/advanced-edit-file.d.ts +69 -0
- package/dist/tools/advanced-edit-file.d.ts.map +1 -0
- package/dist/tools/advanced-edit-file.js +281 -0
- package/dist/tools/agent.d.ts +19 -7
- package/dist/tools/agent.d.ts.map +1 -0
- package/dist/tools/agent.js +70 -54
- package/dist/tools/bash-utils.d.ts +7 -0
- package/dist/tools/bash-utils.d.ts.map +1 -0
- package/dist/tools/bash-utils.js +220 -0
- package/dist/tools/bash.d.ts +25 -14
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +87 -251
- package/dist/tools/code-interpreter.d.ts +22 -10
- package/dist/tools/code-interpreter.d.ts.map +1 -0
- package/dist/tools/code-interpreter.js +146 -210
- package/dist/tools/delete-file.d.ts +18 -9
- package/dist/tools/delete-file.d.ts.map +1 -0
- package/dist/tools/delete-file.js +55 -85
- package/dist/tools/directory-tree.d.ts +26 -6
- package/dist/tools/directory-tree.d.ts.map +1 -0
- package/dist/tools/directory-tree.js +109 -28
- package/dist/tools/dynamic-tool-loader.d.ts +22 -0
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -0
- package/dist/tools/dynamic-tool-loader.js +272 -0
- package/dist/tools/dynamic-tool-parser.d.ts +21 -0
- package/dist/tools/dynamic-tool-parser.d.ts.map +1 -0
- package/dist/tools/dynamic-tool-parser.js +22 -0
- package/dist/tools/edit-file.d.ts +41 -13
- package/dist/tools/edit-file.d.ts.map +1 -0
- package/dist/tools/edit-file.js +173 -96
- package/dist/tools/filesystem-utils.d.ts +7 -21
- package/dist/tools/filesystem-utils.d.ts.map +1 -0
- package/dist/tools/filesystem-utils.js +111 -149
- package/dist/tools/git-utils.d.ts +1 -0
- package/dist/tools/git-utils.d.ts.map +1 -0
- package/dist/tools/glob.d.ts +36 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +143 -0
- package/dist/tools/grep.d.ts +76 -13
- package/dist/tools/grep.d.ts.map +1 -0
- package/dist/tools/grep.js +420 -135
- package/dist/tools/index.d.ts +207 -133
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +245 -127
- package/dist/tools/llm-edit-fixer.d.ts +25 -0
- package/dist/tools/llm-edit-fixer.d.ts.map +1 -0
- package/dist/tools/llm-edit-fixer.js +150 -0
- package/dist/tools/move-file.d.ts +20 -7
- package/dist/tools/move-file.d.ts.map +1 -0
- package/dist/tools/move-file.js +43 -29
- package/dist/tools/read-file.d.ts +49 -10
- package/dist/tools/read-file.d.ts.map +1 -0
- package/dist/tools/read-file.js +79 -67
- package/dist/tools/read-multiple-files.d.ts +19 -7
- package/dist/tools/read-multiple-files.d.ts.map +1 -0
- package/dist/tools/read-multiple-files.js +117 -33
- package/dist/tools/save-file.d.ts +46 -11
- package/dist/tools/save-file.d.ts.map +1 -0
- package/dist/tools/save-file.js +63 -78
- package/dist/tools/think.d.ts +16 -7
- package/dist/tools/think.d.ts.map +1 -0
- package/dist/tools/think.js +34 -22
- package/dist/tools/types.d.ts +18 -11
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +9 -0
- package/dist/tools/utils.d.ts +14 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +16 -0
- package/dist/tools/web-fetch.d.ts +15 -6
- package/dist/tools/web-fetch.d.ts.map +1 -0
- package/dist/tools/web-fetch.js +40 -39
- package/dist/tools/web-search.d.ts +17 -7
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +86 -33
- package/dist/tui/autocomplete.d.ts +44 -0
- package/dist/tui/autocomplete.d.ts.map +1 -0
- package/dist/tui/autocomplete.js +466 -0
- package/dist/tui/components/assistant-message.d.ts +18 -0
- package/dist/tui/components/assistant-message.d.ts.map +1 -0
- package/dist/tui/components/assistant-message.js +29 -0
- package/dist/tui/components/editor.d.ts +51 -0
- package/dist/tui/components/editor.d.ts.map +1 -0
- package/dist/tui/components/editor.js +758 -0
- package/dist/tui/components/footer.d.ts +24 -0
- package/dist/tui/components/footer.d.ts.map +1 -0
- package/dist/tui/components/footer.js +197 -0
- package/dist/tui/components/input.d.ts +14 -0
- package/dist/tui/components/input.d.ts.map +1 -0
- package/dist/tui/components/input.js +122 -0
- package/dist/tui/components/loader.d.ts +19 -0
- package/dist/tui/components/loader.d.ts.map +1 -0
- package/dist/tui/components/loader.js +45 -0
- package/dist/tui/components/markdown.d.ts +103 -0
- package/dist/tui/components/markdown.d.ts.map +1 -0
- package/dist/tui/components/markdown.js +533 -0
- package/dist/tui/components/modal.d.ts +40 -0
- package/dist/tui/components/modal.d.ts.map +1 -0
- package/dist/tui/components/modal.js +292 -0
- package/dist/tui/components/prompt-status.d.ts +16 -0
- package/dist/tui/components/prompt-status.d.ts.map +1 -0
- package/dist/tui/components/prompt-status.js +21 -0
- package/dist/tui/components/select-list.d.ts +22 -0
- package/dist/tui/components/select-list.d.ts.map +1 -0
- package/dist/tui/components/select-list.js +143 -0
- package/dist/tui/components/spacer.d.ts +16 -0
- package/dist/tui/components/spacer.d.ts.map +1 -0
- package/dist/tui/components/spacer.js +27 -0
- package/dist/tui/components/text.d.ts +26 -0
- package/dist/tui/components/text.d.ts.map +1 -0
- package/dist/tui/components/text.js +143 -0
- package/dist/tui/components/thinking-block.d.ts +14 -0
- package/dist/tui/components/thinking-block.d.ts.map +1 -0
- package/dist/tui/components/thinking-block.js +30 -0
- package/dist/tui/components/tool-execution.d.ts +17 -0
- package/dist/tui/components/tool-execution.d.ts.map +1 -0
- package/dist/tui/components/tool-execution.js +153 -0
- package/dist/tui/components/user-message.d.ts +9 -0
- package/dist/tui/components/user-message.d.ts.map +1 -0
- package/dist/tui/components/user-message.js +21 -0
- package/dist/tui/components/welcome.d.ts +6 -0
- package/dist/tui/components/welcome.d.ts.map +1 -0
- package/dist/tui/components/welcome.js +30 -0
- package/dist/tui/index.d.ts +14 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +18 -0
- package/dist/tui/terminal.d.ts +37 -0
- package/dist/tui/terminal.d.ts.map +1 -0
- package/dist/tui/terminal.js +104 -0
- package/dist/tui/tui.d.ts +67 -0
- package/dist/tui/tui.d.ts.map +1 -0
- package/dist/tui/tui.js +184 -0
- package/dist/tui/utils.d.ts +19 -0
- package/dist/tui/utils.d.ts.map +1 -0
- package/dist/tui/utils.js +31 -0
- package/dist/utils/filesystem.d.ts +23 -0
- package/dist/utils/filesystem.d.ts.map +1 -0
- package/dist/utils/filesystem.js +140 -0
- package/dist/utils/filetype-detection.d.ts +3 -0
- package/dist/utils/filetype-detection.d.ts.map +1 -0
- package/dist/utils/filetype-detection.js +112 -0
- package/dist/utils/generators.d.ts +3 -0
- package/dist/utils/generators.d.ts.map +1 -0
- package/dist/utils/generators.js +25 -0
- package/dist/utils/glob.d.ts +52 -0
- package/dist/utils/glob.d.ts.map +1 -0
- package/dist/utils/glob.js +376 -0
- package/dist/utils/ignore.d.ts +104 -0
- package/dist/utils/ignore.d.ts.map +1 -0
- package/dist/utils/ignore.js +649 -0
- package/dist/utils/iterables.d.ts +2 -0
- package/dist/utils/iterables.d.ts.map +1 -0
- package/dist/utils/iterables.js +6 -0
- package/dist/utils/process.d.ts +3 -2
- package/dist/utils/process.d.ts.map +1 -0
- package/dist/utils/process.js +17 -2
- package/dist/utils/zod-utils.d.ts +4 -0
- package/dist/utils/zod-utils.d.ts.map +1 -0
- package/dist/utils/zod-utils.js +7 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +34 -32
- package/dist/conversation-analyzer.d.ts +0 -10
- package/dist/conversation-analyzer.js +0 -88
- package/dist/repl-prompt.d.ts +0 -14
- package/dist/tools/command-validation.d.ts +0 -11
- package/dist/tools/command-validation.js +0 -45
- /package/dist/{token-tracker.js → tokens/tracker.js} +0 -0
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import { isZodSchema, zodToJsonSchema } from "../../utils/zod-utils.js";
|
|
2
|
+
// Prefer global fetch/Headers from Node >= 18
|
|
3
|
+
const fetchImpl = globalThis.fetch;
|
|
4
|
+
const HeadersImpl = globalThis.Headers;
|
|
5
|
+
/**
|
|
6
|
+
* HTTP status codes
|
|
7
|
+
*/
|
|
8
|
+
const HttpStatusCode = {
|
|
9
|
+
badRequest: 400,
|
|
10
|
+
notFound: 404,
|
|
11
|
+
unauthorized: 401,
|
|
12
|
+
forbidden: 403,
|
|
13
|
+
tooManyRequests: 429,
|
|
14
|
+
requestTimeout: 408,
|
|
15
|
+
internalServerError: 500,
|
|
16
|
+
serviceUnavailable: 503,
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Base error class for all Exa API errors
|
|
20
|
+
*/
|
|
21
|
+
class ExaError extends Error {
|
|
22
|
+
statusCode;
|
|
23
|
+
timestamp;
|
|
24
|
+
path;
|
|
25
|
+
constructor(message, statusCode, timestamp, path) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.name = "ExaError";
|
|
28
|
+
this.statusCode = statusCode;
|
|
29
|
+
this.timestamp = timestamp ?? new Date().toISOString();
|
|
30
|
+
this.path = path;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export default class Exa {
|
|
34
|
+
baseUrl;
|
|
35
|
+
headers;
|
|
36
|
+
constructor(apiKey, baseUrl = "https://api.exa.ai") {
|
|
37
|
+
this.baseUrl = baseUrl;
|
|
38
|
+
let resolvedKey = apiKey;
|
|
39
|
+
if (!resolvedKey) {
|
|
40
|
+
resolvedKey = process.env["EXA_API_KEY"];
|
|
41
|
+
if (!resolvedKey) {
|
|
42
|
+
throw new ExaError("API key must be provided as an argument or as an environment variable (EXA_API_KEY)", HttpStatusCode.unauthorized);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Build base headers
|
|
46
|
+
const headers = new HeadersImpl();
|
|
47
|
+
headers.set("x-api-key", resolvedKey);
|
|
48
|
+
headers.set("Content-Type", "application/json");
|
|
49
|
+
headers.set("User-Agent", "acai-exa");
|
|
50
|
+
// Store as a simple record for easier merging and type safety in this codebase
|
|
51
|
+
const headerRecord = {};
|
|
52
|
+
headers.forEach((value, key) => {
|
|
53
|
+
headerRecord[key] = value;
|
|
54
|
+
});
|
|
55
|
+
this.headers = headerRecord;
|
|
56
|
+
}
|
|
57
|
+
extractContentsOptions(options) {
|
|
58
|
+
const { text, highlights, summary, subpages, subpageTarget, extras, livecrawl, livecrawlTimeout, context, ...rest } = options;
|
|
59
|
+
const contentsOptions = {};
|
|
60
|
+
if (text === undefined &&
|
|
61
|
+
summary === undefined &&
|
|
62
|
+
highlights === undefined &&
|
|
63
|
+
extras === undefined) {
|
|
64
|
+
contentsOptions.text = true;
|
|
65
|
+
}
|
|
66
|
+
if (text !== undefined)
|
|
67
|
+
contentsOptions.text = text;
|
|
68
|
+
if (summary !== undefined) {
|
|
69
|
+
if (typeof summary === "object" &&
|
|
70
|
+
summary !== null &&
|
|
71
|
+
"schema" in summary &&
|
|
72
|
+
summary.schema &&
|
|
73
|
+
isZodSchema(summary.schema)) {
|
|
74
|
+
const { schema, ...restSummary } = summary;
|
|
75
|
+
contentsOptions.summary = {
|
|
76
|
+
...restSummary,
|
|
77
|
+
schema: zodToJsonSchema(schema),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
contentsOptions.summary = summary;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (highlights !== undefined)
|
|
85
|
+
contentsOptions.highlights = highlights;
|
|
86
|
+
if (subpages !== undefined)
|
|
87
|
+
contentsOptions.subpages = subpages;
|
|
88
|
+
if (subpageTarget !== undefined)
|
|
89
|
+
contentsOptions.subpageTarget = subpageTarget;
|
|
90
|
+
if (extras !== undefined)
|
|
91
|
+
contentsOptions.extras = extras;
|
|
92
|
+
if (livecrawl !== undefined)
|
|
93
|
+
contentsOptions.livecrawl = livecrawl;
|
|
94
|
+
if (livecrawlTimeout !== undefined)
|
|
95
|
+
contentsOptions.livecrawlTimeout = livecrawlTimeout;
|
|
96
|
+
if (context !== undefined)
|
|
97
|
+
contentsOptions.context = context;
|
|
98
|
+
return {
|
|
99
|
+
contentsOptions,
|
|
100
|
+
restOptions: rest,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
async request(endpoint, method, body, params, headers) {
|
|
104
|
+
if (!fetchImpl) {
|
|
105
|
+
throw new ExaError("Global fetch is not available in this environment.", HttpStatusCode.internalServerError);
|
|
106
|
+
}
|
|
107
|
+
let url = this.baseUrl + endpoint;
|
|
108
|
+
if (params && Object.keys(params).length > 0) {
|
|
109
|
+
const searchParams = new URLSearchParams();
|
|
110
|
+
for (const [key, value] of Object.entries(params)) {
|
|
111
|
+
if (Array.isArray(value)) {
|
|
112
|
+
for (const item of value) {
|
|
113
|
+
searchParams.append(key, String(item));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else if (value !== undefined && value !== null) {
|
|
117
|
+
searchParams.append(key, String(value));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
url += `?${searchParams.toString()}`;
|
|
121
|
+
}
|
|
122
|
+
const combinedHeaders = {
|
|
123
|
+
...this.headers,
|
|
124
|
+
...(headers ?? {}),
|
|
125
|
+
};
|
|
126
|
+
const response = await fetchImpl(url, {
|
|
127
|
+
method,
|
|
128
|
+
headers: combinedHeaders,
|
|
129
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
130
|
+
});
|
|
131
|
+
if (!response.ok) {
|
|
132
|
+
let errorMessage = `HTTP ${response.status}`;
|
|
133
|
+
let errorTimestamp;
|
|
134
|
+
let errorPath = endpoint;
|
|
135
|
+
try {
|
|
136
|
+
const errorData = await response.json();
|
|
137
|
+
const message = (errorData &&
|
|
138
|
+
(errorData.error || errorData.message));
|
|
139
|
+
if (typeof message === "string" && message.length > 0) {
|
|
140
|
+
errorMessage = message;
|
|
141
|
+
}
|
|
142
|
+
errorTimestamp =
|
|
143
|
+
(errorData && errorData.timestamp) ??
|
|
144
|
+
new Date().toISOString();
|
|
145
|
+
errorPath =
|
|
146
|
+
(errorData && errorData.path) ?? endpoint;
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
// ignore body parse errors
|
|
150
|
+
}
|
|
151
|
+
throw new ExaError(errorMessage, response.status, errorTimestamp, errorPath);
|
|
152
|
+
}
|
|
153
|
+
const contentType = response.headers.get("content-type") || "";
|
|
154
|
+
if (contentType.includes("text/event-stream")) {
|
|
155
|
+
return (await this.parseSseStream(response));
|
|
156
|
+
}
|
|
157
|
+
return (await response.json());
|
|
158
|
+
}
|
|
159
|
+
async rawRequest(endpoint, method = "POST", body, queryParams) {
|
|
160
|
+
if (!fetchImpl) {
|
|
161
|
+
throw new ExaError("Global fetch is not available in this environment.", HttpStatusCode.internalServerError);
|
|
162
|
+
}
|
|
163
|
+
let url = this.baseUrl + endpoint;
|
|
164
|
+
if (queryParams) {
|
|
165
|
+
const searchParams = new URLSearchParams();
|
|
166
|
+
for (const [key, value] of Object.entries(queryParams)) {
|
|
167
|
+
if (Array.isArray(value)) {
|
|
168
|
+
for (const item of value) {
|
|
169
|
+
searchParams.append(key, String(item));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else if (value !== undefined && value !== null) {
|
|
173
|
+
searchParams.append(key, String(value));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
url += `?${searchParams.toString()}`;
|
|
177
|
+
}
|
|
178
|
+
const response = await fetchImpl(url, {
|
|
179
|
+
method,
|
|
180
|
+
headers: this.headers,
|
|
181
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
182
|
+
});
|
|
183
|
+
return response;
|
|
184
|
+
}
|
|
185
|
+
async search(query, options) {
|
|
186
|
+
return await this.request("/search", "POST", { query, ...options });
|
|
187
|
+
}
|
|
188
|
+
async searchAndContents(query, options) {
|
|
189
|
+
const { contentsOptions, restOptions } = options === undefined
|
|
190
|
+
? {
|
|
191
|
+
contentsOptions: { text: true },
|
|
192
|
+
restOptions: {},
|
|
193
|
+
}
|
|
194
|
+
: this.extractContentsOptions(options);
|
|
195
|
+
return await this.request("/search", "POST", {
|
|
196
|
+
query,
|
|
197
|
+
contents: contentsOptions,
|
|
198
|
+
...restOptions,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
async findSimilar(url, options) {
|
|
202
|
+
return await this.request("/findSimilar", "POST", { url, ...options });
|
|
203
|
+
}
|
|
204
|
+
async findSimilarAndContents(url, options) {
|
|
205
|
+
const { contentsOptions, restOptions } = options === undefined
|
|
206
|
+
? {
|
|
207
|
+
contentsOptions: { text: true },
|
|
208
|
+
restOptions: {},
|
|
209
|
+
}
|
|
210
|
+
: this.extractContentsOptions(options);
|
|
211
|
+
return await this.request("/findSimilar", "POST", {
|
|
212
|
+
url,
|
|
213
|
+
contents: contentsOptions,
|
|
214
|
+
...restOptions,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
async getContents(urls, options) {
|
|
218
|
+
if (!urls || (Array.isArray(urls) && urls.length === 0)) {
|
|
219
|
+
throw new ExaError("Must provide at least one URL", HttpStatusCode.badRequest);
|
|
220
|
+
}
|
|
221
|
+
let requestUrls;
|
|
222
|
+
if (typeof urls === "string") {
|
|
223
|
+
requestUrls = [urls];
|
|
224
|
+
}
|
|
225
|
+
else if (Array.isArray(urls) && typeof urls[0] === "string") {
|
|
226
|
+
requestUrls = urls;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
requestUrls = urls.map((result) => result.url);
|
|
230
|
+
}
|
|
231
|
+
const payload = {
|
|
232
|
+
urls: requestUrls,
|
|
233
|
+
...(options ?? {}),
|
|
234
|
+
};
|
|
235
|
+
return await this.request("/contents", "POST", payload);
|
|
236
|
+
}
|
|
237
|
+
async answer(query, options) {
|
|
238
|
+
if (options?.stream) {
|
|
239
|
+
throw new ExaError("For streaming responses, please use streamAnswer() instead:\n\n" +
|
|
240
|
+
"for await (const chunk of exa.streamAnswer(query)) {\n" +
|
|
241
|
+
" // Handle chunks\n" +
|
|
242
|
+
"}", HttpStatusCode.badRequest);
|
|
243
|
+
}
|
|
244
|
+
let outputSchema = options
|
|
245
|
+
?.outputSchema;
|
|
246
|
+
if (outputSchema && isZodSchema(outputSchema)) {
|
|
247
|
+
outputSchema = zodToJsonSchema(outputSchema);
|
|
248
|
+
}
|
|
249
|
+
const requestBody = {
|
|
250
|
+
query,
|
|
251
|
+
stream: false,
|
|
252
|
+
text: options?.text ?? false,
|
|
253
|
+
model: options?.model ?? "exa",
|
|
254
|
+
systemPrompt: options
|
|
255
|
+
?.systemPrompt,
|
|
256
|
+
outputSchema,
|
|
257
|
+
userLocation: options
|
|
258
|
+
?.userLocation,
|
|
259
|
+
};
|
|
260
|
+
return await this.request("/answer", "POST", requestBody);
|
|
261
|
+
}
|
|
262
|
+
async *streamAnswer(query, options) {
|
|
263
|
+
if (!fetchImpl) {
|
|
264
|
+
throw new ExaError("Global fetch is not available in this environment.", HttpStatusCode.internalServerError);
|
|
265
|
+
}
|
|
266
|
+
let outputSchema = options?.outputSchema;
|
|
267
|
+
if (outputSchema && isZodSchema(outputSchema)) {
|
|
268
|
+
outputSchema = zodToJsonSchema(outputSchema);
|
|
269
|
+
}
|
|
270
|
+
const body = {
|
|
271
|
+
query,
|
|
272
|
+
text: options?.text ?? false,
|
|
273
|
+
stream: true,
|
|
274
|
+
model: options?.model ?? "exa",
|
|
275
|
+
systemPrompt: options?.systemPrompt,
|
|
276
|
+
outputSchema,
|
|
277
|
+
};
|
|
278
|
+
const response = await fetchImpl(`${this.baseUrl}/answer`, {
|
|
279
|
+
method: "POST",
|
|
280
|
+
headers: this.headers,
|
|
281
|
+
body: JSON.stringify(body),
|
|
282
|
+
});
|
|
283
|
+
if (!response.ok) {
|
|
284
|
+
const message = await response.text();
|
|
285
|
+
throw new ExaError(message, response.status, new Date().toISOString());
|
|
286
|
+
}
|
|
287
|
+
const reader = response.body?.getReader();
|
|
288
|
+
if (!reader) {
|
|
289
|
+
throw new ExaError("No response body available for streaming.", 500, new Date().toISOString());
|
|
290
|
+
}
|
|
291
|
+
const decoder = new TextDecoder();
|
|
292
|
+
let buffer = "";
|
|
293
|
+
try {
|
|
294
|
+
while (true) {
|
|
295
|
+
const { done, value } = await reader.read();
|
|
296
|
+
if (done)
|
|
297
|
+
break;
|
|
298
|
+
buffer += decoder.decode(value, { stream: true });
|
|
299
|
+
const lines = buffer.split("\n");
|
|
300
|
+
buffer = lines.pop() ?? "";
|
|
301
|
+
for (const line of lines) {
|
|
302
|
+
if (!line.startsWith("data: "))
|
|
303
|
+
continue;
|
|
304
|
+
const jsonStr = line.replace(/^data:\s*/, "").trim();
|
|
305
|
+
if (!jsonStr || jsonStr === "[DONE]") {
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
let chunkData;
|
|
309
|
+
try {
|
|
310
|
+
chunkData = JSON.parse(jsonStr);
|
|
311
|
+
}
|
|
312
|
+
catch {
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
const chunk = this.processChunk(chunkData);
|
|
316
|
+
if (chunk.content || chunk.citations) {
|
|
317
|
+
yield chunk;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (buffer.startsWith("data: ")) {
|
|
322
|
+
const leftover = buffer.replace(/^data:\s*/, "").trim();
|
|
323
|
+
if (leftover && leftover !== "[DONE]") {
|
|
324
|
+
try {
|
|
325
|
+
const chunkData = JSON.parse(leftover);
|
|
326
|
+
const chunk = this.processChunk(chunkData);
|
|
327
|
+
if (chunk.content || chunk.citations) {
|
|
328
|
+
yield chunk;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
catch {
|
|
332
|
+
// ignore
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
finally {
|
|
338
|
+
reader.releaseLock();
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
processChunk(chunkData) {
|
|
342
|
+
let content;
|
|
343
|
+
let citations;
|
|
344
|
+
const data = chunkData;
|
|
345
|
+
const choices = data?.["choices"] ?? undefined;
|
|
346
|
+
if (choices?.[0]?.delta) {
|
|
347
|
+
const c = choices[0].delta.content;
|
|
348
|
+
if (typeof c === "string") {
|
|
349
|
+
content = c;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
const rawCitations = data?.["citations"];
|
|
353
|
+
if (rawCitations &&
|
|
354
|
+
rawCitations !== "null" &&
|
|
355
|
+
Array.isArray(rawCitations)) {
|
|
356
|
+
citations = rawCitations.map((c) => ({
|
|
357
|
+
id: String(c["id"] ?? ""),
|
|
358
|
+
url: String(c["url"] ?? ""),
|
|
359
|
+
title: typeof c["title"] === "string"
|
|
360
|
+
? c["title"]
|
|
361
|
+
: undefined,
|
|
362
|
+
publishedDate: typeof c["publishedDate"] === "string"
|
|
363
|
+
? c["publishedDate"]
|
|
364
|
+
: undefined,
|
|
365
|
+
author: typeof c["author"] === "string"
|
|
366
|
+
? c["author"]
|
|
367
|
+
: undefined,
|
|
368
|
+
text: typeof c["text"] === "string"
|
|
369
|
+
? c["text"]
|
|
370
|
+
: undefined,
|
|
371
|
+
}));
|
|
372
|
+
}
|
|
373
|
+
return { content, citations };
|
|
374
|
+
}
|
|
375
|
+
async parseSseStream(response) {
|
|
376
|
+
const reader = response.body?.getReader();
|
|
377
|
+
if (!reader) {
|
|
378
|
+
throw new ExaError("No response body available for streaming.", 500, new Date().toISOString());
|
|
379
|
+
}
|
|
380
|
+
const decoder = new TextDecoder();
|
|
381
|
+
let buffer = "";
|
|
382
|
+
return await new Promise((resolve, reject) => {
|
|
383
|
+
(async () => {
|
|
384
|
+
try {
|
|
385
|
+
while (true) {
|
|
386
|
+
const { done, value } = await reader.read();
|
|
387
|
+
if (done)
|
|
388
|
+
break;
|
|
389
|
+
buffer += decoder.decode(value, { stream: true });
|
|
390
|
+
const lines = buffer.split("\n");
|
|
391
|
+
buffer = lines.pop() ?? "";
|
|
392
|
+
for (const line of lines) {
|
|
393
|
+
if (!line.startsWith("data: "))
|
|
394
|
+
continue;
|
|
395
|
+
const jsonStr = line.replace(/^data:\s*/, "").trim();
|
|
396
|
+
if (!jsonStr || jsonStr === "[DONE]") {
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
let chunk;
|
|
400
|
+
try {
|
|
401
|
+
chunk = JSON.parse(jsonStr);
|
|
402
|
+
}
|
|
403
|
+
catch {
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
406
|
+
const tagged = chunk;
|
|
407
|
+
switch (tagged.tag) {
|
|
408
|
+
case "complete":
|
|
409
|
+
reader.releaseLock();
|
|
410
|
+
resolve(tagged.data);
|
|
411
|
+
return;
|
|
412
|
+
case "error": {
|
|
413
|
+
const message = tagged.error?.message || "Unknown error";
|
|
414
|
+
reader.releaseLock();
|
|
415
|
+
reject(new ExaError(message, HttpStatusCode.internalServerError, new Date().toISOString()));
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
default:
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
reject(new ExaError("Stream ended without a completion event.", HttpStatusCode.internalServerError, new Date().toISOString()));
|
|
424
|
+
}
|
|
425
|
+
catch (err) {
|
|
426
|
+
reject(err);
|
|
427
|
+
}
|
|
428
|
+
finally {
|
|
429
|
+
try {
|
|
430
|
+
reader.releaseLock();
|
|
431
|
+
}
|
|
432
|
+
catch {
|
|
433
|
+
// ignore
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
})();
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
}
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { WorkspaceContext } from "./index.ts";
|
|
1
2
|
import type { MessageHistory } from "./messages.ts";
|
|
2
3
|
import type { ModelManager } from "./models/manager.js";
|
|
3
4
|
import type { PromptManager } from "./prompts/manager.ts";
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
5
|
+
import type { TokenCounter } from "./tokens/counter.ts";
|
|
6
|
+
import type { TokenTracker } from "./tokens/tracker.ts";
|
|
6
7
|
interface CliOptions {
|
|
7
8
|
messageHistory: MessageHistory;
|
|
8
9
|
promptManager: PromptManager;
|
|
@@ -10,6 +11,7 @@ interface CliOptions {
|
|
|
10
11
|
tokenTracker: TokenTracker;
|
|
11
12
|
config: Record<PropertyKey, unknown>;
|
|
12
13
|
tokenCounter: TokenCounter;
|
|
14
|
+
workspace: WorkspaceContext;
|
|
13
15
|
}
|
|
14
16
|
export declare class Cli {
|
|
15
17
|
private options;
|
|
@@ -17,3 +19,4 @@ export declare class Cli {
|
|
|
17
19
|
run(): Promise<void>;
|
|
18
20
|
}
|
|
19
21
|
export {};
|
|
22
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../source/cli.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AASxD,UAAU,UAAU;IAClB,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,EAAE,aAAa,CAAC;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACrC,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,gBAAgB,CAAC;CAC7B;AAWD,qBAAa,GAAG;IACd,OAAO,CAAC,OAAO,CAAa;gBAChB,OAAO,EAAE,UAAU;IAIzB,GAAG;CAkFV"}
|
package/dist/cli.js
CHANGED
|
@@ -2,12 +2,21 @@ import { generateObject, generateText, NoSuchToolError, stepCountIs, } from "ai"
|
|
|
2
2
|
import { logger } from "./logger.js";
|
|
3
3
|
import { AiConfig } from "./models/ai-config.js";
|
|
4
4
|
import { minSystemPrompt } from "./prompts.js";
|
|
5
|
-
import {
|
|
5
|
+
import { BashTool } from "./tools/bash.js";
|
|
6
|
+
import { CodeInterpreterTool } from "./tools/code-interpreter.js";
|
|
6
7
|
import { EditFileTool } from "./tools/edit-file.js";
|
|
8
|
+
import { GlobTool } from "./tools/glob.js";
|
|
9
|
+
import { GrepTool } from "./tools/grep.js";
|
|
7
10
|
import { initCliTools } from "./tools/index.js";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
import { ReadFileTool } from "./tools/read-file.js";
|
|
12
|
+
const activeTools = [
|
|
13
|
+
EditFileTool.name,
|
|
14
|
+
ReadFileTool.name,
|
|
15
|
+
BashTool.name,
|
|
16
|
+
GrepTool.name,
|
|
17
|
+
GlobTool.name,
|
|
18
|
+
CodeInterpreterTool.name,
|
|
19
|
+
];
|
|
11
20
|
export class Cli {
|
|
12
21
|
options;
|
|
13
22
|
constructor(options) {
|
|
@@ -33,41 +42,25 @@ export class Cli {
|
|
|
33
42
|
modelMetadata: modelConfig,
|
|
34
43
|
prompt: userPrompt,
|
|
35
44
|
});
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
const tools = await initCliTools({
|
|
46
|
+
tokenCounter,
|
|
47
|
+
workspace: this.options.workspace,
|
|
48
|
+
});
|
|
40
49
|
try {
|
|
41
50
|
const result = await generateText({
|
|
42
51
|
model: langModel,
|
|
43
|
-
maxOutputTokens:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
providerOptions: {
|
|
49
|
-
anthropic: { cacheControl: { type: "ephemeral" } },
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
...messageHistory.get(),
|
|
53
|
-
],
|
|
54
|
-
temperature: modelConfig.defaultTemperature,
|
|
52
|
+
maxOutputTokens: aiConfig.maxOutputTokens(),
|
|
53
|
+
system: finalSystemPrompt,
|
|
54
|
+
messages: messageHistory.get(),
|
|
55
|
+
temperature: aiConfig.temperature(),
|
|
56
|
+
topP: aiConfig.topP(),
|
|
55
57
|
stopWhen: stepCountIs(60),
|
|
56
58
|
maxRetries: 2,
|
|
57
|
-
providerOptions: aiConfig.
|
|
58
|
-
tools,
|
|
59
|
-
|
|
60
|
-
experimental_activeTools: [
|
|
61
|
-
EditFileTool.name,
|
|
62
|
-
SaveFileTool.name,
|
|
63
|
-
MoveFileTool.name,
|
|
64
|
-
DeleteFileTool.name,
|
|
65
|
-
ThinkTool.name,
|
|
66
|
-
],
|
|
59
|
+
providerOptions: aiConfig.providerOptions(),
|
|
60
|
+
tools: tools.toolDefs,
|
|
61
|
+
activeTools,
|
|
67
62
|
// biome-ignore lint/style/useNamingConvention: third-party controlled
|
|
68
|
-
experimental_repairToolCall:
|
|
69
|
-
? toolCallRepair(modelManager)
|
|
70
|
-
: undefined,
|
|
63
|
+
experimental_repairToolCall: toolCallRepair(modelManager),
|
|
71
64
|
abortSignal: signal,
|
|
72
65
|
});
|
|
73
66
|
if (result.response.messages.length > 0) {
|
|
@@ -75,6 +68,7 @@ export class Cli {
|
|
|
75
68
|
}
|
|
76
69
|
// this tracks the usage of every step in the call to streamText. it's a cumulative usage.
|
|
77
70
|
tokenTracker.trackUsage("cli", result.usage);
|
|
71
|
+
messageHistory.save();
|
|
78
72
|
process.stdout.end(result.text.endsWith("\n") ? result.text : `${result.text}\n`);
|
|
79
73
|
}
|
|
80
74
|
catch (e) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-directory-command.d.ts","sourceRoot":"","sources":["../../source/commands/add-directory-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,mBAAmB,GAAI,0BAGjC,cAAc,KAAG,WAkInB,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import style from "../terminal/style.js";
|
|
4
|
+
import { Text } from "../tui/index.js";
|
|
5
|
+
export const addDirectoryCommand = ({ terminal, workspace, }) => {
|
|
6
|
+
return {
|
|
7
|
+
command: "/add-directory",
|
|
8
|
+
description: "Add a directory to the list of allowed working directories",
|
|
9
|
+
getSubCommands: async () => {
|
|
10
|
+
return [];
|
|
11
|
+
},
|
|
12
|
+
execute: async (args) => {
|
|
13
|
+
const directoryPath = args?.[0];
|
|
14
|
+
if (!directoryPath) {
|
|
15
|
+
terminal.error("Usage: /add-directory <path>");
|
|
16
|
+
return "continue";
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
// Resolve and validate the directory
|
|
20
|
+
const resolvedPath = path.resolve(directoryPath);
|
|
21
|
+
const stats = await fs.stat(resolvedPath);
|
|
22
|
+
if (!stats.isDirectory()) {
|
|
23
|
+
terminal.error(`Path is not a directory: ${resolvedPath}`);
|
|
24
|
+
return "continue";
|
|
25
|
+
}
|
|
26
|
+
// Check if directory is already in the list
|
|
27
|
+
if (workspace.allowedDirs.includes(resolvedPath)) {
|
|
28
|
+
terminal.warn(`Directory already in allowed list: ${resolvedPath}`);
|
|
29
|
+
return "continue";
|
|
30
|
+
}
|
|
31
|
+
// Add the directory to the workspace
|
|
32
|
+
workspace.allowedDirs.push(resolvedPath);
|
|
33
|
+
terminal.writeln(`Added directory to allowed list: ${style.blue(resolvedPath)}`);
|
|
34
|
+
terminal.writeln(`Current allowed directories: ${style.blue(workspace.allowedDirs.join(", "))}`);
|
|
35
|
+
return "continue";
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
39
|
+
terminal.error(`Failed to add directory: ${errorMessage}`);
|
|
40
|
+
return "continue";
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
async handle(args, { tui, container, editor, }) {
|
|
44
|
+
const directoryPath = args?.[0];
|
|
45
|
+
if (!directoryPath) {
|
|
46
|
+
container.addChild(new Text(style.red("Usage: /add-directory <path>"), 0, 1));
|
|
47
|
+
tui.requestRender();
|
|
48
|
+
editor.setText("");
|
|
49
|
+
return "continue";
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
// Resolve and validate the directory
|
|
53
|
+
const resolvedPath = path.resolve(directoryPath);
|
|
54
|
+
const stats = await fs.stat(resolvedPath);
|
|
55
|
+
if (!stats.isDirectory()) {
|
|
56
|
+
container.addChild(new Text(style.red(`Path is not a directory: ${resolvedPath}`), 1, 0));
|
|
57
|
+
tui.requestRender();
|
|
58
|
+
editor.setText("");
|
|
59
|
+
return "continue";
|
|
60
|
+
}
|
|
61
|
+
// Check if directory is already in the list
|
|
62
|
+
if (workspace.allowedDirs.includes(resolvedPath)) {
|
|
63
|
+
container.addChild(new Text(style.yellow(`Directory already in allowed list: ${resolvedPath}`), 1, 0));
|
|
64
|
+
tui.requestRender();
|
|
65
|
+
editor.setText("");
|
|
66
|
+
return "continue";
|
|
67
|
+
}
|
|
68
|
+
// Add the directory to the workspace
|
|
69
|
+
workspace.allowedDirs.push(resolvedPath);
|
|
70
|
+
container.addChild(new Text(`Added directory to allowed list: ${style.blue(resolvedPath)}`, 1, 0));
|
|
71
|
+
container.addChild(new Text(`Current allowed directories: ${style.blue(workspace.allowedDirs.join(", "))}`, 2, 0));
|
|
72
|
+
tui.requestRender();
|
|
73
|
+
editor.setText("");
|
|
74
|
+
return "continue";
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
78
|
+
container.addChild(new Text(style.red(`Failed to add directory: ${errorMessage}`), 0, 1));
|
|
79
|
+
tui.requestRender();
|
|
80
|
+
editor.setText("");
|
|
81
|
+
return "continue";
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application-log-command.d.ts","sourceRoot":"","sources":["../../source/commands/application-log-command.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,qBAAqB,GAAI,eAEnC,cAAc,KAAG,WAwHnB,CAAC"}
|