@travisennis/acai 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +225 -39
- package/dist/agent/index.d.ts +30 -21
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +237 -198
- package/dist/cli.d.ts +4 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +56 -18
- 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/index.js +50 -0
- 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/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} +1 -7
- package/dist/commands/copy/index.d.ts +3 -0
- package/dist/commands/copy/index.d.ts.map +1 -0
- package/dist/commands/copy/index.js +39 -0
- 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/index.d.ts +10 -0
- 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} +65 -147
- 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/utils.js +123 -0
- 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/index.d.ts +3 -0
- package/dist/commands/help/index.d.ts.map +1 -0
- package/dist/commands/{help-command.js → help/index.js} +6 -14
- 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} +40 -200
- 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} +17 -27
- 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} +2 -15
- 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/index.js +89 -0
- package/dist/commands/manager.d.ts +2 -9
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +38 -83
- package/dist/commands/model/index.d.ts +3 -0
- package/dist/commands/model/index.d.ts.map +1 -0
- package/dist/commands/model/index.js +182 -0
- 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/index.d.ts +3 -0
- package/dist/commands/paste/index.d.ts.map +1 -0
- package/dist/commands/paste/index.js +94 -0
- package/dist/commands/paste/utils.d.ts +5 -0
- package/dist/commands/paste/utils.d.ts.map +1 -0
- package/dist/commands/paste/utils.js +86 -0
- package/dist/commands/pickup/index.d.ts +3 -0
- package/dist/commands/pickup/index.d.ts.map +1 -0
- package/dist/commands/pickup/index.js +138 -0
- package/dist/commands/pickup/types.d.ts +6 -0
- package/dist/commands/pickup/types.d.ts.map +1 -0
- package/dist/commands/pickup/types.js +1 -0
- package/dist/commands/pickup/utils.d.ts +7 -0
- package/dist/commands/pickup/utils.d.ts.map +1 -0
- package/dist/commands/pickup/utils.js +56 -0
- package/dist/commands/prompt/index.d.ts +5 -0
- package/dist/commands/prompt/index.d.ts.map +1 -0
- package/dist/commands/prompt/index.js +126 -0
- package/dist/commands/prompt/types.d.ts +15 -0
- package/dist/commands/prompt/types.d.ts.map +1 -0
- package/dist/commands/prompt/types.js +1 -0
- package/dist/commands/prompt/utils.d.ts +12 -0
- package/dist/commands/prompt/utils.d.ts.map +1 -0
- package/dist/commands/prompt/utils.js +107 -0
- package/dist/commands/remove-directory/index.d.ts +3 -0
- package/dist/commands/remove-directory/index.d.ts.map +1 -0
- package/dist/commands/{remove-directory-command.js → remove-directory/index.js} +3 -35
- 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} +8 -11
- 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 -10
- package/dist/commands/session/index.d.ts +3 -0
- package/dist/commands/session/index.d.ts.map +1 -0
- package/dist/commands/session/index.js +197 -0
- package/dist/commands/session/types.d.ts +13 -0
- package/dist/commands/session/types.d.ts.map +1 -0
- package/dist/commands/session/types.js +7 -0
- package/dist/commands/shell/index.d.ts +3 -0
- package/dist/commands/shell/index.d.ts.map +1 -0
- package/dist/commands/{shell-command.js → shell/index.js} +4 -51
- package/dist/commands/types.d.ts +2 -5
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/config.d.ts +36 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +118 -60
- package/dist/dedent.d.ts.map +1 -1
- package/dist/dedent.js +7 -7
- package/dist/execution/index.d.ts +18 -2
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +119 -81
- package/dist/formatting.d.ts +46 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +94 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +299 -177
- 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/anthropic-provider.js +0 -7
- package/dist/models/deepseek-provider.d.ts +9 -8
- 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 +10 -9
- 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 +8 -7
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.js +0 -1
- package/dist/models/manager.d.ts +7 -4
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +5 -25
- package/dist/models/openai-provider.d.ts +11 -10
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +0 -4
- package/dist/models/opencode-zen-provider.d.ts +23 -0
- package/dist/models/opencode-zen-provider.d.ts.map +1 -0
- package/dist/models/opencode-zen-provider.js +76 -0
- package/dist/models/openrouter-provider.d.ts +34 -28
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +148 -139
- package/dist/models/providers.d.ts +6 -16
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +8 -58
- package/dist/models/xai-provider.d.ts +9 -8
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +0 -2
- 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 +8 -4
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +155 -177
- package/dist/repl/project-status.d.ts +19 -0
- package/dist/repl/project-status.d.ts.map +1 -0
- package/dist/repl/project-status.js +78 -0
- package/dist/repl-new.d.ts +15 -6
- package/dist/repl-new.d.ts.map +1 -1
- package/dist/repl-new.js +266 -83
- package/dist/{messages.d.ts → sessions/manager.d.ts} +13 -4
- package/dist/sessions/manager.d.ts.map +1 -0
- package/dist/{messages.js → sessions/manager.js} +126 -16
- package/dist/skills.d.ts +16 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +233 -0
- package/dist/terminal/control.d.ts +56 -0
- package/dist/terminal/control.d.ts.map +1 -0
- package/dist/terminal/control.js +111 -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 -26
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +35 -53
- 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 -101
- package/dist/terminal/index.d.ts.map +1 -1
- package/dist/terminal/index.js +2 -464
- 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/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/tracker.d.ts.map +1 -1
- package/dist/tokens/tracker.js +58 -16
- package/dist/tools/bash.d.ts +11 -11
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +189 -81
- package/dist/tools/directory-tree.d.ts +9 -13
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +90 -60
- package/dist/tools/dynamic-tool-loader.d.ts +22 -8
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +41 -46
- 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 +22 -66
- package/dist/tools/glob.d.ts +15 -16
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +78 -109
- package/dist/tools/grep.d.ts +19 -22
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +61 -93
- package/dist/tools/index.d.ts +202 -167
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +17 -273
- 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 +52 -76
- package/dist/tools/save-file.d.ts +8 -8
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +42 -53
- package/dist/tools/think.d.ts +4 -4
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +9 -32
- package/dist/tools/types.d.ts +5 -21
- 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/assistant-message.js +1 -1
- 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 +87 -0
- package/dist/tui/components/editor.d.ts +61 -7
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +630 -127
- package/dist/tui/components/footer.d.ts +19 -18
- package/dist/tui/components/footer.d.ts.map +1 -1
- package/dist/tui/components/footer.js +90 -185
- 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.map +1 -1
- package/dist/tui/components/input.js +8 -7
- package/dist/tui/components/loader.d.ts +6 -1
- package/dist/tui/components/loader.d.ts.map +1 -1
- package/dist/tui/components/loader.js +8 -3
- package/dist/tui/components/markdown.d.ts +31 -27
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +131 -67
- package/dist/tui/components/modal.d.ts +0 -11
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +9 -37
- package/dist/tui/components/notification.d.ts +28 -0
- package/dist/tui/components/notification.d.ts.map +1 -0
- package/dist/tui/components/notification.js +63 -0
- package/dist/tui/components/progress-bar.d.ts +19 -0
- package/dist/tui/components/progress-bar.d.ts.map +1 -0
- package/dist/tui/components/progress-bar.js +66 -0
- package/dist/tui/components/select-list.d.ts +12 -1
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +73 -32
- package/dist/tui/components/spacer.d.ts +1 -1
- package/dist/tui/components/spacer.d.ts.map +1 -1
- package/dist/tui/components/spacer.js +2 -2
- 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/thinking-block.d.ts.map +1 -1
- package/dist/tui/components/thinking-block.js +4 -1
- package/dist/tui/components/tool-execution.d.ts +7 -6
- package/dist/tui/components/tool-execution.d.ts.map +1 -1
- package/dist/tui/components/tool-execution.js +81 -85
- package/dist/tui/components/user-message.d.ts.map +1 -1
- package/dist/tui/components/user-message.js +6 -4
- package/dist/tui/components/welcome.d.ts +8 -1
- package/dist/tui/components/welcome.d.ts.map +1 -1
- package/dist/tui/components/welcome.js +45 -6
- package/dist/tui/index.d.ts +12 -6
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +7 -3
- package/dist/tui/terminal.d.ts +4 -3
- package/dist/tui/terminal.d.ts.map +1 -1
- package/dist/tui/terminal.js +43 -49
- package/dist/tui/tui.d.ts +3 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +58 -43
- package/dist/tui/utils.d.ts +5 -0
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +80 -1
- package/dist/{tools/bash-utils.d.ts → utils/bash.d.ts} +3 -3
- package/dist/utils/bash.d.ts.map +1 -0
- package/dist/{tools/bash-utils.js → utils/bash.js} +22 -11
- package/dist/utils/{filesystem.d.ts → filesystem/operations.d.ts} +1 -1
- package/dist/utils/filesystem/operations.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.d.ts → utils/filesystem/security.d.ts} +3 -2
- package/dist/utils/filesystem/security.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.js → utils/filesystem/security.js} +62 -4
- 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/{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/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-utils.d.ts → zod.d.ts} +2 -1
- package/dist/utils/zod.d.ts.map +1 -0
- package/dist/utils/zod.js +24 -0
- package/package.json +31 -29
- package/dist/agent/manual-loop.d.ts +0 -41
- package/dist/agent/manual-loop.d.ts.map +0 -1
- package/dist/agent/manual-loop.js +0 -278
- 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/add-directory-command.js +0 -85
- 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 -79
- 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 -64
- 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 -183
- package/dist/commands/copy-command.d.ts +0 -3
- package/dist/commands/copy-command.d.ts.map +0 -1
- package/dist/commands/copy-command.js +0 -80
- 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 -88
- 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 -61
- package/dist/commands/exit-command.d.ts +0 -13
- package/dist/commands/exit-command.d.ts.map +0 -1
- package/dist/commands/exit-command.js +0 -46
- 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 -121
- 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/handoff-command.js +0 -202
- 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 -213
- package/dist/commands/help-command.d.ts +0 -3
- 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 -98
- 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/list-tools-command.js +0 -124
- package/dist/commands/model-command.d.ts +0 -25
- package/dist/commands/model-command.d.ts.map +0 -1
- package/dist/commands/model-command.js +0 -340
- package/dist/commands/paste-command.d.ts +0 -3
- package/dist/commands/paste-command.d.ts.map +0 -1
- package/dist/commands/paste-command.js +0 -277
- 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 -161
- package/dist/commands/prompt-command.d.ts +0 -3
- package/dist/commands/prompt-command.d.ts.map +0 -1
- package/dist/commands/prompt-command.js +0 -280
- 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 -135
- 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 -42
- package/dist/messages.d.ts.map +0 -1
- 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 -58
- 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 -9
- package/dist/repl/project-status-line.d.ts +0 -2
- package/dist/repl/project-status-line.d.ts.map +0 -1
- package/dist/repl/project-status-line.js +0 -31
- package/dist/repl/prompt.d.ts +0 -21
- package/dist/repl/prompt.d.ts.map +0 -1
- package/dist/repl/prompt.js +0 -244
- 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/repl.d.ts +0 -29
- package/dist/repl.d.ts.map +0 -1
- package/dist/repl.js +0 -218
- 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 -368
- 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 -17
- package/dist/terminal/input-prompt.d.ts.map +0 -1
- package/dist/terminal/input-prompt.js +0 -181
- package/dist/terminal/markdown.d.ts +0 -2
- package/dist/terminal/markdown.d.ts.map +0 -1
- package/dist/terminal/markdown.js +0 -118
- 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 -280
- package/dist/terminal/types.d.ts +0 -35
- package/dist/terminal/types.d.ts.map +0 -1
- package/dist/tokens/threshold.d.ts +0 -35
- package/dist/tokens/threshold.d.ts.map +0 -1
- package/dist/tokens/threshold.js +0 -85
- 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 -281
- package/dist/tools/agent.d.ts +0 -29
- package/dist/tools/agent.d.ts.map +0 -1
- package/dist/tools/agent.js +0 -103
- package/dist/tools/bash-utils.d.ts.map +0 -1
- 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 -167
- 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 -70
- 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/filesystem-utils.d.ts.map +0 -1
- package/dist/tools/git-utils.d.ts.map +0 -1
- package/dist/tools/llm-edit-fixer.d.ts +0 -25
- package/dist/tools/llm-edit-fixer.d.ts.map +0 -1
- package/dist/tools/llm-edit-fixer.js +0 -150
- 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 -58
- 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 -139
- 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 -133
- package/dist/tui/components/prompt-status.d.ts +0 -16
- package/dist/tui/components/prompt-status.d.ts.map +0 -1
- package/dist/tui/components/prompt-status.js +0 -21
- package/dist/utils/filesystem.d.ts.map +0 -1
- package/dist/utils/zod-utils.d.ts.map +0 -1
- package/dist/utils/zod-utils.js +0 -7
- /package/dist/{terminal → commands/add-directory}/types.js +0 -0
- /package/dist/utils/{filesystem.js → filesystem/operations.js} +0 -0
package/dist/repl-new.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { logger } from "./logger.js";
|
|
1
2
|
import { PromptError, processPrompt } from "./mentions.js";
|
|
2
|
-
import {
|
|
3
|
+
import { getProjectStatus, } from "./repl/project-status.js";
|
|
4
|
+
import { alert, startProgress, stopProgress } from "./terminal/control.js";
|
|
5
|
+
import style from "./terminal/style.js";
|
|
3
6
|
import { AssistantMessageComponent } from "./tui/components/assistant-message.js";
|
|
4
7
|
import { FooterComponent } from "./tui/components/footer.js";
|
|
5
|
-
import { PromptStatusComponent } from "./tui/components/prompt-status.js";
|
|
6
8
|
import { ThinkingBlockComponent } from "./tui/components/thinking-block.js";
|
|
7
9
|
import { ToolExecutionComponent } from "./tui/components/tool-execution.js";
|
|
8
10
|
import { Welcome } from "./tui/components/welcome.js";
|
|
9
|
-
import {
|
|
11
|
+
import { Container, Editor, Loader, NotificationComponent, ProcessTerminal, Spacer, Text, TUI, UserMessageComponent, } from "./tui/index.js";
|
|
10
12
|
export class NewRepl {
|
|
11
13
|
options;
|
|
12
14
|
tui;
|
|
@@ -14,15 +16,18 @@ export class NewRepl {
|
|
|
14
16
|
editor;
|
|
15
17
|
chatContainer;
|
|
16
18
|
statusContainer;
|
|
17
|
-
promptStatus;
|
|
18
19
|
footer;
|
|
19
20
|
editorContainer; // Container to swap between editor and selector
|
|
21
|
+
notification;
|
|
20
22
|
isInitialized;
|
|
21
23
|
onInputCallback;
|
|
22
24
|
loadingAnimation = null;
|
|
23
25
|
onInterruptCallback;
|
|
26
|
+
onExitCallback;
|
|
24
27
|
lastSigintTime = 0;
|
|
28
|
+
exitNotificationTimer;
|
|
25
29
|
pendingTools;
|
|
30
|
+
tools;
|
|
26
31
|
// Streaming message tracking
|
|
27
32
|
streamingComponent = null;
|
|
28
33
|
// thinking block tracking
|
|
@@ -30,43 +35,65 @@ export class NewRepl {
|
|
|
30
35
|
constructor(options) {
|
|
31
36
|
this.options = options;
|
|
32
37
|
this.tui = new TUI(new ProcessTerminal());
|
|
33
|
-
this.welcome = new Welcome();
|
|
34
|
-
this.editor = new Editor(
|
|
38
|
+
this.welcome = new Welcome({ type: "simple" });
|
|
39
|
+
this.editor = new Editor({
|
|
40
|
+
borderColor: style.gray,
|
|
41
|
+
});
|
|
35
42
|
this.chatContainer = new Container();
|
|
36
43
|
this.statusContainer = new Container();
|
|
37
44
|
this.editorContainer = new Container(); // Container to hold editor or selector
|
|
38
|
-
this.footer = new FooterComponent(options.
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
this.footer = new FooterComponent(options.modelManager, {
|
|
46
|
+
projectStatus: {
|
|
47
|
+
path: "",
|
|
48
|
+
isGitRepository: false,
|
|
49
|
+
fileChanges: { added: 0, modified: 0, deleted: 0, untracked: 0 },
|
|
50
|
+
diffStats: { insertions: 0, deletions: 0 },
|
|
51
|
+
hasChanges: false,
|
|
52
|
+
},
|
|
41
53
|
currentContextWindow: 0,
|
|
42
54
|
contextWindow: options.modelManager.getModelMetadata("repl").contextWindow,
|
|
55
|
+
usage: this.options.tokenTracker.getUsageByApp("repl"),
|
|
43
56
|
});
|
|
44
57
|
this.editorContainer.addChild(this.editor); // Start with editor
|
|
45
58
|
this.editor.onRenderRequested = () => this.tui.requestRender();
|
|
46
59
|
this.isInitialized = false;
|
|
47
60
|
this.pendingTools = new Map();
|
|
61
|
+
this.tools = options.tools;
|
|
62
|
+
this.notification = new NotificationComponent("", { r: 64, g: 64, b: 64 }, style.yellow, 1);
|
|
48
63
|
}
|
|
49
64
|
async init() {
|
|
50
65
|
if (this.isInitialized) {
|
|
51
66
|
return;
|
|
52
67
|
}
|
|
53
68
|
// Setup autocomplete for file paths and slash commands
|
|
54
|
-
const
|
|
69
|
+
const { createDefaultProvider } = await import("./tui/autocomplete.js");
|
|
70
|
+
const autocompleteProvider = createDefaultProvider([...(await this.options.commands.getCompletions())], this.options.workspace.allowedDirs);
|
|
55
71
|
this.editor.setAutocompleteProvider(autocompleteProvider);
|
|
56
|
-
const { promptManager,
|
|
72
|
+
const { promptManager, modelManager, messageHistory, commands, promptHistory, } = this.options;
|
|
73
|
+
// Listen for session title updates
|
|
74
|
+
// messageHistory.on("update-title", (title: string) => {
|
|
75
|
+
// this.footer.setTitle(title);
|
|
76
|
+
// this.tui.requestRender();
|
|
77
|
+
// });
|
|
57
78
|
const modelConfig = modelManager.getModelMetadata("repl");
|
|
58
|
-
this.
|
|
59
|
-
projectStatus: await
|
|
79
|
+
this.footer.setState({
|
|
80
|
+
projectStatus: await getProjectStatus(),
|
|
60
81
|
currentContextWindow: 0,
|
|
61
82
|
contextWindow: modelConfig.contextWindow,
|
|
83
|
+
usage: this.options.tokenTracker.getUsageByApp("repl"),
|
|
62
84
|
});
|
|
85
|
+
this.tui.onCtrlC = () => {
|
|
86
|
+
this.handleCtrlC();
|
|
87
|
+
};
|
|
63
88
|
this.tui.addChild(this.welcome);
|
|
89
|
+
// Initialize footer with current title if one exists
|
|
90
|
+
// this.footer.setTitle(messageHistory.getTitle());
|
|
64
91
|
this.tui.addChild(this.chatContainer);
|
|
65
92
|
this.tui.addChild(this.statusContainer);
|
|
66
93
|
this.tui.addChild(new Spacer(1));
|
|
67
|
-
this.tui.addChild(this.footer);
|
|
68
94
|
this.tui.addChild(this.editorContainer); // Use container that can hold editor or selector
|
|
69
|
-
this.tui.addChild(this.
|
|
95
|
+
this.tui.addChild(this.footer);
|
|
96
|
+
this.tui.addChild(this.notification);
|
|
70
97
|
this.tui.setFocus(this.editor);
|
|
71
98
|
// Set up custom key handlers on the editor
|
|
72
99
|
this.editor.onEscape = () => {
|
|
@@ -75,21 +102,18 @@ export class NewRepl {
|
|
|
75
102
|
this.onInterruptCallback();
|
|
76
103
|
}
|
|
77
104
|
};
|
|
78
|
-
this.editor.onCtrlC = () => {
|
|
79
|
-
this.handleCtrlC();
|
|
80
|
-
};
|
|
81
105
|
// Create editor for input
|
|
82
106
|
this.editor.onSubmit = async (text) => {
|
|
83
107
|
if (text.trim()) {
|
|
84
108
|
// see if the text contains a command
|
|
85
|
-
const commandResult = await commands.
|
|
109
|
+
const commandResult = await commands.handle({ userInput: text }, {
|
|
86
110
|
tui: this.tui,
|
|
87
111
|
container: this.chatContainer,
|
|
88
112
|
inputContainer: this.editorContainer,
|
|
89
113
|
editor: this.editor,
|
|
90
114
|
});
|
|
91
115
|
if (commandResult.break) {
|
|
92
|
-
this.stop();
|
|
116
|
+
this.stop(true);
|
|
93
117
|
process.exit(0);
|
|
94
118
|
}
|
|
95
119
|
if (commandResult.continue) {
|
|
@@ -110,12 +134,12 @@ export class NewRepl {
|
|
|
110
134
|
}
|
|
111
135
|
catch (error) {
|
|
112
136
|
if (error instanceof PromptError) {
|
|
113
|
-
|
|
137
|
+
this.chatContainer.addChild(new Text(style.red(`Prompt processing failed: ${error.message}`), 1, 1));
|
|
114
138
|
if (error.cause &&
|
|
115
139
|
typeof error.cause === "object" &&
|
|
116
140
|
"command" in error.cause &&
|
|
117
141
|
typeof error.cause.command === "string") {
|
|
118
|
-
|
|
142
|
+
this.chatContainer.addChild(new Text(style.red(`Command: ${error.cause.command}`, 1, 1)));
|
|
119
143
|
}
|
|
120
144
|
}
|
|
121
145
|
throw error; // Re-throw other errors
|
|
@@ -123,13 +147,13 @@ export class NewRepl {
|
|
|
123
147
|
}
|
|
124
148
|
else {
|
|
125
149
|
promptHistory.push(promptManager.get());
|
|
150
|
+
this.editor.addToHistory(promptManager.get());
|
|
126
151
|
}
|
|
127
152
|
// flag to see if the user prompt has added context
|
|
128
153
|
const hasAddedContext = promptManager.hasContext();
|
|
129
154
|
if (hasAddedContext) {
|
|
130
155
|
const contextTokenCount = promptManager.getContextTokenCount();
|
|
131
|
-
|
|
132
|
-
terminal.lineBreak();
|
|
156
|
+
this.chatContainer.addChild(new Text(style.green(`Context will be added to prompt. (${contextTokenCount} tokens)`)));
|
|
133
157
|
}
|
|
134
158
|
const userPrompt = promptManager.get();
|
|
135
159
|
const userMsg = promptManager.getUserMessage();
|
|
@@ -148,32 +172,37 @@ export class NewRepl {
|
|
|
148
172
|
await this.init();
|
|
149
173
|
}
|
|
150
174
|
// Update footer with current stats
|
|
151
|
-
this.footer.updateState(state);
|
|
152
|
-
this.
|
|
153
|
-
projectStatus: await
|
|
154
|
-
currentContextWindow:
|
|
175
|
+
// this.footer.updateState(state);
|
|
176
|
+
this.footer.setState({
|
|
177
|
+
projectStatus: await getProjectStatus(),
|
|
178
|
+
currentContextWindow: this.options.messageHistory.getContextWindow(),
|
|
155
179
|
contextWindow: this.options.modelManager.getModelMetadata("repl").contextWindow,
|
|
180
|
+
agentState: state,
|
|
181
|
+
usage: this.options.tokenTracker.getUsageByApp("repl"),
|
|
156
182
|
});
|
|
157
183
|
const eventType = event.type;
|
|
158
184
|
switch (eventType) {
|
|
159
185
|
case "agent-start":
|
|
160
|
-
//
|
|
186
|
+
// start the terminal progress display
|
|
187
|
+
startProgress();
|
|
188
|
+
// disable the submit functionality of the editor
|
|
161
189
|
this.editor.disableSubmit = true;
|
|
162
190
|
// Stop old loader before clearing
|
|
163
191
|
if (this.loadingAnimation) {
|
|
164
192
|
this.loadingAnimation.stop();
|
|
165
193
|
}
|
|
166
194
|
this.statusContainer.clear();
|
|
195
|
+
// Show loading animation
|
|
167
196
|
this.loadingAnimation = new Loader(this.tui, "Working... (esc to interrupt)");
|
|
168
197
|
this.statusContainer.addChild(this.loadingAnimation);
|
|
169
198
|
this.tui.requestRender();
|
|
170
199
|
break;
|
|
171
200
|
case "step-start":
|
|
172
|
-
this.tui.requestRender();
|
|
201
|
+
// this.tui.requestRender();
|
|
173
202
|
break;
|
|
174
203
|
case "step-stop":
|
|
175
|
-
this.pendingTools.clear();
|
|
176
|
-
this.tui.requestRender();
|
|
204
|
+
// this.pendingTools.clear();
|
|
205
|
+
// this.tui.requestRender();
|
|
177
206
|
break;
|
|
178
207
|
case "message-start":
|
|
179
208
|
if (event.role === "assistant") {
|
|
@@ -204,59 +233,28 @@ export class NewRepl {
|
|
|
204
233
|
if (this.streamingComponent && event.role === "assistant") {
|
|
205
234
|
this.streamingComponent.updateContent(event);
|
|
206
235
|
this.streamingComponent = null;
|
|
207
|
-
}
|
|
208
|
-
this.tui.requestRender();
|
|
209
|
-
break;
|
|
210
|
-
case "tool-call-start": {
|
|
211
|
-
// Create tool component for new tool call
|
|
212
|
-
const component = this.pendingTools.get(event.toolCallId);
|
|
213
|
-
if (component) {
|
|
214
|
-
component.update(event);
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
const newComponent = new ToolExecutionComponent(event);
|
|
218
|
-
this.pendingTools.set(event.toolCallId, newComponent);
|
|
219
|
-
this.chatContainer.addChild(newComponent);
|
|
220
|
-
}
|
|
221
|
-
this.tui.requestRender();
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
case "tool-call-end": {
|
|
225
|
-
// Update the existing tool component with the result
|
|
226
|
-
const component = this.pendingTools.get(event.toolCallId);
|
|
227
|
-
if (component) {
|
|
228
|
-
component.update(event);
|
|
229
|
-
this.pendingTools.delete(event.toolCallId);
|
|
230
236
|
this.tui.requestRender();
|
|
231
237
|
}
|
|
232
238
|
break;
|
|
233
|
-
|
|
234
|
-
case "tool-call-update": {
|
|
235
|
-
// Update the existing tool component with the result
|
|
239
|
+
case "tool-call-lifecycle": {
|
|
236
240
|
const component = this.pendingTools.get(event.toolCallId);
|
|
237
241
|
if (component) {
|
|
238
|
-
component.update(event);
|
|
242
|
+
component.update(event.events);
|
|
239
243
|
}
|
|
240
244
|
else {
|
|
241
|
-
//
|
|
242
|
-
const newComponent = new ToolExecutionComponent(event);
|
|
245
|
+
// Create tool component for new tool call
|
|
246
|
+
const newComponent = new ToolExecutionComponent(event.events);
|
|
243
247
|
this.pendingTools.set(event.toolCallId, newComponent);
|
|
244
248
|
this.chatContainer.addChild(newComponent);
|
|
245
249
|
}
|
|
246
250
|
this.tui.requestRender();
|
|
247
251
|
break;
|
|
248
252
|
}
|
|
249
|
-
case "tool-call-error": {
|
|
250
|
-
// Update the existing tool component with the result
|
|
251
|
-
const component = this.pendingTools.get(event.toolCallId);
|
|
252
|
-
if (component) {
|
|
253
|
-
component.update(event);
|
|
254
|
-
this.pendingTools.delete(event.toolCallId);
|
|
255
|
-
this.tui.requestRender();
|
|
256
|
-
}
|
|
257
|
-
break;
|
|
258
|
-
}
|
|
259
253
|
case "agent-stop":
|
|
254
|
+
// stop the terminal progress display
|
|
255
|
+
stopProgress();
|
|
256
|
+
// send a terminal alert to indicate the agent is done
|
|
257
|
+
await alert();
|
|
260
258
|
// Stop loading animation
|
|
261
259
|
if (this.loadingAnimation) {
|
|
262
260
|
this.loadingAnimation.stop();
|
|
@@ -272,6 +270,7 @@ export class NewRepl {
|
|
|
272
270
|
this.tui.requestRender();
|
|
273
271
|
break;
|
|
274
272
|
case "agent-error":
|
|
273
|
+
logger.error(event, "agent-error");
|
|
275
274
|
// Stop loading animation
|
|
276
275
|
if (this.loadingAnimation) {
|
|
277
276
|
this.loadingAnimation.stop();
|
|
@@ -297,15 +296,15 @@ export class NewRepl {
|
|
|
297
296
|
case "thinking":
|
|
298
297
|
if (this.thinkingBlockComponent) {
|
|
299
298
|
this.thinkingBlockComponent.updateContent(event);
|
|
299
|
+
this.tui.requestRender();
|
|
300
300
|
}
|
|
301
|
-
this.tui.requestRender();
|
|
302
301
|
break;
|
|
303
302
|
case "thinking-end":
|
|
304
303
|
if (this.thinkingBlockComponent) {
|
|
305
304
|
this.thinkingBlockComponent.updateContent(event);
|
|
306
305
|
this.thinkingBlockComponent = null;
|
|
306
|
+
this.tui.requestRender();
|
|
307
307
|
}
|
|
308
|
-
this.tui.requestRender();
|
|
309
308
|
break;
|
|
310
309
|
default:
|
|
311
310
|
eventType;
|
|
@@ -336,32 +335,216 @@ export class NewRepl {
|
|
|
336
335
|
setInterruptCallback(callback) {
|
|
337
336
|
this.onInterruptCallback = callback;
|
|
338
337
|
}
|
|
338
|
+
setExitCallback(callback) {
|
|
339
|
+
this.onExitCallback = callback;
|
|
340
|
+
}
|
|
339
341
|
async rerender() {
|
|
340
|
-
this.footer.
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
currentContextWindow: this.options.agent.state.usage.totalTokens,
|
|
342
|
+
this.footer.setState({
|
|
343
|
+
projectStatus: await getProjectStatus(),
|
|
344
|
+
currentContextWindow: this.options.messageHistory.getContextWindow(),
|
|
344
345
|
contextWindow: this.options.modelManager.getModelMetadata("repl").contextWindow,
|
|
346
|
+
usage: this.options.tokenTracker.getUsageByApp("repl"),
|
|
345
347
|
});
|
|
348
|
+
// Reconstruct entire session display from messages
|
|
349
|
+
this.reconstructSession();
|
|
346
350
|
this.tui.requestRender();
|
|
347
351
|
}
|
|
352
|
+
reconstructSession() {
|
|
353
|
+
// Clear existing display
|
|
354
|
+
this.pendingTools.clear();
|
|
355
|
+
this.chatContainer.clear();
|
|
356
|
+
// Get session messages
|
|
357
|
+
const messages = this.options.messageHistory.get();
|
|
358
|
+
// First pass: collect all tool results
|
|
359
|
+
const toolResults = new Map();
|
|
360
|
+
for (const message of messages) {
|
|
361
|
+
if (message.role !== "tool")
|
|
362
|
+
continue;
|
|
363
|
+
const content = message.content;
|
|
364
|
+
if (!Array.isArray(content))
|
|
365
|
+
continue;
|
|
366
|
+
for (const part of content) {
|
|
367
|
+
if (part.type === "tool-result") {
|
|
368
|
+
const output = part.output;
|
|
369
|
+
const outputValue = output && typeof output === "object" && "value" in output
|
|
370
|
+
? String(output.value)
|
|
371
|
+
: "";
|
|
372
|
+
toolResults.set(part.toolCallId, {
|
|
373
|
+
toolName: part.toolName,
|
|
374
|
+
outputValue,
|
|
375
|
+
isError: false,
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
// Second pass: render all messages in order
|
|
381
|
+
for (let i = 0; i < messages.length; i++) {
|
|
382
|
+
const message = messages[i];
|
|
383
|
+
if (message.role === "user") {
|
|
384
|
+
// Render user message
|
|
385
|
+
const textContent = this.extractUserMessageText(message);
|
|
386
|
+
if (textContent) {
|
|
387
|
+
const userComponent = new UserMessageComponent(textContent);
|
|
388
|
+
this.chatContainer.addChild(userComponent);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
else if (message.role === "assistant") {
|
|
392
|
+
// Render assistant message text parts
|
|
393
|
+
this.renderAssistantMessage(message);
|
|
394
|
+
// Collect and render tool calls for this assistant message
|
|
395
|
+
const toolCallsForThisAssistant = this.extractToolCallsFromAssistant(message, toolResults);
|
|
396
|
+
for (const toolCallContent of toolCallsForThisAssistant) {
|
|
397
|
+
const toolCallId = toolCallContent.toolCallId;
|
|
398
|
+
const events = this.createToolEvents(toolCallContent);
|
|
399
|
+
if (events.length > 0) {
|
|
400
|
+
const component = new ToolExecutionComponent(events);
|
|
401
|
+
this.pendingTools.set(toolCallId, component);
|
|
402
|
+
this.chatContainer.addChild(component);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
// Tool messages are handled through their associated assistant message
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
extractUserMessageText(message) {
|
|
410
|
+
if (typeof message.content === "string") {
|
|
411
|
+
return message.content;
|
|
412
|
+
}
|
|
413
|
+
if (Array.isArray(message.content)) {
|
|
414
|
+
const textParts = message.content
|
|
415
|
+
.filter((part) => part.type === "text" && part.text?.trim() !== undefined)
|
|
416
|
+
.map((part) => part.text);
|
|
417
|
+
return textParts.join("\n");
|
|
418
|
+
}
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
421
|
+
renderAssistantMessage(message) {
|
|
422
|
+
if (typeof message.content === "string") {
|
|
423
|
+
if (message.content.trim()) {
|
|
424
|
+
const assistantComponent = new AssistantMessageComponent();
|
|
425
|
+
assistantComponent.updateContent({
|
|
426
|
+
type: "message",
|
|
427
|
+
role: "assistant",
|
|
428
|
+
content: message.content,
|
|
429
|
+
});
|
|
430
|
+
this.chatContainer.addChild(assistantComponent);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
else if (Array.isArray(message.content)) {
|
|
434
|
+
const textParts = message.content
|
|
435
|
+
.filter((part) => part.type === "text" && part.text?.trim() !== undefined)
|
|
436
|
+
.map((part) => part.text)
|
|
437
|
+
.join("\n");
|
|
438
|
+
if (textParts.trim()) {
|
|
439
|
+
const assistantComponent = new AssistantMessageComponent();
|
|
440
|
+
assistantComponent.updateContent({
|
|
441
|
+
type: "message",
|
|
442
|
+
role: "assistant",
|
|
443
|
+
content: textParts,
|
|
444
|
+
});
|
|
445
|
+
this.chatContainer.addChild(assistantComponent);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
extractToolCallsFromAssistant(message, toolResults) {
|
|
450
|
+
const toolCallContents = [];
|
|
451
|
+
if (typeof message.content === "string") {
|
|
452
|
+
return toolCallContents;
|
|
453
|
+
}
|
|
454
|
+
if (!Array.isArray(message.content)) {
|
|
455
|
+
return toolCallContents;
|
|
456
|
+
}
|
|
457
|
+
for (const part of message.content) {
|
|
458
|
+
if (part.type === "tool-call" && part.toolName && part.toolCallId) {
|
|
459
|
+
const result = toolResults.get(part.toolCallId);
|
|
460
|
+
if (result) {
|
|
461
|
+
toolCallContents.push({
|
|
462
|
+
toolName: part.toolName,
|
|
463
|
+
toolCallId: part.toolCallId,
|
|
464
|
+
input: part.input,
|
|
465
|
+
outputValue: result.outputValue,
|
|
466
|
+
isError: result.isError,
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
return toolCallContents;
|
|
472
|
+
}
|
|
473
|
+
createToolEvents(toolCallContent) {
|
|
474
|
+
const events = [];
|
|
475
|
+
// tool-call-start: use the tool's display function
|
|
476
|
+
let startMsg = toolCallContent.toolName;
|
|
477
|
+
if (this.tools && toolCallContent.toolName in this.tools) {
|
|
478
|
+
const tool = this.tools[toolCallContent.toolName];
|
|
479
|
+
if ("display" in tool && typeof tool.display === "function") {
|
|
480
|
+
// biome-ignore lint/suspicious/noExplicitAny: tool display expects tool-specific input
|
|
481
|
+
startMsg = tool.display(toolCallContent.input);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
events.push({
|
|
485
|
+
type: "tool-call-start",
|
|
486
|
+
name: toolCallContent.toolName,
|
|
487
|
+
toolCallId: toolCallContent.toolCallId,
|
|
488
|
+
msg: startMsg,
|
|
489
|
+
args: toolCallContent.input,
|
|
490
|
+
});
|
|
491
|
+
// tool-call-end or tool-call-error
|
|
492
|
+
events.push({
|
|
493
|
+
type: toolCallContent.isError ? "tool-call-error" : "tool-call-end",
|
|
494
|
+
name: toolCallContent.toolName,
|
|
495
|
+
toolCallId: toolCallContent.toolCallId,
|
|
496
|
+
msg: toolCallContent.outputValue,
|
|
497
|
+
args: toolCallContent.input,
|
|
498
|
+
});
|
|
499
|
+
return events;
|
|
500
|
+
}
|
|
348
501
|
handleCtrlC() {
|
|
349
502
|
// Handle Ctrl+C double-press logic
|
|
350
503
|
const now = Date.now();
|
|
351
504
|
const timeSinceLastCtrlC = now - this.lastSigintTime;
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
505
|
+
const DoublePressThreshold = 1000; // 1 second
|
|
506
|
+
if (timeSinceLastCtrlC < DoublePressThreshold) {
|
|
507
|
+
// Second Ctrl+C within threshold - exit
|
|
508
|
+
// Clear notification before exiting
|
|
509
|
+
if (this.exitNotificationTimer) {
|
|
510
|
+
clearTimeout(this.exitNotificationTimer);
|
|
511
|
+
this.exitNotificationTimer = undefined;
|
|
512
|
+
}
|
|
513
|
+
this.notification.setMessage("");
|
|
514
|
+
this.tui.requestRender();
|
|
515
|
+
void this.options.messageHistory.save();
|
|
516
|
+
this.stop(true);
|
|
356
517
|
process.exit(0);
|
|
357
518
|
}
|
|
358
519
|
else {
|
|
359
|
-
// First Ctrl+C - clear the editor
|
|
520
|
+
// First Ctrl+C - clear the editor and show notification
|
|
360
521
|
this.clearEditor();
|
|
522
|
+
this.notification.setMessage("Press Ctrl+C again to exit");
|
|
523
|
+
this.tui.requestRender();
|
|
361
524
|
this.lastSigintTime = now;
|
|
525
|
+
// Clear notification after threshold if no second Ctrl+C
|
|
526
|
+
if (this.exitNotificationTimer) {
|
|
527
|
+
clearTimeout(this.exitNotificationTimer);
|
|
528
|
+
}
|
|
529
|
+
this.exitNotificationTimer = setTimeout(() => {
|
|
530
|
+
if (this.isInitialized) {
|
|
531
|
+
this.notification.setMessage("");
|
|
532
|
+
this.exitNotificationTimer = undefined;
|
|
533
|
+
this.tui.requestRender();
|
|
534
|
+
}
|
|
535
|
+
}, DoublePressThreshold);
|
|
362
536
|
}
|
|
363
537
|
}
|
|
364
|
-
stop() {
|
|
538
|
+
stop(showExitMessage = false) {
|
|
539
|
+
this.notification.setMessage("");
|
|
540
|
+
// Clear any pending notification timer
|
|
541
|
+
if (this.exitNotificationTimer) {
|
|
542
|
+
clearTimeout(this.exitNotificationTimer);
|
|
543
|
+
this.exitNotificationTimer = undefined;
|
|
544
|
+
}
|
|
545
|
+
if (showExitMessage && this.onExitCallback) {
|
|
546
|
+
this.onExitCallback(this.options.messageHistory.getSessionId());
|
|
547
|
+
}
|
|
365
548
|
if (this.loadingAnimation) {
|
|
366
549
|
this.loadingAnimation.stop();
|
|
367
550
|
this.loadingAnimation = null;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import EventEmitter from "node:events";
|
|
2
2
|
import { type AssistantModelMessage, type ImagePart, // Added ImagePart
|
|
3
3
|
type ModelMessage, type ToolModelMessage, type UserModelMessage } from "ai";
|
|
4
|
-
import type { ModelManager } from "
|
|
5
|
-
import type { TokenTracker } from "
|
|
4
|
+
import type { ModelManager } from "../models/manager.ts";
|
|
5
|
+
import type { TokenTracker } from "../tokens/tracker.ts";
|
|
6
6
|
export type UserMessageContentItem = string | ImagePart;
|
|
7
7
|
export declare function createUserMessage(contentItems: UserMessageContentItem[], prompt?: string): UserModelMessage;
|
|
8
8
|
/**
|
|
@@ -23,7 +23,7 @@ interface MessageHistoryEvents {
|
|
|
23
23
|
"update-title": [string];
|
|
24
24
|
"clear-history": [];
|
|
25
25
|
}
|
|
26
|
-
export declare class
|
|
26
|
+
export declare class SessionManager extends EventEmitter<MessageHistoryEvents> {
|
|
27
27
|
private history;
|
|
28
28
|
private sessionId;
|
|
29
29
|
private modelId;
|
|
@@ -31,6 +31,7 @@ export declare class MessageHistory extends EventEmitter<MessageHistoryEvents> {
|
|
|
31
31
|
private createdAt;
|
|
32
32
|
private updatedAt;
|
|
33
33
|
private stateDir;
|
|
34
|
+
private contextWindow;
|
|
34
35
|
private modelManager;
|
|
35
36
|
private tokenTracker;
|
|
36
37
|
constructor({ stateDir, modelManager, tokenTracker, }: {
|
|
@@ -39,9 +40,12 @@ export declare class MessageHistory extends EventEmitter<MessageHistoryEvents> {
|
|
|
39
40
|
tokenTracker: TokenTracker;
|
|
40
41
|
});
|
|
41
42
|
create(modelId: string): void;
|
|
43
|
+
setModelId(modelId: string): void;
|
|
42
44
|
private validMessage;
|
|
43
45
|
get(): ModelMessage[];
|
|
44
46
|
clear(): void;
|
|
47
|
+
setContextWindow(contextWindow: number): void;
|
|
48
|
+
getContextWindow(): number;
|
|
45
49
|
appendUserMessage(msg: string): void;
|
|
46
50
|
appendUserMessage(msg: UserModelMessage): void;
|
|
47
51
|
appendAssistantMessage(msg: string): void;
|
|
@@ -58,8 +62,13 @@ export declare class MessageHistory extends EventEmitter<MessageHistoryEvents> {
|
|
|
58
62
|
* Prioritizes assistant messages, falls back to user messages if no assistant messages exist.
|
|
59
63
|
*/
|
|
60
64
|
getLastMessage(): string | null;
|
|
65
|
+
getSessionId(): string;
|
|
66
|
+
getModelId(): string;
|
|
67
|
+
getTitle(): string;
|
|
68
|
+
getCreatedAt(): Date;
|
|
69
|
+
getUpdatedAt(): Date;
|
|
61
70
|
static load(stateDir: string, count?: number): Promise<SavedMessageHistory[]>;
|
|
62
71
|
restore(savedHistory: SavedMessageHistory): void;
|
|
63
72
|
}
|
|
64
73
|
export {};
|
|
65
|
-
//# sourceMappingURL=
|
|
74
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../source/sessions/manager.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,aAAa,CAAC;AAYvC,OAAO,EACL,KAAK,qBAAqB,EAE1B,KAAK,SAAS,EAAE,kBAAkB;AAClC,KAAK,YAAY,EAEjB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,IAAI,CAAC;AAGZ,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,SAAS,CAAC;AAExD,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,sBAAsB,EAAE,EACtC,MAAM,CAAC,EAAE,MAAM,GACd,gBAAgB,CAuBlB;AAcD;;;GAGG;AACH,KAAK,eAAe,GAAG,qBAAqB,GAAG,gBAAgB,CAAC;AAEhE,KAAK,mBAAmB,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,YAAY,EAAE,CAAC;CAC1B,CAAC;AAUF,UAAU,oBAAoB;IAC5B,cAAc,EAAE,CAAC,MAAM,CAAC,CAAC;IACzB,eAAe,EAAE,EAAE,CAAC;CACrB;AAED,qBAAa,cAAe,SAAQ,YAAY,CAAC,oBAAoB,CAAC;IACpE,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,SAAS,CAAO;IACxB,OAAO,CAAC,SAAS,CAAO;IACxB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,YAAY,CAAe;gBAEvB,EACV,QAAQ,EACR,YAAY,EACZ,YAAY,GACb,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,YAAY,CAAC;QAC3B,YAAY,EAAE,YAAY,CAAC;KAC5B;IAcD,MAAM,CAAC,OAAO,EAAE,MAAM;IAStB,UAAU,CAAC,OAAO,EAAE,MAAM;IAI1B,OAAO,CAAC,YAAY;IAoBpB,GAAG;IAIH,KAAK;IAML,gBAAgB,CAAC,aAAa,EAAE,MAAM;IAOtC,gBAAgB;IAIhB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IACpC,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI;IAmB9C,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IACzC,sBAAsB,CAAC,GAAG,EAAE,qBAAqB,GAAG,IAAI;IAOxD,kBAAkB,CAAC,kBAAkB,EAAE,gBAAgB,EAAE;IAKzD,sBAAsB,CAAC,gBAAgB,EAAE,eAAe,EAAE;IAO1D,OAAO;IAID,IAAI;YA+DI,aAAa;IA6D3B,mBAAmB,IAAI,gBAAgB,GAAG,SAAS;IAOnD,kBAAkB,IAAI,gBAAgB,GAAG,SAAS;IAOlD;;;OAGG;IACH,cAAc,IAAI,MAAM,GAAG,IAAI;IA4C/B,YAAY,IAAI,MAAM;IAItB,UAAU,IAAI,MAAM;IAIpB,QAAQ,IAAI,MAAM;IAIlB,YAAY,IAAI,IAAI;IAIpB,YAAY,IAAI,IAAI;WAIP,IAAI,CACf,QAAQ,EAAE,MAAM,EAChB,KAAK,SAAK,GACT,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAiGjC,OAAO,CAAC,YAAY,EAAE,mBAAmB,GAAG,IAAI;CAajD"}
|