@desplega.ai/agent-swarm 2.13.5 → 2.14.0

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 (414) hide show
  1. package/dist/acp-adapter-99n6z9ky.js +17 -0
  2. package/dist/{acp-targets-w8dbs4nr.js → acp-targets-23exz4z4.js} +10 -10
  3. package/dist/{actions-8zrcbjrx.js → actions-zcr25x27.js} +60 -39
  4. package/dist/{agent-fs-provision-cbt2ttds.js → agent-fs-provision-7fa9e12e.js} +4 -4
  5. package/dist/{amp-adapter-8x6zp8w4.js → amp-adapter-s7ytmv6b.js} +3 -3
  6. package/dist/{app-zfa9dwjw.js → app-5d3sz1hy.js} +7 -7
  7. package/dist/{approval-notifications-rv92zmza.js → approval-notifications-7qgkzkzx.js} +8 -8
  8. package/dist/{assistant-q7s7rm1q.js → assistant-p2yvhc3j.js} +37 -32
  9. package/dist/{boot-args-schema-g27kpzr1.js → boot-args-schema-ry6cb0p7.js} +1 -1
  10. package/dist/{boot-reembed-1mjs52nt.js → boot-reembed-2hkm3vz2.js} +1 -1
  11. package/dist/{boot-reembed-m62dpdkg.js → boot-reembed-c9643ms3.js} +1 -1
  12. package/dist/{boot-scrub-sweep-ss1vcamw.js → boot-scrub-sweep-3ycxr51t.js} +2 -2
  13. package/dist/{boot-seeds-hwnvgbb3.js → boot-seeds-2hzvvzg0.js} +4 -4
  14. package/dist/{boxd-y0szhp0g.js → boxd-9py3x0jb.js} +2 -2
  15. package/dist/{claude-adapter-0rjmbhjk.js → claude-adapter-dnkww93e.js} +9 -9
  16. package/dist/{claude-managed-adapter-6k032agg.js → claude-managed-adapter-yk0cr5x6.js} +4 -4
  17. package/dist/{claude-managed-setup-6czvve8q.js → claude-managed-setup-4byxpp47.js} +5 -5
  18. package/dist/{claude-sdk-session-pr0znb81.js → claude-sdk-session-4wf3dbvs.js} +12467 -12285
  19. package/dist/{cli-t0n9svkb.js → cli-096aftq6.js} +12 -7
  20. package/dist/{cli-2wzkvfgm.js → cli-0e914dp9.js} +3 -3
  21. package/dist/{cli-vcpyttcw.js → cli-0h6m6z5g.js} +1 -1
  22. package/dist/{cli-q41qar56.js → cli-0k7ppk9k.js} +130 -8
  23. package/dist/{cli-ks06cd0n.js → cli-1nfabrt4.js} +8 -8
  24. package/dist/{cli-ebpq3c5z.js → cli-2414h5r9.js} +8 -8
  25. package/dist/{cli-nrt048ys.js → cli-24wervhz.js} +37 -0
  26. package/dist/{cli-pedm2kht.js → cli-2ayk9gn8.js} +2 -2
  27. package/dist/{cli-kr0jpw9c.js → cli-2ckwgs7q.js} +1 -1
  28. package/dist/{cli-evy3egte.js → cli-2savn6mm.js} +11 -100
  29. package/dist/{cli-n79j1vxc.js → cli-2zjxake1.js} +4 -4
  30. package/dist/{cli-z3x7h79n.js → cli-37p61fcg.js} +9 -9
  31. package/dist/{cli-2vp0z049.js → cli-39t9d248.js} +1 -1
  32. package/dist/{cli-sa02jsqt.js → cli-3mhdmcd4.js} +1 -1
  33. package/dist/{cli-34fygf87.js → cli-3wsabyt0.js} +2 -2
  34. package/dist/{cli-grbngev5.js → cli-466jjrwe.js} +11 -2
  35. package/dist/{cli-zxa1vmx7.js → cli-6ajyhxh7.js} +2 -2
  36. package/dist/{cli-bvamr9g0.js → cli-6yy4fepf.js} +4 -4
  37. package/dist/{cli-3vw6dd4g.js → cli-73rmgm45.js} +2 -2
  38. package/dist/{cli-8b4rpnwj.js → cli-7ca8hczj.js} +1 -1
  39. package/dist/{cli-0h8skzss.js → cli-7g5qj2ca.js} +4 -3
  40. package/dist/{cli-srre41gb.js → cli-7w1fs01q.js} +2 -2
  41. package/dist/{cli-tgc1kgg3.js → cli-84wxwt3z.js} +1 -1
  42. package/dist/{cli-4gaf3tx5.js → cli-84xn7bgz.js} +1 -1
  43. package/dist/{cli-s8dhq7rj.js → cli-879txsac.js} +5 -5
  44. package/dist/{cli-9n6g14vs.js → cli-8vbxjzk0.js} +3 -3
  45. package/dist/{cli-cmbb2t8a.js → cli-91amj3md.js} +2 -2
  46. package/dist/{cli-ewk3sg68.js → cli-930zbczq.js} +3 -3
  47. package/dist/{cli-6msnpj1z.js → cli-9fwznq4p.js} +10 -10
  48. package/dist/{cli-qmx8bnt4.js → cli-9j1t3kf6.js} +2 -2
  49. package/dist/{cli-t879ww0y.js → cli-9j47sgzy.js} +2 -2
  50. package/dist/{cli-0qt3epg4.js → cli-ad00h1st.js} +7 -7
  51. package/dist/{cli-avax5mp9.js → cli-adzmmcvf.js} +19 -7
  52. package/dist/{cli-ffn0a515.js → cli-ayxxkk3p.js} +68 -25
  53. package/dist/{cli-4vynxtrb.js → cli-bqfx72e6.js} +10 -3
  54. package/dist/{cli-887vhew6.js → cli-cbg0j1yt.js} +2716 -2643
  55. package/dist/{cli-fw67mnyc.js → cli-cg1q8ymp.js} +1 -1
  56. package/dist/{cli-he5nxaa8.js → cli-dw9rtjm3.js} +1 -1
  57. package/dist/{cli-emdfd8fh.js → cli-dy754erz.js} +9 -1
  58. package/dist/{cli-3860pmrq.js → cli-edxfzgah.js} +4 -4
  59. package/dist/{cli-v09eza21.js → cli-ejnhs815.js} +15 -15
  60. package/dist/{cli-k0nebh10.js → cli-enavhq6r.js} +1 -1
  61. package/dist/{cli-b42yfn17.js → cli-f2rwt43y.js} +13 -13
  62. package/dist/{cli-tvyt8w6n.js → cli-f9g96z28.js} +8 -8
  63. package/dist/{cli-zbbtp02a.js → cli-fww016hh.js} +457 -70
  64. package/dist/{cli-vbge4rsp.js → cli-g6a696c0.js} +4 -4
  65. package/dist/{cli-z1vam71h.js → cli-gc6b94tj.js} +2 -2
  66. package/dist/{cli-5tq15aa7.js → cli-gcyws2bp.js} +2 -2
  67. package/dist/{cli-srktrbby.js → cli-hzhv7yac.js} +1 -1
  68. package/dist/{cli-cp163xga.js → cli-jcnc5ret.js} +44 -32
  69. package/dist/{cli-j69pzrrz.js → cli-jgq9xptq.js} +5 -5
  70. package/dist/{cli-kwj3131p.js → cli-jwnac23b.js} +1 -1
  71. package/dist/{cli-wzecestt.js → cli-kc7vd07m.js} +616 -289
  72. package/dist/{cli-8pd1t17c.js → cli-kg63yp1r.js} +14 -14
  73. package/dist/{cli-zzq96q57.js → cli-krk8y8c7.js} +727 -139
  74. package/dist/{cli-5web09sb.js → cli-m0ea8ggd.js} +8 -10
  75. package/dist/{cli-qrvk9nka.js → cli-md4tn21h.js} +13 -13
  76. package/dist/{cli-1jq2em7b.js → cli-mv8ft7b0.js} +10 -9
  77. package/dist/{cli-ryem5cfq.js → cli-mw1tmn3x.js} +217 -27
  78. package/dist/{cli-abby987g.js → cli-njvpngc6.js} +3 -3
  79. package/dist/{cli-55h8m1x3.js → cli-phe2vcw5.js} +6 -6
  80. package/dist/{cli-prz1p3ft.js → cli-pq0kv31y.js} +5 -5
  81. package/dist/{cli-q1h041y8.js → cli-q457ga28.js} +6 -6
  82. package/dist/{cli-z40t85ms.js → cli-q5n3deaf.js} +1 -1
  83. package/dist/{cli-7ypg8hka.js → cli-qkbevqer.js} +3 -3
  84. package/dist/{cli-f9xw9pr4.js → cli-qrwjk4xy.js} +5 -5
  85. package/dist/{cli-kezzteka.js → cli-r04ve9xw.js} +1 -1
  86. package/dist/{cli-zntvmqmm.js → cli-r495stwd.js} +2 -2
  87. package/dist/{cli-1kvcsd2f.js → cli-r9d2tya0.js} +71 -3
  88. package/dist/{cli-ybte1fqc.js → cli-rp1n2xpd.js} +1 -1
  89. package/dist/{cli-sejvnjvw.js → cli-rs1rzwp4.js} +1 -1
  90. package/dist/{cli-94mxerrp.js → cli-rzbsh6bw.js} +1 -1
  91. package/dist/{cli-94gx6ze9.js → cli-s4pccby1.js} +1 -1
  92. package/dist/{cli-hd5bm1e1.js → cli-shyhb4t5.js} +10 -10
  93. package/dist/{cli-r3dxpmyt.js → cli-srq69pn1.js} +1 -1
  94. package/dist/{cli-7r9tvk8v.js → cli-tc165vrb.js} +8 -3
  95. package/dist/{cli-ced4azn1.js → cli-v4z5v3jd.js} +298 -80
  96. package/dist/{cli-ehg90jd1.js → cli-vxmmttmt.js} +55 -50
  97. package/dist/{cli-tt7dkwjj.js → cli-w4bvtxet.js} +7 -7
  98. package/dist/{cli-x2adbg4j.js → cli-wd7b5hgc.js} +1 -1
  99. package/dist/{cli-htb5bpz2.js → cli-wvbaq052.js} +1 -1
  100. package/dist/{cli-ywy8yz6t.js → cli-wvgg7r4j.js} +2 -2
  101. package/dist/{cli-19d6v8er.js → cli-wym6rxgt.js} +165 -6
  102. package/dist/{cli-f7b9nyvk.js → cli-yd7e590v.js} +12 -12
  103. package/dist/{cli-69zzpjgh.js → cli-yjb3cddd.js} +1 -1
  104. package/dist/{cli-5n9w2xzx.js → cli-z8t4485r.js} +2 -2
  105. package/dist/{cli-jdq3jmny.js → cli-ze1ndjs4.js} +4 -6
  106. package/dist/cli.js +28 -28
  107. package/dist/{codex-adapter-bn7eaxk5.js → codex-adapter-eq61radw.js} +8 -8
  108. package/dist/{codex-hook-nnmezjg9.js → codex-hook-8nmepvz6.js} +3 -3
  109. package/dist/{codex-login-ktfg1cxk.js → codex-login-vbd9707w.js} +1 -1
  110. package/dist/{codex-session-runner-j1e9hffc.js → codex-session-runner-rfx355h4.js} +9 -9
  111. package/dist/{commands-amhpafrr.js → commands-d1z0sx62.js} +3 -3
  112. package/dist/{controller-tw7g10j2.js → controller-9hz6d8x3.js} +4 -4
  113. package/dist/{controllers-connect-2ssqz7f4.js → controllers-connect-tz07d2xr.js} +24 -25
  114. package/dist/core-dynsv289.js +41 -0
  115. package/dist/{cursor-adapter-d6knjmwa.js → cursor-adapter-ef22ze3j.js} +2 -2
  116. package/dist/{db-fd6xxm77.js → db-gd81d68c.js} +3 -3
  117. package/dist/{db-sc59379z.js → db-vrckks6q.js} +4 -2
  118. package/dist/{devin-adapter-3bp6rape.js → devin-adapter-kdt6a2bh.js} +1 -1
  119. package/dist/{dispatcher-a2gdqz8c.js → dispatcher-76as8w2t.js} +21 -22
  120. package/dist/{docker-a59g3ebm.js → docker-51ta7jsh.js} +2 -2
  121. package/dist/dsh-adapter-ypfvcdyz.js +11 -0
  122. package/dist/{e2b-cn7cvjqy.js → e2b-05kn3kpq.js} +16 -5
  123. package/dist/{e2b-qnxyfea6.js → e2b-dm9r8hpy.js} +3 -3
  124. package/dist/{easter-egg-3d-a0pphy71.js → easter-egg-3d-sg21j15g.js} +1 -1
  125. package/dist/{embedding-space-qepzrach.js → embedding-space-zsdw37bb.js} +13 -23
  126. package/dist/{embeddings-d7vr881x.js → embeddings-p4e3e1m6.js} +1 -1
  127. package/dist/{event-bus-7gbsr0g4.js → event-bus-tvf2grf4.js} +1 -1
  128. package/dist/{execute-6afts2bn.js → execute-nztd0af0.js} +1 -1
  129. package/dist/{external-channel-881zq1x4.js → external-channel-717yzn4d.js} +2 -2
  130. package/dist/fx-adapter-9k0hptnz.js +20 -0
  131. package/dist/grok-adapter-skdj2pce.js +20 -0
  132. package/dist/handlers-5btjqkz6.js +39 -0
  133. package/dist/{heartbeat-4c022m6a.js → heartbeat-vfb1gy84.js} +24 -25
  134. package/dist/{hook-a7eh6zty.js → hook-ctz0xmp3.js} +11 -11
  135. package/dist/{hook-4k84x499.js → hook-eh52p7yd.js} +6 -6
  136. package/dist/{http-6aw5wanc.js → http-zregegrx.js} +784 -166
  137. package/dist/{index-xhad0n8m.js → index-5kx15d19.js} +1 -1
  138. package/dist/index-7w8p6em0.js +41 -0
  139. package/dist/index-evay0xyk.js +17 -0
  140. package/dist/{index-yq9hhhhy.js → index-fdym6ryb.js} +25 -26
  141. package/dist/{index-3j803vnb.js → index-mtnbhe12.js} +20533 -19786
  142. package/dist/index-vz4semsx.js +38 -0
  143. package/dist/{index-z2g9469g.js → index-x9qf8dg7.js} +108 -28
  144. package/dist/index-y3s0xp2v.js +43 -0
  145. package/dist/{k8s-36gfn847.js → k8s-ejkk0aw7.js} +2 -2
  146. package/dist/{keepalive-zhbmztqw.js → keepalive-zdqay870.js} +4 -5
  147. package/dist/lead-6cscw8a5.js +82 -0
  148. package/dist/{maintenance-rsp0591h.js → maintenance-t5ndg11m.js} +1 -1
  149. package/dist/{node-rxte5hc6.js → node-jkdd5w7m.js} +1 -1
  150. package/dist/{oauth-refresh-sweep-w3cqmxq7.js → oauth-refresh-sweep-y9zyd7t6.js} +3 -4
  151. package/dist/{object-webhooks-331hay92.js → object-webhooks-mkca91s0.js} +7 -7
  152. package/dist/{onboard-n2w80m2n.js → onboard-ss995244.js} +11 -9
  153. package/dist/{opencode-adapter-z98127cz.js → opencode-adapter-mwpz0278.js} +8 -8
  154. package/dist/{otel-impl-xsk35tvf.js → otel-impl-6n6vva3x.js} +2 -2
  155. package/dist/{pending-2e6trkxd.js → pending-2sxh1t6j.js} +22 -23
  156. package/dist/{pi-mono-adapter-wh6yndtm.js → pi-mono-adapter-sfb7zy43.js} +13 -13
  157. package/dist/{pricing-refresh-9355dj1t.js → pricing-refresh-h79bg4cf.js} +2 -2
  158. package/dist/{rbac-roles-8eajw4s6.js → rbac-roles-ckq0czp4.js} +2 -2
  159. package/dist/{rbac-roles-58y3m912.js → rbac-roles-jg2e260w.js} +3 -3
  160. package/dist/{render-v2-7gskkmd4.js → render-v2-ymbshmn0.js} +7 -7
  161. package/dist/{resume-0drnmpja.js → resume-jdhnt4jk.js} +10 -10
  162. package/dist/{runtime-d2tcmqte.js → runtime-y28jhhnf.js} +1 -1
  163. package/dist/{session-access-0ztys6bd.js → session-access-k4ta5hvp.js} +5 -5
  164. package/dist/{session-source-backfill-cdm5s046.js → session-source-backfill-528j4s8j.js} +3 -3
  165. package/dist/{setup-pqwb9tcc.js → setup-d6pj82fr.js} +15 -6
  166. package/dist/thread-buffer-9w6x5zec.js +40 -0
  167. package/dist/{tree-visibility-rwz67mje.js → tree-visibility-kjxv3nxk.js} +2 -2
  168. package/dist/{user-merge-jobs-mxrhamwt.js → user-merge-jobs-rabbncf6.js} +3 -3
  169. package/dist/{virtual-modules-71y1gsmg.js → virtual-modules-22k51txd.js} +3 -3
  170. package/dist/{work-objects-3k4ykt9j.js → work-objects-xtjbar3r.js} +26 -30
  171. package/dist/{worker-follow-up-y0h64xpr.js → worker-follow-up-fg48vk6d.js} +21 -22
  172. package/dist/worker-g4aj93dt.js +82 -0
  173. package/dist/{x-d27jj7z7.js → x-vfsqypht.js} +2 -2
  174. package/openapi.json +247 -20
  175. package/package.json +10 -10
  176. package/src/apps/definition.ts +76 -24
  177. package/src/apps/row-store.ts +67 -0
  178. package/src/apps/script-types.ts +131 -21
  179. package/src/apps/store.ts +4 -1
  180. package/src/be/db/script-runs.ts +33 -0
  181. package/src/be/db/slack-card-groups.ts +147 -0
  182. package/src/be/db/slack-trees.ts +26 -0
  183. package/src/be/db/task-idempotency.ts +63 -0
  184. package/src/be/db/tasks/read.ts +2 -0
  185. package/src/be/db/tasks/write.ts +4 -2
  186. package/src/be/db/workflow-idempotency.ts +6 -1
  187. package/src/be/db/workflows/read.ts +79 -0
  188. package/src/be/db.ts +51 -147
  189. package/src/be/improvements.ts +24 -2
  190. package/src/be/mcp-proxy.ts +45 -11
  191. package/src/be/memory/embedding-space.ts +10 -20
  192. package/src/be/memory/index.ts +35 -0
  193. package/src/be/memory/providers/openai-embedding.ts +10 -0
  194. package/src/be/migrations/348_task_deferred_until.sql +4 -0
  195. package/src/be/migrations/354_durable_objects.sql +9 -0
  196. package/src/be/migrations/356_slack_outcome_card_groups.sql +14 -0
  197. package/src/be/migrations/357_task_idempotency_keys.sql +27 -0
  198. package/src/be/migrations/362_favorites_app.sql +36 -0
  199. package/src/be/repo-checked-update.ts +58 -5
  200. package/src/be/requester-timezone.ts +10 -0
  201. package/src/be/script-connections.ts +5 -1
  202. package/src/be/script-credential-broker.ts +29 -2
  203. package/src/be/scripts/durable.ts +204 -0
  204. package/src/be/scripts/extract-schema.ts +29 -4
  205. package/src/be/scripts/run-credential.ts +1 -8
  206. package/src/be/scripts/typecheck.ts +32 -7
  207. package/src/be/seed-scripts/catalog/memory-eval.ts +11 -2
  208. package/src/be/seed-scripts/catalog/tool-usage.ts +27 -8
  209. package/src/be/swarm-config-guard.ts +87 -7
  210. package/src/be/users.ts +33 -12
  211. package/src/comb/review-batch.ts +16 -5
  212. package/src/commands/context-preamble.ts +237 -0
  213. package/src/commands/e2b.ts +14 -0
  214. package/src/commands/entrypoint-mcp-config.ts +231 -0
  215. package/src/commands/onboard/agent-fs-version.ts +1 -1
  216. package/src/commands/onboard/compose-generator.ts +2 -1
  217. package/src/commands/onboard/env-generator.ts +16 -7
  218. package/src/commands/runner.ts +23 -7
  219. package/src/commands/setup.tsx +17 -3
  220. package/src/extensions/contract-types.generated.ts +1 -1
  221. package/src/hooks/hook.ts +8 -2
  222. package/src/hooks/native-tool-hooks.ts +4 -2
  223. package/src/http/apps.ts +82 -42
  224. package/src/http/comb.ts +21 -5
  225. package/src/http/config.ts +8 -4
  226. package/src/http/heartbeat.ts +5 -0
  227. package/src/http/index.ts +12 -6
  228. package/src/http/kv.ts +7 -5
  229. package/src/http/mcp-oauth.ts +16 -0
  230. package/src/http/mcp-servers.ts +43 -3
  231. package/src/http/memory.ts +28 -1
  232. package/src/http/metrics.ts +11 -4
  233. package/src/http/onboarding.ts +12 -1
  234. package/src/http/repos.ts +27 -11
  235. package/src/http/request-principal.ts +27 -1
  236. package/src/http/schedules.ts +36 -8
  237. package/src/http/script-connection-proxy.ts +3 -1
  238. package/src/http/script-runs.ts +21 -10
  239. package/src/http/scripts.ts +177 -26
  240. package/src/http/session-cost-recompute.ts +9 -4
  241. package/src/http/skills.ts +70 -0
  242. package/src/http/status.ts +2 -0
  243. package/src/http/tasks.ts +92 -14
  244. package/src/http/trackers/jira.ts +18 -3
  245. package/src/http/trackers/linear.ts +3 -0
  246. package/src/kv-limits.ts +2 -0
  247. package/src/kv-reserved-namespaces.ts +25 -2
  248. package/src/prompts/session-templates.ts +49 -0
  249. package/src/prompts/session-turns.ts +30 -0
  250. package/src/providers/amp-adapter.ts +1 -1
  251. package/src/providers/claude-managed-adapter.ts +14 -0
  252. package/src/providers/claude-sdk-session.ts +14 -1
  253. package/src/providers/cursor-adapter.ts +1 -1
  254. package/src/providers/dsh-adapter.ts +1 -1
  255. package/src/providers/opencode-adapter.ts +3 -5
  256. package/src/providers/runtime-dependencies.ts +11 -8
  257. package/src/rbac/legacy-policy.ts +7 -0
  258. package/src/rbac/permissions.ts +27 -0
  259. package/src/scheduler/scheduler.ts +36 -18
  260. package/src/script-workflows/executor.ts +37 -8
  261. package/src/script-workflows/supervisor.ts +14 -0
  262. package/src/scripts-runtime/ctx.ts +5 -1
  263. package/src/scripts-runtime/durable-object-base.ts +19 -0
  264. package/src/scripts-runtime/eval-harness.ts +46 -1
  265. package/src/scripts-runtime/executors/native.ts +13 -1
  266. package/src/scripts-runtime/executors/quickjs-bundle.ts +20 -1
  267. package/src/scripts-runtime/executors/quickjs-prelude.ts +40 -1
  268. package/src/scripts-runtime/executors/quickjs-runner.ts +26 -3
  269. package/src/scripts-runtime/executors/quickjs-worker.ts +2 -1
  270. package/src/scripts-runtime/executors/types.ts +26 -0
  271. package/src/scripts-runtime/extract-signature.ts +96 -1
  272. package/src/scripts-runtime/loader.ts +11 -5
  273. package/src/scripts-runtime/mcp-client.ts +1 -1
  274. package/src/scripts-runtime/sdk-allowlist.ts +1 -0
  275. package/src/scripts-runtime/swarm-config.ts +7 -0
  276. package/src/scripts-runtime/swarm-sdk.ts +4 -1
  277. package/src/scripts-runtime/types/stdlib.d.ts +19 -0
  278. package/src/scripts-runtime/types/swarm-extension.d.ts +1 -0
  279. package/src/scripts-runtime/types/swarm-sdk.d.ts +19 -0
  280. package/src/slack/actions.ts +24 -0
  281. package/src/slack/assistant.ts +8 -0
  282. package/src/slack/blocks.ts +35 -0
  283. package/src/slack/channel-activity.ts +7 -0
  284. package/src/slack/enrich.ts +46 -54
  285. package/src/slack/files.ts +173 -23
  286. package/src/slack/handlers.test.ts +17 -19
  287. package/src/slack/handlers.ts +15 -14
  288. package/src/slack/render-v2.ts +264 -19
  289. package/src/slack/responses.ts +61 -5
  290. package/src/slack/session-mirror.ts +10 -5
  291. package/src/slack/task-output.ts +25 -14
  292. package/src/slack/templates.ts +9 -0
  293. package/src/slack/thread-participants.ts +64 -24
  294. package/src/slack/watcher.ts +4 -4
  295. package/src/slack/work-objects.ts +1 -1
  296. package/src/stdio.ts +5 -0
  297. package/src/tests/agents-list-model-display.test.ts +4 -0
  298. package/src/tests/apps-script-types.test.ts +63 -16
  299. package/src/tests/apps-sort-order.test.ts +87 -0
  300. package/src/tests/bedrock-model-groups.test.ts +4 -0
  301. package/src/tests/channel-activity.test.ts +9 -0
  302. package/src/tests/chatgpt-subscription-model-groups.test.ts +4 -0
  303. package/src/tests/claude-hook-output.test.ts +2 -0
  304. package/src/tests/claude-managed-adapter.test.ts +15 -3
  305. package/src/tests/claude-sdk-stderr.test.ts +28 -0
  306. package/src/tests/codex-gpt6-release.test.ts +4 -0
  307. package/src/tests/comb-review-batch.test.ts +17 -4
  308. package/src/tests/comb-status.test.ts +1 -0
  309. package/src/tests/db-client.test.ts +11 -5
  310. package/src/tests/db-task-read-contract.test.ts +1 -0
  311. package/src/tests/db-task-write-contract.test.ts +2 -2
  312. package/src/tests/defer-task.test.ts +23 -1
  313. package/src/tests/dsh-adapter.test.ts +1 -1
  314. package/src/tests/e2b-dispatch.test.ts +13 -1
  315. package/src/tests/entrypoint-mcp-config.test.ts +642 -0
  316. package/src/tests/fixtures/onboard/content.env.txt +2 -2
  317. package/src/tests/fixtures/onboard/dev.env.txt +2 -2
  318. package/src/tests/fixtures/onboard/full-all.env.txt +2 -2
  319. package/src/tests/fixtures/onboard/full.env.txt +2 -2
  320. package/src/tests/fixtures/onboard/research.env.txt +2 -2
  321. package/src/tests/fixtures/onboard/solo.env.txt +2 -2
  322. package/src/tests/fixtures/runner-missing-dependency.ts +2 -1
  323. package/src/tests/fx-adapter.test.ts +4 -5
  324. package/src/tests/hook-mcp-config-precedence.test.ts +59 -0
  325. package/src/tests/hook-ping-me-order.test.ts +1 -0
  326. package/src/tests/hook-runtime-close.test.ts +1 -0
  327. package/src/tests/improvements-payload.test.ts +2 -2
  328. package/src/tests/model-groups-live-catalog.test.ts +4 -0
  329. package/src/tests/oauth-credential-bindings.test.ts +8 -3
  330. package/src/tests/oauth-refresh-failure.test.ts +15 -3
  331. package/src/tests/onboard-env.test.ts +1 -1
  332. package/src/tests/openai-compatible-providers.test.ts +5 -0
  333. package/src/tests/openapi-route-headers.test.ts +2 -1
  334. package/src/tests/opus-5-5-registry.test.ts +4 -0
  335. package/src/tests/provider-runtime-dependencies.test.ts +26 -15
  336. package/src/tests/routing-affinity-inventory.test.ts +11 -0
  337. package/src/tests/runner-context-preamble.test.ts +202 -0
  338. package/src/tests/runner-repo-clone-args.test.ts +116 -0
  339. package/src/tests/scheduler-occurrence.test.ts +60 -9
  340. package/src/tests/script-connections-mcp.test.ts +6 -3
  341. package/src/tests/script-connections.test.ts +4 -0
  342. package/src/tests/scripts-namespaces.test.ts +3 -1
  343. package/src/tests/secret-scrubber.test.ts +8 -2
  344. package/src/tests/session-cost-recompute-unit.test.ts +39 -0
  345. package/src/tests/session-costs-recompute-all-providers.test.ts +6 -3
  346. package/src/tests/session-route-posture.test.ts +7 -1
  347. package/src/tests/slack-file-tools-attachments.test.ts +14 -9
  348. package/src/tests/slack-identity-resolution.test.ts +10 -3
  349. package/src/tests/slack-inline-output.test.ts +10 -8
  350. package/src/tests/slack-render-v2.test.ts +9 -4
  351. package/src/tests/slack-steering.test.ts +8 -2
  352. package/src/tests/slack-thread-participants.test.ts +11 -1
  353. package/src/tests/sonnet-5-5-registry.test.ts +4 -0
  354. package/src/tests/swarm-config-encryption.test.ts +5 -8
  355. package/src/tests/ui-spec-script-actions-config.test.ts +7 -3
  356. package/src/tests/workflow-triggers-v2.test.ts +35 -11
  357. package/src/tools/app-patch.ts +6 -2
  358. package/src/tools/app-upsert.ts +8 -4
  359. package/src/tools/defer-task.ts +17 -77
  360. package/src/tools/kv/kv-get.ts +2 -0
  361. package/src/tools/kv/kv-list.ts +11 -5
  362. package/src/tools/kv/kv-set.ts +1 -3
  363. package/src/tools/repos/update-repo.ts +37 -19
  364. package/src/tools/schedules/run-schedule-now.ts +21 -1
  365. package/src/tools/script-apis.ts +9 -4
  366. package/src/tools/script-common.ts +2 -2
  367. package/src/tools/script-run.ts +8 -0
  368. package/src/tools/script-upsert.ts +1 -1
  369. package/src/tools/slack-download-file.ts +15 -12
  370. package/src/tools/slack-post.ts +7 -1
  371. package/src/tools/slack-read.ts +3 -1
  372. package/src/tools/slack-reply.ts +16 -0
  373. package/src/tools/slack-start-thread.ts +8 -1
  374. package/src/tools/slack-upload-file.ts +99 -96
  375. package/src/tools/swarm-config/set-config.ts +3 -1
  376. package/src/tools/swarm-x.ts +0 -2
  377. package/src/tools/utils.ts +3 -0
  378. package/src/types.ts +8 -2
  379. package/src/utils/constants.ts +20 -0
  380. package/src/utils/deferral-time.ts +61 -0
  381. package/src/utils/request-auth-context.ts +15 -16
  382. package/src/utils/secret-scrubber.ts +1 -1
  383. package/src/workflows/engine.ts +6 -11
  384. package/src/workflows/executors/swarm-script.ts +0 -2
  385. package/src/workflows/foreach-driver.ts +6 -12
  386. package/src/workflows/input.ts +24 -1
  387. package/src/workflows/node-timeout.ts +18 -0
  388. package/src/workflows/retry-poller.ts +2 -1
  389. package/src/workflows/triggers.ts +21 -11
  390. package/src/x/composio.ts +10 -1
  391. package/templates/skills/apps/SKILL.md +4 -2
  392. package/templates/skills/apps/content.md +4 -2
  393. package/templates/skills/code-quality/content.md +4 -4
  394. package/templates/skills/scheduled-task-resilience/SKILL.md +2 -0
  395. package/templates/skills/scheduled-task-resilience/content.md +2 -0
  396. package/templates/skills/swarm-docs/content.md +7 -0
  397. package/templates/skills/swarm-scripts/SKILL.md +44 -0
  398. package/templates/skills/swarm-scripts/content.md +44 -0
  399. package/dist/acp-adapter-tbt61zkm.js +0 -17
  400. package/dist/cli-b9ygp1kz.js +0 -459
  401. package/dist/cli-kj0hyr43.js +0 -51
  402. package/dist/cli-m8f4379k.js +0 -173
  403. package/dist/core-bwp98v4w.js +0 -42
  404. package/dist/dsh-adapter-43ygwqn7.js +0 -9
  405. package/dist/fx-adapter-cr2hq17y.js +0 -20
  406. package/dist/grok-adapter-ayddnbsc.js +0 -20
  407. package/dist/handlers-7ghs84x2.js +0 -41
  408. package/dist/index-dtt0d634.js +0 -44
  409. package/dist/index-hmszyqkk.js +0 -42
  410. package/dist/index-j6rm1rtn.js +0 -39
  411. package/dist/index-rwwhsmjg.js +0 -13
  412. package/dist/lead-g2j4q39z.js +0 -83
  413. package/dist/thread-buffer-epx3san4.js +0 -42
  414. package/dist/worker-09gqn9xy.js +0 -83
