@desplega.ai/agent-swarm 2.13.0 → 2.13.1

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 (268) hide show
  1. package/dist/acp-adapter-xtj40wd8.js +17 -0
  2. package/dist/{acp-targets-86f0sh6g.js → acp-targets-n7vm5atw.js} +10 -10
  3. package/dist/{actions-zv8vcxvr.js → actions-hq6wp9xv.js} +27 -27
  4. package/dist/{agent-fs-provision-jqshb33y.js → agent-fs-provision-y0qc1rdd.js} +4 -4
  5. package/dist/{amp-adapter-gt503ywc.js → amp-adapter-1qqs6h91.js} +3 -3
  6. package/dist/{app-6t4k5rh1.js → app-7m4z44rv.js} +10 -10
  7. package/dist/{approval-notifications-fcfw063h.js → approval-notifications-8sr41gjx.js} +11 -11
  8. package/dist/{assistant-9dzybh12.js → assistant-hkczwfv6.js} +28 -28
  9. package/dist/{boot-args-schema-xzfp2feg.js → boot-args-schema-8025snev.js} +1 -1
  10. package/dist/{boot-reembed-r88wngfg.js → boot-reembed-15m87nr1.js} +1 -1
  11. package/dist/{boot-reembed-3jz0p2jk.js → boot-reembed-4bbpxjh1.js} +1 -1
  12. package/dist/{boot-scrub-sweep-scrqhw48.js → boot-scrub-sweep-eajr97e9.js} +2 -2
  13. package/dist/{boot-seeds-vb2dcrrb.js → boot-seeds-9cwy39jx.js} +4 -4
  14. package/dist/{boxd-68n75y1s.js → boxd-hr8rsxzq.js} +1 -1
  15. package/dist/{claude-adapter-h3mp9hgs.js → claude-adapter-g61wa4rt.js} +9 -9
  16. package/dist/{claude-managed-adapter-kpbyj2vb.js → claude-managed-adapter-znkk0prm.js} +3 -3
  17. package/dist/{claude-managed-setup-0efr3wkg.js → claude-managed-setup-f1wndkr2.js} +2 -2
  18. package/dist/{claude-sdk-session-03dw669q.js → claude-sdk-session-687xzf21.js} +20763 -19381
  19. package/dist/{cli-gfcv679k.js → cli-04103ryh.js} +1 -1
  20. package/dist/{cli-hbq0kwxz.js → cli-0a336ze7.js} +4 -4
  21. package/dist/{cli-1v82d2w6.js → cli-0fx95c06.js} +4 -4
  22. package/dist/{cli-wxwv3t11.js → cli-0m77n7ej.js} +3 -3
  23. package/dist/{cli-j53hpbsm.js → cli-0xwb7zpt.js} +2 -2
  24. package/dist/{cli-0dg7ytxm.js → cli-13t0smbk.js} +917 -23
  25. package/dist/{cli-0pazkmd4.js → cli-1b5axkt1.js} +4 -4
  26. package/dist/{cli-6h88mn9q.js → cli-1carhg8g.js} +4 -4
  27. package/dist/{cli-hgsxnjyg.js → cli-1dr5at77.js} +10 -10
  28. package/dist/{cli-0jkenasr.js → cli-2v4xxnx2.js} +1 -1
  29. package/dist/{cli-dnh64e8e.js → cli-32xndx6b.js} +6 -6
  30. package/dist/{cli-hpb9x72z.js → cli-3m8vqehw.js} +9 -9
  31. package/dist/{cli-ercwc8xn.js → cli-3mf04tkh.js} +1 -1
  32. package/dist/{cli-7dbhnsj9.js → cli-3zyme1wt.js} +4 -4
  33. package/dist/{cli-s6zk31gr.js → cli-43dsqhcp.js} +4 -4
  34. package/dist/{cli-t35hx078.js → cli-4h90xaet.js} +2 -2
  35. package/dist/{cli-117g15t4.js → cli-4mj5g29m.js} +8 -8
  36. package/dist/{cli-47hz21se.js → cli-4tbvndmm.js} +4 -5
  37. package/dist/{cli-tn91wc6e.js → cli-50whymxq.js} +1 -1
  38. package/dist/{cli-js10kdk7.js → cli-5basv0e7.js} +19 -5
  39. package/dist/{cli-xfjn2kyq.js → cli-5v6b2am8.js} +5 -5
  40. package/dist/{cli-49f5jyhh.js → cli-6r1dwegd.js} +3 -3
  41. package/dist/{cli-kspxjftk.js → cli-7ewre3dm.js} +15 -6
  42. package/dist/{cli-n3qe7tyr.js → cli-84xtgbn6.js} +35 -2
  43. package/dist/{cli-w14j2z4k.js → cli-8cmjkbvj.js} +2 -2
  44. package/dist/{cli-2m6yaq6b.js → cli-8fj8yfmk.js} +1 -1
  45. package/dist/{cli-9m9kyw77.js → cli-8rbkw18r.js} +2 -2
  46. package/dist/{cli-x05p2d05.js → cli-9tevdxyf.js} +1 -1
  47. package/dist/{cli-f1952kjy.js → cli-9xx36trj.js} +4 -4
  48. package/dist/{cli-hc6e4tac.js → cli-a8ts6x1n.js} +6 -6
  49. package/dist/{cli-mh7pdxe0.js → cli-aebswqmz.js} +12 -12
  50. package/dist/{cli-ex1y88j3.js → cli-at67kvnp.js} +1 -1
  51. package/dist/{cli-b2jh3dyb.js → cli-bjmq14k9.js} +4 -4
  52. package/dist/{cli-mz34pxbk.js → cli-byxsctca.js} +11 -11
  53. package/dist/{cli-dka73bak.js → cli-c0tyzt73.js} +152 -12
  54. package/dist/{cli-wv20kbr3.js → cli-c8kqmzzf.js} +5 -5
  55. package/dist/{cli-qhhb30e8.js → cli-cd9acnvd.js} +9 -9
  56. package/dist/{cli-wndegmns.js → cli-cmgdptmx.js} +3 -3
  57. package/dist/{cli-1dbv9mj9.js → cli-cn6fpa1p.js} +1 -1
  58. package/dist/{cli-wrhbym01.js → cli-cp0m07wb.js} +6 -6
  59. package/dist/{cli-3p288654.js → cli-cpkxh68d.js} +2 -2
  60. package/dist/{cli-g6j6ac3h.js → cli-cqxwjb93.js} +2 -2
  61. package/dist/{cli-8hp56wat.js → cli-d2epqm0y.js} +1 -1
  62. package/dist/{cli-qm3ntjqs.js → cli-dd57p1gd.js} +13 -13
  63. package/dist/{cli-tstj6e8e.js → cli-fn8aj7gb.js} +250 -55
  64. package/dist/{cli-bpje8n65.js → cli-fp65jdp2.js} +31 -6
  65. package/dist/{cli-2skf1mdf.js → cli-gedf48yw.js} +4 -4
  66. package/dist/{cli-c8v2yvej.js → cli-gq6qhmrr.js} +2 -2
  67. package/dist/{cli-sq913bh1.js → cli-grcc2h2g.js} +8 -8
  68. package/dist/{cli-qec9bynj.js → cli-h03j6je3.js} +3 -3
  69. package/dist/{cli-mbwmqb5w.js → cli-h0ewec3d.js} +1 -1
  70. package/dist/{cli-jj3c5nyb.js → cli-h9bejmkf.js} +76 -39
  71. package/dist/{cli-ct8sz3np.js → cli-hs3mqswp.js} +6 -6
  72. package/dist/{cli-tdk7jtka.js → cli-hv3820ez.js} +1 -1
  73. package/dist/{cli-pqfecppn.js → cli-je587f74.js} +1 -1
  74. package/dist/{cli-y4a4458j.js → cli-jhtvt7gn.js} +3 -3
  75. package/dist/{cli-dkejt425.js → cli-mmw2sjaf.js} +7 -7
  76. package/dist/{cli-50w82h6m.js → cli-mwxez0pz.js} +1 -0
  77. package/dist/{cli-avxh26pd.js → cli-nk8swfpx.js} +4 -4
  78. package/dist/{cli-fhvk2nvp.js → cli-p7g7wd9n.js} +9 -9
  79. package/dist/{cli-bhgrhedp.js → cli-q8aq48v1.js} +1 -1
  80. package/dist/{cli-6a40p4kv.js → cli-qn79645p.js} +1 -1
  81. package/dist/{cli-nc6a8b5b.js → cli-qx1dwrr5.js} +2 -2
  82. package/dist/{cli-sdh61g52.js → cli-s6fhqbz1.js} +2 -2
  83. package/dist/{cli-eb279wn3.js → cli-sfajkbd7.js} +2 -2
  84. package/dist/{cli-z64t9pe6.js → cli-snypfjgj.js} +1 -1
  85. package/dist/{cli-ytc7fpza.js → cli-t25rq8mg.js} +4 -4
  86. package/dist/{cli-zqmmy073.js → cli-t90k0phh.js} +18 -18
  87. package/dist/{cli-fz9pcjsw.js → cli-tzzas8rb.js} +4 -4
  88. package/dist/{cli-rtmqzat7.js → cli-vdfngx2g.js} +2 -2
  89. package/dist/{cli-9w8712tq.js → cli-vr4eyq6p.js} +43 -14
  90. package/dist/{cli-z4f346g5.js → cli-vx9acp12.js} +1 -1
  91. package/dist/{cli-y518qkjg.js → cli-w24f3j49.js} +10 -10
  92. package/dist/{cli-yn4kt85g.js → cli-w41bvvms.js} +1 -1
  93. package/dist/{cli-9fsagra4.js → cli-w6c6dj91.js} +1 -1
  94. package/dist/{cli-kde4ky90.js → cli-x5yb8zc8.js} +2 -2
  95. package/dist/{cli-48nvk6sb.js → cli-xhkek467.js} +2 -2
  96. package/dist/{cli-avqkr20b.js → cli-y6qqbpwc.js} +2 -2
  97. package/dist/{cli-7wy8gbwb.js → cli-ya1cj689.js} +1 -1
  98. package/dist/{cli-prf7kz78.js → cli-yeh3g1q6.js} +603 -78
  99. package/dist/{cli-ajjvqhf3.js → cli-z6m6xzxt.js} +2 -2
  100. package/dist/{cli-2jk4s7z1.js → cli-zaate0rd.js} +3 -3
  101. package/dist/{cli-n85m2wkq.js → cli-zkbz8m2q.js} +3 -2
  102. package/dist/{cli-0b655smz.js → cli-zvpkrgsc.js} +5 -5
  103. package/dist/cli.js +27 -27
  104. package/dist/{codex-adapter-f3yp0kaj.js → codex-adapter-ysfg6ty3.js} +8 -8
  105. package/dist/{codex-hook-262cekfp.js → codex-hook-c0nvm30r.js} +2 -2
  106. package/dist/{codex-login-1ven7yje.js → codex-login-ven5cz5j.js} +1 -1
  107. package/dist/{codex-session-runner-ns4mv70p.js → codex-session-runner-823scr6g.js} +9 -9
  108. package/dist/{commands-5bzf2tfw.js → commands-5rbm07fz.js} +3 -3
  109. package/dist/{controller-5xt7kvfm.js → controller-wn3vd217.js} +3 -3
  110. package/dist/{controllers-connect-0gg13mzp.js → controllers-connect-34jzhfft.js} +28 -28
  111. package/dist/core-kdehq26g.js +42 -0
  112. package/dist/{cursor-adapter-p0c5zv6r.js → cursor-adapter-w1681kp1.js} +2 -2
  113. package/dist/{db-2s68ycq7.js → db-6bkgbfwk.js} +3 -3
  114. package/dist/{db-q7q639k5.js → db-hcj16x7z.js} +2 -2
  115. package/dist/{devin-adapter-t8d86q9x.js → devin-adapter-fs90ab4v.js} +1 -1
  116. package/dist/{dispatcher-j2y1q7ae.js → dispatcher-jgjqrfzv.js} +25 -25
  117. package/dist/{docker-1b41eysj.js → docker-1h33jvh9.js} +2 -2
  118. package/dist/{dsh-adapter-pgnkf4st.js → dsh-adapter-g9yqv09y.js} +2 -2
  119. package/dist/{e2b-xm60c8ad.js → e2b-jnk0yeva.js} +2 -2
  120. package/dist/{e2b-ew8c5j5v.js → e2b-y7e5kmzf.js} +2 -2
  121. package/dist/{easter-egg-3d-0kea97jf.js → easter-egg-3d-w17nsny6.js} +1 -1
  122. package/dist/{embedding-space-3n6mhhmy.js → embedding-space-v06fwy7b.js} +6 -6
  123. package/dist/{embeddings-jfmj6yme.js → embeddings-g50dxea4.js} +1 -1
  124. package/dist/{event-bus-v4ywhc2p.js → event-bus-08t2b4y2.js} +1 -1
  125. package/dist/{execute-tjrej979.js → execute-1n36haw1.js} +1 -1
  126. package/dist/{external-channel-jy8w2gg3.js → external-channel-43tv8pg6.js} +2 -2
  127. package/dist/fx-adapter-bvh05t4a.js +20 -0
  128. package/dist/grok-adapter-my5j8mdf.js +20 -0
  129. package/dist/handlers-wyymeeqh.js +41 -0
  130. package/dist/heartbeat-sf3nk937.js +50 -0
  131. package/dist/{hook-bpnncsec.js → hook-dqph1e05.js} +8 -8
  132. package/dist/{hook-fv1jwrv7.js → hook-m1m9dm6w.js} +6 -6
  133. package/dist/{http-bpa26czn.js → http-w0th1cz9.js} +160 -102
  134. package/dist/index-22khdtby.js +44 -0
  135. package/dist/{index-mpj0z9e0.js → index-c0e8en64.js} +1 -1
  136. package/dist/{index-620y7jzq.js → index-e8pz8qdg.js} +3 -3
  137. package/dist/{index-8p0j4h4j.js → index-ez823q84.js} +94 -89
  138. package/dist/{index-w216g9y9.js → index-ffba0z8q.js} +35 -21
  139. package/dist/{index-s8re7mvq.js → index-gkpfgpg7.js} +1 -1
  140. package/dist/{index-4k7m5dgj.js → index-k8ajc0g0.js} +143 -103
  141. package/dist/index-np0582ac.js +40 -0
  142. package/dist/{index-52tgbhrw.js → index-pb03vans.js} +28 -28
  143. package/dist/index-vgkrj1jt.js +39 -0
  144. package/dist/{index-pe3d8jfy.js → index-whysn1wf.js} +1 -1
  145. package/dist/{index-0h6qd4p1.js → index-y4vd4mhn.js} +3 -4
  146. package/dist/{k8s-fy8hbhkg.js → k8s-8326q0rq.js} +2 -2
  147. package/dist/{keepalive-d6z12s04.js → keepalive-2v06q2e8.js} +5 -4
  148. package/dist/lead-55z813ng.js +79 -0
  149. package/dist/{maintenance-7kac6g2g.js → maintenance-vx7vjhhy.js} +1 -1
  150. package/dist/{oauth-refresh-sweep-t1xjetbh.js → oauth-refresh-sweep-g06k4bza.js} +4 -3
  151. package/dist/{object-webhooks-6rdagg0r.js → object-webhooks-3dzdq4fm.js} +7 -7
  152. package/dist/{onboard-32y1cfxy.js → onboard-232pazny.js} +4 -4
  153. package/dist/{opencode-adapter-enp3v31n.js → opencode-adapter-t0paqbh8.js} +8 -8
  154. package/dist/{otel-impl-k0tm5ptj.js → otel-impl-kmpkyp4y.js} +2 -2
  155. package/dist/{pending-24zebgvs.js → pending-x0z3vx1x.js} +26 -26
  156. package/dist/{pi-mono-adapter-yj72xxxe.js → pi-mono-adapter-7pmypn6d.js} +17 -15
  157. package/dist/{pricing-refresh-cf25x38j.js → pricing-refresh-ytjmtyd7.js} +2 -2
  158. package/dist/{rbac-roles-0wydd22m.js → rbac-roles-fgm5mxr2.js} +3 -3
  159. package/dist/{rbac-roles-at6crb3r.js → rbac-roles-xyaxekh3.js} +2 -2
  160. package/dist/{render-v2-nvcw0jd7.js → render-v2-ws972g4r.js} +10 -10
  161. package/dist/{resume-y4w0k5v3.js → resume-m6mjzhkp.js} +13 -13
  162. package/dist/{runtime-vpe43hx0.js → runtime-zzpc0c8a.js} +1 -1
  163. package/dist/{session-access-gkyvnfye.js → session-access-vp35xs91.js} +5 -5
  164. package/dist/{session-source-backfill-3w2st4m2.js → session-source-backfill-p73e8zbe.js} +2 -2
  165. package/dist/{setup-axxvqtys.js → setup-r4kd7rxg.js} +1 -1
  166. package/dist/thread-buffer-cm2nzq6t.js +42 -0
  167. package/dist/{tree-visibility-y4fqvab5.js → tree-visibility-07h2tbs2.js} +2 -2
  168. package/dist/{user-merge-jobs-kcmwvrc6.js → user-merge-jobs-96vg9rpe.js} +3 -3
  169. package/dist/{virtual-modules-7d92dct1.js → virtual-modules-vgn3f2x4.js} +3 -3
  170. package/dist/{work-objects-f708e069.js → work-objects-74hbcx3e.js} +28 -28
  171. package/dist/worker-5pn2vzx6.js +79 -0
  172. package/dist/{worker-follow-up-0by8wztc.js → worker-follow-up-ezavwn5d.js} +25 -25
  173. package/dist/{x-3dtaf2r9.js → x-asbrnafg.js} +2 -2
  174. package/openapi.json +1793 -1622
  175. package/package.json +10 -10
  176. package/src/apps/catalog.generated.json +726 -0
  177. package/src/apps/definition.ts +24 -7
  178. package/src/apps/page-validator.ts +225 -3
  179. package/src/be/db.ts +38 -10
  180. package/src/be/mcp-proxy.ts +5 -4
  181. package/src/be/migrations/340_api_key_spend_cap.sql +5 -0
  182. package/src/be/schedules/validate.ts +26 -0
  183. package/src/be/swarm-config-guard.ts +4 -0
  184. package/src/commands/credential-outcome-report.ts +5 -2
  185. package/src/commands/onboard/agent-fs-version.ts +1 -1
  186. package/src/commands/provider-credentials.ts +19 -0
  187. package/src/commands/provider-error-class.ts +4 -1
  188. package/src/commands/rate-limit-outcome.ts +48 -3
  189. package/src/commands/runner.ts +113 -55
  190. package/src/commands/worktree-reaper.ts +600 -0
  191. package/src/extensions/contract-types.generated.ts +1 -1
  192. package/src/http/agents.ts +4 -0
  193. package/src/http/api-keys.ts +27 -3
  194. package/src/http/pages-public.ts +40 -4
  195. package/src/http/pool-keys.ts +21 -2
  196. package/src/http/schedules.ts +28 -3
  197. package/src/http/script-connections.ts +12 -4
  198. package/src/http/script-runs.ts +12 -3
  199. package/src/http/tasks.ts +6 -10
  200. package/src/mcp-client/http-client.ts +3 -1
  201. package/src/oauth/identity-capture.ts +6 -1
  202. package/src/oauth/mcp-wrapper.ts +10 -3
  203. package/src/oauth/wrapper.ts +15 -3
  204. package/src/prompts/session-templates.ts +1 -0
  205. package/src/providers/acp-targets.ts +2 -2
  206. package/src/providers/amp-adapter.ts +1 -1
  207. package/src/providers/dsh-adapter.ts +1 -1
  208. package/src/providers/pi-mono-adapter.ts +4 -2
  209. package/src/providers/runtime-dependencies.ts +1 -1
  210. package/src/rbac/legacy-policy.ts +2 -0
  211. package/src/rbac/permissions.ts +5 -0
  212. package/src/scripts-runtime/types/swarm-extension.d.ts +7 -7
  213. package/src/slack/enrich.ts +14 -11
  214. package/src/tests/agents-list-model-display.test.ts +23 -0
  215. package/src/tests/apps-spike2.test.ts +35 -0
  216. package/src/tests/base-prompt.test.ts +1 -0
  217. package/src/tests/deploy-guard.test.ts +24 -0
  218. package/src/tests/dsh-adapter.test.ts +1 -1
  219. package/src/tests/ensure-token.test.ts +2 -2
  220. package/src/tests/entrypoint-repo-autoclone-args.test.ts +202 -0
  221. package/src/tests/fake-dns.ts +47 -0
  222. package/src/tests/fixtures/base-prompt-baseline.json +12 -12
  223. package/src/tests/latest-model-report.test.ts +138 -0
  224. package/src/tests/mcp-oauth-dcr-reuse.test.ts +5 -2
  225. package/src/tests/mcp-oauth-ensure-token.test.ts +3 -2
  226. package/src/tests/mcp-oauth-manual-client.test.ts +6 -1
  227. package/src/tests/mcp-oauth-wrapper.test.ts +20 -4
  228. package/src/tests/mcp-outbound-fetch-guard.test.ts +169 -0
  229. package/src/tests/mcp-server-ssrf.test.ts +2 -0
  230. package/src/tests/memory-search-stall.test.ts +5 -0
  231. package/src/tests/oauth-connection-fetch-guard.test.ts +162 -0
  232. package/src/tests/oauth-token-endpoint-fetch-guard.test.ts +121 -0
  233. package/src/tests/oauth-wrapper.test.ts +1 -2
  234. package/src/tests/pages-head-v2.test.ts +2 -1
  235. package/src/tests/script-connections-http.test.ts +8 -3
  236. package/src/tests/script-connections.test.ts +2 -0
  237. package/src/tests/slack-thread-participants.test.ts +14 -3
  238. package/src/tests/spend-cap-credentials.test.ts +34 -0
  239. package/src/tests/spend-cap-outcome.test.ts +67 -0
  240. package/src/tests/subscription-first.test.ts +119 -0
  241. package/src/tests/worktree-reaper.test.ts +424 -0
  242. package/src/tools/get-task-details.ts +247 -5
  243. package/src/tools/schedules/patch-schedule.ts +26 -1
  244. package/src/tools/schedules/update-schedule.ts +28 -2
  245. package/src/utils/credentials.ts +36 -1
  246. package/src/utils/egress-guard.ts +40 -10
  247. package/src/utils/error-tracker.ts +17 -0
  248. package/templates/skills/apps/SKILL.md +191 -2
  249. package/templates/skills/apps/content.md +191 -2
  250. package/templates/skills/boards-and-sheets/content.md +11 -0
  251. package/templates/skills/pages/content.md +11 -0
  252. package/templates/skills/swarm-docs/content.md +2 -0
  253. package/templates/skills/swarm-scripts/SKILL.md +1 -0
  254. package/templates/skills/swarm-scripts/content.md +1 -0
  255. package/templates/workflows/ralph-loop/content.md +6 -6
  256. package/dist/acp-adapter-cn53011z.js +0 -17
  257. package/dist/cli-pr0eze3x.js +0 -149
  258. package/dist/core-0fqtbrxa.js +0 -42
  259. package/dist/fx-adapter-k6w3jvz9.js +0 -20
  260. package/dist/grok-adapter-4q5tssw0.js +0 -20
  261. package/dist/handlers-qxgfvvsf.js +0 -41
  262. package/dist/heartbeat-6tr2w2da.js +0 -50
  263. package/dist/index-0mcxjdsa.js +0 -44
  264. package/dist/index-dz4q23ag.js +0 -40
  265. package/dist/index-s175jckx.js +0 -39
  266. package/dist/lead-p3hx7h35.js +0 -79
  267. package/dist/thread-buffer-rwa7d4dx.js +0 -42
  268. package/dist/worker-8rg9gz74.js +0 -79
