@desplega.ai/agent-swarm 2.13.4 → 2.13.5

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 (307) hide show
  1. package/dist/acp-adapter-tbt61zkm.js +17 -0
  2. package/dist/{acp-targets-zrk9k0n7.js → acp-targets-w8dbs4nr.js} +7 -7
  3. package/dist/{actions-acqqj9jn.js → actions-8zrcbjrx.js} +26 -26
  4. package/dist/{agent-fs-provision-zmaykqnd.js → agent-fs-provision-cbt2ttds.js} +4 -4
  5. package/dist/{amp-adapter-a7ts8tmw.js → amp-adapter-8x6zp8w4.js} +2 -2
  6. package/dist/{anthropic-messages-88b7s3n9.js → anthropic-messages-vdd1zmha.js} +10 -10
  7. package/dist/{app-tmwa442h.js → app-zfa9dwjw.js} +6 -6
  8. package/dist/{approval-notifications-6psaaaye.js → approval-notifications-rv92zmza.js} +7 -7
  9. package/dist/{assistant-564v6emv.js → assistant-q7s7rm1q.js} +24 -24
  10. package/dist/{boot-args-schema-n099e0f2.js → boot-args-schema-g27kpzr1.js} +1 -1
  11. package/dist/{boot-reembed-epvg4fp9.js → boot-reembed-1mjs52nt.js} +1 -1
  12. package/dist/{boot-reembed-chx66qfk.js → boot-reembed-m62dpdkg.js} +1 -1
  13. package/dist/{boot-scrub-sweep-dhkfp0a7.js → boot-scrub-sweep-ss1vcamw.js} +2 -2
  14. package/dist/{boot-seeds-m74fc07r.js → boot-seeds-hwnvgbb3.js} +4 -4
  15. package/dist/{boxd-451q55ys.js → boxd-y0szhp0g.js} +1 -1
  16. package/dist/{claude-adapter-hw63yj3j.js → claude-adapter-0rjmbhjk.js} +7 -7
  17. package/dist/{claude-managed-adapter-z5s7fx6p.js → claude-managed-adapter-6k032agg.js} +3 -3
  18. package/dist/{claude-managed-setup-wee1762m.js → claude-managed-setup-6czvve8q.js} +4 -4
  19. package/dist/{claude-sdk-session-cktyqkpk.js → claude-sdk-session-pr0znb81.js} +12667 -11881
  20. package/dist/{cli-0fgvnb0x.js → cli-0qt3epg4.js} +3 -3
  21. package/dist/{cli-ka48vpev.js → cli-19d6v8er.js} +3 -3
  22. package/dist/{cli-zexwhj3f.js → cli-1jq2em7b.js} +3 -3
  23. package/dist/{cli-5rgm8p39.js → cli-2wzkvfgm.js} +2 -2
  24. package/dist/{cli-x2cem5vy.js → cli-34fygf87.js} +2 -2
  25. package/dist/{cli-tsc3pdfd.js → cli-3860pmrq.js} +3 -3
  26. package/dist/{cli-hhtbandk.js → cli-3vw6dd4g.js} +2 -2
  27. package/dist/{cli-qzz6tz8s.js → cli-4gaf3tx5.js} +1 -1
  28. package/dist/{cli-9ah37a8a.js → cli-55h8m1x3.js} +8 -5
  29. package/dist/{cli-7gbff32z.js → cli-5n9w2xzx.js} +1 -1
  30. package/dist/{cli-p436yrzp.js → cli-5tq15aa7.js} +1 -1
  31. package/dist/{cli-jyhbvdga.js → cli-5web09sb.js} +2 -2
  32. package/dist/{cli-3zrwrnz7.js → cli-69zzpjgh.js} +1 -1
  33. package/dist/{cli-7g3fg4gf.js → cli-6msnpj1z.js} +6 -6
  34. package/dist/{cli-azj9t1f9.js → cli-7r9tvk8v.js} +41 -3
  35. package/dist/{cli-4fpa0zns.js → cli-7ypg8hka.js} +3 -3
  36. package/dist/{cli-8cas2xvp.js → cli-887vhew6.js} +2 -2
  37. package/dist/{cli-t0jmkcah.js → cli-8pd1t17c.js} +7 -7
  38. package/dist/{cli-h9d3sdnc.js → cli-94mxerrp.js} +1 -1
  39. package/dist/{cli-bv4vvnmg.js → cli-9n6g14vs.js} +2 -2
  40. package/dist/{cli-5ashycw3.js → cli-abby987g.js} +2 -2
  41. package/dist/{cli-kj84fqxz.js → cli-avax5mp9.js} +1 -1
  42. package/dist/{cli-ea7nz50q.js → cli-b42yfn17.js} +11 -11
  43. package/dist/{cli-ysv0k1we.js → cli-b9ygp1kz.js} +1 -1
  44. package/dist/{cli-3bxrrh53.js → cli-bvamr9g0.js} +2 -2
  45. package/dist/{cli-gse7bp3z.js → cli-ced4azn1.js} +10 -9
  46. package/dist/{cli-7by7vp6m.js → cli-cmbb2t8a.js} +2 -2
  47. package/dist/{cli-0p76my9q.js → cli-cp163xga.js} +10 -10
  48. package/dist/{cli-jzerrzgc.js → cli-ebpq3c5z.js} +8 -8
  49. package/dist/{cli-p3knvk62.js → cli-ehg90jd1.js} +113 -39
  50. package/dist/{cli-jg5txpm6.js → cli-emdfd8fh.js} +75 -1
  51. package/dist/{cli-d5pc8ep0.js → cli-evy3egte.js} +7 -7
  52. package/dist/{cli-60dwk8tx.js → cli-ewk3sg68.js} +2 -2
  53. package/dist/{cli-nc4pbwmp.js → cli-f7b9nyvk.js} +4 -4
  54. package/dist/{cli-29h5239w.js → cli-f9xw9pr4.js} +4 -4
  55. package/dist/{cli-3tzmh38q.js → cli-ffn0a515.js} +7 -7
  56. package/dist/{cli-dqgnbnxs.js → cli-grbngev5.js} +6 -1
  57. package/dist/{cli-cq4am6vg.js → cli-hd5bm1e1.js} +4 -4
  58. package/dist/{cli-akm6y2a8.js → cli-htb5bpz2.js} +1 -1
  59. package/dist/{cli-tr19nyn9.js → cli-j69pzrrz.js} +6 -6
  60. package/dist/{cli-hdhpdrka.js → cli-jdq3jmny.js} +3 -3
  61. package/dist/{cli-ja450998.js → cli-ks06cd0n.js} +1 -1
  62. package/dist/{cli-pz1dp12c.js → cli-kwj3131p.js} +1 -1
  63. package/dist/{cli-1vmhnncj.js → cli-m8f4379k.js} +3 -3
  64. package/dist/{cli-jbrc98qb.js → cli-n79j1vxc.js} +2 -2
  65. package/dist/{cli-b768ek79.js → cli-nrt048ys.js} +1 -0
  66. package/dist/{cli-93n305hm.js → cli-pedm2kht.js} +1 -1
  67. package/dist/{cli-eds5xnsz.js → cli-phmy14hb.js} +2 -2
  68. package/dist/{cli-n1kjs58m.js → cli-prz1p3ft.js} +3 -3
  69. package/dist/{cli-pz1nq5xm.js → cli-q1h041y8.js} +3 -3
  70. package/dist/{cli-cah298e5.js → cli-q41qar56.js} +104 -119
  71. package/dist/{cli-4pbwg7sn.js → cli-qmx8bnt4.js} +1 -1
  72. package/dist/{cli-944w9wb4.js → cli-qrvk9nka.js} +18 -13
  73. package/dist/{cli-gtj12v95.js → cli-r3dxpmyt.js} +1 -1
  74. package/dist/{cli-phdzn699.js → cli-ryem5cfq.js} +7 -7
  75. package/dist/{cli-49aq3cyn.js → cli-s8dhq7rj.js} +4 -4
  76. package/dist/{cli-fkpnx3vf.js → cli-sejvnjvw.js} +3 -2
  77. package/dist/{cli-m1sns1da.js → cli-srre41gb.js} +2 -2
  78. package/dist/{cli-5rxsb3wq.js → cli-t0n9svkb.js} +3 -3
  79. package/dist/{cli-tzw1jr2t.js → cli-t879ww0y.js} +2 -2
  80. package/dist/{cli-xwsm6xkr.js → cli-tgc1kgg3.js} +1 -1
  81. package/dist/{cli-404am6f3.js → cli-tt7dkwjj.js} +6 -6
  82. package/dist/{cli-zjdhrzm0.js → cli-tvyt8w6n.js} +2 -2
  83. package/dist/{cli-hyqksecw.js → cli-v09eza21.js} +9 -9
  84. package/dist/{cli-rv3y60bt.js → cli-vbge4rsp.js} +4 -4
  85. package/dist/{cli-bzcwwebm.js → cli-vcpyttcw.js} +1 -1
  86. package/dist/{cli-904wk98s.js → cli-wzecestt.js} +338 -98
  87. package/dist/{cli-gkv0r2hq.js → cli-x2adbg4j.js} +70 -8
  88. package/dist/{cli-4q2c8rxw.js → cli-z3x7h79n.js} +12 -6
  89. package/dist/{cli-s33bzmk0.js → cli-z40t85ms.js} +1 -1
  90. package/dist/{cli-rmgvwcmy.js → cli-zbbtp02a.js} +98 -21
  91. package/dist/{cli-3xqad83h.js → cli-zntvmqmm.js} +1 -1
  92. package/dist/{cli-zhwjdhjr.js → cli-zxa1vmx7.js} +1 -1
  93. package/dist/{cli-50wa8k4h.js → cli-zy9bb22b.js} +1 -2
  94. package/dist/{cli-ts5yv7dn.js → cli-zzq96q57.js} +123 -33
  95. package/dist/cli.js +18 -18
  96. package/dist/{codex-adapter-2fs2c0n6.js → codex-adapter-bn7eaxk5.js} +6 -6
  97. package/dist/{codex-hook-jxjv6dy5.js → codex-hook-nnmezjg9.js} +2 -2
  98. package/dist/{codex-session-runner-r55tmx4c.js → codex-session-runner-j1e9hffc.js} +6 -6
  99. package/dist/{commands-0mxdy9x8.js → commands-amhpafrr.js} +3 -3
  100. package/dist/{controller-g3vkfhr4.js → controller-tw7g10j2.js} +3 -3
  101. package/dist/{controllers-connect-4wdmncqt.js → controllers-connect-2ssqz7f4.js} +23 -23
  102. package/dist/{core-gsvj5f3z.js → core-bwp98v4w.js} +21 -21
  103. package/dist/{cursor-adapter-t9qb96q2.js → cursor-adapter-d6knjmwa.js} +1 -1
  104. package/dist/{db-487vvyv9.js → db-fd6xxm77.js} +3 -3
  105. package/dist/{db-76p7w3gr.js → db-sc59379z.js} +2 -2
  106. package/dist/{dispatcher-64rp6w67.js → dispatcher-a2gdqz8c.js} +21 -21
  107. package/dist/{dsh-adapter-8abzqk5c.js → dsh-adapter-43ygwqn7.js} +1 -1
  108. package/dist/{e2b-dc8f6ctq.js → e2b-cn7cvjqy.js} +1 -1
  109. package/dist/{e2b-3ykbe805.js → e2b-qnxyfea6.js} +1 -1
  110. package/dist/{easter-egg-3d-jrrwyf55.js → easter-egg-3d-a0pphy71.js} +1 -1
  111. package/dist/{embedding-space-001hhhpk.js → embedding-space-qepzrach.js} +6 -6
  112. package/dist/{embeddings-esj19cnw.js → embeddings-d7vr881x.js} +1 -1
  113. package/dist/{execute-301hkxqg.js → execute-6afts2bn.js} +1 -1
  114. package/dist/{external-channel-w10e2j05.js → external-channel-881zq1x4.js} +2 -2
  115. package/dist/fx-adapter-cr2hq17y.js +20 -0
  116. package/dist/{grok-adapter-3a0ezfee.js → grok-adapter-ayddnbsc.js} +9 -9
  117. package/dist/handlers-7ghs84x2.js +41 -0
  118. package/dist/{heartbeat-tbrj7vhq.js → heartbeat-4c022m6a.js} +24 -24
  119. package/dist/{hook-3am1sq68.js → hook-4k84x499.js} +5 -5
  120. package/dist/{hook-tx917rqw.js → hook-a7eh6zty.js} +7 -7
  121. package/dist/{http-3rmemtqy.js → http-6aw5wanc.js} +180 -94
  122. package/dist/index-dtt0d634.js +44 -0
  123. package/dist/index-hmszyqkk.js +42 -0
  124. package/dist/index-j6rm1rtn.js +39 -0
  125. package/dist/{index-aetfyx6p.js → index-rwwhsmjg.js} +1 -1
  126. package/dist/{index-s7xtvc0f.js → index-xhad0n8m.js} +1 -1
  127. package/dist/{index-2jw11t8s.js → index-yq9hhhhy.js} +25 -25
  128. package/dist/{index-gfnq66t1.js → index-z2g9469g.js} +202 -17
  129. package/dist/{keepalive-9px3t7qj.js → keepalive-zhbmztqw.js} +4 -4
  130. package/dist/lead-g2j4q39z.js +83 -0
  131. package/dist/{maintenance-vwqjwst6.js → maintenance-rsp0591h.js} +1 -1
  132. package/dist/{node-2wfcey7d.js → node-0as4n1ef.js} +3 -3
  133. package/dist/{node-zd6shky9.js → node-dhxbt01p.js} +3 -3
  134. package/dist/{node-z67yjre7.js → node-rxte5hc6.js} +290 -70
  135. package/dist/{node-hjn5n1yp.js → node-t0ct2zpw.js} +3 -5
  136. package/dist/{oauth-refresh-sweep-yqry3wn4.js → oauth-refresh-sweep-w3cqmxq7.js} +3 -3
  137. package/dist/{object-webhooks-8s1wtths.js → object-webhooks-331hay92.js} +7 -7
  138. package/dist/{onboard-hb8czx0p.js → onboard-n2w80m2n.js} +3 -3
  139. package/dist/{opencode-adapter-djd6m6dk.js → opencode-adapter-z98127cz.js} +6 -6
  140. package/dist/{otel-impl-2ymwyczz.js → otel-impl-xsk35tvf.js} +1 -1
  141. package/dist/{pending-nxavtvx7.js → pending-2e6trkxd.js} +22 -22
  142. package/dist/{pi-mono-adapter-d2cpmcy4.js → pi-mono-adapter-wh6yndtm.js} +8 -8
  143. package/dist/{pricing-refresh-1yz8jkqv.js → pricing-refresh-9355dj1t.js} +2 -2
  144. package/dist/{rbac-roles-dbpx0x9v.js → rbac-roles-58y3m912.js} +3 -3
  145. package/dist/{rbac-roles-7s6m31xw.js → rbac-roles-8eajw4s6.js} +2 -2
  146. package/dist/{render-v2-7y20rjrn.js → render-v2-7gskkmd4.js} +6 -6
  147. package/dist/{resume-wz546x47.js → resume-0drnmpja.js} +9 -9
  148. package/dist/{runtime-cb5bd9tz.js → runtime-d2tcmqte.js} +1 -1
  149. package/dist/{session-access-4vcft8kq.js → session-access-0ztys6bd.js} +5 -5
  150. package/dist/{session-source-backfill-57b50tpw.js → session-source-backfill-cdm5s046.js} +2 -2
  151. package/dist/{setup-e1tevjyj.js → setup-pqwb9tcc.js} +1 -1
  152. package/dist/thread-buffer-epx3san4.js +42 -0
  153. package/dist/{tree-visibility-07wf1nct.js → tree-visibility-rwz67mje.js} +2 -2
  154. package/dist/{user-merge-jobs-n20qpv6s.js → user-merge-jobs-mxrhamwt.js} +3 -3
  155. package/dist/{virtual-modules-6fxmn1yv.js → virtual-modules-71y1gsmg.js} +3 -3
  156. package/dist/{work-objects-eg7y48pe.js → work-objects-3k4ykt9j.js} +24 -24
  157. package/dist/worker-09gqn9xy.js +83 -0
  158. package/dist/{worker-follow-up-jnvnnf2b.js → worker-follow-up-y0h64xpr.js} +21 -21
  159. package/openapi.json +387 -6
  160. package/package.json +4 -4
  161. package/src/apps/sync.ts +20 -5
  162. package/src/azure-devops/boards-sync.ts +1 -1
  163. package/src/be/db/slack-trees.ts +12 -1
  164. package/src/be/db/tasks/read.ts +25 -1
  165. package/src/be/db/tasks/write.ts +47 -12
  166. package/src/be/db/users/avatar.ts +12 -0
  167. package/src/be/db.ts +78 -5
  168. package/src/be/migrations/344_user_avatar.sql +4 -0
  169. package/src/be/migrations/345_task_status_kind.sql +6 -0
  170. package/src/be/primitives/object-embed.ts +2 -2
  171. package/src/be/primitives/objects.ts +2 -2
  172. package/src/be/runtime-pools/supervisor.ts +1 -0
  173. package/src/be/scripts/typecheck.ts +1 -1
  174. package/src/be/swarm-config-guard.ts +4 -0
  175. package/src/bitbucket/handlers.ts +1 -1
  176. package/src/commands/credential-outcome-report.ts +96 -0
  177. package/src/commands/onboard/agent-fs-version.ts +1 -1
  178. package/src/commands/runner.ts +49 -3
  179. package/src/event-waits/github.ts +39 -6
  180. package/src/event-waits/index.ts +4 -2
  181. package/src/event-waits/types.ts +10 -3
  182. package/src/extensions/contract-types.generated.ts +1 -1
  183. package/src/github/app.ts +177 -13
  184. package/src/github/handlers.ts +7 -2
  185. package/src/github/pull-request-state.ts +100 -11
  186. package/src/gitlab/handlers.ts +2 -2
  187. package/src/heartbeat/heartbeat.ts +6 -1
  188. package/src/http/api-keys.ts +26 -0
  189. package/src/http/asset-key-write.ts +45 -0
  190. package/src/http/assets.ts +4 -3
  191. package/src/http/github-token.ts +27 -6
  192. package/src/http/pages.ts +4 -10
  193. package/src/http/schedules.ts +6 -6
  194. package/src/http/sessions.ts +7 -2
  195. package/src/http/tasks.ts +23 -5
  196. package/src/http/users.ts +5 -0
  197. package/src/http/webhooks.ts +19 -1
  198. package/src/http/workflows.ts +5 -10
  199. package/src/integrations/chat-sdk/commands.ts +3 -1
  200. package/src/jira/sync.ts +1 -1
  201. package/src/linear/sync.ts +5 -3
  202. package/src/prompts/session-templates.ts +1 -0
  203. package/src/providers/acp-targets.ts +2 -2
  204. package/src/providers/amp-adapter.ts +1 -1
  205. package/src/providers/claude-adapter.ts +5 -0
  206. package/src/providers/claude-sdk-session.ts +5 -0
  207. package/src/providers/runtime-dependencies.ts +1 -1
  208. package/src/scheduler/deferred-task-waits.ts +74 -13
  209. package/src/scripts-runtime/swarm-sdk.ts +8 -1
  210. package/src/scripts-runtime/types/stdlib.d.ts +8 -1
  211. package/src/scripts-runtime/types/swarm-extension.d.ts +19 -2
  212. package/src/scripts-runtime/types/swarm-sdk.d.ts +8 -1
  213. package/src/slack/actions.ts +1 -1
  214. package/src/slack/render-v2.ts +148 -7
  215. package/src/tests/api-drain-worker-e2e.test.ts +0 -2
  216. package/src/tests/approval-auto-cancellation-migration.test.ts +8 -19
  217. package/src/tests/approval-card-resolution.test.ts +2 -17
  218. package/src/tests/approval-requests-notifications.test.ts +41 -27
  219. package/src/tests/approval-requests.test.ts +137 -369
  220. package/src/tests/apps-sync-engine.test.ts +5 -3
  221. package/src/tests/apps-table-filters-migration.test.ts +44 -25
  222. package/src/tests/bitbucket-handlers.test.ts +2 -0
  223. package/src/tests/chat-sdk-commands.test.ts +1 -0
  224. package/src/tests/claude-adapter.test.ts +35 -0
  225. package/src/tests/codex-adapter.test.ts +3 -92
  226. package/src/tests/codex-gpt6-release.test.ts +0 -9
  227. package/src/tests/codex-oauth-credential-info.test.ts +35 -18
  228. package/src/tests/codex-oauth.test.ts +0 -6
  229. package/src/tests/codex-pool.test.ts +5 -214
  230. package/src/tests/codex-rate-limit-parse.test.ts +0 -7
  231. package/src/tests/codex-swarm-events.test.ts +11 -54
  232. package/src/tests/db-client-busy-retry.test.ts +49 -16
  233. package/src/tests/defer-task.test.ts +1 -0
  234. package/src/tests/e2e-shards.test.ts +9 -9
  235. package/src/tests/enabled-tools.test.ts +0 -2
  236. package/src/tests/fixtures/base-prompt-baseline.json +6 -6
  237. package/src/tests/github-app-worker-auth-helper.test.ts +147 -1
  238. package/src/tests/gitlab-handlers.test.ts +2 -0
  239. package/src/tests/heartbeat-jev-gate.test.ts +9 -241
  240. package/src/tests/heartbeat-reroute-decision.test.ts +2 -0
  241. package/src/tests/heartbeat-supersede-resume.test.ts +2 -0
  242. package/src/tests/heartbeat.test.ts +1 -0
  243. package/src/tests/key-usage-selection.test.ts +302 -0
  244. package/src/tests/memory-e2e.test.ts +34 -103
  245. package/src/tests/memory-key-paths.test.ts +5 -0
  246. package/src/tests/memory-rater-llm.test.ts +33 -149
  247. package/src/tests/memory-store.test.ts +24 -125
  248. package/src/tests/memory.test.ts +31 -100
  249. package/src/tests/merge-gate-detect-changes.test.ts +108 -2
  250. package/src/tests/otel-service-name.test.ts +0 -9
  251. package/src/tests/otel-session-cost-metrics.test.ts +1 -38
  252. package/src/tests/pool-session-logs.test.ts +8 -42
  253. package/src/tests/pre-push-affected-tests.test.ts +106 -0
  254. package/src/tests/prompt-template-session.test.ts +3 -0
  255. package/src/tests/runner-api-drain.test.ts +2 -17
  256. package/src/tests/runner-terminal-window-report.test.ts +132 -0
  257. package/src/tests/runtime-supervisor-failures.test.ts +1 -0
  258. package/src/tests/sandboxed-process.test.ts +26 -21
  259. package/src/tests/schedule-http-triage-tools.test.ts +12 -9
  260. package/src/tests/scheduled-tasks.test.ts +14 -51
  261. package/src/tests/script-executor-conformance.test.ts +4 -48
  262. package/src/tests/script-executor-quickjs-pool.test.ts +9 -7
  263. package/src/tests/script-native-startup.test.ts +21 -25
  264. package/src/tests/secret-rules.test.ts +4 -2
  265. package/src/tests/session-logs.test.ts +1 -260
  266. package/src/tests/slack-render-v2.test.ts +5 -148
  267. package/src/tests/task-cascade-fail.test.ts +1 -0
  268. package/src/tests/task-supersede-resume.test.ts +1 -0
  269. package/src/tests/test-proc.ts +5 -2
  270. package/src/tests/window-stream-reporter.test.ts +122 -0
  271. package/src/tests/workflow-agent-task-retry.test.ts +1 -3
  272. package/src/tests/workflow-cascade-cancel.test.ts +1 -0
  273. package/src/tests/workflow-retry-v2.test.ts +34 -43
  274. package/src/tests/workflow-retry-validation.test.ts +8 -48
  275. package/src/tests/worktree-reaper.test.ts +2 -2
  276. package/src/tools/cancel-task.ts +2 -2
  277. package/src/tools/defer-task.ts +7 -2
  278. package/src/tools/get-task-details.ts +8 -4
  279. package/src/tools/get-tasks.ts +13 -2
  280. package/src/tools/manage-user.ts +9 -0
  281. package/src/tools/store-progress.ts +5 -3
  282. package/src/types.ts +93 -0
  283. package/src/utils/constants.ts +12 -0
  284. package/src/utils/credentials.ts +42 -5
  285. package/src/utils/error-tracker.ts +6 -0
  286. package/src/utils/key-usage.ts +114 -0
  287. package/src/utils/sandboxed-process.ts +1 -0
  288. package/src/workflows/resume.ts +5 -2
  289. package/templates/skills/apps/SKILL.md +2 -0
  290. package/templates/skills/apps/content.md +2 -0
  291. package/templates/skills/boards-and-sheets/content.md +4 -2
  292. package/templates/skills/pages/content.md +7 -0
  293. package/templates/skills/swarm-docs/content.md +1 -0
  294. package/templates/skills/swarm-scripts/SKILL.md +1 -0
  295. package/templates/skills/swarm-scripts/content.md +1 -0
  296. package/dist/acp-adapter-mr4temec.js +0 -17
  297. package/dist/fx-adapter-4sjrbdne.js +0 -20
  298. package/dist/handlers-ef3k11hb.js +0 -41
  299. package/dist/index-e6bq0exk.js +0 -42
  300. package/dist/index-hf2k1vge.js +0 -39
  301. package/dist/index-taxmejj3.js +0 -44
  302. package/dist/lead-5vt6f174.js +0 -83
  303. package/dist/thread-buffer-686pa1p1.js +0 -42
  304. package/dist/worker-4vp616ms.js +0 -83
  305. package/src/tests/apps-table-selection-migration.test.ts +0 -95
  306. package/src/tests/extensions-example-heartbeat-remediate.test.ts +0 -69
  307. package/src/tests/extensions-example-rewrite-and-suppress.test.ts +0 -70
