@bastani/atomic 0.9.20-alpha.8 → 0.9.20-alpha.9

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 (287) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/dist/builtin/intercom/package.json +3 -5
  3. package/dist/builtin/mcp/package.json +3 -3
  4. package/dist/builtin/subagents/CHANGELOG.md +6 -0
  5. package/dist/builtin/subagents/package.json +3 -3
  6. package/dist/builtin/subagents/src/extension/index.bundle.mjs +11 -2
  7. package/dist/builtin/web-access/package.json +1 -1
  8. package/dist/builtin/workflows/CHANGELOG.md +31 -0
  9. package/dist/builtin/workflows/builtin/adversarial-verification.js +3 -3
  10. package/dist/builtin/workflows/builtin/{chunk-ffdrv23t.js → chunk-18yz7r43.js} +1 -1
  11. package/dist/builtin/workflows/builtin/{chunk-9z3ztr2a.js → chunk-1pd5zcfa.js} +1 -1
  12. package/dist/builtin/workflows/builtin/{chunk-5724b0cf.js → chunk-24c235x7.js} +1 -1
  13. package/dist/builtin/workflows/builtin/{chunk-vn0wb31x.js → chunk-2jv44yz7.js} +1 -1
  14. package/dist/builtin/workflows/builtin/{chunk-hmt5w62g.js → chunk-2npg6daz.js} +1 -1
  15. package/dist/builtin/workflows/builtin/{chunk-njmf5ze7.js → chunk-7ps7bnb4.js} +1 -1
  16. package/dist/builtin/workflows/builtin/{chunk-jngsbbpm.js → chunk-ad864596.js} +3 -3
  17. package/dist/builtin/workflows/builtin/{chunk-7n51c5gh.js → chunk-f8jjd90r.js} +1 -1
  18. package/dist/builtin/workflows/builtin/{chunk-3tx8ry44.js → chunk-gxrhbnaj.js} +2 -1
  19. package/dist/builtin/workflows/builtin/{chunk-2hzrv5y8.js → chunk-twefqrv0.js} +986 -199
  20. package/dist/builtin/workflows/builtin/{chunk-7bzcersz.js → chunk-ynded223.js} +3 -3
  21. package/dist/builtin/workflows/builtin/{chunk-dxjxtgmp.js → chunk-z5xdqrs6.js} +1 -1
  22. package/dist/builtin/workflows/builtin/classify-and-act.js +3 -3
  23. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -3
  24. package/dist/builtin/workflows/builtin/generate-and-filter.js +3 -3
  25. package/dist/builtin/workflows/builtin/goal.js +4 -4
  26. package/dist/builtin/workflows/builtin/index.js +12 -12
  27. package/dist/builtin/workflows/builtin/loop-until-done.js +3 -3
  28. package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
  29. package/dist/builtin/workflows/builtin/ralph.js +4 -4
  30. package/dist/builtin/workflows/builtin/steering-context.js +1 -1
  31. package/dist/builtin/workflows/builtin/tournament.js +3 -3
  32. package/dist/builtin/workflows/package.json +4 -4
  33. package/dist/builtin/workflows/src/authoring.d.ts +6 -3
  34. package/dist/builtin/workflows/src/extension/index.bundle.mjs +12092 -11365
  35. package/dist/builtin/workflows/src/index.js +41619 -12907
  36. package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +13 -0
  37. package/dist/core/agent-session-boundaries.d.ts.map +1 -1
  38. package/dist/core/agent-session-boundaries.js +9 -4
  39. package/dist/core/agent-session-boundaries.js.map +1 -1
  40. package/dist/core/agent-session-events.d.ts.map +1 -1
  41. package/dist/core/agent-session-events.js +4 -0
  42. package/dist/core/agent-session-events.js.map +1 -1
  43. package/dist/core/agent-session-methods.d.ts +3 -0
  44. package/dist/core/agent-session-methods.d.ts.map +1 -1
  45. package/dist/core/agent-session-methods.js.map +1 -1
  46. package/dist/core/agent-session-tasks.js +4 -4
  47. package/dist/core/agent-session-tasks.js.map +1 -1
  48. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  49. package/dist/core/agent-session-tool-registry.js +4 -3
  50. package/dist/core/agent-session-tool-registry.js.map +1 -1
  51. package/dist/core/agent-session.d.ts +3 -0
  52. package/dist/core/agent-session.d.ts.map +1 -1
  53. package/dist/core/agent-session.js +3 -0
  54. package/dist/core/agent-session.js.map +1 -1
  55. package/dist/core/cache-stats.d.ts +7 -1
  56. package/dist/core/cache-stats.d.ts.map +1 -1
  57. package/dist/core/cache-stats.js +24 -5
  58. package/dist/core/cache-stats.js.map +1 -1
  59. package/dist/core/execution-model-router.d.ts +1 -1
  60. package/dist/core/execution-model-router.d.ts.map +1 -1
  61. package/dist/core/execution-model-router.js +23 -14
  62. package/dist/core/execution-model-router.js.map +1 -1
  63. package/dist/core/extensions/agent-events.d.ts +9 -1
  64. package/dist/core/extensions/agent-events.d.ts.map +1 -1
  65. package/dist/core/extensions/agent-events.js.map +1 -1
  66. package/dist/core/extensions/api-types.d.ts +2 -1
  67. package/dist/core/extensions/api-types.d.ts.map +1 -1
  68. package/dist/core/extensions/api-types.js.map +1 -1
  69. package/dist/core/extensions/event-types.d.ts +2 -2
  70. package/dist/core/extensions/event-types.d.ts.map +1 -1
  71. package/dist/core/extensions/event-types.js.map +1 -1
  72. package/dist/core/extensions/index.d.ts +1 -1
  73. package/dist/core/extensions/index.d.ts.map +1 -1
  74. package/dist/core/extensions/index.js.map +1 -1
  75. package/dist/core/extensions/loader-core.d.ts.map +1 -1
  76. package/dist/core/extensions/loader-core.js +1 -0
  77. package/dist/core/extensions/loader-core.js.map +1 -1
  78. package/dist/core/extensions/provider-types.d.ts +34 -16
  79. package/dist/core/extensions/provider-types.d.ts.map +1 -1
  80. package/dist/core/extensions/provider-types.js.map +1 -1
  81. package/dist/core/extensions/runtime-types.d.ts +4 -0
  82. package/dist/core/extensions/runtime-types.d.ts.map +1 -1
  83. package/dist/core/extensions/runtime-types.js.map +1 -1
  84. package/dist/core/extensions/tool-types.d.ts +9 -0
  85. package/dist/core/extensions/tool-types.d.ts.map +1 -1
  86. package/dist/core/extensions/tool-types.js.map +1 -1
  87. package/dist/core/fast-model-routing.d.ts.map +1 -1
  88. package/dist/core/fast-model-routing.js +1 -0
  89. package/dist/core/fast-model-routing.js.map +1 -1
  90. package/dist/core/model-registry.d.ts +3 -1
  91. package/dist/core/model-registry.d.ts.map +1 -1
  92. package/dist/core/model-registry.js +6 -0
  93. package/dist/core/model-registry.js.map +1 -1
  94. package/dist/core/model-runtime-auth.d.ts +2 -2
  95. package/dist/core/model-runtime-auth.d.ts.map +1 -1
  96. package/dist/core/model-runtime-auth.js.map +1 -1
  97. package/dist/core/model-runtime-streaming.d.ts.map +1 -1
  98. package/dist/core/model-runtime-streaming.js +2 -1
  99. package/dist/core/model-runtime-streaming.js.map +1 -1
  100. package/dist/core/model-runtime.d.ts +11 -3
  101. package/dist/core/model-runtime.d.ts.map +1 -1
  102. package/dist/core/model-runtime.js +41 -6
  103. package/dist/core/model-runtime.js.map +1 -1
  104. package/dist/core/package-manager-npm.d.ts.map +1 -1
  105. package/dist/core/package-manager-npm.js +32 -8
  106. package/dist/core/package-manager-npm.js.map +1 -1
  107. package/dist/core/package-manager-resolver.js +3 -1
  108. package/dist/core/package-manager-resolver.js.map +1 -1
  109. package/dist/core/package-manager-types.d.ts +1 -0
  110. package/dist/core/package-manager-types.d.ts.map +1 -1
  111. package/dist/core/package-manager-types.js.map +1 -1
  112. package/dist/core/provider-composer-internal.d.ts +40 -21
  113. package/dist/core/provider-composer-internal.d.ts.map +1 -1
  114. package/dist/core/provider-composer-internal.js +22 -20
  115. package/dist/core/provider-composer-internal.js.map +1 -1
  116. package/dist/core/provider-composer.d.ts +3 -3
  117. package/dist/core/provider-composer.d.ts.map +1 -1
  118. package/dist/core/provider-composer.js +54 -10
  119. package/dist/core/provider-composer.js.map +1 -1
  120. package/dist/core/remote-catalog-provider.d.ts +8 -1
  121. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  122. package/dist/core/remote-catalog-provider.js +46 -4
  123. package/dist/core/remote-catalog-provider.js.map +1 -1
  124. package/dist/core/resource-loader-core.d.ts.map +1 -1
  125. package/dist/core/resource-loader-core.js +7 -3
  126. package/dist/core/resource-loader-core.js.map +1 -1
  127. package/dist/core/resource-loader-extension-warnings.d.ts +9 -0
  128. package/dist/core/resource-loader-extension-warnings.d.ts.map +1 -0
  129. package/dist/core/resource-loader-extension-warnings.js +54 -0
  130. package/dist/core/resource-loader-extension-warnings.js.map +1 -0
  131. package/dist/core/resource-loader-extensions.d.ts.map +1 -1
  132. package/dist/core/resource-loader-extensions.js +1 -0
  133. package/dist/core/resource-loader-extensions.js.map +1 -1
  134. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  135. package/dist/core/resource-loader-reload.js +6 -0
  136. package/dist/core/resource-loader-reload.js.map +1 -1
  137. package/dist/core/runtime-credentials.d.ts.map +1 -1
  138. package/dist/core/runtime-credentials.js +3 -1
  139. package/dist/core/runtime-credentials.js.map +1 -1
  140. package/dist/core/sdk.js +16 -6
  141. package/dist/core/sdk.js.map +1 -1
  142. package/dist/core/settings-manager-basic-accessors.js +4 -4
  143. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  144. package/dist/core/structured-output/choice-schema.d.ts +8 -0
  145. package/dist/core/structured-output/choice-schema.d.ts.map +1 -0
  146. package/dist/core/structured-output/choice-schema.js +79 -0
  147. package/dist/core/structured-output/choice-schema.js.map +1 -0
  148. package/dist/core/structured-output/index.d.ts +3 -5
  149. package/dist/core/structured-output/index.d.ts.map +1 -1
  150. package/dist/core/structured-output/index.js +218 -41
  151. package/dist/core/structured-output/index.js.map +1 -1
  152. package/dist/core/structured-output/resolver.d.ts +0 -46
  153. package/dist/core/structured-output/resolver.d.ts.map +1 -1
  154. package/dist/core/structured-output/resolver.js +15 -93
  155. package/dist/core/structured-output/resolver.js.map +1 -1
  156. package/dist/core/structured-output/types.d.ts +27 -21
  157. package/dist/core/structured-output/types.d.ts.map +1 -1
  158. package/dist/core/structured-output/types.js.map +1 -1
  159. package/dist/core/system-prompt.d.ts.map +1 -1
  160. package/dist/core/system-prompt.js +9 -1
  161. package/dist/core/system-prompt.js.map +1 -1
  162. package/dist/core/tasks/owner-store.d.ts +6 -0
  163. package/dist/core/tasks/owner-store.d.ts.map +1 -1
  164. package/dist/core/tasks/owner-store.js +16 -3
  165. package/dist/core/tasks/owner-store.js.map +1 -1
  166. package/dist/core/tasks/pause.js +1 -1
  167. package/dist/core/tasks/pause.js.map +1 -1
  168. package/dist/core/tasks/supervisor.d.ts +4 -2
  169. package/dist/core/tasks/supervisor.d.ts.map +1 -1
  170. package/dist/core/tasks/supervisor.js +9 -3
  171. package/dist/core/tasks/supervisor.js.map +1 -1
  172. package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -1
  173. package/dist/core/tools/ask-user-question/ask-user-question.js +1 -0
  174. package/dist/core/tools/ask-user-question/ask-user-question.js.map +1 -1
  175. package/dist/core/tools/bash.d.ts.map +1 -1
  176. package/dist/core/tools/bash.js +1 -0
  177. package/dist/core/tools/bash.js.map +1 -1
  178. package/dist/core/tools/edit.d.ts.map +1 -1
  179. package/dist/core/tools/edit.js +1 -0
  180. package/dist/core/tools/edit.js.map +1 -1
  181. package/dist/core/tools/file-mutation-coordinator.d.ts +4 -3
  182. package/dist/core/tools/file-mutation-coordinator.d.ts.map +1 -1
  183. package/dist/core/tools/file-mutation-coordinator.js +45 -38
  184. package/dist/core/tools/file-mutation-coordinator.js.map +1 -1
  185. package/dist/core/tools/powershell.d.ts +16 -0
  186. package/dist/core/tools/powershell.d.ts.map +1 -1
  187. package/dist/core/tools/structured-output.d.ts +9 -6
  188. package/dist/core/tools/structured-output.d.ts.map +1 -1
  189. package/dist/core/tools/structured-output.js +36 -8
  190. package/dist/core/tools/structured-output.js.map +1 -1
  191. package/dist/core/tools/todos.d.ts.map +1 -1
  192. package/dist/core/tools/todos.js +1 -0
  193. package/dist/core/tools/todos.js.map +1 -1
  194. package/dist/core/tools/tool-concurrency.d.ts +23 -0
  195. package/dist/core/tools/tool-concurrency.d.ts.map +1 -0
  196. package/dist/core/tools/tool-concurrency.js +58 -0
  197. package/dist/core/tools/tool-concurrency.js.map +1 -0
  198. package/dist/core/tools/tool-definition-wrapper.d.ts +4 -1
  199. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  200. package/dist/core/tools/tool-definition-wrapper.js +2 -0
  201. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  202. package/dist/core/tools/write.d.ts.map +1 -1
  203. package/dist/core/tools/write.js +1 -0
  204. package/dist/core/tools/write.js.map +1 -1
  205. package/dist/index-extensions.d.ts +1 -1
  206. package/dist/index-extensions.d.ts.map +1 -1
  207. package/dist/index-extensions.js.map +1 -1
  208. package/dist/index.d.ts +1 -1
  209. package/dist/index.d.ts.map +1 -1
  210. package/dist/index.js +1 -1
  211. package/dist/index.js.map +1 -1
  212. package/dist/main.d.ts.map +1 -1
  213. package/dist/main.js +4 -0
  214. package/dist/main.js.map +1 -1
  215. package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
  216. package/dist/modes/interactive/components/settings-selector-items.js +11 -9
  217. package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
  218. package/dist/modes/interactive/components/settings-selector-types.d.ts +2 -1
  219. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  220. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  221. package/dist/modes/interactive/components/task-inspector.d.ts +1 -0
  222. package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
  223. package/dist/modes/interactive/components/task-inspector.js +11 -11
  224. package/dist/modes/interactive/components/task-inspector.js.map +1 -1
  225. package/dist/modes/interactive/components/task-list.d.ts +9 -3
  226. package/dist/modes/interactive/components/task-list.d.ts.map +1 -1
  227. package/dist/modes/interactive/components/task-list.js +26 -2
  228. package/dist/modes/interactive/components/task-list.js.map +1 -1
  229. package/dist/modes/interactive/interactive-agent-events.js +3 -9
  230. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  231. package/dist/modes/interactive/interactive-auth-login.js +1 -1
  232. package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
  233. package/dist/modes/interactive/interactive-render-chat.js +3 -9
  234. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  235. package/dist/modes/interactive/interactive-resource-rendering.js +6 -9
  236. package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
  237. package/dist/modes/interactive/interactive-selectors.js +1 -0
  238. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  239. package/dist/modes/interactive/interactive-slash-commands.js +2 -4
  240. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  241. package/dist/modes/interactive-engine/isolated-runtime.d.ts +1 -0
  242. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  243. package/dist/modes/interactive-engine/isolated-runtime.js +5 -0
  244. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  245. package/dist/utils/clipboard-image.d.ts.map +1 -1
  246. package/dist/utils/clipboard-image.js +14 -17
  247. package/dist/utils/clipboard-image.js.map +1 -1
  248. package/docs/background-tasks.md +1 -0
  249. package/docs/computer-use.md +2 -2
  250. package/docs/custom-provider/registration.md +1 -1
  251. package/docs/custom-provider.md +43 -1
  252. package/docs/extensions/authoring.md +22 -3
  253. package/docs/extensions/events.md +18 -0
  254. package/docs/extensions/examples.md +1 -0
  255. package/docs/models/evals.md +31 -79
  256. package/docs/models/model-selection.md +5 -1
  257. package/docs/packages/authoring.md +3 -1
  258. package/docs/providers.md +7 -11
  259. package/docs/sdk/reference.md +18 -42
  260. package/docs/sdk/structured-decisions.md +44 -89
  261. package/docs/sdk.md +1 -1
  262. package/docs/settings.md +6 -6
  263. package/docs/subagents/reference.md +7 -8
  264. package/docs/usage.md +13 -0
  265. package/docs/workflows/api-reference.md +38 -35
  266. package/docs/workflows/authoring.md +113 -1
  267. package/docs/workflows/builtins.md +1 -1
  268. package/docs/workflows/operations.md +51 -29
  269. package/docs/workflows/verification.md +13 -0
  270. package/examples/extensions/README.md +1 -0
  271. package/examples/extensions/debug-provider.ts +90 -0
  272. package/examples/extensions/structured-output.ts +6 -0
  273. package/npm-shrinkwrap.json +32 -32
  274. package/package.json +3 -3
  275. package/dist/builtin/workflows/src/durable/dependency-doctor-types.d.ts +0 -42
  276. package/dist/core/decision-provider.d.ts +0 -4
  277. package/dist/core/decision-provider.d.ts.map +0 -1
  278. package/dist/core/decision-provider.js +0 -12
  279. package/dist/core/decision-provider.js.map +0 -1
  280. package/dist/core/structured-output/jev-client.d.ts +0 -25
  281. package/dist/core/structured-output/jev-client.d.ts.map +0 -1
  282. package/dist/core/structured-output/jev-client.js +0 -174
  283. package/dist/core/structured-output/jev-client.js.map +0 -1
  284. package/dist/core/structured-output/jev.d.ts +0 -5
  285. package/dist/core/structured-output/jev.d.ts.map +0 -1
  286. package/dist/core/structured-output/jev.js +0 -249
  287. package/dist/core/structured-output/jev.js.map +0 -1
