@bastani/atomic 0.10.11-alpha.1 → 0.10.11-alpha.3

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 (457) hide show
  1. package/CHANGELOG.md +155 -0
  2. package/README.md +5 -8
  3. package/dist/_shared/dist-KOELCESV.js +2 -2
  4. package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
  5. package/dist/_shared/lib-4PES5P4V.js +2 -2
  6. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +9 -9
  7. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +8 -8
  8. package/dist/_shared/mode-shared-2QJSCUM6.js +9 -9
  9. package/dist/_shared/p0-cli-BB45ZQY6.js +46 -67
  10. package/dist/_shared/p0-cli-BB45ZQY6.js.map +1 -1
  11. package/dist/_shared/p1a-prewarm-XIU57JHF.js +7 -8
  12. package/dist/_shared/p1a-prewarm-XIU57JHF.js.map +1 -1
  13. package/dist/_shared/{p1b-elig-ENCUPKKJ.js → p1b-elig-TVB5CBLL.js} +14 -2
  14. package/dist/_shared/{p1b-elig-ENCUPKKJ.js.map → p1b-elig-TVB5CBLL.js.map} +1 -1
  15. package/dist/_shared/runtime-O4KCSG4C.js +5 -5
  16. package/dist/_shared/{sdk-AVFII7NK.js → sdk-B5LEWGGI.js} +2633 -488
  17. package/dist/_shared/sdk-B5LEWGGI.js.map +1 -0
  18. package/dist/_shared/session-data-AHTU7IS6.js +3 -3
  19. package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
  20. package/dist/_shared/settings-startup-8-DNZ2RIHM.js +1 -1
  21. package/dist/_shared/{settings-startup-4QCVCI53.js → settings-startup-HXQLSUWM.js} +8 -2
  22. package/dist/_shared/settings-startup-HXQLSUWM.js.map +1 -0
  23. package/dist/_shared/{startup-0-0-57KF6LZH.js → startup-0-0-EZUKEP4Q.js} +436 -51
  24. package/dist/_shared/startup-0-0-EZUKEP4Q.js.map +1 -0
  25. package/dist/_shared/{startup-0-1-GIY75K46.js → startup-0-1-RTOHJFDJ.js} +240 -279
  26. package/dist/_shared/startup-0-1-RTOHJFDJ.js.map +1 -0
  27. package/dist/_shared/{startup-0-2-27OWFHV6.js → startup-0-2-5QHPCEON.js} +254 -46
  28. package/dist/_shared/startup-0-2-5QHPCEON.js.map +1 -0
  29. package/dist/_shared/{startup-0-3-T4DVFYWX.js → startup-0-3-4ZYBYQNM.js} +273 -14
  30. package/dist/_shared/startup-0-3-4ZYBYQNM.js.map +1 -0
  31. package/dist/_shared/startup-0-4-ZMJV547D.js +14 -9
  32. package/dist/_shared/startup-0-4-ZMJV547D.js.map +1 -1
  33. package/dist/_shared/startup-0-5-YDW47QX6.js +10 -10
  34. package/dist/_shared/startup-0-5-YDW47QX6.js.map +1 -1
  35. package/dist/_shared/startup-10-0-TDQNBDDL.js +9 -9
  36. package/dist/_shared/startup-12-0-55AAXBJZ.js +3 -3
  37. package/dist/_shared/startup-14-0-MLX36RBG.js +6 -7
  38. package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
  39. package/dist/_shared/startup-15-0-YUKGAC63.js +7 -7
  40. package/dist/_shared/startup-15-1-4S7FLMNG.js +22 -30
  41. package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
  42. package/dist/_shared/startup-8-0-34CBHPZH.js +455 -102
  43. package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
  44. package/dist/_shared/{startup-8-1-X32CYSXB.js → startup-8-1-LZFXSD3Z.js} +162 -1184
  45. package/dist/_shared/startup-8-1-LZFXSD3Z.js.map +1 -0
  46. package/dist/_shared/storage-command-7MGXLJGZ.js +189 -36
  47. package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
  48. package/dist/_shared/storage-status-K7PX2RXA.js +557 -0
  49. package/dist/_shared/storage-status-K7PX2RXA.js.map +1 -0
  50. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
  51. package/dist/_shared/team-DOQKICG2.js +376 -0
  52. package/dist/_shared/team-DOQKICG2.js.map +1 -0
  53. package/dist/_shared/tree-outline-MUEPK5B7.js +3 -3
  54. package/dist/builtin/intercom/CHANGELOG.md +34 -0
  55. package/dist/builtin/intercom/README.md +2 -2
  56. package/dist/builtin/intercom/broker/broker.bundle.mjs +1091 -344
  57. package/dist/builtin/intercom/broker/database-wake-up-bus.ts +243 -64
  58. package/dist/builtin/intercom/broker/multinode-router.ts +154 -22
  59. package/dist/builtin/intercom/broker/multinode-state-store.ts +30 -3
  60. package/dist/builtin/intercom/broker/open-broker-state.ts +14 -0
  61. package/dist/builtin/intercom/broker/sql-add-column.ts +29 -5
  62. package/dist/builtin/intercom/broker/sql-ended-child-queue-store.ts +3 -2
  63. package/dist/builtin/intercom/broker/sql-held-send-store.ts +2 -2
  64. package/dist/builtin/intercom/broker/sql-known-session-store.ts +43 -19
  65. package/dist/builtin/intercom/broker/sql-lease-store.ts +208 -101
  66. package/dist/builtin/intercom/broker/sql-outbox-store.ts +516 -102
  67. package/dist/builtin/intercom/broker/sql-pending-ask-store.ts +8 -5
  68. package/dist/builtin/intercom/broker/sql-released-ask-store.ts +12 -5
  69. package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +24 -7
  70. package/dist/builtin/intercom/broker/sql-retention.ts +141 -0
  71. package/dist/builtin/intercom/broker/sql-schema.ts +199 -27
  72. package/dist/builtin/intercom/broker/sql-sent-message-authority.ts +74 -19
  73. package/dist/builtin/intercom/broker/wake-up-bus.ts +6 -0
  74. package/dist/builtin/intercom/index.bundle.mjs +2 -3
  75. package/dist/builtin/intercom/package.json +1 -1
  76. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  77. package/dist/builtin/mcp/package.json +1 -1
  78. package/dist/builtin/subagents/CHANGELOG.md +6 -0
  79. package/dist/builtin/subagents/package.json +1 -1
  80. package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
  81. package/dist/builtin/web-access/index.bundle.mjs +2 -10
  82. package/dist/builtin/web-access/package.json +1 -1
  83. package/dist/bun/bundled-sqlite.js +41 -0
  84. package/dist/bun/bundled-sqlite.js.map +1 -0
  85. package/dist/cli/args.js +2 -2
  86. package/dist/cli/auth-cli.code.js +6 -6
  87. package/dist/cli/auth-cli.impl.js +3 -3
  88. package/dist/cli/auth-cli.js +3 -3
  89. package/dist/cli/blueprint-command.code.js +4 -4
  90. package/dist/cli/blueprint-command.impl.js +3 -3
  91. package/dist/cli/blueprint-command.js +3 -3
  92. package/dist/cli/intercom-command.code.js +4 -4
  93. package/dist/cli/intercom-command.code.js.map +1 -1
  94. package/dist/cli/intercom-command.impl.js +3 -3
  95. package/dist/cli/intercom-command.js +3 -3
  96. package/dist/cli/list-models.code.js +2 -2
  97. package/dist/cli/list-models.impl.js +3 -3
  98. package/dist/cli/list-models.js +3 -3
  99. package/dist/cli/session-picker.code.js +2 -2
  100. package/dist/cli/session-picker.impl.js +3 -3
  101. package/dist/cli/session-picker.js +3 -3
  102. package/dist/cli/startup-ui.code.js +2 -2
  103. package/dist/cli/startup-ui.impl.js +3 -3
  104. package/dist/cli/startup-ui.js +3 -3
  105. package/dist/cli/storage-command.impl.js +3 -3
  106. package/dist/cli/storage-command.js +3 -3
  107. package/dist/cli/storage-search-session.code.js +3 -3
  108. package/dist/cli/storage-search-session.impl.js +3 -3
  109. package/dist/cli/storage-search-session.js +3 -3
  110. package/dist/cli/team-command.code.js +20 -114
  111. package/dist/cli/team-command.code.js.map +1 -1
  112. package/dist/cli/team-command.impl.js +3 -3
  113. package/dist/cli/team-command.js +3 -3
  114. package/dist/cli.js +5 -18
  115. package/dist/cli.js.map +1 -1
  116. package/dist/core/agent-rehydrate-errors.d.ts +4 -9
  117. package/dist/core/compaction/compactor.d.ts +3 -3
  118. package/dist/core/debug.code.js +1 -1
  119. package/dist/core/debug.impl.js +3 -3
  120. package/dist/core/debug.js +3 -3
  121. package/dist/core/export-html/card-projection.impl.js +3 -3
  122. package/dist/core/export-html/card-projection.js +3 -3
  123. package/dist/core/export-html/index.code.js +2 -2
  124. package/dist/core/export-html/index.impl.js +3 -3
  125. package/dist/core/export-html/index.js +3 -3
  126. package/dist/core/export-html/json-spans.impl.js +3 -3
  127. package/dist/core/export-html/json-spans.js +3 -3
  128. package/dist/core/export-html/oversized-render-inputs.code.js +1 -1
  129. package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
  130. package/dist/core/export-html/oversized-render-inputs.js +3 -3
  131. package/dist/core/export-html/tool-renderer.impl.js +3 -3
  132. package/dist/core/export-html/tool-renderer.js +3 -3
  133. package/dist/core/extensions/jiti-loader.impl.js +3 -3
  134. package/dist/core/extensions/jiti-loader.js +3 -3
  135. package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
  136. package/dist/core/extensions/jiti-static-loader.js +3 -3
  137. package/dist/core/extensions/loader-host-modules.code.js +1 -1
  138. package/dist/core/extensions/loader-host-modules.impl.js +3 -3
  139. package/dist/core/extensions/loader-host-modules.js +3 -3
  140. package/dist/core/extensions/loader-virtual-modules.js +1 -1
  141. package/dist/core/extensions/runner-context.js +3 -3
  142. package/dist/core/intercom-broker-control-host.code.js +2 -2
  143. package/dist/core/intercom-broker-control-host.impl.js +3 -3
  144. package/dist/core/intercom-broker-control-host.js +3 -3
  145. package/dist/core/intercom-broker-control.code.js +3 -3
  146. package/dist/core/intercom-broker-control.impl.js +3 -3
  147. package/dist/core/intercom-broker-control.js +3 -3
  148. package/dist/core/package-manager-storage-adapters.code.js +1 -1
  149. package/dist/core/package-manager-storage-adapters.impl.js +3 -3
  150. package/dist/core/package-manager-storage-adapters.js +3 -3
  151. package/dist/core/process-start-token.d.ts +8 -0
  152. package/dist/core/process-tree-containment.d.ts +16 -0
  153. package/dist/core/sdk-types.d.ts +1 -2
  154. package/dist/core/sdk-types.js.map +1 -1
  155. package/dist/core/sdk.code.js +4 -4
  156. package/dist/core/sdk.impl.js +3 -3
  157. package/dist/core/sdk.js +3 -3
  158. package/dist/core/session-manager-core.js +27 -15
  159. package/dist/core/session-manager-core.js.map +1 -1
  160. package/dist/core/session-manager-list.impl.js +3 -3
  161. package/dist/core/session-manager-list.js +3 -3
  162. package/dist/core/session-manager.code.js +3 -3
  163. package/dist/core/session-manager.impl.js +3 -3
  164. package/dist/core/session-manager.js +3 -3
  165. package/dist/core/session-open-markers.js +3 -0
  166. package/dist/core/session-open-markers.js.map +1 -0
  167. package/dist/core/session-storage.code.js +1 -1
  168. package/dist/core/session-storage.impl.js +3 -3
  169. package/dist/core/session-storage.js +3 -3
  170. package/dist/core/settings-schema.d.ts +0 -3
  171. package/dist/core/storage/added-exports-0-10-11.js +19 -0
  172. package/dist/core/storage/added-exports-0-10-11.js.map +1 -0
  173. package/dist/core/storage/added-exports.js +3 -0
  174. package/dist/core/storage/added-exports.js.map +1 -1
  175. package/dist/core/storage/creation-time.js +105 -0
  176. package/dist/core/storage/creation-time.js.map +1 -0
  177. package/dist/core/storage/database.d.ts +56 -5
  178. package/dist/core/storage/database.js.map +1 -1
  179. package/dist/core/storage/dialect.d.ts +1 -1
  180. package/dist/core/storage/dialect.js +1 -1
  181. package/dist/core/storage/dialect.js.map +1 -1
  182. package/dist/core/storage/errors.d.ts +13 -13
  183. package/dist/core/storage/errors.js +10 -16
  184. package/dist/core/storage/errors.js.map +1 -1
  185. package/dist/core/storage/fenced-paths.d.ts +11 -0
  186. package/dist/core/storage/fenced-paths.js +11 -0
  187. package/dist/core/storage/fenced-paths.js.map +1 -1
  188. package/dist/core/storage/file-identity.d.ts +2 -0
  189. package/dist/core/storage/file-identity.js +24 -8
  190. package/dist/core/storage/file-identity.js.map +1 -1
  191. package/dist/core/storage/index.d.ts +4 -3
  192. package/dist/core/storage/index.js +5 -3
  193. package/dist/core/storage/index.js.map +1 -1
  194. package/dist/core/storage/libsql-removed.d.ts +71 -0
  195. package/dist/core/storage/libsql-removed.js +123 -0
  196. package/dist/core/storage/libsql-removed.js.map +1 -0
  197. package/dist/core/storage/migrations.d.ts +81 -8
  198. package/dist/core/storage/migrations.js +386 -47
  199. package/dist/core/storage/migrations.js.map +1 -1
  200. package/dist/core/storage/node-sqlite-file-gate.js +0 -15
  201. package/dist/core/storage/node-sqlite-file-gate.js.map +1 -1
  202. package/dist/core/storage/node-sqlite-thread.js +36 -12
  203. package/dist/core/storage/node-sqlite-thread.js.map +1 -1
  204. package/dist/core/storage/node-sqlite.js +135 -3
  205. package/dist/core/storage/node-sqlite.js.map +1 -1
  206. package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
  207. package/dist/core/storage/offline-snapshot-file.js +3 -3
  208. package/dist/core/storage/prefix.d.ts +1 -1
  209. package/dist/core/storage/prefix.js +14 -2
  210. package/dist/core/storage/prefix.js.map +1 -1
  211. package/dist/core/storage/process-selection.d.ts +5 -5
  212. package/dist/core/storage/provider.js +2 -2
  213. package/dist/core/storage/schema-catalog.d.ts +82 -5
  214. package/dist/core/storage/schema-catalog.js +244 -34
  215. package/dist/core/storage/schema-catalog.js.map +1 -1
  216. package/dist/core/storage/selection.d.ts +7 -82
  217. package/dist/core/storage/selection.js +20 -235
  218. package/dist/core/storage/selection.js.map +1 -1
  219. package/dist/core/storage/session/branch-fork-source.code.js +9 -8
  220. package/dist/core/storage/session/branch-fork-source.code.js.map +1 -1
  221. package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
  222. package/dist/core/storage/session/branch-fork-source.js +3 -3
  223. package/dist/core/storage/session/card-view.impl.js +3 -3
  224. package/dist/core/storage/session/card-view.js +3 -3
  225. package/dist/core/storage/session/child-reader.code.js +4 -4
  226. package/dist/core/storage/session/child-reader.impl.js +3 -3
  227. package/dist/core/storage/session/child-reader.js +3 -3
  228. package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
  229. package/dist/core/storage/session/chunked-resume-projection.js +3 -3
  230. package/dist/core/storage/session/errors.js +1 -1
  231. package/dist/core/storage/session/expanded-child-details.code.js +3 -3
  232. package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
  233. package/dist/core/storage/session/expanded-child-details.js +3 -3
  234. package/dist/core/storage/session/fork-detach.d.ts +118 -0
  235. package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
  236. package/dist/core/storage/session/fork-row-bytes.js +3 -3
  237. package/dist/core/storage/session/fork-row-index.impl.js +3 -3
  238. package/dist/core/storage/session/fork-row-index.js +3 -3
  239. package/dist/core/storage/session/fork-schema.js +53 -0
  240. package/dist/core/storage/session/fork-schema.js.map +1 -0
  241. package/dist/core/storage/session/fork-segments.d.ts +58 -0
  242. package/dist/core/storage/session/fork-staging.code.js +5 -8
  243. package/dist/core/storage/session/fork-staging.code.js.map +1 -1
  244. package/dist/core/storage/session/fork-staging.impl.js +3 -3
  245. package/dist/core/storage/session/fork-staging.js +3 -3
  246. package/dist/core/storage/session/fork-sweep.js +61 -0
  247. package/dist/core/storage/session/fork-sweep.js.map +1 -0
  248. package/dist/core/storage/session/fork-window.code.js +4 -4
  249. package/dist/core/storage/session/fork-window.impl.js +3 -3
  250. package/dist/core/storage/session/fork-window.js +3 -3
  251. package/dist/core/storage/session/history-pages.impl.js +3 -3
  252. package/dist/core/storage/session/history-pages.js +3 -3
  253. package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
  254. package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
  255. package/dist/core/storage/session/jsonl-session-store.d.ts +42 -2
  256. package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
  257. package/dist/core/storage/session/jsonl-session-store.js +3 -3
  258. package/dist/core/storage/session/memory-session-store.impl.js +3 -3
  259. package/dist/core/storage/session/memory-session-store.js +3 -3
  260. package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
  261. package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
  262. package/dist/core/storage/session/pinned-branch-resume.js +3 -3
  263. package/dist/core/storage/session/released-history-files.code.js +4 -4
  264. package/dist/core/storage/session/released-history-files.impl.js +3 -3
  265. package/dist/core/storage/session/released-history-files.js +3 -3
  266. package/dist/core/storage/session/resident-fork-rows.code.js +1 -1
  267. package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
  268. package/dist/core/storage/session/resident-fork-rows.js +3 -3
  269. package/dist/core/storage/session/session-resume.impl.js +3 -3
  270. package/dist/core/storage/session/session-resume.js +3 -3
  271. package/dist/core/storage/session/session-search-index.d.ts +43 -4
  272. package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
  273. package/dist/core/storage/session/snapshot-cut.js +3 -3
  274. package/dist/core/storage/session/snapshot-history.code.js +4 -4
  275. package/dist/core/storage/session/snapshot-history.impl.js +3 -3
  276. package/dist/core/storage/session/snapshot-history.js +3 -3
  277. package/dist/core/storage/session/sql-session-store.code.js +1 -1
  278. package/dist/core/storage/session/sql-session-store.d.ts +394 -20
  279. package/dist/core/storage/session/sql-session-store.impl.js +4 -4
  280. package/dist/core/storage/session/sql-session-store.js +4 -4
  281. package/dist/core/storage/session/tree-outline.impl.js +3 -3
  282. package/dist/core/storage/session/tree-outline.js +3 -3
  283. package/dist/core/storage/session/tree-presentation.impl.js +3 -3
  284. package/dist/core/storage/session/tree-presentation.js +3 -3
  285. package/dist/core/storage/session/types.d.ts +22 -0
  286. package/dist/core/storage/sqlite-facade.d.ts +23 -2
  287. package/dist/core/storage/sqlite-facade.js +34 -0
  288. package/dist/core/storage/sqlite-facade.js.map +1 -1
  289. package/dist/core/storage/storage-status.code.js +1 -1
  290. package/dist/core/storage/storage-status.impl.js +3 -3
  291. package/dist/core/storage/storage-status.js +3 -3
  292. package/dist/core/storage/team.code.js +1 -1
  293. package/dist/core/storage/team.d.ts +26 -115
  294. package/dist/core/storage/team.impl.js +3 -3
  295. package/dist/core/storage/team.js +3 -3
  296. package/dist/core/structured-output/index.code.js +1 -1
  297. package/dist/core/structured-output/index.impl.js +3 -3
  298. package/dist/core/structured-output/index.js +3 -3
  299. package/dist/core/tasks/task-completion-entry.impl.js +3 -3
  300. package/dist/core/tasks/task-completion-entry.js +3 -3
  301. package/dist/core/tasks/task-file-history.code.js +4 -4
  302. package/dist/core/tasks/task-file-history.impl.js +3 -3
  303. package/dist/core/tasks/task-file-history.js +3 -3
  304. package/dist/core/tasks/task-reference-archive.code.js +5 -5
  305. package/dist/core/tasks/task-reference-archive.js +3 -3
  306. package/dist/core/tasks/task-reference-identity.js +3 -3
  307. package/dist/core/tasks/task-reference-stream.impl.js +3 -3
  308. package/dist/core/tasks/task-reference-stream.js +3 -3
  309. package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
  310. package/dist/core/tasks/task-unsaved-answer.js +3 -3
  311. package/dist/core/tasks/task-view-source.code.js +1 -1
  312. package/dist/core/tasks/task-view-source.impl.js +3 -3
  313. package/dist/core/tasks/task-view-source.js +3 -3
  314. package/dist/core/tools/history-session.d.ts +2 -0
  315. package/dist/core/tools/history-tasks.d.ts +3 -2
  316. package/dist/core/tools/read-url.code.js +4 -4
  317. package/dist/core/tools/read-url.impl.js +3 -3
  318. package/dist/core/tools/read-url.js +3 -3
  319. package/dist/core/worktree-snapshot/blob-store.d.ts +71 -3
  320. package/dist/core/worktree-snapshot/blob-store.js +575 -67
  321. package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
  322. package/dist/core/worktree-snapshot/errors.code.js +3 -3
  323. package/dist/core/worktree-snapshot/errors.impl.js +3 -3
  324. package/dist/core/worktree-snapshot/errors.js +3 -3
  325. package/dist/core/worktree-snapshot/fork-blob-guard.js +81 -0
  326. package/dist/core/worktree-snapshot/fork-blob-guard.js.map +1 -0
  327. package/dist/core/worktree-snapshot/fork-snapshot-index.js +162 -0
  328. package/dist/core/worktree-snapshot/fork-snapshot-index.js.map +1 -0
  329. package/dist/core/worktree-snapshot/session-index-reset.code.js +4 -0
  330. package/dist/core/worktree-snapshot/session-index-reset.code.js.map +1 -1
  331. package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
  332. package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
  333. package/dist/extensions/codemode/execute.code.js +2 -2
  334. package/dist/extensions/codemode/execute.impl.js +3 -3
  335. package/dist/extensions/codemode/execute.js +3 -3
  336. package/dist/extensions/codemode/renderer.code.js +2 -2
  337. package/dist/extensions/codemode/renderer.impl.js +3 -3
  338. package/dist/extensions/codemode/renderer.js +3 -3
  339. package/dist/extensions/mcp/cli.code.js +3 -3
  340. package/dist/extensions/mcp/cli.impl.js +3 -3
  341. package/dist/extensions/mcp/cli.js +3 -3
  342. package/dist/extensions/mcp/cli.lazy.code.js +2 -2
  343. package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
  344. package/dist/extensions/mcp/cli.lazy.js +3 -3
  345. package/dist/extensions/mcp/runtime.code.js +1 -1
  346. package/dist/extensions/mcp/runtime.impl.js +3 -3
  347. package/dist/extensions/mcp/runtime.js +3 -3
  348. package/dist/index.d.ts +3 -1
  349. package/dist/index.js +8 -8
  350. package/dist/main-first-time-setup.code.js +2 -2
  351. package/dist/main-first-time-setup.impl.js +3 -3
  352. package/dist/main-first-time-setup.js +3 -3
  353. package/dist/main.js +1 -1
  354. package/dist/modes/interactive/components/stored-tree-view.code.js +3 -3
  355. package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
  356. package/dist/modes/interactive/components/stored-tree-view.js +3 -3
  357. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
  358. package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
  359. package/dist/modes/interactive/startup-shell-eligibility.js +1 -1
  360. package/dist/modes/interactive-engine/engine-prewarm.d.ts +1 -1
  361. package/dist/modes/print-mode.js +1 -1
  362. package/dist/package-manager-cli.code.js +7 -7
  363. package/dist/package-manager-cli.impl.js +3 -3
  364. package/dist/package-manager-cli.js +3 -3
  365. package/dist/rpc-entry.js +1 -1
  366. package/dist/startup-files.json +1 -1
  367. package/dist/startup-stages/10.js +1 -1
  368. package/dist/startup-stages/11.js +1 -1
  369. package/dist/startup-stages/12.js +1 -1
  370. package/dist/startup-stages/2.js +2 -3
  371. package/dist/startup-stages/3.js +1 -3
  372. package/dist/startup-stages/4.js +1 -2
  373. package/dist/startup-stages/5.js +1 -1
  374. package/dist/startup-stages/6.js +5 -7
  375. package/dist/startup-stages/7.js +3 -6
  376. package/dist/startup-stages/8.js +7 -2
  377. package/dist/startup-stages/9.js +1 -7
  378. package/dist/startup-stages/stages.json +1 -1
  379. package/dist/utils/compile-cache-deferral.js +8 -13
  380. package/dist/utils/compile-cache-deferral.js.map +1 -1
  381. package/dist/utils/compile-cache-warmup-host.js +3 -4
  382. package/dist/utils/compile-cache-warmup-host.js.map +1 -1
  383. package/dist/utils/compile-cache.js +12 -100
  384. package/dist/utils/compile-cache.js.map +1 -1
  385. package/dist/utils/startup-database-spare.code.js +3 -3
  386. package/dist/utils/startup-database-spare.impl.js +3 -3
  387. package/dist/utils/startup-database-spare.js +3 -3
  388. package/dist/utils/tools-manager.code.js +1 -1
  389. package/dist/utils/tools-manager.impl.js +3 -3
  390. package/dist/utils/tools-manager.js +3 -3
  391. package/dist/utils/worker-threads.js +2 -15
  392. package/dist/utils/worker-threads.js.map +1 -1
  393. package/docs/build.md +3 -3
  394. package/docs/changelog.mdx +1421 -69
  395. package/docs/compaction/reference.md +5 -5
  396. package/docs/compaction.md +7 -9
  397. package/docs/containerization.md +2 -2
  398. package/docs/custom-provider/api-reference.md +1 -1
  399. package/docs/docs.json +37 -10
  400. package/docs/environment-variables.md +0 -2
  401. package/docs/extensions/api-reference.md +4 -4
  402. package/docs/getting-started/installation.md +3 -0
  403. package/docs/guides/configuration.md +1 -1
  404. package/docs/guides/non-interactive.md +1 -1
  405. package/docs/guides/resume-on-any-machine.md +14 -22
  406. package/docs/guides/team-setup.md +56 -83
  407. package/docs/guides.md +2 -4
  408. package/docs/herdr.md +1 -1
  409. package/docs/index.md +1 -1
  410. package/docs/intercom/operations.md +26 -21
  411. package/docs/intercom/reference.md +2 -2
  412. package/docs/intercom.md +1 -1
  413. package/docs/libraries/storage-postgres.md +9 -9
  414. package/docs/libraries.md +2 -3
  415. package/docs/models-configuration.md +2 -2
  416. package/docs/models.md +2 -3
  417. package/docs/packages/authoring.md +7 -7
  418. package/docs/packages.md +1 -1
  419. package/docs/programmatic.md +2 -2
  420. package/docs/quickstart.md +1 -1
  421. package/docs/reference/cli.md +6 -11
  422. package/docs/reference.md +2 -2
  423. package/docs/rpc/extension-ui.md +2 -2
  424. package/docs/sdk/reference.md +5 -4
  425. package/docs/sdk/storage.md +8 -92
  426. package/docs/sdk/structured-decisions.md +1 -1
  427. package/docs/sdk/web-server.md +3 -3
  428. package/docs/sdk.md +14 -4
  429. package/docs/security.md +1 -1
  430. package/docs/session-format.md +5 -5
  431. package/docs/sessions.md +31 -42
  432. package/docs/settings.md +7 -8
  433. package/docs/storage/custom-adapters.md +255 -0
  434. package/docs/storage/jsonl.md +117 -0
  435. package/docs/{guides/postgres-pgbouncer.md → storage/postgres/pgbouncer.md} +73 -68
  436. package/docs/storage/postgres/tuning.md +337 -0
  437. package/docs/storage/postgres.md +556 -0
  438. package/docs/storage/sqlite.md +99 -0
  439. package/docs/storage.md +333 -956
  440. package/docs/subagents/authoring.md +1 -1
  441. package/docs/subagents.md +2 -2
  442. package/docs/tools.md +1 -1
  443. package/docs/worktree-snapshots.md +2 -2
  444. package/package.json +9 -9
  445. package/schemas/models.schema.json +2 -2
  446. package/schemas/settings.schema.json +0 -14
  447. package/dist/_shared/sdk-AVFII7NK.js.map +0 -1
  448. package/dist/_shared/settings-startup-4QCVCI53.js.map +0 -1
  449. package/dist/_shared/startup-0-0-57KF6LZH.js.map +0 -1
  450. package/dist/_shared/startup-0-1-GIY75K46.js.map +0 -1
  451. package/dist/_shared/startup-0-2-27OWFHV6.js.map +0 -1
  452. package/dist/_shared/startup-0-3-T4DVFYWX.js.map +0 -1
  453. package/dist/_shared/startup-8-1-X32CYSXB.js.map +0 -1
  454. package/dist/core/intercom-broker-control.d.ts +0 -129
  455. package/dist/startup-stages/13.js +0 -1
  456. package/docs/guides/postgres-tuning.md +0 -311
  457. package/docs/libraries/storage-libsql.md +0 -97