@@ -1,6 +1,5 @@
1
1
  import { afterAll, beforeAll, describe, expect, test } from "bun:test";
2
2
  import { unlink } from "node:fs/promises";
3
- import { createServer as createHttpServer, type Server } from "node:http";
4
3
  import {
5
4
  closeDb,
6
5
  createSessionLogs,
@@ -8,104 +7,12 @@ import {
8
7
  getDbClient,
9
8
  getSessionLogsBySession,
10
9
  getSessionLogsByTaskId,
11
- getTaskById,
12
10
  initDb,
13
11
  } from "../be/db";
14
- import { listenOnFreePort } from "./test-net";
15
12
 
16
13
  const TEST_DB_PATH = "./test-session-logs.sqlite";
17
14
 
18
- // Helper to parse path segments
19
- function getPathSegments(url: string): string[] {
20
- const pathEnd = url.indexOf("?");
21
- const path = pathEnd === -1 ? url : url.slice(0, pathEnd);
22
- return path.split("/").filter(Boolean);
23
- }
24
-
25
- // Minimal HTTP handler for session logs endpoints
26
- async function handleRequest(
27
- req: { method: string; url: string },
28
- body: string,
29
- ): Promise<{ status: number; body: unknown }> {
30
- const pathSegments = getPathSegments(req.url || "");
31
-
32
- // POST /api/session-logs - Store session logs (batch)
33
- if (req.method === "POST" && pathSegments[0] === "api" && pathSegments[1] === "session-logs") {
34
- const parsedBody = JSON.parse(body);
35
-
36
- // Validate required fields
37
- if (!parsedBody.sessionId || typeof parsedBody.sessionId !== "string") {
38
- return { status: 400, body: { error: "Missing or invalid 'sessionId' field" } };
39
- }
40
-
41
- if (typeof parsedBody.iteration !== "number" || parsedBody.iteration < 1) {
42
- return { status: 400, body: { error: "Missing or invalid 'iteration' field" } };
43
- }
44
-
45
- if (!Array.isArray(parsedBody.lines) || parsedBody.lines.length === 0) {
46
- return { status: 400, body: { error: "Missing or invalid 'lines' array" } };
47
- }
48
-
49
- try {
50
- await createSessionLogs({
51
- taskId: parsedBody.taskId || undefined,
52
- sessionId: parsedBody.sessionId,
53
- iteration: parsedBody.iteration,
54
- cli: parsedBody.cli || "claude",
55
- lines: parsedBody.lines,
56
- });
57
-
58
- return { status: 201, body: { success: true, count: parsedBody.lines.length } };
59
- } catch (error) {
60
- console.error("[TEST] Failed to create session logs:", error);
61
- return { status: 500, body: { error: "Failed to store session logs" } };
62
- }
63
- }
64
-
65
- // GET /api/tasks/:id/session-logs - Get session logs for a task
66
- if (
67
- req.method === "GET" &&
68
- pathSegments[0] === "api" &&
69
- pathSegments[1] === "tasks" &&
70
- pathSegments[2] &&
71
- pathSegments[3] === "session-logs"
72
- ) {
73
- const taskId = pathSegments[2];
74
- const task = await getTaskById(taskId);
75
-
76
- if (!task) {
77
- return { status: 404, body: { error: "Task not found" } };
78
- }
79
-
80
- const logs = await getSessionLogsByTaskId(taskId);
81
- return { status: 200, body: { logs } };
82
- }
83
-
84
- return { status: 404, body: { error: "Not found" } };
85
- }
86
-
87
- // Create test HTTP server
88
- function createTestServer(): Server {
89
- return createHttpServer(async (req, res) => {
90
- res.setHeader("Content-Type", "application/json");
91
-
92
- const chunks: Buffer[] = [];
93
- for await (const chunk of req) {
94
- chunks.push(chunk);
95
- }
96
- const body = Buffer.concat(chunks).toString();
97
-
98
- const result = await handleRequest({ method: req.method || "GET", url: req.url || "/" }, body);
99
-
100
- res.writeHead(result.status);
101
- res.end(JSON.stringify(result.body));
102
- });
103
- }
104
-
105
- describe("Session Logs API", () => {
106
- let server: Server;
107
- let baseUrl = "";
108
-
15
+ describe("Session Logs Storage", () => {
109
16
  beforeAll(async () => {
110
17
  // Clean up any existing test database
111
18
  try {
@@ -116,20 +23,9 @@ describe("Session Logs API", () => {
116
23
 
117
24
  // Initialize test database
118
25
  initDb(TEST_DB_PATH);
119
-
120
- // Start test server
121
- server = createTestServer();
122
- const port = await listenOnFreePort(server);
123
- baseUrl = `http://localhost:${port}`;
124
- console.log(`Test server listening on port ${port}`);
125
26
  });
126
27
 
127
28
  afterAll(async () => {
128
- // Close server
129
- await new Promise<void>((resolve) => {
130
- server.close(() => resolve());
131
- });
132
-
133
29
  // Close database
134
30
  closeDb();
135
31
 
@@ -380,159 +276,4 @@ describe("Session Logs API", () => {
380
276
  expect(bySession.map((l) => l.content)).toEqual(written);
381
277
  });
382
278
  });
383
-
384
- describe("POST /api/session-logs", () => {
385
- test("should return 400 if sessionId is missing", async () => {
386
- const response = await fetch(`${baseUrl}/api/session-logs`, {
387
- method: "POST",
388
- headers: { "Content-Type": "application/json" },
389
- body: JSON.stringify({ iteration: 1, lines: ["test"] }),
390
- });
391
-
392
- expect(response.status).toBe(400);
393
- const data = (await response.json()) as { error: string };
394
- expect(data.error).toContain("sessionId");
395
- });
396
-
397
- test("should return 400 if iteration is missing", async () => {
398
- const response = await fetch(`${baseUrl}/api/session-logs`, {
399
- method: "POST",
400
- headers: { "Content-Type": "application/json" },
401
- body: JSON.stringify({ sessionId: "test", lines: ["test"] }),
402
- });
403
-
404
- expect(response.status).toBe(400);
405
- const data = (await response.json()) as { error: string };
406
- expect(data.error).toContain("iteration");
407
- });
408
-
409
- test("should return 400 if iteration is less than 1", async () => {
410
- const response = await fetch(`${baseUrl}/api/session-logs`, {
411
- method: "POST",
412
- headers: { "Content-Type": "application/json" },
413
- body: JSON.stringify({ sessionId: "test", iteration: 0, lines: ["test"] }),
414
- });
415
-
416
- expect(response.status).toBe(400);
417
- const data = (await response.json()) as { error: string };
418
- expect(data.error).toContain("iteration");
419
- });
420
-
421
- test("should return 400 if lines is missing", async () => {
422
- const response = await fetch(`${baseUrl}/api/session-logs`, {
423
- method: "POST",
424
- headers: { "Content-Type": "application/json" },
425
- body: JSON.stringify({ sessionId: "test", iteration: 1 }),
426
- });
427
-
428
- expect(response.status).toBe(400);
429
- const data = (await response.json()) as { error: string };
430
- expect(data.error).toContain("lines");
431
- });
432
-
433
- test("should return 400 if lines is empty array", async () => {
434
- const response = await fetch(`${baseUrl}/api/session-logs`, {
435
- method: "POST",
436
- headers: { "Content-Type": "application/json" },
437
- body: JSON.stringify({ sessionId: "test", iteration: 1, lines: [] }),
438
- });
439
-
440
- expect(response.status).toBe(400);
441
- const data = (await response.json()) as { error: string };
442
- expect(data.error).toContain("lines");
443
- });
444
-
445
- test("should return 201 on successful POST", async () => {
446
- const response = await fetch(`${baseUrl}/api/session-logs`, {
447
- method: "POST",
448
- headers: { "Content-Type": "application/json" },
449
- body: JSON.stringify({
450
- sessionId: "api-test-session",
451
- iteration: 1,
452
- cli: "claude",
453
- lines: ['{"type":"system"}', '{"type":"result"}'],
454
- }),
455
- });
456
-
457
- expect(response.status).toBe(201);
458
- const data = (await response.json()) as { success: boolean; count: number };
459
- expect(data.success).toBe(true);
460
- expect(data.count).toBe(2);
461
- });
462
-
463
- test("should store logs with taskId", async () => {
464
- const task = await createTaskExtended("API test task");
465
-
466
- const response = await fetch(`${baseUrl}/api/session-logs`, {
467
- method: "POST",
468
- headers: { "Content-Type": "application/json" },
469
- body: JSON.stringify({
470
- sessionId: "api-task-session",
471
- iteration: 1,
472
- taskId: task.id,
473
- cli: "claude",
474
- lines: ['{"type":"test"}'],
475
- }),
476
- });
477
-
478
- expect(response.status).toBe(201);
479
-
480
- // Verify it was stored correctly
481
- const logs = await getSessionLogsByTaskId(task.id);
482
- expect(logs.length).toBe(1);
483
- expect(logs[0]?.taskId).toBe(task.id);
484
- });
485
- });
486
-
487
- describe("GET /api/tasks/:id/session-logs", () => {
488
- test("should return 404 if task does not exist", async () => {
489
- const response = await fetch(`${baseUrl}/api/tasks/non-existent-task/session-logs`);
490
-
491
- expect(response.status).toBe(404);
492
- const data = (await response.json()) as { error: string };
493
- expect(data.error).toContain("Task not found");
494
- });
495
-
496
- test("should return empty logs array for task with no logs", async () => {
497
- const task = await createTaskExtended("Task without logs");
498
-
499
- const response = await fetch(`${baseUrl}/api/tasks/${task.id}/session-logs`);
500
-
501
- expect(response.status).toBe(200);
502
- const data = (await response.json()) as { logs: unknown[] };
503
- expect(data.logs).toEqual([]);
504
- });
505
-
506
- test("should return session logs for a task", async () => {
507
- const task = await createTaskExtended("Task with logs for GET test");
508
-
509
- // Create some logs
510
- await createSessionLogs({
511
- taskId: task.id,
512
- sessionId: "get-test-session",
513
- iteration: 1,
514
- cli: "claude",
515
- lines: ['{"type":"system"}', '{"type":"assistant"}'],
516
- });
517
-
518
- const response = await fetch(`${baseUrl}/api/tasks/${task.id}/session-logs`);
519
-
520
- expect(response.status).toBe(200);
521
- const data = (await response.json()) as {
522
- logs: Array<{
523
- id: string;
524
- taskId: string;
525
- sessionId: string;
526
- iteration: number;
527
- cli: string;
528
- content: string;
529
- lineNumber: number;
530
- createdAt: string;
531
- }>;
532
- };
533
- expect(data.logs.length).toBe(2);
534
- expect(data.logs[0]?.content).toBe('{"type":"system"}');
535
- expect(data.logs[1]?.content).toBe('{"type":"assistant"}');
536
- });
537
- });
538
279
  });
@@ -1311,16 +1311,6 @@ describe("Slack renderer v2", () => {
1311
1311
  ` ↳ ▶️ ship this PR · 8m05s · <https://app.agent-swarm.dev/tasks/${secondAsk.id}|\`${secondAsk.id.slice(0, 8)}\`>`,
1312
1312
  ].join("\n"),
1313
1313
  );
1314
- expect(text).not.toContain("workspace.slack.com");
1315
- expect(text).not.toContain("|↵>");
1316
- expect(text).not.toContain("|result>");
1317
- expect(text).toContain(getTaskLink(ask.id));
1318
- expect(text).toContain(`\`${ask.id.slice(0, 8)}\``);
1319
- expect(text).not.toContain("```");
1320
- expect(text).not.toContain("↩");
1321
- expect(text).not.toContain(":leftwards_arrow_with_hook:");
1322
- const rows = text.split("\n").slice(1);
1323
- expect(rows.slice(0, 3).map((row) => row.match(/^ +/u)?.[0].length)).toEqual([1, 4, 7]);
1324
1314
  });
1325
1315
 
1326
1316
  test("glyphs: running vs stalled in_progress, and a pending task blocked on a dependency", async () => {
@@ -1708,7 +1698,7 @@ describe("Slack renderer v2", () => {
1708
1698
  });
1709
1699
  await startTask(ask.id);
1710
1700
  await ensureSlackThreadTree([ask.id]);
1711
- await completeTask(ask.id, "Recover this outcome through its deterministic task link.");
1701
+ await completeTask(ask.id, "Recover this outcome through its presentation text.");
1712
1702
  await getDbClient().run(`CREATE TRIGGER fail_outcome_timestamp_bind
1713
1703
  BEFORE UPDATE OF ts ON slack_messages
1714
1704
  WHEN OLD.kind = 'outcome' AND OLD.ts LIKE 'pending:%'
@@ -1816,29 +1806,16 @@ describe("Slack renderer v2", () => {
1816
1806
  expect(outcomeBody).toBe(
1817
1807
  "✅ Implemented the Slack renderer and opened a focused pull request.\n\nSecond paragraph that must be rendered.",
1818
1808
  );
1819
- expect(outcomeBody).not.toMatch(/\n{3,}/);
1820
- expect(outcomeBody).toBe(outcomeBody.trim());
1821
- expect(outcomeBody).not.toContain("**Done**");
1822
- expect(outcomeBody).not.toContain(getTaskLink(ask.id));
1823
1809
  expect(started.payload.channel).toBe(channelId);
1824
1810
  expect(started.payload.thread_ts).toBe(threadTs);
1825
1811
  expect(started.payload.recipient_user_id).toBe("U_REQUESTER");
1826
1812
  expect(started.payload.recipient_team_id).toBe("T_TEST");
1827
- expect(String(started.payload.markdown_text).startsWith("✅ Implemented")).toBe(true);
1828
- expect(Object.keys(started.payload).sort()).toEqual([
1829
- "channel",
1830
- "icon_emoji",
1831
- "markdown_text",
1832
- "recipient_team_id",
1833
- "recipient_user_id",
1834
- "thread_ts",
1835
- "username",
1836
- ]);
1813
+ expect(started.payload).not.toHaveProperty("blocks");
1837
1814
  expect(calls.some((call) => call.method === "chat.appendStream")).toBe(false);
1838
1815
  const stopped = calls.find(
1839
1816
  (call) => call.method === "chat.stopStream" && call.payload.channel === channelId,
1840
1817
  )!;
1841
- expect(Object.keys(stopped.payload).sort()).toEqual(["blocks", "channel", "ts"]);
1818
+ expect(stopped.payload.markdown_text).toBeUndefined();
1842
1819
  const completedAsk = (await getTaskById(ask.id))!;
1843
1820
  const duration = formatV2Duration(
1844
1821
  new Date(completedAsk.createdAt),
@@ -2232,15 +2209,6 @@ describe("Slack renderer v2", () => {
2232
2209
 
2233
2210
  const started = calls.find((call) => call.method === "chat.startStream");
2234
2211
  expect(started?.payload.markdown_text).toBe(`✅\n\n${output.trim()}`);
2235
- expect(String(started?.payload.markdown_text)).toContain("# Complete result");
2236
- expect(String(started?.payload.markdown_text)).toContain("**Bold text**");
2237
- expect(String(started?.payload.markdown_text)).toContain(
2238
- "[a labeled link](https://example.com/result)",
2239
- );
2240
- expect(String(started?.payload.markdown_text)).toContain(" - nested item");
2241
- expect(String(started?.payload.markdown_text)).toContain(
2242
- '```ts\nconst message = "preserved";\n```',
2243
- );
2244
2212
  expect(calls.some((call) => call.method === "chat.appendStream")).toBe(false);
2245
2213
  });
2246
2214
 
@@ -2702,30 +2670,6 @@ describe("Slack renderer v2", () => {
2702
2670
  expect((await getSlackOutcomeMessage(ask.id))?.finalizedAt).toBeDefined();
2703
2671
  });
2704
2672
 
2705
- test("keeps the full outcome body when the agent has not replied inline", async () => {
2706
- const lead = await createAgent({ name: "No Reply Lead", isLead: true, status: "idle" });
2707
- const { channelId, threadTs } = uniqueSlackAddress("C_RENDER_NO_REPLY");
2708
- const ask = await createTaskExtended("ask without an inline reply", {
2709
- agentId: lead.id,
2710
- source: "slack",
2711
- slackChannelId: channelId,
2712
- slackThreadTs: threadTs,
2713
- contextKey: slackContextKey({ channelId, threadTs }),
2714
- });
2715
- await startTask(ask.id);
2716
- await ensureSlackThreadTree([ask.id]);
2717
- await completeTask(ask.id, "This output must reach Slack since no slack-reply was sent.");
2718
- calls.length = 0;
2719
- _resetSlackRenderV2ForTests();
2720
-
2721
- await processSlackRenderV2();
2722
-
2723
- const started = calls.find((call) => call.method === "chat.startStream");
2724
- expect(started?.payload.markdown_text).toBe(
2725
- "✅ This output must reach Slack since no slack-reply was sent.",
2726
- );
2727
- });
2728
-
2729
2673
  test("redacts a runtime-rotated config secret from persisted output and its Slack outcome", async () => {
2730
2674
  const lead = await createAgent({ name: "Rotating Secret Lead", isLead: true, status: "idle" });
2731
2675
  const { channelId, threadTs } = uniqueSlackAddress("C_RENDER_ROTATED_SECRET");
@@ -2792,7 +2736,7 @@ describe("Slack renderer v2", () => {
2792
2736
  expect(outcome?.finalizedAt).toBeDefined();
2793
2737
  });
2794
2738
 
2795
- test("renders a legacy deferral as ⏳ with its ETA, even after a slack-reply", async () => {
2739
+ test("renders a legacy deferral as ⏳ without its ETA, even after a slack-reply", async () => {
2796
2740
  const lead = await createAgent({ name: "Deferring Lead", isLead: true, status: "idle" });
2797
2741
  const { channelId, threadTs } = uniqueSlackAddress("C_RENDER_DEFER_AFTER_REPLY");
2798
2742
  const ask = await createTaskExtended("defer after replying by hand", {
@@ -3293,7 +3237,7 @@ describe("Slack renderer v2", () => {
3293
3237
  expect(attempts()).toBe(0);
3294
3238
  });
3295
3239
 
3296
- test("a deferral with no pending text still posts its ETA", async () => {
3240
+ test("a legacy deferral with no pending text still posts a waiting card", async () => {
3297
3241
  const { channelId, threadTs } = uniqueSlackAddress("C_ETA_ONLY");
3298
3242
  const ask = await createTaskExtended("wait", {
3299
3243
  source: "slack",
@@ -3774,40 +3718,6 @@ describe("Slack renderer v2 delegation (SLACK_RENDER_V2_DELEGATION)", () => {
3774
3718
 
3775
3719
  // --- T3: child result cards ---------------------------------------------
3776
3720
 
3777
- test("an eligible mcp child posts once and never twice across 3 ticks", async () => {
3778
- const lead = await createAgent({ name: "Delegation Lead", isLead: true, status: "idle" });
3779
- const worker = await createAgent({ name: "Delegation Worker", isLead: false, status: "idle" });
3780
- const { channelId, threadTs } = uniqueSlackAddress("C_CHILD_ONCE");
3781
- const ask = await createTaskExtended("delegate research", {
3782
- agentId: lead.id,
3783
- source: "slack",
3784
- slackChannelId: channelId,
3785
- slackThreadTs: threadTs,
3786
- contextKey: slackContextKey({ channelId, threadTs }),
3787
- });
3788
- await startTask(ask.id);
3789
- const child = await createTaskExtended("research the API", {
3790
- agentId: worker.id,
3791
- source: "mcp",
3792
- parentTaskId: ask.id,
3793
- followUpConfig: { disabled: true },
3794
- });
3795
- await startTask(child.id);
3796
- await completeTask(child.id, "Found the answer.");
3797
- calls.length = 0;
3798
-
3799
- await processSlackRenderV2();
3800
- await processSlackRenderV2();
3801
- await processSlackRenderV2();
3802
-
3803
- const startStreamCalls = calls.filter((call) => call.method === "chat.startStream");
3804
- expect(startStreamCalls).toHaveLength(1);
3805
- expect(String(startStreamCalls[0]!.payload.markdown_text)).toContain(
3806
- "↳ ✅ Delegation Worker — result",
3807
- );
3808
- expect((await getSlackOutcomeMessage(child.id))?.finalizedAt).toBeDefined();
3809
- });
3810
-
3811
3721
  test("follow-up and reroute-decision children never get a card; a resume child does", async () => {
3812
3722
  const lead = await createAgent({ name: "Tasktype Lead", isLead: true, status: "idle" });
3813
3723
  const worker = await createAgent({ name: "Tasktype Worker", isLead: false, status: "idle" });
@@ -4666,59 +4576,6 @@ describe("Slack renderer v2 delegation (SLACK_RENDER_V2_DELEGATION)", () => {
4666
4576
  });
4667
4577
  });
4668
4578
 
4669
- test("acceptance: ask done + child running yields zero outcome rows across 10 ticks, then exactly one within 2 ticks after settling", async () => {
4670
- const lead = await createAgent({ name: "Acceptance T4 Lead", isLead: true, status: "idle" });
4671
- const worker = await createAgent({
4672
- name: "Acceptance T4 Worker",
4673
- isLead: false,
4674
- status: "idle",
4675
- });
4676
- const { channelId, threadTs } = uniqueSlackAddress("C_T4_ACCEPTANCE");
4677
- const ask = await createTaskExtended("acceptance ask", {
4678
- agentId: lead.id,
4679
- source: "slack",
4680
- slackChannelId: channelId,
4681
- slackThreadTs: threadTs,
4682
- contextKey: slackContextKey({ channelId, threadTs }),
4683
- });
4684
- await startTask(ask.id);
4685
- const child = await createTaskExtended("acceptance child", {
4686
- agentId: worker.id,
4687
- source: "mcp",
4688
- parentTaskId: ask.id,
4689
- followUpConfig: { disabled: true },
4690
- });
4691
- await startTask(child.id);
4692
- await completeTask(ask.id, "Ask done; child still running.");
4693
- calls.length = 0;
4694
-
4695
- for (let tick = 0; tick < 10; tick++) {
4696
- await processSlackRenderV2();
4697
- }
4698
- const openRows = await getDbClient().query(
4699
- `SELECT * FROM slack_messages WHERE task_id = ? AND kind = 'outcome'`,
4700
- [ask.id],
4701
- );
4702
- expect(openRows).toHaveLength(0);
4703
-
4704
- await completeTask(child.id, "Child finished.");
4705
- await backdateLastUpdated([ask.id, child.id], 60);
4706
-
4707
- let ticksToFinalize = 0;
4708
- for (let tick = 0; tick < 2 && !(await getSlackOutcomeMessage(ask.id))?.finalizedAt; tick++) {
4709
- await processSlackRenderV2();
4710
- ticksToFinalize = tick + 1;
4711
- }
4712
-
4713
- expect(ticksToFinalize).toBeLessThanOrEqual(2);
4714
- const finalRows = await getDbClient().query<{ conclusion_kind: string | null }>(
4715
- `SELECT conclusion_kind FROM slack_messages WHERE task_id = ? AND kind = 'outcome'`,
4716
- [ask.id],
4717
- );
4718
- expect(finalRows).toHaveLength(1);
4719
- expect(finalRows[0]?.conclusion_kind).toBe("complete");
4720
- });
4721
-
4722
4579
  test("ask and child both terminal before the first tick: conclusion still links the child's permalink, not a digest", async () => {
4723
4580
  const lead = await createAgent({ name: "First Tick Lead", isLead: true, status: "idle" });
4724
4581
  const worker = await createAgent({ name: "First Tick Worker", isLead: false, status: "idle" });
@@ -118,6 +118,7 @@ describe("cascadeFailDependents", () => {
118
118
 
119
119
  const childAfter = await getTaskById(child.id);
120
120
  expect(childAfter!.status).toBe("failed");
121
+ expect(childAfter!.statusKind).toBe("cascade");
121
122
  expect(childAfter!.failureReason).toContain("Blocked dependency");
122
123
  expect(childAfter!.failureReason).toContain("was failed");
123
124
  });
@@ -87,6 +87,7 @@ describe("Task Supersede + Resume", () => {
87
87
  resumeTaskId: null,
88
88
  });
89
89
  expect(result?.status).toBe("superseded");
90
+ expect(result?.statusKind).toBe("graceful_shutdown");
90
91
  expect(result?.finishedAt).toBeTruthy();
91
92
 
92
93
  const log = (await getLogsByTaskId(task.id)).find((l) => l.eventType === "task_superseded");
@@ -40,6 +40,8 @@ export async function runChild(
40
40
  cwd?: string;
41
41
  env?: Record<string, string | undefined>;
42
42
  stdin?: string | Uint8Array;
43
+ /** Keep stdin open until exit. Use only with children that do not wait for EOF. */
44
+ keepStdinOpen?: boolean;
43
45
  timeoutMs?: number;
44
46
  } = {},
45
47
  ): Promise<ChildResult> {
@@ -49,7 +51,7 @@ export async function runChild(
49
51
  const proc = Bun.spawn(cmd, {
50
52
  cwd: opts.cwd,
51
53
  env: opts.env,
52
- stdin: hasStdin ? "pipe" : "ignore",
54
+ stdin: hasStdin || opts.keepStdinOpen ? "pipe" : "ignore",
53
55
  stdout: "pipe",
54
56
  stderr: "pipe",
55
57
  timeout: timeoutMs,
@@ -57,13 +59,14 @@ export async function runChild(
57
59
  });
58
60
  if (hasStdin) {
59
61
  proc.stdin?.write(opts.stdin as string | Uint8Array);
60
- await proc.stdin?.end();
62
+ if (!opts.keepStdinOpen) await proc.stdin?.end();
61
63
  }
62
64
  const [stdout, stderr, exitCode] = await Promise.all([
63
65
  new Response(proc.stdout).text(),
64
66
  new Response(proc.stderr).text(),
65
67
  proc.exited,
66
68
  ]);
69
+ if (opts.keepStdinOpen) await proc.stdin?.end();
67
70
  const durationMs = performance.now() - start;
68
71
  // Bun's `timeout` option kills the child with `killSignal` once the
69
72
  // deadline passes. A signal exit that took at least `timeoutMs` wall time
@@ -0,0 +1,122 @@
1
+ /**
2
+ * P2: mid-session window snapshots go out when a window moved 5 points or
3
+ * more, or 60 s passed since the last report. A failed report never throws.
4
+ */
5
+ import { describe, expect, spyOn, test } from "bun:test";
6
+ import { createWindowStreamReporter } from "../commands/credential-outcome-report";
7
+ import type { RateLimitWindowTelemetry } from "../utils/error-tracker";
8
+
9
+ function windows(fiveHour: number, sevenDay = 0.1): RateLimitWindowTelemetry {
10
+ const lastSeenAt = new Date().toISOString();
11
+ return {
12
+ five_hour: { status: "allowed", utilization: fiveHour, resetsAt: 1_900_000_000, lastSeenAt },
13
+ seven_day: { status: "allowed", utilization: sevenDay, resetsAt: 1_900_500_000, lastSeenAt },
14
+ };
15
+ }
16
+
17
+ function harness(post?: (w: RateLimitWindowTelemetry) => Promise<void>) {
18
+ let clock = 1_000_000;
19
+ const sent: RateLimitWindowTelemetry[] = [];
20
+ const report = createWindowStreamReporter({
21
+ post:
22
+ post ??
23
+ (async (w) => {
24
+ sent.push(w);
25
+ }),
26
+ now: () => clock,
27
+ });
28
+ return {
29
+ report,
30
+ sent,
31
+ advance: (ms: number) => {
32
+ clock += ms;
33
+ },
34
+ };
35
+ }
36
+
37
+ describe("createWindowStreamReporter", () => {
38
+ test("the first snapshot is sent", () => {
39
+ const h = harness();
40
+ h.report(windows(0.2));
41
+ expect(h.sent).toHaveLength(1);
42
+ });
43
+
44
+ test("a move under 5 points within 60 s is skipped", () => {
45
+ const h = harness();
46
+ h.report(windows(0.2));
47
+ h.advance(10_000);
48
+ h.report(windows(0.24));
49
+ h.advance(10_000);
50
+ h.report(windows(0.2, 0.14));
51
+ expect(h.sent).toHaveLength(1);
52
+ });
53
+
54
+ test("a move of 5 points or more is sent at once", () => {
55
+ const h = harness();
56
+ h.report(windows(0.2));
57
+ h.advance(1_000);
58
+ h.report(windows(0.25));
59
+ h.advance(1_000);
60
+ h.report(windows(0.25, 0.2));
61
+ expect(h.sent).toHaveLength(3);
62
+ });
63
+
64
+ test("the delta compares with the last sent snapshot, not the last seen one", () => {
65
+ const h = harness();
66
+ h.report(windows(0.2));
67
+ h.report(windows(0.23));
68
+ h.report(windows(0.26));
69
+ expect(h.sent.map((w) => w.five_hour?.utilization)).toEqual([0.2, 0.26]);
70
+ });
71
+
72
+ test("an unchanged snapshot is sent again after 60 s", () => {
73
+ const h = harness();
74
+ h.report(windows(0.2));
75
+ h.advance(59_999);
76
+ h.report(windows(0.2));
77
+ expect(h.sent).toHaveLength(1);
78
+ h.advance(1);
79
+ h.report(windows(0.2));
80
+ expect(h.sent).toHaveLength(2);
81
+ });
82
+
83
+ test("a window the last report did not carry is sent at once", () => {
84
+ const h = harness();
85
+ h.report({ five_hour: windows(0.2).five_hour! });
86
+ h.advance(1_000);
87
+ h.report(windows(0.2));
88
+ expect(h.sent).toHaveLength(2);
89
+ });
90
+
91
+ test("an empty snapshot is never sent", () => {
92
+ const h = harness();
93
+ h.report({});
94
+ expect(h.sent).toHaveLength(0);
95
+ });
96
+
97
+ test("a rejected or throwing post never throws and the next event retries", async () => {
98
+ const warn = spyOn(console, "warn").mockImplementation(() => {});
99
+ try {
100
+ let calls = 0;
101
+ const h = harness(async () => {
102
+ calls++;
103
+ throw new Error("HTTP 503");
104
+ });
105
+ expect(() => h.report(windows(0.2))).not.toThrow();
106
+ await Bun.sleep(0);
107
+ h.advance(1_000);
108
+ h.report(windows(0.2));
109
+ await Bun.sleep(0);
110
+ expect(calls).toBe(2);
111
+ expect(warn).toHaveBeenCalled();
112
+
113
+ const sync = harness(() => {
114
+ throw new Error("boom");
115
+ });
116
+ expect(() => sync.report(windows(0.2))).not.toThrow();
117
+ await Bun.sleep(0);
118
+ } finally {
119
+ warn.mockRestore();
120
+ }
121
+ });
122
+ });