@@ -1,5 +1,9 @@
1
1
  import * as oauth from "oauth4webapi";
2
- import { assertUrlSafe, type SsrfGuardOptions } from "../utils/egress-guard";
2
+ import {
3
+ assertUrlSafe,
4
+ createSsrfGuardedFetch,
5
+ type SsrfGuardOptions,
6
+ } from "../utils/egress-guard";
3
7
  import { isEnvFlagEnabled } from "../utils/env-flag";
4
8
  import { isDevOrTestNodeEnv } from "../utils/node-env";
5
9
  import { registerVolatileSecret, scrubSecrets } from "../utils/secret-scrubber";
@@ -74,8 +78,11 @@ async function safeFetch(
74
78
  init?: RequestInit,
75
79
  timeoutMs: number = DEFAULT_FETCH_TIMEOUT_MS,
76
80
  ): Promise<Response> {
77
- assertUrlSafe(url, mcpOAuthSsrfOptions());
78
- return fetch(url, { ...init, signal: init?.signal ?? AbortSignal.timeout(timeoutMs) });
81
+ // Checks every redirect hop and the resolved address, not just the URL string.
82
+ return createSsrfGuardedFetch(mcpOAuthSsrfOptions())(url, {
83
+ ...init,
84
+ signal: init?.signal ?? AbortSignal.timeout(timeoutMs),
85
+ });
79
86
  }
