@bastani/atomic 0.9.84-alpha.1 → 0.9.85-alpha.1
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 +52 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/broker/broker.ts +25 -7
- package/dist/builtin/intercom/broker/spawn.ts +83 -17
- package/dist/builtin/intercom/index.bundle.mjs +89 -26
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +6 -0
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/authoring.d.ts +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +48 -9
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +48 -9
- package/dist/builtin/workflows/src/index.js +48 -9
- package/dist/builtin/workflows/src/local-worker-entry.mjs +48 -9
- package/dist/config.d.ts +3 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -3
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-export.d.ts +2 -2
- package/dist/core/agent-session-export.d.ts.map +1 -1
- package/dist/core/agent-session-export.js +4 -5
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-services.js +1 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-summary.d.ts.map +1 -1
- package/dist/core/agent-session-summary.js +8 -1
- package/dist/core/agent-session-summary.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +3 -6
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/builtin-resource-loader.d.ts.map +1 -1
- package/dist/core/builtin-resource-loader.js +1 -1
- package/dist/core/builtin-resource-loader.js.map +1 -1
- package/dist/core/extensions/loader-core.d.ts +6 -2
- package/dist/core/extensions/loader-core.d.ts.map +1 -1
- package/dist/core/extensions/loader-core.js +13 -9
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/loader-discovery.js +1 -1
- package/dist/core/extensions/loader-discovery.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts +20 -14
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +133 -78
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/ts-source-specifiers.d.ts +1 -0
- package/dist/core/extensions/ts-source-specifiers.d.ts.map +1 -1
- package/dist/core/extensions/ts-source-specifiers.js +18 -2
- package/dist/core/extensions/ts-source-specifiers.js.map +1 -1
- package/dist/core/mandatory-resource-loader.d.ts +5 -2
- package/dist/core/mandatory-resource-loader.d.ts.map +1 -1
- package/dist/core/mandatory-resource-loader.js +17 -12
- package/dist/core/mandatory-resource-loader.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts.map +1 -1
- package/dist/core/model-fallback-failures.js +10 -3
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/resource-loader-extensions.d.ts.map +1 -1
- package/dist/core/resource-loader-extensions.js +1 -1
- package/dist/core/resource-loader-extensions.js.map +1 -1
- package/dist/core/resource-loader-reload.js +1 -1
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/resume/blueprint/resume.d.ts +4 -4
- package/dist/core/resume/blueprint/resume.js +4 -4
- package/dist/core/resume/blueprint/resume.js.map +1 -1
- package/dist/core/resume/session-resume.d.ts +6 -3
- package/dist/core/resume/session-resume.d.ts.map +1 -1
- package/dist/core/resume/session-resume.js +159 -37
- package/dist/core/resume/session-resume.js.map +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +10 -4
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +23 -6
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +2 -2
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +2 -1
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-history.d.ts +13 -1
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +21 -1
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +3 -1
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/session-manager.d.ts +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +1 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-worktree-snapshots.d.ts +61 -4
- package/dist/core/session-worktree-snapshots.d.ts.map +1 -1
- package/dist/core/session-worktree-snapshots.js +261 -28
- package/dist/core/session-worktree-snapshots.js.map +1 -1
- package/dist/core/storage/session/entry-structure.js +31 -1
- package/dist/core/storage/session/entry-structure.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.js +2 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js +2 -0
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/field-tone.d.ts +26 -0
- package/dist/core/tools/ask-user-question/state/selectors/field-tone.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/state/selectors/field-tone.js +27 -0
- package/dist/core/tools/ask-user-question/state/selectors/field-tone.js.map +1 -0
- package/dist/core/tools/ask-user-question/state/selectors/projections.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/projections.js +1 -0
- package/dist/core/tools/ask-user-question/state/selectors/projections.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/state-reducer.js +1 -1
- package/dist/core/tools/ask-user-question/state/state-reducer.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.js +6 -6
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts +5 -3
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js +14 -4
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts +2 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js +3 -3
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts +16 -6
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.js +42 -24
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.js +12 -3
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -1
- package/dist/core/tools/read.d.ts +1 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +13 -14
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/worktree-snapshot/index.d.ts +2 -2
- package/dist/core/worktree-snapshot/index.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/index.js +1 -1
- package/dist/core/worktree-snapshot/index.js.map +1 -1
- package/dist/core/worktree-snapshot/records.d.ts +6 -0
- package/dist/core/worktree-snapshot/records.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/records.js +18 -4
- package/dist/core/worktree-snapshot/records.js.map +1 -1
- package/dist/core/worktree-snapshot/restore.d.ts +24 -1
- package/dist/core/worktree-snapshot/restore.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/restore.js +443 -72
- package/dist/core/worktree-snapshot/restore.js.map +1 -1
- package/dist/core/worktree-snapshot/types.d.ts +44 -0
- package/dist/core/worktree-snapshot/types.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/types.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +2 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +4 -1
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +8 -0
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +11 -2
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-command-timeouts.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-timeouts.js +1 -0
- package/dist/modes/rpc/rpc-command-timeouts.js.map +1 -1
- package/dist/modes/rpc/rpc-input-scheduler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-input-scheduler.js +1 -0
- package/dist/modes/rpc/rpc-input-scheduler.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +11 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/environment-variables.md +1 -1
- package/docs/guides/resume-on-any-machine.md +6 -4
- package/docs/intercom/operations.md +4 -0
- package/docs/rpc/protocol.md +2 -2
- package/docs/sdk/reference.md +3 -0
- package/docs/sdk.md +2 -2
- package/docs/session-format.md +11 -2
- package/docs/sessions.md +4 -2
- package/docs/settings.md +1 -1
- package/docs/workflows/api-reference.md +2 -2
- package/docs/worktree-snapshots.md +13 -5
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-resume.js","sourceRoot":"","sources":["../../../src/core/resume/session-resume.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAA4B,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE9D,OAAO,EACN,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAClB,qBAAqB,GACrB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvF,OAAO,EACN,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,GACxB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EACN,+BAA+B,EAE/B,cAAc,GACd,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAEN,uBAAuB,EACvB,uBAAuB,EACvB,gBAAgB,EAEhB,sBAAsB,EACtB,sBAAsB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,yBAAyB,EAAyB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,CAAC,aAAa,CAAC,EAAE,CAC/F;KACD,CAAC;IACF,OAAO,IAAI,uBAAuB,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE,GAAG,CAAC,CAAC;AACvF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAChC,QAAgB,EAChB,QAAyD;IAEzD,MAAM,UAAU,GAAG,IAAI,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACnD,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,sBAAsB,EAAE,KAAK,QAAQ,CAAC;AACjG,CAAC;AAED,6GAA6G;AAC7G,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC9C,OAAO,IAAI,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,eAAe,CAAC,OAAsD;IAC9E,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,IAAI,+BAA+B,EAAE,CAAC,CAAC;AACvE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CACnC,UAA4B,EAC5B,SAAiB,EACjB,QAAgB,EAChB,eAA+F,EAC/F,OAAsC;IAEtC,OAAO;QACN,UAAU;QACV,SAAS;QACT,QAAQ,EAAE,eAAe,CAAC,2BAA2B,EAAE;QACvD,SAAS,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,CAAC,qBAAqB,EAAE,EAAE,OAAO,EAAE;QACvF,QAAQ,EAAE,cAAc,CAAC,QAAQ,CAAC;KAClC,CAAC;AACH,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { stat } from \"node:fs/promises\";\nimport { join, relative, resolve } from \"node:path\";\nimport { type GitUnavailableError, isGitUnavailableError } from \"../../utils/git-errors.ts\";\nimport { failureDebugFields, reportDebug } from \"../debug.ts\";\nimport type { SessionManager } from \"../session-manager.ts\";\nimport {\n\tcurrentWorktreeSnapshots,\n\tmapRestoredPath,\n\topenResumedSession,\n\tresumeSessionWorktree,\n} from \"../session-worktree-snapshots.ts\";\nimport type { SettingsManager } from \"../settings-manager.ts\";\nimport { ProjectTrustStore } from \"../trust-manager.ts\";\nimport { locateCheckout, readRepositoryConfig } from \"../worktree-snapshot/capture.ts\";\nimport {\n\tisWorkspaceConfigError,\n\tisWorkspaceDriftError,\n\tisWorkspaceSnapshotError,\n} from \"../worktree-snapshot/errors.ts\";\nimport { gitText, runGit } from \"../worktree-snapshot/git.ts\";\nimport { isHeadOnlyAdvance } from \"../worktree-snapshot/head-advance.ts\";\nimport {\n\tdefaultWorktreeSnapshotStoreDir,\n\ttype VerifyWorktreeOptions,\n\tverifyWorktree,\n} from \"../worktree-snapshot/restore.ts\";\nimport type { WorktreeRootMapping, WorktreeSnapshot, WorktreeSnapshotSettings } from \"../worktree-snapshot/types.ts\";\nimport type { BlueprintBuildConfig } from \"./blueprint/build.ts\";\nimport {\n\ttype BlueprintCheckout,\n\tcheckoutsNeedingRebuild,\n\tenclosingRepositoryRoot,\n\tinheritedRemotes,\n\ttype ResumedBlueprints,\n\trecordBlueprintContext,\n\tsetUpResumedBlueprints,\n} from \"./blueprint/resume.ts\";\nimport { isResumePreconditionError, type ResumeEntryPoint, ResumePreconditionError } from \"./errors.ts\";\nimport { isResumeFailure } from \"./failure.ts\";\nimport { isInside } from \"./path-mapping.ts\";\nimport { defaultResumePreflightIo, gitUnavailableProblem, type ResumePreflightIo } from \"./preflight.ts\";\n\n/** What to do when the checkout a resume was started in belongs to the session's repository but differs from it. */\nexport type DirtyCheckoutChoice = \"restore\" | \"use\" | \"cancel\";\n\nexport interface DirtyCheckoutPrompt {\n\t/** Root of the user's checkout the resume was started in. */\n\treadonly checkout: string;\n\t/** Root the session recorded, on the node that recorded it. */\n\treadonly recordedRoot: string;\n\treadonly snapshotId: string;\n}\n\nexport interface ResumeNotice {\n\treadonly type: \"info\" | \"warning\";\n\treadonly message: string;\n}\n\nexport interface PrepareSessionResumeOptions {\n\treadonly entryPoint: ResumeEntryPoint;\n\t/** Where the resume was started: the requested target when it is a checkout of the session's repository. */\n\treadonly launchCwd: string;\n\treadonly settings: WorktreeSnapshotSettings;\n\t/** How the blueprints of worktrees this resume restores are built; the store directory is `storeDir`. */\n\treadonly blueprint: Omit<BlueprintBuildConfig, \"storeDir\">;\n\t/** Host directory for restored worktrees. Default ~/.atomic/agent/worktree-snapshots. */\n\treadonly storeDir?: string;\n\t/** Asks the user about a dirty checkout. Without it a fresh worktree is restored, which overwrites nothing. */\n\treadonly chooseDirtyCheckout?: (prompt: DirtyCheckoutPrompt) => Promise<DirtyCheckoutChoice>;\n\treadonly io?: ResumePreflightIo;\n\t/** Session directory to reopen a moved session in, for stores that keep sessions per directory. */\n\treadonly sessionDirectory?: string;\n\treadonly signal?: AbortSignal;\n\t/**\n\t * Checkouts the session continues in as they are, by the root its recorded restores put them at: never verified and\n\t * never restored, as for checkouts it worked in on this node and changed since.\n\t */\n\treadonly keepInPlace?: ReadonlySet<string>;\n\t/**\n\t * `\"skip\"` restores checkouts but builds and describes no blueprint and records no blueprint context: for a process\n\t * that serves a resume another process of the same user-level action already prepared and built, so one resume\n\t * builds once. Default `\"build\"`.\n\t */\n\treadonly blueprints?: \"build\" | \"skip\";\n\t/**\n\t * Told the warnings of the blueprint builds a resume ran when its caller gets only a session back, as when a\n\t * released session is woken ({@link continueSessionWhereItWorked}).\n\t */\n\treadonly onNotices?: (notices: readonly ResumeNotice[]) => void;\n\t/** Told each slow step the resume starts (checking checkouts, restoring one, building blueprints), for a progress line. */\n\treadonly onProgress?: (message: string) => void;\n}\n\nexport type PreparedSessionResume =\n\t| { readonly status: \"cancelled\" }\n\t| {\n\t\t\treadonly status: \"ready\";\n\t\t\t/** The session opened where it continues: the one passed in when its cwd did not change. */\n\t\t\treadonly sessionManager: SessionManager;\n\t\t\treadonly notices: readonly ResumeNotice[];\n\t\t\t/** The warnings of the blueprint builds this resume ran, also in `notices`. */\n\t\t\treadonly blueprintNotices: readonly ResumeNotice[];\n\t\t\t/** The blueprint context the session's next turn carries, already recorded in it; undefined when none. */\n\t\t\treadonly blueprintContext: string | undefined;\n\t };\n\nasync function isDirectory(path: string): Promise<boolean> {\n\ttry {\n\t\treturn (await stat(path)).isDirectory();\n\t} catch (error) {\n\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\tif (code === \"ENOENT\" || code === \"ENOTDIR\") return false;\n\t\tthrow error;\n\t}\n}\n\nexport interface SessionSnapshotMatch {\n\treadonly root: string;\n\treadonly snapshot: WorktreeSnapshot;\n\t/** The session cwd after the session's recorded restores. */\n\treadonly cwd: string;\n}\n\n/** The latest snapshot of the checkout the session works in, the same one #4245's resume verifies. */\nexport function latestSessionSnapshot(\n\tsessionManager: Pick<SessionManager, \"getCwd\" | \"getWorktreeRootMappings\" | \"getLatestWorktreeSnapshots\">,\n): SessionSnapshotMatch | undefined {\n\tconst cwd = mapRestoredPath(sessionManager.getCwd(), sessionManager.getWorktreeRootMappings());\n\tlet match: SessionSnapshotMatch | undefined;\n\tfor (const [root, snapshot] of sessionManager.getLatestWorktreeSnapshots()) {\n\t\tif (isInside(root, cwd) && (!match || root.length > match.root.length)) match = { root, snapshot, cwd };\n\t}\n\treturn match;\n}\n\n/** Continue in the launch checkout, or stop because the user cancelled; undefined restores a fresh worktree. */\ntype CheckoutReuse =\n\t| {\n\t\t\treadonly kind: \"reused\";\n\t\t\treadonly cwd: string;\n\t\t\t/** Whether the checkout matched the snapshot, rather than being used as it is by the user's choice. */\n\t\t\treadonly matches: boolean;\n\t\t\treadonly notice: ResumeNotice;\n\t\t\t/** The recorded root mapped onto the checkout, recorded once nothing else stops the resume. */\n\t\t\treadonly mapping: WorktreeRootMapping;\n\t }\n\t| { readonly kind: \"cancelled\" }\n\t| undefined;\n\n/**\n * Continues in the checkout the resume started in when it is a checkout of the session's repository: as-is when its\n * tree matches the snapshot (or only its HEAD moved forward over it); when it differs and has local changes, only if\n * the user says so. A clean checkout that differs is left alone and a fresh worktree is restored instead. Returns the\n * mapping that makes paths follow, for the caller to record.\n */\nasync function reuseLaunchCheckout(\n\tmatch: SessionSnapshotMatch,\n\toptions: PrepareSessionResumeOptions,\n): Promise<CheckoutReuse> {\n\tconst checkout = await locateCheckout(options.launchCwd, options.signal).catch((error: unknown) => {\n\t\tif (isWorkspaceSnapshotError(error)) return error;\n\t\tthrow error;\n\t});\n\tif (checkout instanceof Error) return undefined;\n\tconst root = resolve(checkout.root);\n\tconst { remotes } = await readRepositoryConfig(root, options.signal);\n\tif (!remotes.some((remote) => match.snapshot.remotes.includes(remote))) return undefined;\n\tlet matches = true;\n\ttry {\n\t\tawait verifyWorktree(match.snapshot, root, { settings: options.settings, signal: options.signal });\n\t} catch (error) {\n\t\tif (!isWorkspaceDriftError(error)) throw error;\n\t\tmatches = await isHeadOnlyAdvance(error, options.signal);\n\t}\n\tif (!matches) {\n\t\tif (!(await hasLocalChanges(root, options.signal))) return undefined;\n\t\tconst choice = options.chooseDirtyCheckout\n\t\t\t? await options.chooseDirtyCheckout({\n\t\t\t\t\tcheckout: root,\n\t\t\t\t\trecordedRoot: match.root,\n\t\t\t\t\tsnapshotId: match.snapshot.id,\n\t\t\t\t})\n\t\t\t: \"restore\";\n\t\tif (choice === \"cancel\") return { kind: \"cancelled\" };\n\t\tif (choice === \"restore\") return undefined;\n\t}\n\tconst mapping: WorktreeRootMapping = {\n\t\tfrom: match.root,\n\t\tto: root,\n\t\tsnapshotId: match.snapshot.id,\n\t\ttree: match.snapshot.tree,\n\t\trestoredAt: new Date().toISOString(),\n\t};\n\treturn {\n\t\tkind: \"reused\",\n\t\tcwd: resolve(root, relative(match.root, match.cwd)),\n\t\tmatches,\n\t\tmapping,\n\t\tnotice: matches\n\t\t\t? {\n\t\t\t\t\ttype: \"info\",\n\t\t\t\t\tmessage: `Resuming in ${root}, which matches snapshot ${match.snapshot.id.slice(0, 12)} of ${match.root}`,\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tmessage: `Resuming in ${root}, which differs from snapshot ${match.snapshot.id.slice(0, 12)} of ${match.root}`,\n\t\t\t\t},\n\t};\n}\n\n/**\n * Moves a session that a resume restored into a worktree, and that has not worked in it since, back to the checkout it\n * was restored from, when that checkout is on this node and its repository holds the snapshot's commit (#4660). The\n * session continues there as the checkout is now, even when it changed since the snapshot. Undefined keeps the session\n * in its worktree: the worktree is not one Atomic restored, it changed or recorded another snapshot since, or the\n * checkout it came from is gone or is another clone.\n */\nasync function returnToStartingCheckout(\n\tsessionManager: SessionManager,\n\tmatch: SessionSnapshotMatch,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<Extract<CheckoutReuse, { kind: \"reused\" }> | undefined> {\n\tif (!isInside(storeDir, match.root)) return undefined;\n\tconst restore = [...sessionManager.getWorktreeRootMappings()]\n\t\t.reverse()\n\t\t.find((mapping) => resolve(mapping.to) === resolve(match.root));\n\tif (restore === undefined || restore.snapshotId !== match.snapshot.id) return undefined;\n\tconst checkout = resolve(restore.from);\n\tconst cwd = resolve(checkout, relative(match.root, match.cwd));\n\tif (isInside(storeDir, checkout) || !existsSync(cwd)) return undefined;\n\t// When the checkout cannot be examined, the project the session started in is still where it goes back to.\n\tconst examined = await orFallBack(options, \"return-to-checkout-verify\", undefined, async () => ({\n\t\tholdsCommit: await holdsSnapshotCommit(match.snapshot, checkout, options.signal),\n\t\tmatches: !(await worktreeNeedsRestore(match.snapshot, checkout, options)),\n\t}));\n\tif (examined !== undefined && !examined.holdsCommit) return undefined;\n\tconst matches = examined?.matches;\n\tconst snapshotId = match.snapshot.id.slice(0, 12);\n\treturn {\n\t\tkind: \"reused\",\n\t\tcwd,\n\t\tmatches: matches ?? false,\n\t\tmapping: {\n\t\t\tfrom: match.root,\n\t\t\tto: checkout,\n\t\t\tsnapshotId: match.snapshot.id,\n\t\t\ttree: match.snapshot.tree,\n\t\t\trestoredAt: new Date().toISOString(),\n\t\t},\n\t\tnotice: {\n\t\t\ttype: \"info\",\n\t\t\tmessage: `Resuming in ${checkout}, the checkout this session was restored from, instead of the worktree ${match.root}.${matches === undefined ? \"\" : matches ? ` It matches snapshot ${snapshotId}.` : ` It has changed since snapshot ${snapshotId}; that snapshot was not restored.`}`,\n\t\t},\n\t};\n}\n\n/**\n * Runs an optional improvement of where a resume continues. When it fails on a checkout, with a typed resume,\n * workspace or Git failure, the resume goes on with `fallback`, the behaviour it had without the improvement; the\n * reason goes to the debug log. A cancellation, and any failure that is not about a checkout, still end the resume.\n */\nasync function orFallBack<T>(\n\toptions: Pick<PrepareSessionResumeOptions, \"signal\">,\n\tstep: string,\n\tfallback: T,\n\tattempt: () => Promise<T>,\n): Promise<T> {\n\ttry {\n\t\treturn await attempt();\n\t} catch (error) {\n\t\tif (options.signal?.aborted || !isCheckoutFailure(error)) throw error;\n\t\treportDebug(\"storage\", \"resume-checkout-fallback\", { step, ...failureDebugFields(error) });\n\t\treturn fallback;\n\t}\n}\n\n/** Whether the checkout at `root` has uncommitted or untracked changes, which a resume must not overwrite unasked. */\nasync function hasLocalChanges(root: string, signal: AbortSignal | undefined): Promise<boolean> {\n\treturn (await gitText([\"status\", \"--porcelain\"], { cwd: root, signal })).length > 0;\n}\n\n/**\n * Gets a resumed session's checkouts ready on this node before its runtime starts, and returns the session opened\n * where it continues. When the checkout the session works in changed here but is still the one it worked in (its\n * repository holds the snapshot's commit, or Atomic restored it here), the session continues in it as it is, silently\n * (#4660). A session a resume moved into a restored worktree, and that has not worked in it since, returns to\n * the checkout it was restored from when that checkout is here. When the checkout the session works in is missing or\n * belongs to another clone here, a checkout of the same\n * repository the resume started in is used as-is if it matches (and, if it differs, only when the user chooses it).\n * The checkout the session works in is the only one the resume cannot go without: when it must be restored, the\n * precondition of restoring the recorded checkouts, that Git can run, is checked first, and an unmet one refuses the\n * resume before anything is written. Every other checkout the session recorded that is gone or changed here, except\n * those in `keepInPlace`, never blocks the resume: one the session worked in on this node, changed since, continues as\n * it is; the rest are restored into fresh worktrees one by one by #4245's {@link resumeSessionWorktree}, and one that\n * cannot be (Git is unavailable, or its restore fails) is left out with a warning that names its path and why. Each\n * worktree Atomic restored then gets its blueprints built (#4588): a failing step is a warning in `notices` and never\n * stops the resume. The agent gets the blueprints' maintenance and knowledge in the session's next turn. The session's\n * tools resolve paths under every root it recorded into the place that root was restored.\n */\nexport async function prepareSessionResume(\n\tsessionManager: SessionManager,\n\toptions: PrepareSessionResumeOptions,\n): Promise<PreparedSessionResume> {\n\tconst io = options.io ?? defaultResumePreflightIo;\n\tconst storeDir = resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n\tif (!options.settings.enabled || sessionManager.getLatestWorktreeSnapshots().size === 0) {\n\t\tconst unchanged = await describeBlueprintsInPlace(sessionManager, storeDir, options);\n\t\treturn { status: \"ready\", sessionManager, notices: [], blueprintNotices: [], blueprintContext: unchanged };\n\t}\n\tconst notices: ResumeNotice[] = [];\n\tconst checkoutCount = currentWorktreeSnapshots(sessionManager).size;\n\toptions.onProgress?.(\n\t\t`Checking ${checkoutCount === 1 ? \"1 checkout\" : `${checkoutCount} checkouts`} against the session's snapshots`,\n\t);\n\tconst verified = new Map<string, Promise<boolean>>();\n\tconst verifyOnce = (snapshot: WorktreeSnapshot, root: string): Promise<boolean> => {\n\t\tconst key = `${snapshot.id}\\0${resolve(root)}`;\n\t\tlet verification = verified.get(key);\n\t\tif (verification === undefined) {\n\t\t\tverification = worktreeNeedsRestore(snapshot, root, options);\n\t\t\tverified.set(key, verification);\n\t\t}\n\t\treturn verification;\n\t};\n\tconst match = latestSessionSnapshot(sessionManager);\n\tlet git: GitProbe | undefined;\n\tlet reused: WorktreeRootMapping | undefined;\n\tconst needsRestore =\n\t\tmatch !== undefined && !options.keepInPlace?.has(match.root) && (await verifyOnce(match.snapshot, match.root));\n\tconst project =\n\t\tmatch !== undefined && !needsRestore && !options.keepInPlace?.has(match.root)\n\t\t\t? await orFallBack(options, \"return-to-checkout\", undefined, () =>\n\t\t\t\t\treturnToStartingCheckout(sessionManager, match, storeDir, options),\n\t\t\t\t)\n\t\t\t: undefined;\n\tif (project !== undefined) {\n\t\tawait recordReuse(sessionManager, project.mapping);\n\t\tnotices.push(project.notice);\n\t}\n\tconst keepsOwnCheckout =\n\t\tmatch !== undefined &&\n\t\tproject === undefined &&\n\t\tneedsRestore &&\n\t\t(await isDirectory(match.root)) &&\n\t\t(await orFallBack(options, \"own-checkout\", new Set([match.root]), () =>\n\t\t\tcheckoutsWorkedHere(new Map([[match.root, match.snapshot]]), match.cwd, options),\n\t\t).then((worked) => worked.has(match.root)));\n\t// The checkout the session returned to stays as it is, whatever it changed since: only the others are restored.\n\tconst kept = [...(keepsOwnCheckout && match !== undefined ? [match.root] : [])];\n\tif (project !== undefined && match !== undefined) kept.push(match.root, project.mapping.to);\n\tconst resume: PrepareSessionResumeOptions =\n\t\tkept.length > 0 ? { ...options, keepInPlace: new Set([...(options.keepInPlace ?? []), ...kept]) } : options;\n\tif (match !== undefined && !keepsOwnCheckout && needsRestore) {\n\t\tgit = { unavailable: await io.probeGit(options.signal) };\n\t\tconst reuse = git.unavailable === undefined ? await reuseLaunchCheckout(match, options) : undefined;\n\t\tif (reuse?.kind === \"cancelled\") return { status: \"cancelled\" };\n\t\tif (reuse?.kind === \"reused\" && !reuse.matches) {\n\t\t\tawait recordReuse(sessionManager, reuse.mapping);\n\t\t\treturn continueInChosenCheckout(sessionManager, reuse, storeDir, options);\n\t\t}\n\t\tif (reuse?.kind === \"reused\") {\n\t\t\treused = reuse.mapping;\n\t\t\tnotices.push(reuse.notice);\n\t\t}\n\t}\n\tconst checkouts = withMapping(sessionManager, reused);\n\tconst candidates = await restoreCandidates(\n\t\tcheckouts,\n\t\tmapRestoredPath(sessionManager.getCwd(), checkouts.getWorktreeRootMappings()),\n\t\tresume,\n\t\tverifyOnce,\n\t);\n\tif (candidates.targets.length > 0) git ??= { unavailable: await io.probeGit(options.signal) };\n\tconst plan = planRestores(sessionManager, candidates, resume, git?.unavailable);\n\tnotices.push(...plan.left.values());\n\tconst recordedBefore = sessionManager.getWorktreeRootMappings().length;\n\tconst resumed = await restorePlanned(sessionManager, plan, reused, storeDir, resume);\n\tconst cwd = mapRestoredPath(sessionManager.getCwd(), sessionManager.getWorktreeRootMappings());\n\tconst opened = await openResumedSession(sessionManager, cwd, resumed.restored, options.sessionDirectory);\n\tnotices.push(...opened.notices, ...resumed.failed);\n\tconst restoredNow = new Set(\n\t\topened.sessionManager\n\t\t\t.getWorktreeRootMappings()\n\t\t\t.slice(recordedBefore)\n\t\t\t.map((mapping) => resolve(mapping.to))\n\t\t\t.filter((root) => isInside(storeDir, root)),\n\t);\n\tif (restoredNow.size > 0 && options.blueprints !== \"skip\") {\n\t\toptions.onProgress?.(\"Setting up the blueprints of restored worktrees\");\n\t}\n\tconst blueprints = await setUpCheckoutBlueprints(opened.sessionManager, restoredNow, storeDir, options);\n\tnotices.push(...blueprints.notices);\n\tawait recordBlueprintContext(opened.sessionManager, blueprints.context);\n\treturn {\n\t\tstatus: \"ready\",\n\t\tsessionManager: opened.sessionManager,\n\t\tnotices,\n\t\tblueprintNotices: blueprints.notices,\n\t\tblueprintContext: blueprints.context,\n\t};\n}\n\nconst SKIPPED_BLUEPRINTS: ResumedBlueprints = { outcome: undefined, notices: [], layers: [], context: undefined };\n\n/**\n * The blueprint context of a session that has no worktree snapshots to restore: what its working directory's\n * repository and the global blueprint say, recorded in the session. No build runs and no Git command is started.\n */\nasync function describeBlueprintsInPlace(\n\tsessionManager: SessionManager,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<string | undefined> {\n\tif (options.blueprints === \"skip\") return undefined;\n\tconst root = enclosingRepositoryRoot(resolve(sessionManager.getCwd()));\n\tconst blueprints = await setUpResumedBlueprints({\n\t\trestored: [],\n\t\tinPlace: root === undefined ? [] : [{ root, remotes: [] }],\n\t\tconfig: { ...options.blueprint, storeDir },\n\t\tsignal: options.signal,\n\t});\n\tawait recordBlueprintContext(sessionManager, blueprints.context);\n\treturn blueprints.context;\n}\n\n/**\n * Continues in the launch checkout the user chose although it differs from the snapshot. #4245's resume would restore\n * a fresh worktree over that choice, so no other checkout is restored either; the notice names those left out.\n */\nasync function continueInChosenCheckout(\n\tsessionManager: SessionManager,\n\treuse: Extract<CheckoutReuse, { kind: \"reused\" }>,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<PreparedSessionResume> {\n\tconst notices: ResumeNotice[] = [reuse.notice];\n\tfor (const [root, snapshot] of currentWorktreeSnapshots(sessionManager)) {\n\t\tif (!(await isDirectory(root))) {\n\t\t\tnotices.push(\n\t\t\t\tnotRestored(\n\t\t\t\t\troot,\n\t\t\t\t\tsnapshot,\n\t\t\t\t\t\"it does not exist on this node, and the session continues in the checkout you chose, which restores nothing else\",\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\tconst reopened = await sessionManager.openSessionById(\n\t\tsessionManager.getSessionId(),\n\t\treuse.cwd,\n\t\toptions.sessionDirectory,\n\t);\n\tconst blueprints =\n\t\toptions.blueprints === \"skip\"\n\t\t\t? SKIPPED_BLUEPRINTS\n\t\t\t: await setUpResumedBlueprints({\n\t\t\t\t\trestored: [],\n\t\t\t\t\tinPlace: await existingCheckouts(reopened),\n\t\t\t\t\tconfig: { ...options.blueprint, storeDir },\n\t\t\t\t\tsignal: options.signal,\n\t\t\t\t});\n\tawait recordBlueprintContext(reopened, blueprints.context);\n\treturn {\n\t\tstatus: \"ready\",\n\t\tsessionManager: reopened,\n\t\tnotices,\n\t\tblueprintNotices: [],\n\t\tblueprintContext: blueprints.context,\n\t};\n}\n\n/** The session's current checkouts that exist on this node, with the remotes their snapshots recorded. */\nasync function existingCheckouts(sessionManager: SessionCheckouts): Promise<BlueprintCheckout[]> {\n\tconst checkouts: BlueprintCheckout[] = [];\n\tfor (const [root, snapshot] of currentWorktreeSnapshots(sessionManager)) {\n\t\tif (await isDirectory(root)) checkouts.push(checkoutOf(sessionManager, root, snapshot));\n\t}\n\treturn checkouts;\n}\n\n/** The checkout at `root` for the blueprint build, identified by its repository's remotes as the session's restores trace them. */\nfunction checkoutOf(sessionManager: SessionCheckouts, root: string, snapshot: WorktreeSnapshot): BlueprintCheckout {\n\treturn {\n\t\troot,\n\t\tremotes: inheritedRemotes(\n\t\t\troot,\n\t\t\tsnapshot.remotes,\n\t\t\tsessionManager.getWorktreeRootMappings(),\n\t\t\tsessionManager.getWorktreeSnapshotRecords(),\n\t\t),\n\t};\n}\n\n/** A recorded checkout a resume restores, and whether it is missing here or only changed. */\ninterface RestoreTarget {\n\treadonly root: string;\n\treadonly snapshot: WorktreeSnapshot;\n\treadonly absent: boolean;\n\t/** Whether the session's working directory is inside it, so the session cannot continue without it. */\n\treadonly runsHere: boolean;\n}\n\n/** What a resume does about the recorded checkouts that are gone or changed here. */\ninterface RestorePlan {\n\t/** Checkouts the session works in, which the resume restores together or not at all. */\n\treadonly required: readonly RestoreTarget[];\n\t/** Every other checkout the resume restores, each on its own, so that one that cannot be restored is left out. */\n\treadonly optional: readonly RestoreTarget[];\n\t/** The warning for each other checkout the resume continues without restoring, by its root. */\n\treadonly left: ReadonlyMap<string, ResumeNotice>;\n}\n\n/** Records that the session continues in a checkout already here, so paths follow it. */\nasync function recordReuse(sessionManager: SessionManager, mapping: WorktreeRootMapping): Promise<void> {\n\tawait sessionManager.appendWorktreeSnapshot(mapping.to, mapping.snapshotId, undefined, mapping);\n}\n\ntype SessionCheckouts = Pick<SessionManager, \"getBranch\" | \"getWorktreeRootMappings\" | \"getWorktreeSnapshotRecords\">;\n\n/** The session's checkouts as they are once `mapping`, not yet recorded, is. */\nfunction withMapping(sessionManager: SessionManager, mapping: WorktreeRootMapping | undefined): SessionCheckouts {\n\tif (mapping === undefined) return sessionManager;\n\treturn {\n\t\tgetBranch: () => sessionManager.getBranch(),\n\t\tgetWorktreeSnapshotRecords: () => sessionManager.getWorktreeSnapshotRecords(),\n\t\tgetWorktreeRootMappings: () => [...sessionManager.getWorktreeRootMappings(), mapping],\n\t};\n}\n\n/** The warning that the resume continues without restoring the checkout recorded at `root`, with the reason. */\nfunction notRestored(root: string, snapshot: WorktreeSnapshot, reason: string): ResumeNotice {\n\treturn {\n\t\ttype: \"warning\",\n\t\tmessage: `Continuing without restoring ${root} (snapshot ${snapshot.id.slice(0, 12)}): ${reason}`,\n\t};\n}\n\nfunction absentOrChanged(target: Pick<RestoreTarget, \"absent\">): string {\n\treturn target.absent ? \"it does not exist on this node\" : \"it no longer matches the snapshot\";\n}\n\n/**\n * A failure of one checkout alone, which leaves the session's other checkouts restorable: a typed resume, workspace or\n * Git failure, but not a setting that is wrong for every checkout.\n */\nfunction isCheckoutFailure(error: unknown): error is Error {\n\treturn isResumeFailure(error) && !isWorkspaceConfigError(error);\n}\n\n/** What went wrong in `error`, for a warning: the unmet preconditions' reasons, or its own message, and any failed cleanup. */\nfunction describeFailure(error: Error): string {\n\tconst detail = isResumePreconditionError(error)\n\t\t? error.problems.map((problem) => problem.why).join(\"; \")\n\t\t: error.message;\n\tconst cleanup = (error as Error & { readonly cleanupCause?: unknown }).cleanupCause;\n\treturn cleanup instanceof Error ? `${detail}; removing what it restored also failed: ${cleanup.message}` : detail;\n}\n\n/**\n * The recorded checkouts that are gone or changed here, which #4245's resume restores into fresh worktrees, except\n * those the session continues in as they are. Another checkout than the one the session works in is also left alone,\n * with a warning, when it cannot be compared with its snapshot, or when it is here and the session worked in it on this\n * node, so it continues as it is.\n */\nasync function restoreCandidates(\n\tsessionManager: SessionCheckouts,\n\tcwd: string,\n\toptions: PrepareSessionResumeOptions,\n\tneedsRestore: (snapshot: WorktreeSnapshot, root: string) => Promise<boolean>,\n): Promise<{ readonly targets: RestoreTarget[]; readonly left: Map<string, ResumeNotice> }> {\n\tconst targets: RestoreTarget[] = [];\n\tconst left = new Map<string, ResumeNotice>();\n\tconst checkouts = [...currentWorktreeSnapshots(sessionManager)].filter(([root]) => !options.keepInPlace?.has(root));\n\tconst comparisons = await settleBounded(checkouts, VERIFY_CONCURRENCY, ([root, snapshot]) =>\n\t\tneedsRestore(snapshot, root),\n\t);\n\tfor (const [index, [root, snapshot]] of checkouts.entries()) {\n\t\tconst runsHere = isInside(root, cwd);\n\t\tconst comparison = comparisons[index]!;\n\t\tif (comparison.status === \"rejected\") {\n\t\t\tconst error: unknown = comparison.reason;\n\t\t\tif (runsHere || options.signal?.aborted || !isCheckoutFailure(error)) throw error;\n\t\t\tleft.set(root, notRestored(root, snapshot, `it could not be compared with the snapshot: ${error.message}`));\n\t\t\tcontinue;\n\t\t}\n\t\tif (!comparison.value) continue;\n\t\tconst absent = !(await isDirectory(root));\n\t\tif (!runsHere && !absent && (await checkoutsWorkedHere(new Map([[root, snapshot]]), cwd, options)).has(root)) {\n\t\t\tleft.set(\n\t\t\t\troot,\n\t\t\t\tnotRestored(\n\t\t\t\t\troot,\n\t\t\t\t\tsnapshot,\n\t\t\t\t\t\"it changed since the snapshot, and the session worked in it on this node, so it stays as it is\",\n\t\t\t\t),\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\ttargets.push({ root, snapshot, absent, runsHere });\n\t}\n\treturn { targets, left };\n}\n\n/** How many recorded checkouts a resume compares with their snapshots at once. */\nconst VERIFY_CONCURRENCY = 4;\n\n/** `map` over `items`, at most `limit` at a time, each outcome settled in the order of `items`. */\nasync function settleBounded<T, R>(\n\titems: readonly T[],\n\tlimit: number,\n\tmap: (item: T) => Promise<R>,\n): Promise<PromiseSettledResult<R>[]> {\n\tconst outcomes: PromiseSettledResult<R>[] = [];\n\tlet next = 0;\n\tconst work = async (): Promise<void> => {\n\t\twhile (next < items.length) {\n\t\t\tconst index = next++;\n\t\t\ttry {\n\t\t\t\toutcomes[index] = { status: \"fulfilled\", value: await map(items[index]!) };\n\t\t\t} catch (reason) {\n\t\t\t\toutcomes[index] = { status: \"rejected\", reason };\n\t\t\t}\n\t\t}\n\t};\n\tawait Promise.all(Array.from({ length: Math.min(limit, items.length) }, work));\n\treturn outcomes;\n}\n\n/**\n * Restores what `plan` says into fresh worktrees with #4245's {@link resumeSessionWorktree}, recording each restore on\n * `sessionManager`, and returns the mappings it recorded. The checkouts the session works in are restored together,\n * with the mapping to the launch checkout `reused`, and any failure refuses the resume. Every other checkout is\n * restored on its own, and one whose restore fails is reported in `failed` and left out.\n */\nasync function restorePlanned(\n\tsessionManager: SessionManager,\n\tplan: RestorePlan,\n\treused: WorktreeRootMapping | undefined,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<{ restored: WorktreeRootMapping[]; failed: ResumeNotice[] }> {\n\tconst outcome = { restored: [] as WorktreeRootMapping[], failed: [] as ResumeNotice[] };\n\tconst restore = async (targets: readonly RestoreTarget[], pending: WorktreeRootMapping | undefined) => {\n\t\tfor (const target of targets) {\n\t\t\toptions.onProgress?.(`Restoring ${target.root} from snapshot ${target.snapshot.id.slice(0, 12)}`);\n\t\t}\n\t\tconst restoring = new Set(targets.map((target) => target.root));\n\t\tconst resumed = await resumeSessionWorktree(sessionManager, {\n\t\t\tsettings: options.settings,\n\t\t\tstoreDir,\n\t\t\tsignal: options.signal,\n\t\t\tpendingMappings: pending === undefined ? [] : [pending],\n\t\t\tkeepInPlace: new Set(\n\t\t\t\t[...currentWorktreeSnapshots(withMapping(sessionManager, pending)).keys()].filter(\n\t\t\t\t\t(root) => !restoring.has(root),\n\t\t\t\t),\n\t\t\t),\n\t\t});\n\t\tif (resumed.status === \"restored\") outcome.restored.push(...resumed.mappings);\n\t};\n\tawait restore(plan.required, reused);\n\tfor (const target of plan.optional) {\n\t\ttry {\n\t\t\tawait restore([target], undefined);\n\t\t} catch (error) {\n\t\t\tif (options.signal?.aborted || !isCheckoutFailure(error)) throw error;\n\t\t\toutcome.failed.push(\n\t\t\t\tnotRestored(\n\t\t\t\t\ttarget.root,\n\t\t\t\t\ttarget.snapshot,\n\t\t\t\t\t`${absentOrChanged(target)}, and restoring it failed: ${describeFailure(error)}`,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\treturn outcome;\n}\n\n/**\n * Builds the blueprints of the worktrees Atomic restored for the session: each worktree this resume restored\n * (`restoredNow`), and again each worktree restored earlier whose last build failed or never finished. Later changes\n * to an earlier worktree's files are the session's own work. Every other checkout the session works in is only\n * described to the agent.\n */\nasync function setUpCheckoutBlueprints(\n\tsessionManager: SessionManager,\n\trestoredNow: ReadonlySet<string>,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<ResumedBlueprints> {\n\tif (options.blueprints === \"skip\") return SKIPPED_BLUEPRINTS;\n\tconst restoredHere: BlueprintCheckout[] = [];\n\tconst earlier: BlueprintCheckout[] = [];\n\tconst inPlace: BlueprintCheckout[] = [];\n\tfor (const [root, snapshot] of currentWorktreeSnapshots(sessionManager)) {\n\t\tconst checkout = checkoutOf(sessionManager, root, snapshot);\n\t\tif (restoredNow.has(root)) restoredHere.push(checkout);\n\t\telse if (isInside(storeDir, root)) earlier.push(checkout);\n\t\telse if (await isDirectory(root)) inPlace.push(checkout);\n\t}\n\tconst retried = await checkoutsNeedingRebuild(earlier, storeDir);\n\treturn setUpResumedBlueprints({\n\t\trestored: [...restoredHere, ...retried],\n\t\tinPlace,\n\t\tearlier: earlier.filter((checkout) => !retried.includes(checkout)),\n\t\tconfig: { ...options.blueprint, storeDir },\n\t\tsignal: options.signal,\n\t});\n}\n\n/**\n * Whether the repository of the checkout at `root` holds the commit that records `snapshot`. That commit is\n * content-addressed and written only where Atomic captured exactly that state, so it tells the checkout a session\n * worked in, even after it changed, from another checkout of the same repository at the same path on another node,\n * unless Atomic captured the same state there too. A checkout that is not a repository, or a node without Git, does\n * not hold it.\n */\nexport async function holdsSnapshotCommit(\n\tsnapshot: WorktreeSnapshot,\n\troot: string,\n\tsignal?: AbortSignal,\n): Promise<boolean> {\n\ttry {\n\t\tconst { exitCode } = await runGit([\"cat-file\", \"-e\", `${snapshot.snapshot}^{commit}`], {\n\t\t\tcwd: root,\n\t\t\tsignal,\n\t\t\tallowExitCodes: [1, 128],\n\t\t});\n\t\treturn exitCode === 0;\n\t} catch (error) {\n\t\tif (isGitUnavailableError(error)) return false;\n\t\tthrow error;\n\t}\n}\n\n/**\n * Where a woken session continues. Each checkout it recorded that it worked in on this node stays as it is, since work\n * done in it after the release belongs to the session, and a blueprint build that failed or did not finish in a worktree\n * this node restored for it runs again. Every other checkout, as when it is missing or another clone sits at its path on another\n * node, is prepared as `/resume` prepares it. When every checkout stays, it continues in the directory it last worked\n * in, after the restores it recorded, which `reopen` opens it in.\n */\nexport async function continueSessionWhereItWorked(\n\topened: SessionManager,\n\toptions: PrepareSessionResumeOptions,\n\treopen: (cwd: string) => Promise<SessionManager> = (cwd) => opened.openSessionById(opened.getSessionId(), cwd),\n): Promise<SessionManager> {\n\tconst cwd = mapRestoredPath(opened.getCwd(), opened.getWorktreeRootMappings());\n\tconst checkouts = currentWorktreeSnapshots(opened);\n\tconst own = await checkoutsWorkedHere(checkouts, cwd, options);\n\tif (own.size < checkouts.size) {\n\t\tconst prepared = await prepareSessionResume(opened, { ...options, keepInPlace: own });\n\t\tif (prepared.status !== \"ready\") return opened;\n\t\tif (prepared.blueprintNotices.length > 0) options.onNotices?.(prepared.blueprintNotices);\n\t\treturn prepared.sessionManager;\n\t}\n\tconst storeDir = resolveStoreDir(options);\n\tif (checkouts.size === 0) {\n\t\tawait describeBlueprintsInPlace(opened, storeDir, options);\n\t} else {\n\t\tconst blueprints = await setUpCheckoutBlueprints(opened, new Set(), storeDir, options);\n\t\tawait recordBlueprintContext(opened, blueprints.context);\n\t\tif (blueprints.notices.length > 0) options.onNotices?.(blueprints.notices);\n\t}\n\treturn cwd === resolve(opened.getCwd()) ? opened : reopen(cwd);\n}\n\n/**\n * The roots of the `checkouts` a session recorded that are here as checkouts it worked in on this node, as it left them\n * or changed since: a worktree this node restored for it, or a checkout whose repository holds the commit of its latest\n * snapshot. The checkout the session works in counts only while its working directory `cwd` is here too.\n */\nasync function checkoutsWorkedHere(\n\tcheckouts: ReadonlyMap<string, WorktreeSnapshot>,\n\tcwd: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<Set<string>> {\n\tconst storeDir = resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n\tconst own = new Set<string>();\n\tfor (const [root, snapshot] of checkouts) {\n\t\tif (!existsSync(isInside(root, cwd) ? cwd : root)) continue;\n\t\tif (isInside(storeDir, root) || (await holdsSnapshotCommit(snapshot, root, options.signal))) own.add(root);\n\t}\n\treturn own;\n}\n\n/**\n * Whether resuming in `root` restores `snapshot` into a fresh worktree: the checkout is gone, is not a repository of\n * the recorded tree, or no longer matches it. A path that cannot be read fails with its typed `unreadable-path` error\n * instead, since restoring would hide it. A checkout whose HEAD only moved forward over the recorded tree, as after\n * committing the recorded edits, continues in place, as #4245's resume decides. Read-only.\n */\nexport async function worktreeNeedsRestore(\n\tsnapshot: WorktreeSnapshot,\n\troot: string,\n\toptions: VerifyWorktreeOptions,\n): Promise<boolean> {\n\ttry {\n\t\tawait verifyWorktree(snapshot, root, options);\n\t\treturn false;\n\t} catch (error) {\n\t\tif (isWorkspaceDriftError(error)) return !(await isHeadOnlyAdvance(error, options.signal));\n\t\tif (isWorkspaceSnapshotError(error) && error.code !== \"unreadable-path\") return true;\n\t\tthrow error;\n\t}\n}\n\n/** The outcome of starting or provisioning Git once for a resume: the typed reason it cannot run, or undefined. */\ninterface GitProbe {\n\treadonly unavailable: GitUnavailableError | undefined;\n}\n\n/**\n * Decides what the resume does about the `candidates` that are gone or changed here, before anything is written. The\n * precondition of restoring them on this node is that Git can be started or provisioned (`git`, the probe's typed\n * failure). When it is unmet and the session works in a checkout that must be restored, the resume is refused; for any\n * other checkout it leaves that checkout out, with a warning. A blueprint is never a precondition.\n */\nfunction planRestores(\n\tsessionManager: SessionManager,\n\tcandidates: { readonly targets: readonly RestoreTarget[]; readonly left: ReadonlyMap<string, ResumeNotice> },\n\toptions: PrepareSessionResumeOptions,\n\tgit: GitUnavailableError | undefined,\n): RestorePlan {\n\tconst required = candidates.targets.filter((target) => target.runsHere);\n\tconst others = candidates.targets.filter((target) => !target.runsHere);\n\tif (required.length > 0 && git !== undefined) {\n\t\tthrow preconditionFailure(sessionManager, [...required, ...others], options, git);\n\t}\n\tconst left = new Map(candidates.left);\n\tconst optional: RestoreTarget[] = [];\n\tfor (const target of others) {\n\t\tif (git) {\n\t\t\tleft.set(\n\t\t\t\ttarget.root,\n\t\t\t\tnotRestored(\n\t\t\t\t\ttarget.root,\n\t\t\t\t\ttarget.snapshot,\n\t\t\t\t\t`${absentOrChanged(target)}, and Git is unavailable here (${git.code}), which restoring it needs`,\n\t\t\t\t),\n\t\t\t);\n\t\t} else {\n\t\t\toptional.push(target);\n\t\t}\n\t}\n\treturn { required, optional, left };\n}\n\n/** The refusal to resume because `targets` cannot be restored here: Git cannot be started or provisioned. */\nfunction preconditionFailure(\n\tsessionManager: SessionManager,\n\ttargets: readonly RestoreTarget[],\n\toptions: PrepareSessionResumeOptions,\n\tgit: GitUnavailableError,\n): ResumePreconditionError {\n\tconst reasons = targets.map(\n\t\t(target) =>\n\t\t\t`snapshot ${target.snapshot.id.slice(0, 12)} because ${target.root} ${target.absent ? \"does not exist on this node\" : \"no longer matches it\"}`,\n\t);\n\tconst problems = [\n\t\tgitUnavailableProblem(\n\t\t\tgit,\n\t\t\t`session ${sessionManager.getSessionId()} must be restored from ${reasons.join(\", and from \")}`,\n\t\t),\n\t];\n\treturn new ResumePreconditionError({ entryPoint: options.entryPoint, problems }, git);\n}\n\n/**\n * Whether a restored worktree is trusted to run its blueprints outside the CLI: the decision saved in `agentDir` for\n * that path, else the default trust setting.\n */\nexport function savedProjectTrust(\n\tagentDir: string,\n\tsettings: Pick<SettingsManager, \"getDefaultProjectTrust\">,\n): (worktree: string) => boolean {\n\tconst trustStore = new ProjectTrustStore(agentDir);\n\treturn (worktree) => trustStore.get(worktree) ?? settings.getDefaultProjectTrust() === \"always\";\n}\n\n/** Where restored worktrees, the blueprint build ledger and logs live for the agent directory `agentDir`. */\nexport function resumeStoreDir(agentDir: string): string {\n\treturn join(agentDir, \"worktree-snapshots\");\n}\n\nfunction resolveStoreDir(options: Pick<PrepareSessionResumeOptions, \"storeDir\">): string {\n\treturn resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n}\n\n/**\n * The options a resume from `launchCwd` needs: snapshot settings and the blueprint build configuration from\n * `settingsManager`, and the worktree store of `agentDir`.\n */\nexport function sessionResumeOptions(\n\tentryPoint: ResumeEntryPoint,\n\tlaunchCwd: string,\n\tagentDir: string,\n\tsettingsManager: Pick<SettingsManager, \"getWorktreeSnapshotSettings\" | \"getResumeSetupCommand\">,\n\ttrusted: (worktree: string) => boolean,\n): PrepareSessionResumeOptions {\n\treturn {\n\t\tentryPoint,\n\t\tlaunchCwd,\n\t\tsettings: settingsManager.getWorktreeSnapshotSettings(),\n\t\tblueprint: { agentDir, setupCommand: settingsManager.getResumeSetupCommand(), trusted },\n\t\tstoreDir: resumeStoreDir(agentDir),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"session-resume.js","sourceRoot":"","sources":["../../../src/core/resume/session-resume.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAA4B,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE9D,OAAO,EACN,wBAAwB,EACxB,yBAAyB,EAEzB,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,GACrB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iCAAi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BAA2B,EAAE;QACvD,SAAS,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,CAAC,qBAAqB,EAAE,EAAE,OAAO,EAAE;QACvF,QAAQ,EAAE,cAAc,CAAC,QAAQ,CAAC;KAClC,CAAC;AACH,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { stat } from \"node:fs/promises\";\nimport { join, relative, resolve } from \"node:path\";\nimport { type GitUnavailableError, isGitUnavailableError } from \"../../utils/git-errors.ts\";\nimport { failureDebugFields, reportDebug } from \"../debug.ts\";\nimport type { SessionManager } from \"../session-manager.ts\";\nimport {\n\tcurrentWorktreeSnapshots,\n\tformatMissingRecordNotice,\n\ttype MissingSnapshotRecord,\n\tmapRestoredPath,\n\tmissingSnapshotRecords,\n\topenResumedSession,\n\tresumeSessionWorktree,\n} from \"../session-worktree-snapshots.ts\";\nimport type { SettingsManager } from \"../settings-manager.ts\";\nimport { ProjectTrustStore } from \"../trust-manager.ts\";\nimport { locateCheckout, readRepositoryConfig } from \"../worktree-snapshot/capture.ts\";\nimport {\n\tisWorkspaceConfigError,\n\tisWorkspaceDriftError,\n\tisWorkspaceSnapshotError,\n} from \"../worktree-snapshot/errors.ts\";\nimport { gitText, runGit } from \"../worktree-snapshot/git.ts\";\nimport { isHeadOnlyAdvance } from \"../worktree-snapshot/head-advance.ts\";\nimport {\n\tdefaultWorktreeSnapshotStoreDir,\n\ttype VerifyWorktreeOptions,\n\tverifyWorktree,\n} from \"../worktree-snapshot/restore.ts\";\nimport type {\n\tWorktreeRootMapping,\n\tWorktreeSnapshot,\n\tWorktreeSnapshotSettings,\n\tWorktreeUnrestored,\n} from \"../worktree-snapshot/types.ts\";\nimport type { BlueprintBuildConfig } from \"./blueprint/build.ts\";\nimport {\n\ttype BlueprintCheckout,\n\tcheckoutsNeedingRebuild,\n\tenclosingRepositoryRoot,\n\tinheritedRemotes,\n\ttype ResumedBlueprints,\n\trecordBlueprintContext,\n\tsetUpResumedBlueprints,\n} from \"./blueprint/resume.ts\";\nimport { isResumePreconditionError, type ResumeEntryPoint } from \"./errors.ts\";\nimport { isResumeFailure } from \"./failure.ts\";\nimport { isInside } from \"./path-mapping.ts\";\nimport { defaultResumePreflightIo, type ResumePreflightIo } from \"./preflight.ts\";\n\n/** What to do when the checkout a resume was started in belongs to the session's repository but differs from it. */\nexport type DirtyCheckoutChoice = \"restore\" | \"use\" | \"cancel\";\n\nexport interface DirtyCheckoutPrompt {\n\t/** Root of the user's checkout the resume was started in. */\n\treadonly checkout: string;\n\t/** Root the session recorded, on the node that recorded it. */\n\treadonly recordedRoot: string;\n\treadonly snapshotId: string;\n}\n\nexport interface ResumeNotice {\n\treadonly type: \"info\" | \"warning\";\n\treadonly message: string;\n}\n\nexport interface PrepareSessionResumeOptions {\n\treadonly entryPoint: ResumeEntryPoint;\n\t/** Where the resume was started: the requested target when it is a checkout of the session's repository. */\n\treadonly launchCwd: string;\n\treadonly settings: WorktreeSnapshotSettings;\n\t/** How the blueprints of worktrees this resume restores are built; the store directory is `storeDir`. */\n\treadonly blueprint: Omit<BlueprintBuildConfig, \"storeDir\">;\n\t/** Host directory for restored worktrees. Default ~/.atomic/agent/worktree-snapshots. */\n\treadonly storeDir?: string;\n\t/** Asks the user about a dirty checkout. Without it a fresh worktree is restored, which overwrites nothing. */\n\treadonly chooseDirtyCheckout?: (prompt: DirtyCheckoutPrompt) => Promise<DirtyCheckoutChoice>;\n\treadonly io?: ResumePreflightIo;\n\t/** Session directory to reopen a moved session in, for stores that keep sessions per directory. */\n\treadonly sessionDirectory?: string;\n\treadonly signal?: AbortSignal;\n\t/**\n\t * Checkouts the session continues in as they are, by the root its recorded restores put them at: never verified and\n\t * never restored, as for checkouts it worked in on this node and changed since.\n\t */\n\treadonly keepInPlace?: ReadonlySet<string>;\n\t/**\n\t * `\"skip\"` restores checkouts but builds and describes no blueprint and records no blueprint context: for a process\n\t * that serves a resume another process of the same user-level action already prepared and built, so one resume\n\t * builds once. Default `\"build\"`.\n\t */\n\treadonly blueprints?: \"build\" | \"skip\";\n\t/**\n\t * Told the warnings of the blueprint builds a resume ran when its caller gets only a session back, as when a\n\t * released session is woken ({@link continueSessionWhereItWorked}).\n\t */\n\treadonly onNotices?: (notices: readonly ResumeNotice[]) => void;\n\t/** Told each slow step the resume starts (checking checkouts, restoring one, building blueprints), for a progress line. */\n\treadonly onProgress?: (message: string) => void;\n}\n\nexport type PreparedSessionResume =\n\t| { readonly status: \"cancelled\" }\n\t| {\n\t\t\treadonly status: \"ready\";\n\t\t\t/** The session opened where it continues: the one passed in when its cwd did not change. */\n\t\t\treadonly sessionManager: SessionManager;\n\t\t\treadonly notices: readonly ResumeNotice[];\n\t\t\t/** The warnings of the blueprint builds this resume ran, also in `notices`. */\n\t\t\treadonly blueprintNotices: readonly ResumeNotice[];\n\t\t\t/** The blueprint context the session's next turn carries, already recorded in it; undefined when none. */\n\t\t\treadonly blueprintContext: string | undefined;\n\t };\n\nasync function isDirectory(path: string): Promise<boolean> {\n\ttry {\n\t\treturn (await stat(path)).isDirectory();\n\t} catch (error) {\n\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\tif (code === \"ENOENT\" || code === \"ENOTDIR\") return false;\n\t\tthrow error;\n\t}\n}\n\nexport interface SessionSnapshotMatch {\n\treadonly root: string;\n\treadonly snapshot: WorktreeSnapshot;\n\t/** The session cwd after the session's recorded restores. */\n\treadonly cwd: string;\n}\n\n/** The latest snapshot of the checkout the session works in, the same one #4245's resume verifies. */\nexport function latestSessionSnapshot(\n\tsessionManager: Pick<SessionManager, \"getCwd\" | \"getWorktreeRootMappings\" | \"getLatestWorktreeSnapshots\">,\n): SessionSnapshotMatch | undefined {\n\tconst cwd = mapRestoredPath(sessionManager.getCwd(), sessionManager.getWorktreeRootMappings());\n\tlet match: SessionSnapshotMatch | undefined;\n\tfor (const [root, snapshot] of sessionManager.getLatestWorktreeSnapshots()) {\n\t\tif (isInside(root, cwd) && (!match || root.length > match.root.length)) match = { root, snapshot, cwd };\n\t}\n\treturn match;\n}\n\n/** Continue in the launch checkout, or stop because the user cancelled; undefined restores a fresh worktree. */\ntype CheckoutReuse =\n\t| {\n\t\t\treadonly kind: \"reused\";\n\t\t\treadonly cwd: string;\n\t\t\t/** Whether the checkout matched the snapshot, rather than being used as it is by the user's choice. */\n\t\t\treadonly matches: boolean;\n\t\t\treadonly notice: ResumeNotice;\n\t\t\t/** The recorded root mapped onto the checkout, recorded once nothing else stops the resume. */\n\t\t\treadonly mapping: WorktreeRootMapping;\n\t }\n\t| { readonly kind: \"cancelled\" }\n\t| undefined;\n\n/**\n * Continues in the checkout the resume started in when it is a checkout of the session's repository: as-is when its\n * tree matches the snapshot (or only its HEAD moved forward over it); when it differs and has local changes, only if\n * the user says so. A clean checkout that differs is left alone and a fresh worktree is restored instead. Returns the\n * mapping that makes paths follow, for the caller to record.\n */\nasync function reuseLaunchCheckout(\n\tmatch: SessionSnapshotMatch,\n\toptions: PrepareSessionResumeOptions,\n): Promise<CheckoutReuse> {\n\tconst checkout = await locateCheckout(options.launchCwd, options.signal).catch((error: unknown) => {\n\t\tif (isWorkspaceSnapshotError(error)) return error;\n\t\tthrow error;\n\t});\n\tif (checkout instanceof Error) return undefined;\n\tconst root = resolve(checkout.root);\n\tconst { remotes } = await readRepositoryConfig(root, options.signal);\n\tif (!remotes.some((remote) => match.snapshot.remotes.includes(remote))) return undefined;\n\tlet matches = true;\n\ttry {\n\t\tawait verifyWorktree(match.snapshot, root, { settings: options.settings, signal: options.signal });\n\t} catch (error) {\n\t\tif (!isWorkspaceDriftError(error)) throw error;\n\t\tmatches = await isHeadOnlyAdvance(error, options.signal);\n\t}\n\tif (!matches) {\n\t\tif (!(await hasLocalChanges(root, options.signal))) return undefined;\n\t\tconst choice = options.chooseDirtyCheckout\n\t\t\t? await options.chooseDirtyCheckout({\n\t\t\t\t\tcheckout: root,\n\t\t\t\t\trecordedRoot: match.root,\n\t\t\t\t\tsnapshotId: match.snapshot.id,\n\t\t\t\t})\n\t\t\t: \"restore\";\n\t\tif (choice === \"cancel\") return { kind: \"cancelled\" };\n\t\tif (choice === \"restore\") return undefined;\n\t}\n\tconst mapping: WorktreeRootMapping = {\n\t\tfrom: match.root,\n\t\tto: root,\n\t\tsnapshotId: match.snapshot.id,\n\t\ttree: match.snapshot.tree,\n\t\trestoredAt: new Date().toISOString(),\n\t};\n\treturn {\n\t\tkind: \"reused\",\n\t\tcwd: resolve(root, relative(match.root, match.cwd)),\n\t\tmatches,\n\t\tmapping,\n\t\tnotice: matches\n\t\t\t? {\n\t\t\t\t\ttype: \"info\",\n\t\t\t\t\tmessage: `Resuming in ${root}, which matches snapshot ${match.snapshot.id.slice(0, 12)} of ${match.root}`,\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tmessage: `Resuming in ${root}, which differs from snapshot ${match.snapshot.id.slice(0, 12)} of ${match.root}`,\n\t\t\t\t},\n\t};\n}\n\n/**\n * Moves a session that a resume restored into a worktree, and that has not worked in it since, back to the checkout it\n * was restored from, when that checkout is on this node and its repository holds the snapshot's commit (#4660). The\n * session continues there as the checkout is now, even when it changed since the snapshot. Undefined keeps the session\n * in its worktree: the worktree is not one Atomic restored, it changed or recorded another snapshot since, or the\n * checkout it came from is gone or is another clone.\n */\nasync function returnToStartingCheckout(\n\tsessionManager: SessionManager,\n\tmatch: SessionSnapshotMatch,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<Extract<CheckoutReuse, { kind: \"reused\" }> | undefined> {\n\tif (!isInside(storeDir, match.root)) return undefined;\n\tconst restore = [...sessionManager.getWorktreeRootMappings()]\n\t\t.reverse()\n\t\t.find((mapping) => resolve(mapping.to) === resolve(match.root));\n\tif (restore === undefined || restore.snapshotId !== match.snapshot.id) return undefined;\n\tconst checkout = resolve(restore.from);\n\tconst cwd = resolve(checkout, relative(match.root, match.cwd));\n\tif (isInside(storeDir, checkout) || !existsSync(cwd)) return undefined;\n\t// When the checkout cannot be examined, the project the session started in is still where it goes back to.\n\tconst examined = await orFallBack(options, \"return-to-checkout-verify\", undefined, async () => ({\n\t\tholdsCommit: await holdsSnapshotCommit(match.snapshot, checkout, options.signal),\n\t\tmatches: !(await worktreeNeedsRestore(match.snapshot, checkout, options)),\n\t}));\n\tif (examined !== undefined && !examined.holdsCommit) return undefined;\n\tconst matches = examined?.matches;\n\tconst snapshotId = match.snapshot.id.slice(0, 12);\n\treturn {\n\t\tkind: \"reused\",\n\t\tcwd,\n\t\tmatches: matches ?? false,\n\t\tmapping: {\n\t\t\tfrom: match.root,\n\t\t\tto: checkout,\n\t\t\tsnapshotId: match.snapshot.id,\n\t\t\ttree: match.snapshot.tree,\n\t\t\trestoredAt: new Date().toISOString(),\n\t\t},\n\t\tnotice: {\n\t\t\ttype: \"info\",\n\t\t\tmessage: `Resuming in ${checkout}, the checkout this session was restored from, instead of the worktree ${match.root}.${matches === undefined ? \"\" : matches ? ` It matches snapshot ${snapshotId}.` : ` It has changed since snapshot ${snapshotId}; that snapshot was not restored.`}`,\n\t\t},\n\t};\n}\n\n/**\n * Runs an optional improvement of where a resume continues. When it fails on a checkout, with a typed resume,\n * workspace or Git failure, the resume goes on with `fallback`, the behaviour it had without the improvement; the\n * reason goes to the debug log. A cancellation, and any failure that is not about a checkout, still end the resume.\n */\nasync function orFallBack<T>(\n\toptions: Pick<PrepareSessionResumeOptions, \"signal\">,\n\tstep: string,\n\tfallback: T,\n\tattempt: () => Promise<T>,\n): Promise<T> {\n\ttry {\n\t\treturn await attempt();\n\t} catch (error) {\n\t\tif (options.signal?.aborted || !isCheckoutFailure(error)) throw error;\n\t\treportDebug(\"storage\", \"resume-checkout-fallback\", { step, ...failureDebugFields(error) });\n\t\treturn fallback;\n\t}\n}\n\n/** Whether the checkout at `root` has uncommitted or untracked changes, which a resume must not overwrite unasked. */\nasync function hasLocalChanges(root: string, signal: AbortSignal | undefined): Promise<boolean> {\n\treturn (await gitText([\"status\", \"--porcelain\"], { cwd: root, signal })).length > 0;\n}\n\n/**\n * Gets a resumed session's checkouts ready on this node before its runtime starts, and returns the session opened\n * where it continues. When the checkout the session works in changed here but is still the one it worked in (its\n * repository holds the snapshot's commit, or Atomic restored it here), the session continues in it as it is, silently\n * (#4660). A session a resume moved into a restored worktree, and that has not worked in it since, returns to\n * the checkout it was restored from when that checkout is here. When the checkout the session works in is missing or\n * belongs to another clone here, a checkout of the same\n * repository the resume started in is used as-is if it matches (and, if it differs, only when the user chooses it).\n * Resume always opens the session (#4733): a checkout whose snapshot cannot be restored exactly gets the best state\n * this node can reach, its recorded commit with the change sets that apply or the closest commit it can fetch, and one\n * notice saying what is missing; when nothing of it can be restored, Git being unavailable included, the session\n * continues in its recorded directory, or the directory the resume started from when that is not here, with the same\n * kind of notice. Only a snapshot record that fails the security checks, or a restore target that holds other files,\n * refuses the resume. Every other checkout the session recorded that is gone or changed here, except\n * those in `keepInPlace`, never blocks the resume: one the session worked in on this node, changed since, continues as\n * it is; the rest are restored into fresh worktrees one by one by #4245's {@link resumeSessionWorktree}, and one that\n * cannot be (Git is unavailable, or its restore fails) is left out with a warning that names its path and why. Each\n * worktree Atomic restored then gets its blueprints built (#4588): a failing step is a warning in `notices` and never\n * stops the resume. The agent gets the blueprints' maintenance and knowledge in the session's next turn. The session's\n * tools resolve paths under every root it recorded into the place that root was restored.\n */\nexport async function prepareSessionResume(\n\tsessionManager: SessionManager,\n\toptions: PrepareSessionResumeOptions,\n): Promise<PreparedSessionResume> {\n\tconst io = options.io ?? defaultResumePreflightIo;\n\tconst storeDir = resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n\tif (!options.settings.enabled || sessionManager.getLatestWorktreeSnapshots().size === 0) {\n\t\tconst missing = options.settings.enabled ? missingSnapshotRecords(sessionManager) : [];\n\t\tif (missing.length > 0) return continueWithoutRecords(sessionManager, missing, storeDir, options);\n\t\tconst unchanged = await describeBlueprintsInPlace(sessionManager, storeDir, options);\n\t\treturn { status: \"ready\", sessionManager, notices: [], blueprintNotices: [], blueprintContext: unchanged };\n\t}\n\tconst notices: ResumeNotice[] = [];\n\tconst checkoutCount = currentWorktreeSnapshots(sessionManager).size;\n\toptions.onProgress?.(\n\t\t`Checking ${checkoutCount === 1 ? \"1 checkout\" : `${checkoutCount} checkouts`} against the session's snapshots`,\n\t);\n\tconst verified = new Map<string, Promise<boolean>>();\n\tconst verifyOnce = (snapshot: WorktreeSnapshot, root: string): Promise<boolean> => {\n\t\tconst key = `${snapshot.id}\\0${resolve(root)}`;\n\t\tlet verification = verified.get(key);\n\t\tif (verification === undefined) {\n\t\t\tverification = worktreeNeedsRestore(snapshot, root, options);\n\t\t\tverified.set(key, verification);\n\t\t}\n\t\treturn verification;\n\t};\n\t// Which partly restored worktrees are still as the restore left them, compared once per resume.\n\tlet partialOnce: Promise<Set<string>> | undefined;\n\tconst partial = (): Promise<Set<string>> => {\n\t\tpartialOnce ??= partialRestores(sessionManager, options);\n\t\treturn partialOnce;\n\t};\n\tconst match = latestSessionSnapshot(sessionManager);\n\tlet git: GitProbe | undefined;\n\tlet reused: WorktreeRootMapping | undefined;\n\tlet needsRestore: boolean;\n\ttry {\n\t\tneedsRestore =\n\t\t\tmatch !== undefined && !options.keepInPlace?.has(match.root) && (await verifyOnce(match.snapshot, match.root));\n\t} catch (error) {\n\t\tif (!isGitUnavailableError(error)) throw error;\n\t\treturn continueWithoutGit(sessionManager, error, storeDir, options);\n\t}\n\tconst project =\n\t\tmatch !== undefined && !needsRestore && !options.keepInPlace?.has(match.root)\n\t\t\t? await orFallBack(options, \"return-to-checkout\", undefined, () =>\n\t\t\t\t\treturnToStartingCheckout(sessionManager, match, storeDir, options),\n\t\t\t\t)\n\t\t\t: undefined;\n\tif (project !== undefined) {\n\t\tawait recordReuse(sessionManager, project.mapping);\n\t\tnotices.push(project.notice);\n\t}\n\tconst keepsOwnCheckout =\n\t\tmatch !== undefined &&\n\t\tproject === undefined &&\n\t\tneedsRestore &&\n\t\t(await isDirectory(match.root)) &&\n\t\t(await orFallBack(options, \"own-checkout\", new Set([match.root]), async () =>\n\t\t\tcheckoutsWorkedHere(new Map([[match.root, match.snapshot]]), match.cwd, options, await partial()),\n\t\t).then((worked) => worked.has(match.root)));\n\t// The checkout the session returned to stays as it is, whatever it changed since: only the others are restored.\n\tconst kept = [...(keepsOwnCheckout && match !== undefined ? [match.root] : [])];\n\tif (project !== undefined && match !== undefined) kept.push(match.root, project.mapping.to);\n\tconst resume: PrepareSessionResumeOptions =\n\t\tkept.length > 0 ? { ...options, keepInPlace: new Set([...(options.keepInPlace ?? []), ...kept]) } : options;\n\tif (match !== undefined && !keepsOwnCheckout && needsRestore) {\n\t\tgit = { unavailable: await io.probeGit(options.signal) };\n\t\tconst reuse = git.unavailable === undefined ? await reuseLaunchCheckout(match, options) : undefined;\n\t\tif (reuse?.kind === \"cancelled\") return { status: \"cancelled\" };\n\t\tif (reuse?.kind === \"reused\" && !reuse.matches) {\n\t\t\tawait recordReuse(sessionManager, reuse.mapping);\n\t\t\treturn continueInChosenCheckout(sessionManager, reuse, storeDir, options);\n\t\t}\n\t\tif (reuse?.kind === \"reused\") {\n\t\t\treused = reuse.mapping;\n\t\t\tnotices.push(reuse.notice);\n\t\t}\n\t}\n\tconst checkouts = withMapping(sessionManager, reused);\n\tconst candidates = await restoreCandidates(\n\t\tcheckouts,\n\t\tmapRestoredPath(sessionManager.getCwd(), checkouts.getWorktreeRootMappings()),\n\t\tresume,\n\t\tverifyOnce,\n\t\tpartial,\n\t);\n\tif (candidates.targets.length > 0) git ??= { unavailable: await io.probeGit(options.signal) };\n\tconst plan = planRestores(candidates, git?.unavailable);\n\tnotices.push(...plan.left.values());\n\tconst recordedBefore = sessionManager.getWorktreeRootMappings().length;\n\tconst resumed = await restorePlanned(sessionManager, plan, reused, storeDir, resume);\n\tconst cwd = resumed.cwd ?? mapRestoredPath(sessionManager.getCwd(), sessionManager.getWorktreeRootMappings());\n\tconst opened = await openResumedSession(\n\t\tsessionManager,\n\t\tcwd,\n\t\tresumed.restored,\n\t\toptions.sessionDirectory,\n\t\tresumed.unrestored,\n\t);\n\tnotices.push(...opened.notices, ...resumed.failed);\n\tconst restoredNow = new Set(\n\t\topened.sessionManager\n\t\t\t.getWorktreeRootMappings()\n\t\t\t.slice(recordedBefore)\n\t\t\t.map((mapping) => resolve(mapping.to))\n\t\t\t.filter((root) => isInside(storeDir, root)),\n\t);\n\tif (restoredNow.size > 0 && options.blueprints !== \"skip\") {\n\t\toptions.onProgress?.(\"Setting up the blueprints of restored worktrees\");\n\t}\n\tconst blueprints = await setUpCheckoutBlueprints(opened.sessionManager, restoredNow, storeDir, options);\n\tnotices.push(...blueprints.notices);\n\tawait recordBlueprintContext(opened.sessionManager, blueprints.context);\n\treturn {\n\t\tstatus: \"ready\",\n\t\tsessionManager: opened.sessionManager,\n\t\tnotices,\n\t\tblueprintNotices: blueprints.notices,\n\t\tblueprintContext: blueprints.context,\n\t};\n}\n\n/**\n * Opens a session whose checkouts cannot even be compared with their snapshots, because Git cannot run here (#4733):\n * it continues in its recorded directory as it is, or in the directory the resume started from when that is not\n * here, without restoring any checkout, and each is recorded as left out with a notice. Nothing is written to any\n * checkout.\n */\nasync function continueWithoutGit(\n\tsessionManager: SessionManager,\n\tgit: GitUnavailableError,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<PreparedSessionResume> {\n\tconst roots = [...currentWorktreeSnapshots(sessionManager).keys()].filter((root) => !options.keepInPlace?.has(root));\n\tconst resumed = await resumeSessionWorktree(sessionManager, {\n\t\tsettings: options.settings,\n\t\tstoreDir,\n\t\tsignal: options.signal,\n\t\tkeepInPlace: options.keepInPlace,\n\t\tcannotRestore: new Map(roots.map((root) => [root, git])),\n\t\tfallbackCwd: options.launchCwd,\n\t\tskipMissingRecords: true,\n\t});\n\tconst cwd = resumed.status === \"none\" ? sessionManager.getCwd() : resumed.cwd;\n\tconst opened = await openResumedSession(\n\t\tsessionManager,\n\t\tcwd,\n\t\t[],\n\t\toptions.sessionDirectory,\n\t\tresumed.status === \"none\" ? [] : resumed.unrestored.map((checkout) => checkout.record),\n\t);\n\tconst context = await describeBlueprintsInPlace(opened.sessionManager, storeDir, options);\n\treturn {\n\t\tstatus: \"ready\",\n\t\tsessionManager: opened.sessionManager,\n\t\tnotices: [\n\t\t\t...opened.notices,\n\t\t\t...(resumed.missingRecords ?? []).map((missing) => ({\n\t\t\t\ttype: \"warning\" as const,\n\t\t\t\tmessage: formatMissingRecordNotice(missing),\n\t\t\t})),\n\t\t],\n\t\tblueprintNotices: [],\n\t\tblueprintContext: context,\n\t};\n}\n\n/**\n * Opens a session whose every recorded checkout refers to a snapshot the session holds no record of (#4733): nothing\n * can be restored, so it continues in its recorded directory, or the directory the resume started from when that is\n * not here, with one notice per checkout.\n */\nasync function continueWithoutRecords(\n\tsessionManager: SessionManager,\n\tmissing: readonly MissingSnapshotRecord[],\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<PreparedSessionResume> {\n\tconst recorded = mapRestoredPath(sessionManager.getCwd(), sessionManager.getWorktreeRootMappings());\n\tconst cwd = existsSync(recorded) ? recorded : resolve(options.launchCwd);\n\tconst opened = await openResumedSession(sessionManager, cwd, [], options.sessionDirectory);\n\tconst context = await describeBlueprintsInPlace(opened.sessionManager, storeDir, options);\n\treturn {\n\t\tstatus: \"ready\",\n\t\tsessionManager: opened.sessionManager,\n\t\tnotices: missing.map((record) => ({ type: \"warning\" as const, message: formatMissingRecordNotice(record) })),\n\t\tblueprintNotices: [],\n\t\tblueprintContext: context,\n\t};\n}\n\nconst SKIPPED_BLUEPRINTS: ResumedBlueprints = { outcome: undefined, notices: [], layers: [], context: undefined };\n\n/**\n * The blueprint context of a session that has no worktree snapshots to restore: what its working directory's\n * repository and the global blueprint say, recorded in the session. No build runs and no Git command is started.\n */\nasync function describeBlueprintsInPlace(\n\tsessionManager: SessionManager,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<string | undefined> {\n\tif (options.blueprints === \"skip\") return undefined;\n\tconst root = enclosingRepositoryRoot(resolve(sessionManager.getCwd()));\n\tconst blueprints = await setUpResumedBlueprints({\n\t\trestored: [],\n\t\tinPlace: root === undefined ? [] : [{ root, remotes: [] }],\n\t\tconfig: { ...options.blueprint, storeDir },\n\t\tsignal: options.signal,\n\t});\n\tawait recordBlueprintContext(sessionManager, blueprints.context);\n\treturn blueprints.context;\n}\n\n/**\n * Continues in the launch checkout the user chose although it differs from the snapshot. #4245's resume would restore\n * a fresh worktree over that choice, so no other checkout is restored either; the notice names those left out.\n */\nasync function continueInChosenCheckout(\n\tsessionManager: SessionManager,\n\treuse: Extract<CheckoutReuse, { kind: \"reused\" }>,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<PreparedSessionResume> {\n\tconst notices: ResumeNotice[] = [reuse.notice];\n\tfor (const [root, snapshot] of currentWorktreeSnapshots(sessionManager)) {\n\t\tif (!(await isDirectory(root))) {\n\t\t\tnotices.push(\n\t\t\t\tnotRestored(\n\t\t\t\t\troot,\n\t\t\t\t\tsnapshot,\n\t\t\t\t\t\"it does not exist on this node, and the session continues in the checkout you chose, which restores nothing else\",\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\tconst reopened = await sessionManager.openSessionById(\n\t\tsessionManager.getSessionId(),\n\t\treuse.cwd,\n\t\toptions.sessionDirectory,\n\t);\n\tconst blueprints =\n\t\toptions.blueprints === \"skip\"\n\t\t\t? SKIPPED_BLUEPRINTS\n\t\t\t: await setUpResumedBlueprints({\n\t\t\t\t\trestored: [],\n\t\t\t\t\tinPlace: await existingCheckouts(reopened),\n\t\t\t\t\tconfig: { ...options.blueprint, storeDir },\n\t\t\t\t\tsignal: options.signal,\n\t\t\t\t});\n\tawait recordBlueprintContext(reopened, blueprints.context);\n\treturn {\n\t\tstatus: \"ready\",\n\t\tsessionManager: reopened,\n\t\tnotices,\n\t\tblueprintNotices: [],\n\t\tblueprintContext: blueprints.context,\n\t};\n}\n\n/** The session's current checkouts that exist on this node, with the remotes their snapshots recorded. */\nasync function existingCheckouts(sessionManager: SessionCheckouts): Promise<BlueprintCheckout[]> {\n\tconst checkouts: BlueprintCheckout[] = [];\n\tfor (const [root, snapshot] of currentWorktreeSnapshots(sessionManager)) {\n\t\tif (await isDirectory(root)) checkouts.push(checkoutOf(sessionManager, root, snapshot));\n\t}\n\treturn checkouts;\n}\n\n/** The checkout at `root` for the blueprint build, identified by its repository's remotes as the session's restores trace them. */\nfunction checkoutOf(sessionManager: SessionCheckouts, root: string, snapshot: WorktreeSnapshot): BlueprintCheckout {\n\treturn {\n\t\troot,\n\t\tremotes: inheritedRemotes(\n\t\t\troot,\n\t\t\tsnapshot.remotes,\n\t\t\tsessionManager.getWorktreeRootMappings(),\n\t\t\tsessionManager.getWorktreeSnapshotRecords(),\n\t\t),\n\t};\n}\n\n/** A recorded checkout a resume restores, and whether it is missing here or only changed. */\ninterface RestoreTarget {\n\treadonly root: string;\n\treadonly snapshot: WorktreeSnapshot;\n\treadonly absent: boolean;\n\t/** Whether the session's working directory is inside it, so the session cannot continue without it. */\n\treadonly runsHere: boolean;\n}\n\n/** What a resume does about the recorded checkouts that are gone or changed here. */\ninterface RestorePlan {\n\t/** Checkouts the session works in, which the resume restores together or not at all. */\n\treadonly required: readonly RestoreTarget[];\n\t/** Every other checkout the resume restores, each on its own, so that one that cannot be restored is left out. */\n\treadonly optional: readonly RestoreTarget[];\n\t/** The warning for each other checkout the resume continues without restoring, by its root. */\n\treadonly left: ReadonlyMap<string, ResumeNotice>;\n\t/** Why Git cannot run here, when it cannot: the checkouts the session works in are then not restored (#4733). */\n\treadonly git: GitUnavailableError | undefined;\n}\n\n/** Records that the session continues in a checkout already here, so paths follow it. */\nasync function recordReuse(sessionManager: SessionManager, mapping: WorktreeRootMapping): Promise<void> {\n\tawait sessionManager.appendWorktreeSnapshot(mapping.to, mapping.snapshotId, undefined, mapping);\n}\n\ntype SessionCheckouts = Pick<SessionManager, \"getBranch\" | \"getWorktreeRootMappings\" | \"getWorktreeSnapshotRecords\">;\n\n/** The session's checkouts as they are once `mapping`, not yet recorded, is. */\nfunction withMapping(sessionManager: SessionManager, mapping: WorktreeRootMapping | undefined): SessionCheckouts {\n\tif (mapping === undefined) return sessionManager;\n\treturn {\n\t\tgetBranch: () => sessionManager.getBranch(),\n\t\tgetWorktreeSnapshotRecords: () => sessionManager.getWorktreeSnapshotRecords(),\n\t\tgetWorktreeRootMappings: () => [...sessionManager.getWorktreeRootMappings(), mapping],\n\t};\n}\n\n/** The warning that the resume continues without restoring the checkout recorded at `root`, with the reason. */\nfunction notRestored(root: string, snapshot: WorktreeSnapshot, reason: string): ResumeNotice {\n\treturn {\n\t\ttype: \"warning\",\n\t\tmessage: `Continuing without restoring ${root} (snapshot ${snapshot.id.slice(0, 12)}): ${reason}`,\n\t};\n}\n\nfunction absentOrChanged(target: Pick<RestoreTarget, \"absent\">): string {\n\treturn target.absent ? \"it does not exist on this node\" : \"it no longer matches the snapshot\";\n}\n\n/**\n * A failure of one checkout alone, which leaves the session's other checkouts restorable: a typed resume, workspace or\n * Git failure, but not a setting that is wrong for every checkout.\n */\nfunction isCheckoutFailure(error: unknown): error is Error {\n\treturn isResumeFailure(error) && !isWorkspaceConfigError(error);\n}\n\n/** What went wrong in `error`, for a warning: the unmet preconditions' reasons, or its own message, and any failed cleanup. */\nfunction describeFailure(error: Error): string {\n\tconst detail = isResumePreconditionError(error)\n\t\t? error.problems.map((problem) => problem.why).join(\"; \")\n\t\t: error.message;\n\tconst cleanup = (error as Error & { readonly cleanupCause?: unknown }).cleanupCause;\n\treturn cleanup instanceof Error ? `${detail}; removing what it restored also failed: ${cleanup.message}` : detail;\n}\n\n/**\n * The recorded checkouts that are gone or changed here, which #4245's resume restores into fresh worktrees, except\n * those the session continues in as they are. Another checkout than the one the session works in is also left alone,\n * with a warning, when it cannot be compared with its snapshot, or when it is here and the session worked in it on this\n * node, so it continues as it is.\n */\nasync function restoreCandidates(\n\tsessionManager: SessionCheckouts,\n\tcwd: string,\n\toptions: PrepareSessionResumeOptions,\n\tneedsRestore: (snapshot: WorktreeSnapshot, root: string) => Promise<boolean>,\n\tpartial: () => Promise<ReadonlySet<string>>,\n): Promise<{ readonly targets: RestoreTarget[]; readonly left: Map<string, ResumeNotice> }> {\n\tconst targets: RestoreTarget[] = [];\n\tconst left = new Map<string, ResumeNotice>();\n\tconst checkouts = [...currentWorktreeSnapshots(sessionManager)].filter(([root]) => !options.keepInPlace?.has(root));\n\tconst comparisons = await settleBounded(checkouts, VERIFY_CONCURRENCY, ([root, snapshot]) =>\n\t\tneedsRestore(snapshot, root),\n\t);\n\tfor (const [index, [root, snapshot]] of checkouts.entries()) {\n\t\tconst runsHere = isInside(root, cwd);\n\t\tconst comparison = comparisons[index]!;\n\t\tif (comparison.status === \"rejected\") {\n\t\t\tconst error: unknown = comparison.reason;\n\t\t\tif (runsHere || options.signal?.aborted || !isCheckoutFailure(error)) throw error;\n\t\t\tleft.set(root, notRestored(root, snapshot, `it could not be compared with the snapshot: ${error.message}`));\n\t\t\tcontinue;\n\t\t}\n\t\tif (!comparison.value) continue;\n\t\tconst absent = !(await isDirectory(root));\n\t\tif (\n\t\t\t!runsHere &&\n\t\t\t!absent &&\n\t\t\t(await checkoutsWorkedHere(new Map([[root, snapshot]]), cwd, options, await partial())).has(root)\n\t\t) {\n\t\t\tleft.set(\n\t\t\t\troot,\n\t\t\t\tnotRestored(\n\t\t\t\t\troot,\n\t\t\t\t\tsnapshot,\n\t\t\t\t\t\"it changed since the snapshot, and the session worked in it on this node, so it stays as it is\",\n\t\t\t\t),\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\ttargets.push({ root, snapshot, absent, runsHere });\n\t}\n\treturn { targets, left };\n}\n\n/** How many recorded checkouts a resume compares with their snapshots at once. */\nconst VERIFY_CONCURRENCY = 4;\n\n/** `map` over `items`, at most `limit` at a time, each outcome settled in the order of `items`. */\nasync function settleBounded<T, R>(\n\titems: readonly T[],\n\tlimit: number,\n\tmap: (item: T) => Promise<R>,\n): Promise<PromiseSettledResult<R>[]> {\n\tconst outcomes: PromiseSettledResult<R>[] = [];\n\tlet next = 0;\n\tconst work = async (): Promise<void> => {\n\t\twhile (next < items.length) {\n\t\t\tconst index = next++;\n\t\t\ttry {\n\t\t\t\toutcomes[index] = { status: \"fulfilled\", value: await map(items[index]!) };\n\t\t\t} catch (reason) {\n\t\t\t\toutcomes[index] = { status: \"rejected\", reason };\n\t\t\t}\n\t\t}\n\t};\n\tawait Promise.all(Array.from({ length: Math.min(limit, items.length) }, work));\n\treturn outcomes;\n}\n\n/**\n * Restores what `plan` says into fresh worktrees with #4245's {@link resumeSessionWorktree}, recording each restore on\n * `sessionManager`, and returns the mappings it recorded. The checkouts the session works in are restored together,\n * with the mapping to the launch checkout `reused`; one that cannot be restored exactly is restored as far as it can be,\n * or recorded as left out, in `unrestored` (#4733), and only a failure that is not about a checkout refuses the resume.\n * Every other checkout is restored on its own the same way, and one whose restore is refused is reported in `failed`\n * and left out. `cwd` is where the session continues after the restore of the checkouts it works in.\n */\nasync function restorePlanned(\n\tsessionManager: SessionManager,\n\tplan: RestorePlan,\n\treused: WorktreeRootMapping | undefined,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<{\n\trestored: WorktreeRootMapping[];\n\tfailed: ResumeNotice[];\n\tunrestored: WorktreeUnrestored[];\n\tcwd: string | undefined;\n}> {\n\tconst outcome = {\n\t\trestored: [] as WorktreeRootMapping[],\n\t\tfailed: [] as ResumeNotice[],\n\t\tunrestored: [] as WorktreeUnrestored[],\n\t\tcwd: undefined as string | undefined,\n\t\tmissing: new Set<string>(),\n\t};\n\tconst restore = async (targets: readonly RestoreTarget[], pending: WorktreeRootMapping | undefined) => {\n\t\tconst git = plan.git;\n\t\tfor (const target of targets) {\n\t\t\tif (git === undefined) {\n\t\t\t\toptions.onProgress?.(`Restoring ${target.root} from snapshot ${target.snapshot.id.slice(0, 12)}`);\n\t\t\t}\n\t\t}\n\t\tconst restoring = new Set(targets.map((target) => target.root));\n\t\tconst resumed = await resumeSessionWorktree(sessionManager, {\n\t\t\tsettings: options.settings,\n\t\t\tstoreDir,\n\t\t\tsignal: options.signal,\n\t\t\tpendingMappings: pending === undefined ? [] : [pending],\n\t\t\tkeepInPlace: new Set(\n\t\t\t\t[...currentWorktreeSnapshots(withMapping(sessionManager, pending)).keys()].filter(\n\t\t\t\t\t(root) => !restoring.has(root),\n\t\t\t\t),\n\t\t\t),\n\t\t\t...(git === undefined ? {} : { cannotRestore: new Map(targets.map((target) => [target.root, git])) }),\n\t\t\tfallbackCwd: options.launchCwd,\n\t\t\tskipMissingRecords: true,\n\t\t});\n\t\tfor (const missing of resumed.missingRecords ?? []) {\n\t\t\tif (outcome.missing.has(missing.root)) continue;\n\t\t\toutcome.missing.add(missing.root);\n\t\t\toutcome.failed.push({ type: \"warning\", message: formatMissingRecordNotice(missing) });\n\t\t}\n\t\tif (resumed.status === \"none\") return undefined;\n\t\tif (resumed.status === \"restored\") outcome.restored.push(...resumed.mappings);\n\t\toutcome.unrestored.push(...resumed.unrestored.map((checkout) => checkout.record));\n\t\treturn resumed.cwd;\n\t};\n\tif (plan.required.length > 0 || reused !== undefined) outcome.cwd = await restore(plan.required, reused);\n\tfor (const target of plan.optional) {\n\t\ttry {\n\t\t\tawait restore([target], undefined);\n\t\t} catch (error) {\n\t\t\tif (options.signal?.aborted || !isCheckoutFailure(error)) throw error;\n\t\t\toutcome.failed.push(\n\t\t\t\tnotRestored(\n\t\t\t\t\ttarget.root,\n\t\t\t\t\ttarget.snapshot,\n\t\t\t\t\t`${absentOrChanged(target)}, and restoring it failed: ${describeFailure(error)}`,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\treturn outcome;\n}\n\n/**\n * Builds the blueprints of the worktrees Atomic restored for the session: each worktree this resume restored\n * (`restoredNow`), and again each worktree restored earlier whose last build failed or never finished. Later changes\n * to an earlier worktree's files are the session's own work. Every other checkout the session works in is only\n * described to the agent.\n */\nasync function setUpCheckoutBlueprints(\n\tsessionManager: SessionManager,\n\trestoredNow: ReadonlySet<string>,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<ResumedBlueprints> {\n\tif (options.blueprints === \"skip\") return SKIPPED_BLUEPRINTS;\n\tconst restoredHere: BlueprintCheckout[] = [];\n\tconst earlier: BlueprintCheckout[] = [];\n\tconst inPlace: BlueprintCheckout[] = [];\n\tfor (const [root, snapshot] of currentWorktreeSnapshots(sessionManager)) {\n\t\tconst checkout = checkoutOf(sessionManager, root, snapshot);\n\t\tif (restoredNow.has(root)) restoredHere.push(checkout);\n\t\telse if (isInside(storeDir, root)) earlier.push(checkout);\n\t\telse if (await isDirectory(root)) inPlace.push(checkout);\n\t}\n\tconst retried = await checkoutsNeedingRebuild(earlier, storeDir);\n\treturn setUpResumedBlueprints({\n\t\trestored: [...restoredHere, ...retried],\n\t\tinPlace,\n\t\tearlier: earlier.filter((checkout) => !retried.includes(checkout)),\n\t\tconfig: { ...options.blueprint, storeDir },\n\t\tsignal: options.signal,\n\t});\n}\n\n/**\n * Whether the repository of the checkout at `root` holds the commit that records `snapshot`. That commit is\n * content-addressed and written only where Atomic captured exactly that state, so it tells the checkout a session\n * worked in, even after it changed, from another checkout of the same repository at the same path on another node,\n * unless Atomic captured the same state there too. A checkout that is not a repository, or a node without Git, does\n * not hold it.\n */\nexport async function holdsSnapshotCommit(\n\tsnapshot: WorktreeSnapshot,\n\troot: string,\n\tsignal?: AbortSignal,\n): Promise<boolean> {\n\ttry {\n\t\tconst { exitCode } = await runGit([\"cat-file\", \"-e\", `${snapshot.snapshot}^{commit}`], {\n\t\t\tcwd: root,\n\t\t\tsignal,\n\t\t\tallowExitCodes: [1, 128],\n\t\t});\n\t\treturn exitCode === 0;\n\t} catch (error) {\n\t\tif (isGitUnavailableError(error)) return false;\n\t\tthrow error;\n\t}\n}\n\n/**\n * Where a woken session continues. Each checkout it recorded that it worked in on this node stays as it is, since work\n * done in it after the release belongs to the session, and a blueprint build that failed or did not finish in a worktree\n * this node restored for it runs again. Every other checkout, as when it is missing or another clone sits at its path on another\n * node, is prepared as `/resume` prepares it. When every checkout stays, it continues in the directory it last worked\n * in, after the restores it recorded, which `reopen` opens it in.\n */\nexport async function continueSessionWhereItWorked(\n\topened: SessionManager,\n\toptions: PrepareSessionResumeOptions,\n\treopen: (cwd: string) => Promise<SessionManager> = (cwd) => opened.openSessionById(opened.getSessionId(), cwd),\n): Promise<SessionManager> {\n\tconst cwd = mapRestoredPath(opened.getCwd(), opened.getWorktreeRootMappings());\n\tconst checkouts = currentWorktreeSnapshots(opened);\n\tconst own = await checkoutsWorkedHere(checkouts, cwd, options, await partialRestores(opened, options));\n\tif (own.size < checkouts.size) {\n\t\tconst prepared = await prepareSessionResume(opened, { ...options, keepInPlace: own });\n\t\tif (prepared.status !== \"ready\") return opened;\n\t\tif (prepared.blueprintNotices.length > 0) options.onNotices?.(prepared.blueprintNotices);\n\t\treturn prepared.sessionManager;\n\t}\n\tconst storeDir = resolveStoreDir(options);\n\tif (checkouts.size === 0) {\n\t\tawait describeBlueprintsInPlace(opened, storeDir, options);\n\t} else {\n\t\tconst blueprints = await setUpCheckoutBlueprints(opened, new Set(), storeDir, options);\n\t\tawait recordBlueprintContext(opened, blueprints.context);\n\t\tif (blueprints.notices.length > 0) options.onNotices?.(blueprints.notices);\n\t}\n\treturn cwd === resolve(opened.getCwd()) ? opened : reopen(cwd);\n}\n\n/**\n * The roots of the `checkouts` a session recorded that are here as checkouts it worked in on this node, as it left them\n * or changed since: a worktree this node restored for it, or a checkout whose repository holds the commit of its latest\n * snapshot. The checkout the session works in counts only while its working directory `cwd` is here too.\n */\nasync function checkoutsWorkedHere(\n\tcheckouts: ReadonlyMap<string, WorktreeSnapshot>,\n\tcwd: string,\n\toptions: PrepareSessionResumeOptions,\n\tpartial: ReadonlySet<string> = new Set(),\n): Promise<Set<string>> {\n\tconst storeDir = resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n\tconst own = new Set<string>();\n\tfor (const [root, snapshot] of checkouts) {\n\t\tif (!existsSync(isInside(root, cwd) ? cwd : root)) continue;\n\t\tconst restoredHere = isInside(storeDir, root) && !partial.has(resolve(root));\n\t\tif (restoredHere || (await holdsSnapshotCommit(snapshot, root, options.signal))) own.add(root);\n\t}\n\treturn own;\n}\n\n/**\n * The worktrees a resume restored with less than their snapshot (#4733) that are still exactly as it left them: the\n * session recorded no snapshot there since, and their HEAD and files are what the restore put there. The next resume\n * tries the snapshot again instead of keeping them. A worktree changed since, even by hand, is the session's work and\n * stays; one that cannot be compared stays too.\n */\nasync function partialRestores(\n\tsessionManager: SessionCheckouts,\n\toptions: Pick<PrepareSessionResumeOptions, \"settings\" | \"signal\">,\n): Promise<Set<string>> {\n\tconst current = currentWorktreeSnapshots(sessionManager);\n\tconst partial = new Set<string>();\n\tfor (const mapping of sessionManager.getWorktreeRootMappings()) {\n\t\tconst degraded = mapping.degraded;\n\t\tconst snapshot = current.get(mapping.to);\n\t\tif (degraded === undefined || snapshot?.id !== mapping.snapshotId || !existsSync(mapping.to)) continue;\n\t\tconst restored = {\n\t\t\tremotes: [...snapshot.remotes],\n\t\t\thead: degraded.head,\n\t\t\ttree: degraded.tree,\n\t\t\tenvHash: snapshot.envHash,\n\t\t};\n\t\ttry {\n\t\t\tawait verifyWorktree(restored, mapping.to, { settings: options.settings, signal: options.signal });\n\t\t\tpartial.add(resolve(mapping.to));\n\t\t} catch (error) {\n\t\t\tif (options.signal?.aborted) throw error;\n\t\t}\n\t}\n\treturn partial;\n}\n/**\n * Whether resuming in `root` restores `snapshot` into a fresh worktree: the checkout is gone, is not a repository of\n * the recorded tree, or no longer matches it. A path that cannot be read fails with its typed `unreadable-path` error\n * instead, since restoring would hide it. A checkout whose HEAD only moved forward over the recorded tree, as after\n * committing the recorded edits, continues in place, as #4245's resume decides. Read-only.\n */\nexport async function worktreeNeedsRestore(\n\tsnapshot: WorktreeSnapshot,\n\troot: string,\n\toptions: VerifyWorktreeOptions,\n): Promise<boolean> {\n\ttry {\n\t\tawait verifyWorktree(snapshot, root, options);\n\t\treturn false;\n\t} catch (error) {\n\t\tif (isWorkspaceDriftError(error)) return !(await isHeadOnlyAdvance(error, options.signal));\n\t\tif (isWorkspaceSnapshotError(error) && error.code !== \"unreadable-path\") return true;\n\t\tthrow error;\n\t}\n}\n\n/** The outcome of starting or provisioning Git once for a resume: the typed reason it cannot run, or undefined. */\ninterface GitProbe {\n\treadonly unavailable: GitUnavailableError | undefined;\n}\n\n/**\n * Decides what the resume does about the `candidates` that are gone or changed here, before anything is written. The\n * precondition of restoring them on this node is that Git can be started or provisioned (`git`, the probe's typed\n * failure). When it is unmet, the checkouts the session works in are not restored and the session continues without\n * them, with a notice and a record in the session (#4733); any other checkout is left out with a warning. A blueprint\n * is never a precondition.\n */\nfunction planRestores(\n\tcandidates: { readonly targets: readonly RestoreTarget[]; readonly left: ReadonlyMap<string, ResumeNotice> },\n\tgit: GitUnavailableError | undefined,\n): RestorePlan {\n\tconst required = candidates.targets.filter((target) => target.runsHere);\n\tconst others = candidates.targets.filter((target) => !target.runsHere);\n\tconst left = new Map(candidates.left);\n\tconst optional: RestoreTarget[] = [];\n\tfor (const target of others) {\n\t\tif (git) {\n\t\t\tleft.set(\n\t\t\t\ttarget.root,\n\t\t\t\tnotRestored(\n\t\t\t\t\ttarget.root,\n\t\t\t\t\ttarget.snapshot,\n\t\t\t\t\t`${absentOrChanged(target)}, and Git is unavailable here (${git.code}), which restoring it needs`,\n\t\t\t\t),\n\t\t\t);\n\t\t} else {\n\t\t\toptional.push(target);\n\t\t}\n\t}\n\treturn { required, optional, left, git };\n}\n\n/**\n * Whether a restored worktree is trusted to run its blueprints outside the CLI: the decision saved in `agentDir` for\n * that path, else the default trust setting.\n */\nexport function savedProjectTrust(\n\tagentDir: string,\n\tsettings: Pick<SettingsManager, \"getDefaultProjectTrust\">,\n): (worktree: string) => boolean {\n\tconst trustStore = new ProjectTrustStore(agentDir);\n\treturn (worktree) => trustStore.get(worktree) ?? settings.getDefaultProjectTrust() === \"always\";\n}\n\n/** Where restored worktrees, the blueprint build ledger and logs live for the agent directory `agentDir`. */\nexport function resumeStoreDir(agentDir: string): string {\n\treturn join(agentDir, \"worktree-snapshots\");\n}\n\nfunction resolveStoreDir(options: Pick<PrepareSessionResumeOptions, \"storeDir\">): string {\n\treturn resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n}\n\n/**\n * The options a resume from `launchCwd` needs: snapshot settings and the blueprint build configuration from\n * `settingsManager`, and the worktree store of `agentDir`.\n */\nexport function sessionResumeOptions(\n\tentryPoint: ResumeEntryPoint,\n\tlaunchCwd: string,\n\tagentDir: string,\n\tsettingsManager: Pick<SettingsManager, \"getWorktreeSnapshotSettings\" | \"getResumeSetupCommand\">,\n\ttrusted: (worktree: string) => boolean,\n): PrepareSessionResumeOptions {\n\treturn {\n\t\tentryPoint,\n\t\tlaunchCwd,\n\t\tsettings: settingsManager.getWorktreeSnapshotSettings(),\n\t\tblueprint: { agentDir, setupCommand: settingsManager.getResumeSetupCommand(), trusted },\n\t\tstoreDir: resumeStoreDir(agentDir),\n\t};\n}\n"]}
|
package/dist/core/sdk.js
CHANGED
|
@@ -280,7 +280,7 @@ async function constructAgentSession(options, deferStart, persistInitialState, a
|
|
|
280
280
|
resourceLoader = await withBuiltinResourceLoader(resourceLoader, cwd, agentDir, options.builtins, disableWorkflowExtension);
|
|
281
281
|
}
|
|
282
282
|
if (options.builtins?.intercom !== false) {
|
|
283
|
-
resourceLoader = await withMandatoryResourceLoader(resourceLoader, cwd);
|
|
283
|
+
resourceLoader = await withMandatoryResourceLoader(resourceLoader, cwd, agentDir);
|
|
284
284
|
}
|
|
285
285
|
// Check if session has existing data to restore
|
|
286
286
|
const existingSession = sessionManager.buildSessionContext();
|