@desplega.ai/agent-swarm 2.13.3 → 2.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-adapter-mr4temec.js +17 -0
- package/dist/{acp-targets-k8xs4tj8.js → acp-targets-zrk9k0n7.js} +10 -10
- package/dist/{actions-pg5fxjer.js → actions-acqqj9jn.js} +236 -26
- package/dist/{agent-fs-provision-vbk3fppw.js → agent-fs-provision-zmaykqnd.js} +4 -4
- package/dist/{amp-adapter-adbhxsz9.js → amp-adapter-a7ts8tmw.js} +3 -3
- package/dist/{app-b267ggx1.js → app-tmwa442h.js} +7 -7
- package/dist/{approval-notifications-evc1a9z5.js → approval-notifications-6psaaaye.js} +8 -8
- package/dist/{assistant-wgz2ab84.js → assistant-564v6emv.js} +24 -24
- package/dist/{boot-args-schema-6tpk28j4.js → boot-args-schema-n099e0f2.js} +1 -1
- package/dist/{boot-reembed-ankp369c.js → boot-reembed-chx66qfk.js} +1 -1
- package/dist/{boot-reembed-r1zyvefv.js → boot-reembed-epvg4fp9.js} +1 -1
- package/dist/{boot-scrub-sweep-cgb6r5bd.js → boot-scrub-sweep-dhkfp0a7.js} +2 -2
- package/dist/{boot-seeds-bjceqg7b.js → boot-seeds-m74fc07r.js} +4 -4
- package/dist/{boxd-hr8rsxzq.js → boxd-451q55ys.js} +1 -1
- package/dist/{claude-adapter-knztdnff.js → claude-adapter-hw63yj3j.js} +9 -9
- package/dist/{claude-managed-adapter-qwejzqkk.js → claude-managed-adapter-z5s7fx6p.js} +3 -3
- package/dist/{claude-managed-setup-0vgz4d1j.js → claude-managed-setup-wee1762m.js} +3 -3
- package/dist/{claude-sdk-session-c3g6dv0g.js → claude-sdk-session-cktyqkpk.js} +11 -11
- package/dist/{cli-7fa6yv98.js → cli-0fgvnb0x.js} +6 -6
- package/dist/{cli-2v4xxnx2.js → cli-0h8skzss.js} +1 -1
- package/dist/{cli-hhb8kbwd.js → cli-0p76my9q.js} +29 -14
- package/dist/{cli-fp65jdp2.js → cli-1kvcsd2f.js} +219 -155
- package/dist/{cli-wtffytm8.js → cli-1vmhnncj.js} +3 -3
- package/dist/{cli-268b3dgn.js → cli-29h5239w.js} +5 -5
- package/dist/{cli-8fj8yfmk.js → cli-2vp0z049.js} +1 -1
- package/dist/{cli-bh53ppqm.js → cli-3bxrrh53.js} +4 -4
- package/dist/{cli-61fzwtjk.js → cli-3tzmh38q.js} +9 -9
- package/dist/{cli-88np9va3.js → cli-3xqad83h.js} +1 -1
- package/dist/{cli-gc715jrc.js → cli-3zrwrnz7.js} +1 -1
- package/dist/{cli-dw43pnzp.js → cli-404am6f3.js} +7 -7
- package/dist/{cli-8pnawt98.js → cli-49aq3cyn.js} +4 -4
- package/dist/{cli-fbmgpt72.js → cli-4fpa0zns.js} +3 -3
- package/dist/{cli-kwm1bek7.js → cli-4pbwg7sn.js} +2 -2
- package/dist/{cli-djwt4mtn.js → cli-4q2c8rxw.js} +9 -9
- package/dist/{cli-3mf04tkh.js → cli-4vynxtrb.js} +1 -1
- package/dist/{cli-80d5g0fa.js → cli-5ashycw3.js} +3 -3
- package/dist/{cli-61p7ty8d.js → cli-5rgm8p39.js} +3 -3
- package/dist/{cli-r6xnchva.js → cli-5rxsb3wq.js} +6 -6
- package/dist/{cli-a21cwm89.js → cli-60dwk8tx.js} +3 -3
- package/dist/{cli-v1v49t36.js → cli-7by7vp6m.js} +2 -2
- package/dist/{cli-vgh5adn9.js → cli-7g3fg4gf.js} +7 -7
- package/dist/{cli-hxj888w3.js → cli-7gbff32z.js} +2 -2
- package/dist/{cli-q8aq48v1.js → cli-8b4rpnwj.js} +1 -1
- package/dist/{cli-xc8m5cjn.js → cli-8cas2xvp.js} +3 -3
- package/dist/{cli-1606qw3n.js → cli-904wk98s.js} +797 -369
- package/dist/{cli-h3drhntp.js → cli-93n305hm.js} +2 -2
- package/dist/{cli-1wew39p0.js → cli-944w9wb4.js} +20 -16
- package/dist/{cli-je587f74.js → cli-94gx6ze9.js} +1 -1
- package/dist/{cli-hpxcfvdm.js → cli-9ah37a8a.js} +6 -6
- package/dist/{cli-rfejbpe1.js → cli-akm6y2a8.js} +1 -1
- package/dist/{cli-f8rcvf2x.js → cli-azj9t1f9.js} +37 -2
- package/dist/{cli-ef590376.js → cli-bv4vvnmg.js} +3 -3
- package/dist/{cli-ppf9ap9n.js → cli-bzcwwebm.js} +1 -1
- package/dist/{cli-sy2ge2ye.js → cli-cq4am6vg.js} +2 -2
- package/dist/{cli-gxqwm3k3.js → cli-d5pc8ep0.js} +102 -8
- package/dist/{cli-hd2a204w.js → cli-ea7nz50q.js} +12 -12
- package/dist/{cli-zkbz8m2q.js → cli-fkpnx3vf.js} +1 -1
- package/dist/{cli-ya1cj689.js → cli-fw67mnyc.js} +1 -1
- package/dist/{cli-5basv0e7.js → cli-gkv0r2hq.js} +1 -1
- package/dist/{cli-ka4tqjzd.js → cli-gse7bp3z.js} +12 -10
- package/dist/{cli-v8rpjrnx.js → cli-gtj12v95.js} +1 -1
- package/dist/{cli-g4dhd3pr.js → cli-hdhpdrka.js} +6 -23
- package/dist/{cli-dq30fq3q.js → cli-hhtbandk.js} +2 -2
- package/dist/cli-hyqksecw.js +1907 -0
- package/dist/{cli-t25rq8mg.js → cli-ja450998.js} +40 -11
- package/dist/{cli-43dsqhcp.js → cli-jbrc98qb.js} +4 -4
- package/dist/{cli-8sayvj48.js → cli-jyhbvdga.js} +3 -3
- package/dist/{cli-55fqpd9q.js → cli-jzerrzgc.js} +8 -8
- package/dist/{cli-hv3820ez.js → cli-k0nebh10.js} +1 -1
- package/dist/{cli-aytna2fm.js → cli-ka48vpev.js} +5 -5
- package/dist/{cli-d2epqm0y.js → cli-kezzteka.js} +1 -1
- package/dist/{cli-grk77aen.js → cli-kj84fqxz.js} +2 -2
- package/dist/{cli-h0ewec3d.js → cli-kr0jpw9c.js} +1 -1
- package/dist/{cli-wsnradtk.js → cli-m1sns1da.js} +2 -2
- package/dist/{cli-7kv5d674.js → cli-n1kjs58m.js} +4 -4
- package/dist/{cli-syqcny89.js → cli-nc4pbwmp.js} +9 -9
- package/dist/{cli-9gmkw6xn.js → cli-p3knvk62.js} +48 -42
- package/dist/{cli-50whymxq.js → cli-p436yrzp.js} +2 -2
- package/dist/{cli-0j4qmc80.js → cli-phdzn699.js} +7 -7
- package/dist/{cli-1gnf5c7x.js → cli-pz1dp12c.js} +1 -1
- package/dist/{cli-nbawx3s0.js → cli-pz1nq5xm.js} +6 -6
- package/dist/{cli-4dyhzhpx.js → cli-qzz6tz8s.js} +1 -1
- package/dist/{cli-ea367bdn.js → cli-rmgvwcmy.js} +22 -22
- package/dist/{cli-mgr3gatr.js → cli-rv3y60bt.js} +4 -4
- package/dist/cli-s33bzmk0.js +27 -0
- package/dist/{cli-at67kvnp.js → cli-srktrbby.js} +1 -1
- package/dist/{cli-pzsedyb0.js → cli-t0jmkcah.js} +14 -14
- package/dist/{cli-eetzmsy5.js → cli-t9pzz2eq.js} +2 -2
- package/dist/{cli-w24741sm.js → cli-tr19nyn9.js} +4 -4
- package/dist/{cli-e4gx499y.js → cli-ts5yv7dn.js} +163 -86
- package/dist/{cli-czeh7x13.js → cli-tsc3pdfd.js} +4 -4
- package/dist/{cli-y0q92v4r.js → cli-tzw1jr2t.js} +2 -2
- package/dist/{cli-tjf1bh1v.js → cli-x2cem5vy.js} +6 -4
- package/dist/{cli-vx9acp12.js → cli-ybte1fqc.js} +1 -1
- package/dist/{cli-gkjw33x5.js → cli-ysv0k1we.js} +2 -2
- package/dist/{cli-vdfngx2g.js → cli-ywy8yz6t.js} +2 -2
- package/dist/{cli-cpkxh68d.js → cli-z1vam71h.js} +2 -2
- package/dist/{cli-8m6gqnf1.js → cli-zexwhj3f.js} +3 -3
- package/dist/{cli-snwz16eg.js → cli-zhwjdhjr.js} +2 -2
- package/dist/{cli-y754psdt.js → cli-zjdhrzm0.js} +4 -4
- package/dist/cli.js +19 -19
- package/dist/{codex-adapter-493vb8cv.js → codex-adapter-2fs2c0n6.js} +8 -8
- package/dist/{codex-hook-ej8hn6z5.js → codex-hook-jxjv6dy5.js} +1 -1
- package/dist/{codex-login-ven5cz5j.js → codex-login-ktfg1cxk.js} +1 -1
- package/dist/{codex-session-runner-ps5m4z1g.js → codex-session-runner-r55tmx4c.js} +9 -9
- package/dist/{commands-shktk0b8.js → commands-0mxdy9x8.js} +3 -3
- package/dist/{controller-wn3vd217.js → controller-g3vkfhr4.js} +4 -4
- package/dist/{controllers-connect-yft057ws.js → controllers-connect-4wdmncqt.js} +25 -25
- package/dist/core-gsvj5f3z.js +42 -0
- package/dist/{cursor-adapter-8fpm4dng.js → cursor-adapter-t9qb96q2.js} +2 -2
- package/dist/{db-0ezhdhz5.js → db-487vvyv9.js} +3 -3
- package/dist/{db-84pz2w5c.js → db-76p7w3gr.js} +2 -2
- package/dist/{devin-adapter-fs90ab4v.js → devin-adapter-3bp6rape.js} +1 -1
- package/dist/{dispatcher-h2rz69f6.js → dispatcher-64rp6w67.js} +22 -22
- package/dist/{docker-1h33jvh9.js → docker-a59g3ebm.js} +2 -2
- package/dist/{dsh-adapter-g9yqv09y.js → dsh-adapter-8abzqk5c.js} +2 -2
- package/dist/{e2b-y7e5kmzf.js → e2b-3ykbe805.js} +2 -2
- package/dist/{e2b-jnk0yeva.js → e2b-dc8f6ctq.js} +2 -2
- package/dist/{easter-egg-3d-m41ad78v.js → easter-egg-3d-jrrwyf55.js} +1 -1
- package/dist/{embedding-space-yam9zwzj.js → embedding-space-001hhhpk.js} +6 -6
- package/dist/{embeddings-g2be0y8q.js → embeddings-esj19cnw.js} +1 -1
- package/dist/{event-bus-08t2b4y2.js → event-bus-7gbsr0g4.js} +1 -1
- package/dist/{execute-hhdejgzf.js → execute-301hkxqg.js} +1 -1
- package/dist/{external-channel-kjt2yzfj.js → external-channel-w10e2j05.js} +2 -2
- package/dist/fx-adapter-4sjrbdne.js +20 -0
- package/dist/grok-adapter-3a0ezfee.js +20 -0
- package/dist/handlers-ef3k11hb.js +41 -0
- package/dist/{heartbeat-2e5jdexj.js → heartbeat-tbrj7vhq.js} +25 -25
- package/dist/{hook-acg9saz7.js → hook-3am1sq68.js} +6 -6
- package/dist/{hook-34s8cmgn.js → hook-tx917rqw.js} +8 -8
- package/dist/{http-ra2zr2f8.js → http-3rmemtqy.js} +335 -1829
- package/dist/{index-mbpxhc4w.js → index-126v2d0t.js} +1 -4
- package/dist/{index-2z1z7qx6.js → index-2jw11t8s.js} +26 -26
- package/dist/{index-9q42cr54.js → index-aetfyx6p.js} +1 -1
- package/dist/index-e6bq0exk.js +42 -0
- package/dist/{index-9r4j0a60.js → index-gfnq66t1.js} +223 -25
- package/dist/index-hf2k1vge.js +39 -0
- package/dist/{index-93bw5wds.js → index-s7xtvc0f.js} +1 -1
- package/dist/index-taxmejj3.js +44 -0
- package/dist/{k8s-8326q0rq.js → k8s-36gfn847.js} +2 -2
- package/dist/{keepalive-vjnnqbkm.js → keepalive-9px3t7qj.js} +5 -5
- package/dist/lead-5vt6f174.js +83 -0
- package/dist/{maintenance-px2g599e.js → maintenance-vwqjwst6.js} +1 -1
- package/dist/{oauth-refresh-sweep-nkykf09m.js → oauth-refresh-sweep-yqry3wn4.js} +4 -4
- package/dist/{object-webhooks-gt9xnq21.js → object-webhooks-8s1wtths.js} +7 -7
- package/dist/{onboard-1f134p65.js → onboard-hb8czx0p.js} +7 -7
- package/dist/{opencode-adapter-94976yab.js → opencode-adapter-djd6m6dk.js} +8 -8
- package/dist/{otel-impl-5d4p2fqs.js → otel-impl-2ymwyczz.js} +2 -2
- package/dist/{pending-vkk0vx6n.js → pending-nxavtvx7.js} +23 -23
- package/dist/{pi-mono-adapter-cyzdv5er.js → pi-mono-adapter-d2cpmcy4.js} +12 -12
- package/dist/{pricing-refresh-jtmjwss9.js → pricing-refresh-1yz8jkqv.js} +2 -2
- package/dist/{rbac-roles-1fvmdyeb.js → rbac-roles-7s6m31xw.js} +6 -4
- package/dist/{rbac-roles-yd1fgpsn.js → rbac-roles-dbpx0x9v.js} +3 -3
- package/dist/{render-v2-kb5s3vx4.js → render-v2-7y20rjrn.js} +7 -7
- package/dist/{resume-z1vs44n5.js → resume-wz546x47.js} +10 -10
- package/dist/{runtime-gk6ct7r7.js → runtime-cb5bd9tz.js} +1 -1
- package/dist/{session-access-nz6nre4d.js → session-access-4vcft8kq.js} +5 -5
- package/dist/{session-source-backfill-wb60zjkd.js → session-source-backfill-57b50tpw.js} +3 -3
- package/dist/{setup-2x8g8j4s.js → setup-e1tevjyj.js} +1 -1
- package/dist/thread-buffer-686pa1p1.js +42 -0
- package/dist/{tree-visibility-ts3z30kw.js → tree-visibility-07wf1nct.js} +2 -2
- package/dist/{user-merge-jobs-zetg26e0.js → user-merge-jobs-n20qpv6s.js} +3 -3
- package/dist/{virtual-modules-674fka8x.js → virtual-modules-6fxmn1yv.js} +3 -3
- package/dist/{work-objects-w52yyjxm.js → work-objects-eg7y48pe.js} +25 -25
- package/dist/worker-4vp616ms.js +83 -0
- package/dist/{worker-follow-up-dyfxyjbj.js → worker-follow-up-jnvnnf2b.js} +22 -22
- package/dist/{x-asbrnafg.js → x-d27jj7z7.js} +2 -2
- package/openapi.json +475 -28
- package/package.json +2 -2
- package/src/be/db/approvals.ts +2 -0
- package/src/be/db/runtime.ts +5 -0
- package/src/be/db/script-run-sources.ts +17 -0
- package/src/be/db-retention.ts +1 -1
- package/src/be/db.ts +71 -62
- package/src/be/design-system.ts +63 -0
- package/src/be/migrations/342_script_run_sources.sql +20 -0
- package/src/be/migrations/runner.ts +8 -0
- package/src/be/migrations/script-run-sources.ts +51 -0
- package/src/be/rbac-roles.ts +2 -0
- package/src/be/scripts/typecheck.ts +4 -2
- package/src/be/seed-scripts/catalog/design-system-seed.ts +158 -0
- package/src/be/seed-scripts/index.ts +9 -0
- package/src/be/swarm-config-guard.ts +21 -1
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/heartbeat/heartbeat.ts +18 -4
- package/src/http/all-routes.ts +1 -0
- package/src/http/approval-chat-answer.ts +99 -0
- package/src/http/approval-requests.ts +280 -225
- package/src/http/design-system.ts +103 -0
- package/src/http/index.ts +10 -6
- package/src/http/pages-public.ts +25 -10
- package/src/http/pages.ts +17 -0
- package/src/http/person-responder.ts +28 -0
- package/src/integrations/chat-sdk/adapters.ts +33 -3
- package/src/integrations/chat-sdk/inbound.ts +6 -18
- package/src/integrations/chat-sdk/mentions.ts +188 -0
- package/src/integrations/chat-sdk/outbound.ts +20 -3
- package/src/integrations/chat-sdk/router.ts +8 -0
- package/src/integrations/chat-sdk/telegram-thread.ts +12 -0
- package/src/jira/adf.ts +35 -9
- package/src/kv-reserved-namespaces.ts +5 -0
- package/src/pages/page-head.ts +11 -1
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/dsh-adapter.ts +48 -13
- package/src/rbac/legacy-policy.ts +4 -0
- package/src/rbac/permissions.ts +8 -0
- package/src/scheduler/index.ts +1 -0
- package/src/scheduler/scheduler.test.ts +32 -1
- package/src/scheduler/scheduler.ts +24 -1
- package/src/script-workflows/executor.ts +6 -0
- package/src/script-workflows/supervisor.ts +2 -1
- package/src/scripts-runtime/sdk-allowlist.ts +2 -0
- package/src/scripts-runtime/swarm-sdk.ts +12 -23
- package/src/scripts-runtime/types/stdlib.d.ts +4 -1
- package/src/scripts-runtime/types/swarm-sdk.d.ts +4 -1
- package/src/server.ts +2 -0
- package/src/slack/actions.ts +3 -0
- package/src/slack/approval-actions.ts +148 -0
- package/src/slack/approval-buttons.ts +28 -0
- package/src/tests/chat-sdk-mentions.test.ts +183 -0
- package/src/tests/create-page-tool.test.ts +5 -0
- package/src/tests/dsh-adapter.test.ts +53 -1
- package/src/tests/fixtures/compiled-source-schema-boot.ts +24 -0
- package/src/tests/fixtures/secret-corpus.ts +43 -1
- package/src/tests/heartbeat-stall-thresholds.test.ts +174 -0
- package/src/tests/jira-adf.test.ts +42 -2
- package/src/tests/merge-gate-detect-changes.test.ts +208 -16
- package/src/tests/migration-342-script-run-sources.test.ts +196 -0
- package/src/tests/migration-bunfs-compat.test.ts +129 -9
- package/src/tests/rbac-e2e-helpers.test.ts +10 -4
- package/src/tests/rbac-e2e-helpers.ts +13 -4
- package/src/tests/rbac-roles.test.ts +2 -0
- package/src/tests/runtime-e2b-pools.test.ts +7 -1
- package/src/tests/schedule-target-type.test.ts +4 -1
- package/src/tests/script-connections.test.ts +2 -0
- package/src/tests/script-runs-retention.test.ts +43 -16
- package/src/tests/script-workflows-runtime-e2e.test.ts +56 -22
- package/src/tests/scripts-http.test.ts +9 -3
- package/src/tests/sdk-allowlist.test.ts +26 -13
- package/src/tests/sdk-store-progress-skipped.test.ts +12 -5
- package/src/tests/secret-rules.test.ts +34 -0
- package/src/tests/secret-scrub-gate.test.ts +7 -0
- package/src/tests/secret-scrubber.test.ts +62 -2
- package/src/tests/seed-scripts.test.ts +2 -2
- package/src/tests/system-one-hosts-ui-mirror.test.ts +1 -0
- package/src/tests/vcs-azure-devops.test.ts +10 -0
- package/src/tests/vcs-provider.test.ts +8 -0
- package/src/themes/design-system.ts +163 -0
- package/src/themes/page-theme.ts +28 -19
- package/src/tools/chat-post.ts +7 -3
- package/src/tools/create-page.ts +3 -0
- package/src/tools/design-system.ts +102 -0
- package/src/tools/mcp-servers/mcp-server-get.ts +1 -1
- package/src/tools/mcp-servers/mcp-server-list.ts +1 -1
- package/src/tools/register-chat-channel.ts +11 -2
- package/src/tools/skills/skill-get-file.ts +1 -1
- package/src/tools/skills/skill-get.ts +1 -1
- package/src/tools/skills/skill-list.ts +1 -1
- package/src/tools/skills/skill-search.ts +1 -1
- package/src/tools/utils.ts +49 -4
- package/src/tools/workflows/get-workflow-run.ts +1 -1
- package/src/tools/workflows/get-workflow.ts +1 -1
- package/src/tools/workflows/list-workflow-runs.ts +1 -1
- package/src/tools/workflows/list-workflows.ts +1 -1
- package/src/types.ts +65 -0
- package/src/utils/secret-rules.generated.ts +149 -149
- package/src/utils/secret-scrubber.ts +111 -5
- package/src/vcs/azure-devops.ts +22 -1
- package/src/vcs/index.ts +3 -1
- package/src/workflows/approval-inline.ts +122 -0
- package/src/workflows/approval-notifications.ts +7 -2
- package/src/workflows/engine.ts +6 -5
- package/src/workflows/executors/agent-task.ts +14 -0
- package/src/workflows/executors/system-one-providers.ts +23 -0
- package/templates/skills/pages/content.md +34 -8
- package/templates/skills/swarm-docs/content.md +5 -0
- package/templates/skills/workflow-iterate/content.md +1 -1
- package/dist/acp-adapter-t2q6nsqv.js +0 -17
- package/dist/cli-kh973792.js +0 -98
- package/dist/core-nheayfgm.js +0 -42
- package/dist/fx-adapter-8g7xsp8q.js +0 -20
- package/dist/grok-adapter-ztk2zkz1.js +0 -20
- package/dist/handlers-9ywssz71.js +0 -41
- package/dist/index-6mgbdtv1.js +0 -44
- package/dist/index-hqdsn2t2.js +0 -39
- package/dist/index-st231bqv.js +0 -40
- package/dist/lead-mk0xkth2.js +0 -82
- package/dist/thread-buffer-d50rqpev.js +0 -42
- package/dist/worker-662x1vse.js +0 -82
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The org design system: one brand record per swarm deployment, stored in KV
|
|
3
|
+
* (`design-system` / `org`). It restyles every designVersion 2 page that sets
|
|
4
|
+
* no `theme` (see `resolvePageTheme`). `design-system-set` is the only writer;
|
|
5
|
+
* the namespace is reserved, so a raw `kv-set` cannot skip these checks.
|
|
6
|
+
*
|
|
7
|
+
* Writes and reads run the same checks: tokens go through the theme importer,
|
|
8
|
+
* URLs are https (fonts pinned to Google Fonts, which the page CSP allows),
|
|
9
|
+
* and the base preset must exist. A stored record that fails them reads as
|
|
10
|
+
* invalid and pages ignore it.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { type DesignSystem, type DesignSystemInput, DesignSystemSchema } from "../types";
|
|
14
|
+
import { importThemeTokens, ThemeImportError } from "./import";
|
|
15
|
+
import { DEFAULT_THEME_ID, isThemePresetId, THEME_PRESET_IDS } from "./presets";
|
|
16
|
+
|
|
17
|
+
export const DESIGN_SYSTEM_NAMESPACE = "design-system";
|
|
18
|
+
export const DESIGN_SYSTEM_KEY = "org";
|
|
19
|
+
/** The value `design-system-set` replaced, kept for a one-step undo. */
|
|
20
|
+
export const DESIGN_SYSTEM_PREVIOUS_KEY = "org.prev";
|
|
21
|
+
// shortcut: single undo step, upgrade to versions if a second rollback is needed.
|
|
22
|
+
|
|
23
|
+
export type DesignSystemActor = { userId: string | null; agentId?: string };
|
|
24
|
+
|
|
25
|
+
const FONTS_HOST = "fonts.googleapis.com";
|
|
26
|
+
/** Quotes and angle brackets would break out of the `href` attribute even after escaping mistakes. */
|
|
27
|
+
const UNSAFE_URL_CHARACTERS = /["'<>\s\\]/;
|
|
28
|
+
|
|
29
|
+
export class DesignSystemError extends Error {
|
|
30
|
+
override name = "DesignSystemError";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function readHttpsUrl(value: string, label: string, host?: string): string {
|
|
34
|
+
let url: URL;
|
|
35
|
+
try {
|
|
36
|
+
url = new URL(value);
|
|
37
|
+
} catch {
|
|
38
|
+
throw new DesignSystemError(`${label} must be an absolute https URL`);
|
|
39
|
+
}
|
|
40
|
+
if (url.protocol !== "https:" || UNSAFE_URL_CHARACTERS.test(value)) {
|
|
41
|
+
throw new DesignSystemError(`${label} must be an absolute https URL`);
|
|
42
|
+
}
|
|
43
|
+
if (host && url.hostname !== host) {
|
|
44
|
+
throw new DesignSystemError(`${label} must be on https://${host}`);
|
|
45
|
+
}
|
|
46
|
+
return url.href;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function readColor(value: string, index: number): string {
|
|
50
|
+
try {
|
|
51
|
+
// The importer's value check is the token contract's check, so reuse it.
|
|
52
|
+
const { tokens } = importThemeTokens({ light: { "--color-chart-1": value } });
|
|
53
|
+
const color = tokens.light["--color-chart-1"];
|
|
54
|
+
if (color === undefined) throw new ThemeImportError("not a color value");
|
|
55
|
+
return color;
|
|
56
|
+
} catch (err) {
|
|
57
|
+
if (err instanceof ThemeImportError) {
|
|
58
|
+
throw new DesignSystemError(`chartPalette[${index}]: ${err.message}`);
|
|
59
|
+
}
|
|
60
|
+
throw err;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Checks and normalizes a design system write. Throws `DesignSystemError`
|
|
66
|
+
* with a message that names the bad field. `ignored` lists the token names
|
|
67
|
+
* the importer could not place.
|
|
68
|
+
*/
|
|
69
|
+
export function buildDesignSystem(
|
|
70
|
+
input: DesignSystemInput,
|
|
71
|
+
actor: DesignSystemActor,
|
|
72
|
+
now: Date = new Date(),
|
|
73
|
+
): { record: DesignSystem; ignored: string[] } {
|
|
74
|
+
const stamp = {
|
|
75
|
+
source: input.source ?? { kind: "manual" as const },
|
|
76
|
+
updatedBy: actor.userId,
|
|
77
|
+
...(actor.agentId ? { updatedByAgentId: actor.agentId } : {}),
|
|
78
|
+
updatedAt: now.toISOString(),
|
|
79
|
+
};
|
|
80
|
+
if (input.status === "declined") {
|
|
81
|
+
return {
|
|
82
|
+
record: {
|
|
83
|
+
v: 1,
|
|
84
|
+
status: "declined",
|
|
85
|
+
basePreset: DEFAULT_THEME_ID,
|
|
86
|
+
tokens: { light: {}, dark: {} },
|
|
87
|
+
mode: "viewer",
|
|
88
|
+
...stamp,
|
|
89
|
+
},
|
|
90
|
+
ignored: [],
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const basePreset = input.basePreset ?? DEFAULT_THEME_ID;
|
|
94
|
+
if (!isThemePresetId(basePreset)) {
|
|
95
|
+
throw new DesignSystemError(
|
|
96
|
+
`Unknown basePreset "${basePreset}". Use one of: ${THEME_PRESET_IDS.join(", ")}`,
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
let imported: ReturnType<typeof importThemeTokens> = {
|
|
100
|
+
tokens: { light: {}, dark: {} },
|
|
101
|
+
ignored: [],
|
|
102
|
+
};
|
|
103
|
+
if (input.themeTokens) {
|
|
104
|
+
try {
|
|
105
|
+
imported = importThemeTokens(input.themeTokens as Parameters<typeof importThemeTokens>[0]);
|
|
106
|
+
} catch (err) {
|
|
107
|
+
if (err instanceof ThemeImportError) {
|
|
108
|
+
throw new DesignSystemError(`Invalid themeTokens: ${err.message}`);
|
|
109
|
+
}
|
|
110
|
+
throw err;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const record: DesignSystem = {
|
|
114
|
+
v: 1,
|
|
115
|
+
status: "active",
|
|
116
|
+
basePreset,
|
|
117
|
+
tokens: imported.tokens,
|
|
118
|
+
...(input.fontsHref
|
|
119
|
+
? { fontsHref: readHttpsUrl(input.fontsHref, "fontsHref", FONTS_HOST) }
|
|
120
|
+
: {}),
|
|
121
|
+
...(input.logo
|
|
122
|
+
? { logo: { url: readHttpsUrl(input.logo.url, "logo.url"), alt: input.logo.alt } }
|
|
123
|
+
: {}),
|
|
124
|
+
mode: input.mode ?? "viewer",
|
|
125
|
+
...(input.chartPalette ? { chartPalette: input.chartPalette.map(readColor) } : {}),
|
|
126
|
+
...stamp,
|
|
127
|
+
};
|
|
128
|
+
return { record, ignored: imported.ignored };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Revalidates a stored value. Returns null for a missing value and
|
|
133
|
+
* `{ invalid }` for one that no longer passes the write checks (a hand-edited
|
|
134
|
+
* row, or a preset that was removed), so pages fall back instead of rendering
|
|
135
|
+
* it.
|
|
136
|
+
*/
|
|
137
|
+
export function readDesignSystem(
|
|
138
|
+
value: unknown,
|
|
139
|
+
): { record: DesignSystem } | { invalid: string } | null {
|
|
140
|
+
if (value === undefined || value === null) return null;
|
|
141
|
+
const result = DesignSystemSchema.safeParse(value);
|
|
142
|
+
if (!result.success) return { invalid: "stored design system is not a valid v1 record" };
|
|
143
|
+
const parsed = result.data;
|
|
144
|
+
try {
|
|
145
|
+
const { record } = buildDesignSystem(
|
|
146
|
+
{
|
|
147
|
+
status: parsed.status,
|
|
148
|
+
basePreset: parsed.basePreset,
|
|
149
|
+
themeTokens: parsed.tokens,
|
|
150
|
+
fontsHref: parsed.fontsHref,
|
|
151
|
+
logo: parsed.logo,
|
|
152
|
+
mode: parsed.mode,
|
|
153
|
+
chartPalette: parsed.chartPalette,
|
|
154
|
+
source: parsed.source,
|
|
155
|
+
},
|
|
156
|
+
{ userId: parsed.updatedBy, agentId: parsed.updatedByAgentId },
|
|
157
|
+
);
|
|
158
|
+
return { record: { ...record, updatedAt: parsed.updatedAt } };
|
|
159
|
+
} catch (err) {
|
|
160
|
+
if (err instanceof DesignSystemError) return { invalid: err.message };
|
|
161
|
+
throw err;
|
|
162
|
+
}
|
|
163
|
+
}
|
package/src/themes/page-theme.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Theme resolution and CSS for HTML pages (design version 2).
|
|
3
3
|
*
|
|
4
|
-
* Resolution picks one preset, then applies the
|
|
5
|
-
* - Preset: the page `theme` when it names a known preset, else the
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
4
|
+
* Resolution picks one preset, then applies the token layers on top:
|
|
5
|
+
* - Preset: the page `theme` when it names a known preset, else the org
|
|
6
|
+
* design system's `basePreset`, else the viewer theme (the dashboard's
|
|
7
|
+
* `__swarm-theme` param) when it names a known preset, else `hive`. Direct
|
|
8
|
+
* links pass no viewer theme, so they get Hive. Once an org has a brand,
|
|
9
|
+
* the viewer preset no longer repaints it.
|
|
10
|
+
* - Tokens: the Hive values, then the preset's contract keys, then the org
|
|
11
|
+
* design system tokens, then the page `themeTokens` overrides. A shared
|
|
12
|
+
* token (font, radius) that a layer sets only in `light` applies to dark too.
|
|
13
|
+
* - The caller passes `designSystem` only for a page without its own `theme`
|
|
14
|
+
* (`pageHead` in src/http/pages-public.ts), so a page `theme` ignores it.
|
|
11
15
|
*
|
|
12
16
|
* The CSS carries both modes. `.dark` on `<html>` picks dark, and print is
|
|
13
17
|
* always light.
|
|
@@ -60,24 +64,29 @@ export function resolvePageTheme({
|
|
|
60
64
|
pageTheme,
|
|
61
65
|
viewerTheme,
|
|
62
66
|
overrides,
|
|
67
|
+
designSystem,
|
|
63
68
|
}: {
|
|
64
69
|
pageTheme?: string | null;
|
|
65
70
|
viewerTheme?: string | null;
|
|
66
71
|
overrides?: PageThemeTokens | null;
|
|
72
|
+
designSystem?: { basePreset: string; tokens: PageThemeTokens } | null;
|
|
67
73
|
}): ResolvedPageTheme {
|
|
68
74
|
const preset =
|
|
69
|
-
getThemePreset(pageTheme) ??
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
getThemePreset(pageTheme) ??
|
|
76
|
+
getThemePreset(designSystem?.basePreset) ??
|
|
77
|
+
getThemePreset(viewerTheme) ??
|
|
78
|
+
getThemePreset(DEFAULT_THEME_ID);
|
|
79
|
+
const light = { ...HIVE_PAGE_TOKENS.light, ...contractValues(preset?.vars.light) };
|
|
80
|
+
const dark = { ...HIVE_PAGE_TOKENS.dark, ...contractValues(preset?.vars.dark) };
|
|
81
|
+
for (const layer of [designSystem?.tokens, overrides]) {
|
|
82
|
+
const lightValues = contractValues(layer?.light);
|
|
83
|
+
const darkValues = contractValues(layer?.dark);
|
|
84
|
+
Object.assign(light, lightValues);
|
|
85
|
+
Object.assign(dark, darkValues);
|
|
86
|
+
for (const token of PAGE_THEME_SHARED_TOKENS) {
|
|
87
|
+
const value = lightValues[token];
|
|
88
|
+
if (value !== undefined && darkValues[token] === undefined) dark[token] = value;
|
|
89
|
+
}
|
|
81
90
|
}
|
|
82
91
|
return { presetId: preset?.id ?? DEFAULT_THEME_ID, light, dark };
|
|
83
92
|
}
|
package/src/tools/chat-post.ts
CHANGED
|
@@ -18,7 +18,7 @@ export const registerChatPostTool = (server: McpServer) => {
|
|
|
18
18
|
{
|
|
19
19
|
title: "Post to a chat thread or channel",
|
|
20
20
|
description:
|
|
21
|
-
"Lead only. Post a message to any Chat SDK thread or channel (Telegram, Slack, Discord, Teams), outside the thread of your current task. Give threadId to reply in a thread, or channelId to
|
|
21
|
+
"Lead only. Post a message to any Chat SDK thread or channel (Telegram, Slack, Discord, Teams), outside the thread of your current task. Give threadId to reply in a thread or Telegram topic, or channelId to use its registered default topic (otherwise the channel). Ids carry the adapter prefix, such as telegram:12345 or telegram:-100123:42 for topic 42. To answer the user of your current chat task, use chat-reply instead. For a structured result (key figures, a table, charts, links), send a `card`; it posts after the text as a native card.",
|
|
22
22
|
annotations: { openWorldHint: true },
|
|
23
23
|
inputSchema: z.object({
|
|
24
24
|
adapter: z.enum(CHAT_SDK_ADAPTER_NAMES).describe("Chat SDK adapter name."),
|
|
@@ -26,12 +26,16 @@ export const registerChatPostTool = (server: McpServer) => {
|
|
|
26
26
|
.string()
|
|
27
27
|
.min(1)
|
|
28
28
|
.optional()
|
|
29
|
-
.describe(
|
|
29
|
+
.describe(
|
|
30
|
+
"Full SDK thread id, such as telegram:12345, telegram:-100123:42 (positive integer topic id), or slack:C123:1700000000.000100. Overrides the channel default.",
|
|
31
|
+
),
|
|
30
32
|
channelId: z
|
|
31
33
|
.string()
|
|
32
34
|
.min(1)
|
|
33
35
|
.optional()
|
|
34
|
-
.describe(
|
|
36
|
+
.describe(
|
|
37
|
+
"Full SDK channel id, such as telegram:-100123 or slack:C123. Uses its registered default Telegram topic when set. Ignored when threadId is set.",
|
|
38
|
+
),
|
|
35
39
|
text: z
|
|
36
40
|
.string()
|
|
37
41
|
.min(1)
|
package/src/tools/create-page.ts
CHANGED
|
@@ -28,6 +28,7 @@ import { resolveTaskAuditUserId, resolveTaskGroupKey } from "@/be/audit-user";
|
|
|
28
28
|
import { fileCallerSessionIntoGroup } from "@/be/caller-session-group";
|
|
29
29
|
import { createPage, getPage, getPageBySlug, updatePage } from "@/be/db";
|
|
30
30
|
import { getPageEditCounter } from "@/be/db/page-versions";
|
|
31
|
+
import { getDesignSystem } from "@/be/design-system";
|
|
31
32
|
import { classAttributeValues, countColorLiterals } from "@/pages/color-literals";
|
|
32
33
|
import { snapshotPage } from "@/pages/version";
|
|
33
34
|
import { readThemeFields } from "@/themes/page-fields";
|
|
@@ -175,6 +176,7 @@ export const registerCreatePageTool = (server: McpServer) => {
|
|
|
175
176
|
colorLiteralCount: z.number().optional(),
|
|
176
177
|
usesDesignSystem: z.boolean().optional(),
|
|
177
178
|
lightOnlyColors: z.boolean().optional(),
|
|
179
|
+
designSystemStatus: z.string().optional(),
|
|
178
180
|
movedSessionRootId: z.string().optional(),
|
|
179
181
|
}),
|
|
180
182
|
},
|
|
@@ -303,6 +305,7 @@ export const registerCreatePageTool = (server: McpServer) => {
|
|
|
303
305
|
Boolean(input.themeTokens) ||
|
|
304
306
|
bodyUsesDesignSystem(fresh.body),
|
|
305
307
|
lightOnlyColors: hasLightOnlyColors(fresh.themeTokens),
|
|
308
|
+
designSystemStatus: (await getDesignSystem()).current.status,
|
|
306
309
|
...(fresh.designVersion >= 2
|
|
307
310
|
? { colorLiteralCount: countColorLiterals(fresh.body) }
|
|
308
311
|
: {}),
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `design-system-get` / `design-system-set`: the org design system that
|
|
3
|
+
* restyles every designVersion 2 page without its own `theme`
|
|
4
|
+
* (src/themes/design-system.ts). `design-system-set` is the only agent-facing
|
|
5
|
+
* writer, so every value passes the theme importer's checks.
|
|
6
|
+
*/
|
|
7
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
+
import * as z from "zod";
|
|
9
|
+
import { resolveTaskAuditUserId } from "@/be/audit-user";
|
|
10
|
+
import { getAgentById } from "@/be/db";
|
|
11
|
+
import { getDesignSystem, saveDesignSystem } from "@/be/design-system";
|
|
12
|
+
import { can } from "@/rbac";
|
|
13
|
+
import { buildDesignSystem, DesignSystemError } from "@/themes/design-system";
|
|
14
|
+
import { createToolRegistrar, swarmToolOutputSchema, toolErr, toolOk } from "@/tools/utils";
|
|
15
|
+
import { DesignSystemInputSchema } from "@/types";
|
|
16
|
+
|
|
17
|
+
const outputSchema = swarmToolOutputSchema({
|
|
18
|
+
status: z.string().optional(),
|
|
19
|
+
designSystem: z.unknown().optional(),
|
|
20
|
+
previous: z.unknown().optional(),
|
|
21
|
+
invalidReason: z.string().optional(),
|
|
22
|
+
ignoredTokens: z.array(z.string()).optional(),
|
|
23
|
+
saved: z.boolean().optional(),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const registerDesignSystemTools = (server: McpServer) => {
|
|
27
|
+
const register = createToolRegistrar(server);
|
|
28
|
+
|
|
29
|
+
register(
|
|
30
|
+
"design-system-get",
|
|
31
|
+
{
|
|
32
|
+
title: "Get the org design system",
|
|
33
|
+
description:
|
|
34
|
+
'Returns the org design system that restyles every HTML page without its own theme. status is "none" (nobody asked yet), "declined" (the requester said no; do not ask again), "active", or "invalid" (the stored record fails validation and pages ignore it). previous is the value the last design-system-set replaced, for a one-step undo.',
|
|
35
|
+
annotations: { readOnlyHint: true },
|
|
36
|
+
inputSchema: z.object({}),
|
|
37
|
+
outputSchema,
|
|
38
|
+
},
|
|
39
|
+
async () => {
|
|
40
|
+
const { current, previous } = await getDesignSystem();
|
|
41
|
+
return toolOk(`Design system status: ${current.status}.`, {
|
|
42
|
+
data: {
|
|
43
|
+
status: current.status,
|
|
44
|
+
...("record" in current ? { designSystem: current.record } : {}),
|
|
45
|
+
...("reason" in current ? { invalidReason: current.reason } : {}),
|
|
46
|
+
...("record" in previous ? { previous: previous.record } : {}),
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
register(
|
|
53
|
+
"design-system-set",
|
|
54
|
+
{
|
|
55
|
+
title: "Set the org design system",
|
|
56
|
+
description:
|
|
57
|
+
'Saves the org design system: a base preset plus token overrides, fonts, logo, mode lock and chart palette. Every HTML page without its own theme picks it up on its next view. Save only what the requester approved, after they saw a preview (the design-system-seed script builds one). To record a "no", pass status "declined". dryRun: true validates and returns the normalized record without saving. The replaced value is kept as previous (see design-system-get).',
|
|
58
|
+
annotations: { destructiveHint: false },
|
|
59
|
+
rbac: { permission: "design-system.write" },
|
|
60
|
+
inputSchema: DesignSystemInputSchema.extend({
|
|
61
|
+
dryRun: z
|
|
62
|
+
.boolean()
|
|
63
|
+
.optional()
|
|
64
|
+
.describe("Validate and return the normalized record without saving."),
|
|
65
|
+
}),
|
|
66
|
+
outputSchema,
|
|
67
|
+
},
|
|
68
|
+
async ({ dryRun, ...input }, requestInfo) => {
|
|
69
|
+
if (!requestInfo.agentId) return toolErr('Agent ID not found. Set the "X-Agent-ID" header.');
|
|
70
|
+
const agent = await getAgentById(requestInfo.agentId);
|
|
71
|
+
const decision = can({
|
|
72
|
+
principal: { kind: "agent", agentId: requestInfo.agentId, isLead: agent?.isLead ?? false },
|
|
73
|
+
verb: "design-system.write",
|
|
74
|
+
source: "mcp",
|
|
75
|
+
});
|
|
76
|
+
if (!decision.allow) return toolErr(decision.reason);
|
|
77
|
+
|
|
78
|
+
const userId = await resolveTaskAuditUserId(requestInfo.sourceTaskId, requestInfo.agentId);
|
|
79
|
+
let built: ReturnType<typeof buildDesignSystem>;
|
|
80
|
+
try {
|
|
81
|
+
built = buildDesignSystem(input, { userId, agentId: requestInfo.agentId });
|
|
82
|
+
} catch (err) {
|
|
83
|
+
if (err instanceof DesignSystemError) return toolErr(err.message);
|
|
84
|
+
throw err;
|
|
85
|
+
}
|
|
86
|
+
if (!dryRun) await saveDesignSystem(built.record);
|
|
87
|
+
const { record, ignored } = built;
|
|
88
|
+
return toolOk(
|
|
89
|
+
`${dryRun ? "Validated" : "Saved"} ${record.status} design system (basePreset=${record.basePreset}, mode=${record.mode}).` +
|
|
90
|
+
(ignored.length > 0 ? ` Ignored tokens: ${ignored.join(", ")}.` : ""),
|
|
91
|
+
{
|
|
92
|
+
data: {
|
|
93
|
+
status: record.status,
|
|
94
|
+
designSystem: record,
|
|
95
|
+
saved: !dryRun,
|
|
96
|
+
...(ignored.length > 0 ? { ignoredTokens: ignored } : {}),
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
);
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
};
|
|
@@ -8,7 +8,7 @@ export const registerMcpServerGetTool = (server: McpServer) => {
|
|
|
8
8
|
"mcp-server-get",
|
|
9
9
|
{
|
|
10
10
|
title: "Get MCP Server",
|
|
11
|
-
annotations: {
|
|
11
|
+
annotations: { readOnlyHint: true },
|
|
12
12
|
description:
|
|
13
13
|
"Get MCP server details by ID or name. Name resolution uses scope cascade: agent > swarm > global.",
|
|
14
14
|
inputSchema: z.object({
|
|
@@ -25,7 +25,7 @@ export const registerMcpServerListTool = (server: McpServer) => {
|
|
|
25
25
|
"mcp-server-list",
|
|
26
26
|
{
|
|
27
27
|
title: "List MCP Servers",
|
|
28
|
-
annotations: {
|
|
28
|
+
annotations: { readOnlyHint: true },
|
|
29
29
|
description:
|
|
30
30
|
"List MCP servers with optional filters. Use installedOnly to see servers installed for the calling agent.",
|
|
31
31
|
inputSchema: z.object({
|
|
@@ -39,7 +39,7 @@ export const registerRegisterChatChannelTool = (server: McpServer) => {
|
|
|
39
39
|
title: "Route a chat channel to an agent or workflow",
|
|
40
40
|
annotations: { idempotentHint: true },
|
|
41
41
|
description:
|
|
42
|
-
"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.",
|
|
42
|
+
"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.",
|
|
43
43
|
inputSchema: z.object({
|
|
44
44
|
adapter: z.enum(CHAT_SDK_ADAPTER_NAMES).describe("Chat SDK adapter name."),
|
|
45
45
|
channelId: z
|
|
@@ -52,6 +52,13 @@ export const registerRegisterChatChannelTool = (server: McpServer) => {
|
|
|
52
52
|
.optional()
|
|
53
53
|
.describe("Workflow whose webhook trigger receives the channel's messages."),
|
|
54
54
|
name: z.string().max(200).optional().describe("Display name for the mapping."),
|
|
55
|
+
defaultThreadId: z
|
|
56
|
+
.string()
|
|
57
|
+
.min(1)
|
|
58
|
+
.optional()
|
|
59
|
+
.describe(
|
|
60
|
+
"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.",
|
|
61
|
+
),
|
|
55
62
|
}),
|
|
56
63
|
outputSchema: swarmToolOutputSchema({
|
|
57
64
|
yourAgentId: z.string().optional(),
|
|
@@ -60,13 +67,14 @@ export const registerRegisterChatChannelTool = (server: McpServer) => {
|
|
|
60
67
|
.looseObject({
|
|
61
68
|
agentId: z.string().optional(),
|
|
62
69
|
workflowId: z.string().optional(),
|
|
70
|
+
defaultThreadId: z.string().optional(),
|
|
63
71
|
name: z.string().optional(),
|
|
64
72
|
createdAt: z.string().optional(),
|
|
65
73
|
})
|
|
66
74
|
.optional(),
|
|
67
75
|
}),
|
|
68
76
|
},
|
|
69
|
-
async ({ adapter, channelId, agentId, workflowId, name }, requestInfo) => {
|
|
77
|
+
async ({ adapter, channelId, agentId, workflowId, name, defaultThreadId }, requestInfo) => {
|
|
70
78
|
const data = { yourAgentId: requestInfo.agentId };
|
|
71
79
|
try {
|
|
72
80
|
if (!(await canManageChatChannels(requestInfo))) {
|
|
@@ -87,6 +95,7 @@ export const registerRegisterChatChannelTool = (server: McpServer) => {
|
|
|
87
95
|
...(agentId ? { agentId } : {}),
|
|
88
96
|
...(workflowId ? { workflowId } : {}),
|
|
89
97
|
...(name ? { name } : {}),
|
|
98
|
+
...(defaultThreadId ? { defaultThreadId } : {}),
|
|
90
99
|
createdAt: new Date().toISOString(),
|
|
91
100
|
};
|
|
92
101
|
const key = await putChatChannelMapping(adapter, channelId, mapping);
|
|
@@ -8,7 +8,7 @@ export const registerSkillGetFileTool = (server: McpServer) => {
|
|
|
8
8
|
"skill-get-file",
|
|
9
9
|
{
|
|
10
10
|
title: "Get Skill File",
|
|
11
|
-
annotations: {
|
|
11
|
+
annotations: { readOnlyHint: true },
|
|
12
12
|
description:
|
|
13
13
|
"Fetch a bundled reference file from a complex skill by skillId and relative path. Use this when the file is not available on disk.",
|
|
14
14
|
inputSchema: z.object({
|
|
@@ -9,7 +9,7 @@ export const registerSkillGetTool = (server: McpServer) => {
|
|
|
9
9
|
"skill-get",
|
|
10
10
|
{
|
|
11
11
|
title: "Get Skill",
|
|
12
|
-
annotations: {
|
|
12
|
+
annotations: { readOnlyHint: true },
|
|
13
13
|
description:
|
|
14
14
|
"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.",
|
|
15
15
|
inputSchema: z.object({
|
|
@@ -21,7 +21,7 @@ export const registerSkillListTool = (server: McpServer) => {
|
|
|
21
21
|
"skill-list",
|
|
22
22
|
{
|
|
23
23
|
title: "List Skills",
|
|
24
|
-
annotations: {
|
|
24
|
+
annotations: { readOnlyHint: true },
|
|
25
25
|
description: "List available skills with optional filters.",
|
|
26
26
|
inputSchema: z.object({
|
|
27
27
|
type: z.enum(["remote", "personal"]).optional().describe("Filter by type"),
|
|
@@ -21,7 +21,7 @@ export const registerSkillSearchTool = (server: McpServer) => {
|
|
|
21
21
|
"skill-search",
|
|
22
22
|
{
|
|
23
23
|
title: "Search Skills",
|
|
24
|
-
annotations: {
|
|
24
|
+
annotations: { readOnlyHint: true },
|
|
25
25
|
description: "Search skills by keyword (name and description).",
|
|
26
26
|
inputSchema: z.object({
|
|
27
27
|
query: z.string().min(1).describe("Search query"),
|
package/src/tools/utils.ts
CHANGED
|
@@ -18,7 +18,7 @@ import type {
|
|
|
18
18
|
ToolAnnotations,
|
|
19
19
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
20
20
|
import * as z from "zod";
|
|
21
|
-
import { upsertKv } from "../be/db";
|
|
21
|
+
import { getDbClient, upsertKv } from "../be/db";
|
|
22
22
|
import { bindLoopPath } from "../be/event-loop-lag";
|
|
23
23
|
import { MCP_OVERFLOW_NAMESPACE, mcpOverflowNamespace } from "../kv-overflow";
|
|
24
24
|
import { joinKvPath, type KvShapeEntry, splitKvPath, summarizeKvShape } from "../kv-view";
|
|
@@ -26,7 +26,12 @@ import { withSpan } from "../otel";
|
|
|
26
26
|
import { COLOR_LITERAL_THRESHOLD } from "../pages/color-literals";
|
|
27
27
|
import type { PermissionVerb } from "../rbac/permissions";
|
|
28
28
|
import { SCRIPT_LONG_TIMEOUT_HINT_MS } from "../scripts-runtime/executors/types";
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
DEFAULT_MODEL_TIER_MAP,
|
|
31
|
+
isTerminalTaskStatus,
|
|
32
|
+
type ModelTier,
|
|
33
|
+
type ProviderName,
|
|
34
|
+
} from "../types";
|
|
30
35
|
import { scrubObject, scrubSecrets } from "../utils/secret-scrubber";
|
|
31
36
|
|
|
32
37
|
type Meta = RequestHandlerExtra<ServerRequest, ServerNotification>;
|
|
@@ -400,10 +405,14 @@ const createPageNudge = (r: SwarmToolResult): string | undefined => {
|
|
|
400
405
|
usesDesignSystem?: unknown;
|
|
401
406
|
lightOnlyColors?: unknown;
|
|
402
407
|
colorLiteralCount?: unknown;
|
|
408
|
+
designSystemStatus?: unknown;
|
|
403
409
|
}
|
|
404
410
|
| undefined;
|
|
405
411
|
const count = data?.colorLiteralCount;
|
|
406
412
|
const sentences = [
|
|
413
|
+
data?.designSystemStatus === "none"
|
|
414
|
+
? "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."
|
|
415
|
+
: undefined,
|
|
407
416
|
data?.designVersion === 1 && data.usesDesignSystem === true
|
|
408
417
|
? "This page is on designVersion 1 (the original look), so design system classes, tokens and themes have no effect. Pass designVersion: 2."
|
|
409
418
|
: undefined,
|
|
@@ -1114,6 +1123,38 @@ async function applyPreToolCall(
|
|
|
1114
1123
|
};
|
|
1115
1124
|
}
|
|
1116
1125
|
|
|
1126
|
+
/** Tools a session may still call after its task reached a terminal status. */
|
|
1127
|
+
const TERMINAL_TASK_EXEMPT_TOOLS = new Set(["store-progress"]);
|
|
1128
|
+
|
|
1129
|
+
/**
|
|
1130
|
+
* Refuse a write from a session whose task already ended. A superseded or
|
|
1131
|
+
* cancelled task's harness can keep running until the worker kills it, and its
|
|
1132
|
+
* late `slack-reply` / `send-task` calls would act for a task the swarm
|
|
1133
|
+
* already moved past. Read-only is the registrar's `readOnlyHint: true`; a
|
|
1134
|
+
* tool without that annotation counts as a write. Scripts and extensions are
|
|
1135
|
+
* not agent sessions and skip the check.
|
|
1136
|
+
*/
|
|
1137
|
+
async function refuseWriteForTerminalTask(
|
|
1138
|
+
name: string,
|
|
1139
|
+
annotations: ToolAnnotations | undefined,
|
|
1140
|
+
requestInfo: RequestInfo,
|
|
1141
|
+
): Promise<SwarmToolResult | undefined> {
|
|
1142
|
+
if (requestInfo.callOrigin !== "mcp" || !requestInfo.sourceTaskId) return undefined;
|
|
1143
|
+
if (annotations?.readOnlyHint === true || TERMINAL_TASK_EXEMPT_TOOLS.has(name)) return undefined;
|
|
1144
|
+
const row = await getDbClient().get<{ status: string }>(
|
|
1145
|
+
"SELECT status FROM agent_tasks WHERE id = ?",
|
|
1146
|
+
[requestInfo.sourceTaskId],
|
|
1147
|
+
);
|
|
1148
|
+
if (!row || !isTerminalTaskStatus(row.status)) return undefined;
|
|
1149
|
+
return toolErr(
|
|
1150
|
+
`Task ${requestInfo.sourceTaskId} is ${row.status}, so this session can no longer call ${name}. Stop working on it.`,
|
|
1151
|
+
{
|
|
1152
|
+
details:
|
|
1153
|
+
"Only store-progress and read-only tools still work for a finished task. Any new work belongs to a new task.",
|
|
1154
|
+
},
|
|
1155
|
+
);
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1117
1158
|
function dispatchPostToolCall(
|
|
1118
1159
|
dispatcher: ExtensionDispatcher | undefined,
|
|
1119
1160
|
name: string,
|
|
@@ -1170,7 +1211,9 @@ export const createToolRegistrar = (server: McpServer) => {
|
|
|
1170
1211
|
async (span) => {
|
|
1171
1212
|
const pre = await applyPreToolCall(name, {}, requestInfo);
|
|
1172
1213
|
let durationMs = 0;
|
|
1173
|
-
let outcome =
|
|
1214
|
+
let outcome =
|
|
1215
|
+
pre.blocked ??
|
|
1216
|
+
(await refuseWriteForTerminalTask(name, config.annotations, requestInfo));
|
|
1174
1217
|
if (!outcome) {
|
|
1175
1218
|
const startedAt = Date.now();
|
|
1176
1219
|
try {
|
|
@@ -1210,7 +1253,9 @@ export const createToolRegistrar = (server: McpServer) => {
|
|
|
1210
1253
|
const pre = await applyPreToolCall(name, args, requestInfo, config.inputSchema);
|
|
1211
1254
|
const effectiveArgs = pre.args as InferInput<InputArgs>;
|
|
1212
1255
|
let durationMs = 0;
|
|
1213
|
-
let outcome =
|
|
1256
|
+
let outcome =
|
|
1257
|
+
pre.blocked ??
|
|
1258
|
+
(await refuseWriteForTerminalTask(name, config.annotations, requestInfo));
|
|
1214
1259
|
if (!outcome) {
|
|
1215
1260
|
const startedAt = Date.now();
|
|
1216
1261
|
try {
|
|
@@ -43,7 +43,7 @@ export const registerGetWorkflowRunTool = (server: McpServer) => {
|
|
|
43
43
|
"get-workflow-run",
|
|
44
44
|
{
|
|
45
45
|
title: "Get Workflow Run",
|
|
46
|
-
annotations: {
|
|
46
|
+
annotations: { readOnlyHint: true },
|
|
47
47
|
description: "Get details of a workflow run by ID, including all steps and their statuses.",
|
|
48
48
|
inputSchema: z.object({
|
|
49
49
|
id: z.string().uuid().describe("Workflow run ID"),
|
|
@@ -9,7 +9,7 @@ export const registerGetWorkflowTool = (server: McpServer) => {
|
|
|
9
9
|
"get-workflow",
|
|
10
10
|
{
|
|
11
11
|
title: "Get Workflow",
|
|
12
|
-
annotations: {
|
|
12
|
+
annotations: { readOnlyHint: true },
|
|
13
13
|
description:
|
|
14
14
|
"Get a workflow by ID, including its definition, triggers, cooldown, input, and auto-generated edges for UI rendering.",
|
|
15
15
|
inputSchema: z.object({
|
|
@@ -102,7 +102,7 @@ export const registerListWorkflowRunsTool = (server: McpServer) => {
|
|
|
102
102
|
"list-workflow-runs",
|
|
103
103
|
{
|
|
104
104
|
title: "List Workflow Runs",
|
|
105
|
-
annotations: {
|
|
105
|
+
annotations: { readOnlyHint: true },
|
|
106
106
|
description:
|
|
107
107
|
"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.",
|
|
108
108
|
inputSchema: listWorkflowRunsInputSchema,
|
|
@@ -9,7 +9,7 @@ export const registerListWorkflowsTool = (server: McpServer) => {
|
|
|
9
9
|
"list-workflows",
|
|
10
10
|
{
|
|
11
11
|
title: "List Workflows",
|
|
12
|
-
annotations: {
|
|
12
|
+
annotations: { readOnlyHint: true },
|
|
13
13
|
description:
|
|
14
14
|
"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.",
|
|
15
15
|
inputSchema: z.object({
|