@phi-code-admin/phi-code 0.56.3
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/CHANGELOG.md +2994 -0
- package/README.md +567 -0
- package/dist/cli/args.d.ts +48 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +299 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/config-selector.d.ts +14 -0
- package/dist/cli/config-selector.d.ts.map +1 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/config-selector.js.map +1 -0
- package/dist/cli/file-processor.d.ts +15 -0
- package/dist/cli/file-processor.d.ts.map +1 -0
- package/dist/cli/file-processor.js +79 -0
- package/dist/cli/file-processor.js.map +1 -0
- package/dist/cli/list-models.d.ts +9 -0
- package/dist/cli/list-models.d.ts.map +1 -0
- package/dist/cli/list-models.js +92 -0
- package/dist/cli/list-models.js.map +1 -0
- package/dist/cli/session-picker.d.ts +9 -0
- package/dist/cli/session-picker.d.ts.map +1 -0
- package/dist/cli/session-picker.js +34 -0
- package/dist/cli/session-picker.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +16 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +68 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +203 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-session.d.ts +614 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +2475 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/auth-storage.d.ts +134 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +415 -0
- package/dist/core/auth-storage.js.map +1 -0
- package/dist/core/bash-executor.d.ts +47 -0
- package/dist/core/bash-executor.d.ts.map +1 -0
- package/dist/core/bash-executor.js +212 -0
- package/dist/core/bash-executor.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +86 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/core/compaction/branch-summarization.js +242 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +121 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -0
- package/dist/core/compaction/compaction.js +610 -0
- package/dist/core/compaction/compaction.js.map +1 -0
- package/dist/core/compaction/index.d.ts +7 -0
- package/dist/core/compaction/index.d.ts.map +1 -0
- package/dist/core/compaction/index.js +7 -0
- package/dist/core/compaction/index.js.map +1 -0
- package/dist/core/compaction/utils.d.ts +38 -0
- package/dist/core/compaction/utils.d.ts.map +1 -0
- package/dist/core/compaction/utils.js +153 -0
- package/dist/core/compaction/utils.js.map +1 -0
- package/dist/core/defaults.d.ts +3 -0
- package/dist/core/defaults.d.ts.map +1 -0
- package/dist/core/defaults.js +2 -0
- package/dist/core/defaults.js.map +1 -0
- package/dist/core/diagnostics.d.ts +15 -0
- package/dist/core/diagnostics.d.ts.map +1 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/diagnostics.js.map +1 -0
- package/dist/core/event-bus.d.ts +9 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +25 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/exec.d.ts +29 -0
- package/dist/core/exec.d.ts.map +1 -0
- package/dist/core/exec.js +71 -0
- package/dist/core/exec.js.map +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/core/export-html/ansi-to-html.js +249 -0
- package/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/dist/core/export-html/index.d.ts +34 -0
- package/dist/core/export-html/index.d.ts.map +1 -0
- package/dist/core/export-html/index.js +222 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/tool-renderer.d.ts +35 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +63 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -0
- package/dist/core/extensions/index.d.ts +11 -0
- package/dist/core/extensions/index.d.ts.map +1 -0
- package/dist/core/extensions/index.js +9 -0
- package/dist/core/extensions/index.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +25 -0
- package/dist/core/extensions/loader.d.ts.map +1 -0
- package/dist/core/extensions/loader.js +426 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +146 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/extensions/runner.js +640 -0
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +1017 -0
- package/dist/core/extensions/types.d.ts.map +1 -0
- package/dist/core/extensions/types.js +35 -0
- package/dist/core/extensions/types.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +27 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/dist/core/extensions/wrapper.js +102 -0
- package/dist/core/extensions/wrapper.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts +32 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -0
- package/dist/core/footer-data-provider.js +134 -0
- package/dist/core/footer-data-provider.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +9 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/keybindings.d.ts +55 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/keybindings.js +151 -0
- package/dist/core/keybindings.js.map +1 -0
- package/dist/core/messages.d.ts +77 -0
- package/dist/core/messages.d.ts.map +1 -0
- package/dist/core/messages.js +123 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/model-registry.d.ts +114 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +548 -0
- package/dist/core/model-registry.js.map +1 -0
- package/dist/core/model-resolver.d.ts +104 -0
- package/dist/core/model-resolver.d.ts.map +1 -0
- package/dist/core/model-resolver.js +462 -0
- package/dist/core/model-resolver.js.map +1 -0
- package/dist/core/package-manager.d.ts +156 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +1442 -0
- package/dist/core/package-manager.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +50 -0
- package/dist/core/prompt-templates.d.ts.map +1 -0
- package/dist/core/prompt-templates.js +251 -0
- package/dist/core/prompt-templates.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +17 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -0
- package/dist/core/resolve-config-value.js +59 -0
- package/dist/core/resolve-config-value.js.map +1 -0
- package/dist/core/resource-loader.d.ts +184 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +633 -0
- package/dist/core/resource-loader.js.map +1 -0
- package/dist/core/sdk.d.ts +90 -0
- package/dist/core/sdk.d.ts.map +1 -0
- package/dist/core/sdk.js +235 -0
- package/dist/core/sdk.js.map +1 -0
- package/dist/core/session-manager.d.ts +323 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +1094 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/settings-manager.d.ts +232 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +682 -0
- package/dist/core/settings-manager.js.map +1 -0
- package/dist/core/skills.d.ts +58 -0
- package/dist/core/skills.d.ts.map +1 -0
- package/dist/core/skills.js +364 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/slash-commands.d.ts +15 -0
- package/dist/core/slash-commands.d.ts.map +1 -0
- package/dist/core/slash-commands.js +22 -0
- package/dist/core/slash-commands.js.map +1 -0
- package/dist/core/system-prompt.d.ts +28 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +159 -0
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/timings.d.ts +7 -0
- package/dist/core/timings.d.ts.map +1 -0
- package/dist/core/timings.js +25 -0
- package/dist/core/timings.js.map +1 -0
- package/dist/core/tools/bash.d.ts +55 -0
- package/dist/core/tools/bash.d.ts.map +1 -0
- package/dist/core/tools/bash.js +242 -0
- package/dist/core/tools/bash.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +63 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/dist/core/tools/edit-diff.js +243 -0
- package/dist/core/tools/edit-diff.js.map +1 -0
- package/dist/core/tools/edit.d.ts +39 -0
- package/dist/core/tools/edit.d.ts.map +1 -0
- package/dist/core/tools/edit.js +146 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/find.d.ts +39 -0
- package/dist/core/tools/find.d.ts.map +1 -0
- package/dist/core/tools/find.js +206 -0
- package/dist/core/tools/find.js.map +1 -0
- package/dist/core/tools/grep.d.ts +45 -0
- package/dist/core/tools/grep.d.ts.map +1 -0
- package/dist/core/tools/grep.js +239 -0
- package/dist/core/tools/grep.js.map +1 -0
- package/dist/core/tools/index.d.ts +73 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/index.js +61 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/ls.d.ts +40 -0
- package/dist/core/tools/ls.d.ts.map +1 -0
- package/dist/core/tools/ls.js +118 -0
- package/dist/core/tools/ls.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +8 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -0
- package/dist/core/tools/path-utils.js +81 -0
- package/dist/core/tools/path-utils.js.map +1 -0
- package/dist/core/tools/read.d.ts +39 -0
- package/dist/core/tools/read.d.ts.map +1 -0
- package/dist/core/tools/read.js +166 -0
- package/dist/core/tools/read.js.map +1 -0
- package/dist/core/tools/truncate.d.ts +70 -0
- package/dist/core/tools/truncate.d.ts.map +1 -0
- package/dist/core/tools/truncate.js +205 -0
- package/dist/core/tools/truncate.js.map +1 -0
- package/dist/core/tools/write.d.ts +29 -0
- package/dist/core/tools/write.d.ts.map +1 -0
- package/dist/core/tools/write.js +78 -0
- package/dist/core/tools/write.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +8 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +661 -0
- package/dist/main.js.map +1 -0
- package/dist/migrations.d.ts +33 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +261 -0
- package/dist/migrations.js.map +1 -0
- package/dist/modes/index.d.ts +9 -0
- package/dist/modes/index.d.ts.map +1 -0
- package/dist/modes/index.js +8 -0
- package/dist/modes/index.js.map +1 -0
- package/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/modes/interactive/components/armin.d.ts.map +1 -0
- package/dist/modes/interactive/components/armin.js +329 -0
- package/dist/modes/interactive/components/armin.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +16 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-message.js +92 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +35 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/bash-execution.js +156 -0
- package/dist/modes/interactive/components/bash-execution.js.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.js +48 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.js +42 -0
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +43 -0
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts +71 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector.js +470 -0
- package/dist/modes/interactive/components/config-selector.js.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.js +28 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-editor.js +63 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-message.js +74 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
- package/dist/modes/interactive/components/daxnuts.js +138 -0
- package/dist/modes/interactive/components/daxnuts.js.map +1 -0
- package/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/modes/interactive/components/diff.d.ts.map +1 -0
- package/dist/modes/interactive/components/diff.js +133 -0
- package/dist/modes/interactive/components/diff.js.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.js +20 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +20 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-editor.js +105 -0
- package/dist/modes/interactive/components/extension-editor.js.map +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-input.js +55 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +24 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-selector.js +71 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +26 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -0
- package/dist/modes/interactive/components/footer.js +196 -0
- package/dist/modes/interactive/components/footer.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +32 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -0
- package/dist/modes/interactive/components/index.js +33 -0
- package/dist/modes/interactive/components/index.js.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +41 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.js +61 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +42 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
- package/dist/modes/interactive/components/login-dialog.js +139 -0
- package/dist/modes/interactive/components/login-dialog.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +47 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/model-selector.js +259 -0
- package/dist/modes/interactive/components/model-selector.js.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +19 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.js +92 -0
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +49 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +271 -0
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.js +155 -0
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector.js +825 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +58 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector.js +295 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +34 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +45 -0
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/theme-selector.js +44 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.js +46 -0
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +77 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +773 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +70 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector.js +921 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +110 -0
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +9 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message.js +27 -0
- package/dist/modes/interactive/components/user-message.js.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +329 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +3710 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/dist/modes/interactive/theme/theme.d.ts +78 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +944 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -0
- package/dist/modes/print-mode.d.ts +28 -0
- package/dist/modes/print-mode.d.ts.map +1 -0
- package/dist/modes/print-mode.js +101 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +217 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client.js +404 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-mode.js +511 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +409 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-types.js +8 -0
- package/dist/modes/rpc/rpc-types.js.map +1 -0
- package/dist/utils/changelog.d.ts +21 -0
- package/dist/utils/changelog.d.ts.map +1 -0
- package/dist/utils/changelog.js +87 -0
- package/dist/utils/changelog.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -0
- package/dist/utils/clipboard-image.js +162 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/clipboard-native.d.ts +7 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -0
- package/dist/utils/clipboard-native.js +14 -0
- package/dist/utils/clipboard-native.js.map +1 -0
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/clipboard.js +67 -0
- package/dist/utils/clipboard.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +8 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +26 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/git.d.ts +26 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +163 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/image-convert.d.ts +9 -0
- package/dist/utils/image-convert.d.ts.map +1 -0
- package/dist/utils/image-convert.js +35 -0
- package/dist/utils/image-convert.js.map +1 -0
- package/dist/utils/image-resize.d.ts +36 -0
- package/dist/utils/image-resize.d.ts.map +1 -0
- package/dist/utils/image-resize.js +181 -0
- package/dist/utils/image-resize.js.map +1 -0
- package/dist/utils/mime.d.ts +2 -0
- package/dist/utils/mime.d.ts.map +1 -0
- package/dist/utils/mime.js +26 -0
- package/dist/utils/mime.js.map +1 -0
- package/dist/utils/photon.d.ts +21 -0
- package/dist/utils/photon.d.ts.map +1 -0
- package/dist/utils/photon.js +121 -0
- package/dist/utils/photon.js.map +1 -0
- package/dist/utils/shell.d.ts +26 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +186 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +3 -0
- package/dist/utils/tools-manager.d.ts.map +1 -0
- package/dist/utils/tools-manager.js +251 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/extensions/phi/README.md +228 -0
- package/extensions/phi/benchmark.ts +490 -0
- package/extensions/phi/init.ts +331 -0
- package/extensions/phi/memory.ts +285 -0
- package/extensions/phi/orchestrator.ts +411 -0
- package/extensions/phi/skill-loader.ts +336 -0
- package/extensions/phi/smart-router.ts +290 -0
- package/extensions/phi/web-search.ts +284 -0
- package/package.json +101 -0
|
@@ -0,0 +1,773 @@
|
|
|
1
|
+
import * as os from "node:os";
|
|
2
|
+
import { Box, Container, getCapabilities, getImageDimensions, Image, imageFallback, Spacer, Text, truncateToWidth, } from "phi-code-tui";
|
|
3
|
+
import stripAnsi from "strip-ansi";
|
|
4
|
+
import { computeEditDiff } from "../../../core/tools/edit-diff.js";
|
|
5
|
+
import { allTools } from "../../../core/tools/index.js";
|
|
6
|
+
import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize } from "../../../core/tools/truncate.js";
|
|
7
|
+
import { convertToPng } from "../../../utils/image-convert.js";
|
|
8
|
+
import { sanitizeBinaryOutput } from "../../../utils/shell.js";
|
|
9
|
+
import { getLanguageFromPath, highlightCode, theme } from "../theme/theme.js";
|
|
10
|
+
import { renderDiff } from "./diff.js";
|
|
11
|
+
import { keyHint } from "./keybinding-hints.js";
|
|
12
|
+
import { truncateToVisualLines } from "./visual-truncate.js";
|
|
13
|
+
// Preview line limit for bash when not expanded
|
|
14
|
+
const BASH_PREVIEW_LINES = 5;
|
|
15
|
+
// During partial write tool-call streaming, re-highlight the first N lines fully
|
|
16
|
+
// to keep multiline tokenization mostly correct without re-highlighting the full file.
|
|
17
|
+
const WRITE_PARTIAL_FULL_HIGHLIGHT_LINES = 50;
|
|
18
|
+
/**
|
|
19
|
+
* Convert absolute path to tilde notation if it's in home directory
|
|
20
|
+
*/
|
|
21
|
+
function shortenPath(path) {
|
|
22
|
+
if (typeof path !== "string")
|
|
23
|
+
return "";
|
|
24
|
+
const home = os.homedir();
|
|
25
|
+
if (path.startsWith(home)) {
|
|
26
|
+
return `~${path.slice(home.length)}`;
|
|
27
|
+
}
|
|
28
|
+
return path;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Replace tabs with spaces for consistent rendering
|
|
32
|
+
*/
|
|
33
|
+
function replaceTabs(text) {
|
|
34
|
+
return text.replace(/\t/g, " ");
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Normalize control characters for terminal preview rendering.
|
|
38
|
+
* Keep tool arguments unchanged, sanitize only display text.
|
|
39
|
+
*/
|
|
40
|
+
function normalizeDisplayText(text) {
|
|
41
|
+
return text.replace(/\r/g, "");
|
|
42
|
+
}
|
|
43
|
+
/** Safely coerce value to string for display. Returns null if invalid type. */
|
|
44
|
+
function str(value) {
|
|
45
|
+
if (typeof value === "string")
|
|
46
|
+
return value;
|
|
47
|
+
if (value == null)
|
|
48
|
+
return "";
|
|
49
|
+
return null; // Invalid type
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Component that renders a tool call with its result (updateable)
|
|
53
|
+
*/
|
|
54
|
+
export class ToolExecutionComponent extends Container {
|
|
55
|
+
constructor(toolName, args, options = {}, toolDefinition, ui, cwd = process.cwd()) {
|
|
56
|
+
super();
|
|
57
|
+
this.imageComponents = [];
|
|
58
|
+
this.imageSpacers = [];
|
|
59
|
+
this.expanded = false;
|
|
60
|
+
this.isPartial = true;
|
|
61
|
+
// Cached converted images for Kitty protocol (which requires PNG), keyed by index
|
|
62
|
+
this.convertedImages = new Map();
|
|
63
|
+
// When true, this component intentionally renders no lines
|
|
64
|
+
this.hideComponent = false;
|
|
65
|
+
this.toolName = toolName;
|
|
66
|
+
this.args = args;
|
|
67
|
+
this.showImages = options.showImages ?? true;
|
|
68
|
+
this.toolDefinition = toolDefinition;
|
|
69
|
+
this.ui = ui;
|
|
70
|
+
this.cwd = cwd;
|
|
71
|
+
this.addChild(new Spacer(1));
|
|
72
|
+
// Always create both - contentBox for custom tools/bash, contentText for other built-ins
|
|
73
|
+
this.contentBox = new Box(1, 1, (text) => theme.bg("toolPendingBg", text));
|
|
74
|
+
this.contentText = new Text("", 1, 1, (text) => theme.bg("toolPendingBg", text));
|
|
75
|
+
// Use contentBox for bash (visual truncation) or custom tools with custom renderers
|
|
76
|
+
// Use contentText for built-in tools (including overrides without custom renderers)
|
|
77
|
+
if (toolName === "bash" || (toolDefinition && !this.shouldUseBuiltInRenderer())) {
|
|
78
|
+
this.addChild(this.contentBox);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
this.addChild(this.contentText);
|
|
82
|
+
}
|
|
83
|
+
this.updateDisplay();
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Check if we should use built-in rendering for this tool.
|
|
87
|
+
* Returns true if the tool name is a built-in AND either there's no toolDefinition
|
|
88
|
+
* or the toolDefinition doesn't provide custom renderers.
|
|
89
|
+
*/
|
|
90
|
+
shouldUseBuiltInRenderer() {
|
|
91
|
+
const isBuiltInName = this.toolName in allTools;
|
|
92
|
+
const hasCustomRenderers = this.toolDefinition?.renderCall || this.toolDefinition?.renderResult;
|
|
93
|
+
return isBuiltInName && !hasCustomRenderers;
|
|
94
|
+
}
|
|
95
|
+
updateArgs(args) {
|
|
96
|
+
this.args = args;
|
|
97
|
+
if (this.toolName === "write" && this.isPartial) {
|
|
98
|
+
this.updateWriteHighlightCacheIncremental();
|
|
99
|
+
}
|
|
100
|
+
this.updateDisplay();
|
|
101
|
+
}
|
|
102
|
+
highlightSingleLine(line, lang) {
|
|
103
|
+
const highlighted = highlightCode(line, lang);
|
|
104
|
+
return highlighted[0] ?? "";
|
|
105
|
+
}
|
|
106
|
+
refreshWriteHighlightPrefix(cache) {
|
|
107
|
+
const prefixCount = Math.min(WRITE_PARTIAL_FULL_HIGHLIGHT_LINES, cache.normalizedLines.length);
|
|
108
|
+
if (prefixCount === 0)
|
|
109
|
+
return;
|
|
110
|
+
const prefixSource = cache.normalizedLines.slice(0, prefixCount).join("\n");
|
|
111
|
+
const prefixHighlighted = highlightCode(prefixSource, cache.lang);
|
|
112
|
+
for (let i = 0; i < prefixCount; i++) {
|
|
113
|
+
cache.highlightedLines[i] =
|
|
114
|
+
prefixHighlighted[i] ?? this.highlightSingleLine(cache.normalizedLines[i] ?? "", cache.lang);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
rebuildWriteHighlightCacheFull(rawPath, fileContent) {
|
|
118
|
+
const lang = rawPath ? getLanguageFromPath(rawPath) : undefined;
|
|
119
|
+
if (!lang) {
|
|
120
|
+
this.writeHighlightCache = undefined;
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const displayContent = normalizeDisplayText(fileContent);
|
|
124
|
+
const normalized = replaceTabs(displayContent);
|
|
125
|
+
this.writeHighlightCache = {
|
|
126
|
+
rawPath,
|
|
127
|
+
lang,
|
|
128
|
+
rawContent: fileContent,
|
|
129
|
+
normalizedLines: normalized.split("\n"),
|
|
130
|
+
highlightedLines: highlightCode(normalized, lang),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
updateWriteHighlightCacheIncremental() {
|
|
134
|
+
const rawPath = str(this.args?.file_path ?? this.args?.path);
|
|
135
|
+
const fileContent = str(this.args?.content);
|
|
136
|
+
if (rawPath === null || fileContent === null) {
|
|
137
|
+
this.writeHighlightCache = undefined;
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const lang = rawPath ? getLanguageFromPath(rawPath) : undefined;
|
|
141
|
+
if (!lang) {
|
|
142
|
+
this.writeHighlightCache = undefined;
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (!this.writeHighlightCache) {
|
|
146
|
+
this.rebuildWriteHighlightCacheFull(rawPath, fileContent);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const cache = this.writeHighlightCache;
|
|
150
|
+
if (cache.lang !== lang || cache.rawPath !== rawPath) {
|
|
151
|
+
this.rebuildWriteHighlightCacheFull(rawPath, fileContent);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (!fileContent.startsWith(cache.rawContent)) {
|
|
155
|
+
this.rebuildWriteHighlightCacheFull(rawPath, fileContent);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (fileContent.length === cache.rawContent.length) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const deltaRaw = fileContent.slice(cache.rawContent.length);
|
|
162
|
+
const deltaDisplay = normalizeDisplayText(deltaRaw);
|
|
163
|
+
const deltaNormalized = replaceTabs(deltaDisplay);
|
|
164
|
+
cache.rawContent = fileContent;
|
|
165
|
+
if (cache.normalizedLines.length === 0) {
|
|
166
|
+
cache.normalizedLines.push("");
|
|
167
|
+
cache.highlightedLines.push("");
|
|
168
|
+
}
|
|
169
|
+
const segments = deltaNormalized.split("\n");
|
|
170
|
+
const lastIndex = cache.normalizedLines.length - 1;
|
|
171
|
+
cache.normalizedLines[lastIndex] += segments[0];
|
|
172
|
+
cache.highlightedLines[lastIndex] = this.highlightSingleLine(cache.normalizedLines[lastIndex], cache.lang);
|
|
173
|
+
for (let i = 1; i < segments.length; i++) {
|
|
174
|
+
cache.normalizedLines.push(segments[i]);
|
|
175
|
+
cache.highlightedLines.push(this.highlightSingleLine(segments[i], cache.lang));
|
|
176
|
+
}
|
|
177
|
+
this.refreshWriteHighlightPrefix(cache);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Signal that args are complete (tool is about to execute).
|
|
181
|
+
* This triggers diff computation for edit tool.
|
|
182
|
+
*/
|
|
183
|
+
setArgsComplete() {
|
|
184
|
+
if (this.toolName === "write") {
|
|
185
|
+
const rawPath = str(this.args?.file_path ?? this.args?.path);
|
|
186
|
+
const fileContent = str(this.args?.content);
|
|
187
|
+
if (rawPath !== null && fileContent !== null) {
|
|
188
|
+
this.rebuildWriteHighlightCacheFull(rawPath, fileContent);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
this.maybeComputeEditDiff();
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Compute edit diff preview when we have complete args.
|
|
195
|
+
* This runs async and updates display when done.
|
|
196
|
+
*/
|
|
197
|
+
maybeComputeEditDiff() {
|
|
198
|
+
if (this.toolName !== "edit")
|
|
199
|
+
return;
|
|
200
|
+
const path = this.args?.path;
|
|
201
|
+
const oldText = this.args?.oldText;
|
|
202
|
+
const newText = this.args?.newText;
|
|
203
|
+
// Need all three params to compute diff
|
|
204
|
+
if (!path || oldText === undefined || newText === undefined)
|
|
205
|
+
return;
|
|
206
|
+
// Create a key to track which args this computation is for
|
|
207
|
+
const argsKey = JSON.stringify({ path, oldText, newText });
|
|
208
|
+
// Skip if we already computed for these exact args
|
|
209
|
+
if (this.editDiffArgsKey === argsKey)
|
|
210
|
+
return;
|
|
211
|
+
this.editDiffArgsKey = argsKey;
|
|
212
|
+
// Compute diff async
|
|
213
|
+
computeEditDiff(path, oldText, newText, this.cwd).then((result) => {
|
|
214
|
+
// Only update if args haven't changed since we started
|
|
215
|
+
if (this.editDiffArgsKey === argsKey) {
|
|
216
|
+
this.editDiffPreview = result;
|
|
217
|
+
this.updateDisplay();
|
|
218
|
+
this.ui.requestRender();
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
updateResult(result, isPartial = false) {
|
|
223
|
+
this.result = result;
|
|
224
|
+
this.isPartial = isPartial;
|
|
225
|
+
if (this.toolName === "write" && !isPartial) {
|
|
226
|
+
const rawPath = str(this.args?.file_path ?? this.args?.path);
|
|
227
|
+
const fileContent = str(this.args?.content);
|
|
228
|
+
if (rawPath !== null && fileContent !== null) {
|
|
229
|
+
this.rebuildWriteHighlightCacheFull(rawPath, fileContent);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
this.updateDisplay();
|
|
233
|
+
// Convert non-PNG images to PNG for Kitty protocol (async)
|
|
234
|
+
this.maybeConvertImagesForKitty();
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Convert non-PNG images to PNG for Kitty graphics protocol.
|
|
238
|
+
* Kitty requires PNG format (f=100), so JPEG/GIF/WebP won't display.
|
|
239
|
+
*/
|
|
240
|
+
maybeConvertImagesForKitty() {
|
|
241
|
+
const caps = getCapabilities();
|
|
242
|
+
// Only needed for Kitty protocol
|
|
243
|
+
if (caps.images !== "kitty")
|
|
244
|
+
return;
|
|
245
|
+
if (!this.result)
|
|
246
|
+
return;
|
|
247
|
+
const imageBlocks = this.result.content?.filter((c) => c.type === "image") || [];
|
|
248
|
+
for (let i = 0; i < imageBlocks.length; i++) {
|
|
249
|
+
const img = imageBlocks[i];
|
|
250
|
+
if (!img.data || !img.mimeType)
|
|
251
|
+
continue;
|
|
252
|
+
// Skip if already PNG or already converted
|
|
253
|
+
if (img.mimeType === "image/png")
|
|
254
|
+
continue;
|
|
255
|
+
if (this.convertedImages.has(i))
|
|
256
|
+
continue;
|
|
257
|
+
// Convert async
|
|
258
|
+
const index = i;
|
|
259
|
+
convertToPng(img.data, img.mimeType).then((converted) => {
|
|
260
|
+
if (converted) {
|
|
261
|
+
this.convertedImages.set(index, converted);
|
|
262
|
+
this.updateDisplay();
|
|
263
|
+
this.ui.requestRender();
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
setExpanded(expanded) {
|
|
269
|
+
this.expanded = expanded;
|
|
270
|
+
this.updateDisplay();
|
|
271
|
+
}
|
|
272
|
+
setShowImages(show) {
|
|
273
|
+
this.showImages = show;
|
|
274
|
+
this.updateDisplay();
|
|
275
|
+
}
|
|
276
|
+
invalidate() {
|
|
277
|
+
super.invalidate();
|
|
278
|
+
this.updateDisplay();
|
|
279
|
+
}
|
|
280
|
+
render(width) {
|
|
281
|
+
if (this.hideComponent) {
|
|
282
|
+
return [];
|
|
283
|
+
}
|
|
284
|
+
return super.render(width);
|
|
285
|
+
}
|
|
286
|
+
updateDisplay() {
|
|
287
|
+
// Set background based on state
|
|
288
|
+
const bgFn = this.isPartial
|
|
289
|
+
? (text) => theme.bg("toolPendingBg", text)
|
|
290
|
+
: this.result?.isError
|
|
291
|
+
? (text) => theme.bg("toolErrorBg", text)
|
|
292
|
+
: (text) => theme.bg("toolSuccessBg", text);
|
|
293
|
+
const useBuiltInRenderer = this.shouldUseBuiltInRenderer();
|
|
294
|
+
let customRendererHasContent = false;
|
|
295
|
+
this.hideComponent = false;
|
|
296
|
+
// Use built-in rendering for built-in tools (or overrides without custom renderers)
|
|
297
|
+
if (useBuiltInRenderer) {
|
|
298
|
+
if (this.toolName === "bash") {
|
|
299
|
+
// Bash uses Box with visual line truncation
|
|
300
|
+
this.contentBox.setBgFn(bgFn);
|
|
301
|
+
this.contentBox.clear();
|
|
302
|
+
this.renderBashContent();
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
// Other built-in tools: use Text directly with caching
|
|
306
|
+
this.contentText.setCustomBgFn(bgFn);
|
|
307
|
+
this.contentText.setText(this.formatToolExecution());
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
else if (this.toolDefinition) {
|
|
311
|
+
// Custom tools use Box for flexible component rendering
|
|
312
|
+
this.contentBox.setBgFn(bgFn);
|
|
313
|
+
this.contentBox.clear();
|
|
314
|
+
// Render call component
|
|
315
|
+
if (this.toolDefinition.renderCall) {
|
|
316
|
+
try {
|
|
317
|
+
const callComponent = this.toolDefinition.renderCall(this.args, theme);
|
|
318
|
+
if (callComponent !== undefined) {
|
|
319
|
+
this.contentBox.addChild(callComponent);
|
|
320
|
+
customRendererHasContent = true;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
catch {
|
|
324
|
+
// Fall back to default on error
|
|
325
|
+
this.contentBox.addChild(new Text(theme.fg("toolTitle", theme.bold(this.toolName)), 0, 0));
|
|
326
|
+
customRendererHasContent = true;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
// No custom renderCall, show tool name
|
|
331
|
+
this.contentBox.addChild(new Text(theme.fg("toolTitle", theme.bold(this.toolName)), 0, 0));
|
|
332
|
+
customRendererHasContent = true;
|
|
333
|
+
}
|
|
334
|
+
// Render result component if we have a result
|
|
335
|
+
if (this.result && this.toolDefinition.renderResult) {
|
|
336
|
+
try {
|
|
337
|
+
const resultComponent = this.toolDefinition.renderResult({ content: this.result.content, details: this.result.details }, { expanded: this.expanded, isPartial: this.isPartial }, theme);
|
|
338
|
+
if (resultComponent !== undefined) {
|
|
339
|
+
this.contentBox.addChild(resultComponent);
|
|
340
|
+
customRendererHasContent = true;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
catch {
|
|
344
|
+
// Fall back to showing raw output on error
|
|
345
|
+
const output = this.getTextOutput();
|
|
346
|
+
if (output) {
|
|
347
|
+
this.contentBox.addChild(new Text(theme.fg("toolOutput", output), 0, 0));
|
|
348
|
+
customRendererHasContent = true;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
else if (this.result) {
|
|
353
|
+
// Has result but no custom renderResult
|
|
354
|
+
const output = this.getTextOutput();
|
|
355
|
+
if (output) {
|
|
356
|
+
this.contentBox.addChild(new Text(theme.fg("toolOutput", output), 0, 0));
|
|
357
|
+
customRendererHasContent = true;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
// Unknown tool with no registered definition - show generic fallback
|
|
363
|
+
this.contentText.setCustomBgFn(bgFn);
|
|
364
|
+
this.contentText.setText(this.formatToolExecution());
|
|
365
|
+
}
|
|
366
|
+
// Handle images (same for both custom and built-in)
|
|
367
|
+
for (const img of this.imageComponents) {
|
|
368
|
+
this.removeChild(img);
|
|
369
|
+
}
|
|
370
|
+
this.imageComponents = [];
|
|
371
|
+
for (const spacer of this.imageSpacers) {
|
|
372
|
+
this.removeChild(spacer);
|
|
373
|
+
}
|
|
374
|
+
this.imageSpacers = [];
|
|
375
|
+
if (this.result) {
|
|
376
|
+
const imageBlocks = this.result.content?.filter((c) => c.type === "image") || [];
|
|
377
|
+
const caps = getCapabilities();
|
|
378
|
+
for (let i = 0; i < imageBlocks.length; i++) {
|
|
379
|
+
const img = imageBlocks[i];
|
|
380
|
+
if (caps.images && this.showImages && img.data && img.mimeType) {
|
|
381
|
+
// Use converted PNG for Kitty protocol if available
|
|
382
|
+
const converted = this.convertedImages.get(i);
|
|
383
|
+
const imageData = converted?.data ?? img.data;
|
|
384
|
+
const imageMimeType = converted?.mimeType ?? img.mimeType;
|
|
385
|
+
// For Kitty, skip non-PNG images that haven't been converted yet
|
|
386
|
+
if (caps.images === "kitty" && imageMimeType !== "image/png") {
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
const spacer = new Spacer(1);
|
|
390
|
+
this.addChild(spacer);
|
|
391
|
+
this.imageSpacers.push(spacer);
|
|
392
|
+
const imageComponent = new Image(imageData, imageMimeType, { fallbackColor: (s) => theme.fg("toolOutput", s) }, { maxWidthCells: 60 });
|
|
393
|
+
this.imageComponents.push(imageComponent);
|
|
394
|
+
this.addChild(imageComponent);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (!useBuiltInRenderer && this.toolDefinition) {
|
|
399
|
+
this.hideComponent = !customRendererHasContent && this.imageComponents.length === 0;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Render bash content using visual line truncation (like bash-execution.ts)
|
|
404
|
+
*/
|
|
405
|
+
renderBashContent() {
|
|
406
|
+
const command = str(this.args?.command);
|
|
407
|
+
const timeout = this.args?.timeout;
|
|
408
|
+
// Header
|
|
409
|
+
const timeoutSuffix = timeout ? theme.fg("muted", ` (timeout ${timeout}s)`) : "";
|
|
410
|
+
const commandDisplay = command === null ? theme.fg("error", "[invalid arg]") : command ? command : theme.fg("toolOutput", "...");
|
|
411
|
+
this.contentBox.addChild(new Text(theme.fg("toolTitle", theme.bold(`$ ${commandDisplay}`)) + timeoutSuffix, 0, 0));
|
|
412
|
+
if (this.result) {
|
|
413
|
+
const output = this.getTextOutput().trim();
|
|
414
|
+
if (output) {
|
|
415
|
+
// Style each line for the output
|
|
416
|
+
const styledOutput = output
|
|
417
|
+
.split("\n")
|
|
418
|
+
.map((line) => theme.fg("toolOutput", line))
|
|
419
|
+
.join("\n");
|
|
420
|
+
if (this.expanded) {
|
|
421
|
+
// Show all lines when expanded
|
|
422
|
+
this.contentBox.addChild(new Text(`\n${styledOutput}`, 0, 0));
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
// Use visual line truncation when collapsed with width-aware caching
|
|
426
|
+
let cachedWidth;
|
|
427
|
+
let cachedLines;
|
|
428
|
+
let cachedSkipped;
|
|
429
|
+
this.contentBox.addChild({
|
|
430
|
+
render: (width) => {
|
|
431
|
+
if (cachedLines === undefined || cachedWidth !== width) {
|
|
432
|
+
const result = truncateToVisualLines(styledOutput, BASH_PREVIEW_LINES, width);
|
|
433
|
+
cachedLines = result.visualLines;
|
|
434
|
+
cachedSkipped = result.skippedCount;
|
|
435
|
+
cachedWidth = width;
|
|
436
|
+
}
|
|
437
|
+
if (cachedSkipped && cachedSkipped > 0) {
|
|
438
|
+
const hint = theme.fg("muted", `... (${cachedSkipped} earlier lines,`) +
|
|
439
|
+
` ${keyHint("expandTools", "to expand")})`;
|
|
440
|
+
return ["", truncateToWidth(hint, width, "..."), ...cachedLines];
|
|
441
|
+
}
|
|
442
|
+
// Add blank line for spacing (matches expanded case)
|
|
443
|
+
return ["", ...cachedLines];
|
|
444
|
+
},
|
|
445
|
+
invalidate: () => {
|
|
446
|
+
cachedWidth = undefined;
|
|
447
|
+
cachedLines = undefined;
|
|
448
|
+
cachedSkipped = undefined;
|
|
449
|
+
},
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
// Truncation warnings
|
|
454
|
+
const truncation = this.result.details?.truncation;
|
|
455
|
+
const fullOutputPath = this.result.details?.fullOutputPath;
|
|
456
|
+
if (truncation?.truncated || fullOutputPath) {
|
|
457
|
+
const warnings = [];
|
|
458
|
+
if (fullOutputPath) {
|
|
459
|
+
warnings.push(`Full output: ${fullOutputPath}`);
|
|
460
|
+
}
|
|
461
|
+
if (truncation?.truncated) {
|
|
462
|
+
if (truncation.truncatedBy === "lines") {
|
|
463
|
+
warnings.push(`Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines`);
|
|
464
|
+
}
|
|
465
|
+
else {
|
|
466
|
+
warnings.push(`Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)`);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
this.contentBox.addChild(new Text(`\n${theme.fg("warning", `[${warnings.join(". ")}]`)}`, 0, 0));
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
getTextOutput() {
|
|
474
|
+
if (!this.result)
|
|
475
|
+
return "";
|
|
476
|
+
const textBlocks = this.result.content?.filter((c) => c.type === "text") || [];
|
|
477
|
+
const imageBlocks = this.result.content?.filter((c) => c.type === "image") || [];
|
|
478
|
+
let output = textBlocks
|
|
479
|
+
.map((c) => {
|
|
480
|
+
// Use sanitizeBinaryOutput to handle binary data that crashes string-width
|
|
481
|
+
return sanitizeBinaryOutput(stripAnsi(c.text || "")).replace(/\r/g, "");
|
|
482
|
+
})
|
|
483
|
+
.join("\n");
|
|
484
|
+
const caps = getCapabilities();
|
|
485
|
+
if (imageBlocks.length > 0 && (!caps.images || !this.showImages)) {
|
|
486
|
+
const imageIndicators = imageBlocks
|
|
487
|
+
.map((img) => {
|
|
488
|
+
const dims = img.data ? (getImageDimensions(img.data, img.mimeType) ?? undefined) : undefined;
|
|
489
|
+
return imageFallback(img.mimeType, dims);
|
|
490
|
+
})
|
|
491
|
+
.join("\n");
|
|
492
|
+
output = output ? `${output}\n${imageIndicators}` : imageIndicators;
|
|
493
|
+
}
|
|
494
|
+
return output;
|
|
495
|
+
}
|
|
496
|
+
formatToolExecution() {
|
|
497
|
+
let text = "";
|
|
498
|
+
const invalidArg = theme.fg("error", "[invalid arg]");
|
|
499
|
+
if (this.toolName === "read") {
|
|
500
|
+
const rawPath = str(this.args?.file_path ?? this.args?.path);
|
|
501
|
+
const path = rawPath !== null ? shortenPath(rawPath) : null;
|
|
502
|
+
const offset = this.args?.offset;
|
|
503
|
+
const limit = this.args?.limit;
|
|
504
|
+
let pathDisplay = path === null ? invalidArg : path ? theme.fg("accent", path) : theme.fg("toolOutput", "...");
|
|
505
|
+
if (offset !== undefined || limit !== undefined) {
|
|
506
|
+
const startLine = offset ?? 1;
|
|
507
|
+
const endLine = limit !== undefined ? startLine + limit - 1 : "";
|
|
508
|
+
pathDisplay += theme.fg("warning", `:${startLine}${endLine ? `-${endLine}` : ""}`);
|
|
509
|
+
}
|
|
510
|
+
text = `${theme.fg("toolTitle", theme.bold("read"))} ${pathDisplay}`;
|
|
511
|
+
if (this.result) {
|
|
512
|
+
const output = this.getTextOutput();
|
|
513
|
+
const rawPath = str(this.args?.file_path ?? this.args?.path);
|
|
514
|
+
const lang = rawPath ? getLanguageFromPath(rawPath) : undefined;
|
|
515
|
+
const lines = lang ? highlightCode(replaceTabs(output), lang) : output.split("\n");
|
|
516
|
+
const maxLines = this.expanded ? lines.length : 10;
|
|
517
|
+
const displayLines = lines.slice(0, maxLines);
|
|
518
|
+
const remaining = lines.length - maxLines;
|
|
519
|
+
text +=
|
|
520
|
+
"\n\n" +
|
|
521
|
+
displayLines
|
|
522
|
+
.map((line) => (lang ? replaceTabs(line) : theme.fg("toolOutput", replaceTabs(line))))
|
|
523
|
+
.join("\n");
|
|
524
|
+
if (remaining > 0) {
|
|
525
|
+
text += `${theme.fg("muted", `\n... (${remaining} more lines,`)} ${keyHint("expandTools", "to expand")})`;
|
|
526
|
+
}
|
|
527
|
+
const truncation = this.result.details?.truncation;
|
|
528
|
+
if (truncation?.truncated) {
|
|
529
|
+
if (truncation.firstLineExceedsLimit) {
|
|
530
|
+
text +=
|
|
531
|
+
"\n" +
|
|
532
|
+
theme.fg("warning", `[First line exceeds ${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit]`);
|
|
533
|
+
}
|
|
534
|
+
else if (truncation.truncatedBy === "lines") {
|
|
535
|
+
text +=
|
|
536
|
+
"\n" +
|
|
537
|
+
theme.fg("warning", `[Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines (${truncation.maxLines ?? DEFAULT_MAX_LINES} line limit)]`);
|
|
538
|
+
}
|
|
539
|
+
else {
|
|
540
|
+
text +=
|
|
541
|
+
"\n" +
|
|
542
|
+
theme.fg("warning", `[Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)]`);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
else if (this.toolName === "write") {
|
|
548
|
+
const rawPath = str(this.args?.file_path ?? this.args?.path);
|
|
549
|
+
const fileContent = str(this.args?.content);
|
|
550
|
+
const path = rawPath !== null ? shortenPath(rawPath) : null;
|
|
551
|
+
text =
|
|
552
|
+
theme.fg("toolTitle", theme.bold("write")) +
|
|
553
|
+
" " +
|
|
554
|
+
(path === null ? invalidArg : path ? theme.fg("accent", path) : theme.fg("toolOutput", "..."));
|
|
555
|
+
if (fileContent === null) {
|
|
556
|
+
text += `\n\n${theme.fg("error", "[invalid content arg - expected string]")}`;
|
|
557
|
+
}
|
|
558
|
+
else if (fileContent) {
|
|
559
|
+
const lang = rawPath ? getLanguageFromPath(rawPath) : undefined;
|
|
560
|
+
let lines;
|
|
561
|
+
if (lang) {
|
|
562
|
+
const cache = this.writeHighlightCache;
|
|
563
|
+
if (cache && cache.lang === lang && cache.rawPath === rawPath && cache.rawContent === fileContent) {
|
|
564
|
+
lines = cache.highlightedLines;
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
const displayContent = normalizeDisplayText(fileContent);
|
|
568
|
+
const normalized = replaceTabs(displayContent);
|
|
569
|
+
lines = highlightCode(normalized, lang);
|
|
570
|
+
this.writeHighlightCache = {
|
|
571
|
+
rawPath,
|
|
572
|
+
lang,
|
|
573
|
+
rawContent: fileContent,
|
|
574
|
+
normalizedLines: normalized.split("\n"),
|
|
575
|
+
highlightedLines: lines,
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
lines = normalizeDisplayText(fileContent).split("\n");
|
|
581
|
+
this.writeHighlightCache = undefined;
|
|
582
|
+
}
|
|
583
|
+
const totalLines = lines.length;
|
|
584
|
+
const maxLines = this.expanded ? lines.length : 10;
|
|
585
|
+
const displayLines = lines.slice(0, maxLines);
|
|
586
|
+
const remaining = lines.length - maxLines;
|
|
587
|
+
text +=
|
|
588
|
+
"\n\n" +
|
|
589
|
+
displayLines.map((line) => (lang ? line : theme.fg("toolOutput", replaceTabs(line)))).join("\n");
|
|
590
|
+
if (remaining > 0) {
|
|
591
|
+
text +=
|
|
592
|
+
theme.fg("muted", `\n... (${remaining} more lines, ${totalLines} total,`) +
|
|
593
|
+
` ${keyHint("expandTools", "to expand")})`;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
// Show error if tool execution failed
|
|
597
|
+
if (this.result?.isError) {
|
|
598
|
+
const errorText = this.getTextOutput();
|
|
599
|
+
if (errorText) {
|
|
600
|
+
text += `\n\n${theme.fg("error", errorText)}`;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
else if (this.toolName === "edit") {
|
|
605
|
+
const rawPath = str(this.args?.file_path ?? this.args?.path);
|
|
606
|
+
const path = rawPath !== null ? shortenPath(rawPath) : null;
|
|
607
|
+
// Build path display, appending :line if we have diff info
|
|
608
|
+
let pathDisplay = path === null ? invalidArg : path ? theme.fg("accent", path) : theme.fg("toolOutput", "...");
|
|
609
|
+
const firstChangedLine = (this.editDiffPreview && "firstChangedLine" in this.editDiffPreview
|
|
610
|
+
? this.editDiffPreview.firstChangedLine
|
|
611
|
+
: undefined) ||
|
|
612
|
+
(this.result && !this.result.isError ? this.result.details?.firstChangedLine : undefined);
|
|
613
|
+
if (firstChangedLine) {
|
|
614
|
+
pathDisplay += theme.fg("warning", `:${firstChangedLine}`);
|
|
615
|
+
}
|
|
616
|
+
text = `${theme.fg("toolTitle", theme.bold("edit"))} ${pathDisplay}`;
|
|
617
|
+
if (this.result?.isError) {
|
|
618
|
+
// Show error from result
|
|
619
|
+
const errorText = this.getTextOutput();
|
|
620
|
+
if (errorText) {
|
|
621
|
+
text += `\n\n${theme.fg("error", errorText)}`;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
else if (this.result?.details?.diff) {
|
|
625
|
+
// Tool executed successfully - use the diff from result
|
|
626
|
+
// This takes priority over editDiffPreview which may have a stale error
|
|
627
|
+
// due to race condition (async preview computed after file was modified)
|
|
628
|
+
text += `\n\n${renderDiff(this.result.details.diff, { filePath: rawPath ?? undefined })}`;
|
|
629
|
+
}
|
|
630
|
+
else if (this.editDiffPreview) {
|
|
631
|
+
// Use cached diff preview (before tool executes)
|
|
632
|
+
if ("error" in this.editDiffPreview) {
|
|
633
|
+
text += `\n\n${theme.fg("error", this.editDiffPreview.error)}`;
|
|
634
|
+
}
|
|
635
|
+
else if (this.editDiffPreview.diff) {
|
|
636
|
+
text += `\n\n${renderDiff(this.editDiffPreview.diff, { filePath: rawPath ?? undefined })}`;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
else if (this.toolName === "ls") {
|
|
641
|
+
const rawPath = str(this.args?.path);
|
|
642
|
+
const path = rawPath !== null ? shortenPath(rawPath || ".") : null;
|
|
643
|
+
const limit = this.args?.limit;
|
|
644
|
+
text = `${theme.fg("toolTitle", theme.bold("ls"))} ${path === null ? invalidArg : theme.fg("accent", path)}`;
|
|
645
|
+
if (limit !== undefined) {
|
|
646
|
+
text += theme.fg("toolOutput", ` (limit ${limit})`);
|
|
647
|
+
}
|
|
648
|
+
if (this.result) {
|
|
649
|
+
const output = this.getTextOutput().trim();
|
|
650
|
+
if (output) {
|
|
651
|
+
const lines = output.split("\n");
|
|
652
|
+
const maxLines = this.expanded ? lines.length : 20;
|
|
653
|
+
const displayLines = lines.slice(0, maxLines);
|
|
654
|
+
const remaining = lines.length - maxLines;
|
|
655
|
+
text += `\n\n${displayLines.map((line) => theme.fg("toolOutput", line)).join("\n")}`;
|
|
656
|
+
if (remaining > 0) {
|
|
657
|
+
text += `${theme.fg("muted", `\n... (${remaining} more lines,`)} ${keyHint("expandTools", "to expand")})`;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
const entryLimit = this.result.details?.entryLimitReached;
|
|
661
|
+
const truncation = this.result.details?.truncation;
|
|
662
|
+
if (entryLimit || truncation?.truncated) {
|
|
663
|
+
const warnings = [];
|
|
664
|
+
if (entryLimit) {
|
|
665
|
+
warnings.push(`${entryLimit} entries limit`);
|
|
666
|
+
}
|
|
667
|
+
if (truncation?.truncated) {
|
|
668
|
+
warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);
|
|
669
|
+
}
|
|
670
|
+
text += `\n${theme.fg("warning", `[Truncated: ${warnings.join(", ")}]`)}`;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
else if (this.toolName === "find") {
|
|
675
|
+
const pattern = str(this.args?.pattern);
|
|
676
|
+
const rawPath = str(this.args?.path);
|
|
677
|
+
const path = rawPath !== null ? shortenPath(rawPath || ".") : null;
|
|
678
|
+
const limit = this.args?.limit;
|
|
679
|
+
text =
|
|
680
|
+
theme.fg("toolTitle", theme.bold("find")) +
|
|
681
|
+
" " +
|
|
682
|
+
(pattern === null ? invalidArg : theme.fg("accent", pattern || "")) +
|
|
683
|
+
theme.fg("toolOutput", ` in ${path === null ? invalidArg : path}`);
|
|
684
|
+
if (limit !== undefined) {
|
|
685
|
+
text += theme.fg("toolOutput", ` (limit ${limit})`);
|
|
686
|
+
}
|
|
687
|
+
if (this.result) {
|
|
688
|
+
const output = this.getTextOutput().trim();
|
|
689
|
+
if (output) {
|
|
690
|
+
const lines = output.split("\n");
|
|
691
|
+
const maxLines = this.expanded ? lines.length : 20;
|
|
692
|
+
const displayLines = lines.slice(0, maxLines);
|
|
693
|
+
const remaining = lines.length - maxLines;
|
|
694
|
+
text += `\n\n${displayLines.map((line) => theme.fg("toolOutput", line)).join("\n")}`;
|
|
695
|
+
if (remaining > 0) {
|
|
696
|
+
text += `${theme.fg("muted", `\n... (${remaining} more lines,`)} ${keyHint("expandTools", "to expand")})`;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
const resultLimit = this.result.details?.resultLimitReached;
|
|
700
|
+
const truncation = this.result.details?.truncation;
|
|
701
|
+
if (resultLimit || truncation?.truncated) {
|
|
702
|
+
const warnings = [];
|
|
703
|
+
if (resultLimit) {
|
|
704
|
+
warnings.push(`${resultLimit} results limit`);
|
|
705
|
+
}
|
|
706
|
+
if (truncation?.truncated) {
|
|
707
|
+
warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);
|
|
708
|
+
}
|
|
709
|
+
text += `\n${theme.fg("warning", `[Truncated: ${warnings.join(", ")}]`)}`;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
else if (this.toolName === "grep") {
|
|
714
|
+
const pattern = str(this.args?.pattern);
|
|
715
|
+
const rawPath = str(this.args?.path);
|
|
716
|
+
const path = rawPath !== null ? shortenPath(rawPath || ".") : null;
|
|
717
|
+
const glob = str(this.args?.glob);
|
|
718
|
+
const limit = this.args?.limit;
|
|
719
|
+
text =
|
|
720
|
+
theme.fg("toolTitle", theme.bold("grep")) +
|
|
721
|
+
" " +
|
|
722
|
+
(pattern === null ? invalidArg : theme.fg("accent", `/${pattern || ""}/`)) +
|
|
723
|
+
theme.fg("toolOutput", ` in ${path === null ? invalidArg : path}`);
|
|
724
|
+
if (glob) {
|
|
725
|
+
text += theme.fg("toolOutput", ` (${glob})`);
|
|
726
|
+
}
|
|
727
|
+
if (limit !== undefined) {
|
|
728
|
+
text += theme.fg("toolOutput", ` limit ${limit}`);
|
|
729
|
+
}
|
|
730
|
+
if (this.result) {
|
|
731
|
+
const output = this.getTextOutput().trim();
|
|
732
|
+
if (output) {
|
|
733
|
+
const lines = output.split("\n");
|
|
734
|
+
const maxLines = this.expanded ? lines.length : 15;
|
|
735
|
+
const displayLines = lines.slice(0, maxLines);
|
|
736
|
+
const remaining = lines.length - maxLines;
|
|
737
|
+
text += `\n\n${displayLines.map((line) => theme.fg("toolOutput", line)).join("\n")}`;
|
|
738
|
+
if (remaining > 0) {
|
|
739
|
+
text += `${theme.fg("muted", `\n... (${remaining} more lines,`)} ${keyHint("expandTools", "to expand")})`;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
const matchLimit = this.result.details?.matchLimitReached;
|
|
743
|
+
const truncation = this.result.details?.truncation;
|
|
744
|
+
const linesTruncated = this.result.details?.linesTruncated;
|
|
745
|
+
if (matchLimit || truncation?.truncated || linesTruncated) {
|
|
746
|
+
const warnings = [];
|
|
747
|
+
if (matchLimit) {
|
|
748
|
+
warnings.push(`${matchLimit} matches limit`);
|
|
749
|
+
}
|
|
750
|
+
if (truncation?.truncated) {
|
|
751
|
+
warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);
|
|
752
|
+
}
|
|
753
|
+
if (linesTruncated) {
|
|
754
|
+
warnings.push("some lines truncated");
|
|
755
|
+
}
|
|
756
|
+
text += `\n${theme.fg("warning", `[Truncated: ${warnings.join(", ")}]`)}`;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
else {
|
|
761
|
+
// Generic tool (shouldn't reach here for custom tools)
|
|
762
|
+
text = theme.fg("toolTitle", theme.bold(this.toolName));
|
|
763
|
+
const content = JSON.stringify(this.args, null, 2);
|
|
764
|
+
text += `\n\n${content}`;
|
|
765
|
+
const output = this.getTextOutput();
|
|
766
|
+
if (output) {
|
|
767
|
+
text += `\n${output}`;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
return text;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
//# sourceMappingURL=tool-execution.js.map
|