@bastani/atomic 0.9.74-alpha.1 → 0.9.75

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 (383) hide show
  1. package/CHANGELOG.md +162 -0
  2. package/dist/builtin/intercom/package.json +2 -2
  3. package/dist/builtin/mcp/package.json +1 -1
  4. package/dist/builtin/subagents/CHANGELOG.md +21 -0
  5. package/dist/builtin/subagents/package.json +3 -3
  6. package/dist/builtin/subagents/skills/agent-browser/SKILL.md +8 -10
  7. package/dist/builtin/subagents/skills/agent-desktop/SKILL.md +9 -5
  8. package/dist/builtin/subagents/src/extension/index.bundle.mjs +7 -1
  9. package/dist/builtin/web-access/package.json +2 -2
  10. package/dist/builtin/workflows/CHANGELOG.md +80 -0
  11. package/dist/builtin/workflows/README.md +5 -2
  12. package/dist/builtin/workflows/builtin/{chunk-m8eg152f.js → chunk-89we7r4p.js} +1 -1
  13. package/dist/builtin/workflows/builtin/{chunk-a4fdm2cw.js → chunk-8yfssw01.js} +1 -1
  14. package/dist/builtin/workflows/builtin/{chunk-774myqzs.js → chunk-v8mb0005.js} +366 -45
  15. package/dist/builtin/workflows/builtin/{chunk-d5cxskkp.js → chunk-wh2p4qjg.js} +2 -2
  16. package/dist/builtin/workflows/builtin/goal.js +2 -2
  17. package/dist/builtin/workflows/builtin/index.d.ts +10 -0
  18. package/dist/builtin/workflows/builtin/index.js +4 -4
  19. package/dist/builtin/workflows/builtin/open-claude-design.d.ts +12 -0
  20. package/dist/builtin/workflows/builtin/open-claude-design.js +1 -1
  21. package/dist/builtin/workflows/builtin/ralph.js +2 -2
  22. package/dist/builtin/workflows/package.json +2 -2
  23. package/dist/builtin/workflows/skills/impeccable/SKILL.md +4 -4
  24. package/dist/builtin/workflows/skills/impeccable/reference/android.md +1 -1
  25. package/dist/builtin/workflows/skills/impeccable/reference/audit.md +2 -2
  26. package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +1 -1
  27. package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +1 -1
  28. package/dist/builtin/workflows/skills/impeccable/reference/degraded/documenter.md +4 -4
  29. package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +2 -2
  30. package/dist/builtin/workflows/skills/impeccable/reference/degraded/manual-edit-applier.md +3 -2
  31. package/dist/builtin/workflows/skills/impeccable/reference/distill.md +3 -3
  32. package/dist/builtin/workflows/skills/impeccable/reference/doctor.md +1 -1
  33. package/dist/builtin/workflows/skills/impeccable/reference/document.md +3 -3
  34. package/dist/builtin/workflows/skills/impeccable/reference/harden.md +19 -0
  35. package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +15 -8
  36. package/dist/builtin/workflows/skills/impeccable/reference/init.md +2 -0
  37. package/dist/builtin/workflows/skills/impeccable/reference/live.md +8 -6
  38. package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +4 -4
  39. package/dist/builtin/workflows/skills/impeccable/reference/optimize.md +0 -1
  40. package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +1 -1
  41. package/dist/builtin/workflows/skills/impeccable/scripts/VERSION +1 -1
  42. package/dist/builtin/workflows/skills/impeccable/scripts/command-metadata.json +2 -2
  43. package/dist/builtin/workflows/skills/impeccable/scripts/engine-checksums.txt +9 -0
  44. package/dist/builtin/workflows/skills/impeccable/scripts/impeccable +98 -44
  45. package/dist/builtin/workflows/skills/impeccable/scripts/impeccable.cmd +101 -34
  46. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-ignores.js +6 -2
  47. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-session.js +4 -1
  48. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +444 -144
  49. package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +3 -1
  50. package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +2 -2
  51. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5.md +13 -11
  52. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_1.md +10 -8
  53. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_2.md +143 -0
  54. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_haiku_5_5.md +11 -7
  55. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_4_8.md +3 -3
  56. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5.md +6 -2
  57. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5_5.md +7 -7
  58. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5.md +2 -2
  59. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5_5.md +3 -3
  60. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_5.md +2 -2
  61. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_6.md +2 -2
  62. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6.md +6 -5
  63. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_sol.md +4 -4
  64. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_terra.md +2 -2
  65. package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +4 -3
  66. package/dist/builtin/workflows/skills/skill-creator/scripts/aggregate_benchmark.py +0 -0
  67. package/dist/builtin/workflows/skills/skill-creator/scripts/generate_report.py +0 -0
  68. package/dist/builtin/workflows/skills/skill-creator/scripts/improve_description.py +0 -0
  69. package/dist/builtin/workflows/skills/skill-creator/scripts/package_skill.py +0 -0
  70. package/dist/builtin/workflows/skills/skill-creator/scripts/quick_validate.py +0 -0
  71. package/dist/builtin/workflows/skills/skill-creator/scripts/run_eval.py +0 -0
  72. package/dist/builtin/workflows/skills/skill-creator/scripts/run_loop.py +0 -0
  73. package/dist/builtin/workflows/skills/unslop/SKILL.md +15 -34
  74. package/dist/builtin/workflows/src/durable/journal/memory-run-journal.d.ts +1 -0
  75. package/dist/builtin/workflows/src/durable/journal/values.d.ts +2 -0
  76. package/dist/builtin/workflows/src/extension/index.bundle.mjs +809 -410
  77. package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +695 -305
  78. package/dist/builtin/workflows/src/index.js +685 -295
  79. package/dist/builtin/workflows/src/local-worker-entry.mjs +695 -305
  80. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +6 -6
  81. package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +2 -2
  82. package/dist/builtin/workflows/src/shared/serializable-error-families.d.ts +2 -0
  83. package/dist/bun/app-host-modules.d.ts +1 -1
  84. package/dist/bun/app-host-modules.d.ts.map +1 -1
  85. package/dist/bun/app-host-modules.js.map +1 -1
  86. package/dist/bun/internal-workflow-worker.d.ts +2 -0
  87. package/dist/bun/internal-workflow-worker.d.ts.map +1 -1
  88. package/dist/bun/internal-workflow-worker.js +2 -1
  89. package/dist/bun/internal-workflow-worker.js.map +1 -1
  90. package/dist/codemode-worker.js +2 -0
  91. package/dist/config.d.ts +8 -0
  92. package/dist/config.d.ts.map +1 -1
  93. package/dist/config.js +14 -0
  94. package/dist/config.js.map +1 -1
  95. package/dist/core/agent-session-bash.d.ts.map +1 -1
  96. package/dist/core/agent-session-bash.js +2 -1
  97. package/dist/core/agent-session-bash.js.map +1 -1
  98. package/dist/core/agent-session-blueprint-environment.d.ts +10 -0
  99. package/dist/core/agent-session-blueprint-environment.d.ts.map +1 -0
  100. package/dist/core/agent-session-blueprint-environment.js +28 -0
  101. package/dist/core/agent-session-blueprint-environment.js.map +1 -0
  102. package/dist/core/agent-session-events.d.ts.map +1 -1
  103. package/dist/core/agent-session-events.js +2 -0
  104. package/dist/core/agent-session-events.js.map +1 -1
  105. package/dist/core/agent-session-methods.d.ts +1 -0
  106. package/dist/core/agent-session-methods.d.ts.map +1 -1
  107. package/dist/core/agent-session-methods.js.map +1 -1
  108. package/dist/core/agent-session-retry.d.ts.map +1 -1
  109. package/dist/core/agent-session-retry.js +14 -4
  110. package/dist/core/agent-session-retry.js.map +1 -1
  111. package/dist/core/agent-session-runtime.d.ts +20 -0
  112. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  113. package/dist/core/agent-session-runtime.js +55 -6
  114. package/dist/core/agent-session-runtime.js.map +1 -1
  115. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  116. package/dist/core/agent-session-tool-registry.js +2 -1
  117. package/dist/core/agent-session-tool-registry.js.map +1 -1
  118. package/dist/core/agent-session.d.ts +2 -0
  119. package/dist/core/agent-session.d.ts.map +1 -1
  120. package/dist/core/agent-session.js +2 -0
  121. package/dist/core/agent-session.js.map +1 -1
  122. package/dist/core/async-scope.d.ts +13 -0
  123. package/dist/core/async-scope.d.ts.map +1 -0
  124. package/dist/core/async-scope.js +20 -0
  125. package/dist/core/async-scope.js.map +1 -0
  126. package/dist/core/cache-warmer.d.ts +3 -14
  127. package/dist/core/cache-warmer.d.ts.map +1 -1
  128. package/dist/core/cache-warmer.js +8 -60
  129. package/dist/core/cache-warmer.js.map +1 -1
  130. package/dist/core/extensions/extension-work.js +2 -2
  131. package/dist/core/extensions/extension-work.js.map +1 -1
  132. package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
  133. package/dist/core/extensions/loader-host-modules.js +3 -1
  134. package/dist/core/extensions/loader-host-modules.js.map +1 -1
  135. package/dist/core/extensions/ui-types.d.ts +2 -1
  136. package/dist/core/extensions/ui-types.d.ts.map +1 -1
  137. package/dist/core/extensions/ui-types.js.map +1 -1
  138. package/dist/core/extensions/workflow-events.d.ts +1 -1
  139. package/dist/core/extensions/workflow-events.d.ts.map +1 -1
  140. package/dist/core/extensions/workflow-events.js.map +1 -1
  141. package/dist/core/extensions/workflow-run-control.d.ts +4 -2
  142. package/dist/core/extensions/workflow-run-control.d.ts.map +1 -1
  143. package/dist/core/extensions/workflow-run-control.js.map +1 -1
  144. package/dist/core/model-fallback-failures.d.ts +6 -0
  145. package/dist/core/model-fallback-failures.d.ts.map +1 -1
  146. package/dist/core/model-fallback-failures.js +10 -1
  147. package/dist/core/model-fallback-failures.js.map +1 -1
  148. package/dist/core/preferred-providers.d.ts +19 -0
  149. package/dist/core/preferred-providers.d.ts.map +1 -0
  150. package/dist/core/preferred-providers.js +25 -0
  151. package/dist/core/preferred-providers.js.map +1 -0
  152. package/dist/core/provider-alias.d.ts.map +1 -1
  153. package/dist/core/provider-alias.js +4 -0
  154. package/dist/core/provider-alias.js.map +1 -1
  155. package/dist/core/provider-composer.d.ts.map +1 -1
  156. package/dist/core/provider-composer.js +1 -0
  157. package/dist/core/provider-composer.js.map +1 -1
  158. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  159. package/dist/core/remote-catalog-provider.js +3 -0
  160. package/dist/core/remote-catalog-provider.js.map +1 -1
  161. package/dist/core/resume/blueprint/action-expressions.d.ts +32 -0
  162. package/dist/core/resume/blueprint/action-expressions.d.ts.map +1 -0
  163. package/dist/core/resume/blueprint/action-expressions.js +389 -0
  164. package/dist/core/resume/blueprint/action-expressions.js.map +1 -0
  165. package/dist/core/resume/blueprint/actions.d.ts +90 -0
  166. package/dist/core/resume/blueprint/actions.d.ts.map +1 -0
  167. package/dist/core/resume/blueprint/actions.js +818 -0
  168. package/dist/core/resume/blueprint/actions.js.map +1 -0
  169. package/dist/core/resume/blueprint/build.d.ts +102 -0
  170. package/dist/core/resume/blueprint/build.d.ts.map +1 -0
  171. package/dist/core/resume/blueprint/build.js +535 -0
  172. package/dist/core/resume/blueprint/build.js.map +1 -0
  173. package/dist/core/resume/blueprint/context.d.ts +11 -0
  174. package/dist/core/resume/blueprint/context.d.ts.map +1 -0
  175. package/dist/core/resume/blueprint/context.js +106 -0
  176. package/dist/core/resume/blueprint/context.js.map +1 -0
  177. package/dist/core/resume/blueprint/envrc.d.ts +19 -0
  178. package/dist/core/resume/blueprint/envrc.d.ts.map +1 -0
  179. package/dist/core/resume/blueprint/envrc.js +77 -0
  180. package/dist/core/resume/blueprint/envrc.js.map +1 -0
  181. package/dist/core/resume/blueprint/errors.d.ts +179 -0
  182. package/dist/core/resume/blueprint/errors.d.ts.map +1 -0
  183. package/dist/core/resume/blueprint/errors.js +169 -0
  184. package/dist/core/resume/blueprint/errors.js.map +1 -0
  185. package/dist/core/resume/blueprint/ledger.d.ts +51 -0
  186. package/dist/core/resume/blueprint/ledger.d.ts.map +1 -0
  187. package/dist/core/resume/blueprint/ledger.js +119 -0
  188. package/dist/core/resume/blueprint/ledger.js.map +1 -0
  189. package/dist/core/resume/blueprint/notices.d.ts +14 -0
  190. package/dist/core/resume/blueprint/notices.d.ts.map +1 -0
  191. package/dist/core/resume/blueprint/notices.js +44 -0
  192. package/dist/core/resume/blueprint/notices.js.map +1 -0
  193. package/dist/core/resume/blueprint/process.d.ts +44 -0
  194. package/dist/core/resume/blueprint/process.d.ts.map +1 -0
  195. package/dist/core/resume/blueprint/process.js +142 -0
  196. package/dist/core/resume/blueprint/process.js.map +1 -0
  197. package/dist/core/resume/blueprint/resume.d.ts +73 -0
  198. package/dist/core/resume/blueprint/resume.d.ts.map +1 -0
  199. package/dist/core/resume/blueprint/resume.js +206 -0
  200. package/dist/core/resume/blueprint/resume.js.map +1 -0
  201. package/dist/core/resume/blueprint/schema.d.ts +26 -0
  202. package/dist/core/resume/blueprint/schema.d.ts.map +1 -0
  203. package/dist/core/resume/blueprint/schema.js +243 -0
  204. package/dist/core/resume/blueprint/schema.js.map +1 -0
  205. package/dist/core/resume/blueprint/steps.d.ts +54 -0
  206. package/dist/core/resume/blueprint/steps.d.ts.map +1 -0
  207. package/dist/core/resume/blueprint/steps.js +155 -0
  208. package/dist/core/resume/blueprint/steps.js.map +1 -0
  209. package/dist/core/resume/blueprint/types.d.ts +63 -0
  210. package/dist/core/resume/blueprint/types.d.ts.map +1 -0
  211. package/dist/core/resume/blueprint/types.js +2 -0
  212. package/dist/core/resume/blueprint/types.js.map +1 -0
  213. package/dist/core/resume/errors.d.ts +7 -35
  214. package/dist/core/resume/errors.d.ts.map +1 -1
  215. package/dist/core/resume/errors.js +1 -21
  216. package/dist/core/resume/errors.js.map +1 -1
  217. package/dist/core/resume/index.d.ts +12 -4
  218. package/dist/core/resume/index.d.ts.map +1 -1
  219. package/dist/core/resume/index.js +11 -4
  220. package/dist/core/resume/index.js.map +1 -1
  221. package/dist/core/resume/run-setup.d.ts +36 -15
  222. package/dist/core/resume/run-setup.d.ts.map +1 -1
  223. package/dist/core/resume/run-setup.js +70 -54
  224. package/dist/core/resume/run-setup.js.map +1 -1
  225. package/dist/core/resume/session-resume.d.ts +34 -20
  226. package/dist/core/resume/session-resume.d.ts.map +1 -1
  227. package/dist/core/resume/session-resume.js +244 -106
  228. package/dist/core/resume/session-resume.js.map +1 -1
  229. package/dist/core/retry-policy.d.ts +19 -1
  230. package/dist/core/retry-policy.d.ts.map +1 -1
  231. package/dist/core/retry-policy.js +26 -1
  232. package/dist/core/retry-policy.js.map +1 -1
  233. package/dist/core/sdk.js +1 -1
  234. package/dist/core/sdk.js.map +1 -1
  235. package/dist/core/session-cwd.d.ts +56 -1
  236. package/dist/core/session-cwd.d.ts.map +1 -1
  237. package/dist/core/session-cwd.js +94 -4
  238. package/dist/core/session-cwd.js.map +1 -1
  239. package/dist/core/session-manager-core.d.ts +1 -1
  240. package/dist/core/session-manager-core.d.ts.map +1 -1
  241. package/dist/core/session-manager-core.js +10 -5
  242. package/dist/core/session-manager-core.js.map +1 -1
  243. package/dist/core/session-worktree-snapshots.d.ts +11 -0
  244. package/dist/core/session-worktree-snapshots.d.ts.map +1 -1
  245. package/dist/core/session-worktree-snapshots.js +10 -4
  246. package/dist/core/session-worktree-snapshots.js.map +1 -1
  247. package/dist/core/settings-defaults.d.ts +1 -1
  248. package/dist/core/settings-defaults.d.ts.map +1 -1
  249. package/dist/core/settings-defaults.js +1 -1
  250. package/dist/core/settings-defaults.js.map +1 -1
  251. package/dist/core/settings-manager-basic-accessors.d.ts +3 -2
  252. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  253. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  254. package/dist/core/settings-schema.d.ts.map +1 -1
  255. package/dist/core/settings-schema.js +2 -1
  256. package/dist/core/settings-schema.js.map +1 -1
  257. package/dist/core/slash-commands.d.ts.map +1 -1
  258. package/dist/core/slash-commands.js +4 -0
  259. package/dist/core/slash-commands.js.map +1 -1
  260. package/dist/core/storage/write-ahead-log.d.ts +2 -1
  261. package/dist/core/storage/write-ahead-log.d.ts.map +1 -1
  262. package/dist/core/storage/write-ahead-log.js +27 -6
  263. package/dist/core/storage/write-ahead-log.js.map +1 -1
  264. package/dist/core/system-prompt.d.ts.map +1 -1
  265. package/dist/core/system-prompt.js +10 -0
  266. package/dist/core/system-prompt.js.map +1 -1
  267. package/dist/core/tools/file-tool-errors.d.ts +1 -1
  268. package/dist/core/tools/file-tool-errors.js +1 -1
  269. package/dist/core/tools/file-tool-errors.js.map +1 -1
  270. package/dist/core/tools/find.d.ts.map +1 -1
  271. package/dist/core/tools/find.js +52 -26
  272. package/dist/core/tools/find.js.map +1 -1
  273. package/dist/core/tools/grep.d.ts +2 -0
  274. package/dist/core/tools/grep.d.ts.map +1 -1
  275. package/dist/core/tools/grep.js.map +1 -1
  276. package/dist/core/tools/powershell.d.ts.map +1 -1
  277. package/dist/core/tools/powershell.js +10 -2
  278. package/dist/core/tools/powershell.js.map +1 -1
  279. package/dist/core/tools/tool-concurrency.d.ts.map +1 -1
  280. package/dist/core/tools/tool-concurrency.js +2 -2
  281. package/dist/core/tools/tool-concurrency.js.map +1 -1
  282. package/dist/index.d.ts +3 -2
  283. package/dist/index.d.ts.map +1 -1
  284. package/dist/index.js +2 -1
  285. package/dist/index.js.map +1 -1
  286. package/dist/main-session.d.ts +12 -4
  287. package/dist/main-session.d.ts.map +1 -1
  288. package/dist/main-session.js +28 -4
  289. package/dist/main-session.js.map +1 -1
  290. package/dist/main.d.ts.map +1 -1
  291. package/dist/main.js +6 -8
  292. package/dist/main.js.map +1 -1
  293. package/dist/modes/interactive/components/chat-session-host.d.ts +5 -1
  294. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  295. package/dist/modes/interactive/components/chat-session-host.js +6 -1
  296. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  297. package/dist/modes/interactive/components/oauth-selector.d.ts +10 -3
  298. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  299. package/dist/modes/interactive/components/oauth-selector.js +34 -13
  300. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  301. package/dist/modes/interactive/components/provider-brand.d.ts +16 -0
  302. package/dist/modes/interactive/components/provider-brand.d.ts.map +1 -0
  303. package/dist/modes/interactive/components/provider-brand.js +67 -0
  304. package/dist/modes/interactive/components/provider-brand.js.map +1 -0
  305. package/dist/modes/interactive/interactive-auth-routing.d.ts.map +1 -1
  306. package/dist/modes/interactive/interactive-auth-routing.js +8 -6
  307. package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
  308. package/dist/modes/interactive/interactive-extension-dialogs.js +4 -3
  309. package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
  310. package/dist/modes/interactive/interactive-extension-runtime.js +8 -3
  311. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  312. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
  313. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  314. package/dist/modes/interactive/interactive-mode-deps.js +1 -1
  315. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  316. package/dist/modes/interactive/interactive-mode-surface.d.ts +12 -2
  317. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  318. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  319. package/dist/modes/interactive/interactive-session-routing.js +59 -21
  320. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  321. package/dist/modes/interactive/interactive-slash-commands.js +23 -12
  322. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  323. package/dist/modes/interactive/login-provider-options.d.ts.map +1 -1
  324. package/dist/modes/interactive/login-provider-options.js +2 -1
  325. package/dist/modes/interactive/login-provider-options.js.map +1 -1
  326. package/dist/modes/interactive-engine/isolated-runtime.d.ts +2 -0
  327. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  328. package/dist/modes/interactive-engine/isolated-runtime.js +8 -3
  329. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  330. package/dist/modes/rpc/rpc-client-api.d.ts +2 -1
  331. package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
  332. package/dist/modes/rpc/rpc-client-api.js.map +1 -1
  333. package/dist/modes/rpc/rpc-client.d.ts +0 -1
  334. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  335. package/dist/modes/rpc/rpc-client.js +2 -18
  336. package/dist/modes/rpc/rpc-client.js.map +1 -1
  337. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  338. package/dist/modes/rpc/rpc-command-handler.js +8 -2
  339. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  340. package/dist/modes/rpc/rpc-error-decoding.d.ts +7 -0
  341. package/dist/modes/rpc/rpc-error-decoding.d.ts.map +1 -0
  342. package/dist/modes/rpc/rpc-error-decoding.js +25 -0
  343. package/dist/modes/rpc/rpc-error-decoding.js.map +1 -0
  344. package/dist/modes/rpc/rpc-responses.d.ts.map +1 -1
  345. package/dist/modes/rpc/rpc-responses.js +12 -0
  346. package/dist/modes/rpc/rpc-responses.js.map +1 -1
  347. package/dist/modes/rpc/rpc-types.d.ts +11 -0
  348. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  349. package/dist/modes/rpc/rpc-types.js.map +1 -1
  350. package/dist/package-manager-cli.d.ts.map +1 -1
  351. package/dist/package-manager-cli.js +12 -3
  352. package/dist/package-manager-cli.js.map +1 -1
  353. package/docs/background-tasks.md +1 -1
  354. package/docs/codemode.md +22 -0
  355. package/docs/extensions/api-reference.md +27 -1
  356. package/docs/extensions/authoring.md +1 -1
  357. package/docs/extensions/ui.md +1 -1
  358. package/docs/getting-started/first-session.md +1 -1
  359. package/docs/guides/resume-on-any-machine.md +72 -19
  360. package/docs/models/evals.md +85 -17
  361. package/docs/models/reference.md +1 -1
  362. package/docs/providers.md +38 -5
  363. package/docs/reference/cli.md +2 -0
  364. package/docs/rpc/protocol.md +11 -1
  365. package/docs/sdk/reference.md +36 -4
  366. package/docs/sdk.md +2 -2
  367. package/docs/sessions.md +11 -1
  368. package/docs/settings.md +7 -2
  369. package/docs/skills.md +3 -3
  370. package/docs/storage.md +1 -1
  371. package/docs/tools.md +3 -1
  372. package/docs/workflows/api-reference.md +14 -12
  373. package/docs/workflows/authoring.md +29 -1
  374. package/docs/workflows/builtins.md +9 -1
  375. package/docs/workflows/operations.md +8 -8
  376. package/docs/worktree-snapshots.md +3 -2
  377. package/npm-shrinkwrap.json +83 -67
  378. package/package.json +7 -7
  379. package/schemas/settings.schema.json +3 -2
  380. package/dist/core/resume/setup-hook.d.ts +0 -69
  381. package/dist/core/resume/setup-hook.d.ts.map +0 -1
  382. package/dist/core/resume/setup-hook.js +0 -261
  383. package/dist/core/resume/setup-hook.js.map +0 -1
