@mastra/server 1.82.0-alpha.3 → 1.83.0-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/dist/_types/@internal_core@0.1.4/dist/storage/index.d.ts +24 -2
- package/dist/_types/@mastra_schema-compat@1.3.17/dist/_types/{@internal_ai-v6@0.0.94 → @internal_ai-v6@0.0.95}/dist/index.d.ts +96 -15
- package/dist/_types/@mastra_schema-compat@1.3.17/dist/provider-compats/anthropic.d.ts +1 -1
- package/dist/_types/@mastra_schema-compat@1.3.17/dist/provider-compats/deepseek.d.ts +1 -1
- package/dist/_types/@mastra_schema-compat@1.3.17/dist/provider-compats/meta.d.ts +1 -1
- package/dist/_types/@mastra_schema-compat@1.3.17/dist/schema.types.d.ts +3 -3
- package/dist/{a2a-CoiG3TAj.js → a2a-DCpd3CTv.js} +4 -4
- package/dist/{a2a-CoiG3TAj.js.map → a2a-DCpd3CTv.js.map} +1 -1
- package/dist/{a2a-DvqRdny6.cjs → a2a-kz7NjjCg.cjs} +4 -4
- package/dist/{a2a-DvqRdny6.cjs.map → a2a-kz7NjjCg.cjs.map} +1 -1
- package/dist/{agent-builder-C_L1i2eE.js → agent-builder-CocfOSi8.js} +7 -7
- package/dist/{agent-builder-C_L1i2eE.js.map → agent-builder-CocfOSi8.js.map} +1 -1
- package/dist/{agent-builder-D0Up9Fw1.cjs → agent-builder-uDstZROq.cjs} +7 -7
- package/dist/{agent-builder-D0Up9Fw1.cjs.map → agent-builder-uDstZROq.cjs.map} +1 -1
- package/dist/{agents-CgcW6lHt.js → agents-BI8ez-FT.js} +7 -7
- package/dist/{agents-CgcW6lHt.js.map → agents-BI8ez-FT.js.map} +1 -1
- package/dist/{agents-DOHGWXDa.cjs → agents-DsfsDhIT.cjs} +7 -7
- package/dist/{agents-DOHGWXDa.cjs.map → agents-DsfsDhIT.cjs.map} +1 -1
- package/dist/{api-schema-manifest-Ci2qUYHc.js → api-schema-manifest-ChxbN16M.js} +3 -3
- package/dist/{api-schema-manifest-Ci2qUYHc.js.map → api-schema-manifest-ChxbN16M.js.map} +1 -1
- package/dist/{api-schema-manifest-DCHOlOuJ.cjs → api-schema-manifest-DtYTPvh9.cjs} +3 -3
- package/dist/{api-schema-manifest-DCHOlOuJ.cjs.map → api-schema-manifest-DtYTPvh9.cjs.map} +1 -1
- package/dist/{background-tasks-BHhn4YZA.js → background-tasks-BIuEr2of.js} +3 -3
- package/dist/{background-tasks-BHhn4YZA.js.map → background-tasks-BIuEr2of.js.map} +1 -1
- package/dist/{background-tasks-Ci2tlxJC.cjs → background-tasks-BXTIp0QV.cjs} +3 -3
- package/dist/{background-tasks-Ci2tlxJC.cjs.map → background-tasks-BXTIp0QV.cjs.map} +1 -1
- package/dist/{builder-registry-m_gHCe12.js → builder-registry-Dd7pbJ5A.js} +4 -4
- package/dist/{builder-registry-m_gHCe12.js.map → builder-registry-Dd7pbJ5A.js.map} +1 -1
- package/dist/{builder-registry-D1_hGKCJ.cjs → builder-registry-DrBUA6EZ.cjs} +4 -4
- package/dist/{builder-registry-D1_hGKCJ.cjs.map → builder-registry-DrBUA6EZ.cjs.map} +1 -1
- package/dist/{channels-hhQ3vD30.js → channels-B6hwVMbV.js} +4 -4
- package/dist/{channels-hhQ3vD30.js.map → channels-B6hwVMbV.js.map} +1 -1
- package/dist/{channels-Bfkp5vYI.cjs → channels-DbfSH5O2.cjs} +4 -4
- package/dist/{channels-Bfkp5vYI.cjs.map → channels-DbfSH5O2.cjs.map} +1 -1
- package/dist/{conversations-xS7yHuG1.js → conversations-BbZYXKIa.js} +5 -5
- package/dist/{conversations-xS7yHuG1.js.map → conversations-BbZYXKIa.js.map} +1 -1
- package/dist/{conversations-Ch_VuVwY.cjs → conversations-QuKJVEFe.cjs} +5 -5
- package/dist/{conversations-Ch_VuVwY.cjs.map → conversations-QuKJVEFe.cjs.map} +1 -1
- package/dist/{dist-BKNKucT9.cjs → dist-Ctfk9X6u.cjs} +208 -247
- package/dist/dist-Ctfk9X6u.cjs.map +1 -0
- package/dist/dist-DJjVMQiv.js +1 -0
- package/dist/{dist-CIYZuix4.js → dist-OKFDPspq.js} +208 -247
- package/dist/dist-OKFDPspq.js.map +1 -0
- package/dist/{dist-DgKeISkr.cjs → dist-ZYvqJK9p.cjs} +1 -1
- package/dist/docs/SKILL.md +3 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-knowledge-overview.md +106 -0
- package/dist/docs/references/docs-server-custom-adapters.md +4 -0
- package/dist/docs/references/docs-studio-knowledge.md +45 -24
- package/dist/docs/references/reference-server-invoke-route.md +86 -0
- package/dist/docs/references/reference-server-routes.md +63 -0
- package/dist/{dynamic-workflows-DDauBnDt.js → dynamic-workflows-CyaZLmHX.js} +2 -2
- package/dist/{dynamic-workflows-DDauBnDt.js.map → dynamic-workflows-CyaZLmHX.js.map} +1 -1
- package/dist/{dynamic-workflows-CpCkqM1g.cjs → dynamic-workflows-ZmzWJXxG.cjs} +2 -2
- package/dist/{dynamic-workflows-CpCkqM1g.cjs.map → dynamic-workflows-ZmzWJXxG.cjs.map} +1 -1
- package/dist/{editor-builder-Ceen28s8.js → editor-builder-CbfX5bvL.js} +4 -4
- package/dist/{editor-builder-Ceen28s8.js.map → editor-builder-CbfX5bvL.js.map} +1 -1
- package/dist/{editor-builder-CKfy5eZY.cjs → editor-builder-CjJlqR9a.cjs} +4 -4
- package/dist/{editor-builder-CKfy5eZY.cjs.map → editor-builder-CjJlqR9a.cjs.map} +1 -1
- package/dist/{helpers-DNq3LtLq.js → helpers-B29a1nM3.js} +51 -48
- package/dist/helpers-B29a1nM3.js.map +1 -0
- package/dist/{helpers-BKtUXhz2.cjs → helpers-CylvUIZm.cjs} +56 -47
- package/dist/helpers-CylvUIZm.cjs.map +1 -0
- package/dist/{knowledge-Ba74qr0v.js → knowledge-Cd2cCq-Y.js} +4 -4
- package/dist/{knowledge-Ba74qr0v.js.map → knowledge-Cd2cCq-Y.js.map} +1 -1
- package/dist/{knowledge-urR7FFG8.cjs → knowledge-Q_SCnD9m.cjs} +4 -4
- package/dist/{knowledge-urR7FFG8.cjs.map → knowledge-Q_SCnD9m.cjs.map} +1 -1
- package/dist/{logs-B57_NKDn.js → logs-C5L6gRGr.js} +4 -4
- package/dist/{logs-B57_NKDn.js.map → logs-C5L6gRGr.js.map} +1 -1
- package/dist/{logs-BJN3M88A.cjs → logs-DWIbFIw6.cjs} +4 -4
- package/dist/{logs-BJN3M88A.cjs.map → logs-DWIbFIw6.cjs.map} +1 -1
- package/dist/{mcp-B9BILfJP.cjs → mcp-CKvOVfHn.cjs} +3 -3
- package/dist/{mcp-B9BILfJP.cjs.map → mcp-CKvOVfHn.cjs.map} +1 -1
- package/dist/{mcp-BkmWZD6M.js → mcp-CntC59iU.js} +3 -3
- package/dist/{mcp-BkmWZD6M.js.map → mcp-CntC59iU.js.map} +1 -1
- package/dist/{memory-Dqod_AK9.cjs → memory-DIos0BE-.cjs} +57 -15
- package/dist/{memory-Dqod_AK9.cjs.map → memory-DIos0BE-.cjs.map} +1 -1
- package/dist/{memory-ipOCmg0C.js → memory-JzgWJevA.js} +57 -15
- package/dist/{memory-ipOCmg0C.js.map → memory-JzgWJevA.js.map} +1 -1
- package/dist/{observability-DBtyAJnb.js → observability-BCTkIhJT.js} +3 -3
- package/dist/{observability-DBtyAJnb.js.map → observability-BCTkIhJT.js.map} +1 -1
- package/dist/{observability-BtdW6mjq.cjs → observability-mnHHbnoc.cjs} +3 -3
- package/dist/{observability-BtdW6mjq.cjs.map → observability-mnHHbnoc.cjs.map} +1 -1
- package/dist/{observability-new-endpoints-jjCgXuTF.cjs → observability-new-endpoints-B6fo20v5.cjs} +129 -955
- package/dist/observability-new-endpoints-B6fo20v5.cjs.map +1 -0
- package/dist/{observability-new-endpoints-Di7m_-xc.js → observability-new-endpoints-DHn8uKyr.js} +51 -877
- package/dist/observability-new-endpoints-DHn8uKyr.js.map +1 -0
- package/dist/observability-signal-context-BYOFtbM_.cjs +1317 -0
- package/dist/observability-signal-context-BYOFtbM_.cjs.map +1 -0
- package/dist/observability-signal-context-CL5-rCWM.js +952 -0
- package/dist/observability-signal-context-CL5-rCWM.js.map +1 -0
- package/dist/{plans-nHOnlGzr.js → plans-9hdkc-t8.js} +4 -4
- package/dist/{plans-nHOnlGzr.js.map → plans-9hdkc-t8.js.map} +1 -1
- package/dist/{plans-Djcp3C0d.cjs → plans-DMs8SVBG.cjs} +4 -4
- package/dist/{plans-Djcp3C0d.cjs.map → plans-DMs8SVBG.cjs.map} +1 -1
- package/dist/{probe-image-size-DGTRKrgq.js → probe-image-size-Cxm5QtwO.js} +2 -2
- package/dist/{probe-image-size-DGTRKrgq.js.map → probe-image-size-Cxm5QtwO.js.map} +1 -1
- package/dist/{probe-image-size-BAwk1h6w.cjs → probe-image-size-bDuzMW0E.cjs} +2 -2
- package/dist/{probe-image-size-BAwk1h6w.cjs.map → probe-image-size-bDuzMW0E.cjs.map} +1 -1
- package/dist/{responses-CEet9y8G.js → responses-B5_syoSo.js} +5 -5
- package/dist/{responses-CEet9y8G.js.map → responses-B5_syoSo.js.map} +1 -1
- package/dist/{responses-BdOStKtX.cjs → responses-CNKJoC5a.cjs} +5 -5
- package/dist/{responses-BdOStKtX.cjs.map → responses-CNKJoC5a.cjs.map} +1 -1
- package/dist/{route-builder-BxPrwNog.js → route-builder-BKEzjw_M.js} +2 -2
- package/dist/{route-builder-BxPrwNog.js.map → route-builder-BKEzjw_M.js.map} +1 -1
- package/dist/{route-builder-CvARmqnA.cjs → route-builder-DHqDrSSy.cjs} +2 -2
- package/dist/{route-builder-CvARmqnA.cjs.map → route-builder-DHqDrSSy.cjs.map} +1 -1
- package/dist/{routes-DU_FlwJP.cjs → routes-BYQ38dFx.cjs} +32 -32
- package/dist/{routes-DU_FlwJP.cjs.map → routes-BYQ38dFx.cjs.map} +1 -1
- package/dist/{routes-5FpkkzND.js → routes-C0pgNcG-.js} +32 -32
- package/dist/{routes-5FpkkzND.js.map → routes-C0pgNcG-.js.map} +1 -1
- package/dist/{schedules-D8ShgpY3.cjs → schedules-CvWX2yKR.cjs} +3 -3
- package/dist/{schedules-D8ShgpY3.cjs.map → schedules-CvWX2yKR.cjs.map} +1 -1
- package/dist/{schedules-CGViSLZC.js → schedules-D9CKB18-.js} +3 -3
- package/dist/{schedules-CGViSLZC.js.map → schedules-D9CKB18-.js.map} +1 -1
- package/dist/{schema-Bf12g7KC-DBc4NSds.js → schema-Bf12g7KC-5EUrrnSf.js} +96 -96
- package/dist/{schema-Bf12g7KC-DBc4NSds.js.map → schema-Bf12g7KC-5EUrrnSf.js.map} +1 -1
- package/dist/{schema-Bf12g7KC-plP4Ir6h.cjs → schema-Bf12g7KC-C5XzpQxe.cjs} +96 -96
- package/dist/{schema-Bf12g7KC-plP4Ir6h.cjs.map → schema-Bf12g7KC-C5XzpQxe.cjs.map} +1 -1
- package/dist/{scores-BaDFGpmr.js → scores-B3mS6vqB.js} +4 -4
- package/dist/{scores-BaDFGpmr.js.map → scores-B3mS6vqB.js.map} +1 -1
- package/dist/{scores-Bw6Tuga5.cjs → scores-Dxa8dDfV.cjs} +4 -4
- package/dist/{scores-Bw6Tuga5.cjs.map → scores-Dxa8dDfV.cjs.map} +1 -1
- package/dist/server/auth/helpers.d.ts +20 -0
- package/dist/server/auth/helpers.d.ts.map +1 -1
- package/dist/server/auth/index.cjs +2 -1
- package/dist/server/auth/index.js +2 -2
- package/dist/server/handlers/a2a.cjs +1 -1
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agent-controller.cjs +4 -4
- package/dist/server/handlers/agent-controller.js +4 -4
- package/dist/server/handlers/agent-versions.cjs +4 -4
- package/dist/server/handlers/agent-versions.js +4 -4
- package/dist/server/handlers/agents.cjs +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/auth.cjs +4 -4
- package/dist/server/handlers/auth.js +4 -4
- package/dist/server/handlers/authorship.cjs +1 -1
- package/dist/server/handlers/authorship.js +1 -1
- package/dist/server/handlers/background-tasks.cjs +1 -1
- package/dist/server/handlers/background-tasks.js +1 -1
- package/dist/server/handlers/builder-registry.cjs +1 -1
- package/dist/server/handlers/builder-registry.js +1 -1
- package/dist/server/handlers/channels.cjs +1 -1
- package/dist/server/handlers/channels.js +1 -1
- package/dist/server/handlers/conversations.cjs +1 -1
- package/dist/server/handlers/conversations.js +1 -1
- package/dist/server/handlers/datasets.cjs +3 -3
- package/dist/server/handlers/datasets.js +3 -3
- package/dist/server/handlers/dynamic-workflows.cjs +1 -1
- package/dist/server/handlers/dynamic-workflows.js +1 -1
- package/dist/server/handlers/editor-builder.cjs +1 -1
- package/dist/server/handlers/editor-builder.js +1 -1
- package/dist/server/handlers/favorites-enrichment.cjs +1 -1
- package/dist/server/handlers/favorites-enrichment.js +1 -1
- package/dist/server/handlers/gateway-memory-client.cjs +4 -1
- package/dist/server/handlers/gateway-memory-client.cjs.map +1 -1
- package/dist/server/handlers/gateway-memory-client.d.ts.map +1 -1
- package/dist/server/handlers/gateway-memory-client.js +4 -1
- package/dist/server/handlers/gateway-memory-client.js.map +1 -1
- package/dist/server/handlers/knowledge.cjs +1 -1
- package/dist/server/handlers/knowledge.js +1 -1
- package/dist/server/handlers/logs.cjs +1 -1
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/mcp-client-versions.cjs +3 -3
- package/dist/server/handlers/mcp-client-versions.js +3 -3
- package/dist/server/handlers/mcp.cjs +1 -1
- package/dist/server/handlers/mcp.js +1 -1
- package/dist/server/handlers/memory.cjs +1 -1
- package/dist/server/handlers/memory.d.ts.map +1 -1
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/observability-new-endpoints.cjs +1 -1
- package/dist/server/handlers/observability-new-endpoints.d.ts +84 -8
- package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
- package/dist/server/handlers/observability-new-endpoints.js +1 -1
- package/dist/server/handlers/observability-shared.cjs +1 -1
- package/dist/server/handlers/observability-shared.js +1 -1
- package/dist/server/handlers/observability-signal-context.cjs +4 -0
- package/dist/server/handlers/observability-signal-context.d.ts +42 -0
- package/dist/server/handlers/observability-signal-context.d.ts.map +1 -0
- package/dist/server/handlers/observability-signal-context.js +1 -0
- package/dist/server/handlers/observability.cjs +2 -2
- package/dist/server/handlers/observability.js +2 -2
- package/dist/server/handlers/plans.cjs +1 -1
- package/dist/server/handlers/plans.js +1 -1
- package/dist/server/handlers/processor-providers.cjs +2 -2
- package/dist/server/handlers/processor-providers.js +2 -2
- package/dist/server/handlers/processors.cjs +2 -2
- package/dist/server/handlers/processors.js +2 -2
- package/dist/server/handlers/prompt-block-versions.cjs +3 -3
- package/dist/server/handlers/prompt-block-versions.js +3 -3
- package/dist/server/handlers/responses.cjs +1 -1
- package/dist/server/handlers/responses.js +1 -1
- package/dist/server/handlers/responses.storage.cjs +1 -1
- package/dist/server/handlers/responses.storage.js +1 -1
- package/dist/server/handlers/schedules.cjs +1 -1
- package/dist/server/handlers/schedules.js +1 -1
- package/dist/server/handlers/scorer-versions.cjs +3 -3
- package/dist/server/handlers/scorer-versions.js +3 -3
- package/dist/server/handlers/scores.cjs +1 -1
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/stored-agent-favorites.cjs +5 -5
- package/dist/server/handlers/stored-agent-favorites.js +5 -5
- package/dist/server/handlers/stored-agents.cjs +7 -7
- package/dist/server/handlers/stored-agents.js +7 -7
- package/dist/server/handlers/stored-mcp-clients.cjs +3 -3
- package/dist/server/handlers/stored-mcp-clients.js +3 -3
- package/dist/server/handlers/stored-prompt-blocks.cjs +3 -3
- package/dist/server/handlers/stored-prompt-blocks.js +3 -3
- package/dist/server/handlers/stored-scorers.cjs +3 -3
- package/dist/server/handlers/stored-scorers.js +3 -3
- package/dist/server/handlers/stored-skill-favorites.cjs +5 -5
- package/dist/server/handlers/stored-skill-favorites.js +5 -5
- package/dist/server/handlers/stored-skills.cjs +5 -5
- package/dist/server/handlers/stored-skills.js +5 -5
- package/dist/server/handlers/stored-workspaces.cjs +3 -3
- package/dist/server/handlers/stored-workspaces.js +3 -3
- package/dist/server/handlers/system.cjs +3 -3
- package/dist/server/handlers/system.js +3 -3
- package/dist/server/handlers/tool-providers.cjs +3 -3
- package/dist/server/handlers/tool-providers.js +3 -3
- package/dist/server/handlers/tools.cjs +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +1 -1
- package/dist/server/handlers/utils.js +1 -1
- package/dist/server/handlers/validate-agent-instructions.cjs +1 -1
- package/dist/server/handlers/validate-agent-instructions.js +1 -1
- package/dist/server/handlers/vector.cjs +1 -1
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/workflow-builder.cjs +1 -1
- package/dist/server/handlers/workflow-builder.js +1 -1
- package/dist/server/handlers/workflows.cjs +1 -1
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers/workspace.cjs +1 -1
- package/dist/server/handlers/workspace.d.ts +23 -23
- package/dist/server/handlers/workspace.js +1 -1
- package/dist/server/handlers.cjs +16 -16
- package/dist/server/handlers.js +16 -16
- package/dist/server/schemas/agents.d.ts +1 -1
- package/dist/server/schemas/index.cjs +20 -20
- package/dist/server/schemas/index.js +20 -20
- package/dist/server/server-adapter/index.cjs +231 -61
- package/dist/server/server-adapter/index.cjs.map +1 -1
- package/dist/server/server-adapter/index.d.ts +67 -1
- package/dist/server/server-adapter/index.d.ts.map +1 -1
- package/dist/server/server-adapter/index.js +226 -63
- package/dist/server/server-adapter/index.js.map +1 -1
- package/dist/server/server-adapter/mcp-auth.d.ts +16 -1
- package/dist/server/server-adapter/mcp-auth.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/observability.d.ts +42 -4
- package/dist/server/server-adapter/routes/observability.d.ts.map +1 -1
- package/dist/{tools-CI5oeJWT.cjs → tools-C9W7WvyI.cjs} +7 -7
- package/dist/{tools-CI5oeJWT.cjs.map → tools-C9W7WvyI.cjs.map} +1 -1
- package/dist/{tools-BAmCNGM5.js → tools-Ce7SFoT1.js} +7 -7
- package/dist/{tools-BAmCNGM5.js.map → tools-Ce7SFoT1.js.map} +1 -1
- package/dist/{utils-9PRHHTGC.cjs → utils-BXEJ6FZC.cjs} +2 -2
- package/dist/{utils-9PRHHTGC.cjs.map → utils-BXEJ6FZC.cjs.map} +1 -1
- package/dist/{utils-BhBJHsqX.cjs → utils-CL-m2SWZ.cjs} +3 -3
- package/dist/{utils-BhBJHsqX.cjs.map → utils-CL-m2SWZ.cjs.map} +1 -1
- package/dist/{utils-B15w-1hm.js → utils-CTYtskHa.js} +2 -2
- package/dist/{utils-B15w-1hm.js.map → utils-CTYtskHa.js.map} +1 -1
- package/dist/{utils-Dy_dQTlK.js → utils-y-cW3mQU.js} +3 -3
- package/dist/{utils-Dy_dQTlK.js.map → utils-y-cW3mQU.js.map} +1 -1
- package/dist/{vector-BZ1bKtwM.cjs → vector-6k7Ft7EX.cjs} +3 -3
- package/dist/{vector-BZ1bKtwM.cjs.map → vector-6k7Ft7EX.cjs.map} +1 -1
- package/dist/{vector-BAs5o6mH.js → vector-BWFSDXvg.js} +3 -3
- package/dist/{vector-BAs5o6mH.js.map → vector-BWFSDXvg.js.map} +1 -1
- package/dist/{workflow-builder-CaSfD6oL.js → workflow-builder-BNk301jl.js} +4 -4
- package/dist/{workflow-builder-CaSfD6oL.js.map → workflow-builder-BNk301jl.js.map} +1 -1
- package/dist/{workflow-builder-tr_D_ZDN.cjs → workflow-builder-CsOEskDo.cjs} +4 -4
- package/dist/{workflow-builder-tr_D_ZDN.cjs.map → workflow-builder-CsOEskDo.cjs.map} +1 -1
- package/dist/{workflows-BxXS5AfE.js → workflows-BAFGmHCW.js} +24 -13
- package/dist/workflows-BAFGmHCW.js.map +1 -0
- package/dist/{workflows-Cdi6w8JW.cjs → workflows-CJz5Eh0B.cjs} +76 -65
- package/dist/workflows-CJz5Eh0B.cjs.map +1 -0
- package/dist/{workspace-BU6sQpbV.cjs → workspace-C7PytFzz.cjs} +3 -3
- package/dist/{workspace-BU6sQpbV.cjs.map → workspace-C7PytFzz.cjs.map} +1 -1
- package/dist/{workspace-CS-GYTve.js → workspace-CYwDvH0G.js} +3 -3
- package/dist/{workspace-CS-GYTve.js.map → workspace-CYwDvH0G.js.map} +1 -1
- package/package.json +9 -9
- package/dist/dist-BKNKucT9.cjs.map +0 -1
- package/dist/dist-CIYZuix4.js.map +0 -1
- package/dist/dist-mNQb9_wX.js +0 -1
- package/dist/helpers-BKtUXhz2.cjs.map +0 -1
- package/dist/helpers-DNq3LtLq.js.map +0 -1
- package/dist/observability-new-endpoints-Di7m_-xc.js.map +0 -1
- package/dist/observability-new-endpoints-jjCgXuTF.cjs.map +0 -1
- package/dist/workflows-BxXS5AfE.js.map +0 -1
- package/dist/workflows-Cdi6w8JW.cjs.map +0 -1
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/@internal_core@0.1.4/dist/request-context/index.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/@internal_core@0.1.4/dist/routes/index.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/@internal_core@0.1.4/dist/types/index.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/classic/checks.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/classic/coerce.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/classic/compat.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/classic/deep-partial.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/classic/errors.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/classic/external.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/classic/from-json-schema.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/classic/in-out.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/classic/index.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/classic/iso.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/classic/parse.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/classic/schemas.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/core/api.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/core/checks.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/core/compile.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/core/core.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/core/doc.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/core/errors.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/core/index.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/core/json-schema-generator.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/core/json-schema-processors.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/core/json-schema.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/core/memoizer.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/core/parse.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/core/regexes.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/core/registries.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/core/schemas.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/core/standard-schema.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/core/to-json-schema.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/core/util.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/core/versions.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/index.d.cts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/ar.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/az.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/be.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/bg.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/bn.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/ca.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/ckb.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/cs.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/da.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/de.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/el.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/en.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/eo.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/es.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/fa.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/fi.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/fr-CA.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/fr.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/gu.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/he.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/hi.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/hr.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/hu.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/hy.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/id.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/index.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/is.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/it.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/ja.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/ka.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/kh.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/km.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/kn.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/ko.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/lt.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/mk.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/ms.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/ne.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/nl.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/nn.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/no.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/ota.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/pl.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/ps.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/pt-BR.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/pt.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/ro.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/ru.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/sk.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/sl.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/sv.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/ta.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/tg.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/th.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/tk.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/tr.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/ua.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/uk.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/ur.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/uz.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/vi.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/yo.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/zh-CN.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/_types/zod@4.6.7/v4/locales/zh-TW.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/dist/routes/index.d.ts +0 -0
- /package/dist/_types/{@internal_voice@0.0.43 → @internal_voice@0.0.44}/package.json +0 -0
- /package/dist/_types/@mastra_schema-compat@1.3.17/dist/_types/{@internal_ai-sdk-v4@0.0.94 → @internal_ai-sdk-v4@0.0.95}/dist/index.d.ts +0 -0
- /package/dist/_types/@mastra_schema-compat@1.3.17/dist/_types/{@internal_ai-sdk-v5@0.0.94 → @internal_ai-sdk-v5@0.0.95}/dist/index.d.ts +0 -0
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../rolldown-runtime-10nMEhjP.cjs");
|
|
3
|
-
const
|
|
4
|
-
const require_route_builder = require("../../route-builder-CvARmqnA.cjs");
|
|
5
|
-
const require_utils = require("../../utils-BhBJHsqX.cjs");
|
|
3
|
+
const require_helpers = require("../../helpers-CylvUIZm.cjs");
|
|
6
4
|
const require_constants = require("../../constants-DMg8hUOR.cjs");
|
|
7
5
|
const require_server_handlers_error = require("../handlers/error.cjs");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
6
|
+
const require_http_exception = require("../../http-exception-Co3MbFUf.cjs");
|
|
7
|
+
const require_utils = require("../../utils-CL-m2SWZ.cjs");
|
|
8
|
+
const require_route_builder = require("../../route-builder-DHqDrSSy.cjs");
|
|
9
|
+
const require_routes = require("../../routes-BYQ38dFx.cjs");
|
|
10
10
|
let zod_v4 = require("zod/v4");
|
|
11
11
|
let stream = require("stream");
|
|
12
|
+
let _mastra_core_auth_ee = require("@mastra/core/auth/ee");
|
|
12
13
|
let _mastra_core_request_context = require("@mastra/core/request-context");
|
|
13
14
|
let _mastra_core_server = require("@mastra/core/server");
|
|
14
15
|
let _mastra_core_utils = require("@mastra/core/utils");
|
|
@@ -291,6 +292,13 @@ function getBuiltInRouteFGAConfig(route) {
|
|
|
291
292
|
return null;
|
|
292
293
|
}
|
|
293
294
|
// src/server/server-adapter/mcp-auth.ts
|
|
295
|
+
/**
|
|
296
|
+
* Key under which `applyMcpRequestAuth` attaches the trusted request context to
|
|
297
|
+
* `req.auth`. `@mastra/mcp` reads the same registered symbol and copies the
|
|
298
|
+
* values into the request context its tools receive. A symbol cannot come out
|
|
299
|
+
* of a token or JSON payload, so only server code can supply it.
|
|
300
|
+
*/
|
|
301
|
+
const MCP_TRUSTED_REQUEST_CONTEXT = Symbol.for("mastra.mcp.trustedRequestContext");
|
|
294
302
|
function normalizeScopes(value) {
|
|
295
303
|
if (Array.isArray(value)) return value.filter((s) => typeof s === "string");
|
|
296
304
|
if (typeof value === "string") return value.split(/[\s,]+/).filter(Boolean);
|
|
@@ -333,21 +341,42 @@ function buildMcpAuthInfoFromRequestContext(requestContext) {
|
|
|
333
341
|
* transport.
|
|
334
342
|
*
|
|
335
343
|
* Resolution order:
|
|
336
|
-
* 1. An already-set `req.auth`
|
|
344
|
+
* 1. An already-set `req.auth` keeps its identity.
|
|
337
345
|
* 2. A configured `setRequestAuth` hook runs and fully owns the result.
|
|
338
346
|
* 3. Otherwise the principal resolved by Mastra server auth is bridged from the
|
|
339
347
|
* request context using the default mapping.
|
|
348
|
+
*
|
|
349
|
+
* Whichever way `req.auth` is set, the trusted request context is attached to
|
|
350
|
+
* it so MCP tools see the same principal as Mastra routes.
|
|
340
351
|
*/
|
|
341
352
|
async function applyMcpRequestAuth({ req, requestContext, setRequestAuth }) {
|
|
342
353
|
const request = req;
|
|
343
|
-
if (request.auth) return;
|
|
344
354
|
if (!requestContext) return;
|
|
345
|
-
if (
|
|
346
|
-
await setRequestAuth(req, requestContext);
|
|
347
|
-
|
|
355
|
+
if (!request.auth) {
|
|
356
|
+
if (setRequestAuth) await setRequestAuth(req, requestContext);
|
|
357
|
+
else {
|
|
358
|
+
const authInfo = buildMcpAuthInfoFromRequestContext(requestContext);
|
|
359
|
+
if (authInfo) request.auth = authInfo;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if (request.auth && typeof request.auth === "object") attachTrustedRequestContext(request.auth, requestContext);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Hands MCP tools the values Mastra server auth resolved for this request
|
|
366
|
+
* (user, permissions, roles, resource id, tenant, auth mode), so a tool called
|
|
367
|
+
* over MCP is authorized the same way as the matching HTTP route. The token is
|
|
368
|
+
* left out; it is already on `authInfo`.
|
|
369
|
+
*/
|
|
370
|
+
function attachTrustedRequestContext(auth, requestContext) {
|
|
371
|
+
const trusted = {};
|
|
372
|
+
for (const key of require_constants.RESERVED_REQUEST_CONTEXT_KEYS) {
|
|
373
|
+
if (key === "mastra__authToken" || !requestContext.has(key)) continue;
|
|
374
|
+
trusted[key] = requestContext.get(key);
|
|
348
375
|
}
|
|
349
|
-
|
|
350
|
-
|
|
376
|
+
Object.defineProperty(auth, MCP_TRUSTED_REQUEST_CONTEXT, {
|
|
377
|
+
value: trusted,
|
|
378
|
+
configurable: true
|
|
379
|
+
});
|
|
351
380
|
}
|
|
352
381
|
// src/server/server-adapter/mcp-disconnect.ts
|
|
353
382
|
/**
|
|
@@ -780,7 +809,7 @@ function normalizeQueryParams(rawQuery) {
|
|
|
780
809
|
* @template TRequest - The type of the request object
|
|
781
810
|
* @template TResponse - The type of the response object
|
|
782
811
|
*/
|
|
783
|
-
var MastraServer = class
|
|
812
|
+
var MastraServer = class extends _mastra_core_server.MastraServerBase {
|
|
784
813
|
/** Request bodies cannot set agent scopes: handlers strip `scopes`, and `mastra__scopes` is a reserved key. */
|
|
785
814
|
reservesAgentScopes = true;
|
|
786
815
|
mastra;
|
|
@@ -917,8 +946,7 @@ var MastraServer = class MastraServer extends _mastra_core_server.MastraServerBa
|
|
|
917
946
|
* Gets the effective RBAC provider for the current request based on auth mode.
|
|
918
947
|
*/
|
|
919
948
|
getEffectiveRBACProvider(requestContext) {
|
|
920
|
-
|
|
921
|
-
return this.mastra.getServer()?.rbac;
|
|
949
|
+
return getEffectiveRBACProvider(this.mastra, requestContext);
|
|
922
950
|
}
|
|
923
951
|
/**
|
|
924
952
|
* Gets the effective FGA provider for the current request based on auth mode.
|
|
@@ -1020,16 +1048,7 @@ var MastraServer = class MastraServer extends _mastra_core_server.MastraServerBa
|
|
|
1020
1048
|
* @returns Error response if permission denied, null if allowed
|
|
1021
1049
|
*/
|
|
1022
1050
|
checkRoutePermission(route, userPermissions, hasPermissionFn, requestContext) {
|
|
1023
|
-
|
|
1024
|
-
const requiredPermission = getEffectivePermission(route);
|
|
1025
|
-
if (!requiredPermission) return null;
|
|
1026
|
-
const permissions = Array.isArray(requiredPermission) ? requiredPermission : [requiredPermission];
|
|
1027
|
-
if (!(userPermissions && permissions.some((perm) => hasPermissionFn(userPermissions, perm)))) return {
|
|
1028
|
-
status: 403,
|
|
1029
|
-
error: "Forbidden",
|
|
1030
|
-
message: `Missing required permission: ${permissions.join(" or ")}`
|
|
1031
|
-
};
|
|
1032
|
-
return null;
|
|
1051
|
+
return getRoutePermissionError(this.mastra, route, userPermissions, hasPermissionFn, requestContext);
|
|
1033
1052
|
}
|
|
1034
1053
|
/**
|
|
1035
1054
|
* Build a matcher that answers "is this (path, method) a framework-public
|
|
@@ -1370,53 +1389,197 @@ Learn more: https://github.com/mastra-ai/mastra/blob/main/ee/LICENSE`);
|
|
|
1370
1389
|
}, { prefix: this.prefix });
|
|
1371
1390
|
}
|
|
1372
1391
|
async parsePathParams(route, params) {
|
|
1373
|
-
|
|
1374
|
-
if (!pathParamSchema) return params;
|
|
1375
|
-
return pathParamSchema.parseAsync(params);
|
|
1392
|
+
return parseRoutePathParams(route, params);
|
|
1376
1393
|
}
|
|
1377
1394
|
async parseQueryParams(route, params) {
|
|
1378
|
-
|
|
1379
|
-
if (!queryParamSchema) return params;
|
|
1380
|
-
const normalizedParams = parseComplexQueryParams(queryParamSchema, params);
|
|
1381
|
-
return queryParamSchema.parseAsync(normalizedParams);
|
|
1395
|
+
return parseRouteQueryParams(route, params);
|
|
1382
1396
|
}
|
|
1383
1397
|
async parseBody(route, body) {
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1398
|
+
return parseRouteBody(route, body);
|
|
1399
|
+
}
|
|
1400
|
+
resolveValidationError(route, error, context) {
|
|
1401
|
+
return resolveRouteValidationError(this.mastra, route, error, context);
|
|
1402
|
+
}
|
|
1403
|
+
};
|
|
1404
|
+
/**
|
|
1405
|
+
* The RBAC provider for the auth mode the request was authenticated with
|
|
1406
|
+
* (studio vs server).
|
|
1407
|
+
*/
|
|
1408
|
+
function getEffectiveRBACProvider(mastra, requestContext) {
|
|
1409
|
+
if (requestContext.get("mastra__authMode") === "studio") return mastra.getStudio?.()?.rbac ?? mastra.getServer()?.rbac;
|
|
1410
|
+
return mastra.getServer()?.rbac;
|
|
1411
|
+
}
|
|
1412
|
+
/**
|
|
1413
|
+
* Check if the user has the required permission for a route.
|
|
1414
|
+
*
|
|
1415
|
+
* Uses convention-based permission derivation:
|
|
1416
|
+
* 1. If route has explicit `requiresPermission`, use that
|
|
1417
|
+
* 2. Otherwise, derive permission from path/method (e.g., GET /agents → agents:read)
|
|
1418
|
+
* 3. Routes with `requiresAuth: false` skip permission checks
|
|
1419
|
+
*
|
|
1420
|
+
* When the route specifies an array of permissions, the user needs ANY ONE
|
|
1421
|
+
* of them (logical OR). Without an RBAC provider, authenticated users get full access.
|
|
1422
|
+
*
|
|
1423
|
+
* @returns Error response if permission denied, null if allowed
|
|
1424
|
+
*/
|
|
1425
|
+
function getRoutePermissionError(mastra, route, userPermissions, hasPermissionFn, requestContext) {
|
|
1426
|
+
if (!getEffectiveRBACProvider(mastra, requestContext)) return null;
|
|
1427
|
+
const requiredPermission = getEffectivePermission(route);
|
|
1428
|
+
if (!requiredPermission) return null;
|
|
1429
|
+
const permissions = Array.isArray(requiredPermission) ? requiredPermission : [requiredPermission];
|
|
1430
|
+
if (!(userPermissions && permissions.some((perm) => hasPermissionFn(userPermissions, perm)))) return {
|
|
1431
|
+
status: 403,
|
|
1432
|
+
error: "Forbidden",
|
|
1433
|
+
message: `Missing required permission: ${permissions.join(" or ")}`
|
|
1434
|
+
};
|
|
1435
|
+
return null;
|
|
1436
|
+
}
|
|
1437
|
+
async function parseRoutePathParams(route, params) {
|
|
1438
|
+
const pathParamSchema = route.pathParamSchema;
|
|
1439
|
+
if (!pathParamSchema) return params;
|
|
1440
|
+
return pathParamSchema.parseAsync(params);
|
|
1441
|
+
}
|
|
1442
|
+
async function parseRouteQueryParams(route, params) {
|
|
1443
|
+
const queryParamSchema = route.queryParamSchema;
|
|
1444
|
+
if (!queryParamSchema) return params;
|
|
1445
|
+
const normalizedParams = parseComplexQueryParams(queryParamSchema, params);
|
|
1446
|
+
return queryParamSchema.parseAsync(normalizedParams);
|
|
1447
|
+
}
|
|
1448
|
+
async function parseRouteBody(route, body) {
|
|
1449
|
+
const bodySchema = route.bodySchema;
|
|
1450
|
+
if (!bodySchema) return body;
|
|
1451
|
+
if (body === void 0) {
|
|
1452
|
+
const omitted = await bodySchema.safeParseAsync(void 0);
|
|
1453
|
+
if (omitted.success) return omitted.data;
|
|
1454
|
+
const schemaType = getSchemaTypeName(unwrapOptionalNullable(bodySchema));
|
|
1455
|
+
if (schemaType === "object" || schemaType === "ZodObject") {
|
|
1456
|
+
const emptyObject = await bodySchema.safeParseAsync({});
|
|
1457
|
+
if (emptyObject.success) return emptyObject.data;
|
|
1395
1458
|
}
|
|
1396
|
-
|
|
1459
|
+
throw omitted.error;
|
|
1460
|
+
}
|
|
1461
|
+
return bodySchema.parseAsync(body);
|
|
1462
|
+
}
|
|
1463
|
+
const VALIDATION_CONTEXT_LABELS = {
|
|
1464
|
+
query: "query parameters",
|
|
1465
|
+
body: "request body",
|
|
1466
|
+
path: "path parameters"
|
|
1467
|
+
};
|
|
1468
|
+
function resolveRouteValidationError(mastra, route, error, context) {
|
|
1469
|
+
const hook = route.onValidationError ?? mastra.getServer()?.onValidationError;
|
|
1470
|
+
if (hook) try {
|
|
1471
|
+
const result = hook(error, context);
|
|
1472
|
+
if (result) return result;
|
|
1473
|
+
} catch (hookError) {
|
|
1474
|
+
mastra.getLogger()?.error("Error in custom onValidationError hook", { error: hookError instanceof Error ? {
|
|
1475
|
+
message: hookError.message,
|
|
1476
|
+
stack: hookError.stack
|
|
1477
|
+
} : hookError });
|
|
1397
1478
|
}
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
body:
|
|
1401
|
-
path: "path parameters"
|
|
1479
|
+
return {
|
|
1480
|
+
status: 400,
|
|
1481
|
+
body: require_server_handlers_error.formatZodError(error, VALIDATION_CONTEXT_LABELS[context])
|
|
1402
1482
|
};
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1483
|
+
}
|
|
1484
|
+
/**
|
|
1485
|
+
* Runs a server route in-process as the caller, with the checks its HTTP
|
|
1486
|
+
* endpoint applies on every adapter: authentication, auth's `authorizeUser`,
|
|
1487
|
+
* `authorize` and `rules` (against the route's path under `apiPrefix`), input
|
|
1488
|
+
* validation, RBAC permission and FGA. Lets code outside an HTTP request (such
|
|
1489
|
+
* as an MCP tool) reuse a route without proxying through the HTTP server.
|
|
1490
|
+
*
|
|
1491
|
+
* Authentication is not re-run: when server or studio auth is configured, the
|
|
1492
|
+
* request context must already carry the user Mastra server auth resolved
|
|
1493
|
+
* (`MASTRA_USER_KEY`), otherwise the call is refused with 401.
|
|
1494
|
+
*
|
|
1495
|
+
* Only JSON routes are supported; other response types throw. The handler gets
|
|
1496
|
+
* the parsed params, `mastra`, `requestContext` and `abortSignal`, but not the
|
|
1497
|
+
* HTTP-only `request`, `registeredTools`, `taskStore` or `routePrefix`, so
|
|
1498
|
+
* routes that read those are not suitable.
|
|
1499
|
+
*/
|
|
1500
|
+
async function invokeRoute(route, options) {
|
|
1501
|
+
if (route.responseType !== "json") throw new Error(`invokeRoute only runs JSON routes; ${route.method} ${route.path} answers with '${route.responseType}'`);
|
|
1502
|
+
const { mastra, requestContext } = options;
|
|
1503
|
+
const studioAuth = mastra.getStudio?.()?.auth;
|
|
1504
|
+
const serverAuth = mastra.getServer()?.auth;
|
|
1505
|
+
const authConfigured = Boolean(studioAuth || serverAuth);
|
|
1506
|
+
if (authConfigured && route.requiresAuth !== false) {
|
|
1507
|
+
const user = requestContext.get(require_constants.MASTRA_USER_KEY);
|
|
1508
|
+
if (!user) return {
|
|
1509
|
+
status: 401,
|
|
1510
|
+
body: { error: "Authentication required" }
|
|
1511
|
+
};
|
|
1512
|
+
const authConfig = requestContext.get("mastra__authMode") === "studio" && studioAuth ? studioAuth : serverAuth;
|
|
1513
|
+
if (authConfig) {
|
|
1514
|
+
const path = `${require_utils.normalizeRoutePath(mastra.getServer()?.apiPrefix ?? "/api")}${route.path.replace(/:(\w+)/g, (_, name) => encodeURIComponent(options.pathParams?.[name] ?? ""))}`;
|
|
1515
|
+
const token = requestContext.get(require_constants.MASTRA_AUTH_TOKEN_KEY);
|
|
1516
|
+
const authorizationError = await require_helpers.authorizeAuthenticatedUser({
|
|
1517
|
+
path,
|
|
1518
|
+
method: route.method,
|
|
1519
|
+
user,
|
|
1520
|
+
mastra,
|
|
1521
|
+
authConfig,
|
|
1522
|
+
requestContext,
|
|
1523
|
+
rawRequest: new Request(`http://localhost${path}`, {
|
|
1524
|
+
method: route.method,
|
|
1525
|
+
headers: typeof token === "string" && token ? { authorization: `Bearer ${token}` } : void 0
|
|
1526
|
+
}),
|
|
1527
|
+
buildAuthorizeContext: () => null
|
|
1528
|
+
});
|
|
1529
|
+
if (authorizationError) return authorizationError;
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
const parse = async (context, run) => {
|
|
1533
|
+
try {
|
|
1534
|
+
return { value: await run() };
|
|
1535
|
+
} catch (error) {
|
|
1536
|
+
if (require_server_handlers_error.isZodError(error)) return { error: resolveRouteValidationError(mastra, route, error, context) };
|
|
1537
|
+
throw error;
|
|
1413
1538
|
}
|
|
1539
|
+
};
|
|
1540
|
+
const pathParams = await parse("path", () => parseRoutePathParams(route, options.pathParams ?? {}));
|
|
1541
|
+
if (pathParams.error) return pathParams.error;
|
|
1542
|
+
const query = await parse("query", () => parseRouteQueryParams(route, options.query ?? {}));
|
|
1543
|
+
if (query.error) return query.error;
|
|
1544
|
+
const body = await parse("body", () => parseRouteBody(route, options.body));
|
|
1545
|
+
if (body.error) return body.error;
|
|
1546
|
+
const params = {
|
|
1547
|
+
...pathParams.value,
|
|
1548
|
+
...query.value,
|
|
1549
|
+
...typeof body.value === "object" ? body.value : {}
|
|
1550
|
+
};
|
|
1551
|
+
if (authConfigured) {
|
|
1552
|
+
const permissionError = getRoutePermissionError(mastra, route, requestContext.get(require_constants.MASTRA_USER_PERMISSIONS_KEY), _mastra_core_auth_ee.hasPermission, requestContext);
|
|
1553
|
+
if (permissionError) return {
|
|
1554
|
+
status: permissionError.status,
|
|
1555
|
+
body: {
|
|
1556
|
+
error: permissionError.error,
|
|
1557
|
+
message: permissionError.message
|
|
1558
|
+
}
|
|
1559
|
+
};
|
|
1560
|
+
}
|
|
1561
|
+
const fgaError = await checkRouteFGA(mastra, route, requestContext, params);
|
|
1562
|
+
if (fgaError) return {
|
|
1563
|
+
status: fgaError.status,
|
|
1564
|
+
body: {
|
|
1565
|
+
error: fgaError.error,
|
|
1566
|
+
message: fgaError.message
|
|
1567
|
+
}
|
|
1568
|
+
};
|
|
1569
|
+
try {
|
|
1414
1570
|
return {
|
|
1415
|
-
status:
|
|
1416
|
-
body:
|
|
1571
|
+
status: 200,
|
|
1572
|
+
body: await route.handler({
|
|
1573
|
+
...params,
|
|
1574
|
+
requestContext,
|
|
1575
|
+
mastra,
|
|
1576
|
+
abortSignal: options.abortSignal ?? new AbortController().signal
|
|
1577
|
+
})
|
|
1417
1578
|
};
|
|
1579
|
+
} catch (error) {
|
|
1580
|
+
return getHTTPErrorResponse(error);
|
|
1418
1581
|
}
|
|
1419
|
-
}
|
|
1582
|
+
}
|
|
1420
1583
|
/**
|
|
1421
1584
|
* Check FGA authorization for an HTTP route.
|
|
1422
1585
|
* Returns null if authorized or FGA not configured, or an error object if denied.
|
|
@@ -1509,8 +1672,11 @@ exports.generateOpenAPIDocument = require_route_builder.generateOpenAPIDocument;
|
|
|
1509
1672
|
exports.getCustomHTTPExceptionResponse = getCustomHTTPExceptionResponse;
|
|
1510
1673
|
exports.getCustomRouteHTTPExceptionResponse = getCustomRouteHTTPExceptionResponse;
|
|
1511
1674
|
exports.getEffectivePermission = getEffectivePermission;
|
|
1675
|
+
exports.getEffectiveRBACProvider = getEffectiveRBACProvider;
|
|
1512
1676
|
exports.getFGAProvider = getFGAProvider;
|
|
1513
1677
|
exports.getHTTPErrorResponse = getHTTPErrorResponse;
|
|
1678
|
+
exports.getRoutePermissionError = getRoutePermissionError;
|
|
1679
|
+
exports.invokeRoute = invokeRoute;
|
|
1514
1680
|
exports.isReservedRequestContextKey = require_constants.isReservedRequestContextKey;
|
|
1515
1681
|
exports.isSafeObjectKey = isSafeObjectKey;
|
|
1516
1682
|
exports.isStudioClientTypeHeader = require_constants.isStudioClientTypeHeader;
|
|
@@ -1518,9 +1684,13 @@ exports.isZodError = require_server_handlers_error.isZodError;
|
|
|
1518
1684
|
exports.jsonQueryParam = require_route_builder.jsonQueryParam;
|
|
1519
1685
|
exports.normalizeQueryParams = normalizeQueryParams;
|
|
1520
1686
|
exports.normalizeRoutePath = require_utils.normalizeRoutePath;
|
|
1687
|
+
exports.parseRouteBody = parseRouteBody;
|
|
1688
|
+
exports.parseRoutePathParams = parseRoutePathParams;
|
|
1689
|
+
exports.parseRouteQueryParams = parseRouteQueryParams;
|
|
1521
1690
|
exports.pickParams = require_route_builder.pickParams;
|
|
1522
1691
|
exports.propagateRequestAbort = propagateRequestAbort;
|
|
1523
1692
|
exports.redactStreamChunk = redactStreamChunk;
|
|
1693
|
+
exports.resolveRouteValidationError = resolveRouteValidationError;
|
|
1524
1694
|
exports.serializeStreamChunk = serializeStreamChunk;
|
|
1525
1695
|
exports.wrapSchemaForQueryParams = require_route_builder.wrapSchemaForQueryParams;
|
|
1526
1696
|
|