@@ -2,6 +2,7 @@ import type { SessionEntry } from "../../session-manager-types.ts";
2
2
  import { SqlSnapshotBlobStore } from "../../worktree-snapshot/blob-store.ts";
3
3
  import type { SqliteDatabase, SqliteExecutor } from "../database.js";
4
4
  import { type StorageDialect } from "../dialect.js";
5
+ import { type ForkDetachOptions, type ForkDetachReport } from "./fork-detach.js";
5
6
  import { SqlSessionSearchIndex } from "./session-search-index.js";
6
7
  import { type SqlSessionChatRecords } from "./sql-chat-records.js";
7
8
  import type { ChildDisplayLaunch, ForkArchiveSource, OversizedSessionEntry, SessionBlob, SessionBranchPageCut, SessionCompactionPoint, SessionCwdMatcher, SessionEntriesPage, SessionEntriesQuery, SessionEntryRange, SessionEntrySizes, SessionForkSeed, SessionForkStream, SessionListQuery, SessionOpenMarker, SessionOpenMarkerAge, SessionOpenMarkerStore, SessionRecordHeader, SessionResume, SessionScanOptions, SessionScanPage, SessionSnapshot, SessionSnapshotCut, SessionStore, SessionStoredEntry, SessionSummary, SessionTail, SessionTaskReferenceDuplicatePage, SessionTaskReferenceDuplicateQuery, SessionTreeOutlineEntry, SessionWriteOptions, SessionWriteResult, StorageDescriptor } from "./types.js";
