@bastani/atomic 0.10.10 → 0.10.11-alpha.2

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 (402) hide show
  1. package/CHANGELOG.md +139 -0
  2. package/README.md +1 -1
  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 +11 -13
  7. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js.map +1 -1
  8. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +9 -9
  9. package/dist/_shared/mode-shared-2QJSCUM6.js +55 -18
  10. package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -1
  11. package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
  12. package/dist/_shared/runtime-O4KCSG4C.js +5 -5
  13. package/dist/_shared/{sdk-RRLVN7ER.js → sdk-IQMULKFU.js} +2962 -470
  14. package/dist/_shared/sdk-IQMULKFU.js.map +1 -0
  15. package/dist/_shared/session-data-AHTU7IS6.js +4 -4
  16. package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
  17. package/dist/_shared/settings-startup-8-DNZ2RIHM.js +1 -1
  18. package/dist/_shared/{settings-startup-4QCVCI53.js → settings-startup-HXQLSUWM.js} +8 -2
  19. package/dist/_shared/settings-startup-HXQLSUWM.js.map +1 -0
  20. package/dist/_shared/{startup-0-0-4VG2G44V.js → startup-0-0-3IXNMFM2.js} +482 -53
  21. package/dist/_shared/startup-0-0-3IXNMFM2.js.map +1 -0
  22. package/dist/_shared/{startup-0-1-XTIL65D4.js → startup-0-1-7T2IAE7J.js} +121 -251
  23. package/dist/_shared/startup-0-1-7T2IAE7J.js.map +1 -0
  24. package/dist/_shared/{startup-0-2-27OWFHV6.js → startup-0-2-5QHPCEON.js} +293 -10
  25. package/dist/_shared/startup-0-2-5QHPCEON.js.map +1 -0
  26. package/dist/_shared/{startup-0-3-T4DVFYWX.js → startup-0-3-4ZYBYQNM.js} +273 -14
  27. package/dist/_shared/startup-0-3-4ZYBYQNM.js.map +1 -0
  28. package/dist/_shared/startup-0-4-ZMJV547D.js +6 -6
  29. package/dist/_shared/{startup-0-5-FD2P735I.js → startup-0-5-YDW47QX6.js} +29 -71
  30. package/dist/_shared/startup-0-5-YDW47QX6.js.map +1 -0
  31. package/dist/_shared/startup-10-0-TDQNBDDL.js +9 -9
  32. package/dist/_shared/startup-12-0-55AAXBJZ.js +4 -4
  33. package/dist/_shared/startup-14-0-MLX36RBG.js +6 -6
  34. package/dist/_shared/startup-15-0-YUKGAC63.js +34 -10
  35. package/dist/_shared/startup-15-0-YUKGAC63.js.map +1 -1
  36. package/dist/_shared/startup-15-1-4S7FLMNG.js +10 -9
  37. package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
  38. package/dist/_shared/startup-8-0-34CBHPZH.js +421 -84
  39. package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
  40. package/dist/_shared/{startup-8-1-4KANEHRA.js → startup-8-1-X32CYSXB.js} +1291 -722
  41. package/dist/_shared/startup-8-1-X32CYSXB.js.map +1 -0
  42. package/dist/_shared/storage-command-7MGXLJGZ.js +17 -9
  43. package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
  44. package/dist/_shared/task-reference-stream-JWMUZSJX.js +1 -1
  45. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
  46. package/dist/_shared/tree-outline-MUEPK5B7.js +3 -3
  47. package/dist/builtin/intercom/CHANGELOG.md +29 -0
  48. package/dist/builtin/intercom/broker/broker.bundle.mjs +1138 -384
  49. package/dist/builtin/intercom/broker/database-wake-up-bus.ts +103 -24
  50. package/dist/builtin/intercom/broker/multinode-router.ts +42 -21
  51. package/dist/builtin/intercom/broker/multinode-state-store.ts +22 -1
  52. package/dist/builtin/intercom/broker/open-broker-state.ts +82 -31
  53. package/dist/builtin/intercom/broker/paths.ts +8 -4
  54. package/dist/builtin/intercom/broker/released-asker-remote-replies.ts +18 -6
  55. package/dist/builtin/intercom/broker/sql-add-column.ts +4 -1
  56. package/dist/builtin/intercom/broker/sql-ended-child-queue-store.ts +65 -44
  57. package/dist/builtin/intercom/broker/sql-held-send-store.ts +11 -3
  58. package/dist/builtin/intercom/broker/sql-known-session-store.ts +24 -12
  59. package/dist/builtin/intercom/broker/sql-lease-store.ts +386 -65
  60. package/dist/builtin/intercom/broker/sql-outbox-store.ts +462 -130
  61. package/dist/builtin/intercom/broker/sql-pending-ask-store.ts +20 -9
  62. package/dist/builtin/intercom/broker/sql-released-ask-store.ts +14 -6
  63. package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +27 -11
  64. package/dist/builtin/intercom/broker/sql-schema.ts +198 -5
  65. package/dist/builtin/intercom/broker/sql-sent-message-authority.ts +97 -34
  66. package/dist/builtin/intercom/index.bundle.mjs +11 -8
  67. package/dist/builtin/intercom/package.json +1 -1
  68. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  69. package/dist/builtin/mcp/package.json +1 -1
  70. package/dist/builtin/subagents/CHANGELOG.md +18 -0
  71. package/dist/builtin/subagents/package.json +1 -1
  72. package/dist/builtin/subagents/skills/skill-creator/SKILL.md +1 -1
  73. package/dist/builtin/subagents/src/extension/index.bundle.mjs +62 -23
  74. package/dist/builtin/web-access/index.bundle.mjs +1 -1
  75. package/dist/builtin/web-access/package.json +1 -1
  76. package/dist/cli/args.js +2 -2
  77. package/dist/cli/auth-cli.code.js +6 -6
  78. package/dist/cli/auth-cli.impl.js +3 -3
  79. package/dist/cli/auth-cli.js +3 -3
  80. package/dist/cli/blueprint-command.code.js +4 -4
  81. package/dist/cli/blueprint-command.impl.js +3 -3
  82. package/dist/cli/blueprint-command.js +3 -3
  83. package/dist/cli/intercom-command.code.js +3 -3
  84. package/dist/cli/intercom-command.impl.js +3 -3
  85. package/dist/cli/intercom-command.js +3 -3
  86. package/dist/cli/list-models.code.js +2 -2
  87. package/dist/cli/list-models.impl.js +3 -3
  88. package/dist/cli/list-models.js +3 -3
  89. package/dist/cli/session-picker.code.js +2 -2
  90. package/dist/cli/session-picker.impl.js +3 -3
  91. package/dist/cli/session-picker.js +3 -3
  92. package/dist/cli/startup-ui.code.js +2 -2
  93. package/dist/cli/startup-ui.impl.js +3 -3
  94. package/dist/cli/startup-ui.js +3 -3
  95. package/dist/cli/storage-command.impl.js +3 -3
  96. package/dist/cli/storage-command.js +3 -3
  97. package/dist/cli/storage-search-session.code.js +3 -3
  98. package/dist/cli/storage-search-session.impl.js +3 -3
  99. package/dist/cli/storage-search-session.js +3 -3
  100. package/dist/cli/team-command.code.js +3 -3
  101. package/dist/cli/team-command.impl.js +3 -3
  102. package/dist/cli/team-command.js +3 -3
  103. package/dist/cli.js +2 -2
  104. package/dist/core/agent-session-methods.d.ts +3 -0
  105. package/dist/core/agent-session-methods.js.map +1 -1
  106. package/dist/core/agent-session.d.ts +1 -0
  107. package/dist/core/compaction/compactor.d.ts +2 -0
  108. package/dist/core/debug.impl.js +3 -3
  109. package/dist/core/debug.js +3 -3
  110. package/dist/core/export-html/card-projection.code.js +1 -1
  111. package/dist/core/export-html/card-projection.impl.js +3 -3
  112. package/dist/core/export-html/card-projection.js +3 -3
  113. package/dist/core/export-html/index.code.js +2 -2
  114. package/dist/core/export-html/index.impl.js +3 -3
  115. package/dist/core/export-html/index.js +3 -3
  116. package/dist/core/export-html/json-spans.impl.js +3 -3
  117. package/dist/core/export-html/json-spans.js +3 -3
  118. package/dist/core/export-html/oversized-render-inputs.code.js +2 -2
  119. package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
  120. package/dist/core/export-html/oversized-render-inputs.js +3 -3
  121. package/dist/core/export-html/tool-renderer.impl.js +3 -3
  122. package/dist/core/export-html/tool-renderer.js +3 -3
  123. package/dist/core/extensions/jiti-loader.impl.js +3 -3
  124. package/dist/core/extensions/jiti-loader.js +3 -3
  125. package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
  126. package/dist/core/extensions/jiti-static-loader.js +3 -3
  127. package/dist/core/extensions/loader-host-modules.code.js +1 -1
  128. package/dist/core/extensions/loader-host-modules.impl.js +3 -3
  129. package/dist/core/extensions/loader-host-modules.js +3 -3
  130. package/dist/core/extensions/loader-virtual-modules.js +2 -2
  131. package/dist/core/extensions/runner-context.js +4 -4
  132. package/dist/core/extensions/runner-context.js.map +1 -1
  133. package/dist/core/intercom-broker-control-host.code.js +1 -1
  134. package/dist/core/intercom-broker-control-host.impl.js +3 -3
  135. package/dist/core/intercom-broker-control-host.js +3 -3
  136. package/dist/core/intercom-broker-control.code.js +3 -3
  137. package/dist/core/intercom-broker-control.impl.js +3 -3
  138. package/dist/core/intercom-broker-control.js +3 -3
  139. package/dist/core/model-registry.js +1 -1
  140. package/dist/core/model-resolver-defaults.d.ts +3 -2
  141. package/dist/core/package-manager-storage-adapters.code.js +1 -1
  142. package/dist/core/package-manager-storage-adapters.impl.js +3 -3
  143. package/dist/core/package-manager-storage-adapters.js +3 -3
  144. package/dist/core/sdk.code.js +4 -5
  145. package/dist/core/sdk.impl.js +3 -3
  146. package/dist/core/sdk.js +3 -3
  147. package/dist/core/session-manager-core.d.ts +5 -2
  148. package/dist/core/session-manager-core.js +39 -23
  149. package/dist/core/session-manager-core.js.map +1 -1
  150. package/dist/core/session-manager-list.impl.js +3 -3
  151. package/dist/core/session-manager-list.js +3 -3
  152. package/dist/core/session-manager.code.js +3 -3
  153. package/dist/core/session-manager.impl.js +3 -3
  154. package/dist/core/session-manager.js +3 -3
  155. package/dist/core/session-open-markers.js +3 -0
  156. package/dist/core/session-open-markers.js.map +1 -0
  157. package/dist/core/session-storage.code.js +1 -1
  158. package/dist/core/session-storage.impl.js +3 -3
  159. package/dist/core/session-storage.js +3 -3
  160. package/dist/core/storage/added-exports.d.ts +6 -0
  161. package/dist/core/storage/added-exports.js +19 -0
  162. package/dist/core/storage/added-exports.js.map +1 -0
  163. package/dist/core/storage/database.d.ts +53 -0
  164. package/dist/core/storage/database.js.map +1 -1
  165. package/dist/core/storage/fenced-paths.d.ts +47 -0
  166. package/dist/core/storage/fenced-paths.js +53 -0
  167. package/dist/core/storage/fenced-paths.js.map +1 -1
  168. package/dist/core/storage/file-identity.js +31 -2
  169. package/dist/core/storage/file-identity.js.map +1 -1
  170. package/dist/core/storage/index.d.ts +4 -1
  171. package/dist/core/storage/index.js +5 -2
  172. package/dist/core/storage/index.js.map +1 -1
  173. package/dist/core/storage/migrations.d.ts +33 -2
  174. package/dist/core/storage/migrations.js +73 -5
  175. package/dist/core/storage/migrations.js.map +1 -1
  176. package/dist/core/storage/node-sqlite-thread.js +48 -6
  177. package/dist/core/storage/node-sqlite-thread.js.map +1 -1
  178. package/dist/core/storage/node-sqlite.js +137 -4
  179. package/dist/core/storage/node-sqlite.js.map +1 -1
  180. package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
  181. package/dist/core/storage/offline-snapshot-file.js +3 -3
  182. package/dist/core/storage/prefix.d.ts +3 -2
  183. package/dist/core/storage/prefix.js +23 -2
  184. package/dist/core/storage/prefix.js.map +1 -1
  185. package/dist/core/storage/provider.js +2 -2
  186. package/dist/core/storage/schema-catalog.d.ts +120 -0
  187. package/dist/core/storage/schema-catalog.js +351 -0
  188. package/dist/core/storage/schema-catalog.js.map +1 -0
  189. package/dist/core/storage/selection.js +2 -2
  190. package/dist/core/storage/session/branch-fork-source.code.js +47 -25
  191. package/dist/core/storage/session/branch-fork-source.code.js.map +1 -1
  192. package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
  193. package/dist/core/storage/session/branch-fork-source.js +3 -3
  194. package/dist/core/storage/session/card-view.impl.js +3 -3
  195. package/dist/core/storage/session/card-view.js +3 -3
  196. package/dist/core/storage/session/child-reader.code.js +4 -4
  197. package/dist/core/storage/session/child-reader.impl.js +3 -3
  198. package/dist/core/storage/session/child-reader.js +3 -3
  199. package/dist/core/storage/session/chunked-resume-projection.code.js +1 -1
  200. package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
  201. package/dist/core/storage/session/chunked-resume-projection.js +3 -3
  202. package/dist/core/storage/session/errors.js +1 -1
  203. package/dist/core/storage/session/expanded-child-details.code.js +4 -4
  204. package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
  205. package/dist/core/storage/session/expanded-child-details.js +3 -3
  206. package/dist/core/storage/session/fork-detach.d.ts +118 -0
  207. package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
  208. package/dist/core/storage/session/fork-row-bytes.js +3 -3
  209. package/dist/core/storage/session/fork-row-index.impl.js +3 -3
  210. package/dist/core/storage/session/fork-row-index.js +3 -3
  211. package/dist/core/storage/session/fork-schema.js +53 -0
  212. package/dist/core/storage/session/fork-schema.js.map +1 -0
  213. package/dist/core/storage/session/fork-segments.d.ts +58 -0
  214. package/dist/core/storage/session/fork-staging.code.js +176 -36
  215. package/dist/core/storage/session/fork-staging.code.js.map +1 -1
  216. package/dist/core/storage/session/fork-staging.impl.js +3 -3
  217. package/dist/core/storage/session/fork-staging.js +3 -3
  218. package/dist/core/storage/session/fork-sweep.js +61 -0
  219. package/dist/core/storage/session/fork-sweep.js.map +1 -0
  220. package/dist/core/storage/session/fork-window.code.js +4 -4
  221. package/dist/core/storage/session/fork-window.impl.js +3 -3
  222. package/dist/core/storage/session/fork-window.js +3 -3
  223. package/dist/core/storage/session/history-pages.impl.js +3 -3
  224. package/dist/core/storage/session/history-pages.js +3 -3
  225. package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
  226. package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
  227. package/dist/core/storage/session/jsonl-session-store.d.ts +37 -1
  228. package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
  229. package/dist/core/storage/session/jsonl-session-store.js +3 -3
  230. package/dist/core/storage/session/memory-session-store.impl.js +3 -3
  231. package/dist/core/storage/session/memory-session-store.js +3 -3
  232. package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
  233. package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
  234. package/dist/core/storage/session/pinned-branch-resume.js +3 -3
  235. package/dist/core/storage/session/released-history-files.code.js +3 -3
  236. package/dist/core/storage/session/released-history-files.impl.js +3 -3
  237. package/dist/core/storage/session/released-history-files.js +3 -3
  238. package/dist/core/storage/session/resident-fork-rows.code.js +1 -1
  239. package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
  240. package/dist/core/storage/session/resident-fork-rows.js +3 -3
  241. package/dist/core/storage/session/session-resume.impl.js +3 -3
  242. package/dist/core/storage/session/session-resume.js +3 -3
  243. package/dist/core/storage/session/session-search-index.d.ts +5 -0
  244. package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
  245. package/dist/core/storage/session/snapshot-cut.js +3 -3
  246. package/dist/core/storage/session/snapshot-history.code.js +4 -4
  247. package/dist/core/storage/session/snapshot-history.impl.js +3 -3
  248. package/dist/core/storage/session/snapshot-history.js +3 -3
  249. package/dist/core/storage/session/sql-chat-records.d.ts +15 -0
  250. package/dist/core/storage/session/sql-session-store.code.js +1 -1
  251. package/dist/core/storage/session/sql-session-store.d.ts +445 -11
  252. package/dist/core/storage/session/sql-session-store.impl.js +4 -4
  253. package/dist/core/storage/session/sql-session-store.js +4 -4
  254. package/dist/core/storage/session/tree-outline.impl.js +3 -3
  255. package/dist/core/storage/session/tree-outline.js +3 -3
  256. package/dist/core/storage/session/tree-presentation.code.js +1 -1
  257. package/dist/core/storage/session/tree-presentation.impl.js +3 -3
  258. package/dist/core/storage/session/tree-presentation.js +3 -3
  259. package/dist/core/storage/session/types.d.ts +36 -0
  260. package/dist/core/storage/sqlite-facade.d.ts +54 -6
  261. package/dist/core/storage/sqlite-facade.js +384 -18
  262. package/dist/core/storage/sqlite-facade.js.map +1 -1
  263. package/dist/core/storage/statement-sequence.d.ts +83 -0
  264. package/dist/core/storage/statement-sequence.js +21 -0
  265. package/dist/core/storage/statement-sequence.js.map +1 -1
  266. package/dist/core/storage/storage-status.code.js +1 -1
  267. package/dist/core/storage/storage-status.impl.js +3 -3
  268. package/dist/core/storage/storage-status.js +3 -3
  269. package/dist/core/storage/team.code.js +1 -1
  270. package/dist/core/storage/team.impl.js +3 -3
  271. package/dist/core/storage/team.js +3 -3
  272. package/dist/core/structured-output/index.code.js +1 -1
  273. package/dist/core/structured-output/index.impl.js +3 -3
  274. package/dist/core/structured-output/index.js +3 -3
  275. package/dist/core/tasks/task-completion-entry.code.js +1 -1
  276. package/dist/core/tasks/task-completion-entry.impl.js +3 -3
  277. package/dist/core/tasks/task-completion-entry.js +3 -3
  278. package/dist/core/tasks/task-file-history.code.js +4 -4
  279. package/dist/core/tasks/task-file-history.impl.js +3 -3
  280. package/dist/core/tasks/task-file-history.js +3 -3
  281. package/dist/core/tasks/task-reference-archive.code.js +5 -5
  282. package/dist/core/tasks/task-reference-archive.js +3 -3
  283. package/dist/core/tasks/task-reference-identity.js +3 -3
  284. package/dist/core/tasks/task-reference-stream.impl.js +3 -3
  285. package/dist/core/tasks/task-reference-stream.js +3 -3
  286. package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
  287. package/dist/core/tasks/task-unsaved-answer.js +3 -3
  288. package/dist/core/tasks/task-view-source.code.js +1 -1
  289. package/dist/core/tasks/task-view-source.impl.js +3 -3
  290. package/dist/core/tasks/task-view-source.js +3 -3
  291. package/dist/core/tools/bash.d.ts +8 -4
  292. package/dist/core/tools/history-session.d.ts +7 -0
  293. package/dist/core/tools/history-tasks.d.ts +123 -0
  294. package/dist/core/tools/kill.d.ts +5 -2
  295. package/dist/core/tools/powershell.d.ts +2 -2
  296. package/dist/core/tools/read-url.code.js +3 -3
  297. package/dist/core/tools/read-url.impl.js +3 -3
  298. package/dist/core/tools/read-url.js +3 -3
  299. package/dist/core/tools/read.d.ts +12 -2
  300. package/dist/core/tools/resource-selectors.d.ts +2 -0
  301. package/dist/core/tools/search.d.ts +12 -2
  302. package/dist/core/worktree-snapshot/blob-store.d.ts +45 -2
  303. package/dist/core/worktree-snapshot/blob-store.js +228 -60
  304. package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
  305. package/dist/core/worktree-snapshot/errors.code.js +3 -3
  306. package/dist/core/worktree-snapshot/errors.impl.js +3 -3
  307. package/dist/core/worktree-snapshot/errors.js +3 -3
  308. package/dist/core/worktree-snapshot/fork-snapshot-index.js +121 -0
  309. package/dist/core/worktree-snapshot/fork-snapshot-index.js.map +1 -0
  310. package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
  311. package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
  312. package/dist/extensions/codemode/execute.code.js +3 -3
  313. package/dist/extensions/codemode/execute.impl.js +3 -3
  314. package/dist/extensions/codemode/execute.js +3 -3
  315. package/dist/extensions/codemode/renderer.code.js +2 -2
  316. package/dist/extensions/codemode/renderer.impl.js +3 -3
  317. package/dist/extensions/codemode/renderer.js +3 -3
  318. package/dist/extensions/mcp/cli.code.js +3 -3
  319. package/dist/extensions/mcp/cli.impl.js +3 -3
  320. package/dist/extensions/mcp/cli.js +3 -3
  321. package/dist/extensions/mcp/cli.lazy.code.js +2 -2
  322. package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
  323. package/dist/extensions/mcp/cli.lazy.js +3 -3
  324. package/dist/extensions/mcp/runtime.code.js +1 -1
  325. package/dist/extensions/mcp/runtime.impl.js +3 -3
  326. package/dist/extensions/mcp/runtime.js +3 -3
  327. package/dist/index.js +8 -8
  328. package/dist/main-first-time-setup.code.js +2 -2
  329. package/dist/main-first-time-setup.impl.js +3 -3
  330. package/dist/main-first-time-setup.js +3 -3
  331. package/dist/main.js +1 -1
  332. package/dist/modes/interactive/components/agent-panel.d.ts +1 -0
  333. package/dist/modes/interactive/components/stored-tree-view.code.js +3 -3
  334. package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
  335. package/dist/modes/interactive/components/stored-tree-view.js +3 -3
  336. package/dist/modes/interactive/components/task-inspector.d.ts +2 -0
  337. package/dist/modes/interactive/components/user-message-selector-archive.code.js +1 -1
  338. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
  339. package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
  340. package/dist/modes/interactive/interactive-mode-helpers.d.ts +2 -2
  341. package/dist/modes/print-mode.js +1 -1
  342. package/dist/modes/rpc/agent-panel-bridge.d.ts +5 -0
  343. package/dist/package-manager-cli.code.js +7 -7
  344. package/dist/package-manager-cli.impl.js +3 -3
  345. package/dist/package-manager-cli.js +3 -3
  346. package/dist/rpc-entry.js +1 -1
  347. package/dist/startup-files.json +1 -1
  348. package/dist/startup-stages/0.js +1 -1
  349. package/dist/startup-stages/1.js +1 -1
  350. package/dist/startup-stages/10.js +1 -1
  351. package/dist/startup-stages/12.js +1 -1
  352. package/dist/startup-stages/2.js +9 -1
  353. package/dist/startup-stages/3.js +1 -6
  354. package/dist/startup-stages/5.js +1 -1
  355. package/dist/startup-stages/7.js +1 -1
  356. package/dist/startup-stages/8.js +2 -2
  357. package/dist/utils/startup-database-spare.code.js +3 -3
  358. package/dist/utils/startup-database-spare.impl.js +3 -3
  359. package/dist/utils/startup-database-spare.js +3 -3
  360. package/dist/utils/tools-manager.code.js +1 -1
  361. package/dist/utils/tools-manager.impl.js +3 -3
  362. package/dist/utils/tools-manager.js +3 -3
  363. package/docs/background-tasks.md +123 -23
  364. package/docs/compaction.md +18 -0
  365. package/docs/docs.json +2 -0
  366. package/docs/environment-variables.md +1 -1
  367. package/docs/getting-started/installation.md +9 -2
  368. package/docs/guides/postgres-pgbouncer.md +346 -0
  369. package/docs/guides/postgres-tuning.md +311 -0
  370. package/docs/guides/resume-on-any-machine.md +2 -2
  371. package/docs/guides.md +2 -0
  372. package/docs/index.md +1 -1
  373. package/docs/libraries/agent-core.md +1 -1
  374. package/docs/libraries/ai.md +2 -2
  375. package/docs/libraries/codemode.md +1 -1
  376. package/docs/libraries/storage-libsql.md +6 -1
  377. package/docs/libraries/storage-postgres.md +11 -6
  378. package/docs/libraries/tui.md +1 -1
  379. package/docs/libraries.md +2 -2
  380. package/docs/programmatic.md +1 -1
  381. package/docs/quickstart.md +1 -1
  382. package/docs/sdk/storage.md +1 -1
  383. package/docs/sdk/web-server.md +1 -3
  384. package/docs/sdk.md +1 -7
  385. package/docs/sessions.md +67 -2
  386. package/docs/settings.md +20 -1
  387. package/docs/skills/authoring.md +1 -1
  388. package/docs/skills.md +79 -6
  389. package/docs/storage.md +305 -14
  390. package/docs/subagents/reference.md +2 -2
  391. package/docs/subagents.md +4 -3
  392. package/docs/tools.md +44 -10
  393. package/docs/windows.md +1 -1
  394. package/package.json +9 -9
  395. package/dist/_shared/sdk-RRLVN7ER.js.map +0 -1
  396. package/dist/_shared/settings-startup-4QCVCI53.js.map +0 -1
  397. package/dist/_shared/startup-0-0-4VG2G44V.js.map +0 -1
  398. package/dist/_shared/startup-0-1-XTIL65D4.js.map +0 -1
  399. package/dist/_shared/startup-0-2-27OWFHV6.js.map +0 -1
  400. package/dist/_shared/startup-0-3-T4DVFYWX.js.map +0 -1
  401. package/dist/_shared/startup-0-5-FD2P735I.js.map +0 -1
  402. package/dist/_shared/startup-8-1-4KANEHRA.js.map +0 -1
