@desplega.ai/agent-swarm 2.13.3 → 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 (289) hide show
  1. package/dist/acp-adapter-mr4temec.js +17 -0
  2. package/dist/{acp-targets-k8xs4tj8.js → acp-targets-zrk9k0n7.js} +10 -10
  3. package/dist/{actions-pg5fxjer.js → actions-acqqj9jn.js} +236 -26
  4. package/dist/{agent-fs-provision-vbk3fppw.js → agent-fs-provision-zmaykqnd.js} +4 -4
  5. package/dist/{amp-adapter-adbhxsz9.js → amp-adapter-a7ts8tmw.js} +3 -3
  6. package/dist/{app-b267ggx1.js → app-tmwa442h.js} +7 -7
  7. package/dist/{approval-notifications-evc1a9z5.js → approval-notifications-6psaaaye.js} +8 -8
  8. package/dist/{assistant-wgz2ab84.js → assistant-564v6emv.js} +24 -24
  9. package/dist/{boot-args-schema-6tpk28j4.js → boot-args-schema-n099e0f2.js} +1 -1
  10. package/dist/{boot-reembed-ankp369c.js → boot-reembed-chx66qfk.js} +1 -1
  11. package/dist/{boot-reembed-r1zyvefv.js → boot-reembed-epvg4fp9.js} +1 -1
  12. package/dist/{boot-scrub-sweep-cgb6r5bd.js → boot-scrub-sweep-dhkfp0a7.js} +2 -2
  13. package/dist/{boot-seeds-bjceqg7b.js → boot-seeds-m74fc07r.js} +4 -4
  14. package/dist/{boxd-hr8rsxzq.js → boxd-451q55ys.js} +1 -1
  15. package/dist/{claude-adapter-knztdnff.js → claude-adapter-hw63yj3j.js} +9 -9
  16. package/dist/{claude-managed-adapter-qwejzqkk.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-c3g6dv0g.js → claude-sdk-session-cktyqkpk.js} +11 -11
  19. package/dist/{cli-7fa6yv98.js → cli-0fgvnb0x.js} +6 -6
  20. package/dist/{cli-2v4xxnx2.js → cli-0h8skzss.js} +1 -1
  21. package/dist/{cli-hhb8kbwd.js → cli-0p76my9q.js} +29 -14
  22. package/dist/{cli-fp65jdp2.js → cli-1kvcsd2f.js} +219 -155
  23. package/dist/{cli-wtffytm8.js → cli-1vmhnncj.js} +3 -3
  24. package/dist/{cli-268b3dgn.js → cli-29h5239w.js} +5 -5
  25. package/dist/{cli-8fj8yfmk.js → cli-2vp0z049.js} +1 -1
  26. package/dist/{cli-bh53ppqm.js → cli-3bxrrh53.js} +4 -4
  27. package/dist/{cli-61fzwtjk.js → cli-3tzmh38q.js} +9 -9
  28. package/dist/{cli-88np9va3.js → cli-3xqad83h.js} +1 -1
  29. package/dist/{cli-gc715jrc.js → cli-3zrwrnz7.js} +1 -1
  30. package/dist/{cli-dw43pnzp.js → cli-404am6f3.js} +7 -7
  31. package/dist/{cli-8pnawt98.js → cli-49aq3cyn.js} +4 -4
  32. package/dist/{cli-fbmgpt72.js → cli-4fpa0zns.js} +3 -3
  33. package/dist/{cli-kwm1bek7.js → cli-4pbwg7sn.js} +2 -2
  34. package/dist/{cli-djwt4mtn.js → cli-4q2c8rxw.js} +9 -9
  35. package/dist/{cli-3mf04tkh.js → cli-4vynxtrb.js} +1 -1
  36. package/dist/{cli-80d5g0fa.js → cli-5ashycw3.js} +3 -3
  37. package/dist/{cli-61p7ty8d.js → cli-5rgm8p39.js} +3 -3
  38. package/dist/{cli-r6xnchva.js → cli-5rxsb3wq.js} +6 -6
  39. package/dist/{cli-a21cwm89.js → cli-60dwk8tx.js} +3 -3
  40. package/dist/{cli-v1v49t36.js → cli-7by7vp6m.js} +2 -2
  41. package/dist/{cli-vgh5adn9.js → cli-7g3fg4gf.js} +7 -7
  42. package/dist/{cli-hxj888w3.js → cli-7gbff32z.js} +2 -2
  43. package/dist/{cli-q8aq48v1.js → cli-8b4rpnwj.js} +1 -1
  44. package/dist/{cli-xc8m5cjn.js → cli-8cas2xvp.js} +3 -3
  45. package/dist/{cli-1606qw3n.js → cli-904wk98s.js} +797 -369
  46. package/dist/{cli-h3drhntp.js → cli-93n305hm.js} +2 -2
  47. package/dist/{cli-1wew39p0.js → cli-944w9wb4.js} +20 -16
  48. package/dist/{cli-je587f74.js → cli-94gx6ze9.js} +1 -1
  49. package/dist/{cli-hpxcfvdm.js → cli-9ah37a8a.js} +6 -6
  50. package/dist/{cli-rfejbpe1.js → cli-akm6y2a8.js} +1 -1
  51. package/dist/{cli-f8rcvf2x.js → cli-azj9t1f9.js} +37 -2
  52. package/dist/{cli-ef590376.js → cli-bv4vvnmg.js} +3 -3
  53. package/dist/{cli-ppf9ap9n.js → cli-bzcwwebm.js} +1 -1
  54. package/dist/{cli-sy2ge2ye.js → cli-cq4am6vg.js} +2 -2
  55. package/dist/{cli-gxqwm3k3.js → cli-d5pc8ep0.js} +102 -8
  56. package/dist/{cli-hd2a204w.js → cli-ea7nz50q.js} +12 -12
  57. package/dist/{cli-zkbz8m2q.js → cli-fkpnx3vf.js} +1 -1
  58. package/dist/{cli-ya1cj689.js → cli-fw67mnyc.js} +1 -1
  59. package/dist/{cli-5basv0e7.js → cli-gkv0r2hq.js} +1 -1
  60. package/dist/{cli-ka4tqjzd.js → cli-gse7bp3z.js} +12 -10
  61. package/dist/{cli-v8rpjrnx.js → cli-gtj12v95.js} +1 -1
  62. package/dist/{cli-g4dhd3pr.js → cli-hdhpdrka.js} +6 -23
  63. package/dist/{cli-dq30fq3q.js → cli-hhtbandk.js} +2 -2
  64. package/dist/cli-hyqksecw.js +1907 -0
  65. package/dist/{cli-t25rq8mg.js → cli-ja450998.js} +40 -11
  66. package/dist/{cli-43dsqhcp.js → cli-jbrc98qb.js} +4 -4
  67. package/dist/{cli-8sayvj48.js → cli-jyhbvdga.js} +3 -3
  68. package/dist/{cli-55fqpd9q.js → cli-jzerrzgc.js} +8 -8
  69. package/dist/{cli-hv3820ez.js → cli-k0nebh10.js} +1 -1
  70. package/dist/{cli-aytna2fm.js → cli-ka48vpev.js} +5 -5
  71. package/dist/{cli-d2epqm0y.js → cli-kezzteka.js} +1 -1
  72. package/dist/{cli-grk77aen.js → cli-kj84fqxz.js} +2 -2
  73. package/dist/{cli-h0ewec3d.js → cli-kr0jpw9c.js} +1 -1
  74. package/dist/{cli-wsnradtk.js → cli-m1sns1da.js} +2 -2
  75. package/dist/{cli-7kv5d674.js → cli-n1kjs58m.js} +4 -4
  76. package/dist/{cli-syqcny89.js → cli-nc4pbwmp.js} +9 -9
  77. package/dist/{cli-9gmkw6xn.js → cli-p3knvk62.js} +48 -42
  78. package/dist/{cli-50whymxq.js → cli-p436yrzp.js} +2 -2
  79. package/dist/{cli-0j4qmc80.js → cli-phdzn699.js} +7 -7
  80. package/dist/{cli-1gnf5c7x.js → cli-pz1dp12c.js} +1 -1
  81. package/dist/{cli-nbawx3s0.js → cli-pz1nq5xm.js} +6 -6
  82. package/dist/{cli-4dyhzhpx.js → cli-qzz6tz8s.js} +1 -1
  83. package/dist/{cli-ea367bdn.js → cli-rmgvwcmy.js} +22 -22
  84. package/dist/{cli-mgr3gatr.js → cli-rv3y60bt.js} +4 -4
  85. package/dist/cli-s33bzmk0.js +27 -0
  86. package/dist/{cli-at67kvnp.js → cli-srktrbby.js} +1 -1
  87. package/dist/{cli-pzsedyb0.js → cli-t0jmkcah.js} +14 -14
  88. package/dist/{cli-eetzmsy5.js → cli-t9pzz2eq.js} +2 -2
  89. package/dist/{cli-w24741sm.js → cli-tr19nyn9.js} +4 -4
  90. package/dist/{cli-e4gx499y.js → cli-ts5yv7dn.js} +163 -86
  91. package/dist/{cli-czeh7x13.js → cli-tsc3pdfd.js} +4 -4
  92. package/dist/{cli-y0q92v4r.js → cli-tzw1jr2t.js} +2 -2
  93. package/dist/{cli-tjf1bh1v.js → cli-x2cem5vy.js} +6 -4
  94. package/dist/{cli-vx9acp12.js → cli-ybte1fqc.js} +1 -1
  95. package/dist/{cli-gkjw33x5.js → cli-ysv0k1we.js} +2 -2
  96. package/dist/{cli-vdfngx2g.js → cli-ywy8yz6t.js} +2 -2
  97. package/dist/{cli-cpkxh68d.js → cli-z1vam71h.js} +2 -2
  98. package/dist/{cli-8m6gqnf1.js → cli-zexwhj3f.js} +3 -3
  99. package/dist/{cli-snwz16eg.js → cli-zhwjdhjr.js} +2 -2
  100. package/dist/{cli-y754psdt.js → cli-zjdhrzm0.js} +4 -4
  101. package/dist/cli.js +19 -19
  102. package/dist/{codex-adapter-493vb8cv.js → codex-adapter-2fs2c0n6.js} +8 -8
  103. package/dist/{codex-hook-ej8hn6z5.js → codex-hook-jxjv6dy5.js} +1 -1
  104. package/dist/{codex-login-ven5cz5j.js → codex-login-ktfg1cxk.js} +1 -1
  105. package/dist/{codex-session-runner-ps5m4z1g.js → codex-session-runner-r55tmx4c.js} +9 -9
  106. package/dist/{commands-shktk0b8.js → commands-0mxdy9x8.js} +3 -3
  107. package/dist/{controller-wn3vd217.js → controller-g3vkfhr4.js} +4 -4
  108. package/dist/{controllers-connect-yft057ws.js → controllers-connect-4wdmncqt.js} +25 -25
  109. package/dist/core-gsvj5f3z.js +42 -0
  110. package/dist/{cursor-adapter-8fpm4dng.js → cursor-adapter-t9qb96q2.js} +2 -2
  111. package/dist/{db-0ezhdhz5.js → db-487vvyv9.js} +3 -3
  112. package/dist/{db-84pz2w5c.js → db-76p7w3gr.js} +2 -2
  113. package/dist/{devin-adapter-fs90ab4v.js → devin-adapter-3bp6rape.js} +1 -1
  114. package/dist/{dispatcher-h2rz69f6.js → dispatcher-64rp6w67.js} +22 -22
  115. package/dist/{docker-1h33jvh9.js → docker-a59g3ebm.js} +2 -2
  116. package/dist/{dsh-adapter-g9yqv09y.js → dsh-adapter-8abzqk5c.js} +2 -2
  117. package/dist/{e2b-y7e5kmzf.js → e2b-3ykbe805.js} +2 -2
  118. package/dist/{e2b-jnk0yeva.js → e2b-dc8f6ctq.js} +2 -2
  119. package/dist/{easter-egg-3d-m41ad78v.js → easter-egg-3d-jrrwyf55.js} +1 -1
  120. package/dist/{embedding-space-yam9zwzj.js → embedding-space-001hhhpk.js} +6 -6
  121. package/dist/{embeddings-g2be0y8q.js → embeddings-esj19cnw.js} +1 -1
  122. package/dist/{event-bus-08t2b4y2.js → event-bus-7gbsr0g4.js} +1 -1
  123. package/dist/{execute-hhdejgzf.js → execute-301hkxqg.js} +1 -1
  124. package/dist/{external-channel-kjt2yzfj.js → external-channel-w10e2j05.js} +2 -2
  125. package/dist/fx-adapter-4sjrbdne.js +20 -0
  126. package/dist/grok-adapter-3a0ezfee.js +20 -0
  127. package/dist/handlers-ef3k11hb.js +41 -0
  128. package/dist/{heartbeat-2e5jdexj.js → heartbeat-tbrj7vhq.js} +25 -25
  129. package/dist/{hook-acg9saz7.js → hook-3am1sq68.js} +6 -6
  130. package/dist/{hook-34s8cmgn.js → hook-tx917rqw.js} +8 -8
  131. package/dist/{http-ra2zr2f8.js → http-3rmemtqy.js} +335 -1829
  132. package/dist/{index-mbpxhc4w.js → index-126v2d0t.js} +1 -4
  133. package/dist/{index-2z1z7qx6.js → index-2jw11t8s.js} +26 -26
  134. package/dist/{index-9q42cr54.js → index-aetfyx6p.js} +1 -1
  135. package/dist/index-e6bq0exk.js +42 -0
  136. package/dist/{index-9r4j0a60.js → index-gfnq66t1.js} +223 -25
  137. package/dist/index-hf2k1vge.js +39 -0
  138. package/dist/{index-93bw5wds.js → index-s7xtvc0f.js} +1 -1
  139. package/dist/index-taxmejj3.js +44 -0
  140. package/dist/{k8s-8326q0rq.js → k8s-36gfn847.js} +2 -2
  141. package/dist/{keepalive-vjnnqbkm.js → keepalive-9px3t7qj.js} +5 -5
  142. package/dist/lead-5vt6f174.js +83 -0
  143. package/dist/{maintenance-px2g599e.js → maintenance-vwqjwst6.js} +1 -1
  144. package/dist/{oauth-refresh-sweep-nkykf09m.js → oauth-refresh-sweep-yqry3wn4.js} +4 -4
  145. package/dist/{object-webhooks-gt9xnq21.js → object-webhooks-8s1wtths.js} +7 -7
  146. package/dist/{onboard-1f134p65.js → onboard-hb8czx0p.js} +7 -7
  147. package/dist/{opencode-adapter-94976yab.js → opencode-adapter-djd6m6dk.js} +8 -8
  148. package/dist/{otel-impl-5d4p2fqs.js → otel-impl-2ymwyczz.js} +2 -2
  149. package/dist/{pending-vkk0vx6n.js → pending-nxavtvx7.js} +23 -23
  150. package/dist/{pi-mono-adapter-cyzdv5er.js → pi-mono-adapter-d2cpmcy4.js} +12 -12
  151. package/dist/{pricing-refresh-jtmjwss9.js → pricing-refresh-1yz8jkqv.js} +2 -2
  152. package/dist/{rbac-roles-1fvmdyeb.js → rbac-roles-7s6m31xw.js} +6 -4
  153. package/dist/{rbac-roles-yd1fgpsn.js → rbac-roles-dbpx0x9v.js} +3 -3
  154. package/dist/{render-v2-kb5s3vx4.js → render-v2-7y20rjrn.js} +7 -7
  155. package/dist/{resume-z1vs44n5.js → resume-wz546x47.js} +10 -10
  156. package/dist/{runtime-gk6ct7r7.js → runtime-cb5bd9tz.js} +1 -1
  157. package/dist/{session-access-nz6nre4d.js → session-access-4vcft8kq.js} +5 -5
  158. package/dist/{session-source-backfill-wb60zjkd.js → session-source-backfill-57b50tpw.js} +3 -3
  159. package/dist/{setup-2x8g8j4s.js → setup-e1tevjyj.js} +1 -1
  160. package/dist/thread-buffer-686pa1p1.js +42 -0
  161. package/dist/{tree-visibility-ts3z30kw.js → tree-visibility-07wf1nct.js} +2 -2
  162. package/dist/{user-merge-jobs-zetg26e0.js → user-merge-jobs-n20qpv6s.js} +3 -3
  163. package/dist/{virtual-modules-674fka8x.js → virtual-modules-6fxmn1yv.js} +3 -3
  164. package/dist/{work-objects-w52yyjxm.js → work-objects-eg7y48pe.js} +25 -25
  165. package/dist/worker-4vp616ms.js +83 -0
  166. package/dist/{worker-follow-up-dyfxyjbj.js → worker-follow-up-jnvnnf2b.js} +22 -22
  167. package/dist/{x-asbrnafg.js → x-d27jj7z7.js} +2 -2
  168. package/openapi.json +475 -28
  169. package/package.json +2 -2
  170. package/src/be/db/approvals.ts +2 -0
  171. package/src/be/db/runtime.ts +5 -0
  172. package/src/be/db/script-run-sources.ts +17 -0
  173. package/src/be/db-retention.ts +1 -1
  174. package/src/be/db.ts +71 -62
  175. package/src/be/design-system.ts +63 -0
  176. package/src/be/migrations/342_script_run_sources.sql +20 -0
  177. package/src/be/migrations/runner.ts +8 -0
  178. package/src/be/migrations/script-run-sources.ts +51 -0
  179. package/src/be/rbac-roles.ts +2 -0
  180. package/src/be/scripts/typecheck.ts +4 -2
  181. package/src/be/seed-scripts/catalog/design-system-seed.ts +158 -0
  182. package/src/be/seed-scripts/index.ts +9 -0
  183. package/src/be/swarm-config-guard.ts +21 -1
  184. package/src/commands/onboard/agent-fs-version.ts +1 -1
  185. package/src/heartbeat/heartbeat.ts +18 -4
  186. package/src/http/all-routes.ts +1 -0
  187. package/src/http/approval-chat-answer.ts +99 -0
  188. package/src/http/approval-requests.ts +280 -225
  189. package/src/http/design-system.ts +103 -0
  190. package/src/http/index.ts +10 -6
  191. package/src/http/pages-public.ts +25 -10
  192. package/src/http/pages.ts +17 -0
  193. package/src/http/person-responder.ts +28 -0
  194. package/src/integrations/chat-sdk/adapters.ts +33 -3
  195. package/src/integrations/chat-sdk/inbound.ts +6 -18
  196. package/src/integrations/chat-sdk/mentions.ts +188 -0
  197. package/src/integrations/chat-sdk/outbound.ts +20 -3
  198. package/src/integrations/chat-sdk/router.ts +8 -0
  199. package/src/integrations/chat-sdk/telegram-thread.ts +12 -0
  200. package/src/jira/adf.ts +35 -9
  201. package/src/kv-reserved-namespaces.ts +5 -0
  202. package/src/pages/page-head.ts +11 -1
  203. package/src/providers/amp-adapter.ts +1 -1
  204. package/src/providers/dsh-adapter.ts +48 -13
  205. package/src/rbac/legacy-policy.ts +4 -0
  206. package/src/rbac/permissions.ts +8 -0
  207. package/src/scheduler/index.ts +1 -0
  208. package/src/scheduler/scheduler.test.ts +32 -1
  209. package/src/scheduler/scheduler.ts +24 -1
  210. package/src/script-workflows/executor.ts +6 -0
  211. package/src/script-workflows/supervisor.ts +2 -1
  212. package/src/scripts-runtime/sdk-allowlist.ts +2 -0
  213. package/src/scripts-runtime/swarm-sdk.ts +12 -23
  214. package/src/scripts-runtime/types/stdlib.d.ts +4 -1
  215. package/src/scripts-runtime/types/swarm-sdk.d.ts +4 -1
  216. package/src/server.ts +2 -0
  217. package/src/slack/actions.ts +3 -0
  218. package/src/slack/approval-actions.ts +148 -0
  219. package/src/slack/approval-buttons.ts +28 -0
  220. package/src/tests/chat-sdk-mentions.test.ts +183 -0
  221. package/src/tests/create-page-tool.test.ts +5 -0
  222. package/src/tests/dsh-adapter.test.ts +53 -1
  223. package/src/tests/fixtures/compiled-source-schema-boot.ts +24 -0
  224. package/src/tests/fixtures/secret-corpus.ts +43 -1
  225. package/src/tests/heartbeat-stall-thresholds.test.ts +174 -0
  226. package/src/tests/jira-adf.test.ts +42 -2
  227. package/src/tests/merge-gate-detect-changes.test.ts +208 -16
  228. package/src/tests/migration-342-script-run-sources.test.ts +196 -0
  229. package/src/tests/migration-bunfs-compat.test.ts +129 -9
  230. package/src/tests/rbac-e2e-helpers.test.ts +10 -4
  231. package/src/tests/rbac-e2e-helpers.ts +13 -4
  232. package/src/tests/rbac-roles.test.ts +2 -0
  233. package/src/tests/runtime-e2b-pools.test.ts +7 -1
  234. package/src/tests/schedule-target-type.test.ts +4 -1
  235. package/src/tests/script-connections.test.ts +2 -0
  236. package/src/tests/script-runs-retention.test.ts +43 -16
  237. package/src/tests/script-workflows-runtime-e2e.test.ts +56 -22
  238. package/src/tests/scripts-http.test.ts +9 -3
  239. package/src/tests/sdk-allowlist.test.ts +26 -13
  240. package/src/tests/sdk-store-progress-skipped.test.ts +12 -5
  241. package/src/tests/secret-rules.test.ts +34 -0
  242. package/src/tests/secret-scrub-gate.test.ts +7 -0
  243. package/src/tests/secret-scrubber.test.ts +62 -2
  244. package/src/tests/seed-scripts.test.ts +2 -2
  245. package/src/tests/system-one-hosts-ui-mirror.test.ts +1 -0
  246. package/src/tests/vcs-azure-devops.test.ts +10 -0
  247. package/src/tests/vcs-provider.test.ts +8 -0
  248. package/src/themes/design-system.ts +163 -0
  249. package/src/themes/page-theme.ts +28 -19
  250. package/src/tools/chat-post.ts +7 -3
  251. package/src/tools/create-page.ts +3 -0
  252. package/src/tools/design-system.ts +102 -0
  253. package/src/tools/mcp-servers/mcp-server-get.ts +1 -1
  254. package/src/tools/mcp-servers/mcp-server-list.ts +1 -1
  255. package/src/tools/register-chat-channel.ts +11 -2
  256. package/src/tools/skills/skill-get-file.ts +1 -1
  257. package/src/tools/skills/skill-get.ts +1 -1
  258. package/src/tools/skills/skill-list.ts +1 -1
  259. package/src/tools/skills/skill-search.ts +1 -1
  260. package/src/tools/utils.ts +49 -4
  261. package/src/tools/workflows/get-workflow-run.ts +1 -1
  262. package/src/tools/workflows/get-workflow.ts +1 -1
  263. package/src/tools/workflows/list-workflow-runs.ts +1 -1
  264. package/src/tools/workflows/list-workflows.ts +1 -1
  265. package/src/types.ts +65 -0
  266. package/src/utils/secret-rules.generated.ts +149 -149
  267. package/src/utils/secret-scrubber.ts +111 -5
  268. package/src/vcs/azure-devops.ts +22 -1
  269. package/src/vcs/index.ts +3 -1
  270. package/src/workflows/approval-inline.ts +122 -0
  271. package/src/workflows/approval-notifications.ts +7 -2
  272. package/src/workflows/engine.ts +6 -5
  273. package/src/workflows/executors/agent-task.ts +14 -0
  274. package/src/workflows/executors/system-one-providers.ts +23 -0
  275. package/templates/skills/pages/content.md +34 -8
  276. package/templates/skills/swarm-docs/content.md +5 -0
  277. package/templates/skills/workflow-iterate/content.md +1 -1
  278. package/dist/acp-adapter-t2q6nsqv.js +0 -17
  279. package/dist/cli-kh973792.js +0 -98
  280. package/dist/core-nheayfgm.js +0 -42
  281. package/dist/fx-adapter-8g7xsp8q.js +0 -20
  282. package/dist/grok-adapter-ztk2zkz1.js +0 -20
  283. package/dist/handlers-9ywssz71.js +0 -41
  284. package/dist/index-6mgbdtv1.js +0 -44
  285. package/dist/index-hqdsn2t2.js +0 -39
  286. package/dist/index-st231bqv.js +0 -40
  287. package/dist/lead-mk0xkth2.js +0 -82
  288. package/dist/thread-buffer-d50rqpev.js +0 -42
  289. package/dist/worker-662x1vse.js +0 -82