@@ -2343,7 +2343,7 @@ function projectRoot(rootRunId, runs, runById, ownership) {
2343
2343
  for (const stage of run.stages) {
2344
2344
  if (run.status === "running" && stage.status === "paused")
2345
2345
  paused = true;
2346
- if (live && run.status === "running" && !runStopping && stage.status === "waiting")
2346
+ if (live && run.status === "running" && !runStopping && stage.status === "suspended")
2347
2347
  waitingStages++;
2348
2348
  if (stage.status === "awaiting_input" || stage.pendingPrompt) {
2349
2349
  if (acceptsAttention && stage.status !== "paused") {
@@ -3357,7 +3357,7 @@ var init_pending_stage_status = __esm(() => {
3357
3357
  "awaiting_input",
3358
3358
  "paused",
3359
3359
  "blocked",
3360
- "waiting"
3360
+ "suspended"
3361
3361
  ]);
3362
3362
  });
3363
3363
 
@@ -4302,7 +4302,7 @@ function createStageControlRegistry() {
4302
4302
  if (!runMap)
4303
4303
  return [];
4304
4304
  const controlEntries = controlledEntries(runId);
4305
- const targets = stageId ? [runMap.get(stageId)].filter((entry) => entry?.controlsDependencies === true).map((entry) => entry.handle) : controlEntries.map((entry) => entry.handle).filter((h) => h.status === "running" || h.status === "pending" || h.status === "waiting");
4305
+ const targets = stageId ? [runMap.get(stageId)].filter((entry) => entry?.controlsDependencies === true).map((entry) => entry.handle) : controlEntries.map((entry) => entry.handle).filter((h) => h.status === "running" || h.status === "pending" || h.status === "suspended");
4306
4306
  const before = new Map(controlEntries.map((entry) => [entry.handle.stageId, entry.handle.status]));
4307
4307
  for (const handle of targets) {
4308
4308
  if (handle.status === "paused")
@@ -6098,7 +6098,7 @@ function createStageStoreMethods(context) {
6098
6098
  }
6099
6099
  if (stage.status === "running" && context.observation.liveRunIds.has(runId)) {
6100
6100
  context.observation.executingStageIds.add(workflowActivityNodeKey(runId, stage.id));
6101
- } else if (stage.status === "waiting") {
6101
+ } else if (stage.status === "suspended") {
6102
6102
  context.observation.executingStageIds.delete(workflowActivityNodeKey(runId, stage.id));
6103
6103
  }
6104
6104
  context.bumpAndNotify({ runId, stageId: stage.id });
@@ -6424,7 +6424,7 @@ function createStageStoreMethods(context) {
6424
6424
  const resumedTs = nextControlTimestamp(resumedAt, stage.pausedAt);
6425
6425
  if (context.observation.liveRunIds.has(runId) && stage.wait === undefined)
6426
6426
  context.observation.executingStageIds.add(workflowActivityNodeKey(runId, stageId));
6427
- stage.status = stage.wait === undefined ? "running" : "waiting";
6427
+ stage.status = stage.wait === undefined ? "running" : "suspended";
6428
6428
  if (stage.startedAt !== undefined) {
6429
6429
  stage.pausedDurationMs = accumulatePausedDurationMs(stage.pausedDurationMs, stage.pausedAt, resumedTs);
6430
6430
  }
@@ -8063,6 +8063,17 @@ var init_backend = __esm(() => {
8063
8063
  SESSION_HEADER_READ_LIMIT_BYTES = 64 * 1024;
8064
8064
  });
8065
8065
 
8066
+ // dist/builtin/workflows/src/shared/legacy-waiting-status.ts
8067
+ function isLegacyWaiting(status) {
8068
+ return status === "waiting";
8069
+ }
8070
+ function stageStatusFromRecord(status) {
8071
+ return status === "waiting" ? "suspended" : status;
8072
+ }
8073
+ function runSnapshotsFromRecord(runs) {
8074
+ return runs.map((run) => run.stages.some((stage) => isLegacyWaiting(stage.status)) ? { ...run, stages: run.stages.map((stage) => ({ ...stage, status: stageStatusFromRecord(stage.status) })) } : run);
8075
+ }
8076
+
8066
8077
  // dist/builtin/workflows/src/shared/session-transcript.ts
8067
8078
  async function isReopenableSession(store, sessionId) {
8068
8079
  try {
@@ -8956,6 +8967,9 @@ function validateText(field, value2) {
8956
8967
  if (/\p{Surrogate}/u.test(value2))
8957
8968
  throw new JournalInvalidTextError(field, "ill-formed-unicode");
8958
8969
  }
8970
+ function runStatusFromRecord(status) {
8971
+ return status === "waiting" ? "suspended" : status;
8972
+ }
8959
8973
  function serializeJson(value2) {
8960
8974
  const text = JSON.stringify(value2);
8961
8975
  return text.replace(/\p{Surrogate}/gu, (unit) => `\\u${unit.charCodeAt(0).toString(16).padStart(4, "0")}`);
@@ -10259,7 +10273,7 @@ function registerRunJournalConformance(runner, name, open, observeRead) {
10259
10273
  const context = (action) => action();
10260
10274
  const results = await journal.appendMany(held, [
10261
10275
  { event: { type: "RunStarted", payload: null }, key: "start", context },
10262
- { event: { type: "StatusChanged", payload: { status: "waiting" } }, context },
10276
+ { event: { type: "StatusChanged", payload: { status: "suspended" } }, context },
10263
10277
  { event: { type: "RunFinished", payload: null }, key: "start", context }
10264
10278
  ]);
10265
10279
  assert.deepEqual(results.map((result) => result.status === "fulfilled" ? [result.value.status, result.value.entry.seq] : []), [
@@ -10268,7 +10282,7 @@ function registerRunJournalConformance(runner, name, open, observeRead) {
10268
10282
  ["exists", 1]
10269
10283
  ]);
10270
10284
  assert.deepEqual((await entries(journal)).map((entry) => entry.event.type), ["RunStarted", "StatusChanged"]);
10271
- assert.equal((await journal.getRun(header.runId))?.status, "waiting");
10285
+ assert.equal((await journal.getRun(header.runId))?.status, "suspended");
10272
10286
  assert.equal((await journal.takeover(header.runId, "next", held.holderId)).status, "acquired");
10273
10287
  await assert.rejects(journal.appendMany(held, [{ event: { type: "RunFinished", payload: null }, context }]), StaleLeaseError);
10274
10288
  assert.equal((await entries(journal)).length, 2);
@@ -10282,14 +10296,14 @@ function registerRunJournalConformance(runner, name, open, observeRead) {
10282
10296
  const results = await journal.appendMany(held, [
10283
10297
  { event: { type: "RunStarted", payload: null }, context },
10284
10298
  { event: { type: "StatusChanged", payload: { status: "bad\x00status" } }, context },
10285
- { event: { type: "StatusChanged", payload: { status: "waiting" } }, context }
10299
+ { event: { type: "StatusChanged", payload: { status: "suspended" } }, context }
10286
10300
  ]);
10287
10301
  assert.deepEqual(results.map((result) => result.status), ["fulfilled", "rejected", "fulfilled"]);
10288
- const [started, invalid, waiting] = results;
10302
+ const [started, invalid, suspended] = results;
10289
10303
  assert.ok(invalid?.status === "rejected" && invalid.reason instanceof JournalInvalidTextError);
10290
- assert.deepEqual([started, waiting].map((result) => result?.status === "fulfilled" ? result.value.entry.seq : undefined), [1, 2]);
10304
+ assert.deepEqual([started, suspended].map((result) => result?.status === "fulfilled" ? result.value.entry.seq : undefined), [1, 2]);
10291
10305
  assert.deepEqual((await entries(journal)).map((entry) => entry.event.type), ["RunStarted", "StatusChanged"]);
10292
- assert.equal((await journal.getRun(header.runId))?.status, "waiting");
10306
+ assert.equal((await journal.getRun(header.runId))?.status, "suspended");
10293
10307
  });
10294
10308
  check("optional createRunWithEvents creates a run with its events atomically, or nothing", async (journal) => {
10295
10309
  const createRunWithEvents = journal.createRunWithEvents;
@@ -10500,13 +10514,17 @@ class MemoryRunJournal {
10500
10514
  this.ensureOpen();
10501
10515
  validateText("runId", runId);
10502
10516
  const run = this.runs.get(runId);
10503
- return run ? JSON.parse(serializeJson(run.header)) : undefined;
10517
+ return run ? this.summaryOf(run) : undefined;
10504
10518
  }
10505
10519
  async listRuns(filter) {
10506
10520
  this.ensureOpen();
10507
10521
  if (filter?.cwd !== undefined)
10508
10522
  validateText("cwd", filter.cwd);
10509
- return [...this.runs.values()].filter((run) => filter?.cwd === undefined || run.header.cwd === filter.cwd).sort((a, b) => Buffer.compare(Buffer.from(a.header.runId), Buffer.from(b.header.runId))).map((run) => JSON.parse(serializeJson(run.header)));
10523
+ return [...this.runs.values()].filter((run) => filter?.cwd === undefined || run.header.cwd === filter.cwd).sort((a, b) => Buffer.compare(Buffer.from(a.header.runId), Buffer.from(b.header.runId))).map((run) => this.summaryOf(run));
10524
+ }
10525
+ summaryOf(run) {
10526
+ const summary = JSON.parse(serializeJson(run.header));
10527
+ return { ...summary, status: runStatusFromRecord(summary.status) };
10510
10528
  }
10511
10529
  requireRun(runId) {
10512
10530
  this.ensureOpen();
@@ -11015,7 +11033,7 @@ class SqlRunJournal {
11015
11033
  return this.operation(async () => {
11016
11034
  const row = await this.database.get(`SELECT ${JOURNAL_COLUMNS.headerJson}, ${JOURNAL_COLUMNS.status} FROM ${this.tables.runs} WHERE ${JOURNAL_COLUMNS.runId} = ?`, runId);
11017
11035
  const found = row ?? await this.legacy?.find(this.database, runId);
11018
- return found ? { ...JSON.parse(found[JOURNAL_COLUMNS.headerJson]), status: found[JOURNAL_COLUMNS.status] } : undefined;
11036
+ return found ? { ...JSON.parse(found[JOURNAL_COLUMNS.headerJson]), status: runStatusFromRecord(found[JOURNAL_COLUMNS.status]) } : undefined;
11019
11037
  });
11020
11038
  }
11021
11039
  async listRuns(filter) {
@@ -11025,7 +11043,10 @@ class SqlRunJournal {
11025
11043
  return this.operation(async () => {
11026
11044
  const rows = await this.database.all(`SELECT ${JOURNAL_COLUMNS.headerJson}, ${JOURNAL_COLUMNS.status} FROM ${this.tables.runs} ${filter?.cwd === undefined ? "" : `WHERE ${JOURNAL_COLUMNS.cwd} = ?`} ORDER BY ${JOURNAL_COLUMNS.runId}`, ...filter?.cwd === undefined ? [] : [filter.cwd]);
11027
11045
  const legacy = await this.legacy?.pending(this.database, filter) ?? [];
11028
- return [...rows, ...legacy].map((row) => ({ ...JSON.parse(row[JOURNAL_COLUMNS.headerJson]), status: row[JOURNAL_COLUMNS.status] })).sort((left, right) => left.runId < right.runId ? -1 : left.runId > right.runId ? 1 : 0);
11046
+ return [...rows, ...legacy].map((row) => ({
11047
+ ...JSON.parse(row[JOURNAL_COLUMNS.headerJson]),
11048
+ status: runStatusFromRecord(row[JOURNAL_COLUMNS.status])
11049
+ })).sort((left, right) => left.runId < right.runId ? -1 : left.runId > right.runId ? 1 : 0);
11029
11050
  });
11030
11051
  }
11031
11052
  async changeToken() {
@@ -16134,7 +16155,12 @@ var init_run_resume_preflight = __esm(() => {
16134
16155
  // dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts
16135
16156
  import {
16136
16157
  bindSessionWorkspace,
16158
+ currentWorktreeRootMappings,
16159
+ getAgentDir as getAgentDir3,
16160
+ mapRestoredPath,
16161
+ recordRestoredWorktreeContext,
16137
16162
  resolveWorkspace,
16163
+ resumeStoreDir,
16138
16164
  SessionManager as SessionManager2,
16139
16165
  workspaceSessionCwd
16140
16166
  } from "@bastani/atomic";
@@ -16215,6 +16241,13 @@ async function stripWorkflowOnlyOptions2(options, defaultSessionDir, meta, pendi
16215
16241
  sessionOptions.sessionManager = await SessionManager2.create(cwd, sessionDir ?? defaultSessionDir, classification);
16216
16242
  }
16217
16243
  }
16244
+ const manager = sessionOptions.sessionManager;
16245
+ if (manager !== undefined) {
16246
+ const mappings = [...manager.getWorktreeRootMappings(), ...currentWorktreeRootMappings()];
16247
+ const notKept = await recordRestoredWorktreeContext(manager, resumeStoreDir(sessionOptions.agentDir ?? getAgentDir3()), mapRestoredPath(cwd, mappings));
16248
+ if (notKept !== undefined)
16249
+ console.warn(`atomic-workflows: ${notKept.message}`);
16250
+ }
16218
16251
  return {
16219
16252
  ...sessionOptions,
16220
16253
  ...fallbackModels?.length === 0 ? { fallbackModels: [] } : {},
@@ -19635,7 +19668,7 @@ var init_journal_backend = __esm(() => {
19635
19668
  });
19636
19669
 
19637
19670
  // dist/builtin/workflows/src/durable/factory.ts
19638
- import { getAgentDir as getAgentDir3, SettingsManager } from "@bastani/atomic";
19671
+ import { getAgentDir as getAgentDir4, SettingsManager } from "@bastani/atomic";
19639
19672
  import { storageSelectionKey } from "@bastani/atomic/storage";
19640
19673
  function abandonOpening(selected, key, entry) {
19641
19674
  if (selected.get(key) === entry)
@@ -19654,7 +19687,7 @@ function abandonOpening(selected, key, entry) {
19654
19687
  async function initializeDurableBackend(options = {}) {
19655
19688
  const owner = getDurableBackendProcessOwner();
19656
19689
  const choice = options.journal;
19657
- const agentDir = options.agentDir ?? getAgentDir3();
19690
+ const agentDir = options.agentDir ?? getAgentDir4();
19658
19691
  const selection = selectRunJournal({
19659
19692
  agentDir,
19660
19693
  journal: choice,
@@ -19725,7 +19758,7 @@ async function runRestorePreconditionFailure(journal, runId, mappings, settings,
19725
19758
  for (const boundary of workflowSnapshotFrontier(await listWorkflowSnapshotBoundaries(journal, runId))) {
19726
19759
  const here = mapWorkflowWorktreePath(boundary.root, mappings);
19727
19760
  if (await worktreeNeedsRestore(boundary.snapshot, here, { settings, signal })) {
19728
- restoring.push({ root: boundary.root, envHash: boundary.snapshot.envHash });
19761
+ restoring.push({ root: boundary.root, remotes: boundary.snapshot.remotes });
19729
19762
  }
19730
19763
  }
19731
19764
  return await runRestorePreconditionError(runId, restoring);
@@ -20069,12 +20102,12 @@ import { randomUUID as randomUUID7 } from "node:crypto";
20069
20102
  import { existsSync as existsSync3 } from "node:fs";
20070
20103
  import { mkdir, readdir, rm, stat } from "node:fs/promises";
20071
20104
  import { dirname as dirname4, join as join6 } from "node:path";
20072
- import { getAgentDir as getAgentDir4, getEnvValue } from "@bastani/atomic";
20105
+ import { getAgentDir as getAgentDir5, getEnvValue } from "@bastani/atomic";
20073
20106
  function workflowArtifactRoot() {
20074
20107
  const override = getEnvValue(ENV_WORKFLOW_ARTIFACT_DIR);
20075
20108
  if (override !== undefined && override.length > 0)
20076
20109
  return override;
20077
- return join6(dirname4(getAgentDir4()), "workflows");
20110
+ return join6(dirname4(getAgentDir5()), "workflows");
20078
20111
  }
20079
20112
  function workflowArtifactRunsRoot() {
20080
20113
  return join6(workflowArtifactRoot(), "runs");
@@ -23270,6 +23303,7 @@ var init_structured_output_errors = __esm(() => {
23270
23303
  import {
23271
23304
  AgentRehydrateError,
23272
23305
  BackgroundCompactionError,
23306
+ BlueprintError,
23273
23307
  DebugError,
23274
23308
  DecisionError,
23275
23309
  deserializeGitHubCopilotError,
@@ -23281,17 +23315,21 @@ import {
23281
23315
  IntercomBrokerError,
23282
23316
  isGitProvisionError as isGitProvisionError3,
23283
23317
  isSerializedBackgroundCompactionError,
23318
+ isSerializedMissingSessionCwdError,
23284
23319
  LlamaServerError,
23320
+ MissingSessionCwdError,
23285
23321
  parseSerializedDecisionError,
23286
23322
  ResumeError,
23287
23323
  rehydrateAgentRehydrateError,
23288
23324
  rehydrateBackgroundCompactionError,
23325
+ rehydrateBlueprintError,
23289
23326
  rehydrateDebugError,
23290
23327
  rehydrateDecisionError,
23291
23328
  rehydrateEditToolError,
23292
23329
  rehydrateGitProvisionError as rehydrateGitProvisionError2,
23293
23330
  rehydrateIntercomBrokerError,
23294
23331
  rehydrateLlamaServerError,
23332
+ rehydrateMissingSessionCwdError,
23295
23333
  rehydrateResumeError,
23296
23334
  rehydrateSessionStartError,
23297
23335
  rehydrateShellToolError,
@@ -23307,11 +23345,13 @@ import {
23307
23345
  SubscriptionError,
23308
23346
  serializeAgentRehydrateError,
23309
23347
  serializeBackgroundCompactionError,
23348
+ serializeBlueprintError,
23310
23349
  serializeDebugError,
23311
23350
  serializeDecisionError,
23312
23351
  serializeFileToolError,
23313
23352
  serializeGitHubCopilotError,
23314
23353
  serializeIntercomBrokerError,
23354
+ serializeMissingSessionCwdError,
23315
23355
  serializeResumeError,
23316
23356
  serializeSessionStartError,
23317
23357
  serializeSubscriptionError,
@@ -23489,6 +23529,22 @@ var init_serializable_error_families = __esm(() => {
23489
23529
  },
23490
23530
  rehydrate: rehydrateResumeError
23491
23531
  }),
23532
+ "missing-session-cwd": family({
23533
+ is: instanceOf(MissingSessionCwdError),
23534
+ serialize: (error) => {
23535
+ const { cause: _cause, ...form } = serializeMissingSessionCwdError(error);
23536
+ return form;
23537
+ },
23538
+ rehydrate: (form, cause) => isSerializedMissingSessionCwdError(form) ? rehydrateMissingSessionCwdError(form, cause) : undefined
23539
+ }),
23540
+ blueprint: family({
23541
+ is: instanceOf(BlueprintError),
23542
+ serialize: (error) => {
23543
+ const { cause: _cause, ...form } = serializeBlueprintError(error);
23544
+ return form;
23545
+ },
23546
+ rehydrate: rehydrateBlueprintError
23547
+ }),
23492
23548
  "structured-output": family({
23493
23549
  is: instanceOf(WorkflowStructuredOutputInferenceError),
23494
23550
  serialize: (error) => error.toJSON(),
@@ -69989,12 +70045,260 @@ var init_loop_until_done = __esm(() => {
69989
70045
  });
69990
70046
  });
69991
70047
 
70048
+ // dist/builtin/workflows/builtin/open-claude-design-images.ts
70049
+ import { existsSync as existsSync8 } from "node:fs";
70050
+ import { mkdir as mkdir4, readFile as readFile5, writeFile as writeFile8 } from "node:fs/promises";
70051
+ import { dirname as dirname13, join as join25 } from "node:path";
70052
+ import { AuthStorage } from "@bastani/atomic";
70053
+ import { builtinModels } from "@bastani/pi-ai/providers/all";
70054
+ import { Type as Type18 } from "typebox";
70055
+ function parseGptImageId(id) {
70056
+ const groups = GPT_IMAGE_ID.exec(id)?.groups;
70057
+ if (groups?.version === undefined)
70058
+ return;
70059
+ return { version: groups.version.split(".").map(Number), variant: groups.variant };
70060
+ }
70061
+ function compareVersions(left, right) {
70062
+ const differences = Array.from({ length: Math.max(left.length, right.length) }, (_, index) => (left[index] ?? 0) - (right[index] ?? 0));
70063
+ return differences.find((difference) => difference !== 0) ?? 0;
70064
+ }
70065
+ function variantRank(variant) {
70066
+ if (variant === undefined)
70067
+ return 0;
70068
+ if (LOWER_TIER_VARIANTS.has(variant))
70069
+ return -1;
70070
+ const preferred = PREFERRED_VARIANTS.indexOf(variant);
70071
+ return preferred === -1 ? 1 : PREFERRED_VARIANTS.length - preferred + 1;
70072
+ }
70073
+ function compareText(left, right) {
70074
+ return left.localeCompare(right, "en");
70075
+ }
70076
+ function fallbackProviderRank(model) {
70077
+ return model.provider === PREFERRED_FALLBACK_PROVIDER ? 0 : 1;
70078
+ }
70079
+ function compareImageModels(left, right) {
70080
+ const leftGpt = parseGptImageId(left.id);
70081
+ const rightGpt = parseGptImageId(right.id);
70082
+ if (leftGpt !== undefined && rightGpt !== undefined) {
70083
+ return compareVersions(rightGpt.version, leftGpt.version) || variantRank(rightGpt.variant) - variantRank(leftGpt.variant) || compareText(left.provider, right.provider) || compareText(left.id, right.id);
70084
+ }
70085
+ if (leftGpt !== undefined)
70086
+ return -1;
70087
+ if (rightGpt !== undefined)
70088
+ return 1;
70089
+ return fallbackProviderRank(left) - fallbackProviderRank(right) || compareText(left.provider, right.provider) || compareText(right.id, left.id);
70090
+ }
70091
+ function selectReferenceImageModel(available, override) {
70092
+ const requested = override?.trim() ?? "";
70093
+ if (requested.length > 0)
70094
+ return available.find((model) => `${model.provider}/${model.id}` === requested);
70095
+ return [...available].sort(compareImageModels)[0];
70096
+ }
70097
+ function excerpt(label, text, limit) {
70098
+ const trimmed = text?.trim() ?? "";
70099
+ if (trimmed.length === 0)
70100
+ return;
70101
+ return `${label}:
70102
+ ${trimmed.slice(0, limit).trimEnd()}`;
70103
+ }
70104
+ function buildReferenceImagePrompt(context, direction) {
70105
+ return [
70106
+ `A finished ${SURFACE_BY_OUTPUT_TYPE[context.outputType]} for: ${context.brief.trim()}`,
70107
+ "Render the surface edge to edge with crisp, readable text and real, brief-specific content. No browser window, device, desk or poster framing, and no lorem ipsum.",
70108
+ `Direction: ${direction.composition}`,
70109
+ excerpt("Curated references (inspiration to adapt into this product; do not copy their layout or content)", context.curatedReferences, REFERENCES_EXCERPT_CHARS),
70110
+ excerpt("Design system (DESIGN.md)", context.designContext, DESIGN_EXCERPT_CHARS),
70111
+ excerpt("Product context (PRODUCT.md)", context.productContext, PRODUCT_EXCERPT_CHARS),
70112
+ "Keep the palette, typography and component character the context describes; the direction changes only composition and emphasis."
70113
+ ].filter((section) => section !== undefined).join(`
70114
+
70115
+ `);
70116
+ }
70117
+ async function readOptionalText(path) {
70118
+ try {
70119
+ return await readFile5(path, "utf8");
70120
+ } catch (error) {
70121
+ const code = error.code;
70122
+ if (code === "ENOENT" || code === "ENOTDIR")
70123
+ return;
70124
+ throw error;
70125
+ }
70126
+ }
70127
+ function firstWritableImage(output) {
70128
+ for (const block of output) {
70129
+ if (block.type !== "image" || block.data.length === 0)
70130
+ continue;
70131
+ const extension = IMAGE_EXTENSIONS.get(block.mimeType);
70132
+ if (extension !== undefined)
70133
+ return { data: block.data, extension };
70134
+ }
70135
+ return;
70136
+ }
70137
+ async function renderDirection(input) {
70138
+ const { provider, model, prompt, outputBase, signal } = input;
70139
+ let result;
70140
+ try {
70141
+ result = await provider.generateImages(model, { input: [{ type: "text", text: prompt }] }, {
70142
+ signal,
70143
+ quality: "high",
70144
+ size: IMAGE_SIZE,
70145
+ n: 1,
70146
+ timeoutMs: IMAGE_REQUEST_TIMEOUT_MS,
70147
+ maxRetries: IMAGE_REQUEST_MAX_RETRIES
70148
+ });
70149
+ } catch {
70150
+ signal.throwIfAborted();
70151
+ return { failure: { reason: "unexpected-error" } };
70152
+ }
70153
+ signal.throwIfAborted();
70154
+ if (result.stopReason !== "stop") {
70155
+ return {
70156
+ failure: {
70157
+ reason: result.error?.code ?? "unclassified",
70158
+ ...result.error === undefined ? {} : { retryable: result.error.retryable }
70159
+ }
70160
+ };
70161
+ }
70162
+ const image = firstWritableImage(result.output);
70163
+ if (image === undefined)
70164
+ return {};
70165
+ const path = `${outputBase}.${image.extension}`;
70166
+ try {
70167
+ await mkdir4(dirname13(path), { recursive: true });
70168
+ await writeFile8(path, Buffer.from(image.data, "base64"));
70169
+ } catch {
70170
+ return { failure: { reason: "write-failed" } };
70171
+ }
70172
+ return { path };
70173
+ }
70174
+ async function loadPromptContext(request) {
70175
+ const [productContext, designContext] = await Promise.all([
70176
+ readOptionalText(join25(request.workflowCwd, "PRODUCT.md")),
70177
+ readOptionalText(join25(request.workflowCwd, "DESIGN.md"))
70178
+ ]);
70179
+ return {
70180
+ brief: request.brief,
70181
+ outputType: request.outputType,
70182
+ curatedReferences: request.curatedReferences,
70183
+ productContext,
70184
+ designContext
70185
+ };
70186
+ }
70187
+ function directionOutputBase(artifactDir, index, direction) {
70188
+ return join25(artifactDir, REFERENCE_IMAGES_DIRNAME, `${String(index + 1).padStart(2, "0")}-${direction.slug}`);
70189
+ }
70190
+ async function renderReferenceImages(request, provider, model, signal) {
70191
+ const promptContext = await loadPromptContext(request);
70192
+ const outcomes = await Promise.all(REFERENCE_IMAGE_DIRECTIONS.map((direction, index) => renderDirection({
70193
+ provider,
70194
+ model,
70195
+ prompt: buildReferenceImagePrompt(promptContext, direction),
70196
+ outputBase: directionOutputBase(request.artifactDir, index, direction),
70197
+ signal
70198
+ })));
70199
+ const modelId = `${model.provider}/${model.id}`;
70200
+ const paths = outcomes.flatMap(({ path }) => path === undefined ? [] : [path]);
70201
+ if (paths.length > 0)
70202
+ return { status: "generated", model: modelId, paths };
70203
+ const failure = outcomes.find((outcome) => outcome.failure !== undefined)?.failure;
70204
+ return {
70205
+ status: "failed",
70206
+ reason: failure?.reason ?? "no-images-written",
70207
+ model: modelId,
70208
+ paths: [],
70209
+ ...failure?.retryable === undefined ? {} : { retryable: failure.retryable }
70210
+ };
70211
+ }
70212
+ function skipped(reason) {
70213
+ return { status: "skipped", reason, paths: [] };
70214
+ }
70215
+ async function generateReferenceImages(request, createProvider, signal) {
70216
+ try {
70217
+ const provider = await createProvider();
70218
+ const available = await provider.availableImageModels(signal);
70219
+ if (available.length === 0)
70220
+ return skipped("no-image-model");
70221
+ const model = selectReferenceImageModel(available, request.imageModel);
70222
+ if (model === undefined)
70223
+ return skipped("image-model-unavailable");
70224
+ return await renderReferenceImages(request, provider, model, signal);
70225
+ } catch {
70226
+ signal.throwIfAborted();
70227
+ return { status: "failed", reason: "unexpected-error", paths: [] };
70228
+ }
70229
+ }
70230
+ async function createBuiltinReferenceImageProvider(credentials = AuthStorage.create()) {
70231
+ const models = builtinModels({ credentials });
70232
+ return {
70233
+ availableImageModels: (signal) => models.getAvailableOfType("image", undefined, { signal }),
70234
+ generateImages: (model, context, options) => models.generateImages(model, context, options)
70235
+ };
70236
+ }
70237
+ async function runReferenceImagesStep(tool, request, deps = {}) {
70238
+ const createProvider = deps.createImageProvider ?? createBuiltinReferenceImageProvider;
70239
+ const outcome = await tool("reference-images", {
70240
+ brief: request.brief,
70241
+ outputType: request.outputType,
70242
+ artifactDir: request.artifactDir,
70243
+ ...request.imageModel === undefined ? {} : { imageModel: request.imageModel }
70244
+ }, ({ signal }) => generateReferenceImages(request, createProvider, signal), { timeoutMs: REFERENCE_IMAGES_TOOL_TIMEOUT_MS, failureMode: "return" });
70245
+ return outcome.ok ? outcome.value : { status: "failed", reason: "tool-failed", paths: [] };
70246
+ }
70247
+ function existingReferenceImagePaths(status) {
70248
+ return status.status === "generated" ? status.paths.filter((path) => existsSync8(path)) : [];
70249
+ }
70250
+ var referenceImagesStatusSchema, REFERENCE_IMAGES_DIRNAME = "references", REFERENCE_IMAGES_TOOL_TIMEOUT_MS, IMAGE_REQUEST_TIMEOUT_MS, IMAGE_REQUEST_MAX_RETRIES = 1, IMAGE_SIZE = "1536x1024", PRODUCT_EXCERPT_CHARS = 1000, DESIGN_EXCERPT_CHARS = 1500, REFERENCES_EXCERPT_CHARS = 1500, REFERENCE_IMAGE_DIRECTIONS, SURFACE_BY_OUTPUT_TYPE, GPT_IMAGE_ID, PREFERRED_VARIANTS, LOWER_TIER_VARIANTS, PREFERRED_FALLBACK_PROVIDER = "openrouter", IMAGE_EXTENSIONS;
70251
+ var init_open_claude_design_images = __esm(() => {
70252
+ referenceImagesStatusSchema = Type18.Object({
70253
+ status: Type18.Union([Type18.Literal("skipped"), Type18.Literal("generated"), Type18.Literal("failed")]),
70254
+ reason: Type18.Optional(Type18.String()),
70255
+ model: Type18.Optional(Type18.String()),
70256
+ paths: Type18.Array(Type18.String()),
70257
+ retryable: Type18.Optional(Type18.Boolean())
70258
+ }, {
70259
+ additionalProperties: false,
70260
+ description: "Outcome of the reference image step: status (skipped, generated, or failed), the reason, the model used, the image paths under <artifact_dir>/references/, and whether a failure is retryable."
70261
+ });
70262
+ REFERENCE_IMAGES_TOOL_TIMEOUT_MS = 15 * 60000;
70263
+ IMAGE_REQUEST_TIMEOUT_MS = 5 * 60000;
70264
+ REFERENCE_IMAGE_DIRECTIONS = [
70265
+ {
70266
+ slug: "reference-led",
70267
+ composition: "Reference-led. Stay closest to the curated references and the project's design system: lead with the composition the strongest reference uses and show the product concept it implies."
70268
+ },
70269
+ {
70270
+ slug: "brand-forward",
70271
+ composition: "Brand-forward. One dominant, memorable focal move at large scale carries the brand; generous space, and every other region holds still at real reading size."
70272
+ },
70273
+ {
70274
+ slug: "information-dense",
70275
+ composition: "Information-dense. Summary-led, with a compact structured grid and a tight hierarchy that shows more real content at real reading size."
70276
+ }
70277
+ ];
70278
+ SURFACE_BY_OUTPUT_TYPE = {
70279
+ prototype: "desktop web app screen",
70280
+ wireframe: "high-fidelity desktop screen",
70281
+ page: "desktop web page",
70282
+ component: "desktop screen showing the component in two or three representative contexts",
70283
+ theme: "representative product screen showing the theme applied across navigation, type, color and components",
70284
+ tokens: "style-guide screen showing the color, type and spacing tokens applied to real components"
70285
+ };
70286
+ GPT_IMAGE_ID = /^(?:[^/]+\/)?gpt-image-(?<version>\d+(?:\.\d+)*)(?:-(?<variant>.+))?$/;
70287
+ PREFERRED_VARIANTS = ["flare", "sunburst"];
70288
+ LOWER_TIER_VARIANTS = new Set(["mini", "nano"]);
70289
+ IMAGE_EXTENSIONS = new Map([
70290
+ ["image/png", "png"],
70291
+ ["image/jpeg", "jpg"],
70292
+ ["image/webp", "webp"]
70293
+ ]);
70294
+ });
70295
+
69992
70296
  // dist/builtin/workflows/builtin/open-claude-design-utils.ts
69993
70297
  import { spawnSync as spawnSync3 } from "node:child_process";
69994
70298
  import { mkdirSync as mkdirSync7 } from "node:fs";
69995
70299
  import { tmpdir, userInfo } from "node:os";
69996
- import { join as join25 } from "node:path";
69997
- import { Type as Type18 } from "typebox";
70300
+ import { dirname as dirname14, join as join26, relative as relative8, sep as sep9 } from "node:path";
70301
+ import { Type as Type19 } from "typebox";
69998
70302
  import { createChildProcessEnvironment as createChildProcessEnvironment3 } from "@bastani/atomic";
69999
70303
  function taggedPrompt3(sections) {
70000
70304
  return sections.map(([tag, content]) => {
@@ -70022,6 +70326,12 @@ function discoveryDecisionFromResult(result, fallbackBrief) {
70022
70326
  references
70023
70327
  };
70024
70328
  }
70329
+ function referenceImageFileUrl(path) {
70330
+ return `file://${path}`;
70331
+ }
70332
+ function referenceImageRelativeSrc(specPath, imagePath) {
70333
+ return relative8(dirname14(specPath), imagePath).split(sep9).join("/");
70334
+ }
70025
70335
  function joinResults(results) {
70026
70336
  return results.map((result) => `### ${result.name}
70027
70337
 
@@ -70036,32 +70346,32 @@ function tmpArtifactBase() {
70036
70346
  try {
70037
70347
  user = userInfo().username.replace(/[^A-Za-z0-9._-]/g, "_") || "default";
70038
70348
  } catch {}
70039
- return join25(tmpdir(), `open-claude-design-${user}`);
70349
+ return join26(tmpdir(), `open-claude-design-${user}`);
70040
70350
  }
70041
70351
  function prepareArtifactDir(cwd = process.cwd()) {
70042
70352
  const runId = `${new Date().toISOString().replace(/[:.]/g, "-")}-${Math.random().toString(36).slice(2, 8)}`;
70043
70353
  const tmpCandidates = [
70044
- join25(tmpArtifactBase(), runId),
70045
- join25(tmpdir(), "open-claude-design", runId)
70354
+ join26(tmpArtifactBase(), runId),
70355
+ join26(tmpdir(), "open-claude-design", runId)
70046
70356
  ];
70047
- const candidates = process.env.NODE_ENV === "test" ? tmpCandidates : [join25(cwd, "specs", "design", runId), ...tmpCandidates];
70357
+ const candidates = process.env.NODE_ENV === "test" ? tmpCandidates : [join26(cwd, "specs", "design", runId), ...tmpCandidates];
70048
70358
  for (const candidate of candidates) {
70049
70359
  try {
70050
70360
  mkdirSync7(candidate, { recursive: true });
70051
70361
  return {
70052
70362
  runId,
70053
70363
  artifactDir: candidate,
70054
- previewPath: join25(candidate, "preview.html"),
70055
- specPath: join25(candidate, "spec.html")
70364
+ previewPath: join26(candidate, "preview.html"),
70365
+ specPath: join26(candidate, "spec.html")
70056
70366
  };
70057
70367
  } catch {}
70058
70368
  }
70059
- const fallback = join25(tmpArtifactBase(), runId);
70369
+ const fallback = join26(tmpArtifactBase(), runId);
70060
70370
  return {
70061
70371
  runId,
70062
70372
  artifactDir: fallback,
70063
- previewPath: join25(fallback, "preview.html"),
70064
- specPath: join25(fallback, "spec.html")
70373
+ previewPath: join26(fallback, "preview.html"),
70374
+ specPath: join26(fallback, "spec.html")
70065
70375
  };
70066
70376
  }
70067
70377
  function ensureAgentBrowser() {
@@ -70166,10 +70476,10 @@ var init_open_claude_design_utils = __esm(() => {
70166
70476
  "theme",
70167
70477
  "tokens"
70168
70478
  ];
70169
- discoveryDecisionSchema = Type18.Object({
70170
- brief: Type18.String(),
70171
- output_type: Type18.Union([...OUTPUT_TYPES].map((value2) => Type18.Literal(value2))),
70172
- references: Type18.Array(Type18.String())
70479
+ discoveryDecisionSchema = Type19.Object({
70480
+ brief: Type19.String(),
70481
+ output_type: Type19.Union([...OUTPUT_TYPES].map((value2) => Type19.Literal(value2))),
70482
+ references: Type19.Array(Type19.String())
70173
70483
  }, { additionalProperties: false });
70174
70484
  HTML_PREVIEW_RULES = [
70175
70485
  "Produce one self-contained HTML document: inline CSS in <style> and JS in <script>; make no external requests except explicitly required Google Fonts.",
@@ -70363,9 +70673,18 @@ ${input.event.raw}
70363
70673
  `);
70364
70674
  }
70365
70675
  function buildLiveSessionStartPrompt(input) {
70676
+ const referenceImagePaths = input.referenceImagePaths ?? [];
70366
70677
  return [
70367
70678
  `<preview_path>${input.previewPath}</preview_path>`,
70368
70679
  `<preview_file_url>${input.previewFileUrl}</preview_file_url>`,
70680
+ ...referenceImagePaths.length > 0 ? [
70681
+ [
70682
+ "<reference_images>",
70683
+ ...referenceImagePaths.map((path) => `${path} (${referenceImageFileUrl(path)})`),
70684
+ "</reference_images>"
70685
+ ].join(`
70686
+ `)
70687
+ ] : [],
70369
70688
  `<browser_use_guidelines>${input.browserBootstrapRules}</browser_use_guidelines>`,
70370
70689
  "<role>You are an opinionated staff design engineer opening an impeccable `live` review session.</role>",
70371
70690
  [
@@ -70380,6 +70699,9 @@ function buildLiveSessionStartPrompt(input) {
70380
70699
  "2. Print the live `http://` review URL in plain text, plus the preview file URL as the manual fallback, so anyone attaching to this run can find the review.",
70381
70700
  "3. Directly under the URL, print how the user ends the review, in plain text: click exit in the Impeccable overlay, close the browser tab, or say `exit live`. State that the review waits indefinitely until they do, and that ending it exports the design as it then stands, with no further round.",
70382
70701
  "4. Do NOT start a poll loop. The workflow owns polling and will call you back for each event that needs you. Ending your turn does not end the review.",
70702
+ ...referenceImagePaths.length > 0 ? [
70703
+ "5. Under the review URL, also print each <reference_images> path and file URL in plain text, labelled as the AI-generated design directions the preview was built from, so the user can open them beside the preview. Leave the live review tab on the preview."
70704
+ ] : [],
70383
70705
  "</instructions>"
70384
70706
  ].join(`
70385
70707
  `),
@@ -70390,13 +70712,14 @@ function buildLiveSessionStartPrompt(input) {
70390
70712
  }
70391
70713
  var MODEL_EVENTS, LEGACY_REPLY_STATUSES, LIVE_POLL_VERB = "live-poll";
70392
70714
  var init_open_claude_design_live_protocol = __esm(() => {
70715
+ init_open_claude_design_utils();
70393
70716
  MODEL_EVENTS = new Set(["generate", "steer", "manual_edit_apply", "variant_mount_failed"]);
70394
70717
  LEGACY_REPLY_STATUSES = new Set(["done", "error", "complete", "discard", "discarded"]);
70395
70718
  });
70396
70719
 
70397
70720
  // dist/builtin/workflows/builtin/open-claude-design-setup.ts
70398
70721
  import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync4 } from "node:fs";
70399
- import { join as join26 } from "node:path";
70722
+ import { join as join27 } from "node:path";
70400
70723
  function renderDiscoveryContext(discovery) {
70401
70724
  return [
70402
70725
  `Confirmed design brief: ${discovery.brief}`,
@@ -70461,10 +70784,10 @@ async function runDiscoveryAndInit(args) {
70461
70784
  };
70462
70785
  }
70463
70786
  function designContextPath(artifactDir) {
70464
- return join26(artifactDir, DESIGN_CONTEXT_FILENAME);
70787
+ return join27(artifactDir, DESIGN_CONTEXT_FILENAME);
70465
70788
  }
70466
70789
  function referencesBriefPath(artifactDir) {
70467
- return join26(artifactDir, REFERENCES_BRIEF_FILENAME);
70790
+ return join27(artifactDir, REFERENCES_BRIEF_FILENAME);
70468
70791
  }
70469
70792
  function buildReferenceDiscoveryPrompt(args) {
70470
70793
  const siteList = REFERENCE_DESIGN_SITES.map((site, index) => `${index + 1}. ${site.name} — ${site.url}`).join(`
@@ -70490,8 +70813,8 @@ function buildReferenceDiscoveryPrompt(args) {
70490
70813
  [
70491
70814
  "Use the agent-browser skill to open each gallery; if `agent-browser` reports a missing browser executable, follow the bootstrap rules and retry once.",
70492
70815
  "From each gallery, choose 1-3 fitting designs and CLICK INTO each actual live or project-detail page; do not capture only the grid or thumbnail.",
70493
- `Capture motion across the entire page: start \`agent-browser record start ${join26(args.artifactDir, "ref-<site>-<n>.webm")}\`, scroll smoothly in small increments with waits (using repeated \`agent-browser scroll down 600\` or \`agent-browser mouse wheel 600\`) so animations fire and lazy content loads, then run \`agent-browser record stop\`.`,
70494
- `Also run \`agent-browser screenshot ${join26(args.artifactDir, "ref-<site>-<n>.png")} --full\`; this still is the minimum when video is unavailable.`,
70816
+ `Capture motion across the entire page: start \`agent-browser record start ${join27(args.artifactDir, "ref-<site>-<n>.webm")}\`, scroll smoothly in small increments with waits (using repeated \`agent-browser scroll down 600\` or \`agent-browser mouse wheel 600\`) so animations fire and lazy content loads, then run \`agent-browser record stop\`.`,
70817
+ `Also run \`agent-browser screenshot ${join27(args.artifactDir, "ref-<site>-<n>.png")} --full\`; this still is the minimum when video is unavailable.`,
70495
70818
  "Record the actual destination URL, title, and author. For each reference, cite observed layout, typography, color, spacing, and motion traits rather than inferred traits.",
70496
70819
  "Assess fit against DESIGN.md, PRODUCT.md, and the ds-* discovery evidence in the design-context file; prefer on-brand references and flag departures.",
70497
70820
  "Use ask_user_question to ask which reference direction they prefer, offering 2-4 strongest options plus `None of these fit`. If none fit, ask them to provide a reference image, screenshot, URL, or local file path and record the answer.",
@@ -70531,11 +70854,17 @@ function persistDesignContext(artifactDir, content) {
70531
70854
  writeRequiredContextArtifact(artifactDir, designContextPath(artifactDir), content, "design-context");
70532
70855
  }
70533
70856
  function buildLiveReviewGateMessage(args) {
70857
+ const referenceImagePaths = args.referenceImagePaths ?? [];
70534
70858
  return [
70535
70859
  `Design review session ${args.round} is ready for your browser review.`,
70536
70860
  "",
70537
70861
  `Preview file: ${args.previewPath}`,
70538
70862
  `Preview URL: ${args.previewFileUrl}`,
70863
+ ...referenceImagePaths.length > 0 ? [
70864
+ "",
70865
+ "Reference images (AI-generated design directions the preview was built from):",
70866
+ ...referenceImagePaths.map((path) => `- ${path} (${referenceImageFileUrl(path)})`)
70867
+ ] : [],
70539
70868
  "",
70540
70869
  `"${LIVE_REVIEW_GATE_OPTIONS[0]}" opens an interactive browser session; the session-start stage prints the live http:// review URL as soon as its server is up (attach with /workflow connect to see it, or open the preview URL above directly).`,
70541
70870
  "The session is unbounded: pick elements, accept variants, and steer for as long as you like, and everything you accept lands in the preview as you go.",
@@ -70571,7 +70900,7 @@ function forkContinuationOptions2(sessionId) {
70571
70900
  return sessionId === undefined ? {} : { context: "fork", forkFromSessionId: sessionId };
70572
70901
  }
70573
70902
  async function refineOpenClaudeDesign(options) {
70574
- const { designContext, prompt, outputType, previewPath, previewFileUrl, browserBootstrapRules, designContextFile, referencesFile, designModelConfig, workflowCwd } = options;
70903
+ const { designContext, prompt, outputType, previewPath, previewFileUrl, browserBootstrapRules, designContextFile, referencesFile, referenceImagePaths, designModelConfig, workflowCwd } = options;
70575
70904
  const importContext = options.importContext ?? "";
70576
70905
  const generated = await designContext.task("generate-1", {
70577
70906
  prompt: buildInitialGeneratePrompt({
@@ -70580,12 +70909,14 @@ async function refineOpenClaudeDesign(options) {
70580
70909
  previewPath,
70581
70910
  designContextFile,
70582
70911
  referencesFile,
70912
+ referenceImagePaths,
70583
70913
  importContext
70584
70914
  }),
70585
- reads: [designContextFile, referencesFile],
70915
+ reads: [designContextFile, referencesFile, ...referenceImagePaths],
70916
+ ...referenceImagePaths.length > 0 ? { taskNeeds: { needsImages: true } } : {},
70586
70917
  ...designModelConfig
70587
70918
  });
70588
- const gateChoice = await options.ui.select(buildLiveReviewGateMessage({ round: 1, previewPath, previewFileUrl }), LIVE_REVIEW_GATE_OPTIONS).catch((error) => {
70919
+ const gateChoice = await options.ui.select(buildLiveReviewGateMessage({ round: 1, previewPath, previewFileUrl, referenceImagePaths }), LIVE_REVIEW_GATE_OPTIONS).catch((error) => {
70589
70920
  if (isUiUnavailableRejection(error))
70590
70921
  return LIVE_REVIEW_GATE_OPTIONS[0];
70591
70922
  throw error;
@@ -70597,6 +70928,7 @@ async function refineOpenClaudeDesign(options) {
70597
70928
  reviewStageName: "user-feedback-1",
70598
70929
  previewPath,
70599
70930
  previewFileUrl,
70931
+ referenceImagePaths,
70600
70932
  browserBootstrapRules,
70601
70933
  designModelConfig,
70602
70934
  workflowCwd
@@ -70605,10 +70937,10 @@ async function refineOpenClaudeDesign(options) {
70605
70937
  return { latestDesign: generated.text };
70606
70938
  }
70607
70939
  async function runLiveReviewSession(options) {
70608
- const { designContext, round, reviewStageName, previewPath, previewFileUrl, browserBootstrapRules, designModelConfig, workflowCwd } = options;
70940
+ const { designContext, round, reviewStageName, previewPath, previewFileUrl, referenceImagePaths, browserBootstrapRules, designModelConfig, workflowCwd } = options;
70609
70941
  let sessionId;
70610
70942
  const start = await designContext.task(`${reviewStageName}-start`, {
70611
- prompt: buildLiveSessionStartPrompt({ previewPath, previewFileUrl, browserBootstrapRules, round }),
70943
+ prompt: buildLiveSessionStartPrompt({ previewPath, previewFileUrl, referenceImagePaths, browserBootstrapRules, round }),
70612
70944
  ...designModelConfig
70613
70945
  });
70614
70946
  sessionId = start.sessionId;
@@ -70632,6 +70964,7 @@ async function runLiveReviewSession(options) {
70632
70964
  }
70633
70965
  }
70634
70966
  function buildInitialGeneratePrompt(args) {
70967
+ const hasReferenceImages = args.referenceImagePaths.length > 0;
70635
70968
  return taggedPrompt3([
70636
70969
  ["design_brief", args.prompt],
70637
70970
  [
@@ -70643,6 +70976,7 @@ function buildInitialGeneratePrompt(args) {
70643
70976
  "reference_inspiration_file",
70644
70977
  `Read the file at ${args.referencesFile} for the curated reference inspiration to heavily emulate.`
70645
70978
  ],
70979
+ ...hasReferenceImages ? [["reference_images", renderReferenceImagesForGeneration(args.referenceImagePaths)]] : [],
70646
70980
  ["reference_precedence", REFERENCE_PRECEDENCE],
70647
70981
  ["preview_artifact_path", args.previewPath],
70648
70982
  ["html_rules", HTML_PREVIEW_RULES],
@@ -70658,6 +70992,7 @@ function buildInitialGeneratePrompt(args) {
70658
70992
  `First read the design-context and reference-inspiration files named above; they are the design system and reference authority for every decision. If a file is missing, say so and proceed from the brief.`,
70659
70993
  `Create the HTML artifact exactly at ${args.previewPath}.`,
70660
70994
  "Follow <reference_precedence>; heavily reference the reference-inspiration file without copying wholesale or inventing traits.",
70995
+ ...hasReferenceImages ? [REFERENCE_IMAGE_GENERATION_RULE] : [],
70661
70996
  `Build the requested output_type (${args.outputType}): render full realistic layouts for prototypes/pages, or the component in at least three representative contexts.`,
70662
70997
  "Include structure, states, accessibility, responsive behavior, and integration notes as HTML comments so the preview stays clean.",
70663
70998
  "Use project language rather than generic placeholders when conventions exist. Add no features or abstractions beyond this design brief."
@@ -70680,9 +71015,28 @@ function buildInitialGeneratePrompt(args) {
70680
71015
  ]
70681
71016
  ]);
70682
71017
  }
71018
+ function renderReferenceImageList(paths) {
71019
+ return paths.map((path) => `- ${path}`).join(`
71020
+ `);
71021
+ }
71022
+ function renderReferenceImagesForGeneration(paths) {
71023
+ return [
71024
+ "AI-generated design reference images for this brief, one per visual direction (named by file). They were rendered from the brief, PRODUCT.md/DESIGN.md, and the curated references.",
71025
+ renderReferenceImageList(paths)
71026
+ ].join(`
71027
+ `);
71028
+ }
71029
+ function renderReferenceImagesForExport(specPath, paths) {
71030
+ return [
71031
+ "AI-generated design reference images, one per visual direction (named by file), stored next to the spec. They are illustrations, not specifications.",
71032
+ ...paths.map((path) => `- ${path} (src="${referenceImageRelativeSrc(specPath, path)}")`)
71033
+ ].join(`
71034
+ `);
71035
+ }
70683
71036
  async function exportOpenClaudeDesign(options) {
70684
- const { designContext, prompt, outputType, previewPath, previewFileUrl, specPath, specFileUrl, browserBootstrapRules, designContextFile, referencesFile, designModelConfig } = options;
71037
+ const { designContext, prompt, outputType, previewPath, previewFileUrl, specPath, specFileUrl, browserBootstrapRules, designContextFile, referencesFile, referenceImagePaths, designModelConfig } = options;
70685
71038
  const latestDesign = options.latestDesign;
71039
+ const hasReferenceImages = referenceImagePaths.length > 0;
70686
71040
  const handoff = await designContext.task("exporter", {
70687
71041
  reads: [designContextFile, referencesFile],
70688
71042
  prompt: taggedPrompt3([
@@ -70696,6 +71050,7 @@ async function exportOpenClaudeDesign(options) {
70696
71050
  ],
70697
71051
  ["preview_artifact_path", previewPath],
70698
71052
  ["spec_artifact_path", specPath],
71053
+ ...hasReferenceImages ? [["reference_images", renderReferenceImagesForExport(specPath, referenceImagePaths)]] : [],
70699
71054
  ["final_design_summary", "{previous}"],
70700
71055
  ["html_rules", HTML_PREVIEW_RULES],
70701
71056
  ["anti_design_slop_rules", ANTI_SLOP_RULES],
@@ -70710,7 +71065,8 @@ async function exportOpenClaudeDesign(options) {
70710
71065
  "First read the design-context file named above, then read preview_artifact_path as the canonical final design, and use the Write tool to create one self-contained HTML5 file at spec_artifact_path.",
70711
71066
  'In order, include: sticky header with title/status/run id; Executive Summary; Live Preview embedding the full preview via `<iframe srcdoc="...">` or a side-by-side rendered copy in `<article class="preview-frame">`; the six DESIGN.md sections (Overview, Colors, Typography, Elevation, Components, Do\'s and Don\'ts) rendered with swatches, tables, and code blocks; Implementation handoff (Recommended files + components, Implementation steps, Usage example, Accessibility & responsive checklist, Validation commands, Known limitations); and an appendix linking the raw preview path.',
70712
71067
  "Use dense legible typography, generous whitespace, monospaced code, rendered hex/oklch swatches, and copy-to-clipboard hints in HTML comments.",
70713
- `Show the absolute preview path (${previewPath}) and file URL (${previewFileUrl}) prominently. Preserve assumptions and limitations; introduce no requirement absent from the final design or DESIGN.md.`
71068
+ `Show the absolute preview path (${previewPath}) and file URL (${previewFileUrl}) prominently. Preserve assumptions and limitations; introduce no requirement absent from the final design or DESIGN.md.`,
71069
+ ...hasReferenceImages ? [REFERENCE_IMAGE_EXPORT_RULE] : []
70714
71070
  ].join(`
70715
71071
  `)
70716
71072
  ],
@@ -70770,7 +71126,7 @@ async function exportOpenClaudeDesign(options) {
70770
71126
  });
70771
71127
  return { latestDesign, handoff };
70772
71128
  }
70773
- var GROUNDED_REPORTING7 = "Before reporting progress, audit each claim against a tool result from this session. Report only work you can point to evidence for; say so explicitly when something is unverified.";
71129
+ var GROUNDED_REPORTING7 = "Before reporting progress, audit each claim against a tool result from this session. Report only work you can point to evidence for; say so explicitly when something is unverified.", REFERENCE_IMAGE_GENERATION_RULE = "Open every file listed in <reference_images> with the read tool before designing. They are illustrations of distinct visual directions for this brief. Choose the direction that best serves the brief and the references, say which one in your overview, and match its composition, palette, type character, density, and imagery stance in the HTML; borrow from the other directions only where they agree. Do not copy text from the images or invent content from them: <reference_precedence> still wins on any conflict. If an image cannot be read, say so and continue from the other context.", REFERENCE_IMAGE_EXPORT_RULE = 'Add a "Design References" section after the Live Preview that shows every file listed in <reference_images> as `<img src="..." alt="...">` using the relative src given for it, with a caption naming its direction and a note that these are AI-generated illustrations rather than specifications. This is the one exception to the self-contained rule: link the image files by relative path and never inline their data into the HTML.';
70774
71130
  var init_open_claude_design_phases = __esm(() => {
70775
71131
  init_open_claude_design_utils();
70776
71132
  init_open_claude_design_live_protocol();
@@ -70778,7 +71134,7 @@ var init_open_claude_design_phases = __esm(() => {
70778
71134
  });
70779
71135
 
70780
71136
  // dist/builtin/workflows/builtin/open-claude-design-runner.ts
70781
- async function runOpenClaudeDesignWorkflow(ctx) {
71137
+ async function runOpenClaudeDesignWorkflow(ctx, deps = {}) {
70782
71138
  const designContext = ctx;
70783
71139
  const agentBrowser = ensureAgentBrowser();
70784
71140
  const browserBootstrapRules = buildAgentBrowserBootstrapRules(agentBrowser);
@@ -70967,6 +71323,15 @@ async function runOpenClaudeDesignWorkflow(ctx) {
70967
71323
  "Full design-system and reference evidence: read the design-context file."
70968
71324
  ].join(`
70969
71325
  `) : "No user reference was provided; infer the design direction from the brief, project design context, research, and curated reference inspiration.";
71326
+ const referenceImages = await runReferenceImagesStep(designContext.tool, {
71327
+ brief: designBrief,
71328
+ outputType,
71329
+ artifactDir,
71330
+ workflowCwd,
71331
+ curatedReferences: referencesBriefRaw,
71332
+ imageModel: inputs.image_model
71333
+ }, deps);
71334
+ const referenceImagePaths = existingReferenceImagePaths(referenceImages);
70970
71335
  const refinement = await refineOpenClaudeDesign({
70971
71336
  designContext,
70972
71337
  prompt: designBrief,
@@ -70976,6 +71341,7 @@ async function runOpenClaudeDesignWorkflow(ctx) {
70976
71341
  browserBootstrapRules,
70977
71342
  designContextFile,
70978
71343
  referencesFile,
71344
+ referenceImagePaths,
70979
71345
  designModelConfig,
70980
71346
  workflowCwd,
70981
71347
  importContext,
@@ -70993,6 +71359,7 @@ async function runOpenClaudeDesignWorkflow(ctx) {
70993
71359
  browserBootstrapRules,
70994
71360
  designContextFile,
70995
71361
  referencesFile,
71362
+ referenceImagePaths,
70996
71363
  latestDesign,
70997
71364
  designModelConfig
70998
71365
  });
@@ -71009,49 +71376,56 @@ async function runOpenClaudeDesignWorkflow(ctx) {
71009
71376
  preview_file_url: previewFileUrl,
71010
71377
  spec_path: specPath,
71011
71378
  spec_file_url: specFileUrl,
71012
- agent_browser_status: agentBrowser.summary
71379
+ agent_browser_status: agentBrowser.summary,
71380
+ reference_images_status: referenceImages
71013
71381
  };
71014
71382
  }
71015
71383
  var GROUNDED_REPORTING8 = "Before reporting progress, audit each claim against a tool result from this session. Report only work you can point to evidence for; say so explicitly when something is unverified.", DELEGATION_RULE = "Delegate further only work genuinely independent and too large for a handful of tool calls; do not delegate self-verification, and prefer one subagent over several.";
71016
71384
  var init_open_claude_design_runner = __esm(() => {
71017
71385
  init_open_claude_design_utils();
71386
+ init_open_claude_design_images();
71018
71387
  init_open_claude_design_phases();
71019
71388
  init_open_claude_design_setup();
71020
71389
  });
71021
71390
 
71022
71391
  // dist/builtin/workflows/builtin/open-claude-design.ts
71023
- import { Type as Type19 } from "typebox";
71392
+ import { Type as Type20 } from "typebox";
71024
71393
  var open_claude_design_default;
71025
71394
  var init_open_claude_design = __esm(() => {
71026
71395
  init_workflow();
71027
71396
  init_builtin_context();
71397
+ init_open_claude_design_images();
71028
71398
  init_open_claude_design_runner();
71029
71399
  open_claude_design_default = workflow({
71030
71400
  name: "open-claude-design",
71031
71401
  description: "AI-powered design workflow: combined discovery/init → design-system/reference research → curated reference discovery → HTML generation → one live review session → rich HTML handoff. The discovery stage asks what to build, the output type, and which references to emulate, then runs impeccable init for PRODUCT.md/DESIGN.md (references take precedence over project context). The user reviews the generated HTML in one live session.",
71032
71402
  heartbeatIntervalMinutes: 0,
71033
71403
  inputs: {
71034
- prompt: Type19.String({
71404
+ prompt: Type20.String({
71035
71405
  description: "What to design (for example, a dashboard, page, component, or prototype). The discovery stage refines this into a confirmed brief and asks for the output type and references."
71036
71406
  }),
71037
- discover_references: Type19.Boolean({
71407
+ discover_references: Type20.Boolean({
71038
71408
  default: true,
71039
71409
  description: "Discover beautiful, current reference designs from notable design websites (Awwwards, recent.design, Dribbble, Monet, Motionsites) and feed them to generation. Set false to skip the network/browser reference pass."
71040
- })
71410
+ }),
71411
+ image_model: Type20.Optional(Type20.String({
71412
+ description: "Image model for design reference images, as provider/id (for example openai-images/gpt-image-2.6-flare). Defaults to the newest available GPT Image model, then other image providers such as OpenRouter. Reference images are skipped when no image model is available."
71413
+ }))
71041
71414
  },
71042
71415
  outputs: {
71043
- output_type: Type19.Optional(Type19.String({ description: "Kind of design artifact produced." })),
71044
- design_system: Type19.Optional(Type19.String({ description: "Design system source used for generation: the project-derived design system." })),
71045
- artifact: Type19.Optional(Type19.String({ description: "Latest final design summary from the final preview artifact." })),
71046
- handoff: Type19.Optional(Type19.String({ description: "Final rich HTML spec and implementation handoff summary." })),
71047
- import_context: Type19.Optional(Type19.String({ description: "Reference-import context used during generation." })),
71048
- run_id: Type19.Optional(Type19.String({ description: "Per-run design workflow artifact identifier." })),
71049
- artifact_dir: Type19.Optional(Type19.String({ description: "Directory containing preview and spec artifacts." })),
71050
- preview_path: Type19.Optional(Type19.String({ description: "Absolute path to the generated preview.html file." })),
71051
- preview_file_url: Type19.Optional(Type19.String({ description: "file:// URL for the generated preview.html file." })),
71052
- spec_path: Type19.Optional(Type19.String({ description: "Absolute path to the generated spec.html file." })),
71053
- spec_file_url: Type19.Optional(Type19.String({ description: "file:// URL for the generated spec.html file." })),
71054
- agent_browser_status: Type19.Optional(Type19.String({ description: "Outcome of the initial deterministic step that ensures the agent-browser skill's `agent-browser` command is installed." }))
71416
+ output_type: Type20.Optional(Type20.String({ description: "Kind of design artifact produced." })),
71417
+ design_system: Type20.Optional(Type20.String({ description: "Design system source used for generation: the project-derived design system." })),
71418
+ artifact: Type20.Optional(Type20.String({ description: "Latest final design summary from the final preview artifact." })),
71419
+ handoff: Type20.Optional(Type20.String({ description: "Final rich HTML spec and implementation handoff summary." })),
71420
+ import_context: Type20.Optional(Type20.String({ description: "Reference-import context used during generation." })),
71421
+ run_id: Type20.Optional(Type20.String({ description: "Per-run design workflow artifact identifier." })),
71422
+ artifact_dir: Type20.Optional(Type20.String({ description: "Directory containing preview and spec artifacts." })),
71423
+ preview_path: Type20.Optional(Type20.String({ description: "Absolute path to the generated preview.html file." })),
71424
+ preview_file_url: Type20.Optional(Type20.String({ description: "file:// URL for the generated preview.html file." })),
71425
+ spec_path: Type20.Optional(Type20.String({ description: "Absolute path to the generated spec.html file." })),
71426
+ spec_file_url: Type20.Optional(Type20.String({ description: "file:// URL for the generated spec.html file." })),
71427
+ agent_browser_status: Type20.Optional(Type20.String({ description: "Outcome of the initial deterministic step that ensures the agent-browser skill's `agent-browser` command is installed." })),
71428
+ reference_images_status: Type20.Optional(referenceImagesStatusSchema)
71055
71429
  },
71056
71430
  run: async (ctx) => await runOpenClaudeDesignWorkflow(withBuiltinContext(ctx))
71057
71431
  });
@@ -71067,9 +71441,9 @@ var init_ralph_review_gate = __esm(() => {
71067
71441
  });
71068
71442
 
71069
71443
  // dist/builtin/workflows/builtin/ralph-core.ts
71070
- import { mkdir as mkdir4, writeFile as writeFile8 } from "node:fs/promises";
71071
- import { dirname as dirname13, join as join27 } from "node:path";
71072
- import { Type as Type20 } from "typebox";
71444
+ import { mkdir as mkdir5, writeFile as writeFile9 } from "node:fs/promises";
71445
+ import { dirname as dirname15, join as join28 } from "node:path";
71446
+ import { Type as Type21 } from "typebox";
71073
71447
  function taggedPrompt4(sections) {
71074
71448
  return sections.map(([tag, content]) => {
71075
71449
  const trimmed = content.trim();
@@ -71108,11 +71482,11 @@ function slugifyResearchTopic(prompt) {
71108
71482
  }
71109
71483
  function defaultResearchPath(prompt, now = new Date) {
71110
71484
  const date = now.toISOString().slice(0, 10);
71111
- return join27(DEFAULT_RESEARCH_DIR, `${date}-${slugifyResearchTopic(prompt)}.md`);
71485
+ return join28(DEFAULT_RESEARCH_DIR, `${date}-${slugifyResearchTopic(prompt)}.md`);
71112
71486
  }
71113
71487
  async function createImplementationNotesFile(prompt, runId) {
71114
71488
  const notesDir = await createWorkflowArtifactDirectory(runId);
71115
- const notesPath = join27(notesDir, IMPLEMENTATION_NOTES_FILENAME);
71489
+ const notesPath = join28(notesDir, IMPLEMENTATION_NOTES_FILENAME);
71116
71490
  const initialNotes = [
71117
71491
  "# Implementation Notes",
71118
71492
  "",
@@ -71124,7 +71498,7 @@ async function createImplementationNotesFile(prompt, runId) {
71124
71498
  "- Before reporting progress, audit each claim against a tool result from this session. Report only work you can point to evidence for; say so explicitly when something is unverified."
71125
71499
  ].join(`
71126
71500
  `);
71127
- await writeFile8(notesPath, `${initialNotes}
71501
+ await writeFile9(notesPath, `${initialNotes}
71128
71502
  `, {
71129
71503
  encoding: "utf8",
71130
71504
  flag: "wx"
@@ -71133,7 +71507,7 @@ async function createImplementationNotesFile(prompt, runId) {
71133
71507
  }
71134
71508
  async function createQaEvidenceVideoPath(runId) {
71135
71509
  const qaDir = await createWorkflowArtifactDirectory(runId);
71136
- return join27(qaDir, QA_E2E_VIDEO_FILENAME);
71510
+ return join28(qaDir, QA_E2E_VIDEO_FILENAME);
71137
71511
  }
71138
71512
  function renderQaE2eVideoGuidance(qaVideoPath) {
71139
71513
  return [
@@ -71199,8 +71573,8 @@ function artifactSafeName2(value2) {
71199
71573
  return safe.length > 0 ? safe : "artifact";
71200
71574
  }
71201
71575
  async function writeJsonArtifact(path, content) {
71202
- await mkdir4(dirname13(path), { recursive: true });
71203
- await writeFile8(path, `${JSON.stringify(content, null, 2)}
71576
+ await mkdir5(dirname15(path), { recursive: true });
71577
+ await writeFile9(path, `${JSON.stringify(content, null, 2)}
71204
71578
  `, {
71205
71579
  encoding: "utf8"
71206
71580
  });
@@ -71273,60 +71647,60 @@ var init_ralph_core = __esm(() => {
71273
71647
  init_shared_prompts();
71274
71648
  init_ralph_review_gate();
71275
71649
  init_review_convergence();
71276
- reviewFindingSchema2 = Type20.Object({
71277
- title: Type20.String(),
71278
- body: Type20.String(),
71279
- confidence_score: Type20.Number({ minimum: 0, maximum: 1 }),
71280
- objective_alignment: Type20.Union([
71281
- Type20.Literal("required_by_objective"),
71282
- Type20.Literal("consistent_with_objective"),
71283
- Type20.Literal("beyond_objective"),
71284
- Type20.Literal("contradicts_objective")
71650
+ reviewFindingSchema2 = Type21.Object({
71651
+ title: Type21.String(),
71652
+ body: Type21.String(),
71653
+ confidence_score: Type21.Number({ minimum: 0, maximum: 1 }),
71654
+ objective_alignment: Type21.Union([
71655
+ Type21.Literal("required_by_objective"),
71656
+ Type21.Literal("consistent_with_objective"),
71657
+ Type21.Literal("beyond_objective"),
71658
+ Type21.Literal("contradicts_objective")
71285
71659
  ]),
71286
- priority: Type20.Optional(Type20.Union([Type20.Integer({ minimum: 0, maximum: 3 }), Type20.Null()])),
71287
- code_location: Type20.Object({
71288
- absolute_file_path: Type20.String(),
71289
- line_range: Type20.Object({
71290
- start: Type20.Integer({ minimum: 1 }),
71291
- end: Type20.Integer({ minimum: 1 })
71660
+ priority: Type21.Optional(Type21.Union([Type21.Integer({ minimum: 0, maximum: 3 }), Type21.Null()])),
71661
+ code_location: Type21.Object({
71662
+ absolute_file_path: Type21.String(),
71663
+ line_range: Type21.Object({
71664
+ start: Type21.Integer({ minimum: 1 }),
71665
+ end: Type21.Integer({ minimum: 1 })
71292
71666
  }, { additionalProperties: false })
71293
71667
  }, { additionalProperties: false })
71294
71668
  }, { additionalProperties: false });
71295
- requirementsTraceabilitySchema2 = Type20.Object({
71296
- requirement: Type20.String(),
71297
- status: Type20.Union([
71298
- Type20.Literal("proven"),
71299
- Type20.Literal("contradicted"),
71300
- Type20.Literal("missing"),
71301
- Type20.Literal("unverified")
71669
+ requirementsTraceabilitySchema2 = Type21.Object({
71670
+ requirement: Type21.String(),
71671
+ status: Type21.Union([
71672
+ Type21.Literal("proven"),
71673
+ Type21.Literal("contradicted"),
71674
+ Type21.Literal("missing"),
71675
+ Type21.Literal("unverified")
71302
71676
  ]),
71303
- evidence: Type20.String()
71677
+ evidence: Type21.String()
71304
71678
  }, { additionalProperties: false });
71305
- reviewerErrorSchema2 = Type20.Object({
71306
- kind: Type20.Union([
71307
- Type20.Literal("validation_unavailable"),
71308
- Type20.Literal("dependency_unavailable"),
71309
- Type20.Literal("tool_failure"),
71310
- Type20.Literal("reviewer_failure")
71679
+ reviewerErrorSchema2 = Type21.Object({
71680
+ kind: Type21.Union([
71681
+ Type21.Literal("validation_unavailable"),
71682
+ Type21.Literal("dependency_unavailable"),
71683
+ Type21.Literal("tool_failure"),
71684
+ Type21.Literal("reviewer_failure")
71311
71685
  ]),
71312
- message: Type20.String(),
71313
- attempted_recovery: Type20.String()
71686
+ message: Type21.String(),
71687
+ attempted_recovery: Type21.String()
71314
71688
  }, { additionalProperties: false });
71315
- reviewDecisionSchema2 = Type20.Object({
71316
- findings: Type20.Array(reviewFindingSchema2),
71317
- overall_correctness: Type20.Union([
71318
- Type20.Literal("patch is correct"),
71319
- Type20.Literal("patch is incorrect")
71689
+ reviewDecisionSchema2 = Type21.Object({
71690
+ findings: Type21.Array(reviewFindingSchema2),
71691
+ overall_correctness: Type21.Union([
71692
+ Type21.Literal("patch is correct"),
71693
+ Type21.Literal("patch is incorrect")
71320
71694
  ]),
71321
- overall_explanation: Type20.String(),
71322
- overall_confidence_score: Type20.Number({ minimum: 0, maximum: 1 }),
71323
- criterion_scores: Type20.Optional(Type20.Array(Type20.Object({
71324
- criterion_id: Type20.String(),
71695
+ overall_explanation: Type21.String(),
71696
+ overall_confidence_score: Type21.Number({ minimum: 0, maximum: 1 }),
71697
+ criterion_scores: Type21.Optional(Type21.Array(Type21.Object({
71698
+ criterion_id: Type21.String(),
71325
71699
  score: VERIFICATION_SCALE.schema
71326
71700
  }, { additionalProperties: false }))),
71327
- requirements_traceability: Type20.Array(requirementsTraceabilitySchema2),
71328
- stop_review_loop: Type20.Boolean(),
71329
- reviewer_error: Type20.Optional(Type20.Union([Type20.Null(), reviewerErrorSchema2]))
71701
+ requirements_traceability: Type21.Array(requirementsTraceabilitySchema2),
71702
+ stop_review_loop: Type21.Boolean(),
71703
+ reviewer_error: Type21.Optional(Type21.Union([Type21.Null(), reviewerErrorSchema2]))
71330
71704
  }, { additionalProperties: false });
71331
71705
  });
71332
71706
 
@@ -71536,8 +71910,8 @@ var init_ralph_models = __esm(() => {
71536
71910
  });
71537
71911
 
71538
71912
  // dist/builtin/workflows/builtin/ralph-runner.ts
71539
- import { existsSync as existsSync8 } from "node:fs";
71540
- import { join as join28, resolve as resolve13 } from "node:path";
71913
+ import { existsSync as existsSync9 } from "node:fs";
71914
+ import { join as join29, resolve as resolve13 } from "node:path";
71541
71915
  async function runRalphWorkflow(ctx, options) {
71542
71916
  const { prompt, acceptanceCriteria, maxLoops, comparisonBaseBranch, workflowStartCwd, createPr, runId } = options;
71543
71917
  let latestReviewReportPath;
@@ -71598,7 +71972,7 @@ async function runRalphWorkflow(ctx, options) {
71598
71972
  const researchPath = workflowResearchPath;
71599
71973
  finalResearchPath = researchPath;
71600
71974
  finalPlanPath = researchPath;
71601
- const orchestratorReportPath = join28(artifactDir, "orchestrator-report.md");
71975
+ const orchestratorReportPath = join29(artifactDir, "orchestrator-report.md");
71602
71976
  const orchestratorForkOptions = forkContinuationOptions3(previousOrchestratorSessionId);
71603
71977
  const orchestratorPrompt = orchestratorForkOptions.forkFromSessionId === undefined ? taggedPrompt4([
71604
71978
  ["acceptance_criteria", keepContext(acceptanceCriteria)],
@@ -71734,7 +72108,7 @@ Read it before implementation or delegation because it is the primary current im
71734
72108
  diagnostics: parsed.diagnostics,
71735
72109
  allowFinalActionRemaining: createPr
71736
72110
  });
71737
- const artifactPath = join28(artifactDir, `review-${artifactSafeName2(reviewer)}.json`);
72111
+ const artifactPath = join29(artifactDir, `review-${artifactSafeName2(reviewer)}.json`);
71738
72112
  await writeJsonArtifact(artifactPath, {
71739
72113
  reviewer,
71740
72114
  decision: parsed.decision,
@@ -71790,7 +72164,7 @@ Read it before implementation or delegation because it is the primary current im
71790
72164
  usage: fold_usage([orchestrator, ...reviews, ...reverifyResults])
71791
72165
  }));
71792
72166
  }
71793
- latestReviewReportPath = await writeJsonArtifact(join28(artifactDir, "review-round-latest.json"), {
72167
+ latestReviewReportPath = await writeJsonArtifact(join29(artifactDir, "review-round-latest.json"), {
71794
72168
  convergence_decision: roundConvergenceDecision,
71795
72169
  convergence: convergenceEntries,
71796
72170
  consolidated_findings: reverified.batch,
@@ -71800,7 +72174,7 @@ Read it before implementation or delegation because it is the primary current im
71800
72174
  if (approved)
71801
72175
  break;
71802
72176
  }
71803
- const qaVideoAvailable = existsSync8(qaVideoPath);
72177
+ const qaVideoAvailable = existsSync9(qaVideoPath);
71804
72178
  const unapprovedHandoff = createPr === true && !approved;
71805
72179
  const escalationEvidence = unapprovedHandoff ? convergence_escalation_evidence(convergenceEntries) : [];
71806
72180
  if (createPr === true) {
@@ -71915,7 +72289,7 @@ var init_ralph_runner = __esm(() => {
71915
72289
  });
71916
72290
 
71917
72291
  // dist/builtin/workflows/builtin/ralph.ts
71918
- import { Type as Type21 } from "typebox";
72292
+ import { Type as Type22 } from "typebox";
71919
72293
  var ralph_default;
71920
72294
  var init_ralph = __esm(() => {
71921
72295
  init_workflow();
@@ -71927,38 +72301,38 @@ var init_ralph = __esm(() => {
71927
72301
  description: "Raw prompt → research-prompt-refinement → research → orchestrate → multi-model parallel review loop with bounded iteration and immutable acceptance criteria. When launching follow-up ralph runs from review findings, pass the ORIGINAL task text as acceptance_criteria so deltas cannot drift from the literal contract. If the task includes submitting a pull request (or MR/review), remove that final action from the prompt text and set create_pr=true instead when preparing the workflow inputs.",
71928
72302
  heartbeatIntervalMinutes: 15,
71929
72303
  inputs: {
71930
- prompt: Type21.String({ description: "The task or goal to research, execute, and refine. Do not include PR/MR submission instructions here; strip them from the task text and request them via create_pr=true instead." }),
71931
- acceptance_criteria: Type21.Optional(Type21.String({ description: "Original immutable task contract this run must remain consistent with. Defaults to prompt. Orchestrators launching follow-up runs from reviewer findings should pass the ORIGINAL task text here." })),
71932
- max_loops: Type21.Number({
72304
+ prompt: Type22.String({ description: "The task or goal to research, execute, and refine. Do not include PR/MR submission instructions here; strip them from the task text and request them via create_pr=true instead." }),
72305
+ acceptance_criteria: Type22.Optional(Type22.String({ description: "Original immutable task contract this run must remain consistent with. Defaults to prompt. Orchestrators launching follow-up runs from reviewer findings should pass the ORIGINAL task text here." })),
72306
+ max_loops: Type22.Number({
71933
72307
  default: DEFAULT_MAX_LOOPS,
71934
72308
  description: `Maximum research/orchestrate/review iterations (default ${DEFAULT_MAX_LOOPS}).`
71935
72309
  }),
71936
- base_branch: Type21.String({
72310
+ base_branch: Type22.String({
71937
72311
  default: "origin/main",
71938
72312
  description: "Branch reviewers compare the current code delta against (default origin/main)."
71939
72313
  }),
71940
- git_worktree_dir: Type21.String({
72314
+ git_worktree_dir: Type22.String({
71941
72315
  default: "",
71942
72316
  description: "Optional Git worktree path. Leave at the default unless the user explicitly requested worktree isolation — stages never create git worktrees on their own. Absolute paths are used as-is; relative paths resolve from the invoking repo root (or the invoking cwd outside a Git repo). An existing Git worktree root of any repository is reused as-is, even from another repository or a non-Git cwd. Creating a worktree requires starting inside the source Git repo: a missing path or an empty directory becomes a new worktree from base_branch, and a non-empty non-Git directory is treated as a worktree root that gets this run's own <dir>/<4-hex>/<repo-name> checkout, reused on resume."
71943
72317
  }),
71944
- create_pr: Type21.Boolean({
72318
+ create_pr: Type22.Boolean({
71945
72319
  default: false,
71946
72320
  description: "Whether to run the final pull-request creation stage. Defaults to false; prompt text alone does not opt in. If the task asks to submit a PR/MR/review, remove that from the prompt text and set this to true — only the final stage then attempts provider-appropriate PR/MR/review creation."
71947
72321
  })
71948
72322
  },
71949
72323
  outputs: {
71950
- result: Type21.Optional(Type21.String({ description: "Final implementation report from the orchestrator stage." })),
71951
- plan: Type21.Optional(Type21.String({ description: "Latest transformed research question." })),
71952
- plan_path: Type21.Optional(Type21.String({ description: "Backward-compatible alias for research_path." })),
71953
- research: Type21.Optional(Type21.String({ description: "Latest research report text or artifact reference." })),
71954
- research_path: Type21.Optional(Type21.String({ description: "Path to the latest generated research artifact under research/." })),
71955
- implementation_notes_path: Type21.Optional(Type21.String({ description: "Durable run-scoped notes file containing decisions, deviations, blockers, and validation notes." })),
71956
- qa_video_path: Type21.Optional(Type21.String({ description: "Absolute path to the reviewable QA end-to-end proof video recorded with domain-appropriate tooling for UI-applicable changes, when one was produced." })),
71957
- pr_report: Type21.Optional(Type21.String({ description: "Pull-request report emitted only when create_pr=true and the final pull-request stage runs." })),
71958
- approved: Type21.Optional(Type21.Boolean({ description: "Whether the reviewer loop approved before completion or optional final handoff." })),
71959
- iterations_completed: Type21.Optional(Type21.Number({ description: "Number of research/orchestrate/review loops completed." })),
71960
- review_report: Type21.Optional(Type21.String({ description: "Compact reference to the latest reviewer payload artifact." })),
71961
- review_report_path: Type21.Optional(Type21.String({ description: "JSON artifact path for the latest review round." }))
72324
+ result: Type22.Optional(Type22.String({ description: "Final implementation report from the orchestrator stage." })),
72325
+ plan: Type22.Optional(Type22.String({ description: "Latest transformed research question." })),
72326
+ plan_path: Type22.Optional(Type22.String({ description: "Backward-compatible alias for research_path." })),
72327
+ research: Type22.Optional(Type22.String({ description: "Latest research report text or artifact reference." })),
72328
+ research_path: Type22.Optional(Type22.String({ description: "Path to the latest generated research artifact under research/." })),
72329
+ implementation_notes_path: Type22.Optional(Type22.String({ description: "Durable run-scoped notes file containing decisions, deviations, blockers, and validation notes." })),
72330
+ qa_video_path: Type22.Optional(Type22.String({ description: "Absolute path to the reviewable QA end-to-end proof video recorded with domain-appropriate tooling for UI-applicable changes, when one was produced." })),
72331
+ pr_report: Type22.Optional(Type22.String({ description: "Pull-request report emitted only when create_pr=true and the final pull-request stage runs." })),
72332
+ approved: Type22.Optional(Type22.Boolean({ description: "Whether the reviewer loop approved before completion or optional final handoff." })),
72333
+ iterations_completed: Type22.Optional(Type22.Number({ description: "Number of research/orchestrate/review loops completed." })),
72334
+ review_report: Type22.Optional(Type22.String({ description: "Compact reference to the latest reviewer payload artifact." })),
72335
+ review_report_path: Type22.Optional(Type22.String({ description: "JSON artifact path for the latest review round." }))
71962
72336
  },
71963
72337
  worktreeFromInputs: {
71964
72338
  gitWorktreeDir: "git_worktree_dir",
@@ -72158,9 +72532,9 @@ var init_tournament_prompts = __esm(() => {
72158
72532
  });
72159
72533
 
72160
72534
  // dist/builtin/workflows/builtin/tournament-runner.ts
72161
- import { mkdir as mkdir5, readFile as readFile5, writeFile as writeFile9 } from "node:fs/promises";
72162
- import { join as join29, isAbsolute as isAbsolute12, relative as relative8, resolve as resolve14 } from "node:path";
72163
- import { Type as Type22 } from "typebox";
72535
+ import { mkdir as mkdir6, readFile as readFile6, writeFile as writeFile10 } from "node:fs/promises";
72536
+ import { join as join30, isAbsolute as isAbsolute12, relative as relative9, resolve as resolve14 } from "node:path";
72537
+ import { Type as Type23 } from "typebox";
72164
72538
  function serializableObject3(value2) {
72165
72539
  if (value2 === null || Array.isArray(value2) || typeof value2 !== "object")
72166
72540
  return;
@@ -72198,7 +72572,7 @@ function judgeArtifactPath(judgesDir, job, criterionIndex) {
72198
72572
  const filename = `judge-${job.a}-${job.b}-c${criterionIndex}-${criterionSlug(job.criterionId)}-r${job.rep}.json`;
72199
72573
  const root = resolve14(judgesDir);
72200
72574
  const path = resolve14(judgesDir, filename);
72201
- const fromRoot = relative8(root, path);
72575
+ const fromRoot = relative9(root, path);
72202
72576
  if (fromRoot.startsWith("..") || isAbsolute12(fromRoot)) {
72203
72577
  throw new Error(`tournament: judge artifact escaped its directory: ${path}`);
72204
72578
  }
@@ -72248,16 +72622,16 @@ function combineUsage(totals) {
72248
72622
  }
72249
72623
  async function runTournament(ctx) {
72250
72624
  const artifactDir = await stableArtifactRoot(ctx, "tournament");
72251
- const attemptsDir = join29(artifactDir, "attempts");
72625
+ const attemptsDir = join30(artifactDir, "attempts");
72252
72626
  const numAttempts = ctx.inputs.num_attempts ?? 4;
72253
72627
  const maxConcurrency = ctx.inputs.max_concurrency ?? 4;
72254
72628
  const nEvaluations = ctx.inputs.n_evaluations ?? 2;
72255
72629
  const pivotCount = ctx.inputs.pivots ?? 1;
72256
72630
  const seed = ctx.inputs.seed ?? 0;
72257
- const judgesDir = join29(artifactDir, "judges");
72258
- await mkdir5(attemptsDir, { recursive: true });
72259
- await mkdir5(judgesDir, { recursive: true });
72260
- const attemptArtifactPaths = Array.from({ length: numAttempts }, (_, index) => join29(attemptsDir, `attempt-${index + 1}.md`));
72631
+ const judgesDir = join30(artifactDir, "judges");
72632
+ await mkdir6(attemptsDir, { recursive: true });
72633
+ await mkdir6(judgesDir, { recursive: true });
72634
+ const attemptArtifactPaths = Array.from({ length: numAttempts }, (_, index) => join30(attemptsDir, `attempt-${index + 1}.md`));
72261
72635
  const models = ctx.inputs.models;
72262
72636
  const attemptResults = await ctx.parallel(attemptArtifactPaths.map((path, index) => ({
72263
72637
  name: `attempt-${index + 1}`,
@@ -72270,7 +72644,7 @@ async function runTournament(ctx) {
72270
72644
  const entrants = await Promise.all(attemptArtifactPaths.map(async (path, index) => ({
72271
72645
  label: `attempt-${index + 1}`,
72272
72646
  path,
72273
- body: await readFile5(path, "utf8")
72647
+ body: await readFile6(path, "utf8")
72274
72648
  })));
72275
72649
  const criteria = tournamentCriteria(ctx.inputs.criteria);
72276
72650
  const criterionIds = criteria.map((criterion) => criterion.id);
@@ -72341,7 +72715,7 @@ The previous report was invalid. Return the required JSON schema exactly once.`,
72341
72715
  report = judgeReport(retried.structured);
72342
72716
  }
72343
72717
  if (report === undefined) {
72344
- await writeFile9(stage.path, `${JSON.stringify({ invalid: true }, null, 2)}
72718
+ await writeFile10(stage.path, `${JSON.stringify({ invalid: true }, null, 2)}
72345
72719
  `);
72346
72720
  comparisons.push({
72347
72721
  a: stage.job.a,
@@ -72355,7 +72729,7 @@ The previous report was invalid. Return the required JSON schema exactly once.`,
72355
72729
  });
72356
72730
  continue;
72357
72731
  }
72358
- await writeFile9(stage.path, `${JSON.stringify(report, null, 2)}
72732
+ await writeFile10(stage.path, `${JSON.stringify(report, null, 2)}
72359
72733
  `);
72360
72734
  const scoreA = stage.job.swapped ? report.score_b : report.score_a;
72361
72735
  const scoreB = stage.job.swapped ? report.score_a : report.score_b;
@@ -72422,7 +72796,7 @@ The previous report was invalid. Return the required JSON schema exactly once.`,
72422
72796
  const outputRanking = ranking.map(({ label, meanPreference }) => ({ label, meanPreference }));
72423
72797
  const budgetPivots = Math.min(pivotCount, entrants.length);
72424
72798
  const comparisonBudget = (entrants.length + budgetPivots * (entrants.length - budgetPivots) + budgetPivots * (budgetPivots - 1) / 2) * criteria.length * nEvaluations;
72425
- const comparisonPath = join29(artifactDir, "comparisons.json");
72799
+ const comparisonPath = join30(artifactDir, "comparisons.json");
72426
72800
  const assignment = modelAssignment(entrants, models);
72427
72801
  const phaseUsage = {
72428
72802
  attempts: fold_usage(attemptResults),
@@ -72452,13 +72826,13 @@ The previous report was invalid. Return the required JSON schema exactly once.`,
72452
72826
  reducer: reducerUsage,
72453
72827
  total: combineUsage([phaseUsage.attempts, phaseUsage.ring, phaseUsage.pivots, reducerUsage])
72454
72828
  };
72455
- await writeFile9(comparisonPath, `${JSON.stringify({ ...baseLedger, usage }, null, 2)}
72829
+ await writeFile10(comparisonPath, `${JSON.stringify({ ...baseLedger, usage }, null, 2)}
72456
72830
  `);
72457
72831
  };
72458
72832
  await writeLedger(fold_usage([]));
72459
72833
  const winner = ranking[0];
72460
72834
  const winnerEntrant = entrants[winner.index];
72461
- const resultPath = join29(artifactDir, "winner.md");
72835
+ const resultPath = join30(artifactDir, "winner.md");
72462
72836
  const reducer = await ctx.task("comparisons-reducer", {
72463
72837
  prompt: renderComparisonsReducerPrompt({
72464
72838
  task: ctx.inputs.prompt,
@@ -72493,16 +72867,16 @@ var init_tournament_runner = __esm(() => {
72493
72867
  init_verification_criteria();
72494
72868
  init_tournament_prompts();
72495
72869
  init_pattern_artifact_root();
72496
- judgeScoreSchema = Type22.Object({
72497
- criterion_id: Type22.String(),
72498
- score_a: Type22.Integer({ minimum: VERIFICATION_SCALE.min, maximum: VERIFICATION_SCALE.max }),
72499
- score_b: Type22.Integer({ minimum: VERIFICATION_SCALE.min, maximum: VERIFICATION_SCALE.max }),
72500
- evidence: Type22.Array(Type22.String())
72870
+ judgeScoreSchema = Type23.Object({
72871
+ criterion_id: Type23.String(),
72872
+ score_a: Type23.Integer({ minimum: VERIFICATION_SCALE.min, maximum: VERIFICATION_SCALE.max }),
72873
+ score_b: Type23.Integer({ minimum: VERIFICATION_SCALE.min, maximum: VERIFICATION_SCALE.max }),
72874
+ evidence: Type23.Array(Type23.String())
72501
72875
  }, { additionalProperties: false });
72502
72876
  });
72503
72877
 
72504
72878
  // dist/builtin/workflows/builtin/tournament.ts
72505
- import { Type as Type23 } from "typebox";
72879
+ import { Type as Type24 } from "typebox";
72506
72880
  var tournament_default;
72507
72881
  var init_tournament = __esm(() => {
72508
72882
  init_workflow();
@@ -72513,63 +72887,63 @@ var init_tournament = __esm(() => {
72513
72887
  description: "Run independent whole-task attempts through a soft-scored pivot-pairing schedule and return an auditable ranking.",
72514
72888
  heartbeatIntervalMinutes: 15,
72515
72889
  inputs: {
72516
- prompt: Type23.String({ description: "Task every competing agent must attempt independently." }),
72517
- num_attempts: Type23.Integer({
72890
+ prompt: Type24.String({ description: "Task every competing agent must attempt independently." }),
72891
+ num_attempts: Type24.Integer({
72518
72892
  minimum: 2,
72519
72893
  maximum: 8,
72520
72894
  default: 4,
72521
72895
  description: "Number of independent whole-task attempts (2-8)."
72522
72896
  }),
72523
- max_concurrency: Type23.Integer({
72897
+ max_concurrency: Type24.Integer({
72524
72898
  minimum: 1,
72525
72899
  maximum: 8,
72526
72900
  default: 4,
72527
72901
  description: "Maximum simultaneously active attempts or pairwise judges (1-8)."
72528
72902
  }),
72529
- n_evaluations: Type23.Integer({
72903
+ n_evaluations: Type24.Integer({
72530
72904
  minimum: 1,
72531
72905
  default: 2,
72532
72906
  description: "Number of repeated evaluations per criterion and directed pair."
72533
72907
  }),
72534
- pivots: Type23.Integer({
72908
+ pivots: Type24.Integer({
72535
72909
  minimum: 1,
72536
72910
  default: 1,
72537
72911
  description: "Number of pivot candidates used for the second comparison phase."
72538
72912
  }),
72539
- seed: Type23.Integer({
72913
+ seed: Type24.Integer({
72540
72914
  default: 0,
72541
72915
  description: "Seed for the deterministic comparison schedule."
72542
72916
  }),
72543
- criteria: Type23.Optional(Type23.Union([
72544
- Type23.String(),
72545
- Type23.Record(Type23.String(), Type23.String()),
72546
- Type23.Array(Type23.String()),
72547
- Type23.Array(Type23.Object({
72548
- id: Type23.Optional(Type23.String()),
72549
- name: Type23.Optional(Type23.String()),
72550
- description: Type23.String()
72917
+ criteria: Type24.Optional(Type24.Union([
72918
+ Type24.String(),
72919
+ Type24.Record(Type24.String(), Type24.String()),
72920
+ Type24.Array(Type24.String()),
72921
+ Type24.Array(Type24.Object({
72922
+ id: Type24.Optional(Type24.String()),
72923
+ name: Type24.Optional(Type24.String()),
72924
+ description: Type24.String()
72551
72925
  }, { additionalProperties: true }))
72552
72926
  ], {
72553
72927
  description: "Optional V1 judge criteria; accepts a markdown rubric, record, string list, or CriterionInput list; omitted uses the default three-criterion rubric."
72554
72928
  })),
72555
- models: Type23.Optional(Type23.Array(Type23.String(), {
72929
+ models: Type24.Optional(Type24.Array(Type24.String(), {
72556
72930
  description: "Optional ordered model ids assigned round-robin to attempt slots."
72557
72931
  }))
72558
72932
  },
72559
72933
  outputs: {
72560
- result: Type23.String({ description: "Compact reference to the final reducer report; read `result_path` for the full report." }),
72561
- winner: Type23.String({ description: "Stable attempt label selected as the top-ranked tournament winner." }),
72562
- winner_artifact_path: Type23.String({ description: "Path to the original winning attempt artifact." }),
72563
- result_path: Type23.String({ description: "Path to the final reducer report artifact." }),
72564
- attempt_artifact_paths: Type23.Array(Type23.String(), { description: "Paths to every independent attempt artifact." }),
72565
- judge_artifact_paths: Type23.Array(Type23.String(), { description: "Paths to all per-job structured judge artifacts." }),
72566
- comparisons_path: Type23.String({ description: "Path to the durable JSON soft-scored comparisons ledger." }),
72567
- ranking: Type23.Array(Type23.Object({
72568
- label: Type23.String(),
72569
- meanPreference: Type23.Number()
72934
+ result: Type24.String({ description: "Compact reference to the final reducer report; read `result_path` for the full report." }),
72935
+ winner: Type24.String({ description: "Stable attempt label selected as the top-ranked tournament winner." }),
72936
+ winner_artifact_path: Type24.String({ description: "Path to the original winning attempt artifact." }),
72937
+ result_path: Type24.String({ description: "Path to the final reducer report artifact." }),
72938
+ attempt_artifact_paths: Type24.Array(Type24.String(), { description: "Paths to every independent attempt artifact." }),
72939
+ judge_artifact_paths: Type24.Array(Type24.String(), { description: "Paths to all per-job structured judge artifacts." }),
72940
+ comparisons_path: Type24.String({ description: "Path to the durable JSON soft-scored comparisons ledger." }),
72941
+ ranking: Type24.Array(Type24.Object({
72942
+ label: Type24.String(),
72943
+ meanPreference: Type24.Number()
72570
72944
  }, { additionalProperties: false }), { description: "All attempts ordered by mean preference." }),
72571
- seed: Type23.Integer({ description: "Seed used for the deterministic comparison schedule." }),
72572
- artifact_dir: Type23.String({ description: "Run-specific directory containing tournament artifacts." })
72945
+ seed: Type24.Integer({ description: "Seed used for the deterministic comparison schedule." }),
72946
+ artifact_dir: Type24.String({ description: "Run-specific directory containing tournament artifacts." })
72573
72947
  },
72574
72948
  run: async (ctx) => await runTournament(withBuiltinContext(ctx))
72575
72949
  });
@@ -72718,7 +73092,7 @@ var init_workflow_module_loader = __esm(() => {
72718
73092
 
72719
73093
  // dist/builtin/workflows/src/workers/definitions.ts
72720
73094
  import { createHash as createHash5 } from "node:crypto";
72721
- import { readFile as readFile6 } from "node:fs/promises";
73095
+ import { readFile as readFile7 } from "node:fs/promises";
72722
73096
  import { isAbsolute as isAbsolute13 } from "node:path";
72723
73097
  async function loadWorkerDefinition(source) {
72724
73098
  if (!isAbsolute13(source.path) || await definitionDigest(source.path) !== source.digest)
@@ -72735,7 +73109,7 @@ async function loadWorkerWorkflow(path, exportName = "default") {
72735
73109
  return loadWorkerDefinition({ path, exportName, digest: await definitionDigest(path) });
72736
73110
  }
72737
73111
  async function definitionDigest(path) {
72738
- return createHash5("sha256").update(await readFile6(path)).digest("hex");
73112
+ return createHash5("sha256").update(await readFile7(path)).digest("hex");
72739
73113
  }
72740
73114
  var workerDefinitionSources;
72741
73115
  var init_definitions = __esm(() => {
@@ -73662,7 +74036,7 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
73662
74036
  stageId: stage.id,
73663
74037
  stageName: stage.name,
73664
74038
  target: stageRouteTarget(lookups.runs, rootRunId, run.id, stage.id, lookups.segments),
73665
- lifecycle: stage.status === "waiting" || stage.sessionId === undefined && stage.sessionFile === undefined ? "pending" : "running",
74039
+ lifecycle: stage.status === "suspended" || stage.sessionId === undefined && stage.sessionFile === undefined ? "pending" : "running",
73666
74040
  routeEligible: stage.pendingStageDeliveryAvailable === true && isAddressableStageStatus(stage.status),
73667
74041
  group: stage.intercomGroup ?? workflowInvocationIntercomGroup(rootRunId)
73668
74042
  })),
@@ -73941,7 +74315,7 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
73941
74315
  target: payload.target
73942
74316
  };
73943
74317
  const stage = destination.stage;
73944
- const live = stage.status !== "waiting" && (stage.sessionId !== undefined || stage.sessionFile !== undefined);
74318
+ const live = stage.status !== "suspended" && (stage.sessionId !== undefined || stage.sessionFile !== undefined);
73945
74319
  const stageTerminal = stage.status === "completed" || stage.status === "skipped" || stage.status === "failed";
73946
74320
  if (payload.live !== true && live && !stageTerminal && externalRunRouteOwner(activeStore, destination.run.id)?.deliversQueued(destination.run.id, stage.id) === true) {
73947
74321
  payload.handled = true;
@@ -73949,7 +74323,7 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
73949
74323
  payload.completion = refusal === undefined ? queueAndPersist(activeStore, resolvedEvent, workflowInvocationIntercomGroup(rootRunId), true) : Promise.resolve({ outcome: "refused", reason: refusal });
73950
74324
  return;
73951
74325
  }
73952
- if (payload.live === true && stage.status !== "waiting" || live && !stageTerminal) {
74326
+ if (payload.live === true && stage.status !== "suspended" || live && !stageTerminal) {
73953
74327
  payload.handled = true;
73954
74328
  payload.completion = validateLiveDelivery(activeStore, resolvedEvent).then((result) => result.outcome === "forward" ? {
73955
74329
  outcome: "forward",
@@ -74301,7 +74675,7 @@ function knownUninitializedStage(run, stageKey) {
74301
74675
  if (candidates.length !== 1)
74302
74676
  return;
74303
74677
  const stage = candidates[0];
74304
- if (stage.status === "waiting")
74678
+ if (stage.status === "suspended")
74305
74679
  return stage;
74306
74680
  return isAddressableStageStatus(stage.status) && stage.sessionId === undefined && stage.sessionFile === undefined ? stage : undefined;
74307
74681
  }
@@ -74545,7 +74919,7 @@ var init_broker_status = __esm(() => {
74545
74919
 
74546
74920
  // dist/builtin/intercom/broker/paths.ts
74547
74921
  import { homedir as homedir2 } from "os";
74548
- import { join as join30 } from "path";
74922
+ import { join as join31 } from "path";
74549
74923
  function getHomeDir() {
74550
74924
  if (process.platform === "win32") {
74551
74925
  if (process.env.USERPROFILE)
@@ -74562,42 +74936,42 @@ function expandTildePath(path) {
74562
74936
  if (path === "~")
74563
74937
  return getHomeDir();
74564
74938
  if (path.startsWith("~/") || process.platform === "win32" && path.startsWith("~\\")) {
74565
- return join30(getHomeDir(), path.slice(2));
74939
+ return join31(getHomeDir(), path.slice(2));
74566
74940
  }
74567
74941
  return path;
74568
74942
  }
74569
- function getAgentDir5() {
74943
+ function getAgentDir6() {
74570
74944
  const atomicAgentDir = process.env.ATOMIC_CODING_AGENT_DIR;
74571
74945
  if (atomicAgentDir)
74572
74946
  return expandTildePath(atomicAgentDir);
74573
74947
  const piAgentDir = process.env.PI_CODING_AGENT_DIR;
74574
74948
  if (piAgentDir)
74575
74949
  return expandTildePath(piAgentDir);
74576
- return join30(getHomeDir(), ".atomic", "agent");
74950
+ return join31(getHomeDir(), ".atomic", "agent");
74577
74951
  }
74578
74952
  function sanitizePipeSegment(value2) {
74579
74953
  return value2.replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase() || "default";
74580
74954
  }
74581
- function getIntercomDirPath(agentDir = getAgentDir5()) {
74582
- return join30(agentDir, "intercom");
74955
+ function getIntercomDirPath(agentDir = getAgentDir6()) {
74956
+ return join31(agentDir, "intercom");
74583
74957
  }
74584
- function getBrokerPidPath(agentDir = getAgentDir5()) {
74585
- return join30(getIntercomDirPath(agentDir), "broker.pid");
74958
+ function getBrokerPidPath(agentDir = getAgentDir6()) {
74959
+ return join31(getIntercomDirPath(agentDir), "broker.pid");
74586
74960
  }
74587
- function getBrokerSpawnLockPath(agentDir = getAgentDir5()) {
74588
- return join30(getIntercomDirPath(agentDir), "broker.spawn.lock");
74961
+ function getBrokerSpawnLockPath(agentDir = getAgentDir6()) {
74962
+ return join31(getIntercomDirPath(agentDir), "broker.spawn.lock");
74589
74963
  }
74590
- function getBrokerLogPath(agentDir = getAgentDir5()) {
74591
- return join30(getIntercomDirPath(agentDir), "broker.log");
74964
+ function getBrokerLogPath(agentDir = getAgentDir6()) {
74965
+ return join31(getIntercomDirPath(agentDir), "broker.log");
74592
74966
  }
74593
- function getBrokerStartAnnouncementPath(agentDir = getAgentDir5()) {
74594
- return join30(getIntercomDirPath(agentDir), "broker.starting");
74967
+ function getBrokerStartAnnouncementPath(agentDir = getAgentDir6()) {
74968
+ return join31(getIntercomDirPath(agentDir), "broker.starting");
74595
74969
  }
74596
- function getBrokerSocketPath(platform = process.platform, agentDir = getAgentDir5()) {
74970
+ function getBrokerSocketPath(platform = process.platform, agentDir = getAgentDir6()) {
74597
74971
  if (platform === "win32") {
74598
74972
  return `\\\\.\\pipe\\pi-intercom-${sanitizePipeSegment(agentDir)}`;
74599
74973
  }
74600
- return join30(getIntercomDirPath(agentDir), "broker.sock");
74974
+ return join31(getIntercomDirPath(agentDir), "broker.sock");
74601
74975
  }
74602
74976
  var BROKER_STORAGE_ENV = "ATOMIC_STORAGE";
74603
74977
  var init_paths = () => {};
@@ -76771,8 +77145,8 @@ var init_shared_storage_setting = __esm(() => {
76771
77145
  // dist/builtin/intercom/broker/spawn.ts
76772
77146
  import { spawn } from "child_process";
76773
77147
  import { randomUUID as randomUUID16 } from "crypto";
76774
- import { appendFileSync, chmodSync, closeSync as closeSync4, existsSync as existsSync9, mkdirSync as mkdirSync9, openSync as openSync4, readFileSync as readFileSync7, readSync as readSync2, renameSync, statSync as statSync6, unlinkSync as unlinkSync4, writeFileSync as writeFileSync6 } from "fs";
76775
- import { join as join31, dirname as dirname14 } from "path";
77148
+ import { appendFileSync, chmodSync, closeSync as closeSync4, existsSync as existsSync10, mkdirSync as mkdirSync9, openSync as openSync4, readFileSync as readFileSync7, readSync as readSync2, renameSync, statSync as statSync6, unlinkSync as unlinkSync4, writeFileSync as writeFileSync6 } from "fs";
77149
+ import { join as join32, dirname as dirname16 } from "path";
76776
77150
  import { fileURLToPath as fileURLToPath5 } from "url";
76777
77151
  import { createRequire as createRequire3 } from "module";
76778
77152
  import {
@@ -76783,17 +77157,17 @@ import {
76783
77157
  processSharedStorageSelection
76784
77158
  } from "@bastani/atomic";
76785
77159
  function isIntercomPackageRoot(dir) {
76786
- return existsSync9(join31(dir, "package.json")) && existsSync9(join31(dir, "broker"));
77160
+ return existsSync10(join32(dir, "package.json")) && existsSync10(join32(dir, "broker"));
76787
77161
  }
76788
77162
  function resolveIntercomPackageRoot(moduleHref) {
76789
- const here = dirname14(fileURLToPath5(moduleHref));
77163
+ const here = dirname16(fileURLToPath5(moduleHref));
76790
77164
  if (isIntercomPackageRoot(here))
76791
77165
  return here;
76792
- return join31(here, "..");
77166
+ return join32(here, "..");
76793
77167
  }
76794
77168
  function resolveBrokerEntrypoint(packageRoot) {
76795
- const bundled = join31(packageRoot, "broker", "broker.bundle.mjs");
76796
- return existsSync9(bundled) ? bundled : join31(packageRoot, "broker", "broker.ts");
77169
+ const bundled = join32(packageRoot, "broker", "broker.bundle.mjs");
77170
+ return existsSync10(bundled) ? bundled : join32(packageRoot, "broker", "broker.ts");
76797
77171
  }
76798
77172
  function ensurePrivateDirectory(path) {
76799
77173
  mkdirSync9(path, { recursive: true, mode: 448 });
@@ -76809,14 +77183,14 @@ function getCurrentBrokerRuntime() {
76809
77183
  return isBunBinary ? "bun-binary" : "bun-source";
76810
77184
  }
76811
77185
  function requireFromExtensionDir(extensionDir) {
76812
- return createRequire3(join31(extensionDir, "package.json"));
77186
+ return createRequire3(join32(extensionDir, "package.json"));
76813
77187
  }
76814
77188
  function getJitiCliPath(extensionDir = EXTENSION_DIR) {
76815
77189
  try {
76816
77190
  const jitiPackage = requireFromExtensionDir(extensionDir).resolve("jiti/package.json");
76817
- return join31(dirname14(jitiPackage), "lib", "jiti-cli.mjs");
77191
+ return join32(dirname16(jitiPackage), "lib", "jiti-cli.mjs");
76818
77192
  } catch {
76819
- return join31(extensionDir, "node_modules", "jiti", "lib", "jiti-cli.mjs");
77193
+ return join32(extensionDir, "node_modules", "jiti", "lib", "jiti-cli.mjs");
76820
77194
  }
76821
77195
  }
76822
77196
  function getDefaultBrokerRunnerPath(extensionDir) {
@@ -76838,7 +77212,7 @@ function quoteWindowsArg(value2) {
76838
77212
  return `"${value2.replace(/"/g, '""')}"`;
76839
77213
  }
76840
77214
  function getWindowsHiddenLauncherPath(intercomDir = getIntercomDirPath()) {
76841
- return join31(intercomDir, "broker-launch.vbs");
77215
+ return join32(intercomDir, "broker-launch.vbs");
76842
77216
  }
76843
77217
  function usesDefaultBrokerCommand(brokerCommand, brokerArgs) {
76844
77218
  return brokerCommand === "npx" && brokerArgs.length === 2 && brokerArgs[0] === "--no-install" && brokerArgs[1] === "tsx";
@@ -76865,7 +77239,7 @@ function getWindowsHiddenLauncherScript(commandLine) {
76865
77239
  `);
76866
77240
  }
76867
77241
  function writeWindowsHiddenLauncher(commandLine, launcherPath = getWindowsHiddenLauncherPath()) {
76868
- ensurePrivateDirectory(dirname14(launcherPath));
77242
+ ensurePrivateDirectory(dirname16(launcherPath));
76869
77243
  writeFileSync6(launcherPath, getWindowsHiddenLauncherScript(commandLine), "utf-8");
76870
77244
  return launcherPath;
76871
77245
  }
@@ -76909,7 +77283,7 @@ function getBrokerSpawnOptions(extensionDir = EXTENSION_DIR, stderr = "ignore",
76909
77283
  };
76910
77284
  }
76911
77285
  function resetBrokerLog(logPath = getBrokerLogPath()) {
76912
- ensurePrivateDirectory(dirname14(logPath));
77286
+ ensurePrivateDirectory(dirname16(logPath));
76913
77287
  try {
76914
77288
  const previous = readBrokerLogTail(logPath);
76915
77289
  closeSync4(openSync4(logPath, "w"));
@@ -77060,7 +77434,7 @@ async function isBrokerRunning() {
77060
77434
  if (await checkSocketConnectable()) {
77061
77435
  return true;
77062
77436
  }
77063
- if (!existsSync9(getBrokerPidPath()))
77437
+ if (!existsSync10(getBrokerPidPath()))
77064
77438
  return false;
77065
77439
  try {
77066
77440
  const pid = parseInt(readFileSync7(getBrokerPidPath(), "utf-8").trim(), 10);
@@ -77126,7 +77500,7 @@ function isProcessAlive(pid) {
77126
77500
  }
77127
77501
  }
77128
77502
  function isSpawnLockStale(lockPath = getBrokerSpawnLockPath(), nowMs = Date.now()) {
77129
- if (!existsSync9(lockPath)) {
77503
+ if (!existsSync10(lockPath)) {
77130
77504
  return false;
77131
77505
  }
77132
77506
  try {
@@ -77253,10 +77627,10 @@ var init_reply_waiter = __esm(() => {
77253
77627
  });
77254
77628
 
77255
77629
  // dist/builtin/intercom/config.ts
77256
- import { existsSync as existsSync10, readFileSync as readFileSync8 } from "fs";
77630
+ import { existsSync as existsSync11, readFileSync as readFileSync8 } from "fs";
77257
77631
  import { getAgentConfigPaths } from "@bastani/atomic";
77258
77632
  function loadConfig() {
77259
- if (!existsSync10(CONFIG_PATH)) {
77633
+ if (!existsSync11(CONFIG_PATH)) {
77260
77634
  return { ...defaults };
77261
77635
  }
77262
77636
  try {
@@ -77338,7 +77712,7 @@ var init_config = __esm(() => {
77338
77712
  init_diagnostics();
77339
77713
  init_reply_waiter();
77340
77714
  CONFIG_PATHS = getAgentConfigPaths("intercom", "config.json");
77341
- CONFIG_PATH = CONFIG_PATHS.find((path) => existsSync10(path)) ?? CONFIG_PATHS[0];
77715
+ CONFIG_PATH = CONFIG_PATHS.find((path) => existsSync11(path)) ?? CONFIG_PATHS[0];
77342
77716
  DEFAULT_BROKER_ARGS = ["--no-install", "tsx"];
77343
77717
  defaults = {
77344
77718
  brokerCommand: DEFAULT_BROKER_COMMAND,
@@ -78691,14 +79065,14 @@ var UNATTRIBUTED_WRITE = "other";
78691
79065
  var init_pool_coordination_stats = () => {};
78692
79066
 
78693
79067
  // dist/builtin/workflows/src/workers/pooled-watch-trace.ts
78694
- import { dirname as dirname15, join as join32, resolve as resolve15 } from "node:path";
79068
+ import { dirname as dirname17, join as join33, resolve as resolve15 } from "node:path";
78695
79069
  import { appendDebugRecord, isDebugEnabled as isDebugEnabled2, reportDebug } from "@bastani/atomic";
78696
79070
  function configurePooledWatchTrace(journal, processRole) {
78697
79071
  journalPath = journal;
78698
79072
  role = processRole;
78699
79073
  }
78700
79074
  function ownTraceFile(journal, setting) {
78701
- return setting === "1" ? join32(dirname15(resolve15(journal)), "pooled-watch-trace.jsonl") : resolve15(setting);
79075
+ return setting === "1" ? join33(dirname17(resolve15(journal)), "pooled-watch-trace.jsonl") : resolve15(setting);
78702
79076
  }
78703
79077
  function tracePooledWatch(step, detail) {
78704
79078
  if (!isDebugEnabled2("pooled-watch"))
@@ -78719,7 +79093,7 @@ var init_pooled_watch_trace = () => {};
78719
79093
  // dist/builtin/workflows/src/workers/process-log.ts
78720
79094
  import { createWriteStream, mkdirSync as mkdirSync10 } from "node:fs";
78721
79095
  import { rm as rm3, rmdir } from "node:fs/promises";
78722
- import { dirname as dirname16 } from "node:path";
79096
+ import { dirname as dirname18 } from "node:path";
78723
79097
  function logFailureOf(error) {
78724
79098
  const code = error.code;
78725
79099
  return typeof code === "string" ? code : error.name;
@@ -78756,7 +79130,7 @@ function appendProcessLog(stderr, logPath, onFailure) {
78756
79130
  return { close };
78757
79131
  stderr.on("error", fail);
78758
79132
  try {
78759
- mkdirSync10(dirname16(logPath), { recursive: true });
79133
+ mkdirSync10(dirname18(logPath), { recursive: true });
78760
79134
  } catch (error) {
78761
79135
  fail(asError(error));
78762
79136
  return { close };
@@ -78768,7 +79142,7 @@ function appendProcessLog(stderr, logPath, onFailure) {
78768
79142
  }
78769
79143
  async function removeProcessLog(logPath) {
78770
79144
  await rm3(logPath, { force: true });
78771
- await rmdir(dirname16(logPath)).catch((error) => {
79145
+ await rmdir(dirname18(logPath)).catch((error) => {
78772
79146
  const code = error.code;
78773
79147
  if (code !== "ENOENT" && code !== "ENOTEMPTY" && code !== "EEXIST")
78774
79148
  throw error;
@@ -79438,9 +79812,9 @@ var init_worker_timing = __esm(() => {
79438
79812
  // dist/builtin/workflows/src/workers/pool-coordinator.ts
79439
79813
  import { fork } from "node:child_process";
79440
79814
  import { randomUUID as randomUUID18 } from "node:crypto";
79441
- import { existsSync as existsSync11 } from "node:fs";
79442
- import { appendFile, mkdir as mkdir6, rm as rm4, rmdir as rmdir2 } from "node:fs/promises";
79443
- import { delimiter, dirname as dirname17, isAbsolute as isAbsolute14, join as join33, resolve as resolve16 } from "node:path";
79815
+ import { existsSync as existsSync12 } from "node:fs";
79816
+ import { appendFile, mkdir as mkdir7, rm as rm4, rmdir as rmdir2 } from "node:fs/promises";
79817
+ import { delimiter, dirname as dirname19, isAbsolute as isAbsolute14, join as join34, resolve as resolve16 } from "node:path";
79444
79818
  import { setTimeout as delay4 } from "node:timers/promises";
79445
79819
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
79446
79820
  import { setDebugSetting } from "@bastani/atomic";
@@ -79449,10 +79823,10 @@ function unconfirmedCleanup(groups) {
79449
79823
  return new WorkerCleanupUnconfirmedError({ processGroups: groups });
79450
79824
  }
79451
79825
  function workerLogDirectory(journalPath, root) {
79452
- return join33(dirname17(resolve16(journalPath)), "worker-logs", encodeURIComponent(root).replaceAll(".", "%2E"));
79826
+ return join34(dirname19(resolve16(journalPath)), "worker-logs", encodeURIComponent(root).replaceAll(".", "%2E"));
79453
79827
  }
79454
79828
  function traceAnchor(options) {
79455
- return options.shared === undefined ? options.journalPath : join33(options.shared.stateDirectory, "shared-pool");
79829
+ return options.shared === undefined ? options.journalPath : join34(options.shared.stateDirectory, "shared-pool");
79456
79830
  }
79457
79831
  function token(work) {
79458
79832
  return {
@@ -79900,7 +80274,7 @@ class PoolCoordinator {
79900
80274
  if (options.shared !== undefined)
79901
80275
  this.journal ??= await this.countedJournal(await openDurableJournal(options.durable));
79902
80276
  else {
79903
- if (options.journalShard !== undefined && !existsSync11(options.journalPath))
80277
+ if (options.journalShard !== undefined && !existsSync12(options.journalPath))
79904
80278
  throw new JournalShardUnavailableError2({
79905
80279
  code: "shard-missing",
79906
80280
  shardId: options.journalShard,
@@ -80135,7 +80509,7 @@ class PoolCoordinator {
80135
80509
  crossHost: true
80136
80510
  });
80137
80511
  this.logDirectory = workerLogDirectory(traceAnchor(this.options), root);
80138
- await mkdir6(this.logDirectory, { recursive: true });
80512
+ await mkdir7(this.logDirectory, { recursive: true });
80139
80513
  if (this.closed)
80140
80514
  return;
80141
80515
  this.starting = Promise.resolve();
@@ -80246,7 +80620,7 @@ class PoolCoordinator {
80246
80620
  this.activityCursor = Math.max(this.activityCursor, entry.version);
80247
80621
  if (local.has(entry.work.id) || !this.attemptBase.has(entry.work.id))
80248
80622
  continue;
80249
- const runs = JSON.parse(entry.runs);
80623
+ const runs = runSnapshotsFromRecord(JSON.parse(entry.runs));
80250
80624
  this.pendingActivity.set(entry.work.id, { work: entry.work, runs });
80251
80625
  for (const [id, reason] of this.remoteWatches.relayed(entry.work, runs))
80252
80626
  this.endRemoteWatch(id, reason);
@@ -80873,7 +81247,7 @@ class PoolCoordinator {
80873
81247
  let ready = false;
80874
81248
  const lanes = new WorkerRequestLanes;
80875
81249
  const extensions = new AttemptLeaseExtensions(slot, (attempt) => this.queue.extend(this.lease, attempt, options.leaseMs));
80876
- const logPath = join33(this.logDirectory, `${id}.log`);
81250
+ const logPath = join34(this.logDirectory, `${id}.log`);
80877
81251
  this.logs.set(child, logPath);
80878
81252
  appendProcessLog(child.stderr, logPath, (failure) => this.logUnwritable(logPath, failure));
80879
81253
  const startupTimeoutMs = options.startupTimeoutMs;
@@ -81666,7 +82040,7 @@ function withHostGit(env, git) {
81666
82040
  return {
81667
82041
  ...env,
81668
82042
  ...git.env,
81669
- ...isAbsolute14(git.path) ? { [pathKey]: [dirname17(git.path), env[pathKey]].filter(Boolean).join(delimiter) } : {}
82043
+ ...isAbsolute14(git.path) ? { [pathKey]: [dirname19(git.path), env[pathKey]].filter(Boolean).join(delimiter) } : {}
81670
82044
  };
81671
82045
  }
81672
82046
  var CONTROL_ACKNOWLEDGEMENT_STALL_MS = 5000, RECOVERY_INTERVAL_MS = 500, TICK_INTERVAL_MS = 100, STALL_THRESHOLD_MS = 500, COORDINATOR_LEASE_MS, LATE_ROOT_POLL_MS, MIRROR_INTERVAL_MS = 1e4, STDERR_DRAIN_GRACE_MS = 1000, WORKER_EXIT_CONFIRMATION_MS = 5000, WORKER_EXIT_POLL_MS = 50, MAX_CHILD_ATTEMPTS = 3, PLACEMENT_CANDIDATES = 32, PREFERENCE_CACHE_MS = 1000, PREFERENCE_CACHE_ENTRIES = 256, SHARED_POLL_MS = 500, SHARED_IDLE_CLAIM_MS = 500, STAGE_INPUT_LEASE_MS = 30000, STAGE_INPUT_RECEIPT_TIMEOUT_MS = 60000, STAGE_INPUT_RETRY_MAX_MS = 4000, WORKER_HOST_TTL_MS = 15000, MAX_WORKER_REPLACEMENTS = 3, ROUTE_REGISTRATION_WAIT_MS = 120000, STAGE_WATCH_BACKLOG_EVENTS = 2000, STAGE_WATCH_BACKLOG_BYTES, PENDING_STAGE_MESSAGE_EVENT2 = "atomic:workflow-pending-stage-message", STICKY_LIVE_DELIVERED_EVENT2 = "atomic:workflow-sticky-live-delivered", PENDING_STAGE_UNDELIVERABLE_EVENT2 = "atomic:workflow-pending-stage-undeliverable", ENDED_WATCHES_REMEMBERED = 1024;
@@ -81763,7 +82137,7 @@ function remoteStageDrainTargets(generation, runs, queueOf, rootQueue) {
81763
82137
  for (const stage of run.stages) {
81764
82138
  const target = { runId: run.id, stageId: stage.id };
81765
82139
  const { sessionId } = stage;
81766
- if (sessionId === undefined || stage.status === "waiting" || stage.pendingStageDeliveryAvailable !== true || isTerminalStageStatus(stage.status))
82140
+ if (sessionId === undefined || stage.status === "suspended" || stage.pendingStageDeliveryAvailable !== true || isTerminalStageStatus(stage.status))
81767
82141
  forget.push(target);
81768
82142
  else
81769
82143
  drain.push({ target: { ...target, sessionId, generation, queues }, stageName: stage.name });
@@ -84014,14 +84388,14 @@ class PooledStageRegistrations {
84014
84388
  var LIVE;
84015
84389
  var init_pooled_stage_registry = __esm(() => {
84016
84390
  init_stage_queued_user_messages();
84017
- LIVE = new Set(["running", "awaiting_input", "paused", "blocked", "waiting"]);
84391
+ LIVE = new Set(["running", "awaiting_input", "paused", "blocked", "suspended"]);
84018
84392
  });
84019
84393
 
84020
84394
  // dist/builtin/workflows/src/workers/local-pool.ts
84021
84395
  import { fork as fork2 } from "node:child_process";
84022
84396
  import { randomUUID as randomUUID20 } from "node:crypto";
84023
- import { existsSync as existsSync12 } from "node:fs";
84024
- import { join as join34, resolve as resolve17 } from "node:path";
84397
+ import { existsSync as existsSync13 } from "node:fs";
84398
+ import { join as join35, resolve as resolve17 } from "node:path";
84025
84399
  import { setTimeout as delay5 } from "node:timers/promises";
84026
84400
  import { fileURLToPath as fileURLToPath6 } from "node:url";
84027
84401
  import {
@@ -84227,7 +84601,7 @@ class LocalWorkerPool {
84227
84601
  this.options = options;
84228
84602
  if (options.shared === undefined ? options.journalPath === undefined : options.durable === undefined)
84229
84603
  throw new WorkerPlacementConfigError("sdk", options.shared === undefined ? "journalPath" : "durable", "invalid-option", "a local worker pool needs the database its tables are in");
84230
- configurePooledWatchTrace(options.shared === undefined ? options.journalPath : join34(options.shared.stateDirectory, "shared-pool"), "root");
84604
+ configurePooledWatchTrace(options.shared === undefined ? options.journalPath : join35(options.shared.stateDirectory, "shared-pool"), "root");
84231
84605
  if (!Number.isSafeInteger(options.workers) || options.workers < 1)
84232
84606
  throw new Error("Invalid local worker count");
84233
84607
  if (options.startupTimeoutMs !== undefined && (!Number.isSafeInteger(options.startupTimeoutMs) || options.startupTimeoutMs < 1 || options.startupTimeoutMs > MAX_TIMER_DELAY_MS))
@@ -84265,7 +84639,7 @@ class LocalWorkerPool {
84265
84639
  async prepare(root, store) {
84266
84640
  if (this.closed)
84267
84641
  throw new Error("Local worker pool is closed");
84268
- if (this.options.journalShard !== undefined && !existsSync12(this.options.journalPath))
84642
+ if (this.options.journalShard !== undefined && !existsSync13(this.options.journalPath))
84269
84643
  throw new JournalShardUnavailableError3({
84270
84644
  code: "shard-missing",
84271
84645
  shardId: this.options.journalShard,
@@ -85047,7 +85421,7 @@ class LocalWorkerPool {
85047
85421
  const root = this.root;
85048
85422
  if (root === undefined)
85049
85423
  throw new PoolNotInitializedError({});
85050
- const coordinator = this.options.coordinator === "in-process" ? launchCoordinatorInProcess() : launchCoordinatorProcess(join34(workerLogDirectory(traceAnchor(this.options), root), "coordinator.log"));
85424
+ const coordinator = this.options.coordinator === "in-process" ? launchCoordinatorInProcess() : launchCoordinatorProcess(join35(workerLogDirectory(traceAnchor(this.options), root), "coordinator.log"));
85051
85425
  this.coordinator = coordinator;
85052
85426
  const outbox = new RateLimitObservationOutbox((observations) => coordinator.port.send({ kind: "rate-limits", observations }));
85053
85427
  const unobserve = observeProviderRateLimits((observation) => outbox.offer(observation));
@@ -85736,8 +86110,8 @@ var init_public_pool = __esm(() => {
85736
86110
  // dist/builtin/workflows/src/workers/shared-setup.ts
85737
86111
  import { constants } from "node:fs";
85738
86112
  import { access } from "node:fs/promises";
85739
- import { dirname as dirname18, isAbsolute as isAbsolute15, join as join35 } from "node:path";
85740
- import { getAgentDir as getAgentDir6, SettingsManager as SettingsManager2 } from "@bastani/atomic";
86113
+ import { dirname as dirname20, isAbsolute as isAbsolute15, join as join36 } from "node:path";
86114
+ import { getAgentDir as getAgentDir7, SettingsManager as SettingsManager2 } from "@bastani/atomic";
85741
86115
  import {
85742
86116
  loadStorageAdapter,
85743
86117
  StorageAdapterLoadError,
@@ -85773,13 +86147,13 @@ async function sharedSelectionProblems(selection, agentDir) {
85773
86147
  if ("env" in ref) {
85774
86148
  if (process.env[ref.env] === undefined)
85775
86149
  problems.push(sharedPoolProblems.secretUnavailable(secret, ref));
85776
- } else if ("file" in ref && !await readable(isAbsolute15(ref.file) ? ref.file : join35(dirname18(agentDir), ref.file)))
86150
+ } else if ("file" in ref && !await readable(isAbsolute15(ref.file) ? ref.file : join36(dirname20(agentDir), ref.file)))
85777
86151
  problems.push(sharedPoolProblems.secretUnavailable(secret, ref));
85778
86152
  }
85779
86153
  return problems;
85780
86154
  }
85781
86155
  async function checkSharedPlacementSetup(journal, options = {}) {
85782
- const agentDir = options.agentDir ?? getAgentDir6();
86156
+ const agentDir = options.agentDir ?? getAgentDir7();
85783
86157
  const problems = await sharedSelectionProblems(sharedJournalSelection(journal, { agentDir, ...options.cwd === undefined ? {} : { cwd: options.cwd } }), agentDir);
85784
86158
  if (!await processContainmentAvailable())
85785
86159
  problems.push(sharedPoolProblems.processContainmentUnavailable());
@@ -87907,7 +88281,7 @@ function waitForStageStartup(operation, signal) {
87907
88281
  import {
87908
88282
  AutoRoutingInferenceError,
87909
88283
  convertToLlm,
87910
- currentWorktreeRootMappings,
88284
+ currentWorktreeRootMappings as currentWorktreeRootMappings2,
87911
88285
  findToolDetachmentError,
87912
88286
  isExtensionStartupFailure,
87913
88287
  isTaskCleanupError as isTaskCleanupError2,
@@ -88058,7 +88432,7 @@ class StageSessionController {
88058
88432
  pauseControl = new StageSessionPause(() => this.session ?? this.residencyState?.replacement.retiringSession);
88059
88433
  residencyState;
88060
88434
  hasExplicitModelFallbackConfig;
88061
- runWorktreeRootMappings = currentWorktreeRootMappings();
88435
+ runWorktreeRootMappings = currentWorktreeRootMappings2();
88062
88436
  candidatesPromise;
88063
88437
  scopedModelsPromise;
88064
88438
  modelRoute;
@@ -90501,8 +90875,8 @@ var init_stage_runner_controller = __esm(() => {
90501
90875
 
90502
90876
  // dist/builtin/workflows/src/runs/foreground/stage-runner-output.ts
90503
90877
  import { createHash as createHash6 } from "node:crypto";
90504
- import { mkdir as mkdir7, writeFile as writeFile10 } from "node:fs/promises";
90505
- import { basename as basename5, dirname as dirname19, isAbsolute as isAbsolute16, join as join36, resolve as resolve19 } from "node:path";
90878
+ import { mkdir as mkdir8, writeFile as writeFile11 } from "node:fs/promises";
90879
+ import { basename as basename5, dirname as dirname21, isAbsolute as isAbsolute16, join as join37, resolve as resolve19 } from "node:path";
90506
90880
  function normalizeMaxOutput2(maxOutput) {
90507
90881
  return {
90508
90882
  bytes: maxOutput?.bytes ?? DEFAULT_MAX_OUTPUT_BYTES,
@@ -90565,7 +90939,7 @@ function formatByteSize(bytes) {
90565
90939
  }
90566
90940
  function transcriptPath(runId, outputPath) {
90567
90941
  const digest = createHash6("sha256").update(outputPath).digest("hex").slice(0, 16);
90568
- return join36(workflowArtifactRunPath(runId), "transcripts", `${digest}-${basename5(outputPath)}.transcript.md`);
90942
+ return join37(workflowArtifactRunPath(runId), "transcripts", `${digest}-${basename5(outputPath)}.transcript.md`);
90569
90943
  }
90570
90944
  function appendContent(lines, content) {
90571
90945
  if (typeof content === "string") {
@@ -90686,8 +91060,8 @@ async function finalizePromptOutput(fullOutput, outputOptions, runtimeCwd, runId
90686
91060
  const transcriptFile = transcriptPath(runId, outputPath);
90687
91061
  const transcript = renderTranscript(messages, fullOutput);
90688
91062
  try {
90689
- await mkdir7(dirname19(outputPath), { recursive: true });
90690
- await writeFile10(outputPath, fullOutput, "utf8");
91063
+ await mkdir8(dirname21(outputPath), { recursive: true });
91064
+ await writeFile11(outputPath, fullOutput, "utf8");
90691
91065
  } catch (err) {
90692
91066
  return `${displayOutput}
90693
91067
 
@@ -90698,8 +91072,8 @@ ${err instanceof Error ? err.message : String(err)}`;
90698
91072
  let transcriptError;
90699
91073
  try {
90700
91074
  await ensureWorkflowArtifactRunDirectory(runId);
90701
- await mkdir7(dirname19(transcriptFile), { recursive: true });
90702
- await writeFile10(transcriptFile, transcript, "utf8");
91075
+ await mkdir8(dirname21(transcriptFile), { recursive: true });
91076
+ await writeFile11(transcriptFile, transcript, "utf8");
90703
91077
  transcriptAvailable = true;
90704
91078
  } catch (err) {
90705
91079
  transcriptError = err instanceof Error ? err.message : String(err);
@@ -91936,7 +92310,7 @@ var init_child_workflow_failure_message = __esm(() => {
91936
92310
  });
91937
92311
 
91938
92312
  // dist/builtin/workflows/src/engine/primitives/workflow.ts
91939
- import { existsSync as existsSync13 } from "node:fs";
92313
+ import { existsSync as existsSync14 } from "node:fs";
91940
92314
  import {
91941
92315
  acquireWorkspaceWriterLease,
91942
92316
  isBoundWorkspace as isBoundWorkspace4,
@@ -92128,7 +92502,7 @@ async function bindChildWorkspace(workspace, invocation, signal, owner, restored
92128
92502
  binding = recorded;
92129
92503
  } catch (error) {
92130
92504
  const worktree = mapWorkflowWorktreePath(recorded.worktree, restored);
92131
- if (!isWorkspaceRestoreError(error) || worktree === recorded.worktree || existsSync13(recorded.worktree))
92505
+ if (!isWorkspaceRestoreError(error) || worktree === recorded.worktree || existsSync14(recorded.worktree))
92132
92506
  throw error;
92133
92507
  binding = { ...recorded, worktree };
92134
92508
  }
@@ -94434,7 +94808,7 @@ function createStageControlHandle(runtime) {
94434
94808
  readinessPauseVersion = (runtime.state.readinessPauseVersion ?? 0) + 1;
94435
94809
  runtime.state.readinessPauseVersion = readinessPauseVersion;
94436
94810
  }
94437
- if (statusBeforePause === "pending" || statusBeforePause === "running" || statusBeforePause === "waiting" || runtime.innerCtx.isStreaming) {
94811
+ if (statusBeforePause === "pending" || statusBeforePause === "running" || statusBeforePause === "suspended" || runtime.innerCtx.isStreaming) {
94438
94812
  try {
94439
94813
  await runtime.innerCtx.__requestPause();
94440
94814
  } catch (error) {
@@ -94899,14 +95273,14 @@ function createWorkflowStageFactory(input) {
94899
95273
  return;
94900
95274
  statusBeforeRelease = wait.kind !== "tool" || stageSnapshot.status === "completed" || stageSnapshot.status === "failed" ? stageSnapshot.status : undefined;
94901
95275
  if (stageSnapshot.status !== "paused")
94902
- stageSnapshot.status = "waiting";
95276
+ stageSnapshot.status = "suspended";
94903
95277
  if (wait.kind !== "tool")
94904
95278
  idleReleaser.trackReleased(stageId, settleReleased);
94905
95279
  };
94906
95280
  const settleReleased = () => {
94907
95281
  shownWait = undefined;
94908
95282
  delete stageSnapshot.wait;
94909
- if (stageSnapshot.status === "waiting")
95283
+ if (stageSnapshot.status === "suspended")
94910
95284
  stageSnapshot.status = statusBeforeRelease ?? "completed";
94911
95285
  input.activeStore.recordStageStart(input.runId, stageSnapshot);
94912
95286
  };
@@ -94988,7 +95362,7 @@ function createWorkflowStageFactory(input) {
94988
95362
  }
94989
95363
  runtime.abortListeners.attach();
94990
95364
  delete stageSnapshot.wait;
94991
- if (stageSnapshot.status === "waiting")
95365
+ if (stageSnapshot.status === "suspended")
94992
95366
  stageSnapshot.status = statusBeforeRelease ?? "running";
94993
95367
  statusBeforeRelease = undefined;
94994
95368
  input.activeStore.recordStageStart(input.runId, stageSnapshot);
@@ -95292,7 +95666,7 @@ function createWorkflowStageFactory(input) {
95292
95666
  await dropStageControlForCompletion();
95293
95667
  if (shownWait !== undefined) {
95294
95668
  statusBeforeRelease = "completed";
95295
- stageSnapshot.status = "waiting";
95669
+ stageSnapshot.status = "suspended";
95296
95670
  input.activeStore.recordStageStart(input.runId, stageSnapshot);
95297
95671
  }
95298
95672
  return recorded;
@@ -95697,7 +96071,7 @@ import {
95697
96071
  formatWorktreeRestoreWarning,
95698
96072
  resolveWorktreeSnapshotSettings,
95699
96073
  scheduleSnapshotCollection,
95700
- setUpRestoredRunWorktrees,
96074
+ setUpResumedRunWorktrees,
95701
96075
  withWorktreeRootMappings as withWorktreeRootMappings3
95702
96076
  } from "@bastani/atomic";
95703
96077
  async function run(def, inputs, opts = {}) {
@@ -95762,15 +96136,27 @@ async function run(def, inputs, opts = {}) {
95762
96136
  createdAt: Date.now()
95763
96137
  })
95764
96138
  });
95765
- if (restored.length > 0) {
96139
+ if (mappings.length > 0 || restored.length > 0) {
95766
96140
  const snapshots = new Map((await listWorkflowSnapshotBoundaries(journal, runId)).map((boundary) => [
95767
96141
  boundary.snapshot.id,
95768
96142
  boundary.snapshot
95769
96143
  ]));
95770
- await setUpRestoredRunWorktrees(restored.map((mapping) => ({
95771
- root: mapping.to,
95772
- envHash: snapshots.get(mapping.snapshotId).envHash
95773
- })), { signal: opts.signal });
96144
+ const resumeToken = crypto.randomUUID();
96145
+ let blueprintNoticeCount = 0;
96146
+ await setUpResumedRunWorktrees({ restored, mappings, snapshots }, {
96147
+ signal: opts.signal,
96148
+ onNotices: (notices) => {
96149
+ for (const notice of notices) {
96150
+ activeStore.recordNotice({
96151
+ id: `workflow-blueprint:${runId}:${resumeToken}:${blueprintNoticeCount++}`,
96152
+ runId,
96153
+ level: notice.type,
96154
+ message: notice.message,
96155
+ createdAt: Date.now()
96156
+ });
96157
+ }
96158
+ }
96159
+ });
95774
96160
  }
95775
96161
  const allMappings = [...mappings, ...restored];
95776
96162
  if (restored.length > 0) {
@@ -98300,12 +98686,12 @@ var init_registry = () => {};
98300
98686
 
98301
98687
  // dist/builtin/workflows/src/extension/discovery-loaders.ts
98302
98688
  import { readdir as readdir2, stat as stat2 } from "node:fs/promises";
98303
- import { extname, isAbsolute as isAbsolute18, join as join37, resolve as resolve21 } from "node:path";
98689
+ import { extname, isAbsolute as isAbsolute18, join as join38, resolve as resolve21 } from "node:path";
98304
98690
  async function scanWorkflowDir(dir) {
98305
98691
  try {
98306
98692
  const entries = await readdir2(dir, { withFileTypes: true });
98307
98693
  const WORKFLOW_EXTS = new Set([".ts", ".js", ".mjs", ".cjs"]);
98308
- return entries.filter((e) => e.isFile() && WORKFLOW_EXTS.has(extname(e.name))).map((e) => join37(dir, e.name)).sort();
98694
+ return entries.filter((e) => e.isFile() && WORKFLOW_EXTS.has(extname(e.name))).map((e) => join38(dir, e.name)).sort();
98309
98695
  } catch {
98310
98696
  return null;
98311
98697
  }
@@ -98372,16 +98758,16 @@ var init_discovery_loaders = __esm(() => {
98372
98758
  });
98373
98759
 
98374
98760
  // dist/builtin/workflows/src/extension/discovery.ts
98375
- import { join as join38 } from "node:path";
98376
- import { CONFIG_DIR_NAME as CONFIG_DIR_NAME2, getAgentDir as getAgentDir7 } from "@bastani/atomic";
98761
+ import { join as join39 } from "node:path";
98762
+ import { CONFIG_DIR_NAME as CONFIG_DIR_NAME2, getAgentDir as getAgentDir8 } from "@bastani/atomic";
98377
98763
  function workflowAgentDirs(options) {
98378
98764
  if (options?.agentDirs !== undefined)
98379
98765
  return options.agentDirs;
98380
98766
  if (options?.homeDir !== undefined) {
98381
98767
  const homeDir = options.homeDir;
98382
- return [join38(homeDir, CONFIG_DIR_NAME2, "agent")];
98768
+ return [join39(homeDir, CONFIG_DIR_NAME2, "agent")];
98383
98769
  }
98384
- return [getAgentDir7()];
98770
+ return [getAgentDir8()];
98385
98771
  }
98386
98772
  function validateConfig(config) {
98387
98773
  if (config === null || typeof config !== "object") {
@@ -98535,7 +98921,7 @@ async function discoverWorkflows(options) {
98535
98921
  registry = await applyBatch(candidates, registry, sources, diagnostics);
98536
98922
  }
98537
98923
  }
98538
- for (const dir of [join38(cwd, CONFIG_DIR_NAME2, "workflows")]) {
98924
+ for (const dir of [join39(cwd, CONFIG_DIR_NAME2, "workflows")]) {
98539
98925
  const candidates = await loadFromDir(dir, "project-local", diagnostics, getWorkflowHostModules);
98540
98926
  registry = await applyBatch(candidates, registry, sources, diagnostics);
98541
98927
  }
@@ -98547,7 +98933,7 @@ async function discoverWorkflows(options) {
98547
98933
  registry = await applyBatch(candidates, registry, sources, diagnostics);
98548
98934
  }
98549
98935
  }
98550
- for (const dir of agentDirs.map((agentDir) => join38(agentDir, "workflows")).reverse()) {
98936
+ for (const dir of agentDirs.map((agentDir) => join39(agentDir, "workflows")).reverse()) {
98551
98937
  const candidates = await loadFromDir(dir, "user-global", diagnostics, getWorkflowHostModules);
98552
98938
  registry = await applyBatch(candidates, registry, sources, diagnostics);
98553
98939
  }
@@ -98854,10 +99240,10 @@ var init_snapshot_restore = __esm(() => {
98854
99240
 
98855
99241
  // dist/builtin/workflows/src/workers/worker-host.ts
98856
99242
  import { execFile as execFile2 } from "node:child_process";
98857
- import { existsSync as existsSync14 } from "node:fs";
98858
- import { join as join39 } from "node:path";
99243
+ import { existsSync as existsSync15 } from "node:fs";
99244
+ import { join as join40 } from "node:path";
98859
99245
  import {
98860
- getAgentDir as getAgentDir8,
99246
+ getAgentDir as getAgentDir9,
98861
99247
  isGitProvisionError as isGitProvisionError4,
98862
99248
  resolveGit as resolveGit2,
98863
99249
  resolveGitSync as resolveGitSync2,
@@ -98932,7 +99318,7 @@ function probeGit(git) {
98932
99318
  async function runnableSources(root) {
98933
99319
  const sources = [];
98934
99320
  for (const source of root.config.definitions) {
98935
- if (!existsSync14(source.path))
99321
+ if (!existsSync15(source.path))
98936
99322
  continue;
98937
99323
  const digest = await definitionDigest(source.path);
98938
99324
  if (digest === source.digest)
@@ -99203,17 +99589,21 @@ function hostRestorePort(options, git, shared, journal, agentDir) {
99203
99589
  const restore = snapshotRestore({
99204
99590
  recorded: (binding) => shared.recordedSnapshots(binding),
99205
99591
  blobs: journal.snapshotBlobs,
99206
- storeDir: join39(agentDir, "worktree-snapshots"),
99592
+ storeDir: join40(agentDir, "worktree-snapshots"),
99207
99593
  git
99208
99594
  });
99209
- return (binding, hook) => restoreRunWorktree(hook.snapshot?.envHash, () => restore(binding, hook), {
99595
+ return (binding, hook) => restoreRunWorktree(hook.snapshot?.remotes, () => restore(binding, hook), {
99210
99596
  signal: hook.signal,
99211
- agentDir
99597
+ agentDir,
99598
+ onNotices: (notices) => {
99599
+ for (const notice of notices)
99600
+ console.warn(`atomic-workflows: ${notice.message}`);
99601
+ }
99212
99602
  });
99213
99603
  }
99214
99604
  async function startWorkflowWorkerHost(options) {
99215
99605
  validated(options);
99216
- const agentDir = options.agentDir ?? getAgentDir8();
99606
+ const agentDir = options.agentDir ?? getAgentDir9();
99217
99607
  const { selection, git, gitCommand } = await checkHostSetup(options, agentDir);
99218
99608
  const journal = await openSelectedRunJournal(selection, agentDir);
99219
99609
  try {
@@ -99691,8 +100081,8 @@ var init_workflows_host_module = __esm(() => {
99691
100081
 
99692
100082
  // dist/builtin/workflows/src/workers/pool-journal.ts
99693
100083
  import { createHash as createHash7, randomUUID as randomUUID24 } from "node:crypto";
99694
- import { existsSync as existsSync15, mkdirSync as mkdirSync11, readFileSync as readFileSync9, writeFileSync as writeFileSync7 } from "node:fs";
99695
- import { basename as basename6, dirname as dirname20, join as join40, resolve as resolve23 } from "node:path";
100084
+ import { existsSync as existsSync16, mkdirSync as mkdirSync11, readFileSync as readFileSync9, writeFileSync as writeFileSync7 } from "node:fs";
100085
+ import { basename as basename6, dirname as dirname22, join as join41, resolve as resolve23 } from "node:path";
99696
100086
  import { createChildProcessEnvironment as createChildProcessEnvironment6 } from "@bastani/atomic";
99697
100087
  import { storageSelectionKey as storageSelectionKey2 } from "@bastani/atomic/storage";
99698
100088
  function poolWorkerEnvironment(durable) {
@@ -99752,7 +100142,7 @@ function openDurableJournal(durable) {
99752
100142
  return openSelectedRunJournal(decodeSelection(durable.selection), durable.agentDir);
99753
100143
  }
99754
100144
  function poolStateDirectory(agentDir) {
99755
- return join40(dirname20(agentDir), "workflows", "pool");
100145
+ return join41(dirname22(agentDir), "workflows", "pool");
99756
100146
  }
99757
100147
  function databaseIdentity(selection, agentDir) {
99758
100148
  return storageSelectionKey2(selection.kind === "adapter" ? { ...selection, secrets: undefined } : selection, agentDir);
@@ -99760,7 +100150,7 @@ function databaseIdentity(selection, agentDir) {
99760
100150
  function coordinationPath(durable) {
99761
100151
  const selection = decodeSelection(durable.selection);
99762
100152
  const identity = createHash7("sha256").update(databaseIdentity(selection, durable.agentDir)).digest("hex");
99763
- return join40(poolStateDirectory(durable.agentDir), `${identity.slice(0, 24)}.sqlite`);
100153
+ return join41(poolStateDirectory(durable.agentDir), `${identity.slice(0, 24)}.sqlite`);
99764
100154
  }
99765
100155
  function coordinationDatabase(durable) {
99766
100156
  return basename6(coordinationPath(durable), ".sqlite");
@@ -99769,7 +100159,7 @@ function openCoordinationJournal(path) {
99769
100159
  const file = resolve23(path);
99770
100160
  let opened = coordinationJournals.get(file);
99771
100161
  if (opened === undefined) {
99772
- mkdirSync11(dirname20(file), { recursive: true });
100162
+ mkdirSync11(dirname22(file), { recursive: true });
99773
100163
  opened = resolveRunJournal({ journal: { path: file } });
99774
100164
  coordinationJournals.set(file, opened);
99775
100165
  opened.catch(() => {
@@ -99794,13 +100184,13 @@ function poolJournalForRoot(journal, root) {
99794
100184
  return sharedRoots.get(journal)?.has(root) === true ? journal : poolJournalFor(journal);
99795
100185
  }
99796
100186
  function poolHostId(agentDir) {
99797
- const file = join40(poolStateDirectory(agentDir), "host-id");
100187
+ const file = join41(poolStateDirectory(agentDir), "host-id");
99798
100188
  try {
99799
100189
  const existing = readFileSync9(file, "utf8").trim();
99800
100190
  if (existing !== "")
99801
100191
  return existing;
99802
100192
  } catch {}
99803
- mkdirSync11(dirname20(file), { recursive: true });
100193
+ mkdirSync11(dirname22(file), { recursive: true });
99804
100194
  const id = randomUUID24();
99805
100195
  try {
99806
100196
  writeFileSync7(file, `${id}
@@ -99818,7 +100208,7 @@ async function poolJournalOf(journal) {
99818
100208
  if (origin === undefined || !isReopenableSelection(origin.selection))
99819
100209
  return journal;
99820
100210
  const path = coordinationPath(poolDurableJournal(journal));
99821
- if (!existsSync15(path))
100211
+ if (!existsSync16(path))
99822
100212
  return journal;
99823
100213
  const coordination = await openCoordinationJournal(path);
99824
100214
  registerPoolJournal(journal, coordination);
@@ -101600,7 +101990,7 @@ function runSnapshotsFromCheckpoints(checkpoints, rootRunId, rootRunName, fallba
101600
101990
  return runs;
101601
101991
  }
101602
101992
  function stageSnapshotFromDraft(draft, id, parentIds) {
101603
- const status = draft.topology?.status ?? "completed";
101993
+ const status = stageStatusFromRecord(draft.topology?.status ?? "completed");
101604
101994
  const startedAt = draft.startedAt ?? draft.firstCompletedAt;
101605
101995
  const endedAt = draft.endedAt ?? (status === "running" ? undefined : draft.firstCompletedAt);
101606
101996
  const workflowChild = workflowChildFromDraft(draft);
@@ -101695,8 +102085,8 @@ var init_completed_catalog = __esm(() => {
101695
102085
 
101696
102086
  // dist/builtin/workflows/src/extension/extension-factory.ts
101697
102087
  init_store_backend();
101698
- import { join as join43 } from "node:path";
101699
- import { getAgentDir as getAgentDir10, registerExtensionContextRetirementEffect as registerExtensionContextRetirementEffect3 } from "@bastani/atomic";
102088
+ import { join as join44 } from "node:path";
102089
+ import { getAgentDir as getAgentDir11, registerExtensionContextRetirementEffect as registerExtensionContextRetirementEffect3 } from "@bastani/atomic";
101700
102090
 
101701
102091
  // dist/builtin/workflows/src/engine/run-console.ts
101702
102092
  init_run_rejection_boundary();
@@ -102266,7 +102656,7 @@ function stageGlyph(status) {
102266
102656
  return "✗";
102267
102657
  case "awaiting_input":
102268
102658
  return "?";
102269
- case "waiting":
102659
+ case "suspended":
102270
102660
  return "◷";
102271
102661
  case "skipped":
102272
102662
  return "⊘";
@@ -102546,8 +102936,8 @@ function stageWaitLabel(wait) {
102546
102936
  return names.length === 0 ? "tool" : `tool: ${names.join(", ")}`;
102547
102937
  }
102548
102938
  case "idle":
102549
- return "idle";
102550
102939
  case "release":
102940
+ return "between turns";
102551
102941
  case "prompt":
102552
102942
  return "released";
102553
102943
  }
@@ -102588,7 +102978,7 @@ function statusIcon(status) {
102588
102978
  return "○";
102589
102979
  case "awaiting_input":
102590
102980
  return "?";
102591
- case "waiting":
102981
+ case "suspended":
102592
102982
  return "◷";
102593
102983
  case "blocked":
102594
102984
  return "↑";
@@ -104012,7 +104402,7 @@ function renderHeader(run, opts) {
104012
104402
  awaiting_input: 0,
104013
104403
  paused: 0,
104014
104404
  blocked: 0,
104015
- waiting: 0,
104405
+ suspended: 0,
104016
104406
  completed: 0,
104017
104407
  failed: 0,
104018
104408
  skipped: 0
@@ -104028,8 +104418,8 @@ function renderHeader(run, opts) {
104028
104418
  badges.push({ text: `↵ ${counts.awaiting_input}`, fg: theme.info });
104029
104419
  if (counts.paused > 0)
104030
104420
  badges.push({ text: `❚❚ ${counts.paused}`, fg: theme.warning });
104031
- if (counts.waiting > 0)
104032
- badges.push({ text: `◷ ${counts.waiting}`, fg: theme.dim });
104421
+ if (counts.suspended > 0)
104422
+ badges.push({ text: `◷ ${counts.suspended}`, fg: theme.dim });
104033
104423
  if (counts.pending > 0)
104034
104424
  badges.push({ text: `○ ${counts.pending}`, fg: theme.dim });
104035
104425
  if (counts.skipped > 0)
@@ -106703,7 +107093,7 @@ class GraphViewState {
106703
107093
  awaiting_input: 0,
106704
107094
  paused: 0,
106705
107095
  blocked: 0,
106706
- waiting: 0,
107096
+ suspended: 0,
106707
107097
  completed: 0,
106708
107098
  failed: 0,
106709
107099
  skipped: 0
@@ -110558,6 +110948,10 @@ function snapshotMessagesFromHandle(ctx) {
110558
110948
  ctx.chatHost.appendMessages(handle.messages);
110559
110949
  ctx.chatHost.hydrateStreamingAssistantMessage(handle.agentSession?.agent?.state.streamingMessage ?? handle.streamingMessage?.());
110560
110950
  }
110951
+ function waitingToolCallIds(stage) {
110952
+ const calls = stage?.wait?.toolCalls;
110953
+ return calls === undefined ? undefined : new Set(calls.map((call) => call.toolCallId));
110954
+ }
110561
110955
  function snapshotMessagesFromSession(ctx, stage) {
110562
110956
  const handle = liveHandle(ctx);
110563
110957
  const sessionId = handle?.sessionId ?? stage?.sessionId;
@@ -110569,7 +110963,7 @@ function snapshotMessagesFromSession(ctx, stage) {
110569
110963
  ctx.postMortemUnavailableReason ??= "invalid_session";
110570
110964
  return;
110571
110965
  }
110572
- ctx.chatHost.loadSession(sessionStore, sessionId).then((loaded) => {
110966
+ ctx.chatHost.loadSession(sessionStore, sessionId, waitingToolCallIds(stage)).then((loaded) => {
110573
110967
  if (!loaded && !liveHandle(ctx))
110574
110968
  ctx.postMortemUnavailableReason ??= "invalid_session";
110575
110969
  ctx.requestRender?.();
@@ -114274,7 +114668,7 @@ function controllableHandles(activeStore, registry, runId) {
114274
114668
  const controlRunIds = new Set([runId]);
114275
114669
  for (const stage of graph.stages)
114276
114670
  controlRunIds.add(stage.workflowGraphTarget.runId);
114277
- return [...controlRunIds].flatMap((controlRunId) => registry.run(controlRunId).stages().filter((handle) => handle.status === "running" || handle.status === "pending" || handle.status === "awaiting_input" || handle.status === "waiting" || handle.status === "paused").map((handle) => ({ controlRunId, handle })));
114671
+ return [...controlRunIds].flatMap((controlRunId) => registry.run(controlRunId).stages().filter((handle) => handle.status === "running" || handle.status === "pending" || handle.status === "awaiting_input" || handle.status === "suspended" || handle.status === "paused").map((handle) => ({ controlRunId, handle })));
114278
114672
  }
114279
114673
  async function markDurableQuit(runId, run, resumable = true, selectedBackend) {
114280
114674
  const backend = discoverDurableQuitBackend(runId, selectedBackend);
@@ -114425,7 +114819,7 @@ async function settleResumeAcknowledgements(store, targets, message) {
114425
114819
  settled.forEach((result, index) => {
114426
114820
  const target = attempted[index];
114427
114821
  const controlRun = store.run(target.controlRunId);
114428
- const controlVisiblyRunning = target.handle.status === "running" || target.handle.status === "pending" || target.handle.status === "awaiting_input" || target.handle.status === "waiting";
114822
+ const controlVisiblyRunning = target.handle.status === "running" || target.handle.status === "pending" || target.handle.status === "awaiting_input" || target.handle.status === "suspended";
114429
114823
  if (result.status === "fulfilled" || controlVisiblyRunning)
114430
114824
  acknowledged += 1;
114431
114825
  if ((result.status === "fulfilled" || controlVisiblyRunning) && controlRun?.endedAt === undefined) {
@@ -114950,13 +115344,13 @@ async function pauseRunWithAction(runId, opts, action = "pause") {
114950
115344
  const currentRun = activeStore.run(runId);
114951
115345
  const stage = currentRun?.stages.find((candidate) => candidate.id === opts.stageId);
114952
115346
  const paused = stage === undefined ? [] : [structuredClone(stage)];
114953
- const stillActive = currentRun?.stages.some((candidate) => candidate.id !== opts.stageId && (candidate.status === "running" || candidate.status === "pending" || candidate.status === "waiting")) ?? false;
115347
+ const stillActive = currentRun?.stages.some((candidate) => candidate.id !== opts.stageId && (candidate.status === "running" || candidate.status === "pending" || candidate.status === "suspended")) ?? false;
114954
115348
  if (!stillActive)
114955
115349
  activeStore.recordRunPaused(runId);
114956
115350
  return { ok: true, runId, paused };
114957
115351
  }
114958
115352
  const controlRunIds = expandedControlRunIds(activeStore, runId);
114959
- const handles = controlRunIds.flatMap((controlRunId) => registry.run(controlRunId).stages().filter((handle) => handle.status === "running" || handle.status === "pending" || handle.status === "waiting").map((handle) => ({ controlRunId, handle })));
115353
+ const handles = controlRunIds.flatMap((controlRunId) => registry.run(controlRunId).stages().filter((handle) => handle.status === "running" || handle.status === "pending" || handle.status === "suspended").map((handle) => ({ controlRunId, handle })));
114960
115354
  const pauseHandles = async () => {
114961
115355
  const paused = [];
114962
115356
  const pausedRunIds = new Set;
@@ -115101,8 +115495,8 @@ function installCompactionHook(api, store) {
115101
115495
  });
115102
115496
  }
115103
115497
  // dist/builtin/workflows/src/extension/config-loader.ts
115104
- import { isAbsolute as isAbsolute19, join as join41 } from "node:path";
115105
- import { CONFIG_DIR_NAME as CONFIG_DIR_NAME3, getAgentDir as getAgentDir9 } from "@bastani/atomic";
115498
+ import { isAbsolute as isAbsolute19, join as join42 } from "node:path";
115499
+ import { CONFIG_DIR_NAME as CONFIG_DIR_NAME3, getAgentDir as getAgentDir10 } from "@bastani/atomic";
115106
115500
  // dist/builtin/workflows/src/extension/lifecycle-notifications.ts
115107
115501
  init_returned_run_status();
115108
115502
  import { reportDebug as reportDebug4 } from "@bastani/atomic";
@@ -116017,7 +116411,7 @@ function resolveWorkflowPaths(workflows, baseDir) {
116017
116411
  }
116018
116412
  return Object.fromEntries(Object.entries(workflows).map(([name, entry]) => [
116019
116413
  name,
116020
- isAbsolute19(entry.path) ? entry.path : join41(baseDir, entry.path)
116414
+ isAbsolute19(entry.path) ? entry.path : join42(baseDir, entry.path)
116021
116415
  ]));
116022
116416
  }
116023
116417
  function workflowAgentDirs2(opts) {
@@ -116025,12 +116419,12 @@ function workflowAgentDirs2(opts) {
116025
116419
  return opts.agentDirs;
116026
116420
  if (opts.homeDir !== undefined) {
116027
116421
  const homeDir = opts.homeDir;
116028
- return [join41(homeDir, CONFIG_DIR_NAME3, "agent")];
116422
+ return [join42(homeDir, CONFIG_DIR_NAME3, "agent")];
116029
116423
  }
116030
- return [getAgentDir9()];
116424
+ return [getAgentDir10()];
116031
116425
  }
116032
116426
  function toScopedDiscoveryConfig(globalConfig, projectConfig, opts) {
116033
- const globalBase = opts.agentDir ?? (opts.homeDir === undefined ? getAgentDir9() : join41(opts.homeDir, CONFIG_DIR_NAME3, "agent"));
116427
+ const globalBase = opts.agentDir ?? (opts.homeDir === undefined ? getAgentDir10() : join42(opts.homeDir, CONFIG_DIR_NAME3, "agent"));
116034
116428
  const projectBase = opts.projectRoot;
116035
116429
  const result = {};
116036
116430
  const projectWorkflows = resolveWorkflowPaths(projectConfig?.workflows, projectBase);
@@ -116040,7 +116434,7 @@ function toScopedDiscoveryConfig(globalConfig, projectConfig, opts) {
116040
116434
  if (hasWorkflows(globalConfig)) {
116041
116435
  const projectKeys = new Set(Object.keys(projectWorkflows ?? {}));
116042
116436
  const globalEntries = Object.entries(globalConfig.workflows).filter(([name]) => !projectKeys.has(name)).map(([name, entry]) => {
116043
- return [name, isAbsolute19(entry.path) ? entry.path : join41(globalBase, entry.path)];
116437
+ return [name, isAbsolute19(entry.path) ? entry.path : join42(globalBase, entry.path)];
116044
116438
  });
116045
116439
  if (globalEntries.length > 0) {
116046
116440
  result.globalWorkflows = Object.fromEntries(globalEntries);
@@ -116051,8 +116445,8 @@ function toScopedDiscoveryConfig(globalConfig, projectConfig, opts) {
116051
116445
  async function loadWorkflowConfig(opts = {}) {
116052
116446
  const projectRoot = opts.projectRoot ?? process.cwd();
116053
116447
  const diagnostics = [];
116054
- const globalCandidates = workflowAgentDirs2(opts).map((agentDir) => join41(agentDir, "extensions", "workflow", "config.json"));
116055
- const projectCandidates = [join41(projectRoot, CONFIG_DIR_NAME3, "extensions", "workflow", "config.json")];
116448
+ const globalCandidates = workflowAgentDirs2(opts).map((agentDir) => join42(agentDir, "extensions", "workflow", "config.json"));
116449
+ const projectCandidates = [join42(projectRoot, CONFIG_DIR_NAME3, "extensions", "workflow", "config.json")];
116056
116450
  let globalConfig = null;
116057
116451
  for (let i = globalCandidates.length - 1;i >= 0; i--) {
116058
116452
  const globalPath = globalCandidates[i];
@@ -118816,21 +119210,21 @@ function createExtensionRuntime(opts = {}) {
118816
119210
  }
118817
119211
 
118818
119212
  // dist/builtin/workflows/src/extension/status-writer.ts
118819
- import { mkdir as mkdir8, rename as rename2, writeFile as writeFile11 } from "node:fs/promises";
118820
- import { dirname as dirname21, join as join42 } from "node:path";
119213
+ import { mkdir as mkdir9, rename as rename2, writeFile as writeFile12 } from "node:fs/promises";
119214
+ import { dirname as dirname23, join as join43 } from "node:path";
118821
119215
  import { CONFIG_DIR_NAME as CONFIG_DIR_NAME4 } from "@bastani/atomic";
118822
- var DEFAULT_STATUS_SUBPATH = join42(CONFIG_DIR_NAME4, "workflows", "status.json");
119216
+ var DEFAULT_STATUS_SUBPATH = join43(CONFIG_DIR_NAME4, "workflows", "status.json");
118823
119217
  function resolveStatusFilePath(config, opts = {}) {
118824
119218
  if (config.statusFilePath)
118825
119219
  return config.statusFilePath;
118826
119220
  const root = opts.projectRoot ?? process.cwd();
118827
- return join42(root, DEFAULT_STATUS_SUBPATH);
119221
+ return join43(root, DEFAULT_STATUS_SUBPATH);
118828
119222
  }
118829
119223
  async function atomicWriteJson(path, content) {
118830
- const dir = dirname21(path);
118831
- await mkdir8(dir, { recursive: true });
119224
+ const dir = dirname23(path);
119225
+ await mkdir9(dir, { recursive: true });
118832
119226
  const tmpPath = `${path}.tmp`;
118833
- await writeFile11(tmpPath, content, "utf8");
119227
+ await writeFile12(tmpPath, content, "utf8");
118834
119228
  await rename2(tmpPath, path);
118835
119229
  }
118836
119230
  function createStatusWriter(store, config, opts = {}) {
@@ -122705,6 +123099,9 @@ init_pending_stage_status();
122705
123099
  init_possible_stage_prediction();
122706
123100
  init_returned_run_status();
122707
123101
  init_sticky_delivery_state_bound();
123102
+ function currentStatusFilter(filter) {
123103
+ return filter === "waiting" ? "suspended" : filter;
123104
+ }
122708
123105
  var workflowStatusRenderRuns = new WeakMap;
122709
123106
  function setWorkflowStatusRenderRuns(result, runs) {
122710
123107
  workflowStatusRenderRuns.set(result, runs);
@@ -122767,7 +123164,7 @@ function budgetReport(dimension, reading, ceiling) {
122767
123164
  }
122768
123165
  function summarizeRunSnapshot(run, now = Date.now(), options) {
122769
123166
  const awaitingInput = awaitingInputEntries(run);
122770
- const waitingStages = run.stages.filter((stage) => stage.status === "waiting").map((stage) => ({
123167
+ const suspendedStages = run.stages.filter((stage) => stage.status === "suspended").map((stage) => ({
122771
123168
  stageId: stage.id,
122772
123169
  name: stage.name,
122773
123170
  ...stage.wait === undefined ? {} : { wait: stage.wait }
@@ -122842,8 +123239,8 @@ function summarizeRunSnapshot(run, now = Date.now(), options) {
122842
123239
  }),
122843
123240
  awaitingInputCount: awaitingInput.length,
122844
123241
  awaitingInput,
122845
- waitingCount: waitingStages.length,
122846
- waitingStages,
123242
+ suspendedCount: suspendedStages.length,
123243
+ suspendedStages,
122847
123244
  exitReason: run.exitReason,
122848
123245
  error: run.error ?? (strandedRoot ? IMPOSSIBLE_ROOT_LIVENESS_MESSAGE : undefined),
122849
123246
  ...strandedRoot ? { strandedRoot: true } : {}
@@ -122854,11 +123251,12 @@ function runMatchesStatusFilter(summary, filter) {
122854
123251
  return true;
122855
123252
  if (filter === "awaiting_input")
122856
123253
  return summary.awaitingInputCount > 0;
122857
- if (filter === "waiting")
122858
- return summary.waitingCount > 0;
123254
+ if (filter === "suspended")
123255
+ return summary.suspendedCount > 0;
122859
123256
  return summary.status === filter;
122860
123257
  }
122861
- function buildWorkflowStatusListing(snapshots, filter = "all", now = Date.now(), options) {
123258
+ function buildWorkflowStatusListing(snapshots, requestedFilter = "all", now = Date.now(), options) {
123259
+ const filter = currentStatusFilter(requestedFilter);
122862
123260
  const paired = snapshots.map((snapshot) => ({ snapshot, summary: summarizeRunSnapshot(snapshot, now, options) })).filter(({ summary }) => runMatchesStatusFilter(summary, filter));
122863
123261
  paired.sort((a, b) => {
122864
123262
  const aEnded = a.snapshot.endedAt === undefined ? 0 : 1;
@@ -123062,7 +123460,7 @@ function compactWorkflowToolMessage(result) {
123062
123460
  }
123063
123461
  var STATUS_MESSAGE_CHAR_LIMIT = 120;
123064
123462
  var STATUS_PENDING_STAGE_LIMIT = 10;
123065
- var STATUS_WAITING_STAGE_LIMIT = 10;
123463
+ var STATUS_SUSPENDED_STAGE_LIMIT = 10;
123066
123464
  function truncateStatusText(text) {
123067
123465
  const flattened = text.replace(/\s+/g, " ").trim();
123068
123466
  return flattened.length > STATUS_MESSAGE_CHAR_LIMIT ? `${flattened.slice(0, STATUS_MESSAGE_CHAR_LIMIT - 1)}…` : flattened;
@@ -123085,11 +123483,11 @@ function statusRunHint(run) {
123085
123483
  return hint ? `${stage.name} (${hint})` : stage.name;
123086
123484
  }).join(", ")}`;
123087
123485
  }
123088
- const waitingHint = run.waitingStages.length > 0 ? `waiting (${run.waitingCount}): ${[
123089
- ...run.waitingStages.slice(0, STATUS_WAITING_STAGE_LIMIT).map((stage) => stageStatusWithWait(stage.name, stage.wait)),
123090
- ...run.waitingStages.length > STATUS_WAITING_STAGE_LIMIT ? [`…, +${run.waitingStages.length - STATUS_WAITING_STAGE_LIMIT} more`] : []
123486
+ const suspendedHint = run.suspendedStages.length > 0 ? `suspended (${run.suspendedCount}): ${[
123487
+ ...run.suspendedStages.slice(0, STATUS_SUSPENDED_STAGE_LIMIT).map((stage) => stageStatusWithWait(stage.name, stage.wait)),
123488
+ ...run.suspendedStages.length > STATUS_SUSPENDED_STAGE_LIMIT ? [`…, +${run.suspendedStages.length - STATUS_SUSPENDED_STAGE_LIMIT} more`] : []
123091
123489
  ].join(", ")}` : undefined;
123092
- const hints = [primary, waitingHint, budgetHint, toolHint].filter((part) => part !== undefined);
123490
+ const hints = [primary, suspendedHint, budgetHint, toolHint].filter((part) => part !== undefined);
123093
123491
  if (hints.length > 0)
123094
123492
  return hints.join(" · ");
123095
123493
  if (run.error !== undefined && run.error.length > 0)
@@ -124139,7 +124537,7 @@ function snapshotTranscriptEntryCount(snapshot) {
124139
124537
  function workflowStagesResult(args, source) {
124140
124538
  const activeStore = source?.store ?? store;
124141
124539
  const target = resolveToolRunTarget(args, "No active run to inspect.", activeStore);
124142
- const filter = args.statusFilter ?? "all";
124540
+ const filter = currentStatusFilter(args.statusFilter ?? "all");
124143
124541
  if (target.kind === "all") {
124144
124542
  return {
124145
124543
  action: "stages",
@@ -124900,115 +125298,116 @@ var DEFAULT_PROMPT_GUIDANCE = [
124900
125298
  ];
124901
125299
 
124902
125300
  // dist/builtin/workflows/src/extension/workflow-schema.ts
124903
- import { Type as Type25 } from "typebox";
125301
+ import { Type as Type26 } from "typebox";
124904
125302
 
124905
125303
  // dist/builtin/workflows/src/extension/workflow-budget-schema.ts
124906
- import { Type as Type24 } from "typebox";
124907
- var WorkflowBudgetSchema = Type24.Object({
124908
- maxDurationMs: Type24.Optional(Type24.Integer({ minimum: 0, description: "Maximum run duration in milliseconds; 0 disables it." })),
124909
- maxTokens: Type24.Optional(Type24.Integer({ minimum: 0, description: "Maximum charged tokens; 0 disables it." })),
124910
- maxCost: Type24.Optional(Type24.Number({ minimum: 0, description: "Maximum cost in USD; 0 disables it." })),
124911
- warnAtPercent: Type24.Optional(Type24.Number({ minimum: 0, description: "Usage percentage at which to warn; 0 disables it." }))
125304
+ import { Type as Type25 } from "typebox";
125305
+ var WorkflowBudgetSchema = Type25.Object({
125306
+ maxDurationMs: Type25.Optional(Type25.Integer({ minimum: 0, description: "Maximum run duration in milliseconds; 0 disables it." })),
125307
+ maxTokens: Type25.Optional(Type25.Integer({ minimum: 0, description: "Maximum charged tokens; 0 disables it." })),
125308
+ maxCost: Type25.Optional(Type25.Number({ minimum: 0, description: "Maximum cost in USD; 0 disables it." })),
125309
+ warnAtPercent: Type25.Optional(Type25.Number({ minimum: 0, description: "Usage percentage at which to warn; 0 disables it." }))
124912
125310
  }, { additionalProperties: false, description: "Optional workflow run budget." });
124913
125311
 
124914
125312
  // dist/builtin/workflows/src/extension/workflow-schema.ts
124915
- var WorkflowResponseSchema = Type25.Union([
124916
- Type25.String(),
124917
- Type25.Boolean(),
124918
- Type25.Number(),
124919
- Type25.Null(),
124920
- Type25.Array(Type25.Unknown()),
124921
- Type25.Record(Type25.String(), Type25.Unknown())
125313
+ var WorkflowResponseSchema = Type26.Union([
125314
+ Type26.String(),
125315
+ Type26.Boolean(),
125316
+ Type26.Number(),
125317
+ Type26.Null(),
125318
+ Type26.Array(Type26.Unknown()),
125319
+ Type26.Record(Type26.String(), Type26.Unknown())
124922
125320
  ], {
124923
125321
  description: "Answer payload for a pending stage prompt. Primitive prompts accept text strings, booleans, or numeric select indexes according to the prompt kind; structured prompts may accept JSON arrays or objects."
124924
125322
  });
124925
- var WorkflowParametersSchema = Type25.Object({
124926
- workflow: Type25.Optional(Type25.String({
125323
+ var WorkflowParametersSchema = Type26.Object({
125324
+ workflow: Type26.Optional(Type26.String({
124927
125325
  description: "Registered workflow name for run, get, and inputs."
124928
125326
  })),
124929
- inputs: Type25.Optional(Type25.Record(Type25.String(), Type25.Unknown(), {
125327
+ inputs: Type26.Optional(Type26.Record(Type26.String(), Type26.Unknown(), {
124930
125328
  default: {},
124931
125329
  description: "Inputs for action 'run', validated with defaults against the named workflow's input contract, or replacement inputs for action 'fork' (omitted or empty: the source run's inputs). Invalid values fail without launching."
124932
125330
  })),
124933
- budget: Type25.Optional(WorkflowBudgetSchema),
124934
- action: Type25.Optional(Type25.Union([
124935
- Type25.Literal("models"),
124936
- Type25.Literal("run"),
124937
- Type25.Literal("list"),
124938
- Type25.Literal("get"),
124939
- Type25.Literal("inputs"),
124940
- Type25.Literal("status"),
124941
- Type25.Literal("stages"),
124942
- Type25.Literal("stage"),
124943
- Type25.Literal("transcript"),
124944
- Type25.Literal("answer"),
124945
- Type25.Literal("pause"),
124946
- Type25.Literal("quit"),
124947
- Type25.Literal("resume"),
124948
- Type25.Literal("fork"),
124949
- Type25.Literal("reload")
125331
+ budget: Type26.Optional(WorkflowBudgetSchema),
125332
+ action: Type26.Optional(Type26.Union([
125333
+ Type26.Literal("models"),
125334
+ Type26.Literal("run"),
125335
+ Type26.Literal("list"),
125336
+ Type26.Literal("get"),
125337
+ Type26.Literal("inputs"),
125338
+ Type26.Literal("status"),
125339
+ Type26.Literal("stages"),
125340
+ Type26.Literal("stage"),
125341
+ Type26.Literal("transcript"),
125342
+ Type26.Literal("answer"),
125343
+ Type26.Literal("pause"),
125344
+ Type26.Literal("quit"),
125345
+ Type26.Literal("resume"),
125346
+ Type26.Literal("fork"),
125347
+ Type26.Literal("reload")
124950
125348
  ], {
124951
125349
  description: "Workflow action: run/list/get/inputs/models/status, inspect stage metadata, answer pending prompts, pause/resume/quit runs, fork a durable run into a new run (optionally re-running from fromStage with replacement inputs; the source run is never changed), inspect the configured model catalog, or reload workflow resources. 'status' without runId lists every workflow run in the current session with concise per-run summaries (status, timing, active stages, awaiting-input prompts); filter the listing with statusFilter. 'status' with runId returns one run's full detail, including its final outputs (result); add summary:true for a compact form without the stage history. For transcript inspection, prefer status/stages/stage first to get sessionFile/transcriptPath, quote the exact path without rewriting separators (Windows backslashes are valid), then search it with rg/grep and read small ranges; transcript is path-only by default when sessionFile/transcriptPath exists, explicit tail/limit returns bounded previews, and missing transcript paths fall back to a small preview."
124952
125350
  })),
124953
- runId: Type25.Optional(Type25.String({
125351
+ runId: Type26.Optional(Type26.String({
124954
125352
  description: "Full 36-character run UUID or unique 8-character hexadecimal UUID prefix for status/stages/stage/transcript/answer/pause/resume/quit/fork (for fork, the source run). Other truncated forms are rejected; ambiguous prefixes require the full UUID. Omit runId with action 'status' to list all session runs and their statuses. Use '--all' or all:true for supported bulk run-control actions."
124955
125353
  })),
124956
- all: Type25.Optional(Type25.Boolean({
125354
+ all: Type26.Optional(Type26.Boolean({
124957
125355
  description: "Apply supported run-control actions (pause/quit) to all in-flight runs instead of one run; cannot be combined with stageId."
124958
125356
  })),
124959
- stageId: Type25.Optional(Type25.String({
125357
+ stageId: Type26.Optional(Type26.String({
124960
125358
  description: "Exact stage id/name or unique 8-character hexadecimal prefix of a bare stage UUID for stage-scoped inspection, transcript, answer, pause, or resume. Exact names take precedence; partial names are not accepted. A nested composite id must remain the full 'runId:stageId'. For pause and quit it may also name an in-flight ctx.tool node by its exact tool:<argsHash> id or tool name, which aborts that single call."
124961
125359
  })),
124962
- message: Type25.Optional(Type25.String({
125360
+ message: Type26.Optional(Type26.String({
124963
125361
  description: "Prompt answer text for answer, or optional text forwarded when resuming paused work."
124964
125362
  })),
124965
- statusFilter: Type25.Optional(Type25.Union([
124966
- Type25.Literal("pending"),
124967
- Type25.Literal("running"),
124968
- Type25.Literal("awaiting_input"),
124969
- Type25.Literal("paused"),
124970
- Type25.Literal("blocked"),
124971
- Type25.Literal("waiting"),
124972
- Type25.Literal("completed"),
124973
- Type25.Literal("failed"),
124974
- Type25.Literal("skipped"),
124975
- Type25.Literal("cancelled"),
124976
- Type25.Literal("killed"),
124977
- Type25.Literal("all")
125363
+ statusFilter: Type26.Optional(Type26.Union([
125364
+ Type26.Literal("pending"),
125365
+ Type26.Literal("running"),
125366
+ Type26.Literal("awaiting_input"),
125367
+ Type26.Literal("paused"),
125368
+ Type26.Literal("blocked"),
125369
+ Type26.Literal("suspended"),
125370
+ Type26.Literal("waiting"),
125371
+ Type26.Literal("completed"),
125372
+ Type26.Literal("failed"),
125373
+ Type26.Literal("skipped"),
125374
+ Type26.Literal("cancelled"),
125375
+ Type26.Literal("killed"),
125376
+ Type26.Literal("all")
124978
125377
  ], {
124979
- description: "Filter stages (stages action) or listed runs (status action without runId) by status; 'all' (default) includes everything. For the status listing, run statuses match directly, 'awaiting_input' selects runs with at least one stage awaiting input or pending human prompt, and in-flight runs are listed first."
125378
+ description: "Filter stages (stages action) or listed runs (status action without runId) by status; 'all' (default) includes everything. For the status listing, run statuses match directly, 'awaiting_input' selects runs with at least one stage awaiting input or pending human prompt, 'suspended' selects runs with at least one stage released from memory while it waits for a tool result or between turns, 'waiting' is a deprecated alias for 'suspended', and in-flight runs are listed first."
124980
125379
  })),
124981
- summary: Type25.Optional(Type25.Boolean({
125380
+ summary: Type26.Optional(Type26.Boolean({
124982
125381
  description: "Status with runId only: return the run's status, final outputs (result), error and blockers (failed, blocked or awaiting-input stages and tools) without the full stage and tool history. Use it to read what a finished run produced, including a run started by another session."
124983
125382
  })),
124984
- format: Type25.Optional(Type25.Union([Type25.Literal("text"), Type25.Literal("json")], {
125383
+ format: Type26.Optional(Type26.Union([Type26.Literal("text"), Type26.Literal("json")], {
124985
125384
  description: "Agent-visible output format for data-bearing inspection actions (models, status, stages, stage, transcript); 'json' returns the full structured result."
124986
125385
  })),
124987
- limit: Type25.Optional(Type25.Integer({
125386
+ limit: Type26.Optional(Type26.Integer({
124988
125387
  minimum: 0,
124989
125388
  description: "Transcript-only: explicitly inline at most this many recent entries. Omit both limit and tail to use the path-only default when sessionFile/transcriptPath exists; prefer rg/grep on the exact quoted sessionFile/transcriptPath for targeted lookup without rewriting platform path separators."
124990
125389
  })),
124991
- tail: Type25.Optional(Type25.Integer({
125390
+ tail: Type26.Optional(Type26.Integer({
124992
125391
  minimum: 0,
124993
125392
  description: "Transcript-only: explicitly inline the last N entries; overrides limit. Use for quick recent-context checks after status/stages/stage expose the transcript path."
124994
125393
  })),
124995
- includeToolOutput: Type25.Optional(Type25.Boolean({
125394
+ includeToolOutput: Type26.Optional(Type26.Boolean({
124996
125395
  description: "Transcript-only: include captured tool output entries when building inlined snapshot previews; this does not bypass the path-only default. Prefer rg/grep on the exact quoted sessionFile/transcriptPath for large outputs. Live session transcripts may not expose tool output."
124997
125396
  })),
124998
- text: Type25.Optional(Type25.String({
125397
+ text: Type26.Optional(Type26.String({
124999
125398
  description: "Text for a pending prompt answer."
125000
125399
  })),
125001
- response: Type25.Optional(WorkflowResponseSchema),
125002
- promptId: Type25.Optional(Type25.String({
125400
+ response: Type26.Optional(WorkflowResponseSchema),
125401
+ promptId: Type26.Optional(Type26.String({
125003
125402
  description: "Pending prompt identifier for the answer action."
125004
125403
  })),
125005
- fromStage: Type25.Optional(Type25.String({
125404
+ fromStage: Type26.Optional(Type26.String({
125006
125405
  description: "Fork-only: dot path of the completed stage the fork re-runs from, for example 'implement-api.review-2' for a stage inside a nested workflow. An unknown path fails with the run's valid stage paths. Omit to fork the whole run."
125007
125406
  })),
125008
- carryMessages: Type25.Optional(Type25.Union([Type25.Literal("before"), Type25.Literal("all")], {
125407
+ carryMessages: Type26.Optional(Type26.Union([Type26.Literal("before"), Type26.Literal("all")], {
125009
125408
  description: "Fork-only: carry Intercom messages and prompt answers recorded before the fork point ('before', default) or all of them ('all')."
125010
125409
  })),
125011
- reason: Type25.Optional(Type25.String({
125410
+ reason: Type26.Optional(Type26.String({
125012
125411
  description: "Human-readable reason for the reload action, echoed in the reload result."
125013
125412
  }))
125014
125413
  }, { additionalProperties: false });
@@ -125169,7 +125568,7 @@ function factory(pi) {
125169
125568
  pi.on?.("session_start", (_event, ctx) => {
125170
125569
  hostSessionContext = ctx;
125171
125570
  if (ctx?.mode === "tui")
125172
- routeWorkflowConsoleOutput(join43(getAgentDir10(), "workflow-logs"));
125571
+ routeWorkflowConsoleOutput(join44(getAgentDir11(), "workflow-logs"));
125173
125572
  });
125174
125573
  const ownerSessionClosing = () => (hostSessionContext?.getCurrentSessionSignal?.() ?? hostSessionContext?.sessionSignal)?.aborted === true;
125175
125574
  const adapters = buildRuntimeAdapters(pi, {