@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
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var chunkBMAFVZ2D_cjs = require('./chunk-BMAFVZ2D.cjs');
|
|
3
|
+
var chunkYC6PJEPH_cjs = require('./chunk-YC6PJEPH.cjs');
|
|
4
|
+
var chunkT2VLUFGG_cjs = require('./chunk-T2VLUFGG.cjs');
|
|
6
5
|
var chunk4D4KB75Y_cjs = require('./chunk-4D4KB75Y.cjs');
|
|
7
|
-
var
|
|
6
|
+
var chunk52RSUALV_cjs = require('./chunk-52RSUALV.cjs');
|
|
7
|
+
var chunk6BJ7XHRH_cjs = require('./chunk-6BJ7XHRH.cjs');
|
|
8
8
|
var chunkMR7ZWBL6_cjs = require('./chunk-MR7ZWBL6.cjs');
|
|
9
|
-
var
|
|
9
|
+
var chunk72YCRTEX_cjs = require('./chunk-72YCRTEX.cjs');
|
|
10
10
|
var chunkTWH4PTDG_cjs = require('./chunk-TWH4PTDG.cjs');
|
|
11
|
-
var
|
|
12
|
-
var
|
|
11
|
+
var chunkUIGRFDO6_cjs = require('./chunk-UIGRFDO6.cjs');
|
|
12
|
+
var chunkAF74UXR5_cjs = require('./chunk-AF74UXR5.cjs');
|
|
13
13
|
var crypto$1 = require('crypto');
|
|
14
14
|
var EventEmitter = require('events');
|
|
15
15
|
var pMap = require('p-map');
|
|
@@ -139,7 +139,7 @@ function createOnScorerHook(mastra) {
|
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
141
|
async function validateAndSaveScore(storage, payload) {
|
|
142
|
-
const payloadToSave =
|
|
142
|
+
const payloadToSave = chunkT2VLUFGG_cjs.saveScorePayloadSchema.parse(payload);
|
|
143
143
|
await storage?.saveScore(payloadToSave);
|
|
144
144
|
}
|
|
145
145
|
async function findScorer(mastra, entityId, entityType, scorerId) {
|
|
@@ -169,6 +169,17 @@ async function findScorer(mastra, entityId, entityType, scorerId) {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
// src/mastra/index.ts
|
|
172
|
+
function createUndefinedPrimitiveError(type, value, key) {
|
|
173
|
+
const typeLabel = type === "mcp-server" ? "MCP server" : type;
|
|
174
|
+
const errorId = `MASTRA_ADD_${type.toUpperCase().replace("-", "_")}_UNDEFINED`;
|
|
175
|
+
return new chunkTWH4PTDG_cjs.MastraError({
|
|
176
|
+
id: errorId,
|
|
177
|
+
domain: "MASTRA" /* MASTRA */,
|
|
178
|
+
category: "USER" /* USER */,
|
|
179
|
+
text: `Cannot add ${typeLabel}: ${typeLabel} is ${value === null ? "null" : "undefined"}. This may occur if config was spread ({ ...config }) and the original object had getters or non-enumerable properties.`,
|
|
180
|
+
details: { status: 400, ...key && { key } }
|
|
181
|
+
});
|
|
182
|
+
}
|
|
172
183
|
var Mastra = class {
|
|
173
184
|
#vectors;
|
|
174
185
|
#agents;
|
|
@@ -182,11 +193,14 @@ var Mastra = class {
|
|
|
182
193
|
#scorers;
|
|
183
194
|
#tools;
|
|
184
195
|
#processors;
|
|
196
|
+
#memory;
|
|
185
197
|
#server;
|
|
198
|
+
#serverAdapter;
|
|
186
199
|
#mcpServers;
|
|
187
200
|
#bundler;
|
|
188
201
|
#idGenerator;
|
|
189
202
|
#pubsub;
|
|
203
|
+
#gateways;
|
|
190
204
|
#events = {};
|
|
191
205
|
#internalMastraWorkflows = {};
|
|
192
206
|
// This is only used internally for server handlers that require temporary persistence
|
|
@@ -285,7 +299,7 @@ var Mastra = class {
|
|
|
285
299
|
* ```
|
|
286
300
|
*/
|
|
287
301
|
constructor(config) {
|
|
288
|
-
this.#serverCache = new
|
|
302
|
+
this.#serverCache = new chunkUIGRFDO6_cjs.InMemoryServerCache();
|
|
289
303
|
if (config?.pubsub) {
|
|
290
304
|
this.#pubsub = config.pubsub;
|
|
291
305
|
} else {
|
|
@@ -299,7 +313,7 @@ var Mastra = class {
|
|
|
299
313
|
this.#events[topic] = config?.events?.[topic] ?? [];
|
|
300
314
|
}
|
|
301
315
|
}
|
|
302
|
-
const workflowEventProcessor = new
|
|
316
|
+
const workflowEventProcessor = new chunkYC6PJEPH_cjs.WorkflowEventProcessor({ mastra: this });
|
|
303
317
|
const workflowEventCb = async (event, cb) => {
|
|
304
318
|
try {
|
|
305
319
|
await workflowEventProcessor.process(event, cb);
|
|
@@ -314,20 +328,20 @@ var Mastra = class {
|
|
|
314
328
|
}
|
|
315
329
|
let logger;
|
|
316
330
|
if (config?.logger === false) {
|
|
317
|
-
logger =
|
|
331
|
+
logger = chunk6BJ7XHRH_cjs.noopLogger;
|
|
318
332
|
} else {
|
|
319
333
|
if (config?.logger) {
|
|
320
334
|
logger = config.logger;
|
|
321
335
|
} else {
|
|
322
|
-
const levelOnEnv = process.env.NODE_ENV === "production" && process.env.MASTRA_DEV !== "true" ?
|
|
323
|
-
logger = new
|
|
336
|
+
const levelOnEnv = process.env.NODE_ENV === "production" && process.env.MASTRA_DEV !== "true" ? chunkAF74UXR5_cjs.LogLevel.WARN : chunkAF74UXR5_cjs.LogLevel.INFO;
|
|
337
|
+
logger = new chunkAF74UXR5_cjs.ConsoleLogger({ name: "Mastra", level: levelOnEnv });
|
|
324
338
|
}
|
|
325
339
|
}
|
|
326
340
|
this.#logger = logger;
|
|
327
341
|
this.#idGenerator = config?.idGenerator;
|
|
328
342
|
let storage = config?.storage;
|
|
329
343
|
if (storage) {
|
|
330
|
-
storage =
|
|
344
|
+
storage = chunk52RSUALV_cjs.augmentWithInit(storage);
|
|
331
345
|
}
|
|
332
346
|
if (config?.observability) {
|
|
333
347
|
if (typeof config.observability.getDefaultInstance === "function") {
|
|
@@ -337,10 +351,10 @@ var Mastra = class {
|
|
|
337
351
|
this.#logger?.warn(
|
|
338
352
|
'Observability configuration error: Expected an Observability instance, but received a config object. Import and instantiate: import { Observability } from "@mastra/observability"; then pass: observability: new Observability({ default: { enabled: true } }). Observability has been disabled.'
|
|
339
353
|
);
|
|
340
|
-
this.#observability = new
|
|
354
|
+
this.#observability = new chunk72YCRTEX_cjs.NoOpObservability();
|
|
341
355
|
}
|
|
342
356
|
} else {
|
|
343
|
-
this.#observability = new
|
|
357
|
+
this.#observability = new chunk72YCRTEX_cjs.NoOpObservability();
|
|
344
358
|
}
|
|
345
359
|
this.#storage = storage;
|
|
346
360
|
this.#vectors = {};
|
|
@@ -350,45 +364,77 @@ var Mastra = class {
|
|
|
350
364
|
this.#scorers = {};
|
|
351
365
|
this.#tools = {};
|
|
352
366
|
this.#processors = {};
|
|
367
|
+
this.#memory = {};
|
|
353
368
|
this.#workflows = {};
|
|
369
|
+
this.#gateways = {};
|
|
354
370
|
if (config?.tools) {
|
|
355
371
|
Object.entries(config.tools).forEach(([key, tool]) => {
|
|
356
|
-
|
|
372
|
+
if (tool != null) {
|
|
373
|
+
this.addTool(tool, key);
|
|
374
|
+
}
|
|
357
375
|
});
|
|
358
376
|
}
|
|
359
377
|
if (config?.processors) {
|
|
360
378
|
Object.entries(config.processors).forEach(([key, processor]) => {
|
|
361
|
-
|
|
379
|
+
if (processor != null) {
|
|
380
|
+
this.addProcessor(processor, key);
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
if (config?.memory) {
|
|
385
|
+
Object.entries(config.memory).forEach(([key, memory]) => {
|
|
386
|
+
if (memory != null) {
|
|
387
|
+
this.addMemory(memory, key);
|
|
388
|
+
}
|
|
362
389
|
});
|
|
363
390
|
}
|
|
364
391
|
if (config?.vectors) {
|
|
365
392
|
Object.entries(config.vectors).forEach(([key, vector]) => {
|
|
366
|
-
|
|
393
|
+
if (vector != null) {
|
|
394
|
+
this.addVector(vector, key);
|
|
395
|
+
}
|
|
367
396
|
});
|
|
368
397
|
}
|
|
369
398
|
if (config?.scorers) {
|
|
370
399
|
Object.entries(config.scorers).forEach(([key, scorer]) => {
|
|
371
|
-
|
|
400
|
+
if (scorer != null) {
|
|
401
|
+
this.addScorer(scorer, key);
|
|
402
|
+
}
|
|
372
403
|
});
|
|
373
404
|
}
|
|
374
405
|
if (config?.workflows) {
|
|
375
406
|
Object.entries(config.workflows).forEach(([key, workflow]) => {
|
|
376
|
-
|
|
407
|
+
if (workflow != null) {
|
|
408
|
+
this.addWorkflow(workflow, key);
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
if (config?.gateways) {
|
|
413
|
+
Object.entries(config.gateways).forEach(([key, gateway]) => {
|
|
414
|
+
if (gateway != null) {
|
|
415
|
+
this.addGateway(gateway, key);
|
|
416
|
+
}
|
|
377
417
|
});
|
|
378
418
|
}
|
|
379
419
|
if (config?.mcpServers) {
|
|
380
420
|
Object.entries(config.mcpServers).forEach(([key, server]) => {
|
|
381
|
-
|
|
421
|
+
if (server != null) {
|
|
422
|
+
this.addMCPServer(server, key);
|
|
423
|
+
}
|
|
382
424
|
});
|
|
383
425
|
}
|
|
384
426
|
if (config?.agents) {
|
|
385
427
|
Object.entries(config.agents).forEach(([key, agent]) => {
|
|
386
|
-
|
|
428
|
+
if (agent != null) {
|
|
429
|
+
this.addAgent(agent, key);
|
|
430
|
+
}
|
|
387
431
|
});
|
|
388
432
|
}
|
|
389
433
|
if (config?.tts) {
|
|
390
434
|
Object.entries(config.tts).forEach(([key, tts]) => {
|
|
391
|
-
|
|
435
|
+
if (tts != null) {
|
|
436
|
+
this.#tts[key] = tts;
|
|
437
|
+
}
|
|
392
438
|
});
|
|
393
439
|
}
|
|
394
440
|
if (config?.server) {
|
|
@@ -512,6 +558,241 @@ var Mastra = class {
|
|
|
512
558
|
listAgents() {
|
|
513
559
|
return this.#agents;
|
|
514
560
|
}
|
|
561
|
+
async getStoredAgentById(id, options) {
|
|
562
|
+
const storage = this.#storage;
|
|
563
|
+
if (!storage) {
|
|
564
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
565
|
+
id: "MASTRA_GET_STORED_AGENT_STORAGE_NOT_CONFIGURED",
|
|
566
|
+
domain: "MASTRA" /* MASTRA */,
|
|
567
|
+
category: "USER" /* USER */,
|
|
568
|
+
text: "Storage is not configured",
|
|
569
|
+
details: { status: 400 }
|
|
570
|
+
});
|
|
571
|
+
this.#logger?.trackException(error);
|
|
572
|
+
throw error;
|
|
573
|
+
}
|
|
574
|
+
if (!storage.supports.agents) {
|
|
575
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
576
|
+
id: "MASTRA_GET_STORED_AGENT_NOT_SUPPORTED",
|
|
577
|
+
domain: "MASTRA" /* MASTRA */,
|
|
578
|
+
category: "USER" /* USER */,
|
|
579
|
+
text: "Storage does not support agents",
|
|
580
|
+
details: { status: 400 }
|
|
581
|
+
});
|
|
582
|
+
this.#logger?.trackException(error);
|
|
583
|
+
throw error;
|
|
584
|
+
}
|
|
585
|
+
const storedAgent = await storage.getAgentById({ id });
|
|
586
|
+
if (!storedAgent) {
|
|
587
|
+
return null;
|
|
588
|
+
}
|
|
589
|
+
if (options?.raw) {
|
|
590
|
+
return storedAgent;
|
|
591
|
+
}
|
|
592
|
+
return this.#createAgentFromStoredConfig(storedAgent);
|
|
593
|
+
}
|
|
594
|
+
async listStoredAgents(args) {
|
|
595
|
+
const storage = this.#storage;
|
|
596
|
+
if (!storage) {
|
|
597
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
598
|
+
id: "MASTRA_LIST_STORED_AGENTS_STORAGE_NOT_CONFIGURED",
|
|
599
|
+
domain: "MASTRA" /* MASTRA */,
|
|
600
|
+
category: "USER" /* USER */,
|
|
601
|
+
text: "Storage is not configured",
|
|
602
|
+
details: { status: 400 }
|
|
603
|
+
});
|
|
604
|
+
this.#logger?.trackException(error);
|
|
605
|
+
throw error;
|
|
606
|
+
}
|
|
607
|
+
if (!storage.supports.agents) {
|
|
608
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
609
|
+
id: "MASTRA_LIST_STORED_AGENTS_NOT_SUPPORTED",
|
|
610
|
+
domain: "MASTRA" /* MASTRA */,
|
|
611
|
+
category: "USER" /* USER */,
|
|
612
|
+
text: "Storage does not support agents",
|
|
613
|
+
details: { status: 400 }
|
|
614
|
+
});
|
|
615
|
+
this.#logger?.trackException(error);
|
|
616
|
+
throw error;
|
|
617
|
+
}
|
|
618
|
+
const result = await storage.listAgents({
|
|
619
|
+
page: args?.page,
|
|
620
|
+
perPage: args?.perPage,
|
|
621
|
+
orderBy: args?.orderBy
|
|
622
|
+
});
|
|
623
|
+
if (args?.raw) {
|
|
624
|
+
return result;
|
|
625
|
+
}
|
|
626
|
+
const agents = result.agents.map((storedAgent) => this.#createAgentFromStoredConfig(storedAgent));
|
|
627
|
+
return {
|
|
628
|
+
agents,
|
|
629
|
+
total: result.total,
|
|
630
|
+
page: result.page,
|
|
631
|
+
perPage: result.perPage,
|
|
632
|
+
hasMore: result.hasMore
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Creates an Agent instance from a stored agent configuration.
|
|
637
|
+
* @private
|
|
638
|
+
*/
|
|
639
|
+
#createAgentFromStoredConfig(storedAgent) {
|
|
640
|
+
const modelConfig = storedAgent.model;
|
|
641
|
+
if (!modelConfig.provider || !modelConfig.name) {
|
|
642
|
+
throw new chunkTWH4PTDG_cjs.MastraError({
|
|
643
|
+
id: "MASTRA_STORED_AGENT_INVALID_MODEL",
|
|
644
|
+
domain: "MASTRA" /* MASTRA */,
|
|
645
|
+
category: "USER" /* USER */,
|
|
646
|
+
text: `Stored agent "${storedAgent.id}" has invalid model configuration. Both provider and name are required.`,
|
|
647
|
+
details: { agentId: storedAgent.id, model: JSON.stringify(storedAgent.model) }
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
const model = `${modelConfig.provider}/${modelConfig.name}`;
|
|
651
|
+
const tools = this.#resolveStoredTools(storedAgent.tools);
|
|
652
|
+
const workflows = this.#resolveStoredWorkflows(storedAgent.workflows);
|
|
653
|
+
const agents = this.#resolveStoredAgents(storedAgent.agents);
|
|
654
|
+
const memory = this.#resolveStoredMemory(storedAgent.memory);
|
|
655
|
+
const scorers = this.#resolveStoredScorers(storedAgent.scorers);
|
|
656
|
+
const agent = new chunk52RSUALV_cjs.Agent({
|
|
657
|
+
id: storedAgent.id,
|
|
658
|
+
name: storedAgent.name,
|
|
659
|
+
description: storedAgent.description,
|
|
660
|
+
instructions: storedAgent.instructions,
|
|
661
|
+
model,
|
|
662
|
+
tools,
|
|
663
|
+
workflows,
|
|
664
|
+
agents,
|
|
665
|
+
memory,
|
|
666
|
+
scorers,
|
|
667
|
+
defaultOptions: storedAgent.defaultOptions
|
|
668
|
+
});
|
|
669
|
+
agent.__setLogger(this.#logger);
|
|
670
|
+
agent.__registerMastra(this);
|
|
671
|
+
agent.__registerPrimitives({
|
|
672
|
+
logger: this.getLogger(),
|
|
673
|
+
storage: this.getStorage(),
|
|
674
|
+
agents: this.#agents,
|
|
675
|
+
tts: this.#tts,
|
|
676
|
+
vectors: this.#vectors
|
|
677
|
+
});
|
|
678
|
+
return agent;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Resolves tool references from stored configuration to actual tool instances.
|
|
682
|
+
* @private
|
|
683
|
+
*/
|
|
684
|
+
#resolveStoredTools(storedTools) {
|
|
685
|
+
if (!storedTools || storedTools.length === 0) {
|
|
686
|
+
return {};
|
|
687
|
+
}
|
|
688
|
+
const resolvedTools = {};
|
|
689
|
+
const registeredTools = this.#tools;
|
|
690
|
+
for (const toolKey of storedTools) {
|
|
691
|
+
if (registeredTools && registeredTools[toolKey]) {
|
|
692
|
+
resolvedTools[toolKey] = registeredTools[toolKey];
|
|
693
|
+
} else {
|
|
694
|
+
this.#logger?.warn(`Tool "${toolKey}" referenced in stored agent but not registered in Mastra`);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
return resolvedTools;
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Resolves workflow references from stored configuration to actual workflow instances.
|
|
701
|
+
* @private
|
|
702
|
+
*/
|
|
703
|
+
#resolveStoredWorkflows(storedWorkflows) {
|
|
704
|
+
if (!storedWorkflows || storedWorkflows.length === 0) {
|
|
705
|
+
return {};
|
|
706
|
+
}
|
|
707
|
+
const resolvedWorkflows = {};
|
|
708
|
+
for (const workflowKey of storedWorkflows) {
|
|
709
|
+
try {
|
|
710
|
+
const workflow = this.getWorkflow(workflowKey);
|
|
711
|
+
resolvedWorkflows[workflowKey] = workflow;
|
|
712
|
+
} catch {
|
|
713
|
+
try {
|
|
714
|
+
const workflow = this.getWorkflowById(workflowKey);
|
|
715
|
+
resolvedWorkflows[workflowKey] = workflow;
|
|
716
|
+
} catch {
|
|
717
|
+
this.#logger?.warn(`Workflow "${workflowKey}" referenced in stored agent but not registered in Mastra`);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
return resolvedWorkflows;
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Resolves agent references from stored configuration to actual agent instances.
|
|
725
|
+
* @private
|
|
726
|
+
*/
|
|
727
|
+
#resolveStoredAgents(storedAgents) {
|
|
728
|
+
if (!storedAgents || storedAgents.length === 0) {
|
|
729
|
+
return {};
|
|
730
|
+
}
|
|
731
|
+
const resolvedAgents = {};
|
|
732
|
+
for (const agentKey of storedAgents) {
|
|
733
|
+
try {
|
|
734
|
+
const agent = this.getAgent(agentKey);
|
|
735
|
+
resolvedAgents[agentKey] = agent;
|
|
736
|
+
} catch {
|
|
737
|
+
try {
|
|
738
|
+
const agent = this.getAgentById(agentKey);
|
|
739
|
+
resolvedAgents[agentKey] = agent;
|
|
740
|
+
} catch {
|
|
741
|
+
this.#logger?.warn(`Agent "${agentKey}" referenced in stored agent but not registered in Mastra`);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
return resolvedAgents;
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Resolves memory reference from stored configuration to actual memory instance.
|
|
749
|
+
* @private
|
|
750
|
+
*/
|
|
751
|
+
#resolveStoredMemory(storedMemory) {
|
|
752
|
+
if (!storedMemory) {
|
|
753
|
+
return void 0;
|
|
754
|
+
}
|
|
755
|
+
try {
|
|
756
|
+
return this.getMemory(storedMemory);
|
|
757
|
+
} catch {
|
|
758
|
+
try {
|
|
759
|
+
return this.getMemoryById(storedMemory);
|
|
760
|
+
} catch {
|
|
761
|
+
this.#logger?.warn(`Memory "${storedMemory}" referenced in stored agent but not registered in Mastra`);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
return void 0;
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* Resolves scorer references from stored configuration to actual scorer instances.
|
|
768
|
+
* @private
|
|
769
|
+
*/
|
|
770
|
+
#resolveStoredScorers(storedScorers) {
|
|
771
|
+
if (!storedScorers) {
|
|
772
|
+
return void 0;
|
|
773
|
+
}
|
|
774
|
+
const resolvedScorers = {};
|
|
775
|
+
for (const [scorerKey, scorerConfig] of Object.entries(storedScorers)) {
|
|
776
|
+
try {
|
|
777
|
+
const scorer = this.getScorer(scorerKey);
|
|
778
|
+
resolvedScorers[scorerKey] = {
|
|
779
|
+
scorer,
|
|
780
|
+
sampling: scorerConfig.sampling
|
|
781
|
+
};
|
|
782
|
+
} catch {
|
|
783
|
+
try {
|
|
784
|
+
const scorer = this.getScorerById(scorerKey);
|
|
785
|
+
resolvedScorers[scorerKey] = {
|
|
786
|
+
scorer,
|
|
787
|
+
sampling: scorerConfig.sampling
|
|
788
|
+
};
|
|
789
|
+
} catch {
|
|
790
|
+
this.#logger?.warn(`Scorer "${scorerKey}" referenced in stored agent but not registered in Mastra`);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
return Object.keys(resolvedScorers).length > 0 ? resolvedScorers : void 0;
|
|
795
|
+
}
|
|
515
796
|
/**
|
|
516
797
|
* Adds a new agent to the Mastra instance.
|
|
517
798
|
*
|
|
@@ -534,6 +815,9 @@ var Mastra = class {
|
|
|
534
815
|
* ```
|
|
535
816
|
*/
|
|
536
817
|
addAgent(agent, key) {
|
|
818
|
+
if (!agent) {
|
|
819
|
+
throw createUndefinedPrimitiveError("agent", agent, key);
|
|
820
|
+
}
|
|
537
821
|
const agentKey = key || agent.id;
|
|
538
822
|
const agents = this.#agents;
|
|
539
823
|
if (agents[agentKey]) {
|
|
@@ -551,6 +835,13 @@ var Mastra = class {
|
|
|
551
835
|
vectors: this.#vectors
|
|
552
836
|
});
|
|
553
837
|
agents[agentKey] = agent;
|
|
838
|
+
agent.getConfiguredProcessorWorkflows().then((processorWorkflows) => {
|
|
839
|
+
for (const workflow of processorWorkflows) {
|
|
840
|
+
this.addWorkflow(workflow, workflow.id);
|
|
841
|
+
}
|
|
842
|
+
}).catch((err) => {
|
|
843
|
+
this.#logger?.debug(`Failed to register processor workflows for agent ${agentKey}:`, err);
|
|
844
|
+
});
|
|
554
845
|
}
|
|
555
846
|
/**
|
|
556
847
|
* Retrieves a registered vector store by its name.
|
|
@@ -696,6 +987,9 @@ var Mastra = class {
|
|
|
696
987
|
* ```
|
|
697
988
|
*/
|
|
698
989
|
addVector(vector, key) {
|
|
990
|
+
if (!vector) {
|
|
991
|
+
throw createUndefinedPrimitiveError("vector", vector, key);
|
|
992
|
+
}
|
|
699
993
|
const vectorKey = key || vector.id;
|
|
700
994
|
const vectors = this.#vectors;
|
|
701
995
|
if (vectors[vectorKey]) {
|
|
@@ -866,6 +1160,44 @@ var Mastra = class {
|
|
|
866
1160
|
}
|
|
867
1161
|
return workflow;
|
|
868
1162
|
}
|
|
1163
|
+
async listActiveWorkflowRuns() {
|
|
1164
|
+
const storage = this.#storage;
|
|
1165
|
+
if (!storage) {
|
|
1166
|
+
this.#logger.debug("Cannot get active workflow runs. Mastra storage is not initialized");
|
|
1167
|
+
return { runs: [], total: 0 };
|
|
1168
|
+
}
|
|
1169
|
+
const defaultEngineWorkflows = Object.values(this.#workflows).filter((workflow) => workflow.engineType === "default");
|
|
1170
|
+
const allRuns = [];
|
|
1171
|
+
let allTotal = 0;
|
|
1172
|
+
for (const workflow of defaultEngineWorkflows) {
|
|
1173
|
+
const runningRuns = await workflow.listWorkflowRuns({ status: "running" });
|
|
1174
|
+
const waitingRuns = await workflow.listWorkflowRuns({ status: "waiting" });
|
|
1175
|
+
allRuns.push(...runningRuns.runs, ...waitingRuns.runs);
|
|
1176
|
+
allTotal += runningRuns.total + waitingRuns.total;
|
|
1177
|
+
}
|
|
1178
|
+
return {
|
|
1179
|
+
runs: allRuns,
|
|
1180
|
+
total: allTotal
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
async restartAllActiveWorkflowRuns() {
|
|
1184
|
+
const activeRuns = await this.listActiveWorkflowRuns();
|
|
1185
|
+
if (activeRuns.runs.length > 0) {
|
|
1186
|
+
this.#logger.debug(
|
|
1187
|
+
`Restarting ${activeRuns.runs.length} active workflow run${activeRuns.runs.length > 1 ? "s" : ""}`
|
|
1188
|
+
);
|
|
1189
|
+
}
|
|
1190
|
+
for (const runSnapshot of activeRuns.runs) {
|
|
1191
|
+
const workflow = this.getWorkflowById(runSnapshot.workflowName);
|
|
1192
|
+
try {
|
|
1193
|
+
const run = await workflow.createRun({ runId: runSnapshot.runId });
|
|
1194
|
+
await run.restart();
|
|
1195
|
+
this.#logger.debug(`Restarted ${runSnapshot.workflowName} workflow run ${runSnapshot.runId}`);
|
|
1196
|
+
} catch (error) {
|
|
1197
|
+
this.#logger.error(`Failed to restart ${runSnapshot.workflowName} workflow run ${runSnapshot.runId}: ${error}`);
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
869
1201
|
/**
|
|
870
1202
|
* Returns all registered scorers as a record keyed by their IDs.
|
|
871
1203
|
*
|
|
@@ -914,6 +1246,9 @@ var Mastra = class {
|
|
|
914
1246
|
* ```
|
|
915
1247
|
*/
|
|
916
1248
|
addScorer(scorer, key) {
|
|
1249
|
+
if (!scorer) {
|
|
1250
|
+
throw createUndefinedPrimitiveError("scorer", scorer, key);
|
|
1251
|
+
}
|
|
917
1252
|
const scorerKey = key || scorer.id;
|
|
918
1253
|
const scorers = this.#scorers;
|
|
919
1254
|
if (scorers[scorerKey]) {
|
|
@@ -921,6 +1256,7 @@ var Mastra = class {
|
|
|
921
1256
|
logger.debug(`Scorer with key ${scorerKey} already exists. Skipping addition.`);
|
|
922
1257
|
return;
|
|
923
1258
|
}
|
|
1259
|
+
scorer.__registerMastra(this);
|
|
924
1260
|
scorers[scorerKey] = scorer;
|
|
925
1261
|
}
|
|
926
1262
|
/**
|
|
@@ -1141,6 +1477,9 @@ var Mastra = class {
|
|
|
1141
1477
|
* ```
|
|
1142
1478
|
*/
|
|
1143
1479
|
addTool(tool, key) {
|
|
1480
|
+
if (!tool) {
|
|
1481
|
+
throw createUndefinedPrimitiveError("tool", tool, key);
|
|
1482
|
+
}
|
|
1144
1483
|
const toolKey = key || tool.id;
|
|
1145
1484
|
const tools = this.#tools;
|
|
1146
1485
|
if (tools[toolKey]) {
|
|
@@ -1276,6 +1615,9 @@ var Mastra = class {
|
|
|
1276
1615
|
* ```
|
|
1277
1616
|
*/
|
|
1278
1617
|
addProcessor(processor, key) {
|
|
1618
|
+
if (!processor) {
|
|
1619
|
+
throw createUndefinedPrimitiveError("processor", processor, key);
|
|
1620
|
+
}
|
|
1279
1621
|
const processorKey = key || processor.id;
|
|
1280
1622
|
const processors = this.#processors;
|
|
1281
1623
|
if (processors[processorKey]) {
|
|
@@ -1285,6 +1627,131 @@ var Mastra = class {
|
|
|
1285
1627
|
}
|
|
1286
1628
|
processors[processorKey] = processor;
|
|
1287
1629
|
}
|
|
1630
|
+
/**
|
|
1631
|
+
* Retrieves a registered memory instance by its registration key.
|
|
1632
|
+
*
|
|
1633
|
+
* @throws {MastraError} When the memory instance with the specified key is not found
|
|
1634
|
+
*
|
|
1635
|
+
* @example
|
|
1636
|
+
* ```typescript
|
|
1637
|
+
* const mastra = new Mastra({
|
|
1638
|
+
* memory: {
|
|
1639
|
+
* chat: new Memory({ storage })
|
|
1640
|
+
* }
|
|
1641
|
+
* });
|
|
1642
|
+
*
|
|
1643
|
+
* const chatMemory = mastra.getMemory('chat');
|
|
1644
|
+
* ```
|
|
1645
|
+
*/
|
|
1646
|
+
getMemory(name) {
|
|
1647
|
+
if (!this.#memory || !this.#memory[name]) {
|
|
1648
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
1649
|
+
id: "MASTRA_GET_MEMORY_BY_KEY_NOT_FOUND",
|
|
1650
|
+
domain: "MASTRA" /* MASTRA */,
|
|
1651
|
+
category: "USER" /* USER */,
|
|
1652
|
+
text: `Memory with key ${String(name)} not found`,
|
|
1653
|
+
details: {
|
|
1654
|
+
status: 404,
|
|
1655
|
+
memoryKey: String(name),
|
|
1656
|
+
memory: Object.keys(this.#memory ?? {}).join(", ")
|
|
1657
|
+
}
|
|
1658
|
+
});
|
|
1659
|
+
this.#logger?.trackException(error);
|
|
1660
|
+
throw error;
|
|
1661
|
+
}
|
|
1662
|
+
return this.#memory[name];
|
|
1663
|
+
}
|
|
1664
|
+
/**
|
|
1665
|
+
* Retrieves a registered memory instance by its ID.
|
|
1666
|
+
*
|
|
1667
|
+
* Searches through all registered memory instances and returns the one whose ID matches.
|
|
1668
|
+
*
|
|
1669
|
+
* @throws {MastraError} When no memory instance with the specified ID is found
|
|
1670
|
+
*
|
|
1671
|
+
* @example
|
|
1672
|
+
* ```typescript
|
|
1673
|
+
* const mastra = new Mastra({
|
|
1674
|
+
* memory: {
|
|
1675
|
+
* chat: new Memory({ id: 'chat-memory', storage })
|
|
1676
|
+
* }
|
|
1677
|
+
* });
|
|
1678
|
+
*
|
|
1679
|
+
* const memory = mastra.getMemoryById('chat-memory');
|
|
1680
|
+
* ```
|
|
1681
|
+
*/
|
|
1682
|
+
getMemoryById(id) {
|
|
1683
|
+
const allMemory = this.#memory;
|
|
1684
|
+
if (allMemory) {
|
|
1685
|
+
for (const [, memory] of Object.entries(allMemory)) {
|
|
1686
|
+
if (memory.id === id) {
|
|
1687
|
+
return memory;
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
1692
|
+
id: "MASTRA_GET_MEMORY_BY_ID_NOT_FOUND",
|
|
1693
|
+
domain: "MASTRA" /* MASTRA */,
|
|
1694
|
+
category: "USER" /* USER */,
|
|
1695
|
+
text: `Memory with id ${id} not found`,
|
|
1696
|
+
details: {
|
|
1697
|
+
status: 404,
|
|
1698
|
+
memoryId: id,
|
|
1699
|
+
availableIds: Object.values(allMemory ?? {}).map((m) => m.id).join(", ")
|
|
1700
|
+
}
|
|
1701
|
+
});
|
|
1702
|
+
this.#logger?.trackException(error);
|
|
1703
|
+
throw error;
|
|
1704
|
+
}
|
|
1705
|
+
/**
|
|
1706
|
+
* Returns all registered memory instances as a record keyed by their names.
|
|
1707
|
+
*
|
|
1708
|
+
* @example
|
|
1709
|
+
* ```typescript
|
|
1710
|
+
* const mastra = new Mastra({
|
|
1711
|
+
* memory: {
|
|
1712
|
+
* chat: new Memory({ storage }),
|
|
1713
|
+
* longTerm: new Memory({ storage })
|
|
1714
|
+
* }
|
|
1715
|
+
* });
|
|
1716
|
+
*
|
|
1717
|
+
* const allMemory = mastra.listMemory();
|
|
1718
|
+
* console.log(Object.keys(allMemory)); // ['chat', 'longTerm']
|
|
1719
|
+
* ```
|
|
1720
|
+
*/
|
|
1721
|
+
listMemory() {
|
|
1722
|
+
return this.#memory;
|
|
1723
|
+
}
|
|
1724
|
+
/**
|
|
1725
|
+
* Adds a new memory instance to the Mastra instance.
|
|
1726
|
+
*
|
|
1727
|
+
* This method allows dynamic registration of memory instances after the Mastra instance
|
|
1728
|
+
* has been created.
|
|
1729
|
+
*
|
|
1730
|
+
* @example
|
|
1731
|
+
* ```typescript
|
|
1732
|
+
* const mastra = new Mastra();
|
|
1733
|
+
* const chatMemory = new Memory({
|
|
1734
|
+
* id: 'chat-memory',
|
|
1735
|
+
* storage: mastra.getStorage()
|
|
1736
|
+
* });
|
|
1737
|
+
* mastra.addMemory(chatMemory); // Uses memory.id as key
|
|
1738
|
+
* // or
|
|
1739
|
+
* mastra.addMemory(chatMemory, 'customKey'); // Uses custom key
|
|
1740
|
+
* ```
|
|
1741
|
+
*/
|
|
1742
|
+
addMemory(memory, key) {
|
|
1743
|
+
if (!memory) {
|
|
1744
|
+
throw createUndefinedPrimitiveError("memory", memory, key);
|
|
1745
|
+
}
|
|
1746
|
+
const memoryKey = key || memory.id;
|
|
1747
|
+
const memoryRegistry = this.#memory;
|
|
1748
|
+
if (memoryRegistry[memoryKey]) {
|
|
1749
|
+
const logger = this.getLogger();
|
|
1750
|
+
logger.debug(`Memory with key ${memoryKey} already exists. Skipping addition.`);
|
|
1751
|
+
return;
|
|
1752
|
+
}
|
|
1753
|
+
memoryRegistry[memoryKey] = memory;
|
|
1754
|
+
}
|
|
1288
1755
|
/**
|
|
1289
1756
|
* Returns all registered workflows as a record keyed by their IDs.
|
|
1290
1757
|
*
|
|
@@ -1340,6 +1807,9 @@ var Mastra = class {
|
|
|
1340
1807
|
* ```
|
|
1341
1808
|
*/
|
|
1342
1809
|
addWorkflow(workflow, key) {
|
|
1810
|
+
if (!workflow) {
|
|
1811
|
+
throw createUndefinedPrimitiveError("workflow", workflow, key);
|
|
1812
|
+
}
|
|
1343
1813
|
const workflowKey = key || workflow.id;
|
|
1344
1814
|
const workflows = this.#workflows;
|
|
1345
1815
|
if (workflows[workflowKey]) {
|
|
@@ -1352,6 +1822,9 @@ var Mastra = class {
|
|
|
1352
1822
|
logger: this.getLogger(),
|
|
1353
1823
|
storage: this.getStorage()
|
|
1354
1824
|
});
|
|
1825
|
+
if (!workflow.committed) {
|
|
1826
|
+
workflow.commit();
|
|
1827
|
+
}
|
|
1355
1828
|
workflows[workflowKey] = workflow;
|
|
1356
1829
|
}
|
|
1357
1830
|
/**
|
|
@@ -1375,7 +1848,7 @@ var Mastra = class {
|
|
|
1375
1848
|
* ```
|
|
1376
1849
|
*/
|
|
1377
1850
|
setStorage(storage) {
|
|
1378
|
-
this.#storage =
|
|
1851
|
+
this.#storage = chunk52RSUALV_cjs.augmentWithInit(storage);
|
|
1379
1852
|
}
|
|
1380
1853
|
setLogger({ logger }) {
|
|
1381
1854
|
this.#logger = logger;
|
|
@@ -1405,6 +1878,9 @@ var Mastra = class {
|
|
|
1405
1878
|
this.#mcpServers?.[key]?.__setLogger(this.#logger);
|
|
1406
1879
|
});
|
|
1407
1880
|
}
|
|
1881
|
+
if (this.#serverAdapter) {
|
|
1882
|
+
this.#serverAdapter.__setLogger(this.#logger);
|
|
1883
|
+
}
|
|
1408
1884
|
this.#observability.setLogger({ logger: this.#logger });
|
|
1409
1885
|
}
|
|
1410
1886
|
/**
|
|
@@ -1518,6 +1994,74 @@ var Mastra = class {
|
|
|
1518
1994
|
getServer() {
|
|
1519
1995
|
return this.#server;
|
|
1520
1996
|
}
|
|
1997
|
+
/**
|
|
1998
|
+
* Sets the server adapter for this Mastra instance.
|
|
1999
|
+
*
|
|
2000
|
+
* The server adapter provides access to the underlying server app (e.g., Hono, Express)
|
|
2001
|
+
* and allows users to call routes directly via `app.fetch()` instead of making HTTP requests.
|
|
2002
|
+
*
|
|
2003
|
+
* This is typically called by `createHonoServer` or similar factory functions during
|
|
2004
|
+
* server initialization.
|
|
2005
|
+
*
|
|
2006
|
+
* @param adapter - The server adapter instance (e.g., MastraServer from @mastra/hono or @mastra/express)
|
|
2007
|
+
*
|
|
2008
|
+
* @example
|
|
2009
|
+
* ```typescript
|
|
2010
|
+
* const app = new Hono();
|
|
2011
|
+
* const adapter = new MastraServer({ app, mastra });
|
|
2012
|
+
* mastra.setMastraServer(adapter);
|
|
2013
|
+
* ```
|
|
2014
|
+
*/
|
|
2015
|
+
setMastraServer(adapter) {
|
|
2016
|
+
if (this.#serverAdapter) {
|
|
2017
|
+
this.#logger?.debug(
|
|
2018
|
+
"Replacing existing server adapter. Only one adapter should be registered per Mastra instance."
|
|
2019
|
+
);
|
|
2020
|
+
}
|
|
2021
|
+
this.#serverAdapter = adapter;
|
|
2022
|
+
if (this.#logger) {
|
|
2023
|
+
adapter.__setLogger(this.#logger);
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
/**
|
|
2027
|
+
* Gets the server adapter for this Mastra instance.
|
|
2028
|
+
*
|
|
2029
|
+
* @returns The server adapter, or undefined if not set
|
|
2030
|
+
*
|
|
2031
|
+
* @example
|
|
2032
|
+
* ```typescript
|
|
2033
|
+
* const adapter = mastra.getMastraServer();
|
|
2034
|
+
* if (adapter) {
|
|
2035
|
+
* const app = adapter.getApp<Hono>();
|
|
2036
|
+
* }
|
|
2037
|
+
* ```
|
|
2038
|
+
*/
|
|
2039
|
+
getMastraServer() {
|
|
2040
|
+
return this.#serverAdapter;
|
|
2041
|
+
}
|
|
2042
|
+
/**
|
|
2043
|
+
* Gets the server app from the server adapter.
|
|
2044
|
+
*
|
|
2045
|
+
* This is a convenience method that calls `getMastraServer()?.getApp<T>()`.
|
|
2046
|
+
* Use this to access the underlying server framework's app instance (e.g., Hono, Express)
|
|
2047
|
+
* for direct operations like calling routes via `app.fetch()`.
|
|
2048
|
+
*
|
|
2049
|
+
* @template T - The expected type of the app (e.g., Hono, Express Application)
|
|
2050
|
+
* @returns The server app, or undefined if no adapter is set
|
|
2051
|
+
*
|
|
2052
|
+
* @example
|
|
2053
|
+
* ```typescript
|
|
2054
|
+
* // After createHonoServer() is called:
|
|
2055
|
+
* const app = mastra.getServerApp<Hono>();
|
|
2056
|
+
*
|
|
2057
|
+
* // Call routes directly without HTTP overhead
|
|
2058
|
+
* const response = await app?.fetch(new Request('http://localhost/health'));
|
|
2059
|
+
* const data = await response?.json();
|
|
2060
|
+
* ```
|
|
2061
|
+
*/
|
|
2062
|
+
getServerApp() {
|
|
2063
|
+
return this.#serverAdapter?.getApp();
|
|
2064
|
+
}
|
|
1521
2065
|
getBundlerConfig() {
|
|
1522
2066
|
return this.#bundler;
|
|
1523
2067
|
}
|
|
@@ -1641,6 +2185,9 @@ var Mastra = class {
|
|
|
1641
2185
|
* ```
|
|
1642
2186
|
*/
|
|
1643
2187
|
addMCPServer(server, key) {
|
|
2188
|
+
if (!server) {
|
|
2189
|
+
throw createUndefinedPrimitiveError("mcp-server", server, key);
|
|
2190
|
+
}
|
|
1644
2191
|
if (key) {
|
|
1645
2192
|
server.setId(key);
|
|
1646
2193
|
}
|
|
@@ -1785,6 +2332,201 @@ var Mastra = class {
|
|
|
1785
2332
|
}
|
|
1786
2333
|
await this.#pubsub.flush();
|
|
1787
2334
|
}
|
|
2335
|
+
/**
|
|
2336
|
+
* Retrieves a registered gateway by its key.
|
|
2337
|
+
*
|
|
2338
|
+
* @throws {MastraError} When the gateway with the specified key is not found
|
|
2339
|
+
*
|
|
2340
|
+
* @example
|
|
2341
|
+
* ```typescript
|
|
2342
|
+
* const mastra = new Mastra({
|
|
2343
|
+
* gateways: {
|
|
2344
|
+
* myGateway: new CustomGateway()
|
|
2345
|
+
* }
|
|
2346
|
+
* });
|
|
2347
|
+
*
|
|
2348
|
+
* const gateway = mastra.getGateway('myGateway');
|
|
2349
|
+
* ```
|
|
2350
|
+
*/
|
|
2351
|
+
getGateway(key) {
|
|
2352
|
+
const gateway = this.#gateways?.[key];
|
|
2353
|
+
if (!gateway) {
|
|
2354
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
2355
|
+
id: "MASTRA_GET_GATEWAY_BY_KEY_NOT_FOUND",
|
|
2356
|
+
domain: "MASTRA" /* MASTRA */,
|
|
2357
|
+
category: "USER" /* USER */,
|
|
2358
|
+
text: `Gateway with key ${key} not found`,
|
|
2359
|
+
details: {
|
|
2360
|
+
status: 404,
|
|
2361
|
+
gatewayKey: key,
|
|
2362
|
+
gateways: Object.keys(this.#gateways ?? {}).join(", ")
|
|
2363
|
+
}
|
|
2364
|
+
});
|
|
2365
|
+
this.#logger?.trackException(error);
|
|
2366
|
+
throw error;
|
|
2367
|
+
}
|
|
2368
|
+
return gateway;
|
|
2369
|
+
}
|
|
2370
|
+
/**
|
|
2371
|
+
* Retrieves a registered gateway by its ID.
|
|
2372
|
+
*
|
|
2373
|
+
* Searches through all registered gateways and returns the one whose ID matches.
|
|
2374
|
+
* If a gateway doesn't have an explicit ID, its name is used as the ID.
|
|
2375
|
+
*
|
|
2376
|
+
* @throws {MastraError} When no gateway with the specified ID is found
|
|
2377
|
+
*
|
|
2378
|
+
* @example
|
|
2379
|
+
* ```typescript
|
|
2380
|
+
* class CustomGateway extends MastraModelGateway {
|
|
2381
|
+
* readonly id = 'custom-gateway-v1';
|
|
2382
|
+
* readonly name = 'Custom Gateway';
|
|
2383
|
+
* // ...
|
|
2384
|
+
* }
|
|
2385
|
+
*
|
|
2386
|
+
* const mastra = new Mastra({
|
|
2387
|
+
* gateways: {
|
|
2388
|
+
* myGateway: new CustomGateway()
|
|
2389
|
+
* }
|
|
2390
|
+
* });
|
|
2391
|
+
*
|
|
2392
|
+
* const gateway = mastra.getGatewayById('custom-gateway-v1');
|
|
2393
|
+
* ```
|
|
2394
|
+
*/
|
|
2395
|
+
getGatewayById(id) {
|
|
2396
|
+
const gateways = this.#gateways ?? {};
|
|
2397
|
+
for (const gateway of Object.values(gateways)) {
|
|
2398
|
+
if (gateway.getId() === id) {
|
|
2399
|
+
return gateway;
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
2403
|
+
id: "MASTRA_GET_GATEWAY_BY_ID_NOT_FOUND",
|
|
2404
|
+
domain: "MASTRA" /* MASTRA */,
|
|
2405
|
+
category: "USER" /* USER */,
|
|
2406
|
+
text: `Gateway with ID ${id} not found`,
|
|
2407
|
+
details: {
|
|
2408
|
+
status: 404,
|
|
2409
|
+
gatewayId: id,
|
|
2410
|
+
availableIds: Object.values(gateways).map((g) => g.getId()).join(", ")
|
|
2411
|
+
}
|
|
2412
|
+
});
|
|
2413
|
+
this.#logger?.trackException(error);
|
|
2414
|
+
throw error;
|
|
2415
|
+
}
|
|
2416
|
+
/**
|
|
2417
|
+
* Returns all registered gateways as a record keyed by their names.
|
|
2418
|
+
*
|
|
2419
|
+
* @example
|
|
2420
|
+
* ```typescript
|
|
2421
|
+
* const mastra = new Mastra({
|
|
2422
|
+
* gateways: {
|
|
2423
|
+
* netlify: new NetlifyGateway(),
|
|
2424
|
+
* custom: new CustomGateway()
|
|
2425
|
+
* }
|
|
2426
|
+
* });
|
|
2427
|
+
*
|
|
2428
|
+
* const allGateways = mastra.listGateways();
|
|
2429
|
+
* console.log(Object.keys(allGateways)); // ['netlify', 'custom']
|
|
2430
|
+
* ```
|
|
2431
|
+
*/
|
|
2432
|
+
listGateways() {
|
|
2433
|
+
return this.#gateways;
|
|
2434
|
+
}
|
|
2435
|
+
/**
|
|
2436
|
+
* Adds a new gateway to the Mastra instance.
|
|
2437
|
+
*
|
|
2438
|
+
* This method allows dynamic registration of gateways after the Mastra instance
|
|
2439
|
+
* has been created. Gateways enable access to LLM providers through custom
|
|
2440
|
+
* authentication and routing logic.
|
|
2441
|
+
*
|
|
2442
|
+
* If no key is provided, the gateway's ID (or name if no ID is set) will be used as the key.
|
|
2443
|
+
*
|
|
2444
|
+
* @example
|
|
2445
|
+
* ```typescript
|
|
2446
|
+
* import { MastraModelGateway } from '@mastra/core';
|
|
2447
|
+
*
|
|
2448
|
+
* class CustomGateway extends MastraModelGateway {
|
|
2449
|
+
* readonly id = 'custom-gateway-v1'; // Optional, defaults to name
|
|
2450
|
+
* readonly name = 'custom';
|
|
2451
|
+
* readonly prefix = 'custom';
|
|
2452
|
+
*
|
|
2453
|
+
* async fetchProviders() {
|
|
2454
|
+
* return {
|
|
2455
|
+
* myProvider: {
|
|
2456
|
+
* name: 'My Provider',
|
|
2457
|
+
* models: ['model-1', 'model-2'],
|
|
2458
|
+
* apiKeyEnvVar: 'MY_API_KEY',
|
|
2459
|
+
* gateway: 'custom'
|
|
2460
|
+
* }
|
|
2461
|
+
* };
|
|
2462
|
+
* }
|
|
2463
|
+
*
|
|
2464
|
+
* buildUrl(modelId: string) {
|
|
2465
|
+
* return 'https://api.myprovider.com/v1';
|
|
2466
|
+
* }
|
|
2467
|
+
*
|
|
2468
|
+
* async getApiKey(modelId: string) {
|
|
2469
|
+
* return process.env.MY_API_KEY || '';
|
|
2470
|
+
* }
|
|
2471
|
+
*
|
|
2472
|
+
* async resolveLanguageModel({ modelId, providerId, apiKey }) {
|
|
2473
|
+
* const baseURL = this.buildUrl(`${providerId}/${modelId}`);
|
|
2474
|
+
* return createOpenAICompatible({
|
|
2475
|
+
* name: providerId,
|
|
2476
|
+
* apiKey,
|
|
2477
|
+
* baseURL,
|
|
2478
|
+
* supportsStructuredOutputs: true,
|
|
2479
|
+
* }).chatModel(modelId);
|
|
2480
|
+
* }
|
|
2481
|
+
* }
|
|
2482
|
+
*
|
|
2483
|
+
* const mastra = new Mastra();
|
|
2484
|
+
* const newGateway = new CustomGateway();
|
|
2485
|
+
* mastra.addGateway(newGateway); // Uses gateway.getId() as key (gateway.id)
|
|
2486
|
+
* // or
|
|
2487
|
+
* mastra.addGateway(newGateway, 'customKey'); // Uses custom key
|
|
2488
|
+
* ```
|
|
2489
|
+
*/
|
|
2490
|
+
addGateway(gateway, key) {
|
|
2491
|
+
if (!gateway) {
|
|
2492
|
+
throw createUndefinedPrimitiveError("gateway", gateway, key);
|
|
2493
|
+
}
|
|
2494
|
+
const gatewayKey = key || gateway.getId();
|
|
2495
|
+
const gateways = this.#gateways;
|
|
2496
|
+
if (gateways[gatewayKey]) {
|
|
2497
|
+
const logger = this.getLogger();
|
|
2498
|
+
logger.debug(`Gateway with key ${gatewayKey} already exists. Skipping addition.`);
|
|
2499
|
+
return;
|
|
2500
|
+
}
|
|
2501
|
+
gateways[gatewayKey] = gateway;
|
|
2502
|
+
this.#syncGatewayRegistry();
|
|
2503
|
+
}
|
|
2504
|
+
/**
|
|
2505
|
+
* Sync custom gateways with the GatewayRegistry for type generation
|
|
2506
|
+
* @private
|
|
2507
|
+
*/
|
|
2508
|
+
#syncGatewayRegistry() {
|
|
2509
|
+
try {
|
|
2510
|
+
if (process.env.MASTRA_DEV !== "true" && process.env.MASTRA_DEV !== "1") {
|
|
2511
|
+
return;
|
|
2512
|
+
}
|
|
2513
|
+
import('./provider-registry-3TG2KUD2.cjs').then(async ({ GatewayRegistry }) => {
|
|
2514
|
+
const registry = GatewayRegistry.getInstance();
|
|
2515
|
+
const customGateways = Object.values(this.#gateways || {});
|
|
2516
|
+
registry.registerCustomGateways(customGateways);
|
|
2517
|
+
const logger = this.getLogger();
|
|
2518
|
+
logger.info("\u{1F504} Syncing custom gateway types...");
|
|
2519
|
+
await registry.syncGateways(true);
|
|
2520
|
+
logger.info("\u2705 Custom gateway types synced! Restart your TypeScript server to see autocomplete.");
|
|
2521
|
+
}).catch((err) => {
|
|
2522
|
+
const logger = this.getLogger();
|
|
2523
|
+
logger.debug("Gateway registry sync skipped:", err);
|
|
2524
|
+
});
|
|
2525
|
+
} catch (err) {
|
|
2526
|
+
const logger = this.getLogger();
|
|
2527
|
+
logger.debug("Gateway registry sync failed:", err);
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
1788
2530
|
/**
|
|
1789
2531
|
* Gracefully shuts down the Mastra instance and cleans up all resources.
|
|
1790
2532
|
*
|
|
@@ -1822,5 +2564,5 @@ var Mastra = class {
|
|
|
1822
2564
|
};
|
|
1823
2565
|
|
|
1824
2566
|
exports.Mastra = Mastra;
|
|
1825
|
-
//# sourceMappingURL=chunk-
|
|
1826
|
-
//# sourceMappingURL=chunk-
|
|
2567
|
+
//# sourceMappingURL=chunk-SCUWP4II.cjs.map
|
|
2568
|
+
//# sourceMappingURL=chunk-SCUWP4II.cjs.map
|