package/src/be/db.ts CHANGED
@@ -225,6 +225,7 @@ import { clearAgentModelProfileOnOverrideChange } from "./db/model-profiles";
225
225
  import { pageSearchSql } from "./db/page-search";
226
226
  import { parsePageThemeTokens } from "./db/page-theme-tokens";
227
227
  import { getDb, getDbClient } from "./db/runtime";
228
+ import { SCRIPT_RUN_SELECT, storeScriptRunSource } from "./db/script-run-sources";
228
229
  import { classifyClaudeUpdate } from "./db/session-log-reasoning";
229
230
  import {
230
231
  assertAssetKeyMovesAllowed,
@@ -14251,6 +14252,7 @@ type ScriptRunRow = {
14251
14252
  agentId: string;
14252
14253
  scriptName: string | null;
14253
14254
  source: string;
14255
+ storedSource?: string | null;
14254
14256
  args: string;
14255
14257
  kind: string;
14256
14258
  status: string;
@@ -14293,7 +14295,7 @@ function rowToScriptRun(row: ScriptRunRow): ScriptRun {
14293
14295
  id: row.id,
14294
14296
  agentId: row.agentId,
14295
14297
  scriptName: row.scriptName ?? undefined,
14296
- source: row.source,
14298
+ source: row.storedSource ?? row.source,
14297
14299
  // Durable-run args are sealed replay state; callers get the redacted view.
14298
14300
  // The supervisor reads the exact value via getScriptRunExecutionArgs.
14299
14301
  args: sealedJsonForDisplay(row.args),
@@ -14341,40 +14343,43 @@ export async function createScriptRun(data: {
14341
14343
  updatedBy?: string;
14342
14344
  }): Promise<{ run: ScriptRun; existing: boolean }> {
14343
14345
  const client = getDbClient();
14344
- if (data.idempotencyKey) {
14345
- const existing = await client.get<ScriptRunRow>(
14346
- "SELECT * FROM script_runs WHERE idempotencyKey = ?",
14347
- [data.idempotencyKey],
14348
- );
14349
- if (existing) return { run: rowToScriptRun(existing), existing: true };
14350
- }
14346
+ return client.transaction(async () => {
14347
+ if (data.idempotencyKey) {
14348
+ const existing = await client.get<ScriptRunRow>(
14349
+ `${SCRIPT_RUN_SELECT} WHERE r.idempotencyKey = ?`,
14350
+ [data.idempotencyKey],
14351
+ );
14352
+ if (existing) return { run: rowToScriptRun(existing), existing: true };
14353
+ }
14351
14354
 
14352
- const row = await client.get<ScriptRunRow>(
14353
- `INSERT INTO script_runs
14354
- (id, agentId, scriptName, source, args, idempotencyKey, requestedByUserId, sourceTaskId,
14355
+ const sourceHash = await storeScriptRunSource(data.source);
14356
+ const row = await client.get<ScriptRunRow>(
14357
+ `INSERT INTO script_runs
14358
+ (id, agentId, scriptName, source, sourceHash, args, idempotencyKey, requestedByUserId, sourceTaskId,
14355
14359
  created_by, updated_by, startedAt)
14356
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
14360
+ VALUES (?, ?, ?, '', ?, ?, ?, ?, ?, ?, ?, ?)
14357
14361
  RETURNING *`,
14358
- [
14359
- data.id,
14360
- data.agentId,
14361
- data.scriptName ?? null,
14362
- data.source,
14363
- // Sealed, not scrubbed: this is the run's execution input. The supervisor
14364
- // launches (and relaunches after a restart or pause) from it, so a
14365
- // redacted value would change what the script receives.
14366
- sealJson(data.args ?? null),
14367
- data.idempotencyKey ?? null,
14368
- data.requestedByUserId ?? null,
14369
- data.sourceTaskId ?? null,
14370
- data.createdBy ?? null,
14371
- data.updatedBy ?? data.createdBy ?? null,
14372
- // ISO like finishedAt and the inline path, not the column's datetime('now') default.
14373
- new Date().toISOString(),
14374
- ],
14375
- );
14376
- if (!row) throw new Error("Failed to create script run");
14377
- return { run: rowToScriptRun(row), existing: false };
14362
+ [
14363
+ data.id,
14364
+ data.agentId,
14365
+ data.scriptName ?? null,
14366
+ sourceHash,
14367
+ // Sealed, not scrubbed: this is the run's execution input. The supervisor
14368
+ // launches (and relaunches after a restart or pause) from it, so a
14369
+ // redacted value would change what the script receives.
14370
+ sealJson(data.args ?? null),
14371
+ data.idempotencyKey ?? null,
14372
+ data.requestedByUserId ?? null,
14373
+ data.sourceTaskId ?? null,
14374
+ data.createdBy ?? null,
14375
+ data.updatedBy ?? data.createdBy ?? null,
14376
+ // ISO like finishedAt and the inline path, not the column's datetime('now') default.
14377
+ new Date().toISOString(),
14378
+ ],
14379
+ );
14380
+ if (!row) throw new Error("Failed to create script run");
14381
+ return { run: rowToScriptRun({ ...row, storedSource: data.source }), existing: false };
14382
+ });
14378
14383
  }
14379
14384
 
14380
14385
  // Persist a synchronous inline run (POST /api/scripts/run) as an already-terminal
@@ -14401,40 +14406,44 @@ export async function recordInlineScriptRun(data: {
14401
14406
  const args = scrubJsonValue(data.args ?? null);
14402
14407
  const output = data.output === undefined ? null : scrubJsonValue(data.output);
14403
14408
  const provenance = getCurrentRunProvenance();
14404
- const row = await getDbClient().get<ScriptRunRow>(
14405
- `INSERT INTO script_runs
14406
- (id, agentId, scriptName, source, args, kind, status, output, error,
14409
+ const client = getDbClient();
14410
+ return client.transaction(async () => {
14411
+ const sourceHash = await storeScriptRunSource(data.source);
14412
+ const row = await client.get<ScriptRunRow>(
14413
+ `INSERT INTO script_runs
14414
+ (id, agentId, scriptName, source, sourceHash, args, kind, status, output, error,
14407
14415
  startedAt, finishedAt, requestedByUserId, created_by, updated_by, apiEndpointId,
14408
14416
  sourceStepId, parentScriptRunId)
14409
- VALUES (?, ?, ?, ?, ?, 'inline', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
14417
+ VALUES (?, ?, ?, '', ?, ?, 'inline', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
14410
14418
  RETURNING *`,
14411
- [
14412
- data.id,
14413
- data.agentId,
14414
- data.scriptName ?? null,
14415
- data.source,
14416
- args,
14417
- data.status,
14418
- output,
14419
- data.error ?? null,
14420
- data.startedAt,
14421
- data.finishedAt,
14422
- data.requestedByUserId ?? null,
14423
- data.createdBy ?? null,
14424
- data.createdBy ?? null,
14425
- data.apiEndpointId ?? null,
14426
- // A run called through another script run's token (a nested
14427
- // ctx.swarm.script_run) records that run and its workflow step.
14428
- provenance?.sourceStepId ?? null,
14429
- provenance?.sourceScriptRunId ?? null,
14430
- ],
14431
- );
14432
- if (!row) throw new Error("Failed to record inline script run");
14433
- return rowToScriptRun(row);
14419
+ [
14420
+ data.id,
14421
+ data.agentId,
14422
+ data.scriptName ?? null,
14423
+ sourceHash,
14424
+ args,
14425
+ data.status,
14426
+ output,
14427
+ data.error ?? null,
14428
+ data.startedAt,
14429
+ data.finishedAt,
14430
+ data.requestedByUserId ?? null,
14431
+ data.createdBy ?? null,
14432
+ data.createdBy ?? null,
14433
+ data.apiEndpointId ?? null,
14434
+ // A run called through another script run's token (a nested
14435
+ // ctx.swarm.script_run) records that run and its workflow step.
14436
+ provenance?.sourceStepId ?? null,
14437
+ provenance?.sourceScriptRunId ?? null,
14438
+ ],
14439
+ );
14440
+ if (!row) throw new Error("Failed to record inline script run");
14441
+ return rowToScriptRun({ ...row, storedSource: data.source });
14442
+ });
14434
14443
  }
14435
14444
 
14436
14445
  export async function getScriptRun(id: string): Promise<ScriptRun | null> {
14437
- const row = await getDbClient().get<ScriptRunRow>("SELECT * FROM script_runs WHERE id = ?", [id]);
14446
+ const row = await getDbClient().get<ScriptRunRow>(`${SCRIPT_RUN_SELECT} WHERE r.id = ?`, [id]);
14438
14447
  return row ? rowToScriptRun(row) : null;
14439
14448
  }
14440
14449
 
@@ -14442,7 +14451,7 @@ export async function getScriptRunByIdempotencyKey(
14442
14451
  idempotencyKey: string,
14443
14452
  ): Promise<ScriptRun | null> {
14444
14453
  const row = await getDbClient().get<ScriptRunRow>(
14445
- "SELECT * FROM script_runs WHERE idempotencyKey = ?",
14454
+ `${SCRIPT_RUN_SELECT} WHERE r.idempotencyKey = ?`,
14446
14455
  [idempotencyKey],
14447
14456
  );
14448
14457
  return row ? rowToScriptRun(row) : null;
@@ -14639,7 +14648,7 @@ async function updateScriptRunGuarded(
14639
14648
 
14640
14649
  export async function getRunningScriptRuns(): Promise<ScriptRun[]> {
14641
14650
  const rows = await getDbClient().query<ScriptRunRow>(
14642
- "SELECT * FROM script_runs WHERE status IN ('running', 'paused')",
14651
+ `${SCRIPT_RUN_SELECT} WHERE r.status IN ('running', 'paused')`,
14643
14652
  );
14644
14653
  return rows.map(rowToScriptRun);
14645
14654
  }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * KV storage for the org design system (`src/themes/design-system.ts`). The
3
+ * `design-system` namespace is reserved, so these helpers are its only writer.
4
+ */
5
+
6
+ import {
7
+ DESIGN_SYSTEM_KEY,
8
+ DESIGN_SYSTEM_NAMESPACE,
9
+ DESIGN_SYSTEM_PREVIOUS_KEY,
10
+ readDesignSystem,
11
+ } from "../themes/design-system";
12
+ import type { DesignSystem } from "../types";
13
+ import { getDbClient, getKv, upsertKv } from "./db";
14
+
15
+ export type StoredDesignSystem =
16
+ | { status: "none" }
17
+ | { status: "invalid"; reason: string }
18
+ | { status: DesignSystem["status"]; record: DesignSystem };
19
+
20
+ function toStored(value: unknown): StoredDesignSystem {
21
+ const read = readDesignSystem(value);
22
+ if (!read) return { status: "none" };
23
+ if ("invalid" in read) return { status: "invalid", reason: read.invalid };
24
+ return { status: read.record.status, record: read.record };
25
+ }
26
+
27
+ export async function getDesignSystem(): Promise<{
28
+ current: StoredDesignSystem;
29
+ previous: StoredDesignSystem;
30
+ }> {
31
+ const [current, previous] = await Promise.all([
32
+ getKv(DESIGN_SYSTEM_NAMESPACE, DESIGN_SYSTEM_KEY),
33
+ getKv(DESIGN_SYSTEM_NAMESPACE, DESIGN_SYSTEM_PREVIOUS_KEY),
34
+ ]);
35
+ return { current: toStored(current?.value), previous: toStored(previous?.value) };
36
+ }
37
+
38
+ /** The record pages render with: an active, valid design system, else null. */
39
+ export async function getActiveDesignSystem(): Promise<DesignSystem | null> {
40
+ const stored = toStored((await getKv(DESIGN_SYSTEM_NAMESPACE, DESIGN_SYSTEM_KEY))?.value);
41
+ return "record" in stored && stored.record.status === "active" ? stored.record : null;
42
+ }
43
+
44
+ /** Saves `record` and moves the value it replaces to `org.prev`. */
45
+ export async function saveDesignSystem(record: DesignSystem): Promise<void> {
46
+ await getDbClient().transaction(async () => {
47
+ const current = await getKv(DESIGN_SYSTEM_NAMESPACE, DESIGN_SYSTEM_KEY);
48
+ if (current) {
49
+ await upsertKv({
50
+ namespace: DESIGN_SYSTEM_NAMESPACE,
51
+ key: DESIGN_SYSTEM_PREVIOUS_KEY,
52
+ value: current.value,
53
+ valueType: "json",
54
+ });
55
+ }
56
+ await upsertKv({
57
+ namespace: DESIGN_SYSTEM_NAMESPACE,
58
+ key: DESIGN_SYSTEM_KEY,
59
+ value: record,
60
+ valueType: "json",
61
+ });
62
+ });
63
+ }
@@ -0,0 +1,20 @@
1
+ -- Keep the legacy NOT NULL source column so this is an additive migration.
2
+ -- Boot moves existing source text into the content store in bounded batches.
3
+ CREATE TABLE script_run_sources (
4
+ hash TEXT PRIMARY KEY,
5
+ source TEXT NOT NULL
6
+ );
7
+
8
+ ALTER TABLE script_runs ADD COLUMN sourceHash TEXT REFERENCES script_run_sources(hash);
9
+
10
+ -- Includes NULLs for the resumable backfill, as well as FK and GC lookups.
11
+ CREATE INDEX idx_script_runs_sourceHash ON script_runs(sourceHash);
12
+
13
+ CREATE TRIGGER script_runs_delete_source
14
+ AFTER DELETE ON script_runs
15
+ WHEN OLD.sourceHash IS NOT NULL
16
+ BEGIN
17
+ DELETE FROM script_run_sources
18
+ WHERE hash = OLD.sourceHash
19
+ AND NOT EXISTS (SELECT 1 FROM script_runs WHERE sourceHash = OLD.sourceHash);
20
+ END;
@@ -2,6 +2,7 @@ import type { Database } from "bun:sqlite";
2
2
  import { createHash } from "node:crypto";
3
3
  import { readdirSync, readFileSync } from "node:fs";
4
4
  import { join } from "node:path";
5
+ import { backfillScriptRunSources } from "./script-run-sources";
5
6
 
6
7
  interface Migration {
7
8
  version: number;
@@ -198,6 +199,7 @@ export function runMigrations(db: Database): void {
198
199
  db,
199
200
  "no migrations directory could be located (see the preceding [migrations] warning)",
200
201
  );
202
+ backfillScriptRunSources(db);
201
203
  return;
202
204
  }
203
205
 
@@ -215,6 +217,7 @@ export function runMigrations(db: Database): void {
215
217
 
216
218
  if (migrations.length === 0) {
217
219
  assertNotEmptyDatabase(db, `no .sql migration files found in ${migrationsDir}`);
220
+ backfillScriptRunSources(db);
218
221
  return;
219
222
  }
220
223
 
@@ -311,4 +314,9 @@ export function runMigrations(db: Database): void {
311
314
  }
312
315
 
313
316
  db.run("PRAGMA foreign_keys = ON");
317
+
318
+ // Run outside the schema transactions so an interrupted boot keeps completed
319
+ // batches. Check the actual schema even when its SQL file is not packaged:
320
+ // an upgraded database can reuse it even with an incomplete migration bundle.
321
+ backfillScriptRunSources(db);
314
322
  }
@@ -0,0 +1,51 @@
1
+ import type { Database } from "bun:sqlite";
2
+ import { createHash } from "node:crypto";
3
+
4
+ const BATCH_SIZE = 25;
5
+
6
+ function hasScriptRunSourceSchema(db: Database): boolean {
7
+ const schema = db
8
+ .prepare<{ ready: number }, []>(`SELECT
9
+ EXISTS (SELECT 1 FROM pragma_table_info('script_runs') WHERE name = 'sourceHash')
10
+ AND (SELECT count(*) FROM pragma_table_info('script_run_sources')
11
+ WHERE name IN ('hash', 'source')) = 2 AS ready`)
12
+ .get();
13
+ return Boolean(schema?.ready);
14
+ }
15
+
16
+ /** The API must have the schema its run readers and writers use. */
17
+ export function assertScriptRunSourceSchema(db: Database): void {
18
+ if (!hasScriptRunSourceSchema(db)) {
19
+ throw new Error(
20
+ "[migrations] Required script-run source schema is missing. " +
21
+ "Ensure MIGRATIONS_DIR includes 342_script_run_sources.sql and run migrations before starting the API.",
22
+ );
23
+ }
24
+ }
25
+
26
+ /** Boot-only backfill: each committed batch can be safely skipped on restart. */
27
+ export function backfillScriptRunSources(db: Database): void {
28
+ // The generic migration runner also handles partial historical schemas.
29
+ if (!hasScriptRunSourceSchema(db)) return;
30
+ const pending = db.prepare<{ id: string; source: string }, []>(
31
+ `SELECT id, source FROM script_runs WHERE sourceHash IS NULL LIMIT ${BATCH_SIZE}`,
32
+ );
33
+ const insert = db.prepare(
34
+ "INSERT OR IGNORE INTO script_run_sources (hash, source) VALUES (?, ?)",
35
+ );
36
+ const update = db.prepare("UPDATE script_runs SET sourceHash = ?, source = '' WHERE id = ?");
37
+
38
+ const batch = db.transaction(() => {
39
+ const rows = pending.all();
40
+ for (const row of rows) {
41
+ const hash = createHash("sha256").update(row.source, "utf8").digest("hex");
42
+ insert.run(hash, row.source);
43
+ update.run(hash, row.id);
44
+ }
45
+ return rows.length;
46
+ });
47
+
48
+ while (batch.immediate() === BATCH_SIZE) {
49
+ // Release the write lock between batches; the NULL index is the watermark.
50
+ }
51
+ }
@@ -46,6 +46,7 @@ export const BUILTIN_ROLES = [
46
46
  "fs.join.own",
47
47
  "objects.read",
48
48
  "objects.write",
49
+ "page.launch",
49
50
  ],
50
51
  },
51
52
  {
@@ -61,6 +62,7 @@ export const BUILTIN_ROLES = [
61
62
  "comb.presence",
62
63
  "fs.join.own",
63
64
  "objects.read",
65
+ "page.launch",
64
66
  ],
65
67
  },
66
68
  {
@@ -418,7 +418,7 @@ export interface BoardsNamespace {
418
418
  export interface SwarmSdk {
419
419
  // --- memory ---
420
420
  memory_search(args: { query: string; intent: string; scope?: "all" | "agent" | "swarm"; limit?: number; source?: string; keyPrefix?: string }): Promise<unknown>;
421
- memory_get(args: { memoryId: string; intent: string }): Promise<unknown>;
421
+ memory_get(args: { memoryId?: string; id?: string; intent: string }): Promise<unknown>;
422
422
  memory_rate(args: { id: string; useful: boolean; note?: string }): Promise<unknown>;
423
423
  // --- tasks ---
424
424
  task_list(args?: Record<string, unknown>): Promise<unknown>;
@@ -579,7 +579,7 @@ export interface SwarmSdk {
579
579
  chat_reply(args: { text?: string; card?: unknown }): Promise<unknown>;
580
580
  chat_post(args: { adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat"; threadId?: string; channelId?: string; text?: string; card?: unknown }): Promise<unknown>;
581
581
  chat_openDm(args: { adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat"; userId: string }): Promise<unknown>;
582
- chat_registerChannel(args: { adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat"; channelId: string; agentId?: string; workflowId?: string; name?: string }): Promise<unknown>;
582
+ chat_registerChannel(args: { adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat"; channelId: string; agentId?: string; workflowId?: string; name?: string; defaultThreadId?: string }): Promise<unknown>;
583
583
  chat_unregisterChannel(args: { adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat"; channelId: string }): Promise<unknown>;
584
584
 
585
585
  // --- write: messaging (internal) ---
@@ -716,6 +716,8 @@ export interface SwarmSdk {
716
716
  }): Promise<unknown>;
717
717
  page_create(args: Record<string, unknown>): Promise<unknown>;
718
718
  page_delete(args: { pageId?: string; slug?: string }): Promise<unknown>;
719
+ designSystem_get(args?: Record<string, never>): Promise<unknown>;
720
+ designSystem_set(args: Record<string, unknown>): Promise<unknown>;
719
721
  metric_create(args: Record<string, unknown>): Promise<unknown>;
720
722
 
721
723
  // --- human input ---
@@ -0,0 +1,158 @@
1
+ import { z } from "zod";
2
+
3
+ export const argsSchema = z.object({
4
+ url: z.string().optional().describe("Site to read the brand from, for example https://www.agent-swarm.dev"),
5
+ css: z.string().optional().describe("A pasted CSS variable block (shadcn, tweakcn, Tailwind v4)"),
6
+ preset: z.string().optional().describe("A preset id, for example hive or paper"),
7
+ pdfUrl: z.string().optional().describe("A brand PDF. Not supported yet: extract its CSS and pass css"),
8
+ basePreset: z.string().optional().describe("Preset the extracted tokens apply on top of (default hive)"),
9
+ mode: z.enum(["viewer", "light", "dark"]).optional().describe("Mode lock (default viewer)"),
10
+ logo: z.object({ url: z.string(), alt: z.string() }).optional().describe("https logo URL and alt text"),
11
+ fontsHref: z.string().optional().describe("Google Fonts stylesheet URL; a url seed reads it from the site"),
12
+ chartPalette: z.array(z.string()).optional().describe("Ordered chart series colors"),
13
+ save: z.boolean().optional().describe("Save the design system after the preview. Only once the requester approved it"),
14
+ });
15
+
16
+ const LIGHT = new Set([":root", ":host", "html"]);
17
+ const DARK = new Set([".dark", ":root.dark", "html.dark", "[data-theme=dark]", '[data-theme="dark"]']);
18
+ /** The token contract names in their shadcn, bare and `--color-` spellings. Tailwind palette stops stay out. */
19
+ const CONTRACT_NAME =
20
+ /^--(?:color-)?(?:background|foreground|card|surface|popover|primary|secondary|muted|accent|destructive|border|input|ring|chart-\d|status-[a-z]+)(?:-(?:foreground|subtle|strong|solid))?$|^--font-(?:sans|mono)$|^--radius(?:-(?:sm|md|lg|xl))?$/;
21
+ const MAX_STYLESHEETS = 8;
22
+
23
+ function escapeHtml(value: string): string {
24
+ return value.replace(/[&<>"']/g, (c: string) => `&#${c.charCodeAt(0)};`);
25
+ }
26
+
27
+ /** The contract declarations of every light and dark theme block, as one clean CSS block per mode. */
28
+ function themeCss(css: string): string {
29
+ const light: string[] = [];
30
+ const dark: string[] = [];
31
+ for (const match of css.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
32
+ const parts = (match[1] ?? "").split(",").map((part: string) => part.trim());
33
+ const target = parts.every((p: string) => LIGHT.has(p)) ? light : parts.every((p: string) => DARK.has(p)) ? dark : null;
34
+ if (!target) continue;
35
+ for (const declaration of (match[2] ?? "").split(";")) {
36
+ const colon = declaration.indexOf(":");
37
+ const name = declaration.slice(0, colon).trim();
38
+ if (colon > 0 && CONTRACT_NAME.test(name)) target.push(`${name}: ${declaration.slice(colon + 1).trim()};`);
39
+ }
40
+ }
41
+ return [light.length ? `:root { ${light.join(" ")} }` : "", dark.length ? `.dark { ${dark.join(" ")} }` : ""]
42
+ .filter(Boolean)
43
+ .join("\n");
44
+ }
45
+
46
+ async function readSite(url: string, ctx: any): Promise<{ css: string; fontsHref?: string }> {
47
+ const html = await (await ctx.stdlib.fetch(url, { headers: { Accept: "text/html" } })).text();
48
+ const hrefs: string[] = [];
49
+ let fontsHref: string | undefined;
50
+ for (const tag of html.match(/<link\b[^>]*>/gi) ?? []) {
51
+ const href = tag.match(/href=["']([^"']+)["']/i)?.[1]?.replace(/&amp;/g, "&");
52
+ if (!href || !/rel=["']?stylesheet/i.test(tag)) continue;
53
+ if (href.startsWith("https://fonts.googleapis.com/")) fontsHref ??= href;
54
+ else hrefs.push(new URL(href, url).href);
55
+ }
56
+ const sheets = await Promise.all(
57
+ hrefs.slice(0, MAX_STYLESHEETS).map(async (href) => (await ctx.stdlib.fetch(href)).text()),
58
+ );
59
+ const inline = (html.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi) ?? []).map((s: string) => s.replace(/<\/?style\b[^>]*>/gi, ""));
60
+ return { css: themeCss([...inline, ...sheets].join("\n")), fontsHref };
61
+ }
62
+
63
+ function previewHtml(record: any, ignored: string[]): string {
64
+ const names = [...new Set([...Object.keys(record.tokens.light), ...Object.keys(record.tokens.dark)])].sort();
65
+ const rows = names
66
+ .map((name) => {
67
+ const light = record.tokens.light[name] ?? "";
68
+ const dark = record.tokens.dark[name] ?? "";
69
+ const swatch = name.startsWith("--color-") ? `<span class="swarm-badge" data-dot style="--swarm-dot: var(${name})">${escapeHtml(name)}</span>` : escapeHtml(name);
70
+ return `<tr><td class="nowrap">${swatch}</td><td>${escapeHtml(light)}</td><td>${escapeHtml(dark)}</td></tr>`;
71
+ })
72
+ .join("");
73
+ const palette = (record.chartPalette ?? [])
74
+ .map((color: string) => `<span class="swarm-badge" data-dot style="--swarm-dot: ${escapeHtml(color)}">${escapeHtml(color)}</span>`)
75
+ .join(" ");
76
+ return `<!doctype html><html><head><meta charset="utf-8"><title>Design system preview</title>
77
+ ${record.fontsHref ? `<link href="${escapeHtml(record.fontsHref)}" rel="stylesheet">` : ""}</head>
78
+ <body><main class="swarm-page">
79
+ ${record.logo ? `<img src="${escapeHtml(record.logo.url)}" alt="${escapeHtml(record.logo.alt)}" style="height:40px;width:auto">` : ""}
80
+ <p class="swarm-eyebrow">Design system preview · ${escapeHtml(record.source.kind)}${record.source.ref ? ` · ${escapeHtml(record.source.ref)}` : ""}</p>
81
+ <h1>Every page will look like this</h1>
82
+ <p class="swarm-lede">Base preset ${escapeHtml(record.basePreset)}, mode ${escapeHtml(record.mode)}. Nothing is saved until the requester approves it.</p>
83
+ <div class="swarm-metrics">
84
+ <div class="swarm-metric"><div class="swarm-metric-value">${names.length}</div><div class="swarm-metric-label">Tokens set</div></div>
85
+ <div class="swarm-metric" data-tone="success"><div class="swarm-metric-value">98.2%</div><div class="swarm-metric-label">Sample success rate</div></div>
86
+ <div class="swarm-metric" data-tone="error"><div class="swarm-metric-value">3</div><div class="swarm-metric-label">Sample failures</div></div>
87
+ </div>
88
+ <section class="swarm-section"><h2>Components</h2>
89
+ <p><button class="swarm-button" data-variant="primary" type="button">Primary action</button> <button class="swarm-button" type="button">Secondary</button></p>
90
+ <p><span class="swarm-badge" data-tone="success" data-dot>Healthy</span> <span class="swarm-badge" data-tone="warning" data-dot>Degraded</span> <span class="swarm-badge" data-tone="error" data-dot>Down</span></p>
91
+ <div class="swarm-callout">A callout reads like this. <a href="#tokens">Links use the primary color.</a></div>
92
+ ${palette ? `<p>Chart palette: ${palette}</p>` : ""}
93
+ </section>
94
+ <section class="swarm-section" id="tokens"><h2>Tokens</h2>
95
+ <div class="swarm-table-wrap"><table class="swarm-table"><thead><tr><th>Token</th><th>Light</th><th>Dark</th></tr></thead><tbody>${rows || '<tr><td colspan="3">The base preset only.</td></tr>'}</tbody></table></div>
96
+ ${ignored.length ? `<details><summary>${ignored.length} ignored names</summary><p>${escapeHtml(ignored.join(", "))}</p></details>` : ""}
97
+ </section></main></body></html>`;
98
+ }
99
+
100
+ /** Build an org design system from a site URL, a CSS block or a preset, publish a preview page, and save it once approved. */
101
+ export default async function designSystemSeed(args: any, ctx: any) {
102
+ const parsed = argsSchema.safeParse(args ?? {});
103
+ if (!parsed.success) return { error: "invalid args: " + parsed.error.message };
104
+ const a = parsed.data;
105
+ const inputs = [a.url, a.css, a.preset, a.pdfUrl].filter((value) => value !== undefined);
106
+ if (inputs.length !== 1) return { error: "pass exactly one of url, css, preset or pdfUrl" };
107
+ // shortcut: no brand-PDF extraction (taste-engine extract_brand_kit is not wired), add it when a requester sends a PDF.
108
+ if (a.pdfUrl) return { error: "brand PDFs are not supported yet: extract the CSS variables and pass css" };
109
+
110
+ let css = a.css;
111
+ let fontsHref = a.fontsHref;
112
+ let source: any = { kind: "manual" };
113
+ if (a.url) {
114
+ if (!/^https?:\/\//i.test(a.url)) return { error: "url must be an absolute http(s) URL" };
115
+ const site = await readSite(a.url, ctx);
116
+ if (!site.css) return { error: `no :root or .dark custom properties found on ${a.url}` };
117
+ css = site.css;
118
+ fontsHref ??= site.fontsHref;
119
+ source = { kind: "website", ref: a.url, extractedAt: new Date().toISOString() };
120
+ }
121
+ if (a.preset) source = { kind: "preset", ref: a.preset };
122
+
123
+ const input = {
124
+ basePreset: a.preset ?? a.basePreset,
125
+ ...(css ? { themeTokens: { format: "css", css } } : {}),
126
+ ...(fontsHref ? { fontsHref } : {}),
127
+ ...(a.logo ? { logo: a.logo } : {}),
128
+ ...(a.mode ? { mode: a.mode } : {}),
129
+ ...(a.chartPalette ? { chartPalette: a.chartPalette } : {}),
130
+ source,
131
+ };
132
+ const checked: any = await ctx.swarm.designSystem_set({ ...input, dryRun: true });
133
+ const draft = checked?.data ?? checked;
134
+ if (draft?.success === false || !draft?.designSystem) return { error: draft?.message ?? "design system validation failed" };
135
+ const record = draft.designSystem;
136
+ const ignored: string[] = draft.ignoredTokens ?? [];
137
+
138
+ const page: any = await ctx.swarm.page_create({
139
+ title: "Design system preview",
140
+ slug: "design-system-preview",
141
+ contentType: "text/html",
142
+ body: previewHtml(record, ignored),
143
+ theme: record.basePreset,
144
+ themeTokens: { light: record.tokens.light, dark: record.tokens.dark },
145
+ designVersion: 2,
146
+ });
147
+ const pageData = page?.data ?? page;
148
+ if (a.save) await ctx.swarm.designSystem_set(input);
149
+ return {
150
+ saved: a.save === true,
151
+ previewUrl: pageData?.app_url ?? null,
152
+ previewApiUrl: pageData?.api_url ?? null,
153
+ designSystem: record,
154
+ ignoredTokens: ignored,
155
+ // Pass this to design-system-set (or rerun with save: true) once the requester approves.
156
+ saveInput: input,
157
+ };
158
+ }
@@ -30,6 +30,7 @@ import completeTaskSrc from "./catalog/complete-task.ts" with { type: "text" };
30
30
  import compoundInsightsSrc from "./catalog/compound-insights.inline.ts" with { type: "text" };
31
31
  import dateResolveSrc from "./catalog/date-resolve.ts" with { type: "text" };
32
32
  import delegateSrc from "./catalog/delegate.ts" with { type: "text" };
33
+ import designSystemSeedSrc from "./catalog/design-system-seed.ts" with { type: "text" };
33
34
  import dreamingApplySrc from "./catalog/dreaming-apply.ts" with { type: "text" };
34
35
  import dreamingGatherSrc from "./catalog/dreaming-gather.ts" with { type: "text" };
35
36
  import dreamingHeartbeatSrc from "./catalog/dreaming-heartbeat.ts" with { type: "text" };
@@ -142,6 +143,14 @@ export const SEED_SCRIPTS: SeedScript[] = [
142
143
  "Read the actual content of a URL without wading through raw HTML; readable-article / reader-mode extraction.",
143
144
  source: asText(fetchReadableSrc),
144
145
  },
146
+ {
147
+ name: "design-system-seed",
148
+ description:
149
+ "Build the org design system from a site URL, a pasted CSS variable block or a preset, publish a preview page in the swarm look, and save it with save: true once the requester approves.",
150
+ intent:
151
+ "Seed or rebrand the org design system / page theme / brand colors and fonts from a website or shadcn CSS, with a preview before saving.",
152
+ source: asText(designSystemSeedSrc),
153
+ },
145
154
  {
146
155
  name: "json-query",
147
156
  description:
@@ -214,6 +214,18 @@ export const APPS_JSON_COLUMN_MAX_BYTES_BOUNDS = { min: 1_024, max: 16_777_216 }
214
214
  */
215
215
  export const CODEX_OAUTH_KEEP_WARM_MAX_AGE_HOURS_BOUNDS = { min: 1, max: 216 } as const;
216
216
 
217
+ /**
218
+ * Bounds for the scheduler polling interval (`SCHEDULER_INTERVAL_MS`).
219
+ *
220
+ * `src/scheduler/scheduler.ts` parses the boot value against exactly these
221
+ * bounds at call time and falls back to its 10-second default outside them, and
222
+ * VALIDATED_KEYS rejects out-of-range writes with the same numbers, so the config
223
+ * API cannot accept a tick the scheduler would silently replace. The 2^31-1 ms
224
+ * ceiling is the largest delay a 32-bit timer honours: `setInterval` clamps a
225
+ * larger one to 1 ms, the tight loop a non-positive delay already causes (#3169).
226
+ */
227
+ export const SCHEDULER_INTERVAL_MS_BOUNDS = { min: 1, max: 2_147_483_647 } as const;
228
+
217
229
  /**
218
230
  * Decision hosts `SYSTEM_ONE_DEFAULT_PROVIDER` may name: `SYSTEM_ONE_PROVIDER_IDS`
219
231
  * in `src/workflows/executors/system-one-providers.ts`, listed here because that
@@ -694,7 +706,6 @@ const VALIDATED_KEYS: Record<string, ConfigValidator> = {
694
706
  "RBAC_AUDIT_RETENTION_DAYS",
695
707
  "WORKFLOW_MAX_ITERATIONS",
696
708
  "WORKFLOW_MAX_STEPS_PER_RUN",
697
- "SCHEDULER_INTERVAL_MS",
698
709
  "EXTENSION_HANDLER_TIMEOUT_MS",
699
710
  "EXTENSION_MAX_CONSECUTIVE_FAILURES",
700
711
  "RUNTIME_STALE_THRESHOLD_MIN",
@@ -724,6 +735,15 @@ const VALIDATED_KEYS: Record<string, ConfigValidator> = {
724
735
  APPS_JSON_COLUMN_MAX_BYTES_BOUNDS.min,
725
736
  APPS_JSON_COLUMN_MAX_BYTES_BOUNDS.max,
726
737
  ),
738
+ // The scheduler tick is bounded at both ends, and src/scheduler/scheduler.ts
739
+ // parses the boot value against the same range: a delay above the timer ceiling
740
+ // fires after 1 ms, so accepting it would leave the scheduler polling at full
741
+ // speed while the saved value claimed otherwise.
742
+ ...boundedIntegerValidators(
743
+ ["SCHEDULER_INTERVAL_MS"],
744
+ SCHEDULER_INTERVAL_MS_BOUNDS.min,
745
+ SCHEDULER_INTERVAL_MS_BOUNDS.max,
746
+ ),
727
747
  // Worker worktree reaper (src/commands/worktree-reaper.ts clamps to the same ranges).
728
748
  ...enumValidator("WORKTREE_REAPER_MODE", ["off", "dry-run", "on"]),
729
749
  ...boundedIntegerValidators(["WORKTREE_TTL_HOURS"], 1, 2160),
@@ -2,4 +2,4 @@
2
2
  * agent-fs image tag bundled by `agent-swarm onboard --yes`.
3
3
  * `bun run bump:agent-fs` rewrites it together with the other pins.
4
4
  */
5
- export const AGENT_FS_VERSION = "0.18.29";
5
+ export const AGENT_FS_VERSION = "0.18.32";