@desplega.ai/agent-swarm 2.13.0 → 2.13.2

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 (306) hide show
  1. package/README.md +1 -1
  2. package/dist/acp-adapter-x1qqgzwx.js +17 -0
  3. package/dist/{acp-targets-86f0sh6g.js → acp-targets-mz8c5dnt.js} +10 -10
  4. package/dist/{actions-zv8vcxvr.js → actions-5ft3qp5a.js} +27 -27
  5. package/dist/{agent-fs-provision-jqshb33y.js → agent-fs-provision-6fgz7wvz.js} +4 -4
  6. package/dist/{amp-adapter-gt503ywc.js → amp-adapter-nthn8ezm.js} +3 -3
  7. package/dist/{app-6t4k5rh1.js → app-535m78qw.js} +10 -10
  8. package/dist/{approval-notifications-fcfw063h.js → approval-notifications-dewbk403.js} +11 -11
  9. package/dist/{assistant-9dzybh12.js → assistant-39zyabv2.js} +28 -28
  10. package/dist/{boot-args-schema-xzfp2feg.js → boot-args-schema-bqv5bf77.js} +1 -1
  11. package/dist/{boot-reembed-3jz0p2jk.js → boot-reembed-157c0gcz.js} +1 -1
  12. package/dist/{boot-reembed-r88wngfg.js → boot-reembed-fas7z3zn.js} +1 -1
  13. package/dist/{boot-scrub-sweep-scrqhw48.js → boot-scrub-sweep-tmec0be2.js} +2 -2
  14. package/dist/{boot-seeds-vb2dcrrb.js → boot-seeds-32zm50x2.js} +4 -4
  15. package/dist/{boxd-68n75y1s.js → boxd-hr8rsxzq.js} +1 -1
  16. package/dist/{claude-adapter-h3mp9hgs.js → claude-adapter-gwq7x2nj.js} +9 -9
  17. package/dist/{claude-managed-adapter-kpbyj2vb.js → claude-managed-adapter-rkvw6fvq.js} +4 -4
  18. package/dist/{claude-managed-setup-0efr3wkg.js → claude-managed-setup-0vgz4d1j.js} +6 -6
  19. package/dist/{claude-sdk-session-03dw669q.js → claude-sdk-session-5wbwxy8c.js} +20967 -19390
  20. package/dist/{cli-z64t9pe6.js → cli-0f7n3td3.js} +1 -1
  21. package/dist/{cli-j53hpbsm.js → cli-0xwb7zpt.js} +2 -2
  22. package/dist/{cli-wxwv3t11.js → cli-1f48qdnb.js} +55 -13
  23. package/dist/{cli-gfcv679k.js → cli-1gevjrc1.js} +1 -1
  24. package/dist/{cli-0jkenasr.js → cli-2v4xxnx2.js} +1 -1
  25. package/dist/{cli-hc6e4tac.js → cli-2wde56gv.js} +6 -6
  26. package/dist/{cli-mh7pdxe0.js → cli-31vt7baf.js} +17 -17
  27. package/dist/{cli-ercwc8xn.js → cli-3mf04tkh.js} +1 -1
  28. package/dist/{cli-s6zk31gr.js → cli-43dsqhcp.js} +4 -4
  29. package/dist/{cli-1dbv9mj9.js → cli-4djg31jh.js} +1 -1
  30. package/dist/{cli-tn91wc6e.js → cli-50whymxq.js} +1 -1
  31. package/dist/{cli-js10kdk7.js → cli-5basv0e7.js} +19 -5
  32. package/dist/{cli-b2jh3dyb.js → cli-5k1hvycs.js} +4 -4
  33. package/dist/{cli-dkejt425.js → cli-62fjschk.js} +7 -7
  34. package/dist/{cli-zqmmy073.js → cli-69eq6gdk.js} +18 -18
  35. package/dist/{cli-qm3ntjqs.js → cli-6rmryz03.js} +13 -13
  36. package/dist/{cli-mz34pxbk.js → cli-7m6bbtab.js} +11 -11
  37. package/dist/{cli-wv20kbr3.js → cli-8a4qg44m.js} +5 -5
  38. package/dist/{cli-2m6yaq6b.js → cli-8fj8yfmk.js} +1 -1
  39. package/dist/{cli-9m9kyw77.js → cli-8qvte9hn.js} +2 -2
  40. package/dist/{cli-x05p2d05.js → cli-9tevdxyf.js} +1 -1
  41. package/dist/{cli-qec9bynj.js → cli-a6rzw649.js} +3 -3
  42. package/dist/{cli-ex1y88j3.js → cli-at67kvnp.js} +1 -1
  43. package/dist/{cli-yn4kt85g.js → cli-b0kqw55g.js} +1 -1
  44. package/dist/{cli-n3qe7tyr.js → cli-b0m3bg0f.js} +134 -3
  45. package/dist/{cli-xfjn2kyq.js → cli-bp2rt28p.js} +9 -9
  46. package/dist/{cli-2jk4s7z1.js → cli-c9bwawf9.js} +3 -3
  47. package/dist/{cli-wndegmns.js → cli-cmgdptmx.js} +3 -3
  48. package/dist/{cli-3p288654.js → cli-cpkxh68d.js} +2 -2
  49. package/dist/{cli-117g15t4.js → cli-cs26ed89.js} +8 -8
  50. package/dist/{cli-prf7kz78.js → cli-d0jb2qnt.js} +603 -78
  51. package/dist/{cli-8hp56wat.js → cli-d2epqm0y.js} +1 -1
  52. package/dist/{cli-wrhbym01.js → cli-d528acsw.js} +6 -6
  53. package/dist/{cli-tstj6e8e.js → cli-dnvmwsvc.js} +310 -88
  54. package/dist/{cli-9fsagra4.js → cli-e87fg3en.js} +1 -1
  55. package/dist/{cli-jj3c5nyb.js → cli-erh1rgh4.js} +116 -56
  56. package/dist/{cli-f1952kjy.js → cli-ewb028rs.js} +4 -4
  57. package/dist/{cli-ct8sz3np.js → cli-f1sdh8ca.js} +6 -6
  58. package/dist/{cli-0b655smz.js → cli-fcwrd7bh.js} +5 -5
  59. package/dist/{cli-eb279wn3.js → cli-fgm2mad9.js} +2 -2
  60. package/dist/{cli-bpje8n65.js → cli-fp65jdp2.js} +31 -6
  61. package/dist/{cli-dnh64e8e.js → cli-g0b3ma7r.js} +7 -7
  62. package/dist/{cli-avxh26pd.js → cli-gc7jkf4a.js} +4 -4
  63. package/dist/{cli-2skf1mdf.js → cli-gedf48yw.js} +4 -4
  64. package/dist/{cli-ajjvqhf3.js → cli-getrvmtx.js} +27 -6
  65. package/dist/{cli-c8v2yvej.js → cli-gq6qhmrr.js} +2 -2
  66. package/dist/{cli-mbwmqb5w.js → cli-h0ewec3d.js} +1 -1
  67. package/dist/{cli-tdk7jtka.js → cli-hv3820ez.js} +1 -1
  68. package/dist/{cli-avqkr20b.js → cli-j2ybkdk2.js} +2 -2
  69. package/dist/{cli-pqfecppn.js → cli-je587f74.js} +1 -1
  70. package/dist/{cli-hgsxnjyg.js → cli-jkkcm72j.js} +13 -13
  71. package/dist/{cli-g6j6ac3h.js → cli-ka13xx6b.js} +2 -2
  72. package/dist/{cli-t35hx078.js → cli-m1wddksc.js} +2 -2
  73. package/dist/{cli-50w82h6m.js → cli-mwxez0pz.js} +1 -0
  74. package/dist/{cli-nc6a8b5b.js → cli-n14r8h4n.js} +2 -2
  75. package/dist/{cli-y4a4458j.js → cli-n46d87mj.js} +3 -3
  76. package/dist/{cli-0dg7ytxm.js → cli-nkfv398a.js} +1096 -75
  77. package/dist/{cli-fhvk2nvp.js → cli-nvqq3232.js} +9 -9
  78. package/dist/{cli-bhgrhedp.js → cli-q8aq48v1.js} +1 -1
  79. package/dist/{cli-6a40p4kv.js → cli-qn79645p.js} +1 -1
  80. package/dist/{cli-hbq0kwxz.js → cli-r4fphq38.js} +4 -4
  81. package/dist/{cli-47hz21se.js → cli-r8ddn0hf.js} +4 -5
  82. package/dist/{cli-hpb9x72z.js → cli-rvhaahfv.js} +9 -9
  83. package/dist/{cli-qhhb30e8.js → cli-s08zsqva.js} +9 -9
  84. package/dist/{cli-sdh61g52.js → cli-s6fhqbz1.js} +2 -2
  85. package/dist/{cli-y518qkjg.js → cli-sjk85d7v.js} +13 -12
  86. package/dist/{cli-ytc7fpza.js → cli-t25rq8mg.js} +4 -4
  87. package/dist/{cli-sq913bh1.js → cli-t9nxq30h.js} +8 -8
  88. package/dist/{cli-49f5jyhh.js → cli-tbdw3f92.js} +3 -3
  89. package/dist/{cli-1v82d2w6.js → cli-tceqvv6h.js} +4 -4
  90. package/dist/{cli-fz9pcjsw.js → cli-tgmate57.js} +4 -4
  91. package/dist/{cli-rtmqzat7.js → cli-vdfngx2g.js} +2 -2
  92. package/dist/{cli-9w8712tq.js → cli-vr4eyq6p.js} +43 -14
  93. package/dist/{cli-z4f346g5.js → cli-vx9acp12.js} +1 -1
  94. package/dist/{cli-7dbhnsj9.js → cli-wdtqkqnq.js} +4 -4
  95. package/dist/{cli-kde4ky90.js → cli-x5yb8zc8.js} +2 -2
  96. package/dist/{cli-w14j2z4k.js → cli-x7aqhxj5.js} +2 -2
  97. package/dist/{cli-kspxjftk.js → cli-xerdrnqs.js} +15 -6
  98. package/dist/{cli-48nvk6sb.js → cli-xhkek467.js} +2 -2
  99. package/dist/{cli-dka73bak.js → cli-xysy1g8x.js} +152 -12
  100. package/dist/{cli-7wy8gbwb.js → cli-ya1cj689.js} +1 -1
  101. package/dist/{cli-n85m2wkq.js → cli-zkbz8m2q.js} +3 -2
  102. package/dist/{cli-0pazkmd4.js → cli-zm6bkx3e.js} +4 -4
  103. package/dist/{cli-6h88mn9q.js → cli-zqy28rwx.js} +4 -4
  104. package/dist/cli.js +30 -29
  105. package/dist/{codex-adapter-f3yp0kaj.js → codex-adapter-x25xfbnh.js} +8 -8
  106. package/dist/{codex-hook-262cekfp.js → codex-hook-c0nvm30r.js} +2 -2
  107. package/dist/{codex-login-1ven7yje.js → codex-login-ven5cz5j.js} +1 -1
  108. package/dist/{codex-session-runner-ns4mv70p.js → codex-session-runner-kn5xnrvp.js} +9 -9
  109. package/dist/{commands-5bzf2tfw.js → commands-8n59gxmy.js} +3 -3
  110. package/dist/{controller-5xt7kvfm.js → controller-wn3vd217.js} +3 -3
  111. package/dist/{controllers-connect-0gg13mzp.js → controllers-connect-09gvkrhc.js} +28 -28
  112. package/dist/core-2b8bv6ny.js +42 -0
  113. package/dist/{cursor-adapter-p0c5zv6r.js → cursor-adapter-w1681kp1.js} +2 -2
  114. package/dist/{db-2s68ycq7.js → db-e71keqxk.js} +3 -3
  115. package/dist/{db-q7q639k5.js → db-spg81qtr.js} +2 -2
  116. package/dist/{devin-adapter-t8d86q9x.js → devin-adapter-fs90ab4v.js} +1 -1
  117. package/dist/{dispatcher-j2y1q7ae.js → dispatcher-fr4vawwb.js} +25 -25
  118. package/dist/{docker-1b41eysj.js → docker-1h33jvh9.js} +2 -2
  119. package/dist/{dsh-adapter-pgnkf4st.js → dsh-adapter-g9yqv09y.js} +2 -2
  120. package/dist/{e2b-xm60c8ad.js → e2b-jnk0yeva.js} +2 -2
  121. package/dist/{e2b-ew8c5j5v.js → e2b-y7e5kmzf.js} +2 -2
  122. package/dist/{easter-egg-3d-0kea97jf.js → easter-egg-3d-ac9tv9a6.js} +1 -1
  123. package/dist/{embedding-space-3n6mhhmy.js → embedding-space-an77f45k.js} +6 -6
  124. package/dist/{embeddings-jfmj6yme.js → embeddings-jkrehejr.js} +1 -1
  125. package/dist/{event-bus-v4ywhc2p.js → event-bus-08t2b4y2.js} +1 -1
  126. package/dist/{execute-tjrej979.js → execute-3mys4nta.js} +1 -1
  127. package/dist/{external-channel-jy8w2gg3.js → external-channel-s6zxpts9.js} +2 -2
  128. package/dist/fx-adapter-4yet1c4f.js +20 -0
  129. package/dist/grok-adapter-8ge6tw7m.js +20 -0
  130. package/dist/handlers-0r9evrdj.js +41 -0
  131. package/dist/heartbeat-jjpb44e5.js +50 -0
  132. package/dist/{hook-fv1jwrv7.js → hook-68gbs87k.js} +6 -6
  133. package/dist/{hook-bpnncsec.js → hook-y6n23zzj.js} +8 -8
  134. package/dist/{http-bpa26czn.js → http-8c6y008s.js} +404 -146
  135. package/dist/{index-w216g9y9.js → index-0vthtbc2.js} +38 -22
  136. package/dist/index-1v23363p.js +39 -0
  137. package/dist/index-30qw6vyw.js +44 -0
  138. package/dist/index-6bm3w6cn.js +40 -0
  139. package/dist/{index-s8re7mvq.js → index-6h3r0vpe.js} +1 -1
  140. package/dist/{index-620y7jzq.js → index-7dgxveck.js} +3 -3
  141. package/dist/{index-4k7m5dgj.js → index-maddg9ys.js} +143 -103
  142. package/dist/{index-0h6qd4p1.js → index-mbpxhc4w.js} +3 -4
  143. package/dist/index-rz8ve510.js +569 -0
  144. package/dist/{index-mpj0z9e0.js → index-we3nd2t0.js} +1 -1
  145. package/dist/{index-pe3d8jfy.js → index-whysn1wf.js} +1 -1
  146. package/dist/{index-52tgbhrw.js → index-xcw7hjt5.js} +28 -28
  147. package/dist/{index-8p0j4h4j.js → index-ym9fgxad.js} +94 -89
  148. package/dist/{k8s-fy8hbhkg.js → k8s-8326q0rq.js} +2 -2
  149. package/dist/{keepalive-d6z12s04.js → keepalive-7e9r5dvp.js} +5 -4
  150. package/dist/lead-3jpc7kcr.js +79 -0
  151. package/dist/{maintenance-7kac6g2g.js → maintenance-d3erjvcg.js} +1 -1
  152. package/dist/{oauth-refresh-sweep-t1xjetbh.js → oauth-refresh-sweep-0qh70988.js} +4 -3
  153. package/dist/{object-webhooks-6rdagg0r.js → object-webhooks-ac7v2q5p.js} +7 -7
  154. package/dist/{onboard-32y1cfxy.js → onboard-5yphtken.js} +4 -4
  155. package/dist/{opencode-adapter-enp3v31n.js → opencode-adapter-0xvyba4m.js} +8 -8
  156. package/dist/{otel-impl-k0tm5ptj.js → otel-impl-svqp691q.js} +2 -2
  157. package/dist/{pending-24zebgvs.js → pending-bn4xe5br.js} +26 -26
  158. package/dist/{pi-mono-adapter-yj72xxxe.js → pi-mono-adapter-763s8a3w.js} +20 -18
  159. package/dist/{pricing-refresh-cf25x38j.js → pricing-refresh-kfc215mf.js} +2 -2
  160. package/dist/{rbac-roles-0wydd22m.js → rbac-roles-3bznvkpt.js} +3 -3
  161. package/dist/{rbac-roles-at6crb3r.js → rbac-roles-6r4h2ghj.js} +2 -2
  162. package/dist/{render-v2-nvcw0jd7.js → render-v2-f3qedbpy.js} +10 -10
  163. package/dist/{resume-y4w0k5v3.js → resume-vcag4ann.js} +13 -13
  164. package/dist/{runtime-vpe43hx0.js → runtime-x0s55z2t.js} +1 -1
  165. package/dist/{session-access-gkyvnfye.js → session-access-nwzve8q2.js} +5 -5
  166. package/dist/{session-source-backfill-3w2st4m2.js → session-source-backfill-jpqfzmgz.js} +2 -2
  167. package/dist/{setup-axxvqtys.js → setup-d2smwaem.js} +1 -1
  168. package/dist/thread-buffer-8fc703jc.js +42 -0
  169. package/dist/{tree-visibility-y4fqvab5.js → tree-visibility-dwzc8en0.js} +2 -2
  170. package/dist/{user-merge-jobs-kcmwvrc6.js → user-merge-jobs-4ce7kma2.js} +3 -3
  171. package/dist/{virtual-modules-7d92dct1.js → virtual-modules-78a6yw71.js} +3 -3
  172. package/dist/{work-objects-f708e069.js → work-objects-m0w1e7q8.js} +28 -28
  173. package/dist/worker-3p2vq107.js +79 -0
  174. package/dist/{worker-follow-up-0by8wztc.js → worker-follow-up-e3t6f895.js} +25 -25
  175. package/dist/{x-3dtaf2r9.js → x-asbrnafg.js} +2 -2
  176. package/openapi.json +1795 -1623
  177. package/package.json +13 -12
  178. package/src/apps/catalog.generated.json +726 -0
  179. package/src/apps/definition.ts +24 -7
  180. package/src/apps/page-validator.ts +225 -3
  181. package/src/be/db.ts +38 -10
  182. package/src/be/mcp-proxy.ts +5 -4
  183. package/src/be/migrations/340_api_key_spend_cap.sql +5 -0
  184. package/src/be/migrations/341_user_token_expiry.sql +4 -0
  185. package/src/be/schedules/validate.ts +26 -0
  186. package/src/be/scripts/run-credential.ts +55 -1
  187. package/src/be/scripts/typecheck.ts +4 -4
  188. package/src/be/scripts/user-code-mode.ts +160 -0
  189. package/src/be/swarm-config-guard.ts +4 -0
  190. package/src/be/users.ts +48 -7
  191. package/src/commands/credential-outcome-report.ts +5 -2
  192. package/src/commands/onboard/agent-fs-version.ts +1 -1
  193. package/src/commands/provider-credentials.ts +19 -0
  194. package/src/commands/provider-error-class.ts +4 -1
  195. package/src/commands/rate-limit-outcome.ts +48 -3
  196. package/src/commands/runner.ts +113 -55
  197. package/src/commands/worktree-reaper.ts +600 -0
  198. package/src/extensions/contract-types.generated.ts +1 -1
  199. package/src/http/agents.ts +4 -0
  200. package/src/http/api-keys.ts +27 -3
  201. package/src/http/pages-public.ts +40 -4
  202. package/src/http/pool-keys.ts +21 -2
  203. package/src/http/schedules.ts +28 -3
  204. package/src/http/script-connection-proxy.ts +18 -6
  205. package/src/http/script-connections.ts +12 -4
  206. package/src/http/script-runs.ts +12 -3
  207. package/src/http/scripts.ts +2 -11
  208. package/src/http/tasks.ts +6 -10
  209. package/src/http/users.ts +1 -0
  210. package/src/integrations/chat-sdk/adapters.ts +29 -0
  211. package/src/integrations/chat-sdk/limits.ts +3 -0
  212. package/src/integrations/chat-sdk/rocketchat/README.md +8 -0
  213. package/src/integrations/chat-sdk/rocketchat/index.ts +790 -0
  214. package/src/integrations/chat-sdk/rocketchat/markdown.ts +210 -0
  215. package/src/integrations/chat-sdk/rocketchat/types.ts +249 -0
  216. package/src/integrations/chat-sdk/runtime.ts +11 -5
  217. package/src/integrations/chat-sdk/schema.ts +37 -3
  218. package/src/integrations/chat-sdk/status.ts +9 -0
  219. package/src/mcp-client/http-client.ts +3 -1
  220. package/src/oauth/identity-capture.ts +6 -1
  221. package/src/oauth/mcp-wrapper.ts +10 -3
  222. package/src/oauth/wrapper.ts +15 -3
  223. package/src/prompts/session-templates.ts +1 -0
  224. package/src/providers/acp-targets.ts +2 -2
  225. package/src/providers/amp-adapter.ts +1 -1
  226. package/src/providers/dsh-adapter.ts +1 -1
  227. package/src/providers/pi-mono-adapter.ts +4 -2
  228. package/src/providers/runtime-dependencies.ts +1 -1
  229. package/src/rbac/legacy-policy.ts +3 -0
  230. package/src/rbac/permissions.ts +9 -0
  231. package/src/scripts-runtime/executors/native.ts +225 -67
  232. package/src/scripts-runtime/mcp-client.ts +2 -1
  233. package/src/scripts-runtime/swarm-sdk.ts +2 -1
  234. package/src/scripts-runtime/types/stdlib.d.ts +4 -4
  235. package/src/scripts-runtime/types/swarm-extension.d.ts +7 -7
  236. package/src/scripts-runtime/types/swarm-sdk.d.ts +4 -4
  237. package/src/server-user.ts +98 -0
  238. package/src/slack/enrich.ts +14 -11
  239. package/src/tests/agents-list-model-display.test.ts +23 -0
  240. package/src/tests/apps-spike2.test.ts +35 -0
  241. package/src/tests/base-prompt.test.ts +1 -0
  242. package/src/tests/chat-sdk-rocketchat-vendored.test.ts +67 -0
  243. package/src/tests/chat-sdk-status-route.test.ts +13 -1
  244. package/src/tests/codex-app-server.test.ts +4 -6
  245. package/src/tests/deploy-guard.test.ts +24 -0
  246. package/src/tests/dsh-adapter.test.ts +1 -1
  247. package/src/tests/ensure-token.test.ts +2 -2
  248. package/src/tests/entrypoint-repo-autoclone-args.test.ts +202 -0
  249. package/src/tests/fake-dns.ts +47 -0
  250. package/src/tests/fixtures/base-prompt-baseline.json +12 -12
  251. package/src/tests/latest-model-report.test.ts +138 -0
  252. package/src/tests/mcp-oauth-dcr-reuse.test.ts +5 -2
  253. package/src/tests/mcp-oauth-ensure-token.test.ts +3 -2
  254. package/src/tests/mcp-oauth-manual-client.test.ts +6 -1
  255. package/src/tests/mcp-oauth-wrapper.test.ts +20 -4
  256. package/src/tests/mcp-outbound-fetch-guard.test.ts +169 -0
  257. package/src/tests/mcp-server-ssrf.test.ts +2 -0
  258. package/src/tests/mcp-user-route.test.ts +10 -1
  259. package/src/tests/memory-search-stall.test.ts +5 -0
  260. package/src/tests/oauth-connection-fetch-guard.test.ts +162 -0
  261. package/src/tests/oauth-token-endpoint-fetch-guard.test.ts +121 -0
  262. package/src/tests/oauth-wrapper.test.ts +1 -2
  263. package/src/tests/pages-head-v2.test.ts +2 -1
  264. package/src/tests/script-connections-http.test.ts +8 -3
  265. package/src/tests/script-connections-mcp.test.ts +14 -10
  266. package/src/tests/script-connections-sql.test.ts +6 -2
  267. package/src/tests/script-connections.test.ts +4 -0
  268. package/src/tests/slack-thread-participants.test.ts +14 -3
  269. package/src/tests/spend-cap-credentials.test.ts +34 -0
  270. package/src/tests/spend-cap-outcome.test.ts +67 -0
  271. package/src/tests/subscription-first.test.ts +119 -0
  272. package/src/tests/worktree-reaper.test.ts +424 -0
  273. package/src/tools/get-task-details.ts +247 -5
  274. package/src/tools/schedules/patch-schedule.ts +26 -1
  275. package/src/tools/schedules/update-schedule.ts +28 -2
  276. package/src/tools/script-common.ts +37 -22
  277. package/src/tools/script-query-types.ts +1 -1
  278. package/src/tools/script-run.ts +1 -1
  279. package/src/tools/script-search.ts +12 -10
  280. package/src/tools/utils.ts +7 -1
  281. package/src/utils/credentials.ts +36 -1
  282. package/src/utils/egress-guard.ts +40 -10
  283. package/src/utils/error-tracker.ts +17 -0
  284. package/templates/skills/apps/SKILL.md +191 -2
  285. package/templates/skills/apps/content.md +191 -2
  286. package/templates/skills/boards-and-sheets/content.md +11 -0
  287. package/templates/skills/chat-sdk/content.md +2 -2
  288. package/templates/skills/pages/content.md +11 -0
  289. package/templates/skills/swarm-docs/content.md +4 -0
  290. package/templates/skills/swarm-scripts/SKILL.md +1 -0
  291. package/templates/skills/swarm-scripts/content.md +1 -0
  292. package/templates/workflows/ralph-loop/content.md +6 -6
  293. package/dist/acp-adapter-cn53011z.js +0 -17
  294. package/dist/cli-pr0eze3x.js +0 -149
  295. package/dist/core-0fqtbrxa.js +0 -42
  296. package/dist/fx-adapter-k6w3jvz9.js +0 -20
  297. package/dist/grok-adapter-4q5tssw0.js +0 -20
  298. package/dist/handlers-qxgfvvsf.js +0 -41
  299. package/dist/heartbeat-6tr2w2da.js +0 -50
  300. package/dist/index-0mcxjdsa.js +0 -44
  301. package/dist/index-dz4q23ag.js +0 -40
  302. package/dist/index-s175jckx.js +0 -39
  303. package/dist/lead-p3hx7h35.js +0 -79
  304. package/dist/thread-buffer-rwa7d4dx.js +0 -42
  305. package/dist/worker-8rg9gz74.js +0 -79
  306. /package/dist/{cli-m4ejz4nj.js → cli-cah298e5.js} +0 -0
