@desplega.ai/agent-swarm 2.7.10 → 2.8.1

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 (296) hide show
  1. package/dist/acp-adapter-pdy3qsvg.js +15 -0
  2. package/dist/{actions-b8aqhrsg.js → actions-pwjpn0j6.js} +19 -20
  3. package/dist/{amp-adapter-4c165vgn.js → amp-adapter-cq9jgj6x.js} +2 -3
  4. package/dist/{app-m9khefrh.js → app-cnfffgwg.js} +3 -3
  5. package/dist/{assistant-rh4v3ntz.js → assistant-kpn317y1.js} +21 -22
  6. package/dist/{boot-args-schema-hwkc8bzv.js → boot-args-schema-pbbnhmc3.js} +1 -1
  7. package/dist/{boot-reembed-fdyk55h4.js → boot-reembed-9m0ysxma.js} +1 -1
  8. package/dist/{boot-reembed-5y6yw9sj.js → boot-reembed-majbn53m.js} +1 -1
  9. package/dist/{boot-scrub-sweep-r5r8kqsn.js → boot-scrub-sweep-app8g8ym.js} +3 -3
  10. package/dist/{boot-seeds-8f9zt5cm.js → boot-seeds-pbtmvcjm.js} +4 -5
  11. package/dist/{claude-adapter-s5df247c.js → claude-adapter-wn1g3qp5.js} +7 -8
  12. package/dist/{claude-managed-adapter-h74d06yz.js → claude-managed-adapter-jh6c523j.js} +3 -3
  13. package/dist/{claude-managed-setup-9gsmwzyx.js → claude-managed-setup-pd47nzch.js} +6 -6
  14. package/dist/{claude-sdk-session-dq1j4nz9.js → claude-sdk-session-3a2a6589.js} +9066 -8818
  15. package/dist/{cli-n5yexkdg.js → cli-0b4zam62.js} +1 -0
  16. package/dist/{cli-5wfz00be.js → cli-0jzra9ad.js} +2 -2
  17. package/dist/{cli-zjphdj1a.js → cli-0ntbxyaa.js} +40 -18
  18. package/dist/{cli-yz7v0sh4.js → cli-1xh9a7hn.js} +4 -6
  19. package/dist/{cli-eqtfgfr6.js → cli-2gxeg5gr.js} +1 -1
  20. package/dist/{cli-hfkwwy1h.js → cli-2zp0et3v.js} +21 -2
  21. package/dist/{cli-6m6b4bep.js → cli-3rkdne1h.js} +2 -2
  22. package/dist/{cli-mr97t7cc.js → cli-4r05hnqa.js} +263 -14
  23. package/dist/{cli-jc1g9ndz.js → cli-5j88qqa8.js} +10 -5
  24. package/dist/{cli-xfjrc279.js → cli-5mrq3ake.js} +48 -14
  25. package/dist/{cli-an1knn2k.js → cli-6mma83xa.js} +5 -5
  26. package/dist/{cli-tph5wt3y.js → cli-6wj7p986.js} +1 -1
  27. package/dist/{cli-t73cas91.js → cli-7349va39.js} +8100 -7620
  28. package/dist/{cli-5xcb8gxq.js → cli-7b8sbmag.js} +8 -8
  29. package/dist/{cli-3xj33nrx.js → cli-7cp6aa1q.js} +10 -3
  30. package/dist/{cli-mp9aa8g5.js → cli-7p1kvkck.js} +6 -6
  31. package/dist/{cli-j7d73g1y.js → cli-7w69ne2f.js} +3035 -354
  32. package/dist/{cli-cr14kftt.js → cli-89cqnasv.js} +3 -3
  33. package/dist/{cli-w3bk0dgv.js → cli-8aes17e4.js} +2 -2
  34. package/dist/{cli-7wz05bx3.js → cli-93k32c37.js} +468 -745
  35. package/dist/{cli-eqk5p56g.js → cli-9vhebtjz.js} +9 -9
  36. package/dist/{cli-td33w98c.js → cli-9wngrawf.js} +10 -10
  37. package/dist/cli-a3b239vq.js +242 -0
  38. package/dist/{cli-kx4c8j05.js → cli-b085njxz.js} +63 -19
  39. package/dist/{cli-8ewkreqd.js → cli-b5rs97a6.js} +7 -9
  40. package/dist/{cli-bxz823sz.js → cli-b8e9nb04.js} +1 -1
  41. package/dist/{cli-nj3x45rw.js → cli-bb431xey.js} +52 -43
  42. package/dist/{cli-36wdfzgn.js → cli-bsywb58a.js} +8 -8
  43. package/dist/{cli-18qt3few.js → cli-cyhbbd1z.js} +1 -1
  44. package/dist/{cli-eb2azq8n.js → cli-d3p5vwbk.js} +9 -9
  45. package/dist/{cli-2tsfpc70.js → cli-dy32zecz.js} +1 -1
  46. package/dist/{cli-rjyghzg4.js → cli-g70vxtjh.js} +2 -2
  47. package/dist/{cli-55bkx8hh.js → cli-gax7fk3t.js} +1 -1
  48. package/dist/{cli-jg24scat.js → cli-jcpr5smb.js} +3 -3
  49. package/dist/{cli-n07eecjs.js → cli-jywyhqws.js} +3 -3
  50. package/dist/{cli-38yww4e9.js → cli-k0615eh8.js} +8 -8
  51. package/dist/{cli-3xddv0rk.js → cli-k26bkr9t.js} +5 -7
  52. package/dist/{cli-xd5ebp64.js → cli-k93bq1wq.js} +3 -3
  53. package/dist/{cli-f2zenhja.js → cli-kc7v1nfv.js} +1 -1
  54. package/dist/{cli-x9exydey.js → cli-m4dqmnbp.js} +1 -1
  55. package/dist/{cli-gpwhbgx0.js → cli-m9s2qff2.js} +57 -25
  56. package/dist/{cli-ybjdc978.js → cli-mrt48bx7.js} +7 -4
  57. package/dist/{cli-ttbqe3q4.js → cli-p1w18yhx.js} +1 -1
  58. package/dist/{cli-h49ejvmc.js → cli-pcad4cb1.js} +1 -1
  59. package/dist/{cli-tmft5dz2.js → cli-qmqk2yc2.js} +1 -1
  60. package/dist/{cli-g1px1g2e.js → cli-re4raaj0.js} +1 -1
  61. package/dist/{cli-xbtq4d6s.js → cli-sn7rtnj4.js} +12 -8
  62. package/dist/{cli-n9abj89w.js → cli-syybb0p1.js} +8 -8
  63. package/dist/{cli-v2fwbnsk.js → cli-tacge1w0.js} +6 -6
  64. package/dist/{cli-pyrxt9gw.js → cli-tk7cjj8h.js} +1 -1
  65. package/dist/{cli-xvymtmv4.js → cli-tqegb8eq.js} +3 -3
  66. package/dist/{cli-kf3pxxdg.js → cli-v1dv1r37.js} +1 -1
  67. package/dist/{cli-z9cs5m0w.js → cli-vbh10fqa.js} +12 -12
  68. package/dist/{cli-3xcwp3z8.js → cli-vj75tyaw.js} +3 -3
  69. package/dist/{cli-xncjscpm.js → cli-vqptjbr7.js} +50 -24
  70. package/dist/{cli-q581b386.js → cli-wk18cm92.js} +5 -5
  71. package/dist/{cli-4vwxp550.js → cli-x1wa213s.js} +1 -1
  72. package/dist/{cli-n9ftpys4.js → cli-x6t50dmw.js} +7 -7
  73. package/dist/{cli-jrp1dt73.js → cli-xzm9vcfg.js} +1 -1
  74. package/dist/{cli-16phend6.js → cli-yn2bbre9.js} +1 -1
  75. package/dist/{cli-rt0ag4x1.js → cli-yncmerje.js} +5 -5
  76. package/dist/{cli-0m7rtm11.js → cli-zcsw143p.js} +1 -1
  77. package/dist/cli.js +18 -18
  78. package/dist/{codex-adapter-yr60sme6.js → codex-adapter-nha71q3n.js} +5 -6
  79. package/dist/{codex-hook-fac6175r.js → codex-hook-h3vk6xzr.js} +1 -1
  80. package/dist/{codex-session-runner-pch8x584.js → codex-session-runner-ak9x1k1h.js} +5 -6
  81. package/dist/{commands-phjfbkv0.js → commands-f587qpq8.js} +3 -3
  82. package/dist/{controller-jkx994pz.js → controller-hxx8wwy1.js} +2 -2
  83. package/dist/{controllers-connect-c4448kwa.js → controllers-connect-k5sg9m9h.js} +20 -21
  84. package/dist/{cursor-adapter-ndebqnm8.js → cursor-adapter-n5nc3mfe.js} +1 -2
  85. package/dist/{db-ef32tbfc.js → db-amm8w15a.js} +10 -2
  86. package/dist/{db-ez6egt6v.js → db-nzf8zb5z.js} +3 -3
  87. package/dist/{devin-adapter-z46ep5ph.js → devin-adapter-xedz98zv.js} +1 -1
  88. package/dist/{dispatcher-g3tt9hs9.js → dispatcher-89zrts8f.js} +18 -19
  89. package/dist/{dsh-adapter-tcyn3099.js → dsh-adapter-nrhbrjz8.js} +1 -2
  90. package/dist/{easter-egg-3d-e36hk5td.js → easter-egg-3d-533knw22.js} +1 -1
  91. package/dist/{embedding-space-4kyh5qqj.js → embedding-space-ezwenjmj.js} +6 -6
  92. package/dist/{embeddings-6a8v4a6t.js → embeddings-np74ht6g.js} +1 -1
  93. package/dist/{execute-3cbg0twf.js → execute-b3mrb1mv.js} +1 -1
  94. package/dist/{external-channel-se646snz.js → external-channel-z46yx9d7.js} +2 -2
  95. package/dist/{fx-adapter-yw795hqq.js → fx-adapter-3q12snn6.js} +7 -8
  96. package/dist/{grok-adapter-ttmcss2j.js → grok-adapter-ahb1w033.js} +7 -8
  97. package/dist/handlers-vbww69re.js +32 -0
  98. package/dist/heartbeat-dt9qw9c8.js +43 -0
  99. package/dist/{hook-hq93y5ej.js → hook-8k6fbz9b.js} +5 -5
  100. package/dist/{hook-g3nhexsy.js → hook-jgcgygex.js} +6 -6
  101. package/dist/{http-5a9p4h6y.js → http-haw4r8ne.js} +284 -142
  102. package/dist/{index-0eny15vj.js → index-2skqtd76.js} +2 -2
  103. package/dist/{index-6haqt3v5.js → index-4a0670yh.js} +8917 -8476
  104. package/dist/index-4xwaf5th.js +32 -0
  105. package/dist/{index-3c5pxbge.js → index-5gk12my8.js} +1 -1
  106. package/dist/{index-w7em4ktq.js → index-d6wkh8ar.js} +2 -2
  107. package/dist/index-f0hcrs8e.js +33 -0
  108. package/dist/{index-rvccek1w.js → index-gjwaqaq8.js} +5 -5
  109. package/dist/{index-e5pfbsys.js → index-hjhfk3ra.js} +3 -3
  110. package/dist/{index-1qw6f2dc.js → index-khe3gp0k.js} +4 -4
  111. package/dist/index-s4ewdma4.js +37 -0
  112. package/dist/{index-hgn3c961.js → index-tez78qj3.js} +979 -36
  113. package/dist/{index-s72rqgsx.js → index-tvfafeyy.js} +1 -1
  114. package/dist/{keepalive-1j4n4dmk.js → keepalive-xn6s7rmg.js} +3 -3
  115. package/dist/lead-6ygbfhbh.js +70 -0
  116. package/dist/{maintenance-dmghacy5.js → maintenance-vdts800b.js} +1 -1
  117. package/dist/{node-je82wjet.js → node-4c5jqxr3.js} +1 -1
  118. package/dist/{oauth-refresh-sweep-yy06c03c.js → oauth-refresh-sweep-094c8wfk.js} +2 -2
  119. package/dist/{onboard-52f9t5dm.js → onboard-v99eh56m.js} +3 -3
  120. package/dist/{opencode-adapter-krnh9jkn.js → opencode-adapter-dsagkhtw.js} +5 -6
  121. package/dist/{otel-impl-xjqz6wjj.js → otel-impl-q7yr9yp0.js} +1 -1
  122. package/dist/{pi-mono-adapter-dbxyp0qv.js → pi-mono-adapter-546cd1cc.js} +9 -9
  123. package/dist/{pricing-refresh-ctdr74pd.js → pricing-refresh-7dh2yase.js} +2 -3
  124. package/dist/{rbac-roles-ehv8s10n.js → rbac-roles-mdmc96p4.js} +3 -3
  125. package/dist/{rbac-roles-q0gr8eyj.js → rbac-roles-npbmdh77.js} +4 -6
  126. package/dist/{registry-hpjfmcfz.js → registry-32b1mft6.js} +1 -1
  127. package/dist/{render-v2-5b6chvcq.js → render-v2-twhhwmms.js} +3 -3
  128. package/dist/{resume-5a5d2845.js → resume-5gsrjd5e.js} +6 -6
  129. package/dist/{runtime-khxszyfp.js → runtime-1hv06jsn.js} +1 -1
  130. package/dist/{session-access-gj0bjhqg.js → session-access-m191x30x.js} +4 -4
  131. package/dist/{session-source-backfill-2sy0krfk.js → session-source-backfill-nt923ask.js} +2 -2
  132. package/dist/{setup-7ssfakk1.js → setup-wv467afy.js} +1 -1
  133. package/dist/{virtual-modules-pjj0knwf.js → virtual-modules-gazyapte.js} +3 -3
  134. package/dist/{work-objects-bf3syvhq.js → work-objects-8zkrpy13.js} +21 -22
  135. package/dist/{worker-follow-up-38xevga6.js → worker-follow-up-cecqszem.js} +18 -19
  136. package/dist/worker-mz5z7kj0.js +70 -0
  137. package/openapi.json +334 -7
  138. package/package.json +5 -5
  139. package/src/apps/definition.ts +11 -0
  140. package/src/apps/store.ts +28 -8
  141. package/src/be/db/model-profiles.ts +147 -38
  142. package/src/be/db/tasks/read.ts +5 -1
  143. package/src/be/db/workflow-run-definitions.ts +117 -0
  144. package/src/be/db.ts +24 -3
  145. package/src/be/memory/constants.ts +14 -1
  146. package/src/be/memory/key-paths.ts +8 -0
  147. package/src/be/memory/providers/sqlite-store.ts +160 -10
  148. package/src/be/memory/task-learning.ts +79 -14
  149. package/src/be/memory/types.ts +24 -1
  150. package/src/be/migrations/279_backfill_learning_expiry.sql +15 -0
  151. package/src/be/migrations/281_model_profiles_pr2.sql +28 -0
  152. package/src/be/migrations/283_workflow_run_definitions.sql +14 -0
  153. package/src/be/model-profile-check.ts +284 -0
  154. package/src/be/model-tier-resolution.ts +112 -12
  155. package/src/be/multi-runtime.ts +27 -0
  156. package/src/be/runtime-pools/routing.ts +52 -4
  157. package/src/be/scripts/typecheck.ts +1 -0
  158. package/src/be/seed-scripts/catalog/dreaming-learnings.ts +552 -0
  159. package/src/be/seed-scripts/catalog/dreaming-memtax-create.ts +389 -14
  160. package/src/be/seed-scripts/catalog/dreaming-memtax.ts +6 -3
  161. package/src/be/seed-scripts/index.ts +9 -0
  162. package/src/be/steering.ts +8 -2
  163. package/src/commands/onboard/agent-fs-version.ts +1 -1
  164. package/src/commands/runner.ts +32 -1
  165. package/src/fs/provider.ts +17 -3
  166. package/src/heartbeat/heartbeat.ts +12 -1
  167. package/src/heartbeat/index.ts +1 -0
  168. package/src/http/agents.ts +56 -4
  169. package/src/http/apps.ts +3 -1
  170. package/src/http/config.ts +2 -6
  171. package/src/http/index.ts +2 -3
  172. package/src/http/model-profiles.ts +58 -10
  173. package/src/http/poll.ts +36 -3
  174. package/src/http/schedules.ts +42 -3
  175. package/src/http/tasks.ts +37 -12
  176. package/src/http/workflows.ts +15 -2
  177. package/src/prompts/session-templates.ts +1 -1
  178. package/src/providers/acp-targets.ts +11 -6
  179. package/src/providers/amp-adapter.ts +1 -1
  180. package/src/providers/claude-sdk-session.ts +132 -23
  181. package/src/providers/codex-skill-resolver.ts +10 -4
  182. package/src/providers/cursor-adapter.ts +1 -1
  183. package/src/providers/devin-skill-resolver.ts +5 -5
  184. package/src/providers/dsh-adapter.ts +1 -1
  185. package/src/scheduler/schedule-task.ts +1 -0
  186. package/src/scripts-runtime/eval-harness.ts +14 -1
  187. package/src/scripts-runtime/executors/types.ts +3 -0
  188. package/src/scripts-runtime/sdk-allowlist.ts +1 -0
  189. package/src/scripts-runtime/swarm-sdk.ts +18 -1
  190. package/src/scripts-runtime/types/stdlib.d.ts +1 -0
  191. package/src/scripts-runtime/types/swarm-sdk.d.ts +1 -0
  192. package/src/server.ts +2 -0
  193. package/src/slack/app.ts +93 -0
  194. package/src/slack/inbound-dispatch.ts +18 -1
  195. package/src/slack/workspace-guard.ts +345 -0
  196. package/src/tasks/task-terminal-effects.ts +4 -0
  197. package/src/tasks/worker-follow-up.ts +102 -2
  198. package/src/tests/acp-adapter.test.ts +82 -0
  199. package/src/tests/apps-icon.test.ts +120 -0
  200. package/src/tests/chained-task-follow-up.test.ts +248 -0
  201. package/src/tests/check-pr-body.test.ts +40 -0
  202. package/src/tests/claude-sdk-lifecycle.test.ts +216 -1
  203. package/src/tests/claude-sdk-process.fixture.ts +57 -0
  204. package/src/tests/codex-skill-resolver.test.ts +31 -0
  205. package/src/tests/credentials-allowlist.test.ts +470 -0
  206. package/src/tests/db-task-read-contract.test.ts +5 -0
  207. package/src/tests/db-task-write-contract.test.ts +5 -0
  208. package/src/tests/deferred-wake-follow-up.test.ts +47 -0
  209. package/src/tests/docs-index-footprint.test.js +3 -3
  210. package/src/tests/dreaming-learnings.test.ts +1395 -0
  211. package/src/tests/dsh-adapter.test.ts +1 -1
  212. package/src/tests/explicit-model-validation.test.ts +2 -0
  213. package/src/tests/fs-provider.test.ts +42 -0
  214. package/src/tests/heartbeat.test.ts +28 -1
  215. package/src/tests/human-free-reclassify.test.ts +5 -1
  216. package/src/tests/list-endpoint-slimming.test.ts +17 -0
  217. package/src/tests/mcp-tools.test.ts +1 -1
  218. package/src/tests/migration-283-workflow-run-definitions.test.ts +69 -0
  219. package/src/tests/model-profile-check.test.ts +387 -0
  220. package/src/tests/model-profiles-api.test.ts +528 -1
  221. package/src/tests/profile-claim.test.ts +415 -3
  222. package/src/tests/profile-tier-alias.test.ts +382 -0
  223. package/src/tests/schedule-profile.test.ts +359 -0
  224. package/src/tests/script-connections.test.ts +6 -0
  225. package/src/tests/script-native-unawaited-drain.test.ts +167 -0
  226. package/src/tests/script-per-script-executor.test.ts +1 -0
  227. package/src/tests/scripts-sdk-bridge-tool-failure.test.ts +141 -0
  228. package/src/tests/seed-scripts.test.ts +2 -2
  229. package/src/tests/slack-inbound-receipts.test.ts +22 -2
  230. package/src/tests/slack-socket-ack.test.ts +16 -1
  231. package/src/tests/slack-workspace-guard.test.ts +905 -0
  232. package/src/tests/steering-core.test.ts +40 -0
  233. package/src/tests/store-progress-learning.test.ts +605 -20
  234. package/src/tests/tool-annotations.test.ts +1 -1
  235. package/src/tests/workflow-convergence.test.ts +46 -40
  236. package/src/tests/workflow-definition-pinning-recovery.test.ts +552 -0
  237. package/src/tests/workflow-definition-pinning.test.ts +645 -0
  238. package/src/tests/workflow-executors.test.ts +16 -7
  239. package/src/tests/workflow-foreach.test.ts +43 -20
  240. package/src/tests/workflow-notify-slack-ready.test.ts +161 -0
  241. package/src/tests/workflow-profile.test.ts +328 -0
  242. package/src/tools/app-upsert.ts +1 -1
  243. package/src/tools/memory-edit.ts +2 -1
  244. package/src/tools/model-profiles/check-model-profile.ts +63 -0
  245. package/src/tools/schedules/create-schedule.ts +45 -4
  246. package/src/tools/schedules/patch-schedule.ts +50 -4
  247. package/src/tools/schedules/update-schedule.ts +50 -4
  248. package/src/tools/script-run.ts +1 -1
  249. package/src/tools/send-task.ts +17 -2
  250. package/src/tools/store-progress.ts +15 -3
  251. package/src/tools/task-action.ts +9 -1
  252. package/src/tools/templates.ts +13 -0
  253. package/src/tools/tool-config.ts +2 -1
  254. package/src/tools/utils.ts +61 -4
  255. package/src/tools/workflows/create-workflow.ts +1 -1
  256. package/src/tools/workflows/retry-workflow-run.ts +1 -1
  257. package/src/tools/workflows/update-workflow.ts +10 -1
  258. package/src/types.ts +56 -1
  259. package/src/utils/credentials.ts +89 -12
  260. package/src/workflows/engine.ts +10 -1
  261. package/src/workflows/executors/agent-task.ts +21 -2
  262. package/src/workflows/executors/foreach.ts +4 -1
  263. package/src/workflows/executors/notify.ts +62 -6
  264. package/src/workflows/executors/sub-workflow.ts +1 -1
  265. package/src/workflows/executors/swarm-script.ts +4 -1
  266. package/src/workflows/foreach-driver.ts +8 -5
  267. package/src/workflows/limits.ts +2 -1
  268. package/src/workflows/model-validation.ts +27 -2
  269. package/src/workflows/patch-definition.ts +3 -1
  270. package/src/workflows/recovery.ts +6 -6
  271. package/src/workflows/resume.ts +9 -9
  272. package/src/workflows/retry-poller.ts +2 -2
  273. package/templates/skills/apps/SKILL.md +2 -0
  274. package/templates/skills/apps/content.md +2 -0
  275. package/templates/skills/code-quality/content.md +12 -0
  276. package/templates/skills/memory/content.md +8 -0
  277. package/templates/skills/scheduling/config.json +1 -1
  278. package/templates/skills/scheduling/content.md +2 -2
  279. package/templates/skills/swarm-docs/content.md +4 -0
  280. package/templates/skills/swarm-extensions/content.md +1 -1
  281. package/templates/skills/swarm-scripts/SKILL.md +2 -2
  282. package/templates/skills/swarm-scripts/content.md +2 -2
  283. package/templates/skills/work-on-task/SKILL.md +2 -0
  284. package/templates/skills/work-on-task/content.md +2 -0
  285. package/templates/workflows/dreaming/content.md +174 -7
  286. package/dist/acp-adapter-srfhs1s9.js +0 -16
  287. package/dist/cli-bzvs88tv.js +0 -339
  288. package/dist/cli-cyn9v8zr.js +0 -748
  289. package/dist/cli-ed6yqpf1.js +0 -779
  290. package/dist/handlers-17wha3ze.js +0 -33
  291. package/dist/heartbeat-gwewgdms.js +0 -42
  292. package/dist/index-8arwq8mw.js +0 -34
  293. package/dist/index-tpw054az.js +0 -38
  294. package/dist/index-waq75j2j.js +0 -31
  295. package/dist/lead-re73kdgc.js +0 -72
  296. package/dist/worker-r8mz7a65.js +0 -72
