@wahack/pi-coding-agent 15.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10031 -0
- package/README.md +36 -0
- package/examples/README.md +21 -0
- package/examples/custom-tools/README.md +104 -0
- package/examples/custom-tools/hello/index.ts +20 -0
- package/examples/extensions/README.md +142 -0
- package/examples/extensions/api-demo.ts +79 -0
- package/examples/extensions/chalk-logger.ts +25 -0
- package/examples/extensions/hello.ts +31 -0
- package/examples/extensions/pirate.ts +43 -0
- package/examples/extensions/plan-mode.ts +549 -0
- package/examples/extensions/reload-runtime.ts +38 -0
- package/examples/extensions/thinking-note.ts +13 -0
- package/examples/extensions/tools.ts +145 -0
- package/examples/extensions/with-deps/index.ts +36 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +17 -0
- package/examples/hooks/README.md +56 -0
- package/examples/hooks/auto-commit-on-exit.ts +48 -0
- package/examples/hooks/confirm-destructive.ts +58 -0
- package/examples/hooks/custom-compaction.ts +115 -0
- package/examples/hooks/dirty-repo-guard.ts +51 -0
- package/examples/hooks/file-trigger.ts +40 -0
- package/examples/hooks/git-checkpoint.ts +52 -0
- package/examples/hooks/handoff.ts +149 -0
- package/examples/hooks/permission-gate.ts +33 -0
- package/examples/hooks/protected-paths.ts +29 -0
- package/examples/hooks/qna.ts +118 -0
- package/examples/hooks/status-line.ts +39 -0
- package/examples/sdk/01-minimal.ts +21 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +46 -0
- package/examples/sdk/04-skills.ts +43 -0
- package/examples/sdk/06-extensions.ts +82 -0
- package/examples/sdk/06-hooks.ts +61 -0
- package/examples/sdk/07-context-files.ts +35 -0
- package/examples/sdk/08-prompt-templates.ts +41 -0
- package/examples/sdk/08-slash-commands.ts +46 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +54 -0
- package/examples/sdk/11-sessions.ts +47 -0
- package/examples/sdk/12-redis-sessions.ts +54 -0
- package/examples/sdk/13-sql-sessions.ts +61 -0
- package/examples/sdk/README.md +172 -0
- package/package.json +554 -0
- package/scripts/build-binary.ts +100 -0
- package/scripts/bundle-dist.ts +90 -0
- package/scripts/format-prompts.ts +68 -0
- package/scripts/generate-docs-index.ts +40 -0
- package/scripts/generate-template.ts +33 -0
- package/scripts/omp +42 -0
- package/scripts/omp.ts +19 -0
- package/src/async/index.ts +1 -0
- package/src/async/job-manager.ts +625 -0
- package/src/auto-thinking/classifier.ts +185 -0
- package/src/autoresearch/command-resume.md +14 -0
- package/src/autoresearch/dashboard.ts +436 -0
- package/src/autoresearch/git.ts +319 -0
- package/src/autoresearch/helpers.ts +218 -0
- package/src/autoresearch/index.ts +536 -0
- package/src/autoresearch/prompt-setup.md +43 -0
- package/src/autoresearch/prompt.md +103 -0
- package/src/autoresearch/resume-message.md +10 -0
- package/src/autoresearch/state.ts +273 -0
- package/src/autoresearch/storage.ts +699 -0
- package/src/autoresearch/tools/init-experiment.ts +272 -0
- package/src/autoresearch/tools/log-experiment.ts +524 -0
- package/src/autoresearch/tools/run-experiment.ts +407 -0
- package/src/autoresearch/tools/update-notes.ts +109 -0
- package/src/autoresearch/types.ts +168 -0
- package/src/bun-imports.d.ts +28 -0
- package/src/capability/context-file.ts +44 -0
- package/src/capability/extension-module.ts +34 -0
- package/src/capability/extension.ts +47 -0
- package/src/capability/fs.ts +117 -0
- package/src/capability/hook.ts +40 -0
- package/src/capability/index.ts +436 -0
- package/src/capability/instruction.ts +37 -0
- package/src/capability/mcp.ts +74 -0
- package/src/capability/prompt.ts +35 -0
- package/src/capability/rule-buckets.ts +66 -0
- package/src/capability/rule.ts +261 -0
- package/src/capability/settings.ts +34 -0
- package/src/capability/skill.ts +63 -0
- package/src/capability/slash-command.ts +40 -0
- package/src/capability/ssh.ts +41 -0
- package/src/capability/system-prompt.ts +34 -0
- package/src/capability/tool.ts +38 -0
- package/src/capability/types.ts +168 -0
- package/src/cli/agents-cli.ts +138 -0
- package/src/cli/args.ts +340 -0
- package/src/cli/auth-broker-cli.ts +895 -0
- package/src/cli/auth-gateway-cli.ts +611 -0
- package/src/cli/classify-install-target.ts +76 -0
- package/src/cli/claude-trace-cli.ts +795 -0
- package/src/cli/commands/init-xdg.ts +27 -0
- package/src/cli/completion-gen.ts +550 -0
- package/src/cli/config-cli.ts +418 -0
- package/src/cli/dry-balance-cli.ts +856 -0
- package/src/cli/extension-flags.ts +48 -0
- package/src/cli/file-processor.ts +133 -0
- package/src/cli/gallery-cli.ts +230 -0
- package/src/cli/gallery-fixtures/agentic.ts +407 -0
- package/src/cli/gallery-fixtures/codeintel.ts +187 -0
- package/src/cli/gallery-fixtures/edit.ts +194 -0
- package/src/cli/gallery-fixtures/fs.ts +220 -0
- package/src/cli/gallery-fixtures/index.ts +40 -0
- package/src/cli/gallery-fixtures/interaction.ts +49 -0
- package/src/cli/gallery-fixtures/memory.ts +81 -0
- package/src/cli/gallery-fixtures/misc.ts +250 -0
- package/src/cli/gallery-fixtures/search.ts +213 -0
- package/src/cli/gallery-fixtures/shell.ts +167 -0
- package/src/cli/gallery-fixtures/types.ts +57 -0
- package/src/cli/gallery-fixtures/web.ts +158 -0
- package/src/cli/gallery-screenshot.ts +279 -0
- package/src/cli/grep-cli.ts +160 -0
- package/src/cli/grievances-cli.ts +256 -0
- package/src/cli/initial-message.ts +58 -0
- package/src/cli/list-models.ts +194 -0
- package/src/cli/plugin-cli.ts +996 -0
- package/src/cli/read-cli.ts +57 -0
- package/src/cli/session-picker.ts +79 -0
- package/src/cli/setup-cli.ts +231 -0
- package/src/cli/shell-cli.ts +176 -0
- package/src/cli/ssh-cli.ts +179 -0
- package/src/cli/startup-cwd.ts +68 -0
- package/src/cli/stats-cli.ts +238 -0
- package/src/cli/tiny-models-cli.ts +127 -0
- package/src/cli/update-cli.ts +611 -0
- package/src/cli/usage-cli.ts +603 -0
- package/src/cli/web-search-cli.ts +132 -0
- package/src/cli/worktree-cli.ts +291 -0
- package/src/cli-commands.ts +79 -0
- package/src/cli.ts +200 -0
- package/src/commands/acp.ts +24 -0
- package/src/commands/agents.ts +57 -0
- package/src/commands/auth-broker.ts +99 -0
- package/src/commands/auth-gateway.ts +69 -0
- package/src/commands/commit.ts +46 -0
- package/src/commands/complete.ts +66 -0
- package/src/commands/completions.ts +60 -0
- package/src/commands/config.ts +51 -0
- package/src/commands/dry-balance.ts +43 -0
- package/src/commands/gallery.ts +52 -0
- package/src/commands/grep.ts +48 -0
- package/src/commands/grievances.ts +51 -0
- package/src/commands/install.ts +107 -0
- package/src/commands/launch.ts +169 -0
- package/src/commands/plugin.ts +78 -0
- package/src/commands/read.ts +38 -0
- package/src/commands/setup.ts +67 -0
- package/src/commands/shell.ts +29 -0
- package/src/commands/ssh.ts +60 -0
- package/src/commands/stats.ts +29 -0
- package/src/commands/tiny-models.ts +36 -0
- package/src/commands/update.ts +21 -0
- package/src/commands/usage.ts +35 -0
- package/src/commands/web-search.ts +42 -0
- package/src/commands/worktree.ts +56 -0
- package/src/commit/agentic/agent.ts +317 -0
- package/src/commit/agentic/fallback.ts +96 -0
- package/src/commit/agentic/index.ts +355 -0
- package/src/commit/agentic/prompts/analyze-file.md +22 -0
- package/src/commit/agentic/prompts/session-user.md +25 -0
- package/src/commit/agentic/prompts/split-confirm.md +1 -0
- package/src/commit/agentic/prompts/system.md +38 -0
- package/src/commit/agentic/state.ts +60 -0
- package/src/commit/agentic/tools/analyze-file.ts +146 -0
- package/src/commit/agentic/tools/git-file-diff.ts +191 -0
- package/src/commit/agentic/tools/git-hunk.ts +50 -0
- package/src/commit/agentic/tools/git-overview.ts +81 -0
- package/src/commit/agentic/tools/index.ts +54 -0
- package/src/commit/agentic/tools/propose-changelog.ts +144 -0
- package/src/commit/agentic/tools/propose-commit.ts +109 -0
- package/src/commit/agentic/tools/recent-commits.ts +81 -0
- package/src/commit/agentic/tools/schemas.ts +23 -0
- package/src/commit/agentic/tools/split-commit.ts +245 -0
- package/src/commit/agentic/topo-sort.ts +44 -0
- package/src/commit/agentic/trivial.ts +51 -0
- package/src/commit/agentic/validation.ts +183 -0
- package/src/commit/analysis/conventional.ts +64 -0
- package/src/commit/analysis/index.ts +4 -0
- package/src/commit/analysis/scope.ts +242 -0
- package/src/commit/analysis/summary.ts +105 -0
- package/src/commit/analysis/validation.ts +66 -0
- package/src/commit/changelog/detect.ts +40 -0
- package/src/commit/changelog/generate.ts +97 -0
- package/src/commit/changelog/index.ts +234 -0
- package/src/commit/changelog/parse.ts +44 -0
- package/src/commit/cli.ts +85 -0
- package/src/commit/git/diff.ts +148 -0
- package/src/commit/index.ts +5 -0
- package/src/commit/map-reduce/index.ts +69 -0
- package/src/commit/map-reduce/map-phase.ts +193 -0
- package/src/commit/map-reduce/reduce-phase.ts +49 -0
- package/src/commit/map-reduce/utils.ts +9 -0
- package/src/commit/message.ts +11 -0
- package/src/commit/model-selection.ts +92 -0
- package/src/commit/pipeline.ts +243 -0
- package/src/commit/prompts/analysis-system.md +148 -0
- package/src/commit/prompts/analysis-user.md +38 -0
- package/src/commit/prompts/changelog-system.md +50 -0
- package/src/commit/prompts/changelog-user.md +18 -0
- package/src/commit/prompts/file-observer-system.md +24 -0
- package/src/commit/prompts/file-observer-user.md +8 -0
- package/src/commit/prompts/reduce-system.md +50 -0
- package/src/commit/prompts/reduce-user.md +17 -0
- package/src/commit/prompts/summary-retry.md +3 -0
- package/src/commit/prompts/summary-system.md +38 -0
- package/src/commit/prompts/summary-user.md +13 -0
- package/src/commit/prompts/types-description.md +2 -0
- package/src/commit/shared-llm.ts +77 -0
- package/src/commit/types.ts +118 -0
- package/src/commit/utils/exclusions.ts +42 -0
- package/src/commit/utils.ts +58 -0
- package/src/config/api-key-resolver.ts +60 -0
- package/src/config/append-only-context-mode.ts +31 -0
- package/src/config/config-file.ts +317 -0
- package/src/config/file-lock.ts +164 -0
- package/src/config/keybindings.ts +628 -0
- package/src/config/mcp-schema.json +230 -0
- package/src/config/model-discovery.ts +554 -0
- package/src/config/model-registry.ts +2090 -0
- package/src/config/model-resolver.ts +1502 -0
- package/src/config/model-roles.ts +74 -0
- package/src/config/models-config-schema.ts +226 -0
- package/src/config/models-config.ts +129 -0
- package/src/config/prompt-templates.ts +185 -0
- package/src/config/resolve-config-value.ts +94 -0
- package/src/config/settings-schema.ts +3530 -0
- package/src/config/settings.ts +1178 -0
- package/src/config.ts +242 -0
- package/src/cursor.ts +340 -0
- package/src/dap/client.ts +760 -0
- package/src/dap/config.ts +189 -0
- package/src/dap/defaults.json +212 -0
- package/src/dap/index.ts +4 -0
- package/src/dap/session.ts +1441 -0
- package/src/dap/types.ts +610 -0
- package/src/debug/index.ts +515 -0
- package/src/debug/log-formatting.ts +58 -0
- package/src/debug/log-viewer.ts +908 -0
- package/src/debug/profiler.ts +162 -0
- package/src/debug/protocol-probe.ts +267 -0
- package/src/debug/raw-sse-buffer.ts +273 -0
- package/src/debug/raw-sse.ts +292 -0
- package/src/debug/report-bundle.ts +374 -0
- package/src/debug/system-info.ts +111 -0
- package/src/debug/terminal-info.ts +124 -0
- package/src/discovery/agents-md.ts +67 -0
- package/src/discovery/agents.ts +230 -0
- package/src/discovery/at-imports.ts +273 -0
- package/src/discovery/builtin-defaults.ts +39 -0
- package/src/discovery/builtin-rules/index.ts +54 -0
- package/src/discovery/builtin-rules/rs-box-leak.md +48 -0
- package/src/discovery/builtin-rules/rs-future-prelude.md +23 -0
- package/src/discovery/builtin-rules/rs-lazylock.md +51 -0
- package/src/discovery/builtin-rules/rs-match-ergonomics.md +67 -0
- package/src/discovery/builtin-rules/rs-parking-lot.md +44 -0
- package/src/discovery/builtin-rules/rs-result-type.md +19 -0
- package/src/discovery/builtin-rules/ts-bare-catch.md +38 -0
- package/src/discovery/builtin-rules/ts-import-type.md +42 -0
- package/src/discovery/builtin-rules/ts-no-any.md +56 -0
- package/src/discovery/builtin-rules/ts-no-deprecated-leftovers.md +44 -0
- package/src/discovery/builtin-rules/ts-no-dynamic-import.md +39 -0
- package/src/discovery/builtin-rules/ts-no-return-type.md +45 -0
- package/src/discovery/builtin-rules/ts-no-test-timers.md +55 -0
- package/src/discovery/builtin-rules/ts-no-tiny-functions.md +51 -0
- package/src/discovery/builtin-rules/ts-promise-with-resolvers.md +65 -0
- package/src/discovery/builtin-rules/ts-redundant-clear-guard.md +75 -0
- package/src/discovery/builtin-rules/ts-set-map.md +28 -0
- package/src/discovery/builtin.ts +906 -0
- package/src/discovery/claude-plugins.ts +386 -0
- package/src/discovery/claude.ts +584 -0
- package/src/discovery/cline.ts +83 -0
- package/src/discovery/codex.ts +522 -0
- package/src/discovery/cursor.ts +220 -0
- package/src/discovery/gemini.ts +383 -0
- package/src/discovery/github.ts +154 -0
- package/src/discovery/helpers.ts +1016 -0
- package/src/discovery/index.ts +81 -0
- package/src/discovery/mcp-json.ts +171 -0
- package/src/discovery/omp-extension-roots.ts +190 -0
- package/src/discovery/omp-plugins.ts +383 -0
- package/src/discovery/opencode.ts +398 -0
- package/src/discovery/plugin-dir-roots.ts +28 -0
- package/src/discovery/ssh.ts +153 -0
- package/src/discovery/substitute-plugin-root.ts +29 -0
- package/src/discovery/vscode.ts +105 -0
- package/src/discovery/windsurf.ts +147 -0
- package/src/edit/apply-patch/index.ts +87 -0
- package/src/edit/apply-patch/parser.ts +174 -0
- package/src/edit/diff.ts +999 -0
- package/src/edit/file-snapshot-store.ts +91 -0
- package/src/edit/hashline/block-resolver.ts +33 -0
- package/src/edit/hashline/diff.ts +290 -0
- package/src/edit/hashline/execute.ts +242 -0
- package/src/edit/hashline/filesystem.ts +130 -0
- package/src/edit/hashline/index.ts +5 -0
- package/src/edit/hashline/noop-loop-guard.ts +99 -0
- package/src/edit/hashline/params.ts +18 -0
- package/src/edit/index.ts +571 -0
- package/src/edit/modes/apply-patch.lark +19 -0
- package/src/edit/modes/apply-patch.ts +53 -0
- package/src/edit/modes/patch.ts +1891 -0
- package/src/edit/modes/replace.ts +1137 -0
- package/src/edit/normalize.ts +345 -0
- package/src/edit/notebook.ts +242 -0
- package/src/edit/read-file.ts +25 -0
- package/src/edit/renderer.ts +769 -0
- package/src/edit/streaming.ts +517 -0
- package/src/eval/__tests__/agent-bridge.test.ts +708 -0
- package/src/eval/__tests__/bridge-timeout.test.ts +64 -0
- package/src/eval/__tests__/budget-bridge.test.ts +69 -0
- package/src/eval/__tests__/completion-bridge.test.ts +412 -0
- package/src/eval/__tests__/helpers-local-roots.test.ts +58 -0
- package/src/eval/__tests__/idle-timeout.test.ts +80 -0
- package/src/eval/__tests__/js-context-manager.test.ts +241 -0
- package/src/eval/__tests__/kernel-spawn.test.ts +103 -0
- package/src/eval/agent-bridge.ts +319 -0
- package/src/eval/backend.ts +71 -0
- package/src/eval/bridge-timeout.ts +44 -0
- package/src/eval/budget-bridge.ts +48 -0
- package/src/eval/completion-bridge.ts +207 -0
- package/src/eval/concurrency-bridge.ts +34 -0
- package/src/eval/idle-timeout.ts +91 -0
- package/src/eval/index.ts +4 -0
- package/src/eval/js/context-manager.ts +502 -0
- package/src/eval/js/executor.ts +173 -0
- package/src/eval/js/index.ts +51 -0
- package/src/eval/js/shared/helpers.ts +283 -0
- package/src/eval/js/shared/indirect-eval.ts +30 -0
- package/src/eval/js/shared/local-module-loader.ts +342 -0
- package/src/eval/js/shared/prelude.ts +2 -0
- package/src/eval/js/shared/prelude.txt +246 -0
- package/src/eval/js/shared/rewrite-imports.ts +532 -0
- package/src/eval/js/shared/runtime.ts +352 -0
- package/src/eval/js/shared/types.ts +18 -0
- package/src/eval/js/tool-bridge.ts +162 -0
- package/src/eval/js/worker-core.ts +132 -0
- package/src/eval/js/worker-entry.ts +30 -0
- package/src/eval/js/worker-protocol.ts +47 -0
- package/src/eval/py/__tests__/prelude.test.ts +19 -0
- package/src/eval/py/display.ts +71 -0
- package/src/eval/py/executor.ts +742 -0
- package/src/eval/py/index.ts +68 -0
- package/src/eval/py/kernel.ts +748 -0
- package/src/eval/py/prelude.py +658 -0
- package/src/eval/py/prelude.ts +3 -0
- package/src/eval/py/runner.py +1133 -0
- package/src/eval/py/runtime.ts +276 -0
- package/src/eval/py/spawn-options.ts +126 -0
- package/src/eval/py/tool-bridge.ts +182 -0
- package/src/eval/session-id.ts +8 -0
- package/src/eval/types.ts +48 -0
- package/src/exa/index.ts +2 -0
- package/src/exa/mcp-client.ts +370 -0
- package/src/exa/types.ts +69 -0
- package/src/exec/bash-executor.ts +419 -0
- package/src/exec/exec.ts +53 -0
- package/src/exec/non-interactive-env.ts +48 -0
- package/src/export/custom-share.ts +65 -0
- package/src/export/html/index.ts +164 -0
- package/src/export/html/template.css +1051 -0
- package/src/export/html/template.generated.ts +2 -0
- package/src/export/html/template.html +46 -0
- package/src/export/html/template.js +2271 -0
- package/src/export/html/template.macro.ts +25 -0
- package/src/export/html/vendor/highlight.min.js +1213 -0
- package/src/export/html/vendor/marked.min.js +6 -0
- package/src/export/ttsr.ts +583 -0
- package/src/extensibility/custom-commands/bundled/ci-green/index.ts +54 -0
- package/src/extensibility/custom-commands/bundled/review/index.ts +489 -0
- package/src/extensibility/custom-commands/index.ts +2 -0
- package/src/extensibility/custom-commands/loader.ts +238 -0
- package/src/extensibility/custom-commands/types.ts +113 -0
- package/src/extensibility/custom-tools/index.ts +7 -0
- package/src/extensibility/custom-tools/loader.ts +269 -0
- package/src/extensibility/custom-tools/types.ts +270 -0
- package/src/extensibility/custom-tools/wrapper.ts +47 -0
- package/src/extensibility/extensions/compact-handler.ts +40 -0
- package/src/extensibility/extensions/get-commands-handler.ts +78 -0
- package/src/extensibility/extensions/index.ts +16 -0
- package/src/extensibility/extensions/loader.ts +572 -0
- package/src/extensibility/extensions/runner.ts +922 -0
- package/src/extensibility/extensions/types.ts +1322 -0
- package/src/extensibility/extensions/wrapper.ts +223 -0
- package/src/extensibility/hooks/index.ts +5 -0
- package/src/extensibility/hooks/loader.ts +257 -0
- package/src/extensibility/hooks/runner.ts +425 -0
- package/src/extensibility/hooks/tool-wrapper.ts +107 -0
- package/src/extensibility/hooks/types.ts +606 -0
- package/src/extensibility/legacy-pi-ai-shim.ts +24 -0
- package/src/extensibility/legacy-pi-coding-agent-shim.ts +15 -0
- package/src/extensibility/plugins/doctor.ts +65 -0
- package/src/extensibility/plugins/git-url.ts +367 -0
- package/src/extensibility/plugins/index.ts +9 -0
- package/src/extensibility/plugins/installer.ts +192 -0
- package/src/extensibility/plugins/legacy-pi-compat.ts +682 -0
- package/src/extensibility/plugins/loader.ts +313 -0
- package/src/extensibility/plugins/manager.ts +827 -0
- package/src/extensibility/plugins/marketplace/cache.ts +136 -0
- package/src/extensibility/plugins/marketplace/fetcher.ts +317 -0
- package/src/extensibility/plugins/marketplace/index.ts +6 -0
- package/src/extensibility/plugins/marketplace/manager.ts +770 -0
- package/src/extensibility/plugins/marketplace/registry.ts +196 -0
- package/src/extensibility/plugins/marketplace/source-resolver.ts +147 -0
- package/src/extensibility/plugins/marketplace/types.ts +191 -0
- package/src/extensibility/plugins/marketplace-auto-update.ts +49 -0
- package/src/extensibility/plugins/parser.ts +105 -0
- package/src/extensibility/plugins/types.ts +194 -0
- package/src/extensibility/shared-events.ts +343 -0
- package/src/extensibility/skills.ts +312 -0
- package/src/extensibility/slash-commands.ts +227 -0
- package/src/extensibility/tool-proxy.ts +25 -0
- package/src/extensibility/typebox.ts +418 -0
- package/src/extensibility/utils.ts +44 -0
- package/src/goals/index.ts +3 -0
- package/src/goals/runtime.ts +528 -0
- package/src/goals/state.ts +37 -0
- package/src/goals/tools/goal-tool.ts +251 -0
- package/src/hindsight/backend.ts +354 -0
- package/src/hindsight/bank.ts +156 -0
- package/src/hindsight/client.ts +598 -0
- package/src/hindsight/config.ts +175 -0
- package/src/hindsight/content.ts +210 -0
- package/src/hindsight/index.ts +8 -0
- package/src/hindsight/mental-models.ts +429 -0
- package/src/hindsight/seeds.json +32 -0
- package/src/hindsight/state.ts +488 -0
- package/src/hindsight/transcript.ts +71 -0
- package/src/index.ts +59 -0
- package/src/internal-urls/agent-protocol.ts +146 -0
- package/src/internal-urls/artifact-protocol.ts +107 -0
- package/src/internal-urls/docs-index.generated.ts +106 -0
- package/src/internal-urls/history-protocol.ts +113 -0
- package/src/internal-urls/index.ts +25 -0
- package/src/internal-urls/issue-pr-protocol.ts +584 -0
- package/src/internal-urls/json-query.ts +126 -0
- package/src/internal-urls/local-protocol.ts +287 -0
- package/src/internal-urls/mcp-protocol.ts +151 -0
- package/src/internal-urls/memory-protocol.ts +169 -0
- package/src/internal-urls/omp-protocol.ts +93 -0
- package/src/internal-urls/parse.ts +72 -0
- package/src/internal-urls/registry-helpers.ts +25 -0
- package/src/internal-urls/router.ts +105 -0
- package/src/internal-urls/rule-protocol.ts +45 -0
- package/src/internal-urls/skill-protocol.ts +96 -0
- package/src/internal-urls/types.ts +152 -0
- package/src/internal-urls/vault-protocol.ts +936 -0
- package/src/irc/bus.ts +292 -0
- package/src/lib/xai-http.ts +124 -0
- package/src/lsp/client.ts +1193 -0
- package/src/lsp/clients/biome-client.ts +264 -0
- package/src/lsp/clients/index.ts +50 -0
- package/src/lsp/clients/lsp-linter-client.ts +93 -0
- package/src/lsp/clients/swiftlint-client.ts +120 -0
- package/src/lsp/config.ts +502 -0
- package/src/lsp/defaults.json +493 -0
- package/src/lsp/diagnostics-ledger.ts +51 -0
- package/src/lsp/edits.ts +267 -0
- package/src/lsp/index.ts +2477 -0
- package/src/lsp/lspmux.ts +233 -0
- package/src/lsp/render.ts +694 -0
- package/src/lsp/startup-events.ts +13 -0
- package/src/lsp/types.ts +455 -0
- package/src/lsp/utils.ts +718 -0
- package/src/main.ts +1325 -0
- package/src/mcp/client.ts +484 -0
- package/src/mcp/config-writer.ts +225 -0
- package/src/mcp/config.ts +365 -0
- package/src/mcp/index.ts +29 -0
- package/src/mcp/json-rpc.ts +122 -0
- package/src/mcp/loader.ts +124 -0
- package/src/mcp/manager.ts +1275 -0
- package/src/mcp/oauth-discovery.ts +442 -0
- package/src/mcp/oauth-flow.ts +442 -0
- package/src/mcp/render.ts +132 -0
- package/src/mcp/smithery-auth.ts +104 -0
- package/src/mcp/smithery-connect.ts +145 -0
- package/src/mcp/smithery-registry.ts +477 -0
- package/src/mcp/timeout.ts +59 -0
- package/src/mcp/tool-bridge.ts +426 -0
- package/src/mcp/tool-cache.ts +117 -0
- package/src/mcp/transports/http.ts +519 -0
- package/src/mcp/transports/index.ts +6 -0
- package/src/mcp/transports/stdio.ts +528 -0
- package/src/mcp/types.ts +423 -0
- package/src/memories/index.ts +1150 -0
- package/src/memories/storage.ts +577 -0
- package/src/memory-backend/index.ts +18 -0
- package/src/memory-backend/local-backend.ts +39 -0
- package/src/memory-backend/off-backend.ts +25 -0
- package/src/memory-backend/resolve.ts +25 -0
- package/src/memory-backend/runtime.ts +66 -0
- package/src/memory-backend/types.ts +166 -0
- package/src/mnemopi/backend.ts +547 -0
- package/src/mnemopi/config.ts +160 -0
- package/src/mnemopi/index.ts +3 -0
- package/src/mnemopi/state.ts +584 -0
- package/src/modes/acp/acp-agent.ts +2407 -0
- package/src/modes/acp/acp-client-bridge.ts +154 -0
- package/src/modes/acp/acp-event-mapper.ts +929 -0
- package/src/modes/acp/acp-mode.ts +23 -0
- package/src/modes/acp/index.ts +2 -0
- package/src/modes/acp/terminal-auth.ts +37 -0
- package/src/modes/components/agent-dashboard.ts +1206 -0
- package/src/modes/components/agent-hub.ts +1071 -0
- package/src/modes/components/assistant-message.ts +307 -0
- package/src/modes/components/bash-execution.ts +220 -0
- package/src/modes/components/bordered-loader.ts +41 -0
- package/src/modes/components/branch-summary-message.ts +45 -0
- package/src/modes/components/btw-panel.ts +104 -0
- package/src/modes/components/chat-block.ts +111 -0
- package/src/modes/components/compaction-summary-message.ts +87 -0
- package/src/modes/components/copy-selector.ts +206 -0
- package/src/modes/components/countdown-timer.ts +75 -0
- package/src/modes/components/custom-editor.ts +398 -0
- package/src/modes/components/custom-message.ts +63 -0
- package/src/modes/components/diff.ts +277 -0
- package/src/modes/components/dynamic-border.ts +34 -0
- package/src/modes/components/error-banner.ts +33 -0
- package/src/modes/components/eval-execution.ts +158 -0
- package/src/modes/components/execution-shared.ts +101 -0
- package/src/modes/components/extensions/extension-dashboard.ts +399 -0
- package/src/modes/components/extensions/extension-list.ts +502 -0
- package/src/modes/components/extensions/index.ts +9 -0
- package/src/modes/components/extensions/inspector-panel.ts +317 -0
- package/src/modes/components/extensions/state-manager.ts +627 -0
- package/src/modes/components/extensions/types.ts +186 -0
- package/src/modes/components/footer.ts +274 -0
- package/src/modes/components/history-search.ts +280 -0
- package/src/modes/components/hook-editor.ts +167 -0
- package/src/modes/components/hook-input.ts +87 -0
- package/src/modes/components/hook-message.ts +66 -0
- package/src/modes/components/hook-selector.ts +660 -0
- package/src/modes/components/index.ts +38 -0
- package/src/modes/components/keybinding-hints.ts +65 -0
- package/src/modes/components/late-diagnostics-message.ts +60 -0
- package/src/modes/components/login-dialog.ts +164 -0
- package/src/modes/components/mcp-add-wizard.ts +1340 -0
- package/src/modes/components/message-frame.ts +88 -0
- package/src/modes/components/model-selector.ts +1271 -0
- package/src/modes/components/oauth-selector.ts +368 -0
- package/src/modes/components/omfg-panel.ts +141 -0
- package/src/modes/components/overlay-box.ts +108 -0
- package/src/modes/components/plan-review-overlay.ts +820 -0
- package/src/modes/components/plan-toc.ts +138 -0
- package/src/modes/components/plugin-selector.ts +95 -0
- package/src/modes/components/plugin-settings.ts +722 -0
- package/src/modes/components/queue-mode-selector.ts +56 -0
- package/src/modes/components/read-tool-group.ts +670 -0
- package/src/modes/components/segment-track.ts +52 -0
- package/src/modes/components/session-selector.ts +625 -0
- package/src/modes/components/settings-defs.ts +189 -0
- package/src/modes/components/settings-selector.ts +651 -0
- package/src/modes/components/show-images-selector.ts +45 -0
- package/src/modes/components/skill-message.ts +89 -0
- package/src/modes/components/status-line/component.ts +869 -0
- package/src/modes/components/status-line/context-thresholds.ts +79 -0
- package/src/modes/components/status-line/git-utils.ts +42 -0
- package/src/modes/components/status-line/index.ts +5 -0
- package/src/modes/components/status-line/presets.ts +106 -0
- package/src/modes/components/status-line/segments.ts +584 -0
- package/src/modes/components/status-line/separators.ts +55 -0
- package/src/modes/components/status-line/token-rate.ts +66 -0
- package/src/modes/components/status-line/types.ts +108 -0
- package/src/modes/components/theme-selector.ts +63 -0
- package/src/modes/components/thinking-selector.ts +52 -0
- package/src/modes/components/tiny-title-download-progress.ts +90 -0
- package/src/modes/components/tips.txt +19 -0
- package/src/modes/components/todo-reminder.ts +38 -0
- package/src/modes/components/tool-execution.ts +1024 -0
- package/src/modes/components/transcript-container.ts +608 -0
- package/src/modes/components/tree-selector.ts +978 -0
- package/src/modes/components/ttsr-notification.ts +122 -0
- package/src/modes/components/user-message-selector.ts +227 -0
- package/src/modes/components/user-message.ts +66 -0
- package/src/modes/components/visual-truncate.ts +63 -0
- package/src/modes/components/welcome.ts +493 -0
- package/src/modes/controllers/btw-controller.ts +105 -0
- package/src/modes/controllers/command-controller-shared.ts +109 -0
- package/src/modes/controllers/command-controller.ts +1566 -0
- package/src/modes/controllers/event-controller.ts +1054 -0
- package/src/modes/controllers/extension-ui-controller.ts +886 -0
- package/src/modes/controllers/input-controller.ts +1073 -0
- package/src/modes/controllers/mcp-command-controller.ts +2017 -0
- package/src/modes/controllers/omfg-controller.ts +283 -0
- package/src/modes/controllers/omfg-rule.ts +647 -0
- package/src/modes/controllers/selector-controller.ts +1108 -0
- package/src/modes/controllers/ssh-command-controller.ts +384 -0
- package/src/modes/controllers/streaming-reveal.ts +279 -0
- package/src/modes/controllers/tan-command-controller.ts +173 -0
- package/src/modes/controllers/todo-command-controller.ts +485 -0
- package/src/modes/data/emojis.json +1 -0
- package/src/modes/emoji-autocomplete.ts +285 -0
- package/src/modes/gradient-highlight.ts +87 -0
- package/src/modes/image-references.ts +117 -0
- package/src/modes/index.ts +17 -0
- package/src/modes/interactive-mode.ts +3370 -0
- package/src/modes/internal-url-autocomplete.ts +143 -0
- package/src/modes/loop-limit.ts +140 -0
- package/src/modes/magic-keywords.ts +20 -0
- package/src/modes/markdown-prose.ts +247 -0
- package/src/modes/oauth-manual-input.ts +69 -0
- package/src/modes/orchestrate.ts +42 -0
- package/src/modes/print-mode.ts +126 -0
- package/src/modes/prompt-action-autocomplete.ts +260 -0
- package/src/modes/rpc/host-tools.ts +186 -0
- package/src/modes/rpc/host-uris.ts +235 -0
- package/src/modes/rpc/rpc-client.ts +963 -0
- package/src/modes/rpc/rpc-mode.ts +947 -0
- package/src/modes/rpc/rpc-subagents.ts +265 -0
- package/src/modes/rpc/rpc-types.ts +458 -0
- package/src/modes/runtime-init.ts +116 -0
- package/src/modes/session-observer-registry.ts +146 -0
- package/src/modes/setup-version.ts +11 -0
- package/src/modes/setup-wizard/index.ts +99 -0
- package/src/modes/setup-wizard/lazy.ts +16 -0
- package/src/modes/setup-wizard/scenes/glyph.ts +96 -0
- package/src/modes/setup-wizard/scenes/outro.ts +35 -0
- package/src/modes/setup-wizard/scenes/providers.ts +69 -0
- package/src/modes/setup-wizard/scenes/sign-in.ts +205 -0
- package/src/modes/setup-wizard/scenes/splash.ts +201 -0
- package/src/modes/setup-wizard/scenes/theme.ts +299 -0
- package/src/modes/setup-wizard/scenes/types.ts +48 -0
- package/src/modes/setup-wizard/scenes/web-search.ts +129 -0
- package/src/modes/setup-wizard/wizard-overlay.ts +275 -0
- package/src/modes/shared.ts +47 -0
- package/src/modes/theme/dark.json +95 -0
- package/src/modes/theme/defaults/alabaster.json +93 -0
- package/src/modes/theme/defaults/amethyst.json +96 -0
- package/src/modes/theme/defaults/anthracite.json +93 -0
- package/src/modes/theme/defaults/basalt.json +91 -0
- package/src/modes/theme/defaults/birch.json +95 -0
- package/src/modes/theme/defaults/dark-abyss.json +91 -0
- package/src/modes/theme/defaults/dark-arctic.json +104 -0
- package/src/modes/theme/defaults/dark-aurora.json +95 -0
- package/src/modes/theme/defaults/dark-catppuccin.json +107 -0
- package/src/modes/theme/defaults/dark-cavern.json +91 -0
- package/src/modes/theme/defaults/dark-copper.json +95 -0
- package/src/modes/theme/defaults/dark-cosmos.json +90 -0
- package/src/modes/theme/defaults/dark-cyberpunk.json +102 -0
- package/src/modes/theme/defaults/dark-dracula.json +98 -0
- package/src/modes/theme/defaults/dark-eclipse.json +91 -0
- package/src/modes/theme/defaults/dark-ember.json +95 -0
- package/src/modes/theme/defaults/dark-equinox.json +90 -0
- package/src/modes/theme/defaults/dark-forest.json +96 -0
- package/src/modes/theme/defaults/dark-github.json +105 -0
- package/src/modes/theme/defaults/dark-gruvbox.json +112 -0
- package/src/modes/theme/defaults/dark-lavender.json +95 -0
- package/src/modes/theme/defaults/dark-lunar.json +89 -0
- package/src/modes/theme/defaults/dark-midnight.json +95 -0
- package/src/modes/theme/defaults/dark-monochrome.json +94 -0
- package/src/modes/theme/defaults/dark-monokai.json +98 -0
- package/src/modes/theme/defaults/dark-nebula.json +90 -0
- package/src/modes/theme/defaults/dark-nord.json +97 -0
- package/src/modes/theme/defaults/dark-ocean.json +101 -0
- package/src/modes/theme/defaults/dark-one.json +100 -0
- package/src/modes/theme/defaults/dark-poimandres.json +142 -0
- package/src/modes/theme/defaults/dark-rainforest.json +91 -0
- package/src/modes/theme/defaults/dark-reef.json +91 -0
- package/src/modes/theme/defaults/dark-retro.json +92 -0
- package/src/modes/theme/defaults/dark-rose-pine.json +96 -0
- package/src/modes/theme/defaults/dark-sakura.json +95 -0
- package/src/modes/theme/defaults/dark-slate.json +95 -0
- package/src/modes/theme/defaults/dark-solarized.json +97 -0
- package/src/modes/theme/defaults/dark-solstice.json +90 -0
- package/src/modes/theme/defaults/dark-starfall.json +91 -0
- package/src/modes/theme/defaults/dark-sunset.json +99 -0
- package/src/modes/theme/defaults/dark-swamp.json +90 -0
- package/src/modes/theme/defaults/dark-synthwave.json +103 -0
- package/src/modes/theme/defaults/dark-taiga.json +91 -0
- package/src/modes/theme/defaults/dark-terminal.json +95 -0
- package/src/modes/theme/defaults/dark-tokyo-night.json +101 -0
- package/src/modes/theme/defaults/dark-tundra.json +91 -0
- package/src/modes/theme/defaults/dark-twilight.json +91 -0
- package/src/modes/theme/defaults/dark-volcanic.json +91 -0
- package/src/modes/theme/defaults/graphite.json +92 -0
- package/src/modes/theme/defaults/index.ts +199 -0
- package/src/modes/theme/defaults/light-arctic.json +107 -0
- package/src/modes/theme/defaults/light-aurora-day.json +91 -0
- package/src/modes/theme/defaults/light-canyon.json +91 -0
- package/src/modes/theme/defaults/light-catppuccin.json +106 -0
- package/src/modes/theme/defaults/light-cirrus.json +90 -0
- package/src/modes/theme/defaults/light-coral.json +95 -0
- package/src/modes/theme/defaults/light-cyberpunk.json +96 -0
- package/src/modes/theme/defaults/light-dawn.json +90 -0
- package/src/modes/theme/defaults/light-dunes.json +91 -0
- package/src/modes/theme/defaults/light-eucalyptus.json +95 -0
- package/src/modes/theme/defaults/light-forest.json +100 -0
- package/src/modes/theme/defaults/light-frost.json +95 -0
- package/src/modes/theme/defaults/light-github.json +115 -0
- package/src/modes/theme/defaults/light-glacier.json +91 -0
- package/src/modes/theme/defaults/light-gruvbox.json +108 -0
- package/src/modes/theme/defaults/light-haze.json +90 -0
- package/src/modes/theme/defaults/light-honeycomb.json +95 -0
- package/src/modes/theme/defaults/light-lagoon.json +91 -0
- package/src/modes/theme/defaults/light-lavender.json +95 -0
- package/src/modes/theme/defaults/light-meadow.json +91 -0
- package/src/modes/theme/defaults/light-mint.json +95 -0
- package/src/modes/theme/defaults/light-monochrome.json +101 -0
- package/src/modes/theme/defaults/light-ocean.json +99 -0
- package/src/modes/theme/defaults/light-one.json +99 -0
- package/src/modes/theme/defaults/light-opal.json +91 -0
- package/src/modes/theme/defaults/light-orchard.json +91 -0
- package/src/modes/theme/defaults/light-paper.json +95 -0
- package/src/modes/theme/defaults/light-poimandres.json +142 -0
- package/src/modes/theme/defaults/light-prism.json +90 -0
- package/src/modes/theme/defaults/light-retro.json +98 -0
- package/src/modes/theme/defaults/light-sand.json +95 -0
- package/src/modes/theme/defaults/light-savanna.json +91 -0
- package/src/modes/theme/defaults/light-solarized.json +102 -0
- package/src/modes/theme/defaults/light-soleil.json +90 -0
- package/src/modes/theme/defaults/light-sunset.json +99 -0
- package/src/modes/theme/defaults/light-synthwave.json +98 -0
- package/src/modes/theme/defaults/light-tokyo-night.json +111 -0
- package/src/modes/theme/defaults/light-wetland.json +91 -0
- package/src/modes/theme/defaults/light-zenith.json +89 -0
- package/src/modes/theme/defaults/limestone.json +94 -0
- package/src/modes/theme/defaults/mahogany.json +97 -0
- package/src/modes/theme/defaults/marble.json +93 -0
- package/src/modes/theme/defaults/obsidian.json +91 -0
- package/src/modes/theme/defaults/onyx.json +91 -0
- package/src/modes/theme/defaults/pearl.json +93 -0
- package/src/modes/theme/defaults/porcelain.json +91 -0
- package/src/modes/theme/defaults/quartz.json +96 -0
- package/src/modes/theme/defaults/sandstone.json +95 -0
- package/src/modes/theme/defaults/titanium.json +90 -0
- package/src/modes/theme/light.json +93 -0
- package/src/modes/theme/mermaid-cache.ts +29 -0
- package/src/modes/theme/shimmer.ts +235 -0
- package/src/modes/theme/theme-schema.json +459 -0
- package/src/modes/theme/theme.ts +2676 -0
- package/src/modes/turn-budget.ts +31 -0
- package/src/modes/types.ts +359 -0
- package/src/modes/ultrathink.ts +41 -0
- package/src/modes/utils/context-usage.ts +339 -0
- package/src/modes/utils/copy-targets.ts +360 -0
- package/src/modes/utils/hotkeys-markdown.ts +61 -0
- package/src/modes/utils/keybinding-matchers.ts +51 -0
- package/src/modes/utils/tools-markdown.ts +27 -0
- package/src/modes/utils/ui-helpers.ts +801 -0
- package/src/modes/workflow.ts +42 -0
- package/src/plan-mode/approved-plan.ts +186 -0
- package/src/plan-mode/plan-handoff.ts +37 -0
- package/src/plan-mode/plan-protection.ts +31 -0
- package/src/plan-mode/state.ts +6 -0
- package/src/priority.json +41 -0
- package/src/prompts/agents/designer.md +66 -0
- package/src/prompts/agents/explore.md +58 -0
- package/src/prompts/agents/frontmatter.md +11 -0
- package/src/prompts/agents/init.md +33 -0
- package/src/prompts/agents/librarian.md +119 -0
- package/src/prompts/agents/oracle.md +55 -0
- package/src/prompts/agents/plan.md +48 -0
- package/src/prompts/agents/reviewer.md +140 -0
- package/src/prompts/agents/task.md +16 -0
- package/src/prompts/ci-green-request.md +36 -0
- package/src/prompts/dry-balance-bench.md +8 -0
- package/src/prompts/goals/goal-budget-limit.md +16 -0
- package/src/prompts/goals/goal-continuation.md +28 -0
- package/src/prompts/goals/goal-mode-active.md +23 -0
- package/src/prompts/memories/consolidation.md +30 -0
- package/src/prompts/memories/read-path.md +11 -0
- package/src/prompts/memories/stage_one_input.md +6 -0
- package/src/prompts/memories/stage_one_system.md +21 -0
- package/src/prompts/review-custom-request.md +22 -0
- package/src/prompts/review-headless-request.md +16 -0
- package/src/prompts/review-request.md +69 -0
- package/src/prompts/steering/user-interjection.md +10 -0
- package/src/prompts/system/agent-creation-architect.md +50 -0
- package/src/prompts/system/agent-creation-user.md +6 -0
- package/src/prompts/system/auto-continue.md +1 -0
- package/src/prompts/system/auto-thinking-difficulty-local.md +14 -0
- package/src/prompts/system/auto-thinking-difficulty.md +12 -0
- package/src/prompts/system/background-tan-dispatch.md +8 -0
- package/src/prompts/system/btw-user.md +8 -0
- package/src/prompts/system/commit-message-system.md +14 -0
- package/src/prompts/system/custom-system-prompt.md +64 -0
- package/src/prompts/system/eager-todo.md +13 -0
- package/src/prompts/system/empty-stop-retry.md +6 -0
- package/src/prompts/system/irc-incoming.md +7 -0
- package/src/prompts/system/manual-continue.md +7 -0
- package/src/prompts/system/memory-consolidation-system.md +8 -0
- package/src/prompts/system/memory-extraction-system.md +26 -0
- package/src/prompts/system/omfg-user.md +50 -0
- package/src/prompts/system/orchestrate-notice.md +40 -0
- package/src/prompts/system/plan-mode-active.md +109 -0
- package/src/prompts/system/plan-mode-approved.md +25 -0
- package/src/prompts/system/plan-mode-compact-instructions.md +16 -0
- package/src/prompts/system/plan-mode-reference.md +11 -0
- package/src/prompts/system/plan-mode-subagent.md +33 -0
- package/src/prompts/system/plan-mode-tool-decision-reminder.md +9 -0
- package/src/prompts/system/project-prompt.md +52 -0
- package/src/prompts/system/subagent-system-prompt.md +64 -0
- package/src/prompts/system/subagent-user-prompt.md +3 -0
- package/src/prompts/system/subagent-yield-reminder.md +12 -0
- package/src/prompts/system/system-prompt.md +258 -0
- package/src/prompts/system/tiny-title-system.md +8 -0
- package/src/prompts/system/title-system.md +16 -0
- package/src/prompts/system/ttsr-interrupt.md +7 -0
- package/src/prompts/system/ttsr-tool-reminder.md +5 -0
- package/src/prompts/system/ultrathink-notice.md +3 -0
- package/src/prompts/system/web-search.md +25 -0
- package/src/prompts/system/workflow-notice.md +70 -0
- package/src/prompts/tools/apply-patch.md +65 -0
- package/src/prompts/tools/ask.md +30 -0
- package/src/prompts/tools/ast-edit.md +39 -0
- package/src/prompts/tools/ast-grep.md +42 -0
- package/src/prompts/tools/async-result.md +8 -0
- package/src/prompts/tools/bash.md +46 -0
- package/src/prompts/tools/browser.md +73 -0
- package/src/prompts/tools/checkpoint.md +16 -0
- package/src/prompts/tools/debug.md +34 -0
- package/src/prompts/tools/eval.md +92 -0
- package/src/prompts/tools/find.md +36 -0
- package/src/prompts/tools/github.md +21 -0
- package/src/prompts/tools/goal.md +18 -0
- package/src/prompts/tools/image-gen.md +7 -0
- package/src/prompts/tools/inspect-image-system.md +20 -0
- package/src/prompts/tools/inspect-image.md +32 -0
- package/src/prompts/tools/irc.md +59 -0
- package/src/prompts/tools/job.md +19 -0
- package/src/prompts/tools/lsp-late-diagnostic.md +8 -0
- package/src/prompts/tools/lsp.md +42 -0
- package/src/prompts/tools/memory-edit.md +8 -0
- package/src/prompts/tools/patch.md +70 -0
- package/src/prompts/tools/read.md +84 -0
- package/src/prompts/tools/recall.md +5 -0
- package/src/prompts/tools/reflect.md +5 -0
- package/src/prompts/tools/render-mermaid.md +9 -0
- package/src/prompts/tools/replace.md +30 -0
- package/src/prompts/tools/resolve.md +9 -0
- package/src/prompts/tools/retain.md +6 -0
- package/src/prompts/tools/rewind.md +13 -0
- package/src/prompts/tools/search-tool-bm25.md +32 -0
- package/src/prompts/tools/search.md +24 -0
- package/src/prompts/tools/ssh.md +31 -0
- package/src/prompts/tools/task-summary.md +17 -0
- package/src/prompts/tools/task.md +88 -0
- package/src/prompts/tools/todo.md +62 -0
- package/src/prompts/tools/web-search.md +10 -0
- package/src/prompts/tools/write.md +14 -0
- package/src/registry/agent-lifecycle.ts +218 -0
- package/src/registry/agent-registry.ts +151 -0
- package/src/sdk.ts +2558 -0
- package/src/secrets/index.ts +123 -0
- package/src/secrets/obfuscator.ts +298 -0
- package/src/secrets/regex.ts +21 -0
- package/src/session/agent-session.ts +10121 -0
- package/src/session/agent-storage.ts +455 -0
- package/src/session/artifacts.ts +135 -0
- package/src/session/auth-broker-config.ts +131 -0
- package/src/session/auth-storage.ts +29 -0
- package/src/session/blob-store.ts +255 -0
- package/src/session/client-bridge.ts +85 -0
- package/src/session/history-storage.ts +348 -0
- package/src/session/indexed-session-storage.ts +430 -0
- package/src/session/messages.ts +541 -0
- package/src/session/redis-session-storage.ts +170 -0
- package/src/session/session-dump-format.ts +209 -0
- package/src/session/session-history-format.ts +246 -0
- package/src/session/session-manager.ts +3676 -0
- package/src/session/session-storage.ts +529 -0
- package/src/session/shake-types.ts +43 -0
- package/src/session/sql-session-storage.ts +314 -0
- package/src/session/streaming-output.ts +1330 -0
- package/src/session/tool-choice-queue.ts +213 -0
- package/src/session/yield-queue.ts +173 -0
- package/src/slash-commands/acp-builtins.ts +70 -0
- package/src/slash-commands/builtin-registry.ts +1798 -0
- package/src/slash-commands/helpers/context-report.ts +39 -0
- package/src/slash-commands/helpers/format.ts +46 -0
- package/src/slash-commands/helpers/marketplace-manager.ts +25 -0
- package/src/slash-commands/helpers/mcp.ts +532 -0
- package/src/slash-commands/helpers/parse.ts +85 -0
- package/src/slash-commands/helpers/ssh.ts +195 -0
- package/src/slash-commands/helpers/stats-dashboard.ts +85 -0
- package/src/slash-commands/helpers/todo.ts +279 -0
- package/src/slash-commands/helpers/usage-report.ts +95 -0
- package/src/slash-commands/marketplace-install-parser.ts +99 -0
- package/src/slash-commands/types.ts +135 -0
- package/src/ssh/config-writer.ts +183 -0
- package/src/ssh/connection-manager.ts +509 -0
- package/src/ssh/ssh-executor.ts +189 -0
- package/src/ssh/sshfs-mount.ts +140 -0
- package/src/ssh/utils.ts +8 -0
- package/src/stt/downloader.ts +71 -0
- package/src/stt/index.ts +3 -0
- package/src/stt/recorder.ts +351 -0
- package/src/stt/setup.ts +52 -0
- package/src/stt/stt-controller.ts +160 -0
- package/src/stt/transcribe.py +70 -0
- package/src/stt/transcriber.ts +91 -0
- package/src/stubs/natives/index.ts +814 -0
- package/src/stubs/natives/package.json +7 -0
- package/src/stubs/tui/index.ts +282 -0
- package/src/stubs/tui/package.json +7 -0
- package/src/system-prompt.ts +611 -0
- package/src/task/agents.ts +167 -0
- package/src/task/commands.ts +132 -0
- package/src/task/discovery.ts +122 -0
- package/src/task/executor.ts +2133 -0
- package/src/task/index.ts +1419 -0
- package/src/task/name-generator.ts +1577 -0
- package/src/task/omp-command.ts +26 -0
- package/src/task/output-manager.ts +88 -0
- package/src/task/parallel.ts +116 -0
- package/src/task/render.ts +1381 -0
- package/src/task/repair-args.ts +129 -0
- package/src/task/subprocess-tool-registry.ts +88 -0
- package/src/task/types.ts +336 -0
- package/src/task/worktree.ts +514 -0
- package/src/telemetry-export.ts +144 -0
- package/src/thinking.ts +167 -0
- package/src/tiny/compiled-runtime.ts +179 -0
- package/src/tiny/device.ts +111 -0
- package/src/tiny/dtype.ts +101 -0
- package/src/tiny/models.ts +242 -0
- package/src/tiny/text.ts +165 -0
- package/src/tiny/title-client.ts +543 -0
- package/src/tiny/title-protocol.ts +56 -0
- package/src/tiny/worker.ts +568 -0
- package/src/tool-discovery/mode.ts +24 -0
- package/src/tool-discovery/tool-index.ts +256 -0
- package/src/tools/approval.ts +189 -0
- package/src/tools/archive-reader.ts +721 -0
- package/src/tools/ask.ts +928 -0
- package/src/tools/ast-edit.ts +642 -0
- package/src/tools/ast-grep.ts +452 -0
- package/src/tools/auto-generated-guard.ts +322 -0
- package/src/tools/bash-command-fixup.ts +37 -0
- package/src/tools/bash-interactive.ts +408 -0
- package/src/tools/bash-interceptor.ts +67 -0
- package/src/tools/bash-pty-selection.ts +14 -0
- package/src/tools/bash-skill-urls.ts +248 -0
- package/src/tools/bash.ts +1386 -0
- package/src/tools/browser/attach.ts +175 -0
- package/src/tools/browser/launch.ts +660 -0
- package/src/tools/browser/readable.ts +112 -0
- package/src/tools/browser/registry.ts +197 -0
- package/src/tools/browser/render.ts +216 -0
- package/src/tools/browser/tab-protocol.ts +105 -0
- package/src/tools/browser/tab-supervisor.ts +628 -0
- package/src/tools/browser/tab-worker-entry.ts +21 -0
- package/src/tools/browser/tab-worker.ts +1226 -0
- package/src/tools/browser.ts +343 -0
- package/src/tools/checkpoint.ts +136 -0
- package/src/tools/conflict-detect.ts +718 -0
- package/src/tools/context.ts +39 -0
- package/src/tools/debug.ts +1067 -0
- package/src/tools/eval-backends.ts +27 -0
- package/src/tools/eval-render.ts +752 -0
- package/src/tools/eval.ts +577 -0
- package/src/tools/fetch.ts +1926 -0
- package/src/tools/file-recorder.ts +35 -0
- package/src/tools/find.ts +609 -0
- package/src/tools/fs-cache-invalidation.ts +28 -0
- package/src/tools/gh-cache-invalidation.ts +255 -0
- package/src/tools/gh-format.ts +12 -0
- package/src/tools/gh-renderer.ts +481 -0
- package/src/tools/gh.ts +3720 -0
- package/src/tools/github-cache.ts +637 -0
- package/src/tools/grouped-file-output.ts +210 -0
- package/src/tools/image-gen.ts +1517 -0
- package/src/tools/index.ts +599 -0
- package/src/tools/inspect-image-renderer.ts +132 -0
- package/src/tools/inspect-image.ts +174 -0
- package/src/tools/irc.ts +723 -0
- package/src/tools/job.ts +557 -0
- package/src/tools/json-tree.ts +243 -0
- package/src/tools/jtd-to-json-schema.ts +219 -0
- package/src/tools/jtd-to-typescript.ts +136 -0
- package/src/tools/jtd-utils.ts +102 -0
- package/src/tools/list-limit.ts +40 -0
- package/src/tools/match-line-format.ts +20 -0
- package/src/tools/memory-edit.ts +59 -0
- package/src/tools/memory-recall.ts +100 -0
- package/src/tools/memory-reflect.ts +88 -0
- package/src/tools/memory-render.ts +202 -0
- package/src/tools/memory-retain.ts +91 -0
- package/src/tools/output-meta.ts +754 -0
- package/src/tools/output-schema-validator.ts +132 -0
- package/src/tools/path-utils.ts +1054 -0
- package/src/tools/plan-mode-guard.ts +108 -0
- package/src/tools/puppeteer/00_stealth_tampering.txt +63 -0
- package/src/tools/puppeteer/01_stealth_activity.txt +20 -0
- package/src/tools/puppeteer/02_stealth_hairline.txt +11 -0
- package/src/tools/puppeteer/03_stealth_botd.txt +384 -0
- package/src/tools/puppeteer/04_stealth_iframe.txt +81 -0
- package/src/tools/puppeteer/05_stealth_webgl.txt +75 -0
- package/src/tools/puppeteer/06_stealth_screen.txt +72 -0
- package/src/tools/puppeteer/07_stealth_fonts.txt +97 -0
- package/src/tools/puppeteer/08_stealth_audio.txt +51 -0
- package/src/tools/puppeteer/09_stealth_locale.txt +46 -0
- package/src/tools/puppeteer/10_stealth_plugins.txt +206 -0
- package/src/tools/puppeteer/11_stealth_hardware.txt +8 -0
- package/src/tools/puppeteer/12_stealth_codecs.txt +40 -0
- package/src/tools/puppeteer/13_stealth_worker.txt +74 -0
- package/src/tools/read.ts +2929 -0
- package/src/tools/render-mermaid.ts +69 -0
- package/src/tools/render-utils.ts +838 -0
- package/src/tools/renderers.ts +77 -0
- package/src/tools/report-tool-issue.ts +534 -0
- package/src/tools/resolve.ts +276 -0
- package/src/tools/review.ts +253 -0
- package/src/tools/search-tool-bm25.ts +351 -0
- package/src/tools/search.ts +1580 -0
- package/src/tools/sqlite-reader.ts +828 -0
- package/src/tools/ssh.ts +349 -0
- package/src/tools/todo.ts +982 -0
- package/src/tools/tool-errors.ts +62 -0
- package/src/tools/tool-result.ts +94 -0
- package/src/tools/tool-timeouts.ts +30 -0
- package/src/tools/tts.ts +133 -0
- package/src/tools/write.ts +1217 -0
- package/src/tools/yield.ts +269 -0
- package/src/tui/code-cell.ts +216 -0
- package/src/tui/file-list.ts +55 -0
- package/src/tui/hyperlink.ts +175 -0
- package/src/tui/index.ts +12 -0
- package/src/tui/output-block.ts +240 -0
- package/src/tui/status-line.ts +54 -0
- package/src/tui/tree-list.ts +84 -0
- package/src/tui/types.ts +15 -0
- package/src/tui/utils.ts +103 -0
- package/src/utils/block-context.ts +312 -0
- package/src/utils/changelog.ts +132 -0
- package/src/utils/clipboard.ts +193 -0
- package/src/utils/command-args.ts +76 -0
- package/src/utils/commit-message-generator.ts +151 -0
- package/src/utils/edit-mode.ts +41 -0
- package/src/utils/enhanced-paste.ts +230 -0
- package/src/utils/event-bus.ts +33 -0
- package/src/utils/external-editor.ts +65 -0
- package/src/utils/file-display-mode.ts +45 -0
- package/src/utils/file-mentions.ts +281 -0
- package/src/utils/git.ts +1833 -0
- package/src/utils/image-loading.ts +132 -0
- package/src/utils/image-resize.ts +309 -0
- package/src/utils/jj.ts +248 -0
- package/src/utils/lang-from-path.ts +239 -0
- package/src/utils/markit.ts +89 -0
- package/src/utils/open.ts +55 -0
- package/src/utils/session-color.ts +68 -0
- package/src/utils/shell-snapshot.ts +187 -0
- package/src/utils/sixel.ts +69 -0
- package/src/utils/title-generator.ts +373 -0
- package/src/utils/tool-choice.ts +33 -0
- package/src/utils/tools-manager.ts +363 -0
- package/src/web/kagi.ts +305 -0
- package/src/web/parallel.ts +353 -0
- package/src/web/scrapers/artifacthub.ts +207 -0
- package/src/web/scrapers/arxiv.ts +83 -0
- package/src/web/scrapers/aur.ts +162 -0
- package/src/web/scrapers/biorxiv.ts +133 -0
- package/src/web/scrapers/bluesky.ts +262 -0
- package/src/web/scrapers/brew.ts +172 -0
- package/src/web/scrapers/cheatsh.ts +68 -0
- package/src/web/scrapers/chocolatey.ts +196 -0
- package/src/web/scrapers/choosealicense.ts +95 -0
- package/src/web/scrapers/cisa-kev.ts +87 -0
- package/src/web/scrapers/clojars.ts +154 -0
- package/src/web/scrapers/coingecko.ts +177 -0
- package/src/web/scrapers/crates-io.ts +97 -0
- package/src/web/scrapers/crossref.ts +136 -0
- package/src/web/scrapers/devto.ts +147 -0
- package/src/web/scrapers/discogs.ts +306 -0
- package/src/web/scrapers/discourse.ts +197 -0
- package/src/web/scrapers/dockerhub.ts +138 -0
- package/src/web/scrapers/docs-rs.ts +653 -0
- package/src/web/scrapers/fdroid.ts +134 -0
- package/src/web/scrapers/firefox-addons.ts +191 -0
- package/src/web/scrapers/flathub.ts +223 -0
- package/src/web/scrapers/github-gist.ts +58 -0
- package/src/web/scrapers/github.ts +704 -0
- package/src/web/scrapers/gitlab.ts +401 -0
- package/src/web/scrapers/go-pkg.ts +266 -0
- package/src/web/scrapers/hackage.ts +140 -0
- package/src/web/scrapers/hackernews.ts +189 -0
- package/src/web/scrapers/hex.ts +105 -0
- package/src/web/scrapers/huggingface.ts +321 -0
- package/src/web/scrapers/iacr.ts +89 -0
- package/src/web/scrapers/index.ts +252 -0
- package/src/web/scrapers/jetbrains-marketplace.ts +159 -0
- package/src/web/scrapers/lemmy.ts +203 -0
- package/src/web/scrapers/lobsters.ts +175 -0
- package/src/web/scrapers/mastodon.ts +292 -0
- package/src/web/scrapers/maven.ts +138 -0
- package/src/web/scrapers/mdn.ts +173 -0
- package/src/web/scrapers/metacpan.ts +222 -0
- package/src/web/scrapers/musicbrainz.ts +250 -0
- package/src/web/scrapers/npm.ts +98 -0
- package/src/web/scrapers/nuget.ts +183 -0
- package/src/web/scrapers/nvd.ts +222 -0
- package/src/web/scrapers/ollama.ts +239 -0
- package/src/web/scrapers/open-vsx.ts +106 -0
- package/src/web/scrapers/opencorporates.ts +292 -0
- package/src/web/scrapers/openlibrary.ts +336 -0
- package/src/web/scrapers/orcid.ts +286 -0
- package/src/web/scrapers/osv.ts +176 -0
- package/src/web/scrapers/packagist.ts +160 -0
- package/src/web/scrapers/pub-dev.ts +143 -0
- package/src/web/scrapers/pubmed.ts +211 -0
- package/src/web/scrapers/pypi.ts +112 -0
- package/src/web/scrapers/rawg.ts +110 -0
- package/src/web/scrapers/readthedocs.ts +120 -0
- package/src/web/scrapers/reddit.ts +95 -0
- package/src/web/scrapers/repology.ts +251 -0
- package/src/web/scrapers/rfc.ts +201 -0
- package/src/web/scrapers/rubygems.ts +103 -0
- package/src/web/scrapers/searchcode.ts +189 -0
- package/src/web/scrapers/sec-edgar.ts +261 -0
- package/src/web/scrapers/semantic-scholar.ts +171 -0
- package/src/web/scrapers/snapcraft.ts +187 -0
- package/src/web/scrapers/sourcegraph.ts +336 -0
- package/src/web/scrapers/spdx.ts +108 -0
- package/src/web/scrapers/spotify.ts +198 -0
- package/src/web/scrapers/stackoverflow.ts +120 -0
- package/src/web/scrapers/terraform.ts +277 -0
- package/src/web/scrapers/tldr.ts +47 -0
- package/src/web/scrapers/twitter.ts +94 -0
- package/src/web/scrapers/types.ts +397 -0
- package/src/web/scrapers/utils.ts +109 -0
- package/src/web/scrapers/vimeo.ts +133 -0
- package/src/web/scrapers/vscode-marketplace.ts +187 -0
- package/src/web/scrapers/w3c.ts +156 -0
- package/src/web/scrapers/wikidata.ts +344 -0
- package/src/web/scrapers/wikipedia.ts +84 -0
- package/src/web/scrapers/youtube.ts +325 -0
- package/src/web/search/index.ts +292 -0
- package/src/web/search/provider.ts +157 -0
- package/src/web/search/providers/anthropic.ts +318 -0
- package/src/web/search/providers/base.ts +89 -0
- package/src/web/search/providers/brave.ts +152 -0
- package/src/web/search/providers/codex.ts +591 -0
- package/src/web/search/providers/exa.ts +400 -0
- package/src/web/search/providers/gemini.ts +460 -0
- package/src/web/search/providers/jina.ts +111 -0
- package/src/web/search/providers/kagi.ts +86 -0
- package/src/web/search/providers/kimi.ts +196 -0
- package/src/web/search/providers/parallel.ts +225 -0
- package/src/web/search/providers/perplexity.ts +730 -0
- package/src/web/search/providers/searxng.ts +313 -0
- package/src/web/search/providers/synthetic.ts +114 -0
- package/src/web/search/providers/tavily.ts +176 -0
- package/src/web/search/providers/utils.ts +128 -0
- package/src/web/search/providers/zai.ts +333 -0
- package/src/web/search/render.ts +262 -0
- package/src/web/search/types.ts +482 -0
- package/src/web/search/utils.ts +17 -0
- package/src/workspace-tree.ts +286 -0
|
@@ -0,0 +1,1441 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import * as timers from "node:timers/promises";
|
|
3
|
+
import { logger, ptree, untilAborted } from "@oh-my-pi/pi-utils";
|
|
4
|
+
import { NON_INTERACTIVE_ENV } from "../exec/non-interactive-env";
|
|
5
|
+
import { DapClient } from "./client";
|
|
6
|
+
import type {
|
|
7
|
+
DapAttachArguments,
|
|
8
|
+
DapAttachSessionOptions,
|
|
9
|
+
DapBreakpoint,
|
|
10
|
+
DapBreakpointRecord,
|
|
11
|
+
DapCapabilities,
|
|
12
|
+
DapContinueArguments,
|
|
13
|
+
DapContinueOutcome,
|
|
14
|
+
DapContinueResponse,
|
|
15
|
+
DapDataBreakpoint,
|
|
16
|
+
DapDataBreakpointInfoArguments,
|
|
17
|
+
DapDataBreakpointInfoResponse,
|
|
18
|
+
DapDataBreakpointRecord,
|
|
19
|
+
DapDisassembleArguments,
|
|
20
|
+
DapDisassembledInstruction,
|
|
21
|
+
DapDisassembleResponse,
|
|
22
|
+
DapEvaluateArguments,
|
|
23
|
+
DapEvaluateResponse,
|
|
24
|
+
DapExitedEventBody,
|
|
25
|
+
DapFunctionBreakpoint,
|
|
26
|
+
DapFunctionBreakpointRecord,
|
|
27
|
+
DapInitializeArguments,
|
|
28
|
+
DapInstructionBreakpoint,
|
|
29
|
+
DapInstructionBreakpointRecord,
|
|
30
|
+
DapLaunchArguments,
|
|
31
|
+
DapLaunchSessionOptions,
|
|
32
|
+
DapLoadedSourcesResponse,
|
|
33
|
+
DapModule,
|
|
34
|
+
DapModulesArguments,
|
|
35
|
+
DapModulesResponse,
|
|
36
|
+
DapOutputEventBody,
|
|
37
|
+
DapPauseArguments,
|
|
38
|
+
DapReadMemoryArguments,
|
|
39
|
+
DapReadMemoryResponse,
|
|
40
|
+
DapResolvedAdapter,
|
|
41
|
+
DapRunInTerminalArguments,
|
|
42
|
+
DapRunInTerminalResponse,
|
|
43
|
+
DapScopesArguments,
|
|
44
|
+
DapScopesResponse,
|
|
45
|
+
DapSessionStatus,
|
|
46
|
+
DapSessionSummary,
|
|
47
|
+
DapSetDataBreakpointsArguments,
|
|
48
|
+
DapSetInstructionBreakpointsArguments,
|
|
49
|
+
DapSource,
|
|
50
|
+
DapSourceBreakpoint,
|
|
51
|
+
DapStackFrame,
|
|
52
|
+
DapStackTraceArguments,
|
|
53
|
+
DapStackTraceResponse,
|
|
54
|
+
DapStartDebuggingArguments,
|
|
55
|
+
DapStepArguments,
|
|
56
|
+
DapStopLocation,
|
|
57
|
+
DapStoppedEventBody,
|
|
58
|
+
DapThread,
|
|
59
|
+
DapThreadsResponse,
|
|
60
|
+
DapVariablesArguments,
|
|
61
|
+
DapVariablesResponse,
|
|
62
|
+
DapWriteMemoryArguments,
|
|
63
|
+
DapWriteMemoryResponse,
|
|
64
|
+
} from "./types";
|
|
65
|
+
|
|
66
|
+
interface DapSession {
|
|
67
|
+
id: string;
|
|
68
|
+
adapter: DapResolvedAdapter;
|
|
69
|
+
cwd: string;
|
|
70
|
+
program?: string;
|
|
71
|
+
client: DapClient;
|
|
72
|
+
status: DapSessionStatus;
|
|
73
|
+
launchedAt: number;
|
|
74
|
+
lastUsedAt: number;
|
|
75
|
+
breakpoints: Map<string, DapBreakpointRecord[]>;
|
|
76
|
+
functionBreakpoints: DapFunctionBreakpointRecord[];
|
|
77
|
+
instructionBreakpoints: DapInstructionBreakpoint[];
|
|
78
|
+
dataBreakpoints: DapDataBreakpoint[];
|
|
79
|
+
/** Serializes breakpoint mutations — see #serializeBreakpointMutation. */
|
|
80
|
+
breakpointMutationQueue: Promise<void>;
|
|
81
|
+
/** Recent output chunks; trimmed from the front when over MAX_OUTPUT_BYTES. */
|
|
82
|
+
outputChunks: string[];
|
|
83
|
+
/** Cumulative bytes of output ever received (reported in summaries). */
|
|
84
|
+
outputBytes: number;
|
|
85
|
+
/** Bytes currently buffered in outputChunks. */
|
|
86
|
+
outputBufferedBytes: number;
|
|
87
|
+
outputTruncated: boolean;
|
|
88
|
+
stop: DapStopLocation;
|
|
89
|
+
threads: DapThread[];
|
|
90
|
+
lastStackFrames: DapStackFrame[];
|
|
91
|
+
exitCode?: number;
|
|
92
|
+
capabilities?: DapCapabilities;
|
|
93
|
+
initializedSeen: boolean;
|
|
94
|
+
needsConfigurationDone: boolean;
|
|
95
|
+
configurationDoneSent: boolean;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface DapOutputSnapshot {
|
|
99
|
+
snapshot: DapSessionSummary;
|
|
100
|
+
output: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const IDLE_TIMEOUT_MS = 10 * 60 * 1000;
|
|
104
|
+
const CLEANUP_INTERVAL_MS = 30 * 1000;
|
|
105
|
+
const HEARTBEAT_INTERVAL_MS = 5 * 1000;
|
|
106
|
+
const MAX_OUTPUT_BYTES = 128 * 1024;
|
|
107
|
+
const STOP_CAPTURE_TIMEOUT_MS = 5_000;
|
|
108
|
+
|
|
109
|
+
function toErrorMessage(value: unknown): string {
|
|
110
|
+
if (value instanceof Error) return value.message;
|
|
111
|
+
return String(value);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
interface DapStartRequestFailure {
|
|
115
|
+
rejected: boolean;
|
|
116
|
+
error?: unknown;
|
|
117
|
+
/**
|
|
118
|
+
* Resolves (never rejects) when the underlying launch/attach request
|
|
119
|
+
* settles either way. Set by {@link trackDapStartRequest} on each call,
|
|
120
|
+
* so a single failure object must not be reused across launch attempts.
|
|
121
|
+
* Consumed by {@link throwPreferredDapStartError} to bound how long to
|
|
122
|
+
* wait for a delayed adapter-side rejection before falling back to the
|
|
123
|
+
* cascade error from configurationDone.
|
|
124
|
+
*/
|
|
125
|
+
settled?: Promise<void>;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function trackDapStartRequest<T>(promise: Promise<T>, failure: DapStartRequestFailure): Promise<T> {
|
|
129
|
+
const tracked = promise.catch(error => {
|
|
130
|
+
failure.rejected = true;
|
|
131
|
+
failure.error = error;
|
|
132
|
+
throw error;
|
|
133
|
+
});
|
|
134
|
+
failure.settled = tracked.then(
|
|
135
|
+
() => {},
|
|
136
|
+
() => {},
|
|
137
|
+
);
|
|
138
|
+
return tracked;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function combineDapStartErrors(command: "launch" | "attach", startError: unknown, configurationError: unknown): Error {
|
|
142
|
+
const startMessage = toErrorMessage(startError);
|
|
143
|
+
const configurationMessage = toErrorMessage(configurationError);
|
|
144
|
+
if (startMessage === configurationMessage) {
|
|
145
|
+
return startError instanceof Error ? startError : new Error(startMessage);
|
|
146
|
+
}
|
|
147
|
+
return new Error(
|
|
148
|
+
`DAP ${command} failed: ${startMessage}\nDAP configurationDone also failed: ${configurationMessage}`,
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async function throwPreferredDapStartError(
|
|
153
|
+
command: "launch" | "attach",
|
|
154
|
+
startFailure: DapStartRequestFailure,
|
|
155
|
+
configurationError: unknown,
|
|
156
|
+
): Promise<never> {
|
|
157
|
+
await Promise.race([startFailure.settled ?? Promise.resolve(), timers.setTimeout(50)]);
|
|
158
|
+
if (startFailure.rejected) {
|
|
159
|
+
throw combineDapStartErrors(command, startFailure.error, configurationError);
|
|
160
|
+
}
|
|
161
|
+
throw configurationError;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const DEBUGPY_MISSING_MODULE_RE = /No module named ['"]?debugpy['"]?/;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Map a generic adapter-side failure into the targeted `pip install debugpy`
|
|
168
|
+
* hint when the adapter is debugpy and stderr/the wrapping error mentions
|
|
169
|
+
* the missing module. Returns null when the heuristic does not apply, so the
|
|
170
|
+
* caller can rethrow the original error untouched.
|
|
171
|
+
*/
|
|
172
|
+
function mapDebugpyMissingModule(adapterName: string, error: unknown): Error | null {
|
|
173
|
+
if (adapterName !== "debugpy") return null;
|
|
174
|
+
if (!DEBUGPY_MISSING_MODULE_RE.test(toErrorMessage(error))) return null;
|
|
175
|
+
return new Error("adapter 'debugpy' is not available: install with 'pip install debugpy'");
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function normalizePath(filePath: string): string {
|
|
179
|
+
return path.resolve(filePath);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function truncateOutput(session: DapSession, output: string): void {
|
|
183
|
+
if (!output) return;
|
|
184
|
+
const bytes = Buffer.byteLength(output, "utf-8");
|
|
185
|
+
session.outputChunks.push(output);
|
|
186
|
+
session.outputBytes += bytes;
|
|
187
|
+
session.outputBufferedBytes += bytes;
|
|
188
|
+
// Trim whole chunks from the front, but only while the remainder still
|
|
189
|
+
// holds a full MAX_OUTPUT_BYTES tail — dropping the front chunk whenever
|
|
190
|
+
// the total exceeded the cap could retain far less than the cap (e.g.
|
|
191
|
+
// [120KB, 10KB] would keep only 10KB). Recomputing one big string's byte
|
|
192
|
+
// length per 1KB trim iteration was O(n^2) inside the event dispatch loop.
|
|
193
|
+
while (session.outputChunks.length > 1) {
|
|
194
|
+
const frontBytes = Buffer.byteLength(session.outputChunks[0], "utf-8");
|
|
195
|
+
if (session.outputBufferedBytes - frontBytes < MAX_OUTPUT_BYTES) break;
|
|
196
|
+
session.outputChunks.shift();
|
|
197
|
+
session.outputBufferedBytes -= frontBytes;
|
|
198
|
+
session.outputTruncated = true;
|
|
199
|
+
}
|
|
200
|
+
if (session.outputBufferedBytes > MAX_OUTPUT_BYTES) {
|
|
201
|
+
// Byte-slice the front chunk's head so exactly the cap remains (a torn
|
|
202
|
+
// code point at the cut decodes as U+FFFD, acceptable for log output).
|
|
203
|
+
const front = session.outputChunks[0];
|
|
204
|
+
const frontBytes = Buffer.byteLength(front, "utf-8");
|
|
205
|
+
const excess = session.outputBufferedBytes - MAX_OUTPUT_BYTES;
|
|
206
|
+
const kept = Buffer.from(front, "utf-8").subarray(excess).toString("utf-8");
|
|
207
|
+
session.outputChunks[0] = kept;
|
|
208
|
+
session.outputBufferedBytes += Buffer.byteLength(kept, "utf-8") - frontBytes;
|
|
209
|
+
session.outputTruncated = true;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function summarizeBreakpointCount(breakpoints: Map<string, DapBreakpointRecord[]>): number {
|
|
214
|
+
let total = 0;
|
|
215
|
+
for (const entries of breakpoints.values()) {
|
|
216
|
+
total += entries.length;
|
|
217
|
+
}
|
|
218
|
+
return total;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function buildSummary(session: DapSession): DapSessionSummary {
|
|
222
|
+
return {
|
|
223
|
+
id: session.id,
|
|
224
|
+
adapter: session.adapter.name,
|
|
225
|
+
cwd: session.cwd,
|
|
226
|
+
program: session.program,
|
|
227
|
+
status: session.status,
|
|
228
|
+
launchedAt: new Date(session.launchedAt).toISOString(),
|
|
229
|
+
lastUsedAt: new Date(session.lastUsedAt).toISOString(),
|
|
230
|
+
threadId: session.stop.threadId,
|
|
231
|
+
frameId: session.stop.frameId,
|
|
232
|
+
stopReason: session.stop.reason,
|
|
233
|
+
stopDescription: session.stop.description ?? session.stop.text,
|
|
234
|
+
frameName: session.stop.frameName,
|
|
235
|
+
instructionPointerReference: session.stop.instructionPointerReference,
|
|
236
|
+
source: session.stop.source,
|
|
237
|
+
line: session.stop.line,
|
|
238
|
+
column: session.stop.column,
|
|
239
|
+
breakpointFiles: session.breakpoints.size,
|
|
240
|
+
breakpointCount: summarizeBreakpointCount(session.breakpoints),
|
|
241
|
+
functionBreakpointCount: session.functionBreakpoints.length,
|
|
242
|
+
outputBytes: session.outputBytes,
|
|
243
|
+
outputTruncated: session.outputTruncated,
|
|
244
|
+
exitCode: session.exitCode,
|
|
245
|
+
needsConfigurationDone: session.needsConfigurationDone && !session.configurationDoneSent,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export class DapSessionManager {
|
|
250
|
+
#sessions = new Map<string, DapSession>();
|
|
251
|
+
#activeSessionId: string | null = null;
|
|
252
|
+
#cleanupLoopPromise?: Promise<void>;
|
|
253
|
+
#nextId = 0;
|
|
254
|
+
|
|
255
|
+
constructor() {
|
|
256
|
+
this.#startCleanupTimer();
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
getActiveSession(): DapSessionSummary | null {
|
|
260
|
+
const session = this.#getActiveSessionOrNull();
|
|
261
|
+
return session ? buildSummary(session) : null;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
listSessions(): DapSessionSummary[] {
|
|
265
|
+
return Array.from(this.#sessions.values()).map(buildSummary);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
getCapabilities(): DapCapabilities | null {
|
|
269
|
+
return this.#getActiveSessionOrNull()?.capabilities ?? null;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
async launch(
|
|
273
|
+
options: DapLaunchSessionOptions,
|
|
274
|
+
signal?: AbortSignal,
|
|
275
|
+
timeoutMs: number = 30_000,
|
|
276
|
+
): Promise<DapSessionSummary> {
|
|
277
|
+
await this.#ensureLaunchSlot();
|
|
278
|
+
const client = await DapClient.spawn({ adapter: options.adapter, cwd: options.cwd });
|
|
279
|
+
const session = this.#registerSession(client, options.adapter, options.cwd, options.program);
|
|
280
|
+
try {
|
|
281
|
+
session.capabilities = await client.initialize(
|
|
282
|
+
this.#buildInitializeArguments(options.adapter),
|
|
283
|
+
signal,
|
|
284
|
+
timeoutMs,
|
|
285
|
+
);
|
|
286
|
+
session.needsConfigurationDone = session.capabilities.supportsConfigurationDoneRequest === true;
|
|
287
|
+
const launchArguments: DapLaunchArguments = {
|
|
288
|
+
...options.adapter.launchDefaults,
|
|
289
|
+
...(options.extraLaunchArguments ?? {}),
|
|
290
|
+
program: options.program,
|
|
291
|
+
cwd: options.cwd,
|
|
292
|
+
args: options.args,
|
|
293
|
+
};
|
|
294
|
+
// Subscribe to stop events BEFORE launching so we don't miss
|
|
295
|
+
// stopOnEntry events that arrive before we start listening.
|
|
296
|
+
const initialStopPromise = this.#prepareStopOutcome(
|
|
297
|
+
session,
|
|
298
|
+
signal,
|
|
299
|
+
Math.min(timeoutMs, STOP_CAPTURE_TIMEOUT_MS),
|
|
300
|
+
);
|
|
301
|
+
// DAP spec: many adapters do not respond to launch until after
|
|
302
|
+
// configurationDone. Fire launch, complete the config handshake,
|
|
303
|
+
// then await the launch response.
|
|
304
|
+
const launchFailure: DapStartRequestFailure = { rejected: false };
|
|
305
|
+
const launchPromise = trackDapStartRequest(
|
|
306
|
+
client.sendRequest("launch", launchArguments, signal, timeoutMs),
|
|
307
|
+
launchFailure,
|
|
308
|
+
);
|
|
309
|
+
// Mark handled so a fast error response doesn't become an unhandled
|
|
310
|
+
// rejection while we await the config handshake. The actual error
|
|
311
|
+
// still propagates when we await launchPromise below.
|
|
312
|
+
launchPromise.catch(() => {});
|
|
313
|
+
try {
|
|
314
|
+
await this.#completeConfigurationHandshake(session, signal, timeoutMs);
|
|
315
|
+
} catch (error) {
|
|
316
|
+
await throwPreferredDapStartError("launch", launchFailure, error);
|
|
317
|
+
}
|
|
318
|
+
await launchPromise;
|
|
319
|
+
// Try to capture initial stopped state (e.g. stopOnEntry).
|
|
320
|
+
// Timeout is acceptable — the program may simply be running.
|
|
321
|
+
try {
|
|
322
|
+
await untilAborted(signal, initialStopPromise);
|
|
323
|
+
if (session.status === "stopped") {
|
|
324
|
+
await this.#fetchTopFrame(session, signal, Math.min(timeoutMs, STOP_CAPTURE_TIMEOUT_MS));
|
|
325
|
+
}
|
|
326
|
+
} catch {
|
|
327
|
+
if (session.initializedSeen && session.status === "launching") {
|
|
328
|
+
session.status = session.configurationDoneSent ? "running" : "configuring";
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
return buildSummary(session);
|
|
332
|
+
} catch (error) {
|
|
333
|
+
await this.#disposeSession(session);
|
|
334
|
+
const mapped = mapDebugpyMissingModule(options.adapter.name, error);
|
|
335
|
+
if (mapped) throw mapped;
|
|
336
|
+
throw error;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
async attach(
|
|
341
|
+
options: DapAttachSessionOptions,
|
|
342
|
+
signal?: AbortSignal,
|
|
343
|
+
timeoutMs: number = 30_000,
|
|
344
|
+
): Promise<DapSessionSummary> {
|
|
345
|
+
await this.#ensureLaunchSlot();
|
|
346
|
+
const client = await DapClient.spawn({ adapter: options.adapter, cwd: options.cwd });
|
|
347
|
+
const session = this.#registerSession(client, options.adapter, options.cwd);
|
|
348
|
+
try {
|
|
349
|
+
session.capabilities = await client.initialize(
|
|
350
|
+
this.#buildInitializeArguments(options.adapter),
|
|
351
|
+
signal,
|
|
352
|
+
timeoutMs,
|
|
353
|
+
);
|
|
354
|
+
session.needsConfigurationDone = session.capabilities.supportsConfigurationDoneRequest === true;
|
|
355
|
+
const attachArguments: DapAttachArguments = {
|
|
356
|
+
...options.adapter.attachDefaults,
|
|
357
|
+
cwd: options.cwd,
|
|
358
|
+
...(options.pid !== undefined ? { pid: options.pid, processId: options.pid } : {}),
|
|
359
|
+
...(options.port !== undefined ? { port: options.port } : {}),
|
|
360
|
+
...(options.host ? { host: options.host } : {}),
|
|
361
|
+
};
|
|
362
|
+
const initialStopPromise = this.#prepareStopOutcome(
|
|
363
|
+
session,
|
|
364
|
+
signal,
|
|
365
|
+
Math.min(timeoutMs, STOP_CAPTURE_TIMEOUT_MS),
|
|
366
|
+
);
|
|
367
|
+
const attachFailure: DapStartRequestFailure = { rejected: false };
|
|
368
|
+
const attachPromise = trackDapStartRequest(
|
|
369
|
+
client.sendRequest("attach", attachArguments, signal, timeoutMs),
|
|
370
|
+
attachFailure,
|
|
371
|
+
);
|
|
372
|
+
attachPromise.catch(() => {});
|
|
373
|
+
try {
|
|
374
|
+
await this.#completeConfigurationHandshake(session, signal, timeoutMs);
|
|
375
|
+
} catch (error) {
|
|
376
|
+
await throwPreferredDapStartError("attach", attachFailure, error);
|
|
377
|
+
}
|
|
378
|
+
await attachPromise;
|
|
379
|
+
try {
|
|
380
|
+
await untilAborted(signal, initialStopPromise);
|
|
381
|
+
if (session.status === "stopped") {
|
|
382
|
+
await this.#fetchTopFrame(session, signal, Math.min(timeoutMs, STOP_CAPTURE_TIMEOUT_MS));
|
|
383
|
+
}
|
|
384
|
+
} catch {
|
|
385
|
+
if (session.initializedSeen && session.status === "launching") {
|
|
386
|
+
session.status = session.configurationDoneSent ? "running" : "configuring";
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
return buildSummary(session);
|
|
390
|
+
} catch (error) {
|
|
391
|
+
await this.#disposeSession(session);
|
|
392
|
+
const mapped = mapDebugpyMissingModule(options.adapter.name, error);
|
|
393
|
+
if (mapped) throw mapped;
|
|
394
|
+
throw error;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Serialize breakpoint mutations per session: every mutator does a
|
|
400
|
+
* read-modify-write of session state around an await, and the adapter-side
|
|
401
|
+
* set*Breakpoints request replaces the whole list — concurrent mutations
|
|
402
|
+
* would silently drop each other's breakpoints on both sides.
|
|
403
|
+
*/
|
|
404
|
+
#serializeBreakpointMutation<T>(session: DapSession, mutate: () => Promise<T>, signal?: AbortSignal): Promise<T> {
|
|
405
|
+
const run = session.breakpointMutationQueue.then(() => {
|
|
406
|
+
// A mutation can sit behind several queued 30s predecessors; honor a
|
|
407
|
+
// caller abort at dequeue instead of running a request nobody awaits.
|
|
408
|
+
if (signal?.aborted) throw signal.reason instanceof Error ? signal.reason : new Error("Aborted");
|
|
409
|
+
return mutate();
|
|
410
|
+
});
|
|
411
|
+
session.breakpointMutationQueue = run.then(
|
|
412
|
+
() => undefined,
|
|
413
|
+
() => undefined,
|
|
414
|
+
);
|
|
415
|
+
return run;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
async setBreakpoint(
|
|
419
|
+
file: string,
|
|
420
|
+
line: number,
|
|
421
|
+
condition?: string,
|
|
422
|
+
signal?: AbortSignal,
|
|
423
|
+
timeoutMs: number = 30_000,
|
|
424
|
+
) {
|
|
425
|
+
const session = this.#touchActiveSession();
|
|
426
|
+
return this.#serializeBreakpointMutation(
|
|
427
|
+
session,
|
|
428
|
+
async () => {
|
|
429
|
+
const sourcePath = normalizePath(file);
|
|
430
|
+
const current = [...(session.breakpoints.get(sourcePath) ?? [])];
|
|
431
|
+
const deduped = current.filter(entry => entry.line !== line);
|
|
432
|
+
deduped.push({ verified: false, line, condition });
|
|
433
|
+
deduped.sort((left, right) => left.line - right.line);
|
|
434
|
+
const response = await this.#sendRequestWithConfig<{ breakpoints?: DapBreakpoint[] }>(
|
|
435
|
+
session,
|
|
436
|
+
"setBreakpoints",
|
|
437
|
+
{
|
|
438
|
+
source: { path: sourcePath, name: path.basename(sourcePath) },
|
|
439
|
+
breakpoints: deduped.map<DapSourceBreakpoint>(entry => ({
|
|
440
|
+
line: entry.line,
|
|
441
|
+
...(entry.condition ? { condition: entry.condition } : {}),
|
|
442
|
+
})),
|
|
443
|
+
},
|
|
444
|
+
signal,
|
|
445
|
+
timeoutMs,
|
|
446
|
+
);
|
|
447
|
+
session.breakpoints.set(sourcePath, this.#mapSourceBreakpoints(deduped, response?.breakpoints));
|
|
448
|
+
return {
|
|
449
|
+
snapshot: buildSummary(session),
|
|
450
|
+
breakpoints: session.breakpoints.get(sourcePath) ?? [],
|
|
451
|
+
sourcePath,
|
|
452
|
+
};
|
|
453
|
+
},
|
|
454
|
+
signal,
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
async removeBreakpoint(file: string, line: number, signal?: AbortSignal, timeoutMs: number = 30_000) {
|
|
459
|
+
const session = this.#touchActiveSession();
|
|
460
|
+
return this.#serializeBreakpointMutation(
|
|
461
|
+
session,
|
|
462
|
+
async () => {
|
|
463
|
+
const sourcePath = normalizePath(file);
|
|
464
|
+
const current = [...(session.breakpoints.get(sourcePath) ?? [])].filter(entry => entry.line !== line);
|
|
465
|
+
const response = await this.#sendRequestWithConfig<{ breakpoints?: DapBreakpoint[] }>(
|
|
466
|
+
session,
|
|
467
|
+
"setBreakpoints",
|
|
468
|
+
{
|
|
469
|
+
source: { path: sourcePath, name: path.basename(sourcePath) },
|
|
470
|
+
breakpoints: current.map<DapSourceBreakpoint>(entry => ({
|
|
471
|
+
line: entry.line,
|
|
472
|
+
...(entry.condition ? { condition: entry.condition } : {}),
|
|
473
|
+
})),
|
|
474
|
+
},
|
|
475
|
+
signal,
|
|
476
|
+
timeoutMs,
|
|
477
|
+
);
|
|
478
|
+
if (current.length === 0) {
|
|
479
|
+
session.breakpoints.delete(sourcePath);
|
|
480
|
+
} else {
|
|
481
|
+
session.breakpoints.set(sourcePath, this.#mapSourceBreakpoints(current, response?.breakpoints));
|
|
482
|
+
}
|
|
483
|
+
return {
|
|
484
|
+
snapshot: buildSummary(session),
|
|
485
|
+
breakpoints: session.breakpoints.get(sourcePath) ?? [],
|
|
486
|
+
sourcePath,
|
|
487
|
+
};
|
|
488
|
+
},
|
|
489
|
+
signal,
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
async setFunctionBreakpoint(name: string, condition?: string, signal?: AbortSignal, timeoutMs: number = 30_000) {
|
|
494
|
+
const session = this.#touchActiveSession();
|
|
495
|
+
return this.#serializeBreakpointMutation(
|
|
496
|
+
session,
|
|
497
|
+
async () => {
|
|
498
|
+
const current = session.functionBreakpoints.filter(entry => entry.name !== name);
|
|
499
|
+
current.push({ verified: false, name, condition });
|
|
500
|
+
current.sort((left, right) => left.name.localeCompare(right.name));
|
|
501
|
+
const response = await this.#sendRequestWithConfig<{ breakpoints?: DapBreakpoint[] }>(
|
|
502
|
+
session,
|
|
503
|
+
"setFunctionBreakpoints",
|
|
504
|
+
{
|
|
505
|
+
breakpoints: current.map<DapFunctionBreakpoint>(entry => ({
|
|
506
|
+
name: entry.name,
|
|
507
|
+
...(entry.condition ? { condition: entry.condition } : {}),
|
|
508
|
+
})),
|
|
509
|
+
},
|
|
510
|
+
signal,
|
|
511
|
+
timeoutMs,
|
|
512
|
+
);
|
|
513
|
+
session.functionBreakpoints = this.#mapFunctionBreakpoints(current, response?.breakpoints);
|
|
514
|
+
return { snapshot: buildSummary(session), breakpoints: session.functionBreakpoints };
|
|
515
|
+
},
|
|
516
|
+
signal,
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
async removeFunctionBreakpoint(name: string, signal?: AbortSignal, timeoutMs: number = 30_000) {
|
|
521
|
+
const session = this.#touchActiveSession();
|
|
522
|
+
return this.#serializeBreakpointMutation(
|
|
523
|
+
session,
|
|
524
|
+
async () => {
|
|
525
|
+
const current = session.functionBreakpoints.filter(entry => entry.name !== name);
|
|
526
|
+
const response = await this.#sendRequestWithConfig<{ breakpoints?: DapBreakpoint[] }>(
|
|
527
|
+
session,
|
|
528
|
+
"setFunctionBreakpoints",
|
|
529
|
+
{
|
|
530
|
+
breakpoints: current.map<DapFunctionBreakpoint>(entry => ({
|
|
531
|
+
name: entry.name,
|
|
532
|
+
...(entry.condition ? { condition: entry.condition } : {}),
|
|
533
|
+
})),
|
|
534
|
+
},
|
|
535
|
+
signal,
|
|
536
|
+
timeoutMs,
|
|
537
|
+
);
|
|
538
|
+
session.functionBreakpoints = this.#mapFunctionBreakpoints(current, response?.breakpoints);
|
|
539
|
+
return { snapshot: buildSummary(session), breakpoints: session.functionBreakpoints };
|
|
540
|
+
},
|
|
541
|
+
signal,
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
async setInstructionBreakpoint(
|
|
546
|
+
instructionReference: string,
|
|
547
|
+
offset?: number,
|
|
548
|
+
condition?: string,
|
|
549
|
+
hitCondition?: string,
|
|
550
|
+
signal?: AbortSignal,
|
|
551
|
+
timeoutMs: number = 30_000,
|
|
552
|
+
) {
|
|
553
|
+
const session = this.#touchActiveSession();
|
|
554
|
+
return this.#serializeBreakpointMutation(
|
|
555
|
+
session,
|
|
556
|
+
async () => {
|
|
557
|
+
const current = session.instructionBreakpoints.filter(
|
|
558
|
+
entry => entry.instructionReference !== instructionReference || entry.offset !== offset,
|
|
559
|
+
);
|
|
560
|
+
current.push({ instructionReference, offset, condition, hitCondition });
|
|
561
|
+
current.sort((left, right) => {
|
|
562
|
+
const referenceOrder = left.instructionReference.localeCompare(right.instructionReference);
|
|
563
|
+
if (referenceOrder !== 0) {
|
|
564
|
+
return referenceOrder;
|
|
565
|
+
}
|
|
566
|
+
return (left.offset ?? 0) - (right.offset ?? 0);
|
|
567
|
+
});
|
|
568
|
+
const response = await this.#sendRequestWithConfig<{ breakpoints?: DapBreakpoint[] }>(
|
|
569
|
+
session,
|
|
570
|
+
"setInstructionBreakpoints",
|
|
571
|
+
{
|
|
572
|
+
breakpoints: current,
|
|
573
|
+
} satisfies DapSetInstructionBreakpointsArguments,
|
|
574
|
+
signal,
|
|
575
|
+
timeoutMs,
|
|
576
|
+
);
|
|
577
|
+
session.instructionBreakpoints = current;
|
|
578
|
+
return {
|
|
579
|
+
snapshot: buildSummary(session),
|
|
580
|
+
breakpoints: this.#mapInstructionBreakpoints(current, response?.breakpoints),
|
|
581
|
+
};
|
|
582
|
+
},
|
|
583
|
+
signal,
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
async removeInstructionBreakpoint(
|
|
588
|
+
instructionReference: string,
|
|
589
|
+
offset?: number,
|
|
590
|
+
signal?: AbortSignal,
|
|
591
|
+
timeoutMs: number = 30_000,
|
|
592
|
+
) {
|
|
593
|
+
const session = this.#touchActiveSession();
|
|
594
|
+
return this.#serializeBreakpointMutation(
|
|
595
|
+
session,
|
|
596
|
+
async () => {
|
|
597
|
+
const current = session.instructionBreakpoints.filter(entry => {
|
|
598
|
+
if (entry.instructionReference !== instructionReference) {
|
|
599
|
+
return true;
|
|
600
|
+
}
|
|
601
|
+
if (offset === undefined) {
|
|
602
|
+
return false;
|
|
603
|
+
}
|
|
604
|
+
return entry.offset !== offset;
|
|
605
|
+
});
|
|
606
|
+
const response = await this.#sendRequestWithConfig<{ breakpoints?: DapBreakpoint[] }>(
|
|
607
|
+
session,
|
|
608
|
+
"setInstructionBreakpoints",
|
|
609
|
+
{
|
|
610
|
+
breakpoints: current,
|
|
611
|
+
} satisfies DapSetInstructionBreakpointsArguments,
|
|
612
|
+
signal,
|
|
613
|
+
timeoutMs,
|
|
614
|
+
);
|
|
615
|
+
session.instructionBreakpoints = current;
|
|
616
|
+
return {
|
|
617
|
+
snapshot: buildSummary(session),
|
|
618
|
+
breakpoints: this.#mapInstructionBreakpoints(current, response?.breakpoints),
|
|
619
|
+
};
|
|
620
|
+
},
|
|
621
|
+
signal,
|
|
622
|
+
);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
async dataBreakpointInfo(
|
|
626
|
+
name: string,
|
|
627
|
+
variablesReference?: number,
|
|
628
|
+
frameId?: number,
|
|
629
|
+
signal?: AbortSignal,
|
|
630
|
+
timeoutMs: number = 30_000,
|
|
631
|
+
): Promise<{ snapshot: DapSessionSummary; info: DapDataBreakpointInfoResponse }> {
|
|
632
|
+
const session = this.#touchActiveSession();
|
|
633
|
+
const info = await this.#sendRequestWithConfig<DapDataBreakpointInfoResponse>(
|
|
634
|
+
session,
|
|
635
|
+
"dataBreakpointInfo",
|
|
636
|
+
{
|
|
637
|
+
name,
|
|
638
|
+
...(variablesReference !== undefined ? { variablesReference } : {}),
|
|
639
|
+
...(frameId !== undefined ? { frameId } : {}),
|
|
640
|
+
} satisfies DapDataBreakpointInfoArguments,
|
|
641
|
+
signal,
|
|
642
|
+
timeoutMs,
|
|
643
|
+
);
|
|
644
|
+
return { snapshot: buildSummary(session), info };
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
async setDataBreakpoint(
|
|
648
|
+
dataId: string,
|
|
649
|
+
accessType?: "read" | "write" | "readWrite",
|
|
650
|
+
condition?: string,
|
|
651
|
+
hitCondition?: string,
|
|
652
|
+
signal?: AbortSignal,
|
|
653
|
+
timeoutMs: number = 30_000,
|
|
654
|
+
) {
|
|
655
|
+
const session = this.#touchActiveSession();
|
|
656
|
+
return this.#serializeBreakpointMutation(
|
|
657
|
+
session,
|
|
658
|
+
async () => {
|
|
659
|
+
const current = session.dataBreakpoints.filter(entry => entry.dataId !== dataId);
|
|
660
|
+
current.push({ dataId, accessType, condition, hitCondition });
|
|
661
|
+
current.sort((left, right) => left.dataId.localeCompare(right.dataId));
|
|
662
|
+
const response = await this.#sendRequestWithConfig<{ breakpoints?: DapBreakpoint[] }>(
|
|
663
|
+
session,
|
|
664
|
+
"setDataBreakpoints",
|
|
665
|
+
{
|
|
666
|
+
breakpoints: current,
|
|
667
|
+
} satisfies DapSetDataBreakpointsArguments,
|
|
668
|
+
signal,
|
|
669
|
+
timeoutMs,
|
|
670
|
+
);
|
|
671
|
+
session.dataBreakpoints = current;
|
|
672
|
+
return {
|
|
673
|
+
snapshot: buildSummary(session),
|
|
674
|
+
breakpoints: this.#mapDataBreakpoints(current, response?.breakpoints),
|
|
675
|
+
};
|
|
676
|
+
},
|
|
677
|
+
signal,
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
async removeDataBreakpoint(dataId: string, signal?: AbortSignal, timeoutMs: number = 30_000) {
|
|
682
|
+
const session = this.#touchActiveSession();
|
|
683
|
+
return this.#serializeBreakpointMutation(
|
|
684
|
+
session,
|
|
685
|
+
async () => {
|
|
686
|
+
const current = session.dataBreakpoints.filter(entry => entry.dataId !== dataId);
|
|
687
|
+
const response = await this.#sendRequestWithConfig<{ breakpoints?: DapBreakpoint[] }>(
|
|
688
|
+
session,
|
|
689
|
+
"setDataBreakpoints",
|
|
690
|
+
{
|
|
691
|
+
breakpoints: current,
|
|
692
|
+
} satisfies DapSetDataBreakpointsArguments,
|
|
693
|
+
signal,
|
|
694
|
+
timeoutMs,
|
|
695
|
+
);
|
|
696
|
+
session.dataBreakpoints = current;
|
|
697
|
+
return {
|
|
698
|
+
snapshot: buildSummary(session),
|
|
699
|
+
breakpoints: this.#mapDataBreakpoints(current, response?.breakpoints),
|
|
700
|
+
};
|
|
701
|
+
},
|
|
702
|
+
signal,
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
async disassemble(
|
|
707
|
+
memoryReference: string,
|
|
708
|
+
instructionCount: number,
|
|
709
|
+
offset?: number,
|
|
710
|
+
instructionOffset?: number,
|
|
711
|
+
resolveSymbols?: boolean,
|
|
712
|
+
signal?: AbortSignal,
|
|
713
|
+
timeoutMs: number = 30_000,
|
|
714
|
+
): Promise<{ snapshot: DapSessionSummary; instructions: DapDisassembledInstruction[] }> {
|
|
715
|
+
const session = this.#touchActiveSession();
|
|
716
|
+
const response = await this.#sendRequestWithConfig<DapDisassembleResponse>(
|
|
717
|
+
session,
|
|
718
|
+
"disassemble",
|
|
719
|
+
{
|
|
720
|
+
memoryReference,
|
|
721
|
+
instructionCount,
|
|
722
|
+
...(offset !== undefined ? { offset } : {}),
|
|
723
|
+
...(instructionOffset !== undefined ? { instructionOffset } : {}),
|
|
724
|
+
...(resolveSymbols !== undefined ? { resolveSymbols } : {}),
|
|
725
|
+
} satisfies DapDisassembleArguments,
|
|
726
|
+
signal,
|
|
727
|
+
timeoutMs,
|
|
728
|
+
);
|
|
729
|
+
return { snapshot: buildSummary(session), instructions: response?.instructions ?? [] };
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
async readMemory(
|
|
733
|
+
memoryReference: string,
|
|
734
|
+
count: number,
|
|
735
|
+
offset?: number,
|
|
736
|
+
signal?: AbortSignal,
|
|
737
|
+
timeoutMs: number = 30_000,
|
|
738
|
+
): Promise<{ snapshot: DapSessionSummary; address: string; data?: string; unreadableBytes?: number }> {
|
|
739
|
+
const session = this.#touchActiveSession();
|
|
740
|
+
const response = await this.#sendRequestWithConfig<DapReadMemoryResponse>(
|
|
741
|
+
session,
|
|
742
|
+
"readMemory",
|
|
743
|
+
{
|
|
744
|
+
memoryReference,
|
|
745
|
+
count,
|
|
746
|
+
...(offset !== undefined ? { offset } : {}),
|
|
747
|
+
} satisfies DapReadMemoryArguments,
|
|
748
|
+
signal,
|
|
749
|
+
timeoutMs,
|
|
750
|
+
);
|
|
751
|
+
return {
|
|
752
|
+
snapshot: buildSummary(session),
|
|
753
|
+
address: response?.address ?? memoryReference,
|
|
754
|
+
data: response?.data,
|
|
755
|
+
unreadableBytes: response?.unreadableBytes,
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
async writeMemory(
|
|
760
|
+
memoryReference: string,
|
|
761
|
+
data: string,
|
|
762
|
+
offset?: number,
|
|
763
|
+
allowPartial?: boolean,
|
|
764
|
+
signal?: AbortSignal,
|
|
765
|
+
timeoutMs: number = 30_000,
|
|
766
|
+
): Promise<{ snapshot: DapSessionSummary; offset?: number; bytesWritten?: number }> {
|
|
767
|
+
const session = this.#touchActiveSession();
|
|
768
|
+
const response = await this.#sendRequestWithConfig<DapWriteMemoryResponse>(
|
|
769
|
+
session,
|
|
770
|
+
"writeMemory",
|
|
771
|
+
{
|
|
772
|
+
memoryReference,
|
|
773
|
+
data,
|
|
774
|
+
...(offset !== undefined ? { offset } : {}),
|
|
775
|
+
...(allowPartial !== undefined ? { allowPartial } : {}),
|
|
776
|
+
} satisfies DapWriteMemoryArguments,
|
|
777
|
+
signal,
|
|
778
|
+
timeoutMs,
|
|
779
|
+
);
|
|
780
|
+
return {
|
|
781
|
+
snapshot: buildSummary(session),
|
|
782
|
+
offset: response?.offset,
|
|
783
|
+
bytesWritten: response?.bytesWritten,
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
async modules(
|
|
788
|
+
startModule?: number,
|
|
789
|
+
moduleCount?: number,
|
|
790
|
+
signal?: AbortSignal,
|
|
791
|
+
timeoutMs: number = 30_000,
|
|
792
|
+
): Promise<{ snapshot: DapSessionSummary; modules: DapModule[] }> {
|
|
793
|
+
const session = this.#touchActiveSession();
|
|
794
|
+
const response = await this.#sendRequestWithConfig<DapModulesResponse>(
|
|
795
|
+
session,
|
|
796
|
+
"modules",
|
|
797
|
+
{
|
|
798
|
+
...(startModule !== undefined ? { startModule } : {}),
|
|
799
|
+
...(moduleCount !== undefined ? { moduleCount } : {}),
|
|
800
|
+
} satisfies DapModulesArguments,
|
|
801
|
+
signal,
|
|
802
|
+
timeoutMs,
|
|
803
|
+
);
|
|
804
|
+
return { snapshot: buildSummary(session), modules: response?.modules ?? [] };
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
async loadedSources(
|
|
808
|
+
signal?: AbortSignal,
|
|
809
|
+
timeoutMs: number = 30_000,
|
|
810
|
+
): Promise<{ snapshot: DapSessionSummary; sources: DapSource[] }> {
|
|
811
|
+
const session = this.#touchActiveSession();
|
|
812
|
+
const response = await this.#sendRequestWithConfig<DapLoadedSourcesResponse>(
|
|
813
|
+
session,
|
|
814
|
+
"loadedSources",
|
|
815
|
+
{},
|
|
816
|
+
signal,
|
|
817
|
+
timeoutMs,
|
|
818
|
+
);
|
|
819
|
+
return { snapshot: buildSummary(session), sources: response?.sources ?? [] };
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
async customRequest(
|
|
823
|
+
command: string,
|
|
824
|
+
args?: Record<string, unknown>,
|
|
825
|
+
signal?: AbortSignal,
|
|
826
|
+
timeoutMs: number = 30_000,
|
|
827
|
+
): Promise<{ snapshot: DapSessionSummary; body: unknown }> {
|
|
828
|
+
const session = this.#touchActiveSession();
|
|
829
|
+
const body = await this.#sendRequestWithConfig<unknown>(session, command, args, signal, timeoutMs);
|
|
830
|
+
return { snapshot: buildSummary(session), body };
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
async continue(signal?: AbortSignal, timeoutMs: number = 30_000): Promise<DapContinueOutcome> {
|
|
834
|
+
const session = this.#touchActiveSession();
|
|
835
|
+
const threadId = await this.#resolveThreadId(session, signal, timeoutMs);
|
|
836
|
+
// Reset state and subscribe BEFORE sending continue to avoid missing
|
|
837
|
+
// events that arrive in the same buffer as the response.
|
|
838
|
+
session.stop = {};
|
|
839
|
+
session.lastStackFrames = [];
|
|
840
|
+
session.status = "running";
|
|
841
|
+
const outcomePromise = this.#prepareStopOutcome(session, signal, timeoutMs);
|
|
842
|
+
await this.#sendRequestWithConfig<DapContinueResponse>(
|
|
843
|
+
session,
|
|
844
|
+
"continue",
|
|
845
|
+
{ threadId } satisfies DapContinueArguments,
|
|
846
|
+
signal,
|
|
847
|
+
timeoutMs,
|
|
848
|
+
);
|
|
849
|
+
return this.#awaitStopOutcome(session, outcomePromise, signal, timeoutMs);
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
async pause(signal?: AbortSignal, timeoutMs: number = 30_000): Promise<DapSessionSummary> {
|
|
853
|
+
const session = this.#touchActiveSession();
|
|
854
|
+
// status is mutated by the event reader between awaits; check through a
|
|
855
|
+
// closure so TS does not carry stale narrowing from the early return.
|
|
856
|
+
const isStopped = () => session.status === "stopped";
|
|
857
|
+
if (isStopped()) {
|
|
858
|
+
return buildSummary(session);
|
|
859
|
+
}
|
|
860
|
+
const threadId = await this.#resolveThreadId(session, signal, timeoutMs);
|
|
861
|
+
// Subscribe BEFORE sending pause: the stopped event can arrive in the
|
|
862
|
+
// same chunk as the response and would otherwise be dispatched before
|
|
863
|
+
// the waiter subscribes, burning the whole timeout.
|
|
864
|
+
const stoppedPromise = session.client.waitForEvent<DapStoppedEventBody>("stopped", undefined, signal, timeoutMs);
|
|
865
|
+
stoppedPromise.catch(() => {});
|
|
866
|
+
await this.#sendRequestWithConfig(session, "pause", { threadId } satisfies DapPauseArguments, signal, timeoutMs);
|
|
867
|
+
if (!isStopped()) {
|
|
868
|
+
try {
|
|
869
|
+
await untilAborted(signal, stoppedPromise);
|
|
870
|
+
} catch {
|
|
871
|
+
// Timeout or abort — report current state regardless
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
return buildSummary(session);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
async stepIn(signal?: AbortSignal, timeoutMs: number = 30_000): Promise<DapContinueOutcome> {
|
|
878
|
+
return this.#step("stepIn", signal, timeoutMs);
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
async stepOut(signal?: AbortSignal, timeoutMs: number = 30_000): Promise<DapContinueOutcome> {
|
|
882
|
+
return this.#step("stepOut", signal, timeoutMs);
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
async stepOver(signal?: AbortSignal, timeoutMs: number = 30_000): Promise<DapContinueOutcome> {
|
|
886
|
+
return this.#step("next", signal, timeoutMs);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
async threads(
|
|
890
|
+
signal?: AbortSignal,
|
|
891
|
+
timeoutMs: number = 30_000,
|
|
892
|
+
): Promise<{ snapshot: DapSessionSummary; threads: DapThread[] }> {
|
|
893
|
+
const session = this.#touchActiveSession();
|
|
894
|
+
const response = await this.#sendRequestWithConfig<DapThreadsResponse>(
|
|
895
|
+
session,
|
|
896
|
+
"threads",
|
|
897
|
+
undefined,
|
|
898
|
+
signal,
|
|
899
|
+
timeoutMs,
|
|
900
|
+
);
|
|
901
|
+
session.threads = response?.threads ?? [];
|
|
902
|
+
return { snapshot: buildSummary(session), threads: session.threads };
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
async stackTrace(
|
|
906
|
+
frameCount: number | undefined,
|
|
907
|
+
signal?: AbortSignal,
|
|
908
|
+
timeoutMs: number = 30_000,
|
|
909
|
+
): Promise<{ snapshot: DapSessionSummary; stackFrames: DapStackFrame[]; totalFrames?: number }> {
|
|
910
|
+
const session = this.#touchActiveSession();
|
|
911
|
+
const threadId = await this.#resolveThreadId(session, signal, timeoutMs);
|
|
912
|
+
const response = await this.#sendRequestWithConfig<DapStackTraceResponse>(
|
|
913
|
+
session,
|
|
914
|
+
"stackTrace",
|
|
915
|
+
{
|
|
916
|
+
threadId,
|
|
917
|
+
...(frameCount !== undefined ? { levels: frameCount } : {}),
|
|
918
|
+
} satisfies DapStackTraceArguments,
|
|
919
|
+
signal,
|
|
920
|
+
timeoutMs,
|
|
921
|
+
);
|
|
922
|
+
session.lastStackFrames = response?.stackFrames ?? [];
|
|
923
|
+
this.#applyTopFrame(session, session.lastStackFrames[0]);
|
|
924
|
+
return {
|
|
925
|
+
snapshot: buildSummary(session),
|
|
926
|
+
stackFrames: session.lastStackFrames,
|
|
927
|
+
totalFrames: response?.totalFrames,
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
async scopes(frameId: number | undefined, signal?: AbortSignal, timeoutMs: number = 30_000) {
|
|
932
|
+
const session = this.#touchActiveSession();
|
|
933
|
+
const resolvedFrameId = frameId ?? session.stop.frameId;
|
|
934
|
+
if (resolvedFrameId === undefined) {
|
|
935
|
+
throw new Error("No active stack frame. Run stack_trace first or supply frame_id.");
|
|
936
|
+
}
|
|
937
|
+
const response = await this.#sendRequestWithConfig<DapScopesResponse>(
|
|
938
|
+
session,
|
|
939
|
+
"scopes",
|
|
940
|
+
{ frameId: resolvedFrameId } satisfies DapScopesArguments,
|
|
941
|
+
signal,
|
|
942
|
+
timeoutMs,
|
|
943
|
+
);
|
|
944
|
+
return { snapshot: buildSummary(session), scopes: response?.scopes ?? [] };
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
async variables(variableReference: number, signal?: AbortSignal, timeoutMs: number = 30_000) {
|
|
948
|
+
const session = this.#touchActiveSession();
|
|
949
|
+
const response = await this.#sendRequestWithConfig<DapVariablesResponse>(
|
|
950
|
+
session,
|
|
951
|
+
"variables",
|
|
952
|
+
{ variablesReference: variableReference } satisfies DapVariablesArguments,
|
|
953
|
+
signal,
|
|
954
|
+
timeoutMs,
|
|
955
|
+
);
|
|
956
|
+
return { snapshot: buildSummary(session), variables: response?.variables ?? [] };
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
async evaluate(
|
|
960
|
+
expression: string,
|
|
961
|
+
context: DapEvaluateArguments["context"],
|
|
962
|
+
frameId: number | undefined,
|
|
963
|
+
signal?: AbortSignal,
|
|
964
|
+
timeoutMs: number = 30_000,
|
|
965
|
+
) {
|
|
966
|
+
const session = this.#touchActiveSession();
|
|
967
|
+
// Default to the top stopped frame so callers don't need to pass
|
|
968
|
+
// frame_id explicitly for the common case.
|
|
969
|
+
const effectiveFrameId = frameId ?? session.stop.frameId;
|
|
970
|
+
const response = await this.#sendRequestWithConfig<DapEvaluateResponse>(
|
|
971
|
+
session,
|
|
972
|
+
"evaluate",
|
|
973
|
+
{
|
|
974
|
+
expression,
|
|
975
|
+
context,
|
|
976
|
+
...(effectiveFrameId !== undefined ? { frameId: effectiveFrameId } : {}),
|
|
977
|
+
} satisfies DapEvaluateArguments,
|
|
978
|
+
signal,
|
|
979
|
+
timeoutMs,
|
|
980
|
+
);
|
|
981
|
+
return { snapshot: buildSummary(session), evaluation: response };
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
getOutput(limitBytes?: number): DapOutputSnapshot {
|
|
985
|
+
const session = this.#touchActiveSession();
|
|
986
|
+
const output = session.outputChunks.join("");
|
|
987
|
+
if (!limitBytes || limitBytes <= 0 || session.outputBufferedBytes <= limitBytes) {
|
|
988
|
+
return { snapshot: buildSummary(session), output };
|
|
989
|
+
}
|
|
990
|
+
// Byte-slice the tail once; a torn code point at the cut decodes as U+FFFD.
|
|
991
|
+
const buffer = Buffer.from(output, "utf-8");
|
|
992
|
+
if (buffer.length <= limitBytes) {
|
|
993
|
+
return { snapshot: buildSummary(session), output };
|
|
994
|
+
}
|
|
995
|
+
return { snapshot: buildSummary(session), output: buffer.subarray(buffer.length - limitBytes).toString("utf-8") };
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
async terminate(signal?: AbortSignal, timeoutMs: number = 30_000): Promise<DapSessionSummary | null> {
|
|
999
|
+
const session = this.#getActiveSessionOrNull();
|
|
1000
|
+
if (!session) return null;
|
|
1001
|
+
session.lastUsedAt = Date.now();
|
|
1002
|
+
if (session.status !== "terminated") {
|
|
1003
|
+
if (session.capabilities?.supportsTerminateRequest) {
|
|
1004
|
+
await untilAborted(
|
|
1005
|
+
signal,
|
|
1006
|
+
session.client.sendRequest("terminate", undefined, signal, timeoutMs).catch(() => undefined),
|
|
1007
|
+
);
|
|
1008
|
+
}
|
|
1009
|
+
await untilAborted(
|
|
1010
|
+
signal,
|
|
1011
|
+
session.client
|
|
1012
|
+
.sendRequest("disconnect", { terminateDebuggee: true }, signal, timeoutMs)
|
|
1013
|
+
.catch(() => undefined),
|
|
1014
|
+
);
|
|
1015
|
+
}
|
|
1016
|
+
session.status = "terminated";
|
|
1017
|
+
const summary = buildSummary(session);
|
|
1018
|
+
await this.#disposeSession(session);
|
|
1019
|
+
return summary;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
#startCleanupTimer(): void {
|
|
1023
|
+
if (this.#cleanupLoopPromise) return;
|
|
1024
|
+
this.#cleanupLoopPromise = this.#runCleanupLoop();
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
async #runCleanupLoop(): Promise<void> {
|
|
1028
|
+
for await (const _ of timers.setInterval(CLEANUP_INTERVAL_MS, null, { ref: false })) {
|
|
1029
|
+
try {
|
|
1030
|
+
this.#cleanupIdleSessions();
|
|
1031
|
+
} catch (error) {
|
|
1032
|
+
logger.error("DAP idle session cleanup failed", { error: toErrorMessage(error) });
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
#cleanupIdleSessions(): void {
|
|
1038
|
+
if (this.#sessions.size === 0) return;
|
|
1039
|
+
const now = Date.now();
|
|
1040
|
+
for (const session of this.#sessions.values()) {
|
|
1041
|
+
if (
|
|
1042
|
+
session.status === "terminated" ||
|
|
1043
|
+
now - session.lastUsedAt > IDLE_TIMEOUT_MS ||
|
|
1044
|
+
!session.client.isAlive()
|
|
1045
|
+
) {
|
|
1046
|
+
this.#disposeSession(session);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
async #ensureLaunchSlot(): Promise<void> {
|
|
1052
|
+
const active = this.#getActiveSessionOrNull();
|
|
1053
|
+
if (!active) return;
|
|
1054
|
+
if (active.status === "terminated" || !active.client.isAlive()) {
|
|
1055
|
+
await this.#disposeSession(active);
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1058
|
+
throw new Error(`Debug session ${active.id} is still active. Terminate it before launching another.`);
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
#registerSession(client: DapClient, adapter: DapResolvedAdapter, cwd: string, program?: string): DapSession {
|
|
1062
|
+
const session: DapSession = {
|
|
1063
|
+
id: `debug-${++this.#nextId}`,
|
|
1064
|
+
adapter,
|
|
1065
|
+
cwd,
|
|
1066
|
+
program,
|
|
1067
|
+
client,
|
|
1068
|
+
status: "launching",
|
|
1069
|
+
launchedAt: Date.now(),
|
|
1070
|
+
lastUsedAt: Date.now(),
|
|
1071
|
+
breakpoints: new Map(),
|
|
1072
|
+
functionBreakpoints: [],
|
|
1073
|
+
instructionBreakpoints: [],
|
|
1074
|
+
dataBreakpoints: [],
|
|
1075
|
+
breakpointMutationQueue: Promise.resolve(),
|
|
1076
|
+
outputChunks: [],
|
|
1077
|
+
outputBytes: 0,
|
|
1078
|
+
outputBufferedBytes: 0,
|
|
1079
|
+
outputTruncated: false,
|
|
1080
|
+
stop: {},
|
|
1081
|
+
threads: [],
|
|
1082
|
+
lastStackFrames: [],
|
|
1083
|
+
initializedSeen: false,
|
|
1084
|
+
needsConfigurationDone: false,
|
|
1085
|
+
configurationDoneSent: false,
|
|
1086
|
+
};
|
|
1087
|
+
client.onReverseRequest("runInTerminal", async rawArgs => {
|
|
1088
|
+
const args = (rawArgs ?? {}) as DapRunInTerminalArguments;
|
|
1089
|
+
if (!Array.isArray(args.args) || args.args.length === 0) {
|
|
1090
|
+
throw new Error("runInTerminal request did not include a command");
|
|
1091
|
+
}
|
|
1092
|
+
const env = Object.fromEntries(
|
|
1093
|
+
Object.entries(args.env ?? {}).filter((entry): entry is [string, string] => entry[1] !== null),
|
|
1094
|
+
);
|
|
1095
|
+
const proc = ptree.spawn(args.args, {
|
|
1096
|
+
cwd: args.cwd ?? session.cwd,
|
|
1097
|
+
stdin: "pipe",
|
|
1098
|
+
env: {
|
|
1099
|
+
...Bun.env,
|
|
1100
|
+
...NON_INTERACTIVE_ENV,
|
|
1101
|
+
...env,
|
|
1102
|
+
},
|
|
1103
|
+
detached: true,
|
|
1104
|
+
});
|
|
1105
|
+
return { processId: proc.pid } satisfies DapRunInTerminalResponse;
|
|
1106
|
+
});
|
|
1107
|
+
client.onReverseRequest("startDebugging", async rawArgs => {
|
|
1108
|
+
const startArgs = (rawArgs ?? {}) as Partial<DapStartDebuggingArguments>;
|
|
1109
|
+
const request = startArgs.request === "attach" ? "attach" : "launch";
|
|
1110
|
+
const configuration =
|
|
1111
|
+
startArgs.configuration && typeof startArgs.configuration === "object" ? startArgs.configuration : {};
|
|
1112
|
+
logger.debug("Adapter requested child debug session", {
|
|
1113
|
+
adapter: session.adapter.name,
|
|
1114
|
+
sessionId: session.id,
|
|
1115
|
+
request,
|
|
1116
|
+
name: typeof configuration.name === "string" ? configuration.name : undefined,
|
|
1117
|
+
});
|
|
1118
|
+
return {};
|
|
1119
|
+
});
|
|
1120
|
+
client.onEvent("output", body => {
|
|
1121
|
+
truncateOutput(session, (body as DapOutputEventBody | undefined)?.output ?? "");
|
|
1122
|
+
});
|
|
1123
|
+
client.onEvent("initialized", () => {
|
|
1124
|
+
session.initializedSeen = true;
|
|
1125
|
+
session.status = session.configurationDoneSent ? session.status : "configuring";
|
|
1126
|
+
});
|
|
1127
|
+
client.onEvent("stopped", body => {
|
|
1128
|
+
this.#handleStoppedEvent(session, body as DapStoppedEventBody);
|
|
1129
|
+
});
|
|
1130
|
+
client.onEvent("continued", body => {
|
|
1131
|
+
const continued = body as { threadId?: number } | undefined;
|
|
1132
|
+
session.status = "running";
|
|
1133
|
+
session.stop = { threadId: continued?.threadId };
|
|
1134
|
+
session.lastStackFrames = [];
|
|
1135
|
+
});
|
|
1136
|
+
client.onEvent("exited", body => {
|
|
1137
|
+
session.exitCode = (body as DapExitedEventBody | undefined)?.exitCode;
|
|
1138
|
+
});
|
|
1139
|
+
client.onEvent("terminated", () => {
|
|
1140
|
+
session.status = "terminated";
|
|
1141
|
+
});
|
|
1142
|
+
this.#sessions.set(session.id, session);
|
|
1143
|
+
this.#activeSessionId = session.id;
|
|
1144
|
+
const heartbeat = setInterval(() => {
|
|
1145
|
+
if (!client.isAlive()) {
|
|
1146
|
+
session.status = "terminated";
|
|
1147
|
+
}
|
|
1148
|
+
}, HEARTBEAT_INTERVAL_MS);
|
|
1149
|
+
heartbeat.unref?.();
|
|
1150
|
+
client.proc.exited.finally(() => clearInterval(heartbeat));
|
|
1151
|
+
return session;
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
#buildInitializeArguments(adapter: DapResolvedAdapter): DapInitializeArguments {
|
|
1155
|
+
return {
|
|
1156
|
+
clientID: "omp",
|
|
1157
|
+
clientName: "Oh My Pi",
|
|
1158
|
+
adapterID: adapter.name,
|
|
1159
|
+
locale: "en-US",
|
|
1160
|
+
linesStartAt1: true,
|
|
1161
|
+
columnsStartAt1: true,
|
|
1162
|
+
pathFormat: "path",
|
|
1163
|
+
supportsRunInTerminalRequest: true,
|
|
1164
|
+
supportsStartDebuggingRequest: true,
|
|
1165
|
+
supportsMemoryReferences: true,
|
|
1166
|
+
supportsVariableType: true,
|
|
1167
|
+
supportsInvalidatedEvent: true,
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
/**
|
|
1172
|
+
* Wait for the adapter's `initialized` event (if not already received),
|
|
1173
|
+
* then send `configurationDone`. Many adapters block the `launch`/`attach`
|
|
1174
|
+
* response until this handshake completes.
|
|
1175
|
+
*/
|
|
1176
|
+
async #completeConfigurationHandshake(
|
|
1177
|
+
session: DapSession,
|
|
1178
|
+
signal?: AbortSignal,
|
|
1179
|
+
timeoutMs: number = 30_000,
|
|
1180
|
+
): Promise<void> {
|
|
1181
|
+
if (!session.needsConfigurationDone || session.configurationDoneSent) {
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
// Wait for the initialized event if we haven't seen it yet.
|
|
1185
|
+
if (!session.initializedSeen) {
|
|
1186
|
+
try {
|
|
1187
|
+
await untilAborted(signal, session.client.waitForEvent("initialized", undefined, signal, timeoutMs));
|
|
1188
|
+
} catch {
|
|
1189
|
+
// Adapter may not send initialized (e.g. it already terminated).
|
|
1190
|
+
// Proceed anyway — the launch/attach response will surface any real error.
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
await session.client.sendRequest("configurationDone", {}, signal, timeoutMs);
|
|
1195
|
+
session.configurationDoneSent = true;
|
|
1196
|
+
if (session.status === "configuring") {
|
|
1197
|
+
session.status = "running";
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
#handleStoppedEvent(session: DapSession, stopped: DapStoppedEventBody): void {
|
|
1202
|
+
session.status = "stopped";
|
|
1203
|
+
session.stop = {
|
|
1204
|
+
threadId: stopped.threadId,
|
|
1205
|
+
reason: stopped.reason,
|
|
1206
|
+
description: stopped.description,
|
|
1207
|
+
text: stopped.text,
|
|
1208
|
+
};
|
|
1209
|
+
session.lastStackFrames = [];
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
#applyTopFrame(session: DapSession, frame: DapStackFrame | undefined): void {
|
|
1213
|
+
if (!frame) return;
|
|
1214
|
+
session.stop.frameId = frame.id;
|
|
1215
|
+
session.stop.frameName = frame.name;
|
|
1216
|
+
session.stop.instructionPointerReference = frame.instructionPointerReference;
|
|
1217
|
+
session.stop.source = frame.source;
|
|
1218
|
+
session.stop.line = frame.line;
|
|
1219
|
+
session.stop.column = frame.column;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
/**
|
|
1223
|
+
* Fetch the top stack frame from the adapter and apply it to the session's
|
|
1224
|
+
* stop location. Called outside the event dispatch loop to avoid deadlocking
|
|
1225
|
+
* the message reader.
|
|
1226
|
+
*/
|
|
1227
|
+
async #fetchTopFrame(session: DapSession, signal?: AbortSignal, timeoutMs: number = 5_000): Promise<void> {
|
|
1228
|
+
if (session.stop.threadId === undefined) return;
|
|
1229
|
+
try {
|
|
1230
|
+
const response = await session.client.sendRequest<DapStackTraceResponse>(
|
|
1231
|
+
"stackTrace",
|
|
1232
|
+
{ threadId: session.stop.threadId, levels: 1 } satisfies DapStackTraceArguments,
|
|
1233
|
+
signal,
|
|
1234
|
+
timeoutMs,
|
|
1235
|
+
);
|
|
1236
|
+
session.lastStackFrames = response?.stackFrames ?? [];
|
|
1237
|
+
this.#applyTopFrame(session, session.lastStackFrames[0]);
|
|
1238
|
+
} catch (error) {
|
|
1239
|
+
logger.debug("Failed to capture stopped frame", {
|
|
1240
|
+
sessionId: session.id,
|
|
1241
|
+
error: toErrorMessage(error),
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
async #step(command: "stepIn" | "stepOut" | "next", signal?: AbortSignal, timeoutMs: number = 30_000) {
|
|
1247
|
+
const session = this.#touchActiveSession();
|
|
1248
|
+
const threadId = await this.#resolveThreadId(session, signal, timeoutMs);
|
|
1249
|
+
// Reset state and subscribe BEFORE sending the step command to avoid
|
|
1250
|
+
// missing events that arrive in the same buffer as the response.
|
|
1251
|
+
session.stop = {};
|
|
1252
|
+
session.lastStackFrames = [];
|
|
1253
|
+
session.status = "running";
|
|
1254
|
+
const outcomePromise = this.#prepareStopOutcome(session, signal, timeoutMs);
|
|
1255
|
+
await this.#sendRequestWithConfig(session, command, { threadId } satisfies DapStepArguments, signal, timeoutMs);
|
|
1256
|
+
return this.#awaitStopOutcome(session, outcomePromise, signal, timeoutMs);
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
/**
|
|
1260
|
+
* Create a promise that resolves when the session stops, terminates, or exits.
|
|
1261
|
+
* MUST be called before the command that triggers the event.
|
|
1262
|
+
*/
|
|
1263
|
+
#prepareStopOutcome(session: DapSession, signal?: AbortSignal, timeoutMs: number = 30_000): Promise<unknown> {
|
|
1264
|
+
const promises = [
|
|
1265
|
+
session.client.waitForEvent("stopped", undefined, signal, timeoutMs),
|
|
1266
|
+
session.client.waitForEvent("terminated", undefined, signal, timeoutMs),
|
|
1267
|
+
session.client.waitForEvent("exited", undefined, signal, timeoutMs),
|
|
1268
|
+
];
|
|
1269
|
+
// Promise.race leaves the losing waiters pending; their timeouts would
|
|
1270
|
+
// otherwise surface as unhandled rejections once they fire.
|
|
1271
|
+
for (const p of promises) {
|
|
1272
|
+
p.catch(() => {});
|
|
1273
|
+
}
|
|
1274
|
+
const outcome = Promise.race(promises);
|
|
1275
|
+
outcome.catch(() => {});
|
|
1276
|
+
return outcome;
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
/**
|
|
1280
|
+
* Await a pre-subscribed stop outcome, then fetch the top frame if stopped.
|
|
1281
|
+
*/
|
|
1282
|
+
async #awaitStopOutcome(
|
|
1283
|
+
session: DapSession,
|
|
1284
|
+
outcomePromise: Promise<unknown>,
|
|
1285
|
+
signal?: AbortSignal,
|
|
1286
|
+
timeoutMs: number = 30_000,
|
|
1287
|
+
): Promise<DapContinueOutcome> {
|
|
1288
|
+
try {
|
|
1289
|
+
await untilAborted(signal, outcomePromise);
|
|
1290
|
+
if (session.status === "stopped") {
|
|
1291
|
+
await this.#fetchTopFrame(session, signal, Math.min(timeoutMs, 5_000));
|
|
1292
|
+
}
|
|
1293
|
+
const state =
|
|
1294
|
+
session.status === "stopped" ? "stopped" : session.status === "terminated" ? "terminated" : "running";
|
|
1295
|
+
return { snapshot: buildSummary(session), state, timedOut: false };
|
|
1296
|
+
} catch (error) {
|
|
1297
|
+
if (signal?.aborted) {
|
|
1298
|
+
throw error;
|
|
1299
|
+
}
|
|
1300
|
+
return { snapshot: buildSummary(session), state: "running", timedOut: session.status === "running" };
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
async #resolveThreadId(session: DapSession, signal?: AbortSignal, timeoutMs: number = 30_000): Promise<number> {
|
|
1305
|
+
if (session.stop.threadId !== undefined) {
|
|
1306
|
+
return session.stop.threadId;
|
|
1307
|
+
}
|
|
1308
|
+
if (session.threads.length > 0) {
|
|
1309
|
+
return session.threads[0].id;
|
|
1310
|
+
}
|
|
1311
|
+
const response = await session.client.sendRequest<DapThreadsResponse>("threads", undefined, signal, timeoutMs);
|
|
1312
|
+
session.threads = response?.threads ?? [];
|
|
1313
|
+
const threadId = session.threads[0]?.id;
|
|
1314
|
+
if (threadId === undefined) {
|
|
1315
|
+
throw new Error("Debugger reported no threads.");
|
|
1316
|
+
}
|
|
1317
|
+
return threadId;
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
async #sendRequestWithConfig<TBody>(
|
|
1321
|
+
session: DapSession,
|
|
1322
|
+
command: string,
|
|
1323
|
+
args: unknown,
|
|
1324
|
+
signal?: AbortSignal,
|
|
1325
|
+
timeoutMs: number = 30_000,
|
|
1326
|
+
): Promise<TBody> {
|
|
1327
|
+
await this.#ensureConfigurationDone(session, signal, timeoutMs);
|
|
1328
|
+
const body = await session.client.sendRequest<TBody>(command, args, signal, timeoutMs);
|
|
1329
|
+
session.lastUsedAt = Date.now();
|
|
1330
|
+
return body;
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
async #ensureConfigurationDone(
|
|
1334
|
+
session: DapSession,
|
|
1335
|
+
signal?: AbortSignal,
|
|
1336
|
+
timeoutMs: number = 30_000,
|
|
1337
|
+
): Promise<void> {
|
|
1338
|
+
if (!session.needsConfigurationDone || session.configurationDoneSent) {
|
|
1339
|
+
return;
|
|
1340
|
+
}
|
|
1341
|
+
await session.client.sendRequest("configurationDone", {}, signal, timeoutMs);
|
|
1342
|
+
session.configurationDoneSent = true;
|
|
1343
|
+
if (session.status === "configuring") {
|
|
1344
|
+
session.status = "running";
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
#mapSourceBreakpoints(
|
|
1349
|
+
input: DapBreakpointRecord[],
|
|
1350
|
+
responseBreakpoints: DapBreakpoint[] | undefined,
|
|
1351
|
+
): DapBreakpointRecord[] {
|
|
1352
|
+
return input.map((entry, index) => ({
|
|
1353
|
+
line: entry.line,
|
|
1354
|
+
condition: entry.condition,
|
|
1355
|
+
id: responseBreakpoints?.[index]?.id,
|
|
1356
|
+
verified: responseBreakpoints?.[index]?.verified ?? false,
|
|
1357
|
+
message: responseBreakpoints?.[index]?.message,
|
|
1358
|
+
}));
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
#mapFunctionBreakpoints(
|
|
1362
|
+
input: DapFunctionBreakpointRecord[],
|
|
1363
|
+
responseBreakpoints: DapBreakpoint[] | undefined,
|
|
1364
|
+
): DapFunctionBreakpointRecord[] {
|
|
1365
|
+
return input.map((entry, index) => ({
|
|
1366
|
+
name: entry.name,
|
|
1367
|
+
condition: entry.condition,
|
|
1368
|
+
id: responseBreakpoints?.[index]?.id,
|
|
1369
|
+
verified: responseBreakpoints?.[index]?.verified ?? false,
|
|
1370
|
+
message: responseBreakpoints?.[index]?.message,
|
|
1371
|
+
}));
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
#mapInstructionBreakpoints(
|
|
1375
|
+
input: DapInstructionBreakpoint[],
|
|
1376
|
+
responseBreakpoints: DapBreakpoint[] | undefined,
|
|
1377
|
+
): DapInstructionBreakpointRecord[] {
|
|
1378
|
+
return input.map((entry, index) => ({
|
|
1379
|
+
instructionReference: responseBreakpoints?.[index]?.instructionReference ?? entry.instructionReference,
|
|
1380
|
+
offset: responseBreakpoints?.[index]?.offset ?? entry.offset,
|
|
1381
|
+
condition: entry.condition,
|
|
1382
|
+
hitCondition: entry.hitCondition,
|
|
1383
|
+
id: responseBreakpoints?.[index]?.id,
|
|
1384
|
+
verified: responseBreakpoints?.[index]?.verified ?? false,
|
|
1385
|
+
message: responseBreakpoints?.[index]?.message,
|
|
1386
|
+
}));
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
#mapDataBreakpoints(
|
|
1390
|
+
input: DapDataBreakpoint[],
|
|
1391
|
+
responseBreakpoints: DapBreakpoint[] | undefined,
|
|
1392
|
+
): DapDataBreakpointRecord[] {
|
|
1393
|
+
return input.map((entry, index) => ({
|
|
1394
|
+
dataId: entry.dataId,
|
|
1395
|
+
accessType: entry.accessType,
|
|
1396
|
+
condition: entry.condition,
|
|
1397
|
+
hitCondition: entry.hitCondition,
|
|
1398
|
+
id: responseBreakpoints?.[index]?.id,
|
|
1399
|
+
verified: responseBreakpoints?.[index]?.verified ?? false,
|
|
1400
|
+
message: responseBreakpoints?.[index]?.message,
|
|
1401
|
+
}));
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
#touchActiveSession(): DapSession {
|
|
1405
|
+
const session = this.#getActiveSessionOrThrow();
|
|
1406
|
+
session.lastUsedAt = Date.now();
|
|
1407
|
+
if (session.status !== "terminated" && !session.client.isAlive()) {
|
|
1408
|
+
session.status = "terminated";
|
|
1409
|
+
}
|
|
1410
|
+
return session;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
#getActiveSessionOrNull(): DapSession | null {
|
|
1414
|
+
if (!this.#activeSessionId) {
|
|
1415
|
+
return null;
|
|
1416
|
+
}
|
|
1417
|
+
const session = this.#sessions.get(this.#activeSessionId) ?? null;
|
|
1418
|
+
if (!session) {
|
|
1419
|
+
this.#activeSessionId = null;
|
|
1420
|
+
}
|
|
1421
|
+
return session;
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
#getActiveSessionOrThrow(): DapSession {
|
|
1425
|
+
const session = this.#getActiveSessionOrNull();
|
|
1426
|
+
if (!session) {
|
|
1427
|
+
throw new Error("No active debug session. Launch or attach first.");
|
|
1428
|
+
}
|
|
1429
|
+
return session;
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
#disposeSession(session: DapSession) {
|
|
1433
|
+
if (this.#activeSessionId === session.id) {
|
|
1434
|
+
this.#activeSessionId = null;
|
|
1435
|
+
}
|
|
1436
|
+
this.#sessions.delete(session.id);
|
|
1437
|
+
void session.client.dispose().catch(() => {});
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
export const dapSessionManager = new DapSessionManager();
|