@bastani/atomic 0.9.37 → 0.9.38-alpha.10

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 (693) hide show
  1. package/CHANGELOG.md +151 -0
  2. package/README.md +8 -6
  3. package/dist/builtin/intercom/CHANGELOG.md +15 -0
  4. package/dist/builtin/intercom/broker/broker.ts +6 -4
  5. package/dist/builtin/intercom/broker/delivered-message-cache.ts +50 -4
  6. package/dist/builtin/intercom/broker/send-handler.ts +6 -4
  7. package/dist/builtin/intercom/index.bundle.mjs +89 -40
  8. package/dist/builtin/intercom/package.json +2 -2
  9. package/dist/builtin/mcp/package.json +1 -1
  10. package/dist/builtin/subagents/CHANGELOG.md +12 -0
  11. package/dist/builtin/subagents/README.md +9 -4
  12. package/dist/builtin/subagents/package.json +3 -3
  13. package/dist/builtin/subagents/src/extension/index.bundle.mjs +163 -158
  14. package/dist/builtin/web-access/CHANGELOG.md +7 -0
  15. package/dist/builtin/web-access/index.bundle.mjs +53 -15
  16. package/dist/builtin/web-access/package.json +2 -2
  17. package/dist/builtin/workflows/CHANGELOG.md +91 -0
  18. package/dist/builtin/workflows/README.md +5 -10
  19. package/dist/builtin/workflows/builtin/adversarial-verification.js +2 -2
  20. package/dist/builtin/workflows/builtin/{chunk-94f8zfz1.js → chunk-454hz1qt.js} +1 -1
  21. package/dist/builtin/workflows/builtin/{chunk-wf876n16.js → chunk-4bwtzyjq.js} +1 -1
  22. package/dist/builtin/workflows/builtin/{chunk-kb7s3gx2.js → chunk-5eh0brtd.js} +1 -1
  23. package/dist/builtin/workflows/builtin/{chunk-nkj4qhj6.js → chunk-85mx6wcf.js} +7 -7
  24. package/dist/builtin/workflows/builtin/{chunk-rhkg3d8e.js → chunk-8kkv04hz.js} +16 -16
  25. package/dist/builtin/workflows/builtin/chunk-8x61e0s7.js +3148 -0
  26. package/dist/builtin/workflows/builtin/{chunk-r97ndfvt.js → chunk-bjva9j5k.js} +1 -1
  27. package/dist/builtin/workflows/builtin/{chunk-a1ar035d.js → chunk-qdd897wm.js} +1 -1
  28. package/dist/builtin/workflows/builtin/{chunk-gyjck9z8.js → chunk-qjqn389g.js} +1 -1
  29. package/dist/builtin/workflows/builtin/{chunk-632fxeb8.js → chunk-x0vvjyzg.js} +1 -1
  30. package/dist/builtin/workflows/builtin/{chunk-3xffzzbg.js → chunk-y45tkftg.js} +11 -18
  31. package/dist/builtin/workflows/builtin/classify-and-act.js +2 -2
  32. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +2 -2
  33. package/dist/builtin/workflows/builtin/generate-and-filter.js +2 -2
  34. package/dist/builtin/workflows/builtin/goal.js +3 -3
  35. package/dist/builtin/workflows/builtin/index.js +11 -11
  36. package/dist/builtin/workflows/builtin/loop-until-done.js +2 -2
  37. package/dist/builtin/workflows/builtin/open-claude-design.js +2 -2
  38. package/dist/builtin/workflows/builtin/ralph.js +3 -3
  39. package/dist/builtin/workflows/builtin/tournament.js +2 -2
  40. package/dist/builtin/workflows/package.json +2 -2
  41. package/dist/builtin/workflows/src/authoring.d.ts +9 -12
  42. package/dist/builtin/workflows/src/durable/journal/conformance.d.ts +12 -0
  43. package/dist/builtin/workflows/src/durable/journal/internal.d.ts +1 -0
  44. package/dist/builtin/workflows/src/durable/journal/lease-expiry.d.ts +2 -0
  45. package/dist/builtin/workflows/src/durable/journal/legacy-journal-tables.d.ts +42 -0
  46. package/dist/builtin/workflows/src/durable/journal/memory-run-journal.d.ts +35 -0
  47. package/dist/builtin/workflows/src/durable/journal/resolution.d.ts +32 -0
  48. package/dist/builtin/workflows/src/durable/journal/sql-run-journal.d.ts +48 -0
  49. package/dist/builtin/workflows/src/durable/journal/sqlite-run-journal.d.ts +7 -0
  50. package/dist/builtin/workflows/src/durable/journal/types.d.ts +95 -0
  51. package/dist/builtin/workflows/src/durable/journal/values.d.ts +5 -0
  52. package/dist/builtin/workflows/src/extension/index.bundle.mjs +29510 -64819
  53. package/dist/builtin/workflows/src/index.js +10767 -45878
  54. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +8 -14
  55. package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +4 -20
  56. package/dist/bun/split-loader.js +0 -13
  57. package/dist/bun/split-loader.js.map +1 -1
  58. package/dist/cli/args.d.ts +3 -0
  59. package/dist/cli/args.d.ts.map +1 -1
  60. package/dist/cli/args.js +35 -5
  61. package/dist/cli/args.js.map +1 -1
  62. package/dist/cli/credential-print.d.ts.map +1 -1
  63. package/dist/cli/credential-print.js +4 -4
  64. package/dist/cli/credential-print.js.map +1 -1
  65. package/dist/cli/session-picker.d.ts +2 -2
  66. package/dist/cli/session-picker.d.ts.map +1 -1
  67. package/dist/cli/session-picker.js +5 -5
  68. package/dist/cli/session-picker.js.map +1 -1
  69. package/dist/core/agent-session-auto-compaction.d.ts +1 -1
  70. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  71. package/dist/core/agent-session-auto-compaction.js +2 -2
  72. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  73. package/dist/core/agent-session-bash.d.ts +2 -3
  74. package/dist/core/agent-session-bash.d.ts.map +1 -1
  75. package/dist/core/agent-session-bash.js +18 -10
  76. package/dist/core/agent-session-bash.js.map +1 -1
  77. package/dist/core/agent-session-boundaries.d.ts +6 -6
  78. package/dist/core/agent-session-boundaries.d.ts.map +1 -1
  79. package/dist/core/agent-session-boundaries.js +22 -22
  80. package/dist/core/agent-session-boundaries.js.map +1 -1
  81. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  82. package/dist/core/agent-session-compaction.js +3 -2
  83. package/dist/core/agent-session-compaction.js.map +1 -1
  84. package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
  85. package/dist/core/agent-session-custom-message-commit.js +10 -12
  86. package/dist/core/agent-session-custom-message-commit.js.map +1 -1
  87. package/dist/core/agent-session-events.d.ts.map +1 -1
  88. package/dist/core/agent-session-events.js +26 -14
  89. package/dist/core/agent-session-events.js.map +1 -1
  90. package/dist/core/agent-session-export.js +1 -1
  91. package/dist/core/agent-session-export.js.map +1 -1
  92. package/dist/core/agent-session-extension-bindings.d.ts +3 -3
  93. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  94. package/dist/core/agent-session-extension-bindings.js +98 -64
  95. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  96. package/dist/core/agent-session-message-queue.d.ts +2 -2
  97. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  98. package/dist/core/agent-session-message-queue.js +17 -8
  99. package/dist/core/agent-session-message-queue.js.map +1 -1
  100. package/dist/core/agent-session-methods.d.ts +17 -17
  101. package/dist/core/agent-session-methods.d.ts.map +1 -1
  102. package/dist/core/agent-session-methods.js.map +1 -1
  103. package/dist/core/agent-session-models.d.ts +2 -2
  104. package/dist/core/agent-session-models.d.ts.map +1 -1
  105. package/dist/core/agent-session-models.js +59 -42
  106. package/dist/core/agent-session-models.js.map +1 -1
  107. package/dist/core/agent-session-persistent-custom-messages.d.ts +4 -4
  108. package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
  109. package/dist/core/agent-session-persistent-custom-messages.js +16 -17
  110. package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
  111. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  112. package/dist/core/agent-session-prompt.js +6 -8
  113. package/dist/core/agent-session-prompt.js.map +1 -1
  114. package/dist/core/agent-session-retry.d.ts.map +1 -1
  115. package/dist/core/agent-session-retry.js +18 -16
  116. package/dist/core/agent-session-retry.js.map +1 -1
  117. package/dist/core/agent-session-runtime.d.ts +7 -8
  118. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  119. package/dist/core/agent-session-runtime.js +88 -100
  120. package/dist/core/agent-session-runtime.js.map +1 -1
  121. package/dist/core/agent-session-services.d.ts +1 -1
  122. package/dist/core/agent-session-services.d.ts.map +1 -1
  123. package/dist/core/agent-session-services.js +2 -2
  124. package/dist/core/agent-session-services.js.map +1 -1
  125. package/dist/core/agent-session-state.d.ts +4 -6
  126. package/dist/core/agent-session-state.d.ts.map +1 -1
  127. package/dist/core/agent-session-state.js +13 -8
  128. package/dist/core/agent-session-state.js.map +1 -1
  129. package/dist/core/agent-session-summary.js +1 -1
  130. package/dist/core/agent-session-summary.js.map +1 -1
  131. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  132. package/dist/core/agent-session-tool-registry.js +3 -1
  133. package/dist/core/agent-session-tool-registry.js.map +1 -1
  134. package/dist/core/agent-session-tree.d.ts +1 -1
  135. package/dist/core/agent-session-tree.d.ts.map +1 -1
  136. package/dist/core/agent-session-tree.js +8 -7
  137. package/dist/core/agent-session-tree.js.map +1 -1
  138. package/dist/core/agent-session-types.d.ts +2 -0
  139. package/dist/core/agent-session-types.d.ts.map +1 -1
  140. package/dist/core/agent-session-types.js.map +1 -1
  141. package/dist/core/agent-session.js +1 -1
  142. package/dist/core/agent-session.js.map +1 -1
  143. package/dist/core/auth-storage-backends.d.ts +2 -0
  144. package/dist/core/auth-storage-backends.d.ts.map +1 -1
  145. package/dist/core/auth-storage-backends.js +12 -0
  146. package/dist/core/auth-storage-backends.js.map +1 -1
  147. package/dist/core/auth-storage.d.ts +5 -0
  148. package/dist/core/auth-storage.d.ts.map +1 -1
  149. package/dist/core/auth-storage.js +46 -12
  150. package/dist/core/auth-storage.js.map +1 -1
  151. package/dist/core/cache-warmer.js +1 -1
  152. package/dist/core/cache-warmer.js.map +1 -1
  153. package/dist/core/compaction/branch-summarization.d.ts +3 -5
  154. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  155. package/dist/core/compaction/branch-summarization.js +6 -10
  156. package/dist/core/compaction/branch-summarization.js.map +1 -1
  157. package/dist/core/compaction/compaction-runner.d.ts +1 -0
  158. package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
  159. package/dist/core/compaction/compaction-runner.js +4 -1
  160. package/dist/core/compaction/compaction-runner.js.map +1 -1
  161. package/dist/core/compaction/pi-summary-fallback.d.ts +2 -1
  162. package/dist/core/compaction/pi-summary-fallback.d.ts.map +1 -1
  163. package/dist/core/compaction/pi-summary-fallback.js +6 -8
  164. package/dist/core/compaction/pi-summary-fallback.js.map +1 -1
  165. package/dist/core/compaction/utils.d.ts +2 -1
  166. package/dist/core/compaction/utils.d.ts.map +1 -1
  167. package/dist/core/compaction/utils.js +32 -7
  168. package/dist/core/compaction/utils.js.map +1 -1
  169. package/dist/core/export-html/index.js +1 -1
  170. package/dist/core/export-html/index.js.map +1 -1
  171. package/dist/core/export-html/template-js/entries-navigation.js +1 -1
  172. package/dist/core/export-html/template-js/message-tools.js +20 -7
  173. package/dist/core/export-html/template-js/tree-filter-render.js +1 -9
  174. package/dist/core/export-html/template.js +22 -17
  175. package/dist/core/extensions/api-types.d.ts +12 -12
  176. package/dist/core/extensions/api-types.d.ts.map +1 -1
  177. package/dist/core/extensions/api-types.js.map +1 -1
  178. package/dist/core/extensions/context-types.d.ts +4 -2
  179. package/dist/core/extensions/context-types.d.ts.map +1 -1
  180. package/dist/core/extensions/context-types.js.map +1 -1
  181. package/dist/core/extensions/extension-work.d.ts +1 -0
  182. package/dist/core/extensions/extension-work.d.ts.map +1 -1
  183. package/dist/core/extensions/extension-work.js +5 -1
  184. package/dist/core/extensions/extension-work.js.map +1 -1
  185. package/dist/core/extensions/index.d.ts +1 -1
  186. package/dist/core/extensions/index.d.ts.map +1 -1
  187. package/dist/core/extensions/index.js +1 -1
  188. package/dist/core/extensions/index.js.map +1 -1
  189. package/dist/core/extensions/loader-api.d.ts.map +1 -1
  190. package/dist/core/extensions/loader-api.js +40 -42
  191. package/dist/core/extensions/loader-api.js.map +1 -1
  192. package/dist/core/extensions/loader-host-modules.d.ts +1 -1
  193. package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
  194. package/dist/core/extensions/loader-host-modules.js +6 -2
  195. package/dist/core/extensions/loader-host-modules.js.map +1 -1
  196. package/dist/core/extensions/loader-rollback.d.ts.map +1 -1
  197. package/dist/core/extensions/loader-rollback.js +1 -0
  198. package/dist/core/extensions/loader-rollback.js.map +1 -1
  199. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  200. package/dist/core/extensions/loader-virtual-modules.js +1 -0
  201. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  202. package/dist/core/extensions/runner-context.d.ts +1 -0
  203. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  204. package/dist/core/extensions/runner-context.js +10 -3
  205. package/dist/core/extensions/runner-context.js.map +1 -1
  206. package/dist/core/extensions/runner-handlers.d.ts +1 -1
  207. package/dist/core/extensions/runner-handlers.d.ts.map +1 -1
  208. package/dist/core/extensions/runner-handlers.js.map +1 -1
  209. package/dist/core/extensions/runner.d.ts +5 -2
  210. package/dist/core/extensions/runner.d.ts.map +1 -1
  211. package/dist/core/extensions/runner.js +28 -12
  212. package/dist/core/extensions/runner.js.map +1 -1
  213. package/dist/core/extensions/runtime-types.d.ts +7 -7
  214. package/dist/core/extensions/runtime-types.d.ts.map +1 -1
  215. package/dist/core/extensions/runtime-types.js.map +1 -1
  216. package/dist/core/extensions/session-events.d.ts +5 -5
  217. package/dist/core/extensions/session-events.d.ts.map +1 -1
  218. package/dist/core/extensions/session-events.js.map +1 -1
  219. package/dist/core/extensions/workflow-events.d.ts +2 -0
  220. package/dist/core/extensions/workflow-events.d.ts.map +1 -1
  221. package/dist/core/extensions/workflow-events.js.map +1 -1
  222. package/dist/core/extensions/workflow-run-control.d.ts +3 -3
  223. package/dist/core/extensions/workflow-run-control.d.ts.map +1 -1
  224. package/dist/core/extensions/workflow-run-control.js +4 -4
  225. package/dist/core/extensions/workflow-run-control.js.map +1 -1
  226. package/dist/core/fast-model-routing.d.ts.map +1 -1
  227. package/dist/core/fast-model-routing.js +1 -0
  228. package/dist/core/fast-model-routing.js.map +1 -1
  229. package/dist/core/intercom-runtime-group.js +1 -1
  230. package/dist/core/intercom-runtime-group.js.map +1 -1
  231. package/dist/core/model-config.d.ts +774 -9
  232. package/dist/core/model-config.d.ts.map +1 -1
  233. package/dist/core/model-config.js +46 -24
  234. package/dist/core/model-config.js.map +1 -1
  235. package/dist/core/model-fallback-failures.d.ts.map +1 -1
  236. package/dist/core/model-fallback-failures.js +3 -1
  237. package/dist/core/model-fallback-failures.js.map +1 -1
  238. package/dist/core/model-resolver-cli.d.ts +2 -0
  239. package/dist/core/model-resolver-cli.d.ts.map +1 -1
  240. package/dist/core/model-resolver-cli.js +47 -143
  241. package/dist/core/model-resolver-cli.js.map +1 -1
  242. package/dist/core/model-resolver-defaults.js +5 -5
  243. package/dist/core/model-resolver-defaults.js.map +1 -1
  244. package/dist/core/model-resolver-patterns.d.ts +48 -22
  245. package/dist/core/model-resolver-patterns.d.ts.map +1 -1
  246. package/dist/core/model-resolver-patterns.js +154 -105
  247. package/dist/core/model-resolver-patterns.js.map +1 -1
  248. package/dist/core/model-resolver-scope.d.ts +6 -9
  249. package/dist/core/model-resolver-scope.d.ts.map +1 -1
  250. package/dist/core/model-resolver-scope.js +51 -53
  251. package/dist/core/model-resolver-scope.js.map +1 -1
  252. package/dist/core/model-resolver-types.d.ts +0 -6
  253. package/dist/core/model-resolver-types.d.ts.map +1 -1
  254. package/dist/core/model-resolver-types.js.map +1 -1
  255. package/dist/core/model-resolver.d.ts +3 -2
  256. package/dist/core/model-resolver.d.ts.map +1 -1
  257. package/dist/core/model-resolver.js +1 -1
  258. package/dist/core/model-resolver.js.map +1 -1
  259. package/dist/core/model-runtime-streaming.d.ts +9 -2
  260. package/dist/core/model-runtime-streaming.d.ts.map +1 -1
  261. package/dist/core/model-runtime-streaming.js +121 -10
  262. package/dist/core/model-runtime-streaming.js.map +1 -1
  263. package/dist/core/model-runtime.d.ts +6 -0
  264. package/dist/core/model-runtime.d.ts.map +1 -1
  265. package/dist/core/model-runtime.js +103 -2
  266. package/dist/core/model-runtime.js.map +1 -1
  267. package/dist/core/prompt-templates.d.ts.map +1 -1
  268. package/dist/core/prompt-templates.js +6 -2
  269. package/dist/core/prompt-templates.js.map +1 -1
  270. package/dist/core/provider-attribution.js +1 -1
  271. package/dist/core/provider-attribution.js.map +1 -1
  272. package/dist/core/resource-loader-reload.js +1 -1
  273. package/dist/core/resource-loader-reload.js.map +1 -1
  274. package/dist/core/resource-loader-types.d.ts +1 -1
  275. package/dist/core/resource-loader-types.d.ts.map +1 -1
  276. package/dist/core/resource-loader-types.js.map +1 -1
  277. package/dist/core/retry-policy.d.ts +5 -2
  278. package/dist/core/retry-policy.d.ts.map +1 -1
  279. package/dist/core/retry-policy.js +4 -3
  280. package/dist/core/retry-policy.js.map +1 -1
  281. package/dist/core/runtime-credentials.d.ts +1 -0
  282. package/dist/core/runtime-credentials.d.ts.map +1 -1
  283. package/dist/core/runtime-credentials.js +3 -0
  284. package/dist/core/runtime-credentials.js.map +1 -1
  285. package/dist/core/sdk-types.d.ts +4 -0
  286. package/dist/core/sdk-types.d.ts.map +1 -1
  287. package/dist/core/sdk-types.js.map +1 -1
  288. package/dist/core/sdk.d.ts +1 -1
  289. package/dist/core/sdk.d.ts.map +1 -1
  290. package/dist/core/sdk.js +145 -94
  291. package/dist/core/sdk.js.map +1 -1
  292. package/dist/core/session-lifecycle-work.d.ts +3 -0
  293. package/dist/core/session-lifecycle-work.d.ts.map +1 -1
  294. package/dist/core/session-lifecycle-work.js +2 -0
  295. package/dist/core/session-lifecycle-work.js.map +1 -1
  296. package/dist/core/session-manager-archive.d.ts +2 -16
  297. package/dist/core/session-manager-archive.d.ts.map +1 -1
  298. package/dist/core/session-manager-archive.js +8 -109
  299. package/dist/core/session-manager-archive.js.map +1 -1
  300. package/dist/core/session-manager-core.d.ts +53 -51
  301. package/dist/core/session-manager-core.d.ts.map +1 -1
  302. package/dist/core/session-manager-core.js +549 -315
  303. package/dist/core/session-manager-core.js.map +1 -1
  304. package/dist/core/session-manager-entries.d.ts.map +1 -1
  305. package/dist/core/session-manager-entries.js +5 -10
  306. package/dist/core/session-manager-entries.js.map +1 -1
  307. package/dist/core/session-manager-errors.d.ts +10 -0
  308. package/dist/core/session-manager-errors.d.ts.map +1 -0
  309. package/dist/core/session-manager-errors.js +27 -0
  310. package/dist/core/session-manager-errors.js.map +1 -0
  311. package/dist/core/session-manager-list.d.ts +1 -0
  312. package/dist/core/session-manager-list.d.ts.map +1 -1
  313. package/dist/core/session-manager-list.js +23 -25
  314. package/dist/core/session-manager-list.js.map +1 -1
  315. package/dist/core/session-manager-storage.d.ts +3 -12
  316. package/dist/core/session-manager-storage.d.ts.map +1 -1
  317. package/dist/core/session-manager-storage.js +60 -77
  318. package/dist/core/session-manager-storage.js.map +1 -1
  319. package/dist/core/session-manager-types.d.ts +4 -12
  320. package/dist/core/session-manager-types.d.ts.map +1 -1
  321. package/dist/core/session-manager-types.js +2 -1
  322. package/dist/core/session-manager-types.js.map +1 -1
  323. package/dist/core/session-manager-validation.d.ts +3 -0
  324. package/dist/core/session-manager-validation.d.ts.map +1 -1
  325. package/dist/core/session-manager-validation.js +18 -1
  326. package/dist/core/session-manager-validation.js.map +1 -1
  327. package/dist/core/session-manager.d.ts +3 -3
  328. package/dist/core/session-manager.d.ts.map +1 -1
  329. package/dist/core/session-manager.js +3 -3
  330. package/dist/core/session-manager.js.map +1 -1
  331. package/dist/core/session-mutation-queue.d.ts +3 -0
  332. package/dist/core/session-mutation-queue.d.ts.map +1 -0
  333. package/dist/core/session-mutation-queue.js +14 -0
  334. package/dist/core/session-mutation-queue.js.map +1 -0
  335. package/dist/core/session-resume-args.d.ts +4 -0
  336. package/dist/core/session-resume-args.d.ts.map +1 -0
  337. package/dist/core/session-resume-args.js +9 -0
  338. package/dist/core/session-resume-args.js.map +1 -0
  339. package/dist/core/session-storage.d.ts +26 -0
  340. package/dist/core/session-storage.d.ts.map +1 -0
  341. package/dist/core/session-storage.js +171 -0
  342. package/dist/core/session-storage.js.map +1 -0
  343. package/dist/core/session-store-list.d.ts +4 -0
  344. package/dist/core/session-store-list.d.ts.map +1 -0
  345. package/dist/core/session-store-list.js +28 -0
  346. package/dist/core/session-store-list.js.map +1 -0
  347. package/dist/core/settings-manager-basic-accessors.d.ts +1 -1
  348. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  349. package/dist/core/settings-manager-basic-accessors.js +1 -5
  350. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  351. package/dist/core/settings-merge.d.ts.map +1 -1
  352. package/dist/core/settings-merge.js +8 -2
  353. package/dist/core/settings-merge.js.map +1 -1
  354. package/dist/core/settings-schema.d.ts +76 -6
  355. package/dist/core/settings-schema.d.ts.map +1 -1
  356. package/dist/core/settings-schema.js +29 -20
  357. package/dist/core/settings-schema.js.map +1 -1
  358. package/dist/core/storage/database.d.ts +21 -0
  359. package/dist/core/storage/database.d.ts.map +1 -0
  360. package/dist/core/storage/database.js +2 -0
  361. package/dist/core/storage/database.js.map +1 -0
  362. package/dist/core/storage/errors.d.ts +64 -0
  363. package/dist/core/storage/errors.d.ts.map +1 -0
  364. package/dist/core/storage/errors.js +103 -0
  365. package/dist/core/storage/errors.js.map +1 -0
  366. package/dist/core/storage/index.d.ts +10 -0
  367. package/dist/core/storage/index.d.ts.map +1 -0
  368. package/dist/core/storage/index.js +8 -0
  369. package/dist/core/storage/index.js.map +1 -0
  370. package/dist/core/storage/node-sqlite.d.ts +7 -0
  371. package/dist/core/storage/node-sqlite.d.ts.map +1 -0
  372. package/dist/core/storage/node-sqlite.js +202 -0
  373. package/dist/core/storage/node-sqlite.js.map +1 -0
  374. package/dist/core/storage/prefix.d.ts +5 -0
  375. package/dist/core/storage/prefix.d.ts.map +1 -0
  376. package/dist/core/storage/prefix.js +15 -0
  377. package/dist/core/storage/prefix.js.map +1 -0
  378. package/dist/core/storage/provider.d.ts +58 -0
  379. package/dist/core/storage/provider.d.ts.map +1 -0
  380. package/dist/core/storage/provider.js +243 -0
  381. package/dist/core/storage/provider.js.map +1 -0
  382. package/dist/core/storage/run-journal.d.ts +93 -0
  383. package/dist/core/storage/run-journal.d.ts.map +1 -0
  384. package/dist/core/storage/run-journal.js +15 -0
  385. package/dist/core/storage/run-journal.js.map +1 -0
  386. package/dist/core/storage/schema.d.ts +3 -0
  387. package/dist/core/storage/schema.d.ts.map +1 -0
  388. package/dist/core/storage/schema.js +6 -0
  389. package/dist/core/storage/schema.js.map +1 -0
  390. package/dist/core/storage/selection.d.ts +16 -0
  391. package/dist/core/storage/selection.d.ts.map +1 -0
  392. package/dist/core/storage/selection.js +87 -0
  393. package/dist/core/storage/selection.js.map +1 -0
  394. package/dist/core/storage/session/conformance.d.ts +12 -0
  395. package/dist/core/storage/session/conformance.d.ts.map +1 -0
  396. package/dist/core/storage/session/conformance.js +674 -0
  397. package/dist/core/storage/session/conformance.js.map +1 -0
  398. package/dist/core/storage/session/entry-structure.d.ts +4 -0
  399. package/dist/core/storage/session/entry-structure.d.ts.map +1 -0
  400. package/dist/core/storage/session/entry-structure.js +83 -0
  401. package/dist/core/storage/session/entry-structure.js.map +1 -0
  402. package/dist/core/storage/session/errors.d.ts +54 -0
  403. package/dist/core/storage/session/errors.d.ts.map +1 -0
  404. package/dist/core/storage/session/errors.js +95 -0
  405. package/dist/core/storage/session/errors.js.map +1 -0
  406. package/dist/core/storage/session/jsonl-session-store.d.ts +72 -0
  407. package/dist/core/storage/session/jsonl-session-store.d.ts.map +1 -0
  408. package/dist/core/storage/session/jsonl-session-store.js +564 -0
  409. package/dist/core/storage/session/jsonl-session-store.js.map +1 -0
  410. package/dist/core/storage/session/legacy-format.d.ts +20 -0
  411. package/dist/core/storage/session/legacy-format.d.ts.map +1 -0
  412. package/dist/core/storage/session/legacy-format.js +89 -0
  413. package/dist/core/storage/session/legacy-format.js.map +1 -0
  414. package/dist/core/storage/session/legacy-session-store.d.ts +63 -0
  415. package/dist/core/storage/session/legacy-session-store.d.ts.map +1 -0
  416. package/dist/core/storage/session/legacy-session-store.js +239 -0
  417. package/dist/core/storage/session/legacy-session-store.js.map +1 -0
  418. package/dist/core/storage/session/legacy-session-summary.d.ts +11 -0
  419. package/dist/core/storage/session/legacy-session-summary.d.ts.map +1 -0
  420. package/dist/core/storage/session/legacy-session-summary.js +103 -0
  421. package/dist/core/storage/session/legacy-session-summary.js.map +1 -0
  422. package/dist/core/storage/session/memory-session-store.d.ts +33 -0
  423. package/dist/core/storage/session/memory-session-store.d.ts.map +1 -0
  424. package/dist/core/storage/session/memory-session-store.js +120 -0
  425. package/dist/core/storage/session/memory-session-store.js.map +1 -0
  426. package/dist/core/storage/session/scratch-directory.d.ts +2 -0
  427. package/dist/core/storage/session/scratch-directory.d.ts.map +1 -0
  428. package/dist/core/storage/session/scratch-directory.js +5 -0
  429. package/dist/core/storage/session/scratch-directory.js.map +1 -0
  430. package/dist/core/storage/session/session-summary.d.ts +24 -0
  431. package/dist/core/storage/session/session-summary.d.ts.map +1 -0
  432. package/dist/core/storage/session/session-summary.js +79 -0
  433. package/dist/core/storage/session/session-summary.js.map +1 -0
  434. package/dist/core/storage/session/sql-session-store.d.ts +49 -0
  435. package/dist/core/storage/session/sql-session-store.d.ts.map +1 -0
  436. package/dist/core/storage/session/sql-session-store.js +246 -0
  437. package/dist/core/storage/session/sql-session-store.js.map +1 -0
  438. package/dist/core/storage/session/types.d.ts +72 -0
  439. package/dist/core/storage/session/types.d.ts.map +1 -0
  440. package/dist/core/storage/session/types.js +2 -0
  441. package/dist/core/storage/session/types.js.map +1 -0
  442. package/dist/core/storage/session/validation.d.ts +7 -0
  443. package/dist/core/storage/session/validation.d.ts.map +1 -0
  444. package/dist/core/storage/session/validation.js +47 -0
  445. package/dist/core/storage/session/validation.js.map +1 -0
  446. package/dist/core/storage/testing.d.ts +15 -0
  447. package/dist/core/storage/testing.d.ts.map +1 -0
  448. package/dist/core/storage/testing.js +309 -0
  449. package/dist/core/storage/testing.js.map +1 -0
  450. package/dist/core/tasks/completion.d.ts.map +1 -1
  451. package/dist/core/tasks/completion.js +2 -4
  452. package/dist/core/tasks/completion.js.map +1 -1
  453. package/dist/core/tools/bash-session-environment.d.ts.map +1 -1
  454. package/dist/core/tools/bash-session-environment.js +0 -2
  455. package/dist/core/tools/bash-session-environment.js.map +1 -1
  456. package/dist/core/tools/malformed-tool-arguments.d.ts +3 -0
  457. package/dist/core/tools/malformed-tool-arguments.d.ts.map +1 -0
  458. package/dist/core/tools/malformed-tool-arguments.js +23 -0
  459. package/dist/core/tools/malformed-tool-arguments.js.map +1 -0
  460. package/dist/core/tools/read-url.d.ts.map +1 -1
  461. package/dist/core/tools/read-url.js +6 -1
  462. package/dist/core/tools/read-url.js.map +1 -1
  463. package/dist/core/tools/render-utils.d.ts +2 -0
  464. package/dist/core/tools/render-utils.d.ts.map +1 -1
  465. package/dist/core/tools/render-utils.js +19 -0
  466. package/dist/core/tools/render-utils.js.map +1 -1
  467. package/dist/core/tools/todos-model.js +3 -3
  468. package/dist/core/tools/todos-model.js.map +1 -1
  469. package/dist/core/tools/todos-mutations.js +2 -2
  470. package/dist/core/tools/todos-mutations.js.map +1 -1
  471. package/dist/core/tools/todos-render.js +1 -1
  472. package/dist/core/tools/todos-render.js.map +1 -1
  473. package/dist/core/tools/todos-storage.js +2 -2
  474. package/dist/core/tools/todos-storage.js.map +1 -1
  475. package/dist/extensions/codemode/execute.d.ts.map +1 -1
  476. package/dist/extensions/codemode/execute.js +14 -1
  477. package/dist/extensions/codemode/execute.js.map +1 -1
  478. package/dist/extensions/codemode/tool.d.ts +1 -1
  479. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  480. package/dist/extensions/codemode/tool.js.map +1 -1
  481. package/dist/extensions/herdr/index.d.ts.map +1 -1
  482. package/dist/extensions/herdr/index.js +6 -8
  483. package/dist/extensions/herdr/index.js.map +1 -1
  484. package/dist/extensions/mcp/index.js +1 -1
  485. package/dist/extensions/mcp/index.js.map +1 -1
  486. package/dist/extensions/mcp/tools.d.ts.map +1 -1
  487. package/dist/extensions/mcp/tools.js +6 -1
  488. package/dist/extensions/mcp/tools.js.map +1 -1
  489. package/dist/index-extensions.d.ts +1 -1
  490. package/dist/index-extensions.d.ts.map +1 -1
  491. package/dist/index-extensions.js +1 -1
  492. package/dist/index-extensions.js.map +1 -1
  493. package/dist/index.d.ts +5 -2
  494. package/dist/index.d.ts.map +1 -1
  495. package/dist/index.js +5 -2
  496. package/dist/index.js.map +1 -1
  497. package/dist/main-session-options.d.ts.map +1 -1
  498. package/dist/main-session-options.js +1 -0
  499. package/dist/main-session-options.js.map +1 -1
  500. package/dist/main-session.d.ts +12 -2
  501. package/dist/main-session.d.ts.map +1 -1
  502. package/dist/main-session.js +151 -53
  503. package/dist/main-session.js.map +1 -1
  504. package/dist/main.d.ts.map +1 -1
  505. package/dist/main.js +97 -42
  506. package/dist/main.js.map +1 -1
  507. package/dist/modes/interactive/components/chat-session-host.d.ts +3 -1
  508. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  509. package/dist/modes/interactive/components/chat-session-host.js +18 -5
  510. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  511. package/dist/modes/interactive/components/extension-input.d.ts +1 -1
  512. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  513. package/dist/modes/interactive/components/extension-input.js +2 -2
  514. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  515. package/dist/modes/interactive/components/host-session-picker.js +1 -1
  516. package/dist/modes/interactive/components/host-session-picker.js.map +1 -1
  517. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  518. package/dist/modes/interactive/components/scoped-models-selector.js +9 -5
  519. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  520. package/dist/modes/interactive/components/session-selector-delete.d.ts +1 -1
  521. package/dist/modes/interactive/components/session-selector-delete.d.ts.map +1 -1
  522. package/dist/modes/interactive/components/session-selector-delete.js.map +1 -1
  523. package/dist/modes/interactive/components/session-selector-list.d.ts +12 -9
  524. package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
  525. package/dist/modes/interactive/components/session-selector-list.js +27 -25
  526. package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
  527. package/dist/modes/interactive/components/session-selector.d.ts +8 -4
  528. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  529. package/dist/modes/interactive/components/session-selector.js +31 -21
  530. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  531. package/dist/modes/interactive/components/tree-selector-component.d.ts +5 -1
  532. package/dist/modes/interactive/components/tree-selector-component.d.ts.map +1 -1
  533. package/dist/modes/interactive/components/tree-selector-component.js +20 -3
  534. package/dist/modes/interactive/components/tree-selector-component.js.map +1 -1
  535. package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
  536. package/dist/modes/interactive/components/tree-selector-content.js +2 -9
  537. package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
  538. package/dist/modes/interactive/interactive-bash-compact.js +1 -1
  539. package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
  540. package/dist/modes/interactive/interactive-deferred-startup.js +2 -2
  541. package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
  542. package/dist/modes/interactive/interactive-editor-actions.js +2 -2
  543. package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
  544. package/dist/modes/interactive/interactive-extension-runtime.js +2 -0
  545. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  546. package/dist/modes/interactive/interactive-input-handling.js +6 -4
  547. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  548. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  549. package/dist/modes/interactive/interactive-mode-base.js +2 -1
  550. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  551. package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
  552. package/dist/modes/interactive/interactive-mode-helpers.js +7 -3
  553. package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
  554. package/dist/modes/interactive/interactive-mode-surface.d.ts +5 -5
  555. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  556. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  557. package/dist/modes/interactive/interactive-model-routing.js +12 -7
  558. package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
  559. package/dist/modes/interactive/interactive-queueing.js +8 -5
  560. package/dist/modes/interactive/interactive-queueing.js.map +1 -1
  561. package/dist/modes/interactive/interactive-selectors.js +2 -2
  562. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  563. package/dist/modes/interactive/interactive-session-routing.js +38 -14
  564. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  565. package/dist/modes/interactive/interactive-session-runtime.js +6 -0
  566. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  567. package/dist/modes/interactive/interactive-slash-commands.js +5 -3
  568. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  569. package/dist/modes/interactive/interactive-tui.d.ts +1 -0
  570. package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
  571. package/dist/modes/interactive/interactive-tui.js +9 -2
  572. package/dist/modes/interactive/interactive-tui.js.map +1 -1
  573. package/dist/modes/interactive/program-status-reporter.d.ts +4 -0
  574. package/dist/modes/interactive/program-status-reporter.d.ts.map +1 -1
  575. package/dist/modes/interactive/program-status-reporter.js +45 -6
  576. package/dist/modes/interactive/program-status-reporter.js.map +1 -1
  577. package/dist/modes/interactive-engine/create-isolated-runtime.d.ts.map +1 -1
  578. package/dist/modes/interactive-engine/create-isolated-runtime.js +8 -1
  579. package/dist/modes/interactive-engine/create-isolated-runtime.js.map +1 -1
  580. package/dist/modes/interactive-engine/engine-args.d.ts.map +1 -1
  581. package/dist/modes/interactive-engine/engine-args.js +11 -4
  582. package/dist/modes/interactive-engine/engine-args.js.map +1 -1
  583. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +2 -1
  584. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
  585. package/dist/modes/interactive-engine/extension-ui-bridge.js +9 -1
  586. package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
  587. package/dist/modes/interactive-engine/isolated-runtime.d.ts +1 -1
  588. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  589. package/dist/modes/interactive-engine/isolated-runtime.js +99 -74
  590. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  591. package/dist/modes/interactive-engine/protocol.d.ts +4 -0
  592. package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
  593. package/dist/modes/interactive-engine/protocol.js +39 -1
  594. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  595. package/dist/modes/rpc/rpc-bash-request-owners.js +1 -1
  596. package/dist/modes/rpc/rpc-bash-request-owners.js.map +1 -1
  597. package/dist/modes/rpc/rpc-client-api.d.ts +1 -1
  598. package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
  599. package/dist/modes/rpc/rpc-client-api.js +2 -2
  600. package/dist/modes/rpc/rpc-client-api.js.map +1 -1
  601. package/dist/modes/rpc/rpc-client-process.d.ts +2 -2
  602. package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
  603. package/dist/modes/rpc/rpc-client-process.js +20 -7
  604. package/dist/modes/rpc/rpc-client-process.js.map +1 -1
  605. package/dist/modes/rpc/rpc-client.d.ts +4 -1
  606. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  607. package/dist/modes/rpc/rpc-client.js +6 -2
  608. package/dist/modes/rpc/rpc-client.js.map +1 -1
  609. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  610. package/dist/modes/rpc/rpc-command-handler.js +12 -9
  611. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  612. package/dist/modes/rpc/rpc-provider-auth.js +2 -2
  613. package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
  614. package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
  615. package/dist/modes/rpc/rpc-session-binding.js +10 -0
  616. package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
  617. package/dist/modes/rpc/rpc-terminal-drain.d.ts.map +1 -1
  618. package/dist/modes/rpc/rpc-terminal-drain.js +11 -2
  619. package/dist/modes/rpc/rpc-terminal-drain.js.map +1 -1
  620. package/dist/modes/rpc/rpc-types.d.ts +6 -2
  621. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  622. package/dist/modes/rpc/rpc-types.js.map +1 -1
  623. package/dist/utils/canonical-path.d.ts +5 -0
  624. package/dist/utils/canonical-path.d.ts.map +1 -0
  625. package/dist/utils/canonical-path.js +26 -0
  626. package/dist/utils/canonical-path.js.map +1 -0
  627. package/dist/utils/paths.d.ts +1 -7
  628. package/dist/utils/paths.d.ts.map +1 -1
  629. package/dist/utils/paths.js +1 -15
  630. package/dist/utils/paths.js.map +1 -1
  631. package/docs/codemode.md +2 -0
  632. package/docs/compaction.md +2 -2
  633. package/docs/custom-provider/oauth.md +2 -2
  634. package/docs/custom-provider/override.md +3 -3
  635. package/docs/custom-provider/registration.md +7 -7
  636. package/docs/custom-provider/streaming.md +1 -1
  637. package/docs/custom-provider.md +5 -5
  638. package/docs/docs.json +6 -0
  639. package/docs/environment-variables.md +10 -2
  640. package/docs/extensions/api-reference.md +40 -19
  641. package/docs/extensions/authoring.md +1 -1
  642. package/docs/extensions/events.md +12 -8
  643. package/docs/extensions/ui.md +10 -0
  644. package/docs/extensions.md +2 -2
  645. package/docs/getting-started/installation.md +2 -4
  646. package/docs/json.md +1 -1
  647. package/docs/llama-cpp.md +95 -0
  648. package/docs/models/reference.md +9 -0
  649. package/docs/models-configuration.md +206 -0
  650. package/docs/models.md +11 -1
  651. package/docs/packages/authoring.md +1 -1
  652. package/docs/prompt-templates.md +2 -0
  653. package/docs/providers.md +13 -5
  654. package/docs/quickstart.md +2 -1
  655. package/docs/reference/cli.md +10 -6
  656. package/docs/rpc/protocol.md +10 -4
  657. package/docs/sdk/reference.md +16 -14
  658. package/docs/sdk/web-server.md +6 -7
  659. package/docs/sdk.md +67 -27
  660. package/docs/session-format.md +35 -34
  661. package/docs/sessions.md +56 -17
  662. package/docs/settings.md +38 -25
  663. package/docs/storage.md +387 -0
  664. package/docs/subagents.md +19 -6
  665. package/docs/tools.md +2 -0
  666. package/docs/usage.md +3 -2
  667. package/docs/workflows/api-reference.md +88 -60
  668. package/docs/workflows/authoring.md +2 -1
  669. package/docs/workflows/operations.md +32 -174
  670. package/docs/workflows/reliable-design.md +17 -17
  671. package/examples/extensions/bookmark.ts +2 -2
  672. package/examples/extensions/handoff.ts +2 -2
  673. package/examples/extensions/minimal-mode.ts +1 -8
  674. package/examples/extensions/plan-mode/index.ts +15 -13
  675. package/examples/extensions/preset.ts +8 -8
  676. package/examples/extensions/session-name.ts +1 -1
  677. package/examples/extensions/snake.ts +3 -1
  678. package/examples/extensions/space-invaders.ts +3 -1
  679. package/examples/extensions/subagent/display.ts +4 -6
  680. package/examples/extensions/tic-tac-toe.ts +80 -80
  681. package/examples/sdk/11-sessions.ts +5 -5
  682. package/examples/sdk/13-session-runtime.ts +7 -7
  683. package/examples/sdk/README.md +1 -1
  684. package/npm-shrinkwrap.json +53 -469
  685. package/package.json +17 -9
  686. package/schemas/models.schema.json +67 -34
  687. package/schemas/settings.schema.json +138 -27
  688. package/dist/builtin/workflows/builtin/chunk-7fvrnzhb.js +0 -8
  689. package/dist/builtin/workflows/builtin/chunk-8c3ae7tt.js +0 -11609
  690. package/dist/core/session-manager-migrations.d.ts +0 -11
  691. package/dist/core/session-manager-migrations.d.ts.map +0 -1
  692. package/dist/core/session-manager-migrations.js +0 -80
  693. package/dist/core/session-manager-migrations.js.map +0 -1