@@ -261,7 +261,8 @@ async function findDeferredWakeFor(taskId: string, agentId: string): Promise<Def
261
261
  * task already reviews the result, so a follow-up would duplicate it. An
262
262
  * `all` wait with siblings still pending wakes nobody, so the follow-up stays.
263
263
  * A `followUpConfig.onCompleted` / `onFailed` instruction for this status also
264
- * keeps the follow-up, because the wake-up task does not carry that text.
264
+ * keeps the follow-up, because the wake-up task does not carry that text. A
265
+ * rejected `chainedTaskId` keeps it for the same reason.
265
266
  *
266
267
  * With `FOLLOW_UP_GATE_MODE=shadow`, a gated scheduled run also records a
267
268
  * verifier's would-skip decision after commit; the follow-up is never skipped.
@@ -271,6 +272,13 @@ export async function createWorkerTaskFollowUp(args: {
271
272
  status: "completed" | "failed";
272
273
  output?: string;
273
274
  failureReason?: string;
275
+ /**
276
+ * `store-progress` `chainedTaskId`: a live child task the completing agent
277
+ * created to carry this result forward. Honoured only on `completed`.
278
+ */
279
+ chainedTaskId?: string;
280
+ /** Agent that made the completing call; defaults to the task's assignee. */
281
+ completingAgentId?: string;
274
282
  }): Promise<AgentTask | null> {
275
283
  const { task, status, output, failureReason } = args;
276
284
 
@@ -295,6 +303,37 @@ export async function createWorkerTaskFollowUp(args: {
295
303
  return null;
296
304
  }
297
305
 
306
+ // Failures always wake the Lead, so only a completion can hand off to a child.
307
+ let chainRejection: (ChainedTaskCheck & { ok: false }) | null = null;
308
+ if (status === "completed" && args.chainedTaskId) {
309
+ const chain = await checkChainedTask(
310
+ task,
311
+ args.chainedTaskId,
312
+ args.completingAgentId ?? task.agentId ?? "",
313
+ );
314
+ if (chain.ok) {
315
+ try {
316
+ await createLogEntry({
317
+ eventType: "task_follow_up_suppressed",
318
+ taskId: task.id,
319
+ agentId: leadAgent.id,
320
+ metadata: {
321
+ reason: "chained_task_live",
322
+ status,
323
+ chainedTaskId: chain.child.id,
324
+ chainedTaskStatus: chain.child.status,
325
+ ...(task.followUpConfig?.onCompleted ? { droppedOnCompleted: true } : {}),
326
+ },
327
+ });
328
+ } catch {}
329
+ console.log(
330
+ `[worker-follow-up] Skipped follow-up for completed task ${task.id.slice(0, 8)}: work continues in chained task ${chain.child.id.slice(0, 8)} (${chain.child.status})`,
331
+ );
332
+ return null;
333
+ }
334
+ chainRejection = chain;
335
+ }
336
+
298
337
  const agentName = taskAgent.name || task.agentId?.slice(0, 8) || "Unknown";
299
338
  const taskDesc = task.task.slice(0, 200);
300
339
  const creatorAgent = task.creatorAgentId
@@ -323,6 +362,12 @@ export async function createWorkerTaskFollowUp(args: {
323
362
  task_id: task.id,
324
363
  });
325
364
  followUpDescription = completedResult.text;
365
+ if (chainRejection) {
366
+ followUpDescription += resolveTemplate("task.worker.chain_rejected", {
367
+ chained_task_id: chainRejection.chainedTaskId,
368
+ reason: chainRejection.reason,
369
+ }).text;
370
+ }
326
371
  } else {
327
372
  const reason = failureReason || "(no reason given)";
328
373
  const failedResult = resolveTemplate("task.worker.failed", {
@@ -374,8 +419,12 @@ export async function createWorkerTaskFollowUp(args: {
374
419
  const changes = preFollowUp.action === "modify" ? preFollowUp.data : {};
375
420
  const followUpAgentId = changes.agentId === undefined ? leadAgent.id : changes.agentId;
376
421
 
422
+ // Like `instructions`, a rejected chainedTaskId keeps the follow-up: the
423
+ // wake-up task does not carry the rejected id or the reason.
377
424
  const wake =
378
- followUpAgentId && !instructions ? await findDeferredWakeFor(task.id, followUpAgentId) : null;
425
+ followUpAgentId && !instructions && !chainRejection
426
+ ? await findDeferredWakeFor(task.id, followUpAgentId)
427
+ : null;
379
428
  if (wake) {
380
429
  try {
381
430
  await createLogEntry({
@@ -435,6 +484,57 @@ export async function createWorkerTaskFollowUp(args: {
435
484
  return followUp;
436
485
  }
437
486
 
487
+ /**
488
+ * Child statuses that mean the chained work is still going to run. `reviewing`
489
+ * is the accept/reject step of an offer, and a `paused` task keeps its agent
490
+ * and resumes when that worker restarts.
491
+ */
492
+ const LIVE_CHAINED_TASK_STATUSES: ReadonlySet<AgentTask["status"]> = new Set([
493
+ "offered",
494
+ "reviewing",
495
+ "pending",
496
+ "in_progress",
497
+ "paused",
498
+ ]);
499
+
500
+ type ChainedTaskCheck =
501
+ | { ok: true; child: AgentTask }
502
+ | { ok: false; chainedTaskId: string; reason: string };
503
+
504
+ /**
505
+ * Whether `chainedTaskId` may stand in for the Lead follow-up of `task`: it
506
+ * must be a live direct child of `task`, created by the completing agent.
507
+ */
508
+ async function checkChainedTask(
509
+ task: AgentTask,
510
+ chainedTaskId: string,
511
+ completingAgentId: string,
512
+ ): Promise<ChainedTaskCheck> {
513
+ const reject = (reason: string): ChainedTaskCheck => ({ ok: false, chainedTaskId, reason });
514
+ let child: AgentTask | null;
515
+ try {
516
+ child = await getTaskById(chainedTaskId);
517
+ } catch (err) {
518
+ // Fail open: a broken lookup must never drop the follow-up.
519
+ return reject(`lookup failed (${err instanceof Error ? err.message : String(err)})`);
520
+ }
521
+ if (!child) return reject("no task has this id");
522
+ if (child.parentTaskId !== task.id) {
523
+ return reject(
524
+ child.parentTaskId
525
+ ? `its parentTaskId is ${child.parentTaskId}, not this task`
526
+ : "it has no parentTaskId",
527
+ );
528
+ }
529
+ if (!completingAgentId || child.creatorAgentId !== completingAgentId) {
530
+ return reject("it was not created by the agent that completed this task");
531
+ }
532
+ if (!LIVE_CHAINED_TASK_STATUSES.has(child.status)) {
533
+ return reject(`it is ${child.status}, not live`);
534
+ }
535
+ return { ok: true, child };
536
+ }
537
+
438
538
  /** Hop cap for `deferredWorkChatContextKey`; a defer/resume chain is short. */
439
539
  const MAX_CONTINUATION_HOPS = 32;
440
540
 
@@ -1047,6 +1047,88 @@ ${serveFakeAcpAgent("FakeCopilot")}
1047
1047
  expect(env.AGENT_MODEL).toBe("custom-model");
1048
1048
  });
1049
1049
 
1050
+ test.each([
1051
+ ["number", 1],
1052
+ ["boolean", false],
1053
+ ["null", null],
1054
+ ["object", { key: "ALLOWED_TOKEN" }],
1055
+ ["nested array", ["ALLOWED_TOKEN"]],
1056
+ ])("custom target rejects a JSON env-key array containing a %s", (_name, entry) => {
1057
+ const config = baseConfig({
1058
+ env: {
1059
+ ACP_TARGET_ENV_KEYS: JSON.stringify(["ALLOWED_TOKEN", entry]),
1060
+ ALLOWED_TOKEN: "allowed",
1061
+ },
1062
+ });
1063
+ const resolveEnv = () => resolveAcpTarget(config).env(config);
1064
+
1065
+ expect(resolveEnv).toThrow(AcpTargetResolutionError);
1066
+ expect(resolveEnv).toThrow("ACP_TARGET_ENV_KEYS");
1067
+ });
1068
+
1069
+ test("custom target preserves literal keys in an all-string JSON env-key array", () => {
1070
+ const config = baseConfig({
1071
+ env: {
1072
+ ACP_TARGET_ENV_KEYS: JSON.stringify(["ALLOWED_TOKEN", " SPACED_KEY ", "", "ALLOWED_TOKEN"]),
1073
+ ALLOWED_TOKEN: "allowed",
1074
+ " SPACED_KEY ": "literal",
1075
+ "": "empty-key",
1076
+ BLOCKED_TOKEN: "blocked",
1077
+ },
1078
+ });
1079
+ const env = resolveAcpTarget(config).env(config);
1080
+
1081
+ expect(env.ALLOWED_TOKEN).toBe("allowed");
1082
+ expect(env[" SPACED_KEY "]).toBe("literal");
1083
+ expect(env[""]).toBe("empty-key");
1084
+ expect(env.SPACED_KEY).toBeUndefined();
1085
+ expect(env.BLOCKED_TOKEN).toBeUndefined();
1086
+ });
1087
+
1088
+ test("custom target trims comma-separated env keys and ignores empty segments", () => {
1089
+ const config = baseConfig({
1090
+ env: {
1091
+ ACP_TARGET_ENV_KEYS: " ALLOWED_TOKEN , , SECOND_TOKEN, ALLOWED_TOKEN , ",
1092
+ ALLOWED_TOKEN: "allowed",
1093
+ SECOND_TOKEN: "second",
1094
+ BLOCKED_TOKEN: "blocked",
1095
+ },
1096
+ });
1097
+ const env = resolveAcpTarget(config).env(config);
1098
+
1099
+ expect(env.ALLOWED_TOKEN).toBe("allowed");
1100
+ expect(env.SECOND_TOKEN).toBe("second");
1101
+ expect(env.BLOCKED_TOKEN).toBeUndefined();
1102
+ });
1103
+
1104
+ test.each([
1105
+ undefined,
1106
+ "",
1107
+ " ",
1108
+ "[]",
1109
+ ])("custom target forwards no extra env keys for an empty list (%j)", (value) => {
1110
+ const config = baseConfig({
1111
+ env: { ACP_TARGET_ENV_KEYS: value, ALLOWED_TOKEN: "allowed" },
1112
+ });
1113
+
1114
+ expect(resolveAcpTarget(config).env(config).ALLOWED_TOKEN).toBeUndefined();
1115
+ });
1116
+
1117
+ test.each([
1118
+ '["ALLOWED_TOKEN"',
1119
+ '"ALLOWED_TOKEN"',
1120
+ "123",
1121
+ "true",
1122
+ "null",
1123
+ '{"key":"value"}',
1124
+ ])("custom target keeps the text fallback for non-array or invalid JSON (%s)", (value) => {
1125
+ const config = baseConfig({
1126
+ env: { ACP_TARGET_ENV_KEYS: value, [value]: "allowed" },
1127
+ });
1128
+
1129
+ expect(resolveAcpTarget(config).env(config)[value]).toBe("allowed");
1130
+ });
1131
+
1050
1132
  test("configured options are nonfatal when absent or rejected", async () => {
1051
1133
  const advertised = [
1052
1134
  {
@@ -0,0 +1,120 @@
1
+ import { afterAll, beforeAll, describe, expect, test } from "bun:test";
2
+ import { unlink } from "node:fs/promises";
3
+ import { parseAppDefinition } from "../apps/definition";
4
+ import { createApp, getApp, listApps, updateApp } from "../apps/store";
5
+ import { closeDb, getDbClient, initDb } from "../be/db";
6
+
7
+ const TEST_DB_PATH = `/private/tmp/test-apps-icon-${process.pid}.sqlite`;
8
+
9
+ const baseDefinition = {
10
+ models: {},
11
+ queries: {},
12
+ actions: {},
13
+ pages: {
14
+ main: {
15
+ title: "Main",
16
+ root: "root",
17
+ elements: { root: { type: "Stack", props: {}, children: [] } },
18
+ },
19
+ },
20
+ defaultPage: "main",
21
+ };
22
+
23
+ async function createWithIcon(name: string, icon: unknown) {
24
+ const parsed = await parseAppDefinition(baseDefinition, { writerIsUser: true });
25
+ if (!parsed.success) throw new Error(JSON.stringify(parsed.issues));
26
+ const app = await createApp({ name, definition: parsed.definition });
27
+ if (icon !== undefined) {
28
+ // Write the raw column so malformed stored icons (hand edits, old data) can be exercised.
29
+ const stored = { ...parsed.definition, icon };
30
+ await getDbClient().run("UPDATE apps SET definition = ? WHERE id = ?", [
31
+ JSON.stringify(stored),
32
+ app.id,
33
+ ]);
34
+ }
35
+ return app.id;
36
+ }
37
+
38
+ beforeAll(() => {
39
+ initDb(TEST_DB_PATH);
40
+ });
41
+
42
+ afterAll(async () => {
43
+ closeDb();
44
+ for (const suffix of ["", "-wal", "-shm"])
45
+ await unlink(`${TEST_DB_PATH}${suffix}`).catch(() => {});
46
+ });
47
+
48
+ describe("app icon", () => {
49
+ test("definition accepts a lucide icon and rejects a malformed one", async () => {
50
+ const icon = { type: "lucide", icon: "layout-grid", color: "#f59e0b" };
51
+ expect((await parseAppDefinition({ ...baseDefinition, icon })).success).toBe(true);
52
+ expect(
53
+ (await parseAppDefinition({ ...baseDefinition, icon: { type: "lucide", icon: "Not Valid" } }))
54
+ .success,
55
+ ).toBe(false);
56
+ expect(
57
+ (
58
+ await parseAppDefinition({
59
+ ...baseDefinition,
60
+ icon: { type: "lucide", icon: "star", color: "red" },
61
+ })
62
+ ).success,
63
+ ).toBe(false);
64
+ });
65
+
66
+ test('suggests "icon" for avatar and emoji top-level keys', async () => {
67
+ for (const key of ["avatar", "emoji"]) {
68
+ const parsed = await parseAppDefinition({ ...baseDefinition, [key]: "x" });
69
+ expect(parsed.success).toBe(false);
70
+ if (!parsed.success) {
71
+ expect(parsed.issues.some((issue) => issue.message.includes('did you mean "icon"'))).toBe(
72
+ true,
73
+ );
74
+ }
75
+ }
76
+ });
77
+
78
+ test("an icon written through the normal create and update path survives to listApps", async () => {
79
+ const icon = { type: "lucide", icon: "layout-grid", color: "#f59e0b" };
80
+ const parsed = await parseAppDefinition({ ...baseDefinition, icon }, { writerIsUser: true });
81
+ if (!parsed.success) throw new Error(JSON.stringify(parsed.issues));
82
+ const app = await createApp({ name: "Round trip", definition: parsed.definition });
83
+
84
+ expect((await listApps()).find((summary) => summary.id === app.id)?.icon).toEqual(icon);
85
+ expect((await getApp(app.id))?.definition.icon).toEqual(icon);
86
+
87
+ const nextIcon = { type: "lucide", icon: "star" };
88
+ const reparsed = await parseAppDefinition(
89
+ { ...baseDefinition, icon: nextIcon },
90
+ { writerIsUser: true },
91
+ );
92
+ if (!reparsed.success) throw new Error(JSON.stringify(reparsed.issues));
93
+ await updateApp(app.id, { definition: reparsed.definition });
94
+
95
+ expect((await listApps()).find((summary) => summary.id === app.id)?.icon).toEqual(nextIcon);
96
+ });
97
+
98
+ test("listApps projects a valid icon and omits it when absent or invalid", async () => {
99
+ const icon = { type: "lucide", icon: "layout-grid", color: "#f59e0b" };
100
+ const withIcon = await createWithIcon("With icon", icon);
101
+ const withoutIcon = await createWithIcon("Without icon", undefined);
102
+ const badShape = await createWithIcon("Bad shape", { type: "lucide", icon: "Not Valid" });
103
+ const wrongType = await createWithIcon("Wrong type", "star");
104
+
105
+ const byId = new Map((await listApps()).map((app) => [app.id, app]));
106
+ expect(byId.get(withIcon)?.icon).toEqual(icon);
107
+ for (const id of [withoutIcon, badShape, wrongType]) {
108
+ const summary = byId.get(id);
109
+ expect(summary).toBeDefined();
110
+ expect(summary && "icon" in summary).toBe(false);
111
+ }
112
+ });
113
+
114
+ test("an unknown but well-formed icon name is passed through for the dashboard to fall back on", async () => {
115
+ const icon = { type: "lucide", icon: "no-such-icon" };
116
+ const id = await createWithIcon("Unknown icon", icon);
117
+ const summary = (await listApps()).find((app) => app.id === id);
118
+ expect(summary?.icon).toEqual(icon);
119
+ });
120
+ });
@@ -0,0 +1,248 @@
1
+ import { afterAll, beforeAll, describe, expect, test } from "bun:test";
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import {
4
+ cancelTask,
5
+ closeDb,
6
+ completeTask,
7
+ createAgent,
8
+ createTaskExtended,
9
+ getDbClient,
10
+ getLogsByTaskIdAndEventType,
11
+ initDb,
12
+ pauseTask,
13
+ startTask,
14
+ } from "../be/db";
15
+ import { registerStoreProgressTool } from "../tools/store-progress";
16
+ import type { CreateTaskOptions } from "../types";
17
+
18
+ type StoreProgressResult = { structuredContent: { success: boolean; message: string } };
19
+ type RegisteredTool = { handler: (args: unknown, extra: unknown) => Promise<unknown> };
20
+
21
+ let leadId: string;
22
+ let workerId: string;
23
+ let otherWorkerId: string;
24
+ let storeProgress: RegisteredTool;
25
+
26
+ beforeAll(async () => {
27
+ initDb(":memory:");
28
+ leadId = (
29
+ await createAgent({
30
+ name: "Lead",
31
+ isLead: true,
32
+ status: "busy",
33
+ capabilities: [],
34
+ maxTasks: 50,
35
+ })
36
+ ).id;
37
+ workerId = (
38
+ await createAgent({ name: "Reviewer", status: "busy", capabilities: [], maxTasks: 50 })
39
+ ).id;
40
+ otherWorkerId = (
41
+ await createAgent({ name: "Coder", status: "busy", capabilities: [], maxTasks: 50 })
42
+ ).id;
43
+ const server = new McpServer({ name: "chained-follow-up-test", version: "1.0.0" });
44
+ registerStoreProgressTool(server);
45
+ storeProgress = (server as unknown as { _registeredTools: Record<string, RegisteredTool> })
46
+ ._registeredTools["store-progress"]!;
47
+ });
48
+ afterAll(() => closeDb());
49
+
50
+ type FollowUpRow = { id: string; task: string; slackChannelId: string | null };
51
+
52
+ function followUps(parentTaskId: string): Promise<FollowUpRow[]> {
53
+ return getDbClient().query<FollowUpRow>(
54
+ "SELECT id, task, slackChannelId FROM agent_tasks WHERE parentTaskId = ? AND taskType = 'follow-up'",
55
+ [parentTaskId],
56
+ );
57
+ }
58
+
59
+ /** A started worker task, as the Reviewer holds it mid-review. */
60
+ async function reviewTask(options: CreateTaskOptions = {}) {
61
+ const task = await createTaskExtended("Review PR #1", {
62
+ agentId: workerId,
63
+ creatorAgentId: leadId,
64
+ ...options,
65
+ });
66
+ await startTask(task.id);
67
+ return task;
68
+ }
69
+
70
+ /** The fix task the Reviewer chains from its review. */
71
+ function chainChild(parentTaskId: string, options: CreateTaskOptions = {}) {
72
+ return createTaskExtended("Fix the review blockers", {
73
+ agentId: otherWorkerId,
74
+ creatorAgentId: workerId,
75
+ parentTaskId,
76
+ followUpConfig: { disabled: true },
77
+ ...options,
78
+ });
79
+ }
80
+
81
+ async function finish(
82
+ taskId: string,
83
+ args: { status?: "completed" | "failed" | "skipped"; chainedTaskId?: string },
84
+ ) {
85
+ const status = args.status ?? "completed";
86
+ const result = (await storeProgress.handler(
87
+ {
88
+ taskId,
89
+ status,
90
+ ...(status === "completed" ? { output: "CHAINED: fix task" } : { failureReason: "boom" }),
91
+ ...(args.chainedTaskId ? { chainedTaskId: args.chainedTaskId } : {}),
92
+ },
93
+ {
94
+ sessionId: `session-${crypto.randomUUID()}`,
95
+ requestInfo: { headers: { "x-agent-id": workerId } },
96
+ },
97
+ )) as StoreProgressResult;
98
+ // The completion itself never fails because of chainedTaskId.
99
+ expect(result.structuredContent.success).toBe(true);
100
+ }
101
+
102
+ async function suppressions(taskId: string) {
103
+ return (await getLogsByTaskIdAndEventType(taskId, "task_follow_up_suppressed")).map(
104
+ (log) => JSON.parse(log.metadata ?? "{}") as Record<string, unknown>,
105
+ );
106
+ }
107
+
108
+ describe("store-progress chainedTaskId", () => {
109
+ test("a live chained child suppresses the follow-up and logs the handoff", async () => {
110
+ const task = await reviewTask({ followUpConfig: { onCompleted: "CHAINED => no action" } });
111
+ const child = await chainChild(task.id);
112
+
113
+ await finish(task.id, { chainedTaskId: child.id });
114
+
115
+ expect(await followUps(task.id)).toHaveLength(0);
116
+ expect(await suppressions(task.id)).toEqual([
117
+ {
118
+ reason: "chained_task_live",
119
+ status: "completed",
120
+ chainedTaskId: child.id,
121
+ chainedTaskStatus: "pending",
122
+ droppedOnCompleted: true,
123
+ },
124
+ ]);
125
+ });
126
+
127
+ test("in_progress and paused children count as live", async () => {
128
+ for (const settle of [startTask, async (id: string) => pauseTask((await startTask(id))!.id)]) {
129
+ const task = await reviewTask();
130
+ const child = await chainChild(task.id);
131
+ await settle(child.id);
132
+
133
+ await finish(task.id, { chainedTaskId: child.id });
134
+
135
+ expect(await followUps(task.id)).toHaveLength(0);
136
+ }
137
+ });
138
+
139
+ test.each([
140
+ ["completed", (id: string) => completeTask(id, "done"), "it is completed, not live"],
141
+ ["cancelled", (id: string) => cancelTask(id, "stop"), "it is cancelled, not live"],
142
+ ] as const)("a %s child creates the follow-up naming the reason", async (_, settle, reason) => {
143
+ const task = await reviewTask();
144
+ const child = await chainChild(task.id);
145
+ await settle(child.id);
146
+
147
+ await finish(task.id, { chainedTaskId: child.id });
148
+
149
+ const [followUp, ...rest] = await followUps(task.id);
150
+ expect(rest).toHaveLength(0);
151
+ expect(followUp!.task).toContain(`chainedTaskId ${child.id}`);
152
+ expect(followUp!.task).toContain(reason);
153
+ expect(await suppressions(task.id)).toHaveLength(0);
154
+ });
155
+
156
+ test("a child with another parent creates the follow-up", async () => {
157
+ const task = await reviewTask();
158
+ const otherParent = await reviewTask();
159
+ const child = await chainChild(otherParent.id);
160
+
161
+ await finish(task.id, { chainedTaskId: child.id });
162
+
163
+ const [followUp] = await followUps(task.id);
164
+ expect(followUp!.task).toContain(`its parentTaskId is ${otherParent.id}, not this task`);
165
+ });
166
+
167
+ test("a child created by another agent creates the follow-up", async () => {
168
+ const task = await reviewTask();
169
+ const child = await chainChild(task.id, { creatorAgentId: leadId });
170
+
171
+ await finish(task.id, { chainedTaskId: child.id });
172
+
173
+ const [followUp] = await followUps(task.id);
174
+ expect(followUp!.task).toContain("not created by the agent that completed this task");
175
+ });
176
+
177
+ test("an unknown id creates the follow-up", async () => {
178
+ const task = await reviewTask();
179
+ const missing = crypto.randomUUID();
180
+
181
+ await finish(task.id, { chainedTaskId: missing });
182
+
183
+ const [followUp] = await followUps(task.id);
184
+ expect(followUp!.task).toContain(`chainedTaskId ${missing}`);
185
+ expect(followUp!.task).toContain("no task has this id");
186
+ });
187
+
188
+ test("a failed completion ignores chainedTaskId and wakes the lead", async () => {
189
+ const task = await reviewTask();
190
+ const child = await chainChild(task.id);
191
+
192
+ await finish(task.id, { status: "failed", chainedTaskId: child.id });
193
+
194
+ const [followUp, ...rest] = await followUps(task.id);
195
+ expect(rest).toHaveLength(0);
196
+ expect(followUp!.task).not.toContain("chainedTaskId");
197
+ expect(await suppressions(task.id)).toHaveLength(0);
198
+ });
199
+
200
+ test("a skipped completion ignores chainedTaskId", async () => {
201
+ const task = await reviewTask();
202
+ const child = await chainChild(task.id);
203
+
204
+ await finish(task.id, { status: "skipped", chainedTaskId: child.id });
205
+
206
+ expect(await followUps(task.id)).toHaveLength(0);
207
+ expect(await suppressions(task.id)).toHaveLength(0);
208
+ });
209
+
210
+ test("followUpConfig.disabled still disables, with or without a valid chain", async () => {
211
+ for (const chained of [false, true]) {
212
+ const task = await reviewTask({ followUpConfig: { disabled: true } });
213
+ const child = await chainChild(task.id);
214
+
215
+ await finish(task.id, chained ? { chainedTaskId: child.id } : {});
216
+
217
+ expect(await followUps(task.id)).toHaveLength(0);
218
+ expect(await suppressions(task.id)).toHaveLength(0);
219
+ }
220
+ });
221
+
222
+ test("without chainedTaskId the follow-up is unchanged", async () => {
223
+ const task = await reviewTask();
224
+ await chainChild(task.id);
225
+
226
+ await finish(task.id, {});
227
+
228
+ const [followUp] = await followUps(task.id);
229
+ expect(followUp!.task).not.toContain("chainedTaskId");
230
+ });
231
+
232
+ test("a Slack-sourced task with a suppressed follow-up creates nothing in the thread", async () => {
233
+ const slack = { slackChannelId: "C_TEST", slackThreadTs: "1700000000.000100" };
234
+ const task = await reviewTask({ source: "slack", ...slack });
235
+ const child = await chainChild(task.id);
236
+
237
+ await finish(task.id, { chainedTaskId: child.id });
238
+
239
+ expect(await followUps(task.id)).toHaveLength(0);
240
+ // Only the review and its chained child live in the thread: no Lead
241
+ // follow-up exists to reply there or post an outcome card.
242
+ const inThread = await getDbClient().query<{ id: string }>(
243
+ "SELECT id FROM agent_tasks WHERE slackChannelId = ? AND slackThreadTs = ?",
244
+ [slack.slackChannelId, slack.slackThreadTs],
245
+ );
246
+ expect(inThread.map((row) => row.id).sort()).toEqual([task.id, child.id].sort());
247
+ });
248
+ });
@@ -1,4 +1,7 @@
1
1
  import { describe, expect, test } from "bun:test";
2
+ import { mkdtemp, rm } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
2
5
  import {
3
6
  checkPrBody,
4
7
  isFixTitle,
@@ -9,6 +12,7 @@ import {
9
12
  templateLeadLines,
10
13
  templateSections,
11
14
  } from "../../scripts/check-pr-body";
15
+ import { runChild } from "./test-proc";
12
16
 
13
17
  const TEMPLATE = `<!-- top comment -->
14
18
 
@@ -246,3 +250,39 @@ describe("check-pr-body: prose budget", () => {
246
250
  expect(prBodyWarnings("word ".repeat(301))).toHaveLength(1);
247
251
  });
248
252
  });
253
+
254
+ describe("check-pr-body: PR_TEMPLATE_PATH", () => {
255
+ // The org-wide check (desplega-ai/.github) runs this script against another
256
+ // repo's template or the org default, so the CLI must honor the override.
257
+ test("the CLI checks the body against the template the env names", async () => {
258
+ const dir = await mkdtemp(join(tmpdir(), "pr-body-template-"));
259
+ try {
260
+ const templatePath = join(dir, "template.md");
261
+ const bodyPath = join(dir, "body.md");
262
+ await Bun.write(templatePath, "## Only section\n\n<!-- guidance -->\n");
263
+ await Bun.write(bodyPath, "## Only section\n\nFilled.\n");
264
+ const run = (env: Record<string, string>) =>
265
+ runChild(["bun", "scripts/check-pr-body.ts", "--body-file", bodyPath], {
266
+ env: {
267
+ PATH: process.env.PATH,
268
+ HOME: process.env.HOME,
269
+ PR_TITLE: "chore: x",
270
+ PR_AUTHOR: "someone",
271
+ PR_CHANGED_FILES_FILE: bodyPath,
272
+ ...env,
273
+ },
274
+ });
275
+
276
+ const custom = await run({ PR_TEMPLATE_PATH: templatePath });
277
+ expect(custom.stderr).not.toContain("does not match");
278
+ expect(custom.exitCode).toBe(0);
279
+
280
+ // Control: without the override, the repo template applies and this body fails it.
281
+ const repoDefault = await run({});
282
+ expect(repoDefault.exitCode).toBe(1);
283
+ expect(repoDefault.stderr).toContain("does not match .github/pull_request_template.md");
284
+ } finally {
285
+ await rm(dir, { recursive: true, force: true });
286
+ }
287
+ });
288
+ });