@@ -2,18 +2,39 @@ 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 SessionChatRecords } from "./chat-records.js";
5
+ import { type ForkDetachOptions, type ForkDetachReport } from "./fork-detach.js";
6
6
  import { SqlSessionSearchIndex } from "./session-search-index.js";
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";
8
9
  /**
9
10
  * The newest sessions schema this build reads and writes. Version 2 stores long entries in chunks (#4954), which a build
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";
30
+ /** The ledger step, `schema:session-fillfactor`, that sets the sessions table's fillfactor on PostgreSQL (#6560). */
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";
17
38
  /**
18
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,
19
40
  * so their bound and returned values stay within it: libSQL servers cap a row and a bound value (sqld's default is
@@ -81,12 +102,32 @@ export declare class SqlSessionStore implements SessionStore {
81
102
  openMarkers: SqlSessionOpenMarkers;
82
103
  readonly searchIndex?: SqlSessionSearchIndex;
83
104
  private chatStore?;
105
+ /** The database's reader handle, once a read opened it: see `readerDatabase`. */
106
+ private reader?;
107
+ /** The sessions schema version each transaction read first, by its handle: see `sharedHistoryForks`. */
108
+ private readonly schemaVersions;
109
+ /** The fork tables under this store's prefix, which exist once its sessions schema is version 3 (#6560). */
110
+ private readonly forkTables;
111
+ /** See {@link forkLinks}. */
112
+ private forkLinkStatements?;
113
+ /**
114
+ * Whether a read of this store found its sessions schema at {@link SESSION_SCHEMA_VERSION_SHARED_HISTORY}: one way,
115
+ * as the switch is. A read outside a transaction reads sessions through their views once it is set, and before that
116
+ * reads the tables themselves on the condition, checked in the read's own snapshot, that the schema is older.
117
+ */
118
+ private sharedHistorySeen;
119
+ /** For each transaction, whether each session whose row it read has fork segments, as that read found (#6560). */
120
+ private readonly forkedIn;
121
+ /** Whether each recently read session had fork segments: only a first guess, which a read checks (#6560). */
122
+ private readonly forkedSessions;
123
+ /** The sessions each recently forked session's segments named when this store last read them (#6560). */
124
+ private readonly forkSources;
84
125
  /**
85
126
  * Absent on a local libSQL file, which then behaves as before: @libsql/client waits for another process's write
86
127
  * lock on the calling thread, even to begin a transaction, so a side write would stop the event loop where an
87
128
  * ordinary turn-ending notice writes nothing (#5682).
88
129
  */
