@desplega.ai/agent-swarm 2.14.1 → 2.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (346) hide show
  1. package/dist/{acp-adapter-7jv7w8jh.js → acp-adapter-q1vz4hh2.js} +8 -8
  2. package/dist/{acp-targets-0ebmg3et.js → acp-targets-d44eerh4.js} +7 -7
  3. package/dist/{actions-0ds9dx6c.js → actions-z4k4bvss.js} +27 -27
  4. package/dist/{agent-fs-provision-zpbxa9jc.js → agent-fs-provision-aan1cgpx.js} +4 -4
  5. package/dist/{amp-adapter-awh5nn7a.js → amp-adapter-wac3py0p.js} +1 -1
  6. package/dist/{anthropic-messages-gtgp9r85.js → anthropic-messages-njt2r5m4.js} +16 -15
  7. package/dist/{app-nzejkvpp.js → app-wax6qz5e.js} +9 -9
  8. package/dist/{approval-notifications-hbqtb2w3.js → approval-notifications-6fvkhnma.js} +10 -10
  9. package/dist/{assistant-1paft129.js → assistant-e8fe08zx.js} +25 -25
  10. package/dist/{azure-openai-responses-e76k86gf.js → azure-openai-responses-6ewf9rwp.js} +9 -9
  11. package/dist/{boot-args-schema-zs435mfx.js → boot-args-schema-rv97cmnt.js} +1 -1
  12. package/dist/{boot-reembed-91qrd4mz.js → boot-reembed-bcn7frk9.js} +1 -1
  13. package/dist/{boot-reembed-7xq2qgg4.js → boot-reembed-xakrdy6y.js} +1 -1
  14. package/dist/{boot-scrub-sweep-3h5xscw6.js → boot-scrub-sweep-20t8akhf.js} +2 -2
  15. package/dist/{boot-seeds-xkxqa8zc.js → boot-seeds-48rr6r29.js} +4 -4
  16. package/dist/{boxd-464x3w4m.js → boxd-tjpxwecx.js} +2 -2
  17. package/dist/{claude-adapter-6d8eyf2f.js → claude-adapter-0wzwntrj.js} +8 -8
  18. package/dist/{claude-managed-adapter-jzxcaf9m.js → claude-managed-adapter-4xcgt46w.js} +2 -2
  19. package/dist/{claude-managed-setup-5fcx0qh3.js → claude-managed-setup-91cyktw7.js} +5 -5
  20. package/dist/{claude-sdk-session-11vhz1hc.js → claude-sdk-session-ngj4dce5.js} +9658 -9634
  21. package/dist/{cli-hamdfjtx.js → cli-021hrewp.js} +1 -1
  22. package/dist/{cli-pgdqhdkw.js → cli-0kyjrbaa.js} +2 -2
  23. package/dist/{cli-132h67ps.js → cli-0nz04gqv.js} +48 -48
  24. package/dist/{cli-6a77m17n.js → cli-0rrft7s3.js} +2 -2
  25. package/dist/{cli-z0effej1.js → cli-1d9q7qrn.js} +5 -5
  26. package/dist/{cli-tdd9dvw6.js → cli-1t5vhrpv.js} +1 -1
  27. package/dist/{cli-zyf288rw.js → cli-2ja7eadd.js} +1 -1
  28. package/dist/{cli-k9m8fckz.js → cli-3ffzr65w.js} +4 -4
  29. package/dist/{cli-02ba8qx5.js → cli-3kdgm393.js} +4 -4
  30. package/dist/{cli-hh5m39pt.js → cli-3vc518cw.js} +1 -1
  31. package/dist/{cli-5pyes68e.js → cli-5188hq0a.js} +8 -8
  32. package/dist/{cli-zcghfsdg.js → cli-53gt8wfv.js} +1 -1
  33. package/dist/{cli-5t00r6c9.js → cli-5njmmmer.js} +2 -2
  34. package/dist/{cli-etykr11s.js → cli-5rw7nt99.js} +1 -1
  35. package/dist/{cli-6c61yjwy.js → cli-5xx353cy.js} +7554 -1534
  36. package/dist/{cli-by7s3n4p.js → cli-65k149j5.js} +2 -2
  37. package/dist/{cli-1e13gvfn.js → cli-6zpn5hmp.js} +11 -11
  38. package/dist/{cli-rb1z91g8.js → cli-7dpdq7yh.js} +1230 -540
  39. package/dist/{cli-3bagv8rt.js → cli-7wwewkf4.js} +1 -1
  40. package/dist/{cli-288k5ep1.js → cli-83hynhes.js} +15 -11
  41. package/dist/{cli-v84kb7af.js → cli-8ee7xt75.js} +11 -11
  42. package/dist/{cli-v3jxx8dv.js → cli-8ef94zm2.js} +2 -2
  43. package/dist/{cli-9fvk9mv8.js → cli-8gr1bg9t.js} +1 -1
  44. package/dist/{cli-vrb8pvrf.js → cli-9j1qcs0b.js} +6 -6
  45. package/dist/{cli-0dkpdvnn.js → cli-9mvfvggt.js} +5 -5
  46. package/dist/{cli-3bcsc3m7.js → cli-an8bpy60.js} +1 -1
  47. package/dist/{cli-6yhjqd6k.js → cli-azptj8xe.js} +810 -184
  48. package/dist/{cli-3a3hm1z8.js → cli-c0rt16vk.js} +2 -2
  49. package/dist/{cli-byzq8xht.js → cli-c6vhcknq.js} +6 -6
  50. package/dist/{cli-eaqxkeq0.js → cli-cczffwak.js} +8 -8
  51. package/dist/{cli-83kf2y60.js → cli-cgmka83w.js} +6 -6
  52. package/dist/{cli-5xjdft4s.js → cli-d13qgcct.js} +207 -142
  53. package/dist/{cli-k3facve0.js → cli-d5nvy1jy.js} +1 -1
  54. package/dist/{cli-zvsy4abb.js → cli-dev6f0px.js} +3 -3
  55. package/dist/{cli-e1wprqnd.js → cli-dzhht0vq.js} +2 -2
  56. package/dist/{cli-zdkcp8p0.js → cli-e13kbyq0.js} +1 -1
  57. package/dist/{cli-f07sgaax.js → cli-e2k0ej0d.js} +2 -2
  58. package/dist/{cli-dt931hb8.js → cli-ek8b88kv.js} +21 -21
  59. package/dist/{cli-20mkgwev.js → cli-ertcjw6z.js} +249 -19
  60. package/dist/{cli-0qyfna7a.js → cli-f3ta4e67.js} +4 -4
  61. package/dist/{cli-6xrbpj5j.js → cli-f4xv7s0t.js} +4 -4
  62. package/dist/{cli-d1zkys4j.js → cli-fdam1t9b.js} +29 -13
  63. package/dist/{cli-spfz393q.js → cli-feh37wgs.js} +598 -219
  64. package/dist/{cli-ebqx630g.js → cli-fjzjtqna.js} +35 -18
  65. package/dist/{cli-zgsd2w2k.js → cli-fs9t2m2k.js} +16 -16
  66. package/dist/{cli-trvtxwzt.js → cli-g03x26q6.js} +2 -2
  67. package/dist/{cli-0mq8kxfx.js → cli-gnkzh8ed.js} +3 -3
  68. package/dist/{cli-phantfg3.js → cli-gy0r7gb8.js} +40 -15
  69. package/dist/{cli-wsh5vfa7.js → cli-h364asjc.js} +2 -2
  70. package/dist/{cli-3ktfe5jx.js → cli-h3xcfp4c.js} +22 -7
  71. package/dist/{cli-976m0zcw.js → cli-h8k5801a.js} +49 -13
  72. package/dist/{cli-727sq1f9.js → cli-h96yp7xv.js} +2 -2
  73. package/dist/{cli-ytgtqsy9.js → cli-hab0bvrh.js} +1 -1
  74. package/dist/{cli-7dwsn9y5.js → cli-j3wqt73b.js} +4 -4
  75. package/dist/{cli-8kemtj1r.js → cli-jfgaz10x.js} +7 -7
  76. package/dist/{cli-wtwe8vng.js → cli-jrhvywah.js} +25 -24
  77. package/dist/{cli-tjrrabez.js → cli-jrxt5j0n.js} +3 -3
  78. package/dist/{cli-7b7rxz22.js → cli-jw7n9pct.js} +5 -2
  79. package/dist/{cli-k791mabe.js → cli-k9kfck3s.js} +5 -5
  80. package/dist/{cli-44r66df2.js → cli-kkwq5b12.js} +1 -1
  81. package/dist/{cli-e9p9h14n.js → cli-nc842kc9.js} +4 -4
  82. package/dist/{cli-3179w2rz.js → cli-nmj4phcg.js} +1 -1
  83. package/dist/{cli-ny8f5g7t.js → cli-praaw1wh.js} +1 -1
  84. package/dist/{cli-j8fmn3wv.js → cli-q44p4869.js} +7 -7
  85. package/dist/{cli-sq32dgfe.js → cli-q58qt9dw.js} +237 -57
  86. package/dist/{cli-2n7qdqfv.js → cli-qqz5z36e.js} +2 -2
  87. package/dist/{cli-b70cpf8f.js → cli-r7rpy2xz.js} +1 -1
  88. package/dist/{cli-1hj68b3h.js → cli-rcqgr0hs.js} +1 -1
  89. package/dist/{cli-ph95yejc.js → cli-rjc464jg.js} +2 -2
  90. package/dist/{cli-967jrz7j.js → cli-rw3m83j4.js} +15 -15
  91. package/dist/{cli-0vxbrxr3.js → cli-rwcj6wt3.js} +304 -19
  92. package/dist/{cli-yvnnyjxm.js → cli-ryn4y478.js} +1 -1
  93. package/dist/{cli-3g0vbq46.js → cli-s48k2rzx.js} +3 -3
  94. package/dist/{cli-98sea4d9.js → cli-s90wcbk9.js} +2 -2
  95. package/dist/{cli-e2wzzw17.js → cli-svcy72s5.js} +1 -1
  96. package/dist/{cli-643skca1.js → cli-swtwbg85.js} +17 -17
  97. package/dist/{cli-4y2bekkn.js → cli-t1bqpzgz.js} +2 -2
  98. package/dist/{cli-zmfs06hg.js → cli-t5jbjq61.js} +3 -3
  99. package/dist/{cli-mz7ycqn8.js → cli-td2h8zej.js} +6 -6
  100. package/dist/{cli-9t7syepg.js → cli-ttatvwn6.js} +1 -1
  101. package/dist/{cli-v1rhq77v.js → cli-txxcf9s1.js} +6 -6
  102. package/dist/{cli-q4z9s6zs.js → cli-v7az4d1g.js} +2 -2
  103. package/dist/cli-vqt44168.js +14 -0
  104. package/dist/{cli-tkrp183j.js → cli-vs9h3vw2.js} +5 -5
  105. package/dist/{cli-7abeph0b.js → cli-w2fg8kjc.js} +3 -3
  106. package/dist/{cli-sf5kp73f.js → cli-wz7qj1jy.js} +12 -12
  107. package/dist/{cli-ww8wxfzx.js → cli-x5t54ytt.js} +2 -2
  108. package/dist/{cli-nmdy8bzf.js → cli-xphbv66z.js} +1 -1
  109. package/dist/{cli-redtbppc.js → cli-xxgqn93n.js} +3753 -1186
  110. package/dist/{cli-s7bfz1ye.js → cli-z209g721.js} +109 -85
  111. package/dist/{cli-vp2ksaq9.js → cli-z5andw8k.js} +1 -1
  112. package/dist/{cli-xmc2nrtv.js → cli-zr2sc5tr.js} +1 -1
  113. package/dist/{cli-z0c98h7h.js → cli-zrm0610v.js} +61 -54
  114. package/dist/cli.js +41 -40
  115. package/dist/{cloudflare-workers-ai-system-one-w3m0fbf8.js → cloudflare-workers-ai-system-one-kb0tq22h.js} +2 -2
  116. package/dist/{codex-adapter-seht4h9t.js → codex-adapter-0c1ynrmt.js} +5 -5
  117. package/dist/{codex-session-runner-tq95x3gq.js → codex-session-runner-z4t9z7yy.js} +5 -5
  118. package/dist/{commands-0awwqxq5.js → commands-h0jxqdhk.js} +3 -3
  119. package/dist/{controller-hgjx521c.js → controller-4ygy66hv.js} +3 -3
  120. package/dist/{controllers-connect-j4kdmhfj.js → controllers-connect-ynbvv8pv.js} +26 -26
  121. package/dist/core-mj9fzrcm.js +41 -0
  122. package/dist/{cursor-adapter-0rg8wk6j.js → cursor-adapter-9e4d6658.js} +1 -1
  123. package/dist/{db-8xs2js3s.js → db-bg0hxjq1.js} +3 -3
  124. package/dist/{db-dd6hj211.js → db-q12gmpns.js} +2 -2
  125. package/dist/{devtools-b8qts77k.js → devtools-t8my9az6.js} +1 -1
  126. package/dist/{dispatcher-v7drd034.js → dispatcher-v5dbfscq.js} +23 -23
  127. package/dist/{dsh-adapter-ah8npj2x.js → dsh-adapter-z3fneea1.js} +1 -1
  128. package/dist/{e2b-z1g7vpz6.js → e2b-k3kb8b52.js} +3 -3
  129. package/dist/{e2b-hg80w0qr.js → e2b-p269awh6.js} +4 -4
  130. package/dist/{easter-egg-3d-8n4w3s9k.js → easter-egg-3d-y49v5z90.js} +1 -1
  131. package/dist/{embedding-space-0p921zt3.js → embedding-space-mjt5ksq0.js} +5 -5
  132. package/dist/{embeddings-9s7kbrc6.js → embeddings-td9hgnc5.js} +1 -1
  133. package/dist/{execute-x0fy9j0m.js → execute-z8nc8bba.js} +1 -1
  134. package/dist/{external-channel-ktfvn29c.js → external-channel-pjenc2ag.js} +2 -2
  135. package/dist/{fx-adapter-15vjxvgm.js → fx-adapter-pjeztp0n.js} +9 -9
  136. package/dist/getMachineId-bsd-hjs2tbdp.js +36 -0
  137. package/dist/getMachineId-darwin-kzbvr8s3.js +40 -0
  138. package/dist/getMachineId-linux-embmcq2c.js +26 -0
  139. package/dist/getMachineId-unsupported-jvznc6d4.js +20 -0
  140. package/dist/getMachineId-win-qr8z0b13.js +36 -0
  141. package/dist/{google-generative-ai-nzndg246.js → google-generative-ai-tf3w7557.js} +11 -16
  142. package/dist/{google-vertex-ragh3nnw.js → google-vertex-9pj87bd8.js} +15 -17
  143. package/dist/{grok-adapter-77httan0.js → grok-adapter-davbhx8t.js} +9 -9
  144. package/dist/handlers-rf130hnp.js +39 -0
  145. package/dist/{heartbeat-5yaj6dym.js → heartbeat-9hmvqxk0.js} +26 -26
  146. package/dist/{hook-c99nycyh.js → hook-0b1jqs2t.js} +6 -6
  147. package/dist/{hook-2jttae8s.js → hook-1n0sjv8p.js} +7 -7
  148. package/dist/{http-7y9dbfrr.js → http-vykejyjx.js} +412 -183
  149. package/dist/{index-tcegcysh.js → index-07d66kdm.js} +5 -5
  150. package/dist/{index-fqf82sbk.js → index-0hgjxqz8.js} +1 -1
  151. package/dist/{index-t274qhhs.js → index-0nt39qwy.js} +6 -6
  152. package/dist/{index-8p03vx1h.js → index-2xbxq71g.js} +8 -8
  153. package/dist/{index-jvfp0j47.js → index-3j8hffkb.js} +12038 -7667
  154. package/dist/index-8w09aggw.js +43 -0
  155. package/dist/{index-xhp7yp3t.js → index-b3wy4jzs.js} +1 -1
  156. package/dist/{index-6g9rdcrj.js → index-dt9vr7tb.js} +162 -57
  157. package/dist/{index-cw8nxnba.js → index-ezfas4jj.js} +1912 -346
  158. package/dist/index-g2jntx15.js +38 -0
  159. package/dist/{index-h9xnzfhx.js → index-j6sqtb83.js} +101 -72
  160. package/dist/{index-m6g8q65g.js → index-na0tczq0.js} +9268 -10220
  161. package/dist/{index-tn1m3q9b.js → index-p9dkwhwe.js} +3 -3
  162. package/dist/{index-g7rthzrv.js → index-pe2etczf.js} +8 -8
  163. package/dist/index-qffex5k4.js +41 -0
  164. package/dist/index-qrp11tp9.js +4 -0
  165. package/dist/{index-t4n9z755.js → index-ryyrg0d8.js} +406 -317
  166. package/dist/{index-t17p395x.js → index-sf06w57a.js} +13 -13
  167. package/dist/{index-qxcfv8vq.js → index-vybnwd5v.js} +1 -1
  168. package/dist/{index-dm7c6hw5.js → index-wsf1f5pe.js} +27 -27
  169. package/dist/{keepalive-7eyb8y4t.js → keepalive-86z0tzzf.js} +3 -3
  170. package/dist/lead-edmwagkn.js +81 -0
  171. package/dist/{llama-cpp-classify-yvb8vh7w.js → llama-cpp-classify-wd7htn1x.js} +2 -2
  172. package/dist/{maintenance-tdrd8nwv.js → maintenance-19h6tfwz.js} +1 -1
  173. package/dist/{mistral-conversations-w4bncwbt.js → mistral-conversations-txjmc64f.js} +7 -7
  174. package/dist/{module-ES6BEMUI-6htewwha.js → module-ES6BEMUI-44w9s1dx.js} +4 -4
  175. package/dist/{multipart-parser-xevcstye.js → multipart-parser-xqbgwrav.js} +1 -1
  176. package/dist/{oauth-refresh-sweep-f4c7g37h.js → oauth-refresh-sweep-6nmyrv32.js} +2 -2
  177. package/dist/{object-webhooks-p190rdxp.js → object-webhooks-2kynmdf8.js} +7 -7
  178. package/dist/{onboard-56h4sks6.js → onboard-zbpm96mn.js} +5 -5
  179. package/dist/{openai-codex-responses-z2h941b8.js → openai-codex-responses-6ckhys6r.js} +31 -25
  180. package/dist/{openai-completions-5bxdkeg9.js → openai-completions-c9dsq9jh.js} +17 -17
  181. package/dist/{openai-decisions-fyq1p9f9.js → openai-decisions-9vzvv10c.js} +2 -2
  182. package/dist/{openai-responses-dzf3e8r5.js → openai-responses-bhfmt9sa.js} +9 -9
  183. package/dist/{opencode-adapter-xg3yxfr0.js → opencode-adapter-fyqcbdra.js} +5 -5
  184. package/dist/{openrouter-images-0jj12a2q.js → openrouter-images-hkk5p580.js} +3 -3
  185. package/dist/otel-impl-txa20w1h.js +11178 -0
  186. package/dist/{pending-xgv316w0.js → pending-4rxawq8y.js} +24 -24
  187. package/dist/{pi-messages-zk3g4esn.js → pi-messages-py3f96p7.js} +5 -5
  188. package/dist/{pi-mono-adapter-txe0syzb.js → pi-mono-adapter-rnsed1xa.js} +14 -14
  189. package/dist/{pricing-refresh-041zpyhf.js → pricing-refresh-4314hwtw.js} +2 -2
  190. package/dist/{rbac-roles-8f3jbcaf.js → rbac-roles-fztcm8ky.js} +2 -2
  191. package/dist/{rbac-roles-cw7rrw5b.js → rbac-roles-msqt7a3k.js} +3 -3
  192. package/dist/{render-v2-2ezw4mzt.js → render-v2-w49wtecg.js} +9 -9
  193. package/dist/{resume-p14wdx8m.js → resume-gwgtp4m3.js} +12 -12
  194. package/dist/{runtime-he7c9g1r.js → runtime-kkebz8yq.js} +1 -1
  195. package/dist/{session-access-8jvq86fj.js → session-access-kjb19m2w.js} +5 -5
  196. package/dist/{session-source-backfill-6fe3hcgb.js → session-source-backfill-805p4wqr.js} +2 -2
  197. package/dist/{setup-6v0bn4r1.js → setup-q8y168c8.js} +3 -3
  198. package/dist/thread-buffer-yqbffd0t.js +40 -0
  199. package/dist/{tree-visibility-g1a8ff4r.js → tree-visibility-qj323994.js} +2 -2
  200. package/dist/{typesafe-system-one-qkvkgrcz.js → typesafe-system-one-avrdb4zm.js} +2 -2
  201. package/dist/{user-merge-jobs-vjsps179.js → user-merge-jobs-qfp40f2s.js} +3 -3
  202. package/dist/{virtual-modules-mreda4fp.js → virtual-modules-nzxegw0a.js} +7 -7
  203. package/dist/{work-objects-hfw15e35.js → work-objects-hs089w60.js} +25 -25
  204. package/dist/{worker-follow-up-gbaz2ydz.js → worker-follow-up-zwgg20sr.js} +23 -23
  205. package/dist/worker-kg4g7rnx.js +81 -0
  206. package/openapi.json +3 -3
  207. package/package.json +25 -24
  208. package/plugin/commands/create-pr.md +5 -2
  209. package/plugin/pi-skills/create-pr/SKILL.md +5 -2
  210. package/src/apps/sync.ts +7 -2
  211. package/src/be/db/workflow-runs.ts +12 -8
  212. package/src/be/db.ts +4 -1
  213. package/src/be/migrations/367_workflow_run_principal.sql +5 -0
  214. package/src/be/swarm-config-guard.ts +3 -0
  215. package/src/be/task-auto-title-listener.ts +2 -2
  216. package/src/commands/onboard/agent-fs-version.ts +1 -1
  217. package/src/extensions/post-bridge.ts +27 -28
  218. package/src/http/active-sessions.ts +7 -0
  219. package/src/http/agents.ts +7 -0
  220. package/src/http/api-keys.ts +7 -0
  221. package/src/http/approval-requests.ts +4 -0
  222. package/src/http/budgets.ts +2 -0
  223. package/src/http/codex-oauth-keep-warm.ts +6 -2
  224. package/src/http/config.ts +1 -0
  225. package/src/http/context.ts +4 -0
  226. package/src/http/db-query.ts +3 -0
  227. package/src/http/events.ts +2 -0
  228. package/src/http/fs.ts +1 -0
  229. package/src/http/integrations.ts +4 -0
  230. package/src/http/mcp-bridge.ts +1 -0
  231. package/src/http/memory.ts +3 -0
  232. package/src/http/metrics.ts +16 -0
  233. package/src/http/oauth-locks.ts +8 -0
  234. package/src/http/page-proxy.ts +16 -0
  235. package/src/http/pages.ts +9 -0
  236. package/src/http/poll.ts +1 -0
  237. package/src/http/pricing.ts +2 -0
  238. package/src/http/prompt-templates.ts +34 -0
  239. package/src/http/schedules.ts +10 -0
  240. package/src/http/script-runs.ts +24 -0
  241. package/src/http/scripts.ts +1 -0
  242. package/src/http/session-data.ts +2 -0
  243. package/src/http/status.ts +1 -0
  244. package/src/http/tasks.ts +17 -0
  245. package/src/http/trackers/jira.ts +2 -0
  246. package/src/http/trackers/linear.ts +4 -0
  247. package/src/http/users.ts +18 -0
  248. package/src/http/webhooks.ts +12 -0
  249. package/src/http/workflow-events.ts +26 -6
  250. package/src/http/workflows.ts +40 -0
  251. package/src/http/x.ts +4 -0
  252. package/src/linear/app.ts +3 -2
  253. package/src/linear/client.ts +5 -1
  254. package/src/linear/host.ts +40 -0
  255. package/src/linear/oauth.ts +3 -2
  256. package/src/linear/sync.ts +4 -3
  257. package/src/otel-impl.ts +8 -5
  258. package/src/providers/amp-adapter.ts +1 -1
  259. package/src/rbac/legacy-policy.ts +2 -0
  260. package/src/rbac/permissions.ts +5 -0
  261. package/src/scripts-runtime/quickjs-compat.ts +44 -10
  262. package/src/slack/render-v2.ts +50 -23
  263. package/src/slack/reviewed-deliverables.ts +251 -0
  264. package/src/tests/check-pr-body.test.ts +408 -93
  265. package/src/tests/compose-dev-object-store.test.ts +13 -0
  266. package/src/tests/compose-example-object-store.test.ts +67 -0
  267. package/src/tests/db-query.test.ts +8 -4
  268. package/src/tests/e2b-dispatch.test.ts +7 -1
  269. package/src/tests/otel-event-loop-and-logs.test.ts +1 -1
  270. package/src/tests/quickjs-compat.test.ts +40 -4
  271. package/src/tests/rbac-route-verbs-e2e.test.ts +142 -0
  272. package/src/tests/script-connections.test.ts +2 -0
  273. package/src/tests/slack-render-v2.test.ts +52 -8
  274. package/src/tests/workflow-definition-pinning.test.ts +2 -0
  275. package/src/tests/workflow-hitl-routing.test.ts +67 -5
  276. package/src/tests/workflow-replay.test.ts +13 -1
  277. package/src/tests/x402-client.test.ts +82 -0
  278. package/src/tools/memory-rate.ts +2 -2
  279. package/src/tools/prompt-templates/delete.ts +22 -1
  280. package/src/tools/prompt-templates/set.ts +15 -1
  281. package/src/utils/constants.ts +5 -4
  282. package/src/utils/task-citations.ts +11 -0
  283. package/src/workflows/engine.ts +5 -0
  284. package/src/workflows/executors/sub-workflow.ts +5 -7
  285. package/src/workflows/executors/swarm-script.ts +4 -5
  286. package/src/workflows/resume.ts +21 -4
  287. package/src/workflows/run-principal.ts +51 -0
  288. package/src/x402/client.ts +38 -17
  289. package/templates/skills/code-quality/content.md +1 -1
  290. package/templates/skills/pages/content.md +36 -12
  291. package/templates/skills/swarm-docs/content.md +46 -41
  292. package/templates/skills/swarm-scripts/SKILL.md +1 -1
  293. package/templates/skills/swarm-scripts/content.md +1 -1
  294. package/dist/cli-547fsc36.js +0 -15
  295. package/dist/cli-dr6x9qdk.js +0 -15
  296. package/dist/cli-h5cveb69.js +0 -15
  297. package/dist/cli-jngvszex.js +0 -1514
  298. package/dist/cli-p0g0erm9.js +0 -15
  299. package/dist/cli-ph1jce1b.js +0 -16
  300. package/dist/cli-vxxdf2ma.js +0 -15
  301. package/dist/cli-x80zagf5.js +0 -15
  302. package/dist/core-8fw1gwg7.js +0 -41
  303. package/dist/getMachineId-bsd-2rd3pnz7.js +0 -36
  304. package/dist/getMachineId-bsd-3p48mkt1.js +0 -36
  305. package/dist/getMachineId-bsd-bk6tmeen.js +0 -36
  306. package/dist/getMachineId-bsd-pssqgwmm.js +0 -37
  307. package/dist/getMachineId-bsd-v218x3xd.js +0 -36
  308. package/dist/getMachineId-bsd-wbxcazef.js +0 -36
  309. package/dist/getMachineId-bsd-x0942pbz.js +0 -36
  310. package/dist/getMachineId-darwin-5qsy4qcg.js +0 -36
  311. package/dist/getMachineId-darwin-6v7zsshx.js +0 -37
  312. package/dist/getMachineId-darwin-fcc3fjag.js +0 -36
  313. package/dist/getMachineId-darwin-pg84hftj.js +0 -36
  314. package/dist/getMachineId-darwin-tyyevt26.js +0 -36
  315. package/dist/getMachineId-darwin-wagmbf0d.js +0 -36
  316. package/dist/getMachineId-darwin-zvkmwr3y.js +0 -36
  317. package/dist/getMachineId-linux-2ncg1epd.js +0 -29
  318. package/dist/getMachineId-linux-2tmt2ptc.js +0 -29
  319. package/dist/getMachineId-linux-empwyp2y.js +0 -29
  320. package/dist/getMachineId-linux-fanqd45b.js +0 -29
  321. package/dist/getMachineId-linux-h6fyga0x.js +0 -29
  322. package/dist/getMachineId-linux-tbhgz1k9.js +0 -29
  323. package/dist/getMachineId-linux-zrbyw7dt.js +0 -29
  324. package/dist/getMachineId-unsupported-29g9dkgv.js +0 -19
  325. package/dist/getMachineId-unsupported-8xfq8djv.js +0 -19
  326. package/dist/getMachineId-unsupported-8y9cag1p.js +0 -19
  327. package/dist/getMachineId-unsupported-a6sjrm02.js +0 -19
  328. package/dist/getMachineId-unsupported-bp3w7ds0.js +0 -19
  329. package/dist/getMachineId-unsupported-sj6fk8sw.js +0 -19
  330. package/dist/getMachineId-unsupported-v0p5gdxp.js +0 -19
  331. package/dist/getMachineId-win-hc996p0x.js +0 -38
  332. package/dist/getMachineId-win-msq9ad87.js +0 -38
  333. package/dist/getMachineId-win-tajyqwd6.js +0 -38
  334. package/dist/getMachineId-win-tzc163da.js +0 -38
  335. package/dist/getMachineId-win-xdaa0mgq.js +0 -38
  336. package/dist/getMachineId-win-xk6p98m5.js +0 -38
  337. package/dist/getMachineId-win-xtk658fm.js +0 -38
  338. package/dist/handlers-c1jp5b6h.js +0 -39
  339. package/dist/index-7dwh9kxh.js +0 -41
  340. package/dist/index-wp9tarbt.js +0 -43
  341. package/dist/index-z6np2405.js +0 -38
  342. package/dist/lead-50cgn8s1.js +0 -81
  343. package/dist/otel-impl-kepzgm4n.js +0 -55386
  344. package/dist/thread-buffer-8860v1ta.js +0 -40
  345. package/dist/worker-hkm8ftqp.js +0 -81
  346. /package/dist/{node-gbx1t3pa.js → node-q4628t0b.js} +0 -0
