@bastani/atomic 0.10.11-alpha.2 → 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 (432) hide show
  1. package/CHANGELOG.md +99 -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 +6 -6
  7. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +5 -5
  8. package/dist/_shared/mode-shared-2QJSCUM6.js +6 -6
  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 +3 -3
  16. package/dist/_shared/{sdk-IQMULKFU.js → sdk-B5LEWGGI.js} +340 -163
  17. package/dist/_shared/sdk-B5LEWGGI.js.map +1 -0
  18. package/dist/_shared/session-data-AHTU7IS6.js +2 -2
  19. package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
  20. package/dist/_shared/{startup-0-0-3IXNMFM2.js → startup-0-0-EZUKEP4Q.js} +48 -40
  21. package/dist/_shared/startup-0-0-EZUKEP4Q.js.map +1 -0
  22. package/dist/_shared/{startup-0-1-7T2IAE7J.js → startup-0-1-RTOHJFDJ.js} +195 -42
  23. package/dist/_shared/startup-0-1-RTOHJFDJ.js.map +1 -0
  24. package/dist/_shared/startup-0-2-5QHPCEON.js +33 -43
  25. package/dist/_shared/startup-0-2-5QHPCEON.js.map +1 -1
  26. package/dist/_shared/startup-0-3-4ZYBYQNM.js +5 -5
  27. package/dist/_shared/startup-0-4-ZMJV547D.js +12 -7
  28. package/dist/_shared/startup-0-4-ZMJV547D.js.map +1 -1
  29. package/dist/_shared/startup-0-5-YDW47QX6.js +7 -7
  30. package/dist/_shared/startup-0-5-YDW47QX6.js.map +1 -1
  31. package/dist/_shared/startup-10-0-TDQNBDDL.js +6 -6
  32. package/dist/_shared/startup-12-0-55AAXBJZ.js +2 -2
  33. package/dist/_shared/startup-14-0-MLX36RBG.js +4 -5
  34. package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
  35. package/dist/_shared/startup-15-0-YUKGAC63.js +4 -4
  36. package/dist/_shared/startup-15-1-4S7FLMNG.js +19 -27
  37. package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
  38. package/dist/_shared/startup-8-0-34CBHPZH.js +39 -23
  39. package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
  40. package/dist/_shared/{startup-8-1-X32CYSXB.js → startup-8-1-LZFXSD3Z.js} +90 -1176
  41. package/dist/_shared/startup-8-1-LZFXSD3Z.js.map +1 -0
  42. package/dist/_shared/storage-command-7MGXLJGZ.js +186 -35
  43. package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
  44. package/dist/_shared/storage-status-K7PX2RXA.js +557 -0
  45. package/dist/_shared/storage-status-K7PX2RXA.js.map +1 -0
  46. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
  47. package/dist/_shared/team-DOQKICG2.js +376 -0
  48. package/dist/_shared/team-DOQKICG2.js.map +1 -0
  49. package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
  50. package/dist/builtin/intercom/CHANGELOG.md +23 -0
  51. package/dist/builtin/intercom/README.md +2 -2
  52. package/dist/builtin/intercom/broker/broker.bundle.mjs +913 -289
  53. package/dist/builtin/intercom/broker/database-wake-up-bus.ts +243 -64
  54. package/dist/builtin/intercom/broker/multinode-router.ts +154 -22
  55. package/dist/builtin/intercom/broker/multinode-state-store.ts +30 -3
  56. package/dist/builtin/intercom/broker/open-broker-state.ts +14 -0
  57. package/dist/builtin/intercom/broker/sql-add-column.ts +29 -5
  58. package/dist/builtin/intercom/broker/sql-ended-child-queue-store.ts +3 -2
  59. package/dist/builtin/intercom/broker/sql-held-send-store.ts +2 -2
  60. package/dist/builtin/intercom/broker/sql-known-session-store.ts +43 -19
  61. package/dist/builtin/intercom/broker/sql-lease-store.ts +170 -74
  62. package/dist/builtin/intercom/broker/sql-outbox-store.ts +298 -47
  63. package/dist/builtin/intercom/broker/sql-pending-ask-store.ts +8 -5
  64. package/dist/builtin/intercom/broker/sql-released-ask-store.ts +12 -5
  65. package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +24 -7
  66. package/dist/builtin/intercom/broker/sql-retention.ts +141 -0
  67. package/dist/builtin/intercom/broker/sql-schema.ts +136 -19
  68. package/dist/builtin/intercom/broker/sql-sent-message-authority.ts +74 -19
  69. package/dist/builtin/intercom/broker/wake-up-bus.ts +6 -0
  70. package/dist/builtin/intercom/index.bundle.mjs +2 -3
  71. package/dist/builtin/intercom/package.json +1 -1
  72. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  73. package/dist/builtin/mcp/package.json +1 -1
  74. package/dist/builtin/subagents/package.json +1 -1
  75. package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
  76. package/dist/builtin/web-access/index.bundle.mjs +2 -10
  77. package/dist/builtin/web-access/package.json +1 -1
  78. package/dist/bun/bundled-sqlite.js +41 -0
  79. package/dist/bun/bundled-sqlite.js.map +1 -0
  80. package/dist/cli/args.js +2 -2
  81. package/dist/cli/auth-cli.code.js +4 -4
  82. package/dist/cli/auth-cli.impl.js +3 -3
  83. package/dist/cli/auth-cli.js +3 -3
  84. package/dist/cli/blueprint-command.code.js +3 -3
  85. package/dist/cli/blueprint-command.impl.js +3 -3
  86. package/dist/cli/blueprint-command.js +3 -3
  87. package/dist/cli/intercom-command.code.js +3 -3
  88. package/dist/cli/intercom-command.code.js.map +1 -1
  89. package/dist/cli/intercom-command.impl.js +3 -3
  90. package/dist/cli/intercom-command.js +3 -3
  91. package/dist/cli/list-models.code.js +2 -2
  92. package/dist/cli/list-models.impl.js +3 -3
  93. package/dist/cli/list-models.js +3 -3
  94. package/dist/cli/session-picker.code.js +1 -1
  95. package/dist/cli/session-picker.impl.js +3 -3
  96. package/dist/cli/session-picker.js +3 -3
  97. package/dist/cli/startup-ui.code.js +1 -1
  98. package/dist/cli/startup-ui.impl.js +3 -3
  99. package/dist/cli/startup-ui.js +3 -3
  100. package/dist/cli/storage-command.impl.js +3 -3
  101. package/dist/cli/storage-command.js +3 -3
  102. package/dist/cli/storage-search-session.code.js +3 -3
  103. package/dist/cli/storage-search-session.impl.js +3 -3
  104. package/dist/cli/storage-search-session.js +3 -3
  105. package/dist/cli/team-command.code.js +19 -113
  106. package/dist/cli/team-command.code.js.map +1 -1
  107. package/dist/cli/team-command.impl.js +3 -3
  108. package/dist/cli/team-command.js +3 -3
  109. package/dist/cli.js +5 -18
  110. package/dist/cli.js.map +1 -1
  111. package/dist/core/agent-rehydrate-errors.d.ts +4 -9
  112. package/dist/core/compaction/compactor.d.ts +3 -3
  113. package/dist/core/debug.code.js +1 -1
  114. package/dist/core/debug.impl.js +3 -3
  115. package/dist/core/debug.js +3 -3
  116. package/dist/core/export-html/card-projection.impl.js +3 -3
  117. package/dist/core/export-html/card-projection.js +3 -3
  118. package/dist/core/export-html/index.code.js +2 -2
  119. package/dist/core/export-html/index.impl.js +3 -3
  120. package/dist/core/export-html/index.js +3 -3
  121. package/dist/core/export-html/json-spans.impl.js +3 -3
  122. package/dist/core/export-html/json-spans.js +3 -3
  123. package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
  124. package/dist/core/export-html/oversized-render-inputs.js +3 -3
  125. package/dist/core/export-html/tool-renderer.impl.js +3 -3
  126. package/dist/core/export-html/tool-renderer.js +3 -3
  127. package/dist/core/extensions/jiti-loader.impl.js +3 -3
  128. package/dist/core/extensions/jiti-loader.js +3 -3
  129. package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
  130. package/dist/core/extensions/jiti-static-loader.js +3 -3
  131. package/dist/core/extensions/loader-host-modules.code.js +1 -1
  132. package/dist/core/extensions/loader-host-modules.impl.js +3 -3
  133. package/dist/core/extensions/loader-host-modules.js +3 -3
  134. package/dist/core/extensions/loader-virtual-modules.js +1 -1
  135. package/dist/core/extensions/runner-context.js +2 -2
  136. package/dist/core/intercom-broker-control-host.code.js +2 -2
  137. package/dist/core/intercom-broker-control-host.impl.js +3 -3
  138. package/dist/core/intercom-broker-control-host.js +3 -3
  139. package/dist/core/intercom-broker-control.code.js +3 -3
  140. package/dist/core/intercom-broker-control.impl.js +3 -3
  141. package/dist/core/intercom-broker-control.js +3 -3
  142. package/dist/core/package-manager-storage-adapters.code.js +1 -1
  143. package/dist/core/package-manager-storage-adapters.impl.js +3 -3
  144. package/dist/core/package-manager-storage-adapters.js +3 -3
  145. package/dist/core/process-start-token.d.ts +8 -0
  146. package/dist/core/process-tree-containment.d.ts +16 -0
  147. package/dist/core/sdk-types.d.ts +1 -2
  148. package/dist/core/sdk-types.js.map +1 -1
  149. package/dist/core/sdk.code.js +3 -3
  150. package/dist/core/sdk.impl.js +3 -3
  151. package/dist/core/sdk.js +3 -3
  152. package/dist/core/session-manager-core.js +5 -5
  153. package/dist/core/session-manager-list.impl.js +3 -3
  154. package/dist/core/session-manager-list.js +3 -3
  155. package/dist/core/session-manager.code.js +1 -1
  156. package/dist/core/session-manager.impl.js +3 -3
  157. package/dist/core/session-manager.js +3 -3
  158. package/dist/core/session-storage.code.js +1 -1
  159. package/dist/core/session-storage.impl.js +3 -3
  160. package/dist/core/session-storage.js +3 -3
  161. package/dist/core/settings-schema.d.ts +0 -3
  162. package/dist/core/storage/added-exports-0-10-11.js +19 -0
  163. package/dist/core/storage/added-exports-0-10-11.js.map +1 -0
  164. package/dist/core/storage/creation-time.js +105 -0
  165. package/dist/core/storage/creation-time.js.map +1 -0
  166. package/dist/core/storage/database.d.ts +19 -5
  167. package/dist/core/storage/database.js.map +1 -1
  168. package/dist/core/storage/dialect.d.ts +1 -1
  169. package/dist/core/storage/dialect.js +1 -1
  170. package/dist/core/storage/dialect.js.map +1 -1
  171. package/dist/core/storage/errors.d.ts +13 -13
  172. package/dist/core/storage/errors.js +10 -16
  173. package/dist/core/storage/errors.js.map +1 -1
  174. package/dist/core/storage/fenced-paths.d.ts +11 -0
  175. package/dist/core/storage/fenced-paths.js +11 -0
  176. package/dist/core/storage/fenced-paths.js.map +1 -1
  177. package/dist/core/storage/file-identity.d.ts +2 -0
  178. package/dist/core/storage/file-identity.js +24 -8
  179. package/dist/core/storage/file-identity.js.map +1 -1
  180. package/dist/core/storage/index.d.ts +3 -2
  181. package/dist/core/storage/index.js +5 -3
  182. package/dist/core/storage/index.js.map +1 -1
  183. package/dist/core/storage/libsql-removed.d.ts +71 -0
  184. package/dist/core/storage/libsql-removed.js +123 -0
  185. package/dist/core/storage/libsql-removed.js.map +1 -0
  186. package/dist/core/storage/migrations.d.ts +78 -14
  187. package/dist/core/storage/migrations.js +375 -49
  188. package/dist/core/storage/migrations.js.map +1 -1
  189. package/dist/core/storage/node-sqlite-file-gate.js +0 -15
  190. package/dist/core/storage/node-sqlite-file-gate.js.map +1 -1
  191. package/dist/core/storage/node-sqlite-thread.js +8 -13
  192. package/dist/core/storage/node-sqlite-thread.js.map +1 -1
  193. package/dist/core/storage/node-sqlite.js +51 -3
  194. package/dist/core/storage/node-sqlite.js.map +1 -1
  195. package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
  196. package/dist/core/storage/offline-snapshot-file.js +3 -3
  197. package/dist/core/storage/prefix.d.ts +1 -1
  198. package/dist/core/storage/prefix.js +9 -2
  199. package/dist/core/storage/prefix.js.map +1 -1
  200. package/dist/core/storage/process-selection.d.ts +5 -5
  201. package/dist/core/storage/provider.js +2 -2
  202. package/dist/core/storage/schema-catalog.d.ts +7 -8
  203. package/dist/core/storage/schema-catalog.js +8 -8
  204. package/dist/core/storage/schema-catalog.js.map +1 -1
  205. package/dist/core/storage/selection.d.ts +7 -82
  206. package/dist/core/storage/selection.js +20 -235
  207. package/dist/core/storage/selection.js.map +1 -1
  208. package/dist/core/storage/session/branch-fork-source.code.js +2 -2
  209. package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
  210. package/dist/core/storage/session/branch-fork-source.js +3 -3
  211. package/dist/core/storage/session/card-view.impl.js +3 -3
  212. package/dist/core/storage/session/card-view.js +3 -3
  213. package/dist/core/storage/session/child-reader.code.js +3 -3
  214. package/dist/core/storage/session/child-reader.impl.js +3 -3
  215. package/dist/core/storage/session/child-reader.js +3 -3
  216. package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
  217. package/dist/core/storage/session/chunked-resume-projection.js +3 -3
  218. package/dist/core/storage/session/expanded-child-details.code.js +2 -2
  219. package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
  220. package/dist/core/storage/session/expanded-child-details.js +3 -3
  221. package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
  222. package/dist/core/storage/session/fork-row-bytes.js +3 -3
  223. package/dist/core/storage/session/fork-row-index.impl.js +3 -3
  224. package/dist/core/storage/session/fork-row-index.js +3 -3
  225. package/dist/core/storage/session/fork-staging.code.js +4 -7
  226. package/dist/core/storage/session/fork-staging.code.js.map +1 -1
  227. package/dist/core/storage/session/fork-staging.impl.js +3 -3
  228. package/dist/core/storage/session/fork-staging.js +3 -3
  229. package/dist/core/storage/session/fork-window.code.js +3 -3
  230. package/dist/core/storage/session/fork-window.impl.js +3 -3
  231. package/dist/core/storage/session/fork-window.js +3 -3
  232. package/dist/core/storage/session/history-pages.impl.js +3 -3
  233. package/dist/core/storage/session/history-pages.js +3 -3
  234. package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
  235. package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
  236. package/dist/core/storage/session/jsonl-session-store.d.ts +5 -1
  237. package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
  238. package/dist/core/storage/session/jsonl-session-store.js +3 -3
  239. package/dist/core/storage/session/memory-session-store.impl.js +3 -3
  240. package/dist/core/storage/session/memory-session-store.js +3 -3
  241. package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
  242. package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
  243. package/dist/core/storage/session/pinned-branch-resume.js +3 -3
  244. package/dist/core/storage/session/released-history-files.code.js +3 -3
  245. package/dist/core/storage/session/released-history-files.impl.js +3 -3
  246. package/dist/core/storage/session/released-history-files.js +3 -3
  247. package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
  248. package/dist/core/storage/session/resident-fork-rows.js +3 -3
  249. package/dist/core/storage/session/session-resume.impl.js +3 -3
  250. package/dist/core/storage/session/session-resume.js +3 -3
  251. package/dist/core/storage/session/session-search-index.d.ts +43 -4
  252. package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
  253. package/dist/core/storage/session/snapshot-cut.js +3 -3
  254. package/dist/core/storage/session/snapshot-history.code.js +3 -3
  255. package/dist/core/storage/session/snapshot-history.impl.js +3 -3
  256. package/dist/core/storage/session/snapshot-history.js +3 -3
  257. package/dist/core/storage/session/sql-session-store.code.js +1 -1
  258. package/dist/core/storage/session/sql-session-store.d.ts +48 -11
  259. package/dist/core/storage/session/sql-session-store.impl.js +3 -3
  260. package/dist/core/storage/session/sql-session-store.js +3 -3
  261. package/dist/core/storage/session/tree-outline.impl.js +3 -3
  262. package/dist/core/storage/session/tree-outline.js +3 -3
  263. package/dist/core/storage/session/tree-presentation.impl.js +3 -3
  264. package/dist/core/storage/session/tree-presentation.js +3 -3
  265. package/dist/core/storage/sqlite-facade.d.ts +6 -1
  266. package/dist/core/storage/sqlite-facade.js +1 -0
  267. package/dist/core/storage/sqlite-facade.js.map +1 -1
  268. package/dist/core/storage/storage-status.code.js +1 -1
  269. package/dist/core/storage/storage-status.impl.js +3 -3
  270. package/dist/core/storage/storage-status.js +3 -3
  271. package/dist/core/storage/team.code.js +1 -1
  272. package/dist/core/storage/team.d.ts +26 -115
  273. package/dist/core/storage/team.impl.js +3 -3
  274. package/dist/core/storage/team.js +3 -3
  275. package/dist/core/structured-output/index.code.js +1 -1
  276. package/dist/core/structured-output/index.impl.js +3 -3
  277. package/dist/core/structured-output/index.js +3 -3
  278. package/dist/core/tasks/task-completion-entry.impl.js +3 -3
  279. package/dist/core/tasks/task-completion-entry.js +3 -3
  280. package/dist/core/tasks/task-file-history.code.js +3 -3
  281. package/dist/core/tasks/task-file-history.impl.js +3 -3
  282. package/dist/core/tasks/task-file-history.js +3 -3
  283. package/dist/core/tasks/task-reference-archive.code.js +4 -4
  284. package/dist/core/tasks/task-reference-archive.js +3 -3
  285. package/dist/core/tasks/task-reference-identity.js +3 -3
  286. package/dist/core/tasks/task-reference-stream.impl.js +3 -3
  287. package/dist/core/tasks/task-reference-stream.js +3 -3
  288. package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
  289. package/dist/core/tasks/task-unsaved-answer.js +3 -3
  290. package/dist/core/tasks/task-view-source.code.js +1 -1
  291. package/dist/core/tasks/task-view-source.impl.js +3 -3
  292. package/dist/core/tasks/task-view-source.js +3 -3
  293. package/dist/core/tools/history-tasks.d.ts +3 -2
  294. package/dist/core/tools/read-url.code.js +4 -4
  295. package/dist/core/tools/read-url.impl.js +3 -3
  296. package/dist/core/tools/read-url.js +3 -3
  297. package/dist/core/worktree-snapshot/blob-store.d.ts +40 -3
  298. package/dist/core/worktree-snapshot/blob-store.js +414 -21
  299. package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
  300. package/dist/core/worktree-snapshot/errors.code.js +2 -2
  301. package/dist/core/worktree-snapshot/errors.impl.js +3 -3
  302. package/dist/core/worktree-snapshot/errors.js +3 -3
  303. package/dist/core/worktree-snapshot/fork-blob-guard.js +81 -0
  304. package/dist/core/worktree-snapshot/fork-blob-guard.js.map +1 -0
  305. package/dist/core/worktree-snapshot/fork-snapshot-index.js +79 -38
  306. package/dist/core/worktree-snapshot/fork-snapshot-index.js.map +1 -1
  307. package/dist/core/worktree-snapshot/session-index-reset.code.js +4 -0
  308. package/dist/core/worktree-snapshot/session-index-reset.code.js.map +1 -1
  309. package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
  310. package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
  311. package/dist/extensions/codemode/execute.code.js +1 -1
  312. package/dist/extensions/codemode/execute.impl.js +3 -3
  313. package/dist/extensions/codemode/execute.js +3 -3
  314. package/dist/extensions/codemode/renderer.code.js +2 -2
  315. package/dist/extensions/codemode/renderer.impl.js +3 -3
  316. package/dist/extensions/codemode/renderer.js +3 -3
  317. package/dist/extensions/mcp/cli.code.js +3 -3
  318. package/dist/extensions/mcp/cli.impl.js +3 -3
  319. package/dist/extensions/mcp/cli.js +3 -3
  320. package/dist/extensions/mcp/cli.lazy.code.js +2 -2
  321. package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
  322. package/dist/extensions/mcp/cli.lazy.js +3 -3
  323. package/dist/extensions/mcp/runtime.code.js +1 -1
  324. package/dist/extensions/mcp/runtime.impl.js +3 -3
  325. package/dist/extensions/mcp/runtime.js +3 -3
  326. package/dist/index.d.ts +3 -1
  327. package/dist/index.js +5 -5
  328. package/dist/main-first-time-setup.code.js +1 -1
  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/stored-tree-view.code.js +2 -2
  333. package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
  334. package/dist/modes/interactive/components/stored-tree-view.js +3 -3
  335. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
  336. package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
  337. package/dist/modes/interactive/startup-shell-eligibility.js +1 -1
  338. package/dist/modes/interactive-engine/engine-prewarm.d.ts +1 -1
  339. package/dist/modes/print-mode.js +1 -1
  340. package/dist/package-manager-cli.code.js +6 -6
  341. package/dist/package-manager-cli.impl.js +3 -3
  342. package/dist/package-manager-cli.js +3 -3
  343. package/dist/rpc-entry.js +1 -1
  344. package/dist/startup-files.json +1 -1
  345. package/dist/startup-stages/10.js +1 -1
  346. package/dist/startup-stages/11.js +1 -1
  347. package/dist/startup-stages/12.js +1 -1
  348. package/dist/startup-stages/2.js +2 -4
  349. package/dist/startup-stages/3.js +1 -3
  350. package/dist/startup-stages/4.js +1 -2
  351. package/dist/startup-stages/5.js +1 -1
  352. package/dist/startup-stages/6.js +5 -7
  353. package/dist/startup-stages/7.js +3 -10
  354. package/dist/startup-stages/8.js +7 -2
  355. package/dist/startup-stages/9.js +1 -7
  356. package/dist/startup-stages/stages.json +1 -1
  357. package/dist/utils/compile-cache-deferral.js +8 -13
  358. package/dist/utils/compile-cache-deferral.js.map +1 -1
  359. package/dist/utils/compile-cache-warmup-host.js +3 -4
  360. package/dist/utils/compile-cache-warmup-host.js.map +1 -1
  361. package/dist/utils/compile-cache.js +12 -100
  362. package/dist/utils/compile-cache.js.map +1 -1
  363. package/dist/utils/startup-database-spare.code.js +2 -2
  364. package/dist/utils/startup-database-spare.impl.js +3 -3
  365. package/dist/utils/startup-database-spare.js +3 -3
  366. package/dist/utils/tools-manager.code.js +1 -1
  367. package/dist/utils/tools-manager.impl.js +3 -3
  368. package/dist/utils/tools-manager.js +3 -3
  369. package/dist/utils/worker-threads.js +2 -15
  370. package/dist/utils/worker-threads.js.map +1 -1
  371. package/docs/build.md +3 -3
  372. package/docs/changelog.mdx +1421 -69
  373. package/docs/compaction/reference.md +5 -5
  374. package/docs/compaction.md +7 -9
  375. package/docs/containerization.md +2 -2
  376. package/docs/custom-provider/api-reference.md +1 -1
  377. package/docs/docs.json +37 -10
  378. package/docs/environment-variables.md +0 -2
  379. package/docs/extensions/api-reference.md +4 -4
  380. package/docs/getting-started/installation.md +3 -0
  381. package/docs/guides/configuration.md +1 -1
  382. package/docs/guides/non-interactive.md +1 -1
  383. package/docs/guides/resume-on-any-machine.md +14 -22
  384. package/docs/guides/team-setup.md +56 -83
  385. package/docs/guides.md +2 -4
  386. package/docs/herdr.md +1 -1
  387. package/docs/index.md +1 -1
  388. package/docs/intercom/operations.md +26 -21
  389. package/docs/intercom/reference.md +2 -2
  390. package/docs/intercom.md +1 -1
  391. package/docs/libraries/storage-postgres.md +9 -9
  392. package/docs/libraries.md +2 -3
  393. package/docs/models-configuration.md +2 -2
  394. package/docs/models.md +2 -3
  395. package/docs/packages/authoring.md +7 -7
  396. package/docs/packages.md +1 -1
  397. package/docs/programmatic.md +2 -2
  398. package/docs/quickstart.md +1 -1
  399. package/docs/reference/cli.md +6 -11
  400. package/docs/reference.md +2 -2
  401. package/docs/rpc/extension-ui.md +2 -2
  402. package/docs/sdk/reference.md +5 -4
  403. package/docs/sdk/storage.md +8 -92
  404. package/docs/sdk/structured-decisions.md +1 -1
  405. package/docs/sdk/web-server.md +3 -3
  406. package/docs/sdk.md +14 -4
  407. package/docs/security.md +1 -1
  408. package/docs/session-format.md +5 -5
  409. package/docs/sessions.md +29 -49
  410. package/docs/settings.md +7 -8
  411. package/docs/storage/custom-adapters.md +255 -0
  412. package/docs/storage/jsonl.md +117 -0
  413. package/docs/{guides/postgres-pgbouncer.md → storage/postgres/pgbouncer.md} +66 -68
  414. package/docs/storage/postgres/tuning.md +337 -0
  415. package/docs/storage/postgres.md +556 -0
  416. package/docs/storage/sqlite.md +99 -0
  417. package/docs/storage.md +326 -990
  418. package/docs/subagents/authoring.md +1 -1
  419. package/docs/subagents.md +2 -2
  420. package/docs/tools.md +1 -1
  421. package/docs/worktree-snapshots.md +2 -2
  422. package/package.json +9 -9
  423. package/schemas/models.schema.json +2 -2
  424. package/schemas/settings.schema.json +0 -14
  425. package/dist/_shared/sdk-IQMULKFU.js.map +0 -1
  426. package/dist/_shared/startup-0-0-3IXNMFM2.js.map +0 -1
  427. package/dist/_shared/startup-0-1-7T2IAE7J.js.map +0 -1
  428. package/dist/_shared/startup-8-1-X32CYSXB.js.map +0 -1
  429. package/dist/core/intercom-broker-control.d.ts +0 -129
  430. package/dist/startup-stages/13.js +0 -1
  431. package/docs/guides/postgres-tuning.md +0 -311
  432. package/docs/libraries/storage-libsql.md +0 -97
