@code-yeongyu/senpi 2026.7.31 → 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 +270 -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 +85 -14
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +445 -78
- 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/build.d.ts.map +1 -1
- package/dist/core/dynamic-prompt/build.js +4 -0
- package/dist/core/dynamic-prompt/build.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-agent-sdk → claude-sdk-oauth}/account-command.d.ts +2 -2
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-command.d.ts.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-command.js +25 -25
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-command.js.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-events.d.ts.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-events.js.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-management.d.ts +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-management.d.ts.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-management.js +2 -2
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-management.js.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/accounts.d.ts +9 -9
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/accounts.d.ts.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/accounts.js +2 -2
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/accounts.js.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/affinity.d.ts +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/affinity.d.ts.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/affinity.js +3 -3
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/affinity.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/auth-attempt.d.ts +21 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/auth-attempt.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/auth-attempt.js +30 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/auth-attempt.js.map +1 -0
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/auth-lane.d.ts +8 -4
- package/dist/core/extensions/builtin/claude-sdk-oauth/auth-lane.d.ts.map +1 -0
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/auth-lane.js +34 -25
- package/dist/core/extensions/builtin/claude-sdk-oauth/auth-lane.js.map +1 -0
- 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-agent-sdk → claude-sdk-oauth}/custom-tools-schema.d.ts.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/custom-tools-schema.js.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/custom-tools.d.ts.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/custom-tools.js.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/errors.d.ts +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/errors.d.ts.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/errors.js +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/errors.js.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/executable.d.ts.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/executable.js.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/failover.d.ts.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/failover.js +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/failover.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/guidance.d.ts +14 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/guidance.d.ts.map +1 -0
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/guidance.js +37 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/guidance.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/index.d.ts +4 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/index.d.ts.map +1 -0
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/index.js +12 -10
- package/dist/core/extensions/builtin/claude-sdk-oauth/index.js.map +1 -0
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/oauth-login.d.ts +3 -3
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/oauth-login.d.ts.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/oauth-login.js +2 -2
- package/dist/core/extensions/builtin/claude-sdk-oauth/oauth-login.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/options.d.ts +18 -0
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/options.d.ts.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/options.js +70 -10
- package/dist/core/extensions/builtin/claude-sdk-oauth/options.js.map +1 -0
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/prompt-bridge.d.ts.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/prompt-bridge.js +32 -19
- package/dist/core/extensions/builtin/claude-sdk-oauth/prompt-bridge.js.map +1 -0
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/sdk-boundary.d.ts +2 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/sdk-boundary.d.ts.map +1 -0
- package/dist/core/extensions/builtin/{claude-agent-sdk → 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 +19 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.js +176 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-state.d.ts +18 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-state.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-state.js +33 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-state.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.d.ts +3 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.js +76 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.d.ts +87 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.js +259 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.d.ts +19 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js +192 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.d.ts +20 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js +132 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js.map +1 -0
- 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/settings.d.ts +28 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/settings.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/settings.js +107 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/settings.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-guidance.d.ts +2 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream-guidance.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream-guidance.js +10 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream-guidance.js.map +1 -0
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/stream-protocol.d.ts.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/stream-protocol.js.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/stream.d.ts +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream.js +208 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/system-prompt.d.ts +3 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/system-prompt.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/system-prompt.js +25 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/system-prompt.js.map +1 -0
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/tool-watch.d.ts +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/tool-watch.d.ts.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/tool-watch.js +2 -2
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/tool-watch.js.map +1 -1
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/tools.d.ts +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/tools.d.ts.map +1 -0
- package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/tools.js +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/tools.js.map +1 -0
- 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 +18 -0
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.js +73 -0
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.js.map +1 -0
- 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 +119 -15
- 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 +4 -1
- package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/speculative.js +39 -115
- package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/task-intent.d.ts +2 -6
- package/dist/core/extensions/builtin/compaction/task-intent.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/task-intent.js +10 -9
- package/dist/core/extensions/builtin/compaction/task-intent.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/goal/continuation-recovery.d.ts +6 -0
- package/dist/core/extensions/builtin/goal/continuation-recovery.d.ts.map +1 -0
- package/dist/core/extensions/builtin/goal/continuation-recovery.js +20 -0
- package/dist/core/extensions/builtin/goal/continuation-recovery.js.map +1 -0
- package/dist/core/extensions/builtin/goal/continuation.d.ts +2 -4
- package/dist/core/extensions/builtin/goal/continuation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/continuation.js +2 -8
- package/dist/core/extensions/builtin/goal/continuation.js.map +1 -1
- package/dist/core/extensions/builtin/goal/direct-input-lifecycle.d.ts +19 -0
- package/dist/core/extensions/builtin/goal/direct-input-lifecycle.d.ts.map +1 -0
- package/dist/core/extensions/builtin/goal/direct-input-lifecycle.js +48 -0
- package/dist/core/extensions/builtin/goal/direct-input-lifecycle.js.map +1 -0
- package/dist/core/extensions/builtin/goal/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/index.js +17 -15
- package/dist/core/extensions/builtin/goal/index.js.map +1 -1
- package/dist/core/extensions/builtin/goal/lifecycle-helpers.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/lifecycle-helpers.js +12 -10
- package/dist/core/extensions/builtin/goal/lifecycle-helpers.js.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts +5 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.js +94 -52
- package/dist/core/extensions/builtin/goal/monitor-continuation.js.map +1 -1
- package/dist/core/extensions/builtin/goal/persistence.d.ts +16 -0
- package/dist/core/extensions/builtin/goal/persistence.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/persistence.js +185 -11
- package/dist/core/extensions/builtin/goal/persistence.js.map +1 -1
- package/dist/core/extensions/builtin/goal/ui.d.ts +1 -0
- package/dist/core/extensions/builtin/goal/ui.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/ui.js +11 -2
- package/dist/core/extensions/builtin/goal/ui.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/extension.d.ts.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/extension.js +15 -0
- package/dist/core/extensions/builtin/gpt-apply-patch/extension.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 +53 -8
- package/dist/core/extensions/builtin/gpt-apply-patch/tool.js.map +1 -1
- package/dist/core/extensions/builtin/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/index.js +5 -2
- package/dist/core/extensions/builtin/index.js.map +1 -1
- package/dist/core/extensions/builtin/loop-guard/detectors.d.ts +31 -0
- package/dist/core/extensions/builtin/loop-guard/detectors.d.ts.map +1 -0
- package/dist/core/extensions/builtin/loop-guard/detectors.js +152 -0
- package/dist/core/extensions/builtin/loop-guard/detectors.js.map +1 -0
- package/dist/core/extensions/builtin/loop-guard/index.d.ts +3 -0
- package/dist/core/extensions/builtin/loop-guard/index.d.ts.map +1 -0
- package/dist/core/extensions/builtin/loop-guard/index.js +31 -0
- package/dist/core/extensions/builtin/loop-guard/index.js.map +1 -0
- package/dist/core/extensions/builtin/loop-guard/notice.d.ts +5 -0
- package/dist/core/extensions/builtin/loop-guard/notice.d.ts.map +1 -0
- package/dist/core/extensions/builtin/loop-guard/notice.js +42 -0
- package/dist/core/extensions/builtin/loop-guard/notice.js.map +1 -0
- package/dist/core/extensions/builtin/loop-guard/policy.d.ts +30 -0
- package/dist/core/extensions/builtin/loop-guard/policy.d.ts.map +1 -0
- package/dist/core/extensions/builtin/loop-guard/policy.js +30 -0
- package/dist/core/extensions/builtin/loop-guard/policy.js.map +1 -0
- package/dist/core/extensions/builtin/loop-guard/renderer.d.ts +4 -0
- package/dist/core/extensions/builtin/loop-guard/renderer.d.ts.map +1 -0
- package/dist/core/extensions/builtin/loop-guard/renderer.js +50 -0
- package/dist/core/extensions/builtin/loop-guard/renderer.js.map +1 -0
- package/dist/core/extensions/builtin/loop-guard/similarity.d.ts +13 -0
- package/dist/core/extensions/builtin/loop-guard/similarity.d.ts.map +1 -0
- package/dist/core/extensions/builtin/loop-guard/similarity.js +51 -0
- package/dist/core/extensions/builtin/loop-guard/similarity.js.map +1 -0
- package/dist/core/extensions/builtin/loop-guard/tracker.d.ts +13 -0
- package/dist/core/extensions/builtin/loop-guard/tracker.d.ts.map +1 -0
- package/dist/core/extensions/builtin/loop-guard/tracker.js +39 -0
- package/dist/core/extensions/builtin/loop-guard/tracker.js.map +1 -0
- 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/monitor-state-event.d.ts +10 -0
- package/dist/core/extensions/builtin/monitor-state-event.d.ts.map +1 -1
- package/dist/core/extensions/builtin/monitor-state-event.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-flash-0731.d.ts +3 -0
- package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-flash-0731.d.ts.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-flash-0731.js +10 -0
- package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-flash-0731.js.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-flash.d.ts +3 -0
- package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-flash.d.ts.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-flash.js +10 -0
- package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-flash.js.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-pro.d.ts +3 -0
- package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-pro.d.ts.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-pro.js +11 -0
- package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-pro.js.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/deepseek-v4.d.ts +13 -0
- package/dist/core/extensions/builtin/prompt-preset/deepseek-v4.d.ts.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/deepseek-v4.js +60 -0
- package/dist/core/extensions/builtin/prompt-preset/deepseek-v4.js.map +1 -0
- 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/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/index.js +8 -4
- package/dist/core/extensions/builtin/prompt-preset/index.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/prompt-preset/presets.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/presets.js +42 -0
- package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/settings.d.ts +1 -1
- package/dist/core/extensions/builtin/prompt-preset/settings.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/settings.js +3 -0
- package/dist/core/extensions/builtin/prompt-preset/settings.js.map +1 -1
- package/dist/core/extensions/builtin/recommended-models/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/recommended-models/index.js +2 -1
- package/dist/core/extensions/builtin/recommended-models/index.js.map +1 -1
- package/dist/core/extensions/builtin/rules/index.js +4 -3
- package/dist/core/extensions/builtin/rules/index.js.map +1 -1
- package/dist/core/extensions/builtin/rules/rules/constants.d.ts +11 -0
- package/dist/core/extensions/builtin/rules/rules/constants.d.ts.map +1 -1
- package/dist/core/extensions/builtin/rules/rules/constants.js +11 -0
- package/dist/core/extensions/builtin/rules/rules/constants.js.map +1 -1
- package/dist/core/extensions/builtin/rules/rules/formatter.d.ts.map +1 -1
- package/dist/core/extensions/builtin/rules/rules/formatter.js +15 -1
- package/dist/core/extensions/builtin/rules/rules/formatter.js.map +1 -1
- package/dist/core/extensions/builtin/service-tier.d.ts.map +1 -1
- package/dist/core/extensions/builtin/service-tier.js +23 -21
- package/dist/core/extensions/builtin/service-tier.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/extension.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/extension.js +21 -7
- package/dist/core/extensions/builtin/terminal/extension.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-notify.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-notify.js +42 -5
- package/dist/core/extensions/builtin/terminal/monitor-notify.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts +2 -0
- package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-registry.js +2 -0
- package/dist/core/extensions/builtin/terminal/monitor-registry.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-status-ticker.d.ts +37 -0
- package/dist/core/extensions/builtin/terminal/monitor-status-ticker.d.ts.map +1 -0
- package/dist/core/extensions/builtin/terminal/monitor-status-ticker.js +61 -0
- package/dist/core/extensions/builtin/terminal/monitor-status-ticker.js.map +1 -0
- package/dist/core/extensions/builtin/terminal/monitor-status.d.ts +9 -1
- package/dist/core/extensions/builtin/terminal/monitor-status.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-status.js +35 -2
- package/dist/core/extensions/builtin/terminal/monitor-status.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 +2 -1
- package/dist/core/extensions/builtin/terminal/tools/monitor.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/commands.d.ts +2 -2
- package/dist/core/extensions/builtin/todotools/commands.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/commands.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/index.js +6 -3
- package/dist/core/extensions/builtin/todotools/index.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/state.d.ts +1 -1
- package/dist/core/extensions/builtin/todotools/state.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/state.js +1 -1
- package/dist/core/extensions/builtin/todotools/state.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/todo-widget-component.d.ts +19 -0
- package/dist/core/extensions/builtin/todotools/todo-widget-component.d.ts.map +1 -0
- package/dist/core/extensions/builtin/todotools/todo-widget-component.js +78 -0
- package/dist/core/extensions/builtin/todotools/todo-widget-component.js.map +1 -0
- package/dist/core/extensions/builtin/todotools/todo-widget.d.ts +13 -1
- package/dist/core/extensions/builtin/todotools/todo-widget.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/todo-widget.js +32 -14
- package/dist/core/extensions/builtin/todotools/todo-widget.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/tools/todo.d.ts +2 -2
- package/dist/core/extensions/builtin/todotools/tools/todo.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/tools/todo.js +1 -1
- package/dist/core/extensions/builtin/todotools/tools/todo.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/builtin/tps.d.ts.map +1 -1
- package/dist/core/extensions/builtin/tps.js +5 -2
- package/dist/core/extensions/builtin/tps.js.map +1 -1
- package/dist/core/extensions/builtin/ttsr/builtin-rules.d.ts +4 -0
- package/dist/core/extensions/builtin/ttsr/builtin-rules.d.ts.map +1 -0
- package/dist/core/extensions/builtin/ttsr/builtin-rules.js +20 -0
- package/dist/core/extensions/builtin/ttsr/builtin-rules.js.map +1 -0
- package/dist/core/extensions/builtin/ttsr/commands.js +9 -1
- package/dist/core/extensions/builtin/ttsr/commands.js.map +1 -1
- package/dist/core/extensions/builtin/ttsr/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ttsr/index.js +4 -3
- package/dist/core/extensions/builtin/ttsr/index.js.map +1 -1
- package/dist/core/extensions/builtin/ttsr/manager.js +1 -1
- package/dist/core/extensions/builtin/ttsr/manager.js.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/config.d.ts.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/config.js +1 -0
- package/dist/core/extensions/builtin/websearch/websearch/config.js.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/native.d.ts.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/native.js +16 -5
- package/dist/core/extensions/builtin/websearch/websearch/native.js.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/provider-endpoints.d.ts.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/provider-endpoints.js +1 -0
- package/dist/core/extensions/builtin/websearch/websearch/provider-endpoints.js.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/providers/anthropic.d.ts +4 -1
- package/dist/core/extensions/builtin/websearch/websearch/providers/anthropic.d.ts.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/providers/anthropic.js +44 -37
- package/dist/core/extensions/builtin/websearch/websearch/providers/anthropic.js.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/providers/deepseek.d.ts +3 -0
- package/dist/core/extensions/builtin/websearch/websearch/providers/deepseek.d.ts.map +1 -0
- package/dist/core/extensions/builtin/websearch/websearch/providers/deepseek.js +12 -0
- package/dist/core/extensions/builtin/websearch/websearch/providers/deepseek.js.map +1 -0
- package/dist/core/extensions/builtin/websearch/websearch/providers.d.ts.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/providers.js +2 -0
- package/dist/core/extensions/builtin/websearch/websearch/providers.js.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/renderers.d.ts.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/renderers.js +3 -3
- package/dist/core/extensions/builtin/websearch/websearch/renderers.js.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/search.d.ts.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/search.js +1 -3
- package/dist/core/extensions/builtin/websearch/websearch/search.js.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/tool.js +2 -2
- package/dist/core/extensions/builtin/websearch/websearch/tool.js.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/types.d.ts +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/types.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 +19 -18
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +5 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +21 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +38 -2
- 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-resolver.js +2 -2
- package/dist/core/model-resolver.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/core/thinking-levels.d.ts +5 -0
- package/dist/core/thinking-levels.d.ts.map +1 -1
- package/dist/core/thinking-levels.js +9 -39
- package/dist/core/thinking-levels.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/app-server/server/account.d.ts +1 -1
- package/dist/modes/app-server/server/account.js +1 -1
- package/dist/modes/app-server/server/account.js.map +1 -1
- package/dist/modes/app-server/server/server-core.js +1 -1
- package/dist/modes/app-server/server/server-core.js.map +1 -1
- package/dist/modes/interactive/compaction-queue-transfer.d.ts +2 -0
- package/dist/modes/interactive/compaction-queue-transfer.d.ts.map +1 -1
- package/dist/modes/interactive/compaction-queue-transfer.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/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +9 -5
- package/dist/modes/interactive/components/footer.js.map +1 -1
- 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 +189 -62
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/risky-main-model-warning.d.ts +1 -1
- package/dist/modes/interactive/risky-main-model-warning.d.ts.map +1 -1
- package/dist/modes/interactive/risky-main-model-warning.js +1 -1
- package/dist/modes/interactive/risky-main-model-warning.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 +16 -3
- 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 +34 -1
- package/docs/keybindings.md +13 -0
- package/docs/mcp.md +63 -4
- package/docs/models.md +1 -0
- package/docs/providers.md +41 -5
- package/docs/release-guide.md +7 -5
- package/docs/session-format.md +2 -0
- package/docs/settings.md +3 -1
- 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/overlay-test.ts +1 -1
- 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 +45 -0
- package/node_modules/@code-yeongyu/senpi-codemode/README.md +6 -3
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
- package/node_modules/@code-yeongyu/senpi-codemode/src/extension/eval-status-ticker.ts +79 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/extension/eval-status.ts +36 -3
- package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +26 -12
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-execution.ts +146 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-handler.ts +21 -119
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-runtime.ts +157 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-manager.ts +62 -208
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-notification.ts +98 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-snapshot.ts +81 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-state.ts +24 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-eval-result.ts +140 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-notification-queue.ts +53 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-request.ts +45 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool-options.ts +45 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +20 -342
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
- 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 +56 -25
- 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/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.js +134 -0
- 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 +7 -3
- 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/fallback-state.d.ts +24 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses/fallback-state.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses/fallback-state.js +70 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses/fallback-state.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts +2 -16
- 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 +94 -105
- 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 +19 -10
- 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-prompt-cache.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-prompt-cache.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-prompt-cache.js +7 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-prompt-cache.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 +9 -5
- 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/model.d.ts +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/model.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/model.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.d.ts +14 -0
- package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.js +95 -19
- package/node_modules/@earendil-works/pi-ai/dist/models.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/amazon-bedrock.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.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-go.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 +18 -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/dist/utils/unavailable-tool-text.d.ts +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/unavailable-tool-text.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/unavailable-tool-text.js +36 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/unavailable-tool-text.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/mux.js +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/mux.js.map +1 -1
- 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 +37 -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 +89 -21
- 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/claude-agent-sdk/auth-lane.d.ts.map +0 -1
- package/dist/core/extensions/builtin/claude-agent-sdk/auth-lane.js.map +0 -1
- package/dist/core/extensions/builtin/claude-agent-sdk/guidance.d.ts +0 -6
- package/dist/core/extensions/builtin/claude-agent-sdk/guidance.d.ts.map +0 -1
- package/dist/core/extensions/builtin/claude-agent-sdk/guidance.js.map +0 -1
- package/dist/core/extensions/builtin/claude-agent-sdk/index.d.ts +0 -4
- package/dist/core/extensions/builtin/claude-agent-sdk/index.d.ts.map +0 -1
- package/dist/core/extensions/builtin/claude-agent-sdk/index.js.map +0 -1
- package/dist/core/extensions/builtin/claude-agent-sdk/oauth-login.js.map +0 -1
- package/dist/core/extensions/builtin/claude-agent-sdk/options.d.ts +0 -16
- package/dist/core/extensions/builtin/claude-agent-sdk/options.js.map +0 -1
- package/dist/core/extensions/builtin/claude-agent-sdk/prompt-bridge.js.map +0 -1
- package/dist/core/extensions/builtin/claude-agent-sdk/sdk-boundary.d.ts.map +0 -1
- package/dist/core/extensions/builtin/claude-agent-sdk/settings.d.ts +0 -15
- package/dist/core/extensions/builtin/claude-agent-sdk/settings.d.ts.map +0 -1
- package/dist/core/extensions/builtin/claude-agent-sdk/settings.js +0 -41
- package/dist/core/extensions/builtin/claude-agent-sdk/settings.js.map +0 -1
- package/dist/core/extensions/builtin/claude-agent-sdk/stream.d.ts.map +0 -1
- package/dist/core/extensions/builtin/claude-agent-sdk/stream.js +0 -229
- package/dist/core/extensions/builtin/claude-agent-sdk/stream.js.map +0 -1
- package/dist/core/extensions/builtin/claude-agent-sdk/tools.d.ts.map +0 -1
- package/dist/core/extensions/builtin/claude-agent-sdk/tools.js.map +0 -1
- 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 +0 -75
- 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/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-events.d.ts +0 -0
- /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-events.js +0 -0
- /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/custom-tools-schema.d.ts +0 -0
- /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/custom-tools-schema.js +0 -0
- /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/custom-tools.d.ts +0 -0
- /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/custom-tools.js +0 -0
- /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/executable.d.ts +0 -0
- /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/executable.js +0 -0
- /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/failover.d.ts +0 -0
- /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/prompt-bridge.d.ts +0 -0
- /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/sdk-boundary.js +0 -0
- /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/stream-protocol.d.ts +0 -0
- /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/stream-protocol.js +0 -0
- /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,10 +1,14 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
3
|
-
import {
|
|
2
|
+
import { mkdir, readdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { dirname, join, sep } from "node:path";
|
|
4
5
|
import { InvalidGoalStoreError, UnsupportedGoalStoreVersionError } from "./errors.js";
|
|
5
6
|
import { isRecord } from "./types.js";
|
|
6
7
|
import { isGoalStatus, isNonNegativeSafeInteger } from "./validation.js";
|
|
7
8
|
const STORE_VERSION = 1;
|
|
9
|
+
const CURRENT_STORE_DIRECTORY = "goal";
|
|
10
|
+
const LEGACY_STORE_DIRECTORY = "pi-goal";
|
|
11
|
+
const LEGACY_BUDGET_LIMITED_STATUSES = ["budgetLimited", "budget_limited"];
|
|
8
12
|
export function encodedThreadId(ref) {
|
|
9
13
|
return encodeURIComponent(ref.threadId);
|
|
10
14
|
}
|
|
@@ -21,6 +25,139 @@ export async function readGoalFile(ref) {
|
|
|
21
25
|
throw error;
|
|
22
26
|
}
|
|
23
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Imports legacy standalone `pi-goal` state into the current budget-free store.
|
|
30
|
+
*
|
|
31
|
+
* The current store always wins and legacy normalization is confined to this path.
|
|
32
|
+
* Invalid, unsupported, or malformed legacy files are best-effort dead-data imports:
|
|
33
|
+
* they remain untouched and do not block the live current store. Unexpected filesystem
|
|
34
|
+
* failures still propagate.
|
|
35
|
+
*
|
|
36
|
+
* Session-backed stores use their stable thread id. No-session stores enumerate the
|
|
37
|
+
* cwd-keyed legacy bucket because each ephemeral run receives a new thread id, and they
|
|
38
|
+
* inspect both the redirected Senpi-root sibling and the standalone pi agent root.
|
|
39
|
+
* Multiple valid live candidates are reported as a conflict rather than guessed.
|
|
40
|
+
*
|
|
41
|
+
* Returns the imported goal, or null when nothing was migrated.
|
|
42
|
+
*/
|
|
43
|
+
export async function migrateLegacyGoalFile(ref) {
|
|
44
|
+
try {
|
|
45
|
+
await readFile(goalFilePath(ref), "utf8");
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (!isMissingFile(error))
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
const legacyCandidates = await readLegacyGoalCandidates(ref);
|
|
53
|
+
if (legacyCandidates.length > 1) {
|
|
54
|
+
throw new Error(`multiple legacy goals found for no-session store: ${legacyCandidates.map(({ path }) => path).join(", ")}`);
|
|
55
|
+
}
|
|
56
|
+
const candidate = legacyCandidates[0];
|
|
57
|
+
if (candidate === undefined)
|
|
58
|
+
return null;
|
|
59
|
+
const published = await publishMigratedGoalFile(ref, candidate.goal);
|
|
60
|
+
await retireLegacyGoalFile(candidate.path);
|
|
61
|
+
return published ? candidate.goal : null;
|
|
62
|
+
}
|
|
63
|
+
async function readLegacyGoalCandidates(ref) {
|
|
64
|
+
const legacyBaseDir = legacyBaseDirFor(ref.baseDir);
|
|
65
|
+
if (legacyBaseDir === undefined)
|
|
66
|
+
return [];
|
|
67
|
+
const cwdKey = noSessionCwdKey(ref.baseDir);
|
|
68
|
+
if (cwdKey === undefined) {
|
|
69
|
+
const candidate = await readLegacyGoalCandidate(goalFilePath({ ...ref, baseDir: legacyBaseDir }));
|
|
70
|
+
return candidate === null ? [] : [candidate];
|
|
71
|
+
}
|
|
72
|
+
const standaloneAgentDir = process.env.PI_CODING_AGENT_DIR ?? join(homedir(), ".pi", "agent");
|
|
73
|
+
const baseDirs = new Set([
|
|
74
|
+
legacyBaseDir,
|
|
75
|
+
join(standaloneAgentDir, "extensions", LEGACY_STORE_DIRECTORY, "no-session", cwdKey),
|
|
76
|
+
]);
|
|
77
|
+
const candidatePaths = [];
|
|
78
|
+
for (const baseDir of baseDirs) {
|
|
79
|
+
let entries;
|
|
80
|
+
try {
|
|
81
|
+
entries = await readdir(baseDir, { withFileTypes: true });
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
if (isMissingFile(error))
|
|
85
|
+
continue;
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
for (const entry of entries) {
|
|
89
|
+
if (entry.isFile() && entry.name.endsWith(".json"))
|
|
90
|
+
candidatePaths.push(join(baseDir, entry.name));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const candidates = [];
|
|
94
|
+
for (const path of candidatePaths.sort()) {
|
|
95
|
+
const candidate = await readLegacyGoalCandidate(path);
|
|
96
|
+
if (candidate !== null)
|
|
97
|
+
candidates.push(candidate);
|
|
98
|
+
}
|
|
99
|
+
return candidates;
|
|
100
|
+
}
|
|
101
|
+
async function readLegacyGoalCandidate(path) {
|
|
102
|
+
let goal;
|
|
103
|
+
try {
|
|
104
|
+
goal = parseGoalFile(await readFile(path, "utf8"), { legacy: true }).goal;
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
if (isMissingFile(error) || isIgnoredLegacyStoreError(error))
|
|
108
|
+
return null;
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
if (goal === null) {
|
|
112
|
+
await retireLegacyGoalFile(path);
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
return { path, goal };
|
|
116
|
+
}
|
|
117
|
+
async function retireLegacyGoalFile(path) {
|
|
118
|
+
try {
|
|
119
|
+
await rename(path, `${path}.migrated`);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
// Retirement is best-effort: a preserved legacy file must never fail live migration.
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function isIgnoredLegacyStoreError(error) {
|
|
126
|
+
return (error instanceof InvalidGoalStoreError ||
|
|
127
|
+
error instanceof UnsupportedGoalStoreVersionError ||
|
|
128
|
+
error instanceof SyntaxError);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Maps a current goal-store directory to its legacy `pi-goal` counterpart by replacing
|
|
132
|
+
* the `goal` path segment itself.
|
|
133
|
+
*
|
|
134
|
+
* Both store layouts must map correctly:
|
|
135
|
+
* <sessionDir>/extensions/goal -> <sessionDir>/extensions/pi-goal
|
|
136
|
+
* <agentDir>/extensions/goal/no-session/<cwdKey>
|
|
137
|
+
* -> <agentDir>/extensions/pi-goal/no-session/<cwdKey>
|
|
138
|
+
*
|
|
139
|
+
* Swapping `dirname(baseDir)` only works for the first layout; in the no-session
|
|
140
|
+
* fallback it points inside the current store tree, which both misses real legacy
|
|
141
|
+
* state and can import an unrelated nested directory.
|
|
142
|
+
*/
|
|
143
|
+
function legacyBaseDirFor(baseDir) {
|
|
144
|
+
const segments = pathSegments(baseDir);
|
|
145
|
+
const goalIndex = segments.lastIndexOf(CURRENT_STORE_DIRECTORY);
|
|
146
|
+
if (goalIndex === -1)
|
|
147
|
+
return undefined;
|
|
148
|
+
segments[goalIndex] = LEGACY_STORE_DIRECTORY;
|
|
149
|
+
return segments.join(sep);
|
|
150
|
+
}
|
|
151
|
+
function noSessionCwdKey(baseDir) {
|
|
152
|
+
const segments = pathSegments(baseDir);
|
|
153
|
+
const goalIndex = segments.lastIndexOf(CURRENT_STORE_DIRECTORY);
|
|
154
|
+
if (goalIndex === -1 || segments[goalIndex + 1] !== "no-session")
|
|
155
|
+
return undefined;
|
|
156
|
+
return segments[goalIndex + 2];
|
|
157
|
+
}
|
|
158
|
+
function pathSegments(path) {
|
|
159
|
+
return path.split(/[\\/]/);
|
|
160
|
+
}
|
|
24
161
|
export async function writeGoalFile(ref, goal) {
|
|
25
162
|
const filePath = goalFilePath(ref);
|
|
26
163
|
await mkdir(dirname(filePath), { recursive: true });
|
|
@@ -42,7 +179,32 @@ async function writeGoalFileAtomic(filePath, contents) {
|
|
|
42
179
|
throw error;
|
|
43
180
|
}
|
|
44
181
|
}
|
|
45
|
-
function
|
|
182
|
+
async function publishMigratedGoalFile(ref, goal) {
|
|
183
|
+
const filePath = goalFilePath(ref);
|
|
184
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
185
|
+
const contents = `${JSON.stringify({ version: STORE_VERSION, goal }, null, 2)}\n`;
|
|
186
|
+
try {
|
|
187
|
+
await writeFile(filePath, contents, { encoding: "utf8", mode: 0o600, flag: "wx" });
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
if (isFileSystemError(error, "EEXIST"))
|
|
192
|
+
return false;
|
|
193
|
+
throw error;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function parseGoalFile(raw, { legacy = false } = {}) {
|
|
197
|
+
const parsed = parseGoalFileJson(raw);
|
|
198
|
+
if (!isRecord(parsed))
|
|
199
|
+
throw new InvalidGoalStoreError("goal store must be a JSON object");
|
|
200
|
+
if (parsed.version !== STORE_VERSION)
|
|
201
|
+
throw new UnsupportedGoalStoreVersionError("unsupported goal store version");
|
|
202
|
+
const goal = legacy ? normalizeLegacyGoal(parsed.goal) : parsed.goal;
|
|
203
|
+
if (goal !== null && !isGoal(goal))
|
|
204
|
+
throw new InvalidGoalStoreError("goal store contains an invalid goal");
|
|
205
|
+
return { version: STORE_VERSION, goal: goal === null ? null : sanitizeContinuationState(goal) };
|
|
206
|
+
}
|
|
207
|
+
function parseGoalFileJson(raw) {
|
|
46
208
|
let parsed;
|
|
47
209
|
try {
|
|
48
210
|
parsed = JSON.parse(raw);
|
|
@@ -60,13 +222,22 @@ function parseGoalFile(raw) {
|
|
|
60
222
|
throw error;
|
|
61
223
|
}
|
|
62
224
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
225
|
+
return parsed;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Drops legacy budget enforcement: `tokenBudget` is a budgeting input in `pi-goal`, and
|
|
229
|
+
* `budgetLimited` is a status this fork removed, so a budget-limited legacy goal resumes
|
|
230
|
+
* as `active`. This runs only on the legacy import path.
|
|
231
|
+
*/
|
|
232
|
+
function normalizeLegacyGoal(value) {
|
|
233
|
+
if (!isRecord(value))
|
|
234
|
+
return value;
|
|
235
|
+
const normalized = { ...value };
|
|
236
|
+
delete normalized.tokenBudget;
|
|
237
|
+
if (typeof normalized.status === "string" && LEGACY_BUDGET_LIMITED_STATUSES.includes(normalized.status)) {
|
|
238
|
+
normalized.status = "active";
|
|
239
|
+
}
|
|
240
|
+
return normalized;
|
|
70
241
|
}
|
|
71
242
|
function recoverGoalFileWithStaleClosingBraces(raw) {
|
|
72
243
|
let rootStart = 0;
|
|
@@ -144,6 +315,9 @@ function sanitizeContinuationState(goal) {
|
|
|
144
315
|
return next;
|
|
145
316
|
}
|
|
146
317
|
function isMissingFile(error) {
|
|
147
|
-
return error
|
|
318
|
+
return isFileSystemError(error, "ENOENT");
|
|
319
|
+
}
|
|
320
|
+
function isFileSystemError(error, code) {
|
|
321
|
+
return error instanceof Error && "code" in error && error.code === code;
|
|
148
322
|
}
|
|
149
323
|
//# sourceMappingURL=persistence.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/persistence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,gCAAgC,EAAE,MAAM,aAAa,CAAC;AAEtF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAEzE,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB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,eAAe,CAAC;QAC/C,wBAAwB,CAAC,KAAK,CAAC,SAAS,CAAC;QACzC,wBAAwB,CAAC,KAAK,CAAC,SAAS,CAAC;QACzC,CAAC,KAAK,CAAC,aAAa,KAAK,SAAS,IAAI,wBAAwB,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACpF,CAAC,KAAK,CAAC,WAAW,KAAK,SAAS,IAAI,wBAAwB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAChF,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,KAA8B,EAAE,MAAkB;IAChF,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,CACN,OAAO,KAAK,CAAC,aAAa,KAAK,QAAQ;YACvC,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;YACrC,wBAAwB,CAAC,KAAK,CAAC,SAAS,CAAC,CACzC,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,aAAa,KAAK,SAAS,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC;AAC3E,CAAC;AAED,SAAS,yBAAyB,CAAC,IAAU;IAC5C,MAAM,IAAI,GAAS,EAAE,GAAG,IAAI,EAAE,CAAC;IAC/B,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,wBAAwB,CAAC;QAAE,OAAO,IAAI,CAAC,wBAAwB,CAAC;IACnG,IAAI,OAAO,IAAI,CAAC,yBAAyB,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,yBAAyB,CAAC;IAC9F,OAAO,IAAI,CAAC;AACb,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACpC,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC7E,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { mkdir, readFile, rename, rm, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { InvalidGoalStoreError, UnsupportedGoalStoreVersionError } from \"./errors.ts\";\nimport type { Goal, GoalFile, GoalStatus, GoalStoreRef } from \"./types.ts\";\nimport { isRecord } from \"./types.ts\";\nimport { isGoalStatus, isNonNegativeSafeInteger } from \"./validation.ts\";\n\nconst STORE_VERSION = 1;\n\nexport function encodedThreadId(ref: GoalStoreRef): string {\n\treturn encodeURIComponent(ref.threadId);\n}\n\nexport function goalFilePath(ref: GoalStoreRef): string {\n\treturn join(ref.baseDir, `${encodedThreadId(ref)}.json`);\n}\n\nexport async function readGoalFile(ref: GoalStoreRef): Promise<Goal | null> {\n\ttry {\n\t\treturn parseGoalFile(await readFile(goalFilePath(ref), \"utf8\")).goal;\n\t} catch (error) {\n\t\tif (isMissingFile(error)) return null;\n\t\tthrow error;\n\t}\n}\n\nexport async function writeGoalFile(ref: GoalStoreRef, goal: Goal | null): Promise<void> {\n\tconst filePath = goalFilePath(ref);\n\tawait mkdir(dirname(filePath), { recursive: true });\n\tawait writeGoalFileAtomic(filePath, `${JSON.stringify({ version: STORE_VERSION, goal }, null, 2)}\\n`);\n}\n\nasync function writeGoalFileAtomic(filePath: string, contents: string): Promise<void> {\n\tconst tempPath = join(dirname(filePath), `.goal-${randomUUID()}.tmp`);\n\ttry {\n\t\tawait writeFile(tempPath, contents, { encoding: \"utf8\", mode: 0o600 });\n\t\tawait rename(tempPath, filePath);\n\t} catch (error) {\n\t\ttry {\n\t\t\tawait rm(tempPath, { force: true });\n\t\t} catch (cleanupError) {\n\t\t\tthrow new AggregateError(\n\t\t\t\t[error, cleanupError],\n\t\t\t\t\"goal store write failed and its temporary file could not be removed\",\n\t\t\t);\n\t\t}\n\t\tthrow error;\n\t}\n}\n\nfunction parseGoalFile(raw: string): GoalFile {\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch (error) {\n\t\tif (!(error instanceof SyntaxError)) throw error;\n\t\tconst recovered = recoverGoalFileWithStaleClosingBraces(raw);\n\t\tif (recovered === undefined) throw error;\n\t\ttry {\n\t\t\tparsed = JSON.parse(recovered);\n\t\t} catch {\n\t\t\tthrow error;\n\t\t}\n\t}\n\tif (!isRecord(parsed)) throw new InvalidGoalStoreError(\"goal store must be a JSON object\");\n\tif (parsed.version !== STORE_VERSION) throw new UnsupportedGoalStoreVersionError(\"unsupported goal store version\");\n\tif (parsed.goal !== null && !isGoal(parsed.goal))\n\t\tthrow new InvalidGoalStoreError(\"goal store contains an invalid goal\");\n\treturn { version: STORE_VERSION, goal: parsed.goal === null ? null : sanitizeContinuationState(parsed.goal) };\n}\n\nfunction recoverGoalFileWithStaleClosingBraces(raw: string): string | undefined {\n\tlet rootStart = 0;\n\twhile (rootStart < raw.length && /[\\t\\n\\r ]/.test(raw[rootStart] ?? \"\")) rootStart += 1;\n\tif (raw[rootStart] !== \"{\") return undefined;\n\n\tlet depth = 0;\n\tlet inString = false;\n\tlet escaped = false;\n\tfor (let index = rootStart; index < raw.length; index += 1) {\n\t\tconst character = raw[index];\n\t\tif (inString) {\n\t\t\tif (escaped) escaped = false;\n\t\t\telse if (character === \"\\\\\") escaped = true;\n\t\t\telse if (character === '\"') inString = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (character === '\"') inString = true;\n\t\telse if (character === \"{\" || character === \"[\") depth += 1;\n\t\telse if (character === \"}\" || character === \"]\") {\n\t\t\tdepth -= 1;\n\t\t\tif (depth < 0) return undefined;\n\t\t\tif (depth === 0) {\n\t\t\t\tlet hasStaleClosingBrace = false;\n\t\t\t\tfor (let suffixIndex = index + 1; suffixIndex < raw.length; suffixIndex += 1) {\n\t\t\t\t\tconst suffix = raw[suffixIndex];\n\t\t\t\t\tif (suffix === \"}\") hasStaleClosingBrace = true;\n\t\t\t\t\telse if (suffix !== \" \" && suffix !== \"\\t\" && suffix !== \"\\n\" && suffix !== \"\\r\") return undefined;\n\t\t\t\t}\n\t\t\t\treturn hasStaleClosingBrace ? raw.slice(0, index + 1) : undefined;\n\t\t\t}\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction isGoal(value: unknown): value is Goal {\n\tif (!isRecord(value)) return false;\n\treturn (\n\t\ttypeof value.id === \"string\" &&\n\t\ttypeof value.threadId === \"string\" &&\n\t\ttypeof value.objective === \"string\" &&\n\t\tisGoalStatus(value.status) &&\n\t\t(value.tokenBudget === undefined || isNonNegativeSafeInteger(value.tokenBudget)) &&\n\t\thasValidBlockedFields(value, value.status) &&\n\t\tisNonNegativeSafeInteger(value.tokensUsed) &&\n\t\tisNonNegativeSafeInteger(value.timeUsedSeconds) &&\n\t\tisNonNegativeSafeInteger(value.createdAt) &&\n\t\tisNonNegativeSafeInteger(value.updatedAt) &&\n\t\t(value.lastStartedAt === undefined || isNonNegativeSafeInteger(value.lastStartedAt)) &&\n\t\t(value.completedAt === undefined || isNonNegativeSafeInteger(value.completedAt))\n\t);\n}\n\nfunction hasValidBlockedFields(value: Record<string, unknown>, status: GoalStatus): boolean {\n\tif (status === \"blocked\") {\n\t\treturn (\n\t\t\ttypeof value.blockedReason === \"string\" &&\n\t\t\tvalue.blockedReason.trim().length > 0 &&\n\t\t\tisNonNegativeSafeInteger(value.blockedAt)\n\t\t);\n\t}\n\treturn value.blockedReason === undefined && value.blockedAt === undefined;\n}\n\nfunction sanitizeContinuationState(goal: Goal): Goal {\n\tconst next: Goal = { ...goal };\n\tif (!isNonNegativeSafeInteger(next.consecutiveContinuations)) delete next.consecutiveContinuations;\n\tif (typeof next.lastContinuationSignature !== \"string\") delete next.lastContinuationSignature;\n\treturn next;\n}\n\nfunction isMissingFile(error: unknown): boolean {\n\treturn error instanceof Error && \"code\" in error && error.code === \"ENOENT\";\n}\n"]}
|
|
1
|
+
{"version":3,"file":"persistence.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/persistence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAA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KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;AACzE,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { Dirent } from \"node:fs\";\nimport { mkdir, readdir, readFile, rename, rm, writeFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport { dirname, join, sep } from \"node:path\";\nimport { InvalidGoalStoreError, UnsupportedGoalStoreVersionError } from \"./errors.ts\";\nimport type { Goal, GoalFile, GoalStatus, GoalStoreRef } from \"./types.ts\";\nimport { isRecord } from \"./types.ts\";\nimport { isGoalStatus, isNonNegativeSafeInteger } from \"./validation.ts\";\n\nconst STORE_VERSION = 1;\nconst CURRENT_STORE_DIRECTORY = \"goal\";\nconst LEGACY_STORE_DIRECTORY = \"pi-goal\";\nconst LEGACY_BUDGET_LIMITED_STATUSES = [\"budgetLimited\", \"budget_limited\"];\n\nexport function encodedThreadId(ref: GoalStoreRef): string {\n\treturn encodeURIComponent(ref.threadId);\n}\n\nexport function goalFilePath(ref: GoalStoreRef): string {\n\treturn join(ref.baseDir, `${encodedThreadId(ref)}.json`);\n}\n\nexport async function readGoalFile(ref: GoalStoreRef): Promise<Goal | null> {\n\ttry {\n\t\treturn parseGoalFile(await readFile(goalFilePath(ref), \"utf8\")).goal;\n\t} catch (error) {\n\t\tif (isMissingFile(error)) return null;\n\t\tthrow error;\n\t}\n}\n\n/**\n * Imports legacy standalone `pi-goal` state into the current budget-free store.\n *\n * The current store always wins and legacy normalization is confined to this path.\n * Invalid, unsupported, or malformed legacy files are best-effort dead-data imports:\n * they remain untouched and do not block the live current store. Unexpected filesystem\n * failures still propagate.\n *\n * Session-backed stores use their stable thread id. No-session stores enumerate the\n * cwd-keyed legacy bucket because each ephemeral run receives a new thread id, and they\n * inspect both the redirected Senpi-root sibling and the standalone pi agent root.\n * Multiple valid live candidates are reported as a conflict rather than guessed.\n *\n * Returns the imported goal, or null when nothing was migrated.\n */\nexport async function migrateLegacyGoalFile(ref: GoalStoreRef): Promise<Goal | null> {\n\ttry {\n\t\tawait readFile(goalFilePath(ref), \"utf8\");\n\t\treturn null;\n\t} catch (error) {\n\t\tif (!isMissingFile(error)) throw error;\n\t}\n\n\tconst legacyCandidates = await readLegacyGoalCandidates(ref);\n\tif (legacyCandidates.length > 1) {\n\t\tthrow new Error(\n\t\t\t`multiple legacy goals found for no-session store: ${legacyCandidates.map(({ path }) => path).join(\", \")}`,\n\t\t);\n\t}\n\tconst candidate = legacyCandidates[0];\n\tif (candidate === undefined) return null;\n\tconst published = await publishMigratedGoalFile(ref, candidate.goal);\n\tawait retireLegacyGoalFile(candidate.path);\n\treturn published ? candidate.goal : null;\n}\n\ninterface LegacyGoalCandidate {\n\tpath: string;\n\tgoal: Goal;\n}\n\nasync function readLegacyGoalCandidates(ref: GoalStoreRef): Promise<LegacyGoalCandidate[]> {\n\tconst legacyBaseDir = legacyBaseDirFor(ref.baseDir);\n\tif (legacyBaseDir === undefined) return [];\n\tconst cwdKey = noSessionCwdKey(ref.baseDir);\n\tif (cwdKey === undefined) {\n\t\tconst candidate = await readLegacyGoalCandidate(goalFilePath({ ...ref, baseDir: legacyBaseDir }));\n\t\treturn candidate === null ? [] : [candidate];\n\t}\n\n\tconst standaloneAgentDir = process.env.PI_CODING_AGENT_DIR ?? join(homedir(), \".pi\", \"agent\");\n\tconst baseDirs = new Set([\n\t\tlegacyBaseDir,\n\t\tjoin(standaloneAgentDir, \"extensions\", LEGACY_STORE_DIRECTORY, \"no-session\", cwdKey),\n\t]);\n\tconst candidatePaths: string[] = [];\n\tfor (const baseDir of baseDirs) {\n\t\tlet entries: Dirent<string>[];\n\t\ttry {\n\t\t\tentries = await readdir(baseDir, { withFileTypes: true });\n\t\t} catch (error) {\n\t\t\tif (isMissingFile(error)) continue;\n\t\t\tthrow error;\n\t\t}\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.isFile() && entry.name.endsWith(\".json\")) candidatePaths.push(join(baseDir, entry.name));\n\t\t}\n\t}\n\n\tconst candidates: LegacyGoalCandidate[] = [];\n\tfor (const path of candidatePaths.sort()) {\n\t\tconst candidate = await readLegacyGoalCandidate(path);\n\t\tif (candidate !== null) candidates.push(candidate);\n\t}\n\treturn candidates;\n}\n\nasync function readLegacyGoalCandidate(path: string): Promise<LegacyGoalCandidate | null> {\n\tlet goal: Goal | null;\n\ttry {\n\t\tgoal = parseGoalFile(await readFile(path, \"utf8\"), { legacy: true }).goal;\n\t} catch (error) {\n\t\tif (isMissingFile(error) || isIgnoredLegacyStoreError(error)) return null;\n\t\tthrow error;\n\t}\n\tif (goal === null) {\n\t\tawait retireLegacyGoalFile(path);\n\t\treturn null;\n\t}\n\treturn { path, goal };\n}\n\nasync function retireLegacyGoalFile(path: string): Promise<void> {\n\ttry {\n\t\tawait rename(path, `${path}.migrated`);\n\t} catch {\n\t\t// Retirement is best-effort: a preserved legacy file must never fail live migration.\n\t}\n}\n\nfunction isIgnoredLegacyStoreError(error: unknown): boolean {\n\treturn (\n\t\terror instanceof InvalidGoalStoreError ||\n\t\terror instanceof UnsupportedGoalStoreVersionError ||\n\t\terror instanceof SyntaxError\n\t);\n}\n\n/**\n * Maps a current goal-store directory to its legacy `pi-goal` counterpart by replacing\n * the `goal` path segment itself.\n *\n * Both store layouts must map correctly:\n * <sessionDir>/extensions/goal -> <sessionDir>/extensions/pi-goal\n * <agentDir>/extensions/goal/no-session/<cwdKey>\n * -> <agentDir>/extensions/pi-goal/no-session/<cwdKey>\n *\n * Swapping `dirname(baseDir)` only works for the first layout; in the no-session\n * fallback it points inside the current store tree, which both misses real legacy\n * state and can import an unrelated nested directory.\n */\nfunction legacyBaseDirFor(baseDir: string): string | undefined {\n\tconst segments = pathSegments(baseDir);\n\tconst goalIndex = segments.lastIndexOf(CURRENT_STORE_DIRECTORY);\n\tif (goalIndex === -1) return undefined;\n\tsegments[goalIndex] = LEGACY_STORE_DIRECTORY;\n\treturn segments.join(sep);\n}\n\nfunction noSessionCwdKey(baseDir: string): string | undefined {\n\tconst segments = pathSegments(baseDir);\n\tconst goalIndex = segments.lastIndexOf(CURRENT_STORE_DIRECTORY);\n\tif (goalIndex === -1 || segments[goalIndex + 1] !== \"no-session\") return undefined;\n\treturn segments[goalIndex + 2];\n}\n\nfunction pathSegments(path: string): string[] {\n\treturn path.split(/[\\\\/]/);\n}\n\nexport async function writeGoalFile(ref: GoalStoreRef, goal: Goal | null): Promise<void> {\n\tconst filePath = goalFilePath(ref);\n\tawait mkdir(dirname(filePath), { recursive: true });\n\tawait writeGoalFileAtomic(filePath, `${JSON.stringify({ version: STORE_VERSION, goal }, null, 2)}\\n`);\n}\n\nasync function writeGoalFileAtomic(filePath: string, contents: string): Promise<void> {\n\tconst tempPath = join(dirname(filePath), `.goal-${randomUUID()}.tmp`);\n\ttry {\n\t\tawait writeFile(tempPath, contents, { encoding: \"utf8\", mode: 0o600 });\n\t\tawait rename(tempPath, filePath);\n\t} catch (error) {\n\t\ttry {\n\t\t\tawait rm(tempPath, { force: true });\n\t\t} catch (cleanupError) {\n\t\t\tthrow new AggregateError(\n\t\t\t\t[error, cleanupError],\n\t\t\t\t\"goal store write failed and its temporary file could not be removed\",\n\t\t\t);\n\t\t}\n\t\tthrow error;\n\t}\n}\n\nasync function publishMigratedGoalFile(ref: GoalStoreRef, goal: Goal): Promise<boolean> {\n\tconst filePath = goalFilePath(ref);\n\tawait mkdir(dirname(filePath), { recursive: true });\n\tconst contents = `${JSON.stringify({ version: STORE_VERSION, goal }, null, 2)}\\n`;\n\ttry {\n\t\tawait writeFile(filePath, contents, { encoding: \"utf8\", mode: 0o600, flag: \"wx\" });\n\t\treturn true;\n\t} catch (error) {\n\t\tif (isFileSystemError(error, \"EEXIST\")) return false;\n\t\tthrow error;\n\t}\n}\n\nfunction parseGoalFile(raw: string, { legacy = false }: { legacy?: boolean } = {}): GoalFile {\n\tconst parsed = parseGoalFileJson(raw);\n\tif (!isRecord(parsed)) throw new InvalidGoalStoreError(\"goal store must be a JSON object\");\n\tif (parsed.version !== STORE_VERSION) throw new UnsupportedGoalStoreVersionError(\"unsupported goal store version\");\n\tconst goal = legacy ? normalizeLegacyGoal(parsed.goal) : parsed.goal;\n\tif (goal !== null && !isGoal(goal)) throw new InvalidGoalStoreError(\"goal store contains an invalid goal\");\n\treturn { version: STORE_VERSION, goal: goal === null ? null : sanitizeContinuationState(goal) };\n}\n\nfunction parseGoalFileJson(raw: string): unknown {\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch (error) {\n\t\tif (!(error instanceof SyntaxError)) throw error;\n\t\tconst recovered = recoverGoalFileWithStaleClosingBraces(raw);\n\t\tif (recovered === undefined) throw error;\n\t\ttry {\n\t\t\tparsed = JSON.parse(recovered);\n\t\t} catch {\n\t\t\tthrow error;\n\t\t}\n\t}\n\treturn parsed;\n}\n\n/**\n * Drops legacy budget enforcement: `tokenBudget` is a budgeting input in `pi-goal`, and\n * `budgetLimited` is a status this fork removed, so a budget-limited legacy goal resumes\n * as `active`. This runs only on the legacy import path.\n */\nfunction normalizeLegacyGoal(value: unknown): unknown {\n\tif (!isRecord(value)) return value;\n\tconst normalized = { ...value };\n\tdelete normalized.tokenBudget;\n\tif (typeof normalized.status === \"string\" && LEGACY_BUDGET_LIMITED_STATUSES.includes(normalized.status)) {\n\t\tnormalized.status = \"active\";\n\t}\n\treturn normalized;\n}\n\nfunction recoverGoalFileWithStaleClosingBraces(raw: string): string | undefined {\n\tlet rootStart = 0;\n\twhile (rootStart < raw.length && /[\\t\\n\\r ]/.test(raw[rootStart] ?? \"\")) rootStart += 1;\n\tif (raw[rootStart] !== \"{\") return undefined;\n\n\tlet depth = 0;\n\tlet inString = false;\n\tlet escaped = false;\n\tfor (let index = rootStart; index < raw.length; index += 1) {\n\t\tconst character = raw[index];\n\t\tif (inString) {\n\t\t\tif (escaped) escaped = false;\n\t\t\telse if (character === \"\\\\\") escaped = true;\n\t\t\telse if (character === '\"') inString = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (character === '\"') inString = true;\n\t\telse if (character === \"{\" || character === \"[\") depth += 1;\n\t\telse if (character === \"}\" || character === \"]\") {\n\t\t\tdepth -= 1;\n\t\t\tif (depth < 0) return undefined;\n\t\t\tif (depth === 0) {\n\t\t\t\tlet hasStaleClosingBrace = false;\n\t\t\t\tfor (let suffixIndex = index + 1; suffixIndex < raw.length; suffixIndex += 1) {\n\t\t\t\t\tconst suffix = raw[suffixIndex];\n\t\t\t\t\tif (suffix === \"}\") hasStaleClosingBrace = true;\n\t\t\t\t\telse if (suffix !== \" \" && suffix !== \"\\t\" && suffix !== \"\\n\" && suffix !== \"\\r\") return undefined;\n\t\t\t\t}\n\t\t\t\treturn hasStaleClosingBrace ? raw.slice(0, index + 1) : undefined;\n\t\t\t}\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction isGoal(value: unknown): value is Goal {\n\tif (!isRecord(value)) return false;\n\treturn (\n\t\ttypeof value.id === \"string\" &&\n\t\ttypeof value.threadId === \"string\" &&\n\t\ttypeof value.objective === \"string\" &&\n\t\tisGoalStatus(value.status) &&\n\t\t(value.tokenBudget === undefined || isNonNegativeSafeInteger(value.tokenBudget)) &&\n\t\thasValidBlockedFields(value, value.status) &&\n\t\tisNonNegativeSafeInteger(value.tokensUsed) &&\n\t\tisNonNegativeSafeInteger(value.timeUsedSeconds) &&\n\t\tisNonNegativeSafeInteger(value.createdAt) &&\n\t\tisNonNegativeSafeInteger(value.updatedAt) &&\n\t\t(value.lastStartedAt === undefined || isNonNegativeSafeInteger(value.lastStartedAt)) &&\n\t\t(value.completedAt === undefined || isNonNegativeSafeInteger(value.completedAt))\n\t);\n}\n\nfunction hasValidBlockedFields(value: Record<string, unknown>, status: GoalStatus): boolean {\n\tif (status === \"blocked\") {\n\t\treturn (\n\t\t\ttypeof value.blockedReason === \"string\" &&\n\t\t\tvalue.blockedReason.trim().length > 0 &&\n\t\t\tisNonNegativeSafeInteger(value.blockedAt)\n\t\t);\n\t}\n\treturn value.blockedReason === undefined && value.blockedAt === undefined;\n}\n\nfunction sanitizeContinuationState(goal: Goal): Goal {\n\tconst next: Goal = { ...goal };\n\tif (!isNonNegativeSafeInteger(next.consecutiveContinuations)) delete next.consecutiveContinuations;\n\tif (typeof next.lastContinuationSignature !== \"string\") delete next.lastContinuationSignature;\n\treturn next;\n}\n\nfunction isMissingFile(error: unknown): boolean {\n\treturn isFileSystemError(error, \"ENOENT\");\n}\n\nfunction isFileSystemError(error: unknown, code: string): boolean {\n\treturn error instanceof Error && \"code\" in error && error.code === code;\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ExtensionContext } from "../../types.ts";
|
|
2
2
|
import type { Goal } from "./types.ts";
|
|
3
3
|
export declare const STATUS_KEY = "goal";
|
|
4
|
+
export declare function truncateGoalObjective(objective: string, maxLength?: number): string;
|
|
4
5
|
export declare function updateGoalUi(ctx: ExtensionContext, goal: Goal | null, liveElapsedSeconds?: number): void;
|
|
5
6
|
export declare function goalStatusText(goal: Goal, liveElapsedSeconds?: number): string;
|
|
6
7
|
//# sourceMappingURL=ui.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,eAAO,MAAM,UAAU,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,eAAO,MAAM,UAAU,SAAS,CAAC;AAIjC,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,SAA+B,GAAG,MAAM,CAIzG;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAGxG;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,CAmB9E"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { formatGoalElapsedSeconds } from "./format.js";
|
|
2
2
|
export const STATUS_KEY = "goal";
|
|
3
|
+
const OBJECTIVE_PREVIEW_MAX_LENGTH = 32;
|
|
4
|
+
export function truncateGoalObjective(objective, maxLength = OBJECTIVE_PREVIEW_MAX_LENGTH) {
|
|
5
|
+
const normalized = objective.replace(/\s+/g, " ").trim();
|
|
6
|
+
if (normalized.length <= maxLength)
|
|
7
|
+
return normalized;
|
|
8
|
+
return `${normalized.slice(0, Math.max(0, maxLength - 1)).trimEnd()}\u2026`;
|
|
9
|
+
}
|
|
3
10
|
export function updateGoalUi(ctx, goal, liveElapsedSeconds) {
|
|
4
11
|
if (!ctx.hasUI)
|
|
5
12
|
return;
|
|
@@ -19,8 +26,10 @@ export function goalStatusText(goal, liveElapsedSeconds) {
|
|
|
19
26
|
return "Goal paused (/goal resume)";
|
|
20
27
|
case "blocked":
|
|
21
28
|
return goal.blockedReason ? `Goal blocked: ${goal.blockedReason}` : "Goal blocked";
|
|
22
|
-
case "complete":
|
|
23
|
-
|
|
29
|
+
case "complete": {
|
|
30
|
+
const elapsed = goal.timeUsedSeconds > 0 ? ` (${formatGoalElapsedSeconds(goal.timeUsedSeconds)})` : "";
|
|
31
|
+
return `${truncateGoalObjective(goal.objective)} \u00b7 Goal achieved${elapsed}`;
|
|
32
|
+
}
|
|
24
33
|
}
|
|
25
34
|
}
|
|
26
35
|
//# sourceMappingURL=ui.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/ui.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAGvD,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC;AAEjC,MAAM,UAAU,YAAY,CAAC,GAAqB,EAAE,IAAiB,EAAE,kBAA2B;IACjG,IAAI,CAAC,GAAG,CAAC,KAAK;QAAE,OAAO;IACvB,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC;AACpG,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAU,EAAE,kBAA2B;IACrE,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACrB,KAAK,QAAQ,EAAE,CAAC;YACf,IAAI,kBAAkB,KAAK,SAAS,EAAE,CAAC;gBACtC,OAAO,kBAAkB,wBAAwB,CAAC,kBAAkB,CAAC,GAAG,CAAC;YAC1E,CAAC;YACD,OAAO,IAAI,CAAC,eAAe,GAAG,CAAC;gBAC9B,CAAC,CAAC,kBAAkB,wBAAwB,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG;gBACrE,CAAC,CAAC,eAAe,CAAC;QACpB,CAAC;QACD,KAAK,QAAQ;YACZ,OAAO,4BAA4B,CAAC;QACrC,KAAK,SAAS;YACb,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,iBAAiB,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC;QACpF,KAAK,UAAU;
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/ui.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAGvD,MAAM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,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,iBAAiB,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC;QACpF,KAAK,UAAU,EAAE,CAAC;YACjB,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,wBAAwB,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACvG,OAAO,GAAG,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,wBAAwB,OAAO,EAAE,CAAC;QAClF,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import type { ExtensionContext } from \"../../types.ts\";\nimport { formatGoalElapsedSeconds } from \"./format.ts\";\nimport type { Goal } from \"./types.ts\";\n\nexport const STATUS_KEY = \"goal\";\n\nconst OBJECTIVE_PREVIEW_MAX_LENGTH = 32;\n\nexport function truncateGoalObjective(objective: string, maxLength = OBJECTIVE_PREVIEW_MAX_LENGTH): string {\n\tconst normalized = objective.replace(/\\s+/g, \" \").trim();\n\tif (normalized.length <= maxLength) return normalized;\n\treturn `${normalized.slice(0, Math.max(0, maxLength - 1)).trimEnd()}\\u2026`;\n}\n\nexport function updateGoalUi(ctx: ExtensionContext, goal: Goal | null, liveElapsedSeconds?: number): void {\n\tif (!ctx.hasUI) return;\n\tctx.ui.setStatus(STATUS_KEY, goal === null ? undefined : goalStatusText(goal, liveElapsedSeconds));\n}\n\nexport function goalStatusText(goal: Goal, liveElapsedSeconds?: number): string {\n\tswitch (goal.status) {\n\t\tcase \"active\": {\n\t\t\tif (liveElapsedSeconds !== undefined) {\n\t\t\t\treturn `Pursuing goal (${formatGoalElapsedSeconds(liveElapsedSeconds)})`;\n\t\t\t}\n\t\t\treturn goal.timeUsedSeconds > 0\n\t\t\t\t? `Pursuing goal (${formatGoalElapsedSeconds(goal.timeUsedSeconds)})`\n\t\t\t\t: \"Pursuing goal\";\n\t\t}\n\t\tcase \"paused\":\n\t\t\treturn \"Goal paused (/goal resume)\";\n\t\tcase \"blocked\":\n\t\t\treturn goal.blockedReason ? `Goal blocked: ${goal.blockedReason}` : \"Goal blocked\";\n\t\tcase \"complete\": {\n\t\t\tconst elapsed = goal.timeUsedSeconds > 0 ? ` (${formatGoalElapsedSeconds(goal.timeUsedSeconds)})` : \"\";\n\t\t\treturn `${truncateGoalObjective(goal.objective)} \\u00b7 Goal achieved${elapsed}`;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { buildPartialFailureText } from "./recovery.ts";
|
|
2
2
|
import type { ApplyPatchProgressCallback, ApplyPatchResult, AtomicWriteOperations } from "./types.ts";
|
|
3
|
+
export declare function compactApplyPatchResult(result: ApplyPatchResult): ApplyPatchResult;
|
|
3
4
|
export declare function __testWriteFileAtomic(absPath: string, content: string, operations: AtomicWriteOperations): Promise<void>;
|
|
4
5
|
export declare function applyPatchDetailed(cwd: string, patchText: string, onProgress?: ApplyPatchProgressCallback): Promise<ApplyPatchResult>;
|
|
5
6
|
export declare function applyPatch(cwd: string, patchText: string): Promise<string[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/apply.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAGxD,OAAO,KAAK,EAGX,0BAA0B,EAC1B,gBAAgB,EAChB,qBAAqB,EAErB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/apply.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAGxD,OAAO,KAAK,EAGX,0BAA0B,EAC1B,gBAAgB,EAChB,qBAAqB,EAErB,MAAM,YAAY,CAAC;AA2BpB,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAWlF;AAkBD,wBAAsB,qBAAqB,CAC1C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,qBAAqB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAEf;AA2FD,wBAAsB,kBAAkB,CACvC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,0BAA0B,GACrC,OAAO,CAAC,gBAAgB,CAAC,CAqC3B;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA6BlF"}
|
|
@@ -27,6 +27,18 @@ function extractErrorCode(error) {
|
|
|
27
27
|
}
|
|
28
28
|
return undefined;
|
|
29
29
|
}
|
|
30
|
+
export function compactApplyPatchResult(result) {
|
|
31
|
+
return {
|
|
32
|
+
...result,
|
|
33
|
+
details: {
|
|
34
|
+
...result.details,
|
|
35
|
+
appliedOperations: result.details.appliedOperations.map(({ operationIndex, preview }) => {
|
|
36
|
+
const { diff: _diff, patch: _patch, ...metadata } = preview;
|
|
37
|
+
return { operationIndex, preview: { ...metadata, diff: "" } };
|
|
38
|
+
}),
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
30
42
|
async function writeFileAtomic(absPath, content, operations = ATOMIC_WRITE_OPERATIONS) {
|
|
31
43
|
const tempPath = `${absPath}.tmp.${process.pid}.${Math.random().toString(16).slice(2)}`;
|
|
32
44
|
await operations.writeFile(tempPath, content, "utf-8");
|
|
@@ -179,7 +191,7 @@ export async function applyPatch(cwd, patchText) {
|
|
|
179
191
|
recoveryInstructions: createRecoveryInstructions({ appliedFiles, failures }),
|
|
180
192
|
details: { fuzz: 0, appliedOperations },
|
|
181
193
|
};
|
|
182
|
-
throw new ApplyPatchError(message, result);
|
|
194
|
+
throw new ApplyPatchError(message, compactApplyPatchResult(result));
|
|
183
195
|
}
|
|
184
196
|
}
|
|
185
197
|
return summaries;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/apply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAS/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,uBAAuB,GAA0B,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAErF,KAAK,UAAU,wBAAwB,CACtC,UAAkD,EAClD,QAAmD;IAEnD,IAAI,CAAC;QACJ,MAAM,UAAU,EAAE,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACR,4EAA4E;IAC7E,CAAC;AACF,CAAC;AAED,SAAS,YAAY,CAAC,KAAc,EAAE,IAAY;IACjD,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAC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,GAAG,EAAE,IAAI,CAAC,CAAC;YACjD,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAChC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YACvC,iBAAiB,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QACtE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,MAAM,QAAQ,GAAwB;gBACrC,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,CAAC,KAAK,CAAC,EAAE;aACzG,CAAC;YACF,MAAM,MAAM,GAAqB;gBAChC,SAAS;gBACT,YAAY;gBACZ,QAAQ;gBACR,iBAAiB,EAAE,YAAY,CAAC,MAAM,GAAG,CAAC;gBAC1C,oBAAoB,EAAE,0BAA0B,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;gBAC5E,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,iBAAiB,EAAE;aACvC,CAAC;YACF,MAAM,IAAI,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5C,CAAC;IACF,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import { mkdir, readFile, rename, rm, unlink, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { withFileMutationQueue } from \"../../../tools/file-mutation-queue.ts\";\nimport { ApplyPatchError } from \"./errors.ts\";\nimport { parsePatch } from \"./parser.ts\";\nimport { replaceChunks } from \"./patch-replace.ts\";\nimport { buildPatchPreviewFile, readPatchFileSnapshot } from \"./preview.ts\";\nimport { createRecoveryInstructions } from \"./recovery.ts\";\n\nexport { buildPartialFailureText } from \"./recovery.ts\";\n\nimport { normalizePatchText } from \"./text.ts\";\nimport type {\n\tAppliedPatchOperation,\n\tApplyPatchFailure,\n\tApplyPatchProgressCallback,\n\tApplyPatchResult,\n\tAtomicWriteOperations,\n\tParsedPatch,\n} from \"./types.ts\";\nimport { resolvePatchPath } from \"./workspace.ts\";\n\nconst ATOMIC_WRITE_OPERATIONS: AtomicWriteOperations = { writeFile, rename, unlink };\n\nasync function notifyApplyPatchProgress(\n\tonProgress: ApplyPatchProgressCallback | undefined,\n\tprogress: Parameters<ApplyPatchProgressCallback>[0],\n): Promise<void> {\n\ttry {\n\t\tawait onProgress?.(progress);\n\t} catch {\n\t\t// Rendering progress must not affect patch application or recovery details.\n\t}\n}\n\nfunction hasErrorCode(error: unknown, code: string): boolean {\n\treturn Boolean(error && typeof error === \"object\" && \"code\" in error && error.code === code);\n}\n\nfunction extractErrorCode(error: unknown): string | undefined {\n\tif (error && typeof error === \"object\" && \"code\" in error && typeof error.code === \"string\") {\n\t\treturn error.code;\n\t}\n\treturn undefined;\n}\n\nasync function writeFileAtomic(\n\tabsPath: string,\n\tcontent: string,\n\toperations: AtomicWriteOperations = ATOMIC_WRITE_OPERATIONS,\n): Promise<void> {\n\tconst tempPath = `${absPath}.tmp.${process.pid}.${Math.random().toString(16).slice(2)}`;\n\tawait operations.writeFile(tempPath, content, \"utf-8\");\n\ttry {\n\t\tawait operations.rename(tempPath, absPath);\n\t} catch (error) {\n\t\tif (!hasErrorCode(error, \"EEXIST\")) throw error;\n\t\tawait operations.unlink(absPath);\n\t\tawait operations.rename(tempPath, absPath);\n\t}\n}\n\nexport async function __testWriteFileAtomic(\n\tabsPath: string,\n\tcontent: string,\n\toperations: AtomicWriteOperations,\n): Promise<void> {\n\tawait writeFileAtomic(absPath, content, operations);\n}\n\nasync function applySingleHunk(\n\tcwd: string,\n\thunk: ParsedPatch,\n): Promise<{\n\treadonly summary: string;\n\treadonly appliedFile: string;\n\treadonly fuzz: number;\n\treadonly preview: ReturnType<typeof buildPatchPreviewFile>;\n}> {\n\tconst absolutePath = resolvePatchPath(cwd, hunk.filePath);\n\tconst mutationPaths =\n\t\thunk.type === \"update\" && hunk.movePath ? [absolutePath, resolvePatchPath(cwd, hunk.movePath)] : [absolutePath];\n\treturn withPatchMutationQueues(mutationPaths, async () => {\n\t\tif (hunk.type === \"add\") {\n\t\t\tconst source = await readPatchFileSnapshot(absolutePath);\n\t\t\tconst preview = buildPatchPreviewFile({ hunk, source, newContent: hunk.content });\n\t\t\tawait mkdir(path.dirname(absolutePath), { recursive: true });\n\t\t\tawait writeFileAtomic(absolutePath, hunk.content);\n\t\t\treturn { summary: `add: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: 0, preview };\n\t\t}\n\n\t\tif (hunk.type === \"delete\") {\n\t\t\tconst oldContent = await readFile(absolutePath, \"utf-8\");\n\t\t\tconst preview = buildPatchPreviewFile({\n\t\t\t\thunk,\n\t\t\t\tsource: { exists: true, content: oldContent },\n\t\t\t\tnewContent: \"\",\n\t\t\t});\n\t\t\tawait rm(absolutePath);\n\t\t\treturn { summary: `delete: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: 0, preview };\n\t\t}\n\n\t\tconst currentContent = await readFile(absolutePath, \"utf-8\");\n\t\tconst chunkResult =\n\t\t\thunk.chunks.length === 0\n\t\t\t\t? { content: currentContent, fuzz: 0 }\n\t\t\t\t: replaceChunks(currentContent, hunk.filePath, hunk.chunks);\n\n\t\tif (hunk.movePath) {\n\t\t\tconst absoluteMovePath = resolvePatchPath(cwd, hunk.movePath);\n\t\t\tconst moveDestination =\n\t\t\t\tabsoluteMovePath === absolutePath ? undefined : await readPatchFileSnapshot(absoluteMovePath);\n\t\t\tconst preview = buildPatchPreviewFile({\n\t\t\t\thunk,\n\t\t\t\tsource: { exists: true, content: currentContent },\n\t\t\t\tnewContent: chunkResult.content,\n\t\t\t\t...(moveDestination ? { moveDestination } : {}),\n\t\t\t});\n\t\t\tawait mkdir(path.dirname(absoluteMovePath), { recursive: true });\n\t\t\tawait writeFileAtomic(absoluteMovePath, chunkResult.content);\n\t\t\tif (absoluteMovePath !== absolutePath) await rm(absolutePath);\n\t\t\treturn {\n\t\t\t\tsummary: `move: ${hunk.filePath} -> ${hunk.movePath}`,\n\t\t\t\tappliedFile: hunk.movePath,\n\t\t\t\tfuzz: chunkResult.fuzz,\n\t\t\t\tpreview,\n\t\t\t};\n\t\t}\n\n\t\tconst preview = buildPatchPreviewFile({\n\t\t\thunk,\n\t\t\tsource: { exists: true, content: currentContent },\n\t\t\tnewContent: chunkResult.content,\n\t\t});\n\t\tawait writeFileAtomic(absolutePath, chunkResult.content);\n\t\treturn { summary: `update: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: chunkResult.fuzz, preview };\n\t});\n}\n\nasync function withPatchMutationQueues<T>(filePaths: readonly string[], operation: () => Promise<T>): Promise<T> {\n\tconst sortedPaths = [...new Set(filePaths)].sort((left, right) => left.localeCompare(right));\n\tconst runQueued = (index: number): Promise<T> => {\n\t\tconst filePath = sortedPaths[index];\n\t\tif (filePath === undefined) return operation();\n\t\treturn withFileMutationQueue(filePath, () => runQueued(index + 1));\n\t};\n\treturn runQueued(0);\n}\n\nfunction parseNonEmptyPatch(patchText: string): ParsedPatch[] {\n\tconst hunks = parsePatch(patchText);\n\tif (hunks.length === 0) {\n\t\tconst normalized = normalizePatchText(patchText).trim();\n\t\tif (normalized === \"*** Begin Patch\\n*** End Patch\") throw new Error(\"patch rejected: empty patch\");\n\t\tthrow new Error(\"apply_patch verification failed: no hunks found\");\n\t}\n\treturn hunks;\n}\n\nexport async function applyPatchDetailed(\n\tcwd: string,\n\tpatchText: string,\n\tonProgress?: ApplyPatchProgressCallback,\n): Promise<ApplyPatchResult> {\n\tconst hunks = parseNonEmptyPatch(patchText);\n\tconst summaries: string[] = [];\n\tconst appliedFiles: string[] = [];\n\tconst appliedOperations: AppliedPatchOperation[] = [];\n\tconst failures: ApplyPatchFailure[] = [];\n\tlet fuzz = 0;\n\n\tfor (const [operationIndex, hunk] of hunks.entries()) {\n\t\ttry {\n\t\t\tconst applied = await applySingleHunk(cwd, hunk);\n\t\t\tsummaries.push(applied.summary);\n\t\t\tappliedFiles.push(applied.appliedFile);\n\t\t\tappliedOperations.push({ operationIndex, preview: applied.preview });\n\t\t\tfuzz += applied.fuzz;\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tconst code = extractErrorCode(error);\n\t\t\tfailures.push({ operationIndex, filePath: hunk.filePath, operation: hunk.type, message, code });\n\t\t}\n\t\tawait notifyApplyPatchProgress(onProgress, {\n\t\t\tapplied: appliedFiles.length,\n\t\t\tfailed: failures.length,\n\t\t\ttotal: hunks.length,\n\t\t});\n\t}\n\n\tconst result: ApplyPatchResult = {\n\t\tsummaries,\n\t\tappliedFiles,\n\t\tfailures,\n\t\thasPartialSuccess: appliedFiles.length > 0 && failures.length > 0,\n\t\trecoveryInstructions: { mustReadFiles: [], mustNotReadFiles: [], failedFiles: [] },\n\t\tdetails: { fuzz, appliedOperations },\n\t};\n\tresult.recoveryInstructions = createRecoveryInstructions(result);\n\treturn result;\n}\n\nexport async function applyPatch(cwd: string, patchText: string): Promise<string[]> {\n\tconst hunks = parseNonEmptyPatch(patchText);\n\tconst summaries: string[] = [];\n\tconst appliedFiles: string[] = [];\n\tconst appliedOperations: AppliedPatchOperation[] = [];\n\tfor (const [operationIndex, hunk] of hunks.entries()) {\n\t\ttry {\n\t\t\tconst applied = await applySingleHunk(cwd, hunk);\n\t\t\tsummaries.push(applied.summary);\n\t\t\tappliedFiles.push(applied.appliedFile);\n\t\t\tappliedOperations.push({ operationIndex, preview: applied.preview });\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tconst failures: ApplyPatchFailure[] = [\n\t\t\t\t{ operationIndex, filePath: hunk.filePath, operation: hunk.type, message, code: extractErrorCode(error) },\n\t\t\t];\n\t\t\tconst result: ApplyPatchResult = {\n\t\t\t\tsummaries,\n\t\t\t\tappliedFiles,\n\t\t\t\tfailures,\n\t\t\t\thasPartialSuccess: appliedFiles.length > 0,\n\t\t\t\trecoveryInstructions: createRecoveryInstructions({ appliedFiles, failures }),\n\t\t\t\tdetails: { fuzz: 0, appliedOperations },\n\t\t\t};\n\t\t\tthrow new ApplyPatchError(message, result);\n\t\t}\n\t}\n\n\treturn summaries;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/apply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAS/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,uBAAuB,GAA0B,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAErF,KAAK,UAAU,wBAAwB,CACtC,UAAkD,EAClD,QAAmD;IAEnD,IAAI,CAAC;QACJ,MAAM,UAAU,EAAE,CAAC,QAAQ,CA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AI,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,CAAC,KAAK,CAAC,EAAE;aACzG,CAAC;YACF,MAAM,MAAM,GAAqB;gBAChC,SAAS;gBACT,YAAY;gBACZ,QAAQ;gBACR,iBAAiB,EAAE,YAAY,CAAC,MAAM,GAAG,CAAC;gBAC1C,oBAAoB,EAAE,0BAA0B,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;gBAC5E,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,iBAAiB,EAAE;aACvC,CAAC;YACF,MAAM,IAAI,eAAe,CAAC,OAAO,EAAE,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC;QACrE,CAAC;IACF,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import { mkdir, readFile, rename, rm, unlink, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { withFileMutationQueue } from \"../../../tools/file-mutation-queue.ts\";\nimport { ApplyPatchError } from \"./errors.ts\";\nimport { parsePatch } from \"./parser.ts\";\nimport { replaceChunks } from \"./patch-replace.ts\";\nimport { buildPatchPreviewFile, readPatchFileSnapshot } from \"./preview.ts\";\nimport { createRecoveryInstructions } from \"./recovery.ts\";\n\nexport { buildPartialFailureText } from \"./recovery.ts\";\n\nimport { normalizePatchText } from \"./text.ts\";\nimport type {\n\tAppliedPatchOperation,\n\tApplyPatchFailure,\n\tApplyPatchProgressCallback,\n\tApplyPatchResult,\n\tAtomicWriteOperations,\n\tParsedPatch,\n} from \"./types.ts\";\nimport { resolvePatchPath } from \"./workspace.ts\";\n\nconst ATOMIC_WRITE_OPERATIONS: AtomicWriteOperations = { writeFile, rename, unlink };\n\nasync function notifyApplyPatchProgress(\n\tonProgress: ApplyPatchProgressCallback | undefined,\n\tprogress: Parameters<ApplyPatchProgressCallback>[0],\n): Promise<void> {\n\ttry {\n\t\tawait onProgress?.(progress);\n\t} catch {\n\t\t// Rendering progress must not affect patch application or recovery details.\n\t}\n}\n\nfunction hasErrorCode(error: unknown, code: string): boolean {\n\treturn Boolean(error && typeof error === \"object\" && \"code\" in error && error.code === code);\n}\n\nfunction extractErrorCode(error: unknown): string | undefined {\n\tif (error && typeof error === \"object\" && \"code\" in error && typeof error.code === \"string\") {\n\t\treturn error.code;\n\t}\n\treturn undefined;\n}\n\nexport function compactApplyPatchResult(result: ApplyPatchResult): ApplyPatchResult {\n\treturn {\n\t\t...result,\n\t\tdetails: {\n\t\t\t...result.details,\n\t\t\tappliedOperations: result.details.appliedOperations.map(({ operationIndex, preview }) => {\n\t\t\t\tconst { diff: _diff, patch: _patch, ...metadata } = preview;\n\t\t\t\treturn { operationIndex, preview: { ...metadata, diff: \"\" } };\n\t\t\t}),\n\t\t},\n\t};\n}\n\nasync function writeFileAtomic(\n\tabsPath: string,\n\tcontent: string,\n\toperations: AtomicWriteOperations = ATOMIC_WRITE_OPERATIONS,\n): Promise<void> {\n\tconst tempPath = `${absPath}.tmp.${process.pid}.${Math.random().toString(16).slice(2)}`;\n\tawait operations.writeFile(tempPath, content, \"utf-8\");\n\ttry {\n\t\tawait operations.rename(tempPath, absPath);\n\t} catch (error) {\n\t\tif (!hasErrorCode(error, \"EEXIST\")) throw error;\n\t\tawait operations.unlink(absPath);\n\t\tawait operations.rename(tempPath, absPath);\n\t}\n}\n\nexport async function __testWriteFileAtomic(\n\tabsPath: string,\n\tcontent: string,\n\toperations: AtomicWriteOperations,\n): Promise<void> {\n\tawait writeFileAtomic(absPath, content, operations);\n}\n\nasync function applySingleHunk(\n\tcwd: string,\n\thunk: ParsedPatch,\n): Promise<{\n\treadonly summary: string;\n\treadonly appliedFile: string;\n\treadonly fuzz: number;\n\treadonly preview: ReturnType<typeof buildPatchPreviewFile>;\n}> {\n\tconst absolutePath = resolvePatchPath(cwd, hunk.filePath);\n\tconst mutationPaths =\n\t\thunk.type === \"update\" && hunk.movePath ? [absolutePath, resolvePatchPath(cwd, hunk.movePath)] : [absolutePath];\n\treturn withPatchMutationQueues(mutationPaths, async () => {\n\t\tif (hunk.type === \"add\") {\n\t\t\tconst source = await readPatchFileSnapshot(absolutePath);\n\t\t\tconst preview = buildPatchPreviewFile({ hunk, source, newContent: hunk.content });\n\t\t\tawait mkdir(path.dirname(absolutePath), { recursive: true });\n\t\t\tawait writeFileAtomic(absolutePath, hunk.content);\n\t\t\treturn { summary: `add: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: 0, preview };\n\t\t}\n\n\t\tif (hunk.type === \"delete\") {\n\t\t\tconst oldContent = await readFile(absolutePath, \"utf-8\");\n\t\t\tconst preview = buildPatchPreviewFile({\n\t\t\t\thunk,\n\t\t\t\tsource: { exists: true, content: oldContent },\n\t\t\t\tnewContent: \"\",\n\t\t\t});\n\t\t\tawait rm(absolutePath);\n\t\t\treturn { summary: `delete: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: 0, preview };\n\t\t}\n\n\t\tconst currentContent = await readFile(absolutePath, \"utf-8\");\n\t\tconst chunkResult =\n\t\t\thunk.chunks.length === 0\n\t\t\t\t? { content: currentContent, fuzz: 0 }\n\t\t\t\t: replaceChunks(currentContent, hunk.filePath, hunk.chunks);\n\n\t\tif (hunk.movePath) {\n\t\t\tconst absoluteMovePath = resolvePatchPath(cwd, hunk.movePath);\n\t\t\tconst moveDestination =\n\t\t\t\tabsoluteMovePath === absolutePath ? undefined : await readPatchFileSnapshot(absoluteMovePath);\n\t\t\tconst preview = buildPatchPreviewFile({\n\t\t\t\thunk,\n\t\t\t\tsource: { exists: true, content: currentContent },\n\t\t\t\tnewContent: chunkResult.content,\n\t\t\t\t...(moveDestination ? { moveDestination } : {}),\n\t\t\t});\n\t\t\tawait mkdir(path.dirname(absoluteMovePath), { recursive: true });\n\t\t\tawait writeFileAtomic(absoluteMovePath, chunkResult.content);\n\t\t\tif (absoluteMovePath !== absolutePath) await rm(absolutePath);\n\t\t\treturn {\n\t\t\t\tsummary: `move: ${hunk.filePath} -> ${hunk.movePath}`,\n\t\t\t\tappliedFile: hunk.movePath,\n\t\t\t\tfuzz: chunkResult.fuzz,\n\t\t\t\tpreview,\n\t\t\t};\n\t\t}\n\n\t\tconst preview = buildPatchPreviewFile({\n\t\t\thunk,\n\t\t\tsource: { exists: true, content: currentContent },\n\t\t\tnewContent: chunkResult.content,\n\t\t});\n\t\tawait writeFileAtomic(absolutePath, chunkResult.content);\n\t\treturn { summary: `update: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: chunkResult.fuzz, preview };\n\t});\n}\n\nasync function withPatchMutationQueues<T>(filePaths: readonly string[], operation: () => Promise<T>): Promise<T> {\n\tconst sortedPaths = [...new Set(filePaths)].sort((left, right) => left.localeCompare(right));\n\tconst runQueued = (index: number): Promise<T> => {\n\t\tconst filePath = sortedPaths[index];\n\t\tif (filePath === undefined) return operation();\n\t\treturn withFileMutationQueue(filePath, () => runQueued(index + 1));\n\t};\n\treturn runQueued(0);\n}\n\nfunction parseNonEmptyPatch(patchText: string): ParsedPatch[] {\n\tconst hunks = parsePatch(patchText);\n\tif (hunks.length === 0) {\n\t\tconst normalized = normalizePatchText(patchText).trim();\n\t\tif (normalized === \"*** Begin Patch\\n*** End Patch\") throw new Error(\"patch rejected: empty patch\");\n\t\tthrow new Error(\"apply_patch verification failed: no hunks found\");\n\t}\n\treturn hunks;\n}\n\nexport async function applyPatchDetailed(\n\tcwd: string,\n\tpatchText: string,\n\tonProgress?: ApplyPatchProgressCallback,\n): Promise<ApplyPatchResult> {\n\tconst hunks = parseNonEmptyPatch(patchText);\n\tconst summaries: string[] = [];\n\tconst appliedFiles: string[] = [];\n\tconst appliedOperations: AppliedPatchOperation[] = [];\n\tconst failures: ApplyPatchFailure[] = [];\n\tlet fuzz = 0;\n\n\tfor (const [operationIndex, hunk] of hunks.entries()) {\n\t\ttry {\n\t\t\tconst applied = await applySingleHunk(cwd, hunk);\n\t\t\tsummaries.push(applied.summary);\n\t\t\tappliedFiles.push(applied.appliedFile);\n\t\t\tappliedOperations.push({ operationIndex, preview: applied.preview });\n\t\t\tfuzz += applied.fuzz;\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tconst code = extractErrorCode(error);\n\t\t\tfailures.push({ operationIndex, filePath: hunk.filePath, operation: hunk.type, message, code });\n\t\t}\n\t\tawait notifyApplyPatchProgress(onProgress, {\n\t\t\tapplied: appliedFiles.length,\n\t\t\tfailed: failures.length,\n\t\t\ttotal: hunks.length,\n\t\t});\n\t}\n\n\tconst result: ApplyPatchResult = {\n\t\tsummaries,\n\t\tappliedFiles,\n\t\tfailures,\n\t\thasPartialSuccess: appliedFiles.length > 0 && failures.length > 0,\n\t\trecoveryInstructions: { mustReadFiles: [], mustNotReadFiles: [], failedFiles: [] },\n\t\tdetails: { fuzz, appliedOperations },\n\t};\n\tresult.recoveryInstructions = createRecoveryInstructions(result);\n\treturn result;\n}\n\nexport async function applyPatch(cwd: string, patchText: string): Promise<string[]> {\n\tconst hunks = parseNonEmptyPatch(patchText);\n\tconst summaries: string[] = [];\n\tconst appliedFiles: string[] = [];\n\tconst appliedOperations: AppliedPatchOperation[] = [];\n\tfor (const [operationIndex, hunk] of hunks.entries()) {\n\t\ttry {\n\t\t\tconst applied = await applySingleHunk(cwd, hunk);\n\t\t\tsummaries.push(applied.summary);\n\t\t\tappliedFiles.push(applied.appliedFile);\n\t\t\tappliedOperations.push({ operationIndex, preview: applied.preview });\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tconst failures: ApplyPatchFailure[] = [\n\t\t\t\t{ operationIndex, filePath: hunk.filePath, operation: hunk.type, message, code: extractErrorCode(error) },\n\t\t\t];\n\t\t\tconst result: ApplyPatchResult = {\n\t\t\t\tsummaries,\n\t\t\t\tappliedFiles,\n\t\t\t\tfailures,\n\t\t\t\thasPartialSuccess: appliedFiles.length > 0,\n\t\t\t\trecoveryInstructions: createRecoveryInstructions({ appliedFiles, failures }),\n\t\t\t\tdetails: { fuzz: 0, appliedOperations },\n\t\t\t};\n\t\t\tthrow new ApplyPatchError(message, compactApplyPatchResult(result));\n\t\t}\n\t}\n\n\treturn summaries;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EACX,sBAAsB,EAGtB,kBAAkB,EAClB,MAAM,YAAY,CAAC;AAepB,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,GAAG,SAAS,GAAG,kBAAkB,CAK9G;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,GAAG,SAAS,GAAG,OAAO,CAE9F;
|
|
1
|
+
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EACX,sBAAsB,EAGtB,kBAAkB,EAClB,MAAM,YAAY,CAAC;AAepB,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,GAAG,SAAS,GAAG,kBAAkB,CAK9G;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,GAAG,SAAS,GAAG,OAAO,CAE9F;AA0DD,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,sBAAsB,GAAG,IAAI,CAoB5E;eAEc,2BAA2B"}
|
|
@@ -37,6 +37,15 @@ function replaceEditToolsWithApplyPatch(toolNames) {
|
|
|
37
37
|
const at = insertIndex === -1 ? filteredToolNames.length : Math.min(insertIndex, filteredToolNames.length);
|
|
38
38
|
return [...filteredToolNames.slice(0, at), APPLY_PATCH_NAME, ...filteredToolNames.slice(at)];
|
|
39
39
|
}
|
|
40
|
+
function hasApplyPatchFailures(details) {
|
|
41
|
+
if (typeof details !== "object" || details === null)
|
|
42
|
+
return false;
|
|
43
|
+
const result = Reflect.get(details, "result");
|
|
44
|
+
if (typeof result !== "object" || result === null)
|
|
45
|
+
return false;
|
|
46
|
+
const failures = Reflect.get(result, "failures");
|
|
47
|
+
return Array.isArray(failures) && failures.length > 0;
|
|
48
|
+
}
|
|
40
49
|
function syncToolset(pi, model, state, variants) {
|
|
41
50
|
const mode = getApplyPatchWireMode(model);
|
|
42
51
|
const currentToolNames = pi.getActiveTools();
|
|
@@ -70,6 +79,12 @@ export function registerApplyPatchExtension(pi) {
|
|
|
70
79
|
};
|
|
71
80
|
state.activeVariant = "freeform";
|
|
72
81
|
pi.registerTool(variants.freeform);
|
|
82
|
+
pi.on("tool_result", async (event) => {
|
|
83
|
+
if (event.toolName !== APPLY_PATCH_NAME || event.isError || !hasApplyPatchFailures(event.details)) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
return { isError: true };
|
|
87
|
+
});
|
|
73
88
|
pi.on("session_start", async (_event, ctx) => {
|
|
74
89
|
syncToolset(pi, ctx.model, state, variants);
|
|
75
90
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/extension.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAQjD,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAM;IAC9C,kBAAkB;IAClB,wBAAwB;IACxB,wB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AQ,CAAC,QAAQ,CAAC,CAAC;IACnC,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;QAC5C,WAAW,CAAC,EAAE,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,EAAE,CAAC,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACrC,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,eAAe,2BAA2B,CAAC","sourcesContent":["import type { Api, Model } from \"@earendil-works/pi-ai\";\nimport { createApplyPatchTool } from \"./tool.ts\";\nimport type {\n\tApplyPatchExtensionAPI,\n\tApplyPatchToolsetState,\n\tApplyPatchToolVariant,\n\tApplyPatchWireMode,\n} from \"./types.ts\";\n\nconst APPLY_PATCH_FREEFORM_APIS = new Set<Api>([\n\t\"openai-responses\",\n\t\"azure-openai-responses\",\n\t\"openai-codex-responses\",\n]);\nconst APPLY_PATCH_JSON_APIS = new Set<Api>([\"openai-completions\"]);\nconst EDIT_TOOL_NAMES = new Set([\"write\", \"edit\"]);\nconst APPLY_PATCH_NAME = \"apply_patch\";\n\nfunction isGptId(model: Pick<Model<string>, \"api\" | \"id\"> | undefined): model is Pick<Model<string>, \"api\" | \"id\"> {\n\treturn model?.id.startsWith(\"gpt-\") ?? false;\n}\n\nexport function getApplyPatchWireMode(model: Pick<Model<string>, \"api\" | \"id\"> | undefined): ApplyPatchWireMode {\n\tif (!isGptId(model)) return \"none\";\n\tif (APPLY_PATCH_FREEFORM_APIS.has(model.api)) return \"freeform\";\n\tif (APPLY_PATCH_JSON_APIS.has(model.api)) return \"json\";\n\treturn \"none\";\n}\n\nexport function isOpenAIGptModel(model: Pick<Model<string>, \"api\" | \"id\"> | undefined): boolean {\n\treturn getApplyPatchWireMode(model) === \"freeform\";\n}\n\nfunction hasEditTools(toolNames: string[]): boolean {\n\treturn toolNames.some((toolName) => EDIT_TOOL_NAMES.has(toolName));\n}\n\nfunction withoutApplyPatch(toolNames: string[]): string[] {\n\treturn toolNames.filter((toolName) => toolName !== APPLY_PATCH_NAME);\n}\n\nfunction replaceEditToolsWithApplyPatch(toolNames: string[]): string[] {\n\tconst hadApplyPatch = toolNames.includes(APPLY_PATCH_NAME);\n\tconst insertIndex = toolNames.findIndex(\n\t\t(toolName) => EDIT_TOOL_NAMES.has(toolName) || toolName === APPLY_PATCH_NAME,\n\t);\n\tconst filteredToolNames = withoutApplyPatch(toolNames).filter((toolName) => !EDIT_TOOL_NAMES.has(toolName));\n\tif (!hasEditTools(toolNames) && !hadApplyPatch) return filteredToolNames;\n\tconst at = insertIndex === -1 ? filteredToolNames.length : Math.min(insertIndex, filteredToolNames.length);\n\treturn [...filteredToolNames.slice(0, at), APPLY_PATCH_NAME, ...filteredToolNames.slice(at)];\n}\n\nfunction syncToolset(\n\tpi: ApplyPatchExtensionAPI,\n\tmodel: Model<string> | undefined,\n\tstate: ApplyPatchToolsetState & { activeVariant?: ApplyPatchToolVariant },\n\tvariants: Readonly<Record<ApplyPatchToolVariant, ReturnType<typeof createApplyPatchTool>>>,\n): void {\n\tconst mode = getApplyPatchWireMode(model);\n\tconst currentToolNames = pi.getActiveTools();\n\tif (mode !== \"none\") {\n\t\tif (state.activeVariant !== mode) {\n\t\t\tpi.registerTool(variants[mode]);\n\t\t\tstate.activeVariant = mode;\n\t\t}\n\t\tconst activeEdit = currentToolNames.filter((toolName) => EDIT_TOOL_NAMES.has(toolName));\n\t\tif (activeEdit.length > 0) state.removedEditToolNames = activeEdit;\n\t\tpi.setActiveTools(replaceEditToolsWithApplyPatch(currentToolNames));\n\t\treturn;\n\t}\n\tif (state.removedEditToolNames.length === 0) {\n\t\tif (currentToolNames.includes(APPLY_PATCH_NAME)) pi.setActiveTools(withoutApplyPatch(currentToolNames));\n\t\treturn;\n\t}\n\tconst registeredNames = new Set(pi.getAllTools().map((tool) => tool.name));\n\tconst restorable = state.removedEditToolNames.filter((toolName) => registeredNames.has(toolName));\n\tconst restored = [...withoutApplyPatch(currentToolNames), ...restorable];\n\tstate.removedEditToolNames = [];\n\tpi.setActiveTools([...new Set(restored)]);\n}\n\nexport function registerApplyPatchExtension(pi: ApplyPatchExtensionAPI): void {\n\tconst state: ApplyPatchToolsetState & { activeVariant?: ApplyPatchToolVariant } = { removedEditToolNames: [] };\n\tconst variants = {\n\t\tfreeform: createApplyPatchTool(\"freeform\"),\n\t\tjson: createApplyPatchTool(\"json\"),\n\t} as const;\n\tstate.activeVariant = \"freeform\";\n\tpi.registerTool(variants.freeform);\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tsyncToolset(pi, ctx.model, state, variants);\n\t});\n\tpi.on(\"model_select\", async (event) => {\n\t\tsyncToolset(pi, event.model, state, variants);\n\t});\n}\n\nexport default registerApplyPatchExtension;\n"]}
|
|
1
|
+
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/extension.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAQjD,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAM;IAC9C,kBAAkB;IAClB,wBAAwB;IACxB,wBAAwB;CACxB,CAAC,CAAC;AACH,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;AACnE,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AACnD,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAEvC,SAAS,OAAO,CAAC,KAAoD;IACpE,OAAO,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,qB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CAAC,MAAM,CAAC;KACzB,CAAC;IACX,KAAK,CAAC,aAAa,GAAG,UAAU,CAAC;IACjC,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACnC,EAAE,CAAC,EAAE,CAAC,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACpC,IAAI,KAAK,CAAC,QAAQ,KAAK,gBAAgB,IAAI,KAAK,CAAC,OAAO,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YACnG,OAAO,SAAS,CAAC;QAClB,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC1B,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;QAC5C,WAAW,CAAC,EAAE,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,EAAE,CAAC,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACrC,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,eAAe,2BAA2B,CAAC","sourcesContent":["import type { Api, Model } from \"@earendil-works/pi-ai\";\nimport { createApplyPatchTool } from \"./tool.ts\";\nimport type {\n\tApplyPatchExtensionAPI,\n\tApplyPatchToolsetState,\n\tApplyPatchToolVariant,\n\tApplyPatchWireMode,\n} from \"./types.ts\";\n\nconst APPLY_PATCH_FREEFORM_APIS = new Set<Api>([\n\t\"openai-responses\",\n\t\"azure-openai-responses\",\n\t\"openai-codex-responses\",\n]);\nconst APPLY_PATCH_JSON_APIS = new Set<Api>([\"openai-completions\"]);\nconst EDIT_TOOL_NAMES = new Set([\"write\", \"edit\"]);\nconst APPLY_PATCH_NAME = \"apply_patch\";\n\nfunction isGptId(model: Pick<Model<string>, \"api\" | \"id\"> | undefined): model is Pick<Model<string>, \"api\" | \"id\"> {\n\treturn model?.id.startsWith(\"gpt-\") ?? false;\n}\n\nexport function getApplyPatchWireMode(model: Pick<Model<string>, \"api\" | \"id\"> | undefined): ApplyPatchWireMode {\n\tif (!isGptId(model)) return \"none\";\n\tif (APPLY_PATCH_FREEFORM_APIS.has(model.api)) return \"freeform\";\n\tif (APPLY_PATCH_JSON_APIS.has(model.api)) return \"json\";\n\treturn \"none\";\n}\n\nexport function isOpenAIGptModel(model: Pick<Model<string>, \"api\" | \"id\"> | undefined): boolean {\n\treturn getApplyPatchWireMode(model) === \"freeform\";\n}\n\nfunction hasEditTools(toolNames: string[]): boolean {\n\treturn toolNames.some((toolName) => EDIT_TOOL_NAMES.has(toolName));\n}\n\nfunction withoutApplyPatch(toolNames: string[]): string[] {\n\treturn toolNames.filter((toolName) => toolName !== APPLY_PATCH_NAME);\n}\n\nfunction replaceEditToolsWithApplyPatch(toolNames: string[]): string[] {\n\tconst hadApplyPatch = toolNames.includes(APPLY_PATCH_NAME);\n\tconst insertIndex = toolNames.findIndex(\n\t\t(toolName) => EDIT_TOOL_NAMES.has(toolName) || toolName === APPLY_PATCH_NAME,\n\t);\n\tconst filteredToolNames = withoutApplyPatch(toolNames).filter((toolName) => !EDIT_TOOL_NAMES.has(toolName));\n\tif (!hasEditTools(toolNames) && !hadApplyPatch) return filteredToolNames;\n\tconst at = insertIndex === -1 ? filteredToolNames.length : Math.min(insertIndex, filteredToolNames.length);\n\treturn [...filteredToolNames.slice(0, at), APPLY_PATCH_NAME, ...filteredToolNames.slice(at)];\n}\n\nfunction hasApplyPatchFailures(details: unknown): boolean {\n\tif (typeof details !== \"object\" || details === null) return false;\n\tconst result = Reflect.get(details, \"result\");\n\tif (typeof result !== \"object\" || result === null) return false;\n\tconst failures = Reflect.get(result, \"failures\");\n\treturn Array.isArray(failures) && failures.length > 0;\n}\n\nfunction syncToolset(\n\tpi: ApplyPatchExtensionAPI,\n\tmodel: Model<string> | undefined,\n\tstate: ApplyPatchToolsetState & { activeVariant?: ApplyPatchToolVariant },\n\tvariants: Readonly<Record<ApplyPatchToolVariant, ReturnType<typeof createApplyPatchTool>>>,\n): void {\n\tconst mode = getApplyPatchWireMode(model);\n\tconst currentToolNames = pi.getActiveTools();\n\tif (mode !== \"none\") {\n\t\tif (state.activeVariant !== mode) {\n\t\t\tpi.registerTool(variants[mode]);\n\t\t\tstate.activeVariant = mode;\n\t\t}\n\t\tconst activeEdit = currentToolNames.filter((toolName) => EDIT_TOOL_NAMES.has(toolName));\n\t\tif (activeEdit.length > 0) state.removedEditToolNames = activeEdit;\n\t\tpi.setActiveTools(replaceEditToolsWithApplyPatch(currentToolNames));\n\t\treturn;\n\t}\n\tif (state.removedEditToolNames.length === 0) {\n\t\tif (currentToolNames.includes(APPLY_PATCH_NAME)) pi.setActiveTools(withoutApplyPatch(currentToolNames));\n\t\treturn;\n\t}\n\tconst registeredNames = new Set(pi.getAllTools().map((tool) => tool.name));\n\tconst restorable = state.removedEditToolNames.filter((toolName) => registeredNames.has(toolName));\n\tconst restored = [...withoutApplyPatch(currentToolNames), ...restorable];\n\tstate.removedEditToolNames = [];\n\tpi.setActiveTools([...new Set(restored)]);\n}\n\nexport function registerApplyPatchExtension(pi: ApplyPatchExtensionAPI): void {\n\tconst state: ApplyPatchToolsetState & { activeVariant?: ApplyPatchToolVariant } = { removedEditToolNames: [] };\n\tconst variants = {\n\t\tfreeform: createApplyPatchTool(\"freeform\"),\n\t\tjson: createApplyPatchTool(\"json\"),\n\t} as const;\n\tstate.activeVariant = \"freeform\";\n\tpi.registerTool(variants.freeform);\n\tpi.on(\"tool_result\", async (event) => {\n\t\tif (event.toolName !== APPLY_PATCH_NAME || event.isError || !hasApplyPatchFailures(event.details)) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn { isError: true };\n\t});\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tsyncToolset(pi, ctx.model, state, variants);\n\t});\n\tpi.on(\"model_select\", async (event) => {\n\t\tsyncToolset(pi, event.model, state, variants);\n\t});\n}\n\nexport default registerApplyPatchExtension;\n"]}
|
|
@@ -7,6 +7,6 @@ export { clearApplyPatchRenderState, displayPath, formatInFlightCallText, format
|
|
|
7
7
|
export { seekSequence } from "./seek-sequence.ts";
|
|
8
8
|
export { StreamingPatchParser } from "./streaming-parser.ts";
|
|
9
9
|
export { extractPatchedPaths, normalizePatchText, stripHeredoc } from "./text.ts";
|
|
10
|
-
export { createApplyPatchTool } from "./tool.ts";
|
|
10
|
+
export { APPLY_PATCH_RESULT_PATCH_MAX_BYTES, createApplyPatchTool } from "./tool.ts";
|
|
11
11
|
export type { ApplyPatchExtensionAPI, ApplyPatchFailure, ApplyPatchParams, ApplyPatchPreview, ApplyPatchProgress, ApplyPatchProgressCallback, ApplyPatchRecoveryInstructions, ApplyPatchRenderState, ApplyPatchResult, ApplyPatchToolDefinition, ApplyPatchToolDetails, AtomicWriteOperations, FreeformToolFormat, ParsedPatch, PatchChunk, } from "./types.ts";
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAO,EACN,gCAAgC,EAChC,4BAA4B,EAC5B,wBAAwB,EACxB,kBAAkB,EAClB,6BAA6B,GAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC/G,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,0BAA0B,EAC1B,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAO,EACN,gCAAgC,EAChC,4BAA4B,EAC5B,wBAAwB,EACxB,kBAAkB,EAClB,6BAA6B,GAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC/G,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,0BAA0B,EAC1B,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,kCAAkC,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACrF,YAAY,EACX,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,0BAA0B,EAC1B,8BAA8B,EAC9B,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,UAAU,GACV,MAAM,YAAY,CAAC"}
|
|
@@ -7,5 +7,5 @@ export { clearApplyPatchRenderState, displayPath, formatInFlightCallText, format
|
|
|
7
7
|
export { seekSequence } from "./seek-sequence.js";
|
|
8
8
|
export { StreamingPatchParser } from "./streaming-parser.js";
|
|
9
9
|
export { extractPatchedPaths, normalizePatchText, stripHeredoc } from "./text.js";
|
|
10
|
-
export { createApplyPatchTool } from "./tool.js";
|
|
10
|
+
export { APPLY_PATCH_RESULT_PATCH_MAX_BYTES, createApplyPatchTool } from "./tool.js";
|
|
11
11
|
//# sourceMappingURL=index.js.map
|