@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
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Rocket.Chat-specific format conversion using AST-based parsing.
3
+ *
4
+ * Rocket.Chat uses a markdown-like format with some differences from
5
+ * standard CommonMark:
6
+ * - Bold: *text* (single asterisk, not double)
7
+ * - Italic: _text_
8
+ * - Strikethrough: ~text~ (single tilde, not double)
9
+ * - Inline code / code fences: standard backtick syntax
10
+ *
11
+ * @see https://docs.rocket.chat/use-rocket.chat/user-guides/messages/markdown
12
+ */
13
+
14
+ import { normalizeCodeFences } from "@chat-adapter/shared";
15
+ import {
16
+ type AdapterPostableMessage,
17
+ BaseFormatConverter,
18
+ type Content,
19
+ type Delete,
20
+ type Emphasis,
21
+ isTableNode,
22
+ parseMarkdown,
23
+ type Root,
24
+ type Strong,
25
+ stringifyMarkdown,
26
+ type Text,
27
+ tableToAscii,
28
+ walkAst,
29
+ } from "chat";
30
+
31
+ type Handlers = NonNullable<NonNullable<Parameters<typeof stringifyMarkdown>[1]>["handlers"]>;
32
+ type HandleArgs = Parameters<NonNullable<Handlers["text"]>>;
33
+ type State = HandleArgs[2];
34
+ type Info = HandleArgs[3];
35
+
36
+ // Rocket.Chat has no escape syntax, so text stays literal unless it would
37
+ // otherwise turn into formatting.
38
+ const INLINE_PAIRS = {
39
+ "*": /(?:^|[^\p{L}\p{N}])\*(?=\S).*?\S\*(?![\p{L}\p{N}])/mu,
40
+ _: /(?:^|[^\p{L}\p{N}])_(?=\S).*?\S_(?![\p{L}\p{N}])/mu,
41
+ "~": /(?:^|[^\p{L}\p{N}])~(?=\S).*?\S~(?![\p{L}\p{N}])/mu,
42
+ "`": /(?:^|[^\p{L}\p{N}])`(?=\S).*?\S`(?![\p{L}\p{N}])/mu,
43
+ } as const;
44
+ const BLOCK_START = /(^|\n)(?:([>*-])|(\d+)\.)(?= )/g;
45
+
46
+ // Surrounding markers belong to formatting nodes, so they only bound the text.
47
+ function boundary(char: string) {
48
+ return char in INLINE_PAIRS ? " " : char;
49
+ }
50
+
51
+ function text(node: Text, _parent: unknown, _state: State, info: Info) {
52
+ const { before, after } = info;
53
+ const context = [boundary(before.slice(-1)), boundary(after.charAt(0))];
54
+ let value = node.value;
55
+ for (const [marker, pair] of Object.entries(INLINE_PAIRS)) {
56
+ const touchesMarker =
57
+ (value.startsWith(marker) && before.slice(-1) in INLINE_PAIRS) ||
58
+ (value.endsWith(marker) && after.charAt(0) in INLINE_PAIRS);
59
+ if (
60
+ touchesMarker ||
61
+ (value.includes(marker) && pair.test(`${context[0]}${value}${context[1]}`))
62
+ ) {
63
+ value = value.replaceAll(marker, `\\${marker}`);
64
+ }
65
+ }
66
+ return value.replace(
67
+ BLOCK_START,
68
+ (match, lead: string, symbol?: string, digits?: string, offset = 0) => {
69
+ if (offset === 0 && lead === "" && before !== "\n") {
70
+ return match;
71
+ }
72
+ return symbol ? `${lead}\\${symbol}` : `${lead}${digits}\\.`;
73
+ },
74
+ );
75
+ }
76
+
77
+ // `peek` keeps lookahead from serializing nested formatting a second time.
78
+ function strong(node: Strong, _parent: unknown, state: State, info: Info) {
79
+ return `*${state.containerPhrasing(node, { ...info, before: "*", after: "*" })}*`;
80
+ }
81
+ strong.peek = () => "*";
82
+
83
+ function emphasis(node: Emphasis, _parent: unknown, state: State, info: Info) {
84
+ return `_${state.containerPhrasing(node, { ...info, before: "_", after: "_" })}_`;
85
+ }
86
+ emphasis.peek = () => "_";
87
+
88
+ function strikethrough(node: Delete, _parent: unknown, state: State, info: Info) {
89
+ return `~${state.containerPhrasing(node, { ...info, before: "~", after: "~" })}~`;
90
+ }
91
+ strikethrough.peek = () => "~";
92
+
93
+ const handlers: Handlers = {
94
+ text,
95
+ strong,
96
+ emphasis,
97
+ delete: strikethrough,
98
+ break: () => "\n",
99
+ };
100
+
101
+ export class RocketChatFormatConverter extends BaseFormatConverter {
102
+ /**
103
+ * Convert an AST to Rocket.Chat markdown format.
104
+ *
105
+ * Transforms unsupported nodes (headings, thematic breaks, tables) into
106
+ * Rocket.Chat-compatible equivalents and renders supported formatting
107
+ * directly in Rocket.Chat syntax.
108
+ */
109
+ fromAst(ast: Root): string {
110
+ const transformed = walkAst(structuredClone(ast), (node: Content) => {
111
+ // Headings -> bold paragraph (flatten nested strong to avoid ***)
112
+ if (node.type === "heading") {
113
+ const heading = node as Content & { children: Content[] };
114
+ const children = heading.children.flatMap((child) =>
115
+ child.type === "strong" ? (child as Content & { children: Content[] }).children : [child],
116
+ );
117
+ return {
118
+ type: "paragraph",
119
+ children: [{ type: "strong", children }],
120
+ } as Content;
121
+ }
122
+ // Thematic breaks -> text separator
123
+ if (node.type === "thematicBreak") {
124
+ return {
125
+ type: "paragraph",
126
+ children: [{ type: "text", value: "━━━" }],
127
+ } as Content;
128
+ }
129
+ // Tables -> code blocks. Rocket.Chat markdown has no native table
130
+ // syntax, so render a fixed-width ASCII table in a code fence.
131
+ if (isTableNode(node)) {
132
+ return {
133
+ type: "code" as const,
134
+ value: tableToAscii(node),
135
+ lang: undefined,
136
+ } as Content;
137
+ }
138
+ return node;
139
+ });
140
+ return stringifyMarkdown(transformed, {
141
+ emphasis: "_",
142
+ bullet: "-",
143
+ handlers,
144
+ }).trim();
145
+ }
146
+
147
+ /**
148
+ * Parse Rocket.Chat markdown into an AST.
149
+ *
150
+ * Normalizes Rocket.Chat's ``` fences for CommonMark (the text after the
151
+ * opening fence is code, not an info string) and transforms
152
+ * Rocket.Chat-specific formatting to standard markdown outside the fences,
153
+ * then parses with the standard parser.
154
+ */
155
+ toAst(markdown: string): Root {
156
+ return parseMarkdown(this.toStandardMarkdown(markdown));
157
+ }
158
+
159
+ /**
160
+ * Check the budget against the markdown that `toAst` parses, so the checks
161
+ * see the same code fences as the parser. The length limit still applies to
162
+ * the text as delivered.
163
+ */
164
+ protected override exceedsIncomingBudget(markdown: string): boolean {
165
+ return (
166
+ markdown.length > this.maxIncomingParseLength ||
167
+ super.exceedsIncomingBudget(this.toStandardMarkdown(markdown))
168
+ );
169
+ }
170
+
171
+ private toStandardMarkdown(markdown: string): string {
172
+ return normalizeCodeFences(markdown, {
173
+ convertText: (text) => this.fromRocketChatFormat(text),
174
+ });
175
+ }
176
+
177
+ /**
178
+ * Render a postable message to a Rocket.Chat-compatible string.
179
+ */
180
+ override renderPostable(message: AdapterPostableMessage): string {
181
+ if (typeof message === "string") {
182
+ return message;
183
+ }
184
+ if ("raw" in message) {
185
+ return message.raw;
186
+ }
187
+ if ("markdown" in message) {
188
+ return this.fromMarkdown(message.markdown);
189
+ }
190
+ if ("ast" in message) {
191
+ return this.fromAst(message.ast);
192
+ }
193
+ return super.renderPostable(message);
194
+ }
195
+
196
+ /**
197
+ * Convert Rocket.Chat format to standard markdown.
198
+ * Converts single-asterisk bold to double-asterisk bold, and
199
+ * single-tilde strikethrough to double-tilde strikethrough.
200
+ *
201
+ * Careful not to convert _italic_ (which is the same in both formats).
202
+ */
203
+ private fromRocketChatFormat(text: string): string {
204
+ // Convert *bold* to **bold** (single * not preceded/followed by *, no newlines)
205
+ let result = text.replace(/(?<!\*)\*(?!\*)([^\n*]+?)(?<!\*)\*(?!\*)/g, "**$1**");
206
+ // Convert ~strike~ to ~~strike~~ (single ~ not preceded/followed by ~, no newlines)
207
+ result = result.replace(/(?<!~)~(?!~)([^\n~]+?)(?<!~)~(?!~)/g, "~~$1~~");
208
+ return result;
209
+ }
210
+ }
@@ -0,0 +1,249 @@
1
+ /**
2
+ * Type definitions for the Rocket.Chat adapter.
3
+ */
4
+
5
+ import type { Logger } from "chat";
6
+
7
+ // =============================================================================
8
+ // Configuration
9
+ // =============================================================================
10
+
11
+ /**
12
+ * Configuration for the Rocket.Chat adapter.
13
+ *
14
+ * Every field is optional and falls back to an environment variable, so
15
+ * `createRocketChatAdapter()` works with no arguments when the environment
16
+ * is set.
17
+ */
18
+ export interface RocketChatAdapterConfig {
19
+ /**
20
+ * Rocket.Chat server base URL, without a trailing slash or `/api/v1`
21
+ * suffix (e.g. `https://chat.example.com`).
22
+ * Defaults to the `ROCKETCHAT_URL` env var.
23
+ */
24
+ baseUrl?: string;
25
+ /**
26
+ * User ID of the bot account, used for the `X-User-Id` REST header and
27
+ * for ignoring the bot's own messages.
28
+ * Defaults to the `ROCKETCHAT_USER_ID` env var.
29
+ */
30
+ botUserId?: string;
31
+ /** Logger instance for error reporting. Defaults to ConsoleLogger. */
32
+ logger?: Logger;
33
+ /**
34
+ * Personal access token (or login auth token) used for the
35
+ * `X-Auth-Token` REST header.
36
+ * Defaults to the `ROCKETCHAT_TOKEN` env var.
37
+ */
38
+ token?: string;
39
+ /**
40
+ * Bot username used for @-mention detection.
41
+ * Defaults to the `ROCKETCHAT_BOT_USERNAME` env var, then falls back to
42
+ * `"rocketchat-bot"`.
43
+ */
44
+ userName?: string;
45
+ /**
46
+ * Shared secret configured on the Outgoing Webhook integration, compared
47
+ * against the `token` field of each incoming webhook payload.
48
+ * Defaults to the `ROCKETCHAT_WEBHOOK_TOKEN` env var.
49
+ */
50
+ webhookToken?: string;
51
+ }
52
+
53
+ // =============================================================================
54
+ // Thread ID
55
+ // =============================================================================
56
+
57
+ /**
58
+ * Decoded thread ID for Rocket.Chat.
59
+ *
60
+ * Thread ID formats:
61
+ * - Room-level: `rocketchat:{roomId}`
62
+ * - Thread reply: `rocketchat:{roomId}:{tmid}`
63
+ */
64
+ export interface RocketChatThreadId {
65
+ /** Room (channel, private group, or DM) ID. */
66
+ roomId: string;
67
+ /** Parent message ID of the thread. Omit for the room-level thread. */
68
+ tmid?: string;
69
+ }
70
+
71
+ // =============================================================================
72
+ // Rocket.Chat API objects
73
+ // =============================================================================
74
+
75
+ /** Minimal user reference embedded in messages (`u` field). */
76
+ export interface RocketChatMessageUser {
77
+ _id: string;
78
+ name?: string;
79
+ username: string;
80
+ }
81
+
82
+ /** Reaction map keyed by emoji shortcode, as returned on a message. */
83
+ export type RocketChatReactions = Record<string, { usernames: string[] }>;
84
+
85
+ /**
86
+ * Message as returned by the REST API (`chat.postMessage`, `chat.update`,
87
+ * `chat.getMessage`, `chat.getThreadMessages`, `channels.history`,
88
+ * `rooms.history`, …).
89
+ */
90
+ export interface RocketChatMessage {
91
+ _id: string;
92
+ _updatedAt?: string;
93
+ alias?: string;
94
+ attachments?: Record<string, unknown>[];
95
+ channels?: Record<string, unknown>[];
96
+ editedAt?: string;
97
+ editedBy?: RocketChatMessageUser;
98
+ groupable?: boolean;
99
+ md?: Record<string, unknown>[];
100
+ mentions?: Record<string, unknown>[];
101
+ msg: string;
102
+ reactions?: RocketChatReactions;
103
+ replies?: string[];
104
+ rid: string;
105
+ starred?: Record<string, unknown>[];
106
+ t?: string;
107
+ tcount?: number;
108
+ tlm?: string;
109
+ /** Present when the message is a reply in a thread. */
110
+ tmid?: string;
111
+ ts: string;
112
+ u: RocketChatMessageUser;
113
+ urls?: Record<string, unknown>[];
114
+ }
115
+
116
+ /**
117
+ * User as returned by `users.info` / `users.list`.
118
+ *
119
+ * @see https://developer.rocket.chat/apidocs/user-schema
120
+ */
121
+ export interface RocketChatUser {
122
+ _id: string;
123
+ active?: boolean;
124
+ emails?: { address: string; verified: boolean }[];
125
+ name?: string;
126
+ /** `"user"`, `"bot"`, or `"app"`. Absent on older servers. */
127
+ type?: string;
128
+ username: string;
129
+ }
130
+
131
+ // =============================================================================
132
+ // Raw message
133
+ // =============================================================================
134
+
135
+ /** Platform-specific raw message stored on every `Message` from Rocket.Chat. */
136
+ export interface RocketChatRawMessage {
137
+ /** The message itself, in REST API shape. */
138
+ message: RocketChatMessage;
139
+ /** Room ID the message belongs to. */
140
+ roomId: string;
141
+ }
142
+
143
+ // =============================================================================
144
+ // REST API responses
145
+ // =============================================================================
146
+
147
+ /** Response of `POST chat.postMessage`. */
148
+ export interface RocketChatPostMessageResponse {
149
+ channel: string;
150
+ message: RocketChatMessage;
151
+ success: boolean;
152
+ ts: number | string;
153
+ }
154
+
155
+ /** Response of `POST chat.update`. */
156
+ export interface RocketChatUpdateMessageResponse {
157
+ message: RocketChatMessage;
158
+ success: boolean;
159
+ }
160
+
161
+ /** Response of `POST chat.delete`. */
162
+ export interface RocketChatDeleteMessageResponse {
163
+ _id: string;
164
+ message?: Partial<RocketChatMessage>;
165
+ success: boolean;
166
+ ts: string;
167
+ }
168
+
169
+ /** Response of `GET chat.getMessage`. */
170
+ export interface RocketChatGetMessageResponse {
171
+ message: RocketChatMessage;
172
+ success: boolean;
173
+ }
174
+
175
+ /** Response of `GET chat.getThreadMessages`. */
176
+ export interface RocketChatGetThreadMessagesResponse {
177
+ count: number;
178
+ messages: RocketChatMessage[];
179
+ offset: number;
180
+ success: boolean;
181
+ total: number;
182
+ }
183
+
184
+ /** Response of `GET rooms.history`. */
185
+ export interface RocketChatRoomsHistoryResponse {
186
+ cursor?: {
187
+ next: string | null;
188
+ previous: string | null;
189
+ };
190
+ messages: RocketChatMessage[];
191
+ success: boolean;
192
+ }
193
+
194
+ /** Room as returned by `rooms.info`. */
195
+ export interface RocketChatRoom {
196
+ _id: string;
197
+ fname?: string;
198
+ name?: string;
199
+ /** Room type: `c` (channel), `p` (private group), `d` (DM), `l` (livechat). */
200
+ t: string;
201
+ topic?: string;
202
+ }
203
+
204
+ /** Response of `GET rooms.info`. */
205
+ export interface RocketChatRoomInfoResponse {
206
+ room: RocketChatRoom;
207
+ success: boolean;
208
+ }
209
+
210
+ /** Response of `GET users.info`. */
211
+ export interface RocketChatUserInfoResponse {
212
+ success: boolean;
213
+ user: RocketChatUser;
214
+ }
215
+
216
+ /** Error envelope returned by the Rocket.Chat REST API on non-2xx responses. */
217
+ export interface RocketChatErrorResponse {
218
+ error?: string;
219
+ errorType?: string;
220
+ success: false;
221
+ }
222
+
223
+ // =============================================================================
224
+ // Outgoing webhook payload
225
+ // =============================================================================
226
+
227
+ /**
228
+ * Body posted by a Rocket.Chat Outgoing Webhook integration when a message
229
+ * is sent in a room the integration is attached to.
230
+ *
231
+ * @see https://docs.rocket.chat/docs/outgoing-webhook-integrations
232
+ */
233
+ export interface RocketChatWebhookPayload {
234
+ alias?: string;
235
+ /** `true` when the message author is a bot (including this adapter). */
236
+ bot?: boolean;
237
+ channel_id: string;
238
+ channel_name?: string;
239
+ message_id: string;
240
+ siteUrl?: string;
241
+ text: string;
242
+ /** Thread message ID, present when replying inside a thread. */
243
+ tmid?: string;
244
+ timestamp: string;
245
+ /** Shared secret configured on the integration, verified against `webhookToken`. */
246
+ token: string;
247
+ user_id: string;
248
+ user_name: string;
249
+ }
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
2
2
  import type { Chat } from "chat";