package/docs/sessions.md CHANGED
@@ -6,7 +6,7 @@ description: "Resume, search, name, branch, fork, share, and export conversation
6
6
 
7
7
  Atomic saves every conversation as an append-only tree in a local SQLite database (`~/.atomic/workflows/journal.sqlite` by default). You can resume past work, jump back to earlier turns, and branch without losing history. For branch summaries and context clearing, see [Context and compaction](/compaction#branch-summarization).
8
8
 
9
- - To configure SQLite, PostgreSQL, Turso/libSQL, or custom adapters, see [Storage backends](/storage).
9
+ - To choose where sessions are stored, such as a shared PostgreSQL database, see [Storage](/storage).
10
10
  - To resume sessions across machines with worktree snapshots and blueprints, see [Resume sessions on any machine](/guides/resume-on-any-machine).
11
11
  - To open and pass session stores from Node.js or TypeScript, see [SDK session storage](/sdk/storage).
12
12
  - For JSONL schemas, entry types, and the `SessionManager` API, see [Session file format](/session-format).
@@ -176,17 +176,13 @@ Type anywhere in `/tree` to filter entries through the inline search bar.
176
176
  | Typical use | Explore alternatives in place | Branch from an earlier prompt | Duplicate current path before continuing |
177
177
  | Summary | Optional branch summary | None | None |
178
178
 
179
- `/fork` and `/clone` copy the active path, including worktree snapshots, into a new session.
179
+ `/fork` and `/clone` start a new session from the active path, including its worktree snapshots. `atomic --fork <id>`, choosing **Fork** for a session whose directory is missing, and the SDK's `forkTo()` into the same store take every branch.
180
180
 
181
- `atomic --fork <id>`, missing-cwd **Fork**, and same-store SDK `forkTo()` copy all branches. Cross-store forks copy only current context without retired turns or private task records, and reopening warns `Parent history is in its original store or is no longer available.`. For full portable backups of all branches, use `atomic storage export` and `atomic storage import`.
181
+ A fork into another store, such as an SDK `forkTo()` that names a different store, carries only the current context, without retired turns or private task records. Reopening it shows `Parent history is in its original store or is no longer available.` To move every branch of a session to another store, use `atomic storage export` and `atomic storage import`.
182
182
 
183
- ### Forks share history within a store {#forks-share-history}
183
+ ### Shared-history forks {#forks-share-history}
184
184
 
185
- In a SQLite, PostgreSQL, or libSQL store, a fork shares the history it was forked from instead of copying it. A fork of a long session is created as quickly as a fork of a short one. The fork reads and resumes exactly as a copy would, and later changes to the parent never show up in it. A store starts sharing on its own; see [shared-history forks](/storage#shared-history-forks) for when it waits, for example while an older Atomic still has a session open. JSONL and in-memory stores always copy.
186
-
187
- Deleting a session that forks still share history with removes it from every list and search right away. The store keeps the part of its history those forks use, and frees it once the last of them is deleted or no longer needs it. Rewriting such a session first gives each fork its own copy of what it uses.
188
-
189
- Sharing never crosses a store boundary. Anything that takes a session out of its store makes a full standalone copy: `/export`, `/share`, `atomic --export`, `atomic storage export`, a fork into another store, and moving sessions between stores. The copy holds every entry and tool output the session inherited, and it doesn't need the sessions it was forked from. Importing a session always writes it as a standalone session, never as a fork of anything in the target store.
185
+ In a SQLite or PostgreSQL store, a fork shares the history it starts from with the original session instead of copying it, so forking a long session is about as fast as forking a short one. A fork still behaves exactly like a copy: later changes to the original never show up in it, and deleting the original never changes it. Exports and forks into another store write full copies. JSONL and in-memory stores always copy. On SQLite there is nothing to set up. On PostgreSQL, the owner runs `atomic storage migrate` once. Atomic 0.10.11 upgrades the store so that earlier releases can no longer open it. See [Shared-history forks](/storage#shared-history-forks).
190
186
 
191
187
  ## Branch summaries
192
188
 
@@ -204,7 +200,7 @@ The agent can inspect past project sessions from any session or subagent using r
204
200
 
205
201
  - **Search behavior.** Searching `history://sessions` or `history://` scans the newest 25 sessions per page, excludes the current session (search the current session through its own ID URL), skips `custom` and `worktree_snapshot` entries, and caps output at 10 matches per session. Extra matches include a `?cursor=<seq>.<match>` continuation. Multi-line patterns match across up to 16,384 characters or 256 entries, with the same window for lookbehind, and matches crossing that boundary note the cutoff. After compaction, the boundary message gives the exact session URL and range to recover earlier details ([Context cleared](/compaction#context-cleared)).
206
202
  - **Budgets and continuations.** Every `history://` call enforces a 40,000-byte output cap, a 250,000-entry scan cap, and a 3-second nominal time budget. A call in a session that moves to the background has no time limit instead, as described in [Slow history searches](#slow-history-searches). When a call stops early, it returns a `continue with` URL containing `cursor`, `after=<activityMs>.<createdMs>[.<id>]`, and an optional `session=<id>`. Pass that URL unchanged; list continuations expire after 60 seconds.
207
- - **Indexing and storage.** SQLite, libSQL, and PostgreSQL build a trigram index on first search. PostgreSQL installs `pg_trgm` during `atomic storage migrate` or on open when permissions allow. Multi-line patterns scan linearly. The index roughly doubles text-heavy session storage and clears automatically when sessions are deleted or rewritten (`VACUUM` or `VACUUM FULL` reclaims disk space). Never edit active JSONL files in place outside Atomic's storage APIs.
203
+ - **Indexing and storage.** SQLite and PostgreSQL build a search index on the first search. PostgreSQL installs `pg_trgm` during `atomic storage migrate` or on open when permissions allow. Multi-line patterns scan linearly. The index roughly doubles text-heavy session storage and clears automatically when sessions are deleted or rewritten (`VACUUM` or `VACUUM FULL` reclaims disk space). Never edit active JSONL files in place outside Atomic's storage APIs.
208
204
 
209
205
  ### Slow history searches {#slow-history-searches}
210
206
 
@@ -268,59 +264,43 @@ This command writes no `-wal` or `-shm` files on cleanly closed databases and st
268
264
 
269
265
  ## Session storage
270
266
 
271
- Sessions auto-save to `~/.atomic/workflows/journal.sqlite` unless you configure a different store.
267
+ Atomic saves sessions as you go, by default in a local SQLite file, `~/.atomic/workflows/journal.sqlite`. [Storage](/storage) covers every store, sharing sessions between machines, and moving sessions between stores.
272
268
 
273
- - **Legacy sessions.** Under the default SQLite store, earlier JSONL sessions in `~/.atomic/agent/sessions` (formats 1 through 3 and older format-4 files) still appear in `/resume` and `--continue`. Opening one imports a copy into SQLite without modifying the original file. If sync conflict copies exist, the newest message wins. Unopened files over 32 KiB display an estimated summary until opened. Selecting a custom store shows only that store.
274
- - **Project trust and resume hints.** Project-local storage settings apply after project trust approval. New conversations switch before saving, while resumed conversations stay in their original store. Keep generated `--session-dir`, `--session-store`, or `--session-prefix` flags when reopening non-default stores, such as `atomic --session-store "/data/project A/sessions.sqlite" --session-prefix project_ --session <id>`.
275
- - **Import and export.** `--import <file>` or `/import <file>` imports a JSONL export verbatim, including [worktree snapshots](/worktree-snapshots) written by `/export <file>.jsonl`. Import upgrades older supported formats automatically and raises `SessionExistsError` if the ID already exists. Empty imported IDs reopen through `atomic --session ""` or the picker.
276
- - **Ephemeral runs (`--no-session`).** Nothing is saved to a resumable store. When an idle subagent is unloaded from memory during `--no-session`, its history is temporarily saved to a private file in your agent directory and removed on exit; stale files left after a crash are cleaned up on a later startup on the same host. See [Releasing idle sessions](/sdk#releasing-idle-sessions).
277
- - **Forks share history.** A fork in the same store reads the history it keeps from its parent instead of storing a copy, so forking a long session is about as fast as forking a short one. The first time this release opens a store, it marks the store so that older Atomic releases can no longer open it; it waits to do so until no session of an older release is running on that database. See [Shared-history forks](/storage#shared-history-forks).
278
- - **Session stats (`/session`).** Displays the session ID, message count, tokens, and cost. Counts update after each completed message, and per-model cost and cache breakdowns appear once history matches totals.
269
+ - **Sessions from older releases.** With the default store, JSONL sessions from earlier releases in `~/.atomic/agent/sessions` still appear in `/resume` and `--continue`. Opening one imports a copy into SQLite and leaves the original file unchanged. If a sync tool left conflicting copies of a file, the newest message wins. An unopened file over 32 KiB shows an estimated summary until you open it. With any other store, only that store's sessions appear.
270
+ - **Project settings.** A project's storage settings apply once you [trust the project](/security). New conversations then use the project's store, while resumed conversations stay in the store they came from. To reopen a session in a store that is not your default, keep the flags Atomic prints, for example `atomic --session-store "/data/project A/sessions.sqlite" --session-prefix project_ --session <id>`.
271
+ - **Importing a file.** `--import <file>` or `/import <file>` imports a JSONL export as it is, including the [worktree snapshots](/worktree-snapshots) that `/export <file>.jsonl` wrote. It upgrades older formats, and fails with `SessionExistsError` if the store already has a session with that ID. A session imported with an empty ID reopens with `atomic --session ""` or from the picker.
272
+ - **Nothing saved (`--no-session`).** Nothing goes to a store you can resume from. If Atomic unloads an idle subagent from memory in this mode, it keeps the subagent's history in a private temporary file in your agent directory, and deletes it on exit. A later start on the same machine removes files left by a crash. See [Releasing idle sessions](/sdk#releasing-idle-sessions).
273
+ - **Forks share history.** See [Shared-history forks](#forks-share-history).
274
+ - **Session stats (`/session`).** Shows the session ID, message count, tokens, and cost. The counts update after each completed message.
279
275
 
280
276
  ### Choosing a store
281
277
 
282
- Configure `sessions.storage` (sessions only) or top-level `storage` (shared default for sessions and Intercom) in `settings.json`:
278
+ Set `sessions.storage` to choose a store for sessions only, or top-level `storage` to choose one for sessions and Intercom together. For example, in `settings.json`:
283
279
 
284
280
  ```json
285
281
  {
286
282
  "sessions": {
287
- "storage": { "dir": "sessions" }
283
+ "storage": { "path": "sessions.sqlite" }
288
284
  }
289
285
  }
290
286
  ```
291
287
 
292
- Supported store objects:
293
-
294
- - `{ "path": "sessions.sqlite" }`: local SQLite database. Works in both `sessions.storage` and `storage`.
295
- - `{ "dir": "sessions" }`: JSONL directory store. Allowed **only** in `sessions.storage` and `ATOMIC_SESSIONS_STORAGE`. Passing `"dir"` in top-level `storage`, `--storage`, `--storage-file`, or `ATOMIC_STORAGE` fails with `StorageConfigError`.
296
- - `{ "memory": true }`: ephemeral in-memory store.
297
- - `{}` (empty object): selects the default session SQLite file (`<storageHome>/workflows/journal.sqlite`) in `sessions.storage` (overriding any shared `storage`), or `<storageHome>/storage.sqlite` in top-level `storage`.
298
- - Database adapter: [PostgreSQL](/storage#postgresql), [Turso and libSQL](/storage#turso-and-libsql), or a [custom adapter](/storage#selecting-an-adapter).
299
-
300
- Legacy `sessionDir` has been removed.
301
-
302
- Store selection follows this precedence order, from highest to lowest:
303
-
304
- 1. Explicit SDK `sessionManager` (bypasses store selection)
305
- 2. SDK `sessionStore`
306
- 3. SDK `createAgentSession({ storage })`
307
- 4. `--session-store`, `--no-session`, or `--session-dir`
308
- 5. `--storage` or `--storage-file`
309
- 6. `ATOMIC_SESSIONS_STORAGE` or `ATOMIC_CODING_AGENT_SESSION_DIR`
310
- 7. `ATOMIC_STORAGE`
311
- 8. `ATOMIC_PROFILE=ci`
312
- 9. `sessions.storage` in `settings.json`
313
- 10. `storage` in `settings.json`
314
- 11. Default local SQLite (`~/.atomic/workflows/journal.sqlite`)
288
+ | Value | Store |
289
+ | --- | --- |
290
+ | `{ "path": "sessions.sqlite" }` | A [local SQLite](/storage/sqlite) file. |
291
+ | `{ "dir": "sessions" }` | A [JSONL directory](/storage/jsonl). Only in `sessions.storage` and `ATOMIC_SESSIONS_STORAGE`. |
292
+ | `{ "memory": true }` | Memory only. Sessions are lost when the process exits. |
293
+ | `{}` | The default SQLite file. In top-level `storage`, `~/.atomic/storage.sqlite`. |
294
+ | `{ "adapter": "...", "options": {}, "secrets": {} }` | A database through an adapter: [PostgreSQL](/storage/postgres) or a [custom adapter](/storage/custom-adapters#selecting-an-adapter). |
315
295
 
316
- Each selection replaces lower-precedence settings as a whole object rather than merging fields. Settings, JSON flags, and JSON environment variables resolve relative paths from [storage home](/storage#storage-home). `--session-dir`, `--session-store`, and `ATOMIC_CODING_AGENT_SESSION_DIR` resolve relative paths from `cwd`.
296
+ A selection replaces any lower one as a whole object. Fields are never merged. Command-line flags and environment variables can override these settings for one process. [Which selection wins](/storage#which-selection-wins) lists the order. Relative paths in settings and JSON values resolve against the [storage home](/storage#storage-home). Relative paths in `--session-dir`, `--session-store`, and `ATOMIC_CODING_AGENT_SESSION_DIR` resolve against the current directory.
317
297
 
318
- Flag validation rules:
298
+ Flag rules:
319
299
 
320
- - `--session-store` conflicts with `--session-dir` and `--no-session`.
321
- - Combining a non-empty `ATOMIC_CODING_AGENT_SESSION_DIR` with `ATOMIC_SESSIONS_STORAGE`, `--storage`, or `--storage-file` fails startup with `StorageConfigError` (`conflicting-overrides`).
322
- - `--session-prefix` requires `--session-store` (local SQLite only) and must match `[A-Za-z_][A-Za-z0-9_]*` without starting with `sqlite_` (case-insensitive, so `SQLITE_` is also rejected). Shared databases use `storage.prefix` or `atomic storage join --prefix` with the same pattern; PostgreSQL also requires lowercase ASCII and at most 24 characters.
323
- - Invalid CLI storage flags exit cleanly with `Error: ...` (exit code `1`). Invalid or unavailable stores always raise a typed error instead of falling back to memory. See [Selecting storage per process](/storage#selecting-storage-per-process).
300
+ - `--session-store` cannot be combined with `--session-dir` or `--no-session`.
301
+ - A non-empty `ATOMIC_CODING_AGENT_SESSION_DIR` cannot be combined with `ATOMIC_SESSIONS_STORAGE`, `--storage`, or `--storage-file`. Startup fails with `StorageConfigError` and reason `conflicting-overrides`.
302
+ - `--session-prefix` works only with `--session-store`, for a local SQLite file. The prefix must match `[A-Za-z_][A-Za-z0-9_]*` and must not start with `sqlite_` in any letter case. For a shared database, set `prefix` in the `storage` setting, or pass `atomic storage join --prefix`. PostgreSQL prefixes must also be lowercase and at most 24 characters.
303
+ - Invalid storage flags stop the CLI with `Error: ...` and exit code `1`. A store that is invalid or cannot be opened always raises an error. Atomic never falls back to memory.
324
304
 
325
305
  From the SDK, `sessionStore` accepts all five selection kinds (`{ kind: "sqlite", path, prefix? }`, `{ kind: "jsonl", dir }`, `{ kind: "memory" }`, `{ kind: "database", database, prefix? }`, and `{ kind: "adapter", module, options?, secrets?, prefix? }`) or a concrete `SessionStore` instance (`SqlSessionStore`, `JsonlSessionStore`, or `MemorySessionStore`). Passing an explicit `sessionManager` bypasses store selection:
326
306
 
@@ -330,4 +310,4 @@ const { session } = await createAgentSession({
330
310
  });
331
311
  ```
332
312
 
333
- See [SDK session storage](/sdk/storage) for PostgreSQL, libSQL, direct `SessionStore`, and store-closing recipes, [SDK and local SQLite API](/storage#sdk-and-local-sqlite-api) for low-level SQLite handles, and [Session file format](/session-format) for JSONL schemas, entry types, and the `SessionManager` API.
313
+ See [SDK session storage](/sdk/storage) for PostgreSQL, direct `SessionStore`, and store-closing recipes, [SDK and local SQLite API](/storage/sqlite#sdk-and-local-sqlite-api) for low-level SQLite handles, and [Session file format](/session-format) for JSONL schemas, entry types, and the `SessionManager` API.
package/docs/settings.md CHANGED
@@ -271,7 +271,6 @@ Atomic manages these keys automatically in global `settings.json`. Leave them un
271
271
  | `firstRunOnboardingStartedVersion` | string | unset | Version when first-run onboarding started |
272
272
  | `onboardedVersion` | string | unset | Version when onboarding completed |
273
273
  | `lastChangelogVersion` | string | unset | Most recent version whose changelog notice was displayed |
274
- | `teamJoin` | object | unset | `atomic team join` record used by `atomic team leave` |
275
274
  | `enableAnalytics` | boolean | `false` | Opt-in flag saved during first-run setup (storage only; Atomic does not transmit analytics) |
276
275
  | `trackingId` | string | unset | Locally generated analytics ID when `enableAnalytics` is enabled |
277
276
  | `deviceId` | string | unset | Global install ID created when a provider sign-in needs one (project values ignored) |
@@ -431,19 +430,19 @@ On Windows, write JSON paths with forward slashes or escaped backslashes:
431
430
  ```
432
431
 
433
432
  - **Default.** `~/.atomic/workflows/journal.sqlite` (`session_` tables; under `<agentDir>/workflows/` when `ATOMIC_CODING_AGENT_DIR` is set unless it adopted a parent store; see [Storage home](/storage#storage-home)). JSONL is opt-in via `dir`, `--session-dir`, or `ATOMIC_CODING_AGENT_SESSION_DIR` (legacy `sessionDir` was removed).
434
- - **Precedence.** Highest to lowest: SDK `sessionStore`, SDK `storage` (`createAgentSession({ storage })`, see [SDK storage](/sdk/storage)), `--no-session`, `--session-dir`, or `--session-store`, `--storage` or `--storage-file`, `ATOMIC_SESSIONS_STORAGE` or `ATOMIC_CODING_AGENT_SESSION_DIR`, `ATOMIC_STORAGE`, `ATOMIC_PROFILE=ci`, `sessions.storage`, `storage`, and default SQLite. Project selections replace global objects whole rather than merging; an explicit `{}` on `sessions.storage` selects default SQLite rather than inheriting `storage`. Relative paths in settings and JSON flags or env vars resolve from [storage home](/storage#storage-home); `--session-dir`, `--session-store`, and `ATOMIC_CODING_AGENT_SESSION_DIR` resolve from `cwd`. See [Storage and team variables](/environment-variables#storage-and-team-variables).
435
- - **Errors.** Only the winning setting is validated from `settings.json`, whereas process-level selections (`--storage`, `--storage-file`, `ATOMIC_STORAGE`, `ATOMIC_SESSIONS_STORAGE`, and `ATOMIC_PROFILE=ci` with `ATOMIC_TEAM_*`) are validated unconditionally even when outranked. Invalid config throws `StorageConfigError` (`source`, `field`, `reason`) or `TeamProfileConfigError`, and open failures throw typed errors without falling back to memory. See [Choosing a store](/sessions#choosing-a-store), [Selecting storage per process](/storage#selecting-storage-per-process), and [Storage errors](/storage#storage-errors).
433
+ - **Precedence.** Highest to lowest: SDK `sessionStore`, SDK `storage` (`createAgentSession({ storage })`, see [SDK storage](/sdk/storage)), `--no-session`, `--session-dir`, or `--session-store`, `--storage` or `--storage-file`, `ATOMIC_SESSIONS_STORAGE` or `ATOMIC_CODING_AGENT_SESSION_DIR`, `ATOMIC_STORAGE`, `sessions.storage`, `storage`, and default SQLite. Project selections replace global objects whole rather than merging; an explicit `{}` on `sessions.storage` selects default SQLite rather than inheriting `storage`. Relative paths in settings and JSON flags or env vars resolve from [storage home](/storage#storage-home); `--session-dir`, `--session-store`, and `ATOMIC_CODING_AGENT_SESSION_DIR` resolve from `cwd`. See [Storage and team variables](/environment-variables#storage-and-team-variables).
434
+ - **Errors.** Only the winning setting is validated from `settings.json`, whereas process-level selections (`--storage`, `--storage-file`, `ATOMIC_STORAGE`, and `ATOMIC_SESSIONS_STORAGE`) are validated unconditionally even when outranked. A selection naming the removed `@bastani/atomic-storage-libsql` adapter, or a variable of the removed `ATOMIC_PROFILE=ci` team profile, fails with `libsql-removed` (see [Moving off libSQL](/storage#moving-off-libsql)). Invalid config throws `StorageConfigError` (`source`, `field`, `reason`) or `TeamProfileConfigError`, and open failures throw typed errors without falling back to memory. See [Choosing a store](/sessions#choosing-a-store), [Selecting storage per process](/storage#selecting-storage-per-process), and [Storage errors](/storage#storage-errors).
436
435
 
437
436
  #### Storage adapters
438
437
 
439
- Install an adapter [Atomic package](/storage#adapters-from-atomic-packages) (such as [`@bastani/atomic-storage-postgres`](/libraries/storage-postgres) or [`@bastani/atomic-storage-libsql`](/libraries/storage-libsql)), or pass its directory via `--extension` or SDK `additionalExtensionPaths` (which takes precedence over settings), and reference it in `storage` or `sessions.storage`:
438
+ Install an adapter [Atomic package](/storage/custom-adapters#adapters-from-atomic-packages) (such as [`@bastani/atomic-storage-postgres`](/libraries/storage-postgres)), or pass its directory via `--extension` or SDK `additionalExtensionPaths` (which takes precedence over settings), and reference it in `storage` or `sessions.storage`:
440
439
 
441
440
  ```json
442
441
  {
443
442
  "storage": {
444
- "adapter": "@example/atomic-sqlite",
445
- "options": { "url": "libsql://database.example" },
446
- "secrets": { "authToken": { "env": "DATABASE_TOKEN" } },
443
+ "adapter": "@bastani/atomic-storage-postgres",
444
+ "options": { "url": "postgresql://atomic@db.example.com:5432/atomic" },
445
+ "secrets": { "password": { "env": "ATOMIC_DB_PASSWORD" } },
447
446
  "prefix": "project_"
448
447
  }
449
448
  }
@@ -451,7 +450,7 @@ Install an adapter [Atomic package](/storage#adapters-from-atomic-packages) (suc
451
450
 
452
451
  - An empty shared `storage: {}` uses `<storageHome>/storage.sqlite`.
453
452
  - `secrets` accepts `{ "env": "VAR" }` or `{ "file": "token.txt" }` (relative paths resolve from [storage home](/storage#storage-home), falling back to parent if an existing file lives there; one trailing `\n` or `\r\n` is stripped).
454
- - Adapter modules execute code; review them before trusting project settings. See [Selecting an adapter](/storage#selecting-an-adapter).
453
+ - Adapter modules execute code; review them before trusting project settings. See [Selecting an adapter](/storage/custom-adapters#selecting-an-adapter).
455
454
 
456
455
  ### Snapshots
457
456
 
@@ -0,0 +1,255 @@
1
+ ---
2
+ title: "Custom storage adapters"
3
+ sidebarTitle: "Custom adapters"
4
+ description: "Select a storage adapter, ship one in an Atomic package, wrap your own SQL driver, implement a session store, and test it with the conformance suites."
5
+ ---
6
+
7
+ This page is for developers who want Atomic to keep sessions in a database it does not support out of the box. You do that with a **storage adapter**: a JavaScript or TypeScript module that opens a connection to your database and hands it to Atomic. Atomic's own [PostgreSQL](/storage/postgres) support is an adapter too. Only the built-in SQLite, JSONL, and in-memory stores work without one.
8
+
9
+ What kind of adapter you write depends on your database:
10
+
11
+ - **A SQL database that runs SQLite's SQL**, such as a SQLite-compatible server, returns a `SqliteDatabase` from `openDatabase`. Atomic then keeps sessions and Intercom there. Atomic sends SQLite SQL to such an adapter, so the database must run it, or the adapter must translate it.
12
+ - **Any other database** implements `openSessionStore` instead. It holds sessions only, so Intercom cannot route between machines through it.
13
+
14
+ The page covers selecting an adapter, shipping one in an Atomic package, wrapping your own database driver, and testing the result.
15
+
16
+ ## Selecting an adapter
17
+
18
+ A storage adapter is a module whose default export satisfies `StorageAdapterModule`:
19
+
20
+ ```typescript
21
+ import type { StorageAdapterModule } from "@bastani/atomic/storage";
22
+
23
+ export default {
24
+ atomicStorageAdapter: 1,
25
+ async openDatabase(options, context) {
26
+ return openMyDatabase({ url: String(options.url), authToken: String(options.authToken) });
27
+ },
28
+ } satisfies StorageAdapterModule;
29
+ ```
30
+
31
+ Here `openMyDatabase` stands for your own code that connects to the database. [Custom driver adapter example](#custom-driver-adapter-example) shows a complete one.
32
+
33
+ Select an adapter in `sessions.storage` or top-level `storage` in [settings](/settings#sessions), or pass `sessionStore: { kind: "adapter", module, options, secrets, prefix }` in the SDK. Relative module paths resolve from the agent directory (`~/.atomic/agent` by default). Bare package names resolve from user-scope [Atomic packages](#adapters-from-atomic-packages), host extension directories, or the agent directory, never from an embedding application's `node_modules`. Project settings follow the project trust boundary, and adapter code runs with Atomic's privileges.
34
+
35
+ Choose the installation method that matches how you open the adapter:
36
+
37
+ - **Direct SDK database handles (`{ kind: "database", database }`).** Install the package in your project with `npm install`, call the adapter's open function, such as `openPostgresDatabase()`, and pass the handle to `sessionStore: { kind: "database", database, prefix? }` or `SqlSessionStore.open(database, { prefix? })`. See [SDK session storage](/sdk/storage).
38
+ - **Adapter-resolved selections (`{ kind: "adapter", module }`, `settings.json`, or `ATOMIC_STORAGE`).** Install the package in user scope with `atomic install npm:<package>` (without `-l`), or register a local package directory with `DefaultResourceLoader({ additionalExtensionPaths })` or `--extension`.
39
+
40
+ Adapter modules can import `@bastani/atomic/storage` and `@bastani/atomic` directly in both npm installs and standalone binaries. This works for the adapter entry file and any ES module or TypeScript file it imports relatively (including `.mjs` files and `.js` files in `"type": "module"` packages). CommonJS files outside the entry file resolve from `node_modules` instead. List `@bastani/atomic` under `peerDependencies`, not `dependencies`.
41
+
42
+ `options` holds strings, numbers, booleans, or `null`. `secrets` maps secret names to `{ env }`, `{ file }`, or (in the SDK only) `inMemorySecret(value)` (`{ value }`), overriding same-named keys in `options`. Atomic strips one trailing `\n` or `\r\n` from `{ file }` secrets and keeps other whitespace intact. `inMemorySecret()` serializes as `[redacted]` and is refused outside the SDK (`in-memory-secret-unsupported`).
43
+
44
+ `context` provides `agentDir`, `domain: "sessions" | "intercom"`, an optional `signal`, and `secret(name)` to reread `secrets[name]` on demand. An adapter that reads fresh credentials for each new connection (such as a rotated password file) declares `liveSecrets` on its `StorageAdapterModule` (for example `liveSecrets: ["password"]`). Atomic omits names listed in `liveSecrets` from `options` and expects the adapter to call `context.secret(name)`, which throws `StorageConfigError` (`reason: "secret-missing"`) when the secret is missing from `secrets`.
45
+
46
+ Adapter hooks and lifecycle:
47
+
48
+ - Implement `openDatabase(options, context): Promise<SqliteDatabase>` for SQL-backed adapters so Atomic manages schemas, prefixes, and Intercom tables.
49
+ - Implement `openSessionStore(options, context, { prefix? })` for non-SQL session stores. When both hooks exist, `openSessionStore` takes priority for sessions.
50
+ - Missing hooks raise `StorageConfigError` (`reason: "adapter-domain-unsupported"`). Load failures raise `StorageAdapterLoadError`, and driver open failures raise `StorageUnavailableError`.
51
+ - `new StorageProvider().openSessionStore(selection, context)` opens stores programmatically (`kind`: `"memory"`, `"jsonl"`, `"sqlite"`, `"database"`, or `"adapter"`). `loadStorageAdapter(module, context, hostModules)` loads an adapter module.
52
+ - `StorageProvider` instances share one process-wide map of provider-owned databases across matching selections and close each owned database when its last returned store closes. Caller-owned `database` handles passed through `{ kind: "database", database }` are never closed by the provider.
53
+ - If opening storage fails and closing its owned database also fails, Atomic throws the original opening error with a `cleanupCause` field holding the cleanup failure.
54
+
55
+ ### Adapters from Atomic packages
56
+
57
+ An [Atomic package](/packages) can bundle storage adapters and their driver dependencies by listing adapter paths under `atomic.storageAdapters` in `package.json`:
58
+
59
+ ```json
60
+ {
61
+ "name": "@example/atomic-mydb",
62
+ "dependencies": { "mydb-client": "^2.0.0" },
63
+ "peerDependencies": { "@bastani/atomic": "*" },
64
+ "atomic": { "storageAdapters": ["./mydb-adapter.ts"] }
65
+ }
66
+ ```
67
+
68
+ Install the package with `atomic install npm:@example/atomic-mydb` and select it by package name:
69
+
70
+ ```json
71
+ {
72
+ "storage": {
73
+ "adapter": "@example/atomic-mydb",
74
+ "options": { "url": "mydb://db.example.com/atomic" },
75
+ "secrets": { "authToken": { "file": "mydb-token" } }
76
+ }
77
+ }
78
+ ```
79
+
80
+ The bare package name selects the first listed adapter. When a package exports several adapters, select one with `<package>/<name>` using the adapter filename without its extension (such as `@example/atomic-mydb/mydb-adapter`).
81
+
82
+ Host applications embedding Atomic can expose their own adapter without installing it separately. Pass the package directory via `--extension <dir>` or `additionalExtensionPaths: [packageRoot]` on `DefaultResourceLoader` before opening storage, then select `"adapter": "@example/app"` or `"@example/app/<name>"`.
83
+
84
+ Atomic resolves adapter package names in this order:
85
+
86
+ 1. Extension package directories passed to the process (or inherited from the launching Atomic process).
87
+ 2. Packages in effective global settings (including the older `~/.pi/agent/settings.json` for the default agent directory). Project packages are not searched.
88
+ 3. Module resolution from the agent directory.
89
+
90
+ Child processes that Atomic starts (such as subagents and the Intercom broker) automatically inherit adapters resolved from the host's packages without reloading the host package. `atomic storage status` shows the resolved path when run inside such a process, and resolves from global settings or the agent directory when run directly from a shell.
91
+
92
+ ## Bring your own driver
93
+
94
+ To wrap a SQLite-compatible driver into a `SqliteDatabase`, call `createSqliteDatabase` from `@bastani/atomic/storage` with these driver hooks:
95
+
96
+ - `descriptor` provides `{ adapter, location }` for diagnostics (redacted through `redact`).
97
+ - `execute(sql, params)` runs one parameterized statement and returns `{ columns, rows, changes }`. Return integers as `bigint` to preserve 64-bit precision.
98
+ - `executeMultiple(sql)` runs zero or more unparameterized statements.
99
+ - `beginTransaction()` starts a write transaction and returns `{ execute, executeMultiple, commit, rollback, close? }`.
100
+ - `close()` releases the driver connection.
101
+ - `batch(statements)` (optional) executes `{ sql, params }` statements in one atomic write transaction sent as a single request. Provide this only when the driver sends the whole batch at once.
102
+ - `redact(text)` (optional) strips credentials from error text. Use `redactSecrets(secrets)` to build one that removes raw, URI-encoded, and decoded forms.
103
+ - `transientFailure(failure)` (optional) classifies retryable driver errors from structured fields (never message text) and returns `{ code, outcome, hop? }`. Set `outcome` to `"not-applied"` when the database cannot have changed, or `"unknown"` when the write may have committed. Set `hop: { name, failure }` when an intermediate hop such as a proxy failed before reaching the database.
104
+ - `freeBytes()` (optional) returns writable free bytes on the filesystem holding a local database file, or `undefined`.
105
+ - `openReader()` (optional) returns a driver with connections of its own on the same database, for reads. Atomic exposes it as `SqliteDatabase.openReader()`. The reader gets its own call queue and closes when the main database closes. Atomic's stores send only reads through it, so its connections may refuse writes. A store's read through it first waits for any of that store's own writes to the same data that have started but not finished, so a caller that starts a write and then reads without waiting still reads what it wrote.
106
+ - `concurrentTransactions` (optional) marks a driver that runs each transaction on its own connection, as the PostgreSQL adapter does. Atomic then runs calls that cannot conflict at the same time. See the queue rules below.
107
+ - `pipelinedTransactions` (optional) marks a transaction connection that accepts a statement before the previous one is answered. The PostgreSQL adapter sets it. Atomic then sends each statement of a transaction without waiting for the answer before it. It can also send a transaction's last writes together with its commit.
108
+ - `beginTransaction` receives `leading`, the reads the transaction makes first. The driver may send them with the begin and answer the transaction's first calls from them.
109
+ - `beginTransaction` receives `relaxedDurability: true` for a write whose loss in a server crash is harmless, such as a lease renewal. The driver may then answer the commit before the transaction reaches disk, as the PostgreSQL adapter does with `synchronous_commit = off`. Drivers may ignore it.
110
+ - If a statement sent ahead of an earlier answer, or with the commit, fails, the driver's commit must fail, so nothing commits. The transaction then fails with that statement's error.
111
+ - A statement whose connection broke after the commit was sent reports `outcome: "unknown"`, because the commit may have applied.
112
+ - `concurrentReads` (optional) is a positive integer for a driver that runs reads on connections or streams of their own, up to that many at once. Atomic then runs read-only transactions, and statements outside a transaction that `readsOnly` accepts, beside each other. Every other call still waits for each call before it, and a read waits for the writes queued before it. With `concurrentTransactions` as well, Atomic runs at most this many reads at once.
113
+ - `readsOnly(sql)` (optional) says whether a statement run outside a transaction only reads. With `concurrentReads` or `concurrentTransactions`, such a statement runs beside other reads. Answer `true` only for a statement that can never write.
114
+ - On a driver with `concurrentTransactions`, a read-only transaction returns once its reads are answered. Its commit only ends the snapshot, so it finishes in the background, and `close()` waits for it.
115
+
116
+ Driver hooks may return values or promises. Atomic runs one operation at a time unless the driver sets `concurrentTransactions`. It copies binary parameters on call, rejects NUL text bindings with `StorageInvalidTextError`, converts safe-range integers to `number`, expires transaction handles after settlement, and drains accepted work on `close()`. Unclassified driver errors reject with `StorageUnavailableError` (with redacted `cause`), and failed rollbacks reject with `StorageRollbackError`.
117
+
118
+ Transient retry and queue bounds:
119
+
120
+ - Recognized transient failures reject with `StorageTransientError`. Statements and batches that failed before writing retry up to `STORAGE_TRANSIENT_RETRY_ATTEMPTS` (5) times starting at 250 ms with exponential backoff and up to 20% jitter. Writes with `outcome: "unknown"` never retry automatically.
121
+ - Transactions retry (re-running their callback) only when called with `{ retryTransientFailures: true }` and only for callbacks that have no external side effects. Non-boolean values throw `StorageConfigError`. The first retried failure on a database emits a one-time process warning.
122
+ - On a driver with `concurrentTransactions`, a call waits only for earlier unfinished calls it conflicts with. Statements and batches outside a transaction, and serial transactions without a `domain`, conflict with every call. A serial transaction with a `domain` conflicts with others of the same domain. A read-only transaction waits for writes queued before it, but not for other read-only transactions or later writes. Conflicting calls run in call order, and calls that do not conflict, such as appends to different sessions, run concurrently. Other drivers run one call at a time.
123
+ - While a call runs without settling, waiting priority batches (batches sent with `{ priority: true }`) fail after `STORAGE_PRIORITY_CALL_MAX_WAIT_MS` (10 seconds), and other waiting calls fail after `STORAGE_QUEUED_CALL_MAX_WAIT_MS` (60 seconds), both with `StorageUnavailableError`. On a driver with `concurrentTransactions`, only calls waiting behind the stuck call (directly or through other waiting calls) fail. Timers reset for each call that begins running.
124
+ - For shared local SQLite files, enable WAL mode with `switchToWriteAheadLog(exec, busyTimeoutMs)` from `@bastani/atomic/storage`. It retries `SQLITE_BUSY` up to `busyTimeoutMs` and retries Windows `SQLITE_IOERR_TRUNCATE` for up to 5 seconds (or `busyTimeoutMs`, whichever is shorter).
125
+
126
+ You can also implement `SqliteDatabase` directly. In either case, verify your implementation with the [conformance suite](#adapter-conformance).
127
+
128
+ ### Custom driver adapter example
129
+
130
+ This example wraps the SQLite driver built into Node.js, `node:sqlite`, to show how `createSqliteDatabase` and `StorageAdapterModule` fit together. A real adapter wraps the client library of your database in the same way. Save it as `custom-adapter.ts`:
131
+
132
+ ```typescript
133
+ import { DatabaseSync } from "node:sqlite";
134
+ import {
135
+ createSqliteDatabase,
136
+ type SqliteDatabase,
137
+ type SqliteDriverExecutor,
138
+ type SqliteValue,
139
+ type StorageAdapterModule,
140
+ } from "@bastani/atomic/storage";
141
+
142
+ export interface CustomDriverOptions {
143
+ path: string;
144
+ }
145
+
146
+ const WRITES = /^\s*(insert|update|delete|replace)\b/i;
147
+
148
+ function executor(connection: DatabaseSync): SqliteDriverExecutor {
149
+ return {
150
+ execute(sql, params) {
151
+ const statement = connection.prepare(sql);
152
+ statement.setReadBigInts(true);
153
+ const columns = statement.columns().map((column) => column.name);
154
+ if (columns.length === 0) {
155
+ const { changes } = statement.run(...params);
156
+ return { columns, rows: [], changes: Number(changes) };
157
+ }
158
+ statement.setReturnArrays(true);
159
+ const rows = statement.all(...params) as unknown as SqliteValue[][];
160
+ if (!WRITES.test(sql)) return { columns, rows, changes: 0 };
161
+ const { changes } = connection.prepare("SELECT changes() AS changes").get() as { changes: number };
162
+ return { columns, rows, changes };
163
+ },
164
+ executeMultiple: (sql) => connection.exec(sql),
165
+ };
166
+ }
167
+
168
+ export async function openCustomDatabase({ path }: CustomDriverOptions): Promise<SqliteDatabase> {
169
+ const connection = new DatabaseSync(path);
170
+ const database = createSqliteDatabase({
171
+ descriptor: { adapter: "custom-node-sqlite", location: path },
172
+ ...executor(connection),
173
+ beginTransaction() {
174
+ connection.exec("BEGIN IMMEDIATE");
175
+ return {
176
+ ...executor(connection),
177
+ commit: () => connection.exec("COMMIT"),
178
+ rollback: () => connection.exec("ROLLBACK"),
179
+ };
180
+ },
181
+ close() {
182
+ connection.close();
183
+ },
184
+ });
185
+ await database.exec("PRAGMA foreign_keys = ON");
186
+ return database;
187
+ }
188
+
189
+ export default {
190
+ atomicStorageAdapter: 1,
191
+ openDatabase: (options) => openCustomDatabase({ path: String(options.path) }),
192
+ } satisfies StorageAdapterModule;
193
+ ```
194
+
195
+ The default export lets settings select this module as an [adapter](#selecting-an-adapter), with the file in `options.path`. From the SDK, call your open function directly and pass the database to `createAgentSession`:
196
+
197
+ ```typescript
198
+ import { createAgentSession } from "@bastani/atomic";
199
+ import { openCustomDatabase } from "./custom-adapter.js";
200
+
201
+ const database = await openCustomDatabase({ path: "./sessions.sqlite" });
202
+ try {
203
+ const { session } = await createAgentSession({
204
+ sessionStore: { kind: "database", database, prefix: "project_" },
205
+ });
206
+ await session.prompt("List the failing tests");
207
+ } finally {
208
+ await database.close();
209
+ }
210
+ ```
211
+
212
+ Multiple stores can share one caller-owned `database` without closing it.
213
+
214
+ ### Custom `SessionStore` contracts
215
+
216
+ Non-SQL backends can implement `openSessionStore` directly (each session has one writer):
217
+
218
+ - **Required for `history://`.** Implement `readEntryRange(id, query)` honoring `fromSeq`, `toSeq`, `seqs`, `maxChars`, `largeEntryBytes`, `skipTypes`, and `signal`. When `query.seqs` lists sequence numbers, return only the entries at those numbers. A `history://` search reads the entries it found, and the lines around them, this way, in one call. A store that returns the whole range instead still gives the same results, but reads more. Return freshly owned UTF-8 JSON buffers and `{ entries: [{ seq, entry }], throughSeq, lastSeq }` without falling back to whole-session `load()`.
219
+ - **Optional fast-path methods.** Implementing these avoids loading entire sessions into memory (stores implementing only `load()` still work with higher memory use):
220
+
221
+ | Method | Purpose |
222
+ | --- | --- |
223
+ | `readTail(id, fromSeq)` | Header and entries from `fromSeq`, plus earlier live state and omitted usage totals |
224
+ | `readRange(id, startSeq, endSeq)` | Inclusive 1-based range with `seqs`, `lastSeq`, and `epoch` |
225
+ | `findLatestCompaction(id, leafId?)` | Latest active compaction boundary, sequence, and retained start |
226
+ | `readResume(id, leafId?)` | Atomic resume snapshot (header, active branch from compaction, live state, omitted totals, `deliveryOpIds`, `lastSeq`, `lastEntryId`, `leafId`, `epoch`) |
227
+ | `findEntrySeq(id, entryId)` | 1-based entry sequence, or `undefined` |
228
+ | `readEntrySizes` / `readEntryChunk` / `readScanPage` | Byte-bounded streaming exports and remote page reads |
229
+
230
+ - **Epochs and indexes.** Keep `epoch` constant on appends, rotate it on `replace` or recreate, and reject mismatched `epoch` writes with `SessionConflictError`. Mark read-only stores `readOnly: true` to skip cleanup writes. Set `estimated: true` on `SessionSummary` when metadata is unindexed.
231
+ - **Forks and cloning.** `/fork`, `/clone`, and `SessionManager.forkFrom` stream entries in pages (same-store forks copy all branches; cross-store forks copy current context and mark the parent in another store; see [`/tree`, `/fork`, and `/clone`](/sessions#tree-fork-and-clone)).
232
+
233
+ ## Adapter conformance
234
+
235
+ Validate any `SqliteDatabase` adapter against the conformance suites exported from `@bastani/atomic/storage/testing`:
236
+
237
+ ```typescript
238
+ import {
239
+ registerSqliteConnectionConformance,
240
+ registerSqliteDatabaseConformance,
241
+ } from "@bastani/atomic/storage/testing";
242
+
243
+ // Pass your test runner's `describe` and `it` functions.
244
+ registerSqliteDatabaseConformance({ describe, it }, "my adapter", withSubject);
245
+ registerSqliteConnectionConformance({ describe, it }, "my adapter connections", withConnections);
246
+ ```
247
+
248
+ - `withSubject` creates a fresh database per test case and passes `{ database, reopen, withRollbackFailure }` to the callback, cleaning up afterward. `reopen()` closes and reopens the same persistent database, and `withRollbackFailure(error, callback)` injects a rollback failure for the duration of `callback`. The suite verifies parameter binding, exact 64-bit integers, binary snapshots, NUL rejection, transaction ordering and expiration, commit and rollback errors, reopening, and close semantics.
249
+ - `withConnections` (for adapters supporting multiple connections to one database) opens two database handles on the same fresh database and closes both afterward. The suite verifies concurrent write queuing and event-loop responsiveness.
250
+
251
+ Helper utilities exported from `@bastani/atomic/storage` for custom adapters:
252
+
253
+ - `validateStoragePrefix(prefix, dialect?)` validates optional table prefixes (ASCII letters, digits, and `_`, not starting with `sqlite_`, case-insensitively). Passing `"postgres"` also enforces lowercase and `POSTGRES_MAX_STORAGE_PREFIX_LENGTH` (24).
254
+ - `renderStorageIdentifiers("sessions", names, prefix)` returns a frozen map of table names with the `session_` prefix applied.
255
+ - `assertStorageSchemaVersion(domain, found, supported)` throws `StorageSchemaVersionError` when stored and supported versions differ.
@@ -0,0 +1,117 @@
1
+ ---
2
+ title: "JSONL setup"
3
+ sidebarTitle: "Setup"
4
+ description: "Keep sessions as plain JSONL files in a directory on one machine: when to choose it, how to select it, where the files go, how several Atomic processes share it, what it doesn't do, and how to move to SQLite or PostgreSQL."
5
+ ---
6
+
7
+ A JSONL store keeps each session as a plain text file in a directory you choose. Each line of the file is one JSON object. The first line describes the session, and each later line is one entry of the conversation. [Session file format](/session-format) describes every field.
8
+
9
+ ## When to choose JSONL
10
+
11
+ Choose JSONL when you want your sessions as ordinary files on one machine:
12
+
13
+ - You can read, search, or compare a session with any text tool.
14
+ - You can back up or copy the directory like any other folder.
15
+ - You can delete a session by deleting its file.
16
+
17
+ Otherwise, keep the default [local SQLite](/storage/sqlite) store. To share sessions between machines, use [PostgreSQL](/storage/postgres).
18
+
19
+ A JSONL store holds sessions only. Intercom keeps using the store it would use without it.
20
+
21
+ ## Select a JSONL store
22
+
23
+ Add `sessions.storage` to `~/.atomic/agent/settings.json`, or to a trusted project's `.atomic/settings.json`:
24
+
25
+ ```json
26
+ {
27
+ "sessions": {
28
+ "storage": { "dir": "/home/me/atomic-sessions" }
29
+ }
30
+ }
31
+ ```
32
+
33
+ You can select the same store in other ways:
34
+
35
+ | Where | What to set | A relative path starts from |
36
+ | --- | --- | --- |
37
+ | Settings | `sessions.storage` set to `{ "dir": "<directory>" }` | The [storage home](/storage#storage-home) |
38
+ | Environment | `ATOMIC_SESSIONS_STORAGE='{"dir":"<directory>"}'` | The storage home |
39
+ | Environment | `ATOMIC_CODING_AGENT_SESSION_DIR=<directory>` | The current directory |
40
+ | Command line | `atomic --session-dir <directory>` | The current directory |
41
+
42
+ Use an absolute path to avoid surprises. Atomic creates the directory if it is missing. From the SDK, pass `sessionStore: { kind: "jsonl", dir }`, as [SDK session storage](/sdk/storage) shows.
43
+
44
+ Rules for these settings:
45
+
46
+ - `"dir"` works only in `sessions.storage` and `ATOMIC_SESSIONS_STORAGE`. In top-level `storage`, `--storage`, `--storage-file`, or `ATOMIC_STORAGE`, it fails with `StorageConfigError`.
47
+ - `--session-dir` can't be combined with `--session-store` or `--no-session`.
48
+ - A non-empty `ATOMIC_CODING_AGENT_SESSION_DIR` can't be combined with `ATOMIC_SESSIONS_STORAGE`, `--storage`, or `--storage-file`. Atomic stops at startup with `StorageConfigError` (`conflicting-overrides`).
49
+
50
+ When several of these are set, the one higher in [the precedence list](/storage#which-selection-wins) wins. Run `atomic storage status` in your project to see which store Atomic uses and where the choice came from.
51
+
52
+ ## Where the files go
53
+
54
+ Every session file sits directly in the directory you chose:
55
+
56
+ ```text
57
+ /home/me/atomic-sessions/
58
+ 2026-11-26T09-30-00-000Z_2ace5975…e788d7.jsonl
59
+ 2026-11-26T10-02-14-512Z_9f1c03ab…41d0b2.jsonl
60
+ ```
61
+
62
+ A file's name is the time the session was created, with `:` and `.` replaced by `-`, then `_`, then the SHA-256 hash of the session ID in hex. Sessions from every project share the directory. The first line of each file records the project's working directory (`cwd`), which is how `/resume` finds the sessions of the current project.
63
+
64
+ Atomic can also put these next to the session files:
65
+
66
+ - **`.session.lock`.** A folder that exists only while a process writes. See [Several Atomic processes](#several-atomic-processes).
67
+ - **Backups before compaction.** Before Atomic [compacts](/compaction) a session, it saves a copy beside the file, named `<session file>.<timestamp>.<label>.bak`. Atomic never deletes these, so remove old ones yourself.
68
+ - **`tool-results/`.** Long tool output saved in files. Atomic deletes a `tool-results/` folder once its newest file is more than 30 days old.
69
+
70
+ To delete a session, delete its `.jsonl` file, or select it in `/resume`, press `Ctrl+D`, and confirm. Atomic moves the file to the trash when the `trash` command is installed.
71
+
72
+ ## Several Atomic processes
73
+
74
+ Several Atomic processes on one machine can use the same directory at once:
75
+
76
+ - **One writer at a time.** Before it writes, a process takes the `.session.lock` folder in the directory, and other processes wait for it. If a process exits while it holds the lock, another process takes the lock over after about 10 seconds.
77
+ - **Grouped writes.** Saves that queue up while another save holds the lock are written together under one lock.
78
+ - **Files kept open while writing.** While a session is being written, Atomic keeps its file open between saves and closes it soon after the last one. On Windows, Atomic closes each file after it writes, because Windows won't delete or replace an open file.
79
+
80
+ Keep the directory on a local disk of one machine. Don't share it between machines through a network drive or a cloud-synced folder.
81
+
82
+ ## What JSONL doesn't do
83
+
84
+ Compared with local SQLite, a JSONL store:
85
+
86
+ - **Can't be shared between machines.** Use [PostgreSQL](/storage/postgres) for that.
87
+ - **Copies forks.** In SQLite and PostgreSQL, a fork [shares its parent's history](/storage#shared-history-forks). In JSONL, a fork writes a new file with a full copy of that history, so forking a long session takes longer and uses more disk.
88
+ - **Records no worktree snapshots.** [Worktree snapshots](/worktree-snapshots) need a SQL database store.
89
+ - **Keeps subagents on this machine.** Subagents launched from a session in a JSONL store can't be [resumed on another machine](/guides/resume-on-any-machine).
90
+
91
+ ## Move to SQLite or PostgreSQL
92
+
93
+ Export the sessions while the JSONL store is still selected. If you select it with `--session-dir`, set `ATOMIC_SESSIONS_STORAGE` for this one command instead, because `atomic storage export` doesn't take `--session-dir`:
94
+
95
+ ```bash
96
+ ATOMIC_SESSIONS_STORAGE='{"dir":"/home/me/atomic-sessions"}' atomic storage export ~/moved
97
+ ```
98
+
99
+ Then stop selecting the JSONL store. Remove `sessions.storage` from your settings, and unset `ATOMIC_SESSIONS_STORAGE` and `ATOMIC_CODING_AGENT_SESSION_DIR`.
100
+
101
+ To move the sessions into the default local SQLite store, import them:
102
+
103
+ ```bash
104
+ atomic storage import ~/moved
105
+ ```
106
+
107
+ To move them into PostgreSQL, [set up the database](/storage/postgres#set-up-the-database), join it, and import into it by name:
108
+
109
+ ```bash
110
+ (umask 077; printf 'Runtime password: '; read -rs password; printf '\n'; printf '%s' "$password" > ~/atomic-db-password)
111
+ atomic storage join 'postgresql://atomic_runtime@db.example.com:5432/atomic' --password-file ~/atomic-db-password
112
+ rm ~/atomic-db-password # atomic storage join keeps its own copy
113
+ jq .storage ~/.atomic/agent/settings.json > new-storage.json
114
+ atomic storage import ~/moved --storage-file new-storage.json
115
+ ```
116
+
117
+ Import leaves the JSONL files in place. Delete the directory once you have checked the sessions in their new store. See [Exporting and importing sessions](/storage#exporting-and-importing-sessions) for what an export holds.