@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
@@ -84,6 +84,7 @@ import {
84
84
  humanOnlyConfigKeyError,
85
85
  isReservedConfigKey,
86
86
  reservedKeyError,
87
+ SCHEDULER_INTERVAL_MS_BOUNDS,
87
88
  validateConfigValue,
88
89
  validateExportToEnv,
89
90
  init_swarm_config_guard,
@@ -406,27 +407,27 @@ import {
406
407
  recordInlineScriptRun2,
407
408
  exports_db,
408
409
  init_db4
409
- } from "./cli-erh1rgh4.js";
410
+ } from "./cli-ts5yv7dn.js";
410
411
  import {
411
412
  assertMayActOnOperatorGrantedTarget2,
412
413
  getUserGrant2,
413
414
  init_rbac_roles
414
- } from "./cli-n14r8h4n.js";
415
+ } from "./cli-x2cem5vy.js";
415
416
  import {
416
417
  ensurePricingSeeded2,
417
418
  ensureRbacSeeded2,
418
419
  ensureModelProfilesSeeded2,
419
420
  init_boot_seeds
420
- } from "./cli-8qvte9hn.js";
421
+ } from "./cli-4fpa0zns.js";
421
422
  import {
422
423
  requestModelCatalogRefresh2,
423
424
  startPricingRefreshLoop2,
424
425
  init_pricing_refresh
425
- } from "./cli-m1wddksc.js";
426
+ } from "./cli-93n305hm.js";
426
427
  import {
427
428
  workflowEventBus2,
428
429
  init_event_bus
429
- } from "./cli-vx9acp12.js";
430
+ } from "./cli-ybte1fqc.js";
430
431
  import {
431
432
  slackCode,
432
433
  slackMissingScopeMessage,
@@ -435,7 +436,7 @@ import {
435
436
  externalChannelToolError2,
436
437
  getChannelBlockReason2,
437
438
  init_external_channel
438
- } from "./cli-ka13xx6b.js";
439
+ } from "./cli-7gbff32z.js";
439
440
  import {
440
441
  tableToAscii2,
441
442
  init_dist8
@@ -498,7 +499,7 @@ import {
498
499
  startSlackApp2,
499
500
  stopSlackAppUnderLifecycleLock2,
500
501
  init_app4
501
- } from "./cli-69eq6gdk.js";
502
+ } from "./cli-rmgvwcmy.js";
502
503
  import {
503
504
  AGENT_MAX_TASKS_CONFIG_KEY,
504
505
  resetAgentMaxTasksMirror,
@@ -519,7 +520,7 @@ import {
519
520
  postApprovalCancellationUpdates2,
520
521
  createApprovalFollowUpTask2,
521
522
  init_approval_notifications
522
- } from "./cli-f1sdh8ca.js";
523
+ } from "./cli-d5pc8ep0.js";
523
524
  import {
524
525
  shapeApprovalResolution,
525
526
  init_approval_resolution,
@@ -543,7 +544,7 @@ import {
543
544
  resumeFromChildRun2,
544
545
  initWaitBusSubscriptions2,
545
546
  init_resume
546
- } from "./cli-fcwrd7bh.js";
547
+ } from "./cli-9ah37a8a.js";
547
548
  import {
548
549
  getFileStorageProvider2,
549
550
  init_registry2
@@ -551,7 +552,7 @@ import {
551
552
  import {
552
553
  getRuntimePool2,
553
554
  init_db2
554
- } from "./cli-tceqvv6h.js";
555
+ } from "./cli-29h5239w.js";
555
556
  import {
556
557
  duplicateGuardedQueryKey,
557
558
  parseQueryParams,
@@ -584,13 +585,13 @@ import {
584
585
  findRoute,
585
586
  route,
586
587
  init_route_def
587
- } from "./cli-2wde56gv.js";
588
+ } from "./cli-404am6f3.js";
588
589
  import {
589
590
  COMPOSIO_HTTP_METHODS,
590
591
  executeComposioRequest,
591
592
  composioArgsFromParts,
592
593
  init_composio
593
- } from "./cli-3mf04tkh.js";
594
+ } from "./cli-4vynxtrb.js";
594
595
  import {
595
596
  object,
596
597
  init_v4_mini
@@ -686,7 +687,7 @@ import {
686
687
  init_typecheck,
687
688
  parseSkillContent,
688
689
  init_skill_parser
689
- } from "./cli-nkfv398a.js";
690
+ } from "./cli-gse7bp3z.js";
690
691
  import {
691
692
  detachedProcessGroup,
692
693
  registerProcessGroup,
@@ -701,7 +702,7 @@ import {
701
702
  ensureToken,
702
703
  ensureTokenOrThrow,
703
704
  init_ensure_token
704
- } from "./cli-xerdrnqs.js";
705
+ } from "./cli-jyhbvdga.js";
705
706
  import {
706
707
  A1Error,
707
708
  colName,
@@ -736,11 +737,11 @@ import {
736
737
  listObjects,
737
738
  reindexObjects,
738
739
  init_objects
739
- } from "./cli-wdtqkqnq.js";
740
+ } from "./cli-tr19nyn9.js";
740
741
  import {
741
742
  agentFsClientFor,
742
743
  init_agent_fs_identity
743
- } from "./cli-j2ybkdk2.js";
744
+ } from "./cli-zhwjdhjr.js";
744
745
  import {
745
746
  FilesError,
746
747
  providerPath,
@@ -754,7 +755,7 @@ import {
754
755
  isSlackLeaveThreadDisabled,
755
756
  leaveSlackThread,
756
757
  init_left_threads
757
- } from "./cli-4djg31jh.js";
758
+ } from "./cli-gtj12v95.js";
758
759
  import {
759
760
  require_fast_deep_equal
760
761
  } from "./cli-bhp11egn.js";
