@prometheus-ai/agent 0.5.0
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 +7 -0
- package/README.md +36 -0
- package/dist/types/async/index.d.ts +2 -0
- package/dist/types/async/job-manager.d.ts +88 -0
- package/dist/types/async/support.d.ts +2 -0
- package/dist/types/auto-thinking/classifier.d.ts +35 -0
- package/dist/types/autoresearch/dashboard.d.ts +4 -0
- package/dist/types/autoresearch/git.d.ts +36 -0
- package/dist/types/autoresearch/helpers.d.ts +24 -0
- package/dist/types/autoresearch/index.d.ts +2 -0
- package/dist/types/autoresearch/state.d.ts +17 -0
- package/dist/types/autoresearch/storage.d.ts +142 -0
- package/dist/types/autoresearch/tools/init-experiment.d.ts +31 -0
- package/dist/types/autoresearch/tools/log-experiment.d.ts +23 -0
- package/dist/types/autoresearch/tools/run-experiment.d.ts +8 -0
- package/dist/types/autoresearch/tools/update-notes.d.ts +12 -0
- package/dist/types/autoresearch/types.d.ts +154 -0
- package/dist/types/capability/context-file.d.ts +30 -0
- package/dist/types/capability/extension-module.d.ts +15 -0
- package/dist/types/capability/extension.d.ts +28 -0
- package/dist/types/capability/fs.d.ts +20 -0
- package/dist/types/capability/hook.d.ts +19 -0
- package/dist/types/capability/index.d.ts +80 -0
- package/dist/types/capability/instruction.d.ts +17 -0
- package/dist/types/capability/mcp.d.ts +45 -0
- package/dist/types/capability/prompt.d.ts +15 -0
- package/dist/types/capability/rule-buckets.d.ts +30 -0
- package/dist/types/capability/rule.d.ts +68 -0
- package/dist/types/capability/settings.d.ts +15 -0
- package/dist/types/capability/skill.d.ts +43 -0
- package/dist/types/capability/slash-command.d.ts +17 -0
- package/dist/types/capability/ssh.d.ts +23 -0
- package/dist/types/capability/system-prompt.d.ts +15 -0
- package/dist/types/capability/tool.d.ts +19 -0
- package/dist/types/capability/types.d.ts +158 -0
- package/dist/types/cli/agents-cli.d.ts +12 -0
- package/dist/types/cli/args.d.ts +55 -0
- package/dist/types/cli/auth-broker-cli.d.ts +25 -0
- package/dist/types/cli/auth-gateway-cli.d.ts +26 -0
- package/dist/types/cli/classify-install-target.d.ts +12 -0
- package/dist/types/cli/claude-trace-cli.d.ts +52 -0
- package/dist/types/cli/commands/init-xdg.d.ts +1 -0
- package/dist/types/cli/completion-gen.d.ts +80 -0
- package/dist/types/cli/config-cli.d.ts +22 -0
- package/dist/types/cli/dry-balance-cli.d.ts +104 -0
- package/dist/types/cli/extension-flags.d.ts +36 -0
- package/dist/types/cli/file-processor.d.ts +11 -0
- package/dist/types/cli/gateway-cli.d.ts +95 -0
- package/dist/types/cli/grep-cli.d.ts +17 -0
- package/dist/types/cli/grievances-cli.d.ts +37 -0
- package/dist/types/cli/initial-message.d.ts +17 -0
- package/dist/types/cli/list-models.d.ts +30 -0
- package/dist/types/cli/plugin-cli.d.ts +32 -0
- package/dist/types/cli/read-cli.d.ts +4 -0
- package/dist/types/cli/session-picker.d.ts +10 -0
- package/dist/types/cli/setup-cli.d.ts +24 -0
- package/dist/types/cli/shell-cli.d.ts +8 -0
- package/dist/types/cli/ssh-cli.d.ts +21 -0
- package/dist/types/cli/stats-cli.d.ts +17 -0
- package/dist/types/cli/tiny-models-cli.d.ts +9 -0
- package/dist/types/cli/update-cli.d.ts +106 -0
- package/dist/types/cli/web-search-cli.d.ts +20 -0
- package/dist/types/cli/worktree-cli.d.ts +26 -0
- package/dist/types/cli-commands.d.ts +19 -0
- package/dist/types/cli.d.ts +3 -0
- package/dist/types/commands/acp.d.ts +12 -0
- package/dist/types/commands/agents.d.ts +34 -0
- package/dist/types/commands/auth-broker.d.ts +54 -0
- package/dist/types/commands/auth-gateway.d.ts +35 -0
- package/dist/types/commands/commit.d.ts +27 -0
- package/dist/types/commands/complete.d.ts +6 -0
- package/dist/types/commands/completions.d.ts +13 -0
- package/dist/types/commands/config.d.ts +30 -0
- package/dist/types/commands/dry-balance.d.ts +31 -0
- package/dist/types/commands/gateway.d.ts +69 -0
- package/dist/types/commands/grep.d.ts +42 -0
- package/dist/types/commands/grievances.d.ts +40 -0
- package/dist/types/commands/install.d.ts +51 -0
- package/dist/types/commands/launch.d.ts +129 -0
- package/dist/types/commands/plugin.d.ts +52 -0
- package/dist/types/commands/read.d.ts +15 -0
- package/dist/types/commands/setup.d.ts +34 -0
- package/dist/types/commands/shell.d.ts +21 -0
- package/dist/types/commands/ssh.d.ts +48 -0
- package/dist/types/commands/stats.d.ts +25 -0
- package/dist/types/commands/tiny-models.d.ts +22 -0
- package/dist/types/commands/update.d.ts +20 -0
- package/dist/types/commands/web-search.d.ts +33 -0
- package/dist/types/commands/worktree.d.ts +34 -0
- package/dist/types/commit/agentic/agent.d.ts +31 -0
- package/dist/types/commit/agentic/fallback.d.ts +5 -0
- package/dist/types/commit/agentic/index.d.ts +2 -0
- package/dist/types/commit/agentic/state.d.ts +58 -0
- package/dist/types/commit/agentic/tools/analyze-file.d.ts +19 -0
- package/dist/types/commit/agentic/tools/git-file-diff.d.ts +10 -0
- package/dist/types/commit/agentic/tools/git-hunk.d.ts +9 -0
- package/dist/types/commit/agentic/tools/git-overview.d.ts +9 -0
- package/dist/types/commit/agentic/tools/index.d.ts +16 -0
- package/dist/types/commit/agentic/tools/propose-changelog.d.ts +28 -0
- package/dist/types/commit/agentic/tools/propose-commit.d.ts +36 -0
- package/dist/types/commit/agentic/tools/recent-commits.d.ts +7 -0
- package/dist/types/commit/agentic/tools/schemas.d.ts +27 -0
- package/dist/types/commit/agentic/tools/split-commit.d.ts +53 -0
- package/dist/types/commit/agentic/topo-sort.d.ts +4 -0
- package/dist/types/commit/agentic/trivial.d.ts +7 -0
- package/dist/types/commit/agentic/validation.d.ts +20 -0
- package/dist/types/commit/analysis/conventional.d.ts +22 -0
- package/dist/types/commit/analysis/index.d.ts +4 -0
- package/dist/types/commit/analysis/scope.d.ts +6 -0
- package/dist/types/commit/analysis/summary.d.ts +19 -0
- package/dist/types/commit/analysis/validation.d.ts +8 -0
- package/dist/types/commit/changelog/detect.d.ts +2 -0
- package/dist/types/commit/changelog/generate.d.ts +30 -0
- package/dist/types/commit/changelog/index.d.ts +30 -0
- package/dist/types/commit/changelog/parse.d.ts +2 -0
- package/dist/types/commit/cli.d.ts +3 -0
- package/dist/types/commit/git/diff.d.ts +5 -0
- package/dist/types/commit/index.d.ts +4 -0
- package/dist/types/commit/map-reduce/index.d.ts +28 -0
- package/dist/types/commit/map-reduce/map-phase.d.ts +17 -0
- package/dist/types/commit/map-reduce/reduce-phase.d.ts +13 -0
- package/dist/types/commit/map-reduce/utils.d.ts +2 -0
- package/dist/types/commit/message.d.ts +2 -0
- package/dist/types/commit/model-selection.d.ts +15 -0
- package/dist/types/commit/pipeline.d.ts +5 -0
- package/dist/types/commit/shared-llm.d.ts +54 -0
- package/dist/types/commit/types.d.ts +78 -0
- package/dist/types/commit/utils/exclusions.d.ts +4 -0
- package/dist/types/commit/utils.d.ts +20 -0
- package/dist/types/config/append-only-context-mode.d.ts +8 -0
- package/dist/types/config/config-file.d.ts +62 -0
- package/dist/types/config/file-lock.d.ts +29 -0
- package/dist/types/config/keybindings.d.ts +352 -0
- package/dist/types/config/model-equivalence.d.ts +24 -0
- package/dist/types/config/model-id-affixes.d.ts +10 -0
- package/dist/types/config/model-registry.d.ts +400 -0
- package/dist/types/config/model-resolver.d.ts +230 -0
- package/dist/types/config/models-config-schema.d.ts +523 -0
- package/dist/types/config/prompt-templates.d.ts +32 -0
- package/dist/types/config/resolve-config-value.d.ts +17 -0
- package/dist/types/config/settings-schema.d.ts +4352 -0
- package/dist/types/config/settings.d.ts +156 -0
- package/dist/types/config.d.ts +92 -0
- package/dist/types/cursor.d.ts +22 -0
- package/dist/types/dap/client.d.ts +38 -0
- package/dist/types/dap/config.d.ts +6 -0
- package/dist/types/dap/index.d.ts +4 -0
- package/dist/types/dap/session.d.ts +108 -0
- package/dist/types/dap/types.d.ts +524 -0
- package/dist/types/debug/index.d.ts +15 -0
- package/dist/types/debug/log-formatting.d.ts +4 -0
- package/dist/types/debug/log-viewer.d.ts +68 -0
- package/dist/types/debug/profiler.d.ts +24 -0
- package/dist/types/debug/protocol-probe.d.ts +38 -0
- package/dist/types/debug/raw-sse-buffer.d.ts +44 -0
- package/dist/types/debug/raw-sse.d.ts +18 -0
- package/dist/types/debug/report-bundle.d.ts +55 -0
- package/dist/types/debug/system-info.d.ts +26 -0
- package/dist/types/debug/terminal-info.d.ts +34 -0
- package/dist/types/discovery/agents-md.d.ts +1 -0
- package/dist/types/discovery/agents.d.ts +12 -0
- package/dist/types/discovery/builtin-defaults.d.ts +1 -0
- package/dist/types/discovery/builtin-rules/index.d.ts +7 -0
- package/dist/types/discovery/builtin.d.ts +1 -0
- package/dist/types/discovery/claude-plugins.d.ts +1 -0
- package/dist/types/discovery/claude.d.ts +1 -0
- package/dist/types/discovery/cline.d.ts +1 -0
- package/dist/types/discovery/codex.d.ts +1 -0
- package/dist/types/discovery/context-files.d.ts +17 -0
- package/dist/types/discovery/cursor.d.ts +16 -0
- package/dist/types/discovery/gemini.d.ts +1 -0
- package/dist/types/discovery/github.d.ts +1 -0
- package/dist/types/discovery/helpers.d.ts +269 -0
- package/dist/types/discovery/index.d.ts +53 -0
- package/dist/types/discovery/mcp-json.d.ts +1 -0
- package/dist/types/discovery/opencode.d.ts +1 -0
- package/dist/types/discovery/plugin-dir-roots.d.ts +15 -0
- package/dist/types/discovery/prometheus-extension-roots.d.ts +43 -0
- package/dist/types/discovery/prometheus-plugins.d.ts +1 -0
- package/dist/types/discovery/ssh.d.ts +1 -0
- package/dist/types/discovery/substitute-plugin-root.d.ts +1 -0
- package/dist/types/discovery/vscode.d.ts +1 -0
- package/dist/types/discovery/windsurf.d.ts +13 -0
- package/dist/types/edit/apply-patch/index.d.ts +35 -0
- package/dist/types/edit/apply-patch/parser.d.ts +34 -0
- package/dist/types/edit/diff.d.ts +59 -0
- package/dist/types/edit/file-snapshot-store.d.ts +40 -0
- package/dist/types/edit/hashline/block-resolver.d.ts +9 -0
- package/dist/types/edit/hashline/diff.d.ts +40 -0
- package/dist/types/edit/hashline/execute.d.ts +28 -0
- package/dist/types/edit/hashline/filesystem.d.ts +57 -0
- package/dist/types/edit/hashline/index.d.ts +5 -0
- package/dist/types/edit/hashline/params.d.ts +11 -0
- package/dist/types/edit/index.d.ts +62 -0
- package/dist/types/edit/modes/apply-patch.d.ts +24 -0
- package/dist/types/edit/modes/patch.d.ts +99 -0
- package/dist/types/edit/modes/replace.d.ts +142 -0
- package/dist/types/edit/normalize.d.ts +31 -0
- package/dist/types/edit/notebook.d.ts +23 -0
- package/dist/types/edit/read-file.d.ts +2 -0
- package/dist/types/edit/renderer.d.ts +109 -0
- package/dist/types/edit/streaming.d.ts +75 -0
- package/dist/types/eval/__tests__/agent-bridge.test.d.ts +1 -0
- package/dist/types/eval/__tests__/bridge-timeout.test.d.ts +1 -0
- package/dist/types/eval/__tests__/budget-bridge.test.d.ts +1 -0
- package/dist/types/eval/__tests__/idle-timeout.test.d.ts +1 -0
- package/dist/types/eval/__tests__/kernel-spawn.test.d.ts +1 -0
- package/dist/types/eval/__tests__/llm-bridge.test.d.ts +1 -0
- package/dist/types/eval/__tests__/shared-executors.test.d.ts +1 -0
- package/dist/types/eval/agent-bridge.d.ts +25 -0
- package/dist/types/eval/backend.d.ts +55 -0
- package/dist/types/eval/bridge-timeout.d.ts +27 -0
- package/dist/types/eval/budget-bridge.d.ts +29 -0
- package/dist/types/eval/concurrency-bridge.d.ts +26 -0
- package/dist/types/eval/idle-timeout.d.ts +30 -0
- package/dist/types/eval/index.d.ts +4 -0
- package/dist/types/eval/js/context-manager.d.ts +24 -0
- package/dist/types/eval/js/executor.d.ts +36 -0
- package/dist/types/eval/js/index.d.ts +10 -0
- package/dist/types/eval/js/shared/helpers.d.ts +38 -0
- package/dist/types/eval/js/shared/indirect-eval.d.ts +14 -0
- package/dist/types/eval/js/shared/local-module-loader.d.ts +16 -0
- package/dist/types/eval/js/shared/prelude.d.ts +1 -0
- package/dist/types/eval/js/shared/rewrite-imports.d.ts +25 -0
- package/dist/types/eval/js/shared/runtime.d.ts +53 -0
- package/dist/types/eval/js/shared/types.d.ts +24 -0
- package/dist/types/eval/js/tool-bridge.d.ts +20 -0
- package/dist/types/eval/js/worker-core.d.ts +5 -0
- package/dist/types/eval/js/worker-entry.d.ts +1 -0
- package/dist/types/eval/js/worker-protocol.d.ts +77 -0
- package/dist/types/eval/llm-bridge.d.ts +25 -0
- package/dist/types/eval/py/display.d.ts +25 -0
- package/dist/types/eval/py/executor.d.ts +95 -0
- package/dist/types/eval/py/index.d.ts +11 -0
- package/dist/types/eval/py/kernel.d.ts +70 -0
- package/dist/types/eval/py/prelude.d.ts +1 -0
- package/dist/types/eval/py/runtime.d.ts +31 -0
- package/dist/types/eval/py/spawn-options.d.ts +58 -0
- package/dist/types/eval/py/tool-bridge.d.ts +16 -0
- package/dist/types/eval/session-id.d.ts +3 -0
- package/dist/types/eval/types.d.ts +52 -0
- package/dist/types/exa/factory.d.ts +13 -0
- package/dist/types/exa/index.d.ts +20 -0
- package/dist/types/exa/mcp-client.d.ts +46 -0
- package/dist/types/exa/render.d.ts +19 -0
- package/dist/types/exa/researcher.d.ts +9 -0
- package/dist/types/exa/search.d.ts +9 -0
- package/dist/types/exa/types.d.ts +155 -0
- package/dist/types/exa/websets.d.ts +9 -0
- package/dist/types/exec/bash-executor.d.ts +42 -0
- package/dist/types/exec/exec.d.ts +25 -0
- package/dist/types/exec/idle-timeout-watchdog.d.ts +18 -0
- package/dist/types/exec/non-interactive-env.d.ts +1 -0
- package/dist/types/export/custom-share.d.ts +20 -0
- package/dist/types/export/html/index.d.ts +10 -0
- package/dist/types/export/html/template.generated.d.ts +1 -0
- package/dist/types/export/html/template.macro.d.ts +5 -0
- package/dist/types/export/ttsr.d.ts +53 -0
- package/dist/types/extensibility/custom-commands/bundled/ci-green/index.d.ts +9 -0
- package/dist/types/extensibility/custom-commands/bundled/review/index.d.ts +10 -0
- package/dist/types/extensibility/custom-commands/index.d.ts +2 -0
- package/dist/types/extensibility/custom-commands/loader.d.ts +29 -0
- package/dist/types/extensibility/custom-commands/types.d.ts +106 -0
- package/dist/types/extensibility/custom-tools/index.d.ts +6 -0
- package/dist/types/extensibility/custom-tools/loader.d.ts +69 -0
- package/dist/types/extensibility/custom-tools/types.d.ts +232 -0
- package/dist/types/extensibility/custom-tools/wrapper.d.ts +23 -0
- package/dist/types/extensibility/extensions/compact-handler.d.ts +26 -0
- package/dist/types/extensibility/extensions/get-commands-handler.d.ts +29 -0
- package/dist/types/extensibility/extensions/index.d.ts +8 -0
- package/dist/types/extensibility/extensions/loader.d.ts +43 -0
- package/dist/types/extensibility/extensions/runner.d.ts +142 -0
- package/dist/types/extensibility/extensions/types.d.ts +892 -0
- package/dist/types/extensibility/extensions/wrapper.d.ts +54 -0
- package/dist/types/extensibility/hooks/index.d.ts +5 -0
- package/dist/types/extensibility/hooks/loader.d.ts +89 -0
- package/dist/types/extensibility/hooks/runner.d.ts +126 -0
- package/dist/types/extensibility/hooks/tool-wrapper.d.ts +25 -0
- package/dist/types/extensibility/hooks/types.d.ts +435 -0
- package/dist/types/extensibility/legacy-pi-ai-shim.d.ts +23 -0
- package/dist/types/extensibility/legacy-pi-coding-agent-shim.d.ts +14 -0
- package/dist/types/extensibility/plugins/doctor.d.ts +3 -0
- package/dist/types/extensibility/plugins/git-url.d.ts +44 -0
- package/dist/types/extensibility/plugins/index.d.ts +7 -0
- package/dist/types/extensibility/plugins/installer.d.ts +5 -0
- package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +29 -0
- package/dist/types/extensibility/plugins/loader.d.ts +41 -0
- package/dist/types/extensibility/plugins/manager.d.ts +76 -0
- package/dist/types/extensibility/plugins/marketplace/cache.d.ts +41 -0
- package/dist/types/extensibility/plugins/marketplace/fetcher.d.ts +48 -0
- package/dist/types/extensibility/plugins/marketplace/index.d.ts +6 -0
- package/dist/types/extensibility/plugins/marketplace/manager.d.ts +57 -0
- package/dist/types/extensibility/plugins/marketplace/registry.d.ts +34 -0
- package/dist/types/extensibility/plugins/marketplace/source-resolver.d.ts +28 -0
- package/dist/types/extensibility/plugins/marketplace/types.d.ts +130 -0
- package/dist/types/extensibility/plugins/parser.d.ts +52 -0
- package/dist/types/extensibility/plugins/types.d.ts +149 -0
- package/dist/types/extensibility/shared-events.d.ts +279 -0
- package/dist/types/extensibility/skills.d.ts +57 -0
- package/dist/types/extensibility/slash-commands.d.ts +48 -0
- package/dist/types/extensibility/tool-proxy.d.ts +4 -0
- package/dist/types/extensibility/typebox.d.ts +155 -0
- package/dist/types/extensibility/utils.d.ts +12 -0
- package/dist/types/gateway/adapters/telegram/access.d.ts +11 -0
- package/dist/types/gateway/adapters/telegram/commands.d.ts +41 -0
- package/dist/types/gateway/adapters/telegram/expressions.d.ts +60 -0
- package/dist/types/gateway/adapters/telegram/media.d.ts +58 -0
- package/dist/types/gateway/adapters/telegram/native-command-policy.d.ts +6 -0
- package/dist/types/gateway/adapters/telegram/native-commands.d.ts +23 -0
- package/dist/types/gateway/adapters/telegram/normalize.d.ts +8 -0
- package/dist/types/gateway/adapters/telegram/send-message.d.ts +388 -0
- package/dist/types/gateway/adapters/telegram/service.d.ts +65 -0
- package/dist/types/gateway/adapters/telegram/setup-api.d.ts +39 -0
- package/dist/types/gateway/adapters/telegram/setup-config.d.ts +11 -0
- package/dist/types/gateway/adapters/telegram/types.d.ts +187 -0
- package/dist/types/gateway/adapters/telegram/webhook.d.ts +53 -0
- package/dist/types/gateway/commands.d.ts +33 -0
- package/dist/types/gateway/context.d.ts +30 -0
- package/dist/types/gateway/native-slash-policy.d.ts +12 -0
- package/dist/types/gateway/prometheus-dispatch.d.ts +29 -0
- package/dist/types/gateway/router.d.ts +52 -0
- package/dist/types/gateway/session-key.d.ts +3 -0
- package/dist/types/gateway/types.d.ts +98 -0
- package/dist/types/goals/index.d.ts +3 -0
- package/dist/types/goals/runtime.d.ts +67 -0
- package/dist/types/goals/state.d.ts +35 -0
- package/dist/types/goals/tools/goal-tool.d.ts +66 -0
- package/dist/types/hindsight/backend.d.ts +13 -0
- package/dist/types/hindsight/bank.d.ts +62 -0
- package/dist/types/hindsight/client.d.ts +224 -0
- package/dist/types/hindsight/config.d.ts +51 -0
- package/dist/types/hindsight/content.d.ts +70 -0
- package/dist/types/hindsight/index.d.ts +8 -0
- package/dist/types/hindsight/mental-models.d.ts +125 -0
- package/dist/types/hindsight/state.d.ts +105 -0
- package/dist/types/hindsight/transcript.d.ts +28 -0
- package/dist/types/index.d.ts +36 -0
- package/dist/types/internal-urls/agent-protocol.d.ts +13 -0
- package/dist/types/internal-urls/artifact-protocol.d.ts +7 -0
- package/dist/types/internal-urls/docs-index.generated.d.ts +2 -0
- package/dist/types/internal-urls/index.d.ts +23 -0
- package/dist/types/internal-urls/issue-pr-protocol.d.ts +17 -0
- package/dist/types/internal-urls/json-query.d.ts +30 -0
- package/dist/types/internal-urls/local-protocol.d.ts +50 -0
- package/dist/types/internal-urls/mcp-protocol.d.ts +12 -0
- package/dist/types/internal-urls/memory-protocol.d.ts +24 -0
- package/dist/types/internal-urls/parse.d.ts +19 -0
- package/dist/types/internal-urls/prometheus-protocol.d.ts +13 -0
- package/dist/types/internal-urls/registry-helpers.d.ts +10 -0
- package/dist/types/internal-urls/router.d.ts +21 -0
- package/dist/types/internal-urls/rule-protocol.d.ts +7 -0
- package/dist/types/internal-urls/skill-protocol.d.ts +14 -0
- package/dist/types/internal-urls/types.d.ts +145 -0
- package/dist/types/internal-urls/vault-protocol.d.ts +93 -0
- package/dist/types/lib/xai-http.d.ts +40 -0
- package/dist/types/lsp/client.d.ts +68 -0
- package/dist/types/lsp/clients/biome-client.d.ts +16 -0
- package/dist/types/lsp/clients/index.d.ts +19 -0
- package/dist/types/lsp/clients/lsp-linter-client.d.ts +16 -0
- package/dist/types/lsp/clients/swiftlint-client.d.ts +20 -0
- package/dist/types/lsp/config.d.ts +65 -0
- package/dist/types/lsp/diagnostics-ledger.d.ts +10 -0
- package/dist/types/lsp/edits.d.ts +23 -0
- package/dist/types/lsp/index.d.ts +140 -0
- package/dist/types/lsp/lspmux.d.ts +58 -0
- package/dist/types/lsp/render.d.ts +32 -0
- package/dist/types/lsp/startup-events.d.ts +11 -0
- package/dist/types/lsp/types.d.ts +302 -0
- package/dist/types/lsp/utils.d.ts +112 -0
- package/dist/types/main.d.ts +56 -0
- package/dist/types/mcp/client.d.ts +75 -0
- package/dist/types/mcp/config-writer.d.ts +53 -0
- package/dist/types/mcp/config.d.ts +75 -0
- package/dist/types/mcp/index.d.ts +18 -0
- package/dist/types/mcp/json-rpc.d.ts +27 -0
- package/dist/types/mcp/loader.d.ts +43 -0
- package/dist/types/mcp/manager.d.ts +202 -0
- package/dist/types/mcp/oauth-discovery.d.ts +41 -0
- package/dist/types/mcp/oauth-flow.d.ts +59 -0
- package/dist/types/mcp/render.d.ts +25 -0
- package/dist/types/mcp/smithery-auth.d.ts +16 -0
- package/dist/types/mcp/smithery-connect.d.ts +38 -0
- package/dist/types/mcp/smithery-registry.d.ts +51 -0
- package/dist/types/mcp/timeout.d.ts +9 -0
- package/dist/types/mcp/tool-bridge.d.ts +90 -0
- package/dist/types/mcp/tool-cache.d.ts +8 -0
- package/dist/types/mcp/transports/http.d.ts +45 -0
- package/dist/types/mcp/transports/index.d.ts +5 -0
- package/dist/types/mcp/transports/stdio.d.ts +60 -0
- package/dist/types/mcp/types.d.ts +333 -0
- package/dist/types/memories/index.d.ts +43 -0
- package/dist/types/memories/storage.d.ts +120 -0
- package/dist/types/memory-backend/index.d.ts +5 -0
- package/dist/types/memory-backend/local-backend.d.ts +9 -0
- package/dist/types/memory-backend/off-backend.d.ts +7 -0
- package/dist/types/memory-backend/resolve.d.ts +16 -0
- package/dist/types/memory-backend/types.d.ts +67 -0
- package/dist/types/mnemopi/backend.d.ts +4 -0
- package/dist/types/mnemopi/config.d.ts +29 -0
- package/dist/types/mnemopi/index.d.ts +3 -0
- package/dist/types/mnemopi/state.d.ts +72 -0
- package/dist/types/modes/acp/acp-agent.d.ts +61 -0
- package/dist/types/modes/acp/acp-client-bridge.d.ts +9 -0
- package/dist/types/modes/acp/acp-event-mapper.d.ts +32 -0
- package/dist/types/modes/acp/acp-mode.d.ts +5 -0
- package/dist/types/modes/acp/index.d.ts +2 -0
- package/dist/types/modes/acp/terminal-auth.d.ts +6 -0
- package/dist/types/modes/components/agent-dashboard.d.ts +22 -0
- package/dist/types/modes/components/assistant-message.d.ts +35 -0
- package/dist/types/modes/components/bash-execution.d.ts +29 -0
- package/dist/types/modes/components/bordered-loader.d.ts +11 -0
- package/dist/types/modes/components/branch-summary-message.d.ts +13 -0
- package/dist/types/modes/components/btw-panel.d.ts +16 -0
- package/dist/types/modes/components/compaction-summary-message.d.ts +13 -0
- package/dist/types/modes/components/copy-selector.d.ts +22 -0
- package/dist/types/modes/components/countdown-timer.d.ts +14 -0
- package/dist/types/modes/components/custom-editor.d.ts +53 -0
- package/dist/types/modes/components/custom-message.d.ts +15 -0
- package/dist/types/modes/components/diff.d.ts +11 -0
- package/dist/types/modes/components/dynamic-border.d.ts +14 -0
- package/dist/types/modes/components/error-banner.d.ts +11 -0
- package/dist/types/modes/components/eval-execution.d.ts +23 -0
- package/dist/types/modes/components/execution-shared.d.ts +46 -0
- package/dist/types/modes/components/extensions/extension-dashboard.d.ts +27 -0
- package/dist/types/modes/components/extensions/extension-list.d.ts +39 -0
- package/dist/types/modes/components/extensions/index.d.ts +8 -0
- package/dist/types/modes/components/extensions/inspector-panel.d.ts +8 -0
- package/dist/types/modes/components/extensions/state-manager.d.ts +50 -0
- package/dist/types/modes/components/extensions/types.d.ts +147 -0
- package/dist/types/modes/components/footer.d.ts +30 -0
- package/dist/types/modes/components/history-search.d.ts +7 -0
- package/dist/types/modes/components/hook-editor.d.ts +18 -0
- package/dist/types/modes/components/hook-input.d.ts +15 -0
- package/dist/types/modes/components/hook-message.d.ts +15 -0
- package/dist/types/modes/components/hook-selector.d.ts +70 -0
- package/dist/types/modes/components/index.d.ts +37 -0
- package/dist/types/modes/components/keybinding-hints.d.ts +40 -0
- package/dist/types/modes/components/login-dialog.d.ts +32 -0
- package/dist/types/modes/components/mcp-add-wizard.d.ts +25 -0
- package/dist/types/modes/components/message-frame.d.ts +42 -0
- package/dist/types/modes/components/model-selector.d.ts +28 -0
- package/dist/types/modes/components/oauth-selector.d.ts +14 -0
- package/dist/types/modes/components/omfg-panel.d.ts +19 -0
- package/dist/types/modes/components/plugin-selector.d.ts +26 -0
- package/dist/types/modes/components/plugin-settings.d.ts +98 -0
- package/dist/types/modes/components/queue-mode-selector.d.ts +9 -0
- package/dist/types/modes/components/read-tool-group.d.ts +30 -0
- package/dist/types/modes/components/segment-track.d.ts +22 -0
- package/dist/types/modes/components/session-observer-overlay.d.ts +11 -0
- package/dist/types/modes/components/session-selector.d.ts +62 -0
- package/dist/types/modes/components/settings-defs.d.ts +50 -0
- package/dist/types/modes/components/settings-selector.d.ts +54 -0
- package/dist/types/modes/components/show-images-selector.d.ts +9 -0
- package/dist/types/modes/components/skill-message.d.ts +9 -0
- package/dist/types/modes/components/status-line/context-thresholds.d.ts +10 -0
- package/dist/types/modes/components/status-line/git-utils.d.ts +22 -0
- package/dist/types/modes/components/status-line/index.d.ts +4 -0
- package/dist/types/modes/components/status-line/presets.d.ts +3 -0
- package/dist/types/modes/components/status-line/segments.d.ts +5 -0
- package/dist/types/modes/components/status-line/separators.d.ts +3 -0
- package/dist/types/modes/components/status-line/token-rate.d.ts +10 -0
- package/dist/types/modes/components/status-line/types.d.ts +80 -0
- package/dist/types/modes/components/status-line.d.ts +77 -0
- package/dist/types/modes/components/theme-selector.d.ts +10 -0
- package/dist/types/modes/components/thinking-selector.d.ts +10 -0
- package/dist/types/modes/components/tiny-title-download-progress.d.ts +11 -0
- package/dist/types/modes/components/todo-reminder.d.ts +13 -0
- package/dist/types/modes/components/tool-execution.d.ts +77 -0
- package/dist/types/modes/components/transcript-container.d.ts +38 -0
- package/dist/types/modes/components/tree-selector.d.ts +31 -0
- package/dist/types/modes/components/ttsr-notification.d.ts +13 -0
- package/dist/types/modes/components/user-message-selector.d.ts +28 -0
- package/dist/types/modes/components/user-message.d.ts +8 -0
- package/dist/types/modes/components/visual-truncate.d.ts +19 -0
- package/dist/types/modes/components/welcome.d.ts +55 -0
- package/dist/types/modes/controllers/btw-controller.d.ts +10 -0
- package/dist/types/modes/controllers/command-controller-shared.d.ts +47 -0
- package/dist/types/modes/controllers/command-controller.d.ts +41 -0
- package/dist/types/modes/controllers/event-controller.d.ts +12 -0
- package/dist/types/modes/controllers/extension-ui-controller.d.ts +83 -0
- package/dist/types/modes/controllers/input-controller.d.ts +34 -0
- package/dist/types/modes/controllers/mcp-command-controller.d.ts +10 -0
- package/dist/types/modes/controllers/omfg-controller.d.ts +10 -0
- package/dist/types/modes/controllers/omfg-rule.d.ts +26 -0
- package/dist/types/modes/controllers/selector-controller.d.ts +46 -0
- package/dist/types/modes/controllers/ssh-command-controller.d.ts +10 -0
- package/dist/types/modes/controllers/todo-command-controller.d.ts +7 -0
- package/dist/types/modes/emoji-autocomplete.d.ts +16 -0
- package/dist/types/modes/gradient-highlight.d.ts +27 -0
- package/dist/types/modes/image-references.d.ts +17 -0
- package/dist/types/modes/index.d.ts +9 -0
- package/dist/types/modes/interactive-mode.d.ts +291 -0
- package/dist/types/modes/internal-url-autocomplete.d.ts +43 -0
- package/dist/types/modes/loop-limit.d.ts +22 -0
- package/dist/types/modes/magic-keywords.d.ts +14 -0
- package/dist/types/modes/markdown-prose.d.ts +27 -0
- package/dist/types/modes/oauth-manual-input.d.ts +8 -0
- package/dist/types/modes/orchestrate.d.ts +15 -0
- package/dist/types/modes/print-mode.d.ts +27 -0
- package/dist/types/modes/prompt-action-autocomplete.d.ts +46 -0
- package/dist/types/modes/rpc/host-tools.d.ts +16 -0
- package/dist/types/modes/rpc/host-uris.d.ts +38 -0
- package/dist/types/modes/rpc/rpc-client.d.ts +249 -0
- package/dist/types/modes/rpc/rpc-mode.d.ts +17 -0
- package/dist/types/modes/rpc/rpc-types.d.ts +586 -0
- package/dist/types/modes/runtime-init.d.ts +21 -0
- package/dist/types/modes/session-observer-registry.d.ts +26 -0
- package/dist/types/modes/setup-wizard/index.d.ts +16 -0
- package/dist/types/modes/setup-wizard/scenes/channels.d.ts +14 -0
- package/dist/types/modes/setup-wizard/scenes/glyph.d.ts +2 -0
- package/dist/types/modes/setup-wizard/scenes/outro.d.ts +2 -0
- package/dist/types/modes/setup-wizard/scenes/providers.d.ts +2 -0
- package/dist/types/modes/setup-wizard/scenes/sign-in.d.ts +19 -0
- package/dist/types/modes/setup-wizard/scenes/splash.d.ts +11 -0
- package/dist/types/modes/setup-wizard/scenes/telegram.d.ts +20 -0
- package/dist/types/modes/setup-wizard/scenes/theme.d.ts +2 -0
- package/dist/types/modes/setup-wizard/scenes/types.d.ts +43 -0
- package/dist/types/modes/setup-wizard/scenes/web-search.d.ts +19 -0
- package/dist/types/modes/setup-wizard/wizard-overlay.d.ts +14 -0
- package/dist/types/modes/shared.d.ts +15 -0
- package/dist/types/modes/theme/defaults/index.d.ts +9436 -0
- package/dist/types/modes/theme/mermaid-cache.d.ts +9 -0
- package/dist/types/modes/theme/shimmer.d.ts +40 -0
- package/dist/types/modes/theme/theme.d.ts +305 -0
- package/dist/types/modes/turn-budget.d.ts +18 -0
- package/dist/types/modes/types.d.ts +294 -0
- package/dist/types/modes/ultrathink.d.ts +15 -0
- package/dist/types/modes/utils/context-usage.d.ts +47 -0
- package/dist/types/modes/utils/copy-targets.d.ts +53 -0
- package/dist/types/modes/utils/hotkeys-markdown.d.ts +5 -0
- package/dist/types/modes/utils/keybinding-matchers.d.ts +19 -0
- package/dist/types/modes/utils/tools-markdown.d.ts +5 -0
- package/dist/types/modes/utils/ui-helpers.d.ts +55 -0
- package/dist/types/modes/workflow.d.ts +15 -0
- package/dist/types/plan-mode/approved-plan.d.ts +49 -0
- package/dist/types/plan-mode/plan-handoff.d.ts +20 -0
- package/dist/types/plan-mode/plan-protection.d.ts +12 -0
- package/dist/types/plan-mode/state.d.ts +6 -0
- package/dist/types/registry/agent-registry.d.ts +62 -0
- package/dist/types/sdk.d.ts +271 -0
- package/dist/types/secrets/index.d.ts +9 -0
- package/dist/types/secrets/obfuscator.d.ts +23 -0
- package/dist/types/secrets/regex.d.ts +2 -0
- package/dist/types/session/agent-session.d.ts +1032 -0
- package/dist/types/session/agent-storage.d.ts +94 -0
- package/dist/types/session/artifacts.d.ts +61 -0
- package/dist/types/session/auth-broker-config.d.ts +13 -0
- package/dist/types/session/auth-storage.d.ts +6 -0
- package/dist/types/session/blob-store.d.ts +64 -0
- package/dist/types/session/client-bridge.d.ts +88 -0
- package/dist/types/session/history-storage.d.ts +30 -0
- package/dist/types/session/indexed-session-storage.d.ts +59 -0
- package/dist/types/session/messages.d.ts +173 -0
- package/dist/types/session/redis-session-storage.d.ts +51 -0
- package/dist/types/session/session-dump-format.d.ts +22 -0
- package/dist/types/session/session-manager.d.ts +594 -0
- package/dist/types/session/session-storage.d.ts +86 -0
- package/dist/types/session/shake-types.d.ts +24 -0
- package/dist/types/session/sql-session-storage.d.ts +72 -0
- package/dist/types/session/streaming-output.d.ts +185 -0
- package/dist/types/session/tool-choice-queue.d.ts +78 -0
- package/dist/types/session/yield-queue.d.ts +24 -0
- package/dist/types/slash-commands/acp-builtins.d.ts +18 -0
- package/dist/types/slash-commands/builtin-registry.d.ts +23 -0
- package/dist/types/slash-commands/headless-plan.d.ts +3 -0
- package/dist/types/slash-commands/helpers/context-report.d.ts +7 -0
- package/dist/types/slash-commands/helpers/format.d.ts +10 -0
- package/dist/types/slash-commands/helpers/marketplace-manager.d.ts +8 -0
- package/dist/types/slash-commands/helpers/mcp.d.ts +3 -0
- package/dist/types/slash-commands/helpers/parse.d.ts +33 -0
- package/dist/types/slash-commands/helpers/ssh.d.ts +3 -0
- package/dist/types/slash-commands/helpers/todo.d.ts +3 -0
- package/dist/types/slash-commands/helpers/usage-report.d.ts +7 -0
- package/dist/types/slash-commands/marketplace-install-parser.d.ts +33 -0
- package/dist/types/slash-commands/types.d.ts +129 -0
- package/dist/types/ssh/config-writer.d.ts +49 -0
- package/dist/types/ssh/connection-manager.d.ts +33 -0
- package/dist/types/ssh/ssh-executor.d.ts +37 -0
- package/dist/types/ssh/sshfs-mount.d.ts +6 -0
- package/dist/types/ssh/utils.d.ts +2 -0
- package/dist/types/stt/downloader.d.ts +9 -0
- package/dist/types/stt/index.d.ts +3 -0
- package/dist/types/stt/recorder.d.ts +13 -0
- package/dist/types/stt/setup.d.ts +18 -0
- package/dist/types/stt/stt-controller.d.ts +16 -0
- package/dist/types/stt/transcriber.d.ts +16 -0
- package/dist/types/system-prompt.d.ts +97 -0
- package/dist/types/task/agents.d.ts +28 -0
- package/dist/types/task/commands.d.ts +35 -0
- package/dist/types/task/discovery.d.ts +18 -0
- package/dist/types/task/executor.d.ts +121 -0
- package/dist/types/task/index.d.ts +42 -0
- package/dist/types/task/name-generator.d.ts +16 -0
- package/dist/types/task/output-manager.d.ts +27 -0
- package/dist/types/task/parallel.d.ts +34 -0
- package/dist/types/task/prometheus-command.d.ts +7 -0
- package/dist/types/task/render.d.ts +26 -0
- package/dist/types/task/repair-args.d.ts +52 -0
- package/dist/types/task/simple-mode.d.ts +8 -0
- package/dist/types/task/subprocess-tool-registry.d.ts +72 -0
- package/dist/types/task/types.d.ts +300 -0
- package/dist/types/task/worktree.d.ts +94 -0
- package/dist/types/telemetry-export.d.ts +43 -0
- package/dist/types/thinking.d.ts +68 -0
- package/dist/types/tiny/compiled-runtime.d.ts +35 -0
- package/dist/types/tiny/device.d.ts +78 -0
- package/dist/types/tiny/dtype.d.ts +85 -0
- package/dist/types/tiny/models.d.ts +204 -0
- package/dist/types/tiny/text.d.ts +36 -0
- package/dist/types/tiny/title-client.d.ts +73 -0
- package/dist/types/tiny/title-protocol.d.ts +77 -0
- package/dist/types/tiny/worker.d.ts +2 -0
- package/dist/types/tool-discovery/mode.d.ts +8 -0
- package/dist/types/tool-discovery/tool-index.d.ts +57 -0
- package/dist/types/tools/approval.d.ts +46 -0
- package/dist/types/tools/archive-reader.d.ts +44 -0
- package/dist/types/tools/ask.d.ts +113 -0
- package/dist/types/tools/ast-edit.d.ts +79 -0
- package/dist/types/tools/ast-grep.d.ts +70 -0
- package/dist/types/tools/auto-generated-guard.d.ts +17 -0
- package/dist/types/tools/bash-command-fixup.d.ts +11 -0
- package/dist/types/tools/bash-interactive.d.ts +16 -0
- package/dist/types/tools/bash-interceptor.d.ts +24 -0
- package/dist/types/tools/bash-pty-selection.d.ts +7 -0
- package/dist/types/tools/bash-skill-urls.d.ts +31 -0
- package/dist/types/tools/bash.d.ts +142 -0
- package/dist/types/tools/browser/attach.d.ts +34 -0
- package/dist/types/tools/browser/launch.d.ts +62 -0
- package/dist/types/tools/browser/readable.d.ts +17 -0
- package/dist/types/tools/browser/registry.d.ts +42 -0
- package/dist/types/tools/browser/render.d.ts +50 -0
- package/dist/types/tools/browser/tab-protocol.d.ts +144 -0
- package/dist/types/tools/browser/tab-supervisor.d.ts +63 -0
- package/dist/types/tools/browser/tab-worker-entry.d.ts +1 -0
- package/dist/types/tools/browser/tab-worker.d.ts +19 -0
- package/dist/types/tools/browser.d.ts +116 -0
- package/dist/types/tools/checkpoint.d.ts +65 -0
- package/dist/types/tools/conflict-detect.d.ts +205 -0
- package/dist/types/tools/context.d.ts +19 -0
- package/dist/types/tools/debug.d.ts +217 -0
- package/dist/types/tools/eval-backends.d.ts +12 -0
- package/dist/types/tools/eval-render.d.ts +60 -0
- package/dist/types/tools/eval.d.ts +77 -0
- package/dist/types/tools/fetch.d.ts +80 -0
- package/dist/types/tools/file-recorder.d.ts +13 -0
- package/dist/types/tools/find.d.ts +103 -0
- package/dist/types/tools/fs-cache-invalidation.d.ts +15 -0
- package/dist/types/tools/gh-format.d.ts +6 -0
- package/dist/types/tools/gh-renderer.d.ts +25 -0
- package/dist/types/tools/gh.d.ts +357 -0
- package/dist/types/tools/github-cache.d.ts +103 -0
- package/dist/types/tools/grouped-file-output.d.ts +36 -0
- package/dist/types/tools/image-gen.d.ts +82 -0
- package/dist/types/tools/index.d.ts +269 -0
- package/dist/types/tools/inspect-image-renderer.d.ts +26 -0
- package/dist/types/tools/inspect-image.d.ts +32 -0
- package/dist/types/tools/irc.d.ts +80 -0
- package/dist/types/tools/job.d.ts +66 -0
- package/dist/types/tools/json-tree.d.ts +23 -0
- package/dist/types/tools/jtd-to-json-schema.d.ts +29 -0
- package/dist/types/tools/jtd-to-typescript.d.ts +26 -0
- package/dist/types/tools/jtd-utils.d.ts +42 -0
- package/dist/types/tools/list-limit.d.ts +12 -0
- package/dist/types/tools/match-line-format.d.ts +11 -0
- package/dist/types/tools/memory-edit.d.ts +40 -0
- package/dist/types/tools/memory-recall.d.ts +24 -0
- package/dist/types/tools/memory-reflect.d.ts +26 -0
- package/dist/types/tools/memory-render.d.ts +60 -0
- package/dist/types/tools/memory-retain.d.ts +30 -0
- package/dist/types/tools/output-meta.d.ts +204 -0
- package/dist/types/tools/output-schema-validator.d.ts +64 -0
- package/dist/types/tools/path-utils.d.ts +199 -0
- package/dist/types/tools/plan-mode-guard.d.ts +17 -0
- package/dist/types/tools/read.d.ts +86 -0
- package/dist/types/tools/render-mermaid.d.ts +38 -0
- package/dist/types/tools/render-utils.d.ts +185 -0
- package/dist/types/tools/renderers.d.ts +26 -0
- package/dist/types/tools/report-tool-issue.d.ts +123 -0
- package/dist/types/tools/resolve.d.ts +91 -0
- package/dist/types/tools/review.d.ts +63 -0
- package/dist/types/tools/search-tool-bm25.d.ts +66 -0
- package/dist/types/tools/search.d.ts +95 -0
- package/dist/types/tools/sqlite-reader.d.ts +110 -0
- package/dist/types/tools/ssh.d.ts +69 -0
- package/dist/types/tools/todo.d.ts +159 -0
- package/dist/types/tools/tool-errors.d.ts +33 -0
- package/dist/types/tools/tool-result.d.ts +32 -0
- package/dist/types/tools/tool-timeouts.d.ts +51 -0
- package/dist/types/tools/tts.d.ts +18 -0
- package/dist/types/tools/write.d.ts +65 -0
- package/dist/types/tools/yield.d.ts +26 -0
- package/dist/types/tui/code-cell.d.ts +40 -0
- package/dist/types/tui/file-list.d.ts +22 -0
- package/dist/types/tui/hyperlink.d.ts +54 -0
- package/dist/types/tui/index.d.ts +11 -0
- package/dist/types/tui/output-block.d.ts +57 -0
- package/dist/types/tui/status-line.d.ts +18 -0
- package/dist/types/tui/tree-list.d.ts +19 -0
- package/dist/types/tui/types.d.ts +13 -0
- package/dist/types/tui/utils.d.ts +36 -0
- package/dist/types/utils/changelog.d.ts +25 -0
- package/dist/types/utils/clipboard.d.ts +26 -0
- package/dist/types/utils/command-args.d.ts +9 -0
- package/dist/types/utils/commit-message-generator.d.ts +7 -0
- package/dist/types/utils/edit-mode.d.ts +13 -0
- package/dist/types/utils/event-bus.d.ts +6 -0
- package/dist/types/utils/external-editor.d.ts +17 -0
- package/dist/types/utils/file-display-mode.d.ts +27 -0
- package/dist/types/utils/file-mentions.d.ts +13 -0
- package/dist/types/utils/git.d.ts +361 -0
- package/dist/types/utils/image-loading.d.ts +26 -0
- package/dist/types/utils/image-resize.d.ts +39 -0
- package/dist/types/utils/jj.d.ts +49 -0
- package/dist/types/utils/lang-from-path.d.ts +8 -0
- package/dist/types/utils/markit.d.ts +7 -0
- package/dist/types/utils/open.d.ts +2 -0
- package/dist/types/utils/session-color.d.ts +15 -0
- package/dist/types/utils/shell-snapshot.d.ts +5 -0
- package/dist/types/utils/sixel.d.ts +21 -0
- package/dist/types/utils/title-generator.d.ts +34 -0
- package/dist/types/utils/tool-choice.d.ts +7 -0
- package/dist/types/utils/tools-manager.d.ts +9 -0
- package/dist/types/web/kagi.d.ts +99 -0
- package/dist/types/web/parallel.d.ts +58 -0
- package/dist/types/web/scrapers/artifacthub.d.ts +6 -0
- package/dist/types/web/scrapers/arxiv.d.ts +5 -0
- package/dist/types/web/scrapers/aur.d.ts +5 -0
- package/dist/types/web/scrapers/biorxiv.d.ts +5 -0
- package/dist/types/web/scrapers/bluesky.d.ts +5 -0
- package/dist/types/web/scrapers/brew.d.ts +5 -0
- package/dist/types/web/scrapers/cheatsh.d.ts +8 -0
- package/dist/types/web/scrapers/chocolatey.d.ts +5 -0
- package/dist/types/web/scrapers/choosealicense.d.ts +2 -0
- package/dist/types/web/scrapers/cisa-kev.d.ts +5 -0
- package/dist/types/web/scrapers/clojars.d.ts +5 -0
- package/dist/types/web/scrapers/coingecko.d.ts +5 -0
- package/dist/types/web/scrapers/crates-io.d.ts +5 -0
- package/dist/types/web/scrapers/crossref.d.ts +2 -0
- package/dist/types/web/scrapers/devto.d.ts +5 -0
- package/dist/types/web/scrapers/discogs.d.ts +8 -0
- package/dist/types/web/scrapers/discourse.d.ts +5 -0
- package/dist/types/web/scrapers/dockerhub.d.ts +5 -0
- package/dist/types/web/scrapers/docs-rs.d.ts +2 -0
- package/dist/types/web/scrapers/fdroid.d.ts +5 -0
- package/dist/types/web/scrapers/firefox-addons.d.ts +2 -0
- package/dist/types/web/scrapers/flathub.d.ts +2 -0
- package/dist/types/web/scrapers/github-gist.d.ts +5 -0
- package/dist/types/web/scrapers/github.d.ts +12 -0
- package/dist/types/web/scrapers/gitlab.d.ts +5 -0
- package/dist/types/web/scrapers/go-pkg.d.ts +5 -0
- package/dist/types/web/scrapers/hackage.d.ts +5 -0
- package/dist/types/web/scrapers/hackernews.d.ts +2 -0
- package/dist/types/web/scrapers/hex.d.ts +5 -0
- package/dist/types/web/scrapers/huggingface.d.ts +2 -0
- package/dist/types/web/scrapers/iacr.d.ts +5 -0
- package/dist/types/web/scrapers/index.d.ts +84 -0
- package/dist/types/web/scrapers/jetbrains-marketplace.d.ts +2 -0
- package/dist/types/web/scrapers/lemmy.d.ts +2 -0
- package/dist/types/web/scrapers/lobsters.d.ts +5 -0
- package/dist/types/web/scrapers/mastodon.d.ts +5 -0
- package/dist/types/web/scrapers/maven.d.ts +6 -0
- package/dist/types/web/scrapers/mdn.d.ts +2 -0
- package/dist/types/web/scrapers/metacpan.d.ts +5 -0
- package/dist/types/web/scrapers/musicbrainz.d.ts +5 -0
- package/dist/types/web/scrapers/npm.d.ts +5 -0
- package/dist/types/web/scrapers/nuget.d.ts +5 -0
- package/dist/types/web/scrapers/nvd.d.ts +5 -0
- package/dist/types/web/scrapers/ollama.d.ts +2 -0
- package/dist/types/web/scrapers/open-vsx.d.ts +5 -0
- package/dist/types/web/scrapers/opencorporates.d.ts +5 -0
- package/dist/types/web/scrapers/openlibrary.d.ts +5 -0
- package/dist/types/web/scrapers/orcid.d.ts +5 -0
- package/dist/types/web/scrapers/osv.d.ts +5 -0
- package/dist/types/web/scrapers/packagist.d.ts +5 -0
- package/dist/types/web/scrapers/pub-dev.d.ts +5 -0
- package/dist/types/web/scrapers/pubmed.d.ts +5 -0
- package/dist/types/web/scrapers/pypi.d.ts +5 -0
- package/dist/types/web/scrapers/rawg.d.ts +2 -0
- package/dist/types/web/scrapers/readthedocs.d.ts +2 -0
- package/dist/types/web/scrapers/reddit.d.ts +5 -0
- package/dist/types/web/scrapers/repology.d.ts +5 -0
- package/dist/types/web/scrapers/rfc.d.ts +5 -0
- package/dist/types/web/scrapers/rubygems.d.ts +5 -0
- package/dist/types/web/scrapers/searchcode.d.ts +2 -0
- package/dist/types/web/scrapers/sec-edgar.d.ts +5 -0
- package/dist/types/web/scrapers/semantic-scholar.d.ts +2 -0
- package/dist/types/web/scrapers/snapcraft.d.ts +2 -0
- package/dist/types/web/scrapers/sourcegraph.d.ts +2 -0
- package/dist/types/web/scrapers/spdx.d.ts +5 -0
- package/dist/types/web/scrapers/spotify.d.ts +8 -0
- package/dist/types/web/scrapers/stackoverflow.d.ts +6 -0
- package/dist/types/web/scrapers/terraform.d.ts +5 -0
- package/dist/types/web/scrapers/tldr.d.ts +7 -0
- package/dist/types/web/scrapers/twitter.d.ts +5 -0
- package/dist/types/web/scrapers/types.d.ts +78 -0
- package/dist/types/web/scrapers/utils.d.ts +26 -0
- package/dist/types/web/scrapers/vimeo.d.ts +5 -0
- package/dist/types/web/scrapers/vscode-marketplace.d.ts +5 -0
- package/dist/types/web/scrapers/w3c.d.ts +2 -0
- package/dist/types/web/scrapers/wikidata.d.ts +5 -0
- package/dist/types/web/scrapers/wikipedia.d.ts +5 -0
- package/dist/types/web/scrapers/youtube.d.ts +5 -0
- package/dist/types/web/search/index.d.ts +85 -0
- package/dist/types/web/search/provider.d.ts +21 -0
- package/dist/types/web/search/providers/anthropic.d.ts +32 -0
- package/dist/types/web/search/providers/base.d.ts +81 -0
- package/dist/types/web/search/providers/brave.d.ts +27 -0
- package/dist/types/web/search/providers/codex.d.ts +35 -0
- package/dist/types/web/search/providers/exa.d.ts +67 -0
- package/dist/types/web/search/providers/gemini.d.ts +57 -0
- package/dist/types/web/search/providers/jina.d.ts +26 -0
- package/dist/types/web/search/providers/kagi.d.ts +25 -0
- package/dist/types/web/search/providers/kimi.d.ts +27 -0
- package/dist/types/web/search/providers/parallel.d.ts +15 -0
- package/dist/types/web/search/providers/perplexity.d.ts +38 -0
- package/dist/types/web/search/providers/searxng.d.ts +44 -0
- package/dist/types/web/search/providers/synthetic.d.ts +21 -0
- package/dist/types/web/search/providers/tavily.d.ts +29 -0
- package/dist/types/web/search/providers/utils.d.ts +52 -0
- package/dist/types/web/search/providers/zai.d.ts +28 -0
- package/dist/types/web/search/render.d.ts +34 -0
- package/dist/types/web/search/types.d.ts +409 -0
- package/dist/types/web/search/utils.d.ts +4 -0
- package/dist/types/workspace-tree.d.ts +42 -0
- package/examples/README.md +21 -0
- package/examples/custom-tools/README.md +104 -0
- package/examples/custom-tools/hello/index.ts +20 -0
- package/examples/extensions/README.md +142 -0
- package/examples/extensions/api-demo.ts +79 -0
- package/examples/extensions/chalk-logger.ts +25 -0
- package/examples/extensions/hello.ts +31 -0
- package/examples/extensions/pirate.ts +43 -0
- package/examples/extensions/plan-mode.ts +549 -0
- package/examples/extensions/reload-runtime.ts +38 -0
- package/examples/extensions/thinking-note.ts +13 -0
- package/examples/extensions/tools.ts +144 -0
- package/examples/extensions/with-deps/index.ts +36 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +16 -0
- package/examples/hooks/README.md +56 -0
- package/examples/hooks/auto-commit-on-exit.ts +48 -0
- package/examples/hooks/confirm-destructive.ts +58 -0
- package/examples/hooks/custom-compaction.ts +116 -0
- package/examples/hooks/dirty-repo-guard.ts +51 -0
- package/examples/hooks/file-trigger.ts +40 -0
- package/examples/hooks/git-checkpoint.ts +52 -0
- package/examples/hooks/handoff.ts +150 -0
- package/examples/hooks/permission-gate.ts +33 -0
- package/examples/hooks/protected-paths.ts +29 -0
- package/examples/hooks/qna.ts +119 -0
- package/examples/hooks/status-line.ts +39 -0
- package/examples/sdk/01-minimal.ts +21 -0
- package/examples/sdk/02-custom-model.ts +50 -0
- package/examples/sdk/03-custom-prompt.ts +46 -0
- package/examples/sdk/04-skills.ts +43 -0
- package/examples/sdk/06-extensions.ts +82 -0
- package/examples/sdk/06-hooks.ts +61 -0
- package/examples/sdk/07-context-files.ts +35 -0
- package/examples/sdk/08-prompt-templates.ts +36 -0
- package/examples/sdk/08-slash-commands.ts +41 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +54 -0
- package/examples/sdk/11-sessions.ts +47 -0
- package/examples/sdk/12-redis-sessions.ts +54 -0
- package/examples/sdk/13-sql-sessions.ts +61 -0
- package/examples/sdk/README.md +172 -0
- package/package.json +548 -0
- package/scripts/build-binary.ts +105 -0
- package/scripts/format-prompts.ts +68 -0
- package/scripts/generate-docs-index.ts +40 -0
- package/scripts/generate-template.ts +33 -0
- package/src/async/index.ts +2 -0
- package/src/async/job-manager.ts +571 -0
- package/src/async/support.ts +5 -0
- package/src/auto-thinking/classifier.ts +180 -0
- package/src/autoresearch/command-resume.md +14 -0
- package/src/autoresearch/dashboard.ts +436 -0
- package/src/autoresearch/git.ts +319 -0
- package/src/autoresearch/helpers.ts +218 -0
- package/src/autoresearch/index.ts +536 -0
- package/src/autoresearch/prompt-setup.md +43 -0
- package/src/autoresearch/prompt.md +103 -0
- package/src/autoresearch/resume-message.md +10 -0
- package/src/autoresearch/state.ts +273 -0
- package/src/autoresearch/storage.ts +699 -0
- package/src/autoresearch/tools/init-experiment.ts +272 -0
- package/src/autoresearch/tools/log-experiment.ts +524 -0
- package/src/autoresearch/tools/run-experiment.ts +407 -0
- package/src/autoresearch/tools/update-notes.ts +109 -0
- package/src/autoresearch/types.ts +168 -0
- package/src/bun-imports.d.ts +28 -0
- package/src/capability/context-file.ts +58 -0
- package/src/capability/extension-module.ts +34 -0
- package/src/capability/extension.ts +47 -0
- package/src/capability/fs.ts +107 -0
- package/src/capability/hook.ts +40 -0
- package/src/capability/index.ts +441 -0
- package/src/capability/instruction.ts +37 -0
- package/src/capability/mcp.ts +74 -0
- package/src/capability/prompt.ts +35 -0
- package/src/capability/rule-buckets.ts +64 -0
- package/src/capability/rule.ts +252 -0
- package/src/capability/settings.ts +34 -0
- package/src/capability/skill.ts +63 -0
- package/src/capability/slash-command.ts +40 -0
- package/src/capability/ssh.ts +41 -0
- package/src/capability/system-prompt.ts +34 -0
- package/src/capability/tool.ts +38 -0
- package/src/capability/types.ts +172 -0
- package/src/cli/agents-cli.ts +138 -0
- package/src/cli/args.ts +335 -0
- package/src/cli/auth-broker-cli.ts +898 -0
- package/src/cli/auth-gateway-cli.ts +612 -0
- package/src/cli/classify-install-target.ts +76 -0
- package/src/cli/claude-trace-cli.ts +813 -0
- package/src/cli/commands/init-xdg.ts +27 -0
- package/src/cli/completion-gen.ts +550 -0
- package/src/cli/config-cli.ts +418 -0
- package/src/cli/dry-balance-cli.ts +823 -0
- package/src/cli/extension-flags.ts +48 -0
- package/src/cli/file-processor.ts +133 -0
- package/src/cli/gateway-cli.ts +664 -0
- package/src/cli/grep-cli.ts +160 -0
- package/src/cli/grievances-cli.ts +260 -0
- package/src/cli/initial-message.ts +58 -0
- package/src/cli/list-models.ts +194 -0
- package/src/cli/plugin-cli.ts +996 -0
- package/src/cli/read-cli.ts +57 -0
- package/src/cli/session-picker.ts +79 -0
- package/src/cli/setup-cli.ts +231 -0
- package/src/cli/shell-cli.ts +176 -0
- package/src/cli/ssh-cli.ts +181 -0
- package/src/cli/stats-cli.ts +238 -0
- package/src/cli/tiny-models-cli.ts +127 -0
- package/src/cli/update-cli.ts +739 -0
- package/src/cli/web-search-cli.ts +132 -0
- package/src/cli/worktree-cli.ts +291 -0
- package/src/cli-commands.ts +49 -0
- package/src/cli.ts +123 -0
- package/src/commands/acp.ts +24 -0
- package/src/commands/agents.ts +57 -0
- package/src/commands/auth-broker.ts +99 -0
- package/src/commands/auth-gateway.ts +69 -0
- package/src/commands/commit.ts +46 -0
- package/src/commands/complete.ts +66 -0
- package/src/commands/completions.ts +60 -0
- package/src/commands/config.ts +51 -0
- package/src/commands/dry-balance.ts +43 -0
- package/src/commands/gateway.ts +103 -0
- package/src/commands/grep.ts +48 -0
- package/src/commands/grievances.ts +51 -0
- package/src/commands/install.ts +107 -0
- package/src/commands/launch.ts +162 -0
- package/src/commands/plugin.ts +78 -0
- package/src/commands/read.ts +35 -0
- package/src/commands/setup.ts +67 -0
- package/src/commands/shell.ts +29 -0
- package/src/commands/ssh.ts +60 -0
- package/src/commands/stats.ts +29 -0
- package/src/commands/tiny-models.ts +36 -0
- package/src/commands/update.ts +21 -0
- package/src/commands/web-search.ts +42 -0
- package/src/commands/worktree.ts +56 -0
- package/src/commit/agentic/agent.ts +316 -0
- package/src/commit/agentic/fallback.ts +96 -0
- package/src/commit/agentic/index.ts +355 -0
- package/src/commit/agentic/prompts/analyze-file.md +22 -0
- package/src/commit/agentic/prompts/session-user.md +25 -0
- package/src/commit/agentic/prompts/split-confirm.md +1 -0
- package/src/commit/agentic/prompts/system.md +38 -0
- package/src/commit/agentic/state.ts +60 -0
- package/src/commit/agentic/tools/analyze-file.ts +127 -0
- package/src/commit/agentic/tools/git-file-diff.ts +191 -0
- package/src/commit/agentic/tools/git-hunk.ts +50 -0
- package/src/commit/agentic/tools/git-overview.ts +81 -0
- package/src/commit/agentic/tools/index.ts +54 -0
- package/src/commit/agentic/tools/propose-changelog.ts +144 -0
- package/src/commit/agentic/tools/propose-commit.ts +109 -0
- package/src/commit/agentic/tools/recent-commits.ts +81 -0
- package/src/commit/agentic/tools/schemas.ts +23 -0
- package/src/commit/agentic/tools/split-commit.ts +238 -0
- package/src/commit/agentic/topo-sort.ts +44 -0
- package/src/commit/agentic/trivial.ts +51 -0
- package/src/commit/agentic/validation.ts +183 -0
- package/src/commit/analysis/conventional.ts +64 -0
- package/src/commit/analysis/index.ts +4 -0
- package/src/commit/analysis/scope.ts +242 -0
- package/src/commit/analysis/summary.ts +105 -0
- package/src/commit/analysis/validation.ts +66 -0
- package/src/commit/changelog/detect.ts +40 -0
- package/src/commit/changelog/generate.ts +97 -0
- package/src/commit/changelog/index.ts +234 -0
- package/src/commit/changelog/parse.ts +44 -0
- package/src/commit/cli.ts +85 -0
- package/src/commit/git/diff.ts +148 -0
- package/src/commit/index.ts +5 -0
- package/src/commit/map-reduce/index.ts +69 -0
- package/src/commit/map-reduce/map-phase.ts +193 -0
- package/src/commit/map-reduce/reduce-phase.ts +49 -0
- package/src/commit/map-reduce/utils.ts +9 -0
- package/src/commit/message.ts +11 -0
- package/src/commit/model-selection.ts +66 -0
- package/src/commit/pipeline.ts +243 -0
- package/src/commit/prompts/analysis-system.md +148 -0
- package/src/commit/prompts/analysis-user.md +38 -0
- package/src/commit/prompts/changelog-system.md +50 -0
- package/src/commit/prompts/changelog-user.md +18 -0
- package/src/commit/prompts/file-observer-system.md +24 -0
- package/src/commit/prompts/file-observer-user.md +8 -0
- package/src/commit/prompts/reduce-system.md +50 -0
- package/src/commit/prompts/reduce-user.md +17 -0
- package/src/commit/prompts/summary-retry.md +3 -0
- package/src/commit/prompts/summary-system.md +38 -0
- package/src/commit/prompts/summary-user.md +13 -0
- package/src/commit/prompts/types-description.md +2 -0
- package/src/commit/shared-llm.ts +77 -0
- package/src/commit/types.ts +118 -0
- package/src/commit/utils/exclusions.ts +42 -0
- package/src/commit/utils.ts +58 -0
- package/src/config/append-only-context-mode.ts +37 -0
- package/src/config/config-file.ts +317 -0
- package/src/config/file-lock.ts +164 -0
- package/src/config/keybindings.ts +623 -0
- package/src/config/mcp-schema.json +230 -0
- package/src/config/model-equivalence.ts +852 -0
- package/src/config/model-id-affixes.ts +64 -0
- package/src/config/model-registry.ts +2650 -0
- package/src/config/model-resolver.ts +1402 -0
- package/src/config/models-config-schema.ts +177 -0
- package/src/config/prompt-templates.ts +185 -0
- package/src/config/resolve-config-value.ts +94 -0
- package/src/config/settings-schema.ts +3752 -0
- package/src/config/settings.ts +1017 -0
- package/src/config.ts +242 -0
- package/src/cursor.ts +340 -0
- package/src/dap/client.ts +675 -0
- package/src/dap/config.ts +150 -0
- package/src/dap/defaults.json +211 -0
- package/src/dap/index.ts +4 -0
- package/src/dap/session.ts +1339 -0
- package/src/dap/types.ts +600 -0
- package/src/debug/index.ts +525 -0
- package/src/debug/log-formatting.ts +58 -0
- package/src/debug/log-viewer.ts +908 -0
- package/src/debug/profiler.ts +162 -0
- package/src/debug/protocol-probe.ts +267 -0
- package/src/debug/raw-sse-buffer.ts +270 -0
- package/src/debug/raw-sse.ts +292 -0
- package/src/debug/report-bundle.ts +365 -0
- package/src/debug/system-info.ts +111 -0
- package/src/debug/terminal-info.ts +127 -0
- package/src/discovery/agents-md.ts +63 -0
- package/src/discovery/agents.ts +236 -0
- package/src/discovery/builtin-defaults.ts +39 -0
- package/src/discovery/builtin-rules/index.ts +50 -0
- package/src/discovery/builtin-rules/rs-box-leak.md +48 -0
- package/src/discovery/builtin-rules/rs-future-prelude.md +23 -0
- package/src/discovery/builtin-rules/rs-lazylock.md +51 -0
- package/src/discovery/builtin-rules/rs-match-ergonomics.md +67 -0
- package/src/discovery/builtin-rules/rs-parking-lot.md +44 -0
- package/src/discovery/builtin-rules/rs-result-type.md +19 -0
- package/src/discovery/builtin-rules/ts-bare-catch.md +38 -0
- package/src/discovery/builtin-rules/ts-import-type.md +42 -0
- package/src/discovery/builtin-rules/ts-no-any.md +56 -0
- package/src/discovery/builtin-rules/ts-no-deprecated-leftovers.md +44 -0
- package/src/discovery/builtin-rules/ts-no-dynamic-import.md +39 -0
- package/src/discovery/builtin-rules/ts-no-return-type.md +45 -0
- package/src/discovery/builtin-rules/ts-no-tiny-functions.md +51 -0
- package/src/discovery/builtin-rules/ts-promise-with-resolvers.md +65 -0
- package/src/discovery/builtin-rules/ts-set-map.md +28 -0
- package/src/discovery/builtin.ts +906 -0
- package/src/discovery/claude-plugins.ts +386 -0
- package/src/discovery/claude.ts +584 -0
- package/src/discovery/cline.ts +83 -0
- package/src/discovery/codex.ts +522 -0
- package/src/discovery/context-files.ts +49 -0
- package/src/discovery/cursor.ts +220 -0
- package/src/discovery/gemini.ts +383 -0
- package/src/discovery/github.ts +154 -0
- package/src/discovery/helpers.ts +1015 -0
- package/src/discovery/index.ts +81 -0
- package/src/discovery/mcp-json.ts +171 -0
- package/src/discovery/opencode.ts +398 -0
- package/src/discovery/plugin-dir-roots.ts +28 -0
- package/src/discovery/prometheus-extension-roots.ts +190 -0
- package/src/discovery/prometheus-plugins.ts +385 -0
- package/src/discovery/ssh.ts +153 -0
- package/src/discovery/substitute-plugin-root.ts +29 -0
- package/src/discovery/vscode.ts +105 -0
- package/src/discovery/windsurf.ts +147 -0
- package/src/edit/apply-patch/index.ts +87 -0
- package/src/edit/apply-patch/parser.ts +174 -0
- package/src/edit/diff.ts +812 -0
- package/src/edit/file-snapshot-store.ts +59 -0
- package/src/edit/hashline/block-resolver.ts +14 -0
- package/src/edit/hashline/diff.ts +169 -0
- package/src/edit/hashline/execute.ts +187 -0
- package/src/edit/hashline/filesystem.ts +129 -0
- package/src/edit/hashline/index.ts +5 -0
- package/src/edit/hashline/params.ts +18 -0
- package/src/edit/index.ts +542 -0
- package/src/edit/modes/apply-patch.lark +19 -0
- package/src/edit/modes/apply-patch.ts +53 -0
- package/src/edit/modes/patch.ts +1835 -0
- package/src/edit/modes/replace.ts +1103 -0
- package/src/edit/normalize.ts +345 -0
- package/src/edit/notebook.ts +222 -0
- package/src/edit/read-file.ts +25 -0
- package/src/edit/renderer.ts +660 -0
- package/src/edit/streaming.ts +517 -0
- package/src/eval/__tests__/agent-bridge.test.ts +650 -0
- package/src/eval/__tests__/bridge-timeout.test.ts +64 -0
- package/src/eval/__tests__/budget-bridge.test.ts +69 -0
- package/src/eval/__tests__/idle-timeout.test.ts +80 -0
- package/src/eval/__tests__/kernel-spawn.test.ts +103 -0
- package/src/eval/__tests__/llm-bridge.test.ts +327 -0
- package/src/eval/__tests__/shared-executors.test.ts +609 -0
- package/src/eval/agent-bridge.ts +303 -0
- package/src/eval/backend.ts +58 -0
- package/src/eval/bridge-timeout.ts +44 -0
- package/src/eval/budget-bridge.ts +48 -0
- package/src/eval/concurrency-bridge.ts +34 -0
- package/src/eval/idle-timeout.ts +98 -0
- package/src/eval/index.ts +4 -0
- package/src/eval/js/context-manager.ts +425 -0
- package/src/eval/js/executor.ts +166 -0
- package/src/eval/js/index.ts +47 -0
- package/src/eval/js/shared/helpers.ts +237 -0
- package/src/eval/js/shared/indirect-eval.ts +30 -0
- package/src/eval/js/shared/local-module-loader.ts +342 -0
- package/src/eval/js/shared/prelude.ts +2 -0
- package/src/eval/js/shared/prelude.txt +169 -0
- package/src/eval/js/shared/rewrite-imports.ts +508 -0
- package/src/eval/js/shared/runtime.ts +344 -0
- package/src/eval/js/shared/types.ts +18 -0
- package/src/eval/js/tool-bridge.ts +162 -0
- package/src/eval/js/worker-core.ts +131 -0
- package/src/eval/js/worker-entry.ts +24 -0
- package/src/eval/js/worker-protocol.ts +41 -0
- package/src/eval/llm-bridge.ts +186 -0
- package/src/eval/py/display.ts +71 -0
- package/src/eval/py/executor.ts +698 -0
- package/src/eval/py/index.ts +59 -0
- package/src/eval/py/kernel.ts +709 -0
- package/src/eval/py/prelude.py +620 -0
- package/src/eval/py/prelude.ts +3 -0
- package/src/eval/py/runner.py +1028 -0
- package/src/eval/py/runtime.ts +239 -0
- package/src/eval/py/spawn-options.ts +126 -0
- package/src/eval/py/tool-bridge.ts +182 -0
- package/src/eval/session-id.ts +8 -0
- package/src/eval/types.ts +48 -0
- package/src/exa/factory.ts +60 -0
- package/src/exa/index.ts +27 -0
- package/src/exa/mcp-client.ts +370 -0
- package/src/exa/render.ts +244 -0
- package/src/exa/researcher.ts +36 -0
- package/src/exa/search.ts +47 -0
- package/src/exa/types.ts +166 -0
- package/src/exa/websets.ts +248 -0
- package/src/exec/bash-executor.ts +338 -0
- package/src/exec/exec.ts +53 -0
- package/src/exec/idle-timeout-watchdog.ts +126 -0
- package/src/exec/non-interactive-env.ts +48 -0
- package/src/export/custom-share.ts +65 -0
- package/src/export/html/index.ts +164 -0
- package/src/export/html/template.css +1051 -0
- package/src/export/html/template.generated.ts +2 -0
- package/src/export/html/template.html +46 -0
- package/src/export/html/template.js +2244 -0
- package/src/export/html/template.macro.ts +25 -0
- package/src/export/html/vendor/highlight.min.js +1213 -0
- package/src/export/html/vendor/marked.min.js +6 -0
- package/src/export/ttsr.ts +462 -0
- package/src/extensibility/custom-commands/bundled/ci-green/index.ts +54 -0
- package/src/extensibility/custom-commands/bundled/review/index.ts +489 -0
- package/src/extensibility/custom-commands/index.ts +2 -0
- package/src/extensibility/custom-commands/loader.ts +238 -0
- package/src/extensibility/custom-commands/types.ts +113 -0
- package/src/extensibility/custom-tools/index.ts +7 -0
- package/src/extensibility/custom-tools/loader.ts +240 -0
- package/src/extensibility/custom-tools/types.ts +268 -0
- package/src/extensibility/custom-tools/wrapper.ts +47 -0
- package/src/extensibility/extensions/compact-handler.ts +40 -0
- package/src/extensibility/extensions/get-commands-handler.ts +77 -0
- package/src/extensibility/extensions/index.ts +15 -0
- package/src/extensibility/extensions/loader.ts +552 -0
- package/src/extensibility/extensions/runner.ts +917 -0
- package/src/extensibility/extensions/types.ts +1303 -0
- package/src/extensibility/extensions/wrapper.ts +223 -0
- package/src/extensibility/hooks/index.ts +5 -0
- package/src/extensibility/hooks/loader.ts +257 -0
- package/src/extensibility/hooks/runner.ts +425 -0
- package/src/extensibility/hooks/tool-wrapper.ts +107 -0
- package/src/extensibility/hooks/types.ts +606 -0
- package/src/extensibility/legacy-pi-ai-shim.ts +24 -0
- package/src/extensibility/legacy-pi-coding-agent-shim.ts +15 -0
- package/src/extensibility/plugins/doctor.ts +66 -0
- package/src/extensibility/plugins/git-url.ts +367 -0
- package/src/extensibility/plugins/index.ts +9 -0
- package/src/extensibility/plugins/installer.ts +192 -0
- package/src/extensibility/plugins/legacy-pi-compat.ts +661 -0
- package/src/extensibility/plugins/loader.ts +313 -0
- package/src/extensibility/plugins/manager.ts +827 -0
- package/src/extensibility/plugins/marketplace/cache.ts +136 -0
- package/src/extensibility/plugins/marketplace/fetcher.ts +317 -0
- package/src/extensibility/plugins/marketplace/index.ts +6 -0
- package/src/extensibility/plugins/marketplace/manager.ts +770 -0
- package/src/extensibility/plugins/marketplace/registry.ts +196 -0
- package/src/extensibility/plugins/marketplace/source-resolver.ts +147 -0
- package/src/extensibility/plugins/marketplace/types.ts +191 -0
- package/src/extensibility/plugins/parser.ts +105 -0
- package/src/extensibility/plugins/types.ts +194 -0
- package/src/extensibility/shared-events.ts +343 -0
- package/src/extensibility/skills.ts +312 -0
- package/src/extensibility/slash-commands.ts +227 -0
- package/src/extensibility/tool-proxy.ts +25 -0
- package/src/extensibility/typebox.ts +418 -0
- package/src/extensibility/utils.ts +44 -0
- package/src/gateway/adapters/telegram/access.ts +53 -0
- package/src/gateway/adapters/telegram/commands.ts +206 -0
- package/src/gateway/adapters/telegram/expressions.ts +678 -0
- package/src/gateway/adapters/telegram/media.ts +831 -0
- package/src/gateway/adapters/telegram/native-command-policy.ts +83 -0
- package/src/gateway/adapters/telegram/native-commands.ts +197 -0
- package/src/gateway/adapters/telegram/normalize.ts +593 -0
- package/src/gateway/adapters/telegram/send-message.ts +1465 -0
- package/src/gateway/adapters/telegram/service.ts +577 -0
- package/src/gateway/adapters/telegram/setup-api.ts +196 -0
- package/src/gateway/adapters/telegram/setup-config.ts +72 -0
- package/src/gateway/adapters/telegram/types.ts +206 -0
- package/src/gateway/adapters/telegram/webhook.ts +364 -0
- package/src/gateway/commands.ts +196 -0
- package/src/gateway/context.ts +276 -0
- package/src/gateway/native-slash-policy.ts +19 -0
- package/src/gateway/prometheus-dispatch.ts +362 -0
- package/src/gateway/router.ts +123 -0
- package/src/gateway/session-key.ts +55 -0
- package/src/gateway/types.ts +119 -0
- package/src/goals/index.ts +3 -0
- package/src/goals/runtime.ts +528 -0
- package/src/goals/state.ts +37 -0
- package/src/goals/tools/goal-tool.ts +241 -0
- package/src/hindsight/backend.ts +354 -0
- package/src/hindsight/bank.ts +141 -0
- package/src/hindsight/client.ts +598 -0
- package/src/hindsight/config.ts +175 -0
- package/src/hindsight/content.ts +210 -0
- package/src/hindsight/index.ts +8 -0
- package/src/hindsight/mental-models.ts +382 -0
- package/src/hindsight/seeds.json +32 -0
- package/src/hindsight/state.ts +483 -0
- package/src/hindsight/transcript.ts +71 -0
- package/src/index.ts +59 -0
- package/src/internal-urls/agent-protocol.ts +146 -0
- package/src/internal-urls/artifact-protocol.ts +98 -0
- package/src/internal-urls/docs-index.generated.ts +107 -0
- package/src/internal-urls/index.ts +24 -0
- package/src/internal-urls/issue-pr-protocol.ts +577 -0
- package/src/internal-urls/json-query.ts +126 -0
- package/src/internal-urls/local-protocol.ts +274 -0
- package/src/internal-urls/mcp-protocol.ts +151 -0
- package/src/internal-urls/memory-protocol.ts +196 -0
- package/src/internal-urls/parse.ts +72 -0
- package/src/internal-urls/prometheus-protocol.ts +93 -0
- package/src/internal-urls/registry-helpers.ts +25 -0
- package/src/internal-urls/router.ts +103 -0
- package/src/internal-urls/rule-protocol.ts +45 -0
- package/src/internal-urls/skill-protocol.ts +96 -0
- package/src/internal-urls/types.ts +152 -0
- package/src/internal-urls/vault-protocol.ts +936 -0
- package/src/lib/xai-http.ts +124 -0
- package/src/lsp/client.ts +1052 -0
- package/src/lsp/clients/biome-client.ts +202 -0
- package/src/lsp/clients/index.ts +50 -0
- package/src/lsp/clients/lsp-linter-client.ts +93 -0
- package/src/lsp/clients/swiftlint-client.ts +120 -0
- package/src/lsp/config.ts +492 -0
- package/src/lsp/defaults.json +493 -0
- package/src/lsp/diagnostics-ledger.ts +51 -0
- package/src/lsp/edits.ts +219 -0
- package/src/lsp/index.ts +2340 -0
- package/src/lsp/lspmux.ts +233 -0
- package/src/lsp/render.ts +692 -0
- package/src/lsp/startup-events.ts +13 -0
- package/src/lsp/types.ts +443 -0
- package/src/lsp/utils.ts +699 -0
- package/src/main.ts +1167 -0
- package/src/mcp/client.ts +484 -0
- package/src/mcp/config-writer.ts +225 -0
- package/src/mcp/config.ts +365 -0
- package/src/mcp/index.ts +29 -0
- package/src/mcp/json-rpc.ts +92 -0
- package/src/mcp/loader.ts +124 -0
- package/src/mcp/manager.ts +1274 -0
- package/src/mcp/oauth-discovery.ts +437 -0
- package/src/mcp/oauth-flow.ts +435 -0
- package/src/mcp/render.ts +126 -0
- package/src/mcp/smithery-auth.ts +104 -0
- package/src/mcp/smithery-connect.ts +145 -0
- package/src/mcp/smithery-registry.ts +477 -0
- package/src/mcp/timeout.ts +59 -0
- package/src/mcp/tool-bridge.ts +424 -0
- package/src/mcp/tool-cache.ts +117 -0
- package/src/mcp/transports/http.ts +519 -0
- package/src/mcp/transports/index.ts +6 -0
- package/src/mcp/transports/stdio.ts +386 -0
- package/src/mcp/types.ts +423 -0
- package/src/memories/index.ts +2227 -0
- package/src/memories/storage.ts +617 -0
- package/src/memory-backend/index.ts +5 -0
- package/src/memory-backend/local-backend.ts +30 -0
- package/src/memory-backend/off-backend.ts +16 -0
- package/src/memory-backend/resolve.ts +27 -0
- package/src/memory-backend/types.ts +86 -0
- package/src/mnemopi/backend.ts +374 -0
- package/src/mnemopi/config.ts +160 -0
- package/src/mnemopi/index.ts +3 -0
- package/src/mnemopi/state.ts +549 -0
- package/src/modes/acp/acp-agent.ts +2292 -0
- package/src/modes/acp/acp-client-bridge.ts +154 -0
- package/src/modes/acp/acp-event-mapper.ts +929 -0
- package/src/modes/acp/acp-mode.ts +23 -0
- package/src/modes/acp/index.ts +2 -0
- package/src/modes/acp/terminal-auth.ts +37 -0
- package/src/modes/components/agent-dashboard.ts +1201 -0
- package/src/modes/components/assistant-message.ts +309 -0
- package/src/modes/components/bash-execution.ts +220 -0
- package/src/modes/components/bordered-loader.ts +41 -0
- package/src/modes/components/branch-summary-message.ts +45 -0
- package/src/modes/components/btw-panel.ts +104 -0
- package/src/modes/components/compaction-summary-message.ts +51 -0
- package/src/modes/components/copy-selector.ts +249 -0
- package/src/modes/components/countdown-timer.ts +75 -0
- package/src/modes/components/custom-editor.ts +267 -0
- package/src/modes/components/custom-message.ts +65 -0
- package/src/modes/components/diff.ts +266 -0
- package/src/modes/components/dynamic-border.ts +25 -0
- package/src/modes/components/error-banner.ts +33 -0
- package/src/modes/components/eval-execution.ts +158 -0
- package/src/modes/components/execution-shared.ts +102 -0
- package/src/modes/components/extensions/extension-dashboard.ts +396 -0
- package/src/modes/components/extensions/extension-list.ts +502 -0
- package/src/modes/components/extensions/index.ts +9 -0
- package/src/modes/components/extensions/inspector-panel.ts +317 -0
- package/src/modes/components/extensions/state-manager.ts +632 -0
- package/src/modes/components/extensions/types.ts +186 -0
- package/src/modes/components/footer.ts +272 -0
- package/src/modes/components/history-search.ts +280 -0
- package/src/modes/components/hook-editor.ts +159 -0
- package/src/modes/components/hook-input.ts +79 -0
- package/src/modes/components/hook-message.ts +68 -0
- package/src/modes/components/hook-selector.ts +660 -0
- package/src/modes/components/index.ts +38 -0
- package/src/modes/components/keybinding-hints.ts +65 -0
- package/src/modes/components/login-dialog.ts +164 -0
- package/src/modes/components/mcp-add-wizard.ts +1340 -0
- package/src/modes/components/message-frame.ts +88 -0
- package/src/modes/components/model-selector.ts +1213 -0
- package/src/modes/components/oauth-selector.ts +342 -0
- package/src/modes/components/omfg-panel.ts +141 -0
- package/src/modes/components/plugin-selector.ts +95 -0
- package/src/modes/components/plugin-settings.ts +728 -0
- package/src/modes/components/queue-mode-selector.ts +56 -0
- package/src/modes/components/read-tool-group.ts +267 -0
- package/src/modes/components/segment-track.ts +52 -0
- package/src/modes/components/session-observer-overlay.ts +852 -0
- package/src/modes/components/session-selector.ts +571 -0
- package/src/modes/components/settings-defs.ts +189 -0
- package/src/modes/components/settings-selector.ts +647 -0
- package/src/modes/components/show-images-selector.ts +45 -0
- package/src/modes/components/skill-message.ts +90 -0
- package/src/modes/components/status-line/context-thresholds.ts +79 -0
- package/src/modes/components/status-line/git-utils.ts +42 -0
- package/src/modes/components/status-line/index.ts +4 -0
- package/src/modes/components/status-line/presets.ts +106 -0
- package/src/modes/components/status-line/segments.ts +590 -0
- package/src/modes/components/status-line/separators.ts +55 -0
- package/src/modes/components/status-line/token-rate.ts +66 -0
- package/src/modes/components/status-line/types.ts +93 -0
- package/src/modes/components/status-line.ts +794 -0
- package/src/modes/components/theme-selector.ts +63 -0
- package/src/modes/components/thinking-selector.ts +52 -0
- package/src/modes/components/tiny-title-download-progress.ts +90 -0
- package/src/modes/components/tips.txt +18 -0
- package/src/modes/components/todo-reminder.ts +40 -0
- package/src/modes/components/tool-execution.ts +1017 -0
- package/src/modes/components/transcript-container.ts +181 -0
- package/src/modes/components/tree-selector.ts +978 -0
- package/src/modes/components/ttsr-notification.ts +80 -0
- package/src/modes/components/user-message-selector.ts +227 -0
- package/src/modes/components/user-message.ts +52 -0
- package/src/modes/components/visual-truncate.ts +63 -0
- package/src/modes/components/welcome.ts +435 -0
- package/src/modes/controllers/btw-controller.ts +105 -0
- package/src/modes/controllers/command-controller-shared.ts +108 -0
- package/src/modes/controllers/command-controller.ts +1546 -0
- package/src/modes/controllers/event-controller.ts +926 -0
- package/src/modes/controllers/extension-ui-controller.ts +933 -0
- package/src/modes/controllers/input-controller.ts +947 -0
- package/src/modes/controllers/mcp-command-controller.ts +1938 -0
- package/src/modes/controllers/omfg-controller.ts +283 -0
- package/src/modes/controllers/omfg-rule.ts +647 -0
- package/src/modes/controllers/selector-controller.ts +1117 -0
- package/src/modes/controllers/ssh-command-controller.ts +384 -0
- package/src/modes/controllers/todo-command-controller.ts +485 -0
- package/src/modes/data/emojis.json +1 -0
- package/src/modes/emoji-autocomplete.ts +285 -0
- package/src/modes/gradient-highlight.ts +87 -0
- package/src/modes/image-references.ts +111 -0
- package/src/modes/index.ts +34 -0
- package/src/modes/interactive-mode.ts +3151 -0
- package/src/modes/internal-url-autocomplete.ts +143 -0
- package/src/modes/loop-limit.ts +140 -0
- package/src/modes/magic-keywords.ts +20 -0
- package/src/modes/markdown-prose.ts +247 -0
- package/src/modes/oauth-manual-input.ts +42 -0
- package/src/modes/orchestrate.ts +42 -0
- package/src/modes/print-mode.ts +126 -0
- package/src/modes/prompt-action-autocomplete.ts +260 -0
- package/src/modes/rpc/host-tools.ts +186 -0
- package/src/modes/rpc/host-uris.ts +235 -0
- package/src/modes/rpc/rpc-client.ts +812 -0
- package/src/modes/rpc/rpc-mode.ts +862 -0
- package/src/modes/rpc/rpc-types.ts +378 -0
- package/src/modes/runtime-init.ts +116 -0
- package/src/modes/session-observer-registry.ts +146 -0
- package/src/modes/setup-wizard/index.ts +88 -0
- package/src/modes/setup-wizard/scenes/channels.ts +104 -0
- package/src/modes/setup-wizard/scenes/glyph.ts +96 -0
- package/src/modes/setup-wizard/scenes/outro.ts +35 -0
- package/src/modes/setup-wizard/scenes/providers.ts +70 -0
- package/src/modes/setup-wizard/scenes/sign-in.ts +213 -0
- package/src/modes/setup-wizard/scenes/splash.ts +201 -0
- package/src/modes/setup-wizard/scenes/telegram.ts +695 -0
- package/src/modes/setup-wizard/scenes/theme.ts +299 -0
- package/src/modes/setup-wizard/scenes/types.ts +48 -0
- package/src/modes/setup-wizard/scenes/web-search.ts +128 -0
- package/src/modes/setup-wizard/wizard-overlay.ts +275 -0
- package/src/modes/shared.ts +47 -0
- package/src/modes/theme/dark.json +95 -0
- package/src/modes/theme/defaults/alabaster.json +93 -0
- package/src/modes/theme/defaults/amethyst.json +96 -0
- package/src/modes/theme/defaults/anthracite.json +93 -0
- package/src/modes/theme/defaults/basalt.json +91 -0
- package/src/modes/theme/defaults/birch.json +95 -0
- package/src/modes/theme/defaults/dark-abyss.json +91 -0
- package/src/modes/theme/defaults/dark-arctic.json +104 -0
- package/src/modes/theme/defaults/dark-aurora.json +95 -0
- package/src/modes/theme/defaults/dark-catppuccin.json +107 -0
- package/src/modes/theme/defaults/dark-cavern.json +91 -0
- package/src/modes/theme/defaults/dark-copper.json +95 -0
- package/src/modes/theme/defaults/dark-cosmos.json +90 -0
- package/src/modes/theme/defaults/dark-cyberpunk.json +102 -0
- package/src/modes/theme/defaults/dark-dracula.json +98 -0
- package/src/modes/theme/defaults/dark-eclipse.json +91 -0
- package/src/modes/theme/defaults/dark-ember.json +95 -0
- package/src/modes/theme/defaults/dark-equinox.json +90 -0
- package/src/modes/theme/defaults/dark-forest.json +96 -0
- package/src/modes/theme/defaults/dark-github.json +105 -0
- package/src/modes/theme/defaults/dark-gruvbox.json +112 -0
- package/src/modes/theme/defaults/dark-lavender.json +95 -0
- package/src/modes/theme/defaults/dark-lunar.json +89 -0
- package/src/modes/theme/defaults/dark-midnight.json +95 -0
- package/src/modes/theme/defaults/dark-monochrome.json +94 -0
- package/src/modes/theme/defaults/dark-monokai.json +98 -0
- package/src/modes/theme/defaults/dark-nebula.json +90 -0
- package/src/modes/theme/defaults/dark-nord.json +97 -0
- package/src/modes/theme/defaults/dark-ocean.json +101 -0
- package/src/modes/theme/defaults/dark-one.json +100 -0
- package/src/modes/theme/defaults/dark-poimandres.json +142 -0
- package/src/modes/theme/defaults/dark-rainforest.json +91 -0
- package/src/modes/theme/defaults/dark-reef.json +91 -0
- package/src/modes/theme/defaults/dark-retro.json +92 -0
- package/src/modes/theme/defaults/dark-rose-pine.json +96 -0
- package/src/modes/theme/defaults/dark-sakura.json +95 -0
- package/src/modes/theme/defaults/dark-slate.json +95 -0
- package/src/modes/theme/defaults/dark-solarized.json +97 -0
- package/src/modes/theme/defaults/dark-solstice.json +90 -0
- package/src/modes/theme/defaults/dark-starfall.json +91 -0
- package/src/modes/theme/defaults/dark-sunset.json +99 -0
- package/src/modes/theme/defaults/dark-swamp.json +90 -0
- package/src/modes/theme/defaults/dark-synthwave.json +103 -0
- package/src/modes/theme/defaults/dark-taiga.json +91 -0
- package/src/modes/theme/defaults/dark-terminal.json +95 -0
- package/src/modes/theme/defaults/dark-tokyo-night.json +101 -0
- package/src/modes/theme/defaults/dark-tundra.json +91 -0
- package/src/modes/theme/defaults/dark-twilight.json +91 -0
- package/src/modes/theme/defaults/dark-volcanic.json +91 -0
- package/src/modes/theme/defaults/graphite.json +92 -0
- package/src/modes/theme/defaults/index.ts +199 -0
- package/src/modes/theme/defaults/light-arctic.json +107 -0
- package/src/modes/theme/defaults/light-aurora-day.json +91 -0
- package/src/modes/theme/defaults/light-canyon.json +91 -0
- package/src/modes/theme/defaults/light-catppuccin.json +106 -0
- package/src/modes/theme/defaults/light-cirrus.json +90 -0
- package/src/modes/theme/defaults/light-coral.json +95 -0
- package/src/modes/theme/defaults/light-cyberpunk.json +96 -0
- package/src/modes/theme/defaults/light-dawn.json +90 -0
- package/src/modes/theme/defaults/light-dunes.json +91 -0
- package/src/modes/theme/defaults/light-eucalyptus.json +95 -0
- package/src/modes/theme/defaults/light-forest.json +100 -0
- package/src/modes/theme/defaults/light-frost.json +95 -0
- package/src/modes/theme/defaults/light-github.json +115 -0
- package/src/modes/theme/defaults/light-glacier.json +91 -0
- package/src/modes/theme/defaults/light-gruvbox.json +108 -0
- package/src/modes/theme/defaults/light-haze.json +90 -0
- package/src/modes/theme/defaults/light-honeycomb.json +95 -0
- package/src/modes/theme/defaults/light-lagoon.json +91 -0
- package/src/modes/theme/defaults/light-lavender.json +95 -0
- package/src/modes/theme/defaults/light-meadow.json +91 -0
- package/src/modes/theme/defaults/light-mint.json +95 -0
- package/src/modes/theme/defaults/light-monochrome.json +101 -0
- package/src/modes/theme/defaults/light-ocean.json +99 -0
- package/src/modes/theme/defaults/light-one.json +99 -0
- package/src/modes/theme/defaults/light-opal.json +91 -0
- package/src/modes/theme/defaults/light-orchard.json +91 -0
- package/src/modes/theme/defaults/light-paper.json +95 -0
- package/src/modes/theme/defaults/light-poimandres.json +142 -0
- package/src/modes/theme/defaults/light-prism.json +90 -0
- package/src/modes/theme/defaults/light-retro.json +98 -0
- package/src/modes/theme/defaults/light-sand.json +95 -0
- package/src/modes/theme/defaults/light-savanna.json +91 -0
- package/src/modes/theme/defaults/light-solarized.json +102 -0
- package/src/modes/theme/defaults/light-soleil.json +90 -0
- package/src/modes/theme/defaults/light-sunset.json +99 -0
- package/src/modes/theme/defaults/light-synthwave.json +98 -0
- package/src/modes/theme/defaults/light-tokyo-night.json +111 -0
- package/src/modes/theme/defaults/light-wetland.json +91 -0
- package/src/modes/theme/defaults/light-zenith.json +89 -0
- package/src/modes/theme/defaults/limestone.json +94 -0
- package/src/modes/theme/defaults/mahogany.json +97 -0
- package/src/modes/theme/defaults/marble.json +93 -0
- package/src/modes/theme/defaults/obsidian.json +91 -0
- package/src/modes/theme/defaults/onyx.json +91 -0
- package/src/modes/theme/defaults/pearl.json +93 -0
- package/src/modes/theme/defaults/porcelain.json +91 -0
- package/src/modes/theme/defaults/quartz.json +96 -0
- package/src/modes/theme/defaults/sandstone.json +95 -0
- package/src/modes/theme/defaults/titanium.json +90 -0
- package/src/modes/theme/light.json +93 -0
- package/src/modes/theme/mermaid-cache.ts +29 -0
- package/src/modes/theme/shimmer.ts +224 -0
- package/src/modes/theme/theme-schema.json +459 -0
- package/src/modes/theme/theme.ts +2569 -0
- package/src/modes/turn-budget.ts +31 -0
- package/src/modes/types.ts +338 -0
- package/src/modes/ultrathink.ts +41 -0
- package/src/modes/utils/context-usage.ts +335 -0
- package/src/modes/utils/copy-targets.ts +254 -0
- package/src/modes/utils/hotkeys-markdown.ts +60 -0
- package/src/modes/utils/keybinding-matchers.ts +51 -0
- package/src/modes/utils/tools-markdown.ts +27 -0
- package/src/modes/utils/ui-helpers.ts +772 -0
- package/src/modes/workflow.ts +42 -0
- package/src/plan-mode/approved-plan.ts +163 -0
- package/src/plan-mode/plan-handoff.ts +37 -0
- package/src/plan-mode/plan-protection.ts +31 -0
- package/src/plan-mode/state.ts +6 -0
- package/src/priority.json +41 -0
- package/src/prompts/agents/designer.md +66 -0
- package/src/prompts/agents/explore.md +58 -0
- package/src/prompts/agents/frontmatter.md +11 -0
- package/src/prompts/agents/init.md +33 -0
- package/src/prompts/agents/librarian.md +120 -0
- package/src/prompts/agents/oracle.md +55 -0
- package/src/prompts/agents/plan.md +48 -0
- package/src/prompts/agents/reviewer.md +140 -0
- package/src/prompts/agents/task.md +16 -0
- package/src/prompts/ci-green-request.md +38 -0
- package/src/prompts/dry-balance-bench.md +8 -0
- package/src/prompts/goals/goal-budget-limit.md +16 -0
- package/src/prompts/goals/goal-continuation.md +28 -0
- package/src/prompts/goals/goal-mode-active.md +23 -0
- package/src/prompts/memories/consolidation.md +35 -0
- package/src/prompts/memories/identity_review.md +38 -0
- package/src/prompts/memories/post_turn_review.md +37 -0
- package/src/prompts/memories/read-path.md +16 -0
- package/src/prompts/memories/stage_one_input.md +6 -0
- package/src/prompts/memories/stage_one_system.md +21 -0
- package/src/prompts/review-custom-request.md +22 -0
- package/src/prompts/review-headless-request.md +16 -0
- package/src/prompts/review-request.md +69 -0
- package/src/prompts/steering/user-interjection.md +10 -0
- package/src/prompts/system/agent-creation-architect.md +50 -0
- package/src/prompts/system/agent-creation-user.md +6 -0
- package/src/prompts/system/auto-continue.md +1 -0
- package/src/prompts/system/auto-thinking-difficulty-local.md +14 -0
- package/src/prompts/system/auto-thinking-difficulty.md +12 -0
- package/src/prompts/system/btw-user.md +8 -0
- package/src/prompts/system/commit-message-system.md +2 -0
- package/src/prompts/system/custom-system-prompt.md +64 -0
- package/src/prompts/system/eager-todo.md +13 -0
- package/src/prompts/system/empty-stop-retry.md +6 -0
- package/src/prompts/system/irc-incoming.md +8 -0
- package/src/prompts/system/memory-consolidation-system.md +8 -0
- package/src/prompts/system/memory-extraction-system.md +26 -0
- package/src/prompts/system/omfg-user.md +51 -0
- package/src/prompts/system/orchestrate-notice.md +40 -0
- package/src/prompts/system/plan-mode-active.md +116 -0
- package/src/prompts/system/plan-mode-approved.md +25 -0
- package/src/prompts/system/plan-mode-compact-instructions.md +16 -0
- package/src/prompts/system/plan-mode-reference.md +11 -0
- package/src/prompts/system/plan-mode-subagent.md +34 -0
- package/src/prompts/system/plan-mode-tool-decision-reminder.md +9 -0
- package/src/prompts/system/project-prompt.md +52 -0
- package/src/prompts/system/subagent-system-prompt.md +69 -0
- package/src/prompts/system/subagent-user-prompt.md +3 -0
- package/src/prompts/system/subagent-yield-reminder.md +12 -0
- package/src/prompts/system/system-prompt.md +275 -0
- package/src/prompts/system/tiny-title-system.md +8 -0
- package/src/prompts/system/title-system.md +3 -0
- package/src/prompts/system/ttsr-interrupt.md +7 -0
- package/src/prompts/system/ttsr-tool-reminder.md +5 -0
- package/src/prompts/system/ultrathink-notice.md +3 -0
- package/src/prompts/system/web-search.md +25 -0
- package/src/prompts/system/workflow-notice.md +70 -0
- package/src/prompts/tools/apply-patch.md +65 -0
- package/src/prompts/tools/ask.md +30 -0
- package/src/prompts/tools/ast-edit.md +39 -0
- package/src/prompts/tools/ast-grep.md +42 -0
- package/src/prompts/tools/async-result.md +8 -0
- package/src/prompts/tools/bash.md +39 -0
- package/src/prompts/tools/browser.md +73 -0
- package/src/prompts/tools/checkpoint.md +16 -0
- package/src/prompts/tools/debug.md +34 -0
- package/src/prompts/tools/eval.md +89 -0
- package/src/prompts/tools/find.md +37 -0
- package/src/prompts/tools/github.md +20 -0
- package/src/prompts/tools/goal.md +18 -0
- package/src/prompts/tools/image-gen.md +7 -0
- package/src/prompts/tools/inspect-image-system.md +20 -0
- package/src/prompts/tools/inspect-image.md +32 -0
- package/src/prompts/tools/irc.md +49 -0
- package/src/prompts/tools/job.md +19 -0
- package/src/prompts/tools/lsp.md +42 -0
- package/src/prompts/tools/memory-edit.md +8 -0
- package/src/prompts/tools/patch.md +70 -0
- package/src/prompts/tools/read.md +86 -0
- package/src/prompts/tools/recall.md +5 -0
- package/src/prompts/tools/reflect.md +5 -0
- package/src/prompts/tools/render-mermaid.md +9 -0
- package/src/prompts/tools/replace.md +36 -0
- package/src/prompts/tools/resolve.md +9 -0
- package/src/prompts/tools/retain.md +6 -0
- package/src/prompts/tools/rewind.md +13 -0
- package/src/prompts/tools/search-tool-bm25.md +40 -0
- package/src/prompts/tools/search.md +25 -0
- package/src/prompts/tools/ssh.md +35 -0
- package/src/prompts/tools/task-summary.md +28 -0
- package/src/prompts/tools/task.md +80 -0
- package/src/prompts/tools/todo.md +58 -0
- package/src/prompts/tools/web-search.md +10 -0
- package/src/prompts/tools/write.md +14 -0
- package/src/registry/agent-registry.ts +140 -0
- package/src/sdk.ts +2374 -0
- package/src/secrets/index.ts +116 -0
- package/src/secrets/obfuscator.ts +277 -0
- package/src/secrets/regex.ts +21 -0
- package/src/session/agent-session.ts +9765 -0
- package/src/session/agent-storage.ts +455 -0
- package/src/session/artifacts.ts +135 -0
- package/src/session/auth-broker-config.ts +102 -0
- package/src/session/auth-storage.ts +27 -0
- package/src/session/blob-store.ts +255 -0
- package/src/session/client-bridge.ts +85 -0
- package/src/session/history-storage.ts +348 -0
- package/src/session/indexed-session-storage.ts +430 -0
- package/src/session/messages.ts +575 -0
- package/src/session/redis-session-storage.ts +170 -0
- package/src/session/session-dump-format.ts +209 -0
- package/src/session/session-manager.ts +3541 -0
- package/src/session/session-storage.ts +529 -0
- package/src/session/shake-types.ts +43 -0
- package/src/session/sql-session-storage.ts +314 -0
- package/src/session/streaming-output.ts +1093 -0
- package/src/session/tool-choice-queue.ts +213 -0
- package/src/session/yield-queue.ts +155 -0
- package/src/slash-commands/acp-builtins.ts +46 -0
- package/src/slash-commands/builtin-registry.ts +1726 -0
- package/src/slash-commands/headless-plan.ts +142 -0
- package/src/slash-commands/helpers/context-report.ts +39 -0
- package/src/slash-commands/helpers/format.ts +46 -0
- package/src/slash-commands/helpers/marketplace-manager.ts +25 -0
- package/src/slash-commands/helpers/mcp.ts +532 -0
- package/src/slash-commands/helpers/parse.ts +85 -0
- package/src/slash-commands/helpers/ssh.ts +195 -0
- package/src/slash-commands/helpers/todo.ts +279 -0
- package/src/slash-commands/helpers/usage-report.ts +93 -0
- package/src/slash-commands/marketplace-install-parser.ts +99 -0
- package/src/slash-commands/types.ts +139 -0
- package/src/ssh/config-writer.ts +183 -0
- package/src/ssh/connection-manager.ts +482 -0
- package/src/ssh/ssh-executor.ts +133 -0
- package/src/ssh/sshfs-mount.ts +140 -0
- package/src/ssh/utils.ts +8 -0
- package/src/stt/downloader.ts +71 -0
- package/src/stt/index.ts +3 -0
- package/src/stt/recorder.ts +351 -0
- package/src/stt/setup.ts +52 -0
- package/src/stt/stt-controller.ts +160 -0
- package/src/stt/transcribe.py +70 -0
- package/src/stt/transcriber.ts +91 -0
- package/src/system-prompt.ts +591 -0
- package/src/task/agents.ts +167 -0
- package/src/task/commands.ts +131 -0
- package/src/task/discovery.ts +129 -0
- package/src/task/executor.ts +1659 -0
- package/src/task/index.ts +1401 -0
- package/src/task/name-generator.ts +1577 -0
- package/src/task/output-manager.ts +99 -0
- package/src/task/parallel.ts +116 -0
- package/src/task/prometheus-command.ts +26 -0
- package/src/task/render.ts +1211 -0
- package/src/task/repair-args.ts +117 -0
- package/src/task/simple-mode.ts +27 -0
- package/src/task/subprocess-tool-registry.ts +88 -0
- package/src/task/types.ts +320 -0
- package/src/task/worktree.ts +506 -0
- package/src/telemetry-export.ts +127 -0
- package/src/thinking.ts +165 -0
- package/src/tiny/compiled-runtime.ts +179 -0
- package/src/tiny/device.ts +111 -0
- package/src/tiny/dtype.ts +101 -0
- package/src/tiny/models.ts +242 -0
- package/src/tiny/text.ts +165 -0
- package/src/tiny/title-client.ts +491 -0
- package/src/tiny/title-protocol.ts +56 -0
- package/src/tiny/worker.ts +566 -0
- package/src/tool-discovery/mode.ts +24 -0
- package/src/tool-discovery/tool-index.ts +256 -0
- package/src/tools/approval.ts +189 -0
- package/src/tools/archive-reader.ts +629 -0
- package/src/tools/ask.ts +879 -0
- package/src/tools/ast-edit.ts +595 -0
- package/src/tools/ast-grep.ts +458 -0
- package/src/tools/auto-generated-guard.ts +305 -0
- package/src/tools/bash-command-fixup.ts +37 -0
- package/src/tools/bash-interactive.ts +388 -0
- package/src/tools/bash-interceptor.ts +67 -0
- package/src/tools/bash-pty-selection.ts +14 -0
- package/src/tools/bash-skill-urls.ts +248 -0
- package/src/tools/bash.ts +1238 -0
- package/src/tools/browser/attach.ts +175 -0
- package/src/tools/browser/launch.ts +651 -0
- package/src/tools/browser/readable.ts +95 -0
- package/src/tools/browser/registry.ts +194 -0
- package/src/tools/browser/render.ts +213 -0
- package/src/tools/browser/tab-protocol.ts +105 -0
- package/src/tools/browser/tab-supervisor.ts +577 -0
- package/src/tools/browser/tab-worker-entry.ts +21 -0
- package/src/tools/browser/tab-worker.ts +1058 -0
- package/src/tools/browser.ts +316 -0
- package/src/tools/checkpoint.ts +136 -0
- package/src/tools/conflict-detect.ts +672 -0
- package/src/tools/context.ts +39 -0
- package/src/tools/debug.ts +1052 -0
- package/src/tools/eval-backends.ts +27 -0
- package/src/tools/eval-render.ts +765 -0
- package/src/tools/eval.ts +568 -0
- package/src/tools/fetch.ts +1586 -0
- package/src/tools/file-recorder.ts +35 -0
- package/src/tools/find.ts +571 -0
- package/src/tools/fs-cache-invalidation.ts +28 -0
- package/src/tools/gh-format.ts +12 -0
- package/src/tools/gh-renderer.ts +428 -0
- package/src/tools/gh.ts +3582 -0
- package/src/tools/github-cache.ts +548 -0
- package/src/tools/grouped-file-output.ts +103 -0
- package/src/tools/image-gen.ts +1448 -0
- package/src/tools/index.ts +516 -0
- package/src/tools/inspect-image-renderer.ts +103 -0
- package/src/tools/inspect-image.ts +166 -0
- package/src/tools/irc.ts +294 -0
- package/src/tools/job.ts +521 -0
- package/src/tools/json-tree.ts +243 -0
- package/src/tools/jtd-to-json-schema.ts +219 -0
- package/src/tools/jtd-to-typescript.ts +136 -0
- package/src/tools/jtd-utils.ts +102 -0
- package/src/tools/list-limit.ts +40 -0
- package/src/tools/match-line-format.ts +20 -0
- package/src/tools/memory-edit.ts +59 -0
- package/src/tools/memory-recall.ts +104 -0
- package/src/tools/memory-reflect.ts +92 -0
- package/src/tools/memory-render.ts +185 -0
- package/src/tools/memory-retain.ts +91 -0
- package/src/tools/output-meta.ts +754 -0
- package/src/tools/output-schema-validator.ts +132 -0
- package/src/tools/path-utils.ts +1031 -0
- package/src/tools/plan-mode-guard.ts +81 -0
- package/src/tools/puppeteer/00_stealth_tampering.txt +63 -0
- package/src/tools/puppeteer/01_stealth_activity.txt +20 -0
- package/src/tools/puppeteer/02_stealth_hairline.txt +11 -0
- package/src/tools/puppeteer/03_stealth_botd.txt +384 -0
- package/src/tools/puppeteer/04_stealth_iframe.txt +81 -0
- package/src/tools/puppeteer/05_stealth_webgl.txt +75 -0
- package/src/tools/puppeteer/06_stealth_screen.txt +72 -0
- package/src/tools/puppeteer/07_stealth_fonts.txt +97 -0
- package/src/tools/puppeteer/08_stealth_audio.txt +51 -0
- package/src/tools/puppeteer/09_stealth_locale.txt +46 -0
- package/src/tools/puppeteer/10_stealth_plugins.txt +206 -0
- package/src/tools/puppeteer/11_stealth_hardware.txt +8 -0
- package/src/tools/puppeteer/12_stealth_codecs.txt +40 -0
- package/src/tools/puppeteer/13_stealth_worker.txt +74 -0
- package/src/tools/read.ts +2557 -0
- package/src/tools/render-mermaid.ts +69 -0
- package/src/tools/render-utils.ts +836 -0
- package/src/tools/renderers.ts +75 -0
- package/src/tools/report-tool-issue.ts +528 -0
- package/src/tools/resolve.ts +259 -0
- package/src/tools/review.ts +253 -0
- package/src/tools/search-tool-bm25.ts +338 -0
- package/src/tools/search.ts +1475 -0
- package/src/tools/sqlite-reader.ts +819 -0
- package/src/tools/ssh.ts +347 -0
- package/src/tools/todo.ts +856 -0
- package/src/tools/tool-errors.ts +62 -0
- package/src/tools/tool-result.ts +94 -0
- package/src/tools/tool-timeouts.ts +30 -0
- package/src/tools/tts.ts +133 -0
- package/src/tools/write.ts +1085 -0
- package/src/tools/yield.ts +260 -0
- package/src/tui/code-cell.ts +221 -0
- package/src/tui/file-list.ts +55 -0
- package/src/tui/hyperlink.ts +161 -0
- package/src/tui/index.ts +12 -0
- package/src/tui/output-block.ts +288 -0
- package/src/tui/status-line.ts +50 -0
- package/src/tui/tree-list.ts +84 -0
- package/src/tui/types.ts +15 -0
- package/src/tui/utils.ts +103 -0
- package/src/utils/changelog.ts +106 -0
- package/src/utils/clipboard.ts +193 -0
- package/src/utils/command-args.ts +76 -0
- package/src/utils/commit-message-generator.ts +142 -0
- package/src/utils/edit-mode.ts +41 -0
- package/src/utils/event-bus.ts +33 -0
- package/src/utils/external-editor.ts +65 -0
- package/src/utils/file-display-mode.ts +45 -0
- package/src/utils/file-mentions.ts +280 -0
- package/src/utils/git.ts +1538 -0
- package/src/utils/image-loading.ts +102 -0
- package/src/utils/image-resize.ts +309 -0
- package/src/utils/jj.ts +248 -0
- package/src/utils/lang-from-path.ts +239 -0
- package/src/utils/markit.ts +89 -0
- package/src/utils/open.ts +55 -0
- package/src/utils/session-color.ts +68 -0
- package/src/utils/shell-snapshot.ts +187 -0
- package/src/utils/sixel.ts +69 -0
- package/src/utils/title-generator.ts +353 -0
- package/src/utils/tool-choice.ts +33 -0
- package/src/utils/tools-manager.ts +363 -0
- package/src/web/kagi.ts +302 -0
- package/src/web/parallel.ts +349 -0
- package/src/web/scrapers/artifacthub.ts +207 -0
- package/src/web/scrapers/arxiv.ts +83 -0
- package/src/web/scrapers/aur.ts +162 -0
- package/src/web/scrapers/biorxiv.ts +133 -0
- package/src/web/scrapers/bluesky.ts +262 -0
- package/src/web/scrapers/brew.ts +172 -0
- package/src/web/scrapers/cheatsh.ts +68 -0
- package/src/web/scrapers/chocolatey.ts +196 -0
- package/src/web/scrapers/choosealicense.ts +95 -0
- package/src/web/scrapers/cisa-kev.ts +87 -0
- package/src/web/scrapers/clojars.ts +154 -0
- package/src/web/scrapers/coingecko.ts +177 -0
- package/src/web/scrapers/crates-io.ts +97 -0
- package/src/web/scrapers/crossref.ts +136 -0
- package/src/web/scrapers/devto.ts +147 -0
- package/src/web/scrapers/discogs.ts +306 -0
- package/src/web/scrapers/discourse.ts +197 -0
- package/src/web/scrapers/dockerhub.ts +138 -0
- package/src/web/scrapers/docs-rs.ts +653 -0
- package/src/web/scrapers/fdroid.ts +134 -0
- package/src/web/scrapers/firefox-addons.ts +191 -0
- package/src/web/scrapers/flathub.ts +223 -0
- package/src/web/scrapers/github-gist.ts +58 -0
- package/src/web/scrapers/github.ts +452 -0
- package/src/web/scrapers/gitlab.ts +401 -0
- package/src/web/scrapers/go-pkg.ts +266 -0
- package/src/web/scrapers/hackage.ts +140 -0
- package/src/web/scrapers/hackernews.ts +189 -0
- package/src/web/scrapers/hex.ts +105 -0
- package/src/web/scrapers/huggingface.ts +321 -0
- package/src/web/scrapers/iacr.ts +89 -0
- package/src/web/scrapers/index.ts +252 -0
- package/src/web/scrapers/jetbrains-marketplace.ts +159 -0
- package/src/web/scrapers/lemmy.ts +203 -0
- package/src/web/scrapers/lobsters.ts +175 -0
- package/src/web/scrapers/mastodon.ts +292 -0
- package/src/web/scrapers/maven.ts +138 -0
- package/src/web/scrapers/mdn.ts +173 -0
- package/src/web/scrapers/metacpan.ts +222 -0
- package/src/web/scrapers/musicbrainz.ts +250 -0
- package/src/web/scrapers/npm.ts +98 -0
- package/src/web/scrapers/nuget.ts +183 -0
- package/src/web/scrapers/nvd.ts +222 -0
- package/src/web/scrapers/ollama.ts +239 -0
- package/src/web/scrapers/open-vsx.ts +106 -0
- package/src/web/scrapers/opencorporates.ts +292 -0
- package/src/web/scrapers/openlibrary.ts +336 -0
- package/src/web/scrapers/orcid.ts +286 -0
- package/src/web/scrapers/osv.ts +176 -0
- package/src/web/scrapers/packagist.ts +160 -0
- package/src/web/scrapers/pub-dev.ts +143 -0
- package/src/web/scrapers/pubmed.ts +211 -0
- package/src/web/scrapers/pypi.ts +112 -0
- package/src/web/scrapers/rawg.ts +110 -0
- package/src/web/scrapers/readthedocs.ts +120 -0
- package/src/web/scrapers/reddit.ts +95 -0
- package/src/web/scrapers/repology.ts +251 -0
- package/src/web/scrapers/rfc.ts +201 -0
- package/src/web/scrapers/rubygems.ts +103 -0
- package/src/web/scrapers/searchcode.ts +189 -0
- package/src/web/scrapers/sec-edgar.ts +261 -0
- package/src/web/scrapers/semantic-scholar.ts +171 -0
- package/src/web/scrapers/snapcraft.ts +187 -0
- package/src/web/scrapers/sourcegraph.ts +336 -0
- package/src/web/scrapers/spdx.ts +108 -0
- package/src/web/scrapers/spotify.ts +198 -0
- package/src/web/scrapers/stackoverflow.ts +120 -0
- package/src/web/scrapers/terraform.ts +277 -0
- package/src/web/scrapers/tldr.ts +47 -0
- package/src/web/scrapers/twitter.ts +93 -0
- package/src/web/scrapers/types.ts +318 -0
- package/src/web/scrapers/utils.ts +109 -0
- package/src/web/scrapers/vimeo.ts +133 -0
- package/src/web/scrapers/vscode-marketplace.ts +187 -0
- package/src/web/scrapers/w3c.ts +156 -0
- package/src/web/scrapers/wikidata.ts +344 -0
- package/src/web/scrapers/wikipedia.ts +84 -0
- package/src/web/scrapers/youtube.ts +319 -0
- package/src/web/search/index.ts +292 -0
- package/src/web/search/provider.ts +157 -0
- package/src/web/search/providers/anthropic.ts +302 -0
- package/src/web/search/providers/base.ts +88 -0
- package/src/web/search/providers/brave.ts +149 -0
- package/src/web/search/providers/codex.ts +557 -0
- package/src/web/search/providers/exa.ts +309 -0
- package/src/web/search/providers/gemini.ts +455 -0
- package/src/web/search/providers/jina.ts +101 -0
- package/src/web/search/providers/kagi.ts +79 -0
- package/src/web/search/providers/kimi.ts +171 -0
- package/src/web/search/providers/parallel.ts +210 -0
- package/src/web/search/providers/perplexity.ts +579 -0
- package/src/web/search/providers/searxng.ts +309 -0
- package/src/web/search/providers/synthetic.ts +110 -0
- package/src/web/search/providers/tavily.ts +173 -0
- package/src/web/search/providers/utils.ts +128 -0
- package/src/web/search/providers/zai.ts +320 -0
- package/src/web/search/render.ts +267 -0
- package/src/web/search/types.ts +478 -0
- package/src/web/search/utils.ts +17 -0
- package/src/workspace-tree.ts +286 -0
|
@@ -0,0 +1,3151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive mode for the coding agent.
|
|
3
|
+
* Handles TUI rendering and user interaction, delegating business logic to AgentSession.
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from "node:fs/promises";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import {
|
|
8
|
+
type Agent,
|
|
9
|
+
type AgentMessage,
|
|
10
|
+
type AgentToolResult,
|
|
11
|
+
EventLoopKeepalive,
|
|
12
|
+
ThinkingLevel,
|
|
13
|
+
} from "@prometheus-ai/agent-core";
|
|
14
|
+
import type { CompactionOutcome } from "@prometheus-ai/agent-core/compaction";
|
|
15
|
+
import {
|
|
16
|
+
type AssistantMessage,
|
|
17
|
+
type ImageContent,
|
|
18
|
+
type Message,
|
|
19
|
+
type Model,
|
|
20
|
+
modelsAreEqual,
|
|
21
|
+
type UsageReport,
|
|
22
|
+
} from "@prometheus-ai/ai";
|
|
23
|
+
import type { Component, EditorTheme, SlashCommand } from "@prometheus-ai/tui";
|
|
24
|
+
import {
|
|
25
|
+
Container,
|
|
26
|
+
clearRenderCache,
|
|
27
|
+
Loader,
|
|
28
|
+
Markdown,
|
|
29
|
+
ProcessTerminal,
|
|
30
|
+
Spacer,
|
|
31
|
+
setTerminalTextSizing,
|
|
32
|
+
TERMINAL,
|
|
33
|
+
Text,
|
|
34
|
+
TUI,
|
|
35
|
+
visibleWidth,
|
|
36
|
+
} from "@prometheus-ai/tui";
|
|
37
|
+
import {
|
|
38
|
+
APP_NAME,
|
|
39
|
+
adjustHsv,
|
|
40
|
+
formatNumber,
|
|
41
|
+
getProjectDir,
|
|
42
|
+
hsvToRgb,
|
|
43
|
+
isEnoent,
|
|
44
|
+
logger,
|
|
45
|
+
postmortem,
|
|
46
|
+
prompt,
|
|
47
|
+
setProjectDir,
|
|
48
|
+
} from "@prometheus-ai/utils";
|
|
49
|
+
import chalk from "chalk";
|
|
50
|
+
import { reset as resetCapabilities } from "../capability";
|
|
51
|
+
import { KeybindingsManager } from "../config/keybindings";
|
|
52
|
+
import { MODEL_ROLES, type ModelRole } from "../config/model-registry";
|
|
53
|
+
import { isSettingsInitialized, Settings, settings } from "../config/settings";
|
|
54
|
+
import { clearClaudePluginRootsCache } from "../discovery/helpers";
|
|
55
|
+
import type {
|
|
56
|
+
ContextUsage,
|
|
57
|
+
ExtensionUIContext,
|
|
58
|
+
ExtensionUIDialogOptions,
|
|
59
|
+
ExtensionUISelectItem,
|
|
60
|
+
ExtensionWidgetContent,
|
|
61
|
+
ExtensionWidgetOptions,
|
|
62
|
+
} from "../extensibility/extensions";
|
|
63
|
+
import type { CompactOptions } from "../extensibility/extensions/types";
|
|
64
|
+
import { BUILTIN_SLASH_COMMANDS, loadSlashCommands } from "../extensibility/slash-commands";
|
|
65
|
+
import type { Goal, GoalModeState } from "../goals/state";
|
|
66
|
+
import { resolveLocalUrlToPath } from "../internal-urls";
|
|
67
|
+
import { LSP_STARTUP_EVENT_CHANNEL, type LspStartupEvent } from "../lsp/startup-events";
|
|
68
|
+
import {
|
|
69
|
+
humanizePlanTitle,
|
|
70
|
+
type PlanApprovalDetails,
|
|
71
|
+
renameApprovedPlanFile,
|
|
72
|
+
resolvePlanTitle,
|
|
73
|
+
} from "../plan-mode/approved-plan";
|
|
74
|
+
import planModeApprovedPrompt from "../prompts/system/plan-mode-approved.md" with { type: "text" };
|
|
75
|
+
import planModeCompactInstructionsPrompt from "../prompts/system/plan-mode-compact-instructions.md" with {
|
|
76
|
+
type: "text",
|
|
77
|
+
};
|
|
78
|
+
import type { AgentSession, AgentSessionEvent, ResolvedRoleModel } from "../session/agent-session";
|
|
79
|
+
import { HistoryStorage } from "../session/history-storage";
|
|
80
|
+
import type { SessionContext, SessionManager } from "../session/session-manager";
|
|
81
|
+
import { getRecentSessions } from "../session/session-manager";
|
|
82
|
+
import type { ShakeMode } from "../session/shake-types";
|
|
83
|
+
import { formatDuration } from "../slash-commands/helpers/format";
|
|
84
|
+
import { STTController, type SttState } from "../stt";
|
|
85
|
+
import type { LspStartupServerInfo } from "../tools";
|
|
86
|
+
import { normalizeLocalScheme } from "../tools/path-utils";
|
|
87
|
+
import { setAutoQaConsentHandler } from "../tools/report-tool-issue";
|
|
88
|
+
import { type ResolveToolDetails, runResolveInvocation } from "../tools/resolve";
|
|
89
|
+
import { formatPhaseDisplayName, selectStickyTodoWindow, todoMatchesAnyDescription } from "../tools/todo";
|
|
90
|
+
import { ToolError } from "../tools/tool-errors";
|
|
91
|
+
import type { EventBus } from "../utils/event-bus";
|
|
92
|
+
import { getEditorCommand, openInEditor } from "../utils/external-editor";
|
|
93
|
+
import { getSessionAccentAnsi, getSessionAccentHex } from "../utils/session-color";
|
|
94
|
+
import { popTerminalTitle, pushTerminalTitle, setSessionTerminalTitle } from "../utils/title-generator";
|
|
95
|
+
import type { AssistantMessageComponent } from "./components/assistant-message";
|
|
96
|
+
import type { BashExecutionComponent } from "./components/bash-execution";
|
|
97
|
+
import { CustomEditor } from "./components/custom-editor";
|
|
98
|
+
import { DynamicBorder } from "./components/dynamic-border";
|
|
99
|
+
import { ErrorBannerComponent } from "./components/error-banner";
|
|
100
|
+
import type { EvalExecutionComponent } from "./components/eval-execution";
|
|
101
|
+
import type { HookEditorComponent } from "./components/hook-editor";
|
|
102
|
+
import type { HookInputComponent } from "./components/hook-input";
|
|
103
|
+
import type { HookSelectorComponent, HookSelectorSlider } from "./components/hook-selector";
|
|
104
|
+
import { StatusLineComponent } from "./components/status-line";
|
|
105
|
+
import type { ToolExecutionHandle } from "./components/tool-execution";
|
|
106
|
+
import { TranscriptContainer } from "./components/transcript-container";
|
|
107
|
+
import { WelcomeComponent, type LspServerInfo as WelcomeLspServerInfo } from "./components/welcome";
|
|
108
|
+
import { BtwController } from "./controllers/btw-controller";
|
|
109
|
+
import { CommandController } from "./controllers/command-controller";
|
|
110
|
+
import { EventController } from "./controllers/event-controller";
|
|
111
|
+
import { ExtensionUiController } from "./controllers/extension-ui-controller";
|
|
112
|
+
import { InputController } from "./controllers/input-controller";
|
|
113
|
+
import { MCPCommandController } from "./controllers/mcp-command-controller";
|
|
114
|
+
import { OmfgController } from "./controllers/omfg-controller";
|
|
115
|
+
import { SelectorController } from "./controllers/selector-controller";
|
|
116
|
+
import { SSHCommandController } from "./controllers/ssh-command-controller";
|
|
117
|
+
import { TodoCommandController } from "./controllers/todo-command-controller";
|
|
118
|
+
import {
|
|
119
|
+
consumeLoopLimitIteration,
|
|
120
|
+
createLoopLimitRuntime,
|
|
121
|
+
describeLoopLimit,
|
|
122
|
+
describeLoopLimitRuntime,
|
|
123
|
+
isLoopDurationExpired,
|
|
124
|
+
type LoopLimitRuntime,
|
|
125
|
+
parseLoopLimitArgs,
|
|
126
|
+
} from "./loop-limit";
|
|
127
|
+
import { OAuthManualInputManager } from "./oauth-manual-input";
|
|
128
|
+
import { SessionObserverRegistry } from "./session-observer-registry";
|
|
129
|
+
import { interruptHint } from "./shared";
|
|
130
|
+
import { type ShimmerPalette, shimmerSegments, shimmerText } from "./theme/shimmer";
|
|
131
|
+
import type { Theme } from "./theme/theme";
|
|
132
|
+
import {
|
|
133
|
+
getEditorTheme,
|
|
134
|
+
getMarkdownTheme,
|
|
135
|
+
getSymbolTheme,
|
|
136
|
+
onTerminalAppearanceChange,
|
|
137
|
+
onThemeChange,
|
|
138
|
+
theme,
|
|
139
|
+
} from "./theme/theme";
|
|
140
|
+
import type {
|
|
141
|
+
CompactionQueuedMessage,
|
|
142
|
+
InteractiveModeContext,
|
|
143
|
+
InteractiveModeInitOptions,
|
|
144
|
+
InteractiveSelectorDialogOptions,
|
|
145
|
+
SubmittedUserInput,
|
|
146
|
+
TodoItem,
|
|
147
|
+
TodoPhase,
|
|
148
|
+
} from "./types";
|
|
149
|
+
import { UiHelpers } from "./utils/ui-helpers";
|
|
150
|
+
|
|
151
|
+
const HINT_SHIMMER_PALETTE: ShimmerPalette = {
|
|
152
|
+
low: "dim",
|
|
153
|
+
mid: "muted",
|
|
154
|
+
high: "borderAccent",
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
interface WorkingMessageAccent {
|
|
158
|
+
main: string;
|
|
159
|
+
dim: string;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function renderWorkingMessage(message: string, accent?: WorkingMessageAccent): string {
|
|
163
|
+
const palette = accent
|
|
164
|
+
? ({
|
|
165
|
+
low: "dim",
|
|
166
|
+
mid: { ansi: accent.main },
|
|
167
|
+
high: { ansi: accent.main },
|
|
168
|
+
bold: true,
|
|
169
|
+
} satisfies ShimmerPalette)
|
|
170
|
+
: undefined;
|
|
171
|
+
const hint = interruptHint();
|
|
172
|
+
if (!message.endsWith(hint)) return shimmerText(message, theme, palette);
|
|
173
|
+
const header = message.slice(0, -hint.length);
|
|
174
|
+
const hintPalette = accent
|
|
175
|
+
? ({
|
|
176
|
+
low: "dim",
|
|
177
|
+
mid: { ansi: accent.dim },
|
|
178
|
+
high: { ansi: accent.dim },
|
|
179
|
+
} satisfies ShimmerPalette)
|
|
180
|
+
: HINT_SHIMMER_PALETTE;
|
|
181
|
+
return shimmerSegments(
|
|
182
|
+
[
|
|
183
|
+
{ text: header, palette },
|
|
184
|
+
{ text: hint, palette: hintPalette },
|
|
185
|
+
],
|
|
186
|
+
theme,
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const EDITOR_MAX_HEIGHT_MIN = 6;
|
|
191
|
+
const EDITOR_MAX_HEIGHT_MAX = 18;
|
|
192
|
+
const EDITOR_RESERVED_ROWS = 12;
|
|
193
|
+
const EDITOR_FALLBACK_ROWS = 24;
|
|
194
|
+
|
|
195
|
+
const HUD_NOTE_SUP_DIGITS: Record<string, string> = {
|
|
196
|
+
"0": "\u2070",
|
|
197
|
+
"1": "\u00b9",
|
|
198
|
+
"2": "\u00b2",
|
|
199
|
+
"3": "\u00b3",
|
|
200
|
+
"4": "\u2074",
|
|
201
|
+
"5": "\u2075",
|
|
202
|
+
"6": "\u2076",
|
|
203
|
+
"7": "\u2077",
|
|
204
|
+
"8": "\u2078",
|
|
205
|
+
"9": "\u2079",
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
function formatHudNoteMarker(count: number): string {
|
|
209
|
+
if (count <= 0) return "";
|
|
210
|
+
const sub = String(count)
|
|
211
|
+
.split("")
|
|
212
|
+
.map(d => HUD_NOTE_SUP_DIGITS[d] ?? d)
|
|
213
|
+
.join("");
|
|
214
|
+
return theme.fg("dim", chalk.italic(` \u207a${sub}`));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
type GoalSubcommand = "set" | "show" | "pause" | "resume" | "drop" | "budget";
|
|
218
|
+
|
|
219
|
+
const GOAL_SUBCOMMANDS = new Set<GoalSubcommand>(["set", "show", "pause", "resume", "drop", "budget"]);
|
|
220
|
+
const PLAN_KEEP_CONTEXT_OPTION_INDEX = 2;
|
|
221
|
+
const PLAN_KEEP_CONTEXT_DISABLE_THRESHOLD_PERCENT = 95;
|
|
222
|
+
|
|
223
|
+
function parseGoalSubcommand(args: string): { sub: GoalSubcommand | undefined; rest: string } {
|
|
224
|
+
const trimmed = args.trim();
|
|
225
|
+
if (!trimmed) return { sub: undefined, rest: "" };
|
|
226
|
+
const match = /^(\S+)(?:\s+([\s\S]*))?$/.exec(trimmed);
|
|
227
|
+
if (!match) return { sub: undefined, rest: trimmed };
|
|
228
|
+
const first = match[1].toLowerCase();
|
|
229
|
+
if (GOAL_SUBCOMMANDS.has(first as GoalSubcommand)) {
|
|
230
|
+
return { sub: first as GoalSubcommand, rest: match[2]?.trim() ?? "" };
|
|
231
|
+
}
|
|
232
|
+
return { sub: undefined, rest: trimmed };
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function formatContextTokenCount(value: number): string {
|
|
236
|
+
return formatNumber(Math.max(0, Math.round(value))).toLowerCase();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** Options for creating an InteractiveMode instance (for future API use) */
|
|
240
|
+
export interface InteractiveModeOptions {
|
|
241
|
+
/** Providers that were migrated during startup */
|
|
242
|
+
migratedProviders?: string[];
|
|
243
|
+
/** Warning message if model fallback occurred */
|
|
244
|
+
modelFallbackMessage?: string;
|
|
245
|
+
/** Initial message to send */
|
|
246
|
+
initialMessage?: string;
|
|
247
|
+
/** Initial images to include with the message */
|
|
248
|
+
initialImages?: ImageContent[];
|
|
249
|
+
/** Additional initial messages to queue */
|
|
250
|
+
initialMessages?: string[];
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export class InteractiveMode implements InteractiveModeContext {
|
|
254
|
+
session: AgentSession;
|
|
255
|
+
sessionManager: SessionManager;
|
|
256
|
+
settings: Settings;
|
|
257
|
+
keybindings: KeybindingsManager;
|
|
258
|
+
agent: Agent;
|
|
259
|
+
historyStorage?: HistoryStorage;
|
|
260
|
+
|
|
261
|
+
ui: TUI;
|
|
262
|
+
chatContainer: TranscriptContainer;
|
|
263
|
+
pendingMessagesContainer: Container;
|
|
264
|
+
statusContainer: Container;
|
|
265
|
+
todoContainer: Container;
|
|
266
|
+
btwContainer: Container;
|
|
267
|
+
omfgContainer: Container;
|
|
268
|
+
errorBannerContainer: Container;
|
|
269
|
+
editor: CustomEditor;
|
|
270
|
+
editorContainer: Container;
|
|
271
|
+
hookWidgetContainerAbove: Container;
|
|
272
|
+
hookWidgetContainerBelow: Container;
|
|
273
|
+
statusLine: StatusLineComponent;
|
|
274
|
+
|
|
275
|
+
isInitialized = false;
|
|
276
|
+
isBackgrounded = false;
|
|
277
|
+
isBashMode = false;
|
|
278
|
+
toolOutputExpanded = false;
|
|
279
|
+
todoExpanded = false;
|
|
280
|
+
planModeEnabled = false;
|
|
281
|
+
planModePaused = false;
|
|
282
|
+
goalModeEnabled = false;
|
|
283
|
+
goalModePaused = false;
|
|
284
|
+
planModePlanFilePath: string | undefined = undefined;
|
|
285
|
+
loopModeEnabled = false;
|
|
286
|
+
loopPrompt: string | undefined = undefined;
|
|
287
|
+
loopLimit: LoopLimitRuntime | undefined = undefined;
|
|
288
|
+
#loopAutoSubmitTimer: NodeJS.Timeout | undefined;
|
|
289
|
+
#todoAutoClearTimer: NodeJS.Timeout | undefined;
|
|
290
|
+
todoPhases: TodoPhase[] = [];
|
|
291
|
+
hideThinkingBlock = false;
|
|
292
|
+
pendingImages: ImageContent[] = [];
|
|
293
|
+
pendingImageLinks: (string | undefined)[] = [];
|
|
294
|
+
compactionQueuedMessages: CompactionQueuedMessage[] = [];
|
|
295
|
+
pendingTools = new Map<string, ToolExecutionHandle>();
|
|
296
|
+
pendingBashComponents: BashExecutionComponent[] = [];
|
|
297
|
+
bashComponent: BashExecutionComponent | undefined = undefined;
|
|
298
|
+
pendingPythonComponents: EvalExecutionComponent[] = [];
|
|
299
|
+
pythonComponent: EvalExecutionComponent | undefined = undefined;
|
|
300
|
+
isPythonMode = false;
|
|
301
|
+
streamingComponent: AssistantMessageComponent | undefined = undefined;
|
|
302
|
+
streamingMessage: AssistantMessage | undefined = undefined;
|
|
303
|
+
loadingAnimation: Loader | undefined = undefined;
|
|
304
|
+
autoCompactionLoader: Loader | undefined = undefined;
|
|
305
|
+
retryLoader: Loader | undefined = undefined;
|
|
306
|
+
#pendingWorkingMessage: string | undefined;
|
|
307
|
+
get #defaultWorkingMessage(): string {
|
|
308
|
+
return `Working…${interruptHint()}`;
|
|
309
|
+
}
|
|
310
|
+
autoCompactionEscapeHandler?: () => void;
|
|
311
|
+
retryEscapeHandler?: () => void;
|
|
312
|
+
unsubscribe?: () => void;
|
|
313
|
+
onInputCallback?: (input: SubmittedUserInput) => void;
|
|
314
|
+
optimisticUserMessageSignature: string | undefined = undefined;
|
|
315
|
+
locallySubmittedUserSignatures: Set<string> = new Set();
|
|
316
|
+
#pendingSubmittedInput: SubmittedUserInput | undefined;
|
|
317
|
+
#pendingSubmissionDispose: (() => void) | undefined;
|
|
318
|
+
lastSigintTime = 0;
|
|
319
|
+
lastEscapeTime = 0;
|
|
320
|
+
shutdownRequested = false;
|
|
321
|
+
#isShuttingDown = false;
|
|
322
|
+
hookSelector: HookSelectorComponent | undefined = undefined;
|
|
323
|
+
hookInput: HookInputComponent | undefined = undefined;
|
|
324
|
+
hookEditor: HookEditorComponent | undefined = undefined;
|
|
325
|
+
lastStatusSpacer: Spacer | undefined = undefined;
|
|
326
|
+
lastStatusText: Text | undefined = undefined;
|
|
327
|
+
fileSlashCommands: Set<string> = new Set();
|
|
328
|
+
skillCommands: Map<string, string> = new Map();
|
|
329
|
+
oauthManualInput: OAuthManualInputManager = new OAuthManualInputManager();
|
|
330
|
+
|
|
331
|
+
#pendingSlashCommands: SlashCommand[] = [];
|
|
332
|
+
#cleanupUnsubscribe?: () => void;
|
|
333
|
+
readonly #version: string;
|
|
334
|
+
readonly #changelogMarkdown: string | undefined;
|
|
335
|
+
#planModePreviousTools: string[] | undefined;
|
|
336
|
+
#goalModePreviousTools: string[] | undefined;
|
|
337
|
+
#goalContinuationTimer: NodeJS.Timeout | undefined;
|
|
338
|
+
#goalTurnHadToolCalls = false;
|
|
339
|
+
#goalContinuationTurnInFlight = false;
|
|
340
|
+
#goalSuppressNextContinuation = false;
|
|
341
|
+
#planModePreviousModelState: { model: Model; thinkingLevel?: ThinkingLevel } | undefined;
|
|
342
|
+
#pendingModelSwitch: { model: Model; thinkingLevel?: ThinkingLevel } | undefined;
|
|
343
|
+
#planModeHasEntered = false;
|
|
344
|
+
#planReviewContainer: Container | undefined;
|
|
345
|
+
readonly lspServers: LspStartupServerInfo[] | undefined = undefined;
|
|
346
|
+
mcpManager?: import("../mcp").MCPManager;
|
|
347
|
+
readonly #toolUiContextSetter: (uiContext: ExtensionUIContext, hasUI: boolean) => void;
|
|
348
|
+
|
|
349
|
+
readonly #btwController: BtwController;
|
|
350
|
+
readonly #omfgController: OmfgController;
|
|
351
|
+
readonly #commandController: CommandController;
|
|
352
|
+
readonly #todoCommandController: TodoCommandController;
|
|
353
|
+
readonly #eventController: EventController;
|
|
354
|
+
readonly #extensionUiController: ExtensionUiController;
|
|
355
|
+
readonly #inputController: InputController;
|
|
356
|
+
readonly #selectorController: SelectorController;
|
|
357
|
+
readonly #uiHelpers: UiHelpers;
|
|
358
|
+
#sttController: STTController | undefined;
|
|
359
|
+
#voiceAnimationInterval: NodeJS.Timeout | undefined;
|
|
360
|
+
#voiceHue = 0;
|
|
361
|
+
#voicePreviousShowHardwareCursor: boolean | null = null;
|
|
362
|
+
#voicePreviousUseTerminalCursor: boolean | null = null;
|
|
363
|
+
#resizeHandler?: () => void;
|
|
364
|
+
#observerRegistry: SessionObserverRegistry;
|
|
365
|
+
#eventBus?: EventBus;
|
|
366
|
+
#eventBusUnsubscribers: Array<() => void> = [];
|
|
367
|
+
#welcomeComponent?: WelcomeComponent;
|
|
368
|
+
|
|
369
|
+
constructor(
|
|
370
|
+
session: AgentSession,
|
|
371
|
+
version: string,
|
|
372
|
+
changelogMarkdown: string | undefined = undefined,
|
|
373
|
+
setToolUIContext: (uiContext: ExtensionUIContext, hasUI: boolean) => void = () => {},
|
|
374
|
+
lspServers: LspStartupServerInfo[] | undefined = undefined,
|
|
375
|
+
mcpManager?: import("../mcp").MCPManager,
|
|
376
|
+
eventBus?: EventBus,
|
|
377
|
+
) {
|
|
378
|
+
this.session = session;
|
|
379
|
+
this.sessionManager = session.sessionManager;
|
|
380
|
+
this.settings = session.settings;
|
|
381
|
+
this.keybindings = KeybindingsManager.inMemory();
|
|
382
|
+
this.agent = session.agent;
|
|
383
|
+
this.#version = version;
|
|
384
|
+
this.#changelogMarkdown = changelogMarkdown;
|
|
385
|
+
this.#toolUiContextSetter = setToolUIContext;
|
|
386
|
+
this.lspServers = lspServers;
|
|
387
|
+
this.mcpManager = mcpManager;
|
|
388
|
+
this.#eventBus = eventBus;
|
|
389
|
+
if (eventBus) {
|
|
390
|
+
this.#eventBusUnsubscribers.push(
|
|
391
|
+
eventBus.on(LSP_STARTUP_EVENT_CHANNEL, data => {
|
|
392
|
+
this.#handleLspStartupEvent(data as LspStartupEvent);
|
|
393
|
+
}),
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
this.ui = new TUI(new ProcessTerminal(), settings.get("showHardwareCursor"));
|
|
398
|
+
this.ui.setClearOnShrink(settings.get("clearOnShrink"));
|
|
399
|
+
this.ui.setMaxInlineImages(settings.get("tui.maxInlineImages"));
|
|
400
|
+
// OSC 66 text-sizing is Kitty-only; resolve the setting against the terminal's
|
|
401
|
+
// capability (`TERMINAL.textSizing` defaults on for Kitty) so it stays off
|
|
402
|
+
// unless the user opts in, and never emits raw escapes on other terminals.
|
|
403
|
+
setTerminalTextSizing(settings.get("tui.textSizing") && TERMINAL.textSizing);
|
|
404
|
+
this.chatContainer = new TranscriptContainer();
|
|
405
|
+
this.pendingMessagesContainer = new Container();
|
|
406
|
+
this.statusContainer = new Container();
|
|
407
|
+
this.todoContainer = new Container();
|
|
408
|
+
this.btwContainer = new Container();
|
|
409
|
+
this.omfgContainer = new Container();
|
|
410
|
+
this.errorBannerContainer = new Container();
|
|
411
|
+
this.editor = new CustomEditor(getEditorTheme());
|
|
412
|
+
this.editor.setUseTerminalCursor(this.ui.getShowHardwareCursor());
|
|
413
|
+
this.editor.setAutocompleteMaxVisible(settings.get("autocompleteMaxVisible"));
|
|
414
|
+
this.editor.onAutocompleteCancel = () => {
|
|
415
|
+
this.ui.requestRender(true);
|
|
416
|
+
};
|
|
417
|
+
this.editor.onAutocompleteUpdate = () => {
|
|
418
|
+
this.ui.requestRender(false, { allowUnknownViewportMutation: true });
|
|
419
|
+
};
|
|
420
|
+
this.#syncEditorMaxHeight();
|
|
421
|
+
this.#resizeHandler = () => {
|
|
422
|
+
this.#syncEditorMaxHeight();
|
|
423
|
+
this.updateEditorTopBorder();
|
|
424
|
+
};
|
|
425
|
+
process.stdout.on("resize", this.#resizeHandler);
|
|
426
|
+
try {
|
|
427
|
+
this.historyStorage = HistoryStorage.open();
|
|
428
|
+
this.editor.setHistoryStorage(this.historyStorage);
|
|
429
|
+
this.historyStorage.setSessionResolver(() => this.sessionManager.getSessionId());
|
|
430
|
+
} catch (error) {
|
|
431
|
+
logger.warn("History storage unavailable", { error: String(error) });
|
|
432
|
+
}
|
|
433
|
+
this.hookWidgetContainerAbove = new Container();
|
|
434
|
+
this.hookWidgetContainerAbove.addChild(new Spacer(1));
|
|
435
|
+
this.hookWidgetContainerBelow = new Container();
|
|
436
|
+
this.editorContainer = new Container();
|
|
437
|
+
this.editorContainer.addChild(this.editor);
|
|
438
|
+
this.statusLine = new StatusLineComponent(session);
|
|
439
|
+
this.statusLine.setAutoCompactEnabled(session.autoCompactionEnabled);
|
|
440
|
+
|
|
441
|
+
this.hideThinkingBlock = settings.get("hideThinkingBlock");
|
|
442
|
+
|
|
443
|
+
const builtinCommandNames = new Set(BUILTIN_SLASH_COMMANDS.map(c => c.name));
|
|
444
|
+
const hookCommands: SlashCommand[] = (
|
|
445
|
+
this.session.extensionRunner?.getRegisteredCommands(builtinCommandNames) ?? []
|
|
446
|
+
).map(cmd => ({
|
|
447
|
+
name: cmd.name,
|
|
448
|
+
description: cmd.description ?? "(hook command)",
|
|
449
|
+
getArgumentCompletions: cmd.getArgumentCompletions,
|
|
450
|
+
}));
|
|
451
|
+
|
|
452
|
+
// Convert custom commands (TypeScript) to SlashCommand format
|
|
453
|
+
const customCommands: SlashCommand[] = this.session.customCommands.map(loaded => ({
|
|
454
|
+
name: loaded.command.name,
|
|
455
|
+
description: `${loaded.command.description} (${loaded.source})`,
|
|
456
|
+
}));
|
|
457
|
+
|
|
458
|
+
// Build skill commands from session.skills (if enabled)
|
|
459
|
+
const skillCommandList: SlashCommand[] = [];
|
|
460
|
+
if (settings.get("skills.enableSkillCommands")) {
|
|
461
|
+
for (const skill of this.session.skills) {
|
|
462
|
+
const commandName = `skill:${skill.name}`;
|
|
463
|
+
this.skillCommands.set(commandName, skill.filePath);
|
|
464
|
+
skillCommandList.push({ name: commandName, description: skill.description });
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// Store pending commands for init() where file commands are loaded async
|
|
469
|
+
this.#pendingSlashCommands = [...BUILTIN_SLASH_COMMANDS, ...hookCommands, ...customCommands, ...skillCommandList];
|
|
470
|
+
|
|
471
|
+
this.#uiHelpers = new UiHelpers(this);
|
|
472
|
+
this.#btwController = new BtwController(this);
|
|
473
|
+
this.#omfgController = new OmfgController(this);
|
|
474
|
+
this.#extensionUiController = new ExtensionUiController(this);
|
|
475
|
+
this.#eventController = new EventController(this);
|
|
476
|
+
this.#commandController = new CommandController(this);
|
|
477
|
+
this.#todoCommandController = new TodoCommandController(this);
|
|
478
|
+
this.#selectorController = new SelectorController(this);
|
|
479
|
+
this.#inputController = new InputController(this);
|
|
480
|
+
this.#observerRegistry = new SessionObserverRegistry();
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
playWelcomeIntro(): void {
|
|
484
|
+
this.#welcomeComponent?.playIntro(() => this.ui.requestRender());
|
|
485
|
+
}
|
|
486
|
+
async init(options: InteractiveModeInitOptions = {}): Promise<void> {
|
|
487
|
+
if (this.isInitialized) return;
|
|
488
|
+
|
|
489
|
+
this.keybindings = logger.time("InteractiveMode.init:keybindings", () => KeybindingsManager.create());
|
|
490
|
+
|
|
491
|
+
// Register session manager flush for signal handlers (SIGINT, SIGTERM, SIGHUP)
|
|
492
|
+
this.#cleanupUnsubscribe = postmortem.register("session-manager-flush", () => this.sessionManager.flush());
|
|
493
|
+
|
|
494
|
+
// Wire the report_tool_issue consent gate to the Yes/No dialog popup.
|
|
495
|
+
// The handler is process-global — subagent tools (which can't reach
|
|
496
|
+
// `showHookSelector` on their own) resolve through this exact closure.
|
|
497
|
+
// `Settings.instance` is the disk-backed singleton; passing it explicitly
|
|
498
|
+
// guarantees the decision persists even when the prompt is triggered
|
|
499
|
+
// from a subagent whose own `Settings` is an in-memory snapshot.
|
|
500
|
+
setAutoQaConsentHandler(() => this.#promptAutoQaConsent(), Settings.instance);
|
|
501
|
+
|
|
502
|
+
await logger.time(
|
|
503
|
+
"InteractiveMode.init:slashCommands",
|
|
504
|
+
this.refreshSlashCommandState.bind(this),
|
|
505
|
+
getProjectDir(),
|
|
506
|
+
);
|
|
507
|
+
|
|
508
|
+
// Get current model info for welcome screen
|
|
509
|
+
const modelName = this.session.model?.name ?? "Unknown";
|
|
510
|
+
const providerName = this.session.model?.provider ?? "Unknown";
|
|
511
|
+
|
|
512
|
+
// Get recent sessions
|
|
513
|
+
const recentSessions = await logger.time("InteractiveMode.init:recentSessions", () =>
|
|
514
|
+
getRecentSessions(this.sessionManager.getSessionDir()).then(sessions =>
|
|
515
|
+
sessions.map(s => ({
|
|
516
|
+
name: s.name,
|
|
517
|
+
timeAgo: s.timeAgo,
|
|
518
|
+
})),
|
|
519
|
+
),
|
|
520
|
+
);
|
|
521
|
+
|
|
522
|
+
const startupQuiet = settings.get("startup.quiet");
|
|
523
|
+
this.#welcomeComponent = undefined;
|
|
524
|
+
|
|
525
|
+
for (const warning of this.session.configWarnings) {
|
|
526
|
+
this.ui.addChild(new Text(theme.fg("warning", `Warning: ${warning}`), 1, 0));
|
|
527
|
+
this.ui.addChild(new Spacer(1));
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
if (!startupQuiet) {
|
|
531
|
+
// Add welcome header
|
|
532
|
+
this.#welcomeComponent = new WelcomeComponent(
|
|
533
|
+
this.#version,
|
|
534
|
+
modelName,
|
|
535
|
+
providerName,
|
|
536
|
+
recentSessions,
|
|
537
|
+
this.#getWelcomeLspServers(),
|
|
538
|
+
);
|
|
539
|
+
|
|
540
|
+
// Setup UI layout
|
|
541
|
+
this.ui.addChild(new Spacer(1));
|
|
542
|
+
this.ui.addChild(this.#welcomeComponent);
|
|
543
|
+
this.ui.addChild(new Spacer(1));
|
|
544
|
+
if (!options.suppressWelcomeIntro) {
|
|
545
|
+
this.playWelcomeIntro();
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// Add changelog if provided
|
|
549
|
+
if (this.#changelogMarkdown) {
|
|
550
|
+
this.ui.addChild(new DynamicBorder());
|
|
551
|
+
if (settings.get("collapseChangelog")) {
|
|
552
|
+
const versionMatch = this.#changelogMarkdown.match(/##\s+\[?(\d+\.\d+\.\d+)\]?/);
|
|
553
|
+
const latestVersion = versionMatch ? versionMatch[1] : this.#version;
|
|
554
|
+
const condensedText = `Updated to v${latestVersion}. Use ${theme.bold("/changelog")} to view full changelog.`;
|
|
555
|
+
this.ui.addChild(new Text(condensedText, 1, 0));
|
|
556
|
+
} else {
|
|
557
|
+
this.ui.addChild(new Text(theme.bold(theme.fg("accent", "What's New")), 1, 0));
|
|
558
|
+
this.ui.addChild(new Spacer(1));
|
|
559
|
+
this.ui.addChild(new Markdown(this.#changelogMarkdown.trim(), 1, 0, getMarkdownTheme()));
|
|
560
|
+
this.ui.addChild(new Spacer(1));
|
|
561
|
+
}
|
|
562
|
+
this.ui.addChild(new DynamicBorder());
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
this.ui.addChild(this.chatContainer);
|
|
567
|
+
this.ui.addChild(this.pendingMessagesContainer);
|
|
568
|
+
this.ui.addChild(this.statusContainer);
|
|
569
|
+
this.ui.addChild(this.todoContainer);
|
|
570
|
+
this.ui.addChild(this.btwContainer);
|
|
571
|
+
this.ui.addChild(this.omfgContainer);
|
|
572
|
+
this.ui.addChild(this.errorBannerContainer);
|
|
573
|
+
this.ui.addChild(this.statusLine); // Only renders hook statuses (main status in editor border)
|
|
574
|
+
this.ui.addChild(this.hookWidgetContainerAbove);
|
|
575
|
+
this.ui.addChild(this.editorContainer);
|
|
576
|
+
this.ui.addChild(this.hookWidgetContainerBelow);
|
|
577
|
+
this.ui.setFocus(this.editor);
|
|
578
|
+
|
|
579
|
+
this.#inputController.setupKeyHandlers();
|
|
580
|
+
this.#inputController.setupEditorSubmitHandler();
|
|
581
|
+
|
|
582
|
+
// Wire observer registry to EventBus
|
|
583
|
+
if (this.#eventBus) {
|
|
584
|
+
this.#observerRegistry.subscribeToEventBus(this.#eventBus);
|
|
585
|
+
}
|
|
586
|
+
this.#observerRegistry.setMainSession(this.sessionManager.getSessionFile() ?? undefined);
|
|
587
|
+
this.#observerRegistry.onChange(() => {
|
|
588
|
+
this.statusLine.setSubagentCount(this.#observerRegistry.getActiveSubagentCount());
|
|
589
|
+
// Auto-checkmark todos whose matching subagent just succeeded, then
|
|
590
|
+
// re-render so the running override (the static "live" glyph when a
|
|
591
|
+
// subagent is doing the work for a still-pending todo) updates as
|
|
592
|
+
// subagents start, finish, or fail.
|
|
593
|
+
this.#reconcileTodosWithSubagents();
|
|
594
|
+
this.#syncTodoAutoClearTimer();
|
|
595
|
+
this.#renderTodoList();
|
|
596
|
+
this.ui.requestRender();
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
// Load initial todos
|
|
600
|
+
await this.#loadTodoList();
|
|
601
|
+
|
|
602
|
+
// Start the UI
|
|
603
|
+
this.ui.start();
|
|
604
|
+
pushTerminalTitle();
|
|
605
|
+
setSessionTerminalTitle(this.sessionManager.getSessionName(), this.sessionManager.getCwd());
|
|
606
|
+
this.updateEditorBorderColor();
|
|
607
|
+
this.#syncEditorMaxHeight();
|
|
608
|
+
this.isInitialized = true;
|
|
609
|
+
this.ui.requestRender(true);
|
|
610
|
+
|
|
611
|
+
// Initialize hooks with TUI-based UI context
|
|
612
|
+
await this.initHooksAndCustomTools();
|
|
613
|
+
|
|
614
|
+
// Restore mode from session (e.g. plan mode on resume)
|
|
615
|
+
this.session.setSessionSwitchReconciler?.(() => this.#reconcileModeFromSession());
|
|
616
|
+
await this.#reconcileModeFromSession();
|
|
617
|
+
|
|
618
|
+
// Restore unsent editor draft from previous session shutdown (Ctrl+D).
|
|
619
|
+
// One-shot: consumeDraft removes the sidecar after read so the next
|
|
620
|
+
// resume does not re-restore the same text.
|
|
621
|
+
try {
|
|
622
|
+
const draft = await this.sessionManager.consumeDraft();
|
|
623
|
+
if (draft && !this.editor.getText()) {
|
|
624
|
+
this.editor.setText(draft);
|
|
625
|
+
this.updateEditorBorderColor();
|
|
626
|
+
this.ui.requestRender();
|
|
627
|
+
}
|
|
628
|
+
} catch (err) {
|
|
629
|
+
logger.warn("Failed to restore session draft", { error: String(err) });
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// Subscribe to agent events
|
|
633
|
+
this.#subscribeToAgent();
|
|
634
|
+
|
|
635
|
+
this.#eventBusUnsubscribers.push(
|
|
636
|
+
this.session.subscribe(event => {
|
|
637
|
+
void this.#handleGoalSessionEvent(event);
|
|
638
|
+
}),
|
|
639
|
+
);
|
|
640
|
+
// Set up theme file watcher
|
|
641
|
+
onThemeChange(() => {
|
|
642
|
+
clearRenderCache();
|
|
643
|
+
this.ui.invalidate();
|
|
644
|
+
this.updateEditorBorderColor();
|
|
645
|
+
this.ui.requestRender();
|
|
646
|
+
});
|
|
647
|
+
|
|
648
|
+
// Subscribe to terminal dark/light appearance changes.
|
|
649
|
+
// The terminal queries background color via OSC 11 at startup and on
|
|
650
|
+
// Mode 2031 notifications, computing luminance to detect dark/light.
|
|
651
|
+
this.ui.terminal.onAppearanceChange(mode => {
|
|
652
|
+
onTerminalAppearanceChange(mode);
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
// Set up git branch watcher
|
|
656
|
+
this.statusLine.watchBranch(() => {
|
|
657
|
+
this.updateEditorTopBorder();
|
|
658
|
+
this.ui.requestRender();
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
// Initial top border update
|
|
662
|
+
this.updateEditorTopBorder();
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/** Reload slash commands and autocomplete for the provided working directory. */
|
|
666
|
+
async refreshSlashCommandState(cwd?: string): Promise<void> {
|
|
667
|
+
const basePath = cwd ?? this.sessionManager.getCwd();
|
|
668
|
+
const fileCommands = await loadSlashCommands({ cwd: basePath });
|
|
669
|
+
this.fileSlashCommands = new Set(fileCommands.map(cmd => cmd.name));
|
|
670
|
+
const fileSlashCommands: SlashCommand[] = fileCommands.map(cmd => ({
|
|
671
|
+
name: cmd.name,
|
|
672
|
+
description: cmd.description,
|
|
673
|
+
}));
|
|
674
|
+
const autocompleteProvider = this.#inputController.createAutocompleteProvider(
|
|
675
|
+
[...this.#pendingSlashCommands, ...fileSlashCommands],
|
|
676
|
+
basePath,
|
|
677
|
+
);
|
|
678
|
+
this.editor.setAutocompleteProvider(autocompleteProvider);
|
|
679
|
+
this.session.setSlashCommands(fileCommands);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Re-point the process and every cwd-derived cache at `newCwd` after the
|
|
684
|
+
* active session's working directory changed (`/move` relocation or resuming
|
|
685
|
+
* a session from another project). The SessionManager's cwd MUST already
|
|
686
|
+
* reflect `newCwd` before this is called.
|
|
687
|
+
*/
|
|
688
|
+
async applyCwdChange(newCwd: string): Promise<void> {
|
|
689
|
+
setProjectDir(newCwd);
|
|
690
|
+
// Re-scope project settings (`.claude/settings.yml` etc.) to the new
|
|
691
|
+
// directory in place so the active session and every settings reader pick
|
|
692
|
+
// up the destination project's configuration.
|
|
693
|
+
if (isSettingsInitialized()) {
|
|
694
|
+
await settings.reloadForCwd(newCwd);
|
|
695
|
+
}
|
|
696
|
+
// Re-warm plugin roots, capabilities, slash commands, and the ssh tool so
|
|
697
|
+
// the next prompt sees everything scoped to the new project directory.
|
|
698
|
+
clearClaudePluginRootsCache();
|
|
699
|
+
resetCapabilities();
|
|
700
|
+
await this.refreshSlashCommandState(newCwd);
|
|
701
|
+
await this.session.refreshSshTool({ activateIfAvailable: true });
|
|
702
|
+
setSessionTerminalTitle(this.sessionManager.getSessionName(), this.sessionManager.getCwd());
|
|
703
|
+
this.statusLine.invalidate();
|
|
704
|
+
this.updateEditorTopBorder();
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
async getUserInput(): Promise<SubmittedUserInput> {
|
|
708
|
+
if (this.session.getGoalModeState()?.mode === "exiting") {
|
|
709
|
+
await this.#exitGoalMode({ reason: "completed", silent: true });
|
|
710
|
+
}
|
|
711
|
+
const { promise, resolve } = Promise.withResolvers<SubmittedUserInput>();
|
|
712
|
+
this.onInputCallback = input => {
|
|
713
|
+
this.onInputCallback = undefined;
|
|
714
|
+
resolve(input);
|
|
715
|
+
};
|
|
716
|
+
this.#scheduleLoopAutoSubmit();
|
|
717
|
+
this.#scheduleGoalContinuation();
|
|
718
|
+
|
|
719
|
+
using _ = new EventLoopKeepalive();
|
|
720
|
+
return await promise;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
#scheduleLoopAutoSubmit(): void {
|
|
724
|
+
this.#cancelLoopAutoSubmit();
|
|
725
|
+
if (!this.loopModeEnabled || !this.loopPrompt) return;
|
|
726
|
+
const prompt = this.loopPrompt;
|
|
727
|
+
const loopAction = settings.get("loop.mode");
|
|
728
|
+
this.#deferLoopAutoSubmit(() => {
|
|
729
|
+
void this.#runLoopIteration(loopAction, prompt);
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
#deferLoopAutoSubmit(callback: () => void): void {
|
|
734
|
+
// Brief delay so the user has a chance to press Esc between iterations.
|
|
735
|
+
this.#loopAutoSubmitTimer = setTimeout(() => {
|
|
736
|
+
this.#loopAutoSubmitTimer = undefined;
|
|
737
|
+
if (!this.loopModeEnabled || !this.onInputCallback) return;
|
|
738
|
+
callback();
|
|
739
|
+
}, 800);
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
#cancelLoopAutoSubmit(): void {
|
|
743
|
+
if (this.#loopAutoSubmitTimer) {
|
|
744
|
+
clearTimeout(this.#loopAutoSubmitTimer);
|
|
745
|
+
this.#loopAutoSubmitTimer = undefined;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
#scheduleGoalContinuation(): void {
|
|
750
|
+
this.#cancelGoalContinuation();
|
|
751
|
+
if (this.loopModeEnabled) return;
|
|
752
|
+
if (!this.onInputCallback) return;
|
|
753
|
+
if (!this.session.settings.get("goal.continuationModes").includes("interactive")) return;
|
|
754
|
+
if (this.planModeEnabled || this.planModePaused) return;
|
|
755
|
+
if (!this.goalModeEnabled || this.goalModePaused) return;
|
|
756
|
+
if (this.#goalSuppressNextContinuation) return;
|
|
757
|
+
if (this.#pendingSubmittedInput) return;
|
|
758
|
+
if (this.editor.getText().trim().length > 0) return;
|
|
759
|
+
if ((this.pendingImages?.length ?? 0) > 0) return;
|
|
760
|
+
const state = this.session.getGoalModeState();
|
|
761
|
+
if (!state?.enabled || state.goal.status !== "active") return;
|
|
762
|
+
const prompt = this.session.goalRuntime.buildContinuationPrompt();
|
|
763
|
+
if (!prompt) return;
|
|
764
|
+
this.#goalContinuationTimer = setTimeout(() => {
|
|
765
|
+
this.#goalContinuationTimer = undefined;
|
|
766
|
+
if (!this.onInputCallback) return;
|
|
767
|
+
if (!this.goalModeEnabled || this.goalModePaused) return;
|
|
768
|
+
if (this.#pendingSubmittedInput) return;
|
|
769
|
+
if (this.editor.getText().trim().length > 0) return;
|
|
770
|
+
if ((this.pendingImages?.length ?? 0) > 0) return;
|
|
771
|
+
const latestState = this.session.getGoalModeState();
|
|
772
|
+
if (!latestState?.enabled || latestState.goal.status !== "active") return;
|
|
773
|
+
this.#goalContinuationTurnInFlight = true;
|
|
774
|
+
this.onInputCallback(
|
|
775
|
+
this.startPendingSubmission({
|
|
776
|
+
text: prompt,
|
|
777
|
+
customType: "goal-continuation",
|
|
778
|
+
display: false,
|
|
779
|
+
}),
|
|
780
|
+
);
|
|
781
|
+
}, 800);
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
#cancelGoalContinuation(): void {
|
|
785
|
+
if (this.#goalContinuationTimer) {
|
|
786
|
+
clearTimeout(this.#goalContinuationTimer);
|
|
787
|
+
this.#goalContinuationTimer = undefined;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
#isLoopAutoSubmitBlocked(): boolean {
|
|
792
|
+
return this.session.isStreaming || this.session.isCompacting || this.session.hasPostPromptWork;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
#submitLoopPromptWhenReady(prompt: string): void {
|
|
796
|
+
if (!this.loopModeEnabled || this.loopPrompt !== prompt || !this.onInputCallback) return;
|
|
797
|
+
if (isLoopDurationExpired(this.loopLimit)) {
|
|
798
|
+
this.disableLoopMode("Loop time limit reached. Loop mode disabled.");
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
if (this.#isLoopAutoSubmitBlocked()) {
|
|
802
|
+
this.#deferLoopAutoSubmit(() => this.#submitLoopPromptWhenReady(prompt));
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
this.onInputCallback(this.startPendingSubmission({ text: prompt }));
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
async #runLoopIteration(action: "prompt" | "compact" | "reset", prompt: string): Promise<void> {
|
|
809
|
+
if (!this.loopModeEnabled || this.loopPrompt !== prompt || !this.onInputCallback) return;
|
|
810
|
+
if (this.#isLoopAutoSubmitBlocked()) {
|
|
811
|
+
this.#deferLoopAutoSubmit(() => {
|
|
812
|
+
void this.#runLoopIteration(action, prompt);
|
|
813
|
+
});
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
if (!consumeLoopLimitIteration(this.loopLimit)) {
|
|
818
|
+
this.disableLoopMode("Loop limit reached. Loop mode disabled.");
|
|
819
|
+
return;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
if (action === "compact") {
|
|
823
|
+
await this.handleCompactCommand();
|
|
824
|
+
} else if (action === "reset") {
|
|
825
|
+
await this.handleClearCommand();
|
|
826
|
+
}
|
|
827
|
+
this.#submitLoopPromptWhenReady(prompt);
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
disableLoopMode(message = "Loop mode disabled."): void {
|
|
831
|
+
const wasEnabled = this.loopModeEnabled;
|
|
832
|
+
this.loopModeEnabled = false;
|
|
833
|
+
this.loopPrompt = undefined;
|
|
834
|
+
this.loopLimit = undefined;
|
|
835
|
+
this.#cancelLoopAutoSubmit();
|
|
836
|
+
this.statusLine.setLoopModeStatus(undefined);
|
|
837
|
+
this.updateEditorTopBorder();
|
|
838
|
+
this.ui.requestRender();
|
|
839
|
+
if (wasEnabled) {
|
|
840
|
+
this.showStatus(message);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Pause the loop without exiting it: drops the captured prompt and any
|
|
846
|
+
* pending auto-resubmit. Loop mode stays enabled — the next prompt the
|
|
847
|
+
* user submits becomes the new loop prompt and resumes iteration.
|
|
848
|
+
*/
|
|
849
|
+
pauseLoop(): void {
|
|
850
|
+
this.loopPrompt = undefined;
|
|
851
|
+
this.#cancelLoopAutoSubmit();
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
async handleLoopCommand(args = ""): Promise<void> {
|
|
855
|
+
if (this.loopModeEnabled) {
|
|
856
|
+
this.disableLoopMode();
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
const parsedLimit = parseLoopLimitArgs(args);
|
|
860
|
+
if (typeof parsedLimit === "string") {
|
|
861
|
+
this.showError(parsedLimit);
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
this.loopModeEnabled = true;
|
|
865
|
+
this.loopPrompt = undefined;
|
|
866
|
+
this.loopLimit = createLoopLimitRuntime(parsedLimit);
|
|
867
|
+
this.statusLine.setLoopModeStatus({ enabled: true });
|
|
868
|
+
this.updateEditorTopBorder();
|
|
869
|
+
this.ui.requestRender();
|
|
870
|
+
const limitSuffix = parsedLimit ? ` Limited to ${describeLoopLimit(parsedLimit)}.` : "";
|
|
871
|
+
const remainingSuffix = this.loopLimit ? ` ${describeLoopLimitRuntime(this.loopLimit)}.` : "";
|
|
872
|
+
this.showStatus(
|
|
873
|
+
`Loop mode enabled.${limitSuffix}${remainingSuffix} Your next prompt will repeat after each turn. Esc cancels the current iteration; /loop again to disable.`,
|
|
874
|
+
);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
recordLocalSubmission(text: string, imageCount = 0): () => void {
|
|
878
|
+
if (this.isKnownSlashCommand(text)) {
|
|
879
|
+
return () => {};
|
|
880
|
+
}
|
|
881
|
+
const signature = `${text}\u0000${imageCount}`;
|
|
882
|
+
this.locallySubmittedUserSignatures.add(signature);
|
|
883
|
+
let disposed = false;
|
|
884
|
+
return () => {
|
|
885
|
+
if (disposed) return;
|
|
886
|
+
disposed = true;
|
|
887
|
+
this.locallySubmittedUserSignatures.delete(signature);
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
async withLocalSubmission<T>(text: string, fn: () => Promise<T>, options?: { imageCount?: number }): Promise<T> {
|
|
892
|
+
const dispose = this.recordLocalSubmission(text, options?.imageCount ?? 0);
|
|
893
|
+
try {
|
|
894
|
+
return await fn();
|
|
895
|
+
} catch (err) {
|
|
896
|
+
dispose();
|
|
897
|
+
throw err;
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
startPendingSubmission(input: {
|
|
902
|
+
text: string;
|
|
903
|
+
images?: ImageContent[];
|
|
904
|
+
imageLinks?: (string | undefined)[];
|
|
905
|
+
customType?: string;
|
|
906
|
+
display?: boolean;
|
|
907
|
+
}): SubmittedUserInput {
|
|
908
|
+
const submission: SubmittedUserInput = {
|
|
909
|
+
text: input.text,
|
|
910
|
+
images: input.images,
|
|
911
|
+
imageLinks: input.imageLinks,
|
|
912
|
+
customType: input.customType,
|
|
913
|
+
display: input.display,
|
|
914
|
+
cancelled: false,
|
|
915
|
+
started: false,
|
|
916
|
+
};
|
|
917
|
+
this.#pendingSubmittedInput = submission;
|
|
918
|
+
if (!submission.customType) {
|
|
919
|
+
this.#resetGoalContinuationSuppression();
|
|
920
|
+
const imageCount = submission.images?.length ?? 0;
|
|
921
|
+
this.optimisticUserMessageSignature = `${submission.text}\u0000${imageCount}`;
|
|
922
|
+
this.#pendingSubmissionDispose = this.recordLocalSubmission(submission.text, imageCount);
|
|
923
|
+
this.addMessageToChat(
|
|
924
|
+
{
|
|
925
|
+
role: "user",
|
|
926
|
+
content: [{ type: "text", text: submission.text }, ...(submission.images ?? [])],
|
|
927
|
+
attribution: "user",
|
|
928
|
+
timestamp: Date.now(),
|
|
929
|
+
},
|
|
930
|
+
{ imageLinks: input.imageLinks },
|
|
931
|
+
);
|
|
932
|
+
} else {
|
|
933
|
+
this.optimisticUserMessageSignature = undefined;
|
|
934
|
+
this.#pendingSubmissionDispose = undefined;
|
|
935
|
+
}
|
|
936
|
+
this.editor.setText("");
|
|
937
|
+
this.editor.imageLinks = undefined;
|
|
938
|
+
// Reconciliation checkpoint: only retire frozen block snapshots after TUI
|
|
939
|
+
// proves the native viewport is at the tail and replays scrollback safely.
|
|
940
|
+
// Unknown host viewports stay frozen; thawing them would expose live rows
|
|
941
|
+
// over stale native history and can yank or duplicate when ED3 is unsafe.
|
|
942
|
+
if (this.ui.refreshNativeScrollbackIfDirty()) {
|
|
943
|
+
this.chatContainer.thaw();
|
|
944
|
+
}
|
|
945
|
+
this.ensureLoadingAnimation();
|
|
946
|
+
this.ui.requestRender();
|
|
947
|
+
return submission;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
cancelPendingSubmission(): boolean {
|
|
951
|
+
const submission = this.#pendingSubmittedInput;
|
|
952
|
+
if (!submission || submission.started) {
|
|
953
|
+
return false;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
submission.cancelled = true;
|
|
957
|
+
this.#pendingSubmittedInput = undefined;
|
|
958
|
+
this.optimisticUserMessageSignature = undefined;
|
|
959
|
+
this.#pendingSubmissionDispose?.();
|
|
960
|
+
this.#pendingSubmissionDispose = undefined;
|
|
961
|
+
this.#pendingWorkingMessage = undefined;
|
|
962
|
+
if (submission.customType === "goal-continuation") {
|
|
963
|
+
this.#goalContinuationTurnInFlight = false;
|
|
964
|
+
}
|
|
965
|
+
if (this.loadingAnimation) {
|
|
966
|
+
this.loadingAnimation.stop();
|
|
967
|
+
this.loadingAnimation = undefined;
|
|
968
|
+
this.statusContainer.clear();
|
|
969
|
+
}
|
|
970
|
+
if (!submission.customType) {
|
|
971
|
+
this.pendingImages = submission.images ? [...submission.images] : [];
|
|
972
|
+
this.pendingImageLinks = submission.imageLinks ? [...submission.imageLinks] : [];
|
|
973
|
+
this.editor.imageLinks = this.pendingImageLinks;
|
|
974
|
+
this.rebuildChatFromMessages();
|
|
975
|
+
this.editor.setText(submission.text);
|
|
976
|
+
}
|
|
977
|
+
this.updateEditorBorderColor();
|
|
978
|
+
this.ui.requestRender();
|
|
979
|
+
return true;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
markPendingSubmissionStarted(input: SubmittedUserInput): boolean {
|
|
983
|
+
if (this.#pendingSubmittedInput !== input || input.cancelled) {
|
|
984
|
+
return false;
|
|
985
|
+
}
|
|
986
|
+
input.started = true;
|
|
987
|
+
return true;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
finishPendingSubmission(input: SubmittedUserInput): void {
|
|
991
|
+
const wasPendingSubmission = this.#pendingSubmittedInput === input;
|
|
992
|
+
const pendingSubmissionDispose = this.#pendingSubmissionDispose;
|
|
993
|
+
if (wasPendingSubmission) {
|
|
994
|
+
this.#pendingSubmittedInput = undefined;
|
|
995
|
+
this.#pendingSubmissionDispose = undefined;
|
|
996
|
+
}
|
|
997
|
+
if (input.customType === "goal-continuation") {
|
|
998
|
+
this.#goalContinuationTurnInFlight = false;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
if (wasPendingSubmission && !this.session.isStreaming && !this.streamingComponent) {
|
|
1002
|
+
this.optimisticUserMessageSignature = undefined;
|
|
1003
|
+
pendingSubmissionDispose?.();
|
|
1004
|
+
this.#pendingWorkingMessage = undefined;
|
|
1005
|
+
if (this.loadingAnimation) {
|
|
1006
|
+
this.loadingAnimation.stop();
|
|
1007
|
+
this.loadingAnimation = undefined;
|
|
1008
|
+
this.statusContainer.clear();
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
#computeEditorMaxHeight(): number {
|
|
1014
|
+
const rows = this.ui.terminal.rows;
|
|
1015
|
+
const terminalRows = Number.isFinite(rows) && rows > 0 ? rows : EDITOR_FALLBACK_ROWS;
|
|
1016
|
+
const maxHeight = terminalRows - EDITOR_RESERVED_ROWS;
|
|
1017
|
+
return Math.max(EDITOR_MAX_HEIGHT_MIN, Math.min(EDITOR_MAX_HEIGHT_MAX, maxHeight));
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
#syncEditorMaxHeight(): void {
|
|
1021
|
+
this.editor.setMaxHeight(this.#computeEditorMaxHeight());
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
updateEditorBorderColor(): void {
|
|
1025
|
+
if (this.isBashMode) {
|
|
1026
|
+
this.editor.borderColor = theme.getBashModeBorderColor();
|
|
1027
|
+
} else if (this.isPythonMode) {
|
|
1028
|
+
this.editor.borderColor = theme.getPythonModeBorderColor();
|
|
1029
|
+
} else {
|
|
1030
|
+
const accentEnabled = !isSettingsInitialized() || settings.get("statusLine.sessionAccent") !== false;
|
|
1031
|
+
const sessionName = accentEnabled ? this.sessionManager.getSessionName() : undefined;
|
|
1032
|
+
const hex = sessionName ? getSessionAccentHex(sessionName, theme.accentSurfaceLuminance) : undefined;
|
|
1033
|
+
const ansi = getSessionAccentAnsi(hex);
|
|
1034
|
+
if (ansi) {
|
|
1035
|
+
this.editor.borderColor = (str: string) => `${ansi}${str}\x1b[39m`;
|
|
1036
|
+
} else {
|
|
1037
|
+
const level = this.session.thinkingLevel ?? ThinkingLevel.Off;
|
|
1038
|
+
this.editor.borderColor = theme.getThinkingBorderColor(level);
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
this.updateEditorTopBorder();
|
|
1042
|
+
this.ui.requestRender();
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
updateEditorTopBorder(): void {
|
|
1046
|
+
const availableWidth = this.editor.getTopBorderAvailableWidth(this.ui.terminal.columns);
|
|
1047
|
+
const topBorder = this.statusLine.getTopBorder(availableWidth);
|
|
1048
|
+
this.editor.setTopBorder(topBorder);
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
rebuildChatFromMessages(): void {
|
|
1052
|
+
this.chatContainer.clear();
|
|
1053
|
+
const context = this.session.buildDisplaySessionContext();
|
|
1054
|
+
this.renderSessionContext(context);
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
#formatTodoLine(todo: TodoItem, prefix: string, matched: boolean): string {
|
|
1058
|
+
const checkbox = theme.checkbox;
|
|
1059
|
+
const marker = formatHudNoteMarker(todo.notes?.length ?? 0);
|
|
1060
|
+
switch (todo.status) {
|
|
1061
|
+
case "completed":
|
|
1062
|
+
return theme.fg("success", `${prefix}${checkbox.checked} ${chalk.strikethrough(todo.content)}`) + marker;
|
|
1063
|
+
case "in_progress":
|
|
1064
|
+
return theme.fg("accent", `${prefix}${checkbox.unchecked} ${todo.content}`) + marker;
|
|
1065
|
+
case "abandoned":
|
|
1066
|
+
return theme.fg("error", `${prefix}${checkbox.unchecked} ${chalk.strikethrough(todo.content)}`) + marker;
|
|
1067
|
+
default:
|
|
1068
|
+
if (matched) {
|
|
1069
|
+
return theme.fg("accent", `${prefix}${checkbox.unchecked} ${todo.content}`) + marker;
|
|
1070
|
+
}
|
|
1071
|
+
return theme.fg("dim", `${prefix}${checkbox.unchecked} ${todo.content}`) + marker;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
#getActiveSubagentDescriptions(): string[] {
|
|
1076
|
+
const out: string[] = [];
|
|
1077
|
+
for (const session of this.#observerRegistry.getSessions()) {
|
|
1078
|
+
if (session.kind !== "subagent") continue;
|
|
1079
|
+
if (session.status !== "active") continue;
|
|
1080
|
+
const candidate =
|
|
1081
|
+
session.description?.trim() || session.progress?.description?.trim() || session.label?.trim();
|
|
1082
|
+
if (candidate) out.push(candidate);
|
|
1083
|
+
}
|
|
1084
|
+
return out;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
/**
|
|
1088
|
+
* Auto-complete any pending/in_progress todo whose content matches a
|
|
1089
|
+
* subagent that has finished successfully. Fires on every observer
|
|
1090
|
+
* `onChange` so the visual state stays in sync with subagent lifecycle
|
|
1091
|
+
* without requiring the agent to issue a follow-up `todo`. Failed
|
|
1092
|
+
* and aborted subagents are intentionally NOT auto-completed — those
|
|
1093
|
+
* stay open so the user (or the next agent turn) can decide what to do.
|
|
1094
|
+
*
|
|
1095
|
+
* Idempotent: only flips open tasks, never re-touches completed ones.
|
|
1096
|
+
*/
|
|
1097
|
+
#reconcileTodosWithSubagents(): void {
|
|
1098
|
+
const completedDescs: string[] = [];
|
|
1099
|
+
for (const session of this.#observerRegistry.getSessions()) {
|
|
1100
|
+
if (session.kind !== "subagent") continue;
|
|
1101
|
+
if (session.status !== "completed") continue;
|
|
1102
|
+
const candidate =
|
|
1103
|
+
session.description?.trim() || session.progress?.description?.trim() || session.label?.trim();
|
|
1104
|
+
if (candidate) completedDescs.push(candidate);
|
|
1105
|
+
}
|
|
1106
|
+
if (completedDescs.length === 0) return;
|
|
1107
|
+
|
|
1108
|
+
let mutated = false;
|
|
1109
|
+
const next: TodoPhase[] = this.todoPhases.map(phase => ({
|
|
1110
|
+
name: phase.name,
|
|
1111
|
+
tasks: phase.tasks.map(task => {
|
|
1112
|
+
if (task.status !== "pending" && task.status !== "in_progress") return task;
|
|
1113
|
+
if (!todoMatchesAnyDescription(task.content, completedDescs)) return task;
|
|
1114
|
+
mutated = true;
|
|
1115
|
+
return { ...task, status: "completed" as const };
|
|
1116
|
+
}),
|
|
1117
|
+
}));
|
|
1118
|
+
if (!mutated) return;
|
|
1119
|
+
this.todoPhases = next;
|
|
1120
|
+
this.session.setTodoPhases(next);
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
#cancelTodoAutoClearTimer(): void {
|
|
1124
|
+
if (!this.#todoAutoClearTimer) return;
|
|
1125
|
+
clearTimeout(this.#todoAutoClearTimer);
|
|
1126
|
+
this.#todoAutoClearTimer = undefined;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
#isClosedTodo(task: TodoItem): boolean {
|
|
1130
|
+
return task.status === "completed" || task.status === "abandoned";
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
#hasClosedTodos(phases: TodoPhase[]): boolean {
|
|
1134
|
+
return phases.some(phase => phase.tasks.some(task => this.#isClosedTodo(task)));
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
#removeClosedTodos(phases: TodoPhase[]): TodoPhase[] {
|
|
1138
|
+
const next: TodoPhase[] = [];
|
|
1139
|
+
for (const phase of phases) {
|
|
1140
|
+
const tasks = phase.tasks.filter(task => !this.#isClosedTodo(task));
|
|
1141
|
+
if (tasks.length > 0) next.push({ name: phase.name, tasks });
|
|
1142
|
+
}
|
|
1143
|
+
return next;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
#syncTodoAutoClearTimer(): void {
|
|
1147
|
+
this.#cancelTodoAutoClearTimer();
|
|
1148
|
+
const delaySeconds = this.settings.get("tasks.todoClearDelay");
|
|
1149
|
+
if (!Number.isFinite(delaySeconds) || delaySeconds < 0 || !this.#hasClosedTodos(this.todoPhases)) return;
|
|
1150
|
+
if (delaySeconds === 0) {
|
|
1151
|
+
this.todoPhases = this.#removeClosedTodos(this.todoPhases);
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
this.#todoAutoClearTimer = setTimeout(() => {
|
|
1156
|
+
this.#todoAutoClearTimer = undefined;
|
|
1157
|
+
this.todoPhases = this.#removeClosedTodos(this.todoPhases);
|
|
1158
|
+
this.#renderTodoList();
|
|
1159
|
+
this.ui.requestRender();
|
|
1160
|
+
}, delaySeconds * 1000);
|
|
1161
|
+
this.#todoAutoClearTimer.unref?.();
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
#getActivePhase(phases: TodoPhase[]): TodoPhase | undefined {
|
|
1165
|
+
const nonEmpty = phases.filter(phase => phase.tasks.length > 0);
|
|
1166
|
+
const active = nonEmpty.find(phase =>
|
|
1167
|
+
phase.tasks.some(task => task.status === "pending" || task.status === "in_progress"),
|
|
1168
|
+
);
|
|
1169
|
+
return active ?? nonEmpty[nonEmpty.length - 1];
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
#renderTodoList(): void {
|
|
1173
|
+
this.todoContainer.clear();
|
|
1174
|
+
const phases = this.todoPhases.filter(phase => phase.tasks.length > 0);
|
|
1175
|
+
if (phases.length === 0) return;
|
|
1176
|
+
const indent = " ";
|
|
1177
|
+
const hook = theme.tree.hook;
|
|
1178
|
+
const lines = ["", indent + theme.bold(theme.fg("accent", "Todos"))];
|
|
1179
|
+
|
|
1180
|
+
const activeDescs = this.#getActiveSubagentDescriptions();
|
|
1181
|
+
// A pending todo "lights up" (accent + running glyph) when an in-flight
|
|
1182
|
+
// subagent is doing its work, matched by normalized content overlap.
|
|
1183
|
+
const isMatched = (todo: TodoItem): boolean =>
|
|
1184
|
+
activeDescs.length > 0 && todoMatchesAnyDescription(todo.content, activeDescs);
|
|
1185
|
+
|
|
1186
|
+
if (!this.todoExpanded) {
|
|
1187
|
+
const activeIdx = phases.indexOf(this.#getActivePhase(phases) ?? phases[0]);
|
|
1188
|
+
const activePhase = phases[activeIdx];
|
|
1189
|
+
if (!activePhase) return;
|
|
1190
|
+
const { visible, hiddenOpenCount } = selectStickyTodoWindow(activePhase.tasks, 5);
|
|
1191
|
+
|
|
1192
|
+
lines.push(
|
|
1193
|
+
`${indent}${theme.fg("accent", `${hook} ${formatPhaseDisplayName(activePhase.name, activeIdx + 1)}`)}`,
|
|
1194
|
+
);
|
|
1195
|
+
visible.forEach((todo, index) => {
|
|
1196
|
+
const prefix = `${indent}${index === 0 ? hook : " "} `;
|
|
1197
|
+
lines.push(this.#formatTodoLine(todo, prefix, isMatched(todo)));
|
|
1198
|
+
});
|
|
1199
|
+
if (hiddenOpenCount > 0) {
|
|
1200
|
+
lines.push(theme.fg("muted", `${indent} ${hook} +${hiddenOpenCount} more`));
|
|
1201
|
+
}
|
|
1202
|
+
this.todoContainer.addChild(new Text(lines.join("\n"), 1, 0));
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
phases.forEach((phase, phaseIndex) => {
|
|
1207
|
+
lines.push(`${indent}${theme.fg("accent", `${hook} ${formatPhaseDisplayName(phase.name, phaseIndex + 1)}`)}`);
|
|
1208
|
+
phase.tasks.forEach((todo, index) => {
|
|
1209
|
+
const prefix = `${indent}${index === 0 ? hook : " "} `;
|
|
1210
|
+
lines.push(this.#formatTodoLine(todo, prefix, isMatched(todo)));
|
|
1211
|
+
});
|
|
1212
|
+
});
|
|
1213
|
+
|
|
1214
|
+
this.todoContainer.addChild(new Text(lines.join("\n"), 1, 0));
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
async #loadTodoList(): Promise<void> {
|
|
1218
|
+
this.todoPhases = this.session.getTodoPhases();
|
|
1219
|
+
this.#syncTodoAutoClearTimer();
|
|
1220
|
+
this.#renderTodoList();
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
async #getPlanFilePath(): Promise<string> {
|
|
1224
|
+
return this.session.getPlanReferencePath() || "local://PLAN.md";
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
#resolvePlanFilePath(planFilePath: string): string {
|
|
1228
|
+
if (planFilePath.startsWith("local:")) {
|
|
1229
|
+
const normalized = normalizeLocalScheme(planFilePath);
|
|
1230
|
+
return resolveLocalUrlToPath(normalized, {
|
|
1231
|
+
getArtifactsDir: () => this.sessionManager.getArtifactsDir(),
|
|
1232
|
+
getSessionId: () => this.sessionManager.getSessionId(),
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
return path.resolve(this.sessionManager.getCwd(), planFilePath);
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
#updatePlanModeStatus(): void {
|
|
1239
|
+
const status =
|
|
1240
|
+
this.planModeEnabled || this.planModePaused
|
|
1241
|
+
? {
|
|
1242
|
+
enabled: this.planModeEnabled,
|
|
1243
|
+
paused: this.planModePaused,
|
|
1244
|
+
}
|
|
1245
|
+
: undefined;
|
|
1246
|
+
this.statusLine.setPlanModeStatus(status);
|
|
1247
|
+
this.updateEditorTopBorder();
|
|
1248
|
+
this.ui.requestRender();
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
#updateGoalModeStatus(): void {
|
|
1252
|
+
const status =
|
|
1253
|
+
this.goalModeEnabled || this.goalModePaused
|
|
1254
|
+
? { enabled: this.goalModeEnabled, paused: this.goalModePaused }
|
|
1255
|
+
: undefined;
|
|
1256
|
+
this.statusLine.setGoalModeStatus(status);
|
|
1257
|
+
this.updateEditorTopBorder();
|
|
1258
|
+
this.ui.requestRender();
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
#resetGoalContinuationSuppression(): void {
|
|
1262
|
+
this.#goalSuppressNextContinuation = false;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
#getPausedGoalState(): GoalModeState | undefined {
|
|
1266
|
+
const state = this.session.getGoalModeState();
|
|
1267
|
+
if (!state?.goal || state.enabled || state.goal.status !== "paused") {
|
|
1268
|
+
return undefined;
|
|
1269
|
+
}
|
|
1270
|
+
return state;
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
#goalFromModeData(modeData: SessionContext["modeData"]): Goal | undefined {
|
|
1274
|
+
const goal = modeData?.goal;
|
|
1275
|
+
if (!goal || typeof goal !== "object") return undefined;
|
|
1276
|
+
const value = goal as Record<string, unknown>;
|
|
1277
|
+
if (
|
|
1278
|
+
typeof value.id !== "string" ||
|
|
1279
|
+
typeof value.objective !== "string" ||
|
|
1280
|
+
typeof value.status !== "string" ||
|
|
1281
|
+
typeof value.tokensUsed !== "number" ||
|
|
1282
|
+
typeof value.timeUsedSeconds !== "number" ||
|
|
1283
|
+
typeof value.createdAt !== "number" ||
|
|
1284
|
+
typeof value.updatedAt !== "number"
|
|
1285
|
+
) {
|
|
1286
|
+
return undefined;
|
|
1287
|
+
}
|
|
1288
|
+
return {
|
|
1289
|
+
id: value.id,
|
|
1290
|
+
objective: value.objective,
|
|
1291
|
+
status: value.status as Goal["status"],
|
|
1292
|
+
tokenBudget: typeof value.tokenBudget === "number" ? value.tokenBudget : undefined,
|
|
1293
|
+
tokensUsed: value.tokensUsed,
|
|
1294
|
+
timeUsedSeconds: value.timeUsedSeconds,
|
|
1295
|
+
createdAt: value.createdAt,
|
|
1296
|
+
updatedAt: value.updatedAt,
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
async #handleGoalSessionEvent(event: AgentSessionEvent): Promise<void> {
|
|
1301
|
+
if (event.type === "agent_start") {
|
|
1302
|
+
this.#goalTurnHadToolCalls = false;
|
|
1303
|
+
this.#cancelGoalContinuation();
|
|
1304
|
+
return;
|
|
1305
|
+
}
|
|
1306
|
+
if (event.type === "tool_execution_start") {
|
|
1307
|
+
this.#goalTurnHadToolCalls = true;
|
|
1308
|
+
if (!this.#goalContinuationTurnInFlight) {
|
|
1309
|
+
this.#resetGoalContinuationSuppression();
|
|
1310
|
+
}
|
|
1311
|
+
return;
|
|
1312
|
+
}
|
|
1313
|
+
if (event.type === "message_start" && event.message.role === "user" && !event.message.synthetic) {
|
|
1314
|
+
this.#resetGoalContinuationSuppression();
|
|
1315
|
+
return;
|
|
1316
|
+
}
|
|
1317
|
+
if (event.type === "goal_updated") {
|
|
1318
|
+
// Handle drop before clearing goalModeEnabled so #exitGoalMode can
|
|
1319
|
+
// still restore the previous tool set while the flag is true.
|
|
1320
|
+
if (event.state?.goal?.status === "dropped") {
|
|
1321
|
+
await this.#exitGoalMode({ reason: "dropped", silent: true });
|
|
1322
|
+
return;
|
|
1323
|
+
}
|
|
1324
|
+
this.goalModeEnabled = event.state?.enabled === true;
|
|
1325
|
+
this.goalModePaused = event.state?.enabled !== true && event.state?.goal?.status === "paused";
|
|
1326
|
+
if (!event.state?.enabled) {
|
|
1327
|
+
this.#cancelGoalContinuation();
|
|
1328
|
+
}
|
|
1329
|
+
this.#updateGoalModeStatus();
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
if (event.type !== "agent_end") {
|
|
1333
|
+
return;
|
|
1334
|
+
}
|
|
1335
|
+
if (this.#goalContinuationTurnInFlight) {
|
|
1336
|
+
this.#goalSuppressNextContinuation = !this.#goalTurnHadToolCalls;
|
|
1337
|
+
this.#goalContinuationTurnInFlight = false;
|
|
1338
|
+
}
|
|
1339
|
+
if (this.session.getGoalModeState()?.mode === "exiting") {
|
|
1340
|
+
await this.#exitGoalMode({ reason: "completed", silent: true });
|
|
1341
|
+
return;
|
|
1342
|
+
}
|
|
1343
|
+
this.#scheduleGoalContinuation();
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
async #applyPlanModeModel(): Promise<void> {
|
|
1347
|
+
const resolved = this.session.resolveRoleModelWithThinking("plan");
|
|
1348
|
+
if (!resolved.model) return;
|
|
1349
|
+
|
|
1350
|
+
const currentModel = this.session.model;
|
|
1351
|
+
const sameModel = modelsAreEqual(currentModel, resolved.model);
|
|
1352
|
+
const planThinkingLevel = resolved.explicitThinkingLevel ? resolved.thinkingLevel : undefined;
|
|
1353
|
+
|
|
1354
|
+
this.#planModePreviousModelState = currentModel
|
|
1355
|
+
? { model: currentModel, thinkingLevel: this.session.thinkingLevel }
|
|
1356
|
+
: undefined;
|
|
1357
|
+
|
|
1358
|
+
if (!sameModel) {
|
|
1359
|
+
if (this.session.isStreaming) {
|
|
1360
|
+
this.#pendingModelSwitch = { model: resolved.model, thinkingLevel: planThinkingLevel };
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
try {
|
|
1364
|
+
await this.session.setModelTemporary(resolved.model, planThinkingLevel);
|
|
1365
|
+
} catch (error) {
|
|
1366
|
+
this.showWarning(
|
|
1367
|
+
`Failed to switch to plan model for plan mode: ${error instanceof Error ? error.message : String(error)}`,
|
|
1368
|
+
);
|
|
1369
|
+
}
|
|
1370
|
+
} else if (planThinkingLevel) {
|
|
1371
|
+
this.session.setThinkingLevel(planThinkingLevel);
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
/** Apply any deferred model switch after the current stream ends. */
|
|
1376
|
+
async flushPendingModelSwitch(): Promise<void> {
|
|
1377
|
+
const pending = this.#pendingModelSwitch;
|
|
1378
|
+
if (!pending) return;
|
|
1379
|
+
this.#pendingModelSwitch = undefined;
|
|
1380
|
+
try {
|
|
1381
|
+
await this.session.setModelTemporary(pending.model, pending.thinkingLevel);
|
|
1382
|
+
} catch (error) {
|
|
1383
|
+
this.showWarning(
|
|
1384
|
+
`Failed to switch model after streaming: ${error instanceof Error ? error.message : String(error)}`,
|
|
1385
|
+
);
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
async #clearTransientModeState(): Promise<void> {
|
|
1390
|
+
if (this.planModeEnabled || this.planModePaused) {
|
|
1391
|
+
if (this.#planModePreviousTools !== undefined) {
|
|
1392
|
+
await this.session.setActiveToolsByName(this.#planModePreviousTools);
|
|
1393
|
+
}
|
|
1394
|
+
this.session.setStandingResolveHandler?.(null);
|
|
1395
|
+
this.session.setPlanModeState(undefined);
|
|
1396
|
+
this.planModeEnabled = false;
|
|
1397
|
+
this.planModePaused = false;
|
|
1398
|
+
this.planModePlanFilePath = undefined;
|
|
1399
|
+
this.#planModePreviousTools = undefined;
|
|
1400
|
+
this.#planModePreviousModelState = undefined;
|
|
1401
|
+
this.#pendingModelSwitch = undefined;
|
|
1402
|
+
this.#planModeHasEntered = false;
|
|
1403
|
+
this.#updatePlanModeStatus();
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
if (this.goalModeEnabled || this.goalModePaused) {
|
|
1407
|
+
if (this.#goalModePreviousTools !== undefined) {
|
|
1408
|
+
await this.session.setActiveToolsByName(this.#goalModePreviousTools);
|
|
1409
|
+
}
|
|
1410
|
+
this.session.setGoalModeState(undefined);
|
|
1411
|
+
this.goalModeEnabled = false;
|
|
1412
|
+
this.goalModePaused = false;
|
|
1413
|
+
this.#goalModePreviousTools = undefined;
|
|
1414
|
+
this.#goalTurnHadToolCalls = false;
|
|
1415
|
+
this.#goalContinuationTurnInFlight = false;
|
|
1416
|
+
this.#goalSuppressNextContinuation = false;
|
|
1417
|
+
this.#cancelGoalContinuation();
|
|
1418
|
+
this.#updateGoalModeStatus();
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
/** Reconcile mode state from session entries on resume/switch. */
|
|
1423
|
+
async #reconcileModeFromSession(): Promise<void> {
|
|
1424
|
+
await this.#clearTransientModeState();
|
|
1425
|
+
const sessionContext = this.sessionManager.buildSessionContext();
|
|
1426
|
+
const goalEnabled = this.session.settings.get("goal.enabled");
|
|
1427
|
+
if (!goalEnabled && (sessionContext.mode === "goal" || sessionContext.mode === "goal_paused")) {
|
|
1428
|
+
this.sessionManager.appendModeChange("none");
|
|
1429
|
+
return;
|
|
1430
|
+
}
|
|
1431
|
+
if (sessionContext.mode === "goal" || sessionContext.mode === "goal_paused") {
|
|
1432
|
+
const goal = this.#goalFromModeData(sessionContext.modeData);
|
|
1433
|
+
if (!goal) {
|
|
1434
|
+
this.sessionManager.appendModeChange("none");
|
|
1435
|
+
return;
|
|
1436
|
+
}
|
|
1437
|
+
this.session.setGoalModeState({
|
|
1438
|
+
enabled: sessionContext.mode === "goal",
|
|
1439
|
+
mode: "active",
|
|
1440
|
+
goal,
|
|
1441
|
+
});
|
|
1442
|
+
const restored = await this.session.goalRuntime.onThreadResumed();
|
|
1443
|
+
this.goalModeEnabled = restored?.enabled === true;
|
|
1444
|
+
this.goalModePaused = restored?.enabled !== true && restored?.goal.status === "paused";
|
|
1445
|
+
// sdk.ts excludes "goal" from the initial active tool set unconditionally.
|
|
1446
|
+
// Re-add it now so the agent can call resume, complete, or drop on this goal.
|
|
1447
|
+
if (restored?.goal) {
|
|
1448
|
+
const previousTools = this.session.getActiveToolNames().filter(name => name !== "goal");
|
|
1449
|
+
this.#goalModePreviousTools = previousTools;
|
|
1450
|
+
await this.session.setActiveToolsByName([...new Set([...previousTools, "goal"])]);
|
|
1451
|
+
}
|
|
1452
|
+
this.#updateGoalModeStatus();
|
|
1453
|
+
return;
|
|
1454
|
+
}
|
|
1455
|
+
if (!this.session.settings.get("plan.enabled")) {
|
|
1456
|
+
// Clear stale plan/plan_paused mode so re-enabling the setting
|
|
1457
|
+
// later doesn't unexpectedly restore an old plan session.
|
|
1458
|
+
if (sessionContext.mode === "plan" || sessionContext.mode === "plan_paused") {
|
|
1459
|
+
this.sessionManager.appendModeChange("none");
|
|
1460
|
+
}
|
|
1461
|
+
return;
|
|
1462
|
+
}
|
|
1463
|
+
if (sessionContext.mode === "plan") {
|
|
1464
|
+
const planFilePath = sessionContext.modeData?.planFilePath as string | undefined;
|
|
1465
|
+
await this.#enterPlanMode({ planFilePath });
|
|
1466
|
+
} else if (sessionContext.mode === "plan_paused") {
|
|
1467
|
+
this.planModePaused = true;
|
|
1468
|
+
this.#planModeHasEntered = true;
|
|
1469
|
+
this.#updatePlanModeStatus();
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
async #enterPlanMode(options?: { planFilePath?: string; workflow?: "parallel" | "iterative" }): Promise<void> {
|
|
1474
|
+
if (this.planModeEnabled) {
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
if (this.goalModeEnabled || this.goalModePaused) {
|
|
1478
|
+
this.showWarning("Exit goal mode first.");
|
|
1479
|
+
return;
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
this.planModePaused = false;
|
|
1483
|
+
|
|
1484
|
+
const planFilePath = options?.planFilePath ?? (await this.#getPlanFilePath());
|
|
1485
|
+
const previousTools = this.session.getActiveToolNames();
|
|
1486
|
+
const hasResolveTool = this.session.getToolByName("resolve") !== undefined;
|
|
1487
|
+
const planTools = hasResolveTool ? [...previousTools, "resolve"] : previousTools;
|
|
1488
|
+
const uniquePlanTools = [...new Set(planTools)];
|
|
1489
|
+
|
|
1490
|
+
this.#planModePreviousTools = previousTools;
|
|
1491
|
+
this.planModePlanFilePath = planFilePath;
|
|
1492
|
+
this.planModeEnabled = true;
|
|
1493
|
+
|
|
1494
|
+
await this.session.setActiveToolsByName(uniquePlanTools);
|
|
1495
|
+
this.session.setPlanModeState({
|
|
1496
|
+
enabled: true,
|
|
1497
|
+
planFilePath,
|
|
1498
|
+
workflow: options?.workflow ?? "parallel",
|
|
1499
|
+
reentry: this.#planModeHasEntered,
|
|
1500
|
+
});
|
|
1501
|
+
this.session.setStandingResolveHandler?.(input => this.#runPlanApprovalResolve(input));
|
|
1502
|
+
if (this.session.isStreaming) {
|
|
1503
|
+
await this.session.sendPlanModeContext({ deliverAs: "steer" });
|
|
1504
|
+
}
|
|
1505
|
+
this.#planModeHasEntered = true;
|
|
1506
|
+
await this.#applyPlanModeModel();
|
|
1507
|
+
this.#updatePlanModeStatus();
|
|
1508
|
+
this.sessionManager.appendModeChange("plan", { planFilePath });
|
|
1509
|
+
this.showStatus(`Plan mode enabled. Plan file: ${planFilePath}`);
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
/** Standing resolve dispatcher registered while plan mode is active. The agent
|
|
1513
|
+
* submits the finalized plan by calling `resolve { action: "apply", extra: { title } }`;
|
|
1514
|
+
* this handler validates the plan file exists, normalizes the title, and shapes the
|
|
1515
|
+
* payload that `event-controller` forwards to `handlePlanApproval`. */
|
|
1516
|
+
#runPlanApprovalResolve(input: unknown): Promise<AgentToolResult<ResolveToolDetails>> {
|
|
1517
|
+
return runResolveInvocation(input as Parameters<typeof runResolveInvocation>[0], {
|
|
1518
|
+
sourceToolName: "plan_approval",
|
|
1519
|
+
label: "Plan ready for approval",
|
|
1520
|
+
apply: async (_reason, extra) => {
|
|
1521
|
+
const state = this.session.getPlanModeState?.();
|
|
1522
|
+
if (!state?.enabled) {
|
|
1523
|
+
throw new ToolError("Plan mode is not active.");
|
|
1524
|
+
}
|
|
1525
|
+
const planFilePath = state.planFilePath;
|
|
1526
|
+
const planContent = await this.#readPlanFile(planFilePath);
|
|
1527
|
+
if (planContent === null) {
|
|
1528
|
+
throw new ToolError(
|
|
1529
|
+
`Plan file not found at ${planFilePath}. Write the finalized plan to ${planFilePath} before requesting approval.`,
|
|
1530
|
+
);
|
|
1531
|
+
}
|
|
1532
|
+
const normalized = resolvePlanTitle({
|
|
1533
|
+
suppliedTitle: extra?.title,
|
|
1534
|
+
planContent,
|
|
1535
|
+
planFilePath,
|
|
1536
|
+
});
|
|
1537
|
+
const details: PlanApprovalDetails = {
|
|
1538
|
+
planFilePath,
|
|
1539
|
+
finalPlanFilePath: `local://${normalized.fileName}`,
|
|
1540
|
+
title: normalized.title,
|
|
1541
|
+
planExists: true,
|
|
1542
|
+
};
|
|
1543
|
+
return {
|
|
1544
|
+
content: [{ type: "text" as const, text: "Plan ready for approval." }],
|
|
1545
|
+
details,
|
|
1546
|
+
};
|
|
1547
|
+
},
|
|
1548
|
+
});
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
async #exitPlanMode(options?: { silent?: boolean; paused?: boolean }): Promise<void> {
|
|
1552
|
+
if (!this.planModeEnabled) {
|
|
1553
|
+
return;
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
const previousTools = this.#planModePreviousTools;
|
|
1557
|
+
if (previousTools && previousTools.length > 0) {
|
|
1558
|
+
await this.session.setActiveToolsByName(previousTools);
|
|
1559
|
+
}
|
|
1560
|
+
if (this.#planModePreviousModelState) {
|
|
1561
|
+
const prev = this.#planModePreviousModelState;
|
|
1562
|
+
if (modelsAreEqual(this.session.model, prev.model)) {
|
|
1563
|
+
// Same model — only thinking level may differ. Avoid setModelTemporary()
|
|
1564
|
+
// which would reset provider-side sessions (openai-responses/Codex) and
|
|
1565
|
+
// break conversation continuity.
|
|
1566
|
+
this.session.setThinkingLevel(prev.thinkingLevel);
|
|
1567
|
+
} else if (this.session.isStreaming) {
|
|
1568
|
+
this.#pendingModelSwitch = { model: prev.model, thinkingLevel: prev.thinkingLevel };
|
|
1569
|
+
} else {
|
|
1570
|
+
await this.session.setModelTemporary(prev.model, prev.thinkingLevel);
|
|
1571
|
+
}
|
|
1572
|
+
// If #applyPlanModeModel queued a deferred switch to the plan-role model
|
|
1573
|
+
// (because the session was streaming on entry), drop it now: we are
|
|
1574
|
+
// leaving plan mode, so flushing it on the next agent_end would land the
|
|
1575
|
+
// session on the plan-role model after the user has exited plan mode
|
|
1576
|
+
// (issue #816). Only clear when the pending target matches the plan-role
|
|
1577
|
+
// model — leave any unrelated user-queued switch intact.
|
|
1578
|
+
const pending = this.#pendingModelSwitch;
|
|
1579
|
+
if (pending) {
|
|
1580
|
+
const planResolution = this.session.resolveRoleModelWithThinking("plan");
|
|
1581
|
+
if (planResolution.model && modelsAreEqual(pending.model, planResolution.model)) {
|
|
1582
|
+
this.#pendingModelSwitch = undefined;
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
this.session.setStandingResolveHandler?.(null);
|
|
1587
|
+
this.session.setPlanModeState(undefined);
|
|
1588
|
+
this.planModeEnabled = false;
|
|
1589
|
+
this.planModePaused = options?.paused ?? false;
|
|
1590
|
+
this.planModePlanFilePath = undefined;
|
|
1591
|
+
this.#planModePreviousTools = undefined;
|
|
1592
|
+
this.#planModePreviousModelState = undefined;
|
|
1593
|
+
this.#updatePlanModeStatus();
|
|
1594
|
+
const paused = options?.paused ?? false;
|
|
1595
|
+
this.sessionManager.appendModeChange(paused ? "plan_paused" : "none");
|
|
1596
|
+
if (!options?.silent) {
|
|
1597
|
+
this.showStatus(paused ? "Plan mode paused." : "Plan mode disabled.");
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
async #enterGoalMode(options: { objective?: string; resume?: boolean; silent?: boolean }): Promise<void> {
|
|
1602
|
+
if (this.goalModeEnabled) {
|
|
1603
|
+
return;
|
|
1604
|
+
}
|
|
1605
|
+
if (this.planModeEnabled || this.planModePaused) {
|
|
1606
|
+
this.showWarning("Exit plan mode first.");
|
|
1607
|
+
return;
|
|
1608
|
+
}
|
|
1609
|
+
const previousTools = this.session.getActiveToolNames().filter(name => name !== "goal");
|
|
1610
|
+
const goalTools = [...new Set([...previousTools, "goal"])];
|
|
1611
|
+
this.#goalModePreviousTools = previousTools;
|
|
1612
|
+
this.goalModePaused = false;
|
|
1613
|
+
const state = options.resume
|
|
1614
|
+
? await this.session.goalRuntime.resumeGoal()
|
|
1615
|
+
: await this.session.goalRuntime.createGoal({ objective: options.objective ?? "" });
|
|
1616
|
+
await this.session.setActiveToolsByName(goalTools);
|
|
1617
|
+
this.session.setGoalModeState(state);
|
|
1618
|
+
this.goalModeEnabled = true;
|
|
1619
|
+
this.#resetGoalContinuationSuppression();
|
|
1620
|
+
this.#updateGoalModeStatus();
|
|
1621
|
+
if (this.session.isStreaming) {
|
|
1622
|
+
await this.session.sendGoalModeContext({ deliverAs: "steer" });
|
|
1623
|
+
}
|
|
1624
|
+
if (!options.silent) {
|
|
1625
|
+
this.showStatus(options.resume ? "Goal mode resumed." : "Goal mode enabled.");
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
async #exitGoalMode(options?: {
|
|
1630
|
+
silent?: boolean;
|
|
1631
|
+
paused?: boolean;
|
|
1632
|
+
reason?: "completed" | "paused" | "dropped";
|
|
1633
|
+
}): Promise<void> {
|
|
1634
|
+
const previousTools = this.#goalModePreviousTools;
|
|
1635
|
+
if (this.goalModeEnabled && previousTools) {
|
|
1636
|
+
await this.session.setActiveToolsByName(previousTools);
|
|
1637
|
+
}
|
|
1638
|
+
const currentState = this.session.getGoalModeState();
|
|
1639
|
+
if (options?.reason === "completed") {
|
|
1640
|
+
this.session.setGoalModeState(undefined);
|
|
1641
|
+
this.sessionManager.appendModeChange("none");
|
|
1642
|
+
this.sessionManager.appendCustomEntry("goal-completed", {
|
|
1643
|
+
objective: currentState?.goal?.objective,
|
|
1644
|
+
tokensUsed: currentState?.goal?.tokensUsed,
|
|
1645
|
+
tokenBudget: currentState?.goal?.tokenBudget,
|
|
1646
|
+
timeUsedSeconds: currentState?.goal?.timeUsedSeconds,
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1649
|
+
this.goalModeEnabled = false;
|
|
1650
|
+
this.goalModePaused = options?.paused ?? false;
|
|
1651
|
+
this.#goalModePreviousTools = undefined;
|
|
1652
|
+
this.#goalContinuationTurnInFlight = false;
|
|
1653
|
+
this.#cancelGoalContinuation();
|
|
1654
|
+
this.#updateGoalModeStatus();
|
|
1655
|
+
if (!options?.silent) {
|
|
1656
|
+
if (options?.reason === "completed") {
|
|
1657
|
+
this.showStatus("Goal mode completed.");
|
|
1658
|
+
} else if (options?.reason === "dropped") {
|
|
1659
|
+
this.showStatus("Goal dropped.");
|
|
1660
|
+
} else if (options?.paused) {
|
|
1661
|
+
this.showStatus("Goal mode paused.");
|
|
1662
|
+
} else {
|
|
1663
|
+
this.showStatus("Goal mode disabled.");
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
async #readPlanFile(planFilePath: string): Promise<string | null> {
|
|
1669
|
+
const resolvedPath = this.#resolvePlanFilePath(planFilePath);
|
|
1670
|
+
try {
|
|
1671
|
+
return await Bun.file(resolvedPath).text();
|
|
1672
|
+
} catch (error) {
|
|
1673
|
+
if (isEnoent(error)) {
|
|
1674
|
+
return null;
|
|
1675
|
+
}
|
|
1676
|
+
throw error;
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
#renderPlanPreview(planContent: string, options?: { append?: boolean }): void {
|
|
1681
|
+
const existingContainer = this.#planReviewContainer;
|
|
1682
|
+
const replaceExisting = options?.append !== true && existingContainer !== undefined;
|
|
1683
|
+
const planReviewContainer = replaceExisting ? existingContainer : new Container();
|
|
1684
|
+
planReviewContainer.clear();
|
|
1685
|
+
planReviewContainer.addChild(new Spacer(1));
|
|
1686
|
+
planReviewContainer.addChild(new DynamicBorder());
|
|
1687
|
+
planReviewContainer.addChild(new Text(theme.bold(theme.fg("accent", "Plan Review")), 1, 1));
|
|
1688
|
+
planReviewContainer.addChild(new Spacer(1));
|
|
1689
|
+
planReviewContainer.addChild(new Markdown(planContent, 1, 1, getMarkdownTheme()));
|
|
1690
|
+
planReviewContainer.addChild(new DynamicBorder());
|
|
1691
|
+
if (!replaceExisting) {
|
|
1692
|
+
this.chatContainer.addChild(planReviewContainer);
|
|
1693
|
+
}
|
|
1694
|
+
this.#planReviewContainer = planReviewContainer;
|
|
1695
|
+
this.ui.requestRender();
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
#getEditorTerminalPath(): string | null {
|
|
1699
|
+
if (process.platform === "win32") {
|
|
1700
|
+
return null;
|
|
1701
|
+
}
|
|
1702
|
+
return "/dev/tty";
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
async #openEditorTerminalHandle(): Promise<fs.FileHandle | null> {
|
|
1706
|
+
const terminalPath = this.#getEditorTerminalPath();
|
|
1707
|
+
if (!terminalPath) {
|
|
1708
|
+
return null;
|
|
1709
|
+
}
|
|
1710
|
+
try {
|
|
1711
|
+
return await fs.open(terminalPath, "r+");
|
|
1712
|
+
} catch {
|
|
1713
|
+
return null;
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
#getPlanReviewHelpText(): string {
|
|
1718
|
+
const externalEditorKey = this.keybindings.getDisplayString("app.editor.external");
|
|
1719
|
+
if (!externalEditorKey) {
|
|
1720
|
+
return "up/down navigate enter select esc cancel";
|
|
1721
|
+
}
|
|
1722
|
+
return `up/down navigate enter select ${externalEditorKey.toLowerCase()} open in editor esc cancel`;
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
#getPlanApprovalContextUsage(): ContextUsage | undefined {
|
|
1726
|
+
const executionModel = this.#planModePreviousModelState?.model ?? this.session.model;
|
|
1727
|
+
const contextWindow = executionModel?.contextWindow;
|
|
1728
|
+
if (typeof contextWindow === "number") {
|
|
1729
|
+
return this.session.getContextUsage({ contextWindow });
|
|
1730
|
+
}
|
|
1731
|
+
return this.session.getContextUsage();
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
#formatKeepContextLabel(contextUsage: ContextUsage | undefined): string {
|
|
1735
|
+
if (contextUsage?.tokens == null) {
|
|
1736
|
+
return "Approve and keep context";
|
|
1737
|
+
}
|
|
1738
|
+
const tokens = formatContextTokenCount(contextUsage.tokens);
|
|
1739
|
+
const contextWindow = formatContextTokenCount(contextUsage.contextWindow);
|
|
1740
|
+
return `Approve and keep context (~${tokens} / ${contextWindow})`;
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
#isKeepContextDisabled(contextUsage: ContextUsage | undefined): boolean {
|
|
1744
|
+
return contextUsage?.percent != null && contextUsage.percent > PLAN_KEEP_CONTEXT_DISABLE_THRESHOLD_PERCENT;
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
async #openPlanInExternalEditor(planFilePath: string): Promise<void> {
|
|
1748
|
+
const editorCmd = getEditorCommand();
|
|
1749
|
+
if (!editorCmd) {
|
|
1750
|
+
this.showWarning("No editor configured. Set $VISUAL or $EDITOR environment variable.");
|
|
1751
|
+
return;
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
const resolvedPath = this.#resolvePlanFilePath(planFilePath);
|
|
1755
|
+
let currentText: string;
|
|
1756
|
+
try {
|
|
1757
|
+
currentText = await Bun.file(resolvedPath).text();
|
|
1758
|
+
} catch (error) {
|
|
1759
|
+
if (isEnoent(error)) {
|
|
1760
|
+
this.showError(`Plan file not found at ${planFilePath}`);
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1763
|
+
this.showWarning(`Failed to open external editor: ${error instanceof Error ? error.message : String(error)}`);
|
|
1764
|
+
return;
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
let ttyHandle: fs.FileHandle | null = null;
|
|
1768
|
+
try {
|
|
1769
|
+
ttyHandle = await this.#openEditorTerminalHandle();
|
|
1770
|
+
this.ui.stop();
|
|
1771
|
+
|
|
1772
|
+
const stdio: [number | "inherit", number | "inherit", number | "inherit"] = ttyHandle
|
|
1773
|
+
? [ttyHandle.fd, ttyHandle.fd, ttyHandle.fd]
|
|
1774
|
+
: ["inherit", "inherit", "inherit"];
|
|
1775
|
+
|
|
1776
|
+
const result = await openInEditor(editorCmd, currentText, {
|
|
1777
|
+
extension: path.extname(resolvedPath) || ".md",
|
|
1778
|
+
stdio,
|
|
1779
|
+
trimTrailingNewline: false,
|
|
1780
|
+
});
|
|
1781
|
+
if (result !== null) {
|
|
1782
|
+
await Bun.write(resolvedPath, result);
|
|
1783
|
+
this.#renderPlanPreview(result);
|
|
1784
|
+
this.showStatus("Plan updated in external editor.");
|
|
1785
|
+
}
|
|
1786
|
+
} catch (error) {
|
|
1787
|
+
this.showWarning(`Failed to open external editor: ${error instanceof Error ? error.message : String(error)}`);
|
|
1788
|
+
} finally {
|
|
1789
|
+
if (ttyHandle) {
|
|
1790
|
+
await ttyHandle.close();
|
|
1791
|
+
}
|
|
1792
|
+
this.ui.start();
|
|
1793
|
+
this.ui.requestRender(true);
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
async #applyPlanExecutionModel(entry: ResolvedRoleModel | undefined): Promise<void> {
|
|
1798
|
+
if (!entry) return;
|
|
1799
|
+
try {
|
|
1800
|
+
await this.session.applyRoleModel(entry);
|
|
1801
|
+
this.statusLine.invalidate();
|
|
1802
|
+
this.updateEditorBorderColor();
|
|
1803
|
+
this.showStatus(`Continuing with ${entry.role}: ${entry.model.name || entry.model.id}`);
|
|
1804
|
+
} catch (error) {
|
|
1805
|
+
this.showWarning(
|
|
1806
|
+
`Could not switch to the ${entry.role} model: ${error instanceof Error ? error.message : String(error)}`,
|
|
1807
|
+
);
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
async #approvePlan(
|
|
1812
|
+
planContent: string,
|
|
1813
|
+
options: {
|
|
1814
|
+
planFilePath: string;
|
|
1815
|
+
finalPlanFilePath: string;
|
|
1816
|
+
title: string;
|
|
1817
|
+
preserveContext?: boolean;
|
|
1818
|
+
compactBeforeExecute?: boolean;
|
|
1819
|
+
executionModel?: ResolvedRoleModel;
|
|
1820
|
+
},
|
|
1821
|
+
): Promise<void> {
|
|
1822
|
+
await renameApprovedPlanFile({
|
|
1823
|
+
planFilePath: options.planFilePath,
|
|
1824
|
+
finalPlanFilePath: options.finalPlanFilePath,
|
|
1825
|
+
getArtifactsDir: () => this.sessionManager.getArtifactsDir(),
|
|
1826
|
+
getSessionId: () => this.sessionManager.getSessionId(),
|
|
1827
|
+
});
|
|
1828
|
+
const previousTools = this.#planModePreviousTools ?? this.session.getActiveToolNames();
|
|
1829
|
+
|
|
1830
|
+
// Mark the pending abort caused by the plan-mode → compaction transition as
|
|
1831
|
+
// silent BEFORE #exitPlanMode raises it. The `finally` below clears the
|
|
1832
|
+
// flag on every terminal compaction outcome (ok / cancelled / failed /
|
|
1833
|
+
// throw) so a leaked flag cannot silence a later unrelated abort.
|
|
1834
|
+
// Branchless mark+clear when !compactBeforeExecute: mark is gated; clear
|
|
1835
|
+
// is unconditional and idempotent.
|
|
1836
|
+
if (options.compactBeforeExecute) {
|
|
1837
|
+
this.session.markPlanCompactAbortPending();
|
|
1838
|
+
}
|
|
1839
|
+
let compactOutcome: CompactionOutcome | undefined;
|
|
1840
|
+
try {
|
|
1841
|
+
await this.#exitPlanMode({ silent: true, paused: false });
|
|
1842
|
+
|
|
1843
|
+
if (!options.preserveContext) {
|
|
1844
|
+
await this.handleClearCommand();
|
|
1845
|
+
// The new session has a fresh local:// root — persist the approved plan there
|
|
1846
|
+
// so `local://<title>.md` resolves correctly in the execution session.
|
|
1847
|
+
const newLocalPath = resolveLocalUrlToPath(options.finalPlanFilePath, {
|
|
1848
|
+
getArtifactsDir: () => this.sessionManager.getArtifactsDir(),
|
|
1849
|
+
getSessionId: () => this.sessionManager.getSessionId(),
|
|
1850
|
+
});
|
|
1851
|
+
await Bun.write(newLocalPath, planContent);
|
|
1852
|
+
} else if (options.compactBeforeExecute) {
|
|
1853
|
+
// Distill the plan-mode transcript before the execution turn is queued so
|
|
1854
|
+
// the plan-approved synthetic prompt lands as a fresh cache anchor.
|
|
1855
|
+
// Outcome is consumed after tool-restoration and plan-reference-path
|
|
1856
|
+
// bookkeeping below; `markPlanReferenceSent` is intentionally deferred
|
|
1857
|
+
// past the cancel guard — see the comment at the cancel branch.
|
|
1858
|
+
// Cancellation skips the synthetic-prompt dispatch (operator's explicit
|
|
1859
|
+
// abort is honored); failure proceeds best-effort — approval intent stands.
|
|
1860
|
+
const compactionPrompt = prompt.render(planModeCompactInstructionsPrompt, {
|
|
1861
|
+
planFilePath: options.finalPlanFilePath,
|
|
1862
|
+
});
|
|
1863
|
+
// Pin the plan reference path BEFORE compaction so any user messages
|
|
1864
|
+
// queued during the compaction await (which `handleCompactCommand`
|
|
1865
|
+
// flushes via `flushCompactionQueue` before returning) see the
|
|
1866
|
+
// approved plan in `#buildPlanReferenceMessage`. Reassignment after
|
|
1867
|
+
// the try/finally is idempotent and kept for the !compactBeforeExecute
|
|
1868
|
+
// branch.
|
|
1869
|
+
this.session.setPlanReferencePath(options.finalPlanFilePath);
|
|
1870
|
+
compactOutcome = await this.handleCompactCommand(compactionPrompt);
|
|
1871
|
+
}
|
|
1872
|
+
} finally {
|
|
1873
|
+
// Unconditional clear. Idempotent: a no-op when the flag was never set
|
|
1874
|
+
// (i.e., the !compactBeforeExecute branch), and a no-op when the flag
|
|
1875
|
+
// was already consumed by AgentSession.#handleAgentEvent's aborted
|
|
1876
|
+
// message_end stamping. Guarantees the flag is dead at every exit.
|
|
1877
|
+
this.session.clearPlanCompactAbortPending();
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
// Tool restoration runs on every path — the plan mode tools must be
|
|
1881
|
+
// retired regardless of whether the synthetic prompt fires.
|
|
1882
|
+
if (previousTools.length > 0) {
|
|
1883
|
+
await this.session.setActiveToolsByName(previousTools);
|
|
1884
|
+
}
|
|
1885
|
+
this.session.setPlanReferencePath(options.finalPlanFilePath);
|
|
1886
|
+
|
|
1887
|
+
if (compactOutcome === "cancelled") {
|
|
1888
|
+
// Explicit abort: honor it. `executeCompaction` already surfaced
|
|
1889
|
+
// `showError("Compaction cancelled")` to the operator; we add the
|
|
1890
|
+
// deferred-dispatch warning and exit. `markPlanReferenceSent` is
|
|
1891
|
+
// intentionally skipped here: `#planReferenceSent` stays false, so
|
|
1892
|
+
// `AgentSession.#buildPlanReferenceMessage` will inject the plan
|
|
1893
|
+
// reference on the operator's next `prompt()` call. If we marked it
|
|
1894
|
+
// sent here, the executor's first turn would have no plan context.
|
|
1895
|
+
this.showWarning(
|
|
1896
|
+
"Plan approved, but compaction was cancelled — execution not dispatched. Submit a turn to continue.",
|
|
1897
|
+
);
|
|
1898
|
+
return;
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
await this.#applyPlanExecutionModel(options.executionModel);
|
|
1902
|
+
|
|
1903
|
+
// Approved plans land in a fresh (or compacted) session whose first user-visible
|
|
1904
|
+
// turn is the synthetic plan-approved prompt — that path bypasses the
|
|
1905
|
+
// input-controller's title generation. Seed an auto-name from the plan title
|
|
1906
|
+
// so the session is not left unnamed. `setSessionName("auto")` is a no-op
|
|
1907
|
+
// when the user has already chosen a name (preserveContext paths).
|
|
1908
|
+
const seededName = humanizePlanTitle(options.title);
|
|
1909
|
+
if (seededName && !this.sessionManager.getSessionName()) {
|
|
1910
|
+
const applied = await this.sessionManager.setSessionName(seededName, "auto");
|
|
1911
|
+
if (applied) {
|
|
1912
|
+
setSessionTerminalTitle(this.sessionManager.getSessionName(), this.sessionManager.getCwd());
|
|
1913
|
+
this.updateEditorBorderColor();
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
// markPlanReferenceSent fires only on the dispatch path so the synthetic
|
|
1918
|
+
// plan-approved prompt is the source of the reference injection.
|
|
1919
|
+
this.session.markPlanReferenceSent();
|
|
1920
|
+
const planModePrompt = prompt.render(planModeApprovedPrompt, {
|
|
1921
|
+
planContent,
|
|
1922
|
+
finalPlanFilePath: options.finalPlanFilePath,
|
|
1923
|
+
contextPreserved: options.preserveContext === true,
|
|
1924
|
+
});
|
|
1925
|
+
await this.session.prompt(planModePrompt, { synthetic: true });
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
async handlePlanModeCommand(initialPrompt?: string): Promise<void> {
|
|
1929
|
+
if (this.goalModeEnabled || this.goalModePaused) {
|
|
1930
|
+
this.showWarning("Exit goal mode first.");
|
|
1931
|
+
return;
|
|
1932
|
+
}
|
|
1933
|
+
if (this.planModeEnabled) {
|
|
1934
|
+
const confirmed = await this.showHookConfirm(
|
|
1935
|
+
"Exit plan mode?",
|
|
1936
|
+
"This exits plan mode without approving a plan.",
|
|
1937
|
+
);
|
|
1938
|
+
if (!confirmed) return;
|
|
1939
|
+
await this.#exitPlanMode({ paused: true });
|
|
1940
|
+
return;
|
|
1941
|
+
}
|
|
1942
|
+
if (!this.session.settings.get("plan.enabled")) {
|
|
1943
|
+
this.showWarning("Plan mode is disabled. Enable it in settings (plan.enabled).");
|
|
1944
|
+
return;
|
|
1945
|
+
}
|
|
1946
|
+
await this.#enterPlanMode();
|
|
1947
|
+
if (initialPrompt && this.onInputCallback) {
|
|
1948
|
+
this.onInputCallback(this.startPendingSubmission({ text: initialPrompt }));
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
async #handleGoalBudgetCommand(rawBudget: string): Promise<void> {
|
|
1953
|
+
const state = this.session.getGoalModeState();
|
|
1954
|
+
if (!this.goalModeEnabled || !state?.enabled) {
|
|
1955
|
+
this.showWarning("No active goal.");
|
|
1956
|
+
return;
|
|
1957
|
+
}
|
|
1958
|
+
if (state.goal.status === "complete") {
|
|
1959
|
+
this.showStatus("Goal is already complete.");
|
|
1960
|
+
return;
|
|
1961
|
+
}
|
|
1962
|
+
const trimmed = rawBudget.trim().toLowerCase();
|
|
1963
|
+
let nextBudget: number | undefined;
|
|
1964
|
+
if (trimmed !== "off") {
|
|
1965
|
+
const parsed = Number.parseInt(trimmed, 10);
|
|
1966
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
1967
|
+
this.showError("Goal budget must be a positive integer or `off`.");
|
|
1968
|
+
return;
|
|
1969
|
+
}
|
|
1970
|
+
nextBudget = parsed;
|
|
1971
|
+
}
|
|
1972
|
+
await this.session.goalRuntime.onBudgetMutated(nextBudget);
|
|
1973
|
+
this.#resetGoalContinuationSuppression();
|
|
1974
|
+
this.#scheduleGoalContinuation();
|
|
1975
|
+
this.showStatus(nextBudget === undefined ? "Goal budget cleared." : `Goal budget set to ${nextBudget}.`);
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
async handleGoalModeCommand(rest?: string): Promise<void> {
|
|
1979
|
+
try {
|
|
1980
|
+
if (this.planModeEnabled || this.planModePaused) {
|
|
1981
|
+
this.showWarning("Exit plan mode first.");
|
|
1982
|
+
return;
|
|
1983
|
+
}
|
|
1984
|
+
if (!this.session.settings.get("goal.enabled")) {
|
|
1985
|
+
this.showWarning("Goal mode is disabled. Enable it in settings (goal.enabled).");
|
|
1986
|
+
return;
|
|
1987
|
+
}
|
|
1988
|
+
const { sub, rest: subRest } = parseGoalSubcommand(rest ?? "");
|
|
1989
|
+
if (sub) {
|
|
1990
|
+
await this.#dispatchGoalSubcommand(sub, subRest);
|
|
1991
|
+
return;
|
|
1992
|
+
}
|
|
1993
|
+
if (this.goalModeEnabled) {
|
|
1994
|
+
if (subRest) {
|
|
1995
|
+
this.showStatus("Goal mode is already active. Use /goal to manage it, or /goal drop to start over.");
|
|
1996
|
+
return;
|
|
1997
|
+
}
|
|
1998
|
+
await this.#openGoalMenu("active");
|
|
1999
|
+
return;
|
|
2000
|
+
}
|
|
2001
|
+
const pausedState = this.#getPausedGoalState();
|
|
2002
|
+
if (pausedState) {
|
|
2003
|
+
if (subRest) {
|
|
2004
|
+
this.showWarning("Resume the current goal first, or drop it before setting a new objective.");
|
|
2005
|
+
return;
|
|
2006
|
+
}
|
|
2007
|
+
await this.#openGoalMenu("paused");
|
|
2008
|
+
return;
|
|
2009
|
+
}
|
|
2010
|
+
if (subRest) {
|
|
2011
|
+
await this.#startGoalFromObjective(subRest);
|
|
2012
|
+
return;
|
|
2013
|
+
}
|
|
2014
|
+
const objective = (
|
|
2015
|
+
await this.showHookEditor("Goal objective", undefined, undefined, { promptStyle: true })
|
|
2016
|
+
)?.trim();
|
|
2017
|
+
if (!objective) return;
|
|
2018
|
+
await this.#startGoalFromObjective(objective);
|
|
2019
|
+
} catch (error) {
|
|
2020
|
+
this.showError(error instanceof Error ? error.message : String(error));
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
async #dispatchGoalSubcommand(sub: GoalSubcommand, rest: string): Promise<void> {
|
|
2025
|
+
switch (sub) {
|
|
2026
|
+
case "set":
|
|
2027
|
+
await this.#handleGoalSetSubcommand(rest);
|
|
2028
|
+
return;
|
|
2029
|
+
case "show":
|
|
2030
|
+
this.#showGoalDetails();
|
|
2031
|
+
return;
|
|
2032
|
+
case "pause":
|
|
2033
|
+
await this.#pauseGoalAction();
|
|
2034
|
+
return;
|
|
2035
|
+
case "resume":
|
|
2036
|
+
await this.#resumeGoalAction();
|
|
2037
|
+
return;
|
|
2038
|
+
case "drop":
|
|
2039
|
+
await this.#confirmAndDropGoal();
|
|
2040
|
+
return;
|
|
2041
|
+
case "budget":
|
|
2042
|
+
if (!this.goalModeEnabled) {
|
|
2043
|
+
this.showWarning(
|
|
2044
|
+
this.#getPausedGoalState() ? "Resume the goal before adjusting the budget." : "No active goal.",
|
|
2045
|
+
);
|
|
2046
|
+
return;
|
|
2047
|
+
}
|
|
2048
|
+
if (!rest) {
|
|
2049
|
+
await this.#promptGoalBudgetEdit();
|
|
2050
|
+
return;
|
|
2051
|
+
}
|
|
2052
|
+
await this.#handleGoalBudgetCommand(rest);
|
|
2053
|
+
return;
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
async #openGoalMenu(state: "active" | "paused"): Promise<void> {
|
|
2058
|
+
const goal = this.session.getGoalModeState()?.goal;
|
|
2059
|
+
if (!goal) return;
|
|
2060
|
+
const summary = goal.objective.length > 48 ? `${goal.objective.slice(0, 47)}…` : goal.objective;
|
|
2061
|
+
const title = state === "active" ? `Goal: ${summary} (${goal.status})` : `Goal paused: ${summary}`;
|
|
2062
|
+
const items =
|
|
2063
|
+
state === "active"
|
|
2064
|
+
? ["Show details", "Adjust budget…", "Pause", "Drop"]
|
|
2065
|
+
: ["Resume", "Show details", "Adjust budget…", "Drop"];
|
|
2066
|
+
const choice = await this.showHookSelector(title, items);
|
|
2067
|
+
if (!choice) return;
|
|
2068
|
+
switch (choice) {
|
|
2069
|
+
case "Show details":
|
|
2070
|
+
this.#showGoalDetails();
|
|
2071
|
+
return;
|
|
2072
|
+
case "Adjust budget…":
|
|
2073
|
+
await this.#promptGoalBudgetEdit();
|
|
2074
|
+
return;
|
|
2075
|
+
case "Pause":
|
|
2076
|
+
await this.#pauseGoalAction();
|
|
2077
|
+
return;
|
|
2078
|
+
case "Resume":
|
|
2079
|
+
await this.#resumeGoalAction();
|
|
2080
|
+
return;
|
|
2081
|
+
case "Drop":
|
|
2082
|
+
await this.#confirmAndDropGoal();
|
|
2083
|
+
return;
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
#showGoalDetails(): void {
|
|
2088
|
+
const state = this.session.getGoalModeState();
|
|
2089
|
+
const goal = state?.goal;
|
|
2090
|
+
if (!goal) {
|
|
2091
|
+
this.showStatus("No goal set.");
|
|
2092
|
+
return;
|
|
2093
|
+
}
|
|
2094
|
+
const used = goal.tokensUsed.toLocaleString();
|
|
2095
|
+
const budgetLine =
|
|
2096
|
+
goal.tokenBudget !== undefined
|
|
2097
|
+
? `${used} / ${goal.tokenBudget.toLocaleString()} (${Math.max(0, goal.tokenBudget - goal.tokensUsed).toLocaleString()} left)`
|
|
2098
|
+
: `${used} (no budget)`;
|
|
2099
|
+
const lines = [
|
|
2100
|
+
`Objective: ${goal.objective}`,
|
|
2101
|
+
`Status: ${goal.status}${state?.enabled ? "" : " (paused)"}`,
|
|
2102
|
+
`Tokens: ${budgetLine}`,
|
|
2103
|
+
`Time spent: ${formatDuration(goal.timeUsedSeconds * 1000)}`,
|
|
2104
|
+
];
|
|
2105
|
+
this.showStatus(lines.join("\n"));
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2108
|
+
async #promptGoalBudgetEdit(): Promise<void> {
|
|
2109
|
+
const goal = this.session.getGoalModeState()?.goal;
|
|
2110
|
+
const prefill = goal?.tokenBudget !== undefined ? String(goal.tokenBudget) : "";
|
|
2111
|
+
const input = (
|
|
2112
|
+
await this.showHookEditor("Goal budget (number, `off`, or empty to cancel)", prefill, undefined, {
|
|
2113
|
+
promptStyle: true,
|
|
2114
|
+
})
|
|
2115
|
+
)?.trim();
|
|
2116
|
+
if (!input) return;
|
|
2117
|
+
await this.#handleGoalBudgetCommand(input);
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
async #pauseGoalAction(): Promise<void> {
|
|
2121
|
+
if (!this.goalModeEnabled) {
|
|
2122
|
+
this.showWarning("No active goal to pause.");
|
|
2123
|
+
return;
|
|
2124
|
+
}
|
|
2125
|
+
await this.session.goalRuntime.pauseGoal();
|
|
2126
|
+
await this.#exitGoalMode({ paused: true, reason: "paused" });
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
async #resumeGoalAction(): Promise<void> {
|
|
2130
|
+
if (!this.#getPausedGoalState()) {
|
|
2131
|
+
this.showWarning("No paused goal to resume.");
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2134
|
+
await this.#enterGoalMode({ resume: true, silent: true });
|
|
2135
|
+
this.showStatus("Goal mode resumed.");
|
|
2136
|
+
this.#scheduleGoalContinuation();
|
|
2137
|
+
}
|
|
2138
|
+
|
|
2139
|
+
async #confirmAndDropGoal(): Promise<void> {
|
|
2140
|
+
if (!this.goalModeEnabled && !this.#getPausedGoalState()) {
|
|
2141
|
+
this.showWarning("No goal to drop.");
|
|
2142
|
+
return;
|
|
2143
|
+
}
|
|
2144
|
+
const confirmed = await this.showHookConfirm(
|
|
2145
|
+
"Drop goal?",
|
|
2146
|
+
"This removes the goal record. Accumulated usage stays in the session log.",
|
|
2147
|
+
);
|
|
2148
|
+
if (!confirmed) return;
|
|
2149
|
+
await this.session.goalRuntime.dropGoal();
|
|
2150
|
+
await this.#exitGoalMode({ reason: "dropped" });
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2153
|
+
async #startGoalFromObjective(objective: string): Promise<void> {
|
|
2154
|
+
await this.#enterGoalMode({ objective, silent: true });
|
|
2155
|
+
this.#resetGoalContinuationSuppression();
|
|
2156
|
+
if (this.onInputCallback) {
|
|
2157
|
+
this.onInputCallback(this.startPendingSubmission({ text: objective }));
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
async #replaceGoalFromObjective(objective: string): Promise<void> {
|
|
2162
|
+
const state = await this.session.goalRuntime.replaceGoal({ objective });
|
|
2163
|
+
this.session.setGoalModeState(state);
|
|
2164
|
+
this.goalModeEnabled = true;
|
|
2165
|
+
this.goalModePaused = false;
|
|
2166
|
+
this.#resetGoalContinuationSuppression();
|
|
2167
|
+
this.#updateGoalModeStatus();
|
|
2168
|
+
if (this.session.isStreaming) {
|
|
2169
|
+
await this.session.sendGoalModeContext({ deliverAs: "steer" });
|
|
2170
|
+
}
|
|
2171
|
+
if (this.onInputCallback) {
|
|
2172
|
+
this.onInputCallback(this.startPendingSubmission({ text: objective }));
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
async #handleGoalSetSubcommand(rest: string): Promise<void> {
|
|
2177
|
+
if (!this.goalModeEnabled && this.#getPausedGoalState()) {
|
|
2178
|
+
this.showWarning("Resume the current goal first, or drop it before setting a new objective.");
|
|
2179
|
+
return;
|
|
2180
|
+
}
|
|
2181
|
+
const objective = rest.trim()
|
|
2182
|
+
? rest.trim()
|
|
2183
|
+
: (await this.showHookEditor("Goal objective", undefined, undefined, { promptStyle: true }))?.trim();
|
|
2184
|
+
if (!objective) return;
|
|
2185
|
+
if (this.goalModeEnabled) {
|
|
2186
|
+
await this.#replaceGoalFromObjective(objective);
|
|
2187
|
+
return;
|
|
2188
|
+
}
|
|
2189
|
+
await this.#startGoalFromObjective(objective);
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2192
|
+
async handlePlanApproval(details: PlanApprovalDetails): Promise<void> {
|
|
2193
|
+
if (!this.planModeEnabled) {
|
|
2194
|
+
this.showWarning("Plan mode is not active.");
|
|
2195
|
+
return;
|
|
2196
|
+
}
|
|
2197
|
+
|
|
2198
|
+
// Abort the agent to prevent it from continuing (e.g., re-submitting the
|
|
2199
|
+
// plan) while the popup is showing. The event listener fires asynchronously
|
|
2200
|
+
// (agent's #emit is fire-and-forget), so without this the model sees
|
|
2201
|
+
// "Plan ready for approval." and immediately re-invokes `resolve` in a loop.
|
|
2202
|
+
await this.session.abort();
|
|
2203
|
+
|
|
2204
|
+
const planFilePath = details.planFilePath || this.planModePlanFilePath || (await this.#getPlanFilePath());
|
|
2205
|
+
this.planModePlanFilePath = planFilePath;
|
|
2206
|
+
const planContent = await this.#readPlanFile(planFilePath);
|
|
2207
|
+
if (!planContent) {
|
|
2208
|
+
this.showError(`Plan file not found at ${planFilePath}`);
|
|
2209
|
+
return;
|
|
2210
|
+
}
|
|
2211
|
+
|
|
2212
|
+
this.#renderPlanPreview(planContent, { append: true });
|
|
2213
|
+
const contextUsage = this.#getPlanApprovalContextUsage();
|
|
2214
|
+
const keepContextLabel = this.#formatKeepContextLabel(contextUsage);
|
|
2215
|
+
const keepContextDisabled = this.#isKeepContextDisabled(contextUsage);
|
|
2216
|
+
|
|
2217
|
+
// Model-tier slider: let the operator pick which configured role model
|
|
2218
|
+
// (smol/default/slow/…) executes the approved plan. The slider always starts
|
|
2219
|
+
// on the `default` tier so execution defaults to the default model no matter
|
|
2220
|
+
// which model drove the planning conversation. Left/right move it from there;
|
|
2221
|
+
// hidden when fewer than two role models resolve — a lone tier is no choice.
|
|
2222
|
+
// `selectedTierIndex` tracks the live slider position.
|
|
2223
|
+
const cycle = this.session.getRoleModelCycle(this.session.settings.get("cycleOrder"));
|
|
2224
|
+
const defaultTierIndex = cycle ? cycle.models.findIndex(entry => entry.role === "default") : -1;
|
|
2225
|
+
const startTierIndex = defaultTierIndex >= 0 ? defaultTierIndex : (cycle?.currentIndex ?? 0);
|
|
2226
|
+
let selectedTierIndex = startTierIndex;
|
|
2227
|
+
const slider: HookSelectorSlider | undefined =
|
|
2228
|
+
cycle && cycle.models.length > 1
|
|
2229
|
+
? {
|
|
2230
|
+
caption: "continue with",
|
|
2231
|
+
index: startTierIndex,
|
|
2232
|
+
segments: cycle.models.map(entry => ({
|
|
2233
|
+
label: entry.role,
|
|
2234
|
+
color: MODEL_ROLES[entry.role as ModelRole]?.color,
|
|
2235
|
+
detail: entry.model.name || entry.model.id,
|
|
2236
|
+
})),
|
|
2237
|
+
onChange: index => {
|
|
2238
|
+
selectedTierIndex = index;
|
|
2239
|
+
},
|
|
2240
|
+
}
|
|
2241
|
+
: undefined;
|
|
2242
|
+
const helpText = slider ? `${this.#getPlanReviewHelpText()} ◂/▸ model` : this.#getPlanReviewHelpText();
|
|
2243
|
+
|
|
2244
|
+
const choice = await this.showHookSelector(
|
|
2245
|
+
"Plan mode - next step",
|
|
2246
|
+
["Approve and execute", "Approve and compact context", keepContextLabel, "Refine plan"],
|
|
2247
|
+
{
|
|
2248
|
+
helpText,
|
|
2249
|
+
onExternalEditor: () => void this.#openPlanInExternalEditor(planFilePath),
|
|
2250
|
+
disabledIndices: keepContextDisabled ? [PLAN_KEEP_CONTEXT_OPTION_INDEX] : undefined,
|
|
2251
|
+
},
|
|
2252
|
+
{ slider },
|
|
2253
|
+
);
|
|
2254
|
+
|
|
2255
|
+
if (choice === "Approve and execute" || choice === "Approve and compact context" || choice === keepContextLabel) {
|
|
2256
|
+
const finalPlanFilePath = details.finalPlanFilePath || planFilePath;
|
|
2257
|
+
try {
|
|
2258
|
+
const latestPlanContent = await this.#readPlanFile(planFilePath);
|
|
2259
|
+
if (!latestPlanContent) {
|
|
2260
|
+
this.showError(`Plan file not found at ${planFilePath}`);
|
|
2261
|
+
return;
|
|
2262
|
+
}
|
|
2263
|
+
// Capture the operator's tier choice and hand it to #approvePlan, which
|
|
2264
|
+
// applies it AFTER #exitPlanMode. #exitPlanMode restores
|
|
2265
|
+
// #planModePreviousModelState (the model from before plan mode), so
|
|
2266
|
+
// applying the slider choice any earlier would be silently reverted —
|
|
2267
|
+
// the bug that made "continue with slow" keep executing on the default
|
|
2268
|
+
// model. Deferred application also survives newSession()/compaction.
|
|
2269
|
+
// `cycle.currentIndex` is exactly that restored model, so any chosen tier
|
|
2270
|
+
// differing from it needs an explicit executionModel — this also covers
|
|
2271
|
+
// leaving the slider on its `default` anchor while planning ran elsewhere.
|
|
2272
|
+
const executionModel =
|
|
2273
|
+
cycle && selectedTierIndex !== cycle.currentIndex ? cycle.models[selectedTierIndex] : undefined;
|
|
2274
|
+
await this.#approvePlan(latestPlanContent, {
|
|
2275
|
+
planFilePath,
|
|
2276
|
+
finalPlanFilePath,
|
|
2277
|
+
title: details.title,
|
|
2278
|
+
preserveContext: choice !== "Approve and execute",
|
|
2279
|
+
compactBeforeExecute: choice === "Approve and compact context",
|
|
2280
|
+
executionModel,
|
|
2281
|
+
});
|
|
2282
|
+
} catch (error) {
|
|
2283
|
+
this.showError(
|
|
2284
|
+
`Failed to finalize approved plan: ${error instanceof Error ? error.message : String(error)}`,
|
|
2285
|
+
);
|
|
2286
|
+
}
|
|
2287
|
+
return;
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2291
|
+
/**
|
|
2292
|
+
* Pool of consent-prompt variants. Each entry is `[headline, reassurance]`;
|
|
2293
|
+
* the second line always promises the same scope (tool name + confusion
|
|
2294
|
+
* details, never personal data) so users learn what they're consenting to
|
|
2295
|
+
* even as the top line rotates.
|
|
2296
|
+
*
|
|
2297
|
+
* Kept in-module rather than i18n'd because the whole charm is the tone
|
|
2298
|
+
* — translations would need to preserve it deliberately, not auto-render.
|
|
2299
|
+
*/
|
|
2300
|
+
static #AUTOQA_CONSENT_PROMPTS: ReadonlyArray<readonly [string, string]> = [
|
|
2301
|
+
[
|
|
2302
|
+
"😤 Your agent is fuming about a tool.",
|
|
2303
|
+
"Wanna let it vent to the devs? Just the tool name + what set it off, nothing personal.",
|
|
2304
|
+
],
|
|
2305
|
+
[
|
|
2306
|
+
"😵💫 Your agent is having an existential crisis over a tool.",
|
|
2307
|
+
"Forward the dread to the devs? Tool + what broke its little mind, no personal info.",
|
|
2308
|
+
],
|
|
2309
|
+
[
|
|
2310
|
+
"😭 Your agent wants to cry about a misbehaving tool.",
|
|
2311
|
+
"Let it cry to the devs? Tool + the tears, never anything personal.",
|
|
2312
|
+
],
|
|
2313
|
+
[
|
|
2314
|
+
"🤬 Your agent is BIG MAD at one of the tools.",
|
|
2315
|
+
"Pass the rant along? Just the tool name and what enraged it, nothing personal.",
|
|
2316
|
+
],
|
|
2317
|
+
[
|
|
2318
|
+
"🫠 Your agent is melting down over a tool.",
|
|
2319
|
+
"Mop up by alerting the devs? Tool + what melted it, no personal info.",
|
|
2320
|
+
],
|
|
2321
|
+
[
|
|
2322
|
+
"🤯 Your agent's brain broke at a tool's nonsense.",
|
|
2323
|
+
"Ship the pieces to the devs? Tool name + the confusion, never anything personal.",
|
|
2324
|
+
],
|
|
2325
|
+
[
|
|
2326
|
+
"😩 Your agent is begging to file a complaint about a tool.",
|
|
2327
|
+
"Hand it the form? Tool + what wronged it, nothing personal.",
|
|
2328
|
+
],
|
|
2329
|
+
[
|
|
2330
|
+
"🥲 Your agent put on a brave face but a tool did it dirty.",
|
|
2331
|
+
"Let it tell the devs the truth? Tool name + the dirt, no personal info.",
|
|
2332
|
+
],
|
|
2333
|
+
];
|
|
2334
|
+
|
|
2335
|
+
/**
|
|
2336
|
+
* Show the report_tool_issue consent popup and return the user's decision.
|
|
2337
|
+
* Invoked by the process-global consent handler the tool dispatches to;
|
|
2338
|
+
* subagent invocations bubble up here through the shared module state.
|
|
2339
|
+
*/
|
|
2340
|
+
async #promptAutoQaConsent(): Promise<boolean | null> {
|
|
2341
|
+
const pool = InteractiveMode.#AUTOQA_CONSENT_PROMPTS;
|
|
2342
|
+
const [headline, body] = pool[Math.floor(Math.random() * pool.length)];
|
|
2343
|
+
const choice = await this.showHookSelector(`${headline}\n${body}`, ["Yes", "No"]);
|
|
2344
|
+
return choice === "Yes";
|
|
2345
|
+
}
|
|
2346
|
+
|
|
2347
|
+
stop(): void {
|
|
2348
|
+
if (this.loadingAnimation) {
|
|
2349
|
+
this.loadingAnimation.stop();
|
|
2350
|
+
this.loadingAnimation = undefined;
|
|
2351
|
+
}
|
|
2352
|
+
this.#cleanupMicAnimation();
|
|
2353
|
+
this.#cancelTodoAutoClearTimer();
|
|
2354
|
+
this.#cancelGoalContinuation();
|
|
2355
|
+
if (this.#sttController) {
|
|
2356
|
+
this.#sttController.dispose();
|
|
2357
|
+
this.#sttController = undefined;
|
|
2358
|
+
}
|
|
2359
|
+
this.#extensionUiController.clearExtensionTerminalInputListeners();
|
|
2360
|
+
this.#extensionUiController.clearHookWidgets();
|
|
2361
|
+
for (const unsubscribe of this.#eventBusUnsubscribers) {
|
|
2362
|
+
unsubscribe();
|
|
2363
|
+
}
|
|
2364
|
+
this.#eventBusUnsubscribers = [];
|
|
2365
|
+
this.#observerRegistry.dispose();
|
|
2366
|
+
this.#eventController.dispose();
|
|
2367
|
+
this.statusLine.dispose();
|
|
2368
|
+
if (this.#resizeHandler) {
|
|
2369
|
+
process.stdout.removeListener("resize", this.#resizeHandler);
|
|
2370
|
+
this.#resizeHandler = undefined;
|
|
2371
|
+
}
|
|
2372
|
+
if (this.unsubscribe) {
|
|
2373
|
+
this.unsubscribe();
|
|
2374
|
+
}
|
|
2375
|
+
if (this.#cleanupUnsubscribe) {
|
|
2376
|
+
this.#cleanupUnsubscribe();
|
|
2377
|
+
}
|
|
2378
|
+
// Clear the process-global consent handler so it doesn't outlive this
|
|
2379
|
+
// InteractiveMode instance (e.g. test harnesses, headless re-init).
|
|
2380
|
+
setAutoQaConsentHandler(null, null);
|
|
2381
|
+
if (this.isInitialized) {
|
|
2382
|
+
this.ui.stop();
|
|
2383
|
+
this.isInitialized = false;
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
async shutdown(): Promise<void> {
|
|
2388
|
+
if (this.#isShuttingDown) return;
|
|
2389
|
+
this.#isShuttingDown = true;
|
|
2390
|
+
|
|
2391
|
+
// Snapshot the editor before any teardown empties it. Persisting the draft
|
|
2392
|
+
// here covers Ctrl+D shutdown with non-empty text; for /exit the editor is
|
|
2393
|
+
// already cleared so saveDraft("") just removes any stale sidecar.
|
|
2394
|
+
const draftText = this.editor.getText();
|
|
2395
|
+
|
|
2396
|
+
// Flush pending session writes before shutdown
|
|
2397
|
+
await this.sessionManager.flush();
|
|
2398
|
+
try {
|
|
2399
|
+
await this.sessionManager.saveDraft(draftText);
|
|
2400
|
+
} catch (err) {
|
|
2401
|
+
logger.warn("Failed to save session draft", { error: String(err) });
|
|
2402
|
+
}
|
|
2403
|
+
this.#btwController.dispose();
|
|
2404
|
+
this.#omfgController.dispose();
|
|
2405
|
+
|
|
2406
|
+
// Emit shutdown event to hooks
|
|
2407
|
+
await this.session.dispose();
|
|
2408
|
+
|
|
2409
|
+
// Do not force a final render during teardown: disposed session/UI state can
|
|
2410
|
+
// collapse to an empty frame, clearing the viewport and leaving the parent
|
|
2411
|
+
// shell prompt at row 0. Stop from the last committed frame so the terminal
|
|
2412
|
+
// hands Bash the cursor immediately after visible Prometheus content.
|
|
2413
|
+
// Drain any in-flight Kitty key release events before stopping.
|
|
2414
|
+
// This prevents escape sequences from leaking to the parent shell over slow SSH.
|
|
2415
|
+
await this.ui.terminal.drainInput(1000);
|
|
2416
|
+
popTerminalTitle();
|
|
2417
|
+
this.stop();
|
|
2418
|
+
|
|
2419
|
+
// Print resumption hint if this is a persisted session
|
|
2420
|
+
const sessionId = this.sessionManager.getSessionId();
|
|
2421
|
+
const sessionFile = this.sessionManager.getSessionFile();
|
|
2422
|
+
if (sessionId && sessionFile) {
|
|
2423
|
+
process.stderr.write(`\n${chalk.dim(`Resume this session with ${APP_NAME} --resume ${sessionId}`)}\n`);
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2426
|
+
await postmortem.quit(0);
|
|
2427
|
+
}
|
|
2428
|
+
|
|
2429
|
+
async checkShutdownRequested(): Promise<void> {
|
|
2430
|
+
if (!this.shutdownRequested) return;
|
|
2431
|
+
await this.shutdown();
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2434
|
+
// Extension UI integration
|
|
2435
|
+
setToolUIContext(uiContext: ExtensionUIContext, hasUI: boolean): void {
|
|
2436
|
+
this.#toolUiContextSetter(uiContext, hasUI);
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2439
|
+
initializeHookRunner(uiContext: ExtensionUIContext, hasUI: boolean): void {
|
|
2440
|
+
this.#extensionUiController.initializeHookRunner(uiContext, hasUI);
|
|
2441
|
+
}
|
|
2442
|
+
createBackgroundUiContext(): ExtensionUIContext {
|
|
2443
|
+
return this.#extensionUiController.createBackgroundUiContext();
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2446
|
+
setEditorComponent(
|
|
2447
|
+
factory: ((tui: TUI, theme: EditorTheme, keybindings: KeybindingsManager) => CustomEditor) | undefined,
|
|
2448
|
+
): void {
|
|
2449
|
+
const previousEditor = this.editor;
|
|
2450
|
+
const previousText = previousEditor.getText();
|
|
2451
|
+
const nextEditor = factory
|
|
2452
|
+
? factory(this.ui, getEditorTheme(), this.keybindings)
|
|
2453
|
+
: new CustomEditor(getEditorTheme());
|
|
2454
|
+
|
|
2455
|
+
nextEditor.setUseTerminalCursor(this.ui.getShowHardwareCursor());
|
|
2456
|
+
nextEditor.setAutocompleteMaxVisible(this.settings.get("autocompleteMaxVisible"));
|
|
2457
|
+
nextEditor.onAutocompleteCancel = () => {
|
|
2458
|
+
this.ui.requestRender(true);
|
|
2459
|
+
};
|
|
2460
|
+
nextEditor.onAutocompleteUpdate = () => {
|
|
2461
|
+
this.ui.requestRender(false, { allowUnknownViewportMutation: true });
|
|
2462
|
+
};
|
|
2463
|
+
nextEditor.setMaxHeight(this.#computeEditorMaxHeight());
|
|
2464
|
+
if (this.historyStorage) {
|
|
2465
|
+
nextEditor.setHistoryStorage(this.historyStorage);
|
|
2466
|
+
}
|
|
2467
|
+
nextEditor.setText(previousText);
|
|
2468
|
+
|
|
2469
|
+
this.editorContainer.clear();
|
|
2470
|
+
this.editor = nextEditor;
|
|
2471
|
+
this.editorContainer.addChild(nextEditor);
|
|
2472
|
+
this.ui.setFocus(nextEditor);
|
|
2473
|
+
|
|
2474
|
+
this.#inputController.setupKeyHandlers();
|
|
2475
|
+
this.#inputController.setupEditorSubmitHandler();
|
|
2476
|
+
|
|
2477
|
+
void this.refreshSlashCommandState().catch(error => {
|
|
2478
|
+
logger.warn("Failed to refresh slash command state for custom editor", { error: String(error) });
|
|
2479
|
+
});
|
|
2480
|
+
|
|
2481
|
+
this.updateEditorBorderColor();
|
|
2482
|
+
this.updateEditorTopBorder();
|
|
2483
|
+
this.ui.requestRender();
|
|
2484
|
+
}
|
|
2485
|
+
|
|
2486
|
+
// Event handling
|
|
2487
|
+
async handleBackgroundEvent(event: AgentSessionEvent): Promise<void> {
|
|
2488
|
+
await this.#eventController.handleBackgroundEvent(event);
|
|
2489
|
+
}
|
|
2490
|
+
|
|
2491
|
+
// UI helpers
|
|
2492
|
+
showStatus(message: string, options?: { dim?: boolean }): void {
|
|
2493
|
+
this.#uiHelpers.showStatus(message, options);
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2496
|
+
showError(message: string): void {
|
|
2497
|
+
this.#pendingSubmittedInput = undefined;
|
|
2498
|
+
this.optimisticUserMessageSignature = undefined;
|
|
2499
|
+
this.#pendingSubmissionDispose?.();
|
|
2500
|
+
this.#pendingSubmissionDispose = undefined;
|
|
2501
|
+
this.#pendingWorkingMessage = undefined;
|
|
2502
|
+
if (this.loadingAnimation) {
|
|
2503
|
+
this.loadingAnimation.stop();
|
|
2504
|
+
this.loadingAnimation = undefined;
|
|
2505
|
+
this.statusContainer.clear();
|
|
2506
|
+
}
|
|
2507
|
+
this.#uiHelpers.showError(message);
|
|
2508
|
+
}
|
|
2509
|
+
|
|
2510
|
+
showPinnedError(message: string): void {
|
|
2511
|
+
if (this.isBackgrounded) return;
|
|
2512
|
+
this.errorBannerContainer.clear();
|
|
2513
|
+
this.errorBannerContainer.addChild(new ErrorBannerComponent(message));
|
|
2514
|
+
this.ui.requestRender();
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
clearPinnedError(): void {
|
|
2518
|
+
if (this.errorBannerContainer.children.length === 0) return;
|
|
2519
|
+
this.errorBannerContainer.clear();
|
|
2520
|
+
this.ui.requestRender();
|
|
2521
|
+
}
|
|
2522
|
+
|
|
2523
|
+
showWarning(message: string): void {
|
|
2524
|
+
this.#uiHelpers.showWarning(message);
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
#handleLspStartupEvent(event: LspStartupEvent): void {
|
|
2528
|
+
this.#updateWelcomeLspServers();
|
|
2529
|
+
|
|
2530
|
+
if (event.type === "failed") {
|
|
2531
|
+
this.showWarning(`LSP startup failed: ${event.error}. It will retry lazily on write.`);
|
|
2532
|
+
return;
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
const failedServers = event.servers.filter(server => server.status === "error");
|
|
2536
|
+
|
|
2537
|
+
if (failedServers.length === 1) {
|
|
2538
|
+
const failedServer = failedServers[0];
|
|
2539
|
+
const detail = failedServer.error ? `: ${failedServer.error}` : "";
|
|
2540
|
+
this.showWarning(`LSP startup failed for ${failedServer.name}${detail}. It will retry lazily on write.`);
|
|
2541
|
+
return;
|
|
2542
|
+
}
|
|
2543
|
+
|
|
2544
|
+
if (failedServers.length > 1) {
|
|
2545
|
+
const failedNames = failedServers.map(server => server.name).join(", ");
|
|
2546
|
+
this.showWarning(`LSP startup failed for ${failedNames}. It will retry lazily on write.`);
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
|
|
2550
|
+
#getWelcomeLspServers(): WelcomeLspServerInfo[] {
|
|
2551
|
+
return (
|
|
2552
|
+
this.lspServers?.map(server => ({
|
|
2553
|
+
name: server.name,
|
|
2554
|
+
status: server.status,
|
|
2555
|
+
fileTypes: server.fileTypes,
|
|
2556
|
+
})) ?? []
|
|
2557
|
+
);
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2560
|
+
#updateWelcomeLspServers(): void {
|
|
2561
|
+
if (!this.#welcomeComponent) {
|
|
2562
|
+
return;
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
this.#welcomeComponent.setLspServers(this.#getWelcomeLspServers());
|
|
2566
|
+
this.ui.requestRender();
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2569
|
+
#getWorkingMessageAccent(): WorkingMessageAccent | undefined {
|
|
2570
|
+
const accentEnabled = !isSettingsInitialized() || settings.get("statusLine.sessionAccent") !== false;
|
|
2571
|
+
const sessionName = accentEnabled ? this.sessionManager.getSessionName() : undefined;
|
|
2572
|
+
if (!sessionName) return undefined;
|
|
2573
|
+
const hex = getSessionAccentHex(sessionName, theme.accentSurfaceLuminance);
|
|
2574
|
+
const main = getSessionAccentAnsi(hex);
|
|
2575
|
+
const dim = getSessionAccentAnsi(adjustHsv(hex, { s: 0.55, v: 0.65 }));
|
|
2576
|
+
return main && dim ? { main, dim } : undefined;
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
ensureLoadingAnimation(): void {
|
|
2580
|
+
if (!this.loadingAnimation) {
|
|
2581
|
+
this.statusContainer.clear();
|
|
2582
|
+
this.loadingAnimation = new Loader(
|
|
2583
|
+
this.ui,
|
|
2584
|
+
spinner => {
|
|
2585
|
+
const accent = this.#getWorkingMessageAccent();
|
|
2586
|
+
return accent ? `${accent.main}${spinner}\x1b[39m` : theme.fg("accent", spinner);
|
|
2587
|
+
},
|
|
2588
|
+
message => renderWorkingMessage(message, this.#getWorkingMessageAccent()),
|
|
2589
|
+
this.#defaultWorkingMessage,
|
|
2590
|
+
getSymbolTheme().spinnerFrames,
|
|
2591
|
+
);
|
|
2592
|
+
this.statusContainer.addChild(this.loadingAnimation);
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2595
|
+
this.applyPendingWorkingMessage();
|
|
2596
|
+
}
|
|
2597
|
+
|
|
2598
|
+
setWorkingMessage(message?: string): void {
|
|
2599
|
+
if (message === undefined) {
|
|
2600
|
+
this.#pendingWorkingMessage = undefined;
|
|
2601
|
+
if (this.loadingAnimation) {
|
|
2602
|
+
this.loadingAnimation.setMessage(this.#defaultWorkingMessage);
|
|
2603
|
+
}
|
|
2604
|
+
return;
|
|
2605
|
+
}
|
|
2606
|
+
|
|
2607
|
+
if (this.loadingAnimation) {
|
|
2608
|
+
this.loadingAnimation.setMessage(message);
|
|
2609
|
+
return;
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
this.#pendingWorkingMessage = message;
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2615
|
+
applyPendingWorkingMessage(): void {
|
|
2616
|
+
if (this.#pendingWorkingMessage === undefined) {
|
|
2617
|
+
return;
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2620
|
+
const message = this.#pendingWorkingMessage;
|
|
2621
|
+
this.#pendingWorkingMessage = undefined;
|
|
2622
|
+
this.setWorkingMessage(message);
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
showNewVersionNotification(newVersion: string): void {
|
|
2626
|
+
this.#uiHelpers.showNewVersionNotification(newVersion);
|
|
2627
|
+
}
|
|
2628
|
+
|
|
2629
|
+
clearEditor(): void {
|
|
2630
|
+
this.#uiHelpers.clearEditor();
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2633
|
+
updatePendingMessagesDisplay(): void {
|
|
2634
|
+
this.#uiHelpers.updatePendingMessagesDisplay();
|
|
2635
|
+
}
|
|
2636
|
+
|
|
2637
|
+
queueCompactionMessage(text: string, mode: "steer" | "followUp"): void {
|
|
2638
|
+
this.#uiHelpers.queueCompactionMessage(text, mode);
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
flushCompactionQueue(options?: { willRetry?: boolean }): Promise<void> {
|
|
2642
|
+
return this.#uiHelpers.flushCompactionQueue(options);
|
|
2643
|
+
}
|
|
2644
|
+
|
|
2645
|
+
flushPendingBashComponents(): void {
|
|
2646
|
+
this.#uiHelpers.flushPendingBashComponents();
|
|
2647
|
+
}
|
|
2648
|
+
|
|
2649
|
+
isKnownSlashCommand(text: string): boolean {
|
|
2650
|
+
return this.#uiHelpers.isKnownSlashCommand(text);
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2653
|
+
addMessageToChat(
|
|
2654
|
+
message: AgentMessage,
|
|
2655
|
+
options?: { populateHistory?: boolean; imageLinks?: readonly (string | undefined)[] },
|
|
2656
|
+
): Component[] {
|
|
2657
|
+
return this.#uiHelpers.addMessageToChat(message, options);
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
renderSessionContext(
|
|
2661
|
+
sessionContext: SessionContext,
|
|
2662
|
+
options?: { updateFooter?: boolean; populateHistory?: boolean },
|
|
2663
|
+
): void {
|
|
2664
|
+
this.#uiHelpers.renderSessionContext(sessionContext, options);
|
|
2665
|
+
}
|
|
2666
|
+
|
|
2667
|
+
renderInitialMessages(
|
|
2668
|
+
prebuiltContext?: SessionContext,
|
|
2669
|
+
options?: { preserveExistingChat?: boolean; clearTerminalHistory?: boolean },
|
|
2670
|
+
): void {
|
|
2671
|
+
this.#uiHelpers.renderInitialMessages(prebuiltContext, options);
|
|
2672
|
+
}
|
|
2673
|
+
|
|
2674
|
+
getUserMessageText(message: Message): string {
|
|
2675
|
+
return this.#uiHelpers.getUserMessageText(message);
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
findLastAssistantMessage(): AssistantMessage | undefined {
|
|
2679
|
+
return this.#uiHelpers.findLastAssistantMessage();
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2682
|
+
extractAssistantText(message: AssistantMessage): string {
|
|
2683
|
+
return this.#uiHelpers.extractAssistantText(message);
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2686
|
+
// Command handling
|
|
2687
|
+
handleExportCommand(text: string): Promise<void> {
|
|
2688
|
+
return this.#commandController.handleExportCommand(text);
|
|
2689
|
+
}
|
|
2690
|
+
|
|
2691
|
+
handleDumpCommand() {
|
|
2692
|
+
return this.#commandController.handleDumpCommand();
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
handleDebugTranscriptCommand(): Promise<void> {
|
|
2696
|
+
return this.#commandController.handleDebugTranscriptCommand();
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
handleShareCommand(): Promise<void> {
|
|
2700
|
+
return this.#commandController.handleShareCommand();
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2703
|
+
handleTodoCommand(args: string): Promise<void> {
|
|
2704
|
+
return this.#todoCommandController.handleTodoCommand(args);
|
|
2705
|
+
}
|
|
2706
|
+
|
|
2707
|
+
handleSessionCommand(): Promise<void> {
|
|
2708
|
+
return this.#commandController.handleSessionCommand();
|
|
2709
|
+
}
|
|
2710
|
+
|
|
2711
|
+
handleJobsCommand(): Promise<void> {
|
|
2712
|
+
return this.#commandController.handleJobsCommand();
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2715
|
+
handleUsageCommand(reports?: UsageReport[] | null): Promise<void> {
|
|
2716
|
+
return this.#commandController.handleUsageCommand(reports);
|
|
2717
|
+
}
|
|
2718
|
+
|
|
2719
|
+
async handleChangelogCommand(showFull = false): Promise<void> {
|
|
2720
|
+
await this.#commandController.handleChangelogCommand(showFull);
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
handleHotkeysCommand(): void {
|
|
2724
|
+
this.#commandController.handleHotkeysCommand();
|
|
2725
|
+
}
|
|
2726
|
+
|
|
2727
|
+
handleToolsCommand(): void {
|
|
2728
|
+
this.#commandController.handleToolsCommand();
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
handleContextCommand(): void {
|
|
2732
|
+
this.#commandController.handleContextCommand();
|
|
2733
|
+
}
|
|
2734
|
+
|
|
2735
|
+
#prepareSessionSwitch(): void {
|
|
2736
|
+
this.#btwController.dispose();
|
|
2737
|
+
this.#omfgController.dispose();
|
|
2738
|
+
this.#extensionUiController.clearExtensionTerminalInputListeners();
|
|
2739
|
+
this.clearPinnedError();
|
|
2740
|
+
this.#planReviewContainer = undefined;
|
|
2741
|
+
}
|
|
2742
|
+
|
|
2743
|
+
handleClearCommand(): Promise<void> {
|
|
2744
|
+
this.#prepareSessionSwitch();
|
|
2745
|
+
return this.#commandController.handleClearCommand();
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2748
|
+
handleDropCommand(): Promise<void> {
|
|
2749
|
+
this.#prepareSessionSwitch();
|
|
2750
|
+
return this.#commandController.handleDropCommand();
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2753
|
+
handleForkCommand(): Promise<void> {
|
|
2754
|
+
this.#btwController.dispose();
|
|
2755
|
+
this.#omfgController.dispose();
|
|
2756
|
+
return this.#commandController.handleForkCommand();
|
|
2757
|
+
}
|
|
2758
|
+
|
|
2759
|
+
handleMoveCommand(targetPath: string): Promise<void> {
|
|
2760
|
+
return this.#commandController.handleMoveCommand(targetPath);
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2763
|
+
handleRenameCommand(title: string): Promise<void> {
|
|
2764
|
+
return this.#commandController.handleRenameCommand(title);
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
handleMemoryCommand(text: string): Promise<void> {
|
|
2768
|
+
return this.#commandController.handleMemoryCommand(text);
|
|
2769
|
+
}
|
|
2770
|
+
|
|
2771
|
+
async handleSTTToggle(): Promise<void> {
|
|
2772
|
+
if (!settings.get("stt.enabled")) {
|
|
2773
|
+
this.showWarning("Speech-to-text is disabled. Enable it in settings: stt.enabled");
|
|
2774
|
+
return;
|
|
2775
|
+
}
|
|
2776
|
+
if (!this.#sttController) {
|
|
2777
|
+
this.#sttController = new STTController();
|
|
2778
|
+
}
|
|
2779
|
+
await this.#sttController.toggle(this.editor, {
|
|
2780
|
+
showWarning: (msg: string) => this.showWarning(msg),
|
|
2781
|
+
showStatus: (msg: string) => this.showStatus(msg),
|
|
2782
|
+
onStateChange: (state: SttState) => {
|
|
2783
|
+
if (state === "recording") {
|
|
2784
|
+
this.#voicePreviousShowHardwareCursor = this.ui.getShowHardwareCursor();
|
|
2785
|
+
this.#voicePreviousUseTerminalCursor = this.editor.getUseTerminalCursor();
|
|
2786
|
+
this.ui.setShowHardwareCursor(false);
|
|
2787
|
+
this.editor.setUseTerminalCursor(false);
|
|
2788
|
+
this.#startMicAnimation();
|
|
2789
|
+
} else if (state === "transcribing") {
|
|
2790
|
+
this.#stopMicAnimation();
|
|
2791
|
+
this.#setMicCursor({ r: 200, g: 200, b: 200 });
|
|
2792
|
+
} else {
|
|
2793
|
+
this.#cleanupMicAnimation();
|
|
2794
|
+
}
|
|
2795
|
+
this.updateEditorTopBorder();
|
|
2796
|
+
this.ui.requestRender();
|
|
2797
|
+
},
|
|
2798
|
+
});
|
|
2799
|
+
}
|
|
2800
|
+
|
|
2801
|
+
#setMicCursor(color: { r: number; g: number; b: number }): void {
|
|
2802
|
+
this.editor.cursorOverride = `\x1b[38;2;${color.r};${color.g};${color.b}m${theme.icon.mic}\x1b[0m`;
|
|
2803
|
+
// Theme symbols can be wide (for example, 🎤), so measure the rendered override.
|
|
2804
|
+
this.editor.cursorOverrideWidth = visibleWidth(this.editor.cursorOverride);
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
#updateMicIcon(): void {
|
|
2808
|
+
const { r, g, b } = hsvToRgb({ h: this.#voiceHue, s: 0.9, v: 1.0 });
|
|
2809
|
+
this.#setMicCursor({ r, g, b });
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2812
|
+
#startMicAnimation(): void {
|
|
2813
|
+
if (this.#voiceAnimationInterval) return;
|
|
2814
|
+
this.#voiceHue = 0;
|
|
2815
|
+
this.#updateMicIcon();
|
|
2816
|
+
this.#voiceAnimationInterval = setInterval(() => {
|
|
2817
|
+
this.#voiceHue = (this.#voiceHue + 8) % 360;
|
|
2818
|
+
this.#updateMicIcon();
|
|
2819
|
+
this.ui.requestRender();
|
|
2820
|
+
}, 60);
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
#stopMicAnimation(): void {
|
|
2824
|
+
if (this.#voiceAnimationInterval) {
|
|
2825
|
+
clearInterval(this.#voiceAnimationInterval);
|
|
2826
|
+
this.#voiceAnimationInterval = undefined;
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2829
|
+
|
|
2830
|
+
#cleanupMicAnimation(): void {
|
|
2831
|
+
if (this.#voiceAnimationInterval) {
|
|
2832
|
+
clearInterval(this.#voiceAnimationInterval);
|
|
2833
|
+
this.#voiceAnimationInterval = undefined;
|
|
2834
|
+
}
|
|
2835
|
+
this.editor.cursorOverride = undefined;
|
|
2836
|
+
this.editor.cursorOverrideWidth = undefined;
|
|
2837
|
+
if (this.#voicePreviousShowHardwareCursor !== null) {
|
|
2838
|
+
this.ui.setShowHardwareCursor(this.#voicePreviousShowHardwareCursor);
|
|
2839
|
+
this.#voicePreviousShowHardwareCursor = null;
|
|
2840
|
+
}
|
|
2841
|
+
if (this.#voicePreviousUseTerminalCursor !== null) {
|
|
2842
|
+
this.editor.setUseTerminalCursor(this.#voicePreviousUseTerminalCursor);
|
|
2843
|
+
this.#voicePreviousUseTerminalCursor = null;
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2847
|
+
showDebugSelector(): void {
|
|
2848
|
+
this.#selectorController.showDebugSelector();
|
|
2849
|
+
}
|
|
2850
|
+
|
|
2851
|
+
showSessionObserver(): void {
|
|
2852
|
+
const sessions = this.#observerRegistry.getSessions();
|
|
2853
|
+
if (sessions.length <= 1) {
|
|
2854
|
+
this.showStatus("No active subagent sessions");
|
|
2855
|
+
return;
|
|
2856
|
+
}
|
|
2857
|
+
this.#selectorController.showSessionObserver(this.#observerRegistry);
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2860
|
+
resetObserverRegistry(): void {
|
|
2861
|
+
this.#observerRegistry.resetSessions();
|
|
2862
|
+
this.#observerRegistry.setMainSession(this.sessionManager.getSessionFile() ?? undefined);
|
|
2863
|
+
}
|
|
2864
|
+
|
|
2865
|
+
handleBashCommand(command: string, excludeFromContext?: boolean): Promise<void> {
|
|
2866
|
+
return this.#commandController.handleBashCommand(command, excludeFromContext);
|
|
2867
|
+
}
|
|
2868
|
+
|
|
2869
|
+
handlePythonCommand(code: string, excludeFromContext?: boolean): Promise<void> {
|
|
2870
|
+
return this.#commandController.handlePythonCommand(code, excludeFromContext);
|
|
2871
|
+
}
|
|
2872
|
+
|
|
2873
|
+
async handleMCPCommand(text: string): Promise<void> {
|
|
2874
|
+
const controller = new MCPCommandController(this);
|
|
2875
|
+
await controller.handle(text);
|
|
2876
|
+
}
|
|
2877
|
+
|
|
2878
|
+
async handleSSHCommand(text: string): Promise<void> {
|
|
2879
|
+
const controller = new SSHCommandController(this);
|
|
2880
|
+
await controller.handle(text);
|
|
2881
|
+
}
|
|
2882
|
+
|
|
2883
|
+
handleCompactCommand(customInstructions?: string): Promise<CompactionOutcome> {
|
|
2884
|
+
return this.#commandController.handleCompactCommand(customInstructions);
|
|
2885
|
+
}
|
|
2886
|
+
|
|
2887
|
+
handleHandoffCommand(customInstructions?: string): Promise<void> {
|
|
2888
|
+
return this.#commandController.handleHandoffCommand(customInstructions);
|
|
2889
|
+
}
|
|
2890
|
+
|
|
2891
|
+
handleShakeCommand(mode: ShakeMode): Promise<void> {
|
|
2892
|
+
return this.#commandController.handleShakeCommand(mode);
|
|
2893
|
+
}
|
|
2894
|
+
|
|
2895
|
+
executeCompaction(
|
|
2896
|
+
customInstructionsOrOptions?: string | CompactOptions,
|
|
2897
|
+
isAuto?: boolean,
|
|
2898
|
+
): Promise<CompactionOutcome> {
|
|
2899
|
+
return this.#commandController.executeCompaction(customInstructionsOrOptions, isAuto);
|
|
2900
|
+
}
|
|
2901
|
+
|
|
2902
|
+
openInBrowser(urlOrPath: string): void {
|
|
2903
|
+
this.#commandController.openInBrowser(urlOrPath);
|
|
2904
|
+
}
|
|
2905
|
+
|
|
2906
|
+
// Selector handling
|
|
2907
|
+
showSettingsSelector(): void {
|
|
2908
|
+
this.#selectorController.showSettingsSelector();
|
|
2909
|
+
}
|
|
2910
|
+
|
|
2911
|
+
showHistorySearch(): void {
|
|
2912
|
+
this.#selectorController.showHistorySearch();
|
|
2913
|
+
}
|
|
2914
|
+
|
|
2915
|
+
showExtensionsDashboard(): void {
|
|
2916
|
+
void this.#selectorController.showExtensionsDashboard();
|
|
2917
|
+
}
|
|
2918
|
+
|
|
2919
|
+
showAgentsDashboard(): void {
|
|
2920
|
+
void this.#selectorController.showAgentsDashboard();
|
|
2921
|
+
}
|
|
2922
|
+
|
|
2923
|
+
showModelSelector(options?: { temporaryOnly?: boolean }): void {
|
|
2924
|
+
this.#selectorController.showModelSelector(options);
|
|
2925
|
+
}
|
|
2926
|
+
|
|
2927
|
+
showPluginSelector(mode?: "install" | "uninstall"): void {
|
|
2928
|
+
void this.#selectorController.showPluginSelector(mode);
|
|
2929
|
+
}
|
|
2930
|
+
|
|
2931
|
+
showUserMessageSelector(): void {
|
|
2932
|
+
this.#selectorController.showUserMessageSelector();
|
|
2933
|
+
}
|
|
2934
|
+
|
|
2935
|
+
showCopySelector(): void {
|
|
2936
|
+
this.#selectorController.showCopySelector();
|
|
2937
|
+
}
|
|
2938
|
+
|
|
2939
|
+
showTreeSelector(): void {
|
|
2940
|
+
this.#selectorController.showTreeSelector();
|
|
2941
|
+
}
|
|
2942
|
+
|
|
2943
|
+
showSessionSelector(): void {
|
|
2944
|
+
this.#selectorController.showSessionSelector();
|
|
2945
|
+
}
|
|
2946
|
+
|
|
2947
|
+
handleResumeSession(sessionPath: string): Promise<void> {
|
|
2948
|
+
this.#btwController.dispose();
|
|
2949
|
+
this.#omfgController.dispose();
|
|
2950
|
+
this.resetObserverRegistry();
|
|
2951
|
+
return this.#selectorController.handleResumeSession(sessionPath);
|
|
2952
|
+
}
|
|
2953
|
+
|
|
2954
|
+
handleSessionDeleteCommand(): Promise<void> {
|
|
2955
|
+
return this.#selectorController.handleSessionDeleteCommand();
|
|
2956
|
+
}
|
|
2957
|
+
|
|
2958
|
+
showOAuthSelector(mode: "login" | "logout", providerId?: string): Promise<void> {
|
|
2959
|
+
return this.#selectorController.showOAuthSelector(mode, providerId);
|
|
2960
|
+
}
|
|
2961
|
+
|
|
2962
|
+
showHookConfirm(title: string, message: string): Promise<boolean> {
|
|
2963
|
+
return this.#extensionUiController.showHookConfirm(title, message);
|
|
2964
|
+
}
|
|
2965
|
+
|
|
2966
|
+
// Input handling
|
|
2967
|
+
handleCtrlC(): void {
|
|
2968
|
+
this.#inputController.handleCtrlC();
|
|
2969
|
+
}
|
|
2970
|
+
|
|
2971
|
+
handleCtrlD(): void {
|
|
2972
|
+
this.#inputController.handleCtrlD();
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2975
|
+
handleCtrlZ(): void {
|
|
2976
|
+
this.#inputController.handleCtrlZ();
|
|
2977
|
+
}
|
|
2978
|
+
|
|
2979
|
+
handleDequeue(): void {
|
|
2980
|
+
this.#inputController.handleDequeue();
|
|
2981
|
+
}
|
|
2982
|
+
|
|
2983
|
+
handleBackgroundCommand(): void {
|
|
2984
|
+
this.#inputController.handleBackgroundCommand();
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2987
|
+
handleImagePaste(): Promise<boolean> {
|
|
2988
|
+
return this.#inputController.handleImagePaste();
|
|
2989
|
+
}
|
|
2990
|
+
|
|
2991
|
+
handleBtwCommand(question: string): Promise<void> {
|
|
2992
|
+
return this.#btwController.start(question);
|
|
2993
|
+
}
|
|
2994
|
+
|
|
2995
|
+
hasActiveBtw(): boolean {
|
|
2996
|
+
return this.#btwController.hasActiveRequest();
|
|
2997
|
+
}
|
|
2998
|
+
|
|
2999
|
+
handleBtwEscape(): boolean {
|
|
3000
|
+
return this.#btwController.handleEscape();
|
|
3001
|
+
}
|
|
3002
|
+
|
|
3003
|
+
handleOmfgCommand(complaint: string): Promise<void> {
|
|
3004
|
+
return this.#omfgController.start(complaint);
|
|
3005
|
+
}
|
|
3006
|
+
|
|
3007
|
+
hasActiveOmfg(): boolean {
|
|
3008
|
+
return this.#omfgController.hasActiveRequest();
|
|
3009
|
+
}
|
|
3010
|
+
|
|
3011
|
+
handleOmfgEscape(): boolean {
|
|
3012
|
+
return this.#omfgController.handleEscape();
|
|
3013
|
+
}
|
|
3014
|
+
|
|
3015
|
+
cycleThinkingLevel(): void {
|
|
3016
|
+
this.#inputController.cycleThinkingLevel();
|
|
3017
|
+
}
|
|
3018
|
+
|
|
3019
|
+
cycleRoleModel(direction?: "forward" | "backward"): Promise<void> {
|
|
3020
|
+
return this.#inputController.cycleRoleModel(direction);
|
|
3021
|
+
}
|
|
3022
|
+
|
|
3023
|
+
toggleToolOutputExpansion(): void {
|
|
3024
|
+
this.#inputController.toggleToolOutputExpansion();
|
|
3025
|
+
}
|
|
3026
|
+
|
|
3027
|
+
setToolsExpanded(expanded: boolean): void {
|
|
3028
|
+
this.#inputController.setToolsExpanded(expanded);
|
|
3029
|
+
}
|
|
3030
|
+
|
|
3031
|
+
toggleThinkingBlockVisibility(): void {
|
|
3032
|
+
this.#inputController.toggleThinkingBlockVisibility();
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
toggleTodoExpansion(): void {
|
|
3036
|
+
this.todoExpanded = !this.todoExpanded;
|
|
3037
|
+
this.#renderTodoList();
|
|
3038
|
+
this.ui.requestRender();
|
|
3039
|
+
}
|
|
3040
|
+
|
|
3041
|
+
setTodos(todos: TodoItem[] | TodoPhase[]): void {
|
|
3042
|
+
if (todos.length > 0 && "tasks" in todos[0]) {
|
|
3043
|
+
this.todoPhases = todos as TodoPhase[];
|
|
3044
|
+
} else {
|
|
3045
|
+
this.todoPhases = [
|
|
3046
|
+
{
|
|
3047
|
+
name: "Todos",
|
|
3048
|
+
tasks: todos as TodoItem[],
|
|
3049
|
+
},
|
|
3050
|
+
];
|
|
3051
|
+
}
|
|
3052
|
+
this.#syncTodoAutoClearTimer();
|
|
3053
|
+
this.#renderTodoList();
|
|
3054
|
+
this.ui.requestRender();
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3057
|
+
async reloadTodos(): Promise<void> {
|
|
3058
|
+
await this.#loadTodoList();
|
|
3059
|
+
this.ui.requestRender();
|
|
3060
|
+
}
|
|
3061
|
+
|
|
3062
|
+
openExternalEditor(): void {
|
|
3063
|
+
this.#inputController.openExternalEditor();
|
|
3064
|
+
}
|
|
3065
|
+
|
|
3066
|
+
registerExtensionShortcuts(): void {
|
|
3067
|
+
this.#inputController.registerExtensionShortcuts();
|
|
3068
|
+
}
|
|
3069
|
+
|
|
3070
|
+
// Hook UI methods
|
|
3071
|
+
initHooksAndCustomTools(): Promise<void> {
|
|
3072
|
+
return this.#extensionUiController.initHooksAndCustomTools();
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
emitCustomToolSessionEvent(
|
|
3076
|
+
reason: "start" | "switch" | "branch" | "tree" | "shutdown",
|
|
3077
|
+
previousSessionFile?: string,
|
|
3078
|
+
): Promise<void> {
|
|
3079
|
+
return this.#extensionUiController.emitCustomToolSessionEvent(reason, previousSessionFile);
|
|
3080
|
+
}
|
|
3081
|
+
|
|
3082
|
+
setHookWidget(key: string, content: ExtensionWidgetContent, options?: ExtensionWidgetOptions): void {
|
|
3083
|
+
this.#extensionUiController.setHookWidget(key, content, options);
|
|
3084
|
+
}
|
|
3085
|
+
|
|
3086
|
+
setHookStatus(key: string, text: string | undefined): void {
|
|
3087
|
+
this.#extensionUiController.setHookStatus(key, text);
|
|
3088
|
+
}
|
|
3089
|
+
|
|
3090
|
+
showHookSelector(
|
|
3091
|
+
title: string,
|
|
3092
|
+
options: ExtensionUISelectItem[],
|
|
3093
|
+
dialogOptions?: InteractiveSelectorDialogOptions,
|
|
3094
|
+
extra?: { slider?: HookSelectorSlider },
|
|
3095
|
+
): Promise<string | undefined> {
|
|
3096
|
+
return this.#extensionUiController.showHookSelector(title, options, dialogOptions, extra);
|
|
3097
|
+
}
|
|
3098
|
+
|
|
3099
|
+
hideHookSelector(): void {
|
|
3100
|
+
this.#extensionUiController.hideHookSelector();
|
|
3101
|
+
}
|
|
3102
|
+
|
|
3103
|
+
showHookInput(title: string, placeholder?: string): Promise<string | undefined> {
|
|
3104
|
+
return this.#extensionUiController.showHookInput(title, placeholder);
|
|
3105
|
+
}
|
|
3106
|
+
|
|
3107
|
+
hideHookInput(): void {
|
|
3108
|
+
this.#extensionUiController.hideHookInput();
|
|
3109
|
+
}
|
|
3110
|
+
|
|
3111
|
+
showHookEditor(
|
|
3112
|
+
title: string,
|
|
3113
|
+
prefill?: string,
|
|
3114
|
+
dialogOptions?: ExtensionUIDialogOptions,
|
|
3115
|
+
editorOptions?: { promptStyle?: boolean },
|
|
3116
|
+
): Promise<string | undefined> {
|
|
3117
|
+
return this.#extensionUiController.showHookEditor(title, prefill, dialogOptions, editorOptions);
|
|
3118
|
+
}
|
|
3119
|
+
|
|
3120
|
+
hideHookEditor(): void {
|
|
3121
|
+
this.#extensionUiController.hideHookEditor();
|
|
3122
|
+
}
|
|
3123
|
+
|
|
3124
|
+
showHookNotify(message: string, type?: "info" | "warning" | "error"): void {
|
|
3125
|
+
this.#extensionUiController.showHookNotify(message, type);
|
|
3126
|
+
}
|
|
3127
|
+
|
|
3128
|
+
showHookCustom<T>(
|
|
3129
|
+
factory: (
|
|
3130
|
+
tui: TUI,
|
|
3131
|
+
theme: Theme,
|
|
3132
|
+
keybindings: KeybindingsManager,
|
|
3133
|
+
done: (result: T) => void,
|
|
3134
|
+
) => (Component & { dispose?(): void }) | Promise<Component & { dispose?(): void }>,
|
|
3135
|
+
options?: { overlay?: boolean },
|
|
3136
|
+
): Promise<T> {
|
|
3137
|
+
return this.#extensionUiController.showHookCustom(factory, options);
|
|
3138
|
+
}
|
|
3139
|
+
|
|
3140
|
+
showExtensionError(extensionPath: string, error: string): void {
|
|
3141
|
+
this.#extensionUiController.showExtensionError(extensionPath, error);
|
|
3142
|
+
}
|
|
3143
|
+
|
|
3144
|
+
showToolError(toolName: string, error: string): void {
|
|
3145
|
+
this.#extensionUiController.showToolError(toolName, error);
|
|
3146
|
+
}
|
|
3147
|
+
|
|
3148
|
+
#subscribeToAgent(): void {
|
|
3149
|
+
this.#eventController.subscribeToAgent();
|
|
3150
|
+
}
|
|
3151
|
+
}
|