@@ -10,12 +11,30 @@ import type { ChildDisplayLaunch, ForkArchiveSource, OversizedSessionEntry, Sess
10
11
  * that knows only version 1 would read as stubs. A database stays at version 1, which older builds still open, until
11
12
  * this build writes its first chunked entry: that transaction moves the sessions meta to 2, and older builds refuse it
12
13
  * when next opened with `StorageSchemaVersionError`. Builds before 2 check only the meta row, on SQLite and Postgres alike.
14
+ * Version 3 turns on forks that share their parent's history ({@link SESSION_SCHEMA_VERSION_SHARED_HISTORY}).
13
15
  */
14
- export declare const SESSION_SCHEMA_VERSION = 2;
16
+ export declare const SESSION_SCHEMA_VERSION = 3;
17
+ /** The sessions schema the first chunked entry raises a version 1 database to, which builds since #4954 read. */
18
+ export declare const SESSION_SCHEMA_VERSION_CHUNKED = 2;
19
+ /**
20
+ * The sessions schema in which a fork shares its parent's history instead of copying it (#6560). A new database's
21
+ * sessions schema starts at it; a store's open, or `atomic storage migrate`, raises an older one to it by itself once
22
+ * no session of an older build runs there (`SqlSessionStore.enableSharedHistoryForks`); a fork or any other write never
23
+ * does. Builds that know only versions 1
24
+ * and 2 refuse it, at their open and in every transaction, rather than read a fork's own rows as its whole history.
25
+ * `SqlSessionStore.sharedHistoryForks(tx)` tells a transaction whether its database is there.
26
+ */
27
+ export declare const SESSION_SCHEMA_VERSION_SHARED_HISTORY = 3;
15
28
  /** The schema domain of the session tables in the prefix's migration ledger. */
16
29
  export declare const SESSION_DOMAIN = "sessions";
17
30
  /** The ledger step, `schema:session-fillfactor`, that sets the sessions table's fillfactor on PostgreSQL (#6560). */
18
31
  export declare const SESSION_FILLFACTOR_DOMAIN = "session-fillfactor";
32
+ /**
33
+ * The ledger step, `schema:session-append-function`, that creates the session append function on PostgreSQL (#6599).
34
+ * Raise its revision whenever the function's body changes: `atomic storage migrate` of an older build then leaves the
35
+ * newer body in place.
36
+ */
37
+ export declare const SESSION_APPEND_FUNCTION_DOMAIN = "session-append-function";
19
38
  /**
20
39
  * The most bytes of a chunked session blob one row holds. New blobs use a header row and rows of at most this size,
21
40
  * so their bound and returned values stay within it: libSQL servers cap a row and a bound value (sqld's default is
@@ -85,11 +104,28 @@ export declare class SqlSessionStore implements SessionStore {
85
104
  private chatStore?;
86
105
  /** The database's reader handle, once a read opened it: see `readerDatabase`. */
87
106
  private reader?;
88
- /**
89
- * Absent on a local libSQL file, which then behaves as before: @libsql/client waits for another process's write
90
- * lock on the calling thread, even to begin a transaction, so a side write would stop the event loop where an
91
- * ordinary turn-ending notice writes nothing (#5682).
92
- */
107
+ /** Each session's writes this store started and has not finished, each settled as its write is: see `writing`. */
108
+ private readonly unfinishedWrites;
109
+ /** The sessions schema version each transaction read first, by its handle: see `sharedHistoryForks`. */
110
+ private readonly schemaVersions;
111
+ /** The fork tables under this store's prefix, which exist once its sessions schema is version 3 (#6560). */
112
+ private readonly forkTables;
113
+ /** See {@link forkLinks}. */
114
+ private forkLinkStatements?;
115
+ /** See {@link entryLinks}. */
116
+ private entryLinkStatements?;
117
+ /**
118
+ * Whether a read of this store found its sessions schema at {@link SESSION_SCHEMA_VERSION_SHARED_HISTORY}: one way,
119
+ * as the switch is. A read outside a transaction reads sessions through their views once it is set, and before that
120
+ * reads the tables themselves on the condition, checked in the read's own snapshot, that the schema is older.
121
+ */
122
+ private sharedHistorySeen;
123
+ /** For each transaction, whether each session whose row it read has fork segments, as that read found (#6560). */
124
+ private readonly forkedIn;
125
+ /** Whether each recently read session had fork segments: only a first guess, which a read checks (#6560). */
126
+ private readonly forkedSessions;
127
+ /** The sessions each recently forked session's segments named when this store last read them (#6560). */
128
+ private readonly forkSources;
93
129
  get chatRecords(): SqlSessionChatRecords | undefined;
94
130
  private readonly entryByteLength;
95
131
  private chunkRowids?;
@@ -106,6 +142,13 @@ export declare class SqlSessionStore implements SessionStore {
106
142
  private readonly forkStagingTable;
107
143
  /** The generation each recently read session's row held at a revision: see `generation`. */
108
144
  private readonly generations;
145
+ /**
146
+ * The session append function of this store's tables, when the open found it and this role may run it (#6599):
147
+ * `atomic storage migrate` creates it. Absent elsewhere, where appends take their two round trips as before.
148
+ */
149
+ private readonly appendFunction?;
150
+ /** The row each recent write of this store left for its session, which an append through the function plans from. */
151
+ private readonly writtenRows;
109
152
  private constructor();
110
153
  /** Bind an existing transcript for the storage search command. No schema setup, markers or search index. */
111
154
  static openTranscriptReader(database: SqliteDatabase & {
@@ -146,10 +189,19 @@ export declare class SqlSessionStore implements SessionStore {
146
189
  */
147
190
  private sessionWrite;
148
191
  /**
149
- * `transaction` for a body that only reads, in one read-only snapshot, on the database's reader handle when it
150
- * offers one: its reads then wait for neither the writes queued on this store's connection nor their locks.
192
+ * `transaction` for a body that only reads session `sessionId`, in one read-only snapshot, on the database's reader
193
+ * handle when it offers one: its reads then wait for neither the writes queued on this store's connection nor their
194
+ * locks. It first waits for the writes of that session this store started and has not finished (`writing`), so a
195
+ * caller that starts a write and then reads, without awaiting the write, reads it as the store's own connection would
196
+ * have; with none unfinished it waits for nothing.
151
197
  */
152
198
  private readTransaction;
199
+ /**
200
+ * `write`, a write of session `sessionId` this store has just started, kept in `unfinishedWrites` until it settles,
201
+ * for the reads of the session that start meanwhile to wait for (`readTransaction`). No write waits for a read, and
202
+ * no write of this store reads through `readTransaction`, so the wait never comes back to the write.
203
+ */
204
+ private writing;
153
205
  /**
154
206
  * The database's reader handle, opened at the first read and closed with the store; the database without one. A
155
207
  * reader that cannot open, such as when its file can no longer be opened anew, leaves the read on the store's own
@@ -166,12 +218,130 @@ export declare class SqlSessionStore implements SessionStore {
166
218
  private transactionCheckedAlongside;
167
219
  /** The read that checks the sessions schema version, which every transaction of this store makes first. */
168
220
  private schemaCheck;
221
+ /**
222
+ * Reads the sessions schema version through `executor` and refuses one this build does not read. The answer is kept
223
+ * for `executor`, a transaction's own handle, so {@link sharedHistoryForks} costs that transaction no read.
224
+ */
169
225
  private assertReadableSchema;
226
+ /**
227
+ * Whether the database `tx` runs in has forks that share their parent's history turned on: its sessions schema, as
228
+ * `tx` read it, is {@link SESSION_SCHEMA_VERSION_SHARED_HISTORY} (#6560). Every transaction of this store reads the
229
+ * version first, so this costs no further read there; `tx` of any other transaction reads it once. Asked again in each
230
+ * transaction, never kept on the store: another process may turn the forks on at any time, and the switch is one way,
231
+ * so an answer read before it only means a fork is copied.
232
+ */
233
+ sharedHistoryForks(tx: SqliteExecutor): Promise<boolean>;
234
+ /** Notes a sessions schema version a read of this store found: see {@link sharedHistorySeen}. */
235
+ private noteSchemaVersion;
236
+ /** How transaction `tx` reads a session's rows: through its view where its database has shared history (#6560). */
237
+ private viewTables;
238
+ /**
239
+ * A column, `forked`, of a read of a sessions row whose id is `id`: 1 when the session has fork segments (#6560),
240
+ * found by the segments' key. Only where `segments`, the fork segments table, exists.
241
+ */
242
+ private forkedColumn;
243
+ /**
244
+ * Notes what a read of session `sessionId`'s row in transaction `tx` found, `forked` from {@link forkedColumn}: the
245
+ * transaction's later reads of a session without segments read its tables directly. The store remembers it too, as a
246
+ * first guess for a read that sends its statements before that row's answer, and checks it against that answer.
247
+ */
248
+ private noteForked;
249
+ /**
250
+ * How a read outside a transaction reads a session's rows: through its view once this store has seen shared history,
251
+ * and otherwise from the tables themselves, but only while the schema, read in the same statement, is older. Such a
252
+ * read that finds nothing asks `outsideTransaction` to try again.
253
+ */
254
+ private outsideViewTables;
255
+ /**
256
+ * `read`, a read outside a transaction of a session's rows through `outsideViewTables`, once more through the views
257
+ * when it found nothing (`found` says) before this store had seen shared history, and the schema, read after it, is
258
+ * now at version 3: the read's own check then held its rows back. The switch is one way, so a schema older than 3
259
+ * read after the read was older at the read too, and its answer stands.
260
+ */
261
+ private outsideTransaction;
262
+ /**
263
+ * `read`, a read outside a transaction of session `sessionId`'s rows that also reads, as `forked`, whether the
264
+ * session has fork segments, through `outsideTransaction` (#6560): from the tables themselves when this store last
265
+ * found the session without segments, and through its view again when the read's own answer says it now has them.
266
+ */
267
+ private outsideSessionRead;
268
+ /** The `forked` column of a read outside a transaction of the sessions row `id` names: see `outsideSessionRead`. */
269
+ private outsideForkedColumn;
270
+ /**
271
+ * After a read outside a transaction found nothing: reads the sessions schema, refuses one this build does not read,
272
+ * and tells whether shared history is on now where the read, made with `seen` as it was, read the tables themselves.
273
+ */
274
+ private schemaNowShared;
275
+ /**
276
+ * Turns on forks that share their parent's history (#6560), as a store's open does by itself: see
277
+ * {@link SqlSessionStore.switchSharedHistory}. `live` judges whether the process of an older build's open-session
278
+ * marker still runs; the application's judge by default.
279
+ */
280
+ enableSharedHistoryForks(options?: {
281
+ readonly live?: (marker: SessionOpenMarkerBuild) => Promise<boolean>;
282
+ }): Promise<SharedHistoryForksOutcome>;
283
+ /**
284
+ * The switch to shared-history forks (#6560), in one transaction: creates the fork tables, records version 3 in the
285
+ * migration ledger where there is one, and raises the sessions schema to it, so that builds which do not read it
286
+ * refuse the database at their next open or transaction. One way: nothing lowers it again.
287
+ *
288
+ * It never leaves an older process reading what it cannot read: while `live` judges any open-session marker of an
289
+ * older build to be a running process, it changes nothing and is `deferred`, and the next open tries again. The
290
+ * transaction is the only writer of the whole database while it runs, so every session write either finished before
291
+ * it, or starts after it and reads the new version first. Two hosts switching at once run one after the other, and
292
+ * the second finds it `already` done.
293
+ */
294
+ private static switchSharedHistory;
295
+ /**
296
+ * An open's switch to shared-history forks, true when it switched the database. With `precheck`, for an open that
297
+ * read the schema without a lock, it first reads, still without one, the version and the markers of older builds
298
+ * together, so an open that must leave the switch for later, while an older build runs a session, takes no lock and
299
+ * writes nothing; an open that set the schema up under the write lock goes straight to the switch. A switch that cannot run, such as for a role without the
300
+ * privilege to create tables, is left for a later open or `atomic storage migrate`; forks copy meanwhile. Either way
301
+ * the open goes on, and only the debug log notes it.
302
+ */
303
+ private static switchAtOpen;
170
304
  get descriptor(): StorageDescriptor;
171
305
  create(header: SessionRecordHeader, entries: readonly SessionEntry[]): Promise<SessionWriteResult>;
306
+ private writeCreate;
307
+ /**
308
+ * The read that begins a transaction writing a new session `id`, by `create` or by a fork: whether it exists and, where
309
+ * this store has seen shared history, whether a deleted session with this ID left rows forks still read, in the same
310
+ * statement.
311
+ */
312
+ private newSessionRead;
313
+ /**
314
+ * In the transaction that writes a new session `id`, before its writes, given what {@link newSessionRead} found:
315
+ * refuses a session that exists. Where a deleted session with this ID left rows forks still read, those forks get
316
+ * their own copies first and the rows go, so the new session starts empty and their sweep never takes its rows. A
317
+ * fork whose copy a missing source chunk refuses keeps the old rows, and the new session is refused with it.
318
+ */
319
+ private startNewSession;
320
+ /**
321
+ * {@link startNewSession} for a fork with shared history, once it has read its donor: resolves with the donor. A donor
322
+ * that read the rows a deleted session with the child's ID left holds its own copy of them now, in segments of its
323
+ * own, and is read again (#6560).
324
+ */
325
+ private startSharedFork;
172
326
  createFork(header: SessionRecordHeader, entries: SessionForkSeed, source: ForkArchiveSource): Promise<(SessionWriteResult & {
173
327
  remainingBlobs?: readonly string[];
174
328
  }) | undefined>;
329
+ private writeCreateFork;
330
+ /**
331
+ * A fork from the entries a caller holds. Where the database has shared history (#6560) and the source is still in
332
+ * the generation the fork read it in, every entry the store read from the source and the caller kept unchanged, and
333
+ * every receipt, is named by the child's segments, not stored again: the child stores only the entries it changed or
334
+ * added, and their blobs. Otherwise the entries are stored as `create` stores them, receipts as the source stores
335
+ * them. Undefined, with nothing written, for entries with neither receipts nor blobs that share nothing: `create`
336
+ * then stores them, needing nothing of the source, so a source that changed or went away meanwhile does not fail it.
337
+ */
338
+ private writeEntriesFork;
339
+ /**
340
+ * The statements of a fork from `entries` with shared history (#6560), in seq order, after its session row: the
341
+ * segments that name the rows `places` puts in the source, each entry it does not as {@link entryForkWrites} stores it,
342
+ * the search texts of those, and the lineage row. Throws, before the last of them, unless the segments are well formed.
343
+ */
344
+ private sharedEntriesForkWrites;
175
345
  /**
176
346
  * The source session's head, its row locked for share, once the child is known to be new: both reads go out together,
177
347
  * one round trip (#6560). Fails as the source changed when it is no longer the generation the fork read.
@@ -179,10 +349,14 @@ export declare class SqlSessionStore implements SessionStore {
179
349
  private forkDonor;
180
350
  /**
181
351
  * The statements that store a fork's `entries`, in seq order: an entry with a receipt as the source stores it, its row
182
- * and chunks copied in two statements whatever their size, and any other as `create` stores it. A receipt's row that
183
- * names another entry fails the fork: the source changed under it.
352
+ * and chunks copied in two statements whatever their size, and a run of others as `create` stores them, several rows
353
+ * a statement. A receipt's row that names another entry fails the fork: the source changed under it. With `places`
354
+ * and `runs`, an entry `places` puts in the source is named by `runs`' segments instead, and the segments before an
355
+ * entry the child stores go first, for the snapshot index's triggers.
184
356
  */
185
357
  private receiptForkWrites;
358
+ /** The statements of {@link receiptForkWrites} that store `entry`, at index `index` of the fork's entries. */
359
+ private entryForkWrites;
186
360
  /**
187
361
  * The blob copy of a fork from session `source` of this store's tables (#6560), or undefined when a subclass stores
188
362
  * blobs its own way: `createForkArchive` then copies every one through it.
@@ -209,6 +383,7 @@ export declare class SqlSessionStore implements SessionStore {
209
383
  createStagedFork(header: SessionRecordHeader, stream: SessionForkStream, source: ForkArchiveSource): Promise<SessionWriteResult & {
210
384
  readonly remainingBlobs: readonly string[];
211
385
  }>;
386
+ private writeCreateStagedFork;
212
387
  /**
213
388
  * Creates the fork staging table unless it exists, as `atomic storage migrate` does as the owner role (#5594): a
214
389
  * runtime role without DDL privileges then stages bounded clones too. Opens never create it.
@@ -220,6 +395,27 @@ export declare class SqlSessionStore implements SessionStore {
220
395
  * chat record does where `migrate` has not run.
221
396
  */
222
397
  prepareChatRecords(): Promise<void>;
398
+ /** Whether a deleted session with ID `sessionId` left rows forks still read. */
399
+ private hasForkTombstone;
400
+ /** This store's side of detaching and pinning shared fork history: see fork-detach-host.ts. */
401
+ private forkHost;
402
+ /** The statements that link the entries a session with fork segments stores, as a copy links them (#6560). */
403
+ private forkLinks;
404
+ /** How the snapshot index links a materialization's copies and a fork moved onto another copy (#6560). */
405
+ private entryLinks;
406
+ /**
407
+ * @internal Gives every fork that shares history with `sessionId` its own copy of what it reads, so the session's
408
+ * rows no longer stay for them; see fork-detach.ts. Detaches a crash stopped are finished first. Nothing to do where
409
+ * shared-history forks are off.
410
+ */
411
+ detachForks(sessionId: string, options?: ForkDetachOptions): Promise<ForkDetachReport>;
412
+ /** @internal Finishes every detach a crash stopped. Nothing to do where shared-history forks are off. */
413
+ resumeForkDetaches(): Promise<ForkDetachReport>;
414
+ /**
415
+ * @internal Removes the rows of deleted sessions that no fork reads any more, a batch per transaction: `sessionIds`,
416
+ * and a few any earlier sweep left. Resolves with the sessions whose rows went.
417
+ */
418
+ sweepForkTombstones(sessionIds?: readonly string[], batchEntries?: number): Promise<string[]>;
223
419
  private forkStagingTarget;
224
420
  /**
225
421
  * The stored chunk row `index` of the entry `reference` names, whole, in its generation; undefined when the entry is
@@ -241,7 +437,44 @@ export declare class SqlSessionStore implements SessionStore {
241
437
  * cut; with `legacyBytes` 0, only its header. Nothing is converted or written.
242
438
  */
243
439
  private readBlobPart;
440
+ /**
441
+ * A fork from a stream of the source's rows. Where the database has shared history (#6560), the child stores no copy
442
+ * of the rows the source stores unchanged: its segments name them, and it stores only the rows the stream changed or
443
+ * added. A stream of the source's whole history, as it stands, reads no row at all.
444
+ */
244
445
  private createStreamedFork;
446
+ private writeStreamedFork;
447
+ /**
448
+ * The donor `reads` read, when the fork made them, asked for at once: its reads then go out beside the schema check,
449
+ * in one wait for the connection, as a `create`'s first read does. The fork uses it only once the schema it checks in
450
+ * this transaction has shared history: a store that saw shared history may meet a database whose schema says
451
+ * otherwise, and a fork there never names its source's rows. Unused, its failure is nobody's.
452
+ */
453
+ private leadingForkDonor;
454
+ /** Notes the sessions session `id`'s segments name, which a fork of it locks. */
455
+ private noteForkSources;
456
+ /** The fork tables of this store's database, which exist once it has shared history (#6560). */
457
+ private lineageTables;
458
+ /**
459
+ * The reads that begin a fork of session `donor` into `child` with shared history (#6560), in order: whether the child
460
+ * exists; the tombstones of the deleted sessions among the donor's sources, locked `key-share`; the rows of the donor
461
+ * and of the sessions its segments name, as the statement starts or as this store last saw them, each locked
462
+ * `key-share` in id order, unless the child exists, with the donor's watermark and generation, and with `withState`
463
+ * its summary state; then the donor's segments, read once those locks are held.
464
+ */
465
+ private sharedForkReads;
466
+ /**
467
+ * The donor of a fork with shared history (#6560), from `reads`: its watermark, as the locking read found it, is the
468
+ * fork's cut-off. Throws `ForkSourcesMoved`, for the fork to run again, when the donor's segments name a session the
469
+ * reads did not lock: the donor's segments changed since this store last forked it.
470
+ */
471
+ private sharedForkDonor;
472
+ /**
473
+ * A fork with shared history of the donor's whole view as it stands (#6560): its segments, its lineage and its
474
+ * session row, whose summary is the donor's in a generation of its own, and no row of any entry. Undefined, for
475
+ * the fork to read the donor's rows, when the donor's resume index does not cover its watermark.
476
+ */
477
+ private writeSharedPrefixFork;
245
478
  /**
246
479
  * `readEntryChunk` for a fork's reader bound to transaction `tx`, reading session `source` in generation `epoch`: a
247
480
  * read of an entry fetches a whole stored chunk row, or a part as large of an entry stored whole, and answers the next
@@ -255,12 +488,60 @@ export declare class SqlSessionStore implements SessionStore {
255
488
  append(sessionId: string, entries: readonly SessionEntry[], options: SessionWriteOptions): Promise<{
256
489
  readonly lastSeq: number;
257
490
  }>;
491
+ private writeAppend;
492
+ /**
493
+ * Remembers `row`, the session's row a committed write of this store left, for the next append to plan from, where
494
+ * appends go through the append function; forgets the session's row when `row` is undefined. At most
495
+ * {@link WRITTEN_ROWS} sessions are remembered, the latest written.
496
+ */
497
+ private rememberWritten;
498
+ /**
499
+ * Appends `entries` in one round trip through the session append function, planned from the row this store's last
500
+ * write of the session left (#6599). The function takes the session's locks as a session write transaction does,
501
+ * checks the schema version, the session and its expected seq as `forWrite` does, writes nothing unless the stored
502
+ * row is still the one planned from, checks the snapshot blobs as `assertStored` does, and writes the row, the
503
+ * entries and their search texts in the order an append's transaction does. Undefined, having written nothing, when
504
+ * the append is not one it plans (no function, no remembered row, a row other than the stored one, invalid entries,
505
+ * a chunked entry or more than one batch of writes, an entry that refers back past the resume window): the caller
506
+ * then appends in a transaction as before, which reads the row itself and reports what fails.
507
+ */
508
+ private appendThroughFunction;
509
+ /**
510
+ * The session append function of the store's tables, `<prefix>session_append_v1`: one statement, and so one round
511
+ * trip, for what an append's transaction does with its two (#6599). Created by `atomic storage migrate` through
512
+ * {@link prepareAppendFunction}. It runs with the caller's rights, so it lets a role do nothing its table
513
+ * privileges do not, and in the caller's `search_path`, the schema a transaction of the store sets. It writes no
514
+ * chunked entry: an append that has one goes through a transaction. Its answer is one row: `appended`, or why it
515
+ * wrote nothing, with the stored version (`version`), the stored last seq (`conflict`), the first blob that is not
516
+ * stored (`blob`), no session (`missing`), or a stored row other than the one the caller planned from (`stale`).
517
+ */
518
+ private appendFunctionSql;
519
+ /**
520
+ * Creates the session append function (#6599), once per revision, as the ledger records it, and lets every role that
521
+ * may insert into the sessions table execute it: `atomic storage migrate` runs this as the owner role, and a
522
+ * runtime role appends through the function from its next open on. PostgreSQL only; does nothing elsewhere.
523
+ */
524
+ prepareAppendFunction(): Promise<void>;
258
525
  replace(sessionId: string, header: SessionRecordHeader, entries: readonly SessionEntry[], options: SessionWriteOptions): Promise<SessionWriteResult>;
526
+ private writeReplace;
259
527
  updateHeader(header: SessionRecordHeader, options: SessionWriteOptions): Promise<SessionWriteResult>;
528
+ private writeUpdateHeader;
260
529
  load(sessionId: string): Promise<SessionSnapshot>;
261
530
  readEntryRange(sessionId: string, query: SessionEntriesQuery): Promise<SessionEntriesPage>;
262
531
  readHeader(sessionId: string): Promise<SessionRecordHeader | undefined>;
263
532
  delete(sessionId: string): Promise<void>;
533
+ private writeDelete;
534
+ /**
535
+ * The fork history of `sessionId` where the transaction `tx` runs on shared history: through `reads`, the transaction's
536
+ * leading reads, or, for a store that had not seen shared history when the transaction began, read now.
537
+ */
538
+ private readForkPinsWithin;
539
+ /**
540
+ * Removes the rows of deleted sessions no fork reads any more, among `released` and any an earlier sweep left, in
541
+ * transactions of their own after the write that released them committed. A sweep that fails leaves tombstones the
542
+ * next one finishes: the write it follows stands either way.
543
+ */
544
+ private sweepReleasedForkRows;
264
545
  /**
265
546
  * Stores the blob as rows of at most {@link SESSION_BLOB_CHUNK_BYTES}, then publishes its header. Every statement
266
547
  * commits by itself and writes only while the session exists, so no transaction stays open across round trips and
@@ -275,6 +556,18 @@ export declare class SqlSessionStore implements SessionStore {
275
556
  * Rows never change once written. A session deleted meanwhile holds nothing; missing bytes are `blob-incomplete`.
276
557
  */
277
558
  getBlob(sessionId: string, hash: string): Promise<Uint8Array | undefined>;
559
+ /**
560
+ * Where session `sessionId`'s blob `hash` is stored, with its header: its own, or the first of its fork sources' by
561
+ * id, through the segments of a fork that shares its parent's history (#6560). Read outside a transaction.
562
+ */
563
+ private blobOwner;
564
+ /**
565
+ * The sessions whose blobs a session reads (#6560), as a derived table of `owner` and `place`: the session itself,
566
+ * place 0, and, with shared history, the sources its segments name, place 1. A blob is then looked up by its key in
567
+ * each, never by a scan of the blobs of every session. Its parameters are {@link blobPlaceParams}.
568
+ */
569
+ private blobPlaces;
570
+ private blobPlaceParams;
278
571
  private blobHeader;
279
572
  /**
280
573
  * Lists from a per-scope cache revalidated on every call. A cheap change token, which moves on any commit
@@ -319,7 +612,10 @@ export declare class SqlSessionStore implements SessionStore {
319
612
  * it read in pages of its own and joined here rather than by the database, whose string limit it may pass (#4954).
320
613
  */
321
614
  private readSummaries;
322
- /** A session's search texts as one JSON array, read in pages of at most {@link SESSION_READ_PAGE_CHARS}. */
615
+ /**
616
+ * A session's search texts as one JSON array, read in pages of at most {@link SESSION_READ_PAGE_CHARS}, through its
617
+ * view (#6560). Only a session with some text is read this way, so a read that finds none was held back.
618
+ */
323
619
  private readSearchTexts;
324
620
  /**
325
621
  * Keeps only summaries some cached scope still lists, so memory follows the live sessions. Runs in a
@@ -329,6 +625,11 @@ export declare class SqlSessionStore implements SessionStore {
329
625
  private assertOpen;
330
626
  private assertListing;
331
627
  private read;
628
+ /**
629
+ * The entries of session `sessionId` from `from` through `through`, in pages, through its view (#6560): only those
630
+ * whose seq `seqs` lists, when it is given, which then lies in that range. With `epoch`, the session's generation in
631
+ * the snapshot of `tx`, each entry is noted as stored at its seq in it, for a fork of the session to share its row.
632
+ */
332
633
  private readRows;
333
634
  private readSeqs;
334
635
  /**
@@ -336,6 +637,11 @@ export declare class SqlSessionStore implements SessionStore {
336
637
  * a leading read, so a pipelined connection sends it with the transaction's start (#6560).
337
638
  */
338
639
  private resumeRow;
640
+ /**
641
+ * The view (#6560), as `name`, of session `sessionId`'s entries after seq `after` and through seq `through`, with
642
+ * `entry_id`, `entry_json` and `chunks`, and where each is stored.
643
+ */
644
+ private entriesView;
339
645
  private resumeSource;
340
646
  /**
341
647
  * Runs `read`, a read transaction that finds the session's index with `resumeSource`, at once; only when that index is
@@ -347,6 +653,11 @@ export declare class SqlSessionStore implements SessionStore {
347
653
  private prepareResume;
348
654
  readTail(sessionId: string, fromSeq: number): Promise<SessionTail>;
349
655
  readRange(sessionId: string, startSeq: number, endSeq: number, expectedEpoch?: string): Promise<SessionEntryRange>;
656
+ /**
657
+ * The session's watermark and generation; with `segments`, the fork segments table of a database with shared
658
+ * history, also whether the session has segments (#6560), in the same statement: a read that leaves a session without
659
+ * them to its tables' own keyed lookups costs no read of its own to learn it.
660
+ */
350
661
  private historyHead;
351
662
  /** Size at most one page and return only fitting bodies, in the same snapshot as the header. The first
352
663
  * oversized row is a chunk reference; its full inline value never crosses the driver boundary. */
@@ -401,7 +712,7 @@ export declare class SqlSessionStore implements SessionStore {
401
712
  readScanPage(sessionId: string, startSeq: number, endSeq: number, epoch: string | undefined, limit: number, options?: SessionScanOptions): Promise<SessionScanPage>;
402
713
  /**
403
714
  * A condition on an entries row that holds for every entry `select` selects (and more): an entry larger than a page;
404
- * on SQLite and libSQL, a message whose stored type and role say it is a tool result, or an assistant message with a
715
+ * on SQLite, a message whose stored type and role say it is a tool result, or an assistant message with a
405
716
  * tool call named other than `exceptCalls`, and any row that is not valid JSON; on Postgres, which would parse each
406
717
  * row's JSON to read those, any row whose JSON holds a tool call block's `"toolCall"` or a result's `"toolResult"`,
407
718
  * which `JSON.stringify`, the only writer of a row, always writes as such (it never escapes a letter).
@@ -440,44 +751,97 @@ export declare class SqlSessionStore implements SessionStore {
440
751
  /** The resume of `index`, the session's index as of the snapshot of `tx`, with `header`. */
441
752
  private resumeIn;
442
753
  findLatestCompaction(sessionId: string, leafId?: string): Promise<SessionCompactionPoint | undefined>;
754
+ /** The ID of the entry at view seq `seq` of session `sessionId`, read in transaction `tx` (#6560). */
755
+ private entryIdAt;
443
756
  /** The JSON of a long entry, from its chunks, one statement each. */
444
757
  private readEntryChunks;
758
+ /**
759
+ * The read of chunk `index` of the entry at view seq `seq` of session `sessionId` (#6560), found through the view in
760
+ * the statement itself, on the condition `condition` with `params` when given.
761
+ */
762
+ private entryChunkRead;
763
+ /**
764
+ * The chunks of the entry at view seq `seq`: in transaction `tx` with `tables`, or, with `tables` undefined, each
765
+ * read outside a transaction through `outsideTransaction`.
766
+ */
445
767
  private readRawEntryChunks;
446
768
  private entryChunks;
769
+ /** The JSON bytes of the entry stored whole at view seq `seq`, read outside a transaction. */
447
770
  private readInlineEntryBytes;
448
771
  private forWrite;
449
- /** The read of the session's row that `forWrite` checks a write against. */
772
+ /**
773
+ * The read of the session's row that `forWrite` checks a write against; with `forked`, once this store has seen
774
+ * shared history, it also reads whether the session has fork segments (#6560).
775
+ */
450
776
  private headRead;
777
+ /** Whether session `sessionId` has fork segments, read in `tx`, whose database has shared history (#6560). */
778
+ private hasForkSegments;
451
779
  private appendedResume;
780
+ /**
781
+ * The latest seq of session `sessionId` that holds entry `entryId`, through its view (#6560): in transaction
782
+ * `executor` with `tables`, or, with `tables` undefined, outside a transaction through `outsideTransaction`. A fork's
783
+ * inherited entries are linked under the sessions that store them, at their seqs there, which the view renumbers.
784
+ */
452
785
  private seqOfEntry;
453
786
  private saveSummary;
454
787
  /** The statement that saves the session's row as `saveSummary` saves it, with what `saveSummary` returns. */
455
788
  private summaryWrite;
456
789
  private insertEntries;
790
+ /**
791
+ * Notes `written`, the entries a committed write of session `sessionId` stored in generation `epoch`, as stored there
792
+ * (#6560): a manager keeps the very objects it appended, so a fork of it shares their rows without reading them back.
793
+ * Only where this store has seen shared history, for which alone the notes count.
794
+ */
795
+ private noteWritten;
457
796
  /**
458
797
  * A fork's version step, once every entry of the child is in, as the transaction's last write: the same row order as
459
798
  * an append, which takes the snapshot index's progress rows with its entries inserts and the schema row after them,
460
799
  * so the two never deadlock (#6560). The body makes no call after it.
461
800
  */
462
801
  private finishFork;
802
+ /** The statement of {@link finishFork}. */
803
+ private forkVersionStep;
463
804
  /**
464
805
  * The statements that store `entries` after `lastSeq`, in order, each entry encoded only when its statements are
465
- * taken: each entry's row and its chunks, the version step a first chunked entry takes unless `versionStep` is
466
- * false (a fork takes it once its last entry is in), then the entries' search texts.
806
+ * taken: the entries' rows, several to a statement (see {@link rowInserts}), each chunked entry's own row and its
807
+ * chunks in their place among them, the version step a first chunked entry takes unless `versionStep` is false (a
808
+ * fork takes it once its last entry is in), then the entries' search texts. With `written`, each entry is added to it
809
+ * with its seq and its JSON as it is encoded, for {@link noteWritten} once the write commits.
467
810
  */
468
811
  private entryWrites;
469
812
  /**
470
- * Runs the session row's statement, then `entries`' statements, in order. A write of up to
471
- * {@link STATEMENT_BATCH_BYTES}, as an ordinary message is, goes to a connection thread as one batch that waits for
472
- * it once. A larger one runs its statements one at a time as they are made, as before, so it never holds more than
473
- * about that much of them, or sends it, at once.
813
+ * Runs the session row's statement, then `entries`' statements, in order, as the transaction's last calls: the body
814
+ * makes none after them. A write of up to {@link STATEMENT_BATCH_BYTES}, as an ordinary message is, goes with the
815
+ * commit where the connection is pipelined, or to a connection thread as one batch that waits for it once, or a
816
+ * request's worth at a time when it has more statements than one takes. A larger one is sent as it is made, without
817
+ * waiting for each statement's answer, so it never holds more than about that much of them, or sends it, at once.
474
818
  */
475
- /** Writes the session's row and its entries as the transaction's last calls: the body makes none after them. */
476
819
  private writeEntries;
477
820
  private encode;
478
821
  }
822
+ /** A marker of a running session, with the sessions schema and the Atomic version its process recorded. */
823
+ export interface SessionOpenMarkerBuild extends SessionOpenMarkerAge {
824
+ readonly sessionId: string;
825
+ /** The newest sessions schema its process reads; undefined for builds before #5065, which record none. */
826
+ readonly schemaVersion?: number;
827
+ /** Its process's Atomic version; undefined for builds before #6560, which record none. */
828
+ readonly build?: string;
829
+ }
830
+ /**
831
+ * What the switch to shared-history forks did: `enabled`, it raised the sessions schema; `already`, the schema was
832
+ * there; `deferred`, `holders`, running processes of older builds, still have sessions open, and nothing changed.
833
+ */
834
+ export type SharedHistoryForksOutcome = {
835
+ readonly status: "enabled";
836
+ } | {
837
+ readonly status: "already";
838
+ } | {
839
+ readonly status: "deferred";
840
+ readonly holders: readonly SessionOpenMarkerBuild[];
841
+ };
479
842
  /** The running sessions that have a SQL store's sessions open, in a table every host sharing the store reads (#4971). */
480
843
  declare class SqlSessionOpenMarkers implements SessionOpenMarkerStore {
844
+ /** A new table already has the columns the later steps add, so on a new database they find them and alter nothing. */
481
845
  static createTable(tx: SqliteExecutor, dialect: StorageDialect, table: string): Promise<void>;
482
846
  /**
483
847
  * Each marker records the sessions schema version its process reads, so a build that upgrades the schema can tell
@@ -485,11 +849,21 @@ declare class SqlSessionOpenMarkers implements SessionOpenMarkerStore {
485
849
  * builds before it. Additive, as every step of this domain must be.
486
850
  */
487
851
  static addSchemaVersion(tx: SqliteExecutor, dialect: StorageDialect, table: string): Promise<void>;
852
+ /**
853
+ * Each marker records the Atomic version of its process, so a command refused while older processes run names the
854
+ * version each must be upgraded from (#6560). Null for markers of builds before it. Additive.
855
+ */
856
+ static addBuild(tx: SqliteExecutor, dialect: StorageDialect, table: string): Promise<void>;
488
857
  private readonly database;
489
858
  private readonly table;
490
859
  private readonly assertOpen;
491
860
  constructor(database: SqliteDatabase, table: string, assertOpen: () => void);
492
861
  put(sessionId: string, marker: SessionOpenMarker): Promise<void>;
862
+ /**
863
+ * The markers, through `tx`, of processes that do not read sessions schema `version`: those that record an older
864
+ * one, and those of builds that record none.
865
+ */
866
+ olderThan(tx: SqliteExecutor, version: number): Promise<readonly SessionOpenMarkerBuild[]>;
493
867
  remove(sessionId: string, token: string): Promise<void>;
494
868
  list(sessionId: string): Promise<readonly SessionOpenMarkerAge[]>;
495
869
  }
@@ -6,7 +6,7 @@ try {
6
6
  } catch (error) {
7
7
  const root = new URL("../../../", import.meta.url);
8
8
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
9
- const key = `${root.href}#0.10.11-alpha.1`;
9
+ const key = `${root.href}#0.10.11-alpha.3`;
10
10
  let release = releases.get(key);
11
11
  if (release === undefined) {
12
12
  const current = (async () => {
@@ -27,10 +27,10 @@ try {
27
27
  release = current;
28
28
  }
29
29
  const running = await release;
30
- if (running === undefined || running.version === "0.10.11-alpha.1") throw error;
31
- throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.1 while this session was running; restart it to keep using session storage.", {
30
+ if (running === undefined || running.version === "0.10.11-alpha.3") throw error;
31
+ throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.3 while this session was running; restart it to keep using session storage.", {
32
32
  cause: error,
33
33
  });
34
34
  }
35
- export const { LISTING_FETCH_BATCH, SESSION_BLOB_CHUNK_BYTES, SESSION_DOMAIN, SESSION_ENTRY_CHUNK_BYTES, SESSION_FILLFACTOR_DOMAIN, SESSION_PRESENCE_DOMAIN, SESSION_PRESENCE_TABLES, SESSION_READ_FETCH, SESSION_READ_PAGE_CHARS, SESSION_RESUME_REBUILD, SESSION_SCHEMA_VERSION, SESSION_TABLES, SqlSessionStore } = module;
35
+ export const { LISTING_FETCH_BATCH, SESSION_APPEND_FUNCTION_DOMAIN, SESSION_BLOB_CHUNK_BYTES, SESSION_DOMAIN, SESSION_ENTRY_CHUNK_BYTES, SESSION_FILLFACTOR_DOMAIN, SESSION_PRESENCE_DOMAIN, SESSION_PRESENCE_TABLES, SESSION_READ_FETCH, SESSION_READ_PAGE_CHARS, SESSION_RESUME_REBUILD, SESSION_SCHEMA_VERSION, SESSION_SCHEMA_VERSION_CHUNKED, SESSION_SCHEMA_VERSION_SHARED_HISTORY, SESSION_TABLES, SqlSessionStore } = module;
36
36
  //# sourceMappingURL=sql-session-store.impl.js.map