@@ -330,6 +330,8 @@ ctx.stage(name: string, options?: StageOptions): StageContext;
330
330
 
331
331
  Creates and registers a named stage synchronously; work starts when you call a method such as `prompt()` or `complete()`. Use it when `ctx.task` is too coarse and direct session control is required.
332
332
 
333
+ On resume, a cached stage declaration stays synchronous. Its replay metadata is saved before the next checkpoint, prompt, task, tool, or workflow completion. Await those operations and handle their rejection normally; a storage failure is not treated as a successful replay.
334
+
333
335
  ### `ctx.ui`
334
336
 
335
337
  ```typescript
@@ -513,14 +515,14 @@ For large handoffs, write artifacts to files, pass their paths with `reads`, and
513
515
 
514
516
  See [Compression and Artifact Handoffs](/workflows/reliable-design#compression-and-artifact-handoffs) and [Filesystem Context](/workflows/reliable-design#filesystem-context) for complete patterns.
515
517
 
516
- ### `context` / `forkFromSessionFile`
518
+ ### `context` / `forkFromSessionId`
517
519
 
518
520
  ```typescript
519
521
  readonly context?: "fresh" | "fork";
520
- readonly forkFromSessionFile?: string;
522
+ readonly forkFromSessionId?: string;
521
523
  ```
522
524
 
523
- Select a clean session or a forked context, with `forkFromSessionFile` naming an explicit fork source. Omitting `context` creates a fresh session unless the runtime is reopening durable state; see [Locally Scoped Stage Prompts](/workflows/reliable-design#locally-scoped-stage-prompts) for choosing fresh reviewer context versus coherent implementation context.
525
+ Select a clean session or a forked context, with `forkFromSessionId` naming an explicit session ID in the selected session store. Use the earlier task's `sessionId`, not its transcript file path. IDs are preserved verbatim, including an empty stored ID. Omitting `context` creates a fresh session unless the runtime is reopening durable state; see [Locally Scoped Stage Prompts](/workflows/reliable-design#locally-scoped-stage-prompts) for choosing fresh reviewer context versus coherent implementation context.
524
526
 
525
527
  ### `group`
526
528
 
@@ -546,16 +548,14 @@ Selects the primary stage model. String values can carry the reasoning suffix de
546
548
 
547
549
  Use `model: "auto"` for prompt-based selection of an execution model and supported effort before session admission. Omission and concrete models keep prior behavior. Shared chain/parallel defaults accept `auto`; each stage receives one decision. The router sees the final supplied prompt, including interpolated inputs and supplied task context, rather than only a stage name.
548
550
 
549
- `modelConstraints?: ModelConstraints` applies hard restrictions to auto selection and execution/compaction fallbacks. Fields are `allowedModels?: string[]`, `allowedProviders?: string[]`, `excludedProviders?: string[]`, `allowedEfforts?: (string | null)[]`, `maxInputCost?: number`, `maxOutputCost?: number`, `minContextWindow?: number`, and `requiredInputs?: ("text" | "image")[]`. Model IDs are exact provider/model IDs. Costs are catalog USD per million tokens including pricing tiers, not task budgets. Efforts are `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`, or `null` for nonreasoning models. Empty allowlists admit nothing. Inherited and stage restrictions all hold; a task override cannot widen shared restrictions. An authored `thinkingLevel` restricts auto selection to that supported effort. The user's [`modelRouting.allowedModels` and `excludedModels`](/settings#modelrouting) settings also apply to every auto stage, including builtin stages that omit a model; `modelConstraints` cannot widen them, and a stage whose filters leave no eligible model fails before launch.
551
+ `modelConstraints?: ModelConstraints` applies hard restrictions to auto selection and execution/compaction fallbacks. Fields are `allowedModels?: string[]`, `allowedProviders?: string[]`, `excludedProviders?: string[]`, `allowedEfforts?: (string | null)[]`, `maxInputCost?: number`, `maxOutputCost?: number`, `minContextWindow?: number`, and `requiredInputs?: ("text" | "image")[]`. Model IDs are exact provider/model IDs. Costs are catalog USD per million tokens including pricing tiers, not task budgets. Efforts are `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`, or `null` for nonreasoning models. Empty allowlists admit nothing. Inherited and stage restrictions all hold; a task override cannot widen shared restrictions. Use `allowedEfforts` to restrict automatic reasoning selection. The user's [`modelRouting.allowedModels` and `excludedModels`](/settings#modelrouting) settings also apply to every auto stage, including builtin stages that omit a model; `modelConstraints` cannot widen them, and a stage whose filters leave no eligible model fails before launch.
550
552
 
551
553
  An auto stage has no session until it receives prompt text. Model-dependent operations such as `compact()` or `cycleModel()` before that point report an error; call `prompt()` first or deliberately select a concrete model with `setModel()`. Session operations after admission keep their normal behavior.
552
554
 
553
- ### `fallbackModels` / `fallbackThinkingLevels`
555
+ ### `fallbackModels`
554
556
 
555
557
  ```typescript
