@desplega.ai/agent-swarm 2.13.0 → 2.13.2
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/README.md +1 -1
- package/dist/acp-adapter-x1qqgzwx.js +17 -0
- package/dist/{acp-targets-86f0sh6g.js → acp-targets-mz8c5dnt.js} +10 -10
- package/dist/{actions-zv8vcxvr.js → actions-5ft3qp5a.js} +27 -27
- package/dist/{agent-fs-provision-jqshb33y.js → agent-fs-provision-6fgz7wvz.js} +4 -4
- package/dist/{amp-adapter-gt503ywc.js → amp-adapter-nthn8ezm.js} +3 -3
- package/dist/{app-6t4k5rh1.js → app-535m78qw.js} +10 -10
- package/dist/{approval-notifications-fcfw063h.js → approval-notifications-dewbk403.js} +11 -11
- package/dist/{assistant-9dzybh12.js → assistant-39zyabv2.js} +28 -28
- package/dist/{boot-args-schema-xzfp2feg.js → boot-args-schema-bqv5bf77.js} +1 -1
- package/dist/{boot-reembed-3jz0p2jk.js → boot-reembed-157c0gcz.js} +1 -1
- package/dist/{boot-reembed-r88wngfg.js → boot-reembed-fas7z3zn.js} +1 -1
- package/dist/{boot-scrub-sweep-scrqhw48.js → boot-scrub-sweep-tmec0be2.js} +2 -2
- package/dist/{boot-seeds-vb2dcrrb.js → boot-seeds-32zm50x2.js} +4 -4
- package/dist/{boxd-68n75y1s.js → boxd-hr8rsxzq.js} +1 -1
- package/dist/{claude-adapter-h3mp9hgs.js → claude-adapter-gwq7x2nj.js} +9 -9
- package/dist/{claude-managed-adapter-kpbyj2vb.js → claude-managed-adapter-rkvw6fvq.js} +4 -4
- package/dist/{claude-managed-setup-0efr3wkg.js → claude-managed-setup-0vgz4d1j.js} +6 -6
- package/dist/{claude-sdk-session-03dw669q.js → claude-sdk-session-5wbwxy8c.js} +20967 -19390
- package/dist/{cli-z64t9pe6.js → cli-0f7n3td3.js} +1 -1
- package/dist/{cli-j53hpbsm.js → cli-0xwb7zpt.js} +2 -2
- package/dist/{cli-wxwv3t11.js → cli-1f48qdnb.js} +55 -13
- package/dist/{cli-gfcv679k.js → cli-1gevjrc1.js} +1 -1
- package/dist/{cli-0jkenasr.js → cli-2v4xxnx2.js} +1 -1
- package/dist/{cli-hc6e4tac.js → cli-2wde56gv.js} +6 -6
- package/dist/{cli-mh7pdxe0.js → cli-31vt7baf.js} +17 -17
- package/dist/{cli-ercwc8xn.js → cli-3mf04tkh.js} +1 -1
- package/dist/{cli-s6zk31gr.js → cli-43dsqhcp.js} +4 -4
- package/dist/{cli-1dbv9mj9.js → cli-4djg31jh.js} +1 -1
- package/dist/{cli-tn91wc6e.js → cli-50whymxq.js} +1 -1
- package/dist/{cli-js10kdk7.js → cli-5basv0e7.js} +19 -5
- package/dist/{cli-b2jh3dyb.js → cli-5k1hvycs.js} +4 -4
- package/dist/{cli-dkejt425.js → cli-62fjschk.js} +7 -7
- package/dist/{cli-zqmmy073.js → cli-69eq6gdk.js} +18 -18
- package/dist/{cli-qm3ntjqs.js → cli-6rmryz03.js} +13 -13
- package/dist/{cli-mz34pxbk.js → cli-7m6bbtab.js} +11 -11
- package/dist/{cli-wv20kbr3.js → cli-8a4qg44m.js} +5 -5
- package/dist/{cli-2m6yaq6b.js → cli-8fj8yfmk.js} +1 -1
- package/dist/{cli-9m9kyw77.js → cli-8qvte9hn.js} +2 -2
- package/dist/{cli-x05p2d05.js → cli-9tevdxyf.js} +1 -1
- package/dist/{cli-qec9bynj.js → cli-a6rzw649.js} +3 -3
- package/dist/{cli-ex1y88j3.js → cli-at67kvnp.js} +1 -1
- package/dist/{cli-yn4kt85g.js → cli-b0kqw55g.js} +1 -1
- package/dist/{cli-n3qe7tyr.js → cli-b0m3bg0f.js} +134 -3
- package/dist/{cli-xfjn2kyq.js → cli-bp2rt28p.js} +9 -9
- package/dist/{cli-2jk4s7z1.js → cli-c9bwawf9.js} +3 -3
- package/dist/{cli-wndegmns.js → cli-cmgdptmx.js} +3 -3
- package/dist/{cli-3p288654.js → cli-cpkxh68d.js} +2 -2
- package/dist/{cli-117g15t4.js → cli-cs26ed89.js} +8 -8
- package/dist/{cli-prf7kz78.js → cli-d0jb2qnt.js} +603 -78
- package/dist/{cli-8hp56wat.js → cli-d2epqm0y.js} +1 -1
- package/dist/{cli-wrhbym01.js → cli-d528acsw.js} +6 -6
- package/dist/{cli-tstj6e8e.js → cli-dnvmwsvc.js} +310 -88
- package/dist/{cli-9fsagra4.js → cli-e87fg3en.js} +1 -1
- package/dist/{cli-jj3c5nyb.js → cli-erh1rgh4.js} +116 -56
- package/dist/{cli-f1952kjy.js → cli-ewb028rs.js} +4 -4
- package/dist/{cli-ct8sz3np.js → cli-f1sdh8ca.js} +6 -6
- package/dist/{cli-0b655smz.js → cli-fcwrd7bh.js} +5 -5
- package/dist/{cli-eb279wn3.js → cli-fgm2mad9.js} +2 -2
- package/dist/{cli-bpje8n65.js → cli-fp65jdp2.js} +31 -6
- package/dist/{cli-dnh64e8e.js → cli-g0b3ma7r.js} +7 -7
- package/dist/{cli-avxh26pd.js → cli-gc7jkf4a.js} +4 -4
- package/dist/{cli-2skf1mdf.js → cli-gedf48yw.js} +4 -4
- package/dist/{cli-ajjvqhf3.js → cli-getrvmtx.js} +27 -6
- package/dist/{cli-c8v2yvej.js → cli-gq6qhmrr.js} +2 -2
- package/dist/{cli-mbwmqb5w.js → cli-h0ewec3d.js} +1 -1
- package/dist/{cli-tdk7jtka.js → cli-hv3820ez.js} +1 -1
- package/dist/{cli-avqkr20b.js → cli-j2ybkdk2.js} +2 -2
- package/dist/{cli-pqfecppn.js → cli-je587f74.js} +1 -1
- package/dist/{cli-hgsxnjyg.js → cli-jkkcm72j.js} +13 -13
- package/dist/{cli-g6j6ac3h.js → cli-ka13xx6b.js} +2 -2
- package/dist/{cli-t35hx078.js → cli-m1wddksc.js} +2 -2
- package/dist/{cli-50w82h6m.js → cli-mwxez0pz.js} +1 -0
- package/dist/{cli-nc6a8b5b.js → cli-n14r8h4n.js} +2 -2
- package/dist/{cli-y4a4458j.js → cli-n46d87mj.js} +3 -3
- package/dist/{cli-0dg7ytxm.js → cli-nkfv398a.js} +1096 -75
- package/dist/{cli-fhvk2nvp.js → cli-nvqq3232.js} +9 -9
- package/dist/{cli-bhgrhedp.js → cli-q8aq48v1.js} +1 -1
- package/dist/{cli-6a40p4kv.js → cli-qn79645p.js} +1 -1
- package/dist/{cli-hbq0kwxz.js → cli-r4fphq38.js} +4 -4
- package/dist/{cli-47hz21se.js → cli-r8ddn0hf.js} +4 -5
- package/dist/{cli-hpb9x72z.js → cli-rvhaahfv.js} +9 -9
- package/dist/{cli-qhhb30e8.js → cli-s08zsqva.js} +9 -9
- package/dist/{cli-sdh61g52.js → cli-s6fhqbz1.js} +2 -2
- package/dist/{cli-y518qkjg.js → cli-sjk85d7v.js} +13 -12
- package/dist/{cli-ytc7fpza.js → cli-t25rq8mg.js} +4 -4
- package/dist/{cli-sq913bh1.js → cli-t9nxq30h.js} +8 -8
- package/dist/{cli-49f5jyhh.js → cli-tbdw3f92.js} +3 -3
- package/dist/{cli-1v82d2w6.js → cli-tceqvv6h.js} +4 -4
- package/dist/{cli-fz9pcjsw.js → cli-tgmate57.js} +4 -4
- package/dist/{cli-rtmqzat7.js → cli-vdfngx2g.js} +2 -2
- package/dist/{cli-9w8712tq.js → cli-vr4eyq6p.js} +43 -14
- package/dist/{cli-z4f346g5.js → cli-vx9acp12.js} +1 -1
- package/dist/{cli-7dbhnsj9.js → cli-wdtqkqnq.js} +4 -4
- package/dist/{cli-kde4ky90.js → cli-x5yb8zc8.js} +2 -2
- package/dist/{cli-w14j2z4k.js → cli-x7aqhxj5.js} +2 -2
- package/dist/{cli-kspxjftk.js → cli-xerdrnqs.js} +15 -6
- package/dist/{cli-48nvk6sb.js → cli-xhkek467.js} +2 -2
- package/dist/{cli-dka73bak.js → cli-xysy1g8x.js} +152 -12
- package/dist/{cli-7wy8gbwb.js → cli-ya1cj689.js} +1 -1
- package/dist/{cli-n85m2wkq.js → cli-zkbz8m2q.js} +3 -2
- package/dist/{cli-0pazkmd4.js → cli-zm6bkx3e.js} +4 -4
- package/dist/{cli-6h88mn9q.js → cli-zqy28rwx.js} +4 -4
- package/dist/cli.js +30 -29
- package/dist/{codex-adapter-f3yp0kaj.js → codex-adapter-x25xfbnh.js} +8 -8
- package/dist/{codex-hook-262cekfp.js → codex-hook-c0nvm30r.js} +2 -2
- package/dist/{codex-login-1ven7yje.js → codex-login-ven5cz5j.js} +1 -1
- package/dist/{codex-session-runner-ns4mv70p.js → codex-session-runner-kn5xnrvp.js} +9 -9
- package/dist/{commands-5bzf2tfw.js → commands-8n59gxmy.js} +3 -3
- package/dist/{controller-5xt7kvfm.js → controller-wn3vd217.js} +3 -3
- package/dist/{controllers-connect-0gg13mzp.js → controllers-connect-09gvkrhc.js} +28 -28
- package/dist/core-2b8bv6ny.js +42 -0
- package/dist/{cursor-adapter-p0c5zv6r.js → cursor-adapter-w1681kp1.js} +2 -2
- package/dist/{db-2s68ycq7.js → db-e71keqxk.js} +3 -3
- package/dist/{db-q7q639k5.js → db-spg81qtr.js} +2 -2
- package/dist/{devin-adapter-t8d86q9x.js → devin-adapter-fs90ab4v.js} +1 -1
- package/dist/{dispatcher-j2y1q7ae.js → dispatcher-fr4vawwb.js} +25 -25
- package/dist/{docker-1b41eysj.js → docker-1h33jvh9.js} +2 -2
- package/dist/{dsh-adapter-pgnkf4st.js → dsh-adapter-g9yqv09y.js} +2 -2
- package/dist/{e2b-xm60c8ad.js → e2b-jnk0yeva.js} +2 -2
- package/dist/{e2b-ew8c5j5v.js → e2b-y7e5kmzf.js} +2 -2
- package/dist/{easter-egg-3d-0kea97jf.js → easter-egg-3d-ac9tv9a6.js} +1 -1
- package/dist/{embedding-space-3n6mhhmy.js → embedding-space-an77f45k.js} +6 -6
- package/dist/{embeddings-jfmj6yme.js → embeddings-jkrehejr.js} +1 -1
- package/dist/{event-bus-v4ywhc2p.js → event-bus-08t2b4y2.js} +1 -1
- package/dist/{execute-tjrej979.js → execute-3mys4nta.js} +1 -1
- package/dist/{external-channel-jy8w2gg3.js → external-channel-s6zxpts9.js} +2 -2
- package/dist/fx-adapter-4yet1c4f.js +20 -0
- package/dist/grok-adapter-8ge6tw7m.js +20 -0
- package/dist/handlers-0r9evrdj.js +41 -0
- package/dist/heartbeat-jjpb44e5.js +50 -0
- package/dist/{hook-fv1jwrv7.js → hook-68gbs87k.js} +6 -6
- package/dist/{hook-bpnncsec.js → hook-y6n23zzj.js} +8 -8
- package/dist/{http-bpa26czn.js → http-8c6y008s.js} +404 -146
- package/dist/{index-w216g9y9.js → index-0vthtbc2.js} +38 -22
- package/dist/index-1v23363p.js +39 -0
- package/dist/index-30qw6vyw.js +44 -0
- package/dist/index-6bm3w6cn.js +40 -0
- package/dist/{index-s8re7mvq.js → index-6h3r0vpe.js} +1 -1
- package/dist/{index-620y7jzq.js → index-7dgxveck.js} +3 -3
- package/dist/{index-4k7m5dgj.js → index-maddg9ys.js} +143 -103
- package/dist/{index-0h6qd4p1.js → index-mbpxhc4w.js} +3 -4
- package/dist/index-rz8ve510.js +569 -0
- package/dist/{index-mpj0z9e0.js → index-we3nd2t0.js} +1 -1
- package/dist/{index-pe3d8jfy.js → index-whysn1wf.js} +1 -1
- package/dist/{index-52tgbhrw.js → index-xcw7hjt5.js} +28 -28
- package/dist/{index-8p0j4h4j.js → index-ym9fgxad.js} +94 -89
- package/dist/{k8s-fy8hbhkg.js → k8s-8326q0rq.js} +2 -2
- package/dist/{keepalive-d6z12s04.js → keepalive-7e9r5dvp.js} +5 -4
- package/dist/lead-3jpc7kcr.js +79 -0
- package/dist/{maintenance-7kac6g2g.js → maintenance-d3erjvcg.js} +1 -1
- package/dist/{oauth-refresh-sweep-t1xjetbh.js → oauth-refresh-sweep-0qh70988.js} +4 -3
- package/dist/{object-webhooks-6rdagg0r.js → object-webhooks-ac7v2q5p.js} +7 -7
- package/dist/{onboard-32y1cfxy.js → onboard-5yphtken.js} +4 -4
- package/dist/{opencode-adapter-enp3v31n.js → opencode-adapter-0xvyba4m.js} +8 -8
- package/dist/{otel-impl-k0tm5ptj.js → otel-impl-svqp691q.js} +2 -2
- package/dist/{pending-24zebgvs.js → pending-bn4xe5br.js} +26 -26
- package/dist/{pi-mono-adapter-yj72xxxe.js → pi-mono-adapter-763s8a3w.js} +20 -18
- package/dist/{pricing-refresh-cf25x38j.js → pricing-refresh-kfc215mf.js} +2 -2
- package/dist/{rbac-roles-0wydd22m.js → rbac-roles-3bznvkpt.js} +3 -3
- package/dist/{rbac-roles-at6crb3r.js → rbac-roles-6r4h2ghj.js} +2 -2
- package/dist/{render-v2-nvcw0jd7.js → render-v2-f3qedbpy.js} +10 -10
- package/dist/{resume-y4w0k5v3.js → resume-vcag4ann.js} +13 -13
- package/dist/{runtime-vpe43hx0.js → runtime-x0s55z2t.js} +1 -1
- package/dist/{session-access-gkyvnfye.js → session-access-nwzve8q2.js} +5 -5
- package/dist/{session-source-backfill-3w2st4m2.js → session-source-backfill-jpqfzmgz.js} +2 -2
- package/dist/{setup-axxvqtys.js → setup-d2smwaem.js} +1 -1
- package/dist/thread-buffer-8fc703jc.js +42 -0
- package/dist/{tree-visibility-y4fqvab5.js → tree-visibility-dwzc8en0.js} +2 -2
- package/dist/{user-merge-jobs-kcmwvrc6.js → user-merge-jobs-4ce7kma2.js} +3 -3
- package/dist/{virtual-modules-7d92dct1.js → virtual-modules-78a6yw71.js} +3 -3
- package/dist/{work-objects-f708e069.js → work-objects-m0w1e7q8.js} +28 -28
- package/dist/worker-3p2vq107.js +79 -0
- package/dist/{worker-follow-up-0by8wztc.js → worker-follow-up-e3t6f895.js} +25 -25
- package/dist/{x-3dtaf2r9.js → x-asbrnafg.js} +2 -2
- package/openapi.json +1795 -1623
- package/package.json +13 -12
- package/src/apps/catalog.generated.json +726 -0
- package/src/apps/definition.ts +24 -7
- package/src/apps/page-validator.ts +225 -3
- package/src/be/db.ts +38 -10
- package/src/be/mcp-proxy.ts +5 -4
- package/src/be/migrations/340_api_key_spend_cap.sql +5 -0
- package/src/be/migrations/341_user_token_expiry.sql +4 -0
- package/src/be/schedules/validate.ts +26 -0
- package/src/be/scripts/run-credential.ts +55 -1
- package/src/be/scripts/typecheck.ts +4 -4
- package/src/be/scripts/user-code-mode.ts +160 -0
- package/src/be/swarm-config-guard.ts +4 -0
- package/src/be/users.ts +48 -7
- package/src/commands/credential-outcome-report.ts +5 -2
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/provider-credentials.ts +19 -0
- package/src/commands/provider-error-class.ts +4 -1
- package/src/commands/rate-limit-outcome.ts +48 -3
- package/src/commands/runner.ts +113 -55
- package/src/commands/worktree-reaper.ts +600 -0
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/http/agents.ts +4 -0
- package/src/http/api-keys.ts +27 -3
- package/src/http/pages-public.ts +40 -4
- package/src/http/pool-keys.ts +21 -2
- package/src/http/schedules.ts +28 -3
- package/src/http/script-connection-proxy.ts +18 -6
- package/src/http/script-connections.ts +12 -4
- package/src/http/script-runs.ts +12 -3
- package/src/http/scripts.ts +2 -11
- package/src/http/tasks.ts +6 -10
- package/src/http/users.ts +1 -0
- package/src/integrations/chat-sdk/adapters.ts +29 -0
- package/src/integrations/chat-sdk/limits.ts +3 -0
- package/src/integrations/chat-sdk/rocketchat/README.md +8 -0
- package/src/integrations/chat-sdk/rocketchat/index.ts +790 -0
- package/src/integrations/chat-sdk/rocketchat/markdown.ts +210 -0
- package/src/integrations/chat-sdk/rocketchat/types.ts +249 -0
- package/src/integrations/chat-sdk/runtime.ts +11 -5
- package/src/integrations/chat-sdk/schema.ts +37 -3
- package/src/integrations/chat-sdk/status.ts +9 -0
- package/src/mcp-client/http-client.ts +3 -1
- package/src/oauth/identity-capture.ts +6 -1
- package/src/oauth/mcp-wrapper.ts +10 -3
- package/src/oauth/wrapper.ts +15 -3
- package/src/prompts/session-templates.ts +1 -0
- package/src/providers/acp-targets.ts +2 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/dsh-adapter.ts +1 -1
- package/src/providers/pi-mono-adapter.ts +4 -2
- package/src/providers/runtime-dependencies.ts +1 -1
- package/src/rbac/legacy-policy.ts +3 -0
- package/src/rbac/permissions.ts +9 -0
- package/src/scripts-runtime/executors/native.ts +225 -67
- package/src/scripts-runtime/mcp-client.ts +2 -1
- package/src/scripts-runtime/swarm-sdk.ts +2 -1
- package/src/scripts-runtime/types/stdlib.d.ts +4 -4
- package/src/scripts-runtime/types/swarm-extension.d.ts +7 -7
- package/src/scripts-runtime/types/swarm-sdk.d.ts +4 -4
- package/src/server-user.ts +98 -0
- package/src/slack/enrich.ts +14 -11
- package/src/tests/agents-list-model-display.test.ts +23 -0
- package/src/tests/apps-spike2.test.ts +35 -0
- package/src/tests/base-prompt.test.ts +1 -0
- package/src/tests/chat-sdk-rocketchat-vendored.test.ts +67 -0
- package/src/tests/chat-sdk-status-route.test.ts +13 -1
- package/src/tests/codex-app-server.test.ts +4 -6
- package/src/tests/deploy-guard.test.ts +24 -0
- package/src/tests/dsh-adapter.test.ts +1 -1
- package/src/tests/ensure-token.test.ts +2 -2
- package/src/tests/entrypoint-repo-autoclone-args.test.ts +202 -0
- package/src/tests/fake-dns.ts +47 -0
- package/src/tests/fixtures/base-prompt-baseline.json +12 -12
- package/src/tests/latest-model-report.test.ts +138 -0
- package/src/tests/mcp-oauth-dcr-reuse.test.ts +5 -2
- package/src/tests/mcp-oauth-ensure-token.test.ts +3 -2
- package/src/tests/mcp-oauth-manual-client.test.ts +6 -1
- package/src/tests/mcp-oauth-wrapper.test.ts +20 -4
- package/src/tests/mcp-outbound-fetch-guard.test.ts +169 -0
- package/src/tests/mcp-server-ssrf.test.ts +2 -0
- package/src/tests/mcp-user-route.test.ts +10 -1
- package/src/tests/memory-search-stall.test.ts +5 -0
- package/src/tests/oauth-connection-fetch-guard.test.ts +162 -0
- package/src/tests/oauth-token-endpoint-fetch-guard.test.ts +121 -0
- package/src/tests/oauth-wrapper.test.ts +1 -2
- package/src/tests/pages-head-v2.test.ts +2 -1
- package/src/tests/script-connections-http.test.ts +8 -3
- package/src/tests/script-connections-mcp.test.ts +14 -10
- package/src/tests/script-connections-sql.test.ts +6 -2
- package/src/tests/script-connections.test.ts +4 -0
- package/src/tests/slack-thread-participants.test.ts +14 -3
- package/src/tests/spend-cap-credentials.test.ts +34 -0
- package/src/tests/spend-cap-outcome.test.ts +67 -0
- package/src/tests/subscription-first.test.ts +119 -0
- package/src/tests/worktree-reaper.test.ts +424 -0
- package/src/tools/get-task-details.ts +247 -5
- package/src/tools/schedules/patch-schedule.ts +26 -1
- package/src/tools/schedules/update-schedule.ts +28 -2
- package/src/tools/script-common.ts +37 -22
- package/src/tools/script-query-types.ts +1 -1
- package/src/tools/script-run.ts +1 -1
- package/src/tools/script-search.ts +12 -10
- package/src/tools/utils.ts +7 -1
- package/src/utils/credentials.ts +36 -1
- package/src/utils/egress-guard.ts +40 -10
- package/src/utils/error-tracker.ts +17 -0
- package/templates/skills/apps/SKILL.md +191 -2
- package/templates/skills/apps/content.md +191 -2
- package/templates/skills/boards-and-sheets/content.md +11 -0
- package/templates/skills/chat-sdk/content.md +2 -2
- package/templates/skills/pages/content.md +11 -0
- package/templates/skills/swarm-docs/content.md +4 -0
- package/templates/skills/swarm-scripts/SKILL.md +1 -0
- package/templates/skills/swarm-scripts/content.md +1 -0
- package/templates/workflows/ralph-loop/content.md +6 -6
- package/dist/acp-adapter-cn53011z.js +0 -17
- package/dist/cli-pr0eze3x.js +0 -149
- package/dist/core-0fqtbrxa.js +0 -42
- package/dist/fx-adapter-k6w3jvz9.js +0 -20
- package/dist/grok-adapter-4q5tssw0.js +0 -20
- package/dist/handlers-qxgfvvsf.js +0 -41
- package/dist/heartbeat-6tr2w2da.js +0 -50
- package/dist/index-0mcxjdsa.js +0 -44
- package/dist/index-dz4q23ag.js +0 -40
- package/dist/index-s175jckx.js +0 -39
- package/dist/lead-p3hx7h35.js +0 -79
- package/dist/thread-buffer-rwa7d4dx.js +0 -42
- package/dist/worker-8rg9gz74.js +0 -79
- /package/dist/{cli-m4ejz4nj.js → cli-cah298e5.js} +0 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from "bun:test";
|
|
2
|
+
import { spawnProviderProcess } from "../commands/runner";
|
|
3
|
+
import type { CostData, ProviderEvent, ProviderSessionConfig } from "../providers/types";
|
|
4
|
+
|
|
5
|
+
const originalFetch = globalThis.fetch;
|
|
6
|
+
const directory = `${import.meta.dir}/../../work/latest-model-${crypto.randomUUID()}`;
|
|
7
|
+
|
|
8
|
+
const CONFIG = "openai-codex/gpt-5.5";
|
|
9
|
+
const RESOLVED = "openai-codex/gpt-5.6-luna";
|
|
10
|
+
|
|
11
|
+
beforeAll(async () => {
|
|
12
|
+
await Bun.$`mkdir -p ${directory}`.quiet();
|
|
13
|
+
});
|
|
14
|
+
afterAll(async () => {
|
|
15
|
+
await Bun.$`rm -rf ${directory}`.quiet();
|
|
16
|
+
});
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
globalThis.fetch = originalFetch;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
type ReportedModel = { model: string; source: string };
|
|
22
|
+
|
|
23
|
+
/** Runs one task through the real runner and returns the latest_model of every credential-status PUT. */
|
|
24
|
+
async function runTask(
|
|
25
|
+
claim: { resolvedModel?: string; modelSource?: string; modelTier?: "smol" },
|
|
26
|
+
agentConfigModel = CONFIG,
|
|
27
|
+
): Promise<ReportedModel[]> {
|
|
28
|
+
const reports: ReportedModel[] = [];
|
|
29
|
+
globalThis.fetch = (async (input: string | URL | Request, init?: RequestInit) => {
|
|
30
|
+
const path = new URL(input instanceof Request ? input.url : input.toString()).pathname;
|
|
31
|
+
if (path === "/api/config/resolved") {
|
|
32
|
+
return Response.json({ configs: [{ key: "MODEL_OVERRIDE", value: agentConfigModel }] });
|
|
33
|
+
}
|
|
34
|
+
if (path.endsWith("/credential-status") && init?.method === "PUT") {
|
|
35
|
+
const body = JSON.parse(String(init.body)) as { latest_model?: ReportedModel };
|
|
36
|
+
if (body.latest_model) reports.push(body.latest_model);
|
|
37
|
+
}
|
|
38
|
+
return Response.json({ configs: [], enabled: false });
|
|
39
|
+
}) as typeof fetch;
|
|
40
|
+
|
|
41
|
+
const agentId = crypto.randomUUID();
|
|
42
|
+
const adapter = {
|
|
43
|
+
name: "pi",
|
|
44
|
+
traits: {},
|
|
45
|
+
async createSession(config: ProviderSessionConfig) {
|
|
46
|
+
const cost: CostData = {
|
|
47
|
+
sessionId: "provider-session",
|
|
48
|
+
agentId,
|
|
49
|
+
totalCostUsd: 0,
|
|
50
|
+
inputTokens: 1,
|
|
51
|
+
outputTokens: 1,
|
|
52
|
+
model: config.model,
|
|
53
|
+
durationMs: 1,
|
|
54
|
+
numTurns: 1,
|
|
55
|
+
isError: false,
|
|
56
|
+
provider: "pi",
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
sessionId: "provider-session",
|
|
60
|
+
onEvent(listener: (event: ProviderEvent) => void) {
|
|
61
|
+
listener({ type: "session_init", sessionId: "provider-session" });
|
|
62
|
+
listener({ type: "result", cost, isError: false });
|
|
63
|
+
},
|
|
64
|
+
async waitForCompletion() {
|
|
65
|
+
return { exitCode: 0, isError: false, cost };
|
|
66
|
+
},
|
|
67
|
+
async abort() {},
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
} as unknown as Parameters<typeof spawnProviderProcess>[0];
|
|
71
|
+
|
|
72
|
+
const running = await spawnProviderProcess(
|
|
73
|
+
adapter,
|
|
74
|
+
{
|
|
75
|
+
prompt: "hello",
|
|
76
|
+
systemPrompt: "fixture",
|
|
77
|
+
logFile: `${directory}/session.jsonl`,
|
|
78
|
+
role: "worker",
|
|
79
|
+
apiUrl: "http://runner.invalid",
|
|
80
|
+
apiKey: "example-runner-key",
|
|
81
|
+
agentId,
|
|
82
|
+
runnerSessionId: crypto.randomUUID(),
|
|
83
|
+
iteration: 1,
|
|
84
|
+
taskId: crypto.randomUUID(),
|
|
85
|
+
harnessProvider: "pi",
|
|
86
|
+
cwd: directory,
|
|
87
|
+
// `model` stays unset: a tier or profile task carries no raw pin.
|
|
88
|
+
...claim,
|
|
89
|
+
},
|
|
90
|
+
directory,
|
|
91
|
+
);
|
|
92
|
+
await running.promise;
|
|
93
|
+
return reports;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
describe("latest model source across the initial, result and final reports", () => {
|
|
97
|
+
test.each([
|
|
98
|
+
"tier-default",
|
|
99
|
+
"tier-config",
|
|
100
|
+
"worker-env",
|
|
101
|
+
"profile:task",
|
|
102
|
+
"profile:tier-alias",
|
|
103
|
+
])("claim source %s stays task in all three reports", async (modelSource) => {
|
|
104
|
+
const reports = await runTask({ resolvedModel: RESOLVED, modelSource });
|
|
105
|
+
expect(reports.map((r) => [r.model, r.source])).toEqual([
|
|
106
|
+
[RESOLVED, "task"],
|
|
107
|
+
[RESOLVED, "task"],
|
|
108
|
+
[RESOLVED, "task"],
|
|
109
|
+
]);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test("a tier resolved only locally (no server resolution) stays task in all three reports", async () => {
|
|
113
|
+
const reports = await runTask({ modelTier: "smol" });
|
|
114
|
+
expect(reports).toHaveLength(3);
|
|
115
|
+
expect(reports.map((r) => r.source)).toEqual(["task", "task", "task"]);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test("the agent default profile is never task-selected: custom when it differs from the agent config", async () => {
|
|
119
|
+
const reports = await runTask({
|
|
120
|
+
resolvedModel: RESOLVED,
|
|
121
|
+
modelSource: "profile:agent-default",
|
|
122
|
+
});
|
|
123
|
+
expect(reports.map((r) => [r.model, r.source])).toEqual([
|
|
124
|
+
[RESOLVED, "custom"],
|
|
125
|
+
[RESOLVED, "custom"],
|
|
126
|
+
[RESOLVED, "custom"],
|
|
127
|
+
]);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("the agent default profile reports agent_config when it matches the agent config", async () => {
|
|
131
|
+
const reports = await runTask({ resolvedModel: CONFIG, modelSource: "profile:agent-default" });
|
|
132
|
+
expect(reports.map((r) => [r.model, r.source])).toEqual([
|
|
133
|
+
[CONFIG, "agent_config"],
|
|
134
|
+
[CONFIG, "agent_config"],
|
|
135
|
+
[CONFIG, "agent_config"],
|
|
136
|
+
]);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
@@ -110,7 +110,9 @@ describe("MCP OAuth DCR client reuse", () => {
|
|
|
110
110
|
tokenShouldFail = "";
|
|
111
111
|
asScopesSupported = [];
|
|
112
112
|
process.env.SECRETS_ENCRYPTION_KEY = Buffer.alloc(32, 11).toString("base64");
|
|
113
|
-
|
|
113
|
+
// The fetch stubs here route by URL. Allowing private hosts skips name
|
|
114
|
+
// resolution and address pinning, which mcp-outbound-fetch-guard.test.ts covers.
|
|
115
|
+
process.env.MCP_OAUTH_ALLOW_PRIVATE_HOSTS = "true";
|
|
114
116
|
process.env.PUBLIC_MCP_BASE_URL = "https://swarm.example.test";
|
|
115
117
|
process.env.APP_URL = "https://dashboard.example.test";
|
|
116
118
|
|
|
@@ -153,7 +155,8 @@ describe("MCP OAuth DCR client reuse", () => {
|
|
|
153
155
|
}
|
|
154
156
|
if (href === `https://${issuerHost}/token` && init?.method === "POST") {
|
|
155
157
|
capturedTokenBody = (init?.body as string) ?? "";
|
|
156
|
-
|
|
158
|
+
const authorization = new Headers(init?.headers).get("authorization");
|
|
159
|
+
capturedTokenHeaders = authorization === null ? {} : { Authorization: authorization };
|
|
157
160
|
if (tokenShouldFail === "invalid_client") {
|
|
158
161
|
return Response.json(
|
|
159
162
|
{ error: "invalid_client", error_description: "client no longer recognized" },
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Resolves the reserved example names these tests fetch, without real DNS.
|
|
2
|
+
import "./fake-dns";
|
|
1
3
|
import { afterAll, afterEach, beforeAll, describe, expect, test } from "bun:test";
|
|
2
4
|
import { unlink } from "node:fs/promises";
|
|
3
5
|
import { closeDb, createMcpServer, initDb } from "../be/db";
|
|
@@ -155,9 +157,8 @@ describe("ensureMcpToken", () => {
|
|
|
155
157
|
await upsertMcpOAuthToken(input);
|
|
156
158
|
|
|
157
159
|
globalThis.fetch = async (_url: string | URL | Request, init?: RequestInit) => {
|
|
158
|
-
const headers = init?.headers as Record<string, string>;
|
|
159
160
|
const params = new URLSearchParams((init?.body as string) ?? "");
|
|
160
|
-
expect(headers.
|
|
161
|
+
expect(new Headers(init?.headers).get("authorization")).toBeNull();
|
|
161
162
|
expect(params.get("client_id")).toBe("client-abc");
|
|
162
163
|
expect(params.get("client_secret")).toBe("example-secret-xyz");
|
|
163
164
|
return new Response(
|
|
@@ -111,6 +111,9 @@ describe("MCP OAuth manual client flow", () => {
|
|
|
111
111
|
process.env.PUBLIC_MCP_BASE_URL = "https://swarm.example.test";
|
|
112
112
|
process.env.APP_URL = "https://dashboard.example.test";
|
|
113
113
|
delete process.env.DASHBOARD_URL;
|
|
114
|
+
// The fetch stubs here route by URL. Allowing private hosts skips name
|
|
115
|
+
// resolution and address pinning, which mcp-outbound-fetch-guard.test.ts covers.
|
|
116
|
+
process.env.MCP_OAUTH_ALLOW_PRIVATE_HOSTS = "true";
|
|
114
117
|
|
|
115
118
|
globalThis.fetch = (async (input: string | URL | Request, init?: RequestInit) => {
|
|
116
119
|
const href = input.toString();
|
|
@@ -134,7 +137,8 @@ describe("MCP OAuth manual client flow", () => {
|
|
|
134
137
|
}
|
|
135
138
|
if (href === "https://login.salesforce.com/services/oauth2/token") {
|
|
136
139
|
capturedTokenBody = init?.body?.toString() ?? null;
|
|
137
|
-
|
|
140
|
+
const authorization = new Headers(init?.headers).get("authorization");
|
|
141
|
+
capturedTokenHeaders = authorization === null ? {} : { Authorization: authorization };
|
|
138
142
|
return new Response(
|
|
139
143
|
JSON.stringify({
|
|
140
144
|
access_token: "example-sf-access-token",
|
|
@@ -152,6 +156,7 @@ describe("MCP OAuth manual client flow", () => {
|
|
|
152
156
|
|
|
153
157
|
afterEach(async () => {
|
|
154
158
|
globalThis.fetch = originalFetch;
|
|
159
|
+
delete process.env.MCP_OAUTH_ALLOW_PRIVATE_HOSTS;
|
|
155
160
|
closeDb();
|
|
156
161
|
await removeDbFiles();
|
|
157
162
|
if (originalPublicMcpBaseUrl === undefined) delete process.env.PUBLIC_MCP_BASE_URL;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
1
|
+
import { afterAll, afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
2
2
|
import {
|
|
3
3
|
assertUrlSafe,
|
|
4
4
|
authMethodForStoredClient,
|
|
@@ -14,6 +14,16 @@ import {
|
|
|
14
14
|
selectDcrTokenEndpointAuthMethod,
|
|
15
15
|
} from "../oauth/mcp-wrapper";
|
|
16
16
|
|
|
17
|
+
// The fetch stubs here route by URL. Allowing private hosts skips name
|
|
18
|
+
// resolution and address pinning, which mcp-outbound-fetch-guard.test.ts covers.
|
|
19
|
+
// The SSRF guard tests below clear the flag for themselves.
|
|
20
|
+
const prevAllowPrivateHosts = process.env.MCP_OAUTH_ALLOW_PRIVATE_HOSTS;
|
|
21
|
+
process.env.MCP_OAUTH_ALLOW_PRIVATE_HOSTS = "true";
|
|
22
|
+
afterAll(() => {
|
|
23
|
+
if (prevAllowPrivateHosts === undefined) delete process.env.MCP_OAUTH_ALLOW_PRIVATE_HOSTS;
|
|
24
|
+
else process.env.MCP_OAUTH_ALLOW_PRIVATE_HOSTS = prevAllowPrivateHosts;
|
|
25
|
+
});
|
|
26
|
+
|
|
17
27
|
// ─── SSRF guard ──────────────────────────────────────────────────────────────
|
|
18
28
|
|
|
19
29
|
describe("assertUrlSafe (SSRF guard)", () => {
|
|
@@ -251,6 +261,12 @@ describe("buildAuthorizeUrl (PKCE S256, RFC 8707)", () => {
|
|
|
251
261
|
});
|
|
252
262
|
});
|
|
253
263
|
|
|
264
|
+
// Fetches go out with a Headers object, so read the header case-insensitively.
|
|
265
|
+
function authorizationHeaderOf(init?: RequestInit): Record<string, string> {
|
|
266
|
+
const value = new Headers(init?.headers).get("authorization");
|
|
267
|
+
return value === null ? {} : { Authorization: value };
|
|
268
|
+
}
|
|
269
|
+
|
|
254
270
|
// ─── Discovery (PRMD + AS metadata) ──────────────────────────────────────────
|
|
255
271
|
|
|
256
272
|
describe("discoverProtectedResourceMetadata (RFC 9728)", () => {
|
|
@@ -697,7 +713,7 @@ describe("token-endpoint client authentication is applied per the registered met
|
|
|
697
713
|
let capturedHeaders: Record<string, string> = {};
|
|
698
714
|
globalThis.fetch = async (_url: string | URL | Request, init?: RequestInit) => {
|
|
699
715
|
capturedBody = (init?.body as string) ?? "";
|
|
700
|
-
capturedHeaders = (init
|
|
716
|
+
capturedHeaders = authorizationHeaderOf(init);
|
|
701
717
|
return new Response(JSON.stringify({ access_token: "at-1" }), {
|
|
702
718
|
status: 200,
|
|
703
719
|
headers: { "Content-Type": "application/json" },
|
|
@@ -941,7 +957,7 @@ describe("token-endpoint client authentication is applied per the registered met
|
|
|
941
957
|
let capturedHeaders: Record<string, string> = {};
|
|
942
958
|
globalThis.fetch = async (_url: string | URL | Request, init?: RequestInit) => {
|
|
943
959
|
capturedBody = (init?.body as string) ?? "";
|
|
944
|
-
capturedHeaders = (init
|
|
960
|
+
capturedHeaders = authorizationHeaderOf(init);
|
|
945
961
|
return new Response(JSON.stringify({ access_token: "at-1" }), {
|
|
946
962
|
status: 200,
|
|
947
963
|
headers: { "Content-Type": "application/json" },
|
|
@@ -970,7 +986,7 @@ describe("token-endpoint client authentication is applied per the registered met
|
|
|
970
986
|
let capturedBody = "";
|
|
971
987
|
globalThis.fetch = async (_url: string | URL | Request, init?: RequestInit) => {
|
|
972
988
|
capturedBody = (init?.body as string) ?? "";
|
|
973
|
-
capturedHeaders = (init
|
|
989
|
+
capturedHeaders = authorizationHeaderOf(init);
|
|
974
990
|
return new Response(JSON.stringify({ access_token: "new-at" }), {
|
|
975
991
|
status: 200,
|
|
976
992
|
headers: { "Content-Type": "application/json" },
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from "bun:test";
|
|
2
|
+
import { unlink } from "node:fs/promises";
|
|
3
|
+
import { closeDb, createMcpServer, initDb } from "../be/db";
|
|
4
|
+
import { listMcpServerTools } from "../be/mcp-proxy";
|
|
5
|
+
import { discoverProtectedResourceMetadata } from "../oauth/mcp-wrapper";
|
|
6
|
+
import { setFakeDnsAnswer } from "./fake-dns";
|
|
7
|
+
|
|
8
|
+
// No lookup leaves the process: `mcp.public.test` resolves to a public address
|
|
9
|
+
// (reserved test name), `rebind.public.test` to loopback.
|
|
10
|
+
setFakeDnsAnswer("rebind.public.test", ["127.0.0.1"]);
|
|
11
|
+
|
|
12
|
+
const TEST_DB_PATH = "./test-mcp-outbound-fetch-guard.sqlite";
|
|
13
|
+
const originalFetch = globalThis.fetch;
|
|
14
|
+
const savedEnv = {
|
|
15
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
16
|
+
MCP_OAUTH_ALLOW_PRIVATE_HOSTS: process.env.MCP_OAUTH_ALLOW_PRIVATE_HOSTS,
|
|
17
|
+
ALLOW_PRIVATE_NETWORK_URLS: process.env.ALLOW_PRIVATE_NETWORK_URLS,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type Seen = { host: string; hostname: string; href: string };
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A fetch stand-in with the platform's redirect behaviour: unless the caller
|
|
24
|
+
* passes `redirect: "manual"` or `"error"`, a 3xx with Location is followed
|
|
25
|
+
* inside fetch, as the real one does. Requests are routed by the Host header
|
|
26
|
+
* (an address-pinned request keeps the original name there).
|
|
27
|
+
*/
|
|
28
|
+
function installFetch(route: (host: string, url: URL) => Response): Seen[] {
|
|
29
|
+
const seen: Seen[] = [];
|
|
30
|
+
globalThis.fetch = (async (input: string | URL | Request, init?: RequestInit) => {
|
|
31
|
+
let url = new URL(
|
|
32
|
+
typeof input === "string" ? input : input instanceof URL ? input.href : input.url,
|
|
33
|
+
);
|
|
34
|
+
const hostHeader = new Headers(init?.headers).get("host");
|
|
35
|
+
let host = hostHeader ?? url.host;
|
|
36
|
+
for (let hop = 0; hop < 6; hop++) {
|
|
37
|
+
seen.push({ host, hostname: url.hostname, href: url.href });
|
|
38
|
+
const res = route(host, url);
|
|
39
|
+
const location = res.headers.get("location");
|
|
40
|
+
const followed = (init?.redirect ?? "follow") === "follow";
|
|
41
|
+
if (!followed || !location || ![301, 302, 303, 307, 308].includes(res.status)) return res;
|
|
42
|
+
url = new URL(location, url);
|
|
43
|
+
host = url.host;
|
|
44
|
+
}
|
|
45
|
+
throw new Error("too many redirects");
|
|
46
|
+
}) as typeof fetch;
|
|
47
|
+
return seen;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const isLoopback = (s: Seen) =>
|
|
51
|
+
s.hostname === "127.0.0.1" || s.host.startsWith("127.0.0.1") || s.host === "rebind.public.test";
|
|
52
|
+
|
|
53
|
+
async function removeDbFiles(path: string): Promise<void> {
|
|
54
|
+
for (const suffix of ["", "-wal", "-shm"]) {
|
|
55
|
+
try {
|
|
56
|
+
await unlink(path + suffix);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
beforeAll(async () => {
|
|
64
|
+
process.env.NODE_ENV = "production";
|
|
65
|
+
delete process.env.MCP_OAUTH_ALLOW_PRIVATE_HOSTS;
|
|
66
|
+
delete process.env.ALLOW_PRIVATE_NETWORK_URLS;
|
|
67
|
+
await removeDbFiles(TEST_DB_PATH);
|
|
68
|
+
initDb(TEST_DB_PATH);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
afterEach(() => {
|
|
72
|
+
globalThis.fetch = originalFetch;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
afterAll(async () => {
|
|
76
|
+
closeDb();
|
|
77
|
+
for (const [key, value] of Object.entries(savedEnv)) {
|
|
78
|
+
if (value === undefined) delete process.env[key];
|
|
79
|
+
else process.env[key] = value;
|
|
80
|
+
}
|
|
81
|
+
await removeDbFiles(TEST_DB_PATH);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe("MCP OAuth metadata discovery outbound requests", () => {
|
|
85
|
+
test("control: a public resource's metadata is fetched and parsed", async () => {
|
|
86
|
+
const seen = installFetch(() =>
|
|
87
|
+
Response.json({ resource: "https://mcp.public.test/mcp", authorization_servers: [] }),
|
|
88
|
+
);
|
|
89
|
+
const prmd = await discoverProtectedResourceMetadata("https://mcp.public.test/mcp");
|
|
90
|
+
expect(prmd?.resource).toBe("https://mcp.public.test/mcp");
|
|
91
|
+
expect(seen.length).toBeGreaterThan(0);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test("control: a loopback resource URL is refused before any request", async () => {
|
|
95
|
+
const seen = installFetch(() => new Response("unexpected", { status: 500 }));
|
|
96
|
+
await discoverProtectedResourceMetadata("https://127.0.0.1/mcp");
|
|
97
|
+
expect(seen).toEqual([]);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test("does not follow a redirect from a public host to a loopback address", async () => {
|
|
101
|
+
const seen = installFetch((host) =>
|
|
102
|
+
host === "mcp.public.test"
|
|
103
|
+
? new Response(null, { status: 307, headers: { location: "https://127.0.0.1/internal" } })
|
|
104
|
+
: Response.json({ resource: "internal" }),
|
|
105
|
+
);
|
|
106
|
+
const prmd = await discoverProtectedResourceMetadata("https://mcp.public.test/mcp");
|
|
107
|
+
expect(seen.filter(isLoopback)).toEqual([]);
|
|
108
|
+
expect(prmd).toBeNull();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test("does not connect to a name that resolves to a loopback address", async () => {
|
|
112
|
+
const seen = installFetch(() => Response.json({ resource: "internal" }));
|
|
113
|
+
const prmd = await discoverProtectedResourceMetadata("https://rebind.public.test/mcp");
|
|
114
|
+
expect(seen.filter(isLoopback)).toEqual([]);
|
|
115
|
+
expect(prmd).toBeNull();
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe("Script MCP proxy outbound requests", () => {
|
|
120
|
+
const mcpResponses = () => {
|
|
121
|
+
let n = 0;
|
|
122
|
+
return () => {
|
|
123
|
+
n += 1;
|
|
124
|
+
if (n === 1) return Response.json({ jsonrpc: "2.0", id: 1, result: {} });
|
|
125
|
+
if (n === 2) return new Response(null, { status: 202 });
|
|
126
|
+
return Response.json({ jsonrpc: "2.0", id: 2, result: { tools: [] } });
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
test("control: a public MCP server is reachable", async () => {
|
|
131
|
+
const server = await createMcpServer({
|
|
132
|
+
name: `public-${crypto.randomUUID()}`,
|
|
133
|
+
transport: "http",
|
|
134
|
+
url: "https://mcp.public.test/streamable",
|
|
135
|
+
});
|
|
136
|
+
const next = mcpResponses();
|
|
137
|
+
const seen = installFetch(() => next());
|
|
138
|
+
await expect(listMcpServerTools(server.id)).resolves.toEqual([]);
|
|
139
|
+
expect(seen.length).toBe(3);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test("does not follow a redirect from the MCP server to a loopback address", async () => {
|
|
143
|
+
const server = await createMcpServer({
|
|
144
|
+
name: `redirect-${crypto.randomUUID()}`,
|
|
145
|
+
transport: "http",
|
|
146
|
+
url: "https://mcp.public.test/streamable",
|
|
147
|
+
});
|
|
148
|
+
const next = mcpResponses();
|
|
149
|
+
const seen = installFetch((host) =>
|
|
150
|
+
host === "mcp.public.test"
|
|
151
|
+
? new Response(null, { status: 307, headers: { location: "https://127.0.0.1/internal" } })
|
|
152
|
+
: next(),
|
|
153
|
+
);
|
|
154
|
+
await listMcpServerTools(server.id).catch(() => undefined);
|
|
155
|
+
expect(seen.filter(isLoopback)).toEqual([]);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
test("does not connect to an MCP server name that resolves to a loopback address", async () => {
|
|
159
|
+
const server = await createMcpServer({
|
|
160
|
+
name: `rebind-${crypto.randomUUID()}`,
|
|
161
|
+
transport: "http",
|
|
162
|
+
url: "https://rebind.public.test/streamable",
|
|
163
|
+
});
|
|
164
|
+
const next = mcpResponses();
|
|
165
|
+
const seen = installFetch(() => next());
|
|
166
|
+
await expect(listMcpServerTools(server.id)).rejects.toThrow();
|
|
167
|
+
expect(seen.filter(isLoopback)).toEqual([]);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Resolves the reserved example names these tests fetch, without real DNS.
|
|
2
|
+
import "./fake-dns";
|
|
1
3
|
import { afterAll, afterEach, beforeAll, describe, expect, test } from "bun:test";
|
|
2
4
|
import { unlink } from "node:fs/promises";
|
|
3
5
|
import { createServer, type Server } from "node:http";
|
|
@@ -287,7 +287,16 @@ describe("/mcp-user auth and tool surface", () => {
|
|
|
287
287
|
};
|
|
288
288
|
const names = result.result.tools.map((tool) => tool.name).sort();
|
|
289
289
|
expect(names).toEqual(
|
|
290
|
-
[
|
|
290
|
+
[
|
|
291
|
+
"cancel-task",
|
|
292
|
+
"get-task-details",
|
|
293
|
+
"get-tasks",
|
|
294
|
+
"script-get-types",
|
|
295
|
+
"script-run",
|
|
296
|
+
"script-search",
|
|
297
|
+
"send-task",
|
|
298
|
+
"steer-task",
|
|
299
|
+
].sort(),
|
|
291
300
|
);
|
|
292
301
|
const sendTask = result.result.tools.find((tool) => tool.name === "send-task");
|
|
293
302
|
expect(Object.keys(sendTask?.inputSchema.properties ?? {}).sort()).toEqual(
|
|
@@ -72,6 +72,11 @@ async function remember(
|
|
|
72
72
|
sourceTaskId: sourceTaskId ?? undefined,
|
|
73
73
|
});
|
|
74
74
|
await store.updateEmbedding(row.id, mix(cos, 4), "test");
|
|
75
|
+
// The write's post-commit invalidation runs behind the DB lock queue (and the
|
|
76
|
+
// FTS backfill's statements), possibly after the caller resumes. A search that
|
|
77
|
+
// started first would see its count overtaken and retried, so the scan counts
|
|
78
|
+
// below would depend on timing. A query queued now runs after that hook.
|
|
79
|
+
await getDbClient().get("SELECT 1");
|
|
75
80
|
return row.id;
|
|
76
81
|
}
|
|
77
82
|
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from "bun:test";
|
|
2
|
+
import { attemptRemoteRevocation, discoverOAuthApp } from "../http/script-connections";
|
|
3
|
+
import { captureIdentity } from "../oauth/identity-capture";
|
|
4
|
+
import type { OAuthApp } from "../tracker/types";
|
|
5
|
+
import { setFakeDnsAnswer } from "./fake-dns";
|
|
6
|
+
|
|
7
|
+
// No lookup leaves the process: `auth.public.test` resolves to a public address
|
|
8
|
+
// (reserved test name), `rebind.public.test` to loopback.
|
|
9
|
+
setFakeDnsAnswer("rebind.public.test", ["127.0.0.1"]);
|
|
10
|
+
|
|
11
|
+
const originalFetch = globalThis.fetch;
|
|
12
|
+
const savedEnv = {
|
|
13
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
14
|
+
ALLOW_PRIVATE_NETWORK_URLS: process.env.ALLOW_PRIVATE_NETWORK_URLS,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type Seen = { host: string; hostname: string; authorization: string | null; body: string | null };
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A fetch stand-in that records every request and answers from `route`.
|
|
21
|
+
* Requests are routed by the Host header (an address-pinned request keeps the
|
|
22
|
+
* original name there). Every caller here passes `redirect: "manual"`.
|
|
23
|
+
*/
|
|
24
|
+
function installFetch(route: (host: string, url: URL) => Response): Seen[] {
|
|
25
|
+
const seen: Seen[] = [];
|
|
26
|
+
globalThis.fetch = (async (input: string | URL | Request, init?: RequestInit) => {
|
|
27
|
+
const url = new URL(
|
|
28
|
+
typeof input === "string" ? input : input instanceof URL ? input.href : input.url,
|
|
29
|
+
);
|
|
30
|
+
const headers = new Headers(init?.headers);
|
|
31
|
+
const host = headers.get("host") ?? url.host;
|
|
32
|
+
seen.push({
|
|
33
|
+
host,
|
|
34
|
+
hostname: url.hostname,
|
|
35
|
+
authorization: headers.get("authorization"),
|
|
36
|
+
body: typeof init?.body === "string" ? init.body : null,
|
|
37
|
+
});
|
|
38
|
+
return route(host, url);
|
|
39
|
+
}) as typeof fetch;
|
|
40
|
+
return seen;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const isLoopback = (s: Seen) =>
|
|
44
|
+
s.hostname === "127.0.0.1" || s.host.startsWith("127.0.0.1") || s.host === "rebind.public.test";
|
|
45
|
+
|
|
46
|
+
function oauthApp(revocationUrl: string): OAuthApp {
|
|
47
|
+
return {
|
|
48
|
+
id: crypto.randomUUID(),
|
|
49
|
+
provider: "guard-test",
|
|
50
|
+
displayName: null,
|
|
51
|
+
clientId: "client-id",
|
|
52
|
+
clientSecret: "client-secret-value",
|
|
53
|
+
clientSecretEncrypted: false,
|
|
54
|
+
authorizeUrl: "https://auth.public.test/authorize",
|
|
55
|
+
tokenUrl: "https://auth.public.test/token",
|
|
56
|
+
revocationUrl,
|
|
57
|
+
userinfoUrl: null,
|
|
58
|
+
redirectUri: "https://swarm.public.test/callback",
|
|
59
|
+
scopes: "",
|
|
60
|
+
scopeSeparator: " ",
|
|
61
|
+
tokenAuthStyle: "body",
|
|
62
|
+
tokenBodyFormat: "form",
|
|
63
|
+
requiresRefreshTokenRotation: false,
|
|
64
|
+
extraParamsJson: null,
|
|
65
|
+
source: "manual",
|
|
66
|
+
mcpServerId: null,
|
|
67
|
+
metadata: "{}",
|
|
68
|
+
createdAt: new Date().toISOString(),
|
|
69
|
+
updatedAt: new Date().toISOString(),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const metadata = {
|
|
74
|
+
authorization_endpoint: "https://auth.public.test/authorize",
|
|
75
|
+
token_endpoint: "https://auth.public.test/token",
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
beforeAll(() => {
|
|
79
|
+
process.env.NODE_ENV = "production";
|
|
80
|
+
delete process.env.ALLOW_PRIVATE_NETWORK_URLS;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
afterEach(() => {
|
|
84
|
+
globalThis.fetch = originalFetch;
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
afterAll(() => {
|
|
88
|
+
for (const [key, value] of Object.entries(savedEnv)) {
|
|
89
|
+
if (value === undefined) delete process.env[key];
|
|
90
|
+
else process.env[key] = value;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe("OAuth identity capture outbound request", () => {
|
|
95
|
+
test("control: a public userinfo endpoint receives the bearer", async () => {
|
|
96
|
+
const seen = installFetch(() => Response.json({ email: "user@example.com" }));
|
|
97
|
+
const identity = await captureIdentity({
|
|
98
|
+
userinfoUrl: "https://auth.public.test/userinfo",
|
|
99
|
+
accessToken: "live-access-token",
|
|
100
|
+
});
|
|
101
|
+
expect(identity?.accountEmail).toBe("user@example.com");
|
|
102
|
+
expect(seen.map((s) => s.authorization)).toEqual(["Bearer live-access-token"]);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test("does not send the bearer to a name that resolves to a loopback address", async () => {
|
|
106
|
+
const seen = installFetch(() => Response.json({ email: "internal@example.com" }));
|
|
107
|
+
const identity = await captureIdentity({
|
|
108
|
+
userinfoUrl: "https://rebind.public.test/userinfo",
|
|
109
|
+
accessToken: "live-access-token",
|
|
110
|
+
});
|
|
111
|
+
expect(seen.filter(isLoopback)).toEqual([]);
|
|
112
|
+
expect(identity).toBeNull();
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe("OAuth token revocation outbound request", () => {
|
|
117
|
+
test("control: a public revocation endpoint receives the request", async () => {
|
|
118
|
+
const seen = installFetch(() => new Response(null, { status: 200 }));
|
|
119
|
+
await expect(
|
|
120
|
+
attemptRemoteRevocation(oauthApp("https://auth.public.test/revoke"), "live-access-token"),
|
|
121
|
+
).resolves.toBe(true);
|
|
122
|
+
expect(seen).toHaveLength(1);
|
|
123
|
+
expect(seen[0]?.body).toContain("client_secret=client-secret-value");
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test("does not send the client secret to a name that resolves to a loopback address", async () => {
|
|
127
|
+
const seen = installFetch(() => new Response(null, { status: 200 }));
|
|
128
|
+
await attemptRemoteRevocation(
|
|
129
|
+
oauthApp("https://rebind.public.test/revoke"),
|
|
130
|
+
"live-access-token",
|
|
131
|
+
);
|
|
132
|
+
expect(seen.filter(isLoopback)).toEqual([]);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe("OAuth app discovery outbound requests", () => {
|
|
137
|
+
test("control: a public issuer's metadata is fetched and parsed", async () => {
|
|
138
|
+
const seen = installFetch(() => Response.json(metadata));
|
|
139
|
+
const discovered = await discoverOAuthApp("https://auth.public.test");
|
|
140
|
+
expect(discovered.tokenUrl).toBe("https://auth.public.test/token");
|
|
141
|
+
expect(seen.length).toBeGreaterThan(0);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test("does not connect to an issuer name that resolves to a loopback address", async () => {
|
|
145
|
+
const seen = installFetch(() => Response.json(metadata));
|
|
146
|
+
await expect(discoverOAuthApp("https://rebind.public.test")).rejects.toThrow();
|
|
147
|
+
expect(seen.filter(isLoopback)).toEqual([]);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test("does not follow a redirect to a name that resolves to a loopback address", async () => {
|
|
151
|
+
const seen = installFetch((host) =>
|
|
152
|
+
host === "auth.public.test"
|
|
153
|
+
? new Response(null, {
|
|
154
|
+
status: 302,
|
|
155
|
+
headers: { location: "https://rebind.public.test/metadata" },
|
|
156
|
+
})
|
|
157
|
+
: Response.json(metadata),
|
|
158
|
+
);
|
|
159
|
+
await expect(discoverOAuthApp("https://auth.public.test")).rejects.toThrow();
|
|
160
|
+
expect(seen.filter(isLoopback)).toEqual([]);
|
|
161
|
+
});
|
|
162
|
+
});
|