@bastani/atomic 0.10.2-alpha.1 → 0.10.3-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 (499) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +17 -0
  3. package/dist/builtin/intercom/broker/broker-instance.ts +2 -13
  4. package/dist/builtin/intercom/broker/broker.ts +158 -73
  5. package/dist/builtin/intercom/broker/durable-ended-queue.ts +14 -2
  6. package/dist/builtin/intercom/broker/host-command-environment.ts +13 -0
  7. package/dist/builtin/intercom/broker/hosted-session-errors.ts +1 -0
  8. package/dist/builtin/intercom/broker/multinode-router.ts +111 -16
  9. package/dist/builtin/intercom/broker/multinode-state-store.ts +50 -4
  10. package/dist/builtin/intercom/broker/open-broker-state.ts +5 -4
  11. package/dist/builtin/intercom/broker/spawn.ts +144 -25
  12. package/dist/builtin/intercom/broker/sql-add-column.ts +33 -0
  13. package/dist/builtin/intercom/broker/sql-known-session-store.ts +120 -36
  14. package/dist/builtin/intercom/broker/sql-outbox-store.ts +75 -13
  15. package/dist/builtin/intercom/broker/start-announcement.ts +55 -10
  16. package/dist/builtin/intercom/broker/watchdog.ts +10 -7
  17. package/dist/builtin/intercom/index.bundle.mjs +111 -27
  18. package/dist/builtin/intercom/package.json +1 -1
  19. package/dist/builtin/mcp/package.json +1 -1
  20. package/dist/builtin/subagents/CHANGELOG.md +29 -0
  21. package/dist/builtin/subagents/package.json +1 -1
  22. package/dist/builtin/subagents/skills/skill-creator/SKILL.md +30 -52
  23. package/dist/builtin/subagents/skills/skill-creator/eval-viewer/generate_review.py +34 -40
  24. package/dist/builtin/subagents/skills/skill-creator/eval-viewer/viewer.html +2 -2
  25. package/dist/builtin/subagents/skills/skill-creator/scripts/atomic_cli.py +668 -0
  26. package/dist/builtin/subagents/skills/skill-creator/scripts/generate_report.py +3 -3
  27. package/dist/builtin/subagents/skills/skill-creator/scripts/improve_description.py +42 -38
  28. package/dist/builtin/subagents/skills/skill-creator/scripts/run_eval.py +268 -176
  29. package/dist/builtin/subagents/skills/skill-creator/scripts/run_loop.py +20 -11
  30. package/dist/builtin/subagents/skills/skill-creator/scripts/utils.py +1 -1
  31. package/dist/builtin/subagents/src/extension/index.bundle.mjs +163 -97
  32. package/dist/builtin/web-access/CHANGELOG.md +14 -0
  33. package/dist/builtin/web-access/index.bundle.mjs +5 -4
  34. package/dist/builtin/web-access/package.json +1 -1
  35. package/dist/core/agent-session-auto-compaction.d.ts +10 -1
  36. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  37. package/dist/core/agent-session-auto-compaction.js +54 -2
  38. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  39. package/dist/core/agent-session-compaction.d.ts +4 -0
  40. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  41. package/dist/core/agent-session-compaction.js +17 -2
  42. package/dist/core/agent-session-compaction.js.map +1 -1
  43. package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
  44. package/dist/core/agent-session-custom-message-commit.js +3 -1
  45. package/dist/core/agent-session-custom-message-commit.js.map +1 -1
  46. package/dist/core/agent-session-events.d.ts +2 -0
  47. package/dist/core/agent-session-events.d.ts.map +1 -1
  48. package/dist/core/agent-session-events.js +34 -13
  49. package/dist/core/agent-session-events.js.map +1 -1
  50. package/dist/core/agent-session-export.d.ts.map +1 -1
  51. package/dist/core/agent-session-export.js +3 -0
  52. package/dist/core/agent-session-export.js.map +1 -1
  53. package/dist/core/agent-session-message-queue.d.ts +27 -0
  54. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  55. package/dist/core/agent-session-message-queue.js +213 -30
  56. package/dist/core/agent-session-message-queue.js.map +1 -1
  57. package/dist/core/agent-session-methods.d.ts +6 -1
  58. package/dist/core/agent-session-methods.d.ts.map +1 -1
  59. package/dist/core/agent-session-methods.js.map +1 -1
  60. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  61. package/dist/core/agent-session-prompt.js +35 -3
  62. package/dist/core/agent-session-prompt.js.map +1 -1
  63. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  64. package/dist/core/agent-session-runtime.js +2 -2
  65. package/dist/core/agent-session-runtime.js.map +1 -1
  66. package/dist/core/agent-session-state.d.ts.map +1 -1
  67. package/dist/core/agent-session-state.js +6 -1
  68. package/dist/core/agent-session-state.js.map +1 -1
  69. package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
  70. package/dist/core/agent-session-tool-hooks.js +15 -2
  71. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  72. package/dist/core/agent-session-typed-queue.d.ts +14 -1
  73. package/dist/core/agent-session-typed-queue.d.ts.map +1 -1
  74. package/dist/core/agent-session-typed-queue.js +26 -1
  75. package/dist/core/agent-session-typed-queue.js.map +1 -1
  76. package/dist/core/agent-session-types.d.ts +5 -0
  77. package/dist/core/agent-session-types.d.ts.map +1 -1
  78. package/dist/core/agent-session-types.js.map +1 -1
  79. package/dist/core/agent-session.d.ts.map +1 -1
  80. package/dist/core/agent-session.js +2 -1
  81. package/dist/core/agent-session.js.map +1 -1
  82. package/dist/core/async-scope.d.ts +9 -4
  83. package/dist/core/async-scope.d.ts.map +1 -1
  84. package/dist/core/async-scope.js +13 -5
  85. package/dist/core/async-scope.js.map +1 -1
  86. package/dist/core/builtin-diagnostics.js +2 -2
  87. package/dist/core/builtin-diagnostics.js.map +1 -1
  88. package/dist/core/chat-admission-order.d.ts.map +1 -1
  89. package/dist/core/chat-admission-order.js +2 -1
  90. package/dist/core/chat-admission-order.js.map +1 -1
  91. package/dist/core/chat-record-saves.d.ts +4 -0
  92. package/dist/core/chat-record-saves.d.ts.map +1 -0
  93. package/dist/core/chat-record-saves.js +25 -0
  94. package/dist/core/chat-record-saves.js.map +1 -0
  95. package/dist/core/command-deliveries.d.ts +62 -0
  96. package/dist/core/command-deliveries.d.ts.map +1 -0
  97. package/dist/core/command-deliveries.js +139 -0
  98. package/dist/core/command-deliveries.js.map +1 -0
  99. package/dist/core/diagnostic-writer.d.ts.map +1 -1
  100. package/dist/core/diagnostic-writer.js +5 -4
  101. package/dist/core/diagnostic-writer.js.map +1 -1
  102. package/dist/core/extension-startup-close.d.ts +1 -2
  103. package/dist/core/extension-startup-close.d.ts.map +1 -1
  104. package/dist/core/extension-startup-close.js +2 -2
  105. package/dist/core/extension-startup-close.js.map +1 -1
  106. package/dist/core/extensions/jiti-aliases.d.ts +11 -0
  107. package/dist/core/extensions/jiti-aliases.d.ts.map +1 -0
  108. package/dist/core/extensions/jiti-aliases.js +28 -0
  109. package/dist/core/extensions/jiti-aliases.js.map +1 -0
  110. package/dist/core/extensions/loader-api.js +3 -3
  111. package/dist/core/extensions/loader-api.js.map +1 -1
  112. package/dist/core/extensions/loader-bindings.js +2 -2
  113. package/dist/core/extensions/loader-bindings.js.map +1 -1
  114. package/dist/core/extensions/loader-rollback.d.ts +1 -2
  115. package/dist/core/extensions/loader-rollback.d.ts.map +1 -1
  116. package/dist/core/extensions/loader-rollback.js +2 -2
  117. package/dist/core/extensions/loader-rollback.js.map +1 -1
  118. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  119. package/dist/core/extensions/loader-virtual-modules.js +53 -9
  120. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  121. package/dist/core/extensions/native-builtin-entries.d.ts +5 -0
  122. package/dist/core/extensions/native-builtin-entries.d.ts.map +1 -1
  123. package/dist/core/extensions/native-builtin-entries.js +8 -1
  124. package/dist/core/extensions/native-builtin-entries.js.map +1 -1
  125. package/dist/core/extensions/reloadable-scripts.d.ts +21 -2
  126. package/dist/core/extensions/reloadable-scripts.d.ts.map +1 -1
  127. package/dist/core/extensions/reloadable-scripts.js +11 -3
  128. package/dist/core/extensions/reloadable-scripts.js.map +1 -1
  129. package/dist/core/extensions/source-builtin-imports.d.ts +40 -0
  130. package/dist/core/extensions/source-builtin-imports.d.ts.map +1 -0
  131. package/dist/core/extensions/source-builtin-imports.js +142 -0
  132. package/dist/core/extensions/source-builtin-imports.js.map +1 -0
  133. package/dist/core/extensions/transform-graph.d.ts +15 -0
  134. package/dist/core/extensions/transform-graph.d.ts.map +1 -0
  135. package/dist/core/extensions/transform-graph.js +85 -0
  136. package/dist/core/extensions/transform-graph.js.map +1 -0
  137. package/dist/core/extensions/ts-source-specifiers.d.ts +2 -0
  138. package/dist/core/extensions/ts-source-specifiers.d.ts.map +1 -1
  139. package/dist/core/extensions/ts-source-specifiers.js +7 -0
  140. package/dist/core/extensions/ts-source-specifiers.js.map +1 -1
  141. package/dist/core/extensions/ts-transform-worker.d.ts +2 -0
  142. package/dist/core/extensions/ts-transform-worker.d.ts.map +1 -0
  143. package/dist/core/extensions/ts-transform-worker.js +43 -0
  144. package/dist/core/extensions/ts-transform-worker.js.map +1 -0
  145. package/dist/core/message-admission.d.ts.map +1 -1
  146. package/dist/core/message-admission.js +4 -4
  147. package/dist/core/message-admission.js.map +1 -1
  148. package/dist/core/messages.d.ts +5 -0
  149. package/dist/core/messages.d.ts.map +1 -1
  150. package/dist/core/messages.js +35 -0
  151. package/dist/core/messages.js.map +1 -1
  152. package/dist/core/model-fallback-failures.d.ts +1 -1
  153. package/dist/core/model-fallback-failures.d.ts.map +1 -1
  154. package/dist/core/model-fallback-failures.js +18 -1
  155. package/dist/core/model-fallback-failures.js.map +1 -1
  156. package/dist/core/process-start-token.d.ts +7 -0
  157. package/dist/core/process-start-token.d.ts.map +1 -1
  158. package/dist/core/process-start-token.js +14 -0
  159. package/dist/core/process-start-token.js.map +1 -1
  160. package/dist/core/project-trust-electorate.d.ts +24 -0
  161. package/dist/core/project-trust-electorate.d.ts.map +1 -0
  162. package/dist/core/project-trust-electorate.js +52 -0
  163. package/dist/core/project-trust-electorate.js.map +1 -0
  164. package/dist/core/project-trust-state.d.ts +15 -0
  165. package/dist/core/project-trust-state.d.ts.map +1 -1
  166. package/dist/core/project-trust-state.js +15 -0
  167. package/dist/core/project-trust-state.js.map +1 -1
  168. package/dist/core/provider-request-admission.d.ts.map +1 -1
  169. package/dist/core/provider-request-admission.js +2 -2
  170. package/dist/core/provider-request-admission.js.map +1 -1
  171. package/dist/core/queued-input-admission.js +2 -2
  172. package/dist/core/queued-input-admission.js.map +1 -1
  173. package/dist/core/queued-message-delivery.d.ts +2 -2
  174. package/dist/core/queued-message-delivery.d.ts.map +1 -1
  175. package/dist/core/queued-message-delivery.js +6 -3
  176. package/dist/core/queued-message-delivery.js.map +1 -1
  177. package/dist/core/resource-admission-scope.js +2 -2
  178. package/dist/core/resource-admission-scope.js.map +1 -1
  179. package/dist/core/resume/blueprint/process.d.ts +3 -4
  180. package/dist/core/resume/blueprint/process.d.ts.map +1 -1
  181. package/dist/core/resume/blueprint/process.js +33 -17
  182. package/dist/core/resume/blueprint/process.js.map +1 -1
  183. package/dist/core/resume/path-mapping.js +4 -4
  184. package/dist/core/resume/path-mapping.js.map +1 -1
  185. package/dist/core/resume/session-resume.d.ts +9 -0
  186. package/dist/core/resume/session-resume.d.ts.map +1 -1
  187. package/dist/core/resume/session-resume.js +27 -2
  188. package/dist/core/resume/session-resume.js.map +1 -1
  189. package/dist/core/resume-cache-checkpoint.d.ts +27 -1
  190. package/dist/core/resume-cache-checkpoint.d.ts.map +1 -1
  191. package/dist/core/resume-cache-checkpoint.js +45 -0
  192. package/dist/core/resume-cache-checkpoint.js.map +1 -1
  193. package/dist/core/sdk.d.ts.map +1 -1
  194. package/dist/core/sdk.js +7 -31
  195. package/dist/core/sdk.js.map +1 -1
  196. package/dist/core/session-lifecycle-scope.d.ts +1 -2
  197. package/dist/core/session-lifecycle-scope.d.ts.map +1 -1
  198. package/dist/core/session-lifecycle-scope.js +2 -2
  199. package/dist/core/session-lifecycle-scope.js.map +1 -1
  200. package/dist/core/session-lifecycle-work.js +2 -2
  201. package/dist/core/session-lifecycle-work.js.map +1 -1
  202. package/dist/core/session-manager-core.d.ts.map +1 -1
  203. package/dist/core/session-manager-core.js +3 -0
  204. package/dist/core/session-manager-core.js.map +1 -1
  205. package/dist/core/session-storage.d.ts +12 -0
  206. package/dist/core/session-storage.d.ts.map +1 -1
  207. package/dist/core/session-storage.js +68 -1
  208. package/dist/core/session-storage.js.map +1 -1
  209. package/dist/core/settings-lock-directory.d.ts.map +1 -1
  210. package/dist/core/settings-lock-directory.js +4 -3
  211. package/dist/core/settings-lock-directory.js.map +1 -1
  212. package/dist/core/settings-write-ownership.d.ts +1 -2
  213. package/dist/core/settings-write-ownership.d.ts.map +1 -1
  214. package/dist/core/settings-write-ownership.js +2 -2
  215. package/dist/core/settings-write-ownership.js.map +1 -1
  216. package/dist/core/storage/node-sqlite-thread.d.ts.map +1 -1
  217. package/dist/core/storage/node-sqlite-thread.js +6 -4
  218. package/dist/core/storage/node-sqlite-thread.js.map +1 -1
  219. package/dist/core/storage/node-sqlite.d.ts.map +1 -1
  220. package/dist/core/storage/node-sqlite.js +22 -8
  221. package/dist/core/storage/node-sqlite.js.map +1 -1
  222. package/dist/core/system-prompt.d.ts +16 -2
  223. package/dist/core/system-prompt.d.ts.map +1 -1
  224. package/dist/core/system-prompt.js +33 -6
  225. package/dist/core/system-prompt.js.map +1 -1
  226. package/dist/core/tasks/agent-adapter.d.ts.map +1 -1
  227. package/dist/core/tasks/agent-adapter.js +2 -1
  228. package/dist/core/tasks/agent-adapter.js.map +1 -1
  229. package/dist/core/tasks/completion.d.ts +3 -2
  230. package/dist/core/tasks/completion.d.ts.map +1 -1
  231. package/dist/core/tasks/completion.js.map +1 -1
  232. package/dist/core/tasks/execution-scope.js +2 -2
  233. package/dist/core/tasks/execution-scope.js.map +1 -1
  234. package/dist/core/tools/bash.d.ts.map +1 -1
  235. package/dist/core/tools/bash.js +2 -1
  236. package/dist/core/tools/bash.js.map +1 -1
  237. package/dist/core/tools/history-regex-worker.d.ts.map +1 -1
  238. package/dist/core/tools/history-regex-worker.js +3 -2
  239. package/dist/core/tools/history-regex-worker.js.map +1 -1
  240. package/dist/core/tools/shell-task-render.d.ts +3 -2
  241. package/dist/core/tools/shell-task-render.d.ts.map +1 -1
  242. package/dist/core/tools/shell-task-render.js +7 -5
  243. package/dist/core/tools/shell-task-render.js.map +1 -1
  244. package/dist/core/tools/shell-task-status.d.ts +6 -2
  245. package/dist/core/tools/shell-task-status.d.ts.map +1 -1
  246. package/dist/core/tools/shell-task-status.js +13 -8
  247. package/dist/core/tools/shell-task-status.js.map +1 -1
  248. package/dist/core/tools/sqlite-selector-connection.d.ts.map +1 -1
  249. package/dist/core/tools/sqlite-selector-connection.js +4 -3
  250. package/dist/core/tools/sqlite-selector-connection.js.map +1 -1
  251. package/dist/core/tools/windows-directory-security.d.ts.map +1 -1
  252. package/dist/core/tools/windows-directory-security.js +2 -1
  253. package/dist/core/tools/windows-directory-security.js.map +1 -1
  254. package/dist/core/worktree-snapshot/git.js +2 -2
  255. package/dist/core/worktree-snapshot/git.js.map +1 -1
  256. package/dist/extensions/mcp/index.d.ts +6 -1
  257. package/dist/extensions/mcp/index.d.ts.map +1 -1
  258. package/dist/extensions/mcp/index.js +150 -18
  259. package/dist/extensions/mcp/index.js.map +1 -1
  260. package/dist/extensions/mcp/tool-records.d.ts +44 -9
  261. package/dist/extensions/mcp/tool-records.d.ts.map +1 -1
  262. package/dist/extensions/mcp/tool-records.js +58 -16
  263. package/dist/extensions/mcp/tool-records.js.map +1 -1
  264. package/dist/index.d.ts +2 -0
  265. package/dist/index.d.ts.map +1 -1
  266. package/dist/index.js +4 -0
  267. package/dist/index.js.map +1 -1
  268. package/dist/main-session.d.ts +3 -1
  269. package/dist/main-session.d.ts.map +1 -1
  270. package/dist/main-session.js +1 -0
  271. package/dist/main-session.js.map +1 -1
  272. package/dist/main.d.ts.map +1 -1
  273. package/dist/main.js +230 -96
  274. package/dist/main.js.map +1 -1
  275. package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts +5 -0
  276. package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts.map +1 -1
  277. package/dist/modes/interactive/agent-view/agent-view-bridge.js.map +1 -1
  278. package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts +5 -2
  279. package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts.map +1 -1
  280. package/dist/modes/interactive/agent-view/agent-view-switcher.js +3 -3
  281. package/dist/modes/interactive/agent-view/agent-view-switcher.js.map +1 -1
  282. package/dist/modes/interactive/agent-view/contracts.d.ts +6 -0
  283. package/dist/modes/interactive/agent-view/contracts.d.ts.map +1 -1
  284. package/dist/modes/interactive/agent-view/contracts.js.map +1 -1
  285. package/dist/modes/interactive/agent-view/install.d.ts.map +1 -1
  286. package/dist/modes/interactive/agent-view/install.js +2 -1
  287. package/dist/modes/interactive/agent-view/install.js.map +1 -1
  288. package/dist/modes/interactive/agent-view/open-port.d.ts +4 -2
  289. package/dist/modes/interactive/agent-view/open-port.d.ts.map +1 -1
  290. package/dist/modes/interactive/agent-view/open-port.js +4 -3
  291. package/dist/modes/interactive/agent-view/open-port.js.map +1 -1
  292. package/dist/modes/interactive/agent-view/prompt-retarget.d.ts.map +1 -1
  293. package/dist/modes/interactive/agent-view/prompt-retarget.js +18 -5
  294. package/dist/modes/interactive/agent-view/prompt-retarget.js.map +1 -1
  295. package/dist/modes/interactive/agent-view/remote-port.d.ts +10 -1
  296. package/dist/modes/interactive/agent-view/remote-port.d.ts.map +1 -1
  297. package/dist/modes/interactive/agent-view/remote-port.js +36 -4
  298. package/dist/modes/interactive/agent-view/remote-port.js.map +1 -1
  299. package/dist/modes/interactive/agent-view/viewed-keys.d.ts +56 -0
  300. package/dist/modes/interactive/agent-view/viewed-keys.d.ts.map +1 -0
  301. package/dist/modes/interactive/agent-view/viewed-keys.js +63 -0
  302. package/dist/modes/interactive/agent-view/viewed-keys.js.map +1 -0
  303. package/dist/modes/interactive/agent-view/viewed-submit.d.ts +14 -4
  304. package/dist/modes/interactive/agent-view/viewed-submit.d.ts.map +1 -1
  305. package/dist/modes/interactive/agent-view/viewed-submit.js +51 -17
  306. package/dist/modes/interactive/agent-view/viewed-submit.js.map +1 -1
  307. package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
  308. package/dist/modes/interactive/components/agent-panel.js +8 -21
  309. package/dist/modes/interactive/components/agent-panel.js.map +1 -1
  310. package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
  311. package/dist/modes/interactive/components/chat-session-host-actions.js +18 -5
  312. package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
  313. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
  314. package/dist/modes/interactive/components/chat-session-host-rendering.js +6 -0
  315. package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
  316. package/dist/modes/interactive/components/chat-session-host-state.d.ts +1 -0
  317. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  318. package/dist/modes/interactive/components/chat-session-host-state.js +2 -0
  319. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  320. package/dist/modes/interactive/components/chat-session-host-types.d.ts +5 -0
  321. package/dist/modes/interactive/components/chat-session-host-types.d.ts.map +1 -1
  322. package/dist/modes/interactive/components/chat-session-host-types.js.map +1 -1
  323. package/dist/modes/interactive/components/custom-editor.d.ts +33 -2
  324. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  325. package/dist/modes/interactive/components/custom-editor.js +58 -2
  326. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  327. package/dist/modes/interactive/components/host-session-picker.js +2 -2
  328. package/dist/modes/interactive/components/host-session-picker.js.map +1 -1
  329. package/dist/modes/interactive/components/main-composer-keys.d.ts +16 -5
  330. package/dist/modes/interactive/components/main-composer-keys.d.ts.map +1 -1
  331. package/dist/modes/interactive/components/main-composer-keys.js +27 -8
  332. package/dist/modes/interactive/components/main-composer-keys.js.map +1 -1
  333. package/dist/modes/interactive/components/notice-line.d.ts +8 -25
  334. package/dist/modes/interactive/components/notice-line.d.ts.map +1 -1
  335. package/dist/modes/interactive/components/notice-line.js +18 -17
  336. package/dist/modes/interactive/components/notice-line.js.map +1 -1
  337. package/dist/modes/interactive/components/prompt-slot.d.ts +20 -3
  338. package/dist/modes/interactive/components/prompt-slot.d.ts.map +1 -1
  339. package/dist/modes/interactive/components/prompt-slot.js +82 -32
  340. package/dist/modes/interactive/components/prompt-slot.js.map +1 -1
  341. package/dist/modes/interactive/components/queued-messages-view.d.ts +5 -2
  342. package/dist/modes/interactive/components/queued-messages-view.d.ts.map +1 -1
  343. package/dist/modes/interactive/components/queued-messages-view.js +12 -5
  344. package/dist/modes/interactive/components/queued-messages-view.js.map +1 -1
  345. package/dist/modes/interactive/components/task-board.d.ts +5 -8
  346. package/dist/modes/interactive/components/task-board.d.ts.map +1 -1
  347. package/dist/modes/interactive/components/task-board.js +5 -49
  348. package/dist/modes/interactive/components/task-board.js.map +1 -1
  349. package/dist/modes/interactive/components/task-completion-message.d.ts.map +1 -1
  350. package/dist/modes/interactive/components/task-completion-message.js +9 -2
  351. package/dist/modes/interactive/components/task-completion-message.js.map +1 -1
  352. package/dist/modes/interactive/components/task-marks.d.ts +19 -0
  353. package/dist/modes/interactive/components/task-marks.d.ts.map +1 -0
  354. package/dist/modes/interactive/components/task-marks.js +25 -0
  355. package/dist/modes/interactive/components/task-marks.js.map +1 -0
  356. package/dist/modes/interactive/components/task-row.d.ts +10 -2
  357. package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
  358. package/dist/modes/interactive/components/task-row.js +39 -32
  359. package/dist/modes/interactive/components/task-row.js.map +1 -1
  360. package/dist/modes/interactive/components/task-transcript-page.d.ts +7 -0
  361. package/dist/modes/interactive/components/task-transcript-page.d.ts.map +1 -1
  362. package/dist/modes/interactive/components/task-transcript-page.js +106 -10
  363. package/dist/modes/interactive/components/task-transcript-page.js.map +1 -1
  364. package/dist/modes/interactive/components/tool-block-families.d.ts.map +1 -1
  365. package/dist/modes/interactive/components/tool-block-families.js +8 -9
  366. package/dist/modes/interactive/components/tool-block-families.js.map +1 -1
  367. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  368. package/dist/modes/interactive/components/tool-execution.js +5 -1
  369. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  370. package/dist/modes/interactive/extension-command-hold.d.ts.map +1 -1
  371. package/dist/modes/interactive/extension-command-hold.js +5 -7
  372. package/dist/modes/interactive/extension-command-hold.js.map +1 -1
  373. package/dist/modes/interactive/interactive-extension-dialogs.js +6 -1
  374. package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
  375. package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -1
  376. package/dist/modes/interactive/interactive-extension-runtime.js +21 -7
  377. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  378. package/dist/modes/interactive/interactive-initial-session-binding.d.ts +1 -2
  379. package/dist/modes/interactive/interactive-initial-session-binding.d.ts.map +1 -1
  380. package/dist/modes/interactive/interactive-initial-session-binding.js +2 -2
  381. package/dist/modes/interactive/interactive-initial-session-binding.js.map +1 -1
  382. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  383. package/dist/modes/interactive/interactive-input-handling.js +13 -4
  384. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  385. package/dist/modes/interactive/interactive-mode-base.d.ts +2 -1
  386. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  387. package/dist/modes/interactive/interactive-mode-base.js +6 -1
  388. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  389. package/dist/modes/interactive/interactive-mode-helpers.d.ts +4 -2
  390. package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
  391. package/dist/modes/interactive/interactive-mode-helpers.js +6 -0
  392. package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
  393. package/dist/modes/interactive/interactive-mode-surface.d.ts +5 -0
  394. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  395. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  396. package/dist/modes/interactive/interactive-process-lifecycle.js +96 -17
  397. package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
  398. package/dist/modes/interactive/interactive-queueing.d.ts +5 -0
  399. package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
  400. package/dist/modes/interactive/interactive-queueing.js +37 -5
  401. package/dist/modes/interactive/interactive-queueing.js.map +1 -1
  402. package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
  403. package/dist/modes/interactive/interactive-render-chat.js +45 -4
  404. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  405. package/dist/modes/interactive/interactive-resource-disclosure.d.ts +4 -1
  406. package/dist/modes/interactive/interactive-resource-disclosure.d.ts.map +1 -1
  407. package/dist/modes/interactive/interactive-resource-disclosure.js +20 -1
  408. package/dist/modes/interactive/interactive-resource-disclosure.js.map +1 -1
  409. package/dist/modes/interactive/interactive-resource-rendering.js +3 -0
  410. package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
  411. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  412. package/dist/modes/interactive/interactive-startup.js +43 -5
  413. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  414. package/dist/modes/interactive-engine/activity-watchdog.d.ts +6 -3
  415. package/dist/modes/interactive-engine/activity-watchdog.d.ts.map +1 -1
  416. package/dist/modes/interactive-engine/activity-watchdog.js +3 -2
  417. package/dist/modes/interactive-engine/activity-watchdog.js.map +1 -1
  418. package/dist/modes/interactive-engine/engine-health.d.ts +2 -0
  419. package/dist/modes/interactive-engine/engine-health.d.ts.map +1 -1
  420. package/dist/modes/interactive-engine/engine-health.js.map +1 -1
  421. package/dist/modes/interactive-engine/engine-quit-intent.d.ts +10 -0
  422. package/dist/modes/interactive-engine/engine-quit-intent.d.ts.map +1 -1
  423. package/dist/modes/interactive-engine/engine-quit-intent.js +33 -0
  424. package/dist/modes/interactive-engine/engine-quit-intent.js.map +1 -1
  425. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +7 -1
  426. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
  427. package/dist/modes/interactive-engine/extension-ui-bridge.js +15 -2
  428. package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
  429. package/dist/modes/interactive-engine/host-listener-failures.d.ts +24 -0
  430. package/dist/modes/interactive-engine/host-listener-failures.d.ts.map +1 -0
  431. package/dist/modes/interactive-engine/host-listener-failures.js +98 -0
  432. package/dist/modes/interactive-engine/host-listener-failures.js.map +1 -0
  433. package/dist/modes/interactive-engine/isolated-runtime.d.ts +16 -0
  434. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  435. package/dist/modes/interactive-engine/isolated-runtime.js +74 -7
  436. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  437. package/dist/modes/interactive-engine/protocol.d.ts +5 -0
  438. package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
  439. package/dist/modes/interactive-engine/protocol.js +8 -2
  440. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  441. package/dist/modes/interactive-engine/remote-component.d.ts +13 -0
  442. package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
  443. package/dist/modes/interactive-engine/remote-component.js +69 -4
  444. package/dist/modes/interactive-engine/remote-component.js.map +1 -1
  445. package/dist/modes/print-mode.d.ts.map +1 -1
  446. package/dist/modes/print-mode.js +34 -6
  447. package/dist/modes/print-mode.js.map +1 -1
  448. package/dist/modes/rpc/agent-panel-bridge.d.ts +7 -0
  449. package/dist/modes/rpc/agent-panel-bridge.d.ts.map +1 -1
  450. package/dist/modes/rpc/agent-panel-bridge.js +11 -1
  451. package/dist/modes/rpc/agent-panel-bridge.js.map +1 -1
  452. package/dist/modes/rpc/agent-view-rpc-panel.d.ts.map +1 -1
  453. package/dist/modes/rpc/agent-view-rpc-panel.js +11 -5
  454. package/dist/modes/rpc/agent-view-rpc-panel.js.map +1 -1
  455. package/dist/modes/rpc/rpc-client-process.d.ts +8 -1
  456. package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
  457. package/dist/modes/rpc/rpc-client-process.js +89 -65
  458. package/dist/modes/rpc/rpc-client-process.js.map +1 -1
  459. package/dist/modes/rpc/rpc-client.d.ts +21 -0
  460. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  461. package/dist/modes/rpc/rpc-client.js +77 -33
  462. package/dist/modes/rpc/rpc-client.js.map +1 -1
  463. package/dist/modes/rpc/rpc-event-buffer.d.ts +5 -0
  464. package/dist/modes/rpc/rpc-event-buffer.d.ts.map +1 -1
  465. package/dist/modes/rpc/rpc-event-buffer.js +8 -2
  466. package/dist/modes/rpc/rpc-event-buffer.js.map +1 -1
  467. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  468. package/dist/modes/rpc/rpc-mode.js +9 -2
  469. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  470. package/dist/utils/shell.d.ts +5 -1
  471. package/dist/utils/shell.d.ts.map +1 -1
  472. package/dist/utils/shell.js +14 -7
  473. package/dist/utils/shell.js.map +1 -1
  474. package/dist/utils/worker-threads.d.ts +10 -4
  475. package/dist/utils/worker-threads.d.ts.map +1 -1
  476. package/dist/utils/worker-threads.js +10 -4
  477. package/dist/utils/worker-threads.js.map +1 -1
  478. package/docs/background-tasks.md +10 -10
  479. package/docs/compaction.md +1 -0
  480. package/docs/development.md +1 -1
  481. package/docs/environment-variables.md +4 -0
  482. package/docs/extensions/api-reference.md +2 -0
  483. package/docs/extensions/events.md +1 -1
  484. package/docs/getting-started/installation.md +1 -0
  485. package/docs/guides/non-interactive.md +2 -0
  486. package/docs/guides/resume-on-any-machine.md +3 -1
  487. package/docs/intercom/reference.md +1 -1
  488. package/docs/keybindings.md +6 -5
  489. package/docs/libraries/ai.md +2 -1
  490. package/docs/mcp-servers.md +1 -1
  491. package/docs/sdk/reference.md +1 -1
  492. package/docs/sdk.md +6 -0
  493. package/docs/security.md +4 -2
  494. package/docs/settings.md +2 -1
  495. package/docs/storage.md +2 -0
  496. package/docs/subagents.md +2 -2
  497. package/docs/tui/reference.md +3 -1
  498. package/npm-shrinkwrap.json +49 -49
  499. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"session-resume.js","sourceRoot":"","sources":["../../../src/core/resume/session-resume.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAA4B,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AAElF,OAAO,EACN,wBAAwB,EACxB,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EAEpB,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,4BAA4B,EAC5B,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,GACrB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvF,OAAO,EACN,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,GACxB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EACN,+BAA+B,EAC/B,oBAAoB,EACpB,gBAAgB,EAEhB,gBAAgB,GAChB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AACzE,OAAO,EACN,+BAA+B,EAC/B,kBAAkB,EAElB,cAAc,GACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,uB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AI,QAAQ,CAAC,sBAAsB,EAAE,KAAK,QAAQ,CAAC;AACpH,CAAC;AAED,6GAA6G;AAC7G,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC9C,OAAO,IAAI,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,eAAe,CAAC,OAAsD;IAC9E,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,IAAI,+BAA+B,EAAE,CAAC,CAAC;AACvE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CACnC,UAA4B,EAC5B,SAAiB,EACjB,QAAgB,EAChB,eAGC,EACD,OAAyD,EACzD,WAAW,GAAG,IAAI;IAElB,OAAO;QACN,UAAU;QACV,SAAS;QACT,QAAQ,EAAE,eAAe,CAAC,2BAA2B,EAAE;QACvD,IAAI,EAAE,eAAe,CAAC,uBAAuB,EAAE;QAC/C,SAAS,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,CAAC,qBAAqB,EAAE,EAAE,OAAO,EAAE;QACvF,QAAQ,EAAE,cAAc,CAAC,QAAQ,CAAC;QAClC,gBAAgB,EAAE,eAAe,CAAC,yBAAyB,CAAC,WAAW,CAAC;KACxE,CAAC;AACH,CAAC","sourcesContent":["import { stat } from \"node:fs/promises\";\nimport { join, relative, resolve } from \"node:path\";\nimport { type GitUnavailableError, isGitUnavailableError } from \"../../utils/git-errors.ts\";\nimport { failureDebugFields, reportDebugAsync as reportDebug } from \"../debug.ts\";\nimport type { SessionManager } from \"../session-manager.ts\";\nimport {\n\tcurrentWorktreeSnapshots,\n\tformatLapsedPinNotice,\n\tformatMissingRecordNotice,\n\tholdSessionWorktrees,\n\tlapsedDegradedRestores,\n\tlatestRestoreTargets,\n\ttype MissingSnapshotRecord,\n\tmapRestoredPath,\n\tmapRestoredPathAsync,\n\tmissingSnapshotRecords,\n\topenResumedSession,\n\tpooledWorktreeOwnedElsewhere,\n\trecordPendingCarriedWork,\n\treleaseSessionWorktrees,\n\tresumeSessionWorktree,\n} from \"../session-worktree-snapshots.ts\";\nimport type { SettingsManager } from \"../settings-manager.ts\";\nimport { recordTimingLines } from \"../timings.ts\";\nimport { pathExists } from \"../tools/path-utils.ts\";\nimport { ProjectTrustStore } from \"../trust-manager.ts\";\nimport { locateCheckout, readRepositoryConfig } from \"../worktree-snapshot/capture.ts\";\nimport {\n\tisWorkspaceConfigError,\n\tisWorkspaceDriftError,\n\tisWorkspaceSnapshotError,\n} from \"../worktree-snapshot/errors.ts\";\nimport { gitText, runGit } from \"../worktree-snapshot/git.ts\";\nimport { isHeadOnlyAdvance } from \"../worktree-snapshot/head-advance.ts\";\nimport {\n\tDEFAULT_MAX_IDLE_PER_REPOSITORY,\n\tpooledWorktreeHolder,\n\tsetAsideWorktree,\n\ttype WorktreePoolSettings,\n\tworktreeSetAside,\n} from \"../worktree-snapshot/pool.ts\";\nimport { sameRemote } from \"../worktree-snapshot/repository-identity.ts\";\nimport {\n\tdefaultWorktreeSnapshotStoreDir,\n\tpendingLfsDownload,\n\ttype VerifyWorktreeOptions,\n\tverifyWorktree,\n} from \"../worktree-snapshot/restore.ts\";\nimport { holdsSessionSnapshotRef } from \"../worktree-snapshot/session-refs.ts\";\nimport type {\n\tWorktreeRootMapping,\n\tWorktreeSnapshot,\n\tWorktreeSnapshotSettings,\n\tWorktreeUnrestored,\n} from \"../worktree-snapshot/types.ts\";\nimport {\n\tannounceBlueprintBuildWaiting,\n\ttype BlueprintBuildResult,\n\tblueprintBuildShared,\n\thandOverBuildTimings,\n\tholdToolsUntilBuilt,\n} from \"./blueprint/barrier.ts\";\nimport type { BlueprintBuildConfig } from \"./blueprint/build.ts\";\nimport { type CancelledBuild, cancelledBuilds, settleOtherBuilds, withBuildLocks } from \"./blueprint/build-lock.ts\";\nimport {\n\tBLUEPRINT_BUILDING_CONTEXT,\n\ttype BlueprintCheckout,\n\tblueprintBuildReport,\n\tcheckoutsNeedingRebuild,\n\tenclosingRepositoryRoot,\n\tinheritedRemotes,\n\ttype ResumedBlueprints,\n\trecordBlueprintContext,\n\tsetUpResumedBlueprints,\n} from \"./blueprint/resume.ts\";\nimport { isResumePreconditionError, type ResumeEntryPoint } from \"./errors.ts\";\nimport { isResumeFailure } from \"./failure.ts\";\nimport { LfsDownloads } from \"./lfs-downloads.ts\";\nimport { isInside } from \"./path-mapping.ts\";\nimport { defaultResumePreflightIo, type ResumePreflightIo } from \"./preflight.ts\";\nimport { formatResumeTimings, type ResumeTimings, ResumeTimingsRecorder, recordResumeTimings } from \"./timings.ts\";\n\n/** What to do when the checkout a resume was started in belongs to the session's repository but differs from it. */\nexport type DirtyCheckoutChoice = \"restore\" | \"use\" | \"cancel\";\n\nexport interface DirtyCheckoutPrompt {\n\t/** Root of the user's checkout the resume was started in. */\n\treadonly checkout: string;\n\t/** Root the session recorded, on the node that recorded it. */\n\treadonly recordedRoot: string;\n\treadonly snapshotId: string;\n}\n\nexport interface ResumeNotice {\n\treadonly type: \"info\" | \"warning\";\n\treadonly message: string;\n}\n\n/** A fork into a different store does not publish an address or credentials for its source. */\nexport function parentHistoryNotices(manager: Pick<SessionManager, \"getHeader\">): ResumeNotice[] {\n\treturn manager.getHeader()?.parentInOtherStore\n\t\t? [{ type: \"info\", message: \"Parent history is in its original store or is no longer available.\" }]\n\t\t: [];\n}\n\nexport interface PrepareSessionResumeOptions {\n\treadonly entryPoint: ResumeEntryPoint;\n\t/** Where the resume was started: the requested target when it is a checkout of the session's repository. */\n\treadonly launchCwd: string;\n\treadonly settings: WorktreeSnapshotSettings;\n\t/** How the blueprints of worktrees this resume restores are built; the store directory is `storeDir`. */\n\treadonly blueprint: Omit<BlueprintBuildConfig, \"storeDir\">;\n\t/** Host directory for restored worktrees. Default ~/.atomic/agent/worktree-snapshots. */\n\treadonly storeDir?: string;\n\t/** Asks the user about a dirty checkout. Without it a fresh worktree is restored, which overwrites nothing. */\n\treadonly chooseDirtyCheckout?: (prompt: DirtyCheckoutPrompt) => Promise<DirtyCheckoutChoice>;\n\treadonly io?: ResumePreflightIo;\n\t/** Session directory to reopen a moved session in, for stores that keep sessions per directory. */\n\treadonly sessionDirectory?: string;\n\treadonly signal?: AbortSignal;\n\t/**\n\t * Checkouts the session continues in as they are, by the root its recorded restores put them at: never verified and\n\t * never restored, as for checkouts it worked in on this node and changed since.\n\t */\n\treadonly keepInPlace?: ReadonlySet<string>;\n\t/**\n\t * `\"skip\"` restores checkouts but builds and describes no blueprint and records no blueprint context: for a process\n\t * that serves a resume another process of the same user-level action already prepared and built, so one resume\n\t * builds once. Default `\"build\"`.\n\t */\n\treadonly blueprints?: \"build\" | \"skip\";\n\t/**\n\t * Told the warnings of the blueprint builds a resume ran when its caller gets only a session back, as when a\n\t * released session is woken ({@link continueSessionWhereItWorked}).\n\t */\n\treadonly onNotices?: (notices: readonly ResumeNotice[]) => void;\n\t/** Told each slow step the resume starts (checking checkouts, restoring one, building blueprints), for a progress line. */\n\treadonly onProgress?: (message: string) => void;\n\t/**\n\t * The worktree pool (#4748): restores go to stable slots that the session holds while it is open, keeping at most\n\t * `maxIdlePerRepository` idle slots per repository. Default: `snapshots.pool` defaults.\n\t */\n\treadonly pool?: WorktreePoolSettings;\n\t/**\n\t * `\"prompt\"` (default): the resume returns once the blueprints of the worktrees it restored are built. `\"tools\"`: it\n\t * returns once they are restored and the build goes on behind the session's first turn; every tool call of the\n\t * session waits for it (`awaitBlueprintReady`), and the first of them reports how it went. The build's warnings then\n\t * reach the agent and the user with that tool's result, not `notices`.\n\t */\n\treadonly waitForBlueprint?: \"prompt\" | \"tools\";\n}\n\nexport type PreparedSessionResume =\n\t| { readonly status: \"cancelled\" }\n\t| {\n\t\t\treadonly status: \"ready\";\n\t\t\t/** The session opened where it continues: the one passed in when its cwd did not change. */\n\t\t\treadonly sessionManager: SessionManager;\n\t\t\treadonly notices: readonly ResumeNotice[];\n\t\t\t/** The warnings of the blueprint builds this resume ran, also in `notices`. */\n\t\t\treadonly blueprintNotices: readonly ResumeNotice[];\n\t\t\t/**\n\t\t\t * The notices of checkouts whose snapshot record the session does not hold, also in `notices` (#4744). The\n\t\t\t * session records nothing for them, so a caller that shows the notices its entries carry shows these too.\n\t\t\t */\n\t\t\treadonly missingRecordNotices?: readonly ResumeNotice[];\n\t\t\t/** The blueprint context the session's next turn carries, already recorded in it; undefined when none. */\n\t\t\treadonly blueprintContext: string | undefined;\n\t };\n\nasync function isDirectory(path: string): Promise<boolean> {\n\ttry {\n\t\treturn (await stat(path)).isDirectory();\n\t} catch (error) {\n\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\tif (code === \"ENOENT\" || code === \"ENOTDIR\") return false;\n\t\tthrow error;\n\t}\n}\n\nexport interface SessionSnapshotMatch {\n\treadonly root: string;\n\treadonly snapshot: WorktreeSnapshot;\n\t/** The session cwd after the session's recorded restores. */\n\treadonly cwd: string;\n}\n\nfunction matchSessionSnapshot(\n\tcwd: string,\n\tsnapshots: ReadonlyMap<string, WorktreeSnapshot>,\n): SessionSnapshotMatch | undefined {\n\tlet match: SessionSnapshotMatch | undefined;\n\tfor (const [root, snapshot] of snapshots) {\n\t\tif (isInside(root, cwd) && (!match || root.length > match.root.length)) match = { root, snapshot, cwd };\n\t}\n\treturn match;\n}\n\n/** The latest snapshot of the checkout the session works in, the same one #4245's resume verifies. */\nexport function latestSessionSnapshot(\n\tsessionManager: Pick<SessionManager, \"getCwd\" | \"getWorktreeRootMappings\" | \"getLatestWorktreeSnapshots\">,\n\tsnapshots: ReadonlyMap<string, WorktreeSnapshot> = sessionManager.getLatestWorktreeSnapshots(),\n): SessionSnapshotMatch | undefined {\n\tconst cwd = mapRestoredPath(sessionManager.getCwd(), sessionManager.getWorktreeRootMappings());\n\treturn matchSessionSnapshot(cwd, snapshots);\n}\n\nexport async function latestSessionSnapshotAsync(\n\tsessionManager: Pick<SessionManager, \"getCwd\" | \"getWorktreeRootMappings\" | \"getLatestWorktreeSnapshots\">,\n\tsnapshots: ReadonlyMap<string, WorktreeSnapshot> = sessionManager.getLatestWorktreeSnapshots(),\n): Promise<SessionSnapshotMatch | undefined> {\n\tconst cwd = await mapRestoredPathAsync(sessionManager.getCwd(), sessionManager.getWorktreeRootMappings());\n\treturn matchSessionSnapshot(cwd, snapshots);\n}\n\n/** Continue in the launch checkout, or stop because the user cancelled; undefined restores a fresh worktree. */\ntype CheckoutReuse =\n\t| {\n\t\t\treadonly kind: \"reused\";\n\t\t\treadonly cwd: string;\n\t\t\t/** Whether the checkout matched the snapshot, rather than being used as it is by the user's choice. */\n\t\t\treadonly matches: boolean;\n\t\t\treadonly notice: ResumeNotice;\n\t\t\t/** The recorded root mapped onto the checkout, recorded once nothing else stops the resume. */\n\t\t\treadonly mapping: WorktreeRootMapping;\n\t }\n\t| { readonly kind: \"cancelled\" }\n\t| undefined;\n\n/**\n * Continues in the checkout the resume started in when it is a checkout of the session's repository: as-is when its\n * tree matches the snapshot (or only its HEAD moved forward over it); when it differs and has local changes, only if\n * the user says so. A clean checkout that differs is left alone and a fresh worktree is restored instead. Returns the\n * mapping that makes paths follow, for the caller to record.\n */\nasync function reuseLaunchCheckout(\n\tmatch: SessionSnapshotMatch,\n\tsessionId: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<CheckoutReuse> {\n\tconst checkout = await locateCheckout(options.launchCwd, options.signal).catch((error: unknown) => {\n\t\tif (isWorkspaceSnapshotError(error)) return error;\n\t\tthrow error;\n\t});\n\tif (checkout instanceof Error) return undefined;\n\tconst root = resolve(checkout.root);\n\t// A pooled worktree another session owns holds that session's work, even when it matches (#4748).\n\tif (await pooledWorktreeOwnedElsewhere(resolveStoreDir(options), root, sessionId)) return undefined;\n\tconst { remotes } = await readRepositoryConfig(root, options.signal);\n\t// The same repository spelled another way, SSH or HTTPS, with or without `.git`, is still the session's (#4913).\n\tif (!remotes.some((remote) => match.snapshot.remotes.some((recorded) => sameRemote(remote, recorded)))) {\n\t\treturn undefined;\n\t}\n\tlet matches = true;\n\ttry {\n\t\tawait verifyWorktree(match.snapshot, root, { settings: options.settings, signal: options.signal });\n\t} catch (error) {\n\t\tif (!isWorkspaceDriftError(error)) throw error;\n\t\tmatches = await isHeadOnlyAdvance(error, options.signal);\n\t}\n\tif (!matches) {\n\t\tif (!(await hasLocalChanges(root, options.signal))) return undefined;\n\t\tconst choice = options.chooseDirtyCheckout\n\t\t\t? await options.chooseDirtyCheckout({\n\t\t\t\t\tcheckout: root,\n\t\t\t\t\trecordedRoot: match.root,\n\t\t\t\t\tsnapshotId: match.snapshot.id,\n\t\t\t\t})\n\t\t\t: \"restore\";\n\t\tif (choice === \"cancel\") return { kind: \"cancelled\" };\n\t\tif (choice === \"restore\") return undefined;\n\t}\n\tconst mapping: WorktreeRootMapping = {\n\t\tfrom: match.root,\n\t\tto: root,\n\t\tsnapshotId: match.snapshot.id,\n\t\ttree: match.snapshot.tree,\n\t\trestoredAt: new Date().toISOString(),\n\t};\n\treturn {\n\t\tkind: \"reused\",\n\t\tcwd: resolve(root, relative(match.root, match.cwd)),\n\t\tmatches,\n\t\tmapping,\n\t\tnotice: matches\n\t\t\t? {\n\t\t\t\t\ttype: \"info\",\n\t\t\t\t\tmessage: `Resuming in ${root}, which matches snapshot ${match.snapshot.id.slice(0, 12)} of ${match.root}`,\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tmessage: `Resuming in ${root}, which differs from snapshot ${match.snapshot.id.slice(0, 12)} of ${match.root}`,\n\t\t\t\t},\n\t};\n}\n\n/**\n * Moves a session that a resume restored into a worktree, and that has not worked in it since, back to the checkout it\n * was restored from, when that checkout is on this node and its repository holds the snapshot's commit (#4660), or the\n * session's snapshot ref for it (#4923). The\n * session continues there as the checkout is now, even when it changed since the snapshot. Undefined keeps the session\n * in its worktree: the worktree is not one Atomic restored, it changed or recorded another snapshot since, or the\n * checkout it came from is gone or is another clone.\n */\nasync function returnToStartingCheckout(\n\tsessionManager: SessionManager,\n\tmatch: SessionSnapshotMatch,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<Extract<CheckoutReuse, { kind: \"reused\" }> | undefined> {\n\tif (!isInside(storeDir, match.root)) return undefined;\n\tconst restore = [...sessionManager.getWorktreeRootMappings()]\n\t\t.reverse()\n\t\t.find((mapping) => resolve(mapping.to) === resolve(match.root));\n\tif (restore === undefined || restore.snapshotId !== match.snapshot.id) return undefined;\n\tconst checkout = resolve(restore.from);\n\tconst cwd = resolve(checkout, relative(match.root, match.cwd));\n\tif (isInside(storeDir, checkout) || !(await pathExists(cwd))) return undefined;\n\t// When the checkout cannot be examined, the project the session started in is still where it goes back to.\n\tconst examined = await orFallBack(options, \"return-to-checkout-verify\", undefined, async () => ({\n\t\tholdsCommit: await workedInCheckout(match.snapshot, checkout, sessionManager.getSessionId(), options.signal),\n\t\tmatches: !(await worktreeNeedsRestore(match.snapshot, checkout, options)),\n\t}));\n\tif (examined !== undefined && !examined.holdsCommit) return undefined;\n\tconst matches = examined?.matches;\n\tconst snapshotId = match.snapshot.id.slice(0, 12);\n\treturn {\n\t\tkind: \"reused\",\n\t\tcwd,\n\t\tmatches: matches ?? false,\n\t\tmapping: {\n\t\t\tfrom: match.root,\n\t\t\tto: checkout,\n\t\t\tsnapshotId: match.snapshot.id,\n\t\t\ttree: match.snapshot.tree,\n\t\t\trestoredAt: new Date().toISOString(),\n\t\t},\n\t\tnotice: {\n\t\t\ttype: \"info\",\n\t\t\tmessage: `Resuming in ${checkout}, the checkout this session was restored from, instead of the worktree ${match.root}.${matches === undefined ? \"\" : matches ? ` It matches snapshot ${snapshotId}.` : ` It has changed since snapshot ${snapshotId}; that snapshot was not restored.`}`,\n\t\t},\n\t};\n}\n\n/**\n * Runs an optional improvement of where a resume continues. When it fails on a checkout, with a typed resume,\n * workspace or Git failure, the resume goes on with `fallback`, the behaviour it had without the improvement; the\n * reason goes to the debug log. A cancellation, and any failure that is not about a checkout, still end the resume.\n */\nasync function orFallBack<T>(\n\toptions: Pick<PrepareSessionResumeOptions, \"signal\">,\n\tstep: string,\n\tfallback: T,\n\tattempt: () => Promise<T>,\n): Promise<T> {\n\ttry {\n\t\treturn await attempt();\n\t} catch (error) {\n\t\tif (options.signal?.aborted || !isCheckoutFailure(error)) throw error;\n\t\treportDebug(\"storage\", \"resume-checkout-fallback\", { step, ...failureDebugFields(error) });\n\t\treturn fallback;\n\t}\n}\n\n/** Whether the checkout at `root` has uncommitted or untracked changes, which a resume must not overwrite unasked. */\nasync function hasLocalChanges(root: string, signal: AbortSignal | undefined): Promise<boolean> {\n\treturn (await gitText([\"status\", \"--porcelain\"], { cwd: root, signal })).length > 0;\n}\n\n/**\n * Gets a resumed session's checkouts ready on this node before its runtime starts, and returns the session opened\n * where it continues. When the checkout the session works in changed here but is still the one it worked in (its\n * repository holds the snapshot's commit, or Atomic restored it here), the session continues in it as it is, silently\n * (#4660). A session a resume moved into a restored worktree, and that has not worked in it since, returns to\n * the checkout it was restored from when that checkout is here. When the checkout the session works in is missing or\n * belongs to another clone here, a checkout of the same\n * repository the resume started in is used as-is if it matches (and, if it differs, only when the user chooses it).\n * Resume always opens the session (#4733): a checkout whose snapshot cannot be restored exactly gets the best state\n * this node can reach, its recorded commit with the change sets that apply or the closest commit it can fetch, and one\n * notice saying what is missing; when nothing of it can be restored, Git being unavailable included, the session\n * continues in its recorded directory, or the directory the resume started from when that is not here, with the same\n * kind of notice. Only a snapshot record that fails the security checks, or a restore target that holds other files,\n * refuses the resume. Every other checkout the session recorded that is gone or changed here, except\n * those in `keepInPlace`, never blocks the resume: one the session worked in on this node, changed since, continues as\n * it is; the rest are restored into fresh worktrees one by one by #4245's {@link resumeSessionWorktree}, and one that\n * cannot be (Git is unavailable, or its restore fails) is left out with a warning that names its path and why. Each\n * worktree Atomic restored then gets its blueprints built (#4588): a failing step is a warning in `notices` and never\n * stops the resume. The agent gets the blueprints' maintenance and knowledge in the session's next turn. The session's\n * tools resolve paths under every root it recorded into the place that root was restored. A resume that restored a\n * checkout or ran a blueprint step records where its time went in the session it returns (#4748); a failure to record\n * that never stops the resume.\n */\nexport async function prepareSessionResume(\n\tsessionManager: SessionManager,\n\toptions: PrepareSessionResumeOptions,\n): Promise<PreparedSessionResume> {\n\tconst storeDir = resolveStoreDir(options);\n\t// The session holds the pooled worktrees it owns before anything is restored, so evicting idle slots never removes\n\t// one it continues in, and until it closes (#4748).\n\tawait holdSessionWorktrees(sessionManager, sessionManager, storeDir, options.signal);\n\t// `atomic --session` counts from the launch of the process, which is 0 on the clock the recorder uses.\n\tconst timings = new ResumeTimingsRecorder(options.entryPoint === \"cli\" ? 0 : undefined);\n\tlet firstRecorded!: (recorded: ResumeTimings | undefined) => void;\n\tconst recordedAtReady = new Promise<ResumeTimings | undefined>((resolve) => {\n\t\tfirstRecorded = resolve;\n\t});\n\t// A build behind the first turn (`waitForBlueprint: \"tools\"`) adds its steps to the timings once it settles.\n\tconst buildSettled = async (session: SessionManager): Promise<void> => {\n\t\tconst atReady = await recordedAtReady;\n\t\tif (atReady === undefined) return;\n\t\t// The restores too: an LFS download behind the first turn ends after it (#5099).\n\t\tconst { restores, blueprint, blueprintReadyMs } = timings.finish();\n\t\tconst recorded = { ...atReady, restores, blueprint, blueprintReadyMs };\n\t\trecordTimingLines(formatResumeTimings(recorded), \"resume\");\n\t\t// The isolated engine has the session open by now, so it records them.\n\t\tif (blueprintBuildShared(session.getSessionId())) handOverBuildTimings(session.getSessionId(), recorded);\n\t\telse await recordResumeTimings(session, recorded);\n\t};\n\tlet prepared: PreparedSessionResume;\n\ttry {\n\t\toptions.signal?.throwIfAborted();\n\t\tprepared = await timings.run(() => prepareResume(sessionManager, options, buildSettled));\n\t} catch (error) {\n\t\tawait releaseSessionWorktrees(sessionManager);\n\t\tthrow error;\n\t}\n\tif (prepared.status === \"ready\") await holdSessionWorktrees(sessionManager, prepared.sessionManager, storeDir);\n\telse await releaseSessionWorktrees(sessionManager);\n\tif (prepared.status === \"ready\" && timings.recordedWork) {\n\t\tconst recorded = timings.finish();\n\t\tawait recordResumeTimings(prepared.sessionManager, recorded);\n\t\trecordTimingLines(formatResumeTimings(recorded), \"resume\");\n\t\tfirstRecorded(recorded);\n\t} else {\n\t\tfirstRecorded(undefined);\n\t}\n\treturn prepared;\n}\n\nasync function prepareResume(\n\tsessionManager: SessionManager,\n\toptions: PrepareSessionResumeOptions,\n\tbuildSettled: (session: SessionManager) => Promise<void>,\n): Promise<PreparedSessionResume> {\n\tconst io = options.io ?? defaultResumePreflightIo;\n\tconst storeDir = resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n\tif (!options.settings.enabled || sessionManager.getLatestWorktreeSnapshots().size === 0) {\n\t\tconst missing = options.settings.enabled ? await missingSnapshotRecords(sessionManager) : [];\n\t\tif (missing.length > 0) return continueWithoutRecords(sessionManager, missing, storeDir, options);\n\t\tconst unchanged = await describeBlueprintsInPlace(sessionManager, storeDir, options);\n\t\treturn { status: \"ready\", sessionManager, notices: [], blueprintNotices: [], blueprintContext: unchanged };\n\t}\n\t// Work a full restore carried over but could not record is recorded now, where its worktree is here (#5009).\n\tawait recordPendingCarriedWork(sessionManager, { settings: options.settings, storeDir, signal: options.signal });\n\t// A partial restore pinned for longer than its retention no longer holds its snapshot (#4922).\n\tconst notices: ResumeNotice[] = (await lapsedDegradedRestores(sessionManager)).map((lapsed) => ({\n\t\ttype: \"warning\",\n\t\tmessage: formatLapsedPinNotice(lapsed),\n\t}));\n\tnotices.push(...(await setAsideCancelledBuilds(sessionManager, storeDir, options)));\n\tconst checkoutCount = (await currentWorktreeSnapshots(sessionManager)).size;\n\toptions.onProgress?.(\n\t\t`Checking ${checkoutCount === 1 ? \"1 checkout\" : `${checkoutCount} checkouts`} against the session's snapshots`,\n\t);\n\tconst verified = new Map<string, Promise<boolean>>();\n\tconst verifyOnce = (snapshot: WorktreeSnapshot, root: string): Promise<boolean> => {\n\t\tconst key = `${snapshot.id}\\0${resolve(root)}`;\n\t\tlet verification = verified.get(key);\n\t\tif (verification === undefined) {\n\t\t\t// A pooled worktree another session owns is restored fresh, as if it were gone (#4748).\n\t\t\tverification = pooledWorktreeOwnedElsewhere(storeDir, root, sessionManager.getSessionId()).then(\n\t\t\t\t(elsewhere) => elsewhere || worktreeNeedsRestore(snapshot, root, options),\n\t\t\t);\n\t\t\tverified.set(key, verification);\n\t\t}\n\t\treturn verification;\n\t};\n\t// Which partly restored worktrees are still as the restore left them, compared once per resume.\n\tlet partialOnce: Promise<Set<string>> | undefined;\n\tconst partial = (): Promise<Set<string>> => {\n\t\tpartialOnce ??= partialRestores(sessionManager, options);\n\t\treturn partialOnce;\n\t};\n\t// A checkout restored only partly is compared with the snapshot it lacks, which stays its restore target (#4922).\n\tconst match = await latestSessionSnapshotAsync(sessionManager, await latestRestoreTargets(sessionManager));\n\tlet git: GitProbe | undefined;\n\tlet reused: WorktreeRootMapping | undefined;\n\tlet needsRestore: boolean;\n\ttry {\n\t\tneedsRestore =\n\t\t\tmatch !== undefined && !options.keepInPlace?.has(match.root) && (await verifyOnce(match.snapshot, match.root));\n\t} catch (error) {\n\t\tif (!isGitUnavailableError(error)) throw error;\n\t\treturn continueWithoutGit(sessionManager, error, storeDir, options);\n\t}\n\tconst project =\n\t\tmatch !== undefined && !needsRestore && !options.keepInPlace?.has(match.root)\n\t\t\t? await orFallBack(options, \"return-to-checkout\", undefined, () =>\n\t\t\t\t\treturnToStartingCheckout(sessionManager, match, storeDir, options),\n\t\t\t\t)\n\t\t\t: undefined;\n\tif (project !== undefined) {\n\t\tawait recordReuse(sessionManager, project.mapping);\n\t\tnotices.push(project.notice);\n\t}\n\tconst keepsOwnCheckout =\n\t\tmatch !== undefined &&\n\t\tproject === undefined &&\n\t\tneedsRestore &&\n\t\t(await isDirectory(match.root)) &&\n\t\t(await orFallBack(options, \"own-checkout\", new Set([match.root]), async () =>\n\t\t\tcheckoutsWorkedHere(\n\t\t\t\tnew Map([[match.root, match.snapshot]]),\n\t\t\t\tmatch.cwd,\n\t\t\t\tsessionManager.getSessionId(),\n\t\t\t\toptions,\n\t\t\t\tawait partial(),\n\t\t\t),\n\t\t).then((worked) => worked.has(match.root)));\n\t// The checkout the session returned to stays as it is, whatever it changed since: only the others are restored.\n\tconst kept = [...(keepsOwnCheckout && match !== undefined ? [match.root] : [])];\n\tif (project !== undefined && match !== undefined) kept.push(match.root, project.mapping.to);\n\tconst resume: PrepareSessionResumeOptions =\n\t\tkept.length > 0 ? { ...options, keepInPlace: new Set([...(options.keepInPlace ?? []), ...kept]) } : options;\n\tif (match !== undefined && !keepsOwnCheckout && needsRestore) {\n\t\tgit = { unavailable: await io.probeGit(options.signal) };\n\t\tconst reuse =\n\t\t\tgit.unavailable === undefined\n\t\t\t\t? await reuseLaunchCheckout(match, sessionManager.getSessionId(), options)\n\t\t\t\t: undefined;\n\t\tif (reuse?.kind === \"cancelled\") return { status: \"cancelled\" };\n\t\tif (reuse?.kind === \"reused\" && !reuse.matches) {\n\t\t\tawait recordReuse(sessionManager, reuse.mapping);\n\t\t\treturn continueInChosenCheckout(sessionManager, reuse, storeDir, options);\n\t\t}\n\t\tif (reuse?.kind === \"reused\") {\n\t\t\treused = reuse.mapping;\n\t\t\tnotices.push(reuse.notice);\n\t\t}\n\t}\n\tconst checkouts = withMapping(sessionManager, reused);\n\tconst candidates = await restoreCandidates(\n\t\tcheckouts,\n\t\tawait mapRestoredPathAsync(sessionManager.getCwd(), checkouts.getWorktreeRootMappings()),\n\t\tresume,\n\t\tverifyOnce,\n\t\tpartial,\n\t);\n\tif (candidates.targets.length > 0) git ??= { unavailable: await io.probeGit(options.signal) };\n\tconst plan = planRestores(candidates, git?.unavailable);\n\tnotices.push(...plan.left.values());\n\tconst recordedBefore = sessionManager.getWorktreeRootMappings().length;\n\t// Each fresh worktree's LFS download runs behind the other restores and the builds; its own build waits (#5099).\n\tconst lfs = new LfsDownloads();\n\tconst resumed = await restorePlanned(sessionManager, plan, reused, storeDir, resume, lfs);\n\tconst cwd =\n\t\tresumed.cwd ?? (await mapRestoredPathAsync(sessionManager.getCwd(), sessionManager.getWorktreeRootMappings()));\n\tconst opened = await openResumedSession(\n\t\tsessionManager,\n\t\tcwd,\n\t\tresumed.restored,\n\t\toptions.sessionDirectory,\n\t\tresumed.unrestored,\n\t);\n\tnotices.push(...opened.notices, ...resumed.failed);\n\tconst restoredNow = new Set(\n\t\topened.sessionManager\n\t\t\t.getWorktreeRootMappings()\n\t\t\t.slice(recordedBefore)\n\t\t\t.map((mapping) => resolve(mapping.to))\n\t\t\t.filter((root) => isInside(storeDir, root)),\n\t);\n\t// A resume that only joins a build this process already runs in its worktree, as a switch back to the session that\n\t// started it, waits for nothing: that build holds the session's tools, and tells the user when it ends (#4748).\n\tif (\n\t\trestoredNow.size === 0 &&\n\t\toptions.blueprints !== \"skip\" &&\n\t\toptions.waitForBlueprint === \"tools\" &&\n\t\t(await joinsBuildInProgress(opened.sessionManager))\n\t) {\n\t\tawait recordBlueprintContext(opened.sessionManager, BLUEPRINT_BUILDING_CONTEXT);\n\t\treturn {\n\t\t\tstatus: \"ready\",\n\t\t\tsessionManager: opened.sessionManager,\n\t\t\tnotices,\n\t\t\tblueprintNotices: [],\n\t\t\tmissingRecordNotices: resumed.missingNotices,\n\t\t\tblueprintContext: BLUEPRINT_BUILDING_CONTEXT,\n\t\t};\n\t}\n\tif (restoredNow.size > 0 && options.blueprints !== \"skip\" && options.waitForBlueprint === \"tools\") {\n\t\t// The build can be stopped when the process ends before it does (#4748): its steps' process trees end with it,\n\t\t// what ran is recorded, and the ledger keeps the worktrees unbuilt for the next resume.\n\t\tconst stopping = new AbortController();\n\t\tconst signal =\n\t\t\toptions.signal === undefined ? stopping.signal : AbortSignal.any([options.signal, stopping.signal]);\n\t\tconst building = setUpCheckoutBlueprints(\n\t\t\topened.sessionManager,\n\t\t\trestoredNow,\n\t\t\tstoreDir,\n\t\t\t{ ...options, signal },\n\t\t\tlfs,\n\t\t);\n\t\tconst result = building.then(\n\t\t\tasync (blueprints): Promise<BlueprintBuildResult> => {\n\t\t\t\tawait buildSettled(opened.sessionManager);\n\t\t\t\treturn { report: blueprintBuildReport(blueprints), notices: blueprints.notices };\n\t\t\t},\n\t\t\tasync (error: unknown): Promise<BlueprintBuildResult> => {\n\t\t\t\tawait buildSettled(opened.sessionManager).catch(() => undefined);\n\t\t\t\tconst message = `Blueprint build stopped before it finished (${error instanceof Error ? error.message : String(error)}); the next resume builds the restored worktree again.`;\n\t\t\t\treturn { report: message, notices: [{ type: \"warning\", message }] };\n\t\t\t},\n\t\t);\n\t\tholdToolsUntilBuilt(opened.sessionManager.getSessionId(), result, {\n\t\t\troots: restoredNow,\n\t\t\tstop: (reason) => stopping.abort(reason),\n\t\t});\n\t\tawait recordBlueprintContext(opened.sessionManager, BLUEPRINT_BUILDING_CONTEXT);\n\t\treturn {\n\t\t\tstatus: \"ready\",\n\t\t\tsessionManager: opened.sessionManager,\n\t\t\tnotices,\n\t\t\tblueprintNotices: [],\n\t\t\tmissingRecordNotices: resumed.missingNotices,\n\t\t\tblueprintContext: BLUEPRINT_BUILDING_CONTEXT,\n\t\t};\n\t}\n\tif (restoredNow.size > 0 && options.blueprints !== \"skip\") {\n\t\toptions.onProgress?.(\"Setting up the blueprints of restored worktrees\");\n\t}\n\tconst blueprints = await setUpCheckoutBlueprints(opened.sessionManager, restoredNow, storeDir, options, lfs);\n\tnotices.push(...blueprints.notices);\n\tawait recordBlueprintContext(opened.sessionManager, blueprints.context);\n\treturn {\n\t\tstatus: \"ready\",\n\t\tsessionManager: opened.sessionManager,\n\t\tnotices,\n\t\tblueprintNotices: blueprints.notices,\n\t\tmissingRecordNotices: resumed.missingNotices,\n\t\tblueprintContext: blueprints.context,\n\t};\n}\n\n/**\n * Opens a session whose checkouts cannot even be compared with their snapshots, because Git cannot run here (#4733):\n * it continues in its recorded directory as it is, or in the directory the resume started from when that is not\n * here, without restoring any checkout, and each is recorded as left out with a notice. Nothing is written to any\n * checkout.\n */\nasync function continueWithoutGit(\n\tsessionManager: SessionManager,\n\tgit: GitUnavailableError,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<PreparedSessionResume> {\n\tconst roots = [...(await currentWorktreeSnapshots(sessionManager)).keys()].filter(\n\t\t(root) => !options.keepInPlace?.has(root),\n\t);\n\tconst resumed = await resumeSessionWorktree(sessionManager, {\n\t\tsettings: options.settings,\n\t\tstoreDir,\n\t\tsignal: options.signal,\n\t\tkeepInPlace: options.keepInPlace,\n\t\tcannotRestore: new Map(roots.map((root) => [root, git])),\n\t\tfallbackCwd: options.launchCwd,\n\t\tskipMissingRecords: true,\n\t});\n\tconst cwd = resumed.status === \"none\" ? sessionManager.getCwd() : resumed.cwd;\n\tconst opened = await openResumedSession(\n\t\tsessionManager,\n\t\tcwd,\n\t\t[],\n\t\toptions.sessionDirectory,\n\t\tresumed.status === \"none\" ? [] : resumed.unrestored.map((checkout) => checkout.record),\n\t);\n\tconst context = await describeBlueprintsInPlace(opened.sessionManager, storeDir, options);\n\tconst missingRecordNotices = (resumed.missingRecords ?? []).map((missing) => ({\n\t\ttype: \"warning\" as const,\n\t\tmessage: formatMissingRecordNotice(missing),\n\t}));\n\treturn {\n\t\tstatus: \"ready\",\n\t\tsessionManager: opened.sessionManager,\n\t\tnotices: [...opened.notices, ...missingRecordNotices],\n\t\tblueprintNotices: [],\n\t\tmissingRecordNotices,\n\t\tblueprintContext: context,\n\t};\n}\n\n/**\n * Opens a session whose every recorded checkout refers to a snapshot the session holds no record of (#4733): nothing\n * can be restored, so it continues in its recorded directory, or the directory the resume started from when that is\n * not here, with one notice per checkout.\n */\nasync function continueWithoutRecords(\n\tsessionManager: SessionManager,\n\tmissing: readonly MissingSnapshotRecord[],\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<PreparedSessionResume> {\n\tconst recorded = await mapRestoredPathAsync(sessionManager.getCwd(), sessionManager.getWorktreeRootMappings());\n\tconst cwd = (await pathExists(recorded)) ? recorded : resolve(options.launchCwd);\n\tconst opened = await openResumedSession(sessionManager, cwd, [], options.sessionDirectory);\n\tconst context = await describeBlueprintsInPlace(opened.sessionManager, storeDir, options);\n\tconst notices = missing.map((record) => ({ type: \"warning\" as const, message: formatMissingRecordNotice(record) }));\n\treturn {\n\t\tstatus: \"ready\",\n\t\tsessionManager: opened.sessionManager,\n\t\tnotices,\n\t\tblueprintNotices: [],\n\t\tmissingRecordNotices: notices,\n\t\tblueprintContext: context,\n\t};\n}\n\nconst SKIPPED_BLUEPRINTS: ResumedBlueprints = { outcome: undefined, notices: [], layers: [], context: undefined };\n\n/**\n * The blueprint context of a session that has no worktree snapshots to restore: what its working directory's\n * repository and the global blueprint say, recorded in the session. No build runs and no Git command is started.\n */\nasync function describeBlueprintsInPlace(\n\tsessionManager: SessionManager,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<string | undefined> {\n\tif (options.blueprints === \"skip\") return undefined;\n\tconst root = await enclosingRepositoryRoot(resolve(sessionManager.getCwd()));\n\tconst blueprints = await setUpResumedBlueprints({\n\t\trestored: [],\n\t\tinPlace: root === undefined ? [] : [{ root, remotes: [] }],\n\t\tconfig: { ...options.blueprint, storeDir },\n\t\tsignal: options.signal,\n\t});\n\tawait recordBlueprintContext(sessionManager, blueprints.context);\n\treturn blueprints.context;\n}\n\n/**\n * Continues in the launch checkout the user chose although it differs from the snapshot. #4245's resume would restore\n * a fresh worktree over that choice, so no other checkout is restored either; the notice names those left out.\n */\nasync function continueInChosenCheckout(\n\tsessionManager: SessionManager,\n\treuse: Extract<CheckoutReuse, { kind: \"reused\" }>,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<PreparedSessionResume> {\n\tconst notices: ResumeNotice[] = [reuse.notice];\n\tfor (const [root, snapshot] of await currentWorktreeSnapshots(sessionManager)) {\n\t\tif (!(await isDirectory(root))) {\n\t\t\tnotices.push(\n\t\t\t\tnotRestored(\n\t\t\t\t\troot,\n\t\t\t\t\tsnapshot,\n\t\t\t\t\t\"it does not exist on this node, and the session continues in the checkout you chose, which restores nothing else\",\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\tconst reopened = await sessionManager.openSessionById(\n\t\tsessionManager.getSessionId(),\n\t\treuse.cwd,\n\t\toptions.sessionDirectory,\n\t\t{ history: \"tail\" },\n\t);\n\tconst blueprints =\n\t\toptions.blueprints === \"skip\"\n\t\t\t? SKIPPED_BLUEPRINTS\n\t\t\t: await setUpResumedBlueprints({\n\t\t\t\t\trestored: [],\n\t\t\t\t\tinPlace: await existingCheckouts(reopened),\n\t\t\t\t\tconfig: { ...options.blueprint, storeDir },\n\t\t\t\t\tsignal: options.signal,\n\t\t\t\t});\n\tawait recordBlueprintContext(reopened, blueprints.context);\n\treturn {\n\t\tstatus: \"ready\",\n\t\tsessionManager: reopened,\n\t\tnotices,\n\t\tblueprintNotices: [],\n\t\tblueprintContext: blueprints.context,\n\t};\n}\n\n/** The session's current checkouts that exist on this node, with the remotes their snapshots recorded. */\nasync function existingCheckouts(sessionManager: SessionCheckouts): Promise<BlueprintCheckout[]> {\n\tconst checkouts: BlueprintCheckout[] = [];\n\tfor (const [root, snapshot] of await currentWorktreeSnapshots(sessionManager)) {\n\t\tif (await isDirectory(root)) checkouts.push(checkoutOf(sessionManager, root, snapshot));\n\t}\n\treturn checkouts;\n}\n\n/** The checkout at `root` for the blueprint build, identified by its repository's remotes as the session's restores trace them. */\nfunction checkoutOf(sessionManager: SessionCheckouts, root: string, snapshot: WorktreeSnapshot): BlueprintCheckout {\n\treturn {\n\t\troot,\n\t\tremotes: inheritedRemotes(\n\t\t\troot,\n\t\t\tsnapshot.remotes,\n\t\t\tsessionManager.getWorktreeRootMappings(),\n\t\t\tsessionManager.getWorktreeSnapshotRecords(),\n\t\t),\n\t};\n}\n\n/** A recorded checkout a resume restores, and whether it is missing here or only changed. */\ninterface RestoreTarget {\n\treadonly root: string;\n\treadonly snapshot: WorktreeSnapshot;\n\treadonly absent: boolean;\n\t/** Whether the session's working directory is inside it, so the session cannot continue without it. */\n\treadonly runsHere: boolean;\n}\n\n/** What a resume does about the recorded checkouts that are gone or changed here. */\ninterface RestorePlan {\n\t/** Checkouts the session works in, which the resume restores together or not at all. */\n\treadonly required: readonly RestoreTarget[];\n\t/** Every other checkout the resume restores, each on its own, so that one that cannot be restored is left out. */\n\treadonly optional: readonly RestoreTarget[];\n\t/** The warning for each other checkout the resume continues without restoring, by its root. */\n\treadonly left: ReadonlyMap<string, ResumeNotice>;\n\t/** Why Git cannot run here, when it cannot: the checkouts the session works in are then not restored (#4733). */\n\treadonly git: GitUnavailableError | undefined;\n}\n\n/** Records that the session continues in a checkout already here, so paths follow it. */\nasync function recordReuse(sessionManager: SessionManager, mapping: WorktreeRootMapping): Promise<void> {\n\tawait sessionManager.appendWorktreeSnapshot(mapping.to, mapping.snapshotId, undefined, mapping);\n}\n\ntype SessionCheckouts = Pick<\n\tSessionManager,\n\t| \"getBranch\"\n\t| \"getWorktreeRootMappings\"\n\t| \"getWorktreeSnapshotRecords\"\n\t| \"getSessionId\"\n\t| \"loadWorktreeSnapshotRecords\"\n>;\n\n/** The session's checkouts as they are once `mapping`, not yet recorded, is. */\nfunction withMapping(sessionManager: SessionManager, mapping: WorktreeRootMapping | undefined): SessionCheckouts {\n\tif (mapping === undefined) return sessionManager;\n\treturn {\n\t\tgetBranch: () => sessionManager.getBranch(),\n\t\tgetSessionId: () => sessionManager.getSessionId(),\n\t\tgetWorktreeSnapshotRecords: () => sessionManager.getWorktreeSnapshotRecords(),\n\t\tloadWorktreeSnapshotRecords: (ids, options) => sessionManager.loadWorktreeSnapshotRecords(ids, options),\n\t\tgetWorktreeRootMappings: () => [...sessionManager.getWorktreeRootMappings(), mapping],\n\t};\n}\n\n/** The warning that the resume continues without restoring the checkout recorded at `root`, with the reason. */\nfunction notRestored(root: string, snapshot: WorktreeSnapshot, reason: string): ResumeNotice {\n\treturn {\n\t\ttype: \"warning\",\n\t\tmessage: `Continuing without restoring ${root} (snapshot ${snapshot.id.slice(0, 12)}): ${reason}`,\n\t};\n}\n\nfunction absentOrChanged(target: Pick<RestoreTarget, \"absent\">): string {\n\treturn target.absent ? \"it does not exist on this node\" : \"it no longer matches the snapshot\";\n}\n\n/**\n * A failure of one checkout alone, which leaves the session's other checkouts restorable: a typed resume, workspace or\n * Git failure, but not a setting that is wrong for every checkout.\n */\nfunction isCheckoutFailure(error: unknown): error is Error {\n\treturn isResumeFailure(error) && !isWorkspaceConfigError(error);\n}\n\n/** What went wrong in `error`, for a warning: the unmet preconditions' reasons, or its own message, and any failed cleanup. */\nfunction describeFailure(error: Error): string {\n\tconst detail = isResumePreconditionError(error)\n\t\t? error.problems.map((problem) => problem.why).join(\"; \")\n\t\t: error.message;\n\tconst cleanup = (error as Error & { readonly cleanupCause?: unknown }).cleanupCause;\n\treturn cleanup instanceof Error ? `${detail}; removing what it restored also failed: ${cleanup.message}` : detail;\n}\n\n/**\n * The recorded checkouts that are gone or changed here, which #4245's resume restores into fresh worktrees, except\n * those the session continues in as they are. Another checkout than the one the session works in is also left alone,\n * with a warning, when it cannot be compared with its snapshot, or when it is here and the session worked in it on this\n * node, so it continues as it is.\n */\nasync function restoreCandidates(\n\tsessionManager: SessionCheckouts,\n\tcwd: string,\n\toptions: PrepareSessionResumeOptions,\n\tneedsRestore: (snapshot: WorktreeSnapshot, root: string) => Promise<boolean>,\n\tpartial: () => Promise<ReadonlySet<string>>,\n): Promise<{ readonly targets: RestoreTarget[]; readonly left: Map<string, ResumeNotice> }> {\n\tconst targets: RestoreTarget[] = [];\n\tconst left = new Map<string, ResumeNotice>();\n\tconst checkouts = [...(await currentWorktreeSnapshots(sessionManager))].filter(\n\t\t([root]) => !options.keepInPlace?.has(root),\n\t);\n\tconst comparisons = await settleBounded(checkouts, VERIFY_CONCURRENCY, ([root, snapshot]) =>\n\t\tneedsRestore(snapshot, root),\n\t);\n\tfor (const [index, [root, snapshot]] of checkouts.entries()) {\n\t\tconst runsHere = isInside(root, cwd);\n\t\tconst comparison = comparisons[index]!;\n\t\tif (comparison.status === \"rejected\") {\n\t\t\tconst error: unknown = comparison.reason;\n\t\t\tif (runsHere || options.signal?.aborted || !isCheckoutFailure(error)) throw error;\n\t\t\tleft.set(root, notRestored(root, snapshot, `it could not be compared with the snapshot: ${error.message}`));\n\t\t\tcontinue;\n\t\t}\n\t\tif (!comparison.value) continue;\n\t\tconst absent = !(await isDirectory(root));\n\t\tif (\n\t\t\t!runsHere &&\n\t\t\t!absent &&\n\t\t\t(\n\t\t\t\tawait checkoutsWorkedHere(\n\t\t\t\t\tnew Map([[root, snapshot]]),\n\t\t\t\t\tcwd,\n\t\t\t\t\tsessionManager.getSessionId(),\n\t\t\t\t\toptions,\n\t\t\t\t\tawait partial(),\n\t\t\t\t)\n\t\t\t).has(root)\n\t\t) {\n\t\t\tleft.set(\n\t\t\t\troot,\n\t\t\t\tnotRestored(\n\t\t\t\t\troot,\n\t\t\t\t\tsnapshot,\n\t\t\t\t\t\"it changed since the snapshot, and the session worked in it on this node, so it stays as it is\",\n\t\t\t\t),\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\ttargets.push({ root, snapshot, absent, runsHere });\n\t}\n\treturn { targets, left };\n}\n\n/** How many recorded checkouts a resume compares with their snapshots at once. */\nconst VERIFY_CONCURRENCY = 4;\n\n/** `map` over `items`, at most `limit` at a time, each outcome settled in the order of `items`. */\nasync function settleBounded<T, R>(\n\titems: readonly T[],\n\tlimit: number,\n\tmap: (item: T) => Promise<R>,\n): Promise<PromiseSettledResult<R>[]> {\n\tconst outcomes: PromiseSettledResult<R>[] = [];\n\tlet next = 0;\n\tconst work = async (): Promise<void> => {\n\t\twhile (next < items.length) {\n\t\t\tconst index = next++;\n\t\t\ttry {\n\t\t\t\toutcomes[index] = { status: \"fulfilled\", value: await map(items[index]!) };\n\t\t\t} catch (reason) {\n\t\t\t\toutcomes[index] = { status: \"rejected\", reason };\n\t\t\t}\n\t\t}\n\t};\n\tawait Promise.all(Array.from({ length: Math.min(limit, items.length) }, work));\n\treturn outcomes;\n}\n\n/**\n * Restores what `plan` says into fresh worktrees with #4245's {@link resumeSessionWorktree}, recording each restore on\n * `sessionManager`, and returns the mappings it recorded. The checkouts the session works in are restored together,\n * with the mapping to the launch checkout `reused`; one that cannot be restored exactly is restored as far as it can be,\n * or recorded as left out, in `unrestored` (#4733), and only a failure that is not about a checkout refuses the resume.\n * Every other checkout is restored on its own the same way, and one whose restore is refused is reported in `failed`\n * and left out. `cwd` is where the session continues after the restore of the checkouts it works in.\n */\nasync function restorePlanned(\n\tsessionManager: SessionManager,\n\tplan: RestorePlan,\n\treused: WorktreeRootMapping | undefined,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n\tlfs: LfsDownloads,\n): Promise<{\n\trestored: WorktreeRootMapping[];\n\tfailed: ResumeNotice[];\n\t/** The notices in `failed` of checkouts whose snapshot record the session lacks (#4744). */\n\tmissingNotices: ResumeNotice[];\n\tunrestored: WorktreeUnrestored[];\n\tcwd: string | undefined;\n}> {\n\tconst outcome = {\n\t\trestored: [] as WorktreeRootMapping[],\n\t\tfailed: [] as ResumeNotice[],\n\t\tunrestored: [] as WorktreeUnrestored[],\n\t\tcwd: undefined as string | undefined,\n\t\tmissing: new Set<string>(),\n\t\tmissingNotices: [] as ResumeNotice[],\n\t};\n\tlet restored = false;\n\tconst restore = async (\n\t\ttargets: readonly RestoreTarget[],\n\t\tpending: WorktreeRootMapping | undefined,\n\t\tbeforeRecord?: () => Promise<void>,\n\t) => {\n\t\trestored = true;\n\t\tconst git = plan.git;\n\t\tfor (const target of targets) {\n\t\t\tif (git === undefined) {\n\t\t\t\toptions.onProgress?.(`Restoring ${target.root} from snapshot ${target.snapshot.id.slice(0, 12)}`);\n\t\t\t}\n\t\t}\n\t\tconst restoring = new Set(targets.map((target) => target.root));\n\t\tconst resumed = await resumeSessionWorktree(sessionManager, {\n\t\t\tsettings: options.settings,\n\t\t\tstoreDir,\n\t\t\tsignal: options.signal,\n\t\t\tpendingMappings: pending === undefined ? [] : [pending],\n\t\t\tkeepInPlace: new Set(\n\t\t\t\t[...(await currentWorktreeSnapshots(withMapping(sessionManager, pending))).keys()].filter(\n\t\t\t\t\t(root) => !restoring.has(root),\n\t\t\t\t),\n\t\t\t),\n\t\t\t...(git === undefined ? {} : { cannotRestore: new Map(targets.map((target) => [target.root, git])) }),\n\t\t\tfallbackCwd: options.launchCwd,\n\t\t\tskipMissingRecords: true,\n\t\t\tpool: options.pool ?? { maxIdlePerRepository: DEFAULT_MAX_IDLE_PER_REPOSITORY },\n\t\t\tdeferLfs: lfs.start,\n\t\t\tbeforeRecord,\n\t\t});\n\t\tfor (const missing of resumed.missingRecords ?? []) {\n\t\t\tif (outcome.missing.has(missing.root)) continue;\n\t\t\toutcome.missing.add(missing.root);\n\t\t\tconst notice: ResumeNotice = { type: \"warning\", message: formatMissingRecordNotice(missing) };\n\t\t\toutcome.failed.push(notice);\n\t\t\toutcome.missingNotices.push(notice);\n\t\t}\n\t\tif (resumed.status === \"none\") return undefined;\n\t\tif (resumed.status === \"restored\") outcome.restored.push(...resumed.mappings);\n\t\toutcome.unrestored.push(...resumed.unrestored.map((checkout) => checkout.record));\n\t\treturn resumed.cwd;\n\t};\n\tif (plan.required.length > 0 || reused !== undefined) outcome.cwd = await restore(plan.required, reused);\n\t// Optional checkouts restore at once, as many as verification compares (#4748); each records its outcome only after\n\t// the one before it has, so the session lists them, and their notices, in the order a serial resume would.\n\tlet previous = Promise.resolve();\n\tconst turns = plan.optional.map((target) => {\n\t\tconst before = previous;\n\t\tlet done!: () => void;\n\t\tprevious = new Promise<void>((resolveTurn) => {\n\t\t\tdone = resolveTurn;\n\t\t});\n\t\treturn { target, before, done };\n\t});\n\tconst outcomes = await settleBounded(turns, VERIFY_CONCURRENCY, async ({ target, before, done }) => {\n\t\ttry {\n\t\t\tawait restore([target], undefined, () => before);\n\t\t} catch (error) {\n\t\t\tawait before;\n\t\t\tif (options.signal?.aborted || !isCheckoutFailure(error)) throw error;\n\t\t\toutcome.failed.push(\n\t\t\t\tnotRestored(\n\t\t\t\t\ttarget.root,\n\t\t\t\t\ttarget.snapshot,\n\t\t\t\t\t`${absentOrChanged(target)}, and restoring it failed: ${describeFailure(error)}`,\n\t\t\t\t),\n\t\t\t);\n\t\t} finally {\n\t\t\tawait before;\n\t\t\tdone();\n\t\t}\n\t});\n\tfor (const result of outcomes) if (result.status === \"rejected\") throw result.reason;\n\t// With nothing to restore, no restore listed the checkouts whose snapshot record is missing (#4744).\n\tif (!restored) {\n\t\tfor (const missing of await missingSnapshotRecords(sessionManager)) {\n\t\t\tconst notice: ResumeNotice = { type: \"warning\", message: formatMissingRecordNotice(missing) };\n\t\t\toutcome.failed.push(notice);\n\t\t\toutcome.missingNotices.push(notice);\n\t\t}\n\t}\n\treturn outcome;\n}\n\n/**\n * Builds the blueprints of the worktrees Atomic restored for the session: each worktree this resume restored\n * (`restoredNow`), and again each worktree restored earlier whose last build failed or never finished. Later changes\n * to an earlier worktree's files are the session's own work. Every other checkout the session works in is only\n * described to the agent.\n */\nasync function setUpCheckoutBlueprints(\n\tsessionManager: SessionManager,\n\trestoredNow: ReadonlySet<string>,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n\tlfs = new LfsDownloads(),\n): Promise<ResumedBlueprints> {\n\t// The warnings of LFS downloads that end after their restores were recorded come with the build's (#5099).\n\tif (options.blueprints === \"skip\") return { ...SKIPPED_BLUEPRINTS, notices: await lfs.notices(restoredNow) };\n\tconst restoredHere: BlueprintCheckout[] = [];\n\tconst earlier: BlueprintCheckout[] = [];\n\tconst inPlace: BlueprintCheckout[] = [];\n\tfor (const [root, snapshot] of await currentWorktreeSnapshots(sessionManager)) {\n\t\tconst checkout = checkoutOf(sessionManager, root, snapshot);\n\t\tif (restoredNow.has(root)) restoredHere.push({ ...checkout, ready: lfs.ready(root) });\n\t\telse if (isInside(storeDir, root)) {\n\t\t\tif (!(await pooledWorktreeOwnedElsewhere(storeDir, root, sessionManager.getSessionId())))\n\t\t\t\tearlier.push({ ...checkout, ready: finishPendingLfs(lfs, root, options.signal) });\n\t\t} else if (await isDirectory(root)) inPlace.push(checkout);\n\t}\n\t// A worktree this process is building already is joined, not built again (#4748): its tools wait for that build.\n\tconst joined = [...restoredHere, ...earlier].filter((checkout) => buildInProgress(checkout.root) !== undefined);\n\tconst toBuild = restoredHere.filter((checkout) => !joined.includes(checkout));\n\tconst candidates = earlier.filter((checkout) => !joined.includes(checkout));\n\t// Claimed before anything is awaited, so a resume that starts meanwhile in this process joins this one.\n\tconst { promise: settled, resolve: settle } = Promise.withResolvers<undefined>();\n\tconst claimed = [...toBuild, ...candidates].map((checkout) => resolve(checkout.root));\n\tfor (const root of claimed) buildsInProgress.set(root, settled);\n\ttry {\n\t\tawait Promise.all(joined.map((checkout) => buildInProgress(checkout.root)));\n\t\t// Another process's build of one of them is waited for, or the steps of one whose process died are stopped,\n\t\t// before the ledger says which need building.\n\t\t// Settling another build never fails the resume: a failure to read or clean up its lock is a warning.\n\t\tconst settled = await settleOtherBuilds(storeDir, claimed, {\n\t\t\tsignal: options.signal,\n\t\t\tonWait: (root, message) => {\n\t\t\t\toptions.onProgress?.(message);\n\t\t\t\tannounceBlueprintBuildWaiting(root, message);\n\t\t\t},\n\t\t}).catch((error: unknown) => {\n\t\t\tif (options.signal?.aborted) throw error;\n\t\t\treturn {\n\t\t\t\twarnings: [\n\t\t\t\t\t`Could not check for an earlier blueprint build of these worktrees (${error instanceof Error ? describeFailure(error) : String(error)}); building them anyway.`,\n\t\t\t\t],\n\t\t\t\tcancelled: new Set<string>(),\n\t\t\t\trelease: async () => {},\n\t\t\t};\n\t\t});\n\t\t// No other process builds them until this build settled, and then the ledger says whether they still need it.\n\t\tlet built: ResumedBlueprints;\n\t\tconst unlocked: string[] = [];\n\t\ttry {\n\t\t\tconst retried = await checkoutsNeedingRebuild(candidates, storeDir);\n\t\t\tconst restored = [...toBuild, ...retried];\n\t\t\tbuilt = await withBuildLocks(\n\t\t\t\tstoreDir,\n\t\t\t\trestored.map((checkout) => checkout.root),\n\t\t\t\t() =>\n\t\t\t\t\tsetUpResumedBlueprints({\n\t\t\t\t\t\trestored,\n\t\t\t\t\t\tinPlace,\n\t\t\t\t\t\tearlier: [...joined, ...candidates.filter((checkout) => !retried.includes(checkout))],\n\t\t\t\t\t\tconfig: { ...options.blueprint, storeDir },\n\t\t\t\t\t\tsignal: options.signal,\n\t\t\t\t\t}),\n\t\t\t\t(message) => unlocked.push(message),\n\t\t\t);\n\t\t} finally {\n\t\t\tawait settled.release();\n\t\t}\n\t\t// The warnings of LFS downloads that end after their restores were recorded come with the build's (#5099).\n\t\tconst downloads = await lfs.notices([...restoredHere, ...earlier].map((checkout) => checkout.root));\n\t\tconst warnings = [...settled.warnings, ...unlocked].map((message) => ({ type: \"warning\" as const, message }));\n\t\treturn { ...built, notices: [...warnings, ...downloads, ...built.notices] };\n\t} finally {\n\t\tfor (const root of claimed) if (buildsInProgress.get(root) === settled) buildsInProgress.delete(root);\n\t\tsettle(undefined);\n\t}\n}\n\n/** The blueprint builds this process runs, by the restored worktree they build, each settling once its build has. */\nconst buildsInProgress = new Map<string, Promise<undefined>>();\n\nasync function setAsideCancelledBuilds(\n\tsessionManager: SessionCheckouts,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<ResumeNotice[]> {\n\tif (process.platform === \"win32\" || options.blueprints === \"skip\" || !options.settings.enabled) return [];\n\tconst roots: string[] = [];\n\tfor (const root of (await currentWorktreeSnapshots(sessionManager)).keys()) {\n\t\tif (!isInside(storeDir, root) || options.keepInPlace?.has(root) || buildInProgress(root) !== undefined) continue;\n\t\tif (!(await pooledWorktreeOwnedElsewhere(storeDir, root, sessionManager.getSessionId()))) roots.push(root);\n\t}\n\tif (roots.length === 0) return [];\n\tconst notices: ResumeNotice[] = [];\n\tconst setAside = async (build: CancelledBuild): Promise<boolean> => {\n\t\tconst running = `A step of the cancelled build may still be running in ${build.root}; its log is ${build.logs}.`;\n\t\ttry {\n\t\t\tawait setAsideWorktree(storeDir, build.root, { startedAt: build.startedAt, logs: build.logs });\n\t\t\tnotices.push({\n\t\t\t\ttype: \"warning\",\n\t\t\t\tmessage: `The blueprint build of ${build.root} did not finish, so it was cancelled and the worktree set aside; a fresh worktree is restored and built instead. ${running}`,\n\t\t\t});\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tconst reason = error instanceof Error ? error.message : String(error);\n\t\t\tnotices.push({\n\t\t\t\ttype: \"warning\",\n\t\t\t\tmessage: `The blueprint build of ${build.root} did not finish, so it was cancelled; a fresh worktree is restored and built instead, but the worktree could not be set aside (${reason.slice(0, 200)}), so another Atomic process may still use it. ${running}`,\n\t\t\t});\n\t\t\treturn false;\n\t\t}\n\t};\n\tconst warnings = await cancelledBuilds(\n\t\tstoreDir,\n\t\troots,\n\t\t{\n\t\t\tsignal: options.signal,\n\t\t\tonWait: (root, message) => {\n\t\t\t\toptions.onProgress?.(message);\n\t\t\t\tannounceBlueprintBuildWaiting(root, message);\n\t\t\t},\n\t\t},\n\t\tsetAside,\n\t);\n\treturn [...warnings.map((message) => ({ type: \"warning\" as const, message })), ...notices];\n}\n\n/** The build this process runs of the worktree at `root`, if one runs. */\nfunction buildInProgress(root: string): Promise<undefined> | undefined {\n\treturn buildsInProgress.get(resolve(root));\n}\n\n/** Whether a resume of `sessionManager` joins a blueprint build this process already runs in one of its worktrees. */\nasync function joinsBuildInProgress(sessionManager: SessionManager): Promise<boolean> {\n\treturn [...(await currentWorktreeSnapshots(sessionManager)).keys()].some(\n\t\t(root) => buildInProgress(root) !== undefined,\n\t);\n}\n\n/**\n * Finishes the LFS download a resume interrupted, or another process still runs, in the restored worktree at `root`,\n * if one is pending (#5099), so its blueprint runs on the files' content; settles once that is done.\n */\nfunction finishPendingLfs(lfs: LfsDownloads, root: string, signal: AbortSignal | undefined): Promise<void> {\n\tlfs.start(root, async () => (await (await pendingLfsDownload(root, { signal }))?.()) ?? []);\n\treturn lfs.ready(root);\n}\n\n/**\n * Whether the repository of the checkout at `root` holds the commit that records `snapshot`. That commit is\n * content-addressed and written only where Atomic captured exactly that state, so it tells the checkout a session\n * worked in, even after it changed, from another checkout of the same repository at the same path on another node,\n * unless Atomic captured the same state there too. A checkout that is not a repository, or a node without Git, does\n * not hold it.\n */\nexport async function holdsSnapshotCommit(\n\tsnapshot: WorktreeSnapshot,\n\troot: string,\n\tsignal?: AbortSignal,\n): Promise<boolean> {\n\ttry {\n\t\tconst { exitCode } = await runGit([\"cat-file\", \"-e\", `${snapshot.snapshot}^{commit}`], {\n\t\t\tcwd: root,\n\t\t\tsignal,\n\t\t\tallowExitCodes: [1, 128],\n\t\t});\n\t\treturn exitCode === 0;\n\t} catch (error) {\n\t\tif (isGitUnavailableError(error)) return false;\n\t\tthrow error;\n\t}\n}\n\n/**\n * Whether session `sessionId` worked in the checkout at `root`: its repository holds the commit of `snapshot`, or,\n * once `git gc` pruned that commit, keeps the session's snapshot ref for the checkout (#4923).\n */\nasync function workedInCheckout(\n\tsnapshot: WorktreeSnapshot,\n\troot: string,\n\tsessionId: string,\n\tsignal: AbortSignal | undefined,\n): Promise<boolean> {\n\treturn (\n\t\t(await holdsSnapshotCommit(snapshot, root, signal)) ||\n\t\t(await holdsSessionSnapshotRef(sessionId, snapshot, root, signal))\n\t);\n}\n\n/**\n * Where a woken session continues. Each checkout it recorded that it worked in on this node stays as it is, since work\n * done in it after the release belongs to the session, and a blueprint build that failed or did not finish in a worktree\n * this node restored for it runs again. Every other checkout, as when it is missing or another clone sits at its path on another\n * node, is prepared as `/resume` prepares it. When every checkout stays, it continues in the directory it last worked\n * in, after the restores it recorded, which `reopen` opens it in.\n */\nexport async function continueSessionWhereItWorked(\n\topened: SessionManager,\n\toptions: PrepareSessionResumeOptions,\n\treopen: (cwd: string) => Promise<SessionManager> = (cwd) =>\n\t\topened.openSessionById(opened.getSessionId(), cwd, undefined, { history: \"tail\" }),\n): Promise<SessionManager> {\n\tconst storeDir = resolveStoreDir(options);\n\t// The session holds the pooled worktrees it owns before anything else, so no eviction removes one while its\n\t// blueprints are set up again, and until it closes (#4748).\n\tawait holdSessionWorktrees(opened, opened, storeDir, options.signal);\n\ttry {\n\t\toptions.signal?.throwIfAborted();\n\t\tconst cwd = await mapRestoredPathAsync(opened.getCwd(), opened.getWorktreeRootMappings());\n\t\tconst checkouts = await currentWorktreeSnapshots(opened);\n\t\tconst cancelled = await setAsideCancelledBuilds(opened, storeDir, options);\n\t\tif (cancelled.length > 0) options.onNotices?.(cancelled);\n\t\tconst own = await checkoutsWorkedHere(\n\t\t\tcheckouts,\n\t\t\tcwd,\n\t\t\topened.getSessionId(),\n\t\t\toptions,\n\t\t\tawait partialRestores(opened, options),\n\t\t);\n\t\tif (own.size < checkouts.size) {\n\t\t\tconst prepared = await prepareSessionResume(opened, { ...options, keepInPlace: own });\n\t\t\tif (prepared.status !== \"ready\") {\n\t\t\t\tawait holdSessionWorktrees(opened, opened, storeDir);\n\t\t\t\treturn opened;\n\t\t\t}\n\t\t\tif (prepared.blueprintNotices.length > 0) options.onNotices?.(prepared.blueprintNotices);\n\t\t\treturn prepared.sessionManager;\n\t\t}\n\t\tif (checkouts.size === 0) {\n\t\t\tawait describeBlueprintsInPlace(opened, storeDir, options);\n\t\t} else {\n\t\t\tconst blueprints = await setUpCheckoutBlueprints(opened, new Set(), storeDir, options);\n\t\t\tawait recordBlueprintContext(opened, blueprints.context);\n\t\t\tif (blueprints.notices.length > 0) options.onNotices?.(blueprints.notices);\n\t\t}\n\t\tconst continuing = cwd === resolve(opened.getCwd()) ? opened : await reopen(cwd);\n\t\tawait holdSessionWorktrees(opened, continuing, storeDir);\n\t\treturn continuing;\n\t} catch (error) {\n\t\tawait releaseSessionWorktrees(opened);\n\t\tthrow error;\n\t}\n}\n\n/**\n * The roots of the `checkouts` a session recorded that are here as checkouts it worked in on this node, as it left them\n * or changed since: a worktree this node restored for it, or a checkout whose repository holds the commit of its latest\n * snapshot or the session's snapshot ref for it (#4923). A pooled worktree counts only while session `sessionId` owns it: another session that took the slot works\n * in it now (#4748). The checkout the session works in counts only while its working directory `cwd` is here too.\n */\nasync function checkoutsWorkedHere(\n\tcheckouts: ReadonlyMap<string, WorktreeSnapshot>,\n\tcwd: string,\n\tsessionId: string,\n\toptions: PrepareSessionResumeOptions,\n\tpartial: ReadonlySet<string> = new Set(),\n): Promise<Set<string>> {\n\tconst storeDir = resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n\tconst own = new Set<string>();\n\tfor (const [root, snapshot] of checkouts) {\n\t\tif (!(await pathExists(isInside(root, cwd) ? cwd : root))) continue;\n\t\tif (await worktreeSetAside(storeDir, root)) continue;\n\t\tconst holder = await pooledWorktreeHolder(storeDir, root);\n\t\tif (holder !== \"unpooled\") {\n\t\t\t// Slots share their repository's object store, so only the pool record tells whose work a slot holds, and a\n\t\t\t// slot the session could not hold, or lost while stalled, is not its to continue in (#4830).\n\t\t\tconst owned = !(await pooledWorktreeOwnedElsewhere(storeDir, root, sessionId));\n\t\t\tif (owned && !partial.has(resolve(root))) own.add(root);\n\t\t\tcontinue;\n\t\t}\n\t\tconst restoredHere = isInside(storeDir, root) && !partial.has(resolve(root));\n\t\tif (restoredHere || (await workedInCheckout(snapshot, root, sessionId, options.signal))) own.add(root);\n\t}\n\treturn own;\n}\n\n/**\n * The worktrees a resume restored with less than their snapshot (#4733) that are still exactly as it left them: the\n * session recorded no snapshot there since, and their HEAD and files are what the restore put there. The next resume\n * tries the snapshot again instead of keeping them. A worktree changed since, even by hand, is the session's work and\n * stays; one that cannot be compared stays too.\n */\nasync function partialRestores(\n\tsessionManager: SessionCheckouts,\n\toptions: Pick<PrepareSessionResumeOptions, \"settings\" | \"signal\">,\n): Promise<Set<string>> {\n\tconst current = await currentWorktreeSnapshots(sessionManager);\n\tconst partial = new Set<string>();\n\tfor (const mapping of sessionManager.getWorktreeRootMappings()) {\n\t\tconst degraded = mapping.degraded;\n\t\tconst snapshot = current.get(mapping.to);\n\t\tif (degraded === undefined || snapshot?.id !== mapping.snapshotId || !(await pathExists(mapping.to))) continue;\n\t\tconst restored = {\n\t\t\tremotes: [...snapshot.remotes],\n\t\t\thead: degraded.head,\n\t\t\ttree: degraded.tree,\n\t\t\tenvHash: snapshot.envHash,\n\t\t};\n\t\ttry {\n\t\t\tawait verifyWorktree(restored, mapping.to, { settings: options.settings, signal: options.signal });\n\t\t\tpartial.add(resolve(mapping.to));\n\t\t} catch (error) {\n\t\t\tif (options.signal?.aborted) throw error;\n\t\t}\n\t}\n\treturn partial;\n}\n/**\n * Whether resuming in `root` restores `snapshot` into a fresh worktree: the checkout is gone, is not a repository of\n * the recorded tree, or no longer matches it. A path that cannot be read fails with its typed `unreadable-path` error\n * instead, since restoring would hide it. A checkout whose HEAD only moved forward over the recorded tree, as after\n * committing the recorded edits, continues in place, as #4245's resume decides. Read-only.\n */\nexport async function worktreeNeedsRestore(\n\tsnapshot: WorktreeSnapshot,\n\troot: string,\n\toptions: VerifyWorktreeOptions,\n): Promise<boolean> {\n\ttry {\n\t\tawait verifyWorktree(snapshot, root, options);\n\t\treturn false;\n\t} catch (error) {\n\t\tif (isWorkspaceDriftError(error)) return !(await isHeadOnlyAdvance(error, options.signal));\n\t\tif (isWorkspaceSnapshotError(error) && error.code !== \"unreadable-path\") return true;\n\t\tthrow error;\n\t}\n}\n\n/** The outcome of starting or provisioning Git once for a resume: the typed reason it cannot run, or undefined. */\ninterface GitProbe {\n\treadonly unavailable: GitUnavailableError | undefined;\n}\n\n/**\n * Decides what the resume does about the `candidates` that are gone or changed here, before anything is written. The\n * precondition of restoring them on this node is that Git can be started or provisioned (`git`, the probe's typed\n * failure). When it is unmet, the checkouts the session works in are not restored and the session continues without\n * them, with a notice and a record in the session (#4733); any other checkout is left out with a warning. A blueprint\n * is never a precondition.\n */\nfunction planRestores(\n\tcandidates: { readonly targets: readonly RestoreTarget[]; readonly left: ReadonlyMap<string, ResumeNotice> },\n\tgit: GitUnavailableError | undefined,\n): RestorePlan {\n\tconst required = candidates.targets.filter((target) => target.runsHere);\n\tconst others = candidates.targets.filter((target) => !target.runsHere);\n\tconst left = new Map(candidates.left);\n\tconst optional: RestoreTarget[] = [];\n\tfor (const target of others) {\n\t\tif (git) {\n\t\t\tleft.set(\n\t\t\t\ttarget.root,\n\t\t\t\tnotRestored(\n\t\t\t\t\ttarget.root,\n\t\t\t\t\ttarget.snapshot,\n\t\t\t\t\t`${absentOrChanged(target)}, and Git is unavailable here (${git.code}), which restoring it needs`,\n\t\t\t\t),\n\t\t\t);\n\t\t} else {\n\t\t\toptional.push(target);\n\t\t}\n\t}\n\treturn { required, optional, left, git };\n}\n\n/**\n * Whether a restored worktree is trusted to run its blueprints outside the CLI: the decision saved in `agentDir` for\n * that path, else the default trust setting.\n */\nexport function savedProjectTrust(\n\tagentDir: string,\n\tsettings: Pick<SettingsManager, \"getDefaultProjectTrust\">,\n): (worktree: string) => boolean {\n\tconst trustStore = new ProjectTrustStore(agentDir);\n\treturn (worktree) => trustStore.get(worktree) ?? settings.getDefaultProjectTrust() === \"always\";\n}\n\nexport function savedProjectTrustAsync(\n\tagentDir: string,\n\tsettings: Pick<SettingsManager, \"getDefaultProjectTrust\">,\n): (worktree: string) => Promise<boolean> {\n\tconst trustStore = new ProjectTrustStore(agentDir);\n\treturn async (worktree) => (await trustStore.getAsync(worktree)) ?? settings.getDefaultProjectTrust() === \"always\";\n}\n\n/** Where restored worktrees, the blueprint build ledger and logs live for the agent directory `agentDir`. */\nexport function resumeStoreDir(agentDir: string): string {\n\treturn join(agentDir, \"worktree-snapshots\");\n}\n\nfunction resolveStoreDir(options: Pick<PrepareSessionResumeOptions, \"storeDir\">): string {\n\treturn resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n}\n\n/**\n * The options a resume from `launchCwd` needs: snapshot settings and the blueprint build configuration from\n * `settingsManager`, and the worktree store of `agentDir`. A session without a UI (`interactive` false; default true)\n * starts its first turn while the build runs unless `resume.waitForBlueprint` says otherwise.\n */\nexport function sessionResumeOptions(\n\tentryPoint: ResumeEntryPoint,\n\tlaunchCwd: string,\n\tagentDir: string,\n\tsettingsManager: Pick<\n\t\tSettingsManager,\n\t\t\"getWorktreeSnapshotSettings\" | \"getWorktreePoolSettings\" | \"getResumeSetupCommand\" | \"getResumeWaitForBlueprint\"\n\t>,\n\ttrusted: (worktree: string) => boolean | Promise<boolean>,\n\tinteractive = true,\n): PrepareSessionResumeOptions {\n\treturn {\n\t\tentryPoint,\n\t\tlaunchCwd,\n\t\tsettings: settingsManager.getWorktreeSnapshotSettings(),\n\t\tpool: settingsManager.getWorktreePoolSettings(),\n\t\tblueprint: { agentDir, setupCommand: settingsManager.getResumeSetupCommand(), trusted },\n\t\tstoreDir: resumeStoreDir(agentDir),\n\t\twaitForBlueprint: settingsManager.getResumeWaitForBlueprint(interactive),\n\t};\n}\n"]}
