@bastani/atomic 0.9.74 → 0.9.75
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 +136 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +21 -0
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/subagents/skills/agent-browser/SKILL.md +8 -10
- package/dist/builtin/subagents/skills/agent-desktop/SKILL.md +9 -5
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +7 -1
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +64 -0
- package/dist/builtin/workflows/README.md +5 -2
- package/dist/builtin/workflows/builtin/{chunk-m8eg152f.js → chunk-89we7r4p.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-a4fdm2cw.js → chunk-8yfssw01.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-774myqzs.js → chunk-v8mb0005.js} +366 -45
- package/dist/builtin/workflows/builtin/{chunk-d5cxskkp.js → chunk-wh2p4qjg.js} +2 -2
- package/dist/builtin/workflows/builtin/goal.js +2 -2
- package/dist/builtin/workflows/builtin/index.d.ts +10 -0
- package/dist/builtin/workflows/builtin/index.js +4 -4
- package/dist/builtin/workflows/builtin/open-claude-design.d.ts +12 -0
- package/dist/builtin/workflows/builtin/open-claude-design.js +1 -1
- package/dist/builtin/workflows/builtin/ralph.js +2 -2
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/impeccable/SKILL.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/android.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/audit.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/documenter.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/manual-edit-applier.md +3 -2
- package/dist/builtin/workflows/skills/impeccable/reference/distill.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/doctor.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/document.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/harden.md +19 -0
- package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +15 -8
- package/dist/builtin/workflows/skills/impeccable/reference/init.md +2 -0
- package/dist/builtin/workflows/skills/impeccable/reference/live.md +8 -6
- package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/optimize.md +0 -1
- package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/VERSION +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/command-metadata.json +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/engine-checksums.txt +9 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/impeccable +98 -44
- package/dist/builtin/workflows/skills/impeccable/scripts/impeccable.cmd +101 -34
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-ignores.js +6 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-session.js +4 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +444 -144
- package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +3 -1
- package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5.md +13 -11
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_1.md +10 -8
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_2.md +143 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_haiku_5_5.md +11 -7
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_4_8.md +3 -3
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5.md +6 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5_5.md +7 -7
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5_5.md +3 -3
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_5.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_6.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6.md +6 -5
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_sol.md +4 -4
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_terra.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +4 -3
- package/dist/builtin/workflows/skills/skill-creator/scripts/aggregate_benchmark.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/generate_report.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/improve_description.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/package_skill.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/quick_validate.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/run_eval.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/run_loop.py +0 -0
- package/dist/builtin/workflows/skills/unslop/SKILL.md +15 -34
- package/dist/builtin/workflows/src/durable/journal/memory-run-journal.d.ts +1 -0
- package/dist/builtin/workflows/src/durable/journal/values.d.ts +2 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +809 -410
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +695 -305
- package/dist/builtin/workflows/src/index.js +685 -295
- package/dist/builtin/workflows/src/local-worker-entry.mjs +695 -305
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +6 -6
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +2 -2
- package/dist/builtin/workflows/src/shared/serializable-error-families.d.ts +2 -0
- package/dist/bun/app-host-modules.d.ts +1 -1
- package/dist/bun/app-host-modules.d.ts.map +1 -1
- package/dist/bun/app-host-modules.js.map +1 -1
- package/dist/bun/internal-workflow-worker.d.ts +2 -0
- package/dist/bun/internal-workflow-worker.d.ts.map +1 -1
- package/dist/bun/internal-workflow-worker.js +2 -1
- package/dist/bun/internal-workflow-worker.js.map +1 -1
- package/dist/codemode-worker.js +2 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +14 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +2 -1
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-blueprint-environment.d.ts +10 -0
- package/dist/core/agent-session-blueprint-environment.d.ts.map +1 -0
- package/dist/core/agent-session-blueprint-environment.js +28 -0
- package/dist/core/agent-session-blueprint-environment.js.map +1 -0
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +2 -0
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +1 -0
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +14 -4
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +20 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +55 -6
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +2 -1
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/async-scope.d.ts +13 -0
- package/dist/core/async-scope.d.ts.map +1 -0
- package/dist/core/async-scope.js +20 -0
- package/dist/core/async-scope.js.map +1 -0
- package/dist/core/cache-warmer.d.ts +3 -14
- package/dist/core/cache-warmer.d.ts.map +1 -1
- package/dist/core/cache-warmer.js +8 -60
- package/dist/core/cache-warmer.js.map +1 -1
- package/dist/core/extensions/extension-work.js +2 -2
- package/dist/core/extensions/extension-work.js.map +1 -1
- package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-host-modules.js +3 -1
- package/dist/core/extensions/loader-host-modules.js.map +1 -1
- package/dist/core/extensions/ui-types.d.ts +2 -1
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/extensions/workflow-events.d.ts +1 -1
- package/dist/core/extensions/workflow-events.d.ts.map +1 -1
- package/dist/core/extensions/workflow-events.js.map +1 -1
- package/dist/core/extensions/workflow-run-control.d.ts +4 -2
- package/dist/core/extensions/workflow-run-control.d.ts.map +1 -1
- package/dist/core/extensions/workflow-run-control.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts +6 -0
- package/dist/core/model-fallback-failures.d.ts.map +1 -1
- package/dist/core/model-fallback-failures.js +10 -1
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/preferred-providers.d.ts +19 -0
- package/dist/core/preferred-providers.d.ts.map +1 -0
- package/dist/core/preferred-providers.js +25 -0
- package/dist/core/preferred-providers.js.map +1 -0
- package/dist/core/provider-alias.d.ts.map +1 -1
- package/dist/core/provider-alias.js +4 -0
- package/dist/core/provider-alias.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +1 -0
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +3 -0
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resume/blueprint/action-expressions.d.ts +32 -0
- package/dist/core/resume/blueprint/action-expressions.d.ts.map +1 -0
- package/dist/core/resume/blueprint/action-expressions.js +389 -0
- package/dist/core/resume/blueprint/action-expressions.js.map +1 -0
- package/dist/core/resume/blueprint/actions.d.ts +90 -0
- package/dist/core/resume/blueprint/actions.d.ts.map +1 -0
- package/dist/core/resume/blueprint/actions.js +818 -0
- package/dist/core/resume/blueprint/actions.js.map +1 -0
- package/dist/core/resume/blueprint/build.d.ts +102 -0
- package/dist/core/resume/blueprint/build.d.ts.map +1 -0
- package/dist/core/resume/blueprint/build.js +535 -0
- package/dist/core/resume/blueprint/build.js.map +1 -0
- package/dist/core/resume/blueprint/context.d.ts +11 -0
- package/dist/core/resume/blueprint/context.d.ts.map +1 -0
- package/dist/core/resume/blueprint/context.js +106 -0
- package/dist/core/resume/blueprint/context.js.map +1 -0
- package/dist/core/resume/blueprint/envrc.d.ts +19 -0
- package/dist/core/resume/blueprint/envrc.d.ts.map +1 -0
- package/dist/core/resume/blueprint/envrc.js +77 -0
- package/dist/core/resume/blueprint/envrc.js.map +1 -0
- package/dist/core/resume/blueprint/errors.d.ts +179 -0
- package/dist/core/resume/blueprint/errors.d.ts.map +1 -0
- package/dist/core/resume/blueprint/errors.js +169 -0
- package/dist/core/resume/blueprint/errors.js.map +1 -0
- package/dist/core/resume/blueprint/ledger.d.ts +51 -0
- package/dist/core/resume/blueprint/ledger.d.ts.map +1 -0
- package/dist/core/resume/blueprint/ledger.js +119 -0
- package/dist/core/resume/blueprint/ledger.js.map +1 -0
- package/dist/core/resume/blueprint/notices.d.ts +14 -0
- package/dist/core/resume/blueprint/notices.d.ts.map +1 -0
- package/dist/core/resume/blueprint/notices.js +44 -0
- package/dist/core/resume/blueprint/notices.js.map +1 -0
- package/dist/core/resume/blueprint/process.d.ts +44 -0
- package/dist/core/resume/blueprint/process.d.ts.map +1 -0
- package/dist/core/resume/blueprint/process.js +142 -0
- package/dist/core/resume/blueprint/process.js.map +1 -0
- package/dist/core/resume/blueprint/resume.d.ts +73 -0
- package/dist/core/resume/blueprint/resume.d.ts.map +1 -0
- package/dist/core/resume/blueprint/resume.js +206 -0
- package/dist/core/resume/blueprint/resume.js.map +1 -0
- package/dist/core/resume/blueprint/schema.d.ts +26 -0
- package/dist/core/resume/blueprint/schema.d.ts.map +1 -0
- package/dist/core/resume/blueprint/schema.js +243 -0
- package/dist/core/resume/blueprint/schema.js.map +1 -0
- package/dist/core/resume/blueprint/steps.d.ts +54 -0
- package/dist/core/resume/blueprint/steps.d.ts.map +1 -0
- package/dist/core/resume/blueprint/steps.js +155 -0
- package/dist/core/resume/blueprint/steps.js.map +1 -0
- package/dist/core/resume/blueprint/types.d.ts +63 -0
- package/dist/core/resume/blueprint/types.d.ts.map +1 -0
- package/dist/core/resume/blueprint/types.js +2 -0
- package/dist/core/resume/blueprint/types.js.map +1 -0
- package/dist/core/resume/errors.d.ts +7 -35
- package/dist/core/resume/errors.d.ts.map +1 -1
- package/dist/core/resume/errors.js +1 -21
- package/dist/core/resume/errors.js.map +1 -1
- package/dist/core/resume/index.d.ts +12 -4
- package/dist/core/resume/index.d.ts.map +1 -1
- package/dist/core/resume/index.js +11 -4
- package/dist/core/resume/index.js.map +1 -1
- package/dist/core/resume/run-setup.d.ts +36 -15
- package/dist/core/resume/run-setup.d.ts.map +1 -1
- package/dist/core/resume/run-setup.js +70 -54
- package/dist/core/resume/run-setup.js.map +1 -1
- package/dist/core/resume/session-resume.d.ts +34 -20
- package/dist/core/resume/session-resume.d.ts.map +1 -1
- package/dist/core/resume/session-resume.js +244 -106
- package/dist/core/resume/session-resume.js.map +1 -1
- package/dist/core/retry-policy.d.ts +19 -1
- package/dist/core/retry-policy.d.ts.map +1 -1
- package/dist/core/retry-policy.js +26 -1
- package/dist/core/retry-policy.js.map +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-cwd.d.ts +56 -1
- package/dist/core/session-cwd.d.ts.map +1 -1
- package/dist/core/session-cwd.js +94 -4
- package/dist/core/session-cwd.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +1 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +10 -5
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-worktree-snapshots.d.ts +11 -0
- package/dist/core/session-worktree-snapshots.d.ts.map +1 -1
- package/dist/core/session-worktree-snapshots.js +10 -4
- package/dist/core/session-worktree-snapshots.js.map +1 -1
- package/dist/core/settings-defaults.d.ts +1 -1
- package/dist/core/settings-defaults.d.ts.map +1 -1
- package/dist/core/settings-defaults.js +1 -1
- package/dist/core/settings-defaults.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +3 -2
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +2 -1
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +4 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/storage/write-ahead-log.d.ts +2 -1
- package/dist/core/storage/write-ahead-log.d.ts.map +1 -1
- package/dist/core/storage/write-ahead-log.js +27 -6
- package/dist/core/storage/write-ahead-log.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +10 -0
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/file-tool-errors.d.ts +1 -1
- package/dist/core/tools/file-tool-errors.js +1 -1
- package/dist/core/tools/file-tool-errors.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +52 -26
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +2 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/powershell.js +10 -2
- package/dist/core/tools/powershell.js.map +1 -1
- package/dist/core/tools/tool-concurrency.d.ts.map +1 -1
- package/dist/core/tools/tool-concurrency.js +2 -2
- package/dist/core/tools/tool-concurrency.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/main-session.d.ts +12 -4
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +28 -4
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +6 -8
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +5 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +6 -1
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +10 -3
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +34 -13
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/provider-brand.d.ts +16 -0
- package/dist/modes/interactive/components/provider-brand.d.ts.map +1 -0
- package/dist/modes/interactive/components/provider-brand.js +67 -0
- package/dist/modes/interactive/components/provider-brand.js.map +1 -0
- package/dist/modes/interactive/interactive-auth-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-auth-routing.js +8 -6
- package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js +4 -3
- package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +8 -3
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +12 -2
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +59 -21
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +23 -12
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/login-provider-options.d.ts.map +1 -1
- package/dist/modes/interactive/login-provider-options.js +2 -1
- package/dist/modes/interactive/login-provider-options.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +2 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +8 -3
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +2 -1
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +0 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +2 -18
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +8 -2
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-error-decoding.d.ts +7 -0
- package/dist/modes/rpc/rpc-error-decoding.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-error-decoding.js +25 -0
- package/dist/modes/rpc/rpc-error-decoding.js.map +1 -0
- package/dist/modes/rpc/rpc-responses.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-responses.js +12 -0
- package/dist/modes/rpc/rpc-responses.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +11 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +12 -3
- package/dist/package-manager-cli.js.map +1 -1
- package/docs/background-tasks.md +1 -1
- package/docs/codemode.md +22 -0
- package/docs/extensions/api-reference.md +27 -1
- package/docs/extensions/authoring.md +1 -1
- package/docs/extensions/ui.md +1 -1
- package/docs/getting-started/first-session.md +1 -1
- package/docs/guides/resume-on-any-machine.md +72 -19
- package/docs/models/evals.md +85 -17
- package/docs/models/reference.md +1 -1
- package/docs/providers.md +38 -5
- package/docs/reference/cli.md +2 -0
- package/docs/rpc/protocol.md +11 -1
- package/docs/sdk/reference.md +36 -4
- package/docs/sdk.md +2 -2
- package/docs/sessions.md +11 -1
- package/docs/settings.md +7 -2
- package/docs/skills.md +3 -3
- package/docs/storage.md +1 -1
- package/docs/tools.md +3 -1
- package/docs/workflows/api-reference.md +14 -12
- package/docs/workflows/authoring.md +29 -1
- package/docs/workflows/builtins.md +9 -1
- package/docs/workflows/operations.md +8 -8
- package/docs/worktree-snapshots.md +3 -2
- package/npm-shrinkwrap.json +83 -67
- package/package.json +7 -7
- package/schemas/settings.schema.json +3 -2
- package/dist/core/resume/setup-hook.d.ts +0 -69
- package/dist/core/resume/setup-hook.d.ts.map +0 -1
- package/dist/core/resume/setup-hook.js +0 -261
- package/dist/core/resume/setup-hook.js.map +0 -1
|
@@ -2,16 +2,18 @@ import { existsSync } from "node:fs";
|
|
|
2
2
|
import { stat } from "node:fs/promises";
|
|
3
3
|
import { join, relative, resolve } from "node:path";
|
|
4
4
|
import { isGitUnavailableError } from "../../utils/git-errors.js";
|
|
5
|
-
import { currentWorktreeSnapshots, mapRestoredPath,
|
|
5
|
+
import { currentWorktreeSnapshots, mapRestoredPath, openResumedSession, resumeSessionWorktree, } from "../session-worktree-snapshots.js";
|
|
6
6
|
import { ProjectTrustStore } from "../trust-manager.js";
|
|
7
7
|
import { locateCheckout, readRepositoryConfig } from "../worktree-snapshot/capture.js";
|
|
8
|
-
import { isWorkspaceDriftError, isWorkspaceSnapshotError } from "../worktree-snapshot/errors.js";
|
|
8
|
+
import { isWorkspaceConfigError, isWorkspaceDriftError, isWorkspaceSnapshotError, } from "../worktree-snapshot/errors.js";
|
|
9
9
|
import { gitText, runGit } from "../worktree-snapshot/git.js";
|
|
10
10
|
import { isHeadOnlyAdvance } from "../worktree-snapshot/head-advance.js";
|
|
11
11
|
import { defaultWorktreeSnapshotStoreDir, verifyWorktree, } from "../worktree-snapshot/restore.js";
|
|
12
|
+
import { checkoutsNeedingRebuild, enclosingRepositoryRoot, inheritedRemotes, recordBlueprintContext, setUpResumedBlueprints, } from "./blueprint/resume.js";
|
|
13
|
+
import { isResumePreconditionError, ResumePreconditionError } from "./errors.js";
|
|
14
|
+
import { isResumeFailure } from "./failure.js";
|
|
12
15
|
import { isInside } from "./path-mapping.js";
|
|
13
|
-
import {
|
|
14
|
-
import { ensureResumeSetup, predictedSetupProblem, readResumeSetupLedger, reserveResumeSetup, } from "./setup-hook.js";
|
|
16
|
+
import { defaultResumePreflightIo, gitUnavailableProblem } from "./preflight.js";
|
|
15
17
|
async function isDirectory(path) {
|
|
16
18
|
try {
|
|
17
19
|
return (await stat(path)).isDirectory();
|
|
@@ -106,18 +108,22 @@ async function hasLocalChanges(root, signal) {
|
|
|
106
108
|
* Gets a resumed session's checkouts ready on this node before its runtime starts, and returns the session opened
|
|
107
109
|
* where it continues. When the checkout the session works in is missing or changed here, a checkout of the same
|
|
108
110
|
* repository the resume started in is used as-is if it matches (and, if it differs, only when the user chooses it).
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
111
|
+
* The checkout the session works in is the only one the resume cannot go without: when it must be restored, the
|
|
112
|
+
* precondition of restoring the recorded checkouts, that Git can run, is checked first, and an unmet one refuses the
|
|
113
|
+
* resume before anything is written. Every other checkout the session recorded that is gone or changed here, except
|
|
114
|
+
* those in `keepInPlace`, never blocks the resume: one the session worked in on this node, changed since, continues as
|
|
115
|
+
* it is; the rest are restored into fresh worktrees one by one by #4245's {@link resumeSessionWorktree}, and one that
|
|
116
|
+
* cannot be (Git is unavailable, or its restore fails) is left out with a warning that names its path and why. Each
|
|
117
|
+
* worktree Atomic restored then gets its blueprints built (#4588): a failing step is a warning in `notices` and never
|
|
118
|
+
* stops the resume. The agent gets the blueprints' maintenance and knowledge in the session's next turn. The session's
|
|
119
|
+
* tools resolve paths under every root it recorded into the place that root was restored.
|
|
115
120
|
*/
|
|
116
121
|
export async function prepareSessionResume(sessionManager, options) {
|
|
117
122
|
const io = options.io ?? defaultResumePreflightIo;
|
|
118
123
|
const storeDir = resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());
|
|
119
124
|
if (!options.settings.enabled || sessionManager.getLatestWorktreeSnapshots().size === 0) {
|
|
120
|
-
|
|
125
|
+
const unchanged = await describeBlueprintsInPlace(sessionManager, storeDir, options);
|
|
126
|
+
return { status: "ready", sessionManager, notices: [], blueprintNotices: [], blueprintContext: unchanged };
|
|
121
127
|
}
|
|
122
128
|
const notices = [];
|
|
123
129
|
const match = latestSessionSnapshot(sessionManager);
|
|
@@ -132,51 +138,102 @@ export async function prepareSessionResume(sessionManager, options) {
|
|
|
132
138
|
return { status: "cancelled" };
|
|
133
139
|
if (reuse?.kind === "reused" && !reuse.matches) {
|
|
134
140
|
await recordReuse(sessionManager, reuse.mapping);
|
|
135
|
-
return continueInChosenCheckout(sessionManager, reuse, options);
|
|
141
|
+
return continueInChosenCheckout(sessionManager, reuse, storeDir, options);
|
|
136
142
|
}
|
|
137
143
|
if (reuse?.kind === "reused") {
|
|
138
144
|
reused = reuse.mapping;
|
|
139
145
|
notices.push(reuse.notice);
|
|
140
146
|
}
|
|
141
147
|
}
|
|
142
|
-
const
|
|
143
|
-
|
|
148
|
+
const checkouts = withMapping(sessionManager, reused);
|
|
149
|
+
const candidates = await restoreCandidates(checkouts, mapRestoredPath(sessionManager.getCwd(), checkouts.getWorktreeRootMappings()), options);
|
|
150
|
+
if (candidates.targets.length > 0)
|
|
144
151
|
git ??= { unavailable: await io.probeGit(options.signal) };
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const snapshots = sessionManager.getWorktreeSnapshotRecords();
|
|
152
|
+
const plan = planRestores(sessionManager, candidates, options, git?.unavailable);
|
|
153
|
+
notices.push(...plan.left.values());
|
|
148
154
|
const recordedBefore = sessionManager.getWorktreeRootMappings().length;
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
155
|
+
const resumed = await restorePlanned(sessionManager, plan, reused, storeDir, options);
|
|
156
|
+
const cwd = mapRestoredPath(sessionManager.getCwd(), sessionManager.getWorktreeRootMappings());
|
|
157
|
+
const opened = await openResumedSession(sessionManager, cwd, resumed.restored, options.sessionDirectory);
|
|
158
|
+
notices.push(...opened.notices, ...resumed.failed);
|
|
159
|
+
const restoredNow = new Set(opened.sessionManager
|
|
160
|
+
.getWorktreeRootMappings()
|
|
161
|
+
.slice(recordedBefore)
|
|
162
|
+
.map((mapping) => resolve(mapping.to))
|
|
163
|
+
.filter((root) => isInside(storeDir, root)));
|
|
164
|
+
const blueprints = await setUpCheckoutBlueprints(opened.sessionManager, restoredNow, storeDir, options);
|
|
165
|
+
notices.push(...blueprints.notices);
|
|
166
|
+
await recordBlueprintContext(opened.sessionManager, blueprints.context);
|
|
167
|
+
return {
|
|
168
|
+
status: "ready",
|
|
169
|
+
sessionManager: opened.sessionManager,
|
|
170
|
+
notices,
|
|
171
|
+
blueprintNotices: blueprints.notices,
|
|
172
|
+
blueprintContext: blueprints.context,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
const SKIPPED_BLUEPRINTS = { outcome: undefined, notices: [], layers: [], context: undefined };
|
|
176
|
+
/**
|
|
177
|
+
* The blueprint context of a session that has no worktree snapshots to restore: what its working directory's
|
|
178
|
+
* repository and the global blueprint say, recorded in the session. No build runs and no Git command is started.
|
|
179
|
+
*/
|
|
180
|
+
async function describeBlueprintsInPlace(sessionManager, storeDir, options) {
|
|
181
|
+
if (options.blueprints === "skip")
|
|
182
|
+
return undefined;
|
|
183
|
+
const root = enclosingRepositoryRoot(resolve(sessionManager.getCwd()));
|
|
184
|
+
const blueprints = await setUpResumedBlueprints({
|
|
185
|
+
restored: [],
|
|
186
|
+
inPlace: root === undefined ? [] : [{ root, remotes: [] }],
|
|
187
|
+
config: { ...options.blueprint, storeDir },
|
|
152
188
|
signal: options.signal,
|
|
153
|
-
sessionDirectory: options.sessionDirectory,
|
|
154
|
-
beforeRecord: (restored) => reserveRestoredSetup(restored, snapshots, storeDir, options),
|
|
155
|
-
pendingMappings: reused === undefined ? [] : [reused],
|
|
156
|
-
keepInPlace: options.keepInPlace,
|
|
157
189
|
});
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const restoredNow = new Set(mappings.slice(recordedBefore).map((mapping) => resolve(mapping.to)));
|
|
161
|
-
notices.push(...(await setUpRestoredCheckouts(opened.sessionManager, restoredNow, storeDir, options)));
|
|
162
|
-
return { status: "ready", sessionManager: opened.sessionManager, notices };
|
|
190
|
+
await recordBlueprintContext(sessionManager, blueprints.context);
|
|
191
|
+
return blueprints.context;
|
|
163
192
|
}
|
|
164
193
|
/**
|
|
165
194
|
* Continues in the launch checkout the user chose although it differs from the snapshot. #4245's resume would restore
|
|
166
195
|
* a fresh worktree over that choice, so no other checkout is restored either; the notice names those left out.
|
|
167
196
|
*/
|
|
168
|
-
async function continueInChosenCheckout(sessionManager, reuse, options) {
|
|
197
|
+
async function continueInChosenCheckout(sessionManager, reuse, storeDir, options) {
|
|
169
198
|
const notices = [reuse.notice];
|
|
170
|
-
for (const root of currentWorktreeSnapshots(sessionManager)
|
|
199
|
+
for (const [root, snapshot] of currentWorktreeSnapshots(sessionManager)) {
|
|
171
200
|
if (!(await isDirectory(root))) {
|
|
172
|
-
notices.push(
|
|
173
|
-
type: "warning",
|
|
174
|
-
message: `Continuing without restoring ${root}, which this session also recorded`,
|
|
175
|
-
});
|
|
201
|
+
notices.push(notRestored(root, snapshot, "it does not exist on this node, and the session continues in the checkout you chose, which restores nothing else"));
|
|
176
202
|
}
|
|
177
203
|
}
|
|
178
204
|
const reopened = await sessionManager.openSessionById(sessionManager.getSessionId(), reuse.cwd, options.sessionDirectory);
|
|
179
|
-
|
|
205
|
+
const blueprints = options.blueprints === "skip"
|
|
206
|
+
? SKIPPED_BLUEPRINTS
|
|
207
|
+
: await setUpResumedBlueprints({
|
|
208
|
+
restored: [],
|
|
209
|
+
inPlace: await existingCheckouts(reopened),
|
|
210
|
+
config: { ...options.blueprint, storeDir },
|
|
211
|
+
signal: options.signal,
|
|
212
|
+
});
|
|
213
|
+
await recordBlueprintContext(reopened, blueprints.context);
|
|
214
|
+
return {
|
|
215
|
+
status: "ready",
|
|
216
|
+
sessionManager: reopened,
|
|
217
|
+
notices,
|
|
218
|
+
blueprintNotices: [],
|
|
219
|
+
blueprintContext: blueprints.context,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/** The session's current checkouts that exist on this node, with the remotes their snapshots recorded. */
|
|
223
|
+
async function existingCheckouts(sessionManager) {
|
|
224
|
+
const checkouts = [];
|
|
225
|
+
for (const [root, snapshot] of currentWorktreeSnapshots(sessionManager)) {
|
|
226
|
+
if (await isDirectory(root))
|
|
227
|
+
checkouts.push(checkoutOf(sessionManager, root, snapshot));
|
|
228
|
+
}
|
|
229
|
+
return checkouts;
|
|
230
|
+
}
|
|
231
|
+
/** The checkout at `root` for the blueprint build, identified by its repository's remotes as the session's restores trace them. */
|
|
232
|
+
function checkoutOf(sessionManager, root, snapshot) {
|
|
233
|
+
return {
|
|
234
|
+
root,
|
|
235
|
+
remotes: inheritedRemotes(root, snapshot.remotes, sessionManager.getWorktreeRootMappings(), sessionManager.getWorktreeSnapshotRecords()),
|
|
236
|
+
};
|
|
180
237
|
}
|
|
181
238
|
/** Records that the session continues in a checkout already here, so paths follow it. */
|
|
182
239
|
async function recordReuse(sessionManager, mapping) {
|
|
@@ -192,64 +249,125 @@ function withMapping(sessionManager, mapping) {
|
|
|
192
249
|
getWorktreeRootMappings: () => [...sessionManager.getWorktreeRootMappings(), mapping],
|
|
193
250
|
};
|
|
194
251
|
}
|
|
252
|
+
/** The warning that the resume continues without restoring the checkout recorded at `root`, with the reason. */
|
|
253
|
+
function notRestored(root, snapshot, reason) {
|
|
254
|
+
return {
|
|
255
|
+
type: "warning",
|
|
256
|
+
message: `Continuing without restoring ${root} (snapshot ${snapshot.id.slice(0, 12)}): ${reason}`,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function absentOrChanged(target) {
|
|
260
|
+
return target.absent ? "it does not exist on this node" : "it no longer matches the snapshot";
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* A failure of one checkout alone, which leaves the session's other checkouts restorable: a typed resume, workspace or
|
|
264
|
+
* Git failure, but not a setting that is wrong for every checkout.
|
|
265
|
+
*/
|
|
266
|
+
function isCheckoutFailure(error) {
|
|
267
|
+
return isResumeFailure(error) && !isWorkspaceConfigError(error);
|
|
268
|
+
}
|
|
269
|
+
/** What went wrong in `error`, for a warning: the unmet preconditions' reasons, or its own message, and any failed cleanup. */
|
|
270
|
+
function describeFailure(error) {
|
|
271
|
+
const detail = isResumePreconditionError(error)
|
|
272
|
+
? error.problems.map((problem) => problem.why).join("; ")
|
|
273
|
+
: error.message;
|
|
274
|
+
const cleanup = error.cleanupCause;
|
|
275
|
+
return cleanup instanceof Error ? `${detail}; removing what it restored also failed: ${cleanup.message}` : detail;
|
|
276
|
+
}
|
|
195
277
|
/**
|
|
196
278
|
* The recorded checkouts that are gone or changed here, which #4245's resume restores into fresh worktrees, except
|
|
197
|
-
* those the session continues in as they are.
|
|
279
|
+
* those the session continues in as they are. Another checkout than the one the session works in is also left alone,
|
|
280
|
+
* with a warning, when it cannot be compared with its snapshot, or when it is here and the session worked in it on this
|
|
281
|
+
* node, so it continues as it is.
|
|
198
282
|
*/
|
|
199
|
-
async function
|
|
283
|
+
async function restoreCandidates(sessionManager, cwd, options) {
|
|
200
284
|
const targets = [];
|
|
285
|
+
const left = new Map();
|
|
201
286
|
for (const [root, snapshot] of currentWorktreeSnapshots(sessionManager)) {
|
|
202
|
-
if (
|
|
203
|
-
|
|
287
|
+
if (options.keepInPlace?.has(root))
|
|
288
|
+
continue;
|
|
289
|
+
const runsHere = isInside(root, cwd);
|
|
290
|
+
try {
|
|
291
|
+
if (!(await worktreeNeedsRestore(snapshot, root, options)))
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
catch (error) {
|
|
295
|
+
if (runsHere || options.signal?.aborted || !isCheckoutFailure(error))
|
|
296
|
+
throw error;
|
|
297
|
+
left.set(root, notRestored(root, snapshot, `it could not be compared with the snapshot: ${error.message}`));
|
|
298
|
+
continue;
|
|
204
299
|
}
|
|
300
|
+
const absent = !(await isDirectory(root));
|
|
301
|
+
if (!runsHere && !absent && (await checkoutsWorkedHere(new Map([[root, snapshot]]), cwd, options)).has(root)) {
|
|
302
|
+
left.set(root, notRestored(root, snapshot, "it changed since the snapshot, and the session worked in it on this node, so it stays as it is"));
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
targets.push({ root, snapshot, absent, runsHere });
|
|
205
306
|
}
|
|
206
|
-
return targets;
|
|
307
|
+
return { targets, left };
|
|
207
308
|
}
|
|
208
309
|
/**
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
310
|
+
* Restores what `plan` says into fresh worktrees with #4245's {@link resumeSessionWorktree}, recording each restore on
|
|
311
|
+
* `sessionManager`, and returns the mappings it recorded. The checkouts the session works in are restored together,
|
|
312
|
+
* with the mapping to the launch checkout `reused`, and any failure refuses the resume. Every other checkout is
|
|
313
|
+
* restored on its own, and one whose restore fails is reported in `failed` and left out.
|
|
212
314
|
*/
|
|
213
|
-
async function
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
315
|
+
async function restorePlanned(sessionManager, plan, reused, storeDir, options) {
|
|
316
|
+
const outcome = { restored: [], failed: [] };
|
|
317
|
+
const restore = async (targets, pending) => {
|
|
318
|
+
const restoring = new Set(targets.map((target) => target.root));
|
|
319
|
+
const resumed = await resumeSessionWorktree(sessionManager, {
|
|
320
|
+
settings: options.settings,
|
|
219
321
|
storeDir,
|
|
220
|
-
config: options.setup,
|
|
221
322
|
signal: options.signal,
|
|
323
|
+
pendingMappings: pending === undefined ? [] : [pending],
|
|
324
|
+
keepInPlace: new Set([...currentWorktreeSnapshots(withMapping(sessionManager, pending)).keys()].filter((root) => !restoring.has(root))),
|
|
222
325
|
});
|
|
326
|
+
if (resumed.status === "restored")
|
|
327
|
+
outcome.restored.push(...resumed.mappings);
|
|
328
|
+
};
|
|
329
|
+
await restore(plan.required, reused);
|
|
330
|
+
for (const target of plan.optional) {
|
|
331
|
+
try {
|
|
332
|
+
await restore([target], undefined);
|
|
333
|
+
}
|
|
334
|
+
catch (error) {
|
|
335
|
+
if (options.signal?.aborted || !isCheckoutFailure(error))
|
|
336
|
+
throw error;
|
|
337
|
+
outcome.failed.push(notRestored(target.root, target.snapshot, `${absentOrChanged(target)}, and restoring it failed: ${describeFailure(error)}`));
|
|
338
|
+
}
|
|
223
339
|
}
|
|
340
|
+
return outcome;
|
|
224
341
|
}
|
|
225
342
|
/**
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
343
|
+
* Builds the blueprints of the worktrees Atomic restored for the session: each worktree this resume restored
|
|
344
|
+
* (`restoredNow`), and again each worktree restored earlier whose last build failed or never finished. Later changes
|
|
345
|
+
* to an earlier worktree's files are the session's own work. Every other checkout the session works in is only
|
|
346
|
+
* described to the agent.
|
|
229
347
|
*/
|
|
230
|
-
async function
|
|
231
|
-
|
|
348
|
+
async function setUpCheckoutBlueprints(sessionManager, restoredNow, storeDir, options) {
|
|
349
|
+
if (options.blueprints === "skip")
|
|
350
|
+
return SKIPPED_BLUEPRINTS;
|
|
351
|
+
const restoredHere = [];
|
|
352
|
+
const earlier = [];
|
|
353
|
+
const inPlace = [];
|
|
232
354
|
for (const [root, snapshot] of currentWorktreeSnapshots(sessionManager)) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
const setup = await ensureResumeSetup({
|
|
241
|
-
entryPoint: options.entryPoint,
|
|
242
|
-
worktree: root,
|
|
243
|
-
envHash: snapshot.envHash,
|
|
244
|
-
storeDir,
|
|
245
|
-
config: options.setup,
|
|
246
|
-
signal: options.signal,
|
|
247
|
-
});
|
|
248
|
-
if (setup.status === "ran") {
|
|
249
|
-
notices.push({ type: "info", message: `Ran setup hook ${setup.hook} in ${root} (output: ${setup.logPath})` });
|
|
250
|
-
}
|
|
355
|
+
const checkout = checkoutOf(sessionManager, root, snapshot);
|
|
356
|
+
if (restoredNow.has(root))
|
|
357
|
+
restoredHere.push(checkout);
|
|
358
|
+
else if (isInside(storeDir, root))
|
|
359
|
+
earlier.push(checkout);
|
|
360
|
+
else if (await isDirectory(root))
|
|
361
|
+
inPlace.push(checkout);
|
|
251
362
|
}
|
|
252
|
-
|
|
363
|
+
const retried = await checkoutsNeedingRebuild(earlier, storeDir);
|
|
364
|
+
return setUpResumedBlueprints({
|
|
365
|
+
restored: [...restoredHere, ...retried],
|
|
366
|
+
inPlace,
|
|
367
|
+
earlier: earlier.filter((checkout) => !retried.includes(checkout)),
|
|
368
|
+
config: { ...options.blueprint, storeDir },
|
|
369
|
+
signal: options.signal,
|
|
370
|
+
});
|
|
253
371
|
}
|
|
254
372
|
/**
|
|
255
373
|
* Whether the repository of the checkout at `root` holds the commit that records `snapshot`. That commit is
|
|
@@ -275,8 +393,8 @@ export async function holdsSnapshotCommit(snapshot, root, signal) {
|
|
|
275
393
|
}
|
|
276
394
|
/**
|
|
277
395
|
* Where a woken session continues. Each checkout it recorded that it worked in on this node stays as it is, since work
|
|
278
|
-
* done in it after the release belongs to the session, and a
|
|
279
|
-
* restored for it runs again. Every other checkout, as when it is missing or another clone sits at its path on another
|
|
396
|
+
* done in it after the release belongs to the session, and a blueprint build that failed or did not finish in a worktree
|
|
397
|
+
* this node restored for it runs again. Every other checkout, as when it is missing or another clone sits at its path on another
|
|
280
398
|
* node, is prepared as `/resume` prepares it. When every checkout stays, it continues in the directory it last worked
|
|
281
399
|
* in, after the restores it recorded, which `reopen` opens it in.
|
|
282
400
|
*/
|
|
@@ -286,9 +404,22 @@ export async function continueSessionWhereItWorked(opened, options, reopen = (cw
|
|
|
286
404
|
const own = await checkoutsWorkedHere(checkouts, cwd, options);
|
|
287
405
|
if (own.size < checkouts.size) {
|
|
288
406
|
const prepared = await prepareSessionResume(opened, { ...options, keepInPlace: own });
|
|
289
|
-
|
|
407
|
+
if (prepared.status !== "ready")
|
|
408
|
+
return opened;
|
|
409
|
+
if (prepared.blueprintNotices.length > 0)
|
|
410
|
+
options.onNotices?.(prepared.blueprintNotices);
|
|
411
|
+
return prepared.sessionManager;
|
|
412
|
+
}
|
|
413
|
+
const storeDir = resolveStoreDir(options);
|
|
414
|
+
if (checkouts.size === 0) {
|
|
415
|
+
await describeBlueprintsInPlace(opened, storeDir, options);
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
const blueprints = await setUpCheckoutBlueprints(opened, new Set(), storeDir, options);
|
|
419
|
+
await recordBlueprintContext(opened, blueprints.context);
|
|
420
|
+
if (blueprints.notices.length > 0)
|
|
421
|
+
options.onNotices?.(blueprints.notices);
|
|
290
422
|
}
|
|
291
|
-
await retryFailedSessionSetup(opened, options);
|
|
292
423
|
return cwd === resolve(opened.getCwd()) ? opened : reopen(cwd);
|
|
293
424
|
}
|
|
294
425
|
/**
|
|
@@ -307,14 +438,6 @@ async function checkoutsWorkedHere(checkouts, cwd, options) {
|
|
|
307
438
|
}
|
|
308
439
|
return own;
|
|
309
440
|
}
|
|
310
|
-
/**
|
|
311
|
-
* Runs the setup hook again in each worktree Atomic restored for the session whose last hook there failed, as a resume
|
|
312
|
-
* that restores nothing does.
|
|
313
|
-
*/
|
|
314
|
-
export async function retryFailedSessionSetup(sessionManager, options) {
|
|
315
|
-
const storeDir = resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());
|
|
316
|
-
return setUpRestoredCheckouts(sessionManager, new Set(), storeDir, options);
|
|
317
|
-
}
|
|
318
441
|
/**
|
|
319
442
|
* Whether resuming in `root` restores `snapshot` into a fresh worktree: the checkout is gone, is not a repository of
|
|
320
443
|
* the recorded tree, or no longer matches it. A path that cannot be read fails with its typed `unreadable-path` error
|
|
@@ -335,39 +458,54 @@ export async function worktreeNeedsRestore(snapshot, root, options) {
|
|
|
335
458
|
}
|
|
336
459
|
}
|
|
337
460
|
/**
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
461
|
+
* Decides what the resume does about the `candidates` that are gone or changed here, before anything is written. The
|
|
462
|
+
* precondition of restoring them on this node is that Git can be started or provisioned (`git`, the probe's typed
|
|
463
|
+
* failure). When it is unmet and the session works in a checkout that must be restored, the resume is refused; for any
|
|
464
|
+
* other checkout it leaves that checkout out, with a warning. A blueprint is never a precondition.
|
|
341
465
|
*/
|
|
342
|
-
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
466
|
+
function planRestores(sessionManager, candidates, options, git) {
|
|
467
|
+
const required = candidates.targets.filter((target) => target.runsHere);
|
|
468
|
+
const others = candidates.targets.filter((target) => !target.runsHere);
|
|
469
|
+
if (required.length > 0 && git !== undefined) {
|
|
470
|
+
throw preconditionFailure(sessionManager, [...required, ...others], options, git);
|
|
347
471
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
472
|
+
const left = new Map(candidates.left);
|
|
473
|
+
const optional = [];
|
|
474
|
+
for (const target of others) {
|
|
475
|
+
if (git) {
|
|
476
|
+
left.set(target.root, notRestored(target.root, target.snapshot, `${absentOrChanged(target)}, and Git is unavailable here (${git.code}), which restoring it needs`));
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
optional.push(target);
|
|
353
480
|
}
|
|
354
481
|
}
|
|
355
|
-
|
|
482
|
+
return { required, optional, left };
|
|
483
|
+
}
|
|
484
|
+
/** The refusal to resume because `targets` cannot be restored here: Git cannot be started or provisioned. */
|
|
485
|
+
function preconditionFailure(sessionManager, targets, options, git) {
|
|
486
|
+
const reasons = targets.map((target) => `snapshot ${target.snapshot.id.slice(0, 12)} because ${target.root} ${target.absent ? "does not exist on this node" : "no longer matches it"}`);
|
|
487
|
+
const problems = [
|
|
488
|
+
gitUnavailableProblem(git, `session ${sessionManager.getSessionId()} must be restored from ${reasons.join(", and from ")}`),
|
|
489
|
+
];
|
|
490
|
+
return new ResumePreconditionError({ entryPoint: options.entryPoint, problems }, git);
|
|
356
491
|
}
|
|
357
492
|
/**
|
|
358
|
-
* Whether a restored worktree is trusted to run its
|
|
359
|
-
*
|
|
493
|
+
* Whether a restored worktree is trusted to run its blueprints outside the CLI: the decision saved in `agentDir` for
|
|
494
|
+
* that path, else the default trust setting.
|
|
360
495
|
*/
|
|
361
496
|
export function savedProjectTrust(agentDir, settings) {
|
|
362
497
|
const trustStore = new ProjectTrustStore(agentDir);
|
|
363
498
|
return (worktree) => trustStore.get(worktree) ?? settings.getDefaultProjectTrust() === "always";
|
|
364
499
|
}
|
|
365
|
-
/** Where restored worktrees, the
|
|
500
|
+
/** Where restored worktrees, the blueprint build ledger and logs live for the agent directory `agentDir`. */
|
|
366
501
|
export function resumeStoreDir(agentDir) {
|
|
367
502
|
return join(agentDir, "worktree-snapshots");
|
|
368
503
|
}
|
|
504
|
+
function resolveStoreDir(options) {
|
|
505
|
+
return resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());
|
|
506
|
+
}
|
|
369
507
|
/**
|
|
370
|
-
* The options a resume from `launchCwd` needs: snapshot settings and the
|
|
508
|
+
* The options a resume from `launchCwd` needs: snapshot settings and the blueprint build configuration from
|
|
371
509
|
* `settingsManager`, and the worktree store of `agentDir`.
|
|
372
510
|
*/
|
|
373
511
|
export function sessionResumeOptions(entryPoint, launchCwd, agentDir, settingsManager, trusted) {
|
|
@@ -375,7 +513,7 @@ export function sessionResumeOptions(entryPoint, launchCwd, agentDir, settingsMa
|
|
|
375
513
|
entryPoint,
|
|
376
514
|
launchCwd,
|
|
377
515
|
settings: settingsManager.getWorktreeSnapshotSettings(),
|
|
378
|
-
|
|
516
|
+
blueprint: { agentDir, setupCommand: settingsManager.getResumeSetupCommand(), trusted },
|
|
379
517
|
storeDir: resumeStoreDir(agentDir),
|
|
380
518
|
};
|
|
381
519
|
}
|