@@ -839,7 +840,7 @@ import {
839
840
  validateDefinition,
840
841
  applyDefinitionPatch,
841
842
  init_definition2
842
- } from "./cli-jkkcm72j.js";
843
+ } from "./cli-0p76my9q.js";
843
844
  import {
844
845
  isMultiRuntimeEnabled,
845
846
  init_multi_runtime2
@@ -862,16 +863,16 @@ import {
862
863
  import {
863
864
  canProvisionKind,
864
865
  init_runtime_providers
865
- } from "./cli-43dsqhcp.js";
866
+ } from "./cli-jbrc98qb.js";
866
867
  import {
867
868
  getSessionRoot,
868
869
  sessionAccessForRoot,
869
870
  init_session_shares
870
- } from "./cli-b0kqw55g.js";
871
+ } from "./cli-pz1dp12c.js";
871
872
  import {
872
873
  publicEndpointSsrfOptions,
873
874
  init_mcp_wrapper
874
- } from "./cli-xysy1g8x.js";
875
+ } from "./cli-ysv0k1we.js";
875
876
  import {
876
877
  findUserById,
877
878
  findUserByExternalId,
@@ -886,13 +887,13 @@ import {
886
887
  resolveSessionToken,
887
888
  fingerprintApiKey,
888
889
  init_users
889
- } from "./cli-getrvmtx.js";
890
+ } from "./cli-kj84fqxz.js";
890
891
  import {
891
892
  AMP_ESTIMATE_MODELS,
892
893
  ampBillsCacheWrites,
893
894
  resolveAmpModel,
894
895
  init_amp_models
895
- } from "./cli-rfejbpe1.js";
896
+ } from "./cli-akm6y2a8.js";
896
897
  import {
897
898
  resolveGitHubHost,
898
899
  getGitHubLinkConfig,
@@ -910,12 +911,12 @@ import {
910
911
  init_task_attachment_links,
911
912
  contentSha256,
912
913
  init_profile_sync
913
- } from "./cli-s6fhqbz1.js";
914
+ } from "./cli-ka48vpev.js";
914
915
  import {
915
916
  getSlackConfiguration,
916
917
  isSlackConfigured,
917
- init_config4
918
- } from "./cli-eetzmsy5.js";
918
+ init_config5
919
+ } from "./cli-t9pzz2eq.js";
919
920
  import {
920
921
  isSteeringEnabled2,
921
922
  init_steering_enabled
@@ -928,7 +929,7 @@ import {
928
929
  splitCredentialPool,
929
930
  selectCredential,
930
931
  init_credentials2
931
- } from "./cli-5basv0e7.js";
932
+ } from "./cli-gkv0r2hq.js";
932
933
  import {
933
934
  findInterpolationTokens,
934
935
  interpolate,
@@ -938,7 +939,7 @@ import {
938
939
  init_registry3,
939
940
  resolveTemplate,
940
941
  init_resolver
941
- } from "./cli-mwxez0pz.js";
942
+ } from "./cli-b768ek79.js";
942
943
  import {
943
944
  normalizeAssetKey,
944
945
  defaultAssetKey,
@@ -1000,6 +1001,8 @@ import {
1000
1001
  PageContentTypeSchema,
1001
1002
  PageAuthModeSchema,
1002
1003
  PageThemeTokensInputSchema,
1004
+ DesignSystemSchema,
1005
+ DesignSystemInputSchema,
1003
1006
  MetricDefinitionSchema,
1004
1007
  WorkflowRunStatusSchema,
1005
1008
  ScriptRunStatusSchema,
@@ -1013,7 +1016,7 @@ import {
1013
1016
  KvNamespaceSchema,
1014
1017
  KvKeySchema,
1015
1018
  init_types5
1016
- } from "./cli-f8rcvf2x.js";
1019
+ } from "./cli-azj9t1f9.js";
1017
1020
  import {
1018
1021
  init_zod
1019
1022
  } from "./cli-96234j5w.js";
@@ -1067,7 +1070,7 @@ import {
1067
1070
  import {
1068
1071
  init_package,
1069
1072
  package_default
1070
- } from "./cli-sjk85d7v.js";
1073
+ } from "./cli-cq4am6vg.js";
1071
1074
  import {
1072
1075
  getNodeEnv,
1073
1076
  isDevOrTestNodeEnv,
@@ -1087,7 +1090,7 @@ import {
1087
1090
  registerVolatileSecret,
1088
1091
  registerSensitiveKeyName,
1089
1092
  init_secret_scrubber
1090
- } from "./cli-fp65jdp2.js";
1093
+ } from "./cli-1kvcsd2f.js";
1091
1094
  import {
1092
1095
  __toESM,
1093
1096
  __commonJS,
@@ -20469,7 +20472,7 @@ function startRetryPoller(registry, intervalMs = 5000) {
20469
20472
  if (!waiting)
20470
20473
  continue;
20471
20474
  if (result.waitFor === "workflow.child.finished") {
20472
- const { resumeFromChildRun } = await import("./resume-vcag4ann.js");
20475
+ const { resumeFromChildRun } = await import("./resume-wz546x47.js");
20473
20476
  await resumeFromChildRun(step.id, registry);
20474
20477
  }
20475
20478
  } else {
@@ -21088,6 +21091,13 @@ var init_wait_poller = __esm(() => {
21088
21091
  });
21089
21092
 
21090
21093
  // src/workflows/executors/agent-task.ts
21094
+ function crashAfterTaskInsertForTest(description) {
21095
+ if (getNodeEnv() !== "test")
21096
+ return;
21097
+ const marker = process.env.E2E_CRASH_AFTER_WORKFLOW_TASK_INSERT;
21098
+ if (marker && description.includes(marker))
21099
+ process.kill(process.pid, "SIGKILL");
21100
+ }
21091
21101
  var AgentTaskConfigSchema, AgentTaskOutputSchema, AgentTaskExecutor;
21092
21102
  var init_agent_task = __esm(() => {
21093
21103
  init_zod();
@@ -21097,6 +21107,7 @@ var init_agent_task = __esm(() => {
21097
21107
  init_context_key();
21098
21108
  init_errors2();
21099
21109
  init_types5();
21110
+ init_node_env();
21100
21111
  init_base();
21101
21112
  AgentTaskConfigSchema = object2({
21102
21113
  template: string2(),
@@ -21215,6 +21226,7 @@ var init_agent_task = __esm(() => {
21215
21226
  throw error;
21216
21227
  return { status: "failed", error: `Unknown model profile "${config.profile}".` };
21217
21228
  }
21229
+ crashAfterTaskInsertForTest(preCreate.description);
21218
21230
  return {
21219
21231
  status: "success",
21220
21232
  async: true,
@@ -21305,7 +21317,7 @@ async function waitForSlackApp(getApp, signal) {
21305
21317
  var slackReadyWait, NotifyConfigSchema, NotifyOutputSchema, NotifyExecutor;
21306
21318
  var init_notify = __esm(() => {
21307
21319
  init_zod();
21308
- init_config4();
21320
+ init_config5();
21309
21321
  init_secret_scrubber();
21310
21322
  init_base();
21311
21323
  slackReadyWait = { timeoutMs: 25000, pollMs: 250 };
@@ -21348,7 +21360,7 @@ var init_notify = __esm(() => {
21348
21360
  }
21349
21361
  }
21350
21362
  case "slack": {
21351
- const { getSlackApp } = await import("./app-535m78qw.js");
21363
+ const { getSlackApp } = await import("./app-tmwa442h.js");
21352
21364
  let app = getSlackApp();
21353
21365
  if (!app) {
21354
21366
  if (!isSlackConfigured()) {
@@ -23041,7 +23053,12 @@ async function executeSchedule(schedule, extraTags = []) {
23041
23053
  });
23042
23054
  }
23043
23055
  }
23044
- function startScheduler2(registry, intervalMs = 1e4, opts) {
23056
+ function parseSchedulerIntervalMs2(raw) {
23057
+ const value = Number(raw);
23058
+ const { min, max } = SCHEDULER_INTERVAL_MS_BOUNDS;
23059
+ return Number.isInteger(value) && value >= min && value <= max ? value : DEFAULT_SCHEDULER_INTERVAL_MS;
23060
+ }
23061
+ function startScheduler2(registry, intervalMs = DEFAULT_SCHEDULER_INTERVAL_MS, opts) {
23045
23062
  if (schedulerRun) {
23046
23063
  console.log("[Scheduler] Already running");
23047
23064
  return;
@@ -23138,7 +23155,7 @@ async function runScheduleNow2(scheduleId) {
23138
23155
  console.log(`[Scheduler] Manually executed schedule "${schedule.name}"`);
23139
23156
  }
23140
23157
  }
23141
- var import_cron_parser, schedulerInterval = null, schedulerRun = null, isProcessing = false, lastDeferredReapAt = 0, DEFERRED_REAP_INTERVAL_MS, executorRegistry = null, AutomationNeedsSetupError, ERROR_BACKOFF_MS, MAX_CONSECUTIVE_ERRORS = 5;
23158
+ var import_cron_parser, schedulerInterval = null, schedulerRun = null, isProcessing = false, lastDeferredReapAt = 0, DEFERRED_REAP_INTERVAL_MS, executorRegistry = null, AutomationNeedsSetupError, ERROR_BACKOFF_MS, MAX_CONSECUTIVE_ERRORS = 5, DEFAULT_SCHEDULER_INTERVAL_MS = 1e4;
23142
23159
  var init_scheduler = __esm(() => {
23143
23160
  init_automation_preflight_alert();
23144
23161
  init_automation_preflight();
@@ -23148,6 +23165,7 @@ var init_scheduler = __esm(() => {
23148
23165
  init_db3();
23149
23166
  init_run_credential();
23150
23167
  init_workflows_seeder();
23168
+ init_swarm_config_guard();
23151
23169
  init_telemetry();
23152
23170
  init_workflows();
23153
23171
  init_engine();
@@ -24319,6 +24337,8 @@ var init_sdk_allowlist = __esm(() => {
24319
24337
  app_upsert: "app-upsert",
24320
24338
  page_create: "create_page",
24321
24339
  page_delete: "delete-page",
24340
+ designSystem_get: "design-system-get",
24341
+ designSystem_set: "design-system-set",
24322
24342
  metric_create: "create_metric",
24323
24343
  request_humanInput: "request-human-input",
24324
24344
  approval_cancel: "cancel-approval-request",
@@ -24985,7 +25005,7 @@ function setPreloadedTools(server, names) {
24985
25005
  async function applyPreToolCall(name, args, requestInfo, inputSchema) {
24986
25006
  if (requestInfo.callOrigin !== "mcp")
24987
25007
  return { args };
24988
- const dispatcher = await import("./dispatcher-fr4vawwb.js");
25008
+ const dispatcher = await import("./dispatcher-64rp6w67.js");
24989
25009
  const result = await dispatcher.dispatchPre("pre.tool.call", { tool: name, args, requestInfo }, inputSchema ? {
24990
25010
  validateModify: async (data) => {
24991
25011
  const schema = normalizeObjectSchema(inputSchema) ?? inputSchema;
@@ -25020,6 +25040,18 @@ async function applyPreToolCall(name, args, requestInfo, inputSchema) {
25020
25040
  dispatcher
25021
25041
  };
25022
25042
  }
25043
+ async function refuseWriteForTerminalTask(name, annotations, requestInfo) {
25044
+ if (requestInfo.callOrigin !== "mcp" || !requestInfo.sourceTaskId)
25045
+ return;
25046
+ if (annotations?.readOnlyHint === true || TERMINAL_TASK_EXEMPT_TOOLS.has(name))
25047
+ return;
25048
+ const row = await getDbClient2().get("SELECT status FROM agent_tasks WHERE id = ?", [requestInfo.sourceTaskId]);
25049
+ if (!row || !isTerminalTaskStatus(row.status))
25050
+ return;
25051
+ return toolErr(`Task ${requestInfo.sourceTaskId} is ${row.status}, so this session can no longer call ${name}. Stop working on it.`, {
25052
+ details: "Only store-progress and read-only tools still work for a finished task. Any new work belongs to a new task."
25053
+ });
25054
+ }
25023
25055
  function dispatchPostToolCall(dispatcher, name, args, outcome, requestInfo, durationMs) {
25024
25056
  if (!dispatcher)
25025
25057
  return;
@@ -25108,6 +25140,7 @@ var scriptSdkRequestOrigins, extensionRequestOrigins, getRequestInfo = (req) =>
25108
25140
  const data = r.data;
25109
25141
  const count = data?.colorLiteralCount;
25110
25142
  const sentences = [
25143
+ data?.designSystemStatus === "none" ? "This org has no design system yet, so the page uses the default look. Ask the requester once for a site URL, a preset or a CSS block, build a preview with the design-system-seed script, and save it with design-system-set after they approve; if they say no, call design-system-set with status declined so nobody asks again." : undefined,
25111
25144
  data?.designVersion === 1 && data.usesDesignSystem === true ? "This page is on designVersion 1 (the original look), so design system classes, tokens and themes have no effect. Pass designVersion: 2." : undefined,
25112
25145
  data?.lightOnlyColors === true ? "Your themeTokens set colors for light mode only. Dark mode keeps the preset's dark colors; add a dark map (or a .dark block) to restyle it too." : undefined,
25113
25146
  typeof count === "number" && count >= COLOR_LITERAL_THRESHOLD ? `This page hardcodes ${count} color values. Use theme tokens (var(--color-primary), bg-primary, text-muted-foreground) so theme and dark-mode switches restyle it. Until then the page stays light in a dark dashboard.` : undefined
@@ -25179,7 +25212,7 @@ var scriptSdkRequestOrigins, extensionRequestOrigins, getRequestInfo = (req) =>
25179
25212
  return spilled("Payload omitted.");
25180
25213
  return fillPreviewToBudget(json, (preview) => spilled(`JSON payload head:
25181
25214
  ${preview}`));
25182
- }, FINALIZE_PIPELINE, preloadedToolsByServer, createToolRegistrar = (server) => {
25215
+ }, FINALIZE_PIPELINE, preloadedToolsByServer, TERMINAL_TASK_EXEMPT_TOOLS, createToolRegistrar = (server) => {
25183
25216
  return (name, config, cb) => {
25184
25217
  const toolConfig = preloadedToolsByServer.get(server)?.has(name) ? { ...config, _meta: { ...config._meta, "anthropic/alwaysLoad": true } } : config;
25185
25218
  if (config.inputSchema === undefined) {
@@ -25188,7 +25221,7 @@ ${preview}`));
25188
25221
  return withSpan2("mcp.tool", async (span) => {
25189
25222
  const pre = await applyPreToolCall(name, {}, requestInfo);
25190
25223
  let durationMs = 0;
25191
- let outcome = pre.blocked;
25224
+ let outcome = pre.blocked ?? await refuseWriteForTerminalTask(name, config.annotations, requestInfo);
25192
25225
  if (!outcome) {
25193
25226
  const startedAt = Date.now();
25194
25227
  try {
@@ -25211,7 +25244,7 @@ ${preview}`));
25211
25244
  const pre = await applyPreToolCall(name, args, requestInfo, config.inputSchema);
25212
25245
  const effectiveArgs = pre.args;
25213
25246
  let durationMs = 0;
25214
- let outcome = pre.blocked;
25247
+ let outcome = pre.blocked ?? await refuseWriteForTerminalTask(name, config.annotations, requestInfo);
25215
25248
  if (!outcome) {
25216
25249
  const startedAt = Date.now();
25217
25250
  try {
@@ -25332,6 +25365,7 @@ var init_utils = __esm(() => {
25332
25365
  ctxControlMiddleware
25333
25366
  ];
25334
25367
  preloadedToolsByServer = new WeakMap;
25368
+ TERMINAL_TASK_EXEMPT_TOOLS = new Set(["store-progress"]);
25335
25369
  });
25336
25370
 
25337
25371
  // src/http/mcp-bridge.ts
@@ -25745,9 +25779,13 @@ function bridgeRequestFor(name, args) {
25745
25779
  case "memory_search":
25746
25780
  return { method: "POST", path: "/api/memory/search", body };
25747
25781
  case "memory_get": {
25748
- const memoryId = typeof body.memoryId === "string" ? body.memoryId : undefined;
25749
- if (!memoryId)
25750
- throw new Error("memory_get requires string `memoryId`");
25782
+ if (body.memoryId && body.id && body.memoryId !== body.id) {
25783
+ throw new Error("memoryId and id must identify the same memory; supply only one.");
25784
+ }
25785
+ const memoryId = body.memoryId ?? body.id;
25786
+ if (typeof memoryId !== "string" || !memoryId) {
25787
+ throw new Error("Supply memoryId (or its alias id) from memory-search.");
25788
+ }
25751
25789
  const getIntent = typeof body.intent === "string" ? body.intent : "script-sdk";
25752
25790
  return {
25753
25791
  method: "GET",
@@ -25780,28 +25818,6 @@ function bridgeRequestFor(name, args) {
25780
25818
  throw new Error("task_get requires string `taskId`");
25781
25819
  return { method: "GET", path: `/api/tasks/${encodeURIComponent(taskId)}` };
25782
25820
  }
25783
- case "task_storeProgress": {
25784
- const taskId = typeof body.taskId === "string" ? body.taskId : undefined;
25785
- if (!taskId)
25786
- throw new Error("task_storeProgress requires string `taskId`");
25787
- if (body.status === "completed" || body.status === "failed" || body.status === "skipped") {
25788
- return {
25789
- method: "POST",
25790
- path: `/api/tasks/${encodeURIComponent(taskId)}/finish`,
25791
- body: {
25792
- status: body.status,
25793
- output: body.output,
25794
- failureReason: body.failureReason,
25795
- force: body.force
25796
- }
25797
- };
25798
- }
25799
- return {
25800
- method: "POST",
25801
- path: `/api/tasks/${encodeURIComponent(taskId)}/progress`,
25802
- body: { progress: body.progress ?? "" }
25803
- };
25804
- }
25805
25821
  case "task_cancel": {
25806
25822
  const taskId = typeof body.taskId === "string" ? body.taskId : undefined;
25807
25823
  if (!taskId)
@@ -28789,7 +28805,19 @@ var init_unmapped_identities = __esm(() => {
28789
28805
 
28790
28806
  // src/vcs/azure-devops.ts
28791
28807
  function isAzureDevOpsUrl(url) {
28792
- return /(^|[/@.])dev\.azure\.com[/:]|\.visualstudio\.com[/:]/i.test(url);
28808
+ const trimmed = url.trim();
28809
+ const scp = trimmed.match(/^[^@/\s:]+@([^:/\s]+):/);
28810
+ if (scp)
28811
+ return isAzureDevOpsHost(scp[1]);
28812
+ try {
28813
+ return isAzureDevOpsHost(new URL(trimmed).hostname);
28814
+ } catch {
28815
+ return /^(?:ssh\.)?dev\.azure\.com(\/|$)|^[\w.-]+\.visualstudio\.com(\/|$)/i.test(trimmed);
28816
+ }
28817
+ }
28818
+ function isAzureDevOpsHost(hostname) {
28819
+ const host = hostname.toLowerCase();
28820
+ return host === "dev.azure.com" || host === "ssh.dev.azure.com" || host.endsWith(".visualstudio.com");
28793
28821
  }
28794
28822
  function canonicalAzureDevOpsRepoUrl(url) {
28795
28823
  const trimmed = url.trim();
@@ -32728,7 +32756,7 @@ function readApiUrlOverrides() {
32728
32756
  }
32729
32757
  }
32730
32758
  var ChatSdkConfigError, RESOLVER_FIELDS;
32731
- var init_config = __esm(() => {
32759
+ var init_config2 = __esm(() => {
32732
32760
  init_config_refs();
32733
32761
  init_db4();
32734
32762
  init_swarm_config_guard();
@@ -32872,6 +32900,100 @@ var init_logger = __esm(() => {
32872
32900
  init_secret_scrubber();
32873
32901
  });
32874
32902
 
32903
+ // src/integrations/chat-sdk/mentions.ts
32904
+ function escapeRegex(value) {
32905
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
32906
+ }
32907
+ function stripBotMention(text, forms) {
32908
+ let out = text;
32909
+ const names = [...new Set(forms.names.map((name) => name.trim()).filter(Boolean))];
32910
+ names.sort((a, b) => b.length - a.length);
32911
+ for (const name of names) {
32912
+ out = out.replace(new RegExp(`(?<!\\w)@${escapeRegex(name)}(?![\\w-])`, "gi"), "");
32913
+ }
32914
+ for (const id of new Set(forms.ids.filter(Boolean))) {
32915
+ const escaped = escapeRegex(id);
32916
+ out = out.replace(new RegExp(`<@!?${escaped}>`, "g"), "");
32917
+ out = out.replace(new RegExp(`(?<![\\w<&])@${escaped}(?!\\w)`, "g"), "");
32918
+ }
32919
+ return out.trim();
32920
+ }
32921
+ function teamsIdTail(id) {
32922
+ return id.slice(id.lastIndexOf(":") + 1).toLowerCase();
32923
+ }
32924
+ function teamsBotMentionNames(raw, botUserId) {
32925
+ if (!botUserId || !raw || typeof raw !== "object")
32926
+ return [];
32927
+ const entities = raw.entities;
32928
+ if (!Array.isArray(entities))
32929
+ return [];
32930
+ const bot = teamsIdTail(botUserId);
32931
+ const names = [];
32932
+ for (const entity of entities) {
32933
+ if (entity?.type !== "mention")
32934
+ continue;
32935
+ const id = entity.mentioned?.id;
32936
+ if (typeof id !== "string" || teamsIdTail(id) !== bot)
32937
+ continue;
32938
+ if (typeof entity.mentioned?.name === "string")
32939
+ names.push(entity.mentioned.name);
32940
+ if (typeof entity.text === "string") {
32941
+ const label = /<at\b[^>]*>(.*?)<\/at>/is.exec(entity.text)?.[1];
32942
+ if (label)
32943
+ names.push(decodeTeamsLabel(label));
32944
+ }
32945
+ }
32946
+ return names;
32947
+ }
32948
+ function decodeTeamsLabel(label) {
32949
+ return label.replace(/<[^>]*>/g, "").replace(/&quot;/g, '"').replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").trim();
32950
+ }
32951
+ function resolveDiscordMentions(content, botUserId, lookup) {
32952
+ return content.replace(/<(@!?|@&|#)(\d+)>/g, (markup, kind, id) => {
32953
+ if (kind === "#") {
32954
+ const name = lookup.channel(id);
32955
+ return name ? `#${name}` : markup;
32956
+ }
32957
+ if (kind === "@&") {
32958
+ const name = lookup.role(id);
32959
+ return name ? `@${name}` : markup;
32960
+ }
32961
+ if (id === botUserId)
32962
+ return markup;
32963
+ const name = lookup.user(id);
32964
+ return name ? `@${name}` : markup;
32965
+ });
32966
+ }
32967
+ function safeName(read) {
32968
+ try {
32969
+ const value = read();
32970
+ return typeof value === "string" && value.trim() ? value : undefined;
32971
+ } catch {
32972
+ return;
32973
+ }
32974
+ }
32975
+ function discordJsMentionLookup(mentions) {
32976
+ return {
32977
+ user: (id) => safeName(() => mentions?.members?.get(id)?.displayName) ?? safeName(() => mentions?.users?.get(id)?.displayName) ?? safeName(() => mentions?.users?.get(id)?.username),
32978
+ role: (id) => safeName(() => mentions?.roles?.get(id)?.name),
32979
+ channel: (id) => safeName(() => mentions?.channels?.get(id)?.name)
32980
+ };
32981
+ }
32982
+ async function botMentionForms(adapter, message) {
32983
+ const names = [adapter.userName];
32984
+ const ids = adapter.botUserId ? [adapter.botUserId] : [];
32985
+ if (adapter.name === "teams")
32986
+ names.push(...teamsBotMentionNames(message.raw, adapter.botUserId));
32987
+ if (adapter.name === "slack" && adapter.botUserId) {
32988
+ const lookup = adapter.lookupUser;
32989
+ const bot = await lookup?.call(adapter, adapter.botUserId).catch(() => null);
32990
+ if (bot?.displayName)
32991
+ names.push(bot.displayName);
32992
+ }
32993
+ return { names, ids };
32994
+ }
32995
+ var init_mentions2 = () => {};
32996
+
32875
32997
  // src/integrations/chat-sdk/test-hooks.ts
32876
32998
  function getChatSdkTestHooks() {
32877
32999
  return hooks;
@@ -32917,8 +33039,21 @@ async function loadAdapter(name, config, logger) {
32917
33039
  });
32918
33040
  }
32919
33041
  case "discord": {
32920
- const { createDiscordAdapter } = await import("./index-mbpxhc4w.js");
32921
- return createDiscordAdapter({
33042
+ const { DiscordAdapter } = await import("./index-126v2d0t.js");
33043
+
33044
+ class SwarmDiscordAdapter extends DiscordAdapter {
33045
+ handleGatewayMessage(message, isMentioned) {
33046
+ const content = resolveDiscordMentions(message.content, this.botUserId, discordJsMentionLookup(message.mentions));
33047
+ if (content === message.content) {
33048
+ return super.handleGatewayMessage(message, isMentioned);
33049
+ }
33050
+ const view = new Proxy(message, {
33051
+ get: (target, prop) => prop === "content" ? content : Reflect.get(target, prop, target)
33052
+ });
33053
+ return super.handleGatewayMessage(view, isMentioned);
33054
+ }
33055
+ }
33056
+ return new SwarmDiscordAdapter({
32922
33057
  ...base,
32923
33058
  logger: withInfoFilter(logger, keepDiscordInfoLine),
32924
33059
  respondToChannelIds: config.respondToChannelIds ?? [],
@@ -32958,9 +33093,10 @@ function watchSocketConnection(adapter, logger) {
32958
33093
  }
32959
33094
  var DEFAULT_BOT_USER_NAME = "swarm", DEFAULT_API_URLS, DISCORD_NOISY_INFO_PREFIXES;
32960
33095
  var init_adapters = __esm(() => {
32961
- init_config();
33096
+ init_config2();
32962
33097
  init_facts();
32963
33098
  init_logger();
33099
+ init_mentions2();
32964
33100
  init_test_hooks();
32965
33101
  DEFAULT_API_URLS = {
32966
33102
  telegram: "https://api.telegram.org",
@@ -33232,7 +33368,7 @@ function assertTrustedTeamsServiceUrl(serviceUrl) {
33232
33368
  }
33233
33369
  var TRUSTED_TEAMS_SERVICE_HOSTS, UntrustedTeamsServiceUrlError;
33234
33370
  var init_teams_origin = __esm(() => {
33235
- init_config();
33371
+ init_config2();
33236
33372
  TRUSTED_TEAMS_SERVICE_HOSTS = new Set([
33237
33373
  "smba.trafficmanager.net",
33238
33374
  "smba.infra.gcc.teams.microsoft.com",
@@ -34246,6 +34382,220 @@ var init_limits = __esm(() => {
34246
34382
  TELEGRAM_PHOTO_LIMIT = 10 * MB2;
34247
34383
  });
34248
34384
 
34385
+ // src/be/runtime-pools/demand.ts
34386
+ async function pendingWorkForAgent(agentId) {
34387
+ const rows = await getDbClient2().query(`SELECT * FROM agent_tasks WHERE (agentId = ? AND status = 'pending')
34388
+ OR (offeredTo = ? AND status = 'offered') ORDER BY priority DESC, createdAt, rowid`, [agentId, agentId]);
34389
+ const tasks = [];
34390
+ for (const row of rows) {
34391
+ const task = rowToAgentTask(row);
34392
+ if (task.status === "offered" || (await checkDependencies2(task.id)).ready)
34393
+ tasks.push(task);
34394
+ }
34395
+ const mentions = await getDbClient2().get(`SELECT COUNT(DISTINCT m.channelId) AS count FROM channel_messages m
34396
+ JOIN channels c ON c.id = m.channelId
34397
+ LEFT JOIN channel_read_state s ON s.channelId = m.channelId AND s.agentId = ?
34398
+ WHERE m.mentions LIKE ? AND s.processing_since IS NULL
34399
+ AND (s.lastReadAt IS NULL OR m.createdAt > s.lastReadAt)`, [agentId, `%"${agentId}"%`]);
34400
+ return { work: tasks.length + (mentions?.count ?? 0), topTask: tasks[0] ?? null };
34401
+ }
34402
+ function agentRuntimeLimit(maxTasks, slotsPerRuntime) {
34403
+ return Math.floor(maxTasks / slotsPerRuntime);
34404
+ }
34405
+ function countPoolRuntimes(runtimes, now, staleMinutes) {
34406
+ return runtimes.filter((r) => r.status === "provisioning" || r.status === "active" && Date.parse(r.lastSeenAt) >= now.getTime() - staleMinutes * 60000).length;
34407
+ }
34408
+ function computeDesired(pool, agents) {
34409
+ const desired = new Map;
34410
+ let remaining = Math.max(0, (pool.maxRuntimes ?? Infinity) - agents.reduce((n, a) => n + a.current, 0));
34411
+ for (const agent of agents) {
34412
+ const uncovered = Math.max(0, agent.work - agent.freeSlots - agent.provisioning * pool.slotsPerRuntime);
34413
+ const limit = agentRuntimeLimit(agent.maxTasks, pool.slotsPerRuntime);
34414
+ const count = Math.min(limit, Math.max(pool.minRuntimes, agent.current + Math.ceil(uncovered / pool.slotsPerRuntime)));
34415
+ const added = Math.min(remaining, Math.max(0, count - agent.current));
34416
+ desired.set(agent.agentId, Math.min(count, agent.current + added));
34417
+ remaining -= added;
34418
+ }
34419
+ return desired;
34420
+ }
34421
+ var init_demand = __esm(() => {
34422
+ init_db4();
34423
+ init_read();
34424
+ });
34425
+
34426
+ // src/be/runtime-pools/reachability.ts
34427
+ function isRuntimePoolWakeable(pool, now = new Date) {
34428
+ if (!pool.enabled || pool.circuitOpenUntil && Date.parse(pool.circuitOpenUntil) > now.getTime())
34429
+ return false;
34430
+ return canProvisionKind(pool.kind) && pool.maxRuntimes !== 0 && Boolean(pool.resolvedImage ?? pool.image);
34431
+ }
34432
+ async function isAgentReachable(agent) {
34433
+ if (agent.status !== "offline")
34434
+ return true;
34435
+ if (!isRuntimePoolsEnabled() || !agent.runtimePoolId)
34436
+ return false;
34437
+ const pool = await getRuntimePool2(agent.runtimePoolId);
34438
+ if (!pool?.enabled)
34439
+ return false;
34440
+ if (isRuntimePoolWakeable(pool))
34441
+ return true;
34442
+ return await getDbClient2().get(`SELECT id FROM runtime_instances WHERE agent_id = ? AND pool_id = ?
34443
+ AND status = 'provisioning' AND draining = 0 LIMIT 1`, [agent.id, pool.id]) !== null;
34444
+ }
34445
+ async function isAgentOnDemand(agent, now = new Date) {
34446
+ if (agent.status !== "offline" || !agent.runtimePoolId)
34447
+ return false;
34448
+ if (!isRuntimePoolsEnabled() || !isMultiRuntimeEnabled())
34449
+ return false;
34450
+ const pool = await getRuntimePool2(agent.runtimePoolId);
34451
+ if (!pool?.enabled)
34452
+ return false;
34453
+ const runtimes = await listRuntimeInstancesForPool(pool.id);
34454
+ const own = runtimes.filter((r) => r.agentId === agent.id);
34455
+ if (own.some((r) => r.status === "provisioning" && !r.draining))
34456
+ return true;
34457
+ if (!isRuntimePoolWakeable(pool, now))
34458
+ return false;
34459
+ const staleMinutes = runtimeStaleThresholdMinutes();
34460
+ const limit = agentRuntimeLimit(agent.maxTasks ?? 1, pool.slotsPerRuntime);
34461
+ if (countPoolRuntimes(own, now, staleMinutes) >= limit)
34462
+ return false;
34463
+ if (pool.maxRuntimes === null)
34464
+ return true;
34465
+ return countPoolRuntimes(runtimes, now, staleMinutes) < pool.maxRuntimes;
34466
+ }
34467
+ var init_reachability = __esm(() => {
34468
+ init_runtime_providers();
34469
+ init_multi_runtime2();
34470
+ init_runtime_pools_flag();
34471
+ init_db4();
34472
+ init_multi_runtime();
34473
+ init_db2();
34474
+ init_demand();
34475
+ });
34476
+
34477
+ // src/integrations/chat-sdk/telegram-thread.ts
34478
+ function assertTelegramTopicThreadId(threadId, channelId) {
34479
+ const match = /^telegram:([^:]+):([1-9]\d*)$/.exec(threadId);
34480
+ if (!match || match[1] === "biz" || !Number.isSafeInteger(Number(match[2]))) {
34481
+ throw new Error("Invalid Telegram topic threadId. Use telegram:<chatId>:<positive integer topicId>.");
34482
+ }
34483
+ if (channelId !== undefined && `telegram:${match[1]}` !== channelId) {
34484
+ throw new Error("The default Telegram topic must belong to the registered channel.");
34485
+ }
34486
+ }
34487
+ var init_telegram_thread = () => {};
34488
+
34489
+ // src/integrations/chat-sdk/router.ts
34490
+ function chatChannelKey(adapter, channelId) {
34491
+ return channelId.startsWith(`${adapter}:`) ? channelId : `${adapter}:${channelId}`;
34492
+ }
34493
+ async function getChatChannelMapping(adapter, channelId) {
34494
+ const row = await getKv2(CHAT_CHANNELS_NAMESPACE, chatChannelKey(adapter, channelId));
34495
+ if (!row || typeof row.value !== "object" || row.value === null)
34496
+ return null;
34497
+ return row.value;
34498
+ }
34499
+ async function putChatChannelMapping(adapter, channelId, mapping) {
34500
+ const key = chatChannelKey(adapter, channelId);
34501
+ if (mapping.defaultThreadId !== undefined) {
34502
+ if (adapter !== "telegram") {
34503
+ throw new Error("Default topics are supported only for Telegram channels.");
34504
+ }
34505
+ assertTelegramTopicThreadId(mapping.defaultThreadId, key);
34506
+ }
34507
+ await upsertKv2({
34508
+ namespace: CHAT_CHANNELS_NAMESPACE,
34509
+ key,
34510
+ value: mapping,
34511
+ valueType: "json",
34512
+ expiresAt: null
34513
+ });
34514
+ return key;
34515
+ }
34516
+ async function deleteChatChannelMapping(adapter, channelId) {
34517
+ return deleteKv2(CHAT_CHANNELS_NAMESPACE, chatChannelKey(adapter, channelId));
34518
+ }
34519
+ function hasRoutingToken(text) {
34520
+ return /swarm#(?:[a-f0-9-]{36}|all)/i.test(text);
34521
+ }
34522
+ function stripRoutingTokens(text) {
34523
+ return text.replace(/swarm#[a-f0-9-]{36}/gi, "").replace(/swarm#all/gi, "").trim();
34524
+ }
34525
+ function chatOwnerWindowStart(now = Date.now()) {
34526
+ const raw = process.env.CHAT_SDK_OWNER_WINDOW_MIN?.trim();
34527
+ const value = raw ? Number(raw) : Number.NaN;
34528
+ const minutes = Number.isFinite(value) && value >= 0 ? value : DEFAULT_OWNER_WINDOW_MINUTES;
34529
+ return new Date(now - minutes * 60000).toISOString();
34530
+ }
34531
+ async function leadMatch(reachable, matchedText) {
34532
+ const lead = reachable.find((agent) => agent.isLead) ?? await getLeadAgent2();
34533
+ return { agent: lead, reason: "skill", matchedText };
34534
+ }
34535
+ async function routeChatMessage(text, ctx) {
34536
+ const allAgents = await getAllAgents2();
34537
+ const reachableFlags = await Promise.all(allAgents.map((agent) => isAgentReachable(agent)));
34538
+ const reachable = allAgents.filter((_, index) => reachableFlags[index]);
34539
+ const matches = [];
34540
+ for (const match of text.matchAll(/swarm#([a-f0-9-]{36})/gi)) {
34541
+ const agentId = match[1];
34542
+ if (!agentId || matches.some((m) => m.agent?.id === agentId))
34543
+ continue;
34544
+ const agent = await getAgentById2(agentId);
34545
+ if (agent && await isAgentReachable(agent)) {
34546
+ matches.push({ agent, reason: "human_pinned", matchedText: match[0] });
34547
+ }
34548
+ }
34549
+ if (/swarm#all/i.test(text)) {
34550
+ for (const agent of reachable) {
34551
+ if (agent.isLead || matches.some((m) => m.agent?.id === agent.id))
34552
+ continue;
34553
+ matches.push({ agent, reason: "human_pinned", matchedText: "swarm#all" });
34554
+ }
34555
+ }
34556
+ if (matches.length > 0)
34557
+ return { kind: "agents", matches };
34558
+ const mapping = await getChatChannelMapping(ctx.adapter, ctx.channelId);
34559
+ if (mapping?.workflowId && (ctx.botMentioned || ctx.isDirectMessage)) {
34560
+ return { kind: "workflow", workflowId: mapping.workflowId };
34561
+ }
34562
+ if (mapping?.agentId) {
34563
+ const agent = await getAgentById2(mapping.agentId);
34564
+ if (agent) {
34565
+ return {
34566
+ kind: "agents",
34567
+ matches: [{ agent, reason: "human_pinned", matchedText: "channel mapping" }]
34568
+ };
34569
+ }
34570
+ console.warn(scrubSecrets(`[chat-sdk] Channel mapping for ${ctx.channelId} names unknown agent ${mapping.agentId}; using the default route`));
34571
+ }
34572
+ const owner = await getAgentWorkingOnContextKey2(chatSdkContextKey(ctx.threadId), "chat", ctx.adapter === "telegram" && !ctx.isDirectMessage ? chatOwnerWindowStart() : undefined);
34573
+ if (owner && await isAgentReachable(owner)) {
34574
+ return {
34575
+ kind: "agents",
34576
+ matches: [{ agent: owner, reason: "continuity", matchedText: "thread follow-up" }]
34577
+ };
34578
+ }
34579
+ if (owner) {
34580
+ return {
34581
+ kind: "agents",
34582
+ matches: [await leadMatch(reachable, "thread follow-up (lead fallback)")]
34583
+ };
34584
+ }
34585
+ if (ctx.botMentioned || ctx.isDirectMessage) {
34586
+ return { kind: "agents", matches: [await leadMatch(reachable, "@bot")] };
34587
+ }
34588
+ return null;
34589
+ }
34590
+ var CHAT_CHANNELS_NAMESPACE = "integrations:chat:channels", DEFAULT_OWNER_WINDOW_MINUTES = 15;
34591
+ var init_router2 = __esm(() => {
34592
+ init_db4();
34593
+ init_reachability();
34594
+ init_context_key();
34595
+ init_secret_scrubber();
34596
+ init_telegram_thread();
34597
+ });
34598
+
34249
34599
  // src/integrations/chat-sdk/outbound.ts
34250
34600
  function emitChatMessageSent(event) {
34251
34601
  workflowEventBus2.emit("chat.message.sent", { ...event, text: scrubSecrets(event.text) });
@@ -34411,7 +34761,18 @@ function scrubCard(card) {
34411
34761
  return JSON.parse(JSON.stringify(card, (_key, value) => typeof value === "string" ? scrubSecrets(value) : value));
34412
34762
  }
34413
34763
  async function postChatMessage(args) {
34414
- assertTrustedChatTarget(args.threadId ?? args.channelId ?? "");
34764
+ let threadId = args.threadId;
34765
+ if (!threadId && args.channelId && args.adapter === "telegram") {
34766
+ const mapping = await getChatChannelMapping(args.adapter, args.channelId);
34767
+ if (mapping?.defaultThreadId !== undefined) {
34768
+ assertTelegramTopicThreadId(mapping.defaultThreadId, args.channelId);
34769
+ threadId = mapping.defaultThreadId;
34770
+ }
34771
+ }
34772
+ if (args.adapter === "telegram" && threadId?.split(":").length === 3 && !threadId.startsWith("telegram:biz:")) {
34773
+ assertTelegramTopicThreadId(threadId);
34774
+ }
34775
+ assertTrustedChatTarget(threadId ?? args.channelId ?? "");
34415
34776
  const chat = getChatInstance(args.adapter);
34416
34777
  if (!chat)
34417
34778
  throw new ChatAdapterUnavailableError(args.adapter);
@@ -34422,8 +34783,8 @@ async function postChatMessage(args) {
34422
34783
  `) || (card?.title ?? "");
34423
34784
  let result;
34424
34785
  let target;
34425
- if (args.threadId) {
34426
- const thread = chat.thread(args.threadId);
34786
+ if (threadId) {
34787
+ const thread = chat.thread(threadId);
34427
34788
  target = thread;
34428
34789
  const replyTo = args.replyToMessageId;
34429
34790
  const sent = await postChunks(args.adapter, thread, parts, replyTo && thread.adapter.reply ? (message) => thread.reply(replyTo, message) : undefined, card);
@@ -34475,8 +34836,10 @@ var init_outbound2 = __esm(() => {
34475
34836
  init_attachments();
34476
34837
  init_limits();
34477
34838
  init_logger();
34839
+ init_router2();
34478
34840
  init_runtime();
34479
34841
  init_teams_origin();
34842
+ init_telegram_thread();
34480
34843
  ChatAdapterUnavailableError = class ChatAdapterUnavailableError extends Error {
34481
34844
  constructor(adapter) {
34482
34845
  super(`Chat SDK adapter '${adapter}' is not running`);
@@ -34495,201 +34858,6 @@ var init_outbound2 = __esm(() => {
34495
34858
  NON_HEADING_HASH = /^( {0,3}(?:>[ \t]?)*[ \t]*(?:(?:[-*+]|\d{1,9}[.)])[ \t]+(?:\[[ xX]\][ \t]+)?)?)(#{7,}|#{1,6}(?=[^\s#]))/;
34496
34859
  });
34497
34860
 
34498
- // src/be/runtime-pools/demand.ts
34499
- async function pendingWorkForAgent(agentId) {
34500
- const rows = await getDbClient2().query(`SELECT * FROM agent_tasks WHERE (agentId = ? AND status = 'pending')
34501
- OR (offeredTo = ? AND status = 'offered') ORDER BY priority DESC, createdAt, rowid`, [agentId, agentId]);
34502
- const tasks = [];
34503
- for (const row of rows) {
34504
- const task = rowToAgentTask(row);
34505
- if (task.status === "offered" || (await checkDependencies2(task.id)).ready)
34506
- tasks.push(task);
34507
- }
34508
- const mentions = await getDbClient2().get(`SELECT COUNT(DISTINCT m.channelId) AS count FROM channel_messages m
34509
- JOIN channels c ON c.id = m.channelId
34510
- LEFT JOIN channel_read_state s ON s.channelId = m.channelId AND s.agentId = ?
34511
- WHERE m.mentions LIKE ? AND s.processing_since IS NULL
34512
- AND (s.lastReadAt IS NULL OR m.createdAt > s.lastReadAt)`, [agentId, `%"${agentId}"%`]);
34513
- return { work: tasks.length + (mentions?.count ?? 0), topTask: tasks[0] ?? null };
34514
- }
34515
- function agentRuntimeLimit(maxTasks, slotsPerRuntime) {
34516
- return Math.floor(maxTasks / slotsPerRuntime);
34517
- }
34518
- function countPoolRuntimes(runtimes, now, staleMinutes) {
34519
- return runtimes.filter((r) => r.status === "provisioning" || r.status === "active" && Date.parse(r.lastSeenAt) >= now.getTime() - staleMinutes * 60000).length;
34520
- }
34521
- function computeDesired(pool, agents) {
34522
- const desired = new Map;
34523
- let remaining = Math.max(0, (pool.maxRuntimes ?? Infinity) - agents.reduce((n, a) => n + a.current, 0));
34524
- for (const agent of agents) {
34525
- const uncovered = Math.max(0, agent.work - agent.freeSlots - agent.provisioning * pool.slotsPerRuntime);
34526
- const limit = agentRuntimeLimit(agent.maxTasks, pool.slotsPerRuntime);
34527
- const count = Math.min(limit, Math.max(pool.minRuntimes, agent.current + Math.ceil(uncovered / pool.slotsPerRuntime)));
34528
- const added = Math.min(remaining, Math.max(0, count - agent.current));
34529
- desired.set(agent.agentId, Math.min(count, agent.current + added));
34530
- remaining -= added;
34531
- }
34532
- return desired;
34533
- }
34534
- var init_demand = __esm(() => {
34535
- init_db4();
34536
- init_read();
34537
- });
34538
-
34539
- // src/be/runtime-pools/reachability.ts
34540
- function isRuntimePoolWakeable(pool, now = new Date) {
34541
- if (!pool.enabled || pool.circuitOpenUntil && Date.parse(pool.circuitOpenUntil) > now.getTime())
34542
- return false;
34543
- return canProvisionKind(pool.kind) && pool.maxRuntimes !== 0 && Boolean(pool.resolvedImage ?? pool.image);
34544
- }
34545
- async function isAgentReachable(agent) {
34546
- if (agent.status !== "offline")
34547
- return true;
34548
- if (!isRuntimePoolsEnabled() || !agent.runtimePoolId)
34549
- return false;
34550
- const pool = await getRuntimePool2(agent.runtimePoolId);
34551
- if (!pool?.enabled)
34552
- return false;
34553
- if (isRuntimePoolWakeable(pool))
34554
- return true;
34555
- return await getDbClient2().get(`SELECT id FROM runtime_instances WHERE agent_id = ? AND pool_id = ?
34556
- AND status = 'provisioning' AND draining = 0 LIMIT 1`, [agent.id, pool.id]) !== null;
34557
- }
34558
- async function isAgentOnDemand(agent, now = new Date) {
34559
- if (agent.status !== "offline" || !agent.runtimePoolId)
34560
- return false;
34561
- if (!isRuntimePoolsEnabled() || !isMultiRuntimeEnabled())
34562
- return false;
34563
- const pool = await getRuntimePool2(agent.runtimePoolId);
34564
- if (!pool?.enabled)
34565
- return false;
34566
- const runtimes = await listRuntimeInstancesForPool(pool.id);
34567
- const own = runtimes.filter((r) => r.agentId === agent.id);
34568
- if (own.some((r) => r.status === "provisioning" && !r.draining))
34569
- return true;
34570
- if (!isRuntimePoolWakeable(pool, now))
34571
- return false;
34572
- const staleMinutes = runtimeStaleThresholdMinutes();
34573
- const limit = agentRuntimeLimit(agent.maxTasks ?? 1, pool.slotsPerRuntime);
34574
- if (countPoolRuntimes(own, now, staleMinutes) >= limit)
34575
- return false;
34576
- if (pool.maxRuntimes === null)
34577
- return true;
34578
- return countPoolRuntimes(runtimes, now, staleMinutes) < pool.maxRuntimes;
34579
- }
34580
- var init_reachability = __esm(() => {
34581
- init_runtime_providers();
34582
- init_multi_runtime2();
34583
- init_runtime_pools_flag();
34584
- init_db4();
34585
- init_multi_runtime();
34586
- init_db2();
34587
- init_demand();
34588
- });
34589
-
34590
- // src/integrations/chat-sdk/router.ts
34591
- function chatChannelKey(adapter, channelId) {
34592
- return channelId.startsWith(`${adapter}:`) ? channelId : `${adapter}:${channelId}`;
34593
- }
34594
- async function getChatChannelMapping(adapter, channelId) {
34595
- const row = await getKv2(CHAT_CHANNELS_NAMESPACE, chatChannelKey(adapter, channelId));
34596
- if (!row || typeof row.value !== "object" || row.value === null)
34597
- return null;
34598
- return row.value;
34599
- }
34600
- async function putChatChannelMapping(adapter, channelId, mapping) {
34601
- const key = chatChannelKey(adapter, channelId);
34602
- await upsertKv2({
34603
- namespace: CHAT_CHANNELS_NAMESPACE,
34604
- key,
34605
- value: mapping,
34606
- valueType: "json",
34607
- expiresAt: null
34608
- });
34609
- return key;
34610
- }
34611
- async function deleteChatChannelMapping(adapter, channelId) {
34612
- return deleteKv2(CHAT_CHANNELS_NAMESPACE, chatChannelKey(adapter, channelId));
34613
- }
34614
- function hasRoutingToken(text) {
34615
- return /swarm#(?:[a-f0-9-]{36}|all)/i.test(text);
34616
- }
34617
- function stripRoutingTokens(text) {
34618
- return text.replace(/swarm#[a-f0-9-]{36}/gi, "").replace(/swarm#all/gi, "").trim();
34619
- }
34620
- function chatOwnerWindowStart(now = Date.now()) {
34621
- const raw = process.env.CHAT_SDK_OWNER_WINDOW_MIN?.trim();
34622
- const value = raw ? Number(raw) : Number.NaN;
34623
- const minutes = Number.isFinite(value) && value >= 0 ? value : DEFAULT_OWNER_WINDOW_MINUTES;
34624
- return new Date(now - minutes * 60000).toISOString();
34625
- }
34626
- async function leadMatch(reachable, matchedText) {
34627
- const lead = reachable.find((agent) => agent.isLead) ?? await getLeadAgent2();
34628
- return { agent: lead, reason: "skill", matchedText };
34629
- }
34630
- async function routeChatMessage(text, ctx) {
34631
- const allAgents = await getAllAgents2();
34632
- const reachableFlags = await Promise.all(allAgents.map((agent) => isAgentReachable(agent)));
34633
- const reachable = allAgents.filter((_, index) => reachableFlags[index]);
34634
- const matches = [];
34635
- for (const match of text.matchAll(/swarm#([a-f0-9-]{36})/gi)) {
34636
- const agentId = match[1];
34637
- if (!agentId || matches.some((m) => m.agent?.id === agentId))
34638
- continue;
34639
- const agent = await getAgentById2(agentId);
34640
- if (agent && await isAgentReachable(agent)) {
34641
- matches.push({ agent, reason: "human_pinned", matchedText: match[0] });
34642
- }
34643
- }
34644
- if (/swarm#all/i.test(text)) {
34645
- for (const agent of reachable) {
34646
- if (agent.isLead || matches.some((m) => m.agent?.id === agent.id))
34647
- continue;
34648
- matches.push({ agent, reason: "human_pinned", matchedText: "swarm#all" });
34649
- }
34650
- }
34651
- if (matches.length > 0)
34652
- return { kind: "agents", matches };
34653
- const mapping = await getChatChannelMapping(ctx.adapter, ctx.channelId);
34654
- if (mapping?.workflowId && (ctx.botMentioned || ctx.isDirectMessage)) {
34655
- return { kind: "workflow", workflowId: mapping.workflowId };
34656
- }
34657
- if (mapping?.agentId) {
34658
- const agent = await getAgentById2(mapping.agentId);
34659
- if (agent) {
34660
- return {
34661
- kind: "agents",
34662
- matches: [{ agent, reason: "human_pinned", matchedText: "channel mapping" }]
34663
- };
34664
- }
34665
- console.warn(scrubSecrets(`[chat-sdk] Channel mapping for ${ctx.channelId} names unknown agent ${mapping.agentId}; using the default route`));
34666
- }
34667
- const owner = await getAgentWorkingOnContextKey2(chatSdkContextKey(ctx.threadId), "chat", ctx.adapter === "telegram" && !ctx.isDirectMessage ? chatOwnerWindowStart() : undefined);
34668
- if (owner && await isAgentReachable(owner)) {
34669
- return {
34670
- kind: "agents",
34671
- matches: [{ agent: owner, reason: "continuity", matchedText: "thread follow-up" }]
34672
- };
34673
- }
34674
- if (owner) {
34675
- return {
34676
- kind: "agents",
34677
- matches: [await leadMatch(reachable, "thread follow-up (lead fallback)")]
34678
- };
34679
- }
34680
- if (ctx.botMentioned || ctx.isDirectMessage) {
34681
- return { kind: "agents", matches: [await leadMatch(reachable, "@bot")] };
34682
- }
34683
- return null;
34684
- }
34685
- var CHAT_CHANNELS_NAMESPACE = "integrations:chat:channels", DEFAULT_OWNER_WINDOW_MINUTES = 15;
34686
- var init_router2 = __esm(() => {
34687
- init_db4();
34688
- init_reachability();
34689
- init_context_key();
34690
- init_secret_scrubber();
34691
- });
34692
-
34693
34861
  // src/integrations/chat-sdk/reactions.ts
34694
34862
  function chatAdapterReacts(adapter) {
34695
34863
  return adapter in CHAT_REACTIONS;
@@ -34894,19 +35062,6 @@ var init_templates9 = __esm(() => {
34894
35062
  });
34895
35063
 
34896
35064
  // src/integrations/chat-sdk/inbound.ts
34897
- function escapeRegex(value) {
34898
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
34899
- }
34900
- function stripBotMention(text, adapter) {
34901
- let out = text;
34902
- if (adapter.userName) {
34903
- out = out.replace(new RegExp(`(?<!\\w)@${escapeRegex(adapter.userName)}(?![\\w-])`, "gi"), "");
34904
- }
34905
- if (adapter.botUserId) {
34906
- out = out.replace(new RegExp(`<@${escapeRegex(adapter.botUserId)}>`, "g"), "");
34907
- }
34908
- return out.trim();
34909
- }
34910
35065
  function adapterOf(threadId) {
34911
35066
  const i = threadId.indexOf(":");
34912
35067
  return i === -1 ? threadId : threadId.slice(0, i);
@@ -34921,7 +35076,7 @@ async function handleChatInbound(thread, message, kind) {
34921
35076
  text: message.text,
34922
35077
  messageId: message.id
34923
35078
  });
34924
- let text = stripBotMention(chatMessageText(message), thread.adapter);
35079
+ let text = stripBotMention(chatMessageText(message), await botMentionForms(thread.adapter, message));
34925
35080
  const immediate = /^!now\b/i.test(text);
34926
35081
  if (immediate)
34927
35082
  text = text.replace(/^!now\s*/i, "").trim();
@@ -35315,6 +35470,7 @@ var init_inbound = __esm(() => {
35315
35470
  init_commands();
35316
35471
  init_facts();
35317
35472
  init_logger();
35473
+ init_mentions2();
35318
35474
  init_message_text2();
35319
35475
  init_outbound2();
35320
35476
  init_reactions3();
@@ -35905,7 +36061,7 @@ var init_runtime = __esm(() => {
35905
36061
  init_adapters();
35906
36062
  init_background();
35907
36063
  init_commands();
35908
- init_config();
36064
+ init_config2();
35909
36065
  init_discord_gateway();
35910
36066
  init_handlers6();
35911
36067
  init_logger();
@@ -35941,7 +36097,7 @@ function extractText(adf) {
35941
36097
  if (!isNode(adf))
35942
36098
  return "";
35943
36099
  const out = [];
35944
- const visit = (node) => {
36100
+ const visit = (node, marker) => {
35945
36101
  const type = typeof node.type === "string" ? node.type : "";
35946
36102
  switch (type) {
35947
36103
  case "text": {
@@ -35972,14 +36128,21 @@ function extractText(adf) {
35972
36128
  `);
35973
36129
  return;
35974
36130
  }
35975
- case "bulletList":
35976
- case "orderedList": {
36131
+ case "bulletList": {
35977
36132
  for (const child of asNodeArray(node.content))
35978
- visit(child);
36133
+ visit(child, "- ");
36134
+ return;
36135
+ }
36136
+ case "orderedList": {
36137
+ const order = node.attrs?.order;
36138
+ const start = typeof order === "number" && Number.isInteger(order) && order >= 0 ? order : 1;
36139
+ asNodeArray(node.content).forEach((child, index) => {
36140
+ visit(child, `${start + index}. `);
36141
+ });
35979
36142
  return;
35980
36143
  }
35981
36144
  case "listItem": {
35982
- out.push("- ");
36145
+ out.push(marker ?? "- ");
35983
36146
  for (const child of asNodeArray(node.content))
35984
36147
  visit(child);
35985
36148
  if (out.length > 0 && !out[out.length - 1]?.endsWith(`
@@ -35989,6 +36152,17 @@ function extractText(adf) {
35989
36152
  }
35990
36153
  return;
35991
36154
  }
36155
+ case "inlineCard":
36156
+ case "blockCard":
36157
+ case "embedCard": {
36158
+ const url = node.attrs?.url;
36159
+ if (typeof url === "string" && url.length > 0)
36160
+ out.push(url);
36161
+ if (type !== "inlineCard")
36162
+ out.push(`
36163
+ `);
36164
+ return;
36165
+ }
35992
36166
  case "doc": {
35993
36167
  for (const child of asNodeArray(node.content))
35994
36168
  visit(child);
@@ -36722,7 +36896,7 @@ async function notifySlack(text) {
36722
36896
  return;
36723
36897
  }
36724
36898
  try {
36725
- const { getSlackApp } = await import("./app-535m78qw.js");
36899
+ const { getSlackApp } = await import("./app-tmwa442h.js");
36726
36900
  const app = getSlackApp();
36727
36901
  if (!app) {
36728
36902
  console.warn("[Jira webhook keepalive] Slack not available, cannot send notification");
@@ -36793,7 +36967,7 @@ async function deleteJiraWebhook(webhookId) {
36793
36967
  console.log(`[Jira webhook keepalive] Deleted webhook id=${webhookId}`);
36794
36968
  }
36795
36969
  async function overwriteWebhookIds(next) {
36796
- const { getDbClient } = await import("./db-spg81qtr.js");
36970
+ const { getDbClient } = await import("./db-76p7w3gr.js");
36797
36971
  await getDbClient().transaction(async (tx) => {
36798
36972
  const row = await tx.get("SELECT metadata FROM oauth_apps WHERE provider = 'jira'");
36799
36973
  if (!row) {
@@ -110287,7 +110461,7 @@ async function loadGlobalConfigsIntoEnv2(override = false) {
110287
110461
  if (updated.length > 0) {
110288
110462
  refreshSecretScrubberCache();
110289
110463
  }
110290
- const { syncSlackTreeVisibility } = await import("./tree-visibility-dwzc8en0.js");
110464
+ const { syncSlackTreeVisibility } = await import("./tree-visibility-07wf1nct.js");
110291
110465
  await syncSlackTreeVisibility();
110292
110466
  return updated;
110293
110467
  }
@@ -110295,7 +110469,7 @@ async function reloadGlobalConfigsAndIntegrations2() {
110295
110469
  return runWithoutRequestAuth(() => runSlackLifecycleExclusive(() => reloadGlobalConfigsAndIntegrationsInner()));
110296
110470
  }
110297
110471
  async function reloadGlobalConfigsAndIntegrationsInner() {
110298
- const { getEmbeddingProvider, resetEmbeddingProvider } = await import("./index-we3nd2t0.js");
110472
+ const { getEmbeddingProvider, resetEmbeddingProvider } = await import("./index-aetfyx6p.js");
110299
110473
  const wasEmbeddingsConfigured = getEmbeddingProvider().isConfigured();
110300
110474
  const updated = await loadGlobalConfigsIntoEnv2(true);
110301
110475
  await syncTelemetryEnabled("settings").catch((err) => {
@@ -110311,7 +110485,7 @@ async function reloadGlobalConfigsAndIntegrationsInner() {
110311
110485
  integrations.push("embeddings");
110312
110486
  }
110313
110487
  if (isEmbeddingsConfigured) {
110314
- import("./embedding-space-an77f45k.js").then(({ runEmbeddingMaintenance }) => runEmbeddingMaintenance({ backfill: !wasEmbeddingsConfigured })).catch((err) => {
110488
+ import("./embedding-space-001hhhpk.js").then(({ runEmbeddingMaintenance }) => runEmbeddingMaintenance({ backfill: !wasEmbeddingsConfigured })).catch((err) => {
110315
110489
  console.error("[config-reload] embedding maintenance failed (non-fatal):", err);
110316
110490
  });
110317
110491
  }
@@ -118044,7 +118218,7 @@ var registerChatOpenDmTool = (server) => {
118044
118218
  };
118045
118219
  var init_chat_open_dm = __esm(() => {
118046
118220
  init_zod();
118047
- init_config();
118221
+ init_config2();
118048
118222
  init_logger();
118049
118223
  init_runtime();
118050
118224
  init_teams_origin();
@@ -118139,12 +118313,12 @@ var init_cards = __esm(() => {
118139
118313
  var registerChatPostTool = (server) => {
118140
118314
  createToolRegistrar(server)("chat-post", {
118141
118315
  title: "Post to a chat thread or channel",
118142
- description: "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.",
118316
+ description: "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.",
118143
118317
  annotations: { openWorldHint: true },
118144
118318
  inputSchema: object2({
118145
118319
  adapter: _enum2(CHAT_SDK_ADAPTER_NAMES).describe("Chat SDK adapter name."),
118146
- threadId: string2().min(1).optional().describe("Full SDK thread id, such as telegram:12345 or slack:C123:1700000000.000100."),
118147
- channelId: string2().min(1).optional().describe("Full SDK channel id, such as slack:C123. Ignored when threadId is set."),
118320
+ threadId: string2().min(1).optional().describe("Full SDK thread id, such as telegram:12345, telegram:-100123:42 (positive integer topic id), or slack:C123:1700000000.000100. Overrides the channel default."),
118321
+ channelId: string2().min(1).optional().describe("Full SDK channel id, such as telegram:-100123 or slack:C123. Uses its registered default Telegram topic when set. Ignored when threadId is set."),
118148
118322
  text: string2().min(1).max(20000).optional().describe("Markdown text to post. Required unless card is given."),
118149
118323
  card: cardSpecInputSchema.optional(),
118150
118324
  attachments: chatAttachmentsSchema
@@ -118207,7 +118381,7 @@ var registerChatPostTool = (server) => {
118207
118381
  var init_chat_post = __esm(() => {
118208
118382
  init_zod();
118209
118383
  init_cards();
118210
- init_config();
118384
+ init_config2();
118211
118385
  init_logger();
118212
118386
  init_outbound2();
118213
118387
  init_outbound_files();
@@ -119346,37 +119520,6 @@ var init_page_versions = __esm(() => {
119346
119520
  init_runtime2();
119347
119521
  });
119348
119522
 
119349
- // src/pages/version.ts
119350
- async function snapshotPage(pageId, changedByAgentId) {
119351
- const page = await getPage2(pageId);
119352
- if (!page) {
119353
- throw new Error(`Page ${pageId} not found — cannot create snapshot`);
119354
- }
119355
- const nextVersion = await getPageEditCounter(pageId);
119356
- const snapshot = {
119357
- title: page.title,
119358
- description: page.description,
119359
- contentType: page.contentType,
119360
- authMode: page.authMode,
119361
- passwordHash: page.passwordHash,
119362
- body: page.body,
119363
- needsCredentials: page.needsCredentials,
119364
- theme: page.theme,
119365
- themeTokens: page.themeTokens,
119366
- designVersion: page.designVersion
119367
- };
119368
- return createPageVersion2({
119369
- pageId,
119370
- version: nextVersion,
119371
- snapshot,
119372
- changedByAgentId
119373
- });
119374
- }
119375
- var init_version3 = __esm(() => {
119376
- init_db4();
119377
- init_page_versions();
119378
- });
119379
-
119380
119523
  // src/themes/classics.ts
119381
119524
  var CLASSIC_THEME_PRESETS;
119382
119525
  var init_classics = __esm(() => {
@@ -120594,6 +120737,198 @@ var init_presets = __esm(() => {
120594
120737
  THEME_PRESET_IDS = THEME_PRESETS.map((preset) => preset.id);
120595
120738
  });
120596
120739
 
120740
+ // src/themes/design-system.ts
120741
+ function readHttpsUrl(value, label, host) {
120742
+ let url;
120743
+ try {
120744
+ url = new URL(value);
120745
+ } catch {
120746
+ throw new DesignSystemError(`${label} must be an absolute https URL`);
120747
+ }
120748
+ if (url.protocol !== "https:" || UNSAFE_URL_CHARACTERS.test(value)) {
120749
+ throw new DesignSystemError(`${label} must be an absolute https URL`);
120750
+ }
120751
+ if (host && url.hostname !== host) {
120752
+ throw new DesignSystemError(`${label} must be on https://${host}`);
120753
+ }
120754
+ return url.href;
120755
+ }
120756
+ function readColor(value, index) {
120757
+ try {
120758
+ const { tokens } = importThemeTokens({ light: { "--color-chart-1": value } });
120759
+ const color = tokens.light["--color-chart-1"];
120760
+ if (color === undefined)
120761
+ throw new ThemeImportError("not a color value");
120762
+ return color;
120763
+ } catch (err) {
120764
+ if (err instanceof ThemeImportError) {
120765
+ throw new DesignSystemError(`chartPalette[${index}]: ${err.message}`);
120766
+ }
120767
+ throw err;
120768
+ }
120769
+ }
120770
+ function buildDesignSystem(input, actor, now = new Date) {
120771
+ const stamp = {
120772
+ source: input.source ?? { kind: "manual" },
120773
+ updatedBy: actor.userId,
120774
+ ...actor.agentId ? { updatedByAgentId: actor.agentId } : {},
120775
+ updatedAt: now.toISOString()
120776
+ };
120777
+ if (input.status === "declined") {
120778
+ return {
120779
+ record: {
120780
+ v: 1,
120781
+ status: "declined",
120782
+ basePreset: DEFAULT_THEME_ID,
120783
+ tokens: { light: {}, dark: {} },
120784
+ mode: "viewer",
120785
+ ...stamp
120786
+ },
120787
+ ignored: []
120788
+ };
120789
+ }
120790
+ const basePreset = input.basePreset ?? DEFAULT_THEME_ID;
120791
+ if (!isThemePresetId(basePreset)) {
120792
+ throw new DesignSystemError(`Unknown basePreset "${basePreset}". Use one of: ${THEME_PRESET_IDS.join(", ")}`);
120793
+ }
120794
+ let imported = {
120795
+ tokens: { light: {}, dark: {} },
120796
+ ignored: []
120797
+ };
120798
+ if (input.themeTokens) {
120799
+ try {
120800
+ imported = importThemeTokens(input.themeTokens);
120801
+ } catch (err) {
120802
+ if (err instanceof ThemeImportError) {
120803
+ throw new DesignSystemError(`Invalid themeTokens: ${err.message}`);
120804
+ }
120805
+ throw err;
120806
+ }
120807
+ }
120808
+ const record = {
120809
+ v: 1,
120810
+ status: "active",
120811
+ basePreset,
120812
+ tokens: imported.tokens,
120813
+ ...input.fontsHref ? { fontsHref: readHttpsUrl(input.fontsHref, "fontsHref", FONTS_HOST) } : {},
120814
+ ...input.logo ? { logo: { url: readHttpsUrl(input.logo.url, "logo.url"), alt: input.logo.alt } } : {},
120815
+ mode: input.mode ?? "viewer",
120816
+ ...input.chartPalette ? { chartPalette: input.chartPalette.map(readColor) } : {},
120817
+ ...stamp
120818
+ };
120819
+ return { record, ignored: imported.ignored };
120820
+ }
120821
+ function readDesignSystem(value) {
120822
+ if (value === undefined || value === null)
120823
+ return null;
120824
+ const result = DesignSystemSchema.safeParse(value);
120825
+ if (!result.success)
120826
+ return { invalid: "stored design system is not a valid v1 record" };
120827
+ const parsed = result.data;
120828
+ try {
120829
+ const { record } = buildDesignSystem({
120830
+ status: parsed.status,
120831
+ basePreset: parsed.basePreset,
120832
+ themeTokens: parsed.tokens,
120833
+ fontsHref: parsed.fontsHref,
120834
+ logo: parsed.logo,
120835
+ mode: parsed.mode,
120836
+ chartPalette: parsed.chartPalette,
120837
+ source: parsed.source
120838
+ }, { userId: parsed.updatedBy, agentId: parsed.updatedByAgentId });
120839
+ return { record: { ...record, updatedAt: parsed.updatedAt } };
120840
+ } catch (err) {
120841
+ if (err instanceof DesignSystemError)
120842
+ return { invalid: err.message };
120843
+ throw err;
120844
+ }
120845
+ }
120846
+ var DESIGN_SYSTEM_NAMESPACE = "design-system", DESIGN_SYSTEM_KEY = "org", DESIGN_SYSTEM_PREVIOUS_KEY = "org.prev", FONTS_HOST = "fonts.googleapis.com", UNSAFE_URL_CHARACTERS, DesignSystemError;
120847
+ var init_design_system = __esm(() => {
120848
+ init_types5();
120849
+ init_import();
120850
+ init_presets();
120851
+ UNSAFE_URL_CHARACTERS = /["'<>\s\\]/;
120852
+ DesignSystemError = class DesignSystemError extends Error {
120853
+ name = "DesignSystemError";
120854
+ };
120855
+ });
120856
+
120857
+ // src/be/design-system.ts
120858
+ function toStored(value) {
120859
+ const read = readDesignSystem(value);
120860
+ if (!read)
120861
+ return { status: "none" };
120862
+ if ("invalid" in read)
120863
+ return { status: "invalid", reason: read.invalid };
120864
+ return { status: read.record.status, record: read.record };
120865
+ }
120866
+ async function getDesignSystem() {
120867
+ const [current, previous] = await Promise.all([
120868
+ getKv2(DESIGN_SYSTEM_NAMESPACE, DESIGN_SYSTEM_KEY),
120869
+ getKv2(DESIGN_SYSTEM_NAMESPACE, DESIGN_SYSTEM_PREVIOUS_KEY)
120870
+ ]);
120871
+ return { current: toStored(current?.value), previous: toStored(previous?.value) };
120872
+ }
120873
+ async function getActiveDesignSystem() {
120874
+ const stored = toStored((await getKv2(DESIGN_SYSTEM_NAMESPACE, DESIGN_SYSTEM_KEY))?.value);
120875
+ return "record" in stored && stored.record.status === "active" ? stored.record : null;
120876
+ }
120877
+ async function saveDesignSystem(record) {
120878
+ await getDbClient2().transaction(async () => {
120879
+ const current = await getKv2(DESIGN_SYSTEM_NAMESPACE, DESIGN_SYSTEM_KEY);
120880
+ if (current) {
120881
+ await upsertKv2({
120882
+ namespace: DESIGN_SYSTEM_NAMESPACE,
120883
+ key: DESIGN_SYSTEM_PREVIOUS_KEY,
120884
+ value: current.value,
120885
+ valueType: "json"
120886
+ });
120887
+ }
120888
+ await upsertKv2({
120889
+ namespace: DESIGN_SYSTEM_NAMESPACE,
120890
+ key: DESIGN_SYSTEM_KEY,
120891
+ value: record,
120892
+ valueType: "json"
120893
+ });
120894
+ });
120895
+ }
120896
+ var init_design_system2 = __esm(() => {
120897
+ init_design_system();
120898
+ init_db4();
120899
+ });
120900
+
120901
+ // src/pages/version.ts
120902
+ async function snapshotPage(pageId, changedByAgentId) {
120903
+ const page = await getPage2(pageId);
120904
+ if (!page) {
120905
+ throw new Error(`Page ${pageId} not found — cannot create snapshot`);
120906
+ }
120907
+ const nextVersion = await getPageEditCounter(pageId);
120908
+ const snapshot = {
120909
+ title: page.title,
120910
+ description: page.description,
120911
+ contentType: page.contentType,
120912
+ authMode: page.authMode,
120913
+ passwordHash: page.passwordHash,
120914
+ body: page.body,
120915
+ needsCredentials: page.needsCredentials,
120916
+ theme: page.theme,
120917
+ themeTokens: page.themeTokens,
120918
+ designVersion: page.designVersion
120919
+ };
120920
+ return createPageVersion2({
120921
+ pageId,
120922
+ version: nextVersion,
120923
+ snapshot,
120924
+ changedByAgentId
120925
+ });
120926
+ }
120927
+ var init_version3 = __esm(() => {
120928
+ init_db4();
120929
+ init_page_versions();
120930
+ });
120931
+
120597
120932
  // src/themes/page-fields.ts
120598
120933
  function readThemeFields(input) {
120599
120934
  if (typeof input.theme === "string" && !isThemePresetId(input.theme)) {
@@ -120667,6 +121002,7 @@ var SWARM_CLASS, COLOR_TOKEN_REFERENCE, PAGE_COLOR_TOKENS, registerCreatePageToo
120667
121002
  colorLiteralCount: number2().optional(),
120668
121003
  usesDesignSystem: boolean().optional(),
120669
121004
  lightOnlyColors: boolean().optional(),
121005
+ designSystemStatus: string2().optional(),
120670
121006
  movedSessionRootId: string2().optional()
120671
121007
  })
120672
121008
  }, async (input, requestInfo, _meta) => {
@@ -120758,6 +121094,7 @@ var SWARM_CLASS, COLOR_TOKEN_REFERENCE, PAGE_COLOR_TOKENS, registerCreatePageToo
120758
121094
  const designFlags = fresh.contentType === "text/html" ? {
120759
121095
  usesDesignSystem: typeof input.theme === "string" || Boolean(input.themeTokens) || bodyUsesDesignSystem(fresh.body),
120760
121096
  lightOnlyColors: hasLightOnlyColors(fresh.themeTokens),
121097
+ designSystemStatus: (await getDesignSystem()).current.status,
120761
121098
  ...fresh.designVersion >= 2 ? { colorLiteralCount: countColorLiterals(fresh.body) } : {}
120762
121099
  } : {};
120763
121100
  const { ignored } = themeFields;
@@ -120793,6 +121130,7 @@ var init_create_page = __esm(() => {
120793
121130
  init_caller_session_group();
120794
121131
  init_db4();
120795
121132
  init_page_versions();
121133
+ init_design_system2();
120796
121134
  init_color_literals();
120797
121135
  init_version3();
120798
121136
  init_page_fields();
@@ -123856,6 +124194,87 @@ var init_delete_page = __esm(() => {
123856
124194
  });
123857
124195
  });
123858
124196
 
124197
+ // src/tools/design-system.ts
124198
+ var outputSchema, registerDesignSystemTools = (server) => {
124199
+ const register = createToolRegistrar(server);
124200
+ register("design-system-get", {
124201
+ title: "Get the org design system",
124202
+ description: '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.',
124203
+ annotations: { readOnlyHint: true },
124204
+ inputSchema: object2({}),
124205
+ outputSchema
124206
+ }, async () => {
124207
+ const { current, previous } = await getDesignSystem();
124208
+ return toolOk(`Design system status: ${current.status}.`, {
124209
+ data: {
124210
+ status: current.status,
124211
+ ..."record" in current ? { designSystem: current.record } : {},
124212
+ ..."reason" in current ? { invalidReason: current.reason } : {},
124213
+ ..."record" in previous ? { previous: previous.record } : {}
124214
+ }
124215
+ });
124216
+ });
124217
+ register("design-system-set", {
124218
+ title: "Set the org design system",
124219
+ description: '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).',
124220
+ annotations: { destructiveHint: false },
124221
+ rbac: { permission: "design-system.write" },
124222
+ inputSchema: DesignSystemInputSchema.extend({
124223
+ dryRun: boolean().optional().describe("Validate and return the normalized record without saving.")
124224
+ }),
124225
+ outputSchema
124226
+ }, async ({ dryRun, ...input }, requestInfo) => {
124227
+ if (!requestInfo.agentId)
124228
+ return toolErr('Agent ID not found. Set the "X-Agent-ID" header.');
124229
+ const agent = await getAgentById2(requestInfo.agentId);
124230
+ const decision = can({
124231
+ principal: { kind: "agent", agentId: requestInfo.agentId, isLead: agent?.isLead ?? false },
124232
+ verb: "design-system.write",
124233
+ source: "mcp"
124234
+ });
124235
+ if (!decision.allow)
124236
+ return toolErr(decision.reason);
124237
+ const userId = await resolveTaskAuditUserId(requestInfo.sourceTaskId, requestInfo.agentId);
124238
+ let built;
124239
+ try {
124240
+ built = buildDesignSystem(input, { userId, agentId: requestInfo.agentId });
124241
+ } catch (err) {
124242
+ if (err instanceof DesignSystemError)
124243
+ return toolErr(err.message);
124244
+ throw err;
124245
+ }
124246
+ if (!dryRun)
124247
+ await saveDesignSystem(built.record);
124248
+ const { record, ignored } = built;
124249
+ return toolOk(`${dryRun ? "Validated" : "Saved"} ${record.status} design system (basePreset=${record.basePreset}, mode=${record.mode}).` + (ignored.length > 0 ? ` Ignored tokens: ${ignored.join(", ")}.` : ""), {
124250
+ data: {
124251
+ status: record.status,
124252
+ designSystem: record,
124253
+ saved: !dryRun,
124254
+ ...ignored.length > 0 ? { ignoredTokens: ignored } : {}
124255
+ }
124256
+ });
124257
+ });
124258
+ };
124259
+ var init_design_system3 = __esm(() => {
124260
+ init_zod();
124261
+ init_audit_user();
124262
+ init_db4();
124263
+ init_design_system2();
124264
+ init_rbac();
124265
+ init_design_system();
124266
+ init_utils();
124267
+ init_types5();
124268
+ outputSchema = swarmToolOutputSchema({
124269
+ status: string2().optional(),
124270
+ designSystem: unknown().optional(),
124271
+ previous: unknown().optional(),
124272
+ invalidReason: string2().optional(),
124273
+ ignoredTokens: array2(string2()).optional(),
124274
+ saved: boolean().optional()
124275
+ });
124276
+ });
124277
+
123859
124278
  // src/tools/script-common.ts
123860
124279
  function stripAnsi(text) {
123861
124280
  return text.replace(/\x1b\[[0-9;]*m/g, "");
@@ -124814,6 +125233,10 @@ var init_kv_reserved_namespaces = __esm(() => {
124814
125233
  RESERVED_FAMILIES = new Map([
124815
125234
  ["apps", "namespace is reserved for swarm apps; use the app row endpoints"],
124816
125235
  ["comb", "namespace is reserved for Comb; use POST /api/comb/review-batches"],
125236
+ [
125237
+ "design-system",
125238
+ "namespace is reserved for the org design system; use design-system-set or PUT /api/design-system"
125239
+ ],
124817
125240
  ["heartbeat-checklist", "namespace is reserved for heartbeat checklist receipts"],
124818
125241
  ["worker", "namespace is reserved for worker nudges"],
124819
125242
  ["slack-external-alert", "namespace is reserved for Slack external channel alerts"],
@@ -125784,7 +126207,7 @@ var init_mcp_server_delete = __esm(() => {
125784
126207
  var registerMcpServerGetTool = (server) => {
125785
126208
  createToolRegistrar(server)("mcp-server-get", {
125786
126209
  title: "Get MCP Server",
125787
- annotations: { destructiveHint: false },
126210
+ annotations: { readOnlyHint: true },
125788
126211
  description: "Get MCP server details by ID or name. Name resolution uses scope cascade: agent > swarm > global.",
125789
126212
  inputSchema: object2({
125790
126213
  id: string2().optional().describe("MCP server ID"),
@@ -125898,7 +126321,7 @@ function renderServerLines(servers) {
125898
126321
  var registerMcpServerListTool = (server) => {
125899
126322
  createToolRegistrar(server)("mcp-server-list", {
125900
126323
  title: "List MCP Servers",
125901
- annotations: { destructiveHint: false },
126324
+ annotations: { readOnlyHint: true },
125902
126325
  description: "List MCP servers with optional filters. Use installedOnly to see servers installed for the calling agent.",
125903
126326
  inputSchema: object2({
125904
126327
  scope: _enum2(["global", "swarm", "agent"]).optional().describe("Filter by scope"),
@@ -128254,13 +128677,14 @@ var registerRegisterChatChannelTool = (server) => {
128254
128677
  createToolRegistrar(server)("register-chat-channel", {
128255
128678
  title: "Route a chat channel to an agent or workflow",
128256
128679
  annotations: { idempotentHint: true },
128257
- description: "Lead-only. Route every swarm-addressed message from one Chat SDK channel (a Telegram group, Slack channel, Discord channel or Teams chat) to a fixed agent or workflow instead of the lead. Give exactly one of agentId or workflowId. A swarm#<agentId> token in a message still wins over the mapping. Remove it with unregister-chat-channel.",
128680
+ description: "Lead-only. Route every swarm-addressed message from one Chat SDK channel (a Telegram group, Slack channel, Discord channel or Teams chat) to a fixed agent or workflow instead of the lead. Give exactly one of agentId or workflowId. For Telegram, defaultThreadId sets the topic used by channel-only chat-post calls. Re-registering replaces the mapping; omit defaultThreadId to clear it. A swarm#<agentId> token in a message still wins over the mapping. Remove it with unregister-chat-channel.",
128258
128681
  inputSchema: object2({
128259
128682
  adapter: _enum2(CHAT_SDK_ADAPTER_NAMES).describe("Chat SDK adapter name."),
128260
128683
  channelId: string2().min(1).describe("SDK channel id, such as telegram:-100123 or slack:C123 (prefix optional)."),
128261
128684
  agentId: string2().optional().describe("Agent that receives the channel's tasks."),
128262
128685
  workflowId: string2().optional().describe("Workflow whose webhook trigger receives the channel's messages."),
128263
- name: string2().max(200).optional().describe("Display name for the mapping.")
128686
+ name: string2().max(200).optional().describe("Display name for the mapping."),
128687
+ defaultThreadId: string2().min(1).optional().describe("Telegram topic used when chat-post gives only channelId, such as telegram:-100123:42. Must belong to this channel. Explicit threadId and chat-reply ignore this default.")
128264
128688
  }),
128265
128689
  outputSchema: swarmToolOutputSchema({
128266
128690
  yourAgentId: string2().optional(),
@@ -128268,11 +128692,12 @@ var registerRegisterChatChannelTool = (server) => {
128268
128692
  mapping: looseObject({
128269
128693
  agentId: string2().optional(),
128270
128694
  workflowId: string2().optional(),
128695
+ defaultThreadId: string2().optional(),
128271
128696
  name: string2().optional(),
128272
128697
  createdAt: string2().optional()
128273
128698
  }).optional()
128274
128699
  })
128275
- }, async ({ adapter, channelId, agentId, workflowId, name }, requestInfo) => {
128700
+ }, async ({ adapter, channelId, agentId, workflowId, name, defaultThreadId }, requestInfo) => {
128276
128701
  const data = { yourAgentId: requestInfo.agentId };
128277
128702
  try {
128278
128703
  if (!await canManageChatChannels(requestInfo)) {
@@ -128293,6 +128718,7 @@ var registerRegisterChatChannelTool = (server) => {
128293
128718
  ...agentId ? { agentId } : {},
128294
128719
  ...workflowId ? { workflowId } : {},
128295
128720
  ...name ? { name } : {},
128721
+ ...defaultThreadId ? { defaultThreadId } : {},
128296
128722
  createdAt: new Date().toISOString()
128297
128723
  };
128298
128724
  const key = await putChatChannelMapping(adapter, channelId, mapping);
@@ -128333,7 +128759,7 @@ var registerRegisterChatChannelTool = (server) => {
128333
128759
  var init_register_chat_channel = __esm(() => {
128334
128760
  init_zod();
128335
128761
  init_db4();
128336
- init_config();
128762
+ init_config2();
128337
128763
  init_logger();
128338
128764
  init_router2();
128339
128765
  init_rbac();
@@ -128557,7 +128983,7 @@ async function markKapsoMessageSeen(messageId) {
128557
128983
  });
128558
128984
  }
128559
128985
  var KAPSO_NUMBERS_NAMESPACE = "integrations:kapso:numbers", KAPSO_DEDUPE_NAMESPACE = "integrations:kapso:dedupe", KAPSO_DEDUPE_TTL_MS, DEFAULT_KAPSO_API_BASE_URL = "https://api.kapso.ai";
128560
- var init_config2 = __esm(() => {
128986
+ var init_config3 = __esm(() => {
128561
128987
  init_db4();
128562
128988
  KAPSO_DEDUPE_TTL_MS = 24 * 60 * 60 * 1000;
128563
128989
  });
@@ -128694,7 +129120,7 @@ var init_register_kapso_number = __esm(() => {
128694
129120
  init_zod();
128695
129121
  init_db4();
128696
129122
  init_client();
128697
- init_config2();
129123
+ init_config3();
128698
129124
  init_rbac();
128699
129125
  init_utils();
128700
129126
  init_constants3();
@@ -129056,7 +129482,7 @@ function getCombConfig() {
129056
129482
  driveId: getAgentFsDefaultDriveId() ?? null
129057
129483
  };
129058
129484
  }
129059
- var init_config3 = __esm(() => {
129485
+ var init_config4 = __esm(() => {
129060
129486
  init_constants3();
129061
129487
  });
129062
129488
 
@@ -129238,7 +129664,7 @@ var init_auth2 = __esm(() => {
129238
129664
  init_db4();
129239
129665
  init_rbac_roles();
129240
129666
  init_session_shares();
129241
- init_config3();
129667
+ init_config4();
129242
129668
  init_kv_overflow();
129243
129669
  init_kv_reserved_namespaces();
129244
129670
  init_rbac();
@@ -139436,7 +139862,7 @@ async function refusing2(agentId, run) {
139436
139862
  throw error;
139437
139863
  }
139438
139864
  }
139439
- var objectOutputSchema2, CellValue, Grid, RANGE_HELP = "A1 range such as `Tasks!B2:C3`, `A1:C10` (first tab), `'My tab'!A:A` (whole column, capped to the used range) or `B2`.", dataShape, outputSchema, ID2 = "Object id (from sheet-create or sheet-list).", PATH = "Drive path of the `.sheet.json` file, instead of `id`.", WRITE, registerSheetCreateTool = (server) => {
139865
+ var objectOutputSchema2, CellValue, Grid, RANGE_HELP = "A1 range such as `Tasks!B2:C3`, `A1:C10` (first tab), `'My tab'!A:A` (whole column, capped to the used range) or `B2`.", dataShape, outputSchema2, ID2 = "Object id (from sheet-create or sheet-list).", PATH = "Drive path of the `.sheet.json` file, instead of `id`.", WRITE, registerSheetCreateTool = (server) => {
139440
139866
  createToolRegistrar(server)("sheet-create", {
139441
139867
  title: "Create sheet",
139442
139868
  annotations: WRITE,
@@ -139446,7 +139872,7 @@ var objectOutputSchema2, CellValue, Grid, RANGE_HELP = "A1 range such as `Tasks!
139446
139872
  title: string2().max(200).optional(),
139447
139873
  tabs: array2(object2({ name: string2().min(1).max(31), rows: Grid.optional() })).optional().describe("Tabs to create, each with an optional `rows` grid written from A1.")
139448
139874
  }),
139449
- outputSchema
139875
+ outputSchema: outputSchema2
139450
139876
  }, async ({ path, title, tabs }, requestInfo) => {
139451
139877
  const result = await refusing2(requestInfo.agentId, () => createSheet({ agentId: requestInfo.agentId, path, title, tabs }));
139452
139878
  if ("error" in result)
@@ -139465,7 +139891,7 @@ var objectOutputSchema2, CellValue, Grid, RANGE_HELP = "A1 range such as `Tasks!
139465
139891
  id: string2().min(1).optional().describe(ID2),
139466
139892
  path: string2().min(1).optional().describe(PATH)
139467
139893
  }),
139468
- outputSchema
139894
+ outputSchema: outputSchema2
139469
139895
  }, async ({ id, path }, requestInfo) => {
139470
139896
  const result = await refusing2(requestInfo.agentId, () => getSheet({ agentId: requestInfo.agentId, id, path }));
139471
139897
  if ("error" in result)
@@ -139485,7 +139911,7 @@ var objectOutputSchema2, CellValue, Grid, RANGE_HELP = "A1 range such as `Tasks!
139485
139911
  limit: number2().int().positive().max(200).optional(),
139486
139912
  offset: number2().int().nonnegative().optional()
139487
139913
  }),
139488
- outputSchema
139914
+ outputSchema: outputSchema2
139489
139915
  }, async ({ prefix, limit, offset }, requestInfo) => {
139490
139916
  const result = await refusing2(requestInfo.agentId, () => listSheets({ agentId: requestInfo.agentId, prefix, limit, offset }));
139491
139917
  if ("error" in result)
@@ -139508,7 +139934,7 @@ var objectOutputSchema2, CellValue, Grid, RANGE_HELP = "A1 range such as `Tasks!
139508
139934
  range: string2().min(1).describe(RANGE_HELP),
139509
139935
  formulas: boolean().optional().describe("Also return `formulas[][]`: the formula text where a cell has one, else the value.")
139510
139936
  }),
139511
- outputSchema
139937
+ outputSchema: outputSchema2
139512
139938
  }, async ({ id, path, range, formulas }, requestInfo) => {
139513
139939
  const result = await refusing2(requestInfo.agentId, () => getSheetRange({ agentId: requestInfo.agentId, id, path, range, formulas }));
139514
139940
  if ("error" in result)
@@ -139528,7 +139954,7 @@ var objectOutputSchema2, CellValue, Grid, RANGE_HELP = "A1 range such as `Tasks!
139528
139954
  range: string2().min(1).describe(RANGE_HELP),
139529
139955
  values: Grid.describe("Rows of cell values, all the same length (at most 10,000 cells).")
139530
139956
  }),
139531
- outputSchema
139957
+ outputSchema: outputSchema2
139532
139958
  }, async ({ id, path, range, values }, requestInfo) => {
139533
139959
  const result = await refusing2(requestInfo.agentId, () => setSheetRange({ agentId: requestInfo.agentId, id, path, range, values }));
139534
139960
  if ("error" in result)
@@ -139547,7 +139973,7 @@ var objectOutputSchema2, CellValue, Grid, RANGE_HELP = "A1 range such as `Tasks!
139547
139973
  tab: string2().min(1).describe("Tab name."),
139548
139974
  rows: Grid.describe("Rows to append (at most 10,000 cells).")
139549
139975
  }),
139550
- outputSchema
139976
+ outputSchema: outputSchema2
139551
139977
  }, async ({ id, path, tab, rows }, requestInfo) => {
139552
139978
  const result = await refusing2(requestInfo.agentId, () => appendSheetRows({ agentId: requestInfo.agentId, id, path, tab, rows }));
139553
139979
  if ("error" in result)
@@ -139566,7 +139992,7 @@ var objectOutputSchema2, CellValue, Grid, RANGE_HELP = "A1 range such as `Tasks!
139566
139992
  path: string2().min(1).optional().describe(PATH),
139567
139993
  range: string2().min(1).describe(RANGE_HELP)
139568
139994
  }),
139569
- outputSchema
139995
+ outputSchema: outputSchema2
139570
139996
  }, async ({ id, path, range }, requestInfo) => {
139571
139997
  const result = await refusing2(requestInfo.agentId, () => clearSheetRange({ agentId: requestInfo.agentId, id, path, range }));
139572
139998
  if ("error" in result)
@@ -139587,7 +140013,7 @@ var objectOutputSchema2, CellValue, Grid, RANGE_HELP = "A1 range such as `Tasks!
139587
140013
  name: string2().min(1).max(31).describe("New tab name."),
139588
140014
  after: string2().optional().describe("Insert after this tab; default: at the end.")
139589
140015
  }),
139590
- outputSchema
140016
+ outputSchema: outputSchema2
139591
140017
  }, async ({ id, path, name, after }, requestInfo) => {
139592
140018
  const result = await refusing2(requestInfo.agentId, () => addSheetTab({ agentId: requestInfo.agentId, id, path, name, after }));
139593
140019
  if ("error" in result)
@@ -139606,7 +140032,7 @@ var objectOutputSchema2, CellValue, Grid, RANGE_HELP = "A1 range such as `Tasks!
139606
140032
  path: string2().min(1).describe("Drive path for the new sheet, ending in `.sheet.json`."),
139607
140033
  title: string2().max(200).optional()
139608
140034
  }),
139609
- outputSchema
140035
+ outputSchema: outputSchema2
139610
140036
  }, async ({ sourcePath, path, title }, requestInfo) => {
139611
140037
  const result = await refusing2(requestInfo.agentId, () => importSheetXlsx({ agentId: requestInfo.agentId, sourcePath, path, title }));
139612
140038
  if ("error" in result)
@@ -139625,7 +140051,7 @@ var objectOutputSchema2, CellValue, Grid, RANGE_HELP = "A1 range such as `Tasks!
139625
140051
  targetPath: string2().min(1).describe("Drive path for the new file, ending in `.xlsx`."),
139626
140052
  overwrite: boolean().optional().describe("Replace `targetPath` when it exists.")
139627
140053
  }),
139628
- outputSchema
140054
+ outputSchema: outputSchema2
139629
140055
  }, async ({ id, path, targetPath, overwrite }, requestInfo) => {
139630
140056
  const result = await refusing2(requestInfo.agentId, () => exportSheetXlsx({ agentId: requestInfo.agentId, id, path, targetPath, overwrite }));
139631
140057
  if ("error" in result)
@@ -139667,7 +140093,7 @@ var init_sheets = __esm(() => {
139667
140093
  path: string2().optional(),
139668
140094
  dropped: array2(string2()).optional()
139669
140095
  };
139670
- outputSchema = swarmToolOutputSchema(dataShape);
140096
+ outputSchema2 = swarmToolOutputSchema(dataShape);
139671
140097
  WRITE = { readOnlyHint: false, idempotentHint: false };
139672
140098
  });
139673
140099
 
@@ -139824,7 +140250,7 @@ var init_skill_name_resolution = __esm(() => {
139824
140250
  var registerSkillGetTool = (server) => {
139825
140251
  createToolRegistrar(server)("skill-get", {
139826
140252
  title: "Get Skill",
139827
- annotations: { destructiveHint: false },
140253
+ annotations: { readOnlyHint: true },
139828
140254
  description: "Get full skill content by ID or name. Name resolution checks agent scope first, then swarm, then global. In swarm scope the ownerless skill wins, then your own, then the only agent-owned one; when several other agents own that name, it errors with their IDs: pass skillId instead.",
139829
140255
  inputSchema: object2({
139830
140256
  skillId: string2().optional().describe("Skill ID"),
@@ -139878,7 +140304,7 @@ var init_skill_get = __esm(() => {
139878
140304
  var registerSkillGetFileTool = (server) => {
139879
140305
  createToolRegistrar(server)("skill-get-file", {
139880
140306
  title: "Get Skill File",
139881
- annotations: { destructiveHint: false },
140307
+ annotations: { readOnlyHint: true },
139882
140308
  description: "Fetch a bundled reference file from a complex skill by skillId and relative path. Use this when the file is not available on disk.",
139883
140309
  inputSchema: object2({
139884
140310
  skillId: string2().describe("Skill ID"),
@@ -140099,7 +140525,7 @@ function renderSkillList(skills) {
140099
140525
  var registerSkillListTool = (server) => {
140100
140526
  createToolRegistrar(server)("skill-list", {
140101
140527
  title: "List Skills",
140102
- annotations: { destructiveHint: false },
140528
+ annotations: { readOnlyHint: true },
140103
140529
  description: "List available skills with optional filters.",
140104
140530
  inputSchema: object2({
140105
140531
  type: _enum2(["remote", "personal"]).optional().describe("Filter by type"),
@@ -140229,7 +140655,7 @@ function renderSkillList2(skills) {
140229
140655
  var registerSkillSearchTool = (server) => {
140230
140656
  createToolRegistrar(server)("skill-search", {
140231
140657
  title: "Search Skills",
140232
- annotations: { destructiveHint: false },
140658
+ annotations: { readOnlyHint: true },
140233
140659
  description: "Search skills by keyword (name and description).",
140234
140660
  inputSchema: object2({
140235
140661
  query: string2().min(1).describe("Search query"),
@@ -143122,7 +143548,7 @@ async function readScriptActionAllowlist() {
143122
143548
  const [row] = await getSwarmConfigs2({ scope: "global", key: UI_SPEC_SCRIPT_ACTIONS_KEY });
143123
143549
  if (row)
143124
143550
  return row.value;
143125
- const { getDeploymentEnvValue } = await import("./core-2b8bv6ny.js");
143551
+ const { getDeploymentEnvValue } = await import("./core-gsvj5f3z.js");
143126
143552
  return getDeploymentEnvValue(UI_SPEC_SCRIPT_ACTIONS_KEY);
143127
143553
  }
143128
143554
  async function loadScriptActionLookups() {
@@ -144756,7 +145182,7 @@ async function recomputeSessionCost(input, lookupRate) {
144756
145182
  }
144757
145183
  return {
144758
145184
  totalCostUsd: pricedCostUsd + sessionFeesUsd,
144759
- costSource: "pricing-table",
145185
+ costSource: input.estimated ? "estimated" : "pricing-table",
144760
145186
  modelBreakdown: modelUsageEntries ? pricedModels : undefined
144761
145187
  };
144762
145188
  }
@@ -145009,7 +145435,7 @@ async function emitBudgetRefusalSideEffects(ctx, inserted) {
145009
145435
  console.warn(`[budget-refusal-notify] Failed to create follow-up task for budget refusal (task=${ctx.task.id.slice(0, 8)}): ${err}`);
145010
145436
  }
145011
145437
  }
145012
- import("./event-bus-08t2b4y2.js").then(({ workflowEventBus }) => {
145438
+ import("./event-bus-7gbsr0g4.js").then(({ workflowEventBus }) => {
145013
145439
  workflowEventBus.emit("task.budget_refused", {
145014
145440
  taskId: ctx.task.id,
145015
145441
  agentId: ctx.agentId,
@@ -146017,7 +146443,7 @@ async function sendAndFormat(params, agentId, contextMessageId) {
146017
146443
  return toolErr(errorMessage, { data: { yourAgentId: agentId } });
146018
146444
  }
146019
146445
  }
146020
- var SESSION_WINDOW_HINT = 'Outside the 24h WhatsApp session window — free-form text is rejected. Use a pre-approved template message (see the `kapso-whatsapp` skill, "Send a template").', outputSchema2, registerSendWhatsappMessageTool = (server) => {
146446
+ var SESSION_WINDOW_HINT = 'Outside the 24h WhatsApp session window — free-form text is rejected. Use a pre-approved template message (see the `kapso-whatsapp` skill, "Send a template").', outputSchema3, registerSendWhatsappMessageTool = (server) => {
146021
146447
  createToolRegistrar(server)("send-whatsapp-message", {
146022
146448
  title: "Send WhatsApp Message",
146023
146449
  annotations: { openWorldHint: true },
@@ -146028,7 +146454,7 @@ var SESSION_WINDOW_HINT = 'Outside the 24h WhatsApp session window — free-form
146028
146454
  body: string2().min(1).describe("Message text."),
146029
146455
  previewUrl: boolean().optional().describe("Render a link preview for URLs in the body (default false).")
146030
146456
  }),
146031
- outputSchema: outputSchema2
146457
+ outputSchema: outputSchema3
146032
146458
  }, async ({ phoneNumberId, to, body, previewUrl }, requestInfo) => {
146033
146459
  return sendAndFormat({ phoneNumberId, to, body, previewUrl }, requestInfo.agentId, undefined);
146034
146460
  });
@@ -146043,7 +146469,7 @@ var SESSION_WINDOW_HINT = 'Outside the 24h WhatsApp session window — free-form
146043
146469
  inReplyTo: string2().min(1).describe("The inbound WAMID to quote-reply (set as context.message_id)."),
146044
146470
  body: string2().min(1).describe("Reply text.")
146045
146471
  }),
146046
- outputSchema: outputSchema2
146472
+ outputSchema: outputSchema3
146047
146473
  }, async ({ phoneNumberId, to, inReplyTo, body }, requestInfo) => {
146048
146474
  return sendAndFormat({ phoneNumberId, to, body }, requestInfo.agentId, inReplyTo);
146049
146475
  });
@@ -146051,9 +146477,9 @@ var SESSION_WINDOW_HINT = 'Outside the 24h WhatsApp session window — free-form
146051
146477
  var init_whatsapp_message = __esm(() => {
146052
146478
  init_zod();
146053
146479
  init_client();
146054
- init_config2();
146480
+ init_config3();
146055
146481
  init_utils();
146056
- outputSchema2 = swarmToolOutputSchema({
146482
+ outputSchema3 = swarmToolOutputSchema({
146057
146483
  yourAgentId: string2().optional(),
146058
146484
  messageId: string2().optional(),
146059
146485
  sessionWindowExpired: boolean().optional()
@@ -146277,7 +146703,7 @@ var init_delete_workflow = __esm(() => {
146277
146703
  var registerGetWorkflowTool = (server) => {
146278
146704
  createToolRegistrar(server)("get-workflow", {
146279
146705
  title: "Get Workflow",
146280
- annotations: { destructiveHint: false },
146706
+ annotations: { readOnlyHint: true },
146281
146707
  description: "Get a workflow by ID, including its definition, triggers, cooldown, input, and auto-generated edges for UI rendering.",
146282
146708
  inputSchema: object2({
146283
146709
  id: string2().uuid().describe("Workflow ID")
@@ -146337,7 +146763,7 @@ function renderSteps(steps) {
146337
146763
  var STEP_VALUE_CAP = 400, registerGetWorkflowRunTool = (server) => {
146338
146764
  createToolRegistrar(server)("get-workflow-run", {
146339
146765
  title: "Get Workflow Run",
146340
- annotations: { destructiveHint: false },
146766
+ annotations: { readOnlyHint: true },
146341
146767
  description: "Get details of a workflow run by ID, including all steps and their statuses.",
146342
146768
  inputSchema: object2({
146343
146769
  id: string2().uuid().describe("Workflow run ID"),
@@ -146428,7 +146854,7 @@ async function listWorkflowRunsHandler({
146428
146854
  var DEFAULT_RUN_LIMIT = 20, TRIGGER_DATA_SUMMARY_CAP = 400, listWorkflowRunsInputSchema, registerListWorkflowRunsTool = (server) => {
146429
146855
  createToolRegistrar(server)("list-workflow-runs", {
146430
146856
  title: "List Workflow Runs",
146431
- annotations: { destructiveHint: false },
146857
+ annotations: { readOnlyHint: true },
146432
146858
  description: "List execution runs for a workflow with offset pagination (default 20, max 100), optionally filtered by status. Returns SLIM rows WITHOUT the full `context` or trigger data — each row carries a bounded `triggerDataSummary` instead. To inspect a run's context and steps, call `get-workflow-run` by id, or pass `includeContext: true` here.",
146433
146859
  inputSchema: listWorkflowRunsInputSchema,
146434
146860
  outputSchema: swarmToolOutputSchema({
@@ -146461,7 +146887,7 @@ var init_list_workflow_runs = __esm(() => {
146461
146887
  var registerListWorkflowsTool = (server) => {
146462
146888
  createToolRegistrar(server)("list-workflows", {
146463
146889
  title: "List Workflows",
146464
- annotations: { destructiveHint: false },
146890
+ annotations: { readOnlyHint: true },
146465
146891
  description: "List all automation workflows, optionally filtered by enabled status. Returns SLIM rows WITHOUT the full `definition` (DAG) — each row carries a `nodeCount` instead. To inspect or patch a workflow's nodes/triggers, call `get-workflow` by id, or pass `includeFull: true` here.",
146466
146892
  inputSchema: object2({
146467
146893
  enabled: boolean().optional().describe("Filter by enabled status (omit to return all)"),
@@ -147334,6 +147760,7 @@ async function createServer(opts = {}) {
147334
147760
  registerAppUpsertTool(server);
147335
147761
  registerCreatePageTool(server);
147336
147762
  registerDeletePageTool(server);
147763
+ registerDesignSystemTools(server);
147337
147764
  }
147338
147765
  if (hasCapability("metrics")) {
147339
147766
  registerCreateMetricTool(server);
@@ -147439,11 +147866,11 @@ var init_server = __esm(() => {
147439
147866
  init_steering2();
147440
147867
  init_task_reactions();
147441
147868
  init_core();
147442
- init_config();
147869
+ init_config2();
147443
147870
  init_mcp_limits();
147444
147871
  init_resolver();
147445
147872
  init_rbac();
147446
- init_config4();
147873
+ init_config5();
147447
147874
  init_left_threads();
147448
147875
  init_accept_steer();
147449
147876
  init_app_action_run();
@@ -147474,6 +147901,7 @@ var init_server = __esm(() => {
147474
147901
  init_defer_task();
147475
147902
  init_delete_channel();
147476
147903
  init_delete_page();
147904
+ init_design_system3();
147477
147905
  init_extension_activate_version();
147478
147906
  init_extension_catalog();
147479
147907
  init_extension_delete();
@@ -147606,4 +148034,4 @@ var init_server = __esm(() => {
147606
148034
  loggedToolAllowlistWarnings = new Set;
147607
148035
  });
147608
148036
 
147609
- export { safeParse, getObjectShape, getLiteralValue, init_zod_compat, LATEST_PROTOCOL_VERSION, DEFAULT_NEGOTIATED_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, isJSONRPCRequest, isJSONRPCResultResponse, ErrorCode, isJSONRPCErrorResponse, JSONRPCMessageSchema, EmptyResultSchema, isInitializeRequest, InitializeResultSchema, CreateTaskResultSchema, ListResourcesResultSchema, ListResourceTemplatesResultSchema, ReadResourceResultSchema, ResourceListChangedNotificationSchema, ListPromptsResultSchema, GetPromptResultSchema, PromptListChangedNotificationSchema, ListToolsResultSchema, CallToolResultSchema, ToolListChangedNotificationSchema, ListChangedOptionsBaseSchema, CreateMessageRequestSchema, CreateMessageResultSchema, CreateMessageResultWithToolsSchema, ElicitRequestSchema, ElicitResultSchema, CompleteResultSchema, McpError, init_types, Protocol, mergeCapabilities, init_protocol, AjvJsonSchemaValidator, init_ajv_provider, assertToolsCallTaskCapability, assertClientRequestTaskCapability, init_helpers, McpServer, init_mcp, referencedBundlePaths, skillDirs, init_manifest_format, recoverIncompleteRuns, init_recovery, handleWebhookTrigger, verifyHmacSignature, decodeStandardWebhookSecret, verifyStandardWebhookSignature, verifyTokenEquality, WebhookError, init_triggers, snapshotAndUpdateWorkflow, init_version, applyPreTaskCreate, init_apply_task_create, RawLlmConfigSchema, RawLlmOutputSchema, executeRawLlm, init_raw_llm, getExecutorRegistry2, initWorkflows2, init_workflows, isGitHubEnabled, initGitHub, verifyWebhookSignature, getWorkerInstallationToken, init_app, isReservedProviderEvent, init_event_waits, stripSiblingBlock, init_sibling_block, createTaskWithSiblingAwareness, init_sibling_awareness, dispatchScheduleTarget, calculateNextRun2, startScheduler2, stopScheduler2, runScheduleNow2, init_scheduler, ExtensionAssetConflictError, hashOf, scriptHash, liveScriptSpec, liveWorkflowSpec, skillSpecOf, liveSkillSpec, skillHash, init_assets, ExtensionOwnershipError, getExtensionFiles, getExtensionById, getExtensionByName, listExtensions, listExtensionVersions, updateExtensionMeta, listExtensionRuns, init_db, SDK_ALLOWLIST, mcpToolNameForSdkMethod, init_sdk_allowlist, MCP_OVERFLOW_NAMESPACE, mcpOverflowAuthError, init_kv_overflow, hasKvViewArgs, resolveKvView, init_kv_view, COLOR_LITERAL_THRESHOLD, countColorLiterals, init_color_literals, toolErr, createToolRegistrar, init_utils, handleMcpBridge, init_mcp_bridge, Redacted, init_redacted, SCRIPT_SDK_RESPONSE_LIMIT_BYTES, readScriptSdkJsonResponse, init_response_limit, retry, init_retry, ExtensionConfigError, init_loader, ExtensionLifecycleError, setExtensionLoopbackBaseUrl, enableExtension, disableExtension, activateVersion, ExtensionAssetsInvalidError, installExtensionWithAssets, uninstallExtension, reloadExtension, loadEnabledExtensions, stopExtensionRuntime, init_lifecycle, ExtensionAbortedError2, isRegistered2, isExtensionAgentId2, getExtensionBridgeToken2, resolveBridgeCallOrigin2, extensionIdForAgent2, runContext2, registerLoaded2, unregister2, hasNativeToolHandlers2, listRegistered2, dispatchPre2, dispatchPost2, init_dispatcher, resolveIdentity, renderIdentity, init_identity, dismissedNamespace, dismissUnmappedIdentity, restoreUnmappedIdentity, recordUnmappedIdentity, init_unmapped_identities, getDeliveredSlackMessageTs, foldIntoPendingSlackTask, init_slack_fold, MAX_TASK_ATTACHMENT_BYTES, recordTaskAttachmentUpload, scopeFromAttachment, backingProviderId, init_task_attachment_store, transcribeAudioNotes, init_transcription, init_templates, buildEffectiveText, bufferedFileFailures, fetchSlackFiles, createSlackTaskWithFiles, attachSlackFilesToDraft, notifySlackFileFailures, init_inbound_files, pendingWorkForAgent, countPoolRuntimes, computeDesired, init_demand, isRuntimePoolWakeable, isAgentReachable, isAgentOnDemand, init_reachability, isAddressedToOtherUser, broadcastMatches, routeMessage, extractTaskFromMessage, init_router, extractSlackMessageText, slackInboundMessageText, collectSlackMessageFiles, init_message_text, createAdditiveBuffer, init_additive_buffer, isAgentMailEnabled, initAgentMail, verifyAgentMailWebhook, isInboxAllowed, isSenderAllowed, handleMessageReceived, init_agentmail, isAzureDevOpsEnabled, initAzureDevOps, verifyAzureDevOpsWebhook, repointTrackerSyncBySwarmId, init_tracker, isAzureDevOpsUrl, canonicalAzureDevOpsRepoUrl, parseAzureDevOpsRepoUrl, init_azure_devops, createdPullRequestOf, commentedPayloadOf, handlePullRequestCreated, handlePullRequestCommented, handleWorkItemCreated, handleWorkItemUpdated, handleWorkItemCommented, handleWorkItemDeleted, handleWorkItemRestored, initAzureDevOpsOutbound, init_azure_devops2, enqueueAuditRow, enqueueAdmissionRow, flushAuditBuffer, startAuditWriter, stopAuditWriter, startAuditGc, stopAuditGc, init_rbac_audit, getTelemetryIngestAnchor, init_telemetry_ingest_anchor, initApiTelemetry, syncTelemetryEnabled, init_telemetry_enable, isBitbucketEnabled, initBitbucket, verifyBitbucketWebhook, isDuplicateDelivery, markDeliveryProcessed, pullRequestEventOf, pullRequestCommentEventOf, handlePullRequestCreated2, handlePullRequestCommentCreated, handlePullRequestClosed, init_bitbucket, handlePullRequest, handleIssue, handleComment, handlePullRequestReview, handleCheckRun, handleCheckSuite, handleWorkflowRun, init_github, isGitLabEnabled, initGitLab, verifyGitLabWebhook, handleMergeRequest, handleIssue2, handleNote, handlePipeline, init_gitlab, isChatSdkEnabled, getChatSdkConfig, init_config, errorMessage, init_logger, resolveAdapterApiUrl, init_adapters, trackBackground, init_background, TelegramBotApiError, callTelegramBotApi, init_telegram_api, isTrustedTeamsServiceUrl, init_teams_origin, getSessionLabels, rememberSessionLabel, getResourceSessionLabels, init_session_labels, isChatSdkStopping, startChatSdk, getChatInstance, isChatAdapterConfigured, getChatSdkHealth, stopChatSdk, init_runtime, getJiraMetadata, updateJiraMetadata, clearJiraMetadata, init_metadata, registerJiraWebhook, deleteJiraWebhook, init_webhook_lifecycle, isJiraEnabled, initJira, init_app2, handleJiraWebhook, init_webhook, init_jira, handleAgentSessionEvent, handleIssueUpdate, handleIssueDelete, handleAgentSessionPrompted, init_sync, isLinearEnabled, initLinear, init_app3, init_linear, init_slack, verifyPageSession, LEGACY_PAGE_SESSION_COOKIE, isCookieSafePageId, extractPageSession, extractLegacyPageSession, extractAndVerifyCookie, isLocalDevPageRequest, pageSessionSetCookies, init_page_session, resolveHttpRequestAuth, init_auth, getDeploymentEnvValue2, loadGlobalConfigsIntoEnv2, reloadGlobalConfigsAndIntegrations2, scheduleIntegrationsReload2, handleCore2, init_core, runTaskUiScriptAction, init_script_actions, REBOOT_RETRY_PIN_TAG2, getPinCandidateAgent2, resolveLeadOnlyRecoveryAssignment2, getResumeGeneration2, getNextResumeGeneration2, inheritedModelSelection2, nextFallback2, createWorkerTaskFollowUp2, createResumeFollowUp2, createRerouteDecisionTask2, createPoolStarvationDecisionTask2, init_worker_follow_up, MCP_MAX_TOOL_INPUT_ELEMENTS, MCP_MAX_REQUEST_BODY_BYTES, init_mcp_limits, userCtx, init_task_tool_ctx, resolveRequestPrincipal, requestPrincipal, agentFirstPrincipal, requireAuthKind, rejectGuest, init_request_principal, resolveTaskRequester, init_task_requester, handleApps, init_apps, parseScene, init_elements, MAX_OBJECT_BYTES, init_write_object, cancelApprovalRequest, cancelApprovalRequestAndRun, init_approval_cancel, getUserCommsPrefs, init_requester_comms, getTaskDetailsInputSchema, getTaskDetailsOutputSchema, getTaskDetailsHandler, init_get_task_details, cancelTaskInputSchema, cancelTaskOutputSchema, cancelTaskHandler, init_cancel_task, DbQueryTimeoutError, DbQueryConcurrencyCapError, executeReadOnlyQuery, getDbQueryHttpBudgetMs, init_db_query_shared, assertSelectOnlyQuery, executeReadOnlyQueryGated, handleDbQuery, init_db_query, snapshotMetric, init_version2, AssetKeyAuthorizationError, authorizeAssetKeyWrite, init_asset_key_auth, getPageEditCounter, init_page_versions, snapshotPage, init_version3, DEFAULT_THEME_ID, THEME_PRESET_IDS, getThemePreset, init_presets, readThemeFields, init_page_fields, assertOAuthAppUrlsSafe, assertOAuthEgressUrlSafe, init_app_validation, listOAuthPresets, listOAuthPresetIds, getOAuthPreset, hydrateOAuthAppFromPreset, init_presets2, scopedResourceScopeIdSchema, resolveScopedResourceId, init_scoped_resource, MemoryKeyError, init_key_guard, refreshLinks, init_link_resolver, indexMemoryContent, init_index_content, dedupeMemoryDocumentIds, recordMemoryAccesses, recordRetrievals, init_retrieval, ExplicitSelfDuplicateError, applyRating, init_store, shouldPersistAutomaticTaskMemory, init_automatic_task_gate, guardTerminalTaskResultWrite, init_terminal_result_guard, scriptNameSchema, scriptToolOutputSchema, scriptsApiToolResult, init_script_common, getTasksInputSchema, getTasksOutputSchema, getTasksHandler, init_get_tasks, requiresLeadToWrite, reservedNamespaceError, privateNamespaceError, reservedRoomKeyError, init_kv_reserved_namespaces, updateMcpServerChecked, init_mcp_server_checked_update, updateTouchesStdioExecution, init_mcp_server_stdio_gate, canReadMemory, init_access, getLinksForMemory, init_links_store, attachDemotionEvidence, init_demotion_evidence, expandCandidatesWithGraph, init_graph_expansion, isApiDraining, drainApi, init_api_drain, markKapsoMessageRead, sendKapsoReaction, init_client, getKapsoConfig, getKapsoNumberMapping, markKapsoMessageSeen, init_config2, changesMergePolicy, init_repo_merge_policy, updateSwarmRepoChecked, init_repo_checked_update, getCombConfig, init_config3, resolveRoomNamespace, roomRequestInfo, authorizeRoomNamespace, sessionAccessTopic, sessionPresenceRoot, init_auth2, RoomOperationSchema, init_document, removeAwarenessStates, init_awareness, roomTopic, decodeRoomSnapshot, roomView, getRoom, changeRoom, applyRoomUpdate, resetRoom, sweepRooms, closeRooms, removeNamespaceRooms, init_rooms, init_scheduler2, MEMORY_KEYS_DEFAULT_PREFIX, MEMORY_KEYS_MAX_LIMIT, estimateTokens, posteriorMean, listMemoryKeys, checkChunkIntegrity, getMemoryChunks, getPosteriorsByIds, init_key_browser, createEvent, createEventsBatch, getEventCountsFiltered, getEventsFiltered, init_events, mergeScheduleTiming, validateRecurringTiming, changesScheduleTarget, init_validate, renderTypeBlobs, init_script_query_types, renderRunOutput, init_script_run, renderSearchResults, searchSuccessMessage, init_script_search, followUpThreadForSourceTask, evaluateFollowUpRedelegation, init_follow_up_redelegation_guard, checkOutputSchemaShape, sendTaskOutputSchema, sendTaskHandler, init_send_task, setSheetRange, appendSheetRows, clearSheetRange, init_service, steerTaskUserInputSchema, steerTaskOutputSchema, steerTaskHandler, init_steer_task, skipReasonFrom, finalizeSkippedTaskReaction, init_task_skip, IMPROVEMENT_TEXT_MAX, IMPROVEMENT_STATUSES, IMPROVEMENT_SOURCES, ImprovementError, isImprovementsEnabled, getImprovement, listImprovements, createImprovement, approveAndSend, discardImprovement, improvementLeakHints, init_improvements, recomputeSessionCost, init_session_cost_recompute, canClaim, init_budget_admission, emitBudgetRefusalSideEffects, init_budget_refusal_notify, workflowModelErrors, init_model_validation, patchWorkflowDefinition, init_patch_definition, idempotencyKeyHeader, readIdempotencyKey, replayAcceptedOperation, init_idempotency_key, resolveScriptsOnlyMode, init_scripts_only_mode, ALL_CAPABILITIES, hasCapability, getEnabledCapabilities, createServer, init_server };
148037
+ export { safeParse, getObjectShape, getLiteralValue, init_zod_compat, LATEST_PROTOCOL_VERSION, DEFAULT_NEGOTIATED_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, isJSONRPCRequest, isJSONRPCResultResponse, ErrorCode, isJSONRPCErrorResponse, JSONRPCMessageSchema, EmptyResultSchema, isInitializeRequest, InitializeResultSchema, CreateTaskResultSchema, ListResourcesResultSchema, ListResourceTemplatesResultSchema, ReadResourceResultSchema, ResourceListChangedNotificationSchema, ListPromptsResultSchema, GetPromptResultSchema, PromptListChangedNotificationSchema, ListToolsResultSchema, CallToolResultSchema, ToolListChangedNotificationSchema, ListChangedOptionsBaseSchema, CreateMessageRequestSchema, CreateMessageResultSchema, CreateMessageResultWithToolsSchema, ElicitRequestSchema, ElicitResultSchema, CompleteResultSchema, McpError, init_types, Protocol, mergeCapabilities, init_protocol, AjvJsonSchemaValidator, init_ajv_provider, assertToolsCallTaskCapability, assertClientRequestTaskCapability, init_helpers, McpServer, init_mcp, referencedBundlePaths, skillDirs, init_manifest_format, recoverIncompleteRuns, init_recovery, handleWebhookTrigger, verifyHmacSignature, decodeStandardWebhookSecret, verifyStandardWebhookSignature, verifyTokenEquality, WebhookError, init_triggers, snapshotAndUpdateWorkflow, init_version, applyPreTaskCreate, init_apply_task_create, RawLlmConfigSchema, RawLlmOutputSchema, executeRawLlm, init_raw_llm, getExecutorRegistry2, initWorkflows2, init_workflows, isGitHubEnabled, initGitHub, verifyWebhookSignature, getWorkerInstallationToken, init_app, isReservedProviderEvent, init_event_waits, stripSiblingBlock, init_sibling_block, createTaskWithSiblingAwareness, init_sibling_awareness, dispatchScheduleTarget, calculateNextRun2, parseSchedulerIntervalMs2, startScheduler2, stopScheduler2, runScheduleNow2, init_scheduler, ExtensionAssetConflictError, hashOf, scriptHash, liveScriptSpec, liveWorkflowSpec, skillSpecOf, liveSkillSpec, skillHash, init_assets, ExtensionOwnershipError, getExtensionFiles, getExtensionById, getExtensionByName, listExtensions, listExtensionVersions, updateExtensionMeta, listExtensionRuns, init_db, SDK_ALLOWLIST, mcpToolNameForSdkMethod, init_sdk_allowlist, MCP_OVERFLOW_NAMESPACE, mcpOverflowAuthError, init_kv_overflow, hasKvViewArgs, resolveKvView, init_kv_view, COLOR_LITERAL_THRESHOLD, countColorLiterals, init_color_literals, toolErr, createToolRegistrar, init_utils, handleMcpBridge, init_mcp_bridge, Redacted, init_redacted, SCRIPT_SDK_RESPONSE_LIMIT_BYTES, readScriptSdkJsonResponse, init_response_limit, retry, init_retry, ExtensionConfigError, init_loader, ExtensionLifecycleError, setExtensionLoopbackBaseUrl, enableExtension, disableExtension, activateVersion, ExtensionAssetsInvalidError, installExtensionWithAssets, uninstallExtension, reloadExtension, loadEnabledExtensions, stopExtensionRuntime, init_lifecycle, ExtensionAbortedError2, isRegistered2, isExtensionAgentId2, getExtensionBridgeToken2, resolveBridgeCallOrigin2, extensionIdForAgent2, runContext2, registerLoaded2, unregister2, hasNativeToolHandlers2, listRegistered2, dispatchPre2, dispatchPost2, init_dispatcher, resolveIdentity, renderIdentity, init_identity, dismissedNamespace, dismissUnmappedIdentity, restoreUnmappedIdentity, recordUnmappedIdentity, init_unmapped_identities, getDeliveredSlackMessageTs, foldIntoPendingSlackTask, init_slack_fold, MAX_TASK_ATTACHMENT_BYTES, recordTaskAttachmentUpload, scopeFromAttachment, backingProviderId, init_task_attachment_store, transcribeAudioNotes, init_transcription, init_templates, buildEffectiveText, bufferedFileFailures, fetchSlackFiles, createSlackTaskWithFiles, attachSlackFilesToDraft, notifySlackFileFailures, init_inbound_files, pendingWorkForAgent, countPoolRuntimes, computeDesired, init_demand, isRuntimePoolWakeable, isAgentReachable, isAgentOnDemand, init_reachability, isAddressedToOtherUser, broadcastMatches, routeMessage, extractTaskFromMessage, init_router, extractSlackMessageText, slackInboundMessageText, collectSlackMessageFiles, init_message_text, createAdditiveBuffer, init_additive_buffer, isAgentMailEnabled, initAgentMail, verifyAgentMailWebhook, isInboxAllowed, isSenderAllowed, handleMessageReceived, init_agentmail, isAzureDevOpsEnabled, initAzureDevOps, verifyAzureDevOpsWebhook, repointTrackerSyncBySwarmId, init_tracker, isAzureDevOpsUrl, canonicalAzureDevOpsRepoUrl, parseAzureDevOpsRepoUrl, init_azure_devops, createdPullRequestOf, commentedPayloadOf, handlePullRequestCreated, handlePullRequestCommented, handleWorkItemCreated, handleWorkItemUpdated, handleWorkItemCommented, handleWorkItemDeleted, handleWorkItemRestored, initAzureDevOpsOutbound, init_azure_devops2, enqueueAuditRow, enqueueAdmissionRow, flushAuditBuffer, startAuditWriter, stopAuditWriter, startAuditGc, stopAuditGc, init_rbac_audit, getTelemetryIngestAnchor, init_telemetry_ingest_anchor, initApiTelemetry, syncTelemetryEnabled, init_telemetry_enable, isBitbucketEnabled, initBitbucket, verifyBitbucketWebhook, isDuplicateDelivery, markDeliveryProcessed, pullRequestEventOf, pullRequestCommentEventOf, handlePullRequestCreated2, handlePullRequestCommentCreated, handlePullRequestClosed, init_bitbucket, handlePullRequest, handleIssue, handleComment, handlePullRequestReview, handleCheckRun, handleCheckSuite, handleWorkflowRun, init_github, isGitLabEnabled, initGitLab, verifyGitLabWebhook, handleMergeRequest, handleIssue2, handleNote, handlePipeline, init_gitlab, isChatSdkEnabled, getChatSdkConfig, init_config2, errorMessage, init_logger, resolveAdapterApiUrl, init_adapters, trackBackground, init_background, TelegramBotApiError, callTelegramBotApi, init_telegram_api, isTrustedTeamsServiceUrl, init_teams_origin, getSessionLabels, rememberSessionLabel, getResourceSessionLabels, init_session_labels, isChatSdkStopping, startChatSdk, getChatInstance, isChatAdapterConfigured, getChatSdkHealth, stopChatSdk, init_runtime, getJiraMetadata, updateJiraMetadata, clearJiraMetadata, init_metadata, registerJiraWebhook, deleteJiraWebhook, init_webhook_lifecycle, isJiraEnabled, initJira, init_app2, handleJiraWebhook, init_webhook, init_jira, handleAgentSessionEvent, handleIssueUpdate, handleIssueDelete, handleAgentSessionPrompted, init_sync, isLinearEnabled, initLinear, init_app3, init_linear, init_slack, verifyPageSession, LEGACY_PAGE_SESSION_COOKIE, isCookieSafePageId, extractPageSession, extractLegacyPageSession, extractAndVerifyCookie, isLocalDevPageRequest, pageSessionSetCookies, init_page_session, resolveHttpRequestAuth, init_auth, getDeploymentEnvValue2, loadGlobalConfigsIntoEnv2, reloadGlobalConfigsAndIntegrations2, scheduleIntegrationsReload2, handleCore2, init_core, runTaskUiScriptAction, init_script_actions, cancelApprovalRequest, cancelApprovalRequestAndRun, init_approval_cancel, resolveRequestPrincipal, requestPrincipal, agentFirstPrincipal, requireAuthKind, rejectGuest, init_request_principal, REBOOT_RETRY_PIN_TAG2, getPinCandidateAgent2, resolveLeadOnlyRecoveryAssignment2, getResumeGeneration2, getNextResumeGeneration2, inheritedModelSelection2, nextFallback2, createWorkerTaskFollowUp2, createResumeFollowUp2, createRerouteDecisionTask2, createPoolStarvationDecisionTask2, init_worker_follow_up, MCP_MAX_TOOL_INPUT_ELEMENTS, MCP_MAX_REQUEST_BODY_BYTES, init_mcp_limits, userCtx, init_task_tool_ctx, resolveTaskRequester, init_task_requester, handleApps, init_apps, parseScene, init_elements, MAX_OBJECT_BYTES, init_write_object, getUserCommsPrefs, init_requester_comms, getTaskDetailsInputSchema, getTaskDetailsOutputSchema, getTaskDetailsHandler, init_get_task_details, cancelTaskInputSchema, cancelTaskOutputSchema, cancelTaskHandler, init_cancel_task, DbQueryTimeoutError, DbQueryConcurrencyCapError, executeReadOnlyQuery, getDbQueryHttpBudgetMs, init_db_query_shared, assertSelectOnlyQuery, executeReadOnlyQueryGated, handleDbQuery, init_db_query, snapshotMetric, init_version2, AssetKeyAuthorizationError, authorizeAssetKeyWrite, init_asset_key_auth, getPageEditCounter, init_page_versions, DEFAULT_THEME_ID, THEME_PRESET_IDS, getThemePreset, init_presets, DesignSystemError, buildDesignSystem, init_design_system, getDesignSystem, getActiveDesignSystem, saveDesignSystem, init_design_system2, snapshotPage, init_version3, readThemeFields, init_page_fields, assertOAuthAppUrlsSafe, assertOAuthEgressUrlSafe, init_app_validation, listOAuthPresets, listOAuthPresetIds, getOAuthPreset, hydrateOAuthAppFromPreset, init_presets2, scopedResourceScopeIdSchema, resolveScopedResourceId, init_scoped_resource, MemoryKeyError, init_key_guard, refreshLinks, init_link_resolver, indexMemoryContent, init_index_content, dedupeMemoryDocumentIds, recordMemoryAccesses, recordRetrievals, init_retrieval, ExplicitSelfDuplicateError, applyRating, init_store, shouldPersistAutomaticTaskMemory, init_automatic_task_gate, guardTerminalTaskResultWrite, init_terminal_result_guard, scriptNameSchema, scriptToolOutputSchema, scriptsApiToolResult, init_script_common, getTasksInputSchema, getTasksOutputSchema, getTasksHandler, init_get_tasks, requiresLeadToWrite, reservedNamespaceError, privateNamespaceError, reservedRoomKeyError, init_kv_reserved_namespaces, updateMcpServerChecked, init_mcp_server_checked_update, updateTouchesStdioExecution, init_mcp_server_stdio_gate, canReadMemory, init_access, getLinksForMemory, init_links_store, attachDemotionEvidence, init_demotion_evidence, expandCandidatesWithGraph, init_graph_expansion, isApiDraining, drainApi, init_api_drain, markKapsoMessageRead, sendKapsoReaction, init_client, getKapsoConfig, getKapsoNumberMapping, markKapsoMessageSeen, init_config3, changesMergePolicy, init_repo_merge_policy, updateSwarmRepoChecked, init_repo_checked_update, getCombConfig, init_config4, resolveRoomNamespace, roomRequestInfo, authorizeRoomNamespace, sessionAccessTopic, sessionPresenceRoot, init_auth2, RoomOperationSchema, init_document, removeAwarenessStates, init_awareness, roomTopic, decodeRoomSnapshot, roomView, getRoom, changeRoom, applyRoomUpdate, resetRoom, sweepRooms, closeRooms, removeNamespaceRooms, init_rooms, init_scheduler2, MEMORY_KEYS_DEFAULT_PREFIX, MEMORY_KEYS_MAX_LIMIT, estimateTokens, posteriorMean, listMemoryKeys, checkChunkIntegrity, getMemoryChunks, getPosteriorsByIds, init_key_browser, createEvent, createEventsBatch, getEventCountsFiltered, getEventsFiltered, init_events, mergeScheduleTiming, validateRecurringTiming, changesScheduleTarget, init_validate, renderTypeBlobs, init_script_query_types, renderRunOutput, init_script_run, renderSearchResults, searchSuccessMessage, init_script_search, followUpThreadForSourceTask, evaluateFollowUpRedelegation, init_follow_up_redelegation_guard, checkOutputSchemaShape, sendTaskOutputSchema, sendTaskHandler, init_send_task, setSheetRange, appendSheetRows, clearSheetRange, init_service, steerTaskUserInputSchema, steerTaskOutputSchema, steerTaskHandler, init_steer_task, skipReasonFrom, finalizeSkippedTaskReaction, init_task_skip, IMPROVEMENT_TEXT_MAX, IMPROVEMENT_STATUSES, IMPROVEMENT_SOURCES, ImprovementError, isImprovementsEnabled, getImprovement, listImprovements, createImprovement, approveAndSend, discardImprovement, improvementLeakHints, init_improvements, recomputeSessionCost, init_session_cost_recompute, canClaim, init_budget_admission, emitBudgetRefusalSideEffects, init_budget_refusal_notify, workflowModelErrors, init_model_validation, patchWorkflowDefinition, init_patch_definition, idempotencyKeyHeader, readIdempotencyKey, replayAcceptedOperation, init_idempotency_key, resolveScriptsOnlyMode, init_scripts_only_mode, ALL_CAPABILITIES, hasCapability, getEnabledCapabilities, createServer, init_server };