@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speculative.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/speculative.ts"],"names":[],"mappings":"AACA,OAAO,EAIN,oBAAoB,EACpB,iBAAiB,EACjB,yBAAyB,GAMzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAGN,2BAA2B,EAC3B,qBAAqB,EACrB,cAAc,EACd,iBAAiB,GACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,4BAA4B,EAC5B,qCAAqC,EACrC,qCAAqC,GACrC,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kDAAkD,CAAC;AAC5F,OAAO,EAAE,gCAAgC,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAsC,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,sBAAsB,GAAG,OAAO,CAAC;AACvC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,MAAM,8BAA8B,GAAG,IAAI,CA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,EAAE,IAAI,QAAQ,CAAC,gBAAgB,KAAK,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;QAClH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAC5C,CAAC;IAED,OAAO,MAAM,OAAO,CAAC,eAAe,CAAC,UAAU,EAAE;QAChD,MAAM,EAAE,WAAW;QACnB,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB;QAC3C,MAAM;KACN,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC/C,OAAqC,EACrC,QAAmD,EACnD,oBAAkC,EAClC,QAAqD;IAErD,IAAI,CAAC,QAAQ;QAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;IAEhE,MAAM,UAAU,GAAG,MAAM,QAAQ,EAAE,CAAC;IACpC,OAAO,MAAM,wBAAwB,CAAC,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,UAAU,CAAC,CAAC;AAC5F,CAAC","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport {\n\ttype AssistantMessage,\n\ttype AssistantMessageEventStream,\n\ttype Context,\n\thasCredentialHeaders,\n\tisContextOverflow,\n\tisRetryableAssistantError,\n\ttype Message,\n\ttype Model,\n\ttype StreamOptions,\n\ttype TextContent,\n\ttype Tool,\n} from \"@earendil-works/pi-ai\";\nimport { stream } from \"@earendil-works/pi-ai/compat\";\nimport {\n\ttype CompactionPreparation,\n\ttype CompactionResult,\n\tDEFAULT_COMPACTION_SETTINGS,\n\testimateContextTokens,\n\testimateTokens,\n\tprepareCompaction,\n} from \"../../../compaction/index.ts\";\nimport {\n\tconsumeStreamWithIdleTimeout,\n\tDEFAULT_SUMMARIZATION_IDLE_TIMEOUT_MS,\n\tDEFAULT_SUMMARIZATION_MAX_DURATION_MS,\n} from \"../../../compaction/stream-watchdog.ts\";\nimport { convertToLlm } from \"../../../messages.ts\";\nimport type { ModelRegistry } from \"../../../model-registry.ts\";\nimport type { ReadonlySessionManager } from \"../../../session-manager.ts\";\nimport type { ApplyCompactionResult, ContextUsage, ProviderRequestPreparation } from \"../../types.ts\";\nimport { sanitizeAnthropicPayload } from \"../tool-pair-guard/sanitize-anthropic-payload.ts\";\nimport { computeEffectiveKeepRecentTokens, computeEffectiveThreshold } from \"./policy.ts\";\nimport { buildPrompt, type MergedCompactionPromptVariant } from \"./prompts.ts\";\nimport { repairOrphanedToolResults } from \"./repair-tool-pairs.ts\";\nimport { extractTaskIntent, resolveInheritedTaskIntent } from \"./task-intent.ts\";\nimport * as truncation from \"./tool-truncation.ts\";\nimport { computeStructuralYield } from \"./yield.ts\";\n\nconst DEFAULT_CONTEXT_WINDOW = 200_000;\nconst COMPACTION_BUDGET_RATIO = 0.6;\nconst EMERGENCY_CONTEXT_TARGET_RATIO = 0.95;\n// Hysteresis: the emergency prune engages at EMERGENCY_CONTEXT_TARGET_RATIO but only\n// releases once the context falls below this lower ratio. A single threshold makes a\n// session parked near the limit alternate between the pruned and un-pruned history on\n// consecutive requests; because pruning rewrites old tool results, every alternation\n// invalidates the provider prompt-cache prefix and re-bills the whole conversation.\nconst EMERGENCY_CONTEXT_RELEASE_RATIO = 0.85;\nconst SUMMARY_TOKEN_HEADROOM = 32_768;\nconst SUMMARY_CONTEXT_WINDOW_RESERVE_RATIO = 0.5;\nconst SUMMARY_SCHEMA = \"senpi.compaction.summary.v1\";\ntype CompactionProgressCallback = (delta: string) => void;\ntype PruneStep = { messages: AgentMessage[]; removedTokens: number };\n\nexport interface SpeculativeCompactionContext {\n\tmodel: Model<any> | undefined;\n\tsessionManager: ReadonlySessionManager;\n\tmodelRegistry?: ModelRegistry;\n\tgetContextUsage(): ContextUsage | undefined;\n\tgetCompactionSettings?(): CompactionPreparation[\"settings\"];\n\tgetMessageRevision(): number;\n\tgetSystemPrompt?(): string;\n\tprepareProviderRequest?(messages: AgentMessage[]): Promise<ProviderRequestPreparation>;\n\tapplyCompaction(\n\t\tprecomputed: CompactionResult,\n\t\toptions: { reason: \"extension\"; expectedRevision: number; signal?: AbortSignal },\n\t): Promise<ApplyCompactionResult>;\n}\n\nexport interface SpeculativeCompactionSnapshot {\n\tgeneration: number;\n\texpectedRevision: number;\n\tmodel: Model<any>;\n\tcontextWindow: number;\n\tpreparation: CompactionPreparation;\n\tbranchEntries?: ReturnType<ReadonlySessionManager[\"getBranch\"]>;\n\tpromptVariant: MergedCompactionPromptVariant;\n\torigin?: \"speculative\" | \"blocking\" | \"core-route\";\n\tcustomInstructions?: string;\n\t/** Agent system prompt; used to make the summarization request look like normal agent traffic. */\n\tsystemPrompt?: string;\n\t/** Agent tool definitions; forwarded so the request shape matches normal agent traffic. */\n\ttools?: Tool[];\n}\n\nexport type SpeculativeCompactionResult = ApplyCompactionResult | { applied: false; reason: \"unavailable\" | \"failed\" };\n\nfunction approxTokens(text: string): number {\n\treturn Math.ceil(text.length / 4);\n}\n\n/**\n * Summary-generation failure with a user-facing diagnosis. Distinct from a\n * user abort (which resolves `undefined`): callers surface `message` on the\n * manual route and degrade to \"unavailable\" on automatic routes.\n */\n/**\n * Provider `error` stop during summarization, carrying the metadata-aware\n * transient classification from the full assistant message. A refusal whose\n * text happens to look retryable must still surface loudly; the message\n * string alone cannot encode that.\n */\nexport type SummaryRequestFailureKind = \"upstream-stream-truncated\";\n\nexport class SummaryRequestError extends Error {\n\treadonly transient: boolean;\n\treadonly failureKind?: SummaryRequestFailureKind;\n\n\tconstructor(message: string, transient: boolean, failureKind?: SummaryRequestFailureKind) {\n\t\tsuper(message);\n\t\tthis.name = \"SummaryRequestError\";\n\t\tthis.transient = transient;\n\t\tthis.failureKind = failureKind;\n\t}\n}\n\nconst UPSTREAM_STREAM_TRUNCATED_PATTERN = /(?:^|[^A-Za-z0-9_])upstream_stream_truncated(?:[^A-Za-z0-9_]|$)/;\n\nfunction summaryRequestFailureKind(response: AssistantMessage): SummaryRequestFailureKind | undefined {\n\tif (response.stopDetails?.type === \"refusal\" || response.stopDetails?.type === \"sensitive\") return undefined;\n\treturn UPSTREAM_STREAM_TRUNCATED_PATTERN.test(response.errorMessage ?? \"\") ? \"upstream-stream-truncated\" : undefined;\n}\n\nexport class SummaryGenerationError extends Error {\n\treadonly kind: \"auth\" | \"empty-summary\";\n\n\tconstructor(kind: \"auth\" | \"empty-summary\", message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"SummaryGenerationError\";\n\t\tthis.kind = kind;\n\t}\n}\n\n/**\n * Output budget for one summarization request. Adaptive-thinking models emit\n * reasoning tokens before the summary text, so the legacy flat 8192 cap could\n * be consumed entirely by thinking, ending the stream with zero text blocks.\n * Grant generous headroom, clamped to what the model can actually emit and to\n * half the context window: providers that enforce input + output <= window\n * would otherwise reject the request for models advertising contextWindow ==\n * maxTokens (every summarization request also carries conversation input).\n */\nfunction summaryMaxTokens(model: Model<any>, contextWindow: number): number {\n\tconst headroom = model.maxTokens > 0 ? Math.min(SUMMARY_TOKEN_HEADROOM, model.maxTokens) : SUMMARY_TOKEN_HEADROOM;\n\tif (contextWindow > 0) {\n\t\treturn Math.min(headroom, Math.floor(contextWindow * SUMMARY_CONTEXT_WINDOW_RESERVE_RATIO));\n\t}\n\treturn headroom;\n}\n\n/**\n * Reasoning override for summarization requests. Compaction must be fast: a\n * summarization request that inherits the provider's default reasoning mode\n * burns its latency (and output budget) on invisible thinking before emitting\n * the summary. Disable or minimize reasoning per wire family; adapters ignore\n * options their provider does not support. Mirrors how OpenAI Codex keeps its\n * compaction turn cheap.\n */\nfunction summarizationReasoningOptions(model: Model<any>): Record<string, unknown> {\n\tif (!model.reasoning) return {};\n\tif (model.api === \"anthropic-messages\") return { thinkingEnabled: false };\n\tconst reasoningEffort = ([\"low\", \"medium\", \"high\"] as const).find(\n\t\t(level) => model.thinkingLevelMap?.[level] !== null,\n\t);\n\tif (!reasoningEffort) return {};\n\tswitch (model.api) {\n\t\tcase \"openai-responses\":\n\t\tcase \"openai-codex-responses\":\n\t\tcase \"azure-openai-responses\":\n\t\t\treturn { reasoningEffort, reasoningSummary: null };\n\t\tcase \"openai-completions\":\n\t\t\treturn { reasoningEffort };\n\t\tdefault:\n\t\t\treturn {};\n\t}\n}\n\nfunction getSummaryText(message: Message): string {\n\tconst content = Array.isArray(message.content)\n\t\t? message.content\n\t\t: [{ type: \"text\" as const, text: message.content }];\n\treturn content\n\t\t.filter((content): content is TextContent => content.type === \"text\")\n\t\t.map((content) => content.text)\n\t\t.join(\"\\n\")\n\t\t.trim();\n}\n\nfunction isAssistantMessage(message: Message): message is AssistantMessage {\n\treturn message.role === \"assistant\" && \"stopReason\" in message;\n}\n\n/**\n * Providers registered through `pi.registerProvider()` (claude-sdk-oauth, Kiro, any\n * extension provider) exist only in Senpi's ModelRuntime, never in compat's builtin\n * api-registry, which rejects their api id outright. Dispatch through the runtime\n * whenever it is reachable and keep compat for contexts constructed without a registry.\n */\nfunction summarizationStream(\n\tcontext: SpeculativeCompactionContext,\n\tmodel: Model<any>,\n\trequestContext: Context,\n\toptions: StreamOptions & Record<string, unknown>,\n): AssistantMessageEventStream {\n\tconst runtime = context.modelRegistry?.modelRuntime;\n\treturn runtime ? runtime.stream(model, requestContext, options) : stream(model, requestContext, options);\n}\n\nasync function generateSummaryMessage(options: {\n\tcontext: SpeculativeCompactionContext;\n\tmessages: AgentMessage[];\n\tonProgress?: CompactionProgressCallback;\n\tprompt: ReturnType<typeof buildPrompt>;\n\tsignal?: AbortSignal;\n\tsnapshot: SpeculativeCompactionSnapshot;\n\tauth: {\n\t\tapiKey?: string;\n\t\theaders?: Record<string, string>;\n\t\textraBody?: Record<string, unknown>;\n\t};\n}): Promise<Message | undefined> {\n\t// Send the conversation as native LLM messages with the summarization\n\t// instruction as a trailing user message, mirroring normal agent traffic.\n\t// A single serialized `<conversation>` text dump of a large session is\n\t// deterministically refused by Anthropic's anti-distillation classifier\n\t// (\"reverse engineering or duplicating model outputs\"), while the same\n\t// content as native blocks with the agent's system prompt and tools passes.\n\t// Request-local controller: the idle watchdog must be able to tear down a\n\t// stalled summarization request without aborting the caller's own signal.\n\tconst requestController = new AbortController();\n\tconst onCallerAbort = () => requestController.abort(options.signal?.reason);\n\tif (options.signal) {\n\t\tif (options.signal.aborted) onCallerAbort();\n\t\telse options.signal.addEventListener(\"abort\", onCallerAbort, { once: true });\n\t}\n\ttry {\n\t\tconst requestMessages: AgentMessage[] = [\n\t\t\t...options.messages,\n\t\t\t{\n\t\t\t\trole: \"user\",\n\t\t\t\tcontent: [{ type: \"text\", text: options.prompt.user }],\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t},\n\t\t];\n\t\tconst providerRequest = await options.context.prepareProviderRequest?.(requestMessages);\n\t\tconst requestContext = {\n\t\t\tsystemPrompt: options.snapshot.systemPrompt ?? options.prompt.system,\n\t\t\tmessages: repairOrphanedToolResults(convertToLlm(providerRequest?.messages ?? requestMessages)),\n\t\t\t...(options.snapshot.tools && options.snapshot.tools.length > 0 ? { tools: options.snapshot.tools } : {}),\n\t\t};\n\t\tconst headers = providerRequest\n\t\t\t? await providerRequest.transformHeaders(options.auth.headers ?? {})\n\t\t\t: options.auth.headers;\n\t\tconst responseStream = summarizationStream(options.context, options.snapshot.model, requestContext, {\n\t\t\tapiKey: options.auth.apiKey,\n\t\t\theaders,\n\t\t\textraBody: options.auth.extraBody,\n\t\t\tonPayload: async (payload, model) => {\n\t\t\t\tconst sanitized = model.api === \"anthropic-messages\" ? sanitizeAnthropicPayload(payload) : payload;\n\t\t\t\treturn providerRequest ? await providerRequest.transformPayload(sanitized) : sanitized;\n\t\t\t},\n\t\t\tmaxTokens: summaryMaxTokens(options.snapshot.model, options.snapshot.contextWindow),\n\t\t\tsignal: requestController.signal,\n\t\t\t...summarizationReasoningOptions(options.snapshot.model),\n\t\t});\n\t\tawait consumeStreamWithIdleTimeout(responseStream, {\n\t\t\tidleTimeoutMs: DEFAULT_SUMMARIZATION_IDLE_TIMEOUT_MS,\n\t\t\tmaxDurationMs: DEFAULT_SUMMARIZATION_MAX_DURATION_MS,\n\t\t\tabort: () => requestController.abort(),\n\t\t\tsignal: options.signal,\n\t\t\tonEvent: (event) => {\n\t\t\t\tif (event.type === \"text_delta\" && event.delta) {\n\t\t\t\t\toptions.onProgress?.(event.delta);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t\treturn await responseStream.result();\n\t} finally {\n\t\tif (options.signal) options.signal.removeEventListener(\"abort\", onCallerAbort);\n\t}\n}\n\nfunction pruneToolResults(messages: AgentMessage[], contextWindow: number): AgentMessage[] {\n\tconst toolResults = messages\n\t\t.filter((message) => message.role === \"toolResult\")\n\t\t.map((message) => ({ content: message.content, details: undefined }));\n\tif (toolResults.length === 0) return messages;\n\n\tconst prunedResults = truncation.prePruneToolOutputsToBudget(toolResults, contextWindow * COMPACTION_BUDGET_RATIO);\n\tlet resultIndex = 0;\n\treturn messages.map((message) => {\n\t\tif (message.role !== \"toolResult\") return message;\n\t\tconst pruned = prunedResults[resultIndex];\n\t\tresultIndex++;\n\t\treturn pruned ? { ...message, content: pruned.content } : message;\n\t});\n}\n\nexport function truncateContextMessages(messages: AgentMessage[]): AgentMessage[] {\n\tconst toolResults = messages\n\t\t.filter((message) => message.role === \"toolResult\")\n\t\t.map((message) => ({ content: message.content, details: undefined }));\n\tif (toolResults.length === 0) return messages;\n\n\tconst truncatedResults = truncation.truncateOversizedToolResults(toolResults);\n\tlet resultIndex = 0;\n\treturn messages.map((message) => {\n\t\tif (message.role !== \"toolResult\") return message;\n\t\tconst truncated = truncatedResults[resultIndex];\n\t\tresultIndex++;\n\t\treturn truncated ? { ...message, content: truncated.content } : message;\n\t});\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\nfunction 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\nfunction removeOldestHistoryItemForOverflowRetry(messages: AgentMessage[]): AgentMessage[] | undefined {\n\tif (messages.length <= 1) return undefined;\n\tconst boundaryIndex = findLastUserLikeIndex(messages);\n\treturn (\n\t\tremoveFirstOldToolPair(messages, boundaryIndex)?.messages ??\n\t\tremoveFirstOldMessage(messages, boundaryIndex)?.messages ??\n\t\t(messages.length > 1 ? messages.slice(1) : undefined)\n\t);\n}\n\nfunction estimateTotalTokens(messages: AgentMessage[]): number {\n\tlet total = 0;\n\tfor (const message of messages) total += estimateTokens(message);\n\treturn total;\n}\n\n/**\n * Sticky engage/release state for {@link hardLimitEmergencyPrune}. Callers that\n * issue many requests for one session share a single latch so the emitted context\n * shape stays stable while the estimate hovers around the engage threshold.\n */\nexport interface EmergencyPruneLatch {\n\tengaged: boolean;\n}\n\nexport function createEmergencyPruneLatch(): EmergencyPruneLatch {\n\treturn { engaged: false };\n}\n\nexport function hardLimitEmergencyPrune(\n\tmessages: AgentMessage[],\n\tcontextWindow: number,\n\tlatch?: EmergencyPruneLatch,\n): {\n\tmessages: AgentMessage[];\n\tneedsAggressiveCompaction: boolean;\n} {\n\tconst targetTokens = Math.floor(contextWindow * EMERGENCY_CONTEXT_TARGET_RATIO);\n\tconst releaseTokens = Math.floor(contextWindow * EMERGENCY_CONTEXT_RELEASE_RATIO);\n\tconst totalTokens = estimateTotalTokens(messages);\n\t// Without a latch this keeps the historical single-threshold behaviour.\n\tconst engaged = latch\n\t\t? latch.engaged\n\t\t\t? totalTokens > releaseTokens\n\t\t\t: totalTokens > targetTokens\n\t\t: totalTokens > targetTokens;\n\tif (latch) latch.engaged = engaged;\n\tif (!engaged) {\n\t\treturn { messages, needsAggressiveCompaction: false };\n\t}\n\tconst noLlmPruned = truncateContextMessages(pruneToolResults(messages, contextWindow));\n\tif (estimateTotalTokens(noLlmPruned) <= targetTokens) {\n\t\treturn { messages: noLlmPruned, needsAggressiveCompaction: false };\n\t}\n\treturn {\n\t\tmessages: pruneOldMessagesToBudget(noLlmPruned, targetTokens),\n\t\tneedsAggressiveCompaction: true,\n\t};\n}\n\nexport function getPromptVariant(options: {\n\treason: string;\n\tpreparation: { previousSummary?: string; isSplitTurn: boolean };\n}): MergedCompactionPromptVariant {\n\tif (options.reason === \"branch\") return \"branch\";\n\tif (options.preparation.previousSummary) return \"update\";\n\tif (options.preparation.isSplitTurn) return \"turn_prefix\";\n\treturn \"default\";\n}\n\nexport function createSpeculativeCompactionSnapshot(\n\tcontext: SpeculativeCompactionContext,\n\toptions: {\n\t\tcustomInstructions?: string;\n\t\tgeneration: number;\n\t\torigin?: \"speculative\" | \"blocking\" | \"core-route\";\n\t\ttools?: Tool[];\n\t},\n): SpeculativeCompactionSnapshot | undefined {\n\tconst model = context.model;\n\tif (!model) return undefined;\n\n\tconst expectedRevision = context.getMessageRevision();\n\tconst branchEntries = context.sessionManager.getBranch();\n\tconst contextWindow = context.getContextUsage()?.contextWindow ?? model.contextWindow ?? DEFAULT_CONTEXT_WINDOW;\n\tconst settings = context.getCompactionSettings?.() ?? DEFAULT_COMPACTION_SETTINGS;\n\tconst thresholdRatio = computeEffectiveThreshold(contextWindow);\n\tconst preparation = prepareCompaction(branchEntries, {\n\t\t...settings,\n\t\tkeepRecentTokens: computeEffectiveKeepRecentTokens(settings.keepRecentTokens, contextWindow, thresholdRatio),\n\t});\n\tif (!preparation) return undefined;\n\n\treturn {\n\t\tgeneration: options.generation,\n\t\texpectedRevision,\n\t\tmodel,\n\t\tcontextWindow,\n\t\tpreparation,\n\t\tbranchEntries,\n\t\tpromptVariant: getPromptVariant({ reason: \"extension\", preparation }),\n\t\t...(options.origin ? { origin: options.origin } : {}),\n\t\tcustomInstructions: options.customInstructions,\n\t\tsystemPrompt: context.getSystemPrompt?.(),\n\t\ttools: options.tools,\n\t};\n}\n\n/**\n * Generate a compaction summary for the snapshot. Resolves `undefined` only\n * when the request was aborted (caller signal or an aborted stream); every\n * other failure throws — {@link SummaryGenerationError} for diagnosable\n * generation failures, the raw provider error otherwise. Abort is checked\n * before and after credential resolution so a cancelled request never\n * misreports as an auth failure.\n */\nexport async function runExtensionCompaction(\n\tcontext: SpeculativeCompactionContext,\n\tsnapshot: SpeculativeCompactionSnapshot,\n\tsignal?: AbortSignal,\n\tonProgress?: CompactionProgressCallback,\n): Promise<CompactionResult | undefined> {\n\tif (signal?.aborted) return undefined;\n\tconst auth = await context.modelRegistry?.getApiKeyAndHeaders(snapshot.model);\n\tif (signal?.aborted) return undefined;\n\t// A provider is authenticated for summarization by either a resolved key or a\n\t// credential request header: `headers`-authenticated providers (models.json and\n\t// extension providers alike) never resolve an apiKey, yet their normal agent\n\t// turns are fully authenticated.\n\tif (!auth?.ok || !(auth.apiKey || hasCredentialHeaders(auth.headers))) {\n\t\tconst detail =\n\t\t\tauth && !auth.ok ? auth.error : `no credentials resolved for provider \"${snapshot.model.provider}\"`;\n\t\tthrow new SummaryGenerationError(\"auth\", `summarization credentials unavailable: ${detail}`);\n\t}\n\n\tlet messages = pruneToolResults(\n\t\t[...snapshot.preparation.messagesToSummarize, ...snapshot.preparation.turnPrefixMessages],\n\t\tsnapshot.contextWindow,\n\t);\n\tconst prompt = buildPrompt({\n\t\tvariant: snapshot.promptVariant,\n\t\tpreviousSummary: snapshot.preparation.previousSummary,\n\t\ttaskIntent: resolveInheritedTaskIntent(snapshot.branchEntries ?? []),\n\t\tcustomInstructions: snapshot.customInstructions,\n\t});\n\n\twhile (true) {\n\t\tif (signal?.aborted) return undefined;\n\t\tconst response = await generateSummaryMessage({\n\t\t\tcontext,\n\t\t\tmessages,\n\t\t\tonProgress,\n\t\t\tprompt,\n\t\t\tsignal,\n\t\t\tsnapshot,\n\t\t\tauth: {\n\t\t\t\tapiKey: auth.apiKey,\n\t\t\t\theaders: auth.headers,\n\t\t\t\textraBody: auth.extraBody,\n\t\t\t},\n\t\t});\n\t\tif (!response) return undefined;\n\n\t\tif (isAssistantMessage(response) && isContextOverflow(response, snapshot.contextWindow)) {\n\t\t\tconst retryMessages = removeOldestHistoryItemForOverflowRetry(messages);\n\t\t\tif (!retryMessages || retryMessages.length === messages.length) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tmessages = retryMessages;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (isAssistantMessage(response) && response.stopReason === \"aborted\") {\n\t\t\t// A partial summary from an aborted stream must never be applied.\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (isAssistantMessage(response) && response.stopReason === \"error\") {\n\t\t\t// Surface the real provider failure instead of silently degrading\n\t\t\t// into a generic \"Compaction cancelled\". Preserve the structured\n\t\t\t// truncation class here so downstream recovery never trusts arbitrary\n\t\t\t// thrown error text as authorization for destructive context reduction.\n\t\t\tconst failureKind = summaryRequestFailureKind(response);\n\t\t\tthrow new SummaryRequestError(\n\t\t\t\tresponse.errorMessage || \"Compaction summary request failed\",\n\t\t\t\tfailureKind !== undefined || isRetryableAssistantError(response),\n\t\t\t\tfailureKind,\n\t\t\t);\n\t\t}\n\n\t\tconst summary = getSummaryText(response);\n\t\tif (!summary) {\n\t\t\tconst stopReason = isAssistantMessage(response) ? response.stopReason : \"unknown\";\n\t\t\tthrow new SummaryGenerationError(\n\t\t\t\t\"empty-summary\",\n\t\t\t\t`summarization response contained no text (stopReason: ${stopReason})`,\n\t\t\t);\n\t\t}\n\n\t\t// Informational only: the core rejects an applied compaction that would\n\t\t// still overflow (_wouldCompactionOverflow). Rejecting here based on the\n\t\t// size of the *discarded* input made large sessions uncompactable.\n\t\tconst tokenEstimate = estimateContextTokens(convertToLlm(messages)).tokens + approxTokens(summary);\n\t\tconst parsedSummary = extractTaskIntent(summary);\n\t\tconst taskIntent = parsedSummary.taskIntent ?? resolveInheritedTaskIntent(snapshot.branchEntries ?? []);\n\n\t\treturn {\n\t\t\tsummary: parsedSummary.summaryText,\n\t\t\tfirstKeptEntryId: snapshot.preparation.firstKeptEntryId,\n\t\t\ttokensBefore: snapshot.preparation.tokensBefore,\n\t\t\tdetails: {\n\t\t\t\tschema: SUMMARY_SCHEMA,\n\t\t\t\tpromptVariant: snapshot.promptVariant,\n\t\t\t\ttokenEstimate,\n\t\t\t\tstructuralYield: computeStructuralYield({\n\t\t\t\t\tpreviousSummary: snapshot.preparation.previousSummary ?? \"\",\n\t\t\t\t\tmessagesToSummarize: snapshot.preparation.messagesToSummarize,\n\t\t\t\t\tturnPrefixMessages: snapshot.preparation.turnPrefixMessages,\n\t\t\t\t\tsummary: parsedSummary.summaryText,\n\t\t\t\t\ttokensBefore: snapshot.preparation.tokensBefore,\n\t\t\t\t}),\n\t\t\t\t...(snapshot.origin ? { origin: snapshot.origin } : {}),\n\t\t\t\t...(taskIntent ? { taskIntent } : {}),\n\t\t\t},\n\t\t};\n\t}\n\n\tthrow new Error(\"Compaction summary request exceeded the context window after retrying with a smaller input\");\n}\n\nexport async function applyGeneratedCompaction(\n\tcontext: SpeculativeCompactionContext,\n\tsnapshot: SpeculativeCompactionSnapshot | undefined,\n\tgetCurrentGeneration: () => number,\n\tcompaction: CompactionResult | undefined,\n\tsignal?: AbortSignal,\n): Promise<SpeculativeCompactionResult> {\n\tif (!snapshot || !compaction) return { applied: false, reason: \"unavailable\" };\n\n\tif (snapshot.generation !== getCurrentGeneration() || snapshot.expectedRevision !== context.getMessageRevision()) {\n\t\treturn { applied: false, reason: \"stale\" };\n\t}\n\n\treturn await context.applyCompaction(compaction, {\n\t\treason: \"extension\",\n\t\texpectedRevision: snapshot.expectedRevision,\n\t\tsignal,\n\t});\n}\n\nexport async function applySpeculativeCompaction(\n\tcontext: SpeculativeCompactionContext,\n\tsnapshot: SpeculativeCompactionSnapshot | undefined,\n\tgetCurrentGeneration: () => number,\n\tgenerate: () => Promise<CompactionResult | undefined>,\n): Promise<SpeculativeCompactionResult> {\n\tif (!snapshot) return { applied: false, reason: \"unavailable\" };\n\n\tconst compaction = await generate();\n\treturn await applyGeneratedCompaction(context, snapshot, getCurrentGeneration, compaction);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"speculative.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/speculative.ts"],"names":[],"mappings":"AACA,OAAO,EAIN,oBAAoB,EACpB,iBAAiB,EACjB,yBAAyB,EAIzB,0BAA0B,IAAI,wBAAwB,GAGtD,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAGN,2BAA2B,EAC3B,qBAAqB,EACrB,iBAAiB,GACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,4BAA4B,EAC5B,qCAAqC,EACrC,qCAAqC,GACrC,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,OAAO,EACN,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,gCAAgC,EAChC,mCAAmC,EACnC,wCAAwC,GACxC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gCAAgC,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAsC,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,sBAAsB,GAAG,OAAO,CAAC;AACvC,MAAM,8BAA8B,GAAG,IAAI,CAAC;AAC5C,qFAAqF;AACrF,qFAAqF;AACrF,sFAAsF;AACtF,qFAAqF;AACrF,oFAAoF;AACpF,MAAM,+BAA+B,GAA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nD,oBAAkC,EAClC,UAAwC,EACxC,MAAoB;IAEpB,IAAI,CAAC,QAAQ,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;IAE/E,IAAI,QAAQ,CAAC,UAAU,KAAK,oBAAoB,EAAE,IAAI,QAAQ,CAAC,gBAAgB,KAAK,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;QAClH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAC5C,CAAC;IAED,OAAO,MAAM,OAAO,CAAC,eAAe,CAAC,UAAU,EAAE;QAChD,MAAM,EAAE,WAAW;QACnB,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB;QAC3C,MAAM;KACN,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC/C,OAAqC,EACrC,QAAmD,EACnD,oBAAkC,EAClC,QAAqD;IAErD,IAAI,CAAC,QAAQ;QAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;IAEhE,MAAM,UAAU,GAAG,MAAM,QAAQ,EAAE,CAAC;IACpC,OAAO,MAAM,wBAAwB,CAAC,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,UAAU,CAAC,CAAC;AAC5F,CAAC","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport {\n\ttype AssistantMessage,\n\ttype AssistantMessageEventStream,\n\ttype Context,\n\thasCredentialHeaders,\n\tisContextOverflow,\n\tisRetryableAssistantError,\n\ttype Message,\n\ttype Model,\n\ttype StreamOptions,\n\tsanitizeAnthropicToolPairs as sanitizeAnthropicPayload,\n\ttype TextContent,\n\ttype Tool,\n} from \"@earendil-works/pi-ai\";\nimport { stream } from \"@earendil-works/pi-ai/compat\";\nimport {\n\ttype CompactionPreparation,\n\ttype CompactionResult,\n\tDEFAULT_COMPACTION_SETTINGS,\n\testimateContextTokens,\n\tprepareCompaction,\n} from \"../../../compaction/index.ts\";\nimport {\n\tconsumeStreamWithIdleTimeout,\n\tDEFAULT_SUMMARIZATION_IDLE_TIMEOUT_MS,\n\tDEFAULT_SUMMARIZATION_MAX_DURATION_MS,\n} from \"../../../compaction/stream-watchdog.ts\";\nimport { convertToLlm } from \"../../../messages.ts\";\nimport type { ModelRegistry } from \"../../../model-registry.ts\";\nimport type { ReadonlySessionManager } from \"../../../session-manager.ts\";\nimport type { ApplyCompactionResult, ContextUsage, ProviderRequestPreparation } from \"../../types.ts\";\nimport {\n\tallowOverflowRetry,\n\tboundSummarizationInput,\n\testimateTotalTokens,\n\tpruneOldMessagesToBudget,\n\tSUMMARIZATION_INPUT_BUDGET_RATIO,\n\tSummarizationOverflowExhaustedError,\n\tshrinkSummarizationInputForOverflowRetry,\n} from \"./overflow-retry.ts\";\nimport { computeEffectiveKeepRecentTokens, computeEffectiveThreshold } from \"./policy.ts\";\nimport { buildPrompt, type MergedCompactionPromptVariant } from \"./prompts.ts\";\nimport { repairOrphanedToolResults } from \"./repair-tool-pairs.ts\";\nimport { extractTaskIntent, resolveInheritedTaskIntent } from \"./task-intent.ts\";\nimport * as truncation from \"./tool-truncation.ts\";\nimport { computeStructuralYield } from \"./yield.ts\";\n\nconst DEFAULT_CONTEXT_WINDOW = 200_000;\nconst EMERGENCY_CONTEXT_TARGET_RATIO = 0.95;\n// Hysteresis: the emergency prune engages at EMERGENCY_CONTEXT_TARGET_RATIO but only\n// releases once the context falls below this lower ratio. A single threshold makes a\n// session parked near the limit alternate between the pruned and un-pruned history on\n// consecutive requests; because pruning rewrites old tool results, every alternation\n// invalidates the provider prompt-cache prefix and re-bills the whole conversation.\nconst EMERGENCY_CONTEXT_RELEASE_RATIO = 0.85;\nconst SUMMARY_TOKEN_HEADROOM = 32_768;\nconst SUMMARY_CONTEXT_WINDOW_RESERVE_RATIO = 0.5;\nconst SUMMARY_SCHEMA = \"senpi.compaction.summary.v1\";\ntype CompactionProgressCallback = (delta: string) => void;\n\nexport interface SpeculativeCompactionContext {\n\tmodel: Model<any> | undefined;\n\tsessionManager: ReadonlySessionManager;\n\tmodelRegistry?: ModelRegistry;\n\tgetContextUsage(): ContextUsage | undefined;\n\tgetCompactionSettings?(): CompactionPreparation[\"settings\"];\n\tgetMessageRevision(): number;\n\tgetSystemPrompt?(): string;\n\tprepareProviderRequest?(messages: AgentMessage[]): Promise<ProviderRequestPreparation>;\n\tapplyCompaction(\n\t\tprecomputed: CompactionResult,\n\t\toptions: { reason: \"extension\"; expectedRevision: number; signal?: AbortSignal },\n\t): Promise<ApplyCompactionResult>;\n}\n\nexport interface SpeculativeCompactionSnapshot {\n\tgeneration: number;\n\texpectedRevision: number;\n\tmodel: Model<any>;\n\tcontextWindow: number;\n\tpreparation: CompactionPreparation;\n\tbranchEntries?: ReturnType<ReadonlySessionManager[\"getBranch\"]>;\n\tpromptVariant: MergedCompactionPromptVariant;\n\torigin?: \"speculative\" | \"blocking\" | \"core-route\";\n\tcustomInstructions?: string;\n\t/** Agent system prompt; used to make the summarization request look like normal agent traffic. */\n\tsystemPrompt?: string;\n\t/** Agent tool definitions; forwarded so the request shape matches normal agent traffic. */\n\ttools?: Tool[];\n}\n\nexport type SpeculativeCompactionResult = ApplyCompactionResult | { applied: false; reason: \"unavailable\" | \"failed\" };\n\nfunction approxTokens(text: string): number {\n\treturn Math.ceil(text.length / 4);\n}\n\n/**\n * Summary-generation failure with a user-facing diagnosis. Distinct from a\n * user abort (which resolves `undefined`): callers surface `message` on the\n * manual route and degrade to \"unavailable\" on automatic routes.\n */\n/**\n * Provider `error` stop during summarization, carrying the metadata-aware\n * transient classification from the full assistant message. A refusal whose\n * text happens to look retryable must still surface loudly; the message\n * string alone cannot encode that.\n */\nexport type SummaryRequestFailureKind = \"upstream-stream-truncated\";\n\nexport class SummaryRequestError extends Error {\n\treadonly transient: boolean;\n\treadonly failureKind?: SummaryRequestFailureKind;\n\n\tconstructor(message: string, transient: boolean, failureKind?: SummaryRequestFailureKind) {\n\t\tsuper(message);\n\t\tthis.name = \"SummaryRequestError\";\n\t\tthis.transient = transient;\n\t\tthis.failureKind = failureKind;\n\t}\n}\n\nconst UPSTREAM_STREAM_TRUNCATED_PATTERN = /(?:^|[^A-Za-z0-9_])upstream_stream_truncated(?:[^A-Za-z0-9_]|$)/;\n\nfunction summaryRequestFailureKind(response: AssistantMessage): SummaryRequestFailureKind | undefined {\n\tif (response.stopDetails?.type === \"refusal\" || response.stopDetails?.type === \"sensitive\") return undefined;\n\treturn UPSTREAM_STREAM_TRUNCATED_PATTERN.test(response.errorMessage ?? \"\") ? \"upstream-stream-truncated\" : undefined;\n}\n\nexport class SummaryGenerationError extends Error {\n\treadonly kind: \"auth\" | \"empty-summary\";\n\n\tconstructor(kind: \"auth\" | \"empty-summary\", message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"SummaryGenerationError\";\n\t\tthis.kind = kind;\n\t}\n}\n\n/**\n * Output budget for one summarization request. Adaptive-thinking models emit\n * reasoning tokens before the summary text, so the legacy flat 8192 cap could\n * be consumed entirely by thinking, ending the stream with zero text blocks.\n * Grant generous headroom, clamped to what the model can actually emit and to\n * half the context window: providers that enforce input + output <= window\n * would otherwise reject the request for models advertising contextWindow ==\n * maxTokens (every summarization request also carries conversation input).\n */\nfunction summaryMaxTokens(model: Model<any>, contextWindow: number): number {\n\tconst headroom = model.maxTokens > 0 ? Math.min(SUMMARY_TOKEN_HEADROOM, model.maxTokens) : SUMMARY_TOKEN_HEADROOM;\n\tif (contextWindow > 0) {\n\t\treturn Math.min(headroom, Math.floor(contextWindow * SUMMARY_CONTEXT_WINDOW_RESERVE_RATIO));\n\t}\n\treturn headroom;\n}\n\n/**\n * Reasoning override for summarization requests. Compaction must be fast: a\n * summarization request that inherits the provider's default reasoning mode\n * burns its latency (and output budget) on invisible thinking before emitting\n * the summary. Disable or minimize reasoning per wire family; adapters ignore\n * options their provider does not support. Mirrors how OpenAI Codex keeps its\n * compaction turn cheap.\n */\nfunction summarizationReasoningOptions(model: Model<any>): Record<string, unknown> {\n\tif (!model.reasoning) return {};\n\tif (model.api === \"anthropic-messages\") return { thinkingEnabled: false };\n\tconst reasoningEffort = ([\"low\", \"medium\", \"high\"] as const).find(\n\t\t(level) => model.thinkingLevelMap?.[level] !== null,\n\t);\n\tif (!reasoningEffort) return {};\n\tswitch (model.api) {\n\t\tcase \"openai-responses\":\n\t\tcase \"openai-codex-responses\":\n\t\tcase \"azure-openai-responses\":\n\t\t\treturn { reasoningEffort, reasoningSummary: null };\n\t\tcase \"openai-completions\":\n\t\t\treturn { reasoningEffort };\n\t\tdefault:\n\t\t\treturn {};\n\t}\n}\n\nfunction getSummaryText(message: Message): string {\n\tconst content = Array.isArray(message.content)\n\t\t? message.content\n\t\t: [{ type: \"text\" as const, text: message.content }];\n\treturn content\n\t\t.filter((content): content is TextContent => content.type === \"text\")\n\t\t.map((content) => content.text)\n\t\t.join(\"\\n\")\n\t\t.trim();\n}\n\nfunction isAssistantMessage(message: Message): message is AssistantMessage {\n\treturn message.role === \"assistant\" && \"stopReason\" in message;\n}\n\n/**\n * Providers registered through `pi.registerProvider()` (claude-sdk-oauth, Kiro, any\n * extension provider) exist only in Senpi's ModelRuntime, never in compat's builtin\n * api-registry, which rejects their api id outright. Dispatch through the runtime\n * whenever it is reachable and keep compat for contexts constructed without a registry.\n */\nfunction summarizationStream(\n\tcontext: SpeculativeCompactionContext,\n\tmodel: Model<any>,\n\trequestContext: Context,\n\toptions: StreamOptions & Record<string, unknown>,\n): AssistantMessageEventStream {\n\tconst runtime = context.modelRegistry?.modelRuntime;\n\treturn runtime ? runtime.stream(model, requestContext, options) : stream(model, requestContext, options);\n}\n\nasync function generateSummaryMessage(options: {\n\tcontext: SpeculativeCompactionContext;\n\tmessages: AgentMessage[];\n\tonProgress?: CompactionProgressCallback;\n\tprompt: ReturnType<typeof buildPrompt>;\n\tsignal?: AbortSignal;\n\tsnapshot: SpeculativeCompactionSnapshot;\n\tauth: {\n\t\tapiKey?: string;\n\t\theaders?: Record<string, string>;\n\t\textraBody?: Record<string, unknown>;\n\t};\n}): Promise<Message | undefined> {\n\t// Send the conversation as native LLM messages with the summarization\n\t// instruction as a trailing user message, mirroring normal agent traffic.\n\t// A single serialized `<conversation>` text dump of a large session is\n\t// deterministically refused by Anthropic's anti-distillation classifier\n\t// (\"reverse engineering or duplicating model outputs\"), while the same\n\t// content as native blocks with the agent's system prompt and tools passes.\n\t// Request-local controller: the idle watchdog must be able to tear down a\n\t// stalled summarization request without aborting the caller's own signal.\n\tconst requestController = new AbortController();\n\tconst onCallerAbort = () => requestController.abort(options.signal?.reason);\n\tif (options.signal) {\n\t\tif (options.signal.aborted) onCallerAbort();\n\t\telse options.signal.addEventListener(\"abort\", onCallerAbort, { once: true });\n\t}\n\ttry {\n\t\tconst requestMessages: AgentMessage[] = [\n\t\t\t...options.messages,\n\t\t\t{\n\t\t\t\trole: \"user\",\n\t\t\t\tcontent: [{ type: \"text\", text: options.prompt.user }],\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t},\n\t\t];\n\t\tconst providerRequest = await options.context.prepareProviderRequest?.(requestMessages);\n\t\tconst requestContext = {\n\t\t\tsystemPrompt: options.snapshot.systemPrompt ?? options.prompt.system,\n\t\t\tmessages: repairOrphanedToolResults(convertToLlm(providerRequest?.messages ?? requestMessages)),\n\t\t\t...(options.snapshot.tools && options.snapshot.tools.length > 0 ? { tools: options.snapshot.tools } : {}),\n\t\t};\n\t\tconst headers = providerRequest\n\t\t\t? await providerRequest.transformHeaders(options.auth.headers ?? {})\n\t\t\t: options.auth.headers;\n\t\tconst responseStream = summarizationStream(options.context, options.snapshot.model, requestContext, {\n\t\t\tapiKey: options.auth.apiKey,\n\t\t\theaders,\n\t\t\textraBody: options.auth.extraBody,\n\t\t\tonPayload: async (payload, model) => {\n\t\t\t\tconst sanitized = model.api === \"anthropic-messages\" ? sanitizeAnthropicPayload(payload) : payload;\n\t\t\t\treturn providerRequest ? await providerRequest.transformPayload(sanitized) : sanitized;\n\t\t\t},\n\t\t\tmaxTokens: summaryMaxTokens(options.snapshot.model, options.snapshot.contextWindow),\n\t\t\tsignal: requestController.signal,\n\t\t\t...summarizationReasoningOptions(options.snapshot.model),\n\t\t});\n\t\tawait consumeStreamWithIdleTimeout(responseStream, {\n\t\t\tidleTimeoutMs: DEFAULT_SUMMARIZATION_IDLE_TIMEOUT_MS,\n\t\t\tmaxDurationMs: DEFAULT_SUMMARIZATION_MAX_DURATION_MS,\n\t\t\tabort: () => requestController.abort(),\n\t\t\tsignal: options.signal,\n\t\t\tonEvent: (event) => {\n\t\t\t\tif (event.type === \"text_delta\" && event.delta) {\n\t\t\t\t\toptions.onProgress?.(event.delta);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t\treturn await responseStream.result();\n\t} finally {\n\t\tif (options.signal) options.signal.removeEventListener(\"abort\", onCallerAbort);\n\t}\n}\n\nfunction pruneToolResults(messages: AgentMessage[], contextWindow: number, budgetRatio: number): AgentMessage[] {\n\tconst toolResults = messages\n\t\t.filter((message) => message.role === \"toolResult\")\n\t\t.map((message) => ({ content: message.content, details: undefined }));\n\tif (toolResults.length === 0) return messages;\n\n\tconst prunedResults = truncation.prePruneToolOutputsToBudget(toolResults, contextWindow * budgetRatio);\n\tlet resultIndex = 0;\n\treturn messages.map((message) => {\n\t\tif (message.role !== \"toolResult\") return message;\n\t\tconst pruned = prunedResults[resultIndex];\n\t\tresultIndex++;\n\t\treturn pruned ? { ...message, content: pruned.content } : message;\n\t});\n}\n\nexport function truncateContextMessages(messages: AgentMessage[]): AgentMessage[] {\n\tconst toolResults = messages\n\t\t.filter((message) => message.role === \"toolResult\")\n\t\t.map((message) => ({ content: message.content, details: undefined }));\n\tif (toolResults.length === 0) return messages;\n\n\tconst truncatedResults = truncation.truncateOversizedToolResults(toolResults);\n\tlet resultIndex = 0;\n\treturn messages.map((message) => {\n\t\tif (message.role !== \"toolResult\") return message;\n\t\tconst truncated = truncatedResults[resultIndex];\n\t\tresultIndex++;\n\t\treturn truncated ? { ...message, content: truncated.content } : message;\n\t});\n}\n\n/**\n * Sticky engage/release state for {@link hardLimitEmergencyPrune}. Callers that\n * issue many requests for one session share a single latch so the emitted context\n * shape stays stable while the estimate hovers around the engage threshold.\n */\nexport interface EmergencyPruneLatch {\n\tengaged: boolean;\n}\n\nexport function createEmergencyPruneLatch(): EmergencyPruneLatch {\n\treturn { engaged: false };\n}\n\nexport function hardLimitEmergencyPrune(\n\tmessages: AgentMessage[],\n\tcontextWindow: number,\n\tlatch?: EmergencyPruneLatch,\n): {\n\tmessages: AgentMessage[];\n\tneedsAggressiveCompaction: boolean;\n} {\n\tconst targetTokens = Math.floor(contextWindow * EMERGENCY_CONTEXT_TARGET_RATIO);\n\tconst releaseTokens = Math.floor(contextWindow * EMERGENCY_CONTEXT_RELEASE_RATIO);\n\tconst totalTokens = estimateTotalTokens(messages);\n\t// Without a latch this keeps the historical single-threshold behaviour.\n\tconst engaged = latch\n\t\t? latch.engaged\n\t\t\t? totalTokens > releaseTokens\n\t\t\t: totalTokens > targetTokens\n\t\t: totalTokens > targetTokens;\n\tif (latch) latch.engaged = engaged;\n\tif (!engaged) {\n\t\treturn { messages, needsAggressiveCompaction: false };\n\t}\n\tconst noLlmPruned = truncateContextMessages(\n\t\tpruneToolResults(messages, contextWindow, SUMMARIZATION_INPUT_BUDGET_RATIO),\n\t);\n\tif (estimateTotalTokens(noLlmPruned) <= targetTokens) {\n\t\treturn { messages: noLlmPruned, needsAggressiveCompaction: false };\n\t}\n\treturn {\n\t\tmessages: pruneOldMessagesToBudget(noLlmPruned, targetTokens),\n\t\tneedsAggressiveCompaction: true,\n\t};\n}\n\nexport function getPromptVariant(options: {\n\treason: string;\n\tpreparation: { previousSummary?: string; isSplitTurn: boolean };\n}): MergedCompactionPromptVariant {\n\tif (options.reason === \"branch\") return \"branch\";\n\tif (options.preparation.previousSummary) return \"update\";\n\tif (options.preparation.isSplitTurn) return \"turn_prefix\";\n\treturn \"default\";\n}\n\nexport function createSpeculativeCompactionSnapshot(\n\tcontext: SpeculativeCompactionContext,\n\toptions: {\n\t\tcustomInstructions?: string;\n\t\tgeneration: number;\n\t\torigin?: \"speculative\" | \"blocking\" | \"core-route\";\n\t\ttools?: Tool[];\n\t},\n): SpeculativeCompactionSnapshot | undefined {\n\tconst model = context.model;\n\tif (!model) return undefined;\n\n\tconst expectedRevision = context.getMessageRevision();\n\tconst branchEntries = context.sessionManager.getBranch();\n\tconst contextWindow = context.getContextUsage()?.contextWindow ?? model.contextWindow ?? DEFAULT_CONTEXT_WINDOW;\n\tconst settings = context.getCompactionSettings?.() ?? DEFAULT_COMPACTION_SETTINGS;\n\tconst thresholdRatio = computeEffectiveThreshold(contextWindow);\n\tconst preparation = prepareCompaction(branchEntries, {\n\t\t...settings,\n\t\tkeepRecentTokens: computeEffectiveKeepRecentTokens(settings.keepRecentTokens, contextWindow, thresholdRatio),\n\t});\n\tif (!preparation) return undefined;\n\n\treturn {\n\t\tgeneration: options.generation,\n\t\texpectedRevision,\n\t\tmodel,\n\t\tcontextWindow,\n\t\tpreparation,\n\t\tbranchEntries,\n\t\tpromptVariant: getPromptVariant({ reason: \"extension\", preparation }),\n\t\t...(options.origin ? { origin: options.origin } : {}),\n\t\tcustomInstructions: options.customInstructions,\n\t\tsystemPrompt: context.getSystemPrompt?.(),\n\t\ttools: options.tools,\n\t};\n}\n\n/**\n * Generate a compaction summary for the snapshot. Resolves `undefined` only\n * when the request was aborted (caller signal or an aborted stream); every\n * other failure throws — {@link SummaryGenerationError} for diagnosable\n * generation failures, the raw provider error otherwise. Abort is checked\n * before and after credential resolution so a cancelled request never\n * misreports as an auth failure.\n */\nexport async function runExtensionCompaction(\n\tcontext: SpeculativeCompactionContext,\n\tsnapshot: SpeculativeCompactionSnapshot,\n\tsignal?: AbortSignal,\n\tonProgress?: CompactionProgressCallback,\n): Promise<CompactionResult | undefined> {\n\tif (signal?.aborted) return undefined;\n\tconst auth = await context.modelRegistry?.getApiKeyAndHeaders(snapshot.model);\n\tif (signal?.aborted) return undefined;\n\t// A provider is authenticated for summarization by either a resolved key or a\n\t// credential request header: `headers`-authenticated providers (models.json and\n\t// extension providers alike) never resolve an apiKey, yet their normal agent\n\t// turns are fully authenticated.\n\tif (!auth?.ok || !(auth.apiKey || hasCredentialHeaders(auth.headers))) {\n\t\tconst detail =\n\t\t\tauth && !auth.ok ? auth.error : `no credentials resolved for provider \"${snapshot.model.provider}\"`;\n\t\tthrow new SummaryGenerationError(\"auth\", `summarization credentials unavailable: ${detail}`);\n\t}\n\n\tconst prompt = buildPrompt({\n\t\tvariant: snapshot.promptVariant,\n\t\tpreviousSummary: snapshot.preparation.previousSummary,\n\t\ttaskIntent: resolveInheritedTaskIntent(snapshot.branchEntries ?? []),\n\t\tcustomInstructions: snapshot.customInstructions,\n\t});\n\tconst promptTokens = approxTokens(prompt.user);\n\tlet messages = boundSummarizationInput(\n\t\tpruneToolResults(\n\t\t\t[...snapshot.preparation.messagesToSummarize, ...snapshot.preparation.turnPrefixMessages],\n\t\t\tsnapshot.contextWindow,\n\t\t\tSUMMARIZATION_INPUT_BUDGET_RATIO,\n\t\t),\n\t\tsnapshot.contextWindow,\n\t\tpromptTokens,\n\t);\n\tconst overflowRetryStartMs = Date.now();\n\tlet overflowAttempts = 0;\n\n\twhile (true) {\n\t\tif (signal?.aborted) return undefined;\n\t\tconst response = await generateSummaryMessage({\n\t\t\tcontext,\n\t\t\tmessages,\n\t\t\tonProgress,\n\t\t\tprompt,\n\t\t\tsignal,\n\t\t\tsnapshot,\n\t\t\tauth: {\n\t\t\t\tapiKey: auth.apiKey,\n\t\t\t\theaders: auth.headers,\n\t\t\t\textraBody: auth.extraBody,\n\t\t\t},\n\t\t});\n\t\tif (!response) return undefined;\n\n\t\tif (isAssistantMessage(response) && isContextOverflow(response, snapshot.contextWindow)) {\n\t\t\toverflowAttempts++;\n\t\t\tconst elapsedMs = Date.now() - overflowRetryStartMs;\n\t\t\tconst retryMessages = allowOverflowRetry(overflowAttempts, elapsedMs)\n\t\t\t\t? shrinkSummarizationInputForOverflowRetry(messages, snapshot.contextWindow, promptTokens)\n\t\t\t\t: undefined;\n\t\t\tif (!retryMessages) {\n\t\t\t\tthrow new SummarizationOverflowExhaustedError(overflowAttempts, elapsedMs);\n\t\t\t}\n\t\t\tmessages = retryMessages;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (isAssistantMessage(response) && response.stopReason === \"aborted\") {\n\t\t\t// A partial summary from an aborted stream must never be applied.\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (isAssistantMessage(response) && response.stopReason === \"error\") {\n\t\t\t// Surface the real provider failure instead of silently degrading\n\t\t\t// into a generic \"Compaction cancelled\". Preserve the structured\n\t\t\t// truncation class here so downstream recovery never trusts arbitrary\n\t\t\t// thrown error text as authorization for destructive context reduction.\n\t\t\tconst failureKind = summaryRequestFailureKind(response);\n\t\t\tthrow new SummaryRequestError(\n\t\t\t\tresponse.errorMessage || \"Compaction summary request failed\",\n\t\t\t\tfailureKind !== undefined || isRetryableAssistantError(response),\n\t\t\t\tfailureKind,\n\t\t\t);\n\t\t}\n\n\t\tconst summary = getSummaryText(response);\n\t\tif (!summary) {\n\t\t\tconst stopReason = isAssistantMessage(response) ? response.stopReason : \"unknown\";\n\t\t\tthrow new SummaryGenerationError(\n\t\t\t\t\"empty-summary\",\n\t\t\t\t`summarization response contained no text (stopReason: ${stopReason})`,\n\t\t\t);\n\t\t}\n\n\t\t// Informational only: the core rejects an applied compaction that would\n\t\t// still overflow (_wouldCompactionOverflow). Rejecting here based on the\n\t\t// size of the *discarded* input made large sessions uncompactable.\n\t\tconst tokenEstimate = estimateContextTokens(convertToLlm(messages)).tokens + approxTokens(summary);\n\t\tconst parsedSummary = extractTaskIntent(summary);\n\t\tconst taskIntent = parsedSummary.taskIntent ?? resolveInheritedTaskIntent(snapshot.branchEntries ?? []);\n\n\t\treturn {\n\t\t\tsummary: parsedSummary.summaryText,\n\t\t\tfirstKeptEntryId: snapshot.preparation.firstKeptEntryId,\n\t\t\ttokensBefore: snapshot.preparation.tokensBefore,\n\t\t\tdetails: {\n\t\t\t\tschema: SUMMARY_SCHEMA,\n\t\t\t\tpromptVariant: snapshot.promptVariant,\n\t\t\t\ttokenEstimate,\n\t\t\t\tstructuralYield: computeStructuralYield({\n\t\t\t\t\tpreviousSummary: snapshot.preparation.previousSummary ?? \"\",\n\t\t\t\t\tmessagesToSummarize: snapshot.preparation.messagesToSummarize,\n\t\t\t\t\tturnPrefixMessages: snapshot.preparation.turnPrefixMessages,\n\t\t\t\t\tsummary: parsedSummary.summaryText,\n\t\t\t\t\ttokensBefore: snapshot.preparation.tokensBefore,\n\t\t\t\t}),\n\t\t\t\t...(snapshot.origin ? { origin: snapshot.origin } : {}),\n\t\t\t\t...(taskIntent ? { taskIntent } : {}),\n\t\t\t},\n\t\t};\n\t}\n}\n\nexport async function applyGeneratedCompaction(\n\tcontext: SpeculativeCompactionContext,\n\tsnapshot: SpeculativeCompactionSnapshot | undefined,\n\tgetCurrentGeneration: () => number,\n\tcompaction: CompactionResult | undefined,\n\tsignal?: AbortSignal,\n): Promise<SpeculativeCompactionResult> {\n\tif (!snapshot || !compaction) return { applied: false, reason: \"unavailable\" };\n\n\tif (snapshot.generation !== getCurrentGeneration() || snapshot.expectedRevision !== context.getMessageRevision()) {\n\t\treturn { applied: false, reason: \"stale\" };\n\t}\n\n\treturn await context.applyCompaction(compaction, {\n\t\treason: \"extension\",\n\t\texpectedRevision: snapshot.expectedRevision,\n\t\tsignal,\n\t});\n}\n\nexport async function applySpeculativeCompaction(\n\tcontext: SpeculativeCompactionContext,\n\tsnapshot: SpeculativeCompactionSnapshot | undefined,\n\tgetCurrentGeneration: () => number,\n\tgenerate: () => Promise<CompactionResult | undefined>,\n): Promise<SpeculativeCompactionResult> {\n\tif (!snapshot) return { applied: false, reason: \"unavailable\" };\n\n\tconst compaction = await generate();\n\treturn await applyGeneratedCompaction(context, snapshot, getCurrentGeneration, compaction);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transient-failure.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/transient-failure.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transient-failure.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/transient-failure.ts"],"names":[],"mappings":"AAoBA,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAKxF"}
|
|
@@ -15,12 +15,15 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { isRetryableErrorMessage } from "@earendil-works/pi-ai";
|
|
17
17
|
import { StreamDurationBudgetError, StreamIdleTimeoutError } from "../../../compaction/stream-watchdog.js";
|
|
18
|
+
import { SummarizationOverflowExhaustedError } from "./overflow-retry.js";
|
|
18
19
|
import { SummaryRequestError } from "./speculative.js";
|
|
19
20
|
export function isTransientSummarizationFailure(error, message) {
|
|
20
21
|
if (error instanceof StreamDurationBudgetError || error instanceof StreamIdleTimeoutError)
|
|
21
22
|
return true;
|
|
22
23
|
if (error instanceof SummaryRequestError)
|
|
23
24
|
return error.transient;
|
|
25
|
+
if (error instanceof SummarizationOverflowExhaustedError)
|
|
26
|
+
return true;
|
|
24
27
|
return isRetryableErrorMessage(message);
|
|
25
28
|
}
|
|
26
29
|
//# sourceMappingURL=transient-failure.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transient-failure.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/transient-failure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAC3G,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,UAAU,+BAA+B,CAAC,KAAc,EAAE,OAAe;IAC9E,IAAI,KAAK,YAAY,yBAAyB,IAAI,KAAK,YAAY,sBAAsB;QAAE,OAAO,IAAI,CAAC;IACvG,IAAI,KAAK,YAAY,mBAAmB;QAAE,OAAO,KAAK,CAAC,SAAS,CAAC;IACjE,OAAO,uBAAuB,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC","sourcesContent":["/**\n * Classifies a summarization failure as transient (degrade quietly through the\n * compaction failure path) or terminal (surface loudly).\n *\n * Transient failures must not escape as extension errors: the runner would print\n * a raw stack on top of the `compaction_end` message the user already saw, while\n * the turn's own provider request surfaces the same outage again through the\n * normal retry path.\n *\n * Provider `error` stops carry metadata-aware classification through\n * `SummaryRequestError` (a refusal whose text merely looks retryable stays\n * loud). Watchdog trips — a stalled stream or a stream that outlived its\n * wall-clock budget — are infrastructure-slowness outcomes and always degrade.\n * Everything else falls back to the shared message classifier.\n */\nimport { isRetryableErrorMessage } from \"@earendil-works/pi-ai\";\nimport { StreamDurationBudgetError, StreamIdleTimeoutError } from \"../../../compaction/stream-watchdog.ts\";\nimport { SummaryRequestError } from \"./speculative.ts\";\n\nexport function isTransientSummarizationFailure(error: unknown, message: string): boolean {\n\tif (error instanceof StreamDurationBudgetError || error instanceof StreamIdleTimeoutError) return true;\n\tif (error instanceof SummaryRequestError) return error.transient;\n\treturn isRetryableErrorMessage(message);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"transient-failure.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/transient-failure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAC3G,OAAO,EAAE,mCAAmC,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,UAAU,+BAA+B,CAAC,KAAc,EAAE,OAAe;IAC9E,IAAI,KAAK,YAAY,yBAAyB,IAAI,KAAK,YAAY,sBAAsB;QAAE,OAAO,IAAI,CAAC;IACvG,IAAI,KAAK,YAAY,mBAAmB;QAAE,OAAO,KAAK,CAAC,SAAS,CAAC;IACjE,IAAI,KAAK,YAAY,mCAAmC;QAAE,OAAO,IAAI,CAAC;IACtE,OAAO,uBAAuB,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC","sourcesContent":["/**\n * Classifies a summarization failure as transient (degrade quietly through the\n * compaction failure path) or terminal (surface loudly).\n *\n * Transient failures must not escape as extension errors: the runner would print\n * a raw stack on top of the `compaction_end` message the user already saw, while\n * the turn's own provider request surfaces the same outage again through the\n * normal retry path.\n *\n * Provider `error` stops carry metadata-aware classification through\n * `SummaryRequestError` (a refusal whose text merely looks retryable stays\n * loud). Watchdog trips — a stalled stream or a stream that outlived its\n * wall-clock budget — are infrastructure-slowness outcomes and always degrade.\n * Everything else falls back to the shared message classifier.\n */\nimport { isRetryableErrorMessage } from \"@earendil-works/pi-ai\";\nimport { StreamDurationBudgetError, StreamIdleTimeoutError } from \"../../../compaction/stream-watchdog.ts\";\nimport { SummarizationOverflowExhaustedError } from \"./overflow-retry.ts\";\nimport { SummaryRequestError } from \"./speculative.ts\";\n\nexport function isTransientSummarizationFailure(error: unknown, message: string): boolean {\n\tif (error instanceof StreamDurationBudgetError || error instanceof StreamIdleTimeoutError) return true;\n\tif (error instanceof SummaryRequestError) return error.transient;\n\tif (error instanceof SummarizationOverflowExhaustedError) return true;\n\treturn isRetryableErrorMessage(message);\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { buildPartialFailureText } from "./recovery.ts";
|
|
2
2
|
import type { ApplyPatchProgressCallback, ApplyPatchResult, AtomicWriteOperations } from "./types.ts";
|
|
3
|
+
export declare function compactApplyPatchResult(result: ApplyPatchResult): ApplyPatchResult;
|
|
3
4
|
export declare function __testWriteFileAtomic(absPath: string, content: string, operations: AtomicWriteOperations): Promise<void>;
|
|
4
5
|
export declare function applyPatchDetailed(cwd: string, patchText: string, onProgress?: ApplyPatchProgressCallback): Promise<ApplyPatchResult>;
|
|
5
6
|
export declare function applyPatch(cwd: string, patchText: string): Promise<string[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/apply.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAGxD,OAAO,KAAK,EAGX,0BAA0B,EAC1B,gBAAgB,EAChB,qBAAqB,EAErB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/apply.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAGxD,OAAO,KAAK,EAGX,0BAA0B,EAC1B,gBAAgB,EAChB,qBAAqB,EAErB,MAAM,YAAY,CAAC;AA2BpB,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAWlF;AAkBD,wBAAsB,qBAAqB,CAC1C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,qBAAqB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAEf;AA2FD,wBAAsB,kBAAkB,CACvC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,0BAA0B,GACrC,OAAO,CAAC,gBAAgB,CAAC,CAqC3B;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA6BlF"}
|
|
@@ -27,6 +27,18 @@ function extractErrorCode(error) {
|
|
|
27
27
|
}
|
|
28
28
|
return undefined;
|
|
29
29
|
}
|
|
30
|
+
export function compactApplyPatchResult(result) {
|
|
31
|
+
return {
|
|
32
|
+
...result,
|
|
33
|
+
details: {
|
|
34
|
+
...result.details,
|
|
35
|
+
appliedOperations: result.details.appliedOperations.map(({ operationIndex, preview }) => {
|
|
36
|
+
const { diff: _diff, patch: _patch, ...metadata } = preview;
|
|
37
|
+
return { operationIndex, preview: { ...metadata, diff: "" } };
|
|
38
|
+
}),
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
30
42
|
async function writeFileAtomic(absPath, content, operations = ATOMIC_WRITE_OPERATIONS) {
|
|
31
43
|
const tempPath = `${absPath}.tmp.${process.pid}.${Math.random().toString(16).slice(2)}`;
|
|
32
44
|
await operations.writeFile(tempPath, content, "utf-8");
|
|
@@ -179,7 +191,7 @@ export async function applyPatch(cwd, patchText) {
|
|
|
179
191
|
recoveryInstructions: createRecoveryInstructions({ appliedFiles, failures }),
|
|
180
192
|
details: { fuzz: 0, appliedOperations },
|
|
181
193
|
};
|
|
182
|
-
throw new ApplyPatchError(message, result);
|
|
194
|
+
throw new ApplyPatchError(message, compactApplyPatchResult(result));
|
|
183
195
|
}
|
|
184
196
|
}
|
|
185
197
|
return summaries;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/apply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAA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AE,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,CAAC,KAAK,CAAC,EAAE;aACzG,CAAC;YACF,MAAM,MAAM,GAAqB;gBAChC,SAAS;gBACT,YAAY;gBACZ,QAAQ;gBACR,iBAAiB,EAAE,YAAY,CAAC,MAAM,GAAG,CAAC;gBAC1C,oBAAoB,EAAE,0BAA0B,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;gBAC5E,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,iBAAiB,EAAE;aACvC,CAAC;YACF,MAAM,IAAI,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5C,CAAC;IACF,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import { mkdir, readFile, rename, rm, unlink, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { withFileMutationQueue } from \"../../../tools/file-mutation-queue.ts\";\nimport { ApplyPatchError } from \"./errors.ts\";\nimport { parsePatch } from \"./parser.ts\";\nimport { replaceChunks } from \"./patch-replace.ts\";\nimport { buildPatchPreviewFile, readPatchFileSnapshot } from \"./preview.ts\";\nimport { createRecoveryInstructions } from \"./recovery.ts\";\n\nexport { buildPartialFailureText } from \"./recovery.ts\";\n\nimport { normalizePatchText } from \"./text.ts\";\nimport type {\n\tAppliedPatchOperation,\n\tApplyPatchFailure,\n\tApplyPatchProgressCallback,\n\tApplyPatchResult,\n\tAtomicWriteOperations,\n\tParsedPatch,\n} from \"./types.ts\";\nimport { resolvePatchPath } from \"./workspace.ts\";\n\nconst ATOMIC_WRITE_OPERATIONS: AtomicWriteOperations = { writeFile, rename, unlink };\n\nasync function notifyApplyPatchProgress(\n\tonProgress: ApplyPatchProgressCallback | undefined,\n\tprogress: Parameters<ApplyPatchProgressCallback>[0],\n): Promise<void> {\n\ttry {\n\t\tawait onProgress?.(progress);\n\t} catch {\n\t\t// Rendering progress must not affect patch application or recovery details.\n\t}\n}\n\nfunction hasErrorCode(error: unknown, code: string): boolean {\n\treturn Boolean(error && typeof error === \"object\" && \"code\" in error && error.code === code);\n}\n\nfunction extractErrorCode(error: unknown): string | undefined {\n\tif (error && typeof error === \"object\" && \"code\" in error && typeof error.code === \"string\") {\n\t\treturn error.code;\n\t}\n\treturn undefined;\n}\n\nasync function writeFileAtomic(\n\tabsPath: string,\n\tcontent: string,\n\toperations: AtomicWriteOperations = ATOMIC_WRITE_OPERATIONS,\n): Promise<void> {\n\tconst tempPath = `${absPath}.tmp.${process.pid}.${Math.random().toString(16).slice(2)}`;\n\tawait operations.writeFile(tempPath, content, \"utf-8\");\n\ttry {\n\t\tawait operations.rename(tempPath, absPath);\n\t} catch (error) {\n\t\tif (!hasErrorCode(error, \"EEXIST\")) throw error;\n\t\tawait operations.unlink(absPath);\n\t\tawait operations.rename(tempPath, absPath);\n\t}\n}\n\nexport async function __testWriteFileAtomic(\n\tabsPath: string,\n\tcontent: string,\n\toperations: AtomicWriteOperations,\n): Promise<void> {\n\tawait writeFileAtomic(absPath, content, operations);\n}\n\nasync function applySingleHunk(\n\tcwd: string,\n\thunk: ParsedPatch,\n): Promise<{\n\treadonly summary: string;\n\treadonly appliedFile: string;\n\treadonly fuzz: number;\n\treadonly preview: ReturnType<typeof buildPatchPreviewFile>;\n}> {\n\tconst absolutePath = resolvePatchPath(cwd, hunk.filePath);\n\tconst mutationPaths =\n\t\thunk.type === \"update\" && hunk.movePath ? [absolutePath, resolvePatchPath(cwd, hunk.movePath)] : [absolutePath];\n\treturn withPatchMutationQueues(mutationPaths, async () => {\n\t\tif (hunk.type === \"add\") {\n\t\t\tconst source = await readPatchFileSnapshot(absolutePath);\n\t\t\tconst preview = buildPatchPreviewFile({ hunk, source, newContent: hunk.content });\n\t\t\tawait mkdir(path.dirname(absolutePath), { recursive: true });\n\t\t\tawait writeFileAtomic(absolutePath, hunk.content);\n\t\t\treturn { summary: `add: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: 0, preview };\n\t\t}\n\n\t\tif (hunk.type === \"delete\") {\n\t\t\tconst oldContent = await readFile(absolutePath, \"utf-8\");\n\t\t\tconst preview = buildPatchPreviewFile({\n\t\t\t\thunk,\n\t\t\t\tsource: { exists: true, content: oldContent },\n\t\t\t\tnewContent: \"\",\n\t\t\t});\n\t\t\tawait rm(absolutePath);\n\t\t\treturn { summary: `delete: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: 0, preview };\n\t\t}\n\n\t\tconst currentContent = await readFile(absolutePath, \"utf-8\");\n\t\tconst chunkResult =\n\t\t\thunk.chunks.length === 0\n\t\t\t\t? { content: currentContent, fuzz: 0 }\n\t\t\t\t: replaceChunks(currentContent, hunk.filePath, hunk.chunks);\n\n\t\tif (hunk.movePath) {\n\t\t\tconst absoluteMovePath = resolvePatchPath(cwd, hunk.movePath);\n\t\t\tconst moveDestination =\n\t\t\t\tabsoluteMovePath === absolutePath ? undefined : await readPatchFileSnapshot(absoluteMovePath);\n\t\t\tconst preview = buildPatchPreviewFile({\n\t\t\t\thunk,\n\t\t\t\tsource: { exists: true, content: currentContent },\n\t\t\t\tnewContent: chunkResult.content,\n\t\t\t\t...(moveDestination ? { moveDestination } : {}),\n\t\t\t});\n\t\t\tawait mkdir(path.dirname(absoluteMovePath), { recursive: true });\n\t\t\tawait writeFileAtomic(absoluteMovePath, chunkResult.content);\n\t\t\tif (absoluteMovePath !== absolutePath) await rm(absolutePath);\n\t\t\treturn {\n\t\t\t\tsummary: `move: ${hunk.filePath} -> ${hunk.movePath}`,\n\t\t\t\tappliedFile: hunk.movePath,\n\t\t\t\tfuzz: chunkResult.fuzz,\n\t\t\t\tpreview,\n\t\t\t};\n\t\t}\n\n\t\tconst preview = buildPatchPreviewFile({\n\t\t\thunk,\n\t\t\tsource: { exists: true, content: currentContent },\n\t\t\tnewContent: chunkResult.content,\n\t\t});\n\t\tawait writeFileAtomic(absolutePath, chunkResult.content);\n\t\treturn { summary: `update: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: chunkResult.fuzz, preview };\n\t});\n}\n\nasync function withPatchMutationQueues<T>(filePaths: readonly string[], operation: () => Promise<T>): Promise<T> {\n\tconst sortedPaths = [...new Set(filePaths)].sort((left, right) => left.localeCompare(right));\n\tconst runQueued = (index: number): Promise<T> => {\n\t\tconst filePath = sortedPaths[index];\n\t\tif (filePath === undefined) return operation();\n\t\treturn withFileMutationQueue(filePath, () => runQueued(index + 1));\n\t};\n\treturn runQueued(0);\n}\n\nfunction parseNonEmptyPatch(patchText: string): ParsedPatch[] {\n\tconst hunks = parsePatch(patchText);\n\tif (hunks.length === 0) {\n\t\tconst normalized = normalizePatchText(patchText).trim();\n\t\tif (normalized === \"*** Begin Patch\\n*** End Patch\") throw new Error(\"patch rejected: empty patch\");\n\t\tthrow new Error(\"apply_patch verification failed: no hunks found\");\n\t}\n\treturn hunks;\n}\n\nexport async function applyPatchDetailed(\n\tcwd: string,\n\tpatchText: string,\n\tonProgress?: ApplyPatchProgressCallback,\n): Promise<ApplyPatchResult> {\n\tconst hunks = parseNonEmptyPatch(patchText);\n\tconst summaries: string[] = [];\n\tconst appliedFiles: string[] = [];\n\tconst appliedOperations: AppliedPatchOperation[] = [];\n\tconst failures: ApplyPatchFailure[] = [];\n\tlet fuzz = 0;\n\n\tfor (const [operationIndex, hunk] of hunks.entries()) {\n\t\ttry {\n\t\t\tconst applied = await applySingleHunk(cwd, hunk);\n\t\t\tsummaries.push(applied.summary);\n\t\t\tappliedFiles.push(applied.appliedFile);\n\t\t\tappliedOperations.push({ operationIndex, preview: applied.preview });\n\t\t\tfuzz += applied.fuzz;\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tconst code = extractErrorCode(error);\n\t\t\tfailures.push({ operationIndex, filePath: hunk.filePath, operation: hunk.type, message, code });\n\t\t}\n\t\tawait notifyApplyPatchProgress(onProgress, {\n\t\t\tapplied: appliedFiles.length,\n\t\t\tfailed: failures.length,\n\t\t\ttotal: hunks.length,\n\t\t});\n\t}\n\n\tconst result: ApplyPatchResult = {\n\t\tsummaries,\n\t\tappliedFiles,\n\t\tfailures,\n\t\thasPartialSuccess: appliedFiles.length > 0 && failures.length > 0,\n\t\trecoveryInstructions: { mustReadFiles: [], mustNotReadFiles: [], failedFiles: [] },\n\t\tdetails: { fuzz, appliedOperations },\n\t};\n\tresult.recoveryInstructions = createRecoveryInstructions(result);\n\treturn result;\n}\n\nexport async function applyPatch(cwd: string, patchText: string): Promise<string[]> {\n\tconst hunks = parseNonEmptyPatch(patchText);\n\tconst summaries: string[] = [];\n\tconst appliedFiles: string[] = [];\n\tconst appliedOperations: AppliedPatchOperation[] = [];\n\tfor (const [operationIndex, hunk] of hunks.entries()) {\n\t\ttry {\n\t\t\tconst applied = await applySingleHunk(cwd, hunk);\n\t\t\tsummaries.push(applied.summary);\n\t\t\tappliedFiles.push(applied.appliedFile);\n\t\t\tappliedOperations.push({ operationIndex, preview: applied.preview });\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tconst failures: ApplyPatchFailure[] = [\n\t\t\t\t{ operationIndex, filePath: hunk.filePath, operation: hunk.type, message, code: extractErrorCode(error) },\n\t\t\t];\n\t\t\tconst result: ApplyPatchResult = {\n\t\t\t\tsummaries,\n\t\t\t\tappliedFiles,\n\t\t\t\tfailures,\n\t\t\t\thasPartialSuccess: appliedFiles.length > 0,\n\t\t\t\trecoveryInstructions: createRecoveryInstructions({ appliedFiles, failures }),\n\t\t\t\tdetails: { fuzz: 0, appliedOperations },\n\t\t\t};\n\t\t\tthrow new ApplyPatchError(message, result);\n\t\t}\n\t}\n\n\treturn summaries;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/apply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,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,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import { mkdir, readFile, rename, rm, unlink, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { withFileMutationQueue } from \"../../../tools/file-mutation-queue.ts\";\nimport { ApplyPatchError } from \"./errors.ts\";\nimport { parsePatch } from \"./parser.ts\";\nimport { replaceChunks } from \"./patch-replace.ts\";\nimport { buildPatchPreviewFile, readPatchFileSnapshot } from \"./preview.ts\";\nimport { createRecoveryInstructions } from \"./recovery.ts\";\n\nexport { buildPartialFailureText } from \"./recovery.ts\";\n\nimport { normalizePatchText } from \"./text.ts\";\nimport type {\n\tAppliedPatchOperation,\n\tApplyPatchFailure,\n\tApplyPatchProgressCallback,\n\tApplyPatchResult,\n\tAtomicWriteOperations,\n\tParsedPatch,\n} from \"./types.ts\";\nimport { resolvePatchPath } from \"./workspace.ts\";\n\nconst ATOMIC_WRITE_OPERATIONS: AtomicWriteOperations = { writeFile, rename, unlink };\n\nasync function notifyApplyPatchProgress(\n\tonProgress: ApplyPatchProgressCallback | undefined,\n\tprogress: Parameters<ApplyPatchProgressCallback>[0],\n): Promise<void> {\n\ttry {\n\t\tawait onProgress?.(progress);\n\t} catch {\n\t\t// Rendering progress must not affect patch application or recovery details.\n\t}\n}\n\nfunction hasErrorCode(error: unknown, code: string): boolean {\n\treturn Boolean(error && typeof error === \"object\" && \"code\" in error && error.code === code);\n}\n\nfunction extractErrorCode(error: unknown): string | undefined {\n\tif (error && typeof error === \"object\" && \"code\" in error && typeof error.code === \"string\") {\n\t\treturn error.code;\n\t}\n\treturn undefined;\n}\n\nexport function compactApplyPatchResult(result: ApplyPatchResult): ApplyPatchResult {\n\treturn {\n\t\t...result,\n\t\tdetails: {\n\t\t\t...result.details,\n\t\t\tappliedOperations: result.details.appliedOperations.map(({ operationIndex, preview }) => {\n\t\t\t\tconst { diff: _diff, patch: _patch, ...metadata } = preview;\n\t\t\t\treturn { operationIndex, preview: { ...metadata, diff: \"\" } };\n\t\t\t}),\n\t\t},\n\t};\n}\n\nasync function writeFileAtomic(\n\tabsPath: string,\n\tcontent: string,\n\toperations: AtomicWriteOperations = ATOMIC_WRITE_OPERATIONS,\n): Promise<void> {\n\tconst tempPath = `${absPath}.tmp.${process.pid}.${Math.random().toString(16).slice(2)}`;\n\tawait operations.writeFile(tempPath, content, \"utf-8\");\n\ttry {\n\t\tawait operations.rename(tempPath, absPath);\n\t} catch (error) {\n\t\tif (!hasErrorCode(error, \"EEXIST\")) throw error;\n\t\tawait operations.unlink(absPath);\n\t\tawait operations.rename(tempPath, absPath);\n\t}\n}\n\nexport async function __testWriteFileAtomic(\n\tabsPath: string,\n\tcontent: string,\n\toperations: AtomicWriteOperations,\n): Promise<void> {\n\tawait writeFileAtomic(absPath, content, operations);\n}\n\nasync function applySingleHunk(\n\tcwd: string,\n\thunk: ParsedPatch,\n): Promise<{\n\treadonly summary: string;\n\treadonly appliedFile: string;\n\treadonly fuzz: number;\n\treadonly preview: ReturnType<typeof buildPatchPreviewFile>;\n}> {\n\tconst absolutePath = resolvePatchPath(cwd, hunk.filePath);\n\tconst mutationPaths =\n\t\thunk.type === \"update\" && hunk.movePath ? [absolutePath, resolvePatchPath(cwd, hunk.movePath)] : [absolutePath];\n\treturn withPatchMutationQueues(mutationPaths, async () => {\n\t\tif (hunk.type === \"add\") {\n\t\t\tconst source = await readPatchFileSnapshot(absolutePath);\n\t\t\tconst preview = buildPatchPreviewFile({ hunk, source, newContent: hunk.content });\n\t\t\tawait mkdir(path.dirname(absolutePath), { recursive: true });\n\t\t\tawait writeFileAtomic(absolutePath, hunk.content);\n\t\t\treturn { summary: `add: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: 0, preview };\n\t\t}\n\n\t\tif (hunk.type === \"delete\") {\n\t\t\tconst oldContent = await readFile(absolutePath, \"utf-8\");\n\t\t\tconst preview = buildPatchPreviewFile({\n\t\t\t\thunk,\n\t\t\t\tsource: { exists: true, content: oldContent },\n\t\t\t\tnewContent: \"\",\n\t\t\t});\n\t\t\tawait rm(absolutePath);\n\t\t\treturn { summary: `delete: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: 0, preview };\n\t\t}\n\n\t\tconst currentContent = await readFile(absolutePath, \"utf-8\");\n\t\tconst chunkResult =\n\t\t\thunk.chunks.length === 0\n\t\t\t\t? { content: currentContent, fuzz: 0 }\n\t\t\t\t: replaceChunks(currentContent, hunk.filePath, hunk.chunks);\n\n\t\tif (hunk.movePath) {\n\t\t\tconst absoluteMovePath = resolvePatchPath(cwd, hunk.movePath);\n\t\t\tconst moveDestination =\n\t\t\t\tabsoluteMovePath === absolutePath ? undefined : await readPatchFileSnapshot(absoluteMovePath);\n\t\t\tconst preview = buildPatchPreviewFile({\n\t\t\t\thunk,\n\t\t\t\tsource: { exists: true, content: currentContent },\n\t\t\t\tnewContent: chunkResult.content,\n\t\t\t\t...(moveDestination ? { moveDestination } : {}),\n\t\t\t});\n\t\t\tawait mkdir(path.dirname(absoluteMovePath), { recursive: true });\n\t\t\tawait writeFileAtomic(absoluteMovePath, chunkResult.content);\n\t\t\tif (absoluteMovePath !== absolutePath) await rm(absolutePath);\n\t\t\treturn {\n\t\t\t\tsummary: `move: ${hunk.filePath} -> ${hunk.movePath}`,\n\t\t\t\tappliedFile: hunk.movePath,\n\t\t\t\tfuzz: chunkResult.fuzz,\n\t\t\t\tpreview,\n\t\t\t};\n\t\t}\n\n\t\tconst preview = buildPatchPreviewFile({\n\t\t\thunk,\n\t\t\tsource: { exists: true, content: currentContent },\n\t\t\tnewContent: chunkResult.content,\n\t\t});\n\t\tawait writeFileAtomic(absolutePath, chunkResult.content);\n\t\treturn { summary: `update: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: chunkResult.fuzz, preview };\n\t});\n}\n\nasync function withPatchMutationQueues<T>(filePaths: readonly string[], operation: () => Promise<T>): Promise<T> {\n\tconst sortedPaths = [...new Set(filePaths)].sort((left, right) => left.localeCompare(right));\n\tconst runQueued = (index: number): Promise<T> => {\n\t\tconst filePath = sortedPaths[index];\n\t\tif (filePath === undefined) return operation();\n\t\treturn withFileMutationQueue(filePath, () => runQueued(index + 1));\n\t};\n\treturn runQueued(0);\n}\n\nfunction parseNonEmptyPatch(patchText: string): ParsedPatch[] {\n\tconst hunks = parsePatch(patchText);\n\tif (hunks.length === 0) {\n\t\tconst normalized = normalizePatchText(patchText).trim();\n\t\tif (normalized === \"*** Begin Patch\\n*** End Patch\") throw new Error(\"patch rejected: empty patch\");\n\t\tthrow new Error(\"apply_patch verification failed: no hunks found\");\n\t}\n\treturn hunks;\n}\n\nexport async function applyPatchDetailed(\n\tcwd: string,\n\tpatchText: string,\n\tonProgress?: ApplyPatchProgressCallback,\n): Promise<ApplyPatchResult> {\n\tconst hunks = parseNonEmptyPatch(patchText);\n\tconst summaries: string[] = [];\n\tconst appliedFiles: string[] = [];\n\tconst appliedOperations: AppliedPatchOperation[] = [];\n\tconst failures: ApplyPatchFailure[] = [];\n\tlet fuzz = 0;\n\n\tfor (const [operationIndex, hunk] of hunks.entries()) {\n\t\ttry {\n\t\t\tconst applied = await applySingleHunk(cwd, hunk);\n\t\t\tsummaries.push(applied.summary);\n\t\t\tappliedFiles.push(applied.appliedFile);\n\t\t\tappliedOperations.push({ operationIndex, preview: applied.preview });\n\t\t\tfuzz += applied.fuzz;\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tconst code = extractErrorCode(error);\n\t\t\tfailures.push({ operationIndex, filePath: hunk.filePath, operation: hunk.type, message, code });\n\t\t}\n\t\tawait notifyApplyPatchProgress(onProgress, {\n\t\t\tapplied: appliedFiles.length,\n\t\t\tfailed: failures.length,\n\t\t\ttotal: hunks.length,\n\t\t});\n\t}\n\n\tconst result: ApplyPatchResult = {\n\t\tsummaries,\n\t\tappliedFiles,\n\t\tfailures,\n\t\thasPartialSuccess: appliedFiles.length > 0 && failures.length > 0,\n\t\trecoveryInstructions: { mustReadFiles: [], mustNotReadFiles: [], failedFiles: [] },\n\t\tdetails: { fuzz, appliedOperations },\n\t};\n\tresult.recoveryInstructions = createRecoveryInstructions(result);\n\treturn result;\n}\n\nexport async function applyPatch(cwd: string, patchText: string): Promise<string[]> {\n\tconst hunks = parseNonEmptyPatch(patchText);\n\tconst summaries: string[] = [];\n\tconst appliedFiles: string[] = [];\n\tconst appliedOperations: AppliedPatchOperation[] = [];\n\tfor (const [operationIndex, hunk] of hunks.entries()) {\n\t\ttry {\n\t\t\tconst applied = await applySingleHunk(cwd, hunk);\n\t\t\tsummaries.push(applied.summary);\n\t\t\tappliedFiles.push(applied.appliedFile);\n\t\t\tappliedOperations.push({ operationIndex, preview: applied.preview });\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tconst failures: ApplyPatchFailure[] = [\n\t\t\t\t{ operationIndex, filePath: hunk.filePath, operation: hunk.type, message, code: extractErrorCode(error) },\n\t\t\t];\n\t\t\tconst result: ApplyPatchResult = {\n\t\t\t\tsummaries,\n\t\t\t\tappliedFiles,\n\t\t\t\tfailures,\n\t\t\t\thasPartialSuccess: appliedFiles.length > 0,\n\t\t\t\trecoveryInstructions: createRecoveryInstructions({ appliedFiles, failures }),\n\t\t\t\tdetails: { fuzz: 0, appliedOperations },\n\t\t\t};\n\t\t\tthrow new ApplyPatchError(message, compactApplyPatchResult(result));\n\t\t}\n\t}\n\n\treturn summaries;\n}\n"]}
|
|
@@ -7,6 +7,6 @@ export { clearApplyPatchRenderState, displayPath, formatInFlightCallText, format
|
|
|
7
7
|
export { seekSequence } from "./seek-sequence.ts";
|
|
8
8
|
export { StreamingPatchParser } from "./streaming-parser.ts";
|
|
9
9
|
export { extractPatchedPaths, normalizePatchText, stripHeredoc } from "./text.ts";
|
|
10
|
-
export { createApplyPatchTool } from "./tool.ts";
|
|
10
|
+
export { APPLY_PATCH_RESULT_PATCH_MAX_BYTES, createApplyPatchTool } from "./tool.ts";
|
|
11
11
|
export type { ApplyPatchExtensionAPI, ApplyPatchFailure, ApplyPatchParams, ApplyPatchPreview, ApplyPatchProgress, ApplyPatchProgressCallback, ApplyPatchRecoveryInstructions, ApplyPatchRenderState, ApplyPatchResult, ApplyPatchToolDefinition, ApplyPatchToolDetails, AtomicWriteOperations, FreeformToolFormat, ParsedPatch, PatchChunk, } from "./types.ts";
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAO,EACN,gCAAgC,EAChC,4BAA4B,EAC5B,wBAAwB,EACxB,kBAAkB,EAClB,6BAA6B,GAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC/G,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,0BAA0B,EAC1B,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAO,EACN,gCAAgC,EAChC,4BAA4B,EAC5B,wBAAwB,EACxB,kBAAkB,EAClB,6BAA6B,GAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC/G,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,0BAA0B,EAC1B,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,kCAAkC,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACrF,YAAY,EACX,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,0BAA0B,EAC1B,8BAA8B,EAC9B,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,UAAU,GACV,MAAM,YAAY,CAAC"}
|
|
@@ -7,5 +7,5 @@ export { clearApplyPatchRenderState, displayPath, formatInFlightCallText, format
|
|
|
7
7
|
export { seekSequence } from "./seek-sequence.js";
|
|
8
8
|
export { StreamingPatchParser } from "./streaming-parser.js";
|
|
9
9
|
export { extractPatchedPaths, normalizePatchText, stripHeredoc } from "./text.js";
|
|
10
|
-
export { createApplyPatchTool } from "./tool.js";
|
|
10
|
+
export { APPLY_PATCH_RESULT_PATCH_MAX_BYTES, createApplyPatchTool } from "./tool.js";
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAO,EACN,gCAAgC,EAChC,4BAA4B,EAC5B,wBAAwB,EACxB,kBAAkB,EAClB,6BAA6B,GAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC/G,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,0BAA0B,EAC1B,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC","sourcesContent":["export { __testWriteFileAtomic, applyPatch, applyPatchDetailed, buildPartialFailureText } from \"./apply.ts\";\nexport {\n\tAPPLY_PATCH_FREEFORM_DESCRIPTION,\n\tAPPLY_PATCH_JSON_DESCRIPTION,\n\tAPPLY_PATCH_LARK_GRAMMAR,\n\tAPPLY_PATCH_PARAMS,\n\tCODEX_APPLY_PATCH_DESCRIPTION,\n} from \"./constants.ts\";\nexport { ApplyPatchError } from \"./errors.ts\";\nexport { default, getApplyPatchWireMode, isOpenAIGptModel, registerApplyPatchExtension } from \"./extension.ts\";\nexport { parsePatch } from \"./parser.ts\";\nexport {\n\tclearApplyPatchRenderState,\n\tdisplayPath,\n\tformatInFlightCallText,\n\tformatPatchPreview,\n\tgetApplyPatchRenderState,\n\tPATCH_PREVIEW_MAX_CHARS,\n\tPATCH_PREVIEW_MAX_LINES,\n\trenderPatchPreview,\n\ttruncatePreview,\n} from \"./preview-format.ts\";\nexport { seekSequence } from \"./seek-sequence.ts\";\nexport { StreamingPatchParser } from \"./streaming-parser.ts\";\nexport { extractPatchedPaths, normalizePatchText, stripHeredoc } from \"./text.ts\";\nexport { createApplyPatchTool } from \"./tool.ts\";\nexport type {\n\tApplyPatchExtensionAPI,\n\tApplyPatchFailure,\n\tApplyPatchParams,\n\tApplyPatchPreview,\n\tApplyPatchProgress,\n\tApplyPatchProgressCallback,\n\tApplyPatchRecoveryInstructions,\n\tApplyPatchRenderState,\n\tApplyPatchResult,\n\tApplyPatchToolDefinition,\n\tApplyPatchToolDetails,\n\tAtomicWriteOperations,\n\tFreeformToolFormat,\n\tParsedPatch,\n\tPatchChunk,\n} from \"./types.ts\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAO,EACN,gCAAgC,EAChC,4BAA4B,EAC5B,wBAAwB,EACxB,kBAAkB,EAClB,6BAA6B,GAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC/G,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,0BAA0B,EAC1B,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,kCAAkC,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC","sourcesContent":["export { __testWriteFileAtomic, applyPatch, applyPatchDetailed, buildPartialFailureText } from \"./apply.ts\";\nexport {\n\tAPPLY_PATCH_FREEFORM_DESCRIPTION,\n\tAPPLY_PATCH_JSON_DESCRIPTION,\n\tAPPLY_PATCH_LARK_GRAMMAR,\n\tAPPLY_PATCH_PARAMS,\n\tCODEX_APPLY_PATCH_DESCRIPTION,\n} from \"./constants.ts\";\nexport { ApplyPatchError } from \"./errors.ts\";\nexport { default, getApplyPatchWireMode, isOpenAIGptModel, registerApplyPatchExtension } from \"./extension.ts\";\nexport { parsePatch } from \"./parser.ts\";\nexport {\n\tclearApplyPatchRenderState,\n\tdisplayPath,\n\tformatInFlightCallText,\n\tformatPatchPreview,\n\tgetApplyPatchRenderState,\n\tPATCH_PREVIEW_MAX_CHARS,\n\tPATCH_PREVIEW_MAX_LINES,\n\trenderPatchPreview,\n\ttruncatePreview,\n} from \"./preview-format.ts\";\nexport { seekSequence } from \"./seek-sequence.ts\";\nexport { StreamingPatchParser } from \"./streaming-parser.ts\";\nexport { extractPatchedPaths, normalizePatchText, stripHeredoc } from \"./text.ts\";\nexport { APPLY_PATCH_RESULT_PATCH_MAX_BYTES, createApplyPatchTool } from \"./tool.ts\";\nexport type {\n\tApplyPatchExtensionAPI,\n\tApplyPatchFailure,\n\tApplyPatchParams,\n\tApplyPatchPreview,\n\tApplyPatchProgress,\n\tApplyPatchProgressCallback,\n\tApplyPatchRecoveryInstructions,\n\tApplyPatchRenderState,\n\tApplyPatchResult,\n\tApplyPatchToolDefinition,\n\tApplyPatchToolDetails,\n\tAtomicWriteOperations,\n\tFreeformToolFormat,\n\tParsedPatch,\n\tPatchChunk,\n} from \"./types.ts\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/tool.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAKX,wBAAwB,EAGxB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/tool.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAKX,wBAAwB,EAGxB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,kCAAkC,QAAY,CAAC;AA8F5D,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,UAAU,GAAG,MAAmB,GAAG,wBAAwB,CAkGxG"}
|
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
import { Box, Container, Spacer, Text } from "@earendil-works/pi-tui";
|
|
2
2
|
import { defineTool } from "../../types.js";
|
|
3
|
-
import { applyPatchDetailed, buildPartialFailureText } from "./apply.js";
|
|
3
|
+
import { applyPatchDetailed, buildPartialFailureText, compactApplyPatchResult } from "./apply.js";
|
|
4
4
|
import { APPLY_PATCH_FREEFORM_DESCRIPTION, APPLY_PATCH_JSON_DESCRIPTION, APPLY_PATCH_LARK_GRAMMAR, APPLY_PATCH_PARAMS, } from "./constants.js";
|
|
5
5
|
import { normalizeApplyPatchArguments } from "./params.js";
|
|
6
6
|
import { parsePatch } from "./parser.js";
|
|
7
7
|
import { createPendingPatchUpdate } from "./preview.js";
|
|
8
|
-
import { getApplyPatchRenderState, renderPatchPreview } from "./preview-format.js";
|
|
8
|
+
import { getApplyPatchRenderState, renderPatchPreview, truncatePreview } from "./preview-format.js";
|
|
9
9
|
import { renderStreamingPatchCall } from "./streaming-render.js";
|
|
10
|
+
export const APPLY_PATCH_RESULT_PATCH_MAX_BYTES = 16 * 1024;
|
|
11
|
+
function retainedPatch(patch) {
|
|
12
|
+
if (patch === undefined || Buffer.byteLength(patch, "utf8") > APPLY_PATCH_RESULT_PATCH_MAX_BYTES) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
return patch;
|
|
16
|
+
}
|
|
10
17
|
function appliedPreview(result) {
|
|
11
18
|
const files = [...result.details.appliedOperations]
|
|
12
19
|
.sort((left, right) => left.operationIndex - right.operationIndex)
|
|
13
|
-
.map((operation) =>
|
|
20
|
+
.map((operation) => {
|
|
21
|
+
const { diff, patch, ...metadata } = operation.preview;
|
|
22
|
+
const boundedPatch = retainedPatch(patch);
|
|
23
|
+
return {
|
|
24
|
+
...metadata,
|
|
25
|
+
diff: truncatePreview(diff),
|
|
26
|
+
...(boundedPatch === undefined ? {} : { patch: boundedPatch }),
|
|
27
|
+
};
|
|
28
|
+
});
|
|
14
29
|
if (files.length === 0)
|
|
15
30
|
return undefined;
|
|
16
31
|
return {
|
|
@@ -100,15 +115,18 @@ export function createApplyPatchTool(variant = "freeform") {
|
|
|
100
115
|
onUpdate?.({ content: [{ type: "text", text: progressUpdate.text }], details: progressUpdate.details });
|
|
101
116
|
});
|
|
102
117
|
const resultPreview = appliedPreview(result);
|
|
118
|
+
const persistedResult = compactApplyPatchResult(result);
|
|
103
119
|
if (result.failures.length > 0) {
|
|
104
120
|
return {
|
|
105
121
|
content: [{ type: "text", text: buildPartialFailureText(result) }],
|
|
106
|
-
details: resultPreview
|
|
122
|
+
details: resultPreview
|
|
123
|
+
? { preview: resultPreview, result: persistedResult }
|
|
124
|
+
: { result: persistedResult },
|
|
107
125
|
};
|
|
108
126
|
}
|
|
109
127
|
return {
|
|
110
128
|
content: [{ type: "text", text: result.summaries.join("\n") }],
|
|
111
|
-
details: resultPreview ? { preview: resultPreview, result } : { result },
|
|
129
|
+
details: resultPreview ? { preview: resultPreview, result: persistedResult } : { result: persistedResult },
|
|
112
130
|
};
|
|
113
131
|
},
|
|
114
132
|
renderCall(args, theme, context) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EACN,gCAAgC,EAChC,4BAA4B,EAC5B,wBAAwB,EACxB,kBAAkB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAWjE,SAAS,cAAc,CAAC,MAAwB;IAC/C,MAAM,KAAK,GAAG,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC;SACjD,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;SACjE,GAAG,CAAC,CAAC,SAA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,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACxG,CAAC;gBACD,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBACxB,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,OAAO,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACxC,CAAC;KACD,CAAC,CAAC;IAEH,IAAI,OAAO,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACpC,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QAC1B,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,wBAAwB,EAA+B;KAChH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { Box, Container, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport type { AgentToolResult, ToolRenderContext } from \"../../types.ts\";\nimport { defineTool } from \"../../types.ts\";\nimport { applyPatchDetailed, buildPartialFailureText } from \"./apply.ts\";\nimport {\n\tAPPLY_PATCH_FREEFORM_DESCRIPTION,\n\tAPPLY_PATCH_JSON_DESCRIPTION,\n\tAPPLY_PATCH_LARK_GRAMMAR,\n\tAPPLY_PATCH_PARAMS,\n} from \"./constants.ts\";\nimport { normalizeApplyPatchArguments } from \"./params.ts\";\nimport { parsePatch } from \"./parser.ts\";\nimport { createPendingPatchUpdate } from \"./preview.ts\";\nimport { getApplyPatchRenderState, renderPatchPreview } from \"./preview-format.ts\";\nimport { renderStreamingPatchCall } from \"./streaming-render.ts\";\nimport type {\n\tApplyPatchPreview,\n\tApplyPatchRenderState,\n\tApplyPatchResult,\n\tApplyPatchTheme,\n\tApplyPatchToolDefinition,\n\tApplyPatchToolDetails,\n\tFreeformToolFormat,\n} from \"./types.ts\";\n\nfunction appliedPreview(result: ApplyPatchResult): ApplyPatchPreview | undefined {\n\tconst files = [...result.details.appliedOperations]\n\t\t.sort((left, right) => left.operationIndex - right.operationIndex)\n\t\t.map((operation) => operation.preview);\n\tif (files.length === 0) return undefined;\n\treturn {\n\t\tfiles,\n\t\tadded: files.reduce((total, file) => total + file.added, 0),\n\t\tremoved: files.reduce((total, file) => total + file.removed, 0),\n\t};\n}\n\nfunction renderPreviewBox(\n\ttitle: string,\n\tdetails: ApplyPatchToolDetails,\n\tisPartial: boolean,\n\tcwd: string,\n\texpanded: boolean,\n\ttheme: ApplyPatchTheme,\n): Container {\n\tconst component = new Container();\n\tif (!details.preview) return component;\n\tconst bgName = isPartial ? \"toolPendingBg\" : \"toolSuccessBg\";\n\tconst progress = details.progress;\n\tconst renderedTitle = progress ? `Applying patch (${progress.applied + progress.failed}/${progress.total})` : title;\n\tconst box = new Box(1, 1, (text: string) => theme.bg(bgName, text));\n\tbox.addChild(new Text(theme.fg(\"toolTitle\", theme.bold(renderedTitle)), 0, 0));\n\tbox.addChild(new Spacer(1));\n\tbox.addChild(new Text(renderPatchPreview(details.preview, cwd, theme, expanded), 0, 0));\n\tcomponent.addChild(box);\n\treturn component;\n}\n\nfunction renderTextResult(\n\tresult: AgentToolResult<ApplyPatchToolDetails | undefined>,\n\ttheme: ApplyPatchTheme,\n): Container {\n\tconst component = new Container();\n\tconst text = resultText(result);\n\tif (text) component.addChild(new Text(theme.fg(\"toolOutput\", text), 0, 0));\n\treturn component;\n}\n\nfunction resultText(result: AgentToolResult<ApplyPatchToolDetails | undefined>): string {\n\treturn result.content\n\t\t.filter((block) => block.type === \"text\")\n\t\t.map((block) => block.text)\n\t\t.filter((value) => typeof value === \"string\" && value.length > 0)\n\t\t.join(\"\\n\");\n}\n\nfunction renderFailureBox(\n\tresult: AgentToolResult<ApplyPatchToolDetails>,\n\tcwd: string,\n\texpanded: boolean,\n\ttheme: ApplyPatchTheme,\n): Container {\n\tconst patchResult = result.details?.result;\n\tif (!patchResult) return renderTextResult(result, theme);\n\tconst component = new Container();\n\tconst appliedCount = patchResult.appliedFiles.length;\n\tconst title = appliedCount > 0 ? \"Patch partially failed\" : \"Patch failed\";\n\tconst box = new Box(1, 1, (text: string) => theme.bg(\"toolErrorBg\", text));\n\tbox.addChild(new Text(theme.fg(\"toolTitle\", theme.bold(title)), 0, 0));\n\tif (result.details.preview) {\n\t\tbox.addChild(new Spacer(1));\n\t\tbox.addChild(new Text(renderPatchPreview(result.details.preview, cwd, theme, expanded), 0, 0));\n\t}\n\tconst text = resultText(result);\n\tif (text) {\n\t\tbox.addChild(new Spacer(1));\n\t\tbox.addChild(new Text(theme.fg(\"toolOutput\", text), 0, 0));\n\t}\n\tcomponent.addChild(box);\n\treturn component;\n}\n\nexport function createApplyPatchTool(variant: \"freeform\" | \"json\" = \"freeform\"): ApplyPatchToolDefinition {\n\tconst tool = defineTool<typeof APPLY_PATCH_PARAMS, ApplyPatchToolDetails | undefined, ApplyPatchRenderState>({\n\t\tname: \"apply_patch\",\n\t\tlabel: \"ApplyPatch\",\n\t\tdescription: variant === \"json\" ? APPLY_PATCH_JSON_DESCRIPTION : APPLY_PATCH_FREEFORM_DESCRIPTION,\n\t\tparameters: APPLY_PATCH_PARAMS,\n\t\tprepareArguments: normalizeApplyPatchArguments,\n\t\tpromptSnippet: \"Apply Codex-format file patches with apply_patch\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use apply_patch for file edits instead of mutating files through bash, Python scripts, heredocs, or shell redirection.\",\n\t\t\t\"After apply_patch succeeds, do not re-read the edited files just to confirm the patch applied.\",\n\t\t],\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\tparams,\n\t\t\t_signal,\n\t\t\tonUpdate,\n\t\t\tctx,\n\t\t): Promise<AgentToolResult<ApplyPatchToolDetails | undefined>> {\n\t\t\tconst normalizedParams = normalizeApplyPatchArguments(params);\n\t\t\tif (!normalizedParams.input) throw new Error(\"input is required\");\n\t\t\tlet totalOperations = 0;\n\t\t\ttry {\n\t\t\t\ttotalOperations = parsePatch(normalizedParams.input).length;\n\t\t\t} catch {\n\t\t\t\t// createPendingPatchUpdate keeps incomplete or invalid patch text renderable.\n\t\t\t}\n\t\t\tconst initialProgress = totalOperations > 0 ? { applied: 0, failed: 0, total: totalOperations } : undefined;\n\t\t\tconst pendingUpdate = await createPendingPatchUpdate(ctx.cwd, normalizedParams.input, initialProgress);\n\t\t\tonUpdate?.({ content: [{ type: \"text\", text: pendingUpdate.text }], details: pendingUpdate.details });\n\t\t\tconst preview = pendingUpdate.details?.preview;\n\t\t\tconst result = await applyPatchDetailed(ctx.cwd, normalizedParams.input, async (progress) => {\n\t\t\t\tconst progressUpdate = await createPendingPatchUpdate(ctx.cwd, normalizedParams.input, progress, preview);\n\t\t\t\tonUpdate?.({ content: [{ type: \"text\", text: progressUpdate.text }], details: progressUpdate.details });\n\t\t\t});\n\t\t\tconst resultPreview = appliedPreview(result);\n\t\t\tif (result.failures.length > 0) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: buildPartialFailureText(result) }],\n\t\t\t\t\tdetails: resultPreview ? { preview: resultPreview, result } : { result },\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: result.summaries.join(\"\\n\") }],\n\t\t\t\tdetails: resultPreview ? { preview: resultPreview, result } : { result },\n\t\t\t};\n\t\t},\n\t\trenderCall(args, theme, context: ToolRenderContext<ApplyPatchRenderState, { input: string }>) {\n\t\t\tif (!context.executionStarted) {\n\t\t\t\tconst streaming = renderStreamingPatchCall(normalizeApplyPatchArguments(args), theme, context.state);\n\t\t\t\tif (streaming) return streaming;\n\t\t\t}\n\t\t\tif (!context.argsComplete) return new Text(theme.fg(\"toolTitle\", theme.bold(\"apply_patch: Patching\")), 0, 0);\n\t\t\tconst normalizedArgs = normalizeApplyPatchArguments(args);\n\t\t\tconst renderState = getApplyPatchRenderState(context.toolCallId, context.cwd, normalizedArgs.input);\n\t\t\tconst text = renderState.callText?.length ? `apply_patch: ${renderState.callText}` : \"apply_patch\";\n\t\t\treturn new Text(theme.fg(\"toolTitle\", theme.bold(text)), 0, 0);\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tif (context.isError && result.details?.result?.failures.length) {\n\t\t\t\treturn renderFailureBox(result as AgentToolResult<ApplyPatchToolDetails>, context.cwd, true, theme);\n\t\t\t}\n\t\t\tif (result.details?.preview) {\n\t\t\t\tconst expanded = true;\n\t\t\t\treturn renderPreviewBox(\n\t\t\t\t\toptions.isPartial ? \"Applying patch\" : \"Applied patch\",\n\t\t\t\t\tresult.details,\n\t\t\t\t\toptions.isPartial,\n\t\t\t\t\tcontext.cwd,\n\t\t\t\t\texpanded,\n\t\t\t\t\ttheme,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (result.details?.result) {\n\t\t\t\tconst component = new Container();\n\t\t\t\tconst box = new Box(1, 1, (text: string) =>\n\t\t\t\t\ttheme.bg(options.isPartial ? \"toolPendingBg\" : \"toolSuccessBg\", text),\n\t\t\t\t);\n\t\t\t\tbox.addChild(new Text(theme.fg(\"toolTitle\", theme.bold(\"Applying patch\")), 0, 0));\n\t\t\t\tbox.addChild(new Spacer(1));\n\t\t\t\tif (result.details.preview) {\n\t\t\t\t\tconst expanded = options.isPartial ? true : (options.expanded ?? true);\n\t\t\t\t\tbox.addChild(new Text(renderPatchPreview(result.details.preview, context.cwd, theme, expanded), 0, 0));\n\t\t\t\t}\n\t\t\t\tcomponent.addChild(box);\n\t\t\t\treturn component;\n\t\t\t}\n\t\t\treturn renderTextResult(result, theme);\n\t\t},\n\t});\n\n\tif (variant === \"json\") return tool;\n\treturn Object.assign(tool, {\n\t\tfreeform: { type: \"grammar\", syntax: \"lark\", definition: APPLY_PATCH_LARK_GRAMMAR } satisfies FreeformToolFormat,\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE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,CAAC,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAC;oBACvE,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACxG,CAAC;gBACD,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBACxB,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,OAAO,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACxC,CAAC;KACD,CAAC,CAAC;IAEH,IAAI,OAAO,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACpC,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QAC1B,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,wBAAwB,EAA+B;KAChH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { Box, Container, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport type { AgentToolResult, ToolRenderContext } from \"../../types.ts\";\nimport { defineTool } from \"../../types.ts\";\nimport { applyPatchDetailed, buildPartialFailureText, compactApplyPatchResult } from \"./apply.ts\";\nimport {\n\tAPPLY_PATCH_FREEFORM_DESCRIPTION,\n\tAPPLY_PATCH_JSON_DESCRIPTION,\n\tAPPLY_PATCH_LARK_GRAMMAR,\n\tAPPLY_PATCH_PARAMS,\n} from \"./constants.ts\";\nimport { normalizeApplyPatchArguments } from \"./params.ts\";\nimport { parsePatch } from \"./parser.ts\";\nimport { createPendingPatchUpdate } from \"./preview.ts\";\nimport { getApplyPatchRenderState, renderPatchPreview, truncatePreview } from \"./preview-format.ts\";\nimport { renderStreamingPatchCall } from \"./streaming-render.ts\";\nimport type {\n\tApplyPatchPreview,\n\tApplyPatchRenderState,\n\tApplyPatchResult,\n\tApplyPatchTheme,\n\tApplyPatchToolDefinition,\n\tApplyPatchToolDetails,\n\tFreeformToolFormat,\n} from \"./types.ts\";\n\nexport const APPLY_PATCH_RESULT_PATCH_MAX_BYTES = 16 * 1024;\n\nfunction retainedPatch(patch: string | undefined): string | undefined {\n\tif (patch === undefined || Buffer.byteLength(patch, \"utf8\") > APPLY_PATCH_RESULT_PATCH_MAX_BYTES) {\n\t\treturn undefined;\n\t}\n\treturn patch;\n}\n\nfunction appliedPreview(result: ApplyPatchResult): ApplyPatchPreview | undefined {\n\tconst files = [...result.details.appliedOperations]\n\t\t.sort((left, right) => left.operationIndex - right.operationIndex)\n\t\t.map((operation) => {\n\t\t\tconst { diff, patch, ...metadata } = operation.preview;\n\t\t\tconst boundedPatch = retainedPatch(patch);\n\t\t\treturn {\n\t\t\t\t...metadata,\n\t\t\t\tdiff: truncatePreview(diff),\n\t\t\t\t...(boundedPatch === undefined ? {} : { patch: boundedPatch }),\n\t\t\t};\n\t\t});\n\tif (files.length === 0) return undefined;\n\treturn {\n\t\tfiles,\n\t\tadded: files.reduce((total, file) => total + file.added, 0),\n\t\tremoved: files.reduce((total, file) => total + file.removed, 0),\n\t};\n}\n\nfunction renderPreviewBox(\n\ttitle: string,\n\tdetails: ApplyPatchToolDetails,\n\tisPartial: boolean,\n\tcwd: string,\n\texpanded: boolean,\n\ttheme: ApplyPatchTheme,\n): Container {\n\tconst component = new Container();\n\tif (!details.preview) return component;\n\tconst bgName = isPartial ? \"toolPendingBg\" : \"toolSuccessBg\";\n\tconst progress = details.progress;\n\tconst renderedTitle = progress ? `Applying patch (${progress.applied + progress.failed}/${progress.total})` : title;\n\tconst box = new Box(1, 1, (text: string) => theme.bg(bgName, text));\n\tbox.addChild(new Text(theme.fg(\"toolTitle\", theme.bold(renderedTitle)), 0, 0));\n\tbox.addChild(new Spacer(1));\n\tbox.addChild(new Text(renderPatchPreview(details.preview, cwd, theme, expanded), 0, 0));\n\tcomponent.addChild(box);\n\treturn component;\n}\n\nfunction renderTextResult(\n\tresult: AgentToolResult<ApplyPatchToolDetails | undefined>,\n\ttheme: ApplyPatchTheme,\n): Container {\n\tconst component = new Container();\n\tconst text = resultText(result);\n\tif (text) component.addChild(new Text(theme.fg(\"toolOutput\", text), 0, 0));\n\treturn component;\n}\n\nfunction resultText(result: AgentToolResult<ApplyPatchToolDetails | undefined>): string {\n\treturn result.content\n\t\t.filter((block) => block.type === \"text\")\n\t\t.map((block) => block.text)\n\t\t.filter((value) => typeof value === \"string\" && value.length > 0)\n\t\t.join(\"\\n\");\n}\n\nfunction renderFailureBox(\n\tresult: AgentToolResult<ApplyPatchToolDetails>,\n\tcwd: string,\n\texpanded: boolean,\n\ttheme: ApplyPatchTheme,\n): Container {\n\tconst patchResult = result.details?.result;\n\tif (!patchResult) return renderTextResult(result, theme);\n\tconst component = new Container();\n\tconst appliedCount = patchResult.appliedFiles.length;\n\tconst title = appliedCount > 0 ? \"Patch partially failed\" : \"Patch failed\";\n\tconst box = new Box(1, 1, (text: string) => theme.bg(\"toolErrorBg\", text));\n\tbox.addChild(new Text(theme.fg(\"toolTitle\", theme.bold(title)), 0, 0));\n\tif (result.details.preview) {\n\t\tbox.addChild(new Spacer(1));\n\t\tbox.addChild(new Text(renderPatchPreview(result.details.preview, cwd, theme, expanded), 0, 0));\n\t}\n\tconst text = resultText(result);\n\tif (text) {\n\t\tbox.addChild(new Spacer(1));\n\t\tbox.addChild(new Text(theme.fg(\"toolOutput\", text), 0, 0));\n\t}\n\tcomponent.addChild(box);\n\treturn component;\n}\n\nexport function createApplyPatchTool(variant: \"freeform\" | \"json\" = \"freeform\"): ApplyPatchToolDefinition {\n\tconst tool = defineTool<typeof APPLY_PATCH_PARAMS, ApplyPatchToolDetails | undefined, ApplyPatchRenderState>({\n\t\tname: \"apply_patch\",\n\t\tlabel: \"ApplyPatch\",\n\t\tdescription: variant === \"json\" ? APPLY_PATCH_JSON_DESCRIPTION : APPLY_PATCH_FREEFORM_DESCRIPTION,\n\t\tparameters: APPLY_PATCH_PARAMS,\n\t\tprepareArguments: normalizeApplyPatchArguments,\n\t\tpromptSnippet: \"Apply Codex-format file patches with apply_patch\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use apply_patch for file edits instead of mutating files through bash, Python scripts, heredocs, or shell redirection.\",\n\t\t\t\"After apply_patch succeeds, do not re-read the edited files just to confirm the patch applied.\",\n\t\t],\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\tparams,\n\t\t\t_signal,\n\t\t\tonUpdate,\n\t\t\tctx,\n\t\t): Promise<AgentToolResult<ApplyPatchToolDetails | undefined>> {\n\t\t\tconst normalizedParams = normalizeApplyPatchArguments(params);\n\t\t\tif (!normalizedParams.input) throw new Error(\"input is required\");\n\t\t\tlet totalOperations = 0;\n\t\t\ttry {\n\t\t\t\ttotalOperations = parsePatch(normalizedParams.input).length;\n\t\t\t} catch {\n\t\t\t\t// createPendingPatchUpdate keeps incomplete or invalid patch text renderable.\n\t\t\t}\n\t\t\tconst initialProgress = totalOperations > 0 ? { applied: 0, failed: 0, total: totalOperations } : undefined;\n\t\t\tconst pendingUpdate = await createPendingPatchUpdate(ctx.cwd, normalizedParams.input, initialProgress);\n\t\t\tonUpdate?.({ content: [{ type: \"text\", text: pendingUpdate.text }], details: pendingUpdate.details });\n\t\t\tconst preview = pendingUpdate.details?.preview;\n\t\t\tconst result = await applyPatchDetailed(ctx.cwd, normalizedParams.input, async (progress) => {\n\t\t\t\tconst progressUpdate = await createPendingPatchUpdate(ctx.cwd, normalizedParams.input, progress, preview);\n\t\t\t\tonUpdate?.({ content: [{ type: \"text\", text: progressUpdate.text }], details: progressUpdate.details });\n\t\t\t});\n\t\t\tconst resultPreview = appliedPreview(result);\n\t\t\tconst persistedResult = compactApplyPatchResult(result);\n\t\t\tif (result.failures.length > 0) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: buildPartialFailureText(result) }],\n\t\t\t\t\tdetails: resultPreview\n\t\t\t\t\t\t? { preview: resultPreview, result: persistedResult }\n\t\t\t\t\t\t: { result: persistedResult },\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: result.summaries.join(\"\\n\") }],\n\t\t\t\tdetails: resultPreview ? { preview: resultPreview, result: persistedResult } : { result: persistedResult },\n\t\t\t};\n\t\t},\n\t\trenderCall(args, theme, context: ToolRenderContext<ApplyPatchRenderState, { input: string }>) {\n\t\t\tif (!context.executionStarted) {\n\t\t\t\tconst streaming = renderStreamingPatchCall(normalizeApplyPatchArguments(args), theme, context.state);\n\t\t\t\tif (streaming) return streaming;\n\t\t\t}\n\t\t\tif (!context.argsComplete) return new Text(theme.fg(\"toolTitle\", theme.bold(\"apply_patch: Patching\")), 0, 0);\n\t\t\tconst normalizedArgs = normalizeApplyPatchArguments(args);\n\t\t\tconst renderState = getApplyPatchRenderState(context.toolCallId, context.cwd, normalizedArgs.input);\n\t\t\tconst text = renderState.callText?.length ? `apply_patch: ${renderState.callText}` : \"apply_patch\";\n\t\t\treturn new Text(theme.fg(\"toolTitle\", theme.bold(text)), 0, 0);\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tif (context.isError && result.details?.result?.failures.length) {\n\t\t\t\treturn renderFailureBox(result as AgentToolResult<ApplyPatchToolDetails>, context.cwd, true, theme);\n\t\t\t}\n\t\t\tif (result.details?.preview) {\n\t\t\t\tconst expanded = true;\n\t\t\t\treturn renderPreviewBox(\n\t\t\t\t\toptions.isPartial ? \"Applying patch\" : \"Applied patch\",\n\t\t\t\t\tresult.details,\n\t\t\t\t\toptions.isPartial,\n\t\t\t\t\tcontext.cwd,\n\t\t\t\t\texpanded,\n\t\t\t\t\ttheme,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (result.details?.result) {\n\t\t\t\tconst component = new Container();\n\t\t\t\tconst box = new Box(1, 1, (text: string) =>\n\t\t\t\t\ttheme.bg(options.isPartial ? \"toolPendingBg\" : \"toolSuccessBg\", text),\n\t\t\t\t);\n\t\t\t\tbox.addChild(new Text(theme.fg(\"toolTitle\", theme.bold(\"Applying patch\")), 0, 0));\n\t\t\t\tbox.addChild(new Spacer(1));\n\t\t\t\tif (result.details.preview) {\n\t\t\t\t\tconst expanded = options.isPartial ? true : (options.expanded ?? true);\n\t\t\t\t\tbox.addChild(new Text(renderPatchPreview(result.details.preview, context.cwd, theme, expanded), 0, 0));\n\t\t\t\t}\n\t\t\t\tcomponent.addChild(box);\n\t\t\t\treturn component;\n\t\t\t}\n\t\t\treturn renderTextResult(result, theme);\n\t\t},\n\t});\n\n\tif (variant === \"json\") return tool;\n\treturn Object.assign(tool, {\n\t\tfreeform: { type: \"grammar\", syntax: \"lark\", definition: APPLY_PATCH_LARK_GRAMMAR } satisfies FreeformToolFormat,\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detectors.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/loop-guard/detectors.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"detectors.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/loop-guard/detectors.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAWnD,MAAM,MAAM,kBAAkB,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAC/G;IACA,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;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