@@ -647,11 +647,11 @@ Scopes MCP servers for one stage. The runtime applies the scope before execution
647
647
  readonly schema?: TSchema;
648
648
  ```
649
649
 
650
- Enables a schema-specific, single-use final-answer tool 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 schema may describe an object, array, or primitive, and the captured JSON value becomes the schema-backed `stage.prompt(...)` result or `WorkflowTaskResult.structured`; task text remains formatted JSON for handoffs.
650
+ 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. 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.
651
651
 
652
- A schema-backed `StageContext` supports one `prompt()` call, so create another stage for another structured prompt. Missing or invalid `structured_output` calls receive up to three corrective follow-ups quoting the contract error and reminding the model to call `structured_output` instead of replying with plain JSON. That budget is per model candidate: a candidate that spends the initial prompt and all three follow-ups without a valid call is treated as a failed candidate and the stage advances to the next entry in [`fallbackModels`](#fallbackmodels-/-fallbackthinkinglevels), which receives the original stage prompt and its own fresh budget. The recorded attempt error names what the turn actually looked like — no assistant message after the prompt, an assistant message with empty text, or the `structured_output` validation error — so a repeated external cause is attributable. With no fallback candidate left, the stage fails with the contract error rather than completing. An explicit tool allowlist automatically receives the final-answer tool, while items without `schema` do not.
652
+ 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.
653
653
 
654
- With both `schema` and `output`, ordinary text from the successful `structured_output` message goes to the artifact; tool arguments become the typed result. 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.
654
+ 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.
655
655
 
656
656
  ### `output` / `outputMode`
657
657
 
@@ -662,7 +662,7 @@ readonly outputMode?: "inline" | "file-only";
662
662
 
663
663
  Writes stage/task output to a path or disables output persistence with `false`. `outputMode` defaults to `inline`; `file-only` keeps the parent result compact by returning an artifact reference instead of full text and requires an output path.
664
664
 
665
- The runner owns `output`. For an ordinary stage, it saves the completed assistant answers from the current prompt generation in order. The first answer is unchanged; later answers are appended after `## Supplement 1`, `## Supplement 2`, and so on. Text blocks retain their original text, including whitespace and repeated answers. Tool-call progress, reasoning, user input, tool results and earlier session history remain transcript-only. A single answer therefore keeps its existing artifact format. A schema-backed stage retains its separate contract: the ordinary text paired with the successful `structured_output` call owns the artifact, not the tool arguments.
665
+ The runner owns `output`. For an ordinary stage, it saves the completed assistant answers from the current prompt generation in order. The first answer is unchanged; later answers are appended after `## Supplement 1`, `## Supplement 2`, and so on. Text blocks retain their original text, including whitespace and repeated answers. Tool-call progress, reasoning, user input, tool results and earlier session history remain transcript-only. A single answer therefore keeps its existing artifact format. A schema-backed stage retains its separate contract: the ordinary text paired with the successful `structured_output` call owns the artifact, and the tool's inferred value is the structured result.
666
666
 
