@bastani/atomic 0.9.74-alpha.1 → 0.9.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (383) hide show
  1. package/CHANGELOG.md +162 -0
  2. package/dist/builtin/intercom/package.json +2 -2
  3. package/dist/builtin/mcp/package.json +1 -1
  4. package/dist/builtin/subagents/CHANGELOG.md +21 -0
  5. package/dist/builtin/subagents/package.json +3 -3
  6. package/dist/builtin/subagents/skills/agent-browser/SKILL.md +8 -10
  7. package/dist/builtin/subagents/skills/agent-desktop/SKILL.md +9 -5
  8. package/dist/builtin/subagents/src/extension/index.bundle.mjs +7 -1
  9. package/dist/builtin/web-access/package.json +2 -2
  10. package/dist/builtin/workflows/CHANGELOG.md +80 -0
  11. package/dist/builtin/workflows/README.md +5 -2
  12. package/dist/builtin/workflows/builtin/{chunk-m8eg152f.js → chunk-89we7r4p.js} +1 -1
  13. package/dist/builtin/workflows/builtin/{chunk-a4fdm2cw.js → chunk-8yfssw01.js} +1 -1
  14. package/dist/builtin/workflows/builtin/{chunk-774myqzs.js → chunk-v8mb0005.js} +366 -45
  15. package/dist/builtin/workflows/builtin/{chunk-d5cxskkp.js → chunk-wh2p4qjg.js} +2 -2
  16. package/dist/builtin/workflows/builtin/goal.js +2 -2
  17. package/dist/builtin/workflows/builtin/index.d.ts +10 -0
  18. package/dist/builtin/workflows/builtin/index.js +4 -4
  19. package/dist/builtin/workflows/builtin/open-claude-design.d.ts +12 -0
  20. package/dist/builtin/workflows/builtin/open-claude-design.js +1 -1
  21. package/dist/builtin/workflows/builtin/ralph.js +2 -2
  22. package/dist/builtin/workflows/package.json +2 -2
  23. package/dist/builtin/workflows/skills/impeccable/SKILL.md +4 -4
  24. package/dist/builtin/workflows/skills/impeccable/reference/android.md +1 -1
  25. package/dist/builtin/workflows/skills/impeccable/reference/audit.md +2 -2
  26. package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +1 -1
  27. package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +1 -1
  28. package/dist/builtin/workflows/skills/impeccable/reference/degraded/documenter.md +4 -4
  29. package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +2 -2
  30. package/dist/builtin/workflows/skills/impeccable/reference/degraded/manual-edit-applier.md +3 -2
  31. package/dist/builtin/workflows/skills/impeccable/reference/distill.md +3 -3
  32. package/dist/builtin/workflows/skills/impeccable/reference/doctor.md +1 -1
  33. package/dist/builtin/workflows/skills/impeccable/reference/document.md +3 -3
  34. package/dist/builtin/workflows/skills/impeccable/reference/harden.md +19 -0
  35. package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +15 -8
  36. package/dist/builtin/workflows/skills/impeccable/reference/init.md +2 -0
  37. package/dist/builtin/workflows/skills/impeccable/reference/live.md +8 -6
  38. package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +4 -4
  39. package/dist/builtin/workflows/skills/impeccable/reference/optimize.md +0 -1
  40. package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +1 -1
  41. package/dist/builtin/workflows/skills/impeccable/scripts/VERSION +1 -1
  42. package/dist/builtin/workflows/skills/impeccable/scripts/command-metadata.json +2 -2
  43. package/dist/builtin/workflows/skills/impeccable/scripts/engine-checksums.txt +9 -0
  44. package/dist/builtin/workflows/skills/impeccable/scripts/impeccable +98 -44
  45. package/dist/builtin/workflows/skills/impeccable/scripts/impeccable.cmd +101 -34
  46. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-ignores.js +6 -2
  47. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-session.js +4 -1
  48. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +444 -144
  49. package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +3 -1
  50. package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +2 -2
  51. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5.md +13 -11
  52. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_1.md +10 -8
  53. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_2.md +143 -0
  54. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_haiku_5_5.md +11 -7
  55. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_4_8.md +3 -3
  56. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5.md +6 -2
  57. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5_5.md +7 -7
  58. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5.md +2 -2
  59. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5_5.md +3 -3
  60. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_5.md +2 -2
  61. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_6.md +2 -2
  62. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6.md +6 -5
  63. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_sol.md +4 -4
  64. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_terra.md +2 -2
  65. package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +4 -3
  66. package/dist/builtin/workflows/skills/skill-creator/scripts/aggregate_benchmark.py +0 -0
  67. package/dist/builtin/workflows/skills/skill-creator/scripts/generate_report.py +0 -0
  68. package/dist/builtin/workflows/skills/skill-creator/scripts/improve_description.py +0 -0
  69. package/dist/builtin/workflows/skills/skill-creator/scripts/package_skill.py +0 -0
  70. package/dist/builtin/workflows/skills/skill-creator/scripts/quick_validate.py +0 -0
  71. package/dist/builtin/workflows/skills/skill-creator/scripts/run_eval.py +0 -0
  72. package/dist/builtin/workflows/skills/skill-creator/scripts/run_loop.py +0 -0
  73. package/dist/builtin/workflows/skills/unslop/SKILL.md +15 -34
  74. package/dist/builtin/workflows/src/durable/journal/memory-run-journal.d.ts +1 -0
  75. package/dist/builtin/workflows/src/durable/journal/values.d.ts +2 -0
  76. package/dist/builtin/workflows/src/extension/index.bundle.mjs +809 -410
  77. package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +695 -305
  78. package/dist/builtin/workflows/src/index.js +685 -295
  79. package/dist/builtin/workflows/src/local-worker-entry.mjs +695 -305
  80. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +6 -6
  81. package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +2 -2
  82. package/dist/builtin/workflows/src/shared/serializable-error-families.d.ts +2 -0
  83. package/dist/bun/app-host-modules.d.ts +1 -1
  84. package/dist/bun/app-host-modules.d.ts.map +1 -1
  85. package/dist/bun/app-host-modules.js.map +1 -1
  86. package/dist/bun/internal-workflow-worker.d.ts +2 -0
  87. package/dist/bun/internal-workflow-worker.d.ts.map +1 -1
  88. package/dist/bun/internal-workflow-worker.js +2 -1
  89. package/dist/bun/internal-workflow-worker.js.map +1 -1
  90. package/dist/codemode-worker.js +2 -0
  91. package/dist/config.d.ts +8 -0
  92. package/dist/config.d.ts.map +1 -1
  93. package/dist/config.js +14 -0
  94. package/dist/config.js.map +1 -1
  95. package/dist/core/agent-session-bash.d.ts.map +1 -1
  96. package/dist/core/agent-session-bash.js +2 -1
  97. package/dist/core/agent-session-bash.js.map +1 -1
  98. package/dist/core/agent-session-blueprint-environment.d.ts +10 -0
  99. package/dist/core/agent-session-blueprint-environment.d.ts.map +1 -0
  100. package/dist/core/agent-session-blueprint-environment.js +28 -0
  101. package/dist/core/agent-session-blueprint-environment.js.map +1 -0
  102. package/dist/core/agent-session-events.d.ts.map +1 -1
  103. package/dist/core/agent-session-events.js +2 -0
  104. package/dist/core/agent-session-events.js.map +1 -1
  105. package/dist/core/agent-session-methods.d.ts +1 -0
  106. package/dist/core/agent-session-methods.d.ts.map +1 -1
  107. package/dist/core/agent-session-methods.js.map +1 -1
  108. package/dist/core/agent-session-retry.d.ts.map +1 -1
  109. package/dist/core/agent-session-retry.js +14 -4
  110. package/dist/core/agent-session-retry.js.map +1 -1
  111. package/dist/core/agent-session-runtime.d.ts +20 -0
  112. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  113. package/dist/core/agent-session-runtime.js +55 -6
  114. package/dist/core/agent-session-runtime.js.map +1 -1
  115. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  116. package/dist/core/agent-session-tool-registry.js +2 -1
  117. package/dist/core/agent-session-tool-registry.js.map +1 -1
  118. package/dist/core/agent-session.d.ts +2 -0
  119. package/dist/core/agent-session.d.ts.map +1 -1
  120. package/dist/core/agent-session.js +2 -0
  121. package/dist/core/agent-session.js.map +1 -1
  122. package/dist/core/async-scope.d.ts +13 -0
  123. package/dist/core/async-scope.d.ts.map +1 -0
  124. package/dist/core/async-scope.js +20 -0
  125. package/dist/core/async-scope.js.map +1 -0
  126. package/dist/core/cache-warmer.d.ts +3 -14
  127. package/dist/core/cache-warmer.d.ts.map +1 -1
  128. package/dist/core/cache-warmer.js +8 -60
  129. package/dist/core/cache-warmer.js.map +1 -1
  130. package/dist/core/extensions/extension-work.js +2 -2
  131. package/dist/core/extensions/extension-work.js.map +1 -1
  132. package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
  133. package/dist/core/extensions/loader-host-modules.js +3 -1
  134. package/dist/core/extensions/loader-host-modules.js.map +1 -1
  135. package/dist/core/extensions/ui-types.d.ts +2 -1
  136. package/dist/core/extensions/ui-types.d.ts.map +1 -1
  137. package/dist/core/extensions/ui-types.js.map +1 -1
  138. package/dist/core/extensions/workflow-events.d.ts +1 -1
  139. package/dist/core/extensions/workflow-events.d.ts.map +1 -1
  140. package/dist/core/extensions/workflow-events.js.map +1 -1
  141. package/dist/core/extensions/workflow-run-control.d.ts +4 -2
  142. package/dist/core/extensions/workflow-run-control.d.ts.map +1 -1
  143. package/dist/core/extensions/workflow-run-control.js.map +1 -1
  144. package/dist/core/model-fallback-failures.d.ts +6 -0
  145. package/dist/core/model-fallback-failures.d.ts.map +1 -1
  146. package/dist/core/model-fallback-failures.js +10 -1
  147. package/dist/core/model-fallback-failures.js.map +1 -1
  148. package/dist/core/preferred-providers.d.ts +19 -0
  149. package/dist/core/preferred-providers.d.ts.map +1 -0
  150. package/dist/core/preferred-providers.js +25 -0
  151. package/dist/core/preferred-providers.js.map +1 -0
  152. package/dist/core/provider-alias.d.ts.map +1 -1
  153. package/dist/core/provider-alias.js +4 -0
  154. package/dist/core/provider-alias.js.map +1 -1
  155. package/dist/core/provider-composer.d.ts.map +1 -1
  156. package/dist/core/provider-composer.js +1 -0
  157. package/dist/core/provider-composer.js.map +1 -1
  158. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  159. package/dist/core/remote-catalog-provider.js +3 -0
  160. package/dist/core/remote-catalog-provider.js.map +1 -1
  161. package/dist/core/resume/blueprint/action-expressions.d.ts +32 -0
  162. package/dist/core/resume/blueprint/action-expressions.d.ts.map +1 -0
  163. package/dist/core/resume/blueprint/action-expressions.js +389 -0
  164. package/dist/core/resume/blueprint/action-expressions.js.map +1 -0
  165. package/dist/core/resume/blueprint/actions.d.ts +90 -0
  166. package/dist/core/resume/blueprint/actions.d.ts.map +1 -0
  167. package/dist/core/resume/blueprint/actions.js +818 -0
  168. package/dist/core/resume/blueprint/actions.js.map +1 -0
  169. package/dist/core/resume/blueprint/build.d.ts +102 -0
  170. package/dist/core/resume/blueprint/build.d.ts.map +1 -0
  171. package/dist/core/resume/blueprint/build.js +535 -0
  172. package/dist/core/resume/blueprint/build.js.map +1 -0
  173. package/dist/core/resume/blueprint/context.d.ts +11 -0
  174. package/dist/core/resume/blueprint/context.d.ts.map +1 -0
  175. package/dist/core/resume/blueprint/context.js +106 -0
  176. package/dist/core/resume/blueprint/context.js.map +1 -0
  177. package/dist/core/resume/blueprint/envrc.d.ts +19 -0
  178. package/dist/core/resume/blueprint/envrc.d.ts.map +1 -0
  179. package/dist/core/resume/blueprint/envrc.js +77 -0
  180. package/dist/core/resume/blueprint/envrc.js.map +1 -0
  181. package/dist/core/resume/blueprint/errors.d.ts +179 -0
  182. package/dist/core/resume/blueprint/errors.d.ts.map +1 -0
  183. package/dist/core/resume/blueprint/errors.js +169 -0
  184. package/dist/core/resume/blueprint/errors.js.map +1 -0
  185. package/dist/core/resume/blueprint/ledger.d.ts +51 -0
  186. package/dist/core/resume/blueprint/ledger.d.ts.map +1 -0
  187. package/dist/core/resume/blueprint/ledger.js +119 -0
  188. package/dist/core/resume/blueprint/ledger.js.map +1 -0
  189. package/dist/core/resume/blueprint/notices.d.ts +14 -0
  190. package/dist/core/resume/blueprint/notices.d.ts.map +1 -0
  191. package/dist/core/resume/blueprint/notices.js +44 -0
  192. package/dist/core/resume/blueprint/notices.js.map +1 -0
  193. package/dist/core/resume/blueprint/process.d.ts +44 -0
  194. package/dist/core/resume/blueprint/process.d.ts.map +1 -0
  195. package/dist/core/resume/blueprint/process.js +142 -0
  196. package/dist/core/resume/blueprint/process.js.map +1 -0
  197. package/dist/core/resume/blueprint/resume.d.ts +73 -0
  198. package/dist/core/resume/blueprint/resume.d.ts.map +1 -0
  199. package/dist/core/resume/blueprint/resume.js +206 -0
  200. package/dist/core/resume/blueprint/resume.js.map +1 -0
  201. package/dist/core/resume/blueprint/schema.d.ts +26 -0
  202. package/dist/core/resume/blueprint/schema.d.ts.map +1 -0
  203. package/dist/core/resume/blueprint/schema.js +243 -0
  204. package/dist/core/resume/blueprint/schema.js.map +1 -0
  205. package/dist/core/resume/blueprint/steps.d.ts +54 -0
  206. package/dist/core/resume/blueprint/steps.d.ts.map +1 -0
  207. package/dist/core/resume/blueprint/steps.js +155 -0
  208. package/dist/core/resume/blueprint/steps.js.map +1 -0
  209. package/dist/core/resume/blueprint/types.d.ts +63 -0
  210. package/dist/core/resume/blueprint/types.d.ts.map +1 -0
  211. package/dist/core/resume/blueprint/types.js +2 -0
  212. package/dist/core/resume/blueprint/types.js.map +1 -0
  213. package/dist/core/resume/errors.d.ts +7 -35
  214. package/dist/core/resume/errors.d.ts.map +1 -1
  215. package/dist/core/resume/errors.js +1 -21
  216. package/dist/core/resume/errors.js.map +1 -1
  217. package/dist/core/resume/index.d.ts +12 -4
  218. package/dist/core/resume/index.d.ts.map +1 -1
  219. package/dist/core/resume/index.js +11 -4
  220. package/dist/core/resume/index.js.map +1 -1
  221. package/dist/core/resume/run-setup.d.ts +36 -15
  222. package/dist/core/resume/run-setup.d.ts.map +1 -1
  223. package/dist/core/resume/run-setup.js +70 -54
  224. package/dist/core/resume/run-setup.js.map +1 -1
  225. package/dist/core/resume/session-resume.d.ts +34 -20
  226. package/dist/core/resume/session-resume.d.ts.map +1 -1
  227. package/dist/core/resume/session-resume.js +244 -106
  228. package/dist/core/resume/session-resume.js.map +1 -1
  229. package/dist/core/retry-policy.d.ts +19 -1
  230. package/dist/core/retry-policy.d.ts.map +1 -1
  231. package/dist/core/retry-policy.js +26 -1
  232. package/dist/core/retry-policy.js.map +1 -1
  233. package/dist/core/sdk.js +1 -1
  234. package/dist/core/sdk.js.map +1 -1
  235. package/dist/core/session-cwd.d.ts +56 -1
  236. package/dist/core/session-cwd.d.ts.map +1 -1
  237. package/dist/core/session-cwd.js +94 -4
  238. package/dist/core/session-cwd.js.map +1 -1
  239. package/dist/core/session-manager-core.d.ts +1 -1
  240. package/dist/core/session-manager-core.d.ts.map +1 -1
  241. package/dist/core/session-manager-core.js +10 -5
  242. package/dist/core/session-manager-core.js.map +1 -1
  243. package/dist/core/session-worktree-snapshots.d.ts +11 -0
  244. package/dist/core/session-worktree-snapshots.d.ts.map +1 -1
  245. package/dist/core/session-worktree-snapshots.js +10 -4
  246. package/dist/core/session-worktree-snapshots.js.map +1 -1
  247. package/dist/core/settings-defaults.d.ts +1 -1
  248. package/dist/core/settings-defaults.d.ts.map +1 -1
  249. package/dist/core/settings-defaults.js +1 -1
  250. package/dist/core/settings-defaults.js.map +1 -1
  251. package/dist/core/settings-manager-basic-accessors.d.ts +3 -2
  252. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  253. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  254. package/dist/core/settings-schema.d.ts.map +1 -1
  255. package/dist/core/settings-schema.js +2 -1
  256. package/dist/core/settings-schema.js.map +1 -1
  257. package/dist/core/slash-commands.d.ts.map +1 -1
  258. package/dist/core/slash-commands.js +4 -0
  259. package/dist/core/slash-commands.js.map +1 -1
  260. package/dist/core/storage/write-ahead-log.d.ts +2 -1
  261. package/dist/core/storage/write-ahead-log.d.ts.map +1 -1
  262. package/dist/core/storage/write-ahead-log.js +27 -6
  263. package/dist/core/storage/write-ahead-log.js.map +1 -1
  264. package/dist/core/system-prompt.d.ts.map +1 -1
  265. package/dist/core/system-prompt.js +10 -0
  266. package/dist/core/system-prompt.js.map +1 -1
  267. package/dist/core/tools/file-tool-errors.d.ts +1 -1
  268. package/dist/core/tools/file-tool-errors.js +1 -1
  269. package/dist/core/tools/file-tool-errors.js.map +1 -1
  270. package/dist/core/tools/find.d.ts.map +1 -1
  271. package/dist/core/tools/find.js +52 -26
  272. package/dist/core/tools/find.js.map +1 -1
  273. package/dist/core/tools/grep.d.ts +2 -0
  274. package/dist/core/tools/grep.d.ts.map +1 -1
  275. package/dist/core/tools/grep.js.map +1 -1
  276. package/dist/core/tools/powershell.d.ts.map +1 -1
  277. package/dist/core/tools/powershell.js +10 -2
  278. package/dist/core/tools/powershell.js.map +1 -1
  279. package/dist/core/tools/tool-concurrency.d.ts.map +1 -1
  280. package/dist/core/tools/tool-concurrency.js +2 -2
  281. package/dist/core/tools/tool-concurrency.js.map +1 -1
  282. package/dist/index.d.ts +3 -2
  283. package/dist/index.d.ts.map +1 -1
  284. package/dist/index.js +2 -1
  285. package/dist/index.js.map +1 -1
  286. package/dist/main-session.d.ts +12 -4
  287. package/dist/main-session.d.ts.map +1 -1
  288. package/dist/main-session.js +28 -4
  289. package/dist/main-session.js.map +1 -1
  290. package/dist/main.d.ts.map +1 -1
  291. package/dist/main.js +6 -8
  292. package/dist/main.js.map +1 -1
  293. package/dist/modes/interactive/components/chat-session-host.d.ts +5 -1
  294. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  295. package/dist/modes/interactive/components/chat-session-host.js +6 -1
  296. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  297. package/dist/modes/interactive/components/oauth-selector.d.ts +10 -3
  298. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  299. package/dist/modes/interactive/components/oauth-selector.js +34 -13
  300. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  301. package/dist/modes/interactive/components/provider-brand.d.ts +16 -0
  302. package/dist/modes/interactive/components/provider-brand.d.ts.map +1 -0
  303. package/dist/modes/interactive/components/provider-brand.js +67 -0
  304. package/dist/modes/interactive/components/provider-brand.js.map +1 -0
  305. package/dist/modes/interactive/interactive-auth-routing.d.ts.map +1 -1
  306. package/dist/modes/interactive/interactive-auth-routing.js +8 -6
  307. package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
  308. package/dist/modes/interactive/interactive-extension-dialogs.js +4 -3
  309. package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
  310. package/dist/modes/interactive/interactive-extension-runtime.js +8 -3
  311. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  312. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
  313. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  314. package/dist/modes/interactive/interactive-mode-deps.js +1 -1
  315. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  316. package/dist/modes/interactive/interactive-mode-surface.d.ts +12 -2
  317. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  318. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  319. package/dist/modes/interactive/interactive-session-routing.js +59 -21
  320. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  321. package/dist/modes/interactive/interactive-slash-commands.js +23 -12
  322. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  323. package/dist/modes/interactive/login-provider-options.d.ts.map +1 -1
  324. package/dist/modes/interactive/login-provider-options.js +2 -1
  325. package/dist/modes/interactive/login-provider-options.js.map +1 -1
  326. package/dist/modes/interactive-engine/isolated-runtime.d.ts +2 -0
  327. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  328. package/dist/modes/interactive-engine/isolated-runtime.js +8 -3
  329. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  330. package/dist/modes/rpc/rpc-client-api.d.ts +2 -1
  331. package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
  332. package/dist/modes/rpc/rpc-client-api.js.map +1 -1
  333. package/dist/modes/rpc/rpc-client.d.ts +0 -1
  334. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  335. package/dist/modes/rpc/rpc-client.js +2 -18
  336. package/dist/modes/rpc/rpc-client.js.map +1 -1
  337. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  338. package/dist/modes/rpc/rpc-command-handler.js +8 -2
  339. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  340. package/dist/modes/rpc/rpc-error-decoding.d.ts +7 -0
  341. package/dist/modes/rpc/rpc-error-decoding.d.ts.map +1 -0
  342. package/dist/modes/rpc/rpc-error-decoding.js +25 -0
  343. package/dist/modes/rpc/rpc-error-decoding.js.map +1 -0
  344. package/dist/modes/rpc/rpc-responses.d.ts.map +1 -1
  345. package/dist/modes/rpc/rpc-responses.js +12 -0
  346. package/dist/modes/rpc/rpc-responses.js.map +1 -1
  347. package/dist/modes/rpc/rpc-types.d.ts +11 -0
  348. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  349. package/dist/modes/rpc/rpc-types.js.map +1 -1
  350. package/dist/package-manager-cli.d.ts.map +1 -1
  351. package/dist/package-manager-cli.js +12 -3
  352. package/dist/package-manager-cli.js.map +1 -1
  353. package/docs/background-tasks.md +1 -1
  354. package/docs/codemode.md +22 -0
  355. package/docs/extensions/api-reference.md +27 -1
  356. package/docs/extensions/authoring.md +1 -1
  357. package/docs/extensions/ui.md +1 -1
  358. package/docs/getting-started/first-session.md +1 -1
  359. package/docs/guides/resume-on-any-machine.md +72 -19
  360. package/docs/models/evals.md +85 -17
  361. package/docs/models/reference.md +1 -1
  362. package/docs/providers.md +38 -5
  363. package/docs/reference/cli.md +2 -0
  364. package/docs/rpc/protocol.md +11 -1
  365. package/docs/sdk/reference.md +36 -4
  366. package/docs/sdk.md +2 -2
  367. package/docs/sessions.md +11 -1
  368. package/docs/settings.md +7 -2
  369. package/docs/skills.md +3 -3
  370. package/docs/storage.md +1 -1
  371. package/docs/tools.md +3 -1
  372. package/docs/workflows/api-reference.md +14 -12
  373. package/docs/workflows/authoring.md +29 -1
  374. package/docs/workflows/builtins.md +9 -1
  375. package/docs/workflows/operations.md +8 -8
  376. package/docs/worktree-snapshots.md +3 -2
  377. package/npm-shrinkwrap.json +83 -67
  378. package/package.json +7 -7
  379. package/schemas/settings.schema.json +3 -2
  380. package/dist/core/resume/setup-hook.d.ts +0 -69
  381. package/dist/core/resume/setup-hook.d.ts.map +0 -1
  382. package/dist/core/resume/setup-hook.js +0 -261
  383. package/dist/core/resume/setup-hook.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"session-worktree-snapshots.js","sourceRoot":"","sources":["../../src/core/session-worktree-snapshots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAG/D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAG7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EACN,uBAAuB,EACvB,cAAc,EAEd,oBAAoB,EACpB,gBAAgB,GAChB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EACN,kBAAkB,EAElB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,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AI,KAAK,mBAAmB,IAAI,KAAK,CAAC,QAAQ;YAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACzG,CAAC;IACD,MAAM,QAAQ,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,wBAAwB,CAAC;QACxC,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM;QACvB,uBAAuB,EAAE,GAAG,EAAE,CAAC,QAAQ;QACvC,0BAA0B,EAAE,GAAG,EAAE,CAAC,OAAO;KACzC,CAAC,CAAC;IACH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAAC,KAAmB,EAAE,SAAiB;IACzF,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxD,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACjF,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAClD,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import { stat } from \"node:fs/promises\";\nimport { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport type { AssistantMessage } from \"@bastani/pi-ai/compat\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport { getBranchPath } from \"./session-manager-history.ts\";\nimport type { SessionEntry, WorktreeRestoreHostWarning } from \"./session-manager-types.ts\";\nimport type { SessionStore } from \"./storage/session/types.js\";\nimport { snapshotBlobHashes } from \"./worktree-snapshot/blob-store.ts\";\nimport {\n\tcaptureWorktreeSnapshot,\n\tlocateCheckout,\n\ttype WorktreeSnapshotUnavailableReason,\n\twithScratchDirectory,\n\twriteWorkingTree,\n} from \"./worktree-snapshot/capture.ts\";\nimport { sha256Hex } from \"./worktree-snapshot/env-hash.ts\";\nimport {\n\tfindWorkspaceError,\n\ttype GitUnavailableError,\n\tisGitUnavailableError,\n\tisWorkspaceDriftError,\n\tisWorkspaceSnapshotError,\n\tunreadablePathError,\n\tWorkspaceDriftError,\n\ttype WorkspaceError,\n\tWorkspaceRestoreError,\n\tWorkspaceSnapshotError,\n} from \"./worktree-snapshot/errors.ts\";\nimport { scheduleSnapshotCollection } from \"./worktree-snapshot/garbage.ts\";\nimport { gitText, runGit } from \"./worktree-snapshot/git.ts\";\nimport { isHeadOnlyAdvance } from \"./worktree-snapshot/head-advance.ts\";\nimport { canonicalizeWorktreePath } from \"./worktree-snapshot/paths.ts\";\nimport { loadSnapshotPathPolicy } from \"./worktree-snapshot/policy.ts\";\nimport {\n\tremoveRestoredWorktree,\n\trestoreWorktree,\n\tsnapshotRestoreWarnings,\n\tverifyWorktree,\n} from \"./worktree-snapshot/restore.ts\";\nimport type {\n\tSnapshotBlob,\n\tSnapshotBlobStore,\n\tWorktreeRestoreWarning,\n\tWorktreeRootMapping,\n\tWorktreeSnapshot,\n\tWorktreeSnapshotSettings,\n} from \"./worktree-snapshot/types.ts\";\n\n/** Why a turn's snapshot could not be recorded: Git is unavailable, or a typed workspace failure. */\nexport type WorktreeSnapshotUnavailable = WorkspaceError | GitUnavailableError;\n\n/** Built-in tools that can change files: a turn that called one records a snapshot. */\nexport const FILE_WRITING_TOOLS: ReadonlySet<string> = new Set([\"bash\", \"edit\", \"write\", \"powershell\"]);\nconst PATH_TOOLS: ReadonlySet<string> = new Set([\"edit\", \"write\"]);\n\nexport interface TurnSnapshotDependencies {\n\treadonly sessionManager: SessionManager;\n\treadonly cwd: () => string;\n\treadonly settings: () => WorktreeSnapshotSettings;\n\t/** Whether a registered tool declares `writesFiles`. */\n\treadonly declaresWrites: (toolName: string) => boolean;\n\t/** Called once per distinct reason a snapshot could not be recorded. */\n\treadonly onUnavailable: (reason: WorktreeSnapshotUnavailable) => void;\n}\n\nfunction isInside(parent: string, child: string): boolean {\n\tconst path = relative(canonicalizeWorktreePath(parent), canonicalizeWorktreePath(child));\n\treturn path === \"\" || (!path.startsWith(`..${sep}`) && path !== \"..\" && !isAbsolute(path));\n}\n\n/**\n * Records a `worktree_snapshot` entry per checkout at the end of each turn that called a file-writing tool. In-memory\n * sessions, which cannot be resumed elsewhere, record nothing.\n */\nexport class SessionWorktreeSnapshotRecorder {\n\tprivate readonly deps: TurnSnapshotDependencies;\n\tprivate readonly reported = new Set<string>();\n\n\tconstructor(deps: TurnSnapshotDependencies) {\n\t\tthis.deps = deps;\n\t}\n\n\tprivate report(reason: WorktreeSnapshotUnavailable): void {\n\t\tconst key = `${reason.code}\\0${JSON.stringify(reason.fields)}`;\n\t\tif (this.reported.has(key)) return;\n\t\tthis.reported.add(key);\n\t\tthis.deps.onUnavailable(reason);\n\t}\n\n\t/** Directories whose checkouts a turn may have changed: the session cwd and the targets of path-taking tools. */\n\tprivate touchedDirectories(message: AssistantMessage): string[] | undefined {\n\t\tconst cwd = this.deps.cwd();\n\t\tconst directories = new Set<string>();\n\t\tfor (const part of message.content) {\n\t\t\tif (part.type !== \"toolCall\") continue;\n\t\t\tif (!FILE_WRITING_TOOLS.has(part.name) && !this.deps.declaresWrites(part.name)) continue;\n\t\t\tdirectories.add(cwd);\n\t\t\tconst path = PATH_TOOLS.has(part.name) ? part.arguments.path : undefined;\n\t\t\tif (typeof path === \"string\" && path.length > 0) directories.add(resolve(cwd, path, \"..\"));\n\t\t}\n\t\treturn directories.size === 0 ? undefined : [...directories];\n\t}\n\n\t/** Whether the turn may record a snapshot when it ends: a persisted session called a tool that can change files. */\n\tcallsFileWritingTool(message: AssistantMessage): boolean {\n\t\treturn this.deps.sessionManager.isPersisted() && this.touchedDirectories(message) !== undefined;\n\t}\n\n\tasync recordTurn(message: AssistantMessage): Promise<void> {\n\t\tconst directories = this.touchedDirectories(message);\n\t\tif (!directories) return;\n\t\tlet settings: WorktreeSnapshotSettings;\n\t\ttry {\n\t\t\tsettings = this.deps.settings();\n\t\t} catch (error) {\n\t\t\tthis.reportFailure(error);\n\t\t\treturn;\n\t\t}\n\t\tif (!settings.enabled || !this.deps.sessionManager.isPersisted()) return;\n\t\tconst blobs = this.deps.sessionManager.getSessionStore().snapshotBlobs;\n\t\tif (!blobs) {\n\t\t\tthis.report(\n\t\t\t\tnew WorkspaceSnapshotError(\n\t\t\t\t\t\"blob-store-unsupported\",\n\t\t\t\t\tthis.deps.sessionManager.getSessionStore().descriptor.adapter,\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tconst roots = new Set<string>();\n\t\tfor (const directory of directories) {\n\t\t\ttry {\n\t\t\t\tconst checkout = await locateCheckout(await nearestExisting(directory));\n\t\t\t\tif (checkout instanceof Error) this.report(checkout);\n\t\t\t\telse roots.add(checkout.root);\n\t\t\t} catch (error) {\n\t\t\t\tthis.reportFailure(error);\n\t\t\t}\n\t\t}\n\t\tfor (const root of roots) {\n\t\t\tconst previous = this.deps.sessionManager.getLatestWorktreeSnapshots().get(root);\n\t\t\ttry {\n\t\t\t\tconst result = await captureWorktreeSnapshot(root, { settings, previous, blobs });\n\t\t\t\tif (result.status === \"captured\") {\n\t\t\t\t\tawait this.deps.sessionManager.appendWorktreeSnapshot(root, result.snapshot.id, result.snapshot);\n\t\t\t\t} else if (result.status === \"unchanged\") {\n\t\t\t\t\tawait this.deps.sessionManager.appendWorktreeSnapshot(root, result.snapshot.id);\n\t\t\t\t} else if (result.status === \"unavailable\") {\n\t\t\t\t\tthis.report(result.reason);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tthis.reportFailure(error);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Starts an automatic collection of the session store's unreferenced snapshot blobs when one is due, and returns\n\t * without waiting for it. Called when the session closes.\n\t */\n\tscheduleCollection(): void {\n\t\tlet settings: WorktreeSnapshotSettings;\n\t\ttry {\n\t\t\tsettings = this.deps.settings();\n\t\t} catch (error) {\n\t\t\tthis.reportFailure(error);\n\t\t\treturn;\n\t\t}\n\t\tvoid scheduleSnapshotCollection(this.deps.sessionManager.getSessionStore().snapshotBlobs, settings);\n\t}\n\n\tprivate reportFailure(error: unknown): void {\n\t\tconst reason = isGitUnavailableError(error) ? error : findWorkspaceError(error);\n\t\tif (!reason) throw error;\n\t\tthis.report(reason);\n\t}\n}\n\nasync function nearestExisting(directory: string): Promise<string> {\n\tfor (let current = directory; ; current = resolve(current, \"..\")) {\n\t\ttry {\n\t\t\tif ((await stat(current)).isDirectory()) return current;\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code !== \"ENOENT\" && (error as NodeJS.ErrnoException).code !== \"ENOTDIR\")\n\t\t\t\tthrow unreadablePathError(current, error);\n\t\t}\n\t\tif (resolve(current, \"..\") === current) return current;\n\t}\n}\n\n/** `path` rewritten through each restore in order: a path under `from` moves to the same place under `to`. */\nexport function mapRestoredPath(path: string, mappings: readonly WorktreeRootMapping[]): string {\n\tlet mapped = resolve(path);\n\tlet next = 0;\n\twhile (next < mappings.length) {\n\t\tconst current = canonicalizeWorktreePath(mapped);\n\t\tlet best: { index: number; source: string } | undefined;\n\t\tfor (let index = next; index < mappings.length; index++) {\n\t\t\tconst source = canonicalizeWorktreePath(mappings[index]!.from);\n\t\t\tif (isInside(source, current) && (best === undefined || source.length > best.source.length)) {\n\t\t\t\tbest = { index, source };\n\t\t\t}\n\t\t}\n\t\tif (best === undefined) break;\n\t\tmapped = resolve(mappings[best.index]!.to, relative(best.source, current));\n\t\tnext = best.index + 1;\n\t}\n\treturn mapped;\n}\n\n/** Recover the original root of a sequence of restores, so a restored root supersedes its earlier location. */\nfunction originalRoot(root: string, mappings: readonly WorktreeRootMapping[]): string {\n\tlet current = canonicalizeWorktreePath(root);\n\tfor (let index = mappings.length - 1; index >= 0; index--) {\n\t\tconst mapping = mappings[index]!;\n\t\tif (canonicalizeWorktreePath(mapping.to) === current) current = canonicalizeWorktreePath(mapping.from);\n\t}\n\treturn current;\n}\n\n/** The id of the latest snapshot of each checkout on the active branch, keyed by the root it was first recorded under. */\nfunction latestSnapshotIdsByCheckout(\n\tsessionManager: Pick<SessionManager, \"getBranch\">,\n\tmappings: readonly WorktreeRootMapping[],\n): Map<string, string> {\n\tconst latestIds = new Map<string, string>();\n\tfor (const entry of sessionManager.getBranch()) {\n\t\tif (entry.type === \"worktree_snapshot\") latestIds.set(originalRoot(entry.root, mappings), entry.snapshotId);\n\t}\n\treturn latestIds;\n}\n\n/**\n * The latest snapshot of each checkout on the active branch, keyed by where that checkout is now: a checkout restored\n * elsewhere appears once, under its newest location. A snapshot whose record is missing is left out.\n */\nexport function currentWorktreeSnapshots(\n\tsessionManager: Pick<SessionManager, \"getBranch\" | \"getWorktreeRootMappings\" | \"getWorktreeSnapshotRecords\">,\n): Map<string, WorktreeSnapshot> {\n\tconst mappings = sessionManager.getWorktreeRootMappings();\n\tconst records = sessionManager.getWorktreeSnapshotRecords();\n\tconst current = new Map<string, WorktreeSnapshot>();\n\tfor (const [original, snapshotId] of latestSnapshotIdsByCheckout(sessionManager, mappings)) {\n\t\tconst snapshot = records.get(snapshotId);\n\t\tif (snapshot) current.set(mapRestoredPath(original, mappings), snapshot);\n\t}\n\treturn current;\n}\n\nexport type SessionWorktreeResume =\n\t| { readonly status: \"none\" }\n\t| { readonly status: \"verified\"; readonly snapshot: WorktreeSnapshot; readonly cwd: string }\n\t| {\n\t\t\treadonly status: \"restored\";\n\t\t\treadonly snapshot: WorktreeSnapshot;\n\t\t\treadonly mappings: readonly WorktreeRootMapping[];\n\t\t\treadonly cwd: string;\n\t\t\treadonly warnings: readonly WorktreeRestoreWarning[];\n\t };\n\nexport interface ResumeSessionWorktreeOptions {\n\treadonly settings: WorktreeSnapshotSettings;\n\t/** Host directory for shared object stores and restored worktrees. Default ~/.atomic/agent/worktree-snapshots. */\n\treadonly storeDir?: string;\n\treadonly signal?: AbortSignal;\n\t/**\n\t * Called with the new mappings, none when nothing needed restoring, once every checkout is restored and before any\n\t * of them is recorded. When it throws, nothing is recorded and the restored worktrees are removed, as for a failed\n\t * restore.\n\t */\n\treadonly beforeRecord?: (mappings: readonly WorktreeRootMapping[]) => Promise<void>;\n\t/**\n\t * Mappings to checkouts already here that the session continues in, applied as if recorded while deciding what to\n\t * restore, and recorded first, with the restores, only once every checkout is restored and `beforeRecord` passed.\n\t */\n\treadonly pendingMappings?: readonly WorktreeRootMapping[];\n\t/** Checkouts, by the root the session's restores put them at, to continue in as they are without verifying them. */\n\treadonly keepInPlace?: ReadonlySet<string>;\n}\n\n/**\n * Checks the latest recorded snapshot of each checkout on the active session branch. Drifted or missing checkouts are\n * restored into fresh worktrees, and each old→new mapping is recorded only after all checkouts have been restored.\n * The returned cwd follows those mappings. A HEAD-only advance over identical content also resumes in place.\n */\nexport async function resumeSessionWorktree(\n\tsessionManager: SessionManager,\n\toptions: ResumeSessionWorktreeOptions,\n): Promise<SessionWorktreeResume> {\n\tif (!options.settings.enabled) return { status: \"none\" };\n\tconst pending = options.pendingMappings ?? [];\n\tconst existing = [...sessionManager.getWorktreeRootMappings(), ...pending];\n\tconst records = sessionManager.getWorktreeSnapshotRecords();\n\tconst latestIds = latestSnapshotIdsByCheckout(sessionManager, existing);\n\tconst latest = new Map<string, WorktreeSnapshot>();\n\tfor (const [root, snapshotId] of latestIds) {\n\t\tconst snapshot = records.get(snapshotId);\n\t\tif (!snapshot) throw new WorkspaceRestoreError(\"snapshot-not-found\", { snapshotId, target: root });\n\t\tlatest.set(root, snapshot);\n\t}\n\tif (latest.size === 0) return { status: \"none\" };\n\tconst cwd = mapRestoredPath(sessionManager.getCwd(), existing);\n\tconst mappings: WorktreeRootMapping[] = [];\n\tconst warnings: WorktreeRestoreWarning[] = [];\n\tconst hostWarnings = new Map<WorktreeRootMapping, WorktreeRestoreHostWarning[]>();\n\tconst reportedLeftovers = new Set<string>();\n\tlet selected: { root: string; snapshot: WorktreeSnapshot } | undefined;\n\ttry {\n\t\tfor (const [original, snapshot] of latest) {\n\t\t\toptions.signal?.throwIfAborted();\n\t\t\tconst root = mapRestoredPath(original, existing);\n\t\t\tif (isInside(root, cwd) && (!selected || root.length > selected.root.length)) selected = { root, snapshot };\n\t\t\tif (options.keepInPlace?.has(root)) continue;\n\t\t\tlet drift: WorkspaceDriftError;\n\t\t\ttry {\n\t\t\t\tawait verifyWorktree(snapshot, root, { settings: options.settings, signal: options.signal });\n\t\t\t\tcontinue;\n\t\t\t} catch (error) {\n\t\t\t\toptions.signal?.throwIfAborted();\n\t\t\t\tif (isWorkspaceDriftError(error)) {\n\t\t\t\t\tif (await isHeadOnlyAdvance(error, options.signal)) continue;\n\t\t\t\t\tdrift = error;\n\t\t\t\t} else if (isWorkspaceSnapshotError(error)) {\n\t\t\t\t\tdrift = new WorkspaceDriftError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\troot,\n\t\t\t\t\t\t\texpectedHead: snapshot.head,\n\t\t\t\t\t\t\tactualHead: null,\n\t\t\t\t\t\t\texpectedTree: snapshot.tree,\n\t\t\t\t\t\t\tactualTree: null,\n\t\t\t\t\t\t\tsnapshotId: snapshot.id,\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t} else throw error;\n\t\t\t}\n\t\t\tlet restored: Awaited<ReturnType<typeof restoreWorktree>>;\n\t\t\ttry {\n\t\t\t\trestored = await restoreWorktree(snapshot, {\n\t\t\t\t\tblobs: sessionSnapshotBlobs(sessionManager.getSessionStore().snapshotBlobs, sessionManager.getEntries()),\n\t\t\t\t\tstoreDir: options.storeDir,\n\t\t\t\t\tsignal: options.signal,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\toptions.signal?.throwIfAborted();\n\t\t\t\tif (!(error instanceof Error)) throw error;\n\t\t\t\tthrow new WorkspaceDriftError(\n\t\t\t\t\t{\n\t\t\t\t\t\troot: drift.root,\n\t\t\t\t\t\texpectedHead: drift.expectedHead,\n\t\t\t\t\t\tactualHead: drift.actualHead,\n\t\t\t\t\t\texpectedTree: drift.expectedTree,\n\t\t\t\t\t\tactualTree: drift.actualTree,\n\t\t\t\t\t\tsnapshotId: drift.snapshotId,\n\t\t\t\t\t\treason: \"restore-failed\",\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst mapping: WorktreeRootMapping = {\n\t\t\t\tfrom: root,\n\t\t\t\tto: restored.path,\n\t\t\t\tsnapshotId: snapshot.id,\n\t\t\t\ttree: snapshot.tree,\n\t\t\t\trestoredAt: new Date().toISOString(),\n\t\t\t};\n\t\t\tmappings.push(mapping);\n\t\t\twarnings.push(...restored.warnings);\n\t\t\thostWarnings.set(\n\t\t\t\tmapping,\n\t\t\t\trestored.warnings.filter((warning): warning is WorktreeRestoreHostWarning => {\n\t\t\t\t\tif (warning.code === \"lfs-objects-unavailable\") return true;\n\t\t\t\t\tif (warning.code !== \"stale-restore-retained\" || reportedLeftovers.has(warning.path)) return false;\n\t\t\t\t\treportedLeftovers.add(warning.path);\n\t\t\t\t\treturn true;\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\tawait options.beforeRecord?.(mappings);\n\t\tfor (const mapping of [...pending, ...mappings]) {\n\t\t\toptions.signal?.throwIfAborted();\n\t\t\tawait sessionManager.appendWorktreeSnapshot(\n\t\t\t\tmapping.to,\n\t\t\t\tmapping.snapshotId,\n\t\t\t\tundefined,\n\t\t\t\tmapping,\n\t\t\t\thostWarnings.get(mapping),\n\t\t\t);\n\t\t}\n\t} catch (error) {\n\t\tconst cleanupFailures: unknown[] = [];\n\t\tfor (const mapping of [...mappings].reverse()) {\n\t\t\ttry {\n\t\t\t\tawait removeRestoredWorktree(mapping.to, { storeDir: options.storeDir });\n\t\t\t} catch (cleanupCause) {\n\t\t\t\tcleanupFailures.push(cleanupCause);\n\t\t\t}\n\t\t}\n\t\tif (cleanupFailures.length > 0 && error instanceof Error && Object.isExtensible(error)) {\n\t\t\tObject.defineProperty(error, \"cleanupCause\", {\n\t\t\t\tvalue: cleanupFailures.length === 1 ? cleanupFailures[0] : new AggregateError(cleanupFailures),\n\t\t\t\tconfigurable: true,\n\t\t\t});\n\t\t}\n\t\tthrow error;\n\t}\n\tconst snapshot = selected?.snapshot ?? [...latest.values()].at(-1)!;\n\tconst mappedCwd = mapRestoredPath(cwd, mappings);\n\treturn mappings.length === 0\n\t\t? { status: \"verified\", snapshot, cwd: mappedCwd }\n\t\t: { status: \"restored\", snapshot, mappings, cwd: mappedCwd, warnings };\n}\n\n/** The one-line notice shown when a session or run continues in a restored worktree. */\nexport function formatWorktreeRestoreNotice(mapping: WorktreeRootMapping): string {\n\treturn `Restored worktree snapshot ${mapping.snapshotId.slice(0, 12)} of ${mapping.from} into ${mapping.to}`;\n}\n\n/** One line per restore warning, for the notices shown after a restore. */\nexport function formatWorktreeRestoreWarning(warning: WorktreeRestoreWarning): string {\n\tswitch (warning.code) {\n\t\tcase \"omitted-content\":\n\t\t\treturn `The restored snapshot left out ${warning.omitted.length} item(s): ${warning.omitted\n\t\t\t\t.map((omission) => (\"path\" in omission ? `${omission.path} (${omission.reason})` : omission.reason))\n\t\t\t\t.join(\", \")}`;\n\t\tcase \"filters\":\n\t\t\treturn `The source checkout used conversion settings (${[\n\t\t\t\twarning.filters.autocrlf === null ? undefined : `core.autocrlf=${warning.filters.autocrlf}`,\n\t\t\t\twarning.filters.eol === null ? undefined : `core.eol=${warning.filters.eol}`,\n\t\t\t\t...warning.filters.drivers.map((driver) => `filter=${driver}`),\n\t\t\t]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(\", \")}); the restore holds Git's stored content with LF line endings`;\n\t\tcase \"lfs-objects-unavailable\":\n\t\t\treturn `Git LFS objects could not be fetched; these files hold LFS pointers: ${warning.paths.join(\", \")}`;\n\t\tcase \"stale-restore-retained\":\n\t\t\tswitch (warning.kind) {\n\t\t\t\tcase \"worktree\":\n\t\t\t\t\treturn `A restore interrupted earlier left ${warning.path}; remove it with removeRestoredWorktree or delete the directory`;\n\t\t\t\tcase \"record\":\n\t\t\t\t\treturn `A restore interrupted earlier left the crash record ${warning.path}, which cannot be read; delete the file`;\n\t\t\t\tcase \"records-directory\":\n\t\t\t\t\treturn `The restore crash records in ${warning.path} cannot be read; make the directory readable or remove it`;\n\t\t\t}\n\t}\n}\n\n/**\n * One informational line per worktree restored since `since`, each followed by its snapshot's warnings and what the\n * restore itself reported.\n */\nexport function worktreeRestoreNotices(\n\tsessionManager: Pick<SessionManager, \"getBranch\" | \"getWorktreeSnapshotRecords\">,\n\tsince: string,\n): { readonly type: \"info\" | \"warning\"; readonly message: string }[] {\n\treturn restoreNotices(sessionManager, (restore) => restore.restoredAt >= since);\n}\n\nfunction restoreNotices(\n\tsessionManager: Pick<SessionManager, \"getBranch\" | \"getWorktreeSnapshotRecords\">,\n\tinclude: (restore: WorktreeRootMapping) => boolean,\n): { readonly type: \"info\" | \"warning\"; readonly message: string }[] {\n\tconst records = sessionManager.getWorktreeSnapshotRecords();\n\treturn sessionManager.getBranch().flatMap((entry) => {\n\t\tif (entry.type !== \"worktree_snapshot\" || !entry.restore || !include(entry.restore)) return [];\n\t\tconst snapshot = records.get(entry.snapshotId);\n\t\treturn [\n\t\t\t{ type: \"info\" as const, message: formatWorktreeRestoreNotice(entry.restore) },\n\t\t\t...[...(snapshot ? snapshotRestoreWarnings(snapshot) : []), ...(entry.restoreWarnings ?? [])].map(\n\t\t\t\t(warning) => ({ type: \"warning\" as const, message: formatWorktreeRestoreWarning(warning) }),\n\t\t\t),\n\t\t];\n\t});\n}\n\n/**\n * `entries` with each snapshot's record and blobs from `store` carried inline, each once, so the exported file\n * restores without the source storage. Without a store only the records are carried. A blob the store no longer has\n * is left out; restoring that snapshot then fails with `blob-missing`.\n */\nexport async function inlineSnapshotBlobs(\n\tentries: readonly SessionEntry[],\n\trecords: ReadonlyMap<string, WorktreeSnapshot>,\n\tstore: SnapshotBlobStore | undefined,\n): Promise<SessionEntry[]> {\n\tconst emittedRecords = new Set<string>();\n\tconst emittedBlobs = new Set<string>();\n\tconst result: SessionEntry[] = [];\n\tfor (const entry of entries) {\n\t\tif (entry.type !== \"worktree_snapshot\") {\n\t\t\tresult.push(entry);\n\t\t\tcontinue;\n\t\t}\n\t\tconst record = entry.snapshot ?? records.get(entry.snapshotId);\n\t\tconst { blobs: _carried, snapshot: _record, ...rest } = entry;\n\t\tconst blobs: Record<string, string> = {};\n\t\tif (record && store) {\n\t\t\tfor (const hash of snapshotBlobHashes(record)) {\n\t\t\t\tif (emittedBlobs.has(hash)) continue;\n\t\t\t\tconst data = await store.getBlob(hash);\n\t\t\t\tif (data === undefined) continue;\n\t\t\t\tblobs[hash] = Buffer.from(data).toString(\"base64\");\n\t\t\t\temittedBlobs.add(hash);\n\t\t\t}\n\t\t}\n\t\tconst carryRecord = record !== undefined && !emittedRecords.has(record.id);\n\t\tif (record) emittedRecords.add(record.id);\n\t\tresult.push({\n\t\t\t...rest,\n\t\t\t...(carryRecord ? { snapshot: record } : {}),\n\t\t\t...(Object.keys(blobs).length > 0 ? { blobs } : {}),\n\t\t});\n\t}\n\treturn result;\n}\n\n/**\n * Moves inline blobs into `store` after checking each against its hash, and returns the entries without them.\n * Without a store the entries keep their blobs, which restore reads directly. Throws `blob-corrupt` before writing\n * anything when a blob does not match its hash.\n */\nexport async function adoptInlineSnapshotBlobs(\n\tentries: readonly SessionEntry[],\n\tstore: SnapshotBlobStore | undefined,\n): Promise<SessionEntry[]> {\n\tconst blobs: SnapshotBlob[] = [];\n\tfor (const entry of entries) {\n\t\tif (entry.type !== \"worktree_snapshot\" || !entry.blobs) continue;\n\t\tfor (const [hash, base64] of Object.entries(entry.blobs)) {\n\t\t\tconst data = new Uint8Array(Buffer.from(base64, \"base64\"));\n\t\t\tif (sha256Hex(data) !== hash) {\n\t\t\t\tthrow new WorkspaceRestoreError(\"blob-corrupt\", { snapshotId: entry.snapshotId, blob: hash });\n\t\t\t}\n\t\t\tblobs.push({ hash, data });\n\t\t}\n\t}\n\tif (!store || blobs.length === 0) return [...entries];\n\tawait store.putBlobs(blobs);\n\treturn entries.map((entry) => {\n\t\tif (entry.type !== \"worktree_snapshot\" || !entry.blobs) return entry;\n\t\tconst { blobs: _moved, ...rest } = entry;\n\t\treturn rest;\n\t});\n}\n\n/** A read-only view of the blobs carried inline by `entries`. */\nexport function inlineBlobStore(entries: readonly SessionEntry[]): SnapshotBlobStore {\n\tconst blobs = new Map<string, string>();\n\tfor (const entry of entries) {\n\t\tif (entry.type === \"worktree_snapshot\" && entry.blobs) {\n\t\t\tfor (const [hash, base64] of Object.entries(entry.blobs)) blobs.set(hash, base64);\n\t\t}\n\t}\n\treturn {\n\t\tasync putBlobs() {\n\t\t\tthrow new WorkspaceSnapshotError(\"blob-store-unsupported\", \"inline\");\n\t\t},\n\t\tasync getBlob(hash) {\n\t\t\tconst base64 = blobs.get(hash);\n\t\t\treturn base64 === undefined ? undefined : new Uint8Array(Buffer.from(base64, \"base64\"));\n\t\t},\n\t\tasync refreshBlobs(hashes) {\n\t\t\treturn hashes.every((hash) => blobs.has(hash));\n\t\t},\n\t\tasync listBlobHashes() {\n\t\t\treturn [...blobs.keys()];\n\t\t},\n\t};\n}\n\n/** Reads `primary` first, then the blobs carried inline by `entries`. */\nexport function sessionSnapshotBlobs(\n\tprimary: SnapshotBlobStore | undefined,\n\tentries: readonly SessionEntry[],\n): SnapshotBlobStore {\n\tconst inline = inlineBlobStore(entries);\n\tif (!primary) return inline;\n\treturn {\n\t\tputBlobs: (blobs) => primary.putBlobs(blobs),\n\t\tgetBlob: async (hash) => (await primary.getBlob(hash)) ?? (await inline.getBlob(hash)),\n\t\trefreshBlobs: (hashes) => primary.refreshBlobs(hashes),\n\t\tlistBlobHashes: () => primary.listBlobHashes(),\n\t};\n}\n\n/** What an export of `entries` carries: checkouts, snapshots and the bytes of patch and bundle content. */\nexport function describeSnapshotExport(\n\tentries: readonly SessionEntry[],\n\trecords: ReadonlyMap<string, WorktreeSnapshot>,\n): string | undefined {\n\tconst roots = new Set<string>();\n\tconst snapshots = new Set<string>();\n\tconst blobBytes = new Map<string, number>();\n\tlet omitted = 0;\n\tfor (const entry of entries) {\n\t\tif (entry.type !== \"worktree_snapshot\" || snapshots.has(entry.snapshotId)) continue;\n\t\tsnapshots.add(entry.snapshotId);\n\t\tconst record = entry.snapshot ?? records.get(entry.snapshotId);\n\t\tif (!record) continue;\n\t\troots.add(record.root);\n\t\tomitted += record.omitted.length;\n\t\tfor (const link of record.chain) if (link.patch) blobBytes.set(link.patch, link.bytes);\n\t\tif (record.bundle) blobBytes.set(record.bundle.blob, record.bundle.bytes);\n\t}\n\tif (snapshots.size === 0) return undefined;\n\tconst bytes = [...blobBytes.values()].reduce((sum, size) => sum + size, 0);\n\treturn `Includes ${snapshots.size} worktree snapshot(s) of ${[...roots].join(\", \")}: ${bytes} bytes of patch and bundle content${omitted > 0 ? `, ${omitted} omitted item(s) not included` : \"\"}`;\n}\n\nexport type WorktreeSnapshotComparison =\n\t| { readonly status: \"match\"; readonly tree: string; readonly head?: string }\n\t| { readonly status: \"missing\"; readonly reason: WorktreeSnapshotUnavailableReason }\n\t| {\n\t\t\treadonly status: \"differs\";\n\t\t\treadonly head: string;\n\t\t\treadonly tree: string;\n\t\t\t/** `git diff --stat` from the snapshot's tree to the current one, when the snapshot's tree is present locally. */\n\t\t\treadonly stat: string | undefined;\n\t };\n\n/** Compares the checkout at `dir` with `snapshot`, for `/session snapshot`. */\nexport async function compareWorktreeSnapshot(\n\tsnapshot: WorktreeSnapshot,\n\tdir: string,\n\tsettings: WorktreeSnapshotSettings,\n): Promise<WorktreeSnapshotComparison> {\n\tconst checkout = await locateCheckout(dir);\n\tif (checkout instanceof Error) return { status: \"missing\", reason: checkout };\n\tconst present = await runGit([\"cat-file\", \"-e\", `${snapshot.tree}^{tree}`], {\n\t\tcwd: checkout.root,\n\t\tallowExitCodes: [1, 128],\n\t});\n\tconst policy = await loadSnapshotPathPolicy(checkout.root);\n\tconst state = await withScratchDirectory((scratch) =>\n\t\twriteWorkingTree(checkout, settings, policy, scratch, present.exitCode === 0 ? { seedTree: snapshot.tree } : {}),\n\t);\n\tif (state.tree === snapshot.tree) {\n\t\tif (checkout.head === snapshot.head) return { status: \"match\", tree: state.tree };\n\t\tconst drift = new WorkspaceDriftError({\n\t\t\troot: checkout.root,\n\t\t\texpectedHead: snapshot.head,\n\t\t\tactualHead: checkout.head,\n\t\t\texpectedTree: snapshot.tree,\n\t\t\tactualTree: state.tree,\n\t\t\tsnapshotId: snapshot.id,\n\t\t});\n\t\tif (await isHeadOnlyAdvance(drift)) return { status: \"match\", tree: state.tree, head: checkout.head };\n\t}\n\tconst stat =\n\t\tpresent.exitCode === 0\n\t\t\t? await gitText([\"diff-tree\", \"--stat\", \"--no-renames\", \"--no-ext-diff\", \"-r\", snapshot.tree, state.tree], {\n\t\t\t\t\tcwd: checkout.root,\n\t\t\t\t})\n\t\t\t: undefined;\n\treturn { status: \"differs\", head: checkout.head, tree: state.tree, stat };\n}\n\n/** Lines describing `snapshot` for `/session snapshot`. */\nexport function describeWorktreeSnapshot(root: string, snapshot: WorktreeSnapshot): string[] {\n\tconst omitted = snapshot.omitted.map((omission) =>\n\t\t\"path\" in omission\n\t\t\t? `${omission.path} (${omission.reason})`\n\t\t\t: `${omission.commits.length} commit(s) (${omission.reason})`,\n\t);\n\treturn [\n\t\t`${root}`,\n\t\t` snapshot ${snapshot.id} captured ${snapshot.capturedAt}`,\n\t\t` ${snapshot.branch ?? \"detached\"} at ${snapshot.head.slice(0, 12)}, tree ${snapshot.tree.slice(0, 12)}`,\n\t\t` delta chain ${snapshot.chain.length} link(s), ${snapshot.chain.reduce((sum, link) => sum + link.bytes, 0)} bytes; ${\n\t\t\tsnapshot.bundle\n\t\t\t\t? `${snapshot.bundle.commits.length} unpushed commit(s) bundled`\n\t\t\t\t: \"no unpushed commits bundled\"\n\t\t}`,\n\t\t...(omitted.length > 0 ? [` omitted: ${omitted.join(\", \")}`] : []),\n\t\t...(snapshot.filters\n\t\t\t? snapshotRestoreWarnings({ ...snapshot, omitted: [] }).map(formatWorktreeRestoreWarning)\n\t\t\t: []),\n\t];\n}\n\n/**\n * Opens `sessionManager`'s session where it should continue: in place when its checkout matches the last snapshot,\n * in the restored worktree otherwise. Returns the notices to show for a restore it performed.\n */\nexport async function openSessionInWorktree(\n\tsessionManager: SessionManager,\n\toptions: ResumeSessionWorktreeOptions & { readonly sessionDirectory?: string },\n): Promise<{\n\treadonly sessionManager: SessionManager;\n\treadonly notices: { readonly type: \"info\" | \"warning\"; readonly message: string }[];\n}> {\n\tconst resume = await resumeSessionWorktree(sessionManager, options);\n\tconst moved =\n\t\t(resume.status === \"restored\" || resume.status === \"verified\") && resume.cwd !== sessionManager.getCwd();\n\tconst opened = moved\n\t\t? await sessionManager.openSessionById(sessionManager.getSessionId(), resume.cwd, options.sessionDirectory)\n\t\t: sessionManager;\n\tconst restoredHere = new Set(resume.status === \"restored\" ? resume.mappings.map((mapping) => mapping.to) : []);\n\treturn { sessionManager: opened, notices: restoreNotices(opened, (restore) => restoredHere.has(restore.to)) };\n}\n\n/**\n * Whether a session recorded elsewhere continues in `cwd` because a restore moved its checkout there, so opening it\n * from `cwd` resumes it rather than forking it into another project.\n */\nexport async function sessionContinuesIn(store: SessionStore, sessionId: string, cwd: string): Promise<boolean> {\n\tconst { header, entries } = await store.load(sessionId);\n\tconst mappings = entries.flatMap((entry) =>\n\t\tentry.type === \"worktree_snapshot\" && entry.restore ? [entry.restore] : [],\n\t);\n\tif (mappings.length === 0) return false;\n\tconst mapped = mapRestoredPath(header.cwd, mappings);\n\treturn canonicalizeWorktreePath(mapped) === canonicalizeWorktreePath(cwd);\n}\n\n/** The restores recorded on `branch`, oldest first. */\nfunction restoreMappings(branch: readonly SessionEntry[]): WorktreeRootMapping[] {\n\treturn branch.flatMap((entry) => (entry.type === \"worktree_snapshot\" && entry.restore ? [entry.restore] : []));\n}\n\n/** The restores and current snapshots of the branch of stored `entries` that ends at `leafId`, as resume finds them. */\nfunction storedBranchSnapshots(\n\tentries: readonly SessionEntry[],\n\tleafId: string | undefined,\n): { readonly mappings: WorktreeRootMapping[]; readonly current: Map<string, WorktreeSnapshot> } {\n\tconst branch = getBranchPath(leafId, new Map(entries.map((entry) => [entry.id, entry])));\n\tconst records = new Map<string, WorktreeSnapshot>();\n\tfor (const entry of entries) {\n\t\tif (entry.type === \"worktree_snapshot\" && entry.snapshot) records.set(entry.snapshotId, entry.snapshot);\n\t}\n\tconst mappings = restoreMappings(branch);\n\tconst current = currentWorktreeSnapshots({\n\t\tgetBranch: () => branch,\n\t\tgetWorktreeRootMappings: () => mappings,\n\t\tgetWorktreeSnapshotRecords: () => records,\n\t});\n\treturn { mappings, current };\n}\n\n/**\n * Whether a session runs in a checkout it recorded snapshots of: its working directory, followed through the restores\n * it recorded, lies inside a checkout the branch it reopens on recorded a snapshot of. Opening such a session from\n * another directory resumes it against that checkout, verified in place or restored into a fresh worktree, instead of\n * forking it into the other directory.\n */\nexport async function sessionRunsInRecordedCheckout(store: SessionStore, sessionId: string): Promise<boolean> {\n\tconst { header, entries } = await store.load(sessionId);\n\tconst { mappings, current } = storedBranchSnapshots(entries, entries.at(-1)?.id);\n\tconst cwd = mapRestoredPath(header.cwd, mappings);\n\treturn [...current.keys()].some((root) => isInside(root, cwd));\n}\n"]}
