@desplega.ai/agent-swarm 2.10.0 → 2.11.0

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 (378) hide show
  1. package/dist/acp-adapter-weaaxey3.js +16 -0
  2. package/dist/{acp-targets-arrwv4f0.js → acp-targets-5wyy2b9m.js} +9 -9
  3. package/dist/{actions-y0d2n1c2.js → actions-4nxq386s.js} +24 -23
  4. package/dist/{agent-fs-provision-tpj7sktd.js → agent-fs-provision-v6enh76w.js} +4 -4
  5. package/dist/{amp-adapter-vmmnmw8d.js → amp-adapter-ze3x22qn.js} +3 -3
  6. package/dist/{anthropic-messages-zdca3gv1.js → anthropic-messages-88b7s3n9.js} +177 -25
  7. package/dist/{app-wb7w45dq.js → app-kyqt8ehw.js} +7 -6
  8. package/dist/{approval-notifications-7mqr6vbd.js → approval-notifications-a0db0esw.js} +7 -6
  9. package/dist/{assistant-gf60454p.js → assistant-9g5jzq25.js} +26 -25
  10. package/dist/{azure-openai-responses-b3y7fz36.js → azure-openai-responses-jeaas6x0.js} +10 -10
  11. package/dist/{boot-args-schema-qxmd59sr.js → boot-args-schema-d7fme4q1.js} +1 -1
  12. package/dist/{boot-reembed-wb44vc3s.js → boot-reembed-6wpazmpw.js} +1 -1
  13. package/dist/{boot-reembed-5tmeskj2.js → boot-reembed-jrwxeye2.js} +1 -1
  14. package/dist/{boot-scrub-sweep-25bxhnw4.js → boot-scrub-sweep-52h7yntp.js} +2 -2
  15. package/dist/{boot-seeds-nj9za0vk.js → boot-seeds-kb3dxjex.js} +4 -4
  16. package/dist/{boxd-wn235q80.js → boxd-jrrmkv3w.js} +2 -2
  17. package/dist/{claude-adapter-d3krpdyb.js → claude-adapter-0c0y8fqp.js} +8 -8
  18. package/dist/{claude-managed-adapter-t8nfgcgz.js → claude-managed-adapter-w2es07qq.js} +4 -4
  19. package/dist/{claude-managed-setup-7y4pwd81.js → claude-managed-setup-9ssb7ct4.js} +4 -4
  20. package/dist/{claude-sdk-session-d138zy0e.js → claude-sdk-session-p6t0gyse.js} +10941 -10412
  21. package/dist/{cli-p0n7b5rz.js → cli-075ccjh6.js} +344 -130
  22. package/dist/{cli-3caf7pmg.js → cli-0bgj4rh5.js} +3 -3
  23. package/dist/{cli-7r162fxe.js → cli-14xdms9a.js} +23 -17
  24. package/dist/{cli-rqx70rcz.js → cli-17qzb39j.js} +5 -2
  25. package/dist/{cli-y4ccxtz5.js → cli-1h4njv9y.js} +144 -6
  26. package/dist/{cli-6ym4jhzp.js → cli-27fat7st.js} +7 -7
  27. package/dist/{cli-k3q2va86.js → cli-2aacfdcn.js} +5 -5
  28. package/dist/{cli-vq2eg24x.js → cli-2gvdvsxj.js} +3 -3
  29. package/dist/{cli-sb4426be.js → cli-2jtfm8kh.js} +5 -5
  30. package/dist/{cli-6ehs4mta.js → cli-2z2c4k6q.js} +18 -4
  31. package/dist/{cli-6237rnyr.js → cli-3bpr3wks.js} +1 -1
  32. package/dist/{cli-5qhfv9rw.js → cli-453497a0.js} +44 -17
  33. package/dist/{cli-2rnd5j3t.js → cli-4aswccje.js} +2 -2
  34. package/dist/{cli-4ymxrwg5.js → cli-4dyzzkfb.js} +2 -2
  35. package/dist/{cli-p0c3vtch.js → cli-4g323fjh.js} +772 -515
  36. package/dist/{cli-3kd08rej.js → cli-4jjrhy48.js} +1 -1
  37. package/dist/{cli-fcfbct2j.js → cli-4kzp7r0q.js} +5 -5
  38. package/dist/{cli-kxn3747f.js → cli-4se3x6qm.js} +1 -26
  39. package/dist/{cli-zeh2mhkg.js → cli-5ptj757f.js} +1 -1
  40. package/dist/{cli-539h29es.js → cli-6a3j25xd.js} +224 -189
  41. package/dist/{cli-hnamkvnc.js → cli-6c9ve77f.js} +2 -2
  42. package/dist/{cli-3et6fmfe.js → cli-6n7y5ypy.js} +1 -1
  43. package/dist/{cli-8y43jx2r.js → cli-6p8p2e6r.js} +16 -9
  44. package/dist/{cli-zk7v5s89.js → cli-6tvh1fwq.js} +3 -3
  45. package/dist/{cli-p74md7t8.js → cli-7b7rxz22.js} +13 -15
  46. package/dist/{cli-5a6pqy45.js → cli-7e8sxqv5.js} +1 -1
  47. package/dist/{cli-6037prsx.js → cli-892y3vfp.js} +13 -13
  48. package/dist/cli-8mfdbdhe.js +43 -0
  49. package/dist/{cli-s1zqk1aj.js → cli-8zmpwe79.js} +15 -9
  50. package/dist/{cli-zcfpsfzf.js → cli-96234j5w.js} +3 -3
  51. package/dist/{cli-1z4qggfe.js → cli-9fvk9mv8.js} +30 -21
  52. package/dist/{cli-7mv4h3sn.js → cli-9g12h1aq.js} +2 -2
  53. package/dist/{cli-aw83sr40.js → cli-9knhkkgr.js} +3 -3
  54. package/dist/{cli-5mpy301f.js → cli-9t7syepg.js} +1 -1
  55. package/dist/{cli-qj39vrc6.js → cli-9yjhshah.js} +1 -1
  56. package/dist/{cli-6cwr32fe.js → cli-a02habn6.js} +422 -140
  57. package/dist/{cli-7evph51z.js → cli-a49frv85.js} +2 -2
  58. package/dist/{cli-3f8zbtqa.js → cli-a6q6x15h.js} +9 -8
  59. package/dist/{cli-j6te8keb.js → cli-atm0hkes.js} +8 -8
  60. package/dist/{cli-9fjr27ez.js → cli-b82a13ga.js} +13 -13
  61. package/dist/{cli-7zm3b3f5.js → cli-bf0t77nf.js} +1 -1
  62. package/dist/{cli-2xv18ywz.js → cli-bmqp0ser.js} +2 -2
  63. package/dist/{cli-mk7c5ac4.js → cli-bq97k63w.js} +2 -2
  64. package/dist/{cli-vfqvrd82.js → cli-cstggwq7.js} +2 -2
  65. package/dist/{cli-md50mj0r.js → cli-czvvnfr9.js} +3 -3
  66. package/dist/{cli-b6px1k1q.js → cli-dd2k2mcd.js} +1 -1
  67. package/dist/{cli-fq2rr3jb.js → cli-djt6wmrc.js} +6 -6
  68. package/dist/{cli-tsa40663.js → cli-ebqx630g.js} +3 -3
  69. package/dist/{cli-z0m452jr.js → cli-f7dhm7hh.js} +1 -1
  70. package/dist/{cli-mys27d03.js → cli-f8yhybxr.js} +3 -3
  71. package/dist/{cli-5gpqgs8b.js → cli-fwjwkw66.js} +2 -2
  72. package/dist/{cli-gabsjg8x.js → cli-g56fxddf.js} +1 -1
  73. package/dist/{cli-y8p78ekx.js → cli-h2qtafm4.js} +18 -18
  74. package/dist/{cli-psffsanb.js → cli-ha4ek2nb.js} +6 -1
  75. package/dist/{cli-th1dkc2v.js → cli-hnh8erra.js} +2 -2
  76. package/dist/{cli-w16kwbzw.js → cli-htymm48w.js} +1 -1
  77. package/dist/{cli-124ntmf0.js → cli-j2r1apqm.js} +138 -59
  78. package/dist/{cli-43ms35q9.js → cli-k3c13za2.js} +3 -3
  79. package/dist/{cli-54vrpgm0.js → cli-k3facve0.js} +8 -5
  80. package/dist/{cli-v8z0yga9.js → cli-k4r5sfaj.js} +4 -4
  81. package/dist/{cli-91pkxres.js → cli-kbm659dk.js} +2 -2
  82. package/dist/{cli-q5srsxq2.js → cli-m00c47q6.js} +110 -27
  83. package/dist/{cli-3aaeb78m.js → cli-mhrr4d5b.js} +95 -10
  84. package/dist/{cli-xqdz5cqm.js → cli-mz7ycqn8.js} +1 -0
  85. package/dist/{cli-qrta34nb.js → cli-n6ygvrrm.js} +4 -4
  86. package/dist/{cli-k5yewqgd.js → cli-nbakg5xh.js} +3 -3
  87. package/dist/{cli-nstkanmx.js → cli-nc39ym5q.js} +8 -8
  88. package/dist/{cli-01k6wpr9.js → cli-p1a4khta.js} +7 -7
  89. package/dist/{cli-t9ga4qmb.js → cli-p8zqbbt1.js} +40 -33
  90. package/dist/{cli-v46zsvqk.js → cli-ph95yejc.js} +2 -2
  91. package/dist/{cli-k6nejceb.js → cli-q4z9s6zs.js} +2 -2
  92. package/dist/{cli-kbtzfrxj.js → cli-q71g5q39.js} +3 -3
  93. package/dist/{cli-vs9vdpy0.js → cli-qncx2r0s.js} +1 -1
  94. package/dist/{cli-hg42n3hx.js → cli-qrzq3hvg.js} +8 -8
  95. package/dist/{cli-x40a0w9j.js → cli-r813c7rb.js} +1 -1
  96. package/dist/{cli-kpgcm7xy.js → cli-ramn8jae.js} +1 -1
  97. package/dist/{cli-cc93xzes.js → cli-raqw9fw9.js} +28 -17
  98. package/dist/cli-rhsc2zyx.js +68 -0
  99. package/dist/{cli-8st34zhr.js → cli-rpmw4fsv.js} +57 -19
  100. package/dist/{cli-had1p04a.js → cli-rwgwen5v.js} +4 -4
  101. package/dist/{cli-tr27kwyg.js → cli-rytq7dm2.js} +261 -6
  102. package/dist/{cli-s1khw52h.js → cli-s9twe4x0.js} +66 -17
  103. package/dist/{cli-2v2zdm0a.js → cli-t2s7j5cy.js} +2 -2
  104. package/dist/{cli-nv4xsvmk.js → cli-tb4j757d.js} +7 -7
  105. package/dist/{cli-q2d3e1k1.js → cli-thd3005a.js} +1 -1
  106. package/dist/cli-tsfkcd4v.js +30 -0
  107. package/dist/{cli-jrbq4djp.js → cli-v3zcnr8g.js} +1 -1
  108. package/dist/{cli-zfqg6fzn.js → cli-vbppqvte.js} +3 -3
  109. package/dist/{cli-qx4f057j.js → cli-vy3fn0mz.js} +4 -4
  110. package/dist/{cli-7sf9sb0w.js → cli-w5dar1bk.js} +1 -1
  111. package/dist/{cli-w1q68d8x.js → cli-wz4e5am2.js} +9 -9
  112. package/dist/{cli-m9cvf7vs.js → cli-xqbqwpxr.js} +14 -14
  113. package/dist/{cli-2spnz7ye.js → cli-ynph3b70.js} +11137 -8332
  114. package/dist/{cli-43evxwj4.js → cli-yvzxbztc.js} +9 -4
  115. package/dist/{cli-vsw91x06.js → cli-yzxqwcvq.js} +3 -6
  116. package/dist/{cli-wafmk3fn.js → cli-zb1hff00.js} +12 -12
  117. package/dist/{cli-yab6sh8p.js → cli-zcghfsdg.js} +23 -4
  118. package/dist/{cli-wwp1bd3n.js → cli-zhn4r1rz.js} +519 -75
  119. package/dist/{cli-tvgqesec.js → cli-zqq57pgx.js} +4 -4
  120. package/dist/cli.js +28 -27
  121. package/dist/{cloudflare-workers-ai-system-one-4aysy6rh.js → cloudflare-workers-ai-system-one-w3m0fbf8.js} +2 -2
  122. package/dist/{codex-adapter-exfdbj73.js → codex-adapter-ssahg4h4.js} +8 -8
  123. package/dist/{codex-hook-59atdwd8.js → codex-hook-aqtj17yr.js} +1 -1
  124. package/dist/{codex-login-a239g1ah.js → codex-login-9c7aggxe.js} +1 -1
  125. package/dist/{codex-session-runner-xhznc4g3.js → codex-session-runner-xn63q3h7.js} +9 -9
  126. package/dist/{commands-d8g349v4.js → commands-ctey7tr5.js} +3 -3
  127. package/dist/{controller-mwgdmb8y.js → controller-rqhbppg9.js} +4 -4
  128. package/dist/{controllers-connect-5v7qx04j.js → controllers-connect-w3qbpbt1.js} +22 -21
  129. package/dist/{core-sxy4epp2.js → core-df1n049h.js} +19 -18
  130. package/dist/{cursor-adapter-p2q5h35d.js → cursor-adapter-r819hf1a.js} +2 -2
  131. package/dist/{db-wcw0b2j8.js → db-2ah39cyx.js} +2 -2
  132. package/dist/{db-qpganbeb.js → db-p5drc1d1.js} +3 -3
  133. package/dist/{devin-adapter-zp4tqq53.js → devin-adapter-bc6g0x29.js} +1 -1
  134. package/dist/{dispatcher-8d8s49yz.js → dispatcher-x6w14pde.js} +19 -18
  135. package/dist/{docker-09tkkg0n.js → docker-6c4reetq.js} +51 -14
  136. package/dist/{dsh-adapter-me0twn13.js → dsh-adapter-h8qn14n4.js} +2 -2
  137. package/dist/{e2b-sm28k0k3.js → e2b-jg7kyyef.js} +6 -6
  138. package/dist/{e2b-3v1e745x.js → e2b-z4ec0qve.js} +3 -3
  139. package/dist/{easter-egg-3d-wv7w5ty6.js → easter-egg-3d-1y6r9gxy.js} +1 -1
  140. package/dist/{embedding-space-e48xchqa.js → embedding-space-z6ptw3jk.js} +6 -6
  141. package/dist/{embeddings-tgq2afbq.js → embeddings-0sxb1d2h.js} +1 -1
  142. package/dist/{event-bus-xr83x566.js → event-bus-swr88jg5.js} +1 -1
  143. package/dist/{execute-8rhwrk7f.js → execute-6m1ex8ce.js} +8 -4
  144. package/dist/{external-channel-8bt3j2pm.js → external-channel-ezer7pk0.js} +2 -2
  145. package/dist/fx-adapter-zwmps9re.js +19 -0
  146. package/dist/{google-generative-ai-bh0djqjp.js → google-generative-ai-sw77egmr.js} +9 -9
  147. package/dist/{google-vertex-prjbw8dj.js → google-vertex-rrw93g8h.js} +9 -9
  148. package/dist/grok-adapter-q0avf919.js +19 -0
  149. package/dist/handlers-g5jq0e4q.js +36 -0
  150. package/dist/{heartbeat-x0056ra5.js → heartbeat-6c4fr49t.js} +22 -21
  151. package/dist/{hook-mrd2ayxv.js → hook-02rt5tvq.js} +8 -8
  152. package/dist/{hook-a7vmn2st.js → hook-t1c5avbv.js} +5 -5
  153. package/dist/{http-ym9c5svp.js → http-qa3h32a1.js} +2049 -148
  154. package/dist/index-1f6m47mq.js +37 -0
  155. package/dist/index-1p1mpqda.js +36 -0
  156. package/dist/{index-p46tvwtx.js → index-akbgsdhh.js} +25 -24
  157. package/dist/{index-ny60jcat.js → index-e42j998x.js} +16 -13
  158. package/dist/{index-b5wgnm78.js → index-kdmkfjt7.js} +4 -4
  159. package/dist/{index-01ns1pkw.js → index-kqv9ebfj.js} +1 -1
  160. package/dist/{index-9myfj74s.js → index-kzdqn3dd.js} +3 -3
  161. package/dist/{index-4a0670yh.js → index-p2f5xg64.js} +6 -6
  162. package/dist/{index-x6azjwm8.js → index-qpjk2hxk.js} +1 -1
  163. package/dist/index-tnkd410q.js +41 -0
  164. package/dist/{k8s-m56sw868.js → k8s-7jrh5va2.js} +73 -14
  165. package/dist/{keepalive-7yxg8z4c.js → keepalive-jmf6pn8c.js} +4 -4
  166. package/dist/lead-m5e7xt93.js +75 -0
  167. package/dist/{llama-cpp-classify-nfgswa1m.js → llama-cpp-classify-yvb8vh7w.js} +2 -2
  168. package/dist/{maintenance-6tefxmk1.js → maintenance-g7v15tj1.js} +1 -1
  169. package/dist/{mistral-conversations-tm2vd4gc.js → mistral-conversations-w4bncwbt.js} +7 -7
  170. package/dist/{node-7qsx5kvm.js → node-z67yjre7.js} +19 -13
  171. package/dist/{oauth-refresh-sweep-70cavc3a.js → oauth-refresh-sweep-ywgf8tbr.js} +3 -3
  172. package/dist/{onboard-fja65z08.js → onboard-m3fedypq.js} +3 -3
  173. package/dist/{openai-codex-responses-sxjv60xx.js → openai-codex-responses-70g39cgz.js} +20 -14
  174. package/dist/{openai-completions-0c7qnhsx.js → openai-completions-cv3hp4h5.js} +18 -11
  175. package/dist/{openai-decisions-ytp6w6xh.js → openai-decisions-fyq1p9f9.js} +2 -2
  176. package/dist/{openai-responses-a7h29chp.js → openai-responses-trsvnks6.js} +13 -11
  177. package/dist/{opencode-adapter-hakkm7yh.js → opencode-adapter-19ktcbb9.js} +7 -7
  178. package/dist/{openrouter-images-xr9gme9x.js → openrouter-images-0jj12a2q.js} +6 -6
  179. package/dist/{otel-impl-7zhnt6gj.js → otel-impl-3ehm1hgc.js} +2 -2
  180. package/dist/{pending-h01yzpx4.js → pending-fwj2fatd.js} +20 -19
  181. package/dist/{pi-messages-2j0fpqwq.js → pi-messages-zk3g4esn.js} +1 -1
  182. package/dist/{pi-mono-adapter-f52hz743.js → pi-mono-adapter-xdeesvc4.js} +18 -17
  183. package/dist/{pricing-refresh-fzxvk2zf.js → pricing-refresh-4j8dzvxg.js} +2 -2
  184. package/dist/{rbac-roles-9v6vhgbs.js → rbac-roles-8msjr07m.js} +3 -3
  185. package/dist/{rbac-roles-hfgh8sba.js → rbac-roles-n7t2acv8.js} +2 -2
  186. package/dist/{render-v2-1rgspxzf.js → render-v2-j7qggj8h.js} +7 -6
  187. package/dist/{resume-tqy61x24.js → resume-hj1mn65y.js} +9 -8
  188. package/dist/{runtime-exkxyx5f.js → runtime-z31mdsgv.js} +2 -2
  189. package/dist/{session-access-3act7vt4.js → session-access-w38fh09a.js} +4 -4
  190. package/dist/{session-source-backfill-82qe7fqq.js → session-source-backfill-ax6qxv20.js} +3 -3
  191. package/dist/{setup-ry1vfdef.js → setup-dsqmpfcr.js} +1 -1
  192. package/dist/thread-buffer-nf55vwx3.js +39 -0
  193. package/dist/tree-visibility-6vqmnr71.js +24 -0
  194. package/dist/{typesafe-system-one-vcfj2ak8.js → typesafe-system-one-qkvkgrcz.js} +2 -2
  195. package/dist/{user-merge-jobs-bx6bf7db.js → user-merge-jobs-mvheb3ed.js} +3 -3
  196. package/dist/{virtual-modules-s0rjzcqq.js → virtual-modules-w2qk2wew.js} +32 -10
  197. package/dist/{work-objects-z2e5tv03.js → work-objects-4ahy5es5.js} +22 -21
  198. package/dist/worker-ews1nyhw.js +75 -0
  199. package/dist/{worker-follow-up-y3xeg89w.js → worker-follow-up-1gs4aw7y.js} +19 -18
  200. package/dist/{x-wg164ss9.js → x-3wr8c5sh.js} +2 -2
  201. package/openapi.json +995 -49
  202. package/package.json +9 -8
  203. package/src/be/db/request-composition.ts +190 -0
  204. package/src/be/db/runtime.ts +15 -0
  205. package/src/be/db/slack-trees.ts +220 -10
  206. package/src/be/db/tasks/human-free.ts +3 -2
  207. package/src/be/db/workflow-run-retention.ts +101 -0
  208. package/src/be/db-client.ts +23 -1
  209. package/src/be/db-retention-defaults.ts +46 -0
  210. package/src/be/db-retention.ts +55 -6
  211. package/src/be/mcp-events/catalog.ts +108 -0
  212. package/src/be/mcp-events/dispatcher.ts +202 -0
  213. package/src/be/mcp-events/protocol.ts +296 -0
  214. package/src/be/mcp-events/store.ts +231 -0
  215. package/src/be/mcp-events/webhook.ts +226 -0
  216. package/src/be/memory/providers/sqlite-store.ts +110 -24
  217. package/src/be/memory/review-recall-filter.ts +22 -0
  218. package/src/be/memory/search-candidates.ts +5 -7
  219. package/src/be/memory/types.ts +5 -0
  220. package/src/be/migrations/322_runtime_pool_workspace.sql +8 -0
  221. package/src/be/migrations/323_slack_task_tree_visibility.sql +9 -0
  222. package/src/be/migrations/326_slack_reconcile_pages.sql +13 -0
  223. package/src/be/migrations/327_mcp_event_subscriptions.sql +57 -0
  224. package/src/be/migrations/329_workflow_run_retention.sql +9 -0
  225. package/src/be/migrations/330_request_composition.sql +22 -0
  226. package/src/be/model-profile-check.ts +1 -1
  227. package/src/be/multi-runtime.ts +32 -4
  228. package/src/be/runtime-pools/controllers.ts +18 -3
  229. package/src/be/runtime-pools/db.ts +15 -4
  230. package/src/be/runtime-pools/supervisor.ts +42 -2
  231. package/src/be/swarm-config-guard.ts +10 -2
  232. package/src/commands/context-preamble.ts +11 -4
  233. package/src/commands/credential-outcome-report.ts +33 -9
  234. package/src/commands/e2b-stack-wizard.tsx +12 -6
  235. package/src/commands/runner.ts +116 -12
  236. package/src/extensions/catalog.generated.json +1 -1
  237. package/src/github/app.ts +59 -14
  238. package/src/http/all-routes.ts +2 -0
  239. package/src/http/config.ts +2 -1
  240. package/src/http/core.ts +2 -0
  241. package/src/http/github-token.ts +66 -0
  242. package/src/http/index.ts +21 -0
  243. package/src/http/mcp-user.ts +11 -8
  244. package/src/http/mcp.ts +58 -42
  245. package/src/http/prompt-templates.ts +1 -0
  246. package/src/http/request-composition.ts +310 -0
  247. package/src/http/tasks.ts +6 -1
  248. package/src/http/tool-schema-estimate.ts +95 -0
  249. package/src/http/workflows.ts +29 -11
  250. package/src/integrations/chat-sdk/inbound.ts +2 -2
  251. package/src/prompts/base-prompt.ts +133 -7
  252. package/src/prompts/resolver.ts +41 -2
  253. package/src/providers/amp-adapter.ts +1 -1
  254. package/src/providers/opencode-adapter.ts +72 -1
  255. package/src/providers/opencode-swarm-plugin.ts +22 -3
  256. package/src/providers/pi-mono-adapter.ts +1 -0
  257. package/src/providers/pi-mono-extension.ts +71 -0
  258. package/src/providers/pricing-sources.md +4 -0
  259. package/src/providers/request-composition-hook.ts +312 -0
  260. package/src/providers/types.ts +5 -0
  261. package/src/runtime-providers/controller-protocol.ts +7 -0
  262. package/src/runtime-providers/docker.ts +80 -12
  263. package/src/runtime-providers/k8s.ts +111 -6
  264. package/src/runtime-providers/types.ts +17 -0
  265. package/src/scheduler/scheduler.ts +1 -1
  266. package/src/server-user.ts +16 -1
  267. package/src/slack/ack.ts +10 -5
  268. package/src/slack/actions.ts +3 -3
  269. package/src/slack/app.ts +2 -0
  270. package/src/slack/assistant.ts +4 -4
  271. package/src/slack/blocks.ts +3 -3
  272. package/src/slack/handlers.ts +3 -3
  273. package/src/slack/reaction-shortcode.ts +23 -2
  274. package/src/slack/render-v2.ts +297 -200
  275. package/src/slack/responses.ts +7 -5
  276. package/src/slack/thread-buffer.ts +3 -3
  277. package/src/slack/tree-visibility.ts +64 -0
  278. package/src/tasks/worker-follow-up.ts +127 -17
  279. package/src/tests/azure-devops-outbound.test.ts +47 -14
  280. package/src/tests/base-prompt.test.ts +149 -1
  281. package/src/tests/check-playwright-version.test.ts +33 -0
  282. package/src/tests/context-preamble-budget.test.ts +65 -0
  283. package/src/tests/credential-outcome-report.test.ts +81 -1
  284. package/src/tests/db-client.test.ts +22 -0
  285. package/src/tests/db-retention-defaults.test.ts +244 -0
  286. package/src/tests/db-retention.test.ts +2 -1
  287. package/src/tests/db-runtime.test.ts +2 -1
  288. package/src/tests/deploy-release-dispatch.test.ts +332 -0
  289. package/src/tests/e2b-stack-wizard.test.tsx +156 -0
  290. package/src/tests/entrypoint-chown-no-follow.test.ts +69 -0
  291. package/src/tests/entrypoint-repo-clone-target.test.ts +112 -0
  292. package/src/tests/env-flag.test.ts +4 -2
  293. package/src/tests/event-loop-lag.test.ts +12 -18
  294. package/src/tests/extensions-example-slack-reply-gate.test.ts +15 -0
  295. package/src/tests/fixtures/base-prompt-baseline-cases.ts +78 -0
  296. package/src/tests/fixtures/base-prompt-baseline.json +18 -0
  297. package/src/tests/github-app-worker-auth-helper.test.ts +325 -0
  298. package/src/tests/github-installation-token-route.test.ts +199 -0
  299. package/src/tests/mcp-user-events.test.ts +708 -0
  300. package/src/tests/memory-key-paths.test.ts +4 -1
  301. package/src/tests/memory-search-stall.test.ts +421 -0
  302. package/src/tests/migration-322-runtime-pool-workspace.test.ts +116 -0
  303. package/src/tests/migration-329-workflow-run-retention.test.ts +32 -0
  304. package/src/tests/model-profile-fallbacks.test.ts +236 -2
  305. package/src/tests/opencode-adapter.test.ts +86 -0
  306. package/src/tests/pi-mono-extension.test.ts +168 -0
  307. package/src/tests/preload-env.test.ts +61 -1
  308. package/src/tests/preload.ts +22 -0
  309. package/src/tests/prompt-template-resolver.test.ts +85 -0
  310. package/src/tests/reload-config.test.ts +45 -0
  311. package/src/tests/request-composition.test.ts +447 -0
  312. package/src/tests/runner-max-concurrent.test.ts +86 -0
  313. package/src/tests/runtime-pools-db.test.ts +80 -0
  314. package/src/tests/runtime-provider-registration.test.ts +8 -0
  315. package/src/tests/runtime-providers-docker.test.ts +192 -1
  316. package/src/tests/runtime-providers-k8s.test.ts +127 -0
  317. package/src/tests/runtime-remote-controller.test.ts +64 -1
  318. package/src/tests/runtime-supervisor.test.ts +101 -0
  319. package/src/tests/script-connections.test.ts +8 -0
  320. package/src/tests/slack-blocks.test.ts +18 -0
  321. package/src/tests/slack-empty-icon-config.test.ts +113 -0
  322. package/src/tests/slack-reaction-config.test.ts +38 -2
  323. package/src/tests/slack-render-v2-query-plans.test.ts +100 -1
  324. package/src/tests/slack-render-v2-reconcile.test.ts +75 -4
  325. package/src/tests/slack-render-v2.test.ts +683 -11
  326. package/src/tests/swarm-config-reserved-keys.test.ts +1 -0
  327. package/src/tests/task-session-prompts.test.ts +37 -0
  328. package/src/tests/user-delete-perf.test.ts +36 -9
  329. package/src/tests/webhook-filter.test.ts +327 -0
  330. package/src/tests/workflow-async-v2.test.ts +19 -16
  331. package/src/tests/workflow-definition-telemetry.test.ts +15 -5
  332. package/src/tests/workflow-e2e.test.ts +1 -9
  333. package/src/tests/workflow-finalization-races.test.ts +553 -0
  334. package/src/tests/workflow-foreach.test.ts +2 -0
  335. package/src/tests/workflow-hitl-routing.test.ts +26 -20
  336. package/src/tests/workflow-http-v2.test.ts +105 -2
  337. package/src/tests/workflow-idempotency.test.ts +41 -0
  338. package/src/tests/workflow-mcp-webhook-filter.test.ts +214 -0
  339. package/src/tests/workflow-parallel-park.test.ts +297 -0
  340. package/src/tests/workflow-retry-v2.test.ts +57 -21
  341. package/src/tests/workflow-retry-validation.test.ts +13 -13
  342. package/src/tests/workflow-runs-retention.test.ts +533 -0
  343. package/src/tests/workflow-script-principal.test.ts +7 -2
  344. package/src/tests/workflow-tla-races.test.ts +7 -2
  345. package/src/tests/workflow-triggers-v2.test.ts +201 -0
  346. package/src/tests/workflow-wait-builtin-events.test.ts +3 -1
  347. package/src/tests/workflow-wait-event.test.ts +28 -2
  348. package/src/tests/workflow-wait-poller.test.ts +94 -0
  349. package/src/tests/workflow-wait-time.test.ts +7 -3
  350. package/src/tests/workflow-wait.test.ts +26 -0
  351. package/src/tests/workflow-wait.ts +44 -0
  352. package/src/tools/workflows/create-workflow.ts +7 -3
  353. package/src/tools/workflows/update-workflow.ts +7 -3
  354. package/src/types.ts +200 -2
  355. package/src/utils/credentials.ts +7 -0
  356. package/src/workflows/checkpoint.ts +18 -0
  357. package/src/workflows/engine.ts +38 -10
  358. package/src/workflows/foreach-driver.ts +42 -4
  359. package/src/workflows/recovery.ts +6 -1
  360. package/src/workflows/resume.ts +11 -3
  361. package/src/workflows/retry-poller.ts +17 -4
  362. package/src/workflows/successor-routing.ts +108 -0
  363. package/src/workflows/task-step-routing.ts +5 -2
  364. package/src/workflows/triggers.ts +21 -36
  365. package/src/workflows/wait-poller.ts +6 -2
  366. package/src/workflows/webhook-filter.ts +203 -0
  367. package/templates/extensions/slack-reply-gate/hooks.ts +8 -4
  368. package/templates/skills/swarm-docs/content.md +2 -0
  369. package/dist/acp-adapter-bht22g3k.js +0 -16
  370. package/dist/fx-adapter-adtdb3jb.js +0 -19
  371. package/dist/grok-adapter-accnn9km.js +0 -19
  372. package/dist/handlers-1x77561e.js +0 -35
  373. package/dist/index-48qzcqzj.js +0 -35
  374. package/dist/index-rkvaambe.js +0 -36
  375. package/dist/index-xj1mq27m.js +0 -40
  376. package/dist/lead-enzn86bz.js +0 -74
  377. package/dist/thread-buffer-3x93yexa.js +0 -38
  378. package/dist/worker-zfcv2wbf.js +0 -74
