@bastani/atomic 0.9.2 → 0.9.3-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (606) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +2 -2
  3. package/dist/builtin/cursor/CHANGELOG.md +15 -0
  4. package/dist/builtin/cursor/README.md +2 -1
  5. package/dist/builtin/cursor/package.json +2 -2
  6. package/dist/builtin/cursor/src/cursor-models-raw.json +2 -9
  7. package/dist/builtin/cursor/src/model-mapper.ts +14 -3
  8. package/dist/builtin/cursor/src/proto/protobuf-codec-base64.ts +22 -0
  9. package/dist/builtin/cursor/src/proto/protobuf-codec-request.ts +53 -13
  10. package/dist/builtin/cursor/src/proto/protobuf-codec-wire.ts +24 -7
  11. package/dist/builtin/cursor/src/proto/protobuf-codec.ts +3 -2
  12. package/dist/builtin/cursor/src/stream.ts +5 -11
  13. package/dist/builtin/cursor/src/transport-types.ts +3 -0
  14. package/dist/builtin/cursor/src/transport.ts +1 -0
  15. package/dist/builtin/intercom/package.json +1 -1
  16. package/dist/builtin/mcp/CHANGELOG.md +6 -0
  17. package/dist/builtin/mcp/direct-tools.ts +4 -2
  18. package/dist/builtin/mcp/package.json +1 -1
  19. package/dist/builtin/mcp/proxy-call.ts +3 -1
  20. package/dist/builtin/mcp/utils.ts +18 -7
  21. package/dist/builtin/subagents/CHANGELOG.md +20 -0
  22. package/dist/builtin/subagents/README.md +6 -6
  23. package/dist/builtin/subagents/agents/code-simplifier.md +7 -6
  24. package/dist/builtin/subagents/agents/codebase-analyzer.md +5 -4
  25. package/dist/builtin/subagents/agents/codebase-locator.md +3 -3
  26. package/dist/builtin/subagents/agents/codebase-online-researcher.md +10 -10
  27. package/dist/builtin/subagents/agents/codebase-pattern-finder.md +4 -4
  28. package/dist/builtin/subagents/agents/codebase-research-analyzer.md +3 -3
  29. package/dist/builtin/subagents/agents/codebase-research-locator.md +4 -4
  30. package/dist/builtin/subagents/agents/debugger.md +5 -5
  31. package/dist/builtin/subagents/agents/worker.md +56 -0
  32. package/dist/builtin/subagents/package.json +1 -1
  33. package/dist/builtin/subagents/skills/subagent/SKILL.md +11 -11
  34. package/dist/builtin/subagents/src/agents/agent-loaders.ts +3 -5
  35. package/dist/builtin/subagents/src/agents/agent-management-helpers.ts +3 -3
  36. package/dist/builtin/subagents/src/extension/fanout-child.ts +1 -0
  37. package/dist/builtin/subagents/src/extension/index.ts +6 -3
  38. package/dist/builtin/subagents/src/extension/schemas.ts +2 -7
  39. package/dist/builtin/subagents/src/intercom/result-intercom.ts +4 -3
  40. package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +1 -4
  41. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +15 -1
  42. package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +35 -1
  43. package/dist/builtin/subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +1 -1
  44. package/dist/builtin/subagents/src/runs/shared/nested-render.ts +2 -2
  45. package/dist/builtin/subagents/src/runs/shared/pi-args.ts +2 -1
  46. package/dist/builtin/subagents/src/runs/shared/subagent-prompt-runtime.ts +4 -2
  47. package/dist/builtin/subagents/src/shared/types-async.ts +1 -0
  48. package/dist/builtin/subagents/src/shared/types-depth.ts +5 -5
  49. package/dist/builtin/subagents/src/shared/types-runtime.ts +2 -1
  50. package/dist/builtin/subagents/src/slash/prompt-template-bridge.ts +27 -5
  51. package/dist/builtin/subagents/src/tui/render-event-formatting.ts +2 -2
  52. package/dist/builtin/subagents/src/tui/render-layout.ts +27 -4
  53. package/dist/builtin/subagents/src/tui/render-result-animation.ts +22 -31
  54. package/dist/builtin/subagents/src/tui/render-result-compact.ts +6 -6
  55. package/dist/builtin/subagents/src/tui/render-result.ts +20 -19
  56. package/dist/builtin/subagents/src/tui/render-status-progress.ts +3 -3
  57. package/dist/builtin/subagents/src/tui/render-widget.ts +46 -7
  58. package/dist/builtin/subagents/src/tui/render.ts +2 -2
  59. package/dist/builtin/web-access/package.json +1 -1
  60. package/dist/builtin/workflows/CHANGELOG.md +56 -0
  61. package/dist/builtin/workflows/README.md +3 -3
  62. package/dist/builtin/workflows/builtin/goal-artifacts.ts +11 -6
  63. package/dist/builtin/workflows/builtin/goal-ledger.ts +33 -1
  64. package/dist/builtin/workflows/builtin/goal-prompts.ts +23 -28
  65. package/dist/builtin/workflows/builtin/goal-reducer.ts +2 -2
  66. package/dist/builtin/workflows/builtin/goal-reports.ts +2 -5
  67. package/dist/builtin/workflows/builtin/goal-review.ts +1 -1
  68. package/dist/builtin/workflows/builtin/goal-runner.ts +10 -17
  69. package/dist/builtin/workflows/builtin/open-claude-design-feedback.ts +3 -3
  70. package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +1 -3
  71. package/dist/builtin/workflows/builtin/open-claude-design-setup.ts +1 -1
  72. package/dist/builtin/workflows/builtin/ralph-core.ts +7 -17
  73. package/dist/builtin/workflows/builtin/ralph-runner.ts +11 -18
  74. package/dist/builtin/workflows/builtin/shared-prompts.ts +1 -1
  75. package/dist/builtin/workflows/package.json +1 -1
  76. package/dist/builtin/workflows/src/authoring.d.ts +1 -1
  77. package/dist/builtin/workflows/src/durable/backend.ts +343 -0
  78. package/dist/builtin/workflows/src/durable/child-primitive.ts +79 -0
  79. package/dist/builtin/workflows/src/durable/dbos-backend.ts +421 -0
  80. package/dist/builtin/workflows/src/durable/dbos-envelope.ts +171 -0
  81. package/dist/builtin/workflows/src/durable/factory.ts +96 -0
  82. package/dist/builtin/workflows/src/durable/file-backend.ts +433 -0
  83. package/dist/builtin/workflows/src/durable/index.ts +73 -0
  84. package/dist/builtin/workflows/src/durable/resume-catalog.ts +217 -0
  85. package/dist/builtin/workflows/src/durable/resume-runtime.ts +299 -0
  86. package/dist/builtin/workflows/src/durable/scoped-backend.ts +171 -0
  87. package/dist/builtin/workflows/src/durable/stage-primitive.ts +284 -0
  88. package/dist/builtin/workflows/src/durable/tool-primitive.ts +180 -0
  89. package/dist/builtin/workflows/src/durable/types.ts +168 -0
  90. package/dist/builtin/workflows/src/durable/ui-primitive.ts +96 -0
  91. package/dist/builtin/workflows/src/engine/options.ts +3 -0
  92. package/dist/builtin/workflows/src/engine/primitives/parallel.ts +2 -2
  93. package/dist/builtin/workflows/src/engine/primitives/task.ts +4 -4
  94. package/dist/builtin/workflows/src/engine/primitives/ui.ts +22 -8
  95. package/dist/builtin/workflows/src/engine/primitives/workflow.ts +8 -0
  96. package/dist/builtin/workflows/src/engine/run-durable-finalize.ts +69 -0
  97. package/dist/builtin/workflows/src/engine/run-durable-stage-session.ts +31 -0
  98. package/dist/builtin/workflows/src/engine/run.ts +148 -6
  99. package/dist/builtin/workflows/src/engine/runtime.ts +8 -2
  100. package/dist/builtin/workflows/src/extension/config-loader.ts +35 -15
  101. package/dist/builtin/workflows/src/extension/discovery.ts +20 -8
  102. package/dist/builtin/workflows/src/extension/extension-factory.ts +6 -12
  103. package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +5 -1
  104. package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +4 -2
  105. package/dist/builtin/workflows/src/extension/runtime.ts +48 -9
  106. package/dist/builtin/workflows/src/extension/wiring.ts +1 -1
  107. package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +143 -4
  108. package/dist/builtin/workflows/src/runs/background/quit.ts +61 -0
  109. package/dist/builtin/workflows/src/runs/background/status.ts +1 -0
  110. package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +5 -5
  111. package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +74 -33
  112. package/dist/builtin/workflows/src/runs/foreground/executor-stage-context.ts +20 -1
  113. package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +8 -7
  114. package/dist/builtin/workflows/src/runs/foreground/executor-stage-replay.ts +1 -0
  115. package/dist/builtin/workflows/src/runs/foreground/executor-stage-types.ts +1 -1
  116. package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +19 -2
  117. package/dist/builtin/workflows/src/runs/foreground/stage-runner-context.ts +4 -0
  118. package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +10 -10
  119. package/dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts +5 -1
  120. package/dist/builtin/workflows/src/runs/foreground/stage-runner-send-user-message.ts +25 -0
  121. package/dist/builtin/workflows/src/runs/foreground/stage-runner-types.ts +3 -0
  122. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +16 -0
  123. package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +20 -0
  124. package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +23 -1
  125. package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +30 -1
  126. package/dist/builtin/workflows/src/shared/store-public-types.ts +6 -2
  127. package/dist/builtin/workflows/src/shared/store-run-methods.ts +12 -6
  128. package/dist/builtin/workflows/src/shared/types.ts +55 -0
  129. package/dist/builtin/workflows/src/tui/dispatch-confirm.ts +11 -10
  130. package/dist/builtin/workflows/src/tui/graph-view-constants.ts +1 -1
  131. package/dist/builtin/workflows/src/tui/graph-view-graph-render.ts +41 -0
  132. package/dist/builtin/workflows/src/tui/graph-view-input.ts +82 -24
  133. package/dist/builtin/workflows/src/tui/graph-view-render.ts +7 -0
  134. package/dist/builtin/workflows/src/tui/graph-view-state.ts +22 -2
  135. package/dist/builtin/workflows/src/tui/graph-view-types.ts +4 -5
  136. package/dist/builtin/workflows/src/tui/overlay-adapter.ts +9 -11
  137. package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +9 -3
  138. package/dist/builtin/workflows/src/tui/stage-chat-view-input.ts +11 -2
  139. package/dist/builtin/workflows/src/tui/stage-chat-view-live-events.ts +35 -0
  140. package/dist/builtin/workflows/src/tui/stage-chat-view-state.ts +51 -17
  141. package/dist/builtin/workflows/src/tui/stage-chat-view-status.ts +36 -0
  142. package/dist/builtin/workflows/src/tui/stage-chat-view-types.ts +5 -1
  143. package/dist/builtin/workflows/src/tui/stage-chat-view.ts +3 -1
  144. package/dist/builtin/workflows/src/tui/status-list.ts +14 -2
  145. package/dist/builtin/workflows/src/tui/widget.ts +23 -8
  146. package/dist/builtin/workflows/src/tui/workflow-attach-pane-types.ts +5 -4
  147. package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +8 -8
  148. package/dist/builtin/workflows/src/tui/workflow-resume-selector.ts +151 -0
  149. package/dist/cli/args.d.ts.map +1 -1
  150. package/dist/cli/args.js +9 -9
  151. package/dist/cli/args.js.map +1 -1
  152. package/dist/config-self-update.d.ts.map +1 -1
  153. package/dist/config-self-update.js +3 -4
  154. package/dist/config-self-update.js.map +1 -1
  155. package/dist/config.d.ts.map +1 -1
  156. package/dist/config.js +4 -5
  157. package/dist/config.js.map +1 -1
  158. package/dist/core/agent-session-bash.d.ts +1 -0
  159. package/dist/core/agent-session-bash.d.ts.map +1 -1
  160. package/dist/core/agent-session-bash.js +1 -0
  161. package/dist/core/agent-session-bash.js.map +1 -1
  162. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  163. package/dist/core/agent-session-tool-registry.js +23 -0
  164. package/dist/core/agent-session-tool-registry.js.map +1 -1
  165. package/dist/core/bash-executor.d.ts +2 -0
  166. package/dist/core/bash-executor.d.ts.map +1 -1
  167. package/dist/core/bash-executor.js +1 -0
  168. package/dist/core/bash-executor.js.map +1 -1
  169. package/dist/core/compaction/compaction.d.ts +29 -0
  170. package/dist/core/compaction/compaction.d.ts.map +1 -1
  171. package/dist/core/compaction/compaction.js +36 -1
  172. package/dist/core/compaction/compaction.js.map +1 -1
  173. package/dist/core/compaction/context-compaction-metrics.d.ts +14 -2
  174. package/dist/core/compaction/context-compaction-metrics.d.ts.map +1 -1
  175. package/dist/core/compaction/context-compaction-metrics.js +50 -1
  176. package/dist/core/compaction/context-compaction-metrics.js.map +1 -1
  177. package/dist/core/compaction/context-compaction-prompt.d.ts.map +1 -1
  178. package/dist/core/compaction/context-compaction-prompt.js +2 -0
  179. package/dist/core/compaction/context-compaction-prompt.js.map +1 -1
  180. package/dist/core/compaction/context-compaction-runner.d.ts.map +1 -1
  181. package/dist/core/compaction/context-compaction-runner.js +1 -1
  182. package/dist/core/compaction/context-compaction-runner.js.map +1 -1
  183. package/dist/core/compaction/context-deletion-application.d.ts.map +1 -1
  184. package/dist/core/compaction/context-deletion-application.js +5 -5
  185. package/dist/core/compaction/context-deletion-application.js.map +1 -1
  186. package/dist/core/compaction/context-deletion-targets.d.ts +2 -0
  187. package/dist/core/compaction/context-deletion-targets.d.ts.map +1 -1
  188. package/dist/core/compaction/context-deletion-targets.js +23 -3
  189. package/dist/core/compaction/context-deletion-targets.js.map +1 -1
  190. package/dist/core/compaction/context-deletion-tool-definitions.d.ts +6 -0
  191. package/dist/core/compaction/context-deletion-tool-definitions.d.ts.map +1 -1
  192. package/dist/core/compaction/context-deletion-tool-definitions.js.map +1 -1
  193. package/dist/core/compaction/context-deletion-tools.d.ts.map +1 -1
  194. package/dist/core/compaction/context-deletion-tools.js +18 -10
  195. package/dist/core/compaction/context-deletion-tools.js.map +1 -1
  196. package/dist/core/compaction/context-transcript-analysis.d.ts.map +1 -1
  197. package/dist/core/compaction/context-transcript-analysis.js +2 -4
  198. package/dist/core/compaction/context-transcript-analysis.js.map +1 -1
  199. package/dist/core/copilot-gemini-tool-arguments.d.ts.map +1 -1
  200. package/dist/core/copilot-gemini-tool-arguments.js +2 -60
  201. package/dist/core/copilot-gemini-tool-arguments.js.map +1 -1
  202. package/dist/core/extensions/context-types.d.ts +2 -0
  203. package/dist/core/extensions/context-types.d.ts.map +1 -1
  204. package/dist/core/extensions/context-types.js.map +1 -1
  205. package/dist/core/extensions/index.d.ts +2 -2
  206. package/dist/core/extensions/index.d.ts.map +1 -1
  207. package/dist/core/extensions/index.js +1 -1
  208. package/dist/core/extensions/index.js.map +1 -1
  209. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  210. package/dist/core/extensions/loader-virtual-modules.js +57 -32
  211. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  212. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  213. package/dist/core/extensions/runner-context.js +11 -0
  214. package/dist/core/extensions/runner-context.js.map +1 -1
  215. package/dist/core/extensions/tool-events.d.ts +13 -13
  216. package/dist/core/extensions/tool-events.d.ts.map +1 -1
  217. package/dist/core/extensions/tool-events.js +3 -3
  218. package/dist/core/extensions/tool-events.js.map +1 -1
  219. package/dist/core/extensions/types.d.ts +1 -1
  220. package/dist/core/extensions/types.d.ts.map +1 -1
  221. package/dist/core/extensions/types.js +1 -1
  222. package/dist/core/extensions/types.js.map +1 -1
  223. package/dist/core/flattened-tool-arguments.d.ts +18 -0
  224. package/dist/core/flattened-tool-arguments.d.ts.map +1 -1
  225. package/dist/core/flattened-tool-arguments.js +104 -0
  226. package/dist/core/flattened-tool-arguments.js.map +1 -1
  227. package/dist/core/messages.d.ts +1 -0
  228. package/dist/core/messages.d.ts.map +1 -1
  229. package/dist/core/messages.js +46 -1
  230. package/dist/core/messages.js.map +1 -1
  231. package/dist/core/sdk-exports.d.ts +1 -1
  232. package/dist/core/sdk-exports.d.ts.map +1 -1
  233. package/dist/core/sdk-exports.js +1 -1
  234. package/dist/core/sdk-exports.js.map +1 -1
  235. package/dist/core/sdk-types.d.ts +2 -2
  236. package/dist/core/sdk-types.d.ts.map +1 -1
  237. package/dist/core/sdk-types.js.map +1 -1
  238. package/dist/core/sdk.d.ts.map +1 -1
  239. package/dist/core/sdk.js +12 -0
  240. package/dist/core/sdk.js.map +1 -1
  241. package/dist/core/session-manager-core.d.ts +15 -7
  242. package/dist/core/session-manager-core.d.ts.map +1 -1
  243. package/dist/core/session-manager-core.js +20 -9
  244. package/dist/core/session-manager-core.js.map +1 -1
  245. package/dist/core/session-manager-entries.d.ts +2 -2
  246. package/dist/core/session-manager-entries.d.ts.map +1 -1
  247. package/dist/core/session-manager-entries.js +9 -3
  248. package/dist/core/session-manager-entries.js.map +1 -1
  249. package/dist/core/session-manager-history.d.ts.map +1 -1
  250. package/dist/core/session-manager-history.js +2 -1
  251. package/dist/core/session-manager-history.js.map +1 -1
  252. package/dist/core/session-manager-list.d.ts +3 -3
  253. package/dist/core/session-manager-list.d.ts.map +1 -1
  254. package/dist/core/session-manager-list.js +27 -8
  255. package/dist/core/session-manager-list.js.map +1 -1
  256. package/dist/core/session-manager-storage.d.ts +3 -1
  257. package/dist/core/session-manager-storage.d.ts.map +1 -1
  258. package/dist/core/session-manager-storage.js +55 -12
  259. package/dist/core/session-manager-storage.js.map +1 -1
  260. package/dist/core/session-manager-tool-dependencies.d.ts +10 -0
  261. package/dist/core/session-manager-tool-dependencies.d.ts.map +1 -0
  262. package/dist/core/session-manager-tool-dependencies.js +133 -0
  263. package/dist/core/session-manager-tool-dependencies.js.map +1 -0
  264. package/dist/core/session-manager-types.d.ts +22 -0
  265. package/dist/core/session-manager-types.d.ts.map +1 -1
  266. package/dist/core/session-manager-types.js.map +1 -1
  267. package/dist/core/session-manager.d.ts +2 -2
  268. package/dist/core/session-manager.d.ts.map +1 -1
  269. package/dist/core/session-manager.js +1 -1
  270. package/dist/core/session-manager.js.map +1 -1
  271. package/dist/core/settings-manager-basic-accessors.d.ts +4 -0
  272. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  273. package/dist/core/settings-manager-basic-accessors.js +18 -0
  274. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  275. package/dist/core/settings-manager-resource-accessors.d.ts +4 -0
  276. package/dist/core/settings-manager-resource-accessors.d.ts.map +1 -1
  277. package/dist/core/settings-manager-resource-accessors.js +15 -0
  278. package/dist/core/settings-manager-resource-accessors.js.map +1 -1
  279. package/dist/core/settings-types.d.ts +11 -0
  280. package/dist/core/settings-types.d.ts.map +1 -1
  281. package/dist/core/settings-types.js.map +1 -1
  282. package/dist/core/system-prompt.d.ts +1 -1
  283. package/dist/core/system-prompt.d.ts.map +1 -1
  284. package/dist/core/system-prompt.js +3 -2
  285. package/dist/core/system-prompt.js.map +1 -1
  286. package/dist/core/tools/artifact-protocol.d.ts +11 -0
  287. package/dist/core/tools/artifact-protocol.d.ts.map +1 -0
  288. package/dist/core/tools/artifact-protocol.js +76 -0
  289. package/dist/core/tools/artifact-protocol.js.map +1 -0
  290. package/dist/core/tools/artifacts.d.ts +18 -0
  291. package/dist/core/tools/artifacts.d.ts.map +1 -0
  292. package/dist/core/tools/artifacts.js +90 -0
  293. package/dist/core/tools/artifacts.js.map +1 -0
  294. package/dist/core/tools/bash-async-jobs.d.ts +20 -0
  295. package/dist/core/tools/bash-async-jobs.d.ts.map +1 -0
  296. package/dist/core/tools/bash-async-jobs.js +59 -0
  297. package/dist/core/tools/bash-async-jobs.js.map +1 -0
  298. package/dist/core/tools/bash-async-output.d.ts +10 -0
  299. package/dist/core/tools/bash-async-output.d.ts.map +1 -0
  300. package/dist/core/tools/bash-async-output.js +80 -0
  301. package/dist/core/tools/bash-async-output.js.map +1 -0
  302. package/dist/core/tools/bash-interceptor.d.ts +10 -0
  303. package/dist/core/tools/bash-interceptor.d.ts.map +1 -0
  304. package/dist/core/tools/bash-interceptor.js +39 -0
  305. package/dist/core/tools/bash-interceptor.js.map +1 -0
  306. package/dist/core/tools/bash-leading-cd.d.ts +7 -0
  307. package/dist/core/tools/bash-leading-cd.d.ts.map +1 -0
  308. package/dist/core/tools/bash-leading-cd.js +59 -0
  309. package/dist/core/tools/bash-leading-cd.js.map +1 -0
  310. package/dist/core/tools/bash-pty-native.d.ts +14 -0
  311. package/dist/core/tools/bash-pty-native.d.ts.map +1 -0
  312. package/dist/core/tools/bash-pty-native.js +71 -0
  313. package/dist/core/tools/bash-pty-native.js.map +1 -0
  314. package/dist/core/tools/bash.d.ts +28 -17
  315. package/dist/core/tools/bash.d.ts.map +1 -1
  316. package/dist/core/tools/bash.js +152 -35
  317. package/dist/core/tools/bash.js.map +1 -1
  318. package/dist/core/tools/block-resolver.d.ts +16 -0
  319. package/dist/core/tools/block-resolver.d.ts.map +1 -0
  320. package/dist/core/tools/block-resolver.js +74 -0
  321. package/dist/core/tools/block-resolver.js.map +1 -0
  322. package/dist/core/tools/conflict-registry.d.ts +16 -0
  323. package/dist/core/tools/conflict-registry.d.ts.map +1 -0
  324. package/dist/core/tools/conflict-registry.js +44 -0
  325. package/dist/core/tools/conflict-registry.js.map +1 -0
  326. package/dist/core/tools/directory-tree.d.ts +13 -0
  327. package/dist/core/tools/directory-tree.d.ts.map +1 -0
  328. package/dist/core/tools/directory-tree.js +81 -0
  329. package/dist/core/tools/directory-tree.js.map +1 -0
  330. package/dist/core/tools/edit.d.ts +4 -29
  331. package/dist/core/tools/edit.d.ts.map +1 -1
  332. package/dist/core/tools/edit.js +136 -228
  333. package/dist/core/tools/edit.js.map +1 -1
  334. package/dist/core/tools/fetch-url.d.ts +74 -0
  335. package/dist/core/tools/fetch-url.d.ts.map +1 -0
  336. package/dist/core/tools/fetch-url.js +518 -0
  337. package/dist/core/tools/fetch-url.js.map +1 -0
  338. package/dist/core/tools/find.d.ts +27 -9
  339. package/dist/core/tools/find.d.ts.map +1 -1
  340. package/dist/core/tools/find.js +400 -176
  341. package/dist/core/tools/find.js.map +1 -1
  342. package/dist/core/tools/glob-path-utils.d.ts +8 -0
  343. package/dist/core/tools/glob-path-utils.d.ts.map +1 -0
  344. package/dist/core/tools/glob-path-utils.js +26 -0
  345. package/dist/core/tools/glob-path-utils.js.map +1 -0
  346. package/dist/core/tools/grep.d.ts +12 -0
  347. package/dist/core/tools/grep.d.ts.map +1 -1
  348. package/dist/core/tools/grep.js +141 -17
  349. package/dist/core/tools/grep.js.map +1 -1
  350. package/dist/core/tools/hashline-engine/apply.d.ts +11 -0
  351. package/dist/core/tools/hashline-engine/apply.d.ts.map +1 -0
  352. package/dist/core/tools/hashline-engine/apply.js +752 -0
  353. package/dist/core/tools/hashline-engine/apply.js.map +1 -0
  354. package/dist/core/tools/hashline-engine/block.d.ts +40 -0
  355. package/dist/core/tools/hashline-engine/block.d.ts.map +1 -0
  356. package/dist/core/tools/hashline-engine/block.js +117 -0
  357. package/dist/core/tools/hashline-engine/block.js.map +1 -0
  358. package/dist/core/tools/hashline-engine/diff-preview.d.ts +15 -0
  359. package/dist/core/tools/hashline-engine/diff-preview.d.ts.map +1 -0
  360. package/dist/core/tools/hashline-engine/diff-preview.js +98 -0
  361. package/dist/core/tools/hashline-engine/diff-preview.js.map +1 -0
  362. package/dist/core/tools/hashline-engine/format.d.ts +71 -0
  363. package/dist/core/tools/hashline-engine/format.d.ts.map +1 -0
  364. package/dist/core/tools/hashline-engine/format.js +178 -0
  365. package/dist/core/tools/hashline-engine/format.js.map +1 -0
  366. package/dist/core/tools/hashline-engine/fs.d.ts +81 -0
  367. package/dist/core/tools/hashline-engine/fs.d.ts.map +1 -0
  368. package/dist/core/tools/hashline-engine/fs.js +143 -0
  369. package/dist/core/tools/hashline-engine/fs.js.map +1 -0
  370. package/dist/core/tools/hashline-engine/index.d.ts +18 -0
  371. package/dist/core/tools/hashline-engine/index.d.ts.map +1 -0
  372. package/dist/core/tools/hashline-engine/index.js +20 -0
  373. package/dist/core/tools/hashline-engine/index.js.map +1 -0
  374. package/dist/core/tools/hashline-engine/input.d.ts +101 -0
  375. package/dist/core/tools/hashline-engine/input.d.ts.map +1 -0
  376. package/dist/core/tools/hashline-engine/input.js +398 -0
  377. package/dist/core/tools/hashline-engine/input.js.map +1 -0
  378. package/dist/core/tools/hashline-engine/messages.d.ts +99 -0
  379. package/dist/core/tools/hashline-engine/messages.d.ts.map +1 -0
  380. package/dist/core/tools/hashline-engine/messages.js +144 -0
  381. package/dist/core/tools/hashline-engine/messages.js.map +1 -0
  382. package/dist/core/tools/hashline-engine/mismatch.d.ts +45 -0
  383. package/dist/core/tools/hashline-engine/mismatch.d.ts.map +1 -0
  384. package/dist/core/tools/hashline-engine/mismatch.js +90 -0
  385. package/dist/core/tools/hashline-engine/mismatch.js.map +1 -0
  386. package/dist/core/tools/hashline-engine/normalize.d.ts +21 -0
  387. package/dist/core/tools/hashline-engine/normalize.d.ts.map +1 -0
  388. package/dist/core/tools/hashline-engine/normalize.js +33 -0
  389. package/dist/core/tools/hashline-engine/normalize.js.map +1 -0
  390. package/dist/core/tools/hashline-engine/parser.d.ts +24 -0
  391. package/dist/core/tools/hashline-engine/parser.d.ts.map +1 -0
  392. package/dist/core/tools/hashline-engine/parser.js +381 -0
  393. package/dist/core/tools/hashline-engine/parser.js.map +1 -0
  394. package/dist/core/tools/hashline-engine/patcher.d.ts +118 -0
  395. package/dist/core/tools/hashline-engine/patcher.d.ts.map +1 -0
  396. package/dist/core/tools/hashline-engine/patcher.js +341 -0
  397. package/dist/core/tools/hashline-engine/patcher.js.map +1 -0
  398. package/dist/core/tools/hashline-engine/prefixes.d.ts +43 -0
  399. package/dist/core/tools/hashline-engine/prefixes.d.ts.map +1 -0
  400. package/dist/core/tools/hashline-engine/prefixes.js +135 -0
  401. package/dist/core/tools/hashline-engine/prefixes.js.map +1 -0
  402. package/dist/core/tools/hashline-engine/recovery.d.ts +41 -0
  403. package/dist/core/tools/hashline-engine/recovery.d.ts.map +1 -0
  404. package/dist/core/tools/hashline-engine/recovery.js +168 -0
  405. package/dist/core/tools/hashline-engine/recovery.js.map +1 -0
  406. package/dist/core/tools/hashline-engine/snapshots.d.ts +65 -0
  407. package/dist/core/tools/hashline-engine/snapshots.d.ts.map +1 -0
  408. package/dist/core/tools/hashline-engine/snapshots.js +108 -0
  409. package/dist/core/tools/hashline-engine/snapshots.js.map +1 -0
  410. package/dist/core/tools/hashline-engine/stream.d.ts +3 -0
  411. package/dist/core/tools/hashline-engine/stream.d.ts.map +1 -0
  412. package/dist/core/tools/hashline-engine/stream.js +111 -0
  413. package/dist/core/tools/hashline-engine/stream.js.map +1 -0
  414. package/dist/core/tools/hashline-engine/tokenizer.d.ts +69 -0
  415. package/dist/core/tools/hashline-engine/tokenizer.d.ts.map +1 -0
  416. package/dist/core/tools/hashline-engine/tokenizer.js +430 -0
  417. package/dist/core/tools/hashline-engine/tokenizer.js.map +1 -0
  418. package/dist/core/tools/hashline-engine/types.d.ts +166 -0
  419. package/dist/core/tools/hashline-engine/types.d.ts.map +1 -0
  420. package/dist/core/tools/hashline-engine/types.js +9 -0
  421. package/dist/core/tools/hashline-engine/types.js.map +1 -0
  422. package/dist/core/tools/hashline.d.ts +29 -0
  423. package/dist/core/tools/hashline.d.ts.map +1 -0
  424. package/dist/core/tools/hashline.js +110 -0
  425. package/dist/core/tools/hashline.js.map +1 -0
  426. package/dist/core/tools/index.d.ts +6 -4
  427. package/dist/core/tools/index.d.ts.map +1 -1
  428. package/dist/core/tools/index.js +52 -35
  429. package/dist/core/tools/index.js.map +1 -1
  430. package/dist/core/tools/notebook.d.ts +38 -0
  431. package/dist/core/tools/notebook.d.ts.map +1 -0
  432. package/dist/core/tools/notebook.js +125 -0
  433. package/dist/core/tools/notebook.js.map +1 -0
  434. package/dist/core/tools/read-document-extract.d.ts +9 -0
  435. package/dist/core/tools/read-document-extract.d.ts.map +1 -0
  436. package/dist/core/tools/read-document-extract.js +212 -0
  437. package/dist/core/tools/read-document-extract.js.map +1 -0
  438. package/dist/core/tools/read-selectors.d.ts +24 -0
  439. package/dist/core/tools/read-selectors.d.ts.map +1 -0
  440. package/dist/core/tools/read-selectors.js +277 -0
  441. package/dist/core/tools/read-selectors.js.map +1 -0
  442. package/dist/core/tools/read-url.d.ts +37 -0
  443. package/dist/core/tools/read-url.d.ts.map +1 -0
  444. package/dist/core/tools/read-url.js +39 -0
  445. package/dist/core/tools/read-url.js.map +1 -0
  446. package/dist/core/tools/read.d.ts +11 -11
  447. package/dist/core/tools/read.d.ts.map +1 -1
  448. package/dist/core/tools/read.js +224 -94
  449. package/dist/core/tools/read.js.map +1 -1
  450. package/dist/core/tools/resource-selectors.d.ts +44 -0
  451. package/dist/core/tools/resource-selectors.d.ts.map +1 -0
  452. package/dist/core/tools/resource-selectors.js +808 -0
  453. package/dist/core/tools/resource-selectors.js.map +1 -0
  454. package/dist/core/tools/search-details.d.ts +26 -0
  455. package/dist/core/tools/search-details.d.ts.map +1 -0
  456. package/dist/core/tools/search-details.js +24 -0
  457. package/dist/core/tools/search-details.js.map +1 -0
  458. package/dist/core/tools/search-line-ranges.d.ts +11 -0
  459. package/dist/core/tools/search-line-ranges.d.ts.map +1 -0
  460. package/dist/core/tools/search-line-ranges.js +65 -0
  461. package/dist/core/tools/search-line-ranges.js.map +1 -0
  462. package/dist/core/tools/search-native.d.ts +97 -0
  463. package/dist/core/tools/search-native.d.ts.map +1 -0
  464. package/dist/core/tools/search-native.js +27 -0
  465. package/dist/core/tools/search-native.js.map +1 -0
  466. package/dist/core/tools/search.d.ts +24 -0
  467. package/dist/core/tools/search.d.ts.map +1 -0
  468. package/dist/core/tools/search.js +573 -0
  469. package/dist/core/tools/search.js.map +1 -0
  470. package/dist/core/tools/truncate.d.ts +4 -4
  471. package/dist/core/tools/truncate.d.ts.map +1 -1
  472. package/dist/core/tools/truncate.js +3 -3
  473. package/dist/core/tools/truncate.js.map +1 -1
  474. package/dist/core/tools/url-ip-guards.d.ts +4 -0
  475. package/dist/core/tools/url-ip-guards.d.ts.map +1 -0
  476. package/dist/core/tools/url-ip-guards.js +126 -0
  477. package/dist/core/tools/url-ip-guards.js.map +1 -0
  478. package/dist/core/tools/write.d.ts +12 -2
  479. package/dist/core/tools/write.d.ts.map +1 -1
  480. package/dist/core/tools/write.js +166 -14
  481. package/dist/core/tools/write.js.map +1 -1
  482. package/dist/core/trust-manager.d.ts.map +1 -1
  483. package/dist/core/trust-manager.js +2 -3
  484. package/dist/core/trust-manager.js.map +1 -1
  485. package/dist/index-extensions.d.ts +2 -2
  486. package/dist/index-extensions.d.ts.map +1 -1
  487. package/dist/index-extensions.js +1 -1
  488. package/dist/index-extensions.js.map +1 -1
  489. package/dist/index.d.ts +3 -3
  490. package/dist/index.d.ts.map +1 -1
  491. package/dist/index.js +3 -3
  492. package/dist/index.js.map +1 -1
  493. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts +1 -0
  494. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -1
  495. package/dist/modes/interactive/components/chat-session-host-runtime.js +12 -0
  496. package/dist/modes/interactive/components/chat-session-host-runtime.js.map +1 -1
  497. package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.d.ts +4 -0
  498. package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.d.ts.map +1 -0
  499. package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.js +131 -0
  500. package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.js.map +1 -0
  501. package/dist/modes/interactive/components/chat-session-host.d.ts +2 -0
  502. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  503. package/dist/modes/interactive/components/chat-session-host.js +7 -1
  504. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  505. package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
  506. package/dist/modes/interactive/components/chat-transcript.js +15 -4
  507. package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
  508. package/dist/modes/interactive/components/custom-editor.d.ts +1 -0
  509. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  510. package/dist/modes/interactive/components/custom-editor.js +9 -2
  511. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  512. package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
  513. package/dist/modes/interactive/components/settings-selector-handlers.js +3 -0
  514. package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
  515. package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
  516. package/dist/modes/interactive/components/settings-selector-items.js +7 -0
  517. package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
  518. package/dist/modes/interactive/components/settings-selector-types.d.ts +2 -0
  519. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  520. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  521. package/dist/modes/interactive/components/tool-execution.d.ts +3 -0
  522. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  523. package/dist/modes/interactive/components/tool-execution.js +26 -0
  524. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  525. package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
  526. package/dist/modes/interactive/components/tree-selector-content.js +0 -5
  527. package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
  528. package/dist/modes/interactive/interactive-auth-login.d.ts.map +1 -1
  529. package/dist/modes/interactive/interactive-auth-login.js +1 -0
  530. package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
  531. package/dist/modes/interactive/interactive-autocomplete.d.ts.map +1 -1
  532. package/dist/modes/interactive/interactive-autocomplete.js +80 -2
  533. package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
  534. package/dist/modes/interactive/interactive-hotkeys-debug.d.ts.map +1 -1
  535. package/dist/modes/interactive/interactive-hotkeys-debug.js +3 -0
  536. package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -1
  537. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  538. package/dist/modes/interactive/interactive-input-handling.js +51 -0
  539. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  540. package/dist/modes/interactive/interactive-mode-base.d.ts +5 -0
  541. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  542. package/dist/modes/interactive/interactive-mode-base.js +5 -0
  543. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  544. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
  545. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  546. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  547. package/dist/modes/interactive/interactive-mode-surface.d.ts +12 -0
  548. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  549. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  550. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  551. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  552. package/dist/modes/interactive/interactive-mode.js +1 -0
  553. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  554. package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
  555. package/dist/modes/interactive/interactive-model-routing.js +4 -1
  556. package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
  557. package/dist/modes/interactive/interactive-onboarding.d.ts +11 -0
  558. package/dist/modes/interactive/interactive-onboarding.d.ts.map +1 -0
  559. package/dist/modes/interactive/interactive-onboarding.js +220 -0
  560. package/dist/modes/interactive/interactive-onboarding.js.map +1 -0
  561. package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -1
  562. package/dist/modes/interactive/interactive-selectors.js +4 -0
  563. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  564. package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -1
  565. package/dist/modes/interactive/interactive-session-routing.js +6 -0
  566. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  567. package/dist/modes/interactive/interactive-slash-commands.d.ts.map +1 -1
  568. package/dist/modes/interactive/interactive-slash-commands.js +9 -4
  569. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  570. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  571. package/dist/modes/interactive/interactive-startup.js +28 -0
  572. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  573. package/dist/utils/child-process.d.ts.map +1 -1
  574. package/dist/utils/child-process.js +21 -1
  575. package/dist/utils/child-process.js.map +1 -1
  576. package/dist/utils/markit.d.ts +8 -0
  577. package/dist/utils/markit.d.ts.map +1 -0
  578. package/dist/utils/markit.js +53 -0
  579. package/dist/utils/markit.js.map +1 -0
  580. package/dist/utils/paths.d.ts +2 -1
  581. package/dist/utils/paths.d.ts.map +1 -1
  582. package/dist/utils/paths.js +14 -1
  583. package/dist/utils/paths.js.map +1 -1
  584. package/docs/compaction.md +18 -1
  585. package/docs/containerization.md +1 -1
  586. package/docs/docs.json +1 -0
  587. package/docs/extensions.md +25 -36
  588. package/docs/models.md +1 -1
  589. package/docs/providers.md +2 -1
  590. package/docs/quickstart.md +11 -6
  591. package/docs/sdk.md +5 -5
  592. package/docs/session-format.md +6 -0
  593. package/docs/sessions.md +6 -0
  594. package/docs/settings.md +7 -0
  595. package/docs/subagents.md +3 -2
  596. package/docs/tools.md +49 -0
  597. package/docs/usage.md +3 -3
  598. package/docs/workflows.md +112 -8
  599. package/examples/extensions/subagent/README.md +5 -5
  600. package/examples/extensions/subagent/agents/planner.md +1 -1
  601. package/examples/extensions/subagent/agents/reviewer.md +1 -1
  602. package/examples/extensions/subagent/agents/scout.md +2 -2
  603. package/examples/extensions/subagent/display.ts +3 -3
  604. package/examples/sdk/05-tools.ts +3 -3
  605. package/examples/sdk/README.md +1 -1
  606. package/package.json +5 -3