package/src/http/comb.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { IncomingMessage, ServerResponse } from "node:http";
2
2
  import { z } from "zod";
3
3
  import { resolveHttpRequesterUserId } from "../be/audit-user";
4
+ import { getTaskById } from "../be/db";
4
5
  import { getCombConfig } from "../comb/config";
5
6
  import {
6
7
  REVIEW_BATCH_MAX,
@@ -11,8 +12,9 @@ import {
11
12
  import { can } from "../rbac";
12
13
  import { TaskCreationBlockedError } from "../tasks/errors";
13
14
  import { scrubSecrets } from "../utils/secret-scrubber";
14
- import { requestPrincipal } from "./request-principal";
15
- import { route } from "./route-def";
15
+ import { agentFirstPrincipal, requestPrincipal } from "./request-principal";
16
+ import { bodyTask, route } from "./route-def";
17
+ import { denyParentAttach } from "./session-access";
16
18
  import { jsonError } from "./utils";
17
19
 
18
20
  const skippedSchema = z.object({
@@ -50,11 +52,12 @@ const reviewBatchRoute = route({
50
52
  method: "post",
51
53
  path: "/api/comb/review-batches",
52
54
  pattern: ["api", "comb", "review-batches"],
53
- summary: "Send agent-fs comments to the swarm as one lead task",
55
+ summary: "Send agent-fs comments to the swarm as one task",
54
56
  description:
55
- "Comb's 'Send to swarm'. The server reads each comment again from agent-fs with its bootstrap key, skips replies, resolved comments, and comments already sent, and creates ONE task for the lead. Each sent comment gets a `[comb:sent task=<id>]` reply from the swarm service account. A comment is sent at most once. An optional `note` from the sender goes into the task text. When an earlier send lost its reply, the batch posts that reply again (`repaired`). Answers 404 while COMB_ENABLED is off.",
57
+ "Comb's 'Send to swarm'. The server reads each comment again from agent-fs with its bootstrap key, skips replies, resolved comments, and comments already sent, and creates one task. An optional parentTaskId attaches it as a follow-up for the parent’s agent. Without a parent assignee it routes to the lead. Each sent comment gets a `[comb:sent task=<id>]` reply from the swarm service account. A comment is sent at most once. An optional `note` from the sender goes into the task text. When an earlier send lost its reply, the batch posts that reply again (`repaired`). Answers 404 while COMB_ENABLED is off.",
56
58
  tags: ["Comb"],
57
59
  body: z.object({
60
+ parentTaskId: z.uuid().optional(),
58
61
  orgId: z.string().min(1),
59
62
  driveId: z.string().min(1),
60
63
  // agent-fs comment ids are UUIDs, so a malformed id never costs an agent-fs read.
@@ -89,6 +92,7 @@ const reviewBatchRoute = route({
89
92
  schema: batchErrorSchema,
90
93
  },
91
94
  },
95
+ session: bodyTask("parentTaskId"),
92
96
  rbac: { permission: "task.create.own" },
93
97
  });
94
98
 
@@ -118,8 +122,20 @@ export async function handleComb(
118
122
  }
119
123
 
120
124
  try {
125
+ const { parentTaskId, ...batch } = parsed.body;
126
+ const parent = parentTaskId ? await getTaskById(parentTaskId) : null;
127
+ if (parentTaskId && !parent) {
128
+ jsonError(res, "Parent task not found", 404);
129
+ return true;
130
+ }
131
+ const sender = parent ? await agentFirstPrincipal(req, myAgentId) : null;
132
+ if (parent && sender && (await denyParentAttach(req, res, myAgentId, parent, sender)))
133
+ return true;
121
134
  const result = await sendReviewBatch({
122
- ...parsed.body,
135
+ ...batch,
136
+ parent: parent
137
+ ? { id: parent.id, agentId: parent.agentId, agentCaller: sender?.kind === "agent" }
138
+ : undefined,
123
139
  requestedByUserId: await resolveHttpRequesterUserId(req, myAgentId),
124
140
  });
125
141
  reviewBatchRoute.respond(res, result.taskId === null ? 200 : 201, result);
@@ -190,8 +190,8 @@ export async function ensureConfigAdmin(
190
190
  }
191
191
 
192
192
  /**
193
- * A human-only key (see `isHumanOnlyConfigKey`) needs an admin user: a user
194
- * token or a dashboard session. The operator key resolves to the operator,
193
+ * A human-only key (see `isHumanOnlyConfigKey`) needs a user token or dashboard
194
+ * user session, with admin access when RBAC is enabled. The operator key resolves to the operator,
195
195
  * and every worker holds it, so it is refused like an agent or a guest. A
196
196
  * page session is refused whoever its viewer is. The operator key can still
197
197
  * mint an admin user token; see the limit on `HUMAN_ONLY_CONFIG_KEYS`.
@@ -311,7 +311,8 @@ const envPresence = route({
311
311
  }),
312
312
  responses: {
313
313
  200: {
314
- description: "Map of key -> boolean (true iff set in process.env)",
314
+ description:
315
+ "Map of key -> boolean. Empty values are normally absent; an explicitly empty WORKFLOW_INPUT_ENV_ALLOWLIST or Slack icon setting counts as present.",
315
316
  schema: z.object({ presence: z.record(z.string(), z.boolean()) }),
316
317
  },
317
318
  400: { description: "Validation error" },
@@ -501,7 +502,10 @@ export async function handleConfig(
501
502
  // Organization identity is trimmed by both /status and telemetry.
502
503
  // Match that definition without changing presence semantics for secrets.
503
504
  const value = key === "SWARM_ORG_NAME" ? process.env[key]?.trim() : process.env[key];
504
- presence[key] = value !== undefined && (isSlackIconConfigKey(key) || value !== "");
505
+ // An empty workflow allowlist is an active deny-all setting.
506
+ presence[key] =
507
+ value !== undefined &&
508
+ (key === "WORKFLOW_INPUT_ENV_ALLOWLIST" || isSlackIconConfigKey(key) || value !== "");
505
509
  }
506
510
  envPresence.respond(res, 200, { presence });
507
511
  return true;
@@ -1,6 +1,7 @@
1
1
  import type { IncomingMessage, ServerResponse } from "node:http";
2
2
  import { z } from "zod";
3
3
  import { checkHeartbeatChecklist, runHeartbeatSweep } from "../heartbeat/heartbeat";
4
+ import { refuseAgentTokenWithout } from "./request-principal";
4
5
  import { route } from "./route-def";
5
6
  import { json } from "./utils";
6
7
 
@@ -24,6 +25,7 @@ const triggerSweep = route({
24
25
  401: { description: "Unauthorized" },
25
26
  },
26
27
  auth: { apiKey: true },
28
+ rbac: { permission: "heartbeat.trigger" },
27
29
  });
28
30
 
29
31
  const triggerChecklist = route({
@@ -40,6 +42,7 @@ const triggerChecklist = route({
40
42
  401: { description: "Unauthorized" },
41
43
  },
42
44
  auth: { apiKey: true },
45
+ rbac: { permission: "heartbeat.trigger" },
43
46
  });
44
47
 
45
48
  // ─── Handler ─────────────────────────────────────────────────────────────────
@@ -52,6 +55,7 @@ export async function handleHeartbeat(
52
55
  if (triggerSweep.match(req.method, pathSegments)) {
53
56
  const parsed = await triggerSweep.parse(req, res, pathSegments, new URLSearchParams());
54
57
  if (!parsed) return true;
58
+ if (await refuseAgentTokenWithout(req, res, "heartbeat.trigger")) return true;
55
59
 
56
60
  try {
57
61
  await runHeartbeatSweep();
@@ -66,6 +70,7 @@ export async function handleHeartbeat(
66
70
  if (triggerChecklist.match(req.method, pathSegments)) {
67
71
  const parsed = await triggerChecklist.parse(req, res, pathSegments, new URLSearchParams());
68
72
  if (!parsed) return true;
73
+ if (await refuseAgentTokenWithout(req, res, "heartbeat.trigger")) return true;
69
74
 
70
75
  try {
71
76
  await checkHeartbeatChecklist();
package/src/http/index.ts CHANGED
@@ -22,6 +22,7 @@ import { startEventLoopLagProbe, stopEventLoopLagProbe, withLoopPath } from "../
22
22
  import { startHumanFreeDrain, stopHumanFreeDrain } from "../be/human-free-drain";
23
23
  import { initMcpEventsDispatcher } from "../be/mcp-events/dispatcher";
24
24
  import { startMcpOverflowSweep, stopMcpOverflowSweep } from "../be/mcp-overflow-sweep";
25
+ import { setDeploymentEnvReader } from "../be/memory";
25
26
  import {
26
27
  enqueueAuditRow,
27
28
  flushAuditBuffer,
@@ -72,7 +73,11 @@ import { startTelemetryTicker } from "../telemetry-snapshot";
72
73
  import { API_DRAINING_HEADER } from "../utils/api-drain";
73
74
  import { getApiKey } from "../utils/api-key";
74
75
  import { ensure, initialize } from "../utils/business-use";
75
- import { getConfiguredAppUrls, getMcpBaseUrl } from "../utils/constants";
76
+ import {
77
+ getConfiguredAppUrls,
78
+ getScriptApiBaseUrl,
79
+ setApiLoopbackBaseUrl,
80
+ } from "../utils/constants";
76
81
  import { isEnvFlagEnabled } from "../utils/env-flag";
77
82
  import { scrubSecrets } from "../utils/secret-scrubber";
78
83
  import { initWorkflows } from "../workflows";
@@ -687,6 +692,9 @@ try {
687
692
  throw err;
688
693
  }
689
694
  warnIfCorsAllowsAnyOrigin();
695
+ // Before any embed: the provider exempts only the deployment env's base URL
696
+ // from the SSRF check, and it fixes that choice when it builds its client.
697
+ setDeploymentEnvReader(getDeploymentEnvValue);
690
698
 
691
699
  // Register every stored secret (config secrets of all scopes, OAuth and MCP
692
700
  // OAuth credentials, script API tokens) with the scrubber before listen, so
@@ -808,6 +816,7 @@ httpServer
808
816
  const boundAddress = httpServer.address();
809
817
  if (boundAddress && typeof boundAddress === "object") {
810
818
  setExtensionLoopbackBaseUrl(`http://127.0.0.1:${boundAddress.port}`);
819
+ setApiLoopbackBaseUrl(`http://127.0.0.1:${boundAddress.port}`);
811
820
  }
812
821
  console.log(`MCP HTTP server running on http://localhost:${port}/mcp`);
813
822
 
@@ -921,7 +930,7 @@ httpServer
921
930
  await initWorkflows();
922
931
 
923
932
  // Reconcile durable script workflow subprocesses
924
- await startScriptRunSupervisor(getMcpBaseUrl());
933
+ await startScriptRunSupervisor(getScriptApiBaseUrl());
925
934
 
926
935
  // Start scheduler (if enabled). The interval is read post-hydration, like
927
936
  // heartbeat below, and parsed so an unusable value keeps the 10s default (#3169).
@@ -992,10 +1001,7 @@ httpServer
992
1001
  // prefix) changed, then embed rows with a missing or wrong-length vector.
993
1002
  // Non-blocking, idempotent, resumable. See src/be/memory/embedding-space.ts.
994
1003
  import("../be/memory/embedding-space")
995
- .then(({ runEmbeddingMaintenance, setDeploymentEnvReader }) => {
996
- setDeploymentEnvReader(getDeploymentEnvValue);
997
- return runEmbeddingMaintenance({ backfill: true });
998
- })
1004
+ .then(({ runEmbeddingMaintenance }) => runEmbeddingMaintenance({ backfill: true }))
999
1005
  .catch((err) => {
1000
1006
  console.error("[embedding-space] startup maintenance failed (non-fatal):", err);
1001
1007
  });
package/src/http/kv.ts CHANGED
@@ -11,12 +11,14 @@ import {
11
11
  listKv,
12
12
  upsertKv,
13
13
  } from "../be/db";
14
+ import { MAX_KV_BODY_BYTES } from "../kv-limits";
14
15
  import { mcpOverflowAuthError } from "../kv-overflow";
15
16
  import {
16
17
  privateNamespaceError,
17
18
  requiresLeadToWrite,
18
19
  reservedNamespaceError,
19
20
  reservedRoomKeyError,
21
+ scrubReservedRead,
20
22
  } from "../kv-reserved-namespaces";
21
23
  import { hasKvViewArgs, resolveKvView } from "../kv-view";
22
24
  import { can } from "../rbac";
@@ -46,10 +48,6 @@ import { BODY_TOO_LARGE, enforceContentLengthCap, jsonError } from "./utils";
46
48
  * and overrides anything in the URL/body so pages can't escape their namespace.
47
49
  */
48
50
 
49
- // 2 MiB cap on PUT bodies. Pre-flighted via Content-Length; the parsed JSON
50
- // body itself is enforced too (`value` size ≤ MAX_KV_BODY_BYTES after stringify).
51
- const MAX_KV_BODY_BYTES = 2 * 1024 * 1024;
52
-
53
51
  // `limit` upper bound on list endpoints. Anything higher gets clamped silently
54
52
  // — callers should paginate via offset.
55
53
  const MAX_KV_LIST_LIMIT = 1000;
@@ -693,6 +691,7 @@ async function sendGet(
693
691
  jsonError(res, "not found", 404);
694
692
  return true;
695
693
  }
694
+ entry.value = scrubReservedRead(namespace, entry.value);
696
695
  if (hasKvViewArgs(query)) {
697
696
  const view = resolveKvView(entry.value, query);
698
697
  if (!view.ok) {
@@ -791,7 +790,10 @@ async function sendList(
791
790
  const limit = Math.min(query.limit ?? 100, MAX_KV_LIST_LIMIT);
792
791
  const offset = query.offset ?? 0;
793
792
  const prefix = query.prefix && query.prefix.length > 0 ? query.prefix : undefined;
794
- const entries = await listKv(namespace, { prefix, limit, offset });
793
+ const entries = (await listKv(namespace, { prefix, limit, offset })).map((entry) => ({
794
+ ...entry,
795
+ value: scrubReservedRead(namespace, entry.value),
796
+ }));
795
797
  const total = await countKv(namespace, { prefix });
796
798
  respond(res, 200, { entries, total, namespace });
797
799
  return true;
@@ -34,6 +34,7 @@ import {
34
34
  } from "../oauth/mcp-wrapper";
35
35
  import { McpAuthMethodSchema } from "../types";
36
36
  import { getAppUrl, getPublicMcpBaseUrl } from "../utils/constants";
37
+ import { refuseAgentTokenWithout } from "./request-principal";
37
38
  import { route } from "./route-def";
38
39
  import { jsonError } from "./utils";
39
40
 
@@ -186,6 +187,15 @@ async function discoverForMcp(resourceUrl: string): Promise<DiscoveryResult | nu
186
187
  if (!issuer) return null;
187
188
 
188
189
  const as = await discoverAuthorizationServerMetadata(issuer);
190
+ // The browser is sent to authorization_endpoint and the API posts to the others.
191
+ for (const endpoint of [
192
+ as.authorization_endpoint,
193
+ as.token_endpoint,
194
+ as.registration_endpoint,
195
+ as.revocation_endpoint,
196
+ ]) {
197
+ if (endpoint) assertUrlSafe(endpoint, mcpOAuthSsrfOptions());
198
+ }
189
199
 
190
200
  return {
191
201
  resourceUrl: prmd.resource ?? resourceUrl,
@@ -334,6 +344,7 @@ const refreshRoute = route({
334
344
  tags: ["MCP OAuth"],
335
345
  auth: { apiKey: true },
336
346
  params: z.object({ mcpServerId: z.string() }),
347
+ rbac: { permission: "mcp-oauth.manage" },
337
348
  body: z
338
349
  .object({
339
350
  userId: z.string().optional(),
@@ -356,6 +367,7 @@ const disconnectRoute = route({
356
367
  tags: ["MCP OAuth"],
357
368
  auth: { apiKey: true },
358
369
  params: z.object({ mcpServerId: z.string() }),
370
+ rbac: { permission: "mcp-oauth.manage" },
359
371
  query: z.object({ userId: z.string().optional() }),
360
372
  responses: {
361
373
  200: { description: "Token revoked/deleted", schema: OkResponseSchema },
@@ -371,6 +383,7 @@ const manualClientRoute = route({
371
383
  tags: ["MCP OAuth"],
372
384
  auth: { apiKey: true },
373
385
  params: z.object({ mcpServerId: z.string() }),
386
+ rbac: { permission: "mcp-oauth.manage" },
374
387
  body: z.object({
375
388
  clientId: z.string().min(1),
376
389
  clientSecret: z.string().optional(),
@@ -918,6 +931,7 @@ export async function handleMcpOAuth(
918
931
  if (refreshRoute.match(req.method, pathSegments)) {
919
932
  const parsed = await refreshRoute.parse(req, res, pathSegments, queryParams);
920
933
  if (!parsed) return true;
934
+ if (await refuseAgentTokenWithout(req, res, "mcp-oauth.manage")) return true;
921
935
 
922
936
  const userId = parsed.body?.userId ?? null;
923
937
  const existing = await getMcpOAuthToken(parsed.params.mcpServerId, userId);
@@ -965,6 +979,7 @@ export async function handleMcpOAuth(
965
979
  if (disconnectRoute.match(req.method, pathSegments)) {
966
980
  const parsed = await disconnectRoute.parse(req, res, pathSegments, queryParams);
967
981
  if (!parsed) return true;
982
+ if (await refuseAgentTokenWithout(req, res, "mcp-oauth.manage")) return true;
968
983
 
969
984
  const userId = parsed.query.userId ?? null;
970
985
  const token = await getMcpOAuthToken(parsed.params.mcpServerId, userId);
@@ -1002,6 +1017,7 @@ export async function handleMcpOAuth(
1002
1017
  if (manualClientRoute.match(req.method, pathSegments)) {
1003
1018
  const parsed = await manualClientRoute.parse(req, res, pathSegments, queryParams);
1004
1019
  if (!parsed) return true;
1020
+ if (await refuseAgentTokenWithout(req, res, "mcp-oauth.manage")) return true;
1005
1021
 
1006
1022
  const server = await getMcpOrError(res, parsed.params.mcpServerId);
1007
1023
  if (!server) return true;
@@ -17,6 +17,7 @@ import { updateMcpServerChecked } from "../be/mcp-server-checked-update";
17
17
  import { updateTouchesStdioExecution } from "../be/mcp-server-stdio-gate";
18
18
  import { enqueueAdmissionRow } from "../be/rbac-audit";
19
19
  import { getUserGrant } from "../be/rbac-roles";
20
+ import { isApiOnlyConfigKey, isInternalConfigKey } from "../be/swarm-config-guard";
20
21
  import { ensureMcpToken } from "../oauth/ensure-mcp-token";
21
22
  import { assertUrlSafe, publicEndpointSsrfOptions } from "../oauth/mcp-wrapper";
22
23
  import { isCodexOAuthConfigKey } from "../providers/codex-oauth/env-keys";
@@ -29,7 +30,7 @@ import {
29
30
  } from "../rbac";
30
31
  import { AgentMcpServerSchema, McpServerSchema, McpServerWithInstallInfoSchema } from "../types";
31
32
  import { getRequestAuth } from "../utils/request-auth-context";
32
- import { agentFirstPrincipal, authUserId } from "./request-principal";
33
+ import { agentFirstPrincipal, authUserId, refuseAgentTokenWithout } from "./request-principal";
33
34
  import { route } from "./route-def";
34
35
  import { jsonError } from "./utils";
35
36
 
@@ -223,7 +224,11 @@ const getAgentMcpServersRoute = route({
223
224
  // ─── Handler ─────────────────────────────────────────────────────────────────
224
225
 
225
226
  async function canResolveMcpSecretsForHttpUser(req: IncomingMessage): Promise<boolean> {
226
- const userId = authUserId(getRequestAuth(req));
227
+ const auth = getRequestAuth(req);
228
+ // Task tokens are ACP harness credentials and read no config secrets (as on
229
+ // /api/config/resolved). The worker resolves installed servers with its own key.
230
+ if (auth?.kind === "agent" && auth.tokenKind === "task") return false;
231
+ const userId = authUserId(auth);
227
232
  if (!userId) return true;
228
233
  if (!isRbacEnabled()) return true;
229
234
 
@@ -320,7 +325,14 @@ export async function handleMcpServers(
320
325
  return true;
321
326
  }
322
327
 
323
- const configs = await getResolvedConfig(parsed.params.id);
328
+ // API-only and internal rows never leave the API, and Codex OAuth rows carry
329
+ // the refresh token: none of them resolve into an env var or a header.
330
+ const configs = (await getResolvedConfig(parsed.params.id)).filter(
331
+ (c) =>
332
+ !isApiOnlyConfigKey(c.key) &&
333
+ !isInternalConfigKey(c.key) &&
334
+ !isCodexOAuthConfigKey(c.key),
335
+ );
324
336
  const configMap = new Map(configs.map((c) => [c.key, c.value]));
325
337
 
326
338
  const serversWithSecrets = await Promise.all(
@@ -441,6 +453,15 @@ export async function handleMcpServers(
441
453
  jsonError(res, "MCP server not found", 404);
442
454
  return true;
443
455
  }
456
+ if (
457
+ parsed.body.agentId !== singleHeader(req, "x-agent-id") &&
458
+ (await refuseAgentTokenWithout(req, res, "mcp-server.install.any", {
459
+ kind: "agent",
460
+ agentId: parsed.body.agentId,
461
+ }))
462
+ ) {
463
+ return true;
464
+ }
444
465
 
445
466
  try {
446
467
  const agentMcpServer = await installMcpServer(parsed.body.agentId, parsed.params.id);
@@ -455,6 +476,15 @@ export async function handleMcpServers(
455
476
  if (uninstallMcpServerRoute.match(req.method, pathSegments)) {
456
477
  const parsed = await uninstallMcpServerRoute.parse(req, res, pathSegments, queryParams);
457
478
  if (!parsed) return true;
479
+ if (
480
+ parsed.params.agentId !== singleHeader(req, "x-agent-id") &&
481
+ (await refuseAgentTokenWithout(req, res, "mcp-server.uninstall.any", {
482
+ kind: "agent",
483
+ agentId: parsed.params.agentId,
484
+ }))
485
+ ) {
486
+ return true;
487
+ }
458
488
 
459
489
  const removed = await uninstallMcpServer(parsed.params.agentId, parsed.params.id);
460
490
  uninstallMcpServerRoute.respond(res, 200, { success: removed });
@@ -611,6 +641,16 @@ export async function handleMcpServers(
611
641
  if (deleteMcpServerRoute.match(req.method, pathSegments)) {
612
642
  const parsed = await deleteMcpServerRoute.parse(req, res, pathSegments, queryParams);
613
643
  if (!parsed) return true;
644
+ const existing = await getMcpServerById(parsed.params.id);
645
+ if (
646
+ existing &&
647
+ (await refuseAgentTokenWithout(req, res, "mcp-server.delete.any", {
648
+ kind: "owned",
649
+ ownerAgentId: existing.ownerAgentId,
650
+ }))
651
+ ) {
652
+ return true;
653
+ }
614
654
 
615
655
  const result = await deleteMcpServer(parsed.params.id);
616
656
  if (!result.deleted) {
@@ -47,7 +47,7 @@ import { can, type RbacPrincipal } from "../rbac";
47
47
  import { AgentMemorySchema, AgentMemoryScopeSchema, AgentMemorySourceSchema } from "../types";
48
48
  import { getRequestAuth } from "../utils/request-auth-context";
49
49
  import { scrubSecrets } from "../utils/secret-scrubber";
50
- import { agentFirstPrincipal, rejectGuest } from "./request-principal";
50
+ import { agentFirstPrincipal, rejectGuest, requestPrincipal } from "./request-principal";
51
51
  import { bodyTask, route } from "./route-def";
52
52
  import { jsonError, parseQueryParams } from "./utils";
53
53
 
@@ -831,6 +831,22 @@ export async function handleMemory(
831
831
  contextKey,
832
832
  } = parsed.body;
833
833
  const memoryAgentId = agentId ?? (scope === "agent" ? myAgentId : undefined);
834
+ // An agent-bound token writes its own memory. Another agent's needs a lead.
835
+ const auth = getRequestAuth(req);
836
+ if (
837
+ auth?.kind === "agent" &&
838
+ memoryAgentId !== undefined &&
839
+ memoryAgentId !== auth.agentId &&
840
+ !can({
841
+ principal: await ingestPrincipal(req, myAgentId),
842
+ verb: "memory.edit.any",
843
+ resource: { kind: "owned", ownerAgentId: memoryAgentId },
844
+ source: "http",
845
+ }).allow
846
+ ) {
847
+ jsonError(res, "An agent token can index memory only for its own agent", 403);
848
+ return true;
849
+ }
834
850
 
835
851
  if (source === "session_summary" && sourceTaskId) {
836
852
  const sourceTask = await getTaskById(sourceTaskId);
@@ -1370,6 +1386,17 @@ export async function handleMemory(
1370
1386
  if (reEmbedMemory.match(req.method, pathSegments)) {
1371
1387
  const parsed = await reEmbedMemory.parse(req, res, pathSegments, new URLSearchParams());
1372
1388
  if (!parsed) return true;
1389
+ // Operator-first: the shared key stays the operator even with X-Agent-ID.
1390
+ // An agent session token must belong to a lead.
1391
+ const reembedDecision = can({
1392
+ principal: await requestPrincipal(req, myAgentId, { unauthenticatedFallback: "operator" }),
1393
+ verb: "memory.reembed",
1394
+ source: "http",
1395
+ });
1396
+ if (!reembedDecision.allow) {
1397
+ jsonError(res, `Forbidden: ${reembedDecision.reason}`, 403);
1398
+ return true;
1399
+ }
1373
1400
 
1374
1401
  const { agentId, batchSize } = parsed.body;
1375
1402
  const store = getMemoryStore();
@@ -24,6 +24,7 @@ import {
24
24
  type MetricWidget,
25
25
  MetricWidgetSchema,
26
26
  } from "../types";
27
+ import { scrubObject } from "../utils/secret-scrubber";
27
28
  import { assertSelectOnlyQuery, executeReadOnlyQuery } from "./db-query";
28
29
  import { route } from "./route-def";
29
30
  import { jsonError } from "./utils";
@@ -87,7 +88,9 @@ function resolveVariableOptions(metric: Metric) {
87
88
  }
88
89
  const options = resolveVariableOptionValues(variable);
89
90
  optionsByKey[variable.key] = options;
90
- return { ...variable, options };
91
+ // Options are query output, like widget rows: the response gets a scrubbed copy.
92
+ // `optionsByKey` keeps the raw values for validation and parameter binding.
93
+ return { ...variable, options: scrubObject(options) };
91
94
  });
92
95
  return { variables, optionsByKey };
93
96
  }
@@ -162,8 +165,11 @@ function runMetricWidget(widget: MetricWidget, variables: Record<string, MetricP
162
165
  widget,
163
166
  result: {
164
167
  ...result,
165
- rows: result.rows.map((row) =>
166
- Object.fromEntries(result.columns.map((column, index) => [column, row[index]])),
168
+ // Rows can hold secrets pasted into free text: scrub them, as /api/db-query does.
169
+ rows: scrubObject(
170
+ result.rows.map((row) =>
171
+ Object.fromEntries(result.columns.map((column, index) => [column, row[index]])),
172
+ ),
167
173
  ),
168
174
  truncated: result.total > result.rows.length,
169
175
  maxRows,
@@ -180,7 +186,8 @@ function runMetric(metric: Metric, providedVariables: Record<string, unknown> =
180
186
  ...metric,
181
187
  definition: { ...metric.definition, variables: resolved.variables },
182
188
  },
183
- variables,
189
+ // A default can be the first option of an options query, so scrub the echo too.
190
+ variables: scrubObject(variables),
184
191
  widgets,
185
192
  // Kept as the first widget result for older callers during the PR cycle.
186
193
  result: widgets[0]?.result,
@@ -26,7 +26,7 @@ import { assertUrlSafe, publicEndpointSsrfOptions } from "../oauth/mcp-wrapper";
26
26
  import { ProviderNameSchema } from "../types";
27
27
  import { isCombEnabled } from "../utils/constants";
28
28
  import { splitCredentialPool } from "../utils/credentials";
29
- import { isPrivateAddress } from "../utils/egress-guard";
29
+ import { createSsrfGuardedFetch, EgressDeniedError, isPrivateAddress } from "../utils/egress-guard";
30
30
  import { getOpenRouterAttributionHeaders } from "../utils/openrouter-base-url";
31
31
  import { ensureConfigAdmin } from "./config";
32
32
  import {
@@ -383,6 +383,8 @@ async function handleMemoryProbe(body: OnboardingMemoryRequest): Promise<Onboard
383
383
  timeout: 15_000,
384
384
  maxRetries: 0,
385
385
  fetchOptions: { redirect: "manual" },
386
+ // The guard resolves the hostname and refuses a private address.
387
+ fetch: configuredEndpoint ? undefined : createSsrfGuardedFetch(publicEndpointSsrfOptions()),
386
388
  });
387
389
  const response = await client.embeddings.create({
388
390
  model,
@@ -420,6 +422,15 @@ async function handleMemoryProbe(body: OnboardingMemoryRequest): Promise<Onboard
420
422
  );
421
423
  return { ok: true, dimensions, latencyMs };
422
424
  } catch (error) {
425
+ if (error instanceof Error && error.cause instanceof EgressDeniedError) {
426
+ // Same answer as the URL check above: the step state stays as is.
427
+ return {
428
+ ok: false,
429
+ latencyMs: 0,
430
+ error: "The endpoint URL is not allowed.",
431
+ errorClass: "network",
432
+ };
433
+ }
423
434
  const errorClass = classifyMemoryError(error);
424
435
  const latencyMs = Math.max(0, Math.round(performance.now() - started));
425
436
  const message = memoryErrorMessage(errorClass, memoryErrorStatus(error));
package/src/http/repos.ts CHANGED
@@ -1,17 +1,22 @@
1
1
  import type { IncomingMessage, ServerResponse } from "node:http";
2
2
  import { z } from "zod";
3
3
  import { createSwarmRepo, deleteSwarmRepo, getSwarmRepoById, getSwarmRepos } from "../be/db";
4
- import { updateSwarmRepoChecked } from "../be/repo-checked-update";
4
+ import { execConfigRefusal, updateSwarmRepoChecked } from "../be/repo-checked-update";
5
5
  import { changesMergePolicy } from "../be/repo-merge-policy";
6
6
  import { can } from "../rbac";
7
7
  import { emitIntegrationConnected } from "../telemetry";
8
8
  import { RepoGuidelinesInputSchema, RepoHooksSchema, SwarmRepoSchema } from "../types";
9
- import { agentFirstPrincipal } from "./request-principal";
9
+ import { getRequestAuth } from "../utils/request-auth-context";
10
+ import { agentFirstPrincipal, refuseAgentTokenWithout } from "./request-principal";
10
11
  import { route } from "./route-def";
11
12
  import { json, jsonError } from "./utils";
12
13
 
13
14
  // ─── Route Definitions ───────────────────────────────────────────────────────
14
15
 
16
+ /** Workers pass `url`, `clonePath` and `defaultBranch` to git as arguments, so none may read as an option. */
17
+ const notOptionLike = (schema: z.ZodString, field: string) =>
18
+ schema.refine((value) => !value.startsWith("-"), `${field} must not start with "-"`);
19
+
15
20
  const getRepo = route({
16
21
  method: "get",
17
22
  path: "/api/repos/{id}",
@@ -50,10 +55,10 @@ const createRepo = route({
50
55
  summary: "Create a new repo",
51
56
  tags: ["Repos"],
52
57
  body: z.object({
53
- url: z.string().min(1),
58
+ url: notOptionLike(z.string().min(1), "url"),
54
59
  name: z.string().min(1),
55
- clonePath: z.string().optional(),
56
- defaultBranch: z.string().optional(),
60
+ clonePath: notOptionLike(z.string(), "clonePath").optional(),
61
+ defaultBranch: notOptionLike(z.string(), "defaultBranch").optional(),
57
62
  autoClone: z.boolean().optional(),
58
63
  hooks: RepoHooksSchema.optional(),
59
64
  guidelines: RepoGuidelinesInputSchema.nullable().optional(),
@@ -63,7 +68,7 @@ const createRepo = route({
63
68
  400: { description: "Validation error", schema: z.object({ error: z.string() }) },
64
69
  403: {
65
70
  description:
66
- "Only the lead, the operator or a user can turn allowMerge on or set a mergePolicy",
71
+ "Only the lead, the operator or a user can turn allowMerge on, set a mergePolicy or enable hooks",
67
72
  schema: z.object({ error: z.string() }),
68
73
  },
69
74
  409: { description: "Duplicate repo", schema: z.object({ error: z.string() }) },
@@ -79,10 +84,10 @@ const updateRepo = route({
79
84
  tags: ["Repos"],
80
85
  params: z.object({ id: z.string().uuid() }),
81
86
  body: z.object({
82
- url: z.string().optional(),
87
+ url: notOptionLike(z.string(), "url").optional(),
83
88
  name: z.string().optional(),
84
- clonePath: z.string().optional(),
85
- defaultBranch: z.string().optional(),
89
+ clonePath: notOptionLike(z.string(), "clonePath").optional(),
90
+ defaultBranch: notOptionLike(z.string(), "defaultBranch").optional(),
86
91
  autoClone: z.boolean().optional(),
87
92
  hooks: RepoHooksSchema.nullable().optional(),
88
93
  guidelines: RepoGuidelinesInputSchema.nullable().optional(),
@@ -90,7 +95,8 @@ const updateRepo = route({
90
95
  responses: {
91
96
  200: { description: "Repo updated", schema: SwarmRepoSchema },
92
97
  403: {
93
- description: "Only the lead, the operator or a user can change allowMerge or mergePolicy",
98
+ description:
99
+ "Only the lead, the operator or a user can change allowMerge, mergePolicy, url, clonePath or hooks",
94
100
  schema: z.object({ error: z.string() }),
95
101
  },
96
102
  404: { description: "Repo not found", schema: z.object({ error: z.string() }) },
@@ -110,6 +116,7 @@ const deleteRepo = route({
110
116
  200: { description: "Repo deleted", schema: z.object({ success: z.boolean() }) },
111
117
  404: { description: "Repo not found", schema: z.object({ error: z.string() }) },
112
118
  },
119
+ rbac: { permission: "repo.delete" },
113
120
  });
114
121
 
115
122
  // ─── Handler ─────────────────────────────────────────────────────────────────
@@ -168,6 +175,13 @@ export async function handleRepos(
168
175
  return true;
169
176
  }
170
177
  }
178
+ // A non-lead agent token may create a repo, but not one with hooks enabled: an explicit
179
+ // `hooks: { enabled: true }` is refused and an omitted `hooks` stores it disabled.
180
+ const execRefusal = await execConfigRefusal(getRequestAuth(req), "http");
181
+ if (execRefusal && parsed.body.hooks?.enabled === true) {
182
+ jsonError(res, execRefusal, 403);
183
+ return true;
184
+ }
171
185
  try {
172
186
  const repo = await createSwarmRepo({
173
187
  url: parsed.body.url,
@@ -175,7 +189,7 @@ export async function handleRepos(
175
189
  clonePath: parsed.body.clonePath,
176
190
  defaultBranch: parsed.body.defaultBranch,
177
191
  autoClone: parsed.body.autoClone,
178
- hooks: parsed.body.hooks,
192
+ hooks: parsed.body.hooks ?? (execRefusal ? { enabled: false } : undefined),
179
193
  guidelines: parsed.body.guidelines,
180
194
  });
181
195
  try {
@@ -213,6 +227,7 @@ export async function handleRepos(
213
227
  guidelines: parsed.body.guidelines,
214
228
  },
215
229
  () => allowMergeRefusal(req, myAgentId),
230
+ () => execConfigRefusal(getRequestAuth(req), "http"),
216
231
  );
217
232
  if (result.kind === "refused") {
218
233
  jsonError(res, result.refusal, 403);
@@ -237,6 +252,7 @@ export async function handleRepos(
237
252
  if (deleteRepo.match(req.method, pathSegments)) {
238
253
  const parsed = await deleteRepo.parse(req, res, pathSegments, queryParams);
239
254
  if (!parsed) return true;
255
+ if (await refuseAgentTokenWithout(req, res, "repo.delete")) return true;
240
256
  const deleted = await deleteSwarmRepo(parsed.params.id);
241
257
  if (!deleted) {
242
258
  jsonError(res, "Repo not found", 404);