package/src/types.ts CHANGED
@@ -2534,6 +2534,11 @@ export const RuntimePoolCacheSchema = z
2534
2534
  })
2535
2535
  .strict();
2536
2536
 
2537
+ /** Persistent `/workspace/personal` per (agent, slot). `sizeGb` applies to k8s only. */
2538
+ export const RuntimePoolWorkspaceSchema = z
2539
+ .object({ sizeGb: z.number().int().min(1).max(1024).optional() })
2540
+ .strict();
2541
+
2537
2542
  export const RuntimePoolCreateSchema = z
2538
2543
  .object({
2539
2544
  name: z.string().min(1).max(200),
@@ -2549,6 +2554,7 @@ export const RuntimePoolCreateSchema = z
2549
2554
  env: z.record(z.string(), z.string()).default({}),
2550
2555
  resources: RuntimeResourcesSchema.nullable().default(null),
2551
2556
  cache: RuntimePoolCacheSchema.nullable().default(null),
2557
+ workspace: RuntimePoolWorkspaceSchema.nullable().default(null),
2552
2558
  ttlSec: z.number().int().positive().nullable().default(null),
2553
2559
  enabled: z.boolean().default(true),
2554
2560
  })
@@ -2563,6 +2569,7 @@ export const RuntimePoolUpdateSchema = RuntimePoolCreateSchema.partial().extend(
2563
2569
  env: z.record(z.string(), z.string()).optional(),
2564
2570
  resources: RuntimeResourcesSchema.nullable().optional(),
2565
2571
  cache: RuntimePoolCacheSchema.nullable().optional(),
2572
+ workspace: RuntimePoolWorkspaceSchema.nullable().optional(),
2566
2573
  ttlSec: z.number().int().positive().nullable().optional(),
2567
2574
  enabled: z.boolean().optional(),
2568
2575
  });