556
558
  readonly fallbackModels?: readonly string[];
557
- /** @deprecated Prefer a reasoning suffix on each fallback model. */
558
- readonly fallbackThinkingLevels?: readonly string[];
559
559
  ```
560
560
 
561
561
  `fallbackModels` tries the primary and each declared fallback in order. If all fail, the stage fails; the current Atomic-selected model is not appended implicitly. To use it as a final fallback, include it explicitly. The chain advances for:
@@ -590,27 +590,16 @@ Resume sends a replacement objective exactly once, including when pause occurred
590
590
 
591
591
  Workflow-code errors, tool failures, validation failures, refusals, content-filter or safety blocks, cancellations, and task failures do not advance the chain. A reattached finished stage starts on the model that last succeeded; if that model fails retryably, the full chain restarts from the primary.
592
592
 
593
- ### `thinkingLevel` (deprecated)
594
-
595
- ```typescript
596
- /** @deprecated Prefer suffixing model/fallbackModels entries with `:level`. */
597
- readonly thinkingLevel?: WorkflowThinkingLevel;
598
- ```
599
-
600
- Sets the default reasoning effort for candidates without a suffix. A suffix on the model string wins.
601
-
602
593
  ### `scopedModels`
603
594
 
604
595
  ```typescript
605
596
  readonly scopedModels?: readonly WorkflowScopedModel[];
