@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,103 @@
1
+ import type { IncomingMessage, ServerResponse } from "node:http";
2
+ import { z } from "zod";
3
+ import { getDesignSystem, type StoredDesignSystem, saveDesignSystem } from "../be/design-system";
4
+ import { can } from "../rbac";
5
+ import { buildDesignSystem, DesignSystemError } from "../themes/design-system";
6
+ import { DesignSystemInputSchema, DesignSystemSchema } from "../types";
7
+ import { agentFirstPrincipal } from "./request-principal";
8
+ import { route } from "./route-def";
9
+ import { jsonError } from "./utils";
10
+
11
+ /**
12
+ * The org design system over REST (src/themes/design-system.ts). The MCP
13
+ * tools `design-system-get` / `design-system-set` share the same storage.
14
+ */
15
+
16
+ const DesignSystemStateSchema = z.object({
17
+ status: z.enum(["none", "invalid", "active", "declined"]),
18
+ designSystem: DesignSystemSchema.nullable(),
19
+ invalidReason: z.string().optional(),
20
+ previous: DesignSystemSchema.nullable(),
21
+ });
22
+
23
+ const getDesignSystemRoute = route({
24
+ method: "get",
25
+ path: "/api/design-system",
26
+ pattern: ["api", "design-system"],
27
+ summary: "Get the org design system",
28
+ tags: ["Pages"],
29
+ responses: {
30
+ 200: {
31
+ description: "The org design system and the value it replaced",
32
+ schema: DesignSystemStateSchema,
33
+ },
34
+ },
35
+ });
36
+
37
+ const putDesignSystemRoute = route({
38
+ method: "put",
39
+ path: "/api/design-system",
40
+ pattern: ["api", "design-system"],
41
+ summary: "Set or decline the org design system",
42
+ tags: ["Pages"],
43
+ rbac: { permission: "design-system.write" },
44
+ body: DesignSystemInputSchema,
45
+ responses: {
46
+ 200: {
47
+ description: "The saved, normalized design system",
48
+ schema: z.object({ designSystem: DesignSystemSchema, ignoredTokens: z.array(z.string()) }),
49
+ },
50
+ 400: { description: "Invalid design system" },
51
+ 403: { description: "Permission denied" },
52
+ },
53
+ });
54
+
55
+ function recordOf(stored: StoredDesignSystem) {
56
+ return "record" in stored ? stored.record : null;
57
+ }
58
+
59
+ export async function handleDesignSystem(
60
+ req: IncomingMessage,
61
+ res: ServerResponse,
62
+ pathSegments: string[],
63
+ queryParams: URLSearchParams,
64
+ myAgentId: string | undefined,
65
+ ): Promise<boolean> {
66
+ if (getDesignSystemRoute.match(req.method, pathSegments)) {
67
+ const parsed = await getDesignSystemRoute.parse(req, res, pathSegments, queryParams);
68
+ if (!parsed) return true;
69
+ const { current, previous } = await getDesignSystem();
70
+ getDesignSystemRoute.respond(res, 200, {
71
+ status: current.status,
72
+ designSystem: recordOf(current),
73
+ ...("reason" in current ? { invalidReason: current.reason } : {}),
74
+ previous: recordOf(previous),
75
+ });
76
+ return true;
77
+ }
78
+
79
+ if (putDesignSystemRoute.match(req.method, pathSegments)) {
80
+ const parsed = await putDesignSystemRoute.parse(req, res, pathSegments, queryParams);
81
+ if (!parsed) return true;
82
+ const principal = await agentFirstPrincipal(req, myAgentId);
83
+ const decision = can({ principal, verb: "design-system.write", source: "http" });
84
+ if (!decision.allow) {
85
+ jsonError(res, decision.reason, 403);
86
+ return true;
87
+ }
88
+ try {
89
+ const { record, ignored } = buildDesignSystem(parsed.body, {
90
+ userId: principal.kind === "user" ? principal.userId : null,
91
+ ...(principal.kind === "agent" ? { agentId: principal.agentId } : {}),
92
+ });
93
+ await saveDesignSystem(record);
94
+ putDesignSystemRoute.respond(res, 200, { designSystem: record, ignoredTokens: ignored });
95
+ } catch (err) {
96
+ if (!(err instanceof DesignSystemError)) throw err;
97
+ jsonError(res, err.message, 400);
98
+ }
99
+ return true;
100
+ }
101
+
102
+ return false;
103
+ }
@@ -12,22 +12,39 @@ const installationTokenRoute = route({
12
12
  pattern: ["api", "github", "installation-token"],
13
13
  summary: "Mint a GitHub App installation token for worker git and gh",
14
14
  description:
15
- "Internal worker endpoint. Returns a short-lived installation token for the installation in `GITHUB_APP_INSTALLATION_ID`, minted with the API server's GitHub App credentials. The caller cannot choose the installation. Only a registered agent (swarm API key plus X-Agent-ID, or an agent or runtime token) may call it; user, guest and ACP task tokens are refused. 404 when the App or the installation id is not configured, so workers fall back to `GITHUB_TOKEN`.",
15
+ "Internal worker endpoint. Returns a short-lived installation token for worker `git` and `gh`. With a `repo` (`owner/name`) whose owner is listed in the deployment env `GITHUB_APP_REPO_OWNERS`, the API resolves that repository's App installation with the App JWT and mints for it; the repository must also be registered in `swarm_repos` on the configured GitHub host (403 otherwise). Any other call mints for the installation in `GITHUB_APP_INSTALLATION_ID`, so single-installation deployments are unchanged and a caller never picks an installation the operator did not list. Only a registered agent (swarm API key plus X-Agent-ID, or an agent or runtime token) may call it; user, guest and ACP task tokens are refused. 404 when the App is not configured, so workers fall back to `GITHUB_TOKEN`.",
16
16
  tags: ["GitHub"],
17
- body: z.object({}).optional(),
17
+ body: z
18
+ .object({
19
+ repo: z
20
+ .string()
21
+ .max(200)
22
+ .regex(
23
+ /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/,
24
+ "repo must be `owner/name` (letters, digits, dot, dash, underscore)",
25
+ )
26
+ .optional(),
27
+ })
28
+ .optional(),
18
29
  responses: {
19
30
  200: {
20
31
  description: "Installation token and its expiry (ISO 8601)",
21
32
  schema: z.object({ token: z.string(), expiresAt: z.string() }),
22
33
  },
23
- 403: { description: "Caller is not a registered agent" },
34
+ 403: {
35
+ description:
36
+ "Caller is not a registered agent, or the repo of a listed owner is not registered in the swarm",
37
+ },
24
38
  404: { description: "GitHub App worker auth is not configured" },
25
- 502: { description: "GitHub refused or failed to mint the token" },
39
+ 502: {
40
+ description:
41
+ "GitHub refused or failed to mint the token, or the repo has no App installation",
42
+ },
26
43
  },
27
44
  auth: { apiKey: true, agentId: true },
28
45
  rbac: {
29
46
  ungated:
30
- "the handler admits only registered agent principals and mints for one fixed installation",
47
+ "the handler admits only registered agent principals and mints only for the fixed installation or the installation of a registered repo whose owner the deployment env lists",
31
48
  },
32
49
  });
