@desplega.ai/agent-swarm 2.10.0 → 2.11.0
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-weaaxey3.js +16 -0
- package/dist/{acp-targets-arrwv4f0.js → acp-targets-5wyy2b9m.js} +9 -9
- package/dist/{actions-y0d2n1c2.js → actions-4nxq386s.js} +24 -23
- package/dist/{agent-fs-provision-tpj7sktd.js → agent-fs-provision-v6enh76w.js} +4 -4
- package/dist/{amp-adapter-vmmnmw8d.js → amp-adapter-ze3x22qn.js} +3 -3
- package/dist/{anthropic-messages-zdca3gv1.js → anthropic-messages-88b7s3n9.js} +177 -25
- package/dist/{app-wb7w45dq.js → app-kyqt8ehw.js} +7 -6
- package/dist/{approval-notifications-7mqr6vbd.js → approval-notifications-a0db0esw.js} +7 -6
- package/dist/{assistant-gf60454p.js → assistant-9g5jzq25.js} +26 -25
- package/dist/{azure-openai-responses-b3y7fz36.js → azure-openai-responses-jeaas6x0.js} +10 -10
- package/dist/{boot-args-schema-qxmd59sr.js → boot-args-schema-d7fme4q1.js} +1 -1
- package/dist/{boot-reembed-wb44vc3s.js → boot-reembed-6wpazmpw.js} +1 -1
- package/dist/{boot-reembed-5tmeskj2.js → boot-reembed-jrwxeye2.js} +1 -1
- package/dist/{boot-scrub-sweep-25bxhnw4.js → boot-scrub-sweep-52h7yntp.js} +2 -2
- package/dist/{boot-seeds-nj9za0vk.js → boot-seeds-kb3dxjex.js} +4 -4
- package/dist/{boxd-wn235q80.js → boxd-jrrmkv3w.js} +2 -2
- package/dist/{claude-adapter-d3krpdyb.js → claude-adapter-0c0y8fqp.js} +8 -8
- package/dist/{claude-managed-adapter-t8nfgcgz.js → claude-managed-adapter-w2es07qq.js} +4 -4
- package/dist/{claude-managed-setup-7y4pwd81.js → claude-managed-setup-9ssb7ct4.js} +4 -4
- package/dist/{claude-sdk-session-d138zy0e.js → claude-sdk-session-p6t0gyse.js} +10941 -10412
- package/dist/{cli-p0n7b5rz.js → cli-075ccjh6.js} +344 -130
- package/dist/{cli-3caf7pmg.js → cli-0bgj4rh5.js} +3 -3
- package/dist/{cli-7r162fxe.js → cli-14xdms9a.js} +23 -17
- package/dist/{cli-rqx70rcz.js → cli-17qzb39j.js} +5 -2
- package/dist/{cli-y4ccxtz5.js → cli-1h4njv9y.js} +144 -6
- package/dist/{cli-6ym4jhzp.js → cli-27fat7st.js} +7 -7
- package/dist/{cli-k3q2va86.js → cli-2aacfdcn.js} +5 -5
- package/dist/{cli-vq2eg24x.js → cli-2gvdvsxj.js} +3 -3
- package/dist/{cli-sb4426be.js → cli-2jtfm8kh.js} +5 -5
- package/dist/{cli-6ehs4mta.js → cli-2z2c4k6q.js} +18 -4
- package/dist/{cli-6237rnyr.js → cli-3bpr3wks.js} +1 -1
- package/dist/{cli-5qhfv9rw.js → cli-453497a0.js} +44 -17
- package/dist/{cli-2rnd5j3t.js → cli-4aswccje.js} +2 -2
- package/dist/{cli-4ymxrwg5.js → cli-4dyzzkfb.js} +2 -2
- package/dist/{cli-p0c3vtch.js → cli-4g323fjh.js} +772 -515
- package/dist/{cli-3kd08rej.js → cli-4jjrhy48.js} +1 -1
- package/dist/{cli-fcfbct2j.js → cli-4kzp7r0q.js} +5 -5
- package/dist/{cli-kxn3747f.js → cli-4se3x6qm.js} +1 -26
- package/dist/{cli-zeh2mhkg.js → cli-5ptj757f.js} +1 -1
- package/dist/{cli-539h29es.js → cli-6a3j25xd.js} +224 -189
- package/dist/{cli-hnamkvnc.js → cli-6c9ve77f.js} +2 -2
- package/dist/{cli-3et6fmfe.js → cli-6n7y5ypy.js} +1 -1
- package/dist/{cli-8y43jx2r.js → cli-6p8p2e6r.js} +16 -9
- package/dist/{cli-zk7v5s89.js → cli-6tvh1fwq.js} +3 -3
- package/dist/{cli-p74md7t8.js → cli-7b7rxz22.js} +13 -15
- package/dist/{cli-5a6pqy45.js → cli-7e8sxqv5.js} +1 -1
- package/dist/{cli-6037prsx.js → cli-892y3vfp.js} +13 -13
- package/dist/cli-8mfdbdhe.js +43 -0
- package/dist/{cli-s1zqk1aj.js → cli-8zmpwe79.js} +15 -9
- package/dist/{cli-zcfpsfzf.js → cli-96234j5w.js} +3 -3
- package/dist/{cli-1z4qggfe.js → cli-9fvk9mv8.js} +30 -21
- package/dist/{cli-7mv4h3sn.js → cli-9g12h1aq.js} +2 -2
- package/dist/{cli-aw83sr40.js → cli-9knhkkgr.js} +3 -3
- package/dist/{cli-5mpy301f.js → cli-9t7syepg.js} +1 -1
- package/dist/{cli-qj39vrc6.js → cli-9yjhshah.js} +1 -1
- package/dist/{cli-6cwr32fe.js → cli-a02habn6.js} +422 -140
- package/dist/{cli-7evph51z.js → cli-a49frv85.js} +2 -2
- package/dist/{cli-3f8zbtqa.js → cli-a6q6x15h.js} +9 -8
- package/dist/{cli-j6te8keb.js → cli-atm0hkes.js} +8 -8
- package/dist/{cli-9fjr27ez.js → cli-b82a13ga.js} +13 -13
- package/dist/{cli-7zm3b3f5.js → cli-bf0t77nf.js} +1 -1
- package/dist/{cli-2xv18ywz.js → cli-bmqp0ser.js} +2 -2
- package/dist/{cli-mk7c5ac4.js → cli-bq97k63w.js} +2 -2
- package/dist/{cli-vfqvrd82.js → cli-cstggwq7.js} +2 -2
- package/dist/{cli-md50mj0r.js → cli-czvvnfr9.js} +3 -3
- package/dist/{cli-b6px1k1q.js → cli-dd2k2mcd.js} +1 -1
- package/dist/{cli-fq2rr3jb.js → cli-djt6wmrc.js} +6 -6
- package/dist/{cli-tsa40663.js → cli-ebqx630g.js} +3 -3
- package/dist/{cli-z0m452jr.js → cli-f7dhm7hh.js} +1 -1
- package/dist/{cli-mys27d03.js → cli-f8yhybxr.js} +3 -3
- package/dist/{cli-5gpqgs8b.js → cli-fwjwkw66.js} +2 -2
- package/dist/{cli-gabsjg8x.js → cli-g56fxddf.js} +1 -1
- package/dist/{cli-y8p78ekx.js → cli-h2qtafm4.js} +18 -18
- package/dist/{cli-psffsanb.js → cli-ha4ek2nb.js} +6 -1
- package/dist/{cli-th1dkc2v.js → cli-hnh8erra.js} +2 -2
- package/dist/{cli-w16kwbzw.js → cli-htymm48w.js} +1 -1
- package/dist/{cli-124ntmf0.js → cli-j2r1apqm.js} +138 -59
- package/dist/{cli-43ms35q9.js → cli-k3c13za2.js} +3 -3
- package/dist/{cli-54vrpgm0.js → cli-k3facve0.js} +8 -5
- package/dist/{cli-v8z0yga9.js → cli-k4r5sfaj.js} +4 -4
- package/dist/{cli-91pkxres.js → cli-kbm659dk.js} +2 -2
- package/dist/{cli-q5srsxq2.js → cli-m00c47q6.js} +110 -27
- package/dist/{cli-3aaeb78m.js → cli-mhrr4d5b.js} +95 -10
- package/dist/{cli-xqdz5cqm.js → cli-mz7ycqn8.js} +1 -0
- package/dist/{cli-qrta34nb.js → cli-n6ygvrrm.js} +4 -4
- package/dist/{cli-k5yewqgd.js → cli-nbakg5xh.js} +3 -3
- package/dist/{cli-nstkanmx.js → cli-nc39ym5q.js} +8 -8
- package/dist/{cli-01k6wpr9.js → cli-p1a4khta.js} +7 -7
- package/dist/{cli-t9ga4qmb.js → cli-p8zqbbt1.js} +40 -33
- package/dist/{cli-v46zsvqk.js → cli-ph95yejc.js} +2 -2
- package/dist/{cli-k6nejceb.js → cli-q4z9s6zs.js} +2 -2
- package/dist/{cli-kbtzfrxj.js → cli-q71g5q39.js} +3 -3
- package/dist/{cli-vs9vdpy0.js → cli-qncx2r0s.js} +1 -1
- package/dist/{cli-hg42n3hx.js → cli-qrzq3hvg.js} +8 -8
- package/dist/{cli-x40a0w9j.js → cli-r813c7rb.js} +1 -1
- package/dist/{cli-kpgcm7xy.js → cli-ramn8jae.js} +1 -1
- package/dist/{cli-cc93xzes.js → cli-raqw9fw9.js} +28 -17
- package/dist/cli-rhsc2zyx.js +68 -0
- package/dist/{cli-8st34zhr.js → cli-rpmw4fsv.js} +57 -19
- package/dist/{cli-had1p04a.js → cli-rwgwen5v.js} +4 -4
- package/dist/{cli-tr27kwyg.js → cli-rytq7dm2.js} +261 -6
- package/dist/{cli-s1khw52h.js → cli-s9twe4x0.js} +66 -17
- package/dist/{cli-2v2zdm0a.js → cli-t2s7j5cy.js} +2 -2
- package/dist/{cli-nv4xsvmk.js → cli-tb4j757d.js} +7 -7
- package/dist/{cli-q2d3e1k1.js → cli-thd3005a.js} +1 -1
- package/dist/cli-tsfkcd4v.js +30 -0
- package/dist/{cli-jrbq4djp.js → cli-v3zcnr8g.js} +1 -1
- package/dist/{cli-zfqg6fzn.js → cli-vbppqvte.js} +3 -3
- package/dist/{cli-qx4f057j.js → cli-vy3fn0mz.js} +4 -4
- package/dist/{cli-7sf9sb0w.js → cli-w5dar1bk.js} +1 -1
- package/dist/{cli-w1q68d8x.js → cli-wz4e5am2.js} +9 -9
- package/dist/{cli-m9cvf7vs.js → cli-xqbqwpxr.js} +14 -14
- package/dist/{cli-2spnz7ye.js → cli-ynph3b70.js} +11137 -8332
- package/dist/{cli-43evxwj4.js → cli-yvzxbztc.js} +9 -4
- package/dist/{cli-vsw91x06.js → cli-yzxqwcvq.js} +3 -6
- package/dist/{cli-wafmk3fn.js → cli-zb1hff00.js} +12 -12
- package/dist/{cli-yab6sh8p.js → cli-zcghfsdg.js} +23 -4
- package/dist/{cli-wwp1bd3n.js → cli-zhn4r1rz.js} +519 -75
- package/dist/{cli-tvgqesec.js → cli-zqq57pgx.js} +4 -4
- package/dist/cli.js +28 -27
- package/dist/{cloudflare-workers-ai-system-one-4aysy6rh.js → cloudflare-workers-ai-system-one-w3m0fbf8.js} +2 -2
- package/dist/{codex-adapter-exfdbj73.js → codex-adapter-ssahg4h4.js} +8 -8
- package/dist/{codex-hook-59atdwd8.js → codex-hook-aqtj17yr.js} +1 -1
- package/dist/{codex-login-a239g1ah.js → codex-login-9c7aggxe.js} +1 -1
- package/dist/{codex-session-runner-xhznc4g3.js → codex-session-runner-xn63q3h7.js} +9 -9
- package/dist/{commands-d8g349v4.js → commands-ctey7tr5.js} +3 -3
- package/dist/{controller-mwgdmb8y.js → controller-rqhbppg9.js} +4 -4
- package/dist/{controllers-connect-5v7qx04j.js → controllers-connect-w3qbpbt1.js} +22 -21
- package/dist/{core-sxy4epp2.js → core-df1n049h.js} +19 -18
- package/dist/{cursor-adapter-p2q5h35d.js → cursor-adapter-r819hf1a.js} +2 -2
- package/dist/{db-wcw0b2j8.js → db-2ah39cyx.js} +2 -2
- package/dist/{db-qpganbeb.js → db-p5drc1d1.js} +3 -3
- package/dist/{devin-adapter-zp4tqq53.js → devin-adapter-bc6g0x29.js} +1 -1
- package/dist/{dispatcher-8d8s49yz.js → dispatcher-x6w14pde.js} +19 -18
- package/dist/{docker-09tkkg0n.js → docker-6c4reetq.js} +51 -14
- package/dist/{dsh-adapter-me0twn13.js → dsh-adapter-h8qn14n4.js} +2 -2
- package/dist/{e2b-sm28k0k3.js → e2b-jg7kyyef.js} +6 -6
- package/dist/{e2b-3v1e745x.js → e2b-z4ec0qve.js} +3 -3
- package/dist/{easter-egg-3d-wv7w5ty6.js → easter-egg-3d-1y6r9gxy.js} +1 -1
- package/dist/{embedding-space-e48xchqa.js → embedding-space-z6ptw3jk.js} +6 -6
- package/dist/{embeddings-tgq2afbq.js → embeddings-0sxb1d2h.js} +1 -1
- package/dist/{event-bus-xr83x566.js → event-bus-swr88jg5.js} +1 -1
- package/dist/{execute-8rhwrk7f.js → execute-6m1ex8ce.js} +8 -4
- package/dist/{external-channel-8bt3j2pm.js → external-channel-ezer7pk0.js} +2 -2
- package/dist/fx-adapter-zwmps9re.js +19 -0
- package/dist/{google-generative-ai-bh0djqjp.js → google-generative-ai-sw77egmr.js} +9 -9
- package/dist/{google-vertex-prjbw8dj.js → google-vertex-rrw93g8h.js} +9 -9
- package/dist/grok-adapter-q0avf919.js +19 -0
- package/dist/handlers-g5jq0e4q.js +36 -0
- package/dist/{heartbeat-x0056ra5.js → heartbeat-6c4fr49t.js} +22 -21
- package/dist/{hook-mrd2ayxv.js → hook-02rt5tvq.js} +8 -8
- package/dist/{hook-a7vmn2st.js → hook-t1c5avbv.js} +5 -5
- package/dist/{http-ym9c5svp.js → http-qa3h32a1.js} +2049 -148
- package/dist/index-1f6m47mq.js +37 -0
- package/dist/index-1p1mpqda.js +36 -0
- package/dist/{index-p46tvwtx.js → index-akbgsdhh.js} +25 -24
- package/dist/{index-ny60jcat.js → index-e42j998x.js} +16 -13
- package/dist/{index-b5wgnm78.js → index-kdmkfjt7.js} +4 -4
- package/dist/{index-01ns1pkw.js → index-kqv9ebfj.js} +1 -1
- package/dist/{index-9myfj74s.js → index-kzdqn3dd.js} +3 -3
- package/dist/{index-4a0670yh.js → index-p2f5xg64.js} +6 -6
- package/dist/{index-x6azjwm8.js → index-qpjk2hxk.js} +1 -1
- package/dist/index-tnkd410q.js +41 -0
- package/dist/{k8s-m56sw868.js → k8s-7jrh5va2.js} +73 -14
- package/dist/{keepalive-7yxg8z4c.js → keepalive-jmf6pn8c.js} +4 -4
- package/dist/lead-m5e7xt93.js +75 -0
- package/dist/{llama-cpp-classify-nfgswa1m.js → llama-cpp-classify-yvb8vh7w.js} +2 -2
- package/dist/{maintenance-6tefxmk1.js → maintenance-g7v15tj1.js} +1 -1
- package/dist/{mistral-conversations-tm2vd4gc.js → mistral-conversations-w4bncwbt.js} +7 -7
- package/dist/{node-7qsx5kvm.js → node-z67yjre7.js} +19 -13
- package/dist/{oauth-refresh-sweep-70cavc3a.js → oauth-refresh-sweep-ywgf8tbr.js} +3 -3
- package/dist/{onboard-fja65z08.js → onboard-m3fedypq.js} +3 -3
- package/dist/{openai-codex-responses-sxjv60xx.js → openai-codex-responses-70g39cgz.js} +20 -14
- package/dist/{openai-completions-0c7qnhsx.js → openai-completions-cv3hp4h5.js} +18 -11
- package/dist/{openai-decisions-ytp6w6xh.js → openai-decisions-fyq1p9f9.js} +2 -2
- package/dist/{openai-responses-a7h29chp.js → openai-responses-trsvnks6.js} +13 -11
- package/dist/{opencode-adapter-hakkm7yh.js → opencode-adapter-19ktcbb9.js} +7 -7
- package/dist/{openrouter-images-xr9gme9x.js → openrouter-images-0jj12a2q.js} +6 -6
- package/dist/{otel-impl-7zhnt6gj.js → otel-impl-3ehm1hgc.js} +2 -2
- package/dist/{pending-h01yzpx4.js → pending-fwj2fatd.js} +20 -19
- package/dist/{pi-messages-2j0fpqwq.js → pi-messages-zk3g4esn.js} +1 -1
- package/dist/{pi-mono-adapter-f52hz743.js → pi-mono-adapter-xdeesvc4.js} +18 -17
- package/dist/{pricing-refresh-fzxvk2zf.js → pricing-refresh-4j8dzvxg.js} +2 -2
- package/dist/{rbac-roles-9v6vhgbs.js → rbac-roles-8msjr07m.js} +3 -3
- package/dist/{rbac-roles-hfgh8sba.js → rbac-roles-n7t2acv8.js} +2 -2
- package/dist/{render-v2-1rgspxzf.js → render-v2-j7qggj8h.js} +7 -6
- package/dist/{resume-tqy61x24.js → resume-hj1mn65y.js} +9 -8
- package/dist/{runtime-exkxyx5f.js → runtime-z31mdsgv.js} +2 -2
- package/dist/{session-access-3act7vt4.js → session-access-w38fh09a.js} +4 -4
- package/dist/{session-source-backfill-82qe7fqq.js → session-source-backfill-ax6qxv20.js} +3 -3
- package/dist/{setup-ry1vfdef.js → setup-dsqmpfcr.js} +1 -1
- package/dist/thread-buffer-nf55vwx3.js +39 -0
- package/dist/tree-visibility-6vqmnr71.js +24 -0
- package/dist/{typesafe-system-one-vcfj2ak8.js → typesafe-system-one-qkvkgrcz.js} +2 -2
- package/dist/{user-merge-jobs-bx6bf7db.js → user-merge-jobs-mvheb3ed.js} +3 -3
- package/dist/{virtual-modules-s0rjzcqq.js → virtual-modules-w2qk2wew.js} +32 -10
- package/dist/{work-objects-z2e5tv03.js → work-objects-4ahy5es5.js} +22 -21
- package/dist/worker-ews1nyhw.js +75 -0
- package/dist/{worker-follow-up-y3xeg89w.js → worker-follow-up-1gs4aw7y.js} +19 -18
- package/dist/{x-wg164ss9.js → x-3wr8c5sh.js} +2 -2
- package/openapi.json +995 -49
- package/package.json +9 -8
- package/src/be/db/request-composition.ts +190 -0
- package/src/be/db/runtime.ts +15 -0
- package/src/be/db/slack-trees.ts +220 -10
- package/src/be/db/tasks/human-free.ts +3 -2
- package/src/be/db/workflow-run-retention.ts +101 -0
- package/src/be/db-client.ts +23 -1
- package/src/be/db-retention-defaults.ts +46 -0
- package/src/be/db-retention.ts +55 -6
- package/src/be/mcp-events/catalog.ts +108 -0
- package/src/be/mcp-events/dispatcher.ts +202 -0
- package/src/be/mcp-events/protocol.ts +296 -0
- package/src/be/mcp-events/store.ts +231 -0
- package/src/be/mcp-events/webhook.ts +226 -0
- package/src/be/memory/providers/sqlite-store.ts +110 -24
- package/src/be/memory/review-recall-filter.ts +22 -0
- package/src/be/memory/search-candidates.ts +5 -7
- package/src/be/memory/types.ts +5 -0
- package/src/be/migrations/322_runtime_pool_workspace.sql +8 -0
- package/src/be/migrations/323_slack_task_tree_visibility.sql +9 -0
- package/src/be/migrations/326_slack_reconcile_pages.sql +13 -0
- package/src/be/migrations/327_mcp_event_subscriptions.sql +57 -0
- package/src/be/migrations/329_workflow_run_retention.sql +9 -0
- package/src/be/migrations/330_request_composition.sql +22 -0
- package/src/be/model-profile-check.ts +1 -1
- package/src/be/multi-runtime.ts +32 -4
- package/src/be/runtime-pools/controllers.ts +18 -3
- package/src/be/runtime-pools/db.ts +15 -4
- package/src/be/runtime-pools/supervisor.ts +42 -2
- package/src/be/swarm-config-guard.ts +10 -2
- package/src/commands/context-preamble.ts +11 -4
- package/src/commands/credential-outcome-report.ts +33 -9
- package/src/commands/e2b-stack-wizard.tsx +12 -6
- package/src/commands/runner.ts +116 -12
- package/src/extensions/catalog.generated.json +1 -1
- package/src/github/app.ts +59 -14
- package/src/http/all-routes.ts +2 -0
- package/src/http/config.ts +2 -1
- package/src/http/core.ts +2 -0
- package/src/http/github-token.ts +66 -0
- package/src/http/index.ts +21 -0
- package/src/http/mcp-user.ts +11 -8
- package/src/http/mcp.ts +58 -42
- package/src/http/prompt-templates.ts +1 -0
- package/src/http/request-composition.ts +310 -0
- package/src/http/tasks.ts +6 -1
- package/src/http/tool-schema-estimate.ts +95 -0
- package/src/http/workflows.ts +29 -11
- package/src/integrations/chat-sdk/inbound.ts +2 -2
- package/src/prompts/base-prompt.ts +133 -7
- package/src/prompts/resolver.ts +41 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/opencode-adapter.ts +72 -1
- package/src/providers/opencode-swarm-plugin.ts +22 -3
- package/src/providers/pi-mono-adapter.ts +1 -0
- package/src/providers/pi-mono-extension.ts +71 -0
- package/src/providers/pricing-sources.md +4 -0
- package/src/providers/request-composition-hook.ts +312 -0
- package/src/providers/types.ts +5 -0
- package/src/runtime-providers/controller-protocol.ts +7 -0
- package/src/runtime-providers/docker.ts +80 -12
- package/src/runtime-providers/k8s.ts +111 -6
- package/src/runtime-providers/types.ts +17 -0
- package/src/scheduler/scheduler.ts +1 -1
- package/src/server-user.ts +16 -1
- package/src/slack/ack.ts +10 -5
- package/src/slack/actions.ts +3 -3
- package/src/slack/app.ts +2 -0
- package/src/slack/assistant.ts +4 -4
- package/src/slack/blocks.ts +3 -3
- package/src/slack/handlers.ts +3 -3
- package/src/slack/reaction-shortcode.ts +23 -2
- package/src/slack/render-v2.ts +297 -200
- package/src/slack/responses.ts +7 -5
- package/src/slack/thread-buffer.ts +3 -3
- package/src/slack/tree-visibility.ts +64 -0
- package/src/tasks/worker-follow-up.ts +127 -17
- package/src/tests/azure-devops-outbound.test.ts +47 -14
- package/src/tests/base-prompt.test.ts +149 -1
- package/src/tests/check-playwright-version.test.ts +33 -0
- package/src/tests/context-preamble-budget.test.ts +65 -0
- package/src/tests/credential-outcome-report.test.ts +81 -1
- package/src/tests/db-client.test.ts +22 -0
- package/src/tests/db-retention-defaults.test.ts +244 -0
- package/src/tests/db-retention.test.ts +2 -1
- package/src/tests/db-runtime.test.ts +2 -1
- package/src/tests/deploy-release-dispatch.test.ts +332 -0
- package/src/tests/e2b-stack-wizard.test.tsx +156 -0
- package/src/tests/entrypoint-chown-no-follow.test.ts +69 -0
- package/src/tests/entrypoint-repo-clone-target.test.ts +112 -0
- package/src/tests/env-flag.test.ts +4 -2
- package/src/tests/event-loop-lag.test.ts +12 -18
- package/src/tests/extensions-example-slack-reply-gate.test.ts +15 -0
- package/src/tests/fixtures/base-prompt-baseline-cases.ts +78 -0
- package/src/tests/fixtures/base-prompt-baseline.json +18 -0
- package/src/tests/github-app-worker-auth-helper.test.ts +325 -0
- package/src/tests/github-installation-token-route.test.ts +199 -0
- package/src/tests/mcp-user-events.test.ts +708 -0
- package/src/tests/memory-key-paths.test.ts +4 -1
- package/src/tests/memory-search-stall.test.ts +421 -0
- package/src/tests/migration-322-runtime-pool-workspace.test.ts +116 -0
- package/src/tests/migration-329-workflow-run-retention.test.ts +32 -0
- package/src/tests/model-profile-fallbacks.test.ts +236 -2
- package/src/tests/opencode-adapter.test.ts +86 -0
- package/src/tests/pi-mono-extension.test.ts +168 -0
- package/src/tests/preload-env.test.ts +61 -1
- package/src/tests/preload.ts +22 -0
- package/src/tests/prompt-template-resolver.test.ts +85 -0
- package/src/tests/reload-config.test.ts +45 -0
- package/src/tests/request-composition.test.ts +447 -0
- package/src/tests/runner-max-concurrent.test.ts +86 -0
- package/src/tests/runtime-pools-db.test.ts +80 -0
- package/src/tests/runtime-provider-registration.test.ts +8 -0
- package/src/tests/runtime-providers-docker.test.ts +192 -1
- package/src/tests/runtime-providers-k8s.test.ts +127 -0
- package/src/tests/runtime-remote-controller.test.ts +64 -1
- package/src/tests/runtime-supervisor.test.ts +101 -0
- package/src/tests/script-connections.test.ts +8 -0
- package/src/tests/slack-blocks.test.ts +18 -0
- package/src/tests/slack-empty-icon-config.test.ts +113 -0
- package/src/tests/slack-reaction-config.test.ts +38 -2
- package/src/tests/slack-render-v2-query-plans.test.ts +100 -1
- package/src/tests/slack-render-v2-reconcile.test.ts +75 -4
- package/src/tests/slack-render-v2.test.ts +683 -11
- package/src/tests/swarm-config-reserved-keys.test.ts +1 -0
- package/src/tests/task-session-prompts.test.ts +37 -0
- package/src/tests/user-delete-perf.test.ts +36 -9
- package/src/tests/webhook-filter.test.ts +327 -0
- package/src/tests/workflow-async-v2.test.ts +19 -16
- package/src/tests/workflow-definition-telemetry.test.ts +15 -5
- package/src/tests/workflow-e2e.test.ts +1 -9
- package/src/tests/workflow-finalization-races.test.ts +553 -0
- package/src/tests/workflow-foreach.test.ts +2 -0
- package/src/tests/workflow-hitl-routing.test.ts +26 -20
- package/src/tests/workflow-http-v2.test.ts +105 -2
- package/src/tests/workflow-idempotency.test.ts +41 -0
- package/src/tests/workflow-mcp-webhook-filter.test.ts +214 -0
- package/src/tests/workflow-parallel-park.test.ts +297 -0
- package/src/tests/workflow-retry-v2.test.ts +57 -21
- package/src/tests/workflow-retry-validation.test.ts +13 -13
- package/src/tests/workflow-runs-retention.test.ts +533 -0
- package/src/tests/workflow-script-principal.test.ts +7 -2
- package/src/tests/workflow-tla-races.test.ts +7 -2
- package/src/tests/workflow-triggers-v2.test.ts +201 -0
- package/src/tests/workflow-wait-builtin-events.test.ts +3 -1
- package/src/tests/workflow-wait-event.test.ts +28 -2
- package/src/tests/workflow-wait-poller.test.ts +94 -0
- package/src/tests/workflow-wait-time.test.ts +7 -3
- package/src/tests/workflow-wait.test.ts +26 -0
- package/src/tests/workflow-wait.ts +44 -0
- package/src/tools/workflows/create-workflow.ts +7 -3
- package/src/tools/workflows/update-workflow.ts +7 -3
- package/src/types.ts +200 -2
- package/src/utils/credentials.ts +7 -0
- package/src/workflows/checkpoint.ts +18 -0
- package/src/workflows/engine.ts +38 -10
- package/src/workflows/foreach-driver.ts +42 -4
- package/src/workflows/recovery.ts +6 -1
- package/src/workflows/resume.ts +11 -3
- package/src/workflows/retry-poller.ts +17 -4
- package/src/workflows/successor-routing.ts +108 -0
- package/src/workflows/task-step-routing.ts +5 -2
- package/src/workflows/triggers.ts +21 -36
- package/src/workflows/wait-poller.ts +6 -2
- package/src/workflows/webhook-filter.ts +203 -0
- package/templates/extensions/slack-reply-gate/hooks.ts +8 -4
- package/templates/skills/swarm-docs/content.md +2 -0
- package/dist/acp-adapter-bht22g3k.js +0 -16
- package/dist/fx-adapter-adtdb3jb.js +0 -19
- package/dist/grok-adapter-accnn9km.js +0 -19
- package/dist/handlers-1x77561e.js +0 -35
- package/dist/index-48qzcqzj.js +0 -35
- package/dist/index-rkvaambe.js +0 -36
- package/dist/index-xj1mq27m.js +0 -40
- package/dist/lead-enzn86bz.js +0 -74
- package/dist/thread-buffer-3x93yexa.js +0 -38
- package/dist/worker-zfcv2wbf.js +0 -74
|
@@ -0,0 +1,708 @@
|
|
|
1
|
+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import { createHmac, randomBytes } from "node:crypto";
|
|
3
|
+
import { unlink } from "node:fs/promises";
|
|
4
|
+
import {
|
|
5
|
+
createServer as createHttpServer,
|
|
6
|
+
type IncomingMessage,
|
|
7
|
+
type Server,
|
|
8
|
+
type ServerResponse,
|
|
9
|
+
} from "node:http";
|
|
10
|
+
import type { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
11
|
+
import {
|
|
12
|
+
closeDb,
|
|
13
|
+
completeTask,
|
|
14
|
+
createTaskExtended,
|
|
15
|
+
createUser,
|
|
16
|
+
failTask,
|
|
17
|
+
getDbClient,
|
|
18
|
+
initDb,
|
|
19
|
+
startTask,
|
|
20
|
+
} from "../be/db";
|
|
21
|
+
import {
|
|
22
|
+
__setRetryDelaysForTests,
|
|
23
|
+
initMcpEventsDispatcher,
|
|
24
|
+
stopMcpEventsDispatcher,
|
|
25
|
+
} from "../be/mcp-events/dispatcher";
|
|
26
|
+
import {
|
|
27
|
+
MAX_SUBSCRIPTIONS_PER_USER,
|
|
28
|
+
VERIFICATIONS_PER_USER_PER_HOUR,
|
|
29
|
+
} from "../be/mcp-events/protocol";
|
|
30
|
+
import {
|
|
31
|
+
__setWebhookTestOverrides,
|
|
32
|
+
callbackUrlProblem,
|
|
33
|
+
parseWebhookSecret,
|
|
34
|
+
} from "../be/mcp-events/webhook";
|
|
35
|
+
import { type IdentityActor, mintToken, revokeToken } from "../be/users";
|
|
36
|
+
import { handleMcpUser } from "../http/mcp-user";
|
|
37
|
+
import { listenOnFreePort } from "./test-net";
|
|
38
|
+
|
|
39
|
+
const TEST_DB_PATH = "./test-mcp-user-events.sqlite";
|
|
40
|
+
const ACTOR: IdentityActor = { kind: "operator", id: "test" };
|
|
41
|
+
const LOCAL_RECEIVER_OVERRIDES = {
|
|
42
|
+
allowInsecure: true,
|
|
43
|
+
guard: { policy: { allowPrivate: true, allowlist: null } },
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
async function removeDbFiles(path: string): Promise<void> {
|
|
47
|
+
for (const suffix of ["", "-wal", "-shm"]) {
|
|
48
|
+
try {
|
|
49
|
+
await unlink(path + suffix);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ─── MCP server under test ───────────────────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
let mcpServer: Server;
|
|
59
|
+
let mcpPort: number;
|
|
60
|
+
|
|
61
|
+
function createMcpServer(): Server {
|
|
62
|
+
const transports: Record<string, StreamableHTTPServerTransport> = {};
|
|
63
|
+
const sessionUsers: Record<string, string> = {};
|
|
64
|
+
return createHttpServer(async (req: IncomingMessage, res: ServerResponse) => {
|
|
65
|
+
if (await handleMcpUser(req, res, transports, sessionUsers)) return;
|
|
66
|
+
res.writeHead(404);
|
|
67
|
+
res.end();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function parseMcpPayload(text: string): unknown {
|
|
72
|
+
const trimmed = text.trim();
|
|
73
|
+
if (!trimmed) return null;
|
|
74
|
+
if (trimmed.startsWith("event:") || trimmed.startsWith("data:")) {
|
|
75
|
+
return JSON.parse(
|
|
76
|
+
trimmed
|
|
77
|
+
.split("\n")
|
|
78
|
+
.filter((line) => line.startsWith("data:"))
|
|
79
|
+
.map((line) => line.slice("data:".length).trim())
|
|
80
|
+
.join("\n"),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
return JSON.parse(trimmed);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
type RpcResponse = {
|
|
87
|
+
result?: Record<string, unknown>;
|
|
88
|
+
error?: { code: number; message: string; data?: Record<string, unknown> };
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
let rpcId = 10;
|
|
92
|
+
|
|
93
|
+
async function mcpPost(
|
|
94
|
+
token: string,
|
|
95
|
+
body: Record<string, unknown>,
|
|
96
|
+
sessionId?: string,
|
|
97
|
+
): Promise<{ status: number; payload: RpcResponse; sessionId: string | null }> {
|
|
98
|
+
const headers: Record<string, string> = {
|
|
99
|
+
Accept: "application/json, text/event-stream",
|
|
100
|
+
"Content-Type": "application/json",
|
|
101
|
+
Authorization: `Bearer ${token}`,
|
|
102
|
+
};
|
|
103
|
+
if (sessionId) headers["mcp-session-id"] = sessionId;
|
|
104
|
+
const response = await fetch(`http://localhost:${mcpPort}/mcp-user`, {
|
|
105
|
+
method: "POST",
|
|
106
|
+
headers,
|
|
107
|
+
body: JSON.stringify(body),
|
|
108
|
+
});
|
|
109
|
+
const text = await response.text();
|
|
110
|
+
return {
|
|
111
|
+
status: response.status,
|
|
112
|
+
payload: (text ? parseMcpPayload(text) : {}) as RpcResponse,
|
|
113
|
+
sessionId: response.headers.get("mcp-session-id"),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** A client that never touches events: initialize (empty capabilities) + initialized. */
|
|
118
|
+
async function openSession(token: string): Promise<{ sessionId: string; init: RpcResponse }> {
|
|
119
|
+
const { payload, sessionId } = await mcpPost(token, {
|
|
120
|
+
jsonrpc: "2.0",
|
|
121
|
+
id: 1,
|
|
122
|
+
method: "initialize",
|
|
123
|
+
params: {
|
|
124
|
+
protocolVersion: "2025-03-26",
|
|
125
|
+
clientInfo: { name: "plain-client", version: "1" },
|
|
126
|
+
capabilities: {},
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
if (!sessionId) throw new Error("no session id");
|
|
130
|
+
await mcpPost(token, { jsonrpc: "2.0", method: "notifications/initialized" }, sessionId);
|
|
131
|
+
return { sessionId, init: payload };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function rpc(
|
|
135
|
+
token: string,
|
|
136
|
+
sessionId: string,
|
|
137
|
+
method: string,
|
|
138
|
+
params?: Record<string, unknown>,
|
|
139
|
+
): Promise<RpcResponse> {
|
|
140
|
+
const { payload } = await mcpPost(
|
|
141
|
+
token,
|
|
142
|
+
{ jsonrpc: "2.0", id: rpcId++, method, ...(params ? { params } : {}) },
|
|
143
|
+
sessionId,
|
|
144
|
+
);
|
|
145
|
+
return payload;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ─── Webhook receiver ────────────────────────────────────────────────────────
|
|
149
|
+
|
|
150
|
+
type ReceivedRequest = { headers: IncomingMessage["headers"]; body: string; path: string };
|
|
151
|
+
type ReceiverMode = "echo" | "wrong-challenge" | "fail-once" | "fail-always";
|
|
152
|
+
|
|
153
|
+
let receiver: Server;
|
|
154
|
+
let receiverPort: number;
|
|
155
|
+
let received: ReceivedRequest[] = [];
|
|
156
|
+
let receiverMode: ReceiverMode = "echo";
|
|
157
|
+
let failuresLeft = 0;
|
|
158
|
+
|
|
159
|
+
function createReceiver(): Server {
|
|
160
|
+
return createHttpServer((req, res) => {
|
|
161
|
+
let body = "";
|
|
162
|
+
req.on("data", (chunk) => {
|
|
163
|
+
body += chunk;
|
|
164
|
+
});
|
|
165
|
+
req.on("end", () => {
|
|
166
|
+
received.push({ headers: req.headers, body, path: req.url ?? "" });
|
|
167
|
+
const parsed = JSON.parse(body) as { type?: string; challenge?: string };
|
|
168
|
+
if (parsed.type === "verification") {
|
|
169
|
+
const challenge = receiverMode === "wrong-challenge" ? "nope" : parsed.challenge;
|
|
170
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
171
|
+
res.end(JSON.stringify({ challenge }));
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (receiverMode === "fail-always" || (receiverMode === "fail-once" && failuresLeft-- > 0)) {
|
|
175
|
+
res.writeHead(503);
|
|
176
|
+
res.end();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
res.writeHead(204);
|
|
180
|
+
res.end();
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function hookUrl(path = "/hooks/a"): string {
|
|
186
|
+
return `http://127.0.0.1:${receiverPort}${path}`;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function newSecret(): string {
|
|
190
|
+
return `whsec_${randomBytes(32).toString("base64")}`;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function verifySignature(request: ReceivedRequest, secret: string): boolean {
|
|
194
|
+
const key = parseWebhookSecret(secret);
|
|
195
|
+
if (!key) return false;
|
|
196
|
+
const id = String(request.headers["webhook-id"]);
|
|
197
|
+
const ts = String(request.headers["webhook-timestamp"]);
|
|
198
|
+
const expected = createHmac("sha256", key).update(`${id}.${ts}.${request.body}`).digest("base64");
|
|
199
|
+
return String(request.headers["webhook-signature"])
|
|
200
|
+
.split(" ")
|
|
201
|
+
.some((sig) => sig === `v1,${expected}`);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function eventDeliveries(): ReceivedRequest[] {
|
|
205
|
+
return received.filter((r) => !(JSON.parse(r.body) as { type?: string }).type);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
async function waitFor(predicate: () => boolean, timeoutMs = 3000): Promise<void> {
|
|
209
|
+
const deadline = Date.now() + timeoutMs;
|
|
210
|
+
while (!predicate()) {
|
|
211
|
+
if (Date.now() > deadline) throw new Error("timed out waiting for condition");
|
|
212
|
+
await Bun.sleep(10);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// ─── Lifecycle ───────────────────────────────────────────────────────────────
|
|
217
|
+
|
|
218
|
+
const originalEnabled = process.env.MCP_USER_EVENTS_ENABLED;
|
|
219
|
+
|
|
220
|
+
beforeAll(async () => {
|
|
221
|
+
await removeDbFiles(TEST_DB_PATH);
|
|
222
|
+
initDb(TEST_DB_PATH);
|
|
223
|
+
mcpServer = createMcpServer();
|
|
224
|
+
mcpPort = await listenOnFreePort(mcpServer, "127.0.0.1");
|
|
225
|
+
receiver = createReceiver();
|
|
226
|
+
receiverPort = await listenOnFreePort(receiver, "127.0.0.1");
|
|
227
|
+
initMcpEventsDispatcher();
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
afterAll(async () => {
|
|
231
|
+
stopMcpEventsDispatcher();
|
|
232
|
+
__setWebhookTestOverrides(null);
|
|
233
|
+
__setRetryDelaysForTests(null);
|
|
234
|
+
if (originalEnabled === undefined) delete process.env.MCP_USER_EVENTS_ENABLED;
|
|
235
|
+
else process.env.MCP_USER_EVENTS_ENABLED = originalEnabled;
|
|
236
|
+
await new Promise<void>((resolve) => mcpServer.close(() => resolve()));
|
|
237
|
+
await new Promise<void>((resolve) => receiver.close(() => resolve()));
|
|
238
|
+
closeDb();
|
|
239
|
+
await removeDbFiles(TEST_DB_PATH);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
beforeEach(async () => {
|
|
243
|
+
delete process.env.MCP_USER_EVENTS_ENABLED;
|
|
244
|
+
__setWebhookTestOverrides(LOCAL_RECEIVER_OVERRIDES);
|
|
245
|
+
__setRetryDelaysForTests([20, 20, 20, 20]);
|
|
246
|
+
received = [];
|
|
247
|
+
receiverMode = "echo";
|
|
248
|
+
failuresLeft = 0;
|
|
249
|
+
const client = getDbClient();
|
|
250
|
+
await client.run("DELETE FROM mcp_event_subscriptions");
|
|
251
|
+
await client.run("DELETE FROM user_identity_events");
|
|
252
|
+
await client.run("DELETE FROM user_tokens");
|
|
253
|
+
await client.run("DELETE FROM agent_tasks");
|
|
254
|
+
await client.run("DELETE FROM users");
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
afterEach(() => {
|
|
258
|
+
stopMcpEventsDispatcher();
|
|
259
|
+
initMcpEventsDispatcher();
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
async function newUser(name: string): Promise<{ id: string; token: string; tokenId: string }> {
|
|
263
|
+
const user = await createUser({ name });
|
|
264
|
+
const minted = await mintToken(user.id, name, ACTOR);
|
|
265
|
+
return { id: user.id, token: minted.plaintext, tokenId: minted.tokenId };
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
async function subscribe(
|
|
269
|
+
token: string,
|
|
270
|
+
sessionId: string,
|
|
271
|
+
overrides: Record<string, unknown> = {},
|
|
272
|
+
): Promise<RpcResponse> {
|
|
273
|
+
return rpc(token, sessionId, "events/subscribe", {
|
|
274
|
+
name: "task.completed",
|
|
275
|
+
arguments: {},
|
|
276
|
+
delivery: { mode: "webhook", url: hookUrl(), secret: newSecret() },
|
|
277
|
+
cursor: null,
|
|
278
|
+
...overrides,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
async function finishTask(userId: string, outcome: "completed" | "failed", parentTaskId?: string) {
|
|
283
|
+
const task = await createTaskExtended("summarize the release notes", {
|
|
284
|
+
requestedByUserId: userId,
|
|
285
|
+
...(parentTaskId ? { parentTaskId } : {}),
|
|
286
|
+
});
|
|
287
|
+
await startTask(task.id);
|
|
288
|
+
if (outcome === "completed") await completeTask(task.id, "Here is the summary.");
|
|
289
|
+
else await failTask(task.id, "The repo was unreachable.");
|
|
290
|
+
return task;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// ─── Tests ───────────────────────────────────────────────────────────────────
|
|
294
|
+
|
|
295
|
+
describe("backward compatibility for clients that never call events/*", () => {
|
|
296
|
+
test("initialize and tools/list match the kill-switch-off baseline except the capability keys", async () => {
|
|
297
|
+
const user = await newUser("Plain");
|
|
298
|
+
|
|
299
|
+
process.env.MCP_USER_EVENTS_ENABLED = "false";
|
|
300
|
+
const before = await openSession(user.token);
|
|
301
|
+
const toolsBefore = await rpc(user.token, before.sessionId, "tools/list");
|
|
302
|
+
|
|
303
|
+
delete process.env.MCP_USER_EVENTS_ENABLED;
|
|
304
|
+
const after = await openSession(user.token);
|
|
305
|
+
const toolsAfter = await rpc(user.token, after.sessionId, "tools/list");
|
|
306
|
+
|
|
307
|
+
expect(toolsAfter).toEqual({ ...toolsBefore, id: toolsAfter.id } as RpcResponse);
|
|
308
|
+
expect(toolsAfter.result).toEqual(toolsBefore.result as Record<string, unknown>);
|
|
309
|
+
|
|
310
|
+
const capsBefore = (before.init.result as { capabilities: Record<string, unknown> })
|
|
311
|
+
.capabilities;
|
|
312
|
+
const capsAfter = (after.init.result as { capabilities: Record<string, unknown> }).capabilities;
|
|
313
|
+
const { events, extensions, ...restAfter } = capsAfter;
|
|
314
|
+
expect(restAfter).toEqual(capsBefore);
|
|
315
|
+
expect(events).toEqual({});
|
|
316
|
+
expect(extensions).toEqual({ "io.modelcontextprotocol/events": {} });
|
|
317
|
+
expect(Object.keys(capsBefore).sort()).toEqual(["logging", "tools"]);
|
|
318
|
+
|
|
319
|
+
const { capabilities: _a, ...initRestBefore } = before.init.result as Record<string, unknown>;
|
|
320
|
+
const { capabilities: _b, ...initRestAfter } = after.init.result as Record<string, unknown>;
|
|
321
|
+
expect(initRestAfter).toEqual(initRestBefore);
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
test("a task finishing for a user with no subscription sends nothing", async () => {
|
|
325
|
+
const user = await newUser("Quiet");
|
|
326
|
+
await openSession(user.token);
|
|
327
|
+
await finishTask(user.id, "completed");
|
|
328
|
+
await Bun.sleep(100);
|
|
329
|
+
expect(received).toHaveLength(0);
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
describe("kill switch", () => {
|
|
334
|
+
test("MCP_USER_EVENTS_ENABLED=false answers events/* with method not found", async () => {
|
|
335
|
+
process.env.MCP_USER_EVENTS_ENABLED = "false";
|
|
336
|
+
const user = await newUser("Off");
|
|
337
|
+
const { sessionId, init } = await openSession(user.token);
|
|
338
|
+
expect((init.result as { capabilities: Record<string, unknown> }).capabilities.events).toBe(
|
|
339
|
+
undefined,
|
|
340
|
+
);
|
|
341
|
+
for (const method of ["events/list", "events/subscribe", "events/unsubscribe"]) {
|
|
342
|
+
const response = await rpc(user.token, sessionId, method, {});
|
|
343
|
+
expect(response.error?.code).toBe(-32601);
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
test("turning it off stops delivery to existing subscriptions", async () => {
|
|
348
|
+
const user = await newUser("Off later");
|
|
349
|
+
const { sessionId } = await openSession(user.token);
|
|
350
|
+
expect((await subscribe(user.token, sessionId)).result?.id).toBeDefined();
|
|
351
|
+
process.env.MCP_USER_EVENTS_ENABLED = "false";
|
|
352
|
+
await finishTask(user.id, "completed");
|
|
353
|
+
await Bun.sleep(100);
|
|
354
|
+
expect(eventDeliveries()).toHaveLength(0);
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
describe("events/list", () => {
|
|
359
|
+
test("lists task.completed and task.failed with webhook delivery", async () => {
|
|
360
|
+
const user = await newUser("Lister");
|
|
361
|
+
const { sessionId } = await openSession(user.token);
|
|
362
|
+
const response = await rpc(user.token, sessionId, "events/list");
|
|
363
|
+
const events = (response.result as { events: Array<{ name: string; delivery: string[] }> })
|
|
364
|
+
.events;
|
|
365
|
+
expect(events.map((e) => e.name)).toEqual(["task.completed", "task.failed"]);
|
|
366
|
+
for (const e of events) expect(e.delivery).toEqual(["webhook"]);
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
describe("events/subscribe", () => {
|
|
371
|
+
test("verifies the endpoint with a signed challenge, then grants a lease", async () => {
|
|
372
|
+
const user = await newUser("Subscriber");
|
|
373
|
+
const { sessionId } = await openSession(user.token);
|
|
374
|
+
const secret = newSecret();
|
|
375
|
+
const response = await subscribe(user.token, sessionId, {
|
|
376
|
+
delivery: { mode: "webhook", url: hookUrl(), secret },
|
|
377
|
+
});
|
|
378
|
+
const result = response.result as { id: string; refreshBefore: string; cursor: null };
|
|
379
|
+
expect(result.id).toMatch(/^sub_[0-9a-f]{32}$/);
|
|
380
|
+
expect(result.cursor).toBeNull();
|
|
381
|
+
const ttl = new Date(result.refreshBefore).getTime() - Date.now();
|
|
382
|
+
expect(ttl).toBeGreaterThan(59 * 60 * 1000);
|
|
383
|
+
expect(ttl).toBeLessThanOrEqual(60 * 60 * 1000);
|
|
384
|
+
|
|
385
|
+
expect(received).toHaveLength(1);
|
|
386
|
+
const challenge = received[0] as ReceivedRequest;
|
|
387
|
+
expect(JSON.parse(challenge.body).type).toBe("verification");
|
|
388
|
+
expect(String(challenge.headers["webhook-id"])).toMatch(/^msg_verification_/);
|
|
389
|
+
expect(challenge.headers["x-mcp-subscription-id"]).toBe(result.id);
|
|
390
|
+
expect(verifySignature(challenge, secret)).toBe(true);
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
test("a refresh keeps the id, skips the challenge and reports delivery status", async () => {
|
|
394
|
+
const user = await newUser("Refresher");
|
|
395
|
+
const { sessionId } = await openSession(user.token);
|
|
396
|
+
const secret = newSecret();
|
|
397
|
+
const params = { delivery: { mode: "webhook", url: hookUrl(), secret }, ttlMs: 120_000 };
|
|
398
|
+
const first = (await subscribe(user.token, sessionId, params)).result as { id: string };
|
|
399
|
+
const second = (
|
|
400
|
+
await subscribe(user.token, sessionId, {
|
|
401
|
+
...params,
|
|
402
|
+
// Same key with reordered argument keys and a clamped-up TTL.
|
|
403
|
+
arguments: {},
|
|
404
|
+
ttlMs: 1,
|
|
405
|
+
})
|
|
406
|
+
).result as { id: string; refreshBefore: string; deliveryStatus: { active: boolean } };
|
|
407
|
+
expect(second.id).toBe(first.id);
|
|
408
|
+
expect(second.deliveryStatus.active).toBe(true);
|
|
409
|
+
expect(new Date(second.refreshBefore).getTime() - Date.now()).toBeGreaterThan(55_000);
|
|
410
|
+
expect(received.filter((r) => JSON.parse(r.body).type === "verification")).toHaveLength(1);
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
test("skipping the challenge never extends the verification window", async () => {
|
|
414
|
+
const user = await newUser("Window");
|
|
415
|
+
const root = await createTaskExtended("root", { requestedByUserId: user.id });
|
|
416
|
+
const { sessionId } = await openSession(user.token);
|
|
417
|
+
await subscribe(user.token, sessionId);
|
|
418
|
+
const old = new Date(Date.now() - 23 * 60 * 60 * 1000).toISOString();
|
|
419
|
+
await getDbClient().run("UPDATE mcp_event_subscriptions SET verifiedAt = ?", [old]);
|
|
420
|
+
// Same (user, url), new key: covered by the earlier check, so no new challenge.
|
|
421
|
+
const second = (await subscribe(user.token, sessionId, { arguments: { taskId: root.id } }))
|
|
422
|
+
.result as { id: string };
|
|
423
|
+
expect(received.filter((r) => JSON.parse(r.body).type === "verification")).toHaveLength(1);
|
|
424
|
+
const row = await getDbClient().get<{ verifiedAt: string }>(
|
|
425
|
+
"SELECT verifiedAt FROM mcp_event_subscriptions WHERE id = ?",
|
|
426
|
+
[second.id],
|
|
427
|
+
);
|
|
428
|
+
expect(row?.verifiedAt).toBe(old);
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
test("a failed challenge returns CallbackEndpointError and stores nothing", async () => {
|
|
432
|
+
receiverMode = "wrong-challenge";
|
|
433
|
+
const user = await newUser("Bad echo");
|
|
434
|
+
const { sessionId } = await openSession(user.token);
|
|
435
|
+
const response = await subscribe(user.token, sessionId);
|
|
436
|
+
expect(response.error?.code).toBe(-32027);
|
|
437
|
+
expect(response.error?.data).toEqual({ reason: "challenge_failed" });
|
|
438
|
+
const row = await getDbClient().get<{ n: number }>(
|
|
439
|
+
"SELECT COUNT(*) AS n FROM mcp_event_subscriptions",
|
|
440
|
+
);
|
|
441
|
+
expect(row?.n).toBe(0);
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
test("rejects bad params with the draft's error codes", async () => {
|
|
445
|
+
const user = await newUser("Validator");
|
|
446
|
+
const { sessionId } = await openSession(user.token);
|
|
447
|
+
const badSecret = await subscribe(user.token, sessionId, {
|
|
448
|
+
delivery: { mode: "webhook", url: hookUrl(), secret: "whsec_c2hvcnQ=" },
|
|
449
|
+
});
|
|
450
|
+
expect(badSecret.error?.code).toBe(-32602);
|
|
451
|
+
const unknownEvent = await subscribe(user.token, sessionId, { name: "task.exploded" });
|
|
452
|
+
expect(unknownEvent.error).toMatchObject({ code: -32023, data: { kind: "event" } });
|
|
453
|
+
const push = await subscribe(user.token, sessionId, {
|
|
454
|
+
delivery: { mode: "push", url: hookUrl(), secret: newSecret() },
|
|
455
|
+
});
|
|
456
|
+
expect(push.error?.code).toBe(-32026);
|
|
457
|
+
const badArgs = await subscribe(user.token, sessionId, { arguments: { severity: "P1" } });
|
|
458
|
+
expect(badArgs.error?.code).toBe(-32602);
|
|
459
|
+
expect(received).toHaveLength(0);
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
test("a taskId filter must name one of the caller's own tasks", async () => {
|
|
463
|
+
const owner = await newUser("Owner");
|
|
464
|
+
const other = await newUser("Other");
|
|
465
|
+
const task = await createTaskExtended("owner's task", { requestedByUserId: owner.id });
|
|
466
|
+
const { sessionId } = await openSession(other.token);
|
|
467
|
+
const response = await subscribe(other.token, sessionId, { arguments: { taskId: task.id } });
|
|
468
|
+
expect(response.error?.code).toBe(-32024);
|
|
469
|
+
expect(received).toHaveLength(0);
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
test("caps live subscriptions per user", async () => {
|
|
473
|
+
const user = await newUser("Hoarder");
|
|
474
|
+
const { sessionId } = await openSession(user.token);
|
|
475
|
+
for (let i = 0; i < MAX_SUBSCRIPTIONS_PER_USER; i++) {
|
|
476
|
+
const ok = await subscribe(user.token, sessionId, {
|
|
477
|
+
delivery: { mode: "webhook", url: hookUrl(`/hooks/${i}`), secret: newSecret() },
|
|
478
|
+
});
|
|
479
|
+
expect(ok.result?.id).toBeDefined();
|
|
480
|
+
}
|
|
481
|
+
const challengesBefore = received.length;
|
|
482
|
+
const over = await subscribe(user.token, sessionId, {
|
|
483
|
+
delivery: { mode: "webhook", url: hookUrl("/hooks/over"), secret: newSecret() },
|
|
484
|
+
});
|
|
485
|
+
expect(over.error).toMatchObject({
|
|
486
|
+
code: -32025,
|
|
487
|
+
data: { limit: "subscriptions", max: MAX_SUBSCRIPTIONS_PER_USER },
|
|
488
|
+
});
|
|
489
|
+
// Refused before any verification POST to the new URL.
|
|
490
|
+
expect(received.length).toBe(challengesBefore);
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
test("subscribe/unsubscribe churn cannot exceed the hourly verification budget", async () => {
|
|
494
|
+
const user = await newUser("Churner");
|
|
495
|
+
const { sessionId } = await openSession(user.token);
|
|
496
|
+
for (let i = 0; i < VERIFICATIONS_PER_USER_PER_HOUR; i++) {
|
|
497
|
+
const url = hookUrl(`/churn/${i}`);
|
|
498
|
+
const ok = await subscribe(user.token, sessionId, {
|
|
499
|
+
delivery: { mode: "webhook", url, secret: newSecret() },
|
|
500
|
+
});
|
|
501
|
+
expect(ok.result?.id).toBeDefined();
|
|
502
|
+
await rpc(user.token, sessionId, "events/unsubscribe", {
|
|
503
|
+
name: "task.completed",
|
|
504
|
+
arguments: {},
|
|
505
|
+
delivery: { url },
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
const sent = received.length;
|
|
509
|
+
const over = await subscribe(user.token, sessionId, {
|
|
510
|
+
delivery: { mode: "webhook", url: hookUrl("/churn/over"), secret: newSecret() },
|
|
511
|
+
});
|
|
512
|
+
expect(over.error).toMatchObject({ code: -32025, data: { limit: "verifications" } });
|
|
513
|
+
expect(received.length).toBe(sent);
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
test("seals the signing secret at rest", async () => {
|
|
517
|
+
const user = await newUser("Sealed");
|
|
518
|
+
const { sessionId } = await openSession(user.token);
|
|
519
|
+
const secret = newSecret();
|
|
520
|
+
await subscribe(user.token, sessionId, {
|
|
521
|
+
delivery: { mode: "webhook", url: hookUrl(), secret },
|
|
522
|
+
});
|
|
523
|
+
const row = await getDbClient().get<{ secretSealed: string }>(
|
|
524
|
+
"SELECT secretSealed FROM mcp_event_subscriptions",
|
|
525
|
+
);
|
|
526
|
+
expect(row?.secretSealed).toBeDefined();
|
|
527
|
+
expect(row?.secretSealed).not.toContain(secret.slice("whsec_".length, 20));
|
|
528
|
+
expect(row?.secretSealed).not.toContain("whsec_");
|
|
529
|
+
});
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
describe("egress guard", () => {
|
|
533
|
+
test("without the local-receiver override, http and private literals are refused", () => {
|
|
534
|
+
__setWebhookTestOverrides(null);
|
|
535
|
+
expect(callbackUrlProblem("http://hooks.example.com/x")).not.toBeNull();
|
|
536
|
+
expect(callbackUrlProblem("https://127.0.0.1/x")).not.toBeNull();
|
|
537
|
+
expect(callbackUrlProblem("https://10.0.0.8/x")).not.toBeNull();
|
|
538
|
+
expect(callbackUrlProblem("https://user:pw@hooks.example.com/x")).not.toBeNull();
|
|
539
|
+
expect(callbackUrlProblem("https://hooks.example.com/x")).toBeNull();
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
test("a public name that resolves to a private address is refused at send time", async () => {
|
|
543
|
+
let fetched = 0;
|
|
544
|
+
__setWebhookTestOverrides({
|
|
545
|
+
allowInsecure: true,
|
|
546
|
+
guard: {
|
|
547
|
+
policy: { allowPrivate: false, allowlist: null },
|
|
548
|
+
resolve: async () => ["10.1.2.3"],
|
|
549
|
+
},
|
|
550
|
+
baseFetch: (async () => {
|
|
551
|
+
fetched++;
|
|
552
|
+
return new Response(null, { status: 204 });
|
|
553
|
+
}) as unknown as typeof fetch,
|
|
554
|
+
});
|
|
555
|
+
const user = await newUser("Rebind");
|
|
556
|
+
const { sessionId } = await openSession(user.token);
|
|
557
|
+
const response = await subscribe(user.token, sessionId, {
|
|
558
|
+
delivery: { mode: "webhook", url: "http://hooks.example.test/cb", secret: newSecret() },
|
|
559
|
+
});
|
|
560
|
+
expect(response.error).toMatchObject({ code: -32027, data: { reason: "connection_refused" } });
|
|
561
|
+
expect(fetched).toBe(0);
|
|
562
|
+
});
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
describe("delivery", () => {
|
|
566
|
+
test("task.completed reaches the subscriber, signed, and only for the user's own tasks", async () => {
|
|
567
|
+
const user = await newUser("Receiver");
|
|
568
|
+
const other = await newUser("Stranger");
|
|
569
|
+
const { sessionId } = await openSession(user.token);
|
|
570
|
+
const secret = newSecret();
|
|
571
|
+
const sub = (
|
|
572
|
+
await subscribe(user.token, sessionId, {
|
|
573
|
+
delivery: { mode: "webhook", url: hookUrl(), secret },
|
|
574
|
+
})
|
|
575
|
+
).result as { id: string };
|
|
576
|
+
|
|
577
|
+
await finishTask(other.id, "completed");
|
|
578
|
+
await finishTask(user.id, "failed");
|
|
579
|
+
const mine = await finishTask(user.id, "completed");
|
|
580
|
+
await waitFor(() => eventDeliveries().length >= 1);
|
|
581
|
+
await Bun.sleep(50);
|
|
582
|
+
|
|
583
|
+
const deliveries = eventDeliveries();
|
|
584
|
+
expect(deliveries).toHaveLength(1);
|
|
585
|
+
const delivery = deliveries[0] as ReceivedRequest;
|
|
586
|
+
const body = JSON.parse(delivery.body);
|
|
587
|
+
expect(body).toMatchObject({
|
|
588
|
+
name: "task.completed",
|
|
589
|
+
cursor: null,
|
|
590
|
+
data: { taskId: mine.id, status: "completed", output: "Here is the summary." },
|
|
591
|
+
});
|
|
592
|
+
expect(body.eventId).toMatch(/^evt_[0-9a-f]{32}$/);
|
|
593
|
+
expect(delivery.headers["webhook-id"]).toBe(body.eventId);
|
|
594
|
+
expect(delivery.headers["x-mcp-subscription-id"]).toBe(sub.id);
|
|
595
|
+
expect(delivery.headers["content-type"]).toBe("application/json");
|
|
596
|
+
expect(verifySignature(delivery, secret)).toBe(true);
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
test("task.failed carries the failure reason", async () => {
|
|
600
|
+
const user = await newUser("Failer");
|
|
601
|
+
const { sessionId } = await openSession(user.token);
|
|
602
|
+
await subscribe(user.token, sessionId, { name: "task.failed" });
|
|
603
|
+
const task = await finishTask(user.id, "failed");
|
|
604
|
+
await waitFor(() => eventDeliveries().length >= 1);
|
|
605
|
+
expect(JSON.parse((eventDeliveries()[0] as ReceivedRequest).body)).toMatchObject({
|
|
606
|
+
name: "task.failed",
|
|
607
|
+
data: { taskId: task.id, status: "failed", failureReason: "The repo was unreachable." },
|
|
608
|
+
});
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
test("a taskId filter matches the task and its descendants only", async () => {
|
|
612
|
+
const user = await newUser("Filter");
|
|
613
|
+
const root = await createTaskExtended("root", { requestedByUserId: user.id });
|
|
614
|
+
const { sessionId } = await openSession(user.token);
|
|
615
|
+
await subscribe(user.token, sessionId, { arguments: { taskId: root.id } });
|
|
616
|
+
|
|
617
|
+
await finishTask(user.id, "completed");
|
|
618
|
+
const child = await finishTask(user.id, "completed", root.id);
|
|
619
|
+
await waitFor(() => eventDeliveries().length >= 1);
|
|
620
|
+
await Bun.sleep(50);
|
|
621
|
+
const deliveries = eventDeliveries();
|
|
622
|
+
expect(deliveries).toHaveLength(1);
|
|
623
|
+
expect(JSON.parse((deliveries[0] as ReceivedRequest).body).data.taskId).toBe(child.id);
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
test("retries a failed delivery with the same webhook-id and a fresh signature", async () => {
|
|
627
|
+
const user = await newUser("Retry");
|
|
628
|
+
const { sessionId } = await openSession(user.token);
|
|
629
|
+
const secret = newSecret();
|
|
630
|
+
await subscribe(user.token, sessionId, {
|
|
631
|
+
delivery: { mode: "webhook", url: hookUrl(), secret },
|
|
632
|
+
});
|
|
633
|
+
receiverMode = "fail-once";
|
|
634
|
+
failuresLeft = 1;
|
|
635
|
+
await finishTask(user.id, "completed");
|
|
636
|
+
await waitFor(() => eventDeliveries().length >= 2);
|
|
637
|
+
const [first, second] = eventDeliveries() as [ReceivedRequest, ReceivedRequest];
|
|
638
|
+
expect(second.headers["webhook-id"]).toBe(first.headers["webhook-id"]);
|
|
639
|
+
expect(verifySignature(second, secret)).toBe(true);
|
|
640
|
+
// The receiver logs the request before the server records the outcome.
|
|
641
|
+
let row: { lastError: string | null; lastDeliveryAt: string | null } | null = null;
|
|
642
|
+
for (let i = 0; i < 100 && !row?.lastDeliveryAt; i++) {
|
|
643
|
+
await Bun.sleep(10);
|
|
644
|
+
row = await getDbClient().get(
|
|
645
|
+
"SELECT lastError, lastDeliveryAt FROM mcp_event_subscriptions",
|
|
646
|
+
);
|
|
647
|
+
}
|
|
648
|
+
expect(row?.lastError).toBeNull();
|
|
649
|
+
expect(row?.lastDeliveryAt).toBeTruthy();
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
test("stops after the bounded attempt count", async () => {
|
|
653
|
+
const user = await newUser("Dead endpoint");
|
|
654
|
+
const { sessionId } = await openSession(user.token);
|
|
655
|
+
await subscribe(user.token, sessionId);
|
|
656
|
+
receiverMode = "fail-always";
|
|
657
|
+
await finishTask(user.id, "completed");
|
|
658
|
+
await waitFor(() => eventDeliveries().length >= 5);
|
|
659
|
+
await Bun.sleep(150);
|
|
660
|
+
expect(eventDeliveries()).toHaveLength(5);
|
|
661
|
+
const row = await getDbClient().get<{ lastError: string; failedSince: string }>(
|
|
662
|
+
"SELECT lastError, failedSince FROM mcp_event_subscriptions",
|
|
663
|
+
);
|
|
664
|
+
expect(row?.lastError).toBe("http_5xx");
|
|
665
|
+
expect(row?.failedSince).toBeTruthy();
|
|
666
|
+
});
|
|
667
|
+
|
|
668
|
+
test("revoking the subscribing token stops delivery", async () => {
|
|
669
|
+
const user = await newUser("Revoked");
|
|
670
|
+
const { sessionId } = await openSession(user.token);
|
|
671
|
+
expect((await subscribe(user.token, sessionId)).result?.id).toBeDefined();
|
|
672
|
+
await revokeToken(user.tokenId, ACTOR);
|
|
673
|
+
await finishTask(user.id, "completed");
|
|
674
|
+
await Bun.sleep(150);
|
|
675
|
+
expect(eventDeliveries()).toHaveLength(0);
|
|
676
|
+
});
|
|
677
|
+
|
|
678
|
+
test("events/unsubscribe stops delivery and is idempotent", async () => {
|
|
679
|
+
const user = await newUser("Leaver");
|
|
680
|
+
const { sessionId } = await openSession(user.token);
|
|
681
|
+
await subscribe(user.token, sessionId, { arguments: {} });
|
|
682
|
+
const params = { name: "task.completed", arguments: {}, delivery: { url: hookUrl() } };
|
|
683
|
+
expect((await rpc(user.token, sessionId, "events/unsubscribe", params)).result).toEqual({
|
|
684
|
+
resultType: "complete",
|
|
685
|
+
});
|
|
686
|
+
expect((await rpc(user.token, sessionId, "events/unsubscribe", params)).result).toEqual({
|
|
687
|
+
resultType: "complete",
|
|
688
|
+
});
|
|
689
|
+
await finishTask(user.id, "completed");
|
|
690
|
+
await Bun.sleep(100);
|
|
691
|
+
expect(eventDeliveries()).toHaveLength(0);
|
|
692
|
+
});
|
|
693
|
+
|
|
694
|
+
test("another user cannot unsubscribe someone else's subscription", async () => {
|
|
695
|
+
const owner = await newUser("Keeper");
|
|
696
|
+
const intruder = await newUser("Intruder");
|
|
697
|
+
const ownerSession = await openSession(owner.token);
|
|
698
|
+
await subscribe(owner.token, ownerSession.sessionId);
|
|
699
|
+
const intruderSession = await openSession(intruder.token);
|
|
700
|
+
await rpc(intruder.token, intruderSession.sessionId, "events/unsubscribe", {
|
|
701
|
+
name: "task.completed",
|
|
702
|
+
arguments: {},
|
|
703
|
+
delivery: { url: hookUrl() },
|
|
704
|
+
});
|
|
705
|
+
await finishTask(owner.id, "completed");
|
|
706
|
+
await waitFor(() => eventDeliveries().length >= 1);
|
|
707
|
+
});
|
|
708
|
+
});
|