@@ -0,0 +1,61 @@
1
+ import { pauseRun, type PauseResult } from "./status.js";
2
+ import { store as defaultStore } from "../../shared/store.js";
3
+ import type { Store } from "../../shared/store-public-types.js";
4
+ import { topLevelWorkflowRuns } from "../../shared/run-visibility.js";
5
+ import type { StageControlRegistry } from "../foreground/stage-control-registry.js";
6
+ import { getDurableBackend } from "../../durable/factory.js";
7
+
8
+ export type QuitRunResult = PauseResult;
9
+
10
+ /**
11
+ * Quit/detach a workflow UI without authoritatively killing the workflow.
12
+ *
13
+ * This is the graph-panel/orchestrator close affordance: it pauses any live
14
+ * stage handles when possible, annotates the run as resumable via
15
+ * `/workflow resume`, and deliberately does NOT abort through the cancellation
16
+ * registry or append a terminal `workflow.run.end` entry. `/workflow kill`
17
+ * remains the only explicit non-resumable manual kill path.
18
+ */
19
+ export function quitRun(
20
+ runId: string,
21
+ opts?: {
22
+ store?: Store;
23
+ stageControlRegistry?: StageControlRegistry;
24
+ },
25
+ ): QuitRunResult {
26
+ const activeStore = opts?.store ?? defaultStore;
27
+ const run = activeStore.runs().find((candidate) => candidate.id === runId);
28
+ if (!run) return { ok: false, runId, reason: "not_found" };
29
+ if (run.endedAt !== undefined) return { ok: false, runId, reason: "already_ended" };
30
+
31
+ const paused = pauseRun(runId, opts);
32
+ if (!paused.ok && paused.reason !== "no_active_stages") return paused;
33
+ activeStore.recordRunPaused(runId, undefined, { exitReason: "quit", resumable: true });
34
+ // Mark the durable handle inactive so `/workflow resume` in this or another
35
+ // session can discover it again. While the run stays `running` in the store
36
+ // and (after a fresh dispatch) in the durable backend, it is hidden from the
37
+ // resume selector and refused on resume; quitting flips durable to `paused`.
38
+ markDurableQuit(runId);
39
+ return paused.ok ? paused : { ok: true, runId, paused: [] };
40
+ }
41
+
42
+ function markDurableQuit(runId: string): void {
43
+ let backend;
44
+ try {
45
+ backend = getDurableBackend();
46
+ } catch {
47
+ return;
48
+ }
49
+ if (backend.getWorkflow(runId) !== undefined) {
50
+ backend.setWorkflowStatus(runId, "paused", undefined, true);
51
+ }
52
+ }
53
+
54
+ export function quitAllRuns(opts?: {
55
+ store?: Store;
56
+ stageControlRegistry?: StageControlRegistry;
57
+ }): QuitRunResult[] {
58
+ const activeStore = opts?.store ?? defaultStore;
59
+ const inFlight = topLevelWorkflowRuns(activeStore.runs()).filter((r) => r.endedAt === undefined);
60
+ return inFlight.map((r) => quitRun(r.id, { store: activeStore, stageControlRegistry: opts?.stageControlRegistry }));
61
+ }
@@ -405,6 +405,7 @@ export function pauseAllRuns(opts?: {
405
405
  );
406
406
  }
