@travisennis/acai 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +190 -19
- package/bin/acai-wrapper.js +26 -0
- package/dist/agent/index.d.ts +132 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +434 -0
- package/dist/api/exa/index.js +1 -1
- package/dist/cli.d.ts +4 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +67 -40
- package/dist/commands/add-directory-command.d.ts +3 -0
- package/dist/commands/add-directory-command.d.ts.map +1 -0
- package/dist/commands/add-directory-command.js +54 -0
- package/dist/commands/application-log-command.d.ts +1 -1
- package/dist/commands/application-log-command.d.ts.map +1 -1
- package/dist/commands/application-log-command.js +18 -20
- package/dist/commands/clear-command.d.ts +1 -1
- package/dist/commands/clear-command.d.ts.map +1 -1
- package/dist/commands/clear-command.js +7 -3
- package/dist/commands/compact-command.d.ts.map +1 -1
- package/dist/commands/compact-command.js +9 -5
- package/dist/commands/context-command.d.ts +3 -0
- package/dist/commands/context-command.d.ts.map +1 -0
- package/dist/commands/context-command.js +124 -0
- package/dist/commands/copy-command.d.ts.map +1 -1
- package/dist/commands/copy-command.js +14 -5
- package/dist/commands/edit-command.d.ts +1 -1
- package/dist/commands/edit-command.d.ts.map +1 -1
- package/dist/commands/edit-command.js +21 -34
- package/dist/commands/edit-prompt-command.d.ts +1 -1
- package/dist/commands/edit-prompt-command.d.ts.map +1 -1
- package/dist/commands/edit-prompt-command.js +18 -15
- package/dist/commands/exit-command.d.ts +1 -4
- package/dist/commands/exit-command.d.ts.map +1 -1
- package/dist/commands/exit-command.js +9 -5
- package/dist/commands/files-command.d.ts +1 -1
- package/dist/commands/files-command.d.ts.map +1 -1
- package/dist/commands/files-command.js +20 -16
- package/dist/commands/generate-rules-command.d.ts +1 -1
- package/dist/commands/generate-rules-command.d.ts.map +1 -1
- package/dist/commands/generate-rules-command.js +307 -39
- package/dist/commands/handoff-command.d.ts +3 -0
- package/dist/commands/handoff-command.d.ts.map +1 -0
- package/dist/commands/handoff-command.js +191 -0
- package/dist/commands/health-command.d.ts +1 -1
- package/dist/commands/health-command.d.ts.map +1 -1
- package/dist/commands/health-command.js +49 -27
- package/dist/commands/help-command.d.ts +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +25 -5
- package/dist/commands/history-command.d.ts +3 -0
- package/dist/commands/history-command.d.ts.map +1 -0
- package/dist/commands/history-command.js +458 -0
- package/dist/commands/init-command.d.ts +1 -1
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/init-command.js +40 -22
- package/dist/commands/last-log-command.d.ts +1 -1
- package/dist/commands/last-log-command.d.ts.map +1 -1
- package/dist/commands/last-log-command.js +15 -15
- package/dist/commands/list-directories-command.d.ts +3 -0
- package/dist/commands/list-directories-command.d.ts.map +1 -0
- package/dist/commands/list-directories-command.js +35 -0
- package/dist/commands/list-tools-command.d.ts.map +1 -1
- package/dist/commands/list-tools-command.js +61 -21
- package/dist/commands/manager.d.ts +9 -4
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +64 -39
- package/dist/commands/model-command.d.ts.map +1 -1
- package/dist/commands/model-command.js +201 -66
- package/dist/commands/paste-command.d.ts +1 -1
- package/dist/commands/paste-command.d.ts.map +1 -1
- package/dist/commands/paste-command.js +23 -9
- package/dist/commands/pickup-command.d.ts +3 -0
- package/dist/commands/pickup-command.d.ts.map +1 -0
- package/dist/commands/pickup-command.js +109 -0
- package/dist/commands/prompt-command.d.ts +19 -1
- package/dist/commands/prompt-command.d.ts.map +1 -1
- package/dist/commands/prompt-command.js +191 -98
- package/dist/commands/remove-directory-command.d.ts +3 -0
- package/dist/commands/remove-directory-command.d.ts.map +1 -0
- package/dist/commands/remove-directory-command.js +55 -0
- package/dist/commands/reset-command.d.ts +1 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/reset-command.js +8 -5
- package/dist/commands/rules-command.d.ts +1 -1
- package/dist/commands/rules-command.d.ts.map +1 -1
- package/dist/commands/rules-command.js +25 -22
- package/dist/commands/save-command.d.ts +1 -1
- package/dist/commands/save-command.d.ts.map +1 -1
- package/dist/commands/save-command.js +8 -3
- package/dist/commands/shell-command.d.ts.map +1 -1
- package/dist/commands/shell-command.js +45 -24
- package/dist/commands/types.d.ts +9 -7
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/usage-command.d.ts +1 -1
- package/dist/commands/usage-command.d.ts.map +1 -1
- package/dist/commands/usage-command.js +18 -7
- package/dist/config.d.ts +21 -11
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +90 -63
- package/dist/execution/index.d.ts +17 -2
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +62 -20
- package/dist/formatting.d.ts +127 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +201 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +263 -102
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +47 -18
- package/dist/mentions.d.ts +2 -1
- package/dist/mentions.d.ts.map +1 -1
- package/dist/mentions.js +16 -1
- package/dist/messages.d.ts +11 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +122 -21
- package/dist/middleware/cache.d.ts +3 -0
- package/dist/middleware/cache.d.ts.map +1 -0
- package/dist/middleware/cache.js +53 -0
- package/dist/middleware/index.d.ts +1 -0
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/index.js +1 -0
- package/dist/models/ai-config.d.ts +4 -2
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +12 -2
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/anthropic-provider.js +3 -67
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/deepseek-provider.js +0 -2
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/google-provider.js +0 -3
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.js +0 -1
- package/dist/models/manager.d.ts +2 -1
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +26 -2
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +0 -4
- package/dist/models/openrouter-provider.d.ts +16 -22
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +175 -236
- package/dist/models/providers.d.ts +4 -14
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +1 -57
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +0 -2
- package/dist/prompts.d.ts +10 -4
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +447 -70
- package/dist/repl/project-status-line.d.ts +3 -0
- package/dist/repl/project-status-line.d.ts.map +1 -0
- package/dist/repl/project-status-line.js +61 -0
- package/dist/repl/tool-call-repair.d.ts.map +1 -1
- package/dist/repl/tool-call-repair.js +8 -4
- package/dist/repl-new.d.ts +51 -0
- package/dist/repl-new.d.ts.map +1 -0
- package/dist/repl-new.js +354 -0
- package/dist/skills.d.ts +20 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +192 -0
- package/dist/terminal/control.d.ts +55 -0
- package/dist/terminal/control.d.ts.map +1 -0
- package/dist/terminal/control.js +109 -0
- package/dist/terminal/default-theme.d.ts +1 -1
- package/dist/terminal/default-theme.d.ts.map +1 -1
- package/dist/terminal/default-theme.js +24 -28
- package/dist/terminal/formatting.d.ts +23 -25
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +35 -52
- package/dist/terminal/highlight/index.d.ts.map +1 -1
- package/dist/terminal/highlight/index.js +3 -6
- package/dist/terminal/highlight/theme.d.ts.map +1 -1
- package/dist/terminal/highlight/theme.js +2 -6
- package/dist/terminal/index.d.ts +2 -94
- package/dist/terminal/index.d.ts.map +1 -1
- package/dist/terminal/index.js +2 -370
- package/dist/terminal/markdown.js +10 -5
- package/dist/terminal/select-prompt.d.ts +2 -2
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +47 -39
- package/dist/terminal/strip-ansi.js +4 -4
- package/dist/terminal/table/cell.d.ts +114 -0
- package/dist/terminal/table/cell.d.ts.map +1 -0
- package/dist/terminal/table/cell.js +407 -0
- package/dist/terminal/table/debug.d.ts +15 -0
- package/dist/terminal/table/debug.d.ts.map +1 -0
- package/dist/terminal/table/debug.js +32 -0
- package/dist/terminal/table/index.d.ts +3 -0
- package/dist/terminal/table/index.d.ts.map +1 -0
- package/dist/terminal/table/index.js +2 -0
- package/dist/terminal/table/layout-manager.d.ts +27 -0
- package/dist/terminal/table/layout-manager.d.ts.map +1 -0
- package/dist/terminal/table/layout-manager.js +257 -0
- package/dist/terminal/table/table.d.ts +9 -0
- package/dist/terminal/table/table.d.ts.map +1 -0
- package/dist/terminal/table/table.js +97 -0
- package/dist/terminal/table/utils.d.ts +63 -0
- package/dist/terminal/table/utils.d.ts.map +1 -0
- package/dist/terminal/table/utils.js +326 -0
- package/dist/tokens/threshold.d.ts +20 -0
- package/dist/tokens/threshold.d.ts.map +1 -0
- package/dist/tokens/threshold.js +67 -0
- package/dist/tools/advanced-edit-file.d.ts +69 -0
- package/dist/tools/advanced-edit-file.d.ts.map +1 -0
- package/dist/tools/advanced-edit-file.js +285 -0
- package/dist/tools/agent.d.ts +16 -5
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/agent.js +86 -59
- package/dist/tools/bash.d.ts +23 -12
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +243 -128
- package/dist/tools/batch.d.ts +34 -0
- package/dist/tools/batch.d.ts.map +1 -0
- package/dist/tools/batch.js +174 -0
- package/dist/tools/code-interpreter.d.ts +21 -9
- package/dist/tools/code-interpreter.d.ts.map +1 -1
- package/dist/tools/code-interpreter.js +151 -134
- package/dist/tools/delete-file.d.ts +17 -10
- package/dist/tools/delete-file.d.ts.map +1 -1
- package/dist/tools/delete-file.js +60 -97
- package/dist/tools/directory-tree.d.ts +17 -12
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +57 -48
- package/dist/tools/dynamic-tool-loader.d.ts +16 -10
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +122 -130
- package/dist/tools/dynamic-tool-parser.d.ts +1 -0
- package/dist/tools/dynamic-tool-parser.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-parser.js +1 -0
- package/dist/tools/edit-file.d.ts +35 -15
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +127 -114
- package/dist/tools/glob.d.ts +36 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +154 -0
- package/dist/tools/grep.d.ts +73 -12
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +425 -165
- package/dist/tools/index.d.ts +220 -126
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +284 -135
- package/dist/tools/llm-edit-fixer.d.ts +24 -0
- package/dist/tools/llm-edit-fixer.d.ts.map +1 -0
- package/dist/tools/llm-edit-fixer.js +136 -0
- package/dist/tools/move-file.d.ts +19 -7
- package/dist/tools/move-file.d.ts.map +1 -1
- package/dist/tools/move-file.js +48 -34
- package/dist/tools/read-file.d.ts +47 -9
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +84 -70
- package/dist/tools/read-multiple-files.d.ts +17 -6
- package/dist/tools/read-multiple-files.d.ts.map +1 -1
- package/dist/tools/read-multiple-files.js +132 -72
- package/dist/tools/save-file.d.ts +45 -12
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +76 -101
- package/dist/tools/think.d.ts +15 -7
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +34 -20
- package/dist/tools/types.d.ts +8 -10
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +9 -0
- package/dist/tools/utils.d.ts +14 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +16 -0
- package/dist/tools/web-fetch.d.ts +11 -4
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +39 -38
- package/dist/tools/web-search.d.ts +15 -6
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +64 -31
- package/dist/tui/autocomplete.d.ts +44 -0
- package/dist/tui/autocomplete.d.ts.map +1 -0
- package/dist/tui/autocomplete.js +466 -0
- package/dist/tui/components/assistant-message.d.ts +18 -0
- package/dist/tui/components/assistant-message.d.ts.map +1 -0
- package/dist/tui/components/assistant-message.js +29 -0
- package/dist/tui/components/box.d.ts +20 -0
- package/dist/tui/components/box.d.ts.map +1 -0
- package/dist/tui/components/box.js +81 -0
- package/dist/tui/components/editor.d.ts +106 -0
- package/dist/tui/components/editor.d.ts.map +1 -0
- package/dist/tui/components/editor.js +1220 -0
- package/dist/tui/components/footer.d.ts +12 -0
- package/dist/tui/components/footer.d.ts.map +1 -0
- package/dist/tui/components/footer.js +209 -0
- package/dist/tui/components/header.d.ts +21 -0
- package/dist/tui/components/header.d.ts.map +1 -0
- package/dist/tui/components/header.js +63 -0
- package/dist/tui/components/input.d.ts +14 -0
- package/dist/tui/components/input.d.ts.map +1 -0
- package/dist/tui/components/input.js +122 -0
- package/dist/tui/components/loader.d.ts +23 -0
- package/dist/tui/components/loader.d.ts.map +1 -0
- package/dist/tui/components/loader.js +45 -0
- package/dist/tui/components/markdown.d.ts +106 -0
- package/dist/tui/components/markdown.d.ts.map +1 -0
- package/dist/tui/components/markdown.js +586 -0
- package/dist/tui/components/modal.d.ts +29 -0
- package/dist/tui/components/modal.d.ts.map +1 -0
- package/dist/tui/components/modal.js +263 -0
- package/dist/tui/components/progress-bar.d.ts +19 -0
- package/dist/tui/components/progress-bar.d.ts.map +1 -0
- package/dist/tui/components/progress-bar.js +78 -0
- package/dist/tui/components/prompt-status.d.ts +17 -0
- package/dist/tui/components/prompt-status.d.ts.map +1 -0
- package/dist/tui/components/prompt-status.js +26 -0
- package/dist/tui/components/select-list.d.ts +48 -0
- package/dist/tui/components/select-list.d.ts.map +1 -0
- package/dist/tui/components/select-list.js +207 -0
- package/dist/tui/components/spacer.d.ts +16 -0
- package/dist/tui/components/spacer.d.ts.map +1 -0
- package/dist/tui/components/spacer.js +27 -0
- package/dist/tui/components/table.d.ts +27 -0
- package/dist/tui/components/table.d.ts.map +1 -0
- package/dist/tui/components/table.js +125 -0
- package/dist/tui/components/text.d.ts +26 -0
- package/dist/tui/components/text.d.ts.map +1 -0
- package/dist/tui/components/text.js +143 -0
- package/dist/tui/components/thinking-block.d.ts +14 -0
- package/dist/tui/components/thinking-block.d.ts.map +1 -0
- package/dist/tui/components/thinking-block.js +33 -0
- package/dist/tui/components/tool-execution.d.ts +21 -0
- package/dist/tui/components/tool-execution.d.ts.map +1 -0
- package/dist/tui/components/tool-execution.js +161 -0
- package/dist/tui/components/user-message.d.ts +9 -0
- package/dist/tui/components/user-message.d.ts.map +1 -0
- package/dist/tui/components/user-message.js +23 -0
- package/dist/tui/components/welcome.d.ts +6 -0
- package/dist/tui/components/welcome.d.ts.map +1 -0
- package/dist/tui/components/welcome.js +30 -0
- package/dist/tui/index.d.ts +18 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +22 -0
- package/dist/tui/terminal.d.ts +38 -0
- package/dist/tui/terminal.d.ts.map +1 -0
- package/dist/tui/terminal.js +94 -0
- package/dist/tui/tui.d.ts +69 -0
- package/dist/tui/tui.d.ts.map +1 -0
- package/dist/tui/tui.js +204 -0
- package/dist/tui/utils.d.ts +24 -0
- package/dist/tui/utils.d.ts.map +1 -0
- package/dist/tui/utils.js +111 -0
- package/dist/utils/bash.d.ts +7 -0
- package/dist/utils/bash.d.ts.map +1 -0
- package/dist/{tools/bash-utils.js → utils/bash.js} +31 -12
- package/dist/utils/{filesystem.d.ts → filesystem/operations.d.ts} +1 -1
- package/dist/utils/filesystem/operations.d.ts.map +1 -0
- package/dist/utils/filesystem/security.d.ts +9 -0
- package/dist/utils/filesystem/security.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.js → utils/filesystem/security.js} +93 -21
- package/dist/utils/funcs.d.ts +6 -0
- package/dist/utils/funcs.d.ts.map +1 -0
- package/dist/utils/funcs.js +6 -0
- package/dist/utils/generators.d.ts +3 -0
- package/dist/utils/generators.d.ts.map +1 -0
- package/dist/utils/generators.js +25 -0
- package/dist/{tools/git-utils.d.ts → utils/git.d.ts} +1 -1
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/{tools/git-utils.js → utils/git.js} +0 -6
- package/dist/utils/glob.js +1 -1
- package/dist/utils/iterables.d.ts +2 -0
- package/dist/utils/iterables.d.ts.map +1 -0
- package/dist/utils/iterables.js +6 -0
- package/dist/utils/{zod-utils.d.ts → zod.d.ts} +1 -1
- package/dist/utils/zod.d.ts.map +1 -0
- package/package.json +21 -21
- package/dist/conversation-analyzer.d.ts +0 -11
- package/dist/conversation-analyzer.d.ts.map +0 -1
- package/dist/conversation-analyzer.js +0 -88
- package/dist/repl/display-tool-messages.d.ts +0 -4
- package/dist/repl/display-tool-messages.d.ts.map +0 -1
- package/dist/repl/display-tool-messages.js +0 -55
- package/dist/repl/display-tool-use.d.ts +0 -14
- package/dist/repl/display-tool-use.d.ts.map +0 -1
- package/dist/repl/display-tool-use.js +0 -63
- package/dist/repl/get-prompt-header.d.ts +0 -8
- package/dist/repl/get-prompt-header.d.ts.map +0 -1
- package/dist/repl/get-prompt-header.js +0 -38
- package/dist/repl-prompt.d.ts +0 -15
- package/dist/repl-prompt.d.ts.map +0 -1
- package/dist/repl-prompt.js +0 -147
- package/dist/repl.d.ts +0 -31
- package/dist/repl.d.ts.map +0 -1
- package/dist/repl.js +0 -310
- package/dist/terminal/checkbox-prompt.d.ts +0 -36
- package/dist/terminal/checkbox-prompt.d.ts.map +0 -1
- package/dist/terminal/checkbox-prompt.js +0 -362
- package/dist/terminal/editor-prompt.d.ts +0 -10
- package/dist/terminal/editor-prompt.d.ts.map +0 -1
- package/dist/terminal/editor-prompt.js +0 -61
- package/dist/terminal/errors.d.ts +0 -19
- package/dist/terminal/errors.d.ts.map +0 -1
- package/dist/terminal/errors.js +0 -37
- package/dist/terminal/input-prompt.d.ts +0 -16
- package/dist/terminal/input-prompt.d.ts.map +0 -1
- package/dist/terminal/input-prompt.js +0 -181
- package/dist/terminal/search-prompt.d.ts +0 -20
- package/dist/terminal/search-prompt.d.ts.map +0 -1
- package/dist/terminal/search-prompt.js +0 -279
- package/dist/terminal/types.d.ts +0 -35
- package/dist/terminal/types.d.ts.map +0 -1
- package/dist/terminal/types.js +0 -1
- package/dist/tokens/manage-output.d.ts +0 -34
- package/dist/tokens/manage-output.d.ts.map +0 -1
- package/dist/tokens/manage-output.js +0 -44
- package/dist/tool-executor.d.ts +0 -28
- package/dist/tool-executor.d.ts.map +0 -1
- package/dist/tool-executor.js +0 -74
- package/dist/tools/bash-utils.d.ts +0 -7
- package/dist/tools/bash-utils.d.ts.map +0 -1
- package/dist/tools/file-editing-utils.d.ts +0 -2
- package/dist/tools/file-editing-utils.d.ts.map +0 -1
- package/dist/tools/file-editing-utils.js +0 -135
- package/dist/tools/filesystem-utils.d.ts +0 -7
- package/dist/tools/filesystem-utils.d.ts.map +0 -1
- package/dist/tools/git-utils.d.ts.map +0 -1
- package/dist/utils/filesystem.d.ts.map +0 -1
- package/dist/utils/zod-utils.d.ts.map +0 -1
- /package/dist/utils/{filesystem.js → filesystem/operations.js} +0 -0
- /package/dist/utils/{zod-utils.js → zod.js} +0 -0
package/dist/repl.js
DELETED
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
import { isNumber, isRecord } from "@travisennis/stdlib/typeguards";
|
|
2
|
-
import { stepCountIs, streamText } from "ai";
|
|
3
|
-
import { config as configManager } from "./config.js";
|
|
4
|
-
import { logger } from "./logger.js";
|
|
5
|
-
import { PromptError, processPrompt } from "./mentions.js";
|
|
6
|
-
import { AiConfig } from "./models/ai-config.js";
|
|
7
|
-
import { systemPrompt } from "./prompts.js";
|
|
8
|
-
import { displayToolMessages } from "./repl/display-tool-messages.js";
|
|
9
|
-
import { displayToolUse } from "./repl/display-tool-use.js";
|
|
10
|
-
import { getPromptHeader } from "./repl/get-prompt-header.js";
|
|
11
|
-
import { toolCallRepair } from "./repl/tool-call-repair.js";
|
|
12
|
-
import { ReplPrompt } from "./repl-prompt.js";
|
|
13
|
-
import style from "./terminal/style.js";
|
|
14
|
-
import { initAgents, initTools } from "./tools/index.js";
|
|
15
|
-
export class Repl {
|
|
16
|
-
options;
|
|
17
|
-
showLastMessage;
|
|
18
|
-
constructor(options) {
|
|
19
|
-
this.options = options;
|
|
20
|
-
this.showLastMessage = options.showLastMessage;
|
|
21
|
-
}
|
|
22
|
-
async run() {
|
|
23
|
-
const { config, promptManager, terminal, modelManager, tokenTracker, messageHistory, commands, tokenCounter, toolEvents, toolExecutor, promptHistory, } = this.options;
|
|
24
|
-
logger.info(config, "Config:");
|
|
25
|
-
terminal.displayWelcome();
|
|
26
|
-
let currentContextWindow = 0;
|
|
27
|
-
messageHistory.on("clear-history", () => {
|
|
28
|
-
currentContextWindow = 0;
|
|
29
|
-
});
|
|
30
|
-
const finalSystemPrompt = await systemPrompt();
|
|
31
|
-
// Initialize tools once outside the loop - all models support tool calling
|
|
32
|
-
const tools = {
|
|
33
|
-
...(await initTools({
|
|
34
|
-
terminal,
|
|
35
|
-
tokenCounter,
|
|
36
|
-
events: toolEvents,
|
|
37
|
-
toolExecutor,
|
|
38
|
-
})),
|
|
39
|
-
...(await initAgents({
|
|
40
|
-
terminal,
|
|
41
|
-
modelManager,
|
|
42
|
-
tokenTracker,
|
|
43
|
-
tokenCounter,
|
|
44
|
-
events: toolEvents,
|
|
45
|
-
})),
|
|
46
|
-
};
|
|
47
|
-
let currentAbortController = null;
|
|
48
|
-
// Handle Ctrl+C (SIGINT) as a fallback when not in raw mode
|
|
49
|
-
process.on("SIGINT", () => {
|
|
50
|
-
currentAbortController?.abort();
|
|
51
|
-
});
|
|
52
|
-
while (true) {
|
|
53
|
-
currentAbortController = new AbortController();
|
|
54
|
-
const { signal } = currentAbortController;
|
|
55
|
-
const langModel = modelManager.getModel("repl");
|
|
56
|
-
const modelConfig = modelManager.getModelMetadata("repl");
|
|
57
|
-
// agent header/status line
|
|
58
|
-
await getPromptHeader({
|
|
59
|
-
terminal,
|
|
60
|
-
modelId: langModel.modelId,
|
|
61
|
-
contextWindow: modelConfig.contextWindow,
|
|
62
|
-
currentContextWindow,
|
|
63
|
-
});
|
|
64
|
-
// Display last message when continuing/resuming a conversation
|
|
65
|
-
if (this.showLastMessage) {
|
|
66
|
-
const lastMessage = messageHistory.getLastMessage();
|
|
67
|
-
if (lastMessage) {
|
|
68
|
-
terminal.lineBreak();
|
|
69
|
-
terminal.writeln(style.dim("Continuing conversation:"));
|
|
70
|
-
terminal.display(lastMessage);
|
|
71
|
-
terminal.lineBreak();
|
|
72
|
-
terminal.hr();
|
|
73
|
-
}
|
|
74
|
-
// don't show the last message after showing it once
|
|
75
|
-
this.showLastMessage = false;
|
|
76
|
-
}
|
|
77
|
-
if (!promptManager.isPending()) {
|
|
78
|
-
// For interactive input
|
|
79
|
-
const prompt = new ReplPrompt({ commands, history: promptHistory });
|
|
80
|
-
const userInput = await prompt.input();
|
|
81
|
-
prompt.close();
|
|
82
|
-
terminal.startProgress();
|
|
83
|
-
// see if the userInput contains a command
|
|
84
|
-
const commandResult = await commands.handle({ userInput });
|
|
85
|
-
if (commandResult.break) {
|
|
86
|
-
terminal.stopProgress();
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
if (commandResult.continue) {
|
|
90
|
-
terminal.stopProgress();
|
|
91
|
-
terminal.lineBreak();
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
if (!userInput.trim()) {
|
|
95
|
-
terminal.stopProgress();
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
// if there is no pending prompt then use the user's input. otherwise, the prompt was loaded from a command
|
|
99
|
-
if (!promptManager.isPending()) {
|
|
100
|
-
try {
|
|
101
|
-
const processedPrompt = await processPrompt(userInput, {
|
|
102
|
-
baseDir: process.cwd(),
|
|
103
|
-
model: modelConfig,
|
|
104
|
-
});
|
|
105
|
-
for (const context of processedPrompt.context) {
|
|
106
|
-
promptManager.addContext(context);
|
|
107
|
-
}
|
|
108
|
-
promptManager.set(processedPrompt.message);
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
if (error instanceof PromptError) {
|
|
112
|
-
terminal.error(`Prompt processing failed: ${error.message}`);
|
|
113
|
-
if (error.cause &&
|
|
114
|
-
typeof error.cause === "object" &&
|
|
115
|
-
"command" in error.cause &&
|
|
116
|
-
typeof error.cause.command === "string") {
|
|
117
|
-
terminal.error(`Command: ${error.cause.command}`);
|
|
118
|
-
}
|
|
119
|
-
terminal.lineBreak();
|
|
120
|
-
terminal.stopProgress();
|
|
121
|
-
continue; // Continue the REPL loop
|
|
122
|
-
}
|
|
123
|
-
throw error; // Re-throw other errors
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
terminal.lineBreak();
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
terminal.startProgress();
|
|
130
|
-
}
|
|
131
|
-
// flag to see if the user prompt has added context
|
|
132
|
-
const hasAddedContext = promptManager.hasContext();
|
|
133
|
-
if (hasAddedContext) {
|
|
134
|
-
const contextTokenCount = promptManager.getContextTokenCount();
|
|
135
|
-
terminal.info(`Context will be added to prompt. (${contextTokenCount} tokens)`);
|
|
136
|
-
terminal.lineBreak();
|
|
137
|
-
}
|
|
138
|
-
const userPrompt = promptManager.get();
|
|
139
|
-
const userMsg = promptManager.getUserMessage();
|
|
140
|
-
messageHistory.appendUserMessage(userMsg);
|
|
141
|
-
const aiConfig = new AiConfig({
|
|
142
|
-
modelMetadata: modelConfig,
|
|
143
|
-
prompt: userPrompt,
|
|
144
|
-
});
|
|
145
|
-
const maxTokens = aiConfig.getMaxTokens();
|
|
146
|
-
try {
|
|
147
|
-
const result = streamText({
|
|
148
|
-
model: langModel,
|
|
149
|
-
maxOutputTokens: maxTokens,
|
|
150
|
-
messages: [
|
|
151
|
-
{
|
|
152
|
-
role: "system",
|
|
153
|
-
content: finalSystemPrompt,
|
|
154
|
-
providerOptions: {
|
|
155
|
-
anthropic: { cacheControl: { type: "ephemeral" } },
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
...messageHistory.get(),
|
|
159
|
-
],
|
|
160
|
-
temperature: modelConfig.defaultTemperature > -1
|
|
161
|
-
? modelConfig.defaultTemperature
|
|
162
|
-
: undefined,
|
|
163
|
-
stopWhen: stepCountIs(90),
|
|
164
|
-
maxRetries: 2,
|
|
165
|
-
providerOptions: aiConfig.getProviderOptions(),
|
|
166
|
-
tools,
|
|
167
|
-
// biome-ignore lint/style/useNamingConvention: third-party controlled
|
|
168
|
-
experimental_repairToolCall: toolCallRepair(modelManager),
|
|
169
|
-
abortSignal: signal,
|
|
170
|
-
onAbort(_event) {
|
|
171
|
-
logger.warn("The agent loop was aborted by the user.");
|
|
172
|
-
terminal.warn("Operation aborted by user.");
|
|
173
|
-
},
|
|
174
|
-
onFinish: async (result) => {
|
|
175
|
-
logger.debug("onFinish called");
|
|
176
|
-
if (result.response.messages.length > 0) {
|
|
177
|
-
messageHistory.appendResponseMessages(result.response.messages);
|
|
178
|
-
}
|
|
179
|
-
terminal.hr();
|
|
180
|
-
// Notify if configured in project config (acai.json)
|
|
181
|
-
const projectConfig = await configManager.readProjectConfig();
|
|
182
|
-
if (projectConfig.notify) {
|
|
183
|
-
terminal.alert();
|
|
184
|
-
}
|
|
185
|
-
// Create a more visual representation of steps/tool usage
|
|
186
|
-
displayToolUse(result, terminal);
|
|
187
|
-
const total = result.totalUsage ??
|
|
188
|
-
result.usage;
|
|
189
|
-
const inputTokens = isNumber(total.inputTokens)
|
|
190
|
-
? total.inputTokens
|
|
191
|
-
: 0;
|
|
192
|
-
const outputTokens = isNumber(total.outputTokens)
|
|
193
|
-
? total.outputTokens
|
|
194
|
-
: 0;
|
|
195
|
-
const tokenSummary = `Tokens: ↑ ${inputTokens} ↓ ${outputTokens}`;
|
|
196
|
-
terminal.writeln(style.dim(tokenSummary));
|
|
197
|
-
const inputCost = modelConfig.costPerInputToken * inputTokens;
|
|
198
|
-
const outputCost = modelConfig.costPerOutputToken * outputTokens;
|
|
199
|
-
terminal.writeln(style.dim(`Cost: $${(inputCost + outputCost).toFixed(2)}`));
|
|
200
|
-
// Track aggregate usage across all steps when available
|
|
201
|
-
tokenTracker.trackUsage("repl", total);
|
|
202
|
-
// Derive current context window from final step usage
|
|
203
|
-
const finalTotalTokens = result.usage.totalTokens;
|
|
204
|
-
if (isNumber(finalTotalTokens)) {
|
|
205
|
-
currentContextWindow = finalTotalTokens ?? 0;
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
// Fallback: find the stopped step
|
|
209
|
-
for (const step of result.steps) {
|
|
210
|
-
if (step.finishReason === "stop") {
|
|
211
|
-
const usage = step.usage;
|
|
212
|
-
currentContextWindow = Number.isNaN(usage.totalTokens)
|
|
213
|
-
? 0
|
|
214
|
-
: (usage.totalTokens ?? 0);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
terminal.hr();
|
|
219
|
-
},
|
|
220
|
-
onError: ({ error }) => {
|
|
221
|
-
logger.error(error, // Log the full error object
|
|
222
|
-
"Error on REPL streamText");
|
|
223
|
-
terminal.error(error.message.length > 100
|
|
224
|
-
? `${error.message.slice(0, 100)}...`
|
|
225
|
-
: error.message);
|
|
226
|
-
},
|
|
227
|
-
});
|
|
228
|
-
let accumulatedText = "";
|
|
229
|
-
let lastType = null;
|
|
230
|
-
for await (const chunk of result.fullStream) {
|
|
231
|
-
// Handle text-related chunks (reasoning or text-delta)
|
|
232
|
-
if (chunk.type === "reasoning-delta" || chunk.type === "text-delta") {
|
|
233
|
-
if (chunk.type === "reasoning-delta") {
|
|
234
|
-
if (lastType !== "reasoning") {
|
|
235
|
-
terminal.writeln(style.dim("<think>"));
|
|
236
|
-
}
|
|
237
|
-
terminal.write(style.dim(chunk.text)); // Stream reasoning directly
|
|
238
|
-
lastType = "reasoning";
|
|
239
|
-
}
|
|
240
|
-
else if (chunk.type === "text-delta") {
|
|
241
|
-
if (lastType === "reasoning") {
|
|
242
|
-
// Finishing reasoning: Print </think>
|
|
243
|
-
terminal.writeln(style.dim("\n</think>\n"));
|
|
244
|
-
}
|
|
245
|
-
accumulatedText += chunk.text;
|
|
246
|
-
lastType = "text";
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
else if (chunk.type === "tool-call") {
|
|
250
|
-
terminal.stopProgress();
|
|
251
|
-
}
|
|
252
|
-
else if (chunk.type === "tool-result") {
|
|
253
|
-
const messages = toolEvents.get(chunk.toolCallId);
|
|
254
|
-
if (messages) {
|
|
255
|
-
displayToolMessages(messages, terminal);
|
|
256
|
-
toolEvents.delete(chunk.toolCallId);
|
|
257
|
-
}
|
|
258
|
-
else {
|
|
259
|
-
logger.warn(`No tool events found for ${chunk.toolCallId}`);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
// Close thinking tags when moving from reasoning to any other chunk type
|
|
264
|
-
if (lastType === "reasoning") {
|
|
265
|
-
terminal.write(style.dim("\n</think>\n\n"));
|
|
266
|
-
}
|
|
267
|
-
terminal.stopProgress();
|
|
268
|
-
// if there is accumulatedText, display it
|
|
269
|
-
if (accumulatedText.trim()) {
|
|
270
|
-
terminal.writeln(`${style.blue.bold("● Response:")}`);
|
|
271
|
-
terminal.display(accumulatedText, true);
|
|
272
|
-
terminal.lineBreak();
|
|
273
|
-
}
|
|
274
|
-
accumulatedText = "";
|
|
275
|
-
lastType = null;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
// Ensure the final closing tag for reasoning is written if it was the last type
|
|
279
|
-
if (lastType === "reasoning") {
|
|
280
|
-
terminal.write(style.gray("\n</think>\n\n"));
|
|
281
|
-
}
|
|
282
|
-
// if there is accumulatedText, display it
|
|
283
|
-
if (accumulatedText.trim()) {
|
|
284
|
-
terminal.writeln(`${style.green.bold("● Response:")}`);
|
|
285
|
-
terminal.display(accumulatedText, true);
|
|
286
|
-
terminal.lineBreak();
|
|
287
|
-
}
|
|
288
|
-
terminal.lineBreak(); // Add a final newline for clarity
|
|
289
|
-
await result.consumeStream();
|
|
290
|
-
}
|
|
291
|
-
catch (e) {
|
|
292
|
-
if (isRecord(e) && isRecord(e["data"]) && "error" in e["data"]) {
|
|
293
|
-
terminal.error(e["data"]["error"].message);
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
296
|
-
terminal.error(e.message.length > 100
|
|
297
|
-
? `${e.message.slice(0, 100)}...`
|
|
298
|
-
: e.message);
|
|
299
|
-
}
|
|
300
|
-
terminal.lineBreak();
|
|
301
|
-
if (e instanceof Error) {
|
|
302
|
-
logger.error(e);
|
|
303
|
-
}
|
|
304
|
-
else {
|
|
305
|
-
logger.error(JSON.stringify(e, null, 2));
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Standalone checkbox prompt (inquirer-like)
|
|
4
|
-
* - TypeScript version
|
|
5
|
-
*/
|
|
6
|
-
interface TerminalIo {
|
|
7
|
-
stdin: NodeJS.ReadStream;
|
|
8
|
-
stdout: NodeJS.WriteStream;
|
|
9
|
-
}
|
|
10
|
-
interface ChoiceObject<T = unknown> {
|
|
11
|
-
name: string;
|
|
12
|
-
value: T;
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
checked?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export type Choice<T = unknown> = string | ChoiceObject<T>;
|
|
17
|
-
export interface CheckboxOptions<T = unknown> {
|
|
18
|
-
message?: string;
|
|
19
|
-
choices: Choice<T>[];
|
|
20
|
-
initial?: number;
|
|
21
|
-
pageSize?: number;
|
|
22
|
-
loop?: boolean;
|
|
23
|
-
required?: boolean;
|
|
24
|
-
signal?: AbortSignal;
|
|
25
|
-
terminal?: TerminalIo;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Interactive checkbox prompt for selecting multiple options
|
|
29
|
-
* @param options Configuration options for the checkbox prompt
|
|
30
|
-
* @returns Promise resolving to array of selected values
|
|
31
|
-
* @throws {PromptCancelError} When user cancels with Ctrl+C
|
|
32
|
-
* @throws {PromptAbortError} When signal is aborted
|
|
33
|
-
*/
|
|
34
|
-
export declare function checkbox<T = unknown>({ message, choices, initial, pageSize, required, signal, terminal, }: CheckboxOptions<T>): Promise<T[]>;
|
|
35
|
-
export {};
|
|
36
|
-
//# sourceMappingURL=checkbox-prompt.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox-prompt.d.ts","sourceRoot":"","sources":["../../source/terminal/checkbox-prompt.ts"],"names":[],"mappings":";AACA;;;GAGG;AAoCH,UAAU,UAAU;IAClB,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC;CAC5B;AAED,UAAU,YAAY,CAAC,CAAC,GAAG,OAAO;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AACD,MAAM,MAAM,MAAM,CAAC,CAAC,GAAG,OAAO,IAAI,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;AAS3D,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB;AA4GD;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAAC,CAAC,GAAG,OAAO,EAAE,EAC1C,OAAkB,EAClB,OAAO,EACP,OAAW,EACX,QAAY,EACZ,QAAgB,EAChB,MAAM,EACN,QAA2D,GAC5D,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAyPnC"}
|