606
597
  interface WorkflowScopedModel {
607
598
  readonly model: WorkflowModelValue;
608
- /** @deprecated Prefer a model-string reasoning suffix. */
609
- readonly thinkingLevel?: WorkflowThinkingLevel;
610
599
  }
611
600
  ```
612
601
 
613
- Supplies stage-scoped model objects and optional compatibility reasoning levels. The nested `thinkingLevel` field is deprecated.
602
+ Supplies stage-scoped model values. Use a model-string reasoning suffix to select effort.
614
603
 
615
604
  ### `tools` / `noTools` / `excludedTools`
616
605
 
@@ -653,7 +642,7 @@ readonly schema?: TSchema;
653
642
 
654
643
  Enables one schema-backed `structured_output` call for that item. `ctx.stage`, `ctx.task`, `ctx.chain`, and `ctx.parallel` items accept a TypeBox schema or a plain JSON Schema descriptor object. The calling model supplies `instructions` and a nonempty named `state`, plus optional exact `model` and `fallbackModels` IDs. The tool infers a value matching the schema; that inferred value becomes the schema-backed `stage.prompt(...)` result or `WorkflowTaskResult.structured`. The calling model's arguments are not the result. The inferred result has no fixed size limit beyond the selected model's own output-token limit. Omit `model` to use the current stage chat model. After the primary and explicit fallbacks, the current chat model is tried if it was not already used. Atomic resolves each ID through the stage model registry. A registered classifier is used only when the schema is a finite Choice; otherwise that candidate is skipped and the skip is recorded. A classifier runtime failure advances to the next model unless the request was cancelled or refused for safety.
655
644
 
656
- A schema-backed `StageContext` supports one `prompt()` call, so create another stage for another structured prompt. A missing call, or an inference failure that exhausts the tool's own model chain, receives up to three corrective follow-ups quoting the contract error. That budget is per stage model candidate. A candidate that spends the initial prompt and all three follow-ups without a valid inferred result fails, and the stage advances to the next entry in [`fallbackModels`](#fallbackmodels-/-fallbackthinkinglevels), which receives the original stage prompt and its own fresh budget. With no stage fallback left, the stage fails with the contract error rather than completing. An explicit tool allowlist automatically receives `structured_output`, while items without `schema` do not.
645
+ A schema-backed `StageContext` supports one `prompt()` call, so create another stage for another structured prompt. A missing call, or an inference failure that exhausts the tool's own model chain, receives up to three corrective follow-ups quoting the contract error. That budget is per stage model candidate. A candidate that spends the initial prompt and all three follow-ups without a valid inferred result fails, and the stage advances to the next entry in [`fallbackModels`](#fallbackmodels), which receives the original stage prompt and its own fresh budget. With no stage fallback left, the stage fails with the contract error rather than completing. An explicit tool allowlist automatically receives `structured_output`, while items without `schema` do not.
657
646
 
658
647
  With both `schema` and `output`, ordinary text from the successful `structured_output` message goes to the artifact. The inferred tool result is the typed value. Corrective attempts and later turns cannot replace that pair. If the successful message has no ordinary text, the artifact uses the most recent earlier assistant text without a `structured_output` call, or stays empty with a warning. The pattern builtins save their inter-stage decisions as JSON separately.
659
648
 
@@ -780,7 +769,7 @@ readonly orchestrationContext?: CreateAgentSessionOptions["orchestrationContext"
780
769
 
781
770
  These are advanced host-supplied SDK seams on the runtime `StageOptions` used by embedded integrations, not ordinary workflow-file defaults. The standalone workflow-package authoring declaration intentionally omits most of them and types `sessionManager` and `settingsManager` as `never`, so package-authored workflows should not pass these fields directly.
782
771
 
783
- The runtime strips workflow-owned fields before forwarding session options. Internal durable fields such as `resumeFromSessionFile`, `durableReplayKey`, and `durableAccumulatedDurationMs` are not public authoring options.
772
+ The runtime strips workflow-owned fields before forwarding session options. Internal durable fields such as `resumeFromSessionId`, `durableReplayKey`, and `durableAccumulatedDurationMs` are not public authoring options.
784
773
 
785
774
  ### `name` (step items)
786
775
 
@@ -838,11 +827,10 @@ interface CompleteStageOpts {
838
827
  readonly model?: WorkflowModelValue;
839
828
  readonly maxTokens?: number;
840
829
  readonly fallbackModels?: readonly string[];
841
- readonly fallbackThinkingLevels?: readonly string[];
842
830
  }
843
831
  ```