3
3
  import { isEnvFlagEnabled } from "@/utils/env-flag";
4
4
  import { registerVolatileSecret, scrubSecrets } from "@/utils/secret-scrubber";
5
- import { loadAdapter, watchSocketConnection } from "./adapters";
5
+ import { DEFAULT_BOT_USER_NAME, loadAdapter, watchSocketConnection } from "./adapters";
6
6
  import { drainBackground } from "./background";
7
7
  import { registerTelegramCommands } from "./commands";
8
8
  import {
@@ -57,15 +57,21 @@ export function isChatSdkStopping(): boolean {
57
57
  return stopping;
58
58
  }
59
59
 
60
- const DEFAULT_CHAT_USER_NAME = "swarm";
61
-
62
60
  /** Total wait for every step of `stopChatSdk`, inside the 15 s SIGTERM budget. */
63
61
  const SHUTDOWN_BUDGET_MS = 10_000;
64
62
  /** A config reload waits this long for the adapters to come back before it answers. */
65
63
  const RELOAD_START_BUDGET_MS = 15_000;
66
64
 
67
65
  /** Fields whose string value is a credential, registered with the scrubber. */
68
- const SECRET_FIELDS = ["botToken", "secretToken", "signingSecret", "appToken", "appPassword"];
66
+ const SECRET_FIELDS = [
67
+ "botToken",
68
+ "secretToken",
69
+ "signingSecret",
70
+ "appToken",
71
+ "appPassword",
72
+ "token",
73
+ "webhookToken",
74
+ ];
69
75
 
70
76
  function setHealth(
71
77
  name: ChatSdkAdapterName,
@@ -116,7 +122,7 @@ async function startAdapter(
116
122
  state,
117
123
  // Chat requires a userName. The adapter only gets one when the operator
118
124
  // set it, so Telegram can still take the real bot name from getMe.
119
- userName: typeof config.userName === "string" ? config.userName : DEFAULT_CHAT_USER_NAME,
125
+ userName: typeof config.userName === "string" ? config.userName : DEFAULT_BOT_USER_NAME,
120
126
  logger,
121
127
  // The swarm buffers bursts itself (Phase 2). The SDK "queue" strategy
122
128
  // would keep only the latest queued message and skip the rest.
@@ -6,7 +6,13 @@ import { z } from "zod";
6
6
  * with it; `config.ts` adds the DB-backed resolution on top.
7
7
  */
8
8
 
9
- export const CHAT_SDK_ADAPTER_NAMES = ["telegram", "slack", "discord", "teams"] as const;
9
+ export const CHAT_SDK_ADAPTER_NAMES = [
10
+ "telegram",
11
+ "slack",
12
+ "discord",
13
+ "teams",
14
+ "rocketchat",
15
+ ] as const;
10
16
  export type ChatSdkAdapterName = (typeof CHAT_SDK_ADAPTER_NAMES)[number];
11
17
 
12
18
  export const ConfigRefSchema = z.strictObject({ $config: z.string().min(1) });
@@ -18,11 +24,14 @@ const Str = z.union([z.string().trim().min(1), ConfigRefSchema]);
18
24
  * Keys an operator must never set. A base URL plus a `$config` ref would send
19
25
  * the referenced secret to an arbitrary host. A verifier or an "unverified"
20
26
  * switch bypasses the platform signature check on the public webhook.
21
- * Mock base URLs come only from the env-only `CHAT_SDK_API_URL_OVERRIDES`.
27
+ * Base URLs come only from the env-only `CHAT_SDK_API_URL_OVERRIDES`, which
28
+ * is how a self-hosted Rocket.Chat instance URL is set too: the adapter reads
29
+ * it as `baseUrl`, so that name is forbidden here for the same reason.
22
30
  */
23
31
  const FORBIDDEN_ADAPTER_KEYS = [
24
32
  "apiUrl",
25
33
  "apiBaseUrl",
34
+ "baseUrl",
26
35
  "webhookVerifier",
27
36
  "allowUnverifiedWebhooks",
28
37
  ] as const;
@@ -48,7 +57,8 @@ const COMMON_SHAPE = {
48
57
  };
49
58
 
50
59
  function adapterSchema<S extends AdapterShape>(shape: S) {
51
- return z.looseObject({ ...shape, ...COMMON_SHAPE }).superRefine(forbiddenKeyIssues);
60
+ // The adapter's own shape wins: Rocket.Chat needs `userName` required.
61
+ return z.looseObject({ ...COMMON_SHAPE, ...shape }).superRefine(forbiddenKeyIssues);
52
62
  }
53
63
 
54
64
  /**
@@ -143,6 +153,26 @@ export const TeamsAdapterSchema = adapterSchema(TEAMS_SHAPE).superRefine((value,
143
153
  }
144
154
  });
145
155
 
156
+ /**
157
+ * Rocket.Chat is self-hosted, so its instance URL is per deployment. It is
158
+ * not a field here: `baseUrl` is forbidden like every other base URL, and the
159
+ * instance comes from the env-only `CHAT_SDK_API_URL_OVERRIDES.rocketchat`.
160
+ * `botUserId` pairs with `token` on every REST call and identifies the bot's
161
+ * own messages; `webhookToken` is the Outgoing Webhook shared secret.
162
+ */
163
+ // `userName` is required here, unlike the other adapters. Rocket.Chat detects
164
+ // a mention by matching `@<userName>` in the message text, and the REST API
165
+ // has no "who am I" call the adapter could use, so a wrong or defaulted name
166
+ // means the bot silently never sees a mention.
167
+ const ROCKETCHAT_SHAPE = {
168
+ token: Str,
169
+ botUserId: Str,
170
+ webhookToken: Str,
171
+ userName: Str,
172
+ };
173
+
174
+ export const RocketchatAdapterSchema = adapterSchema(ROCKETCHAT_SHAPE);
175
+
146
176
  // Strict: a typo'd adapter name must fail loudly, not silently disable it.
147
177
  export const ChatSdkAdaptersSchema = z
148
178
  .strictObject({
@@ -150,6 +180,7 @@ export const ChatSdkAdaptersSchema = z
150
180
  slack: SlackAdapterSchema,
151
181
  discord: DiscordAdapterSchema,
152
182
  teams: TeamsAdapterSchema,
183
+ rocketchat: RocketchatAdapterSchema,
153
184
  })
154
185
  .partial();
155
186
 
@@ -161,6 +192,7 @@ export const CHAT_SDK_ADAPTER_SCHEMAS: Record<ChatSdkAdapterName, z.ZodType> = {
161
192
  slack: SlackAdapterSchema,
162
193
  discord: DiscordAdapterSchema,
163
194
  teams: TeamsAdapterSchema,
195
+ rocketchat: RocketchatAdapterSchema,
164
196
  };
165
197
 
166
198
  /**
@@ -175,6 +207,7 @@ export const ChatSdkAdaptersDraftSchema = z
175
207
  slack: adapterSchema(draftShape(SLACK_SHAPE)),
176
208
  discord: adapterSchema(draftShape(DISCORD_SHAPE)).superRefine(discordPublicKeyIssue),
177
209
  teams: adapterSchema(draftShape(TEAMS_SHAPE)),
210
+ rocketchat: adapterSchema(draftShape(ROCKETCHAT_SHAPE)),
178
211
  })
179
212
  .partial();
180
213
 
@@ -215,6 +248,7 @@ export const CHAT_SDK_ADAPTER_FIELDS: Record<ChatSdkAdapterName, readonly string
215
248
  slack: formFields(SlackAdapterSchema.shape),
216
249
  discord: formFields(DiscordAdapterSchema.shape),
217
250
  teams: formFields(TeamsAdapterSchema.shape),
251
+ rocketchat: formFields(RocketchatAdapterSchema.shape),
218
252
  };
219
253
 
220
254
  /** `enabled` is the panel switch on the card, not a form field. */
@@ -55,6 +55,10 @@ const DEFAULT_MODES: Partial<Record<ChatSdkAdapterName, string>> = {
55
55
  slack: "webhook",
56
56
  };
57
57
 
58
+ /** Rocket.Chat only: set when the instance URL override is missing, which the adapter needs to start. */
59
+ const ROCKETCHAT_NO_INSTANCE_URL =
60
+ 'No instance URL. Set CHAT_SDK_API_URL_OVERRIDES to {"rocketchat":"https://chat.example.com"} in the deployment environment and restart the API.';
61
+
58
62
  const NOT_RUNNING =
59
63
  "The adapter is starting, or the last configuration save is still applying. Refresh in a few seconds.";
60
64
 
@@ -160,6 +164,11 @@ export async function getChatSdkStatus(): Promise<ChatSdkStatus> {
160
164
  } else if (config.enabled && configured) {
161
165
  error = blockedCause ? `Not started: ${blockedCause}` : NOT_RUNNING;
162
166
  }
167
+ // The instance URL is env-only, so a complete card can still not start.
168
+ // Say which env var is missing instead of the adapter's own error.
169
+ if (name === "rocketchat" && configured && enabled && resolveAdapterApiUrl(name) === "") {
170
+ error = ROCKETCHAT_NO_INSTANCE_URL;
171
+ }
163
172
  return {
164
173
  name,
165
174
  configured,
@@ -44,6 +44,8 @@ type McpHttpClientOptions = {
44
44
  omitEmptyAuthHeaders?: boolean;
45
45
  /** Revalidate the resolved request URL immediately before every fetch. */
46
46
  validateUrl?: (url: string) => void;
47
+ /** Fetch used for every request. Defaults to the global fetch. */
48
+ fetch?: typeof fetch;
47
49
  };
48
50
 
49
51
  export class McpHttpClient {
@@ -91,7 +93,7 @@ export class McpHttpClient {
91
93
  const url = this.useRawUrl ? this.baseUrl : `${this.baseUrl}/mcp`;
92
94
  try {
93
95
  this.options.validateUrl?.(url);
94
- const res = await fetch(url, {
96
+ const res = await (this.options.fetch ?? fetch)(url, {
95
97
  method: "POST",
96
98
  headers,
97
99
  body: JSON.stringify(body),
@@ -1,5 +1,7 @@
1
+ import { createSsrfGuardedFetch } from "@/utils/egress-guard";
1
2
  import { scrubSecrets } from "@/utils/secret-scrubber";
2
3
  import { assertOAuthEgressUrlSafe } from "./app-validation";
4
+ import { publicEndpointSsrfOptions } from "./mcp-wrapper";
3
5
 
4
6
  /**
5
7
  * Best-effort account identity captured after a successful token exchange.
@@ -66,7 +68,10 @@ export async function captureIdentity(input: {
66
68
  const controller = new AbortController();
67
69
  const timer = setTimeout(() => controller.abort(), IDENTITY_FETCH_TIMEOUT_MS);
68
70
  try {
69
- const response = await fetch(input.userinfoUrl, {
71
+ // The guarded fetch also checks the resolved address, so a public name
72
+ // that resolves to a private one never receives the bearer.
73
+ const guardedFetch = createSsrfGuardedFetch(publicEndpointSsrfOptions());
74
+ const response = await guardedFetch(input.userinfoUrl, {
70
75
  headers: {
71
76
  authorization: `Bearer ${input.accessToken}`,
72
77
  accept: "application/json",
@@ -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) ──────────────────────────────────