@desplega.ai/agent-swarm 2.13.3 → 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 (424) hide show
  1. package/dist/acp-adapter-tbt61zkm.js +17 -0
  2. package/dist/{acp-targets-k8xs4tj8.js → acp-targets-w8dbs4nr.js} +10 -10
  3. package/dist/{actions-pg5fxjer.js → actions-8zrcbjrx.js} +237 -27
  4. package/dist/{agent-fs-provision-vbk3fppw.js → agent-fs-provision-cbt2ttds.js} +4 -4
  5. package/dist/{amp-adapter-adbhxsz9.js → amp-adapter-8x6zp8w4.js} +3 -3
  6. package/dist/{anthropic-messages-88b7s3n9.js → anthropic-messages-vdd1zmha.js} +10 -10
  7. package/dist/{app-b267ggx1.js → app-zfa9dwjw.js} +7 -7
  8. package/dist/{approval-notifications-evc1a9z5.js → approval-notifications-rv92zmza.js} +8 -8
  9. package/dist/{assistant-wgz2ab84.js → assistant-q7s7rm1q.js} +25 -25
  10. package/dist/{boot-args-schema-6tpk28j4.js → boot-args-schema-g27kpzr1.js} +1 -1
  11. package/dist/{boot-reembed-r1zyvefv.js → boot-reembed-1mjs52nt.js} +1 -1
  12. package/dist/{boot-reembed-ankp369c.js → boot-reembed-m62dpdkg.js} +1 -1
  13. package/dist/{boot-scrub-sweep-cgb6r5bd.js → boot-scrub-sweep-ss1vcamw.js} +2 -2
  14. package/dist/{boot-seeds-bjceqg7b.js → boot-seeds-hwnvgbb3.js} +4 -4
  15. package/dist/{boxd-hr8rsxzq.js → boxd-y0szhp0g.js} +2 -2
  16. package/dist/{claude-adapter-knztdnff.js → claude-adapter-0rjmbhjk.js} +9 -9
  17. package/dist/{claude-managed-adapter-qwejzqkk.js → claude-managed-adapter-6k032agg.js} +4 -4
  18. package/dist/{claude-managed-setup-0vgz4d1j.js → claude-managed-setup-6czvve8q.js} +5 -5
  19. package/dist/{claude-sdk-session-c3g6dv0g.js → claude-sdk-session-pr0znb81.js} +12671 -11885
  20. package/dist/{cli-2v4xxnx2.js → cli-0h8skzss.js} +1 -1
  21. package/dist/{cli-7fa6yv98.js → cli-0qt3epg4.js} +7 -7
  22. package/dist/{cli-aytna2fm.js → cli-19d6v8er.js} +7 -7
  23. package/dist/{cli-8m6gqnf1.js → cli-1jq2em7b.js} +4 -4
  24. package/dist/{cli-fp65jdp2.js → cli-1kvcsd2f.js} +219 -155
  25. package/dist/{cli-8fj8yfmk.js → cli-2vp0z049.js} +1 -1
  26. package/dist/{cli-61p7ty8d.js → cli-2wzkvfgm.js} +3 -3
  27. package/dist/{cli-tjf1bh1v.js → cli-34fygf87.js} +6 -4
  28. package/dist/{cli-czeh7x13.js → cli-3860pmrq.js} +4 -4
  29. package/dist/{cli-dq30fq3q.js → cli-3vw6dd4g.js} +2 -2
  30. package/dist/{cli-4dyhzhpx.js → cli-4gaf3tx5.js} +1 -1
  31. package/dist/{cli-3mf04tkh.js → cli-4vynxtrb.js} +1 -1
  32. package/dist/{cli-hpxcfvdm.js → cli-55h8m1x3.js} +10 -7
  33. package/dist/{cli-hxj888w3.js → cli-5n9w2xzx.js} +2 -2
  34. package/dist/{cli-50whymxq.js → cli-5tq15aa7.js} +2 -2
  35. package/dist/{cli-8sayvj48.js → cli-5web09sb.js} +3 -3
  36. package/dist/{cli-gc715jrc.js → cli-69zzpjgh.js} +1 -1
  37. package/dist/{cli-vgh5adn9.js → cli-6msnpj1z.js} +8 -8
  38. package/dist/{cli-f8rcvf2x.js → cli-7r9tvk8v.js} +76 -3
  39. package/dist/{cli-fbmgpt72.js → cli-7ypg8hka.js} +3 -3
  40. package/dist/{cli-xc8m5cjn.js → cli-887vhew6.js} +3 -3
  41. package/dist/{cli-q8aq48v1.js → cli-8b4rpnwj.js} +1 -1
  42. package/dist/{cli-pzsedyb0.js → cli-8pd1t17c.js} +14 -14
  43. package/dist/{cli-je587f74.js → cli-94gx6ze9.js} +1 -1
  44. package/dist/{cli-h9d3sdnc.js → cli-94mxerrp.js} +1 -1
  45. package/dist/{cli-ef590376.js → cli-9n6g14vs.js} +3 -3
  46. package/dist/{cli-80d5g0fa.js → cli-abby987g.js} +3 -3
  47. package/dist/{cli-grk77aen.js → cli-avax5mp9.js} +2 -2
  48. package/dist/{cli-hd2a204w.js → cli-b42yfn17.js} +14 -14
  49. package/dist/{cli-gkjw33x5.js → cli-b9ygp1kz.js} +2 -2
  50. package/dist/{cli-bh53ppqm.js → cli-bvamr9g0.js} +4 -4
  51. package/dist/{cli-ka4tqjzd.js → cli-ced4azn1.js} +15 -12
  52. package/dist/{cli-v1v49t36.js → cli-cmbb2t8a.js} +3 -3
  53. package/dist/{cli-hhb8kbwd.js → cli-cp163xga.js} +31 -16
  54. package/dist/{cli-55fqpd9q.js → cli-ebpq3c5z.js} +8 -8
  55. package/dist/{cli-9gmkw6xn.js → cli-ehg90jd1.js} +128 -48
  56. package/dist/{cli-jg5txpm6.js → cli-emdfd8fh.js} +75 -1
  57. package/dist/{cli-gxqwm3k3.js → cli-evy3egte.js} +104 -10
  58. package/dist/{cli-a21cwm89.js → cli-ewk3sg68.js} +3 -3
  59. package/dist/{cli-syqcny89.js → cli-f7b9nyvk.js} +9 -9
  60. package/dist/{cli-268b3dgn.js → cli-f9xw9pr4.js} +5 -5
  61. package/dist/{cli-61fzwtjk.js → cli-ffn0a515.js} +9 -9
  62. package/dist/{cli-ya1cj689.js → cli-fw67mnyc.js} +1 -1
  63. package/dist/{cli-dqgnbnxs.js → cli-grbngev5.js} +6 -1
  64. package/dist/{cli-sy2ge2ye.js → cli-hd5bm1e1.js} +4 -4
  65. package/dist/{cli-rfejbpe1.js → cli-htb5bpz2.js} +1 -1
  66. package/dist/{cli-w24741sm.js → cli-j69pzrrz.js} +7 -7
  67. package/dist/{cli-g4dhd3pr.js → cli-jdq3jmny.js} +6 -23
  68. package/dist/{cli-hv3820ez.js → cli-k0nebh10.js} +1 -1
  69. package/dist/{cli-d2epqm0y.js → cli-kezzteka.js} +1 -1
  70. package/dist/{cli-h0ewec3d.js → cli-kr0jpw9c.js} +1 -1
  71. package/dist/{cli-t25rq8mg.js → cli-ks06cd0n.js} +40 -11
  72. package/dist/{cli-1gnf5c7x.js → cli-kwj3131p.js} +1 -1
  73. package/dist/{cli-wtffytm8.js → cli-m8f4379k.js} +3 -3
  74. package/dist/{cli-43dsqhcp.js → cli-n79j1vxc.js} +4 -4
  75. package/dist/{cli-b768ek79.js → cli-nrt048ys.js} +1 -0
  76. package/dist/{cli-h3drhntp.js → cli-pedm2kht.js} +2 -2
  77. package/dist/{cli-eds5xnsz.js → cli-phmy14hb.js} +2 -2
  78. package/dist/{cli-7kv5d674.js → cli-prz1p3ft.js} +5 -5
  79. package/dist/{cli-nbawx3s0.js → cli-q1h041y8.js} +6 -6
  80. package/dist/{cli-cah298e5.js → cli-q41qar56.js} +104 -119
  81. package/dist/{cli-kwm1bek7.js → cli-qmx8bnt4.js} +2 -2
  82. package/dist/{cli-1wew39p0.js → cli-qrvk9nka.js} +28 -19
  83. package/dist/{cli-v8rpjrnx.js → cli-r3dxpmyt.js} +1 -1
  84. package/dist/{cli-0j4qmc80.js → cli-ryem5cfq.js} +8 -8
  85. package/dist/{cli-8pnawt98.js → cli-s8dhq7rj.js} +5 -5
  86. package/dist/{cli-zkbz8m2q.js → cli-sejvnjvw.js} +3 -2
  87. package/dist/{cli-at67kvnp.js → cli-srktrbby.js} +1 -1
  88. package/dist/{cli-wsnradtk.js → cli-srre41gb.js} +2 -2
  89. package/dist/{cli-r6xnchva.js → cli-t0n9svkb.js} +7 -7
  90. package/dist/{cli-y0q92v4r.js → cli-t879ww0y.js} +2 -2
  91. package/dist/{cli-eetzmsy5.js → cli-t9pzz2eq.js} +2 -2
  92. package/dist/{cli-xwsm6xkr.js → cli-tgc1kgg3.js} +1 -1
  93. package/dist/{cli-dw43pnzp.js → cli-tt7dkwjj.js} +7 -7
  94. package/dist/{cli-y754psdt.js → cli-tvyt8w6n.js} +5 -5
  95. package/dist/cli-v09eza21.js +1907 -0
  96. package/dist/{cli-mgr3gatr.js → cli-vbge4rsp.js} +4 -4
  97. package/dist/{cli-ppf9ap9n.js → cli-vcpyttcw.js} +1 -1
  98. package/dist/{cli-1606qw3n.js → cli-wzecestt.js} +1100 -432
  99. package/dist/{cli-5basv0e7.js → cli-x2adbg4j.js} +71 -9
  100. package/dist/{cli-vx9acp12.js → cli-ybte1fqc.js} +1 -1
  101. package/dist/{cli-vdfngx2g.js → cli-ywy8yz6t.js} +2 -2
  102. package/dist/{cli-cpkxh68d.js → cli-z1vam71h.js} +2 -2
  103. package/dist/{cli-djwt4mtn.js → cli-z3x7h79n.js} +15 -9
  104. package/dist/cli-z40t85ms.js +27 -0
  105. package/dist/{cli-ea367bdn.js → cli-zbbtp02a.js} +104 -27
  106. package/dist/{cli-88np9va3.js → cli-zntvmqmm.js} +2 -2
  107. package/dist/{cli-snwz16eg.js → cli-zxa1vmx7.js} +2 -2
  108. package/dist/{cli-50wa8k4h.js → cli-zy9bb22b.js} +1 -2
  109. package/dist/{cli-e4gx499y.js → cli-zzq96q57.js} +273 -106
  110. package/dist/cli.js +21 -21
  111. package/dist/{codex-adapter-493vb8cv.js → codex-adapter-bn7eaxk5.js} +8 -8
  112. package/dist/{codex-hook-ej8hn6z5.js → codex-hook-nnmezjg9.js} +3 -3
  113. package/dist/{codex-login-ven5cz5j.js → codex-login-ktfg1cxk.js} +1 -1
  114. package/dist/{codex-session-runner-ps5m4z1g.js → codex-session-runner-j1e9hffc.js} +9 -9
  115. package/dist/{commands-shktk0b8.js → commands-amhpafrr.js} +3 -3
  116. package/dist/{controller-wn3vd217.js → controller-tw7g10j2.js} +4 -4
  117. package/dist/{controllers-connect-yft057ws.js → controllers-connect-2ssqz7f4.js} +25 -25
  118. package/dist/core-bwp98v4w.js +42 -0
  119. package/dist/{cursor-adapter-8fpm4dng.js → cursor-adapter-d6knjmwa.js} +2 -2
  120. package/dist/{db-0ezhdhz5.js → db-fd6xxm77.js} +3 -3
  121. package/dist/{db-84pz2w5c.js → db-sc59379z.js} +2 -2
  122. package/dist/{devin-adapter-fs90ab4v.js → devin-adapter-3bp6rape.js} +1 -1
  123. package/dist/{dispatcher-h2rz69f6.js → dispatcher-a2gdqz8c.js} +22 -22
  124. package/dist/{docker-1h33jvh9.js → docker-a59g3ebm.js} +2 -2
  125. package/dist/{dsh-adapter-g9yqv09y.js → dsh-adapter-43ygwqn7.js} +2 -2
  126. package/dist/{e2b-jnk0yeva.js → e2b-cn7cvjqy.js} +3 -3
  127. package/dist/{e2b-y7e5kmzf.js → e2b-qnxyfea6.js} +3 -3
  128. package/dist/{easter-egg-3d-m41ad78v.js → easter-egg-3d-a0pphy71.js} +1 -1
  129. package/dist/{embedding-space-yam9zwzj.js → embedding-space-qepzrach.js} +6 -6
  130. package/dist/{embeddings-g2be0y8q.js → embeddings-d7vr881x.js} +1 -1
  131. package/dist/{event-bus-08t2b4y2.js → event-bus-7gbsr0g4.js} +1 -1
  132. package/dist/{execute-hhdejgzf.js → execute-6afts2bn.js} +1 -1
  133. package/dist/{external-channel-kjt2yzfj.js → external-channel-881zq1x4.js} +2 -2
  134. package/dist/fx-adapter-cr2hq17y.js +20 -0
  135. package/dist/grok-adapter-ayddnbsc.js +20 -0
  136. package/dist/handlers-7ghs84x2.js +41 -0
  137. package/dist/{heartbeat-2e5jdexj.js → heartbeat-4c022m6a.js} +25 -25
  138. package/dist/{hook-acg9saz7.js → hook-4k84x499.js} +6 -6
  139. package/dist/{hook-34s8cmgn.js → hook-a7eh6zty.js} +9 -9
  140. package/dist/{http-ra2zr2f8.js → http-6aw5wanc.js} +456 -1864
  141. package/dist/{index-mbpxhc4w.js → index-126v2d0t.js} +1 -4
  142. package/dist/index-dtt0d634.js +44 -0
  143. package/dist/index-hmszyqkk.js +42 -0
  144. package/dist/index-j6rm1rtn.js +39 -0
  145. package/dist/{index-9q42cr54.js → index-rwwhsmjg.js} +1 -1
  146. package/dist/{index-93bw5wds.js → index-xhad0n8m.js} +1 -1
  147. package/dist/{index-2z1z7qx6.js → index-yq9hhhhy.js} +26 -26
  148. package/dist/{index-9r4j0a60.js → index-z2g9469g.js} +410 -27
  149. package/dist/{k8s-8326q0rq.js → k8s-36gfn847.js} +2 -2
  150. package/dist/{keepalive-vjnnqbkm.js → keepalive-zhbmztqw.js} +5 -5
  151. package/dist/lead-g2j4q39z.js +83 -0
  152. package/dist/{maintenance-px2g599e.js → maintenance-rsp0591h.js} +1 -1
  153. package/dist/{node-2wfcey7d.js → node-0as4n1ef.js} +3 -3
  154. package/dist/{node-zd6shky9.js → node-dhxbt01p.js} +3 -3
  155. package/dist/{node-z67yjre7.js → node-rxte5hc6.js} +290 -70
  156. package/dist/{node-hjn5n1yp.js → node-t0ct2zpw.js} +3 -5
  157. package/dist/{oauth-refresh-sweep-nkykf09m.js → oauth-refresh-sweep-w3cqmxq7.js} +4 -4
  158. package/dist/{object-webhooks-gt9xnq21.js → object-webhooks-331hay92.js} +7 -7
  159. package/dist/{onboard-1f134p65.js → onboard-n2w80m2n.js} +7 -7
  160. package/dist/{opencode-adapter-94976yab.js → opencode-adapter-z98127cz.js} +8 -8
  161. package/dist/{otel-impl-5d4p2fqs.js → otel-impl-xsk35tvf.js} +2 -2
  162. package/dist/{pending-vkk0vx6n.js → pending-2e6trkxd.js} +23 -23
  163. package/dist/{pi-mono-adapter-cyzdv5er.js → pi-mono-adapter-wh6yndtm.js} +13 -13
  164. package/dist/{pricing-refresh-jtmjwss9.js → pricing-refresh-9355dj1t.js} +2 -2
  165. package/dist/{rbac-roles-yd1fgpsn.js → rbac-roles-58y3m912.js} +3 -3
  166. package/dist/{rbac-roles-1fvmdyeb.js → rbac-roles-8eajw4s6.js} +6 -4
  167. package/dist/{render-v2-kb5s3vx4.js → render-v2-7gskkmd4.js} +7 -7
  168. package/dist/{resume-z1vs44n5.js → resume-0drnmpja.js} +10 -10
  169. package/dist/{runtime-gk6ct7r7.js → runtime-d2tcmqte.js} +1 -1
  170. package/dist/{session-access-nz6nre4d.js → session-access-0ztys6bd.js} +5 -5
  171. package/dist/{session-source-backfill-wb60zjkd.js → session-source-backfill-cdm5s046.js} +3 -3
  172. package/dist/{setup-2x8g8j4s.js → setup-pqwb9tcc.js} +1 -1
  173. package/dist/thread-buffer-epx3san4.js +42 -0
  174. package/dist/{tree-visibility-ts3z30kw.js → tree-visibility-rwz67mje.js} +2 -2
  175. package/dist/{user-merge-jobs-zetg26e0.js → user-merge-jobs-mxrhamwt.js} +3 -3
  176. package/dist/{virtual-modules-674fka8x.js → virtual-modules-71y1gsmg.js} +3 -3
  177. package/dist/{work-objects-w52yyjxm.js → work-objects-3k4ykt9j.js} +25 -25
  178. package/dist/worker-09gqn9xy.js +83 -0
  179. package/dist/{worker-follow-up-dyfxyjbj.js → worker-follow-up-y0h64xpr.js} +22 -22
  180. package/dist/{x-asbrnafg.js → x-d27jj7z7.js} +2 -2
  181. package/openapi.json +861 -33
  182. package/package.json +4 -4
  183. package/src/apps/sync.ts +20 -5
  184. package/src/azure-devops/boards-sync.ts +1 -1
  185. package/src/be/db/approvals.ts +2 -0
  186. package/src/be/db/runtime.ts +5 -0
  187. package/src/be/db/script-run-sources.ts +17 -0
  188. package/src/be/db/slack-trees.ts +12 -1
  189. package/src/be/db/tasks/read.ts +25 -1
  190. package/src/be/db/tasks/write.ts +47 -12
  191. package/src/be/db/users/avatar.ts +12 -0
  192. package/src/be/db-retention.ts +1 -1
  193. package/src/be/db.ts +149 -67
  194. package/src/be/design-system.ts +63 -0
  195. package/src/be/migrations/342_script_run_sources.sql +20 -0
  196. package/src/be/migrations/344_user_avatar.sql +4 -0
  197. package/src/be/migrations/345_task_status_kind.sql +6 -0
  198. package/src/be/migrations/runner.ts +8 -0
  199. package/src/be/migrations/script-run-sources.ts +51 -0
  200. package/src/be/primitives/object-embed.ts +2 -2
  201. package/src/be/primitives/objects.ts +2 -2
  202. package/src/be/rbac-roles.ts +2 -0
  203. package/src/be/runtime-pools/supervisor.ts +1 -0
  204. package/src/be/scripts/typecheck.ts +5 -3
  205. package/src/be/seed-scripts/catalog/design-system-seed.ts +158 -0
  206. package/src/be/seed-scripts/index.ts +9 -0
  207. package/src/be/swarm-config-guard.ts +25 -1
  208. package/src/bitbucket/handlers.ts +1 -1
  209. package/src/commands/credential-outcome-report.ts +96 -0
  210. package/src/commands/onboard/agent-fs-version.ts +1 -1
  211. package/src/commands/runner.ts +49 -3
  212. package/src/event-waits/github.ts +39 -6
  213. package/src/event-waits/index.ts +4 -2
  214. package/src/event-waits/types.ts +10 -3
  215. package/src/extensions/contract-types.generated.ts +1 -1
  216. package/src/github/app.ts +177 -13
  217. package/src/github/handlers.ts +7 -2
  218. package/src/github/pull-request-state.ts +100 -11
  219. package/src/gitlab/handlers.ts +2 -2
  220. package/src/heartbeat/heartbeat.ts +24 -5
  221. package/src/http/all-routes.ts +1 -0
  222. package/src/http/api-keys.ts +26 -0
  223. package/src/http/approval-chat-answer.ts +99 -0
  224. package/src/http/approval-requests.ts +280 -225
  225. package/src/http/asset-key-write.ts +45 -0
  226. package/src/http/assets.ts +4 -3
  227. package/src/http/design-system.ts +103 -0
  228. package/src/http/github-token.ts +27 -6
  229. package/src/http/index.ts +10 -6
  230. package/src/http/pages-public.ts +25 -10
  231. package/src/http/pages.ts +21 -10
  232. package/src/http/person-responder.ts +28 -0
  233. package/src/http/schedules.ts +6 -6
  234. package/src/http/sessions.ts +7 -2
  235. package/src/http/tasks.ts +23 -5
  236. package/src/http/users.ts +5 -0
  237. package/src/http/webhooks.ts +19 -1
  238. package/src/http/workflows.ts +5 -10
  239. package/src/integrations/chat-sdk/adapters.ts +33 -3
  240. package/src/integrations/chat-sdk/commands.ts +3 -1
  241. package/src/integrations/chat-sdk/inbound.ts +6 -18
  242. package/src/integrations/chat-sdk/mentions.ts +188 -0
  243. package/src/integrations/chat-sdk/outbound.ts +20 -3
  244. package/src/integrations/chat-sdk/router.ts +8 -0
  245. package/src/integrations/chat-sdk/telegram-thread.ts +12 -0
  246. package/src/jira/adf.ts +35 -9
  247. package/src/jira/sync.ts +1 -1
  248. package/src/kv-reserved-namespaces.ts +5 -0
  249. package/src/linear/sync.ts +5 -3
  250. package/src/pages/page-head.ts +11 -1
  251. package/src/prompts/session-templates.ts +1 -0
  252. package/src/providers/acp-targets.ts +2 -2
  253. package/src/providers/amp-adapter.ts +1 -1
  254. package/src/providers/claude-adapter.ts +5 -0
  255. package/src/providers/claude-sdk-session.ts +5 -0
  256. package/src/providers/dsh-adapter.ts +48 -13
  257. package/src/providers/runtime-dependencies.ts +1 -1
  258. package/src/rbac/legacy-policy.ts +4 -0
  259. package/src/rbac/permissions.ts +8 -0
  260. package/src/scheduler/deferred-task-waits.ts +74 -13
  261. package/src/scheduler/index.ts +1 -0
  262. package/src/scheduler/scheduler.test.ts +32 -1
  263. package/src/scheduler/scheduler.ts +24 -1
  264. package/src/script-workflows/executor.ts +6 -0
  265. package/src/script-workflows/supervisor.ts +2 -1
  266. package/src/scripts-runtime/sdk-allowlist.ts +2 -0
  267. package/src/scripts-runtime/swarm-sdk.ts +20 -24
  268. package/src/scripts-runtime/types/stdlib.d.ts +12 -2
  269. package/src/scripts-runtime/types/swarm-extension.d.ts +19 -2
  270. package/src/scripts-runtime/types/swarm-sdk.d.ts +12 -2
  271. package/src/server.ts +2 -0
  272. package/src/slack/actions.ts +4 -1
  273. package/src/slack/approval-actions.ts +148 -0
  274. package/src/slack/approval-buttons.ts +28 -0
  275. package/src/slack/render-v2.ts +148 -7
  276. package/src/tests/api-drain-worker-e2e.test.ts +0 -2
  277. package/src/tests/approval-auto-cancellation-migration.test.ts +8 -19
  278. package/src/tests/approval-card-resolution.test.ts +2 -17
  279. package/src/tests/approval-requests-notifications.test.ts +41 -27
  280. package/src/tests/approval-requests.test.ts +137 -369
  281. package/src/tests/apps-sync-engine.test.ts +5 -3
  282. package/src/tests/apps-table-filters-migration.test.ts +44 -25
  283. package/src/tests/bitbucket-handlers.test.ts +2 -0
  284. package/src/tests/chat-sdk-commands.test.ts +1 -0
  285. package/src/tests/chat-sdk-mentions.test.ts +183 -0
  286. package/src/tests/claude-adapter.test.ts +35 -0
  287. package/src/tests/codex-adapter.test.ts +3 -92
  288. package/src/tests/codex-gpt6-release.test.ts +0 -9
  289. package/src/tests/codex-oauth-credential-info.test.ts +35 -18
  290. package/src/tests/codex-oauth.test.ts +0 -6
  291. package/src/tests/codex-pool.test.ts +5 -214
  292. package/src/tests/codex-rate-limit-parse.test.ts +0 -7
  293. package/src/tests/codex-swarm-events.test.ts +11 -54
  294. package/src/tests/create-page-tool.test.ts +5 -0
  295. package/src/tests/db-client-busy-retry.test.ts +49 -16
  296. package/src/tests/defer-task.test.ts +1 -0
  297. package/src/tests/dsh-adapter.test.ts +53 -1
  298. package/src/tests/e2e-shards.test.ts +9 -9
  299. package/src/tests/enabled-tools.test.ts +0 -2
  300. package/src/tests/fixtures/base-prompt-baseline.json +6 -6
  301. package/src/tests/fixtures/compiled-source-schema-boot.ts +24 -0
  302. package/src/tests/fixtures/secret-corpus.ts +43 -1
  303. package/src/tests/github-app-worker-auth-helper.test.ts +147 -1
  304. package/src/tests/gitlab-handlers.test.ts +2 -0
  305. package/src/tests/heartbeat-jev-gate.test.ts +9 -241
  306. package/src/tests/heartbeat-reroute-decision.test.ts +2 -0
  307. package/src/tests/heartbeat-stall-thresholds.test.ts +174 -0
  308. package/src/tests/heartbeat-supersede-resume.test.ts +2 -0
  309. package/src/tests/heartbeat.test.ts +1 -0
  310. package/src/tests/jira-adf.test.ts +42 -2
  311. package/src/tests/key-usage-selection.test.ts +302 -0
  312. package/src/tests/memory-e2e.test.ts +34 -103
  313. package/src/tests/memory-key-paths.test.ts +5 -0
  314. package/src/tests/memory-rater-llm.test.ts +33 -149
  315. package/src/tests/memory-store.test.ts +24 -125
  316. package/src/tests/memory.test.ts +31 -100
  317. package/src/tests/merge-gate-detect-changes.test.ts +314 -16
  318. package/src/tests/migration-342-script-run-sources.test.ts +196 -0
  319. package/src/tests/migration-bunfs-compat.test.ts +129 -9
  320. package/src/tests/otel-service-name.test.ts +0 -9
  321. package/src/tests/otel-session-cost-metrics.test.ts +1 -38
  322. package/src/tests/pool-session-logs.test.ts +8 -42
  323. package/src/tests/pre-push-affected-tests.test.ts +106 -0
  324. package/src/tests/prompt-template-session.test.ts +3 -0
  325. package/src/tests/rbac-e2e-helpers.test.ts +10 -4
  326. package/src/tests/rbac-e2e-helpers.ts +13 -4
  327. package/src/tests/rbac-roles.test.ts +2 -0
  328. package/src/tests/runner-api-drain.test.ts +2 -17
  329. package/src/tests/runner-terminal-window-report.test.ts +132 -0
  330. package/src/tests/runtime-e2b-pools.test.ts +7 -1
  331. package/src/tests/runtime-supervisor-failures.test.ts +1 -0
  332. package/src/tests/sandboxed-process.test.ts +26 -21
  333. package/src/tests/schedule-http-triage-tools.test.ts +12 -9
  334. package/src/tests/schedule-target-type.test.ts +4 -1
  335. package/src/tests/scheduled-tasks.test.ts +14 -51
  336. package/src/tests/script-connections.test.ts +2 -0
  337. package/src/tests/script-executor-conformance.test.ts +4 -48
  338. package/src/tests/script-executor-quickjs-pool.test.ts +9 -7
  339. package/src/tests/script-native-startup.test.ts +21 -25
  340. package/src/tests/script-runs-retention.test.ts +43 -16
  341. package/src/tests/script-workflows-runtime-e2e.test.ts +56 -22
  342. package/src/tests/scripts-http.test.ts +9 -3
  343. package/src/tests/sdk-allowlist.test.ts +26 -13
  344. package/src/tests/sdk-store-progress-skipped.test.ts +12 -5
  345. package/src/tests/secret-rules.test.ts +38 -2
  346. package/src/tests/secret-scrub-gate.test.ts +7 -0
  347. package/src/tests/secret-scrubber.test.ts +62 -2
  348. package/src/tests/seed-scripts.test.ts +2 -2
  349. package/src/tests/session-logs.test.ts +1 -260
  350. package/src/tests/slack-render-v2.test.ts +5 -148
  351. package/src/tests/system-one-hosts-ui-mirror.test.ts +1 -0
  352. package/src/tests/task-cascade-fail.test.ts +1 -0
  353. package/src/tests/task-supersede-resume.test.ts +1 -0
  354. package/src/tests/test-proc.ts +5 -2
  355. package/src/tests/vcs-azure-devops.test.ts +10 -0
  356. package/src/tests/vcs-provider.test.ts +8 -0
  357. package/src/tests/window-stream-reporter.test.ts +122 -0
  358. package/src/tests/workflow-agent-task-retry.test.ts +1 -3
  359. package/src/tests/workflow-cascade-cancel.test.ts +1 -0
  360. package/src/tests/workflow-retry-v2.test.ts +34 -43
  361. package/src/tests/workflow-retry-validation.test.ts +8 -48
  362. package/src/tests/worktree-reaper.test.ts +2 -2
  363. package/src/themes/design-system.ts +163 -0
  364. package/src/themes/page-theme.ts +28 -19
  365. package/src/tools/cancel-task.ts +2 -2
  366. package/src/tools/chat-post.ts +7 -3
  367. package/src/tools/create-page.ts +3 -0
  368. package/src/tools/defer-task.ts +7 -2
  369. package/src/tools/design-system.ts +102 -0
  370. package/src/tools/get-task-details.ts +8 -4
  371. package/src/tools/get-tasks.ts +13 -2
  372. package/src/tools/manage-user.ts +9 -0
  373. package/src/tools/mcp-servers/mcp-server-get.ts +1 -1
  374. package/src/tools/mcp-servers/mcp-server-list.ts +1 -1
  375. package/src/tools/register-chat-channel.ts +11 -2
  376. package/src/tools/skills/skill-get-file.ts +1 -1
  377. package/src/tools/skills/skill-get.ts +1 -1
  378. package/src/tools/skills/skill-list.ts +1 -1
  379. package/src/tools/skills/skill-search.ts +1 -1
  380. package/src/tools/store-progress.ts +5 -3
  381. package/src/tools/utils.ts +49 -4
  382. package/src/tools/workflows/get-workflow-run.ts +1 -1
  383. package/src/tools/workflows/get-workflow.ts +1 -1
  384. package/src/tools/workflows/list-workflow-runs.ts +1 -1
  385. package/src/tools/workflows/list-workflows.ts +1 -1
  386. package/src/types.ts +158 -0
  387. package/src/utils/constants.ts +12 -0
  388. package/src/utils/credentials.ts +42 -5
  389. package/src/utils/error-tracker.ts +6 -0
  390. package/src/utils/key-usage.ts +114 -0
  391. package/src/utils/sandboxed-process.ts +1 -0
  392. package/src/utils/secret-rules.generated.ts +149 -149
  393. package/src/utils/secret-scrubber.ts +111 -5
  394. package/src/vcs/azure-devops.ts +22 -1
  395. package/src/vcs/index.ts +3 -1
  396. package/src/workflows/approval-inline.ts +122 -0
  397. package/src/workflows/approval-notifications.ts +7 -2
  398. package/src/workflows/engine.ts +6 -5
  399. package/src/workflows/executors/agent-task.ts +14 -0
  400. package/src/workflows/executors/system-one-providers.ts +23 -0
  401. package/src/workflows/resume.ts +5 -2
  402. package/templates/skills/apps/SKILL.md +2 -0
  403. package/templates/skills/apps/content.md +2 -0
  404. package/templates/skills/boards-and-sheets/content.md +4 -2
  405. package/templates/skills/pages/content.md +41 -8
  406. package/templates/skills/swarm-docs/content.md +6 -0
  407. package/templates/skills/swarm-scripts/SKILL.md +1 -0
  408. package/templates/skills/swarm-scripts/content.md +1 -0
  409. package/templates/skills/workflow-iterate/content.md +1 -1
  410. package/dist/acp-adapter-t2q6nsqv.js +0 -17
  411. package/dist/cli-kh973792.js +0 -98
  412. package/dist/core-nheayfgm.js +0 -42
  413. package/dist/fx-adapter-8g7xsp8q.js +0 -20
  414. package/dist/grok-adapter-ztk2zkz1.js +0 -20
  415. package/dist/handlers-9ywssz71.js +0 -41
  416. package/dist/index-6mgbdtv1.js +0 -44
  417. package/dist/index-hqdsn2t2.js +0 -39
  418. package/dist/index-st231bqv.js +0 -40
  419. package/dist/lead-mk0xkth2.js +0 -82
  420. package/dist/thread-buffer-d50rqpev.js +0 -42
  421. package/dist/worker-662x1vse.js +0 -82
  422. package/src/tests/apps-table-selection-migration.test.ts +0 -95
  423. package/src/tests/extensions-example-heartbeat-remediate.test.ts +0 -69
  424. package/src/tests/extensions-example-rewrite-and-suppress.test.ts +0 -70
