@sayknow-cli/coding-agent 0.3.6 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -0
- package/dist/types/append-only-mode.d.ts +31 -0
- package/dist/types/async/index.d.ts +2 -0
- package/dist/types/async/job-manager.d.ts +328 -0
- package/dist/types/async/support.d.ts +2 -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 +17 -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 +47 -0
- package/dist/types/capability/prompt.d.ts +15 -0
- package/dist/types/capability/rule.d.ts +69 -0
- package/dist/types/capability/settings.d.ts +15 -0
- package/dist/types/capability/skill.d.ts +36 -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 +154 -0
- package/dist/types/cli/agents-cli.d.ts +12 -0
- package/dist/types/cli/args.d.ts +56 -0
- package/dist/types/cli/auth-broker-cli.d.ts +25 -0
- package/dist/types/cli/auth-gateway-cli.d.ts +18 -0
- package/dist/types/cli/classify-install-target.d.ts +18 -0
- package/dist/types/cli/commands/init-xdg.d.ts +1 -0
- package/dist/types/cli/completion-cli.d.ts +41 -0
- package/dist/types/cli/config-cli.d.ts +23 -0
- package/dist/types/cli/daemon-cli.d.ts +25 -0
- package/dist/types/cli/fast-help.d.ts +1 -0
- package/dist/types/cli/file-processor.d.ts +11 -0
- package/dist/types/cli/fixture-report.d.ts +20 -0
- package/dist/types/cli/fixture-report.test.d.ts +1 -0
- package/dist/types/cli/grep-cli.d.ts +17 -0
- package/dist/types/cli/initial-message.d.ts +17 -0
- package/dist/types/cli/list-models.d.ts +36 -0
- package/dist/types/cli/local-provider-smoke.d.ts +59 -0
- package/dist/types/cli/mcp-cli.d.ts +25 -0
- package/dist/types/cli/migrate-cli.d.ts +20 -0
- package/dist/types/cli/nofile-limit.d.ts +11 -0
- package/dist/types/cli/notify-cli.d.ts +32 -0
- package/dist/types/cli/plugin-cli.d.ts +34 -0
- package/dist/types/cli/read-cli.d.ts +4 -0
- package/dist/types/cli/session-picker.d.ts +3 -0
- package/dist/types/cli/setup-cli.d.ts +73 -0
- package/dist/types/cli/shell-cli.d.ts +8 -0
- package/dist/types/cli/skills-cli.d.ts +9 -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/telegram-cli.d.ts +13 -0
- package/dist/types/cli/update-cli.d.ts +89 -0
- package/dist/types/cli/web-search-cli.d.ts +32 -0
- package/dist/types/cli/worktree-cli.d.ts +26 -0
- package/dist/types/cli.d.ts +132 -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 +32 -0
- package/dist/types/commands/codex-native-hook.d.ts +6 -0
- package/dist/types/commands/commit.d.ts +27 -0
- package/dist/types/commands/completion.d.ts +29 -0
- package/dist/types/commands/config.d.ts +33 -0
- package/dist/types/commands/contribution-prep.d.ts +18 -0
- package/dist/types/commands/coordinator.d.ts +19 -0
- package/dist/types/commands/daemon.d.ts +41 -0
- package/dist/types/commands/deep-interview.d.ts +54 -0
- package/dist/types/commands/gc.d.ts +26 -0
- package/dist/types/commands/grep.d.ts +42 -0
- package/dist/types/commands/harness.d.ts +43 -0
- package/dist/types/commands/launch.d.ts +127 -0
- package/dist/types/commands/local-provider.d.ts +34 -0
- package/dist/types/commands/mcp-serve.d.ts +24 -0
- package/dist/types/commands/mcp.d.ts +70 -0
- package/dist/types/commands/migrate.d.ts +33 -0
- package/dist/types/commands/notify.d.ts +41 -0
- package/dist/types/commands/plugin.d.ts +58 -0
- package/dist/types/commands/ralplan.d.ts +7 -0
- package/dist/types/commands/read.d.ts +15 -0
- package/dist/types/commands/rlm.d.ts +10 -0
- package/dist/types/commands/session.d.ts +30 -0
- package/dist/types/commands/setup.d.ts +105 -0
- package/dist/types/commands/shell.d.ts +21 -0
- package/dist/types/commands/skills.d.ts +26 -0
- package/dist/types/commands/ssh.d.ts +48 -0
- package/dist/types/commands/state.d.ts +7 -0
- package/dist/types/commands/stats.d.ts +25 -0
- package/dist/types/commands/team.d.ts +24 -0
- package/dist/types/commands/telegram.d.ts +22 -0
- package/dist/types/commands/ultragoal.d.ts +8 -0
- package/dist/types/commands/update.d.ts +20 -0
- package/dist/types/commands/web-search.d.ts +87 -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/config-file.d.ts +58 -0
- package/dist/types/config/file-lock-gc.d.ts +5 -0
- package/dist/types/config/file-lock.d.ts +36 -0
- package/dist/types/config/keybindings.d.ts +359 -0
- package/dist/types/config/model-equivalence.d.ts +24 -0
- package/dist/types/config/model-profile-activation.d.ts +64 -0
- package/dist/types/config/model-profiles.d.ts +39 -0
- package/dist/types/config/model-registry.d.ts +465 -0
- package/dist/types/config/model-resolver.d.ts +217 -0
- package/dist/types/config/models-config-schema.d.ts +700 -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 +4169 -0
- package/dist/types/config/settings.d.ts +149 -0
- package/dist/types/config/skill-settings-defaults.d.ts +14 -0
- package/dist/types/config/telegram-autostart.d.ts +14 -0
- package/dist/types/config/telegram-env-bridge.d.ts +18 -0
- package/dist/types/config.d.ts +66 -0
- package/dist/types/coordinator/contract.d.ts +4 -0
- package/dist/types/coordinator-mcp/policy.d.ts +24 -0
- package/dist/types/coordinator-mcp/safety.d.ts +26 -0
- package/dist/types/coordinator-mcp/server.d.ts +66 -0
- package/dist/types/cursor.d.ts +24 -0
- package/dist/types/daemon/builtin.d.ts +20 -0
- package/dist/types/daemon/control-types.d.ts +57 -0
- package/dist/types/daemon/runtime.d.ts +25 -0
- package/dist/types/dap/client.d.ts +39 -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/crash-diagnostics.d.ts +45 -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/raw-sse-buffer.d.ts +44 -0
- package/dist/types/debug/raw-sse.d.ts +16 -0
- package/dist/types/debug/report-bundle.d.ts +55 -0
- package/dist/types/debug/runtime-gauges.d.ts +6 -0
- package/dist/types/debug/system-info.d.ts +26 -0
- package/dist/types/deep-interview/plaintext-gate-guard.d.ts +11 -0
- package/dist/types/deep-interview/render-middleware.d.ts +6 -0
- package/dist/types/defaults/skc/extensions/grok-build/index.d.ts +1 -0
- package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/index.d.ts +1 -0
- package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/models/catalog.d.ts +25 -0
- package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/payload/sanitize.d.ts +27 -0
- package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/provider/billing.d.ts +8 -0
- package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/provider/register.d.ts +5 -0
- package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/provider/stream.d.ts +10 -0
- package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/provider/usage.d.ts +2 -0
- package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/shared/base-url.d.ts +2 -0
- package/dist/types/defaults/skc/extensions/grok-cli-vendor/src/shared/errors.d.ts +38 -0
- package/dist/types/defaults/skc-defaults.d.ts +64 -0
- package/dist/types/defaults/skc-grok-cli.d.ts +5 -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.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/cursor.d.ts +19 -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 +271 -0
- package/dist/types/discovery/index.d.ts +48 -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/ssh.d.ts +1 -0
- package/dist/types/discovery/substitute-plugin-root.d.ts +5 -0
- package/dist/types/discovery/vscode.d.ts +1 -0
- package/dist/types/discovery/windsurf.d.ts +15 -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 +75 -0
- package/dist/types/edit/file-read-cache.d.ts +25 -0
- package/dist/types/edit/index.d.ts +58 -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 +149 -0
- package/dist/types/edit/normalize.d.ts +43 -0
- package/dist/types/edit/notebook.d.ts +26 -0
- package/dist/types/edit/read-file.d.ts +8 -0
- package/dist/types/edit/renderer.d.ts +110 -0
- package/dist/types/edit/streaming.d.ts +66 -0
- package/dist/types/eval/backend.d.ts +40 -0
- package/dist/types/eval/index.d.ts +4 -0
- package/dist/types/eval/js/context-manager.d.ts +27 -0
- package/dist/types/eval/js/executor.d.ts +29 -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/prelude.d.ts +1 -0
- package/dist/types/eval/js/shared/rewrite-imports.d.ts +6 -0
- package/dist/types/eval/js/shared/runtime.d.ts +47 -0
- package/dist/types/eval/js/shared/types.d.ts +24 -0
- package/dist/types/eval/js/tool-bridge.d.ts +18 -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/py/display.d.ts +25 -0
- package/dist/types/eval/py/executor.d.ts +88 -0
- package/dist/types/eval/py/index.d.ts +10 -0
- package/dist/types/eval/py/kernel.d.ts +65 -0
- package/dist/types/eval/py/prelude.d.ts +1 -0
- package/dist/types/eval/py/runtime.d.ts +29 -0
- package/dist/types/eval/py/tool-bridge.d.ts +20 -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 +45 -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 +64 -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 +55 -0
- package/dist/types/extensibility/custom-commands/bundled/ci-green/index.d.ts +9 -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 +229 -0
- package/dist/types/extensibility/custom-tools/wrapper.d.ts +24 -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 +9 -0
- package/dist/types/extensibility/extensions/loader.d.ts +43 -0
- package/dist/types/extensibility/extensions/prefix-command-bridge.d.ts +35 -0
- package/dist/types/extensibility/extensions/runner.d.ts +135 -0
- package/dist/types/extensibility/extensions/types.d.ts +918 -0
- package/dist/types/extensibility/extensions/wrapper.d.ts +55 -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 +431 -0
- package/dist/types/extensibility/plugins/doctor.d.ts +3 -0
- package/dist/types/extensibility/plugins/git-url.d.ts +34 -0
- package/dist/types/extensibility/plugins/index.d.ts +8 -0
- package/dist/types/extensibility/plugins/installer.d.ts +5 -0
- package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +2 -0
- package/dist/types/extensibility/plugins/loader.d.ts +31 -0
- package/dist/types/extensibility/plugins/manager.d.ts +65 -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/security-scanner.d.ts +31 -0
- package/dist/types/extensibility/plugins/types.d.ts +149 -0
- package/dist/types/extensibility/shared-events.d.ts +281 -0
- package/dist/types/extensibility/skc-plugins/activation.d.ts +14 -0
- package/dist/types/extensibility/skc-plugins/compiler.d.ts +19 -0
- package/dist/types/extensibility/skc-plugins/constrained-hooks.d.ts +29 -0
- package/dist/types/extensibility/skc-plugins/index.d.ts +18 -0
- package/dist/types/extensibility/skc-plugins/injection.d.ts +40 -0
- package/dist/types/extensibility/skc-plugins/installer.d.ts +13 -0
- package/dist/types/extensibility/skc-plugins/loader.d.ts +3 -0
- package/dist/types/extensibility/skc-plugins/mcp-policy.d.ts +26 -0
- package/dist/types/extensibility/skc-plugins/observability.d.ts +27 -0
- package/dist/types/extensibility/skc-plugins/paths.d.ts +8 -0
- package/dist/types/extensibility/skc-plugins/prompt-appendix.d.ts +16 -0
- package/dist/types/extensibility/skc-plugins/registry.d.ts +32 -0
- package/dist/types/extensibility/skc-plugins/runtime-adapters.d.ts +64 -0
- package/dist/types/extensibility/skc-plugins/schema.d.ts +3 -0
- package/dist/types/extensibility/skc-plugins/session-validation.d.ts +42 -0
- package/dist/types/extensibility/skc-plugins/state.d.ts +9 -0
- package/dist/types/extensibility/skc-plugins/tools.d.ts +8 -0
- package/dist/types/extensibility/skc-plugins/types.d.ts +220 -0
- package/dist/types/extensibility/skc-plugins/validation.d.ts +11 -0
- package/dist/types/extensibility/skills.d.ts +82 -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/goals/index.d.ts +3 -0
- package/dist/types/goals/runtime.d.ts +63 -0
- package/dist/types/goals/state.d.ts +32 -0
- package/dist/types/goals/tools/goal-tool.d.ts +62 -0
- package/dist/types/harness-control-plane/classifier.d.ts +13 -0
- package/dist/types/harness-control-plane/control-endpoint.d.ts +31 -0
- package/dist/types/harness-control-plane/finalize.d.ts +60 -0
- package/dist/types/harness-control-plane/gc-adapter.d.ts +3 -0
- package/dist/types/harness-control-plane/operate.d.ts +35 -0
- package/dist/types/harness-control-plane/owner.d.ts +53 -0
- package/dist/types/harness-control-plane/phase-rollup.d.ts +23 -0
- package/dist/types/harness-control-plane/preserve.d.ts +19 -0
- package/dist/types/harness-control-plane/receipt-ingest.d.ts +19 -0
- package/dist/types/harness-control-plane/receipt-spool.d.ts +19 -0
- package/dist/types/harness-control-plane/receipts.d.ts +149 -0
- package/dist/types/harness-control-plane/rpc-adapter.d.ts +69 -0
- package/dist/types/harness-control-plane/seams.d.ts +21 -0
- package/dist/types/harness-control-plane/session-lease.d.ts +65 -0
- package/dist/types/harness-control-plane/state-machine.d.ts +24 -0
- package/dist/types/harness-control-plane/storage.d.ts +81 -0
- package/dist/types/harness-control-plane/types.d.ts +187 -0
- package/dist/types/hashline/anchors.d.ts +20 -0
- package/dist/types/hashline/apply.d.ts +14 -0
- package/dist/types/hashline/constants.d.ts +19 -0
- package/dist/types/hashline/diff-preview.d.ts +2 -0
- package/dist/types/hashline/diff.d.ts +17 -0
- package/dist/types/hashline/execute.d.ts +4 -0
- package/dist/types/hashline/hash.d.ts +123 -0
- package/dist/types/hashline/index.d.ts +13 -0
- package/dist/types/hashline/input.d.ts +11 -0
- package/dist/types/hashline/parser.d.ts +7 -0
- package/dist/types/hashline/prefixes.d.ts +7 -0
- package/dist/types/hashline/recovery.d.ts +27 -0
- package/dist/types/hashline/stream.d.ts +2 -0
- package/dist/types/hashline/types.d.ts +77 -0
- package/dist/types/hindsight/backend.d.ts +13 -0
- package/dist/types/hindsight/bank.d.ts +54 -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 +99 -0
- package/dist/types/hindsight/transcript.d.ts +28 -0
- package/dist/types/hooks/codex-native-hooks-config.d.ts +29 -0
- package/dist/types/hooks/native-skill-hook.d.ts +28 -0
- package/dist/types/hooks/skill-keywords.d.ts +18 -0
- package/dist/types/hooks/skill-state.d.ts +93 -0
- package/dist/types/i18n/index.d.ts +38 -0
- package/dist/types/i18n/messages/de.d.ts +2 -0
- package/dist/types/i18n/messages/de.messages.d.ts +1 -0
- package/dist/types/i18n/messages/de.settings.d.ts +1 -0
- package/dist/types/i18n/messages/en.d.ts +81 -0
- package/dist/types/i18n/messages/es.d.ts +2 -0
- package/dist/types/i18n/messages/es.messages.d.ts +1 -0
- package/dist/types/i18n/messages/es.settings.d.ts +1 -0
- package/dist/types/i18n/messages/fr.d.ts +2 -0
- package/dist/types/i18n/messages/fr.messages.d.ts +1 -0
- package/dist/types/i18n/messages/fr.settings.d.ts +1 -0
- package/dist/types/i18n/messages/ja.d.ts +2 -0
- package/dist/types/i18n/messages/ja.messages.d.ts +1 -0
- package/dist/types/i18n/messages/ja.settings.d.ts +1 -0
- package/dist/types/i18n/messages/ko.d.ts +2 -0
- package/dist/types/i18n/messages/ko.messages.d.ts +1 -0
- package/dist/types/i18n/messages/ko.settings.d.ts +1 -0
- package/dist/types/i18n/messages/zh.d.ts +2 -0
- package/dist/types/i18n/messages/zh.messages.d.ts +1 -0
- package/dist/types/i18n/messages/zh.settings.d.ts +1 -0
- package/dist/types/index.d.ts +33 -0
- package/dist/types/internal-urls/agent-protocol.d.ts +12 -0
- package/dist/types/internal-urls/artifact-protocol.d.ts +6 -0
- package/dist/types/internal-urls/docs-index.generated.d.ts +2 -0
- package/dist/types/internal-urls/index.d.ts +20 -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 +39 -0
- package/dist/types/internal-urls/mcp-protocol.d.ts +12 -0
- package/dist/types/internal-urls/memory-protocol.d.ts +23 -0
- package/dist/types/internal-urls/parse.d.ts +19 -0
- package/dist/types/internal-urls/registry-helpers.d.ts +11 -0
- package/dist/types/internal-urls/router.d.ts +14 -0
- package/dist/types/internal-urls/rule-protocol.d.ts +6 -0
- package/dist/types/internal-urls/skc-protocol.d.ts +12 -0
- package/dist/types/internal-urls/skill-protocol.d.ts +13 -0
- package/dist/types/internal-urls/types.d.ts +109 -0
- package/dist/types/lsp/client.d.ts +66 -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/edits.d.ts +23 -0
- package/dist/types/lsp/index.d.ts +130 -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 +12 -0
- package/dist/types/lsp/types.d.ts +306 -0
- package/dist/types/lsp/utils.d.ts +108 -0
- package/dist/types/main.d.ts +75 -0
- package/dist/types/memories/index.d.ts +28 -0
- package/dist/types/memories/storage.d.ts +110 -0
- package/dist/types/memory-backend/index.d.ts +4 -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 +15 -0
- package/dist/types/memory-backend/types.d.ts +61 -0
- package/dist/types/migrate/action-planner.d.ts +11 -0
- package/dist/types/migrate/adapters/claude-code.d.ts +2 -0
- package/dist/types/migrate/adapters/codex.d.ts +5 -0
- package/dist/types/migrate/adapters/index.d.ts +45 -0
- package/dist/types/migrate/adapters/opencode.d.ts +2 -0
- package/dist/types/migrate/executor.d.ts +2 -0
- package/dist/types/migrate/mcp-mapper.d.ts +20 -0
- package/dist/types/migrate/report.d.ts +18 -0
- package/dist/types/migrate/skill-normalizer.d.ts +27 -0
- package/dist/types/migrate/types.d.ts +126 -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 +34 -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/bridge/auth.d.ts +12 -0
- package/dist/types/modes/bridge/bridge-client-bridge.d.ts +9 -0
- package/dist/types/modes/bridge/bridge-mode.d.ts +47 -0
- package/dist/types/modes/bridge/bridge-ui-context.d.ts +88 -0
- package/dist/types/modes/bridge/event-stream.d.ts +8 -0
- package/dist/types/modes/components/agent-dashboard.d.ts +21 -0
- package/dist/types/modes/components/assistant-message.d.ts +20 -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/countdown-timer.d.ts +14 -0
- package/dist/types/modes/components/custom-editor.d.ts +67 -0
- package/dist/types/modes/components/custom-message.d.ts +15 -0
- package/dist/types/modes/components/custom-model-preset-wizard.d.ts +12 -0
- package/dist/types/modes/components/custom-provider-wizard.d.ts +10 -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/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 +26 -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 +151 -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 +53 -0
- package/dist/types/modes/components/index.d.ts +35 -0
- package/dist/types/modes/components/jobs-overlay-model.d.ts +31 -0
- package/dist/types/modes/components/jobs-overlay.d.ts +30 -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/message-frame.d.ts +42 -0
- package/dist/types/modes/components/model-selector.d.ts +60 -0
- package/dist/types/modes/components/oauth-selector.d.ts +17 -0
- package/dist/types/modes/components/plugin-selector.d.ts +26 -0
- package/dist/types/modes/components/plugin-settings.d.ts +66 -0
- package/dist/types/modes/components/provider-onboarding-selector.d.ts +7 -0
- package/dist/types/modes/components/queue-mode-selector.d.ts +9 -0
- package/dist/types/modes/components/queued-message-selector.d.ts +12 -0
- package/dist/types/modes/components/read-tool-group.d.ts +30 -0
- package/dist/types/modes/components/runtime-mcp-add-wizard.d.ts +26 -0
- package/dist/types/modes/components/session-observer-overlay.d.ts +11 -0
- package/dist/types/modes/components/session-selector.d.ts +30 -0
- package/dist/types/modes/components/settings-defs.d.ts +50 -0
- package/dist/types/modes/components/settings-selector.d.ts +62 -0
- package/dist/types/modes/components/show-images-selector.d.ts +9 -0
- package/dist/types/modes/components/skill-hud/render.d.ts +2 -0
- package/dist/types/modes/components/skill-message.d.ts +10 -0
- package/dist/types/modes/components/status-line/context-thresholds.d.ts +4 -0
- package/dist/types/modes/components/status-line/git-utils.d.ts +28 -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 +77 -0
- package/dist/types/modes/components/status-line.d.ts +103 -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/todo-reminder.d.ts +13 -0
- package/dist/types/modes/components/tool-execution.d.ts +54 -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/two-column-body.d.ts +9 -0
- package/dist/types/modes/components/user-message-selector.d.ts +28 -0
- package/dist/types/modes/components/user-message.d.ts +7 -0
- package/dist/types/modes/components/visual-truncate.d.ts +19 -0
- package/dist/types/modes/components/welcome.d.ts +45 -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 +40 -0
- package/dist/types/modes/controllers/event-controller.d.ts +17 -0
- package/dist/types/modes/controllers/extension-ui-controller.d.ts +80 -0
- package/dist/types/modes/controllers/input-controller.d.ts +42 -0
- package/dist/types/modes/controllers/runtime-mcp-command-controller.d.ts +10 -0
- package/dist/types/modes/controllers/selector-controller.d.ts +66 -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/index.d.ts +10 -0
- package/dist/types/modes/interactive-mode.d.ts +273 -0
- package/dist/types/modes/jobs-observer.d.ts +57 -0
- package/dist/types/modes/oauth-manual-input.d.ts +8 -0
- package/dist/types/modes/print-mode.d.ts +45 -0
- package/dist/types/modes/prompt-action-autocomplete.d.ts +50 -0
- package/dist/types/modes/rpc/host-tools.d.ts +1 -0
- package/dist/types/modes/rpc/host-uris.d.ts +1 -0
- package/dist/types/modes/rpc/rpc-client.d.ts +288 -0
- package/dist/types/modes/rpc/rpc-mode.d.ts +87 -0
- package/dist/types/modes/rpc/rpc-socket-security.d.ts +7 -0
- package/dist/types/modes/rpc/rpc-types.d.ts +794 -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/shared/agent-wire/approval-gate.d.ts +57 -0
- package/dist/types/modes/shared/agent-wire/command-contract.d.ts +18 -0
- package/dist/types/modes/shared/agent-wire/command-dispatch.d.ts +37 -0
- package/dist/types/modes/shared/agent-wire/command-validation.d.ts +2 -0
- package/dist/types/modes/shared/agent-wire/deep-interview-gate.d.ts +94 -0
- package/dist/types/modes/shared/agent-wire/event-contract.d.ts +103 -0
- package/dist/types/modes/shared/agent-wire/event-envelope.d.ts +60 -0
- package/dist/types/modes/shared/agent-wire/event-observation.d.ts +37 -0
- package/dist/types/modes/shared/agent-wire/handshake.d.ts +56 -0
- package/dist/types/modes/shared/agent-wire/host-tool-bridge.d.ts +16 -0
- package/dist/types/modes/shared/agent-wire/host-uri-bridge.d.ts +17 -0
- package/dist/types/modes/shared/agent-wire/protocol.d.ts +25 -0
- package/dist/types/modes/shared/agent-wire/responses.d.ts +4 -0
- package/dist/types/modes/shared/agent-wire/scopes.d.ts +18 -0
- package/dist/types/modes/shared/agent-wire/session-registry.d.ts +25 -0
- package/dist/types/modes/shared/agent-wire/ui-request-broker.d.ts +42 -0
- package/dist/types/modes/shared/agent-wire/ui-result.d.ts +27 -0
- package/dist/types/modes/shared/agent-wire/unattended-action-policy.d.ts +29 -0
- package/dist/types/modes/shared/agent-wire/unattended-audit.d.ts +68 -0
- package/dist/types/modes/shared/agent-wire/unattended-run-controller.d.ts +161 -0
- package/dist/types/modes/shared/agent-wire/unattended-session.d.ts +82 -0
- package/dist/types/modes/shared/agent-wire/workflow-gate-broker.d.ts +114 -0
- package/dist/types/modes/shared/agent-wire/workflow-gate-schema.d.ts +39 -0
- package/dist/types/modes/shared.d.ts +15 -0
- package/dist/types/modes/slash-command-visibility.d.ts +1 -0
- package/dist/types/modes/theme/defaults/index.d.ts +652 -0
- package/dist/types/modes/theme/mermaid-cache.d.ts +9 -0
- package/dist/types/modes/theme/shimmer.d.ts +38 -0
- package/dist/types/modes/theme/theme.d.ts +275 -0
- package/dist/types/modes/tmux-scroll.d.ts +18 -0
- package/dist/types/modes/types.d.ts +289 -0
- package/dist/types/modes/utils/abort-message.d.ts +4 -0
- package/dist/types/modes/utils/context-usage.d.ts +51 -0
- package/dist/types/modes/utils/hotkeys-markdown.d.ts +5 -0
- package/dist/types/modes/utils/keybinding-matchers.d.ts +10 -0
- package/dist/types/modes/utils/terminal-bell.d.ts +3 -0
- package/dist/types/modes/utils/tools-markdown.d.ts +5 -0
- package/dist/types/modes/utils/ui-helpers.d.ts +54 -0
- package/dist/types/notifications/attachment-registry.d.ts +17 -0
- package/dist/types/notifications/chat-adapters.d.ts +9 -0
- package/dist/types/notifications/config-commands.d.ts +26 -0
- package/dist/types/notifications/config.d.ts +82 -0
- package/dist/types/notifications/daemon-paths.d.ts +10 -0
- package/dist/types/notifications/engine.d.ts +59 -0
- package/dist/types/notifications/helpers.d.ts +55 -0
- package/dist/types/notifications/html-format.d.ts +75 -0
- package/dist/types/notifications/index.d.ts +179 -0
- package/dist/types/notifications/lifecycle-commands.d.ts +68 -0
- package/dist/types/notifications/lifecycle-control-runtime.d.ts +98 -0
- package/dist/types/notifications/lifecycle-orchestrator.d.ts +144 -0
- package/dist/types/notifications/managed-daemon.d.ts +48 -0
- package/dist/types/notifications/operator-runtime.d.ts +52 -0
- package/dist/types/notifications/rate-limit-pool.d.ts +95 -0
- package/dist/types/notifications/recent-activity.d.ts +39 -0
- package/dist/types/notifications/telegram-cli.d.ts +19 -0
- package/dist/types/notifications/telegram-daemon-cli.d.ts +28 -0
- package/dist/types/notifications/telegram-daemon-control.d.ts +64 -0
- package/dist/types/notifications/telegram-daemon.d.ts +407 -0
- package/dist/types/notifications/telegram-reference.d.ts +112 -0
- package/dist/types/notifications/threaded-inbound.d.ts +77 -0
- package/dist/types/notifications/threaded-render.d.ts +78 -0
- package/dist/types/notifications/topic-registry.d.ts +70 -0
- package/dist/types/plan-mode/approved-plan.d.ts +49 -0
- package/dist/types/plan-mode/state.d.ts +6 -0
- package/dist/types/registry/agent-registry.d.ts +62 -0
- package/dist/types/reminders/star-reminder.d.ts +115 -0
- package/dist/types/research-plan/index.d.ts +1 -0
- package/dist/types/research-plan/ledger.d.ts +33 -0
- package/dist/types/rlm/artifacts.d.ts +9 -0
- package/dist/types/rlm/complete-research-tool.d.ts +35 -0
- package/dist/types/rlm/data-context.d.ts +6 -0
- package/dist/types/rlm/index.d.ts +47 -0
- package/dist/types/rlm/notebook.d.ts +12 -0
- package/dist/types/rlm/preset.d.ts +23 -0
- package/dist/types/rlm/python-tool.d.ts +16 -0
- package/dist/types/rlm/report.d.ts +14 -0
- package/dist/types/rlm/types.d.ts +37 -0
- package/dist/types/runtime/process-lifecycle.d.ts +108 -0
- package/dist/types/runtime-api-key.d.ts +7 -0
- package/dist/types/runtime-mcp/client.d.ts +74 -0
- package/dist/types/runtime-mcp/config-writer.d.ts +88 -0
- package/dist/types/runtime-mcp/config.d.ts +77 -0
- package/dist/types/runtime-mcp/discoverable-tool-metadata.d.ts +7 -0
- package/dist/types/runtime-mcp/index.d.ts +18 -0
- package/dist/types/runtime-mcp/json-rpc.d.ts +22 -0
- package/dist/types/runtime-mcp/loader.d.ts +45 -0
- package/dist/types/runtime-mcp/manager.d.ts +195 -0
- package/dist/types/runtime-mcp/oauth-discovery.d.ts +40 -0
- package/dist/types/runtime-mcp/oauth-flow.d.ts +59 -0
- package/dist/types/runtime-mcp/render.d.ts +25 -0
- package/dist/types/runtime-mcp/smithery-auth.d.ts +16 -0
- package/dist/types/runtime-mcp/smithery-connect.d.ts +38 -0
- package/dist/types/runtime-mcp/smithery-registry.d.ts +51 -0
- package/dist/types/runtime-mcp/tool-bridge.d.ts +86 -0
- package/dist/types/runtime-mcp/tool-cache.d.ts +8 -0
- package/dist/types/runtime-mcp/transports/http.d.ts +36 -0
- package/dist/types/runtime-mcp/transports/index.d.ts +5 -0
- package/dist/types/runtime-mcp/transports/stdio.d.ts +29 -0
- package/dist/types/runtime-mcp/types.d.ts +348 -0
- package/dist/types/sdk.d.ts +248 -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 +1182 -0
- package/dist/types/session/agent-storage.d.ts +101 -0
- package/dist/types/session/artifacts.d.ts +64 -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 +160 -0
- package/dist/types/session/client-bridge.d.ts +88 -0
- package/dist/types/session/contribution-prep.d.ts +47 -0
- package/dist/types/session/file-mention-pruning.d.ts +8 -0
- package/dist/types/session/history-storage.d.ts +16 -0
- package/dist/types/session/messages.d.ts +169 -0
- package/dist/types/session/session-dump-format.d.ts +22 -0
- package/dist/types/session/session-manager.d.ts +660 -0
- package/dist/types/session/session-storage.d.ts +88 -0
- package/dist/types/session/streaming-output.d.ts +209 -0
- package/dist/types/session/tool-choice-queue.d.ts +84 -0
- package/dist/types/session/yield-queue.d.ts +24 -0
- package/dist/types/setup/credential-auto-import.d.ts +63 -0
- package/dist/types/setup/credential-import.d.ts +82 -0
- package/dist/types/setup/hermes-setup.d.ts +78 -0
- package/dist/types/setup/host-plugin-setup.d.ts +39 -0
- package/dist/types/setup/model-onboarding-guidance.d.ts +9 -0
- package/dist/types/setup/provider-onboarding.d.ts +52 -0
- package/dist/types/skc-runtime/cli-write-receipt.d.ts +24 -0
- package/dist/types/skc-runtime/deep-interview-ambiguity.d.ts +39 -0
- package/dist/types/skc-runtime/deep-interview-recorder.d.ts +114 -0
- package/dist/types/skc-runtime/deep-interview-runtime.d.ts +36 -0
- package/dist/types/skc-runtime/deep-interview-state.d.ts +127 -0
- package/dist/types/skc-runtime/gc-render.d.ts +6 -0
- package/dist/types/skc-runtime/gc-runtime.d.ts +134 -0
- package/dist/types/skc-runtime/goal-mode-request.d.ts +53 -0
- package/dist/types/skc-runtime/launch-tmux.d.ts +78 -0
- package/dist/types/skc-runtime/launch-worktree.d.ts +46 -0
- package/dist/types/skc-runtime/ledger-event-renderer.d.ts +68 -0
- package/dist/types/skc-runtime/psmux-detect.d.ts +78 -0
- package/dist/types/skc-runtime/ralplan-runtime.d.ts +26 -0
- package/dist/types/skc-runtime/restricted-role-agent-bash.d.ts +3 -0
- package/dist/types/skc-runtime/session-layout.d.ts +59 -0
- package/dist/types/skc-runtime/session-resolution.d.ts +47 -0
- package/dist/types/skc-runtime/session-state-sidecar.d.ts +39 -0
- package/dist/types/skc-runtime/state-graph.d.ts +4 -0
- package/dist/types/skc-runtime/state-migrations.d.ts +33 -0
- package/dist/types/skc-runtime/state-renderer.d.ts +70 -0
- package/dist/types/skc-runtime/state-runtime.d.ts +38 -0
- package/dist/types/skc-runtime/state-schema.d.ts +319 -0
- package/dist/types/skc-runtime/state-validation.d.ts +6 -0
- package/dist/types/skc-runtime/state-writer.d.ts +244 -0
- package/dist/types/skc-runtime/team-gc.d.ts +7 -0
- package/dist/types/skc-runtime/team-runtime.d.ts +355 -0
- package/dist/types/skc-runtime/tmux-common.d.ts +104 -0
- package/dist/types/skc-runtime/tmux-gc.d.ts +7 -0
- package/dist/types/skc-runtime/tmux-sessions.d.ts +62 -0
- package/dist/types/skc-runtime/ultragoal-guard.d.ts +93 -0
- package/dist/types/skc-runtime/ultragoal-receipt-freshness.d.ts +42 -0
- package/dist/types/skc-runtime/ultragoal-runtime.d.ts +410 -0
- package/dist/types/skc-runtime/workflow-command-ref.d.ts +43 -0
- package/dist/types/skc-runtime/workflow-manifest.d.ts +54 -0
- package/dist/types/skill-state/active-state.d.ts +126 -0
- package/dist/types/skill-state/canonical-skills.d.ts +3 -0
- package/dist/types/skill-state/deep-interview-mutation-guard.d.ts +38 -0
- package/dist/types/skill-state/initial-phase.d.ts +12 -0
- package/dist/types/skill-state/workflow-hud.d.ts +83 -0
- package/dist/types/skill-state/workflow-state-contract.d.ts +57 -0
- package/dist/types/skill-state/workflow-state-version.d.ts +3 -0
- package/dist/types/slash-commands/acp-builtins.d.ts +18 -0
- package/dist/types/slash-commands/builtin-registry.d.ts +24 -0
- package/dist/types/slash-commands/helpers/context-report.d.ts +7 -0
- package/dist/types/slash-commands/helpers/fast-status-report.d.ts +82 -0
- package/dist/types/slash-commands/helpers/format.d.ts +10 -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/types.d.ts +120 -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 +118 -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 +19 -0
- package/dist/types/task/executor.d.ts +124 -0
- package/dist/types/task/fork-context-advisory.d.ts +13 -0
- package/dist/types/task/fork-context-budget.d.ts +7 -0
- package/dist/types/task/id.d.ts +7 -0
- package/dist/types/task/index.d.ts +43 -0
- package/dist/types/task/name-generator.d.ts +16 -0
- package/dist/types/task/output-manager.d.ts +36 -0
- package/dist/types/task/parallel.d.ts +34 -0
- package/dist/types/task/receipt.d.ts +87 -0
- package/dist/types/task/render.d.ts +28 -0
- package/dist/types/task/roi-reconciliation.d.ts +27 -0
- package/dist/types/task/simple-mode.d.ts +8 -0
- package/dist/types/task/skc-command.d.ts +7 -0
- package/dist/types/task/spawn-gate.d.ts +29 -0
- package/dist/types/task/subprocess-tool-registry.d.ts +72 -0
- package/dist/types/task/token-log.d.ts +30 -0
- package/dist/types/task/token-log.test.d.ts +1 -0
- package/dist/types/task/types.d.ts +508 -0
- package/dist/types/task/worktree.d.ts +94 -0
- package/dist/types/thinking-metadata.d.ts +16 -0
- package/dist/types/thinking.d.ts +22 -0
- package/dist/types/tool-discovery/tool-index.d.ts +112 -0
- package/dist/types/tools/archive-reader.d.ts +40 -0
- package/dist/types/tools/ask-answer-registry.d.ts +13 -0
- package/dist/types/tools/ask.d.ts +123 -0
- package/dist/types/tools/ast-edit.d.ts +77 -0
- package/dist/types/tools/ast-grep.d.ts +69 -0
- package/dist/types/tools/auto-generated-guard.d.ts +17 -0
- package/dist/types/tools/bash-allowed-prefixes.d.ts +10 -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 +157 -0
- package/dist/types/tools/bisect.d.ts +81 -0
- package/dist/types/tools/browser/actions.d.ts +54 -0
- package/dist/types/tools/browser/attach.d.ts +50 -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 +57 -0
- package/dist/types/tools/browser/render.d.ts +53 -0
- package/dist/types/tools/browser/tab-protocol.d.ts +144 -0
- package/dist/types/tools/browser/tab-supervisor.d.ts +103 -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 +211 -0
- package/dist/types/tools/calculator.d.ts +76 -0
- package/dist/types/tools/checkpoint.d.ts +63 -0
- package/dist/types/tools/composer-bash-policy.d.ts +14 -0
- package/dist/types/tools/computer/render.d.ts +17 -0
- package/dist/types/tools/computer-gc.d.ts +23 -0
- package/dist/types/tools/computer.d.ts +465 -0
- package/dist/types/tools/conflict-detect.d.ts +205 -0
- package/dist/types/tools/context.d.ts +19 -0
- package/dist/types/tools/cron.d.ts +91 -0
- package/dist/types/tools/debug.d.ts +209 -0
- package/dist/types/tools/eval.d.ts +108 -0
- package/dist/types/tools/fetch.d.ts +84 -0
- package/dist/types/tools/file-recorder.d.ts +13 -0
- package/dist/types/tools/find.d.ts +95 -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 +356 -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/hindsight-recall.d.ts +21 -0
- package/dist/types/tools/hindsight-reflect.d.ts +23 -0
- package/dist/types/tools/hindsight-retain.d.ts +27 -0
- package/dist/types/tools/image-gen.d.ts +79 -0
- package/dist/types/tools/index.d.ts +318 -0
- package/dist/types/tools/irc.d.ts +79 -0
- package/dist/types/tools/job.d.ts +78 -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/monitor.d.ts +54 -0
- package/dist/types/tools/output-meta.d.ts +204 -0
- package/dist/types/tools/path-utils.d.ts +147 -0
- package/dist/types/tools/plan-mode-guard.d.ts +18 -0
- package/dist/types/tools/read.d.ts +85 -0
- package/dist/types/tools/recipe/index.d.ts +45 -0
- package/dist/types/tools/recipe/render.d.ts +36 -0
- package/dist/types/tools/recipe/runner.d.ts +60 -0
- package/dist/types/tools/recipe/runners/cargo.d.ts +16 -0
- package/dist/types/tools/recipe/runners/index.d.ts +2 -0
- package/dist/types/tools/recipe/runners/just.d.ts +2 -0
- package/dist/types/tools/recipe/runners/make.d.ts +2 -0
- package/dist/types/tools/recipe/runners/pkg.d.ts +2 -0
- package/dist/types/tools/recipe/runners/task.d.ts +2 -0
- package/dist/types/tools/render-mermaid.d.ts +37 -0
- package/dist/types/tools/render-utils.d.ts +158 -0
- package/dist/types/tools/renderers.d.ts +26 -0
- package/dist/types/tools/resolve.d.ts +80 -0
- package/dist/types/tools/resource-gc.d.ts +54 -0
- package/dist/types/tools/review.d.ts +63 -0
- package/dist/types/tools/search-tool-bm25.d.ts +65 -0
- package/dist/types/tools/search.d.ts +93 -0
- package/dist/types/tools/skill.d.ts +47 -0
- package/dist/types/tools/sqlite-reader.d.ts +94 -0
- package/dist/types/tools/ssh.d.ts +67 -0
- package/dist/types/tools/subagent-render.d.ts +31 -0
- package/dist/types/tools/subagent.d.ts +117 -0
- package/dist/types/tools/telegram-send.d.ts +32 -0
- package/dist/types/tools/todo-write.d.ts +120 -0
- package/dist/types/tools/tool-errors.d.ts +33 -0
- package/dist/types/tools/tool-result.d.ts +30 -0
- package/dist/types/tools/tool-timeouts.d.ts +56 -0
- package/dist/types/tools/ultragoal-ask-guard.d.ts +12 -0
- package/dist/types/tools/vim.d.ts +58 -0
- package/dist/types/tools/write.d.ts +59 -0
- package/dist/types/tools/yield.d.ts +25 -0
- package/dist/types/tui/code-cell.d.ts +32 -0
- package/dist/types/tui/file-list.d.ts +22 -0
- package/dist/types/tui/hyperlink.d.ts +42 -0
- package/dist/types/tui/index.d.ts +11 -0
- package/dist/types/tui/output-block.d.ts +28 -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 +37 -0
- package/dist/types/utils/clipboard.d.ts +22 -0
- package/dist/types/utils/cmux-workspace.d.ts +52 -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 +25 -0
- package/dist/types/utils/git.d.ts +393 -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/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 +10 -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 +31 -0
- package/dist/types/utils/tool-choice.d.ts +20 -0
- package/dist/types/utils/tools-manager.d.ts +9 -0
- package/dist/types/vim/buffer.d.ts +41 -0
- package/dist/types/vim/commands.d.ts +6 -0
- package/dist/types/vim/engine.d.ts +47 -0
- package/dist/types/vim/parser.d.ts +3 -0
- package/dist/types/vim/render.d.ts +25 -0
- package/dist/types/vim/types.d.ts +182 -0
- package/dist/types/web/insane/bridge.d.ts +103 -0
- package/dist/types/web/insane/url-guard.d.ts +25 -0
- package/dist/types/web/kagi.d.ts +23 -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 +83 -0
- package/dist/types/web/scrapers/utils.d.ts +32 -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 +13 -0
- package/dist/types/web/search/index.d.ts +118 -0
- package/dist/types/web/search/provider.d.ts +55 -0
- package/dist/types/web/search/providers/anthropic.d.ts +32 -0
- package/dist/types/web/search/providers/base.d.ts +90 -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/duckduckgo.d.ts +57 -0
- package/dist/types/web/search/providers/exa.d.ts +52 -0
- package/dist/types/web/search/providers/gemini.d.ts +57 -0
- package/dist/types/web/search/providers/insane.d.ts +53 -0
- package/dist/types/web/search/providers/jina.d.ts +26 -0
- package/dist/types/web/search/providers/kagi.d.ts +24 -0
- package/dist/types/web/search/providers/kimi.d.ts +27 -0
- package/dist/types/web/search/providers/openai-compatible.d.ts +9 -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/text-citations.d.ts +23 -0
- package/dist/types/web/search/providers/utils.d.ts +88 -0
- package/dist/types/web/search/providers/xai.d.ts +64 -0
- package/dist/types/web/search/providers/zai.d.ts +28 -0
- package/dist/types/web/search/render.d.ts +36 -0
- package/dist/types/web/search/types.d.ts +372 -0
- package/dist/types/web/search/utils.d.ts +4 -0
- package/dist/types/workflow/workflow-intent-diff.d.ts +25 -0
- package/dist/types/workflow/workflow-intent-report-consumer.d.ts +50 -0
- package/dist/types/workflow/workflow-intent-report-schema.d.ts +2 -0
- package/dist/types/workflow/workflow-intent-report.d.ts +48 -0
- package/dist/types/workspace-tree.d.ts +42 -0
- package/package.json +118 -117
- package/scripts/build-binary.ts +3 -0
- package/src/append-only-mode.ts +58 -0
- package/src/autoresearch/prompt.md +1 -1
- package/src/autoresearch/tools/log-experiment.ts +1 -1
- package/src/capability/mcp.ts +2 -0
- package/src/capability/rule.ts +9 -0
- package/src/cli/completion-cli.ts +234 -0
- package/src/cli/config-cli.ts +61 -9
- package/src/cli/fast-help.ts +1 -0
- package/src/cli/fixture-report.test.ts +230 -0
- package/src/cli/fixture-report.ts +171 -0
- package/src/cli/nofile-limit.ts +48 -0
- package/src/cli/notify-cli.ts +92 -8
- package/src/cli/telegram-cli.ts +156 -0
- package/src/cli/update-cli.ts +109 -9
- package/src/cli/web-search-cli.ts +5 -7
- package/src/cli.ts +31 -2
- package/src/commands/completion.ts +84 -0
- package/src/commands/config.ts +2 -0
- package/src/commands/contribution-prep.ts +1 -1
- package/src/commands/deep-interview.ts +2 -1
- package/src/commands/launch.ts +1 -1
- package/src/commands/ralplan.ts +1 -0
- package/src/commands/telegram.ts +47 -0
- package/src/config/file-lock.ts +73 -34
- package/src/config/keybindings.ts +17 -8
- package/src/config/mcp-schema.json +4 -0
- package/src/config/model-profile-activation.ts +65 -0
- package/src/config/model-profiles.ts +31 -2
- package/src/config/settings-schema.ts +279 -7
- package/src/config/settings.ts +22 -0
- package/src/config/telegram-autostart.ts +107 -0
- package/src/config/telegram-env-bridge.ts +92 -0
- package/src/defaults/skc/skills/ralplan/SKILL.md +29 -20
- package/src/defaults/skc/skills/team/SKILL.md +17 -14
- package/src/defaults/skc/skills/ultragoal/SKILL.md +95 -115
- package/src/defaults/skc/skills/ultragoal/pipeline-validation-contracts.md +30 -0
- package/src/defaults/skc-defaults.ts +25 -0
- package/src/discovery/builtin.ts +12 -0
- package/src/discovery/cursor.ts +5 -84
- package/src/discovery/gemini.ts +3 -89
- package/src/discovery/helpers.ts +10 -0
- package/src/discovery/index.ts +5 -1
- package/src/discovery/mcp-json.ts +11 -0
- package/src/discovery/opencode.ts +5 -122
- package/src/discovery/windsurf.ts +4 -82
- package/src/edit/read-file.ts +9 -1
- package/src/export/html/template.generated.ts +1 -1
- package/src/export/html/template.js +60 -2
- package/src/export/ttsr.ts +96 -18
- package/src/extensibility/extensions/runner.ts +185 -220
- package/src/extensibility/extensions/types.ts +20 -0
- package/src/extensibility/skc-plugins/runtime-adapters.ts +156 -44
- package/src/extensibility/skills.ts +30 -2
- package/src/goals/runtime.ts +10 -2
- package/src/hindsight/backend.ts +1 -3
- package/src/hooks/native-skill-hook.ts +124 -4
- package/src/hooks/skill-state.ts +33 -73
- package/src/i18n/messages/de.ts +1 -0
- package/src/i18n/messages/en.ts +1 -0
- package/src/i18n/messages/es.ts +1 -0
- package/src/i18n/messages/fr.ts +1 -0
- package/src/i18n/messages/ja.settings.ts +28 -0
- package/src/i18n/messages/ja.ts +1 -0
- package/src/i18n/messages/ko.settings.ts +28 -0
- package/src/i18n/messages/ko.ts +1 -0
- package/src/i18n/messages/zh.settings.ts +28 -0
- package/src/i18n/messages/zh.ts +1 -0
- package/src/internal-urls/docs-index.generated.ts +21 -8
- package/src/main.ts +100 -45
- package/src/memories/index.ts +12 -1
- package/src/migrate/executor.ts +23 -6
- package/src/modes/acp/acp-agent.ts +7 -6
- package/src/modes/components/agent-dashboard.ts +1 -34
- package/src/modes/components/assistant-message.ts +241 -82
- package/src/modes/components/custom-editor.ts +27 -0
- package/src/modes/components/extensions/extension-dashboard.ts +2 -48
- package/src/modes/components/hook-selector.ts +21 -3
- package/src/modes/components/model-selector.ts +118 -15
- package/src/modes/components/queued-message-selector.ts +92 -0
- package/src/modes/components/session-selector.ts +19 -9
- package/src/modes/components/settings-selector.ts +64 -5
- package/src/modes/components/skill-message.ts +18 -10
- package/src/modes/components/status-line/presets.ts +11 -0
- package/src/modes/components/status-line/segments.ts +10 -2
- package/src/modes/components/status-line.ts +341 -99
- package/src/modes/components/tool-execution.ts +44 -19
- package/src/modes/components/tree-selector.ts +28 -8
- package/src/modes/components/two-column-body.ts +36 -0
- package/src/modes/components/welcome.ts +335 -63
- package/src/modes/controllers/command-controller.ts +66 -6
- package/src/modes/controllers/event-controller.ts +70 -47
- package/src/modes/controllers/extension-ui-controller.ts +22 -12
- package/src/modes/controllers/input-controller.ts +367 -53
- package/src/modes/controllers/selector-controller.ts +152 -52
- package/src/modes/interactive-mode.ts +80 -39
- package/src/modes/print-mode.ts +43 -4
- package/src/modes/prompt-action-autocomplete.ts +47 -14
- package/src/modes/rpc/rpc-mode.ts +29 -3
- package/src/modes/rpc/rpc-types.ts +10 -0
- package/src/modes/shared/agent-wire/command-validation.ts +4 -0
- package/src/modes/shared/agent-wire/deep-interview-gate.ts +72 -15
- package/src/modes/shared/agent-wire/event-contract.ts +22 -0
- package/src/modes/shared/agent-wire/event-envelope.ts +82 -0
- package/src/modes/shared/agent-wire/scopes.ts +1 -0
- package/src/modes/shared/agent-wire/workflow-gate-schema.ts +20 -0
- package/src/modes/slash-command-visibility.ts +9 -0
- package/src/modes/theme/theme.ts +5 -1
- package/src/modes/types.ts +9 -1
- package/src/modes/utils/hotkeys-markdown.ts +6 -2
- package/src/modes/utils/ui-helpers.ts +95 -9
- package/src/notifications/config.ts +25 -5
- package/src/notifications/daemon-paths.ts +2 -0
- package/src/notifications/html-format.ts +75 -1
- package/src/notifications/index.ts +149 -16
- package/src/notifications/lifecycle-commands.ts +37 -7
- package/src/notifications/lifecycle-control-runtime.ts +12 -3
- package/src/notifications/lifecycle-orchestrator.ts +19 -6
- package/src/notifications/recent-activity.ts +32 -8
- package/src/notifications/telegram-daemon-cli.ts +13 -4
- package/src/notifications/telegram-daemon-control.ts +14 -3
- package/src/notifications/telegram-daemon.ts +382 -93
- package/src/notifications/telegram-reference.ts +36 -30
- package/src/notifications/threaded-render.ts +31 -7
- package/src/prompts/agents/architect.md +24 -12
- package/src/prompts/agents/critic.md +27 -20
- package/src/prompts/agents/executor.md +14 -11
- package/src/prompts/agents/planner.md +24 -14
- package/src/prompts/ci-green-request.md +3 -8
- package/src/prompts/goals/goal-continuation.md +0 -5
- package/src/prompts/goals/goal-mode-active.md +0 -5
- package/src/prompts/system/agent-creation-architect.md +2 -2
- package/src/prompts/system/plan-mode-active.md +1 -1
- package/src/prompts/system/plan-mode-subagent.md +3 -3
- package/src/prompts/system/project-prompt.md +0 -13
- package/src/prompts/system/subagent-system-prompt.md +3 -2
- package/src/prompts/system/system-prompt.md +42 -12
- package/src/prompts/system/volatile-project-context.md +10 -0
- package/src/prompts/system/web-search.md +4 -7
- package/src/prompts/tools/apply-patch.md +6 -0
- package/src/prompts/tools/ast-edit.md +1 -0
- package/src/prompts/tools/bash.md +2 -2
- package/src/prompts/tools/bisect.md +22 -0
- package/src/prompts/tools/browser.md +1 -1
- package/src/prompts/tools/computer.md +2 -2
- package/src/prompts/tools/cron.md +0 -2
- package/src/prompts/tools/eval.md +2 -2
- package/src/prompts/tools/find.md +1 -1
- package/src/prompts/tools/github.md +6 -6
- package/src/prompts/tools/goal.md +1 -3
- package/src/prompts/tools/image-gen.md +12 -5
- package/src/prompts/tools/irc.md +5 -4
- package/src/prompts/tools/job.md +2 -2
- package/src/prompts/tools/lsp.md +1 -1
- package/src/prompts/tools/monitor.md +2 -2
- package/src/prompts/tools/patch.md +2 -2
- package/src/prompts/tools/replace.md +2 -21
- package/src/prompts/tools/rewind.md +1 -1
- package/src/prompts/tools/search-tool-bm25.md +1 -11
- package/src/prompts/tools/search.md +1 -1
- package/src/prompts/tools/skill.md +3 -2
- package/src/prompts/tools/ssh.md +2 -1
- package/src/prompts/tools/subagent.md +2 -2
- package/src/prompts/tools/task.md +4 -5
- package/src/prompts/tools/todo-write.md +1 -1
- package/src/prompts/tools/vim.md +1 -0
- package/src/prompts/tools/web-search.md +2 -0
- package/src/prompts/tools/write.md +8 -2
- package/src/runtime-api-key.ts +16 -0
- package/src/runtime-mcp/config-writer.ts +28 -0
- package/src/runtime-mcp/config.ts +7 -0
- package/src/runtime-mcp/loader.ts +3 -0
- package/src/runtime-mcp/manager.ts +3 -0
- package/src/runtime-mcp/types.ts +6 -0
- package/src/sdk.ts +62 -39
- package/src/session/agent-session.ts +1041 -150
- package/src/session/agent-storage.ts +4 -0
- package/src/session/file-mention-pruning.ts +64 -0
- package/src/session/messages.ts +4 -0
- package/src/session/session-manager.ts +161 -22
- package/src/skc-runtime/deep-interview-ambiguity.ts +206 -0
- package/src/skc-runtime/deep-interview-recorder.ts +62 -8
- package/src/skc-runtime/deep-interview-state.ts +44 -2
- package/src/skc-runtime/ralplan-runtime.ts +22 -6
- package/src/skc-runtime/restricted-role-agent-bash.ts +1 -0
- package/src/skc-runtime/session-state-sidecar.ts +413 -27
- package/src/skc-runtime/state-runtime.ts +20 -7
- package/src/skc-runtime/state-writer.ts +20 -5
- package/src/skc-runtime/ultragoal-guard.ts +205 -90
- package/src/skc-runtime/ultragoal-receipt-freshness.ts +315 -0
- package/src/skc-runtime/ultragoal-runtime.ts +1671 -275
- package/src/skc-runtime/workflow-manifest.generated.json +108 -5
- package/src/skc-runtime/workflow-manifest.ts +74 -2
- package/src/skill-state/active-state.ts +141 -5
- package/src/skill-state/deep-interview-mutation-guard.ts +67 -3
- package/src/slash-commands/builtin-registry.ts +248 -81
- package/src/slash-commands/types.ts +2 -0
- package/src/system-prompt.ts +64 -15
- package/src/task/executor.ts +137 -24
- package/src/task/fork-context-advisory.ts +2 -7
- package/src/task/fork-context-budget.ts +9 -0
- package/src/task/index.ts +13 -6
- package/src/task/output-manager.ts +20 -8
- package/src/task/receipt.ts +26 -7
- package/src/task/token-log.test.ts +188 -0
- package/src/task/token-log.ts +179 -0
- package/src/tools/ast-grep.ts +10 -7
- package/src/tools/bash.ts +39 -14
- package/src/tools/bisect.ts +367 -0
- package/src/tools/computer.ts +246 -43
- package/src/tools/index.ts +11 -1
- package/src/tools/output-meta.ts +116 -4
- package/src/tools/search.ts +8 -2
- package/src/tools/skill.ts +16 -1
- package/src/tools/telegram-send.ts +6 -0
- package/src/tools/ultragoal-ask-guard.ts +39 -5
- package/src/utils/cmux-workspace.ts +233 -0
- package/src/utils/file-mentions.ts +39 -7
- package/src/utils/git.ts +73 -0
- package/src/utils/title-generator.ts +2 -0
- package/src/web/kagi.ts +1 -1
- package/src/web/parallel.ts +2 -2
- package/src/web/scrapers/youtube.ts +24 -12
- package/src/web/search/index.ts +137 -52
- package/src/web/search/provider.ts +80 -0
- package/src/web/search/providers/anthropic.ts +1 -1
- package/src/web/search/providers/brave.ts +1 -1
- package/src/web/search/providers/codex.ts +1 -1
- package/src/web/search/providers/duckduckgo.ts +1 -1
- package/src/web/search/providers/exa.ts +1 -1
- package/src/web/search/providers/gemini.ts +7 -3
- package/src/web/search/providers/jina.ts +1 -1
- package/src/web/search/providers/kimi.ts +6 -1
- package/src/web/search/providers/openai-compatible.ts +1 -1
- package/src/web/search/providers/parallel.ts +1 -1
- package/src/web/search/providers/perplexity.ts +2 -2
- package/src/web/search/providers/searxng.ts +1 -1
- package/src/web/search/providers/synthetic.ts +1 -1
- package/src/web/search/providers/tavily.ts +1 -1
- package/src/web/search/providers/utils.ts +67 -17
- package/src/web/search/providers/xai.ts +1 -1
- package/src/web/search/providers/zai.ts +1 -1
- package/src/web/search/render.ts +3 -0
- package/src/workflow/workflow-intent-diff.ts +222 -0
- package/src/workflow/workflow-intent-report-consumer.ts +221 -0
- package/src/workflow/workflow-intent-report-schema.ts +129 -0
- package/src/workflow/workflow-intent-report.ts +135 -0
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
type AgentMessage,
|
|
27
27
|
type AgentState,
|
|
28
28
|
type AgentTool,
|
|
29
|
-
AppendOnlyContextManager,
|
|
30
29
|
resolveTelemetry,
|
|
31
30
|
type StablePrefixSnapshot,
|
|
32
31
|
ThinkingLevel,
|
|
@@ -44,16 +43,20 @@ import {
|
|
|
44
43
|
type EmergencyCompactionSample,
|
|
45
44
|
emergencyCompactionReason,
|
|
46
45
|
estimateMessageTokensHeuristic,
|
|
46
|
+
estimateTextTokensHeuristic,
|
|
47
47
|
generateBranchSummary,
|
|
48
48
|
generateHandoff,
|
|
49
|
+
IMAGE_TOKEN_ESTIMATE,
|
|
49
50
|
prepareCompaction,
|
|
50
51
|
type SummaryOptions,
|
|
51
52
|
shouldCompact,
|
|
52
53
|
} from "@sayknow-cli/agent-core/compaction";
|
|
53
54
|
import {
|
|
54
55
|
DEFAULT_PRUNE_CONFIG,
|
|
56
|
+
estimateToolOutputPruneSavings,
|
|
55
57
|
pruneAssistantToolArguments,
|
|
56
58
|
pruneToolOutputs,
|
|
59
|
+
shouldRunMaintenancePrune,
|
|
57
60
|
} from "@sayknow-cli/agent-core/compaction/pruning";
|
|
58
61
|
import type {
|
|
59
62
|
AssistantMessage,
|
|
@@ -128,6 +131,7 @@ import {
|
|
|
128
131
|
prompt,
|
|
129
132
|
Snowflake,
|
|
130
133
|
} from "@sayknow-cli/utils";
|
|
134
|
+
import { createAppendOnlyContextManager, resolveAppendOnlyMode } from "../append-only-mode";
|
|
131
135
|
import { type AsyncJob, type AsyncJobDeliveryState, AsyncJobManager } from "../async";
|
|
132
136
|
import { reset as resetCapabilities } from "../capability";
|
|
133
137
|
import type { Rule } from "../capability/rule";
|
|
@@ -225,7 +229,10 @@ import {
|
|
|
225
229
|
modeStatePath as sessionModeStatePath,
|
|
226
230
|
sessionStateDir,
|
|
227
231
|
} from "../skc-runtime/session-layout";
|
|
228
|
-
import {
|
|
232
|
+
import {
|
|
233
|
+
persistCoordinatorRuntimeStateFromEvent,
|
|
234
|
+
registerCoordinatorRuntimeStateFinalizer,
|
|
235
|
+
} from "../skc-runtime/session-state-sidecar";
|
|
229
236
|
import { writeArtifact } from "../skc-runtime/state-writer";
|
|
230
237
|
import { requestSkcWorkerIntegrationAttempt } from "../skc-runtime/team-runtime";
|
|
231
238
|
import {
|
|
@@ -235,6 +242,7 @@ import {
|
|
|
235
242
|
} from "../skill-state/active-state";
|
|
236
243
|
import { assertWorkflowMutationAllowed } from "../skill-state/deep-interview-mutation-guard";
|
|
237
244
|
import { invalidateHostMetadata } from "../ssh/connection-manager";
|
|
245
|
+
import { buildVolatileProjectContext } from "../system-prompt";
|
|
238
246
|
import { resolveThinkingLevelForModel, toReasoningEffort } from "../thinking";
|
|
239
247
|
import {
|
|
240
248
|
buildDiscoverableToolSearchIndex,
|
|
@@ -249,7 +257,7 @@ import { assertEditableFile } from "../tools/auto-generated-guard";
|
|
|
249
257
|
import { releaseTabsForOwner } from "../tools/browser/tab-supervisor";
|
|
250
258
|
import type { CheckpointState } from "../tools/checkpoint";
|
|
251
259
|
import { outputMeta, wrapToolWithMetaNotice } from "../tools/output-meta";
|
|
252
|
-
import { normalizeLocalScheme, resolveToCwd } from "../tools/path-utils";
|
|
260
|
+
import { normalizeLocalScheme, resolveReadPath, resolveToCwd } from "../tools/path-utils";
|
|
253
261
|
import { registerResourceGcSession } from "../tools/resource-gc";
|
|
254
262
|
import { getLatestTodoPhasesFromEntries, type TodoItem, type TodoPhase } from "../tools/todo-write";
|
|
255
263
|
import { ToolAbortError, ToolError } from "../tools/tool-errors";
|
|
@@ -260,6 +268,8 @@ import { type EditMode, resolveEditMode } from "../utils/edit-mode";
|
|
|
260
268
|
import { resolveFileDisplayMode } from "../utils/file-display-mode";
|
|
261
269
|
import { extractFileMentions, generateFileMentionMessages } from "../utils/file-mentions";
|
|
262
270
|
import { buildNamedToolChoice, buildNamedToolChoiceResult } from "../utils/tool-choice";
|
|
271
|
+
import { buildWorkflowIntentDiff, WORKFLOW_INTENT_DIFF_CUSTOM_TYPE } from "../workflow/workflow-intent-diff";
|
|
272
|
+
import { buildWorkspaceTree, type WorkspaceTree } from "../workspace-tree";
|
|
263
273
|
import type { AuthStorage } from "./auth-storage";
|
|
264
274
|
import type { ClientBridge, ClientBridgePermissionOption, ClientBridgePermissionOutcome } from "./client-bridge";
|
|
265
275
|
import {
|
|
@@ -267,6 +277,7 @@ import {
|
|
|
267
277
|
type ContributionPrepResult,
|
|
268
278
|
prepareContributionPrep,
|
|
269
279
|
} from "./contribution-prep";
|
|
280
|
+
import { pruneStaleFileMentions } from "./file-mention-pruning";
|
|
270
281
|
import {
|
|
271
282
|
type BashExecutionMessage,
|
|
272
283
|
type CompactionSummaryMessage,
|
|
@@ -353,7 +364,7 @@ export interface AgentSessionConfig {
|
|
|
353
364
|
agent: Agent;
|
|
354
365
|
sessionManager: SessionManager;
|
|
355
366
|
settings: Settings;
|
|
356
|
-
/** Models to cycle through with
|
|
367
|
+
/** Models to cycle through with Alt+N (from --models flag) */
|
|
357
368
|
scopedModels?: ScopedModelSelection[];
|
|
358
369
|
/** Initial session thinking selector. */
|
|
359
370
|
thinkingLevel?: ThinkingLevel;
|
|
@@ -392,6 +403,8 @@ export interface AgentSessionConfig {
|
|
|
392
403
|
convertToLlm?: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;
|
|
393
404
|
/** System prompt builder that can consider tool availability. Returns ordered provider-facing blocks. */
|
|
394
405
|
rebuildSystemPrompt?: (toolNames: string[], tools: Map<string, AgentTool>) => Promise<{ systemPrompt: string[] }>;
|
|
406
|
+
/** Initial workspace tree snapshot used for the first volatile per-turn context message. */
|
|
407
|
+
workspaceTree?: WorkspaceTree;
|
|
395
408
|
/** Rebuild the SSH tool from current capability discovery results. */
|
|
396
409
|
reloadSshTool?: () => Promise<AgentTool | null>;
|
|
397
410
|
requestedToolNames?: ReadonlySet<string>;
|
|
@@ -612,6 +625,13 @@ const IRC_REPLY_MAX_BYTES = 4096;
|
|
|
612
625
|
*/
|
|
613
626
|
const SIGNAL_TEARDOWN_TIMEOUT_MS = 5_000;
|
|
614
627
|
|
|
628
|
+
/**
|
|
629
|
+
* Throttle window for the per-turn volatile workspace-tree scan. Date/cwd are
|
|
630
|
+
* refreshed every turn; the mtime-sorted tree is rescanned + re-embedded at most
|
|
631
|
+
* once per this interval to bound prompt-hot-path IO and history accumulation.
|
|
632
|
+
*/
|
|
633
|
+
const VOLATILE_TREE_TTL_MS = 30_000;
|
|
634
|
+
|
|
615
635
|
/**
|
|
616
636
|
* Collapse degenerate IRC ephemeral replies before they hit the relay.
|
|
617
637
|
* Models occasionally loop on a single line (~16 reports of N-times-repeated
|
|
@@ -901,8 +921,17 @@ function extractPermissionLocations(
|
|
|
901
921
|
* `tag` is set only by `enqueueCustomMessageDisplay` (used for skill-prompt
|
|
902
922
|
* custom messages queued during streaming) and is matched by the custom-role
|
|
903
923
|
* `message_start` dequeue branch; user-message pushes leave it undefined and
|
|
904
|
-
* rely on the existing text-equality match.
|
|
905
|
-
|
|
924
|
+
* rely on the existing text-equality match. `sequence` gives each queued chip a
|
|
925
|
+
* stable edit id while the display arrays preserve delivery order. */
|
|
926
|
+
type QueuedDisplayEntry = { text: string; tag?: string; sequence: number };
|
|
927
|
+
export type QueuedMessageEditMode = "steer" | "followUp";
|
|
928
|
+
|
|
929
|
+
export interface QueuedMessageEditEntry {
|
|
930
|
+
id: string;
|
|
931
|
+
text: string;
|
|
932
|
+
mode: QueuedMessageEditMode;
|
|
933
|
+
label: string;
|
|
934
|
+
}
|
|
906
935
|
|
|
907
936
|
/** A custom message contributed at the before-agent-start point. */
|
|
908
937
|
export type BeforeAgentStartInternalMessage = Pick<
|
|
@@ -923,6 +952,136 @@ export type BeforeAgentStartContributor = (event: {
|
|
|
923
952
|
sessionId: string | undefined;
|
|
924
953
|
}) => Promise<BeforeAgentStartInternalMessage | undefined>;
|
|
925
954
|
|
|
955
|
+
export class WorkerIntegrationRequestScheduler {
|
|
956
|
+
#inFlight: Promise<void> | undefined = undefined;
|
|
957
|
+
#pending = false;
|
|
958
|
+
|
|
959
|
+
constructor(readonly request: () => Promise<void>) {}
|
|
960
|
+
|
|
961
|
+
enqueue(): void {
|
|
962
|
+
if (this.#inFlight) {
|
|
963
|
+
this.#pending = true;
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
this.#start();
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
async flush(): Promise<void> {
|
|
970
|
+
while (this.#inFlight) {
|
|
971
|
+
await this.#inFlight;
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
#start(): void {
|
|
976
|
+
this.#pending = false;
|
|
977
|
+
// Isolate request rejections so flush() can never reject or deadlock: the
|
|
978
|
+
// request is expected to handle/log its own errors, but a throwing generic
|
|
979
|
+
// request must still clear #inFlight and drain any trailing pending run.
|
|
980
|
+
this.#inFlight = this.request()
|
|
981
|
+
.catch(() => {})
|
|
982
|
+
.finally(() => {
|
|
983
|
+
this.#inFlight = undefined;
|
|
984
|
+
if (this.#pending) this.#start();
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
export type StreamingEditParsedToolCall = {
|
|
990
|
+
toolCall: ToolCall;
|
|
991
|
+
path: string;
|
|
992
|
+
resolvedPath: string;
|
|
993
|
+
diff?: string;
|
|
994
|
+
op?: string;
|
|
995
|
+
rename?: string;
|
|
996
|
+
};
|
|
997
|
+
|
|
998
|
+
export type StreamingEditParsedCacheEntry = {
|
|
999
|
+
version: string;
|
|
1000
|
+
parsed: StreamingEditParsedToolCall | undefined;
|
|
1001
|
+
};
|
|
1002
|
+
|
|
1003
|
+
function stableStreamingEditArgsVersion(args: unknown): string | undefined {
|
|
1004
|
+
if (typeof args === "string") return args;
|
|
1005
|
+
if (!args || typeof args !== "object" || Array.isArray(args)) return undefined;
|
|
1006
|
+
try {
|
|
1007
|
+
return JSON.stringify(args);
|
|
1008
|
+
} catch {
|
|
1009
|
+
return undefined;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
export function getStreamingEditToolCallForEvent(
|
|
1014
|
+
event: AgentEvent,
|
|
1015
|
+
cache: Map<string, StreamingEditParsedCacheEntry>,
|
|
1016
|
+
resolvePath: (filePath: string) => string | undefined,
|
|
1017
|
+
): StreamingEditParsedToolCall | undefined {
|
|
1018
|
+
if (event.type !== "message_update") return undefined;
|
|
1019
|
+
if (event.message.role !== "assistant") return undefined;
|
|
1020
|
+
|
|
1021
|
+
const contentIndex = event.assistantMessageEvent.contentIndex ?? 0;
|
|
1022
|
+
const messageContent = event.message.content;
|
|
1023
|
+
if (!Array.isArray(messageContent) || contentIndex < 0 || contentIndex >= messageContent.length) {
|
|
1024
|
+
return undefined;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
const toolCall = messageContent[contentIndex] as ToolCall;
|
|
1028
|
+
if (toolCall.name !== "edit") return undefined;
|
|
1029
|
+
|
|
1030
|
+
const version = stableStreamingEditArgsVersion(toolCall.arguments);
|
|
1031
|
+
if (version === undefined) return undefined;
|
|
1032
|
+
const cacheKey = String(contentIndex);
|
|
1033
|
+
const cached = cache.get(cacheKey);
|
|
1034
|
+
if (cached?.version === version) return cached.parsed;
|
|
1035
|
+
|
|
1036
|
+
let args: unknown = toolCall.arguments;
|
|
1037
|
+
if (typeof args === "string") {
|
|
1038
|
+
try {
|
|
1039
|
+
args = JSON.parse(args) as unknown;
|
|
1040
|
+
} catch {
|
|
1041
|
+
cache.delete(cacheKey);
|
|
1042
|
+
return undefined;
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
if (!args || typeof args !== "object" || Array.isArray(args)) return undefined;
|
|
1046
|
+
if ("old_text" in args || "new_text" in args) return undefined;
|
|
1047
|
+
|
|
1048
|
+
const argsRecord = args as Record<string, unknown>;
|
|
1049
|
+
const path = typeof argsRecord.path === "string" ? argsRecord.path : undefined;
|
|
1050
|
+
if (!path) return undefined;
|
|
1051
|
+
const resolvedPath = resolvePath(path);
|
|
1052
|
+
if (resolvedPath === undefined) return undefined;
|
|
1053
|
+
|
|
1054
|
+
const parsed = {
|
|
1055
|
+
toolCall,
|
|
1056
|
+
path,
|
|
1057
|
+
resolvedPath,
|
|
1058
|
+
diff: typeof argsRecord.diff === "string" ? argsRecord.diff : undefined,
|
|
1059
|
+
op: typeof argsRecord.op === "string" ? argsRecord.op : undefined,
|
|
1060
|
+
rename: typeof argsRecord.rename === "string" ? argsRecord.rename : undefined,
|
|
1061
|
+
};
|
|
1062
|
+
cache.set(cacheKey, { version, parsed });
|
|
1063
|
+
return parsed;
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
/** Test-only counters for AgentSession event fan-out hot-path assertions. */
|
|
1067
|
+
export const __agentSessionPerfCounters = {
|
|
1068
|
+
listenerSnapshotRebuilds: 0,
|
|
1069
|
+
messageUpdateExtensionQueues: 0,
|
|
1070
|
+
reset(): void {
|
|
1071
|
+
this.listenerSnapshotRebuilds = 0;
|
|
1072
|
+
this.messageUpdateExtensionQueues = 0;
|
|
1073
|
+
},
|
|
1074
|
+
};
|
|
1075
|
+
|
|
1076
|
+
export function buildContextInjectionSignature(kind: string, parts: readonly string[]): string {
|
|
1077
|
+
const hash = crypto.createHash("sha256");
|
|
1078
|
+
hash.update(kind);
|
|
1079
|
+
for (const part of parts) {
|
|
1080
|
+
hash.update("\0");
|
|
1081
|
+
hash.update(part);
|
|
1082
|
+
}
|
|
1083
|
+
return hash.digest("base64url");
|
|
1084
|
+
}
|
|
926
1085
|
export class AgentSession {
|
|
927
1086
|
readonly agent: Agent;
|
|
928
1087
|
readonly sessionManager: SessionManager;
|
|
@@ -946,6 +1105,12 @@ export class AgentSession {
|
|
|
946
1105
|
/** Last (enable, providerId) tuple resolved by `#syncAppendOnlyContext` — used to skip no-op invalidations. */
|
|
947
1106
|
#lastAppendOnlyResolution?: { enable: boolean; providerId: string | undefined };
|
|
948
1107
|
#eventListeners: AgentSessionEventListener[] = [];
|
|
1108
|
+
#eventListenerSnapshot: readonly AgentSessionEventListener[] = Object.freeze([]);
|
|
1109
|
+
|
|
1110
|
+
#rebuildEventListenerSnapshot(): void {
|
|
1111
|
+
this.#eventListenerSnapshot = Object.freeze([...this.#eventListeners]);
|
|
1112
|
+
__agentSessionPerfCounters.listenerSnapshotRebuilds += 1;
|
|
1113
|
+
}
|
|
949
1114
|
|
|
950
1115
|
/** Tracks pending steering messages for UI display. Removed when delivered.
|
|
951
1116
|
* Entry shape: `{ text }` for plain-text steers (user-message dequeue
|
|
@@ -956,6 +1121,7 @@ export class AgentSession {
|
|
|
956
1121
|
/** Tracks pending follow-up messages for UI display. Removed when delivered.
|
|
957
1122
|
* See `#steeringMessages` for entry shape. */
|
|
958
1123
|
#followUpMessages: QueuedDisplayEntry[] = [];
|
|
1124
|
+
#queuedDisplaySequence = 0;
|
|
959
1125
|
/** Messages queued to be included with the next user prompt as context ("asides"). */
|
|
960
1126
|
#pendingNextTurnMessages: CustomMessage[] = [];
|
|
961
1127
|
#scheduledHiddenNextTurnGeneration: number | undefined = undefined;
|
|
@@ -963,13 +1129,18 @@ export class AgentSession {
|
|
|
963
1129
|
#goalModeState: GoalModeState | undefined;
|
|
964
1130
|
#workflowGateEmitter: WorkflowGateEmitter | undefined;
|
|
965
1131
|
#goalRuntime: GoalRuntime;
|
|
1132
|
+
#lastInjectedGoalContextSig: string | undefined = undefined;
|
|
1133
|
+
#lastInjectedPlanContextSig: string | undefined = undefined;
|
|
966
1134
|
#goalTurnCounter = 0;
|
|
1135
|
+
#streamingEditParsedToolCallCache = new Map<string, StreamingEditParsedCacheEntry>();
|
|
967
1136
|
#planReferenceSent = false;
|
|
968
1137
|
#planReferencePath = "local://PLAN.md";
|
|
969
1138
|
#clientBridge: ClientBridge | undefined;
|
|
970
1139
|
#allowAcpAgentInitiatedTurns = false;
|
|
971
1140
|
/** Per-session memory of allow_always / reject_always decisions for gated tools. */
|
|
972
1141
|
#acpPermissionDecisions: Map<string, "allow_always" | "reject_always"> = new Map();
|
|
1142
|
+
#guardedToolWrapperCache = new WeakMap<AgentTool, Map<string, AgentTool>>();
|
|
1143
|
+
#acpPermissionWrapperVersion = 0;
|
|
973
1144
|
|
|
974
1145
|
// Compaction state
|
|
975
1146
|
#compactionAbortController: AbortController | undefined = undefined;
|
|
@@ -1007,6 +1178,7 @@ export class AgentSession {
|
|
|
1007
1178
|
#evalKernelOwnerId: string;
|
|
1008
1179
|
/** Idempotent unregister handle for this session's resource-GC registration. */
|
|
1009
1180
|
#unregisterResourceGc?: () => void;
|
|
1181
|
+
#unregisterRuntimeStateFinalizer?: () => void;
|
|
1010
1182
|
/**
|
|
1011
1183
|
* AsyncJobManager owned by this session (top-level only). Subagents leave
|
|
1012
1184
|
* this undefined and **MUST NOT** dispose the global instance on teardown.
|
|
@@ -1030,6 +1202,11 @@ export class AgentSession {
|
|
|
1030
1202
|
// Extension system
|
|
1031
1203
|
#extensionRunner: ExtensionRunner | undefined = undefined;
|
|
1032
1204
|
#turnIndex = 0;
|
|
1205
|
+
#workerIntegrationScheduler = new WorkerIntegrationRequestScheduler(async () => {
|
|
1206
|
+
await requestSkcWorkerIntegrationAttempt(this.sessionManager.getCwd(), process.env).catch(error => {
|
|
1207
|
+
logger.warn("SKC team worker integration request failed", { error: String(error) });
|
|
1208
|
+
});
|
|
1209
|
+
});
|
|
1033
1210
|
// First-party internal before-agent-start contributors (not user hooks).
|
|
1034
1211
|
#beforeAgentStartContributors: BeforeAgentStartContributor[] = [];
|
|
1035
1212
|
|
|
@@ -1062,6 +1239,10 @@ export class AgentSession {
|
|
|
1062
1239
|
#reloadSshTool: (() => Promise<AgentTool | null>) | undefined;
|
|
1063
1240
|
#requestedToolNames: ReadonlySet<string> | undefined;
|
|
1064
1241
|
#baseSystemPrompt: string[];
|
|
1242
|
+
#initialWorkspaceTree: WorkspaceTree | undefined;
|
|
1243
|
+
/** Throttle cache for the per-turn volatile workspace-tree scan (see #buildVolatileProjectContextMessage). */
|
|
1244
|
+
#cachedWorkspaceTree: WorkspaceTree | undefined;
|
|
1245
|
+
#cachedWorkspaceTreeAt = 0;
|
|
1065
1246
|
/**
|
|
1066
1247
|
* Signature of the (toolNames, tool descriptions) tuple passed to the most
|
|
1067
1248
|
* recent successful `rebuildSystemPrompt` call. Used to skip redundant rebuilds
|
|
@@ -1121,23 +1302,46 @@ export class AgentSession {
|
|
|
1121
1302
|
|
|
1122
1303
|
#streamingEditAbortTriggered = false;
|
|
1123
1304
|
#streamingEditCheckedLineCounts = new Map<string, number>();
|
|
1305
|
+
#streamingEditToolCallStates = new Map<
|
|
1306
|
+
string,
|
|
1307
|
+
{
|
|
1308
|
+
op?: string;
|
|
1309
|
+
resolvedPath?: string;
|
|
1310
|
+
lastProcessedOffset: number;
|
|
1311
|
+
processedPrefix: string;
|
|
1312
|
+
settledVerdict?: "aborted" | "non-edit" | "non-update";
|
|
1313
|
+
debugProcessedChars: number;
|
|
1314
|
+
debugCheckedRemovedLines: number;
|
|
1315
|
+
debugFullChecks: number;
|
|
1316
|
+
debugGuardRuns: number;
|
|
1317
|
+
}
|
|
1318
|
+
>();
|
|
1124
1319
|
|
|
1125
1320
|
#streamingEditPrecheckedToolCallIds = new Set<string>();
|
|
1126
1321
|
|
|
1127
1322
|
#streamingEditFileCache = new Map<string, string>();
|
|
1323
|
+
readonly streamingEditDebugCounters = {
|
|
1324
|
+
guardRuns: 0,
|
|
1325
|
+
processedChars: 0,
|
|
1326
|
+
checkedRemovedLines: 0,
|
|
1327
|
+
fullChecks: 0,
|
|
1328
|
+
nonEditDeterminations: 0,
|
|
1329
|
+
};
|
|
1128
1330
|
#promptInFlightCount = 0;
|
|
1129
1331
|
// Wire-level agent_end emission deferred until #promptInFlightCount drops to 0.
|
|
1130
|
-
//
|
|
1131
|
-
//
|
|
1132
|
-
//
|
|
1133
|
-
//
|
|
1134
|
-
// on `agent_end` can fire its next `prompt`
|
|
1135
|
-
//
|
|
1136
|
-
//
|
|
1332
|
+
// Local subscribers and extension hooks both receive the deferred event from
|
|
1333
|
+
// #flushPendingAgentEnd(), preserving the local-before-extension ordering used
|
|
1334
|
+
// by #emitSessionEvent while still preventing external clients from resuming
|
|
1335
|
+
// before #promptWithMessage's finally decrements #promptInFlightCount. Without
|
|
1336
|
+
// this, a client that resumes on `agent_end` can fire its next `prompt` while
|
|
1337
|
+
// the session still reports busy and hit AgentBusyError. Flushed from both
|
|
1338
|
+
// #endInFlight (normal) and #resetInFlight (abort).
|
|
1137
1339
|
#pendingAgentEndEmit: AgentSessionEvent | undefined;
|
|
1138
1340
|
#obfuscator: SecretObfuscator | undefined;
|
|
1139
1341
|
#checkpointState: CheckpointState | undefined = undefined;
|
|
1140
1342
|
#providerReplaySourceCache = new WeakMap<AgentMessage, ProviderReplaySourceCacheEntry>();
|
|
1343
|
+
#lastOversizedAutoMaintenanceAttemptSignature: string | undefined = undefined;
|
|
1344
|
+
|
|
1141
1345
|
#pendingRewindReport: string | undefined = undefined;
|
|
1142
1346
|
#lastSuccessfulYieldToolCallId: string | undefined = undefined;
|
|
1143
1347
|
#promptGeneration = 0;
|
|
@@ -1216,6 +1420,7 @@ export class AgentSession {
|
|
|
1216
1420
|
if (!pending) return;
|
|
1217
1421
|
this.#pendingAgentEndEmit = undefined;
|
|
1218
1422
|
this.#emit(pending);
|
|
1423
|
+
void this.#queueExtensionEvent(pending);
|
|
1219
1424
|
}
|
|
1220
1425
|
|
|
1221
1426
|
constructor(config: AgentSessionConfig) {
|
|
@@ -1232,6 +1437,11 @@ export class AgentSession {
|
|
|
1232
1437
|
settings: this.settings,
|
|
1233
1438
|
});
|
|
1234
1439
|
}
|
|
1440
|
+
this.#unregisterRuntimeStateFinalizer = registerCoordinatorRuntimeStateFinalizer({
|
|
1441
|
+
sessionId: this.sessionId,
|
|
1442
|
+
cwd: this.sessionManager.getCwd(),
|
|
1443
|
+
sessionFile: this.sessionManager.getSessionFile(),
|
|
1444
|
+
});
|
|
1235
1445
|
// Power assertions are taken per turn (see #beginInFlight); nothing acquired here.
|
|
1236
1446
|
this.#evalKernelOwnerId = config.evalKernelOwnerId ?? `agent-session:${Snowflake.next()}`;
|
|
1237
1447
|
this.#ownedAsyncJobManager = config.ownedAsyncJobManager;
|
|
@@ -1304,6 +1514,7 @@ export class AgentSession {
|
|
|
1304
1514
|
this.#getMcpServerInstructions = config.getMcpServerInstructions;
|
|
1305
1515
|
this.#reloadSshTool = config.reloadSshTool;
|
|
1306
1516
|
this.#baseSystemPrompt = this.agent.state.systemPrompt;
|
|
1517
|
+
this.#initialWorkspaceTree = config.workspaceTree;
|
|
1307
1518
|
this.#mcpDiscoveryEnabled = config.mcpDiscoveryEnabled ?? false;
|
|
1308
1519
|
this.#discoverableToolAllowedNames = config.discoverableToolAllowedNames
|
|
1309
1520
|
? new Set(config.discoverableToolAllowedNames.map(name => name.toLowerCase()))
|
|
@@ -1334,16 +1545,6 @@ export class AgentSession {
|
|
|
1334
1545
|
this.#agentRegistry = config.agentRegistry;
|
|
1335
1546
|
this.#providerSessionId = config.providerSessionId;
|
|
1336
1547
|
this.#providerCacheSessionId = config.providerCacheSessionId;
|
|
1337
|
-
this.agent.setAssistantMessageEventInterceptor((message, assistantMessageEvent) => {
|
|
1338
|
-
const event: AgentEvent = {
|
|
1339
|
-
type: "message_update",
|
|
1340
|
-
message,
|
|
1341
|
-
assistantMessageEvent,
|
|
1342
|
-
};
|
|
1343
|
-
const generation = this.#promptGeneration;
|
|
1344
|
-
this.#preCacheStreamingEditFile(event);
|
|
1345
|
-
this.#maybeAbortStreamingEdit(event, generation);
|
|
1346
|
-
});
|
|
1347
1548
|
// Per-tool TTSR reminders are folded into the matched tool's result via this hook.
|
|
1348
1549
|
this.agent.afterToolCall = ctx => this.#ttsrAfterToolCall(ctx);
|
|
1349
1550
|
this.agent.providerSessionState = this.#providerSessionState;
|
|
@@ -1491,13 +1692,30 @@ export class AgentSession {
|
|
|
1491
1692
|
}
|
|
1492
1693
|
|
|
1493
1694
|
async buildForkContextSeed(options: ForkContextSeedOptions): Promise<ForkContextSeed> {
|
|
1695
|
+
const maxMessages = Math.min(500, Math.max(0, Math.trunc(options.maxMessages)));
|
|
1696
|
+
const maxTokens = Math.max(0, Math.trunc(options.maxTokens));
|
|
1697
|
+
if (maxMessages <= 0 || maxTokens <= 0) {
|
|
1698
|
+
return {
|
|
1699
|
+
messages: [],
|
|
1700
|
+
agentMessages: [],
|
|
1701
|
+
metadata: {
|
|
1702
|
+
sourceSessionId: this.sessionId,
|
|
1703
|
+
parentMessageCount: this.messages.length,
|
|
1704
|
+
includedMessages: 0,
|
|
1705
|
+
skippedMessages: 0,
|
|
1706
|
+
approximateTokens: 0,
|
|
1707
|
+
maxMessages,
|
|
1708
|
+
maxTokens,
|
|
1709
|
+
skippedReasons: {},
|
|
1710
|
+
},
|
|
1711
|
+
cacheIdentity: options.cacheIdentity ?? this.sessionId,
|
|
1712
|
+
};
|
|
1713
|
+
}
|
|
1494
1714
|
const transformedMessages = await this.#transformContext([...this.messages], options.signal);
|
|
1495
1715
|
const convertedMessages = await this.#convertToLlm(transformedMessages);
|
|
1496
1716
|
const providerMessages = this.model
|
|
1497
1717
|
? normalizeMessagesForProvider(convertedMessages, this.model)
|
|
1498
1718
|
: convertedMessages;
|
|
1499
|
-
const maxMessages = Math.min(500, Math.max(0, Math.trunc(options.maxMessages)));
|
|
1500
|
-
const maxTokens = Math.max(0, Math.trunc(options.maxTokens));
|
|
1501
1719
|
const selected: Message[] = [];
|
|
1502
1720
|
const skippedReasons: Record<string, number> = {};
|
|
1503
1721
|
let skippedMessages = 0;
|
|
@@ -1521,10 +1739,9 @@ export class AgentSession {
|
|
|
1521
1739
|
recordSkip("unsupported-role");
|
|
1522
1740
|
return undefined;
|
|
1523
1741
|
}
|
|
1524
|
-
const
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
}
|
|
1742
|
+
const messageWithoutProviderPayload = { ...message } as Message & { providerPayload?: unknown };
|
|
1743
|
+
delete messageWithoutProviderPayload.providerPayload;
|
|
1744
|
+
const cloned = cloneJsonValueForForkSeed(messageWithoutProviderPayload) as Message;
|
|
1528
1745
|
if (Array.isArray(cloned.content)) {
|
|
1529
1746
|
const sanitizedContent: TextContent[] = [];
|
|
1530
1747
|
for (const block of cloned.content) {
|
|
@@ -1536,11 +1753,42 @@ export class AgentSession {
|
|
|
1536
1753
|
recordSkip(`unsupported-content-${block.type}`);
|
|
1537
1754
|
}
|
|
1538
1755
|
}
|
|
1756
|
+
if (sanitizedContent.length === 0) {
|
|
1757
|
+
recordSkip("empty-content");
|
|
1758
|
+
return undefined;
|
|
1759
|
+
}
|
|
1539
1760
|
return { ...cloned, content: sanitizedContent } as Message;
|
|
1540
1761
|
}
|
|
1541
1762
|
return cloned;
|
|
1542
1763
|
};
|
|
1543
1764
|
|
|
1765
|
+
const truncateMessageToTokenBudget = (message: Message): { message: Message; tokens: number } => {
|
|
1766
|
+
const notice = `\n\n[fork-context seed: newest message truncated to fit the ${maxTokens}-token budget]`;
|
|
1767
|
+
const contentText = Array.isArray(message.content)
|
|
1768
|
+
? message.content.map(block => (block.type === "text" ? block.text : "")).join("\n\n")
|
|
1769
|
+
: String(message.content ?? "");
|
|
1770
|
+
let low = 0;
|
|
1771
|
+
let high = contentText.length;
|
|
1772
|
+
let bestMessage: Message = { ...message, content: [{ type: "text", text: notice.trimStart() }] };
|
|
1773
|
+
let bestTokens = estimateMessageTokensHeuristic(bestMessage);
|
|
1774
|
+
while (low <= high) {
|
|
1775
|
+
const mid = Math.floor((low + high) / 2);
|
|
1776
|
+
const candidate: Message = {
|
|
1777
|
+
...message,
|
|
1778
|
+
content: [{ type: "text", text: `${contentText.slice(0, mid)}${notice}` }],
|
|
1779
|
+
};
|
|
1780
|
+
const candidateTokens = estimateMessageTokensHeuristic(candidate);
|
|
1781
|
+
if (candidateTokens <= maxTokens) {
|
|
1782
|
+
bestMessage = candidate;
|
|
1783
|
+
bestTokens = candidateTokens;
|
|
1784
|
+
low = mid + 1;
|
|
1785
|
+
} else {
|
|
1786
|
+
high = mid - 1;
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
return { message: bestMessage, tokens: Math.min(bestTokens, maxTokens) };
|
|
1790
|
+
};
|
|
1791
|
+
|
|
1544
1792
|
for (let i = providerMessages.length - 1; i >= 0; i--) {
|
|
1545
1793
|
if (selected.length >= maxMessages) {
|
|
1546
1794
|
recordSkip("message-limit");
|
|
@@ -1549,9 +1797,20 @@ export class AgentSession {
|
|
|
1549
1797
|
const sanitized = sanitizeMessage(providerMessages[i]!);
|
|
1550
1798
|
if (!sanitized) continue;
|
|
1551
1799
|
const messageTokens = estimateMessageTokensHeuristic(sanitized);
|
|
1552
|
-
|
|
1800
|
+
// Stop at the first message that overflows the token budget. The loop walks
|
|
1801
|
+
// newest→oldest, so `break` keeps the seed a CONTIGUOUS run of the most recent
|
|
1802
|
+
// messages. `continue` here would skip the oversized recent message and scavenge
|
|
1803
|
+
// smaller OLDER ones, yielding a non-contiguous seed that misrepresents the
|
|
1804
|
+
// conversation and violates the recency contract of the receipt/last-turn/bounded modes.
|
|
1805
|
+
if (approximateTokens + messageTokens > maxTokens) {
|
|
1553
1806
|
recordSkip("token-limit");
|
|
1554
|
-
|
|
1807
|
+
if (selected.length === 0) {
|
|
1808
|
+
const truncated = truncateMessageToTokenBudget(sanitized);
|
|
1809
|
+
selected.unshift(truncated.message);
|
|
1810
|
+
approximateTokens = truncated.tokens;
|
|
1811
|
+
skippedReasons["newest-message-truncated"] = (skippedReasons["newest-message-truncated"] ?? 0) + 1;
|
|
1812
|
+
}
|
|
1813
|
+
break;
|
|
1555
1814
|
}
|
|
1556
1815
|
selected.unshift(sanitized);
|
|
1557
1816
|
approximateTokens += messageTokens;
|
|
@@ -1625,6 +1884,17 @@ export class AgentSession {
|
|
|
1625
1884
|
this.#planCompactAbortPending = false;
|
|
1626
1885
|
}
|
|
1627
1886
|
|
|
1887
|
+
#createQueuedDisplayEntry(text: string, tag?: string): QueuedDisplayEntry {
|
|
1888
|
+
const entry: QueuedDisplayEntry = { text, sequence: ++this.#queuedDisplaySequence };
|
|
1889
|
+
if (tag !== undefined) {
|
|
1890
|
+
entry.tag = tag;
|
|
1891
|
+
}
|
|
1892
|
+
return entry;
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
#queuedMessageEditId(mode: QueuedMessageEditMode, sequence: number): string {
|
|
1896
|
+
return `${mode}:${sequence}`;
|
|
1897
|
+
}
|
|
1628
1898
|
/** Register a compact display string for a custom message that the caller is
|
|
1629
1899
|
* about to dispatch via `promptCustomMessage` / `sendCustomMessage`.
|
|
1630
1900
|
* Returns a stable tag the caller MUST embed in
|
|
@@ -1638,7 +1908,7 @@ export class AgentSession {
|
|
|
1638
1908
|
const tag = `skc-cmd-${Date.now()}-${++this.#customDisplayTagCounter}`;
|
|
1639
1909
|
const displayText = text.trim();
|
|
1640
1910
|
if (!displayText) return tag;
|
|
1641
|
-
const entry
|
|
1911
|
+
const entry = this.#createQueuedDisplayEntry(displayText, tag);
|
|
1642
1912
|
if (mode === "steer") {
|
|
1643
1913
|
this.#steeringMessages.push(entry);
|
|
1644
1914
|
} else {
|
|
@@ -1694,15 +1964,23 @@ export class AgentSession {
|
|
|
1694
1964
|
manager.cancelAll({ ownerId: this.#agentId });
|
|
1695
1965
|
}
|
|
1696
1966
|
|
|
1967
|
+
#suppressOwnAsyncJobDeliveries(): void {
|
|
1968
|
+
if (!this.#agentId) return;
|
|
1969
|
+
const manager = AsyncJobManager.instance();
|
|
1970
|
+
if (!manager) return;
|
|
1971
|
+
const pendingJobIds = manager.getDeliveryState({ ownerId: this.#agentId }).pendingJobIds;
|
|
1972
|
+
if (pendingJobIds.length > 0) {
|
|
1973
|
+
manager.acknowledgeDeliveries(pendingJobIds);
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1697
1977
|
// =========================================================================
|
|
1698
1978
|
// Event Subscription
|
|
1699
1979
|
// =========================================================================
|
|
1700
1980
|
|
|
1701
1981
|
/** Emit an event to all listeners */
|
|
1702
1982
|
#emit(event: AgentSessionEvent): void {
|
|
1703
|
-
|
|
1704
|
-
const listeners = [...this.#eventListeners];
|
|
1705
|
-
for (const l of listeners) {
|
|
1983
|
+
for (const l of this.#eventListenerSnapshot) {
|
|
1706
1984
|
l(event);
|
|
1707
1985
|
}
|
|
1708
1986
|
}
|
|
@@ -1732,17 +2010,22 @@ export class AgentSession {
|
|
|
1732
2010
|
}
|
|
1733
2011
|
|
|
1734
2012
|
async #emitSessionEvent(event: AgentSessionEvent): Promise<void> {
|
|
1735
|
-
await persistCoordinatorRuntimeStateFromEvent(event, {
|
|
1736
|
-
sessionId: this.sessionId,
|
|
1737
|
-
cwd: this.sessionManager.getCwd(),
|
|
1738
|
-
sessionFile: this.sessionManager.getSessionFile(),
|
|
1739
|
-
});
|
|
1740
2013
|
if (event.type === "message_update") {
|
|
2014
|
+
// Fast path: message_update maps to no sidecar state, so we must not
|
|
2015
|
+
// build the persistRuntimeState closure here (per-token hot path).
|
|
1741
2016
|
this.#emit(event);
|
|
1742
|
-
|
|
2017
|
+
if (this.#hasStreamingExtensionHandlers()) {
|
|
2018
|
+
__agentSessionPerfCounters.messageUpdateExtensionQueues += 1;
|
|
2019
|
+
void this.#queueExtensionEvent(event);
|
|
2020
|
+
}
|
|
1743
2021
|
return;
|
|
1744
2022
|
}
|
|
1745
|
-
|
|
2023
|
+
const persistRuntimeState = () =>
|
|
2024
|
+
persistCoordinatorRuntimeStateFromEvent(event, {
|
|
2025
|
+
sessionId: this.sessionId,
|
|
2026
|
+
cwd: this.sessionManager.getCwd(),
|
|
2027
|
+
sessionFile: this.sessionManager.getSessionFile(),
|
|
2028
|
+
});
|
|
1746
2029
|
// Hold the wire-level agent_end until in-flight prompts unwind. Subscribers
|
|
1747
2030
|
// (rpc-mode, ACP, Cursor) treat agent_end as the "session is idle" signal;
|
|
1748
2031
|
// emitting while #promptInFlightCount > 0 lets a client fire its next
|
|
@@ -1752,10 +2035,18 @@ export class AgentSession {
|
|
|
1752
2035
|
// supersedes the pending one, which is what subscribers want — they only
|
|
1753
2036
|
// care about the final settle.
|
|
1754
2037
|
if (event.type === "agent_end" && this.#promptInFlightCount > 0) {
|
|
2038
|
+
void persistRuntimeState();
|
|
1755
2039
|
this.#pendingAgentEndEmit = event;
|
|
1756
2040
|
return;
|
|
1757
2041
|
}
|
|
2042
|
+
|
|
2043
|
+
// Local subscribers are part of the AgentSession control path: retryNow(),
|
|
2044
|
+
// auto-continuation gates, goal reminders, and tests all observe these events
|
|
2045
|
+
// synchronously. Coordinator sidecar writes and extension hooks are secondary
|
|
2046
|
+
// sinks, so they must not delay or suppress local delivery.
|
|
1758
2047
|
this.#emit(event);
|
|
2048
|
+
void persistRuntimeState();
|
|
2049
|
+
await this.#emitExtensionEvent(event);
|
|
1759
2050
|
}
|
|
1760
2051
|
|
|
1761
2052
|
// Track last assistant message for auto-compaction check
|
|
@@ -1841,7 +2132,7 @@ export class AgentSession {
|
|
|
1841
2132
|
}
|
|
1842
2133
|
}
|
|
1843
2134
|
|
|
1844
|
-
if (event.type === "turn_start") {
|
|
2135
|
+
if (event.type === "turn_start" && this.#goalRuntime.shouldTrackTurnBaseline()) {
|
|
1845
2136
|
const usage = this.getSessionStats().tokens;
|
|
1846
2137
|
this.#goalRuntime.onTurnStart(`turn-${++this.#goalTurnCounter}`, {
|
|
1847
2138
|
input: usage.input,
|
|
@@ -2593,8 +2884,10 @@ export class AgentSession {
|
|
|
2593
2884
|
// The TTSR manager was already claimed at bucket time; only persistence remains.
|
|
2594
2885
|
const ruleNames = rules.map(r => r.name.trim()).filter(n => n.length > 0);
|
|
2595
2886
|
if (ruleNames.length > 0) {
|
|
2596
|
-
this.
|
|
2887
|
+
const records = this.#ttsrManager?.getInjectedRecords().filter(record => ruleNames.includes(record.name));
|
|
2888
|
+
this.sessionManager.appendTtsrInjection(ruleNames, records, this.#ttsrManager?.getMessageCount());
|
|
2597
2889
|
}
|
|
2890
|
+
|
|
2598
2891
|
return {
|
|
2599
2892
|
content: [{ type: "text", text: reminder }, ...ctx.result.content],
|
|
2600
2893
|
};
|
|
@@ -2619,7 +2912,8 @@ export class AgentSession {
|
|
|
2619
2912
|
return;
|
|
2620
2913
|
}
|
|
2621
2914
|
this.#ttsrManager?.markInjectedByNames(uniqueRuleNames);
|
|
2622
|
-
this.
|
|
2915
|
+
const records = this.#ttsrManager?.getInjectedRecords().filter(record => uniqueRuleNames.includes(record.name));
|
|
2916
|
+
this.sessionManager.appendTtsrInjection(uniqueRuleNames, records, this.#ttsrManager?.getMessageCount());
|
|
2623
2917
|
}
|
|
2624
2918
|
|
|
2625
2919
|
#findTtsrAssistantIndex(targetTimestamp: number | undefined): number {
|
|
@@ -2803,55 +3097,16 @@ export class AgentSession {
|
|
|
2803
3097
|
#resetStreamingEditState(): void {
|
|
2804
3098
|
this.#streamingEditAbortTriggered = false;
|
|
2805
3099
|
this.#streamingEditCheckedLineCounts.clear();
|
|
3100
|
+
this.#streamingEditToolCallStates.clear();
|
|
2806
3101
|
this.#streamingEditPrecheckedToolCallIds.clear();
|
|
3102
|
+
this.#streamingEditParsedToolCallCache.clear();
|
|
2807
3103
|
this.#streamingEditFileCache.clear();
|
|
2808
3104
|
}
|
|
2809
3105
|
|
|
2810
|
-
#getStreamingEditToolCall(event: AgentEvent):
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
resolvedPath: string;
|
|
2815
|
-
diff?: string;
|
|
2816
|
-
op?: string;
|
|
2817
|
-
rename?: string;
|
|
2818
|
-
}
|
|
2819
|
-
| undefined {
|
|
2820
|
-
if (event.type !== "message_update") return undefined;
|
|
2821
|
-
if (event.message.role !== "assistant") return undefined;
|
|
2822
|
-
|
|
2823
|
-
const contentIndex = event.assistantMessageEvent.contentIndex ?? 0;
|
|
2824
|
-
const messageContent = event.message.content;
|
|
2825
|
-
if (!Array.isArray(messageContent) || contentIndex < 0 || contentIndex >= messageContent.length) {
|
|
2826
|
-
return undefined;
|
|
2827
|
-
}
|
|
2828
|
-
|
|
2829
|
-
const toolCall = messageContent[contentIndex] as ToolCall;
|
|
2830
|
-
if (toolCall.name !== "edit") return undefined;
|
|
2831
|
-
|
|
2832
|
-
const args = toolCall.arguments;
|
|
2833
|
-
if (!args || typeof args !== "object" || Array.isArray(args)) return undefined;
|
|
2834
|
-
if ("old_text" in args || "new_text" in args) return undefined;
|
|
2835
|
-
|
|
2836
|
-
const path = typeof args.path === "string" ? args.path : undefined;
|
|
2837
|
-
if (!path) return undefined;
|
|
2838
|
-
|
|
2839
|
-
// `local://` URLs (e.g. local://PLAN.md for plan-mode) resolve to a real
|
|
2840
|
-
// on-disk artifacts path; pre-caching works as long as we ask the
|
|
2841
|
-
// local-protocol handler. Other internal-scheme URLs have no stable filesystem representation;
|
|
2842
|
-
// skip pre-cache entirely for those — the edit tool itself will reject
|
|
2843
|
-
// them through its normal dispatch path.
|
|
2844
|
-
const resolvedPath = this.#resolveSessionFsPath(path);
|
|
2845
|
-
if (resolvedPath === undefined) return undefined;
|
|
2846
|
-
|
|
2847
|
-
return {
|
|
2848
|
-
toolCall,
|
|
2849
|
-
path,
|
|
2850
|
-
resolvedPath,
|
|
2851
|
-
diff: typeof args.diff === "string" ? args.diff : undefined,
|
|
2852
|
-
op: typeof args.op === "string" ? args.op : undefined,
|
|
2853
|
-
rename: typeof args.rename === "string" ? args.rename : undefined,
|
|
2854
|
-
};
|
|
3106
|
+
#getStreamingEditToolCall(event: AgentEvent): StreamingEditParsedToolCall | undefined {
|
|
3107
|
+
return getStreamingEditToolCallForEvent(event, this.#streamingEditParsedToolCallCache, filePath =>
|
|
3108
|
+
this.#resolveSessionFsPath(filePath),
|
|
3109
|
+
);
|
|
2855
3110
|
}
|
|
2856
3111
|
|
|
2857
3112
|
#lastStreamingEditToolCallId: string | undefined;
|
|
@@ -2970,36 +3225,122 @@ export class AgentSession {
|
|
|
2970
3225
|
const assistantEvent = event.assistantMessageEvent;
|
|
2971
3226
|
if (assistantEvent.type !== "toolcall_end" && assistantEvent.type !== "toolcall_delta") return;
|
|
2972
3227
|
|
|
3228
|
+
const contentIndex = assistantEvent.contentIndex ?? 0;
|
|
3229
|
+
const messageContent = event.message.role === "assistant" ? event.message.content : undefined;
|
|
3230
|
+
const candidateToolCall = Array.isArray(messageContent)
|
|
3231
|
+
? (messageContent[contentIndex] as ToolCall | undefined)
|
|
3232
|
+
: undefined;
|
|
3233
|
+
const candidateToolCallId = candidateToolCall?.type === "toolCall" ? candidateToolCall.id : undefined;
|
|
3234
|
+
if (candidateToolCallId) {
|
|
3235
|
+
const cached = this.#streamingEditToolCallStates.get(candidateToolCallId);
|
|
3236
|
+
if (
|
|
3237
|
+
cached?.settledVerdict === "aborted" ||
|
|
3238
|
+
cached?.settledVerdict === "non-edit" ||
|
|
3239
|
+
cached?.settledVerdict === "non-update"
|
|
3240
|
+
) {
|
|
3241
|
+
return;
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
|
|
2973
3245
|
const streamingEdit = this.#getStreamingEditToolCall(event);
|
|
2974
|
-
if (!streamingEdit?.toolCall.id)
|
|
3246
|
+
if (!streamingEdit?.toolCall.id) {
|
|
3247
|
+
if (candidateToolCallId) {
|
|
3248
|
+
this.#streamingEditToolCallStates.set(candidateToolCallId, {
|
|
3249
|
+
lastProcessedOffset: 0,
|
|
3250
|
+
processedPrefix: "",
|
|
3251
|
+
settledVerdict: "non-edit",
|
|
3252
|
+
debugProcessedChars: 0,
|
|
3253
|
+
debugCheckedRemovedLines: 0,
|
|
3254
|
+
debugFullChecks: 0,
|
|
3255
|
+
debugGuardRuns: 0,
|
|
3256
|
+
});
|
|
3257
|
+
this.streamingEditDebugCounters.nonEditDeterminations += 1;
|
|
3258
|
+
}
|
|
3259
|
+
return;
|
|
3260
|
+
}
|
|
2975
3261
|
|
|
2976
3262
|
const { toolCall, path, resolvedPath, diff, op, rename } = streamingEdit;
|
|
3263
|
+
let state = this.#streamingEditToolCallStates.get(toolCall.id);
|
|
3264
|
+
if (!state) {
|
|
3265
|
+
state = {
|
|
3266
|
+
op,
|
|
3267
|
+
resolvedPath,
|
|
3268
|
+
lastProcessedOffset: 0,
|
|
3269
|
+
processedPrefix: "",
|
|
3270
|
+
debugProcessedChars: 0,
|
|
3271
|
+
debugCheckedRemovedLines: 0,
|
|
3272
|
+
debugFullChecks: 0,
|
|
3273
|
+
debugGuardRuns: 0,
|
|
3274
|
+
};
|
|
3275
|
+
this.#streamingEditToolCallStates.set(toolCall.id, state);
|
|
3276
|
+
} else {
|
|
3277
|
+
state.op = op;
|
|
3278
|
+
state.resolvedPath = resolvedPath;
|
|
3279
|
+
}
|
|
3280
|
+
state.debugGuardRuns += 1;
|
|
3281
|
+
this.streamingEditDebugCounters.guardRuns += 1;
|
|
3282
|
+
|
|
3283
|
+
if (op && op !== "update") {
|
|
3284
|
+
state.settledVerdict = "non-update";
|
|
3285
|
+
return;
|
|
3286
|
+
}
|
|
2977
3287
|
if (!diff) return;
|
|
2978
|
-
if (op && op !== "update") return;
|
|
2979
3288
|
|
|
2980
|
-
if (!diff.includes("\n")) return;
|
|
2981
3289
|
const lastNewlineIndex = diff.lastIndexOf("\n");
|
|
2982
3290
|
if (lastNewlineIndex < 0) return;
|
|
2983
|
-
const
|
|
2984
|
-
if (
|
|
3291
|
+
const completeDiff = diff.slice(0, lastNewlineIndex + 1);
|
|
3292
|
+
if (completeDiff.trim().length === 0) return;
|
|
3293
|
+
|
|
3294
|
+
let diffForCheck = completeDiff;
|
|
3295
|
+
let fullCheck = false;
|
|
3296
|
+
// Obfuscated diffs are intentionally checked through the full path because
|
|
3297
|
+
// deobfuscation is not proven chunk-composable across streaming deltas.
|
|
3298
|
+
if (this.#obfuscator) {
|
|
3299
|
+
fullCheck = true;
|
|
3300
|
+
} else if (completeDiff.length < state.lastProcessedOffset || !completeDiff.startsWith(state.processedPrefix)) {
|
|
3301
|
+
fullCheck = true;
|
|
3302
|
+
} else {
|
|
3303
|
+
diffForCheck = completeDiff.slice(state.lastProcessedOffset);
|
|
3304
|
+
}
|
|
3305
|
+
if (!diffForCheck) return;
|
|
2985
3306
|
|
|
2986
3307
|
let normalizedDiff = normalizeDiff(diffForCheck.replace(/\r/g, ""));
|
|
2987
3308
|
if (!normalizedDiff) return;
|
|
2988
|
-
// Deobfuscate the diff so removed lines match real file content
|
|
2989
3309
|
if (this.#obfuscator) normalizedDiff = this.#obfuscator.deobfuscate(normalizedDiff);
|
|
2990
3310
|
if (!normalizedDiff) return;
|
|
2991
3311
|
const lines = normalizedDiff.split("\n");
|
|
2992
3312
|
const hasChangeLine = lines.some(line => line.startsWith("+") || line.startsWith("-"));
|
|
2993
|
-
if (!hasChangeLine)
|
|
3313
|
+
if (!hasChangeLine) {
|
|
3314
|
+
if (!fullCheck) {
|
|
3315
|
+
state.lastProcessedOffset = completeDiff.length;
|
|
3316
|
+
state.processedPrefix = completeDiff;
|
|
3317
|
+
}
|
|
3318
|
+
return;
|
|
3319
|
+
}
|
|
3320
|
+
|
|
3321
|
+
if (fullCheck) {
|
|
3322
|
+
state.debugFullChecks += 1;
|
|
3323
|
+
this.streamingEditDebugCounters.fullChecks += 1;
|
|
3324
|
+
}
|
|
3325
|
+
state.debugProcessedChars += diffForCheck.length;
|
|
3326
|
+
this.streamingEditDebugCounters.processedChars += diffForCheck.length;
|
|
2994
3327
|
|
|
2995
3328
|
const lineCount = lines.length;
|
|
2996
|
-
const lastChecked = this.#streamingEditCheckedLineCounts.get(toolCall.id);
|
|
2997
|
-
if (lastChecked !== undefined && lineCount <= lastChecked) return;
|
|
2998
3329
|
this.#streamingEditCheckedLineCounts.set(toolCall.id, lineCount);
|
|
2999
3330
|
|
|
3000
3331
|
const removedLines = lines
|
|
3001
3332
|
.filter(line => line.startsWith("-") && !line.startsWith("--- "))
|
|
3002
3333
|
.map(line => line.slice(1));
|
|
3334
|
+
state.debugCheckedRemovedLines += removedLines.length;
|
|
3335
|
+
this.streamingEditDebugCounters.checkedRemovedLines += removedLines.length;
|
|
3336
|
+
if (!fullCheck) {
|
|
3337
|
+
state.lastProcessedOffset = completeDiff.length;
|
|
3338
|
+
state.processedPrefix = completeDiff;
|
|
3339
|
+
} else if (!this.#obfuscator) {
|
|
3340
|
+
state.lastProcessedOffset = completeDiff.length;
|
|
3341
|
+
state.processedPrefix = completeDiff;
|
|
3342
|
+
}
|
|
3343
|
+
|
|
3003
3344
|
if (removedLines.length > 0) {
|
|
3004
3345
|
let cachedContent = this.#streamingEditFileCache.get(resolvedPath);
|
|
3005
3346
|
if (cachedContent === undefined) {
|
|
@@ -3010,6 +3351,7 @@ export class AgentSession {
|
|
|
3010
3351
|
const missing = removedLines.find(line => !cachedContent.includes(normalizeToLF(line)));
|
|
3011
3352
|
if (missing) {
|
|
3012
3353
|
this.#streamingEditAbortTriggered = true;
|
|
3354
|
+
state.settledVerdict = "aborted";
|
|
3013
3355
|
logger.warn("Streaming edit aborted due to patch preview failure", {
|
|
3014
3356
|
toolCallId: toolCall.id,
|
|
3015
3357
|
path,
|
|
@@ -3089,12 +3431,21 @@ export class AgentSession {
|
|
|
3089
3431
|
}
|
|
3090
3432
|
}
|
|
3091
3433
|
|
|
3434
|
+
#requestWorkerIntegrationAttempt(): void {
|
|
3435
|
+
this.#workerIntegrationScheduler.enqueue();
|
|
3436
|
+
}
|
|
3437
|
+
|
|
3438
|
+
async #flushWorkerIntegrationAttempt(): Promise<void> {
|
|
3439
|
+
await this.#workerIntegrationScheduler.flush();
|
|
3440
|
+
}
|
|
3441
|
+
|
|
3092
3442
|
/** Emit extension events based on session events */
|
|
3093
3443
|
async #emitExtensionEvent(event: AgentSessionEvent): Promise<void> {
|
|
3094
3444
|
if (event.type === "turn_end") {
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3445
|
+
this.#requestWorkerIntegrationAttempt();
|
|
3446
|
+
}
|
|
3447
|
+
if (event.type === "agent_end") {
|
|
3448
|
+
await this.#flushWorkerIntegrationAttempt();
|
|
3098
3449
|
}
|
|
3099
3450
|
if (!this.#extensionRunner) return;
|
|
3100
3451
|
if (event.type === "agent_start") {
|
|
@@ -3207,11 +3558,15 @@ export class AgentSession {
|
|
|
3207
3558
|
maxAttempts: event.maxAttempts,
|
|
3208
3559
|
});
|
|
3209
3560
|
} else if (event.type === "goal_updated") {
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3561
|
+
try {
|
|
3562
|
+
await this.#extensionRunner.emit({
|
|
3563
|
+
type: "goal_updated",
|
|
3564
|
+
goal: event.goal,
|
|
3565
|
+
state: event.state,
|
|
3566
|
+
});
|
|
3567
|
+
} catch (error) {
|
|
3568
|
+
logger.warn("Goal updated extension hook failed", { error: String(error) });
|
|
3569
|
+
}
|
|
3215
3570
|
}
|
|
3216
3571
|
}
|
|
3217
3572
|
|
|
@@ -3222,12 +3577,14 @@ export class AgentSession {
|
|
|
3222
3577
|
*/
|
|
3223
3578
|
subscribe(listener: AgentSessionEventListener): () => void {
|
|
3224
3579
|
this.#eventListeners.push(listener);
|
|
3580
|
+
this.#rebuildEventListenerSnapshot();
|
|
3225
3581
|
|
|
3226
3582
|
// Return unsubscribe function for this specific listener
|
|
3227
3583
|
return () => {
|
|
3228
3584
|
const index = this.#eventListeners.indexOf(listener);
|
|
3229
3585
|
if (index !== -1) {
|
|
3230
3586
|
this.#eventListeners.splice(index, 1);
|
|
3587
|
+
this.#rebuildEventListenerSnapshot();
|
|
3231
3588
|
}
|
|
3232
3589
|
};
|
|
3233
3590
|
}
|
|
@@ -3304,6 +3661,7 @@ export class AgentSession {
|
|
|
3304
3661
|
} catch (error) {
|
|
3305
3662
|
logger.warn("Failed to emit session_shutdown event", { error: String(error) });
|
|
3306
3663
|
}
|
|
3664
|
+
await this.#flushWorkerIntegrationAttempt();
|
|
3307
3665
|
await this.#cancelPostPromptTasks();
|
|
3308
3666
|
// Cancel jobs this agent registered so a subagent's teardown doesn't
|
|
3309
3667
|
// leak its background bash/task work into the parent's manager. Only
|
|
@@ -3339,6 +3697,8 @@ export class AgentSession {
|
|
|
3339
3697
|
// No-op when this session opened no tabs. Failure is logged, not thrown.
|
|
3340
3698
|
this.#unregisterResourceGc?.();
|
|
3341
3699
|
this.#unregisterResourceGc = undefined;
|
|
3700
|
+
this.#unregisterRuntimeStateFinalizer?.();
|
|
3701
|
+
this.#unregisterRuntimeStateFinalizer = undefined;
|
|
3342
3702
|
await releaseTabsForOwner(this.sessionManager.getSessionId()).catch((error: unknown) =>
|
|
3343
3703
|
logger.warn("session dispose: releaseTabsForOwner failed", { error }),
|
|
3344
3704
|
);
|
|
@@ -3362,6 +3722,7 @@ export class AgentSession {
|
|
|
3362
3722
|
this.#unsubscribeAppendOnly = undefined;
|
|
3363
3723
|
}
|
|
3364
3724
|
this.#eventListeners = [];
|
|
3725
|
+
this.#rebuildEventListenerSnapshot();
|
|
3365
3726
|
}
|
|
3366
3727
|
|
|
3367
3728
|
/**
|
|
@@ -3895,7 +4256,7 @@ export class AgentSession {
|
|
|
3895
4256
|
* prompts or tool execution can run.
|
|
3896
4257
|
*/
|
|
3897
4258
|
#wrapToolForDeepInterviewMutationGuard<T extends AgentTool>(tool: T): T {
|
|
3898
|
-
if (!["edit", "write", "ast_edit"].includes(tool.name)) return tool;
|
|
4259
|
+
if (!["edit", "write", "ast_edit", "bash"].includes(tool.name)) return tool;
|
|
3899
4260
|
return new Proxy(tool, {
|
|
3900
4261
|
get: (target, prop) => {
|
|
3901
4262
|
if (prop !== "execute") return Reflect.get(target, prop, target);
|
|
@@ -3918,10 +4279,42 @@ export class AgentSession {
|
|
|
3918
4279
|
}) as T;
|
|
3919
4280
|
}
|
|
3920
4281
|
|
|
4282
|
+
#guardedToolWrapperCacheKey(): string {
|
|
4283
|
+
const bridge = this.#clientBridge;
|
|
4284
|
+
const acpEnabled = Boolean(bridge?.capabilities.requestPermission && bridge.requestPermission);
|
|
4285
|
+
const activeSkill = this.#activeSkillState?.skill ?? "";
|
|
4286
|
+
const activeSkillSession = this.#activeSkillState?.sessionId ?? "";
|
|
4287
|
+
return [
|
|
4288
|
+
"deep-interview-mutation-v1",
|
|
4289
|
+
"ultragoal-ask-v1",
|
|
4290
|
+
`active=${activeSkill}:${activeSkillSession}`,
|
|
4291
|
+
`acp=${acpEnabled ? "on" : "off"}:${this.#acpPermissionWrapperVersion}`,
|
|
4292
|
+
].join("|");
|
|
4293
|
+
}
|
|
4294
|
+
|
|
3921
4295
|
#prepareToolForExecution<T extends AgentTool>(tool: T): T {
|
|
3922
|
-
|
|
3923
|
-
|
|
4296
|
+
const cacheKey = this.#guardedToolWrapperCacheKey();
|
|
4297
|
+
let wrappersByVersion = this.#guardedToolWrapperCache.get(tool);
|
|
4298
|
+
const cached = wrappersByVersion?.get(cacheKey);
|
|
4299
|
+
if (cached) return cached as T;
|
|
4300
|
+
const wrapped = this.#wrapToolForDeepInterviewMutationGuard(
|
|
4301
|
+
this.#wrapToolForAcpPermission(
|
|
4302
|
+
guardToolForUltragoalAsk(
|
|
4303
|
+
tool,
|
|
4304
|
+
() => this.sessionManager.getCwd(),
|
|
4305
|
+
() => ({
|
|
4306
|
+
activeSkillState: this.getActiveSkillState(),
|
|
4307
|
+
sessionId: this.sessionManager.getSessionId(),
|
|
4308
|
+
}),
|
|
4309
|
+
),
|
|
4310
|
+
),
|
|
3924
4311
|
);
|
|
4312
|
+
if (!wrappersByVersion) {
|
|
4313
|
+
wrappersByVersion = new Map();
|
|
4314
|
+
this.#guardedToolWrapperCache.set(tool, wrappersByVersion);
|
|
4315
|
+
}
|
|
4316
|
+
wrappersByVersion.set(cacheKey, wrapped);
|
|
4317
|
+
return wrapped;
|
|
3925
4318
|
}
|
|
3926
4319
|
|
|
3927
4320
|
#setGuardedAgentTools(tools: AgentTool[]): void {
|
|
@@ -4116,11 +4509,15 @@ export class AgentSession {
|
|
|
4116
4509
|
* For everything else, callers must explicitly call `refreshBaseSystemPrompt()`
|
|
4117
4510
|
* after side-effecting changes; see e.g. the memory hooks and
|
|
4118
4511
|
* `#syncEditToolModeAfterModelChange`.
|
|
4119
|
-
*
|
|
4120
|
-
*
|
|
4121
|
-
*
|
|
4122
|
-
*
|
|
4123
|
-
*
|
|
4512
|
+
* Volatile per-turn facts (current date, cwd, and mtime-sorted workspace tree
|
|
4513
|
+
* RENDERING) are intentionally NOT covered. They are delivered as user-role
|
|
4514
|
+
* context by `#buildVolatileProjectContextMessage()`, outside the provider
|
|
4515
|
+
* cached system prefix, so rollover/touched-file changes must not force a
|
|
4516
|
+
* stable prompt rebuild. Note the AGENTS.md file LIST (`agentsMdFiles`, sorted
|
|
4517
|
+
* by name) surfaced by the same workspace scan is still a stable-prefix input
|
|
4518
|
+
* via project-prompt's `<dir-context>`; adding/removing an AGENTS.md is an
|
|
4519
|
+
* intended instruction change, and name-sorting means touched files do not
|
|
4520
|
+
* perturb it.
|
|
4124
4521
|
*/
|
|
4125
4522
|
#computeAppliedToolSignature(toolNames: string[], tools: AgentTool[]): string {
|
|
4126
4523
|
// Order-preserving join: any reorder must produce a different signature so
|
|
@@ -4151,8 +4548,7 @@ export class AgentSession {
|
|
|
4151
4548
|
entries.sort();
|
|
4152
4549
|
instructionsSegment = entries.join("\u0006");
|
|
4153
4550
|
}
|
|
4154
|
-
|
|
4155
|
-
return `${nameSegment}\u0003${descriptionSegment}\u0005${registrySegment}\u0007${instructionsSegment}|${date}`;
|
|
4551
|
+
return `${nameSegment}\u0003${descriptionSegment}\u0005${registrySegment}\u0007${instructionsSegment}`;
|
|
4156
4552
|
}
|
|
4157
4553
|
|
|
4158
4554
|
/**
|
|
@@ -4578,6 +4974,7 @@ export class AgentSession {
|
|
|
4578
4974
|
setClientBridge(bridge: ClientBridge | undefined): void {
|
|
4579
4975
|
this.#clientBridge = bridge;
|
|
4580
4976
|
this.#acpPermissionDecisions.clear();
|
|
4977
|
+
this.#acpPermissionWrapperVersion++;
|
|
4581
4978
|
const activeToolNames = this.getActiveToolNames();
|
|
4582
4979
|
const activeTools = activeToolNames
|
|
4583
4980
|
.map(name => this.#toolRegistry.get(name))
|
|
@@ -4772,6 +5169,94 @@ export class AgentSession {
|
|
|
4772
5169
|
};
|
|
4773
5170
|
}
|
|
4774
5171
|
|
|
5172
|
+
async #buildAutomaticPlanModeMessage(): Promise<CustomMessage | null> {
|
|
5173
|
+
const state = this.#planModeState;
|
|
5174
|
+
if (!state?.enabled) {
|
|
5175
|
+
this.#lastInjectedPlanContextSig = undefined;
|
|
5176
|
+
return null;
|
|
5177
|
+
}
|
|
5178
|
+
const message = await this.#buildPlanModeMessage();
|
|
5179
|
+
if (!message) {
|
|
5180
|
+
this.#lastInjectedPlanContextSig = undefined;
|
|
5181
|
+
return null;
|
|
5182
|
+
}
|
|
5183
|
+
const content = typeof message.content === "string" ? message.content : "";
|
|
5184
|
+
const signature = buildContextInjectionSignature("plan-mode-context", [
|
|
5185
|
+
"enabled",
|
|
5186
|
+
state.planFilePath,
|
|
5187
|
+
state.workflow ?? "",
|
|
5188
|
+
content,
|
|
5189
|
+
]);
|
|
5190
|
+
if (signature === this.#lastInjectedPlanContextSig) return null;
|
|
5191
|
+
this.#lastInjectedPlanContextSig = signature;
|
|
5192
|
+
return message;
|
|
5193
|
+
}
|
|
5194
|
+
|
|
5195
|
+
#buildAutomaticGoalModeMessage(): CustomMessage | null {
|
|
5196
|
+
const state = this.#goalModeState;
|
|
5197
|
+
if (!state?.enabled || state.goal.status !== "active") {
|
|
5198
|
+
this.#lastInjectedGoalContextSig = undefined;
|
|
5199
|
+
return null;
|
|
5200
|
+
}
|
|
5201
|
+
const message = this.#buildGoalModeMessage();
|
|
5202
|
+
if (!message) {
|
|
5203
|
+
this.#lastInjectedGoalContextSig = undefined;
|
|
5204
|
+
return null;
|
|
5205
|
+
}
|
|
5206
|
+
const content = typeof message.content === "string" ? message.content : "";
|
|
5207
|
+
const signature = buildContextInjectionSignature("goal-mode-context", ["enabled", state.goal.id, content]);
|
|
5208
|
+
if (signature === this.#lastInjectedGoalContextSig) return null;
|
|
5209
|
+
this.#lastInjectedGoalContextSig = signature;
|
|
5210
|
+
return message;
|
|
5211
|
+
}
|
|
5212
|
+
|
|
5213
|
+
/**
|
|
5214
|
+
* Clear the goal/plan static-once injection signatures so the next prompt
|
|
5215
|
+
* re-injects the active mode context once. MUST be called whenever the live
|
|
5216
|
+
* message set is rebuilt in a way that can evict a previously injected
|
|
5217
|
+
* goal-mode-context/plan-mode-context copy (compaction/pruning/handoff
|
|
5218
|
+
* replaceMessages) or when a signature was consumed but the message was not
|
|
5219
|
+
* delivered (prompt-generation abort). Forward-omission relies on the injected
|
|
5220
|
+
* copy surviving in context; this guards that invariant.
|
|
5221
|
+
*/
|
|
5222
|
+
#resetInjectedContextSignatures(): void {
|
|
5223
|
+
this.#lastInjectedPlanContextSig = undefined;
|
|
5224
|
+
this.#lastInjectedGoalContextSig = undefined;
|
|
5225
|
+
}
|
|
5226
|
+
|
|
5227
|
+
async #buildVolatileProjectContextMessage(): Promise<CustomMessage> {
|
|
5228
|
+
const cwd = this.sessionManager.getCwd();
|
|
5229
|
+
// Date + cwd are refreshed every turn (cheap). The mtime-sorted workspace
|
|
5230
|
+
// tree is expensive to scan and large to carry, so throttle it: rebuild at
|
|
5231
|
+
// most once per VOLATILE_TREE_TTL_MS and only embed the tree block on turns
|
|
5232
|
+
// where the scan actually refreshed. This bounds both the per-turn IO cost
|
|
5233
|
+
// and the accumulation of stale tree copies in history, while keeping the
|
|
5234
|
+
// content outside the cached system prefix.
|
|
5235
|
+
let includeTree: WorkspaceTree | undefined;
|
|
5236
|
+
if (this.#initialWorkspaceTree) {
|
|
5237
|
+
this.#cachedWorkspaceTree = this.#initialWorkspaceTree;
|
|
5238
|
+
this.#cachedWorkspaceTreeAt = Date.now();
|
|
5239
|
+
this.#initialWorkspaceTree = undefined;
|
|
5240
|
+
includeTree = this.#cachedWorkspaceTree;
|
|
5241
|
+
} else if (Date.now() - this.#cachedWorkspaceTreeAt >= VOLATILE_TREE_TTL_MS) {
|
|
5242
|
+
try {
|
|
5243
|
+
this.#cachedWorkspaceTree = await buildWorkspaceTree(cwd, { timeoutMs: 5000 });
|
|
5244
|
+
} catch {
|
|
5245
|
+
this.#cachedWorkspaceTree = undefined;
|
|
5246
|
+
}
|
|
5247
|
+
this.#cachedWorkspaceTreeAt = Date.now();
|
|
5248
|
+
includeTree = this.#cachedWorkspaceTree;
|
|
5249
|
+
}
|
|
5250
|
+
return {
|
|
5251
|
+
role: "custom",
|
|
5252
|
+
customType: "volatile-project-context",
|
|
5253
|
+
content: buildVolatileProjectContext({ cwd, workspaceTree: includeTree }),
|
|
5254
|
+
display: false,
|
|
5255
|
+
attribution: "agent",
|
|
5256
|
+
timestamp: Date.now(),
|
|
5257
|
+
};
|
|
5258
|
+
}
|
|
5259
|
+
|
|
4775
5260
|
/**
|
|
4776
5261
|
* Send a prompt to the agent.
|
|
4777
5262
|
* - Handles extension commands (registered via pi.registerCommand) immediately, even during streaming
|
|
@@ -4809,6 +5294,7 @@ export class AgentSession {
|
|
|
4809
5294
|
|
|
4810
5295
|
// Expand file-based prompt templates if requested
|
|
4811
5296
|
const expandedText = expandPromptTemplates ? expandPromptTemplate(text, [...this.#promptTemplates]) : text;
|
|
5297
|
+
const workflowIntentDiff = options?.synthetic ? null : buildWorkflowIntentDiff(expandedText);
|
|
4812
5298
|
|
|
4813
5299
|
// If streaming, queue via steer() or followUp() based on option
|
|
4814
5300
|
if (this.isStreaming) {
|
|
@@ -4820,9 +5306,16 @@ export class AgentSession {
|
|
|
4820
5306
|
} else {
|
|
4821
5307
|
await this.#queueSteer(expandedText, options?.images);
|
|
4822
5308
|
}
|
|
5309
|
+
if (workflowIntentDiff) {
|
|
5310
|
+
this.sessionManager.appendCustomEntry(WORKFLOW_INTENT_DIFF_CUSTOM_TYPE, workflowIntentDiff);
|
|
5311
|
+
}
|
|
4823
5312
|
return;
|
|
4824
5313
|
}
|
|
4825
5314
|
|
|
5315
|
+
if (workflowIntentDiff) {
|
|
5316
|
+
this.sessionManager.appendCustomEntry(WORKFLOW_INTENT_DIFF_CUSTOM_TYPE, workflowIntentDiff);
|
|
5317
|
+
}
|
|
5318
|
+
|
|
4826
5319
|
// Skip eager todo prelude when the user has already queued a directive
|
|
4827
5320
|
const hasPendingUserDirective = this.#toolChoiceQueue.inspect().includes("user-force");
|
|
4828
5321
|
const eagerTodoPrelude =
|
|
@@ -5014,14 +5507,16 @@ export class AgentSession {
|
|
|
5014
5507
|
if (planReferenceMessage) {
|
|
5015
5508
|
messages.push(planReferenceMessage);
|
|
5016
5509
|
}
|
|
5017
|
-
const planModeMessage = await this.#
|
|
5510
|
+
const planModeMessage = await this.#buildAutomaticPlanModeMessage();
|
|
5018
5511
|
if (planModeMessage) {
|
|
5019
5512
|
messages.push(planModeMessage);
|
|
5020
5513
|
}
|
|
5021
|
-
const goalModeMessage = this.#
|
|
5514
|
+
const goalModeMessage = this.#buildAutomaticGoalModeMessage();
|
|
5022
5515
|
if (goalModeMessage) {
|
|
5023
5516
|
messages.push(goalModeMessage);
|
|
5024
5517
|
}
|
|
5518
|
+
const volatileProjectContextMessage = await this.#buildVolatileProjectContextMessage();
|
|
5519
|
+
messages.push(volatileProjectContextMessage);
|
|
5025
5520
|
if (options?.prependMessages) {
|
|
5026
5521
|
messages.push(...options.prependMessages);
|
|
5027
5522
|
}
|
|
@@ -5031,6 +5526,7 @@ export class AgentSession {
|
|
|
5031
5526
|
// Early bail-out: if a newer abort/prompt cycle started during setup,
|
|
5032
5527
|
// return before mutating shared state (nextTurn messages, system prompt).
|
|
5033
5528
|
if (this.#promptGeneration !== generation) {
|
|
5529
|
+
this.#resetInjectedContextSignatures();
|
|
5034
5530
|
return;
|
|
5035
5531
|
}
|
|
5036
5532
|
|
|
@@ -5043,9 +5539,28 @@ export class AgentSession {
|
|
|
5043
5539
|
// Auto-read @filepath mentions
|
|
5044
5540
|
const fileMentions = extractFileMentions(expandedText);
|
|
5045
5541
|
if (fileMentions.length > 0) {
|
|
5046
|
-
const
|
|
5542
|
+
const cwd = this.sessionManager.getCwd();
|
|
5543
|
+
// Collect resolved paths already shown (read or mentioned) in the recent
|
|
5544
|
+
// window so a repeat @mention emits a compact note instead of the full body.
|
|
5545
|
+
const RECENT_MENTION_WINDOW = 40;
|
|
5546
|
+
const recentlyShownPaths = new Set<string>();
|
|
5547
|
+
for (const entry of this.sessionManager.getBranch().slice(-RECENT_MENTION_WINDOW)) {
|
|
5548
|
+
if (entry.type !== "message") continue;
|
|
5549
|
+
const msg = entry.message;
|
|
5550
|
+
if (msg.role === "fileMention") {
|
|
5551
|
+
for (const file of msg.files) {
|
|
5552
|
+
if (!file.duplicate && !file.pruned) recentlyShownPaths.add(resolveReadPath(file.path, cwd));
|
|
5553
|
+
}
|
|
5554
|
+
} else if (msg.role === "toolResult") {
|
|
5555
|
+
const resolved = (msg.details as { resolvedPath?: unknown } | undefined)?.resolvedPath;
|
|
5556
|
+
if (typeof resolved === "string" && resolved) recentlyShownPaths.add(resolveReadPath(resolved, cwd));
|
|
5557
|
+
}
|
|
5558
|
+
}
|
|
5559
|
+
const fileMentionMessages = await generateFileMentionMessages(fileMentions, cwd, {
|
|
5047
5560
|
autoResizeImages: this.settings.get("images.autoResize"),
|
|
5048
5561
|
useHashLines: resolveFileDisplayMode(this).hashLines,
|
|
5562
|
+
maxInlineBytes: this.settings.get("tools.fileMentionInlineBytes") * 1024,
|
|
5563
|
+
recentlyShownPaths,
|
|
5049
5564
|
});
|
|
5050
5565
|
messages.push(...fileMentionMessages);
|
|
5051
5566
|
}
|
|
@@ -5095,8 +5610,12 @@ export class AgentSession {
|
|
|
5095
5610
|
this.#appendBeforeAgentStartCustomMessages(messages, contributed, promptAttribution, message.role);
|
|
5096
5611
|
}
|
|
5097
5612
|
|
|
5098
|
-
// Bail out if a newer abort/prompt cycle has started since we began setup
|
|
5613
|
+
// Bail out if a newer abort/prompt cycle has started since we began setup.
|
|
5614
|
+
// The injection signatures were consumed while building the automatic
|
|
5615
|
+
// goal/plan context above, but the message is not delivered on this
|
|
5616
|
+
// aborted turn, so reset them here so the next real turn re-injects once.
|
|
5099
5617
|
if (this.#promptGeneration !== generation) {
|
|
5618
|
+
this.#resetInjectedContextSignatures();
|
|
5100
5619
|
return;
|
|
5101
5620
|
}
|
|
5102
5621
|
|
|
@@ -5276,7 +5795,7 @@ export class AgentSession {
|
|
|
5276
5795
|
*/
|
|
5277
5796
|
async #queueSteer(text: string, images?: ImageContent[]): Promise<void> {
|
|
5278
5797
|
const displayText = text || (images && images.length > 0 ? "[Image]" : "");
|
|
5279
|
-
this.#steeringMessages.push(
|
|
5798
|
+
this.#steeringMessages.push(this.#createQueuedDisplayEntry(displayText));
|
|
5280
5799
|
const content: (TextContent | ImageContent)[] = [{ type: "text", text }];
|
|
5281
5800
|
if (images && images.length > 0) {
|
|
5282
5801
|
content.push(...images);
|
|
@@ -5307,7 +5826,7 @@ export class AgentSession {
|
|
|
5307
5826
|
*/
|
|
5308
5827
|
async #queueFollowUp(text: string, images?: ImageContent[]): Promise<void> {
|
|
5309
5828
|
const displayText = text || (images && images.length > 0 ? "[Image]" : "");
|
|
5310
|
-
this.#followUpMessages.push(
|
|
5829
|
+
this.#followUpMessages.push(this.#createQueuedDisplayEntry(displayText));
|
|
5311
5830
|
const content: (TextContent | ImageContent)[] = [{ type: "text", text }];
|
|
5312
5831
|
if (images && images.length > 0) {
|
|
5313
5832
|
content.push(...images);
|
|
@@ -5676,25 +6195,90 @@ export class AgentSession {
|
|
|
5676
6195
|
};
|
|
5677
6196
|
}
|
|
5678
6197
|
|
|
6198
|
+
getQueuedMessageEntries(): QueuedMessageEditEntry[] {
|
|
6199
|
+
const entries: QueuedMessageEditEntry[] = [];
|
|
6200
|
+
for (const entry of this.#steeringMessages) {
|
|
6201
|
+
entries.push({
|
|
6202
|
+
id: this.#queuedMessageEditId("steer", entry.sequence),
|
|
6203
|
+
text: entry.text,
|
|
6204
|
+
mode: "steer",
|
|
6205
|
+
label: "Steer",
|
|
6206
|
+
});
|
|
6207
|
+
}
|
|
6208
|
+
for (const entry of this.#followUpMessages) {
|
|
6209
|
+
entries.push({
|
|
6210
|
+
id: this.#queuedMessageEditId("followUp", entry.sequence),
|
|
6211
|
+
text: entry.text,
|
|
6212
|
+
mode: "followUp",
|
|
6213
|
+
label: "Queued",
|
|
6214
|
+
});
|
|
6215
|
+
}
|
|
6216
|
+
return entries;
|
|
6217
|
+
}
|
|
6218
|
+
|
|
6219
|
+
removeQueuedMessageForEditing(id: string): string | undefined {
|
|
6220
|
+
const [mode, sequenceText] = id.split(":");
|
|
6221
|
+
if ((mode !== "steer" && mode !== "followUp") || sequenceText === undefined) return undefined;
|
|
6222
|
+
const sequence = Number(sequenceText);
|
|
6223
|
+
if (!Number.isInteger(sequence)) return undefined;
|
|
6224
|
+
|
|
6225
|
+
const queue = mode === "steer" ? this.#steeringMessages : this.#followUpMessages;
|
|
6226
|
+
const index = queue.findIndex(entry => entry.sequence === sequence);
|
|
6227
|
+
if (index === -1) return undefined;
|
|
6228
|
+
|
|
6229
|
+
const [entry] = queue.splice(index, 1);
|
|
6230
|
+
if (mode === "steer") {
|
|
6231
|
+
this.agent.removeSteerAt(index);
|
|
6232
|
+
} else {
|
|
6233
|
+
this.agent.removeFollowUpAt(index);
|
|
6234
|
+
}
|
|
6235
|
+
return entry?.text;
|
|
6236
|
+
}
|
|
6237
|
+
|
|
6238
|
+
moveQueuedMessageForEditing(id: string, direction: "up" | "down"): boolean {
|
|
6239
|
+
const [mode, sequenceText] = id.split(":");
|
|
6240
|
+
if ((mode !== "steer" && mode !== "followUp") || sequenceText === undefined) return false;
|
|
6241
|
+
const sequence = Number(sequenceText);
|
|
6242
|
+
if (!Number.isInteger(sequence)) return false;
|
|
6243
|
+
|
|
6244
|
+
const queue = mode === "steer" ? this.#steeringMessages : this.#followUpMessages;
|
|
6245
|
+
const fromIndex = queue.findIndex(entry => entry.sequence === sequence);
|
|
6246
|
+
if (fromIndex === -1) return false;
|
|
6247
|
+
const toIndex = direction === "up" ? fromIndex - 1 : fromIndex + 1;
|
|
6248
|
+
const agentMoved =
|
|
6249
|
+
mode === "steer" ? this.agent.moveSteer(fromIndex, toIndex) : this.agent.moveFollowUp(fromIndex, toIndex);
|
|
6250
|
+
if (!agentMoved) return false;
|
|
6251
|
+
return this.#moveQueuedDisplayEntry(queue, fromIndex, toIndex);
|
|
6252
|
+
}
|
|
6253
|
+
|
|
6254
|
+
#moveQueuedDisplayEntry(queue: QueuedDisplayEntry[], fromIndex: number, toIndex: number): boolean {
|
|
6255
|
+
if (fromIndex < 0 || fromIndex >= queue.length) return false;
|
|
6256
|
+
if (toIndex < 0 || toIndex >= queue.length) return false;
|
|
6257
|
+
if (fromIndex === toIndex) return true;
|
|
6258
|
+
const [entry] = queue.splice(fromIndex, 1);
|
|
6259
|
+
if (!entry) return false;
|
|
6260
|
+
queue.splice(toIndex, 0, entry);
|
|
6261
|
+
return true;
|
|
6262
|
+
}
|
|
6263
|
+
|
|
5679
6264
|
/**
|
|
5680
|
-
* Pop the
|
|
6265
|
+
* Pop the newest queued message across steering and follow-up queues.
|
|
5681
6266
|
* Used by dequeue keybinding to restore messages to editor one at a time.
|
|
5682
6267
|
* Returns the popped entry's `.text`; the tag (if any) dies with the
|
|
5683
6268
|
* record — no orphan state can outlive the queue entry.
|
|
5684
6269
|
*/
|
|
5685
6270
|
popLastQueuedMessage(): string | undefined {
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
|
|
5690
|
-
return
|
|
5691
|
-
}
|
|
5692
|
-
// Then from follow-up
|
|
5693
|
-
if (this.#followUpMessages.length > 0) {
|
|
5694
|
-
const entry = this.#followUpMessages.pop();
|
|
5695
|
-
this.agent.popLastFollowUp();
|
|
5696
|
-
return entry?.text;
|
|
6271
|
+
const steeringEntry = this.#steeringMessages.at(-1);
|
|
6272
|
+
const followUpEntry = this.#followUpMessages.at(-1);
|
|
6273
|
+
|
|
6274
|
+
if (steeringEntry && (!followUpEntry || steeringEntry.sequence > followUpEntry.sequence)) {
|
|
6275
|
+
return this.removeQueuedMessageForEditing(this.#queuedMessageEditId("steer", steeringEntry.sequence));
|
|
5697
6276
|
}
|
|
6277
|
+
|
|
6278
|
+
if (followUpEntry) {
|
|
6279
|
+
return this.removeQueuedMessageForEditing(this.#queuedMessageEditId("followUp", followUpEntry.sequence));
|
|
6280
|
+
}
|
|
6281
|
+
|
|
5698
6282
|
return undefined;
|
|
5699
6283
|
}
|
|
5700
6284
|
|
|
@@ -5739,6 +6323,9 @@ export class AgentSession {
|
|
|
5739
6323
|
if (eviction.evictedEntries > 0) await this.sessionManager.rewriteEntries();
|
|
5740
6324
|
const sessionContext = this.buildDisplaySessionContext();
|
|
5741
6325
|
this.agent.replaceMessages(sessionContext.messages);
|
|
6326
|
+
// Compaction can evict a previously injected goal/plan-mode-context copy from
|
|
6327
|
+
// live context; clear the static-once signatures so the next prompt re-injects.
|
|
6328
|
+
this.#resetInjectedContextSignatures();
|
|
5742
6329
|
this.#syncTodoPhasesFromBranch();
|
|
5743
6330
|
this.#closeCodexProviderSessionsForHistoryRewrite();
|
|
5744
6331
|
|
|
@@ -5957,6 +6544,41 @@ export class AgentSession {
|
|
|
5957
6544
|
return true;
|
|
5958
6545
|
}
|
|
5959
6546
|
|
|
6547
|
+
/**
|
|
6548
|
+
* Clear active conversational/model context while preserving the current
|
|
6549
|
+
* session identity and durable history trail.
|
|
6550
|
+
*/
|
|
6551
|
+
async clearContext(): Promise<boolean> {
|
|
6552
|
+
const sessionId = this.sessionId;
|
|
6553
|
+
this.#disconnectFromAgent();
|
|
6554
|
+
await this.abort();
|
|
6555
|
+
this.#cancelOwnAsyncJobs();
|
|
6556
|
+
this.#suppressOwnAsyncJobDeliveries();
|
|
6557
|
+
this.yieldQueue.clear();
|
|
6558
|
+
this.#pendingBackgroundExchanges = [];
|
|
6559
|
+
this.#closeAllProviderSessions("context clear");
|
|
6560
|
+
this.agent.reset();
|
|
6561
|
+
await this.sessionManager.flush();
|
|
6562
|
+
this.sessionManager.appendContextClearEntry({ sessionId });
|
|
6563
|
+
this.setTodoPhases([]);
|
|
6564
|
+
this.#syncAgentSessionId(sessionId);
|
|
6565
|
+
this.#steeringMessages = [];
|
|
6566
|
+
this.#followUpMessages = [];
|
|
6567
|
+
this.#pendingNextTurnMessages = [];
|
|
6568
|
+
this.#scheduledHiddenNextTurnGeneration = undefined;
|
|
6569
|
+
|
|
6570
|
+
this.sessionManager.appendThinkingLevelChange(this.thinkingLevel);
|
|
6571
|
+
if (this.model) {
|
|
6572
|
+
this.sessionManager.appendModelChange(`${this.model.provider}/${this.model.id}`);
|
|
6573
|
+
}
|
|
6574
|
+
this.sessionManager.appendServiceTierChange(this.serviceTier ?? null);
|
|
6575
|
+
this.#todoReminderCount = 0;
|
|
6576
|
+
this.#planReferenceSent = false;
|
|
6577
|
+
this.#planReferencePath = "local://PLAN.md";
|
|
6578
|
+
this.#reconnectToAgent();
|
|
6579
|
+
return true;
|
|
6580
|
+
}
|
|
6581
|
+
|
|
5960
6582
|
/**
|
|
5961
6583
|
* Set a display name for the current session.
|
|
5962
6584
|
*/
|
|
@@ -6528,24 +7150,92 @@ export class AgentSession {
|
|
|
6528
7150
|
const branchEntries = this.sessionManager.getBranch();
|
|
6529
7151
|
const result = pruneToolOutputs(branchEntries, DEFAULT_PRUNE_CONFIG);
|
|
6530
7152
|
const argumentResult = pruneAssistantToolArguments(branchEntries, DEFAULT_PRUNE_CONFIG);
|
|
6531
|
-
const
|
|
6532
|
-
|
|
7153
|
+
const fileMentionResult = pruneStaleFileMentions(branchEntries, p =>
|
|
7154
|
+
resolveReadPath(p, this.sessionManager.getCwd()),
|
|
7155
|
+
);
|
|
7156
|
+
const tokensSaved =
|
|
7157
|
+
result.tokensSaved + argumentResult.argumentTokensSaved + Math.round(fileMentionResult.bytesSaved / 4);
|
|
7158
|
+
const prunedCount = result.prunedCount + argumentResult.argumentPrunedCount + fileMentionResult.changed.length;
|
|
6533
7159
|
if (prunedCount === 0) {
|
|
6534
7160
|
return undefined;
|
|
6535
7161
|
}
|
|
6536
7162
|
|
|
6537
7163
|
// getBranch() returns materialized copies for blob-externalized entries, so
|
|
6538
7164
|
// the pruning mutations must be written back into the canonical store.
|
|
6539
|
-
const combined = [...result.prunedEntries, ...argumentResult.prunedEntries];
|
|
7165
|
+
const combined = [...result.prunedEntries, ...argumentResult.prunedEntries, ...fileMentionResult.changed];
|
|
6540
7166
|
this.sessionManager.applyEntryMessageUpdates(combined);
|
|
6541
7167
|
await this.sessionManager.rewriteEntries();
|
|
6542
7168
|
const sessionContext = this.buildDisplaySessionContext();
|
|
6543
7169
|
this.agent.replaceMessages(sessionContext.messages);
|
|
7170
|
+
// Pruning can evict a previously injected goal/plan-mode-context copy; clear
|
|
7171
|
+
// the static-once signatures so the next prompt re-injects the mode context.
|
|
7172
|
+
this.#resetInjectedContextSignatures();
|
|
6544
7173
|
this.#syncTodoPhasesFromBranch();
|
|
6545
7174
|
this.#closeCodexProviderSessionsForHistoryRewrite();
|
|
6546
7175
|
return { prunedCount, tokensSaved };
|
|
6547
7176
|
}
|
|
6548
7177
|
|
|
7178
|
+
/**
|
|
7179
|
+
* Approximate cost of the prompt-cache-epoch reset that pruning forces:
|
|
7180
|
+
* pruning rewrites already-sent history, invalidating the provider's cached
|
|
7181
|
+
* prefix, so the next turn re-bills that prefix as fresh input. Use the cached
|
|
7182
|
+
* prefix tokens from the last provider usage as the reset-cost estimate.
|
|
7183
|
+
*/
|
|
7184
|
+
#lastCacheEpochResetCost(): number {
|
|
7185
|
+
const messages = this.messages;
|
|
7186
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
7187
|
+
const msg = messages[i];
|
|
7188
|
+
if (msg.role === "assistant" && (msg as AssistantMessage).usage) {
|
|
7189
|
+
const usage = (msg as AssistantMessage).usage;
|
|
7190
|
+
return (usage?.cacheRead ?? 0) + (usage?.cacheWrite ?? 0);
|
|
7191
|
+
}
|
|
7192
|
+
}
|
|
7193
|
+
return 0;
|
|
7194
|
+
}
|
|
7195
|
+
|
|
7196
|
+
/**
|
|
7197
|
+
* Evidence-gated below-threshold maintenance pruning (Finding 13). Runs
|
|
7198
|
+
* #pruneToolOutputs ONCE, below the compaction threshold, only when it is
|
|
7199
|
+
* opted in AND the estimated stale-prunable savings both clear a high minimum
|
|
7200
|
+
* and exceed the one-time cache-epoch reset cost (so remaining-turn savings pay
|
|
7201
|
+
* it back). Default-off/blocked until live evidence justifies enabling. Emits
|
|
7202
|
+
* explicit maintenance/reset telemetry.
|
|
7203
|
+
*/
|
|
7204
|
+
async #maybeRunBelowThresholdMaintenancePrune(): Promise<void> {
|
|
7205
|
+
const compactionSettings = this.settings.getGroup("compaction");
|
|
7206
|
+
if (!compactionSettings.maintenancePruningEnabled) return;
|
|
7207
|
+
|
|
7208
|
+
const estimate = estimateToolOutputPruneSavings(this.sessionManager.getBranch(), DEFAULT_PRUNE_CONFIG);
|
|
7209
|
+
const cacheEpochResetCost = this.#lastCacheEpochResetCost();
|
|
7210
|
+
if (
|
|
7211
|
+
!shouldRunMaintenancePrune({
|
|
7212
|
+
enabled: compactionSettings.maintenancePruningEnabled,
|
|
7213
|
+
estimatedSavings: estimate.tokensSaved,
|
|
7214
|
+
minSavings: compactionSettings.maintenancePruningMinSavingsTokens,
|
|
7215
|
+
cacheEpochResetCost,
|
|
7216
|
+
})
|
|
7217
|
+
) {
|
|
7218
|
+
return;
|
|
7219
|
+
}
|
|
7220
|
+
|
|
7221
|
+
const pruneResult = await this.#pruneToolOutputs();
|
|
7222
|
+
if (!pruneResult || pruneResult.prunedCount === 0) return;
|
|
7223
|
+
|
|
7224
|
+
const resetReason = `below-threshold maintenance: reclaimed ${pruneResult.tokensSaved} tokens > cache-epoch reset cost ${cacheEpochResetCost}`;
|
|
7225
|
+
await this.#emitSessionEvent({
|
|
7226
|
+
type: "notice",
|
|
7227
|
+
level: "info",
|
|
7228
|
+
source: "maintenance-prune",
|
|
7229
|
+
message: `Maintenance pruning reclaimed ${pruneResult.tokensSaved} tokens from ${pruneResult.prunedCount} stale tool outputs (${resetReason}).`,
|
|
7230
|
+
});
|
|
7231
|
+
logger.info("Below-threshold maintenance pruning ran", {
|
|
7232
|
+
tokensSaved: pruneResult.tokensSaved,
|
|
7233
|
+
prunedCount: pruneResult.prunedCount,
|
|
7234
|
+
cacheEpochResetCost,
|
|
7235
|
+
minSavings: compactionSettings.maintenancePruningMinSavingsTokens,
|
|
7236
|
+
});
|
|
7237
|
+
}
|
|
7238
|
+
|
|
6549
7239
|
/**
|
|
6550
7240
|
* Manually compact the session context.
|
|
6551
7241
|
* Aborts current agent operation first.
|
|
@@ -6568,7 +7258,9 @@ export class AgentSession {
|
|
|
6568
7258
|
|
|
6569
7259
|
const compactionSettings = this.settings.getGroup("compaction");
|
|
6570
7260
|
const pathEntries = this.sessionManager.getBranch();
|
|
6571
|
-
const preparation = prepareCompaction(pathEntries, compactionSettings
|
|
7261
|
+
const preparation = prepareCompaction(pathEntries, compactionSettings, {
|
|
7262
|
+
tokenCorrectionRatio: this.#computeCompactionTokenCorrectionRatio(),
|
|
7263
|
+
});
|
|
6572
7264
|
if (!preparation) {
|
|
6573
7265
|
// Check why we can't compact
|
|
6574
7266
|
const lastEntry = pathEntries[pathEntries.length - 1];
|
|
@@ -6880,6 +7572,9 @@ export class AgentSession {
|
|
|
6880
7572
|
// Rebuild agent messages from session
|
|
6881
7573
|
const sessionContext = this.buildDisplaySessionContext();
|
|
6882
7574
|
this.agent.replaceMessages(sessionContext.messages);
|
|
7575
|
+
// Handoff rebuilds live context and can evict a previously injected
|
|
7576
|
+
// goal/plan-mode-context copy; clear the static-once signatures.
|
|
7577
|
+
this.#resetInjectedContextSignatures();
|
|
6883
7578
|
this.#syncTodoPhasesFromBranch();
|
|
6884
7579
|
|
|
6885
7580
|
return { document: handoffText, savedPath };
|
|
@@ -7062,7 +7757,12 @@ export class AgentSession {
|
|
|
7062
7757
|
// Model maxTokens is a capability ceiling, not a per-turn reservation.
|
|
7063
7758
|
// Auto maintenance should track actual context fullness.
|
|
7064
7759
|
const autoCompactionOutputReserveTokens = 0;
|
|
7065
|
-
if (!shouldCompact(contextTokens, contextWindow, compactionSettings, autoCompactionOutputReserveTokens))
|
|
7760
|
+
if (!shouldCompact(contextTokens, contextWindow, compactionSettings, autoCompactionOutputReserveTokens)) {
|
|
7761
|
+
// Below the compaction threshold: optionally run evidence-gated maintenance
|
|
7762
|
+
// pruning (opt-in, high savings + cache-epoch payback required).
|
|
7763
|
+
await this.#maybeRunBelowThresholdMaintenancePrune();
|
|
7764
|
+
return;
|
|
7765
|
+
}
|
|
7066
7766
|
|
|
7067
7767
|
const pruneResult = await this.#pruneToolOutputs();
|
|
7068
7768
|
if (pruneResult) {
|
|
@@ -7112,6 +7812,7 @@ export class AgentSession {
|
|
|
7112
7812
|
}
|
|
7113
7813
|
const safeCount = Math.max(0, Math.min(checkpointState.checkpointMessageCount, this.agent.state.messages.length));
|
|
7114
7814
|
this.agent.replaceMessages(this.agent.state.messages.slice(0, safeCount));
|
|
7815
|
+
this.#resetInjectedContextSignatures();
|
|
7115
7816
|
try {
|
|
7116
7817
|
this.sessionManager.branchWithSummary(checkpointState.checkpointEntryId, report, {
|
|
7117
7818
|
startedAt: checkpointState.startedAt,
|
|
@@ -7200,7 +7901,7 @@ export class AgentSession {
|
|
|
7200
7901
|
return undefined;
|
|
7201
7902
|
}
|
|
7202
7903
|
|
|
7203
|
-
if (!this.#toolRegistry.has("todo_write")) {
|
|
7904
|
+
if (!this.#toolRegistry.has("todo_write") || !this.getActiveToolNames().includes("todo_write")) {
|
|
7204
7905
|
logger.warn("Eager todo enforcement skipped because todo_write is unavailable", {
|
|
7205
7906
|
activeToolNames: this.agent.state.tools.map(tool => tool.name),
|
|
7206
7907
|
});
|
|
@@ -7417,13 +8118,13 @@ export class AgentSession {
|
|
|
7417
8118
|
#syncAppendOnlyContext(model: Model | null | undefined): void {
|
|
7418
8119
|
const setting = this.settings.get("provider.appendOnlyContext") ?? "auto";
|
|
7419
8120
|
const providerId = model?.provider;
|
|
7420
|
-
const enable =
|
|
8121
|
+
const enable = resolveAppendOnlyMode(setting, providerId ?? "");
|
|
7421
8122
|
const prev = this.#lastAppendOnlyResolution;
|
|
7422
8123
|
if (prev && prev.enable === enable && prev.providerId === providerId) return;
|
|
7423
8124
|
this.#lastAppendOnlyResolution = { enable, providerId };
|
|
7424
8125
|
|
|
7425
8126
|
if (enable && !this.agent.appendOnlyContext) {
|
|
7426
|
-
this.agent.setAppendOnlyContext(
|
|
8127
|
+
this.agent.setAppendOnlyContext(createAppendOnlyContextManager(providerId));
|
|
7427
8128
|
} else if (enable && this.agent.appendOnlyContext) {
|
|
7428
8129
|
// Already active — invalidate prefix + log so the next turn
|
|
7429
8130
|
// rebuilds for the current model's normalization.
|
|
@@ -7630,6 +8331,59 @@ export class AgentSession {
|
|
|
7630
8331
|
return false;
|
|
7631
8332
|
}
|
|
7632
8333
|
|
|
8334
|
+
#buildAutoMaintenanceAttemptSignature(
|
|
8335
|
+
action: "context-full" | "handoff",
|
|
8336
|
+
preparation: CompactionPreparation,
|
|
8337
|
+
hookPrompt: string | undefined,
|
|
8338
|
+
hookContext: string[] | undefined,
|
|
8339
|
+
candidateModels: readonly Model[],
|
|
8340
|
+
): string {
|
|
8341
|
+
const source = JSON.stringify({
|
|
8342
|
+
action,
|
|
8343
|
+
model: this.model ? this.#getModelKey(this.model) : undefined,
|
|
8344
|
+
candidates: candidateModels.map(model => this.#getModelKey(model)),
|
|
8345
|
+
isSplitTurn: preparation.isSplitTurn,
|
|
8346
|
+
previousSummary: preparation.previousSummary,
|
|
8347
|
+
previousPreserveData: preparation.previousPreserveData,
|
|
8348
|
+
hookPrompt,
|
|
8349
|
+
hookContext,
|
|
8350
|
+
messagesToSummarize: preparation.messagesToSummarize.map(message =>
|
|
8351
|
+
this.#normalizeSessionMessageForProviderReplay(message),
|
|
8352
|
+
),
|
|
8353
|
+
turnPrefixMessages: preparation.turnPrefixMessages.map(message =>
|
|
8354
|
+
this.#normalizeSessionMessageForProviderReplay(message),
|
|
8355
|
+
),
|
|
8356
|
+
recentMessages: preparation.recentMessages.map(message =>
|
|
8357
|
+
this.#normalizeSessionMessageForProviderReplay(message),
|
|
8358
|
+
),
|
|
8359
|
+
});
|
|
8360
|
+
return `${this.#hashProviderReplaySource(source).toString(16)}:${source.length}`;
|
|
8361
|
+
}
|
|
8362
|
+
|
|
8363
|
+
#isOversizedMaintenanceError(errorMessage: string): boolean {
|
|
8364
|
+
return isContextOverflow(
|
|
8365
|
+
{
|
|
8366
|
+
role: "assistant",
|
|
8367
|
+
content: [],
|
|
8368
|
+
api: this.model?.api ?? "anthropic-messages",
|
|
8369
|
+
provider: this.model?.provider ?? "unknown",
|
|
8370
|
+
model: this.model?.id ?? "unknown",
|
|
8371
|
+
stopReason: "error",
|
|
8372
|
+
errorMessage,
|
|
8373
|
+
usage: {
|
|
8374
|
+
input: 0,
|
|
8375
|
+
output: 0,
|
|
8376
|
+
cacheRead: 0,
|
|
8377
|
+
cacheWrite: 0,
|
|
8378
|
+
totalTokens: 0,
|
|
8379
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
8380
|
+
},
|
|
8381
|
+
timestamp: Date.now(),
|
|
8382
|
+
} as AssistantMessage,
|
|
8383
|
+
this.model?.contextWindow,
|
|
8384
|
+
);
|
|
8385
|
+
}
|
|
8386
|
+
|
|
7633
8387
|
#getModelKey(model: Model): string {
|
|
7634
8388
|
return `${model.provider}/${model.id}`;
|
|
7635
8389
|
}
|
|
@@ -7900,6 +8654,7 @@ export class AgentSession {
|
|
|
7900
8654
|
const autoCompactionAbortController = new AbortController();
|
|
7901
8655
|
this.#autoCompactionAbortController = autoCompactionAbortController;
|
|
7902
8656
|
const autoCompactionSignal = autoCompactionAbortController.signal;
|
|
8657
|
+
let maintenanceAttemptSignature: string | undefined;
|
|
7903
8658
|
|
|
7904
8659
|
try {
|
|
7905
8660
|
if (compactionSettings.strategy === "handoff" && reason !== "overflow") {
|
|
@@ -7972,7 +8727,13 @@ export class AgentSession {
|
|
|
7972
8727
|
|
|
7973
8728
|
const pathEntries = this.sessionManager.getBranch();
|
|
7974
8729
|
|
|
7975
|
-
|
|
8730
|
+
// Emergency/overflow-recovery compaction is conservative: apply the token
|
|
8731
|
+
// correction only when it SHRINKS the keep window (ratio >= 1), never when
|
|
8732
|
+
// it would grow it, so recovery cannot re-overflow the provider window.
|
|
8733
|
+
const overflowRatio = this.#computeCompactionTokenCorrectionRatio();
|
|
8734
|
+
const preparation = prepareCompaction(pathEntries, compactionSettings, {
|
|
8735
|
+
tokenCorrectionRatio: overflowRatio !== undefined ? Math.max(1, overflowRatio) : undefined,
|
|
8736
|
+
});
|
|
7976
8737
|
if (!preparation) {
|
|
7977
8738
|
const continuationSkipReason = willRetry ? this.#detectOverflowRetryContinuationSkip() : undefined;
|
|
7978
8739
|
await this.#emitSessionEvent({
|
|
@@ -8047,6 +8808,26 @@ export class AgentSession {
|
|
|
8047
8808
|
preserveData = compactionPrep.preserveData;
|
|
8048
8809
|
} else {
|
|
8049
8810
|
const candidates = this.#getCompactionModelCandidates(availableModels);
|
|
8811
|
+
maintenanceAttemptSignature = this.#buildAutoMaintenanceAttemptSignature(
|
|
8812
|
+
action,
|
|
8813
|
+
preparation,
|
|
8814
|
+
compactionPrep.hookPrompt,
|
|
8815
|
+
compactionPrep.hookContext,
|
|
8816
|
+
candidates,
|
|
8817
|
+
);
|
|
8818
|
+
if (this.#lastOversizedAutoMaintenanceAttemptSignature === maintenanceAttemptSignature) {
|
|
8819
|
+
await this.#emitSessionEvent({
|
|
8820
|
+
type: "auto_compaction_end",
|
|
8821
|
+
action,
|
|
8822
|
+
result: undefined,
|
|
8823
|
+
aborted: false,
|
|
8824
|
+
willRetry: false,
|
|
8825
|
+
skipped: true,
|
|
8826
|
+
errorMessage:
|
|
8827
|
+
"Auto-compaction skipped: previous unchanged maintenance request exceeded the model context window; change or reduce the conversation before retrying maintenance.",
|
|
8828
|
+
});
|
|
8829
|
+
return;
|
|
8830
|
+
}
|
|
8050
8831
|
const retrySettings = this.settings.getGroup("retry");
|
|
8051
8832
|
const telemetry = resolveTelemetry(this.agent.telemetry, this.sessionId);
|
|
8052
8833
|
let compactResult: CompactionResult | undefined;
|
|
@@ -8179,6 +8960,8 @@ export class AgentSession {
|
|
|
8179
8960
|
details,
|
|
8180
8961
|
preserveData,
|
|
8181
8962
|
};
|
|
8963
|
+
this.#lastOversizedAutoMaintenanceAttemptSignature = undefined;
|
|
8964
|
+
|
|
8182
8965
|
const continuationSkipReason = willRetry ? this.#detectOverflowRetryContinuationSkip() : undefined;
|
|
8183
8966
|
await this.#emitSessionEvent({
|
|
8184
8967
|
type: "auto_compaction_end",
|
|
@@ -8216,6 +8999,9 @@ export class AgentSession {
|
|
|
8216
8999
|
return;
|
|
8217
9000
|
}
|
|
8218
9001
|
const errorMessage = error instanceof Error ? error.message : "compaction failed";
|
|
9002
|
+
if (maintenanceAttemptSignature && this.#isOversizedMaintenanceError(errorMessage)) {
|
|
9003
|
+
this.#lastOversizedAutoMaintenanceAttemptSignature = maintenanceAttemptSignature;
|
|
9004
|
+
}
|
|
8219
9005
|
await this.#emitSessionEvent({
|
|
8220
9006
|
type: "auto_compaction_end",
|
|
8221
9007
|
action,
|
|
@@ -8340,6 +9126,16 @@ export class AgentSession {
|
|
|
8340
9126
|
);
|
|
8341
9127
|
}
|
|
8342
9128
|
|
|
9129
|
+
#isRefusalErrorMessage(errorMessage: string): boolean {
|
|
9130
|
+
// Provider safety-refusal stops. Matches the engine-generated Anthropic
|
|
9131
|
+
// labels from packages/ai ("Refusal (<category>): …", "Refusal (no
|
|
9132
|
+
// details provided)", "Content flagged by safety filters") plus generic
|
|
9133
|
+
// usage-policy refusal copy.
|
|
9134
|
+
return /^refusal(\s*\(|:|$)|content flagged by safety filters|blocked under .{0,40}usage policy/i.test(
|
|
9135
|
+
errorMessage,
|
|
9136
|
+
);
|
|
9137
|
+
}
|
|
9138
|
+
|
|
8343
9139
|
#extractExplicitHttpStatusFromErrorMessage(errorMessage: string): number | undefined {
|
|
8344
9140
|
// Parse only explicit HTTP/status wording. Do not treat generic
|
|
8345
9141
|
// `error: 400` as an HTTP status because rate-limit copy can say
|
|
@@ -8360,6 +9156,13 @@ export class AgentSession {
|
|
|
8360
9156
|
const contextWindow = this.model?.contextWindow ?? 0;
|
|
8361
9157
|
if (isContextOverflow(message, contextWindow)) return "overflow";
|
|
8362
9158
|
const err = message.errorMessage;
|
|
9159
|
+
// Provider safety refusals (e.g. Anthropic stop_reason "refusal" /
|
|
9160
|
+
// "sensitive") are deterministic for the submitted context: replaying
|
|
9161
|
+
// the identical conversation re-triggers the identical refusal, so an
|
|
9162
|
+
// auto-retry loop can never succeed and only re-bills the full context
|
|
9163
|
+
// on every attempt (#1655). Surface immediately instead of joining the
|
|
9164
|
+
// unbounded "unknown" retry class.
|
|
9165
|
+
if (this.#isRefusalErrorMessage(err)) return "terminal";
|
|
8363
9166
|
if (isLocalModelEndpoint(this.model) && this.#isLocalProviderAvailabilityErrorMessage(err)) {
|
|
8364
9167
|
return "local_unavailable";
|
|
8365
9168
|
}
|
|
@@ -8923,22 +9726,52 @@ export class AgentSession {
|
|
|
8923
9726
|
setAutoRetryEnabled(enabled: boolean): void {
|
|
8924
9727
|
this.settings.set("retry.enabled", enabled);
|
|
8925
9728
|
}
|
|
9729
|
+
#isInterruptedRetryTail(message: AgentMessage | undefined): boolean {
|
|
9730
|
+
if (!message) return false;
|
|
9731
|
+
return (
|
|
9732
|
+
message.role === "user" ||
|
|
9733
|
+
message.role === "developer" ||
|
|
9734
|
+
message.role === "toolResult" ||
|
|
9735
|
+
message.role === "fileMention" ||
|
|
9736
|
+
message.role === "custom" ||
|
|
9737
|
+
message.role === "hookMessage"
|
|
9738
|
+
);
|
|
9739
|
+
}
|
|
9740
|
+
|
|
9741
|
+
#isUnresolvedToolUseAssistant(message: AssistantMessage): boolean {
|
|
9742
|
+
return message.stopReason === "toolUse" && message.content.some(content => content.type === "toolCall");
|
|
9743
|
+
}
|
|
9744
|
+
|
|
8926
9745
|
/**
|
|
8927
|
-
* Manually retry the last failed assistant turn
|
|
8928
|
-
*
|
|
8929
|
-
*
|
|
9746
|
+
* Manually retry the last failed assistant turn, or resume an interrupted tail
|
|
9747
|
+
* left by a non-graceful process exit after the user/custom/tool-result message
|
|
9748
|
+
* was persisted but before the agent emitted a terminal assistant response.
|
|
9749
|
+
* Removes failed/aborted/unresolved tool-use assistant tails before
|
|
9750
|
+
* re-attempting with a fresh retry budget.
|
|
9751
|
+
* @returns true if retry/resume was initiated, false if no retryable tail exists or agent is busy
|
|
8930
9752
|
*/
|
|
8931
9753
|
async retry(): Promise<boolean> {
|
|
8932
9754
|
if (this.isStreaming || this.isCompacting || this.isRetrying) return false;
|
|
8933
9755
|
|
|
8934
9756
|
const messages = this.agent.state.messages;
|
|
8935
9757
|
const lastMsg = messages[messages.length - 1];
|
|
8936
|
-
if (lastMsg
|
|
9758
|
+
if (!lastMsg) return false;
|
|
9759
|
+
|
|
9760
|
+
if (lastMsg.role !== "assistant") {
|
|
9761
|
+
if (!this.#isInterruptedRetryTail(lastMsg)) return false;
|
|
9762
|
+
this.#retryAttempt = 0;
|
|
9763
|
+
this.#scheduleAgentContinue({ delayMs: 1 });
|
|
9764
|
+
return true;
|
|
9765
|
+
}
|
|
8937
9766
|
|
|
8938
9767
|
const assistantMsg = lastMsg as AssistantMessage;
|
|
8939
|
-
|
|
9768
|
+
const shouldDropAssistant =
|
|
9769
|
+
assistantMsg.stopReason === "error" ||
|
|
9770
|
+
assistantMsg.stopReason === "aborted" ||
|
|
9771
|
+
this.#isUnresolvedToolUseAssistant(assistantMsg);
|
|
9772
|
+
if (!shouldDropAssistant) return false;
|
|
8940
9773
|
|
|
8941
|
-
// Remove the failed/aborted assistant message
|
|
9774
|
+
// Remove the failed/aborted/incomplete assistant message before re-attempting.
|
|
8942
9775
|
this.agent.replaceMessages(messages.slice(0, -1));
|
|
8943
9776
|
|
|
8944
9777
|
// Reset retry budget for a fresh attempt
|
|
@@ -9700,6 +10533,7 @@ export class AgentSession {
|
|
|
9700
10533
|
}
|
|
9701
10534
|
|
|
9702
10535
|
this.agent.replaceMessages(sessionContext.messages);
|
|
10536
|
+
this.#resetInjectedContextSignatures();
|
|
9703
10537
|
this.#syncTodoPhasesFromBranch();
|
|
9704
10538
|
if (switchingToDifferentSession) {
|
|
9705
10539
|
this.#closeAllProviderSessions("session switch");
|
|
@@ -9872,6 +10706,7 @@ export class AgentSession {
|
|
|
9872
10706
|
|
|
9873
10707
|
if (!skipConversationRestore) {
|
|
9874
10708
|
this.agent.replaceMessages(sessionContext.messages);
|
|
10709
|
+
this.#resetInjectedContextSignatures();
|
|
9875
10710
|
this.#closeCodexProviderSessionsForHistoryRewrite();
|
|
9876
10711
|
}
|
|
9877
10712
|
|
|
@@ -10039,6 +10874,7 @@ export class AgentSession {
|
|
|
10039
10874
|
const displayContext = deobfuscateSessionContext(stateContext, this.#obfuscator);
|
|
10040
10875
|
await this.#restoreMCPSelectionsForSessionContext(displayContext);
|
|
10041
10876
|
this.agent.replaceMessages(displayContext.messages);
|
|
10877
|
+
this.#resetInjectedContextSignatures();
|
|
10042
10878
|
this.#syncTodoPhasesFromBranch();
|
|
10043
10879
|
this.#closeCodexProviderSessionsForHistoryRewrite();
|
|
10044
10880
|
|
|
@@ -10237,6 +11073,57 @@ export class AgentSession {
|
|
|
10237
11073
|
return this.#estimateContextTokensWith(message => this.#estimateMessageDisplayTokens(message));
|
|
10238
11074
|
}
|
|
10239
11075
|
|
|
11076
|
+
/** Count inline image blocks in a message (for bucketing the fixed image token estimate). */
|
|
11077
|
+
#countImageBlocks(message: AgentMessage): number {
|
|
11078
|
+
const content = (message as { content?: unknown }).content;
|
|
11079
|
+
if (!Array.isArray(content)) return 0;
|
|
11080
|
+
let count = 0;
|
|
11081
|
+
for (const block of content) {
|
|
11082
|
+
if (block && typeof block === "object" && (block as { type?: unknown }).type === "image") count++;
|
|
11083
|
+
}
|
|
11084
|
+
return count;
|
|
11085
|
+
}
|
|
11086
|
+
|
|
11087
|
+
/**
|
|
11088
|
+
* Observed heuristic→actual token correction for the compaction keep window
|
|
11089
|
+
* (Finding 7). Compares the provider's real prompt tokens against the chars/4
|
|
11090
|
+
* heuristic estimate of the same content (stable system prefix + history through
|
|
11091
|
+
* the last usage-bearing assistant turn). Image-bearing content is bucketed out
|
|
11092
|
+
* of BOTH sides using the identical fixed IMAGE_TOKEN_ESTIMATE so the 1200-token
|
|
11093
|
+
* image charge cannot skew the text ratio. Returns undefined when data is
|
|
11094
|
+
* insufficient, so prepareCompaction applies no correction (never the confounded
|
|
11095
|
+
* raw promptTokens/estimatedTokens quotient). Clamped to [0.5, 2] downstream.
|
|
11096
|
+
*/
|
|
11097
|
+
#computeCompactionTokenCorrectionRatio(): number | undefined {
|
|
11098
|
+
const messages = this.messages;
|
|
11099
|
+
let lastUsageIndex = -1;
|
|
11100
|
+
let lastUsage: Usage | undefined;
|
|
11101
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
11102
|
+
const msg = messages[i];
|
|
11103
|
+
if (msg.role === "assistant" && (msg as AssistantMessage).usage) {
|
|
11104
|
+
lastUsage = (msg as AssistantMessage).usage;
|
|
11105
|
+
lastUsageIndex = i;
|
|
11106
|
+
break;
|
|
11107
|
+
}
|
|
11108
|
+
}
|
|
11109
|
+
if (!lastUsage || lastUsageIndex < 0) return undefined;
|
|
11110
|
+
const actual = calculatePromptTokens(lastUsage);
|
|
11111
|
+
if (!(actual > 0)) return undefined;
|
|
11112
|
+
|
|
11113
|
+
let heuristic = 0;
|
|
11114
|
+
for (const block of this.agent.state.systemPrompt) heuristic += estimateTextTokensHeuristic(block);
|
|
11115
|
+
let imageBlocks = 0;
|
|
11116
|
+
for (let i = 0; i <= lastUsageIndex; i++) {
|
|
11117
|
+
heuristic += this.#estimateMessageDisplayTokens(messages[i]);
|
|
11118
|
+
imageBlocks += this.#countImageBlocks(messages[i]);
|
|
11119
|
+
}
|
|
11120
|
+
const imgAdjust = imageBlocks * IMAGE_TOKEN_ESTIMATE;
|
|
11121
|
+
const num = actual - imgAdjust;
|
|
11122
|
+
const den = heuristic - imgAdjust;
|
|
11123
|
+
if (!(num > 0) || !(den > 0)) return undefined;
|
|
11124
|
+
return num / den;
|
|
11125
|
+
}
|
|
11126
|
+
|
|
10240
11127
|
#estimateContextTokensForCompaction(pendingMessages: readonly AgentMessage[]): {
|
|
10241
11128
|
tokens: number;
|
|
10242
11129
|
} {
|
|
@@ -10525,6 +11412,10 @@ export class AgentSession {
|
|
|
10525
11412
|
return this.#extensionRunner?.hasHandlers(eventType) ?? false;
|
|
10526
11413
|
}
|
|
10527
11414
|
|
|
11415
|
+
#hasStreamingExtensionHandlers(): boolean {
|
|
11416
|
+
return this.hasExtensionHandlers("message_update");
|
|
11417
|
+
}
|
|
11418
|
+
|
|
10528
11419
|
/**
|
|
10529
11420
|
* Register a first-party internal before-agent-start contributor. Returns an
|
|
10530
11421
|
* unregister function. This is NOT user-facing hook discovery; it is an
|