@greppleai/grip 0.0.0-stage → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +115 -0
- package/README.md +731 -2
- package/dist/bun/cli.d.ts +3 -0
- package/dist/bun/cli.d.ts.map +1 -0
- package/dist/bun/cli.js +13 -0
- package/dist/bun/cli.js.map +1 -0
- package/dist/bun/embedded-assets.d.ts +3 -0
- package/dist/bun/embedded-assets.d.ts.map +1 -0
- package/dist/bun/embedded-assets.js +52 -0
- package/dist/bun/embedded-assets.js.map +1 -0
- package/dist/bun/register-bedrock.d.ts +2 -0
- package/dist/bun/register-bedrock.d.ts.map +1 -0
- package/dist/bun/register-bedrock.js +4 -0
- package/dist/bun/register-bedrock.js.map +1 -0
- package/dist/bun/restore-sandbox-env.d.ts +13 -0
- package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
- package/dist/bun/restore-sandbox-env.js +32 -0
- package/dist/bun/restore-sandbox-env.js.map +1 -0
- package/dist/cli/args.d.ts +70 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +442 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/config-selector.d.ts +14 -0
- package/dist/cli/config-selector.d.ts.map +1 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/config-selector.js.map +1 -0
- package/dist/cli/file-processor.d.ts +15 -0
- package/dist/cli/file-processor.d.ts.map +1 -0
- package/dist/cli/file-processor.js +60 -0
- package/dist/cli/file-processor.js.map +1 -0
- package/dist/cli/initial-message.d.ts +18 -0
- package/dist/cli/initial-message.d.ts.map +1 -0
- package/dist/cli/initial-message.js +22 -0
- package/dist/cli/initial-message.js.map +1 -0
- package/dist/cli/list-models.d.ts +9 -0
- package/dist/cli/list-models.d.ts.map +1 -0
- package/dist/cli/list-models.js +98 -0
- package/dist/cli/list-models.js.map +1 -0
- package/dist/cli/session-picker.d.ts +9 -0
- package/dist/cli/session-picker.d.ts.map +1 -0
- package/dist/cli/session-picker.js +35 -0
- package/dist/cli/session-picker.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +14 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +82 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +406 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-session.d.ts +970 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +5191 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/auth-guidance.d.ts +5 -0
- package/dist/core/auth-guidance.d.ts.map +1 -0
- package/dist/core/auth-guidance.js +21 -0
- package/dist/core/auth-guidance.js.map +1 -0
- package/dist/core/auth-storage.d.ts +150 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +557 -0
- package/dist/core/auth-storage.js.map +1 -0
- package/dist/core/bash-executor.d.ts +26 -0
- package/dist/core/bash-executor.d.ts.map +1 -0
- package/dist/core/bash-executor.js +99 -0
- package/dist/core/bash-executor.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +83 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/core/compaction/branch-summarization.js +220 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +65 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -0
- package/dist/core/compaction/compaction.js +550 -0
- package/dist/core/compaction/compaction.js.map +1 -0
- package/dist/core/compaction/compression-detection-ledger.d.ts +34 -0
- package/dist/core/compaction/compression-detection-ledger.d.ts.map +1 -0
- package/dist/core/compaction/compression-detection-ledger.js +52 -0
- package/dist/core/compaction/compression-detection-ledger.js.map +1 -0
- package/dist/core/compaction/compression-detector.d.ts +71 -0
- package/dist/core/compaction/compression-detector.d.ts.map +1 -0
- package/dist/core/compaction/compression-detector.js +407 -0
- package/dist/core/compaction/compression-detector.js.map +1 -0
- package/dist/core/compaction/compression-economics.d.ts +55 -0
- package/dist/core/compaction/compression-economics.d.ts.map +1 -0
- package/dist/core/compaction/compression-economics.js +151 -0
- package/dist/core/compaction/compression-economics.js.map +1 -0
- package/dist/core/compaction/utils.d.ts +28 -0
- package/dist/core/compaction/utils.d.ts.map +1 -0
- package/dist/core/compaction/utils.js +165 -0
- package/dist/core/compaction/utils.js.map +1 -0
- package/dist/core/defaults.d.ts +3 -0
- package/dist/core/defaults.d.ts.map +1 -0
- package/dist/core/defaults.js +2 -0
- package/dist/core/defaults.js.map +1 -0
- package/dist/core/diagnostics.d.ts +18 -0
- package/dist/core/diagnostics.d.ts.map +1 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/diagnostics.js.map +1 -0
- package/dist/core/event-bus.d.ts +9 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +25 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/exec.d.ts +29 -0
- package/dist/core/exec.d.ts.map +1 -0
- package/dist/core/exec.js +75 -0
- package/dist/core/exec.js.map +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/core/export-html/ansi-to-html.js +245 -0
- package/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/dist/core/export-html/index.d.ts +21 -0
- package/dist/core/export-html/index.d.ts.map +1 -0
- package/dist/core/export-html/index.js +230 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/template.css +1066 -0
- package/dist/core/export-html/template.html +55 -0
- package/dist/core/export-html/template.js +1864 -0
- package/dist/core/export-html/tool-renderer.d.ts +32 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +108 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked.min.js +78 -0
- package/dist/core/extensions/loader.d.ts +24 -0
- package/dist/core/extensions/loader.d.ts.map +1 -0
- package/dist/core/extensions/loader.js +613 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +160 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/extensions/runner.js +962 -0
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +1311 -0
- package/dist/core/extensions/types.d.ts.map +1 -0
- package/dist/core/extensions/types.js +51 -0
- package/dist/core/extensions/types.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +20 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/dist/core/extensions/wrapper.js +22 -0
- package/dist/core/extensions/wrapper.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts +52 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -0
- package/dist/core/footer-data-provider.js +318 -0
- package/dist/core/footer-data-provider.js.map +1 -0
- package/dist/core/grip-agent.d.ts +240 -0
- package/dist/core/grip-agent.d.ts.map +1 -0
- package/dist/core/grip-agent.js +1243 -0
- package/dist/core/grip-agent.js.map +1 -0
- package/dist/core/grip-manifest.d.ts +9 -0
- package/dist/core/grip-manifest.d.ts.map +1 -0
- package/dist/core/grip-manifest.js +25 -0
- package/dist/core/grip-manifest.js.map +1 -0
- package/dist/core/hooks/aggregate.d.ts +5 -0
- package/dist/core/hooks/aggregate.d.ts.map +1 -0
- package/dist/core/hooks/aggregate.js +226 -0
- package/dist/core/hooks/aggregate.js.map +1 -0
- package/dist/core/hooks/config.d.ts +14 -0
- package/dist/core/hooks/config.d.ts.map +1 -0
- package/dist/core/hooks/config.js +372 -0
- package/dist/core/hooks/config.js.map +1 -0
- package/dist/core/hooks/executor.d.ts +12 -0
- package/dist/core/hooks/executor.d.ts.map +1 -0
- package/dist/core/hooks/executor.js +708 -0
- package/dist/core/hooks/executor.js.map +1 -0
- package/dist/core/hooks/index.d.ts +9 -0
- package/dist/core/hooks/index.d.ts.map +1 -0
- package/dist/core/hooks/index.js +14 -0
- package/dist/core/hooks/index.js.map +1 -0
- package/dist/core/hooks/matcher.d.ts +10 -0
- package/dist/core/hooks/matcher.d.ts.map +1 -0
- package/dist/core/hooks/matcher.js +70 -0
- package/dist/core/hooks/matcher.js.map +1 -0
- package/dist/core/hooks/trust-store.d.ts +38 -0
- package/dist/core/hooks/trust-store.d.ts.map +1 -0
- package/dist/core/hooks/trust-store.js +167 -0
- package/dist/core/hooks/trust-store.js.map +1 -0
- package/dist/core/hooks/types.d.ts +234 -0
- package/dist/core/hooks/types.d.ts.map +1 -0
- package/dist/core/hooks/types.js +52 -0
- package/dist/core/hooks/types.js.map +1 -0
- package/dist/core/http-dispatcher.d.ts +21 -0
- package/dist/core/http-dispatcher.d.ts.map +1 -0
- package/dist/core/http-dispatcher.js +82 -0
- package/dist/core/http-dispatcher.js.map +1 -0
- package/dist/core/instruction-resource-loader.d.ts +81 -0
- package/dist/core/instruction-resource-loader.d.ts.map +1 -0
- package/dist/core/instruction-resource-loader.js +574 -0
- package/dist/core/instruction-resource-loader.js.map +1 -0
- package/dist/core/keybindings.d.ts +399 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/keybindings.js +299 -0
- package/dist/core/keybindings.js.map +1 -0
- package/dist/core/lsp/abort.d.ts +3 -0
- package/dist/core/lsp/abort.d.ts.map +1 -0
- package/dist/core/lsp/abort.js +28 -0
- package/dist/core/lsp/abort.js.map +1 -0
- package/dist/core/lsp/client.d.ts +108 -0
- package/dist/core/lsp/client.d.ts.map +1 -0
- package/dist/core/lsp/client.js +586 -0
- package/dist/core/lsp/client.js.map +1 -0
- package/dist/core/lsp/config-loader.d.ts +44 -0
- package/dist/core/lsp/config-loader.d.ts.map +1 -0
- package/dist/core/lsp/config-loader.js +223 -0
- package/dist/core/lsp/config-loader.js.map +1 -0
- package/dist/core/lsp/config.d.ts +134 -0
- package/dist/core/lsp/config.d.ts.map +1 -0
- package/dist/core/lsp/config.js +682 -0
- package/dist/core/lsp/config.js.map +1 -0
- package/dist/core/lsp/diagnostics.d.ts +18 -0
- package/dist/core/lsp/diagnostics.d.ts.map +1 -0
- package/dist/core/lsp/diagnostics.js +311 -0
- package/dist/core/lsp/diagnostics.js.map +1 -0
- package/dist/core/lsp/file-sync.d.ts +58 -0
- package/dist/core/lsp/file-sync.d.ts.map +1 -0
- package/dist/core/lsp/file-sync.js +432 -0
- package/dist/core/lsp/file-sync.js.map +1 -0
- package/dist/core/lsp/integration.d.ts +62 -0
- package/dist/core/lsp/integration.d.ts.map +1 -0
- package/dist/core/lsp/integration.js +145 -0
- package/dist/core/lsp/integration.js.map +1 -0
- package/dist/core/lsp/language-map.d.ts +54 -0
- package/dist/core/lsp/language-map.d.ts.map +1 -0
- package/dist/core/lsp/language-map.js +300 -0
- package/dist/core/lsp/language-map.js.map +1 -0
- package/dist/core/lsp/manager.d.ts +120 -0
- package/dist/core/lsp/manager.d.ts.map +1 -0
- package/dist/core/lsp/manager.js +636 -0
- package/dist/core/lsp/manager.js.map +1 -0
- package/dist/core/lsp/navigation.d.ts +32 -0
- package/dist/core/lsp/navigation.d.ts.map +1 -0
- package/dist/core/lsp/navigation.js +327 -0
- package/dist/core/lsp/navigation.js.map +1 -0
- package/dist/core/lsp/portable-path.d.ts +18 -0
- package/dist/core/lsp/portable-path.d.ts.map +1 -0
- package/dist/core/lsp/portable-path.js +83 -0
- package/dist/core/lsp/portable-path.js.map +1 -0
- package/dist/core/lsp/refactor.d.ts +32 -0
- package/dist/core/lsp/refactor.d.ts.map +1 -0
- package/dist/core/lsp/refactor.js +519 -0
- package/dist/core/lsp/refactor.js.map +1 -0
- package/dist/core/lsp/transport.d.ts +39 -0
- package/dist/core/lsp/transport.d.ts.map +1 -0
- package/dist/core/lsp/transport.js +261 -0
- package/dist/core/lsp/transport.js.map +1 -0
- package/dist/core/messages.d.ts +34 -0
- package/dist/core/messages.d.ts.map +1 -0
- package/dist/core/messages.js +140 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/model-registry.d.ts +148 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +812 -0
- package/dist/core/model-registry.js.map +1 -0
- package/dist/core/model-resolver.d.ts +115 -0
- package/dist/core/model-resolver.d.ts.map +1 -0
- package/dist/core/model-resolver.js +498 -0
- package/dist/core/model-resolver.js.map +1 -0
- package/dist/core/output-guard.d.ts +7 -0
- package/dist/core/output-guard.d.ts.map +1 -0
- package/dist/core/output-guard.js +89 -0
- package/dist/core/output-guard.js.map +1 -0
- package/dist/core/package-manager.d.ts +209 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +2341 -0
- package/dist/core/package-manager.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +57 -0
- package/dist/core/prompt-templates.d.ts.map +1 -0
- package/dist/core/prompt-templates.js +353 -0
- package/dist/core/prompt-templates.js.map +1 -0
- package/dist/core/provider-display-names.d.ts +2 -0
- package/dist/core/provider-display-names.d.ts.map +1 -0
- package/dist/core/provider-display-names.js +33 -0
- package/dist/core/provider-display-names.js.map +1 -0
- package/dist/core/remote-workspace-protocol/contract.d.ts +465 -0
- package/dist/core/remote-workspace-protocol/contract.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/contract.js +825 -0
- package/dist/core/remote-workspace-protocol/contract.js.map +1 -0
- package/dist/core/remote-workspace-protocol/guest-shared-client.d.ts +16 -0
- package/dist/core/remote-workspace-protocol/guest-shared-client.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/guest-shared-client.js +54 -0
- package/dist/core/remote-workspace-protocol/guest-shared-client.js.map +1 -0
- package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.d.ts +23 -0
- package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.js +112 -0
- package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.js.map +1 -0
- package/dist/core/remote-workspace-protocol/guest-shared-uplink.d.ts +30 -0
- package/dist/core/remote-workspace-protocol/guest-shared-uplink.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/guest-shared-uplink.js +243 -0
- package/dist/core/remote-workspace-protocol/guest-shared-uplink.js.map +1 -0
- package/dist/core/remote-workspace-protocol/lima-owner-directory.d.ts +3 -0
- package/dist/core/remote-workspace-protocol/lima-owner-directory.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/lima-owner-directory.js +31 -0
- package/dist/core/remote-workspace-protocol/lima-owner-directory.js.map +1 -0
- package/dist/core/remote-workspace-protocol/lima-owner-lock.d.ts +9 -0
- package/dist/core/remote-workspace-protocol/lima-owner-lock.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/lima-owner-lock.js +89 -0
- package/dist/core/remote-workspace-protocol/lima-owner-lock.js.map +1 -0
- package/dist/core/remote-workspace-protocol/session.d.ts +249 -0
- package/dist/core/remote-workspace-protocol/session.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/session.js +1842 -0
- package/dist/core/remote-workspace-protocol/session.js.map +1 -0
- package/dist/core/remote-workspace-protocol/shared-transport.d.ts +71 -0
- package/dist/core/remote-workspace-protocol/shared-transport.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/shared-transport.js +68 -0
- package/dist/core/remote-workspace-protocol/shared-transport.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +32 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -0
- package/dist/core/resolve-config-value.js +257 -0
- package/dist/core/resolve-config-value.js.map +1 -0
- package/dist/core/resource-loader.d.ts +200 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +1209 -0
- package/dist/core/resource-loader.js.map +1 -0
- package/dist/core/rules.d.ts +40 -0
- package/dist/core/rules.d.ts.map +1 -0
- package/dist/core/rules.js +57 -0
- package/dist/core/rules.js.map +1 -0
- package/dist/core/sandbox/command.d.ts +25 -0
- package/dist/core/sandbox/command.d.ts.map +1 -0
- package/dist/core/sandbox/command.js +102 -0
- package/dist/core/sandbox/command.js.map +1 -0
- package/dist/core/sandbox/config.d.ts +91 -0
- package/dist/core/sandbox/config.d.ts.map +1 -0
- package/dist/core/sandbox/config.js +88 -0
- package/dist/core/sandbox/config.js.map +1 -0
- package/dist/core/sandbox/lima-guest-binary.d.ts +11 -0
- package/dist/core/sandbox/lima-guest-binary.d.ts.map +1 -0
- package/dist/core/sandbox/lima-guest-binary.js +140 -0
- package/dist/core/sandbox/lima-guest-binary.js.map +1 -0
- package/dist/core/sandbox/lima.d.ts +57 -0
- package/dist/core/sandbox/lima.d.ts.map +1 -0
- package/dist/core/sandbox/lima.js +716 -0
- package/dist/core/sandbox/lima.js.map +1 -0
- package/dist/core/sandbox/shared-lima-roots.d.ts +11 -0
- package/dist/core/sandbox/shared-lima-roots.d.ts.map +1 -0
- package/dist/core/sandbox/shared-lima-roots.js +25 -0
- package/dist/core/sandbox/shared-lima-roots.js.map +1 -0
- package/dist/core/sandbox/update-shared-guest-binary.d.ts +8 -0
- package/dist/core/sandbox/update-shared-guest-binary.d.ts.map +1 -0
- package/dist/core/sandbox/update-shared-guest-binary.js +100 -0
- package/dist/core/sandbox/update-shared-guest-binary.js.map +1 -0
- package/dist/core/session/constants.d.ts +2 -0
- package/dist/core/session/constants.d.ts.map +1 -0
- package/dist/core/session/constants.js +2 -0
- package/dist/core/session/constants.js.map +1 -0
- package/dist/core/session/context-metadata.d.ts +5 -0
- package/dist/core/session/context-metadata.d.ts.map +1 -0
- package/dist/core/session/context-metadata.js +55 -0
- package/dist/core/session/context-metadata.js.map +1 -0
- package/dist/core/session/context.d.ts +14 -0
- package/dist/core/session/context.d.ts.map +1 -0
- package/dist/core/session/context.js +117 -0
- package/dist/core/session/context.js.map +1 -0
- package/dist/core/session/ids.d.ts +9 -0
- package/dist/core/session/ids.d.ts.map +1 -0
- package/dist/core/session/ids.js +21 -0
- package/dist/core/session/ids.js.map +1 -0
- package/dist/core/session/in-memory-session-manager.d.ts +17 -0
- package/dist/core/session/in-memory-session-manager.d.ts.map +1 -0
- package/dist/core/session/in-memory-session-manager.js +40 -0
- package/dist/core/session/in-memory-session-manager.js.map +1 -0
- package/dist/core/session/in-memory-session.d.ts +7 -0
- package/dist/core/session/in-memory-session.d.ts.map +1 -0
- package/dist/core/session/in-memory-session.js +11 -0
- package/dist/core/session/in-memory-session.js.map +1 -0
- package/dist/core/session/jsonl-errors.d.ts +36 -0
- package/dist/core/session/jsonl-errors.d.ts.map +1 -0
- package/dist/core/session/jsonl-errors.js +49 -0
- package/dist/core/session/jsonl-errors.js.map +1 -0
- package/dist/core/session/jsonl-helpers.d.ts +20 -0
- package/dist/core/session/jsonl-helpers.d.ts.map +1 -0
- package/dist/core/session/jsonl-helpers.js +21 -0
- package/dist/core/session/jsonl-helpers.js.map +1 -0
- package/dist/core/session/local-session-manager.d.ts +30 -0
- package/dist/core/session/local-session-manager.d.ts.map +1 -0
- package/dist/core/session/local-session-manager.js +205 -0
- package/dist/core/session/local-session-manager.js.map +1 -0
- package/dist/core/session/local-session.d.ts +9 -0
- package/dist/core/session/local-session.d.ts.map +1 -0
- package/dist/core/session/local-session.js +15 -0
- package/dist/core/session/local-session.js.map +1 -0
- package/dist/core/session/migrations.d.ts +11 -0
- package/dist/core/session/migrations.d.ts.map +1 -0
- package/dist/core/session/migrations.js +78 -0
- package/dist/core/session/migrations.js.map +1 -0
- package/dist/core/session/remote-session-client.d.ts +83 -0
- package/dist/core/session/remote-session-client.d.ts.map +1 -0
- package/dist/core/session/remote-session-client.js +224 -0
- package/dist/core/session/remote-session-client.js.map +1 -0
- package/dist/core/session/remote-session-manager.d.ts +32 -0
- package/dist/core/session/remote-session-manager.d.ts.map +1 -0
- package/dist/core/session/remote-session-manager.js +124 -0
- package/dist/core/session/remote-session-manager.js.map +1 -0
- package/dist/core/session/remote-session.d.ts +20 -0
- package/dist/core/session/remote-session.d.ts.map +1 -0
- package/dist/core/session/remote-session.js +33 -0
- package/dist/core/session/remote-session.js.map +1 -0
- package/dist/core/session/session-manager.d.ts +18 -0
- package/dist/core/session/session-manager.d.ts.map +1 -0
- package/dist/core/session/session-manager.js +2 -0
- package/dist/core/session/session-manager.js.map +1 -0
- package/dist/core/session/session.d.ts +140 -0
- package/dist/core/session/session.d.ts.map +1 -0
- package/dist/core/session/session.js +461 -0
- package/dist/core/session/session.js.map +1 -0
- package/dist/core/session/stores/in-memory-session-store.d.ts +39 -0
- package/dist/core/session/stores/in-memory-session-store.d.ts.map +1 -0
- package/dist/core/session/stores/in-memory-session-store.js +168 -0
- package/dist/core/session/stores/in-memory-session-store.js.map +1 -0
- package/dist/core/session/stores/jsonl-session-store.d.ts +97 -0
- package/dist/core/session/stores/jsonl-session-store.d.ts.map +1 -0
- package/dist/core/session/stores/jsonl-session-store.js +1140 -0
- package/dist/core/session/stores/jsonl-session-store.js.map +1 -0
- package/dist/core/session/stores/remote-session-store.d.ts +44 -0
- package/dist/core/session/stores/remote-session-store.d.ts.map +1 -0
- package/dist/core/session/stores/remote-session-store.js +159 -0
- package/dist/core/session/stores/remote-session-store.js.map +1 -0
- package/dist/core/session/stores/session-store.d.ts +42 -0
- package/dist/core/session/stores/session-store.d.ts.map +1 -0
- package/dist/core/session/stores/session-store.js +2 -0
- package/dist/core/session/stores/session-store.js.map +1 -0
- package/dist/core/session/types.d.ts +141 -0
- package/dist/core/session/types.d.ts.map +1 -0
- package/dist/core/session/types.js +2 -0
- package/dist/core/session/types.js.map +1 -0
- package/dist/core/session/usage-ledger.d.ts +18 -0
- package/dist/core/session/usage-ledger.d.ts.map +1 -0
- package/dist/core/session/usage-ledger.js +68 -0
- package/dist/core/session/usage-ledger.js.map +1 -0
- package/dist/core/session-cwd.d.ts +19 -0
- package/dist/core/session-cwd.d.ts.map +1 -0
- package/dist/core/session-cwd.js +38 -0
- package/dist/core/session-cwd.js.map +1 -0
- package/dist/core/settings-manager.d.ts +314 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +991 -0
- package/dist/core/settings-manager.js.map +1 -0
- package/dist/core/skills.d.ts +40 -0
- package/dist/core/skills.d.ts.map +1 -0
- package/dist/core/skills.js +57 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/slash-commands.d.ts +15 -0
- package/dist/core/slash-commands.d.ts.map +1 -0
- package/dist/core/slash-commands.js +36 -0
- package/dist/core/slash-commands.js.map +1 -0
- package/dist/core/source-info.d.ts +26 -0
- package/dist/core/source-info.d.ts.map +1 -0
- package/dist/core/source-info.js +27 -0
- package/dist/core/source-info.js.map +1 -0
- package/dist/core/system-prompt.d.ts +32 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +131 -0
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/telemetry.d.ts +3 -0
- package/dist/core/telemetry.d.ts.map +1 -0
- package/dist/core/telemetry.js +9 -0
- package/dist/core/telemetry.js.map +1 -0
- package/dist/core/timings.d.ts +10 -0
- package/dist/core/timings.d.ts.map +1 -0
- package/dist/core/timings.js +41 -0
- package/dist/core/timings.js.map +1 -0
- package/dist/core/tools/bash.d.ts +51 -0
- package/dist/core/tools/bash.d.ts.map +1 -0
- package/dist/core/tools/bash.js +321 -0
- package/dist/core/tools/bash.js.map +1 -0
- package/dist/core/tools/compress-context.d.ts +27 -0
- package/dist/core/tools/compress-context.d.ts.map +1 -0
- package/dist/core/tools/compress-context.js +142 -0
- package/dist/core/tools/compress-context.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +82 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/dist/core/tools/edit-diff.js +327 -0
- package/dist/core/tools/edit-diff.js.map +1 -0
- package/dist/core/tools/edit.d.ts +50 -0
- package/dist/core/tools/edit.d.ts.map +1 -0
- package/dist/core/tools/edit.js +324 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/file-mutation-queue.d.ts +8 -0
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
- package/dist/core/tools/file-mutation-queue.js +69 -0
- package/dist/core/tools/file-mutation-queue.js.map +1 -0
- package/dist/core/tools/find.d.ts +22 -0
- package/dist/core/tools/find.d.ts.map +1 -0
- package/dist/core/tools/find.js +268 -0
- package/dist/core/tools/find.js.map +1 -0
- package/dist/core/tools/grep.d.ts +27 -0
- package/dist/core/tools/grep.d.ts.map +1 -0
- package/dist/core/tools/grep.js +332 -0
- package/dist/core/tools/grep.js.map +1 -0
- package/dist/core/tools/hash-store.d.ts +12 -0
- package/dist/core/tools/hash-store.d.ts.map +1 -0
- package/dist/core/tools/hash-store.js +48 -0
- package/dist/core/tools/hash-store.js.map +1 -0
- package/dist/core/tools/hashline/apply.d.ts +40 -0
- package/dist/core/tools/hashline/apply.d.ts.map +1 -0
- package/dist/core/tools/hashline/apply.js +261 -0
- package/dist/core/tools/hashline/apply.js.map +1 -0
- package/dist/core/tools/hashline/hash.d.ts +56 -0
- package/dist/core/tools/hashline/hash.d.ts.map +1 -0
- package/dist/core/tools/hashline/hash.js +196 -0
- package/dist/core/tools/hashline/hash.js.map +1 -0
- package/dist/core/tools/hashline/parse.d.ts +8 -0
- package/dist/core/tools/hashline/parse.d.ts.map +1 -0
- package/dist/core/tools/hashline/parse.js +41 -0
- package/dist/core/tools/hashline/parse.js.map +1 -0
- package/dist/core/tools/hashline/resolve.d.ts +51 -0
- package/dist/core/tools/hashline/resolve.d.ts.map +1 -0
- package/dist/core/tools/hashline/resolve.js +187 -0
- package/dist/core/tools/hashline/resolve.js.map +1 -0
- package/dist/core/tools/hashline-utils.d.ts +6 -0
- package/dist/core/tools/hashline-utils.d.ts.map +1 -0
- package/dist/core/tools/hashline-utils.js +23 -0
- package/dist/core/tools/hashline-utils.js.map +1 -0
- package/dist/core/tools/index.d.ts +36 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/index.js +141 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/ls.d.ts +21 -0
- package/dist/core/tools/ls.d.ts.map +1 -0
- package/dist/core/tools/ls.js +156 -0
- package/dist/core/tools/ls.js.map +1 -0
- package/dist/core/tools/operations.d.ts +212 -0
- package/dist/core/tools/operations.d.ts.map +1 -0
- package/dist/core/tools/operations.js +793 -0
- package/dist/core/tools/operations.js.map +1 -0
- package/dist/core/tools/output-accumulator.d.ts +54 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -0
- package/dist/core/tools/output-accumulator.js +184 -0
- package/dist/core/tools/output-accumulator.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +9 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -0
- package/dist/core/tools/path-utils.js +99 -0
- package/dist/core/tools/path-utils.js.map +1 -0
- package/dist/core/tools/read.d.ts +32 -0
- package/dist/core/tools/read.d.ts.map +1 -0
- package/dist/core/tools/read.js +318 -0
- package/dist/core/tools/read.js.map +1 -0
- package/dist/core/tools/render-utils.d.ts +33 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -0
- package/dist/core/tools/render-utils.js +61 -0
- package/dist/core/tools/render-utils.js.map +1 -0
- package/dist/core/tools/replace-diff.d.ts +16 -0
- package/dist/core/tools/replace-diff.d.ts.map +1 -0
- package/dist/core/tools/replace-diff.js +117 -0
- package/dist/core/tools/replace-diff.js.map +1 -0
- package/dist/core/tools/replace-normalize.d.ts +2 -0
- package/dist/core/tools/replace-normalize.d.ts.map +1 -0
- package/dist/core/tools/replace-normalize.js +73 -0
- package/dist/core/tools/replace-normalize.js.map +1 -0
- package/dist/core/tools/replace-render.d.ts +51 -0
- package/dist/core/tools/replace-render.d.ts.map +1 -0
- package/dist/core/tools/replace-render.js +162 -0
- package/dist/core/tools/replace-render.js.map +1 -0
- package/dist/core/tools/runtime.d.ts +2 -0
- package/dist/core/tools/runtime.d.ts.map +1 -0
- package/dist/core/tools/runtime.js +6 -0
- package/dist/core/tools/runtime.js.map +1 -0
- package/dist/core/tools/session-history.d.ts +55 -0
- package/dist/core/tools/session-history.d.ts.map +1 -0
- package/dist/core/tools/session-history.js +649 -0
- package/dist/core/tools/session-history.js.map +1 -0
- package/dist/core/tools/subagent-agents.d.ts +29 -0
- package/dist/core/tools/subagent-agents.d.ts.map +1 -0
- package/dist/core/tools/subagent-agents.js +223 -0
- package/dist/core/tools/subagent-agents.js.map +1 -0
- package/dist/core/tools/subagent.d.ts +185 -0
- package/dist/core/tools/subagent.d.ts.map +1 -0
- package/dist/core/tools/subagent.js +1309 -0
- package/dist/core/tools/subagent.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.js +34 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -0
- package/dist/core/tools/truncate.d.ts +39 -0
- package/dist/core/tools/truncate.d.ts.map +1 -0
- package/dist/core/tools/truncate.js +215 -0
- package/dist/core/tools/truncate.js.map +1 -0
- package/dist/core/tools/websearch.d.ts +33 -0
- package/dist/core/tools/websearch.d.ts.map +1 -0
- package/dist/core/tools/websearch.js +341 -0
- package/dist/core/tools/websearch.js.map +1 -0
- package/dist/core/tools/workspace-tool-host.d.ts +102 -0
- package/dist/core/tools/workspace-tool-host.d.ts.map +1 -0
- package/dist/core/tools/workspace-tool-host.js +348 -0
- package/dist/core/tools/workspace-tool-host.js.map +1 -0
- package/dist/core/tools/write.d.ts +16 -0
- package/dist/core/tools/write.d.ts.map +1 -0
- package/dist/core/tools/write.js +204 -0
- package/dist/core/tools/write.js.map +1 -0
- package/dist/core/workspace-identity.d.ts +7 -0
- package/dist/core/workspace-identity.d.ts.map +1 -0
- package/dist/core/workspace-identity.js +2 -0
- package/dist/core/workspace-identity.js.map +1 -0
- package/dist/daemon/activity-budget.d.ts +10 -0
- package/dist/daemon/activity-budget.d.ts.map +1 -0
- package/dist/daemon/activity-budget.js +34 -0
- package/dist/daemon/activity-budget.js.map +1 -0
- package/dist/daemon/command.d.ts +6 -0
- package/dist/daemon/command.d.ts.map +1 -0
- package/dist/daemon/command.js +58 -0
- package/dist/daemon/command.js.map +1 -0
- package/dist/daemon/config.d.ts +45 -0
- package/dist/daemon/config.d.ts.map +1 -0
- package/dist/daemon/config.js +319 -0
- package/dist/daemon/config.js.map +1 -0
- package/dist/daemon/help.d.ts +2 -0
- package/dist/daemon/help.d.ts.map +1 -0
- package/dist/daemon/help.js +42 -0
- package/dist/daemon/help.js.map +1 -0
- package/dist/daemon/lsp-config.d.ts +4 -0
- package/dist/daemon/lsp-config.d.ts.map +1 -0
- package/dist/daemon/lsp-config.js +155 -0
- package/dist/daemon/lsp-config.js.map +1 -0
- package/dist/daemon/outbound-budget.d.ts +10 -0
- package/dist/daemon/outbound-budget.d.ts.map +1 -0
- package/dist/daemon/outbound-budget.js +30 -0
- package/dist/daemon/outbound-budget.js.map +1 -0
- package/dist/daemon/security.d.ts +19 -0
- package/dist/daemon/security.d.ts.map +1 -0
- package/dist/daemon/security.js +177 -0
- package/dist/daemon/security.js.map +1 -0
- package/dist/daemon/server.d.ts +20 -0
- package/dist/daemon/server.d.ts.map +1 -0
- package/dist/daemon/server.js +480 -0
- package/dist/daemon/server.js.map +1 -0
- package/dist/daemon/shared-connection.d.ts +33 -0
- package/dist/daemon/shared-connection.d.ts.map +1 -0
- package/dist/daemon/shared-connection.js +271 -0
- package/dist/daemon/shared-connection.js.map +1 -0
- package/dist/daemon/shared-revision.d.ts +5 -0
- package/dist/daemon/shared-revision.d.ts.map +1 -0
- package/dist/daemon/shared-revision.js +61 -0
- package/dist/daemon/shared-revision.js.map +1 -0
- package/dist/daemon/shared-roots.d.ts +9 -0
- package/dist/daemon/shared-roots.d.ts.map +1 -0
- package/dist/daemon/shared-roots.js +33 -0
- package/dist/daemon/shared-roots.js.map +1 -0
- package/dist/daemon/workspace-runtime.d.ts +46 -0
- package/dist/daemon/workspace-runtime.d.ts.map +1 -0
- package/dist/daemon/workspace-runtime.js +705 -0
- package/dist/daemon/workspace-runtime.js.map +1 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +107 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +39 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +765 -0
- package/dist/main.js.map +1 -0
- package/dist/migrations.d.ts +35 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +412 -0
- package/dist/migrations.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +30 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-message.js +159 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +36 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/bash-execution.js +173 -0
- package/dist/modes/interactive/components/bash-execution.js.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +18 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.js +54 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +17 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.js +45 -0
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +17 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +46 -0
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts +74 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector.js +514 -0
- package/dist/modes/interactive/components/config-selector.js.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.js +33 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +25 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-editor.js +85 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-message.js +81 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -0
- package/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/modes/interactive/components/diff.d.ts.map +1 -0
- package/dist/modes/interactive/components/diff.js +118 -0
- package/dist/modes/interactive/components/diff.js.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.js +21 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +22 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-editor.js +128 -0
- package/dist/modes/interactive/components/extension-editor.js.map +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-input.js +61 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +26 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-selector.js +83 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +36 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -0
- package/dist/modes/interactive/components/footer.js +227 -0
- package/dist/modes/interactive/components/footer.js.map +1 -0
- package/dist/modes/interactive/components/hook-execution.d.ts +19 -0
- package/dist/modes/interactive/components/hook-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/hook-execution.js +185 -0
- package/dist/modes/interactive/components/hook-execution.js.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.js +36 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +55 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
- package/dist/modes/interactive/components/login-dialog.js +176 -0
- package/dist/modes/interactive/components/login-dialog.js.map +1 -0
- package/dist/modes/interactive/components/markdown-transform.d.ts +4 -0
- package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
- package/dist/modes/interactive/components/markdown-transform.js +19 -0
- package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
- package/dist/modes/interactive/components/mermaid.d.ts +14 -0
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -0
- package/dist/modes/interactive/components/mermaid.js +228 -0
- package/dist/modes/interactive/components/mermaid.js.map +1 -0
- package/dist/modes/interactive/components/message-card.d.ts +9 -0
- package/dist/modes/interactive/components/message-card.d.ts.map +1 -0
- package/dist/modes/interactive/components/message-card.js +24 -0
- package/dist/modes/interactive/components/message-card.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +52 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/model-selector.js +296 -0
- package/dist/modes/interactive/components/model-selector.js.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +33 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.js +165 -0
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +50 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +300 -0
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +22 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.js +144 -0
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +108 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector.js +835 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +81 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector.js +455 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +39 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +18 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +48 -0
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/theme-selector.js +50 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.js +51 -0
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +67 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +312 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +127 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector.js +1098 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +114 -0
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +16 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message.js +50 -0
- package/dist/modes/interactive/components/user-message.js.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +554 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +5870 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +86 -0
- package/dist/modes/interactive/theme/light.json +85 -0
- package/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/dist/modes/interactive/theme/theme.d.ts +109 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +1040 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -0
- package/dist/modes/json-event.d.ts +28 -0
- package/dist/modes/json-event.d.ts.map +1 -0
- package/dist/modes/json-event.js +12 -0
- package/dist/modes/json-event.js.map +1 -0
- package/dist/modes/print-mode.d.ts +29 -0
- package/dist/modes/print-mode.d.ts.map +1 -0
- package/dist/modes/print-mode.js +142 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/modes/rpc/jsonl.d.ts +17 -0
- package/dist/modes/rpc/jsonl.d.ts.map +1 -0
- package/dist/modes/rpc/jsonl.js +49 -0
- package/dist/modes/rpc/jsonl.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +321 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client.js +755 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-mode.js +963 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +652 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-types.js +8 -0
- package/dist/modes/rpc/rpc-types.js.map +1 -0
- package/dist/package-manager-cli.d.ts +4 -0
- package/dist/package-manager-cli.d.ts.map +1 -0
- package/dist/package-manager-cli.js +488 -0
- package/dist/package-manager-cli.js.map +1 -0
- package/dist/utils/ansi.d.ts +2 -0
- package/dist/utils/ansi.d.ts.map +1 -0
- package/dist/utils/ansi.js +25 -0
- package/dist/utils/ansi.js.map +1 -0
- package/dist/utils/changelog.d.ts +23 -0
- package/dist/utils/changelog.d.ts.map +1 -0
- package/dist/utils/changelog.js +74 -0
- package/dist/utils/changelog.js.map +1 -0
- package/dist/utils/child-process.d.ts +15 -0
- package/dist/utils/child-process.d.ts.map +1 -0
- package/dist/utils/child-process.js +88 -0
- package/dist/utils/child-process.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts +13 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -0
- package/dist/utils/clipboard-image.js +248 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/clipboard-native.d.ts +11 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -0
- package/dist/utils/clipboard-native.js +20 -0
- package/dist/utils/clipboard-native.js.map +1 -0
- package/dist/utils/clipboard.d.ts +4 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/clipboard.js +171 -0
- package/dist/utils/clipboard.js.map +1 -0
- package/dist/utils/deprecation.d.ts +4 -0
- package/dist/utils/deprecation.d.ts.map +1 -0
- package/dist/utils/deprecation.js +13 -0
- package/dist/utils/deprecation.js.map +1 -0
- package/dist/utils/directory-completions.d.ts +5 -0
- package/dist/utils/directory-completions.d.ts.map +1 -0
- package/dist/utils/directory-completions.js +64 -0
- package/dist/utils/directory-completions.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts +6 -0
- package/dist/utils/exif-orientation.d.ts.map +1 -0
- package/dist/utils/exif-orientation.js +166 -0
- package/dist/utils/exif-orientation.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +8 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +26 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/fs-watch.d.ts +5 -0
- package/dist/utils/fs-watch.d.ts.map +1 -0
- package/dist/utils/fs-watch.js +25 -0
- package/dist/utils/fs-watch.js.map +1 -0
- package/dist/utils/git.d.ts +27 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +237 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/grip-user-agent.d.ts +2 -0
- package/dist/utils/grip-user-agent.d.ts.map +1 -0
- package/dist/utils/grip-user-agent.js +5 -0
- package/dist/utils/grip-user-agent.js.map +1 -0
- package/dist/utils/html.d.ts +7 -0
- package/dist/utils/html.d.ts.map +1 -0
- package/dist/utils/html.js +40 -0
- package/dist/utils/html.js.map +1 -0
- package/dist/utils/image-convert.d.ts +12 -0
- package/dist/utils/image-convert.d.ts.map +1 -0
- package/dist/utils/image-convert.js +43 -0
- package/dist/utils/image-convert.js.map +1 -0
- package/dist/utils/image-process.d.ts +18 -0
- package/dist/utils/image-process.d.ts.map +1 -0
- package/dist/utils/image-process.js +83 -0
- package/dist/utils/image-process.js.map +1 -0
- package/dist/utils/image-resize-core.d.ts +30 -0
- package/dist/utils/image-resize-core.d.ts.map +1 -0
- package/dist/utils/image-resize-core.js +133 -0
- package/dist/utils/image-resize-core.js.map +1 -0
- package/dist/utils/image-resize-worker.d.ts +2 -0
- package/dist/utils/image-resize-worker.d.ts.map +1 -0
- package/dist/utils/image-resize-worker.js +31 -0
- package/dist/utils/image-resize-worker.js.map +1 -0
- package/dist/utils/image-resize.d.ts +19 -0
- package/dist/utils/image-resize.d.ts.map +1 -0
- package/dist/utils/image-resize.js +86 -0
- package/dist/utils/image-resize.js.map +1 -0
- package/dist/utils/json.d.ts +3 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +7 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/mime.d.ts +3 -0
- package/dist/utils/mime.d.ts.map +1 -0
- package/dist/utils/mime.js +110 -0
- package/dist/utils/mime.js.map +1 -0
- package/dist/utils/open-browser.d.ts +9 -0
- package/dist/utils/open-browser.d.ts.map +1 -0
- package/dist/utils/open-browser.js +22 -0
- package/dist/utils/open-browser.js.map +1 -0
- package/dist/utils/paths.d.ts +31 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +87 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/photon.d.ts +22 -0
- package/dist/utils/photon.d.ts.map +1 -0
- package/dist/utils/photon.js +126 -0
- package/dist/utils/photon.js.map +1 -0
- package/dist/utils/shell.d.ts +28 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +188 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/syntax-highlight.d.ts +12 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -0
- package/dist/utils/syntax-highlight.js +125 -0
- package/dist/utils/syntax-highlight.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +5 -0
- package/dist/utils/tools-manager.d.ts.map +1 -0
- package/dist/utils/tools-manager.js +329 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/dist/utils/version-check.d.ts +14 -0
- package/dist/utils/version-check.d.ts.map +1 -0
- package/dist/utils/version-check.js +91 -0
- package/dist/utils/version-check.js.map +1 -0
- package/dist/utils/windows-self-update.d.ts +3 -0
- package/dist/utils/windows-self-update.d.ts.map +1 -0
- package/dist/utils/windows-self-update.js +77 -0
- package/dist/utils/windows-self-update.js.map +1 -0
- package/docs/compaction.md +408 -0
- package/docs/custom-provider.md +714 -0
- package/docs/daemon-architecture.md +399 -0
- package/docs/daemon.md +112 -0
- package/docs/development.md +72 -0
- package/docs/docs.json +164 -0
- package/docs/extensions.md +2745 -0
- package/docs/hooks.md +85 -0
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/exy.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/index.md +77 -0
- package/docs/json.md +89 -0
- package/docs/keybindings.md +230 -0
- package/docs/lsp.md +499 -0
- package/docs/migrating-to-grip.md +18 -0
- package/docs/models.md +496 -0
- package/docs/packages.md +228 -0
- package/docs/prompt-templates.md +88 -0
- package/docs/providers.md +251 -0
- package/docs/quickstart.md +159 -0
- package/docs/rpc.md +1492 -0
- package/docs/rules.md +117 -0
- package/docs/sandbox.md +104 -0
- package/docs/sdk.md +360 -0
- package/docs/session-format.md +414 -0
- package/docs/sessions.md +137 -0
- package/docs/settings.md +372 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +246 -0
- package/docs/terminal-setup.md +112 -0
- package/docs/termux.md +112 -0
- package/docs/themes.md +295 -0
- package/docs/tmux.md +61 -0
- package/docs/tui.md +918 -0
- package/docs/usage.md +304 -0
- package/docs/windows.md +17 -0
- package/examples/README.md +29 -0
- package/examples/daemon-docker/Dockerfile +43 -0
- package/examples/daemon-docker/README.md +45 -0
- package/examples/extensions/README.md +208 -0
- package/examples/extensions/auto-commit-on-exit.ts +46 -0
- package/examples/extensions/bash-spawn-hook.ts +30 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/border-status-editor.ts +145 -0
- package/examples/extensions/built-in-tool-renderer.ts +259 -0
- package/examples/extensions/claude-rules.ts +86 -0
- package/examples/extensions/commands.ts +82 -0
- package/examples/extensions/confirm-destructive.ts +59 -0
- package/examples/extensions/custom-compaction.ts +131 -0
- package/examples/extensions/custom-footer.ts +79 -0
- package/examples/extensions/custom-header.ts +73 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +707 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +402 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +104 -0
- package/examples/extensions/dirty-repo-guard.ts +59 -0
- package/examples/extensions/doom-overlay/README.md +46 -0
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/examples/extensions/doom-overlay/doom-component.ts +133 -0
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/examples/extensions/doom-overlay/index.ts +74 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/examples/extensions/dynamic-resources/RULES.md +8 -0
- package/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/examples/extensions/dynamic-resources/index.ts +16 -0
- package/examples/extensions/dynamic-tools.ts +74 -0
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/file-trigger.ts +41 -0
- package/examples/extensions/git-checkpoint.ts +53 -0
- package/examples/extensions/git-merge-and-resolve.ts +125 -0
- package/examples/extensions/github-issue-autocomplete.ts +191 -0
- package/examples/extensions/handoff.ts +191 -0
- package/examples/extensions/hello.ts +26 -0
- package/examples/extensions/hidden-thinking-label.ts +53 -0
- package/examples/extensions/inline-bash.ts +104 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/interactive-shell.ts +194 -0
- package/examples/extensions/mac-system-theme.ts +47 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/minimal-mode.ts +428 -0
- package/examples/extensions/modal-editor.ts +86 -0
- package/examples/extensions/model-status.ts +31 -0
- package/examples/extensions/notify.ts +55 -0
- package/examples/extensions/overlay-qa-tests.ts +1374 -0
- package/examples/extensions/overlay-test.ts +171 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +65 -0
- package/examples/extensions/plan-mode/index.ts +346 -0
- package/examples/extensions/plan-mode/utils.ts +172 -0
- package/examples/extensions/preset.ts +426 -0
- package/examples/extensions/prompt-customizer.ts +97 -0
- package/examples/extensions/protected-paths.ts +29 -0
- package/examples/extensions/provider-payload.ts +18 -0
- package/examples/extensions/qna.ts +125 -0
- package/examples/extensions/question.ts +294 -0
- package/examples/extensions/questionnaire.ts +459 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/reload-runtime.ts +37 -0
- package/examples/extensions/rpc-demo.ts +118 -0
- package/examples/extensions/sandbox/index.ts +320 -0
- package/examples/extensions/sandbox/package-lock.json +92 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +381 -0
- package/examples/extensions/space-invaders.ts +597 -0
- package/examples/extensions/status-line.ts +32 -0
- package/examples/extensions/structured-output.ts +65 -0
- package/examples/extensions/subagent/README.md +175 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +126 -0
- package/examples/extensions/subagent/index.ts +1083 -0
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/examples/extensions/subagent/prompts/implement.md +10 -0
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/examples/extensions/summarize.ts +186 -0
- package/examples/extensions/system-prompt-header.ts +17 -0
- package/examples/extensions/tic-tac-toe.ts +1091 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/titlebar-spinner.ts +58 -0
- package/examples/extensions/todo.ts +306 -0
- package/examples/extensions/tool-override.ts +144 -0
- package/examples/extensions/tools.ts +141 -0
- package/examples/extensions/trigger-compact.ts +50 -0
- package/examples/extensions/truncated-tool.ts +200 -0
- package/examples/extensions/widget-placement.ts +9 -0
- package/examples/extensions/with-deps/index.ts +32 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/extensions/working-indicator.ts +123 -0
- package/examples/extensions/working-message-test.ts +25 -0
- package/examples/remote-session-server/README.md +71 -0
- package/examples/remote-session-server/server.ts +353 -0
- package/examples/rpc-extension-ui.ts +642 -0
- package/examples/sdk/01-minimal.ts +27 -0
- package/examples/sdk/02-custom-model.ts +54 -0
- package/examples/sdk/03-custom-prompt.ts +76 -0
- package/examples/sdk/04-skills.ts +60 -0
- package/examples/sdk/05-tools.ts +55 -0
- package/examples/sdk/06-extensions.ts +94 -0
- package/examples/sdk/07-context-files.ts +47 -0
- package/examples/sdk/08-prompt-templates.ts +56 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +50 -0
- package/examples/sdk/10-settings.ts +58 -0
- package/examples/sdk/11-sessions.ts +54 -0
- package/examples/sdk/12-full-control.ts +79 -0
- package/examples/sdk/13-session-runtime.ts +49 -0
- package/examples/sdk/README.md +94 -0
- package/npm-shrinkwrap.json +1878 -0
- package/package.json +101 -5
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "../extensions/types.ts";
|
|
2
|
+
import type { ToolOperations } from "../tools/operations.ts";
|
|
3
|
+
import type { ResolvedLspConfiguration } from "./config.ts";
|
|
4
|
+
import { LspFileSync } from "./file-sync.ts";
|
|
5
|
+
import { LspManager, type LspManagerOptions, type LspServerStatus } from "./manager.ts";
|
|
6
|
+
export declare const LSP_TOOL_NAMES: readonly ["lsp_diagnostics", "lsp_hover", "lsp_definition", "lsp_references", "lsp_rename", "lsp_code_actions"];
|
|
7
|
+
export type LspToolName = (typeof LSP_TOOL_NAMES)[number];
|
|
8
|
+
export type LspRuntimeOwner = "agent-session" | "standalone" | "daemon";
|
|
9
|
+
export interface LspRuntimeState {
|
|
10
|
+
manager: LspManager;
|
|
11
|
+
fileSync: LspFileSync;
|
|
12
|
+
}
|
|
13
|
+
export interface LspSessionStatus {
|
|
14
|
+
owner: LspRuntimeOwner;
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
configuration: ResolvedLspConfiguration;
|
|
17
|
+
servers: LspServerStatus[];
|
|
18
|
+
}
|
|
19
|
+
export interface LspLifecycleOptions extends LspManagerOptions {
|
|
20
|
+
maxTrackedDocuments?: number;
|
|
21
|
+
}
|
|
22
|
+
export declare function createLspToolDefinitions(getState: () => LspRuntimeState, getOperations?: () => ToolOperations): readonly [import("../extensions/types.ts").ToolDefinition<import("typebox").TObject<{
|
|
23
|
+
path: import("typebox").TString;
|
|
24
|
+
}>, import("./diagnostics.ts").LspDiagnosticsDetails, any>, import("../extensions/types.ts").ToolDefinition<import("typebox").TObject<{
|
|
25
|
+
path: import("typebox").TString;
|
|
26
|
+
line: import("typebox").TInteger;
|
|
27
|
+
character: import("typebox").TInteger;
|
|
28
|
+
}>, import("./navigation.ts").LspHoverDetails, any>, import("../extensions/types.ts").ToolDefinition<import("typebox").TObject<{
|
|
29
|
+
path: import("typebox").TString;
|
|
30
|
+
line: import("typebox").TInteger;
|
|
31
|
+
character: import("typebox").TInteger;
|
|
32
|
+
}>, import("./navigation.ts").LspLocationDetails, any>, import("../extensions/types.ts").ToolDefinition<import("typebox").TObject<{
|
|
33
|
+
path: import("typebox").TString;
|
|
34
|
+
line: import("typebox").TInteger;
|
|
35
|
+
character: import("typebox").TInteger;
|
|
36
|
+
includeDeclaration: import("typebox").TOptional<import("typebox").TBoolean>;
|
|
37
|
+
}>, import("./navigation.ts").LspLocationDetails, any>, import("../extensions/types.ts").ToolDefinition<import("typebox").TObject<{
|
|
38
|
+
path: import("typebox").TString;
|
|
39
|
+
line: import("typebox").TInteger;
|
|
40
|
+
character: import("typebox").TInteger;
|
|
41
|
+
newName: import("typebox").TString;
|
|
42
|
+
}>, import("./refactor.ts").LspRenameDetails, any>, import("../extensions/types.ts").ToolDefinition<import("typebox").TObject<{
|
|
43
|
+
path: import("typebox").TString;
|
|
44
|
+
line: import("typebox").TInteger;
|
|
45
|
+
character: import("typebox").TInteger;
|
|
46
|
+
endLine: import("typebox").TOptional<import("typebox").TInteger>;
|
|
47
|
+
endCharacter: import("typebox").TOptional<import("typebox").TInteger>;
|
|
48
|
+
kind: import("typebox").TOptional<import("typebox").TString>;
|
|
49
|
+
}>, import("./refactor.ts").LspCodeActionsDetails, any>];
|
|
50
|
+
export declare function createLspRuntimeState(cwd: string, options?: LspLifecycleOptions): LspRuntimeState;
|
|
51
|
+
/**
|
|
52
|
+
* Register a self-contained LSP runtime for hosts that use the extension system without AgentSession.
|
|
53
|
+
* AgentSession already owns LSP tools and synchronization; extensions running inside it must use
|
|
54
|
+
* `ctx.getLspStatus()` and `ctx.configureLsp()` instead of registering another runtime.
|
|
55
|
+
*/
|
|
56
|
+
export declare function registerStandaloneLspLifecycleHandlers(grip: ExtensionAPI, options?: LspLifecycleOptions): () => LspRuntimeState;
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated Use `registerStandaloneLspLifecycleHandlers` only in standalone extension hosts. In a normal
|
|
59
|
+
* AgentSession, use its built-in LSP runtime through `ctx.getLspStatus()` and `ctx.configureLsp()`.
|
|
60
|
+
*/
|
|
61
|
+
export declare const registerLspLifecycleHandlers: typeof registerStandaloneLspLifecycleHandlers;
|
|
62
|
+
//# sourceMappingURL=integration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../../../src/core/lsp/integration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAA4D,MAAM,wBAAwB,CAAC;AAErH,OAAO,KAAK,EAAmB,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAIxF,eAAO,MAAM,cAAc,iHAOhB,CAAC;AACZ,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAC1D,MAAM,MAAM,eAAe,GAAG,eAAe,GAAG,YAAY,GAAG,QAAQ,CAAC;AACxE,MAAM,WAAW,eAAe;IAC/B,OAAO,EAAE,UAAU,CAAC;IACpB,QAAQ,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAChC,KAAK,EAAE,eAAe,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,wBAAwB,CAAC;IACxC,OAAO,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC7D,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,eAAe,EAAE,aAAa,CAAC,EAAE,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;yDAS7G;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,eAAe,CAMrG;AAID;;;;GAIG;AACH,wBAAgB,sCAAsC,CACrD,IAAI,EAAE,YAAY,EAClB,OAAO,GAAE,mBAAwB,GAC/B,MAAM,eAAe,CAkFvB;AAED;;;GAGG;AACH,eAAO,MAAM,4BAA4B,+CAAyC,CAAC","sourcesContent":["import type { ExtensionAPI, ExtensionContext, ToolResultEvent, ToolResultEventResult } from \"../extensions/types.ts\";\nimport { isEditToolResult, isReadToolResult, isWriteToolResult } from \"../extensions/types.ts\";\nimport type { ToolBackendInfo, ToolOperations } from \"../tools/operations.ts\";\nimport type { ResolvedLspConfiguration } from \"./config.ts\";\nimport { createLspDiagnosticsTool, formatAutoDiagnosticsForChangedFile } from \"./diagnostics.ts\";\nimport { LspFileSync } from \"./file-sync.ts\";\nimport { LspManager, type LspManagerOptions, type LspServerStatus } from \"./manager.ts\";\nimport { createLspDefinitionTool, createLspHoverTool, createLspReferencesTool } from \"./navigation.ts\";\nimport { createLspCodeActionsTool, createLspRenameTool } from \"./refactor.ts\";\n\nexport const LSP_TOOL_NAMES = Object.freeze([\n\t\"lsp_diagnostics\",\n\t\"lsp_hover\",\n\t\"lsp_definition\",\n\t\"lsp_references\",\n\t\"lsp_rename\",\n\t\"lsp_code_actions\",\n] as const);\nexport type LspToolName = (typeof LSP_TOOL_NAMES)[number];\nexport type LspRuntimeOwner = \"agent-session\" | \"standalone\" | \"daemon\";\nexport interface LspRuntimeState {\n\tmanager: LspManager;\n\tfileSync: LspFileSync;\n}\n\nexport interface LspSessionStatus {\n\towner: LspRuntimeOwner;\n\tenabled: boolean;\n\tconfiguration: ResolvedLspConfiguration;\n\tservers: LspServerStatus[];\n}\n\nexport interface LspLifecycleOptions extends LspManagerOptions {\n\tmaxTrackedDocuments?: number;\n}\n\nexport function createLspToolDefinitions(getState: () => LspRuntimeState, getOperations?: () => ToolOperations) {\n\treturn [\n\t\tcreateLspDiagnosticsTool(getState, getOperations),\n\t\tcreateLspHoverTool(getState, getOperations),\n\t\tcreateLspDefinitionTool(getState, getOperations),\n\t\tcreateLspReferencesTool(getState, getOperations),\n\t\tcreateLspRenameTool(getState, getOperations),\n\t\tcreateLspCodeActionsTool(getState, getOperations),\n\t] as const;\n}\n\nexport function createLspRuntimeState(cwd: string, options: LspLifecycleOptions = {}): LspRuntimeState {\n\tconst manager = new LspManager(cwd, options);\n\treturn {\n\t\tmanager,\n\t\tfileSync: new LspFileSync(manager, options.maxTrackedDocuments),\n\t};\n}\n\nconst standaloneRegistrations = new WeakMap<ExtensionAPI, () => LspRuntimeState>();\n\n/**\n * Register a self-contained LSP runtime for hosts that use the extension system without AgentSession.\n * AgentSession already owns LSP tools and synchronization; extensions running inside it must use\n * `ctx.getLspStatus()` and `ctx.configureLsp()` instead of registering another runtime.\n */\nexport function registerStandaloneLspLifecycleHandlers(\n\tgrip: ExtensionAPI,\n\toptions: LspLifecycleOptions = {},\n): () => LspRuntimeState {\n\tconst existing = standaloneRegistrations.get(grip);\n\tif (existing) return existing;\n\tlet state: LspRuntimeState | undefined;\n\tlet delegatedToAgentSession = false;\n\tlet toolsRegistered = false;\n\tlet toolsAvailable = false;\n\tlet toolBackendInfo: ToolBackendInfo | undefined;\n\tlet toolOperations: ExtensionContext[\"toolOperations\"] | undefined;\n\tconst getState = (cwd = process.cwd()): LspRuntimeState => {\n\t\tif (delegatedToAgentSession) {\n\t\t\tthrow new Error(\n\t\t\t\t\"AgentSession already owns LSP. Use ctx.getLspStatus() and ctx.configureLsp() instead of the standalone helper.\",\n\t\t\t);\n\t\t}\n\t\tstate ??= createLspRuntimeState(cwd, {\n\t\t\t...options,\n\t\t\tgetToolBackendInfo: () => toolBackendInfo ?? options.getToolBackendInfo?.() ?? { type: \"local\", cwd },\n\t\t});\n\t\treturn state;\n\t};\n\n\tconst registerToolsOnce = (): void => {\n\t\tif (toolsRegistered) return;\n\t\ttoolsRegistered = true;\n\t\ttoolsAvailable = true;\n\t\tconst [diagnostics, hover, definition, references, rename, codeActions] = createLspToolDefinitions(() =>\n\t\t\tgetState(),\n\t\t);\n\t\tgrip.registerTool(diagnostics);\n\t\tgrip.registerTool(hover);\n\t\tgrip.registerTool(definition);\n\t\tgrip.registerTool(references);\n\t\tgrip.registerTool(rename);\n\t\tgrip.registerTool(codeActions);\n\t};\n\n\tconst unregisterTools = (): void => {\n\t\tif (!toolsAvailable) return;\n\t\ttoolsAvailable = false;\n\t\tfor (const name of LSP_TOOL_NAMES) {\n\t\t\tgrip.unregisterTool(name);\n\t\t}\n\t};\n\n\tgrip.on(\"session_start\", (_event, ctx) => {\n\t\tconst previous = state;\n\t\ttoolBackendInfo = ctx.toolOperations.getBackendInfo?.() ?? { type: \"local\", cwd: ctx.toolOperations.cwd };\n\t\ttoolOperations = ctx.toolOperations;\n\t\tif (delegatedToAgentSession || ctx.getLspStatus().owner === \"agent-session\") {\n\t\t\tdelegatedToAgentSession = true;\n\t\t\tunregisterTools();\n\t\t\tstate = undefined;\n\t\t\treturn previous?.manager.shutdownAll();\n\t\t}\n\t\tdelegatedToAgentSession = false;\n\t\tregisterToolsOnce();\n\t\tstate = createLspRuntimeState(ctx.toolOperations.cwd, {\n\t\t\t...options,\n\t\t\tgetToolBackendInfo: () => toolBackendInfo ?? { type: \"local\", cwd: ctx.toolOperations.cwd },\n\t\t\tgetToolOperations: () => toolOperations ?? ctx.toolOperations,\n\t\t});\n\t\treturn previous?.manager.shutdownAll();\n\t});\n\n\tgrip.on(\"tool_result\", async (event, ctx) => {\n\t\tif (delegatedToAgentSession) return undefined;\n\t\ttoolOperations = ctx.toolOperations;\n\t\ttoolBackendInfo = ctx.toolOperations.getBackendInfo?.() ?? { type: \"local\", cwd: ctx.toolOperations.cwd };\n\t\treturn syncToolResult(event, ctx, getState(ctx.toolOperations.cwd));\n\t});\n\n\tgrip.on(\"session_shutdown\", async () => {\n\t\tconst current = state;\n\t\tstate = undefined;\n\t\ttoolOperations = undefined;\n\t\tawait current?.manager.shutdownAll();\n\t});\n\n\tconst registration = () => getState(process.cwd());\n\tstandaloneRegistrations.set(grip, registration);\n\treturn registration;\n}\n\n/**\n * @deprecated Use `registerStandaloneLspLifecycleHandlers` only in standalone extension hosts. In a normal\n * AgentSession, use its built-in LSP runtime through `ctx.getLspStatus()` and `ctx.configureLsp()`.\n */\nexport const registerLspLifecycleHandlers = registerStandaloneLspLifecycleHandlers;\n\nasync function syncToolResult(\n\tevent: ToolResultEvent,\n\tctx: ExtensionContext,\n\tstate: LspRuntimeState,\n): Promise<ToolResultEventResult | undefined> {\n\tif (event.isError) return;\n\tconst filePath = typeof event.input.path === \"string\" ? event.input.path : undefined;\n\tif (!filePath) return;\n\n\ttry {\n\t\tif (isReadToolResult(event)) {\n\t\t\tawait state.fileSync.handleFileRead(filePath, ctx.toolOperations);\n\t\t\treturn;\n\t\t}\n\t\tif (isWriteToolResult(event) || isEditToolResult(event)) {\n\t\t\tawait state.fileSync.handleFileWrite(filePath, ctx.toolOperations);\n\t\t\tconst diagnostics = await formatAutoDiagnosticsForChangedFile(state, filePath);\n\t\t\tif (!diagnostics) return undefined;\n\t\t\treturn {\n\t\t\t\tcontent: [...event.content, { type: \"text\" as const, text: `\\n\\n${diagnostics}` }],\n\t\t\t};\n\t\t}\n\t} catch {\n\t\t// LSP synchronization is best-effort and must not affect tool results.\n\t}\n}\n"]}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { isEditToolResult, isReadToolResult, isWriteToolResult } from "../extensions/types.js";
|
|
2
|
+
import { createLspDiagnosticsTool, formatAutoDiagnosticsForChangedFile } from "./diagnostics.js";
|
|
3
|
+
import { LspFileSync } from "./file-sync.js";
|
|
4
|
+
import { LspManager } from "./manager.js";
|
|
5
|
+
import { createLspDefinitionTool, createLspHoverTool, createLspReferencesTool } from "./navigation.js";
|
|
6
|
+
import { createLspCodeActionsTool, createLspRenameTool } from "./refactor.js";
|
|
7
|
+
export const LSP_TOOL_NAMES = Object.freeze([
|
|
8
|
+
"lsp_diagnostics",
|
|
9
|
+
"lsp_hover",
|
|
10
|
+
"lsp_definition",
|
|
11
|
+
"lsp_references",
|
|
12
|
+
"lsp_rename",
|
|
13
|
+
"lsp_code_actions",
|
|
14
|
+
]);
|
|
15
|
+
export function createLspToolDefinitions(getState, getOperations) {
|
|
16
|
+
return [
|
|
17
|
+
createLspDiagnosticsTool(getState, getOperations),
|
|
18
|
+
createLspHoverTool(getState, getOperations),
|
|
19
|
+
createLspDefinitionTool(getState, getOperations),
|
|
20
|
+
createLspReferencesTool(getState, getOperations),
|
|
21
|
+
createLspRenameTool(getState, getOperations),
|
|
22
|
+
createLspCodeActionsTool(getState, getOperations),
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
export function createLspRuntimeState(cwd, options = {}) {
|
|
26
|
+
const manager = new LspManager(cwd, options);
|
|
27
|
+
return {
|
|
28
|
+
manager,
|
|
29
|
+
fileSync: new LspFileSync(manager, options.maxTrackedDocuments),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const standaloneRegistrations = new WeakMap();
|
|
33
|
+
/**
|
|
34
|
+
* Register a self-contained LSP runtime for hosts that use the extension system without AgentSession.
|
|
35
|
+
* AgentSession already owns LSP tools and synchronization; extensions running inside it must use
|
|
36
|
+
* `ctx.getLspStatus()` and `ctx.configureLsp()` instead of registering another runtime.
|
|
37
|
+
*/
|
|
38
|
+
export function registerStandaloneLspLifecycleHandlers(grip, options = {}) {
|
|
39
|
+
const existing = standaloneRegistrations.get(grip);
|
|
40
|
+
if (existing)
|
|
41
|
+
return existing;
|
|
42
|
+
let state;
|
|
43
|
+
let delegatedToAgentSession = false;
|
|
44
|
+
let toolsRegistered = false;
|
|
45
|
+
let toolsAvailable = false;
|
|
46
|
+
let toolBackendInfo;
|
|
47
|
+
let toolOperations;
|
|
48
|
+
const getState = (cwd = process.cwd()) => {
|
|
49
|
+
if (delegatedToAgentSession) {
|
|
50
|
+
throw new Error("AgentSession already owns LSP. Use ctx.getLspStatus() and ctx.configureLsp() instead of the standalone helper.");
|
|
51
|
+
}
|
|
52
|
+
state ??= createLspRuntimeState(cwd, {
|
|
53
|
+
...options,
|
|
54
|
+
getToolBackendInfo: () => toolBackendInfo ?? options.getToolBackendInfo?.() ?? { type: "local", cwd },
|
|
55
|
+
});
|
|
56
|
+
return state;
|
|
57
|
+
};
|
|
58
|
+
const registerToolsOnce = () => {
|
|
59
|
+
if (toolsRegistered)
|
|
60
|
+
return;
|
|
61
|
+
toolsRegistered = true;
|
|
62
|
+
toolsAvailable = true;
|
|
63
|
+
const [diagnostics, hover, definition, references, rename, codeActions] = createLspToolDefinitions(() => getState());
|
|
64
|
+
grip.registerTool(diagnostics);
|
|
65
|
+
grip.registerTool(hover);
|
|
66
|
+
grip.registerTool(definition);
|
|
67
|
+
grip.registerTool(references);
|
|
68
|
+
grip.registerTool(rename);
|
|
69
|
+
grip.registerTool(codeActions);
|
|
70
|
+
};
|
|
71
|
+
const unregisterTools = () => {
|
|
72
|
+
if (!toolsAvailable)
|
|
73
|
+
return;
|
|
74
|
+
toolsAvailable = false;
|
|
75
|
+
for (const name of LSP_TOOL_NAMES) {
|
|
76
|
+
grip.unregisterTool(name);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
grip.on("session_start", (_event, ctx) => {
|
|
80
|
+
const previous = state;
|
|
81
|
+
toolBackendInfo = ctx.toolOperations.getBackendInfo?.() ?? { type: "local", cwd: ctx.toolOperations.cwd };
|
|
82
|
+
toolOperations = ctx.toolOperations;
|
|
83
|
+
if (delegatedToAgentSession || ctx.getLspStatus().owner === "agent-session") {
|
|
84
|
+
delegatedToAgentSession = true;
|
|
85
|
+
unregisterTools();
|
|
86
|
+
state = undefined;
|
|
87
|
+
return previous?.manager.shutdownAll();
|
|
88
|
+
}
|
|
89
|
+
delegatedToAgentSession = false;
|
|
90
|
+
registerToolsOnce();
|
|
91
|
+
state = createLspRuntimeState(ctx.toolOperations.cwd, {
|
|
92
|
+
...options,
|
|
93
|
+
getToolBackendInfo: () => toolBackendInfo ?? { type: "local", cwd: ctx.toolOperations.cwd },
|
|
94
|
+
getToolOperations: () => toolOperations ?? ctx.toolOperations,
|
|
95
|
+
});
|
|
96
|
+
return previous?.manager.shutdownAll();
|
|
97
|
+
});
|
|
98
|
+
grip.on("tool_result", async (event, ctx) => {
|
|
99
|
+
if (delegatedToAgentSession)
|
|
100
|
+
return undefined;
|
|
101
|
+
toolOperations = ctx.toolOperations;
|
|
102
|
+
toolBackendInfo = ctx.toolOperations.getBackendInfo?.() ?? { type: "local", cwd: ctx.toolOperations.cwd };
|
|
103
|
+
return syncToolResult(event, ctx, getState(ctx.toolOperations.cwd));
|
|
104
|
+
});
|
|
105
|
+
grip.on("session_shutdown", async () => {
|
|
106
|
+
const current = state;
|
|
107
|
+
state = undefined;
|
|
108
|
+
toolOperations = undefined;
|
|
109
|
+
await current?.manager.shutdownAll();
|
|
110
|
+
});
|
|
111
|
+
const registration = () => getState(process.cwd());
|
|
112
|
+
standaloneRegistrations.set(grip, registration);
|
|
113
|
+
return registration;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* @deprecated Use `registerStandaloneLspLifecycleHandlers` only in standalone extension hosts. In a normal
|
|
117
|
+
* AgentSession, use its built-in LSP runtime through `ctx.getLspStatus()` and `ctx.configureLsp()`.
|
|
118
|
+
*/
|
|
119
|
+
export const registerLspLifecycleHandlers = registerStandaloneLspLifecycleHandlers;
|
|
120
|
+
async function syncToolResult(event, ctx, state) {
|
|
121
|
+
if (event.isError)
|
|
122
|
+
return;
|
|
123
|
+
const filePath = typeof event.input.path === "string" ? event.input.path : undefined;
|
|
124
|
+
if (!filePath)
|
|
125
|
+
return;
|
|
126
|
+
try {
|
|
127
|
+
if (isReadToolResult(event)) {
|
|
128
|
+
await state.fileSync.handleFileRead(filePath, ctx.toolOperations);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (isWriteToolResult(event) || isEditToolResult(event)) {
|
|
132
|
+
await state.fileSync.handleFileWrite(filePath, ctx.toolOperations);
|
|
133
|
+
const diagnostics = await formatAutoDiagnosticsForChangedFile(state, filePath);
|
|
134
|
+
if (!diagnostics)
|
|
135
|
+
return undefined;
|
|
136
|
+
return {
|
|
137
|
+
content: [...event.content, { type: "text", text: `\n\n${diagnostics}` }],
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
// LSP synchronization is best-effort and must not affect tool results.
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=integration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration.js","sourceRoot":"","sources":["../../../src/core/lsp/integration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG/F,OAAO,EAAE,wBAAwB,EAAE,mCAAmC,EAAE,MAAM,kBAAkB,CAAC;AACjG,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAgD,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AACvG,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE9E,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3C,iBAAiB;IACjB,WAAW;IACX,gBAAgB;IAChB,gBAAgB;IAChB,YAAY;IACZ,kBAAkB;CACT,CAAC,CAAC;AAmBZ,MAAM,UAAU,wBAAwB,CAAC,QAA+B,EAAE,aAAoC,EAAE;IAC/G,OAAO;QACN,wBAAwB,CAAC,QAAQ,EAAE,aAAa,CAAC;QACjD,kBAAkB,CAAC,QAAQ,EAAE,aAAa,CAAC;QAC3C,uBAAuB,CAAC,QAAQ,EAAE,aAAa,CAAC;QAChD,uBAAuB,CAAC,QAAQ,EAAE,aAAa,CAAC;QAChD,mBAAmB,CAAC,QAAQ,EAAE,aAAa,CAAC;QAC5C,wBAAwB,CAAC,QAAQ,EAAE,aAAa,CAAC;KACxC,CAAC;AAAA,CACX;AAED,MAAM,UAAU,qBAAqB,CAAC,GAAW,EAAE,OAAO,GAAwB,EAAE,EAAmB;IACtG,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC7C,OAAO;QACN,OAAO;QACP,QAAQ,EAAE,IAAI,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,mBAAmB,CAAC;KAC/D,CAAC;AAAA,CACF;AAED,MAAM,uBAAuB,GAAG,IAAI,OAAO,EAAuC,CAAC;AAEnF;;;;GAIG;AACH,MAAM,UAAU,sCAAsC,CACrD,IAAkB,EAClB,OAAO,GAAwB,EAAE,EACT;IACxB,MAAM,QAAQ,GAAG,uBAAuB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnD,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,IAAI,KAAkC,CAAC;IACvC,IAAI,uBAAuB,GAAG,KAAK,CAAC;IACpC,IAAI,eAAe,GAAG,KAAK,CAAC;IAC5B,IAAI,cAAc,GAAG,KAAK,CAAC;IAC3B,IAAI,eAA4C,CAAC;IACjD,IAAI,cAA8D,CAAC;IACnE,MAAM,QAAQ,GAAG,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,EAAmB,EAAE,CAAC;QAC1D,IAAI,uBAAuB,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CACd,gHAAgH,CAChH,CAAC;QACH,CAAC;QACD,KAAK,KAAK,qBAAqB,CAAC,GAAG,EAAE;YACpC,GAAG,OAAO;YACV,kBAAkB,EAAE,GAAG,EAAE,CAAC,eAAe,IAAI,OAAO,CAAC,kBAAkB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE;SACrG,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IAAA,CACb,CAAC;IAEF,MAAM,iBAAiB,GAAG,GAAS,EAAE,CAAC;QACrC,IAAI,eAAe;YAAE,OAAO;QAC5B,eAAe,GAAG,IAAI,CAAC;QACvB,cAAc,GAAG,IAAI,CAAC;QACtB,MAAM,CAAC,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,CAAC,GAAG,wBAAwB,CAAC,GAAG,EAAE,CACvG,QAAQ,EAAE,CACV,CAAC;QACF,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QAC/B,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACzB,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC9B,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC9B,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IAAA,CAC/B,CAAC;IAEF,MAAM,eAAe,GAAG,GAAS,EAAE,CAAC;QACnC,IAAI,CAAC,cAAc;YAAE,OAAO;QAC5B,cAAc,GAAG,KAAK,CAAC;QACvB,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;YACnC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;IAAA,CACD,CAAC;IAEF,IAAI,CAAC,EAAE,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;QACzC,MAAM,QAAQ,GAAG,KAAK,CAAC;QACvB,eAAe,GAAG,GAAG,CAAC,cAAc,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC;QAC1G,cAAc,GAAG,GAAG,CAAC,cAAc,CAAC;QACpC,IAAI,uBAAuB,IAAI,GAAG,CAAC,YAAY,EAAE,CAAC,KAAK,KAAK,eAAe,EAAE,CAAC;YAC7E,uBAAuB,GAAG,IAAI,CAAC;YAC/B,eAAe,EAAE,CAAC;YAClB,KAAK,GAAG,SAAS,CAAC;YAClB,OAAO,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;QACxC,CAAC;QACD,uBAAuB,GAAG,KAAK,CAAC;QAChC,iBAAiB,EAAE,CAAC;QACpB,KAAK,GAAG,qBAAqB,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,EAAE;YACrD,GAAG,OAAO;YACV,kBAAkB,EAAE,GAAG,EAAE,CAAC,eAAe,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,cAAc,CAAC,GAAG,EAAE;YAC3F,iBAAiB,EAAE,GAAG,EAAE,CAAC,cAAc,IAAI,GAAG,CAAC,cAAc;SAC7D,CAAC,CAAC;QACH,OAAO,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;IAAA,CACvC,CAAC,CAAC;IAEH,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC;QAC5C,IAAI,uBAAuB;YAAE,OAAO,SAAS,CAAC;QAC9C,cAAc,GAAG,GAAG,CAAC,cAAc,CAAC;QACpC,eAAe,GAAG,GAAG,CAAC,cAAc,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC;QAC1G,OAAO,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;IAAA,CACpE,CAAC,CAAC;IAEH,IAAI,CAAC,EAAE,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,KAAK,CAAC;QACtB,KAAK,GAAG,SAAS,CAAC;QAClB,cAAc,GAAG,SAAS,CAAC;QAC3B,MAAM,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;IAAA,CACrC,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACnD,uBAAuB,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAChD,OAAO,YAAY,CAAC;AAAA,CACpB;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,sCAAsC,CAAC;AAEnF,KAAK,UAAU,cAAc,CAC5B,KAAsB,EACtB,GAAqB,EACrB,KAAsB,EACuB;IAC7C,IAAI,KAAK,CAAC,OAAO;QAAE,OAAO;IAC1B,MAAM,QAAQ,GAAG,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IACrF,IAAI,CAAC,QAAQ;QAAE,OAAO;IAEtB,IAAI,CAAC;QACJ,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,MAAM,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;YAClE,OAAO;QACR,CAAC;QACD,IAAI,iBAAiB,CAAC,KAAK,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;YACzD,MAAM,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,QAAQ,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;YACnE,MAAM,WAAW,GAAG,MAAM,mCAAmC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAC/E,IAAI,CAAC,WAAW;gBAAE,OAAO,SAAS,CAAC;YACnC,OAAO;gBACN,OAAO,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,OAAO,WAAW,EAAE,EAAE,CAAC;aAClF,CAAC;QACH,CAAC;IACF,CAAC;IAAC,MAAM,CAAC;QACR,uEAAuE;IACxE,CAAC;AAAA,CACD","sourcesContent":["import type { ExtensionAPI, ExtensionContext, ToolResultEvent, ToolResultEventResult } from \"../extensions/types.ts\";\nimport { isEditToolResult, isReadToolResult, isWriteToolResult } from \"../extensions/types.ts\";\nimport type { ToolBackendInfo, ToolOperations } from \"../tools/operations.ts\";\nimport type { ResolvedLspConfiguration } from \"./config.ts\";\nimport { createLspDiagnosticsTool, formatAutoDiagnosticsForChangedFile } from \"./diagnostics.ts\";\nimport { LspFileSync } from \"./file-sync.ts\";\nimport { LspManager, type LspManagerOptions, type LspServerStatus } from \"./manager.ts\";\nimport { createLspDefinitionTool, createLspHoverTool, createLspReferencesTool } from \"./navigation.ts\";\nimport { createLspCodeActionsTool, createLspRenameTool } from \"./refactor.ts\";\n\nexport const LSP_TOOL_NAMES = Object.freeze([\n\t\"lsp_diagnostics\",\n\t\"lsp_hover\",\n\t\"lsp_definition\",\n\t\"lsp_references\",\n\t\"lsp_rename\",\n\t\"lsp_code_actions\",\n] as const);\nexport type LspToolName = (typeof LSP_TOOL_NAMES)[number];\nexport type LspRuntimeOwner = \"agent-session\" | \"standalone\" | \"daemon\";\nexport interface LspRuntimeState {\n\tmanager: LspManager;\n\tfileSync: LspFileSync;\n}\n\nexport interface LspSessionStatus {\n\towner: LspRuntimeOwner;\n\tenabled: boolean;\n\tconfiguration: ResolvedLspConfiguration;\n\tservers: LspServerStatus[];\n}\n\nexport interface LspLifecycleOptions extends LspManagerOptions {\n\tmaxTrackedDocuments?: number;\n}\n\nexport function createLspToolDefinitions(getState: () => LspRuntimeState, getOperations?: () => ToolOperations) {\n\treturn [\n\t\tcreateLspDiagnosticsTool(getState, getOperations),\n\t\tcreateLspHoverTool(getState, getOperations),\n\t\tcreateLspDefinitionTool(getState, getOperations),\n\t\tcreateLspReferencesTool(getState, getOperations),\n\t\tcreateLspRenameTool(getState, getOperations),\n\t\tcreateLspCodeActionsTool(getState, getOperations),\n\t] as const;\n}\n\nexport function createLspRuntimeState(cwd: string, options: LspLifecycleOptions = {}): LspRuntimeState {\n\tconst manager = new LspManager(cwd, options);\n\treturn {\n\t\tmanager,\n\t\tfileSync: new LspFileSync(manager, options.maxTrackedDocuments),\n\t};\n}\n\nconst standaloneRegistrations = new WeakMap<ExtensionAPI, () => LspRuntimeState>();\n\n/**\n * Register a self-contained LSP runtime for hosts that use the extension system without AgentSession.\n * AgentSession already owns LSP tools and synchronization; extensions running inside it must use\n * `ctx.getLspStatus()` and `ctx.configureLsp()` instead of registering another runtime.\n */\nexport function registerStandaloneLspLifecycleHandlers(\n\tgrip: ExtensionAPI,\n\toptions: LspLifecycleOptions = {},\n): () => LspRuntimeState {\n\tconst existing = standaloneRegistrations.get(grip);\n\tif (existing) return existing;\n\tlet state: LspRuntimeState | undefined;\n\tlet delegatedToAgentSession = false;\n\tlet toolsRegistered = false;\n\tlet toolsAvailable = false;\n\tlet toolBackendInfo: ToolBackendInfo | undefined;\n\tlet toolOperations: ExtensionContext[\"toolOperations\"] | undefined;\n\tconst getState = (cwd = process.cwd()): LspRuntimeState => {\n\t\tif (delegatedToAgentSession) {\n\t\t\tthrow new Error(\n\t\t\t\t\"AgentSession already owns LSP. Use ctx.getLspStatus() and ctx.configureLsp() instead of the standalone helper.\",\n\t\t\t);\n\t\t}\n\t\tstate ??= createLspRuntimeState(cwd, {\n\t\t\t...options,\n\t\t\tgetToolBackendInfo: () => toolBackendInfo ?? options.getToolBackendInfo?.() ?? { type: \"local\", cwd },\n\t\t});\n\t\treturn state;\n\t};\n\n\tconst registerToolsOnce = (): void => {\n\t\tif (toolsRegistered) return;\n\t\ttoolsRegistered = true;\n\t\ttoolsAvailable = true;\n\t\tconst [diagnostics, hover, definition, references, rename, codeActions] = createLspToolDefinitions(() =>\n\t\t\tgetState(),\n\t\t);\n\t\tgrip.registerTool(diagnostics);\n\t\tgrip.registerTool(hover);\n\t\tgrip.registerTool(definition);\n\t\tgrip.registerTool(references);\n\t\tgrip.registerTool(rename);\n\t\tgrip.registerTool(codeActions);\n\t};\n\n\tconst unregisterTools = (): void => {\n\t\tif (!toolsAvailable) return;\n\t\ttoolsAvailable = false;\n\t\tfor (const name of LSP_TOOL_NAMES) {\n\t\t\tgrip.unregisterTool(name);\n\t\t}\n\t};\n\n\tgrip.on(\"session_start\", (_event, ctx) => {\n\t\tconst previous = state;\n\t\ttoolBackendInfo = ctx.toolOperations.getBackendInfo?.() ?? { type: \"local\", cwd: ctx.toolOperations.cwd };\n\t\ttoolOperations = ctx.toolOperations;\n\t\tif (delegatedToAgentSession || ctx.getLspStatus().owner === \"agent-session\") {\n\t\t\tdelegatedToAgentSession = true;\n\t\t\tunregisterTools();\n\t\t\tstate = undefined;\n\t\t\treturn previous?.manager.shutdownAll();\n\t\t}\n\t\tdelegatedToAgentSession = false;\n\t\tregisterToolsOnce();\n\t\tstate = createLspRuntimeState(ctx.toolOperations.cwd, {\n\t\t\t...options,\n\t\t\tgetToolBackendInfo: () => toolBackendInfo ?? { type: \"local\", cwd: ctx.toolOperations.cwd },\n\t\t\tgetToolOperations: () => toolOperations ?? ctx.toolOperations,\n\t\t});\n\t\treturn previous?.manager.shutdownAll();\n\t});\n\n\tgrip.on(\"tool_result\", async (event, ctx) => {\n\t\tif (delegatedToAgentSession) return undefined;\n\t\ttoolOperations = ctx.toolOperations;\n\t\ttoolBackendInfo = ctx.toolOperations.getBackendInfo?.() ?? { type: \"local\", cwd: ctx.toolOperations.cwd };\n\t\treturn syncToolResult(event, ctx, getState(ctx.toolOperations.cwd));\n\t});\n\n\tgrip.on(\"session_shutdown\", async () => {\n\t\tconst current = state;\n\t\tstate = undefined;\n\t\ttoolOperations = undefined;\n\t\tawait current?.manager.shutdownAll();\n\t});\n\n\tconst registration = () => getState(process.cwd());\n\tstandaloneRegistrations.set(grip, registration);\n\treturn registration;\n}\n\n/**\n * @deprecated Use `registerStandaloneLspLifecycleHandlers` only in standalone extension hosts. In a normal\n * AgentSession, use its built-in LSP runtime through `ctx.getLspStatus()` and `ctx.configureLsp()`.\n */\nexport const registerLspLifecycleHandlers = registerStandaloneLspLifecycleHandlers;\n\nasync function syncToolResult(\n\tevent: ToolResultEvent,\n\tctx: ExtensionContext,\n\tstate: LspRuntimeState,\n): Promise<ToolResultEventResult | undefined> {\n\tif (event.isError) return;\n\tconst filePath = typeof event.input.path === \"string\" ? event.input.path : undefined;\n\tif (!filePath) return;\n\n\ttry {\n\t\tif (isReadToolResult(event)) {\n\t\t\tawait state.fileSync.handleFileRead(filePath, ctx.toolOperations);\n\t\t\treturn;\n\t\t}\n\t\tif (isWriteToolResult(event) || isEditToolResult(event)) {\n\t\t\tawait state.fileSync.handleFileWrite(filePath, ctx.toolOperations);\n\t\t\tconst diagnostics = await formatAutoDiagnosticsForChangedFile(state, filePath);\n\t\t\tif (!diagnostics) return undefined;\n\t\t\treturn {\n\t\t\t\tcontent: [...event.content, { type: \"text\" as const, text: `\\n\\n${diagnostics}` }],\n\t\t\t};\n\t\t}\n\t} catch {\n\t\t// LSP synchronization is best-effort and must not affect tool results.\n\t}\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { LspConfiguredServer, LspPathMapping, ResolvedLspConfiguration } from "./config.ts";
|
|
2
|
+
export interface LspRouteTarget {
|
|
3
|
+
server: LspConfiguredServer;
|
|
4
|
+
serverId: string;
|
|
5
|
+
languageId: string;
|
|
6
|
+
workspaceRoot: string;
|
|
7
|
+
instanceKey: string;
|
|
8
|
+
serverUri: string;
|
|
9
|
+
workspaceUri: string;
|
|
10
|
+
mapper: LspPathMapper;
|
|
11
|
+
}
|
|
12
|
+
export interface LspRouteFailure {
|
|
13
|
+
serverId: string;
|
|
14
|
+
reason: string;
|
|
15
|
+
}
|
|
16
|
+
export interface LspRouteResult {
|
|
17
|
+
targets: LspRouteTarget[];
|
|
18
|
+
failures: LspRouteFailure[];
|
|
19
|
+
}
|
|
20
|
+
export type LspPathMappingResult = {
|
|
21
|
+
ok: true;
|
|
22
|
+
value: string;
|
|
23
|
+
} | {
|
|
24
|
+
ok: false;
|
|
25
|
+
reason: string;
|
|
26
|
+
};
|
|
27
|
+
export interface LspRouterOptions {
|
|
28
|
+
pathExists?: (path: string) => Promise<boolean>;
|
|
29
|
+
}
|
|
30
|
+
/** Bidirectional, longest-root path mapper for one configured server. */
|
|
31
|
+
export declare class LspPathMapper {
|
|
32
|
+
private readonly agentMappings;
|
|
33
|
+
private readonly serverMappings;
|
|
34
|
+
constructor(mappings?: readonly LspPathMapping[]);
|
|
35
|
+
agentPathToServerUri(agentPath: string): LspPathMappingResult;
|
|
36
|
+
serverUriToAgentPath(serverUri: string): LspPathMappingResult;
|
|
37
|
+
}
|
|
38
|
+
/** Resolves configured selectors into server/workspace instances without starting clients. */
|
|
39
|
+
export declare class LspRouter {
|
|
40
|
+
private configuration;
|
|
41
|
+
private sessionRoot;
|
|
42
|
+
private pathExists;
|
|
43
|
+
private contextGeneration;
|
|
44
|
+
private readonly rootCache;
|
|
45
|
+
constructor(sessionRoot: string, configuration: ResolvedLspConfiguration, options?: LspRouterOptions);
|
|
46
|
+
setRoutingContext(sessionRoot: string, pathExists: (path: string) => Promise<boolean>): void;
|
|
47
|
+
setConfiguration(configuration: ResolvedLspConfiguration): void;
|
|
48
|
+
clearCache(): void;
|
|
49
|
+
routeFile(filePath: string, signal?: AbortSignal): Promise<LspRouteResult>;
|
|
50
|
+
private resolveWorkspaceRoot;
|
|
51
|
+
private directoryContainsWorkspaceMarker;
|
|
52
|
+
private discoverMarkerRoot;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=language-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-map.d.ts","sourceRoot":"","sources":["../../../src/core/lsp/language-map.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAuB,cAAc,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAetH,MAAM,WAAW,cAAc;IAC9B,MAAM,EAAE,mBAAmB,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC5B;AAED,MAAM,MAAM,oBAAoB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/F,MAAM,WAAW,gBAAgB;IAChC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAChD;AAmGD,yEAAyE;AACzE,qBAAa,aAAa;IACzB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAsB;IACpD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAsB;IAErD,YAAY,QAAQ,GAAE,SAAS,cAAc,EAAO,EAUnD;IAED,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,oBAAoB,CAe5D;IAED,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,oBAAoB,CA2B5D;CACD;AAiBD,8FAA8F;AAC9F,qBAAa,SAAS;IACrB,OAAO,CAAC,aAAa,CAA2B;IAChD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,UAAU,CAAqC;IACvD,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkD;IAE5E,YAAY,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,wBAAwB,EAAE,OAAO,GAAE,gBAAqB,EAIvG;IAED,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAM3F;IAED,gBAAgB,CAAC,aAAa,EAAE,wBAAwB,GAAG,IAAI,CAG9D;IAED,UAAU,IAAI,IAAI,CAGjB;IAEK,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CA2D/E;IAED,OAAO,CAAC,oBAAoB;YAcd,gCAAgC;YAOhC,kBAAkB;CAiBhC","sourcesContent":["import { access } from \"node:fs/promises\";\nimport { minimatch } from \"minimatch\";\nimport { waitForAbort } from \"./abort.ts\";\nimport type { LspConfiguredServer, LspDocumentSelector, LspPathMapping, ResolvedLspConfiguration } from \"./config.ts\";\nimport {\n\tdirnamePortablePath,\n\tisPortableAbsolute,\n\tjoinPortablePath,\n\tnormalizePortablePath,\n\ttype PortablePathFlavor,\n\tpathApi,\n\tpathComparisonValue,\n\tpathFlavor,\n\tportablePathToFileUri,\n\trelativeWithin,\n\tresolvePortablePath,\n} from \"./portable-path.ts\";\n\nexport interface LspRouteTarget {\n\tserver: LspConfiguredServer;\n\tserverId: string;\n\tlanguageId: string;\n\tworkspaceRoot: string;\n\tinstanceKey: string;\n\tserverUri: string;\n\tworkspaceUri: string;\n\tmapper: LspPathMapper;\n}\n\nexport interface LspRouteFailure {\n\tserverId: string;\n\treason: string;\n}\n\nexport interface LspRouteResult {\n\ttargets: LspRouteTarget[];\n\tfailures: LspRouteFailure[];\n}\n\nexport type LspPathMappingResult = { ok: true; value: string } | { ok: false; reason: string };\n\nexport interface LspRouterOptions {\n\tpathExists?: (path: string) => Promise<boolean>;\n}\n\ntype ServerFileUriParseResult = { ok: true; url: URL } | { ok: false; reason: string };\n\ninterface NormalizedMapping {\n\tagentRoot: string;\n\tserverRoot: URL;\n\tagentFlavor: PortablePathFlavor;\n}\n\nfunction encodePathSegments(value: string, flavor: PortablePathFlavor): string {\n\treturn value\n\t\t.split(flavor === \"windows\" ? /[\\\\/]/ : \"/\")\n\t\t.filter(Boolean)\n\t\t.map((segment) => encodeURIComponent(segment))\n\t\t.join(\"/\");\n}\n\nfunction decodedUrlSegments(url: URL): string[] | undefined {\n\ttry {\n\t\tconst segments = url.pathname\n\t\t\t.split(\"/\")\n\t\t\t.filter(Boolean)\n\t\t\t.map((segment) => decodeURIComponent(segment));\n\t\treturn segments.some((segment) => segment === \".\" || segment === \"..\" || segment.includes(\"/\"))\n\t\t\t? undefined\n\t\t\t: segments;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction sameFileAuthority(left: URL, right: URL): boolean {\n\treturn (\n\t\tleft.protocol === \"file:\" &&\n\t\tright.protocol === \"file:\" &&\n\t\tleft.hostname.toLowerCase() === right.hostname.toLowerCase()\n\t);\n}\n\nfunction uriRelativeToRoot(root: URL, candidate: URL): string | undefined {\n\tif (!sameFileAuthority(root, candidate) || candidate.search || candidate.hash) return undefined;\n\tconst rootSegments = decodedUrlSegments(root);\n\tconst candidateSegments = decodedUrlSegments(candidate);\n\tif (!rootSegments || !candidateSegments || rootSegments.length > candidateSegments.length) return undefined;\n\tconst windows = root.hostname.length > 0 || rootSegments[0]?.endsWith(\":\") === true;\n\tfor (let index = 0; index < rootSegments.length; index++) {\n\t\tconst left = windows ? rootSegments[index].toLowerCase() : rootSegments[index];\n\t\tconst right = windows ? candidateSegments[index].toLowerCase() : candidateSegments[index];\n\t\tif (left !== right) return undefined;\n\t}\n\treturn candidateSegments.slice(rootSegments.length).join(\"/\");\n}\n\nfunction appendUriPath(root: URL, child: string, flavor: PortablePathFlavor): string {\n\tconst output = new URL(root.toString());\n\tif (!child) return output.toString();\n\tconst base = output.pathname.endsWith(\"/\") ? output.pathname : `${output.pathname}/`;\n\toutput.pathname = `${base}${encodePathSegments(child, flavor)}`;\n\treturn output.toString();\n}\n\nfunction fileUriToPortablePath(url: URL): string {\n\tconst segments = decodedUrlSegments(url);\n\tif (!segments) throw new Error(`File URI contains invalid percent encoding: ${url.toString()}`);\n\tif (url.hostname && segments.length === 0) throw new Error(`UNC file URI is missing a share: ${url.toString()}`);\n\tif (segments[0]?.endsWith(\":\") && segments.length === 1 && !url.pathname.endsWith(\"/\")) {\n\t\tthrow new Error(`Windows file URI is drive-relative: ${url.toString()}`);\n\t}\n\tif (url.hostname || segments[0]?.endsWith(\":\")) {\n\t\tif (segments.some((segment) => segment.includes(\"\\\\\"))) {\n\t\t\tthrow new Error(`Windows file URI contains an encoded path separator: ${url.toString()}`);\n\t\t}\n\t\tif (url.hostname) return `\\\\\\\\${url.hostname}\\\\${segments.join(\"\\\\\")}`;\n\t\tif (segments.length === 1) return `${segments[0]}\\\\`;\n\t\treturn normalizePortablePath(segments.join(\"\\\\\"), \"windows\");\n\t}\n\treturn `/${segments.join(\"/\")}`;\n}\n\nfunction parseServerFileUri(serverUri: string): ServerFileUriParseResult {\n\tif (/^file:/i.test(serverUri) && !/^file:\\//i.test(serverUri)) {\n\t\treturn { ok: false, reason: `File URI ${JSON.stringify(serverUri)} must contain an absolute path` };\n\t}\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(serverUri);\n\t} catch {\n\t\treturn { ok: false, reason: `Server URI ${JSON.stringify(serverUri)} is malformed` };\n\t}\n\tif (url.protocol !== \"file:\") {\n\t\treturn { ok: false, reason: `Server URI ${JSON.stringify(serverUri)} is not a file URI` };\n\t}\n\tif (url.search || url.hash) {\n\t\treturn { ok: false, reason: `File URI ${JSON.stringify(serverUri)} must not contain a query or fragment` };\n\t}\n\treturn { ok: true, url };\n}\n\n/** Bidirectional, longest-root path mapper for one configured server. */\nexport class LspPathMapper {\n\tprivate readonly agentMappings: NormalizedMapping[];\n\tprivate readonly serverMappings: NormalizedMapping[];\n\n\tconstructor(mappings: readonly LspPathMapping[] = []) {\n\t\tconst normalized = mappings.map((mapping) => ({\n\t\t\tagentRoot: normalizePortablePath(mapping.agentRoot),\n\t\t\tserverRoot: new URL(mapping.serverRootUri),\n\t\t\tagentFlavor: pathFlavor(mapping.agentRoot),\n\t\t}));\n\t\tthis.agentMappings = [...normalized].sort((left, right) => right.agentRoot.length - left.agentRoot.length);\n\t\tthis.serverMappings = [...normalized].sort(\n\t\t\t(left, right) => right.serverRoot.pathname.length - left.serverRoot.pathname.length,\n\t\t);\n\t}\n\n\tagentPathToServerUri(agentPath: string): LspPathMappingResult {\n\t\tconst absolutePath = normalizePortablePath(agentPath);\n\t\tif (this.agentMappings.length === 0) {\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tvalue: portablePathToFileUri(absolutePath),\n\t\t\t};\n\t\t}\n\t\tfor (const mapping of this.agentMappings) {\n\t\t\tconst child = relativeWithin(mapping.agentRoot, absolutePath);\n\t\t\tif (child !== undefined) {\n\t\t\t\treturn { ok: true, value: appendUriPath(mapping.serverRoot, child, mapping.agentFlavor) };\n\t\t\t}\n\t\t}\n\t\treturn { ok: false, reason: `Path ${JSON.stringify(agentPath)} is outside all configured agent path mappings` };\n\t}\n\n\tserverUriToAgentPath(serverUri: string): LspPathMappingResult {\n\t\tconst parsed = parseServerFileUri(serverUri);\n\t\tif (!parsed.ok) return parsed;\n\t\tconst { url } = parsed;\n\t\tif (this.serverMappings.length === 0) {\n\t\t\ttry {\n\t\t\t\treturn { ok: true, value: fileUriToPortablePath(url) };\n\t\t\t} catch (error) {\n\t\t\t\treturn { ok: false, reason: error instanceof Error ? error.message : String(error) };\n\t\t\t}\n\t\t}\n\t\tfor (const mapping of this.serverMappings) {\n\t\t\tconst child = uriRelativeToRoot(mapping.serverRoot, url);\n\t\t\tif (child === undefined) continue;\n\t\t\tif (mapping.agentFlavor === \"windows\" && child.split(\"/\").some((segment) => segment.includes(\"\\\\\"))) {\n\t\t\t\treturn {\n\t\t\t\t\tok: false,\n\t\t\t\t\treason: `File URI ${JSON.stringify(serverUri)} contains an encoded Windows path separator`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst api = pathApi(mapping.agentFlavor);\n\t\t\treturn { ok: true, value: api.join(mapping.agentRoot, ...child.split(\"/\").filter(Boolean)) };\n\t\t}\n\t\treturn {\n\t\t\tok: false,\n\t\t\treason: `File URI ${JSON.stringify(serverUri)} is outside all configured server path mappings`,\n\t\t};\n\t}\n}\n\nfunction selectorMatches(selector: LspDocumentSelector, relativePath: string, flavor: PortablePathFlavor): boolean {\n\tif ((selector.scheme ?? \"file\") !== \"file\") return false;\n\tconst patternPath = flavor === \"windows\" ? relativePath.replace(/\\\\/g, \"/\") : relativePath;\n\treturn minimatch(patternPath, selector.pattern, { dot: true });\n}\n\nasync function defaultPathExists(path: string): Promise<boolean> {\n\ttry {\n\t\tawait access(path);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/** Resolves configured selectors into server/workspace instances without starting clients. */\nexport class LspRouter {\n\tprivate configuration: ResolvedLspConfiguration;\n\tprivate sessionRoot: string;\n\tprivate pathExists: (path: string) => Promise<boolean>;\n\tprivate contextGeneration = 0;\n\tprivate readonly rootCache = new Map<string, Promise<string | undefined>>();\n\n\tconstructor(sessionRoot: string, configuration: ResolvedLspConfiguration, options: LspRouterOptions = {}) {\n\t\tthis.sessionRoot = resolvePortablePath(process.cwd(), sessionRoot);\n\t\tthis.configuration = configuration;\n\t\tthis.pathExists = options.pathExists ?? defaultPathExists;\n\t}\n\n\tsetRoutingContext(sessionRoot: string, pathExists: (path: string) => Promise<boolean>): void {\n\t\tconst nextRoot = resolvePortablePath(process.cwd(), sessionRoot);\n\t\tif (nextRoot === this.sessionRoot && pathExists === this.pathExists) return;\n\t\tthis.clearCache();\n\t\tthis.sessionRoot = nextRoot;\n\t\tthis.pathExists = pathExists;\n\t}\n\n\tsetConfiguration(configuration: ResolvedLspConfiguration): void {\n\t\tthis.configuration = configuration;\n\t\tthis.clearCache();\n\t}\n\n\tclearCache(): void {\n\t\tthis.contextGeneration++;\n\t\tthis.rootCache.clear();\n\t}\n\n\tasync routeFile(filePath: string, signal?: AbortSignal): Promise<LspRouteResult> {\n\t\tconst generation = this.contextGeneration;\n\t\tconst absolutePath = isPortableAbsolute(filePath)\n\t\t\t? normalizePortablePath(filePath)\n\t\t\t: resolvePortablePath(this.sessionRoot, filePath);\n\t\tconst candidates = await waitForAbort(\n\t\t\tPromise.all(\n\t\t\t\tthis.configuration.servers.map(async (server, serverIndex) => {\n\t\t\t\t\tconst workspaceRoot = await this.resolveWorkspaceRoot(server, absolutePath);\n\t\t\t\t\tif (!workspaceRoot) return undefined;\n\t\t\t\t\tconst flavor = pathFlavor(workspaceRoot);\n\t\t\t\t\tconst workspacePath = relativeWithin(workspaceRoot, absolutePath);\n\t\t\t\t\tif (workspacePath === undefined) return undefined;\n\t\t\t\t\tconst selectorIndex = server.selectors.findIndex((selector) =>\n\t\t\t\t\t\tselectorMatches(selector, workspacePath, flavor),\n\t\t\t\t\t);\n\t\t\t\t\tif (selectorIndex === -1) return undefined;\n\t\t\t\t\tconst selector = server.selectors[selectorIndex];\n\t\t\t\t\tconst mapper = new LspPathMapper(server.pathMappings);\n\t\t\t\t\tconst mappedWorkspace = mapper.agentPathToServerUri(workspaceRoot);\n\t\t\t\t\tif (!mappedWorkspace.ok) return { server, serverIndex, failure: mappedWorkspace.reason };\n\t\t\t\t\tconst mapped = mapper.agentPathToServerUri(absolutePath);\n\t\t\t\t\tif (!mapped.ok) return { server, serverIndex, failure: mapped.reason };\n\t\t\t\t\treturn {\n\t\t\t\t\t\tserver,\n\t\t\t\t\t\tserverIndex,\n\t\t\t\t\t\tselectorIndex,\n\t\t\t\t\t\ttarget: {\n\t\t\t\t\t\t\tserver,\n\t\t\t\t\t\t\tserverId: server.id,\n\t\t\t\t\t\t\tlanguageId: selector.languageId,\n\t\t\t\t\t\t\tworkspaceRoot,\n\t\t\t\t\t\t\tinstanceKey: JSON.stringify([server.id, pathComparisonValue(workspaceRoot, flavor)]),\n\t\t\t\t\t\t\tserverUri: mapped.value,\n\t\t\t\t\t\t\tworkspaceUri: mappedWorkspace.value,\n\t\t\t\t\t\t\tmapper,\n\t\t\t\t\t\t} satisfies LspRouteTarget,\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t),\n\t\t\tsignal,\n\t\t);\n\t\tif (generation !== this.contextGeneration) return { targets: [], failures: [] };\n\t\tconst failures: LspRouteFailure[] = [];\n\t\tconst matched = candidates.flatMap((candidate) => {\n\t\t\tif (!candidate) return [];\n\t\t\tif (\"failure\" in candidate && typeof candidate.failure === \"string\") {\n\t\t\t\tfailures.push({ serverId: candidate.server.id, reason: candidate.failure });\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\treturn \"target\" in candidate ? [candidate] : [];\n\t\t});\n\t\tmatched.sort(\n\t\t\t(left, right) =>\n\t\t\t\t(right.server.priority ?? 0) - (left.server.priority ?? 0) ||\n\t\t\t\tleft.serverIndex - right.serverIndex ||\n\t\t\t\tleft.selectorIndex - right.selectorIndex,\n\t\t);\n\t\treturn { targets: matched.map((candidate) => candidate.target), failures };\n\t}\n\n\tprivate resolveWorkspaceRoot(server: LspConfiguredServer, filePath: string): Promise<string | undefined> {\n\t\tif (server.workspace.type === \"session\") return Promise.resolve(this.sessionRoot);\n\t\tif (server.workspace.type === \"fixed\") {\n\t\t\treturn Promise.resolve(resolvePortablePath(this.sessionRoot, server.workspace.path));\n\t\t}\n\t\tconst directory = dirnamePortablePath(filePath);\n\t\tconst cacheKey = `${server.id}\\u0000${pathComparisonValue(directory)}`;\n\t\tconst cached = this.rootCache.get(cacheKey);\n\t\tif (cached) return cached;\n\t\tconst discovery = this.discoverMarkerRoot(server, directory);\n\t\tthis.rootCache.set(cacheKey, discovery);\n\t\treturn discovery;\n\t}\n\n\tprivate async directoryContainsWorkspaceMarker(directory: string, markers: readonly string[]): Promise<boolean> {\n\t\tfor (const marker of markers) {\n\t\t\tif (await this.pathExists(joinPortablePath(directory, marker)).catch(() => false)) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate async discoverMarkerRoot(server: LspConfiguredServer, startDirectory: string): Promise<string | undefined> {\n\t\tif (server.workspace.type !== \"markers\") return undefined;\n\t\tconst api = pathApi(pathFlavor(startDirectory));\n\t\tconst boundary = resolvePortablePath(this.sessionRoot, server.workspace.stopAt ?? this.sessionRoot);\n\t\tif (relativeWithin(boundary, startDirectory) === undefined) {\n\t\t\treturn server.workspace.fallback === \"session\" ? this.sessionRoot : undefined;\n\t\t}\n\t\tlet directory = normalizePortablePath(startDirectory);\n\t\twhile (true) {\n\t\t\tif (await this.directoryContainsWorkspaceMarker(directory, server.workspace.markers)) return directory;\n\t\t\tif (pathComparisonValue(directory) === pathComparisonValue(boundary)) break;\n\t\t\tconst parent = api.dirname(directory);\n\t\t\tif (parent === directory || relativeWithin(boundary, parent) === undefined) break;\n\t\t\tdirectory = parent;\n\t\t}\n\t\treturn server.workspace.fallback === \"session\" ? this.sessionRoot : undefined;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { access } from "node:fs/promises";
|
|
2
|
+
import { minimatch } from "minimatch";
|
|
3
|
+
import { waitForAbort } from "./abort.js";
|
|
4
|
+
import { dirnamePortablePath, isPortableAbsolute, joinPortablePath, normalizePortablePath, pathApi, pathComparisonValue, pathFlavor, portablePathToFileUri, relativeWithin, resolvePortablePath, } from "./portable-path.js";
|
|
5
|
+
function encodePathSegments(value, flavor) {
|
|
6
|
+
return value
|
|
7
|
+
.split(flavor === "windows" ? /[\\/]/ : "/")
|
|
8
|
+
.filter(Boolean)
|
|
9
|
+
.map((segment) => encodeURIComponent(segment))
|
|
10
|
+
.join("/");
|
|
11
|
+
}
|
|
12
|
+
function decodedUrlSegments(url) {
|
|
13
|
+
try {
|
|
14
|
+
const segments = url.pathname
|
|
15
|
+
.split("/")
|
|
16
|
+
.filter(Boolean)
|
|
17
|
+
.map((segment) => decodeURIComponent(segment));
|
|
18
|
+
return segments.some((segment) => segment === "." || segment === ".." || segment.includes("/"))
|
|
19
|
+
? undefined
|
|
20
|
+
: segments;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function sameFileAuthority(left, right) {
|
|
27
|
+
return (left.protocol === "file:" &&
|
|
28
|
+
right.protocol === "file:" &&
|
|
29
|
+
left.hostname.toLowerCase() === right.hostname.toLowerCase());
|
|
30
|
+
}
|
|
31
|
+
function uriRelativeToRoot(root, candidate) {
|
|
32
|
+
if (!sameFileAuthority(root, candidate) || candidate.search || candidate.hash)
|
|
33
|
+
return undefined;
|
|
34
|
+
const rootSegments = decodedUrlSegments(root);
|
|
35
|
+
const candidateSegments = decodedUrlSegments(candidate);
|
|
36
|
+
if (!rootSegments || !candidateSegments || rootSegments.length > candidateSegments.length)
|
|
37
|
+
return undefined;
|
|
38
|
+
const windows = root.hostname.length > 0 || rootSegments[0]?.endsWith(":") === true;
|
|
39
|
+
for (let index = 0; index < rootSegments.length; index++) {
|
|
40
|
+
const left = windows ? rootSegments[index].toLowerCase() : rootSegments[index];
|
|
41
|
+
const right = windows ? candidateSegments[index].toLowerCase() : candidateSegments[index];
|
|
42
|
+
if (left !== right)
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return candidateSegments.slice(rootSegments.length).join("/");
|
|
46
|
+
}
|
|
47
|
+
function appendUriPath(root, child, flavor) {
|
|
48
|
+
const output = new URL(root.toString());
|
|
49
|
+
if (!child)
|
|
50
|
+
return output.toString();
|
|
51
|
+
const base = output.pathname.endsWith("/") ? output.pathname : `${output.pathname}/`;
|
|
52
|
+
output.pathname = `${base}${encodePathSegments(child, flavor)}`;
|
|
53
|
+
return output.toString();
|
|
54
|
+
}
|
|
55
|
+
function fileUriToPortablePath(url) {
|
|
56
|
+
const segments = decodedUrlSegments(url);
|
|
57
|
+
if (!segments)
|
|
58
|
+
throw new Error(`File URI contains invalid percent encoding: ${url.toString()}`);
|
|
59
|
+
if (url.hostname && segments.length === 0)
|
|
60
|
+
throw new Error(`UNC file URI is missing a share: ${url.toString()}`);
|
|
61
|
+
if (segments[0]?.endsWith(":") && segments.length === 1 && !url.pathname.endsWith("/")) {
|
|
62
|
+
throw new Error(`Windows file URI is drive-relative: ${url.toString()}`);
|
|
63
|
+
}
|
|
64
|
+
if (url.hostname || segments[0]?.endsWith(":")) {
|
|
65
|
+
if (segments.some((segment) => segment.includes("\\"))) {
|
|
66
|
+
throw new Error(`Windows file URI contains an encoded path separator: ${url.toString()}`);
|
|
67
|
+
}
|
|
68
|
+
if (url.hostname)
|
|
69
|
+
return `\\\\${url.hostname}\\${segments.join("\\")}`;
|
|
70
|
+
if (segments.length === 1)
|
|
71
|
+
return `${segments[0]}\\`;
|
|
72
|
+
return normalizePortablePath(segments.join("\\"), "windows");
|
|
73
|
+
}
|
|
74
|
+
return `/${segments.join("/")}`;
|
|
75
|
+
}
|
|
76
|
+
function parseServerFileUri(serverUri) {
|
|
77
|
+
if (/^file:/i.test(serverUri) && !/^file:\//i.test(serverUri)) {
|
|
78
|
+
return { ok: false, reason: `File URI ${JSON.stringify(serverUri)} must contain an absolute path` };
|
|
79
|
+
}
|
|
80
|
+
let url;
|
|
81
|
+
try {
|
|
82
|
+
url = new URL(serverUri);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return { ok: false, reason: `Server URI ${JSON.stringify(serverUri)} is malformed` };
|
|
86
|
+
}
|
|
87
|
+
if (url.protocol !== "file:") {
|
|
88
|
+
return { ok: false, reason: `Server URI ${JSON.stringify(serverUri)} is not a file URI` };
|
|
89
|
+
}
|
|
90
|
+
if (url.search || url.hash) {
|
|
91
|
+
return { ok: false, reason: `File URI ${JSON.stringify(serverUri)} must not contain a query or fragment` };
|
|
92
|
+
}
|
|
93
|
+
return { ok: true, url };
|
|
94
|
+
}
|
|
95
|
+
/** Bidirectional, longest-root path mapper for one configured server. */
|
|
96
|
+
export class LspPathMapper {
|
|
97
|
+
agentMappings;
|
|
98
|
+
serverMappings;
|
|
99
|
+
constructor(mappings = []) {
|
|
100
|
+
const normalized = mappings.map((mapping) => ({
|
|
101
|
+
agentRoot: normalizePortablePath(mapping.agentRoot),
|
|
102
|
+
serverRoot: new URL(mapping.serverRootUri),
|
|
103
|
+
agentFlavor: pathFlavor(mapping.agentRoot),
|
|
104
|
+
}));
|
|
105
|
+
this.agentMappings = [...normalized].sort((left, right) => right.agentRoot.length - left.agentRoot.length);
|
|
106
|
+
this.serverMappings = [...normalized].sort((left, right) => right.serverRoot.pathname.length - left.serverRoot.pathname.length);
|
|
107
|
+
}
|
|
108
|
+
agentPathToServerUri(agentPath) {
|
|
109
|
+
const absolutePath = normalizePortablePath(agentPath);
|
|
110
|
+
if (this.agentMappings.length === 0) {
|
|
111
|
+
return {
|
|
112
|
+
ok: true,
|
|
113
|
+
value: portablePathToFileUri(absolutePath),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
for (const mapping of this.agentMappings) {
|
|
117
|
+
const child = relativeWithin(mapping.agentRoot, absolutePath);
|
|
118
|
+
if (child !== undefined) {
|
|
119
|
+
return { ok: true, value: appendUriPath(mapping.serverRoot, child, mapping.agentFlavor) };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return { ok: false, reason: `Path ${JSON.stringify(agentPath)} is outside all configured agent path mappings` };
|
|
123
|
+
}
|
|
124
|
+
serverUriToAgentPath(serverUri) {
|
|
125
|
+
const parsed = parseServerFileUri(serverUri);
|
|
126
|
+
if (!parsed.ok)
|
|
127
|
+
return parsed;
|
|
128
|
+
const { url } = parsed;
|
|
129
|
+
if (this.serverMappings.length === 0) {
|
|
130
|
+
try {
|
|
131
|
+
return { ok: true, value: fileUriToPortablePath(url) };
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
return { ok: false, reason: error instanceof Error ? error.message : String(error) };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
for (const mapping of this.serverMappings) {
|
|
138
|
+
const child = uriRelativeToRoot(mapping.serverRoot, url);
|
|
139
|
+
if (child === undefined)
|
|
140
|
+
continue;
|
|
141
|
+
if (mapping.agentFlavor === "windows" && child.split("/").some((segment) => segment.includes("\\"))) {
|
|
142
|
+
return {
|
|
143
|
+
ok: false,
|
|
144
|
+
reason: `File URI ${JSON.stringify(serverUri)} contains an encoded Windows path separator`,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
const api = pathApi(mapping.agentFlavor);
|
|
148
|
+
return { ok: true, value: api.join(mapping.agentRoot, ...child.split("/").filter(Boolean)) };
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
ok: false,
|
|
152
|
+
reason: `File URI ${JSON.stringify(serverUri)} is outside all configured server path mappings`,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function selectorMatches(selector, relativePath, flavor) {
|
|
157
|
+
if ((selector.scheme ?? "file") !== "file")
|
|
158
|
+
return false;
|
|
159
|
+
const patternPath = flavor === "windows" ? relativePath.replace(/\\/g, "/") : relativePath;
|
|
160
|
+
return minimatch(patternPath, selector.pattern, { dot: true });
|
|
161
|
+
}
|
|
162
|
+
async function defaultPathExists(path) {
|
|
163
|
+
try {
|
|
164
|
+
await access(path);
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/** Resolves configured selectors into server/workspace instances without starting clients. */
|
|
172
|
+
export class LspRouter {
|
|
173
|
+
configuration;
|
|
174
|
+
sessionRoot;
|
|
175
|
+
pathExists;
|
|
176
|
+
contextGeneration = 0;
|
|
177
|
+
rootCache = new Map();
|
|
178
|
+
constructor(sessionRoot, configuration, options = {}) {
|
|
179
|
+
this.sessionRoot = resolvePortablePath(process.cwd(), sessionRoot);
|
|
180
|
+
this.configuration = configuration;
|
|
181
|
+
this.pathExists = options.pathExists ?? defaultPathExists;
|
|
182
|
+
}
|
|
183
|
+
setRoutingContext(sessionRoot, pathExists) {
|
|
184
|
+
const nextRoot = resolvePortablePath(process.cwd(), sessionRoot);
|
|
185
|
+
if (nextRoot === this.sessionRoot && pathExists === this.pathExists)
|
|
186
|
+
return;
|
|
187
|
+
this.clearCache();
|
|
188
|
+
this.sessionRoot = nextRoot;
|
|
189
|
+
this.pathExists = pathExists;
|
|
190
|
+
}
|
|
191
|
+
setConfiguration(configuration) {
|
|
192
|
+
this.configuration = configuration;
|
|
193
|
+
this.clearCache();
|
|
194
|
+
}
|
|
195
|
+
clearCache() {
|
|
196
|
+
this.contextGeneration++;
|
|
197
|
+
this.rootCache.clear();
|
|
198
|
+
}
|
|
199
|
+
async routeFile(filePath, signal) {
|
|
200
|
+
const generation = this.contextGeneration;
|
|
201
|
+
const absolutePath = isPortableAbsolute(filePath)
|
|
202
|
+
? normalizePortablePath(filePath)
|
|
203
|
+
: resolvePortablePath(this.sessionRoot, filePath);
|
|
204
|
+
const candidates = await waitForAbort(Promise.all(this.configuration.servers.map(async (server, serverIndex) => {
|
|
205
|
+
const workspaceRoot = await this.resolveWorkspaceRoot(server, absolutePath);
|
|
206
|
+
if (!workspaceRoot)
|
|
207
|
+
return undefined;
|
|
208
|
+
const flavor = pathFlavor(workspaceRoot);
|
|
209
|
+
const workspacePath = relativeWithin(workspaceRoot, absolutePath);
|
|
210
|
+
if (workspacePath === undefined)
|
|
211
|
+
return undefined;
|
|
212
|
+
const selectorIndex = server.selectors.findIndex((selector) => selectorMatches(selector, workspacePath, flavor));
|
|
213
|
+
if (selectorIndex === -1)
|
|
214
|
+
return undefined;
|
|
215
|
+
const selector = server.selectors[selectorIndex];
|
|
216
|
+
const mapper = new LspPathMapper(server.pathMappings);
|
|
217
|
+
const mappedWorkspace = mapper.agentPathToServerUri(workspaceRoot);
|
|
218
|
+
if (!mappedWorkspace.ok)
|
|
219
|
+
return { server, serverIndex, failure: mappedWorkspace.reason };
|
|
220
|
+
const mapped = mapper.agentPathToServerUri(absolutePath);
|
|
221
|
+
if (!mapped.ok)
|
|
222
|
+
return { server, serverIndex, failure: mapped.reason };
|
|
223
|
+
return {
|
|
224
|
+
server,
|
|
225
|
+
serverIndex,
|
|
226
|
+
selectorIndex,
|
|
227
|
+
target: {
|
|
228
|
+
server,
|
|
229
|
+
serverId: server.id,
|
|
230
|
+
languageId: selector.languageId,
|
|
231
|
+
workspaceRoot,
|
|
232
|
+
instanceKey: JSON.stringify([server.id, pathComparisonValue(workspaceRoot, flavor)]),
|
|
233
|
+
serverUri: mapped.value,
|
|
234
|
+
workspaceUri: mappedWorkspace.value,
|
|
235
|
+
mapper,
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
})), signal);
|
|
239
|
+
if (generation !== this.contextGeneration)
|
|
240
|
+
return { targets: [], failures: [] };
|
|
241
|
+
const failures = [];
|
|
242
|
+
const matched = candidates.flatMap((candidate) => {
|
|
243
|
+
if (!candidate)
|
|
244
|
+
return [];
|
|
245
|
+
if ("failure" in candidate && typeof candidate.failure === "string") {
|
|
246
|
+
failures.push({ serverId: candidate.server.id, reason: candidate.failure });
|
|
247
|
+
return [];
|
|
248
|
+
}
|
|
249
|
+
return "target" in candidate ? [candidate] : [];
|
|
250
|
+
});
|
|
251
|
+
matched.sort((left, right) => (right.server.priority ?? 0) - (left.server.priority ?? 0) ||
|
|
252
|
+
left.serverIndex - right.serverIndex ||
|
|
253
|
+
left.selectorIndex - right.selectorIndex);
|
|
254
|
+
return { targets: matched.map((candidate) => candidate.target), failures };
|
|
255
|
+
}
|
|
256
|
+
resolveWorkspaceRoot(server, filePath) {
|
|
257
|
+
if (server.workspace.type === "session")
|
|
258
|
+
return Promise.resolve(this.sessionRoot);
|
|
259
|
+
if (server.workspace.type === "fixed") {
|
|
260
|
+
return Promise.resolve(resolvePortablePath(this.sessionRoot, server.workspace.path));
|
|
261
|
+
}
|
|
262
|
+
const directory = dirnamePortablePath(filePath);
|
|
263
|
+
const cacheKey = `${server.id}\u0000${pathComparisonValue(directory)}`;
|
|
264
|
+
const cached = this.rootCache.get(cacheKey);
|
|
265
|
+
if (cached)
|
|
266
|
+
return cached;
|
|
267
|
+
const discovery = this.discoverMarkerRoot(server, directory);
|
|
268
|
+
this.rootCache.set(cacheKey, discovery);
|
|
269
|
+
return discovery;
|
|
270
|
+
}
|
|
271
|
+
async directoryContainsWorkspaceMarker(directory, markers) {
|
|
272
|
+
for (const marker of markers) {
|
|
273
|
+
if (await this.pathExists(joinPortablePath(directory, marker)).catch(() => false))
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
async discoverMarkerRoot(server, startDirectory) {
|
|
279
|
+
if (server.workspace.type !== "markers")
|
|
280
|
+
return undefined;
|
|
281
|
+
const api = pathApi(pathFlavor(startDirectory));
|
|
282
|
+
const boundary = resolvePortablePath(this.sessionRoot, server.workspace.stopAt ?? this.sessionRoot);
|
|
283
|
+
if (relativeWithin(boundary, startDirectory) === undefined) {
|
|
284
|
+
return server.workspace.fallback === "session" ? this.sessionRoot : undefined;
|
|
285
|
+
}
|
|
286
|
+
let directory = normalizePortablePath(startDirectory);
|
|
287
|
+
while (true) {
|
|
288
|
+
if (await this.directoryContainsWorkspaceMarker(directory, server.workspace.markers))
|
|
289
|
+
return directory;
|
|
290
|
+
if (pathComparisonValue(directory) === pathComparisonValue(boundary))
|
|
291
|
+
break;
|
|
292
|
+
const parent = api.dirname(directory);
|
|
293
|
+
if (parent === directory || relativeWithin(boundary, parent) === undefined)
|
|
294
|
+
break;
|
|
295
|
+
directory = parent;
|
|
296
|
+
}
|
|
297
|
+
return server.workspace.fallback === "session" ? this.sessionRoot : undefined;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
//# sourceMappingURL=language-map.js.map
|