33
50
 
@@ -51,11 +68,15 @@ export async function handleGitHubToken(
51
68
  jsonError(res, "Only a registered agent may mint a GitHub installation token", 403);
52
69
  return true;
53
70
  }
54
- const result = await getWorkerInstallationToken();
71
+ const result = await getWorkerInstallationToken(parsed.body?.repo);
55
72
  if (result.status === "unconfigured") {
56
73
  jsonError(res, "GitHub App worker auth is not configured", 404);
57
74
  return true;
58
75
  }
76
+ if (result.status === "forbidden") {
77
+ jsonError(res, "The repo is not registered in the swarm", 403);
78
+ return true;
79
+ }
59
80
  if (result.status === "error") {
60
81
  jsonError(res, "GitHub did not mint an installation token", 502);
61
82
  return true;
package/src/http/index.ts CHANGED
@@ -94,6 +94,7 @@ import { handleConfig } from "./config";
94
94
  import { handleContext } from "./context";
95
95
  import { getDeploymentEnvValue, handleCore, loadGlobalConfigsIntoEnv } from "./core";
96
96
  import { handleDbQuery } from "./db-query";
97
+ import { handleDesignSystem } from "./design-system";
97
98
  import { handleEvents } from "./events";
98
99
  import { handleExtensions } from "./extensions";
99
100
  import { handleFavorites } from "./favorites";
@@ -434,6 +435,7 @@ const httpServer = createHttpServer(async (req, res) => {
434
435
  () => handlePagesPublic(req, res, pathSegments, queryParams),
435
436
  () => handlePageProxy(req, res),
436
437
  () => handlePages(req, res, pathSegments, queryParams, myAgentId),
438
+ () => handleDesignSystem(req, res, pathSegments, queryParams, myAgentId),
437
439
  () => handleApiKeys(req, res, pathSegments, queryParams),
438
440
  () => handleHeartbeat(req, res, pathSegments),
439
441
  () => handleEvents(req, res, pathSegments, queryParams, myAgentId),
@@ -921,14 +923,16 @@ httpServer
921
923
  // Reconcile durable script workflow subprocesses
922
924
  await startScriptRunSupervisor(getMcpBaseUrl());
923
925
 
924
- // Start scheduler (if enabled)
926
+ // Start scheduler (if enabled). The interval is read post-hydration, like
927
+ // heartbeat below, and parsed so an unusable value keeps the 10s default (#3169).
925
928
  if (hasCapability("scheduling")) {
926
- const { startScheduler } = await import("../scheduler");
929
+ const { parseSchedulerIntervalMs, startScheduler } = await import("../scheduler");
927
930
  const { getExecutorRegistry } = await import("../workflows");
928
- const intervalMs = Number(process.env.SCHEDULER_INTERVAL_MS) || 10000;
929
- startScheduler(getExecutorRegistry(), intervalMs, {
930
- runId: globalState.__runId!,
931
- });
931
+ startScheduler(
932
+ getExecutorRegistry(),
933
+ parseSchedulerIntervalMs(process.env.SCHEDULER_INTERVAL_MS),
934
+ { runId: globalState.__runId! },
935
+ );
932
936
  }
933
937
 
934
938
  // Start heartbeat triage (unless disabled). Read post-hydration (this block
@@ -24,6 +24,7 @@
24
24
  import type { IncomingMessage, ServerResponse } from "node:http";
25
25
  import { z } from "zod";
26
26
  import { getPage, incrementPageViewCount } from "../be/db";
27
+ import { getActiveDesignSystem } from "../be/design-system";
27
28
  import { BROWSER_SDK_JS, SWARM_UI_JS } from "../pages/browser-sdk";
28
29
  import { COLOR_LITERAL_THRESHOLD, countColorLiterals } from "../pages/color-literals";
29
30
  import {
@@ -38,6 +39,7 @@ import {
38
39
  PAGE_THEME_PARAM,
39
40
  } from "../pages/page-head";
40
41
  import { resolvePageTheme } from "../themes/page-theme";
42
+ import { getThemePreset } from "../themes/presets";
41
43
  import { type Page, PageSchema } from "../types";
42
44
  import { getAppUrl, getConfiguredAppUrls, getLocalDevAppOrigins } from "../utils/constants";
43
45
  import {
@@ -111,24 +113,37 @@ const publicPageJsonRoute = route({
111
113
  /**
112
114
  * The `<head>` defaults for a page's design version (`src/pages/page-head.ts`).
113
115
  * Version 1 is the frozen original head and ignores the viewer params. Version
114
- * 2 resolves the theme: the page `theme`, else the viewer's `__swarm-theme`
115
- * preset, else Hive, plus the page `themeTokens` on top. It is dark only for
116
- * `__swarm-mode=dark`, and a `?print=1` export is always light. A body with
116
+ * 2 resolves the theme: the page `theme`, else the org design system, else the
117
+ * viewer's `__swarm-theme` preset, else Hive, plus the page `themeTokens` on
118
+ * top. The org design system (its tokens, fonts and mode lock) applies only to
119
+ * a page without its own `theme`. The page is dark for `__swarm-mode=dark`, or
120
+ * always when the design system locks `mode: "dark"`; `mode: "light"` keeps it
121
+ * light. A `?print=1` export is always light. A body with
117
122
  * `COLOR_LITERAL_THRESHOLD` or more hardcoded colors also stays light: its
118
123
  * hardcoded light surfaces would get the dark-mode text color.
119
124
  */
120
- function pageHead(page: Page, queryParams: URLSearchParams, wantsPrint: boolean): string {
125
+ async function pageHead(
126
+ page: Page,
127
+ queryParams: URLSearchParams,
128
+ wantsPrint: boolean,
129
+ ): Promise<string> {
121
130
  if (page.designVersion === 1) return PAGE_HEAD_V1;
131
+ const designSystem = getThemePreset(page.theme) ? null : await getActiveDesignSystem();
122
132
  const theme = resolvePageTheme({
123
133
  pageTheme: page.theme,
124
134
  viewerTheme: queryParams.get(PAGE_THEME_PARAM),
125
135
  overrides: page.themeTokens,
136
+ designSystem,
137
+ });
138
+ const mode = designSystem?.mode ?? "viewer";
139
+ const wantsDark =
140
+ mode === "dark" || (mode === "viewer" && queryParams.get(PAGE_MODE_PARAM) === "dark");
141
+ const dark = !wantsPrint && wantsDark && countColorLiterals(page.body) < COLOR_LITERAL_THRESHOLD;
142
+ return buildPageHeadV2({
143
+ theme,
144
+ mode: dark ? "dark" : "light",
145
+ fontsHref: designSystem?.fontsHref,
126
146
  });
127
- const dark =
128
- !wantsPrint &&
129
- queryParams.get(PAGE_MODE_PARAM) === "dark" &&
130
- countColorLiterals(page.body) < COLOR_LITERAL_THRESHOLD;
131
- return buildPageHeadV2({ theme, mode: dark ? "dark" : "light" });
132
147
  }
133
148
 
134
149
  /** A doctype at the start of a body (`\s` also matches a BOM). */
@@ -703,7 +718,7 @@ export async function handlePagesPublic(
703
718
  const html =
704
719
  injectBrowserSdk(page.body, {
705
720
  // The viewer meta goes after the head defaults, which start with <base target>.
706
- head: `${pageHead(page, queryParams, wantsPrint)}<meta name="swarm-viewer" content="${pageViewer(cookiePayload)}">`,
721
+ head: `${await pageHead(page, queryParams, wantsPrint)}<meta name="swarm-viewer" content="${pageViewer(cookiePayload)}">`,
707
722
  headFirst: feedback ? feedbackKeyGuardScript() : "",
708
723
  standardsMode: page.designVersion !== 1,
709
724
  }) +
package/src/http/pages.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import type { IncomingMessage, ServerResponse } from "node:http";
3
3
  import { z } from "zod";
4
- import { AssetKeyAuthorizationError, authorizeAssetKeyWrite } from "../be/asset-key-auth";
5
- import { resolveHttpRequesterUserId } from "../be/audit-user";
4
+ import { AssetKeyAuthorizationError } from "../be/asset-key-auth";
6
5
  import {
7
6
  countAllPages,
8
7
  countPagesByAgent,
@@ -22,8 +21,10 @@ import {
22
21
  import { getPageEditCounter } from "../be/db/page-versions";
23
22
  import { snapshotPage } from "../pages/version";
24
23
  import { resolveTemplate } from "../prompts/resolver";
24
+ import { authorizeHttpAssetKeyWrite } from "./asset-key-write";
25
25
  // Side-effect import: registers `task.page.feedback`.
26
26
  import "../prompts/session-templates";
27
+ import { can } from "../rbac";
27
28
  import { createTaskWithSiblingAwareness } from "../tasks/sibling-awareness";
28
29
  import { readThemeFields } from "../themes/page-fields";
29
30
  import { THEME_PRESET_IDS } from "../themes/presets";
@@ -41,6 +42,7 @@ import { getAppUrl, getPublicMcpBaseUrl } from "../utils/constants";
41
42
  import { isLocalDevPageRequest, pageSessionSetCookies } from "../utils/page-session";
42
43
  import { authUser, getRequestAuth, isOperatorAuth } from "../utils/request-auth-context";
43
44
  import { resolveHttpFavoriteOwner } from "./favorite-owner";
45
+ import { resolveRequestPrincipal } from "./request-principal";
44
46
  import { route } from "./route-def";
45
47
  import { resolveTaskRequester } from "./tasks";
46
48
  import {
@@ -229,9 +231,11 @@ const launchPageRoute = route({
229
231
  summary: "Launch a page session (issues HttpOnly cookie)",
230
232
  tags: ["Pages"],
231
233
  params: z.object({ id: z.string() }),
234
+ rbac: { permission: "page.launch" },
232
235
  responses: {
233
236
  204: { description: "Cookie issued" },
234
237
  400: { description: "Launch not supported for this page (e.g. password mode)" },
238
+ 403: { description: "Caller may not open pages" },
235
239
  404: { description: "Page not found" },
236
240
  },
237
241
  });
@@ -629,10 +633,7 @@ export async function handlePages(
629
633
 
630
634
  try {
631
635
  const key = parsed.body.key
632
- ? await authorizeAssetKeyWrite(
633
- parsed.body.key,
634
- await resolveHttpRequesterUserId(req, myAgentId),
635
- )
636
+ ? await authorizeHttpAssetKeyWrite(req, myAgentId, parsed.body.key)
636
637
  : undefined;
637
638
  const page = await createPage({
638
639
  key,
@@ -876,10 +877,7 @@ export async function handlePages(
876
877
  let key: string | undefined;
877
878
  if (parsed.body.key !== undefined) {
878
879
  try {
879
- key = await authorizeAssetKeyWrite(
880
- parsed.body.key,
881
- await resolveHttpRequesterUserId(req, myAgentId),
882
- );
880
+ key = await authorizeHttpAssetKeyWrite(req, myAgentId, parsed.body.key);
883
881
  } catch (error) {
884
882
  if (error instanceof AssetKeyAuthorizationError) {
885
883
  jsonError(res, error.message, error.statusCode);
@@ -1031,6 +1029,19 @@ export async function handlePages(
1031
1029
  const parsed = await launchPageRoute.parse(req, res, pathSegments, queryParams);
1032
1030
  if (!parsed) return true;
1033
1031
 
1032
+ // Role grants were checked at admission; this refuses guest and controller sessions.
1033
+ const principal = await resolveRequestPrincipal(req, myAgentId, {
1034
+ unauthenticatedFallback: "operator",
1035
+ });
1036
+ const decision = principal
1037
+ ? can({ principal, verb: "page.launch", resource: { kind: "none" }, source: "http" })
1038
+ : { allow: false as const, reason: "no authenticated principal" };
1039
+ if (!decision.allow) {
1040
+ applyLaunchCors(req, res);
1041
+ jsonError(res, decision.reason, 403);
1042
+ return true;
1043
+ }
1044
+
1034
1045
  const page = await getPage(parsed.params.id);
1035
1046
  if (!page) {
1036
1047
  applyLaunchCors(req, res);
@@ -1,5 +1,6 @@
1
1
  import type { IncomingMessage } from "node:http";
2
2
  import { getUserGrant } from "../be/rbac-roles";
3
+ import { findUserById } from "../be/users";
3
4
  import { can, isRbacEnabled, type PermissionVerb } from "../rbac";
4
5
  import type { User } from "../types";
5
6
  import { getRequestAuth } from "../utils/request-auth-context";
@@ -64,3 +65,30 @@ export async function approvalResponder(
64
65
  export function responderKey(responder: ApprovalResponder): string {
65
66
  return responder.kind === "user" ? responder.user.id : "operator";
66
67
  }
68
+
69
+ /**
70
+ * The responder for a person identified outside HTTP, such as a chat user
71
+ * mapped through `user_external_ids`. Applies the checks `approvalResponder`
72
+ * applies to a user credential: an active, unmerged account (what credential
73
+ * resolution requires), the `approval.respond` verb and, with RBAC on, a role
74
+ * that grants it.
75
+ */
76
+ export async function userApprovalResponder(
77
+ userId: string,
78
+ ): Promise<{ ok: true; responder: ApprovalResponder } | { ok: false; message: string }> {
79
+ const refused = {
80
+ ok: false as const,
81
+ message: "You are not allowed to answer approval requests.",
82
+ };
83
+ const user = await findUserById(userId);
84
+ // Credential resolution refuses invited, suspended and merged-away users, so
85
+ // a chat identity mapped to one must not answer either.
86
+ if (!user || user.status !== "active" || user.mergedIntoUserId) return refused;
87
+ const verb: PermissionVerb = "approval.respond";
88
+ if (!can({ principal: { kind: "user", userId }, verb, source: "http" }).allow) return refused;
89
+ if (isRbacEnabled()) {
90
+ const grant = await getUserGrant(userId);
91
+ if (!grant.grantsAll && !grant.verbs.has(verb)) return refused;
92
+ }
93
+ return { ok: true, responder: { kind: "user", user } };
94
+ }
@@ -1,7 +1,7 @@
1
1
  import type { IncomingMessage, ServerResponse } from "node:http";
2
2
  import { CronExpressionParser } from "cron-parser";
3
3
  import { z } from "zod";
4
- import { AssetKeyAuthorizationError, authorizeAssetKeyWrite } from "../be/asset-key-auth";
4
+ import { AssetKeyAuthorizationError } from "../be/asset-key-auth";
5
5
  import { resolveHttpAuditUserId, resolveHttpRequesterUserId } from "../be/audit-user";
6
6
  import {
7
7
  createScheduledTask,
@@ -39,6 +39,7 @@ import {
39
39
  ScheduledTaskTargetTypeSchema,
40
40
  splitLegacyModelAlias,
41
41
  } from "../types";
42
+ import { authorizeHttpAssetKeyWrite } from "./asset-key-write";
42
43
  import { resolveHttpFavoriteOwner } from "./favorite-owner";
43
44
  import { agentFirstPrincipal } from "./request-principal";
44
45
  import { route } from "./route-def";
@@ -439,7 +440,9 @@ export async function handleSchedules(
439
440
  const trustedUserId = await resolveHttpRequesterUserId(req, myAgentId);
440
441
  let key: string | undefined;
441
442
  try {
442
- key = body.key ? await authorizeAssetKeyWrite(body.key, trustedUserId) : undefined;
443
+ key = body.key
444
+ ? await authorizeHttpAssetKeyWrite(req, myAgentId, body.key, trustedUserId)
445
+ : undefined;
443
446
  } catch (error) {
444
447
  if (error instanceof AssetKeyAuthorizationError) {
445
448
  jsonError(res, error.message, error.statusCode);
@@ -577,10 +580,7 @@ export async function handleSchedules(
577
580
  const body = parsed.body as Record<string, unknown>;
578
581
  if (parsed.body.key !== undefined) {
579
582
  try {
580
- body.key = await authorizeAssetKeyWrite(
581
- parsed.body.key,
582
- await resolveHttpRequesterUserId(req, myAgentId),
583
- );
583
+ body.key = await authorizeHttpAssetKeyWrite(req, myAgentId, parsed.body.key);
584
584
  } catch (error) {
585
585
  if (error instanceof AssetKeyAuthorizationError) {
586
586
  jsonError(res, error.message, error.statusCode);
@@ -9,7 +9,7 @@ import {
9
9
  RESOURCE_GROUPS_READ_ONLY,
10
10
  } from "../assets/key";
11
11
  import { SOURCE_GROUPS_READ_ONLY, sourceMoveError, sourceOfKey } from "../assets/source-key";
12
- import { AssetKeyAuthorizationError, authorizeAssetKeyWrite } from "../be/asset-key-auth";
12
+ import { AssetKeyAuthorizationError } from "../be/asset-key-auth";
13
13
  import { resolveHttpRequesterUserId } from "../be/audit-user";
14
14
  import {
15
15
  AgentDeletedError,
@@ -82,6 +82,7 @@ import {
82
82
  } from "../types";
83
83
  import { getRequestAuth } from "../utils/request-auth-context";
84
84
  import { isRuntimePoolsEnabled } from "../utils/runtime-pools-flag";
85
+ import { authorizeHttpAssetKeyWrite } from "./asset-key-write";
85
86
  import { canMutateTaskNamespace } from "./assets";
86
87
  import { resolveHttpFavoriteOwner } from "./favorite-owner";
87
88
  import { createListTotalCache } from "./list-total-cache";
@@ -133,6 +134,7 @@ const AgentTaskSummarySchema = AgentTaskSchema.pick({
133
134
  createdAt: true,
134
135
  lastUpdatedAt: true,
135
136
  finishedAt: true,
137
+ statusKind: true,
136
138
  peakContextPercent: true,
137
139
  totalCostUsd: true,
138
140
  });
@@ -772,7 +774,10 @@ async function withSessionMove(
772
774
  try {
773
775
  const changedBy = await resolveHttpRequesterUserId(req, myAgentId);
774
776
  const actor = await resolveSessionActor(req, myAgentId);
775
- const key = destination === null ? null : await authorizeAssetKeyWrite(destination, changedBy);
777
+ const key =
778
+ destination === null
779
+ ? null
780
+ : await authorizeHttpAssetKeyWrite(req, myAgentId, destination, changedBy);
776
781
  await assertAssetKeyMovesAllowed();
777
782
  await run({ actor, changedBy: changedBy ?? undefined, key });
778
783
  } catch (error) {
package/src/http/tasks.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { IncomingMessage, ServerResponse } from "node:http";
2
2
  import { z } from "zod";
3
- import { AssetKeyAuthorizationError, authorizeAssetKeyWrite } from "../be/asset-key-auth";
3
+ import { AssetKeyAuthorizationError } from "../be/asset-key-auth";
4
4
  import { resolveHttpRequesterUserId } from "../be/audit-user";
5
5
  import {
6
6
  backfillSupersedeTaskResumeTaskId,
@@ -97,12 +97,14 @@ import {
97
97
  SUPERSEDED_WORKFLOW_TASK_REASON,
98
98
  splitLegacyModelAlias,
99
99
  TaskAttachmentSchema,
100
+ TaskStatusKindSchema,
100
101
  } from "../types";
101
102
  import { runTaskUiAction } from "../ui-spec/actions";
102
103
  import { ensure } from "../utils/business-use";
103
104
  import { getRequestAuth } from "../utils/request-auth-context";
104
105
  import { scrubSecrets } from "../utils/secret-scrubber";
105
106
  import { normalizeVcsRepo, vcsRepoUrlMatches } from "../utils/vcs-repo-match";
107
+ import { authorizeHttpAssetKeyWrite } from "./asset-key-write";
106
108
  import { readsRepoSecrets } from "./config";
107
109
  import { createListTotalCache, LIST_TOTAL_TTL_MS } from "./list-total-cache";
108
110
  import {
@@ -172,6 +174,7 @@ const AgentTaskSummarySchema = AgentTaskSchema.pick({
172
174
  createdAt: true,
173
175
  lastUpdatedAt: true,
174
176
  finishedAt: true,
177
+ statusKind: true,
175
178
  peakContextPercent: true,
176
179
  totalCostUsd: true,
177
180
  });
@@ -270,6 +273,9 @@ const listTasks = route({
270
273
  query: z.object({
271
274
  /** Single status, or comma-separated list (e.g. "failed,cancelled"). */
272
275
  status: z.string().optional(),
276
+ statusKind: TaskStatusKindSchema.optional().describe(
277
+ "Why the task ended, e.g. `status=failed&statusKind=error` (crash, rate limit, exit code) vs `statusKind=agent` (the agent chose to fail). Valid kinds per status: TASK_STATUS_KINDS in src/types.ts.",
278
+ ),
273
279
  agentId: z.string().optional(),
274
280
  scheduleId: z.string().optional(),
275
281
  /** Only tasks of this workflow run (indexed; independent of fleet size). */
@@ -1095,6 +1101,7 @@ export async function handleTasks(
1095
1101
  });
1096
1102
  const filters = {
1097
1103
  status,
1104
+ statusKind: parsed.query.statusKind,
1098
1105
  agentId: parsed.query.agentId || undefined,
1099
1106
  scheduleId: parsed.query.scheduleId || undefined,
1100
1107
  workflowRunId: parsed.query.workflowRunId,
@@ -1240,7 +1247,7 @@ export async function handleTasks(
1240
1247
  const inheritedKey = parentTask?.key;
1241
1248
  const requestedKey = parsed.body.key ?? inheritedKey;
1242
1249
  assetKey = requestedKey
1243
- ? await authorizeAssetKeyWrite(requestedKey, trustedUserId)
1250
+ ? await authorizeHttpAssetKeyWrite(req, myAgentId, requestedKey, trustedUserId)
1244
1251
  : undefined;
1245
1252
  } catch (error) {
1246
1253
  if (error instanceof AssetKeyAuthorizationError) {
@@ -1466,7 +1473,12 @@ export async function handleTasks(
1466
1473
  }
1467
1474
  }
1468
1475
 
1469
- const cancelledTask = await cancelTask(parsed.params.id, reason);
1476
+ // Who cancelled comes from the resolved principal, never the body: an agent
1477
+ // (X-Agent-ID, including ctx.swarm.task_cancel) records `agent`, as MCP
1478
+ // cancel-task does; the dashboard and operator record `user`.
1479
+ const cancelledTask = await cancelTask(parsed.params.id, reason, {
1480
+ statusKind: principal.kind === "agent" ? "agent" : "user",
1481
+ });
1470
1482
  if (!cancelledTask) {
1471
1483
  jsonError(res, "Failed to cancel task", 500);
1472
1484
  return true;
@@ -1957,21 +1969,25 @@ export async function handleTasks(
1957
1969
  const result = await completeTask(
1958
1970
  parsed.params.id,
1959
1971
  parsed.body.output || "Completed by runner wrapper (no explicit output)",
1972
+ { statusKind: "runner" },
1960
1973
  );
1961
1974
  if (!result) {
1962
1975
  return { error: "Failed to complete task", status: 500 };
1963
1976
  }
1964
1977
  updatedTask = result;
1965
1978
  } else if (parsed.body.status === "skipped") {
1966
- const result = await skipTask(parsed.params.id, skipReason!);
1979
+ const result = await skipTask(parsed.params.id, skipReason!, { statusKind: "runner" });
1967
1980
  if (!result) {
1968
1981
  return { error: "Failed to mark task as skipped", status: 500 };
1969
1982
  }
1970
1983
  updatedTask = result;
1971
1984
  } else {
1985
+ // The runner posts `failed` for a crash, a non-zero exit, a provider
1986
+ // error or an output-schema parse failure: none is the agent's call.
1972
1987
  const result = await failTask(
1973
1988
  parsed.params.id,
1974
1989
  parsed.body.failureReason || "Process exited without explicit completion",
1990
+ { statusKind: "error" },
1975
1991
  );
1976
1992
  if (!result) {
1977
1993
  return { error: "Failed to mark task as failed", status: 500 };
@@ -2402,7 +2418,9 @@ export async function handleTasks(
2402
2418
  // `task.failed`. Once it queues the step's retry it moves the task to
2403
2419
  // `superseded` itself (`scheduleTaskStepRetry`).
2404
2420
  if (task.workflowRunStepId != null) {
2405
- const failed = await failTask(parsed.params.id, SUPERSEDED_WORKFLOW_TASK_REASON);
2421
+ const failed = await failTask(parsed.params.id, SUPERSEDED_WORKFLOW_TASK_REASON, {
2422
+ statusKind: "error",
2423
+ });
2406
2424
  if (task.agentId) {
2407
2425
  await updateAgentStatusFromCapacity(task.agentId);
2408
2426
  }
package/src/http/users.ts CHANGED
@@ -94,6 +94,7 @@ import {
94
94
  } from "../be/users";
95
95
  import { isRbacEnabled } from "../rbac";
96
96
  import {
97
+ UserAvatarSchema,
97
98
  UserCommsPrefsSchema,
98
99
  UserMergeJobSchema,
99
100
  UserMergeJobStatusSchema,
@@ -285,6 +286,7 @@ const createUserRoute = route({
285
286
  metadata: z.record(z.string(), z.unknown()).optional(),
286
287
  dailyBudgetUsd: z.number().nullable().optional(),
287
288
  status: z.enum(["invited", "active", "suspended"]).optional(),
289
+ avatar: UserAvatarSchema.nullable().optional(),
288
290
  identities: z
289
291
  .array(z.object({ kind: z.string().min(1), externalId: z.string().min(1) }))
290
292
  .optional(),
@@ -445,6 +447,8 @@ const updateUserRoute = route({
445
447
  ),
446
448
  dailyBudgetUsd: z.number().nullable().optional(),
447
449
  status: z.enum(["invited", "active", "suspended"]).optional(),
450
+ // null resets to the initials avatar.
451
+ avatar: UserAvatarSchema.nullable().optional(),
448
452
  // Complete-list diff: passing this replaces the user's identity set,
449
453
  // emitting `identity_added` / `identity_removed` for each delta.
450
454
  identities: z
@@ -1865,6 +1869,7 @@ export async function handleUsers(
1865
1869
  "preferredChannel",
1866
1870
  "notes",
1867
1871
  "metadata",
1872
+ "avatar",
1868
1873
  ] as const;
1869
1874
  for (const field of PROFILE_FIELDS) {
1870
1875
  if (parsed.body[field] === undefined) continue;
@@ -94,6 +94,7 @@ import type { KapsoConfig } from "../integrations/kapso/config";
94
94
  import { getKapsoConfig } from "../integrations/kapso/config";
95
95
  import type { KapsoWebhookPayload } from "../integrations/kapso/inbound";
96
96
  import { resolveKapsoRequestedByUserId, routeKapsoInbound } from "../integrations/kapso/inbound";
97
+ import { hasPendingEventWait } from "../scheduler/deferred-task-waits";
97
98
  import { TaskCreationBlockedError } from "../tasks/errors";
98
99
  import { getPublicMcpBaseUrl } from "../utils/constants";
99
100
  import { resolveGitHubHost } from "../utils/github-host";
@@ -440,7 +441,13 @@ export async function handleWebhooks(
440
441
 
441
442
  // Early ack: events nothing handles (check_run, workflow_run, push, ...) change
442
443
  // no state, so skip the body read, HMAC and parse, and drain the body in the background.
443
- if (typeof eventType === "string" && eventType && !GITHUB_VERIFIED_EVENTS.has(eventType)) {
444
+ // check_run is read only while some agent waits on vcs.pr.checks_done.
445
+ if (
446
+ typeof eventType === "string" &&
447
+ eventType &&
448
+ !GITHUB_VERIFIED_EVENTS.has(eventType) &&
449
+ !(eventType === "check_run" && (await hasPendingEventWait("github", "vcs.pr.checks_done")))
450
+ ) {
444
451
  countGithubIgnoredEvent(eventType);
445
452
  githubWebhook.respond(res, 200, { created: false });
446
453
  req.resume();
@@ -556,6 +563,17 @@ export async function handleWebhooks(
556
563
  });
557
564
  break;
558
565
  }
566
+ case "check_run": {
567
+ const cr = body as CheckRunEvent;
568
+ workflowEventBus.emit(`github.check_run.${cr.action}`, {
569
+ repo: cr.repository.full_name,
570
+ name: cr.check_run.name,
571
+ headSha: cr.check_run.check_suite?.head_sha,
572
+ conclusion: cr.check_run.conclusion,
573
+ pullRequests: (cr.check_run.pull_requests ?? []).map((pr) => pr.number),
574
+ });
575
+ break;
576
+ }
559
577
  case "pull_request_review": {
560
578
  const prr = body as PullRequestReviewEvent;
561
579
  workflowEventBus.emit("github.pull_request_review.submitted", {