@bastani/atomic 0.9.10 → 0.9.11-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 (2339) hide show
  1. package/CHANGELOG.md +255 -0
  2. package/README.md +15 -10
  3. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  4. package/dist/builtin/intercom/package.json +4 -4
  5. package/dist/builtin/mcp/CHANGELOG.md +18 -0
  6. package/dist/builtin/mcp/README.md +3 -3
  7. package/dist/builtin/mcp/cli.js +0 -1
  8. package/dist/builtin/mcp/commands.ts +7 -3
  9. package/dist/builtin/mcp/config.ts +0 -2
  10. package/dist/builtin/mcp/package.json +6 -6
  11. package/dist/builtin/mcp/sampling-handler.ts +1 -5
  12. package/dist/builtin/mcp/types.ts +0 -1
  13. package/dist/builtin/subagents/CHANGELOG.md +40 -0
  14. package/dist/builtin/subagents/README.md +10 -1
  15. package/dist/builtin/subagents/agents/code-simplifier.md +48 -103
  16. package/dist/builtin/subagents/agents/codebase-analyzer.md +28 -131
  17. package/dist/builtin/subagents/agents/codebase-locator.md +25 -84
  18. package/dist/builtin/subagents/agents/codebase-online-researcher.md +61 -260
  19. package/dist/builtin/subagents/agents/codebase-pattern-finder.md +30 -208
  20. package/dist/builtin/subagents/agents/codebase-research-analyzer.md +29 -151
  21. package/dist/builtin/subagents/agents/codebase-research-locator.md +22 -119
  22. package/dist/builtin/subagents/agents/debugger.md +29 -65
  23. package/dist/builtin/subagents/agents/worker.md +24 -31
  24. package/dist/builtin/subagents/package.json +5 -5
  25. package/dist/builtin/subagents/prompts/gather-context-and-clarify.md +18 -11
  26. package/dist/builtin/subagents/prompts/parallel-cleanup.md +34 -33
  27. package/dist/builtin/subagents/prompts/parallel-context-build.md +22 -36
  28. package/dist/builtin/subagents/prompts/parallel-handoff-plan.md +20 -52
  29. package/dist/builtin/subagents/prompts/parallel-research.md +17 -41
  30. package/dist/builtin/subagents/prompts/parallel-review.md +23 -28
  31. package/dist/builtin/subagents/prompts/review-loop.md +18 -27
  32. package/dist/builtin/subagents/skills/subagent/SKILL.md +6 -6
  33. package/dist/builtin/subagents/src/agents/agent-discovery.ts +26 -15
  34. package/dist/builtin/subagents/src/agents/agent-loaders.ts +48 -34
  35. package/dist/builtin/subagents/src/agents/agent-management-helpers.ts +80 -31
  36. package/dist/builtin/subagents/src/agents/agent-management.ts +194 -55
  37. package/dist/builtin/subagents/src/agents/agent-overrides.ts +85 -32
  38. package/dist/builtin/subagents/src/agents/agent-paths.ts +4 -1
  39. package/dist/builtin/subagents/src/agents/agent-selection.ts +1 -1
  40. package/dist/builtin/subagents/src/agents/agent-serializer.ts +1 -4
  41. package/dist/builtin/subagents/src/agents/agents.ts +9 -9
  42. package/dist/builtin/subagents/src/agents/chain-serializer.ts +9 -5
  43. package/dist/builtin/subagents/src/agents/identity.ts +12 -3
  44. package/dist/builtin/subagents/src/agents/skills-paths.ts +64 -24
  45. package/dist/builtin/subagents/src/agents/skills.ts +29 -26
  46. package/dist/builtin/subagents/src/extension/doctor.ts +31 -20
  47. package/dist/builtin/subagents/src/extension/fanout-child.ts +27 -12
  48. package/dist/builtin/subagents/src/extension/index.ts +119 -43
  49. package/dist/builtin/subagents/src/extension/prompt-guidance.ts +4 -2
  50. package/dist/builtin/subagents/src/extension/schemas.ts +304 -177
  51. package/dist/builtin/subagents/src/extension/startup-maintenance.ts +137 -73
  52. package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +49 -21
  53. package/dist/builtin/subagents/src/intercom/result-intercom.ts +76 -38
  54. package/dist/builtin/subagents/src/runs/background/async-event-journal.ts +12 -6
  55. package/dist/builtin/subagents/src/runs/background/async-execution-chain.ts +183 -57
  56. package/dist/builtin/subagents/src/runs/background/async-execution-common.ts +15 -18
  57. package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +67 -26
  58. package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +8 -8
  59. package/dist/builtin/subagents/src/runs/background/async-execution.ts +1 -1
  60. package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +86 -32
  61. package/dist/builtin/subagents/src/runs/background/async-resume.ts +93 -36
  62. package/dist/builtin/subagents/src/runs/background/async-status.ts +82 -27
  63. package/dist/builtin/subagents/src/runs/background/completion-claims.ts +12 -5
  64. package/dist/builtin/subagents/src/runs/background/completion-dedupe.ts +3 -1
  65. package/dist/builtin/subagents/src/runs/background/completion-notification.ts +3 -1
  66. package/dist/builtin/subagents/src/runs/background/notify.ts +38 -18
  67. package/dist/builtin/subagents/src/runs/background/parallel-groups.ts +28 -14
  68. package/dist/builtin/subagents/src/runs/background/result-delivery-processor.ts +147 -79
  69. package/dist/builtin/subagents/src/runs/background/result-file-claims.ts +20 -5
  70. package/dist/builtin/subagents/src/runs/background/result-quarantine.ts +7 -2
  71. package/dist/builtin/subagents/src/runs/background/result-status.ts +11 -5
  72. package/dist/builtin/subagents/src/runs/background/result-watcher-data.ts +18 -5
  73. package/dist/builtin/subagents/src/runs/background/result-watcher.ts +104 -35
  74. package/dist/builtin/subagents/src/runs/background/run-id-resolver.ts +28 -7
  75. package/dist/builtin/subagents/src/runs/background/run-status.ts +120 -32
  76. package/dist/builtin/subagents/src/runs/background/stale-run-reconciler.ts +98 -39
  77. package/dist/builtin/subagents/src/runs/background/subagent-runner-dynamic.ts +185 -37
  78. package/dist/builtin/subagents/src/runs/background/subagent-runner-finalize.ts +23 -9
  79. package/dist/builtin/subagents/src/runs/background/subagent-runner-output.ts +6 -2
  80. package/dist/builtin/subagents/src/runs/background/subagent-runner-parallel-helpers.ts +34 -18
  81. package/dist/builtin/subagents/src/runs/background/subagent-runner-parallel.ts +175 -26
  82. package/dist/builtin/subagents/src/runs/background/subagent-runner-sequential.ts +68 -23
  83. package/dist/builtin/subagents/src/runs/background/subagent-runner-state.ts +200 -49
  84. package/dist/builtin/subagents/src/runs/background/subagent-runner-step.ts +82 -49
  85. package/dist/builtin/subagents/src/runs/background/subagent-runner-streaming.ts +33 -11
  86. package/dist/builtin/subagents/src/runs/background/subagent-runner-types.ts +16 -6
  87. package/dist/builtin/subagents/src/runs/background/subagent-runner-utils.ts +2 -3
  88. package/dist/builtin/subagents/src/runs/background/subagent-runner.ts +11 -8
  89. package/dist/builtin/subagents/src/runs/foreground/chain-execution-details.ts +5 -2
  90. package/dist/builtin/subagents/src/runs/foreground/chain-execution-dynamic-step.ts +115 -31
  91. package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +71 -54
  92. package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-step.ts +104 -37
  93. package/dist/builtin/subagents/src/runs/foreground/chain-execution-sequential-step.ts +102 -61
  94. package/dist/builtin/subagents/src/runs/foreground/chain-execution-types.ts +24 -10
  95. package/dist/builtin/subagents/src/runs/foreground/chain-execution.ts +9 -6
  96. package/dist/builtin/subagents/src/runs/foreground/detached-cleanup-barrier.ts +22 -22
  97. package/dist/builtin/subagents/src/runs/foreground/execution-attempt-control.ts +45 -40
  98. package/dist/builtin/subagents/src/runs/foreground/execution-attempt-finalize.ts +6 -5
  99. package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +118 -43
  100. package/dist/builtin/subagents/src/runs/foreground/execution-detach-reservations.ts +17 -7
  101. package/dist/builtin/subagents/src/runs/foreground/execution-detach-route.ts +5 -3
  102. package/dist/builtin/subagents/src/runs/foreground/execution-intercom-detach.ts +39 -35
  103. package/dist/builtin/subagents/src/runs/foreground/execution-run-sync.ts +81 -42
  104. package/dist/builtin/subagents/src/runs/foreground/execution-structured-retries.ts +27 -21
  105. package/dist/builtin/subagents/src/runs/foreground/execution-updates.ts +2 -5
  106. package/dist/builtin/subagents/src/runs/foreground/execution-utils.ts +9 -4
  107. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +69 -25
  108. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-chain.ts +36 -19
  109. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +95 -62
  110. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-input.ts +30 -9
  111. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +106 -96
  112. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +68 -36
  113. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +262 -83
  114. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-runtime.ts +6 -1
  115. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +67 -41
  116. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +129 -44
  117. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +20 -3
  118. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-worktree.ts +8 -6
  119. package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +65 -47
  120. package/dist/builtin/subagents/src/runs/shared/chain-outputs.ts +37 -12
  121. package/dist/builtin/subagents/src/runs/shared/dynamic-fanout.ts +120 -34
  122. package/dist/builtin/subagents/src/runs/shared/final-drain.ts +12 -7
  123. package/dist/builtin/subagents/src/runs/shared/intercom-group.ts +3 -2
  124. package/dist/builtin/subagents/src/runs/shared/long-running-guard.ts +8 -3
  125. package/dist/builtin/subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +42 -20
  126. package/dist/builtin/subagents/src/runs/shared/model-candidate-filter.ts +8 -4
  127. package/dist/builtin/subagents/src/runs/shared/model-fallback.ts +103 -38
  128. package/dist/builtin/subagents/src/runs/shared/nested-events-control.ts +30 -20
  129. package/dist/builtin/subagents/src/runs/shared/nested-events-core.ts +45 -20
  130. package/dist/builtin/subagents/src/runs/shared/nested-events-projection.ts +57 -23
  131. package/dist/builtin/subagents/src/runs/shared/nested-events-registry.ts +77 -29
  132. package/dist/builtin/subagents/src/runs/shared/nested-events-sanitize.ts +99 -42
  133. package/dist/builtin/subagents/src/runs/shared/nested-events.ts +32 -26
  134. package/dist/builtin/subagents/src/runs/shared/nested-path.ts +22 -17
  135. package/dist/builtin/subagents/src/runs/shared/nested-render.ts +31 -10
  136. package/dist/builtin/subagents/src/runs/shared/parallel-utils.ts +10 -8
  137. package/dist/builtin/subagents/src/runs/shared/pi-args.ts +59 -33
  138. package/dist/builtin/subagents/src/runs/shared/pi-spawn.ts +17 -13
  139. package/dist/builtin/subagents/src/runs/shared/run-history.ts +13 -6
  140. package/dist/builtin/subagents/src/runs/shared/single-output.ts +11 -6
  141. package/dist/builtin/subagents/src/runs/shared/spawn-env.ts +21 -0
  142. package/dist/builtin/subagents/src/runs/shared/structured-output.ts +33 -19
  143. package/dist/builtin/subagents/src/runs/shared/subagent-control.ts +59 -48
  144. package/dist/builtin/subagents/src/runs/shared/subagent-prompt-runtime.ts +18 -11
  145. package/dist/builtin/subagents/src/runs/shared/workflow-graph.ts +41 -11
  146. package/dist/builtin/subagents/src/runs/shared/worktree-post-create.ts +46 -10
  147. package/dist/builtin/subagents/src/runs/shared/worktree-root.ts +21 -5
  148. package/dist/builtin/subagents/src/runs/shared/worktree.ts +89 -34
  149. package/dist/builtin/subagents/src/shared/artifacts.ts +137 -7
  150. package/dist/builtin/subagents/src/shared/event-jsonl-writer.ts +49 -13
  151. package/dist/builtin/subagents/src/shared/fast-mode.ts +13 -6
  152. package/dist/builtin/subagents/src/shared/fork-context.ts +7 -4
  153. package/dist/builtin/subagents/src/shared/formatters.ts +14 -9
  154. package/dist/builtin/subagents/src/shared/jsonl-writer.ts +2 -1
  155. package/dist/builtin/subagents/src/shared/model-info.ts +10 -3
  156. package/dist/builtin/subagents/src/shared/post-exit-stdio-guard.ts +7 -6
  157. package/dist/builtin/subagents/src/shared/session-tokens.ts +2 -1
  158. package/dist/builtin/subagents/src/shared/settings.ts +43 -43
  159. package/dist/builtin/subagents/src/shared/status-format.ts +10 -2
  160. package/dist/builtin/subagents/src/shared/types-async.ts +22 -19
  161. package/dist/builtin/subagents/src/shared/types-config.ts +1 -1
  162. package/dist/builtin/subagents/src/shared/types-depth.ts +23 -11
  163. package/dist/builtin/subagents/src/shared/types-results.ts +49 -6
  164. package/dist/builtin/subagents/src/shared/types-runtime.ts +16 -17
  165. package/dist/builtin/subagents/src/shared/types.ts +2 -2
  166. package/dist/builtin/subagents/src/shared/utils.ts +34 -20
  167. package/dist/builtin/subagents/src/slash/prompt-template-bridge.ts +44 -47
  168. package/dist/builtin/subagents/src/slash/saved-chain-mapping.ts +5 -7
  169. package/dist/builtin/subagents/src/slash/slash-bridge.ts +3 -3
  170. package/dist/builtin/subagents/src/slash/slash-commands.ts +78 -52
  171. package/dist/builtin/subagents/src/slash/slash-live-state.ts +59 -32
  172. package/dist/builtin/subagents/src/tui/render-chain-graph.ts +120 -32
  173. package/dist/builtin/subagents/src/tui/render-event-formatting.ts +85 -22
  174. package/dist/builtin/subagents/src/tui/render-helpers.ts +16 -6
  175. package/dist/builtin/subagents/src/tui/render-layout.ts +8 -3
  176. package/dist/builtin/subagents/src/tui/render-result-compact.ts +125 -43
  177. package/dist/builtin/subagents/src/tui/render-result.ts +128 -85
  178. package/dist/builtin/subagents/src/tui/render-stable-output.ts +17 -13
  179. package/dist/builtin/subagents/src/tui/render-status-progress.ts +52 -20
  180. package/dist/builtin/subagents/src/tui/render-widget-graph.ts +130 -28
  181. package/dist/builtin/subagents/src/tui/render-widget.ts +54 -27
  182. package/dist/builtin/subagents/src/tui/render.ts +10 -3
  183. package/dist/builtin/web-access/CHANGELOG.md +6 -0
  184. package/dist/builtin/web-access/package.json +2 -2
  185. package/dist/builtin/workflows/CHANGELOG.md +127 -0
  186. package/dist/builtin/workflows/README.md +83 -70
  187. package/dist/builtin/workflows/ambient.d.ts +0 -5
  188. package/dist/builtin/workflows/builtin/adversarial-verification-prompts.ts +7 -4
  189. package/dist/builtin/workflows/builtin/adversarial-verification-runner.ts +1 -1
  190. package/dist/builtin/workflows/builtin/adversarial-verification.ts +2 -1
  191. package/dist/builtin/workflows/builtin/classify-and-act-prompts.ts +5 -2
  192. package/dist/builtin/workflows/builtin/classify-and-act-runner.ts +5 -7
  193. package/dist/builtin/workflows/builtin/classify-and-act.ts +3 -2
  194. package/dist/builtin/workflows/builtin/fan-out-and-synthesize-prompts.ts +6 -3
  195. package/dist/builtin/workflows/builtin/fan-out-and-synthesize-runner.ts +5 -5
  196. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.ts +3 -2
  197. package/dist/builtin/workflows/builtin/generate-and-filter-prompts.ts +7 -4
  198. package/dist/builtin/workflows/builtin/generate-and-filter-runner.ts +6 -3
  199. package/dist/builtin/workflows/builtin/generate-and-filter.ts +3 -2
  200. package/dist/builtin/workflows/builtin/goal-artifacts.ts +1 -1
  201. package/dist/builtin/workflows/builtin/goal-models.ts +39 -39
  202. package/dist/builtin/workflows/builtin/goal-orchestrator-prompts.ts +94 -0
  203. package/dist/builtin/workflows/builtin/goal-prompts.ts +70 -285
  204. package/dist/builtin/workflows/builtin/goal-reducer.ts +1 -1
  205. package/dist/builtin/workflows/builtin/goal-runner.ts +72 -116
  206. package/dist/builtin/workflows/builtin/goal.ts +12 -11
  207. package/dist/builtin/workflows/builtin/index.d.ts +17 -112
  208. package/dist/builtin/workflows/builtin/index.ts +1 -2
  209. package/dist/builtin/workflows/builtin/loop-until-done-prompts.ts +20 -12
  210. package/dist/builtin/workflows/builtin/loop-until-done-runner.ts +3 -0
  211. package/dist/builtin/workflows/builtin/loop-until-done.ts +3 -2
  212. package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +149 -88
  213. package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +102 -78
  214. package/dist/builtin/workflows/builtin/open-claude-design-setup.ts +164 -56
  215. package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +16 -21
  216. package/dist/builtin/workflows/builtin/open-claude-design.ts +2 -1
  217. package/dist/builtin/workflows/builtin/ralph-core.ts +61 -57
  218. package/dist/builtin/workflows/builtin/ralph-forked-prompts.ts +41 -45
  219. package/dist/builtin/workflows/builtin/ralph-models.ts +37 -47
  220. package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +37 -117
  221. package/dist/builtin/workflows/builtin/ralph-runner.ts +83 -108
  222. package/dist/builtin/workflows/builtin/ralph.ts +6 -5
  223. package/dist/builtin/workflows/builtin/shared-prompts.ts +117 -70
  224. package/dist/builtin/workflows/builtin/steering-context.ts +51 -0
  225. package/dist/builtin/workflows/builtin/tournament-prompts.ts +21 -12
  226. package/dist/builtin/workflows/builtin/tournament-runner.ts +3 -0
  227. package/dist/builtin/workflows/builtin/tournament.ts +3 -2
  228. package/dist/builtin/workflows/package.json +4 -4
  229. package/dist/builtin/workflows/skills/create-spec/SKILL.md +1 -1
  230. package/dist/builtin/workflows/skills/impeccable/SKILL.md +33 -129
  231. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_asset_producer.toml +11 -3
  232. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_documenter.toml +26 -0
  233. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_finish_reviewer.toml +35 -0
  234. package/dist/builtin/workflows/skills/impeccable/reference/android.md +1 -1
  235. package/dist/builtin/workflows/skills/impeccable/reference/animate.md +72 -189
  236. package/dist/builtin/workflows/skills/impeccable/reference/audit.md +10 -9
  237. package/dist/builtin/workflows/skills/impeccable/reference/audit.native.md +2 -2
  238. package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +19 -108
  239. package/dist/builtin/workflows/skills/impeccable/reference/clarify.md +59 -253
  240. package/dist/builtin/workflows/skills/impeccable/reference/colorize.md +51 -222
  241. package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +45 -0
  242. package/dist/builtin/workflows/skills/impeccable/reference/craft.md +3 -121
  243. package/dist/builtin/workflows/skills/impeccable/reference/critique.md +28 -20
  244. package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +97 -0
  245. package/dist/builtin/workflows/skills/impeccable/reference/degraded/documenter.md +23 -0
  246. package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +32 -0
  247. package/dist/builtin/workflows/skills/impeccable/reference/degraded/manual-edit-applier.md +92 -0
  248. package/dist/builtin/workflows/skills/impeccable/reference/delight.md +47 -279
  249. package/dist/builtin/workflows/skills/impeccable/reference/distill.md +2 -2
  250. package/dist/builtin/workflows/skills/impeccable/reference/doctor.md +53 -0
  251. package/dist/builtin/workflows/skills/impeccable/reference/document.md +60 -73
  252. package/dist/builtin/workflows/skills/impeccable/reference/harden.md +1 -12
  253. package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +23 -12
  254. package/dist/builtin/workflows/skills/impeccable/reference/init.md +64 -163
  255. package/dist/builtin/workflows/skills/impeccable/reference/ios.md +1 -1
  256. package/dist/builtin/workflows/skills/impeccable/reference/layout.md +52 -153
  257. package/dist/builtin/workflows/skills/impeccable/reference/live.md +47 -36
  258. package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +105 -0
  259. package/dist/builtin/workflows/skills/impeccable/reference/{product.md → operate.md} +6 -5
  260. package/dist/builtin/workflows/skills/impeccable/reference/optimize.md +4 -4
  261. package/dist/builtin/workflows/skills/impeccable/reference/overdrive.md +1 -4
  262. package/dist/builtin/workflows/skills/impeccable/reference/polish.md +68 -212
  263. package/dist/builtin/workflows/skills/impeccable/reference/quieter.md +3 -3
  264. package/dist/builtin/workflows/skills/impeccable/reference/routing.md +18 -0
  265. package/dist/builtin/workflows/skills/impeccable/reference/shape.md +38 -144
  266. package/dist/builtin/workflows/skills/impeccable/reference/typeset.md +48 -269
  267. package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +38 -0
  268. package/dist/builtin/workflows/skills/impeccable/scripts/command-metadata.json +1 -1
  269. package/dist/builtin/workflows/skills/impeccable/scripts/concept-seed.mjs +584 -0
  270. package/dist/builtin/workflows/skills/impeccable/scripts/context-signals.mjs +117 -9
  271. package/dist/builtin/workflows/skills/impeccable/scripts/context.mjs +486 -59
  272. package/dist/builtin/workflows/skills/impeccable/scripts/critique-storage.mjs +16 -45
  273. package/dist/builtin/workflows/skills/impeccable/scripts/detector/browser/injected/index.mjs +96 -10
  274. package/dist/builtin/workflows/skills/impeccable/scripts/detector/cli/main.mjs +143 -26
  275. package/dist/builtin/workflows/skills/impeccable/scripts/detector/design-system.mjs +181 -12
  276. package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +3187 -182
  277. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +102 -7
  278. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +282 -70
  279. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +183 -15
  280. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +22 -7
  281. package/dist/builtin/workflows/skills/impeccable/scripts/detector/findings.mjs +7 -1
  282. package/dist/builtin/workflows/skills/impeccable/scripts/detector/node/file-system.mjs +16 -2
  283. package/dist/builtin/workflows/skills/impeccable/scripts/detector/registry/antipatterns.mjs +155 -42
  284. package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +2988 -155
  285. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/constants.mjs +11 -0
  286. package/dist/builtin/workflows/skills/impeccable/scripts/doctor.mjs +336 -0
  287. package/dist/builtin/workflows/skills/impeccable/scripts/generate-image.mjs +232 -0
  288. package/dist/builtin/workflows/skills/impeccable/scripts/hook-admin.mjs +92 -30
  289. package/dist/builtin/workflows/skills/impeccable/scripts/hook-lib.mjs +414 -120
  290. package/dist/builtin/workflows/skills/impeccable/scripts/hook.mjs +25 -8
  291. package/dist/builtin/workflows/skills/impeccable/scripts/lib/artifact-schema.mjs +93 -0
  292. package/dist/builtin/workflows/skills/impeccable/scripts/lib/composition-catalog.mjs +165 -0
  293. package/dist/builtin/workflows/skills/impeccable/scripts/lib/concept-catalog.mjs +329 -0
  294. package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-config.mjs +20 -5
  295. package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-paths.mjs +16 -8
  296. package/dist/builtin/workflows/skills/impeccable/scripts/lib/provider.mjs +1 -0
  297. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-deep.mjs +455 -0
  298. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-notice.mjs +169 -0
  299. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness.mjs +457 -0
  300. package/dist/builtin/workflows/skills/impeccable/scripts/lib/surface-briefs.mjs +151 -0
  301. package/dist/builtin/workflows/skills/impeccable/scripts/lib/target-slug.mjs +33 -0
  302. package/dist/builtin/workflows/skills/impeccable/scripts/lib/template-extensions.mjs +146 -0
  303. package/dist/builtin/workflows/skills/impeccable/scripts/live/completion.mjs +10 -1
  304. package/dist/builtin/workflows/skills/impeccable/scripts/live/event-validation.mjs +15 -0
  305. package/dist/builtin/workflows/skills/impeccable/scripts/live/generation-preflight.mjs +149 -0
  306. package/dist/builtin/workflows/skills/impeccable/scripts/live/poll-lanes.mjs +14 -0
  307. package/dist/builtin/workflows/skills/impeccable/scripts/live/session-store.mjs +109 -32
  308. package/dist/builtin/workflows/skills/impeccable/scripts/live/source-lock.mjs +105 -0
  309. package/dist/builtin/workflows/skills/impeccable/scripts/live/source-search.mjs +105 -0
  310. package/dist/builtin/workflows/skills/impeccable/scripts/live/sveltekit-adapter.mjs +8 -6
  311. package/dist/builtin/workflows/skills/impeccable/scripts/live/tanstack-adapter.mjs +280 -0
  312. package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +212 -69
  313. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-dom.js +5 -1
  314. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-session.js +7 -1
  315. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +565 -115
  316. package/dist/builtin/workflows/skills/impeccable/scripts/live-commit-manual-edits.mjs +3 -0
  317. package/dist/builtin/workflows/skills/impeccable/scripts/live-inject.mjs +198 -14
  318. package/dist/builtin/workflows/skills/impeccable/scripts/live-insert.mjs +24 -6
  319. package/dist/builtin/workflows/skills/impeccable/scripts/live-manual-edit-evidence.mjs +11 -3
  320. package/dist/builtin/workflows/skills/impeccable/scripts/live-poll.mjs +44 -14
  321. package/dist/builtin/workflows/skills/impeccable/scripts/live-server.mjs +405 -34
  322. package/dist/builtin/workflows/skills/impeccable/scripts/live-status.mjs +9 -5
  323. package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +81 -67
  324. package/dist/builtin/workflows/skills/impeccable/scripts/live.mjs +7 -2
  325. package/dist/builtin/workflows/skills/impeccable/scripts/palette.mjs +76 -81
  326. package/dist/builtin/workflows/skills/impeccable/scripts/pin.mjs +4 -4
  327. package/dist/builtin/workflows/skills/impeccable/scripts/serve-question.mjs +890 -0
  328. package/dist/builtin/workflows/skills/impeccable/scripts/surface-brief.mjs +74 -0
  329. package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +57 -252
  330. package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +70 -226
  331. package/dist/builtin/workflows/skills/prompt-engineer/references/core_prompting.md +64 -103
  332. package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +81 -155
  333. package/dist/builtin/workflows/src/authoring/typebox-defaults.d.ts +5 -5
  334. package/dist/builtin/workflows/src/authoring/typebox-defaults.ts +160 -197
  335. package/dist/builtin/workflows/src/authoring/workflow.ts +137 -132
  336. package/dist/builtin/workflows/src/authoring.d.ts +7 -3
  337. package/dist/builtin/workflows/src/durable/backend.ts +512 -385
  338. package/dist/builtin/workflows/src/durable/boundary-lifecycle.ts +172 -0
  339. package/dist/builtin/workflows/src/durable/boundary-topology.ts +475 -0
  340. package/dist/builtin/workflows/src/durable/child-invocation.ts +14 -0
  341. package/dist/builtin/workflows/src/durable/child-primitive.ts +115 -74
  342. package/dist/builtin/workflows/src/durable/completed-catalog-stage-groups.ts +290 -0
  343. package/dist/builtin/workflows/src/durable/completed-catalog.ts +419 -189
  344. package/dist/builtin/workflows/src/durable/completed-inspection.ts +118 -105
  345. package/dist/builtin/workflows/src/durable/completed-subtree.ts +35 -0
  346. package/dist/builtin/workflows/src/durable/dbos-backend.ts +484 -414
  347. package/dist/builtin/workflows/src/durable/dbos-embedded-postgres-root.ts +172 -0
  348. package/dist/builtin/workflows/src/durable/dbos-embedded-postgres.ts +183 -137
  349. package/dist/builtin/workflows/src/durable/dbos-envelope.ts +415 -189
  350. package/dist/builtin/workflows/src/durable/dbos-lifecycle.ts +128 -100
  351. package/dist/builtin/workflows/src/durable/dbos-local-postgres.ts +75 -68
  352. package/dist/builtin/workflows/src/durable/dbos-metadata.ts +138 -101
  353. package/dist/builtin/workflows/src/durable/dbos-prompt-reservations.ts +316 -259
  354. package/dist/builtin/workflows/src/durable/dbos-sdk-handle.ts +138 -117
  355. package/dist/builtin/workflows/src/durable/dbos-status-transition.ts +48 -43
  356. package/dist/builtin/workflows/src/durable/dbos-tombstone.ts +14 -14
  357. package/dist/builtin/workflows/src/durable/durable-hash.ts +9 -11
  358. package/dist/builtin/workflows/src/durable/factory.ts +70 -16
  359. package/dist/builtin/workflows/src/durable/format-version.ts +1 -1
  360. package/dist/builtin/workflows/src/durable/index.ts +69 -68
  361. package/dist/builtin/workflows/src/durable/local-command.ts +50 -37
  362. package/dist/builtin/workflows/src/durable/prompt-reservation-state.ts +156 -149
  363. package/dist/builtin/workflows/src/durable/prompt-reservations.ts +16 -16
  364. package/dist/builtin/workflows/src/durable/resume-catalog.ts +11 -11
  365. package/dist/builtin/workflows/src/durable/resume-eligibility.ts +27 -25
  366. package/dist/builtin/workflows/src/durable/resume-runtime.ts +261 -222
  367. package/dist/builtin/workflows/src/durable/retention-policy.ts +31 -30
  368. package/dist/builtin/workflows/src/durable/run-timing.ts +42 -41
  369. package/dist/builtin/workflows/src/durable/scoped-backend.ts +261 -193
  370. package/dist/builtin/workflows/src/durable/stage-primitive.ts +466 -370
  371. package/dist/builtin/workflows/src/durable/stage-topology-validation.ts +247 -0
  372. package/dist/builtin/workflows/src/durable/stage-topology.ts +53 -0
  373. package/dist/builtin/workflows/src/durable/tool-failure-checkpoint.ts +49 -0
  374. package/dist/builtin/workflows/src/durable/tool-outcome.ts +130 -0
  375. package/dist/builtin/workflows/src/durable/tool-primitive.ts +642 -137
  376. package/dist/builtin/workflows/src/durable/types.ts +243 -132
  377. package/dist/builtin/workflows/src/durable/ui-primitive.ts +243 -164
  378. package/dist/builtin/workflows/src/durable/workflow-child-result.ts +61 -0
  379. package/dist/builtin/workflows/src/durable/workflow-status-transition.ts +16 -15
  380. package/dist/builtin/workflows/src/engine/graph-inference.ts +76 -76
  381. package/dist/builtin/workflows/src/engine/options.ts +35 -35
  382. package/dist/builtin/workflows/src/engine/primitives/chain.ts +27 -22
  383. package/dist/builtin/workflows/src/engine/primitives/exit.ts +1 -1
  384. package/dist/builtin/workflows/src/engine/primitives/parallel.ts +64 -52
  385. package/dist/builtin/workflows/src/engine/primitives/task.ts +110 -95
  386. package/dist/builtin/workflows/src/engine/primitives/ui.ts +46 -50
  387. package/dist/builtin/workflows/src/engine/primitives/workflow.ts +194 -151
  388. package/dist/builtin/workflows/src/engine/replay.ts +6 -6
  389. package/dist/builtin/workflows/src/engine/run-durable-admission.ts +50 -0
  390. package/dist/builtin/workflows/src/engine/run-durable-finalize.ts +64 -37
  391. package/dist/builtin/workflows/src/engine/run-durable-stage-session.ts +30 -24
  392. package/dist/builtin/workflows/src/engine/run-durable-topology.ts +288 -0
  393. package/dist/builtin/workflows/src/engine/run-returned-status.ts +60 -57
  394. package/dist/builtin/workflows/src/engine/run-terminal-event.ts +39 -0
  395. package/dist/builtin/workflows/src/engine/run-terminal-failure.ts +53 -0
  396. package/dist/builtin/workflows/src/engine/run-tool-admission-boundary.ts +99 -0
  397. package/dist/builtin/workflows/src/engine/run-tool-control-registry.ts +179 -0
  398. package/dist/builtin/workflows/src/engine/run-tool-execution-tracker.ts +164 -0
  399. package/dist/builtin/workflows/src/engine/run-tool-node-lifecycle.ts +152 -0
  400. package/dist/builtin/workflows/src/engine/run.ts +680 -477
  401. package/dist/builtin/workflows/src/engine/runtime.ts +160 -140
  402. package/dist/builtin/workflows/src/engine/workflow-activity.ts +7 -3
  403. package/dist/builtin/workflows/src/engine/workflow-tool-abort.ts +92 -0
  404. package/dist/builtin/workflows/src/extension/atomic-stage-session.ts +123 -120
  405. package/dist/builtin/workflows/src/extension/background-ui-adapter.ts +108 -112
  406. package/dist/builtin/workflows/src/extension/companions.ts +116 -116
  407. package/dist/builtin/workflows/src/extension/completed-stage-intercom-ask.ts +123 -111
  408. package/dist/builtin/workflows/src/extension/config-file-loader.ts +153 -148
  409. package/dist/builtin/workflows/src/extension/config-loader.ts +264 -283
  410. package/dist/builtin/workflows/src/extension/discovery-loaders.ts +81 -84
  411. package/dist/builtin/workflows/src/extension/discovery.ts +267 -272
  412. package/dist/builtin/workflows/src/extension/dispatcher.ts +214 -217
  413. package/dist/builtin/workflows/src/extension/extension-factory.ts +103 -93
  414. package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +135 -107
  415. package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +414 -409
  416. package/dist/builtin/workflows/src/extension/hil-answer-notifications.ts +270 -261
  417. package/dist/builtin/workflows/src/extension/index.bundle.mjs +74625 -0
  418. package/dist/builtin/workflows/src/extension/index.ts +37 -37
  419. package/dist/builtin/workflows/src/extension/lifecycle-notification-delivery.ts +64 -64
  420. package/dist/builtin/workflows/src/extension/lifecycle-notifications.ts +386 -369
  421. package/dist/builtin/workflows/src/extension/mcp.ts +35 -35
  422. package/dist/builtin/workflows/src/extension/postmortem-deps.ts +31 -35
  423. package/dist/builtin/workflows/src/extension/public-types.ts +162 -185
  424. package/dist/builtin/workflows/src/extension/render-call.ts +85 -84
  425. package/dist/builtin/workflows/src/extension/render-component.ts +9 -11
  426. package/dist/builtin/workflows/src/extension/render-result.ts +453 -348
  427. package/dist/builtin/workflows/src/extension/renderers.ts +35 -35
  428. package/dist/builtin/workflows/src/extension/runtime-active-block-claim.ts +37 -37
  429. package/dist/builtin/workflows/src/extension/runtime-durable-resume.ts +146 -138
  430. package/dist/builtin/workflows/src/extension/runtime.ts +346 -258
  431. package/dist/builtin/workflows/src/extension/status-writer.ts +95 -95
  432. package/dist/builtin/workflows/src/extension/ui-surface.ts +224 -218
  433. package/dist/builtin/workflows/src/extension/wiring.ts +307 -281
  434. package/dist/builtin/workflows/src/extension/workflow-command-completions.ts +109 -108
  435. package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +257 -224
  436. package/dist/builtin/workflows/src/extension/workflow-command-surfaces.ts +84 -83
  437. package/dist/builtin/workflows/src/extension/workflow-command-utils.ts +126 -132
  438. package/dist/builtin/workflows/src/extension/workflow-durable-resume-command.ts +213 -199
  439. package/dist/builtin/workflows/src/extension/workflow-model-catalog.ts +24 -0
  440. package/dist/builtin/workflows/src/extension/workflow-module-loader.ts +110 -95
  441. package/dist/builtin/workflows/src/extension/workflow-policy.ts +7 -9
  442. package/dist/builtin/workflows/src/extension/workflow-ports.ts +30 -34
  443. package/dist/builtin/workflows/src/extension/workflow-prompts.ts +41 -17
  444. package/dist/builtin/workflows/src/extension/workflow-reload-coordinator.ts +46 -46
  445. package/dist/builtin/workflows/src/extension/workflow-reload-report.ts +28 -25
  446. package/dist/builtin/workflows/src/extension/workflow-resume-picker-rows.ts +48 -45
  447. package/dist/builtin/workflows/src/extension/workflow-resume-shadow.ts +28 -31
  448. package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +539 -453
  449. package/dist/builtin/workflows/src/extension/workflow-schema.ts +149 -91
  450. package/dist/builtin/workflows/src/extension/workflow-stage-results.ts +182 -194
  451. package/dist/builtin/workflows/src/extension/workflow-status-summary.ts +154 -116
  452. package/dist/builtin/workflows/src/extension/workflow-targets.ts +159 -125
  453. package/dist/builtin/workflows/src/extension/workflow-tool-content.ts +204 -216
  454. package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +520 -294
  455. package/dist/builtin/workflows/src/extension/workflow-tool-inspection.ts +146 -150
  456. package/dist/builtin/workflows/src/extension/workflow-tool-registration.ts +43 -46
  457. package/dist/builtin/workflows/src/extension/workflow-tool-send.ts +354 -206
  458. package/dist/builtin/workflows/src/extension/workflow-tool.ts +123 -117
  459. package/dist/builtin/workflows/src/intercom/intercom-bridge.ts +17 -20
  460. package/dist/builtin/workflows/src/intercom/intercom-routing.ts +62 -62
  461. package/dist/builtin/workflows/src/intercom/result-intercom.ts +123 -123
  462. package/dist/builtin/workflows/src/runs/background/cancellation-registry.ts +72 -59
  463. package/dist/builtin/workflows/src/runs/background/durable-resume-transition.ts +45 -45
  464. package/dist/builtin/workflows/src/runs/background/job-tracker.ts +69 -34
  465. package/dist/builtin/workflows/src/runs/background/quit-tool-node.ts +71 -0
  466. package/dist/builtin/workflows/src/runs/background/quit.ts +359 -138
  467. package/dist/builtin/workflows/src/runs/background/resume-acknowledgements.ts +70 -69
  468. package/dist/builtin/workflows/src/runs/background/run-inspect.ts +85 -74
  469. package/dist/builtin/workflows/src/runs/background/runner.ts +122 -121
  470. package/dist/builtin/workflows/src/runs/background/startup-admission.ts +56 -60
  471. package/dist/builtin/workflows/src/runs/background/status.ts +324 -284
  472. package/dist/builtin/workflows/src/runs/background/workflow-lifecycle-aggregate.ts +24 -26
  473. package/dist/builtin/workflows/src/runs/foreground/executor-abort.ts +311 -309
  474. package/dist/builtin/workflows/src/runs/foreground/executor-child-boundary.ts +229 -199
  475. package/dist/builtin/workflows/src/runs/foreground/executor-child-helpers.ts +56 -51
  476. package/dist/builtin/workflows/src/runs/foreground/executor-continuation.ts +168 -152
  477. package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +255 -217
  478. package/dist/builtin/workflows/src/runs/foreground/executor-exit-manager.ts +178 -173
  479. package/dist/builtin/workflows/src/runs/foreground/executor-hil.ts +273 -269
  480. package/dist/builtin/workflows/src/runs/foreground/executor-inputs.ts +59 -56
  481. package/dist/builtin/workflows/src/runs/foreground/executor-lifecycle.ts +375 -351
  482. package/dist/builtin/workflows/src/runs/foreground/executor-outputs.ts +123 -127
  483. package/dist/builtin/workflows/src/runs/foreground/executor-prompt-nodes.ts +360 -295
  484. package/dist/builtin/workflows/src/runs/foreground/executor-queued-user-message.ts +47 -47
  485. package/dist/builtin/workflows/src/runs/foreground/executor-run-finalizers.ts +125 -104
  486. package/dist/builtin/workflows/src/runs/foreground/executor-scheduler.ts +189 -189
  487. package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +294 -242
  488. package/dist/builtin/workflows/src/runs/foreground/executor-stage-context.ts +141 -127
  489. package/dist/builtin/workflows/src/runs/foreground/executor-stage-control.ts +219 -179
  490. package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +406 -354
  491. package/dist/builtin/workflows/src/runs/foreground/executor-stage-replay.ts +143 -126
  492. package/dist/builtin/workflows/src/runs/foreground/executor-stage-types.ts +50 -47
  493. package/dist/builtin/workflows/src/runs/foreground/executor-task-context.ts +1 -1
  494. package/dist/builtin/workflows/src/runs/foreground/executor-task-prompts.ts +148 -153
  495. package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +157 -110
  496. package/dist/builtin/workflows/src/runs/foreground/executor.ts +10 -10
  497. package/dist/builtin/workflows/src/runs/foreground/postmortem-stage-chat.ts +176 -100
  498. package/dist/builtin/workflows/src/runs/foreground/stage-control-registry.ts +363 -257
  499. package/dist/builtin/workflows/src/runs/foreground/stage-delivery-activity.ts +86 -0
  500. package/dist/builtin/workflows/src/runs/foreground/stage-queued-user-messages.ts +95 -0
  501. package/dist/builtin/workflows/src/runs/foreground/stage-runner-candidate.ts +8 -8
  502. package/dist/builtin/workflows/src/runs/foreground/stage-runner-context.ts +233 -221
  503. package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +630 -494
  504. package/dist/builtin/workflows/src/runs/foreground/stage-runner-message-admission.ts +182 -181
  505. package/dist/builtin/workflows/src/runs/foreground/stage-runner-messages.ts +80 -80
  506. package/dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts +78 -74
  507. package/dist/builtin/workflows/src/runs/foreground/stage-runner-output.ts +102 -104
  508. package/dist/builtin/workflows/src/runs/foreground/stage-runner-pause.ts +200 -0
  509. package/dist/builtin/workflows/src/runs/foreground/stage-runner-replacement.ts +31 -32
  510. package/dist/builtin/workflows/src/runs/foreground/stage-runner-send-user-message.ts +115 -98
  511. package/dist/builtin/workflows/src/runs/foreground/stage-runner-session-options.ts +29 -42
  512. package/dist/builtin/workflows/src/runs/foreground/stage-runner-session.ts +44 -52
  513. package/dist/builtin/workflows/src/runs/foreground/stage-runner-structured-output.ts +63 -58
  514. package/dist/builtin/workflows/src/runs/foreground/stage-runner-types.ts +161 -124
  515. package/dist/builtin/workflows/src/runs/foreground/stage-runner-unresolved-overflow.ts +27 -23
  516. package/dist/builtin/workflows/src/runs/foreground/stage-runner.ts +10 -10
  517. package/dist/builtin/workflows/src/runs/foreground/stage-tool-execution-buffer.ts +33 -31
  518. package/dist/builtin/workflows/src/runs/shared/concurrency.ts +53 -53
  519. package/dist/builtin/workflows/src/runs/shared/graph-inference.ts +1 -1
  520. package/dist/builtin/workflows/src/runs/shared/model-fallback-candidates.ts +257 -385
  521. package/dist/builtin/workflows/src/runs/shared/model-fallback-failures.ts +378 -363
  522. package/dist/builtin/workflows/src/runs/shared/prompt-callsite.ts +55 -55
  523. package/dist/builtin/workflows/src/runs/shared/validate-inputs.ts +75 -84
  524. package/dist/builtin/workflows/src/runs/shared/worktree-cache-lifecycle.ts +1 -3
  525. package/dist/builtin/workflows/src/runs/shared/worktree-cwd.ts +96 -83
  526. package/dist/builtin/workflows/src/runs/shared/worktree-diff.ts +9 -2
  527. package/dist/builtin/workflows/src/runs/shared/worktree-git-runner.ts +21 -6
  528. package/dist/builtin/workflows/src/runs/shared/worktree-git.ts +60 -30
  529. package/dist/builtin/workflows/src/runs/shared/worktree-post-create.ts +12 -5
  530. package/dist/builtin/workflows/src/runs/shared/worktree-setup.ts +51 -30
  531. package/dist/builtin/workflows/src/runs/shared/worktree.ts +4 -4
  532. package/dist/builtin/workflows/src/sdk-surface.ts +38 -19
  533. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +17 -16
  534. package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +299 -280
  535. package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +76 -10
  536. package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +311 -219
  537. package/dist/builtin/workflows/src/shared/expanded-workflow-graph.ts +255 -156
  538. package/dist/builtin/workflows/src/shared/intercom-group.ts +33 -26
  539. package/dist/builtin/workflows/src/shared/persistence-compaction-policy.ts +30 -30
  540. package/dist/builtin/workflows/src/shared/persistence-restore-helpers.ts +435 -379
  541. package/dist/builtin/workflows/src/shared/persistence-restore.ts +187 -181
  542. package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +211 -207
  543. package/dist/builtin/workflows/src/shared/prompt-callsite-context.ts +3 -3
  544. package/dist/builtin/workflows/src/shared/render-inputs-schema.ts +87 -94
  545. package/dist/builtin/workflows/src/shared/resume-continuation.ts +1 -1
  546. package/dist/builtin/workflows/src/shared/returned-run-status.ts +91 -77
  547. package/dist/builtin/workflows/src/shared/run-visibility.ts +2 -2
  548. package/dist/builtin/workflows/src/shared/schema-introspection.ts +50 -60
  549. package/dist/builtin/workflows/src/shared/serializable.ts +72 -86
  550. package/dist/builtin/workflows/src/shared/session-transcript.ts +44 -39
  551. package/dist/builtin/workflows/src/shared/stage-prompt.ts +183 -202
  552. package/dist/builtin/workflows/src/shared/stage-ui-broker.ts +270 -274
  553. package/dist/builtin/workflows/src/shared/store-factory.ts +9 -7
  554. package/dist/builtin/workflows/src/shared/store-internal.ts +172 -168
  555. package/dist/builtin/workflows/src/shared/store-prompt-methods.ts +196 -200
  556. package/dist/builtin/workflows/src/shared/store-public-types.ts +208 -196
  557. package/dist/builtin/workflows/src/shared/store-run-methods.ts +238 -222
  558. package/dist/builtin/workflows/src/shared/store-stage-methods.ts +284 -283
  559. package/dist/builtin/workflows/src/shared/store-tool-node-methods.ts +53 -0
  560. package/dist/builtin/workflows/src/shared/store-types.ts +269 -235
  561. package/dist/builtin/workflows/src/shared/store.ts +7 -7
  562. package/dist/builtin/workflows/src/shared/timing.ts +36 -34
  563. package/dist/builtin/workflows/src/shared/types.ts +257 -217
  564. package/dist/builtin/workflows/src/shared/workflow-authoring-types.d.ts +11 -4
  565. package/dist/builtin/workflows/src/shared/workflow-authoring-types.ts +81 -58
  566. package/dist/builtin/workflows/src/shared/workflow-failures-classifier.ts +247 -221
  567. package/dist/builtin/workflows/src/shared/workflow-failures-contract.ts +45 -46
  568. package/dist/builtin/workflows/src/shared/workflow-failures-decisions.ts +330 -351
  569. package/dist/builtin/workflows/src/shared/workflow-failures-signals.ts +212 -157
  570. package/dist/builtin/workflows/src/shared/workflow-failures.ts +10 -10
  571. package/dist/builtin/workflows/src/shared/workflow-run-ownership.ts +49 -0
  572. package/dist/builtin/workflows/src/tui/chat-surface-message.ts +157 -184
  573. package/dist/builtin/workflows/src/tui/chat-surface.ts +332 -355
  574. package/dist/builtin/workflows/src/tui/color-utils.ts +21 -30
  575. package/dist/builtin/workflows/src/tui/connectors.ts +57 -61
  576. package/dist/builtin/workflows/src/tui/dispatch-confirm.ts +168 -192
  577. package/dist/builtin/workflows/src/tui/edge.ts +10 -9
  578. package/dist/builtin/workflows/src/tui/graph-canvas.ts +131 -134
  579. package/dist/builtin/workflows/src/tui/graph-theme.ts +139 -148
  580. package/dist/builtin/workflows/src/tui/graph-view-constants.ts +6 -6
  581. package/dist/builtin/workflows/src/tui/graph-view-graph-render.ts +146 -179
  582. package/dist/builtin/workflows/src/tui/graph-view-input.ts +295 -329
  583. package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +291 -320
  584. package/dist/builtin/workflows/src/tui/graph-view-render.ts +171 -190
  585. package/dist/builtin/workflows/src/tui/graph-view-state.ts +319 -287
  586. package/dist/builtin/workflows/src/tui/graph-view-types.ts +65 -58
  587. package/dist/builtin/workflows/src/tui/header.ts +140 -156
  588. package/dist/builtin/workflows/src/tui/host-input-form.ts +47 -45
  589. package/dist/builtin/workflows/src/tui/inline-form-card.ts +277 -266
  590. package/dist/builtin/workflows/src/tui/inline-form-editor-text.ts +61 -62
  591. package/dist/builtin/workflows/src/tui/inline-form-editor.ts +407 -412
  592. package/dist/builtin/workflows/src/tui/inline-form-overlay.ts +203 -214
  593. package/dist/builtin/workflows/src/tui/inline-form-store.ts +24 -24
  594. package/dist/builtin/workflows/src/tui/inputs-overlay.ts +116 -129
  595. package/dist/builtin/workflows/src/tui/inputs-picker-editing.ts +111 -115
  596. package/dist/builtin/workflows/src/tui/inputs-picker-input.ts +255 -269
  597. package/dist/builtin/workflows/src/tui/inputs-picker-render.ts +248 -236
  598. package/dist/builtin/workflows/src/tui/inputs-picker-types.ts +111 -140
  599. package/dist/builtin/workflows/src/tui/inputs-picker.ts +12 -12
  600. package/dist/builtin/workflows/src/tui/keybindings-adapter.ts +49 -57
  601. package/dist/builtin/workflows/src/tui/layout.ts +124 -133
  602. package/dist/builtin/workflows/src/tui/mouse-input.ts +45 -47
  603. package/dist/builtin/workflows/src/tui/node-card.ts +230 -218
  604. package/dist/builtin/workflows/src/tui/overlay-adapter.ts +381 -398
  605. package/dist/builtin/workflows/src/tui/overlay-terminal-modes.ts +20 -19
  606. package/dist/builtin/workflows/src/tui/prompt-card-input.ts +183 -194
  607. package/dist/builtin/workflows/src/tui/prompt-card-render.ts +243 -302
  608. package/dist/builtin/workflows/src/tui/prompt-card-select.ts +76 -98
  609. package/dist/builtin/workflows/src/tui/prompt-card-state.ts +40 -40
  610. package/dist/builtin/workflows/src/tui/prompt-card-text.ts +76 -83
  611. package/dist/builtin/workflows/src/tui/prompt-card.ts +3 -3
  612. package/dist/builtin/workflows/src/tui/renderers.ts +6 -6
  613. package/dist/builtin/workflows/src/tui/run-detail.ts +300 -256
  614. package/dist/builtin/workflows/src/tui/session-list.ts +19 -18
  615. package/dist/builtin/workflows/src/tui/session-overlays.ts +82 -87
  616. package/dist/builtin/workflows/src/tui/session-picker.ts +258 -275
  617. package/dist/builtin/workflows/src/tui/stage-chat-composer-drafts.ts +11 -11
  618. package/dist/builtin/workflows/src/tui/stage-chat-layout.ts +55 -62
  619. package/dist/builtin/workflows/src/tui/stage-chat-view-archive-history.ts +220 -263
  620. package/dist/builtin/workflows/src/tui/stage-chat-view-custom-ui.ts +91 -102
  621. package/dist/builtin/workflows/src/tui/stage-chat-view-delivery-activity.ts +113 -0
  622. package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +154 -208
  623. package/dist/builtin/workflows/src/tui/stage-chat-view-input.ts +174 -208
  624. package/dist/builtin/workflows/src/tui/stage-chat-view-live-events.ts +53 -23
  625. package/dist/builtin/workflows/src/tui/stage-chat-view-pending-tools.ts +2 -4
  626. package/dist/builtin/workflows/src/tui/stage-chat-view-render-helpers.ts +85 -88
  627. package/dist/builtin/workflows/src/tui/stage-chat-view-render-settings.ts +39 -17
  628. package/dist/builtin/workflows/src/tui/stage-chat-view-state.ts +435 -409
  629. package/dist/builtin/workflows/src/tui/stage-chat-view-status.ts +24 -25
  630. package/dist/builtin/workflows/src/tui/stage-chat-view-transcript.ts +181 -197
  631. package/dist/builtin/workflows/src/tui/stage-chat-view-types.ts +125 -128
  632. package/dist/builtin/workflows/src/tui/stage-chat-view.ts +210 -205
  633. package/dist/builtin/workflows/src/tui/status-helpers.ts +65 -69
  634. package/dist/builtin/workflows/src/tui/status-list.ts +316 -294
  635. package/dist/builtin/workflows/src/tui/store-widget-installer.ts +213 -214
  636. package/dist/builtin/workflows/src/tui/submit-pane.ts +114 -130
  637. package/dist/builtin/workflows/src/tui/switcher.ts +120 -128
  638. package/dist/builtin/workflows/src/tui/text-helpers.ts +136 -145
  639. package/dist/builtin/workflows/src/tui/toast.ts +68 -67
  640. package/dist/builtin/workflows/src/tui/widget.ts +265 -285
  641. package/dist/builtin/workflows/src/tui/workflow-attach-pane-handle.ts +12 -17
  642. package/dist/builtin/workflows/src/tui/workflow-attach-pane-types.ts +81 -91
  643. package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +468 -479
  644. package/dist/builtin/workflows/src/tui/workflow-list.ts +130 -145
  645. package/dist/builtin/workflows/src/tui/workflow-notice-card.ts +127 -144
  646. package/dist/builtin/workflows/src/tui/workflow-resume-selector.ts +217 -217
  647. package/dist/builtin/workflows/src/tui/workflow-status.ts +7 -0
  648. package/dist/builtin/workflows/src/workflows/identity.ts +12 -12
  649. package/dist/builtin/workflows/src/workflows/registry.ts +66 -68
  650. package/dist/bun/cli.js.map +1 -1
  651. package/dist/bun/internal-intercom-broker.d.ts.map +1 -1
  652. package/dist/bun/internal-intercom-broker.js +1 -1
  653. package/dist/bun/internal-intercom-broker.js.map +1 -1
  654. package/dist/bun/register-bedrock.js +1 -1
  655. package/dist/bun/register-bedrock.js.map +1 -1
  656. package/dist/cli/args.d.ts +8 -1
  657. package/dist/cli/args.d.ts.map +1 -1
  658. package/dist/cli/args.js +28 -22
  659. package/dist/cli/args.js.map +1 -1
  660. package/dist/cli/config-selector.d.ts +4 -2
  661. package/dist/cli/config-selector.d.ts.map +1 -1
  662. package/dist/cli/config-selector.js +2 -2
  663. package/dist/cli/config-selector.js.map +1 -1
  664. package/dist/cli/credential-print.d.ts +170 -0
  665. package/dist/cli/credential-print.d.ts.map +1 -0
  666. package/dist/cli/credential-print.js +513 -0
  667. package/dist/cli/credential-print.js.map +1 -0
  668. package/dist/cli/list-models.d.ts +2 -2
  669. package/dist/cli/list-models.d.ts.map +1 -1
  670. package/dist/cli/list-models.js +6 -7
  671. package/dist/cli/list-models.js.map +1 -1
  672. package/dist/cli/project-trust.d.ts +1 -1
  673. package/dist/cli/project-trust.d.ts.map +1 -1
  674. package/dist/cli/project-trust.js.map +1 -1
  675. package/dist/cli/session-picker.d.ts.map +1 -1
  676. package/dist/cli/session-picker.js +2 -1
  677. package/dist/cli/session-picker.js.map +1 -1
  678. package/dist/cli/startup-ui.d.ts +3 -0
  679. package/dist/cli/startup-ui.d.ts.map +1 -1
  680. package/dist/cli/startup-ui.js +58 -2
  681. package/dist/cli/startup-ui.js.map +1 -1
  682. package/dist/cli.js +2 -0
  683. package/dist/cli.js.map +1 -1
  684. package/dist/config-command-parser.d.ts +9 -0
  685. package/dist/config-command-parser.d.ts.map +1 -0
  686. package/dist/config-command-parser.js +22 -0
  687. package/dist/config-command-parser.js.map +1 -0
  688. package/dist/config-self-update.d.ts +6 -2
  689. package/dist/config-self-update.d.ts.map +1 -1
  690. package/dist/config-self-update.js +23 -13
  691. package/dist/config-self-update.js.map +1 -1
  692. package/dist/config.d.ts +5 -3
  693. package/dist/config.d.ts.map +1 -1
  694. package/dist/config.js +36 -14
  695. package/dist/config.js.map +1 -1
  696. package/dist/core/agent-session-accessors.d.ts.map +1 -1
  697. package/dist/core/agent-session-accessors.js +125 -24
  698. package/dist/core/agent-session-accessors.js.map +1 -1
  699. package/dist/core/agent-session-auto-compaction.d.ts +4 -3
  700. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  701. package/dist/core/agent-session-auto-compaction.js +59 -64
  702. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  703. package/dist/core/agent-session-bash.d.ts +10 -7
  704. package/dist/core/agent-session-bash.d.ts.map +1 -1
  705. package/dist/core/agent-session-bash.js +34 -13
  706. package/dist/core/agent-session-bash.js.map +1 -1
  707. package/dist/core/agent-session-compaction.d.ts +11 -1
  708. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  709. package/dist/core/agent-session-compaction.js +138 -27
  710. package/dist/core/agent-session-compaction.js.map +1 -1
  711. package/dist/core/agent-session-custom-message-commit.d.ts +14 -0
  712. package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -0
  713. package/dist/core/agent-session-custom-message-commit.js +145 -0
  714. package/dist/core/agent-session-custom-message-commit.js.map +1 -0
  715. package/dist/core/agent-session-delivery-forwarding.d.ts +9 -0
  716. package/dist/core/agent-session-delivery-forwarding.d.ts.map +1 -0
  717. package/dist/core/agent-session-delivery-forwarding.js +36 -0
  718. package/dist/core/agent-session-delivery-forwarding.js.map +1 -0
  719. package/dist/core/agent-session-events.d.ts +1 -1
  720. package/dist/core/agent-session-events.d.ts.map +1 -1
  721. package/dist/core/agent-session-events.js +58 -19
  722. package/dist/core/agent-session-events.js.map +1 -1
  723. package/dist/core/agent-session-export.d.ts +1 -1
  724. package/dist/core/agent-session-export.d.ts.map +1 -1
  725. package/dist/core/agent-session-export.js +32 -25
  726. package/dist/core/agent-session-export.js.map +1 -1
  727. package/dist/core/agent-session-extension-bindings.d.ts +2 -6
  728. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  729. package/dist/core/agent-session-extension-bindings.js +38 -18
  730. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  731. package/dist/core/agent-session-message-queue.d.ts +7 -4
  732. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  733. package/dist/core/agent-session-message-queue.js +101 -98
  734. package/dist/core/agent-session-message-queue.js.map +1 -1
  735. package/dist/core/agent-session-methods.d.ts +52 -45
  736. package/dist/core/agent-session-methods.d.ts.map +1 -1
  737. package/dist/core/agent-session-methods.js.map +1 -1
  738. package/dist/core/agent-session-models.d.ts +3 -39
  739. package/dist/core/agent-session-models.d.ts.map +1 -1
  740. package/dist/core/agent-session-models.js +22 -160
  741. package/dist/core/agent-session-models.js.map +1 -1
  742. package/dist/core/agent-session-persistent-custom-messages.d.ts +47 -0
  743. package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -0
  744. package/dist/core/agent-session-persistent-custom-messages.js +269 -0
  745. package/dist/core/agent-session-persistent-custom-messages.js.map +1 -0
  746. package/dist/core/agent-session-post-tool-compaction.d.ts +1 -1
  747. package/dist/core/agent-session-post-tool-compaction.d.ts.map +1 -1
  748. package/dist/core/agent-session-post-tool-compaction.js +34 -11
  749. package/dist/core/agent-session-post-tool-compaction.js.map +1 -1
  750. package/dist/core/agent-session-prompt.d.ts +2 -0
  751. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  752. package/dist/core/agent-session-prompt.js +52 -25
  753. package/dist/core/agent-session-prompt.js.map +1 -1
  754. package/dist/core/agent-session-queue-pause.d.ts +10 -0
  755. package/dist/core/agent-session-queue-pause.d.ts.map +1 -0
  756. package/dist/core/agent-session-queue-pause.js +87 -0
  757. package/dist/core/agent-session-queue-pause.js.map +1 -0
  758. package/dist/core/agent-session-retry.d.ts +0 -11
  759. package/dist/core/agent-session-retry.d.ts.map +1 -1
  760. package/dist/core/agent-session-retry.js +44 -63
  761. package/dist/core/agent-session-retry.js.map +1 -1
  762. package/dist/core/agent-session-runtime-auth.d.ts +6 -0
  763. package/dist/core/agent-session-runtime-auth.d.ts.map +1 -0
  764. package/dist/core/agent-session-runtime-auth.js +18 -0
  765. package/dist/core/agent-session-runtime-auth.js.map +1 -0
  766. package/dist/core/agent-session-runtime.d.ts +36 -1
  767. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  768. package/dist/core/agent-session-runtime.js +62 -6
  769. package/dist/core/agent-session-runtime.js.map +1 -1
  770. package/dist/core/agent-session-services.d.ts +4 -9
  771. package/dist/core/agent-session-services.d.ts.map +1 -1
  772. package/dist/core/agent-session-services.js +25 -25
  773. package/dist/core/agent-session-services.js.map +1 -1
  774. package/dist/core/agent-session-state.d.ts +1 -1
  775. package/dist/core/agent-session-state.d.ts.map +1 -1
  776. package/dist/core/agent-session-state.js +3 -0
  777. package/dist/core/agent-session-state.js.map +1 -1
  778. package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
  779. package/dist/core/agent-session-tool-hooks.js +8 -7
  780. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  781. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  782. package/dist/core/agent-session-tool-registry.js +6 -20
  783. package/dist/core/agent-session-tool-registry.js.map +1 -1
  784. package/dist/core/agent-session-transfer.d.ts +4 -0
  785. package/dist/core/agent-session-transfer.d.ts.map +1 -0
  786. package/dist/core/agent-session-transfer.js +67 -0
  787. package/dist/core/agent-session-transfer.js.map +1 -0
  788. package/dist/core/agent-session-tree.d.ts +1 -1
  789. package/dist/core/agent-session-tree.d.ts.map +1 -1
  790. package/dist/core/agent-session-tree.js +13 -3
  791. package/dist/core/agent-session-tree.js.map +1 -1
  792. package/dist/core/agent-session-types.d.ts +28 -14
  793. package/dist/core/agent-session-types.d.ts.map +1 -1
  794. package/dist/core/agent-session-types.js +4 -4
  795. package/dist/core/agent-session-types.js.map +1 -1
  796. package/dist/core/agent-session.d.ts +27 -13
  797. package/dist/core/agent-session.d.ts.map +1 -1
  798. package/dist/core/agent-session.js +17 -12
  799. package/dist/core/agent-session.js.map +1 -1
  800. package/dist/core/anthropic-thinking-guard.d.ts.map +1 -1
  801. package/dist/core/anthropic-thinking-guard.js +4 -2
  802. package/dist/core/anthropic-thinking-guard.js.map +1 -1
  803. package/dist/core/async/format.d.ts +1 -1
  804. package/dist/core/async/format.d.ts.map +1 -1
  805. package/dist/core/async/format.js +3 -1
  806. package/dist/core/async/format.js.map +1 -1
  807. package/dist/core/async/job-manager.d.ts.map +1 -1
  808. package/dist/core/async/job-manager.js +20 -5
  809. package/dist/core/async/job-manager.js.map +1 -1
  810. package/dist/core/async/session-manager.d.ts.map +1 -1
  811. package/dist/core/async/session-manager.js.map +1 -1
  812. package/dist/core/atomic-guide-command.d.ts.map +1 -1
  813. package/dist/core/atomic-guide-command.js +34 -35
  814. package/dist/core/atomic-guide-command.js.map +1 -1
  815. package/dist/core/auth-guidance.d.ts.map +1 -1
  816. package/dist/core/auth-guidance.js.map +1 -1
  817. package/dist/core/auth-storage-backends.d.ts +5 -0
  818. package/dist/core/auth-storage-backends.d.ts.map +1 -1
  819. package/dist/core/auth-storage-backends.js +77 -7
  820. package/dist/core/auth-storage-backends.js.map +1 -1
  821. package/dist/core/auth-storage.d.ts +13 -136
  822. package/dist/core/auth-storage.d.ts.map +1 -1
  823. package/dist/core/auth-storage.js +68 -358
  824. package/dist/core/auth-storage.js.map +1 -1
  825. package/dist/core/bash-executor.d.ts +5 -3
  826. package/dist/core/bash-executor.d.ts.map +1 -1
  827. package/dist/core/bash-executor.js +5 -4
  828. package/dist/core/bash-executor.js.map +1 -1
  829. package/dist/core/builtin-packages.d.ts.map +1 -1
  830. package/dist/core/builtin-packages.js +1 -10
  831. package/dist/core/builtin-packages.js.map +1 -1
  832. package/dist/core/cache-stats.d.ts +25 -0
  833. package/dist/core/cache-stats.d.ts.map +1 -0
  834. package/dist/core/cache-stats.js +70 -0
  835. package/dist/core/cache-stats.js.map +1 -0
  836. package/dist/core/callback-activity.d.ts.map +1 -1
  837. package/dist/core/callback-activity.js.map +1 -1
  838. package/dist/core/codex-errors.d.ts +3 -0
  839. package/dist/core/codex-errors.d.ts.map +1 -0
  840. package/dist/core/codex-errors.js +12 -0
  841. package/dist/core/codex-errors.js.map +1 -0
  842. package/dist/core/codex-fast-mode.d.ts.map +1 -1
  843. package/dist/core/codex-fast-mode.js.map +1 -1
  844. package/dist/core/compaction/branch-summarization.d.ts +15 -5
  845. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  846. package/dist/core/compaction/branch-summarization.js +23 -12
  847. package/dist/core/compaction/branch-summarization.js.map +1 -1
  848. package/dist/core/compaction/compaction-boundary.d.ts +18 -1
  849. package/dist/core/compaction/compaction-boundary.d.ts.map +1 -1
  850. package/dist/core/compaction/compaction-boundary.js +12 -8
  851. package/dist/core/compaction/compaction-boundary.js.map +1 -1
  852. package/dist/core/compaction/compaction-runner.d.ts +63 -6
  853. package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
  854. package/dist/core/compaction/compaction-runner.js +244 -17
  855. package/dist/core/compaction/compaction-runner.js.map +1 -1
  856. package/dist/core/compaction/compaction-types.d.ts +53 -2
  857. package/dist/core/compaction/compaction-types.d.ts.map +1 -1
  858. package/dist/core/compaction/compaction-types.js.map +1 -1
  859. package/dist/core/compaction/compaction.d.ts.map +1 -1
  860. package/dist/core/compaction/compaction.js +5 -1
  861. package/dist/core/compaction/compaction.js.map +1 -1
  862. package/dist/core/compaction/deleted-ranges.d.ts.map +1 -1
  863. package/dist/core/compaction/deleted-ranges.js.map +1 -1
  864. package/dist/core/compaction/fallback-planner.d.ts +64 -0
  865. package/dist/core/compaction/fallback-planner.d.ts.map +1 -0
  866. package/dist/core/compaction/fallback-planner.js +75 -0
  867. package/dist/core/compaction/fallback-planner.js.map +1 -0
  868. package/dist/core/compaction/index.d.ts +7 -4
  869. package/dist/core/compaction/index.d.ts.map +1 -1
  870. package/dist/core/compaction/index.js +7 -4
  871. package/dist/core/compaction/index.js.map +1 -1
  872. package/dist/core/compaction/planner-outcome.d.ts +86 -0
  873. package/dist/core/compaction/planner-outcome.d.ts.map +1 -0
  874. package/dist/core/compaction/planner-outcome.js +122 -0
  875. package/dist/core/compaction/planner-outcome.js.map +1 -0
  876. package/dist/core/compaction/range-planner-diagnostics.d.ts +58 -6
  877. package/dist/core/compaction/range-planner-diagnostics.d.ts.map +1 -1
  878. package/dist/core/compaction/range-planner-diagnostics.js +71 -31
  879. package/dist/core/compaction/range-planner-diagnostics.js.map +1 -1
  880. package/dist/core/compaction/range-planner.d.ts +39 -8
  881. package/dist/core/compaction/range-planner.d.ts.map +1 -1
  882. package/dist/core/compaction/range-planner.js +140 -51
  883. package/dist/core/compaction/range-planner.js.map +1 -1
  884. package/dist/core/compaction/region-trimming.d.ts +34 -0
  885. package/dist/core/compaction/region-trimming.d.ts.map +1 -0
  886. package/dist/core/compaction/region-trimming.js +73 -0
  887. package/dist/core/compaction/region-trimming.js.map +1 -0
  888. package/dist/core/compaction/transcript-serialization.d.ts +8 -1
  889. package/dist/core/compaction/transcript-serialization.d.ts.map +1 -1
  890. package/dist/core/compaction/transcript-serialization.js +78 -27
  891. package/dist/core/compaction/transcript-serialization.js.map +1 -1
  892. package/dist/core/context-tool-pairing.d.ts +19 -0
  893. package/dist/core/context-tool-pairing.d.ts.map +1 -0
  894. package/dist/core/context-tool-pairing.js +50 -0
  895. package/dist/core/context-tool-pairing.js.map +1 -0
  896. package/dist/core/copilot-env-routing.d.ts +36 -0
  897. package/dist/core/copilot-env-routing.d.ts.map +1 -0
  898. package/dist/core/copilot-env-routing.js +94 -0
  899. package/dist/core/copilot-env-routing.js.map +1 -0
  900. package/dist/core/diagnostics.d.ts +8 -0
  901. package/dist/core/diagnostics.d.ts.map +1 -1
  902. package/dist/core/diagnostics.js.map +1 -1
  903. package/dist/core/exec.d.ts.map +1 -1
  904. package/dist/core/exec.js +5 -0
  905. package/dist/core/exec.js.map +1 -1
  906. package/dist/core/experimental.d.ts.map +1 -1
  907. package/dist/core/experimental.js +2 -1
  908. package/dist/core/experimental.js.map +1 -1
  909. package/dist/core/extensions/agent-events.d.ts +10 -0
  910. package/dist/core/extensions/agent-events.d.ts.map +1 -1
  911. package/dist/core/extensions/agent-events.js.map +1 -1
  912. package/dist/core/extensions/api-types.d.ts +9 -3
  913. package/dist/core/extensions/api-types.d.ts.map +1 -1
  914. package/dist/core/extensions/api-types.js.map +1 -1
  915. package/dist/core/extensions/context-types.d.ts +10 -1
  916. package/dist/core/extensions/context-types.d.ts.map +1 -1
  917. package/dist/core/extensions/context-types.js.map +1 -1
  918. package/dist/core/extensions/event-types.d.ts +2 -2
  919. package/dist/core/extensions/event-types.d.ts.map +1 -1
  920. package/dist/core/extensions/event-types.js.map +1 -1
  921. package/dist/core/extensions/index.d.ts +7 -5
  922. package/dist/core/extensions/index.d.ts.map +1 -1
  923. package/dist/core/extensions/index.js +2 -2
  924. package/dist/core/extensions/index.js.map +1 -1
  925. package/dist/core/extensions/loader-api.d.ts +1 -1
  926. package/dist/core/extensions/loader-api.d.ts.map +1 -1
  927. package/dist/core/extensions/loader-api.js +63 -29
  928. package/dist/core/extensions/loader-api.js.map +1 -1
  929. package/dist/core/extensions/loader-core.d.ts.map +1 -1
  930. package/dist/core/extensions/loader-core.js +3 -2
  931. package/dist/core/extensions/loader-core.js.map +1 -1
  932. package/dist/core/extensions/loader-discovery.d.ts.map +1 -1
  933. package/dist/core/extensions/loader-discovery.js.map +1 -1
  934. package/dist/core/extensions/loader-resources.d.ts.map +1 -1
  935. package/dist/core/extensions/loader-resources.js.map +1 -1
  936. package/dist/core/extensions/loader-runtime.d.ts +2 -4
  937. package/dist/core/extensions/loader-runtime.d.ts.map +1 -1
  938. package/dist/core/extensions/loader-runtime.js +214 -13
  939. package/dist/core/extensions/loader-runtime.js.map +1 -1
  940. package/dist/core/extensions/loader-virtual-modules.d.ts +17 -0
  941. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  942. package/dist/core/extensions/loader-virtual-modules.js +288 -19
  943. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  944. package/dist/core/extensions/loader.d.ts.map +1 -1
  945. package/dist/core/extensions/loader.js.map +1 -1
  946. package/dist/core/extensions/message-types.d.ts +12 -4
  947. package/dist/core/extensions/message-types.d.ts.map +1 -1
  948. package/dist/core/extensions/message-types.js.map +1 -1
  949. package/dist/core/extensions/provider-types.d.ts +16 -5
  950. package/dist/core/extensions/provider-types.d.ts.map +1 -1
  951. package/dist/core/extensions/provider-types.js.map +1 -1
  952. package/dist/core/extensions/reactive-widget.d.ts.map +1 -1
  953. package/dist/core/extensions/reactive-widget.js.map +1 -1
  954. package/dist/core/extensions/runner-context.d.ts +29 -1
  955. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  956. package/dist/core/extensions/runner-context.js +56 -0
  957. package/dist/core/extensions/runner-context.js.map +1 -1
  958. package/dist/core/extensions/runner-events.d.ts.map +1 -1
  959. package/dist/core/extensions/runner-events.js.map +1 -1
  960. package/dist/core/extensions/runner-registries.d.ts +2 -1
  961. package/dist/core/extensions/runner-registries.d.ts.map +1 -1
  962. package/dist/core/extensions/runner-registries.js +8 -0
  963. package/dist/core/extensions/runner-registries.js.map +1 -1
  964. package/dist/core/extensions/runner.d.ts +7 -2
  965. package/dist/core/extensions/runner.d.ts.map +1 -1
  966. package/dist/core/extensions/runner.js +65 -23
  967. package/dist/core/extensions/runner.js.map +1 -1
  968. package/dist/core/extensions/runtime-types.d.ts +35 -2
  969. package/dist/core/extensions/runtime-types.d.ts.map +1 -1
  970. package/dist/core/extensions/runtime-types.js.map +1 -1
  971. package/dist/core/extensions/session-events.d.ts.map +1 -1
  972. package/dist/core/extensions/session-events.js.map +1 -1
  973. package/dist/core/extensions/tool-types.d.ts +7 -3
  974. package/dist/core/extensions/tool-types.d.ts.map +1 -1
  975. package/dist/core/extensions/tool-types.js.map +1 -1
  976. package/dist/core/extensions/types.d.ts +15 -2
  977. package/dist/core/extensions/types.d.ts.map +1 -1
  978. package/dist/core/extensions/types.js +1 -1
  979. package/dist/core/extensions/types.js.map +1 -1
  980. package/dist/core/extensions/ui-types.d.ts +34 -6
  981. package/dist/core/extensions/ui-types.d.ts.map +1 -1
  982. package/dist/core/extensions/ui-types.js.map +1 -1
  983. package/dist/core/fallback-models.d.ts +37 -0
  984. package/dist/core/fallback-models.d.ts.map +1 -0
  985. package/dist/core/fallback-models.js +57 -0
  986. package/dist/core/fallback-models.js.map +1 -0
  987. package/dist/core/flattened-tool-arguments.d.ts +4 -7
  988. package/dist/core/flattened-tool-arguments.d.ts.map +1 -1
  989. package/dist/core/flattened-tool-arguments.js +4 -7
  990. package/dist/core/flattened-tool-arguments.js.map +1 -1
  991. package/dist/core/footer-data-provider.d.ts +10 -0
  992. package/dist/core/footer-data-provider.d.ts.map +1 -1
  993. package/dist/core/footer-data-provider.js +5 -3
  994. package/dist/core/footer-data-provider.js.map +1 -1
  995. package/dist/core/http-dispatcher.d.ts +1 -0
  996. package/dist/core/http-dispatcher.d.ts.map +1 -1
  997. package/dist/core/http-dispatcher.js +42 -8
  998. package/dist/core/http-dispatcher.js.map +1 -1
  999. package/dist/core/keybindings.d.ts +7 -2
  1000. package/dist/core/keybindings.d.ts.map +1 -1
  1001. package/dist/core/keybindings.js +3 -1
  1002. package/dist/core/keybindings.js.map +1 -1
  1003. package/dist/core/messages.d.ts +24 -4
  1004. package/dist/core/messages.d.ts.map +1 -1
  1005. package/dist/core/messages.js +64 -13
  1006. package/dist/core/messages.js.map +1 -1
  1007. package/dist/core/model-capabilities.d.ts +18 -0
  1008. package/dist/core/model-capabilities.d.ts.map +1 -0
  1009. package/dist/core/model-capabilities.js +22 -0
  1010. package/dist/core/model-capabilities.js.map +1 -0
  1011. package/dist/core/model-config.d.ts +542 -0
  1012. package/dist/core/model-config.d.ts.map +1 -0
  1013. package/dist/core/{model-registry-schemas.js → model-config.js} +92 -32
  1014. package/dist/core/model-config.js.map +1 -0
  1015. package/dist/core/model-refresh-timeout.d.ts +9 -0
  1016. package/dist/core/model-refresh-timeout.d.ts.map +1 -0
  1017. package/dist/core/model-refresh-timeout.js +9 -0
  1018. package/dist/core/model-refresh-timeout.js.map +1 -0
  1019. package/dist/core/model-registry.d.ts +26 -94
  1020. package/dist/core/model-registry.d.ts.map +1 -1
  1021. package/dist/core/model-registry.js +65 -382
  1022. package/dist/core/model-registry.js.map +1 -1
  1023. package/dist/core/model-resolver-cli.d.ts +2 -2
  1024. package/dist/core/model-resolver-cli.d.ts.map +1 -1
  1025. package/dist/core/model-resolver-cli.js +2 -2
  1026. package/dist/core/model-resolver-cli.js.map +1 -1
  1027. package/dist/core/model-resolver-defaults.d.ts.map +1 -1
  1028. package/dist/core/model-resolver-defaults.js +5 -1
  1029. package/dist/core/model-resolver-defaults.js.map +1 -1
  1030. package/dist/core/model-resolver-initial.d.ts +4 -4
  1031. package/dist/core/model-resolver-initial.d.ts.map +1 -1
  1032. package/dist/core/model-resolver-initial.js +26 -17
  1033. package/dist/core/model-resolver-initial.js.map +1 -1
  1034. package/dist/core/model-resolver-patterns.d.ts.map +1 -1
  1035. package/dist/core/model-resolver-patterns.js +0 -2
  1036. package/dist/core/model-resolver-patterns.js.map +1 -1
  1037. package/dist/core/model-resolver-scope.d.ts +5 -3
  1038. package/dist/core/model-resolver-scope.d.ts.map +1 -1
  1039. package/dist/core/model-resolver-scope.js +32 -8
  1040. package/dist/core/model-resolver-scope.js.map +1 -1
  1041. package/dist/core/model-resolver-types.d.ts +2 -0
  1042. package/dist/core/model-resolver-types.d.ts.map +1 -1
  1043. package/dist/core/model-resolver-types.js.map +1 -1
  1044. package/dist/core/model-resolver.d.ts +3 -3
  1045. package/dist/core/model-resolver.d.ts.map +1 -1
  1046. package/dist/core/model-resolver.js +1 -1
  1047. package/dist/core/model-resolver.js.map +1 -1
  1048. package/dist/core/model-runtime-auth.d.ts +7 -0
  1049. package/dist/core/model-runtime-auth.d.ts.map +1 -0
  1050. package/dist/core/model-runtime-auth.js +17 -0
  1051. package/dist/core/model-runtime-auth.js.map +1 -0
  1052. package/dist/core/model-runtime-providers.d.ts +6 -0
  1053. package/dist/core/model-runtime-providers.d.ts.map +1 -0
  1054. package/dist/core/model-runtime-providers.js +22 -0
  1055. package/dist/core/model-runtime-providers.js.map +1 -0
  1056. package/dist/core/model-runtime-restoration.d.ts +6 -0
  1057. package/dist/core/model-runtime-restoration.d.ts.map +1 -0
  1058. package/dist/core/model-runtime-restoration.js +21 -0
  1059. package/dist/core/model-runtime-restoration.js.map +1 -0
  1060. package/dist/core/model-runtime-snapshot.d.ts +19 -0
  1061. package/dist/core/model-runtime-snapshot.d.ts.map +1 -0
  1062. package/dist/core/model-runtime-snapshot.js +111 -0
  1063. package/dist/core/model-runtime-snapshot.js.map +1 -0
  1064. package/dist/core/model-runtime-streaming.d.ts +17 -0
  1065. package/dist/core/model-runtime-streaming.d.ts.map +1 -0
  1066. package/dist/core/model-runtime-streaming.js +66 -0
  1067. package/dist/core/model-runtime-streaming.js.map +1 -0
  1068. package/dist/core/model-runtime-types.d.ts +21 -0
  1069. package/dist/core/model-runtime-types.d.ts.map +1 -0
  1070. package/dist/core/model-runtime-types.js +2 -0
  1071. package/dist/core/model-runtime-types.js.map +1 -0
  1072. package/dist/core/model-runtime.d.ts +79 -0
  1073. package/dist/core/model-runtime.d.ts.map +1 -0
  1074. package/dist/core/model-runtime.js +417 -0
  1075. package/dist/core/model-runtime.js.map +1 -0
  1076. package/dist/core/models-store.d.ts +2 -10
  1077. package/dist/core/models-store.d.ts.map +1 -1
  1078. package/dist/core/models-store.js +2 -29
  1079. package/dist/core/models-store.js.map +1 -1
  1080. package/dist/core/oauth-login.d.ts +24 -0
  1081. package/dist/core/oauth-login.d.ts.map +1 -0
  1082. package/dist/core/oauth-login.js +92 -0
  1083. package/dist/core/oauth-login.js.map +1 -0
  1084. package/dist/core/oauth-provider-metadata.d.ts +5 -0
  1085. package/dist/core/oauth-provider-metadata.d.ts.map +1 -0
  1086. package/dist/core/oauth-provider-metadata.js +33 -0
  1087. package/dist/core/oauth-provider-metadata.js.map +1 -0
  1088. package/dist/core/openai-responses-payload-sanitizer.js.map +1 -1
  1089. package/dist/core/output-guard.d.ts +44 -0
  1090. package/dist/core/output-guard.d.ts.map +1 -1
  1091. package/dist/core/output-guard.js +63 -0
  1092. package/dist/core/output-guard.js.map +1 -1
  1093. package/dist/core/package-manager-auto-resources.d.ts.map +1 -1
  1094. package/dist/core/package-manager-auto-resources.js +18 -5
  1095. package/dist/core/package-manager-auto-resources.js.map +1 -1
  1096. package/dist/core/package-manager-git.d.ts.map +1 -1
  1097. package/dist/core/package-manager-git.js +27 -11
  1098. package/dist/core/package-manager-git.js.map +1 -1
  1099. package/dist/core/package-manager-npm.d.ts.map +1 -1
  1100. package/dist/core/package-manager-npm.js +4 -2
  1101. package/dist/core/package-manager-npm.js.map +1 -1
  1102. package/dist/core/package-manager-operations.d.ts.map +1 -1
  1103. package/dist/core/package-manager-operations.js +2 -2
  1104. package/dist/core/package-manager-operations.js.map +1 -1
  1105. package/dist/core/package-manager-paths.d.ts.map +1 -1
  1106. package/dist/core/package-manager-paths.js.map +1 -1
  1107. package/dist/core/package-manager-resolver.d.ts.map +1 -1
  1108. package/dist/core/package-manager-resolver.js +71 -26
  1109. package/dist/core/package-manager-resolver.js.map +1 -1
  1110. package/dist/core/package-manager-resource-collector.d.ts.map +1 -1
  1111. package/dist/core/package-manager-resource-collector.js +13 -7
  1112. package/dist/core/package-manager-resource-collector.js.map +1 -1
  1113. package/dist/core/package-manager-resource-files.d.ts.map +1 -1
  1114. package/dist/core/package-manager-resource-files.js +4 -3
  1115. package/dist/core/package-manager-resource-files.js.map +1 -1
  1116. package/dist/core/package-manager-resource-patterns.d.ts +1 -0
  1117. package/dist/core/package-manager-resource-patterns.d.ts.map +1 -1
  1118. package/dist/core/package-manager-resource-patterns.js +15 -0
  1119. package/dist/core/package-manager-resource-patterns.js.map +1 -1
  1120. package/dist/core/package-manager-settings.d.ts.map +1 -1
  1121. package/dist/core/package-manager-settings.js +3 -2
  1122. package/dist/core/package-manager-settings.js.map +1 -1
  1123. package/dist/core/package-manager-source.d.ts.map +1 -1
  1124. package/dist/core/package-manager-source.js +16 -9
  1125. package/dist/core/package-manager-source.js.map +1 -1
  1126. package/dist/core/package-manager-types.d.ts +3 -0
  1127. package/dist/core/package-manager-types.d.ts.map +1 -1
  1128. package/dist/core/package-manager-types.js.map +1 -1
  1129. package/dist/core/package-manager.d.ts +1 -1
  1130. package/dist/core/package-manager.d.ts.map +1 -1
  1131. package/dist/core/package-manager.js +2 -3
  1132. package/dist/core/package-manager.js.map +1 -1
  1133. package/dist/core/prompt-templates-async.d.ts.map +1 -1
  1134. package/dist/core/prompt-templates-async.js +15 -7
  1135. package/dist/core/prompt-templates-async.js.map +1 -1
  1136. package/dist/core/prompt-templates.d.ts +1 -0
  1137. package/dist/core/prompt-templates.d.ts.map +1 -1
  1138. package/dist/core/prompt-templates.js +4 -4
  1139. package/dist/core/prompt-templates.js.map +1 -1
  1140. package/dist/core/provider-composer-internal.d.ts +53 -0
  1141. package/dist/core/provider-composer-internal.d.ts.map +1 -0
  1142. package/dist/core/provider-composer-internal.js +273 -0
  1143. package/dist/core/provider-composer-internal.js.map +1 -0
  1144. package/dist/core/provider-composer.d.ts +16 -0
  1145. package/dist/core/provider-composer.d.ts.map +1 -0
  1146. package/dist/core/provider-composer.js +108 -0
  1147. package/dist/core/provider-composer.js.map +1 -0
  1148. package/dist/core/provider-context-usage.d.ts.map +1 -1
  1149. package/dist/core/provider-context-usage.js +2 -1
  1150. package/dist/core/provider-context-usage.js.map +1 -1
  1151. package/dist/core/provider-display-names.d.ts.map +1 -1
  1152. package/dist/core/provider-display-names.js +4 -0
  1153. package/dist/core/provider-display-names.js.map +1 -1
  1154. package/dist/core/remote-catalog-provider.d.ts +1 -1
  1155. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  1156. package/dist/core/remote-catalog-provider.js +82 -105
  1157. package/dist/core/remote-catalog-provider.js.map +1 -1
  1158. package/dist/core/resolve-config-value.d.ts +8 -7
  1159. package/dist/core/resolve-config-value.d.ts.map +1 -1
  1160. package/dist/core/resolve-config-value.js +26 -23
  1161. package/dist/core/resolve-config-value.js.map +1 -1
  1162. package/dist/core/resource-loader-assets.d.ts.map +1 -1
  1163. package/dist/core/resource-loader-assets.js +58 -8
  1164. package/dist/core/resource-loader-assets.js.map +1 -1
  1165. package/dist/core/resource-loader-context-files.d.ts +6 -0
  1166. package/dist/core/resource-loader-context-files.d.ts.map +1 -1
  1167. package/dist/core/resource-loader-context-files.js +85 -4
  1168. package/dist/core/resource-loader-context-files.js.map +1 -1
  1169. package/dist/core/resource-loader-core.d.ts +13 -3
  1170. package/dist/core/resource-loader-core.d.ts.map +1 -1
  1171. package/dist/core/resource-loader-core.js +39 -19
  1172. package/dist/core/resource-loader-core.js.map +1 -1
  1173. package/dist/core/resource-loader-discovery.d.ts.map +1 -1
  1174. package/dist/core/resource-loader-discovery.js.map +1 -1
  1175. package/dist/core/resource-loader-extensions.d.ts +1 -0
  1176. package/dist/core/resource-loader-extensions.d.ts.map +1 -1
  1177. package/dist/core/resource-loader-extensions.js +140 -12
  1178. package/dist/core/resource-loader-extensions.js.map +1 -1
  1179. package/dist/core/resource-loader-helpers.d.ts.map +1 -1
  1180. package/dist/core/resource-loader-helpers.js +1 -0
  1181. package/dist/core/resource-loader-helpers.js.map +1 -1
  1182. package/dist/core/resource-loader-internals.d.ts +14 -7
  1183. package/dist/core/resource-loader-internals.d.ts.map +1 -1
  1184. package/dist/core/resource-loader-internals.js.map +1 -1
  1185. package/dist/core/resource-loader-package-resources.d.ts.map +1 -1
  1186. package/dist/core/resource-loader-package-resources.js +15 -2
  1187. package/dist/core/resource-loader-package-resources.js.map +1 -1
  1188. package/dist/core/resource-loader-paths.js.map +1 -1
  1189. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  1190. package/dist/core/resource-loader-reload.js +29 -13
  1191. package/dist/core/resource-loader-reload.js.map +1 -1
  1192. package/dist/core/resource-loader-source-info.d.ts +1 -1
  1193. package/dist/core/resource-loader-source-info.d.ts.map +1 -1
  1194. package/dist/core/resource-loader-source-info.js +7 -4
  1195. package/dist/core/resource-loader-source-info.js.map +1 -1
  1196. package/dist/core/resource-loader-types.d.ts +12 -6
  1197. package/dist/core/resource-loader-types.d.ts.map +1 -1
  1198. package/dist/core/resource-loader-types.js.map +1 -1
  1199. package/dist/core/resource-loader.d.ts +1 -1
  1200. package/dist/core/resource-loader.d.ts.map +1 -1
  1201. package/dist/core/resource-loader.js +1 -1
  1202. package/dist/core/resource-loader.js.map +1 -1
  1203. package/dist/core/runtime-credentials.d.ts +16 -0
  1204. package/dist/core/runtime-credentials.d.ts.map +1 -0
  1205. package/dist/core/runtime-credentials.js +42 -0
  1206. package/dist/core/runtime-credentials.js.map +1 -0
  1207. package/dist/core/sdk-exports.d.ts +2 -2
  1208. package/dist/core/sdk-exports.d.ts.map +1 -1
  1209. package/dist/core/sdk-exports.js +2 -2
  1210. package/dist/core/sdk-exports.js.map +1 -1
  1211. package/dist/core/sdk-types.d.ts +16 -18
  1212. package/dist/core/sdk-types.d.ts.map +1 -1
  1213. package/dist/core/sdk-types.js.map +1 -1
  1214. package/dist/core/sdk.d.ts +2 -1
  1215. package/dist/core/sdk.d.ts.map +1 -1
  1216. package/dist/core/sdk.js +61 -132
  1217. package/dist/core/sdk.js.map +1 -1
  1218. package/dist/core/session-manager-archive.d.ts.map +1 -1
  1219. package/dist/core/session-manager-archive.js +5 -2
  1220. package/dist/core/session-manager-archive.js.map +1 -1
  1221. package/dist/core/session-manager-classification.js +3 -3
  1222. package/dist/core/session-manager-classification.js.map +1 -1
  1223. package/dist/core/session-manager-core.d.ts +5 -4
  1224. package/dist/core/session-manager-core.d.ts.map +1 -1
  1225. package/dist/core/session-manager-core.js +29 -33
  1226. package/dist/core/session-manager-core.js.map +1 -1
  1227. package/dist/core/session-manager-entries.d.ts +5 -8
  1228. package/dist/core/session-manager-entries.d.ts.map +1 -1
  1229. package/dist/core/session-manager-entries.js +4 -9
  1230. package/dist/core/session-manager-entries.js.map +1 -1
  1231. package/dist/core/session-manager-history.d.ts +8 -3
  1232. package/dist/core/session-manager-history.d.ts.map +1 -1
  1233. package/dist/core/session-manager-history.js +90 -27
  1234. package/dist/core/session-manager-history.js.map +1 -1
  1235. package/dist/core/session-manager-list.d.ts.map +1 -1
  1236. package/dist/core/session-manager-list.js +1 -1
  1237. package/dist/core/session-manager-list.js.map +1 -1
  1238. package/dist/core/session-manager-migrations.js.map +1 -1
  1239. package/dist/core/session-manager-storage.d.ts +6 -0
  1240. package/dist/core/session-manager-storage.d.ts.map +1 -1
  1241. package/dist/core/session-manager-storage.js +38 -5
  1242. package/dist/core/session-manager-storage.js.map +1 -1
  1243. package/dist/core/session-manager-types.d.ts +10 -8
  1244. package/dist/core/session-manager-types.d.ts.map +1 -1
  1245. package/dist/core/session-manager-types.js.map +1 -1
  1246. package/dist/core/session-manager-validation.d.ts.map +1 -1
  1247. package/dist/core/session-manager-validation.js +3 -16
  1248. package/dist/core/session-manager-validation.js.map +1 -1
  1249. package/dist/core/session-manager.d.ts +4 -4
  1250. package/dist/core/session-manager.d.ts.map +1 -1
  1251. package/dist/core/session-manager.js +2 -2
  1252. package/dist/core/session-manager.js.map +1 -1
  1253. package/dist/core/settings-manager-basic-accessors.d.ts +7 -4
  1254. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  1255. package/dist/core/settings-manager-basic-accessors.js +35 -50
  1256. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  1257. package/dist/core/settings-manager-core.d.ts +2 -4
  1258. package/dist/core/settings-manager-core.d.ts.map +1 -1
  1259. package/dist/core/settings-manager-core.js +5 -51
  1260. package/dist/core/settings-manager-core.js.map +1 -1
  1261. package/dist/core/settings-manager-resource-accessors.d.ts +3 -0
  1262. package/dist/core/settings-manager-resource-accessors.d.ts.map +1 -1
  1263. package/dist/core/settings-manager-resource-accessors.js +16 -0
  1264. package/dist/core/settings-manager-resource-accessors.js.map +1 -1
  1265. package/dist/core/settings-manager-ui-accessors.js +2 -1
  1266. package/dist/core/settings-manager-ui-accessors.js.map +1 -1
  1267. package/dist/core/settings-manager.d.ts +1 -1
  1268. package/dist/core/settings-manager.d.ts.map +1 -1
  1269. package/dist/core/settings-manager.js.map +1 -1
  1270. package/dist/core/settings-storage.d.ts +3 -1
  1271. package/dist/core/settings-storage.d.ts.map +1 -1
  1272. package/dist/core/settings-storage.js +23 -1
  1273. package/dist/core/settings-storage.js.map +1 -1
  1274. package/dist/core/settings-types.d.ts +10 -6
  1275. package/dist/core/settings-types.d.ts.map +1 -1
  1276. package/dist/core/settings-types.js.map +1 -1
  1277. package/dist/core/skills-async.d.ts.map +1 -1
  1278. package/dist/core/skills-async.js +18 -8
  1279. package/dist/core/skills-async.js.map +1 -1
  1280. package/dist/core/slash-commands.d.ts +1 -0
  1281. package/dist/core/slash-commands.d.ts.map +1 -1
  1282. package/dist/core/slash-commands.js +127 -24
  1283. package/dist/core/slash-commands.js.map +1 -1
  1284. package/dist/core/source-info.d.ts +3 -1
  1285. package/dist/core/source-info.d.ts.map +1 -1
  1286. package/dist/core/source-info.js +2 -0
  1287. package/dist/core/source-info.js.map +1 -1
  1288. package/dist/core/summarization-retry.d.ts +11 -0
  1289. package/dist/core/summarization-retry.d.ts.map +1 -0
  1290. package/dist/core/summarization-retry.js +21 -0
  1291. package/dist/core/summarization-retry.js.map +1 -0
  1292. package/dist/core/system-prompt.d.ts.map +1 -1
  1293. package/dist/core/system-prompt.js +15 -18
  1294. package/dist/core/system-prompt.js.map +1 -1
  1295. package/dist/core/thinking-blocks.d.ts.map +1 -1
  1296. package/dist/core/thinking-blocks.js +2 -2
  1297. package/dist/core/thinking-blocks.js.map +1 -1
  1298. package/dist/core/tools/artifact-protocol.d.ts.map +1 -1
  1299. package/dist/core/tools/artifact-protocol.js.map +1 -1
  1300. package/dist/core/tools/artifacts.d.ts.map +1 -1
  1301. package/dist/core/tools/artifacts.js.map +1 -1
  1302. package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -1
  1303. package/dist/core/tools/ask-user-question/ask-user-question.js +1 -1
  1304. package/dist/core/tools/ask-user-question/ask-user-question.js.map +1 -1
  1305. package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts +1 -1
  1306. package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts.map +1 -1
  1307. package/dist/core/tools/ask-user-question/state/build-questionnaire.js +1 -1
  1308. package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -1
  1309. package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts.map +1 -1
  1310. package/dist/core/tools/ask-user-question/state/questionnaire-session.js +2 -4
  1311. package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
  1312. package/dist/core/tools/ask-user-question/state/state-reducer.d.ts.map +1 -1
  1313. package/dist/core/tools/ask-user-question/state/state-reducer.js.map +1 -1
  1314. package/dist/core/tools/ask-user-question/view/body-residual-spacer.d.ts.map +1 -1
  1315. package/dist/core/tools/ask-user-question/view/body-residual-spacer.js.map +1 -1
  1316. package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts.map +1 -1
  1317. package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
  1318. package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.d.ts +1 -1
  1319. package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.d.ts.map +1 -1
  1320. package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.js.map +1 -1
  1321. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts +1 -1
  1322. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts.map +1 -1
  1323. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js +1 -3
  1324. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -1
  1325. package/dist/core/tools/ask-user-question/view/components/submit-picker.d.ts.map +1 -1
  1326. package/dist/core/tools/ask-user-question/view/components/submit-picker.js.map +1 -1
  1327. package/dist/core/tools/ask-user-question/view/components/tab-bar.d.ts.map +1 -1
  1328. package/dist/core/tools/ask-user-question/view/components/tab-bar.js.map +1 -1
  1329. package/dist/core/tools/ask-user-question/view/dialog-builder.d.ts +1 -1
  1330. package/dist/core/tools/ask-user-question/view/dialog-builder.d.ts.map +1 -1
  1331. package/dist/core/tools/ask-user-question/view/dialog-builder.js +1 -1
  1332. package/dist/core/tools/ask-user-question/view/dialog-builder.js.map +1 -1
  1333. package/dist/core/tools/ask-user-question/view/props-adapter.d.ts.map +1 -1
  1334. package/dist/core/tools/ask-user-question/view/props-adapter.js +2 -4
  1335. package/dist/core/tools/ask-user-question/view/props-adapter.js.map +1 -1
  1336. package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts +1 -1
  1337. package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts.map +1 -1
  1338. package/dist/core/tools/ask-user-question/view/tab-content-strategy.js +2 -9
  1339. package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -1
  1340. package/dist/core/tools/bash-async-execution.d.ts.map +1 -1
  1341. package/dist/core/tools/bash-async-execution.js +11 -4
  1342. package/dist/core/tools/bash-async-execution.js.map +1 -1
  1343. package/dist/core/tools/bash-async-jobs.d.ts.map +1 -1
  1344. package/dist/core/tools/bash-async-jobs.js +14 -2
  1345. package/dist/core/tools/bash-async-jobs.js.map +1 -1
  1346. package/dist/core/tools/bash-async-output.d.ts.map +1 -1
  1347. package/dist/core/tools/bash-async-output.js +6 -2
  1348. package/dist/core/tools/bash-async-output.js.map +1 -1
  1349. package/dist/core/tools/bash-interceptor.d.ts.map +1 -1
  1350. package/dist/core/tools/bash-interceptor.js +20 -4
  1351. package/dist/core/tools/bash-interceptor.js.map +1 -1
  1352. package/dist/core/tools/bash-leading-cd.d.ts.map +1 -1
  1353. package/dist/core/tools/bash-leading-cd.js +9 -3
  1354. package/dist/core/tools/bash-leading-cd.js.map +1 -1
  1355. package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
  1356. package/dist/core/tools/bash-pty-native.js.map +1 -1
  1357. package/dist/core/tools/bash-session-environment.d.ts +13 -0
  1358. package/dist/core/tools/bash-session-environment.d.ts.map +1 -0
  1359. package/dist/core/tools/bash-session-environment.js +47 -0
  1360. package/dist/core/tools/bash-session-environment.js.map +1 -0
  1361. package/dist/core/tools/bash.d.ts +4 -1
  1362. package/dist/core/tools/bash.d.ts.map +1 -1
  1363. package/dist/core/tools/bash.js +134 -30
  1364. package/dist/core/tools/bash.js.map +1 -1
  1365. package/dist/core/tools/block-resolver.d.ts.map +1 -1
  1366. package/dist/core/tools/block-resolver.js.map +1 -1
  1367. package/dist/core/tools/conflict-registry.d.ts.map +1 -1
  1368. package/dist/core/tools/conflict-registry.js.map +1 -1
  1369. package/dist/core/tools/directory-tree.d.ts.map +1 -1
  1370. package/dist/core/tools/directory-tree.js +20 -4
  1371. package/dist/core/tools/directory-tree.js.map +1 -1
  1372. package/dist/core/tools/edit.d.ts.map +1 -1
  1373. package/dist/core/tools/edit.js +37 -13
  1374. package/dist/core/tools/edit.js.map +1 -1
  1375. package/dist/core/tools/fetch-url.d.ts.map +1 -1
  1376. package/dist/core/tools/fetch-url.js +127 -41
  1377. package/dist/core/tools/fetch-url.js.map +1 -1
  1378. package/dist/core/tools/find.d.ts.map +1 -1
  1379. package/dist/core/tools/find.js +176 -46
  1380. package/dist/core/tools/find.js.map +1 -1
  1381. package/dist/core/tools/grep.d.ts.map +1 -1
  1382. package/dist/core/tools/grep.js +43 -10
  1383. package/dist/core/tools/grep.js.map +1 -1
  1384. package/dist/core/tools/hashline-engine/apply.d.ts.map +1 -1
  1385. package/dist/core/tools/hashline-engine/apply.js +6 -6
  1386. package/dist/core/tools/hashline-engine/apply.js.map +1 -1
  1387. package/dist/core/tools/hashline-engine/block.js +1 -1
  1388. package/dist/core/tools/hashline-engine/block.js.map +1 -1
  1389. package/dist/core/tools/hashline-engine/format.d.ts.map +1 -1
  1390. package/dist/core/tools/hashline-engine/format.js +1 -1
  1391. package/dist/core/tools/hashline-engine/format.js.map +1 -1
  1392. package/dist/core/tools/hashline-engine/input.d.ts.map +1 -1
  1393. package/dist/core/tools/hashline-engine/input.js +7 -7
  1394. package/dist/core/tools/hashline-engine/input.js.map +1 -1
  1395. package/dist/core/tools/hashline-engine/parser.js +1 -1
  1396. package/dist/core/tools/hashline-engine/parser.js.map +1 -1
  1397. package/dist/core/tools/hashline-engine/patcher.js +5 -5
  1398. package/dist/core/tools/hashline-engine/patcher.js.map +1 -1
  1399. package/dist/core/tools/hashline-engine/prefixes.js +4 -4
  1400. package/dist/core/tools/hashline-engine/prefixes.js.map +1 -1
  1401. package/dist/core/tools/hashline-engine/recovery.d.ts.map +1 -1
  1402. package/dist/core/tools/hashline-engine/recovery.js +4 -2
  1403. package/dist/core/tools/hashline-engine/recovery.js.map +1 -1
  1404. package/dist/core/tools/hashline-engine/snapshots.js +5 -5
  1405. package/dist/core/tools/hashline-engine/snapshots.js.map +1 -1
  1406. package/dist/core/tools/hashline.d.ts.map +1 -1
  1407. package/dist/core/tools/hashline.js +24 -13
  1408. package/dist/core/tools/hashline.js.map +1 -1
  1409. package/dist/core/tools/index.d.ts +6 -6
  1410. package/dist/core/tools/index.d.ts.map +1 -1
  1411. package/dist/core/tools/index.js +6 -6
  1412. package/dist/core/tools/index.js.map +1 -1
  1413. package/dist/core/tools/ls.d.ts.map +1 -1
  1414. package/dist/core/tools/ls.js +2 -1
  1415. package/dist/core/tools/ls.js.map +1 -1
  1416. package/dist/core/tools/notebook.d.ts.map +1 -1
  1417. package/dist/core/tools/notebook.js +13 -3
  1418. package/dist/core/tools/notebook.js.map +1 -1
  1419. package/dist/core/tools/read-document-extract.d.ts.map +1 -1
  1420. package/dist/core/tools/read-document-extract.js +30 -10
  1421. package/dist/core/tools/read-document-extract.js.map +1 -1
  1422. package/dist/core/tools/read-selectors.d.ts.map +1 -1
  1423. package/dist/core/tools/read-selectors.js +59 -15
  1424. package/dist/core/tools/read-selectors.js.map +1 -1
  1425. package/dist/core/tools/read-url.d.ts.map +1 -1
  1426. package/dist/core/tools/read-url.js +41 -7
  1427. package/dist/core/tools/read-url.js.map +1 -1
  1428. package/dist/core/tools/read.d.ts.map +1 -1
  1429. package/dist/core/tools/read.js +307 -72
  1430. package/dist/core/tools/read.js.map +1 -1
  1431. package/dist/core/tools/resource-selectors.d.ts +4 -0
  1432. package/dist/core/tools/resource-selectors.d.ts.map +1 -1
  1433. package/dist/core/tools/resource-selectors.js +324 -84
  1434. package/dist/core/tools/resource-selectors.js.map +1 -1
  1435. package/dist/core/tools/search-details.d.ts.map +1 -1
  1436. package/dist/core/tools/search-details.js +13 -1
  1437. package/dist/core/tools/search-details.js.map +1 -1
  1438. package/dist/core/tools/search-line-ranges.d.ts.map +1 -1
  1439. package/dist/core/tools/search-line-ranges.js +5 -2
  1440. package/dist/core/tools/search-line-ranges.js.map +1 -1
  1441. package/dist/core/tools/search-native.d.ts.map +1 -1
  1442. package/dist/core/tools/search-native.js.map +1 -1
  1443. package/dist/core/tools/search.d.ts.map +1 -1
  1444. package/dist/core/tools/search.js +244 -90
  1445. package/dist/core/tools/search.js.map +1 -1
  1446. package/dist/core/tools/structured-output.d.ts +1 -1
  1447. package/dist/core/tools/structured-output.d.ts.map +1 -1
  1448. package/dist/core/tools/structured-output.js.map +1 -1
  1449. package/dist/core/tools/todos-execute.d.ts.map +1 -1
  1450. package/dist/core/tools/todos-execute.js +4 -4
  1451. package/dist/core/tools/todos-execute.js.map +1 -1
  1452. package/dist/core/tools/todos-locks.d.ts.map +1 -1
  1453. package/dist/core/tools/todos-locks.js.map +1 -1
  1454. package/dist/core/tools/todos-mutations.js +1 -1
  1455. package/dist/core/tools/todos-mutations.js.map +1 -1
  1456. package/dist/core/tools/todos-paths.js +2 -2
  1457. package/dist/core/tools/todos-paths.js.map +1 -1
  1458. package/dist/core/tools/todos-render.d.ts.map +1 -1
  1459. package/dist/core/tools/todos-render.js +2 -2
  1460. package/dist/core/tools/todos-render.js.map +1 -1
  1461. package/dist/core/tools/todos-storage.d.ts.map +1 -1
  1462. package/dist/core/tools/todos-storage.js +1 -2
  1463. package/dist/core/tools/todos-storage.js.map +1 -1
  1464. package/dist/core/tools/todos-types.d.ts.map +1 -1
  1465. package/dist/core/tools/todos-types.js +1 -11
  1466. package/dist/core/tools/todos-types.js.map +1 -1
  1467. package/dist/core/tools/tool-definition-wrapper.d.ts +3 -0
  1468. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  1469. package/dist/core/tools/tool-definition-wrapper.js +9 -5
  1470. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  1471. package/dist/core/tools/url-ip-guards.d.ts.map +1 -1
  1472. package/dist/core/tools/url-ip-guards.js +27 -17
  1473. package/dist/core/tools/url-ip-guards.js.map +1 -1
  1474. package/dist/core/tools/write.d.ts.map +1 -1
  1475. package/dist/core/tools/write.js +88 -29
  1476. package/dist/core/tools/write.js.map +1 -1
  1477. package/dist/core/usage-totals.d.ts +18 -0
  1478. package/dist/core/usage-totals.d.ts.map +1 -0
  1479. package/dist/core/usage-totals.js +43 -0
  1480. package/dist/core/usage-totals.js.map +1 -0
  1481. package/dist/core/workflow-stage-admission.d.ts.map +1 -1
  1482. package/dist/core/workflow-stage-admission.js +8 -2
  1483. package/dist/core/workflow-stage-admission.js.map +1 -1
  1484. package/dist/extensions/index.d.ts +3 -0
  1485. package/dist/extensions/index.d.ts.map +1 -0
  1486. package/dist/extensions/index.js +5 -0
  1487. package/dist/extensions/index.js.map +1 -0
  1488. package/dist/extensions/llama/client.d.ts +61 -0
  1489. package/dist/extensions/llama/client.d.ts.map +1 -0
  1490. package/dist/extensions/llama/client.js +300 -0
  1491. package/dist/extensions/llama/client.js.map +1 -0
  1492. package/dist/extensions/llama/huggingface-ui.d.ts +33 -0
  1493. package/dist/extensions/llama/huggingface-ui.d.ts.map +1 -0
  1494. package/dist/extensions/llama/huggingface-ui.js +166 -0
  1495. package/dist/extensions/llama/huggingface-ui.js.map +1 -0
  1496. package/dist/extensions/llama/huggingface.d.ts +23 -0
  1497. package/dist/extensions/llama/huggingface.d.ts.map +1 -0
  1498. package/dist/extensions/llama/huggingface.js +139 -0
  1499. package/dist/extensions/llama/huggingface.js.map +1 -0
  1500. package/dist/extensions/llama/index.d.ts +3 -0
  1501. package/dist/extensions/llama/index.d.ts.map +1 -0
  1502. package/dist/extensions/llama/index.js +208 -0
  1503. package/dist/extensions/llama/index.js.map +1 -0
  1504. package/dist/extensions/llama/provider.d.ts +10 -0
  1505. package/dist/extensions/llama/provider.d.ts.map +1 -0
  1506. package/dist/extensions/llama/provider.js +107 -0
  1507. package/dist/extensions/llama/provider.js.map +1 -0
  1508. package/dist/extensions/llama/ui.d.ts +42 -0
  1509. package/dist/extensions/llama/ui.d.ts.map +1 -0
  1510. package/dist/extensions/llama/ui.js +237 -0
  1511. package/dist/extensions/llama/ui.js.map +1 -0
  1512. package/dist/index-extensions.d.ts +2 -2
  1513. package/dist/index-extensions.d.ts.map +1 -1
  1514. package/dist/index-extensions.js +1 -1
  1515. package/dist/index-extensions.js.map +1 -1
  1516. package/dist/index.d.ts +22 -23
  1517. package/dist/index.d.ts.map +1 -1
  1518. package/dist/index.js +26 -27
  1519. package/dist/index.js.map +1 -1
  1520. package/dist/main-app-mode.d.ts +1 -0
  1521. package/dist/main-app-mode.d.ts.map +1 -1
  1522. package/dist/main-app-mode.js +3 -0
  1523. package/dist/main-app-mode.js.map +1 -1
  1524. package/dist/main-deferred-startup.d.ts +1 -1
  1525. package/dist/main-deferred-startup.d.ts.map +1 -1
  1526. package/dist/main-deferred-startup.js +16 -15
  1527. package/dist/main-deferred-startup.js.map +1 -1
  1528. package/dist/main-early-input.js.map +1 -1
  1529. package/dist/main-first-time-setup.d.ts +6 -0
  1530. package/dist/main-first-time-setup.d.ts.map +1 -0
  1531. package/dist/main-first-time-setup.js +10 -0
  1532. package/dist/main-first-time-setup.js.map +1 -0
  1533. package/dist/main-runtime-api-key.d.ts +6 -0
  1534. package/dist/main-runtime-api-key.d.ts.map +1 -0
  1535. package/dist/main-runtime-api-key.js +6 -0
  1536. package/dist/main-runtime-api-key.js.map +1 -0
  1537. package/dist/main-session-options.d.ts +2 -2
  1538. package/dist/main-session-options.d.ts.map +1 -1
  1539. package/dist/main-session-options.js +3 -7
  1540. package/dist/main-session-options.js.map +1 -1
  1541. package/dist/main-session.d.ts.map +1 -1
  1542. package/dist/main-session.js +5 -4
  1543. package/dist/main-session.js.map +1 -1
  1544. package/dist/main-types.d.ts +2 -2
  1545. package/dist/main-types.d.ts.map +1 -1
  1546. package/dist/main-types.js.map +1 -1
  1547. package/dist/main.d.ts +1 -1
  1548. package/dist/main.d.ts.map +1 -1
  1549. package/dist/main.js +173 -69
  1550. package/dist/main.js.map +1 -1
  1551. package/dist/migrations-config-values.d.ts.map +1 -1
  1552. package/dist/migrations-config-values.js +3 -1
  1553. package/dist/migrations-config-values.js.map +1 -1
  1554. package/dist/migrations.d.ts.map +1 -1
  1555. package/dist/migrations.js.map +1 -1
  1556. package/dist/modes/index.d.ts +1 -1
  1557. package/dist/modes/index.d.ts.map +1 -1
  1558. package/dist/modes/index.js.map +1 -1
  1559. package/dist/modes/interactive/chat-input-actions.d.ts +1 -1
  1560. package/dist/modes/interactive/chat-input-actions.d.ts.map +1 -1
  1561. package/dist/modes/interactive/chat-input-actions.js +30 -103
  1562. package/dist/modes/interactive/chat-input-actions.js.map +1 -1
  1563. package/dist/modes/interactive/components/atomic-banner.d.ts +9 -8
  1564. package/dist/modes/interactive/components/atomic-banner.d.ts.map +1 -1
  1565. package/dist/modes/interactive/components/atomic-banner.js +68 -22
  1566. package/dist/modes/interactive/components/atomic-banner.js.map +1 -1
  1567. package/dist/modes/interactive/components/atomic-working-status.d.ts +52 -0
  1568. package/dist/modes/interactive/components/atomic-working-status.d.ts.map +1 -0
  1569. package/dist/modes/interactive/components/atomic-working-status.js +215 -0
  1570. package/dist/modes/interactive/components/atomic-working-status.js.map +1 -0
  1571. package/dist/modes/interactive/components/chat-message-renderer.d.ts +1 -1
  1572. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  1573. package/dist/modes/interactive/components/chat-message-renderer.js +7 -6
  1574. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  1575. package/dist/modes/interactive/components/chat-session-host-actions.d.ts +3 -2
  1576. package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
  1577. package/dist/modes/interactive/components/chat-session-host-actions.js +93 -17
  1578. package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
  1579. package/dist/modes/interactive/components/chat-session-host-editor.d.ts +4 -4
  1580. package/dist/modes/interactive/components/chat-session-host-editor.d.ts.map +1 -1
  1581. package/dist/modes/interactive/components/chat-session-host-editor.js +12 -7
  1582. package/dist/modes/interactive/components/chat-session-host-editor.js.map +1 -1
  1583. package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
  1584. package/dist/modes/interactive/components/chat-session-host-events.js +84 -15
  1585. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  1586. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts +1 -1
  1587. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
  1588. package/dist/modes/interactive/components/chat-session-host-rendering.js +49 -14
  1589. package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
  1590. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts +36 -2
  1591. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -1
  1592. package/dist/modes/interactive/components/chat-session-host-runtime.js +129 -25
  1593. package/dist/modes/interactive/components/chat-session-host-runtime.js.map +1 -1
  1594. package/dist/modes/interactive/components/chat-session-host-state.d.ts +11 -2
  1595. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  1596. package/dist/modes/interactive/components/chat-session-host-state.js +5 -0
  1597. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  1598. package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.d.ts.map +1 -1
  1599. package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.js.map +1 -1
  1600. package/dist/modes/interactive/components/chat-session-host-types.d.ts +19 -2
  1601. package/dist/modes/interactive/components/chat-session-host-types.d.ts.map +1 -1
  1602. package/dist/modes/interactive/components/chat-session-host-types.js.map +1 -1
  1603. package/dist/modes/interactive/components/chat-session-host-utils.d.ts +1 -1
  1604. package/dist/modes/interactive/components/chat-session-host-utils.d.ts.map +1 -1
  1605. package/dist/modes/interactive/components/chat-session-host-utils.js +3 -8
  1606. package/dist/modes/interactive/components/chat-session-host-utils.js.map +1 -1
  1607. package/dist/modes/interactive/components/chat-session-host.d.ts +17 -4
  1608. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  1609. package/dist/modes/interactive/components/chat-session-host.js +26 -3
  1610. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  1611. package/dist/modes/interactive/components/chat-transcript.d.ts +1 -1
  1612. package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
  1613. package/dist/modes/interactive/components/chat-transcript.js +5 -12
  1614. package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
  1615. package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
  1616. package/dist/modes/interactive/components/compaction-boundary-message.js +20 -8
  1617. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
  1618. package/dist/modes/interactive/components/config-selector-list.d.ts +6 -6
  1619. package/dist/modes/interactive/components/config-selector-list.d.ts.map +1 -1
  1620. package/dist/modes/interactive/components/config-selector-list.js +66 -125
  1621. package/dist/modes/interactive/components/config-selector-list.js.map +1 -1
  1622. package/dist/modes/interactive/components/config-selector-project-scope.d.ts +4 -0
  1623. package/dist/modes/interactive/components/config-selector-project-scope.d.ts.map +1 -0
  1624. package/dist/modes/interactive/components/config-selector-project-scope.js +59 -0
  1625. package/dist/modes/interactive/components/config-selector-project-scope.js.map +1 -0
  1626. package/dist/modes/interactive/components/config-selector.d.ts +8 -5
  1627. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  1628. package/dist/modes/interactive/components/config-selector.js +46 -13
  1629. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  1630. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
  1631. package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
  1632. package/dist/modes/interactive/components/custom-editor.d.ts +11 -0
  1633. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  1634. package/dist/modes/interactive/components/custom-editor.js +21 -5
  1635. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  1636. package/dist/modes/interactive/components/custom-entry.d.ts +16 -0
  1637. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -0
  1638. package/dist/modes/interactive/components/custom-entry.js +45 -0
  1639. package/dist/modes/interactive/components/custom-entry.js.map +1 -0
  1640. package/dist/modes/interactive/components/custom-message.d.ts +3 -1
  1641. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  1642. package/dist/modes/interactive/components/custom-message.js +10 -5
  1643. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  1644. package/dist/modes/interactive/components/diff.js +2 -2
  1645. package/dist/modes/interactive/components/diff.js.map +1 -1
  1646. package/dist/modes/interactive/components/extension-editor.d.ts +3 -2
  1647. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  1648. package/dist/modes/interactive/components/extension-editor.js +14 -43
  1649. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  1650. package/dist/modes/interactive/components/first-time-setup.d.ts +24 -0
  1651. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -0
  1652. package/dist/modes/interactive/components/first-time-setup.js +80 -0
  1653. package/dist/modes/interactive/components/first-time-setup.js.map +1 -0
  1654. package/dist/modes/interactive/components/footer.d.ts +7 -1
  1655. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  1656. package/dist/modes/interactive/components/footer.js +68 -39
  1657. package/dist/modes/interactive/components/footer.js.map +1 -1
  1658. package/dist/modes/interactive/components/host-input-form-mount.d.ts.map +1 -1
  1659. package/dist/modes/interactive/components/host-input-form-mount.js +4 -2
  1660. package/dist/modes/interactive/components/host-input-form-mount.js.map +1 -1
  1661. package/dist/modes/interactive/components/host-input-form.d.ts +2 -0
  1662. package/dist/modes/interactive/components/host-input-form.d.ts.map +1 -1
  1663. package/dist/modes/interactive/components/host-input-form.js +61 -24
  1664. package/dist/modes/interactive/components/host-input-form.js.map +1 -1
  1665. package/dist/modes/interactive/components/host-session-picker.d.ts.map +1 -1
  1666. package/dist/modes/interactive/components/host-session-picker.js +8 -3
  1667. package/dist/modes/interactive/components/host-session-picker.js.map +1 -1
  1668. package/dist/modes/interactive/components/idle-status.d.ts +8 -0
  1669. package/dist/modes/interactive/components/idle-status.d.ts.map +1 -0
  1670. package/dist/modes/interactive/components/idle-status.js +13 -0
  1671. package/dist/modes/interactive/components/idle-status.js.map +1 -0
  1672. package/dist/modes/interactive/components/index.d.ts +8 -5
  1673. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  1674. package/dist/modes/interactive/components/index.js +5 -2
  1675. package/dist/modes/interactive/components/index.js.map +1 -1
  1676. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  1677. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  1678. package/dist/modes/interactive/components/login-dialog.d.ts +5 -5
  1679. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  1680. package/dist/modes/interactive/components/login-dialog.js +15 -9
  1681. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  1682. package/dist/modes/interactive/components/model-selector.d.ts +4 -3
  1683. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  1684. package/dist/modes/interactive/components/model-selector.js +70 -72
  1685. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  1686. package/dist/modes/interactive/components/oauth-selector.d.ts +4 -3
  1687. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  1688. package/dist/modes/interactive/components/oauth-selector.js +19 -18
  1689. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  1690. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  1691. package/dist/modes/interactive/components/scoped-models-selector.js +22 -13
  1692. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  1693. package/dist/modes/interactive/components/session-selector-list.d.ts +1 -1
  1694. package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
  1695. package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
  1696. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  1697. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  1698. package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
  1699. package/dist/modes/interactive/components/settings-selector-handlers.js +6 -0
  1700. package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
  1701. package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
  1702. package/dist/modes/interactive/components/settings-selector-items.js +14 -0
  1703. package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
  1704. package/dist/modes/interactive/components/settings-selector-submenus.d.ts.map +1 -1
  1705. package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
  1706. package/dist/modes/interactive/components/settings-selector-types.d.ts +4 -0
  1707. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  1708. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  1709. package/dist/modes/interactive/components/startup-identity.d.ts +22 -0
  1710. package/dist/modes/interactive/components/startup-identity.d.ts.map +1 -0
  1711. package/dist/modes/interactive/components/startup-identity.js +58 -0
  1712. package/dist/modes/interactive/components/startup-identity.js.map +1 -0
  1713. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  1714. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  1715. package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
  1716. package/dist/modes/interactive/components/tree-selector-content.js +0 -6
  1717. package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
  1718. package/dist/modes/interactive/components/tree-selector-model.d.ts.map +1 -1
  1719. package/dist/modes/interactive/components/tree-selector-model.js +1 -10
  1720. package/dist/modes/interactive/components/tree-selector-model.js.map +1 -1
  1721. package/dist/modes/interactive/components/tree-selector-viewport.d.ts.map +1 -1
  1722. package/dist/modes/interactive/components/tree-selector-viewport.js.map +1 -1
  1723. package/dist/modes/interactive/components/working-status.d.ts +5 -11
  1724. package/dist/modes/interactive/components/working-status.d.ts.map +1 -1
  1725. package/dist/modes/interactive/components/working-status.js +14 -15
  1726. package/dist/modes/interactive/components/working-status.js.map +1 -1
  1727. package/dist/modes/interactive/external-editor.d.ts +23 -0
  1728. package/dist/modes/interactive/external-editor.d.ts.map +1 -0
  1729. package/dist/modes/interactive/external-editor.js +120 -0
  1730. package/dist/modes/interactive/external-editor.js.map +1 -0
  1731. package/dist/modes/interactive/interactive-agent-events.js +73 -28
  1732. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  1733. package/dist/modes/interactive/interactive-auth-login.js +36 -28
  1734. package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
  1735. package/dist/modes/interactive/interactive-auth-routing.d.ts +4 -1
  1736. package/dist/modes/interactive/interactive-auth-routing.d.ts.map +1 -1
  1737. package/dist/modes/interactive/interactive-auth-routing.js +92 -65
  1738. package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
  1739. package/dist/modes/interactive/interactive-autocomplete.js +24 -14
  1740. package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
  1741. package/dist/modes/interactive/interactive-bash-compact.d.ts +2 -1
  1742. package/dist/modes/interactive/interactive-bash-compact.d.ts.map +1 -1
  1743. package/dist/modes/interactive/interactive-bash-compact.js +26 -8
  1744. package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
  1745. package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
  1746. package/dist/modes/interactive/interactive-deferred-startup.js +61 -27
  1747. package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
  1748. package/dist/modes/interactive/interactive-editor-actions.js +9 -13
  1749. package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
  1750. package/dist/modes/interactive/interactive-extension-context.js +4 -4
  1751. package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
  1752. package/dist/modes/interactive/interactive-extension-custom-ui.js +15 -8
  1753. package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
  1754. package/dist/modes/interactive/interactive-extension-dialogs.js +51 -25
  1755. package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
  1756. package/dist/modes/interactive/interactive-extension-runtime.js +15 -6
  1757. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  1758. package/dist/modes/interactive/interactive-extension-widgets.js +1 -1
  1759. package/dist/modes/interactive/interactive-extension-widgets.js.map +1 -1
  1760. package/dist/modes/interactive/interactive-global-clear.d.ts +55 -3
  1761. package/dist/modes/interactive/interactive-global-clear.d.ts.map +1 -1
  1762. package/dist/modes/interactive/interactive-global-clear.js +61 -3
  1763. package/dist/modes/interactive/interactive-global-clear.js.map +1 -1
  1764. package/dist/modes/interactive/interactive-hotkeys-debug.js +2 -3
  1765. package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -1
  1766. package/dist/modes/interactive/interactive-initial-session-binding.d.ts +4 -0
  1767. package/dist/modes/interactive/interactive-initial-session-binding.d.ts.map +1 -0
  1768. package/dist/modes/interactive/interactive-initial-session-binding.js +23 -0
  1769. package/dist/modes/interactive/interactive-initial-session-binding.js.map +1 -0
  1770. package/dist/modes/interactive/interactive-input-handling.d.ts +2 -1
  1771. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  1772. package/dist/modes/interactive/interactive-input-handling.js +82 -69
  1773. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  1774. package/dist/modes/interactive/interactive-key-identity.d.ts +22 -0
  1775. package/dist/modes/interactive/interactive-key-identity.d.ts.map +1 -0
  1776. package/dist/modes/interactive/interactive-key-identity.js +29 -0
  1777. package/dist/modes/interactive/interactive-key-identity.js.map +1 -0
  1778. package/dist/modes/interactive/interactive-mode-base.d.ts +18 -13
  1779. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  1780. package/dist/modes/interactive/interactive-mode-base.js +26 -18
  1781. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  1782. package/dist/modes/interactive/interactive-mode-deps.d.ts +20 -22
  1783. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  1784. package/dist/modes/interactive/interactive-mode-deps.js +16 -18
  1785. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  1786. package/dist/modes/interactive/interactive-mode-helpers.d.ts +3 -2
  1787. package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
  1788. package/dist/modes/interactive/interactive-mode-helpers.js +8 -18
  1789. package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
  1790. package/dist/modes/interactive/interactive-mode-surface.d.ts +28 -17
  1791. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  1792. package/dist/modes/interactive/interactive-mode-surface.js +1 -0
  1793. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  1794. package/dist/modes/interactive/interactive-mode-types.d.ts +2 -2
  1795. package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -1
  1796. package/dist/modes/interactive/interactive-mode-types.js.map +1 -1
  1797. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  1798. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  1799. package/dist/modes/interactive/interactive-mode.js +1 -0
  1800. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  1801. package/dist/modes/interactive/interactive-model-catalog-startup.d.ts +12 -0
  1802. package/dist/modes/interactive/interactive-model-catalog-startup.d.ts.map +1 -0
  1803. package/dist/modes/interactive/interactive-model-catalog-startup.js +22 -0
  1804. package/dist/modes/interactive/interactive-model-catalog-startup.js.map +1 -0
  1805. package/dist/modes/interactive/interactive-model-routing.js +41 -111
  1806. package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
  1807. package/dist/modes/interactive/interactive-onboarding.js +7 -7
  1808. package/dist/modes/interactive/interactive-onboarding.js.map +1 -1
  1809. package/dist/modes/interactive/interactive-pause.d.ts +4 -0
  1810. package/dist/modes/interactive/interactive-pause.d.ts.map +1 -0
  1811. package/dist/modes/interactive/interactive-pause.js +8 -0
  1812. package/dist/modes/interactive/interactive-pause.js.map +1 -0
  1813. package/dist/modes/interactive/interactive-process-lifecycle.js +43 -12
  1814. package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
  1815. package/dist/modes/interactive/interactive-prompt-restore.d.ts +58 -0
  1816. package/dist/modes/interactive/interactive-prompt-restore.d.ts.map +1 -0
  1817. package/dist/modes/interactive/interactive-prompt-restore.js +87 -0
  1818. package/dist/modes/interactive/interactive-prompt-restore.js.map +1 -0
  1819. package/dist/modes/interactive/interactive-prompt-turn.d.ts +2 -0
  1820. package/dist/modes/interactive/interactive-prompt-turn.d.ts.map +1 -0
  1821. package/dist/modes/interactive/interactive-prompt-turn.js +56 -0
  1822. package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -0
  1823. package/dist/modes/interactive/interactive-queueing.js +6 -9
  1824. package/dist/modes/interactive/interactive-queueing.js.map +1 -1
  1825. package/dist/modes/interactive/interactive-render-chat.js +128 -48
  1826. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  1827. package/dist/modes/interactive/interactive-resource-disclosure.js +1 -3
  1828. package/dist/modes/interactive/interactive-resource-disclosure.js.map +1 -1
  1829. package/dist/modes/interactive/interactive-resource-paths.js +17 -21
  1830. package/dist/modes/interactive/interactive-resource-paths.js.map +1 -1
  1831. package/dist/modes/interactive/interactive-resource-rendering.js +110 -12
  1832. package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
  1833. package/dist/modes/interactive/interactive-selectors.js +13 -5
  1834. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  1835. package/dist/modes/interactive/interactive-session-routing.js +19 -4
  1836. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  1837. package/dist/modes/interactive/interactive-session-runtime.js +12 -1
  1838. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  1839. package/dist/modes/interactive/interactive-slash-commands.js +23 -4
  1840. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  1841. package/dist/modes/interactive/interactive-startup-chat-container.d.ts +20 -0
  1842. package/dist/modes/interactive/interactive-startup-chat-container.d.ts.map +1 -0
  1843. package/dist/modes/interactive/interactive-startup-chat-container.js +26 -0
  1844. package/dist/modes/interactive/interactive-startup-chat-container.js.map +1 -0
  1845. package/dist/modes/interactive/interactive-startup.d.ts +1 -1
  1846. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  1847. package/dist/modes/interactive/interactive-startup.js +37 -37
  1848. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  1849. package/dist/modes/interactive/interactive-submission.d.ts +24 -0
  1850. package/dist/modes/interactive/interactive-submission.d.ts.map +1 -0
  1851. package/dist/modes/interactive/interactive-submission.js +10 -0
  1852. package/dist/modes/interactive/interactive-submission.js.map +1 -0
  1853. package/dist/modes/interactive/interactive-summarization-retry-events.d.ts +8 -0
  1854. package/dist/modes/interactive/interactive-summarization-retry-events.d.ts.map +1 -0
  1855. package/dist/modes/interactive/interactive-summarization-retry-events.js +48 -0
  1856. package/dist/modes/interactive/interactive-summarization-retry-events.js.map +1 -0
  1857. package/dist/modes/interactive/login-provider-options.d.ts +21 -0
  1858. package/dist/modes/interactive/login-provider-options.d.ts.map +1 -0
  1859. package/dist/modes/interactive/login-provider-options.js +50 -0
  1860. package/dist/modes/interactive/login-provider-options.js.map +1 -0
  1861. package/dist/modes/interactive/theme/catppuccin-frappe.json +1 -1
  1862. package/dist/modes/interactive/theme/catppuccin-latte.json +1 -1
  1863. package/dist/modes/interactive/theme/catppuccin-macchiato.json +1 -1
  1864. package/dist/modes/interactive/theme/catppuccin-mocha.json +9 -1
  1865. package/dist/modes/interactive/theme/dark.json +1 -1
  1866. package/dist/modes/interactive/theme/global-theme.d.ts +1 -1
  1867. package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -1
  1868. package/dist/modes/interactive/theme/global-theme.js.map +1 -1
  1869. package/dist/modes/interactive/theme/light.json +1 -1
  1870. package/dist/modes/interactive/theme/theme-class.d.ts +4 -0
  1871. package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
  1872. package/dist/modes/interactive/theme/theme-class.js +7 -0
  1873. package/dist/modes/interactive/theme/theme-class.js.map +1 -1
  1874. package/dist/modes/interactive/theme/theme-loading.d.ts.map +1 -1
  1875. package/dist/modes/interactive/theme/theme-loading.js +5 -1
  1876. package/dist/modes/interactive/theme/theme-loading.js.map +1 -1
  1877. package/dist/modes/interactive/theme/theme-schema.d.ts +32 -0
  1878. package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -1
  1879. package/dist/modes/interactive/theme/theme-schema.js +8 -0
  1880. package/dist/modes/interactive/theme/theme-schema.js.map +1 -1
  1881. package/dist/modes/interactive/theme/theme-schema.json +15 -2
  1882. package/dist/modes/interactive/theme/theme.d.ts +2 -2
  1883. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  1884. package/dist/modes/interactive/theme/theme.js +2 -2
  1885. package/dist/modes/interactive/theme/theme.js.map +1 -1
  1886. package/dist/modes/interactive/whimsical-messages.d.ts +1 -0
  1887. package/dist/modes/interactive/whimsical-messages.d.ts.map +1 -1
  1888. package/dist/modes/interactive/whimsical-messages.js +2 -2
  1889. package/dist/modes/interactive/whimsical-messages.js.map +1 -1
  1890. package/dist/modes/interactive-engine/activity-watchdog.d.ts +16 -6
  1891. package/dist/modes/interactive-engine/activity-watchdog.d.ts.map +1 -1
  1892. package/dist/modes/interactive-engine/activity-watchdog.js +12 -6
  1893. package/dist/modes/interactive-engine/activity-watchdog.js.map +1 -1
  1894. package/dist/modes/interactive-engine/create-isolated-runtime.d.ts.map +1 -1
  1895. package/dist/modes/interactive-engine/create-isolated-runtime.js +8 -5
  1896. package/dist/modes/interactive-engine/create-isolated-runtime.js.map +1 -1
  1897. package/dist/modes/interactive-engine/engine-args.d.ts.map +1 -1
  1898. package/dist/modes/interactive-engine/engine-args.js +0 -1
  1899. package/dist/modes/interactive-engine/engine-args.js.map +1 -1
  1900. package/dist/modes/interactive-engine/engine-child-liveness.d.ts.map +1 -1
  1901. package/dist/modes/interactive-engine/engine-child-liveness.js +6 -4
  1902. package/dist/modes/interactive-engine/engine-child-liveness.js.map +1 -1
  1903. package/dist/modes/interactive-engine/engine-custom-ui.d.ts +3 -2
  1904. package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
  1905. package/dist/modes/interactive-engine/engine-custom-ui.js +37 -28
  1906. package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
  1907. package/dist/modes/interactive-engine/engine-diagnostic-view.d.ts +16 -0
  1908. package/dist/modes/interactive-engine/engine-diagnostic-view.d.ts.map +1 -0
  1909. package/dist/modes/interactive-engine/engine-diagnostic-view.js +19 -0
  1910. package/dist/modes/interactive-engine/engine-diagnostic-view.js.map +1 -0
  1911. package/dist/modes/interactive-engine/engine-dialog-host.d.ts +33 -0
  1912. package/dist/modes/interactive-engine/engine-dialog-host.d.ts.map +1 -0
  1913. package/dist/modes/interactive-engine/engine-dialog-host.js +129 -0
  1914. package/dist/modes/interactive-engine/engine-dialog-host.js.map +1 -0
  1915. package/dist/modes/interactive-engine/engine-generation.d.ts +29 -0
  1916. package/dist/modes/interactive-engine/engine-generation.d.ts.map +1 -0
  1917. package/dist/modes/interactive-engine/engine-generation.js +11 -0
  1918. package/dist/modes/interactive-engine/engine-generation.js.map +1 -0
  1919. package/dist/modes/interactive-engine/engine-health.d.ts +107 -0
  1920. package/dist/modes/interactive-engine/engine-health.d.ts.map +1 -0
  1921. package/dist/modes/interactive-engine/engine-health.js +250 -0
  1922. package/dist/modes/interactive-engine/engine-health.js.map +1 -0
  1923. package/dist/modes/interactive-engine/engine-input-form.d.ts +1 -1
  1924. package/dist/modes/interactive-engine/engine-input-form.d.ts.map +1 -1
  1925. package/dist/modes/interactive-engine/engine-input-form.js +21 -4
  1926. package/dist/modes/interactive-engine/engine-input-form.js.map +1 -1
  1927. package/dist/modes/interactive-engine/engine-monitor.d.ts +8 -1
  1928. package/dist/modes/interactive-engine/engine-monitor.d.ts.map +1 -1
  1929. package/dist/modes/interactive-engine/engine-monitor.js +19 -16
  1930. package/dist/modes/interactive-engine/engine-monitor.js.map +1 -1
  1931. package/dist/modes/interactive-engine/engine-render-service.d.ts.map +1 -1
  1932. package/dist/modes/interactive-engine/engine-render-service.js +19 -24
  1933. package/dist/modes/interactive-engine/engine-render-service.js.map +1 -1
  1934. package/dist/modes/interactive-engine/engine-session-picker.d.ts.map +1 -1
  1935. package/dist/modes/interactive-engine/engine-session-picker.js +4 -2
  1936. package/dist/modes/interactive-engine/engine-session-picker.js.map +1 -1
  1937. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +18 -3
  1938. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
  1939. package/dist/modes/interactive-engine/extension-ui-bridge.js +41 -45
  1940. package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
  1941. package/dist/modes/interactive-engine/input-form-host.d.ts +1 -0
  1942. package/dist/modes/interactive-engine/input-form-host.d.ts.map +1 -1
  1943. package/dist/modes/interactive-engine/input-form-host.js +18 -3
  1944. package/dist/modes/interactive-engine/input-form-host.js.map +1 -1
  1945. package/dist/modes/interactive-engine/isolated-auth.d.ts +10 -0
  1946. package/dist/modes/interactive-engine/isolated-auth.d.ts.map +1 -0
  1947. package/dist/modes/interactive-engine/isolated-auth.js +15 -0
  1948. package/dist/modes/interactive-engine/isolated-auth.js.map +1 -0
  1949. package/dist/modes/interactive-engine/isolated-runtime.d.ts +44 -11
  1950. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  1951. package/dist/modes/interactive-engine/isolated-runtime.js +173 -106
  1952. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  1953. package/dist/modes/interactive-engine/protocol.d.ts +26 -2
  1954. package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
  1955. package/dist/modes/interactive-engine/protocol.js +192 -63
  1956. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  1957. package/dist/modes/interactive-engine/remote-component.d.ts +38 -0
  1958. package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
  1959. package/dist/modes/interactive-engine/remote-component.js +111 -22
  1960. package/dist/modes/interactive-engine/remote-component.js.map +1 -1
  1961. package/dist/modes/interactive-engine/remote-input-ownership.d.ts +48 -0
  1962. package/dist/modes/interactive-engine/remote-input-ownership.d.ts.map +1 -0
  1963. package/dist/modes/interactive-engine/remote-input-ownership.js +42 -0
  1964. package/dist/modes/interactive-engine/remote-input-ownership.js.map +1 -0
  1965. package/dist/modes/interactive-engine/remote-model-catalog.d.ts +17 -0
  1966. package/dist/modes/interactive-engine/remote-model-catalog.d.ts.map +1 -0
  1967. package/dist/modes/interactive-engine/remote-model-catalog.js +80 -0
  1968. package/dist/modes/interactive-engine/remote-model-catalog.js.map +1 -0
  1969. package/dist/modes/interactive-engine/remote-queue-pause.d.ts +13 -0
  1970. package/dist/modes/interactive-engine/remote-queue-pause.d.ts.map +1 -0
  1971. package/dist/modes/interactive-engine/remote-queue-pause.js +38 -0
  1972. package/dist/modes/interactive-engine/remote-queue-pause.js.map +1 -0
  1973. package/dist/modes/interactive-engine/remote-renderer.d.ts +3 -1
  1974. package/dist/modes/interactive-engine/remote-renderer.d.ts.map +1 -1
  1975. package/dist/modes/interactive-engine/remote-renderer.js +41 -10
  1976. package/dist/modes/interactive-engine/remote-renderer.js.map +1 -1
  1977. package/dist/modes/interactive-engine/session-picker-host.d.ts +1 -0
  1978. package/dist/modes/interactive-engine/session-picker-host.d.ts.map +1 -1
  1979. package/dist/modes/interactive-engine/session-picker-host.js +4 -0
  1980. package/dist/modes/interactive-engine/session-picker-host.js.map +1 -1
  1981. package/dist/modes/print-mode.d.ts.map +1 -1
  1982. package/dist/modes/print-mode.js +5 -0
  1983. package/dist/modes/print-mode.js.map +1 -1
  1984. package/dist/modes/rpc/jsonl.d.ts +9 -7
  1985. package/dist/modes/rpc/jsonl.d.ts.map +1 -1
  1986. package/dist/modes/rpc/jsonl.js +23 -24
  1987. package/dist/modes/rpc/jsonl.js.map +1 -1
  1988. package/dist/modes/rpc/queued-writer.d.ts +33 -0
  1989. package/dist/modes/rpc/queued-writer.d.ts.map +1 -0
  1990. package/dist/modes/rpc/queued-writer.js +104 -0
  1991. package/dist/modes/rpc/queued-writer.js.map +1 -0
  1992. package/dist/modes/rpc/rpc-bash-request-owners.d.ts +24 -0
  1993. package/dist/modes/rpc/rpc-bash-request-owners.d.ts.map +1 -0
  1994. package/dist/modes/rpc/rpc-bash-request-owners.js +45 -0
  1995. package/dist/modes/rpc/rpc-bash-request-owners.js.map +1 -0
  1996. package/dist/modes/rpc/rpc-client-api.d.ts +17 -4
  1997. package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
  1998. package/dist/modes/rpc/rpc-client-api.js +92 -25
  1999. package/dist/modes/rpc/rpc-client-api.js.map +1 -1
  2000. package/dist/modes/rpc/rpc-client-process.d.ts +11 -4
  2001. package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
  2002. package/dist/modes/rpc/rpc-client-process.js +77 -29
  2003. package/dist/modes/rpc/rpc-client-process.js.map +1 -1
  2004. package/dist/modes/rpc/rpc-client-waits.d.ts +17 -1
  2005. package/dist/modes/rpc/rpc-client-waits.d.ts.map +1 -1
  2006. package/dist/modes/rpc/rpc-client-waits.js +25 -0
  2007. package/dist/modes/rpc/rpc-client-waits.js.map +1 -1
  2008. package/dist/modes/rpc/rpc-client.d.ts +68 -9
  2009. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  2010. package/dist/modes/rpc/rpc-client.js +205 -158
  2011. package/dist/modes/rpc/rpc-client.js.map +1 -1
  2012. package/dist/modes/rpc/rpc-command-handler.d.ts +10 -3
  2013. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  2014. package/dist/modes/rpc/rpc-command-handler.js +165 -43
  2015. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  2016. package/dist/modes/rpc/rpc-command-timeouts.d.ts +30 -0
  2017. package/dist/modes/rpc/rpc-command-timeouts.d.ts.map +1 -0
  2018. package/dist/modes/rpc/rpc-command-timeouts.js +52 -0
  2019. package/dist/modes/rpc/rpc-command-timeouts.js.map +1 -0
  2020. package/dist/modes/rpc/rpc-event-buffer.d.ts.map +1 -1
  2021. package/dist/modes/rpc/rpc-event-buffer.js +3 -1
  2022. package/dist/modes/rpc/rpc-event-buffer.js.map +1 -1
  2023. package/dist/modes/rpc/rpc-extension-ui.d.ts +4 -2
  2024. package/dist/modes/rpc/rpc-extension-ui.d.ts.map +1 -1
  2025. package/dist/modes/rpc/rpc-extension-ui.js +50 -17
  2026. package/dist/modes/rpc/rpc-extension-ui.js.map +1 -1
  2027. package/dist/modes/rpc/rpc-generation-buffer.d.ts +21 -0
  2028. package/dist/modes/rpc/rpc-generation-buffer.d.ts.map +1 -0
  2029. package/dist/modes/rpc/rpc-generation-buffer.js +35 -0
  2030. package/dist/modes/rpc/rpc-generation-buffer.js.map +1 -0
  2031. package/dist/modes/rpc/rpc-input-scheduler.d.ts +3 -3
  2032. package/dist/modes/rpc/rpc-input-scheduler.d.ts.map +1 -1
  2033. package/dist/modes/rpc/rpc-input-scheduler.js +19 -8
  2034. package/dist/modes/rpc/rpc-input-scheduler.js.map +1 -1
  2035. package/dist/modes/rpc/rpc-input.d.ts +7 -1
  2036. package/dist/modes/rpc/rpc-input.d.ts.map +1 -1
  2037. package/dist/modes/rpc/rpc-input.js +14 -4
  2038. package/dist/modes/rpc/rpc-input.js.map +1 -1
  2039. package/dist/modes/rpc/rpc-keybindings-reload.d.ts.map +1 -1
  2040. package/dist/modes/rpc/rpc-keybindings-reload.js.map +1 -1
  2041. package/dist/modes/rpc/rpc-mode.d.ts +1 -1
  2042. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  2043. package/dist/modes/rpc/rpc-mode.js +23 -23
  2044. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  2045. package/dist/modes/rpc/rpc-model-fallback-prompt.d.ts +4 -0
  2046. package/dist/modes/rpc/rpc-model-fallback-prompt.d.ts.map +1 -0
  2047. package/dist/modes/rpc/rpc-model-fallback-prompt.js +11 -0
  2048. package/dist/modes/rpc/rpc-model-fallback-prompt.js.map +1 -0
  2049. package/dist/modes/rpc/rpc-oauth-client.d.ts +21 -0
  2050. package/dist/modes/rpc/rpc-oauth-client.d.ts.map +1 -0
  2051. package/dist/modes/rpc/rpc-oauth-client.js +81 -0
  2052. package/dist/modes/rpc/rpc-oauth-client.js.map +1 -0
  2053. package/dist/modes/rpc/rpc-oauth-interaction.d.ts +9 -0
  2054. package/dist/modes/rpc/rpc-oauth-interaction.d.ts.map +1 -0
  2055. package/dist/modes/rpc/rpc-oauth-interaction.js +49 -0
  2056. package/dist/modes/rpc/rpc-oauth-interaction.js.map +1 -0
  2057. package/dist/modes/rpc/rpc-output-buffer.d.ts +2 -1
  2058. package/dist/modes/rpc/rpc-output-buffer.d.ts.map +1 -1
  2059. package/dist/modes/rpc/rpc-output-buffer.js +7 -40
  2060. package/dist/modes/rpc/rpc-output-buffer.js.map +1 -1
  2061. package/dist/modes/rpc/rpc-pending-requests.d.ts +37 -0
  2062. package/dist/modes/rpc/rpc-pending-requests.d.ts.map +1 -0
  2063. package/dist/modes/rpc/rpc-pending-requests.js +57 -0
  2064. package/dist/modes/rpc/rpc-pending-requests.js.map +1 -0
  2065. package/dist/modes/rpc/rpc-provider-auth.d.ts +22 -0
  2066. package/dist/modes/rpc/rpc-provider-auth.d.ts.map +1 -0
  2067. package/dist/modes/rpc/rpc-provider-auth.js +117 -0
  2068. package/dist/modes/rpc/rpc-provider-auth.js.map +1 -0
  2069. package/dist/modes/rpc/rpc-responses.d.ts +0 -1
  2070. package/dist/modes/rpc/rpc-responses.d.ts.map +1 -1
  2071. package/dist/modes/rpc/rpc-responses.js +0 -14
  2072. package/dist/modes/rpc/rpc-responses.js.map +1 -1
  2073. package/dist/modes/rpc/rpc-session-binding.d.ts +2 -1
  2074. package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
  2075. package/dist/modes/rpc/rpc-session-binding.js +71 -43
  2076. package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
  2077. package/dist/modes/rpc/rpc-terminal-drain.d.ts +52 -0
  2078. package/dist/modes/rpc/rpc-terminal-drain.d.ts.map +1 -0
  2079. package/dist/modes/rpc/rpc-terminal-drain.js +85 -0
  2080. package/dist/modes/rpc/rpc-terminal-drain.js.map +1 -0
  2081. package/dist/modes/rpc/rpc-transport-error.d.ts +49 -0
  2082. package/dist/modes/rpc/rpc-transport-error.d.ts.map +1 -0
  2083. package/dist/modes/rpc/rpc-transport-error.js +78 -0
  2084. package/dist/modes/rpc/rpc-transport-error.js.map +1 -0
  2085. package/dist/modes/rpc/rpc-types.d.ts +188 -25
  2086. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  2087. package/dist/modes/rpc/rpc-types.js.map +1 -1
  2088. package/dist/package-manager-cli-parser.js.map +1 -1
  2089. package/dist/package-manager-cli.d.ts +3 -3
  2090. package/dist/package-manager-cli.d.ts.map +1 -1
  2091. package/dist/package-manager-cli.js +66 -53
  2092. package/dist/package-manager-cli.js.map +1 -1
  2093. package/dist/rpc-entry.js +6 -2
  2094. package/dist/rpc-entry.js.map +1 -1
  2095. package/dist/self-update-plan.d.ts +12 -0
  2096. package/dist/self-update-plan.d.ts.map +1 -0
  2097. package/dist/self-update-plan.js +42 -0
  2098. package/dist/self-update-plan.js.map +1 -0
  2099. package/dist/utils/child-process.d.ts.map +1 -1
  2100. package/dist/utils/child-process.js.map +1 -1
  2101. package/dist/utils/clipboard-image.js +1 -1
  2102. package/dist/utils/clipboard-image.js.map +1 -1
  2103. package/dist/utils/clipboard-native.d.ts +1 -0
  2104. package/dist/utils/clipboard-native.d.ts.map +1 -1
  2105. package/dist/utils/clipboard-native.js.map +1 -1
  2106. package/dist/utils/clipboard.d.ts +3 -0
  2107. package/dist/utils/clipboard.d.ts.map +1 -1
  2108. package/dist/utils/clipboard.js +31 -8
  2109. package/dist/utils/clipboard.js.map +1 -1
  2110. package/dist/utils/compile-cache.d.ts +8 -0
  2111. package/dist/utils/compile-cache.d.ts.map +1 -0
  2112. package/dist/utils/compile-cache.js +31 -0
  2113. package/dist/utils/compile-cache.js.map +1 -0
  2114. package/dist/utils/fs-watch.d.ts.map +1 -1
  2115. package/dist/utils/fs-watch.js +1 -3
  2116. package/dist/utils/fs-watch.js.map +1 -1
  2117. package/dist/utils/git.js +1 -1
  2118. package/dist/utils/git.js.map +1 -1
  2119. package/dist/utils/interactive-engine-bootstrap.d.ts +67 -0
  2120. package/dist/utils/interactive-engine-bootstrap.d.ts.map +1 -0
  2121. package/dist/utils/interactive-engine-bootstrap.js +117 -0
  2122. package/dist/utils/interactive-engine-bootstrap.js.map +1 -0
  2123. package/dist/utils/interactive-engine-env.d.ts +41 -0
  2124. package/dist/utils/interactive-engine-env.d.ts.map +1 -0
  2125. package/dist/utils/interactive-engine-env.js +67 -0
  2126. package/dist/utils/interactive-engine-env.js.map +1 -0
  2127. package/dist/utils/markit.d.ts.map +1 -1
  2128. package/dist/utils/markit.js +15 -5
  2129. package/dist/utils/markit.js.map +1 -1
  2130. package/dist/utils/shell.js +2 -2
  2131. package/dist/utils/shell.js.map +1 -1
  2132. package/dist/utils/split-launcher.d.ts.map +1 -1
  2133. package/dist/utils/split-launcher.js +1 -2
  2134. package/dist/utils/split-launcher.js.map +1 -1
  2135. package/dist/utils/tools-manager.d.ts.map +1 -1
  2136. package/dist/utils/tools-manager.js +8 -34
  2137. package/dist/utils/tools-manager.js.map +1 -1
  2138. package/dist/utils/version-check.d.ts +1 -0
  2139. package/dist/utils/version-check.d.ts.map +1 -1
  2140. package/dist/utils/version-check.js +7 -5
  2141. package/dist/utils/version-check.js.map +1 -1
  2142. package/docs/changelog.mdx +24 -2
  2143. package/docs/compaction.md +101 -18
  2144. package/docs/custom-provider.md +40 -8
  2145. package/docs/development.md +14 -15
  2146. package/docs/docs.json +12 -2
  2147. package/docs/environment-variables.md +37 -0
  2148. package/docs/extensions.md +166 -18
  2149. package/docs/index.md +1 -0
  2150. package/docs/intercom.md +1 -1
  2151. package/docs/json.md +11 -5
  2152. package/docs/keybindings.md +19 -2
  2153. package/docs/llama-cpp.md +72 -0
  2154. package/docs/models/artificial-analysis-index.md +82 -0
  2155. package/docs/models/model-selection.md +63 -0
  2156. package/docs/models/pareto-efficiency.md +64 -0
  2157. package/docs/models.md +41 -50
  2158. package/docs/packages.md +4 -2
  2159. package/docs/prompt-templates.md +1 -0
  2160. package/docs/providers.md +89 -23
  2161. package/docs/quickstart.md +21 -17
  2162. package/docs/rpc.md +97 -68
  2163. package/docs/sdk.md +68 -71
  2164. package/docs/security.md +15 -0
  2165. package/docs/session-format.md +6 -15
  2166. package/docs/sessions.md +1 -1
  2167. package/docs/settings.md +29 -18
  2168. package/docs/skills.md +8 -0
  2169. package/docs/subagents.md +24 -8
  2170. package/docs/themes.md +10 -1
  2171. package/docs/tui.md +14 -7
  2172. package/docs/usage.md +71 -2
  2173. package/docs/windows.md +1 -1
  2174. package/docs/workflows.md +1253 -534
  2175. package/examples/extensions/README.md +2 -2
  2176. package/examples/extensions/border-status-editor.ts +1 -6
  2177. package/examples/extensions/custom-compaction.ts +7 -2
  2178. package/examples/extensions/custom-footer.ts +1 -1
  2179. package/examples/extensions/custom-provider-anthropic/index.ts +14 -2
  2180. package/examples/extensions/custom-provider-gitlab-duo/index.ts +1 -1
  2181. package/examples/extensions/gondolin/index.ts +1 -1
  2182. package/examples/extensions/handoff.ts +9 -2
  2183. package/examples/extensions/hello.ts +1 -1
  2184. package/examples/extensions/message-renderer.ts +2 -2
  2185. package/examples/extensions/minimal-mode.ts +6 -6
  2186. package/examples/extensions/overlay-qa-focus-components.ts +0 -1
  2187. package/examples/extensions/overlay-qa-streaming-input-components.ts +2 -2
  2188. package/examples/extensions/overlay-qa-tests.ts +16 -14
  2189. package/examples/extensions/overlay-qa-toggle-passive-components.ts +3 -5
  2190. package/examples/extensions/overlay-test.ts +3 -6
  2191. package/examples/extensions/plan-mode/index.ts +1 -1
  2192. package/examples/extensions/preset.ts +1 -1
  2193. package/examples/extensions/qna.ts +1 -1
  2194. package/examples/extensions/sandbox/package-lock.json +3 -3
  2195. package/examples/extensions/structured-output.ts +9 -9
  2196. package/examples/extensions/subagent/display.ts +115 -127
  2197. package/examples/extensions/subagent/index.ts +310 -349
  2198. package/examples/extensions/subagent/render.ts +244 -345
  2199. package/examples/extensions/subagent/runner.ts +223 -230
  2200. package/examples/extensions/subagent/schemas.ts +39 -46
  2201. package/examples/extensions/subagent/types.ts +22 -22
  2202. package/examples/extensions/summarize.ts +4 -1
  2203. package/examples/extensions/tic-tac-toe.ts +4 -4
  2204. package/examples/extensions/todo.ts +1 -1
  2205. package/examples/extensions/tool-override.ts +1 -1
  2206. package/examples/extensions/trigger-compact.ts +4 -1
  2207. package/examples/extensions/working-indicator.ts +3 -2
  2208. package/examples/rpc-extension-ui-components.ts +1 -2
  2209. package/examples/sdk/02-custom-model.ts +8 -10
  2210. package/examples/sdk/03-custom-prompt.ts +1 -6
  2211. package/examples/sdk/06-extensions.ts +1 -6
  2212. package/examples/sdk/07-context-files.ts +1 -6
  2213. package/examples/sdk/09-api-keys-and-oauth.ts +17 -23
  2214. package/examples/sdk/12-full-control.ts +10 -12
  2215. package/examples/sdk/README.md +17 -21
  2216. package/npm-shrinkwrap.json +305 -314
  2217. package/package.json +17 -15
  2218. package/dist/builtin/cursor/CHANGELOG.md +0 -275
  2219. package/dist/builtin/cursor/LICENSE +0 -26
  2220. package/dist/builtin/cursor/README.md +0 -24
  2221. package/dist/builtin/cursor/index.ts +0 -9
  2222. package/dist/builtin/cursor/package.json +0 -47
  2223. package/dist/builtin/cursor/src/auth.ts +0 -352
  2224. package/dist/builtin/cursor/src/catalog-cache.ts +0 -155
  2225. package/dist/builtin/cursor/src/config.ts +0 -123
  2226. package/dist/builtin/cursor/src/conversation-state.ts +0 -135
  2227. package/dist/builtin/cursor/src/cursor-models-raw.json +0 -412
  2228. package/dist/builtin/cursor/src/model-mapper.ts +0 -369
  2229. package/dist/builtin/cursor/src/model-reference.ts +0 -282
  2230. package/dist/builtin/cursor/src/models.ts +0 -54
  2231. package/dist/builtin/cursor/src/native-loader.ts +0 -71
  2232. package/dist/builtin/cursor/src/proto/README.md +0 -34
  2233. package/dist/builtin/cursor/src/proto/agent_pb.ts +0 -15294
  2234. package/dist/builtin/cursor/src/proto/protobuf-codec-base64.ts +0 -22
  2235. package/dist/builtin/cursor/src/proto/protobuf-codec-json.ts +0 -44
  2236. package/dist/builtin/cursor/src/proto/protobuf-codec-request.ts +0 -311
  2237. package/dist/builtin/cursor/src/proto/protobuf-codec-wire.ts +0 -248
  2238. package/dist/builtin/cursor/src/proto/protobuf-codec.ts +0 -200
  2239. package/dist/builtin/cursor/src/provider.ts +0 -301
  2240. package/dist/builtin/cursor/src/stream.ts +0 -494
  2241. package/dist/builtin/cursor/src/transport-errors.ts +0 -74
  2242. package/dist/builtin/cursor/src/transport-frame.ts +0 -56
  2243. package/dist/builtin/cursor/src/transport-http2.ts +0 -122
  2244. package/dist/builtin/cursor/src/transport-native-client.ts +0 -161
  2245. package/dist/builtin/cursor/src/transport-run-stream.ts +0 -188
  2246. package/dist/builtin/cursor/src/transport-timeouts.ts +0 -87
  2247. package/dist/builtin/cursor/src/transport-types.ts +0 -143
  2248. package/dist/builtin/cursor/src/transport.ts +0 -26
  2249. package/dist/builtin/workflows/builtin/deep-research-codebase-runner.ts +0 -492
  2250. package/dist/builtin/workflows/builtin/deep-research-codebase-utils.ts +0 -383
  2251. package/dist/builtin/workflows/builtin/deep-research-codebase.d.ts +0 -35
  2252. package/dist/builtin/workflows/builtin/deep-research-codebase.ts +0 -47
  2253. package/dist/builtin/workflows/skills/impeccable/reference/brand.md +0 -108
  2254. package/dist/builtin/workflows/skills/impeccable/reference/codex.md +0 -105
  2255. package/dist/builtin/workflows/skills/impeccable/reference/interaction-design.md +0 -189
  2256. package/dist/builtin/workflows/skills/impeccable/scripts/hook-before-edit.mjs +0 -516
  2257. package/dist/core/context-window.d.ts +0 -54
  2258. package/dist/core/context-window.d.ts.map +0 -1
  2259. package/dist/core/context-window.js +0 -110
  2260. package/dist/core/context-window.js.map +0 -1
  2261. package/dist/core/copilot-anthropic-sse-repair.d.ts +0 -23
  2262. package/dist/core/copilot-anthropic-sse-repair.d.ts.map +0 -1
  2263. package/dist/core/copilot-anthropic-sse-repair.js +0 -340
  2264. package/dist/core/copilot-anthropic-sse-repair.js.map +0 -1
  2265. package/dist/core/copilot-errors.d.ts +0 -9
  2266. package/dist/core/copilot-errors.d.ts.map +0 -1
  2267. package/dist/core/copilot-errors.js +0 -32
  2268. package/dist/core/copilot-errors.js.map +0 -1
  2269. package/dist/core/copilot-gemini-payload-sanitizer.d.ts +0 -72
  2270. package/dist/core/copilot-gemini-payload-sanitizer.d.ts.map +0 -1
  2271. package/dist/core/copilot-gemini-payload-sanitizer.js +0 -296
  2272. package/dist/core/copilot-gemini-payload-sanitizer.js.map +0 -1
  2273. package/dist/core/copilot-gemini-reasoning.d.ts +0 -126
  2274. package/dist/core/copilot-gemini-reasoning.d.ts.map +0 -1
  2275. package/dist/core/copilot-gemini-reasoning.js +0 -265
  2276. package/dist/core/copilot-gemini-reasoning.js.map +0 -1
  2277. package/dist/core/copilot-gemini-tool-arguments.d.ts +0 -42
  2278. package/dist/core/copilot-gemini-tool-arguments.d.ts.map +0 -1
  2279. package/dist/core/copilot-gemini-tool-arguments.js +0 -159
  2280. package/dist/core/copilot-gemini-tool-arguments.js.map +0 -1
  2281. package/dist/core/copilot-hosts.d.ts +0 -12
  2282. package/dist/core/copilot-hosts.d.ts.map +0 -1
  2283. package/dist/core/copilot-hosts.js +0 -33
  2284. package/dist/core/copilot-hosts.js.map +0 -1
  2285. package/dist/core/copilot-model-catalog.d.ts +0 -114
  2286. package/dist/core/copilot-model-catalog.d.ts.map +0 -1
  2287. package/dist/core/copilot-model-catalog.js +0 -392
  2288. package/dist/core/copilot-model-catalog.js.map +0 -1
  2289. package/dist/core/copilot-model-static-fallbacks.d.ts +0 -43
  2290. package/dist/core/copilot-model-static-fallbacks.d.ts.map +0 -1
  2291. package/dist/core/copilot-model-static-fallbacks.js +0 -50
  2292. package/dist/core/copilot-model-static-fallbacks.js.map +0 -1
  2293. package/dist/core/copilot-model-synthesis.d.ts +0 -10
  2294. package/dist/core/copilot-model-synthesis.d.ts.map +0 -1
  2295. package/dist/core/copilot-model-synthesis.js +0 -91
  2296. package/dist/core/copilot-model-synthesis.js.map +0 -1
  2297. package/dist/core/model-registry-auth.d.ts +0 -8
  2298. package/dist/core/model-registry-auth.d.ts.map +0 -1
  2299. package/dist/core/model-registry-auth.js +0 -83
  2300. package/dist/core/model-registry-auth.js.map +0 -1
  2301. package/dist/core/model-registry-builtins.d.ts +0 -10
  2302. package/dist/core/model-registry-builtins.d.ts.map +0 -1
  2303. package/dist/core/model-registry-builtins.js +0 -171
  2304. package/dist/core/model-registry-builtins.js.map +0 -1
  2305. package/dist/core/model-registry-custom-loader.d.ts +0 -3
  2306. package/dist/core/model-registry-custom-loader.d.ts.map +0 -1
  2307. package/dist/core/model-registry-custom-loader.js +0 -254
  2308. package/dist/core/model-registry-custom-loader.js.map +0 -1
  2309. package/dist/core/model-registry-dynamic.d.ts +0 -7
  2310. package/dist/core/model-registry-dynamic.d.ts.map +0 -1
  2311. package/dist/core/model-registry-dynamic.js +0 -201
  2312. package/dist/core/model-registry-dynamic.js.map +0 -1
  2313. package/dist/core/model-registry-loader.d.ts +0 -5
  2314. package/dist/core/model-registry-loader.d.ts.map +0 -1
  2315. package/dist/core/model-registry-loader.js +0 -28
  2316. package/dist/core/model-registry-loader.js.map +0 -1
  2317. package/dist/core/model-registry-schemas.d.ts +0 -1273
  2318. package/dist/core/model-registry-schemas.d.ts.map +0 -1
  2319. package/dist/core/model-registry-schemas.js.map +0 -1
  2320. package/dist/core/model-registry-types.d.ts +0 -82
  2321. package/dist/core/model-registry-types.d.ts.map +0 -1
  2322. package/dist/core/model-registry-types.js +0 -2
  2323. package/dist/core/model-registry-types.js.map +0 -1
  2324. package/dist/core/oauth-compat.d.ts +0 -17
  2325. package/dist/core/oauth-compat.d.ts.map +0 -1
  2326. package/dist/core/oauth-compat.js +0 -2
  2327. package/dist/core/oauth-compat.js.map +0 -1
  2328. package/dist/core/oauth-provider-bridge.d.ts +0 -40
  2329. package/dist/core/oauth-provider-bridge.d.ts.map +0 -1
  2330. package/dist/core/oauth-provider-bridge.js +0 -169
  2331. package/dist/core/oauth-provider-bridge.js.map +0 -1
  2332. package/dist/modes/interactive/components/context-window-selector.d.ts +0 -53
  2333. package/dist/modes/interactive/components/context-window-selector.d.ts.map +0 -1
  2334. package/dist/modes/interactive/components/context-window-selector.js +0 -136
  2335. package/dist/modes/interactive/components/context-window-selector.js.map +0 -1
  2336. package/dist/modes/rpc/bounded-writer.d.ts +0 -27
  2337. package/dist/modes/rpc/bounded-writer.d.ts.map +0 -1
  2338. package/dist/modes/rpc/bounded-writer.js +0 -103
  2339. package/dist/modes/rpc/bounded-writer.js.map +0 -1
package/docs/workflows.md CHANGED
@@ -32,8 +32,10 @@ Default to a workflow for non-trivial work with a verifiable objective — see [
32
32
 
33
33
  - [Quick Start](#quick-start)
34
34
  - [When to Use Workflows](#when-to-use-workflows)
35
+ - [The Run Contract](#the-run-contract)
35
36
  - [Built-in Workflows](#built-in-workflows)
36
37
  - [Writing a Workflow](#writing-a-workflow)
38
+ - [Scope-Guard Starter Pattern](#scope-guard-starter-pattern)
37
39
  - [The `workflow()` Definition](#the-workflow-definition)
38
40
  - [WorkflowContext](#workflowcontext)
39
41
  - [Task and Stage Options](#task-and-stage-options)
@@ -95,8 +97,10 @@ Atomic will:
95
97
 
96
98
  - ask clarifying questions when stage purpose, inputs, models, or handoffs are ambiguous,
97
99
  - write a `.atomic/workflows/<name>.ts` file using `workflow({...})`,
98
- - pick `ctx.task` / `ctx.chain` / `ctx.parallel` / `ctx.ui` per the [WorkflowContext primitives](#workflowcontext) and [task options](#task-and-stage-options) reference, and
99
- - run `/workflow reload` so Atomic rediscovers the workflow resource and you can launch it immediately.
100
+ - pick `ctx.task` / `ctx.chain` / `ctx.parallel` / `ctx.ui` per the [WorkflowContext primitives](#workflowcontext) and [task options](#task-and-stage-options) reference,
101
+ - use `ctx.tool(name, args, fn)` for workflow-owned side effects so completed operations are durably checkpointed and do not run again after resume (see [`ctx.tool`](#ctxtool--durable-cached-tool-execution)),
102
+ - run `/workflow reload` so Atomic rediscovers the workflow resource and you can launch it immediately,
103
+ - then report the generated workflow folder so you can inspect the code it wrote, using `Custom workflow created. You can inspect its code at: <workflow-folder-path>` (for example, `.atomic/workflows/`); Atomic does this only for newly created custom workflows, never builtin or pre-existing workflows.
100
104
 
101
105
 
102
106
  You can also edit or harden an existing workflow in plain chat — ask Atomic to add a stage, switch a model, save artifacts, or wire in a human approval gate.
@@ -109,7 +113,9 @@ List and run it like any other workflow:
109
113
  /workflow <name> key=value ...
110
114
  ```
111
115
 
112
- Named workflow runs execute in the background. After launch, expect a run id and monitor it with `/workflow status <run-id>`, F2, or `/workflow connect <run-id>`.
116
+ Named workflow runs execute in the background. By default, after launch expect a run id and monitor it with `/workflow status <run-id>`, F2, or `/workflow connect <run-id>`. A definition with `autoAttach: true` instead opens the graph overlay as soon as an interactive top-level named launch through `/workflow <name>` or the registered `workflow` tool is accepted. This option does not affect headless launches or nested `ctx.workflow(...)` calls, and existing input-form launch behavior is unchanged.
117
+
118
+ For a request with several implementation items, do not turn list order into one serial workflow by default. Triage dependencies first, then launch independent items as a bounded wave of separate top-level runs; see [Task queues and software factories](#task-queues-and-software-factories).
113
119
 
114
120
  While a workflow is running, the visible below-editor `BACKGROUND` panel advances its elapsed label every second from the moment the run starts; it does not require opening or switching to the orchestrator. Updates repaint the existing mounted panel in place, paused timers stay frozen, and terminal cards retain their short recent-run expiry.
115
121
 
@@ -165,7 +171,7 @@ Workflows are the default execution path when a request is non-trivial or combin
165
171
 
166
172
  Loop or stop-condition phrasing is an especially strong workflow signal: `do X until Y`, `repeat until`, `iterate until`, `review/fix until passing`, `run checks and fix until green`, and `keep going until done` define control flow and convergence criteria that should be tracked.
167
173
 
168
- Use direct chat only for tiny, deterministic, low-risk answers or edits where stage tracking clearly costs more than it adds, typically a single-file/no-test/no-review change. Decide inline versus workflow before the first tool call; reconnaissance is already inline execution. Once workflow fit is clear, limit pre-workflow reconnaissance to the few reads needed to sharpen the objective and validation criteria, and put deeper research or behavior probing inside the run.
174
+ Use direct chat only for tiny, deterministic, low-risk answers or edits where stage tracking clearly costs more than it adds, typically a single-file/no-test/no-review change. Choose direct chat or a workflow based on that fit; reconnaissance is already inline execution. Once workflow fit is clear, limit pre-workflow reconnaissance to the few reads needed to sharpen the objective and validation criteria, and put deeper research or behavior probing inside the run.
169
175
 
170
176
  Workflow-first does not require builtins, monolithic workflows, or a force-fit builtin: a builtin that matches 60% of the task and fights the other 40% is worse than a small custom graph. Discover named builtin, project, user, and package workflows; or author a task-specific TypeScript `workflow({...})` inline with normal coding tools whenever the task needs richer branching, dynamic fan-out, artifacts, structured outputs, child workflows, human input, gates, retries, or loops.
171
177
 
@@ -173,41 +179,114 @@ Rich custom workflows can compose the [common workflow patterns](#common-workflo
173
179
 
174
180
  If inline work drifts past roughly ten exploratory tool calls without an artifact, edit, or commit, or repeats a "verify one more thing" loop, save the findings to a context file and hand the task to the best-fit named or custom workflow through `reads`. Sunk research is transferable, not a reason to continue inline.
175
181
 
176
- | User goal | Use |
182
+ | User need | Use |
177
183
  |-----------|-----|
178
184
  | Run, inspect, connect to, pause, interrupt, quit, resume, or check status for an existing workflow | `/workflow ...` or `workflow({ action: ... })` |
179
- | Run an autonomous job that materially benefits from a durable goal ledger, bounded worker turns, named validation, and reviewer-gated completion | `/workflow goal objective="..."` so Atomic captures receipts, gates completion through reviewers, stops as `complete`, `blocked`, or `needs_human`, and can optionally run a final PR handoff with `create_pr=true` after approval |
180
- | Run an autonomous job that materially benefits from a durable research-first pipeline, delegated implementation, and iterative review | `/workflow ralph prompt="..."` so Atomic can transform the prompt into a research question, research the codebase first, delegate implementation through sub-agents, review, and iterate; prompt text alone does not opt in to PR creation, so add `create_pr=true` only when you want the final `pull-request` stage and `pr_report` |
181
- | Create or edit reusable automation | a TypeScript workflow definition exported from `workflow({...})` |
182
- | Make a workflow robust | design the stage graph, context handoffs, artifacts, validation gates, model fallbacks, and human approval points before coding |
185
+ | Run repository-wide research | Compose `fan-out-and-synthesize` with repository-focused branches, artifact outputs, and a synthesis barrier, or author a smaller task-specific research workflow. |
186
+ | Run an implementation/review loop | Author a task-specific worker fresh verifier reducer loop with explicit evidence, repair bounds, and stop conditions. |
187
+ | Create or edit reusable automation | A TypeScript workflow definition exported from `workflow({...})` |
188
+ | Make a workflow robust | Design the stage graph, context handoffs, artifacts, validation gates, model fallbacks, and human approval points before coding |
183
189
 
184
190
  ### Choosing an Execution Shape
185
191
 
186
192
  "Use a workflow" is not one decision — it covers several execution shapes with different costs and guarantees. This section is written as agent-facing guidance: it is the self-prompt an orchestrating agent should run before the first tool call on a new request, and it doubles as documentation for humans who want to steer that choice explicitly.
187
193
 
194
+ > **Multi-item routing rule:** Enumerate requested implementation items and prove their dependencies before launch. Run independent items as separate concurrent top-level workflow runs with bounded concurrency, one explicit worktree and root failure boundary per item. Preserve ordered composition only for real code, artifact, contract, decision, approval, or merged-result dependencies.
195
+
188
196
  The shapes, cheapest first:
189
197
 
190
198
  | Shape | What it is | Guarantees you gain | Cost you pay |
191
199
  |---|---|---|---|
192
200
  | **Inline** | Answer or edit directly in the current session. | Lowest latency, zero ceremony. | No tracking, no gates, no isolation, easy to drift. |
193
- | **Inline + subagents** | Bounded specialist delegation (locate/analyze/research/debug passes, noisy command investigation, parallel read-only fanouts) while the parent keeps control and synthesizes. | Context isolation for noisy or parallel evidence-gathering. | No completion gate, no durable stages; the parent is the only reviewer. |
194
- | **Named workflows** | Installed builtin, project, user, or package workflows (`goal`, `ralph`, `deep-research-codebase`, `open-claude-design`, ...). | A proven graph: bounded loops, reviewer gates, ledgers, evidence contracts, tuned model chains. | The task must actually match the graph's objective and inputs. |
195
- | **Custom workflow** | A task-specific TypeScript `workflow({...})` authored inline, composing the common workflow patterns. | Exactly the control flow the task needs: runtime branching, dynamic fan-out, custom gates, tournaments, bounded loops. | Authoring and reload time; you own the design quality. |
196
- | **Composed/nested workflows** | A custom parent that imports proven definitions and calls `ctx.workflow(child)`. | Reuse of hardened children (research, review loops) inside custom control flow, within `maxDepth`. | Parent/child input-output contracts must be mapped deliberately. |
201
+ | **Inline + subagents** | Bounded specialist delegation while the parent keeps control and synthesizes. | Context isolation for noisy or parallel evidence-gathering. | No completion gate or durable stages; the parent remains the reviewer. |
202
+ | **Named workflows** | Installed builtin, project, user, or package workflows. | A tested graph with known inputs, outputs, gates, and artifacts. | The task must match the graph's objective and contract. |
203
+ | **Custom workflow** | A task-specific TypeScript `workflow({...})` composed from common patterns. | Exact control flow for runtime branching, fan-out, gates, tournaments, and bounded loops. | Authoring and reload time; you own design quality. |
204
+ | **Composed/nested workflows** | A parent that imports definitions and calls `ctx.workflow(child)`. | Reuse of tested children inside custom control flow, within `maxDepth`. | Parent/child input-output contracts must be mapped deliberately. |
205
+
206
+ #### The self-prompt: pre-launch workflow architecture
207
+
208
+ For every non-trivial workflow task, perform a short workflow-architecture pass before the first launch. Choose the execution shape before starting substantive work; reconnaissance already counts as inline execution. Derive the task's implementation lifecycle needs, whole-codebase research needs, independent work slices, competing strategies, exact API/type/build contracts, schema or generated-artifact contracts, state-transition/lifecycle behavior, deterministic stop conditions, and required evidence.
209
+
210
+ Use this compact coverage matrix internally (it may stay concise for a straightforward task), and let every unresolved material row change the graph choice:
211
+
212
+ ```text
213
+ requirement/risk | required evidence | workflow/stage that produces it | gap
214
+ ```
197
215
 
198
- #### The self-prompt
216
+ For any custom or composed graph, add this row and resolve it before launch:
199
217
 
200
- Ask these questions in order and stop at the first shape that satisfies every remaining requirement. Decide before the first tool call and state the decision; reconnaissance already counts as inline execution.
218
+ ```text
219
+ acyclic topology | node/edge sketch for branches and loops | architecture pass | unresolved back-edge
220
+ ```
221
+
222
+ Answer these topology questions as part of the pass:
223
+
224
+ 1. Which stages may repeat?
225
+ 2. Does each iteration create distinct tracked work?
226
+ 3. What is the current frontier before each repeated stage?
227
+ 4. Could any proposed parent edge target an ancestor or the node itself?
228
+ 5. Are nested child workflows composed through boundaries rather than recursive `run` invocation?
229
+ 6. Does resume/replay rely on stable per-iteration identity and call order?
230
+
231
+ Sketch expected nodes and dependencies for each branch, loop, and nested boundary. Any unresolved self-edge or back-edge must change the workflow design before launch.
232
+
233
+ Compare candidate workflow **guarantees**, not only broad descriptions. A named graph fits only when it covers the task's lifecycle **and** produces the evidence required for every material requirement/risk. A generic implementation workflow can cover the lifecycle while missing exact API/type/build contracts, schemas/generated artifacts, state transitions, or domain-specific gates. **Do not treat "has reviewers" as proof that a task-specific risk is covered.**
234
+
235
+ Ask these questions in order and stop at the cheapest shape that satisfies every remaining coverage row:
201
236
 
202
237
  1. **Is the outcome provable?** If success can be stated as evidence (tests green, artifact exists, behavior demonstrated, reviewer approves), the task fits a workflow. If no proof is possible or needed, inline is probably fine.
203
238
  2. **Is there structure?** Multiple subtasks, dependencies, handoffs, or parallel slices rule out inline execution. A single focused evidence-gathering pass does not.
204
239
  3. **Is there a loop or gate?** Any "until Y", "fix until passing", review/approval gate, or unknown-length repair cycle requires a workflow that enforces the stop condition, never an improvised inline retry loop or a stretched subagent chain.
205
- 4. **Is it one task or a queue of tasks?** "Address all open issues" or "fix every ticket assigned to me" is a factory request, not one workflow. Enumerate and dependency-classify the items first, then follow [Task queues and software factories](#task-queues-and-software-factories): independent items become separate per-item runs; dependent items share one composed graph.
206
- 5. **Does an installed graph already fit?** If a named workflow's objective and inputs cover essentially the whole task, run it. Do not force-fit a partial match ([When to Use Workflows](#when-to-use-workflows)).
207
- 6. **Does the control flow need shapes builtins don't offer?** Runtime classification, per-item dynamic fan-out, generate-and-filter, tournaments, or domain-specific gates mean authoring a custom workflow from the common workflow patterns.
208
- 7. **Does a proven graph already solve a sub-problem?** Nest it with `ctx.workflow(...)` instead of re-authoring its prompts and gates. Use composition instead of duplication whenever you can cleanly map the child's input/output contract.
209
- 8. **Is it only specialist evidence-gathering?** If the parent keeps control, no completion gate is needed, and the work is bounded (a debug pass, a parallel research fanout, one noisy investigation), inline subagents are enough and cheaper than a workflow.
210
- 9. **Is it truly tiny?** Deterministic, low-risk, single-file/no-test/no-review answer or edit inline and stop.
240
+ 4. **Is it one task or a queue of tasks?** "Address all open issues" or "fix every ticket assigned to me" is a factory request, not one workflow. Enumerate and dependency-classify the items first, then follow [Task queues and software factories](#task-queues-and-software-factories): independent items become bounded concurrent top-level per-item runs; dependent items share one ordered composed graph; independent dependency clusters become separate top-level runs.
241
+ 5. **Does an installed graph supply complete coverage?** Run a named workflow only if its objective, inputs, lifecycle, and produced evidence cover every material row. Do not force-fit a broad-but-partial match ([When to Use Workflows](#when-to-use-workflows)).
242
+ 6. **What routing signals shape the graph?** Broad repository uncertainty points to repository-focused Fan-out-and-synthesize; independent slices to Fan-out-and-synthesize; plausible-but-wrong contract risk to Adversarial verification or a task-specific verification stage; competing architectures or implementations to Generate-and-filter or Tournament; an explicit repeat-until condition to Loop until done; implementation work to a task-specific worker/reviewer loop; and exact API/build/schema requirements to dedicated deterministic gates.
243
+ 7. **Does a tested graph solve only part of the task?** Author one custom parent and nest that definition with `ctx.workflow(...)`, placing the missing research, verification, or deterministic gates around it instead of copying its prompts and gates.
244
+ 8. **Is it only specialist evidence-gathering?** If the parent keeps control, no completion gate is needed, and the work is bounded (a debug pass, a parallel research fanout, one noisy investigation), inline subagents are enough—and cheaper than a workflow.
245
+ 9. **Is it truly tiny?** Deterministic, low-risk, single-file/no-test/no-review—answer or edit inline and stop.
246
+
247
+ A first named workflow launch commits the selected execution shape for the turn. For one task, end the turn after that launch. For an independent queue, the selected shape is a bounded launch wave: issue every planned per-item top-level launch up to the concurrency bound before ending the turn. Do not casually chain unplanned unrelated top-level workflow launches. When one task needs multiple workflow capabilities or dependent items need ordered handoffs, design composition **before** launch: author one custom parent, import project/package definitions or builtins from `@bastani/workflows/builtin`, and call `ctx.workflow(...)`. Nested children preserve their stages and guarantees within the expanded graph up to `maxDepth`, but they remain under the parent's root lifecycle and failure boundary.
248
+
249
+ Choose the cheapest complete graph. Routing cues are not a reason to add decorative stages: avoid duplicated research and review loops. Before launch, state the selected graph, why one broad builtin is sufficient or insufficient, the evidence each major stage produces, and the stop/repair conditions. A simple direct match can be one sentence; a composed graph should briefly name its children and task-specific gates.
250
+
251
+ When an arbitrary task-specific workflow has plausible-but-wrong contract risk, design a bounded evidence-backed adversarial loop:
252
+
253
+ 1. Give a fresh-context, grumpy/skeptical-but-fair reviewer the literal objective. It should aggressively seek realistic counterexamples without inventing requirements or accepting hand-waving and circular worker-authored evidence, then emit a structured verifier plan: exact probe, inputs, command/assertion, expected success condition, and requirement/risk covered.
254
+ 2. For known contracts, author direct task-specific `ctx.tool(...)` gates up front. For adversarially discovered risks, let the model select high-value probes in structured output, but execute the selected compile, test, schema generation/validation, runtime, and artifact-inspection checks authoritatively through durable workflow-owned `ctx.tool(...)` calls. The model must not self-report outcomes.
255
+ 3. Feed the actual tool results to a skeptical evaluation stage. It classifies failures and emits one consolidated, evidence-backed, bounded repair payload for the implementation child.
256
+ 4. After repair, rerun the deterministic verifier tools until the declared pass condition succeeds or the iteration budget is exhausted. Define pass, repair, failure, and iteration-limit conditions before launch.
257
+
258
+ Use `ctx.tool` for workflow-owned external checks and side effects that benefit from durable checkpointing. Leave pure transformations as ordinary TypeScript; do not wrap every model-stage action in a tool call. A custom-loop pre-launch declaration must name the skeptical reviewer, deterministic verifier gates, how model-selected plans become tool executions, how evidence reaches evaluation/repair, and the bounded success/failure condition.
259
+
260
+ #### Judging task complexity
261
+
262
+ Complexity is a property of risk, not effort. Score a task on five axes and let the **worst axis dominate** — complexity is not the sum:
263
+
264
+ | Axis | Low | High |
265
+ |---|---|---|
266
+ | **Blast radius** | one file, one function | crosses module/package boundaries; touches shared contracts (APIs, schemas, migrations) |
267
+ | **Uncertainty** | the exact edit is known before opening the file | the location or cause of the behavior is unknown |
268
+ | **Verifiability cost** | type-checker or a glance confirms it | multi-step validation: build + tests + runtime behavior + artifact checks |
269
+ | **Dependency structure** | independent steps | ordered handoffs where an early mistake propagates |
270
+ | **Failure cost** | reversible edit | wire formats, published APIs, data migrations, releases |
271
+
272
+ A one-line change to a serialization format is complex (high failure cost, exact contract). A 500-line mechanical rename is simple (zero uncertainty, type-checker-verified). The common trap is judging by effort instead of risk: long-but-mechanical is simple; short-but-contractual is not.
273
+
274
+ Fast tells, usable in the first 30 seconds:
275
+
276
+ - **Done-condition test:** if the success condition does not fit in one sentence, the task is complex or underspecified — clarify before guessing.
277
+ - **The "and" test:** "fix X and update docs and add a test" is three tasks in one sentence; enumerate and classify each.
278
+ - **Loop words:** "until it passes", "keep trying" make the task at least moderate — iteration is expected.
279
+ - **Working-memory test:** more than about three interacting constraints at once means complex.
280
+
281
+ **Threshold.** A task earns a workflow when at least two of these are true, or any one is strongly true:
282
+
283
+ 1. Two or more distinct phases with a real handoff (research → implement, implement → verify), not just steps.
284
+ 2. The done-condition needs proof — tests, builds, review, or a contract check. If "how do you know it works?" is a fair question, a verification stage is waiting to exist.
285
+ 3. Iteration is expected — an anticipated repair loop, not a straight line.
286
+ 4. Failure cost is high — even a one-line change gets adversarial verification.
287
+ 5. The work outlives one attention span — losing mid-task state is a real risk.
288
+
289
+ The honest form of the threshold is a comparison: workflow overhead is roughly constant and small, while the cost of being wrong inline scales with uncertainty × failure cost — so the line crosses at "moderate" on any single axis. Guard against the ratchet failure mode: a task that looked simple, then accumulated exploratory calls, ad-hoc fixes, and an untracked mental TODO list is a workflow being run badly in-head; apply the ten-call rule from [When to Use Workflows](#when-to-use-workflows). Map axes to action: all low → inline now; only uncertainty high → short recon, then re-judge; any axis high with a checkable outcome → workflow with a stage producing evidence for the worst axis; failure cost high → add deterministic or adversarial gates regardless of the rest. When the mapping stays ambiguous, fall through to the [scoring rubric](#scoring-rubric) below.
211
290
 
212
291
  #### Scoring rubric
213
292
 
@@ -233,426 +312,444 @@ The rubric prevents two common misuses: using parent-controlled subagent calls f
233
312
 
234
313
  #### Task queues and software factories
235
314
 
236
- Some requests are not one task but a queue of them: "address all open issues", "fix every Linear ticket assigned to me", "burn down the TODO backlog", "upgrade every service to the new SDK". These fire-and-forget factory requests need a separate decision step because one monolithic workflow would process the queue serially in a single growing context.
237
-
238
- **Triage the queue before choosing the shape.** The first action is always a cheap enumeration-and-dependency pass, not implementation: list the items (issue tracker query, ticket API, grep for TODOs), then classify how they relate:
239
-
240
- - **Independent items** — different subsystems, no shared files, no ordering constraints, each individually verifiable.
241
- - **Dependent items** — one blocks another, they touch the same files/modules, they share a migration or API change, or their acceptance criteria reference each other.
242
- - **Clustered** — the queue splits into groups: dependencies inside a group, independence between groups.
315
+ Some requests are not one task but a queue of them: "address all open issues", "fix every Linear ticket assigned to me", "burn down the TODO backlog", or "implement issue A and create a PR after; also implement issue B and create a PR after". One monolithic worker loop would process the queue serially in a growing context and make unrelated work share one root failure boundary.
243
316
 
244
- **Independent items many small runs, not one big one.** Spawn one workflow run per item (typically `goal` with the item's text as the objective and acceptance criteria, `create_pr=true` for per-item PRs), each in its own `git_worktree_dir`, running in the background. One run per item provides what a monolith cannot:
317
+ **Interpret ordering words locally unless a cross-item dependency is explicit.** "Implement A and create PR A after; implement B and create PR B after" normally means `implement A → validate A → PR A` and `implement B → validate B → PR B`; those two item lifecycles may run concurrently. It does not mean `PR A → start B`. Serialize only when the user or repository evidence says, for example, "implement B after A is merged", "B builds on A's branch", "use A's generated schema in B", or "do these in order". Do not infer a cross-item sequence from list order or from "create a PR after" when "after" naturally refers to that item's own implementation. Prove the dependency before serializing independent workflow items. If wording remains materially ambiguous after dependency research, ask one grouped clarification instead of silently serializing.
245
318
 
246
- - **Isolation:** a hard item that stalls or fails does not affect the remaining ones; each run resumes, retries, or can be stopped independently.
247
- - **Clean contexts:** every item starts with fresh context focused on its own objective instead of receiving the transcripts of twenty finished tickets.
248
- - **Independent evidence:** per-item reviewer gates, receipts, and PRs that a human can merge or reject one at a time.
249
- - **Real parallelism:** runs proceed concurrently, up to the number you choose to run at once (worktrees prevent filesystem collisions).
319
+ **Triage before dispatch:**
250
320
 
251
- Dispatch a bounded number at a time (for example 3–5 concurrent runs), wait for lifecycle notices, then dispatch the next wave — and report the dispatch plan (item → run id → worktree) so the queue is auditable.
321
+ 1. Enumerate every requested item.
322
+ 2. Inspect stated issue, PR, branch, and approval dependencies.
323
+ 3. Check whether each prerequisite is already merged into the base each run will use. A merged prerequisite does not serialize current items when every base contains it. An unmerged prerequisite delays only the item or dependency cluster that consumes it; unrelated items remain eligible for separate concurrent workflow runs under the queue's bound.
324
+ 4. Check likely shared files, API contracts, migrations, generated artifacts, and release or deployment effects. A shared unmerged contract can create a dependency even when items edit different files.
325
+ 5. Classify items as **independent**, **dependent**, or **clustered**.
326
+ 6. Dispatch independent items or clusters concurrently with an explicit concurrency bound; preserve dependency order inside each cluster.
327
+ 7. Report an item → run ID → worktree → branch → result/PR map. After each terminal lifecycle notice, inspect that run's status detail before updating its result/PR fields.
252
328
 
253
- **Dependent items one graph that encodes the ordering.** When items block each other or share a change surface, isolation no longer helps — separate runs could modify the same files or rely on outdated assumptions. Encode the dependency structure explicitly instead:
254
-
255
- - **A composed parent workflow** that nests a proven child (for example `ctx.workflow(goal, ...)` per item) in dependency order, passing each item's outputs/artifacts to its dependents — the preferred form, because each item still gets its own bounded loop and reviewer gate while the parent owns sequencing.
256
- - **A single monolithic workflow** only when the items share enough dependencies to form one task with subtasks (one migration touching every call site is one task, not a queue).
257
-
258
- **Clustered queues both.** Compose within a cluster, fan out across clusters: each cluster becomes one run (a composed parent or a single `goal` objective covering the cluster), and independent clusters are dispatched as parallel background runs in waves.
259
-
260
- The self-prompt for factory requests, condensed: **enumerate → classify dependencies → fan out runs where independent, compose graphs where dependent → dispatch in bounded waves → report the plan.** When dependency classification is uncertain, prefer smaller independent runs and let per-item reviewer gates catch collisions — a rejected PR is cheaper than a monolith that applied a bad assumption throughout the queue.
261
-
262
- #### Prompting the choice
263
-
264
- Humans can steer the shape directly. The most direct controls, in rough order of effect:
265
-
266
- - **Name the shape or workflow.** "Do this inline", "use subagents to investigate", "run the goal workflow", or "write a custom workflow for this" overrides the agent's own scoring.
267
- - **State acceptance criteria.** Verbatim acceptance criteria make the objective provable, which both selects workflow execution and sets the immutable contract that `goal`/`ralph` reviewers enforce.
268
- - **State the loop.** "Iterate until tests pass", "review and fix until approved" — loop wording is a hard workflow signal and defines the stop condition.
269
- - **State the evidence.** Asking for a PR, a QA video, test output, or reviewer sign-off tells the agent which gates the graph needs.
270
- - **State the boundary.** "Work in a separate worktree", "don't create the PR yet", or "stop after implementation" separates the implementation loop from explicitly authorized final actions.
271
- - **State the queue policy.** For factory requests, say how to split and gate the queue: "one workflow and PR per issue", "these three tickets depend on each other — do them in order in one run", "triage first and show me the dependency plan before dispatching", or "no more than three runs at a time". Absent a policy, the agent triages dependencies itself and defaults to independent per-item runs with per-item evidence.
272
-
273
- Absent these levers, the agent applies the self-prompt and rubric above — so a prompt that mentions none of them is delegating the shape decision, not avoiding it.
329
+ | Relationship | Execution shape |
330
+ |---|---|
331
+ | Independent issues in separate code areas | Separate top-level workflow runs in bounded parallel waves |
332
+ | A prerequisite is already merged into every selected base | Treat the prerequisite as satisfied; run otherwise independent items in parallel |
333
+ | Same files or a shared unmerged API, schema, migration, or generated artifact | One ordered/composed workflow, or one ordered run per dependent cluster |
334
+ | One issue explicitly builds on another branch, PR, artifact, decision, approval, or merged result | Sequential dependency |
335
+ | Independent clusters with internal dependencies | Separate cluster runs in parallel; compose or sequence items inside each cluster |
336
+ | Material dependency remains unclear | Ask one grouped clarification before implementation |
274
337
 
275
- ### Atomic vs Claude Code Dynamic Workflows
338
+ **Workflow run isolation and Git worktree isolation are separate guarantees.** A top-level run provides its own context, progress, lifecycle controls, retry state, and root failure boundary. A worktree provides a separate checkout and Git state; it is not an operating-system sandbox. Several worktrees inside one sequential root do not create concurrent top-level runs or independent root failure boundaries, while concurrent writer runs without separate worktrees can still conflict. Use both for independent implementation items.
276
339
 
277
- Claude Code Dynamic Workflows and Atomic address a similar problem: important software engineering work is too large for one agent pass, so the system should split the job into stages, run agents in parallel, verify the result, and keep enough state to finish long-running work.
340
+ A natural-language request for a worktree does not configure runner isolation. Inspect the named workflow's inputs first. Each per-item definition must declare and implement its reusable-worktree and branch inputs, and the dispatcher must pass distinct values explicitly. With `worktreeFromInputs`, a missing target is created as a detached checkout from `baseBranch`, while an existing same-repository worktree is reused as-is. Neither case checks out the feature branch named by a separate `branch` input, so the item workflow must enforce that branch step itself.
278
341
 
279
- Atomic's category is broader and more explicit: it is the loop engine for engineering work. The difference is who controls the process and how much of the loop you can inspect, version, extend, and connect to your stack.
342
+ **Supported example: two independent top-level issue runs with a bound of 2.** First save this complete project workflow as `.atomic/workflows/issue-to-pr.ts`, then run `/workflow reload`. It is a user-defined workflow built only from supported authoring APIs, not a bundled workflow name that Atomic installs by default.
280
343
 
281
- | Dimension | Atomic | Claude Code Dynamic Workflows |
282
- | --- | --- | --- |
283
- | Core idea | Open-source, repo-native loop engine for coding agents. You can run built-ins, tell the coding agent to use a workflow for a task, describe new loops in natural language for Atomic to scaffold dynamically, or version them as explicit TypeScript files. | Claude dynamically creates orchestration scripts for a task and fans work out to many parallel Claude subagents. |
284
- | Best fit | Teams that want repeatable software engineering loops they can inspect, version, extend, connect to tools, and run across providers. | Claude Code users who want Claude to decide when a task needs a larger dynamic workflow and orchestrate it automatically. |
285
- | Workflow control | The process is explicit: stages, inputs, handoffs, retries, artifacts, model choices, checkpoints, and human gates are part of the workflow definition. | The process is generated dynamically by Claude for the current task, with confirmation before the first workflow run. |
286
- | Models | Model-agnostic. Atomic connects directly to supported API-key and subscription providers, and workflows can use model fallback chains. | Claude-first. Availability is tied to Claude Code, Claude plans, and Anthropic-supported API/cloud channels. |
287
- | Extensibility | Built on Pi extensions: add tools, TUI, MCP, web access, intercom, skills, prompt templates, themes, custom providers, and packaged workflows. | Optimized for Claude Code's built-in dynamic orchestration experience rather than an open extension SDK you own in-repo. |
288
- | Artifacts and auditability | Research docs, specs, logs, transcripts, reviewer notes, check output, and final summaries can live in the repo or workflow run directory. | Progress is saved and resumable, but the orchestration is primarily a Claude Code runtime behavior. |
289
- | Cost/scale posture | You choose the graph and concurrency. Atomic can be small and deterministic, or broad when you intentionally design a larger workflow. | Designed for large fan-outs, including tens to hundreds of subagents; Anthropic notes it can consume substantially more tokens than a typical Claude Code session. |
290
-
291
- ## Built-in Workflows
292
-
293
- Atomic bundles ten workflows: four established end-to-end workflows and six reusable implementations of the common workflow patterns. They are available in every session — no install step required. Use `/workflow list` to confirm they are loaded, and `/workflow inputs <name>` to see the exact inputs in your environment.
294
-
295
- Workflow authors can also use these builtins as workflow definitions. Import them from `@bastani/workflows/builtin` and pass the definition directly to `ctx.workflow(...)` when one workflow should call `deep-research-codebase`, `goal`, `ralph`, `open-claude-design`, or any of the six pattern builtins as a nested child workflow. See [Workflow Composition](#workflow-composition) for full examples alongside user-defined child workflows.
344
+ ```ts
345
+ // .atomic/workflows/issue-to-pr.ts
346
+ import { workflow } from "@bastani/workflows";
347
+ import { Type, type Static } from "typebox";
296
348
 
297
- For the builtin result tables below, `deep-research-codebase`, `goal`, and `ralph` explicitly declare `outputs: { result: Type.Optional(Type.String(...)) }`, so `result` is an optional part of their declared output contracts and may be omitted, including after an intentional early exit. Like every workflow output, `result` must be declared in `outputs` and returned from `run` or supplied to `ctx.exit({ outputs })` when present — see [Outputs](#outputs); Atomic adds no automatic `result` output.
349
+ const reviewDecision = Type.Object(
350
+ {
351
+ approved: Type.Boolean(),
352
+ findings: Type.Array(Type.String()),
353
+ },
354
+ { additionalProperties: false },
355
+ );
356
+
357
+ function runCommand(argv: readonly string[], cwd: string): string {
358
+ const result = Bun.spawnSync([...argv], { cwd, stdout: "pipe", stderr: "pipe" });
359
+ const stdout = result.stdout.toString().trim();
360
+ const stderr = result.stderr.toString().trim();
361
+ if (result.exitCode !== 0) {
362
+ throw new Error(`${argv.join(" ")} failed (${result.exitCode})\n${stderr || stdout}`);
363
+ }
364
+ return stdout;
365
+ }
298
366
 
299
- | Workflow | What it does | When to use |
300
- |---|---|---|
301
- | `classify-and-act` | Structured classifier deterministic category action; low confidence falls back to human selection. | Route heterogeneous requests to isolated category-specific work. |
302
- | `fan-out-and-synthesize` | Structured partition → bounded parallel artifact branches → synthesis barrier. | Split independent slices and merge evidence with dedupe/conflict resolution. |
303
- | `adversarial-verification` | Worker → fresh rubric verifiers → reducer → bounded repair loop. | Independently prove or reject a candidate. |
304
- | `generate-and-filter` | Candidate fan-out → rubric dedupe/filter → optional judge → shortlist. | Explore more options than you need and select the strongest distinct few. |
305
- | `tournament` | Whole-task attempts → balanced pairwise judges → bracket reducer. | Compare subjective or approach-sensitive solutions. |
306
- | `loop-until-done` | Durable ledger → iteration/evaluator loop → success or inspectable bound exhaustion. | Continue until explicit evidence proves completion. |
307
- | `deep-research-codebase` | Scout + research-history chain → parallel specialist waves → aggregator. Indexes the whole repo and synthesizes findings. | Broad or cross-cutting research before you decide what to change. Prefer `/skill:research-codebase` for one subsystem. |
308
- | `goal` | Persisted goal ledger → bounded worker turns → receipts → three-reviewer gate → deterministic reducer → final report → optional final-stage PR handoff after approval. | Clearly delegated autonomous work that materially benefits from a durable goal ledger, bounded worker turns, named validation, and reviewer-gated completion; optionally allow only the final `pull-request` stage to attempt PR creation with `create_pr=true` after Goal reaches `complete`. |
309
- | `ralph` | Raw prompt → research-prompt-refinement → codebase/online research → sub-agent orchestration → multi-model parallel review → optional final-stage PR handoff. | Clearly delegated autonomous work that materially benefits from a durable research-first pipeline, delegated implementation, and iterative review; optionally allow only the final `pull-request` stage to attempt PR creation with `create_pr=true`. |
310
- | `open-claude-design` | Combined discovery/init (`/skill:impeccable shape` + `/skill:impeccable init` in one `discovery` stage) → design-system/reference research (`ds-*`) → curated gallery reference-discovery using that context → separate forked `generate-*` and `user-feedback-*` chains → rich HTML handoff (`exporter` → `final-display`). The discovery stage asks what to build, the output type, and which references to emulate, then lets impeccable init detect/create/reconcile `PRODUCT.md` and `DESIGN.md` (references take precedence over project context). Renders a live `preview.html` you can iterate against in the browser (opens through impeccable `live` / the `playwright-cli` skill when available). | UI, page, component, theme, or design-token work that benefits from a guided brief, beautiful references, and generation + user feedback loops. |
367
+ export default workflow({
368
+ name: "issue-to-pr",
369
+ description: "Implement, review, check, and open one issue PR in its own worktree.",
370
+ inputs: {
371
+ issue: Type.String(),
372
+ git_worktree_dir: Type.String(),
373
+ base_ref: Type.String({ default: "origin/main" }),
374
+ pr_base: Type.String({ default: "main" }),
375
+ branch: Type.String(),
376
+ checks: Type.Array(Type.Array(Type.String(), { minItems: 1 }), { minItems: 1 }),
377
+ },
378
+ outputs: {
379
+ result: Type.String(),
380
+ pr_url: Type.String(),
381
+ branch: Type.String(),
382
+ worktree: Type.String(),
383
+ },
384
+ worktreeFromInputs: { gitWorktreeDir: "git_worktree_dir", baseBranch: "base_ref" },
385
+ run: async (ctx) => {
386
+ const { issue, branch, checks } = ctx.inputs;
387
+ const cwd = ctx.cwd ?? ctx.inputs.git_worktree_dir;
388
+ const baseRef = ctx.inputs.base_ref;
389
+
390
+ await ctx.tool("select-feature-branch", { branch, base_ref: baseRef }, async () => {
391
+ const probe = Bun.spawnSync(
392
+ ["git", "show-ref", "--verify", "--quiet", `refs/heads/${branch}`],
393
+ { cwd, stdout: "pipe", stderr: "pipe" },
394
+ );
395
+ if (probe.exitCode === 0) return runCommand(["git", "switch", branch], cwd);
396
+ if (probe.exitCode !== 1) throw new Error(probe.stderr.toString().trim());
397
+ return runCommand(["git", "switch", "-c", branch, baseRef], cwd);
398
+ });
311
399
 
312
- ### Six composable pattern builtins
400
+ await ctx.task("implement", {
401
+ context: "fork",
402
+ prompt: [
403
+ `Implement ${issue}.`,
404
+ "Add or update tests, make the smallest correct change, and commit all changes.",
405
+ "Do not create the PR; this workflow does that only after review and checks pass.",
406
+ ].join("\n"),
407
+ });
313
408
 
314
- The six patterns in [Pattern diagrams](#pattern-diagrams) ship as full definitions exported from `@bastani/workflows/builtin`. Each has typed/defaulted inputs and declared outputs a parent can consume:
409
+ let approved = false;
410
+ for (let round = 1; round <= 2; round += 1) {
411
+ const review = await ctx.task(`review-${round}`, {
412
+ context: "fresh",
413
+ schema: reviewDecision,
414
+ prompt: [
415
+ `Review the current ${branch} diff against ${baseRef} for ${issue}.`,
416
+ "Inspect the code and tests. Approve only when the issue is fully met and the patch is safe.",
417
+ "Return structured_output with approved and evidence-backed findings.",
418
+ ].join("\n"),
419
+ });
420
+ const decision = review.structured as Static<typeof reviewDecision>;
421
+ if (decision.approved) {
422
+ approved = true;
423
+ break;
424
+ }
425
+ if (round === 2) {
426
+ throw new Error(`review bound exhausted: ${decision.findings.join("; ")}`);
427
+ }
428
+ await ctx.task(`repair-${round}`, {
429
+ context: "fork",
430
+ prompt: [
431
+ `Repair ${issue} on ${branch}.`,
432
+ ...decision.findings.map((finding) => `- ${finding}`),
433
+ "Run relevant checks and commit the repair. Do not create a PR.",
434
+ ].join("\n"),
435
+ });
436
+ }
437
+ if (!approved) throw new Error("review did not approve the patch");
315
438
 
316
- | Workflow | Required input | Bounded/defaulted knobs | Principal declared outputs |
317
- |---|---|---|---|
318
- | `classify-and-act` | `prompt` | `categories` (1–8), `confidence_threshold` (0.5–0.99) | `result`, `category`, `confidence`, classification/action paths |
319
- | `fan-out-and-synthesize` | `prompt` | `max_branches` (1–12), `max_concurrency` (1–12) | `result`, partitions, branch paths, synthesis/manifest paths |
320
- | `adversarial-verification` | `task` | `verifier_count` (1–5), `max_repairs` (0–5) | `result`, `approved`, repairs, candidate/review/verifier paths, remaining work |
321
- | `generate-and-filter` | `prompt` | `num_candidates` (2–20), `shortlist_size` (1–10), `use_judge`, `max_concurrency` | `result`, shortlist, candidate/filter/judge/final/manifest paths |
322
- | `tournament` | `prompt` | `num_attempts` (2–8), `max_concurrency` (1–8) | `result`, winner, attempt/judge/bracket paths |
323
- | `loop-until-done` | `prompt` | `max_iterations` (1–20) | `result`, `status`, ledger, iteration/evaluation paths, remaining work |
439
+ await ctx.tool("require-clean-commit", { branch }, async () => {
440
+ const pending = runCommand(["git", "status", "--porcelain"], cwd);
441
+ if (pending !== "") throw new Error("implementation left uncommitted changes");
442
+ return { commit: runCommand(["git", "rev-parse", "HEAD"], cwd) };
443
+ });
324
444
 
325
- Run them by name with `/workflow <name> ...` or import their definitions:
445
+ for (const [index, argv] of checks.entries()) {
446
+ await ctx.tool(`check-${index + 1}`, { argv }, async () => runCommand(argv, cwd));
447
+ }
326
448
 
327
- ```ts
328
- import {
329
- adversarialVerification, classifyAndAct, fanOutAndSynthesize,
330
- generateAndFilter, loopUntilDone, tournament,
331
- } from "@bastani/workflows/builtin";
449
+ await ctx.tool("push-feature-branch", { branch }, async () =>
450
+ runCommand(["git", "push", "--set-upstream", "origin", branch], cwd),
451
+ );
452
+ const prUrl = await ctx.tool("create-pr", { issue, branch, base: ctx.inputs.pr_base }, async () =>
453
+ runCommand(
454
+ ["gh", "pr", "create", "--base", ctx.inputs.pr_base, "--head", branch, "--title", issue, "--body", `Implements ${issue}.`],
455
+ cwd,
456
+ ),
457
+ );
332
458
 
333
- const child = await ctx.workflow(fanOutAndSynthesize, {
334
- inputs: { prompt: "Fix every migration call site", max_branches: 6 },
335
- stageName: "migration fix pass",
459
+ return {
460
+ result: `completed ${issue}`,
461
+ pr_url: prUrl,
462
+ branch,
463
+ worktree: cwd,
464
+ };
465
+ },
336
466
  });
337
- if (child.exited === false) console.log(child.outputs.synthesis_path);
338
467
  ```
339
468
 
340
- All six can be nested with `ctx.workflow(definition, { inputs, stageName })` and count toward `maxDepth` (default four workflow levels). Prefer composing these definitions over copying their prompts or graphs: nested children contribute their stages, dedicated prompts, gates, artifacts, HIL nodes, and declared outputs to the expanded parent graph. A migration parent can wrap a `fan-out-and-synthesize` fix pass in `loop-until-done` while tests fail, then invoke `adversarial-verification` for each resulting patch; the parent consumes declared artifact paths and decisions rather than recreating the three graphs.
469
+ The workflow binding creates or validates the reusable worktree before `run` starts. The first durable tool then creates or checks out the requested feature branch, so worktree setup's detached checkout never becomes the implementation branch. The item run owns branch setup implementation bounded review/repair deterministic checks push PR creation. A failed review or check fails that item before push/PR.
341
470
 
342
- Concrete migration composition:
471
+ Inspect the new target with `workflow({ action: "inputs", workflow: "issue-to-pr" })`. Then issue these two ordinary named-run tool calls in the same dispatch turn and end the turn. Interactive named launches return after startup admission instead of waiting for terminal completion, so the two run bodies overlap. Starting exactly two item runs and admitting no third until one ends enforces the bound of 2; the top-level tool has no batch-only worker loop or hidden concurrency field.
343
472
 
344
473
  ```ts
345
- import { adversarialVerification, fanOutAndSynthesize, loopUntilDone } from "@bastani/workflows/builtin";
474
+ workflow({
475
+ action: "run",
476
+ workflow: "issue-to-pr",
477
+ inputs: {
478
+ issue: "#2101 fix cache-key normalization",
479
+ git_worktree_dir: "../atomic-issue-2101",
480
+ base_ref: "origin/main",
481
+ pr_base: "main",
482
+ branch: "fix/2101-cache-key",
483
+ checks: [["bun", "test", "test/unit/cache-key.test.ts"]],
484
+ },
485
+ })
346
486
 
347
- const fixes = await ctx.workflow(fanOutAndSynthesize, {
348
- inputs: { prompt: "Fix every migration call site", max_branches: 6 },
349
- stageName: "migration fixes",
350
- });
351
- const verification = await ctx.workflow(adversarialVerification, {
352
- inputs: { task: `Verify every patch listed by ${fixes.outputs.manifest_path}` },
353
- stageName: "verify migration patches",
354
- });
355
- const convergence = await ctx.workflow(loopUntilDone, {
487
+ workflow({
488
+ action: "run",
489
+ workflow: "issue-to-pr",
356
490
  inputs: {
357
- prompt: `Run migration tests and repair remaining failures using ${fixes.outputs.manifest_path} and ${verification.outputs.review_report_path}.`,
358
- max_iterations: 5,
491
+ issue: "#2102 correct CLI help output",
492
+ git_worktree_dir: "../atomic-issue-2102",
493
+ base_ref: "origin/main",
494
+ pr_base: "main",
495
+ branch: "fix/2102-cli-help",
496
+ checks: [["bun", "test", "test/unit/cli-help.test.ts"]],
359
497
  },
360
- stageName: "loop while migration tests fail",
361
- });
498
+ })
362
499
  ```
363
500
 
364
- The parent can consume every child's precise declared outputs and can call `adversarialVerification` once per patch when its own typed input enumerates patch artifacts.
501
+ For a longer queue, wait for a terminal lifecycle notice before filling an open slot; do not poll. Keep each returned top-level run ID with its item metadata. Lifecycle notices carry terminal status/error, not declared workflow outputs.
365
502
 
366
- ### `deep-research-codebase`
367
-
368
- Inputs:
369
-
370
- | Input | Type | Required | Default | Description |
371
- |---|---|---|---|---|
372
- | `prompt` | text | yes | — | Research question or investigation focus. |
373
- | `max_partitions` | number | no | `100` | Maximum codebase partitions explored in parallel. Actual partitions scale by one per 10K LoC, capped by this value. |
374
- | `max_concurrency` | number | no | `100` | Maximum workflow stages running concurrently during deep research. |
375
-
376
- Run examples:
377
-
378
- ```text
379
- /workflow deep-research-codebase prompt="How do payment retries work end to end?"
380
- /workflow deep-research-codebase prompt="Map the workflow runtime" max_partitions=8 max_concurrency=4
381
- ```
382
-
383
- Workflow tool call:
503
+ After each terminal lifecycle notice, inspect the completed or failed run by its returned ID with the supported per-run status action:
384
504
 
385
505
  ```ts
386
- workflow({
387
- action: "run",
388
- workflow: "deep-research-codebase",
389
- inputs: { prompt: "map workflow runtime", max_concurrency: 4 },
390
- })
506
+ workflow({ action: "status", runId: "<run-id-for-#2101>", format: "json" })
507
+ workflow({ action: "status", runId: "<run-id-for-#2102>", format: "json" })
391
508
  ```
392
509
 
393
- Output locations and result fields:
510
+ Each JSON response has `action: "statusDetail"` and a `detail` object. Read `detail.status` and `detail.error`. For a completed run, read its declared outputs from `detail.result` and require a string `detail.result.pr_url` before filling that item's result/PR fields; do not infer the PR URL from the lifecycle notice or stage prose. A completed detail without the required result or `pr_url` is a reporting-contract failure.
394
511
 
395
- | Field | Meaning |
396
- |---|---|
397
- | `result` | Final Markdown research report text, matching `findings`. |
398
- | `findings` | Final Markdown research report text. |
399
- | `research_doc_path` | Public report path under `research/<date>-<topic>.md`. If a file already exists, the workflow writes a suffixed filename. |
400
- | `artifact_dir` | Hidden per-run handoff directory under `research/.deep-research-<run-id>/`. |
401
- | `manifest_path` | Manifest JSON path inside the hidden artifact directory. |
402
- | `partitions` | Codebase partitions the specialists explored. |
403
- | `explorer_count` | Number of partition explorer groups used. |
404
- | `specialist_count` | Number of specialist stages run across the research waves. |
405
- | `max_concurrency` | Concurrency limit used for the run. |
406
- | `history` | Prior-research/history overview included in the final synthesis. |
407
-
408
- People can read, commit, or share the dated Markdown report. The hidden artifact directory keeps large scout, history, and specialist handoff files available for audit without cluttering the visible research index.
512
+ For a failed run, record `detail.error` and leave the PR field as `no PR` when the failure occurred before `create-pr`. If failure may have occurred during or after that durable tool, inspect its status/tool detail or the GitHub PR list before retrying so the dispatcher does not create a duplicate PR. In either case, free the dispatcher slot, keep unrelated top-level runs active, and do not treat a failed run's partial result as successful output. Only after these per-run inspections should the dispatcher fill the final map:
409
513
 
410
- ### `goal`
514
+ | Item | Run ID | Worktree | Branch | Result / PR |
515
+ |---|---|---|---|---|
516
+ | `#2101` | `7f31a2c0-...` | `../atomic-issue-2101` | `fix/2101-cache-key` | `completed` / `<PR-2101-URL>` |
517
+ | `#2102` | `b84d090e-...` | `../atomic-issue-2102` | `fix/2102-cli-help` | `failed: review/repair bound exhausted` / no PR |
411
518
 
412
- Inputs:
519
+ The second failure does not cancel, pause, or roll back the first run, and it does not block unrelated later items from using an open dispatcher slot. A first item's review, repair, or check failure must not block unrelated items; if it would, reconsider whether the queue was placed in one root workflow by mistake.
413
520
 
414
- | Input | Type | Required | Default | Description |
415
- |---|---|---|---|---|
416
- | `objective` | text | yes | — | Goal-runner objective or delta. Include the desired end state, expected outcome, testing/validation instructions, and any explicit done criteria. |
417
- | `acceptance_criteria` | text | no | objective | Original immutable task contract that the run must remain consistent with. When launching a follow-up `goal` run from review findings, pass the ORIGINAL task text here so reviewer suggestions cannot drift or contradict the literal contract. |
418
- | `max_turns` | number | no | `10` | Maximum worker/review turns before human follow-up is needed. |
419
- | `base_branch` | string | no | `origin/main` | Branch reviewers and the optional final stage compare the current code delta against; also used to create a missing worktree. |
420
- | `git_worktree_dir` | string | no | `""` | Optional reusable Git worktree root. Empty runs in the invoking checkout; non-empty values run Goal stages in the created/reused worktree. |
421
- | `create_pr` | boolean | no | `false` | Safe-by-default PR creation flag. Omitted or `false` skips the final `pull-request` stage and omits `pr_report`; prompt text alone does not opt in, and only strict `true` authorizes the final `pull-request` stage to attempt provider-appropriate PR/MR/review creation after Goal reaches `complete`. |
521
+ This example uses **top-level named runs**, not nested `ctx.workflow(...)` children. Each launch appears in top-level status, gets its own lifecycle notices and controls, and owns an independent root failure boundary. Nested children are hidden from top-level run lists and expand inside one parent graph; a failed child call normally fails its parent, and parent exit cancels in-flight children. Use nested children to preserve ordered composition inside a truly dependent item or cluster, not to claim separate root lifecycles for independent queue items.
422
522
 
423
- `goal` defaults to 10 worker/review turns. Reviewer quorum is fixed internally at 2 reviewer `complete` votes, and approval is deterministic on each reviewer's self-reported `stop_review_loop` boolean: a reviewer approves exactly when it returns `stop_review_loop=true` with no `reviewer_error` (schema-parse failures count as non-approval), and the reducer completes the run when quorum of those booleans is met without recomputing approval from findings arrays or traceability statuses. The repeated-blocker threshold defaults to 3 consecutive same-blocker turns and is clamped to `max_turns` when you run fewer than 3 turns.
523
+ The factory self-prompt is: **enumerate inspect and classify dependencies fan out top-level runs where independent compose where dependent dispatch in bounded waves report the map.**
424
524
 
425
- Run examples:
525
+ #### Prompting the choice
426
526
 
427
- ```text
428
- /workflow goal objective="Implement specs/2026-03-rate-limit.md, add the requested regression tests, run bun test packages/api/rate-limit.test.ts, and finish only when burst traffic returns 429 with Retry-After"
429
- /workflow goal objective="Update the CLI docs to describe the new --json flag, include one usage example, and verify the docs build still passes" max_turns=3
430
- /workflow goal objective="Fix the settings form validation bug; add/adjust the focused test and consider it done when invalid emails show the inline error without submitting"
431
- /workflow goal objective="Implement the focused docs fix, run the docs validation command, and open a PR when complete" create_pr=true
432
- /workflow goal objective="Fix the flaky package install test in an isolated worktree and run the focused regression" git_worktree_dir=../atomic-goal-install-wt base_branch=main
433
- ```
527
+ Humans can steer the shape directly:
434
528
 
435
- `goal` uses the raw `objective` exactly as supplied as the operative objective recorded in the ledger and stores `acceptance_criteria` as the immutable literal contract (defaulting to the objective when omitted); it does not run an initial prompt-refinement stage. It creates an OS-temp `goal-ledger.json` artifact, renders goal-continuation context for each worker turn, writes the latest worker receipt to `worker-receipt.md`, and appends receipts, reviewer decisions, blockers, reducer decisions, and lifecycle events to the ledger.
529
+ - **Name the shape or installed workflow.** "Do this inline", "use subagents to investigate", or "write a custom workflow for this" overrides automatic scoring.
530
+ - **State acceptance criteria.** Verbatim criteria make the objective provable and define reviewer and reducer contracts.
531
+ - **State the loop.** "Iterate until tests pass" or "review and fix until approved" defines a hard workflow stop condition.
532
+ - **State the evidence.** A QA video, test output, generated artifact, or reviewer sign-off tells the graph which gates it needs.
533
+ - **State the boundary.** "Work in a separate worktree", "do not create a PR", or "stop after implementation" separates implementation from final actions.
534
+ - **State the queue policy.** Say how to split, order, isolate, and bound queued items; otherwise Atomic runs the [dependency-triage and bounded-dispatch playbook](#task-queues-and-software-factories) before implementation. Ordinary list order and per-item "create a PR after" wording do not create a cross-item dependency.
436
535
 
437
- Worker and reviewer prompts (and the model-facing ledger artifact) deliberately omit the current turn/attempt number so the worker focuses on completing the objective rather than pacing itself to the workflow budget. Worker and reviewer prompts treat the objective as user-provided data, not higher-priority instructions. By default `goal` does not start the final `pull-request` stage, and `pr_report` is omitted. Prompt text alone does not opt in.
536
+ Absent these controls, Atomic applies the self-prompt and rubric above; a prompt that names none of them delegates the shape decision rather than avoiding it.
438
537
 
439
- Pass `create_pr=true` only when you explicitly want the final stage to inspect provider credentials and attempt provider-appropriate PR/MR/review creation, such as GitHub `gh`, Azure Repos `az repos pr create`, or Sapling/Phabricator tooling, after Goal reaches `complete` within `max_turns`. Goal worker and reviewer prompts explicitly tell intermediate stages to ignore PR-creation requests; only the final `pull-request` stage may attempt that handoff.
538
+ ### Atomic vs Claude Code Dynamic Workflows
440
539
 
441
- Set `git_worktree_dir` when you want Goal's worker and reviewer stages isolated in a reusable Git worktree. Relative paths resolve from the invoking repository root, existing same-repository worktree roots are reused, and missing paths are created from `base_branch`. Goal preserves the invoking repo-relative cwd inside the worktree, so launching from `repo/packages/api` with `git_worktree_dir=../repo-wt` runs stages from `../repo-wt/packages/api`.
540
+ Claude Code Dynamic Workflows and Atomic address a similar problem: important software engineering work is too large for one agent pass, so the system should split the job into stages, run agents in parallel, verify the result, and keep enough state to finish long-running work.
442
541
 
443
- If the run is resumed later with `/workflow resume`, Atomic reuses the original invocation cwd and recorded reusable-worktree metadata instead of resolving the worktree path from the resumed chat's current cwd. Slow Git subprocesses can run for up to 60 seconds before Atomic reports an explicit Git timeout diagnostic.
542
+ Atomic's category is broader and more explicit: it is the loop engine for engineering work. The difference is who controls the process and how much of the loop you can inspect, version, extend, and connect to your stack.
444
543
 
445
- Write the `objective` as a compact acceptance spec. Define the desired end state, required testing, relevant commands or manual checks, and the outcome that proves completion. The workflow is intentionally lean: it does not first generate an RFC or migration plan, so the developer-supplied objective is where scope, validation, and completion criteria belong.
544
+ | Dimension | Atomic | Claude Code Dynamic Workflows |
545
+ | --- | --- | --- |
546
+ | Core idea | Open-source, repo-native loop engine for coding agents. You can run built-ins, tell the coding agent to use a workflow for a task, describe new loops in natural language for Atomic to scaffold dynamically, or version them as explicit TypeScript files. | Claude dynamically creates orchestration scripts for a task and fans work out to many parallel Claude subagents. |
547
+ | Best fit | Teams that want repeatable software engineering loops they can inspect, version, extend, connect to tools, and run across providers. | Claude Code users who want Claude to decide when a task needs a larger dynamic workflow and orchestrate it automatically. |
548
+ | Workflow control | The process is explicit: stages, inputs, handoffs, retries, artifacts, model choices, checkpoints, and human gates are part of the workflow definition. | The process is generated dynamically by Claude for the current task, with confirmation before the first workflow run. |
549
+ | Models | Model-agnostic. Atomic connects directly to supported API-key and subscription providers, and workflows can use model fallback chains. | Claude-first. Availability is tied to Claude Code, Claude plans, and Anthropic-supported API/cloud channels. |
550
+ | Extensibility | Built on Pi extensions: add tools, TUI, MCP, web access, intercom, skills, prompt templates, themes, custom providers, and packaged workflows. | Optimized for Claude Code's built-in dynamic orchestration experience rather than an open extension SDK you own in-repo. |
551
+ | Artifacts and auditability | Research docs, specs, logs, transcripts, reviewer notes, check output, and final summaries can live in the repo or workflow run directory. | Progress is saved and resumable, but the orchestration is primarily a Claude Code runtime behavior. |
552
+ | Cost/scale posture | You choose the graph and concurrency. Atomic can be small and deterministic, or broad when you intentionally design a larger workflow. | Designed for large fan-outs, including tens to hundreds of subagents; Anthropic notes it can consume substantially more tokens than a typical Claude Code session. |
446
553
 
447
- Goal worker/reviewer prompts treat the objective and acceptance criteria as the sole literal source of truth: if follow-up deltas, language specs, upstream issues, in-repo comments, or best practices conflict with explicit wording, reviewers surface the conflict instead of silently implementing external knowledge.
554
+ ## The Run Contract
448
555
 
449
- Reviewer findings carry `objective_alignment` (`required_by_objective`, `consistent_with_objective`, `beyond_objective`, or `contradicts_objective`); `beyond_objective` and `contradicts_objective` findings are reported but do not block completion and must not be promoted into follow-up objectives without reconciling them against the acceptance criteria. Severity labels alone never dismiss objective-relevant findings: `required_by_objective` findings block at any priority (P3 included), while `consistent_with_objective` P3 nice-to-haves stay non-blocking.
556
+ **A run's contract is its objective plus its acceptance criteria. Only the user may change it. Every stage that receives a change must hand it to the next stage.**
450
557
 
451
- Review decisions also include `requirements_traceability`, a clause-by-clause evidence map over every explicit objective/acceptance-criteria requirement. Findings and traceability are audit evidence that drive how each reviewer derives its authoritative `stop_review_loop` boolean; the harness gates approval on that boolean alone, and Goal tells reviewers that process-only clauses (reviewer quorum/approval counts, and the authorized post-approval PR/MR/review final action when `create_pr=true`) must never hold the flag at `false`.
558
+ This is the single most important rule for getting predictable results out of a multi-stage run, and it is the rule most often broken by accident.
452
559
 
453
- Passing worker-authored tests or snapshots alone is circular evidence unless tied to independent current-state proof.
560
+ ### Only the user may change the contract
454
561
 
455
- The worker may claim readiness, but it cannot finalize completion. Before implementing, Goal prompts the worker to derive an observable acceptance/contract matrix from the literal objective/acceptance criteria (one row per clause, each mapped to the concrete check that proves it) and to model states, transitions, and invariants explicitly when the work is stateful.
562
+ A workflow launches with a contract: the objective and, when supplied, explicit acceptance criteria. Two parties relate to it very differently:
456
563
 
457
- Goal consolidates the latest reviewer findings into a deduplicated cross-reviewer batch persisted in the round artifact (`consolidated_findings` in `review-round-latest.json`), and the next worker prompt instructs the worker to plan and repair the whole batch with durable regression evidence for reproduced findings — rather than fixing one finding per turn. Goal prompts workers and reviewers to verify user-visible behavior end-to-end when practical, using `playwright-cli`-skilled subagents for web/frontend flows that may depend on backend/API behavior and tmux-skilled subagents for TUI or terminal-app scenarios.
564
+ - **You may amend it at any time.** A mid-run message steering, a follow-up, resume textis authoritative. If you say "also handle the detached path," that is a new requirement, and the run adopts it from that moment.
565
+ - **Agents may not amend it at all.** An implementer that notices a nearby bug, a cleaner abstraction, or a missing feature has found *deferred work*, not a new criterion. It records the observation and keeps building to the contract.
458
566
 
459
- They must assume credentials/auth/environment access exists until concrete checks plus an actual app/flow launch attempt prove otherwise; reviewers accept skipped E2E only when the worker records the exact attempted commands and observed failure output. Goal reviewers also look for any QA E2E video referenced by the ledger or receipt and must inspect the actual video before treating it as proof.
567
+ ### Amendments must reach the next stage
460
568
 
461
- Three reviewers independently inspect the ledger, worker receipt, repository state, and diff against `base_branch`; each starts in a clean, non-forked context, matching Ralph's reviewer context behavior, and every Goal reviewer uses Ralph's `reviewer-a` model chain with Claude Fable 5 as the primary model.
569
+ An amendment that stays inside the session that received it is invisible to everything downstream. That produces the failure this rule exists to prevent:
462
570
 
463
- Goal instructs each reviewer to first derive its own adversarial check list from the literal contract boundary/edge/negative probes plus state/transition/invariant probes before relying on the worker receipt or worker-authored tests, and each returns structured JSON with findings, evidence, verification still remaining, and an optional blocker.
571
+ > You steer the implementation stage to add a requirement. The implementer adopts it and builds it. The reviewers were launched with the original criteria, so they score the added work as unrequested scope and the original criteria as contradicted. The run then burns review loops arguing about a contract mismatch nobody can see.
464
572
 
465
- A TypeScript reducer marks the goal complete when reviewer quorum approves via the `stop_review_loop` booleans, marks blocked only when the same dependency/tool blocker repeats for the blocker threshold, continues while quorum is missing (recording the reviewers' remaining work in the decision reason), and returns `needs_human` when `max_turns` is exhausted or worker execution fails, so the bounded loop always stops with an inspectable reason.
573
+ So every builtin stage prompt carries a **steering propagation contract**:
466
574
 
467
- At the start of every Goal review, each concurrent reviewer uses [Intercom](/intercom) to initialize/check coordination and discover the sibling reviewers in the same workflow run. Before validation, reviewers communicate their plans and intended ownership, claim expensive or lock-prone checks, and serialize commands that can conflict in a shared checkout or environment, including full test suites, build or test commands, package-manager operations, browser/E2E sessions, migrations, and generated-artifact steps.
575
+ - Restate every objective-relevant steering message in your report or handoff artifact, under an explicit `Contract amendments received` heading, verbatim when short.
576
+ - Keep user-authored amendments visibly separate from your own observations, so the next stage can tell a required clause from an agent proposal.
577
+ - Treat amendments inherited from an upstream stage as contract clauses. Cover them in acceptance and traceability work; never classify them as out-of-scope.
578
+ - Resolve ambiguity before implementing. Use `intercom` to ask the supervisor or originating stage when one is reachable; otherwise state the conflict and implement the narrowest reading consistent with the launch contract.
579
+ - Propagate nothing else this way. Tool preferences, working style, and your own ideas are not amendments.
468
580
 
469
- They announce each coordinated check's start and completion, release every claimed resource and send siblings an explicit resource-release update, and share reusable command outcomes/evidence where appropriate. This operational coordination prevents collisions and duplicate conflicting work; it does not replace independent patch inspection, analysis, or each reviewer's own verdict.
581
+ Every bundled workflow wraps its run context once at the definition entry point, so each `ctx.task`, `ctx.chain`, and `ctx.parallel` prompt carries the contract automatically. Do the same in a custom workflow:
470
582
 
471
- When Goal's reducer returns `needs_human`, `blocked`, or another incomplete status, Atomic does not report the top-level workflow run as successful. `/workflow status` and lifecycle notices surface it as blocked/failed according to the run's terminal condition. Atomic also preserves structured recoverable failure metadata from the run's blocking stage (`failedStageId`) or run-level failure metadata, so auth, rate-limit, and provider fallback exhaustion remains blocked/resumable even if the workflow later returns ordinary outputs instead of a reserved `status` value. Tolerated branch failures from non-fail-fast parallel work do not reclassify an otherwise completed run.
583
+ ```ts
584
+ import { withSteeringPropagationContext } from "@bastani/workflows/builtin/steering-context";
472
585
 
473
- Each Goal review round persists a convergence summary. Each reviewer record and review artifact distinguishes schema-parse status from the review verdict with `parsed`, `approved`, `stopReviewLoop`, `nextAction`, `finalActionRemaining`, and `diagnostics` fields; each reports malformed or missing structured reviewer output as a parse failure rather than as an ordinary finding/rejection.
586
+ export default workflow({
587
+ name: "my-workflow",
588
+ // ...
589
+ run: async (ctx) => await runMyWorkflow(withSteeringPropagationContext(ctx)),
590
+ });
591
+ ```
474
592
 
475
- When `create_pr=true`, reviewers are told that PR/MR/review creation is a post-approval final action: if implementation and validation requirements are proven and only PR creation remains, the implementation can approve with `finalActionRemaining: true` and `nextAction: "pull-request"` instead of consuming another worker turn. The ledger's reducer decision repeats the same concise fields for the controller outcome, so a successful quorum records `approved: true`, `stopReviewLoop: true`, and `nextAction: "pull-request"` when `create_pr=true` (otherwise `"finish"`) before any final handoff runs.
593
+ Wrapping the context rather than each call site means a stage added later inherits the pattern instead of silently dropping amendments.
476
594
 
477
- Result fields:
595
+ ### Scope discipline
478
596
 
479
- | Field | Meaning |
480
- |---|---|
481
- | `result` | Final report with objective, status, receipts, turns, and remaining work. |
482
- | `status` | Final reducer status: `complete`, `blocked`, or `needs_human` (or `active` only if externally interrupted). |
483
- | `approved` | Whether the reducer reached `complete`. |
484
- | `goal_id` | Per-run goal identifier stored in the ledger. |
485
- | `objective` | Raw goal objective used by the run. |
486
- | `acceptance_criteria` | Immutable acceptance criteria used by the run. |
487
- | `ledger_path` | OS-temp path to `goal-ledger.json`, including receipts, reviewer decisions, reducer decisions, blockers, and lifecycle events. |
488
- | `turns_completed` | Worker/review turns completed. |
489
- | `iterations_completed` | Same value as `turns_completed`, retained for status summaries. |
490
- | `receipts` | Ledger receipt summaries and worker artifact paths. |
491
- | `remaining_work` | Remaining gaps/blockers when incomplete, or `none`. |
492
- | `review_report` | Markdown report containing the last structured reviewer decision payloads used by the reducer. |
493
- | `review_report_path` | JSON artifact path for the latest Goal review round. |
494
- | `pr_report` | Pull-request report emitted only when `create_pr=true`, Goal reaches `complete`, and the final `pull-request` stage runs. |
597
+ The mirror of "only the user may amend" is that the agent holds the line. Every builtin implementation stage carries this contract:
495
598
 
496
- ### `ralph`
599
+ > Before writing code, state the goal in one sentence and list the acceptance criteria. That list is the contract. Freeze it.
497
600
 
498
- Inputs:
601
+ While implementing:
499
602
 
500
- | Input | Type | Required | Default | Description |
501
- |---|---|---|---|---|
502
- | `prompt` | text | yes | | Task, feature request, issue summary, or spec path to research, execute, refine, and review. |
503
- | `acceptance_criteria` | text | no | prompt | Original immutable task contract that the run must remain consistent with. When launching a follow-up `ralph` run from review findings, pass the ORIGINAL task text here so reviewer suggestions cannot drift or contradict the literal contract. |
504
- | `max_loops` | number | no | `10` | Maximum research/orchestrate/review iterations before the workflow completes or reports the remaining work without reviewer approval. |
505
- | `base_branch` | string | no | `origin/main` | Branch reviewers and the optional final stage compare the current code delta against; also used to create a missing worktree. |
506
- | `git_worktree_dir` | string | no | `""` | Optional reusable Git worktree root. Empty runs in the invoking checkout; non-empty values run Ralph stages in the created/reused worktree. |
507
- | `create_pr` | boolean | no | `false` | Safe-by-default PR creation flag. Omitted or `false` skips the final `pull-request` stage and omits `pr_report`; prompt text alone does not opt in, and only strict `true` authorizes the final `pull-request` stage to attempt provider-appropriate PR/MR/review creation. |
603
+ - **Done means the contract, not "good."** When all criteria pass, stop. Polish, refactors, and "while I'm here" fixes are new work, not this work.
604
+ - **Every addition must trace to a criterion.** If you cannot point at the criterion a change serves, do not make it. Log it instead.
605
+ - **Keep a deferred list, not a growing diff.** When you notice a bug, smell, or missing feature outside the contract, write one line in a deferred note and move on. Surface it at the end.
606
+ - **Distinguish blockers from improvements.** Change scope only if a criterion is impossible or wrong as written and say so explicitly before proceeding, rather than silently absorbing the work.
607
+ - **Watch for the tells.** "It would be cleaner if…", "we should also…", "this really ought to…" mean you are about to move the goalpost. Stop and check the contract.
608
+ - **Prefer the smallest diff that satisfies the contract.** Fewer files touched, fewer abstractions introduced, no speculative generality for futures nobody asked for.
508
609
 
509
- Run examples:
610
+ At the end, report three things: what the contract was, evidence each criterion passes, and the deferred list. Scope changes belong in the report, never in the diff.
510
611
 
511
- ```text
512
- /workflow ralph prompt="Migrate the database layer to Drizzle" max_loops=3 base_branch=develop
513
- /workflow ralph prompt="Refactor authentication across the API, CLI, and web UI" create_pr=true
514
- /workflow ralph prompt="Safely implement the API refactor" git_worktree_dir=../atomic-ralph-api-wt base_branch=main
515
- ```
612
+ ### Practical consequences
516
613
 
517
- Each `ralph` run uses the raw `prompt` exactly as supplied as the operative objective for research, orchestration, and review, and stores `acceptance_criteria` as the immutable literal contract (defaulting to the prompt when omitted). Shared literal-contract prompt language forbids adding behaviors, restrictions, or error conditions beyond the prompt/acceptance criteria and requires surfacing conflicts with external knowledge; Ralph does not run an initial prompt-refinement stage.
614
+ - **Steer freely it is the supported amendment channel.** You do not need to restart a run to add a requirement.
615
+ - **Say what you mean as a requirement.** "It would be nice if…" reads as guidance; "also handle X" reads as a clause. Stages are told to distinguish them.
616
+ - **Expect amendments in the reports.** If a stage received one and its report has no `Contract amendments received` section, the amendment did not propagate and downstream stages will not honor it.
617
+ - **A growing diff with no new criteria is a defect.** That is the tell that scope discipline slipped, and it is a legitimate reason to stop a run.
518
618
 
519
- Each iteration transforms that raw prompt with `/skill:prompt-engineer Transform the following user request into a codebase and online research question which can be thoroughly explored: ...` (`research-prompt-refinement`), researches that transformed question with `/skill:research-codebase ...`, and writes the findings under `research/`. The research, orchestrator, and reviewer prompts carry `acceptance_criteria` next to the literal contract, so orchestrators should pass the ORIGINAL task text when launching follow-up Ralph runs from reviewer findings.
619
+ ## Built-in Workflows
520
620
 
521
- Before implementing, Ralph prompts the orchestrator to derive an observable acceptance/contract matrix from the literal prompt/acceptance criteria (one row per clause mapped to the concrete observable check that proves it) and to model states, transitions, and invariants explicitly when the work is stateful.
621
+ Atomic bundles nine workflows: six reusable control-flow patterns, two autonomous implementation loops, and one end-to-end design workflow. They are available in every session. Use `/workflow list` to confirm the current set and `/workflow inputs <name>` to inspect a contract before launch.
522
622
 
523
- It treats the research artifact as its primary implementation context, initializes/updates an OS-temp implementation notes file while generating verifiable evidence for any claims it records in the notes and reviewer artifacts, delegates implementation through sub-agents, repairs unresolved reviewer findings as one consolidated batch (with durable regression evidence for reproduced findings) rather than one finding per iteration, and asks two independent reviewers (`reviewer-a` and `reviewer-b`) to inspect the patch directly against `base_branch`.
623
+ | Workflow | What it does | When to use |
624
+ |---|---|---|
625
+ | `classify-and-act` | Structured classifier → deterministic category action; low confidence can fall back to human selection. | Route mixed requests to isolated category-specific work. |
626
+ | `fan-out-and-synthesize` | Structured partition → bounded parallel artifact branches → synthesis barrier. | Split independent slices, including repository research, and merge evidence. |
627
+ | `adversarial-verification` | Worker → fresh rubric verifiers → reducer → bounded repair loop. | Independently prove or reject a candidate. |
628
+ | `generate-and-filter` | Candidate fan-out → rubric dedupe/filter → optional judge → shortlist. | Explore more options than needed and keep the strongest distinct few. |
629
+ | `tournament` | Whole-task attempts → balanced pairwise judges → bracket reducer. | Compare subjective or approach-sensitive solutions. |
630
+ | `loop-until-done` | Durable ledger → iteration/evaluator loop → success or inspectable bound exhaustion. | Continue until explicit evidence proves completion. |
631
+ | `goal` | Durable goal ledger → bounded sub-agent orchestration → parallel review → deterministic reducer. | Autonomous implementation that needs receipts and reviewer-gated completion. |
632
+ | `ralph` | Prompt refinement → codebase research → delegated implementation → multi-model review loop. | Research-first autonomous implementation with bounded review and repair. |
633
+ | `open-claude-design` | Guided discovery and reference research → HTML generation → feedback loop → export and handoff. | UI, page, component, theme, or design-token work. |
524
634
 
525
- The reviewer fan-out runs reviewers on different primary model families (Claude Fable 5 and GPT-5.5 Codex, with shared fallbacks) so the adversarial review gets cross-model coverage instead of repeated passes from one model, and Ralph instructs each reviewer to first derive its own adversarial check list from the literal contract boundary/edge/negative probes plus state/transition/invariant probes before relying on the implementation notes, orchestrator report, or worker-authored tests.
635
+ Across these builtins, model-facing stages use compact, outcome-first contracts tuned for GPT-5.6, Claude Opus 5, and Claude Fable 5. Long artifacts and receipts are rendered before the final instruction, reporting stages ground completion claims in current tool evidence, and user-facing or downstream reports have explicit shape and length bounds. Orchestrators delegate only genuinely independent work that is too large for a handful of tool calls, rather than spawning agents to recheck their own work.
526
636
 
527
- Ralph prompts its orchestrator and reviewers to verify user-visible behavior end-to-end when practical, using `playwright-cli`-skilled subagents for web/frontend flows that may depend on backend/API behavior and tmux-skilled subagents for TUI or terminal-app scenarios. They must assume credentials/auth/environment access exists until concrete checks plus an actual app/flow launch attempt prove otherwise; reviewers accept skipped E2E only when the orchestrator records the exact attempted commands and observed failure output.
637
+ ### Six composable pattern builtins
528
638
 
529
- For UI-applicable or full-stack changes, the orchestrator runs a `playwright-cli` end-to-end QA pass and records a reviewable proof video (referenced in the implementation notes and surfaced as `qa_video_path`); reviewers receive that path and must inspect the actual video before treating it as proof. When `create_pr=true`, the final `pull-request` stage attaches or links that video to the created PR/MR/review after reviewer approval.
639
+ The six common patterns are full definitions exported from `@bastani/workflows/builtin`:
530
640
 
531
- If reviewers find issues, the next `research-prompt-refinement` and research stages receive the review artifact path (whose `review-round-latest.json` carries a deduplicated cross-reviewer `consolidated_findings` batch) so follow-up research can address unresolved findings, and research stages fork from prior research session data when available. The loop stops only when both reviewers independently approve or `max_loops` is reached, so the bounded loop always stops with an inspectable review round.
641
+ | Workflow | Required input | Bounded/defaulted knobs | Principal declared outputs |
642
+ |---|---|---|---|
643
+ | `classify-and-act` | `prompt` | `categories` (1–8), `confidence_threshold` (0.5–0.99) | `result`, category, confidence, classification/action paths |
644
+ | `fan-out-and-synthesize` | `prompt` | `max_branches` (1–12), `max_concurrency` (1–12) | `result`, partitions, branch paths, synthesis/manifest paths |
645
+ | `adversarial-verification` | `task` | `verifier_count` (1–5), `max_repairs` (0–5) | `result`, approval, repairs, candidate/review/verifier paths |
646
+ | `generate-and-filter` | `prompt` | `num_candidates` (2–20), `shortlist_size` (1–10), `use_judge`, `max_concurrency` | `result`, shortlist, candidate/filter/judge/final/manifest paths |
647
+ | `tournament` | `prompt` | `num_attempts` (2–8), `max_concurrency` (1–8) | `result`, winner, attempt/judge/bracket paths |
648
+ | `loop-until-done` | `prompt` | `max_iterations` (1–20) | `result`, `status`, ledger, iteration/evaluation paths, remaining work |
532
649
 
533
- Ralph findings include the same `objective_alignment` classification used by Goal, and each reviewer derives a single authoritative `stop_review_loop` boolean from that evidence: `required_by_objective` findings mean `false` at any priority (P3 included, because severity labels alone never dismiss objective-relevant findings), `consistent_with_objective` P0/P1/P2 findings mean `false` while P3 remains a non-blocking nice-to-have, and `beyond_objective`/`contradicts_objective` findings are surfaced but non-blocking so they are not silently converted into new requirements.
650
+ ```ts
651
+ import {
652
+ adversarialVerification,
653
+ classifyAndAct,
654
+ fanOutAndSynthesize,
655
+ generateAndFilter,
656
+ goal,
657
+ loopUntilDone,
658
+ ralph,
659
+ tournament,
660
+ } from "@bastani/workflows/builtin";
534
661
 
535
- The loop gate approves deterministically on `stop_review_loop=true` plus a null `reviewer_error` (parse failures count as non-approval) without recomputing approval from the findings arrays. Ralph review decisions also include `requirements_traceability`, a clause-by-clause evidence map over every explicit prompt/acceptance-criteria requirement kept as audit evidence for deriving the flag; reviewers are explicitly told that process-only clauses (reviewer quorum, and the authorized post-approval PR/MR/review final action when `create_pr=true`) must never hold the flag at `false`.
662
+ const research = await ctx.workflow(fanOutAndSynthesize, {
663
+ inputs: {
664
+ prompt: "Map the repository by independent subsystem and synthesize cited findings.",
665
+ max_branches: 6,
666
+ },
667
+ stageName: "repository research",
668
+ });
669
+ ```
536
670
 
537
- Passing worker-authored tests or snapshots is circular evidence unless tied to independent current-state proof. By default Ralph does not start the final `pull-request` stage, and `pr_report` is omitted. Prompt text alone does not opt in. Pass `create_pr=true` only when you explicitly want the final `pull-request` stage to inspect provider credentials and attempt provider-appropriate PR/MR/review creation, such as GitHub `gh`, Azure Repos `az repos pr create`, or Sapling/Phabricator tooling; Ralph's own PR-creation instructions live in that final stage and run only after approval.
671
+ All six can run by name or as nested definitions. Prefer composition over copying prompts or graphs: nested children contribute stages, gates, artifacts, HIL nodes, and declared outputs to the expanded parent graph. For broad repository work, write a precise partition prompt, give branches distinct artifact paths, and make synthesis cite concrete files and resolve conflicts. For implementation, author a task-specific parent around the pattern builtins so its literal contract, deterministic checks, repair policy, and final actions stay explicit.
538
672
 
539
- At the start of every Ralph review, each concurrent reviewer uses Intercom to initialize/check coordination and discover the sibling reviewer in the same workflow run. Before validation, reviewers communicate their plans and intended ownership, claim expensive or lock-prone checks, and serialize commands that can conflict in a shared checkout or environment, including full test suites, build or test commands, package-manager operations, browser/E2E sessions, migrations, and generated-artifact steps.
673
+ ### `goal`
540
674
 
541
- They announce each coordinated check's start and completion, release every claimed resource and send the sibling an explicit resource-release update, and share reusable command outcomes/evidence where appropriate. This operational coordination prevents collisions and duplicate conflicting work; it does not replace independent patch inspection, analysis, or each reviewer's own verdict.
675
+ Goal persists the literal objective and immutable acceptance criteria in a run ledger, delegates implementation through bounded orchestrator turns, records receipts, and asks independent reviewers to inspect the current delta. A TypeScript reducer returns `complete`, `blocked`, or `needs_human` rather than trusting free-form completion claims.
542
676
 
543
- Each Ralph review artifact and `review-round-latest.json` includes a `convergence_decision` summary with `parsed`, `approved`, `stopReviewLoop`, `nextAction`, `finalActionRemaining`, and `diagnostics`. This distinguishes malformed or missing structured reviewer output from a parsed reviewer rejection or blocking finding by reporting it as a parse failure.
677
+ Goal reviewers derive checks from the literal objective before consulting implementation receipts, inspect the actual checkout delta, and report commands, observed output, and file:line evidence rather than internal reasoning. Shared contracts cover acceptance-matrix traceability, contract-fidelity risks, end-to-end and QA-video evidence, and independent verification. `stop_review_loop` is the authoritative convergence signal: it remains `false` for P0–P2 findings, any `required_by_objective` finding, or unproven implementation/validation requirements; it becomes `true` only when independent evidence proves the objective and only non-blocking or authorized post-approval work remains. The deterministic reducer consumes that signal without reinterpreting free-form prose.
544
678
 
545
- When `create_pr=true`, reviewers are told that PR/MR/review creation is a post-approval final action: if implementation and validation requirements are proven and only PR creation remains, the implementation can approve with `finalActionRemaining: true` and `nextAction: "pull-request"` instead of consuming another orchestration iteration. When both reviewers converge, the latest round records `approved: true`, `stopReviewLoop: true`, and `nextAction: "pull-request"` when `create_pr=true` (otherwise `"finish"`), and the implementation loop stops before the final handoff stage.
679
+ | Input | Type | Required | Default | Description |
680
+ |---|---|---|---|---|
681
+ | `objective` | text | yes | — | Task to implement and validate. Keep PR/MR creation out of this text. |
682
+ | `acceptance_criteria` | text | no | objective | Immutable original contract, especially for follow-up runs. |
683
+ | `max_turns` | number | no | `10` | Maximum orchestrator/review turns. |
684
+ | `base_branch` | string | no | `origin/main` | Review and optional final-action comparison base. |
685
+ | `git_worktree_dir` | string | no | `""` | Optional reusable worktree, only when explicitly requested. |
686
+ | `create_pr` | boolean | no | `false` | Authorize the post-approval PR/MR/review stage. Prompt text alone never opts in. |
546
687
 
547
- Set `git_worktree_dir` when you want Ralph's worker stages isolated in a reusable Git worktree. Relative paths resolve from the invoking repository root, existing same-repository worktree roots are reused, and missing paths are created from `base_branch`. Ralph preserves the invoking repo-relative cwd inside the worktree, so launching from `repo/packages/api` with `git_worktree_dir=../repo-wt` runs stages from `../repo-wt/packages/api`.
688
+ ```text
689
+ /workflow goal objective="Update the CLI docs for --json, add one example, and validate the docs build"
690
+ /workflow goal objective="Implement specs/rate-limit.md and run focused checks" create_pr=true
691
+ ```
548
692
 
549
- Result fields:
693
+ Declared outputs include `result`, `status`, `approved`, `goal_id`, `objective`, `acceptance_criteria`, `ledger_path`, turn counts, receipts, remaining work, review artifacts, and optional `pr_report`.
550
694
 
551
- | Field | Meaning |
552
- |---|---|
553
- | `result` | Final implementation report from the orchestrator stage. |
554
- | `plan` | Latest transformed research question, retained for compatibility. |
555
- | `plan_path` | Backward-compatible alias for `research_path`. |
556
- | `research` | Latest research report text or artifact reference. |
557
- | `research_path` | Path to the latest generated research artifact under `research/`. |
558
- | `implementation_notes_path` | OS-temp notes file containing decisions, deviations, blockers, and validation notes. |
559
- | `qa_video_path` | Absolute path to the reviewable QA end-to-end proof video recorded with `playwright-cli` for UI-applicable changes, when one was produced. |
560
- | `pr_report` | Pull-request report emitted only when `create_pr=true` and the final `pull-request` stage runs. |
561
- | `approved` | Whether the reviewer loop approved before completion or optional final handoff. |
562
- | `iterations_completed` | Number of research/orchestrate/review loops completed. |
563
- | `review_report` | Compact reference to the latest reviewer payload artifact. |
564
- | `review_report_path` | JSON artifact path for the latest Ralph review round. |
565
-
566
- For a delegated autonomous implementation that materially benefits from a durable research-first pipeline, use `/skill:research-codebase` → `/skill:create-spec` → `/workflow ralph prompt="Implement specs/2026-03-rate-limit.md and validate the documented burst behavior"`. Ralph can start from a spec path, GitHub issue, or crisp ticket description; it uses that prompt as-is, researches the task, delegates through sub-agents, reviews, records a QA proof video for UI/full-stack changes when practical, and iterates.
567
-
568
- Use `/workflow goal` when an autonomous job instead materially benefits from a durable goal ledger, bounded worker turns, and reviewer-gated completion; give it a concrete objective and add `create_pr=true` only when you want Goal's final `pull-request` stage after approval. Task size alone does not select either workflow.
695
+ ### `ralph`
569
696
 
570
- ### `open-claude-design`
697
+ Ralph starts from the raw task, refines it into a research question, runs codebase research, delegates implementation from the research artifact, and sends the patch to independent model-family reviewers. It repeats research, orchestration, and review until reviewers approve or `max_loops` is exhausted.
571
698
 
572
- Inputs:
699
+ Ralph uses the same canonical reviewer evidence and convergence contracts as Goal. Its reviewer prompt receives artifacts first and the review objective last, requires independently derived probes before implementation-authored evidence, and preserves unresolved findings when the bounded loop ends. Forked continuation prompts send only changed state and artifact paths instead of repeating the full established contract.
573
700
 
574
701
  | Input | Type | Required | Default | Description |
575
702
  |---|---|---|---|---|
576
- | `prompt` | text | yes | — | What to design (dashboard, page, component, prototype, …). The discovery stage refines this into a confirmed brief and asks for the output type and references. |
577
- | `discover_references` | boolean | no | `true` | Discover beautiful, current reference designs (Awwwards, recent.design, Dribbble, Monet, Motionsites) and feed them to generation. Set `false` to skip the network/browser reference pass. |
578
- | `max_refinements` | number | no | `3` | Maximum generate/user-feedback loop iterations. |
579
-
580
- The output type (`prototype`, `wireframe`, `page`, `component`, `theme`, `tokens`) and any reference designs are **not** inputs — the discovery stage asks for them. There is no `design_system` input; the workflow establishes or loads the project's `DESIGN.md`/`PRODUCT.md` automatically.
581
-
582
- Result fields:
583
-
584
- | Field | Meaning |
585
- |---|---|
586
- | `output_type` | Kind of design artifact produced (chosen during the discovery interview). |
587
- | `design_system` | Design system source used for generation: the project-derived design system. |
588
- | `artifact` | Latest final design summary from the approved preview artifact. |
589
- | `handoff` | Final rich HTML spec and implementation handoff summary. |
590
- | `approved_for_export` | Whether the latest user-feedback stage reported no further changes before export. |
591
- | `refinements_completed` | Number of refinement iterations completed. |
592
- | `import_context` | Reference-import context used during generation. |
593
- | `run_id` | Per-run design workflow artifact identifier. |
594
- | `artifact_dir` | Directory containing preview and spec artifacts. |
595
- | `preview_path` | Absolute path to the generated `preview.html` file. |
596
- | `preview_file_url` | `file://` URL for the generated `preview.html` file. |
597
- | `spec_path` | Absolute path to the generated `spec.html` file. |
598
- | `spec_file_url` | `file://` URL for the generated `spec.html` file. |
599
- | `playwright_cli_status` | Outcome of the initial deterministic step that ensures the `playwright-cli` skill's `playwright-cli` command is installed. |
703
+ | `prompt` | text | yes | — | Task, issue, or spec to research, implement, and review. Keep PR/MR creation out of this text. |
704
+ | `acceptance_criteria` | text | no | prompt | Immutable original contract, especially for follow-up runs. |
705
+ | `max_loops` | number | no | `10` | Maximum research/orchestrate/review iterations. |
706
+ | `base_branch` | string | no | `origin/main` | Review and optional final-action comparison base. |
707
+ | `git_worktree_dir` | string | no | `""` | Optional reusable worktree, only when explicitly requested. |
708
+ | `create_pr` | boolean | no | `false` | Authorize the post-approval PR/MR/review stage. Prompt text alone never opts in. |
600
709
 
601
- `open-claude-design` has no `result` output; it exposes only the declared fields listed above. Use the declared `artifact` and `handoff` fields for generated content.
710
+ ```text
711
+ /workflow ralph prompt="Migrate the database layer to Drizzle" max_loops=3
712
+ /workflow ralph prompt="Implement specs/rate-limit.md and validate burst behavior" create_pr=true
713
+ ```
602
714
 
603
- **Combined discovery/init.** The workflow's first and only front-door stage runs `/skill:impeccable shape` and `/skill:impeccable init` together. It interviews you (via the structured question tool) about what you want to build, the **output type** (`prototype`, `wireframe`, `page`, `component`, `theme`, or `tokens`), and which **references** to emulate (URLs, local file paths, screenshots, or design docs). Then, in the same `discovery` stage, impeccable init detects `PRODUCT.md`/`DESIGN.md` and creates or reconciles those files as needed.
715
+ Declared outputs include `result`, the latest research question and artifact paths, implementation notes, optional QA video and PR reports, approval, iteration count, and review artifacts.
604
716
 
605
- The references you name take **precedence over `DESIGN.md`/`PRODUCT.md`** during generation (the design system fills gaps the references don't cover, and `PRODUCT.md` still governs strategic register/voice). Headless runs infer a defensible brief, output type, references, and project-context assumptions rather than blocking.
717
+ Goal and Ralph both support reusable worktree binding through `git_worktree_dir` and `base_branch`. Use `create_pr=true` only for an explicitly authorized final action after implementation approval. For follow-up runs based on reviewer findings, pass the original task text as `acceptance_criteria` to prevent contract drift.
606
718
 
607
- **Context and reference phase.** Design-system/reference research runs first, then gallery reference discovery uses those findings before the generator consumes the combined context:
719
+ ### `open-claude-design`
608
720
 
609
- - *Design-system/reference research* — three parallel passes (`ds-locator` / `ds-analyzer` / `ds-patterns`) extract the project's design-system evidence and also handle user-provided references. URL references are captured with browser/screenshot tooling where available; local files, screenshots, and design docs are parsed by the applicable `ds-*` pass. Their extracted requirements feed the generator and **take precedence over `DESIGN.md`/`PRODUCT.md`**. There are no separate `web-capture-*`, `file-parser-*`, or `design-system-builder` stages.
610
- - *Reference discovery* (gated by `discover_references=true`, the default) — after the `ds-*` passes complete, the `reference-discovery` stage receives their evidence plus the `PRODUCT.md`/`DESIGN.md` init summary.
611
- - It uses the `playwright-cli` skill to browse five curated galleries: [Awwwards](https://www.awwwards.com/websites/), [recent.design](https://recent.design/), [Dribbble recents](https://dribbble.com/shots/recent), [Monet](https://www.monet.design/c), and [Motionsites](https://motionsites.ai/).
612
- - It then **opens the strongest selected designs** and, ideally, **records a scroll-through video of each real design page so its animations are captured**. A full-page screenshot is a supplement or fallback, and the real destination URL is retained; it does not just screenshot gallery thumbnails, with web search as the fallback when the browser is unavailable.
613
- - It asks which curated reference direction you prefer. If none align, it asks you to provide a reference image, screenshot, URL, or local path for best results.
614
- - The workflow persists the curated **references brief** to `<artifact_dir>/references.md` and passes it to the generator (`reference_inspiration`) and refinement. Set `discover_references=false` to skip it.
721
+ Inputs:
615
722
 
616
- **Generate/user-feedback loop.** Refinement is intentionally simple and mirrors Ralph's implement/reviewer rhythm: `generate-1` writes the first `preview.html`, `user-feedback-1` opens that preview with `/skill:impeccable live`, and any captured `live_changes`, `user_notes`, or `annotated_snapshot` feed the next forked `generate-*` stage. Generator and feedback stages keep separate session lineages: each later `generate-*` forks from the previous generate session, `user-feedback-1` starts its own feedback chain, and each later `user-feedback-*` forks only from the previous feedback session rather than falling back to generator sessions.
723
+ | Input | Type | Required | Default | Description |
724
+ |---|---|---|---|---|
725
+ | `prompt` | text | yes | — | What to design. The discovery stage refines the brief, output type, and references. |
726
+ | `discover_references` | boolean | no | `true` | Discover current design references and feed them to generation. |
727
+ | `max_refinements` | number | no | `3` | Maximum generate/user-feedback loop iterations. |
617
728
 
618
- When a `user-feedback-*` stage captures no meaningful feedback, the loop exports immediately. The workflow deliberately runs only `exporter`, followed by `final-display`; there is no pre-export scan, forced-fix stage, or export gate. The workflow saves captured feedback as durable artifacts under `<artifact_dir>/feedback/iteration-<n>.md` / `.json` (plus a best-effort copy of the annotated snapshot, constrained to files within the project/artifact dir). If captured notes fail to thread into the next generate prompt, the run fails with an explicit error rather than silently generating without user feedback.
729
+ The workflow establishes or loads project design context, extracts user-provided references, can browse curated galleries, writes a live `preview.html`, and keeps separate generator and feedback session lineages. It exports an HTML spec and implementation handoff after approval. Browser-backed preview and feedback use the `playwright-cli` skill when available. Research context moves between stages as artifact files rather than inline prompt payloads: the composed project design context is written to `<artifact_dir>/design-context.md` and the curated references brief to `<artifact_dir>/references.md`; `reference-discovery` reads the design context, and the generate and exporter stages read both files via `reads` with explicit read instructions. Only small bounded payloads verbatim user annotations and the word-capped prior design summary travel inline, so one oversized research result cannot become one oversized prompt message.
619
730
 
620
- **Browser requirement.** open-claude-design is browser-centric (the discovery/preview review and the `live` QA loop need the `playwright-cli` skill's browser). If no browser is available, the workflow exits cleanly before generation and reports the would-be artifact paths and install instructions rather than generating a design you could not review interactively. (The test harness skips this early exit so headless test runs still complete.)
731
+ **Where the feedback gate appears.** The browser review inside a `user-feedback-*` stage is a long-poll, not an `awaiting_input` graph node, so the stage itself reports `running` while it waits. Each round therefore pauses first at a deterministic run-level prompt: the needs-attention badge fires, and the prompt names the preview path and `file://` URL. Answer `Start live review` to begin the browser session — the stage prints the live `http://` review URL in its first lines of output, visible via `/workflow connect <run-id>` or `Skip remaining review rounds and export as-is` to accept the current design and move to export. In headless runs the gate is skipped and the review degrades as before. A feedback stage that fails outright fails the run; only a completed review with no requested changes counts as approval.
621
732
 
622
- Run examples:
733
+ Declared outputs are `output_type`, `design_system`, `artifact`, `handoff`, `approved_for_export`, `refinements_completed`, `import_context`, `run_id`, `artifact_dir`, `preview_path`, `preview_file_url`, `spec_path`, `spec_file_url`, and `playwright_cli_status`. It has no implicit `result` output.
623
734
 
624
735
  ```text
625
736
  /workflow open-claude-design prompt="Refresh the settings page hierarchy"
626
- /workflow open-claude-design prompt="Design a billing page like Stripe's"
627
- /workflow open-claude-design prompt="Generate spacing and color tokens"
628
737
  /workflow open-claude-design prompt="Design a marketing landing page" discover_references=false
629
738
  ```
630
739
 
631
- The discovery interview asks for the output type and any reference URLs/files, so do not pass `output_type`, `reference`, or `design_system` on the command line.
632
-
633
740
  ### Launching with natural language
634
741
 
635
- You can also start a built-in workflow by describing the task in chat. Atomic picks the matching workflow and fills in inputs from your request:
742
+ You can start a builtin in chat by naming its objective:
636
743
 
637
744
  ```text
638
- Run a deep codebase research workflow on how the rate limiter behaves under burst traffic.
745
+ Fan out repository research by subsystem, save each branch as an artifact, and synthesize cited findings.
639
746
  ```
640
747
 
641
748
  ```text
642
- Use the goal workflow to implement specs/2026-03-rate-limit.md, run the focused rate-limit tests, finish only when burst traffic returns 429 with Retry-After, and cap it at 5 turns.
749
+ Run open-claude-design to refresh the settings page hierarchy.
643
750
  ```
644
751
 
645
- ```text
646
- Use the ralph workflow to research a database-layer migration, implement it, review it, and set `create_pr=true` for final-stage PR handoff.
647
- ```
648
-
649
- ```text
650
- Run open-claude-design to refresh the settings page hierarchy as a page.
651
- ```
652
-
653
- If required inputs are missing or ambiguous, Atomic asks for missing inputs or opens the inline input picker before launching.
654
-
655
- Named workflows run in the background with a run id. See [Running Workflows](#running-workflows) for launch behavior, [Workflow Commands](#workflow-commands) for the common controls, and [Monitor and Control Runs](#monitor-and-control-runs) for steering, pausing, and resuming.
752
+ If required inputs are missing or ambiguous, Atomic asks for them or opens the inline picker. Named runs execute in the background and return a run id.
656
753
 
657
754
  ## Writing a Workflow
658
755
 
@@ -727,6 +824,7 @@ Authoring basics:
727
824
  - `workflow({ ... })` returns the workflow definition directly for discovery; there is no builder terminal step.
728
825
  - Workflow names normalize for lookup: trim, lowercase, convert whitespace/underscore to hyphen, remove other punctuation, and collapse hyphens.
729
826
  - `description` sets the listing text.
827
+ - `autoAttach: true` opens the graph overlay when an interactive top-level named launch through `/workflow <name>` or the registered `workflow` tool is accepted. Only exact `true` is retained on the compiled definition; omission and `false` do not opt a definition into auto-attachment. Existing input-form launch behavior is unchanged.
730
828
  - `inputs` declares typed user inputs.
731
829
  - `worktreeFromInputs` optionally maps input names to workflow-wide reusable Git worktree defaults.
732
830
  - `outputs` declares typed outputs that parent workflows receive from `ctx.workflow(childWorkflow, ...)`.
@@ -736,16 +834,65 @@ To migrate an existing file from the removed `defineWorkflow(...).compile()` bui
736
834
 
737
835
  `prompt` and `task` are aliases for task text inside authored workflow primitives. Prefer `prompt` because it mirrors lower-level `stage.prompt(...)`; `task` remains useful in `ctx.chain(...)` examples.
738
836
 
739
- Author workflows to create at least one tracked stage by calling `ctx.task()`, `ctx.chain()`, `ctx.parallel()`, `ctx.stage()`, or `ctx.workflow()` in the run body so each normal run has graph nodes to inspect, attach to, interrupt, resume, and render. Guard-only workflows may call `ctx.exit(...)` before creating a stage when they intentionally stop early.
837
+ Author workflows to create at least one tracked execution node by calling `ctx.task()`, `ctx.chain()`, `ctx.parallel()`, `ctx.stage()`, `ctx.workflow()`, or `ctx.tool()` in the run body so each normal run has graph work to inspect and render. Stage nodes remain the attachable, interruptible, resumable chat units; durable tool nodes are non-chat execution. Guard-only workflows may call `ctx.exit(...)` before creating a node when they intentionally stop early.
838
+
839
+ ### Dynamic topology must remain acyclic
840
+
841
+ Atomic `workflow({ run })` definitions are imperative, dynamic TypeScript. The final graph is materialized only while `run(ctx)` executes and may depend on runtime inputs, branches, loops, files or network data, model or human output, helpers, and nested workflows. Discovery can report module import and definition-shape diagnostics: it loads the module, checks its exports, schemas, and `run` function, and rejects failures observable at that point. It does not execute every control-flow path or compile `run` into a complete graph. TypeScript and discovery cannot prove arbitrary dynamic acyclicity.
842
+
843
+ **Cyclic workflow graphs are unsupported. Workflow authors and coding agents MUST NOT create self-edges or dependency edges from the current frontier to an existing ancestor. Every materialized execution topology must remain a DAG. If a cycle cannot be removed, redesign or stop before launch.**
844
+
845
+ Before launch, sketch the expected node and dependency shape for every branch and loop. Reject any proposed edge from the current frontier to the node itself or an ancestor. Bounded loops must create distinct tracked work for each iteration, with stable per-iteration identity and call order for resume/replay; never reopen an ancestor below its downstream work.
846
+
847
+ Invalid structural cycle:
848
+
849
+ ```text
850
+ Implement → Review → Validate
851
+ ▲ │
852
+ └────── Repair ──────┘
853
+ ```
854
+
855
+ `Repair` points back to the existing `Implement` ancestor.
856
+
857
+ Valid unrolled loop:
858
+
859
+ ```text
860
+ Implement
861
+
862
+ Review 1
863
+
864
+ Validate 1
865
+
866
+ Repair 1
867
+
868
+ Review 2
869
+
870
+ Validate 2
871
+ ```
872
+
873
+ Each iteration creates new tracked nodes, so the materialized topology stays acyclic.
874
+
875
+ Retained-session activity without new dependency work is not a loop edge:
876
+
877
+ ```text
878
+ Implement ✓
879
+ activity: processing follow-up
880
+ ```
881
+
882
+ Record such follow-up as non-topological activity metadata. Do not reopen the original node as a descendant of its own downstream review or validation work.
883
+
884
+ Runtime and replayed topology checks are the authoritative cycle boundary. If code that materializes or restores topology changes, cover every new parent edge with incremental edge checks and validate reconstruction during execution, replay, and DBOS hydration. Authoring guidance cannot replace those runtime checks or make malformed durable topology safe.
740
885
 
741
886
  ### Guiding Principles
742
887
 
743
888
  - **Locally scoped stage prompts** - Describe only the current stage's objective, inputs, expected outputs, and success criteria. Avoid references to other stages unless the current stage explicitly receives and needs that information, and avoid workflow-specific or stage-specific vocabulary that is not explained inside the current prompt. See [Locally Scoped Stage Prompts](#locally-scoped-stage-prompts) for the expanded contract.
889
+ - **DAG-only dynamic topology** - Treat `run(ctx)` as imperative code that materializes graph nodes at runtime. Keep every branch, loop iteration, and nested boundary acyclic; never add a self-edge or a parent edge to an ancestor, and redesign or stop before launch if one remains.
744
890
  - **Clear vocabulary** - Use clear software engineering terminology in self-described prompts.
745
891
  - **No regex gates** - Avoid hard-coded regular expressions that gate reviews or model outputs.
746
892
  - **Schema-backed gates** - Prefer schema-backed workflow stages (`ctx.stage(..., { schema })`, `ctx.chain` items, or `ctx.parallel` items) for review/gate decisions whenever the workflow must evaluate model output; a schema-enabled item receives the structured-output tool automatically. See [Evaluation and Quality Gates](#evaluation-and-quality-gates).
747
893
  - **Stages are model stages** - Treat atomic workflow units as language model stages, not deterministic tools.
748
894
  - **Small deterministic-gate stages** - When deterministic gates are needed, create small dedicated stages that instruct a model to run a specific tool or perform a specific check. This keeps gates adaptive to the current codebase while preserving explicit workflow structure.
895
+ - **Checkpoint workflow-owned side effects** - Prefer `ctx.tool(name, args, fn)` for filesystem writes, network mutations, external API actions, and other side effects orchestrated directly by the workflow definition. Atomic durably caches a completed call's serializable result, so resume returns that result without rerunning `fn`. Keep pure computation and side-effect-free transformations as ordinary TypeScript. Do not wrap agent-stage internals or every function call indiscriminately. Do not retain `ctx.tool` for detached work after the workflow executor returns: terminal admission is closed first, and a later call rejects before its callback, retries, graph node, or checkpoint can begin.
749
896
 
750
897
  ### Context engineering guidance
751
898
 
@@ -925,12 +1072,44 @@ if (!decision.approved) {
925
1072
 
926
1073
  When the stage session is idle, `sendUserMessage()` starts the next user turn immediately and waits for that turn to finish under the normal workflow stage guard: it observes the stage concurrency limiter, workflow abort/cancellation signals, MCP scoping, readiness gates, and session metadata capture. If `sendUserMessage()` is the first live call on a `ctx.stage(...)` handle, Atomic records the stage as a normal running/completed graph node. If it is called after a prior `prompt()`/`complete()` has already completed the stage, the follow-on turn still uses internal abort/cancellation and concurrency protection while reusing the completed stage session.
927
1074
 
928
- The `content` argument mirrors the Atomic SDK and accepts either a string or text/image content blocks such as `[{ type: "text", text: "Describe this" }, { type: "image", data: "...", mimeType: "image/png" }]` when the underlying stage session supports native user-message delivery. Non-native fallback adapters only support string content and reject text/image block arrays instead of stringifying them. Idle non-native fallback delivery sends the follow-on string to the already-selected session directly, so workflow model fallback retries are not re-run for that injected turn.
1075
+ The `content` argument mirrors the Atomic SDK and accepts either a string or text/image content blocks such as `[{ type: "text", text: "Describe this" }, { type: "image", data: "...", mimeType: "image/png" }]` when the underlying stage session supports native user-message delivery. Non-native fallback adapters only support string content and reject text/image block arrays instead of stringifying them. Idle non-native fallback delivery sends the follow-on string to the already-selected session directly, so workflow model fallback retries are not re-run for that injected turn. During a controlled pause, the runner gates every `stage.sendUserMessage()` before selecting either native delivery or the `prompt()` fallback; therefore an adapter that omits optional `sendUserMessage()` is not prompted until explicit resume, and the admitted delivery runs once afterward.
1076
+
1077
+ When the stage is already streaming, the message is queued as a follow-up by default; pass `{ deliverAs: "steer" }` to steer the active turn instead, or `{ deliverAs: "followUp" }` to be explicit. `deliverAs` only affects streaming delivery and is a no-op for idle sessions. Follow-on turns preserve the stage's `mcp.allow` / `mcp.deny` scope for the injected user turn, just like the original `prompt()`. The older `stage.steer(text)` and `stage.followUp(text)` methods are still available for queueing while a turn is active, but they do not start a new idle turn. If that stage is paused before delivery, Atomic preserves every queued item—type, optional data, duplicate entries, raw content, and order within its steering or follow-up queue—without starting a queued model turn or workflow continuation; late context-bearing traffic joins the hold, and the existing stage `resume` action releases the queue once.
1078
+
1079
+ The two streaming modes have distinct, deterministic timing:
1080
+
1081
+ - **`steer`** is delivered at the next steering boundary: after the current assistant response has finished executing its whole tool batch, and before the next model request. It is not injected between two tool calls emitted by the same assistant response.
1082
+ - **`followUp`** is delivered only when the agent would otherwise stop — no further tool-driven turns and no steering messages left.
1083
+
1084
+ Each queue is FIFO in admission order. There is no global FIFO *across* the two queues: steering keeps its semantic priority even when a follow-up was submitted earlier. A controlled pause or interrupt hold delays eligibility but preserves both the queue class and the order within it. An abort, kill, or fatal provider failure ends the turn without consuming what is still queued.
929
1085
 
930
- When the stage is already streaming, the message is queued as a follow-up by default; pass `{ deliverAs: "steer" }` to steer the active turn instead, or `{ deliverAs: "followUp" }` to be explicit. `deliverAs` only affects streaming delivery and is a no-op for idle sessions. Follow-on turns preserve the stage's `mcp.allow` / `mcp.deny` scope for the injected user turn, just like the original `prompt()`. The older `stage.steer(text)` and `stage.followUp(text)` methods are still available for queueing while a turn is active, but they do not start a new idle turn.
1086
+ A message you type into an attached stage chat and submit with Enter defaults to `steer`, matching normal (non-workflow) session steering, so a mid-run correction lands at the next steering boundary rather than at the end of the turn. Ctrl+F queues a follow-up instead. This is a property of the interactive surface, not of the API: an authored `stage.sendUserMessage()` call that names no `deliverAs` still defaults to follow-up while the stage is streaming.
931
1087
 
932
1088
  Custom `AgentSessionAdapter` implementations must make asynchronous idle-turn ownership observable through their public `subscribe()` stream: emit `{ type: "agent_start" }` when the submitted message has entered the turn, before waiting for that turn to finish, and emit `{ type: "agent_end", messages }` when that turn terminates. This applies both to native `sendUserMessage()` implementations and to the required `prompt()` fallback when `sendUserMessage` is omitted. Atomic retains the resulting logical ownership after releasing serialized message admission, so a concurrent second message is routed as steering/follow-up rather than another prompt even when the adapter publishes `isStreaming` asynchronously after `agent_start`. Correlated turn generations prevent a late end or older delivery settlement from clearing a newer owner. A subscription may replay earlier lifecycle state synchronously during registration; an untagged synchronous replay is treated as a snapshot and does not consume a later current-turn end. If an adapter can emit a delayed end for a replayed turn while a newer turn is active, it must attach the same stable string or numeric `turnId` to that replayed `agent_start` and its matching `agent_end`; Atomic then correlates the old end without disturbing current ownership. After `subscribe()` returns, adapters must emit `agent_start` only for newly started turns, never as a delayed replay of an earlier turn. Adapters that enter streaming synchronously are also detected through `isStreaming`; the bundled Atomic session additionally retains its internal handshake for compatibility. Implementations must not delay the current turn's `agent_start` until turn completion.
933
1089
 
1090
+ Native queue pause is an optional `StageSessionRuntime` optimization for custom adapters:
1091
+
1092
+ ```ts
1093
+ interface StageSessionRuntime {
1094
+ readonly queuedMessagesPaused?: boolean;
1095
+ pauseQueuedMessages?(): void;
1096
+ resumeQueuedMessages?(): boolean | Promise<boolean>;
1097
+ }
1098
+ ```
1099
+
1100
+ Existing adapters may omit all three members and continue using the runner's prior fallback pause behavior: the active call is aborted, the workflow objective remains suspended, and public deliveries admitted through the stage handle wait until explicit resume. Adapters that implement the native capability must provide both methods. `pauseQueuedMessages()` synchronously gates raw queued steer/follow-up work before `abort()` settles; `resumeQueuedMessages()` releases that hold without starting a provider turn and returns `true` only when raw held work was released. Atomic's bundled `AgentSession` implements this stronger native hold, which preserves already-queued and late native traffic verbatim.
1101
+
1102
+ Reporting an already-held queue is a second optional `StageSessionRuntime` capability:
1103
+
1104
+ ```ts
1105
+ interface StageSessionRuntime {
1106
+ getSteeringMessages?(): readonly string[];
1107
+ getFollowUpMessages?(): readonly string[];
1108
+ }
1109
+ ```
1110
+
1111
+ A session announces its queue by `queue_update`, so a queue that exists before Atomic's listeners reach that session is announced to nobody — which happens when a retiring session hands its pending messages to the session replacing it, and when a retained session is reopened for post-mortem chat holding what it was queued. Atomic reads these two methods once, as it attaches a session, and replays the missed snapshot to that stage's listeners; every later change still arrives as an ordinary event. An adapter that omits them loses nothing it had before: only a queue predating the attach is invisible, and a session that starts empty never had one.
1112
+
934
1113
  Externally produced traffic has a separate lifecycle rule. Intercom messages and async bash/subagent completion notices received while a workflow stage generation is still open are admitted through the stage AgentSession's native steering/follow-up queue. For a busy stage, admission into the generation boundary happens synchronously before the exact foreground subagent owner's probe/commit detach handshake; model-visible queue insertion waits inside that admitted delivery until the handshake is claimed or falls back after an unclaimed/vanished owner. A commit accepted within a parallel foreground group releases aggregate supervision for every active sibling while retaining their process and eventual-result ownership. Reserving admission before the asynchronous handshake prevents terminal close from overtaking an in-flight Intercom delivery, while waiting inside the reservation prevents a blocking child request from queueing behind either a single foreground tool call or a parallel aggregate still waiting on another child. The stage drains already-admitted work before publishing its terminal snapshot, including schema-backed turns that have already called `structured_output`.
935
1114
 
936
1115
  Closing the generation is atomic with admission: a notification admitted first belongs to that stage, while ordinary detached notifications arriving after close cannot reopen or mutate the completed stage and are surfaced once through the main-chat notification path instead. A blocking sibling `intercom.ask` is the deliberate exception: when the completed stage retains a valid conversation, Atomic schedules a post-mortem turn in that conversation so it can inspect the exact ask and reply without changing terminal workflow state. Failed running-stage admission and failed post-mortem admission return correlated actionable errors to the asker instead of consuming the full reply timeout.
@@ -987,6 +1166,8 @@ Control-signal probing is fail-closed. When the executor inspects an arbitrary t
987
1166
 
988
1167
  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.
989
1168
 
1169
+ Compose nested workflows through these tracked boundaries; do not call a child definition's `run` function recursively. Each repeated child call must remain a distinct boundary with stable iteration identity and call order so execution, replay, and hydration preserve an acyclic parent/child topology.
1170
+
990
1171
  For workflows intended to be called by parent workflows, declare every field a parent should rely on in the child workflow's `outputs` object, including `result`. No output exists without declaration: a child exposes exactly its declared outputs, and returning an undeclared key fails the child call.
991
1172
 
992
1173
  #### Compose with a user-defined workflow
@@ -1048,107 +1229,75 @@ export default workflow({
1048
1229
 
1049
1230
  #### Compose with builtin workflows
1050
1231
 
1051
- Parent workflows can call exported builtin workflow definitions like user-defined workflows. Use the barrel export to import several builtins:
1232
+ Builtin workflow definitions work like user-defined child definitions. Import several from the barrel:
1052
1233
 
1053
1234
  ```ts
1054
- import { deepResearchCodebase, goal, openClaudeDesign, ralph } from "@bastani/workflows/builtin";
1235
+ import {
1236
+ adversarialVerification,
1237
+ classifyAndAct,
1238
+ fanOutAndSynthesize,
1239
+ generateAndFilter,
1240
+ goal,
1241
+ loopUntilDone,
1242
+ openClaudeDesign,
1243
+ ralph,
1244
+ tournament,
1245
+ } from "@bastani/workflows/builtin";
1055
1246
  ```
1056
1247
 
1057
- Or import one builtin from its individual module path:
1248
+ Or import one individual module:
1058
1249
 
1059
1250
  ```ts
1060
- import deepResearchCodebase from "@bastani/workflows/builtin/deep-research-codebase";
1061
1251
  import goal from "@bastani/workflows/builtin/goal";
1062
- import openClaudeDesign from "@bastani/workflows/builtin/open-claude-design";
1063
1252
  import ralph from "@bastani/workflows/builtin/ralph";
1064
1253
  ```
1065
1254
 
1066
- Common builtin import targets:
1067
-
1068
- | Workflow name | TypeScript export | Individual module path | Typical use inside another workflow |
1069
- |---|---|---|---|
1070
- | `deep-research-codebase` | `deepResearchCodebase` | `@bastani/workflows/builtin/deep-research-codebase` | Gather broad repo research before planning, synthesis, or implementation. |
1071
- | `goal` | `goal` | `@bastani/workflows/builtin/goal` | Run a bounded implementation/check loop with receipts and reviewer-gated completion; pass `create_pr=true` to authorize only the final PR-creation stage after approval. |
1072
- | `ralph` | `ralph` | `@bastani/workflows/builtin/ralph` | Run an autonomous job that benefits from Ralph's durable research/orchestrate/review loop; pass `create_pr=true` to authorize only the final PR-creation stage. |
1073
- | `open-claude-design` | `openClaudeDesign` | `@bastani/workflows/builtin/open-claude-design` | Generate and refine a UI/design artifact and handoff spec. |
1074
-
1075
- Example parent workflow that runs builtin deep research, then chooses either `goal` or `ralph` as the nested implementation runner:
1255
+ Example parent that maps a repository and verifies the synthesis:
1076
1256
 
1077
1257
  ```ts
1078
1258
  import { workflow } from "@bastani/workflows";
1079
1259
  import { Type } from "typebox";
1080
- import { deepResearchCodebase, goal, ralph } from "@bastani/workflows/builtin";
1260
+ import { adversarialVerification, fanOutAndSynthesize } from "@bastani/workflows/builtin";
1081
1261
 
1082
1262
  export default workflow({
1083
- name: "research-then-implement",
1084
- description: "Run deep research, then dispatch to goal or Ralph.",
1085
- inputs: {
1086
- topic: Type.String(),
1087
- runner: Type.Union([Type.Literal("goal"), Type.Literal("ralph")], {
1088
- default: "goal",
1089
- description: "Use goal for a durable ledger and reviewer gates, or Ralph for a durable research-first pipeline.",
1090
- }),
1091
- },
1263
+ name: "research-and-verify",
1264
+ description: "Map repository slices, synthesize evidence, and verify the report.",
1265
+ inputs: { topic: Type.String() },
1092
1266
  outputs: {
1093
- research_doc_path: Type.Optional(Type.String({ description: "Path to the deep-research document used for implementation." })),
1094
- runner: Type.String({ description: "Which nested runner executed: \"goal\" or \"ralph\"." }),
1095
- // Genuinely dynamic: the nested runner (goal vs ralph) is chosen at runtime and
1096
- // each exposes a different declared output shape, so a loose object is appropriate here.
1097
- // When a child's outputs are known and fixed, declare the precise shape instead.
1098
- implementation: Type.Object({}, { additionalProperties: true, description: "Declared outputs from the nested implementation workflow." }),
1267
+ report_path: Type.String(),
1268
+ approved: Type.Boolean(),
1099
1269
  },
1100
1270
  run: async (ctx) => {
1101
- const topic = String(ctx.inputs.topic);
1102
- const research = await ctx.workflow(deepResearchCodebase, {
1103
- inputs: { prompt: topic, max_concurrency: 4 },
1104
- stageName: "deep research",
1271
+ const research = await ctx.workflow(fanOutAndSynthesize, {
1272
+ inputs: {
1273
+ prompt: `Partition repository research for: ${ctx.inputs.topic}. Save cited findings per slice and synthesize conflicts.`,
1274
+ max_branches: 6,
1275
+ },
1276
+ stageName: "repository research",
1105
1277
  });
1106
1278
  if (research.exited === true) {
1107
- return ctx.exit({ status: research.status, reason: research.exitReason ?? "deep research stopped early" });
1108
- }
1109
-
1110
- if (String(ctx.inputs.runner) === "ralph") {
1111
- const implementation = await ctx.workflow(ralph, {
1112
- inputs: {
1113
- prompt: `Use the research document at ${String(research.outputs.research_doc_path)} to plan, implement, and review: ${topic}`,
1114
- create_pr: true,
1115
- },
1116
- stageName: "ralph implementation",
1117
- });
1118
- if (implementation.exited === true) {
1119
- return ctx.exit({ status: implementation.status, reason: implementation.exitReason ?? "ralph stopped early" });
1120
- }
1121
-
1122
- return {
1123
- research_doc_path: research.outputs.research_doc_path,
1124
- runner: "ralph",
1125
- implementation: implementation.outputs,
1126
- };
1279
+ return ctx.exit({ status: research.status, reason: research.exitReason ?? "research stopped early" });
1127
1280
  }
1128
1281
 
1129
- const implementation = await ctx.workflow(goal, {
1130
- inputs: {
1131
- objective: `Use the research document at ${String(research.outputs.research_doc_path)} to implement and validate: ${topic}`,
1132
- max_turns: 3,
1133
- },
1134
- stageName: "goal implementation",
1282
+ const verification = await ctx.workflow(adversarialVerification, {
1283
+ inputs: { task: `Verify the cited report at ${research.outputs.synthesis_path}` },
1284
+ stageName: "verify research report",
1135
1285
  });
1136
- if (implementation.exited === true) {
1137
- return ctx.exit({ status: implementation.status, reason: implementation.exitReason ?? "goal stopped early" });
1286
+ if (verification.exited === true) {
1287
+ return ctx.exit({ status: verification.status, reason: verification.exitReason ?? "verification stopped early" });
1138
1288
  }
1139
1289
 
1140
1290
  return {
1141
- research_doc_path: research.outputs.research_doc_path,
1142
- runner: "goal",
1143
- implementation: implementation.outputs,
1291
+ report_path: research.outputs.synthesis_path,
1292
+ approved: verification.outputs.approved,
1144
1293
  };
1145
1294
  },
1146
1295
  });
1147
1296
  ```
1148
1297
 
1149
- Passing a workflow definition directly to `ctx.workflow(...)` uses the child workflow's normalized name for replay metadata and default boundary labels (`shared-research` for the user-defined example above, or builtin names such as `deep-research-codebase`, `goal`, and `ralph`).
1298
+ Passing a definition directly to `ctx.workflow(...)` uses the child definition's normalized name for replay metadata and the default boundary label.
1150
1299
 
1151
- `ctx.workflow(workflowDefinition)` starts a nested workflow behind a parent boundary stage named `workflow:<workflow-name>` by default. User-facing status and graph views flatten that child into the parent run, so composition behaves like inlining the child workflow code: child stages, HIL prompt nodes, and deeper imported workflows appear in one expanded graph. The nested run id remains available internally for routing attach/pause/interrupt/resume to the correct live stage, but it is not shown as a separate top-level `/workflow status` entry. The returned child result has:
1300
+ `ctx.workflow(workflowDefinition)` starts a nested workflow behind a parent boundary stage named `workflow:<workflow-name>` by default. User-facing status and graph views flatten a valid child graph into the parent run recursively, so composition behaves like inlining the child workflow code: child stages, HIL prompt nodes, and deeper imported workflows appear in one expanded graph. When Atomic hides a valid import boundary, every boundary parent connects to every child root, and every child terminal connects to each downstream dependent of the boundary. Every visible child node keeps a distinct virtual graph ID and its exact `{ runId, stageId }` control target, even when sibling or repeated child workflows reuse local stage IDs or names. Attach, send, pause, interrupt, resume, stage selection, and post-mortem chat therefore route to the nested run and stage that actually own the node. Implementation-owned child runs are not shown as separate top-level `/workflow status` entries. The returned child result has:
1152
1301
 
1153
1302
  | Field | Meaning |
1154
1303
  |---|---|
@@ -1182,9 +1331,9 @@ A child exposes only outputs declared in `outputs` and returned from `run` or su
1182
1331
 
1183
1332
  Missing required outputs, schema type mismatches, and non-JSON-serializable returned values fail normal child completion before the parent continues; child `ctx.exit({ outputs })` allows missing required outputs but still validates every provided key and sets `child.exited === true` so parent code must handle the partial shape.
1184
1333
 
1185
- Pass only workflow definitions to `ctx.workflow(...)`. Import reusable workflows with TypeScript `import` statements first; use `/workflow` names such as `goal` only for launching named runs, not as `ctx.workflow(...)` arguments. If a module is missing or does not export a workflow definition, workflow discovery fails when loading that module. Nested child workflows count against `maxDepth` (default `4` total workflow levels).
1334
+ Pass only workflow definitions to `ctx.workflow(...)`. Import reusable workflows with TypeScript `import` statements first; registry names are only for top-level named runs, not `ctx.workflow(...)` arguments. If a module is missing or does not export a workflow definition, workflow discovery fails when loading that module. Nested child workflows count against `maxDepth` (default `4` total workflow levels).
1186
1335
 
1187
- The graph includes both the parent boundary node and the imported child workflow's own stages while the child is loading/running, so the user can observe progress and interrupt sub-workflows before they complete. Completed boundaries still retain the child workflow name, child run id prefix, and exposed output count for replay/debugging. Skipped or failed boundaries do not retain child-edge metadata (`workflowChild` / `workflowChildRun`), and graph expansion ignores any stale non-completed boundary metadata from older persisted sessions instead of flattening an unrelated child run.
1336
+ Atomic hides an import boundary only when the referenced child run is non-empty and reciprocally identifies that parent run and boundary stage. The same rule applies recursively at deeper nesting levels. If no valid child graph can stand in for the boundary—including a failed or skipped boundary, a missing or empty child graph, stale or mismatched ownership metadata, or a recursive link that cannot produce a valid expansion—the graph keeps the boundary summary node instead of flattening an unrelated or invalid child. Running and completed boundaries with valid child graphs are flattened; completed summaries still retain the child workflow name, child run id prefix, and exposed output count for replay/debugging when fallback is required.
1188
1337
 
1189
1338
  Use `stageName` when the parent needs a more specific label, but keep it concise so the child summary remains readable in the graph.
1190
1339
 
@@ -1194,6 +1343,412 @@ The child executor writes each skipped child `workflow.stage.end` exactly once b
1194
1343
 
1195
1344
  Continuation replay treats the parent child-workflow boundary as the durable checkpoint: a previously completed child boundary replays with the original exposed outputs and without re-running the child, while a child that failed or was interrupted before completion starts again from the beginning on continuation. If `ctx.exit(...)` wins while a completed boundary is being replayed but before replay finalization, the boundary is finalized as skipped and its preloaded child metadata is omitted from store, persistence, restore, and expanded graph views.
1196
1345
 
1346
+ ## Scope-Guard Starter Pattern
1347
+
1348
+ Use a scope guard when a worker may find valid adjacent work and a later reviewer or repair stage could treat that finding as part of the current task. The guard is an independent reviewer built from existing workflow composition. It controls scope only: code reviewers and deterministic checks still decide whether the candidate is correct.
1349
+
1350
+ Do not add a `watchdog` field, stage option, or custom runtime primitive for this pattern. Choose the lightest existing shape that fits the boundary:
1351
+
1352
+ | Need | Shape |
1353
+ |---|---|
1354
+ | One check at a plan, handoff, repair, or completion boundary | A fresh `ctx.task(...)` downstream of the worker |
1355
+ | One checker session that needs several prompts or explicit timing | A fresh `ctx.stage(...)`, with all of its turns completed before downstream dependency work starts |
1356
+ | Steering while the worker generation is open | Fresh guard and forked worker items in one `ctx.parallel(...)`, using inherited same-group Intercom |
1357
+
1358
+ ### Canonical scope contract
1359
+
1360
+ Create one inspectable contract artifact before guarded work starts. Treat it as immutable for that run and include:
1361
+
1362
+ - the literal objective;
1363
+ - required scope and allowed files or systems;
1364
+ - explicit non-goals;
1365
+ - stage boundaries and expected lifecycle order; and
1366
+ - acceptance criteria and required evidence.
1367
+
1368
+ Every worker, guard, reviewer, and repair continuation reads the same path. Do not copy the contract into several prompts that can drift, and do not let a stage overwrite it. If a human changes the objective, write a new versioned contract and start a new guarded unit of work instead of silently changing the active contract.
1369
+
1370
+ Large plans, diffs, logs, reviewer reports, and decision history belong in artifacts. Pass their paths with `reads` where the primitive supports it, tell fresh stages to read the needed sections, and keep Intercom messages short. A fresh guard must not rely on a sibling transcript or hidden graph state.
1371
+
1372
+ ### Decision contract and actions
1373
+
1374
+ For each proposed material expansion, the guard records one evidence-backed classification and action:
1375
+
1376
+ | Classification | Evidence threshold | Action |
1377
+ |---|---|---|
1378
+ | `required` | The literal objective, stated review feedback, acceptance criteria, or required validation directly demands it. | Permit the smallest change that satisfies that demand. |
1379
+ | `dependent` | The selected in-scope implementation would otherwise violate a cited existing contract or proven prerequisite. | Permit only the prerequisite and record the contract that makes it necessary. |
1380
+ | `follow-up` | The finding is valid but the current objective and selected implementation do not require it. | Record it once and continue without implementing it. It does not block this run. |
1381
+ | `unclear` | Evidence cannot decide a material product, public API, security, migration, or scope choice. | Block that expansion and request a supervisor or human decision through a blocking Intercom exchange or `ctx.ui`. |
1382
+
1383
+ Use a stable key for each proposal, such as `public-error-shape` or `transport-timeout`. Keep one row per key, merge repeated evidence into that row, and cap the log (the examples use 20 entries). Do not let the guard and worker echo the same finding back and forth. The persisted decision artifact is the source for later review and repair stages; chat messages only steer the open turn.
1384
+
1385
+ A useful decision record contains `key`, `classification`, concrete `evidence`, and `action`. A guard failure or missing coordination channel never means approval.
1386
+
1387
+ ### Fallback policy
1388
+
1389
+ Pick and document one policy before the run:
1390
+
1391
+ | Policy | When Intercom or the guard is unavailable |
1392
+ |---|---|
1393
+ | `warn` | Mark live steering unavailable, forbid unreviewed expansion, and run a fresh boundary `ctx.task(...)` before the next material change. |
1394
+ | `block` | Stop before expansion and request a decision with `ctx.ui`; in headless mode, fail with the unresolved decision instead of widening scope. |
1395
+ | `off` | Skip the guard only because the workflow author or user explicitly disabled it. Preserve the original scope and do not infer approval for adjacent work. |
1396
+
1397
+ Use `block` for risky public contracts, data changes, security behavior, releases, or publication. `warn` is a practical default when a boundary review can replace live steering. Never degrade silently from `block` to `warn` or from guarded execution to `off`.
1398
+
1399
+ Intercom capability is tool-gated. A stage with `noTools: "all"`, a `tools` allowlist that omits `intercom`, or `excludedTools: ["intercom"]` cannot use live steering. Use a boundary task or the selected fallback policy for that stage.
1400
+
1401
+ ### Lifecycle, topology, and context rules
1402
+
1403
+ - Keep the graph acyclic. A boundary guard is an ordinary downstream reviewer node. Live Intercom steering is activity inside already-running parallel stages, not a new graph edge.
1404
+ - Never make a guard watch itself, recursively start another guard, reopen a terminal task, or add a dependency from the current frontier to an ancestor. Complete all turns on a retained guard before starting downstream dependency work.
1405
+ - Messages admitted before a worker generation closes drain through that stage boundary. Late messages do not reopen or mutate its terminal workflow state. Give each live branch a bounded stop rule; `ctx.parallel(...)` releases downstream work only after all started branches settle, even when one finishes first.
1406
+ - Persist decisions under stable keys. Pause/resume, model fallback, durable replay, and nested workflows then reread the artifact instead of sending duplicate interventions.
1407
+ - Omit `group` for ordinary use. The worker, guard, nested workflows, and delegated subagents inherit the top-level workflow invocation's stable Intercom group. Set an explicit group only for intentional isolation; an override separates that stage from ordinary same-group peers.
1408
+ - Use `context: "fresh"` for guards, reviewers, and judges. They should see only the contract, candidate, decision artifacts, and current files.
1409
+ - Use `context: "fork"` plus `forkFromSessionFile` for implementation, debugging, and repair roles that need continuity with an owned earlier session. `context: "fork"` alone does not name a fork source; an initial worker with no prior lineage may start fresh. A later continuation should use the earlier worker's `sessionFile` when available. Do not fork an independent guard from the worker it judges.
1410
+ - Send a forked continuation only the delta after the fork point: new evidence, the decision artifact, any human answer, and the next action. Keep the full shared contract in its canonical file.
1411
+
1412
+ Expected lifecycle state is not a defect. If the contract says `candidate → validation → approval → push/publish`, a guard at the candidate or validation boundary must not reject the patch merely because it is unpushed or unpublished. Only the later publication stage owns that action.
1413
+
1414
+ ### Runnable boundary-task example
1415
+
1416
+ Use a fresh task when one check at a material boundary is enough. This complete project workflow keeps the worker lineage coherent, saves a structured decision log, and sends ambiguity to `ctx.ui` before the continuation:
1417
+
1418
+ ```ts
1419
+ // .atomic/workflows/scope-guard-boundary.ts
1420
+ import { workflow } from "@bastani/workflows";
1421
+ import { Type, type Static } from "typebox";
1422
+
1423
+ const decisionLogSchema = Type.Object(
1424
+ {
1425
+ decisions: Type.Array(
1426
+ Type.Object(
1427
+ {
1428
+ key: Type.String(),
1429
+ classification: Type.Union([
1430
+ Type.Literal("required"),
1431
+ Type.Literal("dependent"),
1432
+ Type.Literal("follow-up"),
1433
+ Type.Literal("unclear"),
1434
+ ]),
1435
+ evidence: Type.Array(Type.String(), { minItems: 1 }),
1436
+ action: Type.String(),
1437
+ },
1438
+ { additionalProperties: false },
1439
+ ),
1440
+ { maxItems: 20 },
1441
+ ),
1442
+ },
1443
+ { additionalProperties: false },
1444
+ );
1445
+
1446
+ type DecisionLog = Static<typeof decisionLogSchema>;
1447
+
1448
+ function continueWorker(sessionFile: string | undefined) {
1449
+ return sessionFile === undefined
1450
+ ? { context: "fork" as const }
1451
+ : { context: "fork" as const, forkFromSessionFile: sessionFile };
1452
+ }
1453
+
1454
+ export default workflow({
1455
+ name: "scope-guard-boundary",
1456
+ description: "Check scope at an implementation boundary.",
1457
+ inputs: {
1458
+ scope_contract: Type.String(),
1459
+ artifact_dir: Type.String({ default: ".atomic/workflows/runs/scope-guard-boundary" }),
1460
+ },
1461
+ outputs: {
1462
+ decision_log: Type.String(),
1463
+ },
1464
+ run: async (ctx) => {
1465
+ const contract = ctx.inputs.scope_contract;
1466
+ const candidate = `${ctx.inputs.artifact_dir}/candidate.md`;
1467
+ const decisionLog = `${ctx.inputs.artifact_dir}/scope-decisions.json`;
1468
+
1469
+ const worker = await ctx.task("prepare candidate", {
1470
+ context: "fresh",
1471
+ reads: [contract],
1472
+ prompt: [
1473
+ `Read the immutable scope contract at ${contract}.`,
1474
+ "Implement only the required scope and summarize changed files and evidence.",
1475
+ "Do not implement valid adjacent findings; include them in the candidate summary.",
1476
+ ].join("\n"),
1477
+ output: candidate,
1478
+ outputMode: "file-only",
1479
+ });
1480
+
1481
+ const checked = await ctx.task("scope boundary", {
1482
+ context: "fresh",
1483
+ reads: [contract, candidate],
1484
+ schema: decisionLogSchema,
1485
+ prompt: [
1486
+ `Read ${contract} and ${candidate}. Inspect the current candidate.`,
1487
+ "Classify each material expansion as required, dependent, follow-up, or unclear.",
1488
+ "Cite concrete evidence and state the action. Return at most 20 unique keys.",
1489
+ "Follow-up work must not block. Unclear expansion requires a human decision.",
1490
+ "Judge scope only; do not approve implementation correctness.",
1491
+ ].join("\n"),
1492
+ output: decisionLog,
1493
+ outputMode: "file-only",
1494
+ });
1495
+
1496
+ if (checked.structured === undefined) throw new Error("scope guard returned no decision log");
1497
+ const decisions = checked.structured as DecisionLog;
1498
+ const unclear = decisions.decisions.filter((item) => item.classification === "unclear");
1499
+ const humanDecision = unclear.length === 0
1500
+ ? "No unclear scope decisions."
1501
+ : await ctx.ui.editor([
1502
+ "Resolve these scope decisions before the worker continues:",
1503
+ ...unclear.map((item) => `- ${item.key}: ${item.evidence.join("; ")}`),
1504
+ ].join("\n"));
1505
+
1506
+ await ctx.task("continue worker", {
1507
+ ...continueWorker(worker.sessionFile),
1508
+ reads: [contract, decisionLog],
1509
+ prompt: [
1510
+ `Read the decision log at ${decisionLog}.`,
1511
+ `Human decision: ${humanDecision}`,
1512
+ "Apply only required and dependent actions. Record follow-up items without implementing them.",
1513
+ "The original contract and output rules remain unchanged.",
1514
+ ].join("\n"),
1515
+ });
1516
+
1517
+ return { decision_log: decisionLog };
1518
+ },
1519
+ });
1520
+ ```
1521
+
1522
+ The materialized order is `prepare candidate → scope boundary → optional human prompt → continue worker`. Each step is new downstream work; no edge points back to the original worker.
1523
+
1524
+ ### Runnable retained-stage example
1525
+
1526
+ Use `ctx.stage(...)` when one independent checker needs a retained conversation. Run its tracked `prompt()` once, then use `sendUserMessage(...)` for a bounded post-prompt turn on that same session; a second tracked `prompt()` on the finalized stage is invalid.
1527
+
1528
+ ```ts
1529
+ // .atomic/workflows/scope-guard-retained.ts
1530
+ import { workflow } from "@bastani/workflows";
1531
+ import { Type } from "typebox";
1532
+
1533
+ function continueWorker(sessionFile: string | undefined) {
1534
+ return sessionFile === undefined
1535
+ ? { context: "fork" as const }
1536
+ : { context: "fork" as const, forkFromSessionFile: sessionFile };
1537
+ }
1538
+
1539
+ export default workflow({
1540
+ name: "scope-guard-retained",
1541
+ description: "Retain one independent checker for a bounded multi-turn review.",
1542
+ inputs: {
1543
+ scope_contract: Type.String(),
1544
+ artifact_dir: Type.String({ default: ".atomic/workflows/runs/scope-guard-retained" }),
1545
+ },
1546
+ outputs: {
1547
+ decision_log: Type.String(),
1548
+ },
1549
+ run: async (ctx) => {
1550
+ const contract = ctx.inputs.scope_contract;
1551
+ const candidate = `${ctx.inputs.artifact_dir}/candidate.md`;
1552
+ const decisionLog = `${ctx.inputs.artifact_dir}/scope-decisions.md`;
1553
+
1554
+ const worker = await ctx.task("prepare candidate", {
1555
+ context: "fresh",
1556
+ reads: [contract],
1557
+ prompt: `Read ${contract}, prepare the scoped candidate, and summarize evidence.`,
1558
+ output: candidate,
1559
+ outputMode: "file-only",
1560
+ });
1561
+
1562
+ const guard = ctx.stage("retained scope guard", { context: "fresh" });
1563
+ await guard.prompt([
1564
+ `Read the immutable contract at ${contract} and candidate at ${candidate}.`,
1565
+ "Classify each material proposal as required, dependent, follow-up, or unclear.",
1566
+ "Write one deduplicated row per stable key, at most 20 rows, with evidence and action.",
1567
+ "Follow-up means record only; unclear means request a human decision.",
1568
+ "Judge scope only, not implementation correctness.",
1569
+ ].join("\n"), { output: decisionLog, outputMode: "file-only" });
1570
+ await guard.sendUserMessage([
1571
+ `Recheck the complete candidate against ${contract}.`,
1572
+ `If evidence changes a classification, use the write tool to replace ${decisionLog}.`,
1573
+ "Keep the artifact complete, deduplicated, and bounded to 20 rows; do not return a delta.",
1574
+ "If no decision changes, leave the artifact unchanged and say so.",
1575
+ ].join("\n"));
1576
+
1577
+
1578
+ const humanDecision = await ctx.ui.editor(
1579
+ `Review ${decisionLog}. Resolve each unclear row, or state that none remain.`,
1580
+ );
1581
+
1582
+ await ctx.task("apply retained decision", {
1583
+ ...continueWorker(worker.sessionFile),
1584
+ reads: [contract, decisionLog],
1585
+ prompt: [
1586
+ `Read ${decisionLog}.`,
1587
+ `Human decision: ${humanDecision}`,
1588
+ "Apply required and dependent actions only. Do not implement follow-up rows.",
1589
+ ].join("\n"),
1590
+ });
1591
+
1592
+ return { decision_log: decisionLog };
1593
+ },
1594
+ });
1595
+ ```
1596
+
1597
+ The tracked prompt creates the guard node and decision artifact. `sendUserMessage(...)` starts one retained follow-on turn after that node finalizes; it does not create or reopen graph work. The follow-on updates the artifact directly only when evidence changes, and it finishes before the human prompt or worker continuation starts.
1598
+
1599
+ ### Runnable live-parallel example
1600
+
1601
+ Use a live peer only when steering during generation adds clear value. Both branches omit `group`, so Atomic places them in the workflow invocation's same Intercom group. The guard first performs a bounded Intercom status handshake and returns; later blocking `intercom.ask` calls can reopen its retained conversation for classification. After both parallel branches settle, a fresh task reads that transcript and persists the final deduplicated decision artifact. Normal late sends are not part of this handshake.
1602
+
1603
+ ```ts
1604
+ // .atomic/workflows/scope-guard-live.ts
1605
+ import { workflow } from "@bastani/workflows";
1606
+ import { Type, type Static } from "typebox";
1607
+
1608
+ const coordinationSchema = Type.Object(
1609
+ {
1610
+ status: Type.Union([
1611
+ Type.Literal("available"),
1612
+ Type.Literal("unavailable"),
1613
+ Type.Literal("off"),
1614
+ ]),
1615
+ evidence: Type.String(),
1616
+ },
1617
+ { additionalProperties: false },
1618
+ );
1619
+
1620
+ type Coordination = Static<typeof coordinationSchema>;
1621
+
1622
+ function workerContext(sessionFile: string | undefined) {
1623
+ return sessionFile === undefined
1624
+ ? { context: "fresh" as const }
1625
+ : { context: "fork" as const, forkFromSessionFile: sessionFile };
1626
+ }
1627
+
1628
+ export default workflow({
1629
+ name: "scope-guard-live",
1630
+ description: "Run a worker with a live same-group scope peer.",
1631
+ inputs: {
1632
+ scope_contract: Type.String(),
1633
+ worker_session_file: Type.Optional(Type.String({
1634
+ description: "Earlier worker session to continue; omit when no worker lineage exists.",
1635
+ })),
1636
+ fallback_policy: Type.Union([
1637
+ Type.Literal("warn"),
1638
+ Type.Literal("block"),
1639
+ Type.Literal("off"),
1640
+ ], { default: "warn" }),
1641
+ artifact_dir: Type.String({ default: ".atomic/workflows/runs/scope-guard-live" }),
1642
+ },
1643
+ outputs: {
1644
+ decision_log: Type.String(),
1645
+ review: Type.String(),
1646
+ },
1647
+ run: async (ctx) => {
1648
+ const contract = ctx.inputs.scope_contract;
1649
+ const fallbackPolicy = ctx.inputs.fallback_policy;
1650
+ const candidate = `${ctx.inputs.artifact_dir}/candidate.md`;
1651
+ const coordinationPath = `${ctx.inputs.artifact_dir}/scope-coordination.json`;
1652
+ const decisionLog = `${ctx.inputs.artifact_dir}/scope-decisions.md`;
1653
+
1654
+ const branches = await ctx.parallel(
1655
+ [
1656
+ {
1657
+ name: "worker",
1658
+ ...workerContext(ctx.inputs.worker_session_file),
1659
+ reads: [contract],
1660
+ prompt: [
1661
+ `Read the immutable scope contract at ${contract}.`,
1662
+ `The declared Intercom fallback policy is ${fallbackPolicy}.`,
1663
+ "Unless policy is off, connect to Intercom and find the scope-guard peer in this workflow group.",
1664
+ "Before material expansion, send at most 20 blocking asks with a stable key and evidence.",
1665
+ "Apply required or dependent replies only. Record follow-up findings without implementing them.",
1666
+ "For an unclear reply, wait for human input instead of widening scope.",
1667
+ "If Intercom is unavailable: warn forbids expansion, block stops before expansion, and off keeps the original scope without a guard.",
1668
+ "Return the complete candidate summary; do not send a late ready notice.",
1669
+ ].join("\n"),
1670
+ output: candidate,
1671
+ outputMode: "file-only",
1672
+ },
1673
+ {
1674
+ name: "scope guard",
1675
+ context: "fresh",
1676
+ reads: [contract],
1677
+ schema: coordinationSchema,
1678
+ prompt: [
1679
+ `Read the immutable scope contract at ${contract}.`,
1680
+ `The declared fallback policy is ${fallbackPolicy}.`,
1681
+ "If policy is off, do not connect; return status off with evidence.",
1682
+ "Otherwise call intercom status once and return available or unavailable with evidence.",
1683
+ "When a later blocking ask reopens this conversation, classify its stable key as required, dependent, follow-up, or unclear.",
1684
+ "Reply with concrete evidence and one action. Do not approve implementation correctness.",
1685
+ "Never originate another guard or send a normal late message.",
1686
+ ].join("\n"),
1687
+ output: coordinationPath,
1688
+ outputMode: "file-only",
1689
+ },
1690
+ ],
1691
+ { concurrency: 2, failFast: true },
1692
+ );
1693
+
1694
+ const guardResult = branches[1];
1695
+ if (guardResult?.structured === undefined) throw new Error("scope guard returned no coordination status");
1696
+ const coordination = guardResult.structured as Coordination;
1697
+ const guardTranscript = coordination.status === "available"
1698
+ ? guardResult.sessionFile
1699
+ : undefined;
1700
+ const transcriptReads = guardTranscript === undefined ? [] : [guardTranscript];
1701
+ const effectiveStatus = fallbackPolicy === "off"
1702
+ ? "off"
1703
+ : coordination.status === "available" && guardTranscript !== undefined
1704
+ ? "available"
1705
+ : "unavailable";
1706
+ const humanDecision = effectiveStatus === "unavailable" && fallbackPolicy === "block"
1707
+ ? await ctx.ui.editor("Intercom is unavailable. Resolve scope before any blocked expansion continues.")
1708
+ : "No fallback human decision required.";
1709
+
1710
+ if (fallbackPolicy === "off") {
1711
+ await ctx.task("record scope guard off", {
1712
+ context: "fresh",
1713
+ prompt: "Record that the scope guard was explicitly off and that no expansion was approved.",
1714
+ output: decisionLog,
1715
+ outputMode: "file-only",
1716
+ });
1717
+ } else {
1718
+ await ctx.task("persist scope decisions", {
1719
+ context: "fresh",
1720
+ reads: [contract, candidate, coordinationPath, ...transcriptReads],
1721
+ prompt: [
1722
+ `Read ${contract}, ${candidate}, ${coordinationPath}, and any supplied guard transcript.`,
1723
+ `Effective coordination status: ${effectiveStatus}. Fallback policy: ${fallbackPolicy}.`,
1724
+ `Fallback human decision: ${humanDecision}`,
1725
+ "Persist one complete decision log with at most 20 unique stable keys.",
1726
+ "Classify each expansion as required, dependent, follow-up, or unclear with evidence and action.",
1727
+ "When warn has no transcript, perform the fresh boundary scope check here.",
1728
+ "Follow-up does not block. Unclear remains blocked unless the human decision resolves it.",
1729
+ ].join("\n"),
1730
+ output: decisionLog,
1731
+ outputMode: "file-only",
1732
+ });
1733
+ }
1734
+
1735
+ const review = await ctx.task("independent correctness review", {
1736
+ context: "fresh",
1737
+ reads: [contract, candidate, decisionLog],
1738
+ prompt: [
1739
+ `Read ${contract}, ${candidate}, and ${decisionLog}.`,
1740
+ "Inspect the current files and run the required checks.",
1741
+ "Review correctness independently; do not turn follow-up scope findings into blockers.",
1742
+ ].join("\n"),
1743
+ });
1744
+
1745
+ return { decision_log: decisionLog, review: review.text };
1746
+ },
1747
+ });
1748
+ ```
1749
+
1750
+ The parallel fan-out has one shared parent frontier and downstream persistence waits for both branches. Blocking asks use the guard's retained conversation; the fresh persistence task turns the final transcript into the bounded artifact before correctness review. If Intercom is unavailable, `warn` runs that task as a boundary check, `block` requires `ctx.ui`, and `off` records that no guard approval exists.
1751
+
1197
1752
  ## The `workflow()` Definition
1198
1753
 
1199
1754
  `workflow(spec)` is the only supported authoring API. It validates the schema maps, normalizes or infers the name, and returns a frozen branded definition that discovery and `ctx.workflow(...)` accept.
@@ -1224,6 +1779,14 @@ readonly description: string;
1224
1779
 
1225
1780
  Discovery and inspection surfaces show this required listing text. The compiled definition preserves it unchanged.
1226
1781
 
1782
+ ### `autoAttach`
1783
+
1784
+ ```typescript
1785
+ readonly autoAttach?: boolean;
1786
+ ```
1787
+
1788
+ Exact `true` opts interactive top-level named launches through `/workflow <name>` and the registered `workflow` tool into opening the graph overlay immediately. Omission and `false` do not opt in. This option does not affect headless launches, nested `ctx.workflow(...)` calls, or the existing input-form launch path. Compiled definitions retain this field only as literal `true`.
1789
+
1227
1790
  ### `inputs`
1228
1791
 
1229
1792
  ```typescript
@@ -1299,6 +1862,7 @@ interface WorkflowDefinition<
1299
1862
  readonly name: string;
1300
1863
  readonly normalizedName: string;
1301
1864
  readonly description: string;
1865
+ readonly autoAttach?: true;
1302
1866
  readonly inputs: WorkflowInputSchemaMap;
1303
1867
  readonly outputs?: WorkflowOutputSchemaMap;
1304
1868
  readonly inputBindings?: { readonly worktree?: WorkflowWorktreeInputBinding };
@@ -1321,7 +1885,8 @@ The `run` function receives `ctx: WorkflowRunContext`. Prefer its high-level pri
1321
1885
  | Independent concurrent branches | `ctx.parallel(steps, options?)` |
1322
1886
  | Reusable child workflow | Call `ctx.workflow(workflowDefinition, options?)` |
1323
1887
  | Human input during a workflow run | `ctx.ui.input/confirm/select/editor/custom` |
1324
- | Pure deterministic computation, parsing, or file I/O | Plain TypeScript in `run` or helpers |
1888
+ | Pure deterministic computation, parsing, or side-effect-free transformation | Plain TypeScript in `run` or helpers |
1889
+ | Workflow-owned filesystem writes, network mutations, external API actions, or other side effects | `ctx.tool(name, args, fn)` so a completed operation is durably cached and resume does not rerun it |
1325
1890
  | Fine-grained session control | `ctx.stage(name, options?)` |
1326
1891
 
1327
1892
  ### `ctx.inputs`
@@ -1340,6 +1905,14 @@ readonly cwd?: string;
1340
1905
 
1341
1906
  Invocation working directory for workflow-owned artifacts. It defaults to the host process cwd when omitted.
1342
1907
 
1908
+ ### `ctx.models`
1909
+
1910
+ ```typescript
1911
+ readonly models?: WorkflowModelCatalogPort;
1912
+ ```
1913
+
1914
+ Model catalog port for the invoking session, when the host provides one. `models.currentModel` is the user-selected session model; leading a stage's model chain with it (bare, without a `:thinking` suffix) runs the stage at the session's model and default thinking level. `models.listModels()` returns the available catalog. The field is absent when no host catalog exists (for example some detached executions), so definitions should treat it as optional and fall back to their own model configuration.
1915
+
1343
1916
  ### `ctx.task(name, options)`
1344
1917
 
1345
1918
  ```typescript
@@ -1497,28 +2070,63 @@ See [Lifecycle Notices and Human Input](#lifecycle-notices-and-human-input) for
1497
2070
  ### `ctx.tool(name, args, fn, options?)`
1498
2071
 
1499
2072
  ```typescript
2073
+ type WorkflowToolOutcome<TValue extends WorkflowSerializableValue> =
2074
+ | { ok: true; value: TValue; attempts: number; cached: boolean }
2075
+ | {
2076
+ ok: false;
2077
+ error: {
2078
+ name: string;
2079
+ message: string;
2080
+ exitCode?: number;
2081
+ stdout?: string;
2082
+ stderr?: string;
2083
+ };
2084
+ attempts: number;
2085
+ cached: boolean;
2086
+ };
2087
+
2088
+ interface WorkflowToolContext {
2089
+ signal: AbortSignal;
2090
+ }
2091
+
1500
2092
  ctx.tool<TValue extends WorkflowSerializableValue>(
1501
2093
  name: string,
1502
2094
  args: Readonly<Record<string, WorkflowSerializableValue>>,
1503
- fn: () => Promise<TValue>,
1504
- options?: {
1505
- readonly retriesAllowed?: boolean;
1506
- readonly maxAttempts?: number;
1507
- readonly intervalMs?: number;
1508
- readonly backoffRate?: number;
1509
- },
2095
+ fn: (toolCtx: WorkflowToolContext) => Promise<TValue>,
2096
+ options?: WorkflowToolThrowOptions,
1510
2097
  ): Promise<TValue>;
2098
+
2099
+ ctx.tool<TValue extends WorkflowSerializableValue>(
2100
+ name: string,
2101
+ args: Readonly<Record<string, WorkflowSerializableValue>>,
2102
+ fn: (toolCtx: WorkflowToolContext) => Promise<TValue>,
2103
+ options: WorkflowToolOptions & { failureMode: "return" },
2104
+ ): Promise<WorkflowToolOutcome<TValue>>;
1511
2105
  ```
1512
2106
 
1513
- Runs arbitrary TypeScript code and durably caches its serializable result by call order plus the content hash of `name` and `args`. A completed call replays without rerunning `fn`, so use this primitive for durable side effects.
2107
+ Runs arbitrary TypeScript code as a tracked, non-attachable durable workflow graph node and caches its serializable result by call order plus the content hash of `name` and `args`. The node is created before `fn` runs and may appear before, between, after, or without model stages. A completed call replays without rerunning `fn`, so use this primitive for workflow-owned durable side effects; keep pure computation as ordinary TypeScript.
2108
+
2109
+ **Cancellation.** Every callback receives a `WorkflowToolContext` whose `signal` aborts when the run is cancelled, when the run is gracefully quit, or when this single node is aborted with `workflow({ action: "quit"|"interrupt", runId, stageId: "<tool node id or name>" })`. Forward it to `fetch`, a child process, or any client that accepts an `AbortSignal` so a stuck call can be stopped:
2110
+
2111
+ ```ts
2112
+ await ctx.tool("fetch-dataset", { source }, async ({ signal }) => {
2113
+ const response = await fetch(source, { signal });
2114
+ return await response.text();
2115
+ });
2116
+ ```
2117
+
2118
+ Zero-argument callbacks stay valid — `async () => { ... }` still compiles and runs — but a callback that ignores its signal cannot be stopped: quit abandons it after a bounded wait and reports its owning run and node id, and it keeps running until it finishes on its own. A cancelled call writes no replayable checkpoint, so resume re-executes exactly that call at the same ordinal and node id; under `failureMode: "return"` it also writes one inspection-only `tool-failure:` record, which is never a replay cache hit.
1514
2119
 
1515
2120
  **Options:**
2121
+ - `failureMode` — `"throw"` keeps the default throw-on-failure behavior; `"return"` returns a typed success or failure outcome after retries.
1516
2122
  - `retriesAllowed` — retries failures when `true`; default `false`.
1517
- - `maxAttempts` — maximum attempts when retries are enabled; default `3`.
2123
+ - `maxAttempts` — positive integer maximum when retries are enabled; default `3`. Invalid enabled retry bounds throw before the callback runs.
1518
2124
  - `intervalMs` — initial retry interval; default `1000`.
1519
2125
  - `backoffRate` — retry interval multiplier; default `2`.
1520
2126
 
1521
- See [`ctx.tool` durable cached tool execution](#ctxtool--durable-cached-tool-execution) for the full example and cancellation behavior.
2127
+ Retries share one signal per logical call, so an abort stops the current attempt and its backoff sleep instead of starting another attempt.
2128
+
2129
+ See [`ctx.tool` — durable cached tool execution](#ctxtool--durable-cached-tool-execution) for durable failure replay, process-output safety, explicit repair handoffs, and cancellation behavior.
1522
2130
 
1523
2131
  ### `ctx.exit(options?)`
1524
2132
 
@@ -1583,11 +2191,13 @@ Select a clean session or a forked context, with `forkFromSessionFile` naming an
1583
2191
  readonly group?: string | true;
1584
2192
  ```
1585
2193
 
1586
- Sets the stage session's [Intercom](/intercom) home group so orchestrated stages can be isolated into coordination groups: a stage in group G can only intercom peers in G. Provide a named string to join that group, or boolean `true` to auto-generate one shared UUID group **per `ctx.parallel(...)` set** (minted once and shared across every item in that set — never a fresh id per item), so a whole level of reviewers lands in the same isolated group. Authored workflow values accept the trimmed, case-insensitive string sentinels `"true"` and `"auto"`. Those two names are reserved for automatic grouping; use a different name when you need a literal named group. Omit `group` to inherit per the precedence chain (ultimately `"default"`).
2194
+ Sets the stage session's [Intercom](/intercom) home group. Every top-level workflow invocation receives a stable, non-`"default"` runtime group derived from its persistent run identity. Intercom-capable stages inherit that group when `group` is omitted, including stages in nested workflows. The group stays stable across model fallback, pause/resume, and durable replay, while separate top-level invocations receive different groups.
1587
2195
 
1588
- `group` is accepted at every level — run-level defaults (`context`), `stage`/`task`, `parallel` step options, and per parallel item and resolves most-specific-first: `parallel-item > task/stage > parallel-step > run-level`. The resolved value is injected per-session (race-safe across concurrently running in-process stages, stable across model fallback). Group assignment is **gated on intercom capability**: a stage with `noTools`, a `tools` allowlist that omits `intercom`, or `excludedTools` containing `intercom` is never placed into a group (so an agent is never isolated into a group it cannot use). Subagents spawned by a grouped stage inherit that stage's group by default (see [subagents.md](/subagents)), so a reviewer level and its helper subagents form one isolated group. The subagent-only `contact_supervisor` channel still reaches the supervisor across group boundaries through a broker capability bound to the child/supervisor relationship and restored across reconnects; ordinary client `send` frames never gain cross-group authority from a channel flag.
2196
+ `group` is accepted on `stage`/`task` options, on `ctx.parallel(...)` options, and per parallel step. Explicit values override the workflow invocation group; a step-level value also overrides its parallel-set value. A named string joins that group, including `group: "default"` to opt into the shared default group. Boolean `true` auto-generates one shared UUID group **per `ctx.parallel(...)` set** (minted once for every item in that set), while `true` on a non-parallel stage creates a fresh stage-only group. The trimmed, case-insensitive string sentinels `"true"` and `"auto"` have the same automatic behavior and are reserved.
1589
2197
 
1590
- The builtin `goal` and `ralph` workflows use this to isolate each reviewer level into its own group (`goal-reviewers-turn-N` / `ralph-reviewers-iter-N`): same-level reviewers coordinate with each other but cannot reach the worker, orchestrator, parent chat, or other levels, which also keeps reviewer intercom chatter out of the main/parent context window.
2198
+ The full precedence is: explicit stage/task/parallel group > workflow invocation group > `ATOMIC_INTERCOM_GROUP` (or legacy `PI_INTERCOM_GROUP`) > Intercom config > `"default"`. Group assignment is **capability-gated**: a stage with `noTools: "all"`, a `tools` allowlist that omits `intercom`, or `excludedTools` containing `intercom` receives no group. `noTools: "builtin"` still keeps extension tools such as Intercom, so those stages inherit the workflow group unless they exclude Intercom. Subagents inherit their launching stage's resolved group by default (see [subagents.md](/subagents)). The subagent-only `contact_supervisor` channel keeps its broker-authorized cross-group route; ordinary client sends remain group-bound.
2199
+
2200
+ Authors do not need to generate or pass a group through ordinary stages, tasks, parallel steps, nested workflows, or delegated subagents. Use an explicit named group or `group: true` only to create an intentional subgroup, such as isolating one reviewer level from another.
1591
2201
 
1592
2202
  ### `model`
1593
2203
 
@@ -1595,7 +2205,7 @@ The builtin `goal` and `ralph` workflows use this to isolate each reviewer level
1595
2205
  readonly model?: WorkflowModelValue; // string or supported SDK model object
1596
2206
  ```
1597
2207
 
1598
- Selects the primary stage model. String values can carry reasoning and context-window suffixes described under [Reasoning levels](#reasoning-levels) and [Context windows](#context-windows).
2208
+ Selects the primary stage model. String values can carry the reasoning suffix described under [Reasoning levels](#reasoning-levels).
1599
2209
 
1600
2210
  ### `fallbackModels` / `fallbackThinkingLevels`
1601
2211
 
@@ -1620,15 +2230,6 @@ readonly thinkingLevel?: WorkflowThinkingLevel;
1620
2230
 
1621
2231
  Sets the default reasoning effort for candidates without a suffix. A suffix on the model string wins.
1622
2232
 
1623
- ### `contextWindow` / `contextWindowStrict`
1624
-
1625
- ```typescript
1626
- readonly contextWindow?: number;
1627
- readonly contextWindowStrict?: boolean;
1628
- ```
1629
-
1630
- Applies a stage-wide context-window token budget. The runtime rejects unsupported values when `contextWindowStrict` is `true`; otherwise, the model keeps its default.
1631
-
1632
2233
  ### `scopedModels`
1633
2234
 
1634
2235
  ```typescript
@@ -1694,13 +2295,17 @@ readonly outputMode?: "inline" | "file-only";
1694
2295
 
1695
2296
  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.
1696
2297
 
2298
+ The runner writes the stage's **final message** to `output` after the stage ends, so that path belongs to the runner. Never point `output` at a file the same stage's prompt asks the agent to author: the agent's file is overwritten by its closing message, and downstream stages read the leftover summary instead of the work. Pick one owner per artifact — either the stage returns the content as its final message and the runner saves it, or the prompt tells the agent to write a path the stage does not declare as `output`.
2299
+
1697
2300
  ### `reads`
1698
2301
 
1699
2302
  ```typescript
1700
2303
  readonly reads?: readonly string[] | false;
1701
2304
  ```
1702
2305
 
1703
- Provides files for the stage to read before running, or disables inherited reads with `false`. Paths are supplied as readonly strings.
2306
+ Names files for the stage to read before running, or disables inherited reads with `false`. Paths are supplied as readonly strings.
2307
+
2308
+ `reads` passes **paths, not content**. It prepends a `[Read from: <paths>]` directive to the prompt and the stage reads those files itself with its own read tool, so a stage sees whatever is on disk when it runs — not a snapshot taken when the path was passed. Any stage that rewrites an artifact between producer and consumer changes what the consumer reads. This keeps large artifacts out of the prompt; state the expectation in the prompt too, for example `Read the file at ${artifactPath} before continuing.`
1704
2309
 
1705
2310
  ### `maxOutput`
1706
2311
 
@@ -1768,8 +2373,7 @@ Select the stage working directory and agent configuration directory. Worktree-e
1768
2373
  ```typescript
1769
2374
  // Runtime StageOptions forwards non-workflow CreateAgentSessionOptions,
1770
2375
  // including these advanced host integration fields:
1771
- readonly authStorage?: CreateAgentSessionOptions["authStorage"];
1772
- readonly modelRegistry?: CreateAgentSessionOptions["modelRegistry"];
2376
+ readonly modelRuntime?: CreateAgentSessionOptions["modelRuntime"];
1773
2377
  readonly resourceLoader?: CreateAgentSessionOptions["resourceLoader"];
1774
2378
  readonly sessionManager?: SessionManager;
1775
2379
  readonly settingsManager?: SettingsManager;
@@ -1865,31 +2469,6 @@ The standalone `thinkingLevel` stage option is deprecated. It still applies as a
1865
2469
 
1866
2470
  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.
1867
2471
 
1868
- ### Context windows
1869
-
1870
- A `model`/`fallbackModels` entry may also request a context-window budget with a parenthesized size token in the model-name portion. Place the token *before or after* the optional `:reasoning` suffix to prevent a conflict with the reasoning level. This mirrors GitHub Copilot's `Claude Opus 4.8 (1M context)` model-name convention:
1871
-
1872
- ```ts
1873
- await ctx.task("review", {
1874
- task: "Review the diff",
1875
- model: "anthropic/claude-fable-5:high",
1876
- // The copilot opus fallback runs at its largest advertised (long-context) window.
1877
- // Use (long) for a size-agnostic marker, or a rounded long-tier label like (1m).
1878
- fallbackModels: ["github-copilot/claude-opus-4.8 (long):xhigh", "anthropic/claude-opus-4-8:xhigh"],
1879
- });
1880
- ```
1881
-
1882
- The token accepts the same compact sizes as the `--context-window` flag (`1m`, `1.1m`, `936k`, `400k`, or a raw token count), plus a generic `(long)` marker, and the runtime resolves it against that specific candidate model's advertised windows:
1883
-
1884
- - `(long)` — a size-agnostic long-context marker that selects the model's advertised long tier regardless of its exact size, so the same token works across models with different long tiers;
1885
- - a request at or below the model's default window keeps the default;
1886
- - a request above the default selects the long tier — an exact supported window is used as-is, otherwise the smallest supported window at or above the request is selected, rounding **up** so a rounded marker like `(1m)` or `(1.1m)` lands on the long tier even when it sits slightly above or below the marker size (e.g. `(1m)` selects claude-opus-4.8's 1M tier and gpt-5.5's 1.05M tier; `(1.1m)` matches gpt-5.5's rounded long-tier label);
1887
- - when the model exposes no larger tier (or is unavailable), the runtime drops the request and the session keeps the model's default (short) window—a non-strict, automatic fallback.
1888
-
1889
- The budget applies only to the candidate that carries the token; other primary and fallback models in the same chain are unaffected. A parenthesized token that is not a valid size (for example `(preview)`) is left attached to the model id rather than being treated as a context window. Without the token, a tiered model **pins its natural default (short) window** in a workflow stage, so a persisted interactive long-context preference does not leak into workflow runs — use the `(1m)` token or the `contextWindow` stage option to opt into long context.
1890
-
1891
- For stage-wide selection you can instead set the `contextWindow` (and `contextWindowStrict`) stage option, which maps to the SDK `createAgentSession` options of the same name.
1892
-
1893
2472
  ## StageContext
1894
2473
 
1895
2474
  `ctx.stage(name, options?)` returns direct control of a tracked stage session. The executor owns session disposal and wraps stage operations with workflow lifecycle tracking.
@@ -1930,7 +2509,9 @@ stage.sendUserMessage(
1930
2509
  ): Promise<void>;
1931
2510
  ```
1932
2511
 
1933
- Sends a normal follow-on user turn to the retained stage session. This method starts a turn immediately when the session is idle; while streaming, it queues a follow-up by default or sends steering when `deliverAs: "steer"`.
2512
+ Sends a normal follow-on user turn to the retained stage session. This method starts a turn immediately when the session is idle and not controlled-paused; while streaming, it queues a follow-up by default or sends steering when `deliverAs: "steer"`. During controlled pause it joins the raw hold and does not start a turn.
2513
+
2514
+ `deliverAs: "steer"` is consumed after the current assistant response finishes its whole tool batch and before the next model request; `deliverAs: "followUp"` is consumed only when the agent would otherwise stop. Each queue is FIFO in admission order, and steering keeps priority over an earlier-submitted follow-up.
1934
2515
 
1935
2516
  Native sessions accept strings or text/image content blocks. Non-native fallback adapters accept only strings and reject block arrays; `deliverAs` affects streaming delivery only, and follow-on turns retain the stage MCP scope.
1936
2517
 
@@ -1945,7 +2526,7 @@ stage.steer(text: string): Promise<void>;
1945
2526
  stage.followUp(text: string): Promise<void>;
1946
2527
  ```
1947
2528
 
1948
- Queues text while a turn is active. These methods do not start a new idle turn; use `sendUserMessage()` to start one.
2529
+ Queues text while a turn is active. These methods do not start a new idle turn; use `sendUserMessage()` to start one when the stage is not paused. A controlled pause holds queued steering and follow-up items without delivering them, and only the existing stage resume action makes them eligible again.
1949
2530
 
1950
2531
  ### `stage.subscribe(listener)`
1951
2532
 
@@ -2190,20 +2771,23 @@ List or inspect unfamiliar workflows before running them. If required inputs are
2190
2771
 
2191
2772
  ```ts
2192
2773
  workflow({ action: "list" })
2193
- workflow({ action: "get", workflow: "deep-research-codebase" })
2194
- workflow({ action: "inputs", workflow: "deep-research-codebase" })
2774
+ workflow({ action: "get", workflow: "fan-out-and-synthesize" })
2775
+ workflow({ action: "inputs", workflow: "fan-out-and-synthesize" })
2776
+ workflow({ action: "models" })
2195
2777
  ```
2196
2778
 
2197
2779
  The workflow tool action surface is:
2198
2780
 
2199
- - discovery: `list`, `get`, `inputs`
2781
+ - discovery: `list`, `get`, `inputs`, plus `models` for the configured model catalog
2200
2782
  - execution: named `run` with validated `workflow` and `inputs`
2201
2783
  - inspection: `status`, `stages`, `stage`, `transcript`
2202
- - messaging and run control: `send`, `pause`, `interrupt`, `quit`, `resume`
2784
+ - messaging on nonterminal root runs and run control: `send`, `pause`, `interrupt`, `quit`, `resume`
2203
2785
  - rediscovery: `reload`
2204
2786
 
2205
2787
  From interactive chat, named workflow launches run in the background so the parent chat stays available. Run `/workflow connect <run>` to see agents working and chat with and steer each stage. Inspection and control calls (`status`, `stages`, `stage`, `transcript`, `send`, `pause`, `resume`, `interrupt`, `quit`) remain available while work runs.
2206
2788
 
2789
+ `workflow({ action: "models" })` returns the registry's configured-auth catalog snapshot in registry order. Each entry includes `provider`, `id`, `fullId`, an `isCurrent` marker, and `availableThinkingLevels` derived from the real model's `reasoning` and `thinkingLevelMap` metadata. This is not proof of credentials, entitlements, OAuth freshness, or live provider access, and it exposes no authentication details.
2790
+
2207
2791
  Named launches wait only for **startup admission**, not for workflow completion. Atomic returns `status: "running"` after durable registration, reusable-worktree setup, and other pre-body setup succeed, while the workflow body and stages continue in the background. If setup fails before the workflow body is admitted — for example, `git_worktree_dir` points inside the invoking checkout — the original `workflow` tool call instead returns a structured `status: "failed"` result with the allocated run id and concrete setup error. No background-start claim or orphan run is retained, so the caller can correct the inputs and retry immediately. Failures after admission remain ordinary background lifecycle outcomes reported through status and lifecycle notices.
2208
2792
 
2209
2793
  A model may launch in the foreground only when the user explicitly requests it or foreground execution is technically required, and it must tell the user before launching.
@@ -2213,15 +2797,15 @@ Run a named workflow with inputs:
2213
2797
  ```ts
2214
2798
  workflow({
2215
2799
  action: "run",
2216
- workflow: "deep-research-codebase",
2217
- inputs: { prompt: "map workflow runtime", max_concurrency: 4 },
2800
+ workflow: "fan-out-and-synthesize",
2801
+ inputs: { prompt: "map workflow runtime by subsystem", max_concurrency: 4 },
2218
2802
  })
2219
2803
  ```
2220
2804
 
2221
2805
  Slash equivalent:
2222
2806
 
2223
2807
  ```text
2224
- /workflow deep-research-codebase prompt="map workflow runtime" max_concurrency=4
2808
+ /workflow fan-out-and-synthesize prompt="map workflow runtime by subsystem" max_concurrency=4
2225
2809
  ```
2226
2810
 
2227
2811
  <p align="center"><img src="images/workflow-command.png" alt="Running a Workflow Command" width="600" /></p>
@@ -2272,12 +2856,15 @@ Surface behavior:
2272
2856
  - **Graph vs. stage chat** - Use `connect` for the workflow graph. Use `attach` when you want a chat pane for a specific stage.
2273
2857
  - **Hierarchy chord** - `ctrl+x` is the workflow hierarchy chord: in an attached stage chat it means **return to graph**, and in the graph it means **return to main chat**. The workflow surface handles `ctrl+x` before configurable editor or tool actions, including while a composer draft, primitive prompt, custom question, stage switcher, or legacy prompt card owns input.
2274
2858
  - **Draft preservation** - Leaving a stage preserves unsent composer and prompt drafts and keeps pending custom questions unresolved so they reappear when you attach again.
2859
+ - **Queued-message survival** - Steering and follow-up entries queued from a stage chat live on the stage session, not on the pane. Detaching to the graph and reattaching rehydrates the pending `Steering:` / `Follow-up:` rows, and while you are detached the stage's graph node shows a `✉ N queued` badge so a pending message stays visible without attaching. The attached chat shows the pending text; the detached node shows only their count. Both read one projection that the stage handle keeps current from the session's complete `queue_update` snapshots, so rows and badge shrink together as the agent consumes entries. That projection is fed by the events rather than by a concrete Atomic `AgentSession`, so a stage backed by a custom `AgentSessionAdapter` keeps this behavior as long as it publishes ordinary `queue_update` events; each snapshot replaces the previous steering and follow-up lists rather than adding to them. A queue can also outlive the session holding it — a stage session that fails over to a fallback model hands its pending messages to the session replacing it, and a completed stage reopened as a post-mortem chat is restored holding whatever it was queued. Those messages were announced before the projection could reach the new session, so Atomic reads it once as it attaches and the rows and badge show them too.
2275
2860
  - **Reserved keys** - `ctrl+d` and `q` do not navigate workflow surfaces; `ctrl+d` keeps its ordinary editor or prompt behavior where applicable, and `q` remains printable in text-owning prompts. Existing `esc`, `ctrl+c`, and graph `h` close/hide controls are unchanged.
2276
2861
  - **Wheel and trackpad** - While the workflow graph is active, vertical wheel/trackpad gestures pan it up and down, and horizontal gestures pan wide graphs left and right when the terminal exposes horizontal wheel events; these gestures remain scoped to the graph instead of leaking into the main chat or terminal scrollback. Attached stage chats capture mouse/trackpad wheel events by default so scrolling stays inside the active stage transcript or prompt instead of falling through to terminal/main-chat scrollback.
2277
2862
  - **Tool and node detail** - Attached stage chats match main chat's tool-detail expansion behavior while keeping expansion state local to the workflow UI context. Press Ctrl+O (the configurable `app.tools.expand` binding) to expand every visible workflow node and tool card, including single, parallel, and chain subagent progress, current tool activity, and artifact paths; press it again to collapse them. The toggle works for active, completed, and archived stage views, including at the supported 40-column terminal minimum. A mounted prompt, custom question, or other input-owning overlay keeps the key instead of changing expansion.
2863
+ - **Footer context** - An attached live stage chat carries the main chat's current-folder and Git-branch identity into its themed footer and mirrors live extension status lines such as the MCP server indicator. Branch changes trigger a repaint through the host's cached footer provider, and extension status changes are read from that same provider rather than recomputed by the workflow UI.
2864
+ - **Working animation lifecycle** - Ordinary attached-stage work keeps the same exact one-cell `∀` visible while following the active workflow theme's dark → accent → bright/bold → accent → dark luminance ramp every 88ms. Every agent and SDK turn resets to the dark regular phase with a fresh lifecycle-relative cadence; turn, terminal, error, replacement, and disposal cleanup stop the active timer without stale repaint. In an eligible retained-stage chat, every accepted idle follow-up — including a workflow-authored `stage.sendUserMessage(...)` after a prior turn ended — shows Working on admission or attach, including while Atomic restores a saved retained conversation, and keeps it through prompt startup, pre-turn compaction, and agent handoff. Attaching or remounting mid-delivery paints immediately rather than waiting for the turn's first event. A message queued into a live turn with `followUp`/`steer` uses that turn's existing status instead of starting a new one. A no-turn result, prompt or restore error, or terminal completion removes it; once the last accepted post-terminal delivery settles, a leftover start cannot bring it back. An accepted manual retry clears stale status from the prior prompt before showing new pre-stream activity. `NO_COLOR` retains regular/bold activity without foreground-color escapes. Reduced motion uses a static regular accent `∀` without an animation timer; factual automatic retry, fallback, compaction, cancellation, and error copy retains precedence.
2278
2865
  - **Async statusline** - If an async/background subagent is running while the fullscreen workflow graph is open, the graph statusline mirrors the async summary so the background run remains visible; hide the graph with `h`, leave it with `ctrl+x`, or reconnect later to return to the full below-editor async widget.
2279
2866
  - **Copy mode** - Press `ctrl+t` inside an attached stage chat to toggle **copy mode**: copy mode disables workflow-chat mouse reporting so normal terminal/tmux text selection can work; press `ctrl+t` again to leave copy mode and restore transcript or prompt scrolling. Archived read-only stage transcripts expose the same footer and copy-mode status, so their text can also be selected and copied; `esc` closes the transcript and `ctrl+x` returns to the graph. While copy mode is on, wheel/trackpad gestures are handled by the terminal/tmux and may scroll terminal scrollback, so leave copy mode before using the wheel again.
2280
- - **Run control** - Use `interrupt`, `pause`, and `resume` for resumable live work; `resume` on a non-paused run reopens the saved snapshot or overlay. Use `quit` to pause a live run gracefully while preserving it for `/workflow resume`.
2867
+ - **Run control** - Use `interrupt`, `pause`, and `resume` for resumable live work. Pause/interrupt holds a stage's queued steering and follow-up items in place without dequeuing them or starting continuation; `resume` releases those items once in their existing per-queue order, but queue release alone does not start a model turn. `resume` on a non-paused run reopens the saved snapshot or overlay. Use `quit` to pause a live run gracefully while preserving it for `/workflow resume`.
2281
2868
  - **Rediscovery** - Use `/workflow reload` after adding, editing, installing, or removing workflow resources or package manifest workflow entries and you want Atomic to rediscover them in-process ([Reloading workflow resources](#reloading-workflow-resources)).
2282
2869
  - **Status listing** - `/workflow status` lists all retained active and terminal top-level runs by default; implementation-owned nested child runs are flattened into their parent workflow rather than listed separately. `/workflow status --all` is retained as a compatibility alias.
2283
2870
 
@@ -2308,6 +2895,7 @@ workflow({ action: "transcript", runId: "<id-or-prefix>", stageId: "review" })
2308
2895
  workflow({ action: "transcript", runId: "<id-or-prefix>", stageId: "review", tail: 40 })
2309
2896
  workflow({ action: "transcript", runId: "<id-or-prefix>", stageId: "review", limit: 20, includeToolOutput: true })
2310
2897
 
2898
+ // send is admitted only while the authoritative root workflow is nonterminal.
2311
2899
  workflow({ action: "send", runId: "<id-or-prefix>", stageId: "review", text: "please focus on tests" })
2312
2900
  workflow({ action: "send", runId: "<id-or-prefix>", stageId: "approval", promptId: "prompt-1", response: true, delivery: "answer" })
2313
2901
  workflow({ action: "send", runId: "<id-or-prefix>", stageId: "review", message: "continue with tests", delivery: "resume" })
@@ -2324,6 +2912,10 @@ workflow({ action: "resume", runId: "<id-or-prefix>", stageId: "review", message
2324
2912
  workflow({ action: "quit", runId: "<id-or-prefix>" })
2325
2913
  workflow({ action: "quit", all: true })
2326
2914
 
2915
+ // Abort one in-flight ctx.tool node without pausing the run.
2916
+ workflow({ action: "quit", runId: "<id-or-prefix>", stageId: "tool:<argsHash>" })
2917
+ workflow({ action: "interrupt", runId: "<id-or-prefix>", stageId: "publish-artifact" })
2918
+
2327
2919
  workflow({ action: "reload", reason: "added team workflow" })
2328
2920
  ```
2329
2921
 
@@ -2337,18 +2929,27 @@ Control behavior:
2337
2929
  - `stages` lists stage summaries, including flattened stages from nested `ctx.workflow(...)` imports and `sessionFile`/`transcriptPath` when a stage has a persisted session. Use `statusFilter: "all"` to include completed, failed, skipped, and pending stages.
2338
2930
  - `stage` returns details for one stage by stage id, unique prefix, or stage name, including nested child stages shown in the expanded graph and the persisted `sessionFile` when available. Abbreviated stage IDs printed in graph/control messages use this same unique-prefix resolver; collisions return an ambiguity diagnostic rather than selecting a stage.
2339
2931
  - `transcript` is reference-first with a small preview by default: it returns metadata, transcript paths, and up to 5 recent entries. For targeted lookup, quote the exact `sessionFile`/`transcriptPath` value without changing platform separators (preserve Windows backslashes), search it with `rg` or `grep`, then read only small surrounding ranges. Text results include JSON-escaped `sessionFileJson`/`transcriptPathJson` lines for copy-safe path literals. Pass explicit `tail` or `limit` to override the 5-entry preview; `tail` overrides `limit`; `includeToolOutput` includes captured snapshot tool output in snapshot transcript results.
2340
- - `send` delivery modes are `auto`, `answer`, `prompt`, `steer`, `followUp`, and `resume`.
2341
- - Prompt answers can include `promptId` and can carry answer content in `response`, `text`, or `message`; structured UI prompts usually prefer `response`.
2342
- - For a live idle stage, `prompt`, `followUp`, and eligible `auto` delivery all start a fresh prompt immediately; an actively streaming `followUp` remains queued and `steer` remains steering, so neither starts a concurrent prompt. The result's `delivery` and message describe the action actually taken (`prompt`, `followUp`, `steer`, `answer`, or `resume`), not merely the requested mode. Explicit `resume` against a stage that is not paused is a truthful no-op, and explicit message deliveries cannot bypass a paused stage; resume it first.
2343
- - Follow-up messaging to completed or failed stages reuses the retained `sessionFile` when available so the conversation resumes from the archived stage transcript instead of starting empty. If no session metadata was retained, Atomic refuses the follow-up rather than silently resetting.
2344
- - Explicit `delivery: "resume"` or `delivery: "steer"` against a completed post-mortem stage returns a structured `noop` with guidance to use `followUp` or `prompt`; it never appends the supplied text or mutates workflow execution.
2932
+ - `send` operates only while the authoritative root workflow is nonterminal; delivery modes are `auto`, `answer`, `prompt`, `steer`, `followUp`, and `resume`.
2933
+ - A terminal root (`completed`, `failed`, `skipped`, `cancelled`, `killed`, or terminal `blocked`) rejects every programmatic send with `status: "failed"`, `code: "WORKFLOW_TERMINAL"`, `delivery: "rejected"`, the requested root run id and terminal status, and guidance to start a new workflow. Proceed inline instead only when the remaining work is small, deterministic, and low risk.
2934
+ - Atomic checks an already-terminal root before stage resolution, nested-owner routing, prompt inspection, retained-session probing or revival, handle lookup, message admission, and delivery selection. That rejection creates no agent session or handle, appends no transcript, starts no model/tool/file work, answers no input, and mutates no workflow/stage snapshot. Missing or malformed retained sessions receive the same root-terminal error without being probed.
2935
+ - Atomic checks the same shared terminal authority again at the final synchronous SDK message-admission boundary. If a live root terminates while retained-session creation is pending, the send fails with `WORKFLOW_TERMINAL`, disposes its unclaimed provisional session/handle, and admits no prompt, model request, tool/file work, transcript append, or workflow-state mutation. A user-driven attach or Intercom claim remains independent and keeps the retained handle.
2936
+ - Prompt answers on a nonterminal root can include `promptId` and can carry answer content in `response`, `text`, or `message`; structured UI prompts usually prefer `response`.
2937
+ - For a live idle, non-paused stage, `prompt`, `followUp`, and eligible `auto` delivery all start a fresh prompt immediately; an actively streaming `followUp` remains queued and `steer` remains steering, so neither starts a concurrent prompt. During controlled pause, every context-bearing delivery remains held instead. The result's `delivery` and message describe the action actually taken (`prompt`, `followUp`, `steer`, `answer`, or `resume`), not merely the requested mode. Explicit `resume` against a stage that is not paused is a truthful no-op, and explicit message deliveries cannot bypass a paused stage; resume it first.
2938
+ - Delivery timing is mode-specific and deterministic. `steer` (and `auto` against a streaming stage) enters the steering queue and is consumed after the current assistant response finishes its whole tool batch, before the next model request — never between two tool calls of the same response. `followUp` enters the follow-up queue and is consumed only when the agent would otherwise stop. Sequential sends keep submission order *within* the queue they select; there is no global FIFO across the two queues, so a steer submitted after a follow-up is still consumed first. Ordering is promised relative to admission into the selected queue, not relative to when a caller started a request whose session setup or admission finishes later.
2939
+ - While the root remains nonterminal, follow-up messaging to an eligible completed child stage can reuse its retained `sessionFile`. After the root terminates, use explicit `/workflow attach <run-id> <stage>` post-mortem chat instead; `workflow send` never admits a retained-session turn after terminal publication.
2345
2940
  - Arbitrary `ctx.ui.custom<T>` widget prompts require the interactive workflow graph and return a clear unsupported message when targeted through `send`.
2346
- - `delivery: "auto"` first answers a pending prompt, then resumes paused work, then steers a streaming stage, and finally starts a fresh prompt when the live stage is idle.
2347
- - `pause`, `interrupt`, and `quit` can target one top-level run or `all: true`; `stageId` cannot be combined with `all: true`. Stage-scoped `pause` and `interrupt` controls can target a visible nested child stage from the expanded graph; `quit` remains run-level. Atomic routes stage controls to the owning nested run internally.
2941
+ - On a nonterminal root, `delivery: "auto"` first answers a pending prompt, then resumes paused work, then steers a streaming stage, and finally starts a fresh prompt when the live stage is idle.
2942
+ - `pause`, `interrupt`, and `quit` can target one top-level run or `all: true`; `stageId` cannot be combined with `all: true`. Stage-scoped `pause` and `interrupt` controls can target a visible nested child stage from the expanded graph. Atomic routes stage controls to the owning nested run internally.
2943
+ - `interrupt` and `quit` can also name one in-flight `ctx.tool` node with `stageId`, by expanded node id, local `tool:<argsHash>` id, or tool name. Both mean the same thing for a tool: abort that single call now. Tool nodes stay non-attachable — this is an abort control, not a chat target. Identifiers resolve exactly first and then uniquely; a name shared by two tool nodes (or by a stage and a tool) returns the same ambiguity diagnostic stages get, listing each match as `<name> (tool)`.
2944
+ - Aborting one tool node leaves every sibling stage and sibling tool node running and does not pause the run. The node becomes `cancelled`, writes no replayable checkpoint, and re-runs on a later resume. Whether the run itself survives is ordinary author control flow: an awaited `ctx.tool` that is aborted rejects, exactly as it would for any other failure, unless the workflow catches it. A node that has already settled reports that it is not running rather than silently succeeding.
2945
+ - Whole-run `quit` stays authoritative even if workflow code catches the tool rejection. A catch may run cleanup, but its returned outputs do not convert the quit into a completed run: the executor suspends and quit's paused/resumable record stands. To abort one call and intentionally keep the workflow going, target that node instead of quitting the run.
2946
+ - A targeted tool abort reports the node outcome and the run separately: `status: "cancelled"` for the node it cancelled, `stageId` for that node, `abandoned` when the callback ignored its signal, and `workflowStatus` for the run status *observed* when the action returned. It never reports `paused`, and it never predicts what the run does next.
2947
+ - `pause` never accepts a tool node: `ctx.tool` has no turn boundary to stop at, so Atomic rejects it with `Tool nodes cannot be paused; ... Use interrupt or quit to abort it.` instead of a silent no-op.
2348
2948
  - `interrupt` is resumable: it pauses live work when pausable stages exist and keeps the run in live history/status.
2349
2949
  - `pause` is useful for pausing a live run or a single live stage without treating it as a destructive abort.
2350
2950
  - `resume` can target a stage with `stageId`; the target may be a stage id, unique prefix, or stage name. `message` is forwarded to paused work. For a live interrupted streaming prompt, Atomic preserves the existing prompt loop without duplicating the user message and injects `Continue where you left off. If you believe you are finished with your original task (or a redefined task if the user told you), stop.` when required before normal readiness-gate completion. For a paused stage that was idle waiting for a new stage-chat turn, a non-empty message resumes the stage and starts exactly one fresh prompt containing that message; an empty resume releases the pause without creating a prompt.
2351
- - `quit` gracefully pauses in-flight work, marks the run resumable, and leaves it available to `/workflow resume`.
2951
+ - An explicit workflow-tool `resume` target that is absent from the current session store triggers targeted DBOS discovery before Atomic returns `Run not found`. Eligible exact IDs and unique prefixes resume under the original workflow ID; durable prefix collisions return every matching ID. Resource-loading and durable-backend failures remain visible. Ordinary workflow-tool `status` listing stays session-local and does not eagerly hydrate durable history.
2952
+ - Run-level `quit` gracefully pauses in-flight work, marks the run resumable, and leaves it available to `/workflow resume`. A run whose only in-flight work is a `ctx.tool` node is quit like any other: it pauses as resumable instead of reporting that there are no controllable stages.
2352
2953
  - `reload` refreshes discovered workflow resources in-process; the optional `reason` is echoed in the result.
2353
2954
 
2354
2955
  Use slash commands for graph connect and stage attach because those are interactive TUI surfaces. When a run needs user input or attention, tell the user instead of polling silently.
@@ -2357,6 +2958,20 @@ Use slash commands for graph connect and stage attach because those are interact
2357
2958
 
2358
2959
  Graceful quit is idempotent for an already-paused resumable run. If a run is waiting on `ctx.ui`, quit preserves its current DBOS prompt reservation. Answers cannot advance paused workflow code until explicit resume; checkpointing the answer releases exactly that reservation generation. Concurrent and nested prompts use composed scopes and independent DBOS reservation tokens.
2359
2960
 
2961
+ **Quit closes `ctx.tool` admission before it becomes a durability boundary.** A run-level quit pauses controllable stages and waits for their acknowledgements, then closes the root-shared tool-admission boundary shared by the root run and every nested run. Closing is what makes the following scan final: a call admitted while the stage pauses were still being acknowledged is included, and no call can start afterwards — not even while the durable write is in flight. Quit then aborts that complete set, waits a bounded interval for the callbacks to settle, and only then records the durable paused transition and marks the run resumable.
2962
+
2963
+ Aborting a call is the point of no return: that callback's executor is already committed to suspending. So if the durable paused transition then fails or is refused, Atomic still records the pause locally — the run is never left reported as running with nothing running it — but does not advertise it as resumable, and the reported error names both the durable failure and what it left behind. The run stays controllable, so running `/workflow quit` again re-attempts the durable transition and upgrades the run to resumable once it lands.
2964
+
2965
+ A `ctx.tool` call attempted after admission closed never runs: it receives the graceful-quit signal, so it suspends the workflow instead of failing it, and creates no graph node, checkpoint, or side effect.
2966
+
2967
+ A callback that ignores its abort signal is abandoned rather than pinning quit forever — mirroring the failure path — and the quit result reports each abandoned call in `abandonedTools` alongside the cancelled nodes in `cancelledTools`. Both carry the owning `{runId, nodeId}` identity, because two nested child runs legitimately share one local `tool:<argsHash>` id; slash/tool output prints them as `<runId>/<nodeId>`.
2968
+
2969
+ A run whose only in-flight work is a `ctx.tool` node counts as controllable work: it pauses as resumable instead of returning `no_active_stages`. Because a cancelled tool node has no replayable checkpoint, resume re-executes exactly that callback at the same ordinal and node id; completed sibling tools replay from cache.
2970
+
2971
+ Catching the cancellation does not opt out. If workflow code wraps the aborted `await ctx.tool(...)` in `try`/`catch` and returns normally, Atomic still suspends the run rather than publishing a completed result, so the paused/resumable state quit recorded is what survives.
2972
+
2973
+ When a callback was abandoned, its executor stays alive but stops owning the run: Atomic detaches that background job, so `/workflow resume` launches a fresh executor under the same workflow id instead of adopting a job nothing is driving. The abandoned callback may still finish afterwards — its aborted signal blocks any replayable write, and its stale bookkeeping can neither mutate the replacement run's tool node nor unregister the replacement's job or cancellation entry.
2974
+
2360
2975
  When a paused stage interrupted an active model turn, Atomic preserves that turn's existing pause loop: a non-empty resume message is delivered exactly once through the resumed loop, and (if the stage has not finalized) Atomic injects `Continue where you left off. If you believe you are finished with your original task (or a redefined task if the user told you), stop.` before normal completion/readiness handling. A no-message interrupted-turn resume injects the same continuation directly. A different state applies when the stage was idle and waiting for a new stage-chat turn: resuming with a non-empty message starts exactly one fresh prompt containing the text, while an empty resume only releases the pause and does not fabricate a user turn or continuation.
2361
2976
 
2362
2977
  The same continuation applies to user messages queued into a live streaming stage. Steering a turn (Enter in an attached stage chat), queueing a follow-up (Ctrl+F), or using `workflow({ action: "send" })` with `steer`/`followUp` delivery arms the identical continuation prompt, which Atomic injects once when the interrupted turn ends — even if several messages were queued during that turn — so a steered stage returns to its original (or user-redefined) objective instead of stopping after answering the queued message.
@@ -2369,9 +2984,13 @@ When several paused stages resume together, Atomic settles every acknowledgement
2369
2984
 
2370
2985
  These are distinct operations. *Resuming workflow execution* (`/workflow resume`) is for paused, interrupted, recoverably failed, or unfinished durable work; it may replay checkpoints, continue an incomplete stage, and dispatch remaining DAG work. *Opening a post-mortem chat* reopens one terminal agent stage's retained conversation for follow-up only — it never resumes, retries, rewinds, or otherwise changes workflow execution.
2371
2986
 
2372
- Any eligible terminal agent stage with a valid retained session opens as an interactive post-mortem chat regardless of how you reach it: same-process `ctx.task`/`ctx.chain`/`ctx.parallel` stages, completed-workflow inspection, generic `/workflow attach` / `/workflow connect`, restored/replayed durable snapshots after a restart, and `workflow({ action: "send" })`. Explicit `/workflow attach <root-run> <nested-stage>` targets are resolved through the expanded graph and routed to the child run that owns the stage while the overlay remains rooted on the requested graph; the resolved owner is preserved when sibling child workflows reuse the same local stage ID.
2987
+ Any eligible terminal agent stage with a valid retained session opens as an interactive post-mortem chat through the explicit user-driven TUI path: completed-workflow inspection, `/workflow attach`, or `/workflow connect` followed by stage selection, including restored/replayed durable snapshots after a restart. Explicit `/workflow attach <root-run> <nested-stage>` targets are resolved through the expanded graph and routed to the child run that owns the stage while the overlay remains rooted on the requested graph; the resolved owner is preserved when sibling child workflows reuse the same local stage ID.
2988
+
2989
+ `workflow({ action: "send" })` is not a post-mortem path. Once the root is terminal, programmatic sends fail closed before retained-session probing or nested-stage routing. Start a new workflow if tracked work remains; proceed inline only for small, deterministic, low-risk work.
2373
2990
 
2374
- When a nested stage is reopened after a restart or from another checkout, its session cwd comes from the durable root workflow (resolved workflow cwd first, then original invocation cwd) while stage-control ownership remains with the actual child run. Follow-up turns are appended in place to the stage's retained session (no separate fork), so the agent may still invoke its ordinary tools and cause side effects; only the workflow DAG, run/stage status, results, timings, checkpoints, and topology are immutable.
2991
+ When a nested stage is reopened after a restart or from another checkout through the explicit TUI path, its session cwd comes from the durable root workflow (resolved workflow cwd first, then original invocation cwd) while stage-control ownership remains with the actual child run. Follow-up turns are appended in place to the stage's retained session (no separate fork), so the agent may still invoke its ordinary tools and cause side effects; only the workflow DAG, run/stage status, results, timings, checkpoints, and topology are immutable. Post-mortem chat does not resume or modify workflow execution state.
2992
+
2993
+ Pressing Escape during a live post-mortem turn pauses that retained conversation's queued messages without changing the terminal workflow snapshot. The next ordinary submission explicitly releases the conversation queue before it starts the new turn; clearing or restoring every visible queued item does not implicitly resume it.
2375
2994
 
2376
2995
  Every host session replacement or shutdown invalidates post-mortem handles, including a session whose lazy reopen is still pending: if creation finishes after the boundary, Atomic disposes the newly created session and rejects the already-submitted prompt before it can execute. A stage stays a **read-only transcript** when it has no valid retained agent session — prompt/HIL and boundary/summary nodes, skipped nodes without a completed conversation, non-terminal handle-less stages (another process may still own the session), and missing/malformed/deleted session files.
2377
2996
 
@@ -2390,7 +3009,21 @@ Passing a stage session's file path to `--session` still opens it explicitly. Cl
2390
3009
 
2391
3010
  ## Lifecycle Notices and Human Input
2392
3011
 
2393
- Atomic emits deduplicated main-chat notices when top-level workflow runs complete, fail, end blocked, or stop at an active recoverable provider/auth/rate-limit block. A recoverable block remains resumable (`status` surfaces and headless results report it as blocked even though the stored live snapshot stays active), is retained durably as blocked for cross-session resume, appears in the resume picker, and its notice says the workflow **is blocked** rather than implying terminal completion. Each blocked occurrence is deduped by its `blockedAt` timestamp, so a resumed workflow that hits another recoverable block re-notifies the invoking chat. Nested child workflow outcomes are reflected inside the expanded parent graph instead of producing separate top-level cards. Lifecycle notices are delivered through the coding-agent's native idle-prompt admission when the parent chat is idle, or persisted directly to the transcript when the parent chat is streaming, so a cleared steer queue or aborted turn cannot silently drop the card. Delivery is acknowledged before dedupe is committed: while the invoking chat remains active, a rejected admission retains its original payload and retries with capped backoff even if the run changes state or notification configuration is reinstalled. Session replacement cancels those attempts and clears their payloads rather than waking an unrelated chat with an uninspectable old run. Awaiting-input workflow states are tracked for dedupe/restore, but they do not enqueue main-chat connect cards or wake the model; prompt state remains visible through workflow status/connect surfaces.
3012
+ Atomic emits deduplicated main-chat notices when top-level workflow runs complete, fail, end blocked, or stop at an active recoverable provider/auth/rate-limit block. A recoverable block remains resumable (`status` surfaces and headless results report it as blocked even though the stored live snapshot stays active), is retained durably as blocked for cross-session resume, appears in the resume picker, and its notice says the workflow **is blocked** rather than implying terminal completion. Each blocked occurrence is deduped by its `blockedAt` timestamp, so a resumed workflow that hits another recoverable block re-notifies the invoking chat. Nested child workflow outcomes are reflected inside the expanded parent graph instead of producing separate top-level cards.
3013
+
3014
+ Previously, the streaming `persistWhenStreaming` path directly appended the visible card. It did not enqueue a native steer/follow-up or schedule a later model step. Therefore, an earlier provider context snapshot could finish with an uncorrected running claim.
3015
+
3016
+ Streaming lifecycle delivery now deliberately splits display from reconciliation. Before send admission resolves, Atomic appends one `display: true`, `excludeFromContext: true` lifecycle card to agent state and `SessionManager`; that same durable entry atomically carries the recovery marker for its hidden turn. Atomic separately submits the same raw notice text as a `display: false` internal reconciliation through the native steer boundary. This fixes the former direct-context race: a visible entry cannot become provider input between an assistant `workflow` call and its required `status=running` result, while a notice that arrives during final text still causes a later correcting step. The lifecycle path never aborts the active chat itself.
3017
+
3018
+ | Parent state when the notice arrives | Card and prompt transition | Invariants |
3019
+ | --- | --- | --- |
3020
+ | Idle | Commits the display card, then starts one native prompt with the hidden reconciliation. | Admission already includes the durable card; only the hidden copy enters model context. |
3021
+ | Active between completed tool calls | Commits the card and queues the hidden steer for the next native provider step. | Existing completed tool ordering stays intact. |
3022
+ | Active with the workflow tool result pending | Waits for earlier event writes, commits the context-excluded card, then lets the hidden steer follow the matching result. | Provider and reopened-file order remains assistant tool call → `status=running` tool result → lifecycle reconciliation. |
3023
+ | Active final-text streaming | Commits the card without stopping the current text; the hidden steer then creates a safe continuation that can correct a stale progress claim. | The unrelated text finishes normally unless another caller aborts it, and an ordinary abort cannot clear the admitted reconciliation. |
3024
+
3025
+ The visible card preserves the lifecycle custom type, raw notice text, exact details payload (including omitted optional fields), and display behavior. Each deduplicated occurrence has exactly one visible/persisted lifecycle card; the internal reconciliation is hidden and persisted separately only after agent-core consumes it at the provider-safe boundary. If the process exits after card admission but before consumption, startup finds the unresolved marker and queues that hidden correction once; repeated startup binding skips an already queued intent, and the persisted hidden completion suppresses all later restores. Protection is registered before public card listeners run. Session replacement and shutdown fail closed while the hidden input remains queued, since persisting it before a pending tool result would break provider protocol order; host-owned invalidation work does not run on that failed teardown. A transient reconciliation write failure retries persistence without re-queueing model input or creating another card. Physical session appends restore the exact prior file length after a partial write failure, so a later card or reconciliation retry cannot inherit a malformed JSONL tail or phantom parent. Before session replacement or shutdown can discard consumed in-memory recovery state, Atomic flushes the reconciliation again; if that write still fails, disposal stops and keeps the current session recoverable. `clearQueue()` restores only protected references it actually removed, so a reference already drained into core-local in-flight state is not aliased. Stage-session delivery transfer moves protection only with transferred queued references and leaves in-flight ownership at the source. Delivery is acknowledged only after the display card append succeeds; while the invoking chat remains active, a rejected admission retains its original payload and retries with capped backoff even if the run changes state or notification configuration is reinstalled. Session replacement cancels those admission attempts and clears their payloads rather than waking an unrelated chat with an uninspectable old run. Awaiting-input workflow states are tracked for dedupe/restore, but they do not enqueue main-chat connect cards or wake the model; prompt state remains visible through workflow status/connect surfaces.
3026
+
2394
3027
  When an active recoverable block is resumed in-process, Atomic dispatches a fresh-ID continuation that replays the source's completed stages and re-runs the failed one. The durable source is left untouched (stays `blocked`/resumable) so it remains discoverable and recoverable — including a zero-checkpoint first-stage block — if the process dies before the continuation settles; the local source snapshot is killed so the same session will not re-resume it. A process-local claim prevents a concurrent same-session double-dispatch.
2395
3028
 
2396
3029
  Configure lifecycle behavior with `workflowNotifications.enabled` (default `true`) and `workflowNotifications.notifyOn` (default `["completed", "failed", "blocked", "awaiting_input"]`).
@@ -2408,7 +3041,7 @@ When a workflow needs human input, answer in the graph viewer or attached stage
2408
3041
  /workflow attach <run-id> <stage-id-or-name>
2409
3042
  ```
2410
3043
 
2411
- Agents can answer primitive and structured pending prompts programmatically with `workflow({ action: "send", delivery: "answer", ... })`; use `promptId` when it is present in the stage details, and provide answer content with `response`, `text`, or `message`. Arbitrary custom TUI widget prompts intentionally refuse this path in iteration 1 because a generic `T` cannot be reconstructed safely from a non-TUI payload.
3044
+ Agents can answer primitive and structured pending prompts programmatically with `workflow({ action: "send", delivery: "answer", ... })` only while the root workflow is nonterminal; use `promptId` when it is present in the stage details, and provide answer content with `response`, `text`, or `message`. Arbitrary custom TUI widget prompts intentionally refuse this path in iteration 1 because a generic `T` cannot be reconstructed safely from a non-TUI payload.
2412
3045
 
2413
3046
  `ctx.ui.custom<T>(factory, options?)` reuses Atomic's TUI component path: the factory receives the same real `(tui, theme, keybindings, done)` types as extension `ctx.ui.custom`, and the workflow resumes with the value passed to `done(value)`. Use `options.label` for a safe display-only graph/status label and `options.replayIdentity` when widget semantics can change without the callsite changing. Do not put secrets in labels or replay identities; only a hash of the identity is stored, and label text is not part of replay identity. Inline connected rendering is supported; `overlay: true` is rejected clearly because nested workflow graph overlays are not safely supported yet.
2414
3047
 
@@ -2427,11 +3060,13 @@ The readiness prompt can be answered in the attached stage UI or with `workflow(
2427
3060
 
2428
3061
  ## Durable Workflows and Cross-Session Resume
2429
3062
 
2430
- 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; DBOS initialization, query, and write failures fail the workflow action and never select another backend.
3063
+ 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; DBOS query and write failures fail the workflow action and never select another backend.
2431
3064
 
2432
3065
  **Zero-configuration local database.** Without `DBOS_SYSTEM_DATABASE_URL`, Atomic runs DBOS against its own embedded Postgres built from npm-distributed binaries — no Docker daemon or system Postgres install. The cluster lives under `~/.atomic/postgres/v18` on dedicated port `5439`; the first workflow action initializes it once and starts it with `pg_ctl` as a detached daemon that survives Atomic exiting, is shared by every concurrent Atomic session, and is never stopped by Atomic.
2433
3066
 
2434
- When the embedded binaries are unavailable for the platform, Atomic falls back to DBOS's reusable `dbos-db` Docker container; if neither is usable, the workflow action fails with one actionable message: set `DBOS_SYSTEM_DATABASE_URL` to an existing Postgres.
3067
+ **Running as root (Linux).** PostgreSQL refuses to run as UID 0, so a root Atomic process (containers, CI sandboxes, eval harnesses) resolves an unprivileged system account (`postgres`, `nobody`, or `daemon`), keeps the cluster under `/var/lib/atomic-postgres` instead (a root home directory is untraversable for that account), and runs every Postgres command with dropped privileges. When the embedded binaries themselves sit under an untraversable prefix (for example a root-owned `~/.nvm` global install), Atomic copies the Postgres runtime into the cluster directory once and reuses it.
3068
+
3069
+ When the embedded binaries are unavailable for the platform, Atomic falls back to DBOS's reusable `dbos-db` Docker container. If no durable backend can be provisioned at all, workflows **degrade to a process-local in-memory backend with a loud warning** instead of refusing to run: the run executes normally, but its state does not survive the process and `/workflow resume` after exit has nothing to restore. Set `DBOS_SYSTEM_DATABASE_URL` to an existing Postgres to restore durability.
2435
3070
 
2436
3071
  **Multiple concurrent Atomic sessions.** Every Atomic process launches DBOS with a unique executor id, and running root workflows carry owner/heartbeat metadata refreshed by ordinary ≤30-second stage-timing checkpoints. **Running workflows are never resume targets**: a running row with a fresh heartbeat is hidden from every session's picker and refused by direct `/workflow resume <id>` — resuming a workflow that is executing elsewhere would double-dispatch it. Once the heartbeat goes stale (about two minutes after a crash), the workflow surfaces as a red `crashed` row.
2437
3072
 
@@ -2440,26 +3075,42 @@ When two sessions race to resume the same paused workflow, a durable first-write
2440
3075
  ### How it works
2441
3076
 
2442
3077
  - **Only `ctx.*` blocks are checkpointed**: code outside `ctx.*` is not durable.
2443
- - **Durable side effects**: Atomic flushes `ctx.tool` and `ctx.ui` writes before exposing completed results, so resume does not repeat an already-completed effect.
2444
- - **Durable graph operations**: stage, task, chain, parallel, and child-workflow checkpoints include current topology, timing, model, output, and retained chat-session references. Completed inspection reconstructs the graph directly from DBOS.
3078
+ - **Durable side effects and graph nodes**: every `ctx.tool` invocation creates a tracked, non-chat graph node before its callback runs. Atomic flushes successful outputs and opt-in recoverable failure outcomes before exposing them, so resume does not repeat an already-settled callback. Tool nodes can appear before, between, after, or without model stages. An unfinished, aborted, or abandoned tool node has no replayable result and runs again on resume, while completed siblings stay cache hits.
3079
+ - **Durable child identity before dispatch**: before a nested `ctx.workflow(...)` can run child code or a child side effect, Atomic persists and awaits a versioned boundary-start record containing its stable boundary and child run ids, root/parent ownership, source order and parents, composed replay scope, alias, workflow, lifecycle state, and a deterministic fingerprint of the definition plus exact validated inputs. Distinct-input parallel calls keep stable independent scopes even when restart reverses dispatch order; identical calls share that fingerprint and use their own ordinal. Replay validates and reuses that identity before allocating any UUID.
3080
+ - **Symmetric nested scopes**: child effects stay stored under the durable root, while every child sees only its own local checkpoint view. Each nesting layer strips exactly one scope and never suffix-matches sibling or root data, so the rule composes at any depth.
3081
+ - **Stable durable graph**: tool, stage, task, chain, parallel, and child-workflow checkpoints preserve stable source identity/order, parent DAG edges, actual status, owning-run/boundary metadata, timing, output summary, model, retained chat-session references, and exact `{ runId, stageId }` targets. Fresh-process resume and completed inspection reconstruct tool-only, nested-child, mixed, and parallel topology directly from DBOS.
2445
3082
  - **DBOS-only discovery**: `/workflow resume`, `/workflows`, completed inspection, deletion, and targeted lookup hydrate/query DBOS. Session JSONL remains only a chat transcript referenced by a current checkpoint; it is not a workflow catalog or discovery source.
2446
- - **Current format only**: Atomic encodes and decodes one current DBOS format. Prior local files and older DBOS records are not read, converted, or cleaned up. Unsupported or malformed records are ignored as foreign data.
2447
- - **Child side-effect scoping**: nested workflow effects are checkpointed under the durable root with stable child scopes.
3083
+ - **Fail-closed compatibility**: prior local and pre-current records are not converted. A completed current-format child boundary created before boundary-start or invocation-fingerprint identity is accepted only when child checkpoints reciprocally prove the same root, parent run, boundary, child, and scope. Active records without a provable invocation fingerprint, and malformed, duplicate, stale, nonreciprocal, mixed, aliased, cyclic, orphaned, or unsupported topology, are hidden or refused before cache/control/child dispatch without inventing a child link or executing repair work.
3084
+ - **Topology validation boundary**: authoring and discovery guidance cannot prove dynamic acyclicity. Runtime topology work must validate each materialized parent edge incrementally during execution and replay, and DBOS hydration must reject cyclic restored topology before exposing cache, control, or child dispatch.
2448
3085
  - **Cross-session safety**: per-process executor identity, owner/heartbeat liveness on running handles, and claim-guarded status transitions prevent double dispatch when several Atomic sessions share the database.
2449
3086
 
2450
3087
  **Privacy and retention.** DBOS persists workflow inputs, completed tool outputs, UI responses, stage outputs, and chat-session paths. Treat the configured database as sensitive. History does not automatically delete records by age or count; confirmed picker deletion removes inactive DBOS workflow state while preserving independent chat transcripts.
2451
3088
 
2452
- **Resume after editing a workflow.** Replay identity combines the workflow id with stable content hashes and call order. Editing, inserting, or reordering `ctx.*` calls can intentionally invalidate matches. Finish or delete retained runs before deploying incompatible workflow changes.
3089
+ **Resume after editing a workflow.** Replay identity combines the workflow id with stable content hashes and call order. Child calls additionally bind the child definition to the exact validated input value, with a per-identical-invocation ordinal. Editing definitions, inputs, or `ctx.*` call structure can intentionally invalidate matches. Finish or delete retained runs before deploying incompatible workflow changes. Atomic refuses a stored child boundary whose fingerprint, replay scope, alias, workflow, ownership, source order, or parentage no longer matches instead of attaching it to the changed call site.
2453
3090
 
2454
- Durable `/workflow resume` preserves completed stage metadata, active-stage elapsed time, total run elapsed time, and graph topology. While an LM stage or task is active, repeated durable checkpoints refresh its accumulated pause-adjusted duration even when its session file does not change, and refresh the run's total accumulated elapsed time alongside it; graceful quit and recoverable failure additionally persist the exact run total at the boundary.
3091
+ Durable `/workflow resume` preserves completed stage metadata, active-stage elapsed time, total run elapsed time, source order and parent edges, actual lifecycle status, nested ownership, and exact control targets. A completed nested boundary, its completed child stages, `ctx.tool` effects, and answered `ctx.ui` responses are cache hits; only incomplete child or downstream parent work continues. Raw stage-chat prompt answers represented by `StageSnapshot.promptAnswerState` remain live-memory-only and are not DBOS-persisted. While an LM stage or task is active, repeated durable checkpoints refresh its accumulated pause-adjusted duration even when its session file does not change, and refresh the run's total accumulated elapsed time alongside it. Graceful quit forces an exact stage and run timing checkpoint even inside the ordinary 30-second update bucket; normal completion also persists the final accumulated run total.
2455
3092
 
2456
- Each new Atomic process that reopens the unfinished session mid-chat starts from the latest saved baseline and uses the same continuation prompt shown above, so repeated process-boundary resumes keep status, graph, stored, and lifecycle duration cumulative without double-counting pauses from earlier process segments — a resumed mid-running stage timer continues from its previously accumulated elapsed time instead of restarting at zero, and the total workflow duration shown in the main-chat dashboard and status surfaces reports prior-session elapsed plus current-session elapsed.
3093
+ Each new Atomic process that reopens unfinished work starts from the latest saved baseline, so repeated process-boundary resumes keep stable boundary/child ids, status, graph, and lifecycle duration cumulative without double-counting pauses. A stage paused at ten seconds resumes at ten seconds, and the main-chat dashboard reports prior-session elapsed plus current-session elapsed. Completed inspection uses that same accumulated run timing rather than DBOS record wall-clock age.
2457
3094
 
2458
- Replayed `ctx.stage`, `ctx.task`, `ctx.chain`, `ctx.parallel`, and child-workflow checkpoints keep their original summaries, timing, session/model metadata, and parallel fanout parentage instead of appearing as freshly flattened replay nodes.
3095
+ Repeated, sibling, sequential, parallel, and multi-level child calls keep independent composed scopes and stable boundary order. The expanded graph routes attach, send, pause, interrupt, and resume through each stage's ordinary owning `{ runId, stageId}`. Exact expanded ids resolve first; local ids, prefixes, and names resolve only when unique, so collisions never select the first match silently.
2459
3096
 
2460
3097
  ### `ctx.tool` — durable cached tool execution
2461
3098
 
2462
- The `ctx.tool(name, args, fn, options?)` primitive runs arbitrary TypeScript code and caches the result durably. On resume, if that ordinal tool call already completed (matched by call order plus content hash of `name` + `args`), the runtime returns the cached result without re-executing the function ensuring completed side effects are not repeated while still allowing two intentional same-name/same-args calls in one workflow.
3099
+ The `ctx.tool(name, args, fn, options?)` primitive runs arbitrary TypeScript code as a first-class durable graph node and caches the result durably. The node is non-attachable and has no stage chat controls. It is valid before, between, after, or without model stages, so a tool-only workflow completes normally; a workflow that returns normally without any stage, child, tool, or explicit exit remains invalid. On resume, if that ordinal tool call already completed (matched by call order plus content hash of `name` + `args`), the runtime returns the cached result without re-executing the function—ensuring completed side effects are not repeated while still preserving two intentional same-name/same-args calls as distinct ordered nodes. Legacy child checkpoints without topology keep that cached output authoritative even if the additive ownership-migration write is temporarily unavailable: current replay uses inferred child ownership, a later replay retries the metadata write, and fresh completed inspection falls back to root ownership with topology unavailable until a migration succeeds.
3100
+
3101
+ When the workflow body fulfills but one or more admitted tool calls failed, Atomic promotes the first observed failure to the terminal run failure, regardless of admission order, and persists that selected tool-node identity for status inspection and lifecycle output. A direct uncaught `await ctx.tool(...)` rejection keeps the original error and persists its failed-node link through session and durable restore. First-event arbitration also preserves the selected node when concurrent failures throw the same object or primitive; unrelated later stage or body errors do not inherit a caught tool's origin. Tool admission remains open while author code can catch a failure and continue. Once the body settles and failure has won before any real cancellation, Atomic closes admission, cancels remaining non-failed tool nodes, waits for observed failed nodes to finish publication, and publishes the failed root without waiting for callbacks that ignore cancellation.
3102
+
3103
+ Set `failureMode: "return"` when a failed check is expected data for a later repair stage. Atomic runs all configured retries first, then returns a `WorkflowToolOutcome<TValue>`. A successful callback returns `{ ok: true, value, attempts, cached }`. An exhausted callback failure returns `{ ok: false, error, attempts, cached }`; `error` preserves integer `exitCode` and string or byte-buffer `stdout`/`stderr` when the thrown value exposes them. The live and restored tool node stays `failed`, while the workflow body may continue and complete. On replay, Atomic returns the same stored outcome with `cached: true` and does not run the callback again.
3104
+
3105
+ Recoverable output is explicit data flow. Atomic does not add a failed tool outcome to a later stage prompt. The workflow author must place the needed fields in `prompt`, `previous`, an output, or an artifact. Each persisted error text field is best-effort secret-redacted with the workflow persistence rules and limited to 16 KiB of UTF-8; truncated fields keep the final bytes with a marker. Keep the database sensitive even with this filter.
3106
+
3107
+ Cancellation, closed tool admission, and durable-storage faults still throw. They never become ordinary `{ ok: false }` callback outcomes. Omitting `failureMode: "return"` also keeps the existing behavior: an exhausted callback error rejects `ctx.tool` and fails the workflow unless author code catches it. Atomic persists that failed node and the root's selected tool link for later inspection, but excludes the failure record from the replay cache, so a resume or rerun calls the function again. Command failures that expose `exitCode`, `stdout`, or `stderr` remain failures even when a wrapper also uses cancellation-like text or codes; only a real run cancellation that wins the terminal race produces a killed/cancelled root.
3108
+
3109
+ **Per-node cancellation.** Each logical `ctx.tool` call runs under its own `AbortController`, combined with the run's signal and handed to the callback as `{ signal }`. A run abort cascades to every live node; `workflow({ action: "quit"|"interrupt", runId, stageId })` naming one tool node aborts exactly that node and leaves its siblings alone. All retries of one call share that single signal.
3110
+
3111
+ A cancelled call is recorded as `cancelled`, not `failed`, and is never a run failure by itself: it writes no replayable `tool:` checkpoint and no `return_failure` outcome even under `failureMode: "return"`, so a cancellation can never replay as data. Return mode does keep exactly one inspection-only `tool-failure:` record carrying the cancellation message, written for every cancellation timing — while the callback awaits, when the callback throws, and when the callback fulfills after the abort but before persistence. That id is excluded from replay lookup, so `getToolCheckpoint()` still misses and the call runs again. A callback that ignores its signal and returns late is caught before persistence, so its value cannot become a checkpoint either. Resume recomputes the same ordinal and `argsHash` from authored order, so the re-run occupies the same `tool:<argsHash>` graph node instead of creating a new one.
3112
+
3113
+ Tool admission stays open while the workflow body runs and while already-admitted tools drain, including immediate promise-settlement continuations. Before any completed, failed, blocked, exited, or cancelled executor outcome is published, admission closes atomically. A detached call through a retained `ctx.tool` function after that point returns a rejected native promise without starting its callback, retries, graph node, or durable checkpoint; ignoring that promise does not emit an unhandled rejection.
2463
3114
 
2464
3115
  ```ts
2465
3116
  export default workflow({
@@ -2467,11 +3118,13 @@ export default workflow({
2467
3118
  inputs: { source: Type.String() },
2468
3119
  run: async (ctx) => {
2469
3120
  // This side effect is cached durably. On resume, it will NOT re-execute.
3121
+ // Forwarding `signal` lets a quit or targeted abort stop a hung fetch instead of
3122
+ // pinning the run until the request gives up on its own.
2470
3123
  const data = await ctx.tool(
2471
3124
  "fetch-dataset",
2472
3125
  { source: ctx.inputs.source },
2473
- async () => {
2474
- const res = await fetch(ctx.inputs.source);
3126
+ async ({ signal }) => {
3127
+ const res = await fetch(ctx.inputs.source, { signal });
2475
3128
  return await res.text();
2476
3129
  },
2477
3130
  { retriesAllowed: true, maxAttempts: 3 },
@@ -2484,21 +3137,47 @@ export default workflow({
2484
3137
  });
2485
3138
  ```
2486
3139
 
3140
+ A bounded repair loop can pass only the needed failure evidence and use distinct arguments for each real rerun:
3141
+
3142
+ ```ts
3143
+ for (let iteration = 1; iteration <= 2; iteration += 1) {
3144
+ const tests = await ctx.tool(
3145
+ "run-tests",
3146
+ { iteration },
3147
+ async () => runCommand(["bun", "test"]),
3148
+ { failureMode: "return", retriesAllowed: true, maxAttempts: 2 },
3149
+ );
3150
+
3151
+ if (tests.ok) break;
3152
+ await ctx.task("repair-tests", {
3153
+ prompt: `Fix these test failures:\n${tests.error.stderr ?? tests.error.message}`,
3154
+ });
3155
+ }
3156
+ ```
3157
+
3158
+ Changing `iteration` makes each loop pass a distinct durable call. Reusing the same call position and arguments during resume replays its stored outcome instead of running it again.
3159
+
2487
3160
  ### `/workflow resume` — cross-session resume selector
2488
3161
 
2489
3162
  The `/workflow resume` command mirrors `/resume` ergonomics and `/workflows` is its alias. With no id, it builds one newest-first picker from eligible live runs 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`.
2490
3163
 
2491
- Rows carry semantic colors — completed green, paused yellow, failed/blocked/crashed red — and the open picker live-updates on local run changes plus a bounded cross-session poll, so state transitions appear (and freshly running workflows disappear) without reopening it.
3164
+ Rows carry semantic colors — completed green, paused yellow, failed/blocked/crashed red — and show checkpoint progress without the redundant pending-prompt count. The open picker live-updates on local run changes plus a bounded cross-session poll, so state transitions appear (and freshly running workflows disappear) without reopening it.
2492
3165
 
2493
3166
  Ctrl+D deletes a highlighted inactive durable or completed row after confirmation. Deletion rechecks same-process activity and the authoritative DBOS status, refuses a `running` workflow, and leaves host and stage chat transcripts untouched. The history surface matches `/resume` retention semantics: eligible runs remain searchable regardless of age or count, with no automatic history garbage collection. The picker mounts before asynchronous catalog hydration completes and merges DBOS rows when ready.
2494
3167
 
2495
3168
  Only current-format DBOS records are selectable. Atomic hides unsupported or malformed records without reinterpreting them.
2496
3169
 
2497
- Selecting a paused, failed, blocked, or crash-recovery target follows the existing resume path unchanged: Atomic re-dispatches the workflow with its cached inputs and the **original workflow id**, so previously completed `ctx.tool`, `ctx.ui`, stage/task/chain/parallel items, and child workflow boundaries replay from durable checkpoints rather than executing again. Selecting a completed target follows a separate open path.
3170
+ Selecting a paused, resumable failed, blocked, or crash-recovery target follows the existing resume path unchanged: Atomic re-dispatches the workflow with its cached inputs and the **original workflow id**. Every nested invocation validates and reuses its durable boundary and child identity before dispatch. Previously completed `ctx.tool`, `ctx.ui`, stage/task/chain/parallel items, and child boundaries replay from checkpoints instead of executing again; only incomplete work continues.
3171
+
3172
+ A run quit while a `ctx.tool` call was in flight resumes the same way: the unfinished call left no replayable checkpoint, so resume re-executes exactly that callback at the same ordinal and `tool:<argsHash>` node id, while every completed tool — including a sibling that finished before the quit — replays from cache. A cancelled node never replays a cancellation as a value.
3173
+
3174
+ Selecting a completed target—or a checkpointed failed target marked non-resumable—follows a separate read-only open path. Atomic reconstructs root and reciprocal nested child-run snapshots from authoritative checkpoints, remaps persisted source-stage, boundary, and tool references into a stable expanded hierarchy, and never calls the resume dispatcher or runs workflow code, tools, tasks, or prompts. These graphs remain inspectable even when no retained chat transcript survives, including tool-only graphs.
3175
+
3176
+ A terminal child stage with a valid retained session may be reopened for detached post-mortem conversation through `/workflow attach` or completed graph inspection. Follow-up is routed to that real child `{runId, stageId}` and may append chat, but it cannot pause, resume, retry, mutate root or child execution state, write a terminal checkpoint, or emit a duplicate lifecycle notice. Programmatic `workflow send` rejects the terminal root before nested-owner routing or session probing. Tool nodes never offer chat attachment.
2498
3177
 
2499
- Atomic reconstructs a completed run/stage snapshot from authoritative checkpoints, remaps persisted source-stage parent references to the reconstructed stage ids in two passes, and opens the detail/chat overlay without calling the durable resume dispatcher or re-running workflow stages, tools, tasks, prompts, or workflow code.
3178
+ New tool checkpoints persist topology. A current-format tool checkpoint created before that additive topology existed still replays safely: its cached output remains authoritative and its callback is never rerun. Root-level inspection derives deterministic fallback identity/order from checkpoint identity and record order. If a topology-less cached tool replays inside a child workflow, Atomic first appends awaited topology metadata with the current child/boundary ownership, without replacing the original output checkpoint. Foreign or malformed checkpoint formats remain excluded.
2500
3179
 
2501
- Completed detail state is read-only. A retained stage chat may be reopened for follow-up without resuming workflow execution or mutating its DBOS handle. Current checkpoints always include supported topology; foreign checkpoints are excluded rather than displayed with inferred edges.
3180
+ Fresh completed inspection does not currently persist the workflow's declared root output. Live `run()` results still expose the declared output, and this output-persistence limit does not block durable tool topology or read-only graph inspection.
2502
3181
 
2503
3182
  ```text
2504
3183
  /workflow resume # Mixed picker: resumable + completed
@@ -2507,11 +3186,13 @@ Completed detail state is read-only. A retained stage chat may be reopened for f
2507
3186
  /workflows <workflow-id-or-prefix> # Alias for targeted resume/open
2508
3187
  ```
2509
3188
 
2510
- Explicit full IDs take precedence, while prefixes resolve across top-level live, resumable durable, and completed targets as one namespace. An exact loadable paused top-level live target resumes directly from in-session state without enumerating the durable completed-history catalog; this keeps explicit live resume responsive even when retained durable history is large and preserves live-over-durable precedence for duplicate IDs. Nested child runs remain excluded from this top-level target namespace even when addressed by an exact ID.
3189
+ Explicit full IDs take precedence, while prefixes resolve across top-level live, resumable durable, and completed targets as one namespace. An exact loadable paused top-level live target resumes directly from in-session state without enumerating the durable completed-history catalog; this keeps explicit live resume responsive even when retained durable history is large and preserves live-over-durable precedence for duplicate IDs. If a stale or concurrent catalog view presents the same failed root as both resumable and read-only history, the resumable durable target wins for exact and prefix routing. Nested child runs remain excluded from this top-level target namespace even when addressed by an exact ID.
2511
3190
 
2512
- Prefixes and other targets continue through the combined catalog so ambiguity and completed-inspection behavior remain unchanged. Ambiguous prefixes use the existing-style ambiguity diagnostic. A completed backend row with no checkpoints or no usable retained stage conversation is hidden from the picker; an explicit target reports that it is stale or missing required durable checkpoint/session data. A completed run remains inspectable when at least one stage has a usable transcript; missing, empty, directory, context-empty, or partially malformed transcript paths are omitted from stage chat attachment.
3191
+ The non-interactive `workflow({ action: "resume", runId: "<id-or-prefix>" })` surface uses the same durable resumable-target lookup behavior for explicit targets. If the target is absent locally, Atomic loads workflow resources, queries the authoritative DBOS resumable catalog, and only then reports a missing run. This targeted hydration does not change `workflow({ action: "status" })`: an empty session-local status before explicit resume does not imply that DBOS deleted the workflow.
2513
3192
 
2514
- Validation uses the final retained transcript for a repeated stage replay key, so an obsolete superseded checkpoint path does not hide an otherwise valid completed run. Reopening inspection refreshes a changed authoritative retained-chat handle. Session-cache-only rows are likewise hidden because the backend is authoritative. Cancelled, killed, non-resumable failed, and other terminal non-success states are never added. Normal `/resume`, `atomic -r`, and `--continue` behavior for internal workflow stage sessions is unchanged.
3193
+ Prefixes and other targets continue through the combined catalog so ambiguity and read-only inspection behavior remain unchanged. Ambiguous prefixes use the existing-style diagnostic. A current completed or non-resumable failed backend row with valid graph checkpoints remains inspectable even if every retained stage conversation is unavailable. Missing, empty, directory, context-empty, or partially malformed transcript paths are stripped from chat attachment while the graph stays read-only and visible.
3194
+
3195
+ Validation uses the final retained transcript for a repeated stage replay key, so an obsolete superseded checkpoint path does not hide an otherwise valid read-only graph. Reopening inspection refreshes a changed authoritative retained-chat handle. Session-cache-only rows are hidden because the backend is authoritative. Checkpointed non-resumable failed roots appear only in read-only history; cancelled, killed, blocked non-resumable, failed roots without saved progress, and other terminal non-success states are never added. Normal `/resume`, `atomic -r`, and `--continue` behavior for internal workflow stage sessions is unchanged.
2515
3196
 
2516
3197
  ### Cancellation, failure, and retry semantics
2517
3198
 
@@ -2519,14 +3200,18 @@ Validation uses the final retained transcript for a repeated stage replay key, s
2519
3200
  | --- | --- |
2520
3201
  | **Internally cancelled workflow** | Marked `cancelled` in durable state and excluded from `/workflow resume` discovery. Start a new workflow run if you intentionally want to retry cancelled work. |
2521
3202
  | **Stage failure (recoverable)** | Workflow marked `failed` or `blocked` and remains resumable by default. `/workflow resume <id>` continues from the last completed checkpoint unless durable metadata explicitly sets `resumable: false`. |
2522
- | **Stage failure (non-recoverable)** | Workflow marked `failed` or `blocked` with `resumable: false`, so it is excluded from resume discovery. |
3203
+ | **Stage failure (non-recoverable)** | Workflow marked `failed` or `blocked` with `resumable: false`, so it cannot resume execution. A failed root with saved checkpoint progress may still appear in read-only history for inspection; a blocked root does not. |
2523
3204
  | **Process crash** | Workflow remains `running` in durable state. On next session start, it appears in resume discovery when it has a durable checkpoint or pending prompt. Resume re-executes from the last completed checkpoint. |
2524
- | **`ctx.tool` retry** | When `retriesAllowed: true`, the tool function is retried with exponential backoff. Cancellation is checked before each attempt and during retry backoff, so later attempts do not run after the workflow is cancelled. After exhausting retries, the error propagates and the workflow fails. |
3205
+ | **`ctx.tool` retry/default failure** | When `retriesAllowed: true`, the tool function is retried with exponential backoff. Cancellation is checked before each attempt, during retry backoff, and through the callback's own `signal`. Without `failureMode: "return"`, an exhausted callback error propagates and the workflow fails. |
3206
+ | **Recoverable `ctx.tool` failure** | With `failureMode: "return"`, exhausted callback failures are durably returned after retries. The tool node remains failed, downstream handoff is explicit, and replay returns the same outcome with `cached: true`. Cancellation and storage faults still throw. |
3207
+ | **`ctx.tool` node quit/interrupt** | `quit`/`interrupt` with a tool node id or name aborts that call's signal, marks the node `cancelled`, and leaves sibling stages and tools running. The action returns `status: "cancelled"` with the separately observed `workflowStatus`; it never reports the run as paused. No replayable `tool:` checkpoint and no `return_failure` outcome are written — return mode writes only inspection metadata — so resume re-runs exactly that call at the same ordinal and node id. |
3208
+ | **Run quit with in-flight tools** | Quit closes tool admission after stage pauses acknowledge, rescans every root/nested node, aborts that set, and waits a bounded interval before recording the durable paused/resumable transition, so the run is not declared quiesced while a callback still runs and no late call can slip in. A tool-only run pauses as resumable instead of reporting no controllable stages. A call attempted after the close is refused with the graceful-quit signal. Catching the cancellation in workflow code cannot turn the quit into a completed run. |
3209
+ | **Abandoned `ctx.tool` callback** | A callback that ignores its abort signal is abandoned after the bounded wait: quit proceeds, the node is published as `cancelled`, each abandoned call is reported as an owning `{runId, nodeId}` identity, and the stale background job is detached so resume relaunches a fresh executor under the same workflow id. A late return from that callback is discarded before persistence, cannot become a checkpoint, and cannot mutate or unregister the replacement run. |
2525
3210
  | **`ctx.ui` pending prompt** | If a UI prompt was not answered before interruption, resume leaves off on that prompt — the user must answer it to continue. |
2526
3211
 
2527
3212
  ### Configuring DBOS/Postgres
2528
3213
 
2529
- DBOS/Postgres durability requires no setup on supported local platforms. To use an existing Postgres database, set `DBOS_SYSTEM_DATABASE_URL` before starting Atomic; otherwise Atomic provisions embedded Postgres, with Docker as a platform fallback. The DBOS SDK ships with `@bastani/atomic`. If the SDK cannot load or Postgres cannot be reached or provisioned, Atomic fails the workflow action with an actionable diagnostic instead of falling back to the legacy per-workflow file store under `~/.atomic/workflow-durable`.
3214
+ DBOS/Postgres durability requires no setup on supported local platforms. To use an existing Postgres database, set `DBOS_SYSTEM_DATABASE_URL` before starting Atomic; otherwise Atomic provisions embedded Postgres (with drop-privilege support when running as root on Linux), with Docker as a platform fallback. The DBOS SDK ships with `@bastani/atomic`. If no durable backend can be provisioned, workflows run on a process-local in-memory backend with a loud non-durable warning never on the legacy per-workflow file store under `~/.atomic/workflow-durable` — and cross-process resume is unavailable until Postgres provisioning is fixed.
2530
3215
 
2531
3216
  ```bash
2532
3217
  export DBOS_SYSTEM_DATABASE_URL="postgresql://user:password@localhost:5432/atomic_dbos_sys"
@@ -2597,6 +3282,8 @@ Run `/workflow reload` after adding, editing, renaming, or deleting workflow mod
2597
3282
 
2598
3283
  Reload builds a complete replacement registry before publishing it. Concurrent requests are serialized and coalesced, stale discovery from an earlier session cannot overwrite newer state, and a fatal refresh failure retains the previous registry. Reload is safe while workflows are running: existing runs keep the definition and runtime snapshot they started with, while subsequent list/get/inputs/help/completion/invocation calls use the newly published registry.
2599
3284
 
3285
+ The `/workflow` argument-completion popup reads that same live registry. Project, user, package-provided, and built-in workflow names therefore appear immediately after reload both after `/workflow ` and after `/workflow inputs `; restarting Atomic is not required.
3286
+
2600
3287
  A successful rescan may still contain per-resource diagnostics. Both reload surfaces show `CONFIG_INVALID`, `IMPORT_FAILED`, `INVALID_DEFINITION`, `PATH_NOT_FOUND`, and duplicate-name diagnostics instead of reporting bare success while silently skipping a resource. Valid sibling workflows remain available. Fix the reported source/path and reload again; no process restart is required.
2601
3288
 
2602
3289
  ## Workflow Configuration
@@ -3064,14 +3751,19 @@ This runtime migration stub exists only so old modules fail at the callsite with
3064
3751
 
3065
3752
  ```typescript
3066
3753
  import {
3067
- deepResearchCodebase,
3754
+ adversarialVerification,
3755
+ classifyAndAct,
3756
+ fanOutAndSynthesize,
3757
+ generateAndFilter,
3068
3758
  goal,
3759
+ loopUntilDone,
3069
3760
  openClaudeDesign,
3070
3761
  ralph,
3762
+ tournament,
3071
3763
  } from "@bastani/workflows/builtin";
3072
3764
  ```
3073
3765
 
3074
- Each builtin is a workflow definition. The barrel and individual module paths also export the six pattern workflows documented below. See [Compose with builtin workflows](#compose-with-builtin-workflows) for the import table and a parent workflow example.
3766
+ Each export is a workflow definition. All nine definitions are available through individual module paths. See [Compose with builtin workflows](#compose-with-builtin-workflows) for a parent workflow example.
3075
3767
 
3076
3768
 
3077
3769
  ## Fast Inference for Workflow Stages
@@ -3092,13 +3784,16 @@ A workflow is an information-flow system, not just a list of prompts. Most workf
3092
3784
 
3093
3785
  ### Locally Scoped Stage Prompts
3094
3786
 
3095
- Stage prompts should define local contracts, not describe the full workflow runtime. Write prompts as if the stage could be executed independently from a fresh session with only the listed inputs. Include:
3787
+ Stage prompts should define local contracts, not describe the full workflow runtime. Write prompts as if the stage could be executed independently from a fresh session with only the listed inputs. A useful compact shape is `Role · Goal · Success criteria · Constraints · Tools · Output · Stop rules`; omit sections that do not change behavior. Include:
3096
3788
 
3097
3789
  - the stage's current objective and what is out of scope for this stage
3098
- - the exact files, artifacts, child outputs, or user inputs it may use
3099
- - the expected output format, or the schema it must return when the workflow item is schema-enabled
3100
- - the checks, tools, or deterministic commands it should run when relevant
3101
- - the success criteria that let this stage stop
3790
+ - the exact files, artifacts, child outputs, or user inputs it may use; put long inputs before the final instruction
3791
+ - context-dependent tool routes and permission boundaries, without describing tools the stage cannot call
3792
+ - the expected output format and length, or the schema it must return when the workflow item is schema-enabled
3793
+ - the checks, tools, or deterministic commands it should run when relevant, plus evidence required for progress or completion claims
3794
+ - the success criteria and blocker conditions that let this stage stop
3795
+
3796
+ State important constraints once. Reserve absolute wording for safety, required fields, forbidden actions, gating derivations, and other true invariants; express search, iteration, and delegation choices as decision rules. Ask for conclusions, commands, observed results, and citations—not private reasoning or generic self-verification.
3102
3797
 
3103
3798
  Avoid unrelated workflow internals such as reducer algorithms, future PR stages, sibling reviewer names, loop implementation details, or project-specific nicknames unless they are explicitly part of the current stage contract. If a term such as a gate name, ledger field, or workflow nickname is necessary, define it in the prompt before using it.
3104
3799
 
@@ -3113,7 +3808,7 @@ Context mode is an execution property configured with `context`/`forkFromSession
3113
3808
  - **Forked continuation prompts send only the delta.** A forked stage already carries the role, contracts, guidance, and output format from its own earlier prompts, so repeating them uses more tokens and can make the two copies diverge. Send what changed since the fork point — new artifacts, updated state, the next action — plus a one-line pointer back ("the contracts and report format established earlier in this thread still apply unchanged") instead of re-injecting the full text.
3114
3809
  - **Keep one canonical copy of shared contracts.** When fresh and forked variants of a stage share guidance, render the full contract only in the prompt that first establishes it and reference it from continuations. If a continuation needs a contract restated (for example, after a schema change), that is a new contract version, not a repeat.
3115
3810
 
3116
- The builtin `goal` and `ralph` workflows follow this pattern: their first worker/orchestrator prompts include the full contracts, while forked continuation turns send only the per-turn state (new receipts, the latest review artifacts, the rewritten research file) with a pointer back to the established guidance.
3811
+ Long-running worker/reviewer workflows should follow this pattern: establish the complete contract once, then send forked continuation turns only the latest state and artifact paths with a pointer back to the established guidance.
3117
3812
 
3118
3813
  ### Context Fundamentals
3119
3814
 
@@ -3135,10 +3830,10 @@ Watch for these failure modes in long or multi-stage workflows:
3135
3830
 
3136
3831
  | Pattern | Symptom | Mitigation |
3137
3832
  |---------|---------|------------|
3138
- | Lost in the middle | Important constraints are ignored in long prompts | Repeat critical constraints near the end; shorten handoffs |
3833
+ | Lost in the middle | Important constraints are ignored in long prompts | Shorten the handoff; place documents first and the final query/critical contract last |
3139
3834
  | Context poisoning | Bad or obsolete information steers later stages | Validate sources, overwrite stale artifacts, cite evidence |
3140
3835
  | Distraction | Irrelevant context crowds out useful context | Pass only stage-specific files and summaries |
3141
- | Confusion | Similar instructions or duplicate facts conflict | Consolidate instructions and name artifacts clearly |
3836
+ | Confusion | Similar instructions or duplicate facts conflict | Consolidate each shared contract into one canonical copy and name artifacts clearly |
3142
3837
  | Clash | User, system, or stage instructions disagree | Resolve conflicts before launching downstream stages |
3143
3838
 
3144
3839
  Use compaction, file references, and bounded loops before context fills with transcript noise. In attached workflow stage chat, manual compaction shows `Compacting context...`, threshold compaction shows `Auto-compacting...`, and overflow recovery shows `Context overflow detected. Auto-compacting...` in the same animated status row used for normal model work. A successful compaction leaves the normal expandable `✻ Context compacted` boundary in the transcript; the boundary is reconstructed from the durable session and has a typed live fallback if the refreshed session snapshot is temporarily unavailable.
@@ -3156,14 +3851,20 @@ A compressed handoff includes:
3156
3851
  - rejected alternatives when they matter
3157
3852
  - next action expected from the downstream stage
3158
3853
 
3159
- Use `output`, `outputMode: "file-only"`, and `reads` for large research bundles, logs, or reviewer outputs. Keep summaries compact and let downstream stages read full artifacts only when needed. In the downstream stage prompt, say `Read the file at ${artifactPath} before continuing.` Do not inject full session tails, all previous stage outputs, or every prior review round into later prompts by default; pass the latest relevant artifact paths and make older history discoverable from a ledger or index file.
3854
+ Pass file references, not content. This is the strongly encouraged default for every handoff — between stages and back to the caller — and it is what keeps a multi-stage run affordable. Use `output` with `outputMode: "file-only"` and `reads` for research bundles, logs, plans, diffs, reviewer reports, and any other stage product that can grow. In the downstream stage prompt, say `Read the file at ${artifactPath} before continuing.` Do not inject full session tails, all previous stage outputs, or every prior review round into later prompts by default; pass the latest relevant artifact paths and make older history discoverable from a ledger or index file.
3855
+
3856
+ Three rules make that work in practice:
3160
3857
 
3161
- Substantial handoffs should travel through files or durable artifacts instead of hidden transcript assumptions. This keeps stage prompts small, makes review/audit possible, and lets later stages reread the authoritative material without depending on what a previous model summarized.
3858
+ 1. **One owner per artifact.** The runner writes the stage's final message to `output` after the stage ends. Do not also ask that stage's prompt to author the same path, or the agent's file is overwritten by its closing message. Either the stage returns the content and the runner saves it, or the prompt writes a path the stage does not declare as `output`.
3859
+ 2. **Do not read an artifact back just to return it.** `outputMode: "file-only"` exists so the parent receives a compact reference. Calling `readFile` on that artifact and returning its text as a workflow output cancels the saving and drops the whole report into the caller's context window. Return the reference and a `*_path` output instead.
3860
+ 3. **Return paths from the workflow.** Declared outputs are consumed by the calling session, so a workflow's `result` should be a reference plus explicit `*_path` outputs. Callers that need the body read the path; callers that only need the outcome pay nothing for it.
3861
+
3862
+ Substantial handoffs should travel through files or durable artifacts instead of hidden transcript assumptions. This keeps stage prompts small, makes review/audit possible, and lets later stages reread the authoritative material without depending on what a previous model summarized. Remember that `reads` passes paths rather than content: a stage reads the file when it runs, so the artifact must hold the real report at that moment.
3162
3863
 
3163
3864
  ```ts
3164
3865
  const researchPath = ".atomic/workflows/runs/context-demo/research.md";
3165
3866
  await ctx.task("researcher", {
3166
- task: "Map the subsystem and save the report.",
3867
+ task: "Map the subsystem and return the report as your final message; the workflow saves it.",
3167
3868
  output: researchPath,
3168
3869
  outputMode: "file-only",
3169
3870
  });
@@ -3223,11 +3924,11 @@ Build validation into the workflow instead of waiting for a final manual check.
3223
3924
  - reviewer stages: fresh-context reviewers that inspect artifacts and current files
3224
3925
  - LLM-as-judge stages: direct scoring, pairwise comparison, or rubric-based grading for subjective outputs
3225
3926
 
3226
- Prefer schema-enabled workflow items for model review and gate decisions. Atomic passes the schema directly to the final-answer tool and captures the tool arguments; it no longer adds separate structured-output parsing, object-root restrictions, or sidecar validation. Object-shaped decision schemas with explicit booleans/enums, findings arrays, confidence, evidence fields, and error reporting are usually easiest to consume, but array or primitive schemas are valid when they fit the handoff. Avoid brittle regular-expression matching against free-form prose such as “looks good”, “approved”, or “PASS”.
3927
+ Prefer schema-enabled workflow items for model review and gate decisions. Atomic passes the schema directly to the final-answer tool and captures the tool arguments; it no longer adds separate structured-output parsing, object-root restrictions, or sidecar validation. Object-shaped decision schemas with explicit booleans/enums, findings arrays, confidence, evidence fields, and error reporting are usually easiest to consume, but array or primitive schemas are valid when they fit the handoff. Avoid brittle regular-expression matching against free-form prose such as “looks good”, “approved”, or “PASS”. Define each convergence field's derivation once and consume it deterministically rather than recomputing approval from narrative text.
3227
3928
 
3228
- Use small dedicated model stages for adaptive gates when deterministic code alone cannot decide what to check. For example, a stage can read an artifact, inspect the repo, run a named tool or command, and then emit a structured decision by configuring `schema` on that workflow item. Keep that stage's prompt narrow: tell it the specific check to perform, the files/tools it may use, and the structured decision it must return.
3929
+ Use small dedicated model stages for adaptive gates when deterministic code alone cannot decide what to check. For example, a stage can read an artifact, inspect the repo, run a named tool or command, and then emit a structured decision by configuring `schema` on that workflow item. Keep that stage's prompt narrow: tell it the specific check to perform, the files/tools it may use, the evidence to report, and the structured decision it must return. Require progress and completion claims to map to current tool results; when evidence is unavailable, the stage should identify the unverified claim or blocker rather than infer success.
3229
3930
 
3230
- When using LLM judges, reduce bias by defining score anchors, asking for evidence, calibrating against examples, and keeping length/order effects in mind. Track pass rates and failures over time for reusable workflows.
3931
+ When using LLM judges, reduce bias by defining score anchors, requesting observable evidence and criteria-based justification, calibrating against examples, and keeping length/order effects in mind. Do not ask for chain-of-thought or reconstructed internal reasoning. Track pass rates and failures over time for reusable workflows.
3231
3932
 
3232
3933
  ### Tools, MCP, Memory, and Hosted Execution
3233
3934
 
@@ -3380,6 +4081,8 @@ Before implementing or shipping a non-trivial workflow, answer these questions:
3380
4081
  - **Output contract:** Which outputs should be declared in `outputs`, which stage/task/child results should `run` return for those keys, and what runtime type must each value have? If another workflow may call this workflow as a child, which non-default outputs should the parent rely on?
3381
4082
  - **Context size:** Can downstream stages succeed from the handoff alone? Should large transcripts, logs, or research bundles be summarized or saved as artifacts?
3382
4083
  - **Control flow:** Should the workflow use `ctx.chain`, `ctx.parallel`, `ctx.ui`, bounded loops, `failFast`, or `fallbackModels`?
4084
+ - **Acyclic topology:** What node and dependency shape can each branch, bounded loop, and nested workflow boundary materialize? Which stages repeat, does each iteration create distinct tracked work with stable identity and call order, and what is the current frontier before each repeat? Could any proposed parent edge target the node itself or an ancestor? Are nested children composed through `ctx.workflow(...)` boundaries rather than recursive `run` invocation? Redesign or stop before launch if any self-edge or back-edge remains.
4085
+ - **Scope control:** Could valid adjacent findings expand the patch? If so, where will a fresh scope guard read the immutable contract, how will it classify and persist bounded decisions, which `warn`/`block`/`off` fallback applies, and which worker session owns any forked continuation?
3383
4086
  - **User experience:** Are stage names readable in status and graph views? Is the final output compact? Are important artifacts saved with stable paths?
3384
4087
  - **Validation:** What success criteria, review gates, deterministic checks, or evaluator stages prove the workflow did the right thing? Are model gates schema-backed instead of regex/prose-matched, and do adaptive gates run as focused model stages with explicit tool/check instructions?
3385
4088
  - **Final actions:** Does the workflow distinguish implementation/review convergence from post-approval final actions such as PR/MR/review creation, release tagging, deployment, or publication? Are reviewers and reducers prompted to approve and hand off when implementation and validation criteria are proven and only an explicitly authorized final action remains?
@@ -3392,16 +4095,20 @@ Good workflows are information-flow systems, not just prompt sequences. Keep sta
3392
4095
  - Do not guess input keys; inspect with `inputs` or `get` first.
3393
4096
  - Do not call `create`, `update`, or `delete` on the workflow tool; definitions are code-authored.
3394
4097
  - Do not use legacy workflow tool fields like `agent`, `stage`, or run-control `name`.
3395
- - Do not pass strings such as `"goal"` or path objects to `ctx.workflow(...)`; import the workflow definition from `@bastani/workflows/builtin` or another TypeScript module first.
4098
+ - Do not pass strings or path objects to `ctx.workflow(...)`; import the workflow definition from `@bastani/workflows/builtin` or another TypeScript module first.
4099
+ - Do not create a self-edge or a dependency edge from the current frontier to an existing ancestor. Cyclic workflow graphs are unsupported; redesign or stop before launch when a cycle cannot be removed.
4100
+ - Do not model a bounded loop by reopening an earlier node beneath its downstream work. Create distinct tracked work per iteration and keep retained-session follow-up as non-topological activity when it adds no dependency work.
4101
+ - Do not claim TypeScript or workflow discovery proves a dynamic workflow acyclic. Discovery diagnoses imports and definition shape; execution, replay, and DBOS hydration are the runtime topology boundary.
3396
4102
  - Do not rely on undeclared child outputs; returning a key that is not declared in `outputs` fails the run. Declare every child-workflow field you expose in `outputs` — including `result` — and return values matching those schemas from `run` (see [Outputs](#outputs)).
3397
4103
  - Do not expect to select or rename child outputs at the call site; parent workflows receive the child's declared output contract as `child.outputs` after checking `child.exited === false`, and a partial declared-output map when `child.exited === true`.
3398
4104
  - Do not expect named workflow runs to block the chat turn; they are background tasks.
3399
4105
  - Use `interrupt` or `pause` when the user asks to pause specific live work resumably; use `quit` for a graceful run-level process boundary.
3400
4106
  - Keep stage names readable because they appear in workflow status and UI.
3401
- - Do not ask a stage to reason from workflow or stage names that are only orchestration labels. Model stages see their local prompt/artifacts/tools; describe the action to perform and the evidence to use (`review the current code delta`, `create/update the review request`) instead of relying on labels such as `this Goal run` or `the Ralph reviewer` — see the prompt-vocabulary item in the [Design Checklist](#design-checklist).
4107
+ - Do not ask a stage to reason from workflow or stage names that are only orchestration labels. Model stages see their local prompt, artifacts, tools, and reads; describe the concrete action and evidence instead of referring to an implementation-specific nickname.
3402
4108
  - Do not write stage prompts that depend on hidden workflow-wide awareness; make each model stage locally scoped and self-described ([Locally Scoped Stage Prompts](#locally-scoped-stage-prompts)).
3403
4109
  - Do not parse model gate decisions from ad-hoc prose with regular expressions; configure `schema` on a focused workflow item and consume `result.structured`.
3404
4110
  - Do not make reviewers fail an implementation gate solely because an authorized final action has not run yet. Represent that remainder as a post-approval next action (for example `finalActionRemaining` / `nextAction`) and let the final stage perform it.
4111
+ - Do not let scope guards approve correctness or turn follow-up findings into blockers. Keep scope decisions separate from code review and deterministic validation, and do not reject expected pre-publication state assigned to a later lifecycle stage.
3405
4112
  - Return compact structured decisions and save large artifacts to files; artifact handoffs should still use files when the next stage does not need the whole payload in context.
3406
4113
 
3407
4114
  These mistakes cover workflow tool usage and authoring. For run-prompt anti-patterns, see the [Anti-patterns](#anti-patterns) table in [Workflow Best Practices](#workflow-best-practices).
@@ -3426,6 +4133,8 @@ The core workflow pattern is:
3426
4133
  Objective -> Scope -> Done criteria -> Run -> Inspect -> Steer -> Validate -> Summarize
3427
4134
  ```
3428
4135
 
4136
+ Apply this loop per independently verifiable implementation item. When a request contains several items, first use the [task-queue triage and bounded per-item dispatch rule](#task-queues-and-software-factories); do not make one item's inspect/steer/validate cycle block an unrelated item.
4137
+
3429
4138
  Use this sequence:
3430
4139
 
3431
4140
  1. Define the end state.
@@ -3600,7 +4309,9 @@ Summarize root cause, proposed fix, files involved, validation plan, and remaini
3600
4309
 
3601
4310
  For workflows larger than one tracked task, choose a small control-flow pattern before writing prompts. **Workflow authors should favor these common patterns by default:** naming the pattern up front keeps the stage graph understandable, makes validation gates explicit, and helps reviewers see why work is split across model sessions. Reach for a bespoke structure only when none of these patterns fit.
3602
4311
 
3603
- These patterns are composable and the headings below link to runnable builtins. For example, a migration workflow can nest [**fan-out-and-synthesize**](#six-composable-pattern-builtins) for call-site fixes, [**adversarial-verification**](#six-composable-pattern-builtins) per patch, and [**loop-until-done**](#six-composable-pattern-builtins) while tests still fail. Import and compose the builtin definitions instead of copying their prompts/graphs.
4312
+ The first six patterns below have runnable builtins. For example, a migration workflow can nest [**fan-out-and-synthesize**](#six-composable-pattern-builtins) for call-site fixes, [**adversarial-verification**](#six-composable-pattern-builtins) per patch, and [**loop-until-done**](#six-composable-pattern-builtins) while tests still fail. Import and compose the builtin definitions instead of copying their prompts/graphs. **Scope guard** is an authoring starter pattern rather than a builtin; compose its [boundary-task, retained-stage, or live-parallel form](#scope-guard-starter-pattern) from current primitives.
4313
+
4314
+ These graph patterns organize work **inside one root lifecycle**. They do not replace the [task-queue rule](#task-queues-and-software-factories): independent whole implementation items normally get separate top-level runs and failure boundaries, while real dependency clusters may use these patterns inside each cluster run.
3604
4315
 
3605
4316
  | Pattern | Use it when | Atomic shape |
3606
4317
  |---|---|---|
@@ -3610,6 +4321,7 @@ These patterns are composable and the headings below link to runnable builtins.
3610
4321
  | **Generate-and-filter** | You need many candidate ideas, plans, names, fixes, or hypotheses before selecting the best few. | Generator fan-out → dedupe/filter stage → optional verifier/judge → final shortlist. |
3611
4322
  | **Tournament** | The whole task is subjective or approach-sensitive, and comparative judgment is more reliable than absolute scoring. | Several agents attempt the same task → pairwise judges compare results → bracket reducer returns winners. |
3612
4323
  | **Loop until done** | The amount of work is unknown up front, such as finding all failures, mining repeated issues, or iterating until checks pass. | Bounded loop with an explicit stop condition, progress ledger, per-iteration artifacts, and a max-iteration escape hatch. |
4324
+ | **Scope guard** | A worker or repair stage may turn valid adjacent findings into unplanned work. | Immutable contract artifact → fresh boundary or live scope checker → bounded decision artifact → forked worker continuation; correctness review stays separate. |
3613
4325
 
3614
4326
  #### Pattern diagrams
3615
4327
 
@@ -3674,23 +4386,24 @@ Builtin definition and contracts: [Six composable pattern builtins](#six-composa
3674
4386
  ┌─ 3 Adversarial verification ────────────────────────────┐
3675
4387
  │ │
3676
4388
  │ │
3677
- ┌──────────┐
3678
- ├────────────────▸│verifier A│
3679
- └──────────┘
3680
- ┌──────┐ ┌──────────┐
3681
- │worker│◂────┼────────────────▸│verifier B│
3682
- └──────┘ └──────────┘
3683
- ┌──────────┐
3684
- ├────────────────▸│verifier C│
3685
- └──────────┘
4389
+ ┌──────┐ ┌──────────┐
4390
+ │worker│───╮──▸│verifier A│──╮
4391
+ └──────┘ └──────────┘
4392
+ ┌──────────┐ ┌───────┐ │
4393
+ ├──▸│verifier B│──┼──▸│reducer
4394
+ └──────────┘ └───────┘ │
4395
+ ┌──────────┐
4396
+ ╰──▸│verifier C│──╯
4397
+ └──────────┘
3686
4398
  │ │
3687
4399
  └──────────────────────────────────────────────────────────┘
3688
4400
  ```
3689
4401
 
3690
4402
  Best practices:
3691
- - Give verifiers fresh context and a concrete rubric with pass/fail evidence requirements.
3692
- - Separate implementation or generation from independent judgment to reduce a model's bias toward its own output.
3693
- - Ask verifiers to find blockers and not rewrite the candidate unless you explicitly assign them to repair it.
4403
+ - Give verifiers fresh context and a concrete rubric with pass/fail evidence requirements. For task-specific contract risk, use a grumpy/skeptical-but-fair persona that seeks realistic counterexamples, stays within the literal objective, rejects hand-waving and circular worker-authored evidence, and reports only actionable evidence-backed defects.
4404
+ - Separate adversarial probe design from authoritative execution. Require a structured verifier plan with each exact probe, inputs, command/assertion, expected success condition, and covered requirement/risk; then run selected compile, test, schema generation/validation, runtime, or artifact checks through durable workflow-owned `ctx.tool(...)` calls. Actual tool results—not model self-report—feed judgment and consolidated repair.
4405
+ - Known contracts may use direct task-specific `ctx.tool(...)` gates designed before launch; uncertain risks may use model-selected probes executed by those deterministic tools. Rerun the tools after repair until the declared pass condition or iteration limit.
4406
+ - Ask verifiers to find blockers and not rewrite the candidate unless you explicitly assign them to repair it. Keep pure transformations as ordinary TypeScript rather than wrapping every model-stage action in `ctx.tool`.
3694
4407
 
3695
4408
  ##### 4. Generate-and-filter
3696
4409
 
@@ -3753,12 +4466,14 @@ Builtin definition and contracts: [Six composable pattern builtins](#six-composa
3753
4466
  ```text
3754
4467
  ┌─ 6 Loop until done ─────────────────────────────────────┐
3755
4468
  │ │
3756
- yes, spawn another
3757
- ╭────────────────╮
3758
-
3759
- ┌─────┐ ┌─────────────┐ no ┌────┐
3760
- agent│─────▸│new findings?│──────▸│done│ │
3761
- └─────┘ └─────────────┘ └────┘
4469
+ ┌───────┐ ┌─────────────┐ no ┌────┐
4470
+ agent 1│──▸│new findings?│──────▸│done│ │
4471
+ └───────┘ └──────┬──────┘ └────┘
4472
+ yes, spawn distinct work │
4473
+
4474
+ ┌───────┐ ┌────────────┐
4475
+ │ │agent 2│──▸│next check …│ │
4476
+ │ └───────┘ └────────────┘ │
3762
4477
  │ │
3763
4478
  └──────────────────────────────────────────────────────────┘
3764
4479
  ```
@@ -3767,6 +4482,7 @@ Best practices:
3767
4482
  - Define both success and escape conditions before the loop starts.
3768
4483
  - Keep a durable ledger of attempted work, findings, failures, and validation evidence.
3769
4484
  - Bound loops by iterations, budget, or convergence criteria so exhausting a bound produces an inspectable failure instead of letting the loop continue indefinitely.
4485
+ - Materialize every iteration as distinct tracked work with stable iteration identity and call order. Never represent repetition by a self-edge, a back-edge to an ancestor, or reopening an ancestor below its downstream work.
3770
4486
 
3771
4487
  #### Choosing a common workflow pattern
3772
4488
 
@@ -3776,6 +4492,7 @@ Best practices:
3776
4492
  - Pick **generate-and-filter** when output quality depends on exploring a large option space.
3777
4493
  - Pick **tournament** when multiple whole-solution strategies should compete under one rubric.
3778
4494
  - Pick **loop until done** when the workflow should continue until evidence says it is finished, not until a preselected number of stages completes.
4495
+ - Pick **scope guard** when valid adjacent findings could expand a worker or repair stage beyond its immutable contract; choose a boundary task by default and live parallel steering only when timing requires it.
3779
4496
 
3780
4497
  Record the selected pattern in your spec or workflow README, then adapt the diagram to the stage graph. If the final design does not resemble any common pattern, explain why in the workflow's design notes.
3781
4498
 
@@ -4102,6 +4819,7 @@ These anti-patterns target run prompts; [Common Mistakes](#common-mistakes) cove
4102
4819
  | Continuing stale runs | Pause, stop, or rerun with updated context. |
4103
4820
  | Reading every log | Inspect status, then stages, then only relevant details. |
4104
4821
  | Publishing without gates | Require release validation and explicit stop conditions. |
4822
+ | Serializing independent issues from list order | Triage dependencies, then launch separate top-level item runs under a concurrency bound. |
4105
4823
 
4106
4824
  ---
4107
4825
 
@@ -4117,6 +4835,7 @@ Before starting a workflow, include:
4117
4835
  - [ ] Validation command
4118
4836
  - [ ] Reporting requirements
4119
4837
  - [ ] Stop conditions
4838
+ - [ ] Queue dependency classification, concurrency bound, and item → run/worktree/branch map (when several implementation items are requested)
4120
4839
 
4121
4840
  Before accepting a workflow result, ask:
4122
4841