1
+ {"version":3,"file":"session-worktree-snapshots.js","sourceRoot":"","sources":["../../src/core/session-worktree-snapshots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;A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AC,CAAC,EAAE,EAAE,CAAC,CAAC;IACjF,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAClD,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import { stat } from \"node:fs/promises\";\nimport { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport type { AssistantMessage } from \"@bastani/pi-ai/compat\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport { getBranchPath } from \"./session-manager-history.ts\";\nimport type { SessionEntry, WorktreeRestoreHostWarning } from \"./session-manager-types.ts\";\nimport type { SessionStore } from \"./storage/session/types.js\";\nimport { snapshotBlobHashes } from \"./worktree-snapshot/blob-store.ts\";\nimport {\n\tcaptureWorktreeSnapshot,\n\tlocateCheckout,\n\ttype WorktreeSnapshotUnavailableReason,\n\twithScratchDirectory,\n\twriteWorkingTree,\n} from \"./worktree-snapshot/capture.ts\";\nimport { sha256Hex } from \"./worktree-snapshot/env-hash.ts\";\nimport {\n\tfindWorkspaceError,\n\ttype GitUnavailableError,\n\tisGitUnavailableError,\n\tisWorkspaceDriftError,\n\tisWorkspaceSnapshotError,\n\tunreadablePathError,\n\tWorkspaceDriftError,\n\ttype WorkspaceError,\n\tWorkspaceRestoreError,\n\tWorkspaceSnapshotError,\n} from \"./worktree-snapshot/errors.ts\";\nimport { scheduleSnapshotCollection } from \"./worktree-snapshot/garbage.ts\";\nimport { gitText, runGit } from \"./worktree-snapshot/git.ts\";\nimport { isHeadOnlyAdvance } from \"./worktree-snapshot/head-advance.ts\";\nimport { canonicalizeWorktreePath } from \"./worktree-snapshot/paths.ts\";\nimport { loadSnapshotPathPolicy } from \"./worktree-snapshot/policy.ts\";\nimport {\n\tremoveRestoredWorktree,\n\trestoreWorktree,\n\tsnapshotRestoreWarnings,\n\tverifyWorktree,\n} from \"./worktree-snapshot/restore.ts\";\nimport type {\n\tSnapshotBlob,\n\tSnapshotBlobStore,\n\tWorktreeRestoreWarning,\n\tWorktreeRootMapping,\n\tWorktreeSnapshot,\n\tWorktreeSnapshotSettings,\n} from \"./worktree-snapshot/types.ts\";\n\n/** Why a turn's snapshot could not be recorded: Git is unavailable, or a typed workspace failure. */\nexport type WorktreeSnapshotUnavailable = WorkspaceError | GitUnavailableError;\n\n/** Built-in tools that can change files: a turn that called one records a snapshot. */\nexport const FILE_WRITING_TOOLS: ReadonlySet<string> = new Set([\"bash\", \"edit\", \"write\", \"powershell\"]);\nconst PATH_TOOLS: ReadonlySet<string> = new Set([\"edit\", \"write\"]);\n\nexport interface TurnSnapshotDependencies {\n\treadonly sessionManager: SessionManager;\n\treadonly cwd: () => string;\n\treadonly settings: () => WorktreeSnapshotSettings;\n\t/** Whether a registered tool declares `writesFiles`. */\n\treadonly declaresWrites: (toolName: string) => boolean;\n\t/** Called once per distinct reason a snapshot could not be recorded. */\n\treadonly onUnavailable: (reason: WorktreeSnapshotUnavailable) => void;\n}\n\nfunction isInside(parent: string, child: string): boolean {\n\tconst path = relative(canonicalizeWorktreePath(parent), canonicalizeWorktreePath(child));\n\treturn path === \"\" || (!path.startsWith(`..${sep}`) && path !== \"..\" && !isAbsolute(path));\n}\n\n/**\n * Records a `worktree_snapshot` entry per checkout at the end of each turn that called a file-writing tool. In-memory\n * sessions, which cannot be resumed elsewhere, record nothing.\n */\nexport class SessionWorktreeSnapshotRecorder {\n\tprivate readonly deps: TurnSnapshotDependencies;\n\tprivate readonly reported = new Set<string>();\n\n\tconstructor(deps: TurnSnapshotDependencies) {\n\t\tthis.deps = deps;\n\t}\n\n\tprivate report(reason: WorktreeSnapshotUnavailable): void {\n\t\tconst key = `${reason.code}\\0${JSON.stringify(reason.fields)}`;\n\t\tif (this.reported.has(key)) return;\n\t\tthis.reported.add(key);\n\t\tthis.deps.onUnavailable(reason);\n\t}\n\n\t/** Directories whose checkouts a turn may have changed: the session cwd and the targets of path-taking tools. */\n\tprivate touchedDirectories(message: AssistantMessage): string[] | undefined {\n\t\tconst cwd = this.deps.cwd();\n\t\tconst directories = new Set<string>();\n\t\tfor (const part of message.content) {\n\t\t\tif (part.type !== \"toolCall\") continue;\n\t\t\tif (!FILE_WRITING_TOOLS.has(part.name) && !this.deps.declaresWrites(part.name)) continue;\n\t\t\tdirectories.add(cwd);\n\t\t\tconst path = PATH_TOOLS.has(part.name) ? part.arguments.path : undefined;\n\t\t\tif (typeof path === \"string\" && path.length > 0) directories.add(resolve(cwd, path, \"..\"));\n\t\t}\n\t\treturn directories.size === 0 ? undefined : [...directories];\n\t}\n\n\t/** Whether the turn may record a snapshot when it ends: a persisted session called a tool that can change files. */\n\tcallsFileWritingTool(message: AssistantMessage): boolean {\n\t\treturn this.deps.sessionManager.isPersisted() && this.touchedDirectories(message) !== undefined;\n\t}\n\n\tasync recordTurn(message: AssistantMessage): Promise<void> {\n\t\tconst directories = this.touchedDirectories(message);\n\t\tif (!directories) return;\n\t\tlet settings: WorktreeSnapshotSettings;\n\t\ttry {\n\t\t\tsettings = this.deps.settings();\n\t\t} catch (error) {\n\t\t\tthis.reportFailure(error);\n\t\t\treturn;\n\t\t}\n\t\tif (!settings.enabled || !this.deps.sessionManager.isPersisted()) return;\n\t\tconst blobs = this.deps.sessionManager.getSessionStore().snapshotBlobs;\n\t\tif (!blobs) {\n\t\t\tthis.report(\n\t\t\t\tnew WorkspaceSnapshotError(\n\t\t\t\t\t\"blob-store-unsupported\",\n\t\t\t\t\tthis.deps.sessionManager.getSessionStore().descriptor.adapter,\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tconst roots = new Set<string>();\n\t\tfor (const directory of directories) {\n\t\t\ttry {\n\t\t\t\tconst checkout = await locateCheckout(await nearestExisting(directory));\n\t\t\t\tif (checkout instanceof Error) this.report(checkout);\n\t\t\t\telse roots.add(checkout.root);\n\t\t\t} catch (error) {\n\t\t\t\tthis.reportFailure(error);\n\t\t\t}\n\t\t}\n\t\tfor (const root of roots) {\n\t\t\tconst previous = this.deps.sessionManager.getLatestWorktreeSnapshots().get(root);\n\t\t\ttry {\n\t\t\t\tconst result = await captureWorktreeSnapshot(root, { settings, previous, blobs });\n\t\t\t\tif (result.status === \"captured\") {\n\t\t\t\t\tawait this.deps.sessionManager.appendWorktreeSnapshot(root, result.snapshot.id, result.snapshot);\n\t\t\t\t} else if (result.status === \"unchanged\") {\n\t\t\t\t\tawait this.deps.sessionManager.appendWorktreeSnapshot(root, result.snapshot.id);\n\t\t\t\t} else if (result.status === \"unavailable\") {\n\t\t\t\t\tthis.report(result.reason);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tthis.reportFailure(error);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Starts an automatic collection of the session store's unreferenced snapshot blobs when one is due, and returns\n\t * without waiting for it. Called when the session closes.\n\t */\n\tscheduleCollection(): void {\n\t\tlet settings: WorktreeSnapshotSettings;\n\t\ttry {\n\t\t\tsettings = this.deps.settings();\n\t\t} catch (error) {\n\t\t\tthis.reportFailure(error);\n\t\t\treturn;\n\t\t}\n\t\tvoid scheduleSnapshotCollection(this.deps.sessionManager.getSessionStore().snapshotBlobs, settings);\n\t}\n\n\tprivate reportFailure(error: unknown): void {\n\t\tconst reason = isGitUnavailableError(error) ? error : findWorkspaceError(error);\n\t\tif (!reason) throw error;\n\t\tthis.report(reason);\n\t}\n}\n\nasync function nearestExisting(directory: string): Promise<string> {\n\tfor (let current = directory; ; current = resolve(current, \"..\")) {\n\t\ttry {\n\t\t\tif ((await stat(current)).isDirectory()) return current;\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code !== \"ENOENT\" && (error as NodeJS.ErrnoException).code !== \"ENOTDIR\")\n\t\t\t\tthrow unreadablePathError(current, error);\n\t\t}\n\t\tif (resolve(current, \"..\") === current) return current;\n\t}\n}\n\n/** `path` rewritten through each restore in order: a path under `from` moves to the same place under `to`. */\nexport function mapRestoredPath(path: string, mappings: readonly WorktreeRootMapping[]): string {\n\tlet mapped = resolve(path);\n\tlet next = 0;\n\twhile (next < mappings.length) {\n\t\tconst current = canonicalizeWorktreePath(mapped);\n\t\tlet best: { index: number; source: string } | undefined;\n\t\tfor (let index = next; index < mappings.length; index++) {\n\t\t\tconst source = canonicalizeWorktreePath(mappings[index]!.from);\n\t\t\tif (isInside(source, current) && (best === undefined || source.length > best.source.length)) {\n\t\t\t\tbest = { index, source };\n\t\t\t}\n\t\t}\n\t\tif (best === undefined) break;\n\t\tmapped = resolve(mappings[best.index]!.to, relative(best.source, current));\n\t\tnext = best.index + 1;\n\t}\n\treturn mapped;\n}\n\n/** Recover the original root of a sequence of restores, so a restored root supersedes its earlier location. */\nfunction originalRoot(root: string, mappings: readonly WorktreeRootMapping[]): string {\n\tlet current = canonicalizeWorktreePath(root);\n\tfor (let index = mappings.length - 1; index >= 0; index--) {\n\t\tconst mapping = mappings[index]!;\n\t\tif (canonicalizeWorktreePath(mapping.to) === current) current = canonicalizeWorktreePath(mapping.from);\n\t}\n\treturn current;\n}\n\n/** The id of the latest snapshot of each checkout on the active branch, keyed by the root it was first recorded under. */\nfunction latestSnapshotIdsByCheckout(\n\tsessionManager: Pick<SessionManager, \"getBranch\">,\n\tmappings: readonly WorktreeRootMapping[],\n): Map<string, string> {\n\tconst latestIds = new Map<string, string>();\n\tfor (const entry of sessionManager.getBranch()) {\n\t\tif (entry.type === \"worktree_snapshot\") latestIds.set(originalRoot(entry.root, mappings), entry.snapshotId);\n\t}\n\treturn latestIds;\n}\n\n/**\n * The latest snapshot of each checkout on the active branch, keyed by where that checkout is now: a checkout restored\n * elsewhere appears once, under its newest location. A snapshot whose record is missing is left out.\n */\nexport function currentWorktreeSnapshots(\n\tsessionManager: Pick<SessionManager, \"getBranch\" | \"getWorktreeRootMappings\" | \"getWorktreeSnapshotRecords\">,\n): Map<string, WorktreeSnapshot> {\n\tconst mappings = sessionManager.getWorktreeRootMappings();\n\tconst records = sessionManager.getWorktreeSnapshotRecords();\n\tconst current = new Map<string, WorktreeSnapshot>();\n\tfor (const [original, snapshotId] of latestSnapshotIdsByCheckout(sessionManager, mappings)) {\n\t\tconst snapshot = records.get(snapshotId);\n\t\tif (snapshot) current.set(mapRestoredPath(original, mappings), snapshot);\n\t}\n\treturn current;\n}\n\nexport type SessionWorktreeResume =\n\t| { readonly status: \"none\" }\n\t| { readonly status: \"verified\"; readonly snapshot: WorktreeSnapshot; readonly cwd: string }\n\t| {\n\t\t\treadonly status: \"restored\";\n\t\t\treadonly snapshot: WorktreeSnapshot;\n\t\t\treadonly mappings: readonly WorktreeRootMapping[];\n\t\t\treadonly cwd: string;\n\t\t\treadonly warnings: readonly WorktreeRestoreWarning[];\n\t };\n\nexport interface ResumeSessionWorktreeOptions {\n\treadonly settings: WorktreeSnapshotSettings;\n\t/** Host directory for shared object stores and restored worktrees. Default ~/.atomic/agent/worktree-snapshots. */\n\treadonly storeDir?: string;\n\treadonly signal?: AbortSignal;\n\t/**\n\t * Called with the new mappings, none when nothing needed restoring, once every checkout is restored and before any\n\t * of them is recorded. When it throws, nothing is recorded and the restored worktrees are removed, as for a failed\n\t * restore.\n\t */\n\treadonly beforeRecord?: (mappings: readonly WorktreeRootMapping[]) => Promise<void>;\n\t/**\n\t * Mappings to checkouts already here that the session continues in, applied as if recorded while deciding what to\n\t * restore, and recorded first, with the restores, only once every checkout is restored and `beforeRecord` passed.\n\t */\n\treadonly pendingMappings?: readonly WorktreeRootMapping[];\n\t/** Checkouts, by the root the session's restores put them at, to continue in as they are without verifying them. */\n\treadonly keepInPlace?: ReadonlySet<string>;\n}\n\n/**\n * Checks the latest recorded snapshot of each checkout on the active session branch. Drifted or missing checkouts are\n * restored into fresh worktrees, and each old→new mapping is recorded only after all checkouts have been restored.\n * The returned cwd follows those mappings. A HEAD-only advance over identical content also resumes in place.\n */\nexport async function resumeSessionWorktree(\n\tsessionManager: SessionManager,\n\toptions: ResumeSessionWorktreeOptions,\n): Promise<SessionWorktreeResume> {\n\tif (!options.settings.enabled) return { status: \"none\" };\n\tconst pending = options.pendingMappings ?? [];\n\tconst existing = [...sessionManager.getWorktreeRootMappings(), ...pending];\n\tconst records = sessionManager.getWorktreeSnapshotRecords();\n\tconst latestIds = latestSnapshotIdsByCheckout(sessionManager, existing);\n\tconst latest = new Map<string, WorktreeSnapshot>();\n\tfor (const [root, snapshotId] of latestIds) {\n\t\tconst snapshot = records.get(snapshotId);\n\t\tif (!snapshot) throw new WorkspaceRestoreError(\"snapshot-not-found\", { snapshotId, target: root });\n\t\tlatest.set(root, snapshot);\n\t}\n\tif (latest.size === 0) return { status: \"none\" };\n\tconst cwd = mapRestoredPath(sessionManager.getCwd(), existing);\n\tconst mappings: WorktreeRootMapping[] = [];\n\tconst warnings: WorktreeRestoreWarning[] = [];\n\tconst hostWarnings = new Map<WorktreeRootMapping, WorktreeRestoreHostWarning[]>();\n\tconst reportedLeftovers = new Set<string>();\n\tlet selected: { root: string; snapshot: WorktreeSnapshot } | undefined;\n\ttry {\n\t\tfor (const [original, snapshot] of latest) {\n\t\t\toptions.signal?.throwIfAborted();\n\t\t\tconst root = mapRestoredPath(original, existing);\n\t\t\tif (isInside(root, cwd) && (!selected || root.length > selected.root.length)) selected = { root, snapshot };\n\t\t\tif (options.keepInPlace?.has(root)) continue;\n\t\t\tlet drift: WorkspaceDriftError;\n\t\t\ttry {\n\t\t\t\tawait verifyWorktree(snapshot, root, { settings: options.settings, signal: options.signal });\n\t\t\t\tcontinue;\n\t\t\t} catch (error) {\n\t\t\t\toptions.signal?.throwIfAborted();\n\t\t\t\tif (isWorkspaceDriftError(error)) {\n\t\t\t\t\tif (await isHeadOnlyAdvance(error, options.signal)) continue;\n\t\t\t\t\tdrift = error;\n\t\t\t\t} else if (isWorkspaceSnapshotError(error)) {\n\t\t\t\t\tdrift = new WorkspaceDriftError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\troot,\n\t\t\t\t\t\t\texpectedHead: snapshot.head,\n\t\t\t\t\t\t\tactualHead: null,\n\t\t\t\t\t\t\texpectedTree: snapshot.tree,\n\t\t\t\t\t\t\tactualTree: null,\n\t\t\t\t\t\t\tsnapshotId: snapshot.id,\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t} else throw error;\n\t\t\t}\n\t\t\tlet restored: Awaited<ReturnType<typeof restoreWorktree>>;\n\t\t\ttry {\n\t\t\t\trestored = await restoreWorktree(snapshot, {\n\t\t\t\t\tblobs: sessionSnapshotBlobs(sessionManager.getSessionStore().snapshotBlobs, sessionManager.getEntries()),\n\t\t\t\t\tstoreDir: options.storeDir,\n\t\t\t\t\tsignal: options.signal,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\toptions.signal?.throwIfAborted();\n\t\t\t\tif (!(error instanceof Error)) throw error;\n\t\t\t\tthrow new WorkspaceDriftError(\n\t\t\t\t\t{\n\t\t\t\t\t\troot: drift.root,\n\t\t\t\t\t\texpectedHead: drift.expectedHead,\n\t\t\t\t\t\tactualHead: drift.actualHead,\n\t\t\t\t\t\texpectedTree: drift.expectedTree,\n\t\t\t\t\t\tactualTree: drift.actualTree,\n\t\t\t\t\t\tsnapshotId: drift.snapshotId,\n\t\t\t\t\t\treason: \"restore-failed\",\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst mapping: WorktreeRootMapping = {\n\t\t\t\tfrom: root,\n\t\t\t\tto: restored.path,\n\t\t\t\tsnapshotId: snapshot.id,\n\t\t\t\ttree: snapshot.tree,\n\t\t\t\trestoredAt: new Date().toISOString(),\n\t\t\t};\n\t\t\tmappings.push(mapping);\n\t\t\twarnings.push(...restored.warnings);\n\t\t\thostWarnings.set(\n\t\t\t\tmapping,\n\t\t\t\trestored.warnings.filter((warning): warning is WorktreeRestoreHostWarning => {\n\t\t\t\t\tif (warning.code === \"lfs-objects-unavailable\") return true;\n\t\t\t\t\tif (warning.code !== \"stale-restore-retained\" || reportedLeftovers.has(warning.path)) return false;\n\t\t\t\t\treportedLeftovers.add(warning.path);\n\t\t\t\t\treturn true;\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\tawait options.beforeRecord?.(mappings);\n\t\tfor (const mapping of [...pending, ...mappings]) {\n\t\t\toptions.signal?.throwIfAborted();\n\t\t\tawait sessionManager.appendWorktreeSnapshot(\n\t\t\t\tmapping.to,\n\t\t\t\tmapping.snapshotId,\n\t\t\t\tundefined,\n\t\t\t\tmapping,\n\t\t\t\thostWarnings.get(mapping),\n\t\t\t);\n\t\t}\n\t} catch (error) {\n\t\tconst cleanupFailures: unknown[] = [];\n\t\tfor (const mapping of [...mappings].reverse()) {\n\t\t\ttry {\n\t\t\t\tawait removeRestoredWorktree(mapping.to, { storeDir: options.storeDir });\n\t\t\t} catch (cleanupCause) {\n\t\t\t\tcleanupFailures.push(cleanupCause);\n\t\t\t}\n\t\t}\n\t\tif (cleanupFailures.length > 0 && error instanceof Error && Object.isExtensible(error)) {\n\t\t\tObject.defineProperty(error, \"cleanupCause\", {\n\t\t\t\tvalue: cleanupFailures.length === 1 ? cleanupFailures[0] : new AggregateError(cleanupFailures),\n\t\t\t\tconfigurable: true,\n\t\t\t});\n\t\t}\n\t\tthrow error;\n\t}\n\tconst snapshot = selected?.snapshot ?? [...latest.values()].at(-1)!;\n\tconst mappedCwd = mapRestoredPath(cwd, mappings);\n\treturn mappings.length === 0\n\t\t? { status: \"verified\", snapshot, cwd: mappedCwd }\n\t\t: { status: \"restored\", snapshot, mappings, cwd: mappedCwd, warnings };\n}\n\n/** The one-line notice shown when a session or run continues in a restored worktree. */\nexport function formatWorktreeRestoreNotice(mapping: WorktreeRootMapping): string {\n\treturn `Restored worktree snapshot ${mapping.snapshotId.slice(0, 12)} of ${mapping.from} into ${mapping.to}`;\n}\n\n/** One line per restore warning, for the notices shown after a restore. */\nexport function formatWorktreeRestoreWarning(warning: WorktreeRestoreWarning): string {\n\tswitch (warning.code) {\n\t\tcase \"omitted-content\":\n\t\t\treturn `The restored snapshot left out ${warning.omitted.length} item(s): ${warning.omitted\n\t\t\t\t.map((omission) => (\"path\" in omission ? `${omission.path} (${omission.reason})` : omission.reason))\n\t\t\t\t.join(\", \")}`;\n\t\tcase \"filters\":\n\t\t\treturn `The source checkout used conversion settings (${[\n\t\t\t\twarning.filters.autocrlf === null ? undefined : `core.autocrlf=${warning.filters.autocrlf}`,\n\t\t\t\twarning.filters.eol === null ? undefined : `core.eol=${warning.filters.eol}`,\n\t\t\t\t...warning.filters.drivers.map((driver) => `filter=${driver}`),\n\t\t\t]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(\", \")}); the restore holds Git's stored content with LF line endings`;\n\t\tcase \"lfs-objects-unavailable\":\n\t\t\treturn `Git LFS objects could not be fetched; these files hold LFS pointers: ${warning.paths.join(\", \")}`;\n\t\tcase \"stale-restore-retained\":\n\t\t\tswitch (warning.kind) {\n\t\t\t\tcase \"worktree\":\n\t\t\t\t\treturn `A restore interrupted earlier left ${warning.path}; remove it with removeRestoredWorktree or delete the directory`;\n\t\t\t\tcase \"record\":\n\t\t\t\t\treturn `A restore interrupted earlier left the crash record ${warning.path}, which cannot be read; delete the file`;\n\t\t\t\tcase \"records-directory\":\n\t\t\t\t\treturn `The restore crash records in ${warning.path} cannot be read; make the directory readable or remove it`;\n\t\t\t}\n\t}\n}\n\n/**\n * One informational line per worktree restored since `since`, each followed by its snapshot's warnings and what the\n * restore itself reported.\n */\nexport function worktreeRestoreNotices(\n\tsessionManager: Pick<SessionManager, \"getBranch\" | \"getWorktreeSnapshotRecords\">,\n\tsince: string,\n): { readonly type: \"info\" | \"warning\"; readonly message: string }[] {\n\treturn restoreNotices(sessionManager, (restore) => restore.restoredAt >= since);\n}\n\nfunction restoreNotices(\n\tsessionManager: Pick<SessionManager, \"getBranch\" | \"getWorktreeSnapshotRecords\">,\n\tinclude: (restore: WorktreeRootMapping) => boolean,\n): { readonly type: \"info\" | \"warning\"; readonly message: string }[] {\n\tconst records = sessionManager.getWorktreeSnapshotRecords();\n\treturn sessionManager.getBranch().flatMap((entry) => {\n\t\tif (entry.type !== \"worktree_snapshot\" || !entry.restore || !include(entry.restore)) return [];\n\t\tconst snapshot = records.get(entry.snapshotId);\n\t\treturn [\n\t\t\t{ type: \"info\" as const, message: formatWorktreeRestoreNotice(entry.restore) },\n\t\t\t...[...(snapshot ? snapshotRestoreWarnings(snapshot) : []), ...(entry.restoreWarnings ?? [])].map(\n\t\t\t\t(warning) => ({ type: \"warning\" as const, message: formatWorktreeRestoreWarning(warning) }),\n\t\t\t),\n\t\t];\n\t});\n}\n\n/**\n * `entries` with each snapshot's record and blobs from `store` carried inline, each once, so the exported file\n * restores without the source storage. Without a store only the records are carried. A blob the store no longer has\n * is left out; restoring that snapshot then fails with `blob-missing`.\n */\nexport async function inlineSnapshotBlobs(\n\tentries: readonly SessionEntry[],\n\trecords: ReadonlyMap<string, WorktreeSnapshot>,\n\tstore: SnapshotBlobStore | undefined,\n): Promise<SessionEntry[]> {\n\tconst emittedRecords = new Set<string>();\n\tconst emittedBlobs = new Set<string>();\n\tconst result: SessionEntry[] = [];\n\tfor (const entry of entries) {\n\t\tif (entry.type !== \"worktree_snapshot\") {\n\t\t\tresult.push(entry);\n\t\t\tcontinue;\n\t\t}\n\t\tconst record = entry.snapshot ?? records.get(entry.snapshotId);\n\t\tconst { blobs: _carried, snapshot: _record, ...rest } = entry;\n\t\tconst blobs: Record<string, string> = {};\n\t\tif (record && store) {\n\t\t\tfor (const hash of snapshotBlobHashes(record)) {\n\t\t\t\tif (emittedBlobs.has(hash)) continue;\n\t\t\t\tconst data = await store.getBlob(hash);\n\t\t\t\tif (data === undefined) continue;\n\t\t\t\tblobs[hash] = Buffer.from(data).toString(\"base64\");\n\t\t\t\temittedBlobs.add(hash);\n\t\t\t}\n\t\t}\n\t\tconst carryRecord = record !== undefined && !emittedRecords.has(record.id);\n\t\tif (record) emittedRecords.add(record.id);\n\t\tresult.push({\n\t\t\t...rest,\n\t\t\t...(carryRecord ? { snapshot: record } : {}),\n\t\t\t...(Object.keys(blobs).length > 0 ? { blobs } : {}),\n\t\t});\n\t}\n\treturn result;\n}\n\n/**\n * Moves inline blobs into `store` after checking each against its hash, and returns the entries without them.\n * Without a store the entries keep their blobs, which restore reads directly. Throws `blob-corrupt` before writing\n * anything when a blob does not match its hash.\n */\nexport async function adoptInlineSnapshotBlobs(\n\tentries: readonly SessionEntry[],\n\tstore: SnapshotBlobStore | undefined,\n): Promise<SessionEntry[]> {\n\tconst blobs: SnapshotBlob[] = [];\n\tfor (const entry of entries) {\n\t\tif (entry.type !== \"worktree_snapshot\" || !entry.blobs) continue;\n\t\tfor (const [hash, base64] of Object.entries(entry.blobs)) {\n\t\t\tconst data = new Uint8Array(Buffer.from(base64, \"base64\"));\n\t\t\tif (sha256Hex(data) !== hash) {\n\t\t\t\tthrow new WorkspaceRestoreError(\"blob-corrupt\", { snapshotId: entry.snapshotId, blob: hash });\n\t\t\t}\n\t\t\tblobs.push({ hash, data });\n\t\t}\n\t}\n\tif (!store || blobs.length === 0) return [...entries];\n\tawait store.putBlobs(blobs);\n\treturn entries.map((entry) => {\n\t\tif (entry.type !== \"worktree_snapshot\" || !entry.blobs) return entry;\n\t\tconst { blobs: _moved, ...rest } = entry;\n\t\treturn rest;\n\t});\n}\n\n/** A read-only view of the blobs carried inline by `entries`. */\nexport function inlineBlobStore(entries: readonly SessionEntry[]): SnapshotBlobStore {\n\tconst blobs = new Map<string, string>();\n\tfor (const entry of entries) {\n\t\tif (entry.type === \"worktree_snapshot\" && entry.blobs) {\n\t\t\tfor (const [hash, base64] of Object.entries(entry.blobs)) blobs.set(hash, base64);\n\t\t}\n\t}\n\treturn {\n\t\tasync putBlobs() {\n\t\t\tthrow new WorkspaceSnapshotError(\"blob-store-unsupported\", \"inline\");\n\t\t},\n\t\tasync getBlob(hash) {\n\t\t\tconst base64 = blobs.get(hash);\n\t\t\treturn base64 === undefined ? undefined : new Uint8Array(Buffer.from(base64, \"base64\"));\n\t\t},\n\t\tasync refreshBlobs(hashes) {\n\t\t\treturn hashes.every((hash) => blobs.has(hash));\n\t\t},\n\t\tasync listBlobHashes() {\n\t\t\treturn [...blobs.keys()];\n\t\t},\n\t};\n}\n\n/** Reads `primary` first, then the blobs carried inline by `entries`. */\nexport function sessionSnapshotBlobs(\n\tprimary: SnapshotBlobStore | undefined,\n\tentries: readonly SessionEntry[],\n): SnapshotBlobStore {\n\tconst inline = inlineBlobStore(entries);\n\tif (!primary) return inline;\n\treturn {\n\t\tputBlobs: (blobs) => primary.putBlobs(blobs),\n\t\tgetBlob: async (hash) => (await primary.getBlob(hash)) ?? (await inline.getBlob(hash)),\n\t\trefreshBlobs: (hashes) => primary.refreshBlobs(hashes),\n\t\tlistBlobHashes: () => primary.listBlobHashes(),\n\t};\n}\n\n/** What an export of `entries` carries: checkouts, snapshots and the bytes of patch and bundle content. */\nexport function describeSnapshotExport(\n\tentries: readonly SessionEntry[],\n\trecords: ReadonlyMap<string, WorktreeSnapshot>,\n): string | undefined {\n\tconst roots = new Set<string>();\n\tconst snapshots = new Set<string>();\n\tconst blobBytes = new Map<string, number>();\n\tlet omitted = 0;\n\tfor (const entry of entries) {\n\t\tif (entry.type !== \"worktree_snapshot\" || snapshots.has(entry.snapshotId)) continue;\n\t\tsnapshots.add(entry.snapshotId);\n\t\tconst record = entry.snapshot ?? records.get(entry.snapshotId);\n\t\tif (!record) continue;\n\t\troots.add(record.root);\n\t\tomitted += record.omitted.length;\n\t\tfor (const link of record.chain) if (link.patch) blobBytes.set(link.patch, link.bytes);\n\t\tif (record.bundle) blobBytes.set(record.bundle.blob, record.bundle.bytes);\n\t}\n\tif (snapshots.size === 0) return undefined;\n\tconst bytes = [...blobBytes.values()].reduce((sum, size) => sum + size, 0);\n\treturn `Includes ${snapshots.size} worktree snapshot(s) of ${[...roots].join(\", \")}: ${bytes} bytes of patch and bundle content${omitted > 0 ? `, ${omitted} omitted item(s) not included` : \"\"}`;\n}\n\nexport type WorktreeSnapshotComparison =\n\t| { readonly status: \"match\"; readonly tree: string; readonly head?: string }\n\t| { readonly status: \"missing\"; readonly reason: WorktreeSnapshotUnavailableReason }\n\t| {\n\t\t\treadonly status: \"differs\";\n\t\t\treadonly head: string;\n\t\t\treadonly tree: string;\n\t\t\t/** `git diff --stat` from the snapshot's tree to the current one, when the snapshot's tree is present locally. */\n\t\t\treadonly stat: string | undefined;\n\t };\n\n/** Compares the checkout at `dir` with `snapshot`, for `/session snapshot`. */\nexport async function compareWorktreeSnapshot(\n\tsnapshot: WorktreeSnapshot,\n\tdir: string,\n\tsettings: WorktreeSnapshotSettings,\n): Promise<WorktreeSnapshotComparison> {\n\tconst checkout = await locateCheckout(dir);\n\tif (checkout instanceof Error) return { status: \"missing\", reason: checkout };\n\tconst present = await runGit([\"cat-file\", \"-e\", `${snapshot.tree}^{tree}`], {\n\t\tcwd: checkout.root,\n\t\tallowExitCodes: [1, 128],\n\t});\n\tconst policy = await loadSnapshotPathPolicy(checkout.root);\n\tconst state = await withScratchDirectory((scratch) =>\n\t\twriteWorkingTree(checkout, settings, policy, scratch, present.exitCode === 0 ? { seedTree: snapshot.tree } : {}),\n\t);\n\tif (state.tree === snapshot.tree) {\n\t\tif (checkout.head === snapshot.head) return { status: \"match\", tree: state.tree };\n\t\tconst drift = new WorkspaceDriftError({\n\t\t\troot: checkout.root,\n\t\t\texpectedHead: snapshot.head,\n\t\t\tactualHead: checkout.head,\n\t\t\texpectedTree: snapshot.tree,\n\t\t\tactualTree: state.tree,\n\t\t\tsnapshotId: snapshot.id,\n\t\t});\n\t\tif (await isHeadOnlyAdvance(drift)) return { status: \"match\", tree: state.tree, head: checkout.head };\n\t}\n\tconst stat =\n\t\tpresent.exitCode === 0\n\t\t\t? await gitText([\"diff-tree\", \"--stat\", \"--no-renames\", \"--no-ext-diff\", \"-r\", snapshot.tree, state.tree], {\n\t\t\t\t\tcwd: checkout.root,\n\t\t\t\t})\n\t\t\t: undefined;\n\treturn { status: \"differs\", head: checkout.head, tree: state.tree, stat };\n}\n\n/** Lines describing `snapshot` for `/session snapshot`. */\nexport function describeWorktreeSnapshot(root: string, snapshot: WorktreeSnapshot): string[] {\n\tconst omitted = snapshot.omitted.map((omission) =>\n\t\t\"path\" in omission\n\t\t\t? `${omission.path} (${omission.reason})`\n\t\t\t: `${omission.commits.length} commit(s) (${omission.reason})`,\n\t);\n\treturn [\n\t\t`${root}`,\n\t\t` snapshot ${snapshot.id} captured ${snapshot.capturedAt}`,\n\t\t` ${snapshot.branch ?? \"detached\"} at ${snapshot.head.slice(0, 12)}, tree ${snapshot.tree.slice(0, 12)}`,\n\t\t` delta chain ${snapshot.chain.length} link(s), ${snapshot.chain.reduce((sum, link) => sum + link.bytes, 0)} bytes; ${\n\t\t\tsnapshot.bundle\n\t\t\t\t? `${snapshot.bundle.commits.length} unpushed commit(s) bundled`\n\t\t\t\t: \"no unpushed commits bundled\"\n\t\t}`,\n\t\t...(omitted.length > 0 ? [` omitted: ${omitted.join(\", \")}`] : []),\n\t\t...(snapshot.filters\n\t\t\t? snapshotRestoreWarnings({ ...snapshot, omitted: [] }).map(formatWorktreeRestoreWarning)\n\t\t\t: []),\n\t];\n}\n\n/**\n * Opens `sessionManager`'s session where it should continue: in place when its checkout matches the last snapshot,\n * in the restored worktree otherwise. Returns the notices to show for a restore it performed.\n */\nexport async function openSessionInWorktree(\n\tsessionManager: SessionManager,\n\toptions: ResumeSessionWorktreeOptions & { readonly sessionDirectory?: string },\n): Promise<{\n\treadonly sessionManager: SessionManager;\n\treadonly notices: { readonly type: \"info\" | \"warning\"; readonly message: string }[];\n}> {\n\tconst resume = await resumeSessionWorktree(sessionManager, options);\n\treturn openResumedSession(\n\t\tsessionManager,\n\t\tresume.status === \"none\" ? sessionManager.getCwd() : resume.cwd,\n\t\tresume.status === \"restored\" ? resume.mappings : [],\n\t\toptions.sessionDirectory,\n\t);\n}\n\n/**\n * Opens `sessionManager`'s session in `cwd`, where resuming it left its working directory, and returns the notices to\n * show for the worktrees that resuming `restored` it into.\n */\nexport async function openResumedSession(\n\tsessionManager: SessionManager,\n\tcwd: string,\n\trestored: readonly WorktreeRootMapping[],\n\tsessionDirectory?: string,\n): Promise<{\n\treadonly sessionManager: SessionManager;\n\treadonly notices: { readonly type: \"info\" | \"warning\"; readonly message: string }[];\n}> {\n\tconst opened =\n\t\tcwd !== sessionManager.getCwd()\n\t\t\t? await sessionManager.openSessionById(sessionManager.getSessionId(), cwd, sessionDirectory)\n\t\t\t: sessionManager;\n\tconst restoredHere = new Set(restored.map((mapping) => mapping.to));\n\treturn { sessionManager: opened, notices: restoreNotices(opened, (restore) => restoredHere.has(restore.to)) };\n}\n\n/**\n * Whether a session recorded elsewhere continues in `cwd` because a restore moved its checkout there, so opening it\n * from `cwd` resumes it rather than forking it into another project.\n */\nexport async function sessionContinuesIn(store: SessionStore, sessionId: string, cwd: string): Promise<boolean> {\n\tconst { header, entries } = await store.load(sessionId);\n\tconst mappings = entries.flatMap((entry) =>\n\t\tentry.type === \"worktree_snapshot\" && entry.restore ? [entry.restore] : [],\n\t);\n\tif (mappings.length === 0) return false;\n\tconst mapped = mapRestoredPath(header.cwd, mappings);\n\treturn canonicalizeWorktreePath(mapped) === canonicalizeWorktreePath(cwd);\n}\n\n/** The restores recorded on `branch`, oldest first. */\nfunction restoreMappings(branch: readonly SessionEntry[]): WorktreeRootMapping[] {\n\treturn branch.flatMap((entry) => (entry.type === \"worktree_snapshot\" && entry.restore ? [entry.restore] : []));\n}\n\n/** The restores and current snapshots of the branch of stored `entries` that ends at `leafId`, as resume finds them. */\nfunction storedBranchSnapshots(\n\tentries: readonly SessionEntry[],\n\tleafId: string | undefined,\n): { readonly mappings: WorktreeRootMapping[]; readonly current: Map<string, WorktreeSnapshot> } {\n\tconst branch = getBranchPath(leafId, new Map(entries.map((entry) => [entry.id, entry])));\n\tconst records = new Map<string, WorktreeSnapshot>();\n\tfor (const entry of entries) {\n\t\tif (entry.type === \"worktree_snapshot\" && entry.snapshot) records.set(entry.snapshotId, entry.snapshot);\n\t}\n\tconst mappings = restoreMappings(branch);\n\tconst current = currentWorktreeSnapshots({\n\t\tgetBranch: () => branch,\n\t\tgetWorktreeRootMappings: () => mappings,\n\t\tgetWorktreeSnapshotRecords: () => records,\n\t});\n\treturn { mappings, current };\n}\n\n/**\n * Whether a session runs in a checkout it recorded snapshots of: its working directory, followed through the restores\n * it recorded, lies inside a checkout the branch it reopens on recorded a snapshot of. Opening such a session from\n * another directory resumes it against that checkout, verified in place or restored into a fresh worktree, instead of\n * forking it into the other directory.\n */\nexport async function sessionRunsInRecordedCheckout(store: SessionStore, sessionId: string): Promise<boolean> {\n\tconst { header, entries } = await store.load(sessionId);\n\tconst { mappings, current } = storedBranchSnapshots(entries, entries.at(-1)?.id);\n\tconst cwd = mapRestoredPath(header.cwd, mappings);\n\treturn [...current.keys()].some((root) => isInside(root, cwd));\n}\n"]}
@@ -97,7 +97,7 @@ export declare const SETTINGS_DEFAULTS: {
97
97
  readonly showUnknownTargetWarnings: false;
98
98
  };