844
832
 
845
- These options apply to `stage.complete(...)`. `fallbackThinkingLevels` is the same deprecated compatibility helper used by stage options.
833
+ These options apply to `stage.complete(...)`.
846
834
 
847
835
  ### Reasoning levels
848
836
 
@@ -856,17 +844,7 @@ await ctx.task("review", {
856
844
  });
857
845
  ```
858
846
 
859
- The standalone `thinkingLevel` stage option is deprecated. It still applies as a default to any candidate without a suffix, and when both are present the suffix wins, but new workflows should fold the effort into the model strings:
860
-
861
- ```diff
862
- - model: "openai/gpt-5.5",
863
- - fallbackModels: ["anthropic/claude-opus-4-8"],
864
- - thinkingLevel: "high",
865
- + model: "openai/gpt-5.5:high",
866
- + fallbackModels: ["anthropic/claude-opus-4-8:high"],
867
- ```
868
-
869
- This applies everywhere a stage accepts a model: direct `ctx.task`/`ctx.chain`/`ctx.parallel` options, `ctx.stage` options, builtin workflow stage definitions, and workflow parameters. `fallbackThinkingLevels` is an optional compatibility helper aligned by index to `fallbackModels`; it applies only to fallback entries that do not already carry a suffix. Each `WorkflowModelAttempt` reports the resolved model and the effective reasoning effort used for that attempt.
847
+ Reasoning suffixes apply to direct `ctx.task`/`ctx.chain`/`ctx.parallel` options, `ctx.stage` options, builtin workflow stage definitions, and workflow parameters. Each `WorkflowModelAttempt` reports the resolved model and effective reasoning effort for that attempt. Use suffixes rather than separate reasoning fields.
870
848
 
871
849
  ## StageContext
872
850
 
@@ -948,7 +926,7 @@ readonly sessionId: string;
948
926
  readonly sessionFile: string | undefined;
949
927
  ```
