@desplega.ai/agent-swarm 2.13.2 → 2.13.4

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 (324) hide show
  1. package/dist/acp-adapter-mr4temec.js +17 -0
  2. package/dist/{acp-targets-mz8c5dnt.js → acp-targets-zrk9k0n7.js} +10 -10
  3. package/dist/{actions-5ft3qp5a.js → actions-acqqj9jn.js} +236 -26
  4. package/dist/{agent-fs-provision-6fgz7wvz.js → agent-fs-provision-zmaykqnd.js} +4 -4
  5. package/dist/{amp-adapter-nthn8ezm.js → amp-adapter-a7ts8tmw.js} +3 -3
  6. package/dist/{app-535m78qw.js → app-tmwa442h.js} +7 -7
  7. package/dist/{approval-notifications-dewbk403.js → approval-notifications-6psaaaye.js} +8 -8
  8. package/dist/{assistant-39zyabv2.js → assistant-564v6emv.js} +25 -25
  9. package/dist/{boot-args-schema-bqv5bf77.js → boot-args-schema-n099e0f2.js} +1 -1
  10. package/dist/{boot-reembed-fas7z3zn.js → boot-reembed-chx66qfk.js} +1 -1
  11. package/dist/{boot-reembed-157c0gcz.js → boot-reembed-epvg4fp9.js} +1 -1
  12. package/dist/{boot-scrub-sweep-tmec0be2.js → boot-scrub-sweep-dhkfp0a7.js} +2 -2
  13. package/dist/{boot-seeds-32zm50x2.js → boot-seeds-m74fc07r.js} +4 -4
  14. package/dist/{boxd-hr8rsxzq.js → boxd-451q55ys.js} +1 -1
  15. package/dist/{claude-adapter-gwq7x2nj.js → claude-adapter-hw63yj3j.js} +12 -9
  16. package/dist/{claude-managed-adapter-rkvw6fvq.js → claude-managed-adapter-z5s7fx6p.js} +3 -3
  17. package/dist/{claude-managed-setup-0vgz4d1j.js → claude-managed-setup-wee1762m.js} +3 -3
  18. package/dist/{claude-sdk-session-5wbwxy8c.js → claude-sdk-session-cktyqkpk.js} +27 -13
  19. package/dist/{cli-d528acsw.js → cli-0fgvnb0x.js} +7 -7
  20. package/dist/{cli-2v4xxnx2.js → cli-0h8skzss.js} +1 -1
  21. package/dist/{cli-jkkcm72j.js → cli-0p76my9q.js} +31 -16
  22. package/dist/{cli-fp65jdp2.js → cli-1kvcsd2f.js} +219 -155
  23. package/dist/{cli-gc7jkf4a.js → cli-1vmhnncj.js} +3 -3
  24. package/dist/{cli-tceqvv6h.js → cli-29h5239w.js} +5 -5
  25. package/dist/cli-2ap1the6.js +11 -0
  26. package/dist/{cli-8fj8yfmk.js → cli-2vp0z049.js} +1 -1
  27. package/dist/{cli-ewb028rs.js → cli-3bxrrh53.js} +4 -4
  28. package/dist/{cli-nvqq3232.js → cli-3tzmh38q.js} +9 -9
  29. package/dist/{cli-0xwb7zpt.js → cli-3xqad83h.js} +2 -2
  30. package/dist/{cli-0f7n3td3.js → cli-3zrwrnz7.js} +1 -1
  31. package/dist/{cli-2wde56gv.js → cli-404am6f3.js} +7 -7
  32. package/dist/{cli-r4fphq38.js → cli-49aq3cyn.js} +4 -4
  33. package/dist/{cli-8qvte9hn.js → cli-4fpa0zns.js} +3 -3
  34. package/dist/{cli-x5yb8zc8.js → cli-4pbwg7sn.js} +2 -2
  35. package/dist/{cli-s08zsqva.js → cli-4q2c8rxw.js} +76 -10
  36. package/dist/{cli-3mf04tkh.js → cli-4vynxtrb.js} +1 -1
  37. package/dist/{cli-tbdw3f92.js → cli-5ashycw3.js} +3 -3
  38. package/dist/{cli-c9bwawf9.js → cli-5rgm8p39.js} +3 -3
  39. package/dist/{cli-g0b3ma7r.js → cli-5rxsb3wq.js} +6 -6
  40. package/dist/{cli-a6rzw649.js → cli-60dwk8tx.js} +3 -3
  41. package/dist/{cli-xhkek467.js → cli-7by7vp6m.js} +30 -4
  42. package/dist/{cli-62fjschk.js → cli-7g3fg4gf.js} +7 -7
  43. package/dist/{cli-ka13xx6b.js → cli-7gbff32z.js} +2 -2
  44. package/dist/{cli-q8aq48v1.js → cli-8b4rpnwj.js} +1 -1
  45. package/dist/{cli-1f48qdnb.js → cli-8cas2xvp.js} +3 -3
  46. package/dist/{cli-dnvmwsvc.js → cli-904wk98s.js} +799 -371
  47. package/dist/{cli-m1wddksc.js → cli-93n305hm.js} +2 -2
  48. package/dist/{cli-31vt7baf.js → cli-944w9wb4.js} +21 -17
  49. package/dist/{cli-je587f74.js → cli-94gx6ze9.js} +1 -1
  50. package/dist/{cli-fcwrd7bh.js → cli-9ah37a8a.js} +6 -6
  51. package/dist/{cli-rfejbpe1.js → cli-akm6y2a8.js} +1 -1
  52. package/dist/{cli-f8rcvf2x.js → cli-azj9t1f9.js} +37 -2
  53. package/dist/{cli-mwxez0pz.js → cli-b768ek79.js} +1 -1
  54. package/dist/{cli-cmgdptmx.js → cli-bv4vvnmg.js} +31 -7
  55. package/dist/{cli-1gevjrc1.js → cli-bzcwwebm.js} +1 -1
  56. package/dist/{cli-sjk85d7v.js → cli-cq4am6vg.js} +3 -3
  57. package/dist/{cli-f1sdh8ca.js → cli-d5pc8ep0.js} +103 -9
  58. package/dist/{cli-7m6bbtab.js → cli-ea7nz50q.js} +12 -12
  59. package/dist/{cli-zkbz8m2q.js → cli-fkpnx3vf.js} +1 -1
  60. package/dist/{cli-ya1cj689.js → cli-fw67mnyc.js} +1 -1
  61. package/dist/{cli-5basv0e7.js → cli-gkv0r2hq.js} +1 -1
  62. package/dist/{cli-nkfv398a.js → cli-gse7bp3z.js} +12 -10
  63. package/dist/{cli-4djg31jh.js → cli-gtj12v95.js} +1 -1
  64. package/dist/{cli-qn79645p.js → cli-h9d3sdnc.js} +1 -1
  65. package/dist/{cli-tgmate57.js → cli-hdhpdrka.js} +6 -23
  66. package/dist/{cli-fgm2mad9.js → cli-hhtbandk.js} +2 -2
  67. package/dist/cli-hyqksecw.js +1907 -0
  68. package/dist/{cli-t25rq8mg.js → cli-ja450998.js} +40 -11
  69. package/dist/{cli-43dsqhcp.js → cli-jbrc98qb.js} +4 -4
  70. package/dist/{cli-82j36f2m.js → cli-jjzxsk47.js} +9 -3
  71. package/dist/{cli-xerdrnqs.js → cli-jyhbvdga.js} +3 -3
  72. package/dist/{cli-t9nxq30h.js → cli-jzerrzgc.js} +8 -8
  73. package/dist/{cli-hv3820ez.js → cli-k0nebh10.js} +1 -1
  74. package/dist/{cli-s6fhqbz1.js → cli-ka48vpev.js} +6 -6
  75. package/dist/{cli-d2epqm0y.js → cli-kezzteka.js} +1 -1
  76. package/dist/{cli-getrvmtx.js → cli-kj84fqxz.js} +2 -2
  77. package/dist/{cli-h0ewec3d.js → cli-kr0jpw9c.js} +1 -1
  78. package/dist/{cli-gq6qhmrr.js → cli-m1sns1da.js} +3 -3
  79. package/dist/{cli-bp2rt28p.js → cli-n1kjs58m.js} +5 -5
  80. package/dist/{cli-rvhaahfv.js → cli-nc4pbwmp.js} +9 -9
  81. package/dist/{cli-d0jb2qnt.js → cli-p3knvk62.js} +74 -47
  82. package/dist/{cli-50whymxq.js → cli-p436yrzp.js} +2 -2
  83. package/dist/{cli-cs26ed89.js → cli-phdzn699.js} +8 -8
  84. package/dist/{cli-b0kqw55g.js → cli-pz1dp12c.js} +1 -1
  85. package/dist/{cli-8a4qg44m.js → cli-pz1nq5xm.js} +6 -6
  86. package/dist/{cli-e87fg3en.js → cli-qzz6tz8s.js} +1 -1
  87. package/dist/{cli-69eq6gdk.js → cli-rmgvwcmy.js} +38 -29
  88. package/dist/{cli-5k1hvycs.js → cli-rv3y60bt.js} +4 -4
  89. package/dist/cli-s33bzmk0.js +27 -0
  90. package/dist/{cli-at67kvnp.js → cli-srktrbby.js} +1 -1
  91. package/dist/{cli-6rmryz03.js → cli-t0jmkcah.js} +14 -14
  92. package/dist/{cli-eetzmsy5.js → cli-t9pzz2eq.js} +2 -2
  93. package/dist/{cli-wdtqkqnq.js → cli-tr19nyn9.js} +4 -4
  94. package/dist/{cli-erh1rgh4.js → cli-ts5yv7dn.js} +165 -88
  95. package/dist/{cli-zqy28rwx.js → cli-tsc3pdfd.js} +4 -4
  96. package/dist/{cli-x7aqhxj5.js → cli-tzw1jr2t.js} +2 -2
  97. package/dist/{cli-n14r8h4n.js → cli-x2cem5vy.js} +6 -4
  98. package/dist/{cli-vx9acp12.js → cli-ybte1fqc.js} +1 -1
  99. package/dist/{cli-xysy1g8x.js → cli-ysv0k1we.js} +2 -2
  100. package/dist/{cli-vdfngx2g.js → cli-ywy8yz6t.js} +2 -2
  101. package/dist/{cli-cpkxh68d.js → cli-z1vam71h.js} +2 -2
  102. package/dist/{cli-zm6bkx3e.js → cli-zexwhj3f.js} +3 -3
  103. package/dist/{cli-j2ybkdk2.js → cli-zhwjdhjr.js} +2 -2
  104. package/dist/{cli-gedf48yw.js → cli-zjdhrzm0.js} +8 -8
  105. package/dist/cli.js +20 -20
  106. package/dist/{codex-adapter-x25xfbnh.js → codex-adapter-2fs2c0n6.js} +8 -8
  107. package/dist/{codex-hook-c0nvm30r.js → codex-hook-jxjv6dy5.js} +10 -3
  108. package/dist/{codex-login-ven5cz5j.js → codex-login-ktfg1cxk.js} +1 -1
  109. package/dist/{codex-session-runner-kn5xnrvp.js → codex-session-runner-r55tmx4c.js} +9 -9
  110. package/dist/{commands-8n59gxmy.js → commands-0mxdy9x8.js} +3 -3
  111. package/dist/{controller-wn3vd217.js → controller-g3vkfhr4.js} +4 -4
  112. package/dist/{controllers-connect-09gvkrhc.js → controllers-connect-4wdmncqt.js} +25 -25
  113. package/dist/core-gsvj5f3z.js +42 -0
  114. package/dist/{cursor-adapter-w1681kp1.js → cursor-adapter-t9qb96q2.js} +2 -2
  115. package/dist/{db-e71keqxk.js → db-487vvyv9.js} +3 -3
  116. package/dist/{db-spg81qtr.js → db-76p7w3gr.js} +2 -2
  117. package/dist/{devin-adapter-fs90ab4v.js → devin-adapter-3bp6rape.js} +1 -1
  118. package/dist/{dispatcher-fr4vawwb.js → dispatcher-64rp6w67.js} +22 -22
  119. package/dist/{docker-1h33jvh9.js → docker-a59g3ebm.js} +2 -2
  120. package/dist/{dsh-adapter-g9yqv09y.js → dsh-adapter-8abzqk5c.js} +2 -2
  121. package/dist/{e2b-y7e5kmzf.js → e2b-3ykbe805.js} +2 -2
  122. package/dist/{e2b-jnk0yeva.js → e2b-dc8f6ctq.js} +2 -2
  123. package/dist/{easter-egg-3d-ac9tv9a6.js → easter-egg-3d-jrrwyf55.js} +1 -1
  124. package/dist/{embedding-space-an77f45k.js → embedding-space-001hhhpk.js} +6 -6
  125. package/dist/{embeddings-jkrehejr.js → embeddings-esj19cnw.js} +1 -1
  126. package/dist/{event-bus-08t2b4y2.js → event-bus-7gbsr0g4.js} +1 -1
  127. package/dist/{execute-3mys4nta.js → execute-301hkxqg.js} +1 -1
  128. package/dist/{external-channel-s6zxpts9.js → external-channel-w10e2j05.js} +2 -2
  129. package/dist/fx-adapter-4sjrbdne.js +20 -0
  130. package/dist/grok-adapter-3a0ezfee.js +20 -0
  131. package/dist/handlers-ef3k11hb.js +41 -0
  132. package/dist/{heartbeat-jjpb44e5.js → heartbeat-tbrj7vhq.js} +25 -25
  133. package/dist/hook-3am1sq68.js +22 -0
  134. package/dist/{hook-y6n23zzj.js → hook-tx917rqw.js} +11 -8
  135. package/dist/{http-8c6y008s.js → http-3rmemtqy.js} +340 -1841
  136. package/dist/{index-mbpxhc4w.js → index-126v2d0t.js} +1 -4
  137. package/dist/{index-xcw7hjt5.js → index-2jw11t8s.js} +26 -26
  138. package/dist/{index-p2f5xg64.js → index-3j803vnb.js} +36259 -34299
  139. package/dist/{index-we3nd2t0.js → index-aetfyx6p.js} +1 -1
  140. package/dist/index-e6bq0exk.js +42 -0
  141. package/dist/{index-0vthtbc2.js → index-gfnq66t1.js} +231 -25
  142. package/dist/index-hf2k1vge.js +39 -0
  143. package/dist/{index-6h3r0vpe.js → index-s7xtvc0f.js} +1 -1
  144. package/dist/index-taxmejj3.js +44 -0
  145. package/dist/{k8s-8326q0rq.js → k8s-36gfn847.js} +2 -2
  146. package/dist/{keepalive-7e9r5dvp.js → keepalive-9px3t7qj.js} +5 -5
  147. package/dist/lead-5vt6f174.js +83 -0
  148. package/dist/{maintenance-d3erjvcg.js → maintenance-vwqjwst6.js} +1 -1
  149. package/dist/{oauth-refresh-sweep-0qh70988.js → oauth-refresh-sweep-yqry3wn4.js} +4 -4
  150. package/dist/{object-webhooks-ac7v2q5p.js → object-webhooks-8s1wtths.js} +7 -7
  151. package/dist/{onboard-5yphtken.js → onboard-hb8czx0p.js} +7 -7
  152. package/dist/{opencode-adapter-0xvyba4m.js → opencode-adapter-djd6m6dk.js} +8 -8
  153. package/dist/{otel-impl-svqp691q.js → otel-impl-2ymwyczz.js} +2 -2
  154. package/dist/{pending-bn4xe5br.js → pending-nxavtvx7.js} +23 -23
  155. package/dist/{pi-mono-adapter-763s8a3w.js → pi-mono-adapter-d2cpmcy4.js} +13 -13
  156. package/dist/{pricing-refresh-kfc215mf.js → pricing-refresh-1yz8jkqv.js} +2 -2
  157. package/dist/{rbac-roles-6r4h2ghj.js → rbac-roles-7s6m31xw.js} +6 -4
  158. package/dist/{rbac-roles-3bznvkpt.js → rbac-roles-dbpx0x9v.js} +3 -3
  159. package/dist/{render-v2-f3qedbpy.js → render-v2-7y20rjrn.js} +7 -7
  160. package/dist/{resume-vcag4ann.js → resume-wz546x47.js} +10 -10
  161. package/dist/{runtime-x0s55z2t.js → runtime-cb5bd9tz.js} +1 -1
  162. package/dist/{session-access-nwzve8q2.js → session-access-4vcft8kq.js} +5 -5
  163. package/dist/{session-source-backfill-jpqfzmgz.js → session-source-backfill-57b50tpw.js} +3 -3
  164. package/dist/{setup-d2smwaem.js → setup-e1tevjyj.js} +1 -1
  165. package/dist/thread-buffer-686pa1p1.js +42 -0
  166. package/dist/{tree-visibility-dwzc8en0.js → tree-visibility-07wf1nct.js} +2 -2
  167. package/dist/{user-merge-jobs-4ce7kma2.js → user-merge-jobs-n20qpv6s.js} +3 -3
  168. package/dist/{virtual-modules-78a6yw71.js → virtual-modules-6fxmn1yv.js} +3 -3
  169. package/dist/{work-objects-m0w1e7q8.js → work-objects-eg7y48pe.js} +25 -25
  170. package/dist/worker-4vp616ms.js +83 -0
  171. package/dist/{worker-follow-up-e3t6f895.js → worker-follow-up-jnvnnf2b.js} +22 -22
  172. package/dist/{x-asbrnafg.js → x-d27jj7z7.js} +2 -2
  173. package/openapi.json +478 -28
  174. package/package.json +3 -3
  175. package/src/be/db/approvals.ts +2 -0
  176. package/src/be/db/runtime.ts +5 -0
  177. package/src/be/db/script-run-sources.ts +17 -0
  178. package/src/be/db-retention.ts +1 -1
  179. package/src/be/db.ts +71 -62
  180. package/src/be/design-system.ts +63 -0
  181. package/src/be/migrations/342_script_run_sources.sql +20 -0
  182. package/src/be/migrations/runner.ts +8 -0
  183. package/src/be/migrations/script-run-sources.ts +51 -0
  184. package/src/be/rbac-roles.ts +2 -0
  185. package/src/be/scripts/typecheck.ts +4 -2
  186. package/src/be/seed-scripts/catalog/design-system-seed.ts +158 -0
  187. package/src/be/seed-scripts/index.ts +9 -0
  188. package/src/be/swarm-config-guard.ts +21 -1
  189. package/src/commands/onboard/agent-fs-version.ts +1 -1
  190. package/src/commands/runner.ts +62 -6
  191. package/src/heartbeat/heartbeat.ts +18 -4
  192. package/src/hooks/codex-hook.ts +15 -4
  193. package/src/hooks/hook.ts +7 -0
  194. package/src/http/all-routes.ts +1 -0
  195. package/src/http/approval-chat-answer.ts +99 -0
  196. package/src/http/approval-requests.ts +280 -225
  197. package/src/http/design-system.ts +103 -0
  198. package/src/http/index.ts +10 -6
  199. package/src/http/pages-public.ts +25 -10
  200. package/src/http/pages.ts +17 -0
  201. package/src/http/person-responder.ts +28 -0
  202. package/src/http/session-cost-recompute.ts +3 -1
  203. package/src/http/session-data.ts +3 -0
  204. package/src/integrations/chat-sdk/adapters.ts +33 -3
  205. package/src/integrations/chat-sdk/inbound.ts +6 -18
  206. package/src/integrations/chat-sdk/mentions.ts +188 -0
  207. package/src/integrations/chat-sdk/outbound.ts +20 -3
  208. package/src/integrations/chat-sdk/router.ts +8 -0
  209. package/src/integrations/chat-sdk/telegram-thread.ts +12 -0
  210. package/src/jira/adf.ts +35 -9
  211. package/src/kv-reserved-namespaces.ts +5 -0
  212. package/src/pages/page-head.ts +11 -1
  213. package/src/prompts/base-prompt.ts +1 -1
  214. package/src/prompts/session-templates.ts +1 -1
  215. package/src/providers/acp-targets.ts +2 -2
  216. package/src/providers/amp-adapter.ts +1 -1
  217. package/src/providers/claude-adapter.ts +21 -1
  218. package/src/providers/claude-sdk-session.ts +22 -3
  219. package/src/providers/claude-session-events.ts +76 -1
  220. package/src/providers/cursor-adapter.ts +1 -1
  221. package/src/providers/dsh-adapter.ts +48 -13
  222. package/src/providers/fx-adapter.ts +2 -2
  223. package/src/providers/pricing-sources.md +3 -0
  224. package/src/providers/types.ts +13 -0
  225. package/src/rbac/legacy-policy.ts +4 -0
  226. package/src/rbac/permissions.ts +8 -0
  227. package/src/scheduler/index.ts +1 -0
  228. package/src/scheduler/scheduler.test.ts +32 -1
  229. package/src/scheduler/scheduler.ts +24 -1
  230. package/src/script-workflows/executor.ts +6 -0
  231. package/src/script-workflows/supervisor.ts +2 -1
  232. package/src/scripts-runtime/sdk-allowlist.ts +2 -0
  233. package/src/scripts-runtime/swarm-sdk.ts +12 -23
  234. package/src/scripts-runtime/types/stdlib.d.ts +4 -1
  235. package/src/scripts-runtime/types/swarm-sdk.d.ts +4 -1
  236. package/src/server.ts +2 -0
  237. package/src/slack/actions.ts +3 -0
  238. package/src/slack/approval-actions.ts +148 -0
  239. package/src/slack/approval-buttons.ts +28 -0
  240. package/src/slack/render-v2.ts +27 -7
  241. package/src/tests/base-prompt.test.ts +6 -2
  242. package/src/tests/chat-sdk-mentions.test.ts +183 -0
  243. package/src/tests/claude-adapter.test.ts +115 -0
  244. package/src/tests/create-page-tool.test.ts +5 -0
  245. package/src/tests/dsh-adapter.test.ts +53 -1
  246. package/src/tests/fixtures/compiled-source-schema-boot.ts +24 -0
  247. package/src/tests/fixtures/fx/acp-updates-recorded.jsonl +1 -1
  248. package/src/tests/fixtures/secret-corpus.ts +43 -1
  249. package/src/tests/heartbeat-stall-thresholds.test.ts +174 -0
  250. package/src/tests/internal-ai/complete-structured.test.ts +105 -0
  251. package/src/tests/internal-ai/credentials.test.ts +149 -0
  252. package/src/tests/internal-ai/task-title.test.ts +78 -0
  253. package/src/tests/jira-adf.test.ts +42 -2
  254. package/src/tests/mcp-input-caps.test.ts +16 -11
  255. package/src/tests/merge-gate-detect-changes.test.ts +208 -16
  256. package/src/tests/migration-342-script-run-sources.test.ts +196 -0
  257. package/src/tests/migration-bunfs-compat.test.ts +129 -9
  258. package/src/tests/rbac-e2e-helpers.test.ts +10 -4
  259. package/src/tests/rbac-e2e-helpers.ts +13 -4
  260. package/src/tests/rbac-roles.test.ts +2 -0
  261. package/src/tests/runner-slot-reconcile.test.ts +102 -0
  262. package/src/tests/runtime-e2b-pools.test.ts +7 -1
  263. package/src/tests/schedule-target-type.test.ts +4 -1
  264. package/src/tests/script-connections.test.ts +2 -0
  265. package/src/tests/script-runs-retention.test.ts +43 -16
  266. package/src/tests/script-workflows-runtime-e2e.test.ts +56 -22
  267. package/src/tests/scripts-http.test.ts +9 -3
  268. package/src/tests/sdk-allowlist.test.ts +26 -13
  269. package/src/tests/sdk-store-progress-skipped.test.ts +12 -5
  270. package/src/tests/secret-rules.test.ts +34 -0
  271. package/src/tests/secret-scrub-gate.test.ts +7 -0
  272. package/src/tests/secret-scrubber.test.ts +62 -2
  273. package/src/tests/seed-scripts.test.ts +2 -2
  274. package/src/tests/slack-render-v2.test.ts +85 -0
  275. package/src/tests/system-one-hosts-ui-mirror.test.ts +1 -0
  276. package/src/tests/vcs-azure-devops.test.ts +10 -0
  277. package/src/tests/vcs-provider.test.ts +8 -0
  278. package/src/themes/design-system.ts +163 -0
  279. package/src/themes/page-theme.ts +28 -19
  280. package/src/tools/chat-post.ts +7 -3
  281. package/src/tools/create-page.ts +3 -0
  282. package/src/tools/design-system.ts +102 -0
  283. package/src/tools/mcp-servers/mcp-server-get.ts +1 -1
  284. package/src/tools/mcp-servers/mcp-server-list.ts +1 -1
  285. package/src/tools/register-chat-channel.ts +11 -2
  286. package/src/tools/skills/skill-get-file.ts +1 -1
  287. package/src/tools/skills/skill-get.ts +1 -1
  288. package/src/tools/skills/skill-list.ts +1 -1
  289. package/src/tools/skills/skill-search.ts +1 -1
  290. package/src/tools/utils.ts +49 -4
  291. package/src/tools/workflows/get-workflow-run.ts +1 -1
  292. package/src/tools/workflows/get-workflow.ts +1 -1
  293. package/src/tools/workflows/list-workflow-runs.ts +1 -1
  294. package/src/tools/workflows/list-workflows.ts +1 -1
  295. package/src/types.ts +67 -1
  296. package/src/utils/internal-ai/complete-structured.ts +36 -5
  297. package/src/utils/internal-ai/credentials.ts +78 -2
  298. package/src/utils/internal-ai/models.ts +37 -1
  299. package/src/utils/internal-ai/task-title.ts +31 -1
  300. package/src/utils/secret-rules.generated.ts +149 -149
  301. package/src/utils/secret-scrubber.ts +111 -5
  302. package/src/vcs/azure-devops.ts +22 -1
  303. package/src/vcs/index.ts +3 -1
  304. package/src/workflows/approval-inline.ts +122 -0
  305. package/src/workflows/approval-notifications.ts +7 -2
  306. package/src/workflows/engine.ts +6 -5
  307. package/src/workflows/executors/agent-task.ts +14 -0
  308. package/src/workflows/executors/system-one-providers.ts +23 -0
  309. package/templates/skills/pages/content.md +34 -8
  310. package/templates/skills/swarm-docs/content.md +13 -0
  311. package/templates/skills/workflow-iterate/content.md +1 -1
  312. package/dist/acp-adapter-x1qqgzwx.js +0 -17
  313. package/dist/cli-n46d87mj.js +0 -98
  314. package/dist/core-2b8bv6ny.js +0 -42
  315. package/dist/fx-adapter-4yet1c4f.js +0 -20
  316. package/dist/grok-adapter-8ge6tw7m.js +0 -20
  317. package/dist/handlers-0r9evrdj.js +0 -41
  318. package/dist/hook-68gbs87k.js +0 -19
  319. package/dist/index-1v23363p.js +0 -39
  320. package/dist/index-30qw6vyw.js +0 -44
  321. package/dist/index-6bm3w6cn.js +0 -40
  322. package/dist/lead-3jpc7kcr.js +0 -79
  323. package/dist/thread-buffer-8fc703jc.js +0 -42
  324. package/dist/worker-3p2vq107.js +0 -79
