@bastani/atomic 0.9.84 → 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.
Files changed (183) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  3. package/dist/builtin/intercom/broker/broker.ts +25 -7
  4. package/dist/builtin/intercom/broker/spawn.ts +83 -17
  5. package/dist/builtin/intercom/index.bundle.mjs +89 -26
  6. package/dist/builtin/intercom/package.json +1 -1
  7. package/dist/builtin/mcp/package.json +1 -1
  8. package/dist/builtin/subagents/package.json +1 -1
  9. package/dist/builtin/web-access/package.json +1 -1
  10. package/dist/builtin/workflows/CHANGELOG.md +6 -0
  11. package/dist/builtin/workflows/package.json +1 -1
  12. package/dist/builtin/workflows/src/authoring.d.ts +1 -1
  13. package/dist/builtin/workflows/src/extension/index.bundle.mjs +48 -9
  14. package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +48 -9
  15. package/dist/builtin/workflows/src/index.js +48 -9
  16. package/dist/builtin/workflows/src/local-worker-entry.mjs +48 -9
  17. package/dist/config.d.ts +3 -2
  18. package/dist/config.d.ts.map +1 -1
  19. package/dist/config.js +4 -3
  20. package/dist/config.js.map +1 -1
  21. package/dist/core/agent-session-export.d.ts +2 -2
  22. package/dist/core/agent-session-export.d.ts.map +1 -1
  23. package/dist/core/agent-session-export.js +4 -5
  24. package/dist/core/agent-session-export.js.map +1 -1
  25. package/dist/core/agent-session-services.js +1 -1
  26. package/dist/core/agent-session-services.js.map +1 -1
  27. package/dist/core/agent-session-summary.d.ts.map +1 -1
  28. package/dist/core/agent-session-summary.js +8 -1
  29. package/dist/core/agent-session-summary.js.map +1 -1
  30. package/dist/core/agent-session-tree.d.ts.map +1 -1
  31. package/dist/core/agent-session-tree.js +3 -6
  32. package/dist/core/agent-session-tree.js.map +1 -1
  33. package/dist/core/builtin-resource-loader.d.ts.map +1 -1
  34. package/dist/core/builtin-resource-loader.js +1 -1
  35. package/dist/core/builtin-resource-loader.js.map +1 -1
  36. package/dist/core/extensions/loader-core.d.ts +6 -2
  37. package/dist/core/extensions/loader-core.d.ts.map +1 -1
  38. package/dist/core/extensions/loader-core.js +13 -9
  39. package/dist/core/extensions/loader-core.js.map +1 -1
  40. package/dist/core/extensions/loader-discovery.js +1 -1
  41. package/dist/core/extensions/loader-discovery.js.map +1 -1
  42. package/dist/core/extensions/loader-virtual-modules.d.ts +20 -14
  43. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  44. package/dist/core/extensions/loader-virtual-modules.js +133 -78
  45. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  46. package/dist/core/extensions/ts-source-specifiers.d.ts +1 -0
  47. package/dist/core/extensions/ts-source-specifiers.d.ts.map +1 -1
  48. package/dist/core/extensions/ts-source-specifiers.js +18 -2
  49. package/dist/core/extensions/ts-source-specifiers.js.map +1 -1
  50. package/dist/core/mandatory-resource-loader.d.ts +5 -2
  51. package/dist/core/mandatory-resource-loader.d.ts.map +1 -1
  52. package/dist/core/mandatory-resource-loader.js +17 -12
  53. package/dist/core/mandatory-resource-loader.js.map +1 -1
  54. package/dist/core/model-fallback-failures.d.ts.map +1 -1
  55. package/dist/core/model-fallback-failures.js +10 -3
  56. package/dist/core/model-fallback-failures.js.map +1 -1
  57. package/dist/core/resource-loader-extensions.d.ts.map +1 -1
  58. package/dist/core/resource-loader-extensions.js +1 -1
  59. package/dist/core/resource-loader-extensions.js.map +1 -1
  60. package/dist/core/resource-loader-reload.js +1 -1
  61. package/dist/core/resource-loader-reload.js.map +1 -1
  62. package/dist/core/resume/blueprint/resume.d.ts +4 -4
  63. package/dist/core/resume/blueprint/resume.js +4 -4
  64. package/dist/core/resume/blueprint/resume.js.map +1 -1
  65. package/dist/core/resume/session-resume.d.ts +6 -3
  66. package/dist/core/resume/session-resume.d.ts.map +1 -1
  67. package/dist/core/resume/session-resume.js +159 -37
  68. package/dist/core/resume/session-resume.js.map +1 -1
  69. package/dist/core/sdk.js +1 -1
  70. package/dist/core/sdk.js.map +1 -1
  71. package/dist/core/session-manager-core.d.ts +10 -4
  72. package/dist/core/session-manager-core.d.ts.map +1 -1
  73. package/dist/core/session-manager-core.js +23 -6
  74. package/dist/core/session-manager-core.js.map +1 -1
  75. package/dist/core/session-manager-entries.d.ts +2 -2
  76. package/dist/core/session-manager-entries.d.ts.map +1 -1
  77. package/dist/core/session-manager-entries.js +2 -1
  78. package/dist/core/session-manager-entries.js.map +1 -1
  79. package/dist/core/session-manager-history.d.ts +13 -1
  80. package/dist/core/session-manager-history.d.ts.map +1 -1
  81. package/dist/core/session-manager-history.js +21 -1
  82. package/dist/core/session-manager-history.js.map +1 -1
  83. package/dist/core/session-manager-types.d.ts +3 -1
  84. package/dist/core/session-manager-types.d.ts.map +1 -1
  85. package/dist/core/session-manager-types.js.map +1 -1
  86. package/dist/core/session-manager.d.ts +1 -1
  87. package/dist/core/session-manager.d.ts.map +1 -1
  88. package/dist/core/session-manager.js +1 -1
  89. package/dist/core/session-manager.js.map +1 -1
  90. package/dist/core/session-worktree-snapshots.d.ts +61 -4
  91. package/dist/core/session-worktree-snapshots.d.ts.map +1 -1
  92. package/dist/core/session-worktree-snapshots.js +261 -28
  93. package/dist/core/session-worktree-snapshots.js.map +1 -1
  94. package/dist/core/storage/session/entry-structure.js +31 -1
  95. package/dist/core/storage/session/entry-structure.js.map +1 -1
  96. package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts.map +1 -1
  97. package/dist/core/tools/ask-user-question/state/build-questionnaire.js +2 -1
  98. package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -1
  99. package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts.map +1 -1
  100. package/dist/core/tools/ask-user-question/state/questionnaire-session.js +2 -0
  101. package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
  102. package/dist/core/tools/ask-user-question/state/selectors/field-tone.d.ts +26 -0
  103. package/dist/core/tools/ask-user-question/state/selectors/field-tone.d.ts.map +1 -0
  104. package/dist/core/tools/ask-user-question/state/selectors/field-tone.js +27 -0
  105. package/dist/core/tools/ask-user-question/state/selectors/field-tone.js.map +1 -0
  106. package/dist/core/tools/ask-user-question/state/selectors/projections.d.ts.map +1 -1
  107. package/dist/core/tools/ask-user-question/state/selectors/projections.js +1 -0
  108. package/dist/core/tools/ask-user-question/state/selectors/projections.js.map +1 -1
  109. package/dist/core/tools/ask-user-question/state/state-reducer.js +1 -1
  110. package/dist/core/tools/ask-user-question/state/state-reducer.js.map +1 -1
  111. package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts.map +1 -1
  112. package/dist/core/tools/ask-user-question/view/components/multi-select-view.js +6 -6
  113. package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
  114. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts +5 -3
  115. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts.map +1 -1
  116. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js +14 -4
  117. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -1
  118. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts +2 -0
  119. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts.map +1 -1
  120. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js +3 -3
  121. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js.map +1 -1
  122. package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts +16 -6
  123. package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts.map +1 -1
  124. package/dist/core/tools/ask-user-question/view/components/wrapping-select.js +42 -24
  125. package/dist/core/tools/ask-user-question/view/components/wrapping-select.js.map +1 -1
  126. package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts.map +1 -1
  127. package/dist/core/tools/ask-user-question/view/tab-content-strategy.js +12 -3
  128. package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -1
  129. package/dist/core/tools/read.d.ts +1 -0
  130. package/dist/core/tools/read.d.ts.map +1 -1
  131. package/dist/core/tools/read.js +13 -14
  132. package/dist/core/tools/read.js.map +1 -1
  133. package/dist/core/worktree-snapshot/index.d.ts +2 -2
  134. package/dist/core/worktree-snapshot/index.d.ts.map +1 -1
  135. package/dist/core/worktree-snapshot/index.js +1 -1
  136. package/dist/core/worktree-snapshot/index.js.map +1 -1
  137. package/dist/core/worktree-snapshot/records.d.ts +6 -0
  138. package/dist/core/worktree-snapshot/records.d.ts.map +1 -1
  139. package/dist/core/worktree-snapshot/records.js +18 -4
  140. package/dist/core/worktree-snapshot/records.js.map +1 -1
  141. package/dist/core/worktree-snapshot/restore.d.ts +24 -1
  142. package/dist/core/worktree-snapshot/restore.d.ts.map +1 -1
  143. package/dist/core/worktree-snapshot/restore.js +443 -72
  144. package/dist/core/worktree-snapshot/restore.js.map +1 -1
  145. package/dist/core/worktree-snapshot/types.d.ts +44 -0
  146. package/dist/core/worktree-snapshot/types.d.ts.map +1 -1
  147. package/dist/core/worktree-snapshot/types.js.map +1 -1
  148. package/dist/index.d.ts +2 -2
  149. package/dist/index.d.ts.map +1 -1
  150. package/dist/index.js +2 -2
  151. package/dist/index.js.map +1 -1
  152. package/dist/modes/interactive/components/tool-execution.js +2 -1
  153. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  154. package/dist/modes/interactive/interactive-slash-commands.js +4 -1
  155. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  156. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  157. package/dist/modes/interactive-engine/isolated-runtime.js +8 -0
  158. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  159. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  160. package/dist/modes/rpc/rpc-command-handler.js +11 -2
  161. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  162. package/dist/modes/rpc/rpc-command-timeouts.d.ts.map +1 -1
  163. package/dist/modes/rpc/rpc-command-timeouts.js +1 -0
  164. package/dist/modes/rpc/rpc-command-timeouts.js.map +1 -1
  165. package/dist/modes/rpc/rpc-input-scheduler.d.ts.map +1 -1
  166. package/dist/modes/rpc/rpc-input-scheduler.js +1 -0
  167. package/dist/modes/rpc/rpc-input-scheduler.js.map +1 -1
  168. package/dist/modes/rpc/rpc-types.d.ts +11 -1
  169. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  170. package/dist/modes/rpc/rpc-types.js.map +1 -1
  171. package/docs/environment-variables.md +1 -1
  172. package/docs/guides/resume-on-any-machine.md +6 -4
  173. package/docs/intercom/operations.md +4 -0
  174. package/docs/rpc/protocol.md +2 -2
  175. package/docs/sdk/reference.md +3 -0
  176. package/docs/sdk.md +2 -2
  177. package/docs/session-format.md +11 -2
  178. package/docs/sessions.md +4 -2
  179. package/docs/settings.md +1 -1
  180. package/docs/workflows/api-reference.md +2 -2
  181. package/docs/worktree-snapshots.md +13 -5
  182. package/npm-shrinkwrap.json +32 -32
  183. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"session-worktree-snapshots.js","sourceRoot":"","sources":["../../src/core/session-worktree-snapshots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAG/D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAG7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EACN,uBAAuB,EACvB,cAAc,EAEd,oBAAoB,EACpB,gBAAgB,GAChB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EACN,kBAAkB,EAElB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,mBAAm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sep } from \"node:path\";\nimport type { AssistantMessage } from \"@bastani/pi-ai/compat\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport { getBranchPath } from \"./session-manager-history.ts\";\nimport type { SessionEntry, WorktreeRestoreHostWarning } from \"./session-manager-types.ts\";\nimport type { SessionStore } from \"./storage/session/types.js\";\nimport { snapshotBlobHashes } from \"./worktree-snapshot/blob-store.ts\";\nimport {\n\tcaptureWorktreeSnapshot,\n\tlocateCheckout,\n\ttype WorktreeSnapshotUnavailableReason,\n\twithScratchDirectory,\n\twriteWorkingTree,\n} from \"./worktree-snapshot/capture.ts\";\nimport { sha256Hex } from \"./worktree-snapshot/env-hash.ts\";\nimport {\n\tfindWorkspaceError,\n\ttype GitUnavailableError,\n\tisGitUnavailableError,\n\tisWorkspaceDriftError,\n\tisWorkspaceSnapshotError,\n\tunreadablePathError,\n\tWorkspaceDriftError,\n\ttype WorkspaceError,\n\tWorkspaceRestoreError,\n\tWorkspaceSnapshotError,\n} from \"./worktree-snapshot/errors.ts\";\nimport { scheduleSnapshotCollection } from \"./worktree-snapshot/garbage.ts\";\nimport { gitText, runGit } from \"./worktree-snapshot/git.ts\";\nimport { isHeadOnlyAdvance } from \"./worktree-snapshot/head-advance.ts\";\nimport { canonicalizeWorktreePath } from \"./worktree-snapshot/paths.ts\";\nimport { loadSnapshotPathPolicy } from \"./worktree-snapshot/policy.ts\";\nimport {\n\tremoveRestoredWorktree,\n\trestoreWorktree,\n\tsnapshotRestoreWarnings,\n\tverifyWorktree,\n} from \"./worktree-snapshot/restore.ts\";\nimport type {\n\tSnapshotBlob,\n\tSnapshotBlobStore,\n\tWorktreeRestoreWarning,\n\tWorktreeRootMapping,\n\tWorktreeSnapshot,\n\tWorktreeSnapshotSettings,\n} from \"./worktree-snapshot/types.ts\";\n\n/** Why a turn's snapshot could not be recorded: Git is unavailable, or a typed workspace failure. */\nexport type WorktreeSnapshotUnavailable = WorkspaceError | GitUnavailableError;\n\n/** Built-in tools that can change files: a turn that called one records a snapshot. */\nexport const FILE_WRITING_TOOLS: ReadonlySet<string> = new Set([\"bash\", \"edit\", \"write\", \"powershell\"]);\nconst PATH_TOOLS: ReadonlySet<string> = new Set([\"edit\", \"write\"]);\n\nexport interface TurnSnapshotDependencies {\n\treadonly sessionManager: SessionManager;\n\treadonly cwd: () => string;\n\treadonly settings: () => WorktreeSnapshotSettings;\n\t/** Whether a registered tool declares `writesFiles`. */\n\treadonly declaresWrites: (toolName: string) => boolean;\n\t/** Called once per distinct reason a snapshot could not be recorded. */\n\treadonly onUnavailable: (reason: WorktreeSnapshotUnavailable) => void;\n}\n\nfunction isInside(parent: string, child: string): boolean {\n\tconst path = relative(canonicalizeWorktreePath(parent), canonicalizeWorktreePath(child));\n\treturn path === \"\" || (!path.startsWith(`..${sep}`) && path !== \"..\" && !isAbsolute(path));\n}\n\n/**\n * Records a `worktree_snapshot` entry per checkout at the end of each turn that called a file-writing tool. In-memory\n * sessions, which cannot be resumed elsewhere, record nothing.\n */\nexport class SessionWorktreeSnapshotRecorder {\n\tprivate readonly deps: TurnSnapshotDependencies;\n\tprivate readonly reported = new Set<string>();\n\n\tconstructor(deps: TurnSnapshotDependencies) {\n\t\tthis.deps = deps;\n\t}\n\n\tprivate report(reason: WorktreeSnapshotUnavailable): void {\n\t\tconst key = `${reason.code}\\0${JSON.stringify(reason.fields)}`;\n\t\tif (this.reported.has(key)) return;\n\t\tthis.reported.add(key);\n\t\tthis.deps.onUnavailable(reason);\n\t}\n\n\t/** Directories whose checkouts a turn may have changed: the session cwd and the targets of path-taking tools. */\n\tprivate touchedDirectories(message: AssistantMessage): string[] | undefined {\n\t\tconst cwd = this.deps.cwd();\n\t\tconst directories = new Set<string>();\n\t\tfor (const part of message.content) {\n\t\t\tif (part.type !== \"toolCall\") continue;\n\t\t\tif (!FILE_WRITING_TOOLS.has(part.name) && !this.deps.declaresWrites(part.name)) continue;\n\t\t\tdirectories.add(cwd);\n\t\t\tconst path = PATH_TOOLS.has(part.name) ? part.arguments.path : undefined;\n\t\t\tif (typeof path === \"string\" && path.length > 0) directories.add(resolve(cwd, path, \"..\"));\n\t\t}\n\t\treturn directories.size === 0 ? undefined : [...directories];\n\t}\n\n\t/** Whether the turn may record a snapshot when it ends: a persisted session called a tool that can change files. */\n\tcallsFileWritingTool(message: AssistantMessage): boolean {\n\t\treturn this.deps.sessionManager.isPersisted() && this.touchedDirectories(message) !== undefined;\n\t}\n\n\tasync recordTurn(message: AssistantMessage): Promise<void> {\n\t\tconst directories = this.touchedDirectories(message);\n\t\tif (!directories) return;\n\t\tlet settings: WorktreeSnapshotSettings;\n\t\ttry {\n\t\t\tsettings = this.deps.settings();\n\t\t} catch (error) {\n\t\t\tthis.reportFailure(error);\n\t\t\treturn;\n\t\t}\n\t\tif (!settings.enabled || !this.deps.sessionManager.isPersisted()) return;\n\t\tconst blobs = this.deps.sessionManager.getSessionStore().snapshotBlobs;\n\t\tif (!blobs) {\n\t\t\tthis.report(\n\t\t\t\tnew WorkspaceSnapshotError(\n\t\t\t\t\t\"blob-store-unsupported\",\n\t\t\t\t\tthis.deps.sessionManager.getSessionStore().descriptor.adapter,\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tconst roots = new Set<string>();\n\t\tfor (const directory of directories) {\n\t\t\ttry {\n\t\t\t\tconst checkout = await locateCheckout(await nearestExisting(directory));\n\t\t\t\tif (checkout instanceof Error) this.report(checkout);\n\t\t\t\telse roots.add(checkout.root);\n\t\t\t} catch (error) {\n\t\t\t\tthis.reportFailure(error);\n\t\t\t}\n\t\t}\n\t\tfor (const root of roots) {\n\t\t\tconst previous = this.deps.sessionManager.getLatestWorktreeSnapshots().get(root);\n\t\t\ttry {\n\t\t\t\tconst result = await captureWorktreeSnapshot(root, { settings, previous, blobs });\n\t\t\t\tif (result.status === \"captured\") {\n\t\t\t\t\tawait this.deps.sessionManager.appendWorktreeSnapshot(root, result.snapshot.id, result.snapshot);\n\t\t\t\t} else if (result.status === \"unchanged\") {\n\t\t\t\t\tawait this.deps.sessionManager.appendWorktreeSnapshot(root, result.snapshot.id);\n\t\t\t\t} else if (result.status === \"unavailable\") {\n\t\t\t\t\tthis.report(result.reason);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tthis.reportFailure(error);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Starts an automatic collection of the session store's unreferenced snapshot blobs when one is due, and returns\n\t * without waiting for it. Called when the session closes.\n\t */\n\tscheduleCollection(): void {\n\t\tlet settings: WorktreeSnapshotSettings;\n\t\ttry {\n\t\t\tsettings = this.deps.settings();\n\t\t} catch (error) {\n\t\t\tthis.reportFailure(error);\n\t\t\treturn;\n\t\t}\n\t\tvoid scheduleSnapshotCollection(this.deps.sessionManager.getSessionStore().snapshotBlobs, settings);\n\t}\n\n\tprivate reportFailure(error: unknown): void {\n\t\tconst reason = isGitUnavailableError(error) ? error : findWorkspaceError(error);\n\t\tif (!reason) throw error;\n\t\tthis.report(reason);\n\t}\n}\n\nasync function nearestExisting(directory: string): Promise<string> {\n\tfor (let current = directory; ; current = resolve(current, \"..\")) {\n\t\ttry {\n\t\t\tif ((await stat(current)).isDirectory()) return current;\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code !== \"ENOENT\" && (error as NodeJS.ErrnoException).code !== \"ENOTDIR\")\n\t\t\t\tthrow unreadablePathError(current, error);\n\t\t}\n\t\tif (resolve(current, \"..\") === current) return current;\n\t}\n}\n\n/** `path` rewritten through each restore in order: a path under `from` moves to the same place under `to`. */\nexport function mapRestoredPath(path: string, mappings: readonly WorktreeRootMapping[]): string {\n\tlet mapped = resolve(path);\n\tlet next = 0;\n\twhile (next < mappings.length) {\n\t\tconst current = canonicalizeWorktreePath(mapped);\n\t\tlet best: { index: number; source: string } | undefined;\n\t\tfor (let index = next; index < mappings.length; index++) {\n\t\t\tconst source = canonicalizeWorktreePath(mappings[index]!.from);\n\t\t\tif (isInside(source, current) && (best === undefined || source.length > best.source.length)) {\n\t\t\t\tbest = { index, source };\n\t\t\t}\n\t\t}\n\t\tif (best === undefined) break;\n\t\tmapped = resolve(mappings[best.index]!.to, relative(best.source, current));\n\t\tnext = best.index + 1;\n\t}\n\treturn mapped;\n}\n\n/** Recover the original root of a sequence of restores, so a restored root supersedes its earlier location. */\nfunction originalRoot(root: string, mappings: readonly WorktreeRootMapping[]): string {\n\tlet current = canonicalizeWorktreePath(root);\n\tfor (let index = mappings.length - 1; index >= 0; index--) {\n\t\tconst mapping = mappings[index]!;\n\t\tif (canonicalizeWorktreePath(mapping.to) === current) current = canonicalizeWorktreePath(mapping.from);\n\t}\n\treturn current;\n}\n\n/** The id of the latest snapshot of each checkout on the active branch, keyed by the root it was first recorded under. */\nfunction latestSnapshotIdsByCheckout(\n\tsessionManager: Pick<SessionManager, \"getBranch\">,\n\tmappings: readonly WorktreeRootMapping[],\n): Map<string, string> {\n\tconst latestIds = new Map<string, string>();\n\tfor (const entry of sessionManager.getBranch()) {\n\t\tif (entry.type === \"worktree_snapshot\") latestIds.set(originalRoot(entry.root, mappings), entry.snapshotId);\n\t}\n\treturn latestIds;\n}\n\n/**\n * The latest snapshot of each checkout on the active branch, keyed by where that checkout is now: a checkout restored\n * elsewhere appears once, under its newest location. A snapshot whose record is missing is left out.\n */\nexport function currentWorktreeSnapshots(\n\tsessionManager: Pick<SessionManager, \"getBranch\" | \"getWorktreeRootMappings\" | \"getWorktreeSnapshotRecords\">,\n): Map<string, WorktreeSnapshot> {\n\tconst mappings = sessionManager.getWorktreeRootMappings();\n\tconst records = sessionManager.getWorktreeSnapshotRecords();\n\tconst current = new Map<string, WorktreeSnapshot>();\n\tfor (const [original, snapshotId] of latestSnapshotIdsByCheckout(sessionManager, mappings)) {\n\t\tconst snapshot = records.get(snapshotId);\n\t\tif (snapshot) current.set(mapRestoredPath(original, mappings), snapshot);\n\t}\n\treturn current;\n}\n\nexport type SessionWorktreeResume =\n\t| { readonly status: \"none\" }\n\t| { readonly status: \"verified\"; readonly snapshot: WorktreeSnapshot; readonly cwd: string }\n\t| {\n\t\t\treadonly status: \"restored\";\n\t\t\treadonly snapshot: WorktreeSnapshot;\n\t\t\treadonly mappings: readonly WorktreeRootMapping[];\n\t\t\treadonly cwd: string;\n\t\t\treadonly warnings: readonly WorktreeRestoreWarning[];\n\t };\n\nexport interface ResumeSessionWorktreeOptions {\n\treadonly settings: WorktreeSnapshotSettings;\n\t/** Host directory for shared object stores and restored worktrees. Default ~/.atomic/agent/worktree-snapshots. */\n\treadonly storeDir?: string;\n\treadonly signal?: AbortSignal;\n\t/**\n\t * Called with the new mappings, none when nothing needed restoring, once every checkout is restored and before any\n\t * of them is recorded. When it throws, nothing is recorded and the restored worktrees are removed, as for a failed\n\t * restore.\n\t */\n\treadonly beforeRecord?: (mappings: readonly WorktreeRootMapping[]) => Promise<void>;\n\t/**\n\t * Mappings to checkouts already here that the session continues in, applied as if recorded while deciding what to\n\t * restore, and recorded first, with the restores, only once every checkout is restored and `beforeRecord` passed.\n\t */\n\treadonly pendingMappings?: readonly WorktreeRootMapping[];\n\t/** Checkouts, by the root the session's restores put them at, to continue in as they are without verifying them. */\n\treadonly keepInPlace?: ReadonlySet<string>;\n}\n\n/**\n * Checks the latest recorded snapshot of each checkout on the active session branch. Drifted or missing checkouts are\n * restored into fresh worktrees, and each old→new mapping is recorded only after all checkouts have been restored.\n * The returned cwd follows those mappings. A HEAD-only advance over identical content also resumes in place.\n */\nexport async function resumeSessionWorktree(\n\tsessionManager: SessionManager,\n\toptions: ResumeSessionWorktreeOptions,\n): Promise<SessionWorktreeResume> {\n\tif (!options.settings.enabled) return { status: \"none\" };\n\tconst pending = options.pendingMappings ?? [];\n\tconst existing = [...sessionManager.getWorktreeRootMappings(), ...pending];\n\tconst records = sessionManager.getWorktreeSnapshotRecords();\n\tconst latestIds = latestSnapshotIdsByCheckout(sessionManager, existing);\n\tconst latest = new Map<string, WorktreeSnapshot>();\n\tfor (const [root, snapshotId] of latestIds) {\n\t\tconst snapshot = records.get(snapshotId);\n\t\tif (!snapshot) throw new WorkspaceRestoreError(\"snapshot-not-found\", { snapshotId, target: root });\n\t\tlatest.set(root, snapshot);\n\t}\n\tif (latest.size === 0) return { status: \"none\" };\n\tconst cwd = mapRestoredPath(sessionManager.getCwd(), existing);\n\tconst mappings: WorktreeRootMapping[] = [];\n\tconst warnings: WorktreeRestoreWarning[] = [];\n\tconst hostWarnings = new Map<WorktreeRootMapping, WorktreeRestoreHostWarning[]>();\n\tconst reportedLeftovers = new Set<string>();\n\tlet selected: { root: string; snapshot: WorktreeSnapshot } | undefined;\n\ttry {\n\t\tfor (const [original, snapshot] of latest) {\n\t\t\toptions.signal?.throwIfAborted();\n\t\t\tconst root = mapRestoredPath(original, existing);\n\t\t\tif (isInside(root, cwd) && (!selected || root.length > selected.root.length)) selected = { root, snapshot };\n\t\t\tif (options.keepInPlace?.has(root)) continue;\n\t\t\tlet drift: WorkspaceDriftError;\n\t\t\ttry {\n\t\t\t\tawait verifyWorktree(snapshot, root, { settings: options.settings, signal: options.signal });\n\t\t\t\tcontinue;\n\t\t\t} catch (error) {\n\t\t\t\toptions.signal?.throwIfAborted();\n\t\t\t\tif (isWorkspaceDriftError(error)) {\n\t\t\t\t\tif (await isHeadOnlyAdvance(error, options.signal)) continue;\n\t\t\t\t\tdrift = error;\n\t\t\t\t} else if (isWorkspaceSnapshotError(error)) {\n\t\t\t\t\tdrift = new WorkspaceDriftError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\troot,\n\t\t\t\t\t\t\texpectedHead: snapshot.head,\n\t\t\t\t\t\t\tactualHead: null,\n\t\t\t\t\t\t\texpectedTree: snapshot.tree,\n\t\t\t\t\t\t\tactualTree: null,\n\t\t\t\t\t\t\tsnapshotId: snapshot.id,\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t} else throw error;\n\t\t\t}\n\t\t\tlet restored: Awaited<ReturnType<typeof restoreWorktree>>;\n\t\t\ttry {\n\t\t\t\trestored = await restoreWorktree(snapshot, {\n\t\t\t\t\tblobs: sessionSnapshotBlobs(sessionManager.getSessionStore().snapshotBlobs, sessionManager.getEntries()),\n\t\t\t\t\tstoreDir: options.storeDir,\n\t\t\t\t\tsignal: options.signal,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\toptions.signal?.throwIfAborted();\n\t\t\t\tif (!(error instanceof Error)) throw error;\n\t\t\t\tthrow new WorkspaceDriftError(\n\t\t\t\t\t{\n\t\t\t\t\t\troot: drift.root,\n\t\t\t\t\t\texpectedHead: drift.expectedHead,\n\t\t\t\t\t\tactualHead: drift.actualHead,\n\t\t\t\t\t\texpectedTree: drift.expectedTree,\n\t\t\t\t\t\tactualTree: drift.actualTree,\n\t\t\t\t\t\tsnapshotId: drift.snapshotId,\n\t\t\t\t\t\treason: \"restore-failed\",\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst mapping: WorktreeRootMapping = {\n\t\t\t\tfrom: root,\n\t\t\t\tto: restored.path,\n\t\t\t\tsnapshotId: snapshot.id,\n\t\t\t\ttree: snapshot.tree,\n\t\t\t\trestoredAt: new Date().toISOString(),\n\t\t\t};\n\t\t\tmappings.push(mapping);\n\t\t\twarnings.push(...restored.warnings);\n\t\t\thostWarnings.set(\n\t\t\t\tmapping,\n\t\t\t\trestored.warnings.filter((warning): warning is WorktreeRestoreHostWarning => {\n\t\t\t\t\tif (warning.code === \"lfs-objects-unavailable\") return true;\n\t\t\t\t\tif (warning.code !== \"stale-restore-retained\" || reportedLeftovers.has(warning.path)) return false;\n\t\t\t\t\treportedLeftovers.add(warning.path);\n\t\t\t\t\treturn true;\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\tawait options.beforeRecord?.(mappings);\n\t\tfor (const mapping of [...pending, ...mappings]) {\n\t\t\toptions.signal?.throwIfAborted();\n\t\t\tawait sessionManager.appendWorktreeSnapshot(\n\t\t\t\tmapping.to,\n\t\t\t\tmapping.snapshotId,\n\t\t\t\tundefined,\n\t\t\t\tmapping,\n\t\t\t\thostWarnings.get(mapping),\n\t\t\t);\n\t\t}\n\t} catch (error) {\n\t\tconst cleanupFailures: unknown[] = [];\n\t\tfor (const mapping of [...mappings].reverse()) {\n\t\t\ttry {\n\t\t\t\tawait removeRestoredWorktree(mapping.to, { storeDir: options.storeDir });\n\t\t\t} catch (cleanupCause) {\n\t\t\t\tcleanupFailures.push(cleanupCause);\n\t\t\t}\n\t\t}\n\t\tif (cleanupFailures.length > 0 && error instanceof Error && Object.isExtensible(error)) {\n\t\t\tObject.defineProperty(error, \"cleanupCause\", {\n\t\t\t\tvalue: cleanupFailures.length === 1 ? cleanupFailures[0] : new AggregateError(cleanupFailures),\n\t\t\t\tconfigurable: true,\n\t\t\t});\n\t\t}\n\t\tthrow error;\n\t}\n\tconst snapshot = selected?.snapshot ?? [...latest.values()].at(-1)!;\n\tconst mappedCwd = mapRestoredPath(cwd, mappings);\n\treturn mappings.length === 0\n\t\t? { status: \"verified\", snapshot, cwd: mappedCwd }\n\t\t: { status: \"restored\", snapshot, mappings, cwd: mappedCwd, warnings };\n}\n\n/** The one-line notice shown when a session or run continues in a restored worktree. */\nexport function formatWorktreeRestoreNotice(mapping: WorktreeRootMapping): string {\n\treturn `Restored worktree snapshot ${mapping.snapshotId.slice(0, 12)} of ${mapping.from} into ${mapping.to}`;\n}\n\n/** One line per restore warning, for the notices shown after a restore. */\nexport function formatWorktreeRestoreWarning(warning: WorktreeRestoreWarning): string {\n\tswitch (warning.code) {\n\t\tcase \"omitted-content\":\n\t\t\treturn `The restored snapshot left out ${warning.omitted.length} item(s): ${warning.omitted\n\t\t\t\t.map((omission) => (\"path\" in omission ? `${omission.path} (${omission.reason})` : omission.reason))\n\t\t\t\t.join(\", \")}`;\n\t\tcase \"filters\":\n\t\t\treturn `The source checkout used conversion settings (${[\n\t\t\t\twarning.filters.autocrlf === null ? undefined : `core.autocrlf=${warning.filters.autocrlf}`,\n\t\t\t\twarning.filters.eol === null ? undefined : `core.eol=${warning.filters.eol}`,\n\t\t\t\t...warning.filters.drivers.map((driver) => `filter=${driver}`),\n\t\t\t]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(\", \")}); the restore holds Git's stored content with LF line endings`;\n\t\tcase \"lfs-objects-unavailable\":\n\t\t\treturn `Git LFS objects could not be fetched; these files hold LFS pointers: ${warning.paths.join(\", \")}`;\n\t\tcase \"stale-restore-retained\":\n\t\t\tswitch (warning.kind) {\n\t\t\t\tcase \"worktree\":\n\t\t\t\t\treturn `A restore interrupted earlier left ${warning.path}; remove it with removeRestoredWorktree or delete the directory`;\n\t\t\t\tcase \"record\":\n\t\t\t\t\treturn `A restore interrupted earlier left the crash record ${warning.path}, which cannot be read; delete the file`;\n\t\t\t\tcase \"records-directory\":\n\t\t\t\t\treturn `The restore crash records in ${warning.path} cannot be read; make the directory readable or remove it`;\n\t\t\t}\n\t}\n}\n\n/**\n * One informational line per worktree restored since `since`, each followed by its snapshot's warnings and what the\n * restore itself reported.\n */\nexport function worktreeRestoreNotices(\n\tsessionManager: Pick<SessionManager, \"getBranch\" | \"getWorktreeSnapshotRecords\">,\n\tsince: string,\n): { readonly type: \"info\" | \"warning\"; readonly message: string }[] {\n\treturn restoreNotices(sessionManager, (restore) => restore.restoredAt >= since);\n}\n\nfunction restoreNotices(\n\tsessionManager: Pick<SessionManager, \"getBranch\" | \"getWorktreeSnapshotRecords\">,\n\tinclude: (restore: WorktreeRootMapping) => boolean,\n): { readonly type: \"info\" | \"warning\"; readonly message: string }[] {\n\tconst records = sessionManager.getWorktreeSnapshotRecords();\n\treturn sessionManager.getBranch().flatMap((entry) => {\n\t\tif (entry.type !== \"worktree_snapshot\" || !entry.restore || !include(entry.restore)) return [];\n\t\tconst snapshot = records.get(entry.snapshotId);\n\t\treturn [\n\t\t\t{ type: \"info\" as const, message: formatWorktreeRestoreNotice(entry.restore) },\n\t\t\t...[...(snapshot ? snapshotRestoreWarnings(snapshot) : []), ...(entry.restoreWarnings ?? [])].map(\n\t\t\t\t(warning) => ({ type: \"warning\" as const, message: formatWorktreeRestoreWarning(warning) }),\n\t\t\t),\n\t\t];\n\t});\n}\n\n/**\n * `entries` with each snapshot's record and blobs from `store` carried inline, each once, so the exported file\n * restores without the source storage. Without a store only the records are carried. A blob the store no longer has\n * is left out; restoring that snapshot then fails with `blob-missing`.\n */\nexport async function inlineSnapshotBlobs(\n\tentries: readonly SessionEntry[],\n\trecords: ReadonlyMap<string, WorktreeSnapshot>,\n\tstore: SnapshotBlobStore | undefined,\n): Promise<SessionEntry[]> {\n\tconst emittedRecords = new Set<string>();\n\tconst emittedBlobs = new Set<string>();\n\tconst result: SessionEntry[] = [];\n\tfor (const entry of entries) {\n\t\tif (entry.type !== \"worktree_snapshot\") {\n\t\t\tresult.push(entry);\n\t\t\tcontinue;\n\t\t}\n\t\tconst record = entry.snapshot ?? records.get(entry.snapshotId);\n\t\tconst { blobs: _carried, snapshot: _record, ...rest } = entry;\n\t\tconst blobs: Record<string, string> = {};\n\t\tif (record && store) {\n\t\t\tfor (const hash of snapshotBlobHashes(record)) {\n\t\t\t\tif (emittedBlobs.has(hash)) continue;\n\t\t\t\tconst data = await store.getBlob(hash);\n\t\t\t\tif (data === undefined) continue;\n\t\t\t\tblobs[hash] = Buffer.from(data).toString(\"base64\");\n\t\t\t\temittedBlobs.add(hash);\n\t\t\t}\n\t\t}\n\t\tconst carryRecord = record !== undefined && !emittedRecords.has(record.id);\n\t\tif (record) emittedRecords.add(record.id);\n\t\tresult.push({\n\t\t\t...rest,\n\t\t\t...(carryRecord ? { snapshot: record } : {}),\n\t\t\t...(Object.keys(blobs).length > 0 ? { blobs } : {}),\n\t\t});\n\t}\n\treturn result;\n}\n\n/**\n * Moves inline blobs into `store` after checking each against its hash, and returns the entries without them.\n * Without a store the entries keep their blobs, which restore reads directly. Throws `blob-corrupt` before writing\n * anything when a blob does not match its hash.\n */\nexport async function adoptInlineSnapshotBlobs(\n\tentries: readonly SessionEntry[],\n\tstore: SnapshotBlobStore | undefined,\n): Promise<SessionEntry[]> {\n\tconst blobs: SnapshotBlob[] = [];\n\tfor (const entry of entries) {\n\t\tif (entry.type !== \"worktree_snapshot\" || !entry.blobs) continue;\n\t\tfor (const [hash, base64] of Object.entries(entry.blobs)) {\n\t\t\tconst data = new Uint8Array(Buffer.from(base64, \"base64\"));\n\t\t\tif (sha256Hex(data) !== hash) {\n\t\t\t\tthrow new WorkspaceRestoreError(\"blob-corrupt\", { snapshotId: entry.snapshotId, blob: hash });\n\t\t\t}\n\t\t\tblobs.push({ hash, data });\n\t\t}\n\t}\n\tif (!store || blobs.length === 0) return [...entries];\n\tawait store.putBlobs(blobs);\n\treturn entries.map((entry) => {\n\t\tif (entry.type !== \"worktree_snapshot\" || !entry.blobs) return entry;\n\t\tconst { blobs: _moved, ...rest } = entry;\n\t\treturn rest;\n\t});\n}\n\n/** A read-only view of the blobs carried inline by `entries`. */\nexport function inlineBlobStore(entries: readonly SessionEntry[]): SnapshotBlobStore {\n\tconst blobs = new Map<string, string>();\n\tfor (const entry of entries) {\n\t\tif (entry.type === \"worktree_snapshot\" && entry.blobs) {\n\t\t\tfor (const [hash, base64] of Object.entries(entry.blobs)) blobs.set(hash, base64);\n\t\t}\n\t}\n\treturn {\n\t\tasync putBlobs() {\n\t\t\tthrow new WorkspaceSnapshotError(\"blob-store-unsupported\", \"inline\");\n\t\t},\n\t\tasync getBlob(hash) {\n\t\t\tconst base64 = blobs.get(hash);\n\t\t\treturn base64 === undefined ? undefined : new Uint8Array(Buffer.from(base64, \"base64\"));\n\t\t},\n\t\tasync refreshBlobs(hashes) {\n\t\t\treturn hashes.every((hash) => blobs.has(hash));\n\t\t},\n\t\tasync listBlobHashes() {\n\t\t\treturn [...blobs.keys()];\n\t\t},\n\t};\n}\n\n/** Reads `primary` first, then the blobs carried inline by `entries`. */\nexport function sessionSnapshotBlobs(\n\tprimary: SnapshotBlobStore | undefined,\n\tentries: readonly SessionEntry[],\n): SnapshotBlobStore {\n\tconst inline = inlineBlobStore(entries);\n\tif (!primary) return inline;\n\treturn {\n\t\tputBlobs: (blobs) => primary.putBlobs(blobs),\n\t\tgetBlob: async (hash) => (await primary.getBlob(hash)) ?? (await inline.getBlob(hash)),\n\t\trefreshBlobs: (hashes) => primary.refreshBlobs(hashes),\n\t\tlistBlobHashes: () => primary.listBlobHashes(),\n\t};\n}\n\n/** What an export of `entries` carries: checkouts, snapshots and the bytes of patch and bundle content. */\nexport function describeSnapshotExport(\n\tentries: readonly SessionEntry[],\n\trecords: ReadonlyMap<string, WorktreeSnapshot>,\n): string | undefined {\n\tconst roots = new Set<string>();\n\tconst snapshots = new Set<string>();\n\tconst blobBytes = new Map<string, number>();\n\tlet omitted = 0;\n\tfor (const entry of entries) {\n\t\tif (entry.type !== \"worktree_snapshot\" || snapshots.has(entry.snapshotId)) continue;\n\t\tsnapshots.add(entry.snapshotId);\n\t\tconst record = entry.snapshot ?? records.get(entry.snapshotId);\n\t\tif (!record) continue;\n\t\troots.add(record.root);\n\t\tomitted += record.omitted.length;\n\t\tfor (const link of record.chain) if (link.patch) blobBytes.set(link.patch, link.bytes);\n\t\tif (record.bundle) blobBytes.set(record.bundle.blob, record.bundle.bytes);\n\t}\n\tif (snapshots.size === 0) return undefined;\n\tconst bytes = [...blobBytes.values()].reduce((sum, size) => sum + size, 0);\n\treturn `Includes ${snapshots.size} worktree snapshot(s) of ${[...roots].join(\", \")}: ${bytes} bytes of patch and bundle content${omitted > 0 ? `, ${omitted} omitted item(s) not included` : \"\"}`;\n}\n\nexport type WorktreeSnapshotComparison =\n\t| { readonly status: \"match\"; readonly tree: string; readonly head?: string }\n\t| { readonly status: \"missing\"; readonly reason: WorktreeSnapshotUnavailableReason }\n\t| {\n\t\t\treadonly status: \"differs\";\n\t\t\treadonly head: string;\n\t\t\treadonly tree: string;\n\t\t\t/** `git diff --stat` from the snapshot's tree to the current one, when the snapshot's tree is present locally. */\n\t\t\treadonly stat: string | undefined;\n\t };\n\n/** Compares the checkout at `dir` with `snapshot`, for `/session snapshot`. */\nexport async function compareWorktreeSnapshot(\n\tsnapshot: WorktreeSnapshot,\n\tdir: string,\n\tsettings: WorktreeSnapshotSettings,\n): Promise<WorktreeSnapshotComparison> {\n\tconst checkout = await locateCheckout(dir);\n\tif (checkout instanceof Error) return { status: \"missing\", reason: checkout };\n\tconst present = await runGit([\"cat-file\", \"-e\", `${snapshot.tree}^{tree}`], {\n\t\tcwd: checkout.root,\n\t\tallowExitCodes: [1, 128],\n\t});\n\tconst policy = await loadSnapshotPathPolicy(checkout.root);\n\tconst state = await withScratchDirectory((scratch) =>\n\t\twriteWorkingTree(checkout, settings, policy, scratch, present.exitCode === 0 ? { seedTree: snapshot.tree } : {}),\n\t);\n\tif (state.tree === snapshot.tree) {\n\t\tif (checkout.head === snapshot.head) return { status: \"match\", tree: state.tree };\n\t\tconst drift = new WorkspaceDriftError({\n\t\t\troot: checkout.root,\n\t\t\texpectedHead: snapshot.head,\n\t\t\tactualHead: checkout.head,\n\t\t\texpectedTree: snapshot.tree,\n\t\t\tactualTree: state.tree,\n\t\t\tsnapshotId: snapshot.id,\n\t\t});\n\t\tif (await isHeadOnlyAdvance(drift)) return { status: \"match\", tree: state.tree, head: checkout.head };\n\t}\n\tconst stat =\n\t\tpresent.exitCode === 0\n\t\t\t? await gitText([\"diff-tree\", \"--stat\", \"--no-renames\", \"--no-ext-diff\", \"-r\", snapshot.tree, state.tree], {\n\t\t\t\t\tcwd: checkout.root,\n\t\t\t\t})\n\t\t\t: undefined;\n\treturn { status: \"differs\", head: checkout.head, tree: state.tree, stat };\n}\n\n/** Lines describing `snapshot` for `/session snapshot`. */\nexport function describeWorktreeSnapshot(root: string, snapshot: WorktreeSnapshot): string[] {\n\tconst omitted = snapshot.omitted.map((omission) =>\n\t\t\"path\" in omission\n\t\t\t? `${omission.path} (${omission.reason})`\n\t\t\t: `${omission.commits.length} commit(s) (${omission.reason})`,\n\t);\n\treturn [\n\t\t`${root}`,\n\t\t` snapshot ${snapshot.id} captured ${snapshot.capturedAt}`,\n\t\t` ${snapshot.branch ?? \"detached\"} at ${snapshot.head.slice(0, 12)}, tree ${snapshot.tree.slice(0, 12)}`,\n\t\t` delta chain ${snapshot.chain.length} link(s), ${snapshot.chain.reduce((sum, link) => sum + link.bytes, 0)} bytes; ${\n\t\t\tsnapshot.bundle\n\t\t\t\t? `${snapshot.bundle.commits.length} unpushed commit(s) bundled`\n\t\t\t\t: \"no unpushed commits bundled\"\n\t\t}`,\n\t\t...(omitted.length > 0 ? [` omitted: ${omitted.join(\", \")}`] : []),\n\t\t...(snapshot.filters\n\t\t\t? snapshotRestoreWarnings({ ...snapshot, omitted: [] }).map(formatWorktreeRestoreWarning)\n\t\t\t: []),\n\t];\n}\n\n/**\n * Opens `sessionManager`'s session where it should continue: in place when its checkout matches the last snapshot,\n * in the restored worktree otherwise. Returns the notices to show for a restore it performed.\n */\nexport async function openSessionInWorktree(\n\tsessionManager: SessionManager,\n\toptions: ResumeSessionWorktreeOptions & { readonly sessionDirectory?: string },\n): Promise<{\n\treadonly sessionManager: SessionManager;\n\treadonly notices: { readonly type: \"info\" | \"warning\"; readonly message: string }[];\n}> {\n\tconst resume = await resumeSessionWorktree(sessionManager, options);\n\treturn openResumedSession(\n\t\tsessionManager,\n\t\tresume.status === \"none\" ? sessionManager.getCwd() : resume.cwd,\n\t\tresume.status === \"restored\" ? resume.mappings : [],\n\t\toptions.sessionDirectory,\n\t);\n}\n\n/**\n * Opens `sessionManager`'s session in `cwd`, where resuming it left its working directory, and returns the notices to\n * show for the worktrees that resuming `restored` it into.\n */\nexport async function openResumedSession(\n\tsessionManager: SessionManager,\n\tcwd: string,\n\trestored: readonly WorktreeRootMapping[],\n\tsessionDirectory?: string,\n): Promise<{\n\treadonly sessionManager: SessionManager;\n\treadonly notices: { readonly type: \"info\" | \"warning\"; readonly message: string }[];\n}> {\n\tconst opened =\n\t\tcwd !== sessionManager.getCwd()\n\t\t\t? await sessionManager.openSessionById(sessionManager.getSessionId(), cwd, sessionDirectory)\n\t\t\t: sessionManager;\n\tconst restoredHere = new Set(restored.map((mapping) => mapping.to));\n\treturn { sessionManager: opened, notices: restoreNotices(opened, (restore) => restoredHere.has(restore.to)) };\n}\n\n/**\n * Whether a session recorded elsewhere continues in `cwd` because a restore moved its checkout there, so opening it\n * from `cwd` resumes it rather than forking it into another project.\n */\nexport async function sessionContinuesIn(store: SessionStore, sessionId: string, cwd: string): Promise<boolean> {\n\tconst { header, entries } = await store.load(sessionId);\n\tconst mappings = entries.flatMap((entry) =>\n\t\tentry.type === \"worktree_snapshot\" && entry.restore ? [entry.restore] : [],\n\t);\n\tif (mappings.length === 0) return false;\n\tconst mapped = mapRestoredPath(header.cwd, mappings);\n\treturn canonicalizeWorktreePath(mapped) === canonicalizeWorktreePath(cwd);\n}\n\n/** The restores recorded on `branch`, oldest first. */\nfunction restoreMappings(branch: readonly SessionEntry[]): WorktreeRootMapping[] {\n\treturn branch.flatMap((entry) => (entry.type === \"worktree_snapshot\" && entry.restore ? [entry.restore] : []));\n}\n\n/** The restores and current snapshots of the branch of stored `entries` that ends at `leafId`, as resume finds them. */\nfunction storedBranchSnapshots(\n\tentries: readonly SessionEntry[],\n\tleafId: string | undefined,\n): { readonly mappings: WorktreeRootMapping[]; readonly current: Map<string, WorktreeSnapshot> } {\n\tconst branch = getBranchPath(leafId, new Map(entries.map((entry) => [entry.id, entry])));\n\tconst records = new Map<string, WorktreeSnapshot>();\n\tfor (const entry of entries) {\n\t\tif (entry.type === \"worktree_snapshot\" && entry.snapshot) records.set(entry.snapshotId, entry.snapshot);\n\t}\n\tconst mappings = restoreMappings(branch);\n\tconst current = currentWorktreeSnapshots({\n\t\tgetBranch: () => branch,\n\t\tgetWorktreeRootMappings: () => mappings,\n\t\tgetWorktreeSnapshotRecords: () => records,\n\t});\n\treturn { mappings, current };\n}\n\n/**\n * Whether a session runs in a checkout it recorded snapshots of: its working directory, followed through the restores\n * it recorded, lies inside a checkout the branch it reopens on recorded a snapshot of. Opening such a session from\n * another directory resumes it against that checkout, verified in place or restored into a fresh worktree, instead of\n * forking it into the other directory.\n */\nexport async function sessionRunsInRecordedCheckout(store: SessionStore, sessionId: string): Promise<boolean> {\n\tconst { header, entries } = await store.load(sessionId);\n\tconst { mappings, current } = storedBranchSnapshots(entries, entries.at(-1)?.id);\n\tconst cwd = mapRestoredPath(header.cwd, mappings);\n\treturn [...current.keys()].some((root) => isInside(root, cwd));\n}\n"]}