89
- get chatRecords(): SessionChatRecords | undefined;
130
+ get chatRecords(): SqlSessionChatRecords | undefined;
90
131
  private readonly entryByteLength;
91
132
  private chunkRowids?;
92
133
  /** Session ids of each recently listed scope, valid while the store's change token is unchanged. */
@@ -102,6 +143,13 @@ export declare class SqlSessionStore implements SessionStore {
102
143
  private readonly forkStagingTable;
103
144
  /** The generation each recently read session's row held at a revision: see `generation`. */
104
145
  private readonly generations;
146
+ /**
147
+ * The session append function of this store's tables, when the open found it and this role may run it (#6599):
148
+ * `atomic storage migrate` creates it. Absent elsewhere, where appends take their two round trips as before.
149
+ */
150
+ private readonly appendFunction?;
151
+ /** The row each recent write of this store left for its session, which an append through the function plans from. */
152
+ private readonly writtenRows;
105
153
  private constructor();
106
154
  /** Bind an existing transcript for the storage search command. No schema setup, markers or search index. */
107
155
  static openTranscriptReader(database: SqliteDatabase & {
@@ -111,6 +159,7 @@ export declare class SqlSessionStore implements SessionStore {
111
159
  readonly prefix?: string;
112
160
  readonly cwdMatcher?: SessionCwdMatcher;
113
161
  }): Promise<SqlSessionStore>;
162
+ private static openWithCatalog;
114
163
  /**
115
164
  * Removes, in a bounded number of short transactions, the staged rows of clones that stopped mid-copy and whose lease
116
165
  * lapsed (#5594). Housekeeping: nothing reads those rows, so a failure leaves them to a later open or clone.
@@ -130,6 +179,27 @@ export declare class SqlSessionStore implements SessionStore {
130
179
  * since this store opened it, and what it writes then is not this build's to read or write (#5065).
131
180
  */
132
181
  private transaction;
182
+ /**
183
+ * `options` with the schema check its transaction makes first, before the reads `options.leading` names, sent with
184
+ * the transaction's start where the connection is pipelined.
185
+ */
186
+ private checkedFirst;
187
+ /**
188
+ * `transaction` for a write to the rows of the session `sessionId` only, beside writers of other sessions. `leading`
189
+ * names the reads the body makes first, after the schema check.
190
+ */
191
+ private sessionWrite;
192
+ /**
193
+ * `transaction` for a body that only reads, in one read-only snapshot, on the database's reader handle when it
194
+ * offers one: its reads then wait for neither the writes queued on this store's connection nor their locks.
195
+ */
196
+ private readTransaction;
197
+ /**
198
+ * The database's reader handle, opened at the first read and closed with the store; the database without one. A
199
+ * reader that cannot open, such as when its file can no longer be opened anew, leaves the read on the store's own
200
+ * connection, as every read ran before readers, and the next read tries to open one again.
201
+ */
202
+ private readerDatabase;
133
203
  /**
134
204
  * `transaction` for a body that only reads and writes the database. The version check is sent first, as there, but on
135
205
  * a connection thread the body's first reads go behind it without waiting for its answer: one wait for the thread
@@ -138,12 +208,143 @@ export declare class SqlSessionStore implements SessionStore {
138
208
  * failure reported, whatever the body met.
139
209
  */
140
210
  private transactionCheckedAlongside;
211
+ /** The read that checks the sessions schema version, which every transaction of this store makes first. */
212
+ private schemaCheck;
213
+ /**
214
+ * Reads the sessions schema version through `executor` and refuses one this build does not read. The answer is kept
215
+ * for `executor`, a transaction's own handle, so {@link sharedHistoryForks} costs that transaction no read.
216
+ */
141
217
  private assertReadableSchema;
218
+ /**
219
+ * Whether the database `tx` runs in has forks that share their parent's history turned on: its sessions schema, as
220
+ * `tx` read it, is {@link SESSION_SCHEMA_VERSION_SHARED_HISTORY} (#6560). Every transaction of this store reads the
221
+ * version first, so this costs no further read there; `tx` of any other transaction reads it once. Asked again in each
222
+ * transaction, never kept on the store: another process may turn the forks on at any time, and the switch is one way,
223
+ * so an answer read before it only means a fork is copied.
224
+ */
225
+ sharedHistoryForks(tx: SqliteExecutor): Promise<boolean>;
226
+ /** Notes a sessions schema version a read of this store found: see {@link sharedHistorySeen}. */
227
+ private noteSchemaVersion;
228
+ /** How transaction `tx` reads a session's rows: through its view where its database has shared history (#6560). */
229
+ private viewTables;
230
+ /**
231
+ * A column, `forked`, of a read of a sessions row whose id is `id`: 1 when the session has fork segments (#6560),
232
+ * found by the segments' key. Only where `segments`, the fork segments table, exists.
233
+ */
234
+ private forkedColumn;
235
+ /**
236
+ * Notes what a read of session `sessionId`'s row in transaction `tx` found, `forked` from {@link forkedColumn}: the
237
+ * transaction's later reads of a session without segments read its tables directly. The store remembers it too, as a
238
+ * first guess for a read that sends its statements before that row's answer, and checks it against that answer.
239
+ */
240
+ private noteForked;
241
+ /**
242
+ * How a read outside a transaction reads a session's rows: through its view once this store has seen shared history,
243
+ * and otherwise from the tables themselves, but only while the schema, read in the same statement, is older. Such a
244
+ * read that finds nothing asks `outsideTransaction` to try again.
245
+ */
246
+ private outsideViewTables;
247
+ /**
248
+ * `read`, a read outside a transaction of a session's rows through `outsideViewTables`, once more through the views
249
+ * when it found nothing (`found` says) before this store had seen shared history, and the schema, read after it, is
250
+ * 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
251
+ * read after the read was older at the read too, and its answer stands.
252
+ */
253
+ private outsideTransaction;
254
+ /**
255
+ * `read`, a read outside a transaction of session `sessionId`'s rows that also reads, as `forked`, whether the
256
+ * session has fork segments, through `outsideTransaction` (#6560): from the tables themselves when this store last
257
+ * found the session without segments, and through its view again when the read's own answer says it now has them.
258
+ */
259
+ private outsideSessionRead;
260
+ /** The `forked` column of a read outside a transaction of the sessions row `id` names: see `outsideSessionRead`. */
261
+ private outsideForkedColumn;
262
+ /**
263
+ * After a read outside a transaction found nothing: reads the sessions schema, refuses one this build does not read,
264
+ * and tells whether shared history is on now where the read, made with `seen` as it was, read the tables themselves.
265
+ */
266
+ private schemaNowShared;
267
+ /**
268
+ * Turns on forks that share their parent's history (#6560), as a store's open does by itself: see
269
+ * {@link SqlSessionStore.switchSharedHistory}. `live` judges whether the process of an older build's open-session
270
+ * marker still runs; the application's judge by default.
271
+ */
272
+ enableSharedHistoryForks(options?: {
273
+ readonly live?: (marker: SessionOpenMarkerBuild) => Promise<boolean>;
274
+ }): Promise<SharedHistoryForksOutcome>;
275
+ /**
276
+ * The switch to shared-history forks (#6560), in one transaction: creates the fork tables, records version 3 in the
277
+ * migration ledger where there is one, and raises the sessions schema to it, so that builds which do not read it
278
+ * refuse the database at their next open or transaction. One way: nothing lowers it again.
279
+ *
280
+ * It never leaves an older process reading what it cannot read: while `live` judges any open-session marker of an
281
+ * older build to be a running process, it changes nothing and is `deferred`, and the next open tries again. The
282
+ * transaction is the only writer of the whole database while it runs, so every session write either finished before
283
+ * it, or starts after it and reads the new version first. Two hosts switching at once run one after the other, and
284
+ * the second finds it `already` done.
285
+ */
286
+ private static switchSharedHistory;
287
+ /**
288
+ * An open's switch to shared-history forks, true when it switched the database. With `precheck`, for an open that
289
+ * read the schema without a lock, it first reads, still without one, the version and the markers of older builds
290
+ * together, so an open that must leave the switch for later, while an older build runs a session, takes no lock and
291
+ * 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
292
+ * privilege to create tables, is left for a later open or `atomic storage migrate`; forks copy meanwhile. Either way
293
+ * the open goes on, and only the debug log notes it.
294
+ */
295
+ private static switchAtOpen;
142
296
  get descriptor(): StorageDescriptor;
143
297
  create(header: SessionRecordHeader, entries: readonly SessionEntry[]): Promise<SessionWriteResult>;
144
298
  createFork(header: SessionRecordHeader, entries: SessionForkSeed, source: ForkArchiveSource): Promise<(SessionWriteResult & {
145
299
  remainingBlobs?: readonly string[];
146
300
  }) | undefined>;
301
+ /**
302
+ * A fork from the entries a caller holds. Where the database has shared history (#6560) and the source is still in
303
+ * the generation the fork read it in, every entry the store read from the source and the caller kept unchanged, and
304
+ * every receipt, is named by the child's segments, not stored again: the child stores only the entries it changed or
305
+ * added, and their blobs. Otherwise the entries are stored as `create` stores them, receipts as the source stores
306
+ * them. Undefined, with nothing written, for entries with neither receipts nor blobs that share nothing: `create`
307
+ * then stores them, needing nothing of the source, so a source that changed or went away meanwhile does not fail it.
308
+ */
309
+ private writeEntriesFork;
310
+ /**
311
+ * The statements of a fork from `entries` with shared history (#6560), in seq order, after its session row: the
312
+ * segments that name the rows `places` puts in the source, each entry it does not as {@link entryForkWrites} stores it,
313
+ * the search texts of those, and the lineage row. Throws, before the last of them, unless the segments are well formed.
314
+ */
315
+ private sharedEntriesForkWrites;
316
+ /**
317
+ * The source session's head, its row locked for share, once the child is known to be new: both reads go out together,
318
+ * one round trip (#6560). Fails as the source changed when it is no longer the generation the fork read.
319
+ */
320
+ private forkDonor;
321
+ /**
322
+ * The statements that store a fork's `entries`, in seq order: an entry with a receipt as the source stores it, its row
323
+ * and chunks copied in two statements whatever their size, and a run of others as `create` stores them, several rows
324
+ * a statement. A receipt's row that names another entry fails the fork: the source changed under it. With `places`
325
+ * and `runs`, an entry `places` puts in the source is named by `runs`' segments instead, and the segments before an
326
+ * entry the child stores go first, for the snapshot index's triggers.
327
+ */
328
+ private receiptForkWrites;
329
+ /** The statements of {@link receiptForkWrites} that store `entry`, at index `index` of the fork's entries. */
330
+ private entryForkWrites;
331
+ /**
332
+ * The blob copy of a fork from session `source` of this store's tables (#6560), or undefined when a subclass stores
333
+ * blobs its own way: `createForkArchive` then copies every one through it.
334
+ */
335
+ private forkBlobCopy;
336
+ /**
337
+ * Sends a fork's blob copy behind its entries, then checks, in one round trip with them, that every stored entry of
338
+ * the child has all its chunks and which blobs were copied whole. Resolves with the hashes left for
339
+ * `copySessionBlobs`: those the source does not hold, or all of them where this store does not copy blobs itself.
340
+ */
341
+ private finishForkCopy;
342
+ /**
343
+ * Whether `store` keeps its sessions in this store's very tables, so that this store's transaction reads its rows: this
344
+ * store, or another session store opened on the same database with the same prefix, such as through another handle
345
+ * (#6560). A wrapper that serves sessions of its own does not.
346
+ */
347
+ private sharesTablesWith;
147
348
  /**
148
349
  * Clone a complete session, as `create` with every source entry and blob would, from a store on a handle this one
149
350
  * cannot prove to be its own connection (#5594). The source is read a page at a time into the staging table, never
@@ -158,6 +359,31 @@ export declare class SqlSessionStore implements SessionStore {
158
359
  * runtime role without DDL privileges then stages bounded clones too. Opens never create it.
159
360
  */
160
361
  prepareForkStaging(): Promise<void>;
362
+ /**
363
+ * Creates the chat records' table and index unless the ledger records them, as `atomic storage migrate` does as the
364
+ * owner role: a runtime role without DDL privileges then saves chat records too. Opens never create them; the first
365
+ * chat record does where `migrate` has not run.
366
+ */
367
+ prepareChatRecords(): Promise<void>;
368
+ /** Whether a deleted session with ID `sessionId` left rows forks still read. */
369
+ private hasForkTombstone;
370
+ /** This store's side of detaching and pinning shared fork history: see fork-detach-host.ts. */
371
+ private forkHost;
372
+ /** The statements that link the entries a session with fork segments stores, as a copy links them (#6560). */
373
+ private forkLinks;
374
+ /**
375
+ * @internal Gives every fork that shares history with `sessionId` its own copy of what it reads, so the session's
376
+ * rows no longer stay for them; see fork-detach.ts. Detaches a crash stopped are finished first. Nothing to do where
377
+ * shared-history forks are off.
378
+ */
379
+ detachForks(sessionId: string, options?: ForkDetachOptions): Promise<ForkDetachReport>;
380
+ /** @internal Finishes every detach a crash stopped. Nothing to do where shared-history forks are off. */
381
+ resumeForkDetaches(): Promise<ForkDetachReport>;
382
+ /**
383
+ * @internal Removes the rows of deleted sessions that no fork reads any more, a batch per transaction: `sessionIds`,
384
+ * and a few any earlier sweep left. Resolves with the sessions whose rows went.
385
+ */
386
+ sweepForkTombstones(sessionIds?: readonly string[], batchEntries?: number): Promise<string[]>;
161
387
  private forkStagingTarget;
162
388
  /**
163
389
  * The stored chunk row `index` of the entry `reference` names, whole, in its generation; undefined when the entry is
@@ -166,6 +392,12 @@ export declare class SqlSessionStore implements SessionStore {
166
392
  private readStoredEntryChunk;
167
393
  /** How many chunks the entry `reference` names is stored in, 0 when it is stored whole, in its generation. */
168
394
  private readStoredChunks;
395
+ /**
396
+ * The headers of the blobs `hashes` of session `sessionId` in one read (#6560), each with its first chunk row when it
397
+ * is stored in chunks of at most `maxBytes` in all, as `readBlobPart` reads them at offset 0. A blob the session does
398
+ * not hold is left out; one in the legacy one-row layout comes without its value.
399
+ */
400
+ private readBlobFirstParts;
169
401
  /**
170
402
  * The bytes of a blob from `offset`, a multiple of {@link SESSION_BLOB_CHUNK_BYTES}, so a staged clone never holds
171
403
  * the whole of a large one (#5594): the stored chunk row there, or for a blob in the legacy one-row layout (`chunks`
@@ -173,20 +405,106 @@ export declare class SqlSessionStore implements SessionStore {
173
405
  * cut; with `legacyBytes` 0, only its header. Nothing is converted or written.
174
406
  */
175
407
  private readBlobPart;
176
- private copyForkBlob;
408
+ /**
409
+ * A fork from a stream of the source's rows. Where the database has shared history (#6560), the child stores no copy
410
+ * of the rows the source stores unchanged: its segments name them, and it stores only the rows the stream changed or
411
+ * added. A stream of the source's whole history, as it stands, reads no row at all.
412
+ */
177
413
  private createStreamedFork;
414
+ private writeStreamedFork;
415
+ /**
416
+ * The donor `reads` read, when the fork made them, asked for at once: its reads then go out beside the schema check,
417
+ * in one wait for the connection, as a `create`'s first read does. The fork uses it only once the schema it checks in
418
+ * this transaction has shared history: a store that saw shared history may meet a database whose schema says
419
+ * otherwise, and a fork there never names its source's rows. Unused, its failure is nobody's.
420
+ */
421
+ private leadingForkDonor;
422
+ /** Notes the sessions session `id`'s segments name, which a fork of it locks. */
423
+ private noteForkSources;
424
+ /** The fork tables of this store's database, which exist once it has shared history (#6560). */
425
+ private lineageTables;
426
+ /**
427
+ * The reads that begin a fork of session `donor` into `child` with shared history (#6560), in order: whether the child
428
+ * exists; the rows of the donor and of the sessions its segments name, as the statement starts or as this store last
429
+ * saw them, each locked `key-share` in id order, unless the child exists, with the donor's watermark and generation,
430
+ * and with `withState` its summary state; then the donor's segments, read once those locks are held.
431
+ */
432
+ private sharedForkReads;
433
+ /**
434
+ * The donor of a fork with shared history (#6560), from `reads`: its watermark, as the locking read found it, is the
435
+ * fork's cut-off. Throws `ForkSourcesMoved`, for the fork to run again, when the donor's segments name a session the
436
+ * reads did not lock: the donor's segments changed since this store last forked it.
437
+ */
438
+ private sharedForkDonor;
439
+ /**
440
+ * A fork with shared history of the donor's whole view as it stands (#6560): its segments, its lineage and its
441
+ * session row, whose summary is the donor's in a generation of its own, and no row of any entry. Undefined, for
442
+ * the fork to read the donor's rows, when the donor's resume index does not cover its watermark.
443
+ */
444
+ private writeSharedPrefixFork;
445
+ /**
446
+ * `readEntryChunk` for a fork's reader bound to transaction `tx`, reading session `source` in generation `epoch`: a
447
+ * read of an entry fetches a whole stored chunk row, or a part as large of an entry stored whole, and answers the next
448
+ * reads of it from that, so an entry costs a round trip a chunk, not one every 64 KiB (#6560). The fork holds the
449
+ * source's row, so its generation cannot change meanwhile. Other reads go to `reader` as before.
450
+ */
451
+ private forkChunkReader;
178
452
  /** Keep the legacy inline payload outside the iterator's yielded value and the caller's async frame:
179
453
  * neither may retain this row while the next SQLite result is being delivered. */
180
454
  private writeInlineForkSnapshot;
181
455
  append(sessionId: string, entries: readonly SessionEntry[], options: SessionWriteOptions): Promise<{
182
456
  readonly lastSeq: number;
183
457
  }>;
458
+ /**
459
+ * Remembers `row`, the session's row a committed write of this store left, for the next append to plan from, where
460
+ * appends go through the append function; forgets the session's row when `row` is undefined. At most
461
+ * {@link WRITTEN_ROWS} sessions are remembered, the latest written.
462
+ */
463
+ private rememberWritten;
464
+ /**
465
+ * Appends `entries` in one round trip through the session append function, planned from the row this store's last
466
+ * write of the session left (#6599). The function takes the session's locks as a session write transaction does,
467
+ * checks the schema version, the session and its expected seq as `forWrite` does, writes nothing unless the stored
468
+ * row is still the one planned from, checks the snapshot blobs as `assertStored` does, and writes the row, the
469
+ * entries and their search texts in the order an append's transaction does. Undefined, having written nothing, when
470
+ * the append is not one it plans (no function, no remembered row, a row other than the stored one, invalid entries,
471
+ * a chunked entry or more than one batch of writes, an entry that refers back past the resume window): the caller
472
+ * then appends in a transaction as before, which reads the row itself and reports what fails.
473
+ */
474
+ private appendThroughFunction;
475
+ /**
476
+ * The session append function of the store's tables, `<prefix>session_append_v1`: one statement, and so one round
477
+ * trip, for what an append's transaction does with its two (#6599). Created by `atomic storage migrate` through
478
+ * {@link prepareAppendFunction}. It runs with the caller's rights, so it lets a role do nothing its table
479
+ * privileges do not, and in the caller's `search_path`, the schema a transaction of the store sets. It writes no
480
+ * chunked entry: an append that has one goes through a transaction. Its answer is one row: `appended`, or why it
481
+ * wrote nothing, with the stored version (`version`), the stored last seq (`conflict`), the first blob that is not
482
+ * stored (`blob`), no session (`missing`), or a stored row other than the one the caller planned from (`stale`).
483
+ */
484
+ private appendFunctionSql;
485
+ /**
486
+ * Creates the session append function (#6599), once per revision, as the ledger records it, and lets every role that
487
+ * may insert into the sessions table execute it: `atomic storage migrate` runs this as the owner role, and a
488
+ * runtime role appends through the function from its next open on. PostgreSQL only; does nothing elsewhere.
489
+ */
490
+ prepareAppendFunction(): Promise<void>;
184
491
  replace(sessionId: string, header: SessionRecordHeader, entries: readonly SessionEntry[], options: SessionWriteOptions): Promise<SessionWriteResult>;
185
492
  updateHeader(header: SessionRecordHeader, options: SessionWriteOptions): Promise<SessionWriteResult>;
186
493
  load(sessionId: string): Promise<SessionSnapshot>;
187
494
  readEntryRange(sessionId: string, query: SessionEntriesQuery): Promise<SessionEntriesPage>;
188
495
  readHeader(sessionId: string): Promise<SessionRecordHeader | undefined>;
189
496
  delete(sessionId: string): Promise<void>;
497
+ /**
498
+ * The fork history of `sessionId` where the transaction `tx` runs on shared history: through `reads`, the transaction's
499
+ * leading reads, or, for a store that had not seen shared history when the transaction began, read now.
500
+ */
501
+ private readForkPinsWithin;
502
+ /**
503
+ * Removes the rows of deleted sessions no fork reads any more, among `released` and any an earlier sweep left, in
504
+ * transactions of their own after the write that released them committed. A sweep that fails leaves tombstones the
505
+ * next one finishes: the write it follows stands either way.
506
+ */
507
+ private sweepReleasedForkRows;
190
508
  /**
191
509
  * Stores the blob as rows of at most {@link SESSION_BLOB_CHUNK_BYTES}, then publishes its header. Every statement
192
510
  * commits by itself and writes only while the session exists, so no transaction stays open across round trips and
@@ -201,6 +519,18 @@ export declare class SqlSessionStore implements SessionStore {
201
519
  * Rows never change once written. A session deleted meanwhile holds nothing; missing bytes are `blob-incomplete`.
202
520
  */
203
521
  getBlob(sessionId: string, hash: string): Promise<Uint8Array | undefined>;
522
+ /**
523
+ * Where session `sessionId`'s blob `hash` is stored, with its header: its own, or the first of its fork sources' by
524
+ * id, through the segments of a fork that shares its parent's history (#6560). Read outside a transaction.
525
+ */
526
+ private blobOwner;
527
+ /**
528
+ * The sessions whose blobs a session reads (#6560), as a derived table of `owner` and `place`: the session itself,
529
+ * place 0, and, with shared history, the sources its segments name, place 1. A blob is then looked up by its key in
530
+ * each, never by a scan of the blobs of every session. Its parameters are {@link blobPlaceParams}.
531
+ */
532
+ private blobPlaces;
533
+ private blobPlaceParams;
204
534
  private blobHeader;
205
535
  /**
206
536
  * Lists from a per-scope cache revalidated on every call. A cheap change token, which moves on any commit
@@ -245,7 +575,10 @@ export declare class SqlSessionStore implements SessionStore {
245
575
  * it read in pages of its own and joined here rather than by the database, whose string limit it may pass (#4954).
246
576
  */
247
577
  private readSummaries;
248
- /** A session's search texts as one JSON array, read in pages of at most {@link SESSION_READ_PAGE_CHARS}. */
578
+ /**
579
+ * A session's search texts as one JSON array, read in pages of at most {@link SESSION_READ_PAGE_CHARS}, through its
580
+ * view (#6560). Only a session with some text is read this way, so a read that finds none was held back.
581
+ */
249
582
  private readSearchTexts;
250
583
  /**
251
584
  * Keeps only summaries some cached scope still lists, so memory follows the live sessions. Runs in a
@@ -255,12 +588,39 @@ export declare class SqlSessionStore implements SessionStore {
255
588
  private assertOpen;
256
589
  private assertListing;
257
590
  private read;
591
+ /**
592
+ * The entries of session `sessionId` from `from` through `through`, in pages, through its view (#6560): only those
593
+ * whose seq `seqs` lists, when it is given, which then lies in that range. With `epoch`, the session's generation in
594
+ * 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.
595
+ */
258
596
  private readRows;
259
597
  private readSeqs;
598
+ /**
599
+ * The read of the session's row that `resumeSource` makes first: a read transaction that starts with it names it as
600
+ * a leading read, so a pipelined connection sends it with the transaction's start (#6560).
601
+ */
602
+ private resumeRow;
603
+ /**
604
+ * The view (#6560), as `name`, of session `sessionId`'s entries after seq `after` and through seq `through`, with
605
+ * `entry_id`, `entry_json` and `chunks`, and where each is stored.
606
+ */
607
+ private entriesView;
260
608
  private resumeSource;
609
+ /**
610
+ * Runs `read`, a read transaction that finds the session's index with `resumeSource`, at once; only when that index is
611
+ * missing or stale (`resumeSource` rejects with `SessionConflictError`) does it compute the index with
612
+ * `prepareResume` and run `read` again. A current index, the usual case, then costs no read before the transaction:
613
+ * on a server, one round trip fewer (#6560).
614
+ */
615
+ private withResumeIndex;
261
616
  private prepareResume;
262
617
  readTail(sessionId: string, fromSeq: number): Promise<SessionTail>;
263
618
  readRange(sessionId: string, startSeq: number, endSeq: number, expectedEpoch?: string): Promise<SessionEntryRange>;
619
+ /**
620
+ * The session's watermark and generation; with `segments`, the fork segments table of a database with shared
621
+ * history, also whether the session has segments (#6560), in the same statement: a read that leaves a session without
622
+ * them to its tables' own keyed lookups costs no read of its own to learn it.
623
+ */
264
624
  private historyHead;
265
625
  /** Size at most one page and return only fitting bodies, in the same snapshot as the header. The first
266
626
  * oversized row is a chunk reference; its full inline value never crosses the driver boundary. */
@@ -351,36 +711,100 @@ export declare class SqlSessionStore implements SessionStore {
351
711
  deferChildRecords: true;
352
712
  }): Promise<SessionResume>;
353
713
  private resumeWindow;
714
+ /** The resume of `index`, the session's index as of the snapshot of `tx`, with `header`. */
715
+ private resumeIn;
354
716
  findLatestCompaction(sessionId: string, leafId?: string): Promise<SessionCompactionPoint | undefined>;
717
+ /** The ID of the entry at view seq `seq` of session `sessionId`, read in transaction `tx` (#6560). */
718
+ private entryIdAt;
355
719
  /** The JSON of a long entry, from its chunks, one statement each. */
356
720
  private readEntryChunks;
721
+ /**
722
+ * The read of chunk `index` of the entry at view seq `seq` of session `sessionId` (#6560), found through the view in
723
+ * the statement itself, on the condition `condition` with `params` when given.
724
+ */
725
+ private entryChunkRead;
726
+ /**
727
+ * The chunks of the entry at view seq `seq`: in transaction `tx` with `tables`, or, with `tables` undefined, each
728
+ * read outside a transaction through `outsideTransaction`.
729
+ */
357
730
  private readRawEntryChunks;
358
731
  private entryChunks;
732
+ /** The JSON bytes of the entry stored whole at view seq `seq`, read outside a transaction. */
359
733
  private readInlineEntryBytes;
360
734
  private forWrite;
735
+ /**
736
+ * The read of the session's row that `forWrite` checks a write against; with `forked`, once this store has seen
737
+ * shared history, it also reads whether the session has fork segments (#6560).
738
+ */
739
+ private headRead;
740
+ /** Whether session `sessionId` has fork segments, read in `tx`, whose database has shared history (#6560). */
741
+ private hasForkSegments;
361
742
  private appendedResume;
743
+ /**
744
+ * The latest seq of session `sessionId` that holds entry `entryId`, through its view (#6560): in transaction
745
+ * `executor` with `tables`, or, with `tables` undefined, outside a transaction through `outsideTransaction`. A fork's
746
+ * inherited entries are linked under the sessions that store them, at their seqs there, which the view renumbers.
747
+ */
362
748
  private seqOfEntry;
363
749
  private saveSummary;
364
750
  /** The statement that saves the session's row as `saveSummary` saves it, with what `saveSummary` returns. */
365
751
  private summaryWrite;
366
752
  private insertEntries;
753
+ /**
754
+ * Notes `written`, the entries a committed write of session `sessionId` stored in generation `epoch`, as stored there
755
+ * (#6560): a manager keeps the very objects it appended, so a fork of it shares their rows without reading them back.
756
+ * Only where this store has seen shared history, for which alone the notes count.
757
+ */
758
+ private noteWritten;
759
+ /**
760
+ * A fork's version step, once every entry of the child is in, as the transaction's last write: the same row order as
761
+ * an append, which takes the snapshot index's progress rows with its entries inserts and the schema row after them,
762
+ * so the two never deadlock (#6560). The body makes no call after it.
763
+ */
764
+ private finishFork;
765
+ /** The statement of {@link finishFork}. */
766
+ private forkVersionStep;
367
767
  /**
368
768
  * The statements that store `entries` after `lastSeq`, in order, each entry encoded only when its statements are
369
- * taken: each entry's row and its chunks, the version step a first chunked entry takes, then the entries' search
370
- * texts.
769
+ * taken: the entries' rows, several to a statement (see {@link rowInserts}), each chunked entry's own row and its
770
+ * chunks in their place among them, the version step a first chunked entry takes unless `versionStep` is false (a
771
+ * fork takes it once its last entry is in), then the entries' search texts. With `written`, each entry is added to it
772
+ * with its seq and its JSON as it is encoded, for {@link noteWritten} once the write commits.
371
773
  */
372
774
  private entryWrites;
373
775
  /**
374
- * Runs the session row's statement, then `entries`' statements, in order. A write of up to
375
- * {@link STATEMENT_BATCH_BYTES}, as an ordinary message is, goes to a connection thread as one batch that waits for
376
- * it once. A larger one runs its statements one at a time as they are made, as before, so it never holds more than
377
- * about that much of them, or sends it, at once.
776
+ * Runs the session row's statement, then `entries`' statements, in order, as the transaction's last calls: the body
777
+ * makes none after them. A write of up to {@link STATEMENT_BATCH_BYTES}, as an ordinary message is, goes with the
778
+ * commit where the connection is pipelined, or to a connection thread as one batch that waits for it once, or a
779
+ * request's worth at a time when it has more statements than one takes. A larger one is sent as it is made, without
780
+ * waiting for each statement's answer, so it never holds more than about that much of them, or sends it, at once.
378
781
  */
379
782
  private writeEntries;
380
783
  private encode;
381
784
  }
