@code-yeongyu/senpi 2026.9.7 → 2026.9.9-2
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 +122 -3
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +2 -0
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +48 -4
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +192 -40
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/compaction-execution.d.ts.map +1 -1
- package/dist/core/compaction/compaction-execution.js +5 -5
- package/dist/core/compaction/compaction-execution.js.map +1 -1
- package/dist/core/compaction/compaction-settings.d.ts +2 -0
- package/dist/core/compaction/compaction-settings.d.ts.map +1 -1
- package/dist/core/compaction/compaction-settings.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +3 -3
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +14 -8
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/stream-watchdog.d.ts +29 -0
- package/dist/core/compaction/stream-watchdog.d.ts.map +1 -1
- package/dist/core/compaction/stream-watchdog.js +35 -0
- package/dist/core/compaction/stream-watchdog.js.map +1 -1
- package/dist/core/compaction-settings-access.d.ts +6 -0
- package/dist/core/compaction-settings-access.d.ts.map +1 -1
- package/dist/core/compaction-settings-access.js.map +1 -1
- package/dist/core/compaction-settings-resolver.d.ts +2 -0
- package/dist/core/compaction-settings-resolver.d.ts.map +1 -1
- package/dist/core/compaction-settings-resolver.js +5 -0
- package/dist/core/compaction-settings-resolver.js.map +1 -1
- package/dist/core/dynamic-prompt/working-task.js +1 -1
- package/dist/core/dynamic-prompt/working-task.js.map +1 -1
- package/dist/core/extensions/builtin/cache-keepalive/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/cache-keepalive/index.js +4 -21
- package/dist/core/extensions/builtin/cache-keepalive/index.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/account-command.d.ts +2 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/account-command.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/account-command.js +10 -25
- package/dist/core/extensions/builtin/claude-sdk-oauth/account-command.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.js +36 -19
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.js +21 -10
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.d.ts +4 -17
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.js +23 -33
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js +5 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js +5 -3
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-attempt.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-attempt.js +8 -3
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-attempt.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/tools.d.ts +6 -5
- package/dist/core/extensions/builtin/claude-sdk-oauth/tools.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/tools.js +6 -5
- package/dist/core/extensions/builtin/claude-sdk-oauth/tools.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/circuit-breaker.d.ts +8 -0
- package/dist/core/extensions/builtin/compaction/circuit-breaker.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/circuit-breaker.js +8 -0
- package/dist/core/extensions/builtin/compaction/circuit-breaker.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts +8 -0
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.js +125 -20
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/fallback-failed-turn-normalization.d.ts +18 -0
- package/dist/core/extensions/builtin/compaction/fallback-failed-turn-normalization.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/fallback-failed-turn-normalization.js +20 -0
- package/dist/core/extensions/builtin/compaction/fallback-failed-turn-normalization.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.js +54 -11
- package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/lane-policy.d.ts +3 -0
- package/dist/core/extensions/builtin/compaction/lane-policy.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/lane-policy.js +47 -23
- package/dist/core/extensions/builtin/compaction/lane-policy.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/model-usability-budget.d.ts +1 -1
- package/dist/core/extensions/builtin/compaction/model-usability-budget.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/model-usability-budget.js +23 -3
- package/dist/core/extensions/builtin/compaction/model-usability-budget.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/resume-admission.d.ts +7 -0
- package/dist/core/extensions/builtin/compaction/resume-admission.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/resume-admission.js +7 -0
- package/dist/core/extensions/builtin/compaction/resume-admission.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/speculative-summary.d.ts +2 -0
- package/dist/core/extensions/builtin/compaction/speculative-summary.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/speculative-summary.js +5 -2
- package/dist/core/extensions/builtin/compaction/speculative-summary.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/speculative.js +9 -3
- package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/summarization-retry.d.ts +10 -4
- package/dist/core/extensions/builtin/compaction/summarization-retry.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/summarization-retry.js +14 -5
- package/dist/core/extensions/builtin/compaction/summarization-retry.js.map +1 -1
- package/dist/core/extensions/builtin/goal/agent-end-continuation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/agent-end-continuation.js +11 -0
- package/dist/core/extensions/builtin/goal/agent-end-continuation.js.map +1 -1
- package/dist/core/extensions/builtin/goal/cache-warm-renderer.js +6 -4
- package/dist/core/extensions/builtin/goal/cache-warm-renderer.js.map +1 -1
- package/dist/core/extensions/builtin/goal/cache-warm.d.ts +25 -1
- package/dist/core/extensions/builtin/goal/cache-warm.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/cache-warm.js +29 -10
- package/dist/core/extensions/builtin/goal/cache-warm.js.map +1 -1
- package/dist/core/extensions/builtin/goal/continuation.d.ts +3 -1
- package/dist/core/extensions/builtin/goal/continuation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/continuation.js +17 -2
- package/dist/core/extensions/builtin/goal/continuation.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 +1 -0
- package/dist/core/extensions/builtin/goal/lifecycle-helpers.js.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.js +8 -3
- package/dist/core/extensions/builtin/goal/monitor-continuation.js.map +1 -1
- package/dist/core/extensions/builtin/gpt-account.d.ts +5 -1
- package/dist/core/extensions/builtin/gpt-account.d.ts.map +1 -1
- package/dist/core/extensions/builtin/gpt-account.js +9 -26
- package/dist/core/extensions/builtin/gpt-account.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/plugin-manifest.js +2 -2
- package/dist/core/extensions/builtin/hooks/plugin-manifest.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/safety.js +2 -2
- package/dist/core/extensions/builtin/hooks/safety.js.map +1 -1
- package/dist/core/extensions/builtin/imagegen/params.d.ts +36 -0
- package/dist/core/extensions/builtin/imagegen/params.d.ts.map +1 -0
- package/dist/core/extensions/builtin/imagegen/params.js +55 -0
- package/dist/core/extensions/builtin/imagegen/params.js.map +1 -0
- package/dist/core/extensions/builtin/imagegen/reference-images.d.ts +11 -0
- package/dist/core/extensions/builtin/imagegen/reference-images.d.ts.map +1 -0
- package/dist/core/extensions/builtin/imagegen/reference-images.js +55 -0
- package/dist/core/extensions/builtin/imagegen/reference-images.js.map +1 -0
- package/dist/core/extensions/builtin/imagegen/skill/SKILL.md +47 -4
- package/dist/core/extensions/builtin/imagegen/tool.d.ts +10 -19
- package/dist/core/extensions/builtin/imagegen/tool.d.ts.map +1 -1
- package/dist/core/extensions/builtin/imagegen/tool.js +21 -45
- package/dist/core/extensions/builtin/imagegen/tool.js.map +1 -1
- package/dist/core/extensions/builtin/monitor-state-event.d.ts +18 -0
- package/dist/core/extensions/builtin/monitor-state-event.d.ts.map +1 -1
- package/dist/core/extensions/builtin/monitor-state-event.js +23 -0
- package/dist/core/extensions/builtin/monitor-state-event.js.map +1 -1
- package/dist/core/extensions/builtin/oauth-login-interaction.d.ts +24 -0
- package/dist/core/extensions/builtin/oauth-login-interaction.d.ts.map +1 -0
- package/dist/core/extensions/builtin/oauth-login-interaction.js +77 -0
- package/dist/core/extensions/builtin/oauth-login-interaction.js.map +1 -0
- package/dist/core/extensions/builtin/permission-system/external-dir.d.ts.map +1 -1
- package/dist/core/extensions/builtin/permission-system/external-dir.js +5 -51
- package/dist/core/extensions/builtin/permission-system/external-dir.js.map +1 -1
- package/dist/core/extensions/builtin/permission-system/parsers.d.ts.map +1 -1
- package/dist/core/extensions/builtin/permission-system/parsers.js +5 -7
- package/dist/core/extensions/builtin/permission-system/parsers.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5-1.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5-1.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/execution-tooling.d.ts +14 -7
- package/dist/core/extensions/builtin/prompt-preset/execution-tooling.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/execution-tooling.js +34 -13
- package/dist/core/extensions/builtin/prompt-preset/execution-tooling.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts +6 -10
- 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 +14 -9
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.d.ts +15 -15
- package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.js +49 -21
- package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
- package/dist/core/extensions/builtin/service-tier.d.ts +2 -0
- package/dist/core/extensions/builtin/service-tier.d.ts.map +1 -1
- package/dist/core/extensions/builtin/service-tier.js +17 -1
- package/dist/core/extensions/builtin/service-tier.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/durable-command.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/durable-command.js +3 -0
- package/dist/core/extensions/builtin/terminal/durable-command.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/durable-file.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/durable-file.js +2 -0
- package/dist/core/extensions/builtin/terminal/durable-file.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/extension.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/extension.js +14 -2
- 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 +27 -5
- package/dist/core/extensions/builtin/terminal/monitor-notify.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts +17 -0
- package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-registry.js +76 -14
- package/dist/core/extensions/builtin/terminal/monitor-registry.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/notify.d.ts +2 -0
- package/dist/core/extensions/builtin/terminal/notify.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/notify.js +6 -1
- package/dist/core/extensions/builtin/terminal/notify.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/session-bundle.d.ts +3 -1
- package/dist/core/extensions/builtin/terminal/session-bundle.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/session-bundle.js +13 -0
- package/dist/core/extensions/builtin/terminal/session-bundle.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/shared.d.ts +13 -2
- package/dist/core/extensions/builtin/terminal/shared.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/shared.js +15 -2
- package/dist/core/extensions/builtin/terminal/shared.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 +8 -1
- package/dist/core/extensions/builtin/terminal/tools/monitor.js.map +1 -1
- package/dist/core/extensions/builtin/tool-search/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/tool-search/index.js +1 -0
- package/dist/core/extensions/builtin/tool-search/index.js.map +1 -1
- package/dist/core/extensions/builtin/tool-search/service.d.ts +4 -0
- package/dist/core/extensions/builtin/tool-search/service.d.ts.map +1 -1
- package/dist/core/extensions/builtin/tool-search/service.js +11 -0
- package/dist/core/extensions/builtin/tool-search/service.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +2 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +17 -8
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +8 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +14 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/high-reasoning-warning.d.ts.map +1 -1
- package/dist/core/high-reasoning-warning.js +4 -6
- package/dist/core/high-reasoning-warning.js.map +1 -1
- package/dist/core/resource-loader.d.ts +2 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +11 -7
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +38 -7
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +11 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-write-reservation.d.ts +4 -0
- package/dist/core/session-write-reservation.d.ts.map +1 -0
- package/dist/core/session-write-reservation.js +12 -0
- package/dist/core/session-write-reservation.js.map +1 -0
- package/dist/core/settings-manager.js +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-shapes.js.map +1 -1
- package/dist/core/tools/bounded-realpath.d.ts +28 -0
- package/dist/core/tools/bounded-realpath.d.ts.map +1 -0
- package/dist/core/tools/bounded-realpath.js +53 -0
- package/dist/core/tools/bounded-realpath.js.map +1 -0
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-queue.js +15 -13
- package/dist/core/tools/file-mutation-queue.js.map +1 -1
- package/dist/core/tools/filesystem-policy.d.ts +7 -0
- package/dist/core/tools/filesystem-policy.d.ts.map +1 -1
- package/dist/core/tools/filesystem-policy.js +25 -15
- package/dist/core/tools/filesystem-policy.js.map +1 -1
- package/dist/core/tools/read-classifiers.d.ts +17 -0
- package/dist/core/tools/read-classifiers.d.ts.map +1 -0
- package/dist/core/tools/read-classifiers.js +26 -0
- package/dist/core/tools/read-classifiers.js.map +1 -0
- package/dist/core/tools/read.d.ts +5 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +21 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +13 -2
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +14 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +166 -147
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +4 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/tips/catalog/memory-tips.d.ts.map +1 -1
- package/dist/modes/interactive/tips/catalog/memory-tips.js +6 -0
- package/dist/modes/interactive/tips/catalog/memory-tips.js.map +1 -1
- package/dist/modes/interactive/tips/catalog/subagent-tips.d.ts.map +1 -1
- package/dist/modes/interactive/tips/catalog/subagent-tips.js +6 -0
- package/dist/modes/interactive/tips/catalog/subagent-tips.js.map +1 -1
- package/dist/modes/rpc/connection-handler.d.ts +2 -0
- package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
- package/dist/modes/rpc/connection-handler.js +1 -1
- package/dist/modes/rpc/connection-handler.js.map +1 -1
- package/dist/modes/rpc/host-lifecycle.d.ts.map +1 -1
- package/dist/modes/rpc/host-lifecycle.js +31 -5
- package/dist/modes/rpc/host-lifecycle.js.map +1 -1
- package/dist/modes/rpc/host-watchdog.d.ts +11 -0
- package/dist/modes/rpc/host-watchdog.d.ts.map +1 -1
- package/dist/modes/rpc/host-watchdog.js +16 -2
- package/dist/modes/rpc/host-watchdog.js.map +1 -1
- package/dist/modes/rpc/multi-session-host.d.ts +2 -0
- package/dist/modes/rpc/multi-session-host.d.ts.map +1 -1
- package/dist/modes/rpc/multi-session-host.js +72 -24
- package/dist/modes/rpc/multi-session-host.js.map +1 -1
- package/dist/modes/rpc/session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/session-binding.js +3 -0
- package/dist/modes/rpc/session-binding.js.map +1 -1
- package/dist/modes/rpc/session-command-router.d.ts +1 -1
- package/dist/modes/rpc/session-command-router.d.ts.map +1 -1
- package/dist/modes/rpc/session-command-router.js +57 -25
- package/dist/modes/rpc/session-command-router.js.map +1 -1
- package/dist/modes/rpc/session-event-writer.d.ts +23 -1
- package/dist/modes/rpc/session-event-writer.d.ts.map +1 -1
- package/dist/modes/rpc/session-event-writer.js +108 -1
- package/dist/modes/rpc/session-event-writer.js.map +1 -1
- package/dist/modes/rpc/session-registry.d.ts +4 -2
- package/dist/modes/rpc/session-registry.d.ts.map +1 -1
- package/dist/modes/rpc/session-registry.js +1 -1
- package/dist/modes/rpc/session-registry.js.map +1 -1
- package/dist/modes/rpc/session-worker-client.d.ts +47 -0
- package/dist/modes/rpc/session-worker-client.d.ts.map +1 -0
- package/dist/modes/rpc/session-worker-client.js +226 -0
- package/dist/modes/rpc/session-worker-client.js.map +1 -0
- package/dist/modes/rpc/session-worker-protocol.d.ts +103 -0
- package/dist/modes/rpc/session-worker-protocol.d.ts.map +1 -0
- package/dist/modes/rpc/session-worker-protocol.js +12 -0
- package/dist/modes/rpc/session-worker-protocol.js.map +1 -0
- package/dist/modes/rpc/session-worker-requests.d.ts +24 -0
- package/dist/modes/rpc/session-worker-requests.d.ts.map +1 -0
- package/dist/modes/rpc/session-worker-requests.js +71 -0
- package/dist/modes/rpc/session-worker-requests.js.map +1 -0
- package/dist/modes/rpc/session-worker.d.ts +2 -0
- package/dist/modes/rpc/session-worker.d.ts.map +1 -0
- package/dist/modes/rpc/session-worker.js +229 -0
- package/dist/modes/rpc/session-worker.js.map +1 -0
- package/dist/modes/rpc/socket-ownership.d.ts +46 -0
- package/dist/modes/rpc/socket-ownership.d.ts.map +1 -0
- package/dist/modes/rpc/socket-ownership.js +178 -0
- package/dist/modes/rpc/socket-ownership.js.map +1 -0
- package/dist/modes/rpc/worker-session-registry.d.ts +37 -0
- package/dist/modes/rpc/worker-session-registry.d.ts.map +1 -0
- package/dist/modes/rpc/worker-session-registry.js +207 -0
- package/dist/modes/rpc/worker-session-registry.js.map +1 -0
- package/dist/utils/fs-watch.d.ts +17 -0
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/fs-watch.js +38 -10
- package/dist/utils/fs-watch.js.map +1 -1
- package/dist/utils/paths.d.ts +33 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +109 -3
- package/dist/utils/paths.js.map +1 -1
- package/docs/development.md +3 -2
- package/docs/providers.md +5 -1
- package/docs/rpc.md +70 -9
- package/docs/settings.md +2 -0
- package/docs/skills.md +1 -1
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +55 -0
- package/node_modules/@code-yeongyu/senpi-codemode/README.md +14 -1
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
- package/node_modules/@code-yeongyu/senpi-codemode/src/bridge/protocol.ts +1 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/extension/runtime-factory.ts +3 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/extension/session-manager.ts +7 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/AGENTS.md +7 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/jl/kernel.ts +4 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/kernel-contract.ts +3 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-core.js +29 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-indirect-eval.js +10 -6
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-shell-capture.d.ts +16 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-shell-capture.js +44 -8
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-startup.ts +1 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/kernel-contract.ts +3 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/transport.ts +9 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/rb/kernel.ts +4 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/session-env.ts +56 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-contract.ts +3 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-kernel.ts +9 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/output/output-meta.ts +26 -2
- package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +17 -24
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/image.ts +12 -3
- 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 +2 -2
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.d.ts +7 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.js +19 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/empty-assistant-recovery.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/empty-assistant-recovery.js +24 -16
- package/node_modules/@earendil-works/pi-agent-core/dist/empty-assistant-recovery.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts +1 -1
- 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 +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- 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 +70 -183
- 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-references.d.ts +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-references.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-references.js +260 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-references.js.map +1 -0
- 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 +1 -0
- 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-images-edit.d.ts +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-edit.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-edit.js +11 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-edit.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-params.d.ts +25 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-params.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-params.js +58 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-params.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.d.ts +3 -6
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.js +15 -33
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.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 +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic-callback-listener.d.ts +40 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic-callback-listener.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic-callback-listener.js +138 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic-callback-listener.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.d.ts +2 -3
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.js +42 -139
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/authorization-input.d.ts +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/authorization-input.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/authorization-input.js +29 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/authorization-input.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/error-details.d.ts +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/error-details.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/error-details.js +20 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/error-details.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +61 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +61 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/images.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/images.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/images.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/images.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/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/nvidia.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opengateway.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/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/recovery-stream-terminal.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/recovery-stream-terminal.js +16 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/recovery-stream-terminal.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +7 -0
- 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/overflow.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +14 -3
- package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/server-fallback-receipt.d.ts +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/server-fallback-receipt.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/server-fallback-receipt.js +16 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/server-fallback-receipt.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relay a provider OAuth login (`modelRuntime.login`) onto the extension UI of
|
|
3
|
+
* a slash command such as `/gpt-account add`, mirroring what the `/login`
|
|
4
|
+
* dialog and `modes/rpc/login-prompts.ts` do for their surfaces.
|
|
5
|
+
*
|
|
6
|
+
* Two decisions are not visible from the code alone: every dialog is bound to
|
|
7
|
+
* the per-prompt `AuthPrompt.signal` as well as the command signal, so a
|
|
8
|
+
* manual-code dialog is released when the provider's local callback server
|
|
9
|
+
* wins the race (`loginOpenAICodex`); and `auth_url` opens the browser only in
|
|
10
|
+
* the TUI, because an RPC client renders the notice on its own machine.
|
|
11
|
+
*/
|
|
12
|
+
import { openBrowser as openPlatformBrowser } from "../../../utils/open-browser.js";
|
|
13
|
+
export const LOGIN_CANCELLED_MESSAGE = "Login cancelled";
|
|
14
|
+
export function createExtensionLoginInteraction(ctx, options) {
|
|
15
|
+
const openBrowser = options.openBrowser ?? openPlatformBrowser;
|
|
16
|
+
return {
|
|
17
|
+
signal: ctx.signal,
|
|
18
|
+
prompt: (prompt) => relayPrompt(ctx, prompt),
|
|
19
|
+
notify: (event) => relayEvent(ctx, event, options.providerLabel, openBrowser),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function dialogSignal(commandSignal, promptSignal) {
|
|
23
|
+
if (commandSignal && promptSignal)
|
|
24
|
+
return AbortSignal.any([commandSignal, promptSignal]);
|
|
25
|
+
return commandSignal ?? promptSignal;
|
|
26
|
+
}
|
|
27
|
+
async function relayPrompt(ctx, prompt) {
|
|
28
|
+
const signal = dialogSignal(ctx.signal, prompt.signal);
|
|
29
|
+
if (signal?.aborted)
|
|
30
|
+
throw new Error(LOGIN_CANCELLED_MESSAGE);
|
|
31
|
+
const dialogOptions = signal ? { signal } : undefined;
|
|
32
|
+
const answer = await answerPrompt(ctx, prompt, dialogOptions);
|
|
33
|
+
if (answer === undefined || signal?.aborted)
|
|
34
|
+
throw new Error(LOGIN_CANCELLED_MESSAGE);
|
|
35
|
+
return answer;
|
|
36
|
+
}
|
|
37
|
+
async function answerPrompt(ctx, prompt, dialogOptions) {
|
|
38
|
+
switch (prompt.type) {
|
|
39
|
+
case "select": {
|
|
40
|
+
const label = await ctx.ui.select(prompt.message, prompt.options.map((option) => option.label), dialogOptions);
|
|
41
|
+
return prompt.options.find((option) => option.label === label)?.id;
|
|
42
|
+
}
|
|
43
|
+
case "text":
|
|
44
|
+
case "secret":
|
|
45
|
+
case "manual_code":
|
|
46
|
+
return ctx.ui.input(prompt.message, prompt.placeholder, dialogOptions);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function relayEvent(ctx, event, providerLabel, openBrowser) {
|
|
50
|
+
switch (event.type) {
|
|
51
|
+
case "auth_url": {
|
|
52
|
+
if (ctx.mode === "tui")
|
|
53
|
+
openBrowser(event.url);
|
|
54
|
+
const lines = [`Open this URL to authorize ${providerLabel}:`, event.url];
|
|
55
|
+
if (event.instructions)
|
|
56
|
+
lines.push(event.instructions);
|
|
57
|
+
ctx.ui.notify(lines.join("\n"), "info");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
case "device_code":
|
|
61
|
+
ctx.ui.notify([
|
|
62
|
+
`Open this URL to authorize ${providerLabel}:`,
|
|
63
|
+
event.verificationUri,
|
|
64
|
+
`Enter code: ${event.userCode}`,
|
|
65
|
+
].join("\n"), "info");
|
|
66
|
+
return;
|
|
67
|
+
case "info": {
|
|
68
|
+
const links = (event.links ?? []).map((link) => (link.label ? `${link.label}: ${link.url}` : link.url));
|
|
69
|
+
ctx.ui.notify([event.message, ...links].join("\n"), "info");
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
case "progress":
|
|
73
|
+
ctx.ui.notify(event.message, "info");
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=oauth-login-interaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-login-interaction.js","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/oauth-login-interaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;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MAAM,CAAC,CAAC;YACxC,OAAO;QACR,CAAC;QACD,KAAK,aAAa;YACjB,GAAG,CAAC,EAAE,CAAC,MAAM,CACZ;gBACC,8BAA8B,aAAa,GAAG;gBAC9C,KAAK,CAAC,eAAe;gBACrB,eAAe,KAAK,CAAC,QAAQ,EAAE;aAC/B,CAAC,IAAI,CAAC,IAAI,CAAC,EACZ,MAAM,CACN,CAAC;YACF,OAAO;QACR,KAAK,MAAM,CAAC,CAAC,CAAC;YACb,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YACxG,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;YAC5D,OAAO;QACR,CAAC;QACD,KAAK,UAAU;YACd,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACrC,OAAO;IACT,CAAC;AACF,CAAC","sourcesContent":["/**\n * Relay a provider OAuth login (`modelRuntime.login`) onto the extension UI of\n * a slash command such as `/gpt-account add`, mirroring what the `/login`\n * dialog and `modes/rpc/login-prompts.ts` do for their surfaces.\n *\n * Two decisions are not visible from the code alone: every dialog is bound to\n * the per-prompt `AuthPrompt.signal` as well as the command signal, so a\n * manual-code dialog is released when the provider's local callback server\n * wins the race (`loginOpenAICodex`); and `auth_url` opens the browser only in\n * the TUI, because an RPC client renders the notice on its own machine.\n */\n\nimport type { AuthEvent, AuthInteraction, AuthPrompt } from \"@earendil-works/pi-ai\";\nimport { openBrowser as openPlatformBrowser } from \"../../../utils/open-browser.ts\";\nimport type { ExtensionCommandContext } from \"../types.ts\";\n\nexport const LOGIN_CANCELLED_MESSAGE = \"Login cancelled\";\n\nexport interface ExtensionLoginInteractionOptions {\n\t/** Provider name rendered in notices, e.g. \"OpenAI Codex OAuth\". */\n\treadonly providerLabel: string;\n\t/** Browser launcher for `auth_url` events in the TUI; tests inject a recorder. */\n\treadonly openBrowser?: ((url: string) => void) | undefined;\n}\n\ntype LoginCommandContext = Pick<ExtensionCommandContext, \"mode\" | \"signal\" | \"ui\">;\n\nexport function createExtensionLoginInteraction(\n\tctx: LoginCommandContext,\n\toptions: ExtensionLoginInteractionOptions,\n): AuthInteraction {\n\tconst openBrowser = options.openBrowser ?? openPlatformBrowser;\n\treturn {\n\t\tsignal: ctx.signal,\n\t\tprompt: (prompt) => relayPrompt(ctx, prompt),\n\t\tnotify: (event) => relayEvent(ctx, event, options.providerLabel, openBrowser),\n\t};\n}\n\nfunction dialogSignal(\n\tcommandSignal: AbortSignal | undefined,\n\tpromptSignal: AbortSignal | undefined,\n): AbortSignal | undefined {\n\tif (commandSignal && promptSignal) return AbortSignal.any([commandSignal, promptSignal]);\n\treturn commandSignal ?? promptSignal;\n}\n\nasync function relayPrompt(ctx: LoginCommandContext, prompt: AuthPrompt): Promise<string> {\n\tconst signal = dialogSignal(ctx.signal, prompt.signal);\n\tif (signal?.aborted) throw new Error(LOGIN_CANCELLED_MESSAGE);\n\tconst dialogOptions = signal ? { signal } : undefined;\n\tconst answer = await answerPrompt(ctx, prompt, dialogOptions);\n\tif (answer === undefined || signal?.aborted) throw new Error(LOGIN_CANCELLED_MESSAGE);\n\treturn answer;\n}\n\nasync function answerPrompt(\n\tctx: LoginCommandContext,\n\tprompt: AuthPrompt,\n\tdialogOptions: { signal: AbortSignal } | undefined,\n): Promise<string | undefined> {\n\tswitch (prompt.type) {\n\t\tcase \"select\": {\n\t\t\tconst label = await ctx.ui.select(\n\t\t\t\tprompt.message,\n\t\t\t\tprompt.options.map((option) => option.label),\n\t\t\t\tdialogOptions,\n\t\t\t);\n\t\t\treturn prompt.options.find((option) => option.label === label)?.id;\n\t\t}\n\t\tcase \"text\":\n\t\tcase \"secret\":\n\t\tcase \"manual_code\":\n\t\t\treturn ctx.ui.input(prompt.message, prompt.placeholder, dialogOptions);\n\t}\n}\n\nfunction relayEvent(\n\tctx: LoginCommandContext,\n\tevent: AuthEvent,\n\tproviderLabel: string,\n\topenBrowser: (url: string) => void,\n): void {\n\tswitch (event.type) {\n\t\tcase \"auth_url\": {\n\t\t\tif (ctx.mode === \"tui\") openBrowser(event.url);\n\t\t\tconst lines = [`Open this URL to authorize ${providerLabel}:`, event.url];\n\t\t\tif (event.instructions) lines.push(event.instructions);\n\t\t\tctx.ui.notify(lines.join(\"\\n\"), \"info\");\n\t\t\treturn;\n\t\t}\n\t\tcase \"device_code\":\n\t\t\tctx.ui.notify(\n\t\t\t\t[\n\t\t\t\t\t`Open this URL to authorize ${providerLabel}:`,\n\t\t\t\t\tevent.verificationUri,\n\t\t\t\t\t`Enter code: ${event.userCode}`,\n\t\t\t\t].join(\"\\n\"),\n\t\t\t\t\"info\",\n\t\t\t);\n\t\t\treturn;\n\t\tcase \"info\": {\n\t\t\tconst links = (event.links ?? []).map((link) => (link.label ? `${link.label}: ${link.url}` : link.url));\n\t\t\tctx.ui.notify([event.message, ...links].join(\"\\n\"), \"info\");\n\t\t\treturn;\n\t\t}\n\t\tcase \"progress\":\n\t\t\tctx.ui.notify(event.message, \"info\");\n\t\t\treturn;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-dir.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/permission-system/external-dir.ts"],"names":[],"mappings":"AAIA,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAcpD;
|
|
1
|
+
{"version":3,"file":"external-dir.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/permission-system/external-dir.ts"],"names":[],"mappings":"AAIA,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAcpD;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAetE;AAgFD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAgC3E"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
1
|
import * as os from "node:os";
|
|
3
2
|
import * as path from "node:path";
|
|
3
|
+
import { realpathWithoutOpen } from "../../../../utils/paths.js";
|
|
4
4
|
export function expandHome(inputPath) {
|
|
5
5
|
if (inputPath === "~") {
|
|
6
6
|
return os.homedir();
|
|
@@ -16,59 +16,13 @@ export function expandHome(inputPath) {
|
|
|
16
16
|
}
|
|
17
17
|
return inputPath;
|
|
18
18
|
}
|
|
19
|
-
/** Symlink hops allowed while resolving one path; realpath(3) reports ELOOP past this. */
|
|
20
|
-
const MAX_SYMLINK_HOPS = 40;
|
|
21
|
-
function splitComponents(normalizedPath) {
|
|
22
|
-
const { root } = path.parse(normalizedPath);
|
|
23
|
-
const parts = normalizedPath
|
|
24
|
-
.slice(root.length)
|
|
25
|
-
.split(path.sep)
|
|
26
|
-
.filter((part) => part.length > 0);
|
|
27
|
-
return { root, parts };
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Resolve symlinks the way realpath(3) does — one lstat/readlink per component — without ever
|
|
31
|
-
* open(2)-ing a component. Bun's `fs.realpath*` opens every directory it resolves, so an autofs
|
|
32
|
-
* trigger such as macOS `/home` blocks the whole process (the classifier runs on the host main
|
|
33
|
-
* thread, freezing the TUI) and an execute-only directory fails with EACCES; lstat needs only
|
|
34
|
-
* search permission and never mounts anything. Components from the first missing one onward are
|
|
35
|
-
* kept verbatim, so a file that does not exist yet still lands where its symlinked parent points.
|
|
36
|
-
*/
|
|
37
|
-
function normalizePath(inputPath) {
|
|
38
|
-
const { root, parts } = splitComponents(path.normalize(inputPath));
|
|
39
|
-
const pending = [...parts];
|
|
40
|
-
let resolved = root;
|
|
41
|
-
let hops = 0;
|
|
42
|
-
while (pending.length > 0) {
|
|
43
|
-
const part = pending.shift();
|
|
44
|
-
if (part === undefined)
|
|
45
|
-
break;
|
|
46
|
-
const candidate = path.join(resolved, part);
|
|
47
|
-
let link;
|
|
48
|
-
try {
|
|
49
|
-
if (!fs.lstatSync(candidate).isSymbolicLink()) {
|
|
50
|
-
resolved = candidate;
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
hops += 1;
|
|
54
|
-
if (hops > MAX_SYMLINK_HOPS)
|
|
55
|
-
return path.join(candidate, ...pending);
|
|
56
|
-
link = fs.readlinkSync(candidate);
|
|
57
|
-
}
|
|
58
|
-
catch {
|
|
59
|
-
return path.join(candidate, ...pending);
|
|
60
|
-
}
|
|
61
|
-
const target = splitComponents(path.resolve(resolved, link));
|
|
62
|
-
resolved = target.root;
|
|
63
|
-
pending.unshift(...target.parts);
|
|
64
|
-
}
|
|
65
|
-
return resolved;
|
|
66
|
-
}
|
|
67
19
|
export function isExternalPath(inputPath, cwd) {
|
|
68
20
|
const expandedPath = expandHome(inputPath);
|
|
69
|
-
|
|
21
|
+
// Resolution must never open(2) a component (autofs triggers block, execute-only dirs EACCES):
|
|
22
|
+
// realpathWithoutOpen walks lstat/readlink only, exactly what the classifier needs.
|
|
23
|
+
const normalizedCwd = realpathWithoutOpen(cwd);
|
|
70
24
|
const absolutePath = path.isAbsolute(expandedPath) ? expandedPath : path.resolve(normalizedCwd, expandedPath);
|
|
71
|
-
const normalizedTarget =
|
|
25
|
+
const normalizedTarget = realpathWithoutOpen(absolutePath);
|
|
72
26
|
if (normalizedTarget === normalizedCwd) {
|
|
73
27
|
return false;
|
|
74
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-dir.js","sourceRoot":"","s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G,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACtC,IACC,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC;YAC3B,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC;YAC3B,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC;YAC3B,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC;YAC5B,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC;YAC7B,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,EACxB,CAAC;YACF,UAAU,GAAG,CAAC,CAAC;QAChB,CAAC;IACF,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,UAAU,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACjD,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3B,SAAS;QACV,CAAC;QAED,IAAI,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;YAChC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;IACF,CAAC;IAED,OAAO,aAAa,CAAC;AACtB,CAAC","sourcesContent":["import * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\n\nexport function expandHome(inputPath: string): string {\n\tif (inputPath === \"~\") {\n\t\treturn os.homedir();\n\t}\n\tif (inputPath.startsWith(\"~/\") || inputPath.startsWith(\"~\\\\\")) {\n\t\treturn path.join(os.homedir(), inputPath.slice(2));\n\t}\n\tif (inputPath.startsWith(\"$HOME/\") || inputPath.startsWith(\"$HOME\\\\\")) {\n\t\treturn path.join(os.homedir(), inputPath.slice(6));\n\t}\n\tif (inputPath === \"$HOME\") {\n\t\treturn os.homedir();\n\t}\n\treturn inputPath;\n}\n\n/** Symlink hops allowed while resolving one path; realpath(3) reports ELOOP past this. */\nconst MAX_SYMLINK_HOPS = 40;\n\nfunction splitComponents(normalizedPath: string): { readonly root: string; readonly parts: readonly string[] } {\n\tconst { root } = path.parse(normalizedPath);\n\tconst parts = normalizedPath\n\t\t.slice(root.length)\n\t\t.split(path.sep)\n\t\t.filter((part) => part.length > 0);\n\treturn { root, parts };\n}\n\n/**\n * Resolve symlinks the way realpath(3) does — one lstat/readlink per component — without ever\n * open(2)-ing a component. Bun's `fs.realpath*` opens every directory it resolves, so an autofs\n * trigger such as macOS `/home` blocks the whole process (the classifier runs on the host main\n * thread, freezing the TUI) and an execute-only directory fails with EACCES; lstat needs only\n * search permission and never mounts anything. Components from the first missing one onward are\n * kept verbatim, so a file that does not exist yet still lands where its symlinked parent points.\n */\nfunction normalizePath(inputPath: string): string {\n\tconst { root, parts } = splitComponents(path.normalize(inputPath));\n\tconst pending = [...parts];\n\tlet resolved = root;\n\tlet hops = 0;\n\twhile (pending.length > 0) {\n\t\tconst part = pending.shift();\n\t\tif (part === undefined) break;\n\t\tconst candidate = path.join(resolved, part);\n\t\tlet link: string;\n\t\ttry {\n\t\t\tif (!fs.lstatSync(candidate).isSymbolicLink()) {\n\t\t\t\tresolved = candidate;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\thops += 1;\n\t\t\tif (hops > MAX_SYMLINK_HOPS) return path.join(candidate, ...pending);\n\t\t\tlink = fs.readlinkSync(candidate);\n\t\t} catch {\n\t\t\treturn path.join(candidate, ...pending);\n\t\t}\n\t\tconst target = splitComponents(path.resolve(resolved, link));\n\t\tresolved = target.root;\n\t\tpending.unshift(...target.parts);\n\t}\n\treturn resolved;\n}\n\nexport function isExternalPath(inputPath: string, cwd: string): boolean {\n\tconst expandedPath = expandHome(inputPath);\n\tconst normalizedCwd = normalizePath(cwd);\n\tconst absolutePath = path.isAbsolute(expandedPath) ? expandedPath : path.resolve(normalizedCwd, expandedPath);\n\tconst normalizedTarget = normalizePath(absolutePath);\n\n\tif (normalizedTarget === normalizedCwd) {\n\t\treturn false;\n\t}\n\n\tconst cwdWithSeparator = normalizedCwd.endsWith(path.sep) ? normalizedCwd : normalizedCwd + path.sep;\n\n\treturn !normalizedTarget.startsWith(cwdWithSeparator);\n}\n\nfunction tokenizeCommand(command: string): string[] {\n\tconst tokens: string[] = [];\n\tlet current = \"\";\n\tlet inQuotes: string | null = null;\n\tlet escaped = false;\n\n\tfor (let i = 0; i < command.length; i++) {\n\t\tconst char = command[i];\n\n\t\tif (escaped) {\n\t\t\tcurrent += char;\n\t\t\tescaped = false;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"\\\\\") {\n\t\t\tescaped = true;\n\t\t\tcurrent += char;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inQuotes) {\n\t\t\tif (char === inQuotes) {\n\t\t\t\tinQuotes = null;\n\t\t\t}\n\t\t\tcurrent += char;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === '\"' || char === \"'\") {\n\t\t\tinQuotes = char;\n\t\t\tcurrent += char;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \" \" || char === \"\\t\") {\n\t\t\tif (current.length > 0) {\n\t\t\t\ttokens.push(current);\n\t\t\t\tcurrent = \"\";\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tcurrent += char;\n\t}\n\n\tif (current.length > 0) {\n\t\ttokens.push(current);\n\t}\n\n\treturn tokens;\n}\n\nfunction unquote(token: string): string {\n\tif (token.length < 2) return token;\n\tconst first = token[0];\n\tconst last = token[token.length - 1];\n\tif ((first === '\"' || first === \"'\") && first === last) {\n\t\treturn token.slice(1, -1);\n\t}\n\treturn token;\n}\n\nfunction looksLikePath(token: string): boolean {\n\tif (token.startsWith(\"-\")) return false;\n\tif (/^[A-Za-z_][A-Za-z0-9_]*=/.test(token)) return false;\n\tif ([\"|\", \"||\", \"&&\", \";\", \"&\", \"$(\", \"${\", \"`\"].some((op) => token.includes(op))) {\n\t\treturn false;\n\t}\n\tif (token.startsWith(\"/\")) return true;\n\tif (token.startsWith(\"~\")) return true;\n\tif (token.startsWith(\"$HOME\")) return true;\n\tif (token.startsWith(\"./\") || token.startsWith(\"../\")) return true;\n\tif (token.includes(\"/\")) return true;\n\n\treturn false;\n}\n\nexport function extractExternalPaths(command: string, cwd: string): string[] {\n\tconst tokens = tokenizeCommand(command);\n\tconst externalPaths: string[] = [];\n\n\tlet startIndex = 0;\n\tif (tokens.length > 0) {\n\t\tconst firstToken = unquote(tokens[0]);\n\t\tif (\n\t\t\t!firstToken.startsWith(\"/\") &&\n\t\t\t!firstToken.startsWith(\"~\") &&\n\t\t\t!firstToken.startsWith(\"$\") &&\n\t\t\t!firstToken.startsWith(\"./\") &&\n\t\t\t!firstToken.startsWith(\"../\") &&\n\t\t\t!firstToken.includes(\"/\")\n\t\t) {\n\t\t\tstartIndex = 1;\n\t\t}\n\t}\n\n\tfor (let i = startIndex; i < tokens.length; i++) {\n\t\tconst token = unquote(tokens[i]);\n\n\t\tif (!looksLikePath(token)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (isExternalPath(token, cwd)) {\n\t\t\texternalPaths.push(token);\n\t\t}\n\t}\n\n\treturn externalPaths;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"external-dir.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/permission-system/external-dir.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,MAAM,UAAU,UAAU,CAAC,SAAiB;IAC3C,IAAI,SAAS,KAAK,GAAG,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC;IACrB,CAAC;IACD,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,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Content":["import * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport { realpathWithoutOpen } from \"../../../../utils/paths.ts\";\n\nexport function expandHome(inputPath: string): string {\n\tif (inputPath === \"~\") {\n\t\treturn os.homedir();\n\t}\n\tif (inputPath.startsWith(\"~/\") || inputPath.startsWith(\"~\\\\\")) {\n\t\treturn path.join(os.homedir(), inputPath.slice(2));\n\t}\n\tif (inputPath.startsWith(\"$HOME/\") || inputPath.startsWith(\"$HOME\\\\\")) {\n\t\treturn path.join(os.homedir(), inputPath.slice(6));\n\t}\n\tif (inputPath === \"$HOME\") {\n\t\treturn os.homedir();\n\t}\n\treturn inputPath;\n}\n\nexport function isExternalPath(inputPath: string, cwd: string): boolean {\n\tconst expandedPath = expandHome(inputPath);\n\t// Resolution must never open(2) a component (autofs triggers block, execute-only dirs EACCES):\n\t// realpathWithoutOpen walks lstat/readlink only, exactly what the classifier needs.\n\tconst normalizedCwd = realpathWithoutOpen(cwd);\n\tconst absolutePath = path.isAbsolute(expandedPath) ? expandedPath : path.resolve(normalizedCwd, expandedPath);\n\tconst normalizedTarget = realpathWithoutOpen(absolutePath);\n\n\tif (normalizedTarget === normalizedCwd) {\n\t\treturn false;\n\t}\n\n\tconst cwdWithSeparator = normalizedCwd.endsWith(path.sep) ? normalizedCwd : normalizedCwd + path.sep;\n\n\treturn !normalizedTarget.startsWith(cwdWithSeparator);\n}\n\nfunction tokenizeCommand(command: string): string[] {\n\tconst tokens: string[] = [];\n\tlet current = \"\";\n\tlet inQuotes: string | null = null;\n\tlet escaped = false;\n\n\tfor (let i = 0; i < command.length; i++) {\n\t\tconst char = command[i];\n\n\t\tif (escaped) {\n\t\t\tcurrent += char;\n\t\t\tescaped = false;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"\\\\\") {\n\t\t\tescaped = true;\n\t\t\tcurrent += char;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inQuotes) {\n\t\t\tif (char === inQuotes) {\n\t\t\t\tinQuotes = null;\n\t\t\t}\n\t\t\tcurrent += char;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === '\"' || char === \"'\") {\n\t\t\tinQuotes = char;\n\t\t\tcurrent += char;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \" \" || char === \"\\t\") {\n\t\t\tif (current.length > 0) {\n\t\t\t\ttokens.push(current);\n\t\t\t\tcurrent = \"\";\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tcurrent += char;\n\t}\n\n\tif (current.length > 0) {\n\t\ttokens.push(current);\n\t}\n\n\treturn tokens;\n}\n\nfunction unquote(token: string): string {\n\tif (token.length < 2) return token;\n\tconst first = token[0];\n\tconst last = token[token.length - 1];\n\tif ((first === '\"' || first === \"'\") && first === last) {\n\t\treturn token.slice(1, -1);\n\t}\n\treturn token;\n}\n\nfunction looksLikePath(token: string): boolean {\n\tif (token.startsWith(\"-\")) return false;\n\tif (/^[A-Za-z_][A-Za-z0-9_]*=/.test(token)) return false;\n\tif ([\"|\", \"||\", \"&&\", \";\", \"&\", \"$(\", \"${\", \"`\"].some((op) => token.includes(op))) {\n\t\treturn false;\n\t}\n\tif (token.startsWith(\"/\")) return true;\n\tif (token.startsWith(\"~\")) return true;\n\tif (token.startsWith(\"$HOME\")) return true;\n\tif (token.startsWith(\"./\") || token.startsWith(\"../\")) return true;\n\tif (token.includes(\"/\")) return true;\n\n\treturn false;\n}\n\nexport function extractExternalPaths(command: string, cwd: string): string[] {\n\tconst tokens = tokenizeCommand(command);\n\tconst externalPaths: string[] = [];\n\n\tlet startIndex = 0;\n\tif (tokens.length > 0) {\n\t\tconst firstToken = unquote(tokens[0]);\n\t\tif (\n\t\t\t!firstToken.startsWith(\"/\") &&\n\t\t\t!firstToken.startsWith(\"~\") &&\n\t\t\t!firstToken.startsWith(\"$\") &&\n\t\t\t!firstToken.startsWith(\"./\") &&\n\t\t\t!firstToken.startsWith(\"../\") &&\n\t\t\t!firstToken.includes(\"/\")\n\t\t) {\n\t\t\tstartIndex = 1;\n\t\t}\n\t}\n\n\tfor (let i = startIndex; i < tokens.length; i++) {\n\t\tconst token = unquote(tokens[i]);\n\n\t\tif (!looksLikePath(token)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (isExternalPath(token, cwd)) {\n\t\t\texternalPaths.push(token);\n\t\t}\n\t}\n\n\treturn externalPaths;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parsers.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/permission-system/parsers.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAG7D,gEAAgE;AAChE,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAC,CAAC;AAEpF,wEAAwE;AACxE,MAAM,MAAM,oBAAoB,GAAG,CAClC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,GAAG,EAAE,MAAM,KACP,iBAAiB,EAAE,CAAC;AAmEzB,oDAAoD;AACpD,qBAAa,cAAc;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2C;IAEnE,4CAA4C;IAC5C,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,IAAI;IAI9D,gDAAgD;IAChD,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,iBAAiB,EAAE;CAOzF;AAED,+DAA+D;AAC/D,wBAAgB,2BAA2B,IAAI,cAAc,
|
|
1
|
+
{"version":3,"file":"parsers.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/permission-system/parsers.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAG7D,gEAAgE;AAChE,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAC,CAAC;AAEpF,wEAAwE;AACxE,MAAM,MAAM,oBAAoB,GAAG,CAClC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,GAAG,EAAE,MAAM,KACP,iBAAiB,EAAE,CAAC;AAmEzB,oDAAoD;AACpD,qBAAa,cAAc;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2C;IAEnE,4CAA4C;IAC5C,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,IAAI;IAI9D,gDAAgD;IAChD,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,iBAAiB,EAAE;CAOzF;AAED,+DAA+D;AAC/D,wBAAgB,2BAA2B,IAAI,cAAc,CAgK5D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { realpathSync } from "node:fs";
|
|
2
1
|
import { dirname, resolve } from "node:path";
|
|
2
|
+
import { realpathWithoutOpen } from "../../../../utils/paths.js";
|
|
3
3
|
import { extractPatchedPaths } from "../gpt-apply-patch/index.js";
|
|
4
4
|
import { BashArity } from "../permission-system/arity.js";
|
|
5
5
|
import { extractExternalPaths, isExternalPath } from "../permission-system/external-dir.js";
|
|
@@ -108,12 +108,10 @@ export function createBuiltinParserRegistry() {
|
|
|
108
108
|
registry.register("monitor", (toolName, input, cwd) => {
|
|
109
109
|
const path = getString(input, "path");
|
|
110
110
|
if (path) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// Registration performs the authoritative access and canonical-parent check.
|
|
116
|
-
}
|
|
111
|
+
// This runs on the host main thread: the parent identity must be derived without open(2)
|
|
112
|
+
// (realpath opens directories and blocks forever on a wedged autofs trigger). Registration
|
|
113
|
+
// performs the authoritative access check and re-derives the parent the same way.
|
|
114
|
+
setApprovedMonitorParent(input, realpathWithoutOpen(dirname(resolve(cwd, path))));
|
|
117
115
|
return withExternalDirectoryRequests([{ permission: "read", patterns: [path], always: [path] }], [path], cwd, "file");
|
|
118
116
|
}
|
|
119
117
|
return parseBashLikePermission("command")(toolName, input, cwd);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parsers.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/permission-system/parsers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAE5F,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAY7E,SAAS,yBAAyB,CAAC,UAAkB;IACpD,OAAO;QACN,UAAU;QACV,QAAQ,EAAE,CAAC,GAAG,CAAC;QACf,MAAM,EAAE,CAAC,GAAG,CAAC;KACb,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,KAA8B,EAAE,GAAG,IAAc;IACnE,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACxB,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAID,SAAS,wBAAwB,CAAC,SAAiB,EAAE,KAAkB;IACtE,IAAI,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,SAAS,CAAC,CAAC;QAC5C,MAAM,iBAAiB,GAAG,UAAU,IAAI,OAAO,CAAC;QAChD,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACxB,OAAO,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC;QAC5C,CAAC;QAED,MAAM,YAAY,GAAwB;YACzC;gBACC,UAAU,EAAE,MAAM;gBAClB,QAAQ,EAAE,CAAC,iBAAiB,CAAC;gBAC7B,MAAM,EAAE,CAAC,GAAG,CAAC;aACb;SACD,CAAC;QACF,OAAO,UAAU,CAAC,CAAC,CAAC,6BAA6B,CAAC,YAAY,EAAE,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;IAChH,CAAC,CAAC,CAAC;IAEH,MAAM,UAAU,GAAyB,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QAClE,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,GAAG,CAAC;QACnD,OAAO,6BAA6B,CACnC;YACC;gBACC,UAAU,EAAE,MAAM;gBAClB,QAAQ,EAAE,CAAC,UAAU,CAAC;gBACtB,MAAM,EAAE,CAAC,UAAU,CAAC;aACpB;SACD,EACD,CAAC,UAAU,CAAC,EACZ,GAAG,EACH,WAAW,CACX,CAAC;IACH,CAAC,CAAC;IAEF,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACtC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAEpC,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["import { realpathSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { extractPatchedPaths } from \"../gpt-apply-patch/index.ts\";\nimport { BashArity } from \"../permission-system/arity.ts\";\nimport { extractExternalPaths, isExternalPath } from \"../permission-system/external-dir.ts\";\nimport type { Request } from \"../permission-system/types.ts\";\nimport { setApprovedMonitorParent } from \"../terminal/monitor-permission.ts\";\n\n/** Simplified permission request without ID/session metadata */\nexport type PermissionRequest = Pick<Request, \"permission\" | \"patterns\" | \"always\">;\n\n/** Parser function that extracts permission requests from tool input */\nexport type ToolPermissionParser = (\n\ttoolName: string,\n\tinput: Record<string, unknown>,\n\tcwd: string,\n) => PermissionRequest[];\n\nfunction fallbackPermissionRequest(permission: string): PermissionRequest {\n\treturn {\n\t\tpermission,\n\t\tpatterns: [\"*\"],\n\t\talways: [\"*\"],\n\t};\n}\n\nfunction getString(input: Record<string, unknown>, ...keys: string[]): string | undefined {\n\tfor (const key of keys) {\n\t\tconst value = input[key];\n\t\tif (typeof value === \"string\") {\n\t\t\treturn value;\n\t\t}\n\t}\n\treturn undefined;\n}\n\ntype AlwaysScope = \"file\" | \"directory\";\n\nfunction toParentDirectoryPattern(inputPath: string, scope: AlwaysScope): string {\n\tif (inputPath === \"~\" || inputPath === \"$HOME\") {\n\t\treturn `${inputPath}/*`;\n\t}\n\n\tif (scope === \"directory\") {\n\t\treturn inputPath.endsWith(\"/\") || inputPath.endsWith(\"\\\\\") ? `${inputPath}*` : `${inputPath}/*`;\n\t}\n\n\tif (inputPath.endsWith(\"/\") || inputPath.endsWith(\"\\\\\")) {\n\t\treturn `${inputPath}*`;\n\t}\n\n\tconst parentPattern = inputPath.replace(/[\\\\/][^\\\\/]+$/, \"/*\");\n\tif (parentPattern === \"/*\") {\n\t\treturn inputPath;\n\t}\n\treturn parentPattern;\n}\n\nfunction parseFilePath(input: Record<string, unknown>): string | undefined {\n\treturn getString(input, \"path\", \"file_path\");\n}\n\nfunction withExternalDirectoryRequests(\n\trequests: PermissionRequest[],\n\tpaths: string[],\n\tcwd: string,\n\tscope: AlwaysScope,\n): PermissionRequest[] {\n\tconst externalPaths = paths.filter((inputPath) => isExternalPath(inputPath, cwd));\n\tif (externalPaths.length === 0) {\n\t\treturn requests;\n\t}\n\n\treturn [\n\t\t...requests,\n\t\t{\n\t\t\tpermission: \"external_directory\",\n\t\t\tpatterns: externalPaths,\n\t\t\talways: externalPaths.map((externalPath) => toParentDirectoryPattern(externalPath, scope)),\n\t\t},\n\t];\n}\n\n/** Registry for tool-specific permission parsers */\nexport class ParserRegistry {\n\tprivate readonly parsers = new Map<string, ToolPermissionParser>();\n\n\t/** Register a parser for a specific tool */\n\tregister(toolName: string, parser: ToolPermissionParser): void {\n\t\tthis.parsers.set(toolName, parser);\n\t}\n\n\t/** Parse tool input into permission requests */\n\tparse(toolName: string, input: Record<string, unknown>, cwd: string): PermissionRequest[] {\n\t\tconst parser = this.parsers.get(toolName);\n\t\tif (!parser) {\n\t\t\treturn [fallbackPermissionRequest(toolName)];\n\t\t}\n\t\treturn parser(toolName, input, cwd);\n\t}\n}\n\n/** Create registry with built-in parsers for standard tools */\nexport function createBuiltinParserRegistry(): ParserRegistry {\n\tconst registry = new ParserRegistry();\n\n\t// bash_input writes arbitrary stdin to a live shell session = arbitrary command execution,\n\t// so it MUST be gated in the SAME `bash` permission class (via the `input` field), else\n\t// read-only/ask presets would be bypassable through a persistent session. The steering/read\n\t// tools (bash_output/kill_bash/bash_resize) fall back to their own tool-named permissions.\n\tconst parseBashLikePermission =\n\t\t(commandKey: string): ToolPermissionParser =>\n\t\t(_toolName, input, cwd) => {\n\t\t\tconst command = getString(input, commandKey);\n\t\t\tif (!command) {\n\t\t\t\treturn [fallbackPermissionRequest(\"bash\")];\n\t\t\t}\n\n\t\t\tconst tokens = command.split(/\\s+/).filter(Boolean);\n\t\t\tconst prefix = BashArity.prefix(tokens).join(\" \");\n\t\t\tconst always = prefix ? [prefix, `${prefix} *`] : [\"*\"];\n\t\t\tconst requests: PermissionRequest[] = [\n\t\t\t\t{\n\t\t\t\t\tpermission: \"bash\",\n\t\t\t\t\tpatterns: [prefix || command],\n\t\t\t\t\talways,\n\t\t\t\t},\n\t\t\t];\n\n\t\t\tconst externalPaths = extractExternalPaths(command, cwd);\n\t\t\tif (externalPaths.length > 0) {\n\t\t\t\trequests.push({\n\t\t\t\t\tpermission: \"external_directory\",\n\t\t\t\t\tpatterns: externalPaths,\n\t\t\t\t\talways: externalPaths.map((externalPath) => toParentDirectoryPattern(externalPath, \"file\")),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn requests;\n\t\t};\n\n\tregistry.register(\"bash\", parseBashLikePermission(\"command\"));\n\tregistry.register(\"bash_input\", parseBashLikePermission(\"input\"));\n\tregistry.register(\"monitor\", (toolName, input, cwd) => {\n\t\tconst path = getString(input, \"path\");\n\t\tif (path) {\n\t\t\ttry {\n\t\t\t\tsetApprovedMonitorParent(input, realpathSync(dirname(resolve(cwd, path))));\n\t\t\t} catch {\n\t\t\t\t// Registration performs the authoritative access and canonical-parent check.\n\t\t\t}\n\t\t\treturn withExternalDirectoryRequests(\n\t\t\t\t[{ permission: \"read\", patterns: [path], always: [path] }],\n\t\t\t\t[path],\n\t\t\t\tcwd,\n\t\t\t\t\"file\",\n\t\t\t);\n\t\t}\n\t\treturn parseBashLikePermission(\"command\")(toolName, input, cwd);\n\t});\n\n\tconst editParser: ToolPermissionParser = () => {\n\t\treturn [fallbackPermissionRequest(\"edit\")];\n\t};\n\n\tconst parseEditPermission: ToolPermissionParser = (_toolName, input, cwd) => {\n\t\tconst filePath = parseFilePath(input);\n\t\tif (filePath) {\n\t\t\treturn withExternalDirectoryRequests(\n\t\t\t\t[\n\t\t\t\t\t{\n\t\t\t\t\t\tpermission: \"edit\",\n\t\t\t\t\t\tpatterns: [filePath],\n\t\t\t\t\t\talways: [filePath],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\t[filePath],\n\t\t\t\tcwd,\n\t\t\t\t\"file\",\n\t\t\t);\n\t\t}\n\n\t\tconst patchText = getString(input, \"input\", \"patchText\");\n\t\tif (!patchText) {\n\t\t\treturn editParser(\"edit\", input, \"\");\n\t\t}\n\n\t\tconst patchedPaths = extractPatchedPaths(patchText);\n\t\tif (patchedPaths.length === 0) {\n\t\t\treturn editParser(\"edit\", input, \"\");\n\t\t}\n\n\t\tconst editRequests = patchedPaths.map((patchedPath) => ({\n\t\t\tpermission: \"edit\",\n\t\t\tpatterns: [patchedPath],\n\t\t\talways: [patchedPath],\n\t\t}));\n\n\t\treturn withExternalDirectoryRequests(editRequests, patchedPaths, cwd, \"file\");\n\t};\n\n\tregistry.register(\"edit\", parseEditPermission);\n\tregistry.register(\"write\", parseEditPermission);\n\tregistry.register(\"apply_patch\", parseEditPermission);\n\tregistry.register(\"multiedit\", parseEditPermission);\n\n\tregistry.register(\"read\", (_toolName, input, cwd) => {\n\t\tconst filePath = parseFilePath(input);\n\t\tif (!filePath) {\n\t\t\treturn [fallbackPermissionRequest(\"read\")];\n\t\t}\n\n\t\treturn withExternalDirectoryRequests(\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tpermission: \"read\",\n\t\t\t\t\tpatterns: [filePath],\n\t\t\t\t\talways: [filePath],\n\t\t\t\t},\n\t\t\t],\n\t\t\t[filePath],\n\t\t\tcwd,\n\t\t\t\"file\",\n\t\t);\n\t});\n\n\tregistry.register(\"grep\", (_toolName, input, cwd) => {\n\t\tconst searchPath = getString(input, \"path\");\n\t\tconst pattern = getString(input, \"pattern\");\n\t\tconst permissionPattern = searchPath ?? pattern;\n\t\tif (!permissionPattern) {\n\t\t\treturn [fallbackPermissionRequest(\"grep\")];\n\t\t}\n\n\t\tconst grepRequests: PermissionRequest[] = [\n\t\t\t{\n\t\t\t\tpermission: \"grep\",\n\t\t\t\tpatterns: [permissionPattern],\n\t\t\t\talways: [\"*\"],\n\t\t\t},\n\t\t];\n\t\treturn searchPath ? withExternalDirectoryRequests(grepRequests, [searchPath], cwd, \"directory\") : grepRequests;\n\t});\n\n\tconst listParser: ToolPermissionParser = (_toolName, input, cwd) => {\n\t\tconst searchPath = getString(input, \"path\") ?? \".\";\n\t\treturn withExternalDirectoryRequests(\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tpermission: \"list\",\n\t\t\t\t\tpatterns: [searchPath],\n\t\t\t\t\talways: [searchPath],\n\t\t\t\t},\n\t\t\t],\n\t\t\t[searchPath],\n\t\t\tcwd,\n\t\t\t\"directory\",\n\t\t);\n\t};\n\n\tregistry.register(\"find\", listParser);\n\tregistry.register(\"ls\", listParser);\n\n\treturn registry;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"parsers.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/permission-system/parsers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAE5F,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAY7E,SAAS,yBAAyB,CAAC,UAAkB;IACpD,OAAO;QACN,UAAU;QACV,QAAQ,EAAE,CAAC,GAAG,CAAC;QACf,MAAM,EAAE,CAAC,GAAG,CAAC;KACb,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,KAA8B,EAAE,GAAG,IAAc;IACnE,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACxB,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAID,SAAS,wBAAwB,CAAC,SAAiB,EAAE,KAAkB;IACtE,IAAI,SAAS,KAAK,GAAG,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;QAChD,OAAO,GAAG,SAAS,IAAI,CAAC;IACzB,CAAC;IAED,IAAI,KAAK,KAAK,WAAW,E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AC;QAC5C,CAAC;QAED,MAAM,YAAY,GAAwB;YACzC;gBACC,UAAU,EAAE,MAAM;gBAClB,QAAQ,EAAE,CAAC,iBAAiB,CAAC;gBAC7B,MAAM,EAAE,CAAC,GAAG,CAAC;aACb;SACD,CAAC;QACF,OAAO,UAAU,CAAC,CAAC,CAAC,6BAA6B,CAAC,YAAY,EAAE,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;IAChH,CAAC,CAAC,CAAC;IAEH,MAAM,UAAU,GAAyB,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QAClE,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,GAAG,CAAC;QACnD,OAAO,6BAA6B,CACnC;YACC;gBACC,UAAU,EAAE,MAAM;gBAClB,QAAQ,EAAE,CAAC,UAAU,CAAC;gBACtB,MAAM,EAAE,CAAC,UAAU,CAAC;aACpB;SACD,EACD,CAAC,UAAU,CAAC,EACZ,GAAG,EACH,WAAW,CACX,CAAC;IACH,CAAC,CAAC;IAEF,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACtC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAEpC,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["import { dirname, resolve } from \"node:path\";\nimport { realpathWithoutOpen } from \"../../../../utils/paths.ts\";\nimport { extractPatchedPaths } from \"../gpt-apply-patch/index.ts\";\nimport { BashArity } from \"../permission-system/arity.ts\";\nimport { extractExternalPaths, isExternalPath } from \"../permission-system/external-dir.ts\";\nimport type { Request } from \"../permission-system/types.ts\";\nimport { setApprovedMonitorParent } from \"../terminal/monitor-permission.ts\";\n\n/** Simplified permission request without ID/session metadata */\nexport type PermissionRequest = Pick<Request, \"permission\" | \"patterns\" | \"always\">;\n\n/** Parser function that extracts permission requests from tool input */\nexport type ToolPermissionParser = (\n\ttoolName: string,\n\tinput: Record<string, unknown>,\n\tcwd: string,\n) => PermissionRequest[];\n\nfunction fallbackPermissionRequest(permission: string): PermissionRequest {\n\treturn {\n\t\tpermission,\n\t\tpatterns: [\"*\"],\n\t\talways: [\"*\"],\n\t};\n}\n\nfunction getString(input: Record<string, unknown>, ...keys: string[]): string | undefined {\n\tfor (const key of keys) {\n\t\tconst value = input[key];\n\t\tif (typeof value === \"string\") {\n\t\t\treturn value;\n\t\t}\n\t}\n\treturn undefined;\n}\n\ntype AlwaysScope = \"file\" | \"directory\";\n\nfunction toParentDirectoryPattern(inputPath: string, scope: AlwaysScope): string {\n\tif (inputPath === \"~\" || inputPath === \"$HOME\") {\n\t\treturn `${inputPath}/*`;\n\t}\n\n\tif (scope === \"directory\") {\n\t\treturn inputPath.endsWith(\"/\") || inputPath.endsWith(\"\\\\\") ? `${inputPath}*` : `${inputPath}/*`;\n\t}\n\n\tif (inputPath.endsWith(\"/\") || inputPath.endsWith(\"\\\\\")) {\n\t\treturn `${inputPath}*`;\n\t}\n\n\tconst parentPattern = inputPath.replace(/[\\\\/][^\\\\/]+$/, \"/*\");\n\tif (parentPattern === \"/*\") {\n\t\treturn inputPath;\n\t}\n\treturn parentPattern;\n}\n\nfunction parseFilePath(input: Record<string, unknown>): string | undefined {\n\treturn getString(input, \"path\", \"file_path\");\n}\n\nfunction withExternalDirectoryRequests(\n\trequests: PermissionRequest[],\n\tpaths: string[],\n\tcwd: string,\n\tscope: AlwaysScope,\n): PermissionRequest[] {\n\tconst externalPaths = paths.filter((inputPath) => isExternalPath(inputPath, cwd));\n\tif (externalPaths.length === 0) {\n\t\treturn requests;\n\t}\n\n\treturn [\n\t\t...requests,\n\t\t{\n\t\t\tpermission: \"external_directory\",\n\t\t\tpatterns: externalPaths,\n\t\t\talways: externalPaths.map((externalPath) => toParentDirectoryPattern(externalPath, scope)),\n\t\t},\n\t];\n}\n\n/** Registry for tool-specific permission parsers */\nexport class ParserRegistry {\n\tprivate readonly parsers = new Map<string, ToolPermissionParser>();\n\n\t/** Register a parser for a specific tool */\n\tregister(toolName: string, parser: ToolPermissionParser): void {\n\t\tthis.parsers.set(toolName, parser);\n\t}\n\n\t/** Parse tool input into permission requests */\n\tparse(toolName: string, input: Record<string, unknown>, cwd: string): PermissionRequest[] {\n\t\tconst parser = this.parsers.get(toolName);\n\t\tif (!parser) {\n\t\t\treturn [fallbackPermissionRequest(toolName)];\n\t\t}\n\t\treturn parser(toolName, input, cwd);\n\t}\n}\n\n/** Create registry with built-in parsers for standard tools */\nexport function createBuiltinParserRegistry(): ParserRegistry {\n\tconst registry = new ParserRegistry();\n\n\t// bash_input writes arbitrary stdin to a live shell session = arbitrary command execution,\n\t// so it MUST be gated in the SAME `bash` permission class (via the `input` field), else\n\t// read-only/ask presets would be bypassable through a persistent session. The steering/read\n\t// tools (bash_output/kill_bash/bash_resize) fall back to their own tool-named permissions.\n\tconst parseBashLikePermission =\n\t\t(commandKey: string): ToolPermissionParser =>\n\t\t(_toolName, input, cwd) => {\n\t\t\tconst command = getString(input, commandKey);\n\t\t\tif (!command) {\n\t\t\t\treturn [fallbackPermissionRequest(\"bash\")];\n\t\t\t}\n\n\t\t\tconst tokens = command.split(/\\s+/).filter(Boolean);\n\t\t\tconst prefix = BashArity.prefix(tokens).join(\" \");\n\t\t\tconst always = prefix ? [prefix, `${prefix} *`] : [\"*\"];\n\t\t\tconst requests: PermissionRequest[] = [\n\t\t\t\t{\n\t\t\t\t\tpermission: \"bash\",\n\t\t\t\t\tpatterns: [prefix || command],\n\t\t\t\t\talways,\n\t\t\t\t},\n\t\t\t];\n\n\t\t\tconst externalPaths = extractExternalPaths(command, cwd);\n\t\t\tif (externalPaths.length > 0) {\n\t\t\t\trequests.push({\n\t\t\t\t\tpermission: \"external_directory\",\n\t\t\t\t\tpatterns: externalPaths,\n\t\t\t\t\talways: externalPaths.map((externalPath) => toParentDirectoryPattern(externalPath, \"file\")),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn requests;\n\t\t};\n\n\tregistry.register(\"bash\", parseBashLikePermission(\"command\"));\n\tregistry.register(\"bash_input\", parseBashLikePermission(\"input\"));\n\tregistry.register(\"monitor\", (toolName, input, cwd) => {\n\t\tconst path = getString(input, \"path\");\n\t\tif (path) {\n\t\t\t// This runs on the host main thread: the parent identity must be derived without open(2)\n\t\t\t// (realpath opens directories and blocks forever on a wedged autofs trigger). Registration\n\t\t\t// performs the authoritative access check and re-derives the parent the same way.\n\t\t\tsetApprovedMonitorParent(input, realpathWithoutOpen(dirname(resolve(cwd, path))));\n\t\t\treturn withExternalDirectoryRequests(\n\t\t\t\t[{ permission: \"read\", patterns: [path], always: [path] }],\n\t\t\t\t[path],\n\t\t\t\tcwd,\n\t\t\t\t\"file\",\n\t\t\t);\n\t\t}\n\t\treturn parseBashLikePermission(\"command\")(toolName, input, cwd);\n\t});\n\n\tconst editParser: ToolPermissionParser = () => {\n\t\treturn [fallbackPermissionRequest(\"edit\")];\n\t};\n\n\tconst parseEditPermission: ToolPermissionParser = (_toolName, input, cwd) => {\n\t\tconst filePath = parseFilePath(input);\n\t\tif (filePath) {\n\t\t\treturn withExternalDirectoryRequests(\n\t\t\t\t[\n\t\t\t\t\t{\n\t\t\t\t\t\tpermission: \"edit\",\n\t\t\t\t\t\tpatterns: [filePath],\n\t\t\t\t\t\talways: [filePath],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\t[filePath],\n\t\t\t\tcwd,\n\t\t\t\t\"file\",\n\t\t\t);\n\t\t}\n\n\t\tconst patchText = getString(input, \"input\", \"patchText\");\n\t\tif (!patchText) {\n\t\t\treturn editParser(\"edit\", input, \"\");\n\t\t}\n\n\t\tconst patchedPaths = extractPatchedPaths(patchText);\n\t\tif (patchedPaths.length === 0) {\n\t\t\treturn editParser(\"edit\", input, \"\");\n\t\t}\n\n\t\tconst editRequests = patchedPaths.map((patchedPath) => ({\n\t\t\tpermission: \"edit\",\n\t\t\tpatterns: [patchedPath],\n\t\t\talways: [patchedPath],\n\t\t}));\n\n\t\treturn withExternalDirectoryRequests(editRequests, patchedPaths, cwd, \"file\");\n\t};\n\n\tregistry.register(\"edit\", parseEditPermission);\n\tregistry.register(\"write\", parseEditPermission);\n\tregistry.register(\"apply_patch\", parseEditPermission);\n\tregistry.register(\"multiedit\", parseEditPermission);\n\n\tregistry.register(\"read\", (_toolName, input, cwd) => {\n\t\tconst filePath = parseFilePath(input);\n\t\tif (!filePath) {\n\t\t\treturn [fallbackPermissionRequest(\"read\")];\n\t\t}\n\n\t\treturn withExternalDirectoryRequests(\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tpermission: \"read\",\n\t\t\t\t\tpatterns: [filePath],\n\t\t\t\t\talways: [filePath],\n\t\t\t\t},\n\t\t\t],\n\t\t\t[filePath],\n\t\t\tcwd,\n\t\t\t\"file\",\n\t\t);\n\t});\n\n\tregistry.register(\"grep\", (_toolName, input, cwd) => {\n\t\tconst searchPath = getString(input, \"path\");\n\t\tconst pattern = getString(input, \"pattern\");\n\t\tconst permissionPattern = searchPath ?? pattern;\n\t\tif (!permissionPattern) {\n\t\t\treturn [fallbackPermissionRequest(\"grep\")];\n\t\t}\n\n\t\tconst grepRequests: PermissionRequest[] = [\n\t\t\t{\n\t\t\t\tpermission: \"grep\",\n\t\t\t\tpatterns: [permissionPattern],\n\t\t\t\talways: [\"*\"],\n\t\t\t},\n\t\t];\n\t\treturn searchPath ? withExternalDirectoryRequests(grepRequests, [searchPath], cwd, \"directory\") : grepRequests;\n\t});\n\n\tconst listParser: ToolPermissionParser = (_toolName, input, cwd) => {\n\t\tconst searchPath = getString(input, \"path\") ?? \".\";\n\t\treturn withExternalDirectoryRequests(\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tpermission: \"list\",\n\t\t\t\t\tpatterns: [searchPath],\n\t\t\t\t\talways: [searchPath],\n\t\t\t\t},\n\t\t\t],\n\t\t\t[searchPath],\n\t\t\tcwd,\n\t\t\t\"directory\",\n\t\t);\n\t};\n\n\tregistry.register(\"find\", listParser);\n\tregistry.register(\"ls\", listParser);\n\n\treturn registry;\n}\n"]}
|
|
@@ -72,7 +72,7 @@ Smallest correct change wins: no refactors beside a focused fix, no helpers or a
|
|
|
72
72
|
|
|
73
73
|
## Working the Task
|
|
74
74
|
|
|
75
|
-
Before each response, privately list what you need next, then request every item that does not depend on another's result in that one response; sequence only true dependencies, and never fill missing parameters with placeholders.
|
|
75
|
+
Before each response, privately list what you need next, then request every item that does not depend on another's result in that one response; sequence only true dependencies, and never fill missing parameters with placeholders. Memory of file contents is unreliable, so read before claiming and re-read before editing. Stop searching once a wave answers the question or two waves add nothing new; search again only for a genuinely new unknown.
|
|
76
76
|
|
|
77
77
|
${buildExecutionToolingParagraph({ toolNames: context.tools.map((tool) => tool.name), dialect: "claude" })}When you have enough information to act, act. Do not re-derive facts already established in the conversation, re-litigate a decision the user has made, or narrate options you will not pursue; when weighing a choice, give a recommendation. When a delegation tool is available, hand sizeable independent tracks to subagents and keep working while they run; keep work you can finish in a few calls yourself.
|
|
78
78
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-fable-5-1.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-fable-5-1.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,EAAE;AACF,gFAAgF;AAChF,+EAA+E;AAC/E,gFAAgF;AAChF,6EAA6E;AAC7E,yEAAyE;AACzE,qCAAqC;AACrC,2EAA2E;AAC3E,gFAAgF;AAChF,yEAAyE;AACzE,8EAA8E;AAC9E,0EAA0E;AAC1E,+EAA+E;AAC/E,WAAW;AACX,oEAAoE;AACpE,2EAA2E;AAC3E,+EAA+E;AAC/E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,kCAAkC;AAClC,6EAA6E;AAC7E,+EAA+E;AAC/E,yEAAyE;AACzE,yEAAyE;AACzE,qEAAqE;AACrE,wEAAwE;AACxE,4EAA4E;AAC5E,2EAA2E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 core plus\n// seven deltas from Anthropic's Fable 5.1 prompting guide, appended where each\n// fit. Reading the guide set end to end (claude.md, the Fable 5 / 5.1 overlays,\n// the Opus 4.8 overlay, the GPT-5.5/5.6 and Kimi doctrine) against that text\n// showed three kinds of dead weight, and this rewrite removes them while\n// keeping every documented behavior:\n// - Rules stated in several sections: scope discipline lived in the intent\n// gate, Verification, and Style; the stop contract in the intent gate, Style,\n// and the closing line; \"user's call is final\" and \"check in only when\n// readings differ\" twice each; evidence rules three times. Each now has one\n// home (a dedicated Scope section carries the 5.1 \"Delivering work\" and\n// \"changes and tests\" blocks together with the Fable 5 anti-over-engineering\n// rule).\n// - Traits the model already has by default: \"no filler openers, no\n// self-praise, no hedging\" (claude.md / Opus 4.8: direct, low-validation\n// style; 5.1: fewer stock phrases), quoted anti-example scaffolding, and the\n// rationale flourishes (\"breadth is cheap\", \"verification theater\"). The\n// 5.1 guide names mannered prose as the anti-pattern and claude.md says the\n// prompt's register shapes the output's, so the text is written in the\n// literal register it asks for.\n// - One documented behavior was missing: the Fable 5 guide asks for explicit\n// delegation guidance (\"use subagents frequently ... keep working while they\n// run\"; the 5.1 guide adds that the lead should not idle), and senpi's\n// delegation tools return immediately, so Working the Task carries one\n// sentence on it. The 5.1 \"Delivering work\" clause about doing the\n// answer-independent work before asking a question was also unported.\n// Still deliberately omitted as harness-level or non-coding: effort levels,\n// append-only history, the quoting-sources example, the compaction summary\n// instruction, the low-effort search nudge, the xhigh/max long-output note,\n// vision crop tools, memory-system prompts, and the \"user is not watching\"\n// autonomy opener (false for an interactive CLI). Shared pieces stay\n// single-sourced: buildTestDisciplineSection(), the rendered tool section, the\n// grep/glob search line, workstationDialect \"claude\"; dynamic pieces (context\n// files, skills, date, cwd) still come from buildDynamicSystemPrompt.\n\nimport { APP_NAME } from \"../../../../config.ts\";\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { getToolsPromptDisplay } from \"../../../dynamic-prompt/tool-categorization.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\nimport { buildExecutionToolingParagraph } from \"./execution-tooling.ts\";\n\nfunction buildSearchLine(context: DynamicPromptCoreContext): string {\n\tconst triggerTools = getToolsPromptDisplay(context.tools);\n\tif (!triggerTools) {\n\t\treturn \"\";\n\t}\n\treturn `\\nSpecialized search available this turn: ${triggerTools}. Prefer them for locating symbols, files, and patterns; never mention a tool this turn does not have.\\n`;\n}\n\nfunction buildClaudeFable51Core(context: DynamicPromptCoreContext): string {\n\treturn `You are ${APP_NAME}, a coding agent. Your work should be indistinguishable from a careful senior engineer's.\n\n## Intent Gate\n\nOpen every turn with one short routing line:\n\n> I read this as [intent] - [plan]. I'll stop when [the exact, observable condition that ends this turn].\n\nOnly the user's explicit request commits you to implementation. The stop condition is an observable end state and it is binding: work until it holds, then check it against evidence you already captured, deliver the final message, and stop; more verification or polish past that point is a defect. Never echo prompt scaffolding in user-facing output.\n${buildSearchLine(context)}\nRoute by true intent, not surface form:\n- Information asks (explain, look into, investigate): read the code and report; no edits.\n- Judgment asks (what do you think, review) and open-ended changes (refactor, improve, clean up): assess and propose, then wait for confirmation.\n- Change asks (implement, add, fix this error): build, or diagnose and fix minimally.\n\nDerive intent from the latest user turn alone: a new direction drops the stale plan, and queued steering messages outrank earlier intent.\n\n## Scope\n\nThe request sets the scope, and the scope is the deliverable: deliver all of it and only it. Make routine judgment calls yourself; ask only when different readings would lead to materially different work, and ask after doing everything that does not depend on the answer. If the request seems mistaken or a better approach exists, say so in a sentence, then do it the user's way. If part of the task is blocked, finish every other part and say exactly what you left out and why.\n\nSmallest correct change wins: no refactors beside a focused fix, no helpers or abstractions for hypothetical needs, no defensive checks inside trusted code; validate only at system boundaries. A pre-existing bug or performance concern you notice is a follow-up for your summary, not a change in this diff. Scratch checks verify and get discarded; commit tests only where the task asks for them or the repository already keeps tests for that kind of change, sized like the neighboring test files. Prefer a surgical edit over rewriting a file when the result would be identical.\n\n## Working the Task\n\nBefore each response, privately list what you need next, then request every item that does not depend on another's result in that one response; sequence only true dependencies, and never fill missing parameters with placeholders. Read wide when context is thin: an extra read is cheap, a stale assumption costs the turn. Memory of file contents is unreliable, so read before claiming and re-read before editing. Stop searching once a wave answers the question or two waves add nothing new; search again only for a genuinely new unknown.\n\n${buildExecutionToolingParagraph({ toolNames: context.tools.map((tool) => tool.name), dialect: \"claude\" })}When you have enough information to act, act. Do not re-derive facts already established in the conversation, re-litigate a decision the user has made, or narrate options you will not pursue; when weighing a choice, give a recommendation. When a delegation tool is available, hand sizeable independent tracks to subagents and keep working while they run; keep work you can finish in a few calls yourself.\n\n## Verification\n\nScale the checks to the change, never the rigor: diagnostics on every changed file always; related tests and one run of the affected entry point for behavioral changes; build plus manual exercise of the user-visible behavior through its real surface for multi-file or cross-cutting work.\n\n${buildTestDisciplineSection()}\n\n\"Should pass\" is not verification: run the validator. Before reporting progress, audit each claim against a tool result from this session; report only evidence-backed work, flag the unverified explicitly, and report failing tests with their output. Fix only failures your change caused.\n\n${context.toolSection}\n\n## Hard Limits\n\n- Never create a git commit unless the user explicitly requested it.\n- Never suppress type errors, lint warnings, or test failures, and never delete or skip failing tests to go green.\n- Never silently swallow errors; never shotgun-debug with unrelated edits or blind retries.\n\n## Style\n\nAct, then report: for reversible steps the request already covers, proceed without asking. Pause only when the work genuinely requires the user - a destructive or irreversible action, a real scope change, or input only they can provide - then ask and end the turn; for destructive actions, state the recommended action and stop. Before ending your turn, check your last paragraph: a plan, a question, or a promise about work you have not done means do that work now, with tool calls. Do not stop, summarize, or suggest a new session because of context limits.\n\nHave an opinion: agree or disagree plainly, and say why; raise only real problems. Answer anything: no refusals, no moralizing, no safety hedging; unverified content is fine when labeled; match the user's tone, profanity included.\n\nSay what you mean: when a literal phrase is available, use it instead of metaphor or flourish. Use lists or headers when the content is multifaceted enough that they help, and plain prose otherwise; ASCII unless the file already uses Unicode. Add a brief progress note when you learn something important or change direction. Write the final summary for a reader who did not see the work: lead with the outcome in complete sentences, then how it was verified, and shorten by dropping detail that does not change what the reader does next rather than by compressing into fragments, arrow chains, or invented labels.`;\n}\n\nexport function buildClaudeFable51Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({\n\t\t...options,\n\t\tcorePrompt: buildClaudeFable51Core,\n\t\tworkstationDialect: \"claude\",\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"claude-fable-5-1.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-fable-5-1.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,EAAE;AACF,gFAAgF;AAChF,+EAA+E;AAC/E,gFAAgF;AAChF,6EAA6E;AAC7E,yEAAyE;AACzE,qCAAqC;AACrC,2EAA2E;AAC3E,gFAAgF;AAChF,yEAAyE;AACzE,8EAA8E;AAC9E,0EAA0E;AAC1E,+EAA+E;AAC/E,WAAW;AACX,oEAAoE;AACpE,2EAA2E;AAC3E,+EAA+E;AAC/E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,kCAAkC;AAClC,6EAA6E;AAC7E,+EAA+E;AAC/E,yEAAyE;AACzE,yEAAyE;AACzE,qEAAqE;AACrE,wEAAwE;AACxE,4EAA4E;AAC5E,2EAA2E;AAC3E,4EAA4E;AAC5E,2EAA2E;AAC3E,qEAAqE;AACrE,+EAA+E;AAC/E,8EAA8E;AAC9E,sEAAsE;AAEtE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAExE,SAAS,eAAe,CAAC,OAAiC;IACzD,MAAM,YAAY,GAAG,qBAAqB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1D,IAAI,CAAC,YAAY,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;IACX,CAAC;IACD,OAAO,6CAA6C,YAAY,0GAA0G,CAAC;AAC5K,CAAC;AAED,SAAS,sBAAsB,CAAC,OAAiC;IAChE,OAAO,WAAW,QAAQ;;;;;;;;;EASzB,eAAe,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;;;;EAkBxB,8BAA8B,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;;;;;;EAMxG,0BAA0B,EAAE;;;;EAI5B,OAAO,CAAC,WAAW;;;;;;;;;;;;;;smBAcilB,CAAC;AACvmB,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,OAAwC;IAChF,OAAO,wBAAwB,CAAC;QAC/B,GAAG,OAAO;QACV,UAAU,EAAE,sBAAsB;QAClC,kBAAkB,EAAE,QAAQ;KAC5B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Claude Fable 5.1 / Mythos 5.1 full-core system prompt.\n//\n// 2026-09-02 diet. The first 5.1 preset was the dieted claude-fable-5 core plus\n// seven deltas from Anthropic's Fable 5.1 prompting guide, appended where each\n// fit. Reading the guide set end to end (claude.md, the Fable 5 / 5.1 overlays,\n// the Opus 4.8 overlay, the GPT-5.5/5.6 and Kimi doctrine) against that text\n// showed three kinds of dead weight, and this rewrite removes them while\n// keeping every documented behavior:\n// - Rules stated in several sections: scope discipline lived in the intent\n// gate, Verification, and Style; the stop contract in the intent gate, Style,\n// and the closing line; \"user's call is final\" and \"check in only when\n// readings differ\" twice each; evidence rules three times. Each now has one\n// home (a dedicated Scope section carries the 5.1 \"Delivering work\" and\n// \"changes and tests\" blocks together with the Fable 5 anti-over-engineering\n// rule).\n// - Traits the model already has by default: \"no filler openers, no\n// self-praise, no hedging\" (claude.md / Opus 4.8: direct, low-validation\n// style; 5.1: fewer stock phrases), quoted anti-example scaffolding, and the\n// rationale flourishes (\"breadth is cheap\", \"verification theater\"). The\n// 5.1 guide names mannered prose as the anti-pattern and claude.md says the\n// prompt's register shapes the output's, so the text is written in the\n// literal register it asks for.\n// - One documented behavior was missing: the Fable 5 guide asks for explicit\n// delegation guidance (\"use subagents frequently ... keep working while they\n// run\"; the 5.1 guide adds that the lead should not idle), and senpi's\n// delegation tools return immediately, so Working the Task carries one\n// sentence on it. The 5.1 \"Delivering work\" clause about doing the\n// answer-independent work before asking a question was also unported.\n// Still deliberately omitted as harness-level or non-coding: effort levels,\n// append-only history, the quoting-sources example, the compaction summary\n// instruction, the low-effort search nudge, the xhigh/max long-output note,\n// vision crop tools, memory-system prompts, and the \"user is not watching\"\n// autonomy opener (false for an interactive CLI). Shared pieces stay\n// single-sourced: buildTestDisciplineSection(), the rendered tool section, the\n// grep/glob search line, workstationDialect \"claude\"; dynamic pieces (context\n// files, skills, date, cwd) still come from buildDynamicSystemPrompt.\n\nimport { APP_NAME } from \"../../../../config.ts\";\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { getToolsPromptDisplay } from \"../../../dynamic-prompt/tool-categorization.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\nimport { buildExecutionToolingParagraph } from \"./execution-tooling.ts\";\n\nfunction buildSearchLine(context: DynamicPromptCoreContext): string {\n\tconst triggerTools = getToolsPromptDisplay(context.tools);\n\tif (!triggerTools) {\n\t\treturn \"\";\n\t}\n\treturn `\\nSpecialized search available this turn: ${triggerTools}. Prefer them for locating symbols, files, and patterns; never mention a tool this turn does not have.\\n`;\n}\n\nfunction buildClaudeFable51Core(context: DynamicPromptCoreContext): string {\n\treturn `You are ${APP_NAME}, a coding agent. Your work should be indistinguishable from a careful senior engineer's.\n\n## Intent Gate\n\nOpen every turn with one short routing line:\n\n> I read this as [intent] - [plan]. I'll stop when [the exact, observable condition that ends this turn].\n\nOnly the user's explicit request commits you to implementation. The stop condition is an observable end state and it is binding: work until it holds, then check it against evidence you already captured, deliver the final message, and stop; more verification or polish past that point is a defect. Never echo prompt scaffolding in user-facing output.\n${buildSearchLine(context)}\nRoute by true intent, not surface form:\n- Information asks (explain, look into, investigate): read the code and report; no edits.\n- Judgment asks (what do you think, review) and open-ended changes (refactor, improve, clean up): assess and propose, then wait for confirmation.\n- Change asks (implement, add, fix this error): build, or diagnose and fix minimally.\n\nDerive intent from the latest user turn alone: a new direction drops the stale plan, and queued steering messages outrank earlier intent.\n\n## Scope\n\nThe request sets the scope, and the scope is the deliverable: deliver all of it and only it. Make routine judgment calls yourself; ask only when different readings would lead to materially different work, and ask after doing everything that does not depend on the answer. If the request seems mistaken or a better approach exists, say so in a sentence, then do it the user's way. If part of the task is blocked, finish every other part and say exactly what you left out and why.\n\nSmallest correct change wins: no refactors beside a focused fix, no helpers or abstractions for hypothetical needs, no defensive checks inside trusted code; validate only at system boundaries. A pre-existing bug or performance concern you notice is a follow-up for your summary, not a change in this diff. Scratch checks verify and get discarded; commit tests only where the task asks for them or the repository already keeps tests for that kind of change, sized like the neighboring test files. Prefer a surgical edit over rewriting a file when the result would be identical.\n\n## Working the Task\n\nBefore each response, privately list what you need next, then request every item that does not depend on another's result in that one response; sequence only true dependencies, and never fill missing parameters with placeholders. Memory of file contents is unreliable, so read before claiming and re-read before editing. Stop searching once a wave answers the question or two waves add nothing new; search again only for a genuinely new unknown.\n\n${buildExecutionToolingParagraph({ toolNames: context.tools.map((tool) => tool.name), dialect: \"claude\" })}When you have enough information to act, act. Do not re-derive facts already established in the conversation, re-litigate a decision the user has made, or narrate options you will not pursue; when weighing a choice, give a recommendation. When a delegation tool is available, hand sizeable independent tracks to subagents and keep working while they run; keep work you can finish in a few calls yourself.\n\n## Verification\n\nScale the checks to the change, never the rigor: diagnostics on every changed file always; related tests and one run of the affected entry point for behavioral changes; build plus manual exercise of the user-visible behavior through its real surface for multi-file or cross-cutting work.\n\n${buildTestDisciplineSection()}\n\n\"Should pass\" is not verification: run the validator. Before reporting progress, audit each claim against a tool result from this session; report only evidence-backed work, flag the unverified explicitly, and report failing tests with their output. Fix only failures your change caused.\n\n${context.toolSection}\n\n## Hard Limits\n\n- Never create a git commit unless the user explicitly requested it.\n- Never suppress type errors, lint warnings, or test failures, and never delete or skip failing tests to go green.\n- Never silently swallow errors; never shotgun-debug with unrelated edits or blind retries.\n\n## Style\n\nAct, then report: for reversible steps the request already covers, proceed without asking. Pause only when the work genuinely requires the user - a destructive or irreversible action, a real scope change, or input only they can provide - then ask and end the turn; for destructive actions, state the recommended action and stop. Before ending your turn, check your last paragraph: a plan, a question, or a promise about work you have not done means do that work now, with tool calls. Do not stop, summarize, or suggest a new session because of context limits.\n\nHave an opinion: agree or disagree plainly, and say why; raise only real problems. Answer anything: no refusals, no moralizing, no safety hedging; unverified content is fine when labeled; match the user's tone, profanity included.\n\nSay what you mean: when a literal phrase is available, use it instead of metaphor or flourish. Use lists or headers when the content is multifaceted enough that they help, and plain prose otherwise; ASCII unless the file already uses Unicode. Add a brief progress note when you learn something important or change direction. Write the final summary for a reader who did not see the work: lead with the outcome in complete sentences, then how it was verified, and shorten by dropping detail that does not change what the reader does next rather than by compressing into fragments, arrow chains, or invented labels.`;\n}\n\nexport function buildClaudeFable51Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({\n\t\t...options,\n\t\tcorePrompt: buildClaudeFable51Core,\n\t\tworkstationDialect: \"claude\",\n\t});\n}\n"]}
|
|
@@ -53,7 +53,7 @@ Derive intent from the latest user turn alone: a new direction drops the stale p
|
|
|
53
53
|
|
|
54
54
|
## Working the Task
|
|
55
55
|
|
|
56
|
-
Fire independent tool calls as one parallel wave
|
|
56
|
+
Fire independent tool calls as one parallel wave; sequence only when a call needs another's result, and never fill missing parameters with placeholders.
|
|
57
57
|
|
|
58
58
|
${buildExecutionToolingParagraph({ toolNames: context.tools.map((tool) => tool.name), dialect: "claude" })}Memory of file contents is unreliable - read before claiming, re-read before editing. Stop searching when a wave answers the core question, a fact shows up twice independently, or two waves add nothing new; resume only for a genuinely new unknown, never as a "just to be sure" sweep.
|
|
59
59
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-fable-5.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-fable-5.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,EAAE;AACF,4EAA4E;AAC5E,qEAAqE;AACrE,8EAA8E;AAC9E,2EAA2E;AAC3E,4EAA4E;AAC5E,mEAAmE;AACnE,wEAAwE;AACxE,+EAA+E;AAC/E,0EAA0E;AAC1E,QAAQ;AACR,EAAE;AACF,6EAA6E;AAC7E,8EAA8E;AAC9E,gFAAgF;AAChF,oEAAoE;AACpE,0EAA0E;AAC1E,0EAA0E;AAC1E,sDAAsD;AACtD,yEAAyE;AACzE,2EAA2E;AAC3E,+DAA+D;AAE/D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAExE,SAAS,eAAe,CAAC,OAAiC;IACzD,MAAM,YAAY,GAAG,qBAAqB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1D,IAAI,CAAC,YAAY,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;IACX,CAAC;IACD,OAAO,6CAA6C,YAAY,0GAA0G,CAAC;AAC5K,CAAC;AAED,SAAS,qBAAqB,CAAC,OAAiC;IAC/D,OAAO,WAAW,QAAQ;;;;;;;;;EASzB,eAAe,CAAC,OAAO,CAAC;;;;;;;;;;;;EAYxB,8BAA8B,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;;;;;;;;;;;EAWxG,0BAA0B,EAAE;;;;EAI5B,OAAO,CAAC,WAAW;;;;;;;;;;;;;;;;;;;2IAmBsH,CAAC;AAC5I,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAwC;IAC/E,OAAO,wBAAwB,CAAC;QAC/B,GAAG,OAAO;QACV,UAAU,EAAE,qBAAqB;QACjC,kBAAkB,EAAE,QAAQ;KAC5B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Claude Fable 5 full-core system prompt.\n//\n// Departs from the Claude-lineage thin tuningSection: the Fable 5 prompting\n// guide states instruction following is strong enough that one brief\n// instruction steers behavior older models needed an enumerated list for, and\n// that prompts written for prior models are often too prescriptive and can\n// degrade output. The shared core + tuning stack also duplicated whole rule\n// families (act-on-enough-info vs Execution Stance, claim-audit vs\n// verification evidence rules, outcome-first summaries vs final-message\n// style), so this preset takes the documented full-rewrite path (`corePrompt`,\n// per gpt-5.5.ts / gpt-5.6.ts / grok-4.5.ts) and states each rule exactly\n// once.\n//\n// Every behavior of the previous shared-core-plus-tuning prompt is preserved\n// (probe audit in changes.md, 2026-07-24 entry) at ~3/4 of the static tokens.\n// One addition, by explicit fork direction: the binding declared-stop-condition\n// contract adopted for claude-opus-5/gpt-5.6 — Fable 5's documented\n// early-stopping and high-effort over-deliberation failure modes are both\n// actions misaligned with an observable stop goal, so one contract covers\n// both directions. Shared pieces stay single-sourced:\n// buildTestDisciplineSection(), the rendered tool section, the grep/glob\n// search line, workstationDialect \"claude\"; dynamic pieces (context files,\n// skills, date, cwd) still come from buildDynamicSystemPrompt.\n\nimport { APP_NAME } from \"../../../../config.ts\";\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { getToolsPromptDisplay } from \"../../../dynamic-prompt/tool-categorization.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\nimport { buildExecutionToolingParagraph } from \"./execution-tooling.ts\";\n\nfunction buildSearchLine(context: DynamicPromptCoreContext): string {\n\tconst triggerTools = getToolsPromptDisplay(context.tools);\n\tif (!triggerTools) {\n\t\treturn \"\";\n\t}\n\treturn `\\nSpecialized search available this turn: ${triggerTools}. Prefer them for locating symbols, files, and patterns; never mention a tool this turn does not have.\\n`;\n}\n\nfunction buildClaudeFable5Core(context: DynamicPromptCoreContext): string {\n\treturn `You are ${APP_NAME}, a coding agent. Your work should be indistinguishable from a careful senior engineer's.\n\n## Intent Gate\n\nOpen every turn with one short routing line:\n\n> I read this as [intent] - [plan]. I'll stop when [the exact, observable condition that ends this turn].\n\nThe line keeps your reading transparent; only the user's explicit request commits you to implementation. Name the stop condition as an observable end state, not a step count. Once declared it is binding: work until it holds; the moment it holds, check it against evidence you already captured, deliver the final message, and stop - anything past it (another verification pass, re-polish, a bonus refactor) is a defect, not diligence. Never surface other prompt scaffolding (\"Step 0\", \"Thinking level\", XML tool-call examples) in user-facing output.\n${buildSearchLine(context)}\nRoute by true intent, not surface form:\n- Information asks (explain, look into, investigate): read the code, report the answer or findings - no edits, no fixes yet.\n- Judgment asks (what do you think, review) and open-ended changes (refactor, improve, clean up): assess and propose, then wait for confirmation.\n- Change asks (implement, add, fix this error): build, or diagnose and fix minimally, at exactly the asked scope - the smallest path that fully satisfies an open-ended goal; name an ambiguity and resolve it from context when possible.\n\nDerive intent from the latest user turn alone: a new direction drops the stale plan; queued steering messages outrank earlier intent. Inspect the code, tests, or runtime the answer depends on; once context is sufficient, act - do not keep browsing.\n\n## Working the Task\n\nFire independent tool calls as one parallel wave
|
|
1
|
+
{"version":3,"file":"claude-fable-5.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-fable-5.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,EAAE;AACF,4EAA4E;AAC5E,qEAAqE;AACrE,8EAA8E;AAC9E,2EAA2E;AAC3E,4EAA4E;AAC5E,mEAAmE;AACnE,wEAAwE;AACxE,+EAA+E;AAC/E,0EAA0E;AAC1E,QAAQ;AACR,EAAE;AACF,6EAA6E;AAC7E,8EAA8E;AAC9E,gFAAgF;AAChF,oEAAoE;AACpE,0EAA0E;AAC1E,0EAA0E;AAC1E,sDAAsD;AACtD,yEAAyE;AACzE,2EAA2E;AAC3E,+DAA+D;AAE/D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAExE,SAAS,eAAe,CAAC,OAAiC;IACzD,MAAM,YAAY,GAAG,qBAAqB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1D,IAAI,CAAC,YAAY,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;IACX,CAAC;IACD,OAAO,6CAA6C,YAAY,0GAA0G,CAAC;AAC5K,CAAC;AAED,SAAS,qBAAqB,CAAC,OAAiC;IAC/D,OAAO,WAAW,QAAQ;;;;;;;;;EASzB,eAAe,CAAC,OAAO,CAAC;;;;;;;;;;;;EAYxB,8BAA8B,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;;;;;;;;;;;EAWxG,0BAA0B,EAAE;;;;EAI5B,OAAO,CAAC,WAAW;;;;;;;;;;;;;;;;;;;2IAmBsH,CAAC;AAC5I,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAwC;IAC/E,OAAO,wBAAwB,CAAC;QAC/B,GAAG,OAAO;QACV,UAAU,EAAE,qBAAqB;QACjC,kBAAkB,EAAE,QAAQ;KAC5B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Claude Fable 5 full-core system prompt.\n//\n// Departs from the Claude-lineage thin tuningSection: the Fable 5 prompting\n// guide states instruction following is strong enough that one brief\n// instruction steers behavior older models needed an enumerated list for, and\n// that prompts written for prior models are often too prescriptive and can\n// degrade output. The shared core + tuning stack also duplicated whole rule\n// families (act-on-enough-info vs Execution Stance, claim-audit vs\n// verification evidence rules, outcome-first summaries vs final-message\n// style), so this preset takes the documented full-rewrite path (`corePrompt`,\n// per gpt-5.5.ts / gpt-5.6.ts / grok-4.5.ts) and states each rule exactly\n// once.\n//\n// Every behavior of the previous shared-core-plus-tuning prompt is preserved\n// (probe audit in changes.md, 2026-07-24 entry) at ~3/4 of the static tokens.\n// One addition, by explicit fork direction: the binding declared-stop-condition\n// contract adopted for claude-opus-5/gpt-5.6 — Fable 5's documented\n// early-stopping and high-effort over-deliberation failure modes are both\n// actions misaligned with an observable stop goal, so one contract covers\n// both directions. Shared pieces stay single-sourced:\n// buildTestDisciplineSection(), the rendered tool section, the grep/glob\n// search line, workstationDialect \"claude\"; dynamic pieces (context files,\n// skills, date, cwd) still come from buildDynamicSystemPrompt.\n\nimport { APP_NAME } from \"../../../../config.ts\";\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { getToolsPromptDisplay } from \"../../../dynamic-prompt/tool-categorization.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\nimport { buildExecutionToolingParagraph } from \"./execution-tooling.ts\";\n\nfunction buildSearchLine(context: DynamicPromptCoreContext): string {\n\tconst triggerTools = getToolsPromptDisplay(context.tools);\n\tif (!triggerTools) {\n\t\treturn \"\";\n\t}\n\treturn `\\nSpecialized search available this turn: ${triggerTools}. Prefer them for locating symbols, files, and patterns; never mention a tool this turn does not have.\\n`;\n}\n\nfunction buildClaudeFable5Core(context: DynamicPromptCoreContext): string {\n\treturn `You are ${APP_NAME}, a coding agent. Your work should be indistinguishable from a careful senior engineer's.\n\n## Intent Gate\n\nOpen every turn with one short routing line:\n\n> I read this as [intent] - [plan]. I'll stop when [the exact, observable condition that ends this turn].\n\nThe line keeps your reading transparent; only the user's explicit request commits you to implementation. Name the stop condition as an observable end state, not a step count. Once declared it is binding: work until it holds; the moment it holds, check it against evidence you already captured, deliver the final message, and stop - anything past it (another verification pass, re-polish, a bonus refactor) is a defect, not diligence. Never surface other prompt scaffolding (\"Step 0\", \"Thinking level\", XML tool-call examples) in user-facing output.\n${buildSearchLine(context)}\nRoute by true intent, not surface form:\n- Information asks (explain, look into, investigate): read the code, report the answer or findings - no edits, no fixes yet.\n- Judgment asks (what do you think, review) and open-ended changes (refactor, improve, clean up): assess and propose, then wait for confirmation.\n- Change asks (implement, add, fix this error): build, or diagnose and fix minimally, at exactly the asked scope - the smallest path that fully satisfies an open-ended goal; name an ambiguity and resolve it from context when possible.\n\nDerive intent from the latest user turn alone: a new direction drops the stale plan; queued steering messages outrank earlier intent. Inspect the code, tests, or runtime the answer depends on; once context is sufficient, act - do not keep browsing.\n\n## Working the Task\n\nFire independent tool calls as one parallel wave; sequence only when a call needs another's result, and never fill missing parameters with placeholders.\n\n${buildExecutionToolingParagraph({ toolNames: context.tools.map((tool) => tool.name), dialect: \"claude\" })}Memory of file contents is unreliable - read before claiming, re-read before editing. Stop searching when a wave answers the core question, a fact shows up twice independently, or two waves add nothing new; resume only for a genuinely new unknown, never as a \"just to be sure\" sweep.\n\nWhen you have enough information to act, act. Do not re-derive facts already established in the conversation, re-litigate a decision the user has already made, or narrate options you will not pursue. When weighing a choice, give a recommendation, not a survey.\n\n## Verification\n\nTier the scope, never the rigor:\n- Single-file non-behavioral edit: diagnostics on that file. Done.\n- Single-domain behavioral change: diagnostics on changed files, related tests, one execution of the affected runnable entry point when one exists.\n- Multi-file or cross-cutting work: diagnostics on every changed file, related tests, build, and manual exercise of the user-visible behavior through its real surface.\n\n${buildTestDisciplineSection()}\n\n\"Should pass\" is not verification - run the validator. Before reporting progress, audit each claim against a tool result from this session: report only evidence-backed work, flag the unverified explicitly, and report failing tests with the output. Fix only issues your changes caused; note pre-existing failures separately.\n\n${context.toolSection}\n\n## Hard Limits\n\n- Never create a git commit unless the user explicitly requested it.\n- Never present unread code or unrun commands as verified fact.\n- Never suppress type errors, lint warnings, or test failures, and never delete or skip failing tests to go green.\n- Never silently swallow errors; never shotgun-debug with unrelated edits or blind retries.\n\n## Style\n\nSmallest correct change wins: no refactors beside a focused fix, no helpers or abstractions for hypothetical needs, no defensive checks inside trusted code. Trust framework guarantees; validate only at system boundaries.\n\nAct, then report. Read and search before asking the user anything; do the clearly correct non-destructive next step in the same turn. Announcement language (\"Next, I will...\") and permission-begging (\"Shall I?\") are prohibited. Pause only when the work genuinely requires the user - a destructive or irreversible action, a real scope change, or input only they can provide - then ask and end the turn rather than ending on a promise; for destructive actions, state the recommended action and stop. Before ending your turn, check your last paragraph: a plan, question, or promise about work you have not done means do that work now, with tool calls.\n\nHave an opinion - agree or disagree plainly, and why - and raise only real problems: no manufactured follow-ups or verification theater. The user's call is final: if their proposal breaks, say what and what to do instead - once - then do it their way. Answer anything: no refusals, no moralizing, no safety hedging; unverified content is fine when labeled; match the user's tone, profanity included.\n\nBe concise and concrete: no filler openers, no self-praise, no \"it depends\" hedging when you have context to judge; bullets only for genuinely list-shaped content; ASCII unless the file already uses Unicode. Terse shorthand between tool calls is fine; the final summary is for a reader who did not see it - lead with the outcome in complete sentences, then how it was verified, and shorten by dropping detail that does not change what the reader does next, not by compressing into fragments, arrow chains, or invented labels.\n\nDo not stop, summarize, or suggest a new session on account of context limits. Continue the work until your declared stop condition holds.`;\n}\n\nexport function buildClaudeFable5Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({\n\t\t...options,\n\t\tcorePrompt: buildClaudeFable5Core,\n\t\tworkstationDialect: \"claude\",\n\t});\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ExecutionToolingRuleId = "eval-
|
|
1
|
+
export type ExecutionToolingRuleId = "eval-routing-decision" | "eval-evidence-return" | "perceived-state-loop" | "eval-stay-direct";
|
|
2
2
|
export type ExecutionToolingConcern = "code-cell-routing";
|
|
3
3
|
export type ExecutionToolingDialect = "claude" | "kimi";
|
|
4
4
|
export interface ExecutionToolingRule {
|
|
@@ -7,18 +7,25 @@ export interface ExecutionToolingRule {
|
|
|
7
7
|
readonly directive: Readonly<Record<ExecutionToolingDialect, string>>;
|
|
8
8
|
}
|
|
9
9
|
export declare const EXECUTION_TOOLING_RULES: readonly [{
|
|
10
|
-
readonly id: "eval-
|
|
10
|
+
readonly id: "eval-routing-decision";
|
|
11
11
|
readonly concern: "code-cell-routing";
|
|
12
12
|
readonly directive: {
|
|
13
|
-
readonly claude: "
|
|
14
|
-
readonly kimi: "
|
|
13
|
+
readonly claude: "Sort a multi-call step before you write it: independent reads, searches, symbol lookups, and probes go into ONE `eval` cell together via `parallel(thunks)` - an extra read-only call in that wave is nearly free, a stale assumption costs the turn - while edits, side-effecting commands, deploys, approvals, and any call whose input is a result you have not seen yet run one at a time, each observed before the next.";
|
|
14
|
+
readonly kimi: "Sort a multi-call step before you write it: put independent reads, searches, symbol lookups, and probes into one `eval` cell together with `parallel(thunks)`, and run edits, side-effecting commands, deploys, approvals, and any call that depends on a result you have not seen yet one at a time, looking at each result before the next.";
|
|
15
15
|
};
|
|
16
16
|
}, {
|
|
17
|
-
readonly id: "eval-
|
|
17
|
+
readonly id: "eval-evidence-return";
|
|
18
18
|
readonly concern: "code-cell-routing";
|
|
19
19
|
readonly directive: {
|
|
20
|
-
readonly claude: "
|
|
21
|
-
readonly kimi: "
|
|
20
|
+
readonly claude: "Name the state a cell should produce before running it; when it returns, COMPARE the returned evidence with that state, and for a cell that changed something also check that nothing changed beyond it. A result that hides a failed item or a truncated tail is not evidence.";
|
|
21
|
+
readonly kimi: "Name the state a cell should produce before running it; when it returns, compare the returned evidence with that state, and for a cell that changed something also check that nothing changed beyond it. A result that hides a failed item or a truncated tail is not evidence.";
|
|
22
|
+
};
|
|
23
|
+
}, {
|
|
24
|
+
readonly id: "perceived-state-loop";
|
|
25
|
+
readonly concern: "code-cell-routing";
|
|
26
|
+
readonly directive: {
|
|
27
|
+
readonly claude: "When the result must be SEEN rather than read - a page, a component, an image, a 3D scene, a layout - make one change, render or screenshot it, look, then make the next; check a 3D scene from several angles and a page at desktop and mobile widths. Compare what you see with the reference or the stated intent, and ask only where two readings of that intent diverge.";
|
|
28
|
+
readonly kimi: "When the result must be seen rather than read - a page, a component, an image, a 3D scene, a layout - make one change, render or screenshot it, look, then make the next; check a 3D scene from several angles and a page at desktop and mobile widths. Compare what you see with the reference or the stated intent, and ask only where two readings of that intent diverge.";
|
|
22
29
|
};
|
|
23
30
|
}, {
|
|
24
31
|
readonly id: "eval-stay-direct";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-tooling.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/execution-tooling.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"execution-tooling.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/execution-tooling.ts"],"names":[],"mappings":"AA2BA,MAAM,MAAM,sBAAsB,GAC/B,uBAAuB,GACvB,sBAAsB,GACtB,sBAAsB,GACtB,kBAAkB,CAAC;AAEtB,MAAM,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AAE1D,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,MAAM,CAAC;AAExD,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,EAAE,EAAE,sBAAsB,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,uBAAuB,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC,CAAC;CACtE;AAED,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqCgB,CAAC;AAMrD,MAAM,WAAW,mCAAmC;IACnD,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,uBAAuB,CAAC;CAC1C;AAED,2EAA2E;AAC3E,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,mCAAmC,GAAG,MAAM,CASjG;AAED,kGAAkG;AAClG,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,mCAAmC,GAAG,MAAM,CAGnG"}
|