1
+ {"version":3,"file":"session-resume.js","sourceRoot":"","sources":["../../../src/core/resume/session-resume.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAA4B,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AAElF,OAAO,EACN,wBAAwB,EACxB,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EAEpB,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,4BAA4B,EAC5B,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,GACrB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvF,OAAO,EACN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C;KACxE,CAAC;AACH,CAAC","sourcesContent":["import { stat } from \"node:fs/promises\";\nimport { join, relative, resolve } from \"node:path\";\nimport { type GitUnavailableError, isGitUnavailableError } from \"../../utils/git-errors.ts\";\nimport { failureDebugFields, reportDebugAsync as reportDebug } from \"../debug.ts\";\nimport type { SessionManager } from \"../session-manager.ts\";\nimport {\n\tcurrentWorktreeSnapshots,\n\tformatLapsedPinNotice,\n\tformatMissingRecordNotice,\n\tholdSessionWorktrees,\n\tlapsedDegradedRestores,\n\tlatestRestoreTargets,\n\ttype MissingSnapshotRecord,\n\tmapRestoredPath,\n\tmapRestoredPathAsync,\n\tmissingSnapshotRecords,\n\topenResumedSession,\n\tpooledWorktreeOwnedElsewhere,\n\trecordPendingCarriedWork,\n\treleaseSessionWorktrees,\n\tresumeSessionWorktree,\n} from \"../session-worktree-snapshots.ts\";\nimport type { SettingsManager } from \"../settings-manager.ts\";\nimport { recordTimingLines } from \"../timings.ts\";\nimport { pathExists } from \"../tools/path-utils.ts\";\nimport { ProjectTrustStore } from \"../trust-manager.ts\";\nimport { locateCheckout, readRepositoryConfig } from \"../worktree-snapshot/capture.ts\";\nimport {\n\tisWorkspaceConfigError,\n\tisWorkspaceDriftError,\n\tisWorkspaceSnapshotError,\n} from \"../worktree-snapshot/errors.ts\";\nimport { gitText, runGit } from \"../worktree-snapshot/git.ts\";\nimport { isHeadOnlyAdvance } from \"../worktree-snapshot/head-advance.ts\";\nimport {\n\tDEFAULT_MAX_IDLE_PER_REPOSITORY,\n\tpooledWorktreeHolder,\n\tsetAsideWorktree,\n\ttype WorktreePoolSettings,\n\tworktreeSetAside,\n} from \"../worktree-snapshot/pool.ts\";\nimport { sameRemote } from \"../worktree-snapshot/repository-identity.ts\";\nimport {\n\tdefaultWorktreeSnapshotStoreDir,\n\tpendingLfsDownload,\n\ttype VerifyWorktreeOptions,\n\tverifyWorktree,\n} from \"../worktree-snapshot/restore.ts\";\nimport { holdsSessionSnapshotRef } from \"../worktree-snapshot/session-refs.ts\";\nimport type {\n\tWorktreeRootMapping,\n\tWorktreeSnapshot,\n\tWorktreeSnapshotSettings,\n\tWorktreeUnrestored,\n} from \"../worktree-snapshot/types.ts\";\nimport {\n\tannounceBlueprintBuildWaiting,\n\ttype BlueprintBuildResult,\n\tblueprintBuildShared,\n\thandOverBuildTimings,\n\tholdToolsUntilBuilt,\n} from \"./blueprint/barrier.ts\";\nimport type { BlueprintBuildConfig } from \"./blueprint/build.ts\";\nimport { type CancelledBuild, cancelledBuilds, settleOtherBuilds, withBuildLocks } from \"./blueprint/build-lock.ts\";\nimport {\n\tBLUEPRINT_BUILDING_CONTEXT,\n\ttype BlueprintCheckout,\n\tblueprintBuildReport,\n\tcheckoutsNeedingRebuild,\n\tenclosingRepositoryRoot,\n\tinheritedRemotes,\n\ttype ResumedBlueprints,\n\trecordBlueprintContext,\n\tsetUpResumedBlueprints,\n} from \"./blueprint/resume.ts\";\nimport { isResumePreconditionError, type ResumeEntryPoint } from \"./errors.ts\";\nimport { isResumeFailure } from \"./failure.ts\";\nimport { LfsDownloads } from \"./lfs-downloads.ts\";\nimport { isInside } from \"./path-mapping.ts\";\nimport { defaultResumePreflightIo, type ResumePreflightIo } from \"./preflight.ts\";\nimport { formatResumeTimings, type ResumeTimings, ResumeTimingsRecorder, recordResumeTimings } from \"./timings.ts\";\n\n/** What to do when the checkout a resume was started in belongs to the session's repository but differs from it. */\nexport type DirtyCheckoutChoice = \"restore\" | \"use\" | \"cancel\";\n\nexport interface DirtyCheckoutPrompt {\n\t/** Root of the user's checkout the resume was started in. */\n\treadonly checkout: string;\n\t/** Root the session recorded, on the node that recorded it. */\n\treadonly recordedRoot: string;\n\treadonly snapshotId: string;\n}\n\nexport interface ResumeNotice {\n\treadonly type: \"info\" | \"warning\";\n\treadonly message: string;\n}\n\n/** A fork into a different store does not publish an address or credentials for its source. */\nexport function parentHistoryNotices(manager: Pick<SessionManager, \"getHeader\">): ResumeNotice[] {\n\treturn manager.getHeader()?.parentInOtherStore\n\t\t? [{ type: \"info\", message: \"Parent history is in its original store or is no longer available.\" }]\n\t\t: [];\n}\n\nexport interface PrepareSessionResumeOptions {\n\treadonly entryPoint: ResumeEntryPoint;\n\t/** Where the resume was started: the requested target when it is a checkout of the session's repository. */\n\treadonly launchCwd: string;\n\treadonly settings: WorktreeSnapshotSettings;\n\t/** How the blueprints of worktrees this resume restores are built; the store directory is `storeDir`. */\n\treadonly blueprint: Omit<BlueprintBuildConfig, \"storeDir\">;\n\t/** Host directory for restored worktrees. Default ~/.atomic/agent/worktree-snapshots. */\n\treadonly storeDir?: string;\n\t/** Asks the user about a dirty checkout. Without it a fresh worktree is restored, which overwrites nothing. */\n\treadonly chooseDirtyCheckout?: (prompt: DirtyCheckoutPrompt) => Promise<DirtyCheckoutChoice>;\n\treadonly io?: ResumePreflightIo;\n\t/** Session directory to reopen a moved session in, for stores that keep sessions per directory. */\n\treadonly sessionDirectory?: string;\n\treadonly signal?: AbortSignal;\n\t/**\n\t * Checkouts the session continues in as they are, by the root its recorded restores put them at: never verified and\n\t * never restored, as for checkouts it worked in on this node and changed since.\n\t */\n\treadonly keepInPlace?: ReadonlySet<string>;\n\t/**\n\t * `\"skip\"` restores checkouts but builds and describes no blueprint and records no blueprint context: for a process\n\t * that serves a resume another process of the same user-level action already prepared and built, so one resume\n\t * builds once. Default `\"build\"`.\n\t */\n\treadonly blueprints?: \"build\" | \"skip\";\n\t/**\n\t * Told the warnings of the blueprint builds a resume ran when its caller gets only a session back, as when a\n\t * released session is woken ({@link continueSessionWhereItWorked}).\n\t */\n\treadonly onNotices?: (notices: readonly ResumeNotice[]) => void;\n\t/** Told each slow step the resume starts (checking checkouts, restoring one, building blueprints), for a progress line. */\n\treadonly onProgress?: (message: string) => void;\n\t/**\n\t * The worktree pool (#4748): restores go to stable slots that the session holds while it is open, keeping at most\n\t * `maxIdlePerRepository` idle slots per repository. Default: `snapshots.pool` defaults.\n\t */\n\treadonly pool?: WorktreePoolSettings;\n\t/**\n\t * `\"prompt\"` (default): the resume returns once the blueprints of the worktrees it restored are built. `\"tools\"`: it\n\t * returns once they are restored and the build goes on behind the session's first turn; every tool call of the\n\t * session waits for it (`awaitBlueprintReady`), and the first of them reports how it went. The build's warnings then\n\t * reach the agent and the user with that tool's result, not `notices`.\n\t */\n\treadonly waitForBlueprint?: \"prompt\" | \"tools\";\n\t/**\n\t * Restored worktrees whose trust the session decides only after it starts (#5693): when the resume restores one, it\n\t * returns once restored, as with `waitForBlueprint: \"tools\"`, and the build starts when `decided` settles, so no\n\t * project build step runs before the decision. `blueprint.trusted` answers for them after that.\n\t */\n\treadonly trustDecidedLater?: {\n\t\treadonly applies: (root: string) => Promise<boolean>;\n\t\treadonly decided: Promise<void>;\n\t};\n}\n\nexport type PreparedSessionResume =\n\t| { readonly status: \"cancelled\" }\n\t| {\n\t\t\treadonly status: \"ready\";\n\t\t\t/** The session opened where it continues: the one passed in when its cwd did not change. */\n\t\t\treadonly sessionManager: SessionManager;\n\t\t\treadonly notices: readonly ResumeNotice[];\n\t\t\t/** The warnings of the blueprint builds this resume ran, also in `notices`. */\n\t\t\treadonly blueprintNotices: readonly ResumeNotice[];\n\t\t\t/**\n\t\t\t * The notices of checkouts whose snapshot record the session does not hold, also in `notices` (#4744). The\n\t\t\t * session records nothing for them, so a caller that shows the notices its entries carry shows these too.\n\t\t\t */\n\t\t\treadonly missingRecordNotices?: readonly ResumeNotice[];\n\t\t\t/** The blueprint context the session's next turn carries, already recorded in it; undefined when none. */\n\t\t\treadonly blueprintContext: string | undefined;\n\t };\n\nasync function isDirectory(path: string): Promise<boolean> {\n\ttry {\n\t\treturn (await stat(path)).isDirectory();\n\t} catch (error) {\n\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\tif (code === \"ENOENT\" || code === \"ENOTDIR\") return false;\n\t\tthrow error;\n\t}\n}\n\nexport interface SessionSnapshotMatch {\n\treadonly root: string;\n\treadonly snapshot: WorktreeSnapshot;\n\t/** The session cwd after the session's recorded restores. */\n\treadonly cwd: string;\n}\n\nfunction matchSessionSnapshot(\n\tcwd: string,\n\tsnapshots: ReadonlyMap<string, WorktreeSnapshot>,\n): SessionSnapshotMatch | undefined {\n\tlet match: SessionSnapshotMatch | undefined;\n\tfor (const [root, snapshot] of snapshots) {\n\t\tif (isInside(root, cwd) && (!match || root.length > match.root.length)) match = { root, snapshot, cwd };\n\t}\n\treturn match;\n}\n\n/** The latest snapshot of the checkout the session works in, the same one #4245's resume verifies. */\nexport function latestSessionSnapshot(\n\tsessionManager: Pick<SessionManager, \"getCwd\" | \"getWorktreeRootMappings\" | \"getLatestWorktreeSnapshots\">,\n\tsnapshots: ReadonlyMap<string, WorktreeSnapshot> = sessionManager.getLatestWorktreeSnapshots(),\n): SessionSnapshotMatch | undefined {\n\tconst cwd = mapRestoredPath(sessionManager.getCwd(), sessionManager.getWorktreeRootMappings());\n\treturn matchSessionSnapshot(cwd, snapshots);\n}\n\nexport async function latestSessionSnapshotAsync(\n\tsessionManager: Pick<SessionManager, \"getCwd\" | \"getWorktreeRootMappings\" | \"getLatestWorktreeSnapshots\">,\n\tsnapshots: ReadonlyMap<string, WorktreeSnapshot> = sessionManager.getLatestWorktreeSnapshots(),\n): Promise<SessionSnapshotMatch | undefined> {\n\tconst cwd = await mapRestoredPathAsync(sessionManager.getCwd(), sessionManager.getWorktreeRootMappings());\n\treturn matchSessionSnapshot(cwd, snapshots);\n}\n\n/** Continue in the launch checkout, or stop because the user cancelled; undefined restores a fresh worktree. */\ntype CheckoutReuse =\n\t| {\n\t\t\treadonly kind: \"reused\";\n\t\t\treadonly cwd: string;\n\t\t\t/** Whether the checkout matched the snapshot, rather than being used as it is by the user's choice. */\n\t\t\treadonly matches: boolean;\n\t\t\treadonly notice: ResumeNotice;\n\t\t\t/** The recorded root mapped onto the checkout, recorded once nothing else stops the resume. */\n\t\t\treadonly mapping: WorktreeRootMapping;\n\t }\n\t| { readonly kind: \"cancelled\" }\n\t| undefined;\n\n/**\n * Continues in the checkout the resume started in when it is a checkout of the session's repository: as-is when its\n * tree matches the snapshot (or only its HEAD moved forward over it); when it differs and has local changes, only if\n * the user says so. A clean checkout that differs is left alone and a fresh worktree is restored instead. Returns the\n * mapping that makes paths follow, for the caller to record.\n */\nasync function reuseLaunchCheckout(\n\tmatch: SessionSnapshotMatch,\n\tsessionId: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<CheckoutReuse> {\n\tconst checkout = await locateCheckout(options.launchCwd, options.signal).catch((error: unknown) => {\n\t\tif (isWorkspaceSnapshotError(error)) return error;\n\t\tthrow error;\n\t});\n\tif (checkout instanceof Error) return undefined;\n\tconst root = resolve(checkout.root);\n\t// A pooled worktree another session owns holds that session's work, even when it matches (#4748).\n\tif (await pooledWorktreeOwnedElsewhere(resolveStoreDir(options), root, sessionId)) return undefined;\n\tconst { remotes } = await readRepositoryConfig(root, options.signal);\n\t// The same repository spelled another way, SSH or HTTPS, with or without `.git`, is still the session's (#4913).\n\tif (!remotes.some((remote) => match.snapshot.remotes.some((recorded) => sameRemote(remote, recorded)))) {\n\t\treturn undefined;\n\t}\n\tlet matches = true;\n\ttry {\n\t\tawait verifyWorktree(match.snapshot, root, { settings: options.settings, signal: options.signal });\n\t} catch (error) {\n\t\tif (!isWorkspaceDriftError(error)) throw error;\n\t\tmatches = await isHeadOnlyAdvance(error, options.signal);\n\t}\n\tif (!matches) {\n\t\tif (!(await hasLocalChanges(root, options.signal))) return undefined;\n\t\tconst choice = options.chooseDirtyCheckout\n\t\t\t? await options.chooseDirtyCheckout({\n\t\t\t\t\tcheckout: root,\n\t\t\t\t\trecordedRoot: match.root,\n\t\t\t\t\tsnapshotId: match.snapshot.id,\n\t\t\t\t})\n\t\t\t: \"restore\";\n\t\tif (choice === \"cancel\") return { kind: \"cancelled\" };\n\t\tif (choice === \"restore\") return undefined;\n\t}\n\tconst mapping: WorktreeRootMapping = {\n\t\tfrom: match.root,\n\t\tto: root,\n\t\tsnapshotId: match.snapshot.id,\n\t\ttree: match.snapshot.tree,\n\t\trestoredAt: new Date().toISOString(),\n\t};\n\treturn {\n\t\tkind: \"reused\",\n\t\tcwd: resolve(root, relative(match.root, match.cwd)),\n\t\tmatches,\n\t\tmapping,\n\t\tnotice: matches\n\t\t\t? {\n\t\t\t\t\ttype: \"info\",\n\t\t\t\t\tmessage: `Resuming in ${root}, which matches snapshot ${match.snapshot.id.slice(0, 12)} of ${match.root}`,\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tmessage: `Resuming in ${root}, which differs from snapshot ${match.snapshot.id.slice(0, 12)} of ${match.root}`,\n\t\t\t\t},\n\t};\n}\n\n/**\n * Moves a session that a resume restored into a worktree, and that has not worked in it since, back to the checkout it\n * was restored from, when that checkout is on this node and its repository holds the snapshot's commit (#4660), or the\n * session's snapshot ref for it (#4923). The\n * session continues there as the checkout is now, even when it changed since the snapshot. Undefined keeps the session\n * in its worktree: the worktree is not one Atomic restored, it changed or recorded another snapshot since, or the\n * checkout it came from is gone or is another clone.\n */\nasync function returnToStartingCheckout(\n\tsessionManager: SessionManager,\n\tmatch: SessionSnapshotMatch,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<Extract<CheckoutReuse, { kind: \"reused\" }> | undefined> {\n\tif (!isInside(storeDir, match.root)) return undefined;\n\tconst restore = [...sessionManager.getWorktreeRootMappings()]\n\t\t.reverse()\n\t\t.find((mapping) => resolve(mapping.to) === resolve(match.root));\n\tif (restore === undefined || restore.snapshotId !== match.snapshot.id) return undefined;\n\tconst checkout = resolve(restore.from);\n\tconst cwd = resolve(checkout, relative(match.root, match.cwd));\n\tif (isInside(storeDir, checkout) || !(await pathExists(cwd))) return undefined;\n\t// When the checkout cannot be examined, the project the session started in is still where it goes back to.\n\tconst examined = await orFallBack(options, \"return-to-checkout-verify\", undefined, async () => ({\n\t\tholdsCommit: await workedInCheckout(match.snapshot, checkout, sessionManager.getSessionId(), options.signal),\n\t\tmatches: !(await worktreeNeedsRestore(match.snapshot, checkout, options)),\n\t}));\n\tif (examined !== undefined && !examined.holdsCommit) return undefined;\n\tconst matches = examined?.matches;\n\tconst snapshotId = match.snapshot.id.slice(0, 12);\n\treturn {\n\t\tkind: \"reused\",\n\t\tcwd,\n\t\tmatches: matches ?? false,\n\t\tmapping: {\n\t\t\tfrom: match.root,\n\t\t\tto: checkout,\n\t\t\tsnapshotId: match.snapshot.id,\n\t\t\ttree: match.snapshot.tree,\n\t\t\trestoredAt: new Date().toISOString(),\n\t\t},\n\t\tnotice: {\n\t\t\ttype: \"info\",\n\t\t\tmessage: `Resuming in ${checkout}, the checkout this session was restored from, instead of the worktree ${match.root}.${matches === undefined ? \"\" : matches ? ` It matches snapshot ${snapshotId}.` : ` It has changed since snapshot ${snapshotId}; that snapshot was not restored.`}`,\n\t\t},\n\t};\n}\n\n/**\n * Runs an optional improvement of where a resume continues. When it fails on a checkout, with a typed resume,\n * workspace or Git failure, the resume goes on with `fallback`, the behaviour it had without the improvement; the\n * reason goes to the debug log. A cancellation, and any failure that is not about a checkout, still end the resume.\n */\nasync function orFallBack<T>(\n\toptions: Pick<PrepareSessionResumeOptions, \"signal\">,\n\tstep: string,\n\tfallback: T,\n\tattempt: () => Promise<T>,\n): Promise<T> {\n\ttry {\n\t\treturn await attempt();\n\t} catch (error) {\n\t\tif (options.signal?.aborted || !isCheckoutFailure(error)) throw error;\n\t\treportDebug(\"storage\", \"resume-checkout-fallback\", { step, ...failureDebugFields(error) });\n\t\treturn fallback;\n\t}\n}\n\n/** Whether the checkout at `root` has uncommitted or untracked changes, which a resume must not overwrite unasked. */\nasync function hasLocalChanges(root: string, signal: AbortSignal | undefined): Promise<boolean> {\n\treturn (await gitText([\"status\", \"--porcelain\"], { cwd: root, signal })).length > 0;\n}\n\n/**\n * Gets a resumed session's checkouts ready on this node before its runtime starts, and returns the session opened\n * where it continues. When the checkout the session works in changed here but is still the one it worked in (its\n * repository holds the snapshot's commit, or Atomic restored it here), the session continues in it as it is, silently\n * (#4660). A session a resume moved into a restored worktree, and that has not worked in it since, returns to\n * the checkout it was restored from when that checkout is here. When the checkout the session works in is missing or\n * belongs to another clone here, a checkout of the same\n * repository the resume started in is used as-is if it matches (and, if it differs, only when the user chooses it).\n * Resume always opens the session (#4733): a checkout whose snapshot cannot be restored exactly gets the best state\n * this node can reach, its recorded commit with the change sets that apply or the closest commit it can fetch, and one\n * notice saying what is missing; when nothing of it can be restored, Git being unavailable included, the session\n * continues in its recorded directory, or the directory the resume started from when that is not here, with the same\n * kind of notice. Only a snapshot record that fails the security checks, or a restore target that holds other files,\n * refuses the resume. Every other checkout the session recorded that is gone or changed here, except\n * those in `keepInPlace`, never blocks the resume: one the session worked in on this node, changed since, continues as\n * it is; the rest are restored into fresh worktrees one by one by #4245's {@link resumeSessionWorktree}, and one that\n * cannot be (Git is unavailable, or its restore fails) is left out with a warning that names its path and why. Each\n * worktree Atomic restored then gets its blueprints built (#4588): a failing step is a warning in `notices` and never\n * stops the resume. The agent gets the blueprints' maintenance and knowledge in the session's next turn. The session's\n * tools resolve paths under every root it recorded into the place that root was restored. A resume that restored a\n * checkout or ran a blueprint step records where its time went in the session it returns (#4748); a failure to record\n * that never stops the resume.\n */\nexport async function prepareSessionResume(\n\tsessionManager: SessionManager,\n\toptions: PrepareSessionResumeOptions,\n): Promise<PreparedSessionResume> {\n\tconst storeDir = resolveStoreDir(options);\n\t// The session holds the pooled worktrees it owns before anything is restored, so evicting idle slots never removes\n\t// one it continues in, and until it closes (#4748).\n\tawait holdSessionWorktrees(sessionManager, sessionManager, storeDir, options.signal);\n\t// `atomic --session` counts from the launch of the process, which is 0 on the clock the recorder uses.\n\tconst timings = new ResumeTimingsRecorder(options.entryPoint === \"cli\" ? 0 : undefined);\n\tlet firstRecorded!: (recorded: ResumeTimings | undefined) => void;\n\tconst recordedAtReady = new Promise<ResumeTimings | undefined>((resolve) => {\n\t\tfirstRecorded = resolve;\n\t});\n\t// A build behind the first turn (`waitForBlueprint: \"tools\"`) adds its steps to the timings once it settles.\n\tconst buildSettled = async (session: SessionManager): Promise<void> => {\n\t\tconst atReady = await recordedAtReady;\n\t\tif (atReady === undefined) return;\n\t\t// The restores too: an LFS download behind the first turn ends after it (#5099).\n\t\tconst { restores, blueprint, blueprintReadyMs } = timings.finish();\n\t\tconst recorded = { ...atReady, restores, blueprint, blueprintReadyMs };\n\t\trecordTimingLines(formatResumeTimings(recorded), \"resume\");\n\t\t// The isolated engine has the session open by now, so it records them.\n\t\tif (blueprintBuildShared(session.getSessionId())) handOverBuildTimings(session.getSessionId(), recorded);\n\t\telse await recordResumeTimings(session, recorded);\n\t};\n\tlet prepared: PreparedSessionResume;\n\ttry {\n\t\toptions.signal?.throwIfAborted();\n\t\tprepared = await timings.run(() => prepareResume(sessionManager, options, buildSettled));\n\t} catch (error) {\n\t\tawait releaseSessionWorktrees(sessionManager);\n\t\tthrow error;\n\t}\n\tif (prepared.status === \"ready\") await holdSessionWorktrees(sessionManager, prepared.sessionManager, storeDir);\n\telse await releaseSessionWorktrees(sessionManager);\n\tif (prepared.status === \"ready\" && timings.recordedWork) {\n\t\tconst recorded = timings.finish();\n\t\tawait recordResumeTimings(prepared.sessionManager, recorded);\n\t\trecordTimingLines(formatResumeTimings(recorded), \"resume\");\n\t\tfirstRecorded(recorded);\n\t} else {\n\t\tfirstRecorded(undefined);\n\t}\n\treturn prepared;\n}\n\nasync function prepareResume(\n\tsessionManager: SessionManager,\n\toptions: PrepareSessionResumeOptions,\n\tbuildSettled: (session: SessionManager) => Promise<void>,\n): Promise<PreparedSessionResume> {\n\tconst io = options.io ?? defaultResumePreflightIo;\n\tconst storeDir = resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n\tif (!options.settings.enabled || sessionManager.getLatestWorktreeSnapshots().size === 0) {\n\t\tconst missing = options.settings.enabled ? await missingSnapshotRecords(sessionManager) : [];\n\t\tif (missing.length > 0) return continueWithoutRecords(sessionManager, missing, storeDir, options);\n\t\tconst unchanged = await describeBlueprintsInPlace(sessionManager, storeDir, options);\n\t\treturn { status: \"ready\", sessionManager, notices: [], blueprintNotices: [], blueprintContext: unchanged };\n\t}\n\t// Work a full restore carried over but could not record is recorded now, where its worktree is here (#5009).\n\tawait recordPendingCarriedWork(sessionManager, { settings: options.settings, storeDir, signal: options.signal });\n\t// A partial restore pinned for longer than its retention no longer holds its snapshot (#4922).\n\tconst notices: ResumeNotice[] = (await lapsedDegradedRestores(sessionManager)).map((lapsed) => ({\n\t\ttype: \"warning\",\n\t\tmessage: formatLapsedPinNotice(lapsed),\n\t}));\n\tnotices.push(...(await setAsideCancelledBuilds(sessionManager, storeDir, options)));\n\tconst checkoutCount = (await currentWorktreeSnapshots(sessionManager)).size;\n\toptions.onProgress?.(\n\t\t`Checking ${checkoutCount === 1 ? \"1 checkout\" : `${checkoutCount} checkouts`} against the session's snapshots`,\n\t);\n\tconst verified = new Map<string, Promise<boolean>>();\n\tconst verifyOnce = (snapshot: WorktreeSnapshot, root: string): Promise<boolean> => {\n\t\tconst key = `${snapshot.id}\\0${resolve(root)}`;\n\t\tlet verification = verified.get(key);\n\t\tif (verification === undefined) {\n\t\t\t// A pooled worktree another session owns is restored fresh, as if it were gone (#4748).\n\t\t\tverification = pooledWorktreeOwnedElsewhere(storeDir, root, sessionManager.getSessionId()).then(\n\t\t\t\t(elsewhere) => elsewhere || worktreeNeedsRestore(snapshot, root, options),\n\t\t\t);\n\t\t\tverified.set(key, verification);\n\t\t}\n\t\treturn verification;\n\t};\n\t// Which partly restored worktrees are still as the restore left them, compared once per resume.\n\tlet partialOnce: Promise<Set<string>> | undefined;\n\tconst partial = (): Promise<Set<string>> => {\n\t\tpartialOnce ??= partialRestores(sessionManager, options);\n\t\treturn partialOnce;\n\t};\n\t// A checkout restored only partly is compared with the snapshot it lacks, which stays its restore target (#4922).\n\tconst match = await latestSessionSnapshotAsync(sessionManager, await latestRestoreTargets(sessionManager));\n\tlet git: GitProbe | undefined;\n\tlet reused: WorktreeRootMapping | undefined;\n\tlet needsRestore: boolean;\n\ttry {\n\t\tneedsRestore =\n\t\t\tmatch !== undefined && !options.keepInPlace?.has(match.root) && (await verifyOnce(match.snapshot, match.root));\n\t} catch (error) {\n\t\tif (!isGitUnavailableError(error)) throw error;\n\t\treturn continueWithoutGit(sessionManager, error, storeDir, options);\n\t}\n\tconst project =\n\t\tmatch !== undefined && !needsRestore && !options.keepInPlace?.has(match.root)\n\t\t\t? await orFallBack(options, \"return-to-checkout\", undefined, () =>\n\t\t\t\t\treturnToStartingCheckout(sessionManager, match, storeDir, options),\n\t\t\t\t)\n\t\t\t: undefined;\n\tif (project !== undefined) {\n\t\tawait recordReuse(sessionManager, project.mapping);\n\t\tnotices.push(project.notice);\n\t}\n\tconst keepsOwnCheckout =\n\t\tmatch !== undefined &&\n\t\tproject === undefined &&\n\t\tneedsRestore &&\n\t\t(await isDirectory(match.root)) &&\n\t\t(await orFallBack(options, \"own-checkout\", new Set([match.root]), async () =>\n\t\t\tcheckoutsWorkedHere(\n\t\t\t\tnew Map([[match.root, match.snapshot]]),\n\t\t\t\tmatch.cwd,\n\t\t\t\tsessionManager.getSessionId(),\n\t\t\t\toptions,\n\t\t\t\tawait partial(),\n\t\t\t),\n\t\t).then((worked) => worked.has(match.root)));\n\t// The checkout the session returned to stays as it is, whatever it changed since: only the others are restored.\n\tconst kept = [...(keepsOwnCheckout && match !== undefined ? [match.root] : [])];\n\tif (project !== undefined && match !== undefined) kept.push(match.root, project.mapping.to);\n\tconst resume: PrepareSessionResumeOptions =\n\t\tkept.length > 0 ? { ...options, keepInPlace: new Set([...(options.keepInPlace ?? []), ...kept]) } : options;\n\tif (match !== undefined && !keepsOwnCheckout && needsRestore) {\n\t\tgit = { unavailable: await io.probeGit(options.signal) };\n\t\tconst reuse =\n\t\t\tgit.unavailable === undefined\n\t\t\t\t? await reuseLaunchCheckout(match, sessionManager.getSessionId(), options)\n\t\t\t\t: undefined;\n\t\tif (reuse?.kind === \"cancelled\") return { status: \"cancelled\" };\n\t\tif (reuse?.kind === \"reused\" && !reuse.matches) {\n\t\t\tawait recordReuse(sessionManager, reuse.mapping);\n\t\t\treturn continueInChosenCheckout(sessionManager, reuse, storeDir, options);\n\t\t}\n\t\tif (reuse?.kind === \"reused\") {\n\t\t\treused = reuse.mapping;\n\t\t\tnotices.push(reuse.notice);\n\t\t}\n\t}\n\tconst checkouts = withMapping(sessionManager, reused);\n\tconst candidates = await restoreCandidates(\n\t\tcheckouts,\n\t\tawait mapRestoredPathAsync(sessionManager.getCwd(), checkouts.getWorktreeRootMappings()),\n\t\tresume,\n\t\tverifyOnce,\n\t\tpartial,\n\t);\n\tif (candidates.targets.length > 0) git ??= { unavailable: await io.probeGit(options.signal) };\n\tconst plan = planRestores(candidates, git?.unavailable);\n\tnotices.push(...plan.left.values());\n\tconst recordedBefore = sessionManager.getWorktreeRootMappings().length;\n\t// Each fresh worktree's LFS download runs behind the other restores and the builds; its own build waits (#5099).\n\tconst lfs = new LfsDownloads();\n\tconst resumed = await restorePlanned(sessionManager, plan, reused, storeDir, resume, lfs);\n\tconst cwd =\n\t\tresumed.cwd ?? (await mapRestoredPathAsync(sessionManager.getCwd(), sessionManager.getWorktreeRootMappings()));\n\tconst opened = await openResumedSession(\n\t\tsessionManager,\n\t\tcwd,\n\t\tresumed.restored,\n\t\toptions.sessionDirectory,\n\t\tresumed.unrestored,\n\t);\n\tnotices.push(...opened.notices, ...resumed.failed);\n\tconst restoredNow = new Set(\n\t\topened.sessionManager\n\t\t\t.getWorktreeRootMappings()\n\t\t\t.slice(recordedBefore)\n\t\t\t.map((mapping) => resolve(mapping.to))\n\t\t\t.filter((root) => isInside(storeDir, root)),\n\t);\n\t// A resume that only joins a build this process already runs in its worktree, as a switch back to the session that\n\t// started it, waits for nothing: that build holds the session's tools, and tells the user when it ends (#4748).\n\tif (\n\t\trestoredNow.size === 0 &&\n\t\toptions.blueprints !== \"skip\" &&\n\t\toptions.waitForBlueprint === \"tools\" &&\n\t\t(await joinsBuildInProgress(opened.sessionManager))\n\t) {\n\t\tawait recordBlueprintContext(opened.sessionManager, BLUEPRINT_BUILDING_CONTEXT);\n\t\treturn {\n\t\t\tstatus: \"ready\",\n\t\t\tsessionManager: opened.sessionManager,\n\t\t\tnotices,\n\t\t\tblueprintNotices: [],\n\t\t\tmissingRecordNotices: resumed.missingNotices,\n\t\t\tblueprintContext: BLUEPRINT_BUILDING_CONTEXT,\n\t\t};\n\t}\n\tconst trustLater = options.trustDecidedLater;\n\tlet decided: Promise<void> | undefined;\n\tif (trustLater !== undefined && options.blueprints !== \"skip\") {\n\t\tfor (const root of restoredNow) if (await trustLater.applies(root)) decided = trustLater.decided;\n\t}\n\tconst awaitsTrust = decided !== undefined;\n\tif (restoredNow.size > 0 && options.blueprints !== \"skip\" && (options.waitForBlueprint === \"tools\" || awaitsTrust)) {\n\t\t// The build can be stopped when the process ends before it does (#4748): its steps' process trees end with it,\n\t\t// what ran is recorded, and the ledger keeps the worktrees unbuilt for the next resume.\n\t\tconst stopping = new AbortController();\n\t\tconst signal =\n\t\t\toptions.signal === undefined ? stopping.signal : AbortSignal.any([options.signal, stopping.signal]);\n\t\t// A build that waits for the session's trust decision claims and locks nothing while it waits.\n\t\tconst building = (decided ? untilSettled(decided, signal) : Promise.resolve()).then(() =>\n\t\t\tsetUpCheckoutBlueprints(opened.sessionManager, restoredNow, storeDir, { ...options, signal }, lfs),\n\t\t);\n\t\tconst result = building.then(\n\t\t\tasync (blueprints): Promise<BlueprintBuildResult> => {\n\t\t\t\tawait buildSettled(opened.sessionManager);\n\t\t\t\treturn { report: blueprintBuildReport(blueprints), notices: blueprints.notices };\n\t\t\t},\n\t\t\tasync (error: unknown): Promise<BlueprintBuildResult> => {\n\t\t\t\tawait buildSettled(opened.sessionManager).catch(() => undefined);\n\t\t\t\tconst message = `Blueprint build stopped before it finished (${error instanceof Error ? error.message : String(error)}); the next resume builds the restored worktree again.`;\n\t\t\t\treturn { report: message, notices: [{ type: \"warning\", message }] };\n\t\t\t},\n\t\t);\n\t\tholdToolsUntilBuilt(opened.sessionManager.getSessionId(), result, {\n\t\t\troots: restoredNow,\n\t\t\tstop: (reason) => stopping.abort(reason),\n\t\t});\n\t\tawait recordBlueprintContext(opened.sessionManager, BLUEPRINT_BUILDING_CONTEXT);\n\t\treturn {\n\t\t\tstatus: \"ready\",\n\t\t\tsessionManager: opened.sessionManager,\n\t\t\tnotices,\n\t\t\tblueprintNotices: [],\n\t\t\tmissingRecordNotices: resumed.missingNotices,\n\t\t\tblueprintContext: BLUEPRINT_BUILDING_CONTEXT,\n\t\t};\n\t}\n\tif (restoredNow.size > 0 && options.blueprints !== \"skip\") {\n\t\toptions.onProgress?.(\"Setting up the blueprints of restored worktrees\");\n\t}\n\tconst blueprints = await setUpCheckoutBlueprints(opened.sessionManager, restoredNow, storeDir, options, lfs);\n\tnotices.push(...blueprints.notices);\n\tawait recordBlueprintContext(opened.sessionManager, blueprints.context);\n\treturn {\n\t\tstatus: \"ready\",\n\t\tsessionManager: opened.sessionManager,\n\t\tnotices,\n\t\tblueprintNotices: blueprints.notices,\n\t\tmissingRecordNotices: resumed.missingNotices,\n\t\tblueprintContext: blueprints.context,\n\t};\n}\n\n/**\n * Opens a session whose checkouts cannot even be compared with their snapshots, because Git cannot run here (#4733):\n * it continues in its recorded directory as it is, or in the directory the resume started from when that is not\n * here, without restoring any checkout, and each is recorded as left out with a notice. Nothing is written to any\n * checkout.\n */\nasync function continueWithoutGit(\n\tsessionManager: SessionManager,\n\tgit: GitUnavailableError,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<PreparedSessionResume> {\n\tconst roots = [...(await currentWorktreeSnapshots(sessionManager)).keys()].filter(\n\t\t(root) => !options.keepInPlace?.has(root),\n\t);\n\tconst resumed = await resumeSessionWorktree(sessionManager, {\n\t\tsettings: options.settings,\n\t\tstoreDir,\n\t\tsignal: options.signal,\n\t\tkeepInPlace: options.keepInPlace,\n\t\tcannotRestore: new Map(roots.map((root) => [root, git])),\n\t\tfallbackCwd: options.launchCwd,\n\t\tskipMissingRecords: true,\n\t});\n\tconst cwd = resumed.status === \"none\" ? sessionManager.getCwd() : resumed.cwd;\n\tconst opened = await openResumedSession(\n\t\tsessionManager,\n\t\tcwd,\n\t\t[],\n\t\toptions.sessionDirectory,\n\t\tresumed.status === \"none\" ? [] : resumed.unrestored.map((checkout) => checkout.record),\n\t);\n\tconst context = await describeBlueprintsInPlace(opened.sessionManager, storeDir, options);\n\tconst missingRecordNotices = (resumed.missingRecords ?? []).map((missing) => ({\n\t\ttype: \"warning\" as const,\n\t\tmessage: formatMissingRecordNotice(missing),\n\t}));\n\treturn {\n\t\tstatus: \"ready\",\n\t\tsessionManager: opened.sessionManager,\n\t\tnotices: [...opened.notices, ...missingRecordNotices],\n\t\tblueprintNotices: [],\n\t\tmissingRecordNotices,\n\t\tblueprintContext: context,\n\t};\n}\n\n/**\n * Opens a session whose every recorded checkout refers to a snapshot the session holds no record of (#4733): nothing\n * can be restored, so it continues in its recorded directory, or the directory the resume started from when that is\n * not here, with one notice per checkout.\n */\nasync function continueWithoutRecords(\n\tsessionManager: SessionManager,\n\tmissing: readonly MissingSnapshotRecord[],\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<PreparedSessionResume> {\n\tconst recorded = await mapRestoredPathAsync(sessionManager.getCwd(), sessionManager.getWorktreeRootMappings());\n\tconst cwd = (await pathExists(recorded)) ? recorded : resolve(options.launchCwd);\n\tconst opened = await openResumedSession(sessionManager, cwd, [], options.sessionDirectory);\n\tconst context = await describeBlueprintsInPlace(opened.sessionManager, storeDir, options);\n\tconst notices = missing.map((record) => ({ type: \"warning\" as const, message: formatMissingRecordNotice(record) }));\n\treturn {\n\t\tstatus: \"ready\",\n\t\tsessionManager: opened.sessionManager,\n\t\tnotices,\n\t\tblueprintNotices: [],\n\t\tmissingRecordNotices: notices,\n\t\tblueprintContext: context,\n\t};\n}\n\nconst SKIPPED_BLUEPRINTS: ResumedBlueprints = { outcome: undefined, notices: [], layers: [], context: undefined };\n\n/**\n * The blueprint context of a session that has no worktree snapshots to restore: what its working directory's\n * repository and the global blueprint say, recorded in the session. No build runs and no Git command is started.\n */\nasync function describeBlueprintsInPlace(\n\tsessionManager: SessionManager,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<string | undefined> {\n\tif (options.blueprints === \"skip\") return undefined;\n\tconst root = await enclosingRepositoryRoot(resolve(sessionManager.getCwd()));\n\tconst blueprints = await setUpResumedBlueprints({\n\t\trestored: [],\n\t\tinPlace: root === undefined ? [] : [{ root, remotes: [] }],\n\t\tconfig: { ...options.blueprint, storeDir },\n\t\tsignal: options.signal,\n\t});\n\tawait recordBlueprintContext(sessionManager, blueprints.context);\n\treturn blueprints.context;\n}\n\n/**\n * Continues in the launch checkout the user chose although it differs from the snapshot. #4245's resume would restore\n * a fresh worktree over that choice, so no other checkout is restored either; the notice names those left out.\n */\nasync function continueInChosenCheckout(\n\tsessionManager: SessionManager,\n\treuse: Extract<CheckoutReuse, { kind: \"reused\" }>,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<PreparedSessionResume> {\n\tconst notices: ResumeNotice[] = [reuse.notice];\n\tfor (const [root, snapshot] of await currentWorktreeSnapshots(sessionManager)) {\n\t\tif (!(await isDirectory(root))) {\n\t\t\tnotices.push(\n\t\t\t\tnotRestored(\n\t\t\t\t\troot,\n\t\t\t\t\tsnapshot,\n\t\t\t\t\t\"it does not exist on this node, and the session continues in the checkout you chose, which restores nothing else\",\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\tconst reopened = await sessionManager.openSessionById(\n\t\tsessionManager.getSessionId(),\n\t\treuse.cwd,\n\t\toptions.sessionDirectory,\n\t\t{ history: \"tail\" },\n\t);\n\tconst blueprints =\n\t\toptions.blueprints === \"skip\"\n\t\t\t? SKIPPED_BLUEPRINTS\n\t\t\t: await setUpResumedBlueprints({\n\t\t\t\t\trestored: [],\n\t\t\t\t\tinPlace: await existingCheckouts(reopened),\n\t\t\t\t\tconfig: { ...options.blueprint, storeDir },\n\t\t\t\t\tsignal: options.signal,\n\t\t\t\t});\n\tawait recordBlueprintContext(reopened, blueprints.context);\n\treturn {\n\t\tstatus: \"ready\",\n\t\tsessionManager: reopened,\n\t\tnotices,\n\t\tblueprintNotices: [],\n\t\tblueprintContext: blueprints.context,\n\t};\n}\n\n/** The session's current checkouts that exist on this node, with the remotes their snapshots recorded. */\nasync function existingCheckouts(sessionManager: SessionCheckouts): Promise<BlueprintCheckout[]> {\n\tconst checkouts: BlueprintCheckout[] = [];\n\tfor (const [root, snapshot] of await currentWorktreeSnapshots(sessionManager)) {\n\t\tif (await isDirectory(root)) checkouts.push(checkoutOf(sessionManager, root, snapshot));\n\t}\n\treturn checkouts;\n}\n\n/** The checkout at `root` for the blueprint build, identified by its repository's remotes as the session's restores trace them. */\nfunction checkoutOf(sessionManager: SessionCheckouts, root: string, snapshot: WorktreeSnapshot): BlueprintCheckout {\n\treturn {\n\t\troot,\n\t\tremotes: inheritedRemotes(\n\t\t\troot,\n\t\t\tsnapshot.remotes,\n\t\t\tsessionManager.getWorktreeRootMappings(),\n\t\t\tsessionManager.getWorktreeSnapshotRecords(),\n\t\t),\n\t};\n}\n\n/** A recorded checkout a resume restores, and whether it is missing here or only changed. */\ninterface RestoreTarget {\n\treadonly root: string;\n\treadonly snapshot: WorktreeSnapshot;\n\treadonly absent: boolean;\n\t/** Whether the session's working directory is inside it, so the session cannot continue without it. */\n\treadonly runsHere: boolean;\n}\n\n/** What a resume does about the recorded checkouts that are gone or changed here. */\ninterface RestorePlan {\n\t/** Checkouts the session works in, which the resume restores together or not at all. */\n\treadonly required: readonly RestoreTarget[];\n\t/** Every other checkout the resume restores, each on its own, so that one that cannot be restored is left out. */\n\treadonly optional: readonly RestoreTarget[];\n\t/** The warning for each other checkout the resume continues without restoring, by its root. */\n\treadonly left: ReadonlyMap<string, ResumeNotice>;\n\t/** Why Git cannot run here, when it cannot: the checkouts the session works in are then not restored (#4733). */\n\treadonly git: GitUnavailableError | undefined;\n}\n\n/** Records that the session continues in a checkout already here, so paths follow it. */\nasync function recordReuse(sessionManager: SessionManager, mapping: WorktreeRootMapping): Promise<void> {\n\tawait sessionManager.appendWorktreeSnapshot(mapping.to, mapping.snapshotId, undefined, mapping);\n}\n\ntype SessionCheckouts = Pick<\n\tSessionManager,\n\t| \"getBranch\"\n\t| \"getWorktreeRootMappings\"\n\t| \"getWorktreeSnapshotRecords\"\n\t| \"getSessionId\"\n\t| \"loadWorktreeSnapshotRecords\"\n>;\n\n/** The session's checkouts as they are once `mapping`, not yet recorded, is. */\nfunction withMapping(sessionManager: SessionManager, mapping: WorktreeRootMapping | undefined): SessionCheckouts {\n\tif (mapping === undefined) return sessionManager;\n\treturn {\n\t\tgetBranch: () => sessionManager.getBranch(),\n\t\tgetSessionId: () => sessionManager.getSessionId(),\n\t\tgetWorktreeSnapshotRecords: () => sessionManager.getWorktreeSnapshotRecords(),\n\t\tloadWorktreeSnapshotRecords: (ids, options) => sessionManager.loadWorktreeSnapshotRecords(ids, options),\n\t\tgetWorktreeRootMappings: () => [...sessionManager.getWorktreeRootMappings(), mapping],\n\t};\n}\n\n/** The warning that the resume continues without restoring the checkout recorded at `root`, with the reason. */\nfunction notRestored(root: string, snapshot: WorktreeSnapshot, reason: string): ResumeNotice {\n\treturn {\n\t\ttype: \"warning\",\n\t\tmessage: `Continuing without restoring ${root} (snapshot ${snapshot.id.slice(0, 12)}): ${reason}`,\n\t};\n}\n\nfunction absentOrChanged(target: Pick<RestoreTarget, \"absent\">): string {\n\treturn target.absent ? \"it does not exist on this node\" : \"it no longer matches the snapshot\";\n}\n\n/**\n * A failure of one checkout alone, which leaves the session's other checkouts restorable: a typed resume, workspace or\n * Git failure, but not a setting that is wrong for every checkout.\n */\nfunction isCheckoutFailure(error: unknown): error is Error {\n\treturn isResumeFailure(error) && !isWorkspaceConfigError(error);\n}\n\n/** What went wrong in `error`, for a warning: the unmet preconditions' reasons, or its own message, and any failed cleanup. */\nfunction describeFailure(error: Error): string {\n\tconst detail = isResumePreconditionError(error)\n\t\t? error.problems.map((problem) => problem.why).join(\"; \")\n\t\t: error.message;\n\tconst cleanup = (error as Error & { readonly cleanupCause?: unknown }).cleanupCause;\n\treturn cleanup instanceof Error ? `${detail}; removing what it restored also failed: ${cleanup.message}` : detail;\n}\n\n/**\n * The recorded checkouts that are gone or changed here, which #4245's resume restores into fresh worktrees, except\n * those the session continues in as they are. Another checkout than the one the session works in is also left alone,\n * with a warning, when it cannot be compared with its snapshot, or when it is here and the session worked in it on this\n * node, so it continues as it is.\n */\nasync function restoreCandidates(\n\tsessionManager: SessionCheckouts,\n\tcwd: string,\n\toptions: PrepareSessionResumeOptions,\n\tneedsRestore: (snapshot: WorktreeSnapshot, root: string) => Promise<boolean>,\n\tpartial: () => Promise<ReadonlySet<string>>,\n): Promise<{ readonly targets: RestoreTarget[]; readonly left: Map<string, ResumeNotice> }> {\n\tconst targets: RestoreTarget[] = [];\n\tconst left = new Map<string, ResumeNotice>();\n\tconst checkouts = [...(await currentWorktreeSnapshots(sessionManager))].filter(\n\t\t([root]) => !options.keepInPlace?.has(root),\n\t);\n\tconst comparisons = await settleBounded(checkouts, VERIFY_CONCURRENCY, ([root, snapshot]) =>\n\t\tneedsRestore(snapshot, root),\n\t);\n\tfor (const [index, [root, snapshot]] of checkouts.entries()) {\n\t\tconst runsHere = isInside(root, cwd);\n\t\tconst comparison = comparisons[index]!;\n\t\tif (comparison.status === \"rejected\") {\n\t\t\tconst error: unknown = comparison.reason;\n\t\t\tif (runsHere || options.signal?.aborted || !isCheckoutFailure(error)) throw error;\n\t\t\tleft.set(root, notRestored(root, snapshot, `it could not be compared with the snapshot: ${error.message}`));\n\t\t\tcontinue;\n\t\t}\n\t\tif (!comparison.value) continue;\n\t\tconst absent = !(await isDirectory(root));\n\t\tif (\n\t\t\t!runsHere &&\n\t\t\t!absent &&\n\t\t\t(\n\t\t\t\tawait checkoutsWorkedHere(\n\t\t\t\t\tnew Map([[root, snapshot]]),\n\t\t\t\t\tcwd,\n\t\t\t\t\tsessionManager.getSessionId(),\n\t\t\t\t\toptions,\n\t\t\t\t\tawait partial(),\n\t\t\t\t)\n\t\t\t).has(root)\n\t\t) {\n\t\t\tleft.set(\n\t\t\t\troot,\n\t\t\t\tnotRestored(\n\t\t\t\t\troot,\n\t\t\t\t\tsnapshot,\n\t\t\t\t\t\"it changed since the snapshot, and the session worked in it on this node, so it stays as it is\",\n\t\t\t\t),\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\ttargets.push({ root, snapshot, absent, runsHere });\n\t}\n\treturn { targets, left };\n}\n\n/** How many recorded checkouts a resume compares with their snapshots at once. */\nconst VERIFY_CONCURRENCY = 4;\n\n/** `map` over `items`, at most `limit` at a time, each outcome settled in the order of `items`. */\nasync function settleBounded<T, R>(\n\titems: readonly T[],\n\tlimit: number,\n\tmap: (item: T) => Promise<R>,\n): Promise<PromiseSettledResult<R>[]> {\n\tconst outcomes: PromiseSettledResult<R>[] = [];\n\tlet next = 0;\n\tconst work = async (): Promise<void> => {\n\t\twhile (next < items.length) {\n\t\t\tconst index = next++;\n\t\t\ttry {\n\t\t\t\toutcomes[index] = { status: \"fulfilled\", value: await map(items[index]!) };\n\t\t\t} catch (reason) {\n\t\t\t\toutcomes[index] = { status: \"rejected\", reason };\n\t\t\t}\n\t\t}\n\t};\n\tawait Promise.all(Array.from({ length: Math.min(limit, items.length) }, work));\n\treturn outcomes;\n}\n\n/**\n * Restores what `plan` says into fresh worktrees with #4245's {@link resumeSessionWorktree}, recording each restore on\n * `sessionManager`, and returns the mappings it recorded. The checkouts the session works in are restored together,\n * with the mapping to the launch checkout `reused`; one that cannot be restored exactly is restored as far as it can be,\n * or recorded as left out, in `unrestored` (#4733), and only a failure that is not about a checkout refuses the resume.\n * Every other checkout is restored on its own the same way, and one whose restore is refused is reported in `failed`\n * and left out. `cwd` is where the session continues after the restore of the checkouts it works in.\n */\nasync function restorePlanned(\n\tsessionManager: SessionManager,\n\tplan: RestorePlan,\n\treused: WorktreeRootMapping | undefined,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n\tlfs: LfsDownloads,\n): Promise<{\n\trestored: WorktreeRootMapping[];\n\tfailed: ResumeNotice[];\n\t/** The notices in `failed` of checkouts whose snapshot record the session lacks (#4744). */\n\tmissingNotices: ResumeNotice[];\n\tunrestored: WorktreeUnrestored[];\n\tcwd: string | undefined;\n}> {\n\tconst outcome = {\n\t\trestored: [] as WorktreeRootMapping[],\n\t\tfailed: [] as ResumeNotice[],\n\t\tunrestored: [] as WorktreeUnrestored[],\n\t\tcwd: undefined as string | undefined,\n\t\tmissing: new Set<string>(),\n\t\tmissingNotices: [] as ResumeNotice[],\n\t};\n\tlet restored = false;\n\tconst restore = async (\n\t\ttargets: readonly RestoreTarget[],\n\t\tpending: WorktreeRootMapping | undefined,\n\t\tbeforeRecord?: () => Promise<void>,\n\t) => {\n\t\trestored = true;\n\t\tconst git = plan.git;\n\t\tfor (const target of targets) {\n\t\t\tif (git === undefined) {\n\t\t\t\toptions.onProgress?.(`Restoring ${target.root} from snapshot ${target.snapshot.id.slice(0, 12)}`);\n\t\t\t}\n\t\t}\n\t\tconst restoring = new Set(targets.map((target) => target.root));\n\t\tconst resumed = await resumeSessionWorktree(sessionManager, {\n\t\t\tsettings: options.settings,\n\t\t\tstoreDir,\n\t\t\tsignal: options.signal,\n\t\t\tpendingMappings: pending === undefined ? [] : [pending],\n\t\t\tkeepInPlace: new Set(\n\t\t\t\t[...(await currentWorktreeSnapshots(withMapping(sessionManager, pending))).keys()].filter(\n\t\t\t\t\t(root) => !restoring.has(root),\n\t\t\t\t),\n\t\t\t),\n\t\t\t...(git === undefined ? {} : { cannotRestore: new Map(targets.map((target) => [target.root, git])) }),\n\t\t\tfallbackCwd: options.launchCwd,\n\t\t\tskipMissingRecords: true,\n\t\t\tpool: options.pool ?? { maxIdlePerRepository: DEFAULT_MAX_IDLE_PER_REPOSITORY },\n\t\t\tdeferLfs: lfs.start,\n\t\t\tbeforeRecord,\n\t\t});\n\t\tfor (const missing of resumed.missingRecords ?? []) {\n\t\t\tif (outcome.missing.has(missing.root)) continue;\n\t\t\toutcome.missing.add(missing.root);\n\t\t\tconst notice: ResumeNotice = { type: \"warning\", message: formatMissingRecordNotice(missing) };\n\t\t\toutcome.failed.push(notice);\n\t\t\toutcome.missingNotices.push(notice);\n\t\t}\n\t\tif (resumed.status === \"none\") return undefined;\n\t\tif (resumed.status === \"restored\") outcome.restored.push(...resumed.mappings);\n\t\toutcome.unrestored.push(...resumed.unrestored.map((checkout) => checkout.record));\n\t\treturn resumed.cwd;\n\t};\n\tif (plan.required.length > 0 || reused !== undefined) outcome.cwd = await restore(plan.required, reused);\n\t// Optional checkouts restore at once, as many as verification compares (#4748); each records its outcome only after\n\t// the one before it has, so the session lists them, and their notices, in the order a serial resume would.\n\tlet previous = Promise.resolve();\n\tconst turns = plan.optional.map((target) => {\n\t\tconst before = previous;\n\t\tlet done!: () => void;\n\t\tprevious = new Promise<void>((resolveTurn) => {\n\t\t\tdone = resolveTurn;\n\t\t});\n\t\treturn { target, before, done };\n\t});\n\tconst outcomes = await settleBounded(turns, VERIFY_CONCURRENCY, async ({ target, before, done }) => {\n\t\ttry {\n\t\t\tawait restore([target], undefined, () => before);\n\t\t} catch (error) {\n\t\t\tawait before;\n\t\t\tif (options.signal?.aborted || !isCheckoutFailure(error)) throw error;\n\t\t\toutcome.failed.push(\n\t\t\t\tnotRestored(\n\t\t\t\t\ttarget.root,\n\t\t\t\t\ttarget.snapshot,\n\t\t\t\t\t`${absentOrChanged(target)}, and restoring it failed: ${describeFailure(error)}`,\n\t\t\t\t),\n\t\t\t);\n\t\t} finally {\n\t\t\tawait before;\n\t\t\tdone();\n\t\t}\n\t});\n\tfor (const result of outcomes) if (result.status === \"rejected\") throw result.reason;\n\t// With nothing to restore, no restore listed the checkouts whose snapshot record is missing (#4744).\n\tif (!restored) {\n\t\tfor (const missing of await missingSnapshotRecords(sessionManager)) {\n\t\t\tconst notice: ResumeNotice = { type: \"warning\", message: formatMissingRecordNotice(missing) };\n\t\t\toutcome.failed.push(notice);\n\t\t\toutcome.missingNotices.push(notice);\n\t\t}\n\t}\n\treturn outcome;\n}\n\n/**\n * Builds the blueprints of the worktrees Atomic restored for the session: each worktree this resume restored\n * (`restoredNow`), and again each worktree restored earlier whose last build failed or never finished. Later changes\n * to an earlier worktree's files are the session's own work. Every other checkout the session works in is only\n * described to the agent.\n */\nasync function setUpCheckoutBlueprints(\n\tsessionManager: SessionManager,\n\trestoredNow: ReadonlySet<string>,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n\tlfs = new LfsDownloads(),\n): Promise<ResumedBlueprints> {\n\t// The warnings of LFS downloads that end after their restores were recorded come with the build's (#5099).\n\tif (options.blueprints === \"skip\") return { ...SKIPPED_BLUEPRINTS, notices: await lfs.notices(restoredNow) };\n\tconst restoredHere: BlueprintCheckout[] = [];\n\tconst earlier: BlueprintCheckout[] = [];\n\tconst inPlace: BlueprintCheckout[] = [];\n\tfor (const [root, snapshot] of await currentWorktreeSnapshots(sessionManager)) {\n\t\tconst checkout = checkoutOf(sessionManager, root, snapshot);\n\t\tif (restoredNow.has(root)) restoredHere.push({ ...checkout, ready: lfs.ready(root) });\n\t\telse if (isInside(storeDir, root)) {\n\t\t\tif (!(await pooledWorktreeOwnedElsewhere(storeDir, root, sessionManager.getSessionId())))\n\t\t\t\tearlier.push({ ...checkout, ready: finishPendingLfs(lfs, root, options.signal) });\n\t\t} else if (await isDirectory(root)) inPlace.push(checkout);\n\t}\n\t// A worktree this process is building already is joined, not built again (#4748): its tools wait for that build.\n\tconst joined = [...restoredHere, ...earlier].filter((checkout) => buildInProgress(checkout.root) !== undefined);\n\tconst toBuild = restoredHere.filter((checkout) => !joined.includes(checkout));\n\tconst candidates = earlier.filter((checkout) => !joined.includes(checkout));\n\t// Claimed before anything is awaited, so a resume that starts meanwhile in this process joins this one.\n\tconst { promise: settled, resolve: settle } = Promise.withResolvers<undefined>();\n\tconst claimed = [...toBuild, ...candidates].map((checkout) => resolve(checkout.root));\n\tfor (const root of claimed) buildsInProgress.set(root, settled);\n\ttry {\n\t\tawait Promise.all(joined.map((checkout) => buildInProgress(checkout.root)));\n\t\t// Another process's build of one of them is waited for, or the steps of one whose process died are stopped,\n\t\t// before the ledger says which need building.\n\t\t// Settling another build never fails the resume: a failure to read or clean up its lock is a warning.\n\t\tconst settled = await settleOtherBuilds(storeDir, claimed, {\n\t\t\tsignal: options.signal,\n\t\t\tonWait: (root, message) => {\n\t\t\t\toptions.onProgress?.(message);\n\t\t\t\tannounceBlueprintBuildWaiting(root, message);\n\t\t\t},\n\t\t}).catch((error: unknown) => {\n\t\t\tif (options.signal?.aborted) throw error;\n\t\t\treturn {\n\t\t\t\twarnings: [\n\t\t\t\t\t`Could not check for an earlier blueprint build of these worktrees (${error instanceof Error ? describeFailure(error) : String(error)}); building them anyway.`,\n\t\t\t\t],\n\t\t\t\tcancelled: new Set<string>(),\n\t\t\t\trelease: async () => {},\n\t\t\t};\n\t\t});\n\t\t// No other process builds them until this build settled, and then the ledger says whether they still need it.\n\t\tlet built: ResumedBlueprints;\n\t\tconst unlocked: string[] = [];\n\t\ttry {\n\t\t\tconst retried = await checkoutsNeedingRebuild(candidates, storeDir);\n\t\t\tconst restored = [...toBuild, ...retried];\n\t\t\tbuilt = await withBuildLocks(\n\t\t\t\tstoreDir,\n\t\t\t\trestored.map((checkout) => checkout.root),\n\t\t\t\t() =>\n\t\t\t\t\tsetUpResumedBlueprints({\n\t\t\t\t\t\trestored,\n\t\t\t\t\t\tinPlace,\n\t\t\t\t\t\tearlier: [...joined, ...candidates.filter((checkout) => !retried.includes(checkout))],\n\t\t\t\t\t\tconfig: { ...options.blueprint, storeDir },\n\t\t\t\t\t\tsignal: options.signal,\n\t\t\t\t\t}),\n\t\t\t\t(message) => unlocked.push(message),\n\t\t\t);\n\t\t} finally {\n\t\t\tawait settled.release();\n\t\t}\n\t\t// The warnings of LFS downloads that end after their restores were recorded come with the build's (#5099).\n\t\tconst downloads = await lfs.notices([...restoredHere, ...earlier].map((checkout) => checkout.root));\n\t\tconst warnings = [...settled.warnings, ...unlocked].map((message) => ({ type: \"warning\" as const, message }));\n\t\treturn { ...built, notices: [...warnings, ...downloads, ...built.notices] };\n\t} finally {\n\t\tfor (const root of claimed) if (buildsInProgress.get(root) === settled) buildsInProgress.delete(root);\n\t\tsettle(undefined);\n\t}\n}\n\n/** `promise`, or `signal`'s reason once it aborts first. */\nfunction untilSettled(promise: Promise<void>, signal: AbortSignal): Promise<void> {\n\tif (signal.aborted) return Promise.reject(signal.reason);\n\treturn new Promise<void>((resolvePromise, reject) => {\n\t\tconst abort = () => reject(signal.reason);\n\t\tsignal.addEventListener(\"abort\", abort, { once: true });\n\t\tpromise.then(\n\t\t\t() => {\n\t\t\t\tsignal.removeEventListener(\"abort\", abort);\n\t\t\t\tresolvePromise();\n\t\t\t},\n\t\t\t(error: unknown) => {\n\t\t\t\tsignal.removeEventListener(\"abort\", abort);\n\t\t\t\treject(error);\n\t\t\t},\n\t\t);\n\t});\n}\n\n/** The blueprint builds this process runs, by the restored worktree they build, each settling once its build has. */\nconst buildsInProgress = new Map<string, Promise<undefined>>();\n\nasync function setAsideCancelledBuilds(\n\tsessionManager: SessionCheckouts,\n\tstoreDir: string,\n\toptions: PrepareSessionResumeOptions,\n): Promise<ResumeNotice[]> {\n\tif (process.platform === \"win32\" || options.blueprints === \"skip\" || !options.settings.enabled) return [];\n\tconst roots: string[] = [];\n\tfor (const root of (await currentWorktreeSnapshots(sessionManager)).keys()) {\n\t\tif (!isInside(storeDir, root) || options.keepInPlace?.has(root) || buildInProgress(root) !== undefined) continue;\n\t\tif (!(await pooledWorktreeOwnedElsewhere(storeDir, root, sessionManager.getSessionId()))) roots.push(root);\n\t}\n\tif (roots.length === 0) return [];\n\tconst notices: ResumeNotice[] = [];\n\tconst setAside = async (build: CancelledBuild): Promise<boolean> => {\n\t\tconst running = `A step of the cancelled build may still be running in ${build.root}; its log is ${build.logs}.`;\n\t\ttry {\n\t\t\tawait setAsideWorktree(storeDir, build.root, { startedAt: build.startedAt, logs: build.logs });\n\t\t\tnotices.push({\n\t\t\t\ttype: \"warning\",\n\t\t\t\tmessage: `The blueprint build of ${build.root} did not finish, so it was cancelled and the worktree set aside; a fresh worktree is restored and built instead. ${running}`,\n\t\t\t});\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tconst reason = error instanceof Error ? error.message : String(error);\n\t\t\tnotices.push({\n\t\t\t\ttype: \"warning\",\n\t\t\t\tmessage: `The blueprint build of ${build.root} did not finish, so it was cancelled; a fresh worktree is restored and built instead, but the worktree could not be set aside (${reason.slice(0, 200)}), so another Atomic process may still use it. ${running}`,\n\t\t\t});\n\t\t\treturn false;\n\t\t}\n\t};\n\tconst warnings = await cancelledBuilds(\n\t\tstoreDir,\n\t\troots,\n\t\t{\n\t\t\tsignal: options.signal,\n\t\t\tonWait: (root, message) => {\n\t\t\t\toptions.onProgress?.(message);\n\t\t\t\tannounceBlueprintBuildWaiting(root, message);\n\t\t\t},\n\t\t},\n\t\tsetAside,\n\t);\n\treturn [...warnings.map((message) => ({ type: \"warning\" as const, message })), ...notices];\n}\n\n/** The build this process runs of the worktree at `root`, if one runs. */\nfunction buildInProgress(root: string): Promise<undefined> | undefined {\n\treturn buildsInProgress.get(resolve(root));\n}\n\n/** Whether a resume of `sessionManager` joins a blueprint build this process already runs in one of its worktrees. */\nasync function joinsBuildInProgress(sessionManager: SessionManager): Promise<boolean> {\n\treturn [...(await currentWorktreeSnapshots(sessionManager)).keys()].some(\n\t\t(root) => buildInProgress(root) !== undefined,\n\t);\n}\n\n/**\n * Finishes the LFS download a resume interrupted, or another process still runs, in the restored worktree at `root`,\n * if one is pending (#5099), so its blueprint runs on the files' content; settles once that is done.\n */\nfunction finishPendingLfs(lfs: LfsDownloads, root: string, signal: AbortSignal | undefined): Promise<void> {\n\tlfs.start(root, async () => (await (await pendingLfsDownload(root, { signal }))?.()) ?? []);\n\treturn lfs.ready(root);\n}\n\n/**\n * Whether the repository of the checkout at `root` holds the commit that records `snapshot`. That commit is\n * content-addressed and written only where Atomic captured exactly that state, so it tells the checkout a session\n * worked in, even after it changed, from another checkout of the same repository at the same path on another node,\n * unless Atomic captured the same state there too. A checkout that is not a repository, or a node without Git, does\n * not hold it.\n */\nexport async function holdsSnapshotCommit(\n\tsnapshot: WorktreeSnapshot,\n\troot: string,\n\tsignal?: AbortSignal,\n): Promise<boolean> {\n\ttry {\n\t\tconst { exitCode } = await runGit([\"cat-file\", \"-e\", `${snapshot.snapshot}^{commit}`], {\n\t\t\tcwd: root,\n\t\t\tsignal,\n\t\t\tallowExitCodes: [1, 128],\n\t\t});\n\t\treturn exitCode === 0;\n\t} catch (error) {\n\t\tif (isGitUnavailableError(error)) return false;\n\t\tthrow error;\n\t}\n}\n\n/**\n * Whether session `sessionId` worked in the checkout at `root`: its repository holds the commit of `snapshot`, or,\n * once `git gc` pruned that commit, keeps the session's snapshot ref for the checkout (#4923).\n */\nasync function workedInCheckout(\n\tsnapshot: WorktreeSnapshot,\n\troot: string,\n\tsessionId: string,\n\tsignal: AbortSignal | undefined,\n): Promise<boolean> {\n\treturn (\n\t\t(await holdsSnapshotCommit(snapshot, root, signal)) ||\n\t\t(await holdsSessionSnapshotRef(sessionId, snapshot, root, signal))\n\t);\n}\n\n/**\n * Where a woken session continues. Each checkout it recorded that it worked in on this node stays as it is, since work\n * done in it after the release belongs to the session, and a blueprint build that failed or did not finish in a worktree\n * this node restored for it runs again. Every other checkout, as when it is missing or another clone sits at its path on another\n * node, is prepared as `/resume` prepares it. When every checkout stays, it continues in the directory it last worked\n * in, after the restores it recorded, which `reopen` opens it in.\n */\nexport async function continueSessionWhereItWorked(\n\topened: SessionManager,\n\toptions: PrepareSessionResumeOptions,\n\treopen: (cwd: string) => Promise<SessionManager> = (cwd) =>\n\t\topened.openSessionById(opened.getSessionId(), cwd, undefined, { history: \"tail\" }),\n): Promise<SessionManager> {\n\tconst storeDir = resolveStoreDir(options);\n\t// The session holds the pooled worktrees it owns before anything else, so no eviction removes one while its\n\t// blueprints are set up again, and until it closes (#4748).\n\tawait holdSessionWorktrees(opened, opened, storeDir, options.signal);\n\ttry {\n\t\toptions.signal?.throwIfAborted();\n\t\tconst cwd = await mapRestoredPathAsync(opened.getCwd(), opened.getWorktreeRootMappings());\n\t\tconst checkouts = await currentWorktreeSnapshots(opened);\n\t\tconst cancelled = await setAsideCancelledBuilds(opened, storeDir, options);\n\t\tif (cancelled.length > 0) options.onNotices?.(cancelled);\n\t\tconst own = await checkoutsWorkedHere(\n\t\t\tcheckouts,\n\t\t\tcwd,\n\t\t\topened.getSessionId(),\n\t\t\toptions,\n\t\t\tawait partialRestores(opened, options),\n\t\t);\n\t\tif (own.size < checkouts.size) {\n\t\t\tconst prepared = await prepareSessionResume(opened, { ...options, keepInPlace: own });\n\t\t\tif (prepared.status !== \"ready\") {\n\t\t\t\tawait holdSessionWorktrees(opened, opened, storeDir);\n\t\t\t\treturn opened;\n\t\t\t}\n\t\t\tif (prepared.blueprintNotices.length > 0) options.onNotices?.(prepared.blueprintNotices);\n\t\t\treturn prepared.sessionManager;\n\t\t}\n\t\tif (checkouts.size === 0) {\n\t\t\tawait describeBlueprintsInPlace(opened, storeDir, options);\n\t\t} else {\n\t\t\tconst blueprints = await setUpCheckoutBlueprints(opened, new Set(), storeDir, options);\n\t\t\tawait recordBlueprintContext(opened, blueprints.context);\n\t\t\tif (blueprints.notices.length > 0) options.onNotices?.(blueprints.notices);\n\t\t}\n\t\tconst continuing = cwd === resolve(opened.getCwd()) ? opened : await reopen(cwd);\n\t\tawait holdSessionWorktrees(opened, continuing, storeDir);\n\t\treturn continuing;\n\t} catch (error) {\n\t\tawait releaseSessionWorktrees(opened);\n\t\tthrow error;\n\t}\n}\n\n/**\n * The roots of the `checkouts` a session recorded that are here as checkouts it worked in on this node, as it left them\n * or changed since: a worktree this node restored for it, or a checkout whose repository holds the commit of its latest\n * snapshot or the session's snapshot ref for it (#4923). A pooled worktree counts only while session `sessionId` owns it: another session that took the slot works\n * in it now (#4748). The checkout the session works in counts only while its working directory `cwd` is here too.\n */\nasync function checkoutsWorkedHere(\n\tcheckouts: ReadonlyMap<string, WorktreeSnapshot>,\n\tcwd: string,\n\tsessionId: string,\n\toptions: PrepareSessionResumeOptions,\n\tpartial: ReadonlySet<string> = new Set(),\n): Promise<Set<string>> {\n\tconst storeDir = resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n\tconst own = new Set<string>();\n\tfor (const [root, snapshot] of checkouts) {\n\t\tif (!(await pathExists(isInside(root, cwd) ? cwd : root))) continue;\n\t\tif (await worktreeSetAside(storeDir, root)) continue;\n\t\tconst holder = await pooledWorktreeHolder(storeDir, root);\n\t\tif (holder !== \"unpooled\") {\n\t\t\t// Slots share their repository's object store, so only the pool record tells whose work a slot holds, and a\n\t\t\t// slot the session could not hold, or lost while stalled, is not its to continue in (#4830).\n\t\t\tconst owned = !(await pooledWorktreeOwnedElsewhere(storeDir, root, sessionId));\n\t\t\tif (owned && !partial.has(resolve(root))) own.add(root);\n\t\t\tcontinue;\n\t\t}\n\t\tconst restoredHere = isInside(storeDir, root) && !partial.has(resolve(root));\n\t\tif (restoredHere || (await workedInCheckout(snapshot, root, sessionId, options.signal))) own.add(root);\n\t}\n\treturn own;\n}\n\n/**\n * The worktrees a resume restored with less than their snapshot (#4733) that are still exactly as it left them: the\n * session recorded no snapshot there since, and their HEAD and files are what the restore put there. The next resume\n * tries the snapshot again instead of keeping them. A worktree changed since, even by hand, is the session's work and\n * stays; one that cannot be compared stays too.\n */\nasync function partialRestores(\n\tsessionManager: SessionCheckouts,\n\toptions: Pick<PrepareSessionResumeOptions, \"settings\" | \"signal\">,\n): Promise<Set<string>> {\n\tconst current = await currentWorktreeSnapshots(sessionManager);\n\tconst partial = new Set<string>();\n\tfor (const mapping of sessionManager.getWorktreeRootMappings()) {\n\t\tconst degraded = mapping.degraded;\n\t\tconst snapshot = current.get(mapping.to);\n\t\tif (degraded === undefined || snapshot?.id !== mapping.snapshotId || !(await pathExists(mapping.to))) continue;\n\t\tconst restored = {\n\t\t\tremotes: [...snapshot.remotes],\n\t\t\thead: degraded.head,\n\t\t\ttree: degraded.tree,\n\t\t\tenvHash: snapshot.envHash,\n\t\t};\n\t\ttry {\n\t\t\tawait verifyWorktree(restored, mapping.to, { settings: options.settings, signal: options.signal });\n\t\t\tpartial.add(resolve(mapping.to));\n\t\t} catch (error) {\n\t\t\tif (options.signal?.aborted) throw error;\n\t\t}\n\t}\n\treturn partial;\n}\n/**\n * Whether resuming in `root` restores `snapshot` into a fresh worktree: the checkout is gone, is not a repository of\n * the recorded tree, or no longer matches it. A path that cannot be read fails with its typed `unreadable-path` error\n * instead, since restoring would hide it. A checkout whose HEAD only moved forward over the recorded tree, as after\n * committing the recorded edits, continues in place, as #4245's resume decides. Read-only.\n */\nexport async function worktreeNeedsRestore(\n\tsnapshot: WorktreeSnapshot,\n\troot: string,\n\toptions: VerifyWorktreeOptions,\n): Promise<boolean> {\n\ttry {\n\t\tawait verifyWorktree(snapshot, root, options);\n\t\treturn false;\n\t} catch (error) {\n\t\tif (isWorkspaceDriftError(error)) return !(await isHeadOnlyAdvance(error, options.signal));\n\t\tif (isWorkspaceSnapshotError(error) && error.code !== \"unreadable-path\") return true;\n\t\tthrow error;\n\t}\n}\n\n/** The outcome of starting or provisioning Git once for a resume: the typed reason it cannot run, or undefined. */\ninterface GitProbe {\n\treadonly unavailable: GitUnavailableError | undefined;\n}\n\n/**\n * Decides what the resume does about the `candidates` that are gone or changed here, before anything is written. The\n * precondition of restoring them on this node is that Git can be started or provisioned (`git`, the probe's typed\n * failure). When it is unmet, the checkouts the session works in are not restored and the session continues without\n * them, with a notice and a record in the session (#4733); any other checkout is left out with a warning. A blueprint\n * is never a precondition.\n */\nfunction planRestores(\n\tcandidates: { readonly targets: readonly RestoreTarget[]; readonly left: ReadonlyMap<string, ResumeNotice> },\n\tgit: GitUnavailableError | undefined,\n): RestorePlan {\n\tconst required = candidates.targets.filter((target) => target.runsHere);\n\tconst others = candidates.targets.filter((target) => !target.runsHere);\n\tconst left = new Map(candidates.left);\n\tconst optional: RestoreTarget[] = [];\n\tfor (const target of others) {\n\t\tif (git) {\n\t\t\tleft.set(\n\t\t\t\ttarget.root,\n\t\t\t\tnotRestored(\n\t\t\t\t\ttarget.root,\n\t\t\t\t\ttarget.snapshot,\n\t\t\t\t\t`${absentOrChanged(target)}, and Git is unavailable here (${git.code}), which restoring it needs`,\n\t\t\t\t),\n\t\t\t);\n\t\t} else {\n\t\t\toptional.push(target);\n\t\t}\n\t}\n\treturn { required, optional, left, git };\n}\n\n/**\n * Whether a restored worktree is trusted to run its blueprints outside the CLI: the decision saved in `agentDir` for\n * that path, else the default trust setting.\n */\nexport function savedProjectTrust(\n\tagentDir: string,\n\tsettings: Pick<SettingsManager, \"getDefaultProjectTrust\">,\n): (worktree: string) => boolean {\n\tconst trustStore = new ProjectTrustStore(agentDir);\n\treturn (worktree) => trustStore.get(worktree) ?? settings.getDefaultProjectTrust() === \"always\";\n}\n\nexport function savedProjectTrustAsync(\n\tagentDir: string,\n\tsettings: Pick<SettingsManager, \"getDefaultProjectTrust\">,\n): (worktree: string) => Promise<boolean> {\n\tconst trustStore = new ProjectTrustStore(agentDir);\n\treturn async (worktree) => (await trustStore.getAsync(worktree)) ?? settings.getDefaultProjectTrust() === \"always\";\n}\n\n/** Where restored worktrees, the blueprint build ledger and logs live for the agent directory `agentDir`. */\nexport function resumeStoreDir(agentDir: string): string {\n\treturn join(agentDir, \"worktree-snapshots\");\n}\n\nfunction resolveStoreDir(options: Pick<PrepareSessionResumeOptions, \"storeDir\">): string {\n\treturn resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n}\n\n/**\n * The options a resume from `launchCwd` needs: snapshot settings and the blueprint build configuration from\n * `settingsManager`, and the worktree store of `agentDir`. A session without a UI (`interactive` false; default true)\n * starts its first turn while the build runs unless `resume.waitForBlueprint` says otherwise.\n */\nexport function sessionResumeOptions(\n\tentryPoint: ResumeEntryPoint,\n\tlaunchCwd: string,\n\tagentDir: string,\n\tsettingsManager: Pick<\n\t\tSettingsManager,\n\t\t\"getWorktreeSnapshotSettings\" | \"getWorktreePoolSettings\" | \"getResumeSetupCommand\" | \"getResumeWaitForBlueprint\"\n\t>,\n\ttrusted: (worktree: string) => boolean | Promise<boolean>,\n\tinteractive = true,\n): PrepareSessionResumeOptions {\n\treturn {\n\t\tentryPoint,\n\t\tlaunchCwd,\n\t\tsettings: settingsManager.getWorktreeSnapshotSettings(),\n\t\tpool: settingsManager.getWorktreePoolSettings(),\n\t\tblueprint: { agentDir, setupCommand: settingsManager.getResumeSetupCommand(), trusted },\n\t\tstoreDir: resumeStoreDir(agentDir),\n\t\twaitForBlueprint: settingsManager.getResumeWaitForBlueprint(interactive),\n\t};\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import type { AgentMessage, ThinkingLevel } from "@bastani/atomic-agent-core";
2
- import type { Message, ThinkingBudgets } from "@bastani/atomic-ai";
2
+ import { type Message, type ThinkingBudgets } from "@bastani/atomic-ai";
3
+ import type { Api, Model } from "@bastani/atomic-ai/compat";
3
4
  /**
4
5
  * The message a resumed session's history ends with, as its last request before the exit sent it or as that request's
5
6
  * reply. A resume appends blueprint context before the session starts; that was never sent, so it is not part of it.
@@ -19,6 +20,31 @@ export interface CacheCheckpointResult {
19
20
  * checkpoint is answered. The marked message is a copy; the transcript is not changed.
20
21
  */
21
22
  export declare function withCacheCheckpoint(messages: readonly AgentMessage[], rows: readonly (Message | undefined)[], converted: Message[], checkpoint: AgentMessage): CacheCheckpointResult;
23
+ /** What the first request after a resume would send, split by where it comes from. */
24
+ export interface ResumedRequest {
25
+ model: Model<Api>;
26
+ thinkingLevel: ThinkingLevel;
27
+ thinkingBudgets: ThinkingBudgets | undefined;
28
+ /** Whether requests send images as text because image reading is disabled. */
29
+ blockImages: boolean;
30
+ /** The restored history, through the restored checkpoint. */
31
+ history: readonly AgentMessage[];
32
+ /** What only the resume added after it: blueprint context, notices, prompt updates. */
33
+ resumeOnly: readonly AgentMessage[];
34
+ /** The input of the request itself. */
35
+ prompt: readonly AgentMessage[];
36
+ /** The context right after an automatic clear, with what the resume added carried over. */
37
+ cleared: readonly AgentMessage[];
38
+ }
39
+ /**
40
+ * Whether to clear the context before the first request after a resume. Near the context window, what only the resume
41
+ * added can leave too little room for the thinking budget the restored history was sent with, so the request would go
42
+ * out with a lower one and the provider would read the whole history again. A clear first keeps the budget, when:
43
+ * the restored history's last reply was sent with a fixed budget on this model and level; the request would change
44
+ * that budget; the history and the input alone would not; and the cleared context with the resume's additions and
45
+ * the input keeps the whole requested budget.
46
+ */
47
+ export declare function clearsForResumedBudget(request: ResumedRequest): boolean;
22
48
  /**
23
49
  * The thinking budgets a resumed session continues with. While it resumes on the model and thinking level of its last
24
50
  * recorded reply, that reply's budget stays, as it would in a session that kept running: a changed settings file or a
@@ -1 +1 @@
1
- {"version":3,"file":"resume-cache-checkpoint.d.ts","sourceRoot":"","sources":["../../src/core/resume-cache-checkpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,KAAK,EAAoB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrF;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,GAAG,YAAY,GAAG,SAAS,CAQnG;AASD,MAAM,WAAW,qBAAqB;IACrC,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB,uHAAuH;IACvH,IAAI,EAAE,OAAO,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAClC,QAAQ,EAAE,SAAS,YAAY,EAAE,EACjC,IAAI,EAAE,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,EAAE,EACtC,SAAS,EAAE,OAAO,EAAE,EACpB,UAAU,EAAE,YAAY,G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