667
667
  Follow-ups accepted before the stage closes append numbered supplements. Corrections must say what they correct; Atomic does not infer replacement intent. Later retained-session chat cannot overwrite a completed artifact. Use a new tracked stage and output path for replacement. Compaction, branch navigation, and model fallback do not discard already accepted answers; historical branch text is not appended as new output. Stages without `output` retain their last-response behavior.
668
668
 
@@ -1250,37 +1250,6 @@ registry.names();
1250
1250
  registry.get("alpha");
1251
1251
  ```
1252
1252
 
1253
- ### `workflowDependency(operation?)`
1254
-
1255
- ```typescript
1256
- import {
1257
- workflowDependency,
1258
- type WorkflowDependencyOperation,
1259
- type WorkflowDependencyReport,
1260
- } from "@bastani/atomic/workflows";
1261
-
1262
- const report: WorkflowDependencyReport = await workflowDependency("doctor");
1263
- ```
1264
-
1265
- Accepts `"status" | "doctor" | "recover"`, defaulting to `"status"`. Returns `Promise<WorkflowDependencyReport>` without launching workflow execution. `status` and `doctor` inspect read-only; `recover` may restart only the registered managed cluster while preserving its data. For an external database URL, all three operations only query the configured endpoint. Docker fallback receives guidance rather than lifecycle actions.
1266
-
1267
- Managed `doctor` also checks the installed `postgres`, `pg_ctl` and `initdb` binaries with bounded `--version` commands, without repairing links or permissions. `recover` requires this runtime check before attempting repair of a registered cluster. `status` skips installed-binary checks so an existing server can still be inspected when the local installation is broken.
1268
-
1269
- | Report field | Meaning |
1270
- | --- | --- |
1271
- | `provider` | `managed`, `external`, or `docker` |
1272
- | `state` | `ready`, `unavailable`, `uninitialized`, `checking`, or `recovering` |
1273
- | `checkedAt` | Optional ISO timestamp of the reported check |
1274
- | `runtime` | Current JavaScript `executable` and `version`, plus SQL `postgresVersion` when available. Managed `doctor` and `recover` also report `installation.executable` and `installation.version` after version-only runtime checks. |
1275
- | `endpoint` | Optional actual `host` and `port`, without URL credentials |
1276
- | `cluster` | Optional trusted managed cluster metadata, including cluster ID, data directory, directory identity, major version and published server identity |
1277
- | `identityVerified` | Whether managed SQL/data/process identity agreed during this check; external reachability does not grant managed ownership |
1278
- | `consumers` | Conservative live managed-consumer leases with process and runtime identity, not workflow counts |
1279
- | `lastFailure` | Optional most recently observed failure, retained after successful checks until a newer failure replaces it. Process-local, not a persisted incident history; use `state` for current availability. |
1280
- | `guidance` | Safe next steps for the reported condition |
1281
-
1282
- The response budget is five seconds. A `checking` or `recovering` report leaves the existing operation running; concurrent calls join it instead of starting another operation. These states do not confirm availability or recovery success. Inspect again before resuming the original run ID. The workflow tool returns `{ action: "dependency", operation, report }`; `/workflow dependency [status|doctor|recover]` exposes the same capability. See [database inspection and recovery](/workflows/operations#inspecting-and-recovering-the-workflow-database) for troubleshooting and safety limits.
1283
-
1284
1253
  ### `run(definition, inputs, opts?)`
1285
1254
 
1286
1255
  ```typescript
