@code-yeongyu/senpi 2026.8.1 → 2026.8.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 +33 -0
- package/README.md +1 -0
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +27 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/credential-print.d.ts +23 -0
- package/dist/cli/credential-print.d.ts.map +1 -0
- package/dist/cli/credential-print.js +116 -0
- package/dist/cli/credential-print.js.map +1 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +3 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/remote-session.d.ts +53 -0
- package/dist/client/remote-session.d.ts.map +1 -0
- package/dist/client/remote-session.js +340 -0
- package/dist/client/remote-session.js.map +1 -0
- package/dist/client/transcript.d.ts +12 -0
- package/dist/client/transcript.d.ts.map +1 -0
- package/dist/client/transcript.js +98 -0
- package/dist/client/transcript.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +3 -0
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +36 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +325 -41
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +5 -0
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +72 -11
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/dynamic-prompt/verification.d.ts +2 -2
- package/dist/core/dynamic-prompt/verification.d.ts.map +1 -1
- package/dist/core/dynamic-prompt/verification.js +2 -2
- package/dist/core/dynamic-prompt/verification.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/bounded-queue.d.ts +17 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/bounded-queue.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/bounded-queue.js +56 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/bounded-queue.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/sdk-boundary.d.ts +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/sdk-boundary.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/sdk-boundary.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.d.ts +32 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.js +43 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.d.ts +18 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.js +46 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.d.ts +81 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.js +127 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-entry-annotations.d.ts +10 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-entry-annotations.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-entry-annotations.js +34 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-entry-annotations.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-observability.d.ts +56 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-observability.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-observability.js +174 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-observability.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-reaper.d.ts +24 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-reaper.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-reaper.js +34 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-reaper.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-reattach.d.ts +34 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-reattach.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-reattach.js +85 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-reattach.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.d.ts +2 -13
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.js +34 -55
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.js +35 -93
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.d.ts +13 -11
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.js +44 -55
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.d.ts +3 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js +101 -126
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.d.ts +2 -31
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js +26 -98
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-claim.d.ts +14 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-claim.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-claim.js +42 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-claim.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-types.d.ts +32 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-types.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-types.js +8 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-types.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream-events.d.ts +16 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream-events.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream-events.js +92 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream-events.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream.js +48 -88
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/tools.d.ts +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/tools.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/tools.js +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/tools.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/checkpoint-state.d.ts +18 -1
- package/dist/core/extensions/builtin/compaction/checkpoint-state.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/checkpoint-state.js +32 -0
- package/dist/core/extensions/builtin/compaction/checkpoint-state.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts +1 -1
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.js +4 -0
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/idle-retry.d.ts +21 -0
- package/dist/core/extensions/builtin/compaction/idle-retry.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/idle-retry.js +24 -0
- package/dist/core/extensions/builtin/compaction/idle-retry.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.js +91 -13
- package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/lane-policy.d.ts +71 -0
- package/dist/core/extensions/builtin/compaction/lane-policy.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/lane-policy.js +94 -0
- package/dist/core/extensions/builtin/compaction/lane-policy.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/log.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/log.js +1 -0
- package/dist/core/extensions/builtin/compaction/log.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/overflow-retry.d.ts +59 -0
- package/dist/core/extensions/builtin/compaction/overflow-retry.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/overflow-retry.js +155 -0
- package/dist/core/extensions/builtin/compaction/overflow-retry.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/speculative.js +17 -98
- package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/transient-failure.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/transient-failure.js +3 -0
- package/dist/core/extensions/builtin/compaction/transient-failure.js.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/apply.d.ts +1 -0
- package/dist/core/extensions/builtin/gpt-apply-patch/apply.d.ts.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/apply.js +13 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/apply.js.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/index.d.ts +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/index.js +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/index.js.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts +1 -0
- package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/tool.js +23 -5
- package/dist/core/extensions/builtin/gpt-apply-patch/tool.js.map +1 -1
- package/dist/core/extensions/builtin/loop-guard/detectors.d.ts.map +1 -1
- package/dist/core/extensions/builtin/loop-guard/detectors.js +42 -1
- package/dist/core/extensions/builtin/loop-guard/detectors.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/health.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/health.js +2 -1
- package/dist/core/extensions/builtin/mcp/health.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +5 -3
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +8 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/context.d.ts +1 -1
- package/dist/core/extensions/builtin/terminal/tools/context.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/context.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/monitor.js +1 -0
- package/dist/core/extensions/builtin/terminal/tools/monitor.js.map +1 -1
- package/dist/core/extensions/builtin/tool-pair-guard/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/tool-pair-guard/index.js +1 -1
- package/dist/core/extensions/builtin/tool-pair-guard/index.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +14 -18
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +4 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +18 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +16 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +10 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +1 -1
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/keybindings.d.ts +24 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/model-registry.d.ts +2 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +3 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-runtime.d.ts +2 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/package-manager.d.ts +0 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +18 -34
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-manifest.d.ts +9 -0
- package/dist/core/pi-manifest.d.ts.map +1 -0
- package/dist/core/pi-manifest.js +25 -0
- package/dist/core/pi-manifest.js.map +1 -0
- package/dist/core/resource-loader.d.ts +15 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +55 -6
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/retry-fallback/hint-policy.d.ts +29 -0
- package/dist/core/retry-fallback/hint-policy.d.ts.map +1 -0
- package/dist/core/retry-fallback/hint-policy.js +54 -0
- package/dist/core/retry-fallback/hint-policy.js.map +1 -0
- package/dist/core/retry-fallback/probe-scheduler.d.ts +60 -0
- package/dist/core/retry-fallback/probe-scheduler.d.ts.map +1 -0
- package/dist/core/retry-fallback/probe-scheduler.js +206 -0
- package/dist/core/retry-fallback/probe-scheduler.js.map +1 -0
- package/dist/core/retry-fallback/settings.d.ts +9 -0
- package/dist/core/retry-fallback/settings.d.ts.map +1 -1
- package/dist/core/retry-fallback/settings.js +14 -0
- package/dist/core/retry-fallback/settings.js.map +1 -1
- package/dist/core/settings-manager.d.ts +10 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +21 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/extensions/llama/provider.js +1 -1
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +44 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +5 -2
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +16 -4
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/continuity-notice.d.ts +21 -0
- package/dist/modes/interactive/components/continuity-notice.d.ts.map +1 -0
- package/dist/modes/interactive/components/continuity-notice.js +58 -0
- package/dist/modes/interactive/components/continuity-notice.js.map +1 -0
- package/dist/modes/interactive/components/markdown-transform.d.ts +3 -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/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +4 -1
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +6 -2
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +20 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +3 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +8 -2
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/help-content.d.ts.map +1 -1
- package/dist/modes/interactive/help-content.js +1 -0
- package/dist/modes/interactive/help-content.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +21 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +151 -50
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/dark.json +1 -0
- package/dist/modes/interactive/theme/grok-day.json +1 -0
- package/dist/modes/interactive/theme/grok-night.json +1 -0
- package/dist/modes/interactive/theme/light.json +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +5 -1
- package/dist/modes/interactive/theme/theme.d.ts +2 -2
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +13 -3
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
- package/dist/modes/rpc/connection-handler.js +13 -0
- package/dist/modes/rpc/connection-handler.js.map +1 -1
- package/dist/utils/clipboard.d.ts +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +22 -2
- package/dist/utils/clipboard.js.map +1 -1
- package/docs/AGENTS.md +1 -6
- package/docs/custom-provider.md +10 -3
- package/docs/development.md +1 -2
- package/docs/extensions.md +24 -1
- package/docs/keybindings.md +13 -0
- package/docs/mcp.md +63 -4
- package/docs/models.md +1 -0
- package/docs/providers.md +20 -0
- package/docs/release-guide.md +5 -3
- package/docs/session-format.md +2 -0
- package/docs/settings.md +2 -0
- package/docs/skills.md +29 -0
- package/docs/themes.md +5 -3
- package/docs/usage.md +5 -0
- package/examples/extensions/custom-compaction.ts +1 -2
- package/examples/extensions/custom-provider-anthropic/index.ts +8 -2
- package/examples/extensions/doom-overlay/wad-finder.ts +7 -3
- package/examples/extensions/handoff.ts +2 -3
- package/examples/extensions/qna.ts +2 -2
- package/examples/rpc-extension-ui.ts +11 -2
- package/examples/sdk/02-custom-model.ts +1 -2
- package/examples/sdk/12-full-control.ts +2 -0
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +12 -0
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts +14 -3
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js +156 -67
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/array-session-reader.d.ts +3 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/array-session-reader.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/array-session-reader.js +70 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/array-session-reader.js.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.d.ts +4 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.js +22 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.js.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-store.d.ts +13 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-store.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-store.js +304 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-store.js.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/keyed-operation-queue.d.ts +17 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/keyed-operation-queue.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/keyed-operation-queue.js +60 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/keyed-operation-queue.js.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-store.d.ts +6 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-store.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-store.js +107 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-store.js.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repository.d.ts +28 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repository.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repository.js +61 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repository.js.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search-backend.d.ts +8 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search-backend.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search-backend.js +22 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search-backend.js.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts +6 -10
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +154 -77
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts +49 -23
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts +6 -6
- package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/index.js +6 -6
- package/node_modules/@earendil-works/pi-agent-core/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +4 -4
- package/node_modules/@earendil-works/pi-ai/README.md +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +46 -10
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.d.ts +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.d.ts.map +1 -0
- package/{dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.js → node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.js} +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +5 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +64 -4
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +12 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +13 -6
- package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +12 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +19 -10
- package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +84 -47
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +17 -8
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +11 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +7 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js +3 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.d.ts +3 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.js +81 -26
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js +16 -8
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js +4 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +13 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/error-body.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js +23 -4
- package/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.js +10 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js +13 -12
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-hint.d.ts +24 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-hint.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-hint.js +233 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-hint.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/package.json +10 -6
- package/node_modules/@earendil-works/pi-client/CHANGELOG.md +7 -0
- package/node_modules/@earendil-works/pi-client/README.md +64 -0
- package/node_modules/@earendil-works/pi-client/dist/client.d.ts +25 -0
- package/node_modules/@earendil-works/pi-client/dist/client.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-client/dist/client.js +386 -0
- package/node_modules/@earendil-works/pi-client/dist/client.js.map +1 -0
- package/node_modules/@earendil-works/pi-client/dist/connection.d.ts +25 -0
- package/node_modules/@earendil-works/pi-client/dist/connection.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-client/dist/connection.js +204 -0
- package/node_modules/@earendil-works/pi-client/dist/connection.js.map +1 -0
- package/node_modules/@earendil-works/pi-client/dist/errors.d.ts +23 -0
- package/node_modules/@earendil-works/pi-client/dist/errors.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-client/dist/errors.js +42 -0
- package/node_modules/@earendil-works/pi-client/dist/errors.js.map +1 -0
- package/node_modules/@earendil-works/pi-client/dist/index.d.ts +6 -0
- package/node_modules/@earendil-works/pi-client/dist/index.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-client/dist/index.js +3 -0
- package/node_modules/@earendil-works/pi-client/dist/index.js.map +1 -0
- package/node_modules/@earendil-works/pi-client/dist/promise.d.ts +8 -0
- package/node_modules/@earendil-works/pi-client/dist/promise.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-client/dist/promise.js +11 -0
- package/node_modules/@earendil-works/pi-client/dist/promise.js.map +1 -0
- package/node_modules/@earendil-works/pi-client/dist/session-handle.d.ts +54 -0
- package/node_modules/@earendil-works/pi-client/dist/session-handle.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-client/dist/session-handle.js +50 -0
- package/node_modules/@earendil-works/pi-client/dist/session-handle.js.map +1 -0
- package/node_modules/@earendil-works/pi-client/dist/state.d.ts +22 -0
- package/node_modules/@earendil-works/pi-client/dist/state.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-client/dist/state.js +149 -0
- package/node_modules/@earendil-works/pi-client/dist/state.js.map +1 -0
- package/node_modules/@earendil-works/pi-client/dist/transport.d.ts +17 -0
- package/node_modules/@earendil-works/pi-client/dist/transport.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-client/dist/transport.js +2 -0
- package/node_modules/@earendil-works/pi-client/dist/transport.js.map +1 -0
- package/node_modules/@earendil-works/pi-client/dist/types.d.ts +23 -0
- package/node_modules/@earendil-works/pi-client/dist/types.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-client/dist/types.js +2 -0
- package/node_modules/@earendil-works/pi-client/dist/types.js.map +1 -0
- package/node_modules/@earendil-works/pi-client/dist/unix.d.ts +8 -0
- package/node_modules/@earendil-works/pi-client/dist/unix.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-client/dist/unix.js +151 -0
- package/node_modules/@earendil-works/pi-client/dist/unix.js.map +1 -0
- package/node_modules/@earendil-works/pi-client/package.json +56 -0
- package/node_modules/@earendil-works/pi-protocol/README.md +68 -0
- package/node_modules/@earendil-works/pi-protocol/dist/cbor/decoder.d.ts +4 -0
- package/node_modules/@earendil-works/pi-protocol/dist/cbor/decoder.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-protocol/dist/cbor/decoder.js +163 -0
- package/node_modules/@earendil-works/pi-protocol/dist/cbor/decoder.js.map +1 -0
- package/node_modules/@earendil-works/pi-protocol/dist/cbor/encoder.d.ts +4 -0
- package/node_modules/@earendil-works/pi-protocol/dist/cbor/encoder.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-protocol/dist/cbor/encoder.js +199 -0
- package/node_modules/@earendil-works/pi-protocol/dist/cbor/encoder.js.map +1 -0
- package/node_modules/@earendil-works/pi-protocol/dist/cbor/index.d.ts +4 -0
- package/node_modules/@earendil-works/pi-protocol/dist/cbor/index.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-protocol/dist/cbor/index.js +4 -0
- package/node_modules/@earendil-works/pi-protocol/dist/cbor/index.js.map +1 -0
- package/node_modules/@earendil-works/pi-protocol/dist/cbor/options.d.ts +26 -0
- package/node_modules/@earendil-works/pi-protocol/dist/cbor/options.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-protocol/dist/cbor/options.js +29 -0
- package/node_modules/@earendil-works/pi-protocol/dist/cbor/options.js.map +1 -0
- package/node_modules/@earendil-works/pi-protocol/dist/codec.d.ts +29 -0
- package/node_modules/@earendil-works/pi-protocol/dist/codec.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-protocol/dist/codec.js +140 -0
- package/node_modules/@earendil-works/pi-protocol/dist/codec.js.map +1 -0
- package/node_modules/@earendil-works/pi-protocol/dist/framing.d.ts +29 -0
- package/node_modules/@earendil-works/pi-protocol/dist/framing.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-protocol/dist/framing.js +152 -0
- package/node_modules/@earendil-works/pi-protocol/dist/framing.js.map +1 -0
- package/node_modules/@earendil-works/pi-protocol/dist/index.d.ts +5 -0
- package/node_modules/@earendil-works/pi-protocol/dist/index.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-protocol/dist/index.js +5 -0
- package/node_modules/@earendil-works/pi-protocol/dist/index.js.map +1 -0
- package/node_modules/@earendil-works/pi-protocol/dist/schemas.d.ts +13818 -0
- package/node_modules/@earendil-works/pi-protocol/dist/schemas.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-protocol/dist/schemas.js +382 -0
- package/node_modules/@earendil-works/pi-protocol/dist/schemas.js.map +1 -0
- package/node_modules/@earendil-works/pi-protocol/package.json +48 -0
- package/node_modules/@earendil-works/pi-pty/package.json +2 -2
- package/node_modules/@earendil-works/pi-tui/README.md +77 -14
- package/node_modules/@earendil-works/pi-tui/dist/TuiAltScreen.d.ts +83 -0
- package/node_modules/@earendil-works/pi-tui/dist/TuiAltScreen.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/TuiAltScreen.js +687 -0
- package/node_modules/@earendil-works/pi-tui/dist/TuiAltScreen.js.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/TuiMainScreen.d.ts +5 -0
- package/node_modules/@earendil-works/pi-tui/dist/TuiMainScreen.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/TuiMainScreen.js +5 -0
- package/node_modules/@earendil-works/pi-tui/dist/TuiMainScreen.js.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/alt-screen-flash.d.ts +13 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/alt-screen-flash.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/alt-screen-flash.js +36 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/alt-screen-flash.js.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/h-stack.d.ts +7 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/h-stack.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/h-stack.js +43 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/h-stack.js.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/image.js +4 -4
- package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +2 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +3 -2
- package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.d.ts +51 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.js +163 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.js.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +3 -6
- package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/stack.d.ts +32 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/stack.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/stack.js +109 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/stack.js.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/v-stack.d.ts +8 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/v-stack.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/v-stack.js +21 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/v-stack.js.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +10 -4
- package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.js +10 -4
- package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +30 -0
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +18 -0
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/layout-node.d.ts +40 -0
- package/node_modules/@earendil-works/pi-tui/dist/layout-node.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/layout-node.js +6 -0
- package/node_modules/@earendil-works/pi-tui/dist/layout-node.js.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/layout.d.ts +40 -0
- package/node_modules/@earendil-works/pi-tui/dist/layout.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/layout.js +315 -0
- package/node_modules/@earendil-works/pi-tui/dist/layout.js.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +10 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +61 -3
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-text.d.ts +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal-text.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-text.js +12 -2
- package/node_modules/@earendil-works/pi-tui/dist/terminal-text.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +36 -16
- package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.js +72 -18
- package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +10 -0
- package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/utils.js +95 -4
- package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +2 -2
- package/node_modules/typebox/build/compile/validator.d.mts +3 -11
- package/node_modules/typebox/build/compile/validator.mjs +6 -36
- package/node_modules/typebox/build/error/errors.d.mts +1 -7
- package/node_modules/typebox/build/format/_idna.mjs +36 -6
- package/node_modules/typebox/build/format/_puny.mjs +4 -1
- package/node_modules/typebox/build/format/uuid.d.mts +2 -2
- package/node_modules/typebox/build/format/uuid.mjs +3 -3
- package/node_modules/typebox/build/guard/emit.d.mts +0 -4
- package/node_modules/typebox/build/guard/emit.mjs +0 -8
- package/node_modules/typebox/build/guard/guard.d.mts +5 -9
- package/node_modules/typebox/build/guard/guard.mjs +10 -15
- package/node_modules/typebox/build/guard/string.mjs +16 -4
- package/node_modules/typebox/build/schema/engine/_functions.mjs +34 -15
- package/node_modules/typebox/build/schema/engine/boolean.d.mts +3 -3
- package/node_modules/typebox/build/schema/engine/boolean.mjs +4 -4
- package/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
- package/node_modules/typebox/build/schema/engine/index.mjs +0 -1
- package/node_modules/typebox/build/schema/engine/schema.mjs +6 -11
- package/node_modules/typebox/build/schema/engine/type.mjs +14 -18
- package/node_modules/typebox/build/schema/types/dependencies.mjs +1 -1
- package/node_modules/typebox/build/schema/types/index.d.mts +0 -1
- package/node_modules/typebox/build/schema/types/index.mjs +0 -1
- package/node_modules/typebox/build/schema/types/schema.d.mts +1 -1
- package/node_modules/typebox/build/schema/types/schema.mjs +2 -2
- package/node_modules/typebox/build/system/locale/ar_001.mjs +0 -1
- package/node_modules/typebox/build/system/locale/bn_BD.mjs +0 -1
- package/node_modules/typebox/build/system/locale/cs_CZ.mjs +0 -1
- package/node_modules/typebox/build/system/locale/de_DE.mjs +0 -1
- package/node_modules/typebox/build/system/locale/el_GR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/en_US.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_419.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_AR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_ES.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_MX.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fa_IR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fil_PH.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fr_CA.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fr_FR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ha_NG.mjs +0 -1
- package/node_modules/typebox/build/system/locale/hi_IN.mjs +0 -1
- package/node_modules/typebox/build/system/locale/hu_HU.mjs +0 -1
- package/node_modules/typebox/build/system/locale/id_ID.mjs +0 -1
- package/node_modules/typebox/build/system/locale/it_IT.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ja_JP.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ko_KR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ms_MY.mjs +0 -1
- package/node_modules/typebox/build/system/locale/nl_NL.mjs +0 -1
- package/node_modules/typebox/build/system/locale/pl_PL.mjs +0 -1
- package/node_modules/typebox/build/system/locale/pt_BR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/pt_PT.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ro_RO.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ru_RU.mjs +0 -1
- package/node_modules/typebox/build/system/locale/sv_SE.mjs +0 -1
- package/node_modules/typebox/build/system/locale/sw_TZ.mjs +0 -1
- package/node_modules/typebox/build/system/locale/th_TH.mjs +0 -1
- package/node_modules/typebox/build/system/locale/tr_TR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/uk_UA.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ur_PK.mjs +0 -1
- package/node_modules/typebox/build/system/locale/vi_VN.mjs +0 -1
- package/node_modules/typebox/build/system/locale/yo_NG.mjs +0 -1
- package/node_modules/typebox/build/system/locale/zh_Hans.mjs +0 -1
- package/node_modules/typebox/build/system/locale/zh_Hant.mjs +0 -1
- package/node_modules/typebox/build/system/memory/clone.d.mts +2 -3
- package/node_modules/typebox/build/system/memory/clone.mjs +73 -26
- package/node_modules/typebox/build/system/settings/settings.d.mts +15 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +3 -1
- package/node_modules/typebox/build/type/action/_add_immutable.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_add_immutable.mjs +11 -0
- package/node_modules/typebox/build/type/action/_add_optional.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_add_optional.mjs +11 -0
- package/node_modules/typebox/build/type/action/_add_readonly.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_add_readonly.mjs +11 -0
- package/node_modules/typebox/build/type/action/_remove_immutable.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_remove_immutable.mjs +11 -0
- package/node_modules/typebox/build/type/action/_remove_optional.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_remove_optional.mjs +11 -0
- package/node_modules/typebox/build/type/action/_remove_readonly.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_remove_readonly.mjs +11 -0
- package/node_modules/typebox/build/type/action/conditional.d.mts +2 -3
- package/node_modules/typebox/build/type/action/conditional.mjs +2 -1
- package/node_modules/typebox/build/type/action/index.d.mts +7 -4
- package/node_modules/typebox/build/type/action/index.mjs +7 -4
- package/node_modules/typebox/build/type/action/mapped.d.mts +2 -3
- package/node_modules/typebox/build/type/action/mapped.mjs +2 -1
- package/node_modules/typebox/build/type/action/module.d.mts +8 -7
- package/node_modules/typebox/build/type/action/module.mjs +7 -6
- package/node_modules/typebox/build/type/action/readonly_object.mjs +3 -0
- package/node_modules/typebox/build/type/action/with.d.mts +11 -0
- package/node_modules/typebox/build/type/action/with.mjs +11 -0
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +1 -1
- package/node_modules/typebox/build/type/engine/call/instantiate.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/call/instantiate.mjs +3 -2
- package/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs +2 -2
- package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.d.mts +3 -4
- package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.mjs +2 -1
- package/node_modules/typebox/build/type/engine/cyclic/candidates.d.mts +2 -3
- package/node_modules/typebox/build/type/engine/cyclic/candidates.mjs +3 -6
- package/node_modules/typebox/build/type/engine/cyclic/check.d.mts +6 -9
- package/node_modules/typebox/build/type/engine/cyclic/check.mjs +10 -16
- package/node_modules/typebox/build/type/engine/cyclic/dependencies.d.mts +1 -4
- package/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs +9 -15
- package/node_modules/typebox/build/type/engine/cyclic/extends.d.mts +1 -4
- package/node_modules/typebox/build/type/engine/cyclic/extends.mjs +8 -14
- package/node_modules/typebox/build/type/engine/cyclic/instantiate.d.mts +2 -5
- package/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs +3 -2
- package/node_modules/typebox/build/type/engine/enum/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/enum/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +1 -2
- package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +2 -6
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +10 -6
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +10 -6
- package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +2 -1
- package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +3 -3
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +17 -5
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +34 -8
- package/node_modules/typebox/build/type/engine/exclude/operation.d.mts +5 -6
- package/node_modules/typebox/build/type/engine/exclude/operation.mjs +11 -12
- package/node_modules/typebox/build/type/engine/extract/operation.d.mts +5 -6
- package/node_modules/typebox/build/type/engine/extract/operation.mjs +11 -12
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +14 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.mjs +14 -0
- package/node_modules/typebox/build/type/engine/index.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/index.mjs +2 -2
- package/node_modules/typebox/build/type/engine/indexable/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/indexable/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/indexable/from_enum.d.mts +3 -3
- package/node_modules/typebox/build/type/engine/indexable/from_enum.mjs +4 -4
- package/node_modules/typebox/build/type/engine/indexable/from_template_literal.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/indexable/from_template_literal.mjs +3 -3
- package/node_modules/typebox/build/type/engine/indexable/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/indexable/from_type.mjs +9 -6
- package/node_modules/typebox/build/type/engine/indexed/instantiate.d.mts +2 -1
- package/node_modules/typebox/build/type/engine/indexed/instantiate.mjs +5 -2
- package/node_modules/typebox/build/type/engine/instantiate.d.mts +44 -31
- package/node_modules/typebox/build/type/engine/instantiate.mjs +82 -83
- package/node_modules/typebox/build/type/engine/interface/instantiate.d.mts +3 -6
- package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.mjs +3 -3
- package/node_modules/typebox/build/type/engine/keyof/instantiate.d.mts +2 -1
- package/node_modules/typebox/build/type/engine/keyof/instantiate.mjs +5 -1
- package/node_modules/typebox/build/type/engine/mapped/mapped_operation.d.mts +4 -4
- package/node_modules/typebox/build/type/engine/mapped/mapped_operation.mjs +3 -3
- package/node_modules/typebox/build/type/engine/mapped/mapped_variants.d.mts +5 -4
- package/node_modules/typebox/build/type/engine/mapped/mapped_variants.mjs +10 -5
- package/node_modules/typebox/build/type/engine/module/instantiate.d.mts +7 -9
- package/node_modules/typebox/build/type/engine/module/instantiate.mjs +17 -15
- package/node_modules/typebox/build/type/engine/object/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/object/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/object/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/object/from_type.mjs +8 -5
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +14 -0
- package/node_modules/typebox/build/type/engine/optional/instantiate_remove.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/optional/instantiate_remove.mjs +14 -0
- package/node_modules/typebox/build/type/engine/parameters/instantiate.d.mts +3 -4
- package/node_modules/typebox/build/type/engine/parameters/instantiate.mjs +2 -1
- package/node_modules/typebox/build/type/engine/partial/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/partial/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/partial/from_intersect.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/partial/from_intersect.mjs +3 -2
- package/node_modules/typebox/build/type/engine/partial/from_object.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/partial/from_object.mjs +2 -2
- package/node_modules/typebox/build/type/engine/partial/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/partial/from_type.mjs +7 -4
- package/node_modules/typebox/build/type/engine/priority/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/priority/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/priority/priority.d.mts +20 -0
- package/node_modules/typebox/build/type/engine/priority/priority.mjs +28 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +14 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.mjs +14 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_array.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_array.mjs +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs +3 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_object.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_object.mjs +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/readonly_object/from_type.mjs +8 -5
- package/node_modules/typebox/build/type/engine/record/from_key_enum.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/record/from_key_enum.mjs +2 -2
- package/node_modules/typebox/build/type/engine/record/from_key_template_literal.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs +2 -2
- package/node_modules/typebox/build/type/engine/ref/instantiate.d.mts +3 -3
- package/node_modules/typebox/build/type/engine/ref/instantiate.mjs +6 -6
- package/node_modules/typebox/build/type/engine/required/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/required/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/required/from_intersect.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/required/from_intersect.mjs +3 -2
- package/node_modules/typebox/build/type/engine/required/from_object.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/required/from_object.mjs +2 -2
- package/node_modules/typebox/build/type/engine/required/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/required/from_type.mjs +7 -4
- package/node_modules/typebox/build/type/engine/template_literal/decode.mjs +3 -3
- package/node_modules/typebox/build/type/engine/template_literal/encode.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/template_literal/encode.mjs +6 -6
- package/node_modules/typebox/build/type/engine/template_literal/is_finite.mjs +1 -1
- package/node_modules/typebox/build/type/engine/template_literal/is_pattern.mjs +1 -0
- package/node_modules/typebox/build/type/engine/this/expand_this.d.mts +1 -4
- package/node_modules/typebox/build/type/engine/this/expand_this.mjs +7 -13
- package/node_modules/typebox/build/type/engine/with/instantiate.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/{options → with}/instantiate.mjs +5 -5
- package/node_modules/typebox/build/type/extends/dependent.d.mts +6 -0
- package/node_modules/typebox/build/type/extends/dependent.mjs +6 -0
- package/node_modules/typebox/build/type/extends/enum.d.mts +4 -4
- package/node_modules/typebox/build/type/extends/enum.mjs +3 -2
- package/node_modules/typebox/build/type/extends/extends_left.d.mts +5 -7
- package/node_modules/typebox/build/type/extends/extends_left.mjs +24 -27
- package/node_modules/typebox/build/type/extends/extends_right.d.mts +7 -5
- package/node_modules/typebox/build/type/extends/extends_right.mjs +20 -15
- package/node_modules/typebox/build/type/extends/inference.mjs +1 -1
- package/node_modules/typebox/build/type/extends/object.d.mts +8 -1
- package/node_modules/typebox/build/type/extends/object.mjs +25 -3
- package/node_modules/typebox/build/type/extends/parameters.mjs +2 -2
- package/node_modules/typebox/build/type/extends/record.d.mts +13 -0
- package/node_modules/typebox/build/type/extends/record.mjs +23 -0
- package/node_modules/typebox/build/type/extends/template_literal.d.mts +3 -3
- package/node_modules/typebox/build/type/extends/template_literal.mjs +3 -3
- package/node_modules/typebox/build/type/extends/tuple.d.mts +3 -6
- package/node_modules/typebox/build/type/extends/tuple.mjs +6 -5
- package/node_modules/typebox/build/type/extends/union.mjs +2 -2
- package/node_modules/typebox/build/type/script/mapping.d.mts +86 -98
- package/node_modules/typebox/build/type/script/mapping.mjs +95 -92
- package/node_modules/typebox/build/type/script/parser.d.mts +42 -40
- package/node_modules/typebox/build/type/script/parser.mjs +23 -22
- package/node_modules/typebox/build/type/script/script.d.mts +3 -4
- package/node_modules/typebox/build/type/script/script.mjs +3 -2
- package/node_modules/typebox/build/type/script/token/internal/guard.d.mts +1 -1
- package/node_modules/typebox/build/type/script/token/internal/guard.mjs +1 -1
- package/node_modules/typebox/build/type/script/token/internal/take.mjs +1 -1
- package/node_modules/typebox/build/type/script/token/until.mjs +2 -2
- package/node_modules/typebox/build/type/types/_codec.d.mts +12 -12
- package/node_modules/typebox/build/type/types/_codec.mjs +0 -1
- package/node_modules/typebox/build/type/types/_immutable.d.mts +2 -9
- package/node_modules/typebox/build/type/types/_immutable.mjs +2 -10
- package/node_modules/typebox/build/type/types/_optional.d.mts +2 -9
- package/node_modules/typebox/build/type/types/_optional.mjs +2 -11
- package/node_modules/typebox/build/type/types/_readonly.d.mts +2 -9
- package/node_modules/typebox/build/type/types/_readonly.mjs +2 -10
- package/node_modules/typebox/build/type/types/_refine.d.mts +8 -10
- package/node_modules/typebox/build/type/types/_refine.mjs +1 -2
- package/node_modules/typebox/build/type/types/call.d.mts +3 -3
- package/node_modules/typebox/build/type/types/call.mjs +3 -2
- package/node_modules/typebox/build/type/types/deferred.d.mts +1 -0
- package/node_modules/typebox/build/type/types/deferred.mjs +1 -1
- package/node_modules/typebox/build/type/types/dependent.d.mts +17 -0
- package/node_modules/typebox/build/type/types/dependent.mjs +24 -0
- package/node_modules/typebox/build/type/types/enum.d.mts +3 -1
- package/node_modules/typebox/build/type/types/enum.mjs +5 -0
- package/node_modules/typebox/build/type/types/index.d.mts +1 -4
- package/node_modules/typebox/build/type/types/index.mjs +1 -4
- package/node_modules/typebox/build/type/types/number.d.mts +1 -1
- package/node_modules/typebox/build/type/types/number.mjs +1 -1
- package/node_modules/typebox/build/type/types/record.d.mts +13 -7
- package/node_modules/typebox/build/type/types/record.mjs +15 -9
- package/node_modules/typebox/build/type/types/static.d.mts +2 -5
- package/node_modules/typebox/build/typebox.d.mts +3 -7
- package/node_modules/typebox/build/typebox.mjs +3 -7
- package/node_modules/typebox/build/value/clean/clean.mjs +4 -2
- package/node_modules/typebox/build/value/clean/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/value/clean/from_type.mjs +8 -10
- package/node_modules/typebox/build/value/clean/from_union.d.mts +1 -1
- package/node_modules/typebox/build/value/clean/from_union.mjs +1 -2
- package/node_modules/typebox/build/value/clone/clone.mjs +2 -73
- package/node_modules/typebox/build/value/codec/decode.mjs +4 -2
- package/node_modules/typebox/build/value/codec/encode.mjs +4 -2
- package/node_modules/typebox/build/value/codec/from_array.mjs +1 -4
- package/node_modules/typebox/build/value/codec/from_object.mjs +1 -4
- package/node_modules/typebox/build/value/codec/from_record.mjs +2 -7
- package/node_modules/typebox/build/value/codec/from_tuple.mjs +1 -4
- package/node_modules/typebox/build/value/codec/from_union.mjs +2 -3
- package/node_modules/typebox/build/value/convert/from_enum.mjs +3 -4
- package/node_modules/typebox/build/value/convert/from_template_literal.d.mts +1 -1
- package/node_modules/typebox/build/value/convert/from_template_literal.mjs +2 -3
- package/node_modules/typebox/build/value/convert/from_type.mjs +19 -21
- package/node_modules/typebox/build/value/create/from_enum.mjs +2 -2
- package/node_modules/typebox/build/value/create/from_type.mjs +23 -31
- package/node_modules/typebox/build/value/default/from_object.mjs +1 -1
- package/node_modules/typebox/build/value/default/from_type.mjs +8 -10
- package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
- package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
- package/node_modules/typebox/build/value/index.d.mts +0 -1
- package/node_modules/typebox/build/value/index.mjs +0 -1
- package/node_modules/typebox/build/value/repair/from_enum.mjs +2 -3
- package/node_modules/typebox/build/value/repair/from_type.mjs +24 -22
- package/node_modules/typebox/build/value/shared/union_priority_sort.d.mts +6 -2
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +62 -26
- package/node_modules/typebox/build/value/value.d.mts +0 -1
- package/node_modules/typebox/build/value/value.mjs +0 -1
- package/node_modules/typebox/package.json +33 -33
- package/node_modules/typebox/readme.md +117 -103
- package/package.json +20 -10
- package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.d.ts +0 -3
- package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.d.ts.map +0 -1
- package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.js.map +0 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.d.ts +0 -26
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js +0 -100
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js.map +0 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts +0 -42
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js +0 -286
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js.map +0 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.d.ts +0 -18
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js +0 -44
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js.map +0 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts +0 -33
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js +0 -163
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js.map +0 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.d.ts +0 -11
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js +0 -39
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js.map +0 -1
- package/node_modules/typebox/build/schema/engine/_guard.d.mts +0 -6
- package/node_modules/typebox/build/schema/engine/_guard.mjs +0 -26
- package/node_modules/typebox/build/schema/types/_guard.d.mts +0 -10
- package/node_modules/typebox/build/schema/types/_guard.mjs +0 -16
- package/node_modules/typebox/build/type/action/_optional.d.mts +0 -19
- package/node_modules/typebox/build/type/action/_optional.mjs +0 -40
- package/node_modules/typebox/build/type/action/_readonly.d.mts +0 -19
- package/node_modules/typebox/build/type/action/_readonly.mjs +0 -40
- package/node_modules/typebox/build/type/action/awaited.d.mts +0 -15
- package/node_modules/typebox/build/type/action/awaited.mjs +0 -15
- package/node_modules/typebox/build/type/action/options.d.mts +0 -11
- package/node_modules/typebox/build/type/action/options.mjs +0 -11
- package/node_modules/typebox/build/type/engine/awaited/instantiate.d.mts +0 -11
- package/node_modules/typebox/build/type/engine/awaited/instantiate.mjs +0 -20
- package/node_modules/typebox/build/type/engine/enum/enum_to_union.d.mts +0 -14
- package/node_modules/typebox/build/type/engine/enum/enum_to_union.mjs +0 -24
- package/node_modules/typebox/build/type/engine/options/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/options/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/options/instantiate.d.mts +0 -8
- package/node_modules/typebox/build/type/extends/async_iterator.d.mts +0 -7
- package/node_modules/typebox/build/type/extends/async_iterator.mjs +0 -9
- package/node_modules/typebox/build/type/extends/iterator.d.mts +0 -7
- package/node_modules/typebox/build/type/extends/iterator.mjs +0 -9
- package/node_modules/typebox/build/type/extends/promise.d.mts +0 -7
- package/node_modules/typebox/build/type/extends/promise.mjs +0 -9
- package/node_modules/typebox/build/type/types/async_iterator.d.mts +0 -20
- package/node_modules/typebox/build/type/types/async_iterator.mjs +0 -28
- package/node_modules/typebox/build/type/types/base.d.mts +0 -50
- package/node_modules/typebox/build/type/types/base.mjs +0 -84
- package/node_modules/typebox/build/type/types/iterator.d.mts +0 -20
- package/node_modules/typebox/build/type/types/iterator.mjs +0 -28
- package/node_modules/typebox/build/type/types/promise.d.mts +0 -21
- package/node_modules/typebox/build/type/types/promise.mjs +0 -29
- package/node_modules/typebox/build/value/clean/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/clean/from_base.mjs +0 -4
- package/node_modules/typebox/build/value/convert/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/convert/from_base.mjs +0 -4
- package/node_modules/typebox/build/value/create/from_async_iterator.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_async_iterator.mjs +0 -5
- package/node_modules/typebox/build/value/create/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_base.mjs +0 -4
- package/node_modules/typebox/build/value/create/from_iterator.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_iterator.mjs +0 -5
- package/node_modules/typebox/build/value/create/from_promise.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_promise.mjs +0 -5
- package/node_modules/typebox/build/value/default/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/default/from_base.mjs +0 -5
- package/node_modules/typebox/build/value/mutate/error.d.mts +0 -3
- package/node_modules/typebox/build/value/mutate/error.mjs +0 -6
- package/node_modules/typebox/build/value/mutate/from_array.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_array.mjs +0 -16
- package/node_modules/typebox/build/value/mutate/from_object.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_object.mjs +0 -40
- package/node_modules/typebox/build/value/mutate/from_unknown.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_unknown.mjs +0 -7
- package/node_modules/typebox/build/value/mutate/from_value.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_value.mjs +0 -12
- package/node_modules/typebox/build/value/mutate/index.d.mts +0 -1
- package/node_modules/typebox/build/value/mutate/index.mjs +0 -1
- package/node_modules/typebox/build/value/mutate/mutate.d.mts +0 -11
- package/node_modules/typebox/build/value/mutate/mutate.mjs +0 -41
- package/node_modules/typebox/build/value/repair/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/repair/from_base.mjs +0 -8
- /package/node_modules/typebox/build/type/engine/{awaited → with}/index.d.mts +0 -0
- /package/node_modules/typebox/build/type/engine/{awaited → with}/index.mjs +0 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { SessionError, toError } from "../types.js";
|
|
2
|
+
import { createArraySessionReader } from "./array-session-reader.js";
|
|
3
|
+
import { readSessionEntriesForFork } from "./fork.js";
|
|
4
|
+
import { KeyedOperationQueue } from "./keyed-operation-queue.js";
|
|
5
|
+
import { createSessionId, createTimestamp, getFileSystemResultOrThrow } from "./repository.js";
|
|
6
|
+
const DEFAULT_MAX_CONCURRENT_OPERATIONS = 4;
|
|
7
|
+
function invalidSession(path, message, cause) {
|
|
8
|
+
return new SessionError("invalid_session", `Invalid JSONL session file ${path}: ${message}`, cause);
|
|
9
|
+
}
|
|
10
|
+
function invalidEntry(path, line, message, cause) {
|
|
11
|
+
return new SessionError("invalid_entry", `Invalid JSONL session file ${path}: line ${line} ${message}`, cause);
|
|
12
|
+
}
|
|
13
|
+
function parseHeader(line, path) {
|
|
14
|
+
let value;
|
|
15
|
+
try {
|
|
16
|
+
value = JSON.parse(line);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
throw invalidSession(path, "first line is not a valid session header", toError(error));
|
|
20
|
+
}
|
|
21
|
+
if (typeof value !== "object" || value === null)
|
|
22
|
+
throw invalidSession(path, "first line is not a valid session header");
|
|
23
|
+
const header = value;
|
|
24
|
+
if (header.type !== "session" || header.version !== 3) {
|
|
25
|
+
throw invalidSession(path, header.type === "session" ? "unsupported session version" : "first line is not a valid session header");
|
|
26
|
+
}
|
|
27
|
+
if (typeof header.id !== "string" || !header.id)
|
|
28
|
+
throw invalidSession(path, "session header is missing id");
|
|
29
|
+
if (typeof header.timestamp !== "string" || !header.timestamp)
|
|
30
|
+
throw invalidSession(path, "session header is missing timestamp");
|
|
31
|
+
if (typeof header.cwd !== "string" || !header.cwd)
|
|
32
|
+
throw invalidSession(path, "session header is missing cwd");
|
|
33
|
+
if (header.parentSession !== undefined && typeof header.parentSession !== "string") {
|
|
34
|
+
throw invalidSession(path, "session header parentSession must be a string");
|
|
35
|
+
}
|
|
36
|
+
if (header.metadata !== undefined &&
|
|
37
|
+
(typeof header.metadata !== "object" || header.metadata === null || Array.isArray(header.metadata))) {
|
|
38
|
+
throw invalidSession(path, "session header metadata must be an object");
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
type: "session",
|
|
42
|
+
version: 3,
|
|
43
|
+
id: header.id,
|
|
44
|
+
timestamp: header.timestamp,
|
|
45
|
+
cwd: header.cwd,
|
|
46
|
+
parentSession: header.parentSession,
|
|
47
|
+
metadata: header.metadata,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function parseEntry(line, path, lineNumber) {
|
|
51
|
+
let value;
|
|
52
|
+
try {
|
|
53
|
+
value = JSON.parse(line);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
throw invalidEntry(path, lineNumber, "is not valid JSON", toError(error));
|
|
57
|
+
}
|
|
58
|
+
if (typeof value !== "object" || value === null)
|
|
59
|
+
throw invalidEntry(path, lineNumber, "is not a valid session entry");
|
|
60
|
+
const entry = value;
|
|
61
|
+
if (typeof entry.type !== "string")
|
|
62
|
+
throw invalidEntry(path, lineNumber, "is missing entry type");
|
|
63
|
+
if (typeof entry.id !== "string" || !entry.id)
|
|
64
|
+
throw invalidEntry(path, lineNumber, "is missing entry id");
|
|
65
|
+
if (entry.parentId !== null && typeof entry.parentId !== "string")
|
|
66
|
+
throw invalidEntry(path, lineNumber, "has invalid parentId");
|
|
67
|
+
if (typeof entry.timestamp !== "string" || !entry.timestamp)
|
|
68
|
+
throw invalidEntry(path, lineNumber, "is missing timestamp");
|
|
69
|
+
if (entry.type === "leaf" && entry.targetId !== null && typeof entry.targetId !== "string") {
|
|
70
|
+
throw invalidEntry(path, lineNumber, "has invalid targetId");
|
|
71
|
+
}
|
|
72
|
+
return entry;
|
|
73
|
+
}
|
|
74
|
+
function metadataFromHeader(header, path) {
|
|
75
|
+
return {
|
|
76
|
+
id: header.id,
|
|
77
|
+
createdAt: header.timestamp,
|
|
78
|
+
cwd: header.cwd,
|
|
79
|
+
path,
|
|
80
|
+
parentSessionPath: header.parentSession,
|
|
81
|
+
metadata: header.metadata,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export async function loadJsonlSessionMetadata(fs, path) {
|
|
85
|
+
const lines = getFileSystemResultOrThrow(await fs.readTextLines(path, { maxLines: 1 }), `Failed to read session header ${path}`);
|
|
86
|
+
if (!lines[0]?.trim())
|
|
87
|
+
throw invalidSession(path, "missing session header");
|
|
88
|
+
return metadataFromHeader(parseHeader(lines[0], path), path);
|
|
89
|
+
}
|
|
90
|
+
async function loadJsonlSession(fs, path) {
|
|
91
|
+
const content = getFileSystemResultOrThrow(await fs.readTextFile(path), `Failed to read session ${path}`);
|
|
92
|
+
const lines = content.split("\n").filter((line) => line.trim());
|
|
93
|
+
if (lines.length === 0)
|
|
94
|
+
throw invalidSession(path, "missing session header");
|
|
95
|
+
const header = parseHeader(lines[0], path);
|
|
96
|
+
const entries = lines.slice(1).map((line, index) => parseEntry(line, path, index + 2));
|
|
97
|
+
const entryIds = new Set();
|
|
98
|
+
for (const entry of entries) {
|
|
99
|
+
if (entryIds.has(entry.id))
|
|
100
|
+
throw invalidSession(path, `duplicate entry id ${entry.id}`);
|
|
101
|
+
entryIds.add(entry.id);
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
metadata: metadataFromHeader(header, path),
|
|
105
|
+
entries,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function encodeCwd(cwd) {
|
|
109
|
+
return `--${cwd.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
|
|
110
|
+
}
|
|
111
|
+
function createDocumentDescriptor(options) {
|
|
112
|
+
const id = options.id ?? createSessionId();
|
|
113
|
+
if (!id)
|
|
114
|
+
throw new SessionError("invalid_session", "Session id cannot be empty");
|
|
115
|
+
let encodedId;
|
|
116
|
+
try {
|
|
117
|
+
encodedId = encodeURIComponent(id);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
throw new SessionError("invalid_session", `Invalid session id ${JSON.stringify(id)}`, toError(error));
|
|
121
|
+
}
|
|
122
|
+
const timestamp = createTimestamp();
|
|
123
|
+
const fileName = `${timestamp.replace(/[:.]/g, "-")}_${encodedId}.jsonl`;
|
|
124
|
+
return {
|
|
125
|
+
id,
|
|
126
|
+
timestamp,
|
|
127
|
+
fileName,
|
|
128
|
+
operationKey: `document:${JSON.stringify([encodeCwd(options.cwd), fileName])}`,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
class JsonlSessionStore {
|
|
132
|
+
constructor(options) {
|
|
133
|
+
this.entryIdsByPath = new Map();
|
|
134
|
+
this.entriesByPath = new Map();
|
|
135
|
+
this.operationKeysByPath = new Map();
|
|
136
|
+
this.disposed = false;
|
|
137
|
+
this.fs = options.fs;
|
|
138
|
+
this.sessionsRootInput = options.sessionsRoot;
|
|
139
|
+
this.operations = new KeyedOperationQueue({
|
|
140
|
+
maxConcurrentOperations: options.maxConcurrentOperations ?? DEFAULT_MAX_CONCURRENT_OPERATIONS,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
create(options) {
|
|
144
|
+
this.assertOpen();
|
|
145
|
+
const descriptor = createDocumentDescriptor(options);
|
|
146
|
+
return this.operations.enqueue(descriptor.operationKey, () => this.createDocument(descriptor, options, options.parentSessionPath, options.metadata, []));
|
|
147
|
+
}
|
|
148
|
+
load(metadata) {
|
|
149
|
+
this.assertOpen();
|
|
150
|
+
return this.operations.enqueue(this.operationKey(metadata), () => this.loadDocument(metadata));
|
|
151
|
+
}
|
|
152
|
+
async loadDocument(metadata) {
|
|
153
|
+
if (!getFileSystemResultOrThrow(await this.fs.exists(metadata.path), `Failed to check session ${metadata.path}`)) {
|
|
154
|
+
throw new SessionError("not_found", `Session not found: ${metadata.path}`);
|
|
155
|
+
}
|
|
156
|
+
const document = await loadJsonlSession(this.fs, metadata.path);
|
|
157
|
+
this.entriesByPath.set(metadata.path, document.entries);
|
|
158
|
+
this.entryIdsByPath.set(metadata.path, new Set(document.entries.map((entry) => entry.id)));
|
|
159
|
+
return this.reader(document.metadata);
|
|
160
|
+
}
|
|
161
|
+
list(options = {}) {
|
|
162
|
+
this.assertOpen();
|
|
163
|
+
return this.operations.enqueueBarrier(() => this.listSessions(options));
|
|
164
|
+
}
|
|
165
|
+
async listSessions(options) {
|
|
166
|
+
const dirs = options.cwd ? [await this.getSessionDir(options.cwd)] : await this.listSessionDirs();
|
|
167
|
+
const sessions = [];
|
|
168
|
+
for (const dir of dirs) {
|
|
169
|
+
if (!getFileSystemResultOrThrow(await this.fs.exists(dir), `Failed to check session directory ${dir}`))
|
|
170
|
+
continue;
|
|
171
|
+
const files = getFileSystemResultOrThrow(await this.fs.listDir(dir), `Failed to list sessions in ${dir}`).filter((file) => file.kind !== "directory" && file.name.endsWith(".jsonl"));
|
|
172
|
+
for (const file of files)
|
|
173
|
+
sessions.push(await loadJsonlSessionMetadata(this.fs, file.path));
|
|
174
|
+
}
|
|
175
|
+
return sessions.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
|
|
176
|
+
}
|
|
177
|
+
appendEntry(metadata, entry) {
|
|
178
|
+
this.assertOpen();
|
|
179
|
+
return this.operations.enqueue(this.operationKey(metadata), async () => {
|
|
180
|
+
if (!getFileSystemResultOrThrow(await this.fs.exists(metadata.path), `Failed to check session ${metadata.path}`)) {
|
|
181
|
+
throw new SessionError("not_found", `Session not found: ${metadata.path}`);
|
|
182
|
+
}
|
|
183
|
+
let entryIds = this.entryIdsByPath.get(metadata.path);
|
|
184
|
+
if (!entryIds) {
|
|
185
|
+
await this.loadDocument(metadata);
|
|
186
|
+
entryIds = this.entryIdsByPath.get(metadata.path);
|
|
187
|
+
}
|
|
188
|
+
if (entryIds.has(entry.id))
|
|
189
|
+
throw new SessionError("invalid_entry", `Entry ${entry.id} already exists`);
|
|
190
|
+
getFileSystemResultOrThrow(await this.fs.appendFile(metadata.path, `${JSON.stringify(entry)}\n`), `Failed to append session entry ${entry.id}`);
|
|
191
|
+
entryIds.add(entry.id);
|
|
192
|
+
this.entryIdsByPath.set(metadata.path, entryIds);
|
|
193
|
+
this.entriesByPath.get(metadata.path).push(entry);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
delete(metadata) {
|
|
197
|
+
this.assertOpen();
|
|
198
|
+
return this.operations.enqueue(this.operationKey(metadata), async () => {
|
|
199
|
+
getFileSystemResultOrThrow(await this.fs.remove(metadata.path, { force: true }), `Failed to delete session ${metadata.path}`);
|
|
200
|
+
this.entryIdsByPath.delete(metadata.path);
|
|
201
|
+
this.entriesByPath.delete(metadata.path);
|
|
202
|
+
this.operationKeysByPath.delete(metadata.path);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
fork(source, options, selection) {
|
|
206
|
+
this.assertOpen();
|
|
207
|
+
const descriptor = createDocumentDescriptor(options);
|
|
208
|
+
const sourceEntries = this.operations.enqueue(this.operationKey(source), async () => {
|
|
209
|
+
if (!getFileSystemResultOrThrow(await this.fs.exists(source.path), `Failed to check session ${source.path}`)) {
|
|
210
|
+
throw new SessionError("not_found", `Session not found: ${source.path}`);
|
|
211
|
+
}
|
|
212
|
+
const document = await loadJsonlSession(this.fs, source.path);
|
|
213
|
+
this.entriesByPath.set(source.path, document.entries);
|
|
214
|
+
this.entryIdsByPath.set(source.path, new Set(document.entries.map((entry) => entry.id)));
|
|
215
|
+
return readSessionEntriesForFork(createArraySessionReader(document.metadata, () => document.entries), selection);
|
|
216
|
+
});
|
|
217
|
+
return this.operations.enqueue(descriptor.operationKey, async () => this.createDocument(descriptor, options, options.parentSessionPath ?? source.path, options.metadata ?? source.metadata, await sourceEntries));
|
|
218
|
+
}
|
|
219
|
+
async [Symbol.asyncDispose]() {
|
|
220
|
+
if (!this.disposePromise) {
|
|
221
|
+
this.disposed = true;
|
|
222
|
+
this.disposePromise = this.operations.drain();
|
|
223
|
+
}
|
|
224
|
+
await this.disposePromise;
|
|
225
|
+
}
|
|
226
|
+
assertOpen() {
|
|
227
|
+
if (this.disposed)
|
|
228
|
+
throw new SessionError("storage", "JSONL session store is disposed");
|
|
229
|
+
}
|
|
230
|
+
operationKey(metadata) {
|
|
231
|
+
return this.operationKeysByPath.get(metadata.path) ?? metadata.path;
|
|
232
|
+
}
|
|
233
|
+
async createDocument(descriptor, options, parentSessionPath, metadata, entries) {
|
|
234
|
+
const dir = await this.getSessionDir(options.cwd);
|
|
235
|
+
getFileSystemResultOrThrow(await this.fs.createDir(dir, { recursive: true }), `Failed to create session directory ${dir}`);
|
|
236
|
+
const path = getFileSystemResultOrThrow(await this.fs.joinPath([dir, descriptor.fileName]), `Failed to resolve session file path for ${descriptor.id}`);
|
|
237
|
+
if (getFileSystemResultOrThrow(await this.fs.exists(path), `Failed to check session ${path}`)) {
|
|
238
|
+
throw new SessionError("invalid_session", `Session already exists: ${path}`);
|
|
239
|
+
}
|
|
240
|
+
const header = {
|
|
241
|
+
type: "session",
|
|
242
|
+
version: 3,
|
|
243
|
+
id: descriptor.id,
|
|
244
|
+
timestamp: descriptor.timestamp,
|
|
245
|
+
cwd: options.cwd,
|
|
246
|
+
parentSession: parentSessionPath,
|
|
247
|
+
metadata,
|
|
248
|
+
};
|
|
249
|
+
const content = [JSON.stringify(header), ...entries.map((entry) => JSON.stringify(entry)), ""].join("\n");
|
|
250
|
+
getFileSystemResultOrThrow(await this.fs.writeFile(path, content), `Failed to create session ${path}`);
|
|
251
|
+
const storedEntries = [...entries];
|
|
252
|
+
this.entriesByPath.set(path, storedEntries);
|
|
253
|
+
this.entryIdsByPath.set(path, new Set(storedEntries.map((entry) => entry.id)));
|
|
254
|
+
this.operationKeysByPath.set(path, descriptor.operationKey);
|
|
255
|
+
return this.reader(metadataFromHeader(header, path));
|
|
256
|
+
}
|
|
257
|
+
reader(metadata) {
|
|
258
|
+
const reader = createArraySessionReader(metadata, () => {
|
|
259
|
+
const entries = this.entriesByPath.get(metadata.path);
|
|
260
|
+
if (!entries)
|
|
261
|
+
throw new SessionError("not_found", `Session not found: ${metadata.path}`);
|
|
262
|
+
return entries;
|
|
263
|
+
});
|
|
264
|
+
const operationKey = this.operationKey(metadata);
|
|
265
|
+
return {
|
|
266
|
+
metadata: reader.metadata,
|
|
267
|
+
readHead: () => {
|
|
268
|
+
this.assertOpen();
|
|
269
|
+
return this.operations.enqueue(operationKey, () => reader.readHead());
|
|
270
|
+
},
|
|
271
|
+
readEntry: (id) => {
|
|
272
|
+
this.assertOpen();
|
|
273
|
+
return this.operations.enqueue(operationKey, () => reader.readEntry(id));
|
|
274
|
+
},
|
|
275
|
+
readEntries: (options) => {
|
|
276
|
+
this.assertOpen();
|
|
277
|
+
return this.operations.enqueue(operationKey, () => reader.readEntries(options));
|
|
278
|
+
},
|
|
279
|
+
readPathToRootOrCompaction: (leafId) => {
|
|
280
|
+
this.assertOpen();
|
|
281
|
+
return this.operations.enqueue(operationKey, () => reader.readPathToRootOrCompaction(leafId));
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
async getSessionsRoot() {
|
|
286
|
+
this.sessionsRoot ??= getFileSystemResultOrThrow(await this.fs.absolutePath(this.sessionsRootInput), `Failed to resolve sessions root ${this.sessionsRootInput}`);
|
|
287
|
+
return this.sessionsRoot;
|
|
288
|
+
}
|
|
289
|
+
async getSessionDir(cwd) {
|
|
290
|
+
return getFileSystemResultOrThrow(await this.fs.joinPath([await this.getSessionsRoot(), encodeCwd(cwd)]), `Failed to resolve session directory for ${cwd}`);
|
|
291
|
+
}
|
|
292
|
+
async listSessionDirs() {
|
|
293
|
+
const root = await this.getSessionsRoot();
|
|
294
|
+
if (!getFileSystemResultOrThrow(await this.fs.exists(root), `Failed to check sessions root ${root}`))
|
|
295
|
+
return [];
|
|
296
|
+
return getFileSystemResultOrThrow(await this.fs.listDir(root), `Failed to list sessions root ${root}`)
|
|
297
|
+
.filter((entry) => entry.kind === "directory")
|
|
298
|
+
.map((entry) => entry.path);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
export function createJsonlSessionStore(options) {
|
|
302
|
+
return new JsonlSessionStore(options);
|
|
303
|
+
}
|
|
304
|
+
//# sourceMappingURL=jsonl-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonl-store.js","sourceRoot":"","sources":["../../../src/harness/session/jsonl-store.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAwB/F,MAAM,iCAAiC,GAAG,CAAC,CAAC;AAwB5C,SAAS,cAAc,CAAC,IAAY,EAAE,OAAe,EAAE,KAAa;IACnE,OAAO,IAAI,YAAY,CAAC,iBAAiB,EAAE,8BAA8B,IAAI,KAAK,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;AACrG,CAAC;AAED,SAAS,YAAY,CAAC,IAAY,EAAE,IAAY,EAAE,OAAe,EAAE,KAAa;IAC/E,OAAO,IAAI,YAAY,CAAC,eAAe,EAAE,8BAA8B,IAAI,UAAU,IAAI,IAAI,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;AAChH,CAAC;AAED,SAAS,WAAW,CAAC,IAAY,EAAE,IAAY;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C/C,MAAM,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAClD,mCAAmC,IAAI,CAAC,iBAAiB,EAAE,CAC3D,CAAC;QACF,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,GAAW;QACtC,OAAO,0BAA0B,CAChC,MAAM,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,MAAM,IAAI,CAAC,eAAe,EAAE,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EACtE,2CAA2C,GAAG,EAAE,CAChD,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,eAAe;QAC5B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;QAC1C,IAAI,CAAC,0BAA0B,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,iCAAiC,IAAI,EAAE,CAAC;YAAE,OAAO,EAAE,CAAC;QAChH,OAAO,0BAA0B,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,gCAAgC,IAAI,EAAE,CAAC;aACpG,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC;aAC7C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;CACD;AAED,MAAM,UAAU,uBAAuB,CACtC,OAAiC;IAEjC,OAAO,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import type {\n\tFileSystem,\n\tJsonlSessionCreateOptions,\n\tJsonlSessionListOptions,\n\tJsonlSessionMetadata,\n\tSessionForkSelection,\n\tSessionReader,\n\tSessionStore,\n\tSessionTreeEntry,\n} from \"../types.ts\";\nimport { SessionError, toError } from \"../types.ts\";\nimport { createArraySessionReader } from \"./array-session-reader.ts\";\nimport { readSessionEntriesForFork } from \"./fork.ts\";\nimport { KeyedOperationQueue } from \"./keyed-operation-queue.ts\";\nimport { createSessionId, createTimestamp, getFileSystemResultOrThrow } from \"./repository.ts\";\n\nexport interface JsonlSessionStoreOptions {\n\tfs: JsonlSessionStoreFileSystem;\n\tsessionsRoot: string;\n\t/** Maximum active operations across session keys. Defaults to 4. */\n\tmaxConcurrentOperations?: number;\n}\nexport type JsonlSessionStoreFileSystem = Pick<\n\tFileSystem,\n\t| \"absolutePath\"\n\t| \"joinPath\"\n\t| \"readTextFile\"\n\t| \"readTextLines\"\n\t| \"writeFile\"\n\t| \"appendFile\"\n\t| \"listDir\"\n\t| \"exists\"\n\t| \"createDir\"\n\t| \"remove\"\n>;\n\ntype JsonlSessionFileSystem = Pick<FileSystem, \"readTextFile\" | \"readTextLines\" | \"writeFile\" | \"appendFile\">;\n\nconst DEFAULT_MAX_CONCURRENT_OPERATIONS = 4;\n\ninterface SessionHeader {\n\ttype: \"session\";\n\tversion: 3;\n\tid: string;\n\ttimestamp: string;\n\tcwd: string;\n\tparentSession?: string;\n\tmetadata?: Record<string, unknown>;\n}\n\ninterface SessionDocumentDescriptor {\n\tid: string;\n\ttimestamp: string;\n\tfileName: string;\n\toperationKey: string;\n}\n\ninterface JsonlSessionDocument {\n\tmetadata: JsonlSessionMetadata;\n\tentries: SessionTreeEntry[];\n}\n\nfunction invalidSession(path: string, message: string, cause?: Error): SessionError {\n\treturn new SessionError(\"invalid_session\", `Invalid JSONL session file ${path}: ${message}`, cause);\n}\n\nfunction invalidEntry(path: string, line: number, message: string, cause?: Error): SessionError {\n\treturn new SessionError(\"invalid_entry\", `Invalid JSONL session file ${path}: line ${line} ${message}`, cause);\n}\n\nfunction parseHeader(line: string, path: string): SessionHeader {\n\tlet value: unknown;\n\ttry {\n\t\tvalue = JSON.parse(line);\n\t} catch (error) {\n\t\tthrow invalidSession(path, \"first line is not a valid session header\", toError(error));\n\t}\n\tif (typeof value !== \"object\" || value === null)\n\t\tthrow invalidSession(path, \"first line is not a valid session header\");\n\tconst header = value as Partial<SessionHeader>;\n\tif (header.type !== \"session\" || header.version !== 3) {\n\t\tthrow invalidSession(\n\t\t\tpath,\n\t\t\theader.type === \"session\" ? \"unsupported session version\" : \"first line is not a valid session header\",\n\t\t);\n\t}\n\tif (typeof header.id !== \"string\" || !header.id) throw invalidSession(path, \"session header is missing id\");\n\tif (typeof header.timestamp !== \"string\" || !header.timestamp)\n\t\tthrow invalidSession(path, \"session header is missing timestamp\");\n\tif (typeof header.cwd !== \"string\" || !header.cwd) throw invalidSession(path, \"session header is missing cwd\");\n\tif (header.parentSession !== undefined && typeof header.parentSession !== \"string\") {\n\t\tthrow invalidSession(path, \"session header parentSession must be a string\");\n\t}\n\tif (\n\t\theader.metadata !== undefined &&\n\t\t(typeof header.metadata !== \"object\" || header.metadata === null || Array.isArray(header.metadata))\n\t) {\n\t\tthrow invalidSession(path, \"session header metadata must be an object\");\n\t}\n\treturn {\n\t\ttype: \"session\",\n\t\tversion: 3,\n\t\tid: header.id,\n\t\ttimestamp: header.timestamp,\n\t\tcwd: header.cwd,\n\t\tparentSession: header.parentSession,\n\t\tmetadata: header.metadata,\n\t};\n}\n\nfunction parseEntry(line: string, path: string, lineNumber: number): SessionTreeEntry {\n\tlet value: unknown;\n\ttry {\n\t\tvalue = JSON.parse(line);\n\t} catch (error) {\n\t\tthrow invalidEntry(path, lineNumber, \"is not valid JSON\", toError(error));\n\t}\n\tif (typeof value !== \"object\" || value === null)\n\t\tthrow invalidEntry(path, lineNumber, \"is not a valid session entry\");\n\tconst entry = value as { type?: unknown; id?: unknown; parentId?: unknown; timestamp?: unknown; targetId?: unknown };\n\tif (typeof entry.type !== \"string\") throw invalidEntry(path, lineNumber, \"is missing entry type\");\n\tif (typeof entry.id !== \"string\" || !entry.id) throw invalidEntry(path, lineNumber, \"is missing entry id\");\n\tif (entry.parentId !== null && typeof entry.parentId !== \"string\")\n\t\tthrow invalidEntry(path, lineNumber, \"has invalid parentId\");\n\tif (typeof entry.timestamp !== \"string\" || !entry.timestamp)\n\t\tthrow invalidEntry(path, lineNumber, \"is missing timestamp\");\n\tif (entry.type === \"leaf\" && entry.targetId !== null && typeof entry.targetId !== \"string\") {\n\t\tthrow invalidEntry(path, lineNumber, \"has invalid targetId\");\n\t}\n\treturn entry as SessionTreeEntry;\n}\n\nfunction metadataFromHeader(header: SessionHeader, path: string): JsonlSessionMetadata {\n\treturn {\n\t\tid: header.id,\n\t\tcreatedAt: header.timestamp,\n\t\tcwd: header.cwd,\n\t\tpath,\n\t\tparentSessionPath: header.parentSession,\n\t\tmetadata: header.metadata,\n\t};\n}\n\nexport async function loadJsonlSessionMetadata(\n\tfs: JsonlSessionFileSystem,\n\tpath: string,\n): Promise<JsonlSessionMetadata> {\n\tconst lines = getFileSystemResultOrThrow(\n\t\tawait fs.readTextLines(path, { maxLines: 1 }),\n\t\t`Failed to read session header ${path}`,\n\t);\n\tif (!lines[0]?.trim()) throw invalidSession(path, \"missing session header\");\n\treturn metadataFromHeader(parseHeader(lines[0], path), path);\n}\n\nasync function loadJsonlSession(fs: JsonlSessionFileSystem, path: string): Promise<JsonlSessionDocument> {\n\tconst content = getFileSystemResultOrThrow(await fs.readTextFile(path), `Failed to read session ${path}`);\n\tconst lines = content.split(\"\\n\").filter((line) => line.trim());\n\tif (lines.length === 0) throw invalidSession(path, \"missing session header\");\n\tconst header = parseHeader(lines[0]!, path);\n\tconst entries = lines.slice(1).map((line, index) => parseEntry(line, path, index + 2));\n\tconst entryIds = new Set<string>();\n\tfor (const entry of entries) {\n\t\tif (entryIds.has(entry.id)) throw invalidSession(path, `duplicate entry id ${entry.id}`);\n\t\tentryIds.add(entry.id);\n\t}\n\treturn {\n\t\tmetadata: metadataFromHeader(header, path),\n\t\tentries,\n\t};\n}\n\nfunction encodeCwd(cwd: string): string {\n\treturn `--${cwd.replace(/^[/\\\\]/, \"\").replace(/[/\\\\:]/g, \"-\")}--`;\n}\n\nfunction createDocumentDescriptor(options: JsonlSessionCreateOptions): SessionDocumentDescriptor {\n\tconst id = options.id ?? createSessionId();\n\tif (!id) throw new SessionError(\"invalid_session\", \"Session id cannot be empty\");\n\tlet encodedId: string;\n\ttry {\n\t\tencodedId = encodeURIComponent(id);\n\t} catch (error) {\n\t\tthrow new SessionError(\"invalid_session\", `Invalid session id ${JSON.stringify(id)}`, toError(error));\n\t}\n\tconst timestamp = createTimestamp();\n\tconst fileName = `${timestamp.replace(/[:.]/g, \"-\")}_${encodedId}.jsonl`;\n\treturn {\n\t\tid,\n\t\ttimestamp,\n\t\tfileName,\n\t\toperationKey: `document:${JSON.stringify([encodeCwd(options.cwd), fileName])}`,\n\t};\n}\n\nclass JsonlSessionStore\n\timplements SessionStore<JsonlSessionMetadata, JsonlSessionCreateOptions, JsonlSessionListOptions>\n{\n\tprivate readonly fs: JsonlSessionStoreFileSystem;\n\tprivate readonly sessionsRootInput: string;\n\tprivate sessionsRoot: string | undefined;\n\tprivate readonly entryIdsByPath = new Map<string, Set<string>>();\n\tprivate readonly entriesByPath = new Map<string, SessionTreeEntry[]>();\n\tprivate readonly operationKeysByPath = new Map<string, string>();\n\tprivate readonly operations: KeyedOperationQueue<string>;\n\tprivate disposed = false;\n\tprivate disposePromise: Promise<void> | undefined;\n\n\tconstructor(options: JsonlSessionStoreOptions) {\n\t\tthis.fs = options.fs;\n\t\tthis.sessionsRootInput = options.sessionsRoot;\n\t\tthis.operations = new KeyedOperationQueue({\n\t\t\tmaxConcurrentOperations: options.maxConcurrentOperations ?? DEFAULT_MAX_CONCURRENT_OPERATIONS,\n\t\t});\n\t}\n\n\tcreate(options: JsonlSessionCreateOptions): Promise<SessionReader<JsonlSessionMetadata>> {\n\t\tthis.assertOpen();\n\t\tconst descriptor = createDocumentDescriptor(options);\n\t\treturn this.operations.enqueue(descriptor.operationKey, () =>\n\t\t\tthis.createDocument(descriptor, options, options.parentSessionPath, options.metadata, []),\n\t\t);\n\t}\n\n\tload(metadata: JsonlSessionMetadata): Promise<SessionReader<JsonlSessionMetadata>> {\n\t\tthis.assertOpen();\n\t\treturn this.operations.enqueue(this.operationKey(metadata), () => this.loadDocument(metadata));\n\t}\n\n\tprivate async loadDocument(metadata: JsonlSessionMetadata): Promise<SessionReader<JsonlSessionMetadata>> {\n\t\tif (\n\t\t\t!getFileSystemResultOrThrow(await this.fs.exists(metadata.path), `Failed to check session ${metadata.path}`)\n\t\t) {\n\t\t\tthrow new SessionError(\"not_found\", `Session not found: ${metadata.path}`);\n\t\t}\n\t\tconst document = await loadJsonlSession(this.fs, metadata.path);\n\t\tthis.entriesByPath.set(metadata.path, document.entries);\n\t\tthis.entryIdsByPath.set(metadata.path, new Set(document.entries.map((entry) => entry.id)));\n\t\treturn this.reader(document.metadata);\n\t}\n\n\tlist(options: JsonlSessionListOptions = {}): Promise<JsonlSessionMetadata[]> {\n\t\tthis.assertOpen();\n\t\treturn this.operations.enqueueBarrier(() => this.listSessions(options));\n\t}\n\n\tprivate async listSessions(options: JsonlSessionListOptions): Promise<JsonlSessionMetadata[]> {\n\t\tconst dirs = options.cwd ? [await this.getSessionDir(options.cwd)] : await this.listSessionDirs();\n\t\tconst sessions: JsonlSessionMetadata[] = [];\n\t\tfor (const dir of dirs) {\n\t\t\tif (!getFileSystemResultOrThrow(await this.fs.exists(dir), `Failed to check session directory ${dir}`))\n\t\t\t\tcontinue;\n\t\t\tconst files = getFileSystemResultOrThrow(\n\t\t\t\tawait this.fs.listDir(dir),\n\t\t\t\t`Failed to list sessions in ${dir}`,\n\t\t\t).filter((file) => file.kind !== \"directory\" && file.name.endsWith(\".jsonl\"));\n\t\t\tfor (const file of files) sessions.push(await loadJsonlSessionMetadata(this.fs, file.path));\n\t\t}\n\t\treturn sessions.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());\n\t}\n\n\tappendEntry(metadata: JsonlSessionMetadata, entry: SessionTreeEntry): Promise<void> {\n\t\tthis.assertOpen();\n\t\treturn this.operations.enqueue(this.operationKey(metadata), async () => {\n\t\t\tif (\n\t\t\t\t!getFileSystemResultOrThrow(await this.fs.exists(metadata.path), `Failed to check session ${metadata.path}`)\n\t\t\t) {\n\t\t\t\tthrow new SessionError(\"not_found\", `Session not found: ${metadata.path}`);\n\t\t\t}\n\t\t\tlet entryIds = this.entryIdsByPath.get(metadata.path);\n\t\t\tif (!entryIds) {\n\t\t\t\tawait this.loadDocument(metadata);\n\t\t\t\tentryIds = this.entryIdsByPath.get(metadata.path)!;\n\t\t\t}\n\t\t\tif (entryIds.has(entry.id)) throw new SessionError(\"invalid_entry\", `Entry ${entry.id} already exists`);\n\t\t\tgetFileSystemResultOrThrow(\n\t\t\t\tawait this.fs.appendFile(metadata.path, `${JSON.stringify(entry)}\\n`),\n\t\t\t\t`Failed to append session entry ${entry.id}`,\n\t\t\t);\n\t\t\tentryIds.add(entry.id);\n\t\t\tthis.entryIdsByPath.set(metadata.path, entryIds);\n\t\t\tthis.entriesByPath.get(metadata.path)!.push(entry);\n\t\t});\n\t}\n\n\tdelete(metadata: JsonlSessionMetadata): Promise<void> {\n\t\tthis.assertOpen();\n\t\treturn this.operations.enqueue(this.operationKey(metadata), async () => {\n\t\t\tgetFileSystemResultOrThrow(\n\t\t\t\tawait this.fs.remove(metadata.path, { force: true }),\n\t\t\t\t`Failed to delete session ${metadata.path}`,\n\t\t\t);\n\t\t\tthis.entryIdsByPath.delete(metadata.path);\n\t\t\tthis.entriesByPath.delete(metadata.path);\n\t\t\tthis.operationKeysByPath.delete(metadata.path);\n\t\t});\n\t}\n\n\tfork(\n\t\tsource: JsonlSessionMetadata,\n\t\toptions: JsonlSessionCreateOptions,\n\t\tselection: SessionForkSelection,\n\t): Promise<SessionReader<JsonlSessionMetadata>> {\n\t\tthis.assertOpen();\n\t\tconst descriptor = createDocumentDescriptor(options);\n\t\tconst sourceEntries = this.operations.enqueue(this.operationKey(source), async () => {\n\t\t\tif (!getFileSystemResultOrThrow(await this.fs.exists(source.path), `Failed to check session ${source.path}`)) {\n\t\t\t\tthrow new SessionError(\"not_found\", `Session not found: ${source.path}`);\n\t\t\t}\n\t\t\tconst document = await loadJsonlSession(this.fs, source.path);\n\t\t\tthis.entriesByPath.set(source.path, document.entries);\n\t\t\tthis.entryIdsByPath.set(source.path, new Set(document.entries.map((entry) => entry.id)));\n\t\t\treturn readSessionEntriesForFork(\n\t\t\t\tcreateArraySessionReader(document.metadata, () => document.entries),\n\t\t\t\tselection,\n\t\t\t);\n\t\t});\n\t\treturn this.operations.enqueue(descriptor.operationKey, async () =>\n\t\t\tthis.createDocument(\n\t\t\t\tdescriptor,\n\t\t\t\toptions,\n\t\t\t\toptions.parentSessionPath ?? source.path,\n\t\t\t\toptions.metadata ?? source.metadata,\n\t\t\t\tawait sourceEntries,\n\t\t\t),\n\t\t);\n\t}\n\n\tasync [Symbol.asyncDispose](): Promise<void> {\n\t\tif (!this.disposePromise) {\n\t\t\tthis.disposed = true;\n\t\t\tthis.disposePromise = this.operations.drain();\n\t\t}\n\t\tawait this.disposePromise;\n\t}\n\n\tprivate assertOpen(): void {\n\t\tif (this.disposed) throw new SessionError(\"storage\", \"JSONL session store is disposed\");\n\t}\n\n\tprivate operationKey(metadata: JsonlSessionMetadata): string {\n\t\treturn this.operationKeysByPath.get(metadata.path) ?? metadata.path;\n\t}\n\n\tprivate async createDocument(\n\t\tdescriptor: SessionDocumentDescriptor,\n\t\toptions: JsonlSessionCreateOptions,\n\t\tparentSessionPath: string | undefined,\n\t\tmetadata: Record<string, unknown> | undefined,\n\t\tentries: readonly SessionTreeEntry[],\n\t): Promise<SessionReader<JsonlSessionMetadata>> {\n\t\tconst dir = await this.getSessionDir(options.cwd);\n\t\tgetFileSystemResultOrThrow(\n\t\t\tawait this.fs.createDir(dir, { recursive: true }),\n\t\t\t`Failed to create session directory ${dir}`,\n\t\t);\n\t\tconst path = getFileSystemResultOrThrow(\n\t\t\tawait this.fs.joinPath([dir, descriptor.fileName]),\n\t\t\t`Failed to resolve session file path for ${descriptor.id}`,\n\t\t);\n\t\tif (getFileSystemResultOrThrow(await this.fs.exists(path), `Failed to check session ${path}`)) {\n\t\t\tthrow new SessionError(\"invalid_session\", `Session already exists: ${path}`);\n\t\t}\n\t\tconst header: SessionHeader = {\n\t\t\ttype: \"session\",\n\t\t\tversion: 3,\n\t\t\tid: descriptor.id,\n\t\t\ttimestamp: descriptor.timestamp,\n\t\t\tcwd: options.cwd,\n\t\t\tparentSession: parentSessionPath,\n\t\t\tmetadata,\n\t\t};\n\t\tconst content = [JSON.stringify(header), ...entries.map((entry) => JSON.stringify(entry)), \"\"].join(\"\\n\");\n\t\tgetFileSystemResultOrThrow(await this.fs.writeFile(path, content), `Failed to create session ${path}`);\n\t\tconst storedEntries = [...entries];\n\t\tthis.entriesByPath.set(path, storedEntries);\n\t\tthis.entryIdsByPath.set(path, new Set(storedEntries.map((entry) => entry.id)));\n\t\tthis.operationKeysByPath.set(path, descriptor.operationKey);\n\t\treturn this.reader(metadataFromHeader(header, path));\n\t}\n\n\tprivate reader(metadata: JsonlSessionMetadata): SessionReader<JsonlSessionMetadata> {\n\t\tconst reader = createArraySessionReader(metadata, () => {\n\t\t\tconst entries = this.entriesByPath.get(metadata.path);\n\t\t\tif (!entries) throw new SessionError(\"not_found\", `Session not found: ${metadata.path}`);\n\t\t\treturn entries;\n\t\t});\n\t\tconst operationKey = this.operationKey(metadata);\n\t\treturn {\n\t\t\tmetadata: reader.metadata,\n\t\t\treadHead: () => {\n\t\t\t\tthis.assertOpen();\n\t\t\t\treturn this.operations.enqueue(operationKey, () => reader.readHead());\n\t\t\t},\n\t\t\treadEntry: (id) => {\n\t\t\t\tthis.assertOpen();\n\t\t\t\treturn this.operations.enqueue(operationKey, () => reader.readEntry(id));\n\t\t\t},\n\t\t\treadEntries: (options) => {\n\t\t\t\tthis.assertOpen();\n\t\t\t\treturn this.operations.enqueue(operationKey, () => reader.readEntries(options));\n\t\t\t},\n\t\t\treadPathToRootOrCompaction: (leafId) => {\n\t\t\t\tthis.assertOpen();\n\t\t\t\treturn this.operations.enqueue(operationKey, () => reader.readPathToRootOrCompaction(leafId));\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate async getSessionsRoot(): Promise<string> {\n\t\tthis.sessionsRoot ??= getFileSystemResultOrThrow(\n\t\t\tawait this.fs.absolutePath(this.sessionsRootInput),\n\t\t\t`Failed to resolve sessions root ${this.sessionsRootInput}`,\n\t\t);\n\t\treturn this.sessionsRoot;\n\t}\n\n\tprivate async getSessionDir(cwd: string): Promise<string> {\n\t\treturn getFileSystemResultOrThrow(\n\t\t\tawait this.fs.joinPath([await this.getSessionsRoot(), encodeCwd(cwd)]),\n\t\t\t`Failed to resolve session directory for ${cwd}`,\n\t\t);\n\t}\n\n\tprivate async listSessionDirs(): Promise<string[]> {\n\t\tconst root = await this.getSessionsRoot();\n\t\tif (!getFileSystemResultOrThrow(await this.fs.exists(root), `Failed to check sessions root ${root}`)) return [];\n\t\treturn getFileSystemResultOrThrow(await this.fs.listDir(root), `Failed to list sessions root ${root}`)\n\t\t\t.filter((entry) => entry.kind === \"directory\")\n\t\t\t.map((entry) => entry.path);\n\t}\n}\n\nexport function createJsonlSessionStore(\n\toptions: JsonlSessionStoreOptions,\n): SessionStore<JsonlSessionMetadata, JsonlSessionCreateOptions, JsonlSessionListOptions> {\n\treturn new JsonlSessionStore(options);\n}\n"]}
|
package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/keyed-operation-queue.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare class KeyedOperationQueue<TKey> {
|
|
2
|
+
private readonly tails;
|
|
3
|
+
private readonly maxConcurrentOperations;
|
|
4
|
+
private readonly permitWaiters;
|
|
5
|
+
private activeOperations;
|
|
6
|
+
private barrier;
|
|
7
|
+
constructor(options?: {
|
|
8
|
+
maxConcurrentOperations?: number;
|
|
9
|
+
});
|
|
10
|
+
enqueue<T>(key: TKey, operation: () => Promise<T> | T): Promise<T>;
|
|
11
|
+
enqueueBarrier<T>(operation: () => Promise<T> | T): Promise<T>;
|
|
12
|
+
drain(): Promise<void>;
|
|
13
|
+
private runOperation;
|
|
14
|
+
private acquirePermit;
|
|
15
|
+
private releasePermit;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=keyed-operation-queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyed-operation-queue.d.ts","sourceRoot":"","sources":["../../../src/harness/session/keyed-operation-queue.ts"],"names":[],"mappings":"AAAA,qBAAa,mBAAmB,CAAC,IAAI;IACpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkC;IACxD,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAqB;IAC7D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAyB;IACvD,OAAO,CAAC,gBAAgB,CAAK;IAC7B,OAAO,CAAC,OAAO,CAAoC;IAEnD,YAAY,OAAO,GAAE;QAAE,uBAAuB,CAAC,EAAE,MAAM,CAAA;KAAO,EAQ7D;IAED,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAYjE;IAED,cAAc,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAO7D;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;YAEa,YAAY;YASZ,aAAa;IAS3B,OAAO,CAAC,aAAa;CAMrB"}
|
package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/keyed-operation-queue.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export class KeyedOperationQueue {
|
|
2
|
+
constructor(options = {}) {
|
|
3
|
+
this.tails = new Map();
|
|
4
|
+
this.permitWaiters = [];
|
|
5
|
+
this.activeOperations = 0;
|
|
6
|
+
this.barrier = Promise.resolve();
|
|
7
|
+
if (options.maxConcurrentOperations !== undefined &&
|
|
8
|
+
(!Number.isInteger(options.maxConcurrentOperations) || options.maxConcurrentOperations < 1)) {
|
|
9
|
+
throw new RangeError("maxConcurrentOperations must be a positive integer");
|
|
10
|
+
}
|
|
11
|
+
this.maxConcurrentOperations = options.maxConcurrentOperations;
|
|
12
|
+
}
|
|
13
|
+
enqueue(key, operation) {
|
|
14
|
+
const previous = this.tails.get(key) ?? Promise.resolve();
|
|
15
|
+
const result = Promise.all([this.barrier, previous]).then(() => this.runOperation(operation));
|
|
16
|
+
const tail = result.then(() => undefined, () => undefined);
|
|
17
|
+
this.tails.set(key, tail);
|
|
18
|
+
void tail.then(() => {
|
|
19
|
+
if (this.tails.get(key) === tail)
|
|
20
|
+
this.tails.delete(key);
|
|
21
|
+
});
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
enqueueBarrier(operation) {
|
|
25
|
+
const result = Promise.all([this.barrier, ...this.tails.values()]).then(() => this.runOperation(operation));
|
|
26
|
+
this.barrier = result.then(() => undefined, () => undefined);
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
async drain() {
|
|
30
|
+
await Promise.all([this.barrier, ...this.tails.values()]);
|
|
31
|
+
}
|
|
32
|
+
async runOperation(operation) {
|
|
33
|
+
await this.acquirePermit();
|
|
34
|
+
try {
|
|
35
|
+
return await operation();
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
this.releasePermit();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async acquirePermit() {
|
|
42
|
+
if (this.maxConcurrentOperations === undefined)
|
|
43
|
+
return;
|
|
44
|
+
if (this.activeOperations < this.maxConcurrentOperations) {
|
|
45
|
+
this.activeOperations += 1;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
await new Promise((resolve) => this.permitWaiters.push(resolve));
|
|
49
|
+
}
|
|
50
|
+
releasePermit() {
|
|
51
|
+
if (this.maxConcurrentOperations === undefined)
|
|
52
|
+
return;
|
|
53
|
+
const next = this.permitWaiters.shift();
|
|
54
|
+
if (next)
|
|
55
|
+
next();
|
|
56
|
+
else
|
|
57
|
+
this.activeOperations -= 1;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=keyed-operation-queue.js.map
|
package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/keyed-operation-queue.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyed-operation-queue.js","sourceRoot":"","sources":["../../../src/harness/session/keyed-operation-queue.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,mBAAmB;IAO/B,YAAY,OAAO,GAAyC,EAAE;QAN7C,UAAK,GAAG,IAAI,GAAG,EAAuB,CAAC;QAEvC,kBAAa,GAAsB,EAAE,CAAC;QAC/C,qBAAgB,GAAG,CAAC,CAAC;QACrB,YAAO,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;QAGlD,IACC,OAAO,CAAC,uBAAuB,KAAK,SAAS;YAC7C,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,uBAAuB,CAAC,IAAI,OAAO,CAAC,uBAAuB,GAAG,CAAC,CAAC,EAC1F,CAAC;YACF,MAAM,IAAI,UAAU,CAAC,oDAAoD,CAAC,CAAC;QAC5E,CAAC;QACD,IAAI,CAAC,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAChE,CAAC;IAED,OAAO,CAAI,GAAS,EAAE,SAA+B;QACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QAC1D,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;QA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AI,IAAI,CAAC,uBAAuB,KAAK,SAAS;YAAE,OAAO;QACvD,IAAI,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC1D,IAAI,CAAC,gBAAgB,IAAI,CAAC,CAAC;YAC3B,OAAO;QACR,CAAC;QACD,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IACxE,CAAC;IAEO,aAAa;QACpB,IAAI,IAAI,CAAC,uBAAuB,KAAK,SAAS;YAAE,OAAO;QACvD,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QACxC,IAAI,IAAI;YAAE,IAAI,EAAE,CAAC;;YACZ,IAAI,CAAC,gBAAgB,IAAI,CAAC,CAAC;IACjC,CAAC;CACD","sourcesContent":["export class KeyedOperationQueue<TKey> {\n\tprivate readonly tails = new Map<TKey, Promise<void>>();\n\tprivate readonly maxConcurrentOperations: number | undefined;\n\tprivate readonly permitWaiters: Array<() => void> = [];\n\tprivate activeOperations = 0;\n\tprivate barrier: Promise<void> = Promise.resolve();\n\n\tconstructor(options: { maxConcurrentOperations?: number } = {}) {\n\t\tif (\n\t\t\toptions.maxConcurrentOperations !== undefined &&\n\t\t\t(!Number.isInteger(options.maxConcurrentOperations) || options.maxConcurrentOperations < 1)\n\t\t) {\n\t\t\tthrow new RangeError(\"maxConcurrentOperations must be a positive integer\");\n\t\t}\n\t\tthis.maxConcurrentOperations = options.maxConcurrentOperations;\n\t}\n\n\tenqueue<T>(key: TKey, operation: () => Promise<T> | T): Promise<T> {\n\t\tconst previous = this.tails.get(key) ?? Promise.resolve();\n\t\tconst result = Promise.all([this.barrier, previous]).then(() => this.runOperation(operation));\n\t\tconst tail = result.then(\n\t\t\t() => undefined,\n\t\t\t() => undefined,\n\t\t);\n\t\tthis.tails.set(key, tail);\n\t\tvoid tail.then(() => {\n\t\t\tif (this.tails.get(key) === tail) this.tails.delete(key);\n\t\t});\n\t\treturn result;\n\t}\n\n\tenqueueBarrier<T>(operation: () => Promise<T> | T): Promise<T> {\n\t\tconst result = Promise.all([this.barrier, ...this.tails.values()]).then(() => this.runOperation(operation));\n\t\tthis.barrier = result.then(\n\t\t\t() => undefined,\n\t\t\t() => undefined,\n\t\t);\n\t\treturn result;\n\t}\n\n\tasync drain(): Promise<void> {\n\t\tawait Promise.all([this.barrier, ...this.tails.values()]);\n\t}\n\n\tprivate async runOperation<T>(operation: () => Promise<T> | T): Promise<T> {\n\t\tawait this.acquirePermit();\n\t\ttry {\n\t\t\treturn await operation();\n\t\t} finally {\n\t\t\tthis.releasePermit();\n\t\t}\n\t}\n\n\tprivate async acquirePermit(): Promise<void> {\n\t\tif (this.maxConcurrentOperations === undefined) return;\n\t\tif (this.activeOperations < this.maxConcurrentOperations) {\n\t\t\tthis.activeOperations += 1;\n\t\t\treturn;\n\t\t}\n\t\tawait new Promise<void>((resolve) => this.permitWaiters.push(resolve));\n\t}\n\n\tprivate releasePermit(): void {\n\t\tif (this.maxConcurrentOperations === undefined) return;\n\t\tconst next = this.permitWaiters.shift();\n\t\tif (next) next();\n\t\telse this.activeOperations -= 1;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SessionMetadata, SessionStore } from "../types.ts";
|
|
2
|
+
export type InMemorySessionCreateOptions = {
|
|
3
|
+
id?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function createInMemorySessionStore(): SessionStore<SessionMetadata, InMemorySessionCreateOptions, void>;
|
|
6
|
+
//# sourceMappingURL=memory-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-store.d.ts","sourceRoot":"","sources":["../../../src/harness/session/memory-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAwB,eAAe,EAAiB,YAAY,EAAoB,MAAM,aAAa,CAAC;AAOxH,MAAM,MAAM,4BAA4B,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAwH3D,wBAAgB,0BAA0B,IAAI,YAAY,CAAC,eAAe,EAAE,4BAA4B,EAAE,IAAI,CAAC,CAE9G"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { SessionError } from "../types.js";
|
|
2
|
+
import { createArraySessionReader } from "./array-session-reader.js";
|
|
3
|
+
import { readSessionEntriesForFork } from "./fork.js";
|
|
4
|
+
import { KeyedOperationQueue } from "./keyed-operation-queue.js";
|
|
5
|
+
import { createSessionId, createTimestamp } from "./repository.js";
|
|
6
|
+
class InMemorySessionStore {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.sessions = new Map();
|
|
9
|
+
this.operations = new KeyedOperationQueue();
|
|
10
|
+
this.disposed = false;
|
|
11
|
+
}
|
|
12
|
+
create(options = {}) {
|
|
13
|
+
this.assertOpen();
|
|
14
|
+
const id = options.id ?? createSessionId();
|
|
15
|
+
return this.operations.enqueue(id, () => {
|
|
16
|
+
const state = {
|
|
17
|
+
metadata: { id, createdAt: createTimestamp() },
|
|
18
|
+
entries: [],
|
|
19
|
+
};
|
|
20
|
+
this.sessions.set(state.metadata.id, state);
|
|
21
|
+
return this.reader(state);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
load(metadata) {
|
|
25
|
+
this.assertOpen();
|
|
26
|
+
return this.operations.enqueue(metadata.id, () => this.reader(this.getState(metadata)));
|
|
27
|
+
}
|
|
28
|
+
list() {
|
|
29
|
+
this.assertOpen();
|
|
30
|
+
return this.operations.enqueueBarrier(() => [...this.sessions.values()].map((state) => state.metadata));
|
|
31
|
+
}
|
|
32
|
+
appendEntry(metadata, entry) {
|
|
33
|
+
this.assertOpen();
|
|
34
|
+
return this.operations.enqueue(metadata.id, () => {
|
|
35
|
+
const state = this.getState(metadata);
|
|
36
|
+
if (state.entries.some((existing) => existing.id === entry.id)) {
|
|
37
|
+
throw new SessionError("invalid_entry", `Entry ${entry.id} already exists`);
|
|
38
|
+
}
|
|
39
|
+
state.entries.push(entry);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
delete(metadata) {
|
|
43
|
+
this.assertOpen();
|
|
44
|
+
return this.operations.enqueue(metadata.id, () => {
|
|
45
|
+
this.sessions.delete(metadata.id);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
fork(source, options, selection) {
|
|
49
|
+
this.assertOpen();
|
|
50
|
+
const id = options.id ?? createSessionId();
|
|
51
|
+
const sourceEntries = this.operations.enqueue(source.id, () => {
|
|
52
|
+
const sourceState = this.getState(source);
|
|
53
|
+
return readSessionEntriesForFork(createArraySessionReader(sourceState.metadata, () => sourceState.entries), selection);
|
|
54
|
+
});
|
|
55
|
+
return this.operations.enqueue(id, async () => {
|
|
56
|
+
const state = {
|
|
57
|
+
metadata: { id, createdAt: createTimestamp() },
|
|
58
|
+
entries: [...(await sourceEntries)],
|
|
59
|
+
};
|
|
60
|
+
this.sessions.set(state.metadata.id, state);
|
|
61
|
+
return this.reader(state);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async [Symbol.asyncDispose]() {
|
|
65
|
+
if (!this.disposePromise) {
|
|
66
|
+
this.disposed = true;
|
|
67
|
+
this.disposePromise = this.operations.drain();
|
|
68
|
+
}
|
|
69
|
+
await this.disposePromise;
|
|
70
|
+
}
|
|
71
|
+
assertOpen() {
|
|
72
|
+
if (this.disposed)
|
|
73
|
+
throw new SessionError("storage", "In-memory session store is disposed");
|
|
74
|
+
}
|
|
75
|
+
getState(metadata) {
|
|
76
|
+
const state = this.sessions.get(metadata.id);
|
|
77
|
+
if (!state)
|
|
78
|
+
throw new SessionError("not_found", `Session not found: ${metadata.id}`);
|
|
79
|
+
return state;
|
|
80
|
+
}
|
|
81
|
+
reader(state) {
|
|
82
|
+
const reader = createArraySessionReader(state.metadata, () => state.entries);
|
|
83
|
+
return {
|
|
84
|
+
metadata: reader.metadata,
|
|
85
|
+
readHead: () => {
|
|
86
|
+
this.assertOpen();
|
|
87
|
+
return this.operations.enqueue(state.metadata.id, () => reader.readHead());
|
|
88
|
+
},
|
|
89
|
+
readEntry: (id) => {
|
|
90
|
+
this.assertOpen();
|
|
91
|
+
return this.operations.enqueue(state.metadata.id, () => reader.readEntry(id));
|
|
92
|
+
},
|
|
93
|
+
readEntries: (options) => {
|
|
94
|
+
this.assertOpen();
|
|
95
|
+
return this.operations.enqueue(state.metadata.id, () => reader.readEntries(options));
|
|
96
|
+
},
|
|
97
|
+
readPathToRootOrCompaction: (leafId) => {
|
|
98
|
+
this.assertOpen();
|
|
99
|
+
return this.operations.enqueue(state.metadata.id, () => reader.readPathToRootOrCompaction(leafId));
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export function createInMemorySessionStore() {
|
|
105
|
+
return new InMemorySessionStore();
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=memory-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-store.js","sourceRoot":"","sources":["../../../src/harness/session/memory-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AASnE,MAAM,oBAAoB;IAA1B;QACkB,aAAQ,GAAG,IAAI,GAAG,EAAgC,CAAC;QACnD,eAAU,GAAG,IAAI,mBAAmB,EAAU,CAAC;QACxD,aAAQ,GAAG,KAAK,CAAC;IA4G1B,CAAC;IAzGA,MAAM,CAAC,OAAO,GAAiC,EAAE;QAChD,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,MAAM,EAAE,GAA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AE,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC5E,CAAC;YACD,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE;gBACjB,IAAI,CAAC,UAAU,EAAE,CAAC;gBAClB,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,CAAC;YACD,WAAW,EAAE,CAAC,OAAO,EAAE,EAAE;gBACxB,IAAI,CAAC,UAAU,EAAE,CAAC;gBAClB,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;YACtF,CAAC;YACD,0BAA0B,EAAE,CAAC,MAAM,EAAE,EAAE;gBACtC,IAAI,CAAC,UAAU,EAAE,CAAC;gBAClB,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC,CAAC;YACpG,CAAC;SACD,CAAC;IACH,CAAC;CACD;AAED,MAAM,UAAU,0BAA0B;IACzC,OAAO,IAAI,oBAAoB,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import type { SessionForkSelection, SessionMetadata, SessionReader, SessionStore, SessionTreeEntry } from \"../types.ts\";\nimport { SessionError } from \"../types.ts\";\nimport { createArraySessionReader } from \"./array-session-reader.ts\";\nimport { readSessionEntriesForFork } from \"./fork.ts\";\nimport { KeyedOperationQueue } from \"./keyed-operation-queue.ts\";\nimport { createSessionId, createTimestamp } from \"./repository.ts\";\n\nexport type InMemorySessionCreateOptions = { id?: string };\n\ninterface InMemorySessionState {\n\tmetadata: SessionMetadata;\n\tentries: SessionTreeEntry[];\n}\n\nclass InMemorySessionStore implements SessionStore<SessionMetadata, InMemorySessionCreateOptions, void> {\n\tprivate readonly sessions = new Map<string, InMemorySessionState>();\n\tprivate readonly operations = new KeyedOperationQueue<string>();\n\tprivate disposed = false;\n\tprivate disposePromise: Promise<void> | undefined;\n\n\tcreate(options: InMemorySessionCreateOptions = {}): Promise<SessionReader<SessionMetadata>> {\n\t\tthis.assertOpen();\n\t\tconst id = options.id ?? createSessionId();\n\t\treturn this.operations.enqueue(id, () => {\n\t\t\tconst state: InMemorySessionState = {\n\t\t\t\tmetadata: { id, createdAt: createTimestamp() },\n\t\t\t\tentries: [],\n\t\t\t};\n\t\t\tthis.sessions.set(state.metadata.id, state);\n\t\t\treturn this.reader(state);\n\t\t});\n\t}\n\n\tload(metadata: SessionMetadata): Promise<SessionReader<SessionMetadata>> {\n\t\tthis.assertOpen();\n\t\treturn this.operations.enqueue(metadata.id, () => this.reader(this.getState(metadata)));\n\t}\n\n\tlist(): Promise<SessionMetadata[]> {\n\t\tthis.assertOpen();\n\t\treturn this.operations.enqueueBarrier(() => [...this.sessions.values()].map((state) => state.metadata));\n\t}\n\n\tappendEntry(metadata: SessionMetadata, entry: SessionTreeEntry): Promise<void> {\n\t\tthis.assertOpen();\n\t\treturn this.operations.enqueue(metadata.id, () => {\n\t\t\tconst state = this.getState(metadata);\n\t\t\tif (state.entries.some((existing) => existing.id === entry.id)) {\n\t\t\t\tthrow new SessionError(\"invalid_entry\", `Entry ${entry.id} already exists`);\n\t\t\t}\n\t\t\tstate.entries.push(entry);\n\t\t});\n\t}\n\n\tdelete(metadata: SessionMetadata): Promise<void> {\n\t\tthis.assertOpen();\n\t\treturn this.operations.enqueue(metadata.id, () => {\n\t\t\tthis.sessions.delete(metadata.id);\n\t\t});\n\t}\n\n\tfork(\n\t\tsource: SessionMetadata,\n\t\toptions: InMemorySessionCreateOptions,\n\t\tselection: SessionForkSelection,\n\t): Promise<SessionReader<SessionMetadata>> {\n\t\tthis.assertOpen();\n\t\tconst id = options.id ?? createSessionId();\n\t\tconst sourceEntries = this.operations.enqueue(source.id, () => {\n\t\t\tconst sourceState = this.getState(source);\n\t\t\treturn readSessionEntriesForFork(\n\t\t\t\tcreateArraySessionReader(sourceState.metadata, () => sourceState.entries),\n\t\t\t\tselection,\n\t\t\t);\n\t\t});\n\t\treturn this.operations.enqueue(id, async () => {\n\t\t\tconst state: InMemorySessionState = {\n\t\t\t\tmetadata: { id, createdAt: createTimestamp() },\n\t\t\t\tentries: [...(await sourceEntries)],\n\t\t\t};\n\t\t\tthis.sessions.set(state.metadata.id, state);\n\t\t\treturn this.reader(state);\n\t\t});\n\t}\n\n\tasync [Symbol.asyncDispose](): Promise<void> {\n\t\tif (!this.disposePromise) {\n\t\t\tthis.disposed = true;\n\t\t\tthis.disposePromise = this.operations.drain();\n\t\t}\n\t\tawait this.disposePromise;\n\t}\n\n\tprivate assertOpen(): void {\n\t\tif (this.disposed) throw new SessionError(\"storage\", \"In-memory session store is disposed\");\n\t}\n\n\tprivate getState(metadata: SessionMetadata): InMemorySessionState {\n\t\tconst state = this.sessions.get(metadata.id);\n\t\tif (!state) throw new SessionError(\"not_found\", `Session not found: ${metadata.id}`);\n\t\treturn state;\n\t}\n\n\tprivate reader(state: InMemorySessionState): SessionReader<SessionMetadata> {\n\t\tconst reader = createArraySessionReader(state.metadata, () => state.entries);\n\t\treturn {\n\t\t\tmetadata: reader.metadata,\n\t\t\treadHead: () => {\n\t\t\t\tthis.assertOpen();\n\t\t\t\treturn this.operations.enqueue(state.metadata.id, () => reader.readHead());\n\t\t\t},\n\t\t\treadEntry: (id) => {\n\t\t\t\tthis.assertOpen();\n\t\t\t\treturn this.operations.enqueue(state.metadata.id, () => reader.readEntry(id));\n\t\t\t},\n\t\t\treadEntries: (options) => {\n\t\t\t\tthis.assertOpen();\n\t\t\t\treturn this.operations.enqueue(state.metadata.id, () => reader.readEntries(options));\n\t\t\t},\n\t\t\treadPathToRootOrCompaction: (leafId) => {\n\t\t\t\tthis.assertOpen();\n\t\t\t\treturn this.operations.enqueue(state.metadata.id, () => reader.readPathToRootOrCompaction(leafId));\n\t\t\t},\n\t\t};\n\t}\n}\n\nexport function createInMemorySessionStore(): SessionStore<SessionMetadata, InMemorySessionCreateOptions, void> {\n\treturn new InMemorySessionStore();\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type FileError, type Result, type SessionCreateOptions, type SessionForkOptions, type SessionMetadata, type SessionSearch, type SessionSearchHit, type SessionStore, type SessionTreeEntry } from "../types.ts";
|
|
2
|
+
import { type Session, type SessionContextBuildOptions } from "./session.ts";
|
|
3
|
+
export declare function createSessionId(): string;
|
|
4
|
+
export declare function createTimestamp(): string;
|
|
5
|
+
export declare class SessionRepository<TMetadata extends SessionMetadata = SessionMetadata, TCreateOptions extends SessionCreateOptions = SessionCreateOptions, TListOptions = void> {
|
|
6
|
+
private readonly store;
|
|
7
|
+
private readonly searchStore;
|
|
8
|
+
private readonly contextBuildOptions;
|
|
9
|
+
constructor(options: {
|
|
10
|
+
store: SessionStore<TMetadata, TCreateOptions, TListOptions>;
|
|
11
|
+
search?: SessionSearch<TMetadata> | null;
|
|
12
|
+
contextBuildOptions?: SessionContextBuildOptions;
|
|
13
|
+
});
|
|
14
|
+
create(options: TCreateOptions): Promise<Session<TMetadata>>;
|
|
15
|
+
open(metadata: TMetadata): Promise<Session<TMetadata>>;
|
|
16
|
+
list(options?: TListOptions): Promise<TMetadata[]>;
|
|
17
|
+
delete(metadata: TMetadata): Promise<void>;
|
|
18
|
+
fork(source: TMetadata, options: SessionForkOptions & TCreateOptions): Promise<Session<TMetadata>>;
|
|
19
|
+
search(options: Parameters<SessionSearch<TMetadata>["search"]>[0]): Promise<SessionSearchHit<TMetadata>[]>;
|
|
20
|
+
}
|
|
21
|
+
export declare function createSessionRepository<TMetadata extends SessionMetadata = SessionMetadata, TCreateOptions extends SessionCreateOptions = SessionCreateOptions, TListOptions = void>(options: {
|
|
22
|
+
store: SessionStore<TMetadata, TCreateOptions, TListOptions>;
|
|
23
|
+
search?: SessionSearch<TMetadata> | null;
|
|
24
|
+
contextBuildOptions?: SessionContextBuildOptions;
|
|
25
|
+
}): SessionRepository<TMetadata, TCreateOptions, TListOptions>;
|
|
26
|
+
export declare function findSessionEntryMatches<TMetadata extends SessionMetadata>(metadata: TMetadata, entries: readonly SessionTreeEntry[], text: string): SessionSearchHit<TMetadata>[];
|
|
27
|
+
export declare function getFileSystemResultOrThrow<TValue>(result: Result<TValue, FileError>, message: string): TValue;
|
|
28
|
+
//# sourceMappingURL=repository.d.ts.map
|