@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,224 @@
|
|
|
1
|
+
import { validateSessionId } from "./ids.js";
|
|
2
|
+
export class RemoteSessionClientError extends Error {
|
|
3
|
+
status;
|
|
4
|
+
responseText;
|
|
5
|
+
constructor(status, responseText) {
|
|
6
|
+
super(`Remote session request failed with status ${status}: ${responseText}`);
|
|
7
|
+
this.name = "RemoteSessionClientError";
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.responseText = responseText;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export class RemoteSessionProtocolError extends Error {
|
|
13
|
+
operation;
|
|
14
|
+
constructor(operation, message, cause) {
|
|
15
|
+
super(`Invalid remote session ${operation} response: ${message}`, { cause });
|
|
16
|
+
this.name = "RemoteSessionProtocolError";
|
|
17
|
+
this.operation = operation;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function isRecord(value) {
|
|
21
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22
|
+
}
|
|
23
|
+
function requiredString(record, key, operation) {
|
|
24
|
+
const value = record[key];
|
|
25
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
26
|
+
throw new RemoteSessionProtocolError(operation, `${key} must be a non-empty string`);
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
function stringValue(record, key, operation) {
|
|
31
|
+
const value = record[key];
|
|
32
|
+
if (typeof value !== "string") {
|
|
33
|
+
throw new RemoteSessionProtocolError(operation, `${key} must be a string`);
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
function requiredSessionId(record, operation) {
|
|
38
|
+
const id = requiredString(record, "id", operation);
|
|
39
|
+
try {
|
|
40
|
+
validateSessionId(id);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
throw new RemoteSessionProtocolError(operation, "id is not a valid session id", error);
|
|
44
|
+
}
|
|
45
|
+
return id;
|
|
46
|
+
}
|
|
47
|
+
function optionalString(record, key, operation) {
|
|
48
|
+
const value = record[key];
|
|
49
|
+
if (value === undefined)
|
|
50
|
+
return undefined;
|
|
51
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
52
|
+
throw new RemoteSessionProtocolError(operation, `${key} must be a non-empty string when present`);
|
|
53
|
+
}
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
function decodeSnapshot(value, operation, expectedId) {
|
|
57
|
+
if (!isRecord(value))
|
|
58
|
+
throw new RemoteSessionProtocolError(operation, "snapshot must be an object");
|
|
59
|
+
const id = requiredSessionId(value, operation);
|
|
60
|
+
const reference = requiredString(value, "reference", operation);
|
|
61
|
+
if (parseRemoteSessionId(reference) !== id) {
|
|
62
|
+
throw new RemoteSessionProtocolError(operation, `reference ${reference} does not identify snapshot id ${id}`);
|
|
63
|
+
}
|
|
64
|
+
if (expectedId !== undefined && id !== expectedId) {
|
|
65
|
+
throw new RemoteSessionProtocolError(operation, `snapshot id ${id} does not match requested id ${expectedId}`);
|
|
66
|
+
}
|
|
67
|
+
if (!Array.isArray(value.entries) || value.entries.length === 0 || value.entries.some((entry) => !isRecord(entry))) {
|
|
68
|
+
throw new RemoteSessionProtocolError(operation, "entries must be a non-empty array of objects");
|
|
69
|
+
}
|
|
70
|
+
const header = value.entries[0];
|
|
71
|
+
if (!isRecord(header) ||
|
|
72
|
+
header.type !== "session" ||
|
|
73
|
+
header.id !== id ||
|
|
74
|
+
typeof header.cwd !== "string" ||
|
|
75
|
+
typeof header.timestamp !== "string") {
|
|
76
|
+
throw new RemoteSessionProtocolError(operation, "entries must begin with a matching session header");
|
|
77
|
+
}
|
|
78
|
+
const version = value.version;
|
|
79
|
+
if (version !== undefined &&
|
|
80
|
+
(typeof version !== "number" || !Number.isInteger(version) || version < 1 || version !== header.version)) {
|
|
81
|
+
throw new RemoteSessionProtocolError(operation, "version must be a positive integer matching the session header");
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
reference,
|
|
85
|
+
id,
|
|
86
|
+
version: version,
|
|
87
|
+
entries: value.entries,
|
|
88
|
+
etag: optionalString(value, "etag", operation),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function decodeForkSnapshot(value, sourceId) {
|
|
92
|
+
const snapshot = decodeSnapshot(value, "fork");
|
|
93
|
+
if (snapshot.id === sourceId) {
|
|
94
|
+
throw new RemoteSessionProtocolError("fork", "fork snapshot must have a new session id");
|
|
95
|
+
}
|
|
96
|
+
const header = snapshot.entries[0];
|
|
97
|
+
if (header?.type !== "session" || !header.parentSession || parseRemoteSessionId(header.parentSession) !== sourceId) {
|
|
98
|
+
throw new RemoteSessionProtocolError("fork", `fork header must reference source session ${sourceId}`);
|
|
99
|
+
}
|
|
100
|
+
return snapshot;
|
|
101
|
+
}
|
|
102
|
+
function decodeAppendResponse(value) {
|
|
103
|
+
const operation = "append";
|
|
104
|
+
if (!isRecord(value))
|
|
105
|
+
throw new RemoteSessionProtocolError(operation, "response must be an object");
|
|
106
|
+
if (!Number.isInteger(value.accepted)) {
|
|
107
|
+
throw new RemoteSessionProtocolError(operation, "accepted must be an integer");
|
|
108
|
+
}
|
|
109
|
+
return { accepted: value.accepted, etag: optionalString(value, "etag", operation) };
|
|
110
|
+
}
|
|
111
|
+
function decodeReplaceResponse(value) {
|
|
112
|
+
const operation = "replace";
|
|
113
|
+
if (!isRecord(value))
|
|
114
|
+
throw new RemoteSessionProtocolError(operation, "response must be an object");
|
|
115
|
+
return { etag: optionalString(value, "etag", operation) };
|
|
116
|
+
}
|
|
117
|
+
function decodeSessionInfo(value) {
|
|
118
|
+
const operation = "list";
|
|
119
|
+
if (!isRecord(value))
|
|
120
|
+
throw new RemoteSessionProtocolError(operation, "each session must be an object");
|
|
121
|
+
const id = requiredSessionId(value, operation);
|
|
122
|
+
const reference = optionalString(value, "reference", operation);
|
|
123
|
+
const path = optionalString(value, "path", operation);
|
|
124
|
+
for (const candidate of [reference, path]) {
|
|
125
|
+
if (candidate !== undefined && parseRemoteSessionId(candidate) !== id) {
|
|
126
|
+
throw new RemoteSessionProtocolError(operation, `reference ${candidate} does not identify session id ${id}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const created = requiredString(value, "created", operation);
|
|
130
|
+
const modified = requiredString(value, "modified", operation);
|
|
131
|
+
if (!Number.isFinite(Date.parse(created)) || !Number.isFinite(Date.parse(modified))) {
|
|
132
|
+
throw new RemoteSessionProtocolError(operation, "created and modified must be valid date strings");
|
|
133
|
+
}
|
|
134
|
+
if (!Number.isInteger(value.messageCount) || value.messageCount < 0) {
|
|
135
|
+
throw new RemoteSessionProtocolError(operation, "messageCount must be a non-negative integer");
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
reference,
|
|
139
|
+
path,
|
|
140
|
+
id,
|
|
141
|
+
cwd: stringValue(value, "cwd", operation),
|
|
142
|
+
name: optionalString(value, "name", operation),
|
|
143
|
+
parentSessionPath: optionalString(value, "parentSessionPath", operation),
|
|
144
|
+
created,
|
|
145
|
+
modified,
|
|
146
|
+
messageCount: value.messageCount,
|
|
147
|
+
firstMessage: stringValue(value, "firstMessage", operation),
|
|
148
|
+
allMessagesText: stringValue(value, "allMessagesText", operation),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function decodeListResponse(value) {
|
|
152
|
+
if (!isRecord(value) || !Array.isArray(value.sessions)) {
|
|
153
|
+
throw new RemoteSessionProtocolError("list", "sessions must be an array");
|
|
154
|
+
}
|
|
155
|
+
return { sessions: value.sessions.map((session) => decodeSessionInfo(session)) };
|
|
156
|
+
}
|
|
157
|
+
export class RemoteSessionClient {
|
|
158
|
+
baseUrl;
|
|
159
|
+
token;
|
|
160
|
+
fetchImpl;
|
|
161
|
+
constructor(options) {
|
|
162
|
+
this.baseUrl = options.baseUrl.replace(/\/+$/, "");
|
|
163
|
+
this.token = options.token;
|
|
164
|
+
this.fetchImpl = options.fetch ?? fetch;
|
|
165
|
+
}
|
|
166
|
+
createSession(request) {
|
|
167
|
+
return this.request("POST", "/v1/sessions", request, "create", (value) => decodeSnapshot(value, "create", request.id));
|
|
168
|
+
}
|
|
169
|
+
openSession(sessionIdOrReference) {
|
|
170
|
+
const id = parseRemoteSessionId(sessionIdOrReference);
|
|
171
|
+
return this.request("GET", `/v1/sessions/${encodeURIComponent(id)}`, undefined, "open", (value) => decodeSnapshot(value, "open", id));
|
|
172
|
+
}
|
|
173
|
+
appendEntries(sessionIdOrReference, request) {
|
|
174
|
+
return this.request("POST", `/v1/sessions/${encodeURIComponent(parseRemoteSessionId(sessionIdOrReference))}/entries`, request, "append", decodeAppendResponse);
|
|
175
|
+
}
|
|
176
|
+
replaceSnapshot(sessionIdOrReference, request) {
|
|
177
|
+
return this.request("PUT", `/v1/sessions/${encodeURIComponent(parseRemoteSessionId(sessionIdOrReference))}/snapshot`, request, "replace", decodeReplaceResponse);
|
|
178
|
+
}
|
|
179
|
+
listSessions() {
|
|
180
|
+
return this.request("GET", "/v1/sessions", undefined, "list", decodeListResponse);
|
|
181
|
+
}
|
|
182
|
+
getRecentSession() {
|
|
183
|
+
return this.request("GET", "/v1/sessions/recent", undefined, "recent", (value) => decodeSnapshot(value, "recent"));
|
|
184
|
+
}
|
|
185
|
+
forkSession(sessionIdOrReference, request) {
|
|
186
|
+
const sourceId = parseRemoteSessionId(sessionIdOrReference);
|
|
187
|
+
return this.request("POST", `/v1/sessions/${encodeURIComponent(sourceId)}/fork`, request, "fork", (value) => decodeForkSnapshot(value, sourceId));
|
|
188
|
+
}
|
|
189
|
+
importJsonl(request) {
|
|
190
|
+
return this.request("POST", "/v1/sessions/import-jsonl", request, "import", (value) => decodeSnapshot(value, "import"));
|
|
191
|
+
}
|
|
192
|
+
async request(method, path, body, operation, decode) {
|
|
193
|
+
const response = await this.fetchImpl(`${this.baseUrl}${path}`, {
|
|
194
|
+
method,
|
|
195
|
+
headers: {
|
|
196
|
+
Authorization: `Bearer ${this.token}`,
|
|
197
|
+
Accept: "application/json",
|
|
198
|
+
...(body === undefined ? {} : { "Content-Type": "application/json" }),
|
|
199
|
+
},
|
|
200
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
201
|
+
});
|
|
202
|
+
if (!response.ok) {
|
|
203
|
+
throw new RemoteSessionClientError(response.status, await response.text());
|
|
204
|
+
}
|
|
205
|
+
if (response.status === 204) {
|
|
206
|
+
throw new RemoteSessionProtocolError(operation, "response body is required");
|
|
207
|
+
}
|
|
208
|
+
let value;
|
|
209
|
+
try {
|
|
210
|
+
value = await response.json();
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
throw new RemoteSessionProtocolError(operation, "body is not valid JSON", error);
|
|
214
|
+
}
|
|
215
|
+
return decode(value);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
export function parseRemoteSessionId(reference) {
|
|
219
|
+
return reference.startsWith("remote:") ? reference.slice("remote:".length) : reference;
|
|
220
|
+
}
|
|
221
|
+
export function formatRemoteSessionReference(sessionId) {
|
|
222
|
+
return sessionId.startsWith("remote:") ? sessionId : `remote:${sessionId}`;
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=remote-session-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-session-client.js","sourceRoot":"","sources":["../../../src/core/session/remote-session-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAuE7C,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACzC,MAAM,CAAS;IACf,YAAY,CAAS;IAE9B,YAAY,MAAc,EAAE,YAAoB,EAAE;QACjD,KAAK,CAAC,6CAA6C,MAAM,KAAK,YAAY,EAAE,CAAC,CAAC;QAC9E,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,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AAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3D,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YAClB,MAAM,IAAI,wBAAwB,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5E,CAAC;QACD,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC7B,MAAM,IAAI,0BAA0B,CAAC,SAAS,EAAE,2BAA2B,CAAC,CAAC;QAC9E,CAAC;QAED,IAAI,KAAc,CAAC;QACnB,IAAI,CAAC;YACJ,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC/B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,0BAA0B,CAAC,SAAS,EAAE,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAClF,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IAAA,CACrB;CACD;AAED,MAAM,UAAU,oBAAoB,CAAC,SAAiB,EAAU;IAC/D,OAAO,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAAA,CACvF;AAED,MAAM,UAAU,4BAA4B,CAAC,SAAiB,EAAU;IACvE,OAAO,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,SAAS,EAAE,CAAC;AAAA,CAC3E","sourcesContent":["import { validateSessionId } from \"./ids.ts\";\nimport type { FileEntry, SessionInfo } from \"./types.ts\";\n\nexport type RemoteSessionInfo = Omit<SessionInfo, \"path\" | \"created\" | \"modified\"> & {\n\tpath?: string;\n\tcreated: Date | string;\n\tmodified: Date | string;\n};\n\nexport interface RemoteSessionClientOptions {\n\tbaseUrl: string;\n\ttoken: string;\n\tfetch?: typeof fetch;\n}\n\nexport interface RemoteSessionSnapshot {\n\treference: string;\n\tid: string;\n\tversion?: number;\n\tentries: FileEntry[];\n\tetag?: string;\n}\n\nexport interface CreateRemoteSessionRequest {\n\tid?: string;\n\tcwd: string;\n\tprojectId?: string;\n\tparentSession?: string;\n\tmetadata?: Record<string, unknown>;\n}\n\nexport interface AppendRemoteSessionEntriesRequest {\n\tbaseEtag?: string;\n\tentries: FileEntry[];\n}\n\nexport interface AppendRemoteSessionEntriesResponse {\n\tetag?: string;\n\taccepted: number;\n}\n\n// grip-ignore noNearIdenticalDataStructures: Snapshot replacement atomically rewrites complete state, while append applies incremental entries; their endpoint validation and concurrency contracts evolve independently.\nexport interface ReplaceRemoteSessionSnapshotRequest {\n\tbaseEtag?: string;\n\tentries: FileEntry[];\n}\n\nexport interface ReplaceRemoteSessionSnapshotResponse {\n\tetag?: string;\n}\n\nexport interface ForkRemoteSessionRequest {\n\tcwd: string;\n\tprojectId?: string;\n\tleafId?: string;\n}\n\nexport interface ImportRemoteSessionJsonlRequest {\n\tcwd: string;\n\tprojectId?: string;\n\tsourceName?: string;\n\tentries: FileEntry[];\n\tmetadata?: Record<string, unknown>;\n}\n\nexport interface ListRemoteSessionsResponse {\n\tsessions: RemoteSessionInfo[];\n}\n\nexport type RemoteSessionOperation = \"create\" | \"open\" | \"recent\" | \"fork\" | \"import\" | \"list\" | \"append\" | \"replace\";\n\nexport class RemoteSessionClientError extends Error {\n\treadonly status: number;\n\treadonly responseText: string;\n\n\tconstructor(status: number, responseText: string) {\n\t\tsuper(`Remote session request failed with status ${status}: ${responseText}`);\n\t\tthis.name = \"RemoteSessionClientError\";\n\t\tthis.status = status;\n\t\tthis.responseText = responseText;\n\t}\n}\n\nexport class RemoteSessionProtocolError extends Error {\n\treadonly operation: RemoteSessionOperation;\n\n\tconstructor(operation: RemoteSessionOperation, message: string, cause?: unknown) {\n\t\tsuper(`Invalid remote session ${operation} response: ${message}`, { cause });\n\t\tthis.name = \"RemoteSessionProtocolError\";\n\t\tthis.operation = operation;\n\t}\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction requiredString(record: Record<string, unknown>, key: string, operation: RemoteSessionOperation): string {\n\tconst value = record[key];\n\tif (typeof value !== \"string\" || value.length === 0) {\n\t\tthrow new RemoteSessionProtocolError(operation, `${key} must be a non-empty string`);\n\t}\n\treturn value;\n}\n\nfunction stringValue(record: Record<string, unknown>, key: string, operation: RemoteSessionOperation): string {\n\tconst value = record[key];\n\tif (typeof value !== \"string\") {\n\t\tthrow new RemoteSessionProtocolError(operation, `${key} must be a string`);\n\t}\n\treturn value;\n}\n\nfunction requiredSessionId(record: Record<string, unknown>, operation: RemoteSessionOperation): string {\n\tconst id = requiredString(record, \"id\", operation);\n\ttry {\n\t\tvalidateSessionId(id);\n\t} catch (error) {\n\t\tthrow new RemoteSessionProtocolError(operation, \"id is not a valid session id\", error);\n\t}\n\treturn id;\n}\n\nfunction optionalString(\n\trecord: Record<string, unknown>,\n\tkey: string,\n\toperation: RemoteSessionOperation,\n): string | undefined {\n\tconst value = record[key];\n\tif (value === undefined) return undefined;\n\tif (typeof value !== \"string\" || value.length === 0) {\n\t\tthrow new RemoteSessionProtocolError(operation, `${key} must be a non-empty string when present`);\n\t}\n\treturn value;\n}\n\nfunction decodeSnapshot(value: unknown, operation: RemoteSessionOperation, expectedId?: string): RemoteSessionSnapshot {\n\tif (!isRecord(value)) throw new RemoteSessionProtocolError(operation, \"snapshot must be an object\");\n\tconst id = requiredSessionId(value, operation);\n\tconst reference = requiredString(value, \"reference\", operation);\n\tif (parseRemoteSessionId(reference) !== id) {\n\t\tthrow new RemoteSessionProtocolError(operation, `reference ${reference} does not identify snapshot id ${id}`);\n\t}\n\tif (expectedId !== undefined && id !== expectedId) {\n\t\tthrow new RemoteSessionProtocolError(operation, `snapshot id ${id} does not match requested id ${expectedId}`);\n\t}\n\tif (!Array.isArray(value.entries) || value.entries.length === 0 || value.entries.some((entry) => !isRecord(entry))) {\n\t\tthrow new RemoteSessionProtocolError(operation, \"entries must be a non-empty array of objects\");\n\t}\n\tconst header = value.entries[0];\n\tif (\n\t\t!isRecord(header) ||\n\t\theader.type !== \"session\" ||\n\t\theader.id !== id ||\n\t\ttypeof header.cwd !== \"string\" ||\n\t\ttypeof header.timestamp !== \"string\"\n\t) {\n\t\tthrow new RemoteSessionProtocolError(operation, \"entries must begin with a matching session header\");\n\t}\n\tconst version = value.version;\n\tif (\n\t\tversion !== undefined &&\n\t\t(typeof version !== \"number\" || !Number.isInteger(version) || version < 1 || version !== header.version)\n\t) {\n\t\tthrow new RemoteSessionProtocolError(operation, \"version must be a positive integer matching the session header\");\n\t}\n\treturn {\n\t\treference,\n\t\tid,\n\t\tversion: version as number | undefined,\n\t\tentries: value.entries as FileEntry[],\n\t\tetag: optionalString(value, \"etag\", operation),\n\t};\n}\n\nfunction decodeForkSnapshot(value: unknown, sourceId: string): RemoteSessionSnapshot {\n\tconst snapshot = decodeSnapshot(value, \"fork\");\n\tif (snapshot.id === sourceId) {\n\t\tthrow new RemoteSessionProtocolError(\"fork\", \"fork snapshot must have a new session id\");\n\t}\n\tconst header = snapshot.entries[0];\n\tif (header?.type !== \"session\" || !header.parentSession || parseRemoteSessionId(header.parentSession) !== sourceId) {\n\t\tthrow new RemoteSessionProtocolError(\"fork\", `fork header must reference source session ${sourceId}`);\n\t}\n\treturn snapshot;\n}\n\nfunction decodeAppendResponse(value: unknown): AppendRemoteSessionEntriesResponse {\n\tconst operation = \"append\";\n\tif (!isRecord(value)) throw new RemoteSessionProtocolError(operation, \"response must be an object\");\n\tif (!Number.isInteger(value.accepted)) {\n\t\tthrow new RemoteSessionProtocolError(operation, \"accepted must be an integer\");\n\t}\n\treturn { accepted: value.accepted as number, etag: optionalString(value, \"etag\", operation) };\n}\n\nfunction decodeReplaceResponse(value: unknown): ReplaceRemoteSessionSnapshotResponse {\n\tconst operation = \"replace\";\n\tif (!isRecord(value)) throw new RemoteSessionProtocolError(operation, \"response must be an object\");\n\treturn { etag: optionalString(value, \"etag\", operation) };\n}\n\nfunction decodeSessionInfo(value: unknown): RemoteSessionInfo {\n\tconst operation = \"list\";\n\tif (!isRecord(value)) throw new RemoteSessionProtocolError(operation, \"each session must be an object\");\n\tconst id = requiredSessionId(value, operation);\n\tconst reference = optionalString(value, \"reference\", operation);\n\tconst path = optionalString(value, \"path\", operation);\n\tfor (const candidate of [reference, path]) {\n\t\tif (candidate !== undefined && parseRemoteSessionId(candidate) !== id) {\n\t\t\tthrow new RemoteSessionProtocolError(operation, `reference ${candidate} does not identify session id ${id}`);\n\t\t}\n\t}\n\tconst created = requiredString(value, \"created\", operation);\n\tconst modified = requiredString(value, \"modified\", operation);\n\tif (!Number.isFinite(Date.parse(created)) || !Number.isFinite(Date.parse(modified))) {\n\t\tthrow new RemoteSessionProtocolError(operation, \"created and modified must be valid date strings\");\n\t}\n\tif (!Number.isInteger(value.messageCount) || (value.messageCount as number) < 0) {\n\t\tthrow new RemoteSessionProtocolError(operation, \"messageCount must be a non-negative integer\");\n\t}\n\treturn {\n\t\treference,\n\t\tpath,\n\t\tid,\n\t\tcwd: stringValue(value, \"cwd\", operation),\n\t\tname: optionalString(value, \"name\", operation),\n\t\tparentSessionPath: optionalString(value, \"parentSessionPath\", operation),\n\t\tcreated,\n\t\tmodified,\n\t\tmessageCount: value.messageCount as number,\n\t\tfirstMessage: stringValue(value, \"firstMessage\", operation),\n\t\tallMessagesText: stringValue(value, \"allMessagesText\", operation),\n\t};\n}\n\nfunction decodeListResponse(value: unknown): ListRemoteSessionsResponse {\n\tif (!isRecord(value) || !Array.isArray(value.sessions)) {\n\t\tthrow new RemoteSessionProtocolError(\"list\", \"sessions must be an array\");\n\t}\n\treturn { sessions: value.sessions.map((session) => decodeSessionInfo(session)) };\n}\n\nexport class RemoteSessionClient {\n\tprivate readonly baseUrl: string;\n\tprivate readonly token: string;\n\tprivate readonly fetchImpl: typeof fetch;\n\n\tconstructor(options: RemoteSessionClientOptions) {\n\t\tthis.baseUrl = options.baseUrl.replace(/\\/+$/, \"\");\n\t\tthis.token = options.token;\n\t\tthis.fetchImpl = options.fetch ?? fetch;\n\t}\n\n\tcreateSession(request: CreateRemoteSessionRequest): Promise<RemoteSessionSnapshot> {\n\t\treturn this.request(\"POST\", \"/v1/sessions\", request, \"create\", (value) =>\n\t\t\tdecodeSnapshot(value, \"create\", request.id),\n\t\t);\n\t}\n\n\topenSession(sessionIdOrReference: string): Promise<RemoteSessionSnapshot> {\n\t\tconst id = parseRemoteSessionId(sessionIdOrReference);\n\t\treturn this.request(\"GET\", `/v1/sessions/${encodeURIComponent(id)}`, undefined, \"open\", (value) =>\n\t\t\tdecodeSnapshot(value, \"open\", id),\n\t\t);\n\t}\n\n\tappendEntries(\n\t\tsessionIdOrReference: string,\n\t\trequest: AppendRemoteSessionEntriesRequest,\n\t): Promise<AppendRemoteSessionEntriesResponse> {\n\t\treturn this.request(\n\t\t\t\"POST\",\n\t\t\t`/v1/sessions/${encodeURIComponent(parseRemoteSessionId(sessionIdOrReference))}/entries`,\n\t\t\trequest,\n\t\t\t\"append\",\n\t\t\tdecodeAppendResponse,\n\t\t);\n\t}\n\n\treplaceSnapshot(\n\t\tsessionIdOrReference: string,\n\t\trequest: ReplaceRemoteSessionSnapshotRequest,\n\t): Promise<ReplaceRemoteSessionSnapshotResponse> {\n\t\treturn this.request(\n\t\t\t\"PUT\",\n\t\t\t`/v1/sessions/${encodeURIComponent(parseRemoteSessionId(sessionIdOrReference))}/snapshot`,\n\t\t\trequest,\n\t\t\t\"replace\",\n\t\t\tdecodeReplaceResponse,\n\t\t);\n\t}\n\n\tlistSessions(): Promise<ListRemoteSessionsResponse> {\n\t\treturn this.request(\"GET\", \"/v1/sessions\", undefined, \"list\", decodeListResponse);\n\t}\n\n\tgetRecentSession(): Promise<RemoteSessionSnapshot> {\n\t\treturn this.request(\"GET\", \"/v1/sessions/recent\", undefined, \"recent\", (value) =>\n\t\t\tdecodeSnapshot(value, \"recent\"),\n\t\t);\n\t}\n\n\tforkSession(sessionIdOrReference: string, request: ForkRemoteSessionRequest): Promise<RemoteSessionSnapshot> {\n\t\tconst sourceId = parseRemoteSessionId(sessionIdOrReference);\n\t\treturn this.request(\"POST\", `/v1/sessions/${encodeURIComponent(sourceId)}/fork`, request, \"fork\", (value) =>\n\t\t\tdecodeForkSnapshot(value, sourceId),\n\t\t);\n\t}\n\n\timportJsonl(request: ImportRemoteSessionJsonlRequest): Promise<RemoteSessionSnapshot> {\n\t\treturn this.request(\"POST\", \"/v1/sessions/import-jsonl\", request, \"import\", (value) =>\n\t\t\tdecodeSnapshot(value, \"import\"),\n\t\t);\n\t}\n\n\tprivate async request<T>(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody: unknown,\n\t\toperation: RemoteSessionOperation,\n\t\tdecode: (value: unknown) => T,\n\t): Promise<T> {\n\t\tconst response = await this.fetchImpl(`${this.baseUrl}${path}`, {\n\t\t\tmethod,\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${this.token}`,\n\t\t\t\tAccept: \"application/json\",\n\t\t\t\t...(body === undefined ? {} : { \"Content-Type\": \"application/json\" }),\n\t\t\t},\n\t\t\tbody: body === undefined ? undefined : JSON.stringify(body),\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tthrow new RemoteSessionClientError(response.status, await response.text());\n\t\t}\n\t\tif (response.status === 204) {\n\t\t\tthrow new RemoteSessionProtocolError(operation, \"response body is required\");\n\t\t}\n\n\t\tlet value: unknown;\n\t\ttry {\n\t\t\tvalue = await response.json();\n\t\t} catch (error) {\n\t\t\tthrow new RemoteSessionProtocolError(operation, \"body is not valid JSON\", error);\n\t\t}\n\t\treturn decode(value);\n\t}\n}\n\nexport function parseRemoteSessionId(reference: string): string {\n\treturn reference.startsWith(\"remote:\") ? reference.slice(\"remote:\".length) : reference;\n}\n\nexport function formatRemoteSessionReference(sessionId: string): string {\n\treturn sessionId.startsWith(\"remote:\") ? sessionId : `remote:${sessionId}`;\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { RemoteSession } from "./remote-session.ts";
|
|
2
|
+
import type { Session } from "./session.ts";
|
|
3
|
+
import type { OpenSessionOptions, SessionManager } from "./session-manager.ts";
|
|
4
|
+
import type { NewSessionOptions, SessionInfo, SessionListProgress } from "./types.ts";
|
|
5
|
+
export interface RemoteSessionManagerOptions {
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
token: string;
|
|
8
|
+
cwd: string;
|
|
9
|
+
projectId?: string;
|
|
10
|
+
fetch?: typeof fetch;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Remote session manager skeleton.
|
|
14
|
+
*
|
|
15
|
+
* Lifecycle methods are async-compatible through SessionManager so this backend
|
|
16
|
+
* can fetch/create snapshots before returning an active Session.
|
|
17
|
+
*/
|
|
18
|
+
export declare class RemoteSessionManager implements SessionManager {
|
|
19
|
+
private readonly client;
|
|
20
|
+
private readonly cwd;
|
|
21
|
+
private readonly projectId;
|
|
22
|
+
constructor(options: RemoteSessionManagerOptions);
|
|
23
|
+
create(options?: NewSessionOptions): Promise<RemoteSession>;
|
|
24
|
+
openReference(reference: string, options?: OpenSessionOptions): Promise<RemoteSession>;
|
|
25
|
+
continueRecent(): Promise<RemoteSession>;
|
|
26
|
+
forkFrom(reference: string): Promise<RemoteSession>;
|
|
27
|
+
forkSession(source: Session, targetLeafId: string | null): Promise<RemoteSession>;
|
|
28
|
+
importJsonl(inputPath: string, options?: OpenSessionOptions): Promise<RemoteSession>;
|
|
29
|
+
list(_onProgress?: SessionListProgress): Promise<SessionInfo[]>;
|
|
30
|
+
listAll(_onProgress?: SessionListProgress): Promise<SessionInfo[]>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=remote-session-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-session-manager.d.ts","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AkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAqCzF;IAEK,IAAI,CAAC,WAAW,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAGpE;IAEK,OAAO,CAAC,WAAW,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAGvE;CACD","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { basename, resolve } from \"node:path\";\nimport type { JsonlErrorPhase } from \"./jsonl-errors.ts\";\nimport { createJsonlSessionDecodeError } from \"./jsonl-errors.ts\";\nimport { loadEntriesFromFile } from \"./jsonl-helpers.ts\";\nimport { migrateToCurrentVersion } from \"./migrations.ts\";\nimport { RemoteSession } from \"./remote-session.ts\";\nimport type { RemoteSessionInfo, RemoteSessionSnapshot } from \"./remote-session-client.ts\";\nimport { RemoteSessionClient } from \"./remote-session-client.ts\";\nimport type { Session } from \"./session.ts\";\nimport type { OpenSessionOptions, SessionManager } from \"./session-manager.ts\";\nimport { getJsonlEntryLocations, validateCurrentSessionEntries } from \"./stores/jsonl-session-store.ts\";\nimport type { NewSessionOptions, SessionHeader, SessionInfo, SessionListProgress } from \"./types.ts\";\n\nexport interface RemoteSessionManagerOptions {\n\tbaseUrl: string;\n\ttoken: string;\n\tcwd: string;\n\tprojectId?: string;\n\tfetch?: typeof fetch;\n}\n\nfunction getSnapshotCwd(snapshot: RemoteSessionSnapshot, fallback: string): string {\n\tconst header = snapshot.entries.find((entry) => entry.type === \"session\") as SessionHeader | undefined;\n\treturn typeof header?.cwd === \"string\" ? header.cwd : fallback;\n}\n\nfunction validateRemoteSnapshot(snapshot: RemoteSessionSnapshot, phase: JsonlErrorPhase): RemoteSessionSnapshot {\n\tvalidateCurrentSessionEntries(snapshot.entries, snapshot.reference, { phase });\n\treturn snapshot;\n}\n\nfunction normalizeRemoteSessionInfo(session: RemoteSessionInfo): SessionInfo {\n\tconst reference = session.reference ?? session.path;\n\treturn {\n\t\t...session,\n\t\treference,\n\t\tpath: session.path ?? reference ?? session.id,\n\t\tcreated: session.created instanceof Date ? session.created : new Date(session.created),\n\t\tmodified: session.modified instanceof Date ? session.modified : new Date(session.modified),\n\t};\n}\n\n/**\n * Remote session manager skeleton.\n *\n * Lifecycle methods are async-compatible through SessionManager so this backend\n * can fetch/create snapshots before returning an active Session.\n */\nexport class RemoteSessionManager implements SessionManager {\n\tprivate readonly client: RemoteSessionClient;\n\tprivate readonly cwd: string;\n\tprivate readonly projectId: string | undefined;\n\n\tconstructor(options: RemoteSessionManagerOptions) {\n\t\tthis.client = new RemoteSessionClient({ baseUrl: options.baseUrl, token: options.token, fetch: options.fetch });\n\t\tthis.cwd = options.cwd;\n\t\tthis.projectId = options.projectId;\n\t}\n\n\tasync create(options?: NewSessionOptions): Promise<RemoteSession> {\n\t\tconst snapshot = validateRemoteSnapshot(\n\t\t\tawait this.client.createSession({\n\t\t\t\tid: options?.id,\n\t\t\t\tcwd: this.cwd,\n\t\t\t\tprojectId: this.projectId,\n\t\t\t\tparentSession: options?.parentSession,\n\t\t\t}),\n\t\t\t\"create\",\n\t\t);\n\t\treturn new RemoteSession({ client: this.client, cwd: this.cwd, snapshot, sessionManager: this });\n\t}\n\n\tasync openReference(reference: string, options?: OpenSessionOptions): Promise<RemoteSession> {\n\t\tconst snapshot = validateRemoteSnapshot(await this.client.openSession(reference), \"open\");\n\t\treturn new RemoteSession({\n\t\t\tclient: this.client,\n\t\t\tcwd: options?.cwdOverride ?? getSnapshotCwd(snapshot, this.cwd),\n\t\t\tsnapshot,\n\t\t\tsessionManager: this,\n\t\t});\n\t}\n\n\tasync continueRecent(): Promise<RemoteSession> {\n\t\tconst snapshot = validateRemoteSnapshot(await this.client.getRecentSession(), \"open\");\n\t\treturn new RemoteSession({\n\t\t\tclient: this.client,\n\t\t\tcwd: getSnapshotCwd(snapshot, this.cwd),\n\t\t\tsnapshot,\n\t\t\tsessionManager: this,\n\t\t});\n\t}\n\n\tasync forkFrom(reference: string): Promise<RemoteSession> {\n\t\tconst snapshot = validateRemoteSnapshot(\n\t\t\tawait this.client.forkSession(reference, { cwd: this.cwd, projectId: this.projectId }),\n\t\t\t\"fork\",\n\t\t);\n\t\treturn new RemoteSession({ client: this.client, cwd: this.cwd, snapshot, sessionManager: this });\n\t}\n\n\tasync forkSession(source: Session, targetLeafId: string | null): Promise<RemoteSession> {\n\t\tif (source instanceof RemoteSession) await source.flushPendingSync();\n\t\tconst reference = source.getSessionReference();\n\t\tif (!reference) {\n\t\t\tthrow new Error(\"Cannot fork a remote session without a session reference\");\n\t\t}\n\t\tconst snapshot = validateRemoteSnapshot(\n\t\t\tawait this.client.forkSession(reference, {\n\t\t\t\tcwd: this.cwd,\n\t\t\t\tprojectId: this.projectId,\n\t\t\t\tleafId: targetLeafId ?? undefined,\n\t\t\t}),\n\t\t\t\"fork\",\n\t\t);\n\t\treturn new RemoteSession({ client: this.client, cwd: this.cwd, snapshot, sessionManager: this });\n\t}\n\n\tasync importJsonl(inputPath: string, options?: OpenSessionOptions): Promise<RemoteSession> {\n\t\tconst resolvedPath = resolve(inputPath);\n\t\tif (!existsSync(resolvedPath)) {\n\t\t\tthrow new Error(`File not found: ${resolvedPath}`);\n\t\t}\n\n\t\tconst entries = loadEntriesFromFile(resolvedPath, { repair: false, phase: \"import\" });\n\t\tif (entries.length === 0) {\n\t\t\tthrow createJsonlSessionDecodeError(\n\t\t\t\tresolvedPath,\n\t\t\t\t\"import\",\n\t\t\t\t\"schema\",\n\t\t\t\t`Cannot import empty or invalid session JSONL: ${resolvedPath}`,\n\t\t\t);\n\t\t}\n\t\tmigrateToCurrentVersion(entries);\n\t\tvalidateCurrentSessionEntries(entries, resolvedPath, {\n\t\t\tphase: \"import\",\n\t\t\tlocations: getJsonlEntryLocations(entries),\n\t\t});\n\n\t\tconst cwd = options?.cwdOverride ?? getSnapshotCwd({ id: \"\", reference: \"\", entries }, this.cwd);\n\t\tconst snapshot = validateRemoteSnapshot(\n\t\t\tawait this.client.importJsonl({\n\t\t\t\tcwd,\n\t\t\t\tprojectId: this.projectId,\n\t\t\t\tsourceName: basename(resolvedPath),\n\t\t\t\tentries,\n\t\t\t}),\n\t\t\t\"import\",\n\t\t);\n\t\treturn new RemoteSession({\n\t\t\tclient: this.client,\n\t\t\tcwd: getSnapshotCwd(snapshot, cwd),\n\t\t\tsnapshot,\n\t\t\tsessionManager: this,\n\t\t});\n\t}\n\n\tasync list(_onProgress?: SessionListProgress): Promise<SessionInfo[]> {\n\t\tconst response = await this.client.listSessions();\n\t\treturn response.sessions.map((session) => normalizeRemoteSessionInfo(session));\n\t}\n\n\tasync listAll(_onProgress?: SessionListProgress): Promise<SessionInfo[]> {\n\t\tconst response = await this.client.listSessions();\n\t\treturn response.sessions.map((session) => normalizeRemoteSessionInfo(session));\n\t}\n}\n"]}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { basename, resolve } from "node:path";
|
|
3
|
+
import { createJsonlSessionDecodeError } from "./jsonl-errors.js";
|
|
4
|
+
import { loadEntriesFromFile } from "./jsonl-helpers.js";
|
|
5
|
+
import { migrateToCurrentVersion } from "./migrations.js";
|
|
6
|
+
import { RemoteSession } from "./remote-session.js";
|
|
7
|
+
import { RemoteSessionClient } from "./remote-session-client.js";
|
|
8
|
+
import { getJsonlEntryLocations, validateCurrentSessionEntries } from "./stores/jsonl-session-store.js";
|
|
9
|
+
function getSnapshotCwd(snapshot, fallback) {
|
|
10
|
+
const header = snapshot.entries.find((entry) => entry.type === "session");
|
|
11
|
+
return typeof header?.cwd === "string" ? header.cwd : fallback;
|
|
12
|
+
}
|
|
13
|
+
function validateRemoteSnapshot(snapshot, phase) {
|
|
14
|
+
validateCurrentSessionEntries(snapshot.entries, snapshot.reference, { phase });
|
|
15
|
+
return snapshot;
|
|
16
|
+
}
|
|
17
|
+
function normalizeRemoteSessionInfo(session) {
|
|
18
|
+
const reference = session.reference ?? session.path;
|
|
19
|
+
return {
|
|
20
|
+
...session,
|
|
21
|
+
reference,
|
|
22
|
+
path: session.path ?? reference ?? session.id,
|
|
23
|
+
created: session.created instanceof Date ? session.created : new Date(session.created),
|
|
24
|
+
modified: session.modified instanceof Date ? session.modified : new Date(session.modified),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Remote session manager skeleton.
|
|
29
|
+
*
|
|
30
|
+
* Lifecycle methods are async-compatible through SessionManager so this backend
|
|
31
|
+
* can fetch/create snapshots before returning an active Session.
|
|
32
|
+
*/
|
|
33
|
+
export class RemoteSessionManager {
|
|
34
|
+
client;
|
|
35
|
+
cwd;
|
|
36
|
+
projectId;
|
|
37
|
+
constructor(options) {
|
|
38
|
+
this.client = new RemoteSessionClient({ baseUrl: options.baseUrl, token: options.token, fetch: options.fetch });
|
|
39
|
+
this.cwd = options.cwd;
|
|
40
|
+
this.projectId = options.projectId;
|
|
41
|
+
}
|
|
42
|
+
async create(options) {
|
|
43
|
+
const snapshot = validateRemoteSnapshot(await this.client.createSession({
|
|
44
|
+
id: options?.id,
|
|
45
|
+
cwd: this.cwd,
|
|
46
|
+
projectId: this.projectId,
|
|
47
|
+
parentSession: options?.parentSession,
|
|
48
|
+
}), "create");
|
|
49
|
+
return new RemoteSession({ client: this.client, cwd: this.cwd, snapshot, sessionManager: this });
|
|
50
|
+
}
|
|
51
|
+
async openReference(reference, options) {
|
|
52
|
+
const snapshot = validateRemoteSnapshot(await this.client.openSession(reference), "open");
|
|
53
|
+
return new RemoteSession({
|
|
54
|
+
client: this.client,
|
|
55
|
+
cwd: options?.cwdOverride ?? getSnapshotCwd(snapshot, this.cwd),
|
|
56
|
+
snapshot,
|
|
57
|
+
sessionManager: this,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
async continueRecent() {
|
|
61
|
+
const snapshot = validateRemoteSnapshot(await this.client.getRecentSession(), "open");
|
|
62
|
+
return new RemoteSession({
|
|
63
|
+
client: this.client,
|
|
64
|
+
cwd: getSnapshotCwd(snapshot, this.cwd),
|
|
65
|
+
snapshot,
|
|
66
|
+
sessionManager: this,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
async forkFrom(reference) {
|
|
70
|
+
const snapshot = validateRemoteSnapshot(await this.client.forkSession(reference, { cwd: this.cwd, projectId: this.projectId }), "fork");
|
|
71
|
+
return new RemoteSession({ client: this.client, cwd: this.cwd, snapshot, sessionManager: this });
|
|
72
|
+
}
|
|
73
|
+
async forkSession(source, targetLeafId) {
|
|
74
|
+
if (source instanceof RemoteSession)
|
|
75
|
+
await source.flushPendingSync();
|
|
76
|
+
const reference = source.getSessionReference();
|
|
77
|
+
if (!reference) {
|
|
78
|
+
throw new Error("Cannot fork a remote session without a session reference");
|
|
79
|
+
}
|
|
80
|
+
const snapshot = validateRemoteSnapshot(await this.client.forkSession(reference, {
|
|
81
|
+
cwd: this.cwd,
|
|
82
|
+
projectId: this.projectId,
|
|
83
|
+
leafId: targetLeafId ?? undefined,
|
|
84
|
+
}), "fork");
|
|
85
|
+
return new RemoteSession({ client: this.client, cwd: this.cwd, snapshot, sessionManager: this });
|
|
86
|
+
}
|
|
87
|
+
async importJsonl(inputPath, options) {
|
|
88
|
+
const resolvedPath = resolve(inputPath);
|
|
89
|
+
if (!existsSync(resolvedPath)) {
|
|
90
|
+
throw new Error(`File not found: ${resolvedPath}`);
|
|
91
|
+
}
|
|
92
|
+
const entries = loadEntriesFromFile(resolvedPath, { repair: false, phase: "import" });
|
|
93
|
+
if (entries.length === 0) {
|
|
94
|
+
throw createJsonlSessionDecodeError(resolvedPath, "import", "schema", `Cannot import empty or invalid session JSONL: ${resolvedPath}`);
|
|
95
|
+
}
|
|
96
|
+
migrateToCurrentVersion(entries);
|
|
97
|
+
validateCurrentSessionEntries(entries, resolvedPath, {
|
|
98
|
+
phase: "import",
|
|
99
|
+
locations: getJsonlEntryLocations(entries),
|
|
100
|
+
});
|
|
101
|
+
const cwd = options?.cwdOverride ?? getSnapshotCwd({ id: "", reference: "", entries }, this.cwd);
|
|
102
|
+
const snapshot = validateRemoteSnapshot(await this.client.importJsonl({
|
|
103
|
+
cwd,
|
|
104
|
+
projectId: this.projectId,
|
|
105
|
+
sourceName: basename(resolvedPath),
|
|
106
|
+
entries,
|
|
107
|
+
}), "import");
|
|
108
|
+
return new RemoteSession({
|
|
109
|
+
client: this.client,
|
|
110
|
+
cwd: getSnapshotCwd(snapshot, cwd),
|
|
111
|
+
snapshot,
|
|
112
|
+
sessionManager: this,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
async list(_onProgress) {
|
|
116
|
+
const response = await this.client.listSessions();
|
|
117
|
+
return response.sessions.map((session) => normalizeRemoteSessionInfo(session));
|
|
118
|
+
}
|
|
119
|
+
async listAll(_onProgress) {
|
|
120
|
+
const response = await this.client.listSessions();
|
|
121
|
+
return response.sessions.map((session) => normalizeRemoteSessionInfo(session));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=remote-session-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-session-manager.js","sourceRoot":"","sources":["../../../src/core/session/remote-session-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGjE,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAWxG,SAAS,cAAc,CAAC,QAA+B,EAAE,QAAgB,EAAU;IAClF,MAAM,MAA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,cAAc,EAAE,IAAI;SACpB,CAAC,CAAC;IAAA,CACH;IAED,KAAK,CAAC,IAAI,CAAC,WAAiC,EAA0B;QACrE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;QAClD,OAAO,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC,CAAC;IAAA,CAC/E;IAED,KAAK,CAAC,OAAO,CAAC,WAAiC,EAA0B;QACxE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;QAClD,OAAO,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC,CAAC;IAAA,CAC/E;CACD","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { basename, resolve } from \"node:path\";\nimport type { JsonlErrorPhase } from \"./jsonl-errors.ts\";\nimport { createJsonlSessionDecodeError } from \"./jsonl-errors.ts\";\nimport { loadEntriesFromFile } from \"./jsonl-helpers.ts\";\nimport { migrateToCurrentVersion } from \"./migrations.ts\";\nimport { RemoteSession } from \"./remote-session.ts\";\nimport type { RemoteSessionInfo, RemoteSessionSnapshot } from \"./remote-session-client.ts\";\nimport { RemoteSessionClient } from \"./remote-session-client.ts\";\nimport type { Session } from \"./session.ts\";\nimport type { OpenSessionOptions, SessionManager } from \"./session-manager.ts\";\nimport { getJsonlEntryLocations, validateCurrentSessionEntries } from \"./stores/jsonl-session-store.ts\";\nimport type { NewSessionOptions, SessionHeader, SessionInfo, SessionListProgress } from \"./types.ts\";\n\nexport interface RemoteSessionManagerOptions {\n\tbaseUrl: string;\n\ttoken: string;\n\tcwd: string;\n\tprojectId?: string;\n\tfetch?: typeof fetch;\n}\n\nfunction getSnapshotCwd(snapshot: RemoteSessionSnapshot, fallback: string): string {\n\tconst header = snapshot.entries.find((entry) => entry.type === \"session\") as SessionHeader | undefined;\n\treturn typeof header?.cwd === \"string\" ? header.cwd : fallback;\n}\n\nfunction validateRemoteSnapshot(snapshot: RemoteSessionSnapshot, phase: JsonlErrorPhase): RemoteSessionSnapshot {\n\tvalidateCurrentSessionEntries(snapshot.entries, snapshot.reference, { phase });\n\treturn snapshot;\n}\n\nfunction normalizeRemoteSessionInfo(session: RemoteSessionInfo): SessionInfo {\n\tconst reference = session.reference ?? session.path;\n\treturn {\n\t\t...session,\n\t\treference,\n\t\tpath: session.path ?? reference ?? session.id,\n\t\tcreated: session.created instanceof Date ? session.created : new Date(session.created),\n\t\tmodified: session.modified instanceof Date ? session.modified : new Date(session.modified),\n\t};\n}\n\n/**\n * Remote session manager skeleton.\n *\n * Lifecycle methods are async-compatible through SessionManager so this backend\n * can fetch/create snapshots before returning an active Session.\n */\nexport class RemoteSessionManager implements SessionManager {\n\tprivate readonly client: RemoteSessionClient;\n\tprivate readonly cwd: string;\n\tprivate readonly projectId: string | undefined;\n\n\tconstructor(options: RemoteSessionManagerOptions) {\n\t\tthis.client = new RemoteSessionClient({ baseUrl: options.baseUrl, token: options.token, fetch: options.fetch });\n\t\tthis.cwd = options.cwd;\n\t\tthis.projectId = options.projectId;\n\t}\n\n\tasync create(options?: NewSessionOptions): Promise<RemoteSession> {\n\t\tconst snapshot = validateRemoteSnapshot(\n\t\t\tawait this.client.createSession({\n\t\t\t\tid: options?.id,\n\t\t\t\tcwd: this.cwd,\n\t\t\t\tprojectId: this.projectId,\n\t\t\t\tparentSession: options?.parentSession,\n\t\t\t}),\n\t\t\t\"create\",\n\t\t);\n\t\treturn new RemoteSession({ client: this.client, cwd: this.cwd, snapshot, sessionManager: this });\n\t}\n\n\tasync openReference(reference: string, options?: OpenSessionOptions): Promise<RemoteSession> {\n\t\tconst snapshot = validateRemoteSnapshot(await this.client.openSession(reference), \"open\");\n\t\treturn new RemoteSession({\n\t\t\tclient: this.client,\n\t\t\tcwd: options?.cwdOverride ?? getSnapshotCwd(snapshot, this.cwd),\n\t\t\tsnapshot,\n\t\t\tsessionManager: this,\n\t\t});\n\t}\n\n\tasync continueRecent(): Promise<RemoteSession> {\n\t\tconst snapshot = validateRemoteSnapshot(await this.client.getRecentSession(), \"open\");\n\t\treturn new RemoteSession({\n\t\t\tclient: this.client,\n\t\t\tcwd: getSnapshotCwd(snapshot, this.cwd),\n\t\t\tsnapshot,\n\t\t\tsessionManager: this,\n\t\t});\n\t}\n\n\tasync forkFrom(reference: string): Promise<RemoteSession> {\n\t\tconst snapshot = validateRemoteSnapshot(\n\t\t\tawait this.client.forkSession(reference, { cwd: this.cwd, projectId: this.projectId }),\n\t\t\t\"fork\",\n\t\t);\n\t\treturn new RemoteSession({ client: this.client, cwd: this.cwd, snapshot, sessionManager: this });\n\t}\n\n\tasync forkSession(source: Session, targetLeafId: string | null): Promise<RemoteSession> {\n\t\tif (source instanceof RemoteSession) await source.flushPendingSync();\n\t\tconst reference = source.getSessionReference();\n\t\tif (!reference) {\n\t\t\tthrow new Error(\"Cannot fork a remote session without a session reference\");\n\t\t}\n\t\tconst snapshot = validateRemoteSnapshot(\n\t\t\tawait this.client.forkSession(reference, {\n\t\t\t\tcwd: this.cwd,\n\t\t\t\tprojectId: this.projectId,\n\t\t\t\tleafId: targetLeafId ?? undefined,\n\t\t\t}),\n\t\t\t\"fork\",\n\t\t);\n\t\treturn new RemoteSession({ client: this.client, cwd: this.cwd, snapshot, sessionManager: this });\n\t}\n\n\tasync importJsonl(inputPath: string, options?: OpenSessionOptions): Promise<RemoteSession> {\n\t\tconst resolvedPath = resolve(inputPath);\n\t\tif (!existsSync(resolvedPath)) {\n\t\t\tthrow new Error(`File not found: ${resolvedPath}`);\n\t\t}\n\n\t\tconst entries = loadEntriesFromFile(resolvedPath, { repair: false, phase: \"import\" });\n\t\tif (entries.length === 0) {\n\t\t\tthrow createJsonlSessionDecodeError(\n\t\t\t\tresolvedPath,\n\t\t\t\t\"import\",\n\t\t\t\t\"schema\",\n\t\t\t\t`Cannot import empty or invalid session JSONL: ${resolvedPath}`,\n\t\t\t);\n\t\t}\n\t\tmigrateToCurrentVersion(entries);\n\t\tvalidateCurrentSessionEntries(entries, resolvedPath, {\n\t\t\tphase: \"import\",\n\t\t\tlocations: getJsonlEntryLocations(entries),\n\t\t});\n\n\t\tconst cwd = options?.cwdOverride ?? getSnapshotCwd({ id: \"\", reference: \"\", entries }, this.cwd);\n\t\tconst snapshot = validateRemoteSnapshot(\n\t\t\tawait this.client.importJsonl({\n\t\t\t\tcwd,\n\t\t\t\tprojectId: this.projectId,\n\t\t\t\tsourceName: basename(resolvedPath),\n\t\t\t\tentries,\n\t\t\t}),\n\t\t\t\"import\",\n\t\t);\n\t\treturn new RemoteSession({\n\t\t\tclient: this.client,\n\t\t\tcwd: getSnapshotCwd(snapshot, cwd),\n\t\t\tsnapshot,\n\t\t\tsessionManager: this,\n\t\t});\n\t}\n\n\tasync list(_onProgress?: SessionListProgress): Promise<SessionInfo[]> {\n\t\tconst response = await this.client.listSessions();\n\t\treturn response.sessions.map((session) => normalizeRemoteSessionInfo(session));\n\t}\n\n\tasync listAll(_onProgress?: SessionListProgress): Promise<SessionInfo[]> {\n\t\tconst response = await this.client.listSessions();\n\t\treturn response.sessions.map((session) => normalizeRemoteSessionInfo(session));\n\t}\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RemoteSessionClient, RemoteSessionSnapshot } from "./remote-session-client.ts";
|
|
2
|
+
import { Session } from "./session.ts";
|
|
3
|
+
import type { SessionManager } from "./session-manager.ts";
|
|
4
|
+
import type { NewSessionOptions } from "./types.ts";
|
|
5
|
+
export interface RemoteSessionOptions {
|
|
6
|
+
client: RemoteSessionClient;
|
|
7
|
+
cwd: string;
|
|
8
|
+
reference?: string;
|
|
9
|
+
snapshot?: RemoteSessionSnapshot;
|
|
10
|
+
sessionManager?: SessionManager;
|
|
11
|
+
}
|
|
12
|
+
export declare class RemoteSession extends Session {
|
|
13
|
+
private remoteStore;
|
|
14
|
+
constructor(options: RemoteSessionOptions);
|
|
15
|
+
protected prepareNewSessionReference(_sessionDir: string, sessionId: string, _timestamp: string): string | undefined;
|
|
16
|
+
newSession(options?: NewSessionOptions): string | undefined;
|
|
17
|
+
flushPendingSync(): Promise<void>;
|
|
18
|
+
getLastSyncError(): unknown;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=remote-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-session.d.ts","sourceRoot":"","sources":["../../../src/core/session/remote-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAE7F,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,WAAW,oBAAoB;IACpC,MAAM,EAAE,mBAAmB,CAAC;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IACjC,cAAc,CAAC,EAAE,cAAc,CAAC;CAChC;AAED,qBAAa,aAAc,SAAQ,OAAO;IACzC,OAAO,CAAC,WAAW,CAAiC;IAEpD,YAAY,OAAO,EAAE,oBAAoB,EAYxC;IAED,SAAS,CAAC,0BAA0B,CACnC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GAChB,MAAM,GAAG,SAAS,CAEpB;IAEQ,UAAU,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,MAAM,GAAG,SAAS,CAInE;IAED,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEhC;IAED,gBAAgB,IAAI,OAAO,CAE1B;CACD","sourcesContent":["import type { RemoteSessionClient, RemoteSessionSnapshot } from \"./remote-session-client.ts\";\nimport { formatRemoteSessionReference } from \"./remote-session-client.ts\";\nimport { Session } from \"./session.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport { RemoteSessionStore } from \"./stores/remote-session-store.ts\";\nimport type { NewSessionOptions } from \"./types.ts\";\n\nexport interface RemoteSessionOptions {\n\tclient: RemoteSessionClient;\n\tcwd: string;\n\treference?: string;\n\tsnapshot?: RemoteSessionSnapshot;\n\tsessionManager?: SessionManager;\n}\n\nexport class RemoteSession extends Session {\n\tprivate remoteStore: RemoteSessionStore | undefined;\n\n\tconstructor(options: RemoteSessionOptions) {\n\t\tconst reference =\n\t\t\toptions.reference ??\n\t\t\toptions.snapshot?.reference ??\n\t\t\t(options.snapshot ? formatRemoteSessionReference(options.snapshot.id) : undefined);\n\t\tconst store = new RemoteSessionStore({\n\t\t\tclient: options.client,\n\t\t\treference,\n\t\t\tsnapshot: options.snapshot,\n\t\t});\n\t\tsuper(options.cwd, \"\", reference, store, options.sessionManager);\n\t\tthis.remoteStore = store;\n\t}\n\n\tprotected prepareNewSessionReference(\n\t\t_sessionDir: string,\n\t\tsessionId: string,\n\t\t_timestamp: string,\n\t): string | undefined {\n\t\treturn this.getSessionReference() ?? formatRemoteSessionReference(sessionId);\n\t}\n\n\toverride newSession(options?: NewSessionOptions): string | undefined {\n\t\tconst reference = super.newSession(options);\n\t\tthis.remoteStore?.saveSnapshot();\n\t\treturn reference;\n\t}\n\n\tflushPendingSync(): Promise<void> {\n\t\treturn this.remoteStore?.flushPendingSync() ?? Promise.resolve();\n\t}\n\n\tgetLastSyncError(): unknown {\n\t\treturn this.remoteStore?.getLastSyncError();\n\t}\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { formatRemoteSessionReference } from "./remote-session-client.js";
|
|
2
|
+
import { Session } from "./session.js";
|
|
3
|
+
import { RemoteSessionStore } from "./stores/remote-session-store.js";
|
|
4
|
+
export class RemoteSession extends Session {
|
|
5
|
+
remoteStore;
|
|
6
|
+
constructor(options) {
|
|
7
|
+
const reference = options.reference ??
|
|
8
|
+
options.snapshot?.reference ??
|
|
9
|
+
(options.snapshot ? formatRemoteSessionReference(options.snapshot.id) : undefined);
|
|
10
|
+
const store = new RemoteSessionStore({
|
|
11
|
+
client: options.client,
|
|
12
|
+
reference,
|
|
13
|
+
snapshot: options.snapshot,
|
|
14
|
+
});
|
|
15
|
+
super(options.cwd, "", reference, store, options.sessionManager);
|
|
16
|
+
this.remoteStore = store;
|
|
17
|
+
}
|
|
18
|
+
prepareNewSessionReference(_sessionDir, sessionId, _timestamp) {
|
|
19
|
+
return this.getSessionReference() ?? formatRemoteSessionReference(sessionId);
|
|
20
|
+
}
|
|
21
|
+
newSession(options) {
|
|
22
|
+
const reference = super.newSession(options);
|
|
23
|
+
this.remoteStore?.saveSnapshot();
|
|
24
|
+
return reference;
|
|
25
|
+
}
|
|
26
|
+
flushPendingSync() {
|
|
27
|
+
return this.remoteStore?.flushPendingSync() ?? Promise.resolve();
|
|
28
|
+
}
|
|
29
|
+
getLastSyncError() {
|
|
30
|
+
return this.remoteStore?.getLastSyncError();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=remote-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-session.js","sourceRoot":"","sources":["../../../src/core/session/remote-session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAWtE,MAAM,OAAO,aAAc,SAAQ,OAAO;IACjC,WAAW,CAAiC;IAEpD,YAAY,OAA6B,EAAE;QAC1C,MAAM,SAAS,GACd,OAAO,CAAC,SAAS;YACjB,OAAO,CAAC,QAAQ,EAAE,SAAS;YAC3B,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,4BAA4B,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACpF,MAAM,KAAK,GAAG,IAAI,kBAAkB,CAAC;YACpC,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,SAAS;YACT,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC1B,CAAC,CAAC;QACH,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;QACjE,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAAA,CACzB;IAES,0BAA0B,CACnC,WAAmB,EACnB,SAAiB,EACjB,UAAkB,EACG;QACrB,OAAO,IAAI,CAAC,mBAAmB,EAAE,IAAI,4BAA4B,CAAC,SAAS,CAAC,CAAC;IAAA,CAC7E;IAEQ,UAAU,CAAC,OAA2B,EAAsB;QACpE,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC,WAAW,EAAE,YAAY,EAAE,CAAC;QACjC,OAAO,SAAS,CAAC;IAAA,CACjB;IAED,gBAAgB,GAAkB;QACjC,OAAO,IAAI,CAAC,WAAW,EAAE,gBAAgB,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAAA,CACjE;IAED,gBAAgB,GAAY;QAC3B,OAAO,IAAI,CAAC,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAAA,CAC5C;CACD","sourcesContent":["import type { RemoteSessionClient, RemoteSessionSnapshot } from \"./remote-session-client.ts\";\nimport { formatRemoteSessionReference } from \"./remote-session-client.ts\";\nimport { Session } from \"./session.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport { RemoteSessionStore } from \"./stores/remote-session-store.ts\";\nimport type { NewSessionOptions } from \"./types.ts\";\n\nexport interface RemoteSessionOptions {\n\tclient: RemoteSessionClient;\n\tcwd: string;\n\treference?: string;\n\tsnapshot?: RemoteSessionSnapshot;\n\tsessionManager?: SessionManager;\n}\n\nexport class RemoteSession extends Session {\n\tprivate remoteStore: RemoteSessionStore | undefined;\n\n\tconstructor(options: RemoteSessionOptions) {\n\t\tconst reference =\n\t\t\toptions.reference ??\n\t\t\toptions.snapshot?.reference ??\n\t\t\t(options.snapshot ? formatRemoteSessionReference(options.snapshot.id) : undefined);\n\t\tconst store = new RemoteSessionStore({\n\t\t\tclient: options.client,\n\t\t\treference,\n\t\t\tsnapshot: options.snapshot,\n\t\t});\n\t\tsuper(options.cwd, \"\", reference, store, options.sessionManager);\n\t\tthis.remoteStore = store;\n\t}\n\n\tprotected prepareNewSessionReference(\n\t\t_sessionDir: string,\n\t\tsessionId: string,\n\t\t_timestamp: string,\n\t): string | undefined {\n\t\treturn this.getSessionReference() ?? formatRemoteSessionReference(sessionId);\n\t}\n\n\toverride newSession(options?: NewSessionOptions): string | undefined {\n\t\tconst reference = super.newSession(options);\n\t\tthis.remoteStore?.saveSnapshot();\n\t\treturn reference;\n\t}\n\n\tflushPendingSync(): Promise<void> {\n\t\treturn this.remoteStore?.flushPendingSync() ?? Promise.resolve();\n\t}\n\n\tgetLastSyncError(): unknown {\n\t\treturn this.remoteStore?.getLastSyncError();\n\t}\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Session } from "./session.ts";
|
|
2
|
+
import type { NewSessionOptions, SessionInfo, SessionListProgress } from "./types.ts";
|
|
3
|
+
export type SessionResult = Session | Promise<Session>;
|
|
4
|
+
export interface OpenSessionOptions {
|
|
5
|
+
cwdOverride?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SessionManager {
|
|
8
|
+
create(options?: NewSessionOptions): SessionResult;
|
|
9
|
+
openReference(reference: string, options?: OpenSessionOptions): SessionResult;
|
|
10
|
+
continueRecent(): SessionResult;
|
|
11
|
+
forkFrom(reference: string): SessionResult;
|
|
12
|
+
forkSession(source: Session, targetLeafId: string | null): SessionResult;
|
|
13
|
+
importJsonl(inputPath: string, options?: OpenSessionOptions): SessionResult;
|
|
14
|
+
list(onProgress?: SessionListProgress): Promise<SessionInfo[]>;
|
|
15
|
+
listAll(onProgress?: SessionListProgress): Promise<SessionInfo[]>;
|
|
16
|
+
usesDefaultSessionDir?(): boolean;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=session-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-manager.d.ts","sourceRoot":"","sources":["../../../src/core/session/session-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtF,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEvD,MAAM,WAAW,kBAAkB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC9B,MAAM,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,aAAa,CAAC;IACnD,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,aAAa,CAAC;IAC9E,cAAc,IAAI,aAAa,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,CAAC;IAC3C,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,aAAa,CAAC;IACzE,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,aAAa,CAAC;IAC5E,IAAI,CAAC,UAAU,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAC/D,OAAO,CAAC,UAAU,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAClE,qBAAqB,CAAC,IAAI,OAAO,CAAC;CAClC","sourcesContent":["import type { Session } from \"./session.ts\";\nimport type { NewSessionOptions, SessionInfo, SessionListProgress } from \"./types.ts\";\n\nexport type SessionResult = Session | Promise<Session>;\n\nexport interface OpenSessionOptions {\n\tcwdOverride?: string;\n}\n\nexport interface SessionManager {\n\tcreate(options?: NewSessionOptions): SessionResult;\n\topenReference(reference: string, options?: OpenSessionOptions): SessionResult;\n\tcontinueRecent(): SessionResult;\n\tforkFrom(reference: string): SessionResult;\n\tforkSession(source: Session, targetLeafId: string | null): SessionResult;\n\timportJsonl(inputPath: string, options?: OpenSessionOptions): SessionResult;\n\tlist(onProgress?: SessionListProgress): Promise<SessionInfo[]>;\n\tlistAll(onProgress?: SessionListProgress): Promise<SessionInfo[]>;\n\tusesDefaultSessionDir?(): boolean;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-manager.js","sourceRoot":"","sources":["../../../src/core/session/session-manager.ts"],"names":[],"mappings":"","sourcesContent":["import type { Session } from \"./session.ts\";\nimport type { NewSessionOptions, SessionInfo, SessionListProgress } from \"./types.ts\";\n\nexport type SessionResult = Session | Promise<Session>;\n\nexport interface OpenSessionOptions {\n\tcwdOverride?: string;\n}\n\nexport interface SessionManager {\n\tcreate(options?: NewSessionOptions): SessionResult;\n\topenReference(reference: string, options?: OpenSessionOptions): SessionResult;\n\tcontinueRecent(): SessionResult;\n\tforkFrom(reference: string): SessionResult;\n\tforkSession(source: Session, targetLeafId: string | null): SessionResult;\n\timportJsonl(inputPath: string, options?: OpenSessionOptions): SessionResult;\n\tlist(onProgress?: SessionListProgress): Promise<SessionInfo[]>;\n\tlistAll(onProgress?: SessionListProgress): Promise<SessionInfo[]>;\n\tusesDefaultSessionDir?(): boolean;\n}\n"]}
|