@@ -1323,6 +1292,7 @@ interface RunOpts {
1323
1292
  readonly signal?: AbortSignal;
1324
1293
  readonly deferWorkflowStart?: boolean;
1325
1294
  readonly config?: WorkflowRuntimeConfig;
1295
+ readonly durability?: WorkflowDurability;
1326
1296
  readonly models?: WorkflowModelCatalogPort;
1327
1297
  readonly registry?: WorkflowRegistry;
1328
1298
  readonly depth?: number;
@@ -1347,6 +1317,39 @@ Supplies runtime adapters, execution policy, persistence, MCP, cancellation, gra
1347
1317
 
1348
1318
  The public authoring declaration intentionally excludes runtime-only executor fields such as `defaultSessionDir`, `gitWorktreeSetupCache`, `durableBackend`, `durableScope`, and `onStageSession`.
1349
1319
 
1320
+ #### Choosing the durable backend
1321
+
1322
+ ```typescript
1323
+ type WorkflowDurability =
1324
+ | { readonly mode: "memory" }
1325
+ | { readonly mode: "durable"; readonly systemDatabaseUrl?: string };
1326
+ ```
1327
+
1328
+ `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:
1329
+
1330
+ - **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.
1331
+ - **`{ 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.
1332
+ - **`{ 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.
1333
+ - **`{ 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.
1334
+
1335
+ 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.
1336
+
1337
+ ```ts
1338
+ import { run, WorkflowDurabilityRequiredError } from "@bastani/atomic/workflows";
1339
+
1340
+ await run(helloWorld, { name: "Atomic" }, { adapters, durability: { mode: "memory" } });
1341
+
1342
+ try {
1343
+ await run(helloWorld, { name: "Atomic" }, {
1344
+ adapters,
1345
+ durability: { mode: "durable", systemDatabaseUrl: process.env.WORKFLOW_DATABASE_URL },
1346
+ });
1347
+ } catch (error) {
1348
+ if (error instanceof WorkflowDurabilityRequiredError) console.error(error.message);
1349
+ throw error;
1350
+ }
1351
+ ```
1352
+
1350
1353
  ### `resolveInputs(schema, provided)`
1351
1354
 
1352
1355
  ```typescript
@@ -62,7 +62,7 @@ const result = await ctx.task("analyze", {
62
62
 
63
63
  Long prompts are excerpted for model selection only; the stage still receives the full execution prompt. The excerpt preserves the beginning, end, and `<keepContext>...</keepContext>` spans. Protect essential selection requirements with those tags, since unprotected middle text may be omitted. If protected text cannot fit, the normal router context-limit and fallback behavior applies. Hard `modelConstraints` remain enforced independently.
64
64
 
65
- The shared `routerModel` setting chooses the decision provider. It does not choose which workflow to launch. Jev can make the decision but never executes the stage. See [automatic stage operation](/workflows/operations#automatic-stage-models) for failures and resume behavior.
65
+ An explicit `routerModel` chooses the routing decision provider. An unset or `auto` value uses the current chat model; saved classifier credentials do not change that choice. The setting does not choose which workflow to launch. A classifier can make the routing decision but never executes the stage. See [automatic stage operation](/workflows/operations#automatic-stage-models) for failures and resume behavior.
66
66
 
67
67
  **Write workflow code for both Atomic hosts.** Standalone binaries run under Bun; npm installs run under Node. A `Bun.*` global is available only when Atomic itself runs under Bun. Otherwise it fails with `Bun is not defined`, even if Bun is installed separately.
68
68
 
@@ -523,6 +523,8 @@ Prerequisites and setup, each as one bounded attempt:
523
523
  - The `cua-driver` executable (`cua-driver --version`), installed with upstream's one-line installer if missing, followed by `cua-driver telemetry disable` once.
524
524
  - The SDK installed at the exact driver version into a scratch directory outside the user's repository, for example `npm install @trycua/cua-driver@0.28.2 --prefix ~/.cache/atomic-cua`. The package ships per-platform native optional dependencies. Daemon-backed clients verify contract, tool-schema, capability, and protocol versions before each action and refuse on mismatch, so the pin must match `cua-driver --version`.
525
525
 
526
+ The executable installer does not install an agent skill. Atomic bundles the skill, so skip upstream's optional `cua-driver skills install`, `cua-driver skills update`, and `clawhub install @cua/driver` steps; leave existing user-level skills alone.
527
+
526
528
  The scenario itself is a small script in that scratch directory. It acquires the driver with `CuaDriver.connect()` when a daemon is running, so it reuses the daemon's permission identity (on macOS, `CuaDriver.app`'s Accessibility and Screen Recording grants) and the persisted telemetry-off preference; upstream describes `connect()` as a compatibility and app-hosting path, which is exactly the role it plays here. Only when no daemon is reachable does it fall back to `CuaDriver.create()`, which loads the runtime into the node process. On macOS that in-process fallback attributes permissions to the node host, normally the terminal app, as a **separate grant** from the app's; `checkPermissions` is then read-only, and the host must fully quit and relaunch after granting. Save it as `~/.cache/atomic-cua/verify-counter.mjs`:
527
529
 
528
530
  ```js
@@ -702,6 +704,116 @@ export default workflow({
702
704
 
703
705
  A `verified` result is cached durably, so a resumed run does not click again. A thrown `refuted`, `blocked`, or `unknown` result fails the node and is not replayed from cache; a new run executes the preflight and the scenario again from a fresh snapshot, and a durable retry of a resumable failure replays the completed preflight checkpoint and re-runs only the scenario. Keep the artifacts directory outside the repository unless the evidence belongs in the deliverable, and never post the installation UUID from `cua-driver telemetry status` in a result or reason. Safety is the same on both faces: one controller per desktop, a dedicated session or account where practical, and an explicit stopping point before destructive or publishing actions.
704
706
 
707
+ ### Classifier and image models in `ctx.tool`
708
+
709
+ Workflow stages run chat language models. For a schema-backed decision, use the stage's `schema` and `structured_output` tool. It resolves an exact chat or registered classifier ID through the stage model registry and falls back on a classifier runtime failure. The direct `@bastani/pi-ai` examples below are for cases that need the classifier's probabilities or image generation from workflow TypeScript inside `ctx.tool(name, args, fn, { timeoutMs })`. Those calls are durable, replayable nodes. `model: "auto"` selects only chat language models for stage execution; `routerModel` may select a classifier for routing, but a classifier never executes a chat stage.
710
+
711
+ Discovery loads a workflow file with the project that owns it as the module root. The host provides `@bastani/atomic/workflows` and `typebox`; other imports, including `@bastani/atomic` for `AuthStorage`, resolve from that project's `node_modules` in npm and standalone-binary installs alike. Install both libraries next to the workflow at the version `atomic --version` prints, because older releases have no `classify()` or `generateImages()`:
712
+
713
+ ```sh
714
+ npm install --save-dev @bastani/atomic@"$(atomic --version)" @bastani/pi-ai@"$(atomic --version)"
715
+ ```
716
+
717
+ Pass `AuthStorage.create()` to `builtinModels()` so classifier and image requests use credentials saved by Atomic's `/login` flows in `auth.json`; this is the recommended default for workflows running inside Atomic. Ambient provider environment variables such as `TYPESAFE_API_KEY` and `OPENROUTER_API_KEY` continue to work. Never read, print, or pass credential values in workflow state, prompts, or artifacts. Both operations resolve instead of throwing: check `stopReason === "stop"` before using a result, and forward the tool's `signal` so a quit or targeted abort cancels the request.
718
+
719
+ #### Classify a request before choosing a stage
720
+
721
+ Use a classifier for a narrow, structured decision such as routing an incoming request. This follows TypeSafe's [intent routing](https://docs.typesafe.ai/patterns/intent-routing.md) and [confidence-gated routing](https://docs.typesafe.ai/patterns/confidence-routing.md) patterns (index: [docs.typesafe.ai/llms.txt](https://docs.typesafe.ai/llms.txt)): one Choice question returns the selected option with a probability per option and a confidence value, and your code decides what to do with that answer. The classifier does **not** execute a stage; workflow code reads its answer and starts a chat stage or asks for human review. Pick thresholds for your own stakes, as TypeSafe's pattern pages do; a threshold is not a guarantee of correctness. In `.atomic/workflows/triage.ts`:
722
+
723
+ ```ts
724
+ import { AuthStorage } from "@bastani/atomic";
725
+ import { workflow } from "@bastani/atomic/workflows";
726
+ import { builtinModels } from "@bastani/pi-ai/providers/all";
727
+ import { Type } from "typebox";
728
+
729
+ export default workflow({
730
+ name: "triage",
731
+ description: "Route a support request to a suitable handler.",
732
+ inputs: { request: Type.String() },
733
+ outputs: { handler: Type.String() },
734
+ run: async (ctx) => {
735
+ const request = ctx.inputs.request;
736
+ const decision = await ctx.tool("classify-intent", { request }, async ({ signal }) => {
737
+ const models = builtinModels({ credentials: AuthStorage.create() });
738
+ const model = models.getModelOfType("classifier", "typesafe", "jev-latest");
739
+ if (!model) throw new Error("TypeSafe classifier is unavailable");
740
+ const result = await models.classify(model, {
741
+ state: { request },
742
+ questions: {
743
+ intent: {
744
+ type: "choice",
745
+ instructions: "Which support handler should review this request?",
746
+ criteria: {
747
+ account: "Questions about an existing account",
748
+ product: "Questions about product behavior",
749
+ other: "Neither account nor product",
750
+ },
751
+ },
752
+ },
753
+ }, { signal });
754
+ if (result.stopReason !== "stop") throw new Error(result.errorMessage ?? "Classification failed");
755
+ const intent = result.answers.intent;
756
+ if (intent?.type !== "choice") throw new Error("Missing intent answer");
757
+ return { choice: intent.choice, confidence: intent.confidence };
758
+ }, { timeoutMs: 60_000 });
759
+
760
+ // Only workflow code chooses the next action; uncertain requests go to a person.
761
+ if (decision.confidence < 0.7 || decision.choice === "other") {
762
+ return { handler: "human review required" };
763
+ }
764
+ await ctx.task(`${decision.choice}-review`, {
765
+ prompt: `Review this ${decision.choice} request and propose a response: ${request}`,
766
+ });
767
+ return { handler: decision.choice };
768
+ },
769
+ });
770
+ ```
771
+
772
+ The cached `{ choice, confidence }` is what a resumed run replays; the classifier is not asked again. For a consequential action, add policy checks or `ctx.ui.confirm(...)` before the side effect. Without the extra install, a schema-backed stage or task (`ctx.task(name, { schema, prompt })`, as the `classify-and-act` builtin does) can also make a validated decision. Its `structured_output` call can name a registered classifier or omit `model` and use the current chat model. A classifier probability is available only from a direct `classify()` call like the example above; a chat result does not supply one.
773
+
774
+ #### Generate an image artifact in a durable tool step
775
+
776
+ For an illustrative asset or a design mock, call an image model inside `ctx.tool()` and write the returned base64 image to a file; the cached node returns only the path. Image generation uses `generateImages()`, never a stage prompt or `structured_output`. In `.atomic/workflows/preview-asset.ts`:
777
+
778
+ ```ts
779
+ import { mkdir, writeFile } from "node:fs/promises";
780
+ import { dirname, join } from "node:path";
781
+ import { AuthStorage } from "@bastani/atomic";
782
+ import { workflow } from "@bastani/atomic/workflows";
783
+ import { builtinModels } from "@bastani/pi-ai/providers/all";
784
+ import { Type } from "typebox";
785
+
786
+ export default workflow({
787
+ name: "preview-asset",
788
+ description: "Generate a draft visual asset for review.",
789
+ inputs: { brief: Type.String() },
790
+ outputs: { imagePath: Type.String() },
791
+ run: async (ctx) => {
792
+ const brief = ctx.inputs.brief;
793
+ const outputDir = join(ctx.cwd ?? process.cwd(), ".atomic", "workflow-assets", ctx.runId ?? "local");
794
+ const generated = await ctx.tool("generate-preview", { brief, outputDir }, async ({ signal }) => {
795
+ const models = builtinModels({ credentials: AuthStorage.create() });
796
+ const model = models.getModelOfType("image", "openrouter", "google/gemini-2.5-flash-image");
797
+ if (!model) throw new Error("OpenRouter image model is unavailable");
798
+ const result = await models.generateImages(model, {
799
+ input: [{ type: "text", text: `Draft visual asset: ${brief}` }],
800
+ }, { signal });
801
+ if (result.stopReason !== "stop") throw new Error(result.errorMessage ?? "Image generation failed");
802
+ const image = result.output.find((block) => block.type === "image");
803
+ if (!image) throw new Error("The response contained no image");
804
+ const extension = image.mimeType === "image/jpeg" ? "jpg" : image.mimeType === "image/webp" ? "webp" : "png";
805
+ const imagePath = join(outputDir, `preview.${extension}`);
806
+ await mkdir(dirname(imagePath), { recursive: true });
807
+ await writeFile(imagePath, Buffer.from(image.data, "base64"));
808
+ return { imagePath };
809
+ }, { timeoutMs: 120_000 });
810
+ return { imagePath: generated.imagePath };
811
+ },
812
+ });
813
+ ```
814
+
815
+ Hand the path to a later chat stage in its prompt. Review generated assets before publishing them or citing them as evidence: a generated image is not proof of a real-world state.
816
+
705
817
  ### Workflow Composition
706
818
 
707
819
  Use workflow composition when a workflow calls a reusable user-defined workflow from the project or package, or a bundled builtin workflow, and consumes its outputs as a tracked boundary stage. Import the child definition with a normal TypeScript import, then pass it directly to `ctx.workflow(workflowDefinition, options)`. `ctx.workflow(...)` does not accept registry names, path objects, or string aliases.
@@ -100,7 +100,7 @@ Builtin stages report evidence and bounded results. Give each run a concrete obj
100
100
 
101
101
  All nine builtins default to `model: "auto"` for every model stage, including review, scoring, repair and final handoff stages. This also applies when you import a builtin as a child with `ctx.workflow(...)`. Each stage routes independently from its actual prompt; reviewers may select the same model. Builtins no longer ship concrete fallback chains.
102
102
 
103
- Use `/settings` → **Router model** to choose the decision provider without changing your main-chat model. Routing failures stop that stage before execution; inspect `/workflow status <run-id>` and correct the reported router, credentials or eligibility problem before retrying. See [automatic stage models](/workflows/operations#automatic-stage-models) for failure and resume behavior.
103
+ Use `/settings` → **Router model** to choose the decision provider without changing your main-chat model. Unset and `auto` use the current chat model. A complete routing failure can still run the stage on that chat model when it satisfies the stage constraints; otherwise the stage stops before execution. Inspect `/workflow status <run-id>` and correct the reported router, credentials, or eligibility problem before retrying. See [automatic stage models](/workflows/operations#automatic-stage-models) for failure and resume behavior.
104
104
 
105
105
  Explicit `tournament` `models` inputs still assign attempt models in their supplied order, round-robin; an omitted or empty list uses automatic routing. Custom workflow definitions keep their existing defaults. For an explicit model, effort or capability requirement in your own stages, use the [stage model options](/workflows/authoring#automatic-stage-model-selection).
106
106
 
@@ -8,7 +8,7 @@ For stages authored with `model: "auto"`, Atomic ranks up to three distinct elig
8
8
 
9
9
  Model selection uses the actual stage prompt, stage name, hard constraints, eligible model catalog, and compact dated evaluation records, not full human guides. Stage system and appended system prompts are not sent to the model router. Put requirements that should influence model selection in the stage prompt; the execution session still receives its configured system prompts.
10
10
 
11
- Malformed or schema-invalid routing answers receive up to three corrective retries after the initial attempt, independently for Jev and any current-chat fallback, and transient provider failures (connection errors, HTTP 408, 429 and 5xx) are retried up to three times with backoff. Model selection has no built-in wall-clock deadline; cancellation and independent provider limits still apply. Any Jev failure triggers a reported switch to the current chat model, whether the router was selected automatically or pinned. If routing inference fails completely — Jev and the chat structured-output fallback both — the stage runs on the current chat model instead of failing, with a recorded warning, but only when that model is available and satisfies every routing constraint (such as `allowedModels` and effort, cost, context and input limits). Otherwise the stage fails. An empty eligible catalog, stale decisions, credential-bearing routing context and cancellation still prevent stage execution without fallback. Choose router and chat providers permitted to receive the stage task and reference context.
11
+ Malformed or schema-invalid chat routing answers receive up to three corrective retries after the initial attempt. A classifier routing failure, including a provider size or context rejection, switches to the current chat model instead of repeating the classifier request. Transient provider failures (connection errors, HTTP 408, 429 and 5xx) are retried up to three times with backoff. Model selection has no built-in wall-clock deadline; cancellation and independent provider limits still apply. An unset or `auto` router uses the current chat model; an explicit `routerModel` selects a registered classifier or chat model. Saved classifier credentials do not select the router. If routing inference fails completely, the stage runs on the current chat model instead of failing, with a recorded warning, but only when that model is available and satisfies every routing constraint (such as `allowedModels` and effort, cost, context and input limits). Otherwise the stage fails. An empty eligible catalog, stale decisions, credential-bearing routing context and cancellation still prevent stage execution without fallback. Choose router and chat providers permitted to receive the stage task and reference context.
12
12
 
13
13
  Replay reuses recorded results without routing. Resume of a saved auto stage retains its verified selection and revalidates it against the current catalog and restrictions before fresh session admission, without a hidden new decision. If it is no longer eligible, resume fails rather than choosing another model. See [authoring automatic stages](/workflows/authoring#automatic-stage-model-selection).
14
14
 
@@ -105,7 +105,6 @@ The workflow tool action surface is:
105
105
  - inspection: `status`, `stages`, `stage`, `transcript`
106
106
  - prompt response: `answer`; run control: `pause`, `quit`, `resume`; free-form stage communication: ordinary Intercom `send`/live `ask` to `workflow:<rootRunId>/<segment>[/<segment>...]` path targets, including `*` and `**` globs
107
107
  - rediscovery: `reload`
108
- - database diagnostics: `dependency` with `operation: "status"`, `"doctor"`, or `"recover"`
109
108
 
110
109
  Every registered `workflow` tool call has one hard two-minute wall-clock deadline at the shared public tool boundary. The deadline covers request handling through the returned result; for background `run` and `resume`, it therefore covers startup/resume admission and acknowledgement only, not the workflow execution that continues after acknowledgement. A deadline returns one structured result:
111
110
 
@@ -180,7 +179,6 @@ Graph node cards show each model stage's effective model and thinking level abov
180
179
  /workflow pause [run-id|--all]
181
180
  /workflow status [run-id]
182
181
  /workflow status --all
183
- /workflow dependency [status|doctor|recover]
184
182
  /workflow quit <run-id|--all>
185
183
  /workflow resume <run-id> [stage-id-or-name] [message]
186
184
  /workflows [full-workflow-uuid]
@@ -458,6 +456,8 @@ The readiness prompt can be answered in the attached stage UI or with `workflow(
458
456
 
459
457
  Atomic workflows use **DBOS/Postgres as their sole persistent workflow backend**. Atomic configures and launches DBOS lazily on the first workflow action, reuses that process-wide instance, and awaits readiness before workflow execution, resume, inspection, or deletion can access durable state. `DBOS_SYSTEM_DATABASE_URL` may select an existing database. Once DBOS is ready, query and write failures fail the workflow action and never switch backends.
460
458
 
459
+ SDK callers can choose the backend and database for each `run()` call, and require durable state so a run fails fast instead of using the in-memory fallback; see [Choosing the durable backend](/workflows/api-reference#choosing-the-durable-backend).
460
+
461
461
  Root database registration has a 10-second deadline. First-time database provisioning and DBOS initialization are outside that deadline and can take longer. If registration fails or is cancelled, that attempt cannot start workflow code later when PostgreSQL returns. For an outage, restore the database before retrying; do not delete its data to bypass the failure. Authentication and schema errors keep their original diagnostics so you can correct the reported problem. A failed admission can remain a local same-ID retry target, but it is not confirmation that the run was saved for cross-session resume. A previously initialized durable backend does not fall back to in-memory execution after losing its connection.
462
462
 
463
463
  Pausing during startup acknowledges the local pause immediately and retains the live executor for resume, without waiting for database admission. Workflow code stays held until explicit resume. Registration continues under its existing 10-second deadline; inspect `/workflow status <run-id>` for a later persistence error. Do not start a replacement run or delete database records to bypass the error.
@@ -488,17 +488,45 @@ The first workflow action initializes and starts the database. Concurrent Atomic
488
488
 
489
489
  Cluster ownership records live beside the data in `~/.atomic/postgres/v18.shared`, outside Atomic installation/version directories. On Linux root installs, use `/var/lib/atomic-postgres/v18.shared`. Preserve these records and the existing data if Atomic reports an identity mismatch or missing `PG_VERSION`; do not delete either to force initialization. Closing or reloading an updated Atomic client does not stop a ready shared server. Older clients without this lifetime behavior can still stop servers they started, so finish and close those sessions before relying on the updated behavior for long-running work. An explicit `DBOS_SYSTEM_DATABASE_URL` remains outside managed-cluster lifecycle operations.
490
490
 
491
+ New managed PostgreSQL servers start from a complete, immutable runtime under
492
+ `~/.atomic/postgres/pg-runtime` (or `/var/lib/atomic-postgres/pg-runtime` when
493
+ running as root on Linux), separate from data and project checkouts. Removing
494
+ the original worktree or reinstalling packages does not remove files needed by
495
+ a server already using that runtime. Do not delete a runtime generation,
496
+ including a damaged one, while a managed server may still use it.
497
+ Set `ATOMIC_POSTGRES_RUNTIME_CACHE_DIR` before starting Atomic to share retained runtime generations across separate cluster homes; only the runtime cache moves, not cluster data or ownership records. Keep this directory private to a trusted account and do not remove generations while a server may use them.
498
+
491
499
  **Running as root on Linux.** Atomic needs an available unprivileged account, `postgres`, `nobody`, or `daemon`, because PostgreSQL cannot run as root. The cluster is stored under `/var/lib/atomic-postgres`. If privilege or runtime preparation fails, inspect the diagnostic rather than changing data ownership blindly.
492
500
 
493
- **Administrator accounts (Windows).** Atomic can start embedded Postgres from an elevated terminal or an administrative account without changing your account or system permissions. The server runs with reduced privileges, as it does under PostgreSQL's own launcher. Regular Windows accounts remain supported. On either path, server output goes to `~/.atomic/postgres/v18.log`, not your terminal; unrelated commands starting concurrently do not keep the server's log file open. If Postgres exits during startup, Atomic reports the recent log output instead of waiting for a generic readiness timeout. Check that log for configuration or cluster errors; do not delete the cluster while a server may still be using it.
501
+ **Administrator accounts (Windows).** Atomic can start embedded Postgres from an elevated terminal or an administrative account without changing your account or system permissions. The server runs with reduced privileges, as it does under PostgreSQL's own launcher. Regular Windows accounts remain supported.
502
+
503
+ Managed PostgreSQL writes startup output to `~/.atomic/postgres/v18.log` and, after startup, server logs to `~/.atomic/postgres/v18/log/postgresql-<Day>.log`, rotating daily through seven weekday files. If Postgres exits during startup, Atomic reports recent output from both logs. Check these logs for configuration or cluster errors; do not delete the cluster while a server may still be using it.
494
504
 
495
505
  Set `ATOMIC_POSTGRES_PORT` before starting Atomic to choose a preferred loopback port, for example `ATOMIC_POSTGRES_PORT=15439 atomic`. The default is `5439`; valid values are integers from 1 through 65535. An occupied port causes Atomic to choose another loopback port without changing or stopping the listener. Concurrent sessions use one elected starter and discover the verified actual port from `v18.shared/cluster.json`. A persisted port takes precedence over a changed preference. Startup bind races have at most three attempts; inspect `v18.log` if they fail.
496
506
 
497
- Atomic checks PostgreSQL readiness and matches the server to the managed data and process identity before attachment. A listening TCP port alone is not sufficient. If an existing cluster has no trusted ownership records, Atomic refuses to adopt or initialize it. Preserve its data and use an explicit `DBOS_SYSTEM_DATABASE_URL` for that database instead. An explicit URL uses only that endpoint, never alternate managed ports.
507
+ Atomic checks PostgreSQL readiness and matches the server to the managed data and process identity before attachment. A listening TCP port alone is not sufficient. If an existing cluster has no trusted ownership records, Atomic registers it only when it is the embedded cluster an older Atomic (0.9.10–0.9.19) provisioned, recognized by PostgreSQL major version 18 and the loopback launch of that exact data directory recorded in `postmaster.opts`; registration never reinitializes or modifies the data. Any other unregistered data is refused, and recovery never registers a cluster. Preserve refused data and use an explicit `DBOS_SYSTEM_DATABASE_URL` for that database instead. An explicit URL uses only that endpoint, never alternate managed ports.
498
508
 
499
509
  After attachment, Atomic checks the managed server's SQL and process identity before borrowing database connections and every five seconds while idle. Lost health discards old connections. One elected process may restart the existing managed cluster under the shared setup lock; other sessions reconnect to its verified, persisted port. Recovery never initializes missing data, signals an unrelated listener, switches to Docker, or restarts the DBOS executor.
500
510
 
501
- Each process makes at most three recovery attempts per outage, with 250ms and 500ms backoffs. If they fail, monitoring still detects a restored server but does not keep restarting it. Inspect `v18.log`, correct the reported runtime or identity problem, and preserve both the data and ownership records. New admission keeps its 10-second deadline even if shared recovery takes longer. Restoring the connection does not automatically resume a paused run or prove that an interrupted write or external side effect committed. Inspect the original run before retrying. External database URLs receive no managed recovery; restore that exact endpoint yourself.
511
+ Each process makes at most three recovery attempts per check, with short
512
+ backoffs. Later health checks retry after a cooldown if the problem persists.
513
+ If the retained PostgreSQL runtime is damaged or missing, reinstall a complete
514
+ healthy Atomic package or repair your `ATOMIC_POSTGRES_RUNTIME_DIR` override,
515
+ then inspect `v18.log`. Atomic can select a verified replacement, including
516
+ after a same-version reinstall, even when the damaged runtime prevents new
517
+ database connections. A running server must pass process-identity verification
518
+ before Atomic stops it; if the server has already exited, Atomic starts from
519
+ the replacement without stopping anything. If a present server's identity
520
+ cannot be verified, automatic restart is refused; preserve the data,
521
+ `v18.shared`, and damaged runtime, and report the diagnostic for help instead
522
+ of deleting files or starting another server. Identity mismatches and database
523
+ corruption require investigation, not a package reinstall.
524
+ New admission keeps its
525
+ 10-second deadline even if shared recovery takes longer. Restoring the
526
+ connection does not automatically resume a paused run or prove that an
527
+ interrupted write or external side effect committed. Inspect the original run
528
+ before retrying. External database URLs receive no managed recovery; restore
529
+ that exact endpoint yourself.
502
530
 
503
531
  Restart Atomic after upgrading to enable health supervision in a session whose database executor was already initialized by an older version.
504
532
 
@@ -516,29 +544,21 @@ Fallback starts only after failed DBOS initialization has been cleaned up. If At
516
544
 
517
545
  Independent root workflows persist independently. Nested workflows share their root's ordering.
518
546
 
519
- ### Inspecting and recovering the workflow database
520
-
521
- Dependency inspection is separate from run status and does not start a workflow or initialize a database:
522
-
523
- ```text
524
- /workflow dependency # defaults to status
525
- /workflow dependency doctor
526
- /workflow dependency recover
527
- ```
547
+ ### Workflow database recovery
528
548
 
529
- The tool equivalents are `workflow({ action: "dependency", operation: "doctor" })` and `workflow({ action: "dependency", operation: "recover" })`. SDK integrations can use [`workflowDependency()`](/workflows/api-reference#workflowdependency-operation).
549
+ Atomic monitors the managed PostgreSQL server and coordinates recovery when it
550
+ loses health. The shared cluster keeps its data and ownership records; database
551
+ recovery neither starts a replacement workflow nor proves an unfinished external
552
+ effect succeeded. Inspect `/workflow status <full-run-uuid>` for the original run
553
+ and explicitly resume it when eligible. Do not start a duplicate run or delete
554
+ `v18` or `v18.shared` to bypass an identity or availability error.
530
555
 
531
- `status` and `doctor` perform read-only checks. For a managed cluster, the report identifies the actual host/port, trusted cluster and data-directory identity, PostgreSQL process identity, current JavaScript runtime, and PostgreSQL server version when available. `identityVerified: true` means SQL, data and process identity agreed during that check. The consumer list conservatively retains leases whose process may still be alive; it is not a count of running workflows. `lastFailure` retains the most recently observed failure, including runtime diagnostics, after successful checks until a newer failure replaces it. It is process-local history, not a shared or permanent incident log. Use `state`, not the presence of `lastFailure`, to determine whether the latest check succeeded.
532
-
533
- `doctor` also checks the installed PostgreSQL 18 executables with one-second `--version` probes and reports the executable path and version under `runtime.installation`. Missing libraries or an incompatible runtime produce `unavailable` and a diagnostic. These checks do not repair links or permissions. `status` skips them, so it can inspect an existing healthy server even when local runtime files need repair.
534
-
535
- Each request returns within a five-second response budget. `checking` or `recovering` means the existing operation continues in the background, not that it succeeded or was cancelled. Repeated calls join that operation. Use `/workflow dependency status` to check again rather than launching duplicate recovery or a replacement workflow.
536
-
537
- `recover` retries only an already registered managed cluster under its shared setup lock. It preserves data and ownership records, never runs `initdb` over existing data, never adopts an unregistered cluster, and never kills a listener to free a port. Identity mismatches require investigation, not deletion of `v18` or `v18.shared`. If runtime files or libraries are missing, repair the complete installation using [Configuring DBOS/Postgres](#configuring-dbos/postgres), then retry recovery.
538
-
539
- With `DBOS_SYSTEM_DATABASE_URL`, every operation only checks that configured endpoint with a bounded query. Atomic does not restart it, choose another port, or provision a replacement. Correct its service, credentials or TLS settings yourself. A selected Docker fallback returns guidance for inspecting `dbos-db`; dependency recovery does not manage that container.
540
-
541
- Once the dependency is ready, inspect `/workflow status <full-run-uuid>` and explicitly resume the same ID when eligible. Database recovery itself never resumes workflow execution or proves an uncheckpointed external effect succeeded. Keep the original Atomic process open for a retained failed-admission retry. Existing pause and quit acknowledgements remain immediate during admission; inspect run status for later database settlement errors.
556
+ For an explicit `DBOS_SYSTEM_DATABASE_URL`, Atomic does not manage the external
557
+ database. Restore that endpoint or correct its credentials and TLS settings,
558
+ then inspect and resume the original workflow. If the Docker fallback is in use,
559
+ inspect `dbos-db` and correct its service configuration. A database repair does
560
+ not automatically resume a paused workflow or establish whether an interrupted
561
+ write committed.
542
562
 
543
563
  ### How it works
544
564
 
@@ -637,6 +657,8 @@ Changing `iteration` makes each loop pass a distinct durable call. Reusing the s
637
657
 
638
658
  The `/workflow resume` command mirrors `/resume` ergonomics and `/workflows` is its alias. With no id, it builds one newest-first picker from live runs that satisfy the shared resumability predicate and current DBOS resumable/completed records. DBOS is the authoritative catalog; selected records are hydrated and revalidated before resume or inspection. Running workflows never appear: fresh-heartbeat rows are excluded in every session to prevent double dispatch, and stale ones surface as `crashed`. A row whose durable checkpoint or referenced artifact is missing is not resumable and is omitted rather than offered and rejected later. Naming such an id explicitly still produces the existing clear no-checkpoint/not-resumable error.
639
659
 
660
+ Picker rows use the workflow ID as the primary label for search and direct resume. The adjacent details show status, completed stages or checkpoints, then the workflow name; on narrow terminals, the picker may truncate the ID or name visually, but searching the full ID still works.
661
+
640
662
  If resume reports a checkpoint decoding error or an unavailable serializer, retain the full run ID and original diagnostic when reporting the problem. Do not delete saved progress or launch a fresh copy just to bypass the error: that can repeat completed side effects.
641
663
 
642
664
  Only runs with usable durable checkpoints or pending prompts can resume. Deleted durable entries and missing artifacts are not offered. Status and connect/attach still expose eligible terminal runs for inspection.
@@ -682,7 +704,7 @@ Recovery requires saved checkpoints proving one unfinished tool and its complete
682
704
 
683
705
  A tool-frontier continuation must reach and consume the exact unfinished tool before reporting `completed`, whether the body returns normally or calls `ctx.exit({ status: "completed" })`. Omitting the call, including by changing control flow, fails with `insufficient_state: replay topology mismatch` and the pending tool's exact ID. A substituted tool is rejected before its callback runs. While that frontier is pending, completed model and child-workflow predecessors can replay, but new model stages, tasks, and child workflows cannot execute in its place. Stage and task worktree setup also waits for live admission. Replaying completed predecessors alone is not proof of completion. Failed replay publishes no successful result; inspect the same ID and restore the matching flow before another supported resume. Quit, kill, caught targeted cancellation, and intentional non-completed exits retain their existing behavior.
684
706
 
685
- After upgrading or applying a runtime fix, start a new Atomic process; `/workflow reload` refreshes definitions, not the installed runtime. A process-local non-durable warning means cross-process recovery is unavailable.
707
+ After upgrading Atomic itself or applying a code fix, start a new Atomic process; `/workflow reload` refreshes definitions, not loaded code. A process-local non-durable warning means cross-process recovery is unavailable.
686
708
 
687
709
  If saved state cannot prove safe replay, reconcile the original run and external effects before choosing recovery. Do not restart the original workflow from the beginning to bypass the error. A separately authorized recovery-only workflow may perform verified remaining operations, but must not repeat completed side effects or fabricate checkpoints.
688
710
 
@@ -711,7 +733,7 @@ Set `ATOMIC_POSTGRES_RUNTIME_DIR` to a complete extracted runtime containing `bi
711
733
 
712
734
  Keep the complete extracted archive, not only the `atomic` executable. `ATOMIC_POSTGRES_RUNTIME_DIR` accepts complete legacy runtimes without provenance; an incomplete override falls through to installed candidates. Packaging failures do not require deleting or reinitializing the v18 cluster.
713
735
 
714
- If installation reports **incomplete PostgreSQL runtime**, or macOS reports a missing library such as `libzstd.1.dylib`, download a repaired release and reinstall the complete archive. A rejected upgrade leaves your previous installation selected. Do not copy libraries from another version or delete your PostgreSQL data directory: this is an installation problem, not database corruption. An already-running server does not prove that the new installation is usable.
736
+ If installation reports **incomplete PostgreSQL runtime**, or macOS reports a missing library such as `libzstd.1.dylib`, download a repaired release and reinstall the complete archive. A rejected installation leaves the running server untouched. Do not copy libraries from another version or delete your PostgreSQL data directory: this is an installation problem, not database corruption. An already-running server does not prove that the new installation is usable.
715
737
 
716
738
  To check an archive runtime, set `runtime` to its `node_modules/@bastani/atomic-natives/postgres-runtime`, then run `"$runtime/bin/postgres" --version` and `"$runtime/bin/pg_ctl" --version`. On Windows use the corresponding `.exe` files in PowerShell. Both must succeed. If a library-link or copy error is reported, repair the complete installation instead of mixing libraries from different releases.
717
739
 
@@ -20,6 +20,17 @@ Start with the project's existing tests, build, typecheck, and lint commands. Ad
20
20
 
21
21
  See [tool selection](/computer-use#choose-the-right-tool) before operating a session. Herdr is the terminal priority, but the preference does not authorize control from outside a Herdr-managed pane. Install missing tools when permitted; otherwise use the available fallback and describe any coverage gap.
22
22
 
23
+ ### Reuse past verification
24
+
25
+ When a shell tool is available, the agent records each check it ran or attempted as an `Assistant-verification` line in the commits and PRs it writes, for example:
26
+
27
+ ```text
28
+ Assistant-verification: herdr terminal E2E passed: /tasks lists running tasks first at 80x24
29
+ Assistant-verification: cua-driver unavailable: Accessibility permission not granted
30
+ ```
31
+
32
+ Before choosing checks for a change, the agent looks up these lines for comparable changes (for example with `git log --format='%h %s%n%(trailers:key=Assistant-verification)' -- <path>`) and reuses the commands and scenarios that proved them. A setup recorded as `unavailable` is not retried without a reason to expect a different result. Past records guide the choice; they do not replace the project's required checks. See [execution history](/usage#system-prompt-files) to turn these records off.
33
+
23
34
  ## Define a reproducible scenario
24
35
 
25
36
  Before running it, write down:
@@ -80,6 +91,8 @@ Capture the actual application or simulator. A browser recording is not desktop
80
91
 
81
92
  Missing readiness is a blocked finding, not a failure to work around. Before the first action the stage checks `cua-driver --version` (one bounded install attempt with upstream's one-line installer if it is missing, then `cua-driver telemetry disable`), `cua-driver status`, `cua-driver doctor`, and `cua-driver call list_apps`, plus `cua-driver permissions status` on macOS. A builtin Goal or Ralph stage reports a missing macOS Accessibility or Screen Recording grant, a non-interactive Windows session, no graphical Linux session, or a refused or failed install as `blocked`/`needs_human` with the exact remediation (for macOS: `cua-driver permissions grant`, toggle CuaDriver on under System Settings → Privacy & Security → Accessibility and Screen & System Audio Recording, then relaunch the daemon with `open -n -g -a CuaDriver --args serve`), and re-runs the readiness check when the run resumes. A custom workflow does the same from a preflight `ctx.tool` that calls `ctx.exit({ status: "blocked", reason })`. Unlike a builtin stage, a blocked author exit is terminal and not resumable: after the user grants the permission, start a new run, whose fresh preflight checks again rather than replaying a cached result.
82
93
 
94
+ The executable installer does not install an agent skill. Atomic bundles the skill, so skip upstream's optional `cua-driver skills install`, `cua-driver skills update`, and `clawhub install @cua/driver` steps; leave existing user-level skills alone.
95
+
83
96
  Inspect saved files and exports rather than assuming a returned action means a completed operation. An action that times out before its response is `unknown`; resolve it with a fresh snapshot and the postcondition, never by replaying the action.
84
97
 
85
98
  ## Use evidence in a workflow
@@ -112,6 +112,7 @@ cp permission-gate.ts ~/.atomic/agent/extensions/
112
112
  | Extension | Description |
113
113
  |-----------|-------------|
114
114
  | `message-renderer.ts` | Custom message rendering with colors and expandable details via `registerMessageRenderer` |
115
+ | `debug-provider.ts` | Toggle raw provider stream capture with `/debug-provider` and inspect each assistant message in a TUI-only session entry |
115
116
  | `event-bus.ts` | Inter-extension communication via `pi.events` |
116
117
 
117
118
  ### Session Metadata
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Raw provider event viewer.
3
+ *
4
+ * Usage: /debug-provider [on|off]
5
+ * With no argument, the command toggles capture. Captured events are persisted
6
+ * as expandable custom entries.
7
+ */
8
+
9
+ import { type ExtensionAPI, keyHint } from "@bastani/atomic";
10
+ import { Box, Text } from "@earendil-works/pi-tui";
11
+
12
+ const ENTRY_TYPE = "debug-provider-events";
13
+ const STATUS_KEY = "debug-provider";
14
+
15
+ interface ProviderDebugEntry {
16
+ provider: string;
17
+ api: string;
18
+ model: string;
19
+ events: unknown[];
20
+ }
21
+
22
+ export default function (pi: ExtensionAPI) {
23
+ let enabled = false;
24
+ let activeEvents: unknown[] | undefined;
25
+ let completedEntry: ProviderDebugEntry | undefined;
26
+
27
+ pi.registerEntryRenderer<ProviderDebugEntry>(ENTRY_TYPE, (entry, { expanded }, theme) => {
28
+ const data = entry.data;
29
+ if (!data) return new Text(theme.fg("warning", "[provider debug] Missing event data"), 0, 0);
30
+
31
+ const box = new Box(1, 1, (text) => theme.bg("customMessageBg", text));
32
+ const count = `${data.events.length} event${data.events.length === 1 ? "" : "s"}`;
33
+ const expandHint = expanded ? "" : ` (${keyHint("app.tools.expand", "to view events")})`;
34
+ box.addChild(
35
+ new Text(
36
+ `${theme.fg("accent", "[provider debug]")} ${data.provider}/${data.model} (${data.api}) · ${count}${expandHint}`,
37
+ 0,
38
+ 0,
39
+ ),
40
+ );
41
+ if (expanded) {
42
+ box.addChild(new Text(JSON.stringify(data.events, null, 2), 0, 0));
43
+ }
44
+ return box;
45
+ });
46
+
47
+ pi.registerCommand("debug-provider", {
48
+ description: "Toggle capture of raw provider stream events",
49
+ handler: async (args, ctx) => {
50
+ const requestedState = args.trim().toLowerCase();
51
+ if (requestedState !== "" && requestedState !== "on" && requestedState !== "off") {
52
+ ctx.ui.notify("Usage: /debug-provider [on|off]", "warning");
53
+ return;
54
+ }
55
+
56
+ enabled = requestedState === "" ? !enabled : requestedState === "on";
57
+ if (!enabled) {
58
+ activeEvents = undefined;
59
+ completedEntry = undefined;
60
+ }
61
+ ctx.ui.setStatus(STATUS_KEY, enabled ? "provider debug" : undefined);
62
+ ctx.ui.notify(`Provider event capture ${enabled ? "enabled" : "disabled"}`, "info");
63
+ },
64
+ });
65
+
66
+ pi.on("turn_start", () => {
67
+ activeEvents = enabled ? [] : undefined;
68
+ });
69
+
70
+ pi.on("provider_stream_event", (event) => {
71
+ activeEvents?.push(structuredClone(event.data));
72
+ });
73
+
74
+ pi.on("message_end", (event) => {
75
+ if (event.message.role !== "assistant" || !activeEvents) return;
76
+ completedEntry = {
77
+ provider: event.message.provider,
78
+ api: event.message.api,
79
+ model: event.message.model,
80
+ events: activeEvents,
81
+ };
82
+ activeEvents = undefined;
83
+ });
84
+
85
+ pi.on("turn_end", () => {
86
+ if (!completedEntry) return;
87
+ pi.appendEntry<ProviderDebugEntry>(ENTRY_TYPE, completedEntry);
88
+ completedEntry = undefined;
89
+ });
90
+ }
@@ -6,6 +6,12 @@
6
6
  * schema-backed terminating final-answer tool only when this extension is
7
7
  * enabled.
8
8
  *
9
+ * The session model calls the tool with `{ instructions, state, model?,
10
+ * fallbackModels? }`. The tool infers a result matching `SummarySchema` with
11
+ * `model` (a chat model or a classifier such as `typesafe/jev-latest`), then
12
+ * each fallback, then the current chat model. Omit `model` to use the current
13
+ * chat model. A classifier is skipped when the schema is not a finite choice.
14
+ *
9
15
  * Custom factory names are opt-in tools too: `createStructuredOutputTool({ name:
10
16
  * "final_decision", ... })` registers `final_decision`; include that name in any
11
17
  * explicit `tools` allowlist. The default factory name registers