@@ -2612,6 +2619,8 @@ export const RuntimeInstanceSchema = z
2612
2619
  idleSince: z.string().nullable().optional(),
2613
2620
  leaseExpiresAt: z.string().nullable().optional(),
2614
2621
  taskId: z.string().nullable().optional(),
2622
+ /** Persistent workspace slot (lowest free per agent); null without a pool workspace. */
2623
+ workspaceSlot: z.number().int().nullable().optional(),
2615
2624
  /** Runtime-local concurrent task capacity, self-reported at registration. */
2616
2625
  reportedSlots: z.number().int(),
2617
2626
  /** Process-local credential readiness; null when never reported. */
@@ -2898,6 +2907,131 @@ export const WebhookVerificationSchema = z.discriminatedUnion("format", [
2898
2907
  ]);
2899
2908
  export type WebhookVerification = z.infer<typeof WebhookVerificationSchema>;
2900
2909
 
2910
+ const WEBHOOK_FILTER_MAX_FIELDS = 32;
2911
+ const WEBHOOK_FILTER_MAX_VALUES = 64;
2912
+ const WEBHOOK_FILTER_MAX_STRING = 512;
2913
+ const WEBHOOK_FILTER_MAX_HEADER_NAME = 128;
2914
+ const WEBHOOK_FILTER_MAX_PATH = 256;
2915
+ const WEBHOOK_FILTER_MAX_SEGMENTS = 12;
2916
+ const WEBHOOK_FILTER_MAX_SEGMENT = 128;
2917
+ /** HTTP token (RFC 9110 tchar), so header names cannot carry spaces or control characters. */
2918
+ const WEBHOOK_FILTER_HEADER_NAME = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
2919
+
2920
+ export const WEBHOOK_FILTER_PRESETS = ["github", "gitlab", "standard-webhooks"] as const;
2921
+ export const WebhookFilterPresetSchema = z.enum(WEBHOOK_FILTER_PRESETS);
2922
+
2923
+ function hasControlCharacter(value: string): boolean {
2924
+ for (let i = 0; i < value.length; i++) {
2925
+ const code = value.charCodeAt(i);
2926
+ if (code <= 0x1f || code === 0x7f) return true;
2927
+ }
2928
+ return false;
2929
+ }
2930
+
2931
+ function webhookBodyPathIssue(path: string): string | null {
2932
+ if (path.length > WEBHOOK_FILTER_MAX_PATH) {
2933
+ return `body path is longer than ${WEBHOOK_FILTER_MAX_PATH} characters`;
2934
+ }
2935
+ const segments = path.split(".");
2936
+ if (segments.length > WEBHOOK_FILTER_MAX_SEGMENTS) {
2937
+ return `body path has more than ${WEBHOOK_FILTER_MAX_SEGMENTS} segments`;
2938
+ }
2939
+ for (const segment of segments) {
2940
+ if (segment.length === 0) return "body path has an empty segment";
2941
+ if (segment.length > WEBHOOK_FILTER_MAX_SEGMENT) {
2942
+ return `body path segment is longer than ${WEBHOOK_FILTER_MAX_SEGMENT} characters`;
2943
+ }
2944
+ if (hasControlCharacter(segment)) return "body path segment has a control character";
2945
+ }
2946
+ return null;
2947
+ }
2948
+
2949
+ const webhookFilterHeaderValueSchema = z.union([
2950
+ z.string().min(1).max(WEBHOOK_FILTER_MAX_STRING),
2951
+ z.array(z.string().min(1).max(WEBHOOK_FILTER_MAX_STRING)).min(1).max(WEBHOOK_FILTER_MAX_VALUES),
2952
+ ]);
2953
+
2954
+ const webhookFilterBodyScalarSchema = z.union([
2955
+ z.string().max(WEBHOOK_FILTER_MAX_STRING),
2956
+ z.number().finite(),
2957
+ z.boolean(),
2958
+ z.null(),
2959
+ ]);
2960
+
2961
+ const webhookFilterBodyValueSchema = z.union([
2962
+ webhookFilterBodyScalarSchema,
2963
+ z.array(webhookFilterBodyScalarSchema).min(1).max(WEBHOOK_FILTER_MAX_VALUES),
2964
+ ]);
2965
+
2966
+ export const WebhookDeliveryFilterSchema = z
2967
+ .strictObject({
2968
+ headers: z
2969
+ .record(z.string().min(1).max(WEBHOOK_FILTER_MAX_HEADER_NAME), webhookFilterHeaderValueSchema)
2970
+ .optional()
2971
+ .describe(
2972
+ "Header name to one exact value, or a list of exact values. Names are matched case-insensitively. Every entry must match.",
2973
+ ),
2974
+ body: z
2975
+ .record(z.string().min(1).max(WEBHOOK_FILTER_MAX_PATH), webhookFilterBodyValueSchema)
2976
+ .optional()
2977
+ .describe(
2978
+ "Dot path into the JSON body, to one exact scalar or a list of scalars. A numeric segment indexes an array (commits.0.id). No type coercion. Every entry must match.",
2979
+ ),
2980
+ })
2981
+ .superRefine((filter, ctx) => {
2982
+ const headerNames = filter.headers ? Object.keys(filter.headers) : [];
2983
+ const bodyPaths = filter.body ? Object.keys(filter.body) : [];
2984
+ if (headerNames.length + bodyPaths.length === 0) {
2985
+ ctx.addIssue({
2986
+ code: "custom",
2987
+ message: "filter needs at least one header or body field",
2988
+ });
2989
+ }
2990
+ if (headerNames.length > WEBHOOK_FILTER_MAX_FIELDS) {
2991
+ ctx.addIssue({
2992
+ code: "custom",
2993
+ message: `filter has more than ${WEBHOOK_FILTER_MAX_FIELDS} headers`,
2994
+ path: ["headers"],
2995
+ });
2996
+ }
2997
+ if (bodyPaths.length > WEBHOOK_FILTER_MAX_FIELDS) {
2998
+ ctx.addIssue({
2999
+ code: "custom",
3000
+ message: `filter has more than ${WEBHOOK_FILTER_MAX_FIELDS} body fields`,
3001
+ path: ["body"],
3002
+ });
3003
+ }
3004
+ const seenHeaders = new Set<string>();
3005
+ for (const name of headerNames) {
3006
+ if (!WEBHOOK_FILTER_HEADER_NAME.test(name)) {
3007
+ ctx.addIssue({
3008
+ code: "custom",
3009
+ message: "header name must be an HTTP token",
3010
+ path: ["headers", name],
3011
+ });
3012
+ }
3013
+ const folded = name.toLowerCase();
3014
+ if (seenHeaders.has(folded)) {
3015
+ ctx.addIssue({
3016
+ code: "custom",
3017
+ message: "duplicate header name",
3018
+ path: ["headers", name],
3019
+ });
3020
+ }
3021
+ seenHeaders.add(folded);
3022
+ }
3023
+ for (const path of bodyPaths) {
3024
+ const issue = webhookBodyPathIssue(path);
3025
+ if (issue) {
3026
+ ctx.addIssue({ code: "custom", message: issue, path: ["body", path] });
3027
+ }
3028
+ }
3029
+ })
3030
+ .describe(
3031
+ "AND of header and JSON body allowlists. A delivery that misses is acknowledged with 200 and creates no run.",
3032
+ );
3033
+ export type WebhookDeliveryFilter = z.infer<typeof WebhookDeliveryFilterSchema>;
3034
+
2901
3035
  export const TriggerConfigSchema = z
