@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,793 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { constants, createReadStream, createWriteStream } from "node:fs";
|
|
4
|
+
import { access as fsAccess, mkdir as fsMkdir, readdir as fsReaddir, readFile as fsReadFile, stat as fsStat, writeFile as fsWriteFile, } from "node:fs/promises";
|
|
5
|
+
import { posix, win32 } from "node:path";
|
|
6
|
+
import { pipeline } from "node:stream/promises";
|
|
7
|
+
import WebSocket from "ws";
|
|
8
|
+
import { DAEMON_WEBSOCKET_PROTOCOL } from "../../daemon/config.js";
|
|
9
|
+
import { waitForChildProcess } from "../../utils/child-process.js";
|
|
10
|
+
import { detectSupportedImageMimeTypeFromFile } from "../../utils/mime.js";
|
|
11
|
+
import { getShellConfig, getShellEnv, killProcessTree, trackDetachedChildPid, untrackDetachedChildPid, } from "../../utils/shell.js";
|
|
12
|
+
import { DEFAULT_REMOTE_WORKSPACE_PROTOCOL_LIMITS, decodeCanonicalBase64, hashRemoteWorkspaceJson, parseRemoteWorkspaceToolResult, } from "../remote-workspace-protocol/contract.js";
|
|
13
|
+
import { GuestSharedClientTransport } from "../remote-workspace-protocol/guest-shared-client.js";
|
|
14
|
+
import { RemoteWorkspaceClientProtocol, RemoteWorkspaceRequestError, } from "../remote-workspace-protocol/session.js";
|
|
15
|
+
export const GRIP_SESSION_ENVIRONMENT_NAMES = Object.freeze([
|
|
16
|
+
"GRIP_SESSION_ID",
|
|
17
|
+
"GRIP_SESSION_FILE",
|
|
18
|
+
"GRIP_PROVIDER",
|
|
19
|
+
"GRIP_MODEL",
|
|
20
|
+
"GRIP_REASONING_LEVEL",
|
|
21
|
+
]);
|
|
22
|
+
export function borrowToolOperations(operations) {
|
|
23
|
+
const boundMethods = new Map();
|
|
24
|
+
return new Proxy(operations, {
|
|
25
|
+
get(target, property, receiver) {
|
|
26
|
+
if (property === "dispose")
|
|
27
|
+
return undefined;
|
|
28
|
+
const value = Reflect.get(target, property, receiver);
|
|
29
|
+
if (typeof value !== "function")
|
|
30
|
+
return value;
|
|
31
|
+
let bound = boundMethods.get(property);
|
|
32
|
+
if (!bound) {
|
|
33
|
+
bound = value.bind(target);
|
|
34
|
+
boundMethods.set(property, bound);
|
|
35
|
+
}
|
|
36
|
+
return bound;
|
|
37
|
+
},
|
|
38
|
+
has(target, property) {
|
|
39
|
+
return property === "dispose" ? false : Reflect.has(target, property);
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function workspaceRootsEqual(left, right, pathFlavor) {
|
|
44
|
+
if (pathFlavor === "windows")
|
|
45
|
+
return win32.normalize(left).toLowerCase() === win32.normalize(right).toLowerCase();
|
|
46
|
+
return posix.normalize(left) === posix.normalize(right);
|
|
47
|
+
}
|
|
48
|
+
function accessModeToFsMode(mode) {
|
|
49
|
+
switch (mode) {
|
|
50
|
+
case "read":
|
|
51
|
+
return constants.R_OK;
|
|
52
|
+
case "write":
|
|
53
|
+
return constants.W_OK;
|
|
54
|
+
case "readwrite":
|
|
55
|
+
return constants.R_OK | constants.W_OK;
|
|
56
|
+
case "exists":
|
|
57
|
+
case undefined:
|
|
58
|
+
return constants.F_OK;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const MAX_TIMEOUT_MS = 2_147_483_647;
|
|
62
|
+
const MAX_TIMEOUT_SECONDS = MAX_TIMEOUT_MS / 1000;
|
|
63
|
+
function resolveTimeoutMs(timeout) {
|
|
64
|
+
if (timeout === undefined)
|
|
65
|
+
return undefined;
|
|
66
|
+
if (!Number.isFinite(timeout) || timeout <= 0) {
|
|
67
|
+
throw new Error("Invalid timeout: must be a finite number of seconds");
|
|
68
|
+
}
|
|
69
|
+
const timeoutMs = timeout * 1000;
|
|
70
|
+
if (timeoutMs > MAX_TIMEOUT_MS) {
|
|
71
|
+
throw new Error(`Invalid timeout: maximum is ${MAX_TIMEOUT_SECONDS} seconds`);
|
|
72
|
+
}
|
|
73
|
+
return timeoutMs;
|
|
74
|
+
}
|
|
75
|
+
function registerChildProcessAbort(signal, child) {
|
|
76
|
+
const onAbort = () => {
|
|
77
|
+
if (child.pid)
|
|
78
|
+
killProcessTree(child.pid);
|
|
79
|
+
};
|
|
80
|
+
if (!signal)
|
|
81
|
+
return () => undefined;
|
|
82
|
+
if (signal.aborted)
|
|
83
|
+
onAbort();
|
|
84
|
+
else
|
|
85
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
86
|
+
return () => signal.removeEventListener("abort", onAbort);
|
|
87
|
+
}
|
|
88
|
+
function terminateLingeringProcessGroup(child) {
|
|
89
|
+
if (!child.pid || process.platform === "win32")
|
|
90
|
+
return;
|
|
91
|
+
try {
|
|
92
|
+
process.kill(-child.pid, 0);
|
|
93
|
+
killProcessTree(child.pid);
|
|
94
|
+
}
|
|
95
|
+
catch { }
|
|
96
|
+
}
|
|
97
|
+
function cleanupChildExecution(child, timeoutHandle, removeAbortListener) {
|
|
98
|
+
if (child.pid)
|
|
99
|
+
untrackDetachedChildPid(child.pid);
|
|
100
|
+
if (timeoutHandle)
|
|
101
|
+
clearTimeout(timeoutHandle);
|
|
102
|
+
removeAbortListener();
|
|
103
|
+
}
|
|
104
|
+
async function copyFileStream(sourcePath, destinationPath) {
|
|
105
|
+
await pipeline(createReadStream(sourcePath), createWriteStream(destinationPath));
|
|
106
|
+
}
|
|
107
|
+
function writeStreamChunk(stream, chunk) {
|
|
108
|
+
return new Promise((resolve, reject) => {
|
|
109
|
+
const onError = (error) => {
|
|
110
|
+
stream.off("error", onError);
|
|
111
|
+
reject(error);
|
|
112
|
+
};
|
|
113
|
+
stream.once("error", onError);
|
|
114
|
+
stream.write(chunk, (error) => {
|
|
115
|
+
stream.off("error", onError);
|
|
116
|
+
if (error) {
|
|
117
|
+
reject(error);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
resolve();
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function endWriteStream(stream) {
|
|
125
|
+
return new Promise((resolve, reject) => {
|
|
126
|
+
const onError = (error) => {
|
|
127
|
+
stream.off("error", onError);
|
|
128
|
+
reject(error);
|
|
129
|
+
};
|
|
130
|
+
stream.once("error", onError);
|
|
131
|
+
stream.end(() => {
|
|
132
|
+
stream.off("error", onError);
|
|
133
|
+
resolve();
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
export class LocalToolOperations {
|
|
138
|
+
cwd;
|
|
139
|
+
shellPath;
|
|
140
|
+
constructor(cwd, options = {}) {
|
|
141
|
+
this.cwd = cwd;
|
|
142
|
+
this.shellPath = options.shellPath;
|
|
143
|
+
}
|
|
144
|
+
setShellPath(shellPath) {
|
|
145
|
+
this.shellPath = shellPath;
|
|
146
|
+
}
|
|
147
|
+
async exec(command, options) {
|
|
148
|
+
const timeoutMs = resolveTimeoutMs(options.timeout);
|
|
149
|
+
const cwd = options.cwd ?? this.cwd;
|
|
150
|
+
const { shell, args } = getShellConfig(this.shellPath);
|
|
151
|
+
try {
|
|
152
|
+
await fsAccess(cwd, constants.F_OK);
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
throw new Error(`Working directory does not exist: ${cwd}\nCannot execute bash commands.`);
|
|
156
|
+
}
|
|
157
|
+
if (options.signal?.aborted) {
|
|
158
|
+
throw new Error("aborted");
|
|
159
|
+
}
|
|
160
|
+
return new Promise((resolve, reject) => {
|
|
161
|
+
const child = spawn(shell, [...args, command], {
|
|
162
|
+
cwd,
|
|
163
|
+
detached: process.platform !== "win32",
|
|
164
|
+
env: options.env ?? getShellEnv(),
|
|
165
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
166
|
+
windowsHide: true,
|
|
167
|
+
});
|
|
168
|
+
if (child.pid)
|
|
169
|
+
trackDetachedChildPid(child.pid);
|
|
170
|
+
let timedOut = false;
|
|
171
|
+
let timeoutHandle;
|
|
172
|
+
if (timeoutMs !== undefined) {
|
|
173
|
+
timeoutHandle = setTimeout(() => {
|
|
174
|
+
timedOut = true;
|
|
175
|
+
if (child.pid)
|
|
176
|
+
killProcessTree(child.pid);
|
|
177
|
+
}, timeoutMs);
|
|
178
|
+
}
|
|
179
|
+
child.stdout?.on("data", options.onData);
|
|
180
|
+
child.stderr?.on("data", options.onData);
|
|
181
|
+
const removeAbortListener = registerChildProcessAbort(options.signal, child);
|
|
182
|
+
waitForChildProcess(child)
|
|
183
|
+
.then((code) => {
|
|
184
|
+
terminateLingeringProcessGroup(child);
|
|
185
|
+
cleanupChildExecution(child, timeoutHandle, removeAbortListener);
|
|
186
|
+
if (options.signal?.aborted) {
|
|
187
|
+
reject(new Error("aborted"));
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (timedOut) {
|
|
191
|
+
reject(new Error(`timeout:${options.timeout}`));
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
resolve({ exitCode: code });
|
|
195
|
+
})
|
|
196
|
+
.catch((error) => {
|
|
197
|
+
cleanupChildExecution(child, timeoutHandle, removeAbortListener);
|
|
198
|
+
reject(error);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
async access(path, mode) {
|
|
203
|
+
await fsAccess(path, accessModeToFsMode(mode));
|
|
204
|
+
}
|
|
205
|
+
async readFile(path) {
|
|
206
|
+
return fsReadFile(path);
|
|
207
|
+
}
|
|
208
|
+
async writeFile(path, content) {
|
|
209
|
+
await fsWriteFile(path, content, typeof content === "string" ? "utf-8" : undefined);
|
|
210
|
+
}
|
|
211
|
+
async uploadFile(sourcePath, destinationPath) {
|
|
212
|
+
await copyFileStream(sourcePath, destinationPath);
|
|
213
|
+
}
|
|
214
|
+
async downloadFile(sourcePath, destinationPath) {
|
|
215
|
+
await copyFileStream(sourcePath, destinationPath);
|
|
216
|
+
}
|
|
217
|
+
async mkdir(path, options = {}) {
|
|
218
|
+
await fsMkdir(path, { recursive: options.recursive ?? false });
|
|
219
|
+
}
|
|
220
|
+
async stat(path) {
|
|
221
|
+
return fsStat(path);
|
|
222
|
+
}
|
|
223
|
+
async readdir(path) {
|
|
224
|
+
return fsReaddir(path);
|
|
225
|
+
}
|
|
226
|
+
async detectImageMimeType(path) {
|
|
227
|
+
return detectSupportedImageMimeTypeFromFile(path);
|
|
228
|
+
}
|
|
229
|
+
getBackendInfo() {
|
|
230
|
+
return { type: "local", cwd: this.cwd };
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
export class DeferredRemoteToolOperations {
|
|
234
|
+
cwd;
|
|
235
|
+
expectedCwd;
|
|
236
|
+
operations;
|
|
237
|
+
remoteCatalogUnsubscribe;
|
|
238
|
+
catalogListeners = new Set();
|
|
239
|
+
disposePromise;
|
|
240
|
+
onDisconnect;
|
|
241
|
+
constructor(cwd, onDisconnect) {
|
|
242
|
+
this.cwd = cwd;
|
|
243
|
+
this.expectedCwd = cwd;
|
|
244
|
+
this.onDisconnect = onDisconnect;
|
|
245
|
+
}
|
|
246
|
+
async configureRemote(url, options = {}) {
|
|
247
|
+
const next = await createRemoteToolOperations(url, { ...options, onDisconnect: this.onDisconnect });
|
|
248
|
+
try {
|
|
249
|
+
const stat = await next.stat(next.cwd);
|
|
250
|
+
if (!stat.isDirectory())
|
|
251
|
+
throw new Error(`Remote daemon cwd is not a directory: ${next.cwd}`);
|
|
252
|
+
const expectedCwd = options.expectedCwd ?? this.expectedCwd;
|
|
253
|
+
if (!workspaceRootsEqual(next.cwd, expectedCwd, next.workspacePathFlavor)) {
|
|
254
|
+
throw new Error(`Remote daemon workspace root mismatch: expected ${expectedCwd}, received ${next.cwd}`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
await next.dispose();
|
|
259
|
+
throw error;
|
|
260
|
+
}
|
|
261
|
+
await this.replaceOperations(next);
|
|
262
|
+
return this.getBackendInfo();
|
|
263
|
+
}
|
|
264
|
+
async clear() {
|
|
265
|
+
const previous = this.operations;
|
|
266
|
+
this.remoteCatalogUnsubscribe?.();
|
|
267
|
+
this.remoteCatalogUnsubscribe = undefined;
|
|
268
|
+
this.operations = undefined;
|
|
269
|
+
await previous?.dispose?.();
|
|
270
|
+
}
|
|
271
|
+
requireOperations() {
|
|
272
|
+
if (!this.operations) {
|
|
273
|
+
throw new Error("Remote backend is not configured. Configure it over RPC or with /sandbox before using tools.");
|
|
274
|
+
}
|
|
275
|
+
return this.operations;
|
|
276
|
+
}
|
|
277
|
+
async exec(command, options) {
|
|
278
|
+
return this.requireOperations().exec(command, options);
|
|
279
|
+
}
|
|
280
|
+
async access(path, mode) {
|
|
281
|
+
await this.requireOperations().access(path, mode);
|
|
282
|
+
}
|
|
283
|
+
async readFile(path) {
|
|
284
|
+
return this.requireOperations().readFile(path);
|
|
285
|
+
}
|
|
286
|
+
async writeFile(path, content) {
|
|
287
|
+
await this.requireOperations().writeFile(path, content);
|
|
288
|
+
}
|
|
289
|
+
async uploadFile(sourcePath, destinationPath) {
|
|
290
|
+
const operations = this.requireOperations();
|
|
291
|
+
if (!operations.uploadFile)
|
|
292
|
+
throw new Error("Remote backend does not support file upload");
|
|
293
|
+
await operations.uploadFile(sourcePath, destinationPath);
|
|
294
|
+
}
|
|
295
|
+
async downloadFile(sourcePath, destinationPath) {
|
|
296
|
+
const operations = this.requireOperations();
|
|
297
|
+
if (!operations.downloadFile)
|
|
298
|
+
throw new Error("Remote backend does not support file download");
|
|
299
|
+
await operations.downloadFile(sourcePath, destinationPath);
|
|
300
|
+
}
|
|
301
|
+
async mkdir(path, options) {
|
|
302
|
+
await this.requireOperations().mkdir(path, options);
|
|
303
|
+
}
|
|
304
|
+
async stat(path) {
|
|
305
|
+
return this.requireOperations().stat(path);
|
|
306
|
+
}
|
|
307
|
+
async readdir(path) {
|
|
308
|
+
return this.requireOperations().readdir(path);
|
|
309
|
+
}
|
|
310
|
+
async glob(pattern, cwd, options) {
|
|
311
|
+
return this.requireOperations().glob(pattern, cwd, options);
|
|
312
|
+
}
|
|
313
|
+
async grep(options) {
|
|
314
|
+
return this.requireOperations().grep(options);
|
|
315
|
+
}
|
|
316
|
+
async detectImageMimeType(path) {
|
|
317
|
+
return this.requireOperations().detectImageMimeType(path);
|
|
318
|
+
}
|
|
319
|
+
getBackendInfo() {
|
|
320
|
+
return this.operations?.getBackendInfo() ?? { type: "remote", cwd: this.cwd, configured: false };
|
|
321
|
+
}
|
|
322
|
+
isDisconnected() {
|
|
323
|
+
return this.operations?.isDisconnected() ?? false;
|
|
324
|
+
}
|
|
325
|
+
resolveWorkspaceToolExecution(name, parameterSchema) {
|
|
326
|
+
return this.operations ? this.operations.resolveWorkspaceToolExecution(name, parameterSchema) : "unavailable";
|
|
327
|
+
}
|
|
328
|
+
executeWorkspaceTool(name, invocation) {
|
|
329
|
+
return this.requireOperations().executeWorkspaceTool(name, invocation);
|
|
330
|
+
}
|
|
331
|
+
getRemoteLspStatus() {
|
|
332
|
+
return this.operations?.getRemoteLspStatus() ?? { enabled: false, servers: [] };
|
|
333
|
+
}
|
|
334
|
+
onWorkspaceToolCatalogChanged(listener) {
|
|
335
|
+
this.catalogListeners.add(listener);
|
|
336
|
+
return () => this.catalogListeners.delete(listener);
|
|
337
|
+
}
|
|
338
|
+
dispose() {
|
|
339
|
+
this.disposePromise ??= (async () => {
|
|
340
|
+
this.remoteCatalogUnsubscribe?.();
|
|
341
|
+
this.remoteCatalogUnsubscribe = undefined;
|
|
342
|
+
const previous = this.operations;
|
|
343
|
+
this.operations = undefined;
|
|
344
|
+
await previous?.dispose?.();
|
|
345
|
+
})();
|
|
346
|
+
return this.disposePromise;
|
|
347
|
+
}
|
|
348
|
+
async replaceOperations(next) {
|
|
349
|
+
if (this.disposePromise) {
|
|
350
|
+
await next.dispose?.();
|
|
351
|
+
throw new Error("Deferred remote backend is disposed");
|
|
352
|
+
}
|
|
353
|
+
const previous = this.operations;
|
|
354
|
+
this.remoteCatalogUnsubscribe?.();
|
|
355
|
+
this.remoteCatalogUnsubscribe = undefined;
|
|
356
|
+
this.operations = next;
|
|
357
|
+
this.cwd = next.cwd;
|
|
358
|
+
this.remoteCatalogUnsubscribe = next.onWorkspaceToolCatalogChanged(() => Promise.all([...this.catalogListeners].map((listener) => listener())).then(() => undefined));
|
|
359
|
+
await previous?.dispose?.();
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
function isRecord(value) {
|
|
363
|
+
return typeof value === "object" && value !== null;
|
|
364
|
+
}
|
|
365
|
+
function requireRecord(value, label) {
|
|
366
|
+
if (!isRecord(value))
|
|
367
|
+
throw new Error(`Invalid remote workspace ${label}`);
|
|
368
|
+
return value;
|
|
369
|
+
}
|
|
370
|
+
function requireString(value, label) {
|
|
371
|
+
if (typeof value !== "string")
|
|
372
|
+
throw new Error(`Invalid remote workspace ${label}`);
|
|
373
|
+
return value;
|
|
374
|
+
}
|
|
375
|
+
function normalizeRemoteUrl(url) {
|
|
376
|
+
const parsed = new URL(url);
|
|
377
|
+
if (parsed.protocol !== "ws:" && parsed.protocol !== "wss:") {
|
|
378
|
+
throw new Error(`--remote supports ws:// and wss:// URLs, got ${parsed.protocol}`);
|
|
379
|
+
}
|
|
380
|
+
if (parsed.username || parsed.password)
|
|
381
|
+
throw new Error("Remote workspace URLs must not contain credentials");
|
|
382
|
+
if (parsed.hash)
|
|
383
|
+
throw new Error("Remote workspace URLs must not contain fragments");
|
|
384
|
+
return { url: parsed.toString(), protocol: "ws" };
|
|
385
|
+
}
|
|
386
|
+
function websocketPayload(data) {
|
|
387
|
+
if (Buffer.isBuffer(data))
|
|
388
|
+
return Uint8Array.from(data);
|
|
389
|
+
if (Array.isArray(data))
|
|
390
|
+
return Uint8Array.from(Buffer.concat(data));
|
|
391
|
+
return Uint8Array.from(new Uint8Array(data));
|
|
392
|
+
}
|
|
393
|
+
function websocketCloseCode(reason) {
|
|
394
|
+
switch (reason.code) {
|
|
395
|
+
case "normal":
|
|
396
|
+
return 1000;
|
|
397
|
+
case "protocol_error":
|
|
398
|
+
return 1002;
|
|
399
|
+
case "invalid_payload":
|
|
400
|
+
return 1007;
|
|
401
|
+
case "policy_violation":
|
|
402
|
+
return 1008;
|
|
403
|
+
case "message_too_large":
|
|
404
|
+
return 1009;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
export class RemoteToolOperations {
|
|
408
|
+
url;
|
|
409
|
+
protocol;
|
|
410
|
+
cwd;
|
|
411
|
+
workspacePathFlavor = "posix";
|
|
412
|
+
workspaceId = "";
|
|
413
|
+
socket;
|
|
414
|
+
isShared;
|
|
415
|
+
client;
|
|
416
|
+
localToolSchemas = new Map();
|
|
417
|
+
catalogListeners = new Set();
|
|
418
|
+
remoteLspStatus = { enabled: false, servers: [] };
|
|
419
|
+
disconnected = false;
|
|
420
|
+
disposePromise;
|
|
421
|
+
constructor(url, protocol, socket, options) {
|
|
422
|
+
this.url = url;
|
|
423
|
+
this.protocol = protocol;
|
|
424
|
+
this.socket = socket;
|
|
425
|
+
this.isShared = socket instanceof GuestSharedClientTransport;
|
|
426
|
+
this.cwd = "/";
|
|
427
|
+
const transport = socket instanceof GuestSharedClientTransport
|
|
428
|
+
? socket
|
|
429
|
+
: {
|
|
430
|
+
send: (message) => new Promise((resolve, reject) => {
|
|
431
|
+
if (socket.readyState !== WebSocket.OPEN) {
|
|
432
|
+
reject(new Error("Remote workspace connection is not open"));
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
socket.send(JSON.stringify(message), { binary: false, compress: false }, (error) => {
|
|
436
|
+
if (error)
|
|
437
|
+
reject(error);
|
|
438
|
+
else
|
|
439
|
+
resolve();
|
|
440
|
+
});
|
|
441
|
+
}),
|
|
442
|
+
close: (reason) => {
|
|
443
|
+
if (socket.readyState === WebSocket.CLOSED)
|
|
444
|
+
return Promise.resolve();
|
|
445
|
+
return new Promise((resolve) => {
|
|
446
|
+
socket.once("close", () => resolve());
|
|
447
|
+
socket.close(websocketCloseCode(reason), reason.message);
|
|
448
|
+
});
|
|
449
|
+
},
|
|
450
|
+
};
|
|
451
|
+
this.client = new RemoteWorkspaceClientProtocol(transport, {
|
|
452
|
+
requiredCapabilities: ["primitive_operations", "tool_updates"],
|
|
453
|
+
optionalCapabilities: this.isShared
|
|
454
|
+
? ["catalog_refresh", "artifacts", "lsp_status"]
|
|
455
|
+
: ["catalog_refresh", "file_transfer", "artifacts", "lsp_status"],
|
|
456
|
+
receiveLimits: DEFAULT_REMOTE_WORKSPACE_PROTOCOL_LIMITS,
|
|
457
|
+
localToolSchemas: this.localToolSchemas,
|
|
458
|
+
handshakeTimeoutMs: options.handshakeTimeoutMs,
|
|
459
|
+
onDisconnect: (message) => {
|
|
460
|
+
this.disconnected = true;
|
|
461
|
+
options.onDisconnect?.(message);
|
|
462
|
+
},
|
|
463
|
+
onCatalogRefreshed: async () => {
|
|
464
|
+
await this.refreshRemoteLspStatus();
|
|
465
|
+
await Promise.all([...this.catalogListeners].map((listener) => listener()));
|
|
466
|
+
},
|
|
467
|
+
});
|
|
468
|
+
if (socket instanceof GuestSharedClientTransport) {
|
|
469
|
+
socket.bind(this.client);
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
socket.on("message", (data, isBinary) => {
|
|
473
|
+
if (isBinary) {
|
|
474
|
+
void this.client.disconnect("Remote workspace sent an unexpected binary frame");
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
void this.client.receive(websocketPayload(data)).catch(() => undefined);
|
|
478
|
+
});
|
|
479
|
+
socket.on("close", () => void this.client.disconnect("Remote workspace connection closed"));
|
|
480
|
+
socket.on("error", () => void this.client.disconnect("Remote workspace connection failed"));
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
static async connect(url, options = {}) {
|
|
484
|
+
const normalized = normalizeRemoteUrl(url);
|
|
485
|
+
const token = options.token ?? process.env.GRIP_REMOTE_TOKEN;
|
|
486
|
+
const socket = await new Promise((resolve, reject) => {
|
|
487
|
+
const websocket = new WebSocket(normalized.url, DAEMON_WEBSOCKET_PROTOCOL, {
|
|
488
|
+
perMessageDeflate: false,
|
|
489
|
+
...(token ? { headers: { authorization: `Bearer ${token}` } } : {}),
|
|
490
|
+
});
|
|
491
|
+
const cleanup = () => {
|
|
492
|
+
websocket.off("open", onOpen);
|
|
493
|
+
websocket.off("error", onError);
|
|
494
|
+
};
|
|
495
|
+
const onOpen = () => {
|
|
496
|
+
cleanup();
|
|
497
|
+
resolve(websocket);
|
|
498
|
+
};
|
|
499
|
+
const onError = () => {
|
|
500
|
+
cleanup();
|
|
501
|
+
websocket.terminate();
|
|
502
|
+
reject(new Error(`Failed to connect remote workspace: ${normalized.url}`));
|
|
503
|
+
};
|
|
504
|
+
websocket.once("open", onOpen);
|
|
505
|
+
websocket.once("error", onError);
|
|
506
|
+
});
|
|
507
|
+
const operations = new RemoteToolOperations(normalized.url, normalized.protocol, socket, options);
|
|
508
|
+
try {
|
|
509
|
+
const handshake = await operations.client.start();
|
|
510
|
+
operations.cwd = handshake.workspace.root;
|
|
511
|
+
operations.workspacePathFlavor = handshake.workspace.pathFlavor;
|
|
512
|
+
operations.workspaceId = handshake.workspace.id;
|
|
513
|
+
await operations.refreshRemoteLspStatus();
|
|
514
|
+
return operations;
|
|
515
|
+
}
|
|
516
|
+
catch (error) {
|
|
517
|
+
socket.terminate();
|
|
518
|
+
throw error;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
static async connectGuestShared(url, root, token, options = {}) {
|
|
522
|
+
const socket = await GuestSharedClientTransport.attach(url, root, token);
|
|
523
|
+
const operations = new RemoteToolOperations(url, "ws", socket, options);
|
|
524
|
+
try {
|
|
525
|
+
const handshake = await operations.client.start();
|
|
526
|
+
if (!workspaceRootsEqual(handshake.workspace.root, root, handshake.workspace.pathFlavor)) {
|
|
527
|
+
throw new Error("Guest shared workspace root differs from daemon handshake");
|
|
528
|
+
}
|
|
529
|
+
operations.cwd = handshake.workspace.root;
|
|
530
|
+
operations.workspacePathFlavor = handshake.workspace.pathFlavor;
|
|
531
|
+
operations.workspaceId = handshake.workspace.id;
|
|
532
|
+
await operations.refreshRemoteLspStatus();
|
|
533
|
+
return operations;
|
|
534
|
+
}
|
|
535
|
+
catch (error) {
|
|
536
|
+
await socket.close({ code: "normal", message: "Shared guest attach failed" });
|
|
537
|
+
throw error;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
resolveWorkspaceToolExecution(name, parameterSchema) {
|
|
541
|
+
const schemaHash = hashRemoteWorkspaceJson(parameterSchema);
|
|
542
|
+
const catalogTool = this.client.handshake?.catalog.tools.find((tool) => tool.name === name);
|
|
543
|
+
if (!catalogTool)
|
|
544
|
+
return "unavailable";
|
|
545
|
+
if (catalogTool.schemaHash !== schemaHash) {
|
|
546
|
+
throw new Error(`Remote tool schema does not match the local canonical definition: ${name}`);
|
|
547
|
+
}
|
|
548
|
+
this.localToolSchemas.set(name, schemaHash);
|
|
549
|
+
this.client.setLocalToolSchemas(this.localToolSchemas);
|
|
550
|
+
return "remote";
|
|
551
|
+
}
|
|
552
|
+
async executeWorkspaceTool(name, invocation) {
|
|
553
|
+
const invoke = async () => {
|
|
554
|
+
await this.client.waitForCatalogRefresh();
|
|
555
|
+
const handshake = this.client.handshake;
|
|
556
|
+
if (!handshake)
|
|
557
|
+
throw new Error("Remote workspace protocol handshake is unavailable");
|
|
558
|
+
const catalogTool = handshake.catalog.tools.find((tool) => tool.name === name);
|
|
559
|
+
const schemaHash = this.localToolSchemas.get(name);
|
|
560
|
+
if (!catalogTool || !schemaHash || catalogTool.schemaHash !== schemaHash) {
|
|
561
|
+
throw new Error(`Remote tool is unavailable or has schema drift: ${name}`);
|
|
562
|
+
}
|
|
563
|
+
const expectedRevision = await this.revisionForTool(name, invocation);
|
|
564
|
+
const result = requireRecord(await this.client.request("tool.invoke", {
|
|
565
|
+
generation: handshake.catalog.generation,
|
|
566
|
+
catalogHash: handshake.catalogHash,
|
|
567
|
+
toolName: name,
|
|
568
|
+
schemaHash,
|
|
569
|
+
argumentsPrepared: true,
|
|
570
|
+
arguments: invocation.arguments,
|
|
571
|
+
...(expectedRevision ? { expectedRevision } : {}),
|
|
572
|
+
executionOptions: invocation.executionOptions,
|
|
573
|
+
}, {
|
|
574
|
+
signal: invocation.signal,
|
|
575
|
+
onUpdate: invocation.onUpdate
|
|
576
|
+
? (update) => invocation.onUpdate(parseRemoteWorkspaceToolResult(update))
|
|
577
|
+
: undefined,
|
|
578
|
+
}), "tool result");
|
|
579
|
+
const toolResult = result;
|
|
580
|
+
if (!Array.isArray(toolResult.content))
|
|
581
|
+
throw new Error("Invalid remote workspace tool result content");
|
|
582
|
+
if (name.startsWith("lsp_"))
|
|
583
|
+
await this.refreshRemoteLspStatus().catch(() => undefined);
|
|
584
|
+
return {
|
|
585
|
+
content: toolResult.content,
|
|
586
|
+
details: toolResult.details,
|
|
587
|
+
...(typeof toolResult.terminate === "boolean" ? { terminate: toolResult.terminate } : {}),
|
|
588
|
+
};
|
|
589
|
+
};
|
|
590
|
+
try {
|
|
591
|
+
return await invoke();
|
|
592
|
+
}
|
|
593
|
+
catch (error) {
|
|
594
|
+
if (error instanceof RemoteWorkspaceRequestError &&
|
|
595
|
+
error.code === "stale_generation" &&
|
|
596
|
+
error.executionState === "not_started") {
|
|
597
|
+
return invoke();
|
|
598
|
+
}
|
|
599
|
+
throw error;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
getRemoteLspStatus() {
|
|
603
|
+
return structuredClone(this.remoteLspStatus);
|
|
604
|
+
}
|
|
605
|
+
onWorkspaceToolCatalogChanged(listener) {
|
|
606
|
+
this.catalogListeners.add(listener);
|
|
607
|
+
return () => this.catalogListeners.delete(listener);
|
|
608
|
+
}
|
|
609
|
+
async refreshRemoteLspStatus() {
|
|
610
|
+
if (!this.client.handshake?.catalog.operations.includes("lsp.status")) {
|
|
611
|
+
this.remoteLspStatus = { enabled: false, servers: [] };
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
this.remoteLspStatus = (await this.client.request("lsp.status", {}));
|
|
615
|
+
}
|
|
616
|
+
request(method, params) {
|
|
617
|
+
return this.client.request(method, params);
|
|
618
|
+
}
|
|
619
|
+
async revisionForTool(name, invocation) {
|
|
620
|
+
if (!this.isShared || (name !== "edit" && name !== "write"))
|
|
621
|
+
return undefined;
|
|
622
|
+
const path = requireString(requireRecord(invocation.arguments, "shared mutation arguments").path, "shared mutation path");
|
|
623
|
+
return this.sharedExpectedRevision(path, invocation.signal, name === "write");
|
|
624
|
+
}
|
|
625
|
+
/** Observe exact bytes for CAS, or a daemon-confirmed absent target for creation. */
|
|
626
|
+
async sharedExpectedRevision(path, signal, allowAbsent = true) {
|
|
627
|
+
let read;
|
|
628
|
+
try {
|
|
629
|
+
read = await this.client.request("workspace.read", { path }, { signal });
|
|
630
|
+
}
|
|
631
|
+
catch (error) {
|
|
632
|
+
if (!allowAbsent)
|
|
633
|
+
throw error;
|
|
634
|
+
// Do not infer absence from an error message: only a v2 server stat of the
|
|
635
|
+
// same workspace and path may establish the expected-absent precondition.
|
|
636
|
+
const stat = requireRecord(await this.client.request("workspace.stat", { path }, { signal }), "shared stat result");
|
|
637
|
+
if (stat.kind !== "absent")
|
|
638
|
+
throw error;
|
|
639
|
+
return { absent: true };
|
|
640
|
+
}
|
|
641
|
+
const result = requireRecord(read, "shared read result");
|
|
642
|
+
const content = decodeCanonicalBase64(requireString(result.contentBase64, "shared read content"), Number.MAX_SAFE_INTEGER);
|
|
643
|
+
const sha256 = createHash("sha256").update(content).digest("hex");
|
|
644
|
+
if (result.revision !== sha256)
|
|
645
|
+
throw new Error("Shared daemon did not confirm the observed file revision");
|
|
646
|
+
return { sha256 };
|
|
647
|
+
}
|
|
648
|
+
async exec(command, options) {
|
|
649
|
+
const result = requireRecord(await this.client.request("workspace.exec", { command, cwd: options.cwd ?? this.cwd }, {
|
|
650
|
+
signal: options.signal,
|
|
651
|
+
timeoutMs: options.timeout === undefined ? undefined : Math.round(options.timeout * 1000),
|
|
652
|
+
onUpdate: (update) => {
|
|
653
|
+
const record = requireRecord(update, "exec update");
|
|
654
|
+
options.onData(decodeCanonicalBase64(requireString(record.dataBase64, "exec update data"), 1024 * 1024));
|
|
655
|
+
},
|
|
656
|
+
}), "exec result");
|
|
657
|
+
return { exitCode: typeof result.exitCode === "number" ? result.exitCode : null };
|
|
658
|
+
}
|
|
659
|
+
async access(path, mode) {
|
|
660
|
+
await this.request("workspace.access", { path, ...(mode ? { mode } : {}) });
|
|
661
|
+
}
|
|
662
|
+
async readFile(path) {
|
|
663
|
+
const result = requireRecord(await this.request("workspace.read", { path }), "read result");
|
|
664
|
+
return decodeCanonicalBase64(requireString(result.contentBase64, "read content"), Number.MAX_SAFE_INTEGER);
|
|
665
|
+
}
|
|
666
|
+
async writeFile(path, content) {
|
|
667
|
+
const expectedRevision = this.isShared ? await this.sharedExpectedRevision(path) : undefined;
|
|
668
|
+
await this.request("workspace.write", {
|
|
669
|
+
path,
|
|
670
|
+
contentBase64: Buffer.from(content).toString("base64"),
|
|
671
|
+
...(expectedRevision ? { expectedRevision } : {}),
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
async readResource(path) {
|
|
675
|
+
if (!this.client.handshake?.catalog.operations.includes("resource.read")) {
|
|
676
|
+
throw new Error("Remote workspace does not expose resource reads");
|
|
677
|
+
}
|
|
678
|
+
const result = requireRecord(await this.request("resource.read", { path }), "resource read result");
|
|
679
|
+
return decodeCanonicalBase64(requireString(result.contentBase64, "resource read content"), Number.MAX_SAFE_INTEGER);
|
|
680
|
+
}
|
|
681
|
+
async uploadFile(sourcePath, destinationPath) {
|
|
682
|
+
if (this.isShared)
|
|
683
|
+
throw new Error("Shared guest file transfers are unavailable");
|
|
684
|
+
const content = await fsReadFile(sourcePath);
|
|
685
|
+
const sha256 = createHash("sha256").update(content).digest("hex");
|
|
686
|
+
const handle = this.client.beginRequest("transfer.upload", {
|
|
687
|
+
path: destinationPath,
|
|
688
|
+
length: content.byteLength,
|
|
689
|
+
sha256,
|
|
690
|
+
overwrite: true,
|
|
691
|
+
});
|
|
692
|
+
const chunkBytes = this.client.handshake?.limits.maxTransferChunkBytes ?? 64 * 1024;
|
|
693
|
+
for (let offset = 0; offset < content.byteLength; offset += chunkBytes) {
|
|
694
|
+
await handle.sendTransferChunk(content.subarray(offset, Math.min(offset + chunkBytes, content.byteLength)));
|
|
695
|
+
}
|
|
696
|
+
await handle.finishTransfer(content.byteLength, sha256);
|
|
697
|
+
await handle.result;
|
|
698
|
+
}
|
|
699
|
+
async downloadFile(sourcePath, destinationPath) {
|
|
700
|
+
if (this.isShared)
|
|
701
|
+
throw new Error("Shared guest file transfers are unavailable");
|
|
702
|
+
const stream = createWriteStream(destinationPath);
|
|
703
|
+
try {
|
|
704
|
+
await this.client.request("transfer.download", { path: sourcePath }, {
|
|
705
|
+
onTransferChunk: (chunk) => writeStreamChunk(stream, chunk),
|
|
706
|
+
});
|
|
707
|
+
await endWriteStream(stream);
|
|
708
|
+
}
|
|
709
|
+
catch (error) {
|
|
710
|
+
stream.destroy();
|
|
711
|
+
throw error;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
async mkdir(path, options = {}) {
|
|
715
|
+
await this.request("workspace.mkdir", { path, recursive: options.recursive ?? false });
|
|
716
|
+
}
|
|
717
|
+
async stat(path) {
|
|
718
|
+
const result = requireRecord(await this.request("workspace.stat", { path }), "stat result");
|
|
719
|
+
if (result.kind === "absent")
|
|
720
|
+
throw new Error(`Remote workspace path does not exist: ${path}`);
|
|
721
|
+
return {
|
|
722
|
+
isDirectory: () => result.kind === "directory",
|
|
723
|
+
isFile: () => result.kind === "file",
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
async readdir(path) {
|
|
727
|
+
const result = requireRecord(await this.request("workspace.readdir", { path }), "readdir result");
|
|
728
|
+
if (!Array.isArray(result.entries) || !result.entries.every((entry) => typeof entry === "string")) {
|
|
729
|
+
throw new Error("Invalid remote workspace readdir entries");
|
|
730
|
+
}
|
|
731
|
+
return result.entries;
|
|
732
|
+
}
|
|
733
|
+
async glob(pattern, cwd, options) {
|
|
734
|
+
const result = requireRecord(await this.request("workspace.glob", { pattern, cwd, ignore: options.ignore, limit: options.limit }), "glob result");
|
|
735
|
+
if (!Array.isArray(result.matches) || !result.matches.every((entry) => typeof entry === "string")) {
|
|
736
|
+
throw new Error("Invalid remote workspace glob matches");
|
|
737
|
+
}
|
|
738
|
+
return result.matches;
|
|
739
|
+
}
|
|
740
|
+
async grep(options) {
|
|
741
|
+
const result = requireRecord(await this.request("workspace.grep", options), "grep result");
|
|
742
|
+
if (!Array.isArray(result.matches))
|
|
743
|
+
throw new Error("Invalid remote workspace grep matches");
|
|
744
|
+
return {
|
|
745
|
+
isDirectory: result.isDirectory === true,
|
|
746
|
+
matches: result.matches.map((entry) => {
|
|
747
|
+
const match = requireRecord(entry, "grep match");
|
|
748
|
+
return {
|
|
749
|
+
filePath: requireString(match.filePath, "grep file path"),
|
|
750
|
+
lineNumber: typeof match.lineNumber === "number" ? match.lineNumber : 0,
|
|
751
|
+
...(typeof match.lineText === "string" ? { lineText: match.lineText } : {}),
|
|
752
|
+
};
|
|
753
|
+
}),
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
async detectImageMimeType(path) {
|
|
757
|
+
const result = requireRecord(await this.request("workspace.detect_image_mime", { path }), "image MIME result");
|
|
758
|
+
return typeof result.mimeType === "string" ? result.mimeType : null;
|
|
759
|
+
}
|
|
760
|
+
getBackendInfo() {
|
|
761
|
+
return {
|
|
762
|
+
type: "remote",
|
|
763
|
+
cwd: this.cwd,
|
|
764
|
+
url: this.url,
|
|
765
|
+
protocol: this.protocol,
|
|
766
|
+
configured: true,
|
|
767
|
+
workspace: { id: this.workspaceId, root: this.cwd, pathFlavor: this.workspacePathFlavor },
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
isDisconnected() {
|
|
771
|
+
return this.disconnected;
|
|
772
|
+
}
|
|
773
|
+
dispose() {
|
|
774
|
+
this.disposePromise ??= this.client.close().catch(() => {
|
|
775
|
+
if (this.socket instanceof WebSocket)
|
|
776
|
+
this.socket.terminate();
|
|
777
|
+
});
|
|
778
|
+
return this.disposePromise;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
export function createRemoteToolOperations(url, options) {
|
|
782
|
+
if (url.startsWith("grip+ws:")) {
|
|
783
|
+
const parsed = new URL(url.replace(/^grip\+/, ""));
|
|
784
|
+
const root = parsed.searchParams.get("root");
|
|
785
|
+
if (!root || !posix.isAbsolute(root) || parsed.searchParams.size !== 1 || !options?.token) {
|
|
786
|
+
return Promise.reject(new Error("Invalid guest shared workspace attachment"));
|
|
787
|
+
}
|
|
788
|
+
parsed.search = "";
|
|
789
|
+
return RemoteToolOperations.connectGuestShared(parsed.toString(), root, options.token, options);
|
|
790
|
+
}
|
|
791
|
+
return RemoteToolOperations.connect(url, options);
|
|
792
|
+
}
|
|
793
|
+
//# sourceMappingURL=operations.js.map
|