950
928
 
951
- Expose the retained session identifier and its optional transcript file. `sessionFile` is `undefined` when no file is available.
929
+ Expose the retained session identifier and its optional transcript file. Use `sessionId` to identify a session in its selected store. `sessionFile` is display metadata and is `undefined` when no file is available; it cannot be used as a fork or resume identity.
952
930
 
953
931
  ### `stage.setModel(model)` / `stage.setThinkingLevel(level)` / `stage.cycleModel()` / `stage.cycleThinkingLevel()`
954
932
 
@@ -1183,9 +1161,9 @@ Each stage snapshot carries its graph position: `parentIds` lists the stages it
1183
1161
 
1184
1162
  ## Programmatic usage
1185
1163
 
1186
- `@bastani/atomic/workflows` is Atomic's published workflow SDK. Import `workflow` from that specifier, import `Type` from `typebox`, and export the definition returned by `workflow({...})`. Workflow helpers may also import the host TypeBox runtime subpaths `typebox/compile` and `typebox/value`; the legacy `@sinclair/typebox` root and matching subpaths remain supported. Keep runtime helpers such as widget factories and shared utilities in a subdirectory outside the top-level discovery scan, such as `.atomic/workflows/lib/`; see [Workflow Locations](/workflows/operations#workflow-locations).
1164
+ `@bastani/atomic/workflows` is Atomic's published workflow SDK. Import `workflow` from that specifier, import `Type` from `typebox`, and export the definition returned by `workflow({...})`. Workflow helpers may also import `typebox/compile` and `typebox/value`. Keep runtime helpers such as widget factories and shared utilities in a subdirectory outside the top-level discovery scan, such as `.atomic/workflows/lib/`; see [Workflow Locations](/workflows/operations#workflow-locations).
1187
1165
 