407
407
 
408
+
408
409
  // ---------------------------------------------------------------------------
409
410
  // interruptRun
410
411
  // ---------------------------------------------------------------------------
@@ -67,7 +67,7 @@ export async function mapParallelSteps<T>(
67
67
  concurrency: number | undefined,
68
68
  failFast: boolean | undefined,
69
69
  mapper: (step: WorkflowTaskStep) => Promise<T>,
70
- onFirstFailure?: (error: unknown) => void,
70
+ onFirstFailure?: (error: unknown) => void | Promise<void>,
71
71
  control?: {
72
72
  readonly beforeDequeue?: () => void;
73
73
  readonly beforeMap?: () => void;
@@ -92,11 +92,11 @@ export async function mapParallelSteps<T>(
92
92
  controlSignal = error;
93
93
  if (failFastEnabled) rejectFirstFailure(error);
94
94
  };
95
- const recordFailure = (index: number, error: unknown): void => {
95
+ const recordFailure = async (index: number, error: unknown): Promise<void> => {
96
96
  failures.push({ index, error });
97
97
  if (firstFailure === undefined) {
98
98
  firstFailure = error;
99
- onFirstFailure?.(error);
99
+ await onFirstFailure?.(error);
100
100
  if (failFastEnabled) rejectFirstFailure(error);
101
101
  }
102
102
  };
@@ -112,7 +112,7 @@ export async function mapParallelSteps<T>(
112
112
  selectControlSignal(err);
113
113
  return;
114
114
  }
115
- recordFailure(nextIndex, err);
115
+ await recordFailure(nextIndex, err);
116
116
  return;
117
117
  }
118
118
  if (controlSignal !== undefined) return;
@@ -128,7 +128,7 @@ export async function mapParallelSteps<T>(
128
128
  selectControlSignal(err);
129
129
  return;
130
130
  }
131
- recordFailure(index, err);
131
+ await recordFailure(index, err);
132
132
  if (failFastEnabled) return;
133
133
  }
134
134
  }
