@bastani/atomic 0.10.4-alpha.2 → 0.10.5-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (614) hide show
  1. package/CHANGELOG.md +238 -0
  2. package/dist/_shared/chunk-CDOYTDYM.js +4 -0
  3. package/dist/_shared/chunk-CDOYTDYM.js.map +1 -0
  4. package/dist/_shared/compile-cache-warmup-host-RU5L7I7A.js +1 -1
  5. package/dist/_shared/dist-KOELCESV.js +48 -3
  6. package/dist/_shared/fork-row-index-UAUAQRD5.js +47 -2
  7. package/dist/_shared/http-YFAPTIZD.js +16 -4
  8. package/dist/_shared/http-YFAPTIZD.js.map +1 -1
  9. package/dist/_shared/lib-4PES5P4V.js +59 -14
  10. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +1706 -258
  11. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js.map +1 -1
  12. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +317 -64
  13. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js.map +1 -1
  14. package/dist/_shared/{mode-shared-HP7GUA7J.js → mode-shared-2QJSCUM6.js} +432 -81
  15. package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -0
  16. package/dist/_shared/p0-cli-BB45ZQY6.js +3482 -0
  17. package/dist/_shared/p0-cli-BB45ZQY6.js.map +1 -0
  18. package/dist/_shared/p0-cli-GUFK7TPN.js +2 -2838
  19. package/dist/_shared/p0-cli-GUFK7TPN.js.map +1 -1
  20. package/dist/_shared/{p1a-prewarm-YK3KDTLN.js → p1a-prewarm-UQY3X2UK.js} +270 -73
  21. package/dist/_shared/p1a-prewarm-UQY3X2UK.js.map +1 -0
  22. package/dist/_shared/{p1b-elig-PXQA2FYP.js → p1b-elig-ENCUPKKJ.js} +190 -121
  23. package/dist/_shared/p1b-elig-ENCUPKKJ.js.map +1 -0
  24. package/dist/_shared/p2-common-YLSYXMDQ.js +1 -3
  25. package/dist/_shared/p2-common-YLSYXMDQ.js.map +1 -1
  26. package/dist/_shared/p2-shell-TJBYQMCJ.js +1 -1
  27. package/dist/_shared/p2-shell-main-B2WIALFD.js +500 -127
  28. package/dist/_shared/p2-shell-main-B2WIALFD.js.map +1 -1
  29. package/dist/_shared/runtime-O4KCSG4C.js +4 -4
  30. package/dist/_shared/sdk-WQIOHVKO.js +56 -11
  31. package/dist/_shared/session-data-AHTU7IS6.js +48 -3
  32. package/dist/_shared/session-manager-list-2BLEEZVG.js +2 -2
  33. package/dist/_shared/settings-startup-65YEWRV2.js.map +1 -1
  34. package/dist/_shared/sql-session-store-5FD3WBMZ.js +57 -12
  35. package/dist/_shared/{startup-0-0-X4NF3GKM.js → startup-0-0-TYUFUOJZ.js} +528 -321
  36. package/dist/_shared/startup-0-0-TYUFUOJZ.js.map +1 -0
  37. package/dist/_shared/{startup-0-1-7QTG6VJZ.js → startup-0-1-D4LGGINF.js} +284 -81
  38. package/dist/_shared/startup-0-1-D4LGGINF.js.map +1 -0
  39. package/dist/_shared/{startup-0-2-KFDYPDJK.js → startup-0-2-SZGQIWHI.js} +483 -154
  40. package/dist/_shared/startup-0-2-SZGQIWHI.js.map +1 -0
  41. package/dist/_shared/startup-0-3-T4DVFYWX.js +340 -110
  42. package/dist/_shared/startup-0-3-T4DVFYWX.js.map +1 -1
  43. package/dist/_shared/startup-0-4-HN5EB4K7.js +261 -59
  44. package/dist/_shared/startup-0-4-HN5EB4K7.js.map +1 -1
  45. package/dist/_shared/startup-0-5-OHJNE6JH.js +421 -148
  46. package/dist/_shared/startup-0-5-OHJNE6JH.js.map +1 -1
  47. package/dist/_shared/startup-10-0-TDQNBDDL.js +62 -11
  48. package/dist/_shared/startup-10-0-TDQNBDDL.js.map +1 -1
  49. package/dist/_shared/startup-12-0-55AAXBJZ.js +3 -3
  50. package/dist/_shared/startup-14-0-MLX36RBG.js +12 -11
  51. package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
  52. package/dist/_shared/startup-15-0-YUKGAC63.js +53 -158
  53. package/dist/_shared/startup-15-0-YUKGAC63.js.map +1 -1
  54. package/dist/_shared/startup-15-1-4S7FLMNG.js +231 -46
  55. package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
  56. package/dist/_shared/startup-8-0-34CBHPZH.js +115 -35
  57. package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
  58. package/dist/_shared/{startup-8-1-KQJBDKRU.js → startup-8-1-SJW2GMAM.js} +203 -62
  59. package/dist/_shared/startup-8-1-SJW2GMAM.js.map +1 -0
  60. package/dist/_shared/storage-command-7MGXLJGZ.js +55 -10
  61. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +47 -2
  62. package/dist/_shared/tree-outline-MUEPK5B7.js +48 -3
  63. package/dist/builtin/intercom/CHANGELOG.md +59 -0
  64. package/dist/builtin/intercom/README.md +0 -1
  65. package/dist/builtin/intercom/broker/broker-instance.ts +13 -57
  66. package/dist/builtin/intercom/broker/broker-process.ts +30 -10
  67. package/dist/builtin/intercom/broker/broker-routing.ts +12 -2
  68. package/dist/builtin/intercom/broker/broker.bundle.mjs +2557 -498
  69. package/dist/builtin/intercom/broker/broker.ts +164 -55
  70. package/dist/builtin/intercom/broker/client.ts +36 -16
  71. package/dist/builtin/intercom/broker/control.ts +83 -20
  72. package/dist/builtin/intercom/broker/durable-ended-queue.ts +65 -19
  73. package/dist/builtin/intercom/broker/host-command-environment.ts +7 -2
  74. package/dist/builtin/intercom/broker/multinode-router.ts +1675 -387
  75. package/dist/builtin/intercom/broker/multinode-state-store.ts +10 -0
  76. package/dist/builtin/intercom/broker/paths.ts +68 -6
  77. package/dist/builtin/intercom/broker/pending-send-registry.ts +5 -0
  78. package/dist/builtin/intercom/broker/registration-bounds.ts +38 -0
  79. package/dist/builtin/intercom/broker/retiring-broker-check.ts +178 -0
  80. package/dist/builtin/intercom/broker/return-paths.ts +268 -7
  81. package/dist/builtin/intercom/broker/send-handler.ts +253 -28
  82. package/dist/builtin/intercom/broker/send-order-gate.ts +410 -0
  83. package/dist/builtin/intercom/broker/spawn.ts +950 -202
  84. package/dist/builtin/intercom/broker/sql-lease-store.ts +37 -0
  85. package/dist/builtin/intercom/broker/sql-outbox-store.ts +7 -0
  86. package/dist/builtin/intercom/broker/windows-cwd.ts +546 -0
  87. package/dist/builtin/intercom/index.bundle.mjs +3506 -2328
  88. package/dist/builtin/intercom/package.json +1 -1
  89. package/dist/builtin/intercom/retry-policy.ts +4 -0
  90. package/dist/builtin/intercom/types.ts +2 -0
  91. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  92. package/dist/builtin/mcp/package.json +1 -1
  93. package/dist/builtin/subagents/CHANGELOG.md +46 -0
  94. package/dist/builtin/subagents/package.json +1 -1
  95. package/dist/builtin/subagents/src/extension/index.bundle.mjs +336 -86
  96. package/dist/builtin/web-access/CHANGELOG.md +12 -0
  97. package/dist/builtin/web-access/index.bundle.mjs +23 -38
  98. package/dist/builtin/web-access/package.json +1 -1
  99. package/dist/bun/cli.js +1 -1
  100. package/dist/bun/cli.js.map +1 -1
  101. package/dist/bun/internal-intercom-broker.js +119 -4
  102. package/dist/bun/internal-intercom-broker.js.map +1 -1
  103. package/dist/bun/register-theme-validator.js +6 -0
  104. package/dist/bun/register-theme-validator.js.map +1 -0
  105. package/dist/cli/args.js +2 -2
  106. package/dist/cli/auth-cli.code.js +1102 -0
  107. package/dist/cli/auth-cli.code.js.map +1 -0
  108. package/dist/cli/auth-cli.impl.js +36 -0
  109. package/dist/cli/auth-cli.impl.js.map +1 -0
  110. package/dist/cli/auth-cli.js +30 -1096
  111. package/dist/cli/auth-cli.js.map +1 -1
  112. package/dist/cli/blueprint-command.code.js +906 -0
  113. package/dist/cli/blueprint-command.code.js.map +1 -0
  114. package/dist/cli/blueprint-command.impl.js +36 -0
  115. package/dist/cli/blueprint-command.impl.js.map +1 -0
  116. package/dist/cli/blueprint-command.js +30 -900
  117. package/dist/cli/blueprint-command.js.map +1 -1
  118. package/dist/cli/intercom-command.code.js +153 -0
  119. package/dist/cli/intercom-command.code.js.map +1 -0
  120. package/dist/cli/intercom-command.impl.js +36 -0
  121. package/dist/cli/intercom-command.impl.js.map +1 -0
  122. package/dist/cli/intercom-command.js +33 -105
  123. package/dist/cli/intercom-command.js.map +1 -1
  124. package/dist/cli/list-models.code.js +60 -0
  125. package/dist/cli/list-models.code.js.map +1 -0
  126. package/dist/cli/list-models.impl.js +36 -0
  127. package/dist/cli/list-models.impl.js.map +1 -0
  128. package/dist/cli/list-models.js +33 -57
  129. package/dist/cli/list-models.js.map +1 -1
  130. package/dist/cli/session-picker.code.js +55 -0
  131. package/dist/cli/session-picker.code.js.map +1 -0
  132. package/dist/cli/session-picker.impl.js +36 -0
  133. package/dist/cli/session-picker.impl.js.map +1 -0
  134. package/dist/cli/session-picker.js +33 -52
  135. package/dist/cli/session-picker.js.map +1 -1
  136. package/dist/cli/startup-ui.code.js +5 -0
  137. package/dist/cli/startup-ui.code.js.map +1 -0
  138. package/dist/cli/startup-ui.impl.js +36 -0
  139. package/dist/cli/startup-ui.impl.js.map +1 -0
  140. package/dist/cli/startup-ui.js +35 -4
  141. package/dist/cli/storage-command.code.js +3 -0
  142. package/dist/cli/storage-command.code.js.map +1 -0
  143. package/dist/cli/storage-command.impl.js +36 -0
  144. package/dist/cli/storage-command.impl.js.map +1 -0
  145. package/dist/cli/storage-command.js +35 -2
  146. package/dist/cli/storage-search-session.code.js +189 -0
  147. package/dist/cli/storage-search-session.code.js.map +1 -0
  148. package/dist/cli/storage-search-session.impl.js +36 -0
  149. package/dist/cli/storage-search-session.impl.js.map +1 -0
  150. package/dist/cli/storage-search-session.js +33 -186
  151. package/dist/cli/storage-search-session.js.map +1 -1
  152. package/dist/cli/team-command.code.js +217 -0
  153. package/dist/cli/team-command.code.js.map +1 -0
  154. package/dist/cli/team-command.impl.js +36 -0
  155. package/dist/cli/team-command.impl.js.map +1 -0
  156. package/dist/cli/team-command.js +32 -213
  157. package/dist/cli/team-command.js.map +1 -1
  158. package/dist/cli.js +60 -11
  159. package/dist/cli.js.map +1 -1
  160. package/dist/config.js +1 -1
  161. package/dist/core/agent-session-methods.d.ts +4 -3
  162. package/dist/core/agent-session-methods.js.map +1 -1
  163. package/dist/core/agent-session-types.d.ts +5 -0
  164. package/dist/core/compaction/compaction.d.ts +6 -0
  165. package/dist/core/compaction/model-resolver.d.ts +1 -1
  166. package/dist/core/debug.code.js +3 -0
  167. package/dist/core/debug.code.js.map +1 -0
  168. package/dist/core/debug.impl.js +36 -0
  169. package/dist/core/debug.impl.js.map +1 -0
  170. package/dist/core/debug.js +35 -2
  171. package/dist/core/default-model-api-prewarm.d.ts +5 -0
  172. package/dist/core/export-html/card-projection.code.js +257 -0
  173. package/dist/core/export-html/card-projection.code.js.map +1 -0
  174. package/dist/core/export-html/card-projection.impl.js +36 -0
  175. package/dist/core/export-html/card-projection.impl.js.map +1 -0
  176. package/dist/core/export-html/card-projection.js +34 -255
  177. package/dist/core/export-html/card-projection.js.map +1 -1
  178. package/dist/core/export-html/index.code.js +655 -0
  179. package/dist/core/export-html/index.code.js.map +1 -0
  180. package/dist/core/export-html/index.impl.js +36 -0
  181. package/dist/core/export-html/index.impl.js.map +1 -0
  182. package/dist/core/export-html/index.js +30 -604
  183. package/dist/core/export-html/index.js.map +1 -1
  184. package/dist/core/export-html/json-spans.code.js +3 -0
  185. package/dist/core/export-html/json-spans.code.js.map +1 -0
  186. package/dist/core/export-html/json-spans.impl.js +36 -0
  187. package/dist/core/export-html/json-spans.impl.js.map +1 -0
  188. package/dist/core/export-html/json-spans.js +35 -2
  189. package/dist/core/export-html/oversized-render-inputs.code.js +125 -0
  190. package/dist/core/export-html/oversized-render-inputs.code.js.map +1 -0
  191. package/dist/core/export-html/oversized-render-inputs.impl.js +36 -0
  192. package/dist/core/export-html/oversized-render-inputs.impl.js.map +1 -0
  193. package/dist/core/export-html/oversized-render-inputs.js +31 -120
  194. package/dist/core/export-html/oversized-render-inputs.js.map +1 -1
  195. package/dist/core/export-html/tool-renderer.code.js +350 -0
  196. package/dist/core/export-html/tool-renderer.code.js.map +1 -0
  197. package/dist/core/export-html/tool-renderer.impl.js +36 -0
  198. package/dist/core/export-html/tool-renderer.impl.js.map +1 -0
  199. package/dist/core/export-html/tool-renderer.js +33 -347
  200. package/dist/core/export-html/tool-renderer.js.map +1 -1
  201. package/dist/core/extensions/jiti-loader.code.js +3 -0
  202. package/dist/core/extensions/jiti-loader.code.js.map +1 -0
  203. package/dist/core/extensions/jiti-loader.impl.js +36 -0
  204. package/dist/core/extensions/jiti-loader.impl.js.map +1 -0
  205. package/dist/core/extensions/jiti-loader.js +35 -2
  206. package/dist/core/extensions/jiti-static-loader.code.js +3 -0
  207. package/dist/core/extensions/jiti-static-loader.code.js.map +1 -0
  208. package/dist/core/extensions/jiti-static-loader.impl.js +36 -0
  209. package/dist/core/extensions/jiti-static-loader.impl.js.map +1 -0
  210. package/dist/core/extensions/jiti-static-loader.js +35 -2
  211. package/dist/core/extensions/loader-host-modules.code.js +3 -0
  212. package/dist/core/extensions/loader-host-modules.code.js.map +1 -0
  213. package/dist/core/extensions/loader-host-modules.impl.js +36 -0
  214. package/dist/core/extensions/loader-host-modules.impl.js.map +1 -0
  215. package/dist/core/extensions/loader-host-modules.js +35 -2
  216. package/dist/core/extensions/loader-virtual-modules.d.ts +1 -6
  217. package/dist/core/extensions/loader-virtual-modules.js +1 -1
  218. package/dist/core/extensions/runner-context.js +3 -3
  219. package/dist/core/extensions/session-events.d.ts +4 -0
  220. package/dist/core/extensions/session-events.js.map +1 -1
  221. package/dist/core/intercom-broker-control-host.code.js +5 -0
  222. package/dist/core/intercom-broker-control-host.code.js.map +1 -0
  223. package/dist/core/intercom-broker-control-host.impl.js +36 -0
  224. package/dist/core/intercom-broker-control-host.impl.js.map +1 -0
  225. package/dist/core/intercom-broker-control-host.js +35 -4
  226. package/dist/core/intercom-broker-control.code.js +63 -0
  227. package/dist/core/intercom-broker-control.code.js.map +1 -0
  228. package/dist/core/intercom-broker-control.d.ts +21 -0
  229. package/dist/core/intercom-broker-control.impl.js +36 -0
  230. package/dist/core/intercom-broker-control.impl.js.map +1 -0
  231. package/dist/core/intercom-broker-control.js +35 -17
  232. package/dist/core/intercom-broker-control.js.map +1 -1
  233. package/dist/core/package-manager-storage-adapters.code.js +3 -0
  234. package/dist/core/package-manager-storage-adapters.code.js.map +1 -0
  235. package/dist/core/package-manager-storage-adapters.impl.js +36 -0
  236. package/dist/core/package-manager-storage-adapters.impl.js.map +1 -0
  237. package/dist/core/package-manager-storage-adapters.js +35 -2
  238. package/dist/core/process-start-token.d.ts +8 -2
  239. package/dist/core/process-tree-containment.d.ts +27 -0
  240. package/dist/core/queued-message-delivery.d.ts +5 -2
  241. package/dist/core/resume/blueprint/process.d.ts +3 -1
  242. package/dist/core/sdk.code.js +9 -0
  243. package/dist/core/sdk.code.js.map +1 -0
  244. package/dist/core/sdk.impl.js +36 -0
  245. package/dist/core/sdk.impl.js.map +1 -0
  246. package/dist/core/sdk.js +35 -8
  247. package/dist/core/session-manager-core.d.ts +15 -5
  248. package/dist/core/session-manager-core.js +195 -38
  249. package/dist/core/session-manager-core.js.map +1 -1
  250. package/dist/core/session-manager-list.code.js +3 -0
  251. package/dist/core/session-manager-list.code.js.map +1 -0
  252. package/dist/core/session-manager-list.impl.js +36 -0
  253. package/dist/core/session-manager-list.impl.js.map +1 -0
  254. package/dist/core/session-manager-list.js +35 -2
  255. package/dist/core/session-manager-types.d.ts +20 -0
  256. package/dist/core/session-manager.code.js +8 -0
  257. package/dist/core/session-manager.code.js.map +1 -0
  258. package/dist/core/session-manager.d.ts +1 -1
  259. package/dist/core/session-manager.impl.js +36 -0
  260. package/dist/core/session-manager.impl.js.map +1 -0
  261. package/dist/core/session-manager.js +35 -7
  262. package/dist/core/session-storage.code.js +3 -0
  263. package/dist/core/session-storage.code.js.map +1 -0
  264. package/dist/core/session-storage.impl.js +36 -0
  265. package/dist/core/session-storage.impl.js.map +1 -0
  266. package/dist/core/session-storage.js +35 -2
  267. package/dist/core/storage/file-identity.d.ts +3 -0
  268. package/dist/core/storage/file-identity.js +296 -86
  269. package/dist/core/storage/file-identity.js.map +1 -1
  270. package/dist/core/storage/index.d.ts +1 -1
  271. package/dist/core/storage/index.js +52 -7
  272. package/dist/core/storage/index.js.map +1 -1
  273. package/dist/core/storage/node-sqlite-thread.js +47 -2
  274. package/dist/core/storage/node-sqlite.js +49 -4
  275. package/dist/core/storage/node-sqlite.js.map +1 -1
  276. package/dist/core/storage/offline-snapshot-file.code.js +37 -0
  277. package/dist/core/storage/offline-snapshot-file.code.js.map +1 -0
  278. package/dist/core/storage/offline-snapshot-file.impl.js +36 -0
  279. package/dist/core/storage/offline-snapshot-file.impl.js.map +1 -0
  280. package/dist/core/storage/offline-snapshot-file.js +33 -34
  281. package/dist/core/storage/offline-snapshot-file.js.map +1 -1
  282. package/dist/core/storage/provider.js +52 -7
  283. package/dist/core/storage/selection.js +49 -4
  284. package/dist/core/storage/session/branch-fork-source.code.js +146 -0
  285. package/dist/core/storage/session/branch-fork-source.code.js.map +1 -0
  286. package/dist/core/storage/session/branch-fork-source.impl.js +36 -0
  287. package/dist/core/storage/session/branch-fork-source.impl.js.map +1 -0
  288. package/dist/core/storage/session/branch-fork-source.js +32 -97
  289. package/dist/core/storage/session/branch-fork-source.js.map +1 -1
  290. package/dist/core/storage/session/card-view.code.js +60 -0
  291. package/dist/core/storage/session/card-view.code.js.map +1 -0
  292. package/dist/core/storage/session/card-view.impl.js +36 -0
  293. package/dist/core/storage/session/card-view.impl.js.map +1 -0
  294. package/dist/core/storage/session/card-view.js +34 -58
  295. package/dist/core/storage/session/card-view.js.map +1 -1
  296. package/dist/core/storage/session/child-reader.code.js +139 -0
  297. package/dist/core/storage/session/child-reader.code.js.map +1 -0
  298. package/dist/core/storage/session/child-reader.d.ts +1 -0
  299. package/dist/core/storage/session/child-reader.impl.js +36 -0
  300. package/dist/core/storage/session/child-reader.impl.js.map +1 -0
  301. package/dist/core/storage/session/child-reader.js +33 -91
  302. package/dist/core/storage/session/child-reader.js.map +1 -1
  303. package/dist/core/storage/session/chunked-resume-projection.code.js +3 -0
  304. package/dist/core/storage/session/chunked-resume-projection.code.js.map +1 -0
  305. package/dist/core/storage/session/chunked-resume-projection.impl.js +36 -0
  306. package/dist/core/storage/session/chunked-resume-projection.impl.js.map +1 -0
  307. package/dist/core/storage/session/chunked-resume-projection.js +35 -2
  308. package/dist/core/storage/session/expanded-child-details.code.js +684 -0
  309. package/dist/core/storage/session/expanded-child-details.code.js.map +1 -0
  310. package/dist/core/storage/session/expanded-child-details.impl.js +36 -0
  311. package/dist/core/storage/session/expanded-child-details.impl.js.map +1 -0
  312. package/dist/core/storage/session/expanded-child-details.js +31 -634
  313. package/dist/core/storage/session/expanded-child-details.js.map +1 -1
  314. package/dist/core/storage/session/fork-row-bytes.code.js +3 -0
  315. package/dist/core/storage/session/fork-row-bytes.code.js.map +1 -0
  316. package/dist/core/storage/session/fork-row-bytes.impl.js +36 -0
  317. package/dist/core/storage/session/fork-row-bytes.impl.js.map +1 -0
  318. package/dist/core/storage/session/fork-row-bytes.js +35 -2
  319. package/dist/core/storage/session/fork-row-index.code.js +3 -0
  320. package/dist/core/storage/session/fork-row-index.code.js.map +1 -0
  321. package/dist/core/storage/session/fork-row-index.impl.js +36 -0
  322. package/dist/core/storage/session/fork-row-index.impl.js.map +1 -0
  323. package/dist/core/storage/session/fork-row-index.js +35 -2
  324. package/dist/core/storage/session/fork-staging.code.js +580 -0
  325. package/dist/core/storage/session/fork-staging.code.js.map +1 -0
  326. package/dist/core/storage/session/fork-staging.impl.js +36 -0
  327. package/dist/core/storage/session/fork-staging.impl.js.map +1 -0
  328. package/dist/core/storage/session/fork-staging.js +30 -574
  329. package/dist/core/storage/session/fork-staging.js.map +1 -1
  330. package/dist/core/storage/session/fork-window.code.js +522 -0
  331. package/dist/core/storage/session/fork-window.code.js.map +1 -0
  332. package/dist/core/storage/session/fork-window.impl.js +36 -0
  333. package/dist/core/storage/session/fork-window.impl.js.map +1 -0
  334. package/dist/core/storage/session/fork-window.js +30 -471
  335. package/dist/core/storage/session/fork-window.js.map +1 -1
  336. package/dist/core/storage/session/history-pages.code.js +3 -0
  337. package/dist/core/storage/session/history-pages.code.js.map +1 -0
  338. package/dist/core/storage/session/history-pages.impl.js +36 -0
  339. package/dist/core/storage/session/history-pages.impl.js.map +1 -0
  340. package/dist/core/storage/session/history-pages.js +35 -2
  341. package/dist/core/storage/session/jsonl-entry-projection.code.js +3 -0
  342. package/dist/core/storage/session/jsonl-entry-projection.code.js.map +1 -0
  343. package/dist/core/storage/session/jsonl-entry-projection.impl.js +36 -0
  344. package/dist/core/storage/session/jsonl-entry-projection.impl.js.map +1 -0
  345. package/dist/core/storage/session/jsonl-entry-projection.js +35 -2
  346. package/dist/core/storage/session/jsonl-session-store.code.js +3 -0
  347. package/dist/core/storage/session/jsonl-session-store.code.js.map +1 -0
  348. package/dist/core/storage/session/jsonl-session-store.impl.js +36 -0
  349. package/dist/core/storage/session/jsonl-session-store.impl.js.map +1 -0
  350. package/dist/core/storage/session/jsonl-session-store.js +35 -2
  351. package/dist/core/storage/session/memory-session-store.code.js +3 -0
  352. package/dist/core/storage/session/memory-session-store.code.js.map +1 -0
  353. package/dist/core/storage/session/memory-session-store.impl.js +36 -0
  354. package/dist/core/storage/session/memory-session-store.impl.js.map +1 -0
  355. package/dist/core/storage/session/memory-session-store.js +35 -2
  356. package/dist/core/storage/session/pinned-branch-resume.code.js +117 -0
  357. package/dist/core/storage/session/pinned-branch-resume.code.js.map +1 -0
  358. package/dist/core/storage/session/pinned-branch-resume.impl.js +36 -0
  359. package/dist/core/storage/session/pinned-branch-resume.impl.js.map +1 -0
  360. package/dist/core/storage/session/pinned-branch-resume.js +33 -69
  361. package/dist/core/storage/session/pinned-branch-resume.js.map +1 -1
  362. package/dist/core/storage/session/released-history-files.code.js +465 -0
  363. package/dist/core/storage/session/released-history-files.code.js.map +1 -0
  364. package/dist/core/storage/session/released-history-files.impl.js +36 -0
  365. package/dist/core/storage/session/released-history-files.impl.js.map +1 -0
  366. package/dist/core/storage/session/released-history-files.js +32 -461
  367. package/dist/core/storage/session/released-history-files.js.map +1 -1
  368. package/dist/core/storage/session/resident-fork-rows.code.js +57 -0
  369. package/dist/core/storage/session/resident-fork-rows.code.js.map +1 -0
  370. package/dist/core/storage/session/resident-fork-rows.impl.js +36 -0
  371. package/dist/core/storage/session/resident-fork-rows.impl.js.map +1 -0
  372. package/dist/core/storage/session/resident-fork-rows.js +32 -53
  373. package/dist/core/storage/session/resident-fork-rows.js.map +1 -1
  374. package/dist/core/storage/session/session-resume.code.js +3 -0
  375. package/dist/core/storage/session/session-resume.code.js.map +1 -0
  376. package/dist/core/storage/session/session-resume.impl.js +36 -0
  377. package/dist/core/storage/session/session-resume.impl.js.map +1 -0
  378. package/dist/core/storage/session/session-resume.js +35 -2
  379. package/dist/core/storage/session/snapshot-cut.code.js +3 -0
  380. package/dist/core/storage/session/snapshot-cut.code.js.map +1 -0
  381. package/dist/core/storage/session/snapshot-cut.impl.js +36 -0
  382. package/dist/core/storage/session/snapshot-cut.impl.js.map +1 -0
  383. package/dist/core/storage/session/snapshot-cut.js +35 -2
  384. package/dist/core/storage/session/snapshot-history.code.js +107 -0
  385. package/dist/core/storage/session/snapshot-history.code.js.map +1 -0
  386. package/dist/core/storage/session/snapshot-history.impl.js +36 -0
  387. package/dist/core/storage/session/snapshot-history.impl.js.map +1 -0
  388. package/dist/core/storage/session/snapshot-history.js +34 -60
  389. package/dist/core/storage/session/snapshot-history.js.map +1 -1
  390. package/dist/core/storage/session/sql-session-store.code.js +3 -0
  391. package/dist/core/storage/session/sql-session-store.code.js.map +1 -0
  392. package/dist/core/storage/session/sql-session-store.impl.js +36 -0
  393. package/dist/core/storage/session/sql-session-store.impl.js.map +1 -0
  394. package/dist/core/storage/session/sql-session-store.js +35 -2
  395. package/dist/core/storage/session/tree-outline.code.js +3 -0
  396. package/dist/core/storage/session/tree-outline.code.js.map +1 -0
  397. package/dist/core/storage/session/tree-outline.impl.js +36 -0
  398. package/dist/core/storage/session/tree-outline.impl.js.map +1 -0
  399. package/dist/core/storage/session/tree-outline.js +35 -2
  400. package/dist/core/storage/session/tree-presentation.code.js +342 -0
  401. package/dist/core/storage/session/tree-presentation.code.js.map +1 -0
  402. package/dist/core/storage/session/tree-presentation.impl.js +36 -0
  403. package/dist/core/storage/session/tree-presentation.impl.js.map +1 -0
  404. package/dist/core/storage/session/tree-presentation.js +31 -337
  405. package/dist/core/storage/session/tree-presentation.js.map +1 -1
  406. package/dist/core/storage/session/types.d.ts +26 -0
  407. package/dist/core/storage/storage-status.code.js +3 -0
  408. package/dist/core/storage/storage-status.code.js.map +1 -0
  409. package/dist/core/storage/storage-status.impl.js +36 -0
  410. package/dist/core/storage/storage-status.impl.js.map +1 -0
  411. package/dist/core/storage/storage-status.js +35 -2
  412. package/dist/core/storage/team.code.js +3 -0
  413. package/dist/core/storage/team.code.js.map +1 -0
  414. package/dist/core/storage/team.impl.js +36 -0
  415. package/dist/core/storage/team.impl.js.map +1 -0
  416. package/dist/core/storage/team.js +35 -2
  417. package/dist/core/structured-output/index.code.js +3 -0
  418. package/dist/core/structured-output/index.code.js.map +1 -0
  419. package/dist/core/structured-output/index.impl.js +36 -0
  420. package/dist/core/structured-output/index.impl.js.map +1 -0
  421. package/dist/core/structured-output/index.js +35 -2
  422. package/dist/core/tasks/command-output.d.ts +4 -1
  423. package/dist/core/tasks/supervisor.d.ts +2 -0
  424. package/dist/core/tasks/task-completion-entry.code.js +254 -0
  425. package/dist/core/tasks/task-completion-entry.code.js.map +1 -0
  426. package/dist/core/tasks/task-completion-entry.impl.js +36 -0
  427. package/dist/core/tasks/task-completion-entry.impl.js.map +1 -0
  428. package/dist/core/tasks/task-completion-entry.js +33 -251
  429. package/dist/core/tasks/task-completion-entry.js.map +1 -1
  430. package/dist/core/tasks/task-file-history.code.js +424 -0
  431. package/dist/core/tasks/task-file-history.code.js.map +1 -0
  432. package/dist/core/tasks/task-file-history.impl.js +36 -0
  433. package/dist/core/tasks/task-file-history.impl.js.map +1 -0
  434. package/dist/core/tasks/task-file-history.js +32 -375
  435. package/dist/core/tasks/task-file-history.js.map +1 -1
  436. package/dist/core/tasks/task-reference-archive.code.js +514 -0
  437. package/dist/core/tasks/task-reference-archive.code.js.map +1 -0
  438. package/dist/core/tasks/task-reference-archive.js +34 -467
  439. package/dist/core/tasks/task-reference-archive.js.map +1 -1
  440. package/dist/core/tasks/task-reference-identity.code.js +164 -0
  441. package/dist/core/tasks/task-reference-identity.code.js.map +1 -0
  442. package/dist/core/tasks/task-reference-identity.js +32 -160
  443. package/dist/core/tasks/task-reference-identity.js.map +1 -1
  444. package/dist/core/tasks/task-reference-stream.code.js +3 -0
  445. package/dist/core/tasks/task-reference-stream.code.js.map +1 -0
  446. package/dist/core/tasks/task-reference-stream.impl.js +36 -0
  447. package/dist/core/tasks/task-reference-stream.impl.js.map +1 -0
  448. package/dist/core/tasks/task-reference-stream.js +35 -2
  449. package/dist/core/tasks/task-unsaved-answer.code.js +3 -0
  450. package/dist/core/tasks/task-unsaved-answer.code.js.map +1 -0
  451. package/dist/core/tasks/task-unsaved-answer.impl.js +36 -0
  452. package/dist/core/tasks/task-unsaved-answer.impl.js.map +1 -0
  453. package/dist/core/tasks/task-unsaved-answer.js +35 -2
  454. package/dist/core/tasks/task-view-source.code.js +3 -0
  455. package/dist/core/tasks/task-view-source.code.js.map +1 -0
  456. package/dist/core/tasks/task-view-source.d.ts +9 -0
  457. package/dist/core/tasks/task-view-source.impl.js +36 -0
  458. package/dist/core/tasks/task-view-source.impl.js.map +1 -0
  459. package/dist/core/tasks/task-view-source.js +35 -2
  460. package/dist/core/tools/read-url.code.js +1530 -0
  461. package/dist/core/tools/read-url.code.js.map +1 -0
  462. package/dist/core/tools/read-url.impl.js +36 -0
  463. package/dist/core/tools/read-url.impl.js.map +1 -0
  464. package/dist/core/tools/read-url.js +30 -1524
  465. package/dist/core/tools/read-url.js.map +1 -1
  466. package/dist/core/worktree-snapshot/blob-store.js +50 -5
  467. package/dist/core/worktree-snapshot/errors.code.js +6 -0
  468. package/dist/core/worktree-snapshot/errors.code.js.map +1 -0
  469. package/dist/core/worktree-snapshot/errors.impl.js +36 -0
  470. package/dist/core/worktree-snapshot/errors.impl.js.map +1 -0
  471. package/dist/core/worktree-snapshot/errors.js +35 -5
  472. package/dist/core/worktree-snapshot/session-index-reset.code.js +136 -0
  473. package/dist/core/worktree-snapshot/session-index-reset.code.js.map +1 -0
  474. package/dist/core/worktree-snapshot/session-index-reset.impl.js +36 -0
  475. package/dist/core/worktree-snapshot/session-index-reset.impl.js.map +1 -0
  476. package/dist/core/worktree-snapshot/session-index-reset.js +34 -134
  477. package/dist/core/worktree-snapshot/session-index-reset.js.map +1 -1
  478. package/dist/extensions/codemode/execute.code.js +618 -0
  479. package/dist/extensions/codemode/execute.code.js.map +1 -0
  480. package/dist/extensions/codemode/execute.impl.js +36 -0
  481. package/dist/extensions/codemode/execute.impl.js.map +1 -0
  482. package/dist/extensions/codemode/execute.js +30 -612
  483. package/dist/extensions/codemode/execute.js.map +1 -1
  484. package/dist/extensions/codemode/renderer.code.js +110 -0
  485. package/dist/extensions/codemode/renderer.code.js.map +1 -0
  486. package/dist/extensions/codemode/renderer.impl.js +36 -0
  487. package/dist/extensions/codemode/renderer.impl.js.map +1 -0
  488. package/dist/extensions/codemode/renderer.js +33 -107
  489. package/dist/extensions/codemode/renderer.js.map +1 -1
  490. package/dist/extensions/mcp/cli.code.js +565 -0
  491. package/dist/extensions/mcp/cli.code.js.map +1 -0
  492. package/dist/extensions/mcp/cli.impl.js +36 -0
  493. package/dist/extensions/mcp/cli.impl.js.map +1 -0
  494. package/dist/extensions/mcp/cli.js +32 -561
  495. package/dist/extensions/mcp/cli.js.map +1 -1
  496. package/dist/extensions/mcp/cli.lazy.code.js +52 -0
  497. package/dist/extensions/mcp/cli.lazy.code.js.map +1 -0
  498. package/dist/extensions/mcp/cli.lazy.impl.js +36 -0
  499. package/dist/extensions/mcp/cli.lazy.impl.js.map +1 -0
  500. package/dist/extensions/mcp/cli.lazy.js +36 -7
  501. package/dist/extensions/mcp/cli.lazy.js.map +1 -1
  502. package/dist/extensions/mcp/client/transports/stdio.d.ts +2 -0
  503. package/dist/extensions/mcp/runtime.code.js +5 -0
  504. package/dist/extensions/mcp/runtime.code.js.map +1 -0
  505. package/dist/extensions/mcp/runtime.impl.js +36 -0
  506. package/dist/extensions/mcp/runtime.impl.js.map +1 -0
  507. package/dist/extensions/mcp/runtime.js +35 -4
  508. package/dist/index.d.ts +1 -1
  509. package/dist/index.js +8 -8
  510. package/dist/main-first-time-setup.code.js +12 -0
  511. package/dist/main-first-time-setup.code.js.map +1 -0
  512. package/dist/main-first-time-setup.impl.js +36 -0
  513. package/dist/main-first-time-setup.impl.js.map +1 -0
  514. package/dist/main-first-time-setup.js +35 -11
  515. package/dist/main-first-time-setup.js.map +1 -1
  516. package/dist/main.d.ts +1 -1
  517. package/dist/main.js +2 -2
  518. package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts +6 -1
  519. package/dist/modes/interactive/agent-view/contracts.d.ts +4 -0
  520. package/dist/modes/interactive/chat-reader-records.d.ts +1 -1
  521. package/dist/modes/interactive/components/stored-tree-view.code.js +338 -0
  522. package/dist/modes/interactive/components/stored-tree-view.code.js.map +1 -0
  523. package/dist/modes/interactive/components/stored-tree-view.impl.js +36 -0
  524. package/dist/modes/interactive/components/stored-tree-view.impl.js.map +1 -0
  525. package/dist/modes/interactive/components/stored-tree-view.js +33 -290
  526. package/dist/modes/interactive/components/stored-tree-view.js.map +1 -1
  527. package/dist/modes/interactive/components/task-selection-state.d.ts +8 -3
  528. package/dist/modes/interactive/components/task-transcript-page.d.ts +1 -0
  529. package/dist/modes/interactive/components/user-message-selector-archive.code.js +191 -0
  530. package/dist/modes/interactive/components/user-message-selector-archive.code.js.map +1 -0
  531. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +36 -0
  532. package/dist/modes/interactive/components/user-message-selector-archive.impl.js.map +1 -0
  533. package/dist/modes/interactive/components/user-message-selector-archive.js +34 -189
  534. package/dist/modes/interactive/components/user-message-selector-archive.js.map +1 -1
  535. package/dist/modes/interactive/interactive-mode-base.d.ts +6 -0
  536. package/dist/modes/interactive/interactive-mode-deps.js +4 -0
  537. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -0
  538. package/dist/modes/interactive/interactive-mode.js +1 -1
  539. package/dist/modes/interactive/interactive-queueing.d.ts +4 -0
  540. package/dist/modes/interactive/interactive-render-chat.d.ts +22 -0
  541. package/dist/modes/interactive/interactive-startup.d.ts +2 -0
  542. package/dist/modes/interactive/program-status-reporter.d.ts +2 -1
  543. package/dist/modes/interactive/startup-shell-eligibility.js +1 -1
  544. package/dist/modes/interactive/steering-queue-controller.d.ts +4 -0
  545. package/dist/modes/interactive/theme/theme-schema-factory.d.ts +26 -0
  546. package/dist/modes/interactive/theme/theme-schema.d.ts +4 -5
  547. package/dist/modes/interactive-engine/engine-prewarm.d.ts +30 -5
  548. package/dist/modes/interactive-engine/engine-prewarm.js +1 -1
  549. package/dist/modes/interactive-engine/isolated-runtime.d.ts +7 -0
  550. package/dist/modes/interactive-engine/protocol.d.ts +32 -1
  551. package/dist/modes/rpc/agent-view-rpc-types.d.ts +12 -1
  552. package/dist/modes/rpc/agent-view-rpc-types.js.map +1 -1
  553. package/dist/modes/rpc/rpc-client-api.d.ts +3 -1
  554. package/dist/modes/rpc/rpc-types.d.ts +12 -0
  555. package/dist/package-manager-cli.code.js +1140 -0
  556. package/dist/package-manager-cli.code.js.map +1 -0
  557. package/dist/package-manager-cli.impl.js +36 -0
  558. package/dist/package-manager-cli.impl.js.map +1 -0
  559. package/dist/package-manager-cli.js +36 -1067
  560. package/dist/package-manager-cli.js.map +1 -1
  561. package/dist/rpc-entry.js +2 -2
  562. package/dist/startup-files.json +1 -1
  563. package/dist/startup-stages/10.js +1 -1
  564. package/dist/startup-stages/11.js +1 -1
  565. package/dist/startup-stages/12.js +1 -1
  566. package/dist/startup-stages/13.js +1 -0
  567. package/dist/startup-stages/2.js +1 -7
  568. package/dist/startup-stages/3.js +6 -2
  569. package/dist/startup-stages/4.js +2 -1
  570. package/dist/startup-stages/5.js +1 -7
  571. package/dist/startup-stages/6.js +7 -10
  572. package/dist/startup-stages/7.js +10 -3
  573. package/dist/startup-stages/8.js +3 -6
  574. package/dist/startup-stages/9.js +6 -1
  575. package/dist/startup-stages/stages.json +1 -1
  576. package/dist/utils/canonical-path.js +2 -0
  577. package/dist/utils/canonical-path.js.map +1 -1
  578. package/dist/utils/child-process.d.ts +41 -1
  579. package/dist/utils/compile-cache-warmup-host.js +63 -18
  580. package/dist/utils/compile-cache-warmup-host.js.map +1 -1
  581. package/dist/utils/credential-redaction.d.ts +50 -1
  582. package/dist/utils/interactive-engine-bootstrap.d.ts +2 -0
  583. package/dist/utils/interactive-engine-env.d.ts +2 -0
  584. package/dist/utils/memoize-async.d.ts +32 -0
  585. package/dist/utils/memoize-async.js +91 -0
  586. package/dist/utils/memoize-async.js.map +1 -0
  587. package/dist/utils/photon.js +19 -29
  588. package/dist/utils/photon.js.map +1 -1
  589. package/dist/utils/shell.d.ts +7 -4
  590. package/dist/utils/startup-database-spare.code.js +108 -0
  591. package/dist/utils/startup-database-spare.code.js.map +1 -0
  592. package/dist/utils/startup-database-spare.impl.js +36 -0
  593. package/dist/utils/startup-database-spare.impl.js.map +1 -0
  594. package/dist/utils/startup-database-spare.js +33 -105
  595. package/dist/utils/startup-database-spare.js.map +1 -1
  596. package/dist/utils/tools-manager.code.js +3 -0
  597. package/dist/utils/tools-manager.code.js.map +1 -0
  598. package/dist/utils/tools-manager.impl.js +36 -0
  599. package/dist/utils/tools-manager.impl.js.map +1 -0
  600. package/dist/utils/tools-manager.js +35 -2
  601. package/dist/utils/windows-cwd.js +585 -0
  602. package/dist/utils/windows-cwd.js.map +1 -0
  603. package/docs/extensions.md +1 -1
  604. package/docs/getting-started/installation.md +2 -0
  605. package/docs/intercom/operations.md +1 -0
  606. package/docs/reference/cli.md +2 -2
  607. package/package.json +24 -24
  608. package/dist/_shared/mode-shared-HP7GUA7J.js.map +0 -1
  609. package/dist/_shared/p1a-prewarm-YK3KDTLN.js.map +0 -1
  610. package/dist/_shared/p1b-elig-PXQA2FYP.js.map +0 -1
  611. package/dist/_shared/startup-0-0-X4NF3GKM.js.map +0 -1
  612. package/dist/_shared/startup-0-1-7QTG6VJZ.js.map +0 -1
  613. package/dist/_shared/startup-0-2-KFDYPDJK.js.map +0 -1
  614. package/dist/_shared/startup-8-1-KQJBDKRU.js.map +0 -1