@@ -351,8 +351,11 @@ describe("db-query bounded execution (Fix 1)", () => {
351
351
  test("D: caps the serialized payload at maxRows, not at the full match count, for a large result set", async () => {
352
352
  const db = getDb();
353
353
  db.run("CREATE TABLE codex_cap_test (id INTEGER PRIMARY KEY)");
354
- const insert = db.prepare("INSERT INTO codex_cap_test DEFAULT VALUES");
355
- for (let i = 0; i < 20_000; i++) insert.run();
354
+ // One statement = one commit. 20k autocommitted inserts fsync 20k times and
355
+ // blocked the main thread for 26s on a loaded CI runner (hang-watchdog kill).
356
+ db.run(
357
+ "WITH RECURSIVE n(i) AS (SELECT 1 UNION ALL SELECT i + 1 FROM n WHERE i < 20000) INSERT INTO codex_cap_test (id) SELECT i FROM n",
358
+ );
356
359
 
357
360
  const result = await executeReadOnlyQueryBounded("SELECT id FROM codex_cap_test", [], 5000, 3);
358
361
  expect(result.total).toBe(20_000);
@@ -402,8 +405,9 @@ describe("db-query bounded execution (Fix 1)", () => {
402
405
  test("F: /api/db-query caps rows at the new default and still reports the true total", async () => {
403
406
  const db = getDb();
404
407
  db.run("CREATE TABLE http_cap_test (id INTEGER PRIMARY KEY)");
405
- const insert = db.prepare("INSERT INTO http_cap_test DEFAULT VALUES");
406
- for (let i = 0; i < 1500; i++) insert.run();
408
+ db.run(
409
+ "WITH RECURSIVE n(i) AS (SELECT 1 UNION ALL SELECT i + 1 FROM n WHERE i < 1500) INSERT INTO http_cap_test (id) SELECT i FROM n",
410
+ );
407
411
 
408
412
  let server: Server | undefined;
409
413
  try {
@@ -406,7 +406,13 @@ describe("E2B dispatch helpers", () => {
406
406
 
407
407
  test("buildImageTemplate forwards cancellation to the E2B SDK", async () => {
408
408
  const abort = new AbortController();
409
- const build = spyOn(Template, "build").mockResolvedValue({
409
+ // e2b >= 2.63 exports `Template` as a Proxy that caches a bound copy of each
410
+ // static method on first read, so spying on the proxy never reaches the call
411
+ // site. Spy on the underlying class instead, before anything reads `build`.
412
+ // shortcut: the proxy keeps the bound spy cached after mockRestore; fine while
413
+ // no other test in this file calls Template.build for real.
414
+ const TemplateClass = Template.prototype.constructor as typeof Template;
415
+ const build = spyOn(TemplateClass, "build").mockResolvedValue({
410
416
  alias: "worker",
411
417
  name: "worker",
412
418
  tags: [],
@@ -1,5 +1,5 @@
1
1
  import { afterEach, describe, expect, mock, test } from "bun:test";
2
- import { type LogRecord, logs, SeverityNumber } from "@opentelemetry/api-logs";
2
+ import { type LogRecord, logs, SeverityNumber } from "@opentelemetry/api";
3
3
  import { MeterProvider, MetricReader } from "@opentelemetry/sdk-metrics";
4
4
  import {
5
5
  installConsoleLogBridge,
@@ -108,7 +108,10 @@ const bytes = new TextEncoder().encode(url.href);
108
108
  const id = setInterval(() => {}, 10);
109
109
  clearInterval(id);
110
110
  await fetch(url, { method: "POST", body: bytes });
111
- return structuredClone([new TextDecoder().decode(bytes), crypto.randomUUID(), crypto.getRandomValues(new Uint8Array(4))]);`);
111
+ const res = await fetch(url);
112
+ const body = new TextEncoder().encode(await res.text()).buffer;
113
+ const parsed = await (await fetch(url))["json"]();
114
+ return structuredClone([new TextDecoder().decode(bytes), body.byteLength, parsed, crypto.randomUUID(), crypto.getRandomValues(new Uint8Array(4))]);`);
112
115
  expect(checkQuickJSCompat(source)).toEqual({ compatible: true, findings: [] });
113
116
  });
114
117
 
@@ -199,15 +202,48 @@ export default async () => { const process = { env: {} }; return [decode({ from:
199
202
  );
200
203
  });
201
204
 
202
- test("reports each rule and name once, with its first line", () => {
205
+ test("reports each rule and name once, with every line it recurs on", () => {
203
206
  const report = checkQuickJSCompat(wrap("Bun.sleep(1);\nBun.sleep(2);\nreturn process.pid;"));
204
207
  expect(report.findings).toEqual([
205
- { rule: "bunGlobal", message: "Bun.* is not available under quickjs", line: 2 },
208
+ {
209
+ rule: "bunGlobal",
210
+ message: "Bun.* is not available under quickjs",
211
+ line: 2,
212
+ lines: [2, 3],
213
+ },
206
214
  { rule: "process", message: "process is not available under quickjs", line: 4 },
207
215
  ]);
208
216
  expect(quickJSCompatWarnings(report, "actions.sync")).toEqual([
209
- "actions.sync: quickjs compat (bunGlobal, line 2): Bun.* is not available under quickjs",
217
+ "actions.sync: quickjs compat (bunGlobal, lines 2, 3): Bun.* is not available under quickjs",
210
218
  "actions.sync: quickjs compat (process, line 4): process is not available under quickjs",
211
219
  ]);
220
+
221
+ // A zip reader: arrayBuffer() on a Response and later on a fetch result. Before,
222
+ // the second call site was dropped as a duplicate of the first.
223
+ const zip = wrap(`const stream = new Blob([args.data]).stream();
224
+ const inflated = new Uint8Array(await new Response(stream).arrayBuffer());
225
+ const res = await fetch(args.url);
226
+ const buf = new Uint8Array(await res.arrayBuffer());
227
+ const raw = await (await fetch(args.url))["blob"]();
228
+ return [inflated, buf, raw];`);
229
+ expect(checkQuickJSCompat(zip).findings.filter((f) => f.rule === "responseBody")).toEqual([
230
+ {
231
+ rule: "responseBody",
232
+ message:
233
+ ".arrayBuffer() on a fetch Response is not available under quickjs (text() and json() are)",
234
+ line: 3,
235
+ lines: [3, 5],
236
+ },
237
+ {
238
+ rule: "responseBody",
239
+ message:
240
+ ".blob() on a fetch Response is not available under quickjs (text() and json() are)",
241
+ line: 6,
242
+ },
243
+ ]);
244
+ const many = wrap(Array.from({ length: 12 }, () => "Bun.sleep(1);").join("\n"));
245
+ expect(quickJSCompatWarnings(checkQuickJSCompat(many))).toEqual([
246
+ "quickjs compat (bunGlobal, lines 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, +2 more): Bun.* is not available under quickjs",
247
+ ]);
212
248
  });
213
249
  });
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Admission for routes that left the RBAC backlog, over real HTTP.
3
+ *
4
+ * A custom role can only be created in the database (no public route makes
5
+ * one), so this boots the real server on a scratch DB and writes the role
6
+ * rows directly, like rbac-admission-e2e.test.ts.
7
+ *
8
+ * 1. A route that got an existing verb admits a custom role holding it and
9
+ * refuses one without it.
10
+ * 2. A custom role holding `user.manage` still cannot bind its chat identity
11
+ * onto a grant-all admin: user and identity admin stay operator-only.
12
+ */
13
+ import { Database } from "bun:sqlite";
14
+ import { afterAll, describe, expect, setDefaultTimeout, test } from "bun:test";
15
+ import { join } from "node:path";
16
+ import {
17
+ api,
18
+ makeScratchDir,
19
+ registerAgent,
20
+ removeScratchDir,
21
+ type SwarmServer,
22
+ spawnSwarmServer,
23
+ WORKER_A,
24
+ } from "./rbac-e2e-helpers";
25
+
26
+ setDefaultTimeout(120_000);
27
+
28
+ let dir: string | undefined;
29
+ let server: SwarmServer | undefined;
30
+
31
+ /** Replace the user's roles with one custom role holding exactly `verbs`. */
32
+ function setCustomRole(dbPath: string, userId: string, roleId: string, verbs: string[]): void {
33
+ const db = new Database(dbPath);
34
+ try {
35
+ db.run("PRAGMA busy_timeout = 5000");
36
+ db.transaction(() => {
37
+ db.prepare(
38
+ `INSERT OR IGNORE INTO roles (id, name, description, isBuiltin, grantsAll)
39
+ VALUES (?, ?, 'test custom role', 0, 0)`,
40
+ ).run(roleId, roleId);
41
+ for (const verb of verbs) {
42
+ db.prepare("INSERT OR IGNORE INTO role_permissions (roleId, verb) VALUES (?, ?)").run(
43
+ roleId,
44
+ verb,
45
+ );
46
+ }
47
+ db.prepare(
48
+ "DELETE FROM principal_roles WHERE principalType = 'user' AND principalId = ?",
49
+ ).run(userId);
50
+ db.prepare(
51
+ "INSERT INTO principal_roles (principalType, principalId, roleId) VALUES ('user', ?, ?)",
52
+ ).run(userId, roleId);
53
+ })();
54
+ } finally {
55
+ db.close();
56
+ }
57
+ }
58
+
59
+ describe("RBAC admission for routes that left the backlog", () => {
60
+ afterAll(async () => {
61
+ await server?.stop();
62
+ server = undefined;
63
+ if (dir) await removeScratchDir(dir);
64
+ });
65
+
66
+ test("verb admits a custom role, missing verb is 403, user.manage cannot rebind onto an admin", async () => {
67
+ dir = await makeScratchDir();
68
+ const dbPath = join(dir, "route-verbs.sqlite");
69
+ server = await spawnSwarmServer({
70
+ dbPath,
71
+ logPath: join(dir, "server.log"),
72
+ env: { RBAC_ENABLED: "true" },
73
+ });
74
+ await registerAgent(server.base, WORKER_A, "rbac-route-verbs-worker", false);
75
+
76
+ const admin = await api(server.base, "POST", "/api/users", {
77
+ body: { name: "route-verbs-admin", email: "rbac-route-verbs-admin@example.com" },
78
+ });
79
+ expect(admin.status).toBe(200);
80
+ const adminId = admin.body.user.id as string;
81
+
82
+ const user = await api(server.base, "POST", "/api/users", {
83
+ body: {
84
+ name: "route-verbs-user",
85
+ email: "rbac-route-verbs-user@example.com",
86
+ identities: [{ kind: "slack", externalId: "U-ROUTE-VERBS" }],
87
+ },
88
+ });
89
+ expect(user.status).toBe(200);
90
+ const userId = user.body.user.id as string;
91
+
92
+ const minted = await api(server.base, "POST", `/api/users/${userId}/mcp-tokens`, { body: {} });
93
+ expect(minted.status).toBe(200);
94
+ const bearer = minted.body.plaintext as string;
95
+
96
+ // 1. PUT /api/agents/{id}/name declares agent.profile.update.any.
97
+ setCustomRole(dbPath, userId, "rbac-test-no-verbs", ["favorite.write.own"]);
98
+ const denied = await api(server.base, "PUT", `/api/agents/${WORKER_A}/name`, {
99
+ bearer,
100
+ body: { name: "renamed-denied" },
101
+ });
102
+ expect(denied.status).toBe(403);
103
+ expect(denied.body.error).toContain("missing permission 'agent.profile.update.any'");
104
+
105
+ setCustomRole(dbPath, userId, "rbac-test-profile-editor", ["agent.profile.update.any"]);
106
+ const allowed = await api(server.base, "PUT", `/api/agents/${WORKER_A}/name`, {
107
+ bearer,
108
+ body: { name: "renamed-allowed" },
109
+ });
110
+ expect(allowed.status).toBe(200);
111
+ expect(allowed.body.name).toBe("renamed-allowed");
112
+
113
+ // 2. user.manage does not admit identity moves: unbinding its own Slack id
114
+ // and binding it onto the grant-all admin are both refused.
115
+ setCustomRole(dbPath, userId, "rbac-test-user-manager", ["user.manage"]);
116
+ const unbind = await api(
117
+ server.base,
118
+ "DELETE",
119
+ `/api/users/${userId}/identities/slack/U-ROUTE-VERBS`,
120
+ { bearer },
121
+ );
122
+ expect(unbind.status).toBe(403);
123
+ expect(unbind.body.error).toContain("route has no permission verb (operator-only)");
124
+
125
+ const rebind = await api(server.base, "POST", `/api/users/${adminId}/identities`, {
126
+ bearer,
127
+ body: { kind: "slack", externalId: "U-ROUTE-VERBS-2" },
128
+ });
129
+ expect(rebind.status).toBe(403);
130
+ expect(rebind.body.error).toContain("route has no permission verb (operator-only)");
131
+
132
+ const mintAdmin = await api(server.base, "POST", "/api/users", {
133
+ bearer,
134
+ body: { name: "minted-admin" },
135
+ });
136
+ expect(mintAdmin.status).toBe(403);
137
+
138
+ const adminIdentities = await api(server.base, "GET", `/api/users/${adminId}`);
139
+ expect(adminIdentities.status).toBe(200);
140
+ expect(JSON.stringify(adminIdentities.body)).not.toContain("U-ROUTE-VERBS");
141
+ });
142
+ });
@@ -734,6 +734,8 @@ describe("script connections", () => {
734
734
  markMigrationApplied(database, "354_durable_objects.sql");
735
735
  // 362 rebuilds user_favorites, which this fixture does not create (see 301).
736
736
  markMigrationApplied(database, "362_favorites_app.sql");
737
+ // 367 alters workflow_runs, which this fixture does not create.
738
+ markMigrationApplied(database, "367_workflow_run_principal.sql");
737
739
 
738
740
  const id = crypto.randomUUID();
739
741
  const now = new Date().toISOString();
@@ -2089,7 +2089,7 @@ describe("Slack renderer v2", () => {
2089
2089
  expect(blocks.map((block) => block.elements.map((element) => element.text))).toEqual([
2090
2090
  ["Sources: <https://example.com/a|[1]> Cited"],
2091
2091
  ["General sources: <https://example.com/b|[2]> Whole answer"],
2092
- ["📎 <https://example.com/report.md|report.md>"],
2092
+ ["Links: 🌐 <https://example.com/report.md|report.md>"],
2093
2093
  [expect.stringContaining(ask.id.slice(0, 8))],
2094
2094
  ]);
2095
2095
  } finally {
@@ -2098,6 +2098,48 @@ describe("Slack renderer v2", () => {
2098
2098
  }
2099
2099
  });
2100
2100
 
2101
+ test("outcome cards link bare URLs in the answer and show each URL once", async () => {
2102
+ const lead = await createAgent({ name: "Magic Link Lead", isLead: true, status: "idle" });
2103
+ const { channelId, threadTs } = uniqueSlackAddress("C_MAGIC_LINKS");
2104
+ const ask = await createTaskExtended("Magic links", {
2105
+ agentId: lead.id,
2106
+ source: "slack",
2107
+ slackChannelId: channelId,
2108
+ slackThreadTs: threadTs,
2109
+ contextKey: slackContextKey({ channelId, threadTs }),
2110
+ });
2111
+ await startTask(ask.id);
2112
+ await upsertTaskCitations(ask.id, [
2113
+ { index: 1, kind: "url", ref: "https://github.com/o/r/pull/42", label: "The PR" },
2114
+ ]);
2115
+ // The cited PR is the primary attachment: it shows as a source only.
2116
+ await insertTaskAttachment({
2117
+ taskId: ask.id,
2118
+ agentId: lead.id,
2119
+ kind: "url",
2120
+ name: "PR",
2121
+ url: "https://github.com/o/r/pull/42/",
2122
+ isPrimary: true,
2123
+ });
2124
+ await completeTask(
2125
+ ask.id,
2126
+ "Merged [citation:1]. Report: https://docs.example.test/a/b/report.md. Keep `https://code.example.test/x`, [docs](https://docs.example.test/d) and <https://slack.example.test/s|s>.",
2127
+ );
2128
+ await backdateLastUpdated([ask.id], 20);
2129
+ await processSlackRenderV2();
2130
+
2131
+ const started = calls.find((call) => call.method === "chat.startStream");
2132
+ expect(started?.payload.markdown_text).toBe(
2133
+ "✅ Merged <https://github.com/o/r/pull/42|[1]>. Report: <https://docs.example.test/a/b/report.md|docs.example.test/…/report.md>. Keep `https://code.example.test/x`, [docs](https://docs.example.test/d) and <https://slack.example.test/s|s>.",
2134
+ );
2135
+ const stopped = calls.find((call) => call.method === "chat.stopStream");
2136
+ const blocks = stopped?.payload.blocks as { type: string; elements: { text: string }[] }[];
2137
+ expect(blocks.map((block) => block.elements.map((element) => element.text))).toEqual([
2138
+ ["Sources: <https://github.com/o/r/pull/42|[1]> The PR"],
2139
+ [expect.stringContaining(ask.id.slice(0, 8))],
2140
+ ]);
2141
+ });
2142
+
2101
2143
  test("the postMessage fallback keeps captions out of the notification text", async () => {
2102
2144
  const lead = await createAgent({ name: "Fallback Lead", isLead: true, status: "idle" });
2103
2145
  const { channelId, threadTs } = uniqueSlackAddress("C_CAPTION_FALLBACK");
@@ -2221,19 +2263,19 @@ describe("Slack renderer v2", () => {
2221
2263
  label: "plain ASCII positive control",
2222
2264
  attachment: { kind: "agent-fs", name: "report.txt", path: "/reports/report.txt" },
2223
2265
  expected:
2224
- "📎 <https://files.example.test/file/~/org-1/drive-1/reports/report.txt|report.txt>",
2266
+ "Links: 📄 <https://files.example.test/file/~/org-1/drive-1/reports/report.txt|report.txt>",
2225
2267
  },
2226
2268
  {
2227
2269
  label: "raw path spaces and parentheses",
2228
2270
  attachment: { kind: "agent-fs", name: "final report", path: "/shared reports/final (v1).md" },
2229
2271
  expected:
2230
- "📎 <https://files.example.test/file/~/org-1/drive-1/shared%20reports/final%20(v1).md|final report>",
2272
+ "Links: 📄 <https://files.example.test/file/~/org-1/drive-1/shared%20reports/final%20(v1).md|final report>",
2231
2273
  },
2232
2274
  {
2233
2275
  label: "already encoded positive control",
2234
2276
  attachment: { kind: "agent-fs", name: "report", path: "/reports/final%20%28v1%29.md" },
2235
2277
  expected:
2236
- "📎 <https://files.example.test/file/~/org-1/drive-1/reports/final%20%28v1%29.md|report>",
2278
+ "Links: 📄 <https://files.example.test/file/~/org-1/drive-1/reports/final%20%28v1%29.md|report>",
2237
2279
  },
2238
2280
  {
2239
2281
  label: "label delimiters, backslashes, and whitespace",
@@ -2242,12 +2284,12 @@ describe("Slack renderer v2", () => {
2242
2284
  name: " \t[report] <final> & (copy)\\\r\n\t two ",
2243
2285
  url: "https://example.test/report",
2244
2286
  },
2245
- expected: "📎 <https://example.test/report|[report] &lt;final&gt; &amp; (copy)\\ two>",
2287
+ expected: "Links: 🌐 <https://example.test/report|[report] &lt;final&gt; &amp; (copy)\\ two>",
2246
2288
  },
2247
2289
  {
2248
2290
  label: "URL positive control with an IPv6 host",
2249
2291
  attachment: { kind: "url", name: "report", url: "http://[::1]/report.txt?q=a%20b&x=1#part" },
2250
- expected: "📎 <http://[::1]/report.txt?q=a%20b&x=1#part|report>",
2292
+ expected: "Links: 🌐 <http://[::1]/report.txt?q=a%20b&x=1#part|report>",
2251
2293
  },
2252
2294
  {
2253
2295
  label: "URL delimiters with existing escapes and query parameters",
@@ -2257,7 +2299,7 @@ describe("Slack renderer v2", () => {
2257
2299
  url: "https://example.test/a%20b) [c]<(d)>|\\file?q=one two&x=1#part",
2258
2300
  },
2259
2301
  expected:
2260
- "📎 <https://example.test/a%20b)%20[c]%3C(d)%3E%7C%5Cfile?q=one%20two&x=1#part|report>",
2302
+ "Links: 🌐 <https://example.test/a%20b)%20[c]%3C(d)%3E%7C%5Cfile?q=one%20two&x=1#part|report>",
2261
2303
  },
2262
2304
  {
2263
2305
  label: "non-HTTP fallback stays omitted",
@@ -2310,7 +2352,9 @@ describe("Slack renderer v2", () => {
2310
2352
  const captions = (stopped?.payload.blocks as { type: string; elements: { text: string }[] }[])
2311
2353
  .filter((block) => block.type === "context")
2312
2354
  .map((block) => block.elements.map((element) => element.text).join(" "));
2313
- expect(captions.filter((text) => text.startsWith("📎"))).toEqual(expected ? [expected] : []);
2355
+ expect(captions.filter((text) => text.startsWith("Links:"))).toEqual(
2356
+ expected ? [expected] : [],
2357
+ );
2314
2358
  } finally {
2315
2359
  if (originalHost === undefined) delete process.env.AGENT_FS_LIVE_URL;
2316
2360
  else process.env.AGENT_FS_LIVE_URL = originalHost;
@@ -17,6 +17,7 @@ import {
17
17
  initDb,
18
18
  PINNED_WORKFLOW_KEYS,
19
19
  pinWorkflowDefinition,
20
+ resolveApprovalRequest,
20
21
  resolveWaitState,
21
22
  toPinnedDefinition,
22
23
  } from "../be/db";
@@ -396,6 +397,7 @@ describe("a run finishes on the definition it started with", () => {
396
397
  const requestId = (registry.get("mock-hitl") as MockHitlExecutor).lastRequestId!;
397
398
 
398
399
  await editTo(workflow.id, twoNode("B", hitlFirst));
400
+ await resolveApprovalRequest(requestId, { status: "approved", responses: { q1: true } });
399
401
  workflowEventBus.emit("approval.resolved", {
400
402
  requestId,
401
403
  status: "approved",
@@ -129,6 +129,19 @@ const mockDeps: ExecutorDependencies = {
129
129
  interpolate: (t: string) => t,
130
130
  };
131
131
 
132
+ /** Store the answer on the request row, as the respond route does before it emits. */
133
+ async function storeAnswer(
134
+ requestId: string,
135
+ status: "approved" | "rejected" | "timeout" | "cancelled",
136
+ responses: Record<string, unknown> | null,
137
+ ): Promise<void> {
138
+ if (status === "cancelled") {
139
+ await db.cancelApprovalRequestById(requestId, { reason: "test", resolvedBy: null });
140
+ } else {
141
+ await db.resolveApprovalRequest(requestId, { status, responses });
142
+ }
143
+ }
144
+
132
145
  let workflowCounter = 0;
133
146
  const createdWorkflowIds: string[] = [];
134
147
 
@@ -154,11 +167,21 @@ async function stepIsWaiting(runId: string, nodeId: string, notStepId?: string):
154
167
  * Helper: creates a workflow with a HITL node that has port-based routing,
155
168
  * starts it, waits for it to go async, then emits an approval event.
156
169
  * Returns the run ID and step details for verification.
170
+ *
171
+ * `notify` sends a misleading approval.resolved for the step before the answer
172
+ * is stored: one naming its still-pending request ("pending"), or one naming a
173
+ * resolved request bound to another step ("foreign"), each carrying `status`.
174
+ * `eventStatus` makes the real event's payload disagree with the stored answer.
175
+ * The step must route only on the stored request bound to it.
157
176
  */
158
177
  async function runHITLWorkflow(
159
178
  approvalStatus: "approved" | "rejected" | "timeout" | "cancelled",
160
179
  eventBus: InProcessEventBus,
161
180
  registry: ExecutorRegistry,
181
+ opts: {
182
+ notify?: { request: "pending" | "foreign"; status: "approved" | "rejected" | "timeout" };
183
+ eventStatus?: "approved" | "rejected" | "timeout";
184
+ } = {},
162
185
  ) {
163
186
  const def: WorkflowDefinition = {
164
187
  nodes: [
@@ -196,11 +219,36 @@ async function runHITLWorkflow(
196
219
  const requestId = hitlExecutor.lastRequestId!;
197
220
  expect(requestId).toBeTruthy();
198
221
 
222
+ if (opts.notify) {
223
+ let notifiedId = requestId;
224
+ if (opts.notify.request === "foreign") {
225
+ notifiedId = crypto.randomUUID();
226
+ await db.createApprovalRequest({
227
+ id: notifiedId,
228
+ title: "Another step's card",
229
+ questions: [{ id: "q1", type: "approval", label: "Approve?", required: true }],
230
+ approvers: { policy: "any" },
231
+ workflowRunId: runId,
232
+ workflowRunStepId: steps.find((s) => s.nodeId === "start")!.id,
233
+ });
234
+ await storeAnswer(notifiedId, opts.notify.status, { q1: true });
235
+ }
236
+ eventBus.emit("approval.resolved", {
237
+ requestId: notifiedId,
238
+ status: opts.notify.status,
239
+ responses: { q1: true },
240
+ workflowRunId: runId,
241
+ workflowRunStepId: reviewStep!.id,
242
+ });
243
+ }
244
+
199
245
  // Emit approval.resolved event — this triggers resumeFromApprovalResolution
246
+ await storeAnswer(requestId, approvalStatus, approvalStatus === "approved" ? { q1: true } : null);
247
+ const eventStatus = opts.eventStatus ?? approvalStatus;
200
248
  eventBus.emit("approval.resolved", {
201
249
  requestId,
202
- status: approvalStatus,
203
- responses: approvalStatus === "approved" ? { q1: true } : null,
250
+ status: eventStatus,
251
+ responses: eventStatus === "approved" ? { q1: true } : null,
204
252
  workflowRunId: runId,
205
253
  workflowRunStepId: reviewStep!.id,
206
254
  });
@@ -250,7 +298,10 @@ describe("HITL port-based routing", () => {
250
298
  registry.register(new EchoExecutor({ ...mockDeps, eventBus }));
251
299
  setupWorkflowResumeListener(eventBus, registry);
252
300
 
253
- const { runId } = await runHITLWorkflow("approved", eventBus, registry);
301
+ // A notification for the still-pending card must not route the step.
302
+ const { runId } = await runHITLWorkflow("approved", eventBus, registry, {
303
+ notify: { request: "pending", status: "rejected" },
304
+ });
254
305
 
255
306
  const run = await getWorkflowRun(runId);
256
307
  expect(run!.status).toBe("completed");
@@ -275,7 +326,10 @@ describe("HITL port-based routing", () => {
275
326
  registry.register(new EchoExecutor({ ...mockDeps, eventBus }));
276
327
  setupWorkflowResumeListener(eventBus, registry);
277
328
 
278
- const { runId } = await runHITLWorkflow("rejected", eventBus, registry);
329
+ // The stored answer wins over an event payload that disagrees with it.
330
+ const { runId } = await runHITLWorkflow("rejected", eventBus, registry, {
331
+ eventStatus: "approved",
332
+ });
279
333
 
280
334
  const run = await getWorkflowRun(runId);
281
335
  expect(run!.status).toBe("completed");
@@ -291,6 +345,7 @@ describe("HITL port-based routing", () => {
291
345
  // Should NOT have the approved or timeout paths
292
346
  expect(stepNodeIds).not.toContain("deploy");
293
347
  expect(stepNodeIds).not.toContain("notify-timeout");
348
+ expect(steps.find((s) => s.nodeId === "review")!.output).toMatchObject({ status: "rejected" });
294
349
  });
295
350
 
296
351
  test("cancelled → routes to no port; the step stays waiting", async () => {
@@ -321,7 +376,10 @@ describe("HITL port-based routing", () => {
321
376
  registry.register(new EchoExecutor({ ...mockDeps, eventBus }));
322
377
  setupWorkflowResumeListener(eventBus, registry);
323
378
 
324
- const { runId } = await runHITLWorkflow("timeout", eventBus, registry);
379
+ // A resolved card bound to another step must not route this one.
380
+ const { runId } = await runHITLWorkflow("timeout", eventBus, registry, {
381
+ notify: { request: "foreign", status: "approved" },
382
+ });
325
383
 
326
384
  const run = await getWorkflowRun(runId);
327
385
  expect(run!.status).toBe("completed");
@@ -387,6 +445,7 @@ describe("HITL port-based routing", () => {
387
445
  const requestId1 = hitlExecutor.lastRequestId!;
388
446
 
389
447
  // REJECT — should loop back to generate-question
448
+ await storeAnswer(requestId1, "rejected", null);
390
449
  eventBus.emit("approval.resolved", {
391
450
  requestId: requestId1,
392
451
  status: "rejected",
@@ -420,6 +479,7 @@ describe("HITL port-based routing", () => {
420
479
  expect(requestId2).not.toBe(requestId1); // Different request
421
480
 
422
481
  // APPROVE — should go to success
482
+ await storeAnswer(requestId2, "approved", { q1: true });
423
483
  eventBus.emit("approval.resolved", {
424
484
  requestId: requestId2,
425
485
  status: "approved",
@@ -504,6 +564,7 @@ describe("HITL port-based routing", () => {
504
564
  const requestId1 = hitlExecutor.lastRequestId!;
505
565
 
506
566
  // REJECT — should loop back to generate-question (async)
567
+ await storeAnswer(requestId1, "rejected", null);
507
568
  eventBus.emit("approval.resolved", {
508
569
  requestId: requestId1,
509
570
  status: "rejected",
@@ -551,6 +612,7 @@ describe("HITL port-based routing", () => {
551
612
  expect(requestId2).not.toBe(requestId1);
552
613
 
553
614
  // APPROVE — should go to success
615
+ await storeAnswer(requestId2, "approved", { q1: true });
554
616
  eventBus.emit("approval.resolved", {
555
617
  requestId: requestId2,
556
618
  status: "approved",
@@ -14,6 +14,7 @@ import { runBootScrubSweep } from "../be/boot-scrub-sweep";
14
14
  import { __resetEncryptionKeyForTests, encryptSecret, resolveEncryptionKey } from "../be/crypto";
15
15
  import {
16
16
  closeDb,
17
+ createApprovalRequest,
17
18
  createUser,
18
19
  createWaitState,
19
20
  createWorkflow,
@@ -24,6 +25,7 @@ import {
24
25
  getWorkflowRun,
25
26
  getWorkflowRunStepsByRunId,
26
27
  initDb,
28
+ resolveApprovalRequest,
27
29
  updateWorkflowRun,
28
30
  updateWorkflowRunStep,
29
31
  } from "../be/db";
@@ -434,8 +436,18 @@ describe("a live resume with an unreadable sealed context fails the run", () =>
434
436
 
435
437
  test("approval.resolved", async () => {
436
438
  const { runId, stepId } = await parkedRunWithRotatedContext("review", "human-in-the-loop");
439
+ const requestId = crypto.randomUUID();
440
+ await createApprovalRequest({
441
+ id: requestId,
442
+ title: "Review",
443
+ questions: [{ id: "q1", type: "approval", label: "Approve?", required: true }],
444
+ approvers: { policy: "any" },
445
+ workflowRunId: runId,
446
+ workflowRunStepId: stepId,
447
+ });
448
+ await resolveApprovalRequest(requestId, { status: "approved", responses: {} });
437
449
  eventBus.emit("approval.resolved", {
438
- requestId: crypto.randomUUID(),
450
+ requestId,
439
451
  status: "approved",
440
452
  responses: {},
441
453
  workflowRunId: runId,