1
+ {"version":3,"file":"session-worktree-snapshots.js","sourceRoot":"","sources":["../../src/core/session-worktree-snapshots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAG/D,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAG/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EACN,uBAAuB,EACvB,cAAc,EAEd,oBAAoB,EACpB,gBAAgB,GAChB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EACN,kBAAkB,EAElB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EAEnB,qBAAqB,EACrB,sBAAsB,GACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,E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AAG,EAA4B,CAAC;IACpD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,KAAK,CAAC,IAAI,KAAK,mBAAmB,IAAI,KAAK,CAAC,QAAQ;YAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACzG,CAAC;IACD,MAAM,QAAQ,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,wBAAwB,CAAC;QACxC,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM;QACvB,uBAAuB,EAAE,GAAG,EAAE,CAAC,QAAQ;QACvC,0BAA0B,EAAE,GAAG,EAAE,CAAC,OAAO;KACzC,CAAC,CAAC;IACH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAAC,KAAmB,EAAE,SAAiB;IACzF,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxD,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,qBAAqB,CAAC,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IACxF,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAClD,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { stat } from \"node:fs/promises\";\nimport { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport type { AssistantMessage } from \"@bastani/pi-ai/compat\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport { getBranchPath, getSessionLeafId } from \"./session-manager-history.ts\";\nimport type { SessionEntry, WorktreeRestoreHostWarning } from \"./session-manager-types.ts\";\nimport type { SessionStore } from \"./storage/session/types.js\";\nimport { snapshotBlobHashes } from \"./worktree-snapshot/blob-store.ts\";\nimport {\n\tcaptureWorktreeSnapshot,\n\tlocateCheckout,\n\ttype WorktreeSnapshotUnavailableReason,\n\twithScratchDirectory,\n\twriteWorkingTree,\n} from \"./worktree-snapshot/capture.ts\";\nimport { sha256Hex } from \"./worktree-snapshot/env-hash.ts\";\nimport {\n\tfindWorkspaceError,\n\ttype GitUnavailableError,\n\tisGitUnavailableError,\n\tisWorkspaceDriftError,\n\tisWorkspaceError,\n\tisWorkspaceRestoreError,\n\tisWorkspaceSnapshotError,\n\tunreadablePathError,\n\tWorkspaceDriftError,\n\ttype WorkspaceError,\n\tWorkspaceRestoreError,\n\tWorkspaceSnapshotError,\n} from \"./worktree-snapshot/errors.ts\";\nimport { scheduleSnapshotCollection } from \"./worktree-snapshot/garbage.ts\";\nimport { gitText, runGit } from \"./worktree-snapshot/git.ts\";\nimport { isHeadOnlyAdvance } from \"./worktree-snapshot/head-advance.ts\";\nimport { canonicalizeWorktreePath } from \"./worktree-snapshot/paths.ts\";\nimport { loadSnapshotPathPolicy } from \"./worktree-snapshot/policy.ts\";\nimport {\n\tisDegradableRestoreFailure,\n\tremoveRestoredWorktree,\n\trestoreDegradedWorktree,\n\trestoreWorktree,\n\tsnapshotRestoreWarnings,\n\tverifyWorktree,\n} from \"./worktree-snapshot/restore.ts\";\nimport type {\n\tSnapshotBlob,\n\tSnapshotBlobStore,\n\tWorktreeDegradedRestore,\n\tWorktreeRestoreWarning,\n\tWorktreeRootMapping,\n\tWorktreeSnapshot,\n\tWorktreeSnapshotSettings,\n\tWorktreeUnrestored,\n} from \"./worktree-snapshot/types.ts\";\n\n/** Why a turn's snapshot could not be recorded: Git is unavailable, or a typed workspace failure. */\nexport type WorktreeSnapshotUnavailable = WorkspaceError | GitUnavailableError;\n\n/** Built-in tools that can change files: a turn that called one records a snapshot. */\nexport const FILE_WRITING_TOOLS: ReadonlySet<string> = new Set([\"bash\", \"edit\", \"write\", \"powershell\"]);\nconst PATH_TOOLS: ReadonlySet<string> = new Set([\"edit\", \"write\"]);\n\nexport interface TurnSnapshotDependencies {\n\treadonly sessionManager: SessionManager;\n\treadonly cwd: () => string;\n\treadonly settings: () => WorktreeSnapshotSettings;\n\t/** Whether a registered tool declares `writesFiles`. */\n\treadonly declaresWrites: (toolName: string) => boolean;\n\t/** Called once per distinct reason a snapshot could not be recorded. */\n\treadonly onUnavailable: (reason: WorktreeSnapshotUnavailable) => void;\n}\n\nfunction isInside(parent: string, child: string): boolean {\n\tconst path = relative(canonicalizeWorktreePath(parent), canonicalizeWorktreePath(child));\n\treturn path === \"\" || (!path.startsWith(`..${sep}`) && path !== \"..\" && !isAbsolute(path));\n}\n\n/**\n * Records a `worktree_snapshot` entry per checkout at the end of each turn that called a file-writing tool. In-memory\n * sessions, which cannot be resumed elsewhere, record nothing.\n */\nexport class SessionWorktreeSnapshotRecorder {\n\tprivate readonly deps: TurnSnapshotDependencies;\n\tprivate readonly reported = new Set<string>();\n\n\tconstructor(deps: TurnSnapshotDependencies) {\n\t\tthis.deps = deps;\n\t}\n\n\tprivate report(reason: WorktreeSnapshotUnavailable): void {\n\t\tconst key = `${reason.code}\\0${JSON.stringify(reason.fields)}`;\n\t\tif (this.reported.has(key)) return;\n\t\tthis.reported.add(key);\n\t\tthis.deps.onUnavailable(reason);\n\t}\n\n\t/** Directories whose checkouts a turn may have changed: the session cwd and the targets of path-taking tools. */\n\tprivate touchedDirectories(message: AssistantMessage): string[] | undefined {\n\t\tconst cwd = this.deps.cwd();\n\t\tconst directories = new Set<string>();\n\t\tfor (const part of message.content) {\n\t\t\tif (part.type !== \"toolCall\") continue;\n\t\t\tif (!FILE_WRITING_TOOLS.has(part.name) && !this.deps.declaresWrites(part.name)) continue;\n\t\t\tdirectories.add(cwd);\n\t\t\tconst path = PATH_TOOLS.has(part.name) ? part.arguments.path : undefined;\n\t\t\tif (typeof path === \"string\" && path.length > 0) directories.add(resolve(cwd, path, \"..\"));\n\t\t}\n\t\treturn directories.size === 0 ? undefined : [...directories];\n\t}\n\n\t/** Whether the turn may record a snapshot when it ends: a persisted session called a tool that can change files. */\n\tcallsFileWritingTool(message: AssistantMessage): boolean {\n\t\treturn this.deps.sessionManager.isPersisted() && this.touchedDirectories(message) !== undefined;\n\t}\n\n\tasync recordTurn(message: AssistantMessage): Promise<void> {\n\t\tconst directories = this.touchedDirectories(message);\n\t\tif (!directories) return;\n\t\tlet settings: WorktreeSnapshotSettings;\n\t\ttry {\n\t\t\tsettings = this.deps.settings();\n\t\t} catch (error) {\n\t\t\tthis.reportFailure(error);\n\t\t\treturn;\n\t\t}\n\t\tif (!settings.enabled || !this.deps.sessionManager.isPersisted()) return;\n\t\tconst blobs = this.deps.sessionManager.getSessionStore().snapshotBlobs;\n\t\tif (!blobs) {\n\t\t\tthis.report(\n\t\t\t\tnew WorkspaceSnapshotError(\n\t\t\t\t\t\"blob-store-unsupported\",\n\t\t\t\t\tthis.deps.sessionManager.getSessionStore().descriptor.adapter,\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tconst roots = new Set<string>();\n\t\tfor (const directory of directories) {\n\t\t\ttry {\n\t\t\t\tconst checkout = await locateCheckout(await nearestExisting(directory));\n\t\t\t\tif (checkout instanceof Error) this.report(checkout);\n\t\t\t\telse roots.add(checkout.root);\n\t\t\t} catch (error) {\n\t\t\t\tthis.reportFailure(error);\n\t\t\t}\n\t\t}\n\t\tfor (const root of roots) {\n\t\t\tconst previous = this.deps.sessionManager.getLatestWorktreeSnapshots().get(root);\n\t\t\ttry {\n\t\t\t\tconst result = await captureWorktreeSnapshot(root, { settings, previous, blobs });\n\t\t\t\tif (result.status === \"captured\") {\n\t\t\t\t\tawait this.deps.sessionManager.appendWorktreeSnapshot(root, result.snapshot.id, result.snapshot);\n\t\t\t\t} else if (result.status === \"unchanged\") {\n\t\t\t\t\tawait this.deps.sessionManager.appendWorktreeSnapshot(root, result.snapshot.id);\n\t\t\t\t} else if (result.status === \"unavailable\") {\n\t\t\t\t\tthis.report(result.reason);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tthis.reportFailure(error);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Starts an automatic collection of the session store's unreferenced snapshot blobs when one is due, and returns\n\t * without waiting for it. Called when the session closes.\n\t */\n\tscheduleCollection(): void {\n\t\tlet settings: WorktreeSnapshotSettings;\n\t\ttry {\n\t\t\tsettings = this.deps.settings();\n\t\t} catch (error) {\n\t\t\tthis.reportFailure(error);\n\t\t\treturn;\n\t\t}\n\t\tvoid scheduleSnapshotCollection(this.deps.sessionManager.getSessionStore().snapshotBlobs, settings);\n\t}\n\n\tprivate reportFailure(error: unknown): void {\n\t\tconst reason = isGitUnavailableError(error) ? error : findWorkspaceError(error);\n\t\tif (!reason) throw error;\n\t\tthis.report(reason);\n\t}\n}\n\nasync function nearestExisting(directory: string): Promise<string> {\n\tfor (let current = directory; ; current = resolve(current, \"..\")) {\n\t\ttry {\n\t\t\tif ((await stat(current)).isDirectory()) return current;\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code !== \"ENOENT\" && (error as NodeJS.ErrnoException).code !== \"ENOTDIR\")\n\t\t\t\tthrow unreadablePathError(current, error);\n\t\t}\n\t\tif (resolve(current, \"..\") === current) return current;\n\t}\n}\n\n/** `path` rewritten through each restore in order: a path under `from` moves to the same place under `to`. */\nexport function mapRestoredPath(path: string, mappings: readonly WorktreeRootMapping[]): string {\n\tlet mapped = resolve(path);\n\tlet next = 0;\n\twhile (next < mappings.length) {\n\t\tconst current = canonicalizeWorktreePath(mapped);\n\t\tlet best: { index: number; source: string } | undefined;\n\t\tfor (let index = next; index < mappings.length; index++) {\n\t\t\tconst source = canonicalizeWorktreePath(mappings[index]!.from);\n\t\t\tif (isInside(source, current) && (best === undefined || source.length > best.source.length)) {\n\t\t\t\tbest = { index, source };\n\t\t\t}\n\t\t}\n\t\tif (best === undefined) break;\n\t\tmapped = resolve(mappings[best.index]!.to, relative(best.source, current));\n\t\tnext = best.index + 1;\n\t}\n\treturn mapped;\n}\n\n/** Recover the original root of a sequence of restores, so a restored root supersedes its earlier location. */\nfunction originalRoot(root: string, mappings: readonly WorktreeRootMapping[]): string {\n\tlet current = canonicalizeWorktreePath(root);\n\tfor (let index = mappings.length - 1; index >= 0; index--) {\n\t\tconst mapping = mappings[index]!;\n\t\tif (canonicalizeWorktreePath(mapping.to) === current) current = canonicalizeWorktreePath(mapping.from);\n\t}\n\treturn current;\n}\n\n/** The id of the latest snapshot of each checkout on the active branch, keyed by the root it was first recorded under. */\nfunction latestSnapshotIdsByCheckout(\n\tsessionManager: Pick<SessionManager, \"getBranch\">,\n\tmappings: readonly WorktreeRootMapping[],\n): Map<string, string> {\n\tconst latestIds = new Map<string, string>();\n\tfor (const entry of sessionManager.getBranch()) {\n\t\tif (entry.type === \"worktree_snapshot\") latestIds.set(originalRoot(entry.root, mappings), entry.snapshotId);\n\t}\n\treturn latestIds;\n}\n\n/** The checkouts on the active branch whose latest snapshot the session holds no record of, where they are now (#4733). */\nexport function missingSnapshotRecords(\n\tsessionManager: Pick<SessionManager, \"getBranch\" | \"getWorktreeRootMappings\" | \"getWorktreeSnapshotRecords\">,\n): MissingSnapshotRecord[] {\n\tconst mappings = sessionManager.getWorktreeRootMappings();\n\tconst records = sessionManager.getWorktreeSnapshotRecords();\n\tconst missing: MissingSnapshotRecord[] = [];\n\tfor (const [original, snapshotId] of latestSnapshotIdsByCheckout(sessionManager, mappings)) {\n\t\tif (!records.has(snapshotId)) missing.push({ root: mapRestoredPath(original, mappings), snapshotId });\n\t}\n\treturn missing;\n}\n\n/**\n * The latest snapshot of each checkout on the active branch, keyed by where that checkout is now: a checkout restored\n * elsewhere appears once, under its newest location. A snapshot whose record is missing is left out.\n */\nexport function currentWorktreeSnapshots(\n\tsessionManager: Pick<SessionManager, \"getBranch\" | \"getWorktreeRootMappings\" | \"getWorktreeSnapshotRecords\">,\n): Map<string, WorktreeSnapshot> {\n\tconst mappings = sessionManager.getWorktreeRootMappings();\n\tconst records = sessionManager.getWorktreeSnapshotRecords();\n\tconst current = new Map<string, WorktreeSnapshot>();\n\tfor (const [original, snapshotId] of latestSnapshotIdsByCheckout(sessionManager, mappings)) {\n\t\tconst snapshot = records.get(snapshotId);\n\t\tif (snapshot) current.set(mapRestoredPath(original, mappings), snapshot);\n\t}\n\treturn current;\n}\n\n/** A checkout a resume continued without, because nothing of its snapshot could be restored here (#4733). */\nexport interface UnrestoredWorktree {\n\treadonly root: string;\n\treadonly snapshot: WorktreeSnapshot;\n\t/** Why: the restore error, or Git being unavailable. */\n\treadonly reason: Error;\n\t/** The record the resume wrote for it in the session. */\n\treadonly record: WorktreeUnrestored;\n}\n\n/** A checkout whose latest snapshot the session refers to without holding its record (#4733). */\nexport interface MissingSnapshotRecord {\n\treadonly root: string;\n\treadonly snapshotId: string;\n}\n\nexport type SessionWorktreeResume =\n\t| { readonly status: \"none\"; readonly missingRecords?: readonly MissingSnapshotRecord[] }\n\t| {\n\t\t\treadonly status: \"verified\";\n\t\t\treadonly snapshot: WorktreeSnapshot;\n\t\t\treadonly cwd: string;\n\t\t\treadonly unrestored: readonly UnrestoredWorktree[];\n\t\t\treadonly missingRecords?: readonly MissingSnapshotRecord[];\n\t }\n\t| {\n\t\t\treadonly status: \"restored\";\n\t\t\treadonly snapshot: WorktreeSnapshot;\n\t\t\treadonly mappings: readonly WorktreeRootMapping[];\n\t\t\treadonly cwd: string;\n\t\t\treadonly warnings: readonly WorktreeRestoreWarning[];\n\t\t\treadonly unrestored: readonly UnrestoredWorktree[];\n\t\t\treadonly missingRecords?: readonly MissingSnapshotRecord[];\n\t };\n\nexport interface ResumeSessionWorktreeOptions {\n\treadonly settings: WorktreeSnapshotSettings;\n\t/** Host directory for shared object stores and restored worktrees. Default ~/.atomic/agent/worktree-snapshots. */\n\treadonly storeDir?: string;\n\treadonly signal?: AbortSignal;\n\t/**\n\t * Called with the new mappings, none when nothing needed restoring, once every checkout is restored and before any\n\t * of them is recorded. When it throws, nothing is recorded and the restored worktrees are removed, as for a failed\n\t * restore.\n\t */\n\treadonly beforeRecord?: (mappings: readonly WorktreeRootMapping[]) => Promise<void>;\n\t/**\n\t * Mappings to checkouts already here that the session continues in, applied as if recorded while deciding what to\n\t * restore, and recorded first, with the restores, only once every checkout is restored and `beforeRecord` passed.\n\t */\n\treadonly pendingMappings?: readonly WorktreeRootMapping[];\n\t/** Checkouts, by the root the session's restores put them at, to continue in as they are without verifying them. */\n\treadonly keepInPlace?: ReadonlySet<string>;\n\t/**\n\t * Checkouts, by the same roots, that cannot be restored on this host, with the reason, such as Git being\n\t * unavailable: the resume continues without them, as for a restore that gives nothing (#4733).\n\t */\n\treadonly cannotRestore?: ReadonlyMap<string, Error>;\n\t/**\n\t * Where the session continues when the checkout it works in is not restored and its working directory is not on\n\t * this host: the directory the resume started from. Default: the recorded working directory.\n\t */\n\treadonly fallbackCwd?: string;\n\t/**\n\t * Continue without a checkout whose latest snapshot the session holds no record of, listing it in `missingRecords`,\n\t * instead of failing with `snapshot-not-found` before anything is restored (#4733).\n\t */\n\treadonly skipMissingRecords?: boolean;\n}\n\n/**\n * Whether a failed restore of one checkout leaves the resume able to continue without the exact state (#4733): any\n * typed workspace or Git failure, except a snapshot record that fails the security checks (`invalid-snapshot`) and a\n * target that holds other files (`unsafe-target`), which refuse the resume.\n */\nexport function isRecoverableRestoreFailure(error: unknown): error is Error {\n\tif (isWorkspaceRestoreError(error) && (error.code === \"invalid-snapshot\" || error.code === \"unsafe-target\")) {\n\t\treturn false;\n\t}\n\treturn (isWorkspaceError(error) && error.code !== \"invalid-setting\") || isGitUnavailableError(error);\n}\n\n/** The commits of the checkout's earlier snapshots on the branch, newest first, to restore when its own is out of reach. */\nfunction earlierSnapshotHeads(\n\tsessionManager: Pick<SessionManager, \"getBranch\" | \"getWorktreeSnapshotRecords\">,\n\toriginal: string,\n\tmappings: readonly WorktreeRootMapping[],\n\tsnapshot: WorktreeSnapshot,\n): string[] {\n\tconst records = sessionManager.getWorktreeSnapshotRecords();\n\tconst heads: string[] = [];\n\tfor (const entry of [...sessionManager.getBranch()].reverse()) {\n\t\tif (entry.type !== \"worktree_snapshot\" || originalRoot(entry.root, mappings) !== original) continue;\n\t\tconst head = records.get(entry.snapshotId)?.head;\n\t\tif (head !== undefined && head !== snapshot.head && !heads.includes(head)) heads.push(head);\n\t\tif (heads.length === 3) break;\n\t}\n\treturn heads;\n}\n\n/** What a resume tells about a checkout it continued without: why, as a clause, and what to do. */\nfunction unrestoredReason(snapshot: WorktreeSnapshot, reason: Error): { detail: string; hint: string } {\n\tconst head = snapshot.head.slice(0, 12);\n\tif (isGitUnavailableError(reason)) {\n\t\treturn {\n\t\t\tdetail: `Git is unavailable here (${reason.code}), which checking and restoring it need`,\n\t\t\thint: reason.hint ?? \"\",\n\t\t};\n\t}\n\tif (isWorkspaceRestoreError(reason)) {\n\t\tswitch (reason.code) {\n\t\t\tcase \"commits-unavailable\":\n\t\t\t\treturn {\n\t\t\t\t\tdetail:\n\t\t\t\t\t\treason.reason === \"denied-history\"\n\t\t\t\t\t\t\t? `its commit ${head} is not on its recorded remotes, and its unpushed commits touch files snapshots never copy`\n\t\t\t\t\t\t\t: reason.reason === \"bundle-over-cap\"\n\t\t\t\t\t\t\t\t? `its commit ${head} is not on its recorded remotes, and its unpushed commits were too large to record`\n\t\t\t\t\t\t\t\t: `its commit ${head} and the commits around it are not on its recorded remotes`,\n\t\t\t\t\thint: reason.hint,\n\t\t\t\t};\n\t\t\tcase \"snapshot-not-found\":\n\t\t\t\treturn { detail: \"the session holds no record of its snapshot\", hint: reason.hint };\n\t\t\tcase \"blob-missing\":\n\t\t\tcase \"blob-corrupt\":\n\t\t\t\treturn { detail: \"part of its recorded content is not in this storage\", hint: reason.hint };\n\t\t\tdefault:\n\t\t\t\treturn { detail: reason.summary, hint: reason.hint };\n\t\t}\n\t}\n\treturn {\n\t\tdetail: isWorkspaceError(reason) ? reason.summary : reason.message,\n\t\thint: isWorkspaceError(reason) ? reason.hint : \"\",\n\t};\n}\n\n/**\n * Checks the latest recorded snapshot of each checkout on the active session branch. Drifted or missing checkouts are\n * restored into fresh worktrees, and each old→new mapping is recorded only after all checkouts have been restored.\n * The returned cwd follows those mappings. A HEAD-only advance over identical content also resumes in place.\n */\nexport async function resumeSessionWorktree(\n\tsessionManager: SessionManager,\n\toptions: ResumeSessionWorktreeOptions,\n): Promise<SessionWorktreeResume> {\n\tif (!options.settings.enabled) return { status: \"none\" };\n\tconst pending = options.pendingMappings ?? [];\n\tconst existing = [...sessionManager.getWorktreeRootMappings(), ...pending];\n\tconst records = sessionManager.getWorktreeSnapshotRecords();\n\tconst latestIds = latestSnapshotIdsByCheckout(sessionManager, existing);\n\tconst latest = new Map<string, WorktreeSnapshot>();\n\tconst missingRecords: MissingSnapshotRecord[] = [];\n\tfor (const [root, snapshotId] of latestIds) {\n\t\tconst snapshot = records.get(snapshotId);\n\t\tif (!snapshot && options.skipMissingRecords) {\n\t\t\tmissingRecords.push({ root: mapRestoredPath(root, existing), snapshotId });\n\t\t\tcontinue;\n\t\t}\n\t\tif (!snapshot) throw new WorkspaceRestoreError(\"snapshot-not-found\", { snapshotId, target: root });\n\t\tlatest.set(root, snapshot);\n\t}\n\tif (latest.size === 0) return missingRecords.length === 0 ? { status: \"none\" } : { status: \"none\", missingRecords };\n\tconst cwd = mapRestoredPath(sessionManager.getCwd(), existing);\n\tconst mappings: WorktreeRootMapping[] = [];\n\tconst warnings: WorktreeRestoreWarning[] = [];\n\tconst hostWarnings = new Map<WorktreeRootMapping, WorktreeRestoreHostWarning[]>();\n\tconst reportedLeftovers = new Set<string>();\n\tconst left: { root: string; snapshot: WorktreeSnapshot; reason: Error }[] = [];\n\tconst unrestored: UnrestoredWorktree[] = [];\n\tlet continuedIn: string;\n\tlet selected: { root: string; snapshot: WorktreeSnapshot } | undefined;\n\ttry {\n\t\tfor (const [original, snapshot] of latest) {\n\t\t\toptions.signal?.throwIfAborted();\n\t\t\tconst root = mapRestoredPath(original, existing);\n\t\t\tif (isInside(root, cwd) && (!selected || root.length > selected.root.length)) selected = { root, snapshot };\n\t\t\tif (options.keepInPlace?.has(root)) continue;\n\t\t\tconst cannot = options.cannotRestore?.get(root);\n\t\t\tif (cannot !== undefined) {\n\t\t\t\tleft.push({ root, snapshot, reason: cannot });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet drift: WorkspaceDriftError;\n\t\t\ttry {\n\t\t\t\tawait verifyWorktree(snapshot, root, { settings: options.settings, signal: options.signal });\n\t\t\t\tcontinue;\n\t\t\t} catch (error) {\n\t\t\t\toptions.signal?.throwIfAborted();\n\t\t\t\tif (isWorkspaceDriftError(error)) {\n\t\t\t\t\tif (await isHeadOnlyAdvance(error, options.signal)) continue;\n\t\t\t\t\tdrift = error;\n\t\t\t\t} else if (isWorkspaceSnapshotError(error)) {\n\t\t\t\t\tdrift = new WorkspaceDriftError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\troot,\n\t\t\t\t\t\t\texpectedHead: snapshot.head,\n\t\t\t\t\t\t\tactualHead: null,\n\t\t\t\t\t\t\texpectedTree: snapshot.tree,\n\t\t\t\t\t\t\tactualTree: null,\n\t\t\t\t\t\t\tsnapshotId: snapshot.id,\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t} else throw error;\n\t\t\t}\n\t\t\tconst refused = (error: Error) =>\n\t\t\t\tnew WorkspaceDriftError(\n\t\t\t\t\t{\n\t\t\t\t\t\troot: drift.root,\n\t\t\t\t\t\texpectedHead: drift.expectedHead,\n\t\t\t\t\t\tactualHead: drift.actualHead,\n\t\t\t\t\t\texpectedTree: drift.expectedTree,\n\t\t\t\t\t\tactualTree: drift.actualTree,\n\t\t\t\t\t\tsnapshotId: drift.snapshotId,\n\t\t\t\t\t\treason: \"restore-failed\",\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\tconst blobs = sessionSnapshotBlobs(\n\t\t\t\tsessionManager.getSessionStore().snapshotBlobs,\n\t\t\t\tsessionManager.getEntries(),\n\t\t\t);\n\t\t\tlet restored: {\n\t\t\t\tpath: string;\n\t\t\t\twarnings: readonly WorktreeRestoreWarning[];\n\t\t\t\tdegraded?: WorktreeDegradedRestore;\n\t\t\t};\n\t\t\ttry {\n\t\t\t\trestored = await restoreWorktree(snapshot, { blobs, storeDir: options.storeDir, signal: options.signal });\n\t\t\t} catch (error) {\n\t\t\t\toptions.signal?.throwIfAborted();\n\t\t\t\tif (!(error instanceof Error)) throw error;\n\t\t\t\tif (!isRecoverableRestoreFailure(error)) throw refused(error);\n\t\t\t\t// The exact state is out of reach: restore the best this host can, else continue without the checkout.\n\t\t\t\tlet degraded: Awaited<ReturnType<typeof restoreDegradedWorktree>> | undefined;\n\t\t\t\tif (isDegradableRestoreFailure(error)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tdegraded = await restoreDegradedWorktree(snapshot, error, {\n\t\t\t\t\t\t\tblobs,\n\t\t\t\t\t\t\tstoreDir: options.storeDir,\n\t\t\t\t\t\t\tsignal: options.signal,\n\t\t\t\t\t\t\tcandidates: earlierSnapshotHeads(sessionManager, original, existing, snapshot),\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (degradedError) {\n\t\t\t\t\t\toptions.signal?.throwIfAborted();\n\t\t\t\t\t\tif (!(degradedError instanceof Error)) throw degradedError;\n\t\t\t\t\t\tif (!isRecoverableRestoreFailure(degradedError)) throw refused(degradedError);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (degraded === undefined) {\n\t\t\t\t\tleft.push({ root, snapshot, reason: error });\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\trestored = degraded;\n\t\t\t}\n\t\t\tconst mapping: WorktreeRootMapping = {\n\t\t\t\tfrom: root,\n\t\t\t\tto: restored.path,\n\t\t\t\tsnapshotId: snapshot.id,\n\t\t\t\ttree: snapshot.tree,\n\t\t\t\trestoredAt: new Date().toISOString(),\n\t\t\t\t...(restored.degraded === undefined ? {} : { degraded: restored.degraded }),\n\t\t\t};\n\t\t\tmappings.push(mapping);\n\t\t\twarnings.push(...restored.warnings);\n\t\t\thostWarnings.set(\n\t\t\t\tmapping,\n\t\t\t\trestored.warnings.filter((warning): warning is WorktreeRestoreHostWarning => {\n\t\t\t\t\tif (warning.code === \"lfs-objects-unavailable\") return true;\n\t\t\t\t\tif (warning.code !== \"stale-restore-retained\" || reportedLeftovers.has(warning.path)) return false;\n\t\t\t\t\treportedLeftovers.add(warning.path);\n\t\t\t\t\treturn true;\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\tawait options.beforeRecord?.(mappings);\n\t\tfor (const mapping of [...pending, ...mappings]) {\n\t\t\toptions.signal?.throwIfAborted();\n\t\t\tawait sessionManager.appendWorktreeSnapshot(\n\t\t\t\tmapping.to,\n\t\t\t\tmapping.snapshotId,\n\t\t\t\tundefined,\n\t\t\t\tmapping,\n\t\t\t\thostWarnings.get(mapping),\n\t\t\t);\n\t\t}\n\t\tconst continuing = mapRestoredPath(cwd, mappings);\n\t\tconst recordedHere = selected !== undefined && left.some((checkout) => checkout.root === selected!.root);\n\t\tconst launch = recordedHere && !existsSync(continuing) && options.fallbackCwd !== undefined;\n\t\tcontinuedIn = launch ? resolve(options.fallbackCwd!) : continuing;\n\t\tfor (const checkout of left) {\n\t\t\tconst at = new Date().toISOString();\n\t\t\tconst record: WorktreeUnrestored = {\n\t\t\t\tsnapshotId: checkout.snapshot.id,\n\t\t\t\tcontinuedIn,\n\t\t\t\tplace: launch ? \"launch\" : \"recorded\",\n\t\t\t\tcause:\n\t\t\t\t\tisWorkspaceError(checkout.reason) || isGitUnavailableError(checkout.reason)\n\t\t\t\t\t\t? checkout.reason.code\n\t\t\t\t\t\t: \"error\",\n\t\t\t\t...(isWorkspaceRestoreError(checkout.reason) && checkout.reason.reason !== undefined\n\t\t\t\t\t? { causeReason: String(checkout.reason.reason) }\n\t\t\t\t\t: {}),\n\t\t\t\t...unrestoredReason(checkout.snapshot, checkout.reason),\n\t\t\t\tat,\n\t\t\t};\n\t\t\tawait sessionManager.appendWorktreeSnapshot(\n\t\t\t\tcheckout.root,\n\t\t\t\tcheckout.snapshot.id,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\t[],\n\t\t\t\trecord,\n\t\t\t);\n\t\t\tunrestored.push({ ...checkout, record });\n\t\t}\n\t} catch (error) {\n\t\tconst cleanupFailures: unknown[] = [];\n\t\tfor (const mapping of [...mappings].reverse()) {\n\t\t\ttry {\n\t\t\t\tawait removeRestoredWorktree(mapping.to, { storeDir: options.storeDir });\n\t\t\t} catch (cleanupCause) {\n\t\t\t\tcleanupFailures.push(cleanupCause);\n\t\t\t}\n\t\t}\n\t\tif (cleanupFailures.length > 0 && error instanceof Error && Object.isExtensible(error)) {\n\t\t\tObject.defineProperty(error, \"cleanupCause\", {\n\t\t\t\tvalue: cleanupFailures.length === 1 ? cleanupFailures[0] : new AggregateError(cleanupFailures),\n\t\t\t\tconfigurable: true,\n\t\t\t});\n\t\t}\n\t\tthrow error;\n\t}\n\tconst snapshot = selected?.snapshot ?? [...latest.values()].at(-1)!;\n\tconst missing = missingRecords.length === 0 ? {} : { missingRecords };\n\treturn mappings.length === 0\n\t\t? { status: \"verified\", snapshot, cwd: continuedIn, unrestored, ...missing }\n\t\t: { status: \"restored\", snapshot, mappings, cwd: continuedIn, warnings, unrestored, ...missing };\n}\n\n/** The one-line notice shown when a session or run continues in a restored worktree. */\nexport function formatWorktreeRestoreNotice(mapping: WorktreeRootMapping): string {\n\treturn `Restored worktree snapshot ${mapping.snapshotId.slice(0, 12)} of ${mapping.from} into ${mapping.to}`;\n}\n\n/** One line per restore warning, for the notices shown after a restore. */\nexport function formatWorktreeRestoreWarning(warning: WorktreeRestoreWarning): string {\n\tswitch (warning.code) {\n\t\tcase \"omitted-content\":\n\t\t\treturn `The restored snapshot left out ${warning.omitted.length} item(s): ${warning.omitted\n\t\t\t\t.map((omission) => (\"path\" in omission ? `${omission.path} (${omission.reason})` : omission.reason))\n\t\t\t\t.join(\", \")}`;\n\t\tcase \"filters\":\n\t\t\treturn `The source checkout used conversion settings (${[\n\t\t\t\twarning.filters.autocrlf === null ? undefined : `core.autocrlf=${warning.filters.autocrlf}`,\n\t\t\t\twarning.filters.eol === null ? undefined : `core.eol=${warning.filters.eol}`,\n\t\t\t\t...warning.filters.drivers.map((driver) => `filter=${driver}`),\n\t\t\t]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(\", \")}); the restore holds Git's stored content with LF line endings`;\n\t\tcase \"lfs-objects-unavailable\":\n\t\t\treturn `Git LFS objects could not be fetched; these files hold LFS pointers: ${warning.paths.join(\", \")}`;\n\t\tcase \"stale-restore-retained\":\n\t\t\tswitch (warning.kind) {\n\t\t\t\tcase \"worktree\":\n\t\t\t\t\treturn `A restore interrupted earlier left ${warning.path}; remove it with removeRestoredWorktree or delete the directory`;\n\t\t\t\tcase \"record\":\n\t\t\t\t\treturn `A restore interrupted earlier left the crash record ${warning.path}, which cannot be read; delete the file`;\n\t\t\t\tcase \"records-directory\":\n\t\t\t\t\treturn `The restore crash records in ${warning.path} cannot be read; make the directory readable or remove it`;\n\t\t\t}\n\t}\n}\n\n/** The first 12 characters of a commit or snapshot id, as notices show them. */\nfunction short(id: string): string {\n\treturn id.slice(0, 12);\n}\n\n/** What a degraded restore checked out, for its notice. */\nfunction degradedBasis(degraded: WorktreeDegradedRestore, snapshot: WorktreeSnapshot | undefined): string {\n\tswitch (degraded.basis) {\n\t\tcase \"pushed-base\":\n\t\t\treturn `the last pushed commit before it, ${short(degraded.head)}`;\n\t\tcase \"earlier-snapshot\":\n\t\t\treturn `${short(degraded.head)}, the commit of an earlier snapshot of this session`;\n\t\tdefault:\n\t\t\treturn `${short(degraded.head)}, the tip of ${snapshot?.branch ? `branch ${snapshot.branch}` : \"the default branch\"} on its remote`;\n\t}\n}\n\nfunction listed(items: readonly string[], limit = 5): string {\n\treturn items.length <= limit\n\t\t? items.join(\", \")\n\t\t: `${items.slice(0, limit).join(\", \")} and ${items.length - limit} more`;\n}\n\n/**\n * The one notice for a worktree restored with less than its snapshot (#4733): what it holds, what is missing and what\n * to do to get the rest.\n */\nexport function formatDegradedRestoreNotice(\n\tmapping: WorktreeRootMapping,\n\tsnapshot: WorktreeSnapshot | undefined,\n\twarnings: readonly WorktreeRestoreHostWarning[] = [],\n): string {\n\tconst lfs = warnings\n\t\t.filter((warning) => warning.code === \"lfs-objects-unavailable\")\n\t\t.map((warning) => ` ${formatWorktreeRestoreWarning(warning)}.`)\n\t\t.join(\"\");\n\treturn `${degradedRestoreSummary(mapping, snapshot)}${lfs}`;\n}\n\nfunction degradedRestoreSummary(mapping: WorktreeRootMapping, snapshot: WorktreeSnapshot | undefined): string {\n\tconst degraded = mapping.degraded!;\n\tconst links = snapshot?.chain.length ?? 0;\n\tconst restored = `Restored ${mapping.from} into ${mapping.to}`;\n\tconst missingPaths = degraded.missingPaths.length > 0 ? `: ${listed(degraded.missingPaths)}` : \"\";\n\tif (degraded.stage === \"partial-changes\") {\n\t\tconst missing =\n\t\t\tdegraded.missingLinks.length > 0\n\t\t\t\t? `change set${degraded.missingLinks.length === 1 ? \"\" : \"s\"} ${degraded.missingLinks.join(\", \")}${missingPaths}`\n\t\t\t\t: `the recorded content of ${listed(degraded.missingPaths)}, which differs on this machine`;\n\t\treturn `${restored} at its recorded commit ${short(degraded.head)} with ${links - degraded.missingLinks.length} of the ${links} change sets of snapshot ${short(mapping.snapshotId)}. Not restored: ${missing}. ${degraded.hint}`;\n\t}\n\tconst commits = degraded.missingCommits.length;\n\tconst recorded = snapshot === undefined ? \"\" : ` instead of the recorded commit ${short(snapshot.head)}`;\n\tconst changes = degraded.missingLinks.length > 0 ? \" and the snapshot's uncommitted changes\" : \"\";\n\treturn `${restored} at ${degradedBasis(degraded, snapshot)}${recorded}, the closest commit available here. Not restored: ${commits} commit${commits === 1 ? \"\" : \"s\"} (${listed(degraded.missingCommits.map(short), 3)})${changes} of snapshot ${short(mapping.snapshotId)}. ${degraded.hint}`;\n}\n\n/** The notice for a checkout whose snapshot the session holds no record of, which a resume continued without. */\nexport function formatMissingRecordNotice(missing: MissingSnapshotRecord): string {\n\treturn `Continuing without restoring ${missing.root}: the session holds no record of its snapshot ${short(missing.snapshotId)}. Resume on the machine that recorded it, or import (\\`atomic --import <file>\\`) a session saved there with \\`/export <file>.jsonl\\`, which carries its snapshots.`;\n}\n\n/** The one notice for a checkout a resume continued without (#4733). */\nexport function formatUnrestoredNotice(root: string, unrestored: WorktreeUnrestored): string {\n\tconst place =\n\t\tunrestored.place === \"launch\" ? \"the directory the resume started from\" : \"the session's own directory\";\n\treturn `Continuing in ${unrestored.continuedIn} (${place}) without restoring ${root} from snapshot ${short(unrestored.snapshotId)}: ${unrestored.detail}. ${unrestored.hint}`.trimEnd();\n}\n\n/**\n * One informational line per worktree restored since `since`, each followed by its snapshot's warnings and what the\n * restore itself reported; one notice per worktree restored with less than its snapshot, and per checkout a resume\n * continued without, since `since` (#4733).\n */\nexport function worktreeRestoreNotices(\n\tsessionManager: Pick<SessionManager, \"getBranch\" | \"getWorktreeSnapshotRecords\">,\n\tsince: string,\n): { readonly type: \"info\" | \"warning\"; readonly message: string }[] {\n\treturn restoreNotices(sessionManager, (entry) =>\n\t\tentry.restore\n\t\t\t? entry.restore.restoredAt >= since\n\t\t\t: entry.unrestored !== undefined && entry.unrestored.at >= since,\n\t);\n}\n\nfunction restoreNotices(\n\tsessionManager: Pick<SessionManager, \"getBranch\" | \"getWorktreeSnapshotRecords\">,\n\tinclude: (entry: Extract<SessionEntry, { type: \"worktree_snapshot\" }>) => boolean,\n): { readonly type: \"info\" | \"warning\"; readonly message: string }[] {\n\tconst records = sessionManager.getWorktreeSnapshotRecords();\n\treturn sessionManager.getBranch().flatMap((entry) => {\n\t\tif (entry.type !== \"worktree_snapshot\" || !include(entry)) return [];\n\t\tif (entry.unrestored) {\n\t\t\treturn [{ type: \"warning\" as const, message: formatUnrestoredNotice(entry.root, entry.unrestored) }];\n\t\t}\n\t\tif (!entry.restore) return [];\n\t\tconst snapshot = records.get(entry.snapshotId);\n\t\tif (entry.restore.degraded) {\n\t\t\tconst message = formatDegradedRestoreNotice(entry.restore, snapshot, entry.restoreWarnings);\n\t\t\treturn [{ type: \"warning\" as const, message }];\n\t\t}\n\t\treturn [\n\t\t\t{ type: \"info\" as const, message: formatWorktreeRestoreNotice(entry.restore) },\n\t\t\t...[...(snapshot ? snapshotRestoreWarnings(snapshot) : []), ...(entry.restoreWarnings ?? [])].map(\n\t\t\t\t(warning) => ({ type: \"warning\" as const, message: formatWorktreeRestoreWarning(warning) }),\n\t\t\t),\n\t\t];\n\t});\n}\n\n/**\n * `entries` with each snapshot's record and blobs from `store` carried inline, each once, so the exported file\n * restores without the source storage. Without a store only the records are carried. A blob the store no longer has\n * is left out; restoring that snapshot then fails with `blob-missing`.\n */\nexport async function inlineSnapshotBlobs(\n\tentries: readonly SessionEntry[],\n\trecords: ReadonlyMap<string, WorktreeSnapshot>,\n\tstore: SnapshotBlobStore | undefined,\n): Promise<SessionEntry[]> {\n\tconst emittedRecords = new Set<string>();\n\tconst emittedBlobs = new Set<string>();\n\tconst result: SessionEntry[] = [];\n\tfor (const entry of entries) {\n\t\tif (entry.type !== \"worktree_snapshot\") {\n\t\t\tresult.push(entry);\n\t\t\tcontinue;\n\t\t}\n\t\tconst record = entry.snapshot ?? records.get(entry.snapshotId);\n\t\tconst { blobs: _carried, snapshot: _record, ...rest } = entry;\n\t\tconst blobs: Record<string, string> = {};\n\t\tif (record && store) {\n\t\t\tfor (const hash of snapshotBlobHashes(record)) {\n\t\t\t\tif (emittedBlobs.has(hash)) continue;\n\t\t\t\tconst data = await store.getBlob(hash);\n\t\t\t\tif (data === undefined) continue;\n\t\t\t\tblobs[hash] = Buffer.from(data).toString(\"base64\");\n\t\t\t\temittedBlobs.add(hash);\n\t\t\t}\n\t\t}\n\t\tconst carryRecord = record !== undefined && !emittedRecords.has(record.id);\n\t\tif (record) emittedRecords.add(record.id);\n\t\tresult.push({\n\t\t\t...rest,\n\t\t\t...(carryRecord ? { snapshot: record } : {}),\n\t\t\t...(Object.keys(blobs).length > 0 ? { blobs } : {}),\n\t\t});\n\t}\n\treturn result;\n}\n\n/**\n * Moves inline blobs into `store` after checking each against its hash, and returns the entries without them.\n * Without a store the entries keep their blobs, which restore reads directly. Throws `blob-corrupt` before writing\n * anything when a blob does not match its hash.\n */\nexport async function adoptInlineSnapshotBlobs(\n\tentries: readonly SessionEntry[],\n\tstore: SnapshotBlobStore | undefined,\n): Promise<SessionEntry[]> {\n\tconst blobs: SnapshotBlob[] = [];\n\tfor (const entry of entries) {\n\t\tif (entry.type !== \"worktree_snapshot\" || !entry.blobs) continue;\n\t\tfor (const [hash, base64] of Object.entries(entry.blobs)) {\n\t\t\tconst data = new Uint8Array(Buffer.from(base64, \"base64\"));\n\t\t\tif (sha256Hex(data) !== hash) {\n\t\t\t\tthrow new WorkspaceRestoreError(\"blob-corrupt\", { snapshotId: entry.snapshotId, blob: hash });\n\t\t\t}\n\t\t\tblobs.push({ hash, data });\n\t\t}\n\t}\n\tif (!store || blobs.length === 0) return [...entries];\n\tawait store.putBlobs(blobs);\n\treturn entries.map((entry) => {\n\t\tif (entry.type !== \"worktree_snapshot\" || !entry.blobs) return entry;\n\t\tconst { blobs: _moved, ...rest } = entry;\n\t\treturn rest;\n\t});\n}\n\n/** A read-only view of the blobs carried inline by `entries`. */\nexport function inlineBlobStore(entries: readonly SessionEntry[]): SnapshotBlobStore {\n\tconst blobs = new Map<string, string>();\n\tfor (const entry of entries) {\n\t\tif (entry.type === \"worktree_snapshot\" && entry.blobs) {\n\t\t\tfor (const [hash, base64] of Object.entries(entry.blobs)) blobs.set(hash, base64);\n\t\t}\n\t}\n\treturn {\n\t\tasync putBlobs() {\n\t\t\tthrow new WorkspaceSnapshotError(\"blob-store-unsupported\", \"inline\");\n\t\t},\n\t\tasync getBlob(hash) {\n\t\t\tconst base64 = blobs.get(hash);\n\t\t\treturn base64 === undefined ? undefined : new Uint8Array(Buffer.from(base64, \"base64\"));\n\t\t},\n\t\tasync refreshBlobs(hashes) {\n\t\t\treturn hashes.every((hash) => blobs.has(hash));\n\t\t},\n\t\tasync listBlobHashes() {\n\t\t\treturn [...blobs.keys()];\n\t\t},\n\t};\n}\n\n/** Reads `primary` first, then the blobs carried inline by `entries`. */\nexport function sessionSnapshotBlobs(\n\tprimary: SnapshotBlobStore | undefined,\n\tentries: readonly SessionEntry[],\n): SnapshotBlobStore {\n\tconst inline = inlineBlobStore(entries);\n\tif (!primary) return inline;\n\treturn {\n\t\tputBlobs: (blobs) => primary.putBlobs(blobs),\n\t\tgetBlob: async (hash) => (await primary.getBlob(hash)) ?? (await inline.getBlob(hash)),\n\t\trefreshBlobs: (hashes) => primary.refreshBlobs(hashes),\n\t\tlistBlobHashes: () => primary.listBlobHashes(),\n\t};\n}\n\n/** What an export of `entries` carries: checkouts, snapshots and the bytes of patch and bundle content. */\nexport function describeSnapshotExport(\n\tentries: readonly SessionEntry[],\n\trecords: ReadonlyMap<string, WorktreeSnapshot>,\n): string | undefined {\n\tconst roots = new Set<string>();\n\tconst snapshots = new Set<string>();\n\tconst blobBytes = new Map<string, number>();\n\tlet omitted = 0;\n\tfor (const entry of entries) {\n\t\tif (entry.type !== \"worktree_snapshot\" || snapshots.has(entry.snapshotId)) continue;\n\t\tsnapshots.add(entry.snapshotId);\n\t\tconst record = entry.snapshot ?? records.get(entry.snapshotId);\n\t\tif (!record) continue;\n\t\troots.add(record.root);\n\t\tomitted += record.omitted.length;\n\t\tfor (const link of record.chain) if (link.patch) blobBytes.set(link.patch, link.bytes);\n\t\tif (record.bundle) blobBytes.set(record.bundle.blob, record.bundle.bytes);\n\t}\n\tif (snapshots.size === 0) return undefined;\n\tconst bytes = [...blobBytes.values()].reduce((sum, size) => sum + size, 0);\n\treturn `Includes ${snapshots.size} worktree snapshot(s) of ${[...roots].join(\", \")}: ${bytes} bytes of patch and bundle content${omitted > 0 ? `, ${omitted} omitted item(s) not included` : \"\"}`;\n}\n\nexport type WorktreeSnapshotComparison =\n\t| { readonly status: \"match\"; readonly tree: string; readonly head?: string }\n\t| { readonly status: \"missing\"; readonly reason: WorktreeSnapshotUnavailableReason }\n\t| {\n\t\t\treadonly status: \"differs\";\n\t\t\treadonly head: string;\n\t\t\treadonly tree: string;\n\t\t\t/** `git diff --stat` from the snapshot's tree to the current one, when the snapshot's tree is present locally. */\n\t\t\treadonly stat: string | undefined;\n\t };\n\n/** Compares the checkout at `dir` with `snapshot`, for `/session snapshot`. */\nexport async function compareWorktreeSnapshot(\n\tsnapshot: WorktreeSnapshot,\n\tdir: string,\n\tsettings: WorktreeSnapshotSettings,\n): Promise<WorktreeSnapshotComparison> {\n\tconst checkout = await locateCheckout(dir);\n\tif (checkout instanceof Error) return { status: \"missing\", reason: checkout };\n\tconst present = await runGit([\"cat-file\", \"-e\", `${snapshot.tree}^{tree}`], {\n\t\tcwd: checkout.root,\n\t\tallowExitCodes: [1, 128],\n\t});\n\tconst policy = await loadSnapshotPathPolicy(checkout.root);\n\tconst state = await withScratchDirectory((scratch) =>\n\t\twriteWorkingTree(checkout, settings, policy, scratch, present.exitCode === 0 ? { seedTree: snapshot.tree } : {}),\n\t);\n\tif (state.tree === snapshot.tree) {\n\t\tif (checkout.head === snapshot.head) return { status: \"match\", tree: state.tree };\n\t\tconst drift = new WorkspaceDriftError({\n\t\t\troot: checkout.root,\n\t\t\texpectedHead: snapshot.head,\n\t\t\tactualHead: checkout.head,\n\t\t\texpectedTree: snapshot.tree,\n\t\t\tactualTree: state.tree,\n\t\t\tsnapshotId: snapshot.id,\n\t\t});\n\t\tif (await isHeadOnlyAdvance(drift)) return { status: \"match\", tree: state.tree, head: checkout.head };\n\t}\n\tconst stat =\n\t\tpresent.exitCode === 0\n\t\t\t? await gitText([\"diff-tree\", \"--stat\", \"--no-renames\", \"--no-ext-diff\", \"-r\", snapshot.tree, state.tree], {\n\t\t\t\t\tcwd: checkout.root,\n\t\t\t\t})\n\t\t\t: undefined;\n\treturn { status: \"differs\", head: checkout.head, tree: state.tree, stat };\n}\n\n/**\n * What the last resume did about the checkout now at `root`, for `/session snapshot`, when it restored less than the\n * snapshot or nothing of it (#4733): the notice that resume showed. Undefined after a complete restore, or none.\n */\nexport function describeWorktreeRestoreStatus(\n\tsessionManager: Pick<SessionManager, \"getBranch\" | \"getWorktreeSnapshotRecords\">,\n\troot: string,\n): string | undefined {\n\tconst records = sessionManager.getWorktreeSnapshotRecords();\n\tlet status: { readonly snapshotId: string; readonly message: string } | undefined;\n\tfor (const entry of sessionManager.getBranch()) {\n\t\tif (entry.type !== \"worktree_snapshot\") continue;\n\t\tif (entry.restore && resolve(entry.restore.to) === resolve(root)) {\n\t\t\tstatus = entry.restore.degraded\n\t\t\t\t? {\n\t\t\t\t\t\tsnapshotId: entry.snapshotId,\n\t\t\t\t\t\tmessage: formatDegradedRestoreNotice(\n\t\t\t\t\t\t\tentry.restore,\n\t\t\t\t\t\t\trecords.get(entry.snapshotId),\n\t\t\t\t\t\t\tentry.restoreWarnings,\n\t\t\t\t\t\t),\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\t\t} else if (entry.unrestored && resolve(entry.root) === resolve(root)) {\n\t\t\tstatus = { snapshotId: entry.snapshotId, message: formatUnrestoredNotice(entry.root, entry.unrestored) };\n\t\t} else if (status && resolve(entry.root) === resolve(root) && entry.snapshotId !== status.snapshotId) {\n\t\t\t// A later snapshot of the checkout records what it holds now, which replaces what the resume left out.\n\t\t\tstatus = undefined;\n\t\t}\n\t}\n\treturn status?.message;\n}\n\n/** Lines describing `snapshot` for `/session snapshot`. */\nexport function describeWorktreeSnapshot(root: string, snapshot: WorktreeSnapshot): string[] {\n\tconst omitted = snapshot.omitted.map((omission) =>\n\t\t\"path\" in omission\n\t\t\t? `${omission.path} (${omission.reason})`\n\t\t\t: `${omission.commits.length} commit(s) (${omission.reason})`,\n\t);\n\treturn [\n\t\t`${root}`,\n\t\t` snapshot ${snapshot.id} captured ${snapshot.capturedAt}`,\n\t\t` ${snapshot.branch ?? \"detached\"} at ${snapshot.head.slice(0, 12)}, tree ${snapshot.tree.slice(0, 12)}`,\n\t\t` delta chain ${snapshot.chain.length} link(s), ${snapshot.chain.reduce((sum, link) => sum + link.bytes, 0)} bytes; ${\n\t\t\tsnapshot.bundle\n\t\t\t\t? `${snapshot.bundle.commits.length} unpushed commit(s) bundled`\n\t\t\t\t: \"no unpushed commits bundled\"\n\t\t}`,\n\t\t...(omitted.length > 0 ? [` omitted: ${omitted.join(\", \")}`] : []),\n\t\t...(snapshot.filters\n\t\t\t? snapshotRestoreWarnings({ ...snapshot, omitted: [] }).map(formatWorktreeRestoreWarning)\n\t\t\t: []),\n\t];\n}\n\n/**\n * Opens `sessionManager`'s session where it should continue: in place when its checkout matches the last snapshot,\n * in the restored worktree otherwise. Returns the notices to show for a restore it performed.\n */\nexport async function openSessionInWorktree(\n\tsessionManager: SessionManager,\n\toptions: ResumeSessionWorktreeOptions & { readonly sessionDirectory?: string },\n): Promise<{\n\treadonly sessionManager: SessionManager;\n\treadonly notices: { readonly type: \"info\" | \"warning\"; readonly message: string }[];\n}> {\n\tconst resume = await resumeSessionWorktree(sessionManager, options);\n\treturn openResumedSession(\n\t\tsessionManager,\n\t\tresume.status === \"none\" ? sessionManager.getCwd() : resume.cwd,\n\t\tresume.status === \"restored\" ? resume.mappings : [],\n\t\toptions.sessionDirectory,\n\t\tresume.status === \"none\" ? [] : resume.unrestored.map((checkout) => checkout.record),\n\t);\n}\n\n/**\n * Opens `sessionManager`'s session in `cwd`, where resuming it left its working directory, and returns the notices to\n * show for the worktrees that resuming `restored` it into.\n */\nexport async function openResumedSession(\n\tsessionManager: SessionManager,\n\tcwd: string,\n\trestored: readonly WorktreeRootMapping[],\n\tsessionDirectory?: string,\n\tunrestored: readonly WorktreeUnrestored[] = [],\n): Promise<{\n\treadonly sessionManager: SessionManager;\n\treadonly notices: { readonly type: \"info\" | \"warning\"; readonly message: string }[];\n}> {\n\tconst opened =\n\t\tcwd !== sessionManager.getCwd()\n\t\t\t? await sessionManager.openSessionById(sessionManager.getSessionId(), cwd, sessionDirectory)\n\t\t\t: sessionManager;\n\tconst restoredHere = new Set(restored.map((mapping) => mapping.to));\n\tconst leftHere = new Set(unrestored.map((record) => `${record.snapshotId}\\0${record.at}`));\n\treturn {\n\t\tsessionManager: opened,\n\t\tnotices: restoreNotices(opened, (entry) =>\n\t\t\tentry.restore\n\t\t\t\t? restoredHere.has(entry.restore.to)\n\t\t\t\t: entry.unrestored !== undefined && leftHere.has(`${entry.unrestored.snapshotId}\\0${entry.unrestored.at}`),\n\t\t),\n\t};\n}\n\n/**\n * Whether a session recorded elsewhere continues in `cwd` because a restore moved its checkout there, so opening it\n * from `cwd` resumes it rather than forking it into another project.\n */\nexport async function sessionContinuesIn(store: SessionStore, sessionId: string, cwd: string): Promise<boolean> {\n\tconst { header, entries } = await store.load(sessionId);\n\tconst mappings = entries.flatMap((entry) =>\n\t\tentry.type === \"worktree_snapshot\" && entry.restore ? [entry.restore] : [],\n\t);\n\tif (mappings.length === 0) return false;\n\tconst mapped = mapRestoredPath(header.cwd, mappings);\n\treturn canonicalizeWorktreePath(mapped) === canonicalizeWorktreePath(cwd);\n}\n\n/** The restores recorded on `branch`, oldest first. */\nfunction restoreMappings(branch: readonly SessionEntry[]): WorktreeRootMapping[] {\n\treturn branch.flatMap((entry) => (entry.type === \"worktree_snapshot\" && entry.restore ? [entry.restore] : []));\n}\n\n/** The restores and current snapshots of the branch of stored `entries` that ends at `leafId`, as resume finds them. */\nfunction storedBranchSnapshots(\n\tentries: readonly SessionEntry[],\n\tleafId: string | null,\n): { readonly mappings: WorktreeRootMapping[]; readonly current: Map<string, WorktreeSnapshot> } {\n\tconst branch = getBranchPath(leafId, new Map(entries.map((entry) => [entry.id, entry])));\n\tconst records = new Map<string, WorktreeSnapshot>();\n\tfor (const entry of entries) {\n\t\tif (entry.type === \"worktree_snapshot\" && entry.snapshot) records.set(entry.snapshotId, entry.snapshot);\n\t}\n\tconst mappings = restoreMappings(branch);\n\tconst current = currentWorktreeSnapshots({\n\t\tgetBranch: () => branch,\n\t\tgetWorktreeRootMappings: () => mappings,\n\t\tgetWorktreeSnapshotRecords: () => records,\n\t});\n\treturn { mappings, current };\n}\n\n/**\n * Whether a session runs in a checkout it recorded snapshots of: its working directory, followed through the restores\n * it recorded, lies inside a checkout the branch it reopens on recorded a snapshot of. Opening such a session from\n * another directory resumes it against that checkout, verified in place or restored into a fresh worktree, instead of\n * forking it into the other directory.\n */\nexport async function sessionRunsInRecordedCheckout(store: SessionStore, sessionId: string): Promise<boolean> {\n\tconst { header, entries } = await store.load(sessionId);\n\tconst { mappings, current } = storedBranchSnapshots(entries, getSessionLeafId(entries));\n\tconst cwd = mapRestoredPath(header.cwd, mappings);\n\treturn [...current.keys()].some((root) => isInside(root, cwd));\n}\n"]}
@@ -70,7 +70,19 @@ function validPayload(entry) {
70
70
  typeof entry.restore === "object" &&
71
71
  typeof entry.restore.from === "string" &&
72
72
  entry.restore.to === entry.root &&
73
- entry.restore.snapshotId === entry.snapshotId)) &&
73
+ entry.restore.snapshotId === entry.snapshotId &&
74
+ (entry.restore.degraded === undefined || validDegradedRestore(entry.restore.degraded)))) &&
75
+ (entry.unrestored === undefined ||
76
+ (entry.restore === undefined &&
77
+ entry.unrestored !== null &&
78
+ typeof entry.unrestored === "object" &&
79
+ entry.unrestored.snapshotId === entry.snapshotId &&
80
+ typeof entry.unrestored.continuedIn === "string" &&
81
+ (entry.unrestored.place === "recorded" || entry.unrestored.place === "launch") &&
82
+ typeof entry.unrestored.cause === "string" &&
83
+ typeof entry.unrestored.detail === "string" &&
84
+ typeof entry.unrestored.hint === "string" &&
85
+ typeof entry.unrestored.at === "string")) &&
74
86
  (entry.restoreWarnings === undefined ||
75
87
  (entry.restore !== undefined &&
76
88
  Array.isArray(entry.restoreWarnings) &&
@@ -112,4 +124,22 @@ function validMessage(message) {
112
124
  return false;
113
125
  }
114
126
  }
127
+ function isStringList(value) {
128
+ return Array.isArray(value) && value.every((item) => typeof item === "string");
129
+ }
130
+ /** A restore's record of what it restored in place of its snapshot (#4733), as Atomic writes it. */
131
+ function validDegradedRestore(value) {
132
+ if (value === null || typeof value !== "object")
133
+ return false;
134
+ const degraded = value;
135
+ return ((degraded.stage === "partial-changes" || degraded.stage === "closest-commit") &&
136
+ typeof degraded.head === "string" &&
137
+ typeof degraded.tree === "string" &&
138
+ Array.isArray(degraded.missingLinks) &&
139
+ degraded.missingLinks.every((index) => Number.isInteger(index)) &&
140
+ isStringList(degraded.missingPaths) &&
141
+ isStringList(degraded.missingCommits) &&
142
+ typeof degraded.cause === "string" &&
143
+ typeof degraded.hint === "string");
144
+ }
115
145
  //# sourceMappingURL=entry-structure.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"entry-structure.js","sourceRoot":"","sources":["../../../../src/core/storage/session/entry-structure.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,iGAAiG;AACjG,MAAM,UAAU,6BAA6B,CAAC,OAAgC,EAAE,IAAY;IAC3F,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC7B,IACC,CAAC,KAAK;YACN,OAAO,KAAK,KAAK,QAAQ;YACzB,OAAO,KAAK,CAAC,EAAE,KAAK,QAAQ;YAC5B,CAAC,KAAK,CAAC,QAAQ,KAAK,IAAI,IAAI,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC;YAC/D,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ;YACnC,CAAC,YAAY,CAAC,KAAK,CAAC;YAEpB,MAAM,IAAI,yBAAy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AAS,KAAK,SAAS;gBACtC,OAAO,OAAO,CAAC,SAAS,KAAK,SAAS,CACtC,CAAC;QACH,KAAK,eAAe;YACnB,OAAO,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,IAAI,IAAI,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC;QAC/G;YACC,OAAO,KAAK,CAAC;IACf,CAAC;AACF,CAAC","sourcesContent":["import type { SessionEntry, SessionMessageEntry, WorktreeRestoreHostWarning } from \"../../session-manager-types.ts\";\nimport { SessionFormatVersionError } from \"./errors.js\";\nimport { SESSION_FORMAT_VERSION } from \"./types.js\";\n\n/** Validate the tree envelope and required payload fields before consuming persisted entries. */\nexport function validateSessionEntryStructure(entries: readonly SessionEntry[], path: string): void {\n\tfor (const entry of entries) {\n\t\tif (\n\t\t\t!entry ||\n\t\t\ttypeof entry !== \"object\" ||\n\t\t\ttypeof entry.id !== \"string\" ||\n\t\t\t(entry.parentId !== null && typeof entry.parentId !== \"string\") ||\n\t\t\ttypeof entry.timestamp !== \"string\" ||\n\t\t\t!validPayload(entry)\n\t\t)\n\t\t\tthrow new SessionFormatVersionError(path, SESSION_FORMAT_VERSION);\n\t}\n}\n\nfunction validPayload(entry: SessionEntry): boolean {\n\tswitch (entry.type) {\n\t\tcase \"message\":\n\t\t\treturn validMessage(entry.message);\n\t\tcase \"thinking_level_change\":\n\t\t\treturn typeof entry.thinkingLevel === \"string\";\n\t\tcase \"model_change\":\n\t\t\treturn typeof entry.provider === \"string\" && typeof entry.modelId === \"string\";\n\t\tcase \"usage\":\n\t\t\treturn (\n\t\t\t\ttypeof entry.kind === \"string\" &&\n\t\t\t\ttypeof entry.provider === \"string\" &&\n\t\t\t\ttypeof entry.model === \"string\" &&\n\t\t\t\tentry.usage !== null &&\n\t\t\t\ttypeof entry.usage === \"object\"\n\t\t\t);\n\t\tcase \"compaction\":\n\t\t\treturn (\n\t\t\t\ttypeof entry.summary === \"string\" &&\n\t\t\t\t(entry.firstKeptEntryId === null || typeof entry.firstKeptEntryId === \"string\") &&\n\t\t\t\t(entry.coveredThroughEntryId === undefined || typeof entry.coveredThroughEntryId === \"string\") &&\n\t\t\t\ttypeof entry.tokensBefore === \"number\"\n\t\t\t);\n\t\tcase \"context_compaction\":\n\t\t\treturn (\n\t\t\t\tentry.promptVersion === 1 &&\n\t\t\t\tArray.isArray(entry.deletedTargets) &&\n\t\t\t\tArray.isArray(entry.protectedEntryIds) &&\n\t\t\t\tentry.stats !== null &&\n\t\t\t\ttypeof entry.stats === \"object\"\n\t\t\t);\n\t\tcase \"branch_summary\":\n\t\t\treturn typeof entry.fromId === \"string\" && typeof entry.summary === \"string\";\n\t\tcase \"custom\":\n\t\t\treturn typeof entry.customType === \"string\";\n\t\tcase \"custom_message\":\n\t\t\treturn (\n\t\t\t\ttypeof entry.customType === \"string\" &&\n\t\t\t\t(typeof entry.content === \"string\" || Array.isArray(entry.content)) &&\n\t\t\t\ttypeof entry.display === \"boolean\"\n\t\t\t);\n\t\tcase \"context_edit\":\n\t\t\treturn (\n\t\t\t\ttypeof entry.targetId === \"string\" &&\n\t\t\t\t(entry.replacement === null ||\n\t\t\t\t\t(typeof entry.replacement === \"object\" &&\n\t\t\t\t\t\t(typeof entry.replacement.content === \"string\" || Array.isArray(entry.replacement.content))))\n\t\t\t);\n\t\tcase \"label\":\n\t\t\treturn typeof entry.targetId === \"string\" && (entry.label === undefined || typeof entry.label === \"string\");\n\t\tcase \"session_info\":\n\t\t\treturn entry.name === undefined || typeof entry.name === \"string\";\n\t\tcase \"session_summary\":\n\t\t\treturn typeof entry.summary === \"string\" && typeof entry.summarizedThroughId === \"string\";\n\t\tcase \"worktree_snapshot\":\n\t\t\treturn (\n\t\t\t\ttypeof entry.root === \"string\" &&\n\t\t\t\ttypeof entry.snapshotId === \"string\" &&\n\t\t\t\t(entry.snapshot === undefined ||\n\t\t\t\t\t(entry.snapshot !== null &&\n\t\t\t\t\t\ttypeof entry.snapshot === \"object\" &&\n\t\t\t\t\t\tentry.snapshot.id === entry.snapshotId &&\n\t\t\t\t\t\ttypeof entry.snapshot.tree === \"string\" &&\n\t\t\t\t\t\tArray.isArray(entry.snapshot.chain))) &&\n\t\t\t\t(entry.restore === undefined ||\n\t\t\t\t\t(entry.restore !== null &&\n\t\t\t\t\t\ttypeof entry.restore === \"object\" &&\n\t\t\t\t\t\ttypeof entry.restore.from === \"string\" &&\n\t\t\t\t\t\tentry.restore.to === entry.root &&\n\t\t\t\t\t\tentry.restore.snapshotId === entry.snapshotId)) &&\n\t\t\t\t(entry.restoreWarnings === undefined ||\n\t\t\t\t\t(entry.restore !== undefined &&\n\t\t\t\t\t\tArray.isArray(entry.restoreWarnings) &&\n\t\t\t\t\t\tentry.restoreWarnings.every(validRestoreHostWarning))) &&\n\t\t\t\t(entry.blobs === undefined ||\n\t\t\t\t\t(entry.blobs !== null &&\n\t\t\t\t\t\ttypeof entry.blobs === \"object\" &&\n\t\t\t\t\t\t!Array.isArray(entry.blobs) &&\n\t\t\t\t\t\tObject.values(entry.blobs).every((value) => typeof value === \"string\")))\n\t\t\t);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nconst LEFTOVER_KINDS = new Set<string>([\"worktree\", \"record\", \"records-directory\"]);\n\nfunction validRestoreHostWarning(warning: WorktreeRestoreHostWarning | null): boolean {\n\tif (warning?.code === \"lfs-objects-unavailable\") {\n\t\treturn Array.isArray(warning.paths) && warning.paths.every((path) => typeof path === \"string\");\n\t}\n\treturn (\n\t\twarning?.code === \"stale-restore-retained\" && typeof warning.path === \"string\" && LEFTOVER_KINDS.has(warning.kind)\n\t);\n}\n\nfunction validMessage(message: SessionMessageEntry[\"message\"]): boolean {\n\tif (!message || typeof message !== \"object\" || typeof message.timestamp !== \"number\") return false;\n\tswitch (message.role) {\n\t\tcase \"system\":\n\t\tcase \"user\":\n\t\tcase \"assistant\":\n\t\tcase \"toolResult\":\n\t\tcase \"custom\":\n\t\t\treturn typeof message.content === \"string\" || Array.isArray(message.content);\n\t\tcase \"bashExecution\":\n\t\t\treturn (\n\t\t\t\ttypeof message.command === \"string\" &&\n\t\t\t\ttypeof message.output === \"string\" &&\n\t\t\t\ttypeof message.cancelled === \"boolean\" &&\n\t\t\t\ttypeof message.truncated === \"boolean\"\n\t\t\t);\n\t\tcase \"branchSummary\":\n\t\t\treturn typeof message.summary === \"string\" && (message.fromId === null || typeof message.fromId === \"string\");\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n"]}
1
+ {"version":3,"file":"entry-structure.js","sourceRoot":"","sources":["../../../../src/core/storage/session/entry-structure.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,iGAAiG;AACjG,MAAM,UAAU,6BAA6B,CAAC,OAAgC,EAAE,IAAY;IAC3F,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC7B,IACC,CAAC,KAAK;YACN,OAAO,KAAK,KAAK,QAAQ;YACzB,OAAO,KAAK,CAAC,EAAE,KAAK,QAAQ;YAC5B,CAAC,KAAK,CAAC,QAAQ,KAAK,IAAI,IAAI,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC;YAC/D,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ;YACnC,CAAC,YAAY,CAAC,KAAK,CAAC;YAEpB,MAAM,IAAI,yBAAyB,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;IACpE,CAAC;AACF,CAAC;AAED,SAAS,YAAY,CAAC,KAAmB;IACxC,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,SAAS;YACb,OAAO,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACpC,KAAK,uBAAuB;YAC3B,OAAO,OAAO,KAAK,CAAC,aAAa,KAAK,QAAQ,CAAC;QAChD,KAAK,cAAc;YAClB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IAAI,KAAK,QAAQ;QACjC,OAAO,QAAQ,CAAC,IAAI,KAAK,QAAQ;QACjC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;QACpC,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC/D,YAAY,CAAC,QAAQ,CAAC,YAAY,CAAC;QACnC,YAAY,CAAC,QAAQ,CAAC,cAAc,CAAC;QACrC,OAAO,QAAQ,CAAC,KAAK,KAAK,QAAQ;QAClC,OAAO,QAAQ,CAAC,IAAI,KAAK,QAAQ,CACjC,CAAC;AACH,CAAC","sourcesContent":["import type { SessionEntry, SessionMessageEntry, WorktreeRestoreHostWarning } from \"../../session-manager-types.ts\";\nimport { SessionFormatVersionError } from \"./errors.js\";\nimport { SESSION_FORMAT_VERSION } from \"./types.js\";\n\n/** Validate the tree envelope and required payload fields before consuming persisted entries. */\nexport function validateSessionEntryStructure(entries: readonly SessionEntry[], path: string): void {\n\tfor (const entry of entries) {\n\t\tif (\n\t\t\t!entry ||\n\t\t\ttypeof entry !== \"object\" ||\n\t\t\ttypeof entry.id !== \"string\" ||\n\t\t\t(entry.parentId !== null && typeof entry.parentId !== \"string\") ||\n\t\t\ttypeof entry.timestamp !== \"string\" ||\n\t\t\t!validPayload(entry)\n\t\t)\n\t\t\tthrow new SessionFormatVersionError(path, SESSION_FORMAT_VERSION);\n\t}\n}\n\nfunction validPayload(entry: SessionEntry): boolean {\n\tswitch (entry.type) {\n\t\tcase \"message\":\n\t\t\treturn validMessage(entry.message);\n\t\tcase \"thinking_level_change\":\n\t\t\treturn typeof entry.thinkingLevel === \"string\";\n\t\tcase \"model_change\":\n\t\t\treturn typeof entry.provider === \"string\" && typeof entry.modelId === \"string\";\n\t\tcase \"usage\":\n\t\t\treturn (\n\t\t\t\ttypeof entry.kind === \"string\" &&\n\t\t\t\ttypeof entry.provider === \"string\" &&\n\t\t\t\ttypeof entry.model === \"string\" &&\n\t\t\t\tentry.usage !== null &&\n\t\t\t\ttypeof entry.usage === \"object\"\n\t\t\t);\n\t\tcase \"compaction\":\n\t\t\treturn (\n\t\t\t\ttypeof entry.summary === \"string\" &&\n\t\t\t\t(entry.firstKeptEntryId === null || typeof entry.firstKeptEntryId === \"string\") &&\n\t\t\t\t(entry.coveredThroughEntryId === undefined || typeof entry.coveredThroughEntryId === \"string\") &&\n\t\t\t\ttypeof entry.tokensBefore === \"number\"\n\t\t\t);\n\t\tcase \"context_compaction\":\n\t\t\treturn (\n\t\t\t\tentry.promptVersion === 1 &&\n\t\t\t\tArray.isArray(entry.deletedTargets) &&\n\t\t\t\tArray.isArray(entry.protectedEntryIds) &&\n\t\t\t\tentry.stats !== null &&\n\t\t\t\ttypeof entry.stats === \"object\"\n\t\t\t);\n\t\tcase \"branch_summary\":\n\t\t\treturn typeof entry.fromId === \"string\" && typeof entry.summary === \"string\";\n\t\tcase \"custom\":\n\t\t\treturn typeof entry.customType === \"string\";\n\t\tcase \"custom_message\":\n\t\t\treturn (\n\t\t\t\ttypeof entry.customType === \"string\" &&\n\t\t\t\t(typeof entry.content === \"string\" || Array.isArray(entry.content)) &&\n\t\t\t\ttypeof entry.display === \"boolean\"\n\t\t\t);\n\t\tcase \"context_edit\":\n\t\t\treturn (\n\t\t\t\ttypeof entry.targetId === \"string\" &&\n\t\t\t\t(entry.replacement === null ||\n\t\t\t\t\t(typeof entry.replacement === \"object\" &&\n\t\t\t\t\t\t(typeof entry.replacement.content === \"string\" || Array.isArray(entry.replacement.content))))\n\t\t\t);\n\t\tcase \"label\":\n\t\t\treturn typeof entry.targetId === \"string\" && (entry.label === undefined || typeof entry.label === \"string\");\n\t\tcase \"session_info\":\n\t\t\treturn entry.name === undefined || typeof entry.name === \"string\";\n\t\tcase \"session_summary\":\n\t\t\treturn typeof entry.summary === \"string\" && typeof entry.summarizedThroughId === \"string\";\n\t\tcase \"worktree_snapshot\":\n\t\t\treturn (\n\t\t\t\ttypeof entry.root === \"string\" &&\n\t\t\t\ttypeof entry.snapshotId === \"string\" &&\n\t\t\t\t(entry.snapshot === undefined ||\n\t\t\t\t\t(entry.snapshot !== null &&\n\t\t\t\t\t\ttypeof entry.snapshot === \"object\" &&\n\t\t\t\t\t\tentry.snapshot.id === entry.snapshotId &&\n\t\t\t\t\t\ttypeof entry.snapshot.tree === \"string\" &&\n\t\t\t\t\t\tArray.isArray(entry.snapshot.chain))) &&\n\t\t\t\t(entry.restore === undefined ||\n\t\t\t\t\t(entry.restore !== null &&\n\t\t\t\t\t\ttypeof entry.restore === \"object\" &&\n\t\t\t\t\t\ttypeof entry.restore.from === \"string\" &&\n\t\t\t\t\t\tentry.restore.to === entry.root &&\n\t\t\t\t\t\tentry.restore.snapshotId === entry.snapshotId &&\n\t\t\t\t\t\t(entry.restore.degraded === undefined || validDegradedRestore(entry.restore.degraded)))) &&\n\t\t\t\t(entry.unrestored === undefined ||\n\t\t\t\t\t(entry.restore === undefined &&\n\t\t\t\t\t\tentry.unrestored !== null &&\n\t\t\t\t\t\ttypeof entry.unrestored === \"object\" &&\n\t\t\t\t\t\tentry.unrestored.snapshotId === entry.snapshotId &&\n\t\t\t\t\t\ttypeof entry.unrestored.continuedIn === \"string\" &&\n\t\t\t\t\t\t(entry.unrestored.place === \"recorded\" || entry.unrestored.place === \"launch\") &&\n\t\t\t\t\t\ttypeof entry.unrestored.cause === \"string\" &&\n\t\t\t\t\t\ttypeof entry.unrestored.detail === \"string\" &&\n\t\t\t\t\t\ttypeof entry.unrestored.hint === \"string\" &&\n\t\t\t\t\t\ttypeof entry.unrestored.at === \"string\")) &&\n\t\t\t\t(entry.restoreWarnings === undefined ||\n\t\t\t\t\t(entry.restore !== undefined &&\n\t\t\t\t\t\tArray.isArray(entry.restoreWarnings) &&\n\t\t\t\t\t\tentry.restoreWarnings.every(validRestoreHostWarning))) &&\n\t\t\t\t(entry.blobs === undefined ||\n\t\t\t\t\t(entry.blobs !== null &&\n\t\t\t\t\t\ttypeof entry.blobs === \"object\" &&\n\t\t\t\t\t\t!Array.isArray(entry.blobs) &&\n\t\t\t\t\t\tObject.values(entry.blobs).every((value) => typeof value === \"string\")))\n\t\t\t);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nconst LEFTOVER_KINDS = new Set<string>([\"worktree\", \"record\", \"records-directory\"]);\n\nfunction validRestoreHostWarning(warning: WorktreeRestoreHostWarning | null): boolean {\n\tif (warning?.code === \"lfs-objects-unavailable\") {\n\t\treturn Array.isArray(warning.paths) && warning.paths.every((path) => typeof path === \"string\");\n\t}\n\treturn (\n\t\twarning?.code === \"stale-restore-retained\" && typeof warning.path === \"string\" && LEFTOVER_KINDS.has(warning.kind)\n\t);\n}\n\nfunction validMessage(message: SessionMessageEntry[\"message\"]): boolean {\n\tif (!message || typeof message !== \"object\" || typeof message.timestamp !== \"number\") return false;\n\tswitch (message.role) {\n\t\tcase \"system\":\n\t\tcase \"user\":\n\t\tcase \"assistant\":\n\t\tcase \"toolResult\":\n\t\tcase \"custom\":\n\t\t\treturn typeof message.content === \"string\" || Array.isArray(message.content);\n\t\tcase \"bashExecution\":\n\t\t\treturn (\n\t\t\t\ttypeof message.command === \"string\" &&\n\t\t\t\ttypeof message.output === \"string\" &&\n\t\t\t\ttypeof message.cancelled === \"boolean\" &&\n\t\t\t\ttypeof message.truncated === \"boolean\"\n\t\t\t);\n\t\tcase \"branchSummary\":\n\t\t\treturn typeof message.summary === \"string\" && (message.fromId === null || typeof message.fromId === \"string\");\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nfunction isStringList(value: unknown): boolean {\n\treturn Array.isArray(value) && value.every((item) => typeof item === \"string\");\n}\n\n/** A restore's record of what it restored in place of its snapshot (#4733), as Atomic writes it. */\nfunction validDegradedRestore(value: unknown): boolean {\n\tif (value === null || typeof value !== \"object\") return false;\n\tconst degraded = value as Record<string, unknown>;\n\treturn (\n\t\t(degraded.stage === \"partial-changes\" || degraded.stage === \"closest-commit\") &&\n\t\ttypeof degraded.head === \"string\" &&\n\t\ttypeof degraded.tree === \"string\" &&\n\t\tArray.isArray(degraded.missingLinks) &&\n\t\tdegraded.missingLinks.every((index) => Number.isInteger(index)) &&\n\t\tisStringList(degraded.missingPaths) &&\n\t\tisStringList(degraded.missingCommits) &&\n\t\ttypeof degraded.cause === \"string\" &&\n\t\ttypeof degraded.hint === \"string\"\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"build-questionnaire.d.ts","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/state/build-questionnaire.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAoB,KAAK,KAAK,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAgBrD,OAAO,KAAK,EAAE,kBAAkB,EAAuB,MAAM,uCAAuC,CAAC;AAErG,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAerE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,WAAW,wBAAwB;IACxC,GAAG,EAAE;QAAE,QAAQ,EAAE;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;QAAC,aAAa,IAAI,IAAI,CAAA;KAAE,CAAC;IAC9D,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,SAAS,YAAY,EAAE,CAAC;IACnC,UAAU,EAAE,aAAa,CAAC,SAAS,kBAAkB,EAAE,CAAC,CAAC;IACzD,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,kBAAkB,CAAC;IACjC,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IAClC,OAAO,EAAE,yBAAyB,CAAC;IACnC,UAAU,EAAE,KAAK,CAAC;IAClB,WAAW,EAAE,KAAK,CAAC;IACnB,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IACpC,UAAU,EAAE,MAAM,IAAI,CAAC;CACvB;AASD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,kBAAkB,CAEvF"}
1
+ {"version":3,"file":"build-questionnaire.d.ts","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/state/build-questionnaire.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAoB,KAAK,KAAK,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAgBrD,OAAO,KAAK,EAAE,kBAAkB,EAAuB,MAAM,uCAAuC,CAAC;AAErG,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAgBrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,WAAW,wBAAwB;IACxC,GAAG,EAAE;QAAE,QAAQ,EAAE;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;QAAC,aAAa,IAAI,IAAI,CAAA;KAAE,CAAC;IAC9D,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,SAAS,YAAY,EAAE,CAAC;IACnC,UAAU,EAAE,aAAa,CAAC,SAAS,kBAAkB,EAAE,CAAC,CAAC;IACzD,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,kBAAkB,CAAC;IACjC,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IAClC,OAAO,EAAE,yBAAyB,CAAC;IACnC,UAAU,EAAE,KAAK,CAAC;IAClB,WAAW,EAAE,KAAK,CAAC;IACnB,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IACpC,UAAU,EAAE,MAAM,IAAI,CAAC;CACvB;AASD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,kBAAkB,CAEvF"}
@@ -13,6 +13,7 @@ import { DialogView } from "../view/dialog-builder.js";
13
13
  import { QuestionnairePropsAdapter } from "../view/props-adapter.js";
14
14
  import { ROW_INTENT_META } from "./row-intent.js";
15
15
  import { selectActivePreviewPaneIndex } from "./selectors/derivations.js";
16
+ import { styleFieldTone } from "./selectors/field-tone.js";
16
17
  import { selectChatRowProps, selectDialogProps, selectMultiSelectProps, selectOptionListProps, selectPreviewPaneProps, selectSubmitPickerProps, selectTabBarProps, } from "./selectors/projections.js";
17
18
  function maxBodyHeightOf(preview, multiSelect) {
18
19
  return multiSelect ? (width) => multiSelect.naturalHeight(width) : (width) => preview.maxNaturalHeight(width);
@@ -75,7 +76,7 @@ class QuestionnaireBuilder {
75
76
  makeSelectTheme() {
76
77
  const t = this.theme;
77
78
  return {
78
- selectedText: (s) => t.fg("accent", t.bold(s)),
79
+ field: (tone, s) => styleFieldTone(t, tone, s),
79
80
  description: (s) => t.fg("muted", s),
80
81
  scrollInfo: (s) => t.fg("dim", s),
81
82
  };
@@ -1 +1 @@
1
- {"version":3,"file":"build-questionnaire.js","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/state/build-questionnaire.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAc,MAAM,8CAA8C,CAAC;AAE5F,OAAO,EAGN,aAAa,EACb,aAAa,GACb,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sDAAsD,CAAC;AAC5F,OAAO,EAAE,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,MAAM,EAAE,sBAAsB;aAC9B,CAAC;YACF,aAAa,CAAC;gBACb,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW;gBACjC,MAAM,EAAE,sBAAsB;aAC9B,CAAC;SACF,CAAC;IACH,CAAC;IAEO,YAAY,CACnB,IAAkC,EAClC,cAAiD,EACjD,cAAiD;QAEjD,OAAO,IAAI,yBAAyB,CAAC;YACpC,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,WAAW,EAAE,IAAI;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,cAAc;YACd,cAAc;YACd,mBAAmB,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC;SACtC,CAAC,CAAC;IACJ,CAAC;IAEO,MAAM,CAAC,OAAkC,EAAE,MAAkB;QACpE,OAAO;YACN,OAAO;YACP,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;YAC/B,UAAU,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE;SACtC,CAAC;IACH,CAAC;CACD","sourcesContent":["import { Input } from \"@earendil-works/pi-tui\";\nimport { getMarkdownTheme, type Theme } from \"../../../../modes/interactive/theme/theme.js\";\nimport type { QuestionData } from \"../tool/types.js\";\nimport {\n\ttype BoundGlobalBinding,\n\ttype BoundPerTabBinding,\n\tglobalBinding,\n\tperTabBinding,\n} from \"../view/component-binding.ts\";\nimport { ChatRowView } from \"../view/components/chat-row-view.ts\";\nimport { MultiSelectView } from \"../view/components/multi-select-view.ts\";\nimport { OptionListView } from \"../view/components/option-list-view.ts\";\nimport { PreviewBlockRenderer } from \"../view/components/preview/preview-block-renderer.ts\";\nimport { crossTabLeftWidthWithDonation } from \"../view/components/preview/preview-layout-decider.ts\";\nimport type { PreviewPaneProps } from \"../view/components/preview/preview-pane.ts\";\nimport { PreviewPane } from \"../view/components/preview/preview-pane.ts\";\nimport { SubmitPicker } from \"../view/components/submit-picker.ts\";\nimport { TabBar } from \"../view/components/tab-bar.ts\";\nimport type { WrappingSelectItem, WrappingSelectTheme } from \"../view/components/wrapping-select.ts\";\nimport { DialogView } from \"../view/dialog-builder.ts\";\nimport { QuestionnairePropsAdapter } from \"../view/props-adapter.ts\";\nimport type { StatefulView } from \"../view/stateful-view.ts\";\nimport type { TabComponents } from \"../view/tab-components.ts\";\nimport { ROW_INTENT_META } from \"./row-intent.ts\";\nimport type { PerTabSelector } from \"./selectors/contract.ts\";\nimport { selectActivePreviewPaneIndex } from \"./selectors/derivations.ts\";\nimport {\n\tselectChatRowProps,\n\tselectDialogProps,\n\tselectMultiSelectProps,\n\tselectOptionListProps,\n\tselectPreviewPaneProps,\n\tselectSubmitPickerProps,\n\tselectTabBarProps,\n} from \"./selectors/projections.ts\";\nimport type { QuestionnaireState } from \"./state.ts\";\n\nexport interface QuestionnaireBuildConfig {\n\ttui: { terminal: { columns: number }; requestRender(): void };\n\ttheme: Theme;\n\tquestions: readonly QuestionData[];\n\titemsByTab: ReadonlyArray<readonly WrappingSelectItem[]>;\n\tisMulti: boolean;\n\tinitialState: QuestionnaireState;\n\tchatAsOption?: boolean;\n}\n\nexport interface QuestionnaireBuilt {\n\tadapter: QuestionnairePropsAdapter;\n\tnotesInput: Input;\n\tinlineInput: Input;\n\trender: (width: number) => string[];\n\tinvalidate: () => void;\n}\n\nfunction maxBodyHeightOf(preview: PreviewPane, multiSelect: MultiSelectView | undefined): (width: number) => number {\n\treturn multiSelect ? (width) => multiSelect.naturalHeight(width) : (width) => preview.maxNaturalHeight(width);\n}\n\nconst isActiveTab: PerTabSelector<boolean> = (s, ctx) =>\n\tctx.i === selectActivePreviewPaneIndex(s.currentTab, ctx.totalQuestions);\n\n/**\n * Pure factory: assembles every TUI component, the props adapter, and a\n * lifecycle handle. Session-state dependencies arrive via the\n * `inputBuffer` cell. Initial paint is delegated to\n * `adapter.apply(initialState)` (called by the session at construction-end);\n * no selector is invoked here.\n */\nexport function buildQuestionnaire(config: QuestionnaireBuildConfig): QuestionnaireBuilt {\n\treturn new QuestionnaireBuilder(config).build();\n}\n\n/**\n * Programming-by-intention assembly: each private method names one\n * construction step from `build()`. Read top-down; the class is build-only and\n * discarded once the handle is returned.\n */\nclass QuestionnaireBuilder {\n\tprivate readonly tui: QuestionnaireBuildConfig[\"tui\"];\n\tprivate readonly theme: Theme;\n\tprivate readonly questions: readonly QuestionData[];\n\tprivate readonly itemsByTab: ReadonlyArray<readonly WrappingSelectItem[]>;\n\tprivate readonly isMulti: boolean;\n\tprivate readonly initialState: QuestionnaireState;\n\n\tprivate readonly selectTheme: WrappingSelectTheme;\n\tprivate readonly markdownTheme = getMarkdownTheme();\n\tprivate readonly chatRow: ChatRowView;\n\tprivate readonly notesInput = new Input();\n\tprivate readonly inlineInput = new Input();\n\tprivate readonly getTerminalWidth = () => this.tui.terminal.columns;\n\n\tconstructor(config: QuestionnaireBuildConfig) {\n\t\tthis.tui = config.tui;\n\t\tthis.theme = config.theme;\n\t\tthis.questions = config.questions;\n\t\tthis.itemsByTab = config.itemsByTab;\n\t\tthis.isMulti = config.isMulti;\n\t\tthis.initialState = config.initialState;\n\n\t\tthis.selectTheme = this.makeSelectTheme();\n\t\tthis.chatRow = new ChatRowView({\n\t\t\titem: { kind: \"chat\", label: ROW_INTENT_META.chat.label },\n\t\t\ttheme: this.selectTheme,\n\t\t\tinlineInputEnabled: config.chatAsOption !== true,\n\t\t});\n\t}\n\n\tbuild(): QuestionnaireBuilt {\n\t\tconst tabs = this.buildTabComponents();\n\t\tthis.injectGlobalLeftWidth(tabs);\n\t\tconst submitPicker = this.buildSubmitPicker();\n\t\tconst tabBar = this.buildTabBar();\n\t\tconst getBodyHeight = this.buildBodyHeight(tabs);\n\t\tconst dialog = this.buildDialog(tabs, submitPicker, tabBar, getBodyHeight);\n\t\tconst globalBindings = this.buildGlobalBindings(dialog, submitPicker, tabBar);\n\t\tconst perTabBindings = this.buildPerTabBindings();\n\t\tconst adapter = this.buildAdapter(tabs, globalBindings, perTabBindings);\n\t\treturn this.handle(adapter, dialog);\n\t}\n\n\tprivate makeSelectTheme(): WrappingSelectTheme {\n\t\tconst t = this.theme;\n\t\treturn {\n\t\t\tselectedText: (s) => t.fg(\"accent\", t.bold(s)),\n\t\t\tdescription: (s) => t.fg(\"muted\", s),\n\t\t\tscrollInfo: (s) => t.fg(\"dim\", s),\n\t\t};\n\t}\n\n\tprivate buildTabComponents(): ReadonlyArray<TabComponents> {\n\t\treturn this.questions.map((q, i) => this.buildTabFor(q, i));\n\t}\n\n\tprivate buildTabFor(question: QuestionData, index: number): TabComponents {\n\t\tconst optionList = new OptionListView({\n\t\t\titems: this.itemsByTab[index] ?? [],\n\t\t\ttheme: this.selectTheme,\n\t\t});\n\t\tconst previewBlock = new PreviewBlockRenderer({\n\t\t\tquestion,\n\t\t\ttheme: this.theme,\n\t\t\tmarkdownTheme: this.markdownTheme,\n\t\t});\n\t\tconst preview = new PreviewPane({\n\t\t\tquestion,\n\t\t\tgetTerminalWidth: this.getTerminalWidth,\n\t\t\toptionListView: optionList,\n\t\t\tpreviewBlock,\n\t\t});\n\t\tconst multiSelect = question.multiSelect ? new MultiSelectView(this.theme, question) : undefined;\n\t\treturn { optionList, preview, multiSelect, maxBodyHeight: maxBodyHeightOf(preview, multiSelect) };\n\t}\n\n\t/**\n\t * Compute cross-tab max adaptive left width and inject into each PreviewPane.\n\t * Mirrors buildBodyHeight pattern — iterates all tabs, takes max. The inputs\n\t * never change for a dialog, so each pane width is computed once.\n\t * Called after buildTabComponents, before buildDialog (so setGlobalLeftWidth\n\t * is set before any rendering occurs).\n\t */\n\tprivate injectGlobalLeftWidth(tabs: ReadonlyArray<TabComponents>): void {\n\t\tconst questions = this.questions;\n\t\tconst itemsByTab = this.itemsByTab;\n\t\tconst tabsDescriptor = questions.map((q) => ({ multiSelect: q.multiSelect }));\n\t\tconst leftWidthByPaneWidth = new Map<number, number>();\n\t\tconst globalLeftWidth = (paneWidth: number): number => {\n\t\t\tconst cached = leftWidthByPaneWidth.get(paneWidth);\n\t\t\tif (cached !== undefined) return cached;\n\t\t\tconst left = crossTabLeftWidthWithDonation(tabsDescriptor, itemsByTab, questions, paneWidth);\n\t\t\tleftWidthByPaneWidth.set(paneWidth, left);\n\t\t\treturn left;\n\t\t};\n\t\tfor (const tab of tabs) {\n\t\t\ttab.preview.setGlobalLeftWidth(globalLeftWidth);\n\t\t}\n\t}\n\n\tprivate buildSubmitPicker(): SubmitPicker | undefined {\n\t\treturn this.isMulti ? new SubmitPicker(this.theme) : undefined;\n\t}\n\n\tprivate buildTabBar(): TabBar | undefined {\n\t\treturn this.isMulti ? new TabBar(this.theme) : undefined;\n\t}\n\n\tprivate buildBodyHeight(tabs: ReadonlyArray<TabComponents>): (width: number) => number {\n\t\treturn (width) => {\n\t\t\tlet max = 0;\n\t\t\tfor (const tab of tabs) {\n\t\t\t\tconst h = tab.maxBodyHeight(width);\n\t\t\t\tif (h > max) max = h;\n\t\t\t}\n\t\t\treturn Math.max(1, max);\n\t\t};\n\t}\n\n\tprivate pickInitialActivePreview(tabs: ReadonlyArray<TabComponents>): StatefulView<PreviewPaneProps> {\n\t\tconst idx = selectActivePreviewPaneIndex(this.initialState.currentTab, this.questions.length);\n\t\treturn tabs[idx]?.preview ?? tabs[0]!.preview;\n\t}\n\n\tprivate buildDialog(\n\t\ttabs: ReadonlyArray<TabComponents>,\n\t\tsubmitPicker: SubmitPicker | undefined,\n\t\ttabBar: TabBar | undefined,\n\t\tgetBodyHeight: (width: number) => number,\n\t): DialogView {\n\t\treturn new DialogView(\n\t\t\t{\n\t\t\t\ttheme: this.theme,\n\t\t\t\tquestions: this.questions,\n\t\t\t\ttabBar,\n\t\t\t\tnotesInput: this.notesInput,\n\t\t\t\tchatRow: this.chatRow,\n\t\t\t\tisMulti: this.isMulti,\n\t\t\t\ttabsByIndex: tabs,\n\t\t\t\tsubmitPicker,\n\t\t\t\tgetBodyHeight,\n\t\t\t\tgetTerminalWidth: this.getTerminalWidth,\n\t\t\t},\n\t\t\t{ state: this.initialState, activePreviewPane: this.pickInitialActivePreview(tabs) },\n\t\t);\n\t}\n\n\tprivate buildGlobalBindings(\n\t\tdialog: DialogView,\n\t\tsubmitPicker: SubmitPicker | undefined,\n\t\ttabBar: TabBar | undefined,\n\t): ReadonlyArray<BoundGlobalBinding> {\n\t\treturn [\n\t\t\tglobalBinding({ component: dialog, select: selectDialogProps }),\n\t\t\tglobalBinding({ component: this.chatRow, select: selectChatRowProps }),\n\t\t\t...(submitPicker ? [globalBinding({ component: submitPicker, select: selectSubmitPickerProps })] : []),\n\t\t\t...(tabBar ? [globalBinding({ component: tabBar, select: selectTabBarProps })] : []),\n\t\t];\n\t}\n\n\tprivate buildPerTabBindings(): ReadonlyArray<BoundPerTabBinding> {\n\t\treturn [\n\t\t\tperTabBinding({\n\t\t\t\tresolve: (tab) => tab.optionList,\n\t\t\t\tpredicate: isActiveTab,\n\t\t\t\tselect: selectOptionListProps,\n\t\t\t}),\n\t\t\tperTabBinding({\n\t\t\t\tresolve: (tab) => tab.preview,\n\t\t\t\tpredicate: isActiveTab,\n\t\t\t\tselect: selectPreviewPaneProps,\n\t\t\t}),\n\t\t\tperTabBinding({\n\t\t\t\tresolve: (tab) => tab.multiSelect,\n\t\t\t\tselect: selectMultiSelectProps,\n\t\t\t}),\n\t\t];\n\t}\n\n\tprivate buildAdapter(\n\t\ttabs: ReadonlyArray<TabComponents>,\n\t\tglobalBindings: ReadonlyArray<BoundGlobalBinding>,\n\t\tperTabBindings: ReadonlyArray<BoundPerTabBinding>,\n\t): QuestionnairePropsAdapter {\n\t\treturn new QuestionnairePropsAdapter({\n\t\t\ttui: this.tui,\n\t\t\tquestions: this.questions,\n\t\t\titemsByTab: this.itemsByTab,\n\t\t\ttabsByIndex: tabs,\n\t\t\tinlineInput: this.inlineInput,\n\t\t\tglobalBindings,\n\t\t\tperTabBindings,\n\t\t\textraInvalidatables: [this.notesInput],\n\t\t});\n\t}\n\n\tprivate handle(adapter: QuestionnairePropsAdapter, dialog: DialogView): QuestionnaireBuilt {\n\t\treturn {\n\t\t\tadapter,\n\t\t\tnotesInput: this.notesInput,\n\t\t\tinlineInput: this.inlineInput,\n\t\t\trender: (w) => dialog.render(w),\n\t\t\tinvalidate: () => adapter.invalidate(),\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"build-questionnaire.js","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/state/build-questionnaire.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAc,MAAM,8CAA8C,CAAC;AAE5F,OAAO,EAGN,aAAa,EACb,aAAa,GACb,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sDAAsD,CAAC;AAC5F,OAAO,EAAE,6BAA6B,EAAE,MAAM,sDAAsD,CAAC;AAErG,OAAO,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CA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,CAAC,UAAU;YAC3B,WAAW,EAAE,IAAI;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,cAAc;YACd,cAAc;YACd,mBAAmB,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC;SACtC,CAAC,CAAC;IACJ,CAAC;IAEO,MAAM,CAAC,OAAkC,EAAE,MAAkB;QACpE,OAAO;YACN,OAAO;YACP,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;YAC/B,UAAU,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE;SACtC,CAAC;IACH,CAAC;CACD","sourcesContent":["import { Input } from \"@earendil-works/pi-tui\";\nimport { getMarkdownTheme, type Theme } from \"../../../../modes/interactive/theme/theme.js\";\nimport type { QuestionData } from \"../tool/types.js\";\nimport {\n\ttype BoundGlobalBinding,\n\ttype BoundPerTabBinding,\n\tglobalBinding,\n\tperTabBinding,\n} from \"../view/component-binding.ts\";\nimport { ChatRowView } from \"../view/components/chat-row-view.ts\";\nimport { MultiSelectView } from \"../view/components/multi-select-view.ts\";\nimport { OptionListView } from \"../view/components/option-list-view.ts\";\nimport { PreviewBlockRenderer } from \"../view/components/preview/preview-block-renderer.ts\";\nimport { crossTabLeftWidthWithDonation } from \"../view/components/preview/preview-layout-decider.ts\";\nimport type { PreviewPaneProps } from \"../view/components/preview/preview-pane.ts\";\nimport { PreviewPane } from \"../view/components/preview/preview-pane.ts\";\nimport { SubmitPicker } from \"../view/components/submit-picker.ts\";\nimport { TabBar } from \"../view/components/tab-bar.ts\";\nimport type { WrappingSelectItem, WrappingSelectTheme } from \"../view/components/wrapping-select.ts\";\nimport { DialogView } from \"../view/dialog-builder.ts\";\nimport { QuestionnairePropsAdapter } from \"../view/props-adapter.ts\";\nimport type { StatefulView } from \"../view/stateful-view.ts\";\nimport type { TabComponents } from \"../view/tab-components.ts\";\nimport { ROW_INTENT_META } from \"./row-intent.ts\";\nimport type { PerTabSelector } from \"./selectors/contract.ts\";\nimport { selectActivePreviewPaneIndex } from \"./selectors/derivations.ts\";\nimport { styleFieldTone } from \"./selectors/field-tone.ts\";\nimport {\n\tselectChatRowProps,\n\tselectDialogProps,\n\tselectMultiSelectProps,\n\tselectOptionListProps,\n\tselectPreviewPaneProps,\n\tselectSubmitPickerProps,\n\tselectTabBarProps,\n} from \"./selectors/projections.ts\";\nimport type { QuestionnaireState } from \"./state.ts\";\n\nexport interface QuestionnaireBuildConfig {\n\ttui: { terminal: { columns: number }; requestRender(): void };\n\ttheme: Theme;\n\tquestions: readonly QuestionData[];\n\titemsByTab: ReadonlyArray<readonly WrappingSelectItem[]>;\n\tisMulti: boolean;\n\tinitialState: QuestionnaireState;\n\tchatAsOption?: boolean;\n}\n\nexport interface QuestionnaireBuilt {\n\tadapter: QuestionnairePropsAdapter;\n\tnotesInput: Input;\n\tinlineInput: Input;\n\trender: (width: number) => string[];\n\tinvalidate: () => void;\n}\n\nfunction maxBodyHeightOf(preview: PreviewPane, multiSelect: MultiSelectView | undefined): (width: number) => number {\n\treturn multiSelect ? (width) => multiSelect.naturalHeight(width) : (width) => preview.maxNaturalHeight(width);\n}\n\nconst isActiveTab: PerTabSelector<boolean> = (s, ctx) =>\n\tctx.i === selectActivePreviewPaneIndex(s.currentTab, ctx.totalQuestions);\n\n/**\n * Pure factory: assembles every TUI component, the props adapter, and a\n * lifecycle handle. Session-state dependencies arrive via the\n * `inputBuffer` cell. Initial paint is delegated to\n * `adapter.apply(initialState)` (called by the session at construction-end);\n * no selector is invoked here.\n */\nexport function buildQuestionnaire(config: QuestionnaireBuildConfig): QuestionnaireBuilt {\n\treturn new QuestionnaireBuilder(config).build();\n}\n\n/**\n * Programming-by-intention assembly: each private method names one\n * construction step from `build()`. Read top-down; the class is build-only and\n * discarded once the handle is returned.\n */\nclass QuestionnaireBuilder {\n\tprivate readonly tui: QuestionnaireBuildConfig[\"tui\"];\n\tprivate readonly theme: Theme;\n\tprivate readonly questions: readonly QuestionData[];\n\tprivate readonly itemsByTab: ReadonlyArray<readonly WrappingSelectItem[]>;\n\tprivate readonly isMulti: boolean;\n\tprivate readonly initialState: QuestionnaireState;\n\n\tprivate readonly selectTheme: WrappingSelectTheme;\n\tprivate readonly markdownTheme = getMarkdownTheme();\n\tprivate readonly chatRow: ChatRowView;\n\tprivate readonly notesInput = new Input();\n\tprivate readonly inlineInput = new Input();\n\tprivate readonly getTerminalWidth = () => this.tui.terminal.columns;\n\n\tconstructor(config: QuestionnaireBuildConfig) {\n\t\tthis.tui = config.tui;\n\t\tthis.theme = config.theme;\n\t\tthis.questions = config.questions;\n\t\tthis.itemsByTab = config.itemsByTab;\n\t\tthis.isMulti = config.isMulti;\n\t\tthis.initialState = config.initialState;\n\n\t\tthis.selectTheme = this.makeSelectTheme();\n\t\tthis.chatRow = new ChatRowView({\n\t\t\titem: { kind: \"chat\", label: ROW_INTENT_META.chat.label },\n\t\t\ttheme: this.selectTheme,\n\t\t\tinlineInputEnabled: config.chatAsOption !== true,\n\t\t});\n\t}\n\n\tbuild(): QuestionnaireBuilt {\n\t\tconst tabs = this.buildTabComponents();\n\t\tthis.injectGlobalLeftWidth(tabs);\n\t\tconst submitPicker = this.buildSubmitPicker();\n\t\tconst tabBar = this.buildTabBar();\n\t\tconst getBodyHeight = this.buildBodyHeight(tabs);\n\t\tconst dialog = this.buildDialog(tabs, submitPicker, tabBar, getBodyHeight);\n\t\tconst globalBindings = this.buildGlobalBindings(dialog, submitPicker, tabBar);\n\t\tconst perTabBindings = this.buildPerTabBindings();\n\t\tconst adapter = this.buildAdapter(tabs, globalBindings, perTabBindings);\n\t\treturn this.handle(adapter, dialog);\n\t}\n\n\tprivate makeSelectTheme(): WrappingSelectTheme {\n\t\tconst t = this.theme;\n\t\treturn {\n\t\t\tfield: (tone, s) => styleFieldTone(t, tone, s),\n\t\t\tdescription: (s) => t.fg(\"muted\", s),\n\t\t\tscrollInfo: (s) => t.fg(\"dim\", s),\n\t\t};\n\t}\n\n\tprivate buildTabComponents(): ReadonlyArray<TabComponents> {\n\t\treturn this.questions.map((q, i) => this.buildTabFor(q, i));\n\t}\n\n\tprivate buildTabFor(question: QuestionData, index: number): TabComponents {\n\t\tconst optionList = new OptionListView({\n\t\t\titems: this.itemsByTab[index] ?? [],\n\t\t\ttheme: this.selectTheme,\n\t\t});\n\t\tconst previewBlock = new PreviewBlockRenderer({\n\t\t\tquestion,\n\t\t\ttheme: this.theme,\n\t\t\tmarkdownTheme: this.markdownTheme,\n\t\t});\n\t\tconst preview = new PreviewPane({\n\t\t\tquestion,\n\t\t\tgetTerminalWidth: this.getTerminalWidth,\n\t\t\toptionListView: optionList,\n\t\t\tpreviewBlock,\n\t\t});\n\t\tconst multiSelect = question.multiSelect ? new MultiSelectView(this.theme, question) : undefined;\n\t\treturn { optionList, preview, multiSelect, maxBodyHeight: maxBodyHeightOf(preview, multiSelect) };\n\t}\n\n\t/**\n\t * Compute cross-tab max adaptive left width and inject into each PreviewPane.\n\t * Mirrors buildBodyHeight pattern — iterates all tabs, takes max. The inputs\n\t * never change for a dialog, so each pane width is computed once.\n\t * Called after buildTabComponents, before buildDialog (so setGlobalLeftWidth\n\t * is set before any rendering occurs).\n\t */\n\tprivate injectGlobalLeftWidth(tabs: ReadonlyArray<TabComponents>): void {\n\t\tconst questions = this.questions;\n\t\tconst itemsByTab = this.itemsByTab;\n\t\tconst tabsDescriptor = questions.map((q) => ({ multiSelect: q.multiSelect }));\n\t\tconst leftWidthByPaneWidth = new Map<number, number>();\n\t\tconst globalLeftWidth = (paneWidth: number): number => {\n\t\t\tconst cached = leftWidthByPaneWidth.get(paneWidth);\n\t\t\tif (cached !== undefined) return cached;\n\t\t\tconst left = crossTabLeftWidthWithDonation(tabsDescriptor, itemsByTab, questions, paneWidth);\n\t\t\tleftWidthByPaneWidth.set(paneWidth, left);\n\t\t\treturn left;\n\t\t};\n\t\tfor (const tab of tabs) {\n\t\t\ttab.preview.setGlobalLeftWidth(globalLeftWidth);\n\t\t}\n\t}\n\n\tprivate buildSubmitPicker(): SubmitPicker | undefined {\n\t\treturn this.isMulti ? new SubmitPicker(this.theme) : undefined;\n\t}\n\n\tprivate buildTabBar(): TabBar | undefined {\n\t\treturn this.isMulti ? new TabBar(this.theme) : undefined;\n\t}\n\n\tprivate buildBodyHeight(tabs: ReadonlyArray<TabComponents>): (width: number) => number {\n\t\treturn (width) => {\n\t\t\tlet max = 0;\n\t\t\tfor (const tab of tabs) {\n\t\t\t\tconst h = tab.maxBodyHeight(width);\n\t\t\t\tif (h > max) max = h;\n\t\t\t}\n\t\t\treturn Math.max(1, max);\n\t\t};\n\t}\n\n\tprivate pickInitialActivePreview(tabs: ReadonlyArray<TabComponents>): StatefulView<PreviewPaneProps> {\n\t\tconst idx = selectActivePreviewPaneIndex(this.initialState.currentTab, this.questions.length);\n\t\treturn tabs[idx]?.preview ?? tabs[0]!.preview;\n\t}\n\n\tprivate buildDialog(\n\t\ttabs: ReadonlyArray<TabComponents>,\n\t\tsubmitPicker: SubmitPicker | undefined,\n\t\ttabBar: TabBar | undefined,\n\t\tgetBodyHeight: (width: number) => number,\n\t): DialogView {\n\t\treturn new DialogView(\n\t\t\t{\n\t\t\t\ttheme: this.theme,\n\t\t\t\tquestions: this.questions,\n\t\t\t\ttabBar,\n\t\t\t\tnotesInput: this.notesInput,\n\t\t\t\tchatRow: this.chatRow,\n\t\t\t\tisMulti: this.isMulti,\n\t\t\t\ttabsByIndex: tabs,\n\t\t\t\tsubmitPicker,\n\t\t\t\tgetBodyHeight,\n\t\t\t\tgetTerminalWidth: this.getTerminalWidth,\n\t\t\t},\n\t\t\t{ state: this.initialState, activePreviewPane: this.pickInitialActivePreview(tabs) },\n\t\t);\n\t}\n\n\tprivate buildGlobalBindings(\n\t\tdialog: DialogView,\n\t\tsubmitPicker: SubmitPicker | undefined,\n\t\ttabBar: TabBar | undefined,\n\t): ReadonlyArray<BoundGlobalBinding> {\n\t\treturn [\n\t\t\tglobalBinding({ component: dialog, select: selectDialogProps }),\n\t\t\tglobalBinding({ component: this.chatRow, select: selectChatRowProps }),\n\t\t\t...(submitPicker ? [globalBinding({ component: submitPicker, select: selectSubmitPickerProps })] : []),\n\t\t\t...(tabBar ? [globalBinding({ component: tabBar, select: selectTabBarProps })] : []),\n\t\t];\n\t}\n\n\tprivate buildPerTabBindings(): ReadonlyArray<BoundPerTabBinding> {\n\t\treturn [\n\t\t\tperTabBinding({\n\t\t\t\tresolve: (tab) => tab.optionList,\n\t\t\t\tpredicate: isActiveTab,\n\t\t\t\tselect: selectOptionListProps,\n\t\t\t}),\n\t\t\tperTabBinding({\n\t\t\t\tresolve: (tab) => tab.preview,\n\t\t\t\tpredicate: isActiveTab,\n\t\t\t\tselect: selectPreviewPaneProps,\n\t\t\t}),\n\t\t\tperTabBinding({\n\t\t\t\tresolve: (tab) => tab.multiSelect,\n\t\t\t\tselect: selectMultiSelectProps,\n\t\t\t}),\n\t\t];\n\t}\n\n\tprivate buildAdapter(\n\t\ttabs: ReadonlyArray<TabComponents>,\n\t\tglobalBindings: ReadonlyArray<BoundGlobalBinding>,\n\t\tperTabBindings: ReadonlyArray<BoundPerTabBinding>,\n\t): QuestionnairePropsAdapter {\n\t\treturn new QuestionnairePropsAdapter({\n\t\t\ttui: this.tui,\n\t\t\tquestions: this.questions,\n\t\t\titemsByTab: this.itemsByTab,\n\t\t\ttabsByIndex: tabs,\n\t\t\tinlineInput: this.inlineInput,\n\t\t\tglobalBindings,\n\t\t\tperTabBindings,\n\t\t\textraInvalidatables: [this.notesInput],\n\t\t});\n\t}\n\n\tprivate handle(adapter: QuestionnairePropsAdapter, dialog: DialogView): QuestionnaireBuilt {\n\t\treturn {\n\t\t\tadapter,\n\t\t\tnotesInput: this.notesInput,\n\t\t\tinlineInput: this.inlineInput,\n\t\t\trender: (w) => dialog.render(w),\n\t\t\tinvalidate: () => adapter.invalidate(),\n\t\t};\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"questionnaire-session.d.ts","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/state/questionnaire-session.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8CAA8C,CAAC;AAC1E,OAAO,KAAK,EAAgB,mBAAmB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAsDhF,MAAM,WAAW,0BAA0B;IAC1C,GAAG,EAAE;QAAE,QAAQ,EAAE;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;QAAC,aAAa,IAAI,IAAI,CAAA;KAAE,CAAC;IAC9D,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,cAAc,CAAC;IACvB,UAAU,EAAE,kBAAkB,EAAE,EAAE,CAAC;IACnC,IAAI,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC5C,uFAAuF;IACvF,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,6BAA6B;IAC7C,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,UAAU,IAAI,IAAI,CAAC;IACnB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACnC;AAuBD;;;;;GAKG;AACH,qBAAa,oBAAoB;IAChC,OAAO,CAAC,KAAK,CAAsC;IAEnD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0B;IACpD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAyB;IACpD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAU;IAEvC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IACnC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAQ;IACpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA4B;IAExD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAoC;IACxD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqC;IAE1D,QAAQ,CAAC,SAAS,EAAE,6BAA6B,CAAC;IAElD,YAAY,MAAM,EAAE,0BAA0B,EA+B7C;IAED,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAS9B;IAED,OAAO,CAAC,MAAM;IASd,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,sBAAsB;IAW9B,OAAO,CAAC,SAAS;IAqBjB;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,OAAO;IAWf,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,WAAW;CAMnB"}
1
+ {"version":3,"file":"questionnaire-session.d.ts","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/state/questionnaire-session.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8CAA8C,CAAC;AAC1E,OAAO,KAAK,EAAgB,mBAAmB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAsDhF,MAAM,WAAW,0BAA0B;IAC1C,GAAG,EAAE;QAAE,QAAQ,EAAE;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;QAAC,aAAa,IAAI,IAAI,CAAA;KAAE,CAAC;IAC9D,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,cAAc,CAAC;IACvB,UAAU,EAAE,kBAAkB,EAAE,EAAE,CAAC;IACnC,IAAI,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC5C,uFAAuF;IACvF,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,6BAA6B;IAC7C,MAAM,CAAC,KAAK,EAAE,MAAM,GA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