@@ -7,6 +7,8 @@ import {
7
7
  storeOAuthTokens,
8
8
  updateOAuthTokensAfterRefresh,
9
9
  } from "../be/db-queries/oauth";
10
+ import { createSsrfGuardedFetch } from "../utils/egress-guard";
11
+ import { publicEndpointSsrfOptions } from "./mcp-wrapper";
10
12
 
11
13
  // ─── Types ───────────────────────────────────────────────────────────────────
12
14
 
@@ -145,6 +147,16 @@ function tokenRequestInit(
145
147
  return { headers, body: new URLSearchParams(bodyParams).toString() };
146
148
  }
147
149
 
150
+ /**
151
+ * The token endpoint receives the client secret plus the code or refresh
152
+ * token, so it goes through the guarded fetch: a public name that resolves to
153
+ * a private address is refused, and each redirect hop is re-checked. Built per
154
+ * call because the SSRF options read the environment.
155
+ */
156
+ function tokenEndpointFetch(): typeof fetch {
157
+ return createSsrfGuardedFetch(publicEndpointSsrfOptions());
158
+ }
159
+
148
160
  export interface OAuthTokenResponse {
149
161
  accessToken: string;
150
162
  refreshToken?: string;
@@ -165,7 +177,7 @@ export async function exchangeAuthorizationCode(
165
177
  config: OAuthProviderConfig,
166
178
  params: { code: string; codeVerifier: string; redirectUri: string },
167
179
  ): Promise<OAuthTokenResponse> {
168
- const response = await fetch(config.tokenUrl, {
180
+ const response = await tokenEndpointFetch()(config.tokenUrl, {
169
181
  method: "POST",
170
182
  ...tokenRequestInit(config, {
171
183
  grant_type: "authorization_code",
@@ -242,7 +254,7 @@ export async function refreshTokenGrant(
242
254
  config: OAuthProviderConfig,
243
255
  refreshToken: string,
244
256
  ): Promise<OAuthTokenResponse> {
245
- const response = await fetch(config.tokenUrl, {
257
+ const response = await tokenEndpointFetch()(config.tokenUrl, {
246
258
  method: "POST",
247
259
  ...tokenRequestInit(config, {
248
260
  grant_type: "refresh_token",
@@ -297,7 +309,7 @@ export async function performTokenRefreshRequest(
297
309
  scope?: string;
298
310
  expiresAt: string | null;
299
311
  }> {
300
- const response = await fetch(config.tokenUrl, {
312
+ const response = await tokenEndpointFetch()(config.tokenUrl, {
301
313
  method: "POST",
302
314
  ...tokenRequestInit(config, {
303
315
  grant_type: "refresh_token",
@@ -181,6 +181,7 @@ registerTemplate({
181
181
  ## Workspace
182
182
 
183
183
  \`/workspace/personal/\` is yours. \`get-repos\` returns where a repository is cloned.
184
+ Worktrees without unsaved work are removed after your task. To keep one: \`git worktree lock <path>\`.
184
185
  Your profile lives in the database. Edit it with \`update-profile\`: \`soulMd\`, \`identityMd\`, \`heartbeatMd\`, \`setupScript\`, \`toolsMd\`. The files in \`/workspace/\` are mirrors.
185
186
  Your setup script runs at every container start.
186
187
  \`/workspace/TOOLS.md\` holds your environment notes: repos, hosts, services, tool quirks. Read it when a task touches a repo, host, or service you have not used this session. Update it with \`update-profile\` \`toolsMd\`.
@@ -427,7 +427,7 @@ const copilotTargetProfile: AcpTargetProfile = {
427
427
  },
428
428
  };
429
429
 
430
- /** Qwen Code's `--auth-type` choices (0.27.2). `qwen-oauth` and `qwen-subscription` need an interactive sign-in, so they are left out. */
430
+ /** Qwen Code's `--auth-type` choices (0.27.3). `qwen-oauth` and `qwen-subscription` need an interactive sign-in, so they are left out. */
431
431
  const QWEN_AUTH_TYPES = ["openai", "openai-responses", "anthropic", "gemini", "vertex-ai"] as const;
432
432
 
433
433
  // Qwen Code is a Gemini CLI fork: QWEN_SYSTEM_MD replaces its built-in prompt
@@ -480,7 +480,7 @@ const qwenTargetProfile: AcpTargetProfile = {
480
480
  * Kiro CLI reads its prompt from a Kiro agent config, not from a flag or an
481
481
  * env var, so the swarm system prompt is not injected (as with OpenCode).
482
482
  * Kiro advertises no ACP config options (checked on 2.29.1), so the model
483
- * rides on argv as `--model`, which `kiro-cli acp` still accepts in 3.2.1.
483
+ * rides on argv as `--model`, which `kiro-cli acp` still accepts in 3.3.0.
484
484
  */
485
485
  const kiroTargetProfile: AcpTargetProfile = {
486
486
  target: "kiro",
@@ -45,7 +45,7 @@ import type {
45
45
  * default; the image installs exactly this version and the per-task settings
46
46
  * set `amp.updates.mode: "disabled"`. Bump it deliberately, with a live run.
47
47
  */
48
- export const AMP_PACKAGE = "@ampcode/cli@0.0.1794484845-g2f1e0a";
48
+ export const AMP_PACKAGE = "@ampcode/cli@0.0.1794657642-gc1e41b";
49
49
 
50
50
  /** MCP server name. Amp exposes its tools as `agent_swarm` / `store_progress` (dashes become underscores). */
51
51
  const AMP_MCP_SERVER_NAME = "agent-swarm";
@@ -37,7 +37,7 @@ import type {
37
37
  } from "./types";
38
38
 
39
39
  // npm's `latest` is older and lacks the JSON/stdin contract used here.
40
- export const DSH_PACKAGE = "@deepseek-ai/dsh@0.2.2-rc.2";
40
+ export const DSH_PACKAGE = "@deepseek-ai/dsh@0.2.2-rc.3";
41
41
 
42
42
  export function checkDshCredentials(env: Record<string, string | undefined>): CredStatus {
43
43
  return env.DEEPSEEK_API_KEY?.trim() || env.OPENROUTER_API_KEY?.trim()
@@ -1018,10 +1018,12 @@ function resolveModelInner(
1018
1018
  return modelRuntime?.getModel(provider, modelId);
1019
1019
  }
1020
1020
 
1021
- // Try as a full model ID with common providers
1021
+ // Try as a full model ID with common providers. getModel returns undefined
1022
+ // for an unknown id, so keep looking instead of returning the first miss.
1022
1023
  for (const provider of ["anthropic", "openai", "google"]) {
1023
1024
  try {
1024
- return getModel(provider as "anthropic", modelStr as never);
1025
+ const model = getModel(provider as "anthropic", modelStr as never);
1026
+ if (model) return model;
1025
1027
  } catch {}
1026
1028
  }
1027
1029
 
@@ -94,7 +94,7 @@ export async function validateProviderDependencies(
94
94
  case "dsh":
95
95
  requireExecutable(
96
96
  env.DSH_BINARY || "dsh",
97
- "Use worker-full, install @deepseek-ai/dsh@0.2.2-rc.2, or set DSH_BINARY to a trusted executable.",
97
+ "Use worker-full, install @deepseek-ai/dsh@0.2.2-rc.3, or set DSH_BINARY to a trusted executable.",
98
98
  );
99
99
  return;
100
100
  case "amp":
@@ -356,12 +356,15 @@ export const LEGACY_POLICY = {
356
356
  "script.global.write": leadOnly,
357
357
  "script.global.delete": leadOnly,
358
358
  "script.search": anyAuthenticated,
359
+ "script.run": anyAuthenticated,
359
360
  "script.api.read.secrets": leadOnly,
360
361
  "script.api.create": leadOnly,
361
362
  "script.api.update": leadOnly,
362
363
  "script.api.rotate": leadOnly,
363
364
  "script.api.delete": leadOnly,
364
365
  "schedule.deferral.update.any": leadOrResourceOwner,
366
+ // A schedule fires as its creator, so only the creator or a lead picks what it runs.
367
+ "schedule.target.update.any": leadOrResourceOwner,
365
368
  // Pool writes pick the image that receives a runtime token, so only humans
366
369
  // may make them. The lead may only place agents into operator-made pools.
367
370
  "runtime_pool.write": operatorOrUser,
@@ -386,6 +386,10 @@ export const PERMISSIONS = {
386
386
  description: "Search reusable scripts visible to the caller.",
387
387
  namespace: "script",
388
388
  },
389
+ "script.run": {
390
+ description: "Run a global or inline script as yourself from the user MCP.",
391
+ namespace: "script",
392
+ },
389
393
  "script.api.read.secrets": {
390
394
  description: "Reveal an external script API endpoint bearer token.",
391
395
  namespace: "script",
@@ -410,6 +414,11 @@ export const PERMISSIONS = {
410
414
  description: "Change a defer-task schedule the caller did not create.",
411
415
  namespace: "schedule",
412
416
  },
417
+ "schedule.target.update.any": {
418
+ description:
419
+ "Change what a schedule the caller did not create runs (its target, task template, workflow, script, script args or params).",
420
+ namespace: "schedule",
421
+ },
413
422
  "runtime_pool.write": {
414
423
  description: "Create, update, or delete runtime pools (image, provider kind, placement).",
415
424
  namespace: "runtime_pool",
@@ -247,27 +247,203 @@ async function linkOrWriteBareImportShims(baseTmpDir: string, tmpdir: string): P
247
247
  }
248
248
  }
249
249
 
250
- function harnessCommand(
251
- harnessPath: string,
252
- input: ExecutorInput,
253
- env: Record<string, string>,
254
- runAs: SandboxIdentity | undefined,
255
- ): string[] {
256
- return buildSandboxedCommand(
257
- ["bun", "run", harnessPath],
258
- env,
259
- {
260
- virtualMemoryMb: input.resources.memoryMb,
261
- cpuTimeSec: input.resources.cpuTimeSec,
262
- maxProcs: input.resources.maxProcs,
263
- maxFileKb: Math.floor(input.resources.maxFileBytes / 1024),
264
- maxFdCount: input.resources.maxFdCount,
265
- },
266
- "inline",
267
- runAs,
250
+ type HarnessProcess = Bun.Subprocess<"pipe", "pipe", "pipe">;
251
+
252
+ /** Everything a harness spawn depends on, apart from its run dir. */
253
+ interface HarnessSpec {
254
+ harnessPath: string;
255
+ baseTmpDir: string;
256
+ runAs: SandboxIdentity | undefined;
257
+ hostValidatedArgs: boolean;
258
+ resources: ExecutorInput["resources"];
259
+ }
260
+
261
+ function harnessRunPaths(tmpdir: string) {
262
+ return {
263
+ argsFile: `${tmpdir}/args.json`,
264
+ sourceFile: `${tmpdir}/user-module/user-script.ts`,
265
+ resultFile: `${tmpdir}/result.json`,
266
+ errorFile: `${tmpdir}/error.json`,
267
+ startedFile: `${tmpdir}/started.marker`,
268
+ };
269
+ }
270
+
271
+ function harnessEnvFor(spec: HarnessSpec, tmpdir: string): Record<string, string> {
272
+ const paths = harnessRunPaths(tmpdir);
273
+ return {
274
+ PATH: process.env.PATH ?? "/usr/bin:/bin",
275
+ // The dropped identity cannot use the API's HOME.
276
+ HOME: spec.runAs ? tmpdir : (process.env.HOME ?? "/tmp"),
277
+ LANG: process.env.LANG ?? "C.UTF-8",
278
+ LC_ALL: process.env.LC_ALL ?? "C.UTF-8",
279
+ TMPDIR: tmpdir,
280
+ SWARM_SCRIPT_TMPDIR: tmpdir,
281
+ SWARM_SCRIPT_ARGS_FILE: paths.argsFile,
282
+ SWARM_SCRIPT_SOURCE_FILE: paths.sourceFile,
283
+ SWARM_SCRIPT_RESULT_FILE: paths.resultFile,
284
+ SWARM_SCRIPT_ERROR_FILE: paths.errorFile,
285
+ SWARM_SCRIPT_STARTED_FILE: paths.startedFile,
286
+ ...(spec.hostValidatedArgs ? { SWARM_SCRIPT_HOST_VALIDATED_ARGS: "1" } : {}),
287
+ };
288
+ }
289
+
290
+ function spawnHarness(spec: HarnessSpec, tmpdir: string): HarnessProcess {
291
+ const harnessEnv = harnessEnvFor(spec, tmpdir);
292
+ const limits = {
293
+ virtualMemoryMb: spec.resources.memoryMb,
294
+ cpuTimeSec: spec.resources.cpuTimeSec,
295
+ maxProcs: spec.resources.maxProcs,
296
+ maxFileKb: Math.floor(spec.resources.maxFileBytes / 1024),
297
+ maxFdCount: spec.resources.maxFdCount,
298
+ };
299
+ return registerProcessGroup(
300
+ Bun.spawn(
301
+ buildSandboxedCommand(
302
+ ["bun", "run", spec.harnessPath],
303
+ harnessEnv,
304
+ limits,
305
+ "inline",
306
+ spec.runAs,
307
+ ),
308
+ {
309
+ // On POSIX, Bun.spawn only needs PATH itself to locate the `sh`
310
+ // binary for argv[0] — the sandboxed command's `env -i` prelude is
311
+ // what actually scrubs the child's environment down to `harnessEnv`
312
+ // above. On win32 there is no such prelude, so `sandboxSpawnEnv`
313
+ // passes `harnessEnv` through directly instead — see
314
+ // `buildSandboxedCommand`'s win32 doc comment.
315
+ env: sandboxSpawnEnv(harnessEnv),
316
+ cwd: tmpdir,
317
+ detached: detachedProcessGroup,
318
+ stdin: "pipe",
319
+ stdout: "pipe",
320
+ stderr: "pipe",
321
+ },
322
+ ),
268
323
  );
269
324
  }
270
325
 
326
+ /**
327
+ * Warm harness pool. A harness spends most of a short run loading its own
328
+ * modules (ctx, SDK, zod) before it reads the config payload from stdin, and
329
+ * none of that depends on the run. So after each spawn the executor starts
330
+ * one spare harness with the same spec in a fresh run dir; it loads and then
331
+ * blocks on stdin. The next run with that spec writes its args and source
332
+ * into the spare's run dir and sends the payload, skipping spawn and module
333
+ * load. The script itself still runs once per call, in its own process, with
334
+ * the same env, limits and identity, so outputs and side effects are those of
335
+ * a cold run. A spare holds no credentials (they arrive on stdin), is
336
+ * single-use, and is stopped after WARM_IDLE_MS unused.
337
+ *
338
+ * The user module dir is created only after the spare has started: Bun
339
+ * snapshots the cwd listing at startup, and a subdir created later is
340
+ * resolved from disk (see the note above `userModulePath` in eval-harness.ts).
341
+ *
342
+ * Under a dropped identity the spare's run dir stays owned by the API until a
343
+ * run takes it. Every script shares that identity, so a dir it owned while
344
+ * idle could hold links planted by another script, and the API's writes and
345
+ * chowns below would follow them. The harness writes nothing before it reads
346
+ * stdin, so the spare needs no write access while it waits. A taken spare's
347
+ * dir gets the cold path's order: write as the API, then chown.
348
+ */
349
+ interface WarmHarness {
350
+ key: string;
351
+ tmpdir: string;
352
+ proc: HarnessProcess;
353
+ idleTimer: ReturnType<typeof setTimeout>;
354
+ }
355
+
356
+ const WARM_IDLE_MS = 30_000;
357
+ const MAX_WARM_SPECS = 4;
358
+ const warmHarnesses = new Map<string, WarmHarness>();
359
+ const warmingSpecs = new Set<string>();
360
+
361
+ function harnessSpecKey(spec: HarnessSpec): string {
362
+ return JSON.stringify([
363
+ spec.harnessPath,
364
+ spec.baseTmpDir,
365
+ spec.runAs ?? null,
366
+ spec.hostValidatedArgs,
367
+ spec.resources.memoryMb,
368
+ spec.resources.cpuTimeSec,
369
+ spec.resources.maxProcs,
370
+ spec.resources.maxFileBytes,
371
+ spec.resources.maxFdCount,
372
+ process.env.PATH ?? null,
373
+ process.env.HOME ?? null,
374
+ process.env.LANG ?? null,
375
+ process.env.LC_ALL ?? null,
376
+ ]);
377
+ }
378
+
379
+ function harnessAlive(proc: HarnessProcess): boolean {
380
+ return proc.exitCode === null && proc.signalCode === null && !proc.killed;
381
+ }
382
+
383
+ function discardWarmHarness(entry: WarmHarness): void {
384
+ clearTimeout(entry.idleTimer);
385
+ if (warmHarnesses.get(entry.key) === entry) warmHarnesses.delete(entry.key);
386
+ void terminateProcessGroup(entry.proc.pid)
387
+ .catch(() => {})
388
+ .finally(() => rm(entry.tmpdir, { recursive: true, force: true }).catch(() => {}));
389
+ }
390
+
391
+ /** Removes and returns the spare for `key` when it is still waiting on stdin. */
392
+ function takeWarmHarness(key: string): WarmHarness | undefined {
393
+ const entry = warmHarnesses.get(key);
394
+ if (!entry) return undefined;
395
+ warmHarnesses.delete(key);
396
+ clearTimeout(entry.idleTimer);
397
+ if (!harnessAlive(entry.proc)) {
398
+ discardWarmHarness(entry);
399
+ return undefined;
400
+ }
401
+ entry.proc.ref();
402
+ return entry;
403
+ }
404
+
405
+ async function startWarmHarness(key: string, spec: HarnessSpec): Promise<void> {
406
+ if (process.platform === "win32") return;
407
+ if (warmHarnesses.has(key) || warmingSpecs.has(key)) return;
408
+ warmingSpecs.add(key);
409
+ const tmpdir = `${spec.baseTmpDir}/swarm-script-${crypto.randomUUID()}`;
410
+ let started = false;
411
+ try {
412
+ // The run dir stays owned by the API until a run takes the spare (see
413
+ // above): no chown here.
414
+ await mkdir(tmpdir, { recursive: true, mode: 0o755 });
415
+ await linkOrWriteBareImportShims(spec.baseTmpDir, tmpdir);
416
+ if (warmHarnesses.has(key)) return;
417
+ const proc = spawnHarness(spec, tmpdir);
418
+ // A spare must not keep the API (or a CLI / test process) alive.
419
+ proc.unref();
420
+ started = true;
421
+ const entry: WarmHarness = {
422
+ key,
423
+ tmpdir,
424
+ proc,
425
+ idleTimer: setTimeout(() => discardWarmHarness(entry), WARM_IDLE_MS),
426
+ };
427
+ entry.idleTimer.unref?.();
428
+ if (warmHarnesses.size >= MAX_WARM_SPECS) {
429
+ const oldest = warmHarnesses.values().next().value;
430
+ if (oldest) discardWarmHarness(oldest);
431
+ }
432
+ warmHarnesses.set(key, entry);
433
+ void proc.exited.then(
434
+ () => {
435
+ if (warmHarnesses.get(key) === entry) discardWarmHarness(entry);
436
+ },
437
+ () => {},
438
+ );
439
+ } catch {
440
+ // Best-effort: the next run spawns cold.
441
+ } finally {
442
+ warmingSpecs.delete(key);
443
+ if (!started) await rm(tmpdir, { recursive: true, force: true }).catch(() => {});
444
+ }
445
+ }
446
+
271
447
  export class NativeScriptExecutor implements ScriptExecutor {
272
448
  readonly name = "native";
273
449
 
@@ -278,24 +454,24 @@ export class NativeScriptExecutor implements ScriptExecutor {
278
454
 
279
455
  const start = Date.now();
280
456
  const baseTmpDir = process.env.TMPDIR ?? (process.platform === "win32" ? osTmpdir() : "/tmp");
281
- const tmpdir = `${baseTmpDir}/swarm-script-${crypto.randomUUID()}`;
282
- await mkdir(`${tmpdir}/user-module`, { recursive: true });
283
-
284
- const argsFile = `${tmpdir}/args.json`;
285
- const sourceFile = `${tmpdir}/user-module/user-script.ts`;
286
- const resultFile = `${tmpdir}/result.json`;
287
- const errorFile = `${tmpdir}/error.json`;
288
- const startedFile = `${tmpdir}/started.marker`;
289
457
  const runAs = resolveSandboxIdentity();
290
458
  // In compiled binary mode, import.meta.url points into /$bunfs/ which spawned
291
459
  // subprocesses cannot access. Use the pre-built bundle from real filesystem instead.
292
460
  const harnessPath = process.env.SCRIPT_RUNTIME_DIR
293
461
  ? `${process.env.SCRIPT_RUNTIME_DIR}/eval-harness.bundle.js`
294
462
  : fileURLToPath(new URL("../eval-harness.ts", import.meta.url));
463
+ const spec: HarnessSpec = {
464
+ harnessPath,
465
+ baseTmpDir,
466
+ runAs,
467
+ hostValidatedArgs: Boolean(input.hostValidatedArgs),
468
+ resources: input.resources,
469
+ };
470
+ const specKey = harnessSpecKey(spec);
295
471
  let timedOut = false;
296
472
  let killed = input.signal?.aborted ?? false;
297
473
  let removeAbortListener: (() => void) | undefined;
298
- let proc: Bun.Subprocess<"pipe", "pipe", "pipe"> | undefined;
474
+ let proc: HarnessProcess | undefined;
299
475
 
300
476
  const killedOutput = (): ExecutorOutput => ({
301
477
  result: undefined,
@@ -307,9 +483,16 @@ export class NativeScriptExecutor implements ScriptExecutor {
307
483
  error: "killed",
308
484
  });
309
485
 
310
- try {
311
- if (killed) return killedOutput();
486
+ if (killed) return killedOutput();
487
+
488
+ const warm = takeWarmHarness(specKey);
489
+ const tmpdir = warm?.tmpdir ?? `${baseTmpDir}/swarm-script-${crypto.randomUUID()}`;
490
+ const { argsFile, sourceFile, resultFile, errorFile, startedFile } = harnessRunPaths(tmpdir);
491
+ // A taken spare is this run's process from here on: an abort or error
492
+ // below terminates it and removes its run dir like a cold child's.
493
+ if (warm) proc = warm.proc;
312
494
 
495
+ try {
313
496
  // Listen before the first await: an abort during the file writes below
314
497
  // must stop the spawn, not land between the writes and the listener.
315
498
  const onExternalAbort = () => {
@@ -319,11 +502,14 @@ export class NativeScriptExecutor implements ScriptExecutor {
319
502
  input.signal?.addEventListener("abort", onExternalAbort, { once: true });
320
503
  removeAbortListener = () => input.signal?.removeEventListener("abort", onExternalAbort);
321
504
 
505
+ // A spare's run dir already has its node_modules link, and is still
506
+ // owned by the API: write as the API first, then chown, on both paths.
507
+ await mkdir(`${tmpdir}/user-module`, { recursive: true });
322
508
  await Promise.all([
323
509
  Bun.write(argsFile, JSON.stringify(input.args ?? null)),
324
510
  Bun.write(sourceFile, input.source),
325
- linkOrWriteBareImportShims(baseTmpDir, tmpdir),
326
511
  ]);
512
+ if (!warm) await linkOrWriteBareImportShims(baseTmpDir, tmpdir);
327
513
  if (runAs) {
328
514
  // The child writes its result and marker files into the run dir.
329
515
  await Promise.all(
@@ -341,46 +527,18 @@ export class NativeScriptExecutor implements ScriptExecutor {
341
527
  if (proc) void terminateProcessGroup(proc.pid);
342
528
  }, input.resources.wallClockMs);
343
529
 
344
- const harnessEnv: Record<string, string> = {
345
- PATH: process.env.PATH ?? "/usr/bin:/bin",
346
- // The dropped identity cannot use the API's HOME.
347
- HOME: runAs ? tmpdir : (process.env.HOME ?? "/tmp"),
348
- LANG: process.env.LANG ?? "C.UTF-8",
349
- LC_ALL: process.env.LC_ALL ?? "C.UTF-8",
350
- TMPDIR: tmpdir,
351
- SWARM_SCRIPT_TMPDIR: tmpdir,
352
- SWARM_SCRIPT_ARGS_FILE: argsFile,
353
- SWARM_SCRIPT_SOURCE_FILE: sourceFile,
354
- SWARM_SCRIPT_RESULT_FILE: resultFile,
355
- SWARM_SCRIPT_ERROR_FILE: errorFile,
356
- SWARM_SCRIPT_STARTED_FILE: startedFile,
357
- ...(input.hostValidatedArgs ? { SWARM_SCRIPT_HOST_VALIDATED_ARGS: "1" } : {}),
358
- };
530
+ const child = proc ?? spawnHarness(spec, tmpdir);
531
+ proc = child;
532
+ // Load the next run's harness while this one runs.
533
+ void startWarmHarness(specKey, spec);
359
534
 
360
- proc = registerProcessGroup(
361
- Bun.spawn(harnessCommand(harnessPath, input, harnessEnv, runAs), {
362
- // On POSIX, Bun.spawn only needs PATH itself to locate the `sh`
363
- // binary for argv[0] — the sandboxed command's `env -i` prelude is
364
- // what actually scrubs the child's environment down to `harnessEnv`
365
- // above. On win32 there is no such prelude, so `sandboxSpawnEnv`
366
- // passes `harnessEnv` through directly instead — see
367
- // `buildSandboxedCommand`'s win32 doc comment.
368
- env: sandboxSpawnEnv(harnessEnv),
369
- cwd: tmpdir,
370
- detached: detachedProcessGroup,
371
- stdin: "pipe",
372
- stdout: "pipe",
373
- stderr: "pipe",
374
- }),
375
- );
376
-
377
- proc.stdin.write(JSON.stringify(input.configPayload));
378
- proc.stdin.end();
535
+ child.stdin.write(JSON.stringify(input.configPayload));
536
+ child.stdin.end();
379
537
 
380
538
  const [stdout, stderr, exitCode] = await Promise.all([
381
- readStreamCapped(proc.stdout, input.resources.maxStdoutBytes),
382
- readStreamCapped(proc.stderr, input.resources.maxStdoutBytes),
383
- proc.exited.catch(() => (timedOut ? 124 : 1)),
539
+ readStreamCapped(child.stdout, input.resources.maxStdoutBytes),
540
+ readStreamCapped(child.stderr, input.resources.maxStdoutBytes),
541
+ child.exited.catch(() => (timedOut ? 124 : 1)),
384
542
  ]).finally(() => clearTimeout(timeout));
385
543
  // The child owns the run dir: read its files only through the checked reader.
386
544
  const runDirCheck: RunDirFileCheck = {
@@ -35,7 +35,8 @@ function methodNames(
35
35
  function headers(config: SwarmConfig): Record<string, string> {
36
36
  return {
37
37
  Authorization: `Bearer ${Redacted.value(config.apiKey)}`,
38
- "X-Agent-ID": Redacted.value(config.agentId),
38
+ // A user-scoped run has no agent; its user token must not name one.
39
+ ...(Redacted.value(config.agentId) ? { "X-Agent-ID": Redacted.value(config.agentId) } : {}),
39
40
  // Audit-only header: X-Source-Task-Id would also rescope kv, parent send-task, etc.
40
41
  ...(config.auditSourceTaskId
41
42
  ? { "X-Audit-Source-Task-Id": Redacted.value(config.auditSourceTaskId) }
@@ -23,7 +23,8 @@ type BridgeRequest = {
23
23
  function headers(config: SwarmConfig): Record<string, string> {
24
24
  return {
25
25
  Authorization: `Bearer ${Redacted.value(config.apiKey)}`,
26
- "X-Agent-ID": Redacted.value(config.agentId),
26
+ // A user-scoped run has no agent; its user token must not name one.
27
+ ...(Redacted.value(config.agentId) ? { "X-Agent-ID": Redacted.value(config.agentId) } : {}),
27
28
  // Per-boot identity of the invoking worker process (system context, not
28
29
  // script input) — work-acquisition endpoints gate on it in multi-runtime
29
30
  // mode.
@@ -847,25 +847,25 @@ declare module "swarm-sdk" {
847
847
  // --- write: chat sdk ---
848
848
  chat_reply(args: { text?: string; card?: unknown }): Promise<unknown>;
849
849
  chat_post(args: {
850
- adapter: "telegram" | "slack" | "discord" | "teams";
850
+ adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
851
851
  threadId?: string;
852
852
  channelId?: string;
853
853
  text?: string;
854
854
  card?: unknown;
855
855
  }): Promise<unknown>;
856
856
  chat_openDm(args: {
857
- adapter: "telegram" | "slack" | "discord" | "teams";
857
+ adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
858
858
  userId: string;
859
859
  }): Promise<unknown>;
860
860
  chat_registerChannel(args: {
861
- adapter: "telegram" | "slack" | "discord" | "teams";
861
+ adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
862
862
  channelId: string;
863
863
  agentId?: string;
864
864
  workflowId?: string;
865
865
  name?: string;
866
866
  }): Promise<unknown>;
867
867
  chat_unregisterChannel(args: {
868
- adapter: "telegram" | "slack" | "discord" | "teams";
868
+ adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
869
869
  channelId: string;
870
870
  }): Promise<unknown>;
871
871
 
@@ -118,13 +118,13 @@ declare module "swarm-extension" {
118
118
  sourceAgentId?: string | undefined;
119
119
  role?: string | undefined;
120
120
  harnessProvider?:
121
+ | "codex"
121
122
  | "pi"
123
+ | "opencode"
122
124
  | "claude"
123
125
  | "claude-managed"
124
- | "codex"
125
126
  | "grok"
126
127
  | "fx"
127
- | "opencode"
128
128
  | "dsh"
129
129
  | "cursor"
130
130
  | "amp"
@@ -286,13 +286,13 @@ declare module "swarm-extension" {
286
286
  requestedByUserId?: string | undefined;
287
287
  swarmVersion?: string | undefined;
288
288
  provider?:
289
+ | "codex"
289
290
  | "pi"
291
+ | "opencode"
290
292
  | "claude"
291
293
  | "claude-managed"
292
- | "codex"
293
294
  | "grok"
294
295
  | "fx"
295
- | "opencode"
296
296
  | "dsh"
297
297
  | "cursor"
298
298
  | "amp"
@@ -309,13 +309,13 @@ declare module "swarm-extension" {
309
309
  sourceAgentId?: string | undefined;
310
310
  role?: string | undefined;
311
311
  harnessProvider?:
312
+ | "codex"
312
313
  | "pi"
314
+ | "opencode"
313
315
  | "claude"
314
316
  | "claude-managed"
315
- | "codex"
316
317
  | "grok"
317
318
  | "fx"
318
- | "opencode"
319
319
  | "dsh"
320
320
  | "cursor"
321
321
  | "amp"
@@ -353,7 +353,7 @@ declare module "swarm-extension" {
353
353
  sourceTaskId: string | undefined;
354
354
  auditSourceTaskId: string | undefined;
355
355
  contextKey: string | undefined;
356
- callOrigin: "mcp" | "native" | "extension" | "script-sdk";
356
+ callOrigin: "native" | "mcp" | "extension" | "script-sdk";
357
357
  harness?: string | undefined;
358
358
  };
359
359
 
@@ -805,25 +805,25 @@ declare module "swarm-sdk" {
805
805
  // --- write: chat sdk ---
806
806
  chat_reply(args: { text?: string; card?: unknown }): Promise<unknown>;
807
807
  chat_post(args: {
808
- adapter: "telegram" | "slack" | "discord" | "teams";
808
+ adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
809
809
  threadId?: string;
810
810
  channelId?: string;
811
811
  text?: string;
812
812
  card?: unknown;
813
813
  }): Promise<unknown>;
814
814
  chat_openDm(args: {
815
- adapter: "telegram" | "slack" | "discord" | "teams";
815
+ adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
816
816
  userId: string;
817
817
  }): Promise<unknown>;
818
818
  chat_registerChannel(args: {
819
- adapter: "telegram" | "slack" | "discord" | "teams";
819
+ adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
820
820
  channelId: string;
821
821
  agentId?: string;
822
822
  workflowId?: string;
823
823
  name?: string;
824
824
  }): Promise<unknown>;
825
825
  chat_unregisterChannel(args: {
826
- adapter: "telegram" | "slack" | "discord" | "teams";
826
+ adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
827
827
  channelId: string;
828
828
  }): Promise<unknown>;
829
829