@@ -0,0 +1,158 @@
1
+ import { z } from "zod";
2
+
3
+ export const argsSchema = z.object({
4
+ url: z.string().optional().describe("Site to read the brand from, for example https://www.agent-swarm.dev"),
5
+ css: z.string().optional().describe("A pasted CSS variable block (shadcn, tweakcn, Tailwind v4)"),
6
+ preset: z.string().optional().describe("A preset id, for example hive or paper"),
7
+ pdfUrl: z.string().optional().describe("A brand PDF. Not supported yet: extract its CSS and pass css"),
8
+ basePreset: z.string().optional().describe("Preset the extracted tokens apply on top of (default hive)"),
9
+ mode: z.enum(["viewer", "light", "dark"]).optional().describe("Mode lock (default viewer)"),
10
+ logo: z.object({ url: z.string(), alt: z.string() }).optional().describe("https logo URL and alt text"),
11
+ fontsHref: z.string().optional().describe("Google Fonts stylesheet URL; a url seed reads it from the site"),
12
+ chartPalette: z.array(z.string()).optional().describe("Ordered chart series colors"),
13
+ save: z.boolean().optional().describe("Save the design system after the preview. Only once the requester approved it"),
14
+ });
15
+
16
+ const LIGHT = new Set([":root", ":host", "html"]);
17
+ const DARK = new Set([".dark", ":root.dark", "html.dark", "[data-theme=dark]", '[data-theme="dark"]']);
18
+ /** The token contract names in their shadcn, bare and `--color-` spellings. Tailwind palette stops stay out. */
19
+ const CONTRACT_NAME =
20
+ /^--(?:color-)?(?:background|foreground|card|surface|popover|primary|secondary|muted|accent|destructive|border|input|ring|chart-\d|status-[a-z]+)(?:-(?:foreground|subtle|strong|solid))?$|^--font-(?:sans|mono)$|^--radius(?:-(?:sm|md|lg|xl))?$/;
21
+ const MAX_STYLESHEETS = 8;
22
+
23
+ function escapeHtml(value: string): string {
24
+ return value.replace(/[&<>"']/g, (c: string) => `&#${c.charCodeAt(0)};`);
25
+ }
26
+
27
+ /** The contract declarations of every light and dark theme block, as one clean CSS block per mode. */
28
+ function themeCss(css: string): string {
29
+ const light: string[] = [];
30
+ const dark: string[] = [];
31
+ for (const match of css.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
32
+ const parts = (match[1] ?? "").split(",").map((part: string) => part.trim());
33
+ const target = parts.every((p: string) => LIGHT.has(p)) ? light : parts.every((p: string) => DARK.has(p)) ? dark : null;
34
+ if (!target) continue;
35
+ for (const declaration of (match[2] ?? "").split(";")) {
36
+ const colon = declaration.indexOf(":");
37
+ const name = declaration.slice(0, colon).trim();
38
+ if (colon > 0 && CONTRACT_NAME.test(name)) target.push(`${name}: ${declaration.slice(colon + 1).trim()};`);
39
+ }
40
+ }
41
+ return [light.length ? `:root { ${light.join(" ")} }` : "", dark.length ? `.dark { ${dark.join(" ")} }` : ""]
42
+ .filter(Boolean)
43
+ .join("\n");
44
+ }
45
+
46
+ async function readSite(url: string, ctx: any): Promise<{ css: string; fontsHref?: string }> {
47
+ const html = await (await ctx.stdlib.fetch(url, { headers: { Accept: "text/html" } })).text();
48
+ const hrefs: string[] = [];
49
+ let fontsHref: string | undefined;
50
+ for (const tag of html.match(/<link\b[^>]*>/gi) ?? []) {
51
+ const href = tag.match(/href=["']([^"']+)["']/i)?.[1]?.replace(/&amp;/g, "&");
52
+ if (!href || !/rel=["']?stylesheet/i.test(tag)) continue;
53
+ if (href.startsWith("https://fonts.googleapis.com/")) fontsHref ??= href;
54
+ else hrefs.push(new URL(href, url).href);
55
+ }
56
+ const sheets = await Promise.all(
57
+ hrefs.slice(0, MAX_STYLESHEETS).map(async (href) => (await ctx.stdlib.fetch(href)).text()),
58
+ );
59
+ const inline = (html.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi) ?? []).map((s: string) => s.replace(/<\/?style\b[^>]*>/gi, ""));
60
+ return { css: themeCss([...inline, ...sheets].join("\n")), fontsHref };
61
+ }
62
+
63
+ function previewHtml(record: any, ignored: string[]): string {
64
+ const names = [...new Set([...Object.keys(record.tokens.light), ...Object.keys(record.tokens.dark)])].sort();
65
+ const rows = names
66
+ .map((name) => {
67
+ const light = record.tokens.light[name] ?? "";
68
+ const dark = record.tokens.dark[name] ?? "";
69
+ const swatch = name.startsWith("--color-") ? `<span class="swarm-badge" data-dot style="--swarm-dot: var(${name})">${escapeHtml(name)}</span>` : escapeHtml(name);
70
+ return `<tr><td class="nowrap">${swatch}</td><td>${escapeHtml(light)}</td><td>${escapeHtml(dark)}</td></tr>`;
71
+ })
72
+ .join("");
73
+ const palette = (record.chartPalette ?? [])
74
+ .map((color: string) => `<span class="swarm-badge" data-dot style="--swarm-dot: ${escapeHtml(color)}">${escapeHtml(color)}</span>`)
75
+ .join(" ");
76
+ return `<!doctype html><html><head><meta charset="utf-8"><title>Design system preview</title>
77
+ ${record.fontsHref ? `<link href="${escapeHtml(record.fontsHref)}" rel="stylesheet">` : ""}</head>
78
+ <body><main class="swarm-page">
79
+ ${record.logo ? `<img src="${escapeHtml(record.logo.url)}" alt="${escapeHtml(record.logo.alt)}" style="height:40px;width:auto">` : ""}
80
+ <p class="swarm-eyebrow">Design system preview · ${escapeHtml(record.source.kind)}${record.source.ref ? ` · ${escapeHtml(record.source.ref)}` : ""}</p>
81
+ <h1>Every page will look like this</h1>
82
+ <p class="swarm-lede">Base preset ${escapeHtml(record.basePreset)}, mode ${escapeHtml(record.mode)}. Nothing is saved until the requester approves it.</p>
83
+ <div class="swarm-metrics">
84
+ <div class="swarm-metric"><div class="swarm-metric-value">${names.length}</div><div class="swarm-metric-label">Tokens set</div></div>
85
+ <div class="swarm-metric" data-tone="success"><div class="swarm-metric-value">98.2%</div><div class="swarm-metric-label">Sample success rate</div></div>
86
+ <div class="swarm-metric" data-tone="error"><div class="swarm-metric-value">3</div><div class="swarm-metric-label">Sample failures</div></div>
87
+ </div>
88
+ <section class="swarm-section"><h2>Components</h2>
89
+ <p><button class="swarm-button" data-variant="primary" type="button">Primary action</button> <button class="swarm-button" type="button">Secondary</button></p>
90
+ <p><span class="swarm-badge" data-tone="success" data-dot>Healthy</span> <span class="swarm-badge" data-tone="warning" data-dot>Degraded</span> <span class="swarm-badge" data-tone="error" data-dot>Down</span></p>
91
+ <div class="swarm-callout">A callout reads like this. <a href="#tokens">Links use the primary color.</a></div>
92
+ ${palette ? `<p>Chart palette: ${palette}</p>` : ""}
93
+ </section>
94
+ <section class="swarm-section" id="tokens"><h2>Tokens</h2>
95
+ <div class="swarm-table-wrap"><table class="swarm-table"><thead><tr><th>Token</th><th>Light</th><th>Dark</th></tr></thead><tbody>${rows || '<tr><td colspan="3">The base preset only.</td></tr>'}</tbody></table></div>
96
+ ${ignored.length ? `<details><summary>${ignored.length} ignored names</summary><p>${escapeHtml(ignored.join(", "))}</p></details>` : ""}
97
+ </section></main></body></html>`;
98
+ }
99
+
100
+ /** Build an org design system from a site URL, a CSS block or a preset, publish a preview page, and save it once approved. */
101
+ export default async function designSystemSeed(args: any, ctx: any) {
102
+ const parsed = argsSchema.safeParse(args ?? {});
103
+ if (!parsed.success) return { error: "invalid args: " + parsed.error.message };
104
+ const a = parsed.data;
105
+ const inputs = [a.url, a.css, a.preset, a.pdfUrl].filter((value) => value !== undefined);
106
+ if (inputs.length !== 1) return { error: "pass exactly one of url, css, preset or pdfUrl" };
107
+ // shortcut: no brand-PDF extraction (taste-engine extract_brand_kit is not wired), add it when a requester sends a PDF.
108
+ if (a.pdfUrl) return { error: "brand PDFs are not supported yet: extract the CSS variables and pass css" };
109
+
110
+ let css = a.css;
111
+ let fontsHref = a.fontsHref;
112
+ let source: any = { kind: "manual" };
113
+ if (a.url) {
114
+ if (!/^https?:\/\//i.test(a.url)) return { error: "url must be an absolute http(s) URL" };
115
+ const site = await readSite(a.url, ctx);
116
+ if (!site.css) return { error: `no :root or .dark custom properties found on ${a.url}` };
117
+ css = site.css;
118
+ fontsHref ??= site.fontsHref;
119
+ source = { kind: "website", ref: a.url, extractedAt: new Date().toISOString() };
120
+ }
121
+ if (a.preset) source = { kind: "preset", ref: a.preset };
122
+
123
+ const input = {
124
+ basePreset: a.preset ?? a.basePreset,
125
+ ...(css ? { themeTokens: { format: "css", css } } : {}),
126
+ ...(fontsHref ? { fontsHref } : {}),
127
+ ...(a.logo ? { logo: a.logo } : {}),
128
+ ...(a.mode ? { mode: a.mode } : {}),
129
+ ...(a.chartPalette ? { chartPalette: a.chartPalette } : {}),
130
+ source,
131
+ };
132
+ const checked: any = await ctx.swarm.designSystem_set({ ...input, dryRun: true });
133
+ const draft = checked?.data ?? checked;
134
+ if (draft?.success === false || !draft?.designSystem) return { error: draft?.message ?? "design system validation failed" };
135
+ const record = draft.designSystem;
136
+ const ignored: string[] = draft.ignoredTokens ?? [];
137
+
138
+ const page: any = await ctx.swarm.page_create({
139
+ title: "Design system preview",
140
+ slug: "design-system-preview",
141
+ contentType: "text/html",
142
+ body: previewHtml(record, ignored),
143
+ theme: record.basePreset,
144
+ themeTokens: { light: record.tokens.light, dark: record.tokens.dark },
145
+ designVersion: 2,
146
+ });
147
+ const pageData = page?.data ?? page;
148
+ if (a.save) await ctx.swarm.designSystem_set(input);
149
+ return {
150
+ saved: a.save === true,
151
+ previewUrl: pageData?.app_url ?? null,
152
+ previewApiUrl: pageData?.api_url ?? null,
153
+ designSystem: record,
154
+ ignoredTokens: ignored,
155
+ // Pass this to design-system-set (or rerun with save: true) once the requester approves.
156
+ saveInput: input,
157
+ };
158
+ }
@@ -30,6 +30,7 @@ import completeTaskSrc from "./catalog/complete-task.ts" with { type: "text" };
30
30
  import compoundInsightsSrc from "./catalog/compound-insights.inline.ts" with { type: "text" };
31
31
  import dateResolveSrc from "./catalog/date-resolve.ts" with { type: "text" };
32
32
  import delegateSrc from "./catalog/delegate.ts" with { type: "text" };
33
+ import designSystemSeedSrc from "./catalog/design-system-seed.ts" with { type: "text" };
33
34
  import dreamingApplySrc from "./catalog/dreaming-apply.ts" with { type: "text" };
34
35
  import dreamingGatherSrc from "./catalog/dreaming-gather.ts" with { type: "text" };
35
36
  import dreamingHeartbeatSrc from "./catalog/dreaming-heartbeat.ts" with { type: "text" };
@@ -142,6 +143,14 @@ export const SEED_SCRIPTS: SeedScript[] = [
142
143
  "Read the actual content of a URL without wading through raw HTML; readable-article / reader-mode extraction.",
143
144
  source: asText(fetchReadableSrc),
144
145
  },
146
+ {
147
+ name: "design-system-seed",
148
+ description:
149
+ "Build the org design system from a site URL, a pasted CSS variable block or a preset, publish a preview page in the swarm look, and save it with save: true once the requester approves.",
150
+ intent:
151
+ "Seed or rebrand the org design system / page theme / brand colors and fonts from a website or shadcn CSS, with a preview before saving.",
152
+ source: asText(designSystemSeedSrc),
153
+ },
145
154
  {
146
155
  name: "json-query",
147
156
  description:
@@ -21,6 +21,7 @@ import {
21
21
  parseFollowUpGateScheduleIds,
22
22
  } from "../utils/follow-up-gate-schedule-ids";
23
23
  import { kindForModelString } from "../utils/internal-ai/models";
24
+ import { CREDENTIAL_SELECTION_STRATEGIES } from "../utils/key-usage";
24
25
  import { normalizeOrgWebsite } from "../utils/org-website";
25
26
  import { parseTaskToolManifest } from "../utils/task-tool-manifest";
26
27
  import { isTierConfigKey, validateTierConfigValue } from "./model-tier-keys";
@@ -82,6 +83,8 @@ const RESERVED_KEYS = new Set([
82
83
  "GITHUB_API_URL",
83
84
  // Picks which App installation workers get tokens for; a config writer must not choose it.
84
85
  "GITHUB_APP_INSTALLATION_ID",
86
+ // Owners whose repos get a token for their own installation; same reason.
87
+ "GITHUB_APP_REPO_OWNERS",
85
88
  ]);
86
89
 
87
90
  // Config keys the API server owns for its own use and must NEVER hand out over
@@ -214,6 +217,18 @@ export const APPS_JSON_COLUMN_MAX_BYTES_BOUNDS = { min: 1_024, max: 16_777_216 }
214
217
  */
215
218
  export const CODEX_OAUTH_KEEP_WARM_MAX_AGE_HOURS_BOUNDS = { min: 1, max: 216 } as const;
216
219
 
220
+ /**
221
+ * Bounds for the scheduler polling interval (`SCHEDULER_INTERVAL_MS`).
222
+ *
223
+ * `src/scheduler/scheduler.ts` parses the boot value against exactly these
224
+ * bounds at call time and falls back to its 10-second default outside them, and
225
+ * VALIDATED_KEYS rejects out-of-range writes with the same numbers, so the config
226
+ * API cannot accept a tick the scheduler would silently replace. The 2^31-1 ms
227
+ * ceiling is the largest delay a 32-bit timer honours: `setInterval` clamps a
228
+ * larger one to 1 ms, the tight loop a non-positive delay already causes (#3169).
229
+ */
230
+ export const SCHEDULER_INTERVAL_MS_BOUNDS = { min: 1, max: 2_147_483_647 } as const;
231
+
217
232
  /**
218
233
  * Decision hosts `SYSTEM_ONE_DEFAULT_PROVIDER` may name: `SYSTEM_ONE_PROVIDER_IDS`
219
234
  * in `src/workflows/executors/system-one-providers.ts`, listed here because that
@@ -549,6 +564,7 @@ const VALIDATED_KEYS: Record<string, ConfigValidator> = {
549
564
  // fail: worker fails a task fast when every key has exhausted the task
550
565
  // model's weekly window (Fable/Opus/Sonnet). fallback: legacy random pick.
551
566
  ...enumValidator("MODEL_WINDOW_EXHAUSTED_POLICY", ["fail", "fallback"]),
567
+ ...enumValidator("CREDENTIAL_SELECTION_STRATEGY", [...CREDENTIAL_SELECTION_STRATEGIES]),
552
568
  ...enumValidator("HEARTBEAT_CHECKLIST_GATE_MODE", ["shadow", "enforce"]),
553
569
  // `enforce` is deliberately absent: the follow-up gate only records decisions.
554
570
  ...enumValidator("FOLLOW_UP_GATE_MODE", ["off", "shadow"]),
@@ -694,7 +710,6 @@ const VALIDATED_KEYS: Record<string, ConfigValidator> = {
694
710
  "RBAC_AUDIT_RETENTION_DAYS",
695
711
  "WORKFLOW_MAX_ITERATIONS",
696
712
  "WORKFLOW_MAX_STEPS_PER_RUN",
697
- "SCHEDULER_INTERVAL_MS",
698
713
  "EXTENSION_HANDLER_TIMEOUT_MS",
699
714
  "EXTENSION_MAX_CONSECUTIVE_FAILURES",
700
715
  "RUNTIME_STALE_THRESHOLD_MIN",
@@ -724,6 +739,15 @@ const VALIDATED_KEYS: Record<string, ConfigValidator> = {
724
739
  APPS_JSON_COLUMN_MAX_BYTES_BOUNDS.min,
725
740
  APPS_JSON_COLUMN_MAX_BYTES_BOUNDS.max,
726
741
  ),
742
+ // The scheduler tick is bounded at both ends, and src/scheduler/scheduler.ts
743
+ // parses the boot value against the same range: a delay above the timer ceiling
744
+ // fires after 1 ms, so accepting it would leave the scheduler polling at full
745
+ // speed while the saved value claimed otherwise.
746
+ ...boundedIntegerValidators(
747
+ ["SCHEDULER_INTERVAL_MS"],
748
+ SCHEDULER_INTERVAL_MS_BOUNDS.min,
749
+ SCHEDULER_INTERVAL_MS_BOUNDS.max,
750
+ ),
727
751
  // Worker worktree reaper (src/commands/worktree-reaper.ts clamps to the same ranges).
728
752
  ...enumValidator("WORKTREE_REAPER_MODE", ["off", "dry-run", "on"]),
729
753
  ...boundedIntegerValidators(["WORKTREE_TTL_HOURS"], 1, 2160),
@@ -430,7 +430,7 @@ export async function handlePullRequestClosed(
430
430
  const reason = outcome === "merged" ? "PR was merged" : "PR was declined";
431
431
  for (const task of await findActiveTasksByVcs(repository.full_name, pr.id, "bitbucket")) {
432
432
  console.log(`[Bitbucket] Cancelling task ${task.id} — ${reason}`);
433
- await failTask(task.id, reason);
433
+ await failTask(task.id, reason, { statusKind: "external" });
434
434
  }
435
435
  return { created: false };
436
436
  }
@@ -103,6 +103,102 @@ export async function reportKeyRateLimitWindows(
103
103
  }
104
104
  }
105
105
 
106
+ /** Server terminal statuses whose finished session still reports its window telemetry. */
107
+ const TELEMETRY_TERMINAL_STATUSES = new Set(["completed", "failed"]);
108
+
109
+ /**
110
+ * Reports the window snapshot of a session whose task the server already
111
+ * holds as `completed` or `failed` (the agent finished the task before its
112
+ * session ended). The server result stands, so no outcome and no `finish`:
113
+ * only the provider usage the session observed. Fire-and-forget; returns the
114
+ * settled report so a test can await it. Never throws.
115
+ */
116
+ export function reportTerminalSessionWindows(input: {
117
+ apiUrl: string;
118
+ apiKey: string;
119
+ credentialInfo?: { keyType: string; keySuffix: string; keyIndex: number };
120
+ serverTerminalStatus: string;
121
+ rateLimitWindows?: RateLimitWindowTelemetry;
122
+ }): Promise<void> {
123
+ const { credentialInfo, rateLimitWindows } = input;
124
+ if (
125
+ !credentialInfo ||
126
+ !TELEMETRY_TERMINAL_STATUSES.has(input.serverTerminalStatus) ||
127
+ !rateLimitWindows ||
128
+ Object.keys(rateLimitWindows).length === 0
129
+ ) {
130
+ return Promise.resolve();
131
+ }
132
+ return reportKeyRateLimitWindows(
133
+ input.apiUrl,
134
+ input.apiKey,
135
+ credentialInfo.keyType,
136
+ credentialInfo.keySuffix,
137
+ credentialInfo.keyIndex,
138
+ rateLimitWindows,
139
+ ).catch((err) => {
140
+ console.warn(
141
+ `[credential] Failed to report rate-limit windows: ${err instanceof Error ? err.message : String(err)}`,
142
+ );
143
+ });
144
+ }
145
+
146
+ /**
147
+ * Throttles mid-session window reports. A snapshot goes out when it carries a
148
+ * window the last report did not, when any window's utilization moved by
149
+ * `minDeltaPoints` percentage points or more, or when `minIntervalMs` passed.
150
+ * `post` is fire-and-forget: a rejection is logged, never thrown, and a
151
+ * failed report does not count as sent.
152
+ */
153
+ export function createWindowStreamReporter(opts: {
154
+ post: (windows: RateLimitWindowTelemetry) => Promise<void>;
155
+ minDeltaPoints?: number;
156
+ minIntervalMs?: number;
157
+ now?: () => number;
158
+ }): (windows: RateLimitWindowTelemetry) => void {
159
+ const minDelta = (opts.minDeltaPoints ?? 5) / 100;
160
+ const minIntervalMs = opts.minIntervalMs ?? 60_000;
161
+ const now = opts.now ?? Date.now;
162
+ let lastSentAt: number | undefined;
163
+ let lastSent: Record<string, number | undefined> = {};
164
+
165
+ const due = (windows: RateLimitWindowTelemetry, at: number): boolean => {
166
+ if (lastSentAt === undefined || at - lastSentAt >= minIntervalMs) return true;
167
+ return Object.entries(windows).some(([key, window]) => {
168
+ if (!(key in lastSent)) return true;
169
+ const before = lastSent[key];
170
+ const after = window.utilization;
171
+ if (before === undefined || after === undefined) return before !== after;
172
+ return Math.abs(after - before) >= minDelta - 1e-9;
173
+ });
174
+ };
175
+
176
+ return (windows) => {
177
+ if (Object.keys(windows).length === 0) return;
178
+ const at = now();
179
+ if (!due(windows, at)) return;
180
+ const previous = { sentAt: lastSentAt, sent: lastSent };
181
+ lastSentAt = at;
182
+ lastSent = Object.fromEntries(Object.entries(windows).map(([k, w]) => [k, w.utilization]));
183
+ let report: Promise<void>;
184
+ try {
185
+ report = opts.post(windows);
186
+ } catch (err) {
187
+ report = Promise.reject(err);
188
+ }
189
+ report.catch((err) => {
190
+ // Retry on the next event rather than wait out the interval.
191
+ if (lastSentAt === at) {
192
+ lastSentAt = previous.sentAt;
193
+ lastSent = previous.sent;
194
+ }
195
+ console.warn(
196
+ `[credential] Failed to stream rate-limit windows: ${err instanceof Error ? err.message : String(err)}`,
197
+ );
198
+ });
199
+ };
200
+ }
201
+
106
202
  export interface CredentialOutcomeInput {
107
203
  apiUrl: string;
108
204
  apiKey: string;
@@ -2,4 +2,4 @@
2
2
  * agent-fs image tag bundled by `agent-swarm onboard --yes`.
3
3
  * `bun run bump:agent-fs` rewrites it together with the other pins.
4
4
  */
5
- export const AGENT_FS_VERSION = "0.18.29";
5
+ export const AGENT_FS_VERSION = "0.18.33";
@@ -97,7 +97,11 @@ import {
97
97
  normalizeProviderKeyAliases,
98
98
  resolveCredentialPools,
99
99
  } from "../utils/credentials.ts";
100
- import { resolveCodexCreditsExhaustedCooldownMs } from "../utils/error-tracker.ts";
100
+ import {
101
+ RATE_LIMIT_WINDOWS_EVENT,
102
+ type RateLimitWindowTelemetry,
103
+ resolveCodexCreditsExhaustedCooldownMs,
104
+ } from "../utils/error-tracker.ts";
101
105
  import { isGitHubUrl, scopeGitHubTokenToEnterprise } from "../utils/github-host";
102
106
  import { probeHarnessCliVersion, reportHarnessModelOutcome } from "../utils/harness-cli-version.ts";
103
107
  import { resolveHarnessProvider } from "../utils/harness-provider.ts";
@@ -130,7 +134,12 @@ import {
130
134
  buildResumeContextPreamble,
131
135
  prependContextPreamble,
132
136
  } from "./context-preamble.ts";
133
- import { reportCredentialOutcomeThenFinish } from "./credential-outcome-report.ts";
137
+ import {
138
+ createWindowStreamReporter,
139
+ reportCredentialOutcomeThenFinish,
140
+ reportKeyRateLimitWindows,
141
+ reportTerminalSessionWindows,
142
+ } from "./credential-outcome-report.ts";
134
143
  import {
135
144
  type CredentialRefreshState,
136
145
  credentialFingerprint,
@@ -4494,6 +4503,10 @@ function providerEventAttributes(event: ProviderEvent): Attributes {
4494
4503
  "agentswarm.context.total_tokens": event.contextTotalTokens,
4495
4504
  };
4496
4505
  case "custom":
4506
+ // A window snapshot can carry seat billing fields: keep it off the span.
4507
+ if (event.name === RATE_LIMIT_WINDOWS_EVENT) {
4508
+ return { "agentswarm.provider.event_name": event.name };
4509
+ }
4497
4510
  return {
4498
4511
  "agentswarm.provider.event_name": event.name,
4499
4512
  "agentswarm.provider.event_data_preview": telemetryPreview(event.data),
@@ -5068,10 +5081,33 @@ export async function spawnProviderProcess(
5068
5081
  }
5069
5082
  }
5070
5083
 
5084
+ // Mid-session window snapshots, throttled: the pool view stays fresh while a
5085
+ // long session runs, and a crash loses less than the whole session.
5086
+ const streamWindows =
5087
+ credentialInfo && opts.apiUrl
5088
+ ? createWindowStreamReporter({
5089
+ post: (windows) =>
5090
+ reportKeyRateLimitWindows(
5091
+ opts.apiUrl,
5092
+ opts.apiKey,
5093
+ credentialInfo.keyType,
5094
+ credentialInfo.keySuffix,
5095
+ credentialInfo.keyIndex,
5096
+ windows,
5097
+ false,
5098
+ ),
5099
+ })
5100
+ : undefined;
5101
+
5071
5102
  session.onEvent((event) =>
5072
5103
  withSpanContext(sessionSpan, () => {
5073
5104
  sessionSpan.addEvent(`provider.${event.type}`, providerEventAttributes(event));
5074
5105
  switch (event.type) {
5106
+ case "custom":
5107
+ if (event.name === RATE_LIMIT_WINDOWS_EVENT && streamWindows) {
5108
+ streamWindows(event.data as RateLimitWindowTelemetry);
5109
+ }
5110
+ break;
5075
5111
  case "session_init":
5076
5112
  providerSessionId = event.sessionId;
5077
5113
  pendingHarnessVariant = event.harnessVariant;
@@ -5979,8 +6015,18 @@ export async function checkCompletedProcesses(
5979
6015
  cancelledSignaled?.delete(taskId);
5980
6016
  // The server finished this task without the session (heartbeat sweep,
5981
6017
  // another writer). Its result stands: no finish call, and no credential
5982
- // or model outcome built from the abort this runner forced.
6018
+ // or model outcome built from the abort this runner forced. The usage
6019
+ // windows the session observed are provider facts, so they still go out.
5983
6020
  if (serverTerminalStatus) {
6021
+ if (apiConfig) {
6022
+ void reportTerminalSessionWindows({
6023
+ apiUrl: apiConfig.apiUrl,
6024
+ apiKey: apiConfig.apiKey,
6025
+ credentialInfo,
6026
+ serverTerminalStatus,
6027
+ rateLimitWindows: result.rateLimitWindows,
6028
+ });
6029
+ }
5984
6030
  console.log(
5985
6031
  `[${role}] Task ${taskId.slice(0, 8)} was already ${serverTerminalStatus} server-side — slot released, server result kept`,
5986
6032
  );
@@ -1,7 +1,7 @@
1
1
  import * as z from "zod";
2
2
  import { isGitHubEnabled } from "@/github/app";
3
- import { fetchPullRequestState } from "@/github/pull-request-state";
4
- import type { EventMatch, ExternalEvent, ExternalEventAdapter } from "./types";
3
+ import { fetchPullRequestState, fetchRequiredCheckStates } from "@/github/pull-request-state";
4
+ import type { ConfirmResult, EventMatch, ExternalEvent, ExternalEventAdapter } from "./types";
5
5
 
6
6
  const PrMatch = z
7
7
  .object({ repo: z.string().regex(/^[\w.-]+\/[\w.-]+$/), number: z.number().int().positive() })
@@ -12,11 +12,31 @@ function prMatch(repo: string, number: number): EventMatch {
12
12
  return { repo: repo.toLowerCase(), number };
13
13
  }
14
14
 
15
+ /**
16
+ * Have all required checks finished on the PR's current head? Reads the head SHA
17
+ * fresh, so a push after the candidate check_run makes the answer "not yet".
18
+ */
19
+ async function confirmChecksDone(repo: string, number: number): Promise<ConfirmResult> {
20
+ const pr = await fetchPullRequestState(repo, number);
21
+ if (!pr.headSha || !pr.baseRef)
22
+ throw new Error(`GitHub returned no head or base for ${repo}#${number}`);
23
+ const checks = await fetchRequiredCheckStates(repo, pr.baseRef, pr.headSha);
24
+ const done = checks.every((check) => check.complete);
25
+ return {
26
+ happened: done,
27
+ detail: done
28
+ ? `head ${pr.headSha.slice(0, 12)}, ${checks
29
+ .map((check) => `${check.name}=${check.conclusion} (completed ${check.completedAt})`)
30
+ .join(", ")}`
31
+ : undefined,
32
+ };
33
+ }
34
+
15
35
  export const githubAdapter: ExternalEventAdapter = {
16
36
  source: "github",
17
- events: ["vcs.pr.merged"],
37
+ events: ["vcs.pr.merged", "vcs.pr.checks_done"],
18
38
  matchHint: "repo (owner/name), number",
19
- busPrefix: "github.pull_request.",
39
+ busPrefixes: ["github.pull_request.", "github.check_run."],
20
40
  readsWithServerCredentials: true,
21
41
  isEnabled: isGitHubEnabled,
22
42
  parseMatch(_event, match) {
@@ -27,6 +47,16 @@ export const githubAdapter: ExternalEventAdapter = {
27
47
  return prMatch(parsed.data.repo, parsed.data.number);
28
48
  },
29
49
  fromBusEvent(busEvent, payload): ExternalEvent[] {
50
+ if (busEvent === "github.check_run.completed") {
51
+ // A finished check run names a candidate for each PR it ran on. GitHub leaves
52
+ // `pull_requests` empty for a fork's head; those waits fall to the ceiling.
53
+ const run = payload as { repo?: unknown; pullRequests?: unknown } | null;
54
+ if (typeof run?.repo !== "string" || !Array.isArray(run.pullRequests)) return [];
55
+ const repo = run.repo;
56
+ return run.pullRequests
57
+ .filter((n): n is number => typeof n === "number")
58
+ .map((n) => ({ event: "vcs.pr.checks_done", match: prMatch(repo, n) }));
59
+ }
30
60
  const pr = payload as { repo?: unknown; number?: unknown; merged?: unknown } | null;
31
61
  if (
32
62
  busEvent !== "github.pull_request.closed" ||
@@ -37,7 +67,10 @@ export const githubAdapter: ExternalEventAdapter = {
37
67
  return [];
38
68
  return [{ event: "vcs.pr.merged", match: prMatch(pr.repo, pr.number) }];
39
69
  },
40
- async confirm(_event, match) {
41
- return (await fetchPullRequestState(String(match.repo), Number(match.number))).merged;
70
+ async confirm(event, match) {
71
+ const repo = String(match.repo);
72
+ const number = Number(match.number);
73
+ if (event === "vcs.pr.checks_done") return await confirmChecksDone(repo, number);
74
+ return (await fetchPullRequestState(repo, number)).merged;
42
75
  },
43
76
  };
@@ -16,7 +16,9 @@ export function getExternalEventAdapter(source: string): ExternalEventAdapter |
16
16
  * trusts the event (no `confirm`), or drive confirm reads with server credentials.
17
17
  */
18
18
  export function isReservedProviderEvent(name: string): boolean {
19
- return EXTERNAL_EVENT_ADAPTERS.some((adapter) => name.startsWith(adapter.busPrefix));
19
+ return EXTERNAL_EVENT_ADAPTERS.some((adapter) =>
20
+ adapter.busPrefixes.some((prefix) => name.startsWith(prefix)),
21
+ );
20
22
  }
21
23
 
22
24
  /** Every shared event name some adapter serves, deduplicated. */
@@ -26,4 +28,4 @@ export const EXTERNAL_EVENT_NAMES: [string, ...string[]] = [
26
28
 
27
29
  /** Tool-description line listing the served events; the docs generator reads it as a literal, so keep it in step with the list above. */
28
30
  export const EXTERNAL_EVENTS_DOC =
29
- 'vcs.pr.merged with source "github" and match {repo (owner/name), number}';
31
+ 'vcs.pr.merged or vcs.pr.checks_done (every required check of the base branch ruleset finished on the PR head, any conclusion) with source "github" and match {repo (owner/name), number}';
@@ -12,6 +12,9 @@ export type EventMatch = Record<string, string | number>;
12
12
  /** A provider event reduced to the shared vocabulary (e.g. `vcs.pr.merged`). */
13
13
  export type ExternalEvent = { event: string; match: EventMatch };
14
14
 
15
+ /** A `confirm` answer; `detail` goes into the wake-up cause (e.g. each required check's conclusion). */
16
+ export type ConfirmResult = { happened: boolean; detail?: string };
17
+
15
18
  export interface ExternalEventAdapter {
16
19
  /** Provider id as agents write it in `wakeOn.source`, e.g. `github`. */
17
20
  readonly source: string;
@@ -19,8 +22,8 @@ export interface ExternalEventAdapter {
19
22
  readonly events: readonly string[];
20
23
  /** What `match` holds, for the tool description, e.g. `repo (owner/name), number`. */
21
24
  readonly matchHint: string;
22
- /** `workflowEventBus` name prefix the provider's webhook handler emits under, e.g. `github.`. */
23
- readonly busPrefix: string;
25
+ /** `workflowEventBus` name prefixes the provider's webhook handler emits under, e.g. `github.pull_request.`. */
26
+ readonly busPrefixes: readonly string[];
24
27
  /** True when `confirm` reads with server-held credentials, so task-scoped tokens may not trigger it. */
25
28
  readonly readsWithServerCredentials?: boolean;
26
29
  /** False when the provider integration is off, so no event could ever arrive. */
@@ -35,7 +38,7 @@ export interface ExternalEventAdapter {
35
38
  * the wait fires only on `true`, and boot re-checks pending waits (a delivery
36
39
  * missed while the API was down). Without it, the verified webhook is trusted.
37
40
  */
38
- confirm?(event: string, match: EventMatch): Promise<boolean>;
41
+ confirm?(event: string, match: EventMatch): Promise<boolean | ConfirmResult>;
39
42
  }
40
43
 
41
44
  /** Canonical key for lookup: the same match always yields the same string. */
@@ -49,3 +52,7 @@ export function describeEventWait(source: string, event: string, match: EventMat
49
52
  .join(", ");
50
53
  return `${event} on ${source} (${target})`;
51
54
  }
55
+
56
+ export function toConfirmResult(result: boolean | ConfirmResult): ConfirmResult {
57
+ return typeof result === "boolean" ? { happened: result } : result;
58
+ }