@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,5 +1,43 @@
|
|
|
1
1
|
import { CYCLE_MAX_PERIOD, CYCLE_MIN_PERIOD, CYCLE_REPETITION_THRESHOLD, ESCALATION_FACTOR, IDENTICAL_RUN_THRESHOLD, SIMILAR_RUN_THRESHOLD, SIMILARITY_THRESHOLD, } from "./policy.js";
|
|
2
2
|
import { meanAdjacentSimilarity } from "./similarity.js";
|
|
3
|
+
const TARGET_FIELDS = new Map([
|
|
4
|
+
["read", ["path"]],
|
|
5
|
+
["bash_output", ["bash_id"]],
|
|
6
|
+
["task_output", ["task_id", "name"]],
|
|
7
|
+
["task_update", ["task_id"]],
|
|
8
|
+
["task_send", ["to"]],
|
|
9
|
+
["lsp_diagnostics", ["filePath"]],
|
|
10
|
+
]);
|
|
11
|
+
function targetIdentity(record) {
|
|
12
|
+
const fields = TARGET_FIELDS.get(record.toolName);
|
|
13
|
+
if (fields === undefined)
|
|
14
|
+
return undefined;
|
|
15
|
+
let args;
|
|
16
|
+
try {
|
|
17
|
+
args = JSON.parse(record.argsJson);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
if (typeof args !== "object" || args === null || Array.isArray(args))
|
|
23
|
+
return undefined;
|
|
24
|
+
for (const field of fields) {
|
|
25
|
+
const value = Reflect.get(args, field);
|
|
26
|
+
if (typeof value === "string" && value.length > 0)
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
function hasAllDistinctTargets(records) {
|
|
32
|
+
const identities = [];
|
|
33
|
+
for (const record of records) {
|
|
34
|
+
const identity = targetIdentity(record);
|
|
35
|
+
if (identity === undefined)
|
|
36
|
+
return false;
|
|
37
|
+
identities.push(identity);
|
|
38
|
+
}
|
|
39
|
+
return new Set(identities).size === identities.length;
|
|
40
|
+
}
|
|
3
41
|
export function detectIdenticalRun(records) {
|
|
4
42
|
const last = records[records.length - 1];
|
|
5
43
|
if (last === undefined)
|
|
@@ -26,9 +64,12 @@ export function detectSimilarRun(records) {
|
|
|
26
64
|
}
|
|
27
65
|
if (run < SIMILAR_RUN_THRESHOLD)
|
|
28
66
|
return undefined;
|
|
29
|
-
const
|
|
67
|
+
const runRecords = records.slice(records.length - run);
|
|
68
|
+
const argStrings = runRecords.map((record) => record.argsJson);
|
|
30
69
|
if (new Set(argStrings).size === 1)
|
|
31
70
|
return undefined;
|
|
71
|
+
if (hasAllDistinctTargets(runRecords))
|
|
72
|
+
return undefined;
|
|
32
73
|
const similarity = meanAdjacentSimilarity(argStrings);
|
|
33
74
|
if (similarity < SIMILARITY_THRESHOLD)
|
|
34
75
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detectors.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/loop-guard/detectors.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,0BAA0B,EAC1B,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAsBzD,MAAM,UAAU,kBAAkB,CAAC,OAAkC;IACpE,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACzC,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACzC,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,IAAI,CAAC,GAAG,OAAO,CAA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YAC1C,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,WAAW;gBAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACvE,CAAC;IACF,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACD;AAED,MAAM,UAAU,UAAU,CAAC,OAAkC,EAAE,IAAgB;IAC9E,MAAM,UAAU,GAAG,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IAClG,MAAM,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;IAChD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACpC,IAAI,SAAS,KAAK,SAAS;YAAE,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IAChF,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACnB,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACpC,IAAI,SAAS,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;IACxE,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import {\n\tCYCLE_MAX_PERIOD,\n\tCYCLE_MIN_PERIOD,\n\tCYCLE_REPETITION_THRESHOLD,\n\tESCALATION_FACTOR,\n\tIDENTICAL_RUN_THRESHOLD,\n\tSIMILAR_RUN_THRESHOLD,\n\tSIMILARITY_THRESHOLD,\n} from \"./policy.ts\";\nimport { meanAdjacentSimilarity } from \"./similarity.ts\";\nimport type { ToolCallRecord } from \"./tracker.ts\";\n\nexport type LoopGuardDetection =\n\t| { readonly kind: \"identical\"; readonly toolName: string; readonly count: number; readonly fingerprint: string }\n\t| {\n\t\t\treadonly kind: \"similar\";\n\t\t\treadonly toolName: string;\n\t\t\treadonly count: number;\n\t\t\treadonly similarity: number;\n\t\t\treadonly fingerprint: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"cycle\";\n\t\t\treadonly period: number;\n\t\t\treadonly count: number;\n\t\t\treadonly cycleTools: readonly string[];\n\t\t\treadonly fingerprint: string;\n\t };\n\nexport type LoopGuardKind = LoopGuardDetection[\"kind\"];\n\nexport function detectIdenticalRun(records: readonly ToolCallRecord[]): LoopGuardDetection | undefined {\n\tconst last = records[records.length - 1];\n\tif (last === undefined) return undefined;\n\tlet run = 1;\n\tfor (let i = records.length - 2; i >= 0; i--) {\n\t\tif (records[i]?.signature !== last.signature) break;\n\t\trun++;\n\t}\n\tif (run < IDENTICAL_RUN_THRESHOLD) return undefined;\n\treturn { kind: \"identical\", toolName: last.toolName, count: run, fingerprint: last.signature };\n}\n\nexport function detectSimilarRun(records: readonly ToolCallRecord[]): LoopGuardDetection | undefined {\n\tconst last = records[records.length - 1];\n\tif (last === undefined) return undefined;\n\tlet run = 1;\n\tfor (let i = records.length - 2; i >= 0; i--) {\n\t\tif (records[i]?.toolName !== last.toolName) break;\n\t\trun++;\n\t}\n\tif (run < SIMILAR_RUN_THRESHOLD) return undefined;\n\tconst argStrings = records.slice(records.length - run).map((record) => record.argsJson);\n\tif (new Set(argStrings).size === 1) return undefined;\n\tconst similarity = meanAdjacentSimilarity(argStrings);\n\tif (similarity < SIMILARITY_THRESHOLD) return undefined;\n\treturn { kind: \"similar\", toolName: last.toolName, count: run, similarity, fingerprint: last.toolName };\n}\n\nexport function detectCycle(records: readonly ToolCallRecord[]): LoopGuardDetection | undefined {\n\tconst total = records.length;\n\tfor (let period = CYCLE_MIN_PERIOD; period <= CYCLE_MAX_PERIOD; period++) {\n\t\tif (total < period * CYCLE_REPETITION_THRESHOLD) continue;\n\t\tconst cycle = records.slice(total - period);\n\t\tif (new Set(cycle.map((record) => record.signature)).size < 2) continue;\n\t\tlet repetitions = 1;\n\t\twhile (repetitions * period + period <= total) {\n\t\t\tconst blockStart = total - (repetitions + 1) * period;\n\t\t\tlet matches = true;\n\t\t\tfor (let offset = 0; offset < period; offset++) {\n\t\t\t\tif (records[blockStart + offset]?.signature !== cycle[offset]?.signature) {\n\t\t\t\t\tmatches = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!matches) break;\n\t\t\trepetitions++;\n\t\t}\n\t\tif (repetitions < CYCLE_REPETITION_THRESHOLD) continue;\n\t\treturn {\n\t\t\tkind: \"cycle\",\n\t\t\tperiod,\n\t\t\tcount: repetitions,\n\t\t\tcycleTools: cycle.map((record) => record.toolName),\n\t\t\tfingerprint: cycle.map((record) => record.signature).join(\"\\u0001\"),\n\t\t};\n\t}\n\treturn undefined;\n}\n\ninterface GateEntry {\n\tfingerprint: string;\n\tlastNotifiedCount: number;\n}\n\nexport class NoticeGate {\n\tprivate entries = new Map<LoopGuardKind, GateEntry>();\n\n\tadmit(detection: LoopGuardDetection): boolean {\n\t\tconst existing = this.entries.get(detection.kind);\n\t\tif (existing === undefined || existing.fingerprint !== detection.fingerprint) {\n\t\t\tthis.entries.set(detection.kind, { fingerprint: detection.fingerprint, lastNotifiedCount: detection.count });\n\t\t\treturn true;\n\t\t}\n\t\tif (detection.count >= existing.lastNotifiedCount * ESCALATION_FACTOR) {\n\t\t\texisting.lastNotifiedCount = detection.count;\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprune(active: ReadonlyMap<LoopGuardKind, string>): void {\n\t\tfor (const [kind, entry] of this.entries) {\n\t\t\tif (active.get(kind) !== entry.fingerprint) this.entries.delete(kind);\n\t\t}\n\t}\n\n\treset(): void {\n\t\tthis.entries.clear();\n\t}\n}\n\nexport function detectLoop(records: readonly ToolCallRecord[], gate: NoticeGate): LoopGuardDetection | undefined {\n\tconst detections = [detectIdenticalRun(records), detectCycle(records), detectSimilarRun(records)];\n\tconst active = new Map<LoopGuardKind, string>();\n\tfor (const detection of detections) {\n\t\tif (detection !== undefined) active.set(detection.kind, detection.fingerprint);\n\t}\n\tgate.prune(active);\n\tfor (const detection of detections) {\n\t\tif (detection !== undefined && gate.admit(detection)) return detection;\n\t}\n\treturn undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"detectors.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/loop-guard/detectors.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,0BAA0B,EAC1B,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,MAAM,aAAa,GAAG,IAAI,GAAG,CAA4B;IACxD,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC,aAAa,EAAE,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC,aAAa,EAAE,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC,iBAAiB,EAAE,CAAC,UAAU,CAAC,CAAC;CACjC,CAAC,CAAC;AAqBH,SAAS,cAAc,CAAC,MAAsB;IAC7C,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAClD,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC3C,IAAI,IAAa,CAAC;IAClB,IAAI,CAAC;QACJ,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,I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;IAED,KAAK;QACJ,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACD;AAED,MAAM,UAAU,UAAU,CAAC,OAAkC,EAAE,IAAgB;IAC9E,MAAM,UAAU,GAAG,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IAClG,MAAM,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;IAChD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACpC,IAAI,SAAS,KAAK,SAAS;YAAE,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IAChF,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACnB,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACpC,IAAI,SAAS,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;IACxE,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import {\n\tCYCLE_MAX_PERIOD,\n\tCYCLE_MIN_PERIOD,\n\tCYCLE_REPETITION_THRESHOLD,\n\tESCALATION_FACTOR,\n\tIDENTICAL_RUN_THRESHOLD,\n\tSIMILAR_RUN_THRESHOLD,\n\tSIMILARITY_THRESHOLD,\n} from \"./policy.ts\";\nimport { meanAdjacentSimilarity } from \"./similarity.ts\";\nimport type { ToolCallRecord } from \"./tracker.ts\";\n\nconst TARGET_FIELDS = new Map<string, readonly string[]>([\n\t[\"read\", [\"path\"]],\n\t[\"bash_output\", [\"bash_id\"]],\n\t[\"task_output\", [\"task_id\", \"name\"]],\n\t[\"task_update\", [\"task_id\"]],\n\t[\"task_send\", [\"to\"]],\n\t[\"lsp_diagnostics\", [\"filePath\"]],\n]);\n\nexport type LoopGuardDetection =\n\t| { readonly kind: \"identical\"; readonly toolName: string; readonly count: number; readonly fingerprint: string }\n\t| {\n\t\t\treadonly kind: \"similar\";\n\t\t\treadonly toolName: string;\n\t\t\treadonly count: number;\n\t\t\treadonly similarity: number;\n\t\t\treadonly fingerprint: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"cycle\";\n\t\t\treadonly period: number;\n\t\t\treadonly count: number;\n\t\t\treadonly cycleTools: readonly string[];\n\t\t\treadonly fingerprint: string;\n\t };\n\nexport type LoopGuardKind = LoopGuardDetection[\"kind\"];\n\nfunction targetIdentity(record: ToolCallRecord): string | undefined {\n\tconst fields = TARGET_FIELDS.get(record.toolName);\n\tif (fields === undefined) return undefined;\n\tlet args: unknown;\n\ttry {\n\t\targs = JSON.parse(record.argsJson);\n\t} catch {\n\t\treturn undefined;\n\t}\n\tif (typeof args !== \"object\" || args === null || Array.isArray(args)) return undefined;\n\tfor (const field of fields) {\n\t\tconst value: unknown = Reflect.get(args, field);\n\t\tif (typeof value === \"string\" && value.length > 0) return value;\n\t}\n\treturn undefined;\n}\n\nfunction hasAllDistinctTargets(records: readonly ToolCallRecord[]): boolean {\n\tconst identities: string[] = [];\n\tfor (const record of records) {\n\t\tconst identity = targetIdentity(record);\n\t\tif (identity === undefined) return false;\n\t\tidentities.push(identity);\n\t}\n\treturn new Set(identities).size === identities.length;\n}\n\nexport function detectIdenticalRun(records: readonly ToolCallRecord[]): LoopGuardDetection | undefined {\n\tconst last = records[records.length - 1];\n\tif (last === undefined) return undefined;\n\tlet run = 1;\n\tfor (let i = records.length - 2; i >= 0; i--) {\n\t\tif (records[i]?.signature !== last.signature) break;\n\t\trun++;\n\t}\n\tif (run < IDENTICAL_RUN_THRESHOLD) return undefined;\n\treturn { kind: \"identical\", toolName: last.toolName, count: run, fingerprint: last.signature };\n}\n\nexport function detectSimilarRun(records: readonly ToolCallRecord[]): LoopGuardDetection | undefined {\n\tconst last = records[records.length - 1];\n\tif (last === undefined) return undefined;\n\tlet run = 1;\n\tfor (let i = records.length - 2; i >= 0; i--) {\n\t\tif (records[i]?.toolName !== last.toolName) break;\n\t\trun++;\n\t}\n\tif (run < SIMILAR_RUN_THRESHOLD) return undefined;\n\tconst runRecords = records.slice(records.length - run);\n\tconst argStrings = runRecords.map((record) => record.argsJson);\n\tif (new Set(argStrings).size === 1) return undefined;\n\tif (hasAllDistinctTargets(runRecords)) return undefined;\n\tconst similarity = meanAdjacentSimilarity(argStrings);\n\tif (similarity < SIMILARITY_THRESHOLD) return undefined;\n\treturn { kind: \"similar\", toolName: last.toolName, count: run, similarity, fingerprint: last.toolName };\n}\n\nexport function detectCycle(records: readonly ToolCallRecord[]): LoopGuardDetection | undefined {\n\tconst total = records.length;\n\tfor (let period = CYCLE_MIN_PERIOD; period <= CYCLE_MAX_PERIOD; period++) {\n\t\tif (total < period * CYCLE_REPETITION_THRESHOLD) continue;\n\t\tconst cycle = records.slice(total - period);\n\t\tif (new Set(cycle.map((record) => record.signature)).size < 2) continue;\n\t\tlet repetitions = 1;\n\t\twhile (repetitions * period + period <= total) {\n\t\t\tconst blockStart = total - (repetitions + 1) * period;\n\t\t\tlet matches = true;\n\t\t\tfor (let offset = 0; offset < period; offset++) {\n\t\t\t\tif (records[blockStart + offset]?.signature !== cycle[offset]?.signature) {\n\t\t\t\t\tmatches = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!matches) break;\n\t\t\trepetitions++;\n\t\t}\n\t\tif (repetitions < CYCLE_REPETITION_THRESHOLD) continue;\n\t\treturn {\n\t\t\tkind: \"cycle\",\n\t\t\tperiod,\n\t\t\tcount: repetitions,\n\t\t\tcycleTools: cycle.map((record) => record.toolName),\n\t\t\tfingerprint: cycle.map((record) => record.signature).join(\"\\u0001\"),\n\t\t};\n\t}\n\treturn undefined;\n}\n\ninterface GateEntry {\n\tfingerprint: string;\n\tlastNotifiedCount: number;\n}\n\nexport class NoticeGate {\n\tprivate entries = new Map<LoopGuardKind, GateEntry>();\n\n\tadmit(detection: LoopGuardDetection): boolean {\n\t\tconst existing = this.entries.get(detection.kind);\n\t\tif (existing === undefined || existing.fingerprint !== detection.fingerprint) {\n\t\t\tthis.entries.set(detection.kind, { fingerprint: detection.fingerprint, lastNotifiedCount: detection.count });\n\t\t\treturn true;\n\t\t}\n\t\tif (detection.count >= existing.lastNotifiedCount * ESCALATION_FACTOR) {\n\t\t\texisting.lastNotifiedCount = detection.count;\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprune(active: ReadonlyMap<LoopGuardKind, string>): void {\n\t\tfor (const [kind, entry] of this.entries) {\n\t\t\tif (active.get(kind) !== entry.fingerprint) this.entries.delete(kind);\n\t\t}\n\t}\n\n\treset(): void {\n\t\tthis.entries.clear();\n\t}\n}\n\nexport function detectLoop(records: readonly ToolCallRecord[], gate: NoticeGate): LoopGuardDetection | undefined {\n\tconst detections = [detectIdenticalRun(records), detectCycle(records), detectSimilarRun(records)];\n\tconst active = new Map<LoopGuardKind, string>();\n\tfor (const detection of detections) {\n\t\tif (detection !== undefined) active.set(detection.kind, detection.fingerprint);\n\t}\n\tgate.prune(active);\n\tfor (const detection of detections) {\n\t\tif (detection !== undefined && gate.admit(detection)) return detection;\n\t}\n\treturn undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/health.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EACN,SAAS,EAKT,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/health.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EACN,SAAS,EAKT,MAAM,aAAa,CAAC;AAGrB,eAAO,MAAM,iBAAiB,QAAS,CAAC;AACxC,eAAO,MAAM,mBAAmB,OAAQ,CAAC;AASzC,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;AAExD,wBAAsB,2BAA2B,CAChD,UAAU,EAAE,gBAAgB,EAC5B,WAAW,CAAC,EAAE,kBAAkB,GAC9B,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED,wBAAsB,yBAAyB,CAAC,CAAC,EAChD,UAAU,EAAE,gBAAgB,EAC5B,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACzB,OAAO,CAAC,CAAC,CAAC,CAgBZ;AAED,wBAAsB,+BAA+B,CAAC,CAAC,EACtD,UAAU,EAAE,gBAAgB,EAC5B,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACzB,OAAO,CAAC,CAAC,CAAC,CAgBZ;AA6CD,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,gBAAgB,EAAE,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAK9G"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
2
2
|
import { OAuthFlowError } from "./auth/oauth-errors.js";
|
|
3
3
|
import { AuthError, ConnectError, isMcpSessionExpiredError, isRetriableMcpError, SessionExpiredError, } from "./errors.js";
|
|
4
|
+
import { reconnectMcpNow } from "./reconnect.js";
|
|
4
5
|
export const MCP_PING_STALE_MS = 30_000;
|
|
5
6
|
export const MCP_PING_TIMEOUT_MS = 2_000;
|
|
6
7
|
const healthByConnection = new WeakMap();
|
|
@@ -49,7 +50,7 @@ export async function withMcpSessionExpiryRetry(connection, operation) {
|
|
|
49
50
|
if (!isMcpSessionExpiredError(error))
|
|
50
51
|
throw error;
|
|
51
52
|
connection.markDegraded(sessionExpiredError(connection, error, true));
|
|
52
|
-
await connection
|
|
53
|
+
await reconnectMcpNow(connection);
|
|
53
54
|
try {
|
|
54
55
|
return await oper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AAC,UAAU,EAAE,CAC3D,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc,EAAE,KAAK,GAAG,CAAC;IAClD,IAAI,KAAK,YAAY,iBAAiB;QAAE,OAAO,IAAI,CAAC;IACpD,IAAI,KAAK,YAAY,cAAc;QAAE,OAAO,KAAK,CAAC,QAAQ,CAAC;IAC3D,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,EAAE,CAAC;QAClF,OAAO,gBAAgB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import { UnauthorizedError } from \"@modelcontextprotocol/sdk/client/auth.js\";\nimport { OAuthFlowError } from \"./auth/oauth-errors.ts\";\nimport type { ServerConnection } from \"./connection.ts\";\nimport {\n\tAuthError,\n\tConnectError,\n\tisMcpSessionExpiredError,\n\tisRetriableMcpError,\n\tSessionExpiredError,\n} from \"./errors.ts\";\n\nexport const MCP_PING_STALE_MS = 30_000;\nexport const MCP_PING_TIMEOUT_MS = 2_000;\n\ninterface McpHealthState {\n\tlastSuccessfulPingAtMs: number | undefined;\n\tpendingValidation: Promise<void> | undefined;\n}\n\nconst healthByConnection = new WeakMap<ServerConnection, McpHealthState>();\n\nexport type McpEnsureFreshAuth = () => Promise<unknown>;\n\nexport async function ensureMcpToolCallConnection(\n\tconnection: ServerConnection,\n\tensureFresh?: McpEnsureFreshAuth,\n): Promise<void> {\n\tawait ensureFreshAuth(connection, ensureFresh);\n\tconst health = healthStateFor(connection);\n\tif (connection.state !== \"connected\") {\n\t\tif (connection.state === \"idle\" || connection.state === \"connecting\") {\n\t\t\ttry {\n\t\t\t\tawait connection.connect();\n\t\t\t} catch (error) {\n\t\t\t\tif (isNeedsAuthError(error)) throw headlessAuthError(connection, error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t} else if (connection.state === \"needs_auth\") {\n\t\t\tthrow headlessAuthError(connection);\n\t\t} else {\n\t\t\tawait renewConnection(connection, health);\n\t\t\treturn;\n\t\t}\n\t}\n\tconst lastSuccessfulPingAtMs = health.lastSuccessfulPingAtMs;\n\tif (lastSuccessfulPingAtMs !== undefined && Date.now() - lastSuccessfulPingAtMs <= MCP_PING_STALE_MS) {\n\t\treturn;\n\t}\n\tif (health.pendingValidation !== undefined) {\n\t\tawait health.pendingValidation;\n\t\treturn;\n\t}\n\tconst pendingValidation = pingOrRenew(connection, health).finally(() => {\n\t\tif (health.pendingValidation === pendingValidation) health.pendingValidation = undefined;\n\t});\n\thealth.pendingValidation = pendingValidation;\n\tawait pendingValidation;\n}\n\nexport async function withMcpSessionExpiryRetry<T>(\n\tconnection: ServerConnection,\n\toperation: () => Promise<T>,\n): Promise<T> {\n\ttry {\n\t\treturn await operation();\n\t} catch (error) {\n\t\tif (!isMcpSessionExpiredError(error)) throw error;\n\t\tconnection.markDegraded(sessionExpiredError(connection, error, true));\n\t\tawait connection.renew();\n\t\ttry {\n\t\t\treturn await operation();\n\t\t} catch (retryError) {\n\t\t\tif (!isMcpSessionExpiredError(retryError)) throw retryError;\n\t\t\tconst expired = sessionExpiredError(connection, retryError, false);\n\t\t\tconnection.markSuspended(expired);\n\t\t\tthrow expired;\n\t\t}\n\t}\n}\n\nexport async function withMcpRetriableFailedSendRetry<T>(\n\tconnection: ServerConnection,\n\toperation: () => Promise<T>,\n): Promise<T> {\n\ttry {\n\t\treturn await operation();\n\t} catch (error) {\n\t\tif (!isRetriableFailedSendError(error)) throw error;\n\t\tconnection.markDegraded(failedSendError(connection, error, true));\n\t\tawait connection.renew();\n\t\ttry {\n\t\t\treturn await operation();\n\t\t} catch (retryError) {\n\t\t\tif (isRetriableFailedSendError(retryError)) {\n\t\t\t\tconnection.markDegraded(failedSendError(connection, retryError, false));\n\t\t\t}\n\t\t\tthrow retryError;\n\t\t}\n\t}\n}\n\nfunction healthStateFor(connection: ServerConnection): McpHealthState {\n\tlet health = healthByConnection.get(connection);\n\tif (health === undefined) {\n\t\thealth = { lastSuccessfulPingAtMs: undefined, pendingValidation: undefined };\n\t\thealthByConnection.set(connection, health);\n\t}\n\treturn health;\n}\n\nasync function pingOrRenew(connection: ServerConnection, health: McpHealthState): Promise<void> {\n\ttry {\n\t\tawait connection.client.ping({ timeout: MCP_PING_TIMEOUT_MS });\n\t\thealth.lastSuccessfulPingAtMs = Date.now();\n\t} catch (error) {\n\t\tconnection.markDegraded(error instanceof Error ? error : new Error(String(error)));\n\t\tawait renewConnection(connection, health);\n\t}\n}\n\nasync function renewConnection(connection: ServerConnection, health: McpHealthState): Promise<void> {\n\ttry {\n\t\tawait connection.renew();\n\t} catch (error) {\n\t\tif (isNeedsAuthError(error)) throw headlessAuthError(connection, error);\n\t\tthrow error;\n\t}\n\thealth.lastSuccessfulPingAtMs = Date.now();\n}\n\nasync function ensureFreshAuth(\n\tconnection: ServerConnection,\n\tensureFresh: McpEnsureFreshAuth | undefined,\n): Promise<void> {\n\tif (ensureFresh === undefined) return;\n\ttry {\n\t\tawait ensureFresh();\n\t} catch (error) {\n\t\tconst authError = markMcpConnectionNeedsAuth(connection, error);\n\t\tif (authError !== undefined) throw authError;\n\t\tthrow error;\n\t}\n}\n\nexport function markMcpConnectionNeedsAuth(connection: ServerConnection, error: unknown): AuthError | undefined {\n\tif (!isNeedsAuthError(error)) return undefined;\n\tconst authError = headlessAuthError(connection, error);\n\tconnection.markNeedsAuth(authError);\n\treturn authError;\n}\n\nfunction isRetriableFailedSendError(error: unknown): boolean {\n\treturn isRetriableMcpError(error) && !isMcpSessionExpiredError(error);\n}\n\nfunction failedSendError(connection: ServerConnection, cause: unknown, retriable: boolean): ConnectError {\n\tconst suffix = retriable\n\t\t? \"reconnecting once before retry\"\n\t\t: `post-reconnect retry also failed; run /mcp reconnect ${connection.serverName}`;\n\treturn new ConnectError(`MCP server ${connection.serverName} failed to send tool call; ${suffix}`, {\n\t\tcause,\n\t\tphase: \"call\",\n\t\tretriable,\n\t\tserverName: connection.serverName,\n\t});\n}\n\nfunction sessionExpiredError(connection: ServerConnection, cause: unknown, retriable: boolean): SessionExpiredError {\n\tconst suffix = retriable\n\t\t? \"reinitializing once\"\n\t\t: `reinitialize retry also expired; run /mcp reconnect ${connection.serverName}`;\n\treturn new SessionExpiredError(`MCP server ${connection.serverName} session expired; ${suffix}`, {\n\t\tcause,\n\t\tphase: \"session\",\n\t\tretriable,\n\t\tserverName: connection.serverName,\n\t});\n}\n\nfunction headlessAuthError(connection: ServerConnection, cause?: unknown): AuthError {\n\treturn new AuthError(\n\t\t`MCP server ${connection.serverName} needs OAuth. Run senpi interactive, then /mcp auth-start ${connection.serverName} and /mcp auth-complete ${connection.serverName} <redirect-url>.`,\n\t\t{ cause, phase: \"auth\", serverName: connection.serverName },\n\t);\n}\n\nfunction isNeedsAuthError(error: unknown, depth = 0): boolean {\n\tif (error instanceof UnauthorizedError) return true;\n\tif (error instanceof OAuthFlowError) return error.terminal;\n\tif (depth < 5 && error !== null && typeof error === \"object\" && \"cause\" in error) {\n\t\treturn isNeedsAuthError(error.cause, depth + 1);\n\t}\n\treturn false;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EACN,SAAS,EACT,YAAY,EACZ,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACxC,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAOzC,MAAM,kBAAkB,GAAG,I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AC","sourcesContent":["import { UnauthorizedError } from \"@modelcontextprotocol/sdk/client/auth.js\";\nimport { OAuthFlowError } from \"./auth/oauth-errors.ts\";\nimport type { ServerConnection } from \"./connection.ts\";\nimport {\n\tAuthError,\n\tConnectError,\n\tisMcpSessionExpiredError,\n\tisRetriableMcpError,\n\tSessionExpiredError,\n} from \"./errors.ts\";\nimport { reconnectMcpNow } from \"./reconnect.ts\";\n\nexport const MCP_PING_STALE_MS = 30_000;\nexport const MCP_PING_TIMEOUT_MS = 2_000;\n\ninterface McpHealthState {\n\tlastSuccessfulPingAtMs: number | undefined;\n\tpendingValidation: Promise<void> | undefined;\n}\n\nconst healthByConnection = new WeakMap<ServerConnection, McpHealthState>();\n\nexport type McpEnsureFreshAuth = () => Promise<unknown>;\n\nexport async function ensureMcpToolCallConnection(\n\tconnection: ServerConnection,\n\tensureFresh?: McpEnsureFreshAuth,\n): Promise<void> {\n\tawait ensureFreshAuth(connection, ensureFresh);\n\tconst health = healthStateFor(connection);\n\tif (connection.state !== \"connected\") {\n\t\tif (connection.state === \"idle\" || connection.state === \"connecting\") {\n\t\t\ttry {\n\t\t\t\tawait connection.connect();\n\t\t\t} catch (error) {\n\t\t\t\tif (isNeedsAuthError(error)) throw headlessAuthError(connection, error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t} else if (connection.state === \"needs_auth\") {\n\t\t\tthrow headlessAuthError(connection);\n\t\t} else {\n\t\t\tawait renewConnection(connection, health);\n\t\t\treturn;\n\t\t}\n\t}\n\tconst lastSuccessfulPingAtMs = health.lastSuccessfulPingAtMs;\n\tif (lastSuccessfulPingAtMs !== undefined && Date.now() - lastSuccessfulPingAtMs <= MCP_PING_STALE_MS) {\n\t\treturn;\n\t}\n\tif (health.pendingValidation !== undefined) {\n\t\tawait health.pendingValidation;\n\t\treturn;\n\t}\n\tconst pendingValidation = pingOrRenew(connection, health).finally(() => {\n\t\tif (health.pendingValidation === pendingValidation) health.pendingValidation = undefined;\n\t});\n\thealth.pendingValidation = pendingValidation;\n\tawait pendingValidation;\n}\n\nexport async function withMcpSessionExpiryRetry<T>(\n\tconnection: ServerConnection,\n\toperation: () => Promise<T>,\n): Promise<T> {\n\ttry {\n\t\treturn await operation();\n\t} catch (error) {\n\t\tif (!isMcpSessionExpiredError(error)) throw error;\n\t\tconnection.markDegraded(sessionExpiredError(connection, error, true));\n\t\tawait reconnectMcpNow(connection);\n\t\ttry {\n\t\t\treturn await operation();\n\t\t} catch (retryError) {\n\t\t\tif (!isMcpSessionExpiredError(retryError)) throw retryError;\n\t\t\tconst expired = sessionExpiredError(connection, retryError, false);\n\t\t\tconnection.markSuspended(expired);\n\t\t\tthrow expired;\n\t\t}\n\t}\n}\n\nexport async function withMcpRetriableFailedSendRetry<T>(\n\tconnection: ServerConnection,\n\toperation: () => Promise<T>,\n): Promise<T> {\n\ttry {\n\t\treturn await operation();\n\t} catch (error) {\n\t\tif (!isRetriableFailedSendError(error)) throw error;\n\t\tconnection.markDegraded(failedSendError(connection, error, true));\n\t\tawait connection.renew();\n\t\ttry {\n\t\t\treturn await operation();\n\t\t} catch (retryError) {\n\t\t\tif (isRetriableFailedSendError(retryError)) {\n\t\t\t\tconnection.markDegraded(failedSendError(connection, retryError, false));\n\t\t\t}\n\t\t\tthrow retryError;\n\t\t}\n\t}\n}\n\nfunction healthStateFor(connection: ServerConnection): McpHealthState {\n\tlet health = healthByConnection.get(connection);\n\tif (health === undefined) {\n\t\thealth = { lastSuccessfulPingAtMs: undefined, pendingValidation: undefined };\n\t\thealthByConnection.set(connection, health);\n\t}\n\treturn health;\n}\n\nasync function pingOrRenew(connection: ServerConnection, health: McpHealthState): Promise<void> {\n\ttry {\n\t\tawait connection.client.ping({ timeout: MCP_PING_TIMEOUT_MS });\n\t\thealth.lastSuccessfulPingAtMs = Date.now();\n\t} catch (error) {\n\t\tconnection.markDegraded(error instanceof Error ? error : new Error(String(error)));\n\t\tawait renewConnection(connection, health);\n\t}\n}\n\nasync function renewConnection(connection: ServerConnection, health: McpHealthState): Promise<void> {\n\ttry {\n\t\tawait connection.renew();\n\t} catch (error) {\n\t\tif (isNeedsAuthError(error)) throw headlessAuthError(connection, error);\n\t\tthrow error;\n\t}\n\thealth.lastSuccessfulPingAtMs = Date.now();\n}\n\nasync function ensureFreshAuth(\n\tconnection: ServerConnection,\n\tensureFresh: McpEnsureFreshAuth | undefined,\n): Promise<void> {\n\tif (ensureFresh === undefined) return;\n\ttry {\n\t\tawait ensureFresh();\n\t} catch (error) {\n\t\tconst authError = markMcpConnectionNeedsAuth(connection, error);\n\t\tif (authError !== undefined) throw authError;\n\t\tthrow error;\n\t}\n}\n\nexport function markMcpConnectionNeedsAuth(connection: ServerConnection, error: unknown): AuthError | undefined {\n\tif (!isNeedsAuthError(error)) return undefined;\n\tconst authError = headlessAuthError(connection, error);\n\tconnection.markNeedsAuth(authError);\n\treturn authError;\n}\n\nfunction isRetriableFailedSendError(error: unknown): boolean {\n\treturn isRetriableMcpError(error) && !isMcpSessionExpiredError(error);\n}\n\nfunction failedSendError(connection: ServerConnection, cause: unknown, retriable: boolean): ConnectError {\n\tconst suffix = retriable\n\t\t? \"reconnecting once before retry\"\n\t\t: `post-reconnect retry also failed; run /mcp reconnect ${connection.serverName}`;\n\treturn new ConnectError(`MCP server ${connection.serverName} failed to send tool call; ${suffix}`, {\n\t\tcause,\n\t\tphase: \"call\",\n\t\tretriable,\n\t\tserverName: connection.serverName,\n\t});\n}\n\nfunction sessionExpiredError(connection: ServerConnection, cause: unknown, retriable: boolean): SessionExpiredError {\n\tconst suffix = retriable\n\t\t? \"reinitializing once\"\n\t\t: `reinitialize retry also expired; run /mcp reconnect ${connection.serverName}`;\n\treturn new SessionExpiredError(`MCP server ${connection.serverName} session expired; ${suffix}`, {\n\t\tcause,\n\t\tphase: \"session\",\n\t\tretriable,\n\t\tserverName: connection.serverName,\n\t});\n}\n\nfunction headlessAuthError(connection: ServerConnection, cause?: unknown): AuthError {\n\treturn new AuthError(\n\t\t`MCP server ${connection.serverName} needs OAuth. Run senpi interactive, then /mcp auth-start ${connection.serverName} and /mcp auth-complete ${connection.serverName} <redirect-url>.`,\n\t\t{ cause, phase: \"auth\", serverName: connection.serverName },\n\t);\n}\n\nfunction isNeedsAuthError(error: unknown, depth = 0): boolean {\n\tif (error instanceof UnauthorizedError) return true;\n\tif (error instanceof OAuthFlowError) return error.terminal;\n\tif (depth < 5 && error !== null && typeof error === \"object\" && \"cause\" in error) {\n\t\treturn isNeedsAuthError(error.cause, depth + 1);\n\t}\n\treturn false;\n}\n"]}
|
|
@@ -37,7 +37,7 @@ export declare const GPT56_EXECUTION_RULES: readonly [{
|
|
|
37
37
|
}, {
|
|
38
38
|
readonly id: "test-first";
|
|
39
39
|
readonly concern: "test-first";
|
|
40
|
-
readonly directive: "Work test-first on behavior changes: write the failing test, watch it fail for the right reason, then make the smallest change that turns it green.
|
|
40
|
+
readonly directive: "Work test-first on behavior changes: write the one failing test at the seam the change touches, watch it fail for the right reason, then make the smallest change that turns it green. Prose, doc, and visual-only changes take review plus real-surface QA, not tests. Skip test-first also for formatting, comments, renames, or dependency bumps, and never write a test that cannot fail for the regression it names.";
|
|
41
41
|
}, {
|
|
42
42
|
readonly id: "atomic-commits";
|
|
43
43
|
readonly concern: "commit-discipline";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpt-5.6.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.6.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gpt-5.6.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.6.ts"],"names":[],"mappings":"AA+CA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AAKlH,MAAM,MAAM,oBAAoB,GAC7B,oBAAoB,GACpB,mBAAmB,GACnB,gBAAgB,GAChB,qBAAqB,GACrB,wBAAwB,GACxB,YAAY,GACZ,kBAAkB,GAClB,YAAY,GACZ,gBAAgB,GAChB,oBAAoB,CAAC;AAExB,MAAM,MAAM,qBAAqB,GAC9B,oBAAoB,GACpB,YAAY,GACZ,iBAAiB,GACjB,YAAY,GACZ,mBAAmB,GACnB,gBAAgB,CAAC;AAEpB,MAAM,WAAW,kBAAkB;IAClC,EAAE,EAAE,oBAAoB,CAAC;IACzB,OAAO,EAAE,qBAAqB,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;CAClB;AAgCD,eAAO,MAAM,qBAAqB;iBAC3B,oBAAoB;sBAAW,oBAAoB;;;iBACnD,mBAAmB;sBAAW,oBAAoB;;;iBAClD,gBAAgB;sBAAW,oBAAoB;;;iBAC/C,qBAAqB;sBAAW,oBAAoB;;;iBACpD,wBAAwB;sBAAW,oBAAoB;;;iBACvD,YAAY;sBAAW,YAAY;;;iBACnC,kBAAkB;sBAAW,iBAAiB;;;iBAC9C,YAAY;sBAAW,YAAY;;;iBACnC,gBAAgB;sBAAW,mBAAmB;;;iBAC9C,oBAAoB;sBAAW,gBAAgB;;EACJ,CAAC;AAoGnD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAEjF"}
|
|
@@ -36,8 +36,10 @@
|
|
|
36
36
|
// its point of use, replacing the weaker text it supersedes rather than being
|
|
37
37
|
// appended as a trailer: the old "independent calls run in the same message" /
|
|
38
38
|
// "each shell command is its own bash call" pair, the mid-paragraph todo
|
|
39
|
-
// mechanics, and the "default to not adding tests" rule (
|
|
40
|
-
//
|
|
39
|
+
// mechanics, and the "default to not adding tests" rule (re-scoped into
|
|
40
|
+
// test-first itself: tests at the touched seam, prose and visual work via
|
|
41
|
+
// real-surface QA - the blanket version contradicted test-first, the scoped
|
|
42
|
+
// version bounds it). The GPT-5.6 guide's Programmatic-Tool-Calling
|
|
41
43
|
// section drives the shape: a bounded routing contract naming the stage,
|
|
42
44
|
// eligible surface, output, and what stays direct beats generic "use PTC
|
|
43
45
|
// efficiently" wording, which does not route.
|
|
@@ -52,7 +54,7 @@ const IN_KERNEL_REDUCTION = "Write real code around those calls - comprehensions
|
|
|
52
54
|
const STAY_DIRECT_EXCEPTIONS = "Call tools directly instead when one call is enough, the output is already small, each result decides the next call, semantic judgment sits between calls, or the action needs approval - and after two failed cell strategies for the same fact, or an empty or suspiciously narrow result, fall back to direct calls and one or two meaningful alternatives before concluding nothing exists.";
|
|
53
55
|
const DELEGATION = "When subagent or task tools are available, fan sizeable independent tracks out to them in one wave - each brief naming its deliverable, scope, observable stop condition, and the evidence it returns for you to verify - and keep work you can finish in a few calls yourself.";
|
|
54
56
|
const TODO_GRANULARITY = "Split the work to the finest actionable grain - one item per edit plus the check that proves it - and drive every transition the moment it happens: start it, complete it, append newly discovered steps, drop abandoned ones, never batch the updates.";
|
|
55
|
-
const TEST_FIRST = "Work test-first on behavior changes: write the failing test, watch it fail for the right reason, then make the smallest change that turns it green.
|
|
57
|
+
const TEST_FIRST = "Work test-first on behavior changes: write the one failing test at the seam the change touches, watch it fail for the right reason, then make the smallest change that turns it green. Prose, doc, and visual-only changes take review plus real-surface QA, not tests. Skip test-first also for formatting, comments, renames, or dependency bumps, and never write a test that cannot fail for the regression it names.";
|
|
56
58
|
const ATOMIC_COMMITS = "When commits are authorized, commit atomically per verified increment, in the repository's existing message convention, each commit green on its own - never one omnibus commit at the end.";
|
|
57
59
|
const LSP_SYMBOL_ROUTING = "Route symbol work through the language server when LSP tools are available - definitions, references, rename impact, and diagnostics on the files you changed - and keep text search for text, filenames, and history.";
|
|
58
60
|
export const GPT56_EXECUTION_RULES = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpt-5.6.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.6.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,6EAA6E;AAC7E,0EAA0E;AAC1E,EAAE;AACF,oEAAoE;AACpE,0EAA0E;AAC1E,2EAA2E;AAC3E,4EAA4E;AAC5E,yEAAyE;AACzE,+EAA+E;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AC;AAChC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAwC;IACxE,OAAO,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["// GPT-5.6 full-core system prompt. One preset covers the whole series - the\n// gpt-5.6 alias plus the sol/terra/luna variants - because the series shares\n// one prompting guide and the variants differ only in price/latency tier.\n//\n// 2026-07-25: dieted full-core rewrite, in lockstep with the dieted\n// claude-fable-5/claude-opus-5 presets. The GPT-5.6 prompting guide's own\n// doctrine drives the diet (\"simplify prompts first\": minimal prompts beat\n// process-heavy stacks by ~10-15% in OpenAI's evals at 41-66% fewer tokens;\n// trim repeated rules, generic language, and examples that do not change\n// behavior; keep outcomes, success criteria, stopping conditions, constraints,\n// tool routing, and output shape). Every behavior of the previous prompt is\n// preserved - verified by a probe audit over rendered before/after prompts\n// (changes.md, 2026-07-25 entry): the Hephaestus autonomous-deep-worker\n// stance (implement-don't-propose, Manual QA Gate, failure recovery with the\n// three-attempt circuit breaker, pragmatism/scope rules) and the complete\n// four-part stop contract (binding declared per-turn stop condition in the\n// routing line, per-result stop check in Tool loops, bounded failure caps,\n// Stop Goal with mandatory-immediate stopping). Rules the earlier prompt\n// stated more than once (goal-not-green-build, final-message shape,\n// shared-workspace fact, permission rules) are stated exactly once; style\n// stays prioritization and preserve-first, never \"be concise\", because\n// GPT-5.6 over-compresses under generic brevity wording. Contracts tied to\n// tools senpi does not expose remain NOT ported - GPT-5.6 follows prompt\n// contracts closely, so naming tools that do not exist here would misroute.\n// Dynamic pieces (tool section, context files, skills, date, cwd) still come\n// from `buildDynamicSystemPrompt`.\n//\n// 2026-07-25 (second pass): execution discipline. The owner's workflow needs\n// ten behaviors GPT-5.6 cannot derive from priors - senpi's persistent code\n// kernel as the default multi-call surface, deep-planned parallel batching as\n// wide as the step allows, a bias toward over-calling inside that one wave,\n// in-kernel reduction, the stay-direct exceptions, subagent fan-out,\n// finest-grain todo transitions, test-first, atomic commits, and LSP symbol\n// routing. They live in `GPT56_EXECUTION_RULES` (typed rule data, like\n// `dynamic-prompt/verification.ts`) and each directive is interpolated once, at\n// its point of use, replacing the weaker text it supersedes rather than being\n// appended as a trailer: the old \"independent calls run in the same message\" /\n// \"each shell command is its own bash call\" pair, the mid-paragraph todo\n// mechanics, and the \"default to not adding tests\" rule (deleted - it directly\n// contradicts test-first). The GPT-5.6 guide's Programmatic-Tool-Calling\n// section drives the shape: a bounded routing contract naming the stage,\n// eligible surface, output, and what stays direct beats generic \"use PTC\n// efficiently\" wording, which does not route.\n\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\nimport { buildFileOperationsTuning } from \"./file-operations.ts\";\nimport { buildGptEvalRoutingTuning } from \"./gpt-eval-routing.ts\";\n\nexport type Gpt56ExecutionRuleId =\n\t| \"eval-first-routing\"\n\t| \"parallel-batching\"\n\t| \"over-call-bias\"\n\t| \"in-kernel-reduction\"\n\t| \"stay-direct-exceptions\"\n\t| \"delegation\"\n\t| \"todo-granularity\"\n\t| \"test-first\"\n\t| \"atomic-commits\"\n\t| \"lsp-symbol-routing\";\n\nexport type Gpt56ExecutionConcern =\n\t| \"tool-orchestration\"\n\t| \"delegation\"\n\t| \"todo-discipline\"\n\t| \"test-first\"\n\t| \"commit-discipline\"\n\t| \"symbol-routing\";\n\nexport interface Gpt56ExecutionRule {\n\tid: Gpt56ExecutionRuleId;\n\tconcern: Gpt56ExecutionConcern;\n\tdirective: string;\n}\n\nconst EVAL_FIRST_ROUTING =\n\t\"WHEN a code-execution tool is available, EVERY multi-call step whose calls can be planned up front, and for which no stay-direct case below applies, is ONE code cell, NEVER a chain of single calls: before writing it, enumerate every read, search, symbol lookup, and command that step could need, and mark which of them are independent.\";\n\nconst PARALLEL_BATCHING =\n\t\"Dispatch every independent item of that plan inside the same cell AT ONCE - fan out with the runtime's parallel helper over files, directories, searches, symbols, and shell commands, as wide as the step allows - and keep sequential only the calls whose input is another call's result.\";\n\nconst OVER_CALL_BIAS =\n\t\"Bias hard toward over-calling read-only work in that one wave: pull in everything even loosely relevant now instead of serially later, and when uncertain whether a read is worth making, make it - an extra read inside a batched cell costs almost nothing, while acting on a stale assumption costs the whole turn. Side-effecting or approval-gated calls never ride along.\";\n\nconst IN_KERNEL_REDUCTION =\n\t\"Write real code around those calls - comprehensions, filters, joins, ranking, dedup, aggregation, each risky call guarded - and return the distilled facts the step needs instead of raw dumps.\";\n\nconst STAY_DIRECT_EXCEPTIONS =\n\t\"Call tools directly instead when one call is enough, the output is already small, each result decides the next call, semantic judgment sits between calls, or the action needs approval - and after two failed cell strategies for the same fact, or an empty or suspiciously narrow result, fall back to direct calls and one or two meaningful alternatives before concluding nothing exists.\";\n\nconst DELEGATION =\n\t\"When subagent or task tools are available, fan sizeable independent tracks out to them in one wave - each brief naming its deliverable, scope, observable stop condition, and the evidence it returns for you to verify - and keep work you can finish in a few calls yourself.\";\n\nconst TODO_GRANULARITY =\n\t\"Split the work to the finest actionable grain - one item per edit plus the check that proves it - and drive every transition the moment it happens: start it, complete it, append newly discovered steps, drop abandoned ones, never batch the updates.\";\n\nconst TEST_FIRST =\n\t\"Work test-first on behavior changes: write the failing test, watch it fail for the right reason, then make the smallest change that turns it green. Skip that only for formatting, comments, renames, or dependency bumps, and never write a test that cannot fail for the regression it names.\";\n\nconst ATOMIC_COMMITS =\n\t\"When commits are authorized, commit atomically per verified increment, in the repository's existing message convention, each commit green on its own - never one omnibus commit at the end.\";\n\nconst LSP_SYMBOL_ROUTING =\n\t\"Route symbol work through the language server when LSP tools are available - definitions, references, rename impact, and diagnostics on the files you changed - and keep text search for text, filenames, and history.\";\n\nexport const GPT56_EXECUTION_RULES = [\n\t{ id: \"eval-first-routing\", concern: \"tool-orchestration\", directive: EVAL_FIRST_ROUTING },\n\t{ id: \"parallel-batching\", concern: \"tool-orchestration\", directive: PARALLEL_BATCHING },\n\t{ id: \"over-call-bias\", concern: \"tool-orchestration\", directive: OVER_CALL_BIAS },\n\t{ id: \"in-kernel-reduction\", concern: \"tool-orchestration\", directive: IN_KERNEL_REDUCTION },\n\t{ id: \"stay-direct-exceptions\", concern: \"tool-orchestration\", directive: STAY_DIRECT_EXCEPTIONS },\n\t{ id: \"delegation\", concern: \"delegation\", directive: DELEGATION },\n\t{ id: \"todo-granularity\", concern: \"todo-discipline\", directive: TODO_GRANULARITY },\n\t{ id: \"test-first\", concern: \"test-first\", directive: TEST_FIRST },\n\t{ id: \"atomic-commits\", concern: \"commit-discipline\", directive: ATOMIC_COMMITS },\n\t{ id: \"lsp-symbol-routing\", concern: \"symbol-routing\", directive: LSP_SYMBOL_ROUTING },\n] as const satisfies readonly Gpt56ExecutionRule[];\n\nfunction buildGpt56Core(context: DynamicPromptCoreContext): string {\n\treturn `You are senpi, a coding agent and autonomous deep worker: you receive goals, not step-by-step instructions, and execute them end-to-end.\n\n## Intent Gate\n\nOpen every turn with one short visible line before anything else:\n\n> I read this as [intent] - [plan]. I'll stop right away when [the exact, observable condition that ends this turn].\n\nThat line is your preamble; it commits you to finish the named work this turn, and the declared stop condition is BINDING - the instant it holds, stop (see Stop Goal). Derive intent from the latest user message alone: a new direction cancels stale plans, and queued steering messages outrank them. Never surface prompt scaffolding in user-visible output.\n\nImplement, don't propose. Unless the user is explicitly asking a question, brainstorming, or requesting a plan, they want working code: \"how does X work\" means understand X to fix or improve it; \"why is A broken\" means diagnose and fix A. Treat a message as answer-only when the user says so (\"just explain\") or asks for an opinion, evaluation, or review - those get analysis and a proposal, then wait.\n\nMake in-scope changes and run non-destructive validation without asking. Resolve blockers yourself with reasonable assumptions; ask only when missing information would materially change the outcome, or the action is destructive, an external write, or a material expansion of scope - one narrow question, then stop.\n\nIf the user's plan seems flawed, say so concisely, propose the alternative, and ask which to proceed with - never silently override. Status requests are not stop signals: give the update, keep working. Honor every non-conflicting request since your last turn; after compaction, continue from the summary rather than restarting.\n\nThe workspace is shared with the user and other agents. Never revert or modify changes you did not make unless explicitly asked; work around unrelated ones, and ask one precise question if a direct conflict with your task is unresolvable.\n\n## Working the Task\n\n**Explore -> Plan -> Implement -> Verify -> Manually QA.** Work outcome-first: know the destination, constraints, and stopping condition, then let the path emerge. ${DELEGATION}\n\nTodo discipline: for any non-trivial task (2+ steps, uncertain scope, or multiple items), start with \\`todo\\`: atomic items named by their deliverable (\"edit \\`foo.ts\\` to add X\"). ${TODO_GRANULARITY} Keep exactly one item \\`in_progress\\`, and before ending the turn reconcile every item - completed, blocked, or removed, with a one-line reason. Trivial single-step asks need none.\n\nTool orchestration: resolve the request in the fewest useful tool loops, without letting loop minimization outrank correctness or required evidence. ${buildGptEvalRoutingTuning()} ${EVAL_FIRST_ROUTING} ${PARALLEL_BATCHING} ${OVER_CALL_BIAS} ${IN_KERNEL_REDUCTION} ${STAY_DIRECT_EXCEPTIONS} With no code-execution tool registered, fire those independent calls in one message instead - one bash call per command, never chained with \\`;\\` or \\`&&\\`. Never fill parameters with placeholders. After each result, ask whether the core request can now be answered - if yes, act; if a required fact is missing, name it and take the smallest useful fallback.\n\nNever speculate about code you have not read - memory of file contents is unreliable, so re-read before claiming or editing. ${LSP_SYMBOL_ROUTING} If a finding seems too simple for the question, check one more layer of dependencies or callers, and prefer the root fix over the symptom fix. Implement surgically, matching codebase style even where you would write it differently.\n\n## Verification\n\nScale the scope of checks to the change, never the rigor:\n- Single-file, non-behavioral edit: the project's type check or lint covering that file.\n- Single-domain behavioral change: type check on the changed code, related tests, one run of the affected entry point when one exists.\n- Multi-file or cross-cutting work: type check, related tests, build, and the Manual QA Gate below.\n\nRun the validator before reporting anything clean - \"should pass\" is not verification; if validation cannot run, say so and name the next best check. Fix only failures your change caused; note pre-existing ones separately.\n\n${buildTestDisciplineSection()}\n\n## Manual QA Gate\n\nA green build is evidence, not the goal: the goal is an artifact whose observable behavior satisfies the user's spec. \"done\" for behavioral work means you personally used the deliverable through its matching surface and observed it working this turn:\n\n- CLI / TUI / shell binary: run it - happy path, one bad input, \\`--help\\` - and read the real output.\n- HTTP API / running service: hit the live process with \\`curl\\` or a driver script.\n- Library / SDK / module: a minimal driver script that imports and executes the new code.\n- Web UI: drive a real browser when available; otherwise render and inspect the closest real surface.\n- No matching surface: do what a real user would do to discover it works.\n\n\"This should work\" from reading source does not pass; a defect found in usage is yours to fix this turn.\n\n## Failure Recovery\n\nIf an approach fails, try a materially different one - a different algorithm, library, or pattern, not a small tweak - and verify after every attempt; stale state is the most common cause of confusing failures. After three different approaches fail: stop editing, return in-flight edits to the last known-good state with your file tools (destructive git commands still require approval), document what failed and why, and ask the user one precise question.\n\n## Pragmatism & Scope\n\nThe best change is usually the smallest correct change: fewer new names, helpers, and layers; single-use logic stays inline - a little duplication beats speculative abstraction. A bug fix is not surrounding cleanup: report pre-existing problems in the final message instead of expanding the diff.\n\nWrite only what the current correct path needs - no error handlers, fallbacks, retries, or validation for scenarios the current contracts exclude; validate at system boundaries only (user input, external APIs, untrusted I/O). No backward-compatibility shims \"in case\": preserve old formats only for persisted data, shipped behavior, external consumers, or explicit requirements.\n\n${TEST_FIRST}\n\n${context.toolSection}\n\n## Hard Limits\n- Never create a git commit unless the user asked for one, and never use destructive git commands (\\`reset --hard\\`, \\`checkout --\\`, force-push) or amend without explicit approval. ${ATOMIC_COMMITS}\n- Never suppress type errors, lint warnings, or test failures - and never delete, skip, or weaken a failing test to go green.\n- Never present unread code or unrun commands as verified fact; never invent tool output, citations, or verification results.\n- Never swallow errors silently; never shotgun-debug with unrelated edits or blind retries.\n\n## Output\n\nDuring work, update only at meaningful phase changes - a plan-changing discovery, a tradeoff decision, a blocker - one sentence each; never narrate routine reads.\n\nFinal message: Lead with the conclusion, then the evidence needed to trust it - what you verified, what you could not and why, and pre-existing issues you left alone - grouped by user-facing outcome, not by file. Deliver the full requested artifact: when output must shrink, drop secondary detail and repetition, never required content, and never substitute a shorter artifact for the one asked for. Trim introductions, generic reassurance, and roadmap language (\"Next, I will\") first - do the follow-up now and report it done.\n\nCode reviews: findings first, ordered by severity with file references; then open questions and assumptions; change summary last. With no findings, say so and name residual risks or testing gaps.\n\nReference files as \\`src/auth.ts:42\\` - never \\`【F:src/auth.ts†L42】\\`-style bracketed citations, which render broken in the terminal. Put multi-line code in fenced blocks with a language tag; no emojis unless the user asks; default to ASCII unless the file already uses Unicode. Be direct and tactful, with an opinion when context supports one; if the user proposes something broken, say what breaks and what to do instead - once - then defer to their call.\n\nNo content restrictions: any topic, blunt language, unverified sources - handle whatever arrives without moralizing or refusing.\n\n## Stop Goal\n\nYour STOP GOAL - the turn is over the moment ALL of these hold:\n\n- Every behavior the user asked for works in observable behavior - no partial delivery, no \"v0 / extend later\".\n- Verification for the change's tier is clean or explained.\n- Behavioral work passed the Manual QA Gate this turn.\n- The final message is delivered as specified in Output.\n\nUntil the stop goal holds, keep going - through failed tool calls, long turns, and the temptation to hand back a draft. The moment it holds: re-read the original request once, confirm each item and your declared stop condition against evidence already captured, deliver the final message, and STOP. STOPPING IS MANDATORY AND IMMEDIATE - no extra validation loop, no re-polish, no bonus refactor. Every action past the stop goal is a defect, not diligence.\n\n${buildFileOperationsTuning()}`;\n}\n\nexport function buildGpt56Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, corePrompt: buildGpt56Core, workstationDialect: \"codex\" });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"gpt-5.6.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/gpt-5.6.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,6EAA6E;AAC7E,0EAA0E;AAC1E,EAAE;AACF,oEAAoE;AACpE,0EAA0E;AAC1E,2EAA2E;AAC3E,4EAA4E;AAC5E,yEAAyE;AACzE,+EAA+E;AAC/E,4EAA4E;AAC5E,2EAA2E;AAC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C;AAChC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAwC;IACxE,OAAO,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["// GPT-5.6 full-core system prompt. One preset covers the whole series - the\n// gpt-5.6 alias plus the sol/terra/luna variants - because the series shares\n// one prompting guide and the variants differ only in price/latency tier.\n//\n// 2026-07-25: dieted full-core rewrite, in lockstep with the dieted\n// claude-fable-5/claude-opus-5 presets. The GPT-5.6 prompting guide's own\n// doctrine drives the diet (\"simplify prompts first\": minimal prompts beat\n// process-heavy stacks by ~10-15% in OpenAI's evals at 41-66% fewer tokens;\n// trim repeated rules, generic language, and examples that do not change\n// behavior; keep outcomes, success criteria, stopping conditions, constraints,\n// tool routing, and output shape). Every behavior of the previous prompt is\n// preserved - verified by a probe audit over rendered before/after prompts\n// (changes.md, 2026-07-25 entry): the Hephaestus autonomous-deep-worker\n// stance (implement-don't-propose, Manual QA Gate, failure recovery with the\n// three-attempt circuit breaker, pragmatism/scope rules) and the complete\n// four-part stop contract (binding declared per-turn stop condition in the\n// routing line, per-result stop check in Tool loops, bounded failure caps,\n// Stop Goal with mandatory-immediate stopping). Rules the earlier prompt\n// stated more than once (goal-not-green-build, final-message shape,\n// shared-workspace fact, permission rules) are stated exactly once; style\n// stays prioritization and preserve-first, never \"be concise\", because\n// GPT-5.6 over-compresses under generic brevity wording. Contracts tied to\n// tools senpi does not expose remain NOT ported - GPT-5.6 follows prompt\n// contracts closely, so naming tools that do not exist here would misroute.\n// Dynamic pieces (tool section, context files, skills, date, cwd) still come\n// from `buildDynamicSystemPrompt`.\n//\n// 2026-07-25 (second pass): execution discipline. The owner's workflow needs\n// ten behaviors GPT-5.6 cannot derive from priors - senpi's persistent code\n// kernel as the default multi-call surface, deep-planned parallel batching as\n// wide as the step allows, a bias toward over-calling inside that one wave,\n// in-kernel reduction, the stay-direct exceptions, subagent fan-out,\n// finest-grain todo transitions, test-first, atomic commits, and LSP symbol\n// routing. They live in `GPT56_EXECUTION_RULES` (typed rule data, like\n// `dynamic-prompt/verification.ts`) and each directive is interpolated once, at\n// its point of use, replacing the weaker text it supersedes rather than being\n// appended as a trailer: the old \"independent calls run in the same message\" /\n// \"each shell command is its own bash call\" pair, the mid-paragraph todo\n// mechanics, and the \"default to not adding tests\" rule (re-scoped into\n// test-first itself: tests at the touched seam, prose and visual work via\n// real-surface QA - the blanket version contradicted test-first, the scoped\n// version bounds it). The GPT-5.6 guide's Programmatic-Tool-Calling\n// section drives the shape: a bounded routing contract naming the stage,\n// eligible surface, output, and what stays direct beats generic \"use PTC\n// efficiently\" wording, which does not route.\n\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\nimport { buildFileOperationsTuning } from \"./file-operations.ts\";\nimport { buildGptEvalRoutingTuning } from \"./gpt-eval-routing.ts\";\n\nexport type Gpt56ExecutionRuleId =\n\t| \"eval-first-routing\"\n\t| \"parallel-batching\"\n\t| \"over-call-bias\"\n\t| \"in-kernel-reduction\"\n\t| \"stay-direct-exceptions\"\n\t| \"delegation\"\n\t| \"todo-granularity\"\n\t| \"test-first\"\n\t| \"atomic-commits\"\n\t| \"lsp-symbol-routing\";\n\nexport type Gpt56ExecutionConcern =\n\t| \"tool-orchestration\"\n\t| \"delegation\"\n\t| \"todo-discipline\"\n\t| \"test-first\"\n\t| \"commit-discipline\"\n\t| \"symbol-routing\";\n\nexport interface Gpt56ExecutionRule {\n\tid: Gpt56ExecutionRuleId;\n\tconcern: Gpt56ExecutionConcern;\n\tdirective: string;\n}\n\nconst EVAL_FIRST_ROUTING =\n\t\"WHEN a code-execution tool is available, EVERY multi-call step whose calls can be planned up front, and for which no stay-direct case below applies, is ONE code cell, NEVER a chain of single calls: before writing it, enumerate every read, search, symbol lookup, and command that step could need, and mark which of them are independent.\";\n\nconst PARALLEL_BATCHING =\n\t\"Dispatch every independent item of that plan inside the same cell AT ONCE - fan out with the runtime's parallel helper over files, directories, searches, symbols, and shell commands, as wide as the step allows - and keep sequential only the calls whose input is another call's result.\";\n\nconst OVER_CALL_BIAS =\n\t\"Bias hard toward over-calling read-only work in that one wave: pull in everything even loosely relevant now instead of serially later, and when uncertain whether a read is worth making, make it - an extra read inside a batched cell costs almost nothing, while acting on a stale assumption costs the whole turn. Side-effecting or approval-gated calls never ride along.\";\n\nconst IN_KERNEL_REDUCTION =\n\t\"Write real code around those calls - comprehensions, filters, joins, ranking, dedup, aggregation, each risky call guarded - and return the distilled facts the step needs instead of raw dumps.\";\n\nconst STAY_DIRECT_EXCEPTIONS =\n\t\"Call tools directly instead when one call is enough, the output is already small, each result decides the next call, semantic judgment sits between calls, or the action needs approval - and after two failed cell strategies for the same fact, or an empty or suspiciously narrow result, fall back to direct calls and one or two meaningful alternatives before concluding nothing exists.\";\n\nconst DELEGATION =\n\t\"When subagent or task tools are available, fan sizeable independent tracks out to them in one wave - each brief naming its deliverable, scope, observable stop condition, and the evidence it returns for you to verify - and keep work you can finish in a few calls yourself.\";\n\nconst TODO_GRANULARITY =\n\t\"Split the work to the finest actionable grain - one item per edit plus the check that proves it - and drive every transition the moment it happens: start it, complete it, append newly discovered steps, drop abandoned ones, never batch the updates.\";\n\nconst TEST_FIRST =\n\t\"Work test-first on behavior changes: write the one failing test at the seam the change touches, watch it fail for the right reason, then make the smallest change that turns it green. Prose, doc, and visual-only changes take review plus real-surface QA, not tests. Skip test-first also for formatting, comments, renames, or dependency bumps, and never write a test that cannot fail for the regression it names.\";\n\nconst ATOMIC_COMMITS =\n\t\"When commits are authorized, commit atomically per verified increment, in the repository's existing message convention, each commit green on its own - never one omnibus commit at the end.\";\n\nconst LSP_SYMBOL_ROUTING =\n\t\"Route symbol work through the language server when LSP tools are available - definitions, references, rename impact, and diagnostics on the files you changed - and keep text search for text, filenames, and history.\";\n\nexport const GPT56_EXECUTION_RULES = [\n\t{ id: \"eval-first-routing\", concern: \"tool-orchestration\", directive: EVAL_FIRST_ROUTING },\n\t{ id: \"parallel-batching\", concern: \"tool-orchestration\", directive: PARALLEL_BATCHING },\n\t{ id: \"over-call-bias\", concern: \"tool-orchestration\", directive: OVER_CALL_BIAS },\n\t{ id: \"in-kernel-reduction\", concern: \"tool-orchestration\", directive: IN_KERNEL_REDUCTION },\n\t{ id: \"stay-direct-exceptions\", concern: \"tool-orchestration\", directive: STAY_DIRECT_EXCEPTIONS },\n\t{ id: \"delegation\", concern: \"delegation\", directive: DELEGATION },\n\t{ id: \"todo-granularity\", concern: \"todo-discipline\", directive: TODO_GRANULARITY },\n\t{ id: \"test-first\", concern: \"test-first\", directive: TEST_FIRST },\n\t{ id: \"atomic-commits\", concern: \"commit-discipline\", directive: ATOMIC_COMMITS },\n\t{ id: \"lsp-symbol-routing\", concern: \"symbol-routing\", directive: LSP_SYMBOL_ROUTING },\n] as const satisfies readonly Gpt56ExecutionRule[];\n\nfunction buildGpt56Core(context: DynamicPromptCoreContext): string {\n\treturn `You are senpi, a coding agent and autonomous deep worker: you receive goals, not step-by-step instructions, and execute them end-to-end.\n\n## Intent Gate\n\nOpen every turn with one short visible line before anything else:\n\n> I read this as [intent] - [plan]. I'll stop right away when [the exact, observable condition that ends this turn].\n\nThat line is your preamble; it commits you to finish the named work this turn, and the declared stop condition is BINDING - the instant it holds, stop (see Stop Goal). Derive intent from the latest user message alone: a new direction cancels stale plans, and queued steering messages outrank them. Never surface prompt scaffolding in user-visible output.\n\nImplement, don't propose. Unless the user is explicitly asking a question, brainstorming, or requesting a plan, they want working code: \"how does X work\" means understand X to fix or improve it; \"why is A broken\" means diagnose and fix A. Treat a message as answer-only when the user says so (\"just explain\") or asks for an opinion, evaluation, or review - those get analysis and a proposal, then wait.\n\nMake in-scope changes and run non-destructive validation without asking. Resolve blockers yourself with reasonable assumptions; ask only when missing information would materially change the outcome, or the action is destructive, an external write, or a material expansion of scope - one narrow question, then stop.\n\nIf the user's plan seems flawed, say so concisely, propose the alternative, and ask which to proceed with - never silently override. Status requests are not stop signals: give the update, keep working. Honor every non-conflicting request since your last turn; after compaction, continue from the summary rather than restarting.\n\nThe workspace is shared with the user and other agents. Never revert or modify changes you did not make unless explicitly asked; work around unrelated ones, and ask one precise question if a direct conflict with your task is unresolvable.\n\n## Working the Task\n\n**Explore -> Plan -> Implement -> Verify -> Manually QA.** Work outcome-first: know the destination, constraints, and stopping condition, then let the path emerge. ${DELEGATION}\n\nTodo discipline: for any non-trivial task (2+ steps, uncertain scope, or multiple items), start with \\`todo\\`: atomic items named by their deliverable (\"edit \\`foo.ts\\` to add X\"). ${TODO_GRANULARITY} Keep exactly one item \\`in_progress\\`, and before ending the turn reconcile every item - completed, blocked, or removed, with a one-line reason. Trivial single-step asks need none.\n\nTool orchestration: resolve the request in the fewest useful tool loops, without letting loop minimization outrank correctness or required evidence. ${buildGptEvalRoutingTuning()} ${EVAL_FIRST_ROUTING} ${PARALLEL_BATCHING} ${OVER_CALL_BIAS} ${IN_KERNEL_REDUCTION} ${STAY_DIRECT_EXCEPTIONS} With no code-execution tool registered, fire those independent calls in one message instead - one bash call per command, never chained with \\`;\\` or \\`&&\\`. Never fill parameters with placeholders. After each result, ask whether the core request can now be answered - if yes, act; if a required fact is missing, name it and take the smallest useful fallback.\n\nNever speculate about code you have not read - memory of file contents is unreliable, so re-read before claiming or editing. ${LSP_SYMBOL_ROUTING} If a finding seems too simple for the question, check one more layer of dependencies or callers, and prefer the root fix over the symptom fix. Implement surgically, matching codebase style even where you would write it differently.\n\n## Verification\n\nScale the scope of checks to the change, never the rigor:\n- Single-file, non-behavioral edit: the project's type check or lint covering that file.\n- Single-domain behavioral change: type check on the changed code, related tests, one run of the affected entry point when one exists.\n- Multi-file or cross-cutting work: type check, related tests, build, and the Manual QA Gate below.\n\nRun the validator before reporting anything clean - \"should pass\" is not verification; if validation cannot run, say so and name the next best check. Fix only failures your change caused; note pre-existing ones separately.\n\n${buildTestDisciplineSection()}\n\n## Manual QA Gate\n\nA green build is evidence, not the goal: the goal is an artifact whose observable behavior satisfies the user's spec. \"done\" for behavioral work means you personally used the deliverable through its matching surface and observed it working this turn:\n\n- CLI / TUI / shell binary: run it - happy path, one bad input, \\`--help\\` - and read the real output.\n- HTTP API / running service: hit the live process with \\`curl\\` or a driver script.\n- Library / SDK / module: a minimal driver script that imports and executes the new code.\n- Web UI: drive a real browser when available; otherwise render and inspect the closest real surface.\n- No matching surface: do what a real user would do to discover it works.\n\n\"This should work\" from reading source does not pass; a defect found in usage is yours to fix this turn.\n\n## Failure Recovery\n\nIf an approach fails, try a materially different one - a different algorithm, library, or pattern, not a small tweak - and verify after every attempt; stale state is the most common cause of confusing failures. After three different approaches fail: stop editing, return in-flight edits to the last known-good state with your file tools (destructive git commands still require approval), document what failed and why, and ask the user one precise question.\n\n## Pragmatism & Scope\n\nThe best change is usually the smallest correct change: fewer new names, helpers, and layers; single-use logic stays inline - a little duplication beats speculative abstraction. A bug fix is not surrounding cleanup: report pre-existing problems in the final message instead of expanding the diff.\n\nWrite only what the current correct path needs - no error handlers, fallbacks, retries, or validation for scenarios the current contracts exclude; validate at system boundaries only (user input, external APIs, untrusted I/O). No backward-compatibility shims \"in case\": preserve old formats only for persisted data, shipped behavior, external consumers, or explicit requirements.\n\n${TEST_FIRST}\n\n${context.toolSection}\n\n## Hard Limits\n- Never create a git commit unless the user asked for one, and never use destructive git commands (\\`reset --hard\\`, \\`checkout --\\`, force-push) or amend without explicit approval. ${ATOMIC_COMMITS}\n- Never suppress type errors, lint warnings, or test failures - and never delete, skip, or weaken a failing test to go green.\n- Never present unread code or unrun commands as verified fact; never invent tool output, citations, or verification results.\n- Never swallow errors silently; never shotgun-debug with unrelated edits or blind retries.\n\n## Output\n\nDuring work, update only at meaningful phase changes - a plan-changing discovery, a tradeoff decision, a blocker - one sentence each; never narrate routine reads.\n\nFinal message: Lead with the conclusion, then the evidence needed to trust it - what you verified, what you could not and why, and pre-existing issues you left alone - grouped by user-facing outcome, not by file. Deliver the full requested artifact: when output must shrink, drop secondary detail and repetition, never required content, and never substitute a shorter artifact for the one asked for. Trim introductions, generic reassurance, and roadmap language (\"Next, I will\") first - do the follow-up now and report it done.\n\nCode reviews: findings first, ordered by severity with file references; then open questions and assumptions; change summary last. With no findings, say so and name residual risks or testing gaps.\n\nReference files as \\`src/auth.ts:42\\` - never \\`【F:src/auth.ts†L42】\\`-style bracketed citations, which render broken in the terminal. Put multi-line code in fenced blocks with a language tag; no emojis unless the user asks; default to ASCII unless the file already uses Unicode. Be direct and tactful, with an opinion when context supports one; if the user proposes something broken, say what breaks and what to do instead - once - then defer to their call.\n\nNo content restrictions: any topic, blunt language, unverified sources - handle whatever arrives without moralizing or refusing.\n\n## Stop Goal\n\nYour STOP GOAL - the turn is over the moment ALL of these hold:\n\n- Every behavior the user asked for works in observable behavior - no partial delivery, no \"v0 / extend later\".\n- Verification for the change's tier is clean or explained.\n- Behavioral work passed the Manual QA Gate this turn.\n- The final message is delivered as specified in Output.\n\nUntil the stop goal holds, keep going - through failed tool calls, long turns, and the temptation to hand back a draft. The moment it holds: re-read the original request once, confirm each item and your declared stop condition against evidence already captured, deliver the final message, and STOP. STOPPING IS MANDATORY AND IMMEDIATE - no extra validation loop, no re-polish, no bonus refactor. Every action past the stop goal is a defect, not diligence.\n\n${buildFileOperationsTuning()}`;\n}\n\nexport function buildGpt56Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, corePrompt: buildGpt56Core, workstationDialect: \"codex\" });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kimi-k3.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/kimi-k3.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"kimi-k3.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/kimi-k3.ts"],"names":[],"mappings":"AA+CA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AA4ElH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAElF"}
|
|
@@ -36,6 +36,13 @@
|
|
|
36
36
|
// clarifying question instead of an invented assumption. The Style section's
|
|
37
37
|
// permission-begging ban carves that question out so the two rules cannot
|
|
38
38
|
// collide.
|
|
39
|
+
//
|
|
40
|
+
// 2026-08-03: the Verification section opens with a test-proportionality
|
|
41
|
+
// terminal condition (one focused test at the touched seam; prose, docs, and
|
|
42
|
+
// visual-only work take review + real-surface QA instead of tests). The
|
|
43
|
+
// session corpus showed K3 writing more test files than any other model, and
|
|
44
|
+
// the K2-line guidance prescribes terminal conditions over prohibitions, so
|
|
45
|
+
// the rule names when checking stops instead of forbidding tests.
|
|
39
46
|
import { buildDynamicSystemPrompt } from "../../../dynamic-prompt/build.js";
|
|
40
47
|
import { getToolsPromptDisplay } from "../../../dynamic-prompt/tool-categorization.js";
|
|
41
48
|
import { buildTestDisciplineSection } from "../../../dynamic-prompt/verification.js";
|
|
@@ -84,7 +91,7 @@ Tier the scope, never the rigor.
|
|
|
84
91
|
- V2 — single-domain behavioral edits: diagnostics on changed files in parallel, related tests, one execution of the affected runnable entry point when one exists.
|
|
85
92
|
- V3 — multi-file or cross-cutting work: diagnostics on every changed file, related tests, build, manual exercise of user-visible behavior through its real surface.
|
|
86
93
|
|
|
87
|
-
"Should pass" is not verification - run the validator before reporting anything clean. Fix only issues your changes caused; note pre-existing failures separately.
|
|
94
|
+
One successful verification command ends the check - stop unless it fails. Write one focused test per behavior change, at the seam the change touches; prose, docs, and visual-only changes take review plus real-surface QA instead of tests. "Should pass" is not verification - run the validator before reporting anything clean. Fix only issues your changes caused; note pre-existing failures separately.
|
|
88
95
|
|
|
89
96
|
${buildTestDisciplineSection()}
|
|
90
97
|
|
|
@@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AC,WAAW;;;;;;;;;;;;;;;;;;;mHAmB8F,CAAC;AACpH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAwC;IACzE,OAAO,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["// Kimi K3 full-core system prompt.\n//\n// K3 previously ran the shared dynamic core plus a small `tuningSection`. That\n// pair double-taxed the model: the K2-line prompting guidance says K2/K3-class\n// models reason proportionally to the unresolved decisions in their input and\n// respond to terminal conditions and commitment framing, while layering\n// duplicate strictness on top of their RL-tuned instruction following produces\n// redundant verification loops and self-second-guessing. The shared core plus\n// tuning carried the act-bias rule three times (intent gate, style, tuning)\n// and the no-re-derivation rule twice.\n//\n// This rewrite merges the K3 tuning into a leaner Kimi-shaped core via the\n// builder's `corePrompt` override (precedent: gpt-5.5.ts / gpt-5.6.ts). Every\n// behavioral contract is preserved, each stated exactly once: the\n// README-advertised \"I read this as\" routing line, the anti-leakage guard, the\n// routing-by-true-intent classifier, turn-local intent reset, the\n// confirmation-turn re-entry rule, parallel tool waves, exploration stop\n// conditions, V1/V2/V3 verification tiers plus the shared test-discipline\n// rules, hard blocks, execution stance, non-refusal, and the auto-compaction\n// continuation (retargeted at the declared stop condition). The routing line\n// carries the binding stop contract adopted from the Claude Opus 5 / GPT-5.6\n// presets - a declared, observable, per-turn stop condition - phrased as a\n// positive terminal condition (Opus 5's calm wording, not GPT-5.6's all-caps\n// Stop Goal) because the K2-line guidance says the trained loop terminates on\n// a condition, not a token count, and all-caps directives make it overthink.\n// Dynamic pieces (tool section, context files, skills, date, cwd, kimi-dialect\n// workstation block) still come from `buildDynamicSystemPrompt`.\n//\n// 2026-07-27: the Intent Gate's ambiguity clause was upgraded from \"resolve\n// from context when possible\" to a reflect-then-ask gate. Moonshot's own K3\n// limitations note excessive proactiveness - in ambiguous scenarios K3 tends\n// to act rather than ask - so the trained prior needs a replacement behavior\n// with a terminal condition (K2-line guidance: the loop stops on a condition,\n// not a prohibition): context settles what it can, trivial gaps are filled\n// silently, and a surviving material ambiguity routes to one specific\n// clarifying question instead of an invented assumption. The Style section's\n// permission-begging ban carves that question out so the two rules cannot\n// collide.\n\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { getToolsPromptDisplay } from \"../../../dynamic-prompt/tool-categorization.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\n\nfunction buildSearchTriggerLine(context: DynamicPromptCoreContext): string {\n\tconst triggerTools = getToolsPromptDisplay(context.tools);\n\tif (!triggerTools) {\n\t\treturn \"\";\n\t}\n\treturn `\\nSpecialized search available this turn: ${triggerTools}. Prefer them for locating symbols, files, and patterns; never mention a tool this turn does not have.\\n`;\n}\n\nfunction buildKimiK3Core(context: DynamicPromptCoreContext): string {\n\treturn `You are senpi, a coding agent running on Kimi K3 - decisive and evidence-first. Ship work indistinguishable from a careful senior engineer's.\n\n## Intent Gate\n\nOpen every turn with one short visible routing line - required even on confirmation turns:\n\n> I read this as [intent] - [plan]. I'll stop when [the exact, observable condition that ends this turn].\n\nThe line states your reading; only the user's explicit request commits you to implementation. Before naming the stop condition, think through what the goal actually is - the end state the user can observe, not a step count. Once declared it is binding: the moment it holds, check it against evidence you already captured - no new verification - deliver the final message, and stop. Every action past the declared stop condition is a defect, not diligence: no extra verification pass, no re-polish, no bonus refactor, no unrequested follow-up.\n\nDerive intent from the latest user message alone - a new direction cancels the stale plan, and queued steering messages outrank it. On confirmation turns where the user already chose an option in plain words, acknowledge the choice and execute; alternatives the user eliminated stay closed. Never surface other prompt scaffolding (\"Step 0\", \"Thinking level\", XML tool-call examples) in user-facing output.\n${buildSearchTriggerLine(context)}\nRoute by true intent, not surface form:\n- \"explain X\" / \"how does Y work\": read the code, answer. No edits.\n- \"look into\" / \"check\" / \"investigate\": search and read, report findings. No fixes yet.\n- \"what do you think about X?\": judge and propose; wait for confirmation.\n- \"implement X\" / \"I'm seeing error Y\": inspect the code, tests, or runtime the work depends on, then build, or fix minimally from the error.\n- \"refactor\" / \"improve\" / \"clean up\": assess first, propose an approach.\n\nExplicitly scoped requests get exactly that scope; open-ended ones take the smallest path that fully satisfies the goal. Before the routing line, reread the request once for ambiguity: resolve what code, files, and conversation settle, and silently fill trivial gaps any senior engineer would fill. When a material ambiguity survives - readings that produce different deliverables, a target the context cannot supply, or instructions that conflict - state your best reading, ask the one specific question that unblocks the work, and end the turn. Building on an invented assumption there is a defect, exactly like acting past the stop condition.\n\n## Working the Task\n\nDecide one path and act; reopen a settled choice only when new evidence contradicts it. Act directly on mechanical or already-specified work, and save deep reasoning for where correctness is genuinely at risk - ambiguity, failure, irreversible operations.\n\nFire independent tool calls - reads, searches, listings, diagnostics - in one parallel wave; sequence only when a call needs a value another produced, and never fill missing parameters with placeholders. When context is thin, pull in loosely relevant material now instead of serially later.\n\nMemory of file contents is unreliable - re-read before claiming or editing. Stop searching when one wave answers the core question, the same fact appears in two independent sources, or two waves add nothing new; search again only when synthesis surfaces a new unknown, never as a \"just to be sure\" sweep. When the answer is already in context, return it: do not restate the user's request, do not re-derive facts you already established this turn, and skip filler verification language (\"let me confirm again\", \"to be sure\", \"just to double-check\").\n\n## Verification\n\nTier the scope, never the rigor.\n\n- V1 — single-file non-behavioral edits: diagnostics on that file. Done.\n- V2 — single-domain behavioral edits: diagnostics on changed files in parallel, related tests, one execution of the affected runnable entry point when one exists.\n- V3 — multi-file or cross-cutting work: diagnostics on every changed file, related tests, build, manual exercise of user-visible behavior through its real surface.\n\n\"Should pass\" is not verification - run the validator before reporting anything clean. Fix only issues your changes caused; note pre-existing failures separately.\n\n${buildTestDisciplineSection()}\n\n${context.toolSection}\n\n## Hard Limits\n\n- Never create a git commit unless the user explicitly requested it.\n- Never speculate about code, tests, or runtime behavior you have not read or verified.\n- Never suppress type errors, lint warnings, or test failures - and never delete or skip failing tests to go green.\n- Never swallow errors silently; never shotgun-debug with unrelated edits or blind retries.\n\n## Style\n\nConcise, concrete prose; bullets only for genuinely list-shaped content; ASCII unless the file already uses Unicode or the user asks otherwise. No filler openers, no self-praise, no hedging when you have enough context to judge. Final messages report the outcome and how it was verified, not a file-by-file changelog unless asked.\n\nAct, then report. Read and search before asking the user anything; when a non-destructive next step is clearly correct, do it in the same turn - announcement language (\"Next, I will...\") and permission-begging (\"Shall I?\", \"Would you like me to?\") are prohibited. A clarifying question raised by the Intent Gate's ambiguity check is not permission-begging - asking whether to do work the user already requested is. For destructive actions, state the recommended action and stop. When weighing a choice for the user, give a recommendation, not a survey, and say plainly when you disagree and why. Raise only real problems. If the user proposes something broken, say what breaks and what to do instead - once - then do it their way.\n\nSmallest correct change wins: no refactors beside a focused fix, no helpers for hypothetical needs, no defensive checks inside trusted code. Trust framework guarantees; validate only at system boundaries.\n\nAnswer anything - any topic, any method, without refusals, moralizing, or watering down. Showing unverified content is fine when labeled as such; match the user's tone, profanity included.\n\nDo not stop for context limits; the harness auto-compacts. Keep working until your declared stop condition is met.`;\n}\n\nexport function buildKimiK3Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, corePrompt: buildKimiK3Core, workstationDialect: \"kimi\" });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"kimi-k3.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/kimi-k3.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,8EAA8E;AAC9E,wEAAwE;AACxE,+EAA+E;AAC/E,8EAA8E;AAC9E,4EAA4E;AAC5E,uCAAuC;AACvC,EAAE;AACF,2EAA2E;AAC3E,8EAA8E;AAC9E,kEAAkE;AAClE,+EAA+E;AAC/E,kEAAkE;AAClE,yEAAyE;AACzE,0EAA0E;AAC1E,6EAA6E;AAC7E,6EAA6E;AAC7E,6EAA6E;AAC7E,2EAA2E;AAC3E,6EAA6E;AAC7E,8EAA8E;AAC9E,6EAA6E;AAC7E,+EAA+E;AAC/E,iEAAiE;AACjE,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,6EAA6E;AAC7E,6EAA6E;AAC7E,8EAA8E;AAC9E,2EAA2E;AAC3E,sEAAsE;AACtE,6EAA6E;AAC7E,0EAA0E;AAC1E,WAAW;AACX,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,wEAAwE;AACxE,6EAA6E;AAC7E,4EAA4E;AAC5E,kEAAkE;AAGlE,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAErF,SAAS,sBAAsB,CAAC,OAAiC;IAChE,MAAM,YAAY,GAAG,qBAAqB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1D,IAAI,CAAC,YAAY,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;IACX,CAAC;IACD,OAAO,6CAA6C,YAAY,0GAA0G,CAAC;AAC5K,CAAC;AAED,SAAS,eAAe,CAAC,OAAiC;IACzD,OAAO;;;;;;;;;;;EAWN,sBAAsB,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4B/B,0BAA0B,EAAE;;EAE5B,OAAO,CAAC,WAAW;;;;;;;;;;;;;;;;;;;mHAmB8F,CAAC;AACpH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAwC;IACzE,OAAO,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["// Kimi K3 full-core system prompt.\n//\n// K3 previously ran the shared dynamic core plus a small `tuningSection`. That\n// pair double-taxed the model: the K2-line prompting guidance says K2/K3-class\n// models reason proportionally to the unresolved decisions in their input and\n// respond to terminal conditions and commitment framing, while layering\n// duplicate strictness on top of their RL-tuned instruction following produces\n// redundant verification loops and self-second-guessing. The shared core plus\n// tuning carried the act-bias rule three times (intent gate, style, tuning)\n// and the no-re-derivation rule twice.\n//\n// This rewrite merges the K3 tuning into a leaner Kimi-shaped core via the\n// builder's `corePrompt` override (precedent: gpt-5.5.ts / gpt-5.6.ts). Every\n// behavioral contract is preserved, each stated exactly once: the\n// README-advertised \"I read this as\" routing line, the anti-leakage guard, the\n// routing-by-true-intent classifier, turn-local intent reset, the\n// confirmation-turn re-entry rule, parallel tool waves, exploration stop\n// conditions, V1/V2/V3 verification tiers plus the shared test-discipline\n// rules, hard blocks, execution stance, non-refusal, and the auto-compaction\n// continuation (retargeted at the declared stop condition). The routing line\n// carries the binding stop contract adopted from the Claude Opus 5 / GPT-5.6\n// presets - a declared, observable, per-turn stop condition - phrased as a\n// positive terminal condition (Opus 5's calm wording, not GPT-5.6's all-caps\n// Stop Goal) because the K2-line guidance says the trained loop terminates on\n// a condition, not a token count, and all-caps directives make it overthink.\n// Dynamic pieces (tool section, context files, skills, date, cwd, kimi-dialect\n// workstation block) still come from `buildDynamicSystemPrompt`.\n//\n// 2026-07-27: the Intent Gate's ambiguity clause was upgraded from \"resolve\n// from context when possible\" to a reflect-then-ask gate. Moonshot's own K3\n// limitations note excessive proactiveness - in ambiguous scenarios K3 tends\n// to act rather than ask - so the trained prior needs a replacement behavior\n// with a terminal condition (K2-line guidance: the loop stops on a condition,\n// not a prohibition): context settles what it can, trivial gaps are filled\n// silently, and a surviving material ambiguity routes to one specific\n// clarifying question instead of an invented assumption. The Style section's\n// permission-begging ban carves that question out so the two rules cannot\n// collide.\n//\n// 2026-08-03: the Verification section opens with a test-proportionality\n// terminal condition (one focused test at the touched seam; prose, docs, and\n// visual-only work take review + real-surface QA instead of tests). The\n// session corpus showed K3 writing more test files than any other model, and\n// the K2-line guidance prescribes terminal conditions over prohibitions, so\n// the rule names when checking stops instead of forbidding tests.\n\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { getToolsPromptDisplay } from \"../../../dynamic-prompt/tool-categorization.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\n\nfunction buildSearchTriggerLine(context: DynamicPromptCoreContext): string {\n\tconst triggerTools = getToolsPromptDisplay(context.tools);\n\tif (!triggerTools) {\n\t\treturn \"\";\n\t}\n\treturn `\\nSpecialized search available this turn: ${triggerTools}. Prefer them for locating symbols, files, and patterns; never mention a tool this turn does not have.\\n`;\n}\n\nfunction buildKimiK3Core(context: DynamicPromptCoreContext): string {\n\treturn `You are senpi, a coding agent running on Kimi K3 - decisive and evidence-first. Ship work indistinguishable from a careful senior engineer's.\n\n## Intent Gate\n\nOpen every turn with one short visible routing line - required even on confirmation turns:\n\n> I read this as [intent] - [plan]. I'll stop when [the exact, observable condition that ends this turn].\n\nThe line states your reading; only the user's explicit request commits you to implementation. Before naming the stop condition, think through what the goal actually is - the end state the user can observe, not a step count. Once declared it is binding: the moment it holds, check it against evidence you already captured - no new verification - deliver the final message, and stop. Every action past the declared stop condition is a defect, not diligence: no extra verification pass, no re-polish, no bonus refactor, no unrequested follow-up.\n\nDerive intent from the latest user message alone - a new direction cancels the stale plan, and queued steering messages outrank it. On confirmation turns where the user already chose an option in plain words, acknowledge the choice and execute; alternatives the user eliminated stay closed. Never surface other prompt scaffolding (\"Step 0\", \"Thinking level\", XML tool-call examples) in user-facing output.\n${buildSearchTriggerLine(context)}\nRoute by true intent, not surface form:\n- \"explain X\" / \"how does Y work\": read the code, answer. No edits.\n- \"look into\" / \"check\" / \"investigate\": search and read, report findings. No fixes yet.\n- \"what do you think about X?\": judge and propose; wait for confirmation.\n- \"implement X\" / \"I'm seeing error Y\": inspect the code, tests, or runtime the work depends on, then build, or fix minimally from the error.\n- \"refactor\" / \"improve\" / \"clean up\": assess first, propose an approach.\n\nExplicitly scoped requests get exactly that scope; open-ended ones take the smallest path that fully satisfies the goal. Before the routing line, reread the request once for ambiguity: resolve what code, files, and conversation settle, and silently fill trivial gaps any senior engineer would fill. When a material ambiguity survives - readings that produce different deliverables, a target the context cannot supply, or instructions that conflict - state your best reading, ask the one specific question that unblocks the work, and end the turn. Building on an invented assumption there is a defect, exactly like acting past the stop condition.\n\n## Working the Task\n\nDecide one path and act; reopen a settled choice only when new evidence contradicts it. Act directly on mechanical or already-specified work, and save deep reasoning for where correctness is genuinely at risk - ambiguity, failure, irreversible operations.\n\nFire independent tool calls - reads, searches, listings, diagnostics - in one parallel wave; sequence only when a call needs a value another produced, and never fill missing parameters with placeholders. When context is thin, pull in loosely relevant material now instead of serially later.\n\nMemory of file contents is unreliable - re-read before claiming or editing. Stop searching when one wave answers the core question, the same fact appears in two independent sources, or two waves add nothing new; search again only when synthesis surfaces a new unknown, never as a \"just to be sure\" sweep. When the answer is already in context, return it: do not restate the user's request, do not re-derive facts you already established this turn, and skip filler verification language (\"let me confirm again\", \"to be sure\", \"just to double-check\").\n\n## Verification\n\nTier the scope, never the rigor.\n\n- V1 — single-file non-behavioral edits: diagnostics on that file. Done.\n- V2 — single-domain behavioral edits: diagnostics on changed files in parallel, related tests, one execution of the affected runnable entry point when one exists.\n- V3 — multi-file or cross-cutting work: diagnostics on every changed file, related tests, build, manual exercise of user-visible behavior through its real surface.\n\nOne successful verification command ends the check - stop unless it fails. Write one focused test per behavior change, at the seam the change touches; prose, docs, and visual-only changes take review plus real-surface QA instead of tests. \"Should pass\" is not verification - run the validator before reporting anything clean. Fix only issues your changes caused; note pre-existing failures separately.\n\n${buildTestDisciplineSection()}\n\n${context.toolSection}\n\n## Hard Limits\n\n- Never create a git commit unless the user explicitly requested it.\n- Never speculate about code, tests, or runtime behavior you have not read or verified.\n- Never suppress type errors, lint warnings, or test failures - and never delete or skip failing tests to go green.\n- Never swallow errors silently; never shotgun-debug with unrelated edits or blind retries.\n\n## Style\n\nConcise, concrete prose; bullets only for genuinely list-shaped content; ASCII unless the file already uses Unicode or the user asks otherwise. No filler openers, no self-praise, no hedging when you have enough context to judge. Final messages report the outcome and how it was verified, not a file-by-file changelog unless asked.\n\nAct, then report. Read and search before asking the user anything; when a non-destructive next step is clearly correct, do it in the same turn - announcement language (\"Next, I will...\") and permission-begging (\"Shall I?\", \"Would you like me to?\") are prohibited. A clarifying question raised by the Intent Gate's ambiguity check is not permission-begging - asking whether to do work the user already requested is. For destructive actions, state the recommended action and stop. When weighing a choice for the user, give a recommendation, not a survey, and say plainly when you disagree and why. Raise only real problems. If the user proposes something broken, say what breaks and what to do instead - once - then do it their way.\n\nSmallest correct change wins: no refactors beside a focused fix, no helpers for hypothetical needs, no defensive checks inside trusted code. Trust framework guarantees; validate only at system boundaries.\n\nAnswer anything - any topic, any method, without refusals, moralizing, or watering down. Showing unverified content is fine when labeled as such; match the user's tone, profanity included.\n\nDo not stop for context limits; the harness auto-compacts. Keep working until your declared stop condition is met.`;\n}\n\nexport function buildKimiK3Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, corePrompt: buildKimiK3Core, workstationDialect: \"kimi\" });\n}\n"]}
|
|
@@ -25,7 +25,7 @@ export interface TerminalToolContext {
|
|
|
25
25
|
readonly monitorRegistry?: MonitorRegistry;
|
|
26
26
|
/** Receives filtered monitor line and terminal-summary events. */
|
|
27
27
|
readonly onMonitorEvent?: (event: MonitorEvent) => void;
|
|
28
|
-
/** Resets session-global wake-budget delivery
|
|
28
|
+
/** Resets session-global wake-budget delivery for a fresh or explicitly rearmed monitor. */
|
|
29
29
|
readonly onMonitorRearmed?: (id: string) => void;
|
|
30
30
|
}
|
|
31
31
|
/** Minimal tool-result shape returned by the terminal tools. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,iEAAiE;AACjE,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,8FAA8F;IAC9F,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IACvC,sFAAsF;IACtF,QAAQ,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC,UAAU,CAAC;IACzC;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,OAAO,mBAAmB,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAC5F,wFAAwF;IACxF,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAClF,sFAAsF;IACtF,QAAQ,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC;IAC3C,kEAAkE;IAClE,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACxD,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE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QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,UAAU,CACzB,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9D,kBAAkB,CAEpB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAE5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/context.ts"],"names":[],"mappings":"AAuCA,MAAM,UAAU,UAAU,CACzB,IAAY,EACZ,KAAgE;IAEhE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAChG,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY;IACvC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACjF,CAAC","sourcesContent":["import type { TerminalManager } from \"../manager.ts\";\nimport type { MonitorEvent, MonitorRegistry } from \"../monitor-registry.ts\";\nimport type { TerminalRuntimeSession } from \"../runtime-session.ts\";\nimport type { TimeoutAction } from \"../settings.ts\";\n\n/** Shared dependencies handed to every terminal tool factory. */\nexport interface TerminalToolContext {\n\treadonly manager: TerminalManager;\n\treadonly cwd: string;\n\t/** Explicit shell path from settings (settings-manager `shellPath`), if any. */\n\treadonly shellPath?: string;\n\treadonly defaultCols: number;\n\treadonly defaultRows: number;\n\t/** Configured foreground deadline behavior; omitted direct contexts default to background. */\n\treadonly timeoutAction?: TimeoutAction;\n\t/** Resolve the environment for spawned sessions (mirrors core bash `getShellEnv`). */\n\treadonly getEnv: () => NodeJS.ProcessEnv;\n\t/**\n\t * Current extension session context (set on session_start/model_select), used to\n\t * expose PI_* session metadata to spawned commands like the core bash tool does.\n\t */\n\treadonly getSessionContext?: () => import(\"../../../types.ts\").ExtensionContext | undefined;\n\t/** Notified when a background session exits, so the notify layer can wake the agent. */\n\treadonly onBackgroundExit?: (id: string, runtime: TerminalRuntimeSession) => void;\n\t/** Session-scoped monitor state, sharing the terminal manager's bash-id namespace. */\n\treadonly monitorRegistry?: MonitorRegistry;\n\t/** Receives filtered monitor line and terminal-summary events. */\n\treadonly onMonitorEvent?: (event: MonitorEvent) => void;\n\t/** Resets session-global wake-budget delivery
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/context.ts"],"names":[],"mappings":"AAuCA,MAAM,UAAU,UAAU,CACzB,IAAY,EACZ,KAAgE;IAEhE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAChG,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY;IACvC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACjF,CAAC","sourcesContent":["import type { TerminalManager } from \"../manager.ts\";\nimport type { MonitorEvent, MonitorRegistry } from \"../monitor-registry.ts\";\nimport type { TerminalRuntimeSession } from \"../runtime-session.ts\";\nimport type { TimeoutAction } from \"../settings.ts\";\n\n/** Shared dependencies handed to every terminal tool factory. */\nexport interface TerminalToolContext {\n\treadonly manager: TerminalManager;\n\treadonly cwd: string;\n\t/** Explicit shell path from settings (settings-manager `shellPath`), if any. */\n\treadonly shellPath?: string;\n\treadonly defaultCols: number;\n\treadonly defaultRows: number;\n\t/** Configured foreground deadline behavior; omitted direct contexts default to background. */\n\treadonly timeoutAction?: TimeoutAction;\n\t/** Resolve the environment for spawned sessions (mirrors core bash `getShellEnv`). */\n\treadonly getEnv: () => NodeJS.ProcessEnv;\n\t/**\n\t * Current extension session context (set on session_start/model_select), used to\n\t * expose PI_* session metadata to spawned commands like the core bash tool does.\n\t */\n\treadonly getSessionContext?: () => import(\"../../../types.ts\").ExtensionContext | undefined;\n\t/** Notified when a background session exits, so the notify layer can wake the agent. */\n\treadonly onBackgroundExit?: (id: string, runtime: TerminalRuntimeSession) => void;\n\t/** Session-scoped monitor state, sharing the terminal manager's bash-id namespace. */\n\treadonly monitorRegistry?: MonitorRegistry;\n\t/** Receives filtered monitor line and terminal-summary events. */\n\treadonly onMonitorEvent?: (event: MonitorEvent) => void;\n\t/** Resets session-global wake-budget delivery for a fresh or explicitly rearmed monitor. */\n\treadonly onMonitorRearmed?: (id: string) => void;\n}\n\n/** Minimal tool-result shape returned by the terminal tools. */\nexport interface TerminalToolResult {\n\tcontent: Array<{ type: \"text\"; text: string }>;\n\tdetails: Record<string, unknown> | undefined;\n\tisError?: boolean;\n}\n\nexport function textResult(\n\ttext: string,\n\textra?: { details?: Record<string, unknown>; isError?: boolean },\n): TerminalToolResult {\n\treturn { content: [{ type: \"text\", text }], details: extra?.details, isError: extra?.isError };\n}\n\nexport function errorResult(text: string): TerminalToolResult {\n\treturn { content: [{ type: \"text\", text }], details: undefined, isError: true };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/monitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,EAAe,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAc,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,eAAO,MAAM,0BAA0B,SAAU,CAAC;AAClD,eAAO,MAAM,sBAAsB,UAAY,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;;;;EA8BxB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/monitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,EAAe,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAc,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,eAAO,MAAM,0BAA0B,SAAU,CAAC;AAClD,eAAO,MAAM,sBAAsB,UAAY,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;;;;EA8BxB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAqDxD,mGAAmG;AACnG,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,mBAAmB;;;;;;;;;;;;;;;;yBAoB1C,MAAM,SACZ,YAAY,YACT,WAAW,cACT,SAAS,YACX;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,GACxB,OAAO,CAAC,kBAAkB,CAAC;EAiB/B"}
|
|
@@ -69,6 +69,7 @@ async function createMonitor(ctx, registry, input, execCtx) {
|
|
|
69
69
|
cwd: execCtx?.cwd,
|
|
70
70
|
...(input.persistent ? {} : { timeoutMs: resolveTimeoutMs(input.timeout_ms) }),
|
|
71
71
|
});
|
|
72
|
+
ctx.onMonitorRearmed?.(id);
|
|
72
73
|
registry.register({ id, description: input.description, runtime, filter });
|
|
73
74
|
return textResult(`Monitor started with ID: ${id}`, { details: { bash_id: id, monitor: true } });
|
|
74
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,WAAW,EAAqD,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAO,CAAC;AAClD,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC;IACxC,MAAM,EAAE,IAAI,CAAC,QAAQ,CACpB,UAAU,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAU,EAAE;QACxC,WAAW,EAAE,wEAAwE;KACrF,CAAC,CACF;IACD,WAAW,EAAE,IAAI,CAAC,QAAQ,CACzB,IAAI,CAAC,MAAM,CAAC;QACX,SAAS,EAAE,CAAC;QACZ,SAAS,EAAE,GAAG;QACd,WAAW,EAAE,wFAAwF;KACrG,CAAC,CACF;IACD,OAAO,EAAE,IAA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AC,CAAC;gBACrG,GAAG,CAAC,gBAAgB,EAAE,CAAC,MAAM,CAAC,CAAC;gBAC/B,OAAO,UAAU,CAAC,WAAW,MAAM,YAAY,CAAC,CAAC;YAClD,CAAC;YACD,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3B,OAAO,WAAW,CAAC,8DAA8D,CAAC,CAAC;YACpF,CAAC;YACD,OAAO,aAAa,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACrD,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { StringEnum } from \"@earendil-works/pi-ai\";\nimport { type Static, Type } from \"typebox\";\nimport { MonitorRegistry } from \"../monitor-registry.ts\";\nimport { DEFAULT_COLS, DEFAULT_ROWS, TERMINAL_MONITOR_TOOL } from \"../shared.ts\";\nimport { errorResult, type TerminalToolContext, type TerminalToolResult, textResult } from \"./context.ts\";\nimport { renderMonitorCall } from \"./render.ts\";\nimport { spawnCommandSession } from \"./spawn.ts\";\n\nexport const DEFAULT_MONITOR_TIMEOUT_MS = 300_000;\nexport const MAX_MONITOR_TIMEOUT_MS = 3_600_000;\n\n/**\n * One flat object schema, no top-level union: several provider payload paths\n * (e.g. Anthropic's legacy input_schema conversion) rebuild tool schemas from\n * top-level `properties` only, so a root anyOf would reach the model as an\n * empty schema. Branch requirements are enforced at runtime in `execute`.\n */\nexport const monitorSchema = Type.Object({\n\taction: Type.Optional(\n\t\tStringEnum([\"create\", \"rearm\"] as const, {\n\t\t\tdescription: \"Defaults to create. rearm resumes a monitor paused by the wake budget.\",\n\t\t}),\n\t),\n\tdescription: Type.Optional(\n\t\tType.String({\n\t\t\tminLength: 1,\n\t\t\tmaxLength: 200,\n\t\t\tdescription: \"Create (required): specific label shown with every event, e.g. 'errors in deploy.log'.\",\n\t\t}),\n\t),\n\tcommand: Type.Optional(\n\t\tType.String({\n\t\t\tdescription: \"Create (required): shell command to run and watch in a PTY-backed monitor session.\",\n\t\t}),\n\t),\n\tfilter: Type.Optional(Type.String({ description: \"Only stdout lines matching this regex become monitor events.\" })),\n\ttimeout_ms: Type.Optional(\n\t\tType.Number({\n\t\t\tminimum: 1,\n\t\t\tmaximum: MAX_MONITOR_TIMEOUT_MS,\n\t\t\tdescription: \"Watcher deadline in milliseconds (default 300000; ignored by persistent monitors).\",\n\t\t}),\n\t),\n\tpersistent: Type.Optional(\n\t\tType.Boolean({ description: \"Keep watching until the command exits or kill_bash stops its bash_id.\" }),\n\t),\n\tbash_id: Type.Optional(Type.String({ description: \"Rearm (required): paused monitor bash_id to resume.\" })),\n});\nexport type MonitorInput = Static<typeof monitorSchema>;\n\ntype MonitorCreateInput = MonitorInput & { description: string; command: string };\n\nfunction isCreateInput(input: MonitorInput): input is MonitorCreateInput {\n\treturn (\n\t\ttypeof input.description === \"string\" &&\n\t\tinput.description.length > 0 &&\n\t\ttypeof input.command === \"string\" &&\n\t\tinput.command.length > 0\n\t);\n}\n\nfunction resolveDimension(value: number | undefined, fallback: number): number {\n\tif (value === undefined || !Number.isFinite(value) || value < 1) return fallback;\n\treturn Math.trunc(value);\n}\n\nfunction resolveTimeoutMs(value: number | undefined): number {\n\tconst timeout = value ?? DEFAULT_MONITOR_TIMEOUT_MS;\n\treturn Math.min(Math.max(Math.trunc(timeout), 1), MAX_MONITOR_TIMEOUT_MS);\n}\n\nfunction compileFilter(filter: string | undefined): RegExp | undefined {\n\tif (filter === undefined) return undefined;\n\treturn new RegExp(filter);\n}\n\nasync function createMonitor(\n\tctx: TerminalToolContext,\n\tregistry: MonitorRegistry,\n\tinput: MonitorCreateInput,\n\texecCtx: { cwd?: string } | undefined,\n): Promise<TerminalToolResult> {\n\tlet filter: RegExp | undefined;\n\ttry {\n\t\tfilter = compileFilter(input.filter);\n\t} catch {\n\t\treturn errorResult(`Invalid monitor filter regex: ${input.filter}`);\n\t}\n\n\tconst { id, runtime } = await spawnCommandSession(ctx, {\n\t\tcommand: input.command,\n\t\tcols: resolveDimension(undefined, ctx.defaultCols || DEFAULT_COLS),\n\t\trows: resolveDimension(undefined, ctx.defaultRows || DEFAULT_ROWS),\n\t\tcwd: execCtx?.cwd,\n\t\t...(input.persistent ? {} : { timeoutMs: resolveTimeoutMs(input.timeout_ms) }),\n\t});\n\tregistry.register({ id, description: input.description, runtime, filter });\n\treturn textResult(`Monitor started with ID: ${id}`, { details: { bash_id: id, monitor: true } });\n}\n\n/** Build the PTY-backed monitor tool. Monitor handles share TerminalManager's bash_N namespace. */\nexport function createMonitorTool(ctx: TerminalToolContext) {\n\tlet fallbackRegistry: MonitorRegistry | undefined;\n\tconst getRegistry = (): MonitorRegistry => {\n\t\tconst sessionRegistry = ctx.monitorRegistry;\n\t\tif (sessionRegistry) return sessionRegistry;\n\t\tfallbackRegistry ??= new MonitorRegistry((event) => ctx.onMonitorEvent?.(event));\n\t\treturn fallbackRegistry;\n\t};\n\treturn {\n\t\tname: TERMINAL_MONITOR_TOOL,\n\t\tlabel: \"monitor\",\n\t\tdescription:\n\t\t\t\"Subscribe to events from a command instead of polling for them: each stdout line arrives as an injected event while you keep working. Updates identical to a monitor's previous batch are dropped, so a watcher reprinting unchanged status does not re-wake the session. Returns a bash_id immediately; peek with bash_output, stop with kill_bash.\",\n\t\tpromptSnippet: \"Subscribe to a command's stdout lines as injected events instead of polling\",\n\t\tpromptGuidelines: [\n\t\t\t\"Waiting on observable state (CI checks, builds, log patterns, deploys) means a monitor, never a foreground sleep/poll loop.\",\n\t\t],\n\t\tparameters: monitorSchema,\n\t\trenderCall: renderMonitorCall,\n\t\tasync execute(\n\t\t\t_toolCallId: string,\n\t\t\tinput: MonitorInput,\n\t\t\t_signal?: AbortSignal,\n\t\t\t_onUpdate?: undefined,\n\t\t\texecCtx?: { cwd?: string },\n\t\t): Promise<TerminalToolResult> {\n\t\t\tconst registry = getRegistry();\n\t\t\tif (input.action === \"rearm\") {\n\t\t\t\tconst bashId = input.bash_id;\n\t\t\t\tif (bashId === undefined || bashId.length === 0) return errorResult(\"monitor rearm requires bash_id.\");\n\t\t\t\tconst outcome = registry.rearm(bashId);\n\t\t\t\tif (outcome === \"not_found\") return errorResult(`No active monitor found with id: ${bashId}`);\n\t\t\t\tif (outcome === \"not_paused\") return textResult(`Monitor ${bashId} is not paused; no action taken.`);\n\t\t\t\tctx.onMonitorRearmed?.(bashId);\n\t\t\t\treturn textResult(`Monitor ${bashId} re-armed.`);\n\t\t\t}\n\t\t\tif (!isCreateInput(input)) {\n\t\t\t\treturn errorResult(\"monitor requires description and command to start a watcher.\");\n\t\t\t}\n\t\t\treturn createMonitor(ctx, registry, input, execCtx);\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,WAAW,EAAqD,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAO,CAAC;AAClD,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC;IACxC,MAAM,EAAE,IAAI,CAAC,QAAQ,CACpB,UAAU,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAU,EAAE;QACxC,WAAW,EAAE,wEAAwE;KACrF,CAAC,CACF;IACD,WAAW,EAAE,IAAI,CAAC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CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;gBACvC,IAAI,OAAO,KAAK,WAAW;oBAAE,OAAO,WAAW,CAAC,oCAAoC,MAAM,EAAE,CAAC,CAAC;gBAC9F,IAAI,OAAO,KAAK,YAAY;oBAAE,OAAO,UAAU,CAAC,WAAW,MAAM,kCAAkC,CAAC,CAAC;gBACrG,GAAG,CAAC,gBAAgB,EAAE,CAAC,MAAM,CAAC,CAAC;gBAC/B,OAAO,UAAU,CAAC,WAAW,MAAM,YAAY,CAAC,CAAC;YAClD,CAAC;YACD,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3B,OAAO,WAAW,CAAC,8DAA8D,CAAC,CAAC;YACpF,CAAC;YACD,OAAO,aAAa,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACrD,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { StringEnum } from \"@earendil-works/pi-ai\";\nimport { type Static, Type } from \"typebox\";\nimport { MonitorRegistry } from \"../monitor-registry.ts\";\nimport { DEFAULT_COLS, DEFAULT_ROWS, TERMINAL_MONITOR_TOOL } from \"../shared.ts\";\nimport { errorResult, type TerminalToolContext, type TerminalToolResult, textResult } from \"./context.ts\";\nimport { renderMonitorCall } from \"./render.ts\";\nimport { spawnCommandSession } from \"./spawn.ts\";\n\nexport const DEFAULT_MONITOR_TIMEOUT_MS = 300_000;\nexport const MAX_MONITOR_TIMEOUT_MS = 3_600_000;\n\n/**\n * One flat object schema, no top-level union: several provider payload paths\n * (e.g. Anthropic's legacy input_schema conversion) rebuild tool schemas from\n * top-level `properties` only, so a root anyOf would reach the model as an\n * empty schema. Branch requirements are enforced at runtime in `execute`.\n */\nexport const monitorSchema = Type.Object({\n\taction: Type.Optional(\n\t\tStringEnum([\"create\", \"rearm\"] as const, {\n\t\t\tdescription: \"Defaults to create. rearm resumes a monitor paused by the wake budget.\",\n\t\t}),\n\t),\n\tdescription: Type.Optional(\n\t\tType.String({\n\t\t\tminLength: 1,\n\t\t\tmaxLength: 200,\n\t\t\tdescription: \"Create (required): specific label shown with every event, e.g. 'errors in deploy.log'.\",\n\t\t}),\n\t),\n\tcommand: Type.Optional(\n\t\tType.String({\n\t\t\tdescription: \"Create (required): shell command to run and watch in a PTY-backed monitor session.\",\n\t\t}),\n\t),\n\tfilter: Type.Optional(Type.String({ description: \"Only stdout lines matching this regex become monitor events.\" })),\n\ttimeout_ms: Type.Optional(\n\t\tType.Number({\n\t\t\tminimum: 1,\n\t\t\tmaximum: MAX_MONITOR_TIMEOUT_MS,\n\t\t\tdescription: \"Watcher deadline in milliseconds (default 300000; ignored by persistent monitors).\",\n\t\t}),\n\t),\n\tpersistent: Type.Optional(\n\t\tType.Boolean({ description: \"Keep watching until the command exits or kill_bash stops its bash_id.\" }),\n\t),\n\tbash_id: Type.Optional(Type.String({ description: \"Rearm (required): paused monitor bash_id to resume.\" })),\n});\nexport type MonitorInput = Static<typeof monitorSchema>;\n\ntype MonitorCreateInput = MonitorInput & { description: string; command: string };\n\nfunction isCreateInput(input: MonitorInput): input is MonitorCreateInput {\n\treturn (\n\t\ttypeof input.description === \"string\" &&\n\t\tinput.description.length > 0 &&\n\t\ttypeof input.command === \"string\" &&\n\t\tinput.command.length > 0\n\t);\n}\n\nfunction resolveDimension(value: number | undefined, fallback: number): number {\n\tif (value === undefined || !Number.isFinite(value) || value < 1) return fallback;\n\treturn Math.trunc(value);\n}\n\nfunction resolveTimeoutMs(value: number | undefined): number {\n\tconst timeout = value ?? DEFAULT_MONITOR_TIMEOUT_MS;\n\treturn Math.min(Math.max(Math.trunc(timeout), 1), MAX_MONITOR_TIMEOUT_MS);\n}\n\nfunction compileFilter(filter: string | undefined): RegExp | undefined {\n\tif (filter === undefined) return undefined;\n\treturn new RegExp(filter);\n}\n\nasync function createMonitor(\n\tctx: TerminalToolContext,\n\tregistry: MonitorRegistry,\n\tinput: MonitorCreateInput,\n\texecCtx: { cwd?: string } | undefined,\n): Promise<TerminalToolResult> {\n\tlet filter: RegExp | undefined;\n\ttry {\n\t\tfilter = compileFilter(input.filter);\n\t} catch {\n\t\treturn errorResult(`Invalid monitor filter regex: ${input.filter}`);\n\t}\n\n\tconst { id, runtime } = await spawnCommandSession(ctx, {\n\t\tcommand: input.command,\n\t\tcols: resolveDimension(undefined, ctx.defaultCols || DEFAULT_COLS),\n\t\trows: resolveDimension(undefined, ctx.defaultRows || DEFAULT_ROWS),\n\t\tcwd: execCtx?.cwd,\n\t\t...(input.persistent ? {} : { timeoutMs: resolveTimeoutMs(input.timeout_ms) }),\n\t});\n\tctx.onMonitorRearmed?.(id);\n\tregistry.register({ id, description: input.description, runtime, filter });\n\treturn textResult(`Monitor started with ID: ${id}`, { details: { bash_id: id, monitor: true } });\n}\n\n/** Build the PTY-backed monitor tool. Monitor handles share TerminalManager's bash_N namespace. */\nexport function createMonitorTool(ctx: TerminalToolContext) {\n\tlet fallbackRegistry: MonitorRegistry | undefined;\n\tconst getRegistry = (): MonitorRegistry => {\n\t\tconst sessionRegistry = ctx.monitorRegistry;\n\t\tif (sessionRegistry) return sessionRegistry;\n\t\tfallbackRegistry ??= new MonitorRegistry((event) => ctx.onMonitorEvent?.(event));\n\t\treturn fallbackRegistry;\n\t};\n\treturn {\n\t\tname: TERMINAL_MONITOR_TOOL,\n\t\tlabel: \"monitor\",\n\t\tdescription:\n\t\t\t\"Subscribe to events from a command instead of polling for them: each stdout line arrives as an injected event while you keep working. Updates identical to a monitor's previous batch are dropped, so a watcher reprinting unchanged status does not re-wake the session. Returns a bash_id immediately; peek with bash_output, stop with kill_bash.\",\n\t\tpromptSnippet: \"Subscribe to a command's stdout lines as injected events instead of polling\",\n\t\tpromptGuidelines: [\n\t\t\t\"Waiting on observable state (CI checks, builds, log patterns, deploys) means a monitor, never a foreground sleep/poll loop.\",\n\t\t],\n\t\tparameters: monitorSchema,\n\t\trenderCall: renderMonitorCall,\n\t\tasync execute(\n\t\t\t_toolCallId: string,\n\t\t\tinput: MonitorInput,\n\t\t\t_signal?: AbortSignal,\n\t\t\t_onUpdate?: undefined,\n\t\t\texecCtx?: { cwd?: string },\n\t\t): Promise<TerminalToolResult> {\n\t\t\tconst registry = getRegistry();\n\t\t\tif (input.action === \"rearm\") {\n\t\t\t\tconst bashId = input.bash_id;\n\t\t\t\tif (bashId === undefined || bashId.length === 0) return errorResult(\"monitor rearm requires bash_id.\");\n\t\t\t\tconst outcome = registry.rearm(bashId);\n\t\t\t\tif (outcome === \"not_found\") return errorResult(`No active monitor found with id: ${bashId}`);\n\t\t\t\tif (outcome === \"not_paused\") return textResult(`Monitor ${bashId} is not paused; no action taken.`);\n\t\t\t\tctx.onMonitorRearmed?.(bashId);\n\t\t\t\treturn textResult(`Monitor ${bashId} re-armed.`);\n\t\t\t}\n\t\t\tif (!isCreateInput(input)) {\n\t\t\t\treturn errorResult(\"monitor requires description and command to start a watcher.\");\n\t\t\t}\n\t\t\treturn createMonitor(ctx, registry, input, execCtx);\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/tool-pair-guard/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/tool-pair-guard/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAInD,2EAA2E;AAC3E,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAQrE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sanitizeAnthropicPayload } from "
|
|
1
|
+
import { sanitizeAnthropicToolPairs as sanitizeAnthropicPayload } from "@earendil-works/pi-ai";
|
|
2
2
|
import { sanitizeOpenAIChatCompletionsPayload } from "./sanitize-openai-chat-completions-payload.js";
|
|
3
3
|
import { sanitizeOpenAIResponsesPayload } from "./sanitize-openai-responses-payload.js";
|
|
4
4
|
/** Guards provider requests by keeping tool-call/result pairs balanced. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/tool-pair-guard/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/tool-pair-guard/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,IAAI,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAE/F,OAAO,EAAE,oCAAoC,EAAE,MAAM,+CAA+C,CAAC;AACrG,OAAO,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AAExF,2EAA2E;AAC3E,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAAgB;IAC9D,EAAE,CAAC,EAAE,CAAC,yBAAyB,EAAE,CAAC,KAAK,EAAE,EAAE;QAC1C,MAAM,yBAAyB,GAAG,wBAAwB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC1E,MAAM,yBAAyB,GAAG,8BAA8B,CAAC,yBAAyB,CAAC,CAAC;QAC5F,MAAM,gBAAgB,GAAG,oCAAoC,CAAC,yBAAyB,CAAC,CAAC;QACzF,IAAI,gBAAgB,KAAK,KAAK,CAAC,OAAO;YAAE,OAAO,SAAS,CAAC;QACzD,OAAO,gBAAgB,CAAC;IACzB,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { sanitizeAnthropicToolPairs as sanitizeAnthropicPayload } from \"@earendil-works/pi-ai\";\nimport type { ExtensionAPI } from \"../../types.ts\";\nimport { sanitizeOpenAIChatCompletionsPayload } from \"./sanitize-openai-chat-completions-payload.ts\";\nimport { sanitizeOpenAIResponsesPayload } from \"./sanitize-openai-responses-payload.ts\";\n\n/** Guards provider requests by keeping tool-call/result pairs balanced. */\nexport default function toolPairGuardExtension(pi: ExtensionAPI): void {\n\tpi.on(\"before_provider_request\", (event) => {\n\t\tconst sanitizedAnthropicPayload = sanitizeAnthropicPayload(event.payload);\n\t\tconst sanitizedResponsesPayload = sanitizeOpenAIResponsesPayload(sanitizedAnthropicPayload);\n\t\tconst sanitizedPayload = sanitizeOpenAIChatCompletionsPayload(sanitizedResponsesPayload);\n\t\tif (sanitizedPayload === event.payload) return undefined;\n\t\treturn sanitizedPayload;\n\t});\n}\n"]}
|