@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,94 @@
|
|
|
1
|
+
import { CLAUDE_SDK_OAUTH_PROVIDER_ID } from "../claude-sdk-oauth/account-management.js";
|
|
2
|
+
import { loadClaudeSdkOauthProviderSettingsFromDisk } from "../claude-sdk-oauth/settings.js";
|
|
3
|
+
/** Custom session entry type carrying a mirrored SDK compaction boundary. */
|
|
4
|
+
export const CLAUDE_SDK_OAUTH_COMPACT_ENTRY_TYPE = "claude-sdk-oauth-compact";
|
|
5
|
+
/** Assistant-message diagnostic the lane uses to transport a received boundary. */
|
|
6
|
+
export const CLAUDE_SDK_OAUTH_COMPACT_BOUNDARY_DIAGNOSTIC = "claude_sdk_oauth_compact_boundary";
|
|
7
|
+
/**
|
|
8
|
+
* Reason reported when senpi declines to compact an SDK-native lane. The
|
|
9
|
+
* structured `rejectionCause` stays `cancelled-by-extension` (a closed union
|
|
10
|
+
* shared with the RPC surface); this string is what the user and the compaction
|
|
11
|
+
* log see.
|
|
12
|
+
*/
|
|
13
|
+
export const SDK_NATIVE_LANE_REJECTION_REASON = "the Claude Agent SDK owns compaction for this session";
|
|
14
|
+
const COMPACT_BOUNDARY_SCHEMA = "senpi.claude-sdk-oauth.compact-boundary.v1";
|
|
15
|
+
function isRecord(value) {
|
|
16
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Pure lane predicate. Kept separate from {@link createCompactionLanePolicy} so
|
|
20
|
+
* callers that already know the resolved resume mode never touch disk.
|
|
21
|
+
*/
|
|
22
|
+
export function isSdkNativeCompactionLane(input) {
|
|
23
|
+
if (input.model?.provider !== CLAUDE_SDK_OAUTH_PROVIDER_ID)
|
|
24
|
+
return false;
|
|
25
|
+
return input.resumeMode !== "off";
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Per-extension-instance policy holding one memoized provider-settings read.
|
|
29
|
+
* Settings are only read when the active model actually belongs to the lane, so
|
|
30
|
+
* other providers never pay for the lookup.
|
|
31
|
+
*/
|
|
32
|
+
export function createCompactionLanePolicy(options = {}) {
|
|
33
|
+
const load = options.loadProviderSettings ?? loadClaudeSdkOauthProviderSettingsFromDisk;
|
|
34
|
+
let cachedCwd;
|
|
35
|
+
let cachedResumeMode;
|
|
36
|
+
return {
|
|
37
|
+
disablesSenpiCompaction(context) {
|
|
38
|
+
if (context.model?.provider !== CLAUDE_SDK_OAUTH_PROVIDER_ID)
|
|
39
|
+
return false;
|
|
40
|
+
// Per-cwd cache is the intended contract (pinned by lane-policy.test.ts):
|
|
41
|
+
// resumeMode is read once per cwd. A mid-session switch takes effect on
|
|
42
|
+
// the next cwd or session.
|
|
43
|
+
if (cachedCwd !== context.cwd) {
|
|
44
|
+
try {
|
|
45
|
+
cachedResumeMode = load(context.cwd).resumeMode;
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// A settings read failure must never silently disable senpi compaction:
|
|
49
|
+
// fail closed by keeping senpi's own compaction fully active.
|
|
50
|
+
cachedCwd = undefined;
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
cachedCwd = context.cwd;
|
|
54
|
+
}
|
|
55
|
+
return isSdkNativeCompactionLane({ model: context.model, resumeMode: cachedResumeMode });
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Parse an SDK `compact_boundary` system message into the senpi ledger payload. */
|
|
60
|
+
export function parseCompactBoundaryMessage(value) {
|
|
61
|
+
if (!isRecord(value))
|
|
62
|
+
return undefined;
|
|
63
|
+
if (value.type !== "system" || value.subtype !== "compact_boundary")
|
|
64
|
+
return undefined;
|
|
65
|
+
if (typeof value.session_id !== "string" || typeof value.uuid !== "string")
|
|
66
|
+
return undefined;
|
|
67
|
+
if (!isRecord(value.compact_metadata))
|
|
68
|
+
return undefined;
|
|
69
|
+
return {
|
|
70
|
+
schema: COMPACT_BOUNDARY_SCHEMA,
|
|
71
|
+
sdkSessionId: value.session_id,
|
|
72
|
+
uuid: value.uuid,
|
|
73
|
+
compactMetadata: { ...value.compact_metadata },
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function messageDiagnostics(message) {
|
|
77
|
+
if (message.role !== "assistant")
|
|
78
|
+
return [];
|
|
79
|
+
const diagnostics = message.diagnostics;
|
|
80
|
+
return Array.isArray(diagnostics) ? diagnostics : [];
|
|
81
|
+
}
|
|
82
|
+
/** Collect every compaction boundary the lane attached to a finalized message. */
|
|
83
|
+
export function collectCompactBoundaryEntries(message) {
|
|
84
|
+
const entries = [];
|
|
85
|
+
for (const diagnostic of messageDiagnostics(message)) {
|
|
86
|
+
if (diagnostic.type !== CLAUDE_SDK_OAUTH_COMPACT_BOUNDARY_DIAGNOSTIC)
|
|
87
|
+
continue;
|
|
88
|
+
const entry = parseCompactBoundaryMessage(diagnostic.details);
|
|
89
|
+
if (entry)
|
|
90
|
+
entries.push(entry);
|
|
91
|
+
}
|
|
92
|
+
return entries;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=lane-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lane-policy.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/lane-policy.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AAEzF,OAAO,EAAE,0CAA0C,EAAE,MAAM,iCAAiC,CAAC;AAE7F,6EAA6E;AAC7E,MAAM,CAAC,MAAM,mCAAmC,GAAG,0BAA0B,CAAC;AAC9E,mFAAmF;AACnF,MAAM,CAAC,MAAM,4CAA4C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,OAAO,CAAC,CAAC;QAC9D,IAAI,KAAK;YAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["/**\n * Provider-scoped compaction opt-out for the `claude-sdk-oauth` main lane.\n *\n * That lane keeps one resident SDK session per senpi session, and the Claude\n * Agent SDK runs its own native auto-compaction over that session's transcript.\n * Running senpi's compaction on top of it would rewrite a history senpi no\n * longer owns, so senpi stands down for the lane: no auto-compaction triggers,\n * no context reduction. Every other provider is untouched.\n *\n * The stand-down is conditional on the lane actually being resident: with the\n * `resumeMode: \"off\"` escape hatch senpi flattens its own history into every\n * request, so senpi's compaction must stay fully active there.\n *\n * This module also owns the shape of the mirrored `compact_boundary` ledger\n * entry, so the SDK's native compactions stay visible in senpi history.\n */\nimport type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { AssistantMessageDiagnostic } from \"@earendil-works/pi-ai\";\nimport { CLAUDE_SDK_OAUTH_PROVIDER_ID } from \"../claude-sdk-oauth/account-management.ts\";\nimport type { ClaudeSdkOauthProviderSettings } from \"../claude-sdk-oauth/settings.ts\";\nimport { loadClaudeSdkOauthProviderSettingsFromDisk } from \"../claude-sdk-oauth/settings.ts\";\n\n/** Custom session entry type carrying a mirrored SDK compaction boundary. */\nexport const CLAUDE_SDK_OAUTH_COMPACT_ENTRY_TYPE = \"claude-sdk-oauth-compact\";\n/** Assistant-message diagnostic the lane uses to transport a received boundary. */\nexport const CLAUDE_SDK_OAUTH_COMPACT_BOUNDARY_DIAGNOSTIC = \"claude_sdk_oauth_compact_boundary\";\n/**\n * Reason reported when senpi declines to compact an SDK-native lane. The\n * structured `rejectionCause` stays `cancelled-by-extension` (a closed union\n * shared with the RPC surface); this string is what the user and the compaction\n * log see.\n */\nexport const SDK_NATIVE_LANE_REJECTION_REASON = \"the Claude Agent SDK owns compaction for this session\";\nconst COMPACT_BOUNDARY_SCHEMA = \"senpi.claude-sdk-oauth.compact-boundary.v1\";\n\nexport interface LaneModel {\n\tprovider?: string;\n}\n\nexport interface SdkNativeLaneInput {\n\tmodel: LaneModel | undefined;\n\t/** Resolved `claudeSdkOauthProvider.resumeMode`; `undefined` means the \"auto\" default. */\n\tresumeMode?: string;\n}\n\nexport interface LaneContext {\n\tcwd: string;\n\tmodel: LaneModel | undefined;\n}\n\nexport interface CompactionLanePolicy {\n\t/** True when the SDK owns this lane's context and senpi compaction must stand down. */\n\tdisablesSenpiCompaction(context: LaneContext): boolean;\n}\n\nexport interface CompactBoundaryEntry {\n\tschema: typeof COMPACT_BOUNDARY_SCHEMA;\n\tsdkSessionId: string;\n\tuuid: string;\n\tcompactMetadata: Record<string, unknown>;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Pure lane predicate. Kept separate from {@link createCompactionLanePolicy} so\n * callers that already know the resolved resume mode never touch disk.\n */\nexport function isSdkNativeCompactionLane(input: SdkNativeLaneInput): boolean {\n\tif (input.model?.provider !== CLAUDE_SDK_OAUTH_PROVIDER_ID) return false;\n\treturn input.resumeMode !== \"off\";\n}\n\n/**\n * Per-extension-instance policy holding one memoized provider-settings read.\n * Settings are only read when the active model actually belongs to the lane, so\n * other providers never pay for the lookup.\n */\nexport function createCompactionLanePolicy(\n\toptions: { loadProviderSettings?: (cwd: string) => ClaudeSdkOauthProviderSettings } = {},\n): CompactionLanePolicy {\n\tconst load = options.loadProviderSettings ?? loadClaudeSdkOauthProviderSettingsFromDisk;\n\tlet cachedCwd: string | undefined;\n\tlet cachedResumeMode: string | undefined;\n\treturn {\n\t\tdisablesSenpiCompaction(context: LaneContext): boolean {\n\t\t\tif (context.model?.provider !== CLAUDE_SDK_OAUTH_PROVIDER_ID) return false;\n\t\t\t// Per-cwd cache is the intended contract (pinned by lane-policy.test.ts):\n\t\t\t// resumeMode is read once per cwd. A mid-session switch takes effect on\n\t\t\t// the next cwd or session.\n\t\t\tif (cachedCwd !== context.cwd) {\n\t\t\t\ttry {\n\t\t\t\t\tcachedResumeMode = load(context.cwd).resumeMode;\n\t\t\t\t} catch {\n\t\t\t\t\t// A settings read failure must never silently disable senpi compaction:\n\t\t\t\t\t// fail closed by keeping senpi's own compaction fully active.\n\t\t\t\t\tcachedCwd = undefined;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tcachedCwd = context.cwd;\n\t\t\t}\n\t\t\treturn isSdkNativeCompactionLane({ model: context.model, resumeMode: cachedResumeMode });\n\t\t},\n\t};\n}\n\n/** Parse an SDK `compact_boundary` system message into the senpi ledger payload. */\nexport function parseCompactBoundaryMessage(value: unknown): CompactBoundaryEntry | undefined {\n\tif (!isRecord(value)) return undefined;\n\tif (value.type !== \"system\" || value.subtype !== \"compact_boundary\") return undefined;\n\tif (typeof value.session_id !== \"string\" || typeof value.uuid !== \"string\") return undefined;\n\tif (!isRecord(value.compact_metadata)) return undefined;\n\treturn {\n\t\tschema: COMPACT_BOUNDARY_SCHEMA,\n\t\tsdkSessionId: value.session_id,\n\t\tuuid: value.uuid,\n\t\tcompactMetadata: { ...value.compact_metadata },\n\t};\n}\n\nfunction messageDiagnostics(message: AgentMessage): readonly AssistantMessageDiagnostic[] {\n\tif (message.role !== \"assistant\") return [];\n\tconst diagnostics = message.diagnostics;\n\treturn Array.isArray(diagnostics) ? diagnostics : [];\n}\n\n/** Collect every compaction boundary the lane attached to a finalized message. */\nexport function collectCompactBoundaryEntries(message: AgentMessage): CompactBoundaryEntry[] {\n\tconst entries: CompactBoundaryEntry[] = [];\n\tfor (const diagnostic of messageDiagnostics(message)) {\n\t\tif (diagnostic.type !== CLAUDE_SDK_OAUTH_COMPACT_BOUNDARY_DIAGNOSTIC) continue;\n\t\tconst entry = parseCompactBoundaryMessage(diagnostic.details);\n\t\tif (entry) entries.push(entry);\n\t}\n\treturn entries;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/log.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/log.ts"],"names":[],"mappings":"AAwCA,MAAM,MAAM,qBAAqB,GAC9B,qBAAqB,GACrB,qBAAqB,GACrB,mBAAmB,GACnB,yBAAyB,GACzB,kBAAkB,GAClB,eAAe,GACf,sBAAsB,GACtB,UAAU,GACV,cAAc,GACd,mBAAmB,GACnB,oBAAoB,GACpB,iBAAiB,GACjB,qBAAqB,GACrB,cAAc,GACd,gBAAgB,CAAC;AAEpB,MAAM,WAAW,oBAAoB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAChC,KAAK,CAAC,KAAK,EAAE,qBAAqB,EAAE,IAAI,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACvE,IAAI,CAAC,KAAK,EAAE,qBAAqB,EAAE,IAAI,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACtE;AAED,MAAM,WAAW,uBAAuB;IACvC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,sBAAsB,CACrC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,OAAO,GAAE,uBAA4B,GACnC,gBAAgB,CA4BlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,iBAAiB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAC1C,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC5B,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,SAAS;IACT,YAAY;IACZ,WAAW;IACX,QAAQ;IACR,cAAc;IACd,aAAa;IACb,cAAc;IACd,eAAe;IACf,WAAW;IACX,cAAc;IACd,OAAO;IACP,YAAY;CACZ,CAAC,CAAC;AACH,MAAM,YAAY,GAAG,oBAAoB,CAAC;AAC1C,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC;IACtB,qBAAqB;IACrB,qBAAqB;IACrB,mBAAmB;IACnB,yBAAyB;IACzB,kBAAkB;IAClB,eAAe;IACf,sBAAsB;IACtB,UAAU;IACV,cAAc;IACd,mBAAmB;IACnB,oBAAoB;IACpB,iBAAiB;IACjB,qBAAqB;IACrB,gBAAgB;CAChB,CAAC,CAAC;AAgDH,MAAM,UAAU,sBAAsB,CACrC,QAA4B,EAC5B,OAAO,GAA4B,EAAE;IAErC,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAA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AAC,KAAK,CAAC,CAAC;IAChB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAC9E,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACrC,IAAI,IAAI,KAAK,SAAS;gBAAE,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;QACzC,CAAC;IACF,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC","sourcesContent":["import { closeSync, mkdirSync, openSync, renameSync, statSync, writeSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\n\nconst DEFAULT_MAX_BYTES = 5 * 1024 * 1024;\nconst ALLOWED_KEYS = new Set([\n\t\"origin\",\n\t\"reason\",\n\t\"route\",\n\t\"variant\",\n\t\"generation\",\n\t\"requestId\",\n\t\"tokens\",\n\t\"tokensBefore\",\n\t\"savedTokens\",\n\t\"savingsRatio\",\n\t\"contextWindow\",\n\t\"threshold\",\n\t\"remainingSec\",\n\t\"count\",\n\t\"durationMs\",\n]);\nconst DEBUG_PREFIX = \"[senpi-compaction]\";\nconst EVENTS = new Set([\n\t\"speculative_started\",\n\t\"speculative_applied\",\n\t\"speculative_stale\",\n\t\"speculative_invalidated\",\n\t\"blocking_started\",\n\t\"warm_consumed\",\n\t\"core_route_generated\",\n\t\"skip_cap\",\n\t\"skip_breaker\",\n\t\"threshold_trigger\",\n\t\"hard_limit_trigger\",\n\t\"emergency_prune\",\n\t\"ineffective_counted\",\n\t\"summary_failed\",\n]);\n\nexport type CompactionLoggerEvent =\n\t| \"speculative_started\"\n\t| \"speculative_applied\"\n\t| \"speculative_stale\"\n\t| \"speculative_invalidated\"\n\t| \"blocking_started\"\n\t| \"warm_consumed\"\n\t| \"core_route_generated\"\n\t| \"skip_cap\"\n\t| \"skip_breaker\"\n\t| \"threshold_trigger\"\n\t| \"hard_limit_trigger\"\n\t| \"emergency_prune\"\n\t| \"ineffective_counted\"\n\t| \"idle_trigger\"\n\t| \"summary_failed\";\n\nexport interface CompactionLoggerData {\n\torigin?: string;\n\treason?: string;\n\troute?: string;\n\tvariant?: string;\n\tgeneration?: number;\n\trequestId?: string;\n\ttokens?: number;\n\ttokensBefore?: number;\n\tsavedTokens?: number;\n\tsavingsRatio?: number;\n\tcontextWindow?: number;\n\tthreshold?: number;\n\tremainingSec?: number;\n\tcount?: number;\n\tdurationMs?: number;\n}\n\nexport interface CompactionLogger {\n\tdebug(event: CompactionLoggerEvent, data?: CompactionLoggerData): void;\n\tinfo(event: CompactionLoggerEvent, data?: CompactionLoggerData): void;\n}\n\nexport interface CompactionLoggerOptions {\n\tsink?: (line: string) => void;\n\tmirrorToStderr?: boolean;\n\tmaxBytes?: number;\n}\n\nexport function createCompactionLogger(\n\tagentDir: string | undefined,\n\toptions: CompactionLoggerOptions = {},\n): CompactionLogger {\n\tif (typeof agentDir !== \"string\" || agentDir.length === 0) {\n\t\treturn { debug: () => {}, info: () => {} };\n\t}\n\tconst filePath = join(agentDir, \"logs\", \"compaction.log\");\n\tconst maxBytes = validMaxBytes(options.maxBytes);\n\tlet reportedFailure = false;\n\n\tfunction log(level: \"debug\" | \"info\", event: CompactionLoggerEvent, data?: CompactionLoggerData): void {\n\t\ttry {\n\t\t\tif (!EVENTS.has(event)) return;\n\t\t\tconst line = formatLine(level, event, data);\n\t\t\twriteLine(filePath, line, maxBytes, options.sink);\n\t\t\tif (options.mirrorToStderr ?? process.env.SENPI_COMPACTION_DEBUG === \"1\") {\n\t\t\t\tconsole.error(DEBUG_PREFIX, line);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (!reportedFailure) {\n\t\t\t\treportedFailure = true;\n\t\t\t\tconsole.error(\"Unable to write compaction log\", error);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tdebug: (event, data) => log(\"debug\", event, data),\n\t\tinfo: (event, data) => log(\"info\", event, data),\n\t};\n}\n\nfunction validMaxBytes(value: number | undefined): number {\n\treturn typeof value === \"number\" && Number.isFinite(value) && value > 0 ? Math.floor(value) : DEFAULT_MAX_BYTES;\n}\n\nfunction formatLine(level: \"debug\" | \"info\", event: CompactionLoggerEvent, data?: CompactionLoggerData): string {\n\tconst entry: Record<string, unknown> = { ts: new Date().toISOString(), level, event };\n\tif (data) {\n\t\tfor (const [key, value] of Object.entries(data)) {\n\t\t\tif (!ALLOWED_KEYS.has(key)) continue;\n\t\t\tconst safeValue = safeValueOf(value, new WeakSet<object>());\n\t\t\tif (safeValue !== undefined) entry[key] = safeValue;\n\t\t}\n\t}\n\treturn JSON.stringify(entry);\n}\n\nfunction writeLine(filePath: string, line: string, maxBytes: number, sink?: (line: string) => void): void {\n\tconst text = `${line}\\n`;\n\tif (sink) sink(line);\n\tmkdirSync(dirname(filePath), { recursive: true, mode: 0o700 });\n\tif (needsRotate(filePath, Buffer.byteLength(text), maxBytes)) {\n\t\tconst rotated = `${filePath}.1`;\n\t\trenameSync(filePath, rotated);\n\t}\n\tconst fd = openSync(filePath, \"a\", 0o600);\n\ttry {\n\t\twriteSync(fd, text);\n\t} finally {\n\t\tcloseSync(fd);\n\t}\n}\n\nfunction needsRotate(filePath: string, incomingBytes: number, maxBytes: number): boolean {\n\ttry {\n\t\treturn statSync(filePath).size + incomingBytes > maxBytes;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction safeValueOf(value: unknown, seen: WeakSet<object>): unknown {\n\tif (value === undefined) return undefined;\n\tif (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\" || value === null)\n\t\treturn value;\n\tif (typeof value === \"bigint\") return value.toString();\n\tif (typeof value === \"symbol\" || typeof value === \"function\") return String(value);\n\tif (typeof value !== \"object\") return String(value);\n\tif (seen.has(value)) return \"[Circular]\";\n\tseen.add(value);\n\tif (Array.isArray(value)) return value.map((item) => safeValueOf(item, seen));\n\tconst out: Record<string, unknown> = {};\n\tfor (const [key, item] of Object.entries(value)) {\n\t\tif (ALLOWED_KEYS.has(key)) {\n\t\t\tconst safe = safeValueOf(item, seen);\n\t\t\tif (safe !== undefined) out[key] = safe;\n\t\t}\n\t}\n\treturn out;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,iBAAiB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAC1C,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC5B,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,SAAS;IACT,YAAY;IACZ,WAAW;IACX,QAAQ;IACR,cAAc;IACd,aAAa;IACb,cAAc;IACd,eAAe;IACf,WAAW;IACX,cAAc;IACd,OAAO;IACP,YAAY;CACZ,CAAC,CAAC;AACH,MAAM,YAAY,GAAG,oBAAoB,CAAC;AAC1C,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC;IACtB,qBAAqB;IACrB,qBAAqB;IACrB,mBAAmB;IACnB,yBAAyB;IACzB,cAAc;IACd,kBAAkB;IAClB,eAAe;IACf,sBAAsB;IACtB,UAAU;IACV,cAAc;IACd,mBAAmB;IACnB,oBAAoB;IACpB,iBAAiB;IACjB,qBAAqB;IACrB,gBAAgB;CAChB,CAAC,CAAC;AAgDH,M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AAM,CAAC,KAAK,CAAC,CAAC;IACpD,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;QAAE,OAAO,YAAY,CAAC;IACzC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAC9E,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACrC,IAAI,IAAI,KAAK,SAAS;gBAAE,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;QACzC,CAAC;IACF,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC","sourcesContent":["import { closeSync, mkdirSync, openSync, renameSync, statSync, writeSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\n\nconst DEFAULT_MAX_BYTES = 5 * 1024 * 1024;\nconst ALLOWED_KEYS = new Set([\n\t\"origin\",\n\t\"reason\",\n\t\"route\",\n\t\"variant\",\n\t\"generation\",\n\t\"requestId\",\n\t\"tokens\",\n\t\"tokensBefore\",\n\t\"savedTokens\",\n\t\"savingsRatio\",\n\t\"contextWindow\",\n\t\"threshold\",\n\t\"remainingSec\",\n\t\"count\",\n\t\"durationMs\",\n]);\nconst DEBUG_PREFIX = \"[senpi-compaction]\";\nconst EVENTS = new Set([\n\t\"speculative_started\",\n\t\"speculative_applied\",\n\t\"speculative_stale\",\n\t\"speculative_invalidated\",\n\t\"idle_trigger\",\n\t\"blocking_started\",\n\t\"warm_consumed\",\n\t\"core_route_generated\",\n\t\"skip_cap\",\n\t\"skip_breaker\",\n\t\"threshold_trigger\",\n\t\"hard_limit_trigger\",\n\t\"emergency_prune\",\n\t\"ineffective_counted\",\n\t\"summary_failed\",\n]);\n\nexport type CompactionLoggerEvent =\n\t| \"speculative_started\"\n\t| \"speculative_applied\"\n\t| \"speculative_stale\"\n\t| \"speculative_invalidated\"\n\t| \"blocking_started\"\n\t| \"warm_consumed\"\n\t| \"core_route_generated\"\n\t| \"skip_cap\"\n\t| \"skip_breaker\"\n\t| \"threshold_trigger\"\n\t| \"hard_limit_trigger\"\n\t| \"emergency_prune\"\n\t| \"ineffective_counted\"\n\t| \"idle_trigger\"\n\t| \"summary_failed\";\n\nexport interface CompactionLoggerData {\n\torigin?: string;\n\treason?: string;\n\troute?: string;\n\tvariant?: string;\n\tgeneration?: number;\n\trequestId?: string;\n\ttokens?: number;\n\ttokensBefore?: number;\n\tsavedTokens?: number;\n\tsavingsRatio?: number;\n\tcontextWindow?: number;\n\tthreshold?: number;\n\tremainingSec?: number;\n\tcount?: number;\n\tdurationMs?: number;\n}\n\nexport interface CompactionLogger {\n\tdebug(event: CompactionLoggerEvent, data?: CompactionLoggerData): void;\n\tinfo(event: CompactionLoggerEvent, data?: CompactionLoggerData): void;\n}\n\nexport interface CompactionLoggerOptions {\n\tsink?: (line: string) => void;\n\tmirrorToStderr?: boolean;\n\tmaxBytes?: number;\n}\n\nexport function createCompactionLogger(\n\tagentDir: string | undefined,\n\toptions: CompactionLoggerOptions = {},\n): CompactionLogger {\n\tif (typeof agentDir !== \"string\" || agentDir.length === 0) {\n\t\treturn { debug: () => {}, info: () => {} };\n\t}\n\tconst filePath = join(agentDir, \"logs\", \"compaction.log\");\n\tconst maxBytes = validMaxBytes(options.maxBytes);\n\tlet reportedFailure = false;\n\n\tfunction log(level: \"debug\" | \"info\", event: CompactionLoggerEvent, data?: CompactionLoggerData): void {\n\t\ttry {\n\t\t\tif (!EVENTS.has(event)) return;\n\t\t\tconst line = formatLine(level, event, data);\n\t\t\twriteLine(filePath, line, maxBytes, options.sink);\n\t\t\tif (options.mirrorToStderr ?? process.env.SENPI_COMPACTION_DEBUG === \"1\") {\n\t\t\t\tconsole.error(DEBUG_PREFIX, line);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (!reportedFailure) {\n\t\t\t\treportedFailure = true;\n\t\t\t\tconsole.error(\"Unable to write compaction log\", error);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tdebug: (event, data) => log(\"debug\", event, data),\n\t\tinfo: (event, data) => log(\"info\", event, data),\n\t};\n}\n\nfunction validMaxBytes(value: number | undefined): number {\n\treturn typeof value === \"number\" && Number.isFinite(value) && value > 0 ? Math.floor(value) : DEFAULT_MAX_BYTES;\n}\n\nfunction formatLine(level: \"debug\" | \"info\", event: CompactionLoggerEvent, data?: CompactionLoggerData): string {\n\tconst entry: Record<string, unknown> = { ts: new Date().toISOString(), level, event };\n\tif (data) {\n\t\tfor (const [key, value] of Object.entries(data)) {\n\t\t\tif (!ALLOWED_KEYS.has(key)) continue;\n\t\t\tconst safeValue = safeValueOf(value, new WeakSet<object>());\n\t\t\tif (safeValue !== undefined) entry[key] = safeValue;\n\t\t}\n\t}\n\treturn JSON.stringify(entry);\n}\n\nfunction writeLine(filePath: string, line: string, maxBytes: number, sink?: (line: string) => void): void {\n\tconst text = `${line}\\n`;\n\tif (sink) sink(line);\n\tmkdirSync(dirname(filePath), { recursive: true, mode: 0o700 });\n\tif (needsRotate(filePath, Buffer.byteLength(text), maxBytes)) {\n\t\tconst rotated = `${filePath}.1`;\n\t\trenameSync(filePath, rotated);\n\t}\n\tconst fd = openSync(filePath, \"a\", 0o600);\n\ttry {\n\t\twriteSync(fd, text);\n\t} finally {\n\t\tcloseSync(fd);\n\t}\n}\n\nfunction needsRotate(filePath: string, incomingBytes: number, maxBytes: number): boolean {\n\ttry {\n\t\treturn statSync(filePath).size + incomingBytes > maxBytes;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction safeValueOf(value: unknown, seen: WeakSet<object>): unknown {\n\tif (value === undefined) return undefined;\n\tif (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\" || value === null)\n\t\treturn value;\n\tif (typeof value === \"bigint\") return value.toString();\n\tif (typeof value === \"symbol\" || typeof value === \"function\") return String(value);\n\tif (typeof value !== \"object\") return String(value);\n\tif (seen.has(value)) return \"[Circular]\";\n\tseen.add(value);\n\tif (Array.isArray(value)) return value.map((item) => safeValueOf(item, seen));\n\tconst out: Record<string, unknown> = {};\n\tfor (const [key, item] of Object.entries(value)) {\n\t\tif (ALLOWED_KEYS.has(key)) {\n\t\t\tconst safe = safeValueOf(item, seen);\n\t\t\tif (safe !== undefined) out[key] = safe;\n\t\t}\n\t}\n\treturn out;\n}\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { AgentMessage } from "@earendil-works/pi-agent-core";
|
|
2
|
+
/**
|
|
3
|
+
* Overflow-retry policy for summarization requests (issue #650).
|
|
4
|
+
*
|
|
5
|
+
* When the provider verdicts a completed summarization response as context
|
|
6
|
+
* overflow, retrying with a slightly smaller input is correct — but the
|
|
7
|
+
* historical loop removed exactly one history item per FULL billed attempt,
|
|
8
|
+
* so a session whose summarization input exceeded the real window wedged on
|
|
9
|
+
* "Compacting..." for the length of its history (observed: ~48 minutes and
|
|
10
|
+
* ~13.5M billed tokens on gpt-5.6-sol). Every knob below exists to keep the
|
|
11
|
+
* worst case small and observable:
|
|
12
|
+
*
|
|
13
|
+
* - the summarization input is pre-sized before the first attempt;
|
|
14
|
+
* - each retry halves the estimated input instead of dropping one item;
|
|
15
|
+
* - retries stop at a hard attempt cap and a cumulative wall-clock budget;
|
|
16
|
+
* - exhaustion throws a typed error the deterministic fallback can classify.
|
|
17
|
+
*/
|
|
18
|
+
export declare const MAX_SUMMARIZATION_OVERFLOW_RETRIES = 3;
|
|
19
|
+
/**
|
|
20
|
+
* Cumulative wall-clock budget across all overflow retries of one compaction
|
|
21
|
+
* run. Twice the per-attempt stream budget: a slow provider may consume the
|
|
22
|
+
* per-attempt watchdog on each attempt, and the retry loop must still end
|
|
23
|
+
* well inside one user's patience.
|
|
24
|
+
*/
|
|
25
|
+
export declare const SUMMARIZATION_OVERFLOW_TOTAL_BUDGET_MS = 240000;
|
|
26
|
+
/** Fraction of the context window the summarization input may occupy. */
|
|
27
|
+
export declare const SUMMARIZATION_INPUT_BUDGET_RATIO = 0.6;
|
|
28
|
+
export declare class SummarizationOverflowExhaustedError extends Error {
|
|
29
|
+
readonly attempts: number;
|
|
30
|
+
readonly elapsedMs: number;
|
|
31
|
+
constructor(attempts: number, elapsedMs: number);
|
|
32
|
+
}
|
|
33
|
+
export interface PruneStep {
|
|
34
|
+
messages: AgentMessage[];
|
|
35
|
+
removedTokens: number;
|
|
36
|
+
}
|
|
37
|
+
export declare function estimateTotalTokens(messages: AgentMessage[]): number;
|
|
38
|
+
export declare function pruneOldMessagesToBudget(messages: AgentMessage[], targetTokens: number): AgentMessage[];
|
|
39
|
+
/** Estimated-token budget for the history portion of a summarization request. */
|
|
40
|
+
export declare function summarizationHistoryBudget(contextWindow: number, promptTokens: number): number;
|
|
41
|
+
/**
|
|
42
|
+
* Pre-size the summarization input before the first billed attempt. Only the
|
|
43
|
+
* oldest messages are dropped; a fitting input passes through untouched.
|
|
44
|
+
*/
|
|
45
|
+
export declare function boundSummarizationInput(messages: AgentMessage[], contextWindow: number, promptTokens: number): AgentMessage[];
|
|
46
|
+
/**
|
|
47
|
+
* Shrink for the next overflow retry. Halving the estimated input converges
|
|
48
|
+
* in O(log n) retries instead of the historical one-item-per-attempt O(n),
|
|
49
|
+
* where each attempt was a full billed summarization stream.
|
|
50
|
+
*/
|
|
51
|
+
export declare function shrinkSummarizationInputForOverflowRetry(messages: AgentMessage[], contextWindow: number, promptTokens: number): AgentMessage[] | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Decide whether another billed overflow retry is allowed. The attempt cap and
|
|
54
|
+
* the cumulative budget are both checked BEFORE scheduling a new request: an
|
|
55
|
+
* attempt that consumed the whole per-attempt watchdog must not be followed by
|
|
56
|
+
* another equally expensive one once the total budget is spent.
|
|
57
|
+
*/
|
|
58
|
+
export declare function allowOverflowRetry(attempts: number, elapsedMs: number): boolean;
|
|
59
|
+
//# sourceMappingURL=overflow-retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overflow-retry.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/overflow-retry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAGlE;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,kCAAkC,IAAI,CAAC;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,sCAAsC,SAAU,CAAC;AAE9D,yEAAyE;AACzE,eAAO,MAAM,gCAAgC,MAAM,CAAC;AAKpD,qBAAa,mCAAoC,SAAQ,KAAK;IAC7D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,YAAY,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAQ9C;CACD;AAED,MAAM,WAAW,SAAS;IACzB,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,MAAM,CAIpE;AA4DD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,YAAY,EAAE,MAAM,GAAG,YAAY,EAAE,CAWvG;AAED,iFAAiF;AACjF,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAK9F;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACtC,QAAQ,EAAE,YAAY,EAAE,EACxB,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,GAClB,YAAY,EAAE,CAEhB;AAED;;;;GAIG;AACH,wBAAgB,wCAAwC,CACvD,QAAQ,EAAE,YAAY,EAAE,EACxB,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,GAClB,YAAY,EAAE,GAAG,SAAS,CAU5B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAE/E"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { estimateTokens } from "../../../compaction/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Overflow-retry policy for summarization requests (issue #650).
|
|
4
|
+
*
|
|
5
|
+
* When the provider verdicts a completed summarization response as context
|
|
6
|
+
* overflow, retrying with a slightly smaller input is correct — but the
|
|
7
|
+
* historical loop removed exactly one history item per FULL billed attempt,
|
|
8
|
+
* so a session whose summarization input exceeded the real window wedged on
|
|
9
|
+
* "Compacting..." for the length of its history (observed: ~48 minutes and
|
|
10
|
+
* ~13.5M billed tokens on gpt-5.6-sol). Every knob below exists to keep the
|
|
11
|
+
* worst case small and observable:
|
|
12
|
+
*
|
|
13
|
+
* - the summarization input is pre-sized before the first attempt;
|
|
14
|
+
* - each retry halves the estimated input instead of dropping one item;
|
|
15
|
+
* - retries stop at a hard attempt cap and a cumulative wall-clock budget;
|
|
16
|
+
* - exhaustion throws a typed error the deterministic fallback can classify.
|
|
17
|
+
*/
|
|
18
|
+
export const MAX_SUMMARIZATION_OVERFLOW_RETRIES = 3;
|
|
19
|
+
/**
|
|
20
|
+
* Cumulative wall-clock budget across all overflow retries of one compaction
|
|
21
|
+
* run. Twice the per-attempt stream budget: a slow provider may consume the
|
|
22
|
+
* per-attempt watchdog on each attempt, and the retry loop must still end
|
|
23
|
+
* well inside one user's patience.
|
|
24
|
+
*/
|
|
25
|
+
export const SUMMARIZATION_OVERFLOW_TOTAL_BUDGET_MS = 240_000;
|
|
26
|
+
/** Fraction of the context window the summarization input may occupy. */
|
|
27
|
+
export const SUMMARIZATION_INPUT_BUDGET_RATIO = 0.6;
|
|
28
|
+
/** Floor for the history budget after reserving space for the prompt. */
|
|
29
|
+
const MIN_HISTORY_BUDGET_TOKENS = 256;
|
|
30
|
+
export class SummarizationOverflowExhaustedError extends Error {
|
|
31
|
+
constructor(attempts, elapsedMs) {
|
|
32
|
+
super(`Compaction summary request exceeded the context window after ${attempts} overflow ` +
|
|
33
|
+
`${attempts === 1 ? "retry" : "retries"} over ${Math.round(elapsedMs / 1000)}s`);
|
|
34
|
+
this.name = "SummarizationOverflowExhaustedError";
|
|
35
|
+
this.attempts = attempts;
|
|
36
|
+
this.elapsedMs = elapsedMs;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function estimateTotalTokens(messages) {
|
|
40
|
+
let total = 0;
|
|
41
|
+
for (const message of messages)
|
|
42
|
+
total += estimateTokens(message);
|
|
43
|
+
return total;
|
|
44
|
+
}
|
|
45
|
+
function getToolCallIds(message) {
|
|
46
|
+
const ids = new Set();
|
|
47
|
+
if (message.role !== "assistant")
|
|
48
|
+
return ids;
|
|
49
|
+
for (const block of message.content) {
|
|
50
|
+
if (block.type === "toolCall")
|
|
51
|
+
ids.add(block.id);
|
|
52
|
+
}
|
|
53
|
+
return ids;
|
|
54
|
+
}
|
|
55
|
+
function findLastUserLikeIndex(messages) {
|
|
56
|
+
for (let index = messages.length - 1; index >= 0; index--) {
|
|
57
|
+
const role = messages[index]?.role;
|
|
58
|
+
if (role === "user" || role === "bashExecution")
|
|
59
|
+
return index;
|
|
60
|
+
}
|
|
61
|
+
return messages.length;
|
|
62
|
+
}
|
|
63
|
+
function removeAssistantToolPair(messages, assistantIndex) {
|
|
64
|
+
const ids = getToolCallIds(messages[assistantIndex]);
|
|
65
|
+
let removedTokens = 0;
|
|
66
|
+
const pruned = messages.filter((message, index) => {
|
|
67
|
+
const remove = index === assistantIndex || (message.role === "toolResult" && ids.has(message.toolCallId));
|
|
68
|
+
if (remove)
|
|
69
|
+
removedTokens += estimateTokens(message);
|
|
70
|
+
return !remove;
|
|
71
|
+
});
|
|
72
|
+
return { messages: pruned, removedTokens };
|
|
73
|
+
}
|
|
74
|
+
function removeFirstOldToolPair(messages, boundaryIndex) {
|
|
75
|
+
for (let index = 0; index < boundaryIndex; index++) {
|
|
76
|
+
const message = messages[index];
|
|
77
|
+
if (!message)
|
|
78
|
+
continue;
|
|
79
|
+
if (message.role === "assistant" && getToolCallIds(message).size > 0)
|
|
80
|
+
return removeAssistantToolPair(messages, index);
|
|
81
|
+
if (message.role === "toolResult") {
|
|
82
|
+
return {
|
|
83
|
+
messages: messages.filter((_message, candidateIndex) => candidateIndex !== index),
|
|
84
|
+
removedTokens: estimateTokens(message),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
function removeFirstOldMessage(messages, boundaryIndex) {
|
|
91
|
+
for (let index = 0; index < boundaryIndex; index++) {
|
|
92
|
+
const message = messages[index];
|
|
93
|
+
if (!message || message.role === "toolResult")
|
|
94
|
+
continue;
|
|
95
|
+
if (message.role === "assistant" && getToolCallIds(message).size > 0)
|
|
96
|
+
return removeAssistantToolPair(messages, index);
|
|
97
|
+
return {
|
|
98
|
+
messages: messages.filter((_candidate, candidateIndex) => candidateIndex !== index),
|
|
99
|
+
removedTokens: estimateTokens(message),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
export function pruneOldMessagesToBudget(messages, targetTokens) {
|
|
105
|
+
let pruned = messages;
|
|
106
|
+
let total = estimateTotalTokens(pruned);
|
|
107
|
+
while (total > targetTokens) {
|
|
108
|
+
const boundaryIndex = findLastUserLikeIndex(pruned);
|
|
109
|
+
const next = removeFirstOldToolPair(pruned, boundaryIndex) ?? removeFirstOldMessage(pruned, boundaryIndex);
|
|
110
|
+
if (!next || next.messages.length === pruned.length)
|
|
111
|
+
break;
|
|
112
|
+
pruned = next.messages;
|
|
113
|
+
total -= next.removedTokens;
|
|
114
|
+
}
|
|
115
|
+
return pruned;
|
|
116
|
+
}
|
|
117
|
+
/** Estimated-token budget for the history portion of a summarization request. */
|
|
118
|
+
export function summarizationHistoryBudget(contextWindow, promptTokens) {
|
|
119
|
+
return Math.max(MIN_HISTORY_BUDGET_TOKENS, Math.floor(contextWindow * SUMMARIZATION_INPUT_BUDGET_RATIO) - promptTokens);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Pre-size the summarization input before the first billed attempt. Only the
|
|
123
|
+
* oldest messages are dropped; a fitting input passes through untouched.
|
|
124
|
+
*/
|
|
125
|
+
export function boundSummarizationInput(messages, contextWindow, promptTokens) {
|
|
126
|
+
return pruneOldMessagesToBudget(messages, summarizationHistoryBudget(contextWindow, promptTokens));
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Shrink for the next overflow retry. Halving the estimated input converges
|
|
130
|
+
* in O(log n) retries instead of the historical one-item-per-attempt O(n),
|
|
131
|
+
* where each attempt was a full billed summarization stream.
|
|
132
|
+
*/
|
|
133
|
+
export function shrinkSummarizationInputForOverflowRetry(messages, contextWindow, promptTokens) {
|
|
134
|
+
if (messages.length <= 1)
|
|
135
|
+
return undefined;
|
|
136
|
+
const budget = summarizationHistoryBudget(contextWindow, promptTokens);
|
|
137
|
+
const halfTokens = Math.floor(estimateTotalTokens(messages) / 2);
|
|
138
|
+
const shrunk = pruneOldMessagesToBudget(messages, Math.min(halfTokens, budget));
|
|
139
|
+
if (shrunk.length < messages.length)
|
|
140
|
+
return shrunk;
|
|
141
|
+
// Every remaining message sits at or after the turn boundary, so budget
|
|
142
|
+
// pruning cannot shrink further; still drop the oldest so the retry
|
|
143
|
+
// differs from the rejected attempt instead of re-billing an identical one.
|
|
144
|
+
return messages.slice(1);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Decide whether another billed overflow retry is allowed. The attempt cap and
|
|
148
|
+
* the cumulative budget are both checked BEFORE scheduling a new request: an
|
|
149
|
+
* attempt that consumed the whole per-attempt watchdog must not be followed by
|
|
150
|
+
* another equally expensive one once the total budget is spent.
|
|
151
|
+
*/
|
|
152
|
+
export function allowOverflowRetry(attempts, elapsedMs) {
|
|
153
|
+
return attempts < MAX_SUMMARIZATION_OVERFLOW_RETRIES && elapsedMs < SUMMARIZATION_OVERFLOW_TOTAL_BUDGET_MS;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=overflow-retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overflow-retry.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/overflow-retry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,OAAO,CAAC;AAE9D,yEAAyE;AACzE,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAG,CAAC;AAEpD,yEAAyE;AACzE,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAEtC,MAAM,OAAO,mCAAoC,SAAQ,KAAK;IAI7D,YAAY,QAAgB,EAAE,SAAiB;QAC9C,KAAK,CACJ,gEAAgE,QAAQ,YAAY;YACnF,GAAG,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,SAAS,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAChF,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,qCAAqC,CAAC;QAClD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC5B,CAAC;CACD;AAOD,M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AC,QAAQ,EAAE,0BAA0B,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;AACpG,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wCAAwC,CACvD,QAAwB,EACxB,aAAqB,EACrB,YAAoB;IAEpB,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC;IAC3C,MAAM,MAAM,GAAG,0BAA0B,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;IACvE,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IACjE,MAAM,MAAM,GAAG,wBAAwB,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;IAChF,IAAI,MAAM,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM;QAAE,OAAO,MAAM,CAAC;IACnD,wEAAwE;IACxE,oEAAoE;IACpE,4EAA4E;IAC5E,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB,EAAE,SAAiB;IACrE,OAAO,QAAQ,GAAG,kCAAkC,IAAI,SAAS,GAAG,sCAAsC,CAAC;AAC5G,CAAC","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport { estimateTokens } from \"../../../compaction/index.ts\";\n\n/**\n * Overflow-retry policy for summarization requests (issue #650).\n *\n * When the provider verdicts a completed summarization response as context\n * overflow, retrying with a slightly smaller input is correct — but the\n * historical loop removed exactly one history item per FULL billed attempt,\n * so a session whose summarization input exceeded the real window wedged on\n * \"Compacting...\" for the length of its history (observed: ~48 minutes and\n * ~13.5M billed tokens on gpt-5.6-sol). Every knob below exists to keep the\n * worst case small and observable:\n *\n * - the summarization input is pre-sized before the first attempt;\n * - each retry halves the estimated input instead of dropping one item;\n * - retries stop at a hard attempt cap and a cumulative wall-clock budget;\n * - exhaustion throws a typed error the deterministic fallback can classify.\n */\n\nexport const MAX_SUMMARIZATION_OVERFLOW_RETRIES = 3;\n\n/**\n * Cumulative wall-clock budget across all overflow retries of one compaction\n * run. Twice the per-attempt stream budget: a slow provider may consume the\n * per-attempt watchdog on each attempt, and the retry loop must still end\n * well inside one user's patience.\n */\nexport const SUMMARIZATION_OVERFLOW_TOTAL_BUDGET_MS = 240_000;\n\n/** Fraction of the context window the summarization input may occupy. */\nexport const SUMMARIZATION_INPUT_BUDGET_RATIO = 0.6;\n\n/** Floor for the history budget after reserving space for the prompt. */\nconst MIN_HISTORY_BUDGET_TOKENS = 256;\n\nexport class SummarizationOverflowExhaustedError extends Error {\n\treadonly attempts: number;\n\treadonly elapsedMs: number;\n\n\tconstructor(attempts: number, elapsedMs: number) {\n\t\tsuper(\n\t\t\t`Compaction summary request exceeded the context window after ${attempts} overflow ` +\n\t\t\t\t`${attempts === 1 ? \"retry\" : \"retries\"} over ${Math.round(elapsedMs / 1000)}s`,\n\t\t);\n\t\tthis.name = \"SummarizationOverflowExhaustedError\";\n\t\tthis.attempts = attempts;\n\t\tthis.elapsedMs = elapsedMs;\n\t}\n}\n\nexport interface PruneStep {\n\tmessages: AgentMessage[];\n\tremovedTokens: number;\n}\n\nexport function estimateTotalTokens(messages: AgentMessage[]): number {\n\tlet total = 0;\n\tfor (const message of messages) total += estimateTokens(message);\n\treturn total;\n}\n\nfunction getToolCallIds(message: AgentMessage): Set<string> {\n\tconst ids = new Set<string>();\n\tif (message.role !== \"assistant\") return ids;\n\tfor (const block of message.content) {\n\t\tif (block.type === \"toolCall\") ids.add(block.id);\n\t}\n\treturn ids;\n}\n\nfunction findLastUserLikeIndex(messages: AgentMessage[]): number {\n\tfor (let index = messages.length - 1; index >= 0; index--) {\n\t\tconst role = messages[index]?.role;\n\t\tif (role === \"user\" || role === \"bashExecution\") return index;\n\t}\n\treturn messages.length;\n}\n\nfunction removeAssistantToolPair(messages: AgentMessage[], assistantIndex: number): PruneStep {\n\tconst ids = getToolCallIds(messages[assistantIndex]);\n\tlet removedTokens = 0;\n\tconst pruned = messages.filter((message, index) => {\n\t\tconst remove = index === assistantIndex || (message.role === \"toolResult\" && ids.has(message.toolCallId));\n\t\tif (remove) removedTokens += estimateTokens(message);\n\t\treturn !remove;\n\t});\n\treturn { messages: pruned, removedTokens };\n}\n\nfunction removeFirstOldToolPair(messages: AgentMessage[], boundaryIndex: number): PruneStep | undefined {\n\tfor (let index = 0; index < boundaryIndex; index++) {\n\t\tconst message = messages[index];\n\t\tif (!message) continue;\n\t\tif (message.role === \"assistant\" && getToolCallIds(message).size > 0)\n\t\t\treturn removeAssistantToolPair(messages, index);\n\t\tif (message.role === \"toolResult\") {\n\t\t\treturn {\n\t\t\t\tmessages: messages.filter((_message, candidateIndex) => candidateIndex !== index),\n\t\t\t\tremovedTokens: estimateTokens(message),\n\t\t\t};\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction removeFirstOldMessage(messages: AgentMessage[], boundaryIndex: number): PruneStep | undefined {\n\tfor (let index = 0; index < boundaryIndex; index++) {\n\t\tconst message = messages[index];\n\t\tif (!message || message.role === \"toolResult\") continue;\n\t\tif (message.role === \"assistant\" && getToolCallIds(message).size > 0)\n\t\t\treturn removeAssistantToolPair(messages, index);\n\t\treturn {\n\t\t\tmessages: messages.filter((_candidate, candidateIndex) => candidateIndex !== index),\n\t\t\tremovedTokens: estimateTokens(message),\n\t\t};\n\t}\n\treturn undefined;\n}\n\nexport function pruneOldMessagesToBudget(messages: AgentMessage[], targetTokens: number): AgentMessage[] {\n\tlet pruned = messages;\n\tlet total = estimateTotalTokens(pruned);\n\twhile (total > targetTokens) {\n\t\tconst boundaryIndex = findLastUserLikeIndex(pruned);\n\t\tconst next = removeFirstOldToolPair(pruned, boundaryIndex) ?? removeFirstOldMessage(pruned, boundaryIndex);\n\t\tif (!next || next.messages.length === pruned.length) break;\n\t\tpruned = next.messages;\n\t\ttotal -= next.removedTokens;\n\t}\n\treturn pruned;\n}\n\n/** Estimated-token budget for the history portion of a summarization request. */\nexport function summarizationHistoryBudget(contextWindow: number, promptTokens: number): number {\n\treturn Math.max(\n\t\tMIN_HISTORY_BUDGET_TOKENS,\n\t\tMath.floor(contextWindow * SUMMARIZATION_INPUT_BUDGET_RATIO) - promptTokens,\n\t);\n}\n\n/**\n * Pre-size the summarization input before the first billed attempt. Only the\n * oldest messages are dropped; a fitting input passes through untouched.\n */\nexport function boundSummarizationInput(\n\tmessages: AgentMessage[],\n\tcontextWindow: number,\n\tpromptTokens: number,\n): AgentMessage[] {\n\treturn pruneOldMessagesToBudget(messages, summarizationHistoryBudget(contextWindow, promptTokens));\n}\n\n/**\n * Shrink for the next overflow retry. Halving the estimated input converges\n * in O(log n) retries instead of the historical one-item-per-attempt O(n),\n * where each attempt was a full billed summarization stream.\n */\nexport function shrinkSummarizationInputForOverflowRetry(\n\tmessages: AgentMessage[],\n\tcontextWindow: number,\n\tpromptTokens: number,\n): AgentMessage[] | undefined {\n\tif (messages.length <= 1) return undefined;\n\tconst budget = summarizationHistoryBudget(contextWindow, promptTokens);\n\tconst halfTokens = Math.floor(estimateTotalTokens(messages) / 2);\n\tconst shrunk = pruneOldMessagesToBudget(messages, Math.min(halfTokens, budget));\n\tif (shrunk.length < messages.length) return shrunk;\n\t// Every remaining message sits at or after the turn boundary, so budget\n\t// pruning cannot shrink further; still drop the oldest so the retry\n\t// differs from the rejected attempt instead of re-billing an identical one.\n\treturn messages.slice(1);\n}\n\n/**\n * Decide whether another billed overflow retry is allowed. The attempt cap and\n * the cumulative budget are both checked BEFORE scheduling a new request: an\n * attempt that consumed the whole per-attempt watchdog must not be followed by\n * another equally expensive one once the total budget is spent.\n */\nexport function allowOverflowRetry(attempts: number, elapsedMs: number): boolean {\n\treturn attempts < MAX_SUMMARIZATION_OVERFLOW_RETRIES && elapsedMs < SUMMARIZATION_OVERFLOW_TOTAL_BUDGET_MS;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speculative.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/speculative.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAQN,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"speculative.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/speculative.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAQN,KAAK,KAAK,EAIV,KAAK,IAAI,EACT,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EAIrB,MAAM,8BAA8B,CAAC;AAOtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAWtG,OAAO,EAAe,KAAK,6BAA6B,EAAE,MAAM,cAAc,CAAC;AAiB/E,KAAK,0BAA0B,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;AAE1D,MAAM,WAAW,4BAA4B;IAC5C,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC9B,cAAc,EAAE,sBAAsB,CAAC;IACvC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,eAAe,IAAI,YAAY,GAAG,SAAS,CAAC;IAC5C,qBAAqB,CAAC,IAAI,qBAAqB,CAAC,UAAU,CAAC,CAAC;IAC5D,kBAAkB,IAAI,MAAM,CAAC;IAC7B,eAAe,CAAC,IAAI,MAAM,CAAC;IAC3B,sBAAsB,CAAC,CAAC,QAAQ,EAAE,YAAY,EAA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B,wBAAwB,CAC7C,OAAO,EAAE,4BAA4B,EACrC,QAAQ,EAAE,6BAA6B,GAAG,SAAS,EACnD,oBAAoB,EAAE,MAAM,MAAM,EAClC,UAAU,EAAE,gBAAgB,GAAG,SAAS,EACxC,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,2BAA2B,CAAC,CAYtC;AAED,wBAAsB,0BAA0B,CAC/C,OAAO,EAAE,4BAA4B,EACrC,QAAQ,EAAE,6BAA6B,GAAG,SAAS,EACnD,oBAAoB,EAAE,MAAM,MAAM,EAClC,QAAQ,EAAE,MAAM,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,GACnD,OAAO,CAAC,2BAA2B,CAAC,CAKtC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { hasCredentialHeaders, isContextOverflow, isRetryableAssistantError, } from "@earendil-works/pi-ai";
|
|
1
|
+
import { hasCredentialHeaders, isContextOverflow, isRetryableAssistantError, sanitizeAnthropicToolPairs as sanitizeAnthropicPayload, } from "@earendil-works/pi-ai";
|
|
2
2
|
import { stream } from "@earendil-works/pi-ai/compat";
|
|
3
|
-
import { DEFAULT_COMPACTION_SETTINGS, estimateContextTokens,
|
|
3
|
+
import { DEFAULT_COMPACTION_SETTINGS, estimateContextTokens, prepareCompaction, } from "../../../compaction/index.js";
|
|
4
4
|
import { consumeStreamWithIdleTimeout, DEFAULT_SUMMARIZATION_IDLE_TIMEOUT_MS, DEFAULT_SUMMARIZATION_MAX_DURATION_MS, } from "../../../compaction/stream-watchdog.js";
|
|
5
5
|
import { convertToLlm } from "../../../messages.js";
|
|
6
|
-
import {
|
|
6
|
+
import { allowOverflowRetry, boundSummarizationInput, estimateTotalTokens, pruneOldMessagesToBudget, SUMMARIZATION_INPUT_BUDGET_RATIO, SummarizationOverflowExhaustedError, shrinkSummarizationInputForOverflowRetry, } from "./overflow-retry.js";
|
|
7
7
|
import { computeEffectiveKeepRecentTokens, computeEffectiveThreshold } from "./policy.js";
|
|
8
8
|
import { buildPrompt } from "./prompts.js";
|
|
9
9
|
import { repairOrphanedToolResults } from "./repair-tool-pairs.js";
|
|
@@ -11,7 +11,6 @@ import { extractTaskIntent, resolveInheritedTaskIntent } from "./task-intent.js"
|
|
|
11
11
|
import * as truncation from "./tool-truncation.js";
|
|
12
12
|
import { computeStructuralYield } from "./yield.js";
|
|
13
13
|
const DEFAULT_CONTEXT_WINDOW = 200_000;
|
|
14
|
-
const COMPACTION_BUDGET_RATIO = 0.6;
|
|
15
14
|
const EMERGENCY_CONTEXT_TARGET_RATIO = 0.95;
|
|
16
15
|
// Hysteresis: the emergency prune engages at EMERGENCY_CONTEXT_TARGET_RATIO but only
|
|
17
16
|
// releases once the context falls below this lower ratio. A single threshold makes a
|
|
@@ -177,13 +176,13 @@ async function generateSummaryMessage(options) {
|
|
|
177
176
|
options.signal.removeEventListener("abort", onCallerAbort);
|
|
178
177
|
}
|
|
179
178
|
}
|
|
180
|
-
function pruneToolResults(messages, contextWindow) {
|
|
179
|
+
function pruneToolResults(messages, contextWindow, budgetRatio) {
|
|
181
180
|
const toolResults = messages
|
|
182
181
|
.filter((message) => message.role === "toolResult")
|
|
183
182
|
.map((message) => ({ content: message.content, details: undefined }));
|
|
184
183
|
if (toolResults.length === 0)
|
|
185
184
|
return messages;
|
|
186
|
-
const prunedResults = truncation.prePruneToolOutputsToBudget(toolResults, contextWindow *
|
|
185
|
+
const prunedResults = truncation.prePruneToolOutputsToBudget(toolResults, contextWindow * budgetRatio);
|
|
187
186
|
let resultIndex = 0;
|
|
188
187
|
return messages.map((message) => {
|
|
189
188
|
if (message.role !== "toolResult")
|
|
@@ -209,92 +208,6 @@ export function truncateContextMessages(messages) {
|
|
|
209
208
|
return truncated ? { ...message, content: truncated.content } : message;
|
|
210
209
|
});
|
|
211
210
|
}
|
|
212
|
-
function getToolCallIds(message) {
|
|
213
|
-
const ids = new Set();
|
|
214
|
-
if (message.role !== "assistant")
|
|
215
|
-
return ids;
|
|
216
|
-
for (const block of message.content) {
|
|
217
|
-
if (block.type === "toolCall")
|
|
218
|
-
ids.add(block.id);
|
|
219
|
-
}
|
|
220
|
-
return ids;
|
|
221
|
-
}
|
|
222
|
-
function findLastUserLikeIndex(messages) {
|
|
223
|
-
for (let index = messages.length - 1; index >= 0; index--) {
|
|
224
|
-
const role = messages[index]?.role;
|
|
225
|
-
if (role === "user" || role === "bashExecution")
|
|
226
|
-
return index;
|
|
227
|
-
}
|
|
228
|
-
return messages.length;
|
|
229
|
-
}
|
|
230
|
-
function removeAssistantToolPair(messages, assistantIndex) {
|
|
231
|
-
const ids = getToolCallIds(messages[assistantIndex]);
|
|
232
|
-
let removedTokens = 0;
|
|
233
|
-
const pruned = messages.filter((message, index) => {
|
|
234
|
-
const remove = index === assistantIndex || (message.role === "toolResult" && ids.has(message.toolCallId));
|
|
235
|
-
if (remove)
|
|
236
|
-
removedTokens += estimateTokens(message);
|
|
237
|
-
return !remove;
|
|
238
|
-
});
|
|
239
|
-
return { messages: pruned, removedTokens };
|
|
240
|
-
}
|
|
241
|
-
function removeFirstOldToolPair(messages, boundaryIndex) {
|
|
242
|
-
for (let index = 0; index < boundaryIndex; index++) {
|
|
243
|
-
const message = messages[index];
|
|
244
|
-
if (!message)
|
|
245
|
-
continue;
|
|
246
|
-
if (message.role === "assistant" && getToolCallIds(message).size > 0)
|
|
247
|
-
return removeAssistantToolPair(messages, index);
|
|
248
|
-
if (message.role === "toolResult") {
|
|
249
|
-
return {
|
|
250
|
-
messages: messages.filter((_message, candidateIndex) => candidateIndex !== index),
|
|
251
|
-
removedTokens: estimateTokens(message),
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
return undefined;
|
|
256
|
-
}
|
|
257
|
-
function removeFirstOldMessage(messages, boundaryIndex) {
|
|
258
|
-
for (let index = 0; index < boundaryIndex; index++) {
|
|
259
|
-
const message = messages[index];
|
|
260
|
-
if (!message || message.role === "toolResult")
|
|
261
|
-
continue;
|
|
262
|
-
if (message.role === "assistant" && getToolCallIds(message).size > 0)
|
|
263
|
-
return removeAssistantToolPair(messages, index);
|
|
264
|
-
return {
|
|
265
|
-
messages: messages.filter((_candidate, candidateIndex) => candidateIndex !== index),
|
|
266
|
-
removedTokens: estimateTokens(message),
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
return undefined;
|
|
270
|
-
}
|
|
271
|
-
function pruneOldMessagesToBudget(messages, targetTokens) {
|
|
272
|
-
let pruned = messages;
|
|
273
|
-
let total = estimateTotalTokens(pruned);
|
|
274
|
-
while (total > targetTokens) {
|
|
275
|
-
const boundaryIndex = findLastUserLikeIndex(pruned);
|
|
276
|
-
const next = removeFirstOldToolPair(pruned, boundaryIndex) ?? removeFirstOldMessage(pruned, boundaryIndex);
|
|
277
|
-
if (!next || next.messages.length === pruned.length)
|
|
278
|
-
break;
|
|
279
|
-
pruned = next.messages;
|
|
280
|
-
total -= next.removedTokens;
|
|
281
|
-
}
|
|
282
|
-
return pruned;
|
|
283
|
-
}
|
|
284
|
-
function removeOldestHistoryItemForOverflowRetry(messages) {
|
|
285
|
-
if (messages.length <= 1)
|
|
286
|
-
return undefined;
|
|
287
|
-
const boundaryIndex = findLastUserLikeIndex(messages);
|
|
288
|
-
return (removeFirstOldToolPair(messages, boundaryIndex)?.messages ??
|
|
289
|
-
removeFirstOldMessage(messages, boundaryIndex)?.messages ??
|
|
290
|
-
(messages.length > 1 ? messages.slice(1) : undefined));
|
|
291
|
-
}
|
|
292
|
-
function estimateTotalTokens(messages) {
|
|
293
|
-
let total = 0;
|
|
294
|
-
for (const message of messages)
|
|
295
|
-
total += estimateTokens(message);
|
|
296
|
-
return total;
|
|
297
|
-
}
|
|
298
211
|
export function createEmergencyPruneLatch() {
|
|
299
212
|
return { engaged: false };
|
|
300
213
|
}
|
|
@@ -313,7 +226,7 @@ export function hardLimitEmergencyPrune(messages, contextWindow, latch) {
|
|
|
313
226
|
if (!engaged) {
|
|
314
227
|
return { messages, needsAggressiveCompaction: false };
|
|
315
228
|
}
|
|
316
|
-
const noLlmPruned = truncateContextMessages(pruneToolResults(messages, contextWindow));
|
|
229
|
+
const noLlmPruned = truncateContextMessages(pruneToolResults(messages, contextWindow, SUMMARIZATION_INPUT_BUDGET_RATIO));
|
|
317
230
|
if (estimateTotalTokens(noLlmPruned) <= targetTokens) {
|
|
318
231
|
return { messages: noLlmPruned, needsAggressiveCompaction: false };
|
|
319
232
|
}
|
|
@@ -382,13 +295,16 @@ export async function runExtensionCompaction(context, snapshot, signal, onProgre
|
|
|
382
295
|
const detail = auth && !auth.ok ? auth.error : `no credentials resolved for provider "${snapshot.model.provider}"`;
|
|
383
296
|
throw new SummaryGenerationError("auth", `summarization credentials unavailable: ${detail}`);
|
|
384
297
|
}
|
|
385
|
-
let messages = pruneToolResults([...snapshot.preparation.messagesToSummarize, ...snapshot.preparation.turnPrefixMessages], snapshot.contextWindow);
|
|
386
298
|
const prompt = buildPrompt({
|
|
387
299
|
variant: snapshot.promptVariant,
|
|
388
300
|
previousSummary: snapshot.preparation.previousSummary,
|
|
389
301
|
taskIntent: resolveInheritedTaskIntent(snapshot.branchEntries ?? []),
|
|
390
302
|
customInstructions: snapshot.customInstructions,
|
|
391
303
|
});
|
|
304
|
+
const promptTokens = approxTokens(prompt.user);
|
|
305
|
+
let messages = boundSummarizationInput(pruneToolResults([...snapshot.preparation.messagesToSummarize, ...snapshot.preparation.turnPrefixMessages], snapshot.contextWindow, SUMMARIZATION_INPUT_BUDGET_RATIO), snapshot.contextWindow, promptTokens);
|
|
306
|
+
const overflowRetryStartMs = Date.now();
|
|
307
|
+
let overflowAttempts = 0;
|
|
392
308
|
while (true) {
|
|
393
309
|
if (signal?.aborted)
|
|
394
310
|
return undefined;
|
|
@@ -408,9 +324,13 @@ export async function runExtensionCompaction(context, snapshot, signal, onProgre
|
|
|
408
324
|
if (!response)
|
|
409
325
|
return undefined;
|
|
410
326
|
if (isAssistantMessage(response) && isContextOverflow(response, snapshot.contextWindow)) {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
327
|
+
overflowAttempts++;
|
|
328
|
+
const elapsedMs = Date.now() - overflowRetryStartMs;
|
|
329
|
+
const retryMessages = allowOverflowRetry(overflowAttempts, elapsedMs)
|
|
330
|
+
? shrinkSummarizationInputForOverflowRetry(messages, snapshot.contextWindow, promptTokens)
|
|
331
|
+
: undefined;
|
|
332
|
+
if (!retryMessages) {
|
|
333
|
+
throw new SummarizationOverflowExhaustedError(overflowAttempts, elapsedMs);
|
|
414
334
|
}
|
|
415
335
|
messages = retryMessages;
|
|
416
336
|
continue;
|
|
@@ -458,7 +378,6 @@ export async function runExtensionCompaction(context, snapshot, signal, onProgre
|
|
|
458
378
|
},
|
|
459
379
|
};
|
|
460
380
|
}
|
|
461
|
-
throw new Error("Compaction summary request exceeded the context window after retrying with a smaller input");
|
|
462
381
|
}
|
|
463
382
|
export async function applyGeneratedCompaction(context, snapshot, getCurrentGeneration, compaction, signal) {
|
|
464
383
|
if (!snapshot || !compaction)
|