@@ -1,4 +1,4 @@
1
- import { afterEach, beforeEach, describe, expect, test } from "bun:test";
1
+ import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test";
2
2
  import { openAICompatibleKeyVars } from "@desplega/model-catalog";
3
3
  import {
4
4
  clearVolatileSecretsForTesting,
@@ -118,7 +118,7 @@ describe("scrubSecrets — env-based replacement", () => {
118
118
  version: SCRUBBER_RULES_VERSION,
119
119
  keyVars: [...openAICompatibleKeyVars()].sort(),
120
120
  }).toEqual({
121
- version: 14,
121
+ version: 15,
122
122
  keyVars: ["AI_GATEWAY_API_KEY", "HELMCODE_API_KEY", "HELMCODE_API_NAN", "NAN_API_KEY"],
123
123
  });
124
124
  });
@@ -415,6 +415,47 @@ describe("scrubObject", () => {
415
415
  });
416
416
  });
417
417
 
418
+ test("scrubs object keys, and two keys that redact alike both survive", () => {
419
+ const a = ["ghp", randomToken(36)].join("_");
420
+ const b = ["ghp", randomToken(36)].join("_");
421
+ const out = scrubObject({ [a]: "first", nested: { [b]: "second" }, [b]: "third", plain: 1 });
422
+ expect(out).toEqual({
423
+ "[REDACTED:github_token]": "first",
424
+ nested: { "[REDACTED:github_token]": "second" },
425
+ "[REDACTED:github_token]#2": "third",
426
+ plain: 1,
427
+ });
428
+ });
429
+
430
+ test("key clashes skip a literal suffixed key and keep every entry", () => {
431
+ const tokens = Array.from({ length: 2000 }, () => ["ghp", randomToken(36)].join("_"));
432
+ const input: Record<string, number> = { [tokens[0] as string]: 0 };
433
+ input["[REDACTED:github_token]#3"] = -1;
434
+ tokens.slice(1).forEach((token, i) => {
435
+ input[token] = i + 1;
436
+ });
437
+ // Cost guard: count the clash probes. A rescan from `#2` on every clash
438
+ // costs ~N^2/2 (about 2M here); the per-marker next-suffix cache keeps it
439
+ // near 2N. The lower bound proves the spy still sees the probe path.
440
+ const hasOwn = spyOn(Object, "hasOwn");
441
+ let out: Record<string, number>;
442
+ let probes: number;
443
+ try {
444
+ out = scrubObject(input);
445
+ probes = hasOwn.mock.calls.length;
446
+ } finally {
447
+ hasOwn.mockRestore();
448
+ }
449
+ expect(probes).toBeGreaterThanOrEqual(2001);
450
+ expect(probes).toBeLessThanOrEqual(4 * 2001);
451
+ expect(Object.keys(out)).toHaveLength(2001);
452
+ expect(out["[REDACTED:github_token]"]).toBe(0);
453
+ expect(out["[REDACTED:github_token]#2"]).toBe(1);
454
+ expect(out["[REDACTED:github_token]#3"]).toBe(-1);
455
+ expect(out["[REDACTED:github_token]#4"]).toBe(2);
456
+ expect(out["[REDACTED:github_token]#2001"]).toBe(1999);
457
+ });
458
+
418
459
  test("handles circular references without recursing forever", () => {
419
460
  const value: Record<string, unknown> = { a: "ok" };
420
461
  value.self = value;
@@ -677,6 +718,9 @@ describe("scrubSecrets — env dumps and escaped forms", () => {
677
718
  });
678
719
 
679
720
  // Every credential below is built at runtime; nothing secret-shaped is a literal.
721
+ // The BEGIN line is joined at runtime too, so repo secret scanners never pair it with a later END.
722
+ const PEM_BEGIN = ["-----BEGIN", "PRIVATE KEY-----"].join(" ");
723
+
680
724
  function pemBlock(label: string): string {
681
725
  const body = Array.from({ length: 5 }, () => randomToken(64)).join("\n");
682
726
  return `-----BEGIN ${label}PRIVATE KEY-----\n${body}\n-----END ${label}PRIVATE KEY-----`;
@@ -756,6 +800,20 @@ function probeCases(): ProbeCase[] {
756
800
  }),
757
801
  '{"type":"service_account","private_key":"-----BEGIN PRIVATE KEY-----[REDACTED:private_key]-----END PRIVATE KEY-----\\n","client_email":"bot@x.example"}',
758
802
  );
803
+ const cut = pemBlock("").split("\n").slice(0, 3).join("\n");
804
+ add(
805
+ "PEM cut off before its END line",
806
+ cut.split("\n")[1] ?? "",
807
+ `${cut}\n[truncated 40 lines]`,
808
+ `${PEM_BEGIN}[REDACTED:private_key]\n[truncated 40 lines]`,
809
+ );
810
+ const gcpCut = JSON.stringify({ type: "service_account", private_key: `${pemBlock("")}\n` });
811
+ add(
812
+ "GCP service-account JSON cut off inside private_key",
813
+ gcpCut.split("\\n")[1] ?? "",
814
+ gcpCut.slice(0, 190),
815
+ `{"type":"service_account","private_key":"${PEM_BEGIN}[REDACTED:private_key]`,
816
+ );
759
817
  s = `${randomToken(30)}.${randomToken(20)}`;
760
818
  add(
761
819
  "Authorization: Bearer (raw)",
@@ -933,6 +991,8 @@ describe("scrubSecrets — over-redaction guards", () => {
933
991
  () => {
934
992
  const inputs = [
935
993
  `-----BEGIN RSA PRIVATE KEY-----${"A".repeat(200_000)}`,
994
+ `${PEM_BEGIN}${`${"A".repeat(15)}\n`.repeat(12_000)}`,
995
+ `${PEM_BEGIN}${`\\n${"A".repeat(15)}`.repeat(11_000)}`,
936
996
  "-----BEGIN RSA PRIVATE KEY-----\n".repeat(6_000),
937
997
  `"password": "${"\\\\".repeat(100_000)}`,
938
998
  `\\"password\\": \\"${"\\\\".repeat(100_000)}`,
@@ -67,8 +67,8 @@ afterAll(async () => {
67
67
  });
68
68
 
69
69
  describe("seed-scripts catalog", () => {
70
- test("manifest holds 41 unique, well-described scripts", () => {
71
- expect(SEED_SCRIPTS.length).toBe(41);
70
+ test("manifest holds 42 unique, well-described scripts", () => {
71
+ expect(SEED_SCRIPTS.length).toBe(42);
72
72
  const names = SEED_SCRIPTS.map((s) => s.name);
73
73
  expect(new Set(names).size).toBe(names.length);
74
74
  for (const s of SEED_SCRIPTS) {
@@ -4416,6 +4416,91 @@ describe("Slack renderer v2 delegation (SLACK_RENDER_V2_DELEGATION)", () => {
4416
4416
  expect(String(conclusionStream?.payload.markdown_text)).toContain(getTaskLink(child.id));
4417
4417
  });
4418
4418
 
4419
+ test("a negative settle window falls back to the default, so a just-terminal closure still waits it out", async () => {
4420
+ process.env.SLACK_CONCLUSION_SETTLE_SEC = "-1";
4421
+ const lead = await createAgent({ name: "Negative Settle Lead", isLead: true, status: "idle" });
4422
+ const worker = await createAgent({
4423
+ name: "Negative Settle Worker",
4424
+ isLead: false,
4425
+ status: "idle",
4426
+ });
4427
+ const { channelId, threadTs } = uniqueSlackAddress("C_NEGATIVE_SETTLE");
4428
+ const ask = await createTaskExtended("negative settle ask", {
4429
+ agentId: lead.id,
4430
+ source: "slack",
4431
+ slackChannelId: channelId,
4432
+ slackThreadTs: threadTs,
4433
+ contextKey: slackContextKey({ channelId, threadTs }),
4434
+ });
4435
+ await startTask(ask.id);
4436
+ const child = await createTaskExtended("settle child work", {
4437
+ agentId: worker.id,
4438
+ source: "mcp",
4439
+ parentTaskId: ask.id,
4440
+ followUpConfig: { disabled: true },
4441
+ });
4442
+ await startTask(child.id);
4443
+ await completeTask(child.id, "Child result body.");
4444
+ calls.length = 0;
4445
+
4446
+ // Tick 1: the child gets its own card; the ask is still open, so no conclusion.
4447
+ await processSlackRenderV2();
4448
+ expect((await getSlackOutcomeMessage(child.id))?.finalizedAt).toBeDefined();
4449
+ expect(await getSlackOutcomeMessage(ask.id)).toBeNull();
4450
+
4451
+ // Every member is terminal but the closure has been quiet for 2s only. A
4452
+ // negative settle window must not read as "already quiet long enough".
4453
+ await completeTask(ask.id, "Ask completed.");
4454
+ await backdateLastUpdated([ask.id, child.id], 2);
4455
+ calls.length = 0;
4456
+
4457
+ await processSlackRenderV2();
4458
+ expect(await getSlackOutcomeMessage(ask.id)).toBeNull();
4459
+
4460
+ // The fallback is the documented 10s, so 30s of quiet does conclude.
4461
+ await backdateLastUpdated([ask.id, child.id], 30);
4462
+ await processSlackRenderV2();
4463
+ expect((await getSlackOutcomeMessage(ask.id))?.conclusionKind).toBe("complete");
4464
+ });
4465
+
4466
+ test("a negative timeout falls back to the default, so a fresh unfinished closure is not timed out at once", async () => {
4467
+ process.env.SLACK_CONCLUSION_TIMEOUT_MIN = "-1";
4468
+ const lead = await createAgent({ name: "Negative Timeout Lead", isLead: true, status: "idle" });
4469
+ const worker = await createAgent({
4470
+ name: "Negative Timeout Worker",
4471
+ isLead: false,
4472
+ status: "idle",
4473
+ });
4474
+ const { channelId, threadTs } = uniqueSlackAddress("C_NEGATIVE_TIMEOUT");
4475
+ const ask = await createTaskExtended("negative timeout ask", {
4476
+ agentId: lead.id,
4477
+ source: "slack",
4478
+ slackChannelId: channelId,
4479
+ slackThreadTs: threadTs,
4480
+ contextKey: slackContextKey({ channelId, threadTs }),
4481
+ });
4482
+ await startTask(ask.id);
4483
+ const child = await createTaskExtended("still running work", {
4484
+ agentId: worker.id,
4485
+ source: "mcp",
4486
+ parentTaskId: ask.id,
4487
+ followUpConfig: { disabled: true },
4488
+ });
4489
+ await startTask(child.id);
4490
+ await completeTask(ask.id, "Ask done; the child never finished.");
4491
+ await backdateLastUpdated([ask.id, child.id], 2);
4492
+ calls.length = 0;
4493
+
4494
+ // 2s of idle is nowhere near the 240min fallback, so no timeout card.
4495
+ await processSlackRenderV2();
4496
+ expect(await getSlackOutcomeMessage(ask.id)).toBeNull();
4497
+
4498
+ // Past the documented 240min default the closure does conclude as timed out.
4499
+ await backdateLastUpdated([ask.id, child.id], 260 * 60);
4500
+ await processSlackRenderV2();
4501
+ expect((await getSlackOutcomeMessage(ask.id))?.conclusionKind).toBe("timeout");
4502
+ });
4503
+
4419
4504
  test("a stale in-progress ask times out without a completed outcome", async () => {
4420
4505
  process.env.SLACK_CONCLUSION_TIMEOUT_MIN = "1";
4421
4506
  const lead = await createAgent({ name: "Stale Ask Lead", isLead: true, status: "idle" });
@@ -22,6 +22,7 @@ function serviceShape(service: Service) {
22
22
  return {
23
23
  defaultModel: service.defaultModel,
24
24
  allowedModels: service.allowedModels ? [...service.allowedModels] : undefined,
25
+ knownModels: service.knownModels ? [...service.knownModels] : undefined,
25
26
  };
26
27
  }
27
28
 
@@ -13,8 +13,10 @@ describe("Azure Repos URL helpers", () => {
13
13
  "https://dev.azure.com/org/project/_git/repo",
14
14
  "https://org@dev.azure.com/org/project/_git/repo",
15
15
  "git@ssh.dev.azure.com:v3/org/project/repo",
16
+ "ssh://git@ssh.dev.azure.com/v3/org/project/repo",
16
17
  "https://fabrikam.visualstudio.com/DefaultCollection/_git/Fabrikam",
17
18
  "https://dev.azure.com/github-mirror/project/_git/repo",
19
+ "dev.azure.com/org/project/_git/repo",
18
20
  ]) {
19
21
  expect(isAzureDevOpsUrl(url)).toBe(true);
20
22
  expect(detectVcsProvider(url)).toBe("azure-devops");
@@ -22,6 +24,14 @@ describe("Azure Repos URL helpers", () => {
22
24
  expect(detectVcsProvider("desplega-ai/agent-swarm")).toBe("github");
23
25
  expect(detectVcsProvider("https://gitlab.com/group/project")).toBe("gitlab");
24
26
  expect(isAzureDevOpsUrl("https://example.com/dev.azure.com.html")).toBe(false);
27
+ // Only the host counts: a `dev.azure.com` path segment on another host is not Azure.
28
+ expect(isAzureDevOpsUrl("https://notdev.azure.com/org/project/_git/repo")).toBe(false);
29
+ expect(isAzureDevOpsUrl("https://dev.azure.com.evil.com/org/project/_git/repo")).toBe(false);
30
+ expect(isAzureDevOpsUrl("https://x.dev.azure.com/org/project/_git/repo")).toBe(false);
31
+ expect(isAzureDevOpsUrl("https://github.com/acme/dev.azure.com/tree/main")).toBe(false);
32
+ expect(isAzureDevOpsUrl("git@github.com:acme/dev.azure.com.git")).toBe(false);
33
+ expect(isAzureDevOpsUrl("https://code.example.com/acme/dev.azure.com/repo")).toBe(false);
34
+ expect(detectVcsProvider("git@github.com:acme/dev.azure.com.git")).toBe("github");
25
35
  });
26
36
 
27
37
  test("canonicalizes clone URLs to one https form", () => {
@@ -4,6 +4,10 @@ import { detectVcsProvider } from "../vcs";
4
4
  describe("detectVcsProvider", () => {
5
5
  test("detects github.com URLs", () => {
6
6
  expect(detectVcsProvider("https://github.com/org/repo")).toBe("github");
7
+ expect(detectVcsProvider("git@github.com:org/repo.git")).toBe("github");
8
+ expect(detectVcsProvider("https://www.github.com/org/repo")).toBe("github");
9
+ // A `dev.azure.com` path segment on a GitHub URL is still a GitHub URL.
10
+ expect(detectVcsProvider("https://github.com/acme/dev.azure.com/tree/main")).toBe("github");
7
11
  });
8
12
 
9
13
  test("detects shorthand org/repo as github", () => {
@@ -58,5 +62,9 @@ describe("detectVcsProvider", () => {
58
62
  test("returns null for unrecognised URLs", () => {
59
63
  expect(detectVcsProvider("https://example.com")).toBeNull();
60
64
  expect(detectVcsProvider("https://notbitbucket.org/org/repo")).toBeNull();
65
+ // A `github.com` path segment on another host keeps that host's provider.
66
+ expect(detectVcsProvider("https://gitea.example.com/mirrors/github.com/acme/repo")).toBeNull();
67
+ expect(detectVcsProvider("https://notgithub.com/acme/repo")).toBeNull();
68
+ expect(detectVcsProvider("https://code.example.com/acme/repo")).toBeNull();
61
69
  });
62
70
  });
@@ -0,0 +1,163 @@
1
+ /**
2
+ * The org design system: one brand record per swarm deployment, stored in KV
3
+ * (`design-system` / `org`). It restyles every designVersion 2 page that sets
4
+ * no `theme` (see `resolvePageTheme`). `design-system-set` is the only writer;
5
+ * the namespace is reserved, so a raw `kv-set` cannot skip these checks.
6
+ *
7
+ * Writes and reads run the same checks: tokens go through the theme importer,
8
+ * URLs are https (fonts pinned to Google Fonts, which the page CSP allows),
9
+ * and the base preset must exist. A stored record that fails them reads as
10
+ * invalid and pages ignore it.
11
+ */
12
+
13
+ import { type DesignSystem, type DesignSystemInput, DesignSystemSchema } from "../types";
14
+ import { importThemeTokens, ThemeImportError } from "./import";
15
+ import { DEFAULT_THEME_ID, isThemePresetId, THEME_PRESET_IDS } from "./presets";
16
+
17
+ export const DESIGN_SYSTEM_NAMESPACE = "design-system";
18
+ export const DESIGN_SYSTEM_KEY = "org";
19
+ /** The value `design-system-set` replaced, kept for a one-step undo. */
20
+ export const DESIGN_SYSTEM_PREVIOUS_KEY = "org.prev";
21
+ // shortcut: single undo step, upgrade to versions if a second rollback is needed.
22
+
23
+ export type DesignSystemActor = { userId: string | null; agentId?: string };
24
+
25
+ const FONTS_HOST = "fonts.googleapis.com";
26
+ /** Quotes and angle brackets would break out of the `href` attribute even after escaping mistakes. */
27
+ const UNSAFE_URL_CHARACTERS = /["'<>\s\\]/;
28
+
29
+ export class DesignSystemError extends Error {
30
+ override name = "DesignSystemError";
31
+ }
32
+
33
+ function readHttpsUrl(value: string, label: string, host?: string): string {
34
+ let url: URL;
35
+ try {
36
+ url = new URL(value);
37
+ } catch {
38
+ throw new DesignSystemError(`${label} must be an absolute https URL`);
39
+ }
40
+ if (url.protocol !== "https:" || UNSAFE_URL_CHARACTERS.test(value)) {
41
+ throw new DesignSystemError(`${label} must be an absolute https URL`);
42
+ }
43
+ if (host && url.hostname !== host) {
44
+ throw new DesignSystemError(`${label} must be on https://${host}`);
45
+ }
46
+ return url.href;
47
+ }
48
+
49
+ function readColor(value: string, index: number): string {
50
+ try {
51
+ // The importer's value check is the token contract's check, so reuse it.
52
+ const { tokens } = importThemeTokens({ light: { "--color-chart-1": value } });
53
+ const color = tokens.light["--color-chart-1"];
54
+ if (color === undefined) throw new ThemeImportError("not a color value");
55
+ return color;
56
+ } catch (err) {
57
+ if (err instanceof ThemeImportError) {
58
+ throw new DesignSystemError(`chartPalette[${index}]: ${err.message}`);
59
+ }
60
+ throw err;
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Checks and normalizes a design system write. Throws `DesignSystemError`
66
+ * with a message that names the bad field. `ignored` lists the token names
67
+ * the importer could not place.
68
+ */
69
+ export function buildDesignSystem(
70
+ input: DesignSystemInput,
71
+ actor: DesignSystemActor,
72
+ now: Date = new Date(),
73
+ ): { record: DesignSystem; ignored: string[] } {
74
+ const stamp = {
75
+ source: input.source ?? { kind: "manual" as const },
76
+ updatedBy: actor.userId,
77
+ ...(actor.agentId ? { updatedByAgentId: actor.agentId } : {}),
78
+ updatedAt: now.toISOString(),
79
+ };
80
+ if (input.status === "declined") {
81
+ return {
82
+ record: {
83
+ v: 1,
84
+ status: "declined",
85
+ basePreset: DEFAULT_THEME_ID,
86
+ tokens: { light: {}, dark: {} },
87
+ mode: "viewer",
88
+ ...stamp,
89
+ },
90
+ ignored: [],
91
+ };
92
+ }
93
+ const basePreset = input.basePreset ?? DEFAULT_THEME_ID;
94
+ if (!isThemePresetId(basePreset)) {
95
+ throw new DesignSystemError(
96
+ `Unknown basePreset "${basePreset}". Use one of: ${THEME_PRESET_IDS.join(", ")}`,
97
+ );
98
+ }
99
+ let imported: ReturnType<typeof importThemeTokens> = {
100
+ tokens: { light: {}, dark: {} },
101
+ ignored: [],
102
+ };
103
+ if (input.themeTokens) {
104
+ try {
105
+ imported = importThemeTokens(input.themeTokens as Parameters<typeof importThemeTokens>[0]);
106
+ } catch (err) {
107
+ if (err instanceof ThemeImportError) {
108
+ throw new DesignSystemError(`Invalid themeTokens: ${err.message}`);
109
+ }
110
+ throw err;
111
+ }
112
+ }
113
+ const record: DesignSystem = {
114
+ v: 1,
115
+ status: "active",
116
+ basePreset,
117
+ tokens: imported.tokens,
118
+ ...(input.fontsHref
119
+ ? { fontsHref: readHttpsUrl(input.fontsHref, "fontsHref", FONTS_HOST) }
120
+ : {}),
121
+ ...(input.logo
122
+ ? { logo: { url: readHttpsUrl(input.logo.url, "logo.url"), alt: input.logo.alt } }
123
+ : {}),
124
+ mode: input.mode ?? "viewer",
125
+ ...(input.chartPalette ? { chartPalette: input.chartPalette.map(readColor) } : {}),
126
+ ...stamp,
127
+ };
128
+ return { record, ignored: imported.ignored };
129
+ }
130
+
131
+ /**
132
+ * Revalidates a stored value. Returns null for a missing value and
133
+ * `{ invalid }` for one that no longer passes the write checks (a hand-edited
134
+ * row, or a preset that was removed), so pages fall back instead of rendering
135
+ * it.
136
+ */
137
+ export function readDesignSystem(
138
+ value: unknown,
139
+ ): { record: DesignSystem } | { invalid: string } | null {
140
+ if (value === undefined || value === null) return null;
141
+ const result = DesignSystemSchema.safeParse(value);
142
+ if (!result.success) return { invalid: "stored design system is not a valid v1 record" };
143
+ const parsed = result.data;
144
+ try {
145
+ const { record } = buildDesignSystem(
146
+ {
147
+ status: parsed.status,
148
+ basePreset: parsed.basePreset,
149
+ themeTokens: parsed.tokens,
150
+ fontsHref: parsed.fontsHref,
151
+ logo: parsed.logo,
152
+ mode: parsed.mode,
153
+ chartPalette: parsed.chartPalette,
154
+ source: parsed.source,
155
+ },
156
+ { userId: parsed.updatedBy, agentId: parsed.updatedByAgentId },
157
+ );
158
+ return { record: { ...record, updatedAt: parsed.updatedAt } };
159
+ } catch (err) {
160
+ if (err instanceof DesignSystemError) return { invalid: err.message };
161
+ throw err;
162
+ }
163
+ }
@@ -1,13 +1,17 @@
1
1
  /**
2
2
  * Theme resolution and CSS for HTML pages (design version 2).
3
3
  *
4
- * Resolution picks one preset, then applies the page's own overrides:
5
- * - Preset: the page `theme` when it names a known preset, else the viewer
6
- * theme (the dashboard's `__swarm-theme` param) when it names a known
7
- * preset, else `hive`. Direct links pass no viewer theme, so they get Hive.
8
- * - Tokens: the Hive values, then the preset's contract keys, then the page
9
- * `themeTokens` overrides. A shared token (font, radius) that the overrides
10
- * set only in `light` applies to dark too.
4
+ * Resolution picks one preset, then applies the token layers on top:
5
+ * - Preset: the page `theme` when it names a known preset, else the org
6
+ * design system's `basePreset`, else the viewer theme (the dashboard's
7
+ * `__swarm-theme` param) when it names a known preset, else `hive`. Direct
8
+ * links pass no viewer theme, so they get Hive. Once an org has a brand,
9
+ * the viewer preset no longer repaints it.
10
+ * - Tokens: the Hive values, then the preset's contract keys, then the org
11
+ * design system tokens, then the page `themeTokens` overrides. A shared
12
+ * token (font, radius) that a layer sets only in `light` applies to dark too.
13
+ * - The caller passes `designSystem` only for a page without its own `theme`
14
+ * (`pageHead` in src/http/pages-public.ts), so a page `theme` ignores it.
11
15
  *
12
16
  * The CSS carries both modes. `.dark` on `<html>` picks dark, and print is
13
17
  * always light.
@@ -60,24 +64,29 @@ export function resolvePageTheme({
60
64
  pageTheme,
61
65
  viewerTheme,
62
66
  overrides,
67
+ designSystem,
63
68
  }: {
64
69
  pageTheme?: string | null;
65
70
  viewerTheme?: string | null;
66
71
  overrides?: PageThemeTokens | null;
72
+ designSystem?: { basePreset: string; tokens: PageThemeTokens } | null;
67
73
  }): ResolvedPageTheme {
68
74
  const preset =
69
- getThemePreset(pageTheme) ?? getThemePreset(viewerTheme) ?? getThemePreset(DEFAULT_THEME_ID);
70
- const lightOverrides = contractValues(overrides?.light);
71
- const darkOverrides = contractValues(overrides?.dark);
72
- const light = {
73
- ...HIVE_PAGE_TOKENS.light,
74
- ...contractValues(preset?.vars.light),
75
- ...lightOverrides,
76
- };
77
- const dark = { ...HIVE_PAGE_TOKENS.dark, ...contractValues(preset?.vars.dark), ...darkOverrides };
78
- for (const token of PAGE_THEME_SHARED_TOKENS) {
79
- const value = lightOverrides[token];
80
- if (value !== undefined && darkOverrides[token] === undefined) dark[token] = value;
75
+ getThemePreset(pageTheme) ??
76
+ getThemePreset(designSystem?.basePreset) ??
77
+ getThemePreset(viewerTheme) ??
78
+ getThemePreset(DEFAULT_THEME_ID);
79
+ const light = { ...HIVE_PAGE_TOKENS.light, ...contractValues(preset?.vars.light) };
80
+ const dark = { ...HIVE_PAGE_TOKENS.dark, ...contractValues(preset?.vars.dark) };
81
+ for (const layer of [designSystem?.tokens, overrides]) {
82
+ const lightValues = contractValues(layer?.light);
83
+ const darkValues = contractValues(layer?.dark);
84
+ Object.assign(light, lightValues);
85
+ Object.assign(dark, darkValues);
86
+ for (const token of PAGE_THEME_SHARED_TOKENS) {
87
+ const value = lightValues[token];
88
+ if (value !== undefined && darkValues[token] === undefined) dark[token] = value;
89
+ }
81
90
  }
82
91
  return { presetId: preset?.id ?? DEFAULT_THEME_ID, light, dark };
83
92
  }
@@ -18,7 +18,7 @@ export const registerChatPostTool = (server: McpServer) => {
18
18
  {
19
19
  title: "Post to a chat thread or channel",
20
20
  description:
21
- "Lead only. Post a message to any Chat SDK thread or channel (Telegram, Slack, Discord, Teams), outside the thread of your current task. Give threadId to reply in a thread, or channelId to start a new message in a channel. Ids carry the adapter prefix, such as telegram:12345. To answer the user of your current chat task, use chat-reply instead. For a structured result (key figures, a table, charts, links), send a `card`; it posts after the text as a native card.",
21
+ "Lead only. Post a message to any Chat SDK thread or channel (Telegram, Slack, Discord, Teams), outside the thread of your current task. Give threadId to reply in a thread or Telegram topic, or channelId to use its registered default topic (otherwise the channel). Ids carry the adapter prefix, such as telegram:12345 or telegram:-100123:42 for topic 42. To answer the user of your current chat task, use chat-reply instead. For a structured result (key figures, a table, charts, links), send a `card`; it posts after the text as a native card.",
22
22
  annotations: { openWorldHint: true },
23
23
  inputSchema: z.object({
24
24
  adapter: z.enum(CHAT_SDK_ADAPTER_NAMES).describe("Chat SDK adapter name."),
@@ -26,12 +26,16 @@ export const registerChatPostTool = (server: McpServer) => {
26
26
  .string()
27
27
  .min(1)
28
28
  .optional()
29
- .describe("Full SDK thread id, such as telegram:12345 or slack:C123:1700000000.000100."),
29
+ .describe(
30
+ "Full SDK thread id, such as telegram:12345, telegram:-100123:42 (positive integer topic id), or slack:C123:1700000000.000100. Overrides the channel default.",
31
+ ),
30
32
  channelId: z
31
33
  .string()
32
34
  .min(1)
33
35
  .optional()
34
- .describe("Full SDK channel id, such as slack:C123. Ignored when threadId is set."),
36
+ .describe(
37
+ "Full SDK channel id, such as telegram:-100123 or slack:C123. Uses its registered default Telegram topic when set. Ignored when threadId is set.",
38
+ ),
35
39
  text: z
36
40
  .string()
37
41
  .min(1)
@@ -28,6 +28,7 @@ import { resolveTaskAuditUserId, resolveTaskGroupKey } from "@/be/audit-user";
28
28
  import { fileCallerSessionIntoGroup } from "@/be/caller-session-group";
29
29
  import { createPage, getPage, getPageBySlug, updatePage } from "@/be/db";
30
30
  import { getPageEditCounter } from "@/be/db/page-versions";
31
+ import { getDesignSystem } from "@/be/design-system";
31
32
  import { classAttributeValues, countColorLiterals } from "@/pages/color-literals";
32
33
  import { snapshotPage } from "@/pages/version";
33
34
  import { readThemeFields } from "@/themes/page-fields";
@@ -175,6 +176,7 @@ export const registerCreatePageTool = (server: McpServer) => {
175
176
  colorLiteralCount: z.number().optional(),
176
177
  usesDesignSystem: z.boolean().optional(),
177
178
  lightOnlyColors: z.boolean().optional(),
179
+ designSystemStatus: z.string().optional(),
178
180
  movedSessionRootId: z.string().optional(),
179
181
  }),
180
182
  },
@@ -303,6 +305,7 @@ export const registerCreatePageTool = (server: McpServer) => {
303
305
  Boolean(input.themeTokens) ||
304
306
  bodyUsesDesignSystem(fresh.body),
305
307
  lightOnlyColors: hasLightOnlyColors(fresh.themeTokens),
308
+ designSystemStatus: (await getDesignSystem()).current.status,
306
309
  ...(fresh.designVersion >= 2
307
310
  ? { colorLiteralCount: countColorLiterals(fresh.body) }
308
311
  : {}),
@@ -0,0 +1,102 @@
1
+ /**
2
+ * `design-system-get` / `design-system-set`: the org design system that
3
+ * restyles every designVersion 2 page without its own `theme`
4
+ * (src/themes/design-system.ts). `design-system-set` is the only agent-facing
5
+ * writer, so every value passes the theme importer's checks.
6
+ */
7
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
8
+ import * as z from "zod";
9
+ import { resolveTaskAuditUserId } from "@/be/audit-user";
10
+ import { getAgentById } from "@/be/db";
11
+ import { getDesignSystem, saveDesignSystem } from "@/be/design-system";
12
+ import { can } from "@/rbac";
13
+ import { buildDesignSystem, DesignSystemError } from "@/themes/design-system";
14
+ import { createToolRegistrar, swarmToolOutputSchema, toolErr, toolOk } from "@/tools/utils";
15
+ import { DesignSystemInputSchema } from "@/types";
16
+
17
+ const outputSchema = swarmToolOutputSchema({
18
+ status: z.string().optional(),
19
+ designSystem: z.unknown().optional(),
20
+ previous: z.unknown().optional(),
21
+ invalidReason: z.string().optional(),
22
+ ignoredTokens: z.array(z.string()).optional(),
23
+ saved: z.boolean().optional(),
24
+ });
25
+
26
+ export const registerDesignSystemTools = (server: McpServer) => {
27
+ const register = createToolRegistrar(server);
28
+
29
+ register(
30
+ "design-system-get",
31
+ {
32
+ title: "Get the org design system",
33
+ description:
34
+ 'Returns the org design system that restyles every HTML page without its own theme. status is "none" (nobody asked yet), "declined" (the requester said no; do not ask again), "active", or "invalid" (the stored record fails validation and pages ignore it). previous is the value the last design-system-set replaced, for a one-step undo.',
35
+ annotations: { readOnlyHint: true },
36
+ inputSchema: z.object({}),
37
+ outputSchema,
38
+ },
39
+ async () => {
40
+ const { current, previous } = await getDesignSystem();
41
+ return toolOk(`Design system status: ${current.status}.`, {
42
+ data: {
43
+ status: current.status,
44
+ ...("record" in current ? { designSystem: current.record } : {}),
45
+ ...("reason" in current ? { invalidReason: current.reason } : {}),
46
+ ...("record" in previous ? { previous: previous.record } : {}),
47
+ },
48
+ });
49
+ },
50
+ );
51
+
52
+ register(
53
+ "design-system-set",
54
+ {
55
+ title: "Set the org design system",
56
+ description:
57
+ 'Saves the org design system: a base preset plus token overrides, fonts, logo, mode lock and chart palette. Every HTML page without its own theme picks it up on its next view. Save only what the requester approved, after they saw a preview (the design-system-seed script builds one). To record a "no", pass status "declined". dryRun: true validates and returns the normalized record without saving. The replaced value is kept as previous (see design-system-get).',
58
+ annotations: { destructiveHint: false },
59
+ rbac: { permission: "design-system.write" },
60
+ inputSchema: DesignSystemInputSchema.extend({
61
+ dryRun: z
62
+ .boolean()
63
+ .optional()
64
+ .describe("Validate and return the normalized record without saving."),
65
+ }),
66
+ outputSchema,
67
+ },
68
+ async ({ dryRun, ...input }, requestInfo) => {
69
+ if (!requestInfo.agentId) return toolErr('Agent ID not found. Set the "X-Agent-ID" header.');
70
+ const agent = await getAgentById(requestInfo.agentId);
71
+ const decision = can({
72
+ principal: { kind: "agent", agentId: requestInfo.agentId, isLead: agent?.isLead ?? false },
73
+ verb: "design-system.write",
74
+ source: "mcp",
75
+ });
76
+ if (!decision.allow) return toolErr(decision.reason);
77
+
78
+ const userId = await resolveTaskAuditUserId(requestInfo.sourceTaskId, requestInfo.agentId);
79
+ let built: ReturnType<typeof buildDesignSystem>;
80
+ try {
81
+ built = buildDesignSystem(input, { userId, agentId: requestInfo.agentId });
82
+ } catch (err) {
83
+ if (err instanceof DesignSystemError) return toolErr(err.message);
84
+ throw err;
85
+ }
86
+ if (!dryRun) await saveDesignSystem(built.record);
87
+ const { record, ignored } = built;
88
+ return toolOk(
89
+ `${dryRun ? "Validated" : "Saved"} ${record.status} design system (basePreset=${record.basePreset}, mode=${record.mode}).` +
90
+ (ignored.length > 0 ? ` Ignored tokens: ${ignored.join(", ")}.` : ""),
91
+ {
92
+ data: {
93
+ status: record.status,
94
+ designSystem: record,
95
+ saved: !dryRun,
96
+ ...(ignored.length > 0 ? { ignoredTokens: ignored } : {}),
97
+ },
98
+ },
99
+ );
100
+ },
101
+ );
102
+ };
@@ -8,7 +8,7 @@ export const registerMcpServerGetTool = (server: McpServer) => {
8
8
  "mcp-server-get",
9
9
  {
10
10
  title: "Get MCP Server",
11
- annotations: { destructiveHint: false },
11
+ annotations: { readOnlyHint: true },
12
12
  description:
13
13
  "Get MCP server details by ID or name. Name resolution uses scope cascade: agent > swarm > global.",
14
14
  inputSchema: z.object({