785
+ /** A marker of a running session, with the sessions schema and the Atomic version its process recorded. */
786
+ export interface SessionOpenMarkerBuild extends SessionOpenMarkerAge {
787
+ readonly sessionId: string;
788
+ /** The newest sessions schema its process reads; undefined for builds before #5065, which record none. */
789
+ readonly schemaVersion?: number;
790
+ /** Its process's Atomic version; undefined for builds before #6560, which record none. */
791
+ readonly build?: string;
792
+ }
793
+ /**
794
+ * What the switch to shared-history forks did: `enabled`, it raised the sessions schema; `already`, the schema was
795
+ * there; `deferred`, `holders`, running processes of older builds, still have sessions open, and nothing changed.
796
+ */
797
+ export type SharedHistoryForksOutcome = {
798
+ readonly status: "enabled";
799
+ } | {
800
+ readonly status: "already";
801
+ } | {
802
+ readonly status: "deferred";
803
+ readonly holders: readonly SessionOpenMarkerBuild[];
804
+ };
382
805
  /** The running sessions that have a SQL store's sessions open, in a table every host sharing the store reads (#4971). */
383
806
  declare class SqlSessionOpenMarkers implements SessionOpenMarkerStore {
807
+ /** A new table already has the columns the later steps add, so on a new database they find them and alter nothing. */
384
808
  static createTable(tx: SqliteExecutor, dialect: StorageDialect, table: string): Promise<void>;
385
809
  /**
386
810
  * Each marker records the sessions schema version its process reads, so a build that upgrades the schema can tell
@@ -388,11 +812,21 @@ declare class SqlSessionOpenMarkers implements SessionOpenMarkerStore {
388
812
  * builds before it. Additive, as every step of this domain must be.
389
813
  */
390
814
  static addSchemaVersion(tx: SqliteExecutor, dialect: StorageDialect, table: string): Promise<void>;
815
+ /**
816
+ * Each marker records the Atomic version of its process, so a command refused while older processes run names the
817
+ * version each must be upgraded from (#6560). Null for markers of builds before it. Additive.
818
+ */
819
+ static addBuild(tx: SqliteExecutor, dialect: StorageDialect, table: string): Promise<void>;
391
820
  private readonly database;
392
821
  private readonly table;
393
822
  private readonly assertOpen;
394
823
  constructor(database: SqliteDatabase, table: string, assertOpen: () => void);
395
824
  put(sessionId: string, marker: SessionOpenMarker): Promise<void>;
825
+ /**
826
+ * The markers, through `tx`, of processes that do not read sessions schema `version`: those that record an older
827
+ * one, and those of builds that record none.
828
+ */
829
+ olderThan(tx: SqliteExecutor, version: number): Promise<readonly SessionOpenMarkerBuild[]>;
396
830
  remove(sessionId: string, token: string): Promise<void>;
397
831
  list(sessionId: string): Promise<readonly SessionOpenMarkerAge[]>;
398
832
  }
@@ -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.10`;
9
+ const key = `${root.href}#0.10.11-alpha.2`;
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.10") throw error;
31
- throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.10 while this session was running; restart it to keep using session storage.", {
30
+ if (running === undefined || running.version === "0.10.11-alpha.2") throw error;
31
+ throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.2 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_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