@mastra/core 1.0.0-beta.1 → 1.0.0-beta.11
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 +1218 -0
- package/dist/agent/agent-legacy.d.ts +35 -30
- package/dist/agent/agent-legacy.d.ts.map +1 -1
- package/dist/agent/agent-types.test-d.d.ts +2 -0
- package/dist/agent/agent-types.test-d.d.ts.map +1 -0
- package/dist/agent/agent.d.ts +24 -9
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.types.d.ts +17 -9
- package/dist/agent/agent.types.d.ts.map +1 -1
- package/dist/agent/index.cjs +9 -9
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/index.cjs +3 -3
- package/dist/agent/message-list/index.d.ts +61 -3
- package/dist/agent/message-list/index.d.ts.map +1 -1
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/message-list/prompt/attachments-to-parts.d.ts.map +1 -1
- package/dist/agent/message-list/prompt/convert-file.d.ts +1 -1
- package/dist/agent/message-list/prompt/convert-file.d.ts.map +1 -1
- package/dist/agent/message-list/prompt/download-assets.d.ts.map +1 -1
- package/dist/agent/save-queue/index.d.ts +3 -1
- package/dist/agent/save-queue/index.d.ts.map +1 -1
- package/dist/agent/test-utils.d.ts +37 -0
- package/dist/agent/test-utils.d.ts.map +1 -1
- package/dist/agent/trip-wire.d.ts +38 -4
- package/dist/agent/trip-wire.d.ts.map +1 -1
- package/dist/agent/types.d.ts +46 -14
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/utils.d.ts +4 -5
- package/dist/agent/utils.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts +37 -13
- package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts +3 -3
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts +34 -11
- package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts +2 -1
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/schema.d.ts +38 -15
- package/dist/agent/workflows/prepare-stream/schema.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts +11 -1
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts.map +1 -1
- package/dist/base.cjs +2 -2
- package/dist/base.js +1 -1
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.js +1 -1
- package/dist/cache/index.cjs +3 -3
- package/dist/cache/index.js +1 -1
- package/dist/{chunk-JUBFO5J3.js → chunk-2ULLRN4Y.js} +16333 -11839
- package/dist/chunk-2ULLRN4Y.js.map +1 -0
- package/dist/{chunk-OJNJA5ZI.js → chunk-3CKZSDTQ.js} +3 -3
- package/dist/{chunk-OJNJA5ZI.js.map → chunk-3CKZSDTQ.js.map} +1 -1
- package/dist/chunk-3E3ILV6T.cjs +518 -0
- package/dist/chunk-3E3ILV6T.cjs.map +1 -0
- package/dist/{chunk-TQTAMPSC.js → chunk-3N3QE4ZK.js} +3 -3
- package/dist/chunk-3N3QE4ZK.js.map +1 -0
- package/dist/{chunk-QUKUN6NR.cjs → chunk-4JKEUSCC.cjs} +107 -7
- package/dist/chunk-4JKEUSCC.cjs.map +1 -0
- package/dist/{chunk-MSWTA73A.cjs → chunk-52RSUALV.cjs} +16490 -11957
- package/dist/chunk-52RSUALV.cjs.map +1 -0
- package/dist/chunk-5PAEYE3Q.js +513 -0
- package/dist/chunk-5PAEYE3Q.js.map +1 -0
- package/dist/{chunk-ECFXGXWO.cjs → chunk-5Q6WAYEY.cjs} +695 -375
- package/dist/chunk-5Q6WAYEY.cjs.map +1 -0
- package/dist/{chunk-CBAB7GOD.cjs → chunk-6BJ7XHRH.cjs} +2 -2
- package/dist/{chunk-CBAB7GOD.cjs.map → chunk-6BJ7XHRH.cjs.map} +1 -1
- package/dist/{chunk-GRBGQ2GE.js → chunk-6TBWJV35.js} +5 -3
- package/dist/chunk-6TBWJV35.js.map +1 -0
- package/dist/chunk-6XCINXZ7.cjs +194 -0
- package/dist/chunk-6XCINXZ7.cjs.map +1 -0
- package/dist/{chunk-E7K4FTLN.cjs → chunk-72YCRTEX.cjs} +18 -2
- package/dist/chunk-72YCRTEX.cjs.map +1 -0
- package/dist/{chunk-W7UH2PWL.js → chunk-7P6BNIJH.js} +1142 -331
- package/dist/chunk-7P6BNIJH.js.map +1 -0
- package/dist/{chunk-76K3IYWM.js → chunk-ADADLFDR.js} +3 -3
- package/dist/{chunk-76K3IYWM.js.map → chunk-ADADLFDR.js.map} +1 -1
- package/dist/{chunk-DSNPWVIG.cjs → chunk-AF74UXR5.cjs} +4 -3
- package/dist/chunk-AF74UXR5.cjs.map +1 -0
- package/dist/{chunk-GGYKYORQ.cjs → chunk-BJXKH4LG.cjs} +407 -22
- package/dist/chunk-BJXKH4LG.cjs.map +1 -0
- package/dist/{chunk-2ZVKF4HP.cjs → chunk-BUKY6CTR.cjs} +1147 -334
- package/dist/chunk-BUKY6CTR.cjs.map +1 -0
- package/dist/chunk-BWYU7D33.js +192 -0
- package/dist/chunk-BWYU7D33.js.map +1 -0
- package/dist/{chunk-XEVG546F.js → chunk-C36YRTZ6.js} +178 -12
- package/dist/chunk-C36YRTZ6.js.map +1 -0
- package/dist/{chunk-CB575O6L.cjs → chunk-CZEJQSWB.cjs} +473 -124
- package/dist/chunk-CZEJQSWB.cjs.map +1 -0
- package/dist/chunk-DD2VNRQM.js +62 -0
- package/dist/chunk-DD2VNRQM.js.map +1 -0
- package/dist/{chunk-KEXGB7FK.cjs → chunk-DGV2FWB4.cjs} +7 -7
- package/dist/{chunk-KEXGB7FK.cjs.map → chunk-DGV2FWB4.cjs.map} +1 -1
- package/dist/{chunk-Y63IFHEZ.cjs → chunk-EOPEDKLG.cjs} +4 -4
- package/dist/chunk-EOPEDKLG.cjs.map +1 -0
- package/dist/{chunk-UIZSWUKP.js → chunk-F2GAJSBI.js} +105 -7
- package/dist/chunk-F2GAJSBI.js.map +1 -0
- package/dist/{chunk-4CDL2QJT.js → chunk-IVV5TOMD.js} +122 -37
- package/dist/chunk-IVV5TOMD.js.map +1 -0
- package/dist/{chunk-MV7KHWUT.js → chunk-JIGDJK2O.js} +391 -15
- package/dist/chunk-JIGDJK2O.js.map +1 -0
- package/dist/chunk-KJBMTK5B.cjs +64 -0
- package/dist/chunk-KJBMTK5B.cjs.map +1 -0
- package/dist/{chunk-S6URFGCZ.js → chunk-LSHPJWM5.js} +3 -3
- package/dist/{chunk-S6URFGCZ.js.map → chunk-LSHPJWM5.js.map} +1 -1
- package/dist/chunk-MGCGWPQJ.cjs +275 -0
- package/dist/chunk-MGCGWPQJ.cjs.map +1 -0
- package/dist/chunk-MRFUISXC.cjs +4981 -0
- package/dist/chunk-MRFUISXC.cjs.map +1 -0
- package/dist/{chunk-KJ2SW6VA.js → chunk-NRUZYMHE.js} +4 -3
- package/dist/chunk-NRUZYMHE.js.map +1 -0
- package/dist/{chunk-CINNK34N.js → chunk-O2BJW7YA.js} +26 -11
- package/dist/chunk-O2BJW7YA.js.map +1 -0
- package/dist/chunk-OEIVMCWX.js +4959 -0
- package/dist/chunk-OEIVMCWX.js.map +1 -0
- package/dist/{chunk-WM6CK2F3.cjs → chunk-PG5H6QIO.cjs} +131 -49
- package/dist/chunk-PG5H6QIO.cjs.map +1 -0
- package/dist/{chunk-JPGVRWWL.js → chunk-PK2A5WBG.js} +472 -125
- package/dist/chunk-PK2A5WBG.js.map +1 -0
- package/dist/{chunk-X7JMA3IY.js → chunk-PSCMWPLC.js} +2 -2
- package/dist/{chunk-X7JMA3IY.js.map → chunk-PSCMWPLC.js.map} +1 -1
- package/dist/{chunk-VOY2RXOC.cjs → chunk-S73Z3PBJ.cjs} +182 -15
- package/dist/chunk-S73Z3PBJ.cjs.map +1 -0
- package/dist/{chunk-MA7TEM62.cjs → chunk-SCUWP4II.cjs} +769 -27
- package/dist/chunk-SCUWP4II.cjs.map +1 -0
- package/dist/{chunk-JV2KH24V.js → chunk-SXNQRJQD.js} +695 -375
- package/dist/chunk-SXNQRJQD.js.map +1 -0
- package/dist/{chunk-BMAFVZ2D.cjs → chunk-T2VLUFGG.cjs} +4 -4
- package/dist/{chunk-BMAFVZ2D.cjs.map → chunk-T2VLUFGG.cjs.map} +1 -1
- package/dist/chunk-THZTRBFS.js +268 -0
- package/dist/chunk-THZTRBFS.js.map +1 -0
- package/dist/{chunk-VOQ3ULMT.js → chunk-U3XOLEPX.js} +759 -17
- package/dist/chunk-U3XOLEPX.js.map +1 -0
- package/dist/{chunk-Y6ROD72V.cjs → chunk-UIGRFDO6.cjs} +4 -4
- package/dist/{chunk-Y6ROD72V.cjs.map → chunk-UIGRFDO6.cjs.map} +1 -1
- package/dist/{chunk-H6CZGPZD.js → chunk-US2U7ECW.js} +179 -38
- package/dist/chunk-US2U7ECW.js.map +1 -0
- package/dist/{chunk-J7O6WENZ.cjs → chunk-UVHSM2GU.cjs} +6 -2
- package/dist/chunk-UVHSM2GU.cjs.map +1 -0
- package/dist/{chunk-CD56CXVE.cjs → chunk-WTSZBHIZ.cjs} +32 -17
- package/dist/chunk-WTSZBHIZ.cjs.map +1 -0
- package/dist/{chunk-KIZIOFZC.js → chunk-Y36Y5MTD.js} +17 -3
- package/dist/chunk-Y36Y5MTD.js.map +1 -0
- package/dist/{chunk-DNEURYF3.cjs → chunk-YC6PJEPH.cjs} +206 -65
- package/dist/chunk-YC6PJEPH.cjs.map +1 -0
- package/dist/{chunk-IQO7ANVS.cjs → chunk-YWMMBIOM.cjs} +21 -20
- package/dist/chunk-YWMMBIOM.cjs.map +1 -0
- package/dist/{chunk-I4CXL4SR.js → chunk-Z57R5WS4.js} +16 -15
- package/dist/chunk-Z57R5WS4.js.map +1 -0
- package/dist/deployer/index.cjs +2 -2
- package/dist/deployer/index.js +1 -1
- package/dist/di/index.cjs +10 -2
- package/dist/di/index.d.ts +1 -1
- package/dist/di/index.d.ts.map +1 -1
- package/dist/di/index.js +1 -1
- package/dist/evals/base.d.ts +10 -2
- package/dist/evals/base.d.ts.map +1 -1
- package/dist/evals/base.test-utils.d.ts +25 -25
- package/dist/evals/index.cjs +9 -9
- package/dist/evals/index.js +2 -2
- package/dist/evals/scoreTraces/index.cjs +7 -6
- package/dist/evals/scoreTraces/index.cjs.map +1 -1
- package/dist/evals/scoreTraces/index.js +4 -3
- package/dist/evals/scoreTraces/index.js.map +1 -1
- package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts.map +1 -1
- package/dist/evals/types.d.ts +25 -24
- package/dist/evals/types.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/integration/index.cjs +2 -2
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.cjs +30 -10
- package/dist/llm/index.d.ts +2 -0
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +5 -1
- package/dist/llm/model/aisdk/v5/model.d.ts +47 -0
- package/dist/llm/model/aisdk/v5/model.d.ts.map +1 -0
- package/dist/llm/model/base.types.d.ts +2 -2
- package/dist/llm/model/base.types.d.ts.map +1 -1
- package/dist/llm/model/gateway-resolver.d.ts.map +1 -1
- package/dist/llm/model/gateways/azure.d.ts +36 -0
- package/dist/llm/model/gateways/azure.d.ts.map +1 -0
- package/dist/llm/model/gateways/base.d.ts +9 -4
- package/dist/llm/model/gateways/base.d.ts.map +1 -1
- package/dist/llm/model/gateways/constants.d.ts.map +1 -1
- package/dist/llm/model/gateways/index.d.ts +4 -1
- package/dist/llm/model/gateways/index.d.ts.map +1 -1
- package/dist/llm/model/gateways/models-dev.d.ts +3 -2
- package/dist/llm/model/gateways/models-dev.d.ts.map +1 -1
- package/dist/llm/model/gateways/netlify.d.ts +4 -3
- package/dist/llm/model/gateways/netlify.d.ts.map +1 -1
- package/dist/llm/model/is-v2-model.d.ts +3 -0
- package/dist/llm/model/is-v2-model.d.ts.map +1 -0
- package/dist/llm/model/model-method-from-agent.d.ts +4 -0
- package/dist/llm/model/model-method-from-agent.d.ts.map +1 -0
- package/dist/llm/model/model.d.ts.map +1 -1
- package/dist/llm/model/model.loop.d.ts +2 -2
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/llm/model/model.loop.types.d.ts +4 -2
- package/dist/llm/model/model.loop.types.d.ts.map +1 -1
- package/dist/llm/model/provider-options.d.ts +4 -1
- package/dist/llm/model/provider-options.d.ts.map +1 -1
- package/dist/llm/model/provider-registry.d.ts +11 -1
- package/dist/llm/model/provider-registry.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +489 -27
- package/dist/llm/model/registry-generator.d.ts +12 -0
- package/dist/llm/model/registry-generator.d.ts.map +1 -1
- package/dist/llm/model/resolve-model.d.ts +1 -1
- package/dist/llm/model/resolve-model.d.ts.map +1 -1
- package/dist/llm/model/router.d.ts +12 -5
- package/dist/llm/model/router.d.ts.map +1 -1
- package/dist/llm/model/shared.types.d.ts +17 -6
- package/dist/llm/model/shared.types.d.ts.map +1 -1
- package/dist/logger/constants.d.ts +1 -0
- package/dist/logger/constants.d.ts.map +1 -1
- package/dist/logger/index.cjs +11 -11
- package/dist/logger/index.js +2 -2
- package/dist/logger/transport.d.ts +1 -1
- package/dist/logger/transport.d.ts.map +1 -1
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/loop/loop.d.ts.map +1 -1
- package/dist/loop/network/index.d.ts.map +1 -1
- package/dist/loop/test-utils/MastraLanguageModelV2Mock.d.ts +37 -0
- package/dist/loop/test-utils/MastraLanguageModelV2Mock.d.ts.map +1 -0
- package/dist/loop/test-utils/fullStream.d.ts.map +1 -1
- package/dist/loop/test-utils/generateText.d.ts.map +1 -1
- package/dist/loop/test-utils/options.d.ts.map +1 -1
- package/dist/loop/test-utils/resultObject.d.ts.map +1 -1
- package/dist/loop/test-utils/streamObject.d.ts.map +1 -1
- package/dist/loop/test-utils/textStream.d.ts.map +1 -1
- package/dist/loop/test-utils/toUIMessageStream.d.ts.map +1 -1
- package/dist/loop/test-utils/tools.d.ts.map +1 -1
- package/dist/loop/test-utils/utils.d.ts +1 -1
- package/dist/loop/test-utils/utils.d.ts.map +1 -1
- package/dist/loop/types.d.ts +42 -20
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +60 -42
- package/dist/loop/workflows/agentic-execution/index.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +41 -29
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +20 -14
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts +1 -1
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts +62 -43
- package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
- package/dist/loop/workflows/run-state.d.ts +2 -2
- package/dist/loop/workflows/run-state.d.ts.map +1 -1
- package/dist/loop/workflows/schema.d.ts +32 -15
- package/dist/loop/workflows/schema.d.ts.map +1 -1
- package/dist/loop/workflows/stream.d.ts +1 -1
- package/dist/loop/workflows/stream.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +377 -12
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/mcp/index.cjs +4 -4
- package/dist/mcp/index.cjs.map +1 -1
- package/dist/mcp/index.d.ts +4 -4
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +2 -2
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/types.d.ts +2 -2
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/memory/index.cjs +21 -327
- package/dist/memory/index.cjs.map +1 -1
- package/dist/memory/index.js +1 -327
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/memory.d.ts +28 -18
- package/dist/memory/memory.d.ts.map +1 -1
- package/dist/memory/mock.d.ts +15 -14
- package/dist/memory/mock.d.ts.map +1 -1
- package/dist/memory/types.d.ts +69 -11
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/models-dev-23RN2WHG.js +3 -0
- package/dist/{models-dev-DNBKXHT4.js.map → models-dev-23RN2WHG.js.map} +1 -1
- package/dist/models-dev-EO3SUIY2.cjs +12 -0
- package/dist/{models-dev-YBEEQIX6.cjs.map → models-dev-EO3SUIY2.cjs.map} +1 -1
- package/dist/netlify-GXJ5D5DD.js +3 -0
- package/dist/{netlify-7G2L5VSH.js.map → netlify-GXJ5D5DD.js.map} +1 -1
- package/dist/netlify-KJLY3GFS.cjs +12 -0
- package/dist/{netlify-GWNGSIRZ.cjs.map → netlify-KJLY3GFS.cjs.map} +1 -1
- package/dist/observability/index.cjs +16 -8
- package/dist/observability/index.js +1 -1
- package/dist/observability/types/tracing.d.ts +236 -13
- package/dist/observability/types/tracing.d.ts.map +1 -1
- package/dist/observability/utils.d.ts +47 -1
- package/dist/observability/utils.d.ts.map +1 -1
- package/dist/processors/index.cjs +115 -11
- package/dist/processors/index.d.ts +246 -26
- package/dist/processors/index.d.ts.map +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/memory/index.d.ts +7 -0
- package/dist/processors/memory/index.d.ts.map +1 -0
- package/dist/processors/memory/message-history.d.ts +43 -0
- package/dist/processors/memory/message-history.d.ts.map +1 -0
- package/dist/processors/memory/semantic-recall.d.ts +152 -0
- package/dist/processors/memory/semantic-recall.d.ts.map +1 -0
- package/dist/processors/memory/working-memory.d.ts +65 -0
- package/dist/processors/memory/working-memory.d.ts.map +1 -0
- package/dist/processors/processors/batch-parts.d.ts +1 -1
- package/dist/processors/processors/batch-parts.d.ts.map +1 -1
- package/dist/processors/processors/index.d.ts +2 -1
- package/dist/processors/processors/index.d.ts.map +1 -1
- package/dist/processors/processors/language-detector.d.ts +15 -1
- package/dist/processors/processors/language-detector.d.ts.map +1 -1
- package/dist/processors/processors/moderation.d.ts +15 -1
- package/dist/processors/processors/moderation.d.ts.map +1 -1
- package/dist/processors/processors/pii-detector.d.ts +15 -1
- package/dist/processors/processors/pii-detector.d.ts.map +1 -1
- package/dist/processors/processors/prepare-step.d.ts +12 -0
- package/dist/processors/processors/prepare-step.d.ts.map +1 -0
- package/dist/processors/processors/prompt-injection-detector.d.ts +15 -1
- package/dist/processors/processors/prompt-injection-detector.d.ts.map +1 -1
- package/dist/processors/processors/structured-output.d.ts +7 -5
- package/dist/processors/processors/structured-output.d.ts.map +1 -1
- package/dist/processors/processors/system-prompt-scrubber.d.ts +1 -1
- package/dist/processors/processors/system-prompt-scrubber.d.ts.map +1 -1
- package/dist/processors/processors/token-limiter.d.ts +22 -12
- package/dist/processors/processors/token-limiter.d.ts.map +1 -1
- package/dist/processors/processors/tool-call-filter.d.ts +28 -0
- package/dist/processors/processors/tool-call-filter.d.ts.map +1 -0
- package/dist/processors/processors/unicode-normalizer.d.ts +1 -1
- package/dist/processors/processors/unicode-normalizer.d.ts.map +1 -1
- package/dist/processors/runner.d.ts +83 -9
- package/dist/processors/runner.d.ts.map +1 -1
- package/dist/processors/step-schema.d.ts +49731 -0
- package/dist/processors/step-schema.d.ts.map +1 -0
- package/dist/provider-registry-3TG2KUD2.cjs +40 -0
- package/dist/provider-registry-3TG2KUD2.cjs.map +1 -0
- package/dist/provider-registry-F67Y6OF2.js +3 -0
- package/dist/provider-registry-F67Y6OF2.js.map +1 -0
- package/dist/provider-registry.json +1056 -61
- package/dist/{registry-generator-MK63POJO.cjs → registry-generator-34SC4TAU.cjs} +23 -6
- package/dist/registry-generator-34SC4TAU.cjs.map +1 -0
- package/dist/{registry-generator-H4YNODDH.js → registry-generator-UMTNPBJX.js} +23 -7
- package/dist/registry-generator-UMTNPBJX.js.map +1 -0
- package/dist/relevance/index.cjs +2 -2
- package/dist/relevance/index.js +1 -1
- package/dist/request-context/index.cjs +10 -2
- package/dist/request-context/index.d.ts +26 -0
- package/dist/request-context/index.d.ts.map +1 -1
- package/dist/request-context/index.js +1 -1
- package/dist/server/auth.d.ts +11 -0
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/base.d.ts +51 -0
- package/dist/server/base.d.ts.map +1 -0
- package/dist/server/composite-auth.d.ts +9 -0
- package/dist/server/composite-auth.d.ts.map +1 -0
- package/dist/server/index.cjs +124 -3
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +121 -3
- package/dist/server/index.js.map +1 -1
- package/dist/server/simple-auth.d.ts +27 -0
- package/dist/server/simple-auth.d.ts.map +1 -0
- package/dist/server/types.d.ts +6 -0
- package/dist/server/types.d.ts.map +1 -1
- package/dist/storage/base.d.ts +76 -3
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/constants.d.ts +3 -1
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/domains/agents/base.d.ts +49 -0
- package/dist/storage/domains/agents/base.d.ts.map +1 -0
- package/dist/storage/domains/agents/index.d.ts +3 -0
- package/dist/storage/domains/agents/index.d.ts.map +1 -0
- package/dist/storage/domains/agents/inmemory.d.ts +22 -0
- package/dist/storage/domains/agents/inmemory.d.ts.map +1 -0
- package/dist/storage/domains/index.d.ts +1 -0
- package/dist/storage/domains/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/operations/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/scores/base.d.ts +2 -2
- package/dist/storage/domains/scores/base.d.ts.map +1 -1
- package/dist/storage/domains/scores/inmemory.d.ts +2 -2
- package/dist/storage/domains/scores/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/workflows/base.d.ts +4 -0
- package/dist/storage/domains/workflows/base.d.ts.map +1 -1
- package/dist/storage/domains/workflows/inmemory.d.ts +5 -1
- package/dist/storage/domains/workflows/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +65 -29
- package/dist/storage/index.js +1 -1
- package/dist/storage/mock.d.ts +7 -2
- package/dist/storage/mock.d.ts.map +1 -1
- package/dist/storage/storageWithInit.d.ts.map +1 -1
- package/dist/storage/types.d.ts +88 -5
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/utils.d.ts +82 -0
- package/dist/storage/utils.d.ts.map +1 -1
- package/dist/stream/MastraAgentNetworkStream.d.ts +2 -2
- package/dist/stream/MastraAgentNetworkStream.d.ts.map +1 -1
- package/dist/stream/MastraWorkflowStream.d.ts +2 -2
- package/dist/stream/MastraWorkflowStream.d.ts.map +1 -1
- package/dist/stream/RunOutput.d.ts +2 -2
- package/dist/stream/RunOutput.d.ts.map +1 -1
- package/dist/stream/aisdk/v4/transform.d.ts.map +1 -1
- package/dist/stream/aisdk/v4/usage.d.ts +19 -0
- package/dist/stream/aisdk/v4/usage.d.ts.map +1 -0
- package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/execute.d.ts +9 -5
- package/dist/stream/aisdk/v5/execute.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/input.d.ts +4 -1
- package/dist/stream/aisdk/v5/input.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/output-helpers.d.ts +5 -1
- package/dist/stream/aisdk/v5/output-helpers.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/output.d.ts +11 -13
- package/dist/stream/aisdk/v5/output.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/transform.d.ts +2 -1
- package/dist/stream/aisdk/v5/transform.d.ts.map +1 -1
- package/dist/stream/base/base.d.ts +1 -1
- package/dist/stream/base/base.d.ts.map +1 -1
- package/dist/stream/base/input.d.ts +1 -1
- package/dist/stream/base/output-format-handlers.d.ts +14 -1
- package/dist/stream/base/output-format-handlers.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts +9 -14
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +15 -11
- package/dist/stream/index.d.ts +2 -2
- package/dist/stream/index.d.ts.map +1 -1
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +97 -32
- package/dist/stream/types.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.cjs +101 -30
- package/dist/test-utils/llm-mock.cjs.map +1 -1
- package/dist/test-utils/llm-mock.d.ts +7 -2
- package/dist/test-utils/llm-mock.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.js +97 -30
- package/dist/test-utils/llm-mock.js.map +1 -1
- package/dist/tools/index.cjs +6 -6
- package/dist/tools/index.js +2 -2
- package/dist/tools/is-vercel-tool.cjs +2 -2
- package/dist/tools/is-vercel-tool.js +1 -1
- package/dist/tools/stream.d.ts +10 -4
- package/dist/tools/stream.d.ts.map +1 -1
- package/dist/tools/tool-builder/builder.d.ts +2 -0
- package/dist/tools/tool-builder/builder.d.ts.map +1 -1
- package/dist/tools/tool-stream-types.test-d.d.ts +2 -0
- package/dist/tools/tool-stream-types.test-d.d.ts.map +1 -0
- package/dist/tools/tool.d.ts +21 -8
- package/dist/tools/tool.d.ts.map +1 -1
- package/dist/tools/types.d.ts +33 -6
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/validation.d.ts +25 -1
- package/dist/tools/validation.d.ts.map +1 -1
- package/dist/tts/index.cjs +2 -2
- package/dist/tts/index.js +1 -1
- package/dist/types/zod-compat.d.ts +14 -1
- package/dist/types/zod-compat.d.ts.map +1 -1
- package/dist/utils.cjs +25 -21
- package/dist/utils.d.ts +9 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/vector/filter/index.cjs +7 -189
- package/dist/vector/filter/index.cjs.map +1 -1
- package/dist/vector/filter/index.js +1 -190
- package/dist/vector/filter/index.js.map +1 -1
- package/dist/vector/index.cjs +7 -2
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.ts +1 -0
- package/dist/vector/index.d.ts.map +1 -1
- package/dist/vector/index.js +2 -1
- package/dist/vector/index.js.map +1 -1
- package/dist/vector/types.d.ts +86 -3
- package/dist/vector/types.d.ts.map +1 -1
- package/dist/vector/vector.d.ts +39 -2
- package/dist/vector/vector.d.ts.map +1 -1
- package/dist/voice/aisdk/index.d.ts +3 -0
- package/dist/voice/aisdk/index.d.ts.map +1 -0
- package/dist/voice/aisdk/speech.d.ts +23 -0
- package/dist/voice/aisdk/speech.d.ts.map +1 -0
- package/dist/voice/aisdk/transcription.d.ts +22 -0
- package/dist/voice/aisdk/transcription.d.ts.map +1 -0
- package/dist/voice/composite-voice.d.ts +4 -3
- package/dist/voice/composite-voice.d.ts.map +1 -1
- package/dist/voice/index.cjs +12 -4
- package/dist/voice/index.d.ts +1 -0
- package/dist/voice/index.d.ts.map +1 -1
- package/dist/voice/index.js +1 -1
- package/dist/workflows/default.d.ts +180 -270
- package/dist/workflows/default.d.ts.map +1 -1
- package/dist/workflows/evented/execution-engine.d.ts +3 -1
- package/dist/workflows/evented/execution-engine.d.ts.map +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/step-executor.d.ts +1 -1
- package/dist/workflows/evented/step-executor.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/index.d.ts +5 -4
- package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/loop.d.ts +1 -1
- package/dist/workflows/evented/workflow-event-processor/loop.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/parallel.d.ts +2 -2
- package/dist/workflows/evented/workflow-event-processor/parallel.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/sleep.d.ts +2 -2
- package/dist/workflows/evented/workflow-event-processor/sleep.d.ts.map +1 -1
- package/dist/workflows/evented/workflow.d.ts +2 -1
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/execution-engine.d.ts +8 -6
- package/dist/workflows/execution-engine.d.ts.map +1 -1
- package/dist/workflows/handlers/control-flow.d.ts +133 -0
- package/dist/workflows/handlers/control-flow.d.ts.map +1 -0
- package/dist/workflows/handlers/entry.d.ts +43 -0
- package/dist/workflows/handlers/entry.d.ts.map +1 -0
- package/dist/workflows/handlers/sleep.d.ts +60 -0
- package/dist/workflows/handlers/sleep.d.ts.map +1 -0
- package/dist/workflows/handlers/step.d.ts +58 -0
- package/dist/workflows/handlers/step.d.ts.map +1 -0
- package/dist/workflows/index.cjs +40 -16
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/step.d.ts +8 -6
- package/dist/workflows/step.d.ts.map +1 -1
- package/dist/workflows/types.d.ts +257 -10
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/utils.d.ts +36 -0
- package/dist/workflows/utils.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts +146 -55
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +26 -30
- package/src/llm/model/provider-types.generated.d.ts +489 -27
- package/dist/chunk-2ZVKF4HP.cjs.map +0 -1
- package/dist/chunk-436FFEF6.js +0 -34
- package/dist/chunk-436FFEF6.js.map +0 -1
- package/dist/chunk-4CDL2QJT.js.map +0 -1
- package/dist/chunk-7AHYOMHJ.js +0 -149
- package/dist/chunk-7AHYOMHJ.js.map +0 -1
- package/dist/chunk-CB575O6L.cjs.map +0 -1
- package/dist/chunk-CD56CXVE.cjs.map +0 -1
- package/dist/chunk-CINNK34N.js.map +0 -1
- package/dist/chunk-DNEURYF3.cjs.map +0 -1
- package/dist/chunk-DSNPWVIG.cjs.map +0 -1
- package/dist/chunk-E7K4FTLN.cjs.map +0 -1
- package/dist/chunk-ECFXGXWO.cjs.map +0 -1
- package/dist/chunk-ET6UOTTU.cjs +0 -154
- package/dist/chunk-ET6UOTTU.cjs.map +0 -1
- package/dist/chunk-GGYKYORQ.cjs.map +0 -1
- package/dist/chunk-GRBGQ2GE.js.map +0 -1
- package/dist/chunk-H6CZGPZD.js.map +0 -1
- package/dist/chunk-HDJFSJCK.js +0 -2237
- package/dist/chunk-HDJFSJCK.js.map +0 -1
- package/dist/chunk-HGNRQ3OG.js +0 -58
- package/dist/chunk-HGNRQ3OG.js.map +0 -1
- package/dist/chunk-I4CXL4SR.js.map +0 -1
- package/dist/chunk-IQO7ANVS.cjs.map +0 -1
- package/dist/chunk-J7O6WENZ.cjs.map +0 -1
- package/dist/chunk-JPGVRWWL.js.map +0 -1
- package/dist/chunk-JUBFO5J3.js.map +0 -1
- package/dist/chunk-JV2KH24V.js.map +0 -1
- package/dist/chunk-KIZIOFZC.js.map +0 -1
- package/dist/chunk-KJ2SW6VA.js.map +0 -1
- package/dist/chunk-LJFJTTZQ.cjs +0 -4
- package/dist/chunk-LJFJTTZQ.cjs.map +0 -1
- package/dist/chunk-LRSB62Z6.cjs +0 -60
- package/dist/chunk-LRSB62Z6.cjs.map +0 -1
- package/dist/chunk-LWBQ4P4N.cjs +0 -2240
- package/dist/chunk-LWBQ4P4N.cjs.map +0 -1
- package/dist/chunk-MA7TEM62.cjs.map +0 -1
- package/dist/chunk-MSWTA73A.cjs.map +0 -1
- package/dist/chunk-MV7KHWUT.js.map +0 -1
- package/dist/chunk-QUKUN6NR.cjs.map +0 -1
- package/dist/chunk-TQTAMPSC.js.map +0 -1
- package/dist/chunk-UIZSWUKP.js.map +0 -1
- package/dist/chunk-V3VLOOSW.cjs +0 -36
- package/dist/chunk-V3VLOOSW.cjs.map +0 -1
- package/dist/chunk-VOQ3ULMT.js.map +0 -1
- package/dist/chunk-VOY2RXOC.cjs.map +0 -1
- package/dist/chunk-W7UH2PWL.js.map +0 -1
- package/dist/chunk-WM6CK2F3.cjs.map +0 -1
- package/dist/chunk-XEVG546F.js.map +0 -1
- package/dist/chunk-Y63IFHEZ.cjs.map +0 -1
- package/dist/chunk-ZV5CC35D.js +0 -3
- package/dist/chunk-ZV5CC35D.js.map +0 -1
- package/dist/models-dev-DNBKXHT4.js +0 -3
- package/dist/models-dev-YBEEQIX6.cjs +0 -12
- package/dist/netlify-7G2L5VSH.js +0 -3
- package/dist/netlify-GWNGSIRZ.cjs +0 -12
- package/dist/registry-generator-H4YNODDH.js.map +0 -1
- package/dist/registry-generator-MK63POJO.cjs.map +0 -1
package/dist/mcp/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mcp/index.ts"],"names":["MastraBase","MastraError","RegisteredLogger","slugify","randomUUID"],"mappings":";;;;;;;;;;;;AA2BO,IAAe,aAAA,GAAf,cAAqCA,4BAAA,CAAW;AAAA;AAAA,EAE7C,QAAA,GAAW,KAAA;AAAA;AAAA,EAEH,IAAA;AAAA;AAAA,EAEA,OAAA;AAAA;AAAA,EAER,GAAA;AAAA;AAAA,EAEQ,WAAA;AAAA;AAAA,EAEA,UAAA;AAAA;AAAA,EAEA,WAAA;AAAA;AAAA,EAEA,QAAA;AAAA;AAAA,EAEA,gBAAA;AAAA;AAAA,EAEA,QAAA;AAAA;AAAA,EAEA,OAAA;AAAA;AAAA,EAET,cAAA;AAAA;AAAA,EAEA,MAAA;AAAA;AAAA,EAEY,MAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,aAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnB,IAAW,EAAA,GAAa;AACtB,IAAA,OAAO,IAAA,CAAK,GAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,KAAA,GAAoD;AAClD,IAAA,OAAO,IAAA,CAAK,cAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,EAAA,EAAY;AAChB,IAAA,IAAI,KAAK,QAAA,EAAU;AACjB,MAAA;AAAA,IACF;AACA,IAAA,IAAA,CAAK,GAAA,GAAM,EAAA;AACX,IAAA,IAAA,CAAK,QAAA,GAAW,IAAA;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AA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IAAA,iBAAe,IAAI,IAAA,IAAO,WAAA,EAAY;AAChE,IAAA,IAAA,CAAK,QAAA,GAAW,MAAA,CAAO,QAAA,KAAa,MAAA,GAAY,OAAO,MAAA,CAAO,QAAA;AAC9D,IAAA,IAAA,CAAK,mBAAmB,MAAA,CAAO,gBAAA;AAC/B,IAAA,IAAA,CAAK,WAAW,MAAA,CAAO,QAAA;AACvB,IAAA,IAAA,CAAK,UAAU,MAAA,CAAO,OAAA;AACtB,IAAA,IAAA,CAAK,SAAS,MAAA,CAAO,MAAA;AACrB,IAAA,IAAA,CAAK,YAAY,MAAA,CAAO,SAAA;AACxB,IAAA,IAAA,CAAK,gBAAgB,MAAA,CAAO,KAAA;AAC5B,IAAA,IAAA,CAAK,cAAA,GAAiB,KAAK,YAAA,CAAa,MAAA,CAAO,OAAO,MAAA,CAAO,MAAA,EAAQ,OAAO,SAAS,CAAA;AAAA,EACvF;AA6EF","file":"index.cjs","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport slugify from '@sindresorhus/slugify';\nimport type { ToolsInput } from '../agent';\nimport { MastraBase } from '../base';\nimport { MastraError } from '../error';\nimport { RegisteredLogger } from '../logger';\nimport type { Mastra } from '../mastra';\nimport type { InternalCoreTool, MCPToolType, ToolAction, ToolExecutionContext } from '../tools';\nimport type {\n MCPServerConfig,\n MCPServerHonoSSEOptions,\n MCPServerHTTPOptions,\n MCPServerSSEOptions,\n PackageInfo,\n RemoteInfo,\n Repository,\n ServerDetailInfo,\n ServerInfo,\n} from './types';\nexport * from './types';\nexport type { MCPToolType } from '../tools';\n\n/**\n * Abstract base class for MCP server implementations.\n * This provides a common interface and shared functionality for all MCP servers\n * that can be registered with Mastra, including handling of server metadata.\n */\nexport abstract class MCPServerBase extends MastraBase {\n /** Tracks if the server ID has been definitively set. */\n private idWasSet = false;\n /** The display name of the MCP server. */\n public readonly name: string;\n /** The semantic version of the MCP server. */\n public readonly version: string;\n /** Internal storage for the server's unique ID. */\n private _id: string;\n /** A description of what the MCP server does. */\n public readonly description?: string;\n /** Repository information for the server's source code. */\n public readonly repository?: Repository;\n /** The release date of this server version (ISO 8601 string). */\n public readonly releaseDate: string;\n /** Indicates if this version is the latest available. */\n public readonly isLatest: boolean;\n /** The canonical packaging format (e.g., \"npm\", \"docker\"), if applicable. */\n public readonly packageCanonical?: MCPServerConfig['packageCanonical'];\n /** Information about installable packages for this server. */\n public readonly packages?: PackageInfo[];\n /** Information about remote access points for this server. */\n public readonly remotes?: RemoteInfo[];\n /** The tools registered with and converted by this MCP server. */\n public convertedTools: Record<string, InternalCoreTool>;\n /** Reference to the Mastra instance if this server is registered with one. */\n public mastra: Mastra | undefined;\n /** Agents to be exposed as tools. */\n protected readonly agents?: MCPServerConfig['agents'];\n /** Workflows to be exposed as tools. */\n protected readonly workflows?: MCPServerConfig['workflows'];\n /** Original tools configuration for re-conversion when Mastra instance is registered. */\n protected readonly originalTools: ToolsInput;\n\n /**\n * Public getter for the server's unique ID.\n * The ID is set at construction or by Mastra and is read-only afterwards.\n */\n public get id(): string {\n return this._id;\n }\n\n /**\n * Gets a read-only view of the registered tools.\n * @returns A readonly record of converted tools.\n */\n tools(): Readonly<Record<string, InternalCoreTool>> {\n return this.convertedTools;\n }\n\n /**\n * Sets the server's unique ID. This method is typically called by Mastra when\n * registering the server, using the key provided in the Mastra configuration.\n * It ensures the ID is set only once.\n * If an ID was already provided in the MCPServerConfig, this method will be a no-op.\n * @param id The unique ID to assign to the server.\n */\n setId(id: string) {\n if (this.idWasSet) {\n return;\n }\n this._id = id;\n this.idWasSet = true;\n }\n\n /**\n * Abstract method to convert and validate tool definitions provided to the server.\n * This method will also handle agents passed in the config.\n * @param tools Tool definitions to convert.\n * @param agents Agent definitions to convert to tools.\n * @param workflows Workflow definitions to convert to tools.\n * @returns A record of converted and validated tools.\n */\n public abstract convertTools(\n tools: ToolsInput,\n agents?: MCPServerConfig['agents'],\n workflows?: MCPServerConfig['workflows'],\n ): Record<string, InternalCoreTool>;\n\n /**\n * Internal method used by Mastra to register itself with the server.\n * @param mastra The Mastra instance.\n * @internal\n */\n __registerMastra(mastra: Mastra): void {\n this.mastra = mastra;\n // Re-convert tools now that we have the Mastra instance to populate MCP tools execute with mastra instance\n this.convertedTools = this.convertTools(this.originalTools, this.agents, this.workflows);\n\n // Auto-register tools with the Mastra instance\n if (this.originalTools && typeof this.originalTools === 'object') {\n Object.entries(this.originalTools).forEach(([key, tool]) => {\n try {\n // Only add tools that have an id property (ToolAction type)\n if (tool && typeof tool === 'object' && 'id' in tool) {\n // Use tool's intrinsic ID to avoid collisions across MCP servers\n const toolKey = typeof (tool as any).id === 'string' ? (tool as any).id : key;\n mastra.addTool(tool as ToolAction<any, any, any, any, ToolExecutionContext<any, any>>, toolKey);\n }\n } catch (error) {\n // Tool might already be registered, that's okay\n if (!(error instanceof MastraError) || error.id !== 'MASTRA_ADD_TOOL_DUPLICATE_KEY') {\n throw error;\n }\n }\n });\n }\n\n // Auto-register agents with the Mastra instance\n if (this.agents && typeof this.agents === 'object') {\n Object.entries(this.agents).forEach(([key, agent]) => {\n try {\n mastra.addAgent(agent, key);\n } catch (error) {\n // Agent might already be registered, that's okay\n if (!(error instanceof MastraError) || error.id !== 'MASTRA_ADD_AGENT_DUPLICATE_KEY') {\n throw error;\n }\n }\n });\n }\n\n // Auto-register workflows with the Mastra instance\n if (this.workflows && typeof this.workflows === 'object') {\n Object.entries(this.workflows).forEach(([key, workflow]) => {\n try {\n mastra.addWorkflow(workflow, key);\n } catch (error) {\n // Workflow might already be registered, that's okay\n if (!(error instanceof MastraError) || error.id !== 'MASTRA_ADD_WORKFLOW_DUPLICATE_KEY') {\n throw error;\n }\n }\n });\n }\n }\n\n /**\n * Constructor for the MCPServerBase.\n * @param config Configuration options for the MCP server, including metadata.\n */\n constructor(config: MCPServerConfig) {\n super({ component: RegisteredLogger.MCP_SERVER, name: config.name });\n this.name = config.name;\n this.version = config.version;\n\n // If user does not provide an ID, we will use the key from the Mastra config, but if user does not pass MCPServer\n // to Mastra, we will generate a random UUID as a backup.\n if (config.id) {\n this._id = slugify(config.id);\n this.idWasSet = true;\n } else {\n this._id = this.mastra?.generateId() || randomUUID();\n }\n\n this.description = config.description;\n this.repository = config.repository;\n this.releaseDate = config.releaseDate || new Date().toISOString();\n this.isLatest = config.isLatest === undefined ? true : config.isLatest;\n this.packageCanonical = config.packageCanonical;\n this.packages = config.packages;\n this.remotes = config.remotes;\n this.agents = config.agents;\n this.workflows = config.workflows;\n this.originalTools = config.tools;\n this.convertedTools = this.convertTools(config.tools, config.agents, config.workflows);\n }\n\n /**\n * Start the MCP server using stdio transport\n * This is typically used for Windsurf integration\n */\n public abstract startStdio(): Promise<void>;\n\n /**\n * Start the MCP server using SSE transport\n * This is typically used for web integration\n * @param options Options for the SSE transport\n */\n public abstract startSSE(options: MCPServerSSEOptions): Promise<void>;\n\n /**\n * Start the MCP server using Hono SSE transport\n * Used for Hono servers\n * @param options Options for the SSE transport\n */\n public abstract startHonoSSE(options: MCPServerHonoSSEOptions): Promise<Response | undefined>;\n\n /**\n * Start the MCP server using HTTP transport\n * @param options Options for the HTTP transport\n */\n public abstract startHTTP(options: MCPServerHTTPOptions): Promise<void>;\n\n /**\n * Close the MCP server and all its connections\n */\n public abstract close(): Promise<void>;\n\n /**\n * Gets the basic information about the server, conforming to the MCP Registry 'Server' schema.\n * This information is suitable for listing multiple servers.\n * @returns ServerInfo object containing basic server metadata.\n */\n public abstract getServerInfo(): ServerInfo;\n\n /**\n * Gets detailed information about the server, conforming to the MCP Registry 'ServerDetail' schema.\n * This includes all information from `getServerInfo` plus package and remote details.\n * @returns ServerDetailInfo object containing comprehensive server metadata.\n */\n public abstract getServerDetail(): ServerDetailInfo;\n\n /**\n * Gets a list of tools provided by this MCP server, including their schemas.\n * @returns An object containing an array of tool information.\n */\n public abstract getToolListInfo(): {\n tools: Array<{ name: string; description?: string; inputSchema: any; outputSchema?: any; toolType?: MCPToolType }>;\n };\n\n /**\n * Gets information for a specific tool provided by this MCP server.\n * @param toolId The ID/name of the tool to retrieve.\n * @returns Tool information (name, description, inputSchema) or undefined if not found.\n */\n public abstract getToolInfo(\n toolId: string,\n ): { name: string; description?: string; inputSchema: any; outputSchema?: any; toolType?: MCPToolType } | undefined;\n\n /**\n * Executes a specific tool provided by this MCP server.\n * @param toolId The ID/name of the tool to execute.\n * @param args The arguments to pass to the tool's execute function.\n * @param executionContext Optional context for the tool execution (e.g., messages, toolCallId).\n * @returns A promise that resolves to the result of the tool execution.\n * @throws Error if the tool is not found, or if execution fails.\n */\n public abstract executeTool(\n toolId: string,\n args: any,\n executionContext?: { messages?: any[]; toolCallId?: string },\n ): Promise<any>;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/index.ts"],"names":["MastraBase","MastraError","RegisteredLogger","slugify","randomUUID"],"mappings":";;;;;;;;;;;;AA2BO,IAAe,aAAA,GAAf,cAAkEA,4BAAA,CAAW;AAAA;AAAA,EAE1E,QAAA,GAAW,KAAA;AAAA;AAAA,EAEH,IAAA;AAAA;AAAA,EAEA,OAAA;AAAA;AAAA,EAER,GAAA;AAAA;AAAA,EAEQ,WAAA;AAAA;AAAA,EAEA,UAAA;AAAA;AAAA,EAEA,WAAA;AAAA;AAAA,EAEA,QAAA;AAAA;AAAA,EAEA,gBAAA;AAAA;AAAA,EAEA,QAAA;AAAA;AAAA,EAEA,OAAA;AAAA;AAAA,EAET,cAAA;AAAA;AAAA,EAEA,MAAA;AAAA;AAAA,EAEY,MAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,aAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnB,IAAW,EAAA,GAAU;AACnB,IAAA,OAAO,IAAA,CAAK,GAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,KAAA,GAAoD;AAClD,IAAA,OAAO,IAAA,CAAK,cAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,EAAA,EAAS;A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AgBC,iBAAA,EAAW;AAAA,IACtD;AAEA,IAAA,IAAA,CAAK,cAAc,MAAA,CAAO,WAAA;AAC1B,IAAA,IAAA,CAAK,aAAa,MAAA,CAAO,UAAA;AACzB,IAAA,IAAA,CAAK,cAAc,MAAA,CAAO,WAAA,IAAA,iBAAe,IAAI,IAAA,IAAO,WAAA,EAAY;AAChE,IAAA,IAAA,CAAK,QAAA,GAAW,MAAA,CAAO,QAAA,KAAa,MAAA,GAAY,OAAO,MAAA,CAAO,QAAA;AAC9D,IAAA,IAAA,CAAK,mBAAmB,MAAA,CAAO,gBAAA;AAC/B,IAAA,IAAA,CAAK,WAAW,MAAA,CAAO,QAAA;AACvB,IAAA,IAAA,CAAK,UAAU,MAAA,CAAO,OAAA;AACtB,IAAA,IAAA,CAAK,SAAS,MAAA,CAAO,MAAA;AACrB,IAAA,IAAA,CAAK,YAAY,MAAA,CAAO,SAAA;AACxB,IAAA,IAAA,CAAK,gBAAgB,MAAA,CAAO,KAAA;AAC5B,IAAA,IAAA,CAAK,cAAA,GAAiB,KAAK,YAAA,CAAa,MAAA,CAAO,OAAO,MAAA,CAAO,MAAA,EAAQ,OAAO,SAAS,CAAA;AAAA,EACvF;AA6EF","file":"index.cjs","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport slugify from '@sindresorhus/slugify';\nimport type { ToolsInput } from '../agent';\nimport { MastraBase } from '../base';\nimport { MastraError } from '../error';\nimport { RegisteredLogger } from '../logger';\nimport type { Mastra } from '../mastra';\nimport type { InternalCoreTool, MCPToolType, ToolAction, ToolExecutionContext } from '../tools';\nimport type {\n MCPServerConfig,\n MCPServerHonoSSEOptions,\n MCPServerHTTPOptions,\n MCPServerSSEOptions,\n PackageInfo,\n RemoteInfo,\n Repository,\n ServerDetailInfo,\n ServerInfo,\n} from './types';\nexport * from './types';\nexport type { MCPToolType } from '../tools';\n\n/**\n * Abstract base class for MCP server implementations.\n * This provides a common interface and shared functionality for all MCP servers\n * that can be registered with Mastra, including handling of server metadata.\n */\nexport abstract class MCPServerBase<TId extends string = string> extends MastraBase {\n /** Tracks if the server ID has been definitively set. */\n private idWasSet = false;\n /** The display name of the MCP server. */\n public readonly name: string;\n /** The semantic version of the MCP server. */\n public readonly version: string;\n /** Internal storage for the server's unique ID. */\n private _id: TId;\n /** A description of what the MCP server does. */\n public readonly description?: string;\n /** Repository information for the server's source code. */\n public readonly repository?: Repository;\n /** The release date of this server version (ISO 8601 string). */\n public readonly releaseDate: string;\n /** Indicates if this version is the latest available. */\n public readonly isLatest: boolean;\n /** The canonical packaging format (e.g., \"npm\", \"docker\"), if applicable. */\n public readonly packageCanonical?: MCPServerConfig['packageCanonical'];\n /** Information about installable packages for this server. */\n public readonly packages?: PackageInfo[];\n /** Information about remote access points for this server. */\n public readonly remotes?: RemoteInfo[];\n /** The tools registered with and converted by this MCP server. */\n public convertedTools: Record<string, InternalCoreTool>;\n /** Reference to the Mastra instance if this server is registered with one. */\n public mastra: Mastra | undefined;\n /** Agents to be exposed as tools. */\n protected readonly agents?: MCPServerConfig['agents'];\n /** Workflows to be exposed as tools. */\n protected readonly workflows?: MCPServerConfig['workflows'];\n /** Original tools configuration for re-conversion when Mastra instance is registered. */\n protected readonly originalTools: ToolsInput;\n\n /**\n * Public getter for the server's unique ID.\n * The ID is set at construction or by Mastra and is read-only afterwards.\n */\n public get id(): TId {\n return this._id;\n }\n\n /**\n * Gets a read-only view of the registered tools.\n * @returns A readonly record of converted tools.\n */\n tools(): Readonly<Record<string, InternalCoreTool>> {\n return this.convertedTools;\n }\n\n /**\n * Sets the server's unique ID. This method is typically called by Mastra when\n * registering the server, using the key provided in the Mastra configuration.\n * It ensures the ID is set only once.\n * If an ID was already provided in the MCPServerConfig, this method will be a no-op.\n * @param id The unique ID to assign to the server.\n */\n setId(id: TId) {\n if (this.idWasSet) {\n return;\n }\n this._id = id;\n this.idWasSet = true;\n }\n\n /**\n * Abstract method to convert and validate tool definitions provided to the server.\n * This method will also handle agents passed in the config.\n * @param tools Tool definitions to convert.\n * @param agents Agent definitions to convert to tools.\n * @param workflows Workflow definitions to convert to tools.\n * @returns A record of converted and validated tools.\n */\n public abstract convertTools(\n tools: ToolsInput,\n agents?: MCPServerConfig['agents'],\n workflows?: MCPServerConfig['workflows'],\n ): Record<string, InternalCoreTool>;\n\n /**\n * Internal method used by Mastra to register itself with the server.\n * @param mastra The Mastra instance.\n * @internal\n */\n __registerMastra(mastra: Mastra): void {\n this.mastra = mastra;\n // Re-convert tools now that we have the Mastra instance to populate MCP tools execute with mastra instance\n this.convertedTools = this.convertTools(this.originalTools, this.agents, this.workflows);\n\n // Auto-register tools with the Mastra instance\n if (this.originalTools && typeof this.originalTools === 'object') {\n Object.entries(this.originalTools).forEach(([key, tool]) => {\n try {\n // Only add tools that have an id property (ToolAction type)\n if (tool && typeof tool === 'object' && 'id' in tool) {\n // Use tool's intrinsic ID to avoid collisions across MCP servers\n const toolKey = typeof (tool as any).id === 'string' ? (tool as any).id : key;\n mastra.addTool(tool as ToolAction<any, any, any, any, ToolExecutionContext<any, any>>, toolKey);\n }\n } catch (error) {\n // Tool might already be registered, that's okay\n if (!(error instanceof MastraError) || error.id !== 'MASTRA_ADD_TOOL_DUPLICATE_KEY') {\n throw error;\n }\n }\n });\n }\n\n // Auto-register agents with the Mastra instance\n if (this.agents && typeof this.agents === 'object') {\n Object.entries(this.agents).forEach(([key, agent]) => {\n try {\n mastra.addAgent(agent, key);\n } catch (error) {\n // Agent might already be registered, that's okay\n if (!(error instanceof MastraError) || error.id !== 'MASTRA_ADD_AGENT_DUPLICATE_KEY') {\n throw error;\n }\n }\n });\n }\n\n // Auto-register workflows with the Mastra instance\n if (this.workflows && typeof this.workflows === 'object') {\n Object.entries(this.workflows).forEach(([key, workflow]) => {\n try {\n mastra.addWorkflow(workflow, key);\n } catch (error) {\n // Workflow might already be registered, that's okay\n if (!(error instanceof MastraError) || error.id !== 'MASTRA_ADD_WORKFLOW_DUPLICATE_KEY') {\n throw error;\n }\n }\n });\n }\n }\n\n /**\n * Constructor for the MCPServerBase.\n * @param config Configuration options for the MCP server, including metadata.\n */\n constructor(config: MCPServerConfig<TId>) {\n super({ component: RegisteredLogger.MCP_SERVER, name: config.name });\n this.name = config.name;\n this.version = config.version;\n\n // If user does not provide an ID, we will use the key from the Mastra config, but if user does not pass MCPServer\n // to Mastra, we will generate a random UUID as a backup.\n if (config.id) {\n this._id = slugify(config.id) as TId;\n this.idWasSet = true;\n } else {\n this._id = (this.mastra?.generateId() || randomUUID()) as TId;\n }\n\n this.description = config.description;\n this.repository = config.repository;\n this.releaseDate = config.releaseDate || new Date().toISOString();\n this.isLatest = config.isLatest === undefined ? true : config.isLatest;\n this.packageCanonical = config.packageCanonical;\n this.packages = config.packages;\n this.remotes = config.remotes;\n this.agents = config.agents;\n this.workflows = config.workflows;\n this.originalTools = config.tools;\n this.convertedTools = this.convertTools(config.tools, config.agents, config.workflows);\n }\n\n /**\n * Start the MCP server using stdio transport\n * This is typically used for Windsurf integration\n */\n public abstract startStdio(): Promise<void>;\n\n /**\n * Start the MCP server using SSE transport\n * This is typically used for web integration\n * @param options Options for the SSE transport\n */\n public abstract startSSE(options: MCPServerSSEOptions): Promise<void>;\n\n /**\n * Start the MCP server using Hono SSE transport\n * Used for Hono servers\n * @param options Options for the SSE transport\n */\n public abstract startHonoSSE(options: MCPServerHonoSSEOptions): Promise<Response | undefined>;\n\n /**\n * Start the MCP server using HTTP transport\n * @param options Options for the HTTP transport\n */\n public abstract startHTTP(options: MCPServerHTTPOptions): Promise<void>;\n\n /**\n * Close the MCP server and all its connections\n */\n public abstract close(): Promise<void>;\n\n /**\n * Gets the basic information about the server, conforming to the MCP Registry 'Server' schema.\n * This information is suitable for listing multiple servers.\n * @returns ServerInfo object containing basic server metadata.\n */\n public abstract getServerInfo(): ServerInfo;\n\n /**\n * Gets detailed information about the server, conforming to the MCP Registry 'ServerDetail' schema.\n * This includes all information from `getServerInfo` plus package and remote details.\n * @returns ServerDetailInfo object containing comprehensive server metadata.\n */\n public abstract getServerDetail(): ServerDetailInfo;\n\n /**\n * Gets a list of tools provided by this MCP server, including their schemas.\n * @returns An object containing an array of tool information.\n */\n public abstract getToolListInfo(): {\n tools: Array<{ name: string; description?: string; inputSchema: any; outputSchema?: any; toolType?: MCPToolType }>;\n };\n\n /**\n * Gets information for a specific tool provided by this MCP server.\n * @param toolId The ID/name of the tool to retrieve.\n * @returns Tool information (name, description, inputSchema) or undefined if not found.\n */\n public abstract getToolInfo(\n toolId: string,\n ): { name: string; description?: string; inputSchema: any; outputSchema?: any; toolType?: MCPToolType } | undefined;\n\n /**\n * Executes a specific tool provided by this MCP server.\n * @param toolId The ID/name of the tool to execute.\n * @param args The arguments to pass to the tool's execute function.\n * @param executionContext Optional context for the tool execution (e.g., messages, toolCallId).\n * @returns A promise that resolves to the result of the tool execution.\n * @throws Error if the tool is not found, or if execution fails.\n */\n public abstract executeTool(\n toolId: string,\n args: any,\n executionContext?: { messages?: any[]; toolCallId?: string },\n ): Promise<any>;\n}\n"]}
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type { MCPToolType } from '../tools/index.js';
|
|
|
10
10
|
* This provides a common interface and shared functionality for all MCP servers
|
|
11
11
|
* that can be registered with Mastra, including handling of server metadata.
|
|
12
12
|
*/
|
|
13
|
-
export declare abstract class MCPServerBase extends MastraBase {
|
|
13
|
+
export declare abstract class MCPServerBase<TId extends string = string> extends MastraBase {
|
|
14
14
|
/** Tracks if the server ID has been definitively set. */
|
|
15
15
|
private idWasSet;
|
|
16
16
|
/** The display name of the MCP server. */
|
|
@@ -47,7 +47,7 @@ export declare abstract class MCPServerBase extends MastraBase {
|
|
|
47
47
|
* Public getter for the server's unique ID.
|
|
48
48
|
* The ID is set at construction or by Mastra and is read-only afterwards.
|
|
49
49
|
*/
|
|
50
|
-
get id():
|
|
50
|
+
get id(): TId;
|
|
51
51
|
/**
|
|
52
52
|
* Gets a read-only view of the registered tools.
|
|
53
53
|
* @returns A readonly record of converted tools.
|
|
@@ -60,7 +60,7 @@ export declare abstract class MCPServerBase extends MastraBase {
|
|
|
60
60
|
* If an ID was already provided in the MCPServerConfig, this method will be a no-op.
|
|
61
61
|
* @param id The unique ID to assign to the server.
|
|
62
62
|
*/
|
|
63
|
-
setId(id:
|
|
63
|
+
setId(id: TId): void;
|
|
64
64
|
/**
|
|
65
65
|
* Abstract method to convert and validate tool definitions provided to the server.
|
|
66
66
|
* This method will also handle agents passed in the config.
|
|
@@ -80,7 +80,7 @@ export declare abstract class MCPServerBase extends MastraBase {
|
|
|
80
80
|
* Constructor for the MCPServerBase.
|
|
81
81
|
* @param config Configuration options for the MCP server, including metadata.
|
|
82
82
|
*/
|
|
83
|
-
constructor(config: MCPServerConfig);
|
|
83
|
+
constructor(config: MCPServerConfig<TId>);
|
|
84
84
|
/**
|
|
85
85
|
* Start the MCP server using stdio transport
|
|
86
86
|
* This is typically used for Windsurf integration
|
package/dist/mcp/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAoC,MAAM,UAAU,CAAC;AAChG,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,UAAU,EACX,MAAM,SAAS,CAAC;AACjB,cAAc,SAAS,CAAC;AACxB,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;;;GAIG;AACH,8BAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp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AO,CAAC,IAAI,CAAC;IAEtC;;;;OAIG;aACa,aAAa,IAAI,UAAU;IAE3C;;;;OAIG;aACa,eAAe,IAAI,gBAAgB;IAEnD;;;OAGG;aACa,eAAe,IAAI;QACjC,KAAK,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,WAAW,CAAC,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,GAAG,CAAC;YAAC,YAAY,CAAC,EAAE,GAAG,CAAC;YAAC,QAAQ,CAAC,EAAE,WAAW,CAAA;SAAE,CAAC,CAAC;KACpH;IAED;;;;OAIG;aACa,WAAW,CACzB,MAAM,EAAE,MAAM,GACb;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,GAAG,CAAC;QAAC,YAAY,CAAC,EAAE,GAAG,CAAC;QAAC,QAAQ,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,SAAS;IAEnH;;;;;;;OAOG;aACa,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,GAAG,EACT,gBAAgB,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAC3D,OAAO,CAAC,GAAG,CAAC;CAChB"}
|
package/dist/mcp/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MastraError } from '../chunk-JJ5O45LH.js';
|
|
2
|
-
import { MastraBase } from '../chunk-
|
|
3
|
-
import { RegisteredLogger } from '../chunk-
|
|
2
|
+
import { MastraBase } from '../chunk-LSHPJWM5.js';
|
|
3
|
+
import { RegisteredLogger } from '../chunk-NRUZYMHE.js';
|
|
4
4
|
import { randomUUID } from 'crypto';
|
|
5
5
|
import slugify from '@sindresorhus/slugify';
|
|
6
6
|
|
package/dist/mcp/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["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S,MAAA,CAAO,MAAA;AACrB,IAAA,IAAA,CAAK,YAAY,MAAA,CAAO,SAAA;AACxB,IAAA,IAAA,CAAK,gBAAgB,MAAA,CAAO,KAAA;AAC5B,IAAA,IAAA,CAAK,cAAA,GAAiB,KAAK,YAAA,CAAa,MAAA,CAAO,OAAO,MAAA,CAAO,MAAA,EAAQ,OAAO,SAAS,CAAA;AAAA,EACvF;AA6EF","file":"index.js","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport slugify from '@sindresorhus/slugify';\nimport type { ToolsInput } from '../agent';\nimport { MastraBase } from '../base';\nimport { MastraError } from '../error';\nimport { RegisteredLogger } from '../logger';\nimport type { Mastra } from '../mastra';\nimport type { InternalCoreTool, MCPToolType, ToolAction, ToolExecutionContext } from '../tools';\nimport type {\n MCPServerConfig,\n MCPServerHonoSSEOptions,\n MCPServerHTTPOptions,\n MCPServerSSEOptions,\n PackageInfo,\n RemoteInfo,\n Repository,\n ServerDetailInfo,\n ServerInfo,\n} from './types';\nexport * from './types';\nexport type { MCPToolType } from '../tools';\n\n/**\n * Abstract base class for MCP server implementations.\n * This provides a common interface and shared functionality for all MCP servers\n * that can be registered with Mastra, including handling of server metadata.\n */\nexport abstract class MCPServerBase extends MastraBase {\n /** Tracks if the server ID has been definitively set. */\n private idWasSet = false;\n /** The display name of the MCP server. */\n public readonly name: string;\n /** The semantic version of the MCP server. */\n public readonly version: string;\n /** Internal storage for the server's unique ID. */\n private _id: string;\n /** A description of what the MCP server does. */\n public readonly description?: string;\n /** Repository information for the server's source code. */\n public readonly repository?: Repository;\n /** The release date of this server version (ISO 8601 string). */\n public readonly releaseDate: string;\n /** Indicates if this version is the latest available. */\n public readonly isLatest: boolean;\n /** The canonical packaging format (e.g., \"npm\", \"docker\"), if applicable. */\n public readonly packageCanonical?: MCPServerConfig['packageCanonical'];\n /** Information about installable packages for this server. */\n public readonly packages?: PackageInfo[];\n /** Information about remote access points for this server. */\n public readonly remotes?: RemoteInfo[];\n /** The tools registered with and converted by this MCP server. */\n public convertedTools: Record<string, InternalCoreTool>;\n /** Reference to the Mastra instance if this server is registered with one. */\n public mastra: Mastra | undefined;\n /** Agents to be exposed as tools. */\n protected readonly agents?: MCPServerConfig['agents'];\n /** Workflows to be exposed as tools. */\n protected readonly workflows?: MCPServerConfig['workflows'];\n /** Original tools configuration for re-conversion when Mastra instance is registered. */\n protected readonly originalTools: ToolsInput;\n\n /**\n * Public getter for the server's unique ID.\n * The ID is set at construction or by Mastra and is read-only afterwards.\n */\n public get id(): string {\n return this._id;\n }\n\n /**\n * Gets a read-only view of the registered tools.\n * @returns A readonly record of converted tools.\n */\n tools(): Readonly<Record<string, InternalCoreTool>> {\n return this.convertedTools;\n }\n\n /**\n * Sets the server's unique ID. This method is typically called by Mastra when\n * registering the server, using the key provided in the Mastra configuration.\n * It ensures the ID is set only once.\n * If an ID was already provided in the MCPServerConfig, this method will be a no-op.\n * @param id The unique ID to assign to the server.\n */\n setId(id: string) {\n if (this.idWasSet) {\n return;\n }\n this._id = id;\n this.idWasSet = true;\n }\n\n /**\n * Abstract method to convert and validate tool definitions provided to the server.\n * This method will also handle agents passed in the config.\n * @param tools Tool definitions to convert.\n * @param agents Agent definitions to convert to tools.\n * @param workflows Workflow definitions to convert to tools.\n * @returns A record of converted and validated tools.\n */\n public abstract convertTools(\n tools: ToolsInput,\n agents?: MCPServerConfig['agents'],\n workflows?: MCPServerConfig['workflows'],\n ): Record<string, InternalCoreTool>;\n\n /**\n * Internal method used by Mastra to register itself with the server.\n * @param mastra The Mastra instance.\n * @internal\n */\n __registerMastra(mastra: Mastra): void {\n this.mastra = mastra;\n // Re-convert tools now that we have the Mastra instance to populate MCP tools execute with mastra instance\n this.convertedTools = this.convertTools(this.originalTools, this.agents, this.workflows);\n\n // Auto-register tools with the Mastra instance\n if (this.originalTools && typeof this.originalTools === 'object') {\n Object.entries(this.originalTools).forEach(([key, tool]) => {\n try {\n // Only add tools that have an id property (ToolAction type)\n if (tool && typeof tool === 'object' && 'id' in tool) {\n // Use tool's intrinsic ID to avoid collisions across MCP servers\n const toolKey = typeof (tool as any).id === 'string' ? (tool as any).id : key;\n mastra.addTool(tool as ToolAction<any, any, any, any, ToolExecutionContext<any, any>>, toolKey);\n }\n } catch (error) {\n // Tool might already be registered, that's okay\n if (!(error instanceof MastraError) || error.id !== 'MASTRA_ADD_TOOL_DUPLICATE_KEY') {\n throw error;\n }\n }\n });\n }\n\n // Auto-register agents with the Mastra instance\n if (this.agents && typeof this.agents === 'object') {\n Object.entries(this.agents).forEach(([key, agent]) => {\n try {\n mastra.addAgent(agent, key);\n } catch (error) {\n // Agent might already be registered, that's okay\n if (!(error instanceof MastraError) || error.id !== 'MASTRA_ADD_AGENT_DUPLICATE_KEY') {\n throw error;\n }\n }\n });\n }\n\n // Auto-register workflows with the Mastra instance\n if (this.workflows && typeof this.workflows === 'object') {\n Object.entries(this.workflows).forEach(([key, workflow]) => {\n try {\n mastra.addWorkflow(workflow, key);\n } catch (error) {\n // Workflow might already be registered, that's okay\n if (!(error instanceof MastraError) || error.id !== 'MASTRA_ADD_WORKFLOW_DUPLICATE_KEY') {\n throw error;\n }\n }\n });\n }\n }\n\n /**\n * Constructor for the MCPServerBase.\n * @param config Configuration options for the MCP server, including metadata.\n */\n constructor(config: MCPServerConfig) {\n super({ component: RegisteredLogger.MCP_SERVER, name: config.name });\n this.name = config.name;\n this.version = config.version;\n\n // If user does not provide an ID, we will use the key from the Mastra config, but if user does not pass MCPServer\n // to Mastra, we will generate a random UUID as a backup.\n if (config.id) {\n this._id = slugify(config.id);\n this.idWasSet = true;\n } else {\n this._id = this.mastra?.generateId() || randomUUID();\n }\n\n this.description = config.description;\n this.repository = config.repository;\n this.releaseDate = config.releaseDate || new Date().toISOString();\n this.isLatest = config.isLatest === undefined ? true : config.isLatest;\n this.packageCanonical = config.packageCanonical;\n this.packages = config.packages;\n this.remotes = config.remotes;\n this.agents = config.agents;\n this.workflows = config.workflows;\n this.originalTools = config.tools;\n this.convertedTools = this.convertTools(config.tools, config.agents, config.workflows);\n }\n\n /**\n * Start the MCP server using stdio transport\n * This is typically used for Windsurf integration\n */\n public abstract startStdio(): Promise<void>;\n\n /**\n * Start the MCP server using SSE transport\n * This is typically used for web integration\n * @param options Options for the SSE transport\n */\n public abstract startSSE(options: MCPServerSSEOptions): Promise<void>;\n\n /**\n * Start the MCP server using Hono SSE transport\n * Used for Hono servers\n * @param options Options for the SSE transport\n */\n public abstract startHonoSSE(options: MCPServerHonoSSEOptions): Promise<Response | undefined>;\n\n /**\n * Start the MCP server using HTTP transport\n * @param options Options for the HTTP transport\n */\n public abstract startHTTP(options: MCPServerHTTPOptions): Promise<void>;\n\n /**\n * Close the MCP server and all its connections\n */\n public abstract close(): Promise<void>;\n\n /**\n * Gets the basic information about the server, conforming to the MCP Registry 'Server' schema.\n * This information is suitable for listing multiple servers.\n * @returns ServerInfo object containing basic server metadata.\n */\n public abstract getServerInfo(): ServerInfo;\n\n /**\n * Gets detailed information about the server, conforming to the MCP Registry 'ServerDetail' schema.\n * This includes all information from `getServerInfo` plus package and remote details.\n * @returns ServerDetailInfo object containing comprehensive server metadata.\n */\n public abstract getServerDetail(): ServerDetailInfo;\n\n /**\n * Gets a list of tools provided by this MCP server, including their schemas.\n * @returns An object containing an array of tool information.\n */\n public abstract getToolListInfo(): {\n tools: Array<{ name: string; description?: string; inputSchema: any; outputSchema?: any; toolType?: MCPToolType }>;\n };\n\n /**\n * Gets information for a specific tool provided by this MCP server.\n * @param toolId The ID/name of the tool to retrieve.\n * @returns Tool information (name, description, inputSchema) or undefined if not found.\n */\n public abstract getToolInfo(\n toolId: string,\n ): { name: string; description?: string; inputSchema: any; outputSchema?: any; toolType?: MCPToolType } | undefined;\n\n /**\n * Executes a specific tool provided by this MCP server.\n * @param toolId The ID/name of the tool to execute.\n * @param args The arguments to pass to the tool's execute function.\n * @param executionContext Optional context for the tool execution (e.g., messages, toolCallId).\n * @returns A promise that resolves to the result of the tool execution.\n * @throws Error if the tool is not found, or if execution fails.\n */\n public abstract executeTool(\n toolId: string,\n args: any,\n executionContext?: { messages?: any[]; toolCallId?: string },\n ): Promise<any>;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/index.ts"],"names":[],"mappings":";;;;;;AA2BO,IAAe,aAAA,GAAf,cAAkE,UAAA,CAAW;AAAA;AAAA,EAE1E,QAAA,GAAW,KAAA;AAAA;AAAA,EAEH,IAAA;AAAA;AAAA,EAEA,OAAA;AAAA;AAAA,EAER,GAAA;AAAA;AAAA,EAEQ,WAAA;AAAA;AAAA,EAEA,UAAA;AAAA;AAAA,EAEA,WAAA;AAAA;AAAA,EAEA,QAAA;AAAA;AAAA,EAEA,gBAAA;AAAA;AAAA,EAEA,QAAA;AAAA;AAAA,EAEA,OAAA;AAAA;AAAA,EAET,cAAA;AAAA;AAAA,EAEA,MAAA;AAAA;AAAA,EAEY,MAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,aAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnB,IAAW,EAAA,GAAU;AACnB,IAAA,OAAO,IAAA,CAAK,GAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,KAAA,GAAoD;AAClD,IAAA,OAAO,IAAA,CAAK,cAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,EAAA,EAAS;AACb,IAAA,IAAI,KAAK,QAAA,EAAU;AACjB,MAAA;AAAA,IACF;AACA,IAAA,IAAA,CAAK,GAAA,GAAM,EAAA;AACX,IAAA,IAAA,CAAK,QAAA,GAAW,IAAA;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqBA,iBAAiB,MAAA,EAAsB;AACrC,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAEd,IAAA,IAAA,CAAK,cAAA,GAAiB,KAAK,YAAA,CAAa,IAAA,CAAK,eAAe,IAAA,CAAK,MAAA,EAAQ,KAAK,SAA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AA,IAAA,CAAK,WAAW,MAAA,CAAO,QAAA;AACvB,IAAA,IAAA,CAAK,UAAU,MAAA,CAAO,OAAA;AACtB,IAAA,IAAA,CAAK,SAAS,MAAA,CAAO,MAAA;AACrB,IAAA,IAAA,CAAK,YAAY,MAAA,CAAO,SAAA;AACxB,IAAA,IAAA,CAAK,gBAAgB,MAAA,CAAO,KAAA;AAC5B,IAAA,IAAA,CAAK,cAAA,GAAiB,KAAK,YAAA,CAAa,MAAA,CAAO,OAAO,MAAA,CAAO,MAAA,EAAQ,OAAO,SAAS,CAAA;AAAA,EACvF;AA6EF","file":"index.js","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport slugify from '@sindresorhus/slugify';\nimport type { ToolsInput } from '../agent';\nimport { MastraBase } from '../base';\nimport { MastraError } from '../error';\nimport { RegisteredLogger } from '../logger';\nimport type { Mastra } from '../mastra';\nimport type { InternalCoreTool, MCPToolType, ToolAction, ToolExecutionContext } from '../tools';\nimport type {\n MCPServerConfig,\n MCPServerHonoSSEOptions,\n MCPServerHTTPOptions,\n MCPServerSSEOptions,\n PackageInfo,\n RemoteInfo,\n Repository,\n ServerDetailInfo,\n ServerInfo,\n} from './types';\nexport * from './types';\nexport type { MCPToolType } from '../tools';\n\n/**\n * Abstract base class for MCP server implementations.\n * This provides a common interface and shared functionality for all MCP servers\n * that can be registered with Mastra, including handling of server metadata.\n */\nexport abstract class MCPServerBase<TId extends string = string> extends MastraBase {\n /** Tracks if the server ID has been definitively set. */\n private idWasSet = false;\n /** The display name of the MCP server. */\n public readonly name: string;\n /** The semantic version of the MCP server. */\n public readonly version: string;\n /** Internal storage for the server's unique ID. */\n private _id: TId;\n /** A description of what the MCP server does. */\n public readonly description?: string;\n /** Repository information for the server's source code. */\n public readonly repository?: Repository;\n /** The release date of this server version (ISO 8601 string). */\n public readonly releaseDate: string;\n /** Indicates if this version is the latest available. */\n public readonly isLatest: boolean;\n /** The canonical packaging format (e.g., \"npm\", \"docker\"), if applicable. */\n public readonly packageCanonical?: MCPServerConfig['packageCanonical'];\n /** Information about installable packages for this server. */\n public readonly packages?: PackageInfo[];\n /** Information about remote access points for this server. */\n public readonly remotes?: RemoteInfo[];\n /** The tools registered with and converted by this MCP server. */\n public convertedTools: Record<string, InternalCoreTool>;\n /** Reference to the Mastra instance if this server is registered with one. */\n public mastra: Mastra | undefined;\n /** Agents to be exposed as tools. */\n protected readonly agents?: MCPServerConfig['agents'];\n /** Workflows to be exposed as tools. */\n protected readonly workflows?: MCPServerConfig['workflows'];\n /** Original tools configuration for re-conversion when Mastra instance is registered. */\n protected readonly originalTools: ToolsInput;\n\n /**\n * Public getter for the server's unique ID.\n * The ID is set at construction or by Mastra and is read-only afterwards.\n */\n public get id(): TId {\n return this._id;\n }\n\n /**\n * Gets a read-only view of the registered tools.\n * @returns A readonly record of converted tools.\n */\n tools(): Readonly<Record<string, InternalCoreTool>> {\n return this.convertedTools;\n }\n\n /**\n * Sets the server's unique ID. This method is typically called by Mastra when\n * registering the server, using the key provided in the Mastra configuration.\n * It ensures the ID is set only once.\n * If an ID was already provided in the MCPServerConfig, this method will be a no-op.\n * @param id The unique ID to assign to the server.\n */\n setId(id: TId) {\n if (this.idWasSet) {\n return;\n }\n this._id = id;\n this.idWasSet = true;\n }\n\n /**\n * Abstract method to convert and validate tool definitions provided to the server.\n * This method will also handle agents passed in the config.\n * @param tools Tool definitions to convert.\n * @param agents Agent definitions to convert to tools.\n * @param workflows Workflow definitions to convert to tools.\n * @returns A record of converted and validated tools.\n */\n public abstract convertTools(\n tools: ToolsInput,\n agents?: MCPServerConfig['agents'],\n workflows?: MCPServerConfig['workflows'],\n ): Record<string, InternalCoreTool>;\n\n /**\n * Internal method used by Mastra to register itself with the server.\n * @param mastra The Mastra instance.\n * @internal\n */\n __registerMastra(mastra: Mastra): void {\n this.mastra = mastra;\n // Re-convert tools now that we have the Mastra instance to populate MCP tools execute with mastra instance\n this.convertedTools = this.convertTools(this.originalTools, this.agents, this.workflows);\n\n // Auto-register tools with the Mastra instance\n if (this.originalTools && typeof this.originalTools === 'object') {\n Object.entries(this.originalTools).forEach(([key, tool]) => {\n try {\n // Only add tools that have an id property (ToolAction type)\n if (tool && typeof tool === 'object' && 'id' in tool) {\n // Use tool's intrinsic ID to avoid collisions across MCP servers\n const toolKey = typeof (tool as any).id === 'string' ? (tool as any).id : key;\n mastra.addTool(tool as ToolAction<any, any, any, any, ToolExecutionContext<any, any>>, toolKey);\n }\n } catch (error) {\n // Tool might already be registered, that's okay\n if (!(error instanceof MastraError) || error.id !== 'MASTRA_ADD_TOOL_DUPLICATE_KEY') {\n throw error;\n }\n }\n });\n }\n\n // Auto-register agents with the Mastra instance\n if (this.agents && typeof this.agents === 'object') {\n Object.entries(this.agents).forEach(([key, agent]) => {\n try {\n mastra.addAgent(agent, key);\n } catch (error) {\n // Agent might already be registered, that's okay\n if (!(error instanceof MastraError) || error.id !== 'MASTRA_ADD_AGENT_DUPLICATE_KEY') {\n throw error;\n }\n }\n });\n }\n\n // Auto-register workflows with the Mastra instance\n if (this.workflows && typeof this.workflows === 'object') {\n Object.entries(this.workflows).forEach(([key, workflow]) => {\n try {\n mastra.addWorkflow(workflow, key);\n } catch (error) {\n // Workflow might already be registered, that's okay\n if (!(error instanceof MastraError) || error.id !== 'MASTRA_ADD_WORKFLOW_DUPLICATE_KEY') {\n throw error;\n }\n }\n });\n }\n }\n\n /**\n * Constructor for the MCPServerBase.\n * @param config Configuration options for the MCP server, including metadata.\n */\n constructor(config: MCPServerConfig<TId>) {\n super({ component: RegisteredLogger.MCP_SERVER, name: config.name });\n this.name = config.name;\n this.version = config.version;\n\n // If user does not provide an ID, we will use the key from the Mastra config, but if user does not pass MCPServer\n // to Mastra, we will generate a random UUID as a backup.\n if (config.id) {\n this._id = slugify(config.id) as TId;\n this.idWasSet = true;\n } else {\n this._id = (this.mastra?.generateId() || randomUUID()) as TId;\n }\n\n this.description = config.description;\n this.repository = config.repository;\n this.releaseDate = config.releaseDate || new Date().toISOString();\n this.isLatest = config.isLatest === undefined ? true : config.isLatest;\n this.packageCanonical = config.packageCanonical;\n this.packages = config.packages;\n this.remotes = config.remotes;\n this.agents = config.agents;\n this.workflows = config.workflows;\n this.originalTools = config.tools;\n this.convertedTools = this.convertTools(config.tools, config.agents, config.workflows);\n }\n\n /**\n * Start the MCP server using stdio transport\n * This is typically used for Windsurf integration\n */\n public abstract startStdio(): Promise<void>;\n\n /**\n * Start the MCP server using SSE transport\n * This is typically used for web integration\n * @param options Options for the SSE transport\n */\n public abstract startSSE(options: MCPServerSSEOptions): Promise<void>;\n\n /**\n * Start the MCP server using Hono SSE transport\n * Used for Hono servers\n * @param options Options for the SSE transport\n */\n public abstract startHonoSSE(options: MCPServerHonoSSEOptions): Promise<Response | undefined>;\n\n /**\n * Start the MCP server using HTTP transport\n * @param options Options for the HTTP transport\n */\n public abstract startHTTP(options: MCPServerHTTPOptions): Promise<void>;\n\n /**\n * Close the MCP server and all its connections\n */\n public abstract close(): Promise<void>;\n\n /**\n * Gets the basic information about the server, conforming to the MCP Registry 'Server' schema.\n * This information is suitable for listing multiple servers.\n * @returns ServerInfo object containing basic server metadata.\n */\n public abstract getServerInfo(): ServerInfo;\n\n /**\n * Gets detailed information about the server, conforming to the MCP Registry 'ServerDetail' schema.\n * This includes all information from `getServerInfo` plus package and remote details.\n * @returns ServerDetailInfo object containing comprehensive server metadata.\n */\n public abstract getServerDetail(): ServerDetailInfo;\n\n /**\n * Gets a list of tools provided by this MCP server, including their schemas.\n * @returns An object containing an array of tool information.\n */\n public abstract getToolListInfo(): {\n tools: Array<{ name: string; description?: string; inputSchema: any; outputSchema?: any; toolType?: MCPToolType }>;\n };\n\n /**\n * Gets information for a specific tool provided by this MCP server.\n * @param toolId The ID/name of the tool to retrieve.\n * @returns Tool information (name, description, inputSchema) or undefined if not found.\n */\n public abstract getToolInfo(\n toolId: string,\n ): { name: string; description?: string; inputSchema: any; outputSchema?: any; toolType?: MCPToolType } | undefined;\n\n /**\n * Executes a specific tool provided by this MCP server.\n * @param toolId The ID/name of the tool to execute.\n * @param args The arguments to pass to the tool's execute function.\n * @param executionContext Optional context for the tool execution (e.g., messages, toolCallId).\n * @returns A promise that resolves to the result of the tool execution.\n * @throws Error if the tool is not found, or if execution fails.\n */\n public abstract executeTool(\n toolId: string,\n args: any,\n executionContext?: { messages?: any[]; toolCallId?: string },\n ): Promise<any>;\n}\n"]}
|
package/dist/mcp/types.d.ts
CHANGED
|
@@ -167,7 +167,7 @@ export interface RemoteInfo {
|
|
|
167
167
|
url: string;
|
|
168
168
|
}
|
|
169
169
|
/** Configuration options for creating an MCPServer instance. */
|
|
170
|
-
export interface MCPServerConfig {
|
|
170
|
+
export interface MCPServerConfig<TId extends string = string> {
|
|
171
171
|
/** The display name of the MCP server. */
|
|
172
172
|
name: string;
|
|
173
173
|
/** The semantic version of the MCP server. */
|
|
@@ -189,7 +189,7 @@ export interface MCPServerConfig {
|
|
|
189
189
|
* If not provided, a UUID will be generated.
|
|
190
190
|
* If provided, this ID is considered final and cannot be changed by Mastra.
|
|
191
191
|
*/
|
|
192
|
-
id?:
|
|
192
|
+
id?: TId;
|
|
193
193
|
/** Optional description of the MCP server. */
|
|
194
194
|
description?: string;
|
|
195
195
|
/** Optional repository information for the server's source code. */
|
package/dist/mcp/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/mcp/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,UAAU,uBAAuB;IAC/B;;OAEG;IACH,GAAG,EAAE,GAAG,CAAC;IAET;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IA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MAAM,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;IACjE,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;CACxB;AAGD,6FAA6F;AAC7F,MAAM,WAAW,UAAU;IACzB,mCAAmC;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,oCAAoC;IACpC,cAAc,EAAE,aAAa,CAAC;CAC/B;AAED,sGAAsG;AACtG,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAClD,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;IACxD,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;CACxB"}
|
package/dist/memory/index.cjs
CHANGED
|
@@ -1,334 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var chunkV3VLOOSW_cjs = require('../chunk-V3VLOOSW.cjs');
|
|
5
|
-
var chunkECFXGXWO_cjs = require('../chunk-ECFXGXWO.cjs');
|
|
6
|
-
var chunk2ZVKF4HP_cjs = require('../chunk-2ZVKF4HP.cjs');
|
|
7
|
-
var chunkWM6CK2F3_cjs = require('../chunk-WM6CK2F3.cjs');
|
|
8
|
-
var chunkKEXGB7FK_cjs = require('../chunk-KEXGB7FK.cjs');
|
|
3
|
+
var chunk52RSUALV_cjs = require('../chunk-52RSUALV.cjs');
|
|
9
4
|
|
|
10
|
-
// src/memory/memory.ts
|
|
11
|
-
var MemoryProcessor = class extends chunkKEXGB7FK_cjs.MastraBase {
|
|
12
|
-
/**
|
|
13
|
-
* Process a list of messages and return a filtered or transformed list.
|
|
14
|
-
* @param messages The messages to process
|
|
15
|
-
* @returns The processed messages
|
|
16
|
-
*/
|
|
17
|
-
process(messages, _opts) {
|
|
18
|
-
return messages;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
var memoryDefaultOptions = {
|
|
22
|
-
lastMessages: 10,
|
|
23
|
-
semanticRecall: false,
|
|
24
|
-
generateTitle: false,
|
|
25
|
-
workingMemory: {
|
|
26
|
-
enabled: false,
|
|
27
|
-
template: `
|
|
28
|
-
# User Information
|
|
29
|
-
- **First Name**:
|
|
30
|
-
- **Last Name**:
|
|
31
|
-
- **Location**:
|
|
32
|
-
- **Occupation**:
|
|
33
|
-
- **Interests**:
|
|
34
|
-
- **Goals**:
|
|
35
|
-
- **Events**:
|
|
36
|
-
- **Facts**:
|
|
37
|
-
- **Projects**:
|
|
38
|
-
`
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
var MastraMemory = class extends chunkKEXGB7FK_cjs.MastraBase {
|
|
42
|
-
MAX_CONTEXT_TOKENS;
|
|
43
|
-
_storage;
|
|
44
|
-
vector;
|
|
45
|
-
embedder;
|
|
46
|
-
processors = [];
|
|
47
|
-
threadConfig = { ...memoryDefaultOptions };
|
|
48
|
-
#mastra;
|
|
49
|
-
constructor(config) {
|
|
50
|
-
super({ component: "MEMORY", name: config.name });
|
|
51
|
-
if (config.options) this.threadConfig = this.getMergedThreadConfig(config.options);
|
|
52
|
-
if (config.processors) this.processors = config.processors;
|
|
53
|
-
if (config.storage) {
|
|
54
|
-
this._storage = chunkV3VLOOSW_cjs.augmentWithInit(config.storage);
|
|
55
|
-
this._hasOwnStorage = true;
|
|
56
|
-
}
|
|
57
|
-
if (this.threadConfig.semanticRecall) {
|
|
58
|
-
if (!config.vector) {
|
|
59
|
-
throw new Error(
|
|
60
|
-
`Semantic recall requires a vector store to be configured.
|
|
61
5
|
|
|
62
|
-
https://mastra.ai/en/docs/memory/semantic-recall`
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
this.vector = config.vector;
|
|
66
|
-
if (!config.embedder) {
|
|
67
|
-
throw new Error(
|
|
68
|
-
`Semantic recall requires an embedder to be configured.
|
|
69
6
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return this._hasOwnStorage;
|
|
91
|
-
}
|
|
92
|
-
get storage() {
|
|
93
|
-
if (!this._storage) {
|
|
94
|
-
throw new Error(
|
|
95
|
-
`Memory requires a storage provider to function. Add a storage configuration to Memory or to your Mastra instance.
|
|
96
|
-
|
|
97
|
-
https://mastra.ai/en/docs/memory/overview`
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
return this._storage;
|
|
101
|
-
}
|
|
102
|
-
setStorage(storage) {
|
|
103
|
-
this._storage = chunkV3VLOOSW_cjs.augmentWithInit(storage);
|
|
104
|
-
}
|
|
105
|
-
setVector(vector) {
|
|
106
|
-
this.vector = vector;
|
|
107
|
-
}
|
|
108
|
-
setEmbedder(embedder) {
|
|
109
|
-
this.embedder = embedder;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Get a system message to inject into the conversation.
|
|
113
|
-
* This will be called before each conversation turn.
|
|
114
|
-
* Implementations can override this to inject custom system messages.
|
|
115
|
-
*/
|
|
116
|
-
async getSystemMessage(_input) {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Get tools that should be available to the agent.
|
|
121
|
-
* This will be called when converting tools for the agent.
|
|
122
|
-
* Implementations can override this to provide additional tools.
|
|
123
|
-
*/
|
|
124
|
-
listTools(_config) {
|
|
125
|
-
return {};
|
|
126
|
-
}
|
|
127
|
-
async createEmbeddingIndex(dimensions, config) {
|
|
128
|
-
const defaultDimensions = 1536;
|
|
129
|
-
const isDefault = dimensions === defaultDimensions;
|
|
130
|
-
const usedDimensions = dimensions ?? defaultDimensions;
|
|
131
|
-
const separator = this.vector?.indexSeparator ?? "_";
|
|
132
|
-
const indexName = isDefault ? `memory${separator}messages` : `memory${separator}messages${separator}${usedDimensions}`;
|
|
133
|
-
if (typeof this.vector === `undefined`) {
|
|
134
|
-
throw new Error(`Tried to create embedding index but no vector db is attached to this Memory instance.`);
|
|
135
|
-
}
|
|
136
|
-
const semanticConfig = typeof config?.semanticRecall === "object" ? config.semanticRecall : void 0;
|
|
137
|
-
const indexConfig = semanticConfig?.indexConfig;
|
|
138
|
-
const createParams = {
|
|
139
|
-
indexName,
|
|
140
|
-
dimension: usedDimensions,
|
|
141
|
-
...indexConfig?.metric && { metric: indexConfig.metric }
|
|
142
|
-
};
|
|
143
|
-
if (indexConfig && (indexConfig.type || indexConfig.ivf || indexConfig.hnsw)) {
|
|
144
|
-
createParams.indexConfig = {};
|
|
145
|
-
if (indexConfig.type) createParams.indexConfig.type = indexConfig.type;
|
|
146
|
-
if (indexConfig.ivf) createParams.indexConfig.ivf = indexConfig.ivf;
|
|
147
|
-
if (indexConfig.hnsw) createParams.indexConfig.hnsw = indexConfig.hnsw;
|
|
148
|
-
}
|
|
149
|
-
await this.vector.createIndex(createParams);
|
|
150
|
-
return { indexName };
|
|
151
|
-
}
|
|
152
|
-
getMergedThreadConfig(config) {
|
|
153
|
-
if (config?.workingMemory && "use" in config.workingMemory) {
|
|
154
|
-
throw new Error("The workingMemory.use option has been removed. Working memory always uses tool-call mode.");
|
|
155
|
-
}
|
|
156
|
-
if (config?.threads?.generateTitle !== void 0) {
|
|
157
|
-
throw new Error(
|
|
158
|
-
"The threads.generateTitle option has been moved. Use the top-level generateTitle option instead."
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
const mergedConfig = chunkWM6CK2F3_cjs.deepMerge(this.threadConfig, config || {});
|
|
162
|
-
if (config?.workingMemory?.schema) {
|
|
163
|
-
if (mergedConfig.workingMemory) {
|
|
164
|
-
mergedConfig.workingMemory.schema = config.workingMemory.schema;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return mergedConfig;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Apply all configured message processors to a list of messages.
|
|
171
|
-
* @param messages The messages to process
|
|
172
|
-
* @returns The processed messages
|
|
173
|
-
*/
|
|
174
|
-
async applyProcessors(messages, opts) {
|
|
175
|
-
const processors = opts.processors || this.processors;
|
|
176
|
-
if (!processors || processors.length === 0) {
|
|
177
|
-
return messages;
|
|
178
|
-
}
|
|
179
|
-
let processedMessages = [...messages];
|
|
180
|
-
for (const processor of processors) {
|
|
181
|
-
processedMessages = await processor.process(processedMessages, {
|
|
182
|
-
systemMessage: opts.systemMessage,
|
|
183
|
-
newMessages: opts.newMessages,
|
|
184
|
-
memorySystemMessage: opts.memorySystemMessage
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
return processedMessages;
|
|
188
|
-
}
|
|
189
|
-
processMessages({
|
|
190
|
-
messages,
|
|
191
|
-
processors,
|
|
192
|
-
...opts
|
|
193
|
-
}) {
|
|
194
|
-
return this.applyProcessors(messages, { processors: processors || this.processors, ...opts });
|
|
195
|
-
}
|
|
196
|
-
estimateTokens(text) {
|
|
197
|
-
return Math.ceil(text.split(" ").length * 1.3);
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Helper method to create a new thread
|
|
201
|
-
* @param title - Optional title for the thread
|
|
202
|
-
* @param metadata - Optional metadata for the thread
|
|
203
|
-
* @returns Promise resolving to the created thread
|
|
204
|
-
*/
|
|
205
|
-
async createThread({
|
|
206
|
-
threadId,
|
|
207
|
-
resourceId,
|
|
208
|
-
title,
|
|
209
|
-
metadata,
|
|
210
|
-
memoryConfig,
|
|
211
|
-
saveThread = true
|
|
212
|
-
}) {
|
|
213
|
-
const thread = {
|
|
214
|
-
id: threadId || this.generateId(),
|
|
215
|
-
title: title || `New Thread ${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
216
|
-
resourceId,
|
|
217
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
218
|
-
updatedAt: /* @__PURE__ */ new Date(),
|
|
219
|
-
metadata
|
|
220
|
-
};
|
|
221
|
-
return saveThread ? this.saveThread({ thread, memoryConfig }) : thread;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Helper method to add a single message to a thread
|
|
225
|
-
* @param threadId - The thread to add the message to
|
|
226
|
-
* @param content - The message content
|
|
227
|
-
* @param role - The role of the message sender
|
|
228
|
-
* @param type - The type of the message
|
|
229
|
-
* @param toolNames - Optional array of tool names that were called
|
|
230
|
-
* @param toolCallArgs - Optional array of tool call arguments
|
|
231
|
-
* @param toolCallIds - Optional array of tool call ids
|
|
232
|
-
* @returns Promise resolving to the saved message
|
|
233
|
-
* @deprecated use saveMessages instead
|
|
234
|
-
*/
|
|
235
|
-
async addMessage(_params) {
|
|
236
|
-
throw new Error("addMessage is deprecated. Please use saveMessages instead.");
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Generates a unique identifier
|
|
240
|
-
* @returns A unique string ID
|
|
241
|
-
*/
|
|
242
|
-
generateId() {
|
|
243
|
-
return this.#mastra?.generateId() || crypto.randomUUID();
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
// src/memory/mock.ts
|
|
248
|
-
var MockMemory = class extends MastraMemory {
|
|
249
|
-
threads = {};
|
|
250
|
-
constructor({ storage } = {}) {
|
|
251
|
-
super({ name: "mock", storage: storage || new chunkGGYKYORQ_cjs.InMemoryStore() });
|
|
252
|
-
this._hasOwnStorage = true;
|
|
253
|
-
}
|
|
254
|
-
async getThreadById({ threadId }) {
|
|
255
|
-
return this.storage.getThreadById({ threadId });
|
|
256
|
-
}
|
|
257
|
-
async saveThread({ thread }) {
|
|
258
|
-
return this.storage.saveThread({ thread });
|
|
259
|
-
}
|
|
260
|
-
async saveMessages({
|
|
261
|
-
messages
|
|
262
|
-
}) {
|
|
263
|
-
const dbMessages = new chunkECFXGXWO_cjs.MessageList({
|
|
264
|
-
generateMessageId: () => this.generateId()
|
|
265
|
-
}).add(messages, "memory").get.all.db();
|
|
266
|
-
return this.storage.saveMessages({ messages: dbMessages });
|
|
267
|
-
}
|
|
268
|
-
async listThreadsByResourceId(args) {
|
|
269
|
-
return this.storage.listThreadsByResourceId(args);
|
|
270
|
-
}
|
|
271
|
-
async recall(args) {
|
|
272
|
-
const result = await this.storage.listMessages({
|
|
273
|
-
threadId: args.threadId,
|
|
274
|
-
resourceId: args.resourceId,
|
|
275
|
-
perPage: args.perPage,
|
|
276
|
-
page: args.page,
|
|
277
|
-
orderBy: args.orderBy,
|
|
278
|
-
filter: args.filter,
|
|
279
|
-
include: args.include
|
|
280
|
-
});
|
|
281
|
-
return result;
|
|
282
|
-
}
|
|
283
|
-
async deleteThread(threadId) {
|
|
284
|
-
return this.storage.deleteThread({ threadId });
|
|
285
|
-
}
|
|
286
|
-
async deleteMessages(messageIds) {
|
|
287
|
-
const ids = Array.isArray(messageIds) ? messageIds?.map((item) => typeof item === "string" ? item : item.id) : [messageIds];
|
|
288
|
-
return this.storage.deleteMessages(ids);
|
|
289
|
-
}
|
|
290
|
-
// Add missing method implementations
|
|
291
|
-
async getWorkingMemory({
|
|
292
|
-
threadId: _threadId,
|
|
293
|
-
resourceId: _resourceId,
|
|
294
|
-
memoryConfig: _memoryConfig
|
|
295
|
-
}) {
|
|
296
|
-
return null;
|
|
297
|
-
}
|
|
298
|
-
async getWorkingMemoryTemplate({
|
|
299
|
-
memoryConfig: _memoryConfig
|
|
300
|
-
} = {}) {
|
|
301
|
-
return null;
|
|
302
|
-
}
|
|
303
|
-
getMergedThreadConfig(config) {
|
|
304
|
-
return config || {};
|
|
305
|
-
}
|
|
306
|
-
async updateWorkingMemory({
|
|
307
|
-
threadId: _threadId,
|
|
308
|
-
resourceId: _resourceId,
|
|
309
|
-
workingMemory: _workingMemory,
|
|
310
|
-
memoryConfig: _memoryConfig
|
|
311
|
-
}) {
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
async __experimental_updateWorkingMemoryVNext({
|
|
315
|
-
threadId: _threadId,
|
|
316
|
-
resourceId: _resourceId,
|
|
317
|
-
workingMemory: _workingMemory,
|
|
318
|
-
searchString: _searchString,
|
|
319
|
-
memoryConfig: _memoryConfig
|
|
320
|
-
}) {
|
|
321
|
-
return { success: true, reason: "Mock implementation" };
|
|
322
|
-
}
|
|
323
|
-
async updateMessages({ messages }) {
|
|
324
|
-
const result = await this.saveMessages({ messages });
|
|
325
|
-
return result.messages;
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
exports.MastraMemory = MastraMemory;
|
|
330
|
-
exports.MemoryProcessor = MemoryProcessor;
|
|
331
|
-
exports.MockMemory = MockMemory;
|
|
332
|
-
exports.memoryDefaultOptions = memoryDefaultOptions;
|
|
7
|
+
Object.defineProperty(exports, "MastraMemory", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunk52RSUALV_cjs.MastraMemory; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "MemoryProcessor", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunk52RSUALV_cjs.MemoryProcessor; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "MockMemory", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunk52RSUALV_cjs.MockMemory; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "memoryDefaultOptions", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunk52RSUALV_cjs.memoryDefaultOptions; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "parseMemoryRequestContext", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunk52RSUALV_cjs.parseMemoryRequestContext; }
|
|
26
|
+
});
|
|
333
27
|
//# sourceMappingURL=index.cjs.map
|
|
334
28
|
//# sourceMappingURL=index.cjs.map
|