1188
- Package authors list both `@bastani/atomic` and `typebox` in `peerDependencies`. The `@bastani/atomic` package publishes compiled JavaScript and declarations for `@bastani/atomic/workflows`, `@bastani/atomic/workflows/builtin`, and each `@bastani/atomic/workflows/builtin/*` module. TypeScript resolves those exports directly under `moduleResolution: NodeNext`. When Atomic executes a workflow file or an imported helper, its runtime loader resolves the workflow SDK and supported TypeBox aliases to the same in-memory host modules.
1166
+ Package authors list both `@bastani/atomic` and `typebox` in `peerDependencies`. The `@bastani/atomic` package publishes compiled JavaScript and declarations for `@bastani/atomic/workflows`, `@bastani/atomic/workflows/builtin`, and each `@bastani/atomic/workflows/builtin/*` module. TypeScript resolves those exports directly under `moduleResolution: NodeNext`. When Atomic executes a workflow file or an imported helper, its runtime loader supplies the workflow SDK and current TypeBox modules.
1189
1167
 
1190
1168
  The loader also shares the host's modules for the exact specifiers `@bastani/atomic`, `@bastani/pi-ai`, and `@bastani/pi-ai/providers/all`. These exceptions expose Atomic's public root API and the AI compatibility API and provider transports. The host's versions take precedence over project-local copies, including in standalone-binary installs without project packages. Workflow files and relative imports still refresh on reload. Other deep subpaths resolve from disk. The workflow loader does not share the extension loader's remaining host aliases, including the separate agent-core and UI packages, other AI subpaths, and `proper-lockfile`. Older or alternative hosts without [`getWorkflowHostModules()`](/extensions/api-reference#pi-getworkflowhostmodules) retain filesystem resolution for the three specifiers.
1191
1169
 
@@ -1288,7 +1266,7 @@ Executes a compiled definition programmatically with validated inputs. Empty-inp
1288
1266
 
1289
1267
  #### Stage sessions and adapters
1290
1268
 
1291
- When `opts.adapters` supplies neither `agentSession` nor `prompt`, `run()` uses `createAgentSessionAdapter({ cwd: opts.cwd })`. Each stage then runs its own in-process Atomic `createAgentSession` session with an in-memory `SessionManager`, unless the stage sets `sessionDir` or resumes or forks a session. Stage sessions resolve models, credentials, settings, and resources the same way `createAgentSession` does. A `prompt` adapter on its own answers stage prompts itself, so `run()` adds no default session adapter beside it.
1269
+ When `opts.adapters` supplies neither `agentSession` nor `prompt`, `run()` uses `createAgentSessionAdapter({ cwd: opts.cwd })`. Each stage then runs its own in-process Atomic `createAgentSession` session with persistent session storage by default. Use the stage's `sessionDir` to choose its session directory, or supply an explicitly selected in-memory session manager through a custom adapter for ephemeral stages. A persistent storage failure fails stage creation; it never falls back to memory. Stage sessions resolve models, credentials, settings, and resources the same way `createAgentSession` does. A `prompt` adapter on its own answers stage prompts itself, so `run()` adds no default session adapter beside it.
1292
1270
 
1293
1271
  ```typescript
1294
1272
  function createAgentSessionAdapter(
@@ -1310,7 +1288,7 @@ A custom adapter's `create(options, meta)` receives the stage's session options,
1310
1288
  ```ts
1311
1289
  import { createAgentSessionAdapter, run } from "@bastani/atomic/workflows";
1312
1290
 
1313
- // Default: in-process stage sessions with in-memory session managers.
1291
+ // Default: in-process stage sessions with persistent session storage.
1314
1292
  await run(helloWorld, { name: "Atomic" }, { cwd: process.cwd() });
1315
1293
 
1316
1294
  // Shared options for every stage.
@@ -1355,7 +1333,7 @@ interface RunOpts {
1355
1333
  readonly signal?: AbortSignal;
1356
1334
  readonly deferWorkflowStart?: boolean;
1357
1335
  readonly config?: WorkflowRuntimeConfig;
1358
- readonly durability?: WorkflowDurability;
1336
+ readonly journal?: RunJournalOption;
1359
1337
  readonly models?: WorkflowModelCatalogPort;
1360
1338
  readonly registry?: WorkflowRegistry;
1361
1339
  readonly depth?: number;
@@ -1386,38 +1364,86 @@ The public authoring declaration intentionally excludes runtime-only executor fi
1386
1364
  #### Choosing the durable backend
1387
1365
 
1388
1366
  ```typescript
1389
- type WorkflowDurability =
1390
- | { readonly mode: "memory" }
1391
- | { readonly mode: "durable"; readonly systemDatabaseUrl?: string; readonly poolSize?: number };
1367
+ import type { RunJournalOption } from "@bastani/atomic/workflows";
1392
1368
  ```
1393
1369
 
1394
- `run()` sets up workflow durability itself and shuts it down when the run ends, unless another Atomic session in the same process is still using it. `durability` chooses the backend for one call:
1370
+ `run()` uses the local SQLite journal at `~/.atomic/workflows/journal.sqlite` by default, shared with sessions under separate `wf_` and `session_` table prefixes. It releases the run's lease when execution settles. Select a journal with `RunOpts.journal`:
1395
1371
 
1396
- - **Omitted:** durable, with Atomic's default database selection (`DBOS_SYSTEM_DATABASE_URL`, then its managed Postgres). If Postgres can't start, the run uses memory and prints a warning.
1397
- - **`{ mode: "memory" }`:** runs with an in-memory backend that lasts only for this call. Postgres is never started, and nothing can be resumed after the process exits.
1398
- - **`{ mode: "durable" }`:** requires durable state and fails fast. If the backend can't start, or only an in-memory fallback is available, `run()` rejects with `WorkflowDurabilityRequiredError` before the workflow runs.
1399
- - **`{ mode: "durable", systemDatabaseUrl }`:** also chooses the Postgres database, for example a hosted one, and Atomic doesn't start or manage a local Postgres. `DBOS_SYSTEM_DATABASE_URL` overrides this value when set, so an operator can point a deployment at another database without changing code.
1400
- - **`{ mode: "durable", poolSize }`:** sets the maximum connections per workflow database pool, with or without a URL, including when the URL comes from `DBOS_SYSTEM_DATABASE_URL`. Defaults to 10; must be an integer of at least 2 because an ownership pool holds one long-lived advisory-lock connection and needs another for transactions. Each process opens a DBOS SQL pool and an ownership-fence pool, plus another fence pool after recovery. Lower it for tight hosted connection limits or many processes; raise it for a high-throughput process on a large database.
1372
+ - `{ path }` opens that SQLite file.
1373
+ - `{ database, prefix? }` uses a caller-owned async `SqliteDatabase` facade. Atomic initializes the journal schema on it but does not close the database.
1374
+ - `{ memory: true }` explicitly selects `MemoryRunJournal`. Records last only for the process and cannot recover runs after exit.
1375
+ - `{ adapter, options?, secrets?, prefix? }` loads your installed adapter module. See [Storage adapters](/storage#selecting-an-adapter).
1376
+ - A `RunJournal` instance is used as supplied. `SqlRunJournal`, `openSqlRunJournal`, `MemoryRunJournal`, journal error classes, and `registerRunJournalConformance` are exported from `@bastani/atomic/workflows`.
1401
1377
 
1402
- One process uses one workflow database: DBOS runs a single executor per process, so a later run in the same process that asks for a different URL rejects. Separate processes are independent. The Atomic CLI and any number of SDK applications can each use their own database, or share one, including Atomic's managed Postgres. Each process only recovers its own interrupted runs, and an SDK process that exits doesn't stop the managed Postgres other processes are using.
1378
+ Use `await openSqlRunJournal(path)` to open a file directly, or omit `path` for the default journal. It also accepts a caller-owned `node:sqlite` `DatabaseSync` directly and wraps the connection itself. Pass an async `SqliteDatabase` facade to `SqlRunJournal.open` or `RunOpts.journal.database` instead. `await resolveRunJournal(options)` applies the selection rules below.
1403
1379
 
1404
- While DBOS remains configured, a request for a different `poolSize` rejects. Repeating the same size or omitting it keeps the current configuration.
1380
+ To attach your own SQLite-compatible driver, implement the [async SQLite storage API](/storage) and pass its facade to `SqlRunJournal.open`:
1405
1381
 
1406
1382
  ```ts
1407
- import { run, WorkflowDurabilityRequiredError } from "@bastani/atomic/workflows";
1408
-
1409
- await run(helloWorld, { name: "Atomic" }, { durability: { mode: "memory" } });
1383
+ import { openNodeSqliteDatabase } from "@bastani/atomic/storage";
1384
+ import { SqlRunJournal, run } from "@bastani/atomic/workflows";
1410
1385
 
1386
+ const database = await openNodeSqliteDatabase("./shared.sqlite");
1387
+ const journal = await SqlRunJournal.open(database, { prefix: "project_" });
1411
1388
  try {
1412
- await run(helloWorld, { name: "Atomic" }, {
1413
- durability: { mode: "durable", systemDatabaseUrl: process.env.WORKFLOW_DATABASE_URL },
1414
- });
1415
- } catch (error) {
1416
- if (error instanceof WorkflowDurabilityRequiredError) console.error(error.message);
1417
- throw error;
1389
+ await run(helloWorld, { name: "Atomic" }, { journal });
1390
+ } finally {
1391
+ await journal.close();
1392
+ await database.close();
1393
+ }
1394
+ ```
1395
+
1396
+ `SqlRunJournal.open` leaves ownership of the facade with you. Journal tables use `wf_` names, optionally preceded by your prefix; session tables use a separate namespace in the same database. A new prefix selects an empty journal, not a migration. Bare journal table names from earlier unreleased builds are not read. SQL event and lease timestamps, including expiry checks, use the database clock. Journal storage failures expose `StorageUnavailableError.adapter`, `.location`, and `.cause`; use `.location` rather than `.path`.
1397
+
1398
+ Custom journals implement this full async interface. The named types are exported from `@bastani/atomic/workflows`:
1399
+
1400
+ ```ts
1401
+ interface RunJournal {
1402
+ createRun(header: RunHeader): Promise<"created" | "exists">;
1403
+ getRun(runId: string): Promise<RunSummary | undefined>;
1404
+ listRuns(filter?: { cwd?: string }): Promise<readonly RunSummary[]>;
1405
+ acquire(runId: string, holderId: string): Promise<LeaseOutcome>;
1406
+ takeover(runId: string, holderId: string, expectedHolder: string): Promise<LeaseOutcome>;
1407
+ takeoverExpired(runId: string, holderId: string, staleAfterMs: number): Promise<LeaseOutcome>;
1408
+ leaseState(runId: string): Promise<LeaseState | undefined>;
1409
+ renew(lease: Lease): Promise<void>;
1410
+ release(lease: Lease): Promise<void>;
1411
+ append(lease: Lease, event: RunEvent, options?: { key?: string; expectSeq?: number }): Promise<AppendOutcome>;
1412
+ read(runId: string, fromSeq?: number): AsyncIterable<JournalEntry>;
1413
+ readKey(runId: string, key: string): Promise<JournalEntry | undefined>;
1414
+ deleteOwnedRun(lease: Lease, expectSeq?: number): Promise<void>;
1415
+ deleteRun(runId: string): Promise<void>;
1416
+ close(): Promise<void>;
1418
1417
  }
1419
1418
  ```
1420
1419
 
1420
+ `getRun` returns the current summary or `undefined`. `leaseState` returns the current lease with its `renewedAt` timestamp and `ageMs`, or `undefined` when unheld. `ageMs` is the journal-clock time since renewal, computed in the same read and clamped to a non-negative safe integer. Use it for expiry decisions instead of subtracting `renewedAt` from the process clock. `takeoverExpired` measures a duration on the journal's clock and atomically refuses a foreign lease unless its renewal is strictly older than `staleAfterMs`, returning the `held` outcome while fresh. `read` loads bounded pages only as consumed, in sequence order starting at the inclusive `fromSeq`, which defaults to 1. Stopping iteration must stop further page reads.
1421
+
1422
+ `append` checks lease fencing first, then the idempotency key before `expectSeq`. A committed keyed retry returns `{ status: "exists", entry }` with the original entry even when the retry's sequence expectation is stale. A new key with a stale expectation rejects with `JournalCasConflictError` without writing.
1423
+
1424
+ `SqlRunJournal.append` serializes its payload once at invocation, before asynchronous lease and key checks, so later caller mutation cannot change the event. This invokes `toJSON` once even for a keyed duplicate, which still returns the original entry without writing. For `StatusChanged`, text validation and the run summary's status use the serialized payload, not the original object's status. Header and payload serialization failures retain their original cause in `StorageUnavailableError`; append reports such a failure only after the lease, key, and sequence checks above. A payload that cannot serialize has no status snapshot to validate, even if its original status contains invalid text.
1425
+
1426
+ `deleteOwnedRun` atomically deletes a run only while the lease's `runId`, `holderId`, and `epoch` still match; otherwise it rejects with `StaleLeaseError` and preserves the run and its events. An optional `expectSeq` must equal the latest sequence or the operation rejects with `JournalCasConflictError` without deleting anything. Deletion keeps the last epoch so an old lease cannot delete or write a recreated run. `deleteRun` is an unconditional administrative operation. Inputs and returned records must be detached. `close()` is idempotent, and every later operation rejects.
1427
+
1428
+ Custom journals need only the async contract; no synchronous journal methods are required. Use `registerRunJournalConformance(runner, name, open, observeRead)` to check a fresh journal per case. Supply a read observer that reports actual page sizes and entries loaded or copied, with `restore()` and `reset()` methods, so the suite can verify lazy reads without consuming the whole history.
1429
+
1430
+ Precedence is `RunOpts.journal`, non-empty `ATOMIC_WORKFLOW_JOURNAL_PATH`, `workflows.journal`, shared top-level `storage`, then the default `~/.atomic/workflows/journal.sqlite`. Nearer settings selections replace whole objects, never merge options or secrets. Relative settings paths resolve against Atomic home. Invalid selected values raise `StorageConfigError`; storage failures reject the call without selecting memory. Keep the same journal and working directory when resuming stored runs.
1431
+
1432
+ ```ts
1433
+ import { run } from "@bastani/atomic/workflows";
1434
+
1435
+ await run(helloWorld, { name: "Atomic" }, { journal: { path: "./workflow-runs.sqlite" } });
1436
+ await run(helloWorld, { name: "Atomic" }, { journal: { memory: true } });
1437
+ ```
1438
+
1439
+ #### Durable writes
1440
+
1441
+ Await asynchronous workflow operations before using their results. Atomic commits a successful write before publishing its new state, and shutdown drains accepted journal writes before releasing ownership. A write failure rejects with a typed storage error, not an in-memory fallback.
1442
+
1443
+ For direct durable-backend use, open `JournalDurableBackend` with `await JournalDurableBackend.open(journal, { ownsJournal: false })`, not a constructor. Omit `ownsJournal: false` to let the backend close the journal. Await `commitWorkflowRegistration`, `commitWorkflowStatus`, `commitWorkflowStatusTransition`, `commitPendingPromptAdjustment`, `commitReset`, and `commitCheckpoint`; use `commitAdditiveCheckpointBestEffort` for additive writes.
1444
+
1445
+ `ctx.stage()` remains synchronous. For a cached stage, Atomic commits its replay metadata before the next async execution boundary; callers do not need an extra checkpoint or flush. See [Storage errors](/storage#storage-errors) for configuration, driver, and ownership failures.
1446
+
1421
1447
  ### `resolveInputs(schema, provided)`
1422
1448
 
1423
1449
  ```typescript
@@ -1529,6 +1555,8 @@ interface StoreSnapshot {
1529
1555
 
1530
1556
  `createStore()` returns an isolated workflow state store. `store` is the default singleton exported by the SDK authoring surface.
1531
1557
 
1558
+ Every `RunSnapshot` passed to `recordRunStart()` must include `toolNodes`. Use `toolNodes: []` when the run has no tool nodes.
1559
+
1532
1560
  `snapshot()` returns a JSON copy of every run and notice; `version` increases on every store change. `graphSnapshot()` returns a cached, size-bounded copy for graph rendering that stays the same object until the store changes. `subscribe(listener)` calls `listener` with a fresh `snapshot()` after each change and returns an unsubscribe function.
1533
1561
 
1534
1562
  Atomic's runtime store also has prompt, session, and pause/resume methods used by embedded integrations; those controls are not part of the published `Store` contract shown here.
@@ -632,7 +632,8 @@ The workflow runs a readiness preflight as its own `ctx.tool` first, so a missin
632
632
  import { spawn } from "node:child_process";
633
633
  import { homedir } from "node:os";
634
634
  import { join } from "node:path";
635
- import { Type, workflow } from "@bastani/workflows";
635
+ import { workflow } from "@bastani/atomic/workflows";
636
+ import { Type } from "typebox";
636
637
 
637
638
  const sdkDir = join(homedir(), ".cache", "atomic-cua");
638
639
  const cuaEnv = { ...process.env, CUA_DRIVER_RS_TELEMETRY_ENABLED: "false" };