@mastra/server 1.0.0-beta.2 → 1.0.0-beta.20
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 +691 -0
- package/README.md +2 -2
- package/dist/chunk-3MN73W4B.cjs +326 -0
- package/dist/chunk-3MN73W4B.cjs.map +1 -0
- package/dist/chunk-3OUPQHSX.js +314 -0
- package/dist/chunk-3OUPQHSX.js.map +1 -0
- package/dist/chunk-3PZVR6W3.cjs +1117 -0
- package/dist/chunk-3PZVR6W3.cjs.map +1 -0
- package/dist/{chunk-SHWNNZBL.js → chunk-3REGEJEN.js} +13 -17
- package/dist/chunk-3REGEJEN.js.map +1 -0
- package/dist/chunk-3W67K7YE.js +13 -0
- package/dist/chunk-3W67K7YE.js.map +1 -0
- package/dist/chunk-4EYONQIW.cjs +82 -0
- package/dist/chunk-4EYONQIW.cjs.map +1 -0
- package/dist/chunk-5NFRDYFN.js +77 -0
- package/dist/chunk-5NFRDYFN.js.map +1 -0
- package/dist/chunk-5NXQ6QXL.js +116 -0
- package/dist/chunk-5NXQ6QXL.js.map +1 -0
- package/dist/chunk-5W4RPVTK.cjs +49 -0
- package/dist/chunk-5W4RPVTK.cjs.map +1 -0
- package/dist/chunk-6HKMJXTF.js +234 -0
- package/dist/chunk-6HKMJXTF.js.map +1 -0
- package/dist/{chunk-2PLXW4ZX.cjs → chunk-AQI6GLTN.cjs} +74 -74
- package/dist/{chunk-2PLXW4ZX.cjs.map → chunk-AQI6GLTN.cjs.map} +1 -1
- package/dist/chunk-AVOFMAUS.cjs +125 -0
- package/dist/chunk-AVOFMAUS.cjs.map +1 -0
- package/dist/chunk-B35F4QEM.cjs +346 -0
- package/dist/chunk-B35F4QEM.cjs.map +1 -0
- package/dist/chunk-DUZRZLVR.js +302 -0
- package/dist/chunk-DUZRZLVR.js.map +1 -0
- package/dist/chunk-DVSCJECS.js +250 -0
- package/dist/chunk-DVSCJECS.js.map +1 -0
- package/dist/chunk-EUBTCHQC.js +83 -0
- package/dist/chunk-EUBTCHQC.js.map +1 -0
- package/dist/chunk-FEEM6QFN.js +219 -0
- package/dist/chunk-FEEM6QFN.js.map +1 -0
- package/dist/chunk-FWSKVWS7.cjs +88 -0
- package/dist/chunk-FWSKVWS7.cjs.map +1 -0
- package/dist/chunk-G2AMUTU4.js +250 -0
- package/dist/chunk-G2AMUTU4.js.map +1 -0
- package/dist/chunk-G3KUL3RL.cjs +211 -0
- package/dist/chunk-G3KUL3RL.cjs.map +1 -0
- package/dist/{chunk-W2KMU354.cjs → chunk-GWLR6K3H.cjs} +23 -4
- package/dist/chunk-GWLR6K3H.cjs.map +1 -0
- package/dist/{chunk-RQK4FQUD.js → chunk-H66LLFDL.js} +4 -46
- package/dist/chunk-H66LLFDL.js.map +1 -0
- package/dist/chunk-HT4LP3BO.js +75 -0
- package/dist/chunk-HT4LP3BO.js.map +1 -0
- package/dist/chunk-IMPZBQ5U.cjs +33025 -0
- package/dist/chunk-IMPZBQ5U.cjs.map +1 -0
- package/dist/chunk-IQEVRCM6.cjs +205 -0
- package/dist/chunk-IQEVRCM6.cjs.map +1 -0
- package/dist/{chunk-FPBYKMIS.js → chunk-J6DCK7KG.js} +222 -30
- package/dist/chunk-J6DCK7KG.js.map +1 -0
- package/dist/chunk-JQPDZZLI.js +1018 -0
- package/dist/chunk-JQPDZZLI.js.map +1 -0
- package/dist/chunk-JXPRNYUC.js +279 -0
- package/dist/chunk-JXPRNYUC.js.map +1 -0
- package/dist/chunk-K3LMK4KU.js +180 -0
- package/dist/chunk-K3LMK4KU.js.map +1 -0
- package/dist/chunk-KEW7MXUS.cjs +312 -0
- package/dist/chunk-KEW7MXUS.cjs.map +1 -0
- package/dist/chunk-KXYDJIKD.cjs +1048 -0
- package/dist/chunk-KXYDJIKD.cjs.map +1 -0
- package/dist/{chunk-QU6N55W6.cjs → chunk-L2E5RUVT.cjs} +17 -21
- package/dist/chunk-L2E5RUVT.cjs.map +1 -0
- package/dist/chunk-L7ZFPOGS.js +44 -0
- package/dist/chunk-L7ZFPOGS.js.map +1 -0
- package/dist/chunk-LJ6YRVDI.cjs +15 -0
- package/dist/chunk-LJ6YRVDI.cjs.map +1 -0
- package/dist/{chunk-ZULZ2752.js → chunk-LOA7RQYO.js} +3 -3
- package/dist/{chunk-ZULZ2752.js.map → chunk-LOA7RQYO.js.map} +1 -1
- package/dist/chunk-MCYD5LW7.cjs +90 -0
- package/dist/chunk-MCYD5LW7.cjs.map +1 -0
- package/dist/chunk-OKURLPIJ.js +32986 -0
- package/dist/chunk-OKURLPIJ.js.map +1 -0
- package/dist/{chunk-UXGQZUYZ.js → chunk-ONN5EA7E.js} +13 -3
- package/dist/chunk-ONN5EA7E.js.map +1 -0
- package/dist/chunk-P3H4AZKI.cjs +252 -0
- package/dist/chunk-P3H4AZKI.cjs.map +1 -0
- package/dist/chunk-PNZQCQY4.cjs +252 -0
- package/dist/chunk-PNZQCQY4.cjs.map +1 -0
- package/dist/chunk-Q4BOUQ2O.js +1075 -0
- package/dist/chunk-Q4BOUQ2O.js.map +1 -0
- package/dist/{chunk-D7T74TVR.js → chunk-QKXZF7YS.js} +23 -4
- package/dist/chunk-QKXZF7YS.js.map +1 -0
- package/dist/chunk-R25YJP3Y.cjs +269 -0
- package/dist/chunk-R25YJP3Y.cjs.map +1 -0
- package/dist/chunk-SEP5QUTR.js +196 -0
- package/dist/chunk-SEP5QUTR.js.map +1 -0
- package/dist/{chunk-V5WWQN7P.cjs → chunk-SUKFO7UM.cjs} +13 -2
- package/dist/chunk-SUKFO7UM.cjs.map +1 -0
- package/dist/chunk-T3ZHTCEI.cjs +928 -0
- package/dist/chunk-T3ZHTCEI.cjs.map +1 -0
- package/dist/chunk-T4SPG2GP.cjs +82 -0
- package/dist/chunk-T4SPG2GP.cjs.map +1 -0
- package/dist/chunk-TOGG5Q45.js +328 -0
- package/dist/chunk-TOGG5Q45.js.map +1 -0
- package/dist/chunk-UKRDDBXY.cjs +225 -0
- package/dist/chunk-UKRDDBXY.cjs.map +1 -0
- package/dist/chunk-V3RILBZM.cjs +186 -0
- package/dist/chunk-V3RILBZM.cjs.map +1 -0
- package/dist/chunk-VJNZJAIO.cjs +289 -0
- package/dist/chunk-VJNZJAIO.cjs.map +1 -0
- package/dist/{chunk-LPM6BBAX.cjs → chunk-VX3VN7FN.cjs} +3 -54
- package/dist/chunk-VX3VN7FN.cjs.map +1 -0
- package/dist/chunk-X5KAQFOV.js +204 -0
- package/dist/chunk-X5KAQFOV.js.map +1 -0
- package/dist/chunk-XAVPSRSG.cjs +46 -0
- package/dist/chunk-XAVPSRSG.cjs.map +1 -0
- package/dist/chunk-XOUK3IYU.js +77 -0
- package/dist/chunk-XOUK3IYU.js.map +1 -0
- package/dist/chunk-XWGAT2DA.js +44 -0
- package/dist/chunk-XWGAT2DA.js.map +1 -0
- package/dist/{chunk-KJIDZQRA.cjs → chunk-Y3VSCOCE.cjs} +228 -30
- package/dist/chunk-Y3VSCOCE.cjs.map +1 -0
- package/dist/chunk-ZRBZESWG.js +903 -0
- package/dist/chunk-ZRBZESWG.js.map +1 -0
- package/dist/{dist-G2BYZJOC.cjs → dist-7NTDEVLP.cjs} +28 -28
- package/dist/{dist-G2BYZJOC.cjs.map → dist-7NTDEVLP.cjs.map} +1 -1
- package/dist/{dist-X7XR3M3Z.js → dist-B5GMANA6.js} +3 -3
- package/dist/{dist-X7XR3M3Z.js.map → dist-B5GMANA6.js.map} +1 -1
- package/dist/dist-EDO7GEGI.js +3 -0
- package/dist/{dist-YREX2TJT.js.map → dist-EDO7GEGI.js.map} +1 -1
- package/dist/{dist-RFMYFILX.cjs → dist-OF24ZMHH.cjs} +30 -30
- package/dist/{dist-RFMYFILX.cjs.map → dist-OF24ZMHH.cjs.map} +1 -1
- package/dist/{dist-4MVGNSRL.cjs → dist-P6YSNLL3.cjs} +20 -20
- package/dist/{dist-4MVGNSRL.cjs.map → dist-P6YSNLL3.cjs.map} +1 -1
- package/dist/{dist-PQZUVLPC.js → dist-SMBO5KVB.js} +3 -3
- package/dist/{dist-PQZUVLPC.js.map → dist-SMBO5KVB.js.map} +1 -1
- package/dist/{dist-XVBSOGFK.js → dist-THPMW5QR.js} +3 -3
- package/dist/{dist-XVBSOGFK.js.map → dist-THPMW5QR.js.map} +1 -1
- package/dist/{dist-FZYCV3VB.cjs → dist-VZTG56X2.cjs} +26 -26
- package/dist/{dist-FZYCV3VB.cjs.map → dist-VZTG56X2.cjs.map} +1 -1
- package/dist/dist-ZLC23RVC.cjs +16 -0
- package/dist/{dist-P4MXBQ3U.cjs.map → dist-ZLC23RVC.cjs.map} +1 -1
- package/dist/{dist-R7WYX6LC.js → dist-ZOZ6MHJH.js} +3 -3
- package/dist/{dist-R7WYX6LC.js.map → dist-ZOZ6MHJH.js.map} +1 -1
- package/dist/docs/README.md +31 -0
- package/dist/docs/SKILL.md +32 -0
- package/dist/docs/SOURCE_MAP.json +6 -0
- package/dist/docs/server/01-custom-adapters.md +377 -0
- package/dist/docs/server/02-reference.md +828 -0
- package/dist/server/auth/defaults.d.ts +3 -0
- package/dist/server/auth/defaults.d.ts.map +1 -0
- package/dist/server/auth/helpers.d.ts +14 -0
- package/dist/server/auth/helpers.d.ts.map +1 -0
- package/dist/server/auth/index.cjs +137 -0
- package/dist/server/auth/index.cjs.map +1 -0
- package/dist/server/auth/index.d.ts +3 -0
- package/dist/server/auth/index.d.ts.map +1 -0
- package/dist/server/auth/index.js +127 -0
- package/dist/server/auth/index.js.map +1 -0
- package/dist/server/handlers/a2a.cjs +15 -7
- package/dist/server/handlers/a2a.d.ts +482 -0
- package/dist/server/handlers/a2a.d.ts.map +1 -1
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +31 -43
- package/dist/server/handlers/agent-builder.d.ts +624 -77
- package/dist/server/handlers/agent-builder.d.ts.map +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agents.cjs +57 -37
- package/dist/server/handlers/agents.d.ts +3296 -131
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/error.cjs +6 -2
- package/dist/server/handlers/error.d.ts +12 -0
- package/dist/server/handlers/error.d.ts.map +1 -1
- package/dist/server/handlers/error.js +1 -1
- package/dist/server/handlers/logs.cjs +7 -7
- package/dist/server/handlers/logs.d.ts +135 -27
- package/dist/server/handlers/logs.d.ts.map +1 -1
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/mcp.cjs +40 -0
- package/dist/server/handlers/mcp.cjs.map +1 -0
- package/dist/server/handlers/mcp.d.ts +110 -0
- package/dist/server/handlers/mcp.d.ts.map +1 -0
- package/dist/server/handlers/mcp.js +3 -0
- package/dist/server/handlers/mcp.js.map +1 -0
- package/dist/server/handlers/memory.cjs +71 -27
- package/dist/server/handlers/memory.d.ts +1016 -95
- package/dist/server/handlers/memory.d.ts.map +1 -1
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/observability.cjs +9 -9
- package/dist/server/handlers/observability.d.ts +146 -42
- package/dist/server/handlers/observability.d.ts.map +1 -1
- package/dist/server/handlers/observability.js +1 -1
- package/dist/server/handlers/scores.cjs +13 -13
- package/dist/server/handlers/scores.d.ts +110 -141
- package/dist/server/handlers/scores.d.ts.map +1 -1
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/stored-agents.cjs +28 -0
- package/dist/server/handlers/stored-agents.cjs.map +1 -0
- package/dist/server/handlers/stored-agents.d.ts +289 -0
- package/dist/server/handlers/stored-agents.d.ts.map +1 -0
- package/dist/server/handlers/stored-agents.js +3 -0
- package/dist/server/handlers/stored-agents.js.map +1 -0
- package/dist/server/handlers/system.cjs +12 -0
- package/dist/server/handlers/system.cjs.map +1 -0
- package/dist/server/handlers/system.d.ts +7 -0
- package/dist/server/handlers/system.d.ts.map +1 -0
- package/dist/server/handlers/system.js +3 -0
- package/dist/server/handlers/system.js.map +1 -0
- package/dist/server/handlers/test-utils.cjs +15 -0
- package/dist/server/handlers/test-utils.cjs.map +1 -0
- package/dist/server/handlers/test-utils.d.ts +6 -0
- package/dist/server/handlers/test-utils.d.ts.map +1 -0
- package/dist/server/handlers/test-utils.js +13 -0
- package/dist/server/handlers/test-utils.js.map +1 -0
- package/dist/server/handlers/tools.cjs +11 -11
- package/dist/server/handlers/tools.d.ts +69 -23
- package/dist/server/handlers/tools.d.ts.map +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +11 -3
- package/dist/server/handlers/utils.d.ts +5 -0
- package/dist/server/handlers/utils.d.ts.map +1 -1
- package/dist/server/handlers/utils.js +1 -1
- package/dist/server/handlers/vector.cjs +31 -7
- package/dist/server/handlers/vector.d.ts +93 -9
- package/dist/server/handlers/vector.d.ts.map +1 -1
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +21 -9
- package/dist/server/handlers/voice.d.ts +81 -40
- package/dist/server/handlers/voice.d.ts.map +1 -1
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +57 -37
- package/dist/server/handlers/workflows.d.ts +980 -74
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +36 -31
- package/dist/server/handlers.d.ts +1 -0
- package/dist/server/handlers.d.ts.map +1 -1
- package/dist/server/handlers.js +12 -11
- package/dist/server/schemas/a2a.d.ts +786 -0
- package/dist/server/schemas/a2a.d.ts.map +1 -0
- package/dist/server/schemas/agent-builder.d.ts +225 -0
- package/dist/server/schemas/agent-builder.d.ts.map +1 -0
- package/dist/server/schemas/agents.d.ts +1401 -0
- package/dist/server/schemas/agents.d.ts.map +1 -0
- package/dist/server/schemas/common.d.ts +179 -0
- package/dist/server/schemas/common.d.ts.map +1 -0
- package/dist/server/schemas/logs.d.ts +124 -0
- package/dist/server/schemas/logs.d.ts.map +1 -0
- package/dist/server/schemas/mcp.d.ts +299 -0
- package/dist/server/schemas/mcp.d.ts.map +1 -0
- package/dist/server/schemas/memory.d.ts +1128 -0
- package/dist/server/schemas/memory.d.ts.map +1 -0
- package/dist/server/schemas/scores.d.ts +259 -0
- package/dist/server/schemas/scores.d.ts.map +1 -0
- package/dist/server/schemas/stored-agents.d.ts +792 -0
- package/dist/server/schemas/stored-agents.d.ts.map +1 -0
- package/dist/server/schemas/system.d.ts +36 -0
- package/dist/server/schemas/system.d.ts.map +1 -0
- package/dist/server/schemas/vectors.d.ts +107 -0
- package/dist/server/schemas/vectors.d.ts.map +1 -0
- package/dist/server/schemas/workflows.d.ts +863 -0
- package/dist/server/schemas/workflows.d.ts.map +1 -0
- package/dist/server/server-adapter/index.cjs +510 -0
- package/dist/server/server-adapter/index.cjs.map +1 -0
- package/dist/server/server-adapter/index.d.ts +109 -0
- package/dist/server/server-adapter/index.d.ts.map +1 -0
- package/dist/server/server-adapter/index.js +482 -0
- package/dist/server/server-adapter/index.js.map +1 -0
- package/dist/server/server-adapter/openapi-utils.d.ts +59 -0
- package/dist/server/server-adapter/openapi-utils.d.ts.map +1 -0
- package/dist/server/server-adapter/redact.d.ts +26 -0
- package/dist/server/server-adapter/redact.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/a2a.d.ts +3 -0
- package/dist/server/server-adapter/routes/a2a.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/agent-builder.d.ts +3 -0
- package/dist/server/server-adapter/routes/agent-builder.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/agents.d.ts +3 -0
- package/dist/server/server-adapter/routes/agents.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/index.d.ts +50 -0
- package/dist/server/server-adapter/routes/index.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/legacy.d.ts +7 -0
- package/dist/server/server-adapter/routes/legacy.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/logs.d.ts +3 -0
- package/dist/server/server-adapter/routes/logs.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/mcp.d.ts +9 -0
- package/dist/server/server-adapter/routes/mcp.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/memory.d.ts +3 -0
- package/dist/server/server-adapter/routes/memory.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/observability.d.ts +3 -0
- package/dist/server/server-adapter/routes/observability.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/route-builder.d.ts +111 -0
- package/dist/server/server-adapter/routes/route-builder.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/scorers.d.ts +3 -0
- package/dist/server/server-adapter/routes/scorers.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/stored-agents.d.ts +8 -0
- package/dist/server/server-adapter/routes/stored-agents.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/stream-types.d.ts +10 -0
- package/dist/server/server-adapter/routes/stream-types.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/system.d.ts +12 -0
- package/dist/server/server-adapter/routes/system.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/tools.d.ts +3 -0
- package/dist/server/server-adapter/routes/tools.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/vectors.d.ts +3 -0
- package/dist/server/server-adapter/routes/vectors.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/workflows.d.ts +3 -0
- package/dist/server/server-adapter/routes/workflows.d.ts.map +1 -0
- package/dist/server/utils.d.ts +1 -1
- package/dist/server/utils.d.ts.map +1 -1
- package/dist/{token-375W3LEI.cjs → token-6GSAFR2W-K2BTU23I-5WBYUIGY.cjs} +11 -12
- package/dist/token-6GSAFR2W-K2BTU23I-5WBYUIGY.cjs.map +1 -0
- package/dist/{token-C3IMNCC4.js → token-6GSAFR2W-K2BTU23I-NW33N3NU.js} +8 -9
- package/dist/token-6GSAFR2W-K2BTU23I-NW33N3NU.js.map +1 -0
- package/dist/token-6GSAFR2W-KVDFAJ2M-EPLMGMHT.cjs +63 -0
- package/dist/token-6GSAFR2W-KVDFAJ2M-EPLMGMHT.cjs.map +1 -0
- package/dist/token-6GSAFR2W-KVDFAJ2M-VW443KIA.js +61 -0
- package/dist/token-6GSAFR2W-KVDFAJ2M-VW443KIA.js.map +1 -0
- package/dist/token-6GSAFR2W-VLY2XUPA-NCSASMWN.js +61 -0
- package/dist/token-6GSAFR2W-VLY2XUPA-NCSASMWN.js.map +1 -0
- package/dist/token-6GSAFR2W-VLY2XUPA-RKITWXKR.cjs +63 -0
- package/dist/token-6GSAFR2W-VLY2XUPA-RKITWXKR.cjs.map +1 -0
- package/dist/token-util-NEHG7TUY-DJYRKLRD-6TH3ODCN.cjs +10 -0
- package/dist/token-util-NEHG7TUY-DJYRKLRD-6TH3ODCN.cjs.map +1 -0
- package/dist/token-util-NEHG7TUY-DJYRKLRD-EACKYD4V.js +8 -0
- package/dist/token-util-NEHG7TUY-DJYRKLRD-EACKYD4V.js.map +1 -0
- package/dist/token-util-NEHG7TUY-KSXDO2NO-J6DEINGO.cjs +10 -0
- package/dist/token-util-NEHG7TUY-KSXDO2NO-J6DEINGO.cjs.map +1 -0
- package/dist/token-util-NEHG7TUY-KSXDO2NO-WH6I3PH3.js +8 -0
- package/dist/token-util-NEHG7TUY-KSXDO2NO-WH6I3PH3.js.map +1 -0
- package/dist/token-util-NEHG7TUY-TIJ3LMSH-ANFISSXX.cjs +10 -0
- package/dist/token-util-NEHG7TUY-TIJ3LMSH-ANFISSXX.cjs.map +1 -0
- package/dist/token-util-NEHG7TUY-TIJ3LMSH-SGVKOKXF.js +8 -0
- package/dist/token-util-NEHG7TUY-TIJ3LMSH-SGVKOKXF.js.map +1 -0
- package/package.json +35 -10
- package/dist/chunk-2IS5WICF.js +0 -23036
- package/dist/chunk-2IS5WICF.js.map +0 -1
- package/dist/chunk-2YZH5PH6.cjs +0 -200
- package/dist/chunk-2YZH5PH6.cjs.map +0 -1
- package/dist/chunk-3AMNUUZF.js +0 -124
- package/dist/chunk-3AMNUUZF.js.map +0 -1
- package/dist/chunk-3F52QCI4.js +0 -192
- package/dist/chunk-3F52QCI4.js.map +0 -1
- package/dist/chunk-4JF5WXPL.js +0 -502
- package/dist/chunk-4JF5WXPL.js.map +0 -1
- package/dist/chunk-73PAWDM5.js +0 -83
- package/dist/chunk-73PAWDM5.js.map +0 -1
- package/dist/chunk-A24TSVEZ.cjs +0 -130
- package/dist/chunk-A24TSVEZ.cjs.map +0 -1
- package/dist/chunk-A2NPD5N6.cjs +0 -517
- package/dist/chunk-A2NPD5N6.cjs.map +0 -1
- package/dist/chunk-B3Z6J745.js +0 -122
- package/dist/chunk-B3Z6J745.js.map +0 -1
- package/dist/chunk-BTWIR2B7.cjs +0 -28
- package/dist/chunk-BTWIR2B7.cjs.map +0 -1
- package/dist/chunk-D7T74TVR.js.map +0 -1
- package/dist/chunk-EHACNWDL.cjs +0 -681
- package/dist/chunk-EHACNWDL.cjs.map +0 -1
- package/dist/chunk-FPBYKMIS.js.map +0 -1
- package/dist/chunk-GLAZTMX3.cjs +0 -128
- package/dist/chunk-GLAZTMX3.cjs.map +0 -1
- package/dist/chunk-ID6JYDNL.cjs +0 -23075
- package/dist/chunk-ID6JYDNL.cjs.map +0 -1
- package/dist/chunk-KF3RI45U.cjs +0 -172
- package/dist/chunk-KF3RI45U.cjs.map +0 -1
- package/dist/chunk-KJIDZQRA.cjs.map +0 -1
- package/dist/chunk-KWH5QBXP.js +0 -123
- package/dist/chunk-KWH5QBXP.js.map +0 -1
- package/dist/chunk-LPM6BBAX.cjs.map +0 -1
- package/dist/chunk-ND5OKOMT.js +0 -165
- package/dist/chunk-ND5OKOMT.js.map +0 -1
- package/dist/chunk-PPMIB3FQ.cjs +0 -88
- package/dist/chunk-PPMIB3FQ.cjs.map +0 -1
- package/dist/chunk-QU6N55W6.cjs.map +0 -1
- package/dist/chunk-RQK4FQUD.js.map +0 -1
- package/dist/chunk-S54HNARD.cjs +0 -131
- package/dist/chunk-S54HNARD.cjs.map +0 -1
- package/dist/chunk-SHWNNZBL.js.map +0 -1
- package/dist/chunk-SZIFSF4T.js +0 -25
- package/dist/chunk-SZIFSF4T.js.map +0 -1
- package/dist/chunk-TOCYBDP2.js +0 -46
- package/dist/chunk-TOCYBDP2.js.map +0 -1
- package/dist/chunk-UXGQZUYZ.js.map +0 -1
- package/dist/chunk-V5WWQN7P.cjs.map +0 -1
- package/dist/chunk-W2KMU354.cjs.map +0 -1
- package/dist/chunk-X3MICMI2.cjs +0 -620
- package/dist/chunk-X3MICMI2.cjs.map +0 -1
- package/dist/chunk-X6C7BUWN.cjs +0 -48
- package/dist/chunk-X6C7BUWN.cjs.map +0 -1
- package/dist/chunk-Z2O5YVHY.js +0 -661
- package/dist/chunk-Z2O5YVHY.js.map +0 -1
- package/dist/chunk-ZJ6KEY6H.js +0 -600
- package/dist/chunk-ZJ6KEY6H.js.map +0 -1
- package/dist/dist-P4MXBQ3U.cjs +0 -16
- package/dist/dist-YREX2TJT.js +0 -3
- package/dist/token-375W3LEI.cjs.map +0 -1
- package/dist/token-C3IMNCC4.js.map +0 -1
- package/dist/token-util-CV3RRG6K.cjs +0 -9
- package/dist/token-util-CV3RRG6K.cjs.map +0 -1
- package/dist/token-util-E5QO2RCL.js +0 -7
- package/dist/token-util-E5QO2RCL.js.map +0 -1
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
> Create a custom server adapter for frameworks other than Hono or Express.
|
|
2
|
+
|
|
3
|
+
# Custom Adapters
|
|
4
|
+
|
|
5
|
+
Create a custom adapter when you need to run Mastra with a framework other than Hono or Express. This might be necessary if you have specific request/response handling requirements that `@mastra/hono` and `@mastra/express` don't support.
|
|
6
|
+
|
|
7
|
+
A custom adapter translates between Mastra's route definitions and your framework's routing system. You'll implement methods that register middleware, handle requests, and send responses using your framework's APIs.
|
|
8
|
+
|
|
9
|
+
> **Note:**
|
|
10
|
+
|
|
11
|
+
For Hono or Express, use the provided adapters instead:
|
|
12
|
+
- [@mastra/hono](https://mastra.ai/reference/v1/server/hono-adapter)
|
|
13
|
+
- [@mastra/express](https://mastra.ai/reference/v1/server/express-adapter)
|
|
14
|
+
|
|
15
|
+
## Abstract class
|
|
16
|
+
|
|
17
|
+
The `MastraServer` abstract class from `@mastra/server/server-adapter` provides the foundation for all adapters. It handles route registration logic, parameter validation, and other shared functionality. Your custom adapter extends this class and implements the framework-specific parts.
|
|
18
|
+
|
|
19
|
+
The class takes three type parameters that represent your framework's types:
|
|
20
|
+
|
|
21
|
+
```typescript title="my-framework-adapter.ts"
|
|
22
|
+
import { MastraServer } from '@mastra/server/server-adapter';
|
|
23
|
+
|
|
24
|
+
export class MyFrameworkServer extends MastraServer<
|
|
25
|
+
// Your framework's app type (e.g., FastifyInstance)
|
|
26
|
+
MyApp,
|
|
27
|
+
// Your framework's request type (e.g., FastifyRequest)
|
|
28
|
+
MyRequest,
|
|
29
|
+
// Your framework's response type (e.g., FastifyReply)
|
|
30
|
+
MyResponse
|
|
31
|
+
> {
|
|
32
|
+
// Implement abstract methods
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
These type parameters ensure type safety throughout your adapter implementation and enable proper typing when accessing framework-specific APIs.
|
|
37
|
+
|
|
38
|
+
## Required methods
|
|
39
|
+
|
|
40
|
+
You must implement these six abstract methods. Each handles a specific part of the request lifecycle, from attaching context to sending responses.
|
|
41
|
+
|
|
42
|
+
### registerContextMiddleware()
|
|
43
|
+
|
|
44
|
+
This method runs first and attaches Mastra context to every incoming request. Route handlers need access to the Mastra instance, tools, and other context to function. How you attach this context depends on your framework — Express uses `res.locals`, Hono uses `c.set()`, and other frameworks have their own patterns.
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
registerContextMiddleware(): void {
|
|
48
|
+
this.app.use('*', (req, res, next) => {
|
|
49
|
+
// Attach context to your framework's request/response
|
|
50
|
+
res.locals.mastra = this.mastra;
|
|
51
|
+
res.locals.requestContext = new RequestContext();
|
|
52
|
+
res.locals.tools = this.tools;
|
|
53
|
+
res.locals.abortSignal = createAbortSignal(req);
|
|
54
|
+
next();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Context to attach:
|
|
60
|
+
|
|
61
|
+
| Key | Type | Description |
|
|
62
|
+
|-----|------|-------------|
|
|
63
|
+
| `mastra` | `Mastra` | The Mastra instance |
|
|
64
|
+
| `requestContext` | `RequestContext` | Request-scoped context map |
|
|
65
|
+
| `tools` | `Record<string, Tool>` | Available tools |
|
|
66
|
+
| `abortSignal` | `AbortSignal` | Request cancellation signal |
|
|
67
|
+
| `taskStore` | `InMemoryTaskStore` | A2A task storage (if configured) |
|
|
68
|
+
|
|
69
|
+
### registerAuthMiddleware()
|
|
70
|
+
|
|
71
|
+
Register authentication and authorization middleware. This method should check if authentication is configured on the Mastra instance and skip registration entirely if not. When auth is configured, you'll typically register two middleware functions: one for authentication (validating tokens and setting the user) and one for authorization (checking if the user can access the requested resource).
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
registerAuthMiddleware(): void {
|
|
75
|
+
const authConfig = this.mastra.getServer()?.auth;
|
|
76
|
+
if (!authConfig) return;
|
|
77
|
+
|
|
78
|
+
// Register authentication (validate token, set user)
|
|
79
|
+
this.app.use('*', async (req, res, next) => {
|
|
80
|
+
const token = extractToken(req);
|
|
81
|
+
const user = await authConfig.authenticateToken?.(token, req);
|
|
82
|
+
if (!user) {
|
|
83
|
+
return res.status(401).json({ error: 'Unauthorized' });
|
|
84
|
+
}
|
|
85
|
+
res.locals.user = user;
|
|
86
|
+
next();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Register authorization (check permissions)
|
|
90
|
+
this.app.use('*', async (req, res, next) => {
|
|
91
|
+
const allowed = await authConfig.authorize?.(
|
|
92
|
+
req.path,
|
|
93
|
+
req.method,
|
|
94
|
+
res.locals.user,
|
|
95
|
+
res
|
|
96
|
+
);
|
|
97
|
+
if (!allowed) {
|
|
98
|
+
return res.status(403).json({ error: 'Forbidden' });
|
|
99
|
+
}
|
|
100
|
+
next();
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### registerRoute()
|
|
106
|
+
|
|
107
|
+
Register a single route with your framework. This method is called once for each Mastra route during initialization. It receives a `ServerRoute` object containing the path, HTTP method, handler function, and Zod schemas for validation. Your implementation should wire this up to your framework's routing system.
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
async registerRoute(
|
|
111
|
+
app: MyApp,
|
|
112
|
+
route: ServerRoute,
|
|
113
|
+
{ prefix }: { prefix?: string }
|
|
114
|
+
): Promise<void> {
|
|
115
|
+
const path = `${prefix || ''}${route.path}`;
|
|
116
|
+
const method = route.method.toLowerCase();
|
|
117
|
+
|
|
118
|
+
app[method](path, async (req, res) => {
|
|
119
|
+
try {
|
|
120
|
+
// 1. Extract parameters
|
|
121
|
+
const params = await this.getParams(route, req);
|
|
122
|
+
|
|
123
|
+
// 2. Validate with Zod schemas
|
|
124
|
+
const queryParams = await this.parseQueryParams(route, params.queryParams);
|
|
125
|
+
const body = await this.parseBody(route, params.body);
|
|
126
|
+
|
|
127
|
+
// 3. Build handler params
|
|
128
|
+
const handlerParams = {
|
|
129
|
+
...params.urlParams,
|
|
130
|
+
...queryParams,
|
|
131
|
+
...(typeof body === 'object' ? body : {}),
|
|
132
|
+
mastra: this.mastra,
|
|
133
|
+
requestContext: res.locals.requestContext,
|
|
134
|
+
tools: res.locals.tools,
|
|
135
|
+
abortSignal: res.locals.abortSignal,
|
|
136
|
+
taskStore: this.taskStore,
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// 4. Call handler
|
|
140
|
+
const result = await route.handler(handlerParams);
|
|
141
|
+
|
|
142
|
+
// 5. Send response
|
|
143
|
+
return this.sendResponse(route, res, result);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
const status = error.status ?? error.details?.status ?? 500;
|
|
146
|
+
return res.status(status).json({ error: error.message });
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### getParams()
|
|
153
|
+
|
|
154
|
+
Extract URL parameters, query parameters, and request body from the incoming request. Different frameworks expose these values in different ways—Express uses `req.params`, `req.query`, and `req.body`, while other frameworks may use different property names or require method calls. This method normalizes the extraction for your framework.
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
async getParams(
|
|
158
|
+
route: ServerRoute,
|
|
159
|
+
request: MyRequest
|
|
160
|
+
): Promise<{
|
|
161
|
+
urlParams: Record<string, string>;
|
|
162
|
+
queryParams: Record<string, string>;
|
|
163
|
+
body: unknown;
|
|
164
|
+
}> {
|
|
165
|
+
return {
|
|
166
|
+
// From route path (e.g., :agentId)
|
|
167
|
+
urlParams: request.params,
|
|
168
|
+
// From URL query string
|
|
169
|
+
queryParams: request.query,
|
|
170
|
+
// From request body
|
|
171
|
+
body: request.body,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### sendResponse()
|
|
177
|
+
|
|
178
|
+
Send the response back to the client based on the route's response type. Mastra routes can return different response types: JSON for most API responses, streams for agent generation, and special types for MCP transports. Your implementation should handle each type appropriately for your framework.
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
async sendResponse(
|
|
182
|
+
route: ServerRoute,
|
|
183
|
+
response: MyResponse,
|
|
184
|
+
result: unknown
|
|
185
|
+
): Promise<unknown> {
|
|
186
|
+
switch (route.responseType) {
|
|
187
|
+
case 'json':
|
|
188
|
+
return response.json(result);
|
|
189
|
+
|
|
190
|
+
case 'stream':
|
|
191
|
+
return this.stream(route, response, result);
|
|
192
|
+
|
|
193
|
+
case 'datastream-response':
|
|
194
|
+
// Return AI SDK Response directly
|
|
195
|
+
return result;
|
|
196
|
+
|
|
197
|
+
case 'mcp-http':
|
|
198
|
+
// Handle MCP HTTP transport
|
|
199
|
+
return this.handleMcpHttp(response, result);
|
|
200
|
+
|
|
201
|
+
case 'mcp-sse':
|
|
202
|
+
// Handle MCP SSE transport
|
|
203
|
+
return this.handleMcpSse(response, result);
|
|
204
|
+
|
|
205
|
+
default:
|
|
206
|
+
return response.json(result);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### stream()
|
|
212
|
+
|
|
213
|
+
Handle streaming responses for agent generation. When an agent generates a response, it produces a stream of chunks that should be sent to the client as they become available. This method reads from the stream, optionally applies redaction to hide sensitive data, and writes chunks to the response in the appropriate format (SSE or newline-delimited JSON).
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
async stream(
|
|
217
|
+
route: ServerRoute,
|
|
218
|
+
response: MyResponse,
|
|
219
|
+
result: unknown
|
|
220
|
+
): Promise<unknown> {
|
|
221
|
+
const isSSE = route.streamFormat === 'sse';
|
|
222
|
+
|
|
223
|
+
// Set streaming headers based on format
|
|
224
|
+
response.setHeader('Content-Type', isSSE ? 'text/event-stream' : 'text/plain');
|
|
225
|
+
response.setHeader('Transfer-Encoding', 'chunked');
|
|
226
|
+
|
|
227
|
+
const reader = result.fullStream.getReader();
|
|
228
|
+
|
|
229
|
+
try {
|
|
230
|
+
while (true) {
|
|
231
|
+
const { done, value } = await reader.read();
|
|
232
|
+
if (done) break;
|
|
233
|
+
|
|
234
|
+
// Apply redaction if enabled
|
|
235
|
+
const chunk = this.streamOptions.redact
|
|
236
|
+
? redactChunk(value)
|
|
237
|
+
: value;
|
|
238
|
+
|
|
239
|
+
// Format based on stream format
|
|
240
|
+
if (isSSE) {
|
|
241
|
+
response.write(`data: ${JSON.stringify(chunk)}\n\n`);
|
|
242
|
+
} else {
|
|
243
|
+
response.write(JSON.stringify(chunk) + '\x1E');
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Send completion marker (SSE uses data: [DONE], other formats use record separator)
|
|
248
|
+
if (isSSE) {
|
|
249
|
+
response.write('data: [DONE]\n\n');
|
|
250
|
+
}
|
|
251
|
+
response.end();
|
|
252
|
+
} catch (error) {
|
|
253
|
+
reader.cancel();
|
|
254
|
+
throw error;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## Helper methods
|
|
260
|
+
|
|
261
|
+
The base class provides helper methods you can use in your implementation. These handle common tasks like parameter validation and route registration, so you don't need to reimplement them:
|
|
262
|
+
|
|
263
|
+
| Method | Description |
|
|
264
|
+
|--------|-------------|
|
|
265
|
+
| `parsePathParams(route, params)` | Validate path params with Zod schema |
|
|
266
|
+
| `parseQueryParams(route, params)` | Validate query params with Zod schema |
|
|
267
|
+
| `parseBody(route, body)` | Validate body with Zod schema |
|
|
268
|
+
| `mergeRequestContext({ paramsRequestContext, bodyRequestContext })` | Merge request context from multiple sources |
|
|
269
|
+
| `registerRoutes()` | Register all Mastra routes (calls `registerRoute` for each) |
|
|
270
|
+
| `registerOpenAPIRoute(app, config, { prefix })` | Register OpenAPI spec endpoint |
|
|
271
|
+
|
|
272
|
+
The `parse*` methods use Zod schemas defined on each route to validate input and return typed results. If validation fails, they throw an error with details about what went wrong.
|
|
273
|
+
|
|
274
|
+
## Constructor
|
|
275
|
+
|
|
276
|
+
Your adapter's constructor should accept the same options as the base class and pass them to `super()`. You can add additional framework-specific options if needed:
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
constructor(options: {
|
|
280
|
+
app: MyApp;
|
|
281
|
+
mastra: Mastra;
|
|
282
|
+
prefix?: string;
|
|
283
|
+
openapiPath?: string;
|
|
284
|
+
bodyLimitOptions?: BodyLimitOptions;
|
|
285
|
+
streamOptions?: StreamOptions;
|
|
286
|
+
customRouteAuthConfig?: Map<string, boolean>;
|
|
287
|
+
}) {
|
|
288
|
+
super(options);
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
See [Server Adapters](https://mastra.ai/docs/v1/server/server-adapters#constructor-options) for full documentation on each option.
|
|
293
|
+
|
|
294
|
+
## Full example
|
|
295
|
+
|
|
296
|
+
Here's a skeleton implementation showing all the required methods. This uses pseudocode for framework-specific parts—replace with your framework's actual APIs:
|
|
297
|
+
|
|
298
|
+
```typescript title="my-framework-adapter.ts"
|
|
299
|
+
import { MastraServer, ServerRoute } from '@mastra/server/server-adapter';
|
|
300
|
+
import type { Mastra } from '@mastra/core';
|
|
301
|
+
|
|
302
|
+
export class MyFrameworkServer extends MastraServer<MyApp, MyRequest, MyResponse> {
|
|
303
|
+
constructor(options: { app: MyApp; mastra: Mastra; prefix?: string }) {
|
|
304
|
+
super(options);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
registerContextMiddleware(): void {
|
|
308
|
+
this.app.use('*', (req, res, next) => {
|
|
309
|
+
res.locals.mastra = this.mastra;
|
|
310
|
+
res.locals.requestContext = this.mergeRequestContext({
|
|
311
|
+
paramsRequestContext: req.query.requestContext,
|
|
312
|
+
bodyRequestContext: req.body?.requestContext,
|
|
313
|
+
});
|
|
314
|
+
res.locals.tools = this.tools ?? {};
|
|
315
|
+
res.locals.abortSignal = createAbortSignal(req);
|
|
316
|
+
next();
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
registerAuthMiddleware(): void {
|
|
321
|
+
const authConfig = this.mastra.getServer()?.auth;
|
|
322
|
+
if (!authConfig) return;
|
|
323
|
+
// ... implement auth middleware
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
async registerRoute(app: MyApp, route: ServerRoute, { prefix }: { prefix?: string }): Promise<void> {
|
|
327
|
+
// ... implement route registration
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
async getParams(route: ServerRoute, request: MyRequest) {
|
|
331
|
+
return {
|
|
332
|
+
urlParams: request.params,
|
|
333
|
+
queryParams: request.query,
|
|
334
|
+
body: request.body,
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
async sendResponse(route: ServerRoute, response: MyResponse, result: unknown) {
|
|
339
|
+
if (route.responseType === 'stream') {
|
|
340
|
+
return this.stream(route, response, result);
|
|
341
|
+
}
|
|
342
|
+
return response.json(result);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
async stream(route: ServerRoute, response: MyResponse, result: unknown) {
|
|
346
|
+
// ... implement streaming
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
## Usage
|
|
352
|
+
|
|
353
|
+
Once your adapter is implemented, use it the same way as the provided adapters:
|
|
354
|
+
|
|
355
|
+
```typescript title="server.ts"
|
|
356
|
+
import { MyFrameworkServer } from './my-framework-adapter';
|
|
357
|
+
import { mastra } from './mastra';
|
|
358
|
+
|
|
359
|
+
const app = createMyFrameworkApp();
|
|
360
|
+
const server = new MyFrameworkServer({ app, mastra });
|
|
361
|
+
|
|
362
|
+
await server.init();
|
|
363
|
+
|
|
364
|
+
app.listen(4111);
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
> **Note:**
|
|
368
|
+
|
|
369
|
+
The existing [@mastra/hono](https://github.com/mastra-ai/mastra/blob/main/server-adapters/hono/src/index.ts) and [@mastra/express](https://github.com/mastra-ai/mastra/blob/main/server-adapters/express/src/index.ts) implementations are good references when building your custom adapter. They show how to handle framework-specific patterns for context storage, middleware registration, and response handling.
|
|
370
|
+
|
|
371
|
+
## Related
|
|
372
|
+
|
|
373
|
+
- [Server Adapters](https://mastra.ai/docs/v1/server/server-adapters) - Overview and shared concepts
|
|
374
|
+
- [Hono Adapter](https://mastra.ai/reference/v1/server/hono-adapter) - Reference implementation
|
|
375
|
+
- [Express Adapter](https://mastra.ai/reference/v1/server/express-adapter) - Reference implementation
|
|
376
|
+
- [MastraServer Reference](https://mastra.ai/reference/v1/server/mastra-server) - Full API reference
|
|
377
|
+
- [createRoute() Reference](https://mastra.ai/reference/v1/server/create-route) - Creating type-safe custom routes
|