@@ -111,7 +111,15 @@ function withNativeErrorCode(error) {
111
111
  return mapped === undefined ? error : Object.assign(error, { code: mapped, errno: number });
112
112
  }
113
113
  function fileStat(stats) {
114
- return { dev: stats.dev, ino: stats.ino, birthtimeNs: stats.birthtimeNs, symbolicLink: stats.isSymbolicLink() };
114
+ return {
115
+ dev: stats.dev,
116
+ ino: stats.ino,
117
+ size: stats.size,
118
+ mtimeNs: stats.mtimeNs,
119
+ ctimeNs: stats.ctimeNs,
120
+ birthtimeNs: stats.birthtimeNs,
121
+ symbolicLink: stats.isSymbolicLink(),
122
+ };
115
123
  }
116
124
  function isMissingEntry(error) {
117
125
  return error.code === "ENOENT";
@@ -298,17 +306,32 @@ export async function fileIdentityAsync(path) {
298
306
  return undefined;
299
307
  }
300
308
  }
301
- function* fileIdentitySteps(path) {
309
+ function decisionStampOf(stat) {
310
+ if (stat === undefined || stat.ino === 0n || (stat.mtimeNs === 0n && stat.ctimeNs === 0n))
311
+ return undefined;
312
+ return { dev: stat.dev, ino: stat.ino, size: stat.size, mtimeNs: stat.mtimeNs, ctimeNs: stat.ctimeNs };
313
+ }
314
+ function sameDecisionStamp(left, right) {
315
+ return (left.dev === right.dev &&
316
+ left.ino === right.ino &&
317
+ left.size === right.size &&
318
+ left.mtimeNs === right.mtimeNs &&
319
+ left.ctimeNs === right.ctimeNs);
320
+ }
321
+ function* fileIdentityWithStatSteps(path) {
302
322
  try {
303
- const { dev, ino } = yield* io("stat", path);
304
- if (ino !== 0n)
305
- return `${dev}:${ino}`;
306
- return realPathIdentity(yield* io("realpath", path));
323
+ const stat = yield* io("stat", path);
324
+ if (stat.ino !== 0n)
325
+ return { identity: `${stat.dev}:${stat.ino}`, stat };
326
+ return { identity: realPathIdentity(yield* io("realpath", path)) };
307
327
  }
308
328
  catch {
309
329
  return undefined;
310
330
  }
311
331
  }
332
+ function* fileIdentitySteps(path) {
333
+ return (yield* fileIdentityWithStatSteps(path))?.identity;
334
+ }
312
335
  function realPathIdentity(real) {
313
336
  return `path:${process.platform === "win32" || process.platform === "darwin" ? real.toLowerCase() : real}`;
314
337
  }
@@ -378,7 +401,7 @@ function getPathComparisonKey(path) {
378
401
  function pathsEqual(left, right) {
379
402
  return getPathComparisonKey(left) === getPathComparisonKey(right);
380
403
  }
381
- function createStorageHomeEntry(home, adoptedClaim, provisionalWithoutSettings) {
404
+ function createStorageHomeEntry(home, adoptedClaim, provisionalWithoutSettings, decisionId, canonicalAgentPath) {
382
405
  const workflowsDir = join(home, "workflows");
383
406
  return {
384
407
  home,
@@ -386,11 +409,16 @@ function createStorageHomeEntry(home, adoptedClaim, provisionalWithoutSettings)
386
409
  sessionDatabasePath: join(workflowsDir, "journal.sqlite"),
387
410
  sharedStoragePath: join(home, "storage.sqlite"),
388
411
  ...(adoptedClaim === undefined ? {} : { adoptedClaim }),
412
+ ...(decisionId === undefined ? {} : { decisionId }),
413
+ ...(canonicalAgentPath === undefined ? {} : { canonicalAgentPath }),
389
414
  ...(provisionalWithoutSettings ? { provisionalWithoutSettings: true } : {}),
390
415
  };
391
416
  }
392
- function createDefaultStorageHomeEntry(home, provisionalWithoutSettings) {
393
- return { ...createStorageHomeEntry(home, undefined, provisionalWithoutSettings), defaultHome: true };
417
+ function createDefaultStorageHomeEntry(home, provisionalWithoutSettings, decisionId, canonicalAgentPath) {
418
+ return {
419
+ ...createStorageHomeEntry(home, undefined, provisionalWithoutSettings, decisionId, canonicalAgentPath),
420
+ defaultHome: true,
421
+ };
394
422
  }
395
423
  export function readClaimFile(file) {
396
424
  return runStorageStepsSync(readClaimFileSteps(file));
@@ -823,6 +851,7 @@ function recordSettledStorageHome(fastKey, cacheKey, settled) {
823
851
  fastStorageHomes.set(fastKey.rawAgentDir, { ...fastKey, entry: settled });
824
852
  return settled;
825
853
  }
854
+ const decisionCanonicalPaths = new WeakMap();
826
855
  let storageTargetDecisions = new WeakMap();
827
856
  let defaultTargetClaims = new WeakMap();
828
857
  function* canonicalPathSteps(path) {
@@ -905,17 +934,30 @@ function* readStorageHomeDecisionSteps(file) {
905
934
  ...(decision.parentOwner === undefined ? {} : { parentOwner: resolve(agentPath, decision.parentOwner) }),
906
935
  };
907
936
  }
908
- if (decision.parentOwner === undefined)
937
+ const isHomeDecision = basename(file) === HOME_DECISION_FILE;
938
+ if (decision.parentOwner === undefined) {
939
+ if (isHomeDecision)
940
+ decisionCanonicalPaths.set(decision, agentPath);
909
941
  return decision;
910
- if (basename(file) === HOME_DECISION_FILE) {
942
+ }
943
+ if (isHomeDecision) {
911
944
  const owner = yield* readStorageOwnerSteps(join(parent, PARENT_CLAIM_FILE));
912
945
  if (owner !== undefined) {
913
- const currentOwner = yield* currentStorageOwnerPathSteps(owner, parent);
946
+ const context = {
947
+ path: dirname(file),
948
+ canonicalPath: agentPath,
949
+ decisionId: decision.id,
950
+ fresh: true,
951
+ };
952
+ const currentOwner = yield* currentStorageOwnerPathSteps(owner, parent, undefined, context);
914
953
  if (pathsEqual(decision.parentOwner, owner.path) ||
915
954
  (currentOwner !== undefined && (yield* sameDirectorySteps(decision.parentOwner, currentOwner)))) {
916
- return { ...decision, home: parent, parentOwner: currentOwner ?? owner.path };
955
+ const resolvedDecision = { ...decision, home: parent, parentOwner: currentOwner ?? owner.path };
956
+ decisionCanonicalPaths.set(resolvedDecision, agentPath);
957
+ return resolvedDecision;
917
958
  }
918
959
  }
960
+ decisionCanonicalPaths.set(decision, agentPath);
919
961
  }
920
962
  else {
921
963
  const homeFile = storageHomeDecisionFile(dirname(file));
@@ -994,6 +1036,7 @@ function* storageDecisionMetadataSteps(path) {
994
1036
  if (decision === null ||
995
1037
  typeof decision !== "object" ||
996
1038
  (decision.id !== undefined && typeof decision.id !== "string") ||
1039
+ (decision.parentOwner !== undefined && typeof decision.parentOwner !== "string") ||
997
1040
  (decision.targets !== undefined &&
998
1041
  (!Array.isArray(decision.targets) || decision.targets.some((target) => typeof target !== "string"))))
999
1042
  return undefined;
@@ -1048,66 +1091,65 @@ function* readStorageOwnerSteps(file) {
1048
1091
  }
1049
1092
  return owner;
1050
1093
  }
1051
- function* currentStorageOwnerPathSteps(owner, claimDirectory = dirname(owner.path), claimedTarget) {
1052
- const path = owner.relativePath === undefined ? owner.path : resolve(claimDirectory, owner.relativePath);
1053
- if (owner.identity === undefined ||
1054
- (yield* fileIdentitySteps(owner.homeIdentity ? storageHomeDecisionFile(path) : path)) === owner.identity)
1055
- return path;
1094
+ function* scanStorageOwnerCandidatesSteps(owner, claimDirectory, claimedTarget, recordedPath, excludedExactCandidate) {
1056
1095
  const exact = [];
1057
1096
  const recorded = [];
1058
1097
  const fallback = [];
1059
1098
  function* consider(candidate) {
1060
1099
  if (!(yield* io("isDirectory", candidate)))
1061
1100
  return;
1062
- const identity = yield* fileIdentitySteps(owner.homeIdentity ? storageHomeDecisionFile(candidate) : candidate);
1063
- let matches;
1064
- if (identity === owner.identity) {
1065
- matches = exact;
1066
- }
1067
- else {
1068
- const metadata = yield* storageDecisionMetadataSteps(candidate);
1069
- if ((owner.decisionId === undefined || metadata?.id !== owner.decisionId) &&
1070
- (owner.directoryIdentity === undefined || (yield* fileIdentitySteps(candidate)) !== owner.directoryIdentity))
1071
- return;
1072
- const atRecordedPath = yield* sameDirectorySteps(candidate, path);
1073
- const targets = [
1074
- ...(metadata?.targets ?? []),
1075
- ...(yield* configuredRelativeTargetsSteps(candidate, getHomeDir(), undefined, false)),
1076
- ];
1077
- const physicalCandidate = yield* canonicalPathSteps(candidate);
1078
- const ownTargets = [];
1079
- for (const target of targets) {
1080
- if (containsPath(physicalCandidate, yield* canonicalPathSteps(resolve(candidate, target))) &&
1081
- (claimedTarget === undefined ||
1082
- !pathsEqual(resolve(candidate, target), resolve(candidate, claimedTarget)) ||
1083
- (yield* io("exists", yield* localTargetMarkerFileSteps(candidate, claimedTarget)))))
1084
- ownTargets.push(target);
1101
+ const identityInfo = yield* fileIdentityWithStatSteps(owner.homeIdentity ? storageHomeDecisionFile(candidate) : candidate);
1102
+ const isExcludedExact = excludedExactCandidate !== undefined && (yield* sameDirectorySteps(candidate, excludedExactCandidate));
1103
+ if (!isExcludedExact && identityInfo !== undefined && identityInfo.identity === owner.identity) {
1104
+ for (const match of exact) {
1105
+ if (yield* sameDirectorySteps(match.path, candidate))
1106
+ return;
1085
1107
  }
1086
- const legacyTargets = owner.legacyTargets;
1087
- let unownedTargets = ownTargets;
1088
- if (legacyTargets !== undefined) {
1089
- unownedTargets = [];
1090
- for (const target of ownTargets) {
1091
- if (!legacyTargets.some((legacy) => pathsEqual(resolve(candidate, legacy), resolve(candidate, target))) ||
1092
- !(yield* hasRelativeTargetEntriesSteps(claimDirectory, candidate, [target], true)))
1093
- unownedTargets.push(target);
1094
- }
1108
+ exact.push({ path: candidate, stat: identityInfo.stat });
1109
+ return;
1110
+ }
1111
+ const metadata = yield* storageDecisionMetadataSteps(candidate);
1112
+ if ((owner.decisionId === undefined || metadata?.id !== owner.decisionId) &&
1113
+ (owner.directoryIdentity === undefined || (yield* fileIdentitySteps(candidate)) !== owner.directoryIdentity))
1114
+ return;
1115
+ const atRecordedPath = yield* sameDirectorySteps(candidate, recordedPath);
1116
+ const targets = [
1117
+ ...(metadata?.targets ?? []),
1118
+ ...(yield* configuredRelativeTargetsSteps(candidate, getHomeDir(), undefined, false)),
1119
+ ];
1120
+ const physicalCandidate = yield* canonicalPathSteps(candidate);
1121
+ const ownTargets = [];
1122
+ for (const target of targets) {
1123
+ if (containsPath(physicalCandidate, yield* canonicalPathSteps(resolve(candidate, target))) &&
1124
+ (claimedTarget === undefined ||
1125
+ !pathsEqual(resolve(candidate, target), resolve(candidate, claimedTarget)) ||
1126
+ (yield* io("exists", yield* localTargetMarkerFileSteps(candidate, claimedTarget)))))
1127
+ ownTargets.push(target);
1128
+ }
1129
+ const legacyTargets = owner.legacyTargets;
1130
+ let unownedTargets = ownTargets;
1131
+ if (legacyTargets !== undefined) {
1132
+ unownedTargets = [];
1133
+ for (const target of ownTargets) {
1134
+ if (!legacyTargets.some((legacy) => pathsEqual(resolve(candidate, legacy), resolve(candidate, target))) ||
1135
+ !(yield* hasRelativeTargetEntriesSteps(claimDirectory, candidate, [target], true)))
1136
+ unownedTargets.push(target);
1095
1137
  }
1096
- if ((yield* hasOwnStoreEntriesSteps(candidate, claimDirectory, [])) ||
1097
- (owner.legacyTargets === undefined && atRecordedPath
1098
- ? yield* hasOwnTargetEntriesSteps(candidate, claimDirectory, ownTargets)
1099
- : yield* hasRelativeTargetEntriesSteps(candidate, candidate, unownedTargets, true)))
1100
- return;
1101
- matches = atRecordedPath ? recorded : fallback;
1102
1138
  }
1103
- for (const match of matches) {
1104
- if (yield* sameDirectorySteps(match, candidate))
1139
+ if ((yield* hasOwnStoreEntriesSteps(candidate, claimDirectory, [])) ||
1140
+ (owner.legacyTargets === undefined && atRecordedPath
1141
+ ? yield* hasOwnTargetEntriesSteps(candidate, claimDirectory, ownTargets)
1142
+ : yield* hasRelativeTargetEntriesSteps(candidate, candidate, unownedTargets, true)))
1143
+ return;
1144
+ const bucket = atRecordedPath ? recorded : fallback;
1145
+ for (const match of bucket) {
1146
+ if (yield* sameDirectorySteps(match.path, candidate))
1105
1147
  return;
1106
1148
  }
1107
- matches.push(candidate);
1149
+ bucket.push({ path: candidate, metadata });
1108
1150
  }
1109
1151
  try {
1110
- yield* consider(path);
1152
+ yield* consider(recordedPath);
1111
1153
  for (const entry of yield* io("listDirectory", claimDirectory)) {
1112
1154
  yield* consider(join(claimDirectory, entry.name));
1113
1155
  }
@@ -1115,8 +1157,112 @@ function* currentStorageOwnerPathSteps(owner, claimDirectory = dirname(owner.pat
1115
1157
  catch {
1116
1158
  return undefined;
1117
1159
  }
1118
- const matches = exact.length > 0 ? exact : recorded.length > 0 ? recorded : fallback;
1119
- return matches.length === 1 ? matches[0] : undefined;
1160
+ return { exact, recorded, fallback };
1161
+ }
1162
+ /**
1163
+ * When a single inode-matched `.atomic-storage-home` candidate carries a conflicting on-disk `decisionId` and does not
1164
+ * still carry the original owner's evidence, check whether demoting it reveals a unique eligible owner with on-disk
1165
+ * `decisionId === owner.decisionId` (e.g. a moved/renamed owner whose deleted decision inode was reused by a sibling).
1166
+ * If no such unique replacement exists, preserve the inode match unchanged.
1167
+ */
1168
+ function* maybeDisplaceConflictingExactCandidateSteps(owner, claimDirectory, claimedTarget, recordedPath, candidate, candidateStat, context) {
1169
+ if (!owner.homeIdentity ||
1170
+ owner.decisionId === undefined ||
1171
+ owner.identity === undefined ||
1172
+ owner.identity.startsWith("path:")) {
1173
+ return { ownerPath: candidate };
1174
+ }
1175
+ const directPathMatchesCaller = context !== undefined && pathsEqual(candidate, context.path);
1176
+ const cachedCanonicalMatchesCaller = context !== undefined && context.canonicalPath !== undefined && pathsEqual(candidate, context.canonicalPath);
1177
+ const pathMatchesCaller = directPathMatchesCaller || cachedCanonicalMatchesCaller;
1178
+ // Only trust cached canonicalPath as proving isSelf when freshly resolved in this call; a warm cached
1179
+ // symlink may have been repointed to a sibling, so leave isSelf undefined for live sameDirectorySteps verification.
1180
+ let isSelf = directPathMatchesCaller || (context?.fresh && cachedCanonicalMatchesCaller) ? true : undefined;
1181
+ if (!pathMatchesCaller && context?.onlySelf) {
1182
+ isSelf = yield* sameDirectorySteps(candidate, context.path);
1183
+ }
1184
+ if (context?.onlySelf && isSelf === false && context.decisionId !== owner.decisionId) {
1185
+ return { ownerPath: candidate, isSelf: false };
1186
+ }
1187
+ const liveStamp = decisionStampOf(candidateStat);
1188
+ if (context !== undefined && (pathMatchesCaller || isSelf === true)) {
1189
+ if (context.fresh && context.decisionId === owner.decisionId) {
1190
+ if (context.verifiedCache !== undefined && liveStamp !== undefined) {
1191
+ context.verifiedCache.verifiedDecision = { id: context.decisionId, stamp: liveStamp };
1192
+ }
1193
+ return { ownerPath: candidate, isSelf };
1194
+ }
1195
+ const cached = context.verifiedCache?.verifiedDecision;
1196
+ if (cached !== undefined &&
1197
+ cached.id === owner.decisionId &&
1198
+ liveStamp !== undefined &&
1199
+ sameDecisionStamp(cached.stamp, liveStamp)) {
1200
+ return { ownerPath: candidate, isSelf };
1201
+ }
1202
+ }
1203
+ const candMetadata = yield* storageDecisionMetadataSteps(candidate);
1204
+ if (candMetadata?.id !== undefined &&
1205
+ context?.verifiedCache !== undefined &&
1206
+ liveStamp !== undefined &&
1207
+ (pathMatchesCaller || isSelf === true)) {
1208
+ context.verifiedCache.verifiedDecision = { id: candMetadata.id, stamp: liveStamp };
1209
+ }
1210
+ if (candMetadata?.id === undefined || candMetadata.id === owner.decisionId) {
1211
+ return { ownerPath: candidate, isSelf };
1212
+ }
1213
+ // Legitimate owners whose decision file was replaced in place keep parentOwner (parent claims) or directoryIdentity (target claims).
1214
+ if (claimedTarget === undefined) {
1215
+ if (candMetadata.parentOwner !== undefined)
1216
+ return { ownerPath: candidate, isSelf };
1217
+ }
1218
+ else if (owner.directoryIdentity !== undefined &&
1219
+ (yield* fileIdentitySteps(candidate)) === owner.directoryIdentity) {
1220
+ return { ownerPath: candidate, isSelf };
1221
+ }
1222
+ const demoted = yield* scanStorageOwnerCandidatesSteps(owner, claimDirectory, claimedTarget, recordedPath, candidate);
1223
+ if (demoted === undefined)
1224
+ return { ownerPath: candidate, isSelf };
1225
+ if (demoted.exact.length > 0) {
1226
+ if (demoted.exact.length !== 1)
1227
+ return { ownerPath: candidate, isSelf };
1228
+ const other = demoted.exact[0].path;
1229
+ if (yield* sameDirectorySteps(other, candidate))
1230
+ return { ownerPath: candidate, isSelf };
1231
+ const otherMeta = yield* storageDecisionMetadataSteps(other);
1232
+ return otherMeta?.id === owner.decisionId ? { ownerPath: other } : { ownerPath: candidate, isSelf };
1233
+ }
1234
+ const weakMatches = demoted.recorded.length > 0 ? demoted.recorded : demoted.fallback;
1235
+ if (weakMatches.length !== 1)
1236
+ return { ownerPath: candidate, isSelf };
1237
+ const replacement = weakMatches[0];
1238
+ if (yield* sameDirectorySteps(replacement.path, candidate))
1239
+ return { ownerPath: candidate, isSelf };
1240
+ return replacement.metadata?.id === owner.decisionId
1241
+ ? { ownerPath: replacement.path }
1242
+ : { ownerPath: candidate, isSelf };
1243
+ }
1244
+ function* resolveStorageOwnerForCallerSteps(owner, claimDirectory = dirname(owner.path), claimedTarget, context) {
1245
+ const path = owner.relativePath === undefined ? owner.path : resolve(claimDirectory, owner.relativePath);
1246
+ if (owner.identity === undefined)
1247
+ return { ownerPath: path };
1248
+ const fastInfo = yield* fileIdentityWithStatSteps(owner.homeIdentity ? storageHomeDecisionFile(path) : path);
1249
+ if (fastInfo?.identity === owner.identity) {
1250
+ return yield* maybeDisplaceConflictingExactCandidateSteps(owner, claimDirectory, claimedTarget, path, path, fastInfo.stat, context);
1251
+ }
1252
+ const scanned = yield* scanStorageOwnerCandidatesSteps(owner, claimDirectory, claimedTarget, path);
1253
+ if (scanned === undefined)
1254
+ return { ownerPath: undefined };
1255
+ if (scanned.exact.length > 0) {
1256
+ if (scanned.exact.length !== 1)
1257
+ return { ownerPath: undefined };
1258
+ const soleExact = scanned.exact[0];
1259
+ return yield* maybeDisplaceConflictingExactCandidateSteps(owner, claimDirectory, claimedTarget, path, soleExact.path, soleExact.stat, context);
1260
+ }
1261
+ const weakMatches = scanned.recorded.length > 0 ? scanned.recorded : scanned.fallback;
1262
+ return { ownerPath: weakMatches.length === 1 ? weakMatches[0].path : undefined };
1263
+ }
1264
+ function* currentStorageOwnerPathSteps(owner, claimDirectory = dirname(owner.path), claimedTarget, context) {
1265
+ return (yield* resolveStorageOwnerForCallerSteps(owner, claimDirectory, claimedTarget, context)).ownerPath;
1120
1266
  }
1121
1267
  function* refreshStorageOwnerSteps(file, owner, agentPath, claimDirectory) {
1122
1268
  const current = {
@@ -1144,22 +1290,47 @@ function* refreshStorageOwnerSteps(file, owner, agentPath, claimDirectory) {
1144
1290
  catch { }
1145
1291
  }
1146
1292
  }
1147
- function* parentStorageOwnerSteps(parent) {
1293
+ function* parentStorageOwnerSteps(parent, context) {
1148
1294
  const owner = yield* readStorageOwnerSteps(join(parent, PARENT_CLAIM_FILE));
1149
1295
  return owner === undefined
1150
1296
  ? yield* readClaimFileSteps(join(parent, "workflows", ADOPTION_CLAIM_FILE))
1151
- : ((yield* currentStorageOwnerPathSteps(owner, parent)) ?? join(parent, PARENT_CLAIM_FILE));
1297
+ : ((yield* currentStorageOwnerPathSteps(owner, parent, undefined, context)) ?? join(parent, PARENT_CLAIM_FILE));
1298
+ }
1299
+ function* parentStorageOwnerMatchesSelfSteps(parent, context) {
1300
+ const owner = yield* readStorageOwnerSteps(join(parent, PARENT_CLAIM_FILE));
1301
+ if (owner === undefined) {
1302
+ const legacy = yield* readClaimFileSteps(join(parent, "workflows", ADOPTION_CLAIM_FILE));
1303
+ return {
1304
+ existingOwner: legacy,
1305
+ isSelf: legacy !== undefined && (yield* sameDirectorySteps(legacy, context.path)),
1306
+ };
1307
+ }
1308
+ const resolved = yield* resolveStorageOwnerForCallerSteps(owner, parent, undefined, context);
1309
+ const existingOwner = resolved.ownerPath ?? join(parent, PARENT_CLAIM_FILE);
1310
+ const isSelf = resolved.isSelf !== undefined
1311
+ ? resolved.isSelf
1312
+ : resolved.ownerPath !== undefined && (yield* sameDirectorySteps(resolved.ownerPath, context.path));
1313
+ return { existingOwner, isSelf };
1152
1314
  }
1153
1315
  function* applyStorageHomeDecisionSteps(decision, agentPath) {
1316
+ const canonicalAgentPath = decisionCanonicalPaths.get(decision);
1154
1317
  if (decision.defaultHome) {
1155
1318
  const home = yield* defaultHomeForAgentSteps(agentPath, join(getHomeDir(), CONFIG_DIR_NAME));
1156
- return home === undefined ? createStorageHomeEntry(agentPath) : createDefaultStorageHomeEntry(home);
1319
+ return home === undefined
1320
+ ? createStorageHomeEntry(agentPath, undefined, false, decision.id, canonicalAgentPath)
1321
+ : createDefaultStorageHomeEntry(home, false, decision.id, canonicalAgentPath);
1157
1322
  }
1158
1323
  if (decision.parentOwner === undefined)
1159
- return createStorageHomeEntry(agentPath);
1324
+ return createStorageHomeEntry(agentPath, undefined, false, decision.id, canonicalAgentPath);
1325
+ const context = {
1326
+ path: agentPath,
1327
+ canonicalPath: canonicalAgentPath,
1328
+ decisionId: decision.id,
1329
+ fresh: true,
1330
+ };
1160
1331
  const workflows = join(decision.home, "workflows");
1161
1332
  const claim = join(decision.home, PARENT_CLAIM_FILE);
1162
- const preferred = yield* canonicalPathSteps((yield* parentStorageOwnerSteps(decision.home)) ?? decision.parentOwner);
1333
+ const preferred = yield* canonicalPathSteps((yield* parentStorageOwnerSteps(decision.home, context)) ?? decision.parentOwner);
1163
1334
  const ownerTargets = new Set([
1164
1335
  ...((yield* storageDecisionMetadataSteps(preferred))?.targets ?? []),
1165
1336
  ...(yield* configuredRelativeTargetsSteps(preferred, getHomeDir(), undefined, false)),
@@ -1175,7 +1346,7 @@ function* applyStorageHomeDecisionSteps(decision, agentPath) {
1175
1346
  const winner = yield* readStorageOwnerSteps(claim);
1176
1347
  if (winner === undefined)
1177
1348
  throw new Error(`Cannot claim storage home at ${claim}`);
1178
- const winnerPath = yield* currentStorageOwnerPathSteps(winner, decision.home);
1349
+ const winnerPath = yield* currentStorageOwnerPathSteps(winner, decision.home, undefined, context);
1179
1350
  if (winnerPath !== undefined && (yield* sameDirectorySteps(winnerPath, agentPath))) {
1180
1351
  yield* refreshStorageOwnerSteps(claim, winner, agentPath, decision.home);
1181
1352
  }
@@ -1192,14 +1363,17 @@ function* applyStorageHomeDecisionSteps(decision, agentPath) {
1192
1363
  }
1193
1364
  }
1194
1365
  if (winnerPath !== undefined && (yield* sameDirectorySteps(winnerPath, agentPath)))
1195
- return createStorageHomeEntry(decision.home, claim);
1366
+ return createStorageHomeEntry(decision.home, claim, false, decision.id, canonicalAgentPath);
1196
1367
  const weakCandidate = (winner.decisionId !== undefined && (yield* storageDecisionMetadataSteps(agentPath))?.id === winner.decisionId) ||
1197
1368
  (winner.directoryIdentity !== undefined && (yield* fileIdentitySteps(agentPath)) === winner.directoryIdentity);
1198
1369
  return weakCandidate && winner.legacyTargets !== undefined
1199
- ? { ...createStorageHomeEntry(agentPath), rejectedParentAdoption: { legacyTargets: winner.legacyTargets } }
1200
- : createStorageHomeEntry(agentPath);
1370
+ ? {
1371
+ ...createStorageHomeEntry(agentPath, undefined, false, decision.id, canonicalAgentPath),
1372
+ rejectedParentAdoption: { legacyTargets: winner.legacyTargets },
1373
+ }
1374
+ : createStorageHomeEntry(agentPath, undefined, false, decision.id, canonicalAgentPath);
1201
1375
  }
1202
- function* resolveStorageHomeEntrySteps(agentDir, settings) {
1376
+ function* resolveStorageHomeEntrySteps(agentDir, settings, freshness) {
1203
1377
  const platform = process.platform;
1204
1378
  const rawHome = getHomeDir(platform);
1205
1379
  const rawAgentDir = agentDir ?? resolveConfiguredAgentDir(rawHome);
@@ -1232,6 +1406,8 @@ function* resolveStorageHomeEntrySteps(agentDir, settings) {
1232
1406
  fastStorageHomes.set(rawAgentDir, { ...fastKey, entry: cached });
1233
1407
  return cached;
1234
1408
  }
1409
+ if (freshness !== undefined)
1410
+ freshness.fresh = true;
1235
1411
  const matchedDefaultHome = yield* defaultHomeForAgentSteps(agentPath, defaultHome);
1236
1412
  if (matchedDefaultHome !== undefined) {
1237
1413
  const file = storageHomeDecisionFile(agentPath);
@@ -1262,11 +1438,16 @@ function* resolveStorageHomeEntrySteps(agentDir, settings) {
1262
1438
  }
1263
1439
  const relativeTargets = yield* configuredRelativeTargetsSteps(agentPath, rawHome, settings);
1264
1440
  const parentWorkflows = join(parent, "workflows");
1265
- const existingOwner = yield* parentStorageOwnerSteps(parent);
1441
+ const { existingOwner, isSelf: existingOwnerIsSelf } = yield* parentStorageOwnerMatchesSelfSteps(parent, {
1442
+ path: agentPath,
1443
+ decisionId: undefined,
1444
+ fresh: true,
1445
+ onlySelf: true,
1446
+ });
1266
1447
  let decision = { home: agentPath };
1267
1448
  if (!(yield* hasOwnStoreEntriesSteps(agentPath, parent, relativeTargets))) {
1268
1449
  if (existingOwner !== undefined) {
1269
- if (yield* sameDirectorySteps(existingOwner, agentPath))
1450
+ if (existingOwnerIsSelf)
1270
1451
  decision = { home: parent, parentOwner: existingOwner };
1271
1452
  }
1272
1453
  else if (yield* hasParentStoreEntriesSteps(parent, agentPath, relativeTargets)) {
@@ -1308,8 +1489,14 @@ function* coLocatesWorkflowStoreSteps(agentDir, settings) {
1308
1489
  if (decision !== undefined) {
1309
1490
  if (decision.defaultHome || decision.parentOwner === undefined)
1310
1491
  return true;
1311
- const owner = yield* parentStorageOwnerSteps(decision.home);
1312
- return !(yield* sameDirectorySteps(owner ?? decision.parentOwner, agentPath));
1492
+ const { existingOwner, isSelf } = yield* parentStorageOwnerMatchesSelfSteps(decision.home, {
1493
+ path: agentPath,
1494
+ canonicalPath: decisionCanonicalPaths.get(decision),
1495
+ decisionId: decision.id,
1496
+ fresh: true,
1497
+ onlySelf: true,
1498
+ });
1499
+ return existingOwner === undefined ? !(yield* sameDirectorySteps(decision.parentOwner, agentPath)) : !isSelf;
1313
1500
  }
1314
1501
  const parent = dirname(agentPath);
1315
1502
  if (pathsEqual(parent, agentPath) || (yield* isDefaultStorageHomeSteps(parent, defaultHome)))
@@ -1318,9 +1505,14 @@ function* coLocatesWorkflowStoreSteps(agentDir, settings) {
1318
1505
  if (yield* hasOwnStoreEntriesSteps(agentPath, parent, relativeTargets))
1319
1506
  return true;
1320
1507
  const parentWorkflows = join(parent, "workflows");
1321
- const existingOwner = yield* parentStorageOwnerSteps(parent);
1508
+ const { existingOwner, isSelf: existingOwnerIsSelf } = yield* parentStorageOwnerMatchesSelfSteps(parent, {
1509
+ path: agentPath,
1510
+ decisionId: undefined,
1511
+ fresh: true,
1512
+ onlySelf: true,
1513
+ });
1322
1514
  if (existingOwner !== undefined)
1323
- return !(yield* sameDirectorySteps(existingOwner, agentPath));
1515
+ return !existingOwnerIsSelf;
1324
1516
  if (!(yield* hasParentStoreEntriesSteps(parent, agentPath, relativeTargets)))
1325
1517
  return true;
1326
1518
  const hostIdOwner = yield* eligibleLegacyHostOwnerSteps(parentWorkflows, rawHome);
@@ -1412,11 +1604,12 @@ export async function storagePathBaseDirAsync(path, agentDir, settings) {
1412
1604
  return runStorageSteps(storagePathBaseDirSteps(path, agentDir, settings));
1413
1605
  }
1414
1606
  export function* storagePathBaseDirSteps(path, agentDir, settings) {
1415
- const entry = yield* resolveStorageHomeEntrySteps(agentDir, settings);
1607
+ const entryFreshness = { fresh: false };
1608
+ const entry = yield* resolveStorageHomeEntrySteps(agentDir, settings, entryFreshness);
1416
1609
  const targetCacheKey = `${agentDir}\0${path}`;
1417
1610
  const cached = storageTargetDecisions.get(entry)?.get(targetCacheKey);
1418
1611
  if (cached !== undefined)
1419
- return yield* applyStorageTargetDecisionSteps(cached, settings);
1612
+ return yield* applyStorageTargetDecisionSteps(cached, settings, entryFreshness.fresh);
1420
1613
  const home = entry.home;
1421
1614
  const target = normalizeRelativeTarget(path, getHomeDir());
1422
1615
  if (target === undefined)
@@ -1490,7 +1683,13 @@ export function* storagePathBaseDirSteps(path, agentDir, settings) {
1490
1683
  };
1491
1684
  }
1492
1685
  }
1493
- const resolved = { agentPath, target, decision };
1686
+ const resolved = {
1687
+ agentPath,
1688
+ ...(entry.canonicalAgentPath === undefined ? {} : { canonicalAgentPath: entry.canonicalAgentPath }),
1689
+ target,
1690
+ decision,
1691
+ ...(entry.decisionId === undefined ? {} : { decisionId: entry.decisionId }),
1692
+ };
1494
1693
  if (!entry.provisionalWithoutSettings && settings !== undefined && (yield* io("isDirectory", agentPath))) {
1495
1694
  let targets = storageTargetDecisions.get(entry);
1496
1695
  if (targets === undefined) {
@@ -1499,7 +1698,7 @@ export function* storagePathBaseDirSteps(path, agentDir, settings) {
1499
1698
  }
1500
1699
  targets.set(targetCacheKey, resolved);
1501
1700
  }
1502
- return yield* applyStorageTargetDecisionSteps(resolved, settings);
1701
+ return yield* applyStorageTargetDecisionSteps(resolved, settings, entryFreshness.fresh);
1503
1702
  }
1504
1703
  function* defaultTargetVersionSteps({ agentPath, target, decision, }) {
1505
1704
  if (!decision.defaultHome)
@@ -1524,10 +1723,18 @@ function* defaultTargetVersionSteps({ agentPath, target, decision, }) {
1524
1723
  return undefined;
1525
1724
  }
1526
1725
  }
1527
- function* applyStorageTargetDecisionSteps(targetDecision, settings) {
1528
- const { agentPath, target, decision } = targetDecision;
1726
+ function* applyStorageTargetDecisionSteps(targetDecision, settings, entryFresh = false) {
1727
+ const { agentPath, canonicalAgentPath, target, decision, decisionId } = targetDecision;
1529
1728
  if (decision.parentOwner === undefined)
1530
1729
  return decision.home;
1730
+ const context = {
1731
+ path: agentPath,
1732
+ canonicalPath: canonicalAgentPath,
1733
+ decisionId,
1734
+ fresh: entryFresh,
1735
+ onlySelf: true,
1736
+ verifiedCache: targetDecision,
1737
+ };
1531
1738
  const version = yield* defaultTargetVersionSteps(targetDecision);
1532
1739
  const cached = defaultTargetClaims.get(targetDecision);
1533
1740
  const selected = resolve(decision.home, target);
@@ -1546,8 +1753,11 @@ function* applyStorageTargetDecisionSteps(targetDecision, settings) {
1546
1753
  }
1547
1754
  if (owner === undefined)
1548
1755
  throw new Error(`Cannot claim storage target at ${claim}`);
1549
- const ownerPath = yield* currentStorageOwnerPathSteps(owner, dirname(claim), target);
1550
- if (ownerPath !== undefined && (yield* sameDirectorySteps(ownerPath, agentPath)))
1756
+ const resolved = yield* resolveStorageOwnerForCallerSteps(owner, dirname(claim), target, context);
1757
+ const isSelf = resolved.isSelf !== undefined
1758
+ ? resolved.isSelf
1759
+ : resolved.ownerPath !== undefined && (yield* sameDirectorySteps(resolved.ownerPath, agentPath));
1760
+ if (isSelf)
1551
1761
  continue;
1552
1762
  const fallback = resolve(agentPath, target);
1553
1763
  if (!containsPath(yield* canonicalPathSteps(agentPath), yield* canonicalPathSteps(fallback)) ||