@draht/coding-agent 2026.9.5-1 → 2026.10.4-2
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 +452 -0
- package/dist/bun/cli.d.ts +1 -1
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js +6 -3
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/sandbox-env-setup.d.ts +2 -0
- package/dist/bun/sandbox-env-setup.d.ts.map +1 -0
- package/dist/bun/sandbox-env-setup.js +4 -0
- package/dist/bun/sandbox-env-setup.js.map +1 -0
- package/dist/bundle/chunks/anthropic-messages-GAKYXF65.js +6 -0
- package/dist/bundle/chunks/anthropic.js +75 -0
- package/dist/bundle/chunks/azure-openai-responses-ZIXMK6JO.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +79 -0
- package/dist/bundle/chunks/chunk-2E5VODES.js +2 -0
- package/dist/bundle/chunks/chunk-2FBJKY7F.js +2 -0
- package/dist/bundle/chunks/chunk-2N4I6WXC.js +2 -0
- package/dist/bundle/chunks/chunk-5VZWYVZB.js +82 -0
- package/dist/bundle/chunks/chunk-63BK6WK2.js +2 -0
- package/dist/bundle/chunks/chunk-6MSE6LZ3.js +6 -0
- package/dist/bundle/chunks/chunk-6ZJKIMU7.js +2 -0
- package/dist/bundle/chunks/chunk-736QBNUZ.js +12 -0
- package/dist/bundle/chunks/chunk-BXSHCX3G.js +11 -0
- package/dist/bundle/chunks/chunk-CEJJ5XF2.js +170 -0
- package/dist/bundle/chunks/chunk-COF5JT7R.js +4 -0
- package/dist/bundle/chunks/chunk-D6TMD5Q2.js +44 -0
- package/dist/bundle/chunks/chunk-DPE4ALPU.js +146 -0
- package/dist/bundle/chunks/chunk-EBVYI75P.js +2 -0
- package/dist/bundle/chunks/chunk-GVXA72ZA.js +2 -0
- package/dist/bundle/chunks/chunk-H6FT43VC.js +137 -0
- package/dist/bundle/chunks/chunk-HJ72RANT.js +2 -0
- package/dist/bundle/chunks/chunk-HTJ3L72O.js +2 -0
- package/dist/bundle/chunks/chunk-HZ2UHMBT.js +2 -0
- package/dist/bundle/chunks/chunk-I5OKY6RH.js +11 -0
- package/dist/bundle/chunks/chunk-IWTUBX6V.js +4 -0
- package/dist/bundle/chunks/chunk-KPO5375S.js +2 -0
- package/dist/bundle/chunks/chunk-KVH4HR57.js +31 -0
- package/dist/bundle/chunks/chunk-LDAOC5RB.js +18 -0
- package/dist/bundle/chunks/chunk-ON6XU6AG.js +2 -0
- package/dist/bundle/chunks/chunk-QMN7OD6G.js +2 -0
- package/dist/bundle/chunks/chunk-RZKPFWMH.js +42 -0
- package/dist/bundle/chunks/chunk-SDRCE6OP.js +2 -0
- package/dist/bundle/chunks/chunk-SVNWI7EV.js +8 -0
- package/dist/bundle/chunks/chunk-TIA2T6EO.js +3 -0
- package/dist/bundle/chunks/chunk-VOFPZOUQ.js +1472 -0
- package/dist/bundle/chunks/chunk-XBUEMKIY.js +2 -0
- package/dist/bundle/chunks/chunk-XOGEYN4Q.js +2 -0
- package/dist/bundle/chunks/chunk-ZZD35WKM.js +2 -0
- package/dist/bundle/chunks/cli-SR5QBZH4.js +51 -0
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-MJKOAE5S.js +2 -0
- package/dist/bundle/chunks/codemode-worker.js +315 -0
- package/dist/bundle/chunks/execute-VCYDHEYA.js +328 -0
- package/dist/bundle/chunks/github-copilot.js +2 -0
- package/dist/bundle/chunks/google-antigravity.js +75 -0
- package/dist/bundle/chunks/google-gemini-cli.js +75 -0
- package/dist/bundle/chunks/google-generative-ai-RPUPQ6PM.js +2 -0
- package/dist/bundle/chunks/google-vertex-EZES5QVQ.js +2 -0
- package/dist/bundle/chunks/https-proxy-agent-O2PVUIOI.js +13 -0
- package/dist/bundle/chunks/image-resize-worker.js +2 -0
- package/dist/bundle/chunks/jiti-loader-RKXLMQV2.js +2 -0
- package/dist/bundle/chunks/kimi-coding.js +2 -0
- package/dist/bundle/chunks/lib-XOG5PI3Y.js +9 -0
- package/dist/bundle/chunks/llama-cpp-classify-EJ5XMSQL.js +22 -0
- package/dist/bundle/chunks/meta.js +2 -0
- package/dist/bundle/chunks/mistral-conversations-AOYGU43Y.js +5 -0
- package/dist/bundle/chunks/multipart-parser-AZP5BX2W.js +3 -0
- package/dist/bundle/chunks/node-C2JGH2OB.js +2 -0
- package/dist/bundle/chunks/node-LQ52KV6B.js +16 -0
- package/dist/bundle/chunks/openai-chatgpt.js +75 -0
- package/dist/bundle/chunks/openai-codex-responses-M2Y77JEQ.js +10 -0
- package/dist/bundle/chunks/openai-codex.js +75 -0
- package/dist/bundle/chunks/openai-completions-A4OKYOYV.js +7 -0
- package/dist/bundle/chunks/openai-responses-6IXV53T3.js +3 -0
- package/dist/bundle/chunks/opencode-go.js +2 -0
- package/dist/bundle/chunks/openrouter-images-LYV4NKFM.js +2 -0
- package/dist/bundle/chunks/openrouter.js +75 -0
- package/dist/bundle/chunks/pi-messages-KKMEUT3Z.js +8 -0
- package/dist/bundle/chunks/radius.js +75 -0
- package/dist/bundle/chunks/runtime-6YJPGSP7.js +2 -0
- package/dist/bundle/chunks/settings-manager-D2EG7WDO.js +2 -0
- package/dist/bundle/chunks/src-TIBHS42X.js +4 -0
- package/dist/bundle/chunks/typesafe-system-one-YBEEY5XU.js +2 -0
- package/dist/bundle/chunks/virtual-modules-CBOAFAFT.js +2 -0
- package/dist/bundle/chunks/xai.js +75 -0
- package/dist/bundle/cli-runtime.js +3 -0
- package/dist/bundle/cli.js +5 -0
- package/dist/bundle/index.js +2 -0
- package/dist/bundle/rpc-entry.js +3 -0
- package/dist/cli/args.d.ts +4 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +72 -21
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth-check.d.ts +19 -0
- package/dist/cli/auth-check.d.ts.map +1 -0
- package/dist/cli/auth-check.js +50 -0
- package/dist/cli/auth-check.js.map +1 -0
- package/dist/cli/auth-command.d.ts +24 -0
- package/dist/cli/auth-command.d.ts.map +1 -0
- package/dist/cli/auth-command.js +103 -0
- package/dist/cli/auth-command.js.map +1 -0
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +3 -2
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/credential-print.d.ts +5 -3
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +42 -30
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/cli/file-processor.d.ts +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +2 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/list-models.d.ts +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +2 -2
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/session-picker.d.ts +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/setup.d.ts +2 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +12 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cli/startup-ui.d.ts +2 -2
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +42 -33
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/cli.js +3 -12
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +20 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +42 -6
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +12 -3
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +14 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +237 -39
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +1386 -565
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +20 -8
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +199 -56
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bug-report-upload.d.ts +11 -0
- package/dist/core/bug-report-upload.d.ts.map +1 -0
- package/dist/core/bug-report-upload.js +20 -0
- package/dist/core/bug-report-upload.js.map +1 -0
- package/dist/core/bug-report.d.ts +176 -0
- package/dist/core/bug-report.d.ts.map +1 -0
- package/dist/core/bug-report.js +292 -0
- package/dist/core/bug-report.js.map +1 -0
- package/dist/core/builtins/duet.js +2 -2
- package/dist/core/builtins/duet.js.map +1 -1
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +12 -1
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/cache-warmer.d.ts +103 -0
- package/dist/core/cache-warmer.d.ts.map +1 -0
- package/dist/core/cache-warmer.js +356 -0
- package/dist/core/cache-warmer.js.map +1 -0
- package/dist/core/checkpoints/checkpoint-manager.d.ts +8 -4
- package/dist/core/checkpoints/checkpoint-manager.d.ts.map +1 -1
- package/dist/core/checkpoints/checkpoint-manager.js +46 -10
- package/dist/core/checkpoints/checkpoint-manager.js.map +1 -1
- package/dist/core/checkpoints/rewind.d.ts +4 -2
- package/dist/core/checkpoints/rewind.d.ts.map +1 -1
- package/dist/core/checkpoints/rewind.js +4 -3
- package/dist/core/checkpoints/rewind.js.map +1 -1
- package/dist/core/compaction/branch-summarization.js +2 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +9 -6
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +196 -118
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +2 -1
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +25 -18
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/crash-log.d.ts +27 -0
- package/dist/core/crash-log.d.ts.map +1 -0
- package/dist/core/crash-log.js +140 -0
- package/dist/core/crash-log.js.map +1 -0
- package/dist/core/defaults.d.ts +1 -0
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/defaults.js +9 -0
- package/dist/core/defaults.js.map +1 -1
- package/dist/core/experimental.js +1 -1
- package/dist/core/experimental.js.map +1 -1
- package/dist/core/export-html/template.css +10 -0
- package/dist/core/export-html/template.js +72 -18
- package/dist/core/extensions/index.d.ts +2 -2
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/jiti-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-loader.js +5 -0
- package/dist/core/extensions/jiti-loader.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +228 -89
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +47 -8
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +376 -104
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +521 -88
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +3 -0
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts +3 -0
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -0
- package/dist/core/extensions/virtual-modules.js +37 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +2 -2
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +3 -22
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +1 -1
- package/dist/core/footer-data-provider.js +19 -18
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +83 -13
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +33 -7
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/mcp-servers.d.ts +119 -0
- package/dist/core/mcp-servers.d.ts.map +1 -0
- package/dist/core/mcp-servers.js +191 -0
- package/dist/core/mcp-servers.js.map +1 -0
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +1 -0
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts +202 -20
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +53 -18
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +19 -2
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +39 -2
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +7 -5
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +29 -17
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +79 -20
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +460 -134
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/models-store.d.ts +12 -7
- package/dist/core/models-store.d.ts.map +1 -1
- package/dist/core/models-store.js +87 -18
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/multi-agent/fsm.js +8 -3
- package/dist/core/multi-agent/fsm.js.map +1 -1
- package/dist/core/multi-agent/mailbox.js +1 -3
- package/dist/core/multi-agent/mailbox.js.map +1 -1
- package/dist/core/multi-agent/permission-gate.d.ts +5 -2
- package/dist/core/multi-agent/permission-gate.d.ts.map +1 -1
- package/dist/core/multi-agent/permission-gate.js +597 -34
- package/dist/core/multi-agent/permission-gate.js.map +1 -1
- package/dist/core/multi-agent/task-board.js +2 -4
- package/dist/core/multi-agent/task-board.js.map +1 -1
- package/dist/core/multi-agent/worktree.js +1 -3
- package/dist/core/multi-agent/worktree.js.map +1 -1
- package/dist/core/nested-tool-calls.d.ts +102 -0
- package/dist/core/nested-tool-calls.d.ts.map +1 -0
- package/dist/core/nested-tool-calls.js +178 -0
- package/dist/core/nested-tool-calls.js.map +1 -0
- package/dist/core/package-manager.d.ts +10 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +149 -33
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-manifest.d.ts.map +1 -1
- package/dist/core/pi-manifest.js +13 -12
- package/dist/core/pi-manifest.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +6 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +63 -37
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-attribution.js +5 -5
- package/dist/core/provider-attribution.js.map +1 -1
- package/dist/core/provider-composer.d.ts +44 -20
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +151 -51
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/radius.d.ts +13 -0
- package/dist/core/radius.d.ts.map +1 -1
- package/dist/core/radius.js +19 -0
- package/dist/core/radius.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +10 -3
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +105 -81
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts +7 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +219 -42
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +5 -5
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +13 -9
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sandbox/executor.js +1 -0
- package/dist/core/sandbox/executor.js.map +1 -1
- package/dist/core/sdk.d.ts +7 -5
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +100 -52
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-cwd.js +1 -0
- package/dist/core/session-cwd.js.map +1 -1
- package/dist/core/session-export.d.ts +8 -0
- package/dist/core/session-export.d.ts.map +1 -0
- package/dist/core/session-export.js +33 -0
- package/dist/core/session-export.js.map +1 -0
- package/dist/core/session-manager.d.ts +75 -15
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +314 -144
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-diagnostics.d.ts +9 -0
- package/dist/core/settings-diagnostics.d.ts.map +1 -0
- package/dist/core/settings-diagnostics.js +21 -0
- package/dist/core/settings-diagnostics.js.map +1 -0
- package/dist/core/settings-manager.d.ts +84 -4
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +239 -25
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +51 -33
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +3 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/soak/soak-log.js +6 -0
- package/dist/core/soak/soak-log.js.map +1 -1
- package/dist/core/socket-server/socket-server.js +11 -0
- package/dist/core/socket-server/socket-server.js.map +1 -1
- package/dist/core/socket-server/types.d.ts +2 -1
- package/dist/core/socket-server/types.d.ts.map +1 -1
- package/dist/core/socket-server/types.js.map +1 -1
- package/dist/core/source-info.d.ts +8 -0
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js +16 -0
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/system-prompt.d.ts +49 -6
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +126 -89
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +32 -2
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +82 -143
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +0 -5
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +2 -5
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts +5 -12
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +19 -171
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts +4 -0
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +11 -58
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +4 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +10 -62
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +4 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +18 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +4 -0
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +9 -50
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +11 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +54 -12
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +16 -0
- package/dist/core/tools/powershell.d.ts.map +1 -0
- package/dist/core/tools/powershell.js +39 -0
- package/dist/core/tools/powershell.js.map +1 -0
- package/dist/core/tools/read.d.ts +8 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +16 -123
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +6 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +26 -0
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts +12 -0
- package/dist/core/tools/renderers/bash.d.ts.map +1 -0
- package/dist/core/tools/renderers/bash.js +117 -0
- package/dist/core/tools/renderers/bash.js.map +1 -0
- package/dist/core/tools/renderers/edit.d.ts +23 -0
- package/dist/core/tools/renderers/edit.d.ts.map +1 -0
- package/dist/core/tools/renderers/edit.js +167 -0
- package/dist/core/tools/renderers/edit.js.map +1 -0
- package/dist/core/tools/renderers/find.d.ts +10 -0
- package/dist/core/tools/renderers/find.d.ts.map +1 -0
- package/dist/core/tools/renderers/find.js +64 -0
- package/dist/core/tools/renderers/find.js.map +1 -0
- package/dist/core/tools/renderers/grep.d.ts +10 -0
- package/dist/core/tools/renderers/grep.d.ts.map +1 -0
- package/dist/core/tools/renderers/grep.js +69 -0
- package/dist/core/tools/renderers/grep.js.map +1 -0
- package/dist/core/tools/renderers/index.d.ts +28 -0
- package/dist/core/tools/renderers/index.d.ts.map +1 -0
- package/dist/core/tools/renderers/index.js +47 -0
- package/dist/core/tools/renderers/index.js.map +1 -0
- package/dist/core/tools/renderers/ls.d.ts +10 -0
- package/dist/core/tools/renderers/ls.d.ts.map +1 -0
- package/dist/core/tools/renderers/ls.js +58 -0
- package/dist/core/tools/renderers/ls.js.map +1 -0
- package/dist/core/tools/renderers/read.d.ts +11 -0
- package/dist/core/tools/renderers/read.d.ts.map +1 -0
- package/dist/core/tools/renderers/read.js +130 -0
- package/dist/core/tools/renderers/read.js.map +1 -0
- package/dist/core/tools/renderers/write.d.ts +10 -0
- package/dist/core/tools/renderers/write.d.ts.map +1 -0
- package/dist/core/tools/renderers/write.js +153 -0
- package/dist/core/tools/renderers/write.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +5 -3
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +3 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/truncate.d.ts +14 -0
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/truncate.js +29 -0
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/core/tools/write.d.ts +4 -0
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +12 -147
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +4 -1
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/usage-totals.d.ts +3 -1
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js +28 -1
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/core/virtual-models.d.ts +117 -0
- package/dist/core/virtual-models.d.ts.map +1 -0
- package/dist/core/virtual-models.js +124 -0
- package/dist/core/virtual-models.js.map +1 -0
- package/dist/experimental/micro/api.d.ts +81 -0
- package/dist/experimental/micro/api.d.ts.map +1 -0
- package/dist/experimental/micro/api.js +2 -0
- package/dist/experimental/micro/api.js.map +1 -0
- package/dist/experimental/micro/main.d.ts +3 -0
- package/dist/experimental/micro/main.d.ts.map +1 -0
- package/dist/experimental/micro/main.js +21 -0
- package/dist/experimental/micro/main.js.map +1 -0
- package/dist/experimental/micro/models.d.ts +11 -0
- package/dist/experimental/micro/models.d.ts.map +1 -0
- package/dist/experimental/micro/models.js +95 -0
- package/dist/experimental/micro/models.js.map +1 -0
- package/dist/experimental/micro/runtime.d.ts +12 -0
- package/dist/experimental/micro/runtime.d.ts.map +1 -0
- package/dist/experimental/micro/runtime.js +465 -0
- package/dist/experimental/micro/runtime.js.map +1 -0
- package/dist/experimental/micro/sessions.d.ts +10 -0
- package/dist/experimental/micro/sessions.d.ts.map +1 -0
- package/dist/experimental/micro/sessions.js +41 -0
- package/dist/experimental/micro/sessions.js.map +1 -0
- package/dist/experimental/micro/tools.d.ts +10 -0
- package/dist/experimental/micro/tools.d.ts.map +1 -0
- package/dist/experimental/micro/tools.js +96 -0
- package/dist/experimental/micro/tools.js.map +1 -0
- package/dist/experimental/micro/tui.d.ts +3 -0
- package/dist/experimental/micro/tui.d.ts.map +1 -0
- package/dist/experimental/micro/tui.js +510 -0
- package/dist/experimental/micro/tui.js.map +1 -0
- package/dist/experimental/mini/main.d.ts +7 -0
- package/dist/experimental/mini/main.d.ts.map +1 -0
- package/dist/experimental/mini/main.js +21 -0
- package/dist/experimental/mini/main.js.map +1 -0
- package/dist/experimental/mini/server/entry.d.ts +3 -0
- package/dist/experimental/mini/server/entry.d.ts.map +1 -0
- package/dist/experimental/mini/server/entry.js +11 -0
- package/dist/experimental/mini/server/entry.js.map +1 -0
- package/dist/experimental/mini/server/run.d.ts +13 -0
- package/dist/experimental/mini/server/run.d.ts.map +1 -0
- package/dist/experimental/mini/server/run.js +150 -0
- package/dist/experimental/mini/server/run.js.map +1 -0
- package/dist/experimental/mini/shared/protocol.d.ts +127 -0
- package/dist/experimental/mini/shared/protocol.d.ts.map +1 -0
- package/dist/experimental/mini/shared/protocol.js +13 -0
- package/dist/experimental/mini/shared/protocol.js.map +1 -0
- package/dist/experimental/mini/shared/rpc.d.ts +49 -0
- package/dist/experimental/mini/shared/rpc.d.ts.map +1 -0
- package/dist/experimental/mini/shared/rpc.js +171 -0
- package/dist/experimental/mini/shared/rpc.js.map +1 -0
- package/dist/experimental/mini/shared/transport.d.ts +35 -0
- package/dist/experimental/mini/shared/transport.d.ts.map +1 -0
- package/dist/experimental/mini/shared/transport.js +94 -0
- package/dist/experimental/mini/shared/transport.js.map +1 -0
- package/dist/experimental/mini/tui/run.d.ts +9 -0
- package/dist/experimental/mini/tui/run.d.ts.map +1 -0
- package/dist/experimental/mini/tui/run.js +62 -0
- package/dist/experimental/mini/tui/run.js.map +1 -0
- package/dist/experimental/mini/tui/session.d.ts +26 -0
- package/dist/experimental/mini/tui/session.d.ts.map +1 -0
- package/dist/experimental/mini/tui/session.js +94 -0
- package/dist/experimental/mini/tui/session.js.map +1 -0
- package/dist/experimental/mini/tui/view.d.ts +10 -0
- package/dist/experimental/mini/tui/view.d.ts.map +1 -0
- package/dist/experimental/mini/tui/view.js +461 -0
- package/dist/experimental/mini/tui/view.js.map +1 -0
- package/dist/experimental/mini/worker/entry.d.ts +3 -0
- package/dist/experimental/mini/worker/entry.d.ts.map +1 -0
- package/dist/experimental/mini/worker/entry.js +10 -0
- package/dist/experimental/mini/worker/entry.js.map +1 -0
- package/dist/experimental/mini/worker/lane-service.d.ts +44 -0
- package/dist/experimental/mini/worker/lane-service.d.ts.map +1 -0
- package/dist/experimental/mini/worker/lane-service.js +97 -0
- package/dist/experimental/mini/worker/lane-service.js.map +1 -0
- package/dist/experimental/mini/worker/models-service.d.ts +19 -0
- package/dist/experimental/mini/worker/models-service.d.ts.map +1 -0
- package/dist/experimental/mini/worker/models-service.js +136 -0
- package/dist/experimental/mini/worker/models-service.js.map +1 -0
- package/dist/experimental/mini/worker/run.d.ts +14 -0
- package/dist/experimental/mini/worker/run.d.ts.map +1 -0
- package/dist/experimental/mini/worker/run.js +88 -0
- package/dist/experimental/mini/worker/run.js.map +1 -0
- package/dist/extensions/codemode/execute.d.ts +16 -0
- package/dist/extensions/codemode/execute.d.ts.map +1 -0
- package/dist/extensions/codemode/execute.js +429 -0
- package/dist/extensions/codemode/execute.js.map +1 -0
- package/dist/extensions/codemode/execute.lazy.d.ts +3 -0
- package/dist/extensions/codemode/execute.lazy.d.ts.map +1 -0
- package/dist/extensions/codemode/execute.lazy.js +3 -0
- package/dist/extensions/codemode/execute.lazy.js.map +1 -0
- package/dist/extensions/codemode/index.d.ts +21 -0
- package/dist/extensions/codemode/index.d.ts.map +1 -0
- package/dist/extensions/codemode/index.js +31 -0
- package/dist/extensions/codemode/index.js.map +1 -0
- package/dist/extensions/codemode/renderer.d.ts +12 -0
- package/dist/extensions/codemode/renderer.d.ts.map +1 -0
- package/dist/extensions/codemode/renderer.js +137 -0
- package/dist/extensions/codemode/renderer.js.map +1 -0
- package/dist/extensions/codemode/tool.d.ts +123 -0
- package/dist/extensions/codemode/tool.d.ts.map +1 -0
- package/dist/extensions/codemode/tool.js +315 -0
- package/dist/extensions/codemode/tool.js.map +1 -0
- package/dist/extensions/codemode/worker.d.ts +7 -0
- package/dist/extensions/codemode/worker.d.ts.map +1 -0
- package/dist/extensions/codemode/worker.js +7 -0
- package/dist/extensions/codemode/worker.js.map +1 -0
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +9 -1
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/llama/client.d.ts +8 -0
- package/dist/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js +13 -0
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/huggingface.js +2 -0
- package/dist/extensions/llama/huggingface.js.map +1 -1
- package/dist/extensions/llama/index.d.ts.map +1 -1
- package/dist/extensions/llama/index.js +13 -2
- package/dist/extensions/llama/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts +4 -2
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +119 -17
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/extensions/llama/ui.js +28 -12
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/extensions/mcp/cli.d.ts +21 -0
- package/dist/extensions/mcp/cli.d.ts.map +1 -0
- package/dist/extensions/mcp/cli.js +500 -0
- package/dist/extensions/mcp/cli.js.map +1 -0
- package/dist/extensions/mcp/cli.lazy.d.ts +3 -0
- package/dist/extensions/mcp/cli.lazy.d.ts.map +1 -0
- package/dist/extensions/mcp/cli.lazy.js +3 -0
- package/dist/extensions/mcp/cli.lazy.js.map +1 -0
- package/dist/extensions/mcp/config.d.ts +72 -0
- package/dist/extensions/mcp/config.d.ts.map +1 -0
- package/dist/extensions/mcp/config.js +158 -0
- package/dist/extensions/mcp/config.js.map +1 -0
- package/dist/extensions/mcp/index.d.ts +76 -0
- package/dist/extensions/mcp/index.d.ts.map +1 -0
- package/dist/extensions/mcp/index.js +1055 -0
- package/dist/extensions/mcp/index.js.map +1 -0
- package/dist/extensions/mcp/log.d.ts +16 -0
- package/dist/extensions/mcp/log.d.ts.map +1 -0
- package/dist/extensions/mcp/log.js +66 -0
- package/dist/extensions/mcp/log.js.map +1 -0
- package/dist/extensions/mcp/oauth.d.ts +96 -0
- package/dist/extensions/mcp/oauth.d.ts.map +1 -0
- package/dist/extensions/mcp/oauth.js +333 -0
- package/dist/extensions/mcp/oauth.js.map +1 -0
- package/dist/extensions/mcp/resources.d.ts +43 -0
- package/dist/extensions/mcp/resources.d.ts.map +1 -0
- package/dist/extensions/mcp/resources.js +262 -0
- package/dist/extensions/mcp/resources.js.map +1 -0
- package/dist/extensions/mcp/runtime.d.ts +98 -0
- package/dist/extensions/mcp/runtime.d.ts.map +1 -0
- package/dist/extensions/mcp/runtime.js +394 -0
- package/dist/extensions/mcp/runtime.js.map +1 -0
- package/dist/extensions/mcp/runtime.lazy.d.ts +3 -0
- package/dist/extensions/mcp/runtime.lazy.d.ts.map +1 -0
- package/dist/extensions/mcp/runtime.lazy.js +3 -0
- package/dist/extensions/mcp/runtime.lazy.js.map +1 -0
- package/dist/extensions/mcp/tools.d.ts +84 -0
- package/dist/extensions/mcp/tools.d.ts.map +1 -0
- package/dist/extensions/mcp/tools.js +251 -0
- package/dist/extensions/mcp/tools.js.map +1 -0
- package/dist/extensions/mcp/ui.d.ts +60 -0
- package/dist/extensions/mcp/ui.d.ts.map +1 -0
- package/dist/extensions/mcp/ui.js +174 -0
- package/dist/extensions/mcp/ui.js.map +1 -0
- package/dist/extensions/stub-provider/provider.d.ts +2 -2
- package/dist/extensions/stub-provider/provider.d.ts.map +1 -1
- package/dist/extensions/stub-provider/provider.js +2 -1
- package/dist/extensions/stub-provider/provider.js.map +1 -1
- package/dist/extensions/tool-search/index.d.ts +12 -0
- package/dist/extensions/tool-search/index.d.ts.map +1 -0
- package/dist/extensions/tool-search/index.js +15 -0
- package/dist/extensions/tool-search/index.js.map +1 -0
- package/dist/extensions/tool-search/tool.d.ts +73 -0
- package/dist/extensions/tool-search/tool.d.ts.map +1 -0
- package/dist/extensions/tool-search/tool.js +189 -0
- package/dist/extensions/tool-search/tool.js.map +1 -0
- package/dist/index.d.ts +20 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +4 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +123 -51
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +1 -1
- package/dist/migrations.js +7 -6
- package/dist/migrations.js.map +1 -1
- package/dist/modes/index.d.ts +1 -0
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/bug-report.d.ts +19 -0
- package/dist/modes/interactive/bug-report.d.ts.map +1 -0
- package/dist/modes/interactive/bug-report.js +211 -0
- package/dist/modes/interactive/bug-report.js.map +1 -0
- package/dist/modes/interactive/chat-viewport.d.ts +20 -0
- package/dist/modes/interactive/chat-viewport.d.ts.map +1 -0
- package/dist/modes/interactive/chat-viewport.js +28 -0
- package/dist/modes/interactive/chat-viewport.js.map +1 -0
- package/dist/modes/interactive/components/armin.js +10 -6
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +6 -2
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +38 -15
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +9 -4
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +3 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +15 -6
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +15 -6
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +35 -8
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js +5 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +10 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +54 -2
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +4 -1
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +7 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/daxnuts.js +8 -6
- package/dist/modes/interactive/components/daxnuts.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +1 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +4 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +14 -3
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +2 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +14 -2
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +16 -1
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +4 -4
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js +12 -4
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +7 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +51 -6
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +9 -3
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts +3 -0
- package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
- package/dist/modes/interactive/components/markdown-transform.js +19 -0
- package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
- package/dist/modes/interactive/components/mermaid.d.ts +11 -0
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -0
- package/dist/modes/interactive/components/mermaid.js +75 -0
- package/dist/modes/interactive/components/mermaid.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +10 -4
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +101 -40
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +11 -3
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +4 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +60 -32
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +5 -5
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +128 -78
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +23 -4
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +230 -67
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts +72 -0
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-submenu.js +165 -0
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +1 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +14 -5
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +3 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +12 -3
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js +2 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/themed-text.d.ts +17 -0
- package/dist/modes/interactive/components/themed-text.d.ts.map +1 -0
- package/dist/modes/interactive/components/themed-text.js +29 -0
- package/dist/modes/interactive/components/themed-text.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +15 -3
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +76 -18
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +21 -4
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +78 -52
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +44 -18
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +8 -2
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +6 -3
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +3 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +12 -2
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts +27 -3
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.js +39 -6
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -1
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +69 -5
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1314 -593
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/model-catalog-refresh.d.ts +7 -0
- package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -0
- package/dist/modes/interactive/model-catalog-refresh.js +34 -0
- package/dist/modes/interactive/model-catalog-refresh.js.map +1 -0
- package/dist/modes/interactive/session-share.d.ts +23 -0
- package/dist/modes/interactive/session-share.d.ts.map +1 -0
- package/dist/modes/interactive/session-share.js +130 -0
- package/dist/modes/interactive/session-share.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +54 -63
- package/dist/modes/interactive/theme/light.json +52 -60
- package/dist/modes/interactive/theme/system-theme.d.ts +54 -0
- package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/system-theme.js +535 -0
- package/dist/modes/interactive/theme/system-theme.js.map +1 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts +59 -7
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +164 -51
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme-json.d.ts +85 -0
- package/dist/modes/interactive/theme/theme-json.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-json.js +132 -0
- package/dist/modes/interactive/theme/theme-json.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +24 -3
- package/dist/modes/interactive/theme/theme.d.ts +80 -42
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +274 -417
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/tui-renderer.d.ts +22 -0
- package/dist/modes/interactive/tui-renderer.d.ts.map +1 -0
- package/dist/modes/interactive/tui-renderer.js +67 -0
- package/dist/modes/interactive/tui-renderer.js.map +1 -0
- package/dist/modes/json-event.d.ts +34 -0
- package/dist/modes/json-event.d.ts.map +1 -0
- package/dist/modes/json-event.js +29 -0
- package/dist/modes/json-event.js.map +1 -0
- package/dist/modes/print-mode.d.ts +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +12 -2
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +17 -9
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +27 -15
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +14 -12
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +22 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts +1 -0
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +217 -63
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/prompts/commands/plan-phase.md +1 -0
- package/dist/prompts/commands/review.md +2 -0
- package/dist/prompts/commands/verify-work.md +1 -0
- package/dist/prompts/commands/why.md +4 -0
- package/dist/rpc-entry.js +1 -0
- package/dist/rpc-entry.js.map +1 -1
- package/dist/skills/blast-radius/SKILL.md +1 -0
- package/dist/skills/explainers/SKILL.md +65 -0
- package/dist/skills/unslop/SKILL.md +19 -1
- package/dist/utils/abort.d.ts +5 -0
- package/dist/utils/abort.d.ts.map +1 -0
- package/dist/utils/abort.js +48 -0
- package/dist/utils/abort.js.map +1 -0
- package/dist/utils/changelog.js +1 -1
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/child-process.d.ts +1 -1
- package/dist/utils/child-process.js +1 -1
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts +7 -0
- package/dist/utils/clipboard-command.d.ts.map +1 -0
- package/dist/utils/clipboard-command.js +45 -0
- package/dist/utils/clipboard-command.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +60 -91
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +116 -121
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/draht-user-agent.d.ts +2 -0
- package/dist/utils/draht-user-agent.d.ts.map +1 -0
- package/dist/utils/draht-user-agent.js +5 -0
- package/dist/utils/draht-user-agent.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts +2 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +2 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/management-http.d.ts +25 -0
- package/dist/utils/management-http.d.ts.map +1 -0
- package/dist/utils/management-http.js +54 -0
- package/dist/utils/management-http.js.map +1 -0
- package/dist/utils/mime.js +1 -1
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/paths.d.ts +4 -3
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +15 -4
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/photon.d.ts +2 -1
- package/dist/utils/photon.d.ts.map +1 -1
- package/dist/utils/photon.js.map +1 -1
- package/dist/utils/shell.d.ts +4 -3
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +20 -35
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +1 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +62 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/text.d.ts +8 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +9 -0
- package/dist/utils/text.js.map +1 -0
- package/dist/utils/tool-result-images.d.ts +21 -0
- package/dist/utils/tool-result-images.d.ts.map +1 -0
- package/dist/utils/tool-result-images.js +48 -0
- package/dist/utils/tool-result-images.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +11 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +53 -36
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts +4 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +30 -9
- package/dist/utils/version-check.js.map +1 -1
- package/dist/utils/wsl.d.ts +3 -0
- package/dist/utils/wsl.d.ts.map +1 -0
- package/dist/utils/wsl.js +15 -0
- package/dist/utils/wsl.js.map +1 -0
- package/dist/utils/zip.d.ts +7 -0
- package/dist/utils/zip.d.ts.map +1 -0
- package/dist/utils/zip.js +60 -0
- package/dist/utils/zip.js.map +1 -0
- package/docs/cli-integration.md +106 -0
- package/docs/cli.md +374 -0
- package/docs/compaction.md +91 -29
- package/docs/configuration.md +47 -0
- package/docs/containerization.md +100 -66
- package/docs/custom-provider.md +109 -707
- package/docs/docs.json +155 -99
- package/docs/environment-variables.md +30 -17
- package/docs/extensions.md +169 -2811
- package/docs/how-pi-works.md +53 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/index.md +25 -69
- package/docs/json.md +197 -56
- package/docs/keybindings.md +89 -93
- package/docs/llama-cpp.md +18 -3
- package/docs/mcp.md +231 -0
- package/docs/message-types.md +261 -0
- package/docs/models.md +94 -478
- package/docs/packages.md +67 -163
- package/docs/prompt-templates.md +31 -68
- package/docs/providers.md +118 -215
- package/docs/quickstart.md +55 -108
- package/docs/rpc-commands.md +860 -0
- package/docs/rpc-extension-ui.md +200 -0
- package/docs/rpc.md +139 -1518
- package/docs/sdk.md +79 -1127
- package/docs/security.md +76 -32
- package/docs/session-format.md +73 -219
- package/docs/sessions.md +36 -116
- package/docs/settings.md +124 -257
- package/docs/shell-aliases.md +85 -5
- package/docs/skills.md +52 -189
- package/docs/slash-commands.md +61 -0
- package/docs/terminal-setup.md +132 -61
- package/docs/termux.md +74 -84
- package/docs/themes.md +91 -252
- package/docs/tmux.md +31 -39
- package/docs/tui.md +74 -891
- package/docs/usage.md +54 -255
- package/docs/virtual-models.md +114 -0
- package/docs/windows.md +57 -7
- package/examples/extensions/antigravity-image-gen.ts +9 -9
- package/examples/extensions/bash-spawn-hook.ts +1 -1
- package/examples/extensions/border-status-editor.ts +1 -1
- package/examples/extensions/built-in-tool-renderer.ts +16 -40
- package/examples/extensions/custom-compaction.ts +1 -16
- package/examples/extensions/custom-provider-anthropic/index.ts +20 -13
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +4 -3
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +5 -5
- package/examples/extensions/debug-provider.ts +90 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +7 -3
- package/examples/extensions/dynamic-resources/dynamic.json +3 -1
- package/examples/extensions/git-checkpoint.ts +2 -2
- package/examples/extensions/handoff.ts +2 -11
- package/examples/extensions/jev-router.ts +113 -0
- package/examples/extensions/minimal-mode.ts +24 -96
- package/examples/extensions/notify.ts +3 -1
- package/examples/extensions/prompt-customizer.ts +19 -67
- package/examples/extensions/qna.ts +3 -7
- package/examples/extensions/subagent/agents.ts +40 -9
- package/examples/extensions/subagent/index.ts +27 -4
- package/examples/extensions/summarize.ts +7 -18
- package/examples/extensions/titlebar-spinner.ts +1 -1
- package/examples/rpc-client.ts +35 -0
- package/examples/rpc-extension-ui.ts +38 -9
- package/examples/sdk/02-custom-model.ts +1 -2
- package/examples/sdk/06-extensions.ts +1 -1
- package/examples/sdk/09-api-keys-and-oauth.ts +1 -1
- package/examples/sdk/12-full-control.ts +1 -1
- package/examples/sdk/14-codemode-mcp.ts +61 -0
- package/package.json +25 -30
- package/prompts/commands/plan-phase.md +1 -0
- package/prompts/commands/review.md +2 -0
- package/prompts/commands/verify-work.md +1 -0
- package/prompts/commands/why.md +4 -0
- package/skills/blast-radius/SKILL.md +1 -0
- package/skills/explainers/SKILL.md +65 -0
- package/skills/unslop/SKILL.md +19 -1
- package/dist/utils/clipboard-native.d.ts +0 -11
- package/dist/utils/clipboard-native.d.ts.map +0 -1
- package/dist/utils/clipboard-native.js +0 -20
- package/dist/utils/clipboard-native.js.map +0 -1
- package/dist/utils/pi-user-agent.d.ts +0 -2
- package/dist/utils/pi-user-agent.d.ts.map +0 -1
- package/dist/utils/pi-user-agent.js +0 -5
- package/dist/utils/pi-user-agent.js.map +0 -1
- package/docs/development.md +0 -71
- package/docs/tree.md +0 -231
- package/examples/extensions/kimi-deferred-tools.ts +0 -61
|
@@ -6,43 +6,50 @@ import * as crypto from "node:crypto";
|
|
|
6
6
|
import * as fs from "node:fs";
|
|
7
7
|
import * as os from "node:os";
|
|
8
8
|
import * as path from "node:path";
|
|
9
|
-
import {
|
|
9
|
+
import { isRetryableAssistantError, } from "@draht/ai/compat";
|
|
10
|
+
import * as TuiLayouts from "@draht/tui";
|
|
11
|
+
import { CombinedAutocompleteProvider, Container, fuzzyFilter, getCapabilities, hyperlink, Markdown, matchesKey, Spacer, setCapabilityOverrides, setKeybindings, Text, TruncatedText, TuiAltScreen, TuiMainScreen, visibleWidth, } from "@draht/tui";
|
|
10
12
|
import chalk from "chalk";
|
|
11
|
-
import { spawn
|
|
12
|
-
import { APP_NAME, APP_TITLE, CONFIG_DIR_NAME, DISPLAY_VERSION, getAgentDir, getAuthPath, getDebugLogPath, getDocsPath,
|
|
13
|
+
import { spawn } from "child_process";
|
|
14
|
+
import { APP_NAME, APP_TITLE, CONFIG_DIR_NAME, DISPLAY_VERSION, getAgentDir, getAuthPath, getDebugLogPath, getDocsPath, VERSION, } from "../../config.js";
|
|
13
15
|
import { parseSkillBlock } from "../../core/agent-session.js";
|
|
14
16
|
import { SessionImportFileNotFoundError } from "../../core/agent-session-runtime.js";
|
|
15
17
|
import { CACHE_TTL_MS, collectCacheMisses, computeCacheWaste, detectCacheMiss, } from "../../core/cache-stats.js";
|
|
18
|
+
import { formatCacheWarmingStatus, formatCacheWarmingUsage } from "../../core/cache-warmer.js";
|
|
16
19
|
import { CheckpointManager } from "../../core/checkpoints/checkpoint-manager.js";
|
|
17
20
|
import { DEFAULT_REWIND_SCOPE, listRewindTargets, performRewind, REWIND_SCOPE_CHOICES, rewindScopeForLabel, } from "../../core/checkpoints/rewind.js";
|
|
18
21
|
import { formatContextWindow } from "../../core/context-windows.js";
|
|
22
|
+
import { findExtensionStackMatches, recordCrash, takeUnnotifiedCrash } from "../../core/crash-log.js";
|
|
23
|
+
import { DEFAULT_THINKING_LEVEL, THINKING_LEVEL_OPTIONS } from "../../core/defaults.js";
|
|
19
24
|
import { FooterDataProvider } from "../../core/footer-data-provider.js";
|
|
20
25
|
import { configureHttpDispatcher, formatHttpIdleTimeoutMs } from "../../core/http-dispatcher.js";
|
|
21
26
|
import { KeybindingsManager } from "../../core/keybindings.js";
|
|
22
|
-
import { createCompactionSummaryMessage } from "../../core/messages.js";
|
|
23
|
-
import { defaultModelPerProvider, findExactModelReferenceMatch,
|
|
27
|
+
import { createCompactionSummaryMessage, createCustomMessage } from "../../core/messages.js";
|
|
28
|
+
import { defaultModelPerProvider, findExactModelReferenceMatch, resolveModelScopeFromModels, } from "../../core/model-resolver.js";
|
|
29
|
+
import { CredentialSynchronizationError } from "../../core/model-runtime.js";
|
|
24
30
|
import { DefaultPackageManager } from "../../core/package-manager.js";
|
|
25
31
|
import { formatMissingSessionCwdPrompt, MissingSessionCwdError } from "../../core/session-cwd.js";
|
|
26
|
-
import { SessionManager, sessionEntryToContextMessages } from "../../core/session-manager.js";
|
|
32
|
+
import { SessionManager, sessionEntryToContextMessages, } from "../../core/session-manager.js";
|
|
27
33
|
import { BUILTIN_SLASH_COMMANDS } from "../../core/slash-commands.js";
|
|
28
34
|
import { boundedSafeText } from "../../core/socket-server/safe-text.js";
|
|
29
|
-
import {
|
|
35
|
+
import { withBuiltInRenderers } from "../../core/tools/renderers/index.js";
|
|
30
36
|
import { hasTrustRequiringProjectResources, ProjectTrustStore } from "../../core/trust-manager.js";
|
|
31
37
|
import { getUsageCostBreakdown } from "../../core/usage-totals.js";
|
|
32
38
|
import { getChangelogPath, getNewEntries, normalizeChangelogLinks, parseChangelog } from "../../utils/changelog.js";
|
|
33
|
-
import { copyToClipboard, readClipboardText } from "../../utils/clipboard.js";
|
|
39
|
+
import { copyToClipboard, readClipboardFilePaths, readClipboardText } from "../../utils/clipboard.js";
|
|
34
40
|
import { extensionForImageMimeType, readClipboardImage } from "../../utils/clipboard-image.js";
|
|
35
41
|
import { parseGitUrl } from "../../utils/git.js";
|
|
36
42
|
import { sendTerminalNotification } from "../../utils/notify.js";
|
|
37
43
|
import { getCwdRelativePath } from "../../utils/paths.js";
|
|
38
|
-
import { getPiUserAgent } from "../../utils/pi-user-agent.js";
|
|
39
44
|
import { killTrackedDetachedChildren } from "../../utils/shell.js";
|
|
45
|
+
import { loadAllHighlightLanguages } from "../../utils/syntax-highlight.js";
|
|
40
46
|
import { ensureTool } from "../../utils/tools-manager.js";
|
|
41
47
|
import { checkForNewPiVersion } from "../../utils/version-check.js";
|
|
48
|
+
import { reportBug } from "./bug-report.js";
|
|
49
|
+
import { createChatViewport } from "./chat-viewport.js";
|
|
42
50
|
import { ArminComponent } from "./components/armin.js";
|
|
43
51
|
import { AssistantMessageComponent } from "./components/assistant-message.js";
|
|
44
52
|
import { BashExecutionComponent } from "./components/bash-execution.js";
|
|
45
|
-
import { BorderedLoader } from "./components/bordered-loader.js";
|
|
46
53
|
import { BranchSummaryMessageComponent } from "./components/branch-summary-message.js";
|
|
47
54
|
import { CompactionSummaryMessageComponent } from "./components/compaction-summary-message.js";
|
|
48
55
|
import { CustomEditor } from "./components/custom-editor.js";
|
|
@@ -57,6 +64,7 @@ import { boundDialogText, ExtensionSelectorComponent, MAX_DETAIL_ROWS } from "./
|
|
|
57
64
|
import { FooterComponent, formatTokens } from "./components/footer.js";
|
|
58
65
|
import { formatKeyText, keyDisplayText, keyHint, keyText, rawKeyHint } from "./components/keybinding-hints.js";
|
|
59
66
|
import { LoginDialogComponent } from "./components/login-dialog.js";
|
|
67
|
+
import { createMermaidMarkdownTransformer } from "./components/mermaid.js";
|
|
60
68
|
import { ModelSelectorComponent } from "./components/model-selector.js";
|
|
61
69
|
import { formatAuthSelectorProviderType, OAuthSelectorComponent, } from "./components/oauth-selector.js";
|
|
62
70
|
import { ScopedModelsSelectorComponent } from "./components/scoped-models-selector.js";
|
|
@@ -64,31 +72,51 @@ import { SessionSelectorComponent } from "./components/session-selector.js";
|
|
|
64
72
|
import { SettingsSelectorComponent } from "./components/settings-selector.js";
|
|
65
73
|
import { SkillInvocationMessageComponent } from "./components/skill-invocation-message.js";
|
|
66
74
|
import { BranchSummaryStatusIndicator, CompactionStatusIndicator, IdleStatus, RetryStatusIndicator, WorkingStatusIndicator, } from "./components/status-indicator.js";
|
|
75
|
+
import { ThemedText } from "./components/themed-text.js";
|
|
76
|
+
import { ThinkingSelectorComponent } from "./components/thinking-selector.js";
|
|
67
77
|
import { ToolExecutionComponent } from "./components/tool-execution.js";
|
|
68
78
|
import { TreeSelectorComponent } from "./components/tree-selector.js";
|
|
69
79
|
import { TrustSelectorComponent } from "./components/trust-selector.js";
|
|
70
80
|
import { UserMessageComponent } from "./components/user-message.js";
|
|
71
81
|
import { UserMessageSelectorComponent } from "./components/user-message-selector.js";
|
|
72
82
|
import { editInExternalEditor } from "./external-editor.js";
|
|
83
|
+
import { refreshModelCatalogs } from "./model-catalog-refresh.js";
|
|
73
84
|
import { getModelSearchText } from "./model-search.js";
|
|
74
|
-
import {
|
|
85
|
+
import { shareSession } from "./session-share.js";
|
|
86
|
+
import { getAvailableThemes, getAvailableThemesWithPaths, getEditorTheme, getMarkdownTheme, getThemeByName, onThemeChange, SYSTEM_THEME_NAME, setRegisteredThemes, stopThemeWatcher, Theme, theme, } from "./theme/theme.js";
|
|
75
87
|
import { InteractiveThemeController } from "./theme/theme-controller.js";
|
|
88
|
+
import { createInteractiveTui, createInteractiveTuiReference } from "./tui-renderer.js";
|
|
89
|
+
export { createInteractiveTui, createInteractiveTuiReference } from "./tui-renderer.js";
|
|
90
|
+
function isWorkingStatusEditor(editor) {
|
|
91
|
+
return ("embedWorkingStatus" in editor &&
|
|
92
|
+
editor.embedWorkingStatus === true &&
|
|
93
|
+
"setWorkingStatusIndicator" in editor &&
|
|
94
|
+
typeof editor.setWorkingStatusIndicator === "function");
|
|
95
|
+
}
|
|
76
96
|
function isExpandable(obj) {
|
|
77
97
|
return typeof obj === "object" && obj !== null && "setExpanded" in obj && typeof obj.setExpanded === "function";
|
|
78
98
|
}
|
|
79
|
-
class ExpandableText extends
|
|
99
|
+
class ExpandableText extends ThemedText {
|
|
100
|
+
state;
|
|
80
101
|
constructor(getCollapsedText, getExpandedText, expanded = false, paddingX = 0, paddingY = 0) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
this.
|
|
102
|
+
const state = { expanded };
|
|
103
|
+
super(() => (state.expanded ? getExpandedText() : getCollapsedText()), paddingX, paddingY);
|
|
104
|
+
this.state = state;
|
|
84
105
|
}
|
|
85
106
|
setExpanded(expanded) {
|
|
86
|
-
this.
|
|
107
|
+
this.state.expanded = expanded;
|
|
108
|
+
this.invalidate();
|
|
87
109
|
}
|
|
88
110
|
}
|
|
89
111
|
function isCustomSessionEntry(item) {
|
|
90
112
|
return "type" in item && item.type === "custom";
|
|
91
113
|
}
|
|
114
|
+
function isCompactionCostNotice(item) {
|
|
115
|
+
return "type" in item && item.type === "compaction_cost";
|
|
116
|
+
}
|
|
117
|
+
function isUsageSessionEntry(item) {
|
|
118
|
+
return "type" in item && item.type === "usage";
|
|
119
|
+
}
|
|
92
120
|
const DEAD_TERMINAL_ERROR_CODES = new Set(["EIO", "EPIPE", "ENOTCONN"]);
|
|
93
121
|
function isDeadTerminalError(error) {
|
|
94
122
|
if (!error || typeof error !== "object" || !("code" in error)) {
|
|
@@ -97,6 +125,22 @@ function isDeadTerminalError(error) {
|
|
|
97
125
|
const code = error.code;
|
|
98
126
|
return code !== undefined && DEAD_TERMINAL_ERROR_CODES.has(code);
|
|
99
127
|
}
|
|
128
|
+
export function formatCrashExtensionHint(extensionMatches) {
|
|
129
|
+
const matches = Array.isArray(extensionMatches)
|
|
130
|
+
? extensionMatches.filter((match) => typeof match === "string" && match.length > 0)
|
|
131
|
+
: [];
|
|
132
|
+
if (matches.length === 0)
|
|
133
|
+
return undefined;
|
|
134
|
+
const quoted = matches.map((match) => `\`${match}\``);
|
|
135
|
+
const labels = quoted.length === 1
|
|
136
|
+
? quoted[0]
|
|
137
|
+
: quoted.length === 2
|
|
138
|
+
? quoted.join(" and ")
|
|
139
|
+
: `${quoted.slice(0, -1).join(", ")}, and ${quoted[quoted.length - 1]}`;
|
|
140
|
+
const noun = matches.length === 1 ? "extension" : "extensions";
|
|
141
|
+
const pronoun = matches.length === 1 ? "it" : "them";
|
|
142
|
+
return `A stack frame came from loaded ${noun} ${labels}, which may be involved. Try disabling ${pronoun} with \`${APP_NAME} config\`, or run \`${APP_NAME} -ne\` to confirm.`;
|
|
143
|
+
}
|
|
100
144
|
const ANTHROPIC_SUBSCRIPTION_AUTH_WARNING = "Anthropic subscription auth is active. Third-party harness usage draws from extra usage and is billed per token, not your Claude plan limits. Manage extra usage at https://claude.ai/settings/usage. Disable this warning in /settings.";
|
|
101
145
|
function isAnthropicSubscriptionAuthKey(apiKey) {
|
|
102
146
|
return typeof apiKey === "string" && apiKey.startsWith("sk-ant-oat");
|
|
@@ -128,6 +172,11 @@ export function formatResumeCommand(sessionManager) {
|
|
|
128
172
|
function hasDefaultModelProvider(providerId) {
|
|
129
173
|
return providerId in defaultModelPerProvider;
|
|
130
174
|
}
|
|
175
|
+
function llamaCppPostLoginGuidance(actionLabel, loadedModelCount) {
|
|
176
|
+
return loadedModelCount === 0
|
|
177
|
+
? `${actionLabel}. No llama.cpp models are loaded. Use /llama to load a model, then /model to select it.`
|
|
178
|
+
: `${actionLabel}. Use /model to select a loaded llama.cpp model, or /llama to manage models.`;
|
|
179
|
+
}
|
|
131
180
|
const AUTH_TYPE_ORDER = { oauth: 0, api_key: 1 };
|
|
132
181
|
function createFuzzyAutocompleteItems(items, prefix, getSearchText, toAutocompleteItem) {
|
|
133
182
|
const filtered = fuzzyFilter(items, prefix, getSearchText);
|
|
@@ -165,6 +214,132 @@ function formatLoginProviderCompletionDescription(provider) {
|
|
|
165
214
|
return provider.name === provider.id ? authTypes : `${provider.name} · ${authTypes}`;
|
|
166
215
|
}
|
|
167
216
|
export class InteractiveMode {
|
|
217
|
+
runtimeHost;
|
|
218
|
+
renderer;
|
|
219
|
+
ui;
|
|
220
|
+
mainScreenRenderState;
|
|
221
|
+
loadedResourcesContainer;
|
|
222
|
+
chatContainer;
|
|
223
|
+
documentContainer;
|
|
224
|
+
transcriptScrollView;
|
|
225
|
+
fullscreenLayoutRoot;
|
|
226
|
+
pendingMessagesContainer;
|
|
227
|
+
statusContainer;
|
|
228
|
+
defaultEditor;
|
|
229
|
+
editor;
|
|
230
|
+
editorComponentFactory;
|
|
231
|
+
autocompleteProvider;
|
|
232
|
+
autocompleteProviderWrappers = [];
|
|
233
|
+
fdPath;
|
|
234
|
+
editorContainer;
|
|
235
|
+
activeSelectorToken;
|
|
236
|
+
activeSelectorDispose;
|
|
237
|
+
footer;
|
|
238
|
+
footerContainer;
|
|
239
|
+
footerDataProvider;
|
|
240
|
+
// Stored so the same manager can be injected into custom editors, selectors, and extension UI.
|
|
241
|
+
keybindings;
|
|
242
|
+
version;
|
|
243
|
+
isInitialized = false;
|
|
244
|
+
onInputCallback;
|
|
245
|
+
pendingUserInputs = [];
|
|
246
|
+
activeStatusIndicator = undefined;
|
|
247
|
+
activeWorkingIndicatorEmbedded = false;
|
|
248
|
+
idleStatus = new IdleStatus();
|
|
249
|
+
workingMessage = undefined;
|
|
250
|
+
workingVisible = true;
|
|
251
|
+
workingIndicatorOptions = undefined;
|
|
252
|
+
defaultWorkingMessage = "Working";
|
|
253
|
+
defaultHiddenThinkingLabel = "Thinking...";
|
|
254
|
+
hiddenThinkingLabel = this.defaultHiddenThinkingLabel;
|
|
255
|
+
lastSigintTime = 0;
|
|
256
|
+
lastEscapeTime = 0;
|
|
257
|
+
changelogMarkdown = undefined;
|
|
258
|
+
startupNoticesShown = false;
|
|
259
|
+
anthropicSubscriptionWarningShown = false;
|
|
260
|
+
// Status line tracking (for mutating immediately-sequential status updates)
|
|
261
|
+
lastStatusSpacer = undefined;
|
|
262
|
+
lastStatusText = undefined;
|
|
263
|
+
lastStatusMessage = "";
|
|
264
|
+
managedToolStatusStarted = false;
|
|
265
|
+
// Streaming message tracking
|
|
266
|
+
streamingComponent = undefined;
|
|
267
|
+
entriesRenderedByBoundaryCompaction = new Set();
|
|
268
|
+
streamingMessage = undefined;
|
|
269
|
+
// Tool execution tracking: toolCallId -> component
|
|
270
|
+
pendingTools = new Map();
|
|
271
|
+
// Tool output expansion state
|
|
272
|
+
toolOutputExpanded = false;
|
|
273
|
+
// Thinking block visibility state
|
|
274
|
+
hideThinkingBlock = false;
|
|
275
|
+
outputPad = 1;
|
|
276
|
+
mermaidMarkdownTransformer = createMermaidMarkdownTransformer({
|
|
277
|
+
getMode: () => this.settingsManager.getMermaidRenderingMode(),
|
|
278
|
+
theme,
|
|
279
|
+
});
|
|
280
|
+
// Skill commands: command name -> skill file path
|
|
281
|
+
skillCommands = new Map();
|
|
282
|
+
// Agent subscription unsubscribe function
|
|
283
|
+
unsubscribe;
|
|
284
|
+
signalCleanupHandlers = [];
|
|
285
|
+
// Track if editor is in bash mode (text starts with !)
|
|
286
|
+
isBashMode = false;
|
|
287
|
+
// True while `/rewind` is rewriting the working tree. The selector hands
|
|
288
|
+
// focus back to the editor before the restore finishes, so submissions have
|
|
289
|
+
// to be gated here or a new prompt runs against a half-restored tree.
|
|
290
|
+
isRewindRunning = false;
|
|
291
|
+
// Track current bash execution component
|
|
292
|
+
bashComponent = undefined;
|
|
293
|
+
// Track pending bash components (shown in pending area, moved to chat on submit)
|
|
294
|
+
pendingBashComponents = [];
|
|
295
|
+
// Auto-compaction state
|
|
296
|
+
autoCompactionEscapeHandler;
|
|
297
|
+
// Auto-retry state
|
|
298
|
+
retryEscapeHandler;
|
|
299
|
+
// Messages queued while compaction is running
|
|
300
|
+
compactionQueuedMessages = [];
|
|
301
|
+
// Shutdown state
|
|
302
|
+
shutdownRequested = false;
|
|
303
|
+
/** The `/bug` hint is shown at most once per session so error output stays readable. */
|
|
304
|
+
bugReportHintShown = false;
|
|
305
|
+
// Extension UI state
|
|
306
|
+
extensionSelector = undefined;
|
|
307
|
+
/**
|
|
308
|
+
* Settles the promise of the dialog currently occupying {@link extensionSelector}.
|
|
309
|
+
*
|
|
310
|
+
* The slot holds at most one dialog, so opening a second one used to overwrite the first without
|
|
311
|
+
* settling it — stranding a promise that `beforeToolCall` is awaiting, which wedges the agent
|
|
312
|
+
* loop forever. Keeping the settle function beside the component makes the slot non-clobbering.
|
|
313
|
+
*/
|
|
314
|
+
extensionSelectorSettle = undefined;
|
|
315
|
+
/** Label of the surface that decided the open ask elsewhere, pending a one-line notice. */
|
|
316
|
+
extensionDialogDecidedBy = undefined;
|
|
317
|
+
extensionInput = undefined;
|
|
318
|
+
/** Settles the promise `showExtensionInput` returned. See {@link hideExtensionInput}. */
|
|
319
|
+
extensionInputSettle = undefined;
|
|
320
|
+
extensionEditor = undefined;
|
|
321
|
+
/** Settles the promise `showExtensionEditor` returned. See {@link hideExtensionEditor}. */
|
|
322
|
+
extensionEditorSettle = undefined;
|
|
323
|
+
extensionTerminalInputSubscriptions = new Set();
|
|
324
|
+
// Extension widgets (components rendered above/below the editor)
|
|
325
|
+
extensionWidgetsAbove = new Map();
|
|
326
|
+
extensionWidgetsBelow = new Map();
|
|
327
|
+
widgetContainerAbove;
|
|
328
|
+
widgetContainerBelow;
|
|
329
|
+
// Custom footer from extension (undefined = use built-in footer)
|
|
330
|
+
customFooter = undefined;
|
|
331
|
+
// Header container that holds the built-in or custom header
|
|
332
|
+
headerContainer;
|
|
333
|
+
// Built-in header (logo + keybinding hints + changelog)
|
|
334
|
+
builtInHeader = undefined;
|
|
335
|
+
// Custom header from extension (undefined = use built-in header)
|
|
336
|
+
customHeader = undefined;
|
|
337
|
+
options;
|
|
338
|
+
onRightClickPaste = () => {
|
|
339
|
+
void this.handleRightClickPaste();
|
|
340
|
+
};
|
|
341
|
+
autoTrustOnReloadCwd;
|
|
342
|
+
themeController;
|
|
168
343
|
// Convenience accessors
|
|
169
344
|
get session() {
|
|
170
345
|
return this.runtimeHost.session;
|
|
@@ -179,101 +354,37 @@ export class InteractiveMode {
|
|
|
179
354
|
return this.session.settingsManager;
|
|
180
355
|
}
|
|
181
356
|
constructor(runtimeHost, options = {}) {
|
|
182
|
-
this.autocompleteProviderWrappers = [];
|
|
183
|
-
this.isInitialized = false;
|
|
184
|
-
this.pendingUserInputs = [];
|
|
185
|
-
this.activeStatusIndicator = undefined;
|
|
186
|
-
this.idleStatus = new IdleStatus();
|
|
187
|
-
this.workingMessage = undefined;
|
|
188
|
-
this.workingVisible = true;
|
|
189
|
-
this.workingIndicatorOptions = undefined;
|
|
190
|
-
this.defaultWorkingMessage = "Working...";
|
|
191
|
-
this.defaultHiddenThinkingLabel = "Thinking...";
|
|
192
|
-
this.hiddenThinkingLabel = this.defaultHiddenThinkingLabel;
|
|
193
|
-
this.lastSigintTime = 0;
|
|
194
|
-
this.lastEscapeTime = 0;
|
|
195
|
-
this.changelogMarkdown = undefined;
|
|
196
|
-
this.startupNoticesShown = false;
|
|
197
|
-
this.anthropicSubscriptionWarningShown = false;
|
|
198
|
-
// Status line tracking (for mutating immediately-sequential status updates)
|
|
199
|
-
this.lastStatusSpacer = undefined;
|
|
200
|
-
this.lastStatusText = undefined;
|
|
201
|
-
// Streaming message tracking
|
|
202
|
-
this.streamingComponent = undefined;
|
|
203
|
-
this.streamingMessage = undefined;
|
|
204
|
-
// Tool execution tracking: toolCallId -> component
|
|
205
|
-
this.pendingTools = new Map();
|
|
206
|
-
// Tool output expansion state
|
|
207
|
-
this.toolOutputExpanded = false;
|
|
208
|
-
// Thinking block visibility state
|
|
209
|
-
this.hideThinkingBlock = false;
|
|
210
|
-
this.outputPad = 1;
|
|
211
|
-
// Skill commands: command name -> skill file path
|
|
212
|
-
this.skillCommands = new Map();
|
|
213
|
-
this.signalCleanupHandlers = [];
|
|
214
|
-
// Track if editor is in bash mode (text starts with !)
|
|
215
|
-
this.isBashMode = false;
|
|
216
|
-
// True while `/rewind` is rewriting the working tree. The selector hands
|
|
217
|
-
// focus back to the editor before the restore finishes, so submissions have
|
|
218
|
-
// to be gated here or a new prompt runs against a half-restored tree.
|
|
219
|
-
this.isRewindRunning = false;
|
|
220
|
-
// Track current bash execution component
|
|
221
|
-
this.bashComponent = undefined;
|
|
222
|
-
// Track pending bash components (shown in pending area, moved to chat on submit)
|
|
223
|
-
this.pendingBashComponents = [];
|
|
224
|
-
// Messages queued while compaction is running
|
|
225
|
-
this.compactionQueuedMessages = [];
|
|
226
|
-
// Shutdown state
|
|
227
|
-
this.shutdownRequested = false;
|
|
228
|
-
// Extension UI state
|
|
229
|
-
this.extensionSelector = undefined;
|
|
230
|
-
/**
|
|
231
|
-
* Settles the promise of the dialog currently occupying {@link extensionSelector}.
|
|
232
|
-
*
|
|
233
|
-
* The slot holds at most one dialog, so opening a second one used to overwrite the first without
|
|
234
|
-
* settling it — stranding a promise that `beforeToolCall` is awaiting, which wedges the agent
|
|
235
|
-
* loop forever. Keeping the settle function beside the component makes the slot non-clobbering.
|
|
236
|
-
*/
|
|
237
|
-
this.extensionSelectorSettle = undefined;
|
|
238
|
-
/** Label of the surface that decided the open ask elsewhere, pending a one-line notice. */
|
|
239
|
-
this.extensionDialogDecidedBy = undefined;
|
|
240
|
-
this.extensionInput = undefined;
|
|
241
|
-
/** Settles the promise `showExtensionInput` returned. See {@link hideExtensionInput}. */
|
|
242
|
-
this.extensionInputSettle = undefined;
|
|
243
|
-
this.extensionEditor = undefined;
|
|
244
|
-
/** Settles the promise `showExtensionEditor` returned. See {@link hideExtensionEditor}. */
|
|
245
|
-
this.extensionEditorSettle = undefined;
|
|
246
|
-
this.extensionTerminalInputUnsubscribers = new Set();
|
|
247
|
-
// Extension widgets (components rendered above/below the editor)
|
|
248
|
-
this.extensionWidgetsAbove = new Map();
|
|
249
|
-
this.extensionWidgetsBelow = new Map();
|
|
250
|
-
// Custom footer from extension (undefined = use built-in footer)
|
|
251
|
-
this.customFooter = undefined;
|
|
252
|
-
// Built-in header (logo + keybinding hints + changelog)
|
|
253
|
-
this.builtInHeader = undefined;
|
|
254
|
-
// Custom header from extension (undefined = use built-in header)
|
|
255
|
-
this.customHeader = undefined;
|
|
256
|
-
/**
|
|
257
|
-
* Gracefully shutdown the agent.
|
|
258
|
-
* Stops the TUI before emitting shutdown events so extension UI cleanup cannot
|
|
259
|
-
* repaint the final frame while the process is exiting.
|
|
260
|
-
*/
|
|
261
|
-
this.isShuttingDown = false;
|
|
262
357
|
this.runtimeHost = runtimeHost;
|
|
263
|
-
this.
|
|
358
|
+
setCapabilityOverrides(this.settingsManager.getTerminalCapabilityOverrides());
|
|
359
|
+
const tuiMode = options.tuiMode ?? this.settingsManager.getTuiMode();
|
|
360
|
+
this.options = { ...options, tuiMode };
|
|
264
361
|
this.autoTrustOnReloadCwd = options.autoTrustOnReloadCwd;
|
|
265
362
|
this.runtimeHost.setBeforeSessionInvalidate(() => {
|
|
266
363
|
this.resetExtensionUI();
|
|
267
364
|
});
|
|
268
365
|
this.runtimeHost.setRebindSession(async () => {
|
|
269
366
|
await this.rebindCurrentSession({ renderBeforeBind: true });
|
|
367
|
+
this.themeController.applyFromSettings();
|
|
270
368
|
});
|
|
271
369
|
this.version = VERSION;
|
|
272
|
-
this.
|
|
370
|
+
this.renderer = createInteractiveTui({
|
|
371
|
+
tuiMode,
|
|
372
|
+
showHardwareCursor: this.settingsManager.getShowHardwareCursor(),
|
|
373
|
+
logDirectory: getAgentDir(),
|
|
374
|
+
terminal: options.terminal,
|
|
375
|
+
onRightClickPaste: this.onRightClickPaste,
|
|
376
|
+
fullscreenCopyOnSelect: this.settingsManager.getFullscreenCopyOnSelect(),
|
|
377
|
+
fullscreenWheelScrollLines: this.settingsManager.getFullscreenWheelScrollLines(),
|
|
378
|
+
});
|
|
379
|
+
this.ui = createInteractiveTuiReference(() => this.renderer);
|
|
273
380
|
this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());
|
|
274
381
|
this.headerContainer = new Container();
|
|
275
382
|
this.loadedResourcesContainer = new Container();
|
|
276
383
|
this.chatContainer = new Container();
|
|
384
|
+
this.documentContainer = new Container();
|
|
385
|
+
this.documentContainer.addChild(this.headerContainer);
|
|
386
|
+
this.documentContainer.addChild(this.loadedResourcesContainer);
|
|
387
|
+
this.documentContainer.addChild(this.chatContainer);
|
|
277
388
|
this.pendingMessagesContainer = new Container();
|
|
278
389
|
this.statusContainer = new Container();
|
|
279
390
|
this.widgetContainerAbove = new Container();
|
|
@@ -285,6 +396,7 @@ export class InteractiveMode {
|
|
|
285
396
|
this.defaultEditor = new CustomEditor(this.ui, getEditorTheme(), this.keybindings, {
|
|
286
397
|
paddingX: editorPaddingX,
|
|
287
398
|
autocompleteMaxVisible,
|
|
399
|
+
embedWorkingStatus: true,
|
|
288
400
|
});
|
|
289
401
|
this.editor = this.defaultEditor;
|
|
290
402
|
this.editorContainer = new Container();
|
|
@@ -292,15 +404,23 @@ export class InteractiveMode {
|
|
|
292
404
|
this.footerDataProvider = new FooterDataProvider(this.sessionManager.getCwd());
|
|
293
405
|
this.footer = new FooterComponent(this.session, this.footerDataProvider);
|
|
294
406
|
this.footer.setAutoCompactEnabled(this.session.autoCompactionEnabled);
|
|
407
|
+
this.footerContainer = new Container();
|
|
408
|
+
this.footerContainer.addChild(this.footer);
|
|
295
409
|
// Load hide thinking block setting
|
|
296
410
|
this.hideThinkingBlock = this.settingsManager.getHideThinkingBlock();
|
|
297
411
|
this.outputPad = this.settingsManager.getOutputPad();
|
|
298
412
|
// Register themes from resource loader and initialize
|
|
299
413
|
setRegisteredThemes(this.session.resourceLoader.getThemes().themes);
|
|
300
|
-
this.themeController = new InteractiveThemeController(this.ui,
|
|
414
|
+
this.themeController = new InteractiveThemeController(this.ui, {
|
|
415
|
+
getSettingsManager: () => this.settingsManager,
|
|
416
|
+
showError: (message) => this.showError(message),
|
|
417
|
+
onChanged: () => this.updateEditorBorderColor(),
|
|
418
|
+
initialThemeSetting: options.initialThemeSetting,
|
|
419
|
+
});
|
|
301
420
|
}
|
|
302
421
|
getAutocompleteSourceTag(sourceInfo) {
|
|
303
|
-
|
|
422
|
+
// Built-in extension commands are untagged, like built-in commands.
|
|
423
|
+
if (!sourceInfo || sourceInfo.source === "builtin") {
|
|
304
424
|
return undefined;
|
|
305
425
|
}
|
|
306
426
|
const scopePrefix = sourceInfo.scope === "user" ? "u" : sourceInfo.scope === "project" ? "p" : "t";
|
|
@@ -347,11 +467,10 @@ export class InteractiveMode {
|
|
|
347
467
|
}));
|
|
348
468
|
const modelCommand = slashCommands.find((command) => command.name === "model");
|
|
349
469
|
if (modelCommand) {
|
|
350
|
-
modelCommand.getArgumentCompletions =
|
|
351
|
-
// Get available models (scoped or from registry)
|
|
470
|
+
modelCommand.getArgumentCompletions = (prefix) => {
|
|
352
471
|
const models = this.session.scopedModels.length > 0
|
|
353
472
|
? this.session.scopedModels.map((s) => s.model)
|
|
354
|
-
:
|
|
473
|
+
: this.session.modelRuntime.getAvailableSnapshot();
|
|
355
474
|
if (models.length === 0)
|
|
356
475
|
return null;
|
|
357
476
|
// Create items with provider/id format
|
|
@@ -368,6 +487,15 @@ export class InteractiveMode {
|
|
|
368
487
|
}));
|
|
369
488
|
};
|
|
370
489
|
}
|
|
490
|
+
const thinkingCommand = slashCommands.find((command) => command.name === "thinking");
|
|
491
|
+
if (thinkingCommand) {
|
|
492
|
+
thinkingCommand.getArgumentCompletions = (prefix) => {
|
|
493
|
+
return createFuzzyAutocompleteItems(this.session.getAvailableThinkingLevels(), prefix, (level) => level, (level) => ({
|
|
494
|
+
value: level,
|
|
495
|
+
label: level,
|
|
496
|
+
}));
|
|
497
|
+
};
|
|
498
|
+
}
|
|
371
499
|
const loginCommand = slashCommands.find((command) => command.name === "login");
|
|
372
500
|
if (loginCommand) {
|
|
373
501
|
loginCommand.getArgumentCompletions = (prefix) => {
|
|
@@ -445,23 +573,88 @@ export class InteractiveMode {
|
|
|
445
573
|
this.chatContainer.addChild(new Text(condensedText, 1, 0));
|
|
446
574
|
}
|
|
447
575
|
else {
|
|
448
|
-
this.chatContainer.addChild(new
|
|
576
|
+
this.chatContainer.addChild(new ThemedText(() => theme.bold(theme.fg("accent", "What's New")), 1, 0));
|
|
449
577
|
this.chatContainer.addChild(new Spacer(1));
|
|
450
578
|
this.chatContainer.addChild(new Markdown(this.changelogMarkdown.trim(), 1, 0, this.getMarkdownThemeWithSettings()));
|
|
451
579
|
this.chatContainer.addChild(new Spacer(1));
|
|
452
580
|
}
|
|
453
581
|
this.chatContainer.addChild(new DynamicBorder());
|
|
454
582
|
}
|
|
583
|
+
mountInteractiveTui(tui, components) {
|
|
584
|
+
for (const component of components)
|
|
585
|
+
tui.addChild(component);
|
|
586
|
+
if (TuiLayouts.isViewportTUI(tui)) {
|
|
587
|
+
if (!this.fullscreenLayoutRoot)
|
|
588
|
+
throw new Error("Fullscreen layout is not initialized");
|
|
589
|
+
tui.setLayoutRoot(this.fullscreenLayoutRoot);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
stopInteractiveTui(fullscreenExitOutput) {
|
|
593
|
+
if (this.renderer.mode === "fullscreen" && fullscreenExitOutput === "transcript") {
|
|
594
|
+
while (this.renderer.hasOverlayEntries)
|
|
595
|
+
this.renderer.hideOverlay();
|
|
596
|
+
this.switchTuiMode("regular", false, false);
|
|
597
|
+
this.renderer.renderNow();
|
|
598
|
+
}
|
|
599
|
+
this.ui.stop({ preserveScreen: this.renderer.mode === "fullscreen" });
|
|
600
|
+
}
|
|
601
|
+
switchTuiMode(mode, restoreProgress = true, startRenderer = true) {
|
|
602
|
+
const previousUi = this.renderer;
|
|
603
|
+
if (mode === previousUi.mode)
|
|
604
|
+
return true;
|
|
605
|
+
if (previousUi.hasOverlayEntries)
|
|
606
|
+
return false;
|
|
607
|
+
const components = [...previousUi.children];
|
|
608
|
+
const focus = previousUi.getFocusedComponent();
|
|
609
|
+
const terminal = previousUi.terminal;
|
|
610
|
+
const showHardwareCursor = previousUi.getShowHardwareCursor();
|
|
611
|
+
const clearOnShrink = previousUi.getClearOnShrink();
|
|
612
|
+
const onDebug = previousUi.onDebug;
|
|
613
|
+
if (previousUi instanceof TuiMainScreen) {
|
|
614
|
+
this.mainScreenRenderState = previousUi.captureRenderState();
|
|
615
|
+
}
|
|
616
|
+
previousUi.stop({ preserveScreen: true });
|
|
617
|
+
previousUi.setFocus(null);
|
|
618
|
+
previousUi.clear();
|
|
619
|
+
if (TuiLayouts.isViewportTUI(previousUi))
|
|
620
|
+
previousUi.setLayoutRoot(undefined);
|
|
621
|
+
const nextUi = createInteractiveTui({
|
|
622
|
+
tuiMode: mode,
|
|
623
|
+
showHardwareCursor,
|
|
624
|
+
logDirectory: getAgentDir(),
|
|
625
|
+
terminal,
|
|
626
|
+
onRightClickPaste: this.onRightClickPaste,
|
|
627
|
+
fullscreenCopyOnSelect: this.settingsManager.getFullscreenCopyOnSelect(),
|
|
628
|
+
fullscreenWheelScrollLines: this.settingsManager.getFullscreenWheelScrollLines(),
|
|
629
|
+
});
|
|
630
|
+
nextUi.setClearOnShrink(clearOnShrink);
|
|
631
|
+
nextUi.onDebug = onDebug;
|
|
632
|
+
if (nextUi instanceof TuiMainScreen && this.mainScreenRenderState) {
|
|
633
|
+
nextUi.restoreRenderState(this.mainScreenRenderState);
|
|
634
|
+
}
|
|
635
|
+
this.renderer = nextUi;
|
|
636
|
+
this.options.tuiMode = mode;
|
|
637
|
+
this.mountInteractiveTui(nextUi, components);
|
|
638
|
+
nextUi.invalidate();
|
|
639
|
+
nextUi.setFocus(focus);
|
|
640
|
+
if (!startRenderer)
|
|
641
|
+
return true;
|
|
642
|
+
nextUi.start();
|
|
643
|
+
this.themeController.rebindTui();
|
|
644
|
+
this.rebindExtensionTerminalInputListeners();
|
|
645
|
+
if (restoreProgress &&
|
|
646
|
+
this.settingsManager.getShowTerminalProgress() &&
|
|
647
|
+
(this.session.isStreaming || this.session.isCompacting)) {
|
|
648
|
+
terminal.setProgress(true);
|
|
649
|
+
}
|
|
650
|
+
return true;
|
|
651
|
+
}
|
|
455
652
|
async init() {
|
|
456
653
|
if (this.isInitialized)
|
|
457
654
|
return;
|
|
458
655
|
this.registerSignalHandlers();
|
|
459
656
|
// Load changelog (only show new entries, skip for resumed sessions)
|
|
460
657
|
this.changelogMarkdown = this.getChangelogForDisplay();
|
|
461
|
-
// Ensure fd and rg are available (downloads if missing, adds to PATH via getBinDir)
|
|
462
|
-
// Both are needed: fd for autocomplete, rg for grep tool and bash commands
|
|
463
|
-
const [fdPath] = await Promise.all([ensureTool("fd"), ensureTool("rg")]);
|
|
464
|
-
this.fdPath = fdPath;
|
|
465
658
|
if (this.session.scopedModels.length > 0 && (this.options.verbose || !this.settingsManager.getQuietStartup())) {
|
|
466
659
|
const modelList = this.session.scopedModels
|
|
467
660
|
.map((sm) => {
|
|
@@ -475,43 +668,65 @@ export class InteractiveMode {
|
|
|
475
668
|
: "";
|
|
476
669
|
console.log(theme.fg("dim", `Model scope: ${modelList}${cycleHint}`));
|
|
477
670
|
}
|
|
478
|
-
//
|
|
479
|
-
// Keep loaded resources before chat so restored session messages never precede them.
|
|
480
|
-
this.ui.addChild(this.headerContainer);
|
|
481
|
-
this.ui.addChild(this.loadedResourcesContainer);
|
|
482
|
-
this.ui.addChild(this.chatContainer);
|
|
483
|
-
this.ui.addChild(this.pendingMessagesContainer);
|
|
484
|
-
this.ui.addChild(this.statusContainer);
|
|
671
|
+
// Keep one component tree and remount it when changing renderers.
|
|
485
672
|
this.renderWidgets(); // Initialize with default spacer
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
673
|
+
const viewport = createChatViewport({
|
|
674
|
+
document: this.documentContainer,
|
|
675
|
+
pendingMessages: this.pendingMessagesContainer,
|
|
676
|
+
status: this.statusContainer,
|
|
677
|
+
widgetsAbove: this.widgetContainerAbove,
|
|
678
|
+
editor: this.editorContainer,
|
|
679
|
+
widgetsBelow: this.widgetContainerBelow,
|
|
680
|
+
footer: this.footerContainer,
|
|
681
|
+
scrollbar: this.settingsManager.getFullscreenScrollbar(),
|
|
682
|
+
scrollbarTrackStyle: (text) => theme.fg("scrollbarTrack", text),
|
|
683
|
+
scrollbarThumbStyle: (text) => theme.fg("scrollbarThumb", text),
|
|
684
|
+
});
|
|
685
|
+
this.transcriptScrollView = viewport.transcript;
|
|
686
|
+
this.fullscreenLayoutRoot = viewport.root;
|
|
687
|
+
this.mountInteractiveTui(this.renderer, [
|
|
688
|
+
this.documentContainer,
|
|
689
|
+
this.pendingMessagesContainer,
|
|
690
|
+
this.statusContainer,
|
|
691
|
+
this.widgetContainerAbove,
|
|
692
|
+
this.editorContainer,
|
|
693
|
+
this.widgetContainerBelow,
|
|
694
|
+
this.footerContainer,
|
|
695
|
+
]);
|
|
696
|
+
// Accept text while startup completes, but only enable interrupt, exit, and submission feedback.
|
|
697
|
+
this.defaultEditor.onAction("app.clear", () => this.handleCtrlC());
|
|
698
|
+
this.defaultEditor.onCtrlD = () => this.handleCtrlD();
|
|
699
|
+
this.defaultEditor.onSubmit = (text) => this.handleStartupSubmit(text);
|
|
490
700
|
this.ui.setFocus(this.editor);
|
|
491
|
-
this.setupKeyHandlers();
|
|
492
|
-
this.setupEditorSubmitHandler();
|
|
493
701
|
// Start the UI before initializing extensions so session_start handlers can use interactive dialogs
|
|
494
702
|
this.ui.start();
|
|
495
703
|
this.isInitialized = true;
|
|
496
|
-
|
|
704
|
+
this.themeController.applyFromSettings();
|
|
705
|
+
// The header and startup notices bake theme colors into their text, so build them once the terminal
|
|
706
|
+
// reported its colors. This ends at the terminal's DA1 reply, or after 100 ms if it answers nothing.
|
|
707
|
+
await this.themeController.waitForTerminalColors();
|
|
497
708
|
// Add header with keybindings from config (unless silenced)
|
|
498
709
|
if (this.options.verbose || !this.settingsManager.getQuietStartup()) {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
710
|
+
// Built on demand so the header follows theme changes.
|
|
711
|
+
const logo = () => {
|
|
712
|
+
const asciiArt = [
|
|
713
|
+
" ╭─╮",
|
|
714
|
+
" ╰─┼──────────╮",
|
|
715
|
+
" │ ┌──────╮ │",
|
|
716
|
+
" │ │ │ │",
|
|
717
|
+
" │ │ │ │",
|
|
718
|
+
" └─┼──────╯ │",
|
|
719
|
+
" └────────╯",
|
|
720
|
+
]
|
|
721
|
+
.map((line) => theme.fg("border", line))
|
|
722
|
+
.join("\n");
|
|
723
|
+
const wordmark = theme.bold(theme.fg("accent", APP_NAME)) + theme.fg("dim", ` v${DISPLAY_VERSION} · /dʁaːt/`);
|
|
724
|
+
return `${asciiArt}\n${wordmark}`;
|
|
725
|
+
};
|
|
726
|
+
const withLogo = (hints) => `${logo()}\n${hints}`;
|
|
512
727
|
// Build startup instructions using keybinding hint helpers
|
|
513
728
|
const hint = (keybinding, description) => keyHint(keybinding, description);
|
|
514
|
-
const expandedInstructions = [
|
|
729
|
+
const expandedInstructions = () => [
|
|
515
730
|
hint("app.interrupt", "to interrupt"),
|
|
516
731
|
hint("app.clear", "to clear"),
|
|
517
732
|
rawKeyHint(`${keyText("app.clear")} twice`, "to exit"),
|
|
@@ -532,19 +747,19 @@ export class InteractiveMode {
|
|
|
532
747
|
rawKeyHint("!!", "to run bash (no context)"),
|
|
533
748
|
hint("app.message.followUp", "to queue follow-up"),
|
|
534
749
|
hint("app.message.dequeue", "to edit all queued messages"),
|
|
535
|
-
hint("app.clipboard.pasteImage", "to paste
|
|
750
|
+
hint("app.clipboard.pasteImage", "to paste files on macOS, images, or text"),
|
|
536
751
|
rawKeyHint("drop files", "to attach"),
|
|
537
752
|
].join("\n");
|
|
538
|
-
const compactInstructions = [
|
|
753
|
+
const compactInstructions = () => [
|
|
539
754
|
hint("app.interrupt", "interrupt"),
|
|
540
755
|
rawKeyHint(`${keyText("app.clear")}/${keyText("app.exit")}`, "clear/exit"),
|
|
541
756
|
rawKeyHint("/", "commands"),
|
|
542
757
|
rawKeyHint("!", "bash"),
|
|
543
758
|
hint("app.tools.expand", "more"),
|
|
544
759
|
].join(theme.fg("muted", " · "));
|
|
545
|
-
const compactOnboarding = theme.fg("dim", `Press ${keyText("app.tools.expand")} to show full startup help and loaded resources.`);
|
|
546
|
-
const onboarding = theme.fg("dim", `${APP_NAME} can explain its own features and look up its docs. Ask it how to use or extend ${APP_NAME}.`);
|
|
547
|
-
this.builtInHeader = new ExpandableText(() => `${
|
|
760
|
+
const compactOnboarding = () => theme.fg("dim", `Press ${keyText("app.tools.expand")} to show full startup help and loaded resources.`);
|
|
761
|
+
const onboarding = () => theme.fg("dim", `${APP_NAME} can explain its own features and look up its docs. Ask it how to use or extend ${APP_NAME}.`);
|
|
762
|
+
this.builtInHeader = new ExpandableText(() => `${withLogo(compactInstructions())}\n${compactOnboarding()}\n\n${onboarding()}`, () => `${withLogo(expandedInstructions())}\n\n${onboarding()}`, this.getStartupExpansionState(), 1, 0);
|
|
548
763
|
// Setup UI layout
|
|
549
764
|
this.headerContainer.addChild(new Spacer(1));
|
|
550
765
|
this.headerContainer.addChild(this.builtInHeader);
|
|
@@ -556,6 +771,18 @@ export class InteractiveMode {
|
|
|
556
771
|
this.headerContainer.addChild(this.builtInHeader);
|
|
557
772
|
}
|
|
558
773
|
this.ui.requestRender();
|
|
774
|
+
// Ensure fd and rg are available after mounting the TUI (downloads if missing, adds to PATH via getBinDir)
|
|
775
|
+
// so slow downloads do not make startup appear frozen.
|
|
776
|
+
// Both are needed: fd for autocomplete, rg for grep tool and bash commands.
|
|
777
|
+
const [fdPath] = await Promise.all([
|
|
778
|
+
ensureTool("fd", (status) => this.showManagedToolStatus(status)),
|
|
779
|
+
ensureTool("rg", (status) => this.showManagedToolStatus(status)),
|
|
780
|
+
]);
|
|
781
|
+
this.fdPath = fdPath;
|
|
782
|
+
// Enable the remaining input handlers only after managed-tool setup completes.
|
|
783
|
+
this.setupKeyHandlers();
|
|
784
|
+
this.setupEditorSubmitHandler();
|
|
785
|
+
this.ui.requestRender();
|
|
559
786
|
// Initialize extensions first so resources are shown before messages
|
|
560
787
|
await this.rebindCurrentSession();
|
|
561
788
|
// Render initial messages AFTER showing loaded resources
|
|
@@ -572,6 +799,14 @@ export class InteractiveMode {
|
|
|
572
799
|
});
|
|
573
800
|
// Initialize available provider count for footer display
|
|
574
801
|
await this.updateAvailableProviderCount();
|
|
802
|
+
// Flush the completed startup state before loading the remaining syntax grammars.
|
|
803
|
+
this.ui.renderNow();
|
|
804
|
+
void loadAllHighlightLanguages().then(() => {
|
|
805
|
+
if (!this.isInitialized)
|
|
806
|
+
return;
|
|
807
|
+
this.ui.invalidate();
|
|
808
|
+
this.ui.requestRender();
|
|
809
|
+
});
|
|
575
810
|
}
|
|
576
811
|
/**
|
|
577
812
|
* Update terminal title with session name and cwd.
|
|
@@ -593,10 +828,12 @@ export class InteractiveMode {
|
|
|
593
828
|
async run() {
|
|
594
829
|
await this.init();
|
|
595
830
|
if (!process.env.DRAHT_OFFLINE) {
|
|
596
|
-
|
|
597
|
-
|
|
831
|
+
const controller = new AbortController();
|
|
832
|
+
const timeout = setTimeout(() => controller.abort(), 15_000);
|
|
833
|
+
void refreshModelCatalogs(this.session.modelRuntime, controller.signal)
|
|
598
834
|
.then(() => this.updateAvailableProviderCount())
|
|
599
|
-
.catch(() => { })
|
|
835
|
+
.catch(() => { })
|
|
836
|
+
.finally(() => clearTimeout(timeout));
|
|
600
837
|
}
|
|
601
838
|
// Start version check asynchronously
|
|
602
839
|
checkForNewPiVersion(this.version).then((newRelease) => {
|
|
@@ -625,7 +862,18 @@ export class InteractiveMode {
|
|
|
625
862
|
}
|
|
626
863
|
});
|
|
627
864
|
// Show startup warnings
|
|
628
|
-
const { migratedProviders, modelFallbackMessage, initialMessage, initialImages, initialMessages } = this.options;
|
|
865
|
+
const { migratedProviders, startupDiagnostics, modelFallbackMessage, initialMessage, initialImages, initialMessages, } = this.options;
|
|
866
|
+
for (const diagnostic of startupDiagnostics ?? []) {
|
|
867
|
+
if (diagnostic.type === "error") {
|
|
868
|
+
this.showError(diagnostic.message);
|
|
869
|
+
}
|
|
870
|
+
else if (diagnostic.type === "warning") {
|
|
871
|
+
this.showWarning(diagnostic.message);
|
|
872
|
+
}
|
|
873
|
+
else {
|
|
874
|
+
this.showStatus(diagnostic.message);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
629
877
|
if (migratedProviders && migratedProviders.length > 0) {
|
|
630
878
|
this.showWarning(`Migrated credentials to auth.json: ${migratedProviders.join(", ")}`);
|
|
631
879
|
}
|
|
@@ -636,6 +884,11 @@ export class InteractiveMode {
|
|
|
636
884
|
if (modelFallbackMessage) {
|
|
637
885
|
this.showWarning(modelFallbackMessage);
|
|
638
886
|
}
|
|
887
|
+
const crash = takeUnnotifiedCrash();
|
|
888
|
+
if (crash) {
|
|
889
|
+
const when = new Date(crash.timestamp).toLocaleString();
|
|
890
|
+
this.showWarning(`${APP_NAME} crashed on ${when} (${crash.message}). Run /bug to report it; the crash details are attached automatically.`);
|
|
891
|
+
}
|
|
639
892
|
void this.maybeWarnAboutAnthropicSubscriptionAuth();
|
|
640
893
|
// Process initial messages
|
|
641
894
|
if (initialMessage) {
|
|
@@ -741,35 +994,17 @@ export class InteractiveMode {
|
|
|
741
994
|
const changelogPath = getChangelogPath();
|
|
742
995
|
const entries = parseChangelog(changelogPath);
|
|
743
996
|
if (!lastVersion) {
|
|
744
|
-
// Fresh install - record the version,
|
|
997
|
+
// Fresh install - record the version, don't show changelog
|
|
745
998
|
this.settingsManager.setLastChangelogVersion(VERSION);
|
|
746
|
-
this.reportInstallTelemetry(VERSION);
|
|
747
999
|
return undefined;
|
|
748
1000
|
}
|
|
749
1001
|
const newEntries = getNewEntries(entries, lastVersion);
|
|
750
1002
|
if (newEntries.length > 0) {
|
|
751
1003
|
this.settingsManager.setLastChangelogVersion(VERSION);
|
|
752
|
-
this.reportInstallTelemetry(VERSION);
|
|
753
1004
|
return newEntries.map((e) => normalizeChangelogLinks(e.content, e)).join("\n\n");
|
|
754
1005
|
}
|
|
755
1006
|
return undefined;
|
|
756
1007
|
}
|
|
757
|
-
reportInstallTelemetry(version) {
|
|
758
|
-
if (process.env.DRAHT_OFFLINE) {
|
|
759
|
-
return;
|
|
760
|
-
}
|
|
761
|
-
if (!isInstallTelemetryEnabled(this.settingsManager)) {
|
|
762
|
-
return;
|
|
763
|
-
}
|
|
764
|
-
void fetch(`https://pi.dev/api/report-install?version=${encodeURIComponent(version)}`, {
|
|
765
|
-
headers: {
|
|
766
|
-
"User-Agent": getPiUserAgent(version),
|
|
767
|
-
},
|
|
768
|
-
signal: AbortSignal.timeout(5000),
|
|
769
|
-
})
|
|
770
|
-
.then(() => undefined)
|
|
771
|
-
.catch(() => undefined);
|
|
772
|
-
}
|
|
773
1008
|
getMarkdownThemeWithSettings() {
|
|
774
1009
|
return {
|
|
775
1010
|
...getMarkdownTheme(),
|
|
@@ -1079,8 +1314,9 @@ export class InteractiveMode {
|
|
|
1079
1314
|
}
|
|
1080
1315
|
return theme.fg("dim", ` ${labels.join(", ")}`);
|
|
1081
1316
|
};
|
|
1317
|
+
// Bodies are built on demand so the listing follows theme changes.
|
|
1082
1318
|
const addLoadedSection = (name, collapsedBody, expandedBody = collapsedBody, color = "mdHeading") => {
|
|
1083
|
-
const section = new ExpandableText(() => `${sectionHeader(name, color)}\n${collapsedBody}`, () => `${sectionHeader(name, color)}\n${expandedBody}`, this.getStartupExpansionState(), 0, 0);
|
|
1319
|
+
const section = new ExpandableText(() => `${sectionHeader(name, color)}\n${collapsedBody()}`, () => `${sectionHeader(name, color)}\n${expandedBody()}`, this.getStartupExpansionState(), 0, 0);
|
|
1084
1320
|
this.loadedResourcesContainer.addChild(section);
|
|
1085
1321
|
this.loadedResourcesContainer.addChild(new Spacer(1));
|
|
1086
1322
|
};
|
|
@@ -1125,27 +1361,25 @@ export class InteractiveMode {
|
|
|
1125
1361
|
];
|
|
1126
1362
|
if (contextFiles.length > 0) {
|
|
1127
1363
|
this.loadedResourcesContainer.addChild(new Spacer(1));
|
|
1128
|
-
const contextList = contextFiles
|
|
1129
|
-
|
|
1130
|
-
.join("\n");
|
|
1131
|
-
const contextCompactList = formatCompactList(contextFiles.map((contextFile) => this.formatContextPath(contextFile.path)), { sort: false });
|
|
1364
|
+
const contextList = () => contextFiles.map((f) => theme.fg("dim", ` ${this.formatDisplayPath(f.path)}`)).join("\n");
|
|
1365
|
+
const contextCompactList = () => formatCompactList(contextFiles.map((contextFile) => this.formatContextPath(contextFile.path)), { sort: false });
|
|
1132
1366
|
addLoadedSection("Context", contextCompactList, contextList);
|
|
1133
1367
|
}
|
|
1134
1368
|
const skills = skillsResult.skills;
|
|
1135
1369
|
if (skills.length > 0) {
|
|
1136
1370
|
const groups = this.buildScopeGroups(skills.map((skill) => ({ path: skill.filePath, sourceInfo: skill.sourceInfo })));
|
|
1137
|
-
const skillList = this.formatScopeGroups(groups, {
|
|
1371
|
+
const skillList = () => this.formatScopeGroups(groups, {
|
|
1138
1372
|
formatPath: (item) => this.formatDisplayPath(item.path),
|
|
1139
1373
|
formatPackagePath: (item) => this.getShortPath(item.path, item.sourceInfo),
|
|
1140
1374
|
});
|
|
1141
|
-
const skillCompactList = formatCompactList(skills.map((skill) => skill.name));
|
|
1375
|
+
const skillCompactList = () => formatCompactList(skills.map((skill) => skill.name));
|
|
1142
1376
|
addLoadedSection("Skills", skillCompactList, skillList);
|
|
1143
1377
|
}
|
|
1144
1378
|
const templates = this.session.promptTemplates;
|
|
1145
1379
|
if (templates.length > 0) {
|
|
1146
1380
|
const groups = this.buildScopeGroups(templates.map((template) => ({ path: template.filePath, sourceInfo: template.sourceInfo })));
|
|
1147
1381
|
const templateByPath = new Map(templates.map((t) => [t.filePath, t]));
|
|
1148
|
-
const templateList = this.formatScopeGroups(groups, {
|
|
1382
|
+
const templateList = () => this.formatScopeGroups(groups, {
|
|
1149
1383
|
formatPath: (item) => {
|
|
1150
1384
|
const template = templateByPath.get(item.path);
|
|
1151
1385
|
return template ? `/${template.name}` : this.formatDisplayPath(item.path);
|
|
@@ -1155,53 +1389,40 @@ export class InteractiveMode {
|
|
|
1155
1389
|
return template ? `/${template.name}` : this.formatDisplayPath(item.path);
|
|
1156
1390
|
},
|
|
1157
1391
|
});
|
|
1158
|
-
const promptCompactList = formatCompactList(templates.map((template) => `/${template.name}`));
|
|
1392
|
+
const promptCompactList = () => formatCompactList(templates.map((template) => `/${template.name}`));
|
|
1159
1393
|
addLoadedSection("Prompts", promptCompactList, templateList);
|
|
1160
1394
|
}
|
|
1161
1395
|
if (extensions.length > 0) {
|
|
1162
1396
|
const groups = this.buildScopeGroups(extensions);
|
|
1163
|
-
const extList = this.formatScopeGroups(groups, {
|
|
1397
|
+
const extList = () => this.formatScopeGroups(groups, {
|
|
1164
1398
|
formatPath: (item) => this.formatExtensionDisplayPath(item.path),
|
|
1165
1399
|
formatPackagePath: (item) => this.formatExtensionDisplayPath(this.getShortPath(item.path, item.sourceInfo)),
|
|
1166
1400
|
});
|
|
1167
|
-
const
|
|
1401
|
+
const extensionLabels = this.getCompactExtensionLabels(extensions);
|
|
1402
|
+
const extensionCompactList = () => formatCompactList(extensionLabels);
|
|
1168
1403
|
addLoadedSection("Extensions", extensionCompactList, extList, "mdHeading");
|
|
1169
1404
|
}
|
|
1170
|
-
// Show loaded themes (excluding built-in)
|
|
1171
|
-
const loadedThemes = themesResult.themes;
|
|
1172
|
-
const customThemes = loadedThemes.filter((t) => t.sourcePath);
|
|
1173
|
-
if (customThemes.length > 0) {
|
|
1174
|
-
const groups = this.buildScopeGroups(customThemes.map((loadedTheme) => ({
|
|
1175
|
-
path: loadedTheme.sourcePath,
|
|
1176
|
-
sourceInfo: loadedTheme.sourceInfo,
|
|
1177
|
-
})));
|
|
1178
|
-
const themeList = this.formatScopeGroups(groups, {
|
|
1179
|
-
formatPath: (item) => this.formatDisplayPath(item.path),
|
|
1180
|
-
formatPackagePath: (item) => this.getShortPath(item.path, item.sourceInfo),
|
|
1181
|
-
});
|
|
1182
|
-
const themeCompactList = formatCompactList(customThemes.map((loadedTheme) => loadedTheme.name ?? this.getCompactPathLabel(loadedTheme.sourcePath, loadedTheme.sourceInfo)));
|
|
1183
|
-
addLoadedSection("Themes", themeCompactList, themeList);
|
|
1184
|
-
}
|
|
1185
1405
|
}
|
|
1186
1406
|
if (showDiagnostics) {
|
|
1187
1407
|
const skillDiagnostics = skillsResult.diagnostics;
|
|
1188
1408
|
if (skillDiagnostics.length > 0) {
|
|
1189
|
-
const warningLines = this.formatDiagnostics(skillDiagnostics, sourceInfos);
|
|
1190
|
-
this.loadedResourcesContainer.addChild(new
|
|
1409
|
+
const warningLines = () => this.formatDiagnostics(skillDiagnostics, sourceInfos);
|
|
1410
|
+
this.loadedResourcesContainer.addChild(new ThemedText(() => `${theme.fg("warning", "[Skill conflicts]")}\n${warningLines()}`, 0, 0));
|
|
1191
1411
|
this.loadedResourcesContainer.addChild(new Spacer(1));
|
|
1192
1412
|
}
|
|
1193
1413
|
const promptDiagnostics = promptsResult.diagnostics;
|
|
1194
1414
|
if (promptDiagnostics.length > 0) {
|
|
1195
|
-
const warningLines = this.formatDiagnostics(promptDiagnostics, sourceInfos);
|
|
1196
|
-
this.loadedResourcesContainer.addChild(new
|
|
1415
|
+
const warningLines = () => this.formatDiagnostics(promptDiagnostics, sourceInfos);
|
|
1416
|
+
this.loadedResourcesContainer.addChild(new ThemedText(() => `${theme.fg("warning", "[Prompt conflicts]")}\n${warningLines()}`, 0, 0));
|
|
1197
1417
|
this.loadedResourcesContainer.addChild(new Spacer(1));
|
|
1198
1418
|
}
|
|
1199
1419
|
const extensionDiagnostics = [];
|
|
1200
|
-
const
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1420
|
+
const extensionsResult = this.session.resourceLoader.getExtensions();
|
|
1421
|
+
for (const error of extensionsResult.errors) {
|
|
1422
|
+
extensionDiagnostics.push({ type: "error", message: error.error, path: error.path });
|
|
1423
|
+
}
|
|
1424
|
+
for (const warning of extensionsResult.warnings ?? []) {
|
|
1425
|
+
extensionDiagnostics.push({ type: "warning", message: warning.warning, path: warning.path });
|
|
1205
1426
|
}
|
|
1206
1427
|
const commandDiagnostics = this.session.extensionRunner.getCommandDiagnostics();
|
|
1207
1428
|
extensionDiagnostics.push(...commandDiagnostics);
|
|
@@ -1209,14 +1430,14 @@ export class InteractiveMode {
|
|
|
1209
1430
|
const shortcutDiagnostics = this.session.extensionRunner.getShortcutDiagnostics();
|
|
1210
1431
|
extensionDiagnostics.push(...shortcutDiagnostics);
|
|
1211
1432
|
if (extensionDiagnostics.length > 0) {
|
|
1212
|
-
const warningLines = this.formatDiagnostics(extensionDiagnostics, sourceInfos);
|
|
1213
|
-
this.loadedResourcesContainer.addChild(new
|
|
1433
|
+
const warningLines = () => this.formatDiagnostics(extensionDiagnostics, sourceInfos);
|
|
1434
|
+
this.loadedResourcesContainer.addChild(new ThemedText(() => `${theme.fg("warning", "[Extension issues]")}\n${warningLines()}`, 0, 0));
|
|
1214
1435
|
this.loadedResourcesContainer.addChild(new Spacer(1));
|
|
1215
1436
|
}
|
|
1216
1437
|
const themeDiagnostics = themesResult.diagnostics;
|
|
1217
1438
|
if (themeDiagnostics.length > 0) {
|
|
1218
|
-
const warningLines = this.formatDiagnostics(themeDiagnostics, sourceInfos);
|
|
1219
|
-
this.loadedResourcesContainer.addChild(new
|
|
1439
|
+
const warningLines = () => this.formatDiagnostics(themeDiagnostics, sourceInfos);
|
|
1440
|
+
this.loadedResourcesContainer.addChild(new ThemedText(() => `${theme.fg("warning", "[Theme conflicts]")}\n${warningLines()}`, 0, 0));
|
|
1220
1441
|
this.loadedResourcesContainer.addChild(new Spacer(1));
|
|
1221
1442
|
}
|
|
1222
1443
|
}
|
|
@@ -1299,8 +1520,17 @@ export class InteractiveMode {
|
|
|
1299
1520
|
this.showLoadedResources({ force: false, showDiagnosticsWhenQuiet: true });
|
|
1300
1521
|
this.showStartupNoticesIfNeeded();
|
|
1301
1522
|
}
|
|
1523
|
+
applyFullscreenScrollbarSetting() {
|
|
1524
|
+
this.transcriptScrollView?.setScrollbar(this.settingsManager.getFullscreenScrollbar());
|
|
1525
|
+
}
|
|
1302
1526
|
applyRuntimeSettings() {
|
|
1527
|
+
setCapabilityOverrides(this.settingsManager.getTerminalCapabilityOverrides());
|
|
1303
1528
|
configureHttpDispatcher(this.settingsManager.getHttpIdleTimeoutMs());
|
|
1529
|
+
this.applyFullscreenScrollbarSetting();
|
|
1530
|
+
if (this.renderer instanceof TuiAltScreen) {
|
|
1531
|
+
this.renderer.setCopyOnSelect(this.settingsManager.getFullscreenCopyOnSelect());
|
|
1532
|
+
this.renderer.setWheelScrollLines(this.settingsManager.getFullscreenWheelScrollLines());
|
|
1533
|
+
}
|
|
1304
1534
|
this.footer.setSession(this.session);
|
|
1305
1535
|
this.footer.setAutoCompactEnabled(this.session.autoCompactionEnabled);
|
|
1306
1536
|
this.footerDataProvider.setCwd(this.sessionManager.getCwd());
|
|
@@ -1344,10 +1574,60 @@ export class InteractiveMode {
|
|
|
1344
1574
|
async handleFatalRuntimeError(prefix, error) {
|
|
1345
1575
|
const message = error instanceof Error ? error.message : String(error);
|
|
1346
1576
|
this.showError(`${prefix}: ${message}`);
|
|
1577
|
+
const extensionHint = this.getCrashExtensionHint(error);
|
|
1578
|
+
if (extensionHint) {
|
|
1579
|
+
this.chatContainer.addChild(new ThemedText(() => theme.fg("warning", extensionHint), this.outputPad, 0));
|
|
1580
|
+
}
|
|
1581
|
+
if (this.recordCrash("fatal_error", error)) {
|
|
1582
|
+
const instructions = this.crashReportInstructions();
|
|
1583
|
+
this.chatContainer.addChild(new ThemedText(() => theme.fg("muted", instructions), this.outputPad, 0));
|
|
1584
|
+
}
|
|
1347
1585
|
stopThemeWatcher();
|
|
1348
|
-
this.stop();
|
|
1586
|
+
this.stop("transcript");
|
|
1349
1587
|
process.exit(1);
|
|
1350
1588
|
}
|
|
1589
|
+
getCrashExtensionHint(error) {
|
|
1590
|
+
try {
|
|
1591
|
+
return formatCrashExtensionHint(findExtensionStackMatches(error instanceof Error ? error.stack : undefined, this.session.resourceLoader.getExtensions().extensions));
|
|
1592
|
+
}
|
|
1593
|
+
catch {
|
|
1594
|
+
return undefined;
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
/** Persist a crash so the next start can point the user at `/bug`. Returns false when nothing was written. */
|
|
1598
|
+
recordCrash(kind, error) {
|
|
1599
|
+
try {
|
|
1600
|
+
return (recordCrash({
|
|
1601
|
+
kind,
|
|
1602
|
+
error,
|
|
1603
|
+
sessionFile: this.session.sessionFile,
|
|
1604
|
+
cwd: this.session.sessionManager.getCwd(),
|
|
1605
|
+
}) !== undefined);
|
|
1606
|
+
}
|
|
1607
|
+
catch {
|
|
1608
|
+
return false;
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
crashReportInstructions() {
|
|
1612
|
+
const resume = this.session.sessionFile
|
|
1613
|
+
? `run \`${APP_NAME} -r\` to resume the session, then`
|
|
1614
|
+
: `start ${APP_NAME} and`;
|
|
1615
|
+
return `To report this crash: ${resume} run /bug. The crash details are attached automatically.`;
|
|
1616
|
+
}
|
|
1617
|
+
suggestBugReport() {
|
|
1618
|
+
if (this.bugReportHintShown)
|
|
1619
|
+
return;
|
|
1620
|
+
this.bugReportHintShown = true;
|
|
1621
|
+
this.chatContainer.addChild(new ThemedText(() => theme.fg("muted", `If this looks like a ${APP_NAME} bug, /bug collects a report to the developers.`), this.outputPad, 0));
|
|
1622
|
+
this.ui.requestRender();
|
|
1623
|
+
}
|
|
1624
|
+
maybeSuggestBugReport(message) {
|
|
1625
|
+
if (message.stopReason !== "error" || isRetryableAssistantError(message))
|
|
1626
|
+
return;
|
|
1627
|
+
if (/\b(?:abort(?:ed)?|cancel(?:l?ed)?)\b/i.test(message.errorMessage ?? ""))
|
|
1628
|
+
return;
|
|
1629
|
+
this.suggestBugReport();
|
|
1630
|
+
}
|
|
1351
1631
|
renderCurrentSessionState() {
|
|
1352
1632
|
this.loadedResourcesContainer.clear();
|
|
1353
1633
|
this.chatContainer.clear();
|
|
@@ -1361,8 +1641,15 @@ export class InteractiveMode {
|
|
|
1361
1641
|
/**
|
|
1362
1642
|
* Get a registered tool definition by name (for custom rendering).
|
|
1363
1643
|
*/
|
|
1644
|
+
/**
|
|
1645
|
+
* Extension-registered definition, falling back to the built-in one. The renderer components take
|
|
1646
|
+
* whatever this returns, so they never reach into the tool registry themselves.
|
|
1647
|
+
*/
|
|
1364
1648
|
getRegisteredToolDefinition(toolName) {
|
|
1365
|
-
return this.session.getToolDefinition(toolName);
|
|
1649
|
+
return withBuiltInRenderers(toolName, this.session.getToolDefinition(toolName));
|
|
1650
|
+
}
|
|
1651
|
+
getMarkdownTransformers() {
|
|
1652
|
+
return [this.mermaidMarkdownTransformer, ...this.session.extensionRunner.getMarkdownTransformers()];
|
|
1366
1653
|
}
|
|
1367
1654
|
/**
|
|
1368
1655
|
* Set up keyboard shortcuts registered by extensions.
|
|
@@ -1429,24 +1716,49 @@ export class InteractiveMode {
|
|
|
1429
1716
|
this.footerDataProvider.setExtensionStatus(key, text);
|
|
1430
1717
|
this.ui.requestRender();
|
|
1431
1718
|
}
|
|
1719
|
+
setEditorWorkingStatusIndicator(indicator) {
|
|
1720
|
+
this.defaultEditor.setWorkingStatusIndicator(undefined);
|
|
1721
|
+
if (!isWorkingStatusEditor(this.editor))
|
|
1722
|
+
return false;
|
|
1723
|
+
this.editor.setWorkingStatusIndicator(indicator);
|
|
1724
|
+
return true;
|
|
1725
|
+
}
|
|
1432
1726
|
showStatusIndicator(indicator) {
|
|
1433
1727
|
this.activeStatusIndicator?.dispose();
|
|
1434
1728
|
this.activeStatusIndicator = indicator;
|
|
1729
|
+
this.activeWorkingIndicatorEmbedded = false;
|
|
1435
1730
|
this.statusContainer.clear();
|
|
1731
|
+
this.setEditorWorkingStatusIndicator(undefined);
|
|
1732
|
+
if (this.setEditorWorkingStatusIndicator(indicator)) {
|
|
1733
|
+
this.activeWorkingIndicatorEmbedded = true;
|
|
1734
|
+
return;
|
|
1735
|
+
}
|
|
1436
1736
|
this.statusContainer.addChild(indicator);
|
|
1437
1737
|
}
|
|
1438
1738
|
clearStatusIndicator(kind) {
|
|
1439
1739
|
if (kind && this.activeStatusIndicator?.kind !== kind) {
|
|
1440
1740
|
return;
|
|
1441
1741
|
}
|
|
1442
|
-
const
|
|
1443
|
-
this.
|
|
1742
|
+
const clearedIndicator = this.activeStatusIndicator;
|
|
1743
|
+
const clearedIndicatorWasEmbedded = this.activeWorkingIndicatorEmbedded;
|
|
1744
|
+
clearedIndicator?.dispose();
|
|
1444
1745
|
this.activeStatusIndicator = undefined;
|
|
1746
|
+
this.activeWorkingIndicatorEmbedded = false;
|
|
1445
1747
|
this.statusContainer.clear();
|
|
1446
|
-
|
|
1748
|
+
this.setEditorWorkingStatusIndicator(undefined);
|
|
1749
|
+
if (clearedIndicator &&
|
|
1750
|
+
!clearedIndicatorWasEmbedded &&
|
|
1751
|
+
this.options.tuiMode === "regular" &&
|
|
1752
|
+
this.ui.getClearOnShrink()) {
|
|
1447
1753
|
this.statusContainer.addChild(this.idleStatus);
|
|
1448
1754
|
}
|
|
1449
1755
|
}
|
|
1756
|
+
showWorkingStatusIndicator() {
|
|
1757
|
+
const colorFn = isWorkingStatusEditor(this.editor)
|
|
1758
|
+
? (text) => (this.editor.borderColor ?? theme.getThinkingBorderColor(this.session.thinkingLevel || "off"))(text)
|
|
1759
|
+
: undefined;
|
|
1760
|
+
this.showStatusIndicator(new WorkingStatusIndicator(this.ui, this.workingMessage ?? this.defaultWorkingMessage, this.workingIndicatorOptions, colorFn));
|
|
1761
|
+
}
|
|
1450
1762
|
setWorkingVisible(visible) {
|
|
1451
1763
|
this.workingVisible = visible;
|
|
1452
1764
|
if (!visible) {
|
|
@@ -1455,7 +1767,7 @@ export class InteractiveMode {
|
|
|
1455
1767
|
return;
|
|
1456
1768
|
}
|
|
1457
1769
|
if (this.session.isStreaming && this.activeStatusIndicator?.kind !== "working") {
|
|
1458
|
-
this.
|
|
1770
|
+
this.showWorkingStatusIndicator();
|
|
1459
1771
|
}
|
|
1460
1772
|
this.ui.requestRender();
|
|
1461
1773
|
}
|
|
@@ -1503,7 +1815,7 @@ export class InteractiveMode {
|
|
|
1503
1815
|
container.addChild(new Text(line, 1, 0));
|
|
1504
1816
|
}
|
|
1505
1817
|
if (content.length > InteractiveMode.MAX_WIDGET_LINES) {
|
|
1506
|
-
container.addChild(new
|
|
1818
|
+
container.addChild(new ThemedText(() => theme.fg("muted", "... (widget truncated)"), 1, 0));
|
|
1507
1819
|
}
|
|
1508
1820
|
component = container;
|
|
1509
1821
|
}
|
|
@@ -1557,7 +1869,7 @@ export class InteractiveMode {
|
|
|
1557
1869
|
this.setHiddenThinkingLabel();
|
|
1558
1870
|
}
|
|
1559
1871
|
// Maximum total widget lines to prevent viewport overflow
|
|
1560
|
-
static
|
|
1872
|
+
static MAX_WIDGET_LINES = 10;
|
|
1561
1873
|
/**
|
|
1562
1874
|
* Render all extension widgets to the widget container.
|
|
1563
1875
|
*/
|
|
@@ -1591,22 +1903,16 @@ export class InteractiveMode {
|
|
|
1591
1903
|
if (this.customFooter?.dispose) {
|
|
1592
1904
|
this.customFooter.dispose();
|
|
1593
1905
|
}
|
|
1594
|
-
|
|
1595
|
-
if (this.customFooter) {
|
|
1596
|
-
this.ui.removeChild(this.customFooter);
|
|
1597
|
-
}
|
|
1598
|
-
else {
|
|
1599
|
-
this.ui.removeChild(this.footer);
|
|
1600
|
-
}
|
|
1906
|
+
this.footerContainer.clear();
|
|
1601
1907
|
if (factory) {
|
|
1602
1908
|
// Create and add custom footer, passing the data provider
|
|
1603
1909
|
this.customFooter = factory(this.ui, theme, this.footerDataProvider);
|
|
1604
|
-
this.
|
|
1910
|
+
this.footerContainer.addChild(this.customFooter);
|
|
1605
1911
|
}
|
|
1606
1912
|
else {
|
|
1607
1913
|
// Restore built-in footer
|
|
1608
1914
|
this.customFooter = undefined;
|
|
1609
|
-
this.
|
|
1915
|
+
this.footerContainer.addChild(this.footer);
|
|
1610
1916
|
}
|
|
1611
1917
|
this.ui.requestRender();
|
|
1612
1918
|
}
|
|
@@ -1652,18 +1958,23 @@ export class InteractiveMode {
|
|
|
1652
1958
|
this.ui.requestRender();
|
|
1653
1959
|
}
|
|
1654
1960
|
addExtensionTerminalInputListener(handler) {
|
|
1655
|
-
const
|
|
1656
|
-
this.
|
|
1961
|
+
const subscription = { handler, unsubscribe: this.ui.addInputListener(handler) };
|
|
1962
|
+
this.extensionTerminalInputSubscriptions.add(subscription);
|
|
1657
1963
|
return () => {
|
|
1658
|
-
unsubscribe();
|
|
1659
|
-
this.
|
|
1964
|
+
subscription.unsubscribe();
|
|
1965
|
+
this.extensionTerminalInputSubscriptions.delete(subscription);
|
|
1660
1966
|
};
|
|
1661
1967
|
}
|
|
1662
|
-
|
|
1663
|
-
for (const
|
|
1664
|
-
unsubscribe();
|
|
1968
|
+
rebindExtensionTerminalInputListeners() {
|
|
1969
|
+
for (const subscription of this.extensionTerminalInputSubscriptions) {
|
|
1970
|
+
subscription.unsubscribe();
|
|
1971
|
+
subscription.unsubscribe = this.ui.addInputListener(subscription.handler);
|
|
1665
1972
|
}
|
|
1666
|
-
|
|
1973
|
+
}
|
|
1974
|
+
clearExtensionTerminalInputListeners() {
|
|
1975
|
+
for (const subscription of this.extensionTerminalInputSubscriptions)
|
|
1976
|
+
subscription.unsubscribe();
|
|
1977
|
+
this.extensionTerminalInputSubscriptions.clear();
|
|
1667
1978
|
}
|
|
1668
1979
|
/**
|
|
1669
1980
|
* Create the ExtensionUIContext for extensions.
|
|
@@ -1793,6 +2104,7 @@ export class InteractiveMode {
|
|
|
1793
2104
|
onToggleToolsExpanded: () => this.toggleToolOutputExpansion(),
|
|
1794
2105
|
});
|
|
1795
2106
|
this.extensionSelectorSettle = settle;
|
|
2107
|
+
this.disposeActiveSelector();
|
|
1796
2108
|
this.editorContainer.clear();
|
|
1797
2109
|
this.editorContainer.addChild(this.extensionSelector);
|
|
1798
2110
|
this.ui.setFocus(this.extensionSelector);
|
|
@@ -1968,6 +2280,7 @@ export class InteractiveMode {
|
|
|
1968
2280
|
this.hideExtensionInput();
|
|
1969
2281
|
}, { tui: this.ui, timeout: opts?.timeout });
|
|
1970
2282
|
this.extensionInputSettle = settle;
|
|
2283
|
+
this.disposeActiveSelector();
|
|
1971
2284
|
this.editorContainer.clear();
|
|
1972
2285
|
this.editorContainer.addChild(this.extensionInput);
|
|
1973
2286
|
this.ui.setFocus(this.extensionInput);
|
|
@@ -2025,6 +2338,7 @@ export class InteractiveMode {
|
|
|
2025
2338
|
this.hideExtensionEditor();
|
|
2026
2339
|
}, undefined, this.settingsManager.getExternalEditorCommand());
|
|
2027
2340
|
this.extensionEditorSettle = settle;
|
|
2341
|
+
this.disposeActiveSelector();
|
|
2028
2342
|
this.editorContainer.clear();
|
|
2029
2343
|
this.editorContainer.addChild(this.extensionEditor);
|
|
2030
2344
|
this.ui.setFocus(this.extensionEditor);
|
|
@@ -2063,6 +2377,7 @@ export class InteractiveMode {
|
|
|
2063
2377
|
this.editorComponentFactory = factory;
|
|
2064
2378
|
// Save text from current editor before switching
|
|
2065
2379
|
const currentText = this.editor.getText();
|
|
2380
|
+
this.disposeActiveSelector();
|
|
2066
2381
|
this.editorContainer.clear();
|
|
2067
2382
|
if (factory) {
|
|
2068
2383
|
// Create the custom editor with tui, theme, and keybindings
|
|
@@ -2115,6 +2430,13 @@ export class InteractiveMode {
|
|
|
2115
2430
|
this.editor = this.defaultEditor;
|
|
2116
2431
|
}
|
|
2117
2432
|
this.editorContainer.addChild(this.editor);
|
|
2433
|
+
if (this.activeStatusIndicator) {
|
|
2434
|
+
this.statusContainer.clear();
|
|
2435
|
+
this.activeWorkingIndicatorEmbedded = this.setEditorWorkingStatusIndicator(this.activeStatusIndicator);
|
|
2436
|
+
if (!this.activeWorkingIndicatorEmbedded) {
|
|
2437
|
+
this.statusContainer.addChild(this.activeStatusIndicator);
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2118
2440
|
this.ui.setFocus(this.editor);
|
|
2119
2441
|
this.ui.requestRender();
|
|
2120
2442
|
}
|
|
@@ -2186,6 +2508,7 @@ export class InteractiveMode {
|
|
|
2186
2508
|
options?.onHandle?.(handle);
|
|
2187
2509
|
}
|
|
2188
2510
|
else {
|
|
2511
|
+
this.disposeActiveSelector();
|
|
2189
2512
|
this.editorContainer.clear();
|
|
2190
2513
|
this.editorContainer.addChild(component);
|
|
2191
2514
|
this.ui.setFocus(component);
|
|
@@ -2206,17 +2529,14 @@ export class InteractiveMode {
|
|
|
2206
2529
|
*/
|
|
2207
2530
|
showExtensionError(extensionPath, error, stack) {
|
|
2208
2531
|
const errorMsg = `Extension "${extensionPath}" error: ${error}`;
|
|
2209
|
-
const errorText = new
|
|
2532
|
+
const errorText = new ThemedText(() => theme.fg("error", errorMsg), 1, 0);
|
|
2210
2533
|
this.chatContainer.addChild(errorText);
|
|
2211
2534
|
if (stack) {
|
|
2212
2535
|
// Show stack trace in dim color, indented
|
|
2213
|
-
const stackLines = stack
|
|
2214
|
-
|
|
2215
|
-
.
|
|
2216
|
-
.
|
|
2217
|
-
.join("\n");
|
|
2218
|
-
if (stackLines) {
|
|
2219
|
-
this.chatContainer.addChild(new Text(stackLines, 1, 0));
|
|
2536
|
+
const stackLines = stack.split("\n").slice(1); // Skip first line (duplicates error message)
|
|
2537
|
+
if (stackLines.length > 0) {
|
|
2538
|
+
const renderStack = () => stackLines.map((line) => theme.fg("dim", ` ${line.trim()}`)).join("\n");
|
|
2539
|
+
this.chatContainer.addChild(new ThemedText(renderStack, 1, 0));
|
|
2220
2540
|
}
|
|
2221
2541
|
}
|
|
2222
2542
|
this.ui.requestRender();
|
|
@@ -2273,7 +2593,7 @@ export class InteractiveMode {
|
|
|
2273
2593
|
this.defaultEditor.onAction("app.tools.expand", () => this.toggleToolOutputExpansion());
|
|
2274
2594
|
this.defaultEditor.onAction("app.thinking.toggle", () => this.toggleThinkingBlockVisibility());
|
|
2275
2595
|
this.defaultEditor.onAction("app.editor.external", () => void this.handleOpenExternalEditor());
|
|
2276
|
-
this.defaultEditor.onAction("app.message.copy", () => void this.handleCopyCommand());
|
|
2596
|
+
this.defaultEditor.onAction("app.message.copy", () => void this.handleCopyCommand({ flashConfirmation: true, preferSelection: true }));
|
|
2277
2597
|
this.defaultEditor.onAction("app.message.followUp", () => this.handleFollowUp());
|
|
2278
2598
|
this.defaultEditor.onAction("app.message.dequeue", () => this.handleDequeue());
|
|
2279
2599
|
this.defaultEditor.onAction("app.session.new", () => this.handleClearCommand());
|
|
@@ -2288,14 +2608,46 @@ export class InteractiveMode {
|
|
|
2288
2608
|
this.updateEditorBorderColor();
|
|
2289
2609
|
}
|
|
2290
2610
|
};
|
|
2291
|
-
// Handle clipboard paste (triggered on Ctrl+V).
|
|
2292
|
-
//
|
|
2611
|
+
// Handle clipboard paste (triggered on Ctrl+V). Copied files use their original paths,
|
|
2612
|
+
// images are attached via temporary files, and plain text is the final fallback.
|
|
2293
2613
|
this.defaultEditor.onPasteImage = () => {
|
|
2294
2614
|
void this.handleClipboardPaste();
|
|
2295
2615
|
};
|
|
2296
2616
|
}
|
|
2617
|
+
async handleRightClickPaste() {
|
|
2618
|
+
const target = this.renderer.getFocusedComponent();
|
|
2619
|
+
const handleInput = target?.handleInput;
|
|
2620
|
+
if (!target || !handleInput)
|
|
2621
|
+
return;
|
|
2622
|
+
try {
|
|
2623
|
+
const text = await readClipboardText();
|
|
2624
|
+
if (!text || this.renderer.getFocusedComponent() !== target)
|
|
2625
|
+
return;
|
|
2626
|
+
handleInput.call(target, `\x1b[200~${text}\x1b[201~`);
|
|
2627
|
+
this.ui.requestRender();
|
|
2628
|
+
}
|
|
2629
|
+
catch {
|
|
2630
|
+
// Silently ignore clipboard errors (may not have permission, etc.)
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2297
2633
|
async handleClipboardPaste() {
|
|
2298
2634
|
try {
|
|
2635
|
+
const filePaths = await readClipboardFilePaths();
|
|
2636
|
+
if (filePaths) {
|
|
2637
|
+
if (filePaths.some((filePath) => /\p{Cc}/u.test(filePath))) {
|
|
2638
|
+
throw new Error("Clipboard file path contains control characters");
|
|
2639
|
+
}
|
|
2640
|
+
const paths = this.isBashMode ? filePaths.map(quoteIfNeeded).join(" ") : filePaths.join("\n");
|
|
2641
|
+
const cursor = this.editor.getCursor?.();
|
|
2642
|
+
const currentLine = cursor ? (this.editor.getText().split("\n")[cursor.line] ?? "") : "";
|
|
2643
|
+
const characterBeforeCursor = cursor && cursor.col > 0 ? currentLine[cursor.col - 1] : "";
|
|
2644
|
+
const characterAfterCursor = cursor ? currentLine[cursor.col] : "";
|
|
2645
|
+
const leadingSpace = characterBeforeCursor && !/\s/.test(characterBeforeCursor) ? " " : "";
|
|
2646
|
+
const trailingSpace = characterAfterCursor && !/\s/.test(characterAfterCursor) ? " " : "";
|
|
2647
|
+
this.editor.insertTextAtCursor?.(`${leadingSpace}${paths}${trailingSpace}`);
|
|
2648
|
+
this.ui.requestRender();
|
|
2649
|
+
return;
|
|
2650
|
+
}
|
|
2299
2651
|
const image = await readClipboardImage();
|
|
2300
2652
|
if (image) {
|
|
2301
2653
|
const tmpDir = os.tmpdir();
|
|
@@ -2313,10 +2665,14 @@ export class InteractiveMode {
|
|
|
2313
2665
|
this.ui.requestRender();
|
|
2314
2666
|
}
|
|
2315
2667
|
}
|
|
2316
|
-
catch {
|
|
2317
|
-
|
|
2668
|
+
catch (error) {
|
|
2669
|
+
this.showError(`Failed to paste from clipboard: ${error instanceof Error ? error.message : String(error)}`);
|
|
2318
2670
|
}
|
|
2319
2671
|
}
|
|
2672
|
+
handleStartupSubmit(text) {
|
|
2673
|
+
this.editor.setText(text);
|
|
2674
|
+
this.showStatus("Startup is still in progress");
|
|
2675
|
+
}
|
|
2320
2676
|
setupEditorSubmitHandler() {
|
|
2321
2677
|
this.defaultEditor.onSubmit = async (text) => {
|
|
2322
2678
|
text = text.trim();
|
|
@@ -2347,6 +2703,12 @@ export class InteractiveMode {
|
|
|
2347
2703
|
await this.handleModelCommand(searchTerm);
|
|
2348
2704
|
return;
|
|
2349
2705
|
}
|
|
2706
|
+
if (text === "/thinking" || text.startsWith("/thinking ")) {
|
|
2707
|
+
const searchTerm = text.startsWith("/thinking ") ? text.slice(10).trim() : undefined;
|
|
2708
|
+
this.editor.setText("");
|
|
2709
|
+
this.handleThinkingCommand(searchTerm);
|
|
2710
|
+
return;
|
|
2711
|
+
}
|
|
2350
2712
|
if (text === "/export" || text.startsWith("/export ")) {
|
|
2351
2713
|
await this.handleExportCommand(text);
|
|
2352
2714
|
this.editor.setText("");
|
|
@@ -2362,6 +2724,12 @@ export class InteractiveMode {
|
|
|
2362
2724
|
this.editor.setText("");
|
|
2363
2725
|
return;
|
|
2364
2726
|
}
|
|
2727
|
+
if (text === "/bug" || text.startsWith("/bug ")) {
|
|
2728
|
+
const hint = text.slice("/bug".length).trim();
|
|
2729
|
+
this.editor.setText("");
|
|
2730
|
+
await this.handleBugCommand(hint ? hint : undefined);
|
|
2731
|
+
return;
|
|
2732
|
+
}
|
|
2365
2733
|
if (text === "/copy") {
|
|
2366
2734
|
await this.handleCopyCommand();
|
|
2367
2735
|
this.editor.setText("");
|
|
@@ -2528,17 +2896,21 @@ export class InteractiveMode {
|
|
|
2528
2896
|
switch (event.type) {
|
|
2529
2897
|
case "agent_start":
|
|
2530
2898
|
this.pendingTools.clear();
|
|
2531
|
-
if (this.settingsManager.getShowTerminalProgress()) {
|
|
2532
|
-
this.ui.terminal.setProgress(true);
|
|
2533
|
-
}
|
|
2534
2899
|
// Restore main escape handler if retry handler is still active
|
|
2535
2900
|
// (retry success event fires later, but we need main handler now)
|
|
2536
2901
|
if (this.retryEscapeHandler) {
|
|
2537
2902
|
this.defaultEditor.onEscape = this.retryEscapeHandler;
|
|
2538
2903
|
this.retryEscapeHandler = undefined;
|
|
2539
2904
|
}
|
|
2905
|
+
break;
|
|
2906
|
+
case "turn_start":
|
|
2907
|
+
if (this.settingsManager.getShowTerminalProgress()) {
|
|
2908
|
+
this.ui.terminal.setProgress(true);
|
|
2909
|
+
}
|
|
2540
2910
|
if (this.workingVisible) {
|
|
2541
|
-
|
|
2911
|
+
if (this.activeStatusIndicator?.kind !== "working") {
|
|
2912
|
+
this.showWorkingStatusIndicator();
|
|
2913
|
+
}
|
|
2542
2914
|
}
|
|
2543
2915
|
else {
|
|
2544
2916
|
this.clearStatusIndicator();
|
|
@@ -2550,10 +2922,44 @@ export class InteractiveMode {
|
|
|
2550
2922
|
this.ui.requestRender();
|
|
2551
2923
|
break;
|
|
2552
2924
|
case "entry_appended":
|
|
2925
|
+
if (this.entriesRenderedByBoundaryCompaction.delete(event.entry.id))
|
|
2926
|
+
break;
|
|
2553
2927
|
if (event.entry.type === "custom") {
|
|
2554
2928
|
this.addCustomEntryToChat(event.entry);
|
|
2555
2929
|
this.ui.requestRender();
|
|
2556
2930
|
}
|
|
2931
|
+
else if (event.entry.type === "usage" && event.entry.kind === "cache_warm") {
|
|
2932
|
+
this.addCacheWarmingUsage(event.entry);
|
|
2933
|
+
this.ui.requestRender();
|
|
2934
|
+
}
|
|
2935
|
+
else if (event.entry.type === "custom_message" && event.entry.display) {
|
|
2936
|
+
this.addMessageToChat(createCustomMessage(event.entry.customType, event.entry.content, event.entry.display, event.entry.details, event.entry.timestamp));
|
|
2937
|
+
this.ui.requestRender();
|
|
2938
|
+
}
|
|
2939
|
+
else if (event.entry.type === "compaction") {
|
|
2940
|
+
const entries = this.sessionManager.buildContextEntries();
|
|
2941
|
+
if (entries[0]?.id !== event.entry.id)
|
|
2942
|
+
break;
|
|
2943
|
+
this.chatContainer.clear();
|
|
2944
|
+
const branch = this.sessionManager.getBranch();
|
|
2945
|
+
const compactionIndex = branch.findIndex((entry) => entry.id === event.entry.id);
|
|
2946
|
+
const entriesAfterCompaction = new Set(branch.slice(compactionIndex + 1).map((entry) => entry.id));
|
|
2947
|
+
const retainedEntries = entries.slice(1);
|
|
2948
|
+
this.renderSessionEntries(retainedEntries.filter((entry) => !entriesAfterCompaction.has(entry.id)));
|
|
2949
|
+
this.addMessageToChat(createCompactionSummaryMessage(event.entry.summary, event.entry.tokensBefore, event.entry.timestamp));
|
|
2950
|
+
if (event.entry.usage) {
|
|
2951
|
+
this.addCompactionCostNotice({
|
|
2952
|
+
type: "compaction_cost",
|
|
2953
|
+
kind: "compaction",
|
|
2954
|
+
usage: event.entry.usage,
|
|
2955
|
+
});
|
|
2956
|
+
}
|
|
2957
|
+
this.renderSessionEntries(retainedEntries.filter((entry) => entriesAfterCompaction.has(entry.id)));
|
|
2958
|
+
for (const entryId of entriesAfterCompaction)
|
|
2959
|
+
this.entriesRenderedByBoundaryCompaction.add(entryId);
|
|
2960
|
+
this.footer.invalidate();
|
|
2961
|
+
this.ui.requestRender();
|
|
2962
|
+
}
|
|
2557
2963
|
break;
|
|
2558
2964
|
case "session_info_changed":
|
|
2559
2965
|
this.updateTerminalTitle();
|
|
@@ -2579,17 +2985,17 @@ export class InteractiveMode {
|
|
|
2579
2985
|
this.ui.requestRender();
|
|
2580
2986
|
}
|
|
2581
2987
|
else if (event.message.role === "assistant") {
|
|
2582
|
-
this.streamingComponent = new AssistantMessageComponent(undefined, this.hideThinkingBlock, this.getMarkdownThemeWithSettings(), this.hiddenThinkingLabel, this.outputPad);
|
|
2988
|
+
this.streamingComponent = new AssistantMessageComponent(undefined, this.hideThinkingBlock, this.getMarkdownThemeWithSettings(), this.hiddenThinkingLabel, this.outputPad, this.getMarkdownTransformers());
|
|
2583
2989
|
this.streamingMessage = event.message;
|
|
2584
2990
|
this.chatContainer.addChild(this.streamingComponent);
|
|
2585
|
-
this.streamingComponent.updateContent(this.streamingMessage);
|
|
2991
|
+
this.streamingComponent.updateContent(this.streamingMessage, true);
|
|
2586
2992
|
this.ui.requestRender();
|
|
2587
2993
|
}
|
|
2588
2994
|
break;
|
|
2589
2995
|
case "message_update":
|
|
2590
2996
|
if (this.streamingComponent && event.message.role === "assistant") {
|
|
2591
2997
|
this.streamingMessage = event.message;
|
|
2592
|
-
this.streamingComponent.updateContent(this.streamingMessage);
|
|
2998
|
+
this.streamingComponent.updateContent(this.streamingMessage, true);
|
|
2593
2999
|
for (const content of this.streamingMessage.content) {
|
|
2594
3000
|
if (content.type === "toolCall") {
|
|
2595
3001
|
if (!this.pendingTools.has(content.id)) {
|
|
@@ -2626,7 +3032,7 @@ export class InteractiveMode {
|
|
|
2626
3032
|
: "Operation aborted";
|
|
2627
3033
|
this.streamingMessage.errorMessage = errorMessage;
|
|
2628
3034
|
}
|
|
2629
|
-
this.streamingComponent.updateContent(this.streamingMessage);
|
|
3035
|
+
this.streamingComponent.updateContent(this.streamingMessage, false);
|
|
2630
3036
|
if (this.streamingMessage.stopReason === "aborted" || this.streamingMessage.stopReason === "error") {
|
|
2631
3037
|
if (!errorMessage) {
|
|
2632
3038
|
errorMessage = this.streamingMessage.errorMessage || "Error";
|
|
@@ -2638,12 +3044,14 @@ export class InteractiveMode {
|
|
|
2638
3044
|
});
|
|
2639
3045
|
}
|
|
2640
3046
|
this.pendingTools.clear();
|
|
3047
|
+
this.maybeSuggestBugReport(this.streamingMessage);
|
|
2641
3048
|
}
|
|
2642
3049
|
else {
|
|
2643
3050
|
// Args are now complete - trigger diff computation for edit tools
|
|
2644
3051
|
for (const [, component] of this.pendingTools.entries()) {
|
|
2645
3052
|
component.setArgsComplete();
|
|
2646
3053
|
}
|
|
3054
|
+
this.maybeShowThinkingDropNotice(this.streamingMessage);
|
|
2647
3055
|
this.maybeShowCacheMissNotice(this.streamingMessage);
|
|
2648
3056
|
}
|
|
2649
3057
|
this.streamingComponent = undefined;
|
|
@@ -2656,6 +3064,9 @@ export class InteractiveMode {
|
|
|
2656
3064
|
// The bash execution callback handles TUI output rendering.
|
|
2657
3065
|
break;
|
|
2658
3066
|
case "tool_execution_start": {
|
|
3067
|
+
// Nested calls (from codemode scripts) are shown inside their parent's row.
|
|
3068
|
+
if (event.parentToolCallId)
|
|
3069
|
+
break;
|
|
2659
3070
|
let component = this.pendingTools.get(event.toolCallId);
|
|
2660
3071
|
if (!component) {
|
|
2661
3072
|
component = new ToolExecutionComponent(event.toolName, event.toolCallId, event.args, {
|
|
@@ -2735,9 +3146,21 @@ export class InteractiveMode {
|
|
|
2735
3146
|
}
|
|
2736
3147
|
}
|
|
2737
3148
|
else if (event.result) {
|
|
3149
|
+
const entries = this.sessionManager.buildContextEntries();
|
|
3150
|
+
if (entries[0]?.type !== "compaction") {
|
|
3151
|
+
throw new Error("Completed compaction is missing from the session context");
|
|
3152
|
+
}
|
|
2738
3153
|
this.chatContainer.clear();
|
|
2739
|
-
|
|
3154
|
+
// The latest compaction is prepended for model context; append it below at its chronological position.
|
|
3155
|
+
this.renderSessionEntries(entries.slice(1));
|
|
2740
3156
|
this.addMessageToChat(createCompactionSummaryMessage(event.result.summary, event.result.tokensBefore, new Date().toISOString()));
|
|
3157
|
+
if (event.result.usage) {
|
|
3158
|
+
this.addCompactionCostNotice({
|
|
3159
|
+
type: "compaction_cost",
|
|
3160
|
+
kind: "compaction",
|
|
3161
|
+
usage: event.result.usage,
|
|
3162
|
+
});
|
|
3163
|
+
}
|
|
2741
3164
|
this.footer.invalidate();
|
|
2742
3165
|
}
|
|
2743
3166
|
else if (event.errorMessage) {
|
|
@@ -2746,7 +3169,8 @@ export class InteractiveMode {
|
|
|
2746
3169
|
}
|
|
2747
3170
|
else {
|
|
2748
3171
|
this.chatContainer.addChild(new Spacer(1));
|
|
2749
|
-
|
|
3172
|
+
const errorMessage = event.errorMessage;
|
|
3173
|
+
this.chatContainer.addChild(new ThemedText(() => theme.fg("error", errorMessage), 1, 0));
|
|
2750
3174
|
}
|
|
2751
3175
|
}
|
|
2752
3176
|
void this.flushCompactionQueue({ willRetry: event.willRetry });
|
|
@@ -2810,6 +3234,19 @@ export class InteractiveMode {
|
|
|
2810
3234
|
: message.content.filter((c) => c.type === "text");
|
|
2811
3235
|
return textBlocks.map((c) => c.text).join("");
|
|
2812
3236
|
}
|
|
3237
|
+
/** Show a managed-tool status update in the chat. */
|
|
3238
|
+
showManagedToolStatus(status) {
|
|
3239
|
+
if (!this.managedToolStatusStarted) {
|
|
3240
|
+
this.chatContainer.addChild(new Spacer(1));
|
|
3241
|
+
this.managedToolStatusStarted = true;
|
|
3242
|
+
}
|
|
3243
|
+
const message = status.type === "warning" ? `Warning: ${status.message}` : status.message;
|
|
3244
|
+
const color = status.type === "warning" ? "warning" : "dim";
|
|
3245
|
+
this.chatContainer.addChild(new ThemedText(() => theme.fg(color, message), 1, 0));
|
|
3246
|
+
this.lastStatusSpacer = undefined;
|
|
3247
|
+
this.lastStatusText = undefined;
|
|
3248
|
+
this.ui.requestRender();
|
|
3249
|
+
}
|
|
2813
3250
|
/**
|
|
2814
3251
|
* Show a status message in the chat.
|
|
2815
3252
|
*
|
|
@@ -2821,12 +3258,14 @@ export class InteractiveMode {
|
|
|
2821
3258
|
const last = children.length > 0 ? children[children.length - 1] : undefined;
|
|
2822
3259
|
const secondLast = children.length > 1 ? children[children.length - 2] : undefined;
|
|
2823
3260
|
if (last && secondLast && last === this.lastStatusText && secondLast === this.lastStatusSpacer) {
|
|
2824
|
-
this.
|
|
3261
|
+
this.lastStatusMessage = message;
|
|
3262
|
+
this.lastStatusText.invalidate();
|
|
2825
3263
|
this.ui.requestRender();
|
|
2826
3264
|
return;
|
|
2827
3265
|
}
|
|
2828
3266
|
const spacer = new Spacer(1);
|
|
2829
|
-
|
|
3267
|
+
this.lastStatusMessage = message;
|
|
3268
|
+
const text = new ThemedText(() => theme.fg("dim", this.lastStatusMessage), 1, 0);
|
|
2830
3269
|
this.chatContainer.addChild(spacer);
|
|
2831
3270
|
this.chatContainer.addChild(text);
|
|
2832
3271
|
this.lastStatusSpacer = spacer;
|
|
@@ -2886,6 +3325,8 @@ export class InteractiveMode {
|
|
|
2886
3325
|
this.chatContainer.addChild(component);
|
|
2887
3326
|
break;
|
|
2888
3327
|
}
|
|
3328
|
+
case "system":
|
|
3329
|
+
break;
|
|
2889
3330
|
case "user": {
|
|
2890
3331
|
const textContent = this.getUserMessageText(message);
|
|
2891
3332
|
if (textContent) {
|
|
@@ -2901,12 +3342,12 @@ export class InteractiveMode {
|
|
|
2901
3342
|
// Render user message separately if present
|
|
2902
3343
|
if (skillBlock.userMessage) {
|
|
2903
3344
|
this.chatContainer.addChild(new Spacer(1));
|
|
2904
|
-
const userComponent = new UserMessageComponent(skillBlock.userMessage, this.getMarkdownThemeWithSettings(), this.outputPad);
|
|
3345
|
+
const userComponent = new UserMessageComponent(skillBlock.userMessage, this.getMarkdownThemeWithSettings(), this.outputPad, this.getMarkdownTransformers());
|
|
2905
3346
|
this.chatContainer.addChild(userComponent);
|
|
2906
3347
|
}
|
|
2907
3348
|
}
|
|
2908
3349
|
else {
|
|
2909
|
-
const userComponent = new UserMessageComponent(textContent, this.getMarkdownThemeWithSettings(), this.outputPad);
|
|
3350
|
+
const userComponent = new UserMessageComponent(textContent, this.getMarkdownThemeWithSettings(), this.outputPad, this.getMarkdownTransformers());
|
|
2910
3351
|
this.chatContainer.addChild(userComponent);
|
|
2911
3352
|
}
|
|
2912
3353
|
if (options?.populateHistory) {
|
|
@@ -2916,7 +3357,7 @@ export class InteractiveMode {
|
|
|
2916
3357
|
break;
|
|
2917
3358
|
}
|
|
2918
3359
|
case "assistant": {
|
|
2919
|
-
const assistantComponent = new AssistantMessageComponent(message, this.hideThinkingBlock, this.getMarkdownThemeWithSettings(), this.hiddenThinkingLabel, this.outputPad);
|
|
3360
|
+
const assistantComponent = new AssistantMessageComponent(message, this.hideThinkingBlock, this.getMarkdownThemeWithSettings(), this.hiddenThinkingLabel, this.outputPad, this.getMarkdownTransformers());
|
|
2920
3361
|
this.chatContainer.addChild(assistantComponent);
|
|
2921
3362
|
break;
|
|
2922
3363
|
}
|
|
@@ -2932,8 +3373,8 @@ export class InteractiveMode {
|
|
|
2932
3373
|
renderSessionItems(items, options = {}) {
|
|
2933
3374
|
this.pendingTools.clear();
|
|
2934
3375
|
const renderedPendingTools = new Map();
|
|
2935
|
-
// Cache
|
|
2936
|
-
//
|
|
3376
|
+
// Cache misses are not persisted, unlike successful cache-warming usage.
|
|
3377
|
+
// Re-derive them and inject them after the assistant messages that paid for them.
|
|
2937
3378
|
const cacheMisses = this.settingsManager.getShowCacheMissNotices()
|
|
2938
3379
|
? collectCacheMisses(this.sessionManager.getEntries(), this.session.modelRuntime)
|
|
2939
3380
|
: new Map();
|
|
@@ -2946,6 +3387,14 @@ export class InteractiveMode {
|
|
|
2946
3387
|
this.addCustomEntryToChat(item);
|
|
2947
3388
|
continue;
|
|
2948
3389
|
}
|
|
3390
|
+
if (isUsageSessionEntry(item)) {
|
|
3391
|
+
this.addCacheWarmingUsage(item);
|
|
3392
|
+
continue;
|
|
3393
|
+
}
|
|
3394
|
+
if (isCompactionCostNotice(item)) {
|
|
3395
|
+
this.addCompactionCostNotice(item);
|
|
3396
|
+
continue;
|
|
3397
|
+
}
|
|
2949
3398
|
const message = item;
|
|
2950
3399
|
// Assistant messages need special handling for tool calls
|
|
2951
3400
|
if (message.role === "assistant") {
|
|
@@ -3010,13 +3459,75 @@ export class InteractiveMode {
|
|
|
3010
3459
|
*/
|
|
3011
3460
|
renderSessionEntries(entries, options = {}) {
|
|
3012
3461
|
const items = entries.flatMap((entry) => {
|
|
3013
|
-
if (entry.type === "custom") {
|
|
3462
|
+
if (entry.type === "custom" || (entry.type === "usage" && entry.kind === "cache_warm")) {
|
|
3014
3463
|
return [entry];
|
|
3015
3464
|
}
|
|
3016
|
-
|
|
3465
|
+
const messages = sessionEntryToContextMessages(entry);
|
|
3466
|
+
if ((entry.type === "compaction" || entry.type === "branch_summary") && entry.usage && messages.length > 0) {
|
|
3467
|
+
return [...messages, { type: "compaction_cost", kind: entry.type, usage: entry.usage }];
|
|
3468
|
+
}
|
|
3469
|
+
return messages;
|
|
3017
3470
|
});
|
|
3018
3471
|
this.renderSessionItems(items, options);
|
|
3019
3472
|
}
|
|
3473
|
+
addCacheWarmingUsage(entry) {
|
|
3474
|
+
if (!this.settingsManager.getShowCacheMissNotices())
|
|
3475
|
+
return;
|
|
3476
|
+
this.chatContainer.addChild(new Spacer(1));
|
|
3477
|
+
const usage = formatCacheWarmingUsage(entry);
|
|
3478
|
+
this.chatContainer.addChild(new ThemedText(() => theme.fg("dim", usage), 1, 0));
|
|
3479
|
+
}
|
|
3480
|
+
/**
|
|
3481
|
+
* Render billing usage for a compaction or branch summary. The notice is derived
|
|
3482
|
+
* from persisted summary usage and is not stored as a separate session entry.
|
|
3483
|
+
*/
|
|
3484
|
+
addCompactionCostNotice(notice) {
|
|
3485
|
+
if (!this.settingsManager.getShowCacheMissNotices())
|
|
3486
|
+
return;
|
|
3487
|
+
const { usage } = notice;
|
|
3488
|
+
const tokens = usage.input + usage.output + usage.cacheRead + usage.cacheWrite;
|
|
3489
|
+
const cost = usage.cost.total >= 0.01 ? ` (~$${usage.cost.total.toFixed(2)})` : "";
|
|
3490
|
+
const label = notice.kind === "compaction" ? "Compaction" : "Branch summary";
|
|
3491
|
+
this.chatContainer.addChild(new Spacer(1));
|
|
3492
|
+
this.chatContainer.addChild(new ThemedText(() => theme.fg("warning", `${label}: ${formatTokens(tokens)} tokens billed${cost}`), 1, 0));
|
|
3493
|
+
}
|
|
3494
|
+
static countDroppedThinkingBlocks(message) {
|
|
3495
|
+
let count = 0;
|
|
3496
|
+
for (const diagnostic of message.diagnostics ?? []) {
|
|
3497
|
+
if (diagnostic.type !== "anthropic_input_transformations")
|
|
3498
|
+
continue;
|
|
3499
|
+
const transformations = diagnostic.details?.transformations;
|
|
3500
|
+
if (!Array.isArray(transformations))
|
|
3501
|
+
continue;
|
|
3502
|
+
count += transformations.filter((transformation) => typeof transformation === "object" &&
|
|
3503
|
+
transformation !== null &&
|
|
3504
|
+
transformation.type === "thinking_dropped").length;
|
|
3505
|
+
}
|
|
3506
|
+
return count;
|
|
3507
|
+
}
|
|
3508
|
+
maybeShowThinkingDropNotice(message) {
|
|
3509
|
+
if (!this.settingsManager.getShowCacheMissNotices())
|
|
3510
|
+
return;
|
|
3511
|
+
const droppedCount = InteractiveMode.countDroppedThinkingBlocks(message);
|
|
3512
|
+
if (droppedCount === 0)
|
|
3513
|
+
return;
|
|
3514
|
+
let previousDroppedCount = 0;
|
|
3515
|
+
// message_end reaches the UI before the current message is persisted,
|
|
3516
|
+
// so the branch's last assistant message is the previous response.
|
|
3517
|
+
const branch = this.sessionManager.getBranch();
|
|
3518
|
+
for (let i = branch.length - 1; i >= 0; i--) {
|
|
3519
|
+
const entry = branch[i];
|
|
3520
|
+
if (entry.type === "message" && entry.message.role === "assistant") {
|
|
3521
|
+
previousDroppedCount = InteractiveMode.countDroppedThinkingBlocks(entry.message);
|
|
3522
|
+
break;
|
|
3523
|
+
}
|
|
3524
|
+
}
|
|
3525
|
+
if (droppedCount <= previousDroppedCount)
|
|
3526
|
+
return;
|
|
3527
|
+
const noun = droppedCount === 1 ? "thinking block" : "thinking blocks";
|
|
3528
|
+
this.chatContainer.addChild(new Spacer(1));
|
|
3529
|
+
this.chatContainer.addChild(new ThemedText(() => theme.fg("warning", `Anthropic dropped ${droppedCount} ${noun} (details in session)`), 1, 0));
|
|
3530
|
+
}
|
|
3020
3531
|
/**
|
|
3021
3532
|
* Show a transcript notice when a completed assistant message paid for a
|
|
3022
3533
|
* significant cache miss. Only states observable facts: the miss itself,
|
|
@@ -3042,9 +3553,8 @@ export class InteractiveMode {
|
|
|
3042
3553
|
else if (miss.idleMs >= CACHE_TTL_MS) {
|
|
3043
3554
|
label = `Cache miss after ${Math.round(miss.idleMs / 60_000)}m idle`;
|
|
3044
3555
|
}
|
|
3045
|
-
const text = theme.fg("warning", `${label}: ${reBilled}`);
|
|
3046
3556
|
this.chatContainer.addChild(new Spacer(1));
|
|
3047
|
-
this.chatContainer.addChild(new
|
|
3557
|
+
this.chatContainer.addChild(new ThemedText(() => theme.fg("warning", `${label}: ${reBilled}`), 1, 0));
|
|
3048
3558
|
}
|
|
3049
3559
|
renderInitialMessages() {
|
|
3050
3560
|
const entries = this.sessionManager.buildContextEntries();
|
|
@@ -3068,7 +3578,7 @@ export class InteractiveMode {
|
|
|
3068
3578
|
if (this.chatContainer.children.length > 0) {
|
|
3069
3579
|
this.chatContainer.addChild(new Spacer(1));
|
|
3070
3580
|
}
|
|
3071
|
-
this.chatContainer.addChild(new
|
|
3581
|
+
this.chatContainer.addChild(new ThemedText(() => theme.fg("warning", `This project is not trusted. Project ${CONFIG_DIR_NAME} resources and packages are ignored. Use /trust to save a trust decision, then restart ${APP_NAME}.`), 1, 0));
|
|
3072
3582
|
}
|
|
3073
3583
|
async getUserInput() {
|
|
3074
3584
|
const queuedInput = this.pendingUserInputs.shift();
|
|
@@ -3103,6 +3613,12 @@ export class InteractiveMode {
|
|
|
3103
3613
|
// Only called when editor is empty (enforced by CustomEditor)
|
|
3104
3614
|
void this.shutdown();
|
|
3105
3615
|
}
|
|
3616
|
+
/**
|
|
3617
|
+
* Gracefully shutdown the agent.
|
|
3618
|
+
* Stops the TUI before emitting shutdown events so extension UI cleanup cannot
|
|
3619
|
+
* repaint the final frame while the process is exiting.
|
|
3620
|
+
*/
|
|
3621
|
+
isShuttingDown = false;
|
|
3106
3622
|
async shutdown(options) {
|
|
3107
3623
|
if (this.isShuttingDown)
|
|
3108
3624
|
return;
|
|
@@ -3175,8 +3691,14 @@ export class InteractiveMode {
|
|
|
3175
3691
|
this.ui.stop();
|
|
3176
3692
|
}
|
|
3177
3693
|
catch { }
|
|
3178
|
-
console.error(
|
|
3694
|
+
console.error(`${APP_NAME} exiting due to uncaughtException:`);
|
|
3179
3695
|
console.error(error);
|
|
3696
|
+
const extensionHint = this.getCrashExtensionHint(error);
|
|
3697
|
+
if (extensionHint)
|
|
3698
|
+
console.error(`\n${extensionHint}`);
|
|
3699
|
+
if (this.recordCrash("uncaught_exception", error)) {
|
|
3700
|
+
console.error(`\n${this.crashReportInstructions()}`);
|
|
3701
|
+
}
|
|
3180
3702
|
process.exit(1);
|
|
3181
3703
|
}
|
|
3182
3704
|
/**
|
|
@@ -3308,6 +3830,7 @@ export class InteractiveMode {
|
|
|
3308
3830
|
const level = this.session.thinkingLevel || "off";
|
|
3309
3831
|
this.editor.borderColor = theme.getThinkingBorderColor(level);
|
|
3310
3832
|
}
|
|
3833
|
+
this.activeStatusIndicator?.invalidate();
|
|
3311
3834
|
this.ui.requestRender();
|
|
3312
3835
|
}
|
|
3313
3836
|
cycleThinkingLevel() {
|
|
@@ -3394,6 +3917,8 @@ export class InteractiveMode {
|
|
|
3394
3917
|
this.setToolsExpanded(!this.toolOutputExpanded);
|
|
3395
3918
|
}
|
|
3396
3919
|
setToolsExpanded(expanded) {
|
|
3920
|
+
if (expanded === this.toolOutputExpanded)
|
|
3921
|
+
return;
|
|
3397
3922
|
this.toolOutputExpanded = expanded;
|
|
3398
3923
|
const activeHeader = this.customHeader ?? this.builtInHeader;
|
|
3399
3924
|
if (isExpandable(activeHeader)) {
|
|
@@ -3408,18 +3933,19 @@ export class InteractiveMode {
|
|
|
3408
3933
|
}
|
|
3409
3934
|
this.showStatus(`Tool output: ${expanded ? "expanded" : "collapsed"}`);
|
|
3410
3935
|
}
|
|
3936
|
+
/** Update rendered assistant messages without rebuilding live tool components. */
|
|
3937
|
+
updateThinkingBlockVisibility() {
|
|
3938
|
+
for (const child of this.chatContainer.children) {
|
|
3939
|
+
if (child instanceof AssistantMessageComponent) {
|
|
3940
|
+
child.setHideThinkingBlock(this.hideThinkingBlock);
|
|
3941
|
+
}
|
|
3942
|
+
}
|
|
3943
|
+
this.ui.requestRender();
|
|
3944
|
+
}
|
|
3411
3945
|
toggleThinkingBlockVisibility() {
|
|
3412
3946
|
this.hideThinkingBlock = !this.hideThinkingBlock;
|
|
3413
3947
|
this.settingsManager.setHideThinkingBlock(this.hideThinkingBlock);
|
|
3414
|
-
|
|
3415
|
-
this.chatContainer.clear();
|
|
3416
|
-
this.rebuildChatFromMessages();
|
|
3417
|
-
// If streaming, re-add the streaming component with updated visibility and re-render
|
|
3418
|
-
if (this.streamingComponent && this.streamingMessage) {
|
|
3419
|
-
this.streamingComponent.setHideThinkingBlock(this.hideThinkingBlock);
|
|
3420
|
-
this.streamingComponent.updateContent(this.streamingMessage);
|
|
3421
|
-
this.chatContainer.addChild(this.streamingComponent);
|
|
3422
|
-
}
|
|
3948
|
+
this.updateThinkingBlockVisibility();
|
|
3423
3949
|
this.showStatus(`Thinking blocks: ${this.hideThinkingBlock ? "hidden" : "visible"}`);
|
|
3424
3950
|
}
|
|
3425
3951
|
async handleOpenExternalEditor() {
|
|
@@ -3449,44 +3975,38 @@ export class InteractiveMode {
|
|
|
3449
3975
|
}
|
|
3450
3976
|
showError(errorMessage) {
|
|
3451
3977
|
this.chatContainer.addChild(new Spacer(1));
|
|
3452
|
-
this.chatContainer.addChild(new
|
|
3978
|
+
this.chatContainer.addChild(new ThemedText(() => theme.fg("error", `Error: ${errorMessage}`), this.outputPad, 0));
|
|
3453
3979
|
this.ui.requestRender();
|
|
3454
3980
|
}
|
|
3455
3981
|
showWarning(warningMessage) {
|
|
3456
3982
|
this.chatContainer.addChild(new Spacer(1));
|
|
3457
|
-
this.chatContainer.addChild(new
|
|
3983
|
+
this.chatContainer.addChild(new ThemedText(() => theme.fg("warning", `Warning: ${warningMessage}`), 1, 0));
|
|
3458
3984
|
this.ui.requestRender();
|
|
3459
3985
|
}
|
|
3460
3986
|
showNewVersionNotification(release) {
|
|
3461
|
-
const
|
|
3462
|
-
|
|
3463
|
-
const changelogUrl = "https://
|
|
3464
|
-
const
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3987
|
+
const updateInstruction = () => theme.fg("muted", `New version ${release.version} is available. Run `) +
|
|
3988
|
+
theme.fg("accent", `${APP_NAME} update`);
|
|
3989
|
+
const changelogUrl = "https://github.com/draht-dev/draht/blob/main/packages/coding-agent/CHANGELOG.md";
|
|
3990
|
+
const changelogLine = () => {
|
|
3991
|
+
const changelogLink = getCapabilities().hyperlinks
|
|
3992
|
+
? hyperlink(theme.fg("accent", changelogUrl), changelogUrl)
|
|
3993
|
+
: theme.fg("accent", changelogUrl);
|
|
3994
|
+
return theme.fg("muted", "Changelog: ") + changelogLink;
|
|
3995
|
+
};
|
|
3469
3996
|
this.chatContainer.addChild(new Spacer(1));
|
|
3470
3997
|
this.chatContainer.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
|
|
3471
|
-
this.chatContainer.addChild(new
|
|
3472
|
-
|
|
3473
|
-
this.chatContainer.addChild(new Spacer(1));
|
|
3474
|
-
this.chatContainer.addChild(new Markdown(note, 1, 0, this.getMarkdownThemeWithSettings(), {
|
|
3475
|
-
color: (text) => theme.fg("muted", text),
|
|
3476
|
-
}));
|
|
3477
|
-
this.chatContainer.addChild(new Spacer(1));
|
|
3478
|
-
}
|
|
3479
|
-
this.chatContainer.addChild(new Text(changelogLine, 1, 0));
|
|
3998
|
+
this.chatContainer.addChild(new ThemedText(() => `${theme.bold(theme.fg("warning", "Update Available"))}\n${updateInstruction()}`, 1, 0));
|
|
3999
|
+
this.chatContainer.addChild(new ThemedText(changelogLine, 1, 0));
|
|
3480
4000
|
this.chatContainer.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
|
|
3481
4001
|
this.ui.requestRender();
|
|
3482
4002
|
}
|
|
3483
4003
|
showPackageUpdateNotification(packages) {
|
|
3484
|
-
const
|
|
3485
|
-
|
|
4004
|
+
const updateInstruction = () => theme.fg("muted", "Package updates are available. Run ") +
|
|
4005
|
+
theme.fg("accent", `${APP_NAME} update --extensions`);
|
|
3486
4006
|
const packageLines = packages.map((pkg) => `- ${pkg}`).join("\n");
|
|
3487
4007
|
this.chatContainer.addChild(new Spacer(1));
|
|
3488
4008
|
this.chatContainer.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
|
|
3489
|
-
this.chatContainer.addChild(new
|
|
4009
|
+
this.chatContainer.addChild(new ThemedText(() => `${theme.bold(theme.fg("warning", "Package Updates Available"))}\n${updateInstruction()}\n${theme.fg("muted", "Packages:")}\n${packageLines}`, 1, 0));
|
|
3490
4010
|
this.chatContainer.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
|
|
3491
4011
|
this.ui.requestRender();
|
|
3492
4012
|
}
|
|
@@ -3548,7 +4068,7 @@ export class InteractiveMode {
|
|
|
3548
4068
|
if (allQueued.length === 0) {
|
|
3549
4069
|
this.updatePendingMessagesDisplay();
|
|
3550
4070
|
if (options?.abort) {
|
|
3551
|
-
this.
|
|
4071
|
+
void this.session.abort();
|
|
3552
4072
|
}
|
|
3553
4073
|
return 0;
|
|
3554
4074
|
}
|
|
@@ -3558,7 +4078,7 @@ export class InteractiveMode {
|
|
|
3558
4078
|
this.editor.setText(combinedText);
|
|
3559
4079
|
this.updatePendingMessagesDisplay();
|
|
3560
4080
|
if (options?.abort) {
|
|
3561
|
-
this.
|
|
4081
|
+
void this.session.abort();
|
|
3562
4082
|
}
|
|
3563
4083
|
return allQueued.length;
|
|
3564
4084
|
}
|
|
@@ -3659,26 +4179,50 @@ export class InteractiveMode {
|
|
|
3659
4179
|
// =========================================================================
|
|
3660
4180
|
// Selectors
|
|
3661
4181
|
// =========================================================================
|
|
4182
|
+
disposeActiveSelector() {
|
|
4183
|
+
const dispose = this.activeSelectorDispose;
|
|
4184
|
+
this.activeSelectorToken = undefined;
|
|
4185
|
+
this.activeSelectorDispose = undefined;
|
|
4186
|
+
dispose?.();
|
|
4187
|
+
}
|
|
3662
4188
|
/**
|
|
3663
4189
|
* Shows a selector component in place of the editor.
|
|
3664
4190
|
* @param create Factory that receives a `done` callback and returns the component and focus target
|
|
3665
4191
|
*/
|
|
3666
4192
|
showSelector(create) {
|
|
4193
|
+
const token = {};
|
|
4194
|
+
let dispose;
|
|
3667
4195
|
const done = () => {
|
|
4196
|
+
dispose?.();
|
|
4197
|
+
if (this.activeSelectorToken !== token)
|
|
4198
|
+
return;
|
|
4199
|
+
this.activeSelectorToken = undefined;
|
|
4200
|
+
this.activeSelectorDispose = undefined;
|
|
3668
4201
|
this.editorContainer.clear();
|
|
3669
4202
|
this.editorContainer.addChild(this.editor);
|
|
3670
4203
|
this.ui.setFocus(this.editor);
|
|
3671
4204
|
};
|
|
3672
|
-
const
|
|
4205
|
+
const created = create(done);
|
|
4206
|
+
dispose = created.dispose;
|
|
4207
|
+
this.disposeActiveSelector();
|
|
4208
|
+
this.activeSelectorToken = token;
|
|
4209
|
+
this.activeSelectorDispose = dispose;
|
|
3673
4210
|
this.editorContainer.clear();
|
|
3674
|
-
this.editorContainer.addChild(component);
|
|
3675
|
-
this.ui.setFocus(focus);
|
|
4211
|
+
this.editorContainer.addChild(created.component);
|
|
4212
|
+
this.ui.setFocus(created.focus);
|
|
3676
4213
|
this.ui.requestRender();
|
|
3677
4214
|
}
|
|
3678
4215
|
showSettingsSelector() {
|
|
3679
4216
|
this.showSelector((done) => {
|
|
3680
|
-
|
|
4217
|
+
let selector;
|
|
4218
|
+
const defaultProvider = this.settingsManager.getDefaultProvider();
|
|
4219
|
+
const defaultModelId = this.settingsManager.getDefaultModel();
|
|
4220
|
+
const defaultModel = defaultProvider && defaultModelId ? `${defaultProvider}/${defaultModelId}` : "not set";
|
|
4221
|
+
selector = new SettingsSelectorComponent({
|
|
3681
4222
|
autoCompact: this.session.autoCompactionEnabled,
|
|
4223
|
+
defaultModel,
|
|
4224
|
+
currentModel: this.session.model,
|
|
4225
|
+
availableDefaultModels: this.session.modelRuntime.getAvailableSnapshot(),
|
|
3682
4226
|
showImages: this.settingsManager.getShowImages(),
|
|
3683
4227
|
imageWidthCells: this.settingsManager.getImageWidthCells(),
|
|
3684
4228
|
autoResizeImages: this.settingsManager.getImageAutoResize(),
|
|
@@ -3688,12 +4232,15 @@ export class InteractiveMode {
|
|
|
3688
4232
|
followUpMode: this.session.followUpMode,
|
|
3689
4233
|
transport: this.settingsManager.getTransport(),
|
|
3690
4234
|
httpIdleTimeoutMs: this.settingsManager.getHttpIdleTimeoutMs(),
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
4235
|
+
cacheWarmingMode: this.settingsManager.getCacheWarmingMode(),
|
|
4236
|
+
thinkingLevel: this.settingsManager.getDefaultThinkingLevel() ?? DEFAULT_THINKING_LEVEL,
|
|
4237
|
+
availableThinkingLevels: [...THINKING_LEVEL_OPTIONS],
|
|
4238
|
+
modelThinkingLevels: this.settingsManager.getAllModelThinkingLevels(),
|
|
4239
|
+
currentTheme: this.themeController.getThemeSelection() || SYSTEM_THEME_NAME,
|
|
3694
4240
|
terminalTheme: this.themeController.getTerminalTheme(),
|
|
3695
4241
|
availableThemes: getAvailableThemes(),
|
|
3696
4242
|
hideThinkingBlock: this.hideThinkingBlock,
|
|
4243
|
+
mermaidRenderingMode: this.settingsManager.getMermaidRenderingMode(),
|
|
3697
4244
|
collapseChangelog: this.settingsManager.getCollapseChangelog(),
|
|
3698
4245
|
enableInstallTelemetry: this.settingsManager.getEnableInstallTelemetry(),
|
|
3699
4246
|
doubleEscapeAction: this.settingsManager.getDoubleEscapeAction(),
|
|
@@ -3708,6 +4255,11 @@ export class InteractiveMode {
|
|
|
3708
4255
|
attachableSessions: this.settingsManager.getAttachableSessions(),
|
|
3709
4256
|
clearOnShrink: this.settingsManager.getClearOnShrink(),
|
|
3710
4257
|
showTerminalProgress: this.settingsManager.getShowTerminalProgress(),
|
|
4258
|
+
tuiMode: this.ui.mode,
|
|
4259
|
+
fullscreenExitOutput: this.settingsManager.getFullscreenExitOutput(),
|
|
4260
|
+
fullscreenScrollbar: this.settingsManager.getFullscreenScrollbar(),
|
|
4261
|
+
fullscreenCopyOnSelect: this.settingsManager.getFullscreenCopyOnSelect(),
|
|
4262
|
+
fullscreenWheelScrollLines: this.settingsManager.getFullscreenWheelScrollLines(),
|
|
3711
4263
|
warnings: this.settingsManager.getWarnings(),
|
|
3712
4264
|
}, {
|
|
3713
4265
|
onAutoCompactChange: (enabled) => {
|
|
@@ -3755,26 +4307,45 @@ export class InteractiveMode {
|
|
|
3755
4307
|
configureHttpDispatcher(timeoutMs);
|
|
3756
4308
|
this.showStatus(`HTTP idle timeout: ${formatHttpIdleTimeoutMs(timeoutMs)}`);
|
|
3757
4309
|
},
|
|
3758
|
-
|
|
3759
|
-
this.session.
|
|
3760
|
-
this.
|
|
3761
|
-
|
|
4310
|
+
onCacheWarmingModeChange: (mode) => {
|
|
4311
|
+
this.session.setCacheWarmingMode(mode);
|
|
4312
|
+
this.showStatus(`Cache warming: ${mode}`);
|
|
4313
|
+
},
|
|
4314
|
+
onModelThinkingLevelChange: (provider, modelId, level) => {
|
|
4315
|
+
this.settingsManager.setModelThinkingLevel(provider, modelId, level);
|
|
4316
|
+
// If the override is for the current model, apply it to the session too
|
|
4317
|
+
const current = this.session.model;
|
|
4318
|
+
if (current && current.provider === provider && current.id === modelId) {
|
|
4319
|
+
this.session.setThinkingLevel(level);
|
|
4320
|
+
this.footer.invalidate();
|
|
4321
|
+
this.updateEditorBorderColor();
|
|
4322
|
+
}
|
|
4323
|
+
},
|
|
4324
|
+
onModelThinkingLevelRemove: (provider, modelId) => {
|
|
4325
|
+
this.settingsManager.removeModelThinkingLevel(provider, modelId);
|
|
4326
|
+
// If the override was for the current model, revert to global default
|
|
4327
|
+
const current = this.session.model;
|
|
4328
|
+
if (current && current.provider === provider && current.id === modelId) {
|
|
4329
|
+
const globalDefault = this.settingsManager.getDefaultThinkingLevel() ?? DEFAULT_THINKING_LEVEL;
|
|
4330
|
+
this.session.setThinkingLevel(globalDefault);
|
|
4331
|
+
this.footer.invalidate();
|
|
4332
|
+
this.updateEditorBorderColor();
|
|
4333
|
+
}
|
|
3762
4334
|
},
|
|
3763
4335
|
onThemeChange: (themeSetting) => {
|
|
3764
4336
|
this.settingsManager.setTheme(themeSetting);
|
|
3765
|
-
|
|
4337
|
+
this.themeController.setThemeSetting(themeSetting);
|
|
3766
4338
|
},
|
|
3767
4339
|
onThemePreview: (themeName) => this.themeController.preview(themeName),
|
|
3768
4340
|
onHideThinkingBlockChange: (hidden) => {
|
|
3769
4341
|
this.hideThinkingBlock = hidden;
|
|
3770
4342
|
this.settingsManager.setHideThinkingBlock(hidden);
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
this.
|
|
3777
|
-
this.rebuildChatFromMessages();
|
|
4343
|
+
this.updateThinkingBlockVisibility();
|
|
4344
|
+
},
|
|
4345
|
+
onMermaidRenderingModeChange: (mode) => {
|
|
4346
|
+
this.settingsManager.setMermaidRenderingMode(mode);
|
|
4347
|
+
this.chatContainer.invalidate();
|
|
4348
|
+
this.ui.requestRender();
|
|
3778
4349
|
},
|
|
3779
4350
|
onShowCacheMissNoticesChange: (shown) => {
|
|
3780
4351
|
this.settingsManager.setShowCacheMissNotices(shown);
|
|
@@ -3849,6 +4420,34 @@ export class InteractiveMode {
|
|
|
3849
4420
|
onShowTerminalProgressChange: (enabled) => {
|
|
3850
4421
|
this.settingsManager.setShowTerminalProgress(enabled);
|
|
3851
4422
|
},
|
|
4423
|
+
onTuiModeChange: (mode) => {
|
|
4424
|
+
if (!this.switchTuiMode(mode)) {
|
|
4425
|
+
selector?.getSettingsList().updateValue("tui-mode", this.ui.mode);
|
|
4426
|
+
this.showStatus("Close active overlays before changing TUI mode");
|
|
4427
|
+
return;
|
|
4428
|
+
}
|
|
4429
|
+
this.settingsManager.setTuiMode(mode);
|
|
4430
|
+
if (!this.activeStatusIndicator)
|
|
4431
|
+
this.statusContainer.clear();
|
|
4432
|
+
this.showStatus(`TUI mode: ${mode}`);
|
|
4433
|
+
},
|
|
4434
|
+
onFullscreenExitOutputChange: (output) => {
|
|
4435
|
+
this.settingsManager.setFullscreenExitOutput(output);
|
|
4436
|
+
},
|
|
4437
|
+
onFullscreenScrollbarChange: (mode) => {
|
|
4438
|
+
this.settingsManager.setFullscreenScrollbar(mode);
|
|
4439
|
+
this.applyFullscreenScrollbarSetting();
|
|
4440
|
+
},
|
|
4441
|
+
onFullscreenCopyOnSelectChange: (enabled) => {
|
|
4442
|
+
this.settingsManager.setFullscreenCopyOnSelect(enabled);
|
|
4443
|
+
if (this.renderer instanceof TuiAltScreen)
|
|
4444
|
+
this.renderer.setCopyOnSelect(enabled);
|
|
4445
|
+
},
|
|
4446
|
+
onFullscreenWheelScrollLinesChange: (lines) => {
|
|
4447
|
+
this.settingsManager.setFullscreenWheelScrollLines(lines);
|
|
4448
|
+
if (this.renderer instanceof TuiAltScreen)
|
|
4449
|
+
this.renderer.setWheelScrollLines(lines);
|
|
4450
|
+
},
|
|
3852
4451
|
onWarningsChange: (warnings) => {
|
|
3853
4452
|
this.settingsManager.setWarnings(warnings);
|
|
3854
4453
|
},
|
|
@@ -3860,6 +4459,44 @@ export class InteractiveMode {
|
|
|
3860
4459
|
return { component: selector, focus: selector.getSettingsList() };
|
|
3861
4460
|
});
|
|
3862
4461
|
}
|
|
4462
|
+
handleThinkingCommand(searchTerm) {
|
|
4463
|
+
const availableLevels = this.session.getAvailableThinkingLevels();
|
|
4464
|
+
if (!searchTerm) {
|
|
4465
|
+
this.showThinkingSelector();
|
|
4466
|
+
return;
|
|
4467
|
+
}
|
|
4468
|
+
const normalized = searchTerm.trim().toLowerCase();
|
|
4469
|
+
const level = availableLevels.find((candidate) => candidate.toLowerCase() === normalized);
|
|
4470
|
+
if (!level) {
|
|
4471
|
+
this.showError(`Unknown thinking level "${searchTerm}". Available levels: ${availableLevels.join(", ")}.`);
|
|
4472
|
+
return;
|
|
4473
|
+
}
|
|
4474
|
+
this.selectThinkingLevel(level, false);
|
|
4475
|
+
}
|
|
4476
|
+
selectThinkingLevel(level, persist) {
|
|
4477
|
+
try {
|
|
4478
|
+
this.session.setThinkingLevel(level, { persist });
|
|
4479
|
+
this.footer.invalidate();
|
|
4480
|
+
this.updateEditorBorderColor();
|
|
4481
|
+
this.showStatus(persist ? `Default thinking level: ${level}` : `Thinking level: ${level}`);
|
|
4482
|
+
}
|
|
4483
|
+
catch (error) {
|
|
4484
|
+
this.showError(error instanceof Error ? error.message : String(error));
|
|
4485
|
+
}
|
|
4486
|
+
}
|
|
4487
|
+
showThinkingSelector() {
|
|
4488
|
+
this.showSelector((done) => {
|
|
4489
|
+
const selectLevel = (level, persist) => {
|
|
4490
|
+
this.selectThinkingLevel(level, persist);
|
|
4491
|
+
done();
|
|
4492
|
+
};
|
|
4493
|
+
const selector = new ThinkingSelectorComponent(this.session.thinkingLevel ?? DEFAULT_THINKING_LEVEL, this.session.getAvailableThinkingLevels(), (level) => selectLevel(level, false), () => {
|
|
4494
|
+
done();
|
|
4495
|
+
this.ui.requestRender();
|
|
4496
|
+
}, (level) => selectLevel(level, true), this.settingsManager.getDefaultThinkingLevel() ?? DEFAULT_THINKING_LEVEL);
|
|
4497
|
+
return { component: selector, focus: selector };
|
|
4498
|
+
});
|
|
4499
|
+
}
|
|
3863
4500
|
async handleModelCommand(searchTerm) {
|
|
3864
4501
|
if (!searchTerm) {
|
|
3865
4502
|
this.showModelSelector();
|
|
@@ -3868,7 +4505,7 @@ export class InteractiveMode {
|
|
|
3868
4505
|
const model = await this.findExactModelMatch(searchTerm);
|
|
3869
4506
|
if (model) {
|
|
3870
4507
|
try {
|
|
3871
|
-
await this.session.setModel(model);
|
|
4508
|
+
await this.session.setModel(model, { persist: false });
|
|
3872
4509
|
this.footer.invalidate();
|
|
3873
4510
|
this.updateEditorBorderColor();
|
|
3874
4511
|
this.showStatus(`Model: ${model.id}`);
|
|
@@ -3883,20 +4520,37 @@ export class InteractiveMode {
|
|
|
3883
4520
|
this.showModelSelector(searchTerm);
|
|
3884
4521
|
}
|
|
3885
4522
|
async findExactModelMatch(searchTerm) {
|
|
3886
|
-
const
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
if (this.session.scopedModels.length > 0)
|
|
3891
|
-
return
|
|
3892
|
-
|
|
4523
|
+
const cachedModels = this.session.scopedModels.length > 0
|
|
4524
|
+
? this.session.scopedModels.map((scoped) => scoped.model)
|
|
4525
|
+
: [...this.session.modelRuntime.getAvailableSnapshot()];
|
|
4526
|
+
const cachedMatch = findExactModelReferenceMatch(searchTerm, cachedModels);
|
|
4527
|
+
if (cachedMatch || this.session.scopedModels.length > 0)
|
|
4528
|
+
return cachedMatch;
|
|
4529
|
+
this.showStatus("Refreshing model catalogs…");
|
|
4530
|
+
const controller = new AbortController();
|
|
4531
|
+
let timedOut = false;
|
|
4532
|
+
const timeout = setTimeout(() => {
|
|
4533
|
+
timedOut = true;
|
|
4534
|
+
controller.abort();
|
|
4535
|
+
}, 15_000);
|
|
3893
4536
|
try {
|
|
3894
|
-
await this.session.modelRuntime.
|
|
3895
|
-
|
|
4537
|
+
const result = await refreshModelCatalogs(this.session.modelRuntime, controller.signal);
|
|
4538
|
+
if (result.aborted && timedOut) {
|
|
4539
|
+
this.showWarning("Model refresh timed out; searching cached models.");
|
|
4540
|
+
}
|
|
4541
|
+
else if (result.errors.size > 0) {
|
|
4542
|
+
this.showWarning(`Could not refresh ${[...result.errors.keys()].join(", ")}; searching cached models.`);
|
|
4543
|
+
}
|
|
3896
4544
|
}
|
|
3897
|
-
catch {
|
|
3898
|
-
|
|
4545
|
+
catch (error) {
|
|
4546
|
+
this.showWarning(timedOut
|
|
4547
|
+
? "Model refresh timed out; searching cached models."
|
|
4548
|
+
: `Could not refresh model catalogs: ${error instanceof Error ? error.message : String(error)}`);
|
|
3899
4549
|
}
|
|
4550
|
+
finally {
|
|
4551
|
+
clearTimeout(timeout);
|
|
4552
|
+
}
|
|
4553
|
+
return findExactModelReferenceMatch(searchTerm, [...this.session.modelRuntime.getAvailableSnapshot()]);
|
|
3900
4554
|
}
|
|
3901
4555
|
/** Update the footer's available provider count from the current snapshot without refreshing catalogs. */
|
|
3902
4556
|
updateAvailableProviderCount() {
|
|
@@ -3968,7 +4622,7 @@ export class InteractiveMode {
|
|
|
3968
4622
|
onSelect: (selection) => {
|
|
3969
4623
|
trustStore.setMany(selection.updates);
|
|
3970
4624
|
done();
|
|
3971
|
-
this.showStatus(`Saved trust decision: ${selection.trusted ? "trusted" : "untrusted"}. Restart
|
|
4625
|
+
this.showStatus(`Saved trust decision: ${selection.trusted ? "trusted" : "untrusted"}. Restart ${APP_NAME} for this to take effect.`);
|
|
3972
4626
|
},
|
|
3973
4627
|
onCancel: () => {
|
|
3974
4628
|
done();
|
|
@@ -3980,13 +4634,14 @@ export class InteractiveMode {
|
|
|
3980
4634
|
}
|
|
3981
4635
|
showModelSelector(initialSearchInput) {
|
|
3982
4636
|
this.showSelector((done) => {
|
|
3983
|
-
const
|
|
4637
|
+
const selectModel = async (model, persist) => {
|
|
3984
4638
|
try {
|
|
3985
|
-
await this.session.setModel(model);
|
|
4639
|
+
await this.session.setModel(model, { persist });
|
|
4640
|
+
this.updateAvailableProviderCount();
|
|
3986
4641
|
this.footer.invalidate();
|
|
3987
4642
|
this.updateEditorBorderColor();
|
|
3988
4643
|
done();
|
|
3989
|
-
this.showStatus(`Model: ${model.id}`);
|
|
4644
|
+
this.showStatus(persist ? `Default model: ${model.provider}/${model.id}` : `Model: ${model.id}`);
|
|
3990
4645
|
void this.maybeWarnAboutAnthropicSubscriptionAuth(model);
|
|
3991
4646
|
this.checkDaxnutsEasterEgg(model);
|
|
3992
4647
|
}
|
|
@@ -3994,77 +4649,74 @@ export class InteractiveMode {
|
|
|
3994
4649
|
done();
|
|
3995
4650
|
this.showError(error instanceof Error ? error.message : String(error));
|
|
3996
4651
|
}
|
|
3997
|
-
}
|
|
4652
|
+
};
|
|
4653
|
+
const defaultProvider = this.settingsManager.getDefaultProvider();
|
|
4654
|
+
const defaultModel = this.settingsManager.getDefaultModel();
|
|
4655
|
+
const selector = new ModelSelectorComponent(this.ui, this.session.model, this.session.modelRuntime, this.session.scopedModels, (model) => selectModel(model, false), () => {
|
|
3998
4656
|
done();
|
|
3999
4657
|
this.ui.requestRender();
|
|
4000
|
-
}, initialSearchInput);
|
|
4001
|
-
return { component: selector, focus: selector };
|
|
4658
|
+
}, initialSearchInput, (model) => selectModel(model, true), defaultProvider && defaultModel ? { provider: defaultProvider, id: defaultModel } : undefined);
|
|
4659
|
+
return { component: selector, focus: selector, dispose: () => selector.dispose() };
|
|
4002
4660
|
});
|
|
4003
4661
|
}
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
const allModels = [...(await this.session.modelRuntime.getAvailable())];
|
|
4008
|
-
const allModelIds = new Set(allModels.map((model) => `${model.provider}/${model.id}`));
|
|
4662
|
+
showModelsSelector() {
|
|
4663
|
+
let availableModels = [...this.session.modelRuntime.getAvailableSnapshot()];
|
|
4664
|
+
let availableModelIds = new Set(availableModels.map((model) => `${model.provider}/${model.id}`));
|
|
4009
4665
|
const configuredPatterns = this.settingsManager.getEnabledModels();
|
|
4010
4666
|
const sessionScopedModels = this.session.scopedModels;
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
currentEnabledIds = configuredScope.scopedModels.map((scoped) => `${scoped.model.provider}/${scoped.model.id}`);
|
|
4028
|
-
}
|
|
4029
|
-
for (const diagnostic of configuredScope?.diagnostics ?? []) {
|
|
4030
|
-
if (diagnostic.code !== "no-match")
|
|
4031
|
-
continue;
|
|
4032
|
-
currentEnabledIds ??= [];
|
|
4033
|
-
if (!currentEnabledIds.includes(diagnostic.pattern))
|
|
4034
|
-
currentEnabledIds.push(diagnostic.pattern);
|
|
4035
|
-
}
|
|
4036
|
-
// Helper to update session's scoped models (session-only, no persist)
|
|
4037
|
-
const updateSessionModels = async (enabledIds) => {
|
|
4667
|
+
const configuredEnabledIds = (models) => {
|
|
4668
|
+
if (!configuredPatterns?.length)
|
|
4669
|
+
return null;
|
|
4670
|
+
const resolved = resolveModelScopeFromModels(configuredPatterns, models);
|
|
4671
|
+
const ids = resolved.scopedModels.map((scoped) => `${scoped.model.provider}/${scoped.model.id}`);
|
|
4672
|
+
for (const diagnostic of resolved.diagnostics) {
|
|
4673
|
+
if (diagnostic.code === "no-match" && !ids.includes(diagnostic.pattern))
|
|
4674
|
+
ids.push(diagnostic.pattern);
|
|
4675
|
+
}
|
|
4676
|
+
return ids;
|
|
4677
|
+
};
|
|
4678
|
+
let currentEnabledIds = sessionScopedModels.length > 0
|
|
4679
|
+
? sessionScopedModels.map((scoped) => `${scoped.model.provider}/${scoped.model.id}`)
|
|
4680
|
+
: configuredEnabledIds(availableModels);
|
|
4681
|
+
let selectionChanged = false;
|
|
4682
|
+
const updateSessionModels = (enabledIds) => {
|
|
4038
4683
|
currentEnabledIds = enabledIds === null ? null : [...enabledIds];
|
|
4039
|
-
const hasEnabledAvailableModel = enabledIds?.some((id) =>
|
|
4040
|
-
const allAvailableModelsEnabled = enabledIds !== null && [...
|
|
4684
|
+
const hasEnabledAvailableModel = enabledIds?.some((id) => availableModelIds.has(id)) ?? false;
|
|
4685
|
+
const allAvailableModelsEnabled = enabledIds !== null && [...availableModelIds].every((id) => enabledIds.includes(id));
|
|
4041
4686
|
if (enabledIds && hasEnabledAvailableModel && !allAvailableModelsEnabled) {
|
|
4042
|
-
const newScopedModels =
|
|
4043
|
-
this.session.setScopedModels(newScopedModels.map((
|
|
4044
|
-
model:
|
|
4045
|
-
thinkingLevel:
|
|
4687
|
+
const newScopedModels = resolveModelScopeFromModels(enabledIds, availableModels).scopedModels;
|
|
4688
|
+
this.session.setScopedModels(newScopedModels.map((scoped) => ({
|
|
4689
|
+
model: scoped.model,
|
|
4690
|
+
thinkingLevel: scoped.thinkingLevel,
|
|
4046
4691
|
})));
|
|
4047
4692
|
}
|
|
4048
4693
|
else {
|
|
4049
|
-
// All enabled or none enabled = no filter
|
|
4050
4694
|
this.session.setScopedModels([]);
|
|
4051
4695
|
}
|
|
4052
|
-
|
|
4696
|
+
this.updateAvailableProviderCount();
|
|
4053
4697
|
this.ui.requestRender();
|
|
4054
4698
|
};
|
|
4055
4699
|
this.showSelector((done) => {
|
|
4700
|
+
let disposed = false;
|
|
4701
|
+
let timedOut = false;
|
|
4702
|
+
const controller = new AbortController();
|
|
4703
|
+
const timeout = setTimeout(() => {
|
|
4704
|
+
timedOut = true;
|
|
4705
|
+
controller.abort();
|
|
4706
|
+
}, 15_000);
|
|
4056
4707
|
const selector = new ScopedModelsSelectorComponent({
|
|
4057
|
-
allModels,
|
|
4708
|
+
allModels: availableModels,
|
|
4058
4709
|
enabledModelIds: currentEnabledIds,
|
|
4710
|
+
refreshStatus: "Refreshing model catalogs…",
|
|
4059
4711
|
}, {
|
|
4060
|
-
onChange:
|
|
4061
|
-
|
|
4712
|
+
onChange: (enabledIds) => {
|
|
4713
|
+
selectionChanged = true;
|
|
4714
|
+
updateSessionModels(enabledIds);
|
|
4062
4715
|
},
|
|
4063
4716
|
onPersist: (enabledIds) => {
|
|
4064
|
-
// Persist to settings
|
|
4065
4717
|
const allEnabled = enabledIds !== null &&
|
|
4066
|
-
enabledIds.length ===
|
|
4067
|
-
enabledIds.every((id) =>
|
|
4718
|
+
enabledIds.length === availableModels.length &&
|
|
4719
|
+
enabledIds.every((id) => availableModelIds.has(id));
|
|
4068
4720
|
const newPatterns = enabledIds === null || allEnabled ? undefined : enabledIds;
|
|
4069
4721
|
this.settingsManager.setEnabledModels(newPatterns ? [...newPatterns] : undefined);
|
|
4070
4722
|
this.showStatus("Model selection saved to settings");
|
|
@@ -4074,7 +4726,50 @@ export class InteractiveMode {
|
|
|
4074
4726
|
this.ui.requestRender();
|
|
4075
4727
|
},
|
|
4076
4728
|
});
|
|
4077
|
-
|
|
4729
|
+
void refreshModelCatalogs(this.session.modelRuntime, controller.signal)
|
|
4730
|
+
.then((result) => {
|
|
4731
|
+
if (disposed)
|
|
4732
|
+
return;
|
|
4733
|
+
availableModels = [...this.session.modelRuntime.getAvailableSnapshot()];
|
|
4734
|
+
availableModelIds = new Set(availableModels.map((model) => `${model.provider}/${model.id}`));
|
|
4735
|
+
if (!selectionChanged && sessionScopedModels.length === 0) {
|
|
4736
|
+
currentEnabledIds = configuredEnabledIds(availableModels);
|
|
4737
|
+
selector.updateModels(availableModels, currentEnabledIds);
|
|
4738
|
+
}
|
|
4739
|
+
else {
|
|
4740
|
+
selector.updateModels(availableModels);
|
|
4741
|
+
}
|
|
4742
|
+
if (currentEnabledIds !== null)
|
|
4743
|
+
updateSessionModels(currentEnabledIds);
|
|
4744
|
+
if (result.aborted && timedOut) {
|
|
4745
|
+
selector.setRefreshStatus("Model refresh timed out; showing cached models.", "warning");
|
|
4746
|
+
}
|
|
4747
|
+
else if (result.errors.size > 0) {
|
|
4748
|
+
selector.setRefreshStatus(`Could not refresh ${[...result.errors.keys()].join(", ")}; showing cached models.`, "warning");
|
|
4749
|
+
}
|
|
4750
|
+
else {
|
|
4751
|
+
selector.setRefreshStatus("Model catalogs refreshed.", "success");
|
|
4752
|
+
}
|
|
4753
|
+
this.ui.requestRender();
|
|
4754
|
+
})
|
|
4755
|
+
.catch((error) => {
|
|
4756
|
+
if (disposed)
|
|
4757
|
+
return;
|
|
4758
|
+
selector.setRefreshStatus(timedOut
|
|
4759
|
+
? "Model refresh timed out; showing cached models."
|
|
4760
|
+
: `Could not refresh model catalogs: ${error instanceof Error ? error.message : String(error)}`, "warning");
|
|
4761
|
+
this.ui.requestRender();
|
|
4762
|
+
})
|
|
4763
|
+
.finally(() => clearTimeout(timeout));
|
|
4764
|
+
return {
|
|
4765
|
+
component: selector,
|
|
4766
|
+
focus: selector,
|
|
4767
|
+
dispose: () => {
|
|
4768
|
+
disposed = true;
|
|
4769
|
+
clearTimeout(timeout);
|
|
4770
|
+
controller.abort();
|
|
4771
|
+
},
|
|
4772
|
+
};
|
|
4078
4773
|
});
|
|
4079
4774
|
}
|
|
4080
4775
|
showUserMessageSelector() {
|
|
@@ -4184,6 +4879,11 @@ export class InteractiveMode {
|
|
|
4184
4879
|
this.restoreQueuedMessagesToEditor();
|
|
4185
4880
|
await this.session.abort();
|
|
4186
4881
|
}
|
|
4882
|
+
// Recheck after the dialogs and streaming abort, before replacing another operation's UI.
|
|
4883
|
+
if (this.session.isCompacting) {
|
|
4884
|
+
this.showError("Wait for the current compaction or tree navigation to finish before navigating the session tree.");
|
|
4885
|
+
return;
|
|
4886
|
+
}
|
|
4187
4887
|
// Set up escape handler and status indicator if summarizing
|
|
4188
4888
|
let showingSummaryIndicator = false;
|
|
4189
4889
|
const originalOnEscape = this.defaultEditor.onEscape;
|
|
@@ -4372,9 +5072,9 @@ export class InteractiveMode {
|
|
|
4372
5072
|
}
|
|
4373
5073
|
showSessionSelector() {
|
|
4374
5074
|
this.showSelector((done) => {
|
|
4375
|
-
const selector = new SessionSelectorComponent((onProgress) => SessionManager.list(this.sessionManager.getCwd(), this.sessionManager.getSessionDir(), onProgress), (onProgress) => this.sessionManager.usesDefaultSessionDir()
|
|
4376
|
-
? SessionManager.listAll(onProgress)
|
|
4377
|
-
: SessionManager.listAll(this.sessionManager.getSessionDir(), onProgress), async (sessionPath) => {
|
|
5075
|
+
const selector = new SessionSelectorComponent((onProgress, signal) => SessionManager.list(this.sessionManager.getCwd(), this.sessionManager.getSessionDir(), onProgress, signal), (onProgress, signal) => this.sessionManager.usesDefaultSessionDir()
|
|
5076
|
+
? SessionManager.listAll(onProgress, signal)
|
|
5077
|
+
: SessionManager.listAll(this.sessionManager.getSessionDir(), onProgress, signal), async (sessionPath) => {
|
|
4378
5078
|
done();
|
|
4379
5079
|
await this.handleResumeSession(sessionPath);
|
|
4380
5080
|
}, () => {
|
|
@@ -4462,7 +5162,7 @@ export class InteractiveMode {
|
|
|
4462
5162
|
return options.sort((a, b) => a.name.localeCompare(b.name));
|
|
4463
5163
|
}
|
|
4464
5164
|
async getLogoutProviderOptions() {
|
|
4465
|
-
return (await this.session.modelRuntime.listCredentials())
|
|
5165
|
+
return (await this.session.modelRuntime.listCredentials({ signal: AbortSignal.timeout(15_000) }))
|
|
4466
5166
|
.map(({ providerId, type }) => ({
|
|
4467
5167
|
id: providerId,
|
|
4468
5168
|
name: this.session.modelRuntime.getProvider(providerId)?.name ?? providerId,
|
|
@@ -4480,7 +5180,6 @@ export class InteractiveMode {
|
|
|
4480
5180
|
provider.name.toLowerCase() === normalizedProviderRef);
|
|
4481
5181
|
}
|
|
4482
5182
|
async handleLoginCommand(providerRef) {
|
|
4483
|
-
await this.session.modelRuntime.getAvailable();
|
|
4484
5183
|
if (!providerRef) {
|
|
4485
5184
|
this.showLoginAuthTypeSelector();
|
|
4486
5185
|
return;
|
|
@@ -4594,7 +5293,14 @@ export class InteractiveMode {
|
|
|
4594
5293
|
this.showLoginAuthTypeSelector();
|
|
4595
5294
|
return;
|
|
4596
5295
|
}
|
|
4597
|
-
|
|
5296
|
+
let providerOptions;
|
|
5297
|
+
try {
|
|
5298
|
+
providerOptions = await this.getLogoutProviderOptions();
|
|
5299
|
+
}
|
|
5300
|
+
catch (error) {
|
|
5301
|
+
this.showError(`Could not read stored credentials: ${error instanceof Error ? error.message : String(error)}`);
|
|
5302
|
+
return;
|
|
5303
|
+
}
|
|
4598
5304
|
if (providerOptions.length === 0) {
|
|
4599
5305
|
this.showStatus("No stored credentials to remove. /logout only removes credentials saved by /login; environment variables and models.json config are unchanged.");
|
|
4600
5306
|
return;
|
|
@@ -4607,7 +5313,9 @@ export class InteractiveMode {
|
|
|
4607
5313
|
return;
|
|
4608
5314
|
}
|
|
4609
5315
|
try {
|
|
4610
|
-
await this.session.modelRuntime.logout(providerOption.id
|
|
5316
|
+
await this.session.modelRuntime.logout(providerOption.id, {
|
|
5317
|
+
signal: AbortSignal.timeout(15_000),
|
|
5318
|
+
});
|
|
4611
5319
|
await this.updateAvailableProviderCount();
|
|
4612
5320
|
const message = providerOption.authType === "oauth"
|
|
4613
5321
|
? `Logged out of ${providerOption.name}`
|
|
@@ -4615,7 +5323,10 @@ export class InteractiveMode {
|
|
|
4615
5323
|
this.showStatus(message);
|
|
4616
5324
|
}
|
|
4617
5325
|
catch (error) {
|
|
4618
|
-
|
|
5326
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
5327
|
+
this.showError(error instanceof CredentialSynchronizationError
|
|
5328
|
+
? `Credentials removed for ${providerOption.name}, but local model state could not be synchronized: ${message}`
|
|
5329
|
+
: `Logout failed: ${message}`);
|
|
4619
5330
|
}
|
|
4620
5331
|
}, () => {
|
|
4621
5332
|
done();
|
|
@@ -4625,54 +5336,98 @@ export class InteractiveMode {
|
|
|
4625
5336
|
});
|
|
4626
5337
|
}
|
|
4627
5338
|
async completeProviderAuthentication(providerId, providerName, authType, previousModel) {
|
|
4628
|
-
await this.session.modelRuntime.getAvailable();
|
|
4629
5339
|
const actionLabel = authType === "oauth" ? `Logged in to ${providerName}` : `Saved API key for ${providerName}`;
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
5340
|
+
const session = this.session;
|
|
5341
|
+
// Dynamic catalogs may be empty until the first authenticated network refresh.
|
|
5342
|
+
const deferSelection = isUnknownModel(previousModel) &&
|
|
5343
|
+
hasDefaultModelProvider(providerId) &&
|
|
5344
|
+
!session.modelRuntime
|
|
5345
|
+
.getAvailableSnapshot()
|
|
5346
|
+
.some((model) => model.provider === providerId && model.id === defaultModelPerProvider[providerId]);
|
|
5347
|
+
const finishAuthentication = async () => {
|
|
5348
|
+
let selectedModel;
|
|
5349
|
+
let selectionError;
|
|
5350
|
+
if (isUnknownModel(previousModel)) {
|
|
5351
|
+
const availableModels = this.session.modelRuntime.getAvailableSnapshot();
|
|
5352
|
+
const providerModels = availableModels.filter((model) => model.provider === providerId);
|
|
5353
|
+
// Matches LLAMA_PROVIDER_ID from extensions/llama/provider.ts; kept inline to avoid coupling interactive mode to the built-in extension.
|
|
5354
|
+
if (providerId === "llama.cpp") {
|
|
5355
|
+
selectionError = llamaCppPostLoginGuidance(actionLabel, providerModels.length);
|
|
5356
|
+
}
|
|
5357
|
+
else if (!hasDefaultModelProvider(providerId)) {
|
|
5358
|
+
selectionError = `${actionLabel}, but no default model is configured for provider "${providerId}". Use /model to select a model.`;
|
|
5359
|
+
}
|
|
5360
|
+
else if (providerModels.length === 0) {
|
|
5361
|
+
selectionError = `${actionLabel}, but no models are available for that provider. Use /model to select a model.`;
|
|
5362
|
+
}
|
|
5363
|
+
else {
|
|
5364
|
+
const defaultModelId = defaultModelPerProvider[providerId];
|
|
5365
|
+
// Radius catalogs vary by account; prefer balanced, then use catalog order.
|
|
5366
|
+
selectedModel =
|
|
5367
|
+
providerModels.find((model) => model.id === defaultModelId) ??
|
|
5368
|
+
(providerId === "radius" ? providerModels[0] : undefined);
|
|
5369
|
+
if (!selectedModel) {
|
|
5370
|
+
selectionError = `${actionLabel}, but its default model "${defaultModelId}" is not available. Use /model to select a model.`;
|
|
5371
|
+
}
|
|
5372
|
+
else {
|
|
5373
|
+
try {
|
|
5374
|
+
await this.session.setModel(selectedModel, { persist: true });
|
|
5375
|
+
}
|
|
5376
|
+
catch (error) {
|
|
5377
|
+
selectedModel = undefined;
|
|
5378
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
5379
|
+
selectionError = `${actionLabel}, but selecting its default model failed: ${errorMessage}. Use /model to select a model.`;
|
|
5380
|
+
}
|
|
5381
|
+
}
|
|
5382
|
+
}
|
|
4637
5383
|
}
|
|
4638
|
-
|
|
4639
|
-
|
|
5384
|
+
await this.updateAvailableProviderCount();
|
|
5385
|
+
this.footer.invalidate();
|
|
5386
|
+
this.updateEditorBorderColor();
|
|
5387
|
+
if (selectedModel) {
|
|
5388
|
+
this.showStatus(`${actionLabel}. Selected ${selectedModel.id}. Credentials saved to ${getAuthPath()}`);
|
|
5389
|
+
void this.maybeWarnAboutAnthropicSubscriptionAuth(selectedModel);
|
|
5390
|
+
this.checkDaxnutsEasterEgg(selectedModel);
|
|
4640
5391
|
}
|
|
4641
5392
|
else {
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
selectionError = `${actionLabel}, but its default model "${defaultModelId}" is not available. Use /model to select a model.`;
|
|
5393
|
+
this.showStatus(`${actionLabel}. Credentials saved to ${getAuthPath()}`);
|
|
5394
|
+
if (selectionError) {
|
|
5395
|
+
this.showError(selectionError);
|
|
4646
5396
|
}
|
|
4647
5397
|
else {
|
|
4648
|
-
|
|
4649
|
-
await this.session.setModel(selectedModel);
|
|
4650
|
-
}
|
|
4651
|
-
catch (error) {
|
|
4652
|
-
selectedModel = undefined;
|
|
4653
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
4654
|
-
selectionError = `${actionLabel}, but selecting its default model failed: ${errorMessage}. Use /model to select a model.`;
|
|
4655
|
-
}
|
|
5398
|
+
void this.maybeWarnAboutAnthropicSubscriptionAuth();
|
|
4656
5399
|
}
|
|
4657
5400
|
}
|
|
4658
|
-
}
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
this.updateEditorBorderColor();
|
|
4662
|
-
if (selectedModel) {
|
|
4663
|
-
this.showStatus(`${actionLabel}. Selected ${selectedModel.id}. Credentials saved to ${getAuthPath()}`);
|
|
4664
|
-
void this.maybeWarnAboutAnthropicSubscriptionAuth(selectedModel);
|
|
4665
|
-
this.checkDaxnutsEasterEgg(selectedModel);
|
|
5401
|
+
};
|
|
5402
|
+
if (deferSelection) {
|
|
5403
|
+
this.showStatus(`${actionLabel}. Credentials saved to ${getAuthPath()}. Refreshing model catalog…`);
|
|
4666
5404
|
}
|
|
4667
5405
|
else {
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
5406
|
+
await finishAuthentication();
|
|
5407
|
+
}
|
|
5408
|
+
const controller = new AbortController();
|
|
5409
|
+
const timeout = setTimeout(() => controller.abort(), 15_000);
|
|
5410
|
+
void session.modelRuntime
|
|
5411
|
+
.refresh({ providers: [providerId], signal: controller.signal })
|
|
5412
|
+
.then(async (result) => {
|
|
5413
|
+
if (result.aborted) {
|
|
5414
|
+
this.showWarning(`${actionLabel}, but its model catalog refresh timed out; using cached models.`);
|
|
4671
5415
|
}
|
|
4672
|
-
else {
|
|
4673
|
-
|
|
5416
|
+
else if (result.errors.size > 0) {
|
|
5417
|
+
this.showWarning(`${actionLabel}, but its model catalog could not be refreshed; using cached models.`);
|
|
4674
5418
|
}
|
|
4675
|
-
|
|
5419
|
+
// Do not replace a model or session selected while the refresh was running.
|
|
5420
|
+
if (deferSelection && this.session === session && session.model === previousModel) {
|
|
5421
|
+
await finishAuthentication();
|
|
5422
|
+
}
|
|
5423
|
+
this.updateAvailableProviderCount();
|
|
5424
|
+
this.footer.invalidate();
|
|
5425
|
+
this.ui.requestRender();
|
|
5426
|
+
})
|
|
5427
|
+
.catch((error) => {
|
|
5428
|
+
this.showWarning(`${actionLabel}, but its model catalog could not be refreshed: ${error instanceof Error ? error.message : String(error)}`);
|
|
5429
|
+
})
|
|
5430
|
+
.finally(() => clearTimeout(timeout));
|
|
4676
5431
|
}
|
|
4677
5432
|
showAmbientAuthDialog(providerOption) {
|
|
4678
5433
|
const restoreEditor = () => {
|
|
@@ -4682,7 +5437,7 @@ export class InteractiveMode {
|
|
|
4682
5437
|
this.ui.requestRender();
|
|
4683
5438
|
};
|
|
4684
5439
|
const dialog = new LoginDialogComponent(this.ui, providerOption.id, () => restoreEditor(), providerOption.name, `${providerOption.name} setup`);
|
|
4685
|
-
dialog.showInfo(`${providerOption.method?.name ?? "Authentication"} is configured outside
|
|
5440
|
+
dialog.showInfo(`${providerOption.method?.name ?? "Authentication"} is configured outside ${APP_NAME}.`, [], true);
|
|
4686
5441
|
this.editorContainer.clear();
|
|
4687
5442
|
this.editorContainer.addChild(dialog);
|
|
4688
5443
|
this.ui.setFocus(dialog);
|
|
@@ -4718,7 +5473,10 @@ export class InteractiveMode {
|
|
|
4718
5473
|
catch (error) {
|
|
4719
5474
|
restoreEditor();
|
|
4720
5475
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
4721
|
-
if (
|
|
5476
|
+
if (error instanceof CredentialSynchronizationError) {
|
|
5477
|
+
this.showError(`Saved API key for ${providerName}, but local model state could not be synchronized: ${errorMsg}`);
|
|
5478
|
+
}
|
|
5479
|
+
else if (errorMsg !== "Login cancelled") {
|
|
4722
5480
|
this.showError(`Failed to save API key for ${providerName}: ${errorMsg}`);
|
|
4723
5481
|
}
|
|
4724
5482
|
}
|
|
@@ -4798,7 +5556,7 @@ export class InteractiveMode {
|
|
|
4798
5556
|
signal: dialog.signal,
|
|
4799
5557
|
prompt: (prompt) => this.showAuthPrompt(dialog, prompt),
|
|
4800
5558
|
notify: (event) => this.notifyAuthDialog(dialog, event),
|
|
4801
|
-
});
|
|
5559
|
+
}, { getDeviceId: () => this.settingsManager.getOrCreateDeviceId() });
|
|
4802
5560
|
}
|
|
4803
5561
|
async showLoginDialog(providerId, providerName) {
|
|
4804
5562
|
const previousModel = this.session.model;
|
|
@@ -4821,7 +5579,10 @@ export class InteractiveMode {
|
|
|
4821
5579
|
catch (error) {
|
|
4822
5580
|
restoreEditor();
|
|
4823
5581
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
4824
|
-
if (
|
|
5582
|
+
if (error instanceof CredentialSynchronizationError) {
|
|
5583
|
+
this.showError(`Logged in to ${providerName}, but local model state could not be synchronized: ${errorMsg}`);
|
|
5584
|
+
}
|
|
5585
|
+
else if (errorMsg !== "Login cancelled") {
|
|
4825
5586
|
this.showError(`Failed to login to ${providerName}: ${errorMsg}`);
|
|
4826
5587
|
}
|
|
4827
5588
|
}
|
|
@@ -4843,7 +5604,7 @@ export class InteractiveMode {
|
|
|
4843
5604
|
const borderColor = (s) => theme.fg("border", s);
|
|
4844
5605
|
reloadBox.addChild(new DynamicBorder(borderColor));
|
|
4845
5606
|
reloadBox.addChild(new Spacer(1));
|
|
4846
|
-
reloadBox.addChild(new
|
|
5607
|
+
reloadBox.addChild(new ThemedText(() => theme.fg("muted", "Reloading keybindings, extensions, skills, prompts, themes, and context files..."), 1, 0));
|
|
4847
5608
|
reloadBox.addChild(new Spacer(1));
|
|
4848
5609
|
reloadBox.addChild(new DynamicBorder(borderColor));
|
|
4849
5610
|
const previousEditor = this.editor;
|
|
@@ -4872,28 +5633,14 @@ export class InteractiveMode {
|
|
|
4872
5633
|
try {
|
|
4873
5634
|
await this.session.reload({ beforeSessionStart: restoreChatBeforeSessionStart });
|
|
4874
5635
|
restoreChatBeforeSessionStart();
|
|
4875
|
-
configureHttpDispatcher(this.settingsManager.getHttpIdleTimeoutMs());
|
|
4876
5636
|
this.keybindings.reload();
|
|
4877
5637
|
const activeHeader = this.customHeader ?? this.builtInHeader;
|
|
4878
5638
|
if (isExpandable(activeHeader)) {
|
|
4879
5639
|
activeHeader.setExpanded(this.toolOutputExpanded);
|
|
4880
5640
|
}
|
|
4881
5641
|
setRegisteredThemes(this.session.resourceLoader.getThemes().themes);
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
const autocompleteMaxVisible = this.settingsManager.getAutocompleteMaxVisible();
|
|
4885
|
-
this.defaultEditor.setPaddingX(editorPaddingX);
|
|
4886
|
-
this.defaultEditor.setAutocompleteMaxVisible(autocompleteMaxVisible);
|
|
4887
|
-
if (this.editor !== this.defaultEditor) {
|
|
4888
|
-
this.editor.setPaddingX?.(editorPaddingX);
|
|
4889
|
-
this.editor.setAutocompleteMaxVisible?.(autocompleteMaxVisible);
|
|
4890
|
-
}
|
|
4891
|
-
this.ui.setShowHardwareCursor(this.settingsManager.getShowHardwareCursor());
|
|
4892
|
-
const clearOnShrink = this.settingsManager.getClearOnShrink();
|
|
4893
|
-
this.ui.setClearOnShrink(clearOnShrink);
|
|
4894
|
-
if (!clearOnShrink && !this.activeStatusIndicator) {
|
|
4895
|
-
this.statusContainer.clear();
|
|
4896
|
-
}
|
|
5642
|
+
this.applyRuntimeSettings();
|
|
5643
|
+
this.themeController.applyFromSettings();
|
|
4897
5644
|
this.setupAutocompleteProvider();
|
|
4898
5645
|
const runner = this.session.extensionRunner;
|
|
4899
5646
|
this.setupExtensionShortcuts(runner);
|
|
@@ -4927,7 +5674,9 @@ export class InteractiveMode {
|
|
|
4927
5674
|
this.showStatus(`Session exported to: ${filePath}`);
|
|
4928
5675
|
}
|
|
4929
5676
|
else {
|
|
4930
|
-
const filePath = await this.session.exportToHtml(outputPath
|
|
5677
|
+
const filePath = await this.session.exportToHtml(outputPath, {
|
|
5678
|
+
themeName: theme.name,
|
|
5679
|
+
});
|
|
4931
5680
|
this.showStatus(`Session exported to: ${filePath}`);
|
|
4932
5681
|
}
|
|
4933
5682
|
}
|
|
@@ -5003,93 +5752,34 @@ export class InteractiveMode {
|
|
|
5003
5752
|
}
|
|
5004
5753
|
}
|
|
5005
5754
|
async handleShareCommand() {
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
}
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5755
|
+
await shareSession({
|
|
5756
|
+
session: this.session,
|
|
5757
|
+
ui: this.ui,
|
|
5758
|
+
editorContainer: this.editorContainer,
|
|
5759
|
+
editor: this.editor,
|
|
5760
|
+
showStatus: (message) => this.showStatus(message),
|
|
5761
|
+
showError: (message) => this.showError(message),
|
|
5762
|
+
});
|
|
5763
|
+
}
|
|
5764
|
+
async handleBugCommand(hint) {
|
|
5765
|
+
await reportBug({
|
|
5766
|
+
session: this.session,
|
|
5767
|
+
ui: this.ui,
|
|
5768
|
+
editorContainer: this.editorContainer,
|
|
5769
|
+
editor: this.editor,
|
|
5770
|
+
keybindings: this.keybindings,
|
|
5771
|
+
showStatus: (message) => this.showStatus(message),
|
|
5772
|
+
showError: (message) => this.showError(message),
|
|
5773
|
+
}, hint);
|
|
5774
|
+
}
|
|
5775
|
+
async handleCopyCommand(options = {}) {
|
|
5776
|
+
if (options.preferSelection &&
|
|
5777
|
+
this.ui instanceof TuiAltScreen &&
|
|
5778
|
+
!this.ui.getCopyOnSelect() &&
|
|
5779
|
+
this.ui.hasActiveSelection()) {
|
|
5780
|
+
await this.ui.copyActiveSelectionToClipboard();
|
|
5025
5781
|
return;
|
|
5026
5782
|
}
|
|
5027
|
-
// Show cancellable loader, replacing the editor
|
|
5028
|
-
const loader = new BorderedLoader(this.ui, theme, "Creating gist...");
|
|
5029
|
-
this.editorContainer.clear();
|
|
5030
|
-
this.editorContainer.addChild(loader);
|
|
5031
|
-
this.ui.setFocus(loader);
|
|
5032
|
-
this.ui.requestRender();
|
|
5033
|
-
const restoreEditor = () => {
|
|
5034
|
-
loader.dispose();
|
|
5035
|
-
this.editorContainer.clear();
|
|
5036
|
-
this.editorContainer.addChild(this.editor);
|
|
5037
|
-
this.ui.setFocus(this.editor);
|
|
5038
|
-
try {
|
|
5039
|
-
fs.unlinkSync(tmpFile);
|
|
5040
|
-
}
|
|
5041
|
-
catch {
|
|
5042
|
-
// Ignore cleanup errors
|
|
5043
|
-
}
|
|
5044
|
-
};
|
|
5045
|
-
// Create a secret gist asynchronously
|
|
5046
|
-
let proc = null;
|
|
5047
|
-
loader.onAbort = () => {
|
|
5048
|
-
proc?.kill();
|
|
5049
|
-
restoreEditor();
|
|
5050
|
-
this.showStatus("Share cancelled");
|
|
5051
|
-
};
|
|
5052
|
-
try {
|
|
5053
|
-
const result = await new Promise((resolve) => {
|
|
5054
|
-
proc = spawn("gh", ["gist", "create", "--public=false", tmpFile]);
|
|
5055
|
-
let stdout = "";
|
|
5056
|
-
let stderr = "";
|
|
5057
|
-
proc.stdout?.on("data", (data) => {
|
|
5058
|
-
stdout += data.toString();
|
|
5059
|
-
});
|
|
5060
|
-
proc.stderr?.on("data", (data) => {
|
|
5061
|
-
stderr += data.toString();
|
|
5062
|
-
});
|
|
5063
|
-
proc.on("close", (code) => resolve({ stdout, stderr, code }));
|
|
5064
|
-
});
|
|
5065
|
-
if (loader.signal.aborted)
|
|
5066
|
-
return;
|
|
5067
|
-
restoreEditor();
|
|
5068
|
-
if (result.code !== 0) {
|
|
5069
|
-
const errorMsg = result.stderr?.trim() || "Unknown error";
|
|
5070
|
-
this.showError(`Failed to create gist: ${errorMsg}`);
|
|
5071
|
-
return;
|
|
5072
|
-
}
|
|
5073
|
-
// Extract gist ID from the URL returned by gh
|
|
5074
|
-
// gh returns something like: https://gist.github.com/username/GIST_ID
|
|
5075
|
-
const gistUrl = result.stdout?.trim();
|
|
5076
|
-
const gistId = gistUrl?.split("/").pop();
|
|
5077
|
-
if (!gistId) {
|
|
5078
|
-
this.showError("Failed to parse gist ID from gh output");
|
|
5079
|
-
return;
|
|
5080
|
-
}
|
|
5081
|
-
// Create the preview URL
|
|
5082
|
-
const previewUrl = getShareViewerUrl(gistId);
|
|
5083
|
-
this.showStatus(`Share URL: ${previewUrl}\nGist: ${gistUrl}`);
|
|
5084
|
-
}
|
|
5085
|
-
catch (error) {
|
|
5086
|
-
if (!loader.signal.aborted) {
|
|
5087
|
-
restoreEditor();
|
|
5088
|
-
this.showError(`Failed to create gist: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
5089
|
-
}
|
|
5090
|
-
}
|
|
5091
|
-
}
|
|
5092
|
-
async handleCopyCommand() {
|
|
5093
5783
|
const text = this.session.getLastAssistantText();
|
|
5094
5784
|
if (!text) {
|
|
5095
5785
|
this.showError("No agent messages to copy yet.");
|
|
@@ -5097,7 +5787,12 @@ export class InteractiveMode {
|
|
|
5097
5787
|
}
|
|
5098
5788
|
try {
|
|
5099
5789
|
await copyToClipboard(text);
|
|
5100
|
-
|
|
5790
|
+
if (options.flashConfirmation && this.ui instanceof TuiAltScreen) {
|
|
5791
|
+
this.ui.flash("Copied!");
|
|
5792
|
+
}
|
|
5793
|
+
else {
|
|
5794
|
+
this.showStatus("Copied last agent message to clipboard");
|
|
5795
|
+
}
|
|
5101
5796
|
}
|
|
5102
5797
|
catch (error) {
|
|
5103
5798
|
this.showError(error instanceof Error ? error.message : String(error));
|
|
@@ -5109,7 +5804,7 @@ export class InteractiveMode {
|
|
|
5109
5804
|
const currentName = this.sessionManager.getSessionName();
|
|
5110
5805
|
if (currentName) {
|
|
5111
5806
|
this.chatContainer.addChild(new Spacer(1));
|
|
5112
|
-
this.chatContainer.addChild(new
|
|
5807
|
+
this.chatContainer.addChild(new ThemedText(() => theme.fg("dim", `Session name: ${currentName}`), 1, 0));
|
|
5113
5808
|
}
|
|
5114
5809
|
else {
|
|
5115
5810
|
this.showWarning("Usage: /name <name>");
|
|
@@ -5123,7 +5818,8 @@ export class InteractiveMode {
|
|
|
5123
5818
|
this.showWarning(`Session name was normalized from ${JSON.stringify(name)} to ${JSON.stringify(sessionName)}`);
|
|
5124
5819
|
}
|
|
5125
5820
|
this.chatContainer.addChild(new Spacer(1));
|
|
5126
|
-
|
|
5821
|
+
const displayName = sessionName ?? name;
|
|
5822
|
+
this.chatContainer.addChild(new ThemedText(() => theme.fg("dim", `Session name set: ${displayName}`), 1, 0));
|
|
5127
5823
|
this.ui.requestRender();
|
|
5128
5824
|
}
|
|
5129
5825
|
handleSessionCommand() {
|
|
@@ -5135,52 +5831,69 @@ export class InteractiveMode {
|
|
|
5135
5831
|
// resolves to a concrete responseModel). Usage without model attribution is
|
|
5136
5832
|
// grouped separately so the breakdown reconciles with the session total.
|
|
5137
5833
|
const usageBreakdown = getUsageCostBreakdown(entries);
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
const
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5834
|
+
// Snapshot the stats; the text is built on demand so it follows theme changes.
|
|
5835
|
+
const cacheWarmingStatus = this.session.cacheWarmingStatus;
|
|
5836
|
+
const cacheWarmingMode = this.settingsManager.getCacheWarmingMode();
|
|
5837
|
+
const model = this.session.model;
|
|
5838
|
+
const selectedModelKey = `${model?.provider}/${model?.id}`;
|
|
5839
|
+
const renderInfo = () => {
|
|
5840
|
+
let info = `${theme.bold("Session Info")}\n\n`;
|
|
5841
|
+
if (sessionName) {
|
|
5842
|
+
info += `${theme.fg("dim", "Name:")} ${sessionName}\n`;
|
|
5843
|
+
}
|
|
5844
|
+
info += `${theme.fg("dim", "File:")} ${stats.sessionFile ?? "In-memory"}\n`;
|
|
5845
|
+
info += `${theme.fg("dim", "ID:")} ${stats.sessionId}\n\n`;
|
|
5846
|
+
info += `${theme.bold("Messages")}\n`;
|
|
5847
|
+
info += `${theme.fg("dim", "Total:")} ${stats.totalMessages}\n`;
|
|
5848
|
+
info += `${theme.fg("dim", "User:")} ${stats.userMessages}\n`;
|
|
5849
|
+
info += `${theme.fg("dim", "Assistant:")} ${stats.assistantMessages}\n`;
|
|
5850
|
+
info += `${theme.fg("dim", "Tools:")} ${stats.toolCalls} calls, ${stats.toolResults} results\n\n`;
|
|
5851
|
+
info += `${theme.bold("Tokens")}\n`;
|
|
5852
|
+
// "Input" is the full prompt volume. With cache activity, split it into
|
|
5853
|
+
// cached (served from cache) vs uncached (everything else) - the only
|
|
5854
|
+
// provider-independent split. Cache writes, where reported, are a detail
|
|
5855
|
+
// of the uncached portion.
|
|
5856
|
+
const { input, cacheRead, cacheWrite } = stats.tokens;
|
|
5857
|
+
const promptTokens = input + cacheRead + cacheWrite;
|
|
5858
|
+
info += `${theme.fg("dim", "Input:")} ${promptTokens.toLocaleString()}\n`;
|
|
5859
|
+
if (promptTokens > 0 && (cacheRead > 0 || cacheWrite > 0)) {
|
|
5860
|
+
const hitRate = theme.fg("dim", `(${((cacheRead / promptTokens) * 100).toFixed(1)}%)`);
|
|
5861
|
+
info += ` ${theme.fg("dim", "Cached:")} ${cacheRead.toLocaleString()} ${hitRate}\n`;
|
|
5862
|
+
const written = cacheWrite > 0 ? ` ${theme.fg("dim", `(${cacheWrite.toLocaleString()} written to cache)`)}` : "";
|
|
5863
|
+
info += ` ${theme.fg("dim", "Uncached:")} ${(input + cacheWrite).toLocaleString()}${written}\n`;
|
|
5864
|
+
}
|
|
5865
|
+
info += `${theme.fg("dim", "Output:")} ${stats.tokens.output.toLocaleString()}\n`;
|
|
5866
|
+
info += `${theme.fg("dim", "Total:")} ${stats.tokens.total.toLocaleString()}\n`;
|
|
5867
|
+
info += `\n${theme.bold("Cache Warming")}\n`;
|
|
5868
|
+
info += `${theme.fg("dim", "Mode:")} ${cacheWarmingMode}\n`;
|
|
5869
|
+
info += `${theme.fg("dim", "Status:")} ${cacheWarmingStatus ? formatCacheWarmingStatus(cacheWarmingStatus) : "Inactive (cache warming unavailable)"}\n`;
|
|
5870
|
+
const decision = cacheWarmingStatus?.decision;
|
|
5871
|
+
if (decision?.economicsAvailable) {
|
|
5872
|
+
info += `${theme.fg("dim", "Cache miss penalty:")} $${decision.missCost.toFixed(3)}\n`;
|
|
5873
|
+
info += `${theme.fg("dim", "Refresh cost:")} $${decision.warmCost.toFixed(3)}\n`;
|
|
5874
|
+
}
|
|
5875
|
+
if (stats.cost > 0 || cacheWaste.missedTokens > 0) {
|
|
5876
|
+
info += `\n${theme.bold("Cost")}\n`;
|
|
5877
|
+
info += `${theme.fg("dim", "Total:")} $${stats.cost.toFixed(3)}`;
|
|
5878
|
+
// A single entry repeats the total, unless it names a model other than the selected one.
|
|
5879
|
+
if (usageBreakdown.length > 1 || usageBreakdown[0]?.key !== selectedModelKey) {
|
|
5880
|
+
for (const entry of usageBreakdown) {
|
|
5881
|
+
info += `\n ${theme.fg("dim", `${entry.key}:`)} $${entry.cost.toFixed(3)} ${theme.fg("dim", `(${formatTokens(entry.tokens)} tokens)`)}`;
|
|
5882
|
+
}
|
|
5883
|
+
}
|
|
5884
|
+
if (cacheWaste.missedTokens > 0) {
|
|
5885
|
+
const missLabel = cacheWaste.missCount === 1 ? "1 miss" : `${cacheWaste.missCount} misses`;
|
|
5886
|
+
const detail = `${cacheWaste.missedTokens.toLocaleString()} tokens, ${missLabel}`;
|
|
5887
|
+
info +=
|
|
5888
|
+
cacheWaste.missedCost >= 0.0001
|
|
5889
|
+
? `\n${theme.fg("dim", "Cache Re-billed:")} $${cacheWaste.missedCost.toFixed(3)} ${theme.fg("dim", `(${detail})`)}`
|
|
5890
|
+
: `\n${theme.fg("dim", "Cache Re-billed:")} ${detail}`;
|
|
5171
5891
|
}
|
|
5172
5892
|
}
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
const detail = `${cacheWaste.missedTokens.toLocaleString()} tokens, ${missLabel}`;
|
|
5176
|
-
info +=
|
|
5177
|
-
cacheWaste.missedCost >= 0.0001
|
|
5178
|
-
? `\n${theme.fg("dim", "Cache Re-billed:")} $${cacheWaste.missedCost.toFixed(3)} ${theme.fg("dim", `(${detail})`)}`
|
|
5179
|
-
: `\n${theme.fg("dim", "Cache Re-billed:")} ${detail}`;
|
|
5180
|
-
}
|
|
5181
|
-
}
|
|
5893
|
+
return info;
|
|
5894
|
+
};
|
|
5182
5895
|
this.chatContainer.addChild(new Spacer(1));
|
|
5183
|
-
this.chatContainer.addChild(new
|
|
5896
|
+
this.chatContainer.addChild(new ThemedText(renderInfo, 1, 0));
|
|
5184
5897
|
this.ui.requestRender();
|
|
5185
5898
|
}
|
|
5186
5899
|
handleChangelogCommand() {
|
|
@@ -5194,7 +5907,7 @@ export class InteractiveMode {
|
|
|
5194
5907
|
: "No changelog entries found.";
|
|
5195
5908
|
this.chatContainer.addChild(new Spacer(1));
|
|
5196
5909
|
this.chatContainer.addChild(new DynamicBorder());
|
|
5197
|
-
this.chatContainer.addChild(new
|
|
5910
|
+
this.chatContainer.addChild(new ThemedText(() => theme.bold(theme.fg("accent", "What's New")), 1, 0));
|
|
5198
5911
|
this.chatContainer.addChild(new Spacer(1));
|
|
5199
5912
|
this.chatContainer.addChild(new Markdown(changelogMarkdown, 1, 1, this.getMarkdownThemeWithSettings()));
|
|
5200
5913
|
this.chatContainer.addChild(new DynamicBorder());
|
|
@@ -5293,10 +6006,10 @@ ${cycleContextWindow ? `| \`${cycleContextWindow}\` | Cycle context window |\n`
|
|
|
5293
6006
|
| \`${expandTools}\` | Toggle tool output expansion |
|
|
5294
6007
|
| \`${toggleThinking}\` | Toggle thinking block visibility |
|
|
5295
6008
|
| \`${externalEditor}\` | Edit message in external editor |
|
|
5296
|
-
| \`${copyMessage}\` | Copy last assistant message |
|
|
6009
|
+
| \`${copyMessage}\` | Copy selection or last assistant message |
|
|
5297
6010
|
| \`${followUp}\` | Queue follow-up message |
|
|
5298
6011
|
| \`${dequeue}\` | Restore queued messages |
|
|
5299
|
-
| \`${pasteImage}\` | Paste
|
|
6012
|
+
| \`${pasteImage}\` | Paste files on macOS, images, or text from clipboard |
|
|
5300
6013
|
| \`/\` | Slash commands |
|
|
5301
6014
|
| \`!\` | Run bash command |
|
|
5302
6015
|
| \`!!\` | Run bash command (excluded from context) |
|
|
@@ -5318,7 +6031,7 @@ ${cycleContextWindow ? `| \`${cycleContextWindow}\` | Cycle context window |\n`
|
|
|
5318
6031
|
}
|
|
5319
6032
|
this.chatContainer.addChild(new Spacer(1));
|
|
5320
6033
|
this.chatContainer.addChild(new DynamicBorder());
|
|
5321
|
-
this.chatContainer.addChild(new
|
|
6034
|
+
this.chatContainer.addChild(new ThemedText(() => theme.bold(theme.fg("accent", "Keyboard Shortcuts")), 1, 0));
|
|
5322
6035
|
this.chatContainer.addChild(new Spacer(1));
|
|
5323
6036
|
this.chatContainer.addChild(new Markdown(hotkeys.trim(), 1, 1, this.getMarkdownThemeWithSettings()));
|
|
5324
6037
|
this.chatContainer.addChild(new DynamicBorder());
|
|
@@ -5332,7 +6045,7 @@ ${cycleContextWindow ? `| \`${cycleContextWindow}\` | Cycle context window |\n`
|
|
|
5332
6045
|
return;
|
|
5333
6046
|
}
|
|
5334
6047
|
this.chatContainer.addChild(new Spacer(1));
|
|
5335
|
-
this.chatContainer.addChild(new
|
|
6048
|
+
this.chatContainer.addChild(new ThemedText(() => theme.fg("accent", "✓ New session started"), 1, 1));
|
|
5336
6049
|
this.ui.requestRender();
|
|
5337
6050
|
}
|
|
5338
6051
|
catch (error) {
|
|
@@ -5363,7 +6076,7 @@ ${cycleContextWindow ? `| \`${cycleContextWindow}\` | Cycle context window |\n`
|
|
|
5363
6076
|
fs.mkdirSync(path.dirname(debugLogPath), { recursive: true });
|
|
5364
6077
|
fs.writeFileSync(debugLogPath, debugData);
|
|
5365
6078
|
this.chatContainer.addChild(new Spacer(1));
|
|
5366
|
-
this.chatContainer.addChild(new
|
|
6079
|
+
this.chatContainer.addChild(new ThemedText(() => `${theme.fg("accent", "✓ Debug log written")}\n${theme.fg("muted", debugLogPath)}`, 1, 1));
|
|
5367
6080
|
this.ui.requestRender();
|
|
5368
6081
|
}
|
|
5369
6082
|
handleArminSaysHi() {
|
|
@@ -5389,12 +6102,19 @@ ${cycleContextWindow ? `| \`${cycleContextWindow}\` | Cycle context window |\n`
|
|
|
5389
6102
|
async handleBashCommand(command, excludeFromContext = false) {
|
|
5390
6103
|
const extensionRunner = this.session.extensionRunner;
|
|
5391
6104
|
// Emit user_bash event to let extensions intercept
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
6105
|
+
let eventResult;
|
|
6106
|
+
try {
|
|
6107
|
+
eventResult = await extensionRunner.emitUserBash({
|
|
6108
|
+
type: "user_bash",
|
|
6109
|
+
command,
|
|
6110
|
+
excludeFromContext,
|
|
6111
|
+
cwd: this.sessionManager.getCwd(),
|
|
6112
|
+
});
|
|
6113
|
+
}
|
|
6114
|
+
catch {
|
|
6115
|
+
// The extension runner already reported the error. Do not fall back to local execution.
|
|
6116
|
+
return;
|
|
6117
|
+
}
|
|
5398
6118
|
// If extension returned a full result, use it directly
|
|
5399
6119
|
if (eventResult?.result) {
|
|
5400
6120
|
const result = eventResult.result;
|
|
@@ -5460,7 +6180,8 @@ ${cycleContextWindow ? `| \`${cycleContextWindow}\` | Cycle context window |\n`
|
|
|
5460
6180
|
// Ignore, will be emitted as an event
|
|
5461
6181
|
}
|
|
5462
6182
|
}
|
|
5463
|
-
stop() {
|
|
6183
|
+
stop(fullscreenExitOutput = this.settingsManager.getFullscreenExitOutput()) {
|
|
6184
|
+
this.disposeActiveSelector();
|
|
5464
6185
|
if (this.settingsManager.getShowTerminalProgress()) {
|
|
5465
6186
|
this.ui.terminal.setProgress(false);
|
|
5466
6187
|
}
|
|
@@ -5473,7 +6194,7 @@ ${cycleContextWindow ? `| \`${cycleContextWindow}\` | Cycle context window |\n`
|
|
|
5473
6194
|
this.unsubscribe();
|
|
5474
6195
|
}
|
|
5475
6196
|
if (this.isInitialized) {
|
|
5476
|
-
this.
|
|
6197
|
+
this.stopInteractiveTui(fullscreenExitOutput);
|
|
5477
6198
|
this.isInitialized = false;
|
|
5478
6199
|
}
|
|
5479
6200
|
this.unregisterSignalHandlers();
|