99
99
  readonly httpIdleTimeoutMs: 600000;
100
- readonly cacheWarming: "streaming";
100
+ readonly cacheWarming: "idle";
101
101
  readonly tasks: {
102
102
  /** Same 15-minute default as workflow heartbeats. */
103
103
  readonly heartbeatMs: number;
@@ -1 +1 @@
1
- {"version":3,"file":"settings-defaults.d.ts","sourceRoot":"","sources":["../../src/core/settings-defaults.ts"],"names":[],"mappings":"AAEA,mFAAmF;AACnF,eAAO,MAAM,iBAAiB;aAC7B,aAAa,EAAE,EAAE;aACjB,SAAS,EAAE,MAAM;aACjB,YAAY,EAAE,eAAe;aAC7B,YAAY,EAAE,eAAe;aAC7B,UAAU;iBACT,OAAO;iBACP,aAAa,EAAE,KAAK;iBACpB,iBAAiB,EAAE,GAAG;iBACtB,eAAe,EAAE,CAAC;QAClB,oGAAoG;iBACpG,iBAAiB,EAAE,MAAO;QAC1B,4GAA4G;i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B,iBAAiB,EAAE,MAAO;aAC1B,YAAY,EAAE,WAAW;aACzB,KAAK;QACJ,qDAAqD;iBACrD,WAAW;;CAEH,CAAC"}
1
+ {"version":3,"file":"settings-defaults.d.ts","sourceRoot":"","sources":["../../src/core/settings-defaults.ts"],"names":[],"mappings":"AAEA,mFAAmF;AACnF,eAAO,MAAM,iBAAiB;aAC7B,aAAa,EAAE,EAAE;aACjB,SAAS,EAAE,MAAM;aACjB,YAAY,EAAE,eAAe;aAC7B,YAAY,EAAE,eAAe;aAC7B,UAAU;iBACT,OAAO;iBACP,aAAa,EAAE,KAAK;iBACpB,iBAAiB,EAAE,GAAG;iBACtB,eAAe,EAAE,CAAC;QAClB,oGAAoG;iBACpG,iBAAiB,EAAE,MAAO;QAC1B,4GAA4G;iBAC5G,UAAU;iBACV,0BAA0B,EAAE,EAAE;QAC9B,oGAAoG;iBACpG,aAAa;;aAEd,aAAa;iBACZ,aAAa,EAAE,KAAK;iBACpB,UAAU;;aAEX,cAAc;iBACb,OAAO;;aAER,SAAS;iBACR,OAAO;iBACP,gBAAgB;iBAChB,YAAY;iBACZ,gBAAgB;iBAChB,SAAS,EAAE,EAAE;iBACb,WAAW;iBACX,sBAAsB,EAAE,IAAI;iBAC5B,YAAY,EAAE,IAAI;;aAEnB,KAAK;iBACJ,OAAO;iBACP,UAAU,EAAE,CAAC;iBACb,WAAW,EAAE,IAAI;iBACjB,eAAe;iBACf,uBAAuB;iBACvB,QAAQ;qBACP,eAAe,EAAE,KAAK;;;aAGxB,iBAAiB;aACjB,oBAAoB;aACpB,SAAS;iBACR,qBAAqB;;aAEtB,YAAY;aACZ,mBAAmB,EAAE,KAAK;aAC1B,MAAM;iBACL,aAAa,EAAE,CAAC;iBAChB,YAAY,EAAE,CAAC;;aAEhB,iBAAiB;aACjB,KAAK;aACL,sBAAsB;aACtB,mBAAmB;aACnB,KAAK;iBACJ,OAAO;;aAER,QAAQ;iBACP,UAAU;iBACV,eAAe,EAAE,EAAE;iBACnB,aAAa;iBACb,oBAAoB;;aAErB,MAAM;iBACL,UAAU;iBACV,WAAW;;aAEZ,kBAAkB,EAAE,MAAM;aAC1B,cAAc,EAAE,SAAS;aACzB,cAAc,EAAE,CAAC;aACjB,SAAS,EAAE,CAAC;aACZ,sBAAsB,EAAE,CAAC;aACzB,mBAAmB,EAAE,MAAM;aAC3B,oBAAoB,EAAE,YAAY;aAClC,sBAAsB;aACtB,0BAA0B,EAAE,MAAM;aAClC,QAAQ;iBACP,IAAI,EAAE,IAAI;iBACV,YAAY,EAAE,IAAI;;aAEnB,QAAQ;iBACP,eAAe,EAAE,IAAI;iBACrB,OAAO,EAAE,WAAW;iBACpB,KAAK;;aAEN,QAAQ;iBACP,mBAAmB;;aAEpB,QAAQ;iBACP,yBAAyB;;aAE1B,iBAAiB,EAAE,MAAO;aAC1B,YAAY,EAAE,MAAM;aACpB,KAAK;QACJ,qDAAqD;iBACrD,WAAW;;CAEH,CAAC"}
@@ -98,7 +98,7 @@ export const SETTINGS_DEFAULTS = {
98
98
  showUnknownTargetWarnings: false,
99
99
  },
100
100
  httpIdleTimeoutMs: 600_000,
101
- cacheWarming: "streaming",
101
+ cacheWarming: "idle",
102
102
  tasks: {
103
103
  /** Same 15-minute default as workflow heartbeats. */
104
104
  heartbeatMs: 15 * 60_000,
@@ -1 +1 @@
1
- {"version":3,"file":"settings-defaults.js","sourceRoot":"","sources":["../../src/core/settings-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AAE9E,mFAAmF;AACnF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAChC,aAAa,EAAE,EAAE;IACjB,SAAS,EAAE,MAAM;IACjB,YAAY,EAAE,eAAe;IAC7B,YAAY,EAAE,eAAe;IAC7B,UAAU,EAAE;QACX,OAAO,EAAE,IAAI;QACb,aAAa,EAAE,KAAK;QACpB,iBAAiB,EAAE,GAAG;QACtB,eAAe,EAAE,CAAC;QAClB,oGAAoG;QAC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AAU,EAAE,IAAI;QAChB,WAAW,EAAE,KAAK;KAClB;IACD,kBAAkB,EAAE,MAAM;IAC1B,cAAc,EAAE,SAAS;IACzB,cAAc,EAAE,CAAC;IACjB,SAAS,EAAE,CAAC;IACZ,sBAAsB,EAAE,CAAC;IACzB,mBAAmB,EAAE,MAAM;IAC3B,oBAAoB,EAAE,YAAY;IAClC,sBAAsB,EAAE,IAAI;IAC5B,0BAA0B,EAAE,MAAM;IAClC,QAAQ,EAAE;QACT,IAAI,EAAE,IAAI;QACV,YAAY,EAAE,IAAI;KAClB;IACD,QAAQ,EAAE;QACT,eAAe,EAAE,IAAI;QACrB,OAAO,EAAE,WAAW;QACpB,KAAK,EAAE,IAAI;KACX;IACD,QAAQ,EAAE;QACT,mBAAmB,EAAE,IAAI;KACzB;IACD,QAAQ,EAAE;QACT,yBAAyB,EAAE,KAAK;KAChC;IACD,iBAAiB,EAAE,OAAO;IAC1B,YAAY,EAAE,WAAW;IACzB,KAAK,EAAE;QACN,qDAAqD;QACrD,WAAW,EAAE,EAAE,GAAG,MAAM;KACxB;CACQ,CAAC","sourcesContent":["import { DEFAULT_MAX_AGENT_RETRY_DELAY_MS } from \"@bastani/pi-ai/utils/retry\";\n\n/** Runtime defaults shared by settings accessors and the published JSON Schema. */\nexport const SETTINGS_DEFAULTS = {\n\tdecisionModel: \"\",\n\ttransport: \"auto\",\n\tsteeringMode: \"one-at-a-time\",\n\tfollowUpMode: \"one-at-a-time\",\n\tcompaction: {\n\t\tenabled: true,\n\t\treserveTokens: 16384,\n\t\tcompression_ratio: 0.5,\n\t\tpreserve_recent: 2,\n\t\t/** Wall-clock limit on automatic compaction's model planning, so it cannot block a turn (#4198). */\n\t\tplanningTimeoutMs: 300_000,\n\t\t/** Compact a frozen prefix in the background past the soft threshold; commit at a turn boundary (#4330). */\n\t\tbackground: true,\n\t\tbackgroundThresholdPercent: 75,\n\t\t/** Add lines from earlier history that match the current task to each compacted context (#4568). */\n\t\thistoryRecall: true,\n\t},\n\tbranchSummary: {\n\t\treserveTokens: 16384,\n\t\tskipPrompt: false,\n\t},\n\tsessionSummary: {\n\t\tenabled: true,\n\t},\n\tsnapshots: {\n\t\tenabled: true,\n\t\tincludeUntracked: true,\n\t\tmaxFileBytes: 5 * 1024 * 1024,\n\t\tmaxSnapshotBytes: 50 * 1024 * 1024,\n\t\tfullEvery: 10,\n\t\tautoCollect: true,\n\t\tcollectIntervalSeconds: 3600,\n\t\tgraceSeconds: 3600,\n\t},\n\tretry: {\n\t\tenabled: true,\n\t\tmaxRetries: 3,\n\t\tbaseDelayMs: 2000,\n\t\tmaxAgentDelayMs: DEFAULT_MAX_AGENT_RETRY_DELAY_MS,\n\t\tfallbackOnContentFilter: true,\n\t\tprovider: {\n\t\t\tmaxRetryDelayMs: 60000,\n\t\t},\n\t},\n\thideThinkingBlock: false,\n\tshowCacheMissNotices: false,\n\tworkflows: {\n\t\tautoAdvanceAfterSteer: true,\n\t},\n\tquietStartup: false,\n\tdefaultProjectTrust: \"ask\",\n\tsearch: {\n\t\tcontextBefore: 1,\n\t\tcontextAfter: 3,\n\t},\n\tcollapseChangelog: false,\n\tdebug: false,\n\tenableInstallTelemetry: true,\n\tenableSkillCommands: true,\n\therdr: {\n\t\tenabled: true,\n\t},\n\tterminal: {\n\t\tshowImages: true,\n\t\timageWidthCells: 60,\n\t\tclearOnShrink: false,\n\t\tshowTerminalProgress: false,\n\t},\n\timages: {\n\t\tautoResize: true,\n\t\tblockImages: false,\n\t},\n\tdoubleEscapeAction: \"tree\",\n\ttreeFilterMode: \"default\",\n\teditorPaddingX: 0,\n\toutputPad: 1,\n\tautocompleteMaxVisible: 5,\n\tfullscreenScrollbar: \"auto\",\n\tfullscreenExitOutput: \"transcript\",\n\tfullscreenCopyOnSelect: true,\n\tfullscreenWheelScrollLines: \"auto\",\n\tcodemode: {\n\t\tmode: \"on\",\n\t\tinlineBudget: 3000,\n\t},\n\tmarkdown: {\n\t\tcodeBlockIndent: \" \",\n\t\tmermaid: \"streaming\",\n\t\tlatex: true,\n\t},\n\twarnings: {\n\t\tanthropicExtraUsage: true,\n\t},\n\tintercom: {\n\t\tshowUnknownTargetWarnings: false,\n\t},\n\thttpIdleTimeoutMs: 600_000,\n\tcacheWarming: \"streaming\",\n\ttasks: {\n\t\t/** Same 15-minute default as workflow heartbeats. */\n\t\theartbeatMs: 15 * 60_000,\n\t},\n} as const;\n"]}
1
+ {"version":3,"file":"settings-defaults.js","sourceRoot":"","sources":["../../src/core/settings-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AAE9E,mFAAmF;AACnF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAChC,aAAa,EAAE,EAAE;IACjB,SAAS,EAAE,MAAM;IACjB,YAAY,EAAE,eAAe;IAC7B,YAAY,EAAE,eAAe;IAC7B,UAAU,EAAE;QACX,OAAO,EAAE,IAAI;QACb,aAAa,EAAE,KAAK;QACpB,iBAAiB,EAAE,GAAG;QACtB,eAAe,EAAE,CAAC;QAClB,oGAAoG;QACpG,iBAAiB,EAAE,OAAO;QAC1B,4GAA4G;QAC5G,UAAU,EAAE,IAAI;QAChB,0BAA0B,EAAE,EAAE;QAC9B,oGAAoG;QACpG,aAAa,EAAE,IAAI;KACnB;IACD,aAAa,EAAE;QACd,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,KAAK;KACjB;IACD,cAAc,EAAE;QACf,OAAO,EAAE,IAAI;KACb;IACD,SAAS,EAAE;QACV,OAAO,EAAE,IAAI;QACb,gBAAgB,EAAE,IAAI;QACtB,YAAY,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI;QAC7B,gBAAgB,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;QAClC,SAAS,EAAE,EAAE;QACb,WAAW,EAAE,IAAI;QACjB,sBAAsB,EAAE,IAAI;QAC5B,YAAY,EAAE,IAAI;KAClB;IACD,KAAK,EAAE;QACN,OAAO,EAAE,IAAI;QACb,UAAU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AC1B,YAAY,EAAE,MAAM;IACpB,KAAK,EAAE;QACN,qDAAqD;QACrD,WAAW,EAAE,EAAE,GAAG,MAAM;KACxB;CACQ,CAAC","sourcesContent":["import { DEFAULT_MAX_AGENT_RETRY_DELAY_MS } from \"@bastani/pi-ai/utils/retry\";\n\n/** Runtime defaults shared by settings accessors and the published JSON Schema. */\nexport const SETTINGS_DEFAULTS = {\n\tdecisionModel: \"\",\n\ttransport: \"auto\",\n\tsteeringMode: \"one-at-a-time\",\n\tfollowUpMode: \"one-at-a-time\",\n\tcompaction: {\n\t\tenabled: true,\n\t\treserveTokens: 16384,\n\t\tcompression_ratio: 0.5,\n\t\tpreserve_recent: 2,\n\t\t/** Wall-clock limit on automatic compaction's model planning, so it cannot block a turn (#4198). */\n\t\tplanningTimeoutMs: 300_000,\n\t\t/** Compact a frozen prefix in the background past the soft threshold; commit at a turn boundary (#4330). */\n\t\tbackground: true,\n\t\tbackgroundThresholdPercent: 75,\n\t\t/** Add lines from earlier history that match the current task to each compacted context (#4568). */\n\t\thistoryRecall: true,\n\t},\n\tbranchSummary: {\n\t\treserveTokens: 16384,\n\t\tskipPrompt: false,\n\t},\n\tsessionSummary: {\n\t\tenabled: true,\n\t},\n\tsnapshots: {\n\t\tenabled: true,\n\t\tincludeUntracked: true,\n\t\tmaxFileBytes: 5 * 1024 * 1024,\n\t\tmaxSnapshotBytes: 50 * 1024 * 1024,\n\t\tfullEvery: 10,\n\t\tautoCollect: true,\n\t\tcollectIntervalSeconds: 3600,\n\t\tgraceSeconds: 3600,\n\t},\n\tretry: {\n\t\tenabled: true,\n\t\tmaxRetries: 3,\n\t\tbaseDelayMs: 2000,\n\t\tmaxAgentDelayMs: DEFAULT_MAX_AGENT_RETRY_DELAY_MS,\n\t\tfallbackOnContentFilter: true,\n\t\tprovider: {\n\t\t\tmaxRetryDelayMs: 60000,\n\t\t},\n\t},\n\thideThinkingBlock: false,\n\tshowCacheMissNotices: false,\n\tworkflows: {\n\t\tautoAdvanceAfterSteer: true,\n\t},\n\tquietStartup: false,\n\tdefaultProjectTrust: \"ask\",\n\tsearch: {\n\t\tcontextBefore: 1,\n\t\tcontextAfter: 3,\n\t},\n\tcollapseChangelog: false,\n\tdebug: false,\n\tenableInstallTelemetry: true,\n\tenableSkillCommands: true,\n\therdr: {\n\t\tenabled: true,\n\t},\n\tterminal: {\n\t\tshowImages: true,\n\t\timageWidthCells: 60,\n\t\tclearOnShrink: false,\n\t\tshowTerminalProgress: false,\n\t},\n\timages: {\n\t\tautoResize: true,\n\t\tblockImages: false,\n\t},\n\tdoubleEscapeAction: \"tree\",\n\ttreeFilterMode: \"default\",\n\teditorPaddingX: 0,\n\toutputPad: 1,\n\tautocompleteMaxVisible: 5,\n\tfullscreenScrollbar: \"auto\",\n\tfullscreenExitOutput: \"transcript\",\n\tfullscreenCopyOnSelect: true,\n\tfullscreenWheelScrollLines: \"auto\",\n\tcodemode: {\n\t\tmode: \"on\",\n\t\tinlineBudget: 3000,\n\t},\n\tmarkdown: {\n\t\tcodeBlockIndent: \" \",\n\t\tmermaid: \"streaming\",\n\t\tlatex: true,\n\t},\n\twarnings: {\n\t\tanthropicExtraUsage: true,\n\t},\n\tintercom: {\n\t\tshowUnknownTargetWarnings: false,\n\t},\n\thttpIdleTimeoutMs: 600_000,\n\tcacheWarming: \"idle\",\n\ttasks: {\n\t\t/** Same 15-minute default as workflow heartbeats. */\n\t\theartbeatMs: 15 * 60_000,\n\t},\n} as const;\n"]}
@@ -95,8 +95,9 @@ interface SettingsManagerBasicAccessors {
95
95
  /** Merged `snapshots.*` settings; throws WorkspaceConfigError (source "settings") for an invalid value. */
96
96
  getWorktreeSnapshotSettings(): WorktreeSnapshotSettings;
97
97
  /**
98
- * `resume.setupCommand` from the global settings, trimmed; undefined when unset or blank. A project's own value is
99
- * ignored: it would run a repository-chosen command on a machine that never trusted the repository.
98
+ * Deprecated `resume.setupCommand` from the global settings, trimmed; undefined when unset or blank. It runs as one
99
+ * global maintenance step of the blueprint build. A project's own value is ignored: it would run a
100
+ * repository-chosen command on a machine that never trusted the repository.
100
101
  */
101
102
  getResumeSetupCommand(): string | undefined;
102
103
  getRetryEnabled(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"settings-manager-basic-accessors.d.ts","sourceRoot":"","sources":["../../src/core/settings-manager-basic-accessors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAuB,MAAM,gBAAgB,CAAC;AAWjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAGX,oBAAoB,EACpB,gBAAgB,EAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEjF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAE7E,KAAK,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC,CAAC;AAE9D,oFAAoF;AACpF,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IACvC,QAAQ,CAAC,eAAe,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;CACxE;AA6CD,UAAU,6BAA6B;IACtC,mBAAmB,IAAI,gBAAgB,CAAC;IACxC,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAClD,uBAAuB,IAAI,MAAM,GAAG,SAAS,CAAC;IAC9C,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/C,0FAA0F;IAC1F,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IAC/C;;;OAGG;IACH,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9C,m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IAC5C,eAAe,IAAI,OAAO,CAAC;IAC3B,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxC,gBAAgB,IAAI;QACnB,OAAO,EAAE,OAAO,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;QACxB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,uBAAuB,EAAE,OAAO,CAAC;KACjC,CAAC;IACF,YAAY,IAAI,MAAM,GAAG,SAAS,CAAC;IACnC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IAC9C,oBAAoB,IAAI,MAAM,CAAC;IAC/B,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,4BAA4B,IAAI,MAAM,GAAG,SAAS,CAAC;IACnD,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAAC;IAC1C,wBAAwB,IAAI;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;CACjG;AAED,OAAO,QAAQ,4BAA4B,CAAC;IAC3C,UAAU,eAAgB,SAAQ,6BAA6B;KAAG;CAClE"}
1
+ {"version":3,"file":"settings-manager-basic-accessors.d.ts","sourceRoot":"","sources":["../../src/core/settings-manager-basic-accessors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAuB,MAAM,gBAAgB,CAAC;AAWjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAGX,oBAAoB,EACpB,gBAAgB,EAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEjF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAE7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