80
87
 
81
88
  // ─── Protected Resource Metadata (RFC 9728) ──────────────────────────────────
@@ -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.1794571247-g07b20f";
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":
@@ -362,6 +362,8 @@ export const LEGACY_POLICY = {
362
362
  "script.api.rotate": leadOnly,
363
363
  "script.api.delete": leadOnly,
364
364
  "schedule.deferral.update.any": leadOrResourceOwner,
365
+ // A schedule fires as its creator, so only the creator or a lead picks what it runs.
366
+ "schedule.target.update.any": leadOrResourceOwner,
365
367
  // Pool writes pick the image that receives a runtime token, so only humans
366
368
  // may make them. The lead may only place agents into operator-made pools.
367
369
  "runtime_pool.write": operatorOrUser,
@@ -410,6 +410,11 @@ export const PERMISSIONS = {
410
410
  description: "Change a defer-task schedule the caller did not create.",
411
411
  namespace: "schedule",
412
412
  },
413
+ "schedule.target.update.any": {
414
+ description:
415
+ "Change what a schedule the caller did not create runs (its target, task template, workflow, script, script args or params).",
416
+ namespace: "schedule",
417
+ },
413
418
  "runtime_pool.write": {
414
419
  description: "Create, update, or delete runtime pools (image, provider kind, placement).",
415
420
  namespace: "runtime_pool",
@@ -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
 
@@ -168,7 +168,7 @@ export async function resolveSlackParticipant(
168
168
  // Another team's profile email is set by that team, not verified as owned by
169
169
  // this sender, so it never links to an existing user. An operator can link
170
170
  // the alias by hand. With our own team unknown (`auth.test` failed), a sender
171
- // that carries a team is not linked either; trust below still reads the email.
171
+ // that carries a team is not linked either, and its email grants no trust.
172
172
  const linkable = !eventContext.userTeam || sameTeam === true;
173
173
  if (!user && email && linkable) {
174
174
  if (isCompanyEmail(email, domains)) {
@@ -207,17 +207,20 @@ export async function resolveSlackParticipant(
207
207
  ? audience
208
208
  : foreignTeam
209
209
  ? "external"
210
- : domains.length === 0
211
- ? user
212
- ? "internal"
213
- : email
214
- ? "external"
215
- : "unknown"
216
- : !email
217
- ? "unknown"
218
- : isCompanyEmail(email, domains)
210
+ : // Own team unknown: the sender's team may be foreign, so its email proves nothing.
211
+ eventContext.userTeam && sameTeam === undefined
212
+ ? "unknown"
213
+ : domains.length === 0
214
+ ? user
219
215
  ? "internal"
220
- : "external";
216
+ : email
217
+ ? "external"
218
+ : "unknown"
219
+ : !email
220
+ ? "unknown"
221
+ : isCompanyEmail(email, domains)
222
+ ? "internal"
223
+ : "external";
221
224
  return { userId: user?.id, trust };
222
225
  }
223
226
 
@@ -56,6 +56,29 @@ describe("agents list model display", () => {
56
56
  });
57
57
  });
58
58
 
59
+ test("a last run whose model the task chose is not flagged as a pending change", () => {
60
+ const display = getAgentModelDisplay(
61
+ "openai-codex/gpt-6.1-sol",
62
+ "openrouter/deepseek/deepseek-v4.1-flash",
63
+ undefined,
64
+ "task",
65
+ );
66
+
67
+ expect(display.diverged).toBe(false);
68
+ expect(display.lastUsedFromTask).toBe(true);
69
+ expect(display.primary).toBe("openai-codex/gpt-6.1-sol");
70
+ });
71
+
72
+ test("a last run on neither the saved model nor a task's pick still reads as next task", () => {
73
+ expect(
74
+ getAgentModelDisplay("claude-opus-4-7", "claude-sonnet-4-6", undefined, "agent_config")
75
+ .diverged,
76
+ ).toBe(true);
77
+ expect(
78
+ getAgentModelDisplay("claude-opus-4-7", "claude-sonnet-4-6", undefined, "custom").diverged,
79
+ ).toBe(true);
80
+ });
81
+
59
82
  test("shows configured model alone before an agent reports a last-used model", () => {
60
83
  const display = getAgentModelDisplay("claude-opus-4-7", null);
61
84
 
@@ -1035,8 +1035,42 @@ describe("custom app actions", () => {
1035
1035
  agentId: OTHER_AGENT_ID,
1036
1036
  typeChecked: true,
1037
1037
  });
1038
+ // A global script another agent wrote runs as that agent at invoke time.
1039
+ const foreignGlobal = await upsertScriptByName({
1040
+ name: `app_action_foreign_global_${crypto.randomUUID().replaceAll("-", "")}`,
1041
+ scope: "global",
1042
+ scopeId: null,
1043
+ source: "export default function run() { return { ok: true }; }",
1044
+ description: "Foreign-written global action fixture",
1045
+ intent: "Prove the script ownership gate for global scripts",
1046
+ signatureJson: JSON.stringify({ args: { type: "object" }, result: { type: "object" } }),
1047
+ agentId: LEAD_ID,
1048
+ typeChecked: true,
1049
+ });
1038
1050
 
1039
1051
  try {
1052
+ const deniedGlobal = await request<{ issues: Array<{ path: string; message: string }> }>(
1053
+ "/api/apps",
1054
+ {
1055
+ method: "POST",
1056
+ body: JSON.stringify({
1057
+ name: "Foreign global wire",
1058
+ definition: {
1059
+ ...baseDefinition,
1060
+ actions: { run: { kind: "script", scriptId: foreignGlobal.script.id } },
1061
+ },
1062
+ }),
1063
+ },
1064
+ );
1065
+ expect(deniedGlobal.status).toBe(400);
1066
+ expect(
1067
+ deniedGlobal.body.issues.some(
1068
+ (issue) =>
1069
+ issue.path === "actions.run.scriptId" &&
1070
+ issue.message.includes("only that agent or the operator"),
1071
+ ),
1072
+ ).toBe(true);
1073
+
1040
1074
  // An agent writer referencing a foreign agent-scoped script is rejected.
1041
1075
  const denied = await request<{ issues: Array<{ path: string; message: string }> }>(
1042
1076
  "/api/apps",
@@ -1084,6 +1118,7 @@ describe("custom app actions", () => {
1084
1118
  expect(patched.status).toBe(200);
1085
1119
  } finally {
1086
1120
  await deleteScript({ name: foreign.script.name, scope: "agent", scopeId: OTHER_AGENT_ID });
1121
+ await deleteScript({ name: foreignGlobal.script.name, scope: "global" });
1087
1122
  }
1088
1123
  });
1089
1124
 
@@ -829,6 +829,7 @@ For task waits, add \`wakeOn:{event:"settled",taskIds:["<id>"],mode:"all"}\`; th
829
829
  ## Workspace
830
830
 
831
831
  \`/workspace/personal/\` is yours. \`get-repos\` returns where a repository is cloned.
832
+ Worktrees without unsaved work are removed after your task. To keep one: \`git worktree lock <path>\`.
832
833
  Your profile lives in the database. Edit it with \`update-profile\`: \`soulMd\`, \`identityMd\`, \`heartbeatMd\`, \`setupScript\`, \`toolsMd\`. The files in \`/workspace/\` are mirrors.
833
834
  Your setup script runs at every container start.
834
835
  \`/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\`.
@@ -152,3 +152,27 @@ describe.skipIf(!hasYq && !process.env.CI)("deploy guard (scripts/deploy-guard.s
152
152
  CHILD_PROCESS_TEST_BUDGET_MS,
153
153
  );
154
154
  });
155
+
156
+ // Job-level concurrency orders jobs by when they reach the gate, not by commit:
157
+ // with cancel-in-progress an older run whose detect job finished last cancelled
158
+ // the main tip's builds, and :latest stayed on an older build. Builds now never
159
+ // cancel; a superseded run skips them instead.
160
+ test("build jobs never cancel each other and skip when superseded", async () => {
161
+ type Job = { if?: string; concurrency?: Record<string, unknown> };
162
+ const wf = Bun.YAML.parse(await Bun.file(join(REPO_ROOT, WORKFLOW)).text()) as {
163
+ jobs: Record<string, Job>;
164
+ };
165
+ const builds = Object.entries(wf.jobs).filter(([name]) => name.startsWith("build-and-push-"));
166
+ expect(builds.length).toBeGreaterThanOrEqual(7);
167
+ for (const [name, job] of builds) {
168
+ expect({ name, cancel: job.concurrency?.["cancel-in-progress"] }).toEqual({
169
+ name,
170
+ cancel: false,
171
+ });
172
+ expect({ name, queue: job.concurrency?.queue }).toEqual({ name, queue: "max" });
173
+ expect({ name, if: job.if }).toEqual({
174
+ name,
175
+ if: "needs.detect-version-change.outputs.superseded != 'true'",
176
+ });
177
+ }
178
+ });
@@ -376,7 +376,7 @@ describe("dsh harness", () => {
376
376
  await rename(join(config.cwd, "dsh"), join(config.cwd, "npx"));
377
377
  config.env = { ...config.env, DSH_BINARY: "", PATH: config.cwd };
378
378
  await expect(new DshAdapter().createSession(config)).rejects.toThrow(
379
- "dsh CLI not found. Install @deepseek-ai/dsh@0.2.2-rc.2",
379
+ "dsh CLI not found. Install @deepseek-ai/dsh@0.2.2-rc.3",
380
380
  );
381
381
  expect(await Bun.file(join(config.cwd, "invocation.json")).exists()).toBe(false);
382
382
  });
@@ -92,8 +92,8 @@ describe("ensureToken", () => {
92
92
 
93
93
  // Should have called the token endpoint
94
94
  expect(fetchSpy).toHaveBeenCalledTimes(1);
95
- const [url, init] = fetchSpy.mock.calls[0] as [string, RequestInit];
96
- expect(url).toBe("https://example.com/oauth/token");
95
+ const [url, init] = fetchSpy.mock.calls[0] as [string | URL, RequestInit];
96
+ expect(String(url)).toBe("https://example.com/oauth/token");
97
97
  expect(init.method).toBe("POST");
98
98
  expect(init.body).toContain("grant_type=refresh_token");
99
99
  expect(init.body).toContain("refresh_token=example-refresh-token");
@@ -0,0 +1,202 @@
1
+ import { afterAll, beforeAll, describe, expect, test } from "bun:test";
2
+ import {
3
+ chmodSync,
4
+ existsSync,
5
+ mkdirSync,
6
+ mkdtempSync,
7
+ readFileSync,
8
+ realpathSync,
9
+ rmSync,
10
+ writeFileSync,
11
+ } from "node:fs";
12
+ import { tmpdir } from "node:os";
13
+ import { join } from "node:path";
14
+ import { CHILD_PROCESS_TEST_BUDGET_MS, expectChildOk, runChild } from "./test-proc";
15
+
16
+ /**
17
+ * Runs the real repo auto-clone loop from docker-entrypoint.sh against a
18
+ * scratch repos.json. gosu, git and gh are stubbed: git and gh log their argv
19
+ * one element per line, so the test can check that every repo field reaches
20
+ * the command as exactly one argument and is never parsed as shell.
21
+ */
22
+ const entrypoint = readFileSync("docker-entrypoint.sh", "utf8");
23
+ const loopStart = entrypoint.indexOf(
24
+ "jq -c '.repos[]' /tmp/swarm_repos.json | while read -r repo; do",
25
+ );
26
+ const loopEnd = entrypoint.indexOf("\n done\n", loopStart);
27
+ const loop = entrypoint
28
+ .slice(loopStart, loopEnd + "\n done\n".length)
29
+ .replace("/tmp/swarm_repos.json", '"$REPOS_JSON"');
30
+
31
+ let root = "";
32
+ let bin = "";
33
+ beforeAll(() => {
34
+ root = realpathSync(mkdtempSync(join(tmpdir(), "entrypoint-autoclone-")));
35
+ bin = join(root, "bin");
36
+ mkdirSync(bin);
37
+ // Each stub appends its name and argv (one element per line) to $ARGV_LOG.
38
+ const stub = (name: string, extra = "") =>
39
+ `#!/usr/bin/env bash\n{ echo "== ${name}"; for a in "$@"; do printf '%s\\n' "$a"; done; } >> "$ARGV_LOG"\n${extra}exit 0\n`;
40
+ writeFileSync(join(bin, "gh"), stub("gh"));
41
+ writeFileSync(
42
+ join(bin, "git"),
43
+ stub("git", 'if [ "$1" = branch ]; then echo "$CURRENT_BRANCH"; fi\n'),
44
+ );
45
+ chmodSync(join(bin, "gh"), 0o755);
46
+ chmodSync(join(bin, "git"), 0o755);
47
+ });
48
+ afterAll(() => {
49
+ rmSync(root, { recursive: true, force: true });
50
+ });
51
+
52
+ interface Repo {
53
+ url: string;
54
+ name: string;
55
+ clonePath: string;
56
+ defaultBranch: string;
57
+ }
58
+
59
+ async function runLoop(caseDir: string, repo: Repo, currentBranch = repo.defaultBranch) {
60
+ const reposJson = join(caseDir, "repos.json");
61
+ const argvLog = join(caseDir, "argv.log");
62
+ writeFileSync(reposJson, JSON.stringify({ repos: [{ ...repo, hooks: { enabled: false } }] }));
63
+ writeFileSync(argvLog, "");
64
+ const result = await runChild(
65
+ [
66
+ "bash",
67
+ "-c",
68
+ [
69
+ 'gosu() { shift; "$@"; }',
70
+ "chown() { :; }",
71
+ "chown_no_follow() { :; }",
72
+ "prepare_clone_target() { :; }",
73
+ loop,
74
+ ].join("\n"),
75
+ ],
76
+ {
77
+ cwd: caseDir,
78
+ env: {
79
+ PATH: `${bin}:${process.env.PATH ?? "/usr/bin:/bin"}`,
80
+ REPOS_JSON: reposJson,
81
+ ARGV_LOG: argvLog,
82
+ CURRENT_BRANCH: currentBranch,
83
+ },
84
+ timeoutMs: CHILD_PROCESS_TEST_BUDGET_MS,
85
+ },
86
+ );
87
+ expectChildOk(result, "repo auto-clone loop");
88
+ return readFileSync(argvLog, "utf8");
89
+ }
90
+
91
+ function freshCase(name: string) {
92
+ const dir = join(root, name);
93
+ mkdirSync(dir, { recursive: true });
94
+ return dir;
95
+ }
96
+
97
+ describe("docker-entrypoint.sh repo auto-clone", () => {
98
+ test("located the loop", () => {
99
+ expect(loopStart).toBeGreaterThan(-1);
100
+ expect(loopEnd).toBeGreaterThan(loopStart);
101
+ });
102
+
103
+ test("control: plain fields reach gh and git unchanged", async () => {
104
+ const dir = freshCase("plain");
105
+ const clonePath = join(dir, "repos", "r");
106
+ const cloneLog = await runLoop(dir, {
107
+ url: "https://github.com/o/r",
108
+ name: "r",
109
+ clonePath,
110
+ defaultBranch: "main",
111
+ });
112
+ expect(cloneLog).toContain(
113
+ `== gh\nrepo\nclone\nhttps://github.com/o/r\n${clonePath}\n--\n--branch\nmain\n--single-branch\n`,
114
+ );
115
+
116
+ mkdirSync(join(clonePath, ".git"), { recursive: true });
117
+ const syncLog = await runLoop(dir, {
118
+ url: "https://github.com/o/r",
119
+ name: "r",
120
+ clonePath,
121
+ defaultBranch: "main",
122
+ });
123
+ expect(syncLog).toContain("== git\nreset\n--hard\norigin/main\n");
124
+ });
125
+
126
+ test("a quote in the url stays inside the url argument", async () => {
127
+ const dir = freshCase("url");
128
+ const marker = join(dir, "marker");
129
+ const url = `https://github.com/o/r'; touch '${marker}'; echo '`;
130
+ const log = await runLoop(dir, {
131
+ url,
132
+ name: "r",
133
+ clonePath: join(dir, "repos", "r"),
134
+ defaultBranch: "main",
135
+ });
136
+ expect(existsSync(marker)).toBe(false);
137
+ expect(log.split("\n")).toContain(url);
138
+ });
139
+
140
+ test("a quote in the url stays inside the url argument for plain git hosts", async () => {
141
+ const dir = freshCase("url-git");
142
+ const marker = join(dir, "marker");
143
+ const url = `https://gitlab.example.com/o/r'; touch '${marker}'; echo '`;
144
+ const log = await runLoop(dir, {
145
+ url,
146
+ name: "r",
147
+ clonePath: join(dir, "repos", "r"),
148
+ defaultBranch: "main",
149
+ });
150
+ expect(existsSync(marker)).toBe(false);
151
+ expect(log.split("\n")).toContain(url);
152
+ });
153
+
154
+ test("a quote in the clone path stays inside the path argument", async () => {
155
+ const dir = freshCase("path");
156
+ const marker = join(dir, "marker");
157
+ const clonePath = join(dir, "repos", `r'; touch '${marker}'; echo '`);
158
+ const log = await runLoop(dir, {
159
+ url: "https://github.com/o/r",
160
+ name: "r",
161
+ clonePath,
162
+ defaultBranch: "main",
163
+ });
164
+ expect(existsSync(marker)).toBe(false);
165
+ expect(log.split("\n")).toContain(clonePath);
166
+ });
167
+
168
+ test("a quote in the default branch stays inside the branch argument when syncing", async () => {
169
+ const dir = freshCase("branch-sync");
170
+ const marker = join(dir, "marker");
171
+ const clonePath = join(dir, "repos", "r");
172
+ mkdirSync(join(clonePath, ".git"), { recursive: true });
173
+ const branch = `main'; touch '${marker}'; echo '`;
174
+ await runLoop(dir, {
175
+ url: "https://github.com/o/r",
176
+ name: "r",
177
+ clonePath,
178
+ defaultBranch: branch,
179
+ });
180
+ expect(existsSync(marker)).toBe(false);
181
+ });
182
+
183
+ test("a url or branch that starts with a dash is skipped, never passed to git as an option", async () => {
184
+ const dir = freshCase("dash");
185
+ const clonePath = join(dir, "repos", "r");
186
+ mkdirSync(join(clonePath, ".git"), { recursive: true });
187
+ const branchLog = await runLoop(dir, {
188
+ url: "https://github.com/o/r",
189
+ name: "r",
190
+ clonePath,
191
+ defaultBranch: "--upload-pack=true",
192
+ });
193
+ const urlLog = await runLoop(dir, {
194
+ url: "--upload-pack=true",
195
+ name: "r",
196
+ clonePath: join(dir, "repos", "fresh"),
197
+ defaultBranch: "main",
198
+ });
199
+ expect(branchLog).not.toContain("--upload-pack");
200
+ expect(urlLog).not.toContain("--upload-pack");
201
+ });
202
+ });
@@ -0,0 +1,47 @@
1
+ import { mock } from "bun:test";
2
+ import * as realDns from "node:dns/promises";
3
+
4
+ /**
5
+ * Import first in a test file whose code resolves hostnames through
6
+ * `node:dns/promises` (the guarded fetches in src/utils/egress-guard.ts).
7
+ * Reserved example names (RFC 2606 / RFC 6761: example.com, .example, .test,
8
+ * .invalid) resolve in-process to a public address, so those tests never
9
+ * touch real DNS. `setFakeDnsAnswer` pins a name to other addresses. Every
10
+ * other name goes to the real resolver, so the mock is harmless to files that
11
+ * share the process.
12
+ */
13
+
14
+ export const FAKE_PUBLIC_ADDRESS = "93.184.216.34";
15
+
16
+ const answers = new Map<string, string[]>();
17
+
18
+ export function setFakeDnsAnswer(hostname: string, addresses: string[]): void {
19
+ answers.set(hostname.toLowerCase(), addresses);
20
+ }
21
+
22
+ function isReservedName(hostname: string): boolean {
23
+ return (
24
+ hostname === "example.com" ||
25
+ hostname.endsWith(".example.com") ||
26
+ /\.(example|test|invalid)$/.test(hostname)
27
+ );
28
+ }
29
+
30
+ const lookup = (async (hostname: string, options?: unknown) => {
31
+ const name = hostname.toLowerCase().replace(/\.$/, "");
32
+ const addresses = answers.get(name) ?? (isReservedName(name) ? [FAKE_PUBLIC_ADDRESS] : null);
33
+ if (!addresses) {
34
+ return (realDns.lookup as (h: string, o?: unknown) => Promise<unknown>)(hostname, options);
35
+ }
36
+ const records = addresses.map((address) => ({
37
+ address,
38
+ family: address.includes(":") ? 6 : 4,
39
+ }));
40
+ return (options as { all?: boolean } | undefined)?.all ? records : records[0];
41
+ }) as typeof realDns.lookup;
42
+
43
+ mock.module("node:dns/promises", () => ({
44
+ ...realDns,
45
+ lookup,
46
+ default: { ...realDns, lookup },
47
+ }));