2902
3036
  .discriminatedUnion("type", [
2903
3037
  z.object({
@@ -2916,15 +3050,21 @@ export const TriggerConfigSchema = z
2916
3050
  .array(z.string().min(1))
2917
3051
  .optional()
2918
3052
  .describe(
2919
- "Optional event allowlist, matched exactly against the eventHeader value after signature verification. A delivery whose event is not listed (or that has no event header) gets a 2xx `skipped` reply and creates no run. Omit or leave empty to accept every event.",
3053
+ "Deprecated alias of one delivery-filter clause, AND-ed with filter. Matched exactly against eventHeader, or against the preset event field when eventHeader is omitted: X-GitHub-Event (github, and the default), X-Gitlab-Event (gitlab), or JSON body type (standard-webhooks). A miss returns 200 skipped with reason event-not-allowed and creates no run. Omit or leave empty to add no event clause.",
2920
3054
  ),
2921
3055
  eventHeader: z
2922
3056
  .string()
2923
3057
  .min(1)
2924
3058
  .optional()
2925
3059
  .describe(
2926
- "Request header holding the event name for `events` (case-insensitive lookup). Defaults to X-GitHub-Event.",
3060
+ "Deprecated. Header read for events. The name lookup is case-insensitive and the value is exact. Overrides preset. Defaults to X-GitHub-Event when preset is omitted.",
2927
3061
  ),
3062
+ preset: WebhookFilterPresetSchema.optional().describe(
3063
+ "Optional sender preset for the events allowlist. github reads X-GitHub-Event, gitlab reads X-Gitlab-Event, and standard-webhooks reads the JSON body field type. A preset alone does not filter. Ignored when eventHeader is set.",
3064
+ ),
3065
+ filter: WebhookDeliveryFilterSchema.optional().describe(
3066
+ "Header and JSON body allowlists, AND-ed with events. Evaluated after signature verification and before a run is saved. A miss returns 200 skipped with reason filter-not-matched and creates no run.",
3067
+ ),
2928
3068
  }),
2929
3069
  z.object({
2930
3070
  type: z.literal("schedule"),
@@ -4202,6 +4342,64 @@ export const ContextSnapshotSchema = z
4202
4342
 
4203
4343
  export type ContextSnapshot = z.infer<typeof ContextSnapshotSchema>;
4204
4344
 
4345
+ // Migration 248: per-session request composition manifest. Each part is one
4346
+ // static piece of the prompt the harness sends on every LLM call. Message
4347
+ // history and the harness's own base prompt are derived at read time.
4348
+ export const RequestCompositionPartKindSchema = z.enum([
4349
+ "system_section",
4350
+ "persona",
4351
+ "claude_md",
4352
+ "operator_prompt",
4353
+ "tool_schemas",
4354
+ "skills_listing",
4355
+ "task_prompt",
4356
+ "memories",
4357
+ ]);
4358
+ export type RequestCompositionPartKind = z.infer<typeof RequestCompositionPartKindSchema>;
4359
+
4360
+ export const RequestCompositionFidelitySchema = z.enum(["exact", "estimate"]);
4361
+
4362
+ /** A part as the worker measures it: chars only, the server adds the estimate. */
4363
+ export const RequestCompositionPartInputSchema = z.object({
4364
+ kind: RequestCompositionPartKindSchema,
4365
+ id: z.string().min(1).max(200),
4366
+ label: z.string().min(1).max(200),
4367
+ chars: z.number().int().min(0),
4368
+ fidelity: RequestCompositionFidelitySchema.default("exact"),
4369
+ });
4370
+ export type RequestCompositionPartInput = z.input<typeof RequestCompositionPartInputSchema>;
4371
+
4372
+ export const RequestCompositionPartSchema = RequestCompositionPartInputSchema.extend({
4373
+ estTokens: z.number().int().min(0),
4374
+ }).openapi("RequestCompositionPart");
4375
+ export type RequestCompositionPart = z.infer<typeof RequestCompositionPartSchema>;
4376
+
4377
+ /**
4378
+ * Which swarm tool schemas the harness sends up front. Worker-side facts:
4379
+ * claude defers every MCP tool behind ToolSearch except preloaded ones, pi
4380
+ * with PI_TOOL_DEFERRAL keeps the core set plus preloaded ones.
4381
+ */
4382
+ export const RequestCompositionToolLoadingSchema = z.enum(["all", "core", "preloaded", "none"]);
4383
+ export type RequestCompositionToolLoading = z.infer<typeof RequestCompositionToolLoadingSchema>;
4384
+
4385
+ export const RequestCompositionSchema = z
4386
+ .object({
4387
+ id: z.uuid(),
4388
+ taskId: z.string(),
4389
+ agentId: z.string(),
4390
+ sessionId: z.string(),
4391
+ seq: z.number().int().min(0),
4392
+ provider: z.string(),
4393
+ model: z.string().nullable(),
4394
+ source: z.enum(["worker", "harness-hook"]),
4395
+ parts: z.array(RequestCompositionPartSchema),
4396
+ staticEstTokens: z.number().int().min(0),
4397
+ tokenRatio: z.number(),
4398
+ createdAt: z.iso.datetime(),
4399
+ })
4400
+ .openapi("RequestComposition");
4401
+ export type RequestComposition = z.infer<typeof RequestCompositionSchema>;
4402
+
4205
4403
  // ============================================================================
4206
4404
  // Budgets + Pricing (per-agent daily cost budget — V1)
4207
4405
  // ============================================================================
@@ -598,6 +598,13 @@ export async function resolveCredentialPools(
598
598
  let modelBlockedCount = allowedIdx
599
599
  ? (info?.modelBlockedIndices?.filter(inAllowlist).length ?? 0)
600
600
  : (info?.modelBlockedIndices?.length ?? 0);
601
+ // A key-wide report this worker could not persist (`reportCredentialOutcomeThenFinish`)
602
+ // still keeps the key out of the next draw, also when the availability read failed too.
603
+ const keyBlocked = (i: number) => (opts?.localBlocks?.get(`${envVar}:${i}:key`) ?? 0) > nowMs;
604
+ const pool = splitCredentialPool(val).map((_, i) => i);
605
+ if (pool.some(keyBlocked)) {
606
+ available = (available ?? pool.filter(inAllowlist)).filter((i) => !keyBlocked(i));
607
+ }
601
608
  if (available && window && opts?.localBlocks) {
602
609
  const beforeCount = available.length;
603
610
  available = available.filter((i) => {
@@ -24,6 +24,22 @@ async function holdsFence(runId: string, stepId: string, fence: StepFence): Prom
24
24
  return row != null && (await getRunLineageBlock(runId)) == null;
25
25
  }
26
26
 
27
+ /**
28
+ * Fold the stored run context into this walker's copy, inside the caller's
29
+ * transaction and before it writes `context: ctx`. Each walker writes the
30
+ * whole context from its own copy, so a key another walker stored meanwhile
31
+ * would otherwise be dropped. The walker's own value wins on a shared key.
32
+ */
33
+ export async function adoptStoredContext(
34
+ runId: string,
35
+ ctx: Record<string, unknown>,
36
+ ): Promise<void> {
37
+ const stored = (await getWorkflowRun(runId))?.context as Record<string, unknown> | undefined;
38
+ for (const key in stored) {
39
+ if (!(key in ctx)) ctx[key] = stored[key];
40
+ }
41
+ }
42
+
27
43
  /**
28
44
  * Checkpoint a successful step — atomic DB write of step result + run context.
29
45
  * Returns false, writing nothing, when `fence` no longer holds.
@@ -46,6 +62,7 @@ export async function checkpointStep(
46
62
  });
47
63
 
48
64
  // Merge step output into run context
65
+ await adoptStoredContext(runId, ctx);
49
66
  ctx[nodeId] = result.output;
50
67
  await updateWorkflowRun(runId, {
51
68
  context: ctx,
@@ -145,6 +162,7 @@ export async function checkpointStepWaiting(
145
162
  );
146
163
  if (!step) return false;
147
164
 
165
+ await adoptStoredContext(runId, ctx);
148
166
  await updateWorkflowRun(
149
167
  runId,
150
168
  options.keepRunStatus ? { context: ctx } : { status: "waiting", context: ctx },
@@ -31,6 +31,7 @@ import { WorkflowReplayStateError } from "../be/workflow-replay";
31
31
  import { telemetry } from "../telemetry";
32
32
  import type { Workflow, WorkflowDefinition, WorkflowNode, WorkflowRunStep } from "../types";
33
33
  import {
34
+ adoptStoredContext,
34
35
  checkpointStep,
35
36
  checkpointStepFailure,
36
37
  checkpointStepWaiting,
@@ -54,6 +55,11 @@ import { validateJsonSchema } from "./json-schema-validator";
54
55
  import { getMaxWorkflowStepsPerRun } from "./limits";
55
56
  import { resolveNodeTimeoutMs, startStepDeadline } from "./node-timeout";
56
57
  import { findWorkflowReadinessProblems, formatReadinessRunError } from "./readiness";
58
+ import {
59
+ hasOwedSuccessors,
60
+ holdSuccessorRouting,
61
+ type SuccessorWalkDebt,
62
+ } from "./successor-routing";
57
63
  import { deepInterpolate } from "./template";
58
64
  import { runStepValidation, type ValidationRunResult } from "./validation";
59
65
 
@@ -94,6 +100,12 @@ export interface WorkflowExecutionOptions {
94
100
  * needs the run id waits for every instant step before it.
95
101
  */
96
102
  detach?: boolean;
103
+ /**
104
+ * The hold of the claim whose successors this walk routes
105
+ * (`TaskStepRoutingResult.successorDebt`). `walkGraph` takes it over and
106
+ * strips it, so steps never see it.
107
+ */
108
+ successorDebt?: SuccessorWalkDebt;
97
109
  }
98
110
 
99
111
  /**
@@ -466,11 +478,25 @@ export async function walkGraph(
466
478
  options: WorkflowExecutionOptions = {},
467
479
  ): Promise<void> {
468
480
  const release = holdWorkflowRun(runId);
481
+ // Taken before the first await: the claim that owes this walk hands over here.
482
+ const { successorDebt, ...walkOptions } = options;
483
+ const routed = holdSuccessorRouting(runId, successorDebt);
469
484
  try {
470
- await walkGraphOwned(def, runId, ctx, startNodes, registry, workflowId, secretKeys, options);
485
+ await walkGraphOwned(
486
+ def,
487
+ runId,
488
+ ctx,
489
+ startNodes,
490
+ registry,
491
+ routed,
492
+ workflowId,
493
+ secretKeys,
494
+ walkOptions,
495
+ );
471
496
  } catch (err) {
472
497
  if (!(await failRunOnUnreadableReplay(runId, err))) throw err;
473
498
  } finally {
499
+ routed();
474
500
  release();
475
501
  }
476
502
  }
@@ -481,6 +507,7 @@ async function walkGraphOwned(
481
507
  ctx: Record<string, unknown>,
482
508
  startNodes: WorkflowNode[],
483
509
  registry: ExecutorRegistry,
510
+ routed: () => void,
484
511
  workflowId?: string,
485
512
  secretKeys: Set<string> = new Set(),
486
513
  options: WorkflowExecutionOptions = {},
@@ -588,7 +615,6 @@ async function walkGraphOwned(
588
615
 
589
616
  // Collect successors and check for errors/pauses
590
617
  const nextBatch = new Map<string, WorkflowNode>();
591
- let hasWaiting = false;
592
618
 
593
619
  for (let i = 0; i < results.length; i++) {
594
620
  const result = results[i]!;
@@ -600,10 +626,9 @@ async function walkGraphOwned(
600
626
  if (currentRun?.status === "failed") return;
601
627
  continue;
602
628
  }
603
- if (result.outcome === "waiting") {
604
- hasWaiting = true;
605
- continue;
606
- }
629
+ // A waiting step pauses only its own branch. Its siblings' successors
630
+ // still run here, and the check below holds any join it feeds.
631
+ if (result.outcome === "waiting") continue;
607
632
  // Mark this node as completed
608
633
  const sourceNodeId = pendingNodes[i]!.id;
609
634
  completedNodeIds.add(sourceNodeId);
@@ -615,8 +640,6 @@ async function walkGraphOwned(
615
640
  }
616
641
  }
617
642
 
618
- if (hasWaiting) return; // Run paused, will be resumed by event
619
-
620
643
  // Convergence check — only wait for predecessors with active edges to
621
644
  // this node, not all structural predecessors. This prevents deadlocks
622
645
  // when conditional branches skip nodes.
@@ -662,6 +685,7 @@ async function walkGraphOwned(
662
685
  // finalizeOrWait): a cancel committing in between would otherwise be
663
686
  // overwritten from a stale snapshot, resurrecting the run as `completed` or
664
687
  // parking it in `waiting` with no waiting step left to ever finalize it.
688
+ routed();
665
689
  await getDbClient().transaction(async () => {
666
690
  const run = await getWorkflowRun(runId);
667
691
  if (!run || run.status !== "running") return;
@@ -669,8 +693,10 @@ async function walkGraphOwned(
669
693
  if (await getRunLineageBlock(runId)) return;
670
694
 
671
695
  const finalSteps = await getWorkflowRunStepsByRunId(runId);
672
- // Another walker is still executing a branch; it finalizes the run.
673
- if (hasRunningStep(finalSteps)) return;
696
+ // Another walker is still executing a branch, or has successors left to
697
+ // start; it finalizes the run.
698
+ if (hasRunningStep(finalSteps) || hasOwedSuccessors(runId)) return;
699
+ await adoptStoredContext(runId, ctx);
674
700
  const hasWaitingSteps = finalSteps.some((s) => s.status === "waiting");
675
701
  const hasPendingRetries = finalSteps.some(
676
702
  (s) => s.status === "failed" && s.nextRetryAt != null,
@@ -1159,6 +1185,8 @@ async function runClaimedStep(
1159
1185
  ctx,
1160
1186
  registry,
1161
1187
  });
1188
+ // This walk's own hold covers the successors it routes next.
1189
+ drive.successorDebt?.release();
1162
1190
  if (drive.joined) return { outcome: "completed", successors: drive.successors };
1163
1191
  return { outcome: drive.parked ? "waiting" : "completed", successors: [] };
1164
1192
  }
@@ -49,6 +49,7 @@ import {
49
49
  import { getSecretInputKeys } from "./input";
50
50
  import { resolveNodeTimeoutMs, startStepDeadline } from "./node-timeout";
51
51
  import { rebuildNodeExecutionInput } from "./step-input";
52
+ import { claimAndOweWalk, type SuccessorWalkDebt } from "./successor-routing";
52
53
 
53
54
  export { FOREACH_ITEMS_WAIT_FOR };
54
55
 
@@ -69,6 +70,12 @@ export interface ForeachDriveResult {
69
70
  successors: WorkflowNode[];
70
71
  /** How many children this drive claimed (queued or orphaned). */
71
72
  claimed: number;
73
+ /**
74
+ * The join's hold on the run, taken in the transaction that closed it, when
75
+ * `successors` is nonempty. Pass it to the `walkGraph` that routes them, or
76
+ * release it.
77
+ */
78
+ successorDebt?: SuccessorWalkDebt;
72
79
  }
73
80
 
74
81
  const NOT_JOINED: ForeachDriveResult = { joined: false, successors: [], claimed: 0 };
@@ -125,6 +132,23 @@ export async function driveForeach(
125
132
  parentNodeId: string,
126
133
  registry: ExecutorRegistry,
127
134
  options: { ctx?: Record<string, unknown> } = {},
135
+ ): Promise<ForeachDriveResult> {
136
+ const owed: { debt?: SuccessorWalkDebt } = {};
137
+ try {
138
+ return await driveForeachOwed(runId, parentNodeId, registry, options, owed);
139
+ } catch (err) {
140
+ // The join closed, then the drive's cleanup threw: no walk takes the hold.
141
+ owed.debt?.release();
142
+ throw err;
143
+ }
144
+ }
145
+
146
+ async function driveForeachOwed(
147
+ runId: string,
148
+ parentNodeId: string,
149
+ registry: ExecutorRegistry,
150
+ options: { ctx?: Record<string, unknown> },
151
+ owed: { debt?: SuccessorWalkDebt },
128
152
  ): Promise<ForeachDriveResult> {
129
153
  const run = await getWorkflowRun(runId);
130
154
  if (!run || (run.status !== "running" && run.status !== "waiting")) return NOT_JOINED;
@@ -176,12 +200,20 @@ export async function driveForeach(
176
200
  item: items.find((candidate) => candidate[itemKeyField] === childItemKey(child)),
177
201
  });
178
202
  if (!outcome) continue;
179
- const settled = await settleForeachChild(def, runId, child.id, outcome, ctx, {
180
- from: ["running"],
181
- });
203
+ // The join's successors have no step row until a walk starts them:
204
+ // owe that walk from the commit that closes the join.
205
+ const settled = await claimAndOweWalk(runId, () =>
206
+ settleForeachChild(def, runId, child.id, outcome, ctx, { from: ["running"] }),
207
+ );
182
208
  ownedChildren.delete(child.id);
183
209
  if (settled.joined) {
184
- return { joined: true, successors: settled.successors, claimed: claimedTotal };
210
+ owed.debt = settled.successorDebt;
211
+ return {
212
+ joined: true,
213
+ successors: settled.successors,
214
+ claimed: claimedTotal,
215
+ successorDebt: settled.successorDebt,
216
+ };
185
217
  }
186
218
  if (settled.runFailed) {
187
219
  failedFast = child.nodeId;
@@ -270,12 +302,16 @@ export async function runForeachDrive(
270
302
  registry: ExecutorRegistry,
271
303
  ): Promise<ForeachDriveResult> {
272
304
  const release = holdWorkflowRun(runId);
305
+ let debt: SuccessorWalkDebt | undefined;
273
306
  try {
274
307
  const drive = await driveForeach(runId, parentNodeId, registry);
275
308
  if (!drive.joined) {
276
309
  await parkRunIfRunning(runId);
277
310
  return drive;
278
311
  }
312
+ // The join's debt keeps other finalizers off the run until the walk below
313
+ // takes it over.
314
+ debt = drive.successorDebt;
279
315
  const run = await getWorkflowRun(runId);
280
316
  const workflow = run ? await getRenderedWorkflow(run) : null;
281
317
  if (!run || !workflow) return drive;
@@ -289,6 +325,7 @@ export async function runForeachDrive(
289
325
  registry,
290
326
  workflow.id,
291
327
  getSecretInputKeys(workflow.input),
328
+ { successorDebt: debt },
292
329
  );
293
330
  } else {
294
331
  const { finalizeOrWait } = await import("./resume");
@@ -296,6 +333,7 @@ export async function runForeachDrive(
296
333
  }
297
334
  return drive;
298
335
  } finally {
336
+ debt?.release();
299
337
  release();
300
338
  }
301
339
  }
@@ -19,6 +19,7 @@ import {
19
19
  } from "../be/db/workflow-runs";
20
20
  import type { WorkflowRunStep } from "../types";
21
21
  import { shapeApprovalResolution } from "./approval-resolution";
22
+ import { adoptStoredContext } from "./checkpoint";
22
23
  import { loadCompletedStepRouting } from "./completed-step-routing";
23
24
  import { FAILED_TASK_OUTPUT_PREFIX } from "./constants";
24
25
  import {
@@ -38,6 +39,7 @@ import {
38
39
  resumeFromChildRun,
39
40
  resumeWaitState,
40
41
  } from "./resume";
42
+ import { hasOwedSuccessors } from "./successor-routing";
41
43
  import {
42
44
  checkpointPortStepAndResolveSuccessors,
43
45
  completeTaskStepAndResolveSuccessors,
@@ -233,7 +235,7 @@ async function completeIfSettled(runId: string, ctx: Record<string, unknown>): P
233
235
  if (run?.status !== "running") return false;
234
236
  if (await getRunLineageBlock(runId)) return false;
235
237
  const steps = await getWorkflowRunStepsByRunId(runId);
236
- if (retryPendingNodeIds(steps).size > 0) return false;
238
+ if (retryPendingNodeIds(steps).size > 0 || hasOwedSuccessors(runId)) return false;
237
239
  const latest = new Map<string, WorkflowRunStep>();
238
240
  for (const step of steps) latest.set(step.nodeId, step);
239
241
  for (const step of latest.values()) {
@@ -241,6 +243,7 @@ async function completeIfSettled(runId: string, ctx: Record<string, unknown>): P
241
243
  return false;
242
244
  }
243
245
  }
246
+ await adoptStoredContext(runId, ctx);
244
247
  await updateWorkflowRun(runId, {
245
248
  status: "completed",
246
249
  context: ctx,
@@ -344,6 +347,7 @@ async function recoverWaitingRuns(registry: ExecutorRegistry): Promise<number> {
344
347
  registry,
345
348
  workflow.id,
346
349
  secretKeys,
350
+ { successorDebt: routing.successorDebt },
347
351
  );
348
352
  }
349
353
  recovered++;
@@ -445,6 +449,7 @@ async function recoverApprovalWaitingRuns(registry: ExecutorRegistry): Promise<n
445
449
  registry,
446
450
  workflow.id,
447
451
  secretKeys,
452
+ { successorDebt: routing.successorDebt },
448
453
  );
449
454
  } else {
450
455
  await finalizeOrWait(stuck.runId);
@@ -70,6 +70,7 @@ import {
70
70
  import { getSecretInputKeys } from "./input";
71
71
  import { getMaxWorkflowStepsPerRun } from "./limits";
72
72
  import { findWorkflowReadinessProblems, formatReadinessProblems } from "./readiness";
73
+ import { hasOwedSuccessors } from "./successor-routing";
73
74
  import {
74
75
  checkpointPortStepAndResolveSuccessors,
75
76
  completeTaskStepAndResolveSuccessors,
@@ -297,6 +298,7 @@ async function resumeFromTaskCompletionUnguarded(
297
298
  registry,
298
299
  workflow.id,
299
300
  secretKeys,
301
+ { successorDebt: routing.successorDebt },
300
302
  );
301
303
  } else {
302
304
  await finalizeOrWait(run.id);
@@ -318,9 +320,10 @@ export async function finalizeOrWait(runId: string): Promise<void> {
318
320
  if (status !== "running" && status !== "waiting") return;
319
321
  if (await getRunLineageBlock(runId)) return;
320
322
  const steps = await getWorkflowRunStepsByRunId(runId);
321
- // A branch still executing belongs to a live walk, which finalizes the
322
- // run itself; its finalizer only acts on a `running` run.
323
- if (hasRunningStep(steps)) {
323
+ // A branch still executing, or a completed step whose successors have no
324
+ // row yet, belongs to a live walk, which finalizes the run itself; its
325
+ // finalizer only acts on a `running` run.
326
+ if (hasRunningStep(steps) || hasOwedSuccessors(runId)) {
324
327
  if (status === "waiting") await updateWorkflowRun(runId, { status: "running" });
325
328
  return;
326
329
  }
@@ -439,6 +442,7 @@ async function handleTaskFailureUnguarded(
439
442
  registry,
440
443
  workflow.id,
441
444
  secretKeys,
445
+ { successorDebt: routing.successorDebt },
442
446
  );
443
447
  } else {
444
448
  await finalizeOrWait(run.id);
@@ -960,6 +964,7 @@ async function resumeFromApprovalResolutionUnguarded(
960
964
  registry,
961
965
  workflow.id,
962
966
  secretKeys,
967
+ { successorDebt: routing.successorDebt },
963
968
  );
964
969
  } else {
965
970
  await finalizeOrWait(run.id);
@@ -1088,6 +1093,7 @@ async function resumeClaimedWait(
1088
1093
  registry,
1089
1094
  workflow.id,
1090
1095
  secretKeys,
1096
+ { successorDebt: routing.successorDebt },
1091
1097
  );
1092
1098
  } else {
1093
1099
  await finalizeOrWait(run.id);
@@ -1184,6 +1190,7 @@ export async function resumeFromChildRun(
1184
1190
  registry,
1185
1191
  workflow.id,
1186
1192
  secretKeys,
1193
+ { successorDebt: routing.successorDebt },
1187
1194
  );
1188
1195
  } else {
1189
1196
  await finalizeOrWait(run.id);
@@ -1196,6 +1203,7 @@ const CHILD_RETRY_SCHEDULED = {
1196
1203
  claimed: true,
1197
1204
  runFailed: false,
1198
1205
  successors: [] as WorkflowNode[],
1206
+ successorDebt: undefined,
1199
1207
  } as const;
1200
1208
 
1201
1209
  /** The `node.retry` of a top-level `sub-workflow` node; foreach items retry through their parent. */