@mastra/server-adapters-test-suite 0.2.0-alpha.3 → 0.2.1-alpha.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/CHANGELOG.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # @mastra/server-adapters-test-suite
2
2
 
3
+ ## 0.2.1-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - `server.auth.authorize(path, method, user, context)` can now call `context.get('requestContext')` and `context.get('mastra')` on the Express, Fastify, Koa and Elysia adapters, as it already could on Hono. Values an app sets on the request context in `authorize` now reach route handlers on every adapter. ([#29069](https://github.com/mastra-ai/mastra/pull/29069))
8
+
9
+ ```ts
10
+ authorize: async (path, method, user, context) => {
11
+ context.get('requestContext').set('tenantId', user.orgId); // read it in any route handler
12
+ return appAuthorize(path, method, user, context);
13
+ };
14
+ ```
15
+
16
+ - Updated dependencies [[`0a553f0`](https://github.com/mastra-ai/mastra/commit/0a553f0f6ff4150fa5d9897b53824a647f7ddd1e), [`99ca92b`](https://github.com/mastra-ai/mastra/commit/99ca92b60272063a5cb978628e5d286f86c37d4d), [`ba602f5`](https://github.com/mastra-ai/mastra/commit/ba602f5f4622d6a3e6beb6d2741e3d19efe57ca9), [`4d3ebbd`](https://github.com/mastra-ai/mastra/commit/4d3ebbd304509acb118f319e8467fc932079e715), [`a4d1537`](https://github.com/mastra-ai/mastra/commit/a4d1537e8bac1d3634059bdbc843d787f1ac91f2), [`5a37eef`](https://github.com/mastra-ai/mastra/commit/5a37eefdafb239ccc6514018113f3fb1a025ce9b), [`41dc481`](https://github.com/mastra-ai/mastra/commit/41dc481f1b3509ec6c2a06e63caaa4f630cafa80), [`500edeb`](https://github.com/mastra-ai/mastra/commit/500edeb84e7ec665b5af26e99fced33cf3c85bfd), [`8bea966`](https://github.com/mastra-ai/mastra/commit/8bea9662c5d89c248c7311fc6cca6523d552af5d), [`0a553f0`](https://github.com/mastra-ai/mastra/commit/0a553f0f6ff4150fa5d9897b53824a647f7ddd1e), [`697ea99`](https://github.com/mastra-ai/mastra/commit/697ea99ae93f6dae203cab0f059bc5f9d8316c1e), [`cbe76c0`](https://github.com/mastra-ai/mastra/commit/cbe76c0d76e5543866f918fd41041c4d73a1a172), [`eddb060`](https://github.com/mastra-ai/mastra/commit/eddb0605db3f0be107e5ea392c7a407675303185), [`eddb060`](https://github.com/mastra-ai/mastra/commit/eddb0605db3f0be107e5ea392c7a407675303185), [`49e59f2`](https://github.com/mastra-ai/mastra/commit/49e59f251e45de082262e3892b599f48c1ddb413), [`ba602f5`](https://github.com/mastra-ai/mastra/commit/ba602f5f4622d6a3e6beb6d2741e3d19efe57ca9), [`b3b2cd2`](https://github.com/mastra-ai/mastra/commit/b3b2cd292a314ed4b422dd055f8d1580c781860a), [`99ca92b`](https://github.com/mastra-ai/mastra/commit/99ca92b60272063a5cb978628e5d286f86c37d4d)]:
17
+ - @mastra/core@1.82.0-alpha.0
18
+ - @mastra/server@1.82.0-alpha.0
19
+ - @mastra/mcp@2.8.0-alpha.0
20
+
21
+ ## 0.2.0
22
+
23
+ ### Minor Changes
24
+
25
+ - Added `createStructuredWakeTestSuite` to check that idle-thread subscriptions receive structured results and validation errors before the terminal event on plain, durable, and evented agents. ([#28617](https://github.com/mastra-ai/mastra/pull/28617))
26
+
27
+ Pass your adapter's scripted model fixture as `setupModel` and its real HTTP server factory as `startServer`:
28
+
29
+ ```ts
30
+ import { createStructuredWakeTestSuite } from '@mastra/server-adapters-test-suite';
31
+
32
+ createStructuredWakeTestSuite({ setupModel, startServer });
33
+ ```
34
+
35
+ ### Patch Changes
36
+
37
+ - dependencies updates: ([#28417](https://github.com/mastra-ai/mastra/pull/28417))
38
+ - Updated dependency [`@types/node@22.19.15` ↗︎](https://www.npmjs.com/package/@types/node/v/22.19.15) (from `22.20.5`, in `devDependencies`)
39
+
40
+ - Add a reusable real-HTTP disconnect suite covering durable and evented stream starts, resumes, tool approvals, observer replay, and explicit cancellation, with ordinary agents as the cancellation control. ([#28162](https://github.com/mastra-ai/mastra/pull/28162))
41
+
42
+ - Removed the `supportsRBAC` option from the adapter test suite config. Every built-in adapter now enforces route permissions, so the shared "Studio-only RBAC" tests always run. ([#28205](https://github.com/mastra-ai/mastra/pull/28205))
43
+
44
+ - Server adapters tested with the shared route suite now pass for the MCP server event routes (`/mcp/:serverId/events/:eventName/poll`, `/stream`, `/emit`) and `POST /observability/spans/aggregate`. The suite now registers a test event on its MCP server, supplies the `eventName` path param and an emit payload, runs the dev-only emit route with `MASTRA_DEV` set, and mocks span aggregation support. ([#28116](https://github.com/mastra-ai/mastra/pull/28116))
45
+
46
+ - Skipped the run-scoped abort route (`POST /agents/:agentId/runs/:runId/abort`) in the generic adapter route suite, since it returns 501 for the suite's non-durable agent by design. Adapter suites no longer fail on this route. ([#28301](https://github.com/mastra-ai/mastra/pull/28301))
47
+
48
+ - Updated dependencies [[`ce5d473`](https://github.com/mastra-ai/mastra/commit/ce5d4731eeeb44779748852618b95c5cb6485bed), [`a15ea70`](https://github.com/mastra-ai/mastra/commit/a15ea70e71ca57242fa61b23e7f0178d77f9af4b), [`164b9c1`](https://github.com/mastra-ai/mastra/commit/164b9c196afb3e477e97029c369b34a14b84544b), [`ce5d473`](https://github.com/mastra-ai/mastra/commit/ce5d4731eeeb44779748852618b95c5cb6485bed), [`a15ea70`](https://github.com/mastra-ai/mastra/commit/a15ea70e71ca57242fa61b23e7f0178d77f9af4b), [`ce5d473`](https://github.com/mastra-ai/mastra/commit/ce5d4731eeeb44779748852618b95c5cb6485bed), [`347f562`](https://github.com/mastra-ai/mastra/commit/347f562ff20b0b61fc4e5e8b58b8b0aac971b3cd), [`f396b43`](https://github.com/mastra-ai/mastra/commit/f396b435c72042fc6d9e82c361fa047675995812), [`f396b43`](https://github.com/mastra-ai/mastra/commit/f396b435c72042fc6d9e82c361fa047675995812), [`c253e13`](https://github.com/mastra-ai/mastra/commit/c253e13ac627d0325f8665004f7af8a49805a9a4), [`0a913e0`](https://github.com/mastra-ai/mastra/commit/0a913e096cb569aea396fa3d9f286cc874179ce8), [`c8f8e41`](https://github.com/mastra-ai/mastra/commit/c8f8e410d39a29b8b69cb7bf90cc9a774cb956f5), [`3dfe2eb`](https://github.com/mastra-ai/mastra/commit/3dfe2eb8c3ef3b18d2395a3618b6214488963d05), [`152e380`](https://github.com/mastra-ai/mastra/commit/152e380aca6fcf74f598a158c710c0e755ceb325), [`3143101`](https://github.com/mastra-ai/mastra/commit/31431019ddd56d0b5677f8cd169f715f0e907266), [`08640de`](https://github.com/mastra-ai/mastra/commit/08640de350ff9183c1d9ef568fde4c6ccdf181e4), [`b7ff751`](https://github.com/mastra-ai/mastra/commit/b7ff751ed0fd87a3f93ce438c355c2dcc16e79d5), [`24a821b`](https://github.com/mastra-ai/mastra/commit/24a821b0ff29f527787c0645a7bf7bbe50d27f57), [`551189d`](https://github.com/mastra-ai/mastra/commit/551189d6b6737a928b61335ce80cbe19e1b53bdd), [`99e4867`](https://github.com/mastra-ai/mastra/commit/99e486723d3f0063ae70a39c9840daf92a98fa23), [`a1e248b`](https://github.com/mastra-ai/mastra/commit/a1e248bfe0776ab6ca2a55fed3c423b08fb5ae03), [`0afde2c`](https://github.com/mastra-ai/mastra/commit/0afde2c114aa02b0186ae963c8c83796f8801b60), [`38ff787`](https://github.com/mastra-ai/mastra/commit/38ff787998d56210cfd938439af0fea68703a196), [`929a728`](https://github.com/mastra-ai/mastra/commit/929a7281d411ac515e0befb53a5383741b06d484), [`1fc075a`](https://github.com/mastra-ai/mastra/commit/1fc075ab7f7eddca854512d21149db8212f422eb), [`1fc075a`](https://github.com/mastra-ai/mastra/commit/1fc075ab7f7eddca854512d21149db8212f422eb), [`a5a9179`](https://github.com/mastra-ai/mastra/commit/a5a9179daa5ac1ed49447265038208c9f96cd0f8), [`38ff787`](https://github.com/mastra-ai/mastra/commit/38ff787998d56210cfd938439af0fea68703a196), [`52db47c`](https://github.com/mastra-ai/mastra/commit/52db47cd0d66f891d41a2dbfa36e55b640a30a37), [`8e1247c`](https://github.com/mastra-ai/mastra/commit/8e1247cb26fc1a3cd1c2ac6edaf34fddad897852), [`a984dd2`](https://github.com/mastra-ai/mastra/commit/a984dd2f178a494ee26f05f399890f2147d988ed), [`ed76bdc`](https://github.com/mastra-ai/mastra/commit/ed76bdcc88e09c0f7f0da14ffadca62b1b4a2409), [`bc2d5bd`](https://github.com/mastra-ai/mastra/commit/bc2d5bd1064eebd4f4d1b39a725baec0cefc2a0f), [`2f655e5`](https://github.com/mastra-ai/mastra/commit/2f655e53fcae10a2423e0194a113ce52e70580fe), [`ac953f0`](https://github.com/mastra-ai/mastra/commit/ac953f08a74d063ce0e8d2368b36556f715b1fb0), [`ca04e2c`](https://github.com/mastra-ai/mastra/commit/ca04e2cbb6f5ae13edf006905d9810434b4163fe), [`9ffb79b`](https://github.com/mastra-ai/mastra/commit/9ffb79b17e6ed0f0ec6bd1640218ef2a5fb7c058), [`0d7d5cb`](https://github.com/mastra-ai/mastra/commit/0d7d5cbdccacc0b03697b3400579ea520e382061), [`155e3ac`](https://github.com/mastra-ai/mastra/commit/155e3aca3e57114ce3393bd88f6848c29f37c82b), [`be5c929`](https://github.com/mastra-ai/mastra/commit/be5c9292ac6d4beb7f1020d0dc745edd18842f3d), [`7adffbb`](https://github.com/mastra-ai/mastra/commit/7adffbb3df2f734b59648dcf8d461e7af8d1f914), [`e39aa42`](https://github.com/mastra-ai/mastra/commit/e39aa4237c81a2eb546a899c9739c96d6359737f), [`0d7d5cb`](https://github.com/mastra-ai/mastra/commit/0d7d5cbdccacc0b03697b3400579ea520e382061), [`2afea6f`](https://github.com/mastra-ai/mastra/commit/2afea6f00bdb4da7a336be9f8ee79f449ed815a6), [`7c20f00`](https://github.com/mastra-ai/mastra/commit/7c20f008c84db8f4f49e6e95d6dc965482bb2039), [`e20bbd0`](https://github.com/mastra-ai/mastra/commit/e20bbd0ef40475bda611ddfd8ea2721ddac3642c), [`c9ff73d`](https://github.com/mastra-ai/mastra/commit/c9ff73dd24e9473cb0008857105367c99ba839cb), [`f51a29e`](https://github.com/mastra-ai/mastra/commit/f51a29e82b6e2371b5c6aed46141ce20f099c9a9), [`7d58088`](https://github.com/mastra-ai/mastra/commit/7d580884fbf1fb5d90e0761272e2480ed01da70f), [`4ad204d`](https://github.com/mastra-ai/mastra/commit/4ad204dc5bdde76dca26cb7d87c48dd11f97316d), [`f5ebbf3`](https://github.com/mastra-ai/mastra/commit/f5ebbf3b2dc935b8fc068996b4db478815f05bd5), [`decd0a0`](https://github.com/mastra-ai/mastra/commit/decd0a0066286996a4558f63e91a8edfa1143feb), [`e56f88e`](https://github.com/mastra-ai/mastra/commit/e56f88e18d906635b033173abcae637cf361ce8a), [`cd4722a`](https://github.com/mastra-ai/mastra/commit/cd4722a583a0eb75022b1da6a6f8210f8126e486), [`db2a1a6`](https://github.com/mastra-ai/mastra/commit/db2a1a659ecb057ae9ff6798a501ed33dd38b7c7), [`6a4a607`](https://github.com/mastra-ai/mastra/commit/6a4a607e710000e46790e20f28c2355af9ca2a05), [`2499c00`](https://github.com/mastra-ai/mastra/commit/2499c00181520cf7cda756729dc0e0085b85454f), [`de53c27`](https://github.com/mastra-ai/mastra/commit/de53c27a70dbd0c362384691459648043edbee72), [`de53c27`](https://github.com/mastra-ai/mastra/commit/de53c27a70dbd0c362384691459648043edbee72), [`015c7db`](https://github.com/mastra-ai/mastra/commit/015c7db2acf5c0e364195831c3de2bcc376474fe), [`d580530`](https://github.com/mastra-ai/mastra/commit/d580530ff36d43e752b1f838b3f8e16017e8f92b), [`a6077b7`](https://github.com/mastra-ai/mastra/commit/a6077b7f61bde8d302f20b54a2dced2d969887aa), [`5bd713b`](https://github.com/mastra-ai/mastra/commit/5bd713b4f2ca7769675d949f8052943807c11598), [`5c0a994`](https://github.com/mastra-ai/mastra/commit/5c0a99438ef82cf5584218f250a023371bab3373), [`d3f5000`](https://github.com/mastra-ai/mastra/commit/d3f500024f7b0c107c3786757b3f5481f029d061), [`682ebf6`](https://github.com/mastra-ai/mastra/commit/682ebf6b6f867224acbcb021fc142b902738ad07), [`11c83d5`](https://github.com/mastra-ai/mastra/commit/11c83d53331588e06623d5d4a35baa606bbaa424), [`dd6205e`](https://github.com/mastra-ai/mastra/commit/dd6205e985e5fd76b59d000076ab199143c989eb), [`97ade4e`](https://github.com/mastra-ai/mastra/commit/97ade4e8621a9afd01a1f38b921519ddc3086568), [`4d7ecb2`](https://github.com/mastra-ai/mastra/commit/4d7ecb26cdc28be5a385b58f78fca42dbb2c4e31), [`c8b8e27`](https://github.com/mastra-ai/mastra/commit/c8b8e27e9b26d9a08bc61d2e663804f25ae4fa2d), [`8ae87fa`](https://github.com/mastra-ai/mastra/commit/8ae87fadd01daa128086e015473881bf55d6e47b), [`75de514`](https://github.com/mastra-ai/mastra/commit/75de5143ee07764b5958e70eef0facd7750b03ea), [`fe73073`](https://github.com/mastra-ai/mastra/commit/fe73073027b4884d1a301e6d6cc4f0bf168b43ae), [`2ca9e35`](https://github.com/mastra-ai/mastra/commit/2ca9e3522f117cc12fee7a9dad2f5961cd41164e), [`d1aee64`](https://github.com/mastra-ai/mastra/commit/d1aee64e65968744c118440d2d01eb4fba3616d6), [`20f40eb`](https://github.com/mastra-ai/mastra/commit/20f40ebf5623b059336f4c3000d47755941b4451), [`7adffbb`](https://github.com/mastra-ai/mastra/commit/7adffbb3df2f734b59648dcf8d461e7af8d1f914), [`e718b91`](https://github.com/mastra-ai/mastra/commit/e718b91a64eb720cd755b7fd78255d0ab5a412de), [`9a9085e`](https://github.com/mastra-ai/mastra/commit/9a9085ef3481c31093152ea9976759c72dc3fd89), [`35806cb`](https://github.com/mastra-ai/mastra/commit/35806cb9b62dfed212b238d00148341d8b2f68ac), [`2fed0ad`](https://github.com/mastra-ai/mastra/commit/2fed0ad258322811ea7f2107f1121c6d5dee1c59), [`823a389`](https://github.com/mastra-ai/mastra/commit/823a3890deb5cf14484fd655c8360df4c41c4aed), [`6fea510`](https://github.com/mastra-ai/mastra/commit/6fea51000dfc4f249993a7d3959ad41ca6c422ca), [`9a83d42`](https://github.com/mastra-ai/mastra/commit/9a83d42b2461dd1629021d05704939b641330d5b), [`703b0a1`](https://github.com/mastra-ai/mastra/commit/703b0a1cb342d3a6fce72b5b07685fbb31695674), [`bfce5b6`](https://github.com/mastra-ai/mastra/commit/bfce5b6982dc17a6944484b1ee9b333f6f5023d6), [`95c6e7c`](https://github.com/mastra-ai/mastra/commit/95c6e7caf4929d941f958e3f146b551e25eaeef3), [`2447071`](https://github.com/mastra-ai/mastra/commit/2447071b11d7a5f159e6dc726eb5df0aa0db69da), [`ff35b8c`](https://github.com/mastra-ai/mastra/commit/ff35b8c3d86136509d31b87fed7f789a572dc1af), [`59421d0`](https://github.com/mastra-ai/mastra/commit/59421d0137a0642c60b687567e33bf2358be4c64), [`501b207`](https://github.com/mastra-ai/mastra/commit/501b207b1b6300af44b5b8f40ff33adfe7a9d195), [`3143101`](https://github.com/mastra-ai/mastra/commit/31431019ddd56d0b5677f8cd169f715f0e907266), [`2829b0e`](https://github.com/mastra-ai/mastra/commit/2829b0eae687d36c8f864eba4051225ae3b82343), [`e053569`](https://github.com/mastra-ai/mastra/commit/e05356995ee8c807516d8aff836a8363dba7eee6), [`d9245dd`](https://github.com/mastra-ai/mastra/commit/d9245dd486349163bfc6468ab45e5600abc6a59e), [`ab1727d`](https://github.com/mastra-ai/mastra/commit/ab1727d5cafb64e36b04fad9f8871dc6640d2420), [`4fc17c6`](https://github.com/mastra-ai/mastra/commit/4fc17c65e85628a71201bf7490fca1db8376cf71), [`a9ad47d`](https://github.com/mastra-ai/mastra/commit/a9ad47d8c3186e51142b9c1a3ed1e8e29ade2338), [`358c711`](https://github.com/mastra-ai/mastra/commit/358c71145d677394ce03a019156bc464afe6cc76), [`dbdfaee`](https://github.com/mastra-ai/mastra/commit/dbdfaee279dab2a5dca31134ca1967eb582e639c), [`cf0ca8b`](https://github.com/mastra-ai/mastra/commit/cf0ca8b55d67a3ccf6ee7835e4dd2addea0c82a8), [`2ded35c`](https://github.com/mastra-ai/mastra/commit/2ded35cb0c97b26f641a9eb9a5747d32164d45c9), [`875a657`](https://github.com/mastra-ai/mastra/commit/875a65748d5e03b436bab01d7f9fe782fa2941e7), [`d3e8ec7`](https://github.com/mastra-ai/mastra/commit/d3e8ec74e90bedefc28414e459ec9c5d52c97ccc), [`ddb7721`](https://github.com/mastra-ai/mastra/commit/ddb77211bc797c45fe434baac5c44c4193c1381e), [`d1aee64`](https://github.com/mastra-ai/mastra/commit/d1aee64e65968744c118440d2d01eb4fba3616d6), [`72487ba`](https://github.com/mastra-ai/mastra/commit/72487ba7498b6c7935c995dfb1877ffc1b9950c8), [`38ff787`](https://github.com/mastra-ai/mastra/commit/38ff787998d56210cfd938439af0fea68703a196), [`1fc075a`](https://github.com/mastra-ai/mastra/commit/1fc075ab7f7eddca854512d21149db8212f422eb), [`d58fe2a`](https://github.com/mastra-ai/mastra/commit/d58fe2ac5cd64a96dca05657f07df18f23db14e1), [`7662736`](https://github.com/mastra-ai/mastra/commit/7662736615043b8f4d0d2e7277094936ff2c88d6), [`5e88354`](https://github.com/mastra-ai/mastra/commit/5e883545edd6082e741cdce1d192e0e83fa5dc2e), [`5bb592a`](https://github.com/mastra-ai/mastra/commit/5bb592a862869d529d8d6ca48772cd0e1863f224), [`bd508a2`](https://github.com/mastra-ai/mastra/commit/bd508a2dec8c550baec245bfffc2d0853386e2eb), [`6f5eadb`](https://github.com/mastra-ai/mastra/commit/6f5eadbf7744a48ee742b940455e969922c3277d), [`578cb67`](https://github.com/mastra-ai/mastra/commit/578cb670bd8621538eda4afc1f25139e5903aab9), [`4278b9d`](https://github.com/mastra-ai/mastra/commit/4278b9dfb8aef7f274e4dfb102597cc0400475ee), [`2ac8cf1`](https://github.com/mastra-ai/mastra/commit/2ac8cf1435ba3abae9dba7b6c34f1c02f75eab21), [`1283717`](https://github.com/mastra-ai/mastra/commit/1283717ecfc652da293aafe6ff582afa07ca84a5), [`875a657`](https://github.com/mastra-ai/mastra/commit/875a65748d5e03b436bab01d7f9fe782fa2941e7), [`2b9f9a5`](https://github.com/mastra-ai/mastra/commit/2b9f9a55799ee7a6020a063d2419096429254481), [`307b711`](https://github.com/mastra-ai/mastra/commit/307b711bbe73132f1f319c3326333d49bc23b79d), [`45c1d16`](https://github.com/mastra-ai/mastra/commit/45c1d16c4f0cd3e5b18d2a788fb998c70b45b7c0), [`dc10589`](https://github.com/mastra-ai/mastra/commit/dc1058900dd9be01638d43491ddfd2037da12bac), [`339da0b`](https://github.com/mastra-ai/mastra/commit/339da0bef7e2e5570f533f6b41abbd746190bffb), [`f00e938`](https://github.com/mastra-ai/mastra/commit/f00e938e7d2e78ad1ee414047b7516968ec8cb15), [`34ee1d1`](https://github.com/mastra-ai/mastra/commit/34ee1d16226852f57d1f8bb34ee7a88397e5cce2), [`8c61247`](https://github.com/mastra-ai/mastra/commit/8c6124708341d699c3b1f3bb19f19be468923483), [`a9f392e`](https://github.com/mastra-ai/mastra/commit/a9f392e60e5bc1fab66280314bab5f697e8d7c09), [`fdd2201`](https://github.com/mastra-ai/mastra/commit/fdd22014f6fbfa115eba53cff42063544af2ff41), [`5c56910`](https://github.com/mastra-ai/mastra/commit/5c56910b2647e11cbb6880431e556471b25ba949), [`66da6af`](https://github.com/mastra-ai/mastra/commit/66da6af573224af3daeb8767cddbd6112ad2c5e4), [`b7ff751`](https://github.com/mastra-ai/mastra/commit/b7ff751ed0fd87a3f93ce438c355c2dcc16e79d5), [`0811cda`](https://github.com/mastra-ai/mastra/commit/0811cda8d22476cf1393b429a63aaefa5292048c), [`1e31034`](https://github.com/mastra-ai/mastra/commit/1e31034b30cb9661e38af548dfda646aee74f08f), [`17444a7`](https://github.com/mastra-ai/mastra/commit/17444a7e46b656b3877faad6e61d5637f435b291), [`a7cc444`](https://github.com/mastra-ai/mastra/commit/a7cc44423357eaa1e0a73c63ce28ba08ca2ce85c), [`3cdaaa8`](https://github.com/mastra-ai/mastra/commit/3cdaaa86f48812bdae1077e55be1d58dd5e85fc5), [`3be96ae`](https://github.com/mastra-ai/mastra/commit/3be96ae2f65a2ff3b2189fb79fd03b7eedee3dbe), [`852110d`](https://github.com/mastra-ai/mastra/commit/852110d4eeaf5ab74ea94747343501700033a1e8), [`f3bc1ca`](https://github.com/mastra-ai/mastra/commit/f3bc1caddb161453f8e2636fd0fc96d9b60e2719), [`b63456b`](https://github.com/mastra-ai/mastra/commit/b63456befb5f51d1a2b1288225f02c30738b6099), [`f156ad0`](https://github.com/mastra-ai/mastra/commit/f156ad0b7ed6b0ba286efd9040c061c9240d55c3), [`580452a`](https://github.com/mastra-ai/mastra/commit/580452acbbb9812eae1b31d4f3ded716c348a78b), [`4303017`](https://github.com/mastra-ai/mastra/commit/4303017f393b9c09f692837d8e9e7a19f6539cf4)]:
49
+ - @mastra/core@1.80.0
50
+ - @mastra/mcp@2.6.0
51
+ - @mastra/server@1.80.0
52
+
3
53
  ## 0.2.0-alpha.3
4
54
 
5
55
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -9,4 +9,5 @@ export { createHttpLoggingTestSuite, type HttpLoggingTestSuiteConfig } from './h
9
9
  export { createBodyLimitTestSuite, type BodyLimitTestSuiteConfig } from './body-limit-test-suite.js';
10
10
  export { createCustomRouteFGATestSuite, type CustomRouteFGATestSuiteConfig } from './custom-route-fga-test-suite.js';
11
11
  export { createDefaultTestContext, createStreamWithSensitiveData, createStreamWithUnserializableChunk, expectSerializedStreamChunks, consumeSSEStream, } from './test-helpers.js';
12
+ export { createKnowledgeRoutesTestSuite, type KnowledgeRoutesTestSuiteConfig } from './knowledge-routes-test-suite.js';
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,KAAK,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAC5G,OAAO,EAAE,gCAAgC,EAAE,KAAK,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AACrH,YAAY,EACV,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,WAAW,EACX,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,KAAK,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACtG,OAAO,EAAE,wBAAwB,EAAE,KAAK,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACjG,OAAO,EAAE,0BAA0B,EAAE,KAAK,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACxG,OAAO,EAAE,wBAAwB,EAAE,KAAK,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAClG,OAAO,EAAE,6BAA6B,EAAE,KAAK,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAElH,OAAO,EACL,wBAAwB,EACxB,6BAA6B,EAC7B,mCAAmC,EACnC,4BAA4B,EAC5B,gBAAgB,GACjB,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,KAAK,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAC5G,OAAO,EAAE,gCAAgC,EAAE,KAAK,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AACrH,YAAY,EACV,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,WAAW,EACX,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,KAAK,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACtG,OAAO,EAAE,wBAAwB,EAAE,KAAK,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACjG,OAAO,EAAE,0BAA0B,EAAE,KAAK,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACxG,OAAO,EAAE,wBAAwB,EAAE,KAAK,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAClG,OAAO,EAAE,6BAA6B,EAAE,KAAK,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAElH,OAAO,EACL,wBAAwB,EACxB,6BAA6B,EAC7B,mCAAmC,EACnC,4BAA4B,EAC5B,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,8BAA8B,EAAE,KAAK,8BAA8B,EAAE,MAAM,+BAA+B,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ErrorCategory, ErrorDomain, MastraError } from "@mastra/core/error";
2
2
  import { registerApiRoute } from "@mastra/core/server";
3
3
  import { handleError } from "@mastra/server/handlers/error";
4
- import { HTTPException, SERVER_ROUTES, WorkflowRegistry, createRoute, serializeStreamChunk } from "@mastra/server/server-adapter";
4
+ import { HTTPException, KNOWLEDGE_ROUTES, MASTRA_KNOWLEDGE_PRINCIPALS_KEY, SERVER_ROUTES, WorkflowRegistry, createRoute, serializeStreamChunk } from "@mastra/server/server-adapter";
5
5
  import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
6
6
  import * as zod from "zod";
7
7
  import { z } from "zod";
@@ -32,6 +32,7 @@ import { MCPServerBase } from "@mastra/core/mcp";
32
32
  import { RequestContext } from "@mastra/core/request-context";
33
33
  import { standardSchemaToJSONSchema } from "@mastra/core/schema";
34
34
  import { z as z$2 } from "zod/v4";
35
+ import { Knowledge } from "@mastra/core/knowledge";
35
36
  // src/route-test-utils.ts
36
37
  /**
37
38
  * Normalizes a route path to ensure consistent formatting.
@@ -143,7 +144,7 @@ function generateValidDataFromSchema(schema, fieldName) {
143
144
  if (typeName === "ZodOptional" || typeName === "ZodNullable") return generateValidDataFromSchema(def.innerType, fieldName);
144
145
  if (typeName === "ZodDefault") {
145
146
  if ("_zod" in schema) return def.defaultValue;
146
- else return def.defaultValue();
147
+ return def.defaultValue();
147
148
  }
148
149
  if (typeName === "ZodString") {
149
150
  if ((def.checks ?? []).some((check) => {
@@ -244,16 +245,16 @@ function generateValidDataFromSchema(schema, fieldName) {
244
245
  if (typeName === "ZodBigInt") return 0n;
245
246
  if (typeName === "ZodLiteral") {
246
247
  if ("_zod" in schema) return def.values?.[0];
247
- else return def.value;
248
+ return def.value;
248
249
  }
249
250
  if (typeName === "ZodEnum") {
250
251
  if ("_zod" in schema) return Object.values(def.entries)[0];
251
- else return def.values[0];
252
+ return def.values[0];
252
253
  }
253
254
  if (typeName === "ZodNativeEnum") return Object.values(def.values)[0];
254
255
  if (typeName === "ZodArray") {
255
256
  if ("_zod" in schema) return [generateValidDataFromSchema(def.element, fieldName)];
256
- else return [generateValidDataFromSchema(def.type, fieldName)];
257
+ return [generateValidDataFromSchema(def.type, fieldName)];
257
258
  }
258
259
  if (typeName === "ZodObject") {
259
260
  const shape = typeof def.shape === "function" ? def.shape() : def.shape;
@@ -348,6 +349,7 @@ function getDefaultValidPathParams(route) {
348
349
  if (route.path.includes(":serverId")) params.serverId = "test-server-1";
349
350
  if (route.path.includes(":toolId") && route.path.includes("/mcp/")) params.toolId = "getWeather";
350
351
  if (route.path.includes(":eventName")) params.eventName = "ticket.created";
352
+ if (route.path.includes(":taskKey")) params.taskKey = "test-task-key";
351
353
  if (route.path.includes(":workspaceId")) params.workspaceId = "test-workspace";
352
354
  if (route.path.includes(":skillName")) params.skillName = "test-skill";
353
355
  if (route.path.includes(":referencePath")) params.referencePath = "test-reference.md";
@@ -2168,6 +2170,9 @@ function createRouteAdapterTestSuite(config) {
2168
2170
  "/background-tasks/stream",
2169
2171
  "/agents/:agentId/observe",
2170
2172
  "/mcp/:serverId/events/:eventName/stream",
2173
+ "/mcp/:serverId/tasks/find",
2174
+ "/mcp/:serverId/tasks/:taskKey/cancel",
2175
+ "/mcp/:serverId/tasks/:taskKey/input",
2171
2176
  "/agents/:agentId/recover",
2172
2177
  "/agents/:agentId/runs/:runId/abort",
2173
2178
  "/agents/:agentId/plans/file",
@@ -5632,6 +5637,103 @@ function createCustomRouteFGATestSuite(config) {
5632
5637
  });
5633
5638
  });
5634
5639
  }
5635
- export { consumeSSEStream, createBodyLimitTestSuite, createCustomRouteFGATestSuite, createDefaultTestContext, createDurableDisconnectTestSuite, createHttpLoggingTestSuite, createMCPRouteTestSuite, createMCPTransportTestSuite, createMultipartTestSuite, createRouteAdapterTestSuite, createStreamWithSensitiveData, createStreamWithUnserializableChunk, createStructuredWakeTestSuite, expectSerializedStreamChunks };
5640
+ // src/knowledge-routes-test-suite.ts
5641
+ /**
5642
+ * The opt-in Knowledge routes on every adapter: RBAC `knowledge:read` gates them, the Knowledge principals
5643
+ * `authorize` sets through `context.get('requestContext')` reach the handler (no mapping is refused), and a
5644
+ * repeated query param (`scopeId`) arrives as a list.
5645
+ */
5646
+ function createKnowledgeRoutesTestSuite(config) {
5647
+ const { suiteName = "Knowledge routes", startServer } = config;
5648
+ describe(suiteName, () => {
5649
+ let close;
5650
+ afterEach(async () => {
5651
+ await close?.();
5652
+ close = void 0;
5653
+ });
5654
+ const setup = async () => {
5655
+ const knowledge = new Knowledge({
5656
+ id: "kb",
5657
+ scopes: {},
5658
+ storage: new InMemoryStore({ id: "kb" })
5659
+ });
5660
+ const store = await knowledge.getStorage();
5661
+ const provenance = { author: "test" };
5662
+ const scopes = {};
5663
+ for (const [team, page] of [
5664
+ ["support", "Payments runbook"],
5665
+ ["eng", "Payments service"],
5666
+ ["sales", "Payments pricing"]
5667
+ ]) {
5668
+ const { scope } = await store.materializeScope({
5669
+ address: `team:${team}`,
5670
+ declaration: "team:$teamId",
5671
+ name: team,
5672
+ provenance
5673
+ });
5674
+ scopes[team] = scope.id;
5675
+ await store.createPage({
5676
+ parentId: scope.id,
5677
+ name: page,
5678
+ provenance
5679
+ });
5680
+ }
5681
+ const permissions = {
5682
+ "reader-token": ["knowledge:read"],
5683
+ "unmapped-token": ["knowledge:read"],
5684
+ "other-token": []
5685
+ };
5686
+ const mastra = new Mastra({
5687
+ logger: false,
5688
+ knowledge: { main: knowledge },
5689
+ server: { apiRoutes: [...KNOWLEDGE_ROUTES] }
5690
+ });
5691
+ const originalGetServer = mastra.getServer.bind(mastra);
5692
+ mastra.getServer = () => ({
5693
+ ...originalGetServer(),
5694
+ rbac: {
5695
+ getRoles: async () => ["member"],
5696
+ getPermissions: async (user) => permissions[user.id] ?? []
5697
+ },
5698
+ auth: {
5699
+ authenticateToken: async (token) => token in permissions ? { id: token } : null,
5700
+ authorize: async (_path, _method, user, context) => {
5701
+ if (user.id === "reader-token") context.get("requestContext").set(MASTRA_KNOWLEDGE_PRINCIPALS_KEY, "all");
5702
+ return true;
5703
+ }
5704
+ }
5705
+ });
5706
+ const server = await startServer(mastra);
5707
+ close = server.close;
5708
+ const get = (path, token) => server.request(`/api/knowledge/main${path}`, token ? { headers: { authorization: `Bearer ${token}` } } : {});
5709
+ return {
5710
+ get,
5711
+ scopes
5712
+ };
5713
+ };
5714
+ it("serves a reader authorize mapped to Knowledge principals and refuses everyone else", async () => {
5715
+ const { get } = await setup();
5716
+ const roots = await get("/tree", "reader-token");
5717
+ expect(roots.status).toBe(200);
5718
+ const body = await roots.json();
5719
+ expect(body.pages.map((page) => page.name).sort()).toEqual([
5720
+ "eng",
5721
+ "sales",
5722
+ "support"
5723
+ ]);
5724
+ expect((await get("/tree", "unmapped-token")).status).toBe(403);
5725
+ expect((await get("/tree", "other-token")).status).toBe(403);
5726
+ expect((await get("/tree")).status).toBe(401);
5727
+ });
5728
+ it("reads a repeated scopeId param as a list", async () => {
5729
+ const { get, scopes } = await setup();
5730
+ const res = await get(`/search?q=payments&scopeId=${scopes.support}&scopeId=${scopes.eng}`, "reader-token");
5731
+ expect(res.status).toBe(200);
5732
+ const body = await res.json();
5733
+ expect(body.results.map((hit) => hit.page.name).sort()).toEqual(["Payments runbook", "Payments service"]);
5734
+ });
5735
+ });
5736
+ }
5737
+ export { consumeSSEStream, createBodyLimitTestSuite, createCustomRouteFGATestSuite, createDefaultTestContext, createDurableDisconnectTestSuite, createHttpLoggingTestSuite, createKnowledgeRoutesTestSuite, createMCPRouteTestSuite, createMCPTransportTestSuite, createMultipartTestSuite, createRouteAdapterTestSuite, createStreamWithSensitiveData, createStreamWithUnserializableChunk, createStructuredWakeTestSuite, expectSerializedStreamChunks };
5636
5738
 
5637
5739
  //# sourceMappingURL=index.js.map