@code-yeongyu/senpi 2026.8.3 → 2026.8.4
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 +68 -0
- package/README.md +9 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/client/remote-session.d.ts +2 -2
- package/dist/client/transcript.d.ts +1 -1
- package/dist/core/agent-session.d.ts +6 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +174 -39
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts +2 -1
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.js +126 -26
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.js +12 -7
- package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/per-turn-cap.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/per-turn-cap.js +4 -1
- package/dist/core/extensions/builtin/compaction/per-turn-cap.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/retained-message-safety.d.ts +4 -0
- package/dist/core/extensions/builtin/compaction/retained-message-safety.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/retained-message-safety.js +155 -0
- package/dist/core/extensions/builtin/compaction/retained-message-safety.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/speculative.js +21 -13
- package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
- package/dist/core/extensions/builtin/goal/cache-warm-renderer.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/cache-warm-renderer.js +9 -14
- package/dist/core/extensions/builtin/goal/cache-warm-renderer.js.map +1 -1
- package/dist/core/extensions/builtin/goal/continuation-recovery.d.ts +1 -0
- package/dist/core/extensions/builtin/goal/continuation-recovery.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/continuation-recovery.js +7 -0
- package/dist/core/extensions/builtin/goal/continuation-recovery.js.map +1 -1
- package/dist/core/extensions/builtin/goal/continuation.d.ts +2 -1
- package/dist/core/extensions/builtin/goal/continuation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/continuation.js +2 -1
- package/dist/core/extensions/builtin/goal/continuation.js.map +1 -1
- package/dist/core/extensions/builtin/goal/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/index.js +26 -11
- package/dist/core/extensions/builtin/goal/index.js.map +1 -1
- package/dist/core/extensions/builtin/goal/lifecycle-helpers.d.ts +7 -1
- package/dist/core/extensions/builtin/goal/lifecycle-helpers.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/lifecycle-helpers.js +14 -2
- package/dist/core/extensions/builtin/goal/lifecycle-helpers.js.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts +3 -2
- package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.js +89 -46
- package/dist/core/extensions/builtin/goal/monitor-continuation.js.map +1 -1
- package/dist/core/extensions/builtin/goal/wait-progress.d.ts +11 -0
- package/dist/core/extensions/builtin/goal/wait-progress.d.ts.map +1 -0
- package/dist/core/extensions/builtin/goal/wait-progress.js +30 -0
- package/dist/core/extensions/builtin/goal/wait-progress.js.map +1 -0
- package/dist/core/extensions/builtin/goal/wait-ticker.d.ts +38 -0
- package/dist/core/extensions/builtin/goal/wait-ticker.d.ts.map +1 -0
- package/dist/core/extensions/builtin/goal/wait-ticker.js +71 -0
- package/dist/core/extensions/builtin/goal/wait-ticker.js.map +1 -0
- package/dist/core/extensions/builtin/gpt-apply-patch/extension.d.ts.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/extension.js +14 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/extension.js.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/types.d.ts +1 -0
- package/dist/core/extensions/builtin/gpt-apply-patch/types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/types.js.map +1 -1
- package/dist/core/extensions/builtin/loop-guard/renderer.d.ts.map +1 -1
- package/dist/core/extensions/builtin/loop-guard/renderer.js +4 -12
- package/dist/core/extensions/builtin/loop-guard/renderer.js.map +1 -1
- package/dist/core/extensions/builtin/rule-activation/index.d.ts +6 -0
- package/dist/core/extensions/builtin/rule-activation/index.d.ts.map +1 -0
- package/dist/core/extensions/builtin/rule-activation/index.js +10 -0
- package/dist/core/extensions/builtin/rule-activation/index.js.map +1 -0
- package/dist/core/extensions/builtin/rule-activation/renderer.d.ts +3 -0
- package/dist/core/extensions/builtin/rule-activation/renderer.d.ts.map +1 -0
- package/dist/core/extensions/builtin/rule-activation/renderer.js +37 -0
- package/dist/core/extensions/builtin/rule-activation/renderer.js.map +1 -0
- package/dist/core/extensions/builtin/rule-activation/types.d.ts +15 -0
- package/dist/core/extensions/builtin/rule-activation/types.d.ts.map +1 -0
- package/dist/core/extensions/builtin/rule-activation/types.js +45 -0
- package/dist/core/extensions/builtin/rule-activation/types.js.map +1 -0
- package/dist/core/extensions/builtin/rules/config.d.ts +3 -0
- package/dist/core/extensions/builtin/rules/config.d.ts.map +1 -0
- package/dist/core/extensions/builtin/rules/config.js +24 -0
- package/dist/core/extensions/builtin/rules/config.js.map +1 -0
- package/dist/core/extensions/builtin/rules/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/rules/index.js +14 -4
- package/dist/core/extensions/builtin/rules/index.js.map +1 -1
- package/dist/core/extensions/builtin/rules/rules/formatter.d.ts.map +1 -1
- package/dist/core/extensions/builtin/rules/rules/formatter.js +21 -5
- package/dist/core/extensions/builtin/rules/rules/formatter.js.map +1 -1
- package/dist/core/extensions/builtin/rules/rules/types.d.ts +1 -1
- package/dist/core/extensions/builtin/rules/rules/types.js.map +1 -1
- package/dist/core/extensions/builtin/service-tier.d.ts.map +1 -1
- package/dist/core/extensions/builtin/service-tier.js +2 -3
- package/dist/core/extensions/builtin/service-tier.js.map +1 -1
- package/dist/core/extensions/builtin/ttsr/detectors/repetitive-turns.d.ts +22 -0
- package/dist/core/extensions/builtin/ttsr/detectors/repetitive-turns.d.ts.map +1 -0
- package/dist/core/extensions/builtin/ttsr/detectors/repetitive-turns.js +93 -0
- package/dist/core/extensions/builtin/ttsr/detectors/repetitive-turns.js.map +1 -0
- package/dist/core/extensions/builtin/ttsr/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ttsr/index.js +60 -21
- package/dist/core/extensions/builtin/ttsr/index.js.map +1 -1
- package/dist/core/extensions/builtin/ttsr/prompts.d.ts +1 -0
- package/dist/core/extensions/builtin/ttsr/prompts.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ttsr/prompts.js +5 -0
- package/dist/core/extensions/builtin/ttsr/prompts.js.map +1 -1
- package/dist/core/extensions/builtin/ttsr/repetitive-turns-lane.d.ts +23 -0
- package/dist/core/extensions/builtin/ttsr/repetitive-turns-lane.d.ts.map +1 -0
- package/dist/core/extensions/builtin/ttsr/repetitive-turns-lane.js +101 -0
- package/dist/core/extensions/builtin/ttsr/repetitive-turns-lane.js.map +1 -0
- package/dist/core/extensions/builtin/ttsr/stream-remediation.d.ts +15 -0
- package/dist/core/extensions/builtin/ttsr/stream-remediation.d.ts.map +1 -0
- package/dist/core/extensions/builtin/ttsr/stream-remediation.js +22 -0
- package/dist/core/extensions/builtin/ttsr/stream-remediation.js.map +1 -0
- package/dist/core/extensions/builtin/ttsr/types.d.ts +1 -1
- package/dist/core/extensions/builtin/ttsr/types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ttsr/types.js.map +1 -1
- package/dist/core/extensions/notice/adapters.d.ts +15 -0
- package/dist/core/extensions/notice/adapters.d.ts.map +1 -0
- package/dist/core/extensions/notice/adapters.js +22 -0
- package/dist/core/extensions/notice/adapters.js.map +1 -0
- package/dist/core/extensions/notice/box.d.ts +8 -0
- package/dist/core/extensions/notice/box.d.ts.map +1 -0
- package/dist/core/extensions/notice/box.js +17 -0
- package/dist/core/extensions/notice/box.js.map +1 -0
- package/dist/core/extensions/notice/index.d.ts +4 -0
- package/dist/core/extensions/notice/index.d.ts.map +1 -0
- package/dist/core/extensions/notice/index.js +3 -0
- package/dist/core/extensions/notice/index.js.map +1 -0
- package/dist/core/extensions/notice/spec.d.ts +23 -0
- package/dist/core/extensions/notice/spec.d.ts.map +1 -0
- package/dist/core/extensions/notice/spec.js +2 -0
- package/dist/core/extensions/notice/spec.js.map +1 -0
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -0
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +2 -2
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +8 -3
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +1 -0
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/retry-fallback/settings.d.ts.map +1 -1
- package/dist/core/retry-fallback/settings.js +16 -1
- package/dist/core/retry-fallback/settings.js.map +1 -1
- package/dist/core/retry-fallback/validate.d.ts.map +1 -1
- package/dist/core/retry-fallback/validate.js +15 -2
- package/dist/core/retry-fallback/validate.js.map +1 -1
- package/dist/core/session-log.js +1 -1
- package/dist/core/session-log.js.map +1 -1
- package/dist/core/settings-manager.d.ts +7 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +13 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +5 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +22 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +2 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +42 -7
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-stderr-guard.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-stderr-guard.js +37 -0
- package/dist/modes/interactive/interactive-stderr-guard.js.map +1 -1
- package/docs/providers.md +19 -0
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +40 -0
- package/node_modules/@code-yeongyu/senpi-codemode/README.md +13 -3
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
- package/node_modules/@code-yeongyu/senpi-codemode/src/extension/eval-status.ts +1 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +6 -6
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-runtime.ts +4 -4
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-manager.ts +2 -2
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-snapshot.ts +2 -2
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-request.ts +20 -2
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +17 -2
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/render.ts +18 -7
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/types.ts +19 -5
- package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/node_modules/@earendil-works/pi-ai/README.md +3 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.js +3 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.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/alibaba-token-plan.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/opencode-go.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/ollama.d.ts +9 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/ollama.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/ollama.js +142 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/ollama.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +1 -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/package.json +1 -1
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +5 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/slash-command-autocomplete.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/slash-command-autocomplete.js +36 -8
- package/node_modules/@earendil-works/pi-tui/dist/slash-command-autocomplete.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +2 -0
- package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.js +49 -33
- package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +8 -13
- package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/client.d.ts +1 -1
- package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/client.js +1 -1
- package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/connection.d.ts +1 -1
- package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/connection.js +1 -1
- package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/errors.d.ts +1 -1
- package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/session-handle.d.ts +1 -1
- package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/state.d.ts +1 -1
- package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/types.d.ts +1 -1
- package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/unix.js +1 -1
- package/node_modules/@earendil-works/pi-client/CHANGELOG.md +0 -7
- package/node_modules/@earendil-works/pi-client/README.md +0 -64
- package/node_modules/@earendil-works/pi-client/package.json +0 -56
- package/node_modules/@earendil-works/pi-protocol/README.md +0 -68
- package/node_modules/@earendil-works/pi-protocol/package.json +0 -48
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/client.d.ts.map +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/client.js.map +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/connection.d.ts.map +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/connection.js.map +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/errors.d.ts.map +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/errors.js +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/errors.js.map +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/index.d.ts +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/index.d.ts.map +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/index.js +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/index.js.map +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/promise.d.ts +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/promise.d.ts.map +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/promise.js +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/promise.js.map +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/session-handle.d.ts.map +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/session-handle.js +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/session-handle.js.map +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/state.d.ts.map +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/state.js +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/state.js.map +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/transport.d.ts +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/transport.d.ts.map +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/transport.js +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/transport.js.map +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/types.d.ts.map +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/types.js +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/types.js.map +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/unix.d.ts +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/unix.d.ts.map +0 -0
- /package/{node_modules/@earendil-works/pi-client/dist → vendor/pi-client}/unix.js.map +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/cbor/decoder.d.ts +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/cbor/decoder.d.ts.map +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/cbor/decoder.js +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/cbor/decoder.js.map +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/cbor/encoder.d.ts +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/cbor/encoder.d.ts.map +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/cbor/encoder.js +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/cbor/encoder.js.map +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/cbor/index.d.ts +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/cbor/index.d.ts.map +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/cbor/index.js +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/cbor/index.js.map +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/cbor/options.d.ts +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/cbor/options.d.ts.map +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/cbor/options.js +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/cbor/options.js.map +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/codec.d.ts +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/codec.d.ts.map +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/codec.js +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/codec.js.map +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/framing.d.ts +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/framing.d.ts.map +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/framing.js +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/framing.js.map +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/index.d.ts +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/index.d.ts.map +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/index.js +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/index.js.map +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/schemas.d.ts +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/schemas.d.ts.map +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/schemas.js +0 -0
- /package/{node_modules/@earendil-works/pi-protocol/dist → vendor/pi-protocol}/schemas.js.map +0 -0
|
@@ -207,6 +207,7 @@ export class AgentSession {
|
|
|
207
207
|
/** Recovery-only order across both native queue modes and TUI compaction ownership. */
|
|
208
208
|
this._queuedInputOrder = [];
|
|
209
209
|
this._nextQueuedInputOrder = 0;
|
|
210
|
+
this._supersededCompactionLogAttemptIds = new Set();
|
|
210
211
|
/** Messages queued to be included with the next user prompt as context ("asides"). */
|
|
211
212
|
this._pendingNextTurnMessages = [];
|
|
212
213
|
// Queues held while the first post-compaction response is classified. Agent
|
|
@@ -313,7 +314,6 @@ export class AgentSession {
|
|
|
313
314
|
this.agent = config.agent;
|
|
314
315
|
this.sessionManager = config.sessionManager;
|
|
315
316
|
this.settingsManager = config.settingsManager;
|
|
316
|
-
this.agent.abortServerSideFallback = this.settingsManager.getAbortServerSideFallback();
|
|
317
317
|
const noModelFallback = config.resourceLoader.getExtensions().runtime.flagValues.get("no-model-fallback") === true ||
|
|
318
318
|
process.env.SENPI_NO_FALLBACK === "1";
|
|
319
319
|
if (noModelFallback) {
|
|
@@ -334,8 +334,11 @@ export class AgentSession {
|
|
|
334
334
|
const fallbackLogger = createFallbackLogger(this._agentDir);
|
|
335
335
|
this._sessionLogger = createSessionLogger(this._agentDir);
|
|
336
336
|
this._fallbackValidationWarnings = validateFallbackChains(this.settingsManager.getRawFallbackChains(), this._modelRegistry);
|
|
337
|
+
// `source` names the scope that supplied the chains so a single log line
|
|
338
|
+
// points at the file to open; "default" means no scope configured any.
|
|
339
|
+
const fallbackChainsSource = this.settingsManager.getFallbackChainsScope() ?? "default";
|
|
337
340
|
for (const warning of this._fallbackValidationWarnings) {
|
|
338
|
-
fallbackLogger.warn("validation_warning", { warning });
|
|
341
|
+
fallbackLogger.warn("validation_warning", { warning, source: fallbackChainsSource });
|
|
339
342
|
}
|
|
340
343
|
this._selectorCooldowns = new SelectorCooldowns(config.fallbackNow ?? (() => Date.now()));
|
|
341
344
|
this._fallbackNow = config.fallbackNow ?? (() => Date.now());
|
|
@@ -569,8 +572,11 @@ export class AgentSession {
|
|
|
569
572
|
return await this._enforceCompactionBeforeProvider(turn.message, true, "threshold");
|
|
570
573
|
}
|
|
571
574
|
catch (error) {
|
|
572
|
-
if (error instanceof RequiredCompactionError
|
|
573
|
-
this.
|
|
575
|
+
if (error instanceof RequiredCompactionError) {
|
|
576
|
+
this._requiredCompactionTurnError = error;
|
|
577
|
+
if (this.agent.hasQueuedMessages()) {
|
|
578
|
+
this._requiredCompactionAdmissionError = error;
|
|
579
|
+
}
|
|
574
580
|
}
|
|
575
581
|
throw error;
|
|
576
582
|
}
|
|
@@ -633,18 +639,76 @@ export class AgentSession {
|
|
|
633
639
|
/** Mirror stuck-prone lifecycle transitions into logs/session.log (content-free). */
|
|
634
640
|
_logSessionEvent(event) {
|
|
635
641
|
if (event.type === "compaction_start") {
|
|
636
|
-
|
|
642
|
+
const previousAttempt = this._activeCompactionLogAttempt;
|
|
643
|
+
if (previousAttempt) {
|
|
644
|
+
const tokensAfter = this._estimateCompactionLogTokens("persisted");
|
|
645
|
+
this._sessionLogger.info("compaction_decision", {
|
|
646
|
+
attemptId: previousAttempt.id,
|
|
647
|
+
reason: previousAttempt.reason,
|
|
648
|
+
mode: previousAttempt.reason === "manual" ? "manual" : "auto",
|
|
649
|
+
action: "compact",
|
|
650
|
+
disposition: "superseded",
|
|
651
|
+
accepted: false,
|
|
652
|
+
skipped: true,
|
|
653
|
+
aborted: true,
|
|
654
|
+
willRetry: false,
|
|
655
|
+
tokensBefore: previousAttempt.tokensBefore,
|
|
656
|
+
tokensAfter,
|
|
657
|
+
});
|
|
658
|
+
this._supersededCompactionLogAttemptIds.add(previousAttempt.id);
|
|
659
|
+
}
|
|
660
|
+
const attempt = {
|
|
661
|
+
id: event.requestId ?? randomUUID(),
|
|
662
|
+
reason: event.reason,
|
|
663
|
+
tokensBefore: this._estimateCompactionLogTokens("persisted"),
|
|
664
|
+
};
|
|
665
|
+
this._activeCompactionLogAttempt = attempt;
|
|
666
|
+
this._sessionLogger.info("compaction_start", {
|
|
667
|
+
attemptId: attempt.id,
|
|
668
|
+
reason: event.reason,
|
|
669
|
+
mode: event.reason === "manual" ? "manual" : "auto",
|
|
670
|
+
action: "compact",
|
|
671
|
+
tokensBefore: attempt.tokensBefore,
|
|
672
|
+
});
|
|
637
673
|
return;
|
|
638
674
|
}
|
|
639
675
|
if (event.type === "compaction_end") {
|
|
676
|
+
if (event.requestId && this._supersededCompactionLogAttemptIds.delete(event.requestId))
|
|
677
|
+
return;
|
|
678
|
+
const activeAttempt = this._activeCompactionLogAttempt;
|
|
679
|
+
const attempt = event.requestId !== undefined && activeAttempt?.id === event.requestId ? activeAttempt : undefined;
|
|
680
|
+
const accepted = event.accepted ?? event.result !== undefined;
|
|
681
|
+
const rejected = event.rejectionCause !== undefined;
|
|
682
|
+
const skipped = !accepted && (attempt === undefined || (!rejected && !event.aborted && !event.errorMessage));
|
|
683
|
+
const disposition = accepted
|
|
684
|
+
? "committed"
|
|
685
|
+
: attempt === undefined
|
|
686
|
+
? "skipped"
|
|
687
|
+
: rejected
|
|
688
|
+
? "rejected"
|
|
689
|
+
: event.aborted
|
|
690
|
+
? "aborted"
|
|
691
|
+
: event.errorMessage
|
|
692
|
+
? "failed"
|
|
693
|
+
: "skipped";
|
|
694
|
+
const tokensAfter = this._estimateCompactionLogTokens(accepted ? "active" : "persisted");
|
|
640
695
|
this._sessionLogger.info("compaction_decision", {
|
|
696
|
+
attemptId: attempt?.id ?? event.requestId,
|
|
641
697
|
reason: event.reason,
|
|
642
|
-
|
|
698
|
+
mode: event.reason === "manual" ? "manual" : "auto",
|
|
699
|
+
action: accepted || attempt ? "compact" : "none",
|
|
700
|
+
disposition,
|
|
701
|
+
accepted,
|
|
702
|
+
skipped,
|
|
643
703
|
aborted: event.aborted,
|
|
644
704
|
willRetry: event.willRetry,
|
|
645
705
|
rejectionCause: event.rejectionCause,
|
|
646
706
|
error: event.errorMessage,
|
|
707
|
+
tokensBefore: attempt?.tokensBefore ?? tokensAfter,
|
|
708
|
+
tokensAfter,
|
|
647
709
|
});
|
|
710
|
+
if (attempt)
|
|
711
|
+
this._activeCompactionLogAttempt = undefined;
|
|
648
712
|
return;
|
|
649
713
|
}
|
|
650
714
|
if (event.type === "message_end" && event.message.role === "assistant") {
|
|
@@ -659,6 +723,15 @@ export class AgentSession {
|
|
|
659
723
|
this._sessionLogger.warn("provider_error", { kind, error: message.errorMessage });
|
|
660
724
|
}
|
|
661
725
|
}
|
|
726
|
+
_estimateCompactionLogTokens(source) {
|
|
727
|
+
try {
|
|
728
|
+
const messages = source === "active" ? this.agent.state.messages : this.sessionManager.buildSessionContext().messages;
|
|
729
|
+
return estimateMessagesTokens(filterContextExcludedMessages(messages));
|
|
730
|
+
}
|
|
731
|
+
catch {
|
|
732
|
+
return undefined;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
662
735
|
_emitQueueUpdate() {
|
|
663
736
|
this._emit({
|
|
664
737
|
type: "queue_update",
|
|
@@ -737,6 +810,8 @@ export class AgentSession {
|
|
|
737
810
|
async _promptAgent(messages) {
|
|
738
811
|
this._isAgentRunActive = true;
|
|
739
812
|
this._requiredCompactionAdmissionError = undefined;
|
|
813
|
+
this.agent.abortServerSideFallback =
|
|
814
|
+
this.settingsManager.getAbortServerSideFallback() && this._retryFallback.hasConfiguredChain();
|
|
740
815
|
try {
|
|
741
816
|
await this.agent.prompt(messages);
|
|
742
817
|
// AgentSession's subscriber intentionally queues event work instead of
|
|
@@ -864,14 +939,17 @@ export class AgentSession {
|
|
|
864
939
|
const messages = filterContextExcludedMessages(this.agent.state.messages);
|
|
865
940
|
const estimate = estimateContextTokens(messages);
|
|
866
941
|
if (estimate.lastUsageIndex === null) {
|
|
867
|
-
|
|
942
|
+
if (!this._isRequiredCompactionError(message))
|
|
943
|
+
return undefined;
|
|
868
944
|
}
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
945
|
+
else {
|
|
946
|
+
const compactionEntry = getLatestCompactionEntry(this.sessionManager.getBranch());
|
|
947
|
+
const usageMessage = messages[estimate.lastUsageIndex];
|
|
948
|
+
if (compactionEntry &&
|
|
949
|
+
usageMessage?.role === "assistant" &&
|
|
950
|
+
this._isAssistantFromBeforeLatestCompaction(usageMessage)) {
|
|
951
|
+
return undefined;
|
|
952
|
+
}
|
|
875
953
|
}
|
|
876
954
|
contextTokens = estimate.tokens;
|
|
877
955
|
}
|
|
@@ -926,14 +1004,18 @@ export class AgentSession {
|
|
|
926
1004
|
return true;
|
|
927
1005
|
}
|
|
928
1006
|
_willRetryAfterAgentEnd(messages) {
|
|
929
|
-
const settings = this.settingsManager.getRetrySettings();
|
|
930
|
-
if (!settings.enabled) {
|
|
931
|
-
return false;
|
|
932
|
-
}
|
|
933
1007
|
const lastAssistant = this._lastAssistantMessage ?? this._findLastAssistantInMessages(messages);
|
|
934
1008
|
if (!lastAssistant) {
|
|
935
1009
|
return false;
|
|
936
1010
|
}
|
|
1011
|
+
if (this._isRequiredCompactionError(lastAssistant) &&
|
|
1012
|
+
this._getRequiredAutoCompactionReason(lastAssistant) !== undefined) {
|
|
1013
|
+
return true;
|
|
1014
|
+
}
|
|
1015
|
+
const settings = this.settingsManager.getRetrySettings();
|
|
1016
|
+
if (!settings.enabled) {
|
|
1017
|
+
return false;
|
|
1018
|
+
}
|
|
937
1019
|
const retryableError = this._isRetryableError(lastAssistant);
|
|
938
1020
|
if (!retryableError && this._isHardErrorFallbackEligible(lastAssistant)) {
|
|
939
1021
|
return true;
|
|
@@ -957,7 +1039,15 @@ export class AgentSession {
|
|
|
957
1039
|
}
|
|
958
1040
|
return this._retryFallback.canTryFallback();
|
|
959
1041
|
}
|
|
1042
|
+
_isRequiredCompactionError(message) {
|
|
1043
|
+
return (this._requiredCompactionTurnError !== undefined &&
|
|
1044
|
+
message.stopReason === "error" &&
|
|
1045
|
+
message.errorMessage === this._requiredCompactionTurnError.message);
|
|
1046
|
+
}
|
|
960
1047
|
async _processAgentEvent(event, signal) {
|
|
1048
|
+
if (event.type === "agent_start") {
|
|
1049
|
+
this._requiredCompactionTurnError = undefined;
|
|
1050
|
+
}
|
|
961
1051
|
// When a user message starts, check if it's from either queue and remove it BEFORE emitting
|
|
962
1052
|
// This ensures the UI sees the updated queue state
|
|
963
1053
|
if (event.type === "message_start" && event.message.role === "user") {
|
|
@@ -1059,6 +1149,7 @@ export class AgentSession {
|
|
|
1059
1149
|
this._lastAssistantMessage = undefined;
|
|
1060
1150
|
this._skipNextPostRetryCompactionCheck = false;
|
|
1061
1151
|
const requiredAutoCompaction = this._getRequiredAutoCompactionReason(msg);
|
|
1152
|
+
const retryAfterRequiredCompaction = requiredAutoCompaction !== undefined && this._isRequiredCompactionError(msg);
|
|
1062
1153
|
// Retry transient failures normally and eligible hard errors only through a fallback.
|
|
1063
1154
|
const retryableError = this._isRetryableError(msg);
|
|
1064
1155
|
const hardErrorFallbackEligible = this._isHardErrorFallbackEligible(msg);
|
|
@@ -1086,11 +1177,20 @@ export class AgentSession {
|
|
|
1086
1177
|
retryContinuationBlocked ||= retryOutcome === "blocked";
|
|
1087
1178
|
if (!retryContinuationBlocked) {
|
|
1088
1179
|
if (compactedBeforeRetry && this.agent.hasQueuedMessages()) {
|
|
1180
|
+
// Accepted recovery supersedes the stored admission rejection: the
|
|
1181
|
+
// queued continuation is about to run, so the originating prompt must
|
|
1182
|
+
// not observe the stale RequiredCompactionError.
|
|
1183
|
+
this._requiredCompactionAdmissionError = undefined;
|
|
1089
1184
|
this._scheduleContinuationAfterCurrentEvent();
|
|
1090
1185
|
launchedContinuation = true;
|
|
1091
1186
|
}
|
|
1092
1187
|
else {
|
|
1093
|
-
launchedContinuation = await this._checkCompaction(msg);
|
|
1188
|
+
launchedContinuation = await this._checkCompaction(msg, true, undefined, retryAfterRequiredCompaction);
|
|
1189
|
+
if (launchedContinuation && this.agent.hasQueuedMessages()) {
|
|
1190
|
+
// Same supersession on the post-check path: an accepted recovery
|
|
1191
|
+
// compaction owns the continuation now.
|
|
1192
|
+
this._requiredCompactionAdmissionError = undefined;
|
|
1193
|
+
}
|
|
1094
1194
|
allowsPostCompactionUsageExemptContinuation = this._postCompactionUsageExemptAssistants.has(msg);
|
|
1095
1195
|
if (allowsPostCompactionUsageExemptContinuation) {
|
|
1096
1196
|
this._flushPostCompactionDeferredMessages();
|
|
@@ -1113,6 +1213,9 @@ export class AgentSession {
|
|
|
1113
1213
|
!retryContinuationBlocked &&
|
|
1114
1214
|
(allowsQueuedContinuation || allowsPostCompactionUsageExemptContinuation) &&
|
|
1115
1215
|
this.agent.hasQueuedMessages()) {
|
|
1216
|
+
// A scheduled continuation owns the queue now; the stored admission
|
|
1217
|
+
// rejection from a superseded required compaction must not surface.
|
|
1218
|
+
this._requiredCompactionAdmissionError = undefined;
|
|
1116
1219
|
this._scheduleContinuationAfterCurrentEvent();
|
|
1117
1220
|
launchedContinuation = true;
|
|
1118
1221
|
}
|
|
@@ -2647,6 +2750,8 @@ export class AgentSession {
|
|
|
2647
2750
|
}
|
|
2648
2751
|
const thinkingLevel = this._getThinkingLevelForModelSwitch(opts.ephemeralThinkingLevel);
|
|
2649
2752
|
this.agent.state.model = model;
|
|
2753
|
+
this.agent.abortServerSideFallback =
|
|
2754
|
+
this.settingsManager.getAbortServerSideFallback() && this._retryFallback.hasConfiguredChain();
|
|
2650
2755
|
if (opts.appendSessionEntry) {
|
|
2651
2756
|
this.sessionManager.appendModelChange(model.provider, model.id, opts.entryReason, previousModel?.provider, previousModel?.id);
|
|
2652
2757
|
}
|
|
@@ -2966,6 +3071,7 @@ export class AgentSession {
|
|
|
2966
3071
|
async compact(customInstructions) {
|
|
2967
3072
|
const admission = this._claimPendingCompactionAdmission();
|
|
2968
3073
|
const controller = admission.controller;
|
|
3074
|
+
const requestId = randomUUID();
|
|
2969
3075
|
let outcome = "failed";
|
|
2970
3076
|
let disconnected = false;
|
|
2971
3077
|
try {
|
|
@@ -2975,11 +3081,12 @@ export class AgentSession {
|
|
|
2975
3081
|
await this._abortActiveAgentAndRetry("system");
|
|
2976
3082
|
this._disconnectFromAgent();
|
|
2977
3083
|
disconnected = true;
|
|
2978
|
-
this._emit({ type: "compaction_start", reason: "manual" });
|
|
3084
|
+
this._emit({ type: "compaction_start", reason: "manual", requestId });
|
|
2979
3085
|
const execution = await this._executeCompaction({
|
|
2980
3086
|
controller,
|
|
2981
3087
|
owner: "compaction",
|
|
2982
3088
|
reason: "manual",
|
|
3089
|
+
requestId,
|
|
2983
3090
|
customInstructions,
|
|
2984
3091
|
willRetry: false,
|
|
2985
3092
|
});
|
|
@@ -3005,6 +3112,7 @@ export class AgentSession {
|
|
|
3005
3112
|
result: undefined,
|
|
3006
3113
|
aborted,
|
|
3007
3114
|
willRetry: false,
|
|
3115
|
+
requestId,
|
|
3008
3116
|
errorMessage: aborted ? undefined : `Compaction failed: ${message}`,
|
|
3009
3117
|
});
|
|
3010
3118
|
throw error;
|
|
@@ -3028,9 +3136,13 @@ export class AgentSession {
|
|
|
3028
3136
|
return { applied: false, reason: "stale" };
|
|
3029
3137
|
}
|
|
3030
3138
|
const ownsController = this._compactionAbortController === undefined;
|
|
3139
|
+
const lifecycleState = this._compactionLifecycle.state;
|
|
3140
|
+
const requestId = !ownsController && lifecycleState.status === "running" && lifecycleState.stage === "feedback"
|
|
3141
|
+
? lifecycleState.operationId
|
|
3142
|
+
: randomUUID();
|
|
3031
3143
|
if (ownsController) {
|
|
3032
3144
|
this._claimCompactionController(new AbortController(), "compaction");
|
|
3033
|
-
this._emit({ type: "compaction_start", reason: options.reason });
|
|
3145
|
+
this._emit({ type: "compaction_start", reason: options.reason, requestId });
|
|
3034
3146
|
}
|
|
3035
3147
|
const controller = this._compactionAbortController;
|
|
3036
3148
|
if (!controller)
|
|
@@ -3041,6 +3153,7 @@ export class AgentSession {
|
|
|
3041
3153
|
controller,
|
|
3042
3154
|
owner: "compaction",
|
|
3043
3155
|
reason: options.reason,
|
|
3156
|
+
requestId,
|
|
3044
3157
|
willRetry: false,
|
|
3045
3158
|
precomputed,
|
|
3046
3159
|
});
|
|
@@ -3062,6 +3175,7 @@ export class AgentSession {
|
|
|
3062
3175
|
result: undefined,
|
|
3063
3176
|
aborted,
|
|
3064
3177
|
willRetry: false,
|
|
3178
|
+
requestId,
|
|
3065
3179
|
errorMessage: aborted ? undefined : `Compaction failed: ${message}`,
|
|
3066
3180
|
});
|
|
3067
3181
|
return { applied: false, reason: "rejected" };
|
|
@@ -3076,14 +3190,15 @@ export class AgentSession {
|
|
|
3076
3190
|
const controller = new AbortController();
|
|
3077
3191
|
this._claimCompactionController(controller, "compaction");
|
|
3078
3192
|
const model = this.model;
|
|
3193
|
+
const requestId = randomUUID();
|
|
3079
3194
|
this._compactionLifecycle.begin({
|
|
3080
|
-
operationId:
|
|
3195
|
+
operationId: requestId,
|
|
3081
3196
|
stage: "feedback",
|
|
3082
3197
|
reason,
|
|
3083
3198
|
model: model ? { provider: model.provider, id: model.id } : undefined,
|
|
3084
3199
|
startedRevision: this._messageRevision,
|
|
3085
3200
|
}, controller);
|
|
3086
|
-
this._emit({ type: "compaction_start", reason });
|
|
3201
|
+
this._emit({ type: "compaction_start", reason, requestId });
|
|
3087
3202
|
return controller.signal;
|
|
3088
3203
|
}
|
|
3089
3204
|
_updateExtensionCompactionFeedback(options) {
|
|
@@ -3121,7 +3236,8 @@ export class AgentSession {
|
|
|
3121
3236
|
result: undefined,
|
|
3122
3237
|
aborted,
|
|
3123
3238
|
willRetry: false,
|
|
3124
|
-
|
|
3239
|
+
requestId: operation.operationId,
|
|
3240
|
+
errorMessage: aborted ? undefined : (options.errorMessage ?? "Compaction did not apply"),
|
|
3125
3241
|
});
|
|
3126
3242
|
this._releaseCompactionController(options.signal);
|
|
3127
3243
|
}
|
|
@@ -3136,7 +3252,7 @@ export class AgentSession {
|
|
|
3136
3252
|
if (!this._ownsCompactionController(controller, request.owner)) {
|
|
3137
3253
|
throw new CompactionExecutionError(new CompactionCancelledError(), false, true);
|
|
3138
3254
|
}
|
|
3139
|
-
const requestId = randomUUID();
|
|
3255
|
+
const requestId = request.requestId ?? randomUUID();
|
|
3140
3256
|
const operationId = this._compactionLifecycle.begin({
|
|
3141
3257
|
operationId: requestId,
|
|
3142
3258
|
stage: "execution",
|
|
@@ -3391,6 +3507,10 @@ export class AgentSession {
|
|
|
3391
3507
|
* Cancel in-progress compaction (manual or auto).
|
|
3392
3508
|
*/
|
|
3393
3509
|
abortCompaction() {
|
|
3510
|
+
const lifecycleState = this._compactionLifecycle.state;
|
|
3511
|
+
const activeFeedbackRequestId = lifecycleState.status === "running" && lifecycleState.stage === "feedback"
|
|
3512
|
+
? lifecycleState.operationId
|
|
3513
|
+
: undefined;
|
|
3394
3514
|
const feedbackOperation = this._compactionLifecycle.abort(this._messageRevision);
|
|
3395
3515
|
this._compactionAbortController?.abort();
|
|
3396
3516
|
this._autoCompactionAbortController?.abort();
|
|
@@ -3402,6 +3522,7 @@ export class AgentSession {
|
|
|
3402
3522
|
result: undefined,
|
|
3403
3523
|
aborted: true,
|
|
3404
3524
|
willRetry: false,
|
|
3525
|
+
requestId: activeFeedbackRequestId,
|
|
3405
3526
|
});
|
|
3406
3527
|
}
|
|
3407
3528
|
}
|
|
@@ -3607,16 +3728,20 @@ export class AgentSession {
|
|
|
3607
3728
|
else {
|
|
3608
3729
|
const messages = filterContextExcludedMessages(this.agent.state.messages);
|
|
3609
3730
|
const estimate = estimateContextTokens(messages);
|
|
3610
|
-
if (estimate.lastUsageIndex === null)
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3731
|
+
if (estimate.lastUsageIndex === null) {
|
|
3732
|
+
if (!this._isRequiredCompactionError(assistantMessage))
|
|
3733
|
+
return false;
|
|
3734
|
+
}
|
|
3735
|
+
else {
|
|
3736
|
+
// Verify the usage source is post-compaction. Kept pre-compaction messages
|
|
3737
|
+
// have stale usage reflecting the old (larger) context and would falsely
|
|
3738
|
+
// trigger compaction right after one just finished.
|
|
3739
|
+
const usageMsg = messages[estimate.lastUsageIndex];
|
|
3740
|
+
if (compactionEntry &&
|
|
3741
|
+
usageMsg.role === "assistant" &&
|
|
3742
|
+
this._isAssistantFromBeforeLatestCompaction(usageMsg)) {
|
|
3743
|
+
return false;
|
|
3744
|
+
}
|
|
3620
3745
|
}
|
|
3621
3746
|
contextTokens = estimate.tokens;
|
|
3622
3747
|
}
|
|
@@ -3626,7 +3751,7 @@ export class AgentSession {
|
|
|
3626
3751
|
return await this._runPrePromptCompaction(assistantMessage, skipAbortedCheck, inlineReason, retryAfterCompaction);
|
|
3627
3752
|
}
|
|
3628
3753
|
else {
|
|
3629
|
-
const compacted = await this._runAutoCompaction("threshold",
|
|
3754
|
+
const compacted = await this._runAutoCompaction("threshold", retryAfterCompaction);
|
|
3630
3755
|
if (!compacted &&
|
|
3631
3756
|
this._compactionLifecycle.state.status === "failed" &&
|
|
3632
3757
|
getLatestCompactionEntry(this.sessionManager.getBranch()) !== null) {
|
|
@@ -3646,13 +3771,15 @@ export class AgentSession {
|
|
|
3646
3771
|
}
|
|
3647
3772
|
async _runPrePromptCompaction(lastAssistantMessage, skipAbortedCheck, reason = "pre_prompt", willRetry = false, allowSummaryOnly = false) {
|
|
3648
3773
|
const controller = new AbortController();
|
|
3774
|
+
const requestId = randomUUID();
|
|
3649
3775
|
this._claimCompactionController(controller, "compaction");
|
|
3650
|
-
this._emit({ type: "compaction_start", reason });
|
|
3776
|
+
this._emit({ type: "compaction_start", reason, requestId });
|
|
3651
3777
|
try {
|
|
3652
3778
|
const execution = await this._executeCompaction({
|
|
3653
3779
|
controller,
|
|
3654
3780
|
owner: "compaction",
|
|
3655
3781
|
reason,
|
|
3782
|
+
requestId,
|
|
3656
3783
|
willRetry,
|
|
3657
3784
|
lastAssistantMessage,
|
|
3658
3785
|
skipAbortedCheck,
|
|
@@ -3680,6 +3807,7 @@ export class AgentSession {
|
|
|
3680
3807
|
result: undefined,
|
|
3681
3808
|
aborted,
|
|
3682
3809
|
willRetry: false,
|
|
3810
|
+
requestId,
|
|
3683
3811
|
errorMessage: aborted ? undefined : `Pre-prompt compaction failed: ${errorMessage}`,
|
|
3684
3812
|
});
|
|
3685
3813
|
return false;
|
|
@@ -3792,9 +3920,10 @@ export class AgentSession {
|
|
|
3792
3920
|
const finishCompactionWork = this._sessionWorkBarrier.begin();
|
|
3793
3921
|
const agentMessagesAtStart = this.agent.state.messages.slice();
|
|
3794
3922
|
const autoCompactionController = new AbortController();
|
|
3923
|
+
const requestId = randomUUID();
|
|
3795
3924
|
this._claimCompactionController(autoCompactionController, "auto");
|
|
3796
3925
|
const endBeforeExecution = () => {
|
|
3797
|
-
this._emit({ type: "compaction_start", reason });
|
|
3926
|
+
this._emit({ type: "compaction_start", reason, requestId });
|
|
3798
3927
|
if (reason === "overflow" && this._autoCompactionAbortController === autoCompactionController) {
|
|
3799
3928
|
this._overflowRecoveryAttempted = false;
|
|
3800
3929
|
}
|
|
@@ -3811,6 +3940,7 @@ export class AgentSession {
|
|
|
3811
3940
|
result: undefined,
|
|
3812
3941
|
aborted: autoCompactionController.signal.aborted,
|
|
3813
3942
|
willRetry: false,
|
|
3943
|
+
requestId,
|
|
3814
3944
|
});
|
|
3815
3945
|
return false;
|
|
3816
3946
|
};
|
|
@@ -3838,11 +3968,12 @@ export class AgentSession {
|
|
|
3838
3968
|
}
|
|
3839
3969
|
if (!this._ownsCompactionController(autoCompactionController, "auto"))
|
|
3840
3970
|
return false;
|
|
3841
|
-
this._emit({ type: "compaction_start", reason });
|
|
3971
|
+
this._emit({ type: "compaction_start", reason, requestId });
|
|
3842
3972
|
const execution = await this._executeCompaction({
|
|
3843
3973
|
controller: autoCompactionController,
|
|
3844
3974
|
owner: "auto",
|
|
3845
3975
|
reason,
|
|
3976
|
+
requestId,
|
|
3846
3977
|
willRetry,
|
|
3847
3978
|
agentMessagesAtStart,
|
|
3848
3979
|
});
|
|
@@ -3888,6 +4019,7 @@ export class AgentSession {
|
|
|
3888
4019
|
result: undefined,
|
|
3889
4020
|
aborted,
|
|
3890
4021
|
willRetry: false,
|
|
4022
|
+
requestId,
|
|
3891
4023
|
errorMessage: aborted
|
|
3892
4024
|
? undefined
|
|
3893
4025
|
: reason === "overflow"
|
|
@@ -4169,6 +4301,7 @@ export class AgentSession {
|
|
|
4169
4301
|
compact: (options) => {
|
|
4170
4302
|
const admission = this._claimPendingCompactionAdmission();
|
|
4171
4303
|
const controller = admission.controller;
|
|
4304
|
+
const requestId = randomUUID();
|
|
4172
4305
|
void (async () => {
|
|
4173
4306
|
let outcome = "failed";
|
|
4174
4307
|
let compactionCompleted = false;
|
|
@@ -4177,11 +4310,12 @@ export class AgentSession {
|
|
|
4177
4310
|
await this._abortActiveAgentAndRetry("system");
|
|
4178
4311
|
this._disconnectFromAgent();
|
|
4179
4312
|
disconnected = true;
|
|
4180
|
-
this._emit({ type: "compaction_start", reason: "extension" });
|
|
4313
|
+
this._emit({ type: "compaction_start", reason: "extension", requestId });
|
|
4181
4314
|
const execution = await this._executeCompaction({
|
|
4182
4315
|
controller,
|
|
4183
4316
|
owner: "compaction",
|
|
4184
4317
|
reason: "extension",
|
|
4318
|
+
requestId,
|
|
4185
4319
|
customInstructions: options?.customInstructions,
|
|
4186
4320
|
willRetry: false,
|
|
4187
4321
|
});
|
|
@@ -4208,6 +4342,7 @@ export class AgentSession {
|
|
|
4208
4342
|
result: undefined,
|
|
4209
4343
|
aborted,
|
|
4210
4344
|
willRetry: false,
|
|
4345
|
+
requestId,
|
|
4211
4346
|
errorMessage: aborted ? undefined : `Compaction failed: ${message}`,
|
|
4212
4347
|
});
|
|
4213
4348
|
const err = error instanceof Error ? error : new Error(String(error));
|