@@ -8,6 +8,21 @@ import { hasExplicitFastModeCandidate } from "./executor-direct-helpers.js";
8
8
  import { applyFailureToStage } from "./executor-lifecycle.js";
9
9
  import { isTerminalStage } from "./executor-scheduler.js";
10
10
 
11
+ export interface TrackedStageCallOptions {
12
+ readonly eagerSession?: boolean;
13
+ readonly allowFinalized?: boolean;
14
+ }
15
+
16
+ export type TrackedStageCaller = <T>(
17
+ call: () => Promise<T>,
18
+ eagerSessionOrOptions?: boolean | TrackedStageCallOptions,
19
+ ) => Promise<T>;
20
+
21
+ function normalizeTrackedStageCallOptions(input: boolean | TrackedStageCallOptions | undefined): Required<TrackedStageCallOptions> {
22
+ if (typeof input === "boolean") return { eagerSession: input, allowFinalized: false };
23
+ return { eagerSession: input?.eagerSession === true, allowFinalized: input?.allowFinalized === true };
24
+ }
25
+
11
26
  export function createTrackedStageCaller(input: {
12
27
  readonly runtime: LiveStageRuntime;
13
28
  readonly limiter: ConcurrencyLimiter;
@@ -15,7 +30,7 @@ export function createTrackedStageCaller(input: {
15
30
  readonly adapters: StageAdapters;
16
31
  readonly hasContinuation: boolean;
17
32
  readonly hasScopedParents: boolean;
18
- }): <T>(call: () => Promise<T>, eagerSession?: boolean) => Promise<T> {
33
+ }): TrackedStageCaller {
19
34
  const { runtime } = input;
20
35
  const readinessGateEnabled = runtime.opts.confirmStageReadiness !== undefined || runtime.opts.usePromptNodesForUi === true;
21
36
  const confirmReadiness = async (): Promise<"advance" | "stay"> => {
@@ -68,22 +83,24 @@ export function createTrackedStageCaller(input: {
68
83
  return result;
69
84
  };
70
85
 
71
- return async <T>(call: () => Promise<T>, eagerSession = false): Promise<T> => {
86
+ return async <T>(call: () => Promise<T>, eagerSessionOrOptions?: boolean | TrackedStageCallOptions): Promise<T> => {
87
+ const callOptions = normalizeTrackedStageCallOptions(eagerSessionOrOptions);
72
88
  runtime.exit.throwIfWorkflowExitSelected();
73
89
  await runtime.scheduler.waitForStageRelease(runtime.stageId, runtime.releaseLiveHandle);
74
- if (runtime.state.stageFinalized) throw runtime.parallelFailFastError();
90
+ if (runtime.state.stageFinalized && !callOptions.allowFinalized) throw runtime.parallelFailFastError();
75
91
 
76
92
  await input.limiter.acquire();
77
93
  try {
78
94
  await runtime.scheduler.waitForStageRelease(runtime.stageId, runtime.releaseLiveHandle);
79
95
  runtime.exit.throwIfWorkflowExitSelected();
80
- if (runtime.state.stageFinalized) throw runtime.parallelFailFastError();
96
+ if (runtime.state.stageFinalized && !callOptions.allowFinalized) throw runtime.parallelFailFastError();
81
97
  } catch (err) {
82
98
  input.limiter.release();
83
99
  throw err;
84
100
  }
85
101
 
86
- if (!input.hasContinuation && runtime.stageSnapshot.startedAt === undefined && !input.hasScopedParents) {
102
+ const trackStageLifecycle = !runtime.state.stageFinalized;
103
+ if (trackStageLifecycle && !input.hasContinuation && runtime.stageSnapshot.startedAt === undefined && !input.hasScopedParents) {
87
104
  const actualParentIds = runtime.scheduler.tracker.currentParents();
88
105
  const sameParents = actualParentIds.length === runtime.stageSnapshot.parentIds.length &&
89
106
  actualParentIds.every((value) => runtime.stageSnapshot.parentIds.includes(value));
@@ -92,25 +109,29 @@ export function createTrackedStageCaller(input: {
92
109
  runtime.scheduler.setStageParentIds(runtime.stageSnapshot, actualParentIds);
93
110
  }
94
111
  }
95
- runtime.stageSnapshot.status = "running";
96
- runtime.stageSnapshot.startedAt = Date.now();
97
- const hasNoExplicitModelConfig = input.options?.model === undefined && input.options?.fallbackModels === undefined;
98
- const promptAdapterHandlesInitialPrompt = input.adapters.prompt !== undefined;
99
- if (eagerSession && !promptAdapterHandlesInitialPrompt && (hasNoExplicitModelConfig || await hasExplicitFastModeCandidate({
100
- model: input.options?.model,
101
- fallbackModels: input.options?.fallbackModels,
102
- models: runtime.opts.models,
103
- }))) {
104
- try {
105
- await runtime.innerCtx.__ensureSession();
106
- runtime.captureStageSessionMeta();
107
- } catch (err) {
108
- if (!(err instanceof Error && err.message.includes("prompt adapter not configured"))) throw err;
112
+ if (trackStageLifecycle) {
113
+ runtime.stageSnapshot.status = "running";
114
+ runtime.stageSnapshot.startedAt = Date.now();
115
+ const hasNoExplicitModelConfig = input.options?.model === undefined && input.options?.fallbackModels === undefined;
116
+ const promptAdapterHandlesInitialPrompt = input.adapters.prompt !== undefined;
117
+ if (callOptions.eagerSession && !promptAdapterHandlesInitialPrompt && (hasNoExplicitModelConfig || await hasExplicitFastModeCandidate({
118
+ model: input.options?.model,
119
+ fallbackModels: input.options?.fallbackModels,
120
+ models: runtime.opts.models,
121
+ }))) {
122
+ try {
123
+ await runtime.innerCtx.__ensureSession();
124
+ runtime.captureStageSessionMeta();
125
+ } catch (err) {
126
+ if (!(err instanceof Error && err.message.includes("prompt adapter not configured"))) throw err;
127
+ }
109
128
  }
129
+ runtime.applyModelFallbackMeta(runtime.innerCtx.__modelFallbackMeta());
130
+ runtime.activeStore.recordStageStart(runtime.runId, runtime.stageSnapshot);
131
+ runtime.appendStageStartOnce();
132
+ } else {
133
+ runtime.applyModelFallbackMeta(runtime.innerCtx.__modelFallbackMeta());
110
134
  }
111
- runtime.applyModelFallbackMeta(runtime.innerCtx.__modelFallbackMeta());
112
- runtime.activeStore.recordStageStart(runtime.runId, runtime.stageSnapshot);
113
- runtime.appendStageStartOnce();
114
135
 
115
136
  runtime.mcpScope.apply();
116
137
 
@@ -158,37 +179,57 @@ export function createTrackedStageCaller(input: {
158
179
  }
159
180
  runtime.captureStageSessionMeta();
160
181
  runtime.applyModelFallbackMeta(runtime.innerCtx.__modelFallbackMeta());
161
- if (runtime.stageFailFastScope?.failed === true && runtime.stageFailFastScope.activeStages.has(runtime.stageId)) {
182
+ if (trackStageLifecycle && runtime.stageFailFastScope?.failed === true && runtime.stageFailFastScope.activeStages.has(runtime.stageId)) {
162
183
  runtime.markSkippedForParallelFailFast();
163
184
  throw runtime.parallelFailFastError();
164
185
  }
165
- if (runtime.state.stageFinalized) throw runtime.parallelFailFastError();
166
- runtime.stageSnapshot.status = "completed";
167
- const assistantText = runtime.innerCtx.__getLastAssistantText();
168
- if (assistantText !== undefined) runtime.stageSnapshot.result = assistantText;
186
+ if (trackStageLifecycle && runtime.state.stageFinalized) throw runtime.parallelFailFastError();
187
+ if (trackStageLifecycle) {
188
+ runtime.stageSnapshot.status = "completed";
189
+ const assistantText = runtime.innerCtx.__getLastAssistantText();
190
+ if (assistantText !== undefined) runtime.stageSnapshot.result = assistantText;
191
+ }
169
192
  return result;
170
193
  } catch (err) {
171
194
  const workflowExitAbort = runtime.signal.aborted ? runtime.exit.currentWorkflowExitAbortReason() : undefined;
172
195
  if (workflowExitAbort !== undefined && !runtime.state.skippedForParallelFailFast) {
173
196
  runtime.state.stageClosedByWorkflowExit = true;
174
- if (!isTerminalStage(runtime.stageSnapshot)) {
197
+ if (trackStageLifecycle && !isTerminalStage(runtime.stageSnapshot)) {
175
198
  runtime.stageSnapshot.status = "skipped";
176
199
  runtime.stageSnapshot.skippedReason = runtime.exit.workflowExitSkippedReason(workflowExitAbort.reason);
177
200
  }
178
- } else if (!runtime.signal.aborted && !runtime.state.skippedForParallelFailFast) {
201
+ } else if (trackStageLifecycle && !runtime.signal.aborted && !runtime.state.skippedForParallelFailFast) {
179
202
  applyFailureToStage(runtime.stageSnapshot, runtime.classifyExecutorFailure(err));
180
203
  }
181
204
  throw err;
182
205
  } finally {
206
+ // Finalization, handle release, and limiter release are each independent.
207
+ // If finalizeStageSnapshot() throws, the limiter must still be released
208
+ // so the concurrency semaphore is not leaked.
209
+ // cross-ref: issue #1498 — durable finalization failures must not leak the stage limiter.
183
210
  runtime.mcpScope.clear();
184
211
  runtime.captureStageSessionMeta();
185
- runtime.finalizeStageSnapshot();
186
- if (runtime.state.stageClosedByWorkflowExit || runtime.exit.currentWorkflowExitAbortReason() !== undefined) {
212
+ let finalizationError: { readonly thrown: true; readonly error: unknown } | undefined;
213
+ if (trackStageLifecycle) {
214
+ try {
215
+ await runtime.finalizeStageSnapshot();
216
+ } catch (err) {
217
+ finalizationError = { thrown: true, error: err };
218
+ }
219
+ try {
220
+ if (runtime.state.stageClosedByWorkflowExit || runtime.exit.currentWorkflowExitAbortReason() !== undefined) {
221
+ await runtime.releaseLiveHandle().catch(() => {});
222
+ } else {
223
+ await runtime.dropStageControlForCompletion().catch(() => {});
224
+ }
225
+ } catch {
226
+ // Best-effort: handle release failure must not prevent limiter release.
227
+ }
228
+ } else if (runtime.state.stageClosedByWorkflowExit || runtime.exit.currentWorkflowExitAbortReason() !== undefined) {
187
229
  await runtime.releaseLiveHandle().catch(() => {});
188
- } else {
189
- await runtime.dropStageControlForCompletion().catch(() => {});
190
230
  }
191
231
  input.limiter.release();
232
+ if (finalizationError !== undefined) throw finalizationError.error;
192
233
  }
193
234
  };
194
235
  }
@@ -1,5 +1,6 @@
1
1
  import type { StageContextWithMeta, StageNoticeInput, LiveStageRuntime } from "./executor-stage-types.js";
2
2
  import type { InternalStageContext } from "./stage-runner.js";
3
+ import type { TrackedStageCaller } from "./executor-stage-call.js";
3
4
 
4
5
  function noticeValue(value: unknown): string {
5
6
  if (typeof value === "string") return value;
@@ -31,7 +32,7 @@ function compactionMeta(result: unknown): string | undefined {
31
32
 
32
33
  export function createStageContext(input: {
33
34
  readonly runtime: LiveStageRuntime;
34
- readonly runTrackedStageCall: <T>(call: () => Promise<T>, eagerSession?: boolean) => Promise<T>;
35
+ readonly runTrackedStageCall: TrackedStageCaller;
35
36
  }): StageContextWithMeta {
36
37
  const { runtime } = input;
37
38
  const recordStageNotice = (notice: StageNoticeInput): void => {
@@ -43,6 +44,19 @@ export function createStageContext(input: {
43
44
  };
44
45
 
45
46
  const innerCtx: InternalStageContext = runtime.innerCtx;
47
+ const sendStreamingUserMessage: InternalStageContext["sendUserMessage"] = async (text, options) => {
48
+ runtime.mcpScope.apply();
49
+ try {
50
+ await innerCtx.sendUserMessage(text, options);
51
+ } finally {
52
+ try {
53
+ runtime.mcpScope.clear();
54
+ } finally {
55
+ runtime.captureStageSessionMeta();
56
+ runtime.applyModelFallbackMeta(innerCtx.__modelFallbackMeta());
57
+ }
58
+ }
59
+ };
46
60
  return {
47
61
  name: innerCtx.name,
48
62
  prompt: (text, promptOptions) => {
@@ -53,6 +67,11 @@ export function createStageContext(input: {
53
67
  runtime.throwIfStageMutationBlocked();
54
68
  return input.runTrackedStageCall(() => innerCtx.complete(text, completeOptions));
55
69
  },
70
+ sendUserMessage: (text, options) => {
71
+ runtime.throwIfStageMutationBlocked();
72
+ if (innerCtx.isStreaming) return sendStreamingUserMessage(text, options);
73
+ return input.runTrackedStageCall(() => innerCtx.sendUserMessage(text, options), { allowFinalized: true });
74
+ },
56
75
  steer: (text) => {
57
76
  runtime.throwIfStageMutationBlocked();
58
77
  return innerCtx.steer(text);
@@ -193,6 +193,7 @@ export function createWorkflowStageFactory(input: {
193
193
  if (meta.sessionId !== undefined) stageSnapshot.sessionId = meta.sessionId;
194
194
  if (meta.sessionFile !== undefined) stageSnapshot.sessionFile = meta.sessionFile;
195
195
  if (meta.sessionId !== undefined || meta.sessionFile !== undefined) input.activeStore.recordStageSession(input.runId, stageId, meta);
196
+ void input.opts.onStageSession?.(input.runId, stageSnapshot);
196
197
  };
197
198
  const releaseLiveHandle = async (): Promise<void> => {
198
199
  if (state.liveHandleReleased) return;
@@ -226,7 +227,7 @@ export function createWorkflowStageFactory(input: {
226
227
  });
227
228
  };
228
229
 
229
- const finalizeStageSnapshot = (): boolean => {
230
+ const finalizeStageSnapshot = async (): Promise<boolean> => {
230
231
  if (state.stageFinalized) return false;
231
232
  if (stageSnapshot.endedAt !== undefined && isTerminalStage(stageSnapshot)) {
232
233
  state.stageFinalized = true;
@@ -242,7 +243,7 @@ export function createWorkflowStageFactory(input: {
242
243
  applyModelFallbackMeta(innerCtx.__modelFallbackMeta());
243
244
  input.activeStore.recordStageEnd(input.runId, stageSnapshot);
244
245
  stageUiBroker.cancelStagePrompt(input.runId, stageId, new Error(`atomic-workflows: stage ${stageId} completed with pending custom UI`));
245
- input.opts.onStageEnd?.(input.runId, stageSnapshot);
246
+ await input.opts.onStageEnd?.(input.runId, stageSnapshot);
246
247
  if (input.opts.persistence) {
247
248
  appendStageStartOnce();
248
249
  appendStageEnd(input.opts.persistence, {
@@ -325,12 +326,12 @@ export function createWorkflowStageFactory(input: {
325
326
  // workflow-exit cleanup and removes the stage from the fail-fast active set.
326
327
  // Later paths must not overwrite the terminal skippedReason; they only abort
327
328
  // and release idempotent live handles.
328
- const skipForParallelFailFast = (): void => {
329
+ const skipForParallelFailFast = async (): Promise<void> => {
329
330
  if (isTerminalStage(stageSnapshot)) return;
330
331
  markSkippedForParallelFailFast();
331
- finalizeStageSnapshot();
332
- void innerCtx.abort().catch(() => {});
333
- void dropStageControlForCompletion().catch(() => {});
332
+ await finalizeStageSnapshot();
333
+ await innerCtx.abort().catch(() => {});
334
+ await dropStageControlForCompletion().catch(() => {});
334
335
  };
335
336
  stageFailFastScope?.activeStages.set(stageId, { skip: skipForParallelFailFast });
336
337
  runtime.unregisterWorkflowExitCleanup = input.exit.registerWorkflowExitCleanup(stageId, {
@@ -339,7 +340,7 @@ export function createWorkflowStageFactory(input: {
339
340
  if (!isTerminalStage(stageSnapshot)) {
340
341
  stageSnapshot.status = "skipped";
341
342
  stageSnapshot.skippedReason = input.exit.workflowExitSkippedReason(reason);
342
- finalizeStageSnapshot();
343
+ await finalizeStageSnapshot();
343
344
  }
344
345
  await innerCtx.abort().catch(() => {});
345
346
  await releaseLiveHandle().catch(() => {});
@@ -95,6 +95,7 @@ export function createReplayStageContext(input: {
95
95
  name,
96
96
  prompt: replayText,
97
97
  complete: replayText,
98
+ sendUserMessage: async () => rejectReplayMutation("send a user message"),
98
99
  steer: async () => rejectReplayMutation("steer"),
99
100
  followUp: async () => rejectReplayMutation("follow up"),
100
101
  subscribe: () => () => {},
@@ -48,7 +48,7 @@ export interface LiveStageRuntime {
48
48
  readonly captureStageSessionMeta: () => void;
49
49
  readonly applyModelFallbackMeta: (meta: ReturnType<InternalStageContext["__modelFallbackMeta"]>) => void;
50
50
  readonly appendStageStartOnce: () => void;
51
- readonly finalizeStageSnapshot: () => boolean;
51
+ readonly finalizeStageSnapshot: () => Promise<boolean>;
52
52
  readonly releaseLiveHandle: () => Promise<void>;
53
53
  readonly dropStageControlForCompletion: () => Promise<void>;
54
54
  readonly markSkippedForParallelFailFast: () => void;
@@ -70,6 +70,22 @@ export interface RunOpts extends Omit<AuthoringContract.RunOpts, "adapters" | "s
70
70
  runId?: string;
71
71
  /** Replay completed stages from a failed source run, then resume at this stage. */
72
72
  continuation?: RunContinuationOpts;
73
+ /**
74
+ * Durable workflow backend override (for testing). Defaults to the global
75
+ * backend resolved by `getDurableBackend()`.
76
+ *
77
+ * cross-ref: issue #1498 — DBOS-backed cross-session resumability.
78
+ */
79
+ durableBackend?: import("../../durable/backend.js").DurableWorkflowBackend;
80
+ /**
81
+ * Durable scope for a child workflow run. When set, the child's internal
82
+ * `ctx.tool`/`ctx.ui`/`ctx.stage` checkpoints are routed under the root
83
+ * workflow id with a stable boundary prefix so an interrupted child does
84
+ * not re-execute completed side effects on parent resume.
85
+ *
86
+ * cross-ref: issue #1498.
87
+ */
88
+ durableScope?: import("../../durable/scoped-backend.js").DurableScope;
73
89
  /** Internal parent linkage for nested ctx.workflow(...) runs. */
74
90
  parentRun?: {
75
91
  readonly runId: string;
@@ -78,7 +94,8 @@ export interface RunOpts extends Omit<AuthoringContract.RunOpts, "adapters" | "s
78
94
  };
79
95
  onRunStart?: (snapshot: RunSnapshot) => void;
80
96
  onStageStart?: (runId: string, snapshot: StageSnapshot) => void;
81
- onStageEnd?: (runId: string, snapshot: StageSnapshot) => void;
97
+ onStageEnd?: (runId: string, snapshot: StageSnapshot) => unknown;
98
+ onStageSession?: (runId: string, snapshot: StageSnapshot) => unknown;
82
99
  onRunEnd?: (runId: string, status: RunStatus, result?: WorkflowOutputValues, error?: string, exitReason?: string) => void;
83
100
  }
84
101
 
@@ -94,7 +111,7 @@ export interface RunResult<TOutputs extends WorkflowOutputValues = WorkflowOutpu
94
111
  }
95
112
 
96
113
  export interface ParallelFailFastStage {
97
- readonly skip: () => void;
114
+ readonly skip: () => Promise<void>;
98
115
  }
99
116
 
100
117
  export interface ParallelFailFastScope {
@@ -92,6 +92,10 @@ export function createStageContext(opts: StageRunnerOpts): InternalStageContext
92
92
  return lastAssistantText;
93
93
  },
94
94
 
95
+ async sendUserMessage(text, options) {
96
+ await controller.sendUserMessage(text, options);
97
+ },
98
+
95
99
  async steer(text) {
96
100
  await (await controller.ensureSession()).steer(text);
97
101
  },
@@ -1,10 +1,11 @@
1
1
  import { getModelDefaultContextWindow, getSupportedContextWindows, SessionManager, shouldApplyCodexFastModeForScope, type AgentSession, type CreateAgentSessionOptions, type PromptOptions, type StructuredOutputCapture } from "@bastani/atomic";
2
- import type { StageContext, StageExecutionMeta, StageOptions, WorkflowModelAttempt, WorkflowModelCatalogPort } from "../../shared/types.js";
2
+ import type { StageContext, StageExecutionMeta, StageOptions, StageSendUserMessageOptions, StageUserMessageContent, WorkflowModelAttempt, WorkflowModelCatalogPort } from "../../shared/types.js";
3
3
  import { buildModelCandidatesFromCatalog, errorMessage, isRetryableModelFailure, workflowModelId, type WorkflowResolvedModelCandidate } from "../shared/model-fallback.js";
4
4
  import { WorkflowPromptModelFailure, lastAssistantTextFromSession, latestTerminalAssistantFailureSince } from "./stage-runner-messages.js";
5
5
  import { missingAdapter, stripWorkflowOnlyOptions, unavailableSync } from "./stage-runner-options.js";
6
6
  import { asAgentSession, disposeStageSession, normalizeSessionCreateResult } from "./stage-runner-session.js";
7
7
  import { structuredOutputToolErrorFromEvent } from "./stage-runner-structured-output.js";
8
+ import { sendStageUserMessage } from "./stage-runner-send-user-message.js";
8
9
  import type { AgentSessionConsumer, StageModelFallbackMeta, StageRunnerOpts, StageSessionCreateOptions, StageSessionCreateResult, StageSessionEvent, StageSessionRuntime, WorkflowFastModeSettingsManager } from "./stage-runner-types.js";
9
10
 
10
11
  type PauseRequest = {
@@ -60,7 +61,6 @@ export class StageSessionController {
60
61
  get latestStructuredOutputToolError(): string | undefined { return this.latestStructuredOutputToolErrorValue; }
61
62
 
62
63
  resetStructuredOutputToolError(): void { this.latestStructuredOutputToolErrorValue = undefined; }
63
-
64
64
  requireSession(property: string): StageSessionRuntime {
65
65
  if (!this.session) unavailableSync(property);
66
66
  return this.session;
@@ -98,6 +98,10 @@ export class StageSessionController {
98
98
  return this.ensureSession(consumer);
99
99
  }
100
100
 
101
+ async sendUserMessage(content: StageUserMessageContent, options?: StageSendUserMessageOptions): Promise<void> {
102
+ await sendStageUserMessage(await this.ensureSession("prompt"), content, options);
103
+ }
104
+
101
105
  async promptWithFallback(
102
106
  text: string,
103
107
  sdkOptions: PromptOptions | undefined,
@@ -242,14 +246,10 @@ export class StageSessionController {
242
246
  fallbackThinkingLevels: undefined,
243
247
  };
244
248
  if (resumeOptions?.restoreSavedModel) delete optionsForCandidate.model;
245
- // Pin a tiered model's natural default (short) context window when neither
246
- // the `(1m)` model-string token nor an explicit stage-level contextWindow
247
- // selects one for a fresh (non-resumed) stage session. This prevents a
248
- // persisted interactive context-window preference (e.g. a previously
249
- // selected long tier) from leaking into workflow stages, so a tiered model
250
- // uses its short tier unless the author explicitly opts into the long tier
251
- // via the `(1m)` token or the numeric contextWindow option. Single-window
252
- // models carry no selectable long tier, so they are left untouched.
249
+ // Pin a tiered model's short default context window for fresh, non-resumed
250
+ // stage sessions unless the author selected a long tier via `(1m)` or
251
+ // contextWindow. This prevents persisted interactive long-tier preferences
252
+ // from leaking into workflow stages; single-window models are left alone.
253
253
  if (
254
254
  resumeOptions?.restoreSavedModel !== true &&
255
255
  this.reattachSessionFile === undefined &&
@@ -18,6 +18,8 @@ export function stripWorkflowOnlyOptions(
18
18
  fallbackThinkingLevels: _fallbackThinkingLevels,
19
19
  context,
20
20
  forkFromSessionFile,
21
+ resumeFromSessionFile,
22
+ durableReplayKey: _durableReplayKey,
21
23
  sessionDir,
22
24
  gitWorktreeDir: _gitWorktreeDir,
23
25
  baseBranch: _baseBranch,
@@ -26,7 +28,9 @@ export function stripWorkflowOnlyOptions(
26
28
  if (sessionOptions.sessionManager === undefined) {
27
29
  const cwd = sessionOptions.cwd ?? process.cwd();
28
30
  const effectiveSessionDir = sessionDir ?? defaultSessionDir;
29
- if (context === "fork" && forkFromSessionFile !== undefined) {
31
+ if (resumeFromSessionFile !== undefined) {
32
+ sessionOptions.sessionManager = SessionManager.open(resumeFromSessionFile, effectiveSessionDir, cwd);
33
+ } else if (context === "fork" && forkFromSessionFile !== undefined) {
30
34
  sessionOptions.sessionManager = SessionManager.forkFrom(forkFromSessionFile, cwd, effectiveSessionDir);
31
35
  } else if (effectiveSessionDir !== undefined) {
32
36
  sessionOptions.sessionManager = SessionManager.create(cwd, effectiveSessionDir);
@@ -0,0 +1,25 @@
1
+ import type { StageSendUserMessageOptions, StageUserMessageContent } from "../../shared/types.js";
2
+ import type { StageSessionRuntime } from "./stage-runner-types.js";
3
+
4
+ function unsupportedContentError(): Error {
5
+ return new Error("atomic-workflows: this stage session adapter does not support non-string sendUserMessage content; provide a runtime sendUserMessage implementation for text/image blocks.");
6
+ }
7
+
8
+ export async function sendStageUserMessage(
9
+ activeSession: StageSessionRuntime,
10
+ content: StageUserMessageContent,
11
+ options?: StageSendUserMessageOptions,
12
+ ): Promise<void> {
13
+ const deliverAs = activeSession.isStreaming ? options?.deliverAs ?? "followUp" : options?.deliverAs;
14
+ if (activeSession.sendUserMessage !== undefined) {
15
+ await activeSession.sendUserMessage(content, deliverAs === undefined ? undefined : { deliverAs });
16
+ return;
17
+ }
18
+ if (typeof content !== "string") throw unsupportedContentError();
19
+ if (activeSession.isStreaming) {
20
+ if (deliverAs === "steer") await activeSession.steer(content);
21
+ else await activeSession.followUp(content);
22
+ return;
23
+ }
24
+ await activeSession.prompt(content);
25
+ }
@@ -6,6 +6,8 @@ import type {
6
6
  import type {
7
7
  CompleteStageOpts,
8
8
  StageContext,
9
+ StageSendUserMessageOptions,
10
+ StageUserMessageContent,
9
11
  StageExecutionMeta,
10
12
  StageOptions,
11
13
  WorkflowExecutionMode,
@@ -26,6 +28,7 @@ export type WorkflowFastModeSettingsManager = {
26
28
 
27
29
  export interface StageSessionRuntime {
28
30
  prompt(text: string, options?: PromptOptions): Promise<string | void>;
31
+ sendUserMessage?(content: StageUserMessageContent, options?: StageSendUserMessageOptions): Promise<void>;
29
32
  steer(text: string): Promise<void>;
30
33
  followUp(text: string): Promise<void>;
31
34
  subscribe(listener: (event: StageSessionEvent) => void): () => void;
@@ -40,6 +40,16 @@ export interface WorkflowModelFallbackFields {
40
40
  readonly fallbackThinkingLevels?: readonly string[];
41
41
  }
42
42
  export type WorkflowModelValue = string | object;
43
+ export interface StageTextContent {
44
+ readonly type: "text";
45
+ readonly text: string;
46
+ }
47
+ export interface StageImageContent {
48
+ readonly type: "image";
49
+ readonly data: string;
50
+ readonly mimeType: string;
51
+ }
52
+ export type StageUserMessageContent = string | readonly (StageTextContent | StageImageContent)[];
43
53
  export type WorkflowStageResult<TSchemaDef extends TSchema | undefined = undefined> = [TSchemaDef] extends [TSchema] ? Static<TSchemaDef> : string;
44
54
  export interface WorkflowModelUsage extends WorkflowSerializableObject {
45
55
  readonly input?: number;
@@ -178,6 +188,7 @@ export interface WorkflowPersistencePort {
178
188
  }
179
189
  export interface StageSessionRuntime {
180
190
  prompt(text: string, options?: PromptOptions): Promise<string | void>;
191
+ sendUserMessage?(content: StageUserMessageContent, options?: StageSendUserMessageOptions): Promise<void>;
181
192
  steer(text: string): Promise<void>;
182
193
  followUp(text: string): Promise<void>;
183
194
  subscribe(listener: (event: never) => void): () => void;
@@ -236,10 +247,15 @@ export interface StageAdapters {
236
247
  readonly prompt?: PromptAdapter;
237
248
  readonly complete?: CompleteAdapter;
238
249
  }
250
+ export type StageUserMessageDelivery = "steer" | "followUp";
251
+ export interface StageSendUserMessageOptions {
252
+ readonly deliverAs?: StageUserMessageDelivery;
253
+ }
239
254
  export interface StageContext<TSchemaDef extends TSchema | undefined = undefined> {
240
255
  readonly name: string;
241
256
  prompt(text: string, options?: StagePromptOptions): Promise<WorkflowStageResult<TSchemaDef>>;
242
257
  complete(text: string, options?: CompleteStageOpts): Promise<string>;
258
+ sendUserMessage(content: StageUserMessageContent, options?: StageSendUserMessageOptions): Promise<void>;
243
259
  steer(text: string): Promise<void>;
244
260
  followUp(text: string): Promise<void>;
245
261
  subscribe(listener: (event: never) => void): () => void;