@mastra/core 0.24.0 → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +478 -141
- package/README.md +2 -3
- package/agent/message-list.d.ts +1 -0
- package/dist/action/index.d.ts +0 -2
- package/dist/action/index.d.ts.map +1 -1
- package/dist/agent/__tests__/mock-model.d.ts +3 -1
- package/dist/agent/__tests__/mock-model.d.ts.map +1 -1
- package/dist/agent/agent-legacy.d.ts +176 -0
- package/dist/agent/agent-legacy.d.ts.map +1 -0
- package/dist/agent/agent.d.ts +83 -229
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.types.d.ts +10 -25
- package/dist/agent/agent.types.d.ts.map +1 -1
- package/dist/agent/index.cjs +10 -26
- package/dist/agent/index.d.ts +1 -2
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/index.cjs +16 -0
- package/dist/agent/message-list/index.d.ts +77 -87
- package/dist/agent/message-list/index.d.ts.map +1 -1
- package/dist/agent/message-list/index.js +3 -0
- package/dist/agent/message-list/prompt/attachments-to-parts.d.ts +2 -2
- package/dist/agent/message-list/prompt/attachments-to-parts.d.ts.map +1 -1
- package/dist/agent/message-list/prompt/convert-to-mastra-v1.d.ts +2 -2
- package/dist/agent/message-list/prompt/download-assets.d.ts.map +1 -1
- package/dist/agent/message-list/prompt/invalid-content-error.d.ts +1 -1
- package/dist/agent/message-list/prompt/invalid-content-error.d.ts.map +1 -1
- package/dist/agent/message-list/types.d.ts +2 -1
- package/dist/agent/message-list/types.d.ts.map +1 -1
- package/dist/agent/message-list/utils/ai-v4-v5/core-model-message.d.ts +3 -2
- package/dist/agent/message-list/utils/ai-v4-v5/core-model-message.d.ts.map +1 -1
- package/dist/agent/message-list/utils/ai-v4-v5/ui-message.d.ts +3 -2
- package/dist/agent/message-list/utils/ai-v4-v5/ui-message.d.ts.map +1 -1
- package/dist/agent/message-list/utils/ai-v5/gemini-compatibility.d.ts +1 -1
- package/dist/agent/message-list/utils/ai-v5/gemini-compatibility.d.ts.map +1 -1
- package/dist/agent/message-list/utils/convert-messages.d.ts +4 -4
- package/dist/agent/message-list/utils/convert-messages.d.ts.map +1 -1
- package/dist/agent/test-utils.d.ts +2 -79
- package/dist/agent/test-utils.d.ts.map +1 -1
- package/dist/agent/trip-wire.d.ts +1 -1
- package/dist/agent/trip-wire.d.ts.map +1 -1
- package/dist/agent/types.d.ts +23 -37
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/utils.d.ts +15 -64
- package/dist/agent/utils.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts +16 -20
- package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts +5 -7
- 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 +14 -18
- 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 +6 -6
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/schema.d.ts +10 -12
- package/dist/agent/workflows/prepare-stream/schema.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts +3 -7
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts.map +1 -1
- package/dist/ai-sdk.types.d.ts +4705 -0
- package/dist/base.cjs +2 -2
- package/dist/base.d.ts +0 -16
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +1 -1
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.d.ts +2 -1
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/index.js +1 -1
- package/dist/cache/index.cjs +3 -3
- package/dist/cache/index.js +1 -1
- package/dist/chunk-26SQQNMU.js +15754 -0
- package/dist/chunk-26SQQNMU.js.map +1 -0
- package/dist/{chunk-FHVFGVIO.js → chunk-32CTMD2C.js} +90 -32
- package/dist/chunk-32CTMD2C.js.map +1 -0
- package/dist/chunk-4CDL2QJT.js +649 -0
- package/dist/chunk-4CDL2QJT.js.map +1 -0
- package/dist/chunk-5WRI5ZAA.js +29 -0
- package/dist/{chunk-3HXBPDKN.js.map → chunk-5WRI5ZAA.js.map} +1 -1
- package/dist/{chunk-KAEQISOW.js → chunk-76K3IYWM.js} +5 -5
- package/dist/chunk-76K3IYWM.js.map +1 -0
- package/dist/chunk-7AHYOMHJ.js +149 -0
- package/dist/chunk-7AHYOMHJ.js.map +1 -0
- package/dist/{chunk-BWGXM3D4.js → chunk-7SKXKUYT.js} +712 -541
- package/dist/chunk-7SKXKUYT.js.map +1 -0
- package/dist/{chunk-UZKIGB7M.cjs → chunk-BMAFVZ2D.cjs} +5 -5
- package/dist/chunk-BMAFVZ2D.cjs.map +1 -0
- package/dist/chunk-BNBRQS7N.js +910 -0
- package/dist/chunk-BNBRQS7N.js.map +1 -0
- package/dist/{chunk-34ZCWSUA.js → chunk-BU4IAJWF.js} +6 -9
- package/dist/chunk-BU4IAJWF.js.map +1 -0
- package/dist/{chunk-ABZOBBLL.cjs → chunk-BXOL277H.cjs} +735 -562
- package/dist/chunk-BXOL277H.cjs.map +1 -0
- package/dist/{chunk-6TEQIYXV.cjs → chunk-CBAB7GOD.cjs} +15 -15
- package/dist/chunk-CBAB7GOD.cjs.map +1 -0
- package/dist/{chunk-A5KDVZDL.cjs → chunk-DSNPWVIG.cjs} +9 -9
- package/dist/chunk-DSNPWVIG.cjs.map +1 -0
- package/dist/chunk-DZUJEN5N.cjs +32 -0
- package/dist/{chunk-EBVYYC2Q.cjs.map → chunk-DZUJEN5N.cjs.map} +1 -1
- package/dist/chunk-E7K4FTLN.cjs +273 -0
- package/dist/chunk-E7K4FTLN.cjs.map +1 -0
- package/dist/{chunk-MJMID7LX.cjs → chunk-ECFXGXWO.cjs} +609 -644
- package/dist/chunk-ECFXGXWO.cjs.map +1 -0
- package/dist/chunk-ET6UOTTU.cjs +154 -0
- package/dist/chunk-ET6UOTTU.cjs.map +1 -0
- package/dist/chunk-FD734TPS.cjs +15818 -0
- package/dist/chunk-FD734TPS.cjs.map +1 -0
- package/dist/chunk-GGYKYORQ.cjs +2060 -0
- package/dist/chunk-GGYKYORQ.cjs.map +1 -0
- package/dist/{chunk-HLRWYUFN.js → chunk-GRBGQ2GE.js} +5 -5
- package/dist/{chunk-HLRWYUFN.js.map → chunk-GRBGQ2GE.js.map} +1 -1
- package/dist/chunk-IU2SZXJQ.cjs +913 -0
- package/dist/chunk-IU2SZXJQ.cjs.map +1 -0
- package/dist/{chunk-GPWMM745.cjs → chunk-J7O6WENZ.cjs} +5 -5
- package/dist/{chunk-GPWMM745.cjs.map → chunk-J7O6WENZ.cjs.map} +1 -1
- package/dist/{chunk-PZUZNPFM.js → chunk-JJ5O45LH.js} +3 -4
- package/dist/chunk-JJ5O45LH.js.map +1 -0
- package/dist/{chunk-E3PG7G6E.js → chunk-JV2KH24V.js} +599 -633
- package/dist/chunk-JV2KH24V.js.map +1 -0
- package/dist/chunk-KEXGB7FK.cjs +29 -0
- package/dist/chunk-KEXGB7FK.cjs.map +1 -0
- package/dist/chunk-KIZIOFZC.js +265 -0
- package/dist/chunk-KIZIOFZC.js.map +1 -0
- package/dist/{chunk-UXG7PYML.js → chunk-KJ2SW6VA.js} +9 -9
- package/dist/chunk-KJ2SW6VA.js.map +1 -0
- package/dist/{chunk-TTELJD4F.js → chunk-L54GIUCB.js} +2 -2
- package/dist/chunk-L54GIUCB.js.map +1 -0
- package/dist/chunk-L7XKOKOW.js +12385 -0
- package/dist/chunk-L7XKOKOW.js.map +1 -0
- package/dist/{chunk-TSNDVBUU.cjs → chunk-MR7ZWBL6.cjs} +2 -2
- package/dist/chunk-MR7ZWBL6.cjs.map +1 -0
- package/dist/chunk-MV7KHWUT.js +2031 -0
- package/dist/chunk-MV7KHWUT.js.map +1 -0
- package/dist/{chunk-3NTOFNIU.js → chunk-OJNJA5ZI.js} +3 -3
- package/dist/{chunk-3NTOFNIU.js.map → chunk-OJNJA5ZI.js.map} +1 -1
- package/dist/{chunk-3VXXCPKX.js → chunk-P6APHXPZ.js} +334 -410
- package/dist/chunk-P6APHXPZ.js.map +1 -0
- package/dist/{chunk-77JHIM4E.cjs → chunk-QCQLOMJM.cjs} +348 -424
- package/dist/chunk-QCQLOMJM.cjs.map +1 -0
- package/dist/chunk-QM5SRDJX.js +9022 -0
- package/dist/chunk-QM5SRDJX.js.map +1 -0
- package/dist/{chunk-WBAXXG34.cjs → chunk-QUKUN6NR.cjs} +32 -66
- package/dist/chunk-QUKUN6NR.cjs.map +1 -0
- package/dist/{chunk-ROS5CMJS.cjs → chunk-QUZGDSWE.cjs} +63 -50
- package/dist/chunk-QUZGDSWE.cjs.map +1 -0
- package/dist/chunk-S5MJLXMG.cjs +12424 -0
- package/dist/chunk-S5MJLXMG.cjs.map +1 -0
- package/dist/chunk-S6URFGCZ.js +27 -0
- package/dist/chunk-S6URFGCZ.js.map +1 -0
- package/dist/chunk-SVLMF4UZ.cjs +9033 -0
- package/dist/chunk-SVLMF4UZ.cjs.map +1 -0
- package/dist/{chunk-ZMELUU72.js → chunk-TQTAMPSC.js} +3 -3
- package/dist/chunk-TQTAMPSC.js.map +1 -0
- package/dist/{chunk-5NTO7S5I.cjs → chunk-TWH4PTDG.cjs} +2 -4
- package/dist/chunk-TWH4PTDG.cjs.map +1 -0
- package/dist/{chunk-WCHE6FJ7.js → chunk-UIZSWUKP.js} +15 -50
- package/dist/chunk-UIZSWUKP.js.map +1 -0
- package/dist/{chunk-Z4RIRDU3.js → chunk-VJUZZB2I.js} +45 -32
- package/dist/chunk-VJUZZB2I.js.map +1 -0
- package/dist/{chunk-MCASUJWY.cjs → chunk-VOY2RXOC.cjs} +36 -59
- package/dist/chunk-VOY2RXOC.cjs.map +1 -0
- package/dist/{chunk-3JX2Y3WH.cjs → chunk-VV753WCB.cjs} +18 -21
- package/dist/chunk-VV753WCB.cjs.map +1 -0
- package/dist/chunk-WM6CK2F3.cjs +674 -0
- package/dist/chunk-WM6CK2F3.cjs.map +1 -0
- package/dist/{chunk-PFXXH2RP.js → chunk-X7JMA3IY.js} +15 -15
- package/dist/chunk-X7JMA3IY.js.map +1 -0
- package/dist/{chunk-NR77P3TK.js → chunk-XEVG546F.js} +14 -37
- package/dist/chunk-XEVG546F.js.map +1 -0
- package/dist/{chunk-QFF5JUKT.cjs → chunk-Y63IFHEZ.cjs} +4 -4
- package/dist/chunk-Y63IFHEZ.cjs.map +1 -0
- package/dist/{chunk-B7V6NYWH.cjs → chunk-Y6ROD72V.cjs} +4 -4
- package/dist/{chunk-B7V6NYWH.cjs.map → chunk-Y6ROD72V.cjs.map} +1 -1
- package/dist/{chunk-7J3XX4AO.cjs → chunk-YIK3ASEG.cjs} +100 -42
- package/dist/chunk-YIK3ASEG.cjs.map +1 -0
- package/dist/deployer/index.cjs +8 -6
- package/dist/deployer/index.cjs.map +1 -1
- package/dist/deployer/index.js +10 -1
- package/dist/deployer/index.js.map +1 -1
- package/dist/di/index.cjs +3 -3
- package/dist/di/index.d.ts +1 -1
- package/dist/di/index.js +1 -1
- package/dist/error/index.cjs +6 -6
- package/dist/error/index.d.ts +0 -1
- package/dist/error/index.d.ts.map +1 -1
- package/dist/error/index.js +1 -1
- package/dist/{scores → evals}/base.d.ts +20 -18
- package/dist/evals/base.d.ts.map +1 -0
- package/dist/{scores → evals}/base.test-utils.d.ts +25 -25
- package/dist/evals/base.test-utils.d.ts.map +1 -0
- package/dist/{scores → evals}/hooks.d.ts +3 -3
- package/dist/evals/hooks.d.ts.map +1 -0
- package/dist/evals/index.cjs +37 -0
- package/dist/evals/index.d.ts +4 -0
- package/dist/evals/index.d.ts.map +1 -0
- package/dist/evals/index.js +4 -0
- package/dist/{scores/run-experiment → evals/run}/index.d.ts +18 -18
- package/dist/evals/run/index.d.ts.map +1 -0
- package/dist/evals/run/scorerAccumulator.d.ts.map +1 -0
- package/dist/{scores → evals}/scoreTraces/index.cjs +79 -99
- package/dist/evals/scoreTraces/index.cjs.map +1 -0
- package/dist/evals/scoreTraces/index.d.ts.map +1 -0
- package/dist/{scores → evals}/scoreTraces/index.js +72 -92
- package/dist/evals/scoreTraces/index.js.map +1 -0
- package/dist/{scores → evals}/scoreTraces/scoreTraces.d.ts +2 -2
- package/dist/evals/scoreTraces/scoreTraces.d.ts.map +1 -0
- package/dist/{scores → evals}/scoreTraces/scoreTracesWorkflow.d.ts +11 -11
- package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts.map +1 -0
- package/dist/{scores → evals}/scoreTraces/utils.d.ts +7 -7
- package/dist/evals/scoreTraces/utils.d.ts.map +1 -0
- package/dist/{scores → evals}/types.d.ts +22 -22
- package/dist/evals/types.d.ts.map +1 -0
- package/dist/features/index.cjs +8 -0
- package/dist/features/index.cjs.map +1 -0
- package/dist/features/index.d.ts +17 -0
- package/dist/features/index.d.ts.map +1 -0
- package/dist/features/index.js +6 -0
- package/dist/features/index.js.map +1 -0
- package/dist/hooks/index.cjs +4 -4
- package/dist/hooks/index.d.ts +1 -27
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/index.cjs +2 -340
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -113
- package/dist/index.js.map +1 -1
- package/dist/integration/index.cjs +87 -10
- package/dist/integration/index.cjs.map +1 -1
- package/dist/integration/index.js +88 -1
- package/dist/integration/index.js.map +1 -1
- package/dist/integration/integration.d.ts +3 -3
- package/dist/integration/integration.d.ts.map +1 -1
- package/dist/llm/index.cjs +7 -7
- package/dist/llm/index.d.ts +5 -6
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +1 -1
- package/dist/llm/model/base.types.d.ts +6 -7
- package/dist/llm/model/base.types.d.ts.map +1 -1
- package/dist/llm/model/model.d.ts +7 -7
- package/dist/llm/model/model.d.ts.map +1 -1
- package/dist/llm/model/model.loop.d.ts +1 -1
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/llm/model/model.loop.types.d.ts +3 -3
- package/dist/llm/model/model.loop.types.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +32 -7
- package/dist/llm/model/resolve-model.d.ts +8 -8
- package/dist/llm/model/shared.types.d.ts +2 -2
- package/dist/llm/model/shared.types.d.ts.map +1 -1
- package/dist/logger/constants.d.ts +1 -1
- package/dist/logger/default-logger.d.ts +2 -2
- package/dist/logger/default-logger.d.ts.map +1 -1
- package/dist/logger/index.cjs +11 -11
- package/dist/logger/index.js +2 -2
- package/dist/logger/logger.d.ts +4 -4
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/multi-logger.d.ts +2 -2
- package/dist/logger/multi-logger.d.ts.map +1 -1
- package/dist/logger/transport.d.ts +3 -3
- 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 +1 -1
- package/dist/loop/loop.d.ts.map +1 -1
- package/dist/loop/network/index.d.ts +15 -15
- package/dist/loop/network/index.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/types.d.ts +4 -7
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +55 -55
- package/dist/loop/workflows/agentic-execution/index.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +38 -38
- 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 -20
- 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 +2 -2
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts +55 -55
- package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
- package/dist/loop/workflows/schema.d.ts +19 -20
- 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/hooks.d.ts +2 -2
- package/dist/mastra/hooks.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +389 -180
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/mcp/index.cjs +41 -4
- package/dist/mcp/index.cjs.map +1 -1
- package/dist/mcp/index.d.ts +6 -4
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +39 -2
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/types.d.ts +0 -15
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/memory/index.cjs +327 -13
- package/dist/memory/index.cjs.map +1 -1
- package/dist/memory/index.d.ts +1 -0
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +327 -1
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/memory.d.ts +33 -57
- package/dist/memory/memory.d.ts.map +1 -1
- package/dist/memory/mock.d.ts +61 -0
- package/dist/memory/mock.d.ts.map +1 -0
- package/dist/memory/types.d.ts +48 -45
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/models-dev-7U4NRMM3.js +3 -0
- package/dist/{models-dev-4VGIWYS3.js.map → models-dev-7U4NRMM3.js.map} +1 -1
- package/dist/models-dev-VKSAQPRK.cjs +12 -0
- package/dist/{models-dev-AXZASLL2.cjs.map → models-dev-VKSAQPRK.cjs.map} +1 -1
- package/dist/netlify-2IDXTNFW.cjs +12 -0
- package/dist/{netlify-TX6V7SJJ.cjs.map → netlify-2IDXTNFW.cjs.map} +1 -1
- package/dist/netlify-42ZNWIDQ.js +3 -0
- package/dist/{netlify-VJXBII33.js.map → netlify-42ZNWIDQ.js.map} +1 -1
- package/dist/{ai-tracing → observability}/context.d.ts +5 -5
- package/dist/observability/context.d.ts.map +1 -0
- package/dist/observability/index.cjs +36 -0
- package/dist/observability/index.d.ts +11 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +3 -0
- package/dist/observability/no-op.d.ts +22 -0
- package/dist/observability/no-op.d.ts.map +1 -0
- package/dist/observability/types/index.d.ts +2 -0
- package/dist/observability/types/index.d.ts.map +1 -0
- package/dist/{ai-tracing/types.d.ts → observability/types/tracing.d.ts} +161 -107
- package/dist/observability/types/tracing.d.ts.map +1 -0
- package/dist/observability/utils.d.ts +12 -0
- package/dist/observability/utils.d.ts.map +1 -0
- package/dist/processors/index.cjs +11 -11
- package/dist/processors/index.d.ts +10 -9
- package/dist/processors/index.d.ts.map +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/processors/batch-parts.d.ts +2 -1
- package/dist/processors/processors/batch-parts.d.ts.map +1 -1
- package/dist/processors/processors/language-detector.d.ts +6 -5
- package/dist/processors/processors/language-detector.d.ts.map +1 -1
- package/dist/processors/processors/moderation.d.ts +8 -7
- package/dist/processors/processors/moderation.d.ts.map +1 -1
- package/dist/processors/processors/pii-detector.d.ts +8 -7
- package/dist/processors/processors/pii-detector.d.ts.map +1 -1
- package/dist/processors/processors/prompt-injection-detector.d.ts +6 -5
- package/dist/processors/processors/prompt-injection-detector.d.ts.map +1 -1
- package/dist/processors/processors/structured-output.d.ts +3 -2
- package/dist/processors/processors/structured-output.d.ts.map +1 -1
- package/dist/processors/processors/system-prompt-scrubber.d.ts +6 -5
- package/dist/processors/processors/system-prompt-scrubber.d.ts.map +1 -1
- package/dist/processors/processors/token-limiter.d.ts +5 -4
- package/dist/processors/processors/token-limiter.d.ts.map +1 -1
- package/dist/processors/processors/unicode-normalizer.d.ts +5 -4
- package/dist/processors/processors/unicode-normalizer.d.ts.map +1 -1
- package/dist/processors/runner.d.ts +5 -5
- package/dist/processors/runner.d.ts.map +1 -1
- package/dist/provider-registry.json +76 -18
- package/dist/{registry-generator-DXRSYYYT.js → registry-generator-H4YNODDH.js} +2 -2
- package/dist/{registry-generator-DXRSYYYT.js.map → registry-generator-H4YNODDH.js.map} +1 -1
- package/dist/{registry-generator-6WVOHM2L.cjs → registry-generator-MK63POJO.cjs} +2 -2
- package/dist/{registry-generator-6WVOHM2L.cjs.map → registry-generator-MK63POJO.cjs.map} +1 -1
- package/dist/relevance/index.cjs +47 -13
- package/dist/relevance/index.cjs.map +1 -1
- package/dist/relevance/index.d.ts +0 -1
- package/dist/relevance/index.d.ts.map +1 -1
- package/dist/relevance/index.js +49 -1
- package/dist/relevance/index.js.map +1 -1
- package/dist/relevance/mastra-agent/index.d.ts.map +1 -1
- package/dist/request-context/index.cjs +12 -0
- package/dist/{runtime-context → request-context}/index.d.ts +1 -1
- package/dist/{runtime-context → request-context}/index.d.ts.map +1 -1
- package/dist/request-context/index.js +3 -0
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/index.cjs +9 -25
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +4 -21
- package/dist/server/index.js.map +1 -1
- package/dist/server/types.d.ts +3 -3
- package/dist/server/types.d.ts.map +1 -1
- package/dist/storage/base.d.ts +75 -143
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/constants.d.ts +3 -4
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/domains/index.d.ts +0 -2
- package/dist/storage/domains/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/base.d.ts +19 -56
- package/dist/storage/domains/memory/base.d.ts.map +1 -1
- package/dist/storage/domains/memory/inmemory.d.ts +15 -35
- package/dist/storage/domains/memory/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/observability/base.d.ts +24 -24
- package/dist/storage/domains/observability/base.d.ts.map +1 -1
- package/dist/storage/domains/observability/inmemory.d.ts +18 -18
- package/dist/storage/domains/observability/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 +5 -5
- package/dist/storage/domains/scores/base.d.ts.map +1 -1
- package/dist/storage/domains/scores/inmemory.d.ts +5 -5
- package/dist/storage/domains/scores/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/workflows/base.d.ts +4 -11
- package/dist/storage/domains/workflows/base.d.ts.map +1 -1
- package/dist/storage/domains/workflows/inmemory.d.ts +4 -11
- package/dist/storage/domains/workflows/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +74 -1775
- package/dist/storage/index.cjs.map +1 -1
- package/dist/storage/index.js +1 -1744
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/mock.d.ts +35 -92
- package/dist/storage/mock.d.ts.map +1 -1
- package/dist/storage/types.d.ts +77 -75
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/MastraAgentNetworkStream.d.ts +4 -2
- package/dist/stream/MastraAgentNetworkStream.d.ts.map +1 -1
- package/dist/stream/MastraWorkflowStream.d.ts +1 -1
- package/dist/stream/MastraWorkflowStream.d.ts.map +1 -1
- package/dist/stream/RunOutput.d.ts +1 -0
- package/dist/stream/RunOutput.d.ts.map +1 -1
- package/dist/stream/aisdk/v4/input.d.ts +1 -1
- package/dist/stream/aisdk/v4/input.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/execute.d.ts +4 -11
- package/dist/stream/aisdk/v5/execute.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/output.d.ts +1 -1
- package/dist/stream/aisdk/v5/output.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts +1 -1
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +11 -11
- package/dist/stream/index.d.ts +1 -1
- package/dist/stream/index.d.ts.map +1 -1
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +2 -6
- package/dist/stream/types.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.cjs +8 -8
- package/dist/test-utils/llm-mock.cjs.map +1 -1
- package/dist/test-utils/llm-mock.d.ts +1 -1
- package/dist/test-utils/llm-mock.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.js +3 -3
- package/dist/test-utils/llm-mock.js.map +1 -1
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.js +1 -1
- package/dist/tools/is-vercel-tool.cjs +2 -2
- package/dist/tools/is-vercel-tool.js +1 -1
- package/dist/tools/tool-builder/builder.d.ts +3 -71
- package/dist/tools/tool-builder/builder.d.ts.map +1 -1
- package/dist/tools/tool.d.ts +25 -25
- package/dist/tools/tool.d.ts.map +1 -1
- package/dist/tools/types.d.ts +102 -11
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/validation.d.ts +4 -3
- package/dist/tools/validation.d.ts.map +1 -1
- package/dist/tts/index.cjs +12 -6
- package/dist/tts/index.cjs.map +1 -1
- package/dist/tts/index.d.ts +0 -1
- package/dist/tts/index.d.ts.map +1 -1
- package/dist/tts/index.js +14 -1
- package/dist/tts/index.js.map +1 -1
- package/dist/types/dynamic-argument.d.ts +3 -3
- package/dist/utils/fetchWithRetry.d.ts +9 -0
- package/dist/utils/fetchWithRetry.d.ts.map +1 -0
- package/dist/utils.cjs +33 -17
- package/dist/utils.d.ts +39 -6
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/vector/embed.d.ts +1 -1
- package/dist/vector/embed.d.ts.map +1 -1
- package/dist/vector/index.cjs +80 -8
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.js +80 -1
- package/dist/vector/index.js.map +1 -1
- package/dist/vector/vector.d.ts +5 -2
- package/dist/vector/vector.d.ts.map +1 -1
- package/dist/voice/composite-voice.d.ts +1 -7
- package/dist/voice/composite-voice.d.ts.map +1 -1
- package/dist/voice/index.cjs +4 -4
- package/dist/voice/index.js +1 -1
- package/dist/voice/voice.d.ts +0 -1
- package/dist/voice/voice.d.ts.map +1 -1
- package/dist/workflows/default.d.ts +35 -43
- package/dist/workflows/default.d.ts.map +1 -1
- package/dist/workflows/evented/execution-engine.d.ts +5 -3
- 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 +15 -13
- package/dist/workflows/evented/step-executor.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/index.d.ts +5 -5
- package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/loop.d.ts +3 -3
- 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/sleep.d.ts +2 -2
- package/dist/workflows/evented/workflow-event-processor/utils.d.ts +2 -7
- package/dist/workflows/evented/workflow-event-processor/utils.d.ts.map +1 -1
- package/dist/workflows/evented/workflow.d.ts +11 -14
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/execution-engine.d.ts +6 -6
- package/dist/workflows/execution-engine.d.ts.map +1 -1
- package/dist/workflows/index.cjs +22 -14
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/step.d.ts +5 -5
- package/dist/workflows/step.d.ts.map +1 -1
- package/dist/workflows/types.d.ts +20 -44
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/utils.d.ts +14 -0
- package/dist/workflows/utils.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts +74 -64
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/evals/scoreTraces.d.ts +1 -0
- package/evals.d.ts +1 -0
- package/features.d.ts +1 -0
- package/observability.d.ts +1 -0
- package/package.json +48 -64
- package/request-context.d.ts +1 -0
- package/src/_types/ai-sdk.types.d.ts +4705 -0
- package/src/llm/model/provider-types.generated.d.ts +32 -7
- package/agent/input-processor/processors.d.ts +0 -1
- package/ai-tracing.d.ts +0 -1
- package/dist/agent/index.warning.d.ts +0 -13
- package/dist/agent/index.warning.d.ts.map +0 -1
- package/dist/agent/input-processor/index.cjs +0 -28
- package/dist/agent/input-processor/index.d.ts +0 -10
- package/dist/agent/input-processor/index.d.ts.map +0 -1
- package/dist/agent/input-processor/index.js +0 -3
- package/dist/agent/input-processor/processors/index.d.ts +0 -6
- package/dist/agent/input-processor/processors/index.d.ts.map +0 -1
- package/dist/agent/input-processor/processors/language-detector.d.ts +0 -18
- package/dist/agent/input-processor/processors/language-detector.d.ts.map +0 -1
- package/dist/agent/input-processor/processors/moderation.d.ts +0 -18
- package/dist/agent/input-processor/processors/moderation.d.ts.map +0 -1
- package/dist/agent/input-processor/processors/pii-detector.d.ts +0 -18
- package/dist/agent/input-processor/processors/pii-detector.d.ts.map +0 -1
- package/dist/agent/input-processor/processors/prompt-injection-detector.d.ts +0 -18
- package/dist/agent/input-processor/processors/prompt-injection-detector.d.ts.map +0 -1
- package/dist/agent/input-processor/processors/unicode-normalizer.d.ts +0 -18
- package/dist/agent/input-processor/processors/unicode-normalizer.d.ts.map +0 -1
- package/dist/ai-tracing/context.d.ts.map +0 -1
- package/dist/ai-tracing/exporters/base.d.ts +0 -111
- package/dist/ai-tracing/exporters/base.d.ts.map +0 -1
- package/dist/ai-tracing/exporters/cloud.d.ts +0 -30
- package/dist/ai-tracing/exporters/cloud.d.ts.map +0 -1
- package/dist/ai-tracing/exporters/console.d.ts +0 -10
- package/dist/ai-tracing/exporters/console.d.ts.map +0 -1
- package/dist/ai-tracing/exporters/default.d.ts +0 -98
- package/dist/ai-tracing/exporters/default.d.ts.map +0 -1
- package/dist/ai-tracing/exporters/index.d.ts +0 -9
- package/dist/ai-tracing/exporters/index.d.ts.map +0 -1
- package/dist/ai-tracing/index.cjs +0 -148
- package/dist/ai-tracing/index.d.ts +0 -13
- package/dist/ai-tracing/index.d.ts.map +0 -1
- package/dist/ai-tracing/index.js +0 -3
- package/dist/ai-tracing/model-tracing.d.ts +0 -63
- package/dist/ai-tracing/model-tracing.d.ts.map +0 -1
- package/dist/ai-tracing/registry.d.ts +0 -51
- package/dist/ai-tracing/registry.d.ts.map +0 -1
- package/dist/ai-tracing/span_processors/index.d.ts +0 -5
- package/dist/ai-tracing/span_processors/index.d.ts.map +0 -1
- package/dist/ai-tracing/span_processors/sensitive-data-filter.d.ts +0 -85
- package/dist/ai-tracing/span_processors/sensitive-data-filter.d.ts.map +0 -1
- package/dist/ai-tracing/spans/base.d.ts +0 -65
- package/dist/ai-tracing/spans/base.d.ts.map +0 -1
- package/dist/ai-tracing/spans/default.d.ts +0 -13
- package/dist/ai-tracing/spans/default.d.ts.map +0 -1
- package/dist/ai-tracing/spans/index.d.ts +0 -7
- package/dist/ai-tracing/spans/index.d.ts.map +0 -1
- package/dist/ai-tracing/spans/no-op.d.ts +0 -15
- package/dist/ai-tracing/spans/no-op.d.ts.map +0 -1
- package/dist/ai-tracing/tracers/base.d.ts +0 -105
- package/dist/ai-tracing/tracers/base.d.ts.map +0 -1
- package/dist/ai-tracing/tracers/default.d.ts +0 -7
- package/dist/ai-tracing/tracers/default.d.ts.map +0 -1
- package/dist/ai-tracing/tracers/index.d.ts +0 -6
- package/dist/ai-tracing/tracers/index.d.ts.map +0 -1
- package/dist/ai-tracing/types.d.ts.map +0 -1
- package/dist/ai-tracing/utils.d.ts +0 -68
- package/dist/ai-tracing/utils.d.ts.map +0 -1
- package/dist/base.warning.d.ts +0 -9
- package/dist/base.warning.d.ts.map +0 -1
- package/dist/bundler/index.warning.d.ts +0 -9
- package/dist/bundler/index.warning.d.ts.map +0 -1
- package/dist/chunk-253FBVD4.cjs +0 -1303
- package/dist/chunk-253FBVD4.cjs.map +0 -1
- package/dist/chunk-2B3VLGTH.js +0 -87
- package/dist/chunk-2B3VLGTH.js.map +0 -1
- package/dist/chunk-34ZCWSUA.js.map +0 -1
- package/dist/chunk-3HXBPDKN.js +0 -105
- package/dist/chunk-3JX2Y3WH.cjs.map +0 -1
- package/dist/chunk-3VXXCPKX.js.map +0 -1
- package/dist/chunk-4R2TBRS7.cjs +0 -191
- package/dist/chunk-4R2TBRS7.cjs.map +0 -1
- package/dist/chunk-5NTO7S5I.cjs.map +0 -1
- package/dist/chunk-6C7VGVK4.js +0 -267
- package/dist/chunk-6C7VGVK4.js.map +0 -1
- package/dist/chunk-6KOL2B3A.cjs +0 -75
- package/dist/chunk-6KOL2B3A.cjs.map +0 -1
- package/dist/chunk-6TEQIYXV.cjs.map +0 -1
- package/dist/chunk-6VOPKVYH.cjs +0 -57
- package/dist/chunk-6VOPKVYH.cjs.map +0 -1
- package/dist/chunk-77JHIM4E.cjs.map +0 -1
- package/dist/chunk-7J3XX4AO.cjs.map +0 -1
- package/dist/chunk-A5KDVZDL.cjs.map +0 -1
- package/dist/chunk-ABZOBBLL.cjs.map +0 -1
- package/dist/chunk-AQGLVU53.cjs +0 -603
- package/dist/chunk-AQGLVU53.cjs.map +0 -1
- package/dist/chunk-BLUDYAPI.js +0 -596
- package/dist/chunk-BLUDYAPI.js.map +0 -1
- package/dist/chunk-BWGXM3D4.js.map +0 -1
- package/dist/chunk-C7OVZMPW.cjs +0 -91
- package/dist/chunk-C7OVZMPW.cjs.map +0 -1
- package/dist/chunk-DMBN72QF.cjs +0 -39
- package/dist/chunk-DMBN72QF.cjs.map +0 -1
- package/dist/chunk-DTTOVV72.js +0 -2880
- package/dist/chunk-DTTOVV72.js.map +0 -1
- package/dist/chunk-E3PG7G6E.js.map +0 -1
- package/dist/chunk-EBVYYC2Q.cjs +0 -111
- package/dist/chunk-FHVFGVIO.js.map +0 -1
- package/dist/chunk-GB5BIA4V.js +0 -167
- package/dist/chunk-GB5BIA4V.js.map +0 -1
- package/dist/chunk-HEQTUMUA.cjs +0 -271
- package/dist/chunk-HEQTUMUA.cjs.map +0 -1
- package/dist/chunk-HF3GZRFP.cjs +0 -9
- package/dist/chunk-HF3GZRFP.cjs.map +0 -1
- package/dist/chunk-JVV5LREI.js +0 -431
- package/dist/chunk-JVV5LREI.js.map +0 -1
- package/dist/chunk-KAEQISOW.js.map +0 -1
- package/dist/chunk-KDX3ZMQ2.js +0 -12
- package/dist/chunk-KDX3ZMQ2.js.map +0 -1
- package/dist/chunk-LG5B3KIW.js +0 -1215
- package/dist/chunk-LG5B3KIW.js.map +0 -1
- package/dist/chunk-LZUSZT7R.cjs +0 -170
- package/dist/chunk-LZUSZT7R.cjs.map +0 -1
- package/dist/chunk-MCASUJWY.cjs.map +0 -1
- package/dist/chunk-MJMID7LX.cjs.map +0 -1
- package/dist/chunk-MKCC5K77.js +0 -90
- package/dist/chunk-MKCC5K77.js.map +0 -1
- package/dist/chunk-NPNGPMT2.js +0 -39
- package/dist/chunk-NPNGPMT2.js.map +0 -1
- package/dist/chunk-NR77P3TK.js.map +0 -1
- package/dist/chunk-NUAURT4I.cjs +0 -82
- package/dist/chunk-NUAURT4I.cjs.map +0 -1
- package/dist/chunk-OIT3PCWA.js +0 -72
- package/dist/chunk-OIT3PCWA.js.map +0 -1
- package/dist/chunk-P35FNLTQ.cjs +0 -2936
- package/dist/chunk-P35FNLTQ.cjs.map +0 -1
- package/dist/chunk-PFXXH2RP.js.map +0 -1
- package/dist/chunk-PZUZNPFM.js.map +0 -1
- package/dist/chunk-QFF5JUKT.cjs.map +0 -1
- package/dist/chunk-RKXWLG33.js +0 -7
- package/dist/chunk-RKXWLG33.js.map +0 -1
- package/dist/chunk-ROS5CMJS.cjs.map +0 -1
- package/dist/chunk-SJMKDSRF.js +0 -179
- package/dist/chunk-SJMKDSRF.js.map +0 -1
- package/dist/chunk-SSULK22X.cjs +0 -14
- package/dist/chunk-SSULK22X.cjs.map +0 -1
- package/dist/chunk-TSNDVBUU.cjs.map +0 -1
- package/dist/chunk-TTELJD4F.js.map +0 -1
- package/dist/chunk-TX4TTPYJ.cjs +0 -436
- package/dist/chunk-TX4TTPYJ.cjs.map +0 -1
- package/dist/chunk-UXG7PYML.js.map +0 -1
- package/dist/chunk-UZKIGB7M.cjs.map +0 -1
- package/dist/chunk-VF676YCO.cjs +0 -150
- package/dist/chunk-VF676YCO.cjs.map +0 -1
- package/dist/chunk-VQASQG5D.js +0 -55
- package/dist/chunk-VQASQG5D.js.map +0 -1
- package/dist/chunk-WBAXXG34.cjs.map +0 -1
- package/dist/chunk-WCHE6FJ7.js.map +0 -1
- package/dist/chunk-WM4RO23J.js +0 -145
- package/dist/chunk-WM4RO23J.js.map +0 -1
- package/dist/chunk-Z4RIRDU3.js.map +0 -1
- package/dist/chunk-ZABG3SZ2.cjs +0 -93
- package/dist/chunk-ZABG3SZ2.cjs.map +0 -1
- package/dist/chunk-ZISECZZO.js +0 -72
- package/dist/chunk-ZISECZZO.js.map +0 -1
- package/dist/chunk-ZMELUU72.js.map +0 -1
- package/dist/deployer/index.warning.d.ts +0 -9
- package/dist/deployer/index.warning.d.ts.map +0 -1
- package/dist/eval/evaluation.d.ts +0 -14
- package/dist/eval/evaluation.d.ts.map +0 -1
- package/dist/eval/index.cjs +0 -16
- package/dist/eval/index.d.ts +0 -4
- package/dist/eval/index.d.ts.map +0 -1
- package/dist/eval/index.js +0 -3
- package/dist/eval/metric.d.ts +0 -8
- package/dist/eval/metric.d.ts.map +0 -1
- package/dist/eval/types.d.ts +0 -9
- package/dist/eval/types.d.ts.map +0 -1
- package/dist/integration/index.warning.d.ts +0 -3
- package/dist/integration/index.warning.d.ts.map +0 -1
- package/dist/integration/integration.warning.d.ts +0 -5
- package/dist/integration/integration.warning.d.ts.map +0 -1
- package/dist/integration/openapi-toolset.warning.d.ts +0 -5
- package/dist/integration/openapi-toolset.warning.d.ts.map +0 -1
- package/dist/loop/telemetry/index.d.ts +0 -36
- package/dist/loop/telemetry/index.d.ts.map +0 -1
- package/dist/loop/telemetry/noop.d.ts +0 -3
- package/dist/loop/telemetry/noop.d.ts.map +0 -1
- package/dist/loop/test-utils/mockTracer.d.ts +0 -47
- package/dist/loop/test-utils/mockTracer.d.ts.map +0 -1
- package/dist/loop/test-utils/telemetry.d.ts +0 -6
- package/dist/loop/test-utils/telemetry.d.ts.map +0 -1
- package/dist/memory/index.warning.d.ts +0 -6
- package/dist/memory/index.warning.d.ts.map +0 -1
- package/dist/models-dev-4VGIWYS3.js +0 -3
- package/dist/models-dev-AXZASLL2.cjs +0 -12
- package/dist/netlify-TX6V7SJJ.cjs +0 -12
- package/dist/netlify-VJXBII33.js +0 -3
- package/dist/relevance/cohere/index.d.ts +0 -9
- package/dist/relevance/cohere/index.d.ts.map +0 -1
- package/dist/runtime-context/index.cjs +0 -12
- package/dist/runtime-context/index.js +0 -3
- package/dist/scores/base.d.ts.map +0 -1
- package/dist/scores/base.test-utils.d.ts.map +0 -1
- package/dist/scores/hooks.d.ts.map +0 -1
- package/dist/scores/index.cjs +0 -37
- package/dist/scores/index.cjs.map +0 -1
- package/dist/scores/index.d.ts +0 -4
- package/dist/scores/index.d.ts.map +0 -1
- package/dist/scores/index.js +0 -4
- package/dist/scores/index.js.map +0 -1
- package/dist/scores/run-experiment/index.d.ts.map +0 -1
- package/dist/scores/run-experiment/scorerAccumulator.d.ts.map +0 -1
- package/dist/scores/scoreTraces/index.cjs.map +0 -1
- package/dist/scores/scoreTraces/index.d.ts.map +0 -1
- package/dist/scores/scoreTraces/index.js.map +0 -1
- package/dist/scores/scoreTraces/scoreTraces.d.ts.map +0 -1
- package/dist/scores/scoreTraces/scoreTracesWorkflow.d.ts.map +0 -1
- package/dist/scores/scoreTraces/utils.d.ts.map +0 -1
- package/dist/scores/types.d.ts.map +0 -1
- package/dist/storage/base.warning.d.ts +0 -8
- package/dist/storage/base.warning.d.ts.map +0 -1
- package/dist/storage/domains/legacy-evals/base.d.ts +0 -13
- package/dist/storage/domains/legacy-evals/base.d.ts.map +0 -1
- package/dist/storage/domains/legacy-evals/index.d.ts +0 -2
- package/dist/storage/domains/legacy-evals/index.d.ts.map +0 -1
- package/dist/storage/domains/legacy-evals/inmemory.d.ts +0 -17
- package/dist/storage/domains/legacy-evals/inmemory.d.ts.map +0 -1
- package/dist/storage/domains/traces/base.d.ts +0 -14
- package/dist/storage/domains/traces/base.d.ts.map +0 -1
- package/dist/storage/domains/traces/index.d.ts +0 -3
- package/dist/storage/domains/traces/index.d.ts.map +0 -1
- package/dist/storage/domains/traces/inmemory.d.ts +0 -22
- package/dist/storage/domains/traces/inmemory.d.ts.map +0 -1
- package/dist/storage/index.warning.d.ts +0 -3
- package/dist/storage/index.warning.d.ts.map +0 -1
- package/dist/telemetry/composite-exporter.d.ts +0 -10
- package/dist/telemetry/composite-exporter.d.ts.map +0 -1
- package/dist/telemetry/index.cjs +0 -32
- package/dist/telemetry/index.cjs.map +0 -1
- package/dist/telemetry/index.d.ts +0 -6
- package/dist/telemetry/index.d.ts.map +0 -1
- package/dist/telemetry/index.js +0 -3
- package/dist/telemetry/index.js.map +0 -1
- package/dist/telemetry/otel-vendor.cjs +0 -105
- package/dist/telemetry/otel-vendor.cjs.map +0 -1
- package/dist/telemetry/otel-vendor.d.ts +0 -11
- package/dist/telemetry/otel-vendor.d.ts.map +0 -1
- package/dist/telemetry/otel-vendor.js +0 -59
- package/dist/telemetry/otel-vendor.js.map +0 -1
- package/dist/telemetry/storage-exporter.d.ts +0 -21
- package/dist/telemetry/storage-exporter.d.ts.map +0 -1
- package/dist/telemetry/telemetry.d.ts +0 -59
- package/dist/telemetry/telemetry.d.ts.map +0 -1
- package/dist/telemetry/telemetry.decorators.d.ts +0 -15
- package/dist/telemetry/telemetry.decorators.d.ts.map +0 -1
- package/dist/telemetry/types.d.ts +0 -74
- package/dist/telemetry/types.d.ts.map +0 -1
- package/dist/telemetry/utility.d.ts +0 -15
- package/dist/telemetry/utility.d.ts.map +0 -1
- package/dist/tools/index.warning.d.ts +0 -8
- package/dist/tools/index.warning.d.ts.map +0 -1
- package/dist/tts/index.warning.d.ts +0 -7
- package/dist/tts/index.warning.d.ts.map +0 -1
- package/dist/vector/index.warning.d.ts +0 -6
- package/dist/vector/index.warning.d.ts.map +0 -1
- package/dist/workflows/index.warning.d.ts +0 -6
- package/dist/workflows/index.warning.d.ts.map +0 -1
- package/dist/workflows/legacy/index.cjs +0 -92
- package/dist/workflows/legacy/index.cjs.map +0 -1
- package/dist/workflows/legacy/index.d.ts +0 -5
- package/dist/workflows/legacy/index.d.ts.map +0 -1
- package/dist/workflows/legacy/index.js +0 -3
- package/dist/workflows/legacy/index.js.map +0 -1
- package/dist/workflows/legacy/machine.d.ts +0 -386
- package/dist/workflows/legacy/machine.d.ts.map +0 -1
- package/dist/workflows/legacy/step.d.ts +0 -15
- package/dist/workflows/legacy/step.d.ts.map +0 -1
- package/dist/workflows/legacy/types.d.ts +0 -397
- package/dist/workflows/legacy/types.d.ts.map +0 -1
- package/dist/workflows/legacy/utils.d.ts +0 -68
- package/dist/workflows/legacy/utils.d.ts.map +0 -1
- package/dist/workflows/legacy/workflow-instance.d.ts +0 -97
- package/dist/workflows/legacy/workflow-instance.d.ts.map +0 -1
- package/dist/workflows/legacy/workflow.d.ts +0 -109
- package/dist/workflows/legacy/workflow.d.ts.map +0 -1
- package/dist/workflows/workflow.warning.d.ts +0 -9
- package/dist/workflows/workflow.warning.d.ts.map +0 -1
- package/eval.d.ts +0 -1
- package/runtime-context.d.ts +0 -1
- package/scores/scoreTraces.d.ts +0 -1
- package/scores.d.ts +0 -1
- package/telemetry/otel-vendor.d.ts +0 -1
- package/telemetry.d.ts +0 -1
- package/workflows/legacy.d.ts +0 -1
- /package/dist/agent/{input-processor → message-list}/index.cjs.map +0 -0
- /package/dist/agent/{input-processor → message-list}/index.js.map +0 -0
- /package/dist/{ai-tracing → evals}/index.cjs.map +0 -0
- /package/dist/{ai-tracing → evals}/index.js.map +0 -0
- /package/dist/{scores/run-experiment → evals/run}/scorerAccumulator.d.ts +0 -0
- /package/dist/{scores → evals}/scoreTraces/index.d.ts +0 -0
- /package/dist/{eval → observability}/index.cjs.map +0 -0
- /package/dist/{eval → observability}/index.js.map +0 -0
- /package/dist/{runtime-context → request-context}/index.cjs.map +0 -0
- /package/dist/{runtime-context → request-context}/index.js.map +0 -0
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var chunkUZKIGB7M_cjs = require('./chunk-UZKIGB7M.cjs');
|
|
3
|
+
var chunkQCQLOMJM_cjs = require('./chunk-QCQLOMJM.cjs');
|
|
5
4
|
var chunkV3VLOOSW_cjs = require('./chunk-V3VLOOSW.cjs');
|
|
5
|
+
var chunkBMAFVZ2D_cjs = require('./chunk-BMAFVZ2D.cjs');
|
|
6
6
|
var chunk4D4KB75Y_cjs = require('./chunk-4D4KB75Y.cjs');
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var chunkA5KDVZDL_cjs = require('./chunk-A5KDVZDL.cjs');
|
|
14
|
-
var chunkEBVYYC2Q_cjs = require('./chunk-EBVYYC2Q.cjs');
|
|
7
|
+
var chunkCBAB7GOD_cjs = require('./chunk-CBAB7GOD.cjs');
|
|
8
|
+
var chunkMR7ZWBL6_cjs = require('./chunk-MR7ZWBL6.cjs');
|
|
9
|
+
var chunkE7K4FTLN_cjs = require('./chunk-E7K4FTLN.cjs');
|
|
10
|
+
var chunkTWH4PTDG_cjs = require('./chunk-TWH4PTDG.cjs');
|
|
11
|
+
var chunkY6ROD72V_cjs = require('./chunk-Y6ROD72V.cjs');
|
|
12
|
+
var chunkDSNPWVIG_cjs = require('./chunk-DSNPWVIG.cjs');
|
|
15
13
|
var crypto$1 = require('crypto');
|
|
16
14
|
var EventEmitter = require('events');
|
|
17
15
|
var pMap = require('p-map');
|
|
@@ -29,7 +27,7 @@ var EventEmitterPubSub = class extends chunk4D4KB75Y_cjs.PubSub {
|
|
|
29
27
|
}
|
|
30
28
|
async publish(topic, event) {
|
|
31
29
|
const id = crypto.randomUUID();
|
|
32
|
-
const createdAt = /* @__PURE__ */new Date();
|
|
30
|
+
const createdAt = /* @__PURE__ */ new Date();
|
|
33
31
|
this.emitter.emit(topic, {
|
|
34
32
|
...event,
|
|
35
33
|
id,
|
|
@@ -42,10 +40,11 @@ var EventEmitterPubSub = class extends chunk4D4KB75Y_cjs.PubSub {
|
|
|
42
40
|
async unsubscribe(topic, cb) {
|
|
43
41
|
this.emitter.off(topic, cb);
|
|
44
42
|
}
|
|
45
|
-
async flush() {
|
|
43
|
+
async flush() {
|
|
44
|
+
}
|
|
46
45
|
};
|
|
47
46
|
function createOnScorerHook(mastra) {
|
|
48
|
-
return async hookData => {
|
|
47
|
+
return async (hookData) => {
|
|
49
48
|
const storage = mastra.getStorage();
|
|
50
49
|
if (!storage) {
|
|
51
50
|
mastra.getLogger()?.warn("Storage not found, skipping score validation and saving");
|
|
@@ -54,22 +53,24 @@ function createOnScorerHook(mastra) {
|
|
|
54
53
|
const entityId = hookData.entity.id;
|
|
55
54
|
const entityType = hookData.entityType;
|
|
56
55
|
const scorer = hookData.scorer;
|
|
56
|
+
const scorerId = scorer.id;
|
|
57
|
+
if (!scorerId) {
|
|
58
|
+
mastra.getLogger()?.warn("Scorer ID not found, skipping score validation and saving");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
57
61
|
try {
|
|
58
|
-
const scorerToUse = await findScorer(mastra, entityId, entityType,
|
|
62
|
+
const scorerToUse = await findScorer(mastra, entityId, entityType, scorerId);
|
|
59
63
|
if (!scorerToUse) {
|
|
60
|
-
throw new
|
|
64
|
+
throw new chunkTWH4PTDG_cjs.MastraError({
|
|
61
65
|
id: "MASTRA_SCORER_NOT_FOUND",
|
|
62
66
|
domain: "MASTRA" /* MASTRA */,
|
|
63
67
|
category: "USER" /* USER */,
|
|
64
|
-
text: `Scorer with ID ${
|
|
68
|
+
text: `Scorer with ID ${scorerId} not found`
|
|
65
69
|
});
|
|
66
70
|
}
|
|
67
71
|
let input = hookData.input;
|
|
68
72
|
let output = hookData.output;
|
|
69
|
-
const {
|
|
70
|
-
structuredOutput,
|
|
71
|
-
...rest
|
|
72
|
-
} = hookData;
|
|
73
|
+
const { structuredOutput, ...rest } = hookData;
|
|
73
74
|
const runResult = await scorerToUse.scorer.run({
|
|
74
75
|
...rest,
|
|
75
76
|
input,
|
|
@@ -86,7 +87,7 @@ function createOnScorerHook(mastra) {
|
|
|
86
87
|
...rest,
|
|
87
88
|
...runResult,
|
|
88
89
|
entityId,
|
|
89
|
-
scorerId
|
|
90
|
+
scorerId,
|
|
90
91
|
spanId,
|
|
91
92
|
traceId,
|
|
92
93
|
metadata: {
|
|
@@ -95,93 +96,92 @@ function createOnScorerHook(mastra) {
|
|
|
95
96
|
};
|
|
96
97
|
await validateAndSaveScore(storage, payload);
|
|
97
98
|
if (currentSpan && spanId && traceId) {
|
|
98
|
-
await pMap__default.default(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
99
|
+
await pMap__default.default(
|
|
100
|
+
currentSpan.observabilityInstance.getExporters(),
|
|
101
|
+
async (exporter) => {
|
|
102
|
+
if (exporter.addScoreToTrace) {
|
|
103
|
+
try {
|
|
104
|
+
await exporter.addScoreToTrace({
|
|
105
|
+
traceId,
|
|
106
|
+
spanId,
|
|
107
|
+
score: runResult.score,
|
|
108
|
+
reason: runResult.reason,
|
|
109
|
+
scorerName: scorerToUse.scorer.id,
|
|
110
|
+
metadata: {
|
|
111
|
+
...currentSpan.metadata ?? {}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
} catch (error) {
|
|
115
|
+
mastra.getLogger()?.error(`Failed to add score to trace via exporter: ${error}`);
|
|
108
116
|
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
});
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
{ concurrency: 3 }
|
|
120
|
+
);
|
|
114
121
|
}
|
|
115
122
|
} catch (error) {
|
|
116
|
-
const mastraError = new
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
const mastraError = new chunkTWH4PTDG_cjs.MastraError(
|
|
124
|
+
{
|
|
125
|
+
id: "MASTRA_SCORER_FAILED_TO_RUN_HOOK",
|
|
126
|
+
domain: "SCORER" /* SCORER */,
|
|
127
|
+
category: "USER" /* USER */,
|
|
128
|
+
details: {
|
|
129
|
+
scorerId: scorer.id,
|
|
130
|
+
entityId,
|
|
131
|
+
entityType
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
error
|
|
135
|
+
);
|
|
126
136
|
mastra.getLogger()?.trackException(mastraError);
|
|
127
137
|
mastra.getLogger()?.error(mastraError.toString());
|
|
128
138
|
}
|
|
129
139
|
};
|
|
130
140
|
}
|
|
131
141
|
async function validateAndSaveScore(storage, payload) {
|
|
132
|
-
const payloadToSave =
|
|
142
|
+
const payloadToSave = chunkBMAFVZ2D_cjs.saveScorePayloadSchema.parse(payload);
|
|
133
143
|
await storage?.saveScore(payloadToSave);
|
|
134
144
|
}
|
|
135
|
-
async function findScorer(mastra, entityId, entityType,
|
|
145
|
+
async function findScorer(mastra, entityId, entityType, scorerId) {
|
|
136
146
|
let scorerToUse;
|
|
137
147
|
if (entityType === "AGENT") {
|
|
138
|
-
const scorers = await mastra.getAgentById(entityId).
|
|
148
|
+
const scorers = await mastra.getAgentById(entityId).listScorers();
|
|
139
149
|
for (const [_, scorer] of Object.entries(scorers)) {
|
|
140
|
-
if (scorer.scorer.
|
|
150
|
+
if (scorer.scorer.id === scorerId) {
|
|
141
151
|
scorerToUse = scorer;
|
|
142
152
|
break;
|
|
143
153
|
}
|
|
144
154
|
}
|
|
145
155
|
} else if (entityType === "WORKFLOW") {
|
|
146
|
-
const scorers = await mastra.getWorkflowById(entityId).
|
|
156
|
+
const scorers = await mastra.getWorkflowById(entityId).listScorers();
|
|
147
157
|
for (const [_, scorer] of Object.entries(scorers)) {
|
|
148
|
-
if (scorer.scorer.
|
|
158
|
+
if (scorer.scorer.id === scorerId) {
|
|
149
159
|
scorerToUse = scorer;
|
|
150
160
|
break;
|
|
151
161
|
}
|
|
152
162
|
}
|
|
153
163
|
}
|
|
154
164
|
if (!scorerToUse) {
|
|
155
|
-
const mastraRegisteredScorer = mastra.
|
|
156
|
-
scorerToUse = mastraRegisteredScorer ? {
|
|
157
|
-
scorer: mastraRegisteredScorer
|
|
158
|
-
} : void 0;
|
|
165
|
+
const mastraRegisteredScorer = mastra.getScorerById(scorerId);
|
|
166
|
+
scorerToUse = mastraRegisteredScorer ? { scorer: mastraRegisteredScorer } : void 0;
|
|
159
167
|
}
|
|
160
168
|
return scorerToUse;
|
|
161
169
|
}
|
|
162
170
|
|
|
163
171
|
// src/mastra/index.ts
|
|
164
|
-
var
|
|
165
|
-
_Mastra_decorators = [chunkAQGLVU53_cjs.InstrumentClass({
|
|
166
|
-
prefix: "mastra",
|
|
167
|
-
excludeMethods: ["getLogger", "getTelemetry"]
|
|
168
|
-
})];
|
|
169
|
-
exports.Mastra = class Mastra {
|
|
172
|
+
var Mastra = class {
|
|
170
173
|
#vectors;
|
|
171
174
|
#agents;
|
|
172
175
|
#logger;
|
|
173
|
-
#legacy_workflows;
|
|
174
176
|
#workflows;
|
|
177
|
+
#observability;
|
|
175
178
|
#tts;
|
|
176
179
|
#deployer;
|
|
177
180
|
#serverMiddleware = [];
|
|
178
|
-
/**
|
|
179
|
-
* @deprecated Use {@link getAITracing()} instead.
|
|
180
|
-
*/
|
|
181
|
-
#telemetry;
|
|
182
181
|
#storage;
|
|
183
|
-
#memory;
|
|
184
182
|
#scorers;
|
|
183
|
+
#tools;
|
|
184
|
+
#processors;
|
|
185
185
|
#server;
|
|
186
186
|
#mcpServers;
|
|
187
187
|
#bundler;
|
|
@@ -191,24 +191,6 @@ exports.Mastra = class Mastra {
|
|
|
191
191
|
#internalMastraWorkflows = {};
|
|
192
192
|
// This is only used internally for server handlers that require temporary persistence
|
|
193
193
|
#serverCache;
|
|
194
|
-
/**
|
|
195
|
-
* @deprecated use {@link getAITracing()} instead
|
|
196
|
-
*/
|
|
197
|
-
get telemetry() {
|
|
198
|
-
return this.#telemetry;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* @deprecated use getStorage() instead
|
|
202
|
-
*/
|
|
203
|
-
get storage() {
|
|
204
|
-
return this.#storage;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* @deprecated use getMemory() instead
|
|
208
|
-
*/
|
|
209
|
-
get memory() {
|
|
210
|
-
return this.#memory;
|
|
211
|
-
}
|
|
212
194
|
get pubsub() {
|
|
213
195
|
return this.#pubsub;
|
|
214
196
|
}
|
|
@@ -246,7 +228,7 @@ exports.Mastra = class Mastra {
|
|
|
246
228
|
if (this.#idGenerator) {
|
|
247
229
|
const id = this.#idGenerator();
|
|
248
230
|
if (!id) {
|
|
249
|
-
const error = new
|
|
231
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
250
232
|
id: "MASTRA_ID_GENERATOR_RETURNED_EMPTY_STRING",
|
|
251
233
|
domain: "MASTRA" /* MASTRA */,
|
|
252
234
|
category: "USER" /* USER */,
|
|
@@ -281,14 +263,15 @@ exports.Mastra = class Mastra {
|
|
|
281
263
|
* Creates a new Mastra instance with the provided configuration.
|
|
282
264
|
*
|
|
283
265
|
* The constructor initializes all the components specified in the config, sets up
|
|
284
|
-
* internal systems like logging and
|
|
266
|
+
* internal systems like logging and observability, and registers components with each other.
|
|
285
267
|
*
|
|
286
268
|
* @example
|
|
287
269
|
* ```typescript
|
|
288
270
|
* const mastra = new Mastra({
|
|
289
271
|
* agents: {
|
|
290
272
|
* assistant: new Agent({
|
|
291
|
-
*
|
|
273
|
+
* id: 'assistant',
|
|
274
|
+
* name: 'Assistant',
|
|
292
275
|
* instructions: 'You are a helpful assistant',
|
|
293
276
|
* model: 'openai/gpt-5'
|
|
294
277
|
* })
|
|
@@ -296,18 +279,13 @@ exports.Mastra = class Mastra {
|
|
|
296
279
|
* storage: new PostgresStore({
|
|
297
280
|
* connectionString: process.env.DATABASE_URL
|
|
298
281
|
* }),
|
|
299
|
-
* logger: new PinoLogger({ name: 'MyApp' })
|
|
282
|
+
* logger: new PinoLogger({ name: 'MyApp' }),
|
|
283
|
+
* observability: { default: { enabled: true }},
|
|
300
284
|
* });
|
|
301
285
|
* ```
|
|
302
286
|
*/
|
|
303
287
|
constructor(config) {
|
|
304
|
-
|
|
305
|
-
this.#serverMiddleware = config.serverMiddleware.map(m => ({
|
|
306
|
-
handler: m.handler,
|
|
307
|
-
path: m.path || "/api/*"
|
|
308
|
-
}));
|
|
309
|
-
}
|
|
310
|
-
this.#serverCache = new chunkB7V6NYWH_cjs.InMemoryServerCache();
|
|
288
|
+
this.#serverCache = new chunkY6ROD72V_cjs.InMemoryServerCache();
|
|
311
289
|
if (config?.pubsub) {
|
|
312
290
|
this.#pubsub = config.pubsub;
|
|
313
291
|
} else {
|
|
@@ -321,9 +299,7 @@ exports.Mastra = class Mastra {
|
|
|
321
299
|
this.#events[topic] = config?.events?.[topic] ?? [];
|
|
322
300
|
}
|
|
323
301
|
}
|
|
324
|
-
const workflowEventProcessor = new
|
|
325
|
-
mastra: this
|
|
326
|
-
});
|
|
302
|
+
const workflowEventProcessor = new chunkQCQLOMJM_cjs.WorkflowEventProcessor({ mastra: this });
|
|
327
303
|
const workflowEventCb = async (event, cb) => {
|
|
328
304
|
try {
|
|
329
305
|
await workflowEventProcessor.process(event, cb);
|
|
@@ -338,16 +314,13 @@ exports.Mastra = class Mastra {
|
|
|
338
314
|
}
|
|
339
315
|
let logger;
|
|
340
316
|
if (config?.logger === false) {
|
|
341
|
-
logger =
|
|
317
|
+
logger = chunkCBAB7GOD_cjs.noopLogger;
|
|
342
318
|
} else {
|
|
343
319
|
if (config?.logger) {
|
|
344
320
|
logger = config.logger;
|
|
345
321
|
} else {
|
|
346
|
-
const levelOnEnv = process.env.NODE_ENV === "production" && process.env.MASTRA_DEV !== "true" ?
|
|
347
|
-
logger = new
|
|
348
|
-
name: "Mastra",
|
|
349
|
-
level: levelOnEnv
|
|
350
|
-
});
|
|
322
|
+
const levelOnEnv = process.env.NODE_ENV === "production" && process.env.MASTRA_DEV !== "true" ? chunkDSNPWVIG_cjs.LogLevel.WARN : chunkDSNPWVIG_cjs.LogLevel.INFO;
|
|
323
|
+
logger = new chunkDSNPWVIG_cjs.ConsoleLogger({ name: "Mastra", level: levelOnEnv });
|
|
351
324
|
}
|
|
352
325
|
}
|
|
353
326
|
this.#logger = logger;
|
|
@@ -356,202 +329,74 @@ exports.Mastra = class Mastra {
|
|
|
356
329
|
if (storage) {
|
|
357
330
|
storage = chunkV3VLOOSW_cjs.augmentWithInit(storage);
|
|
358
331
|
}
|
|
359
|
-
this.#telemetry = chunkAQGLVU53_cjs.Telemetry.init(config?.telemetry);
|
|
360
|
-
if (config?.telemetry?.enabled !== false && typeof globalThis !== "undefined" && globalThis.___MASTRA_TELEMETRY___ !== true) {
|
|
361
|
-
this.#logger?.warn(`Mastra telemetry is enabled, but the required instrumentation file was not loaded. If you are using Mastra outside of the mastra server environment, see: https://mastra.ai/en/docs/observability/tracing#tracing-outside-mastra-server-environment`, `If you are using a custom instrumentation file or want to disable this warning, set the globalThis.___MASTRA_TELEMETRY___ variable to true in your instrumentation file.`);
|
|
362
|
-
}
|
|
363
|
-
if (config?.telemetry?.enabled !== false) {
|
|
364
|
-
this.#logger?.warn(`Mastra telemetry is deprecated and will be removed on the Nov 4th release. Instead use AI Tracing. More info can be found here: https://github.com/mastra-ai/mastra/issues/8577 and here: https://mastra.ai/en/docs/observability/ai-tracing/overview`);
|
|
365
|
-
}
|
|
366
332
|
if (config?.observability) {
|
|
367
|
-
|
|
333
|
+
if (typeof config.observability.getDefaultInstance === "function") {
|
|
334
|
+
this.#observability = config.observability;
|
|
335
|
+
this.#observability.setLogger({ logger: this.#logger });
|
|
336
|
+
} else {
|
|
337
|
+
this.#logger?.warn(
|
|
338
|
+
'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
|
+
);
|
|
340
|
+
this.#observability = new chunkE7K4FTLN_cjs.NoOpObservability();
|
|
341
|
+
}
|
|
342
|
+
} else {
|
|
343
|
+
this.#observability = new chunkE7K4FTLN_cjs.NoOpObservability();
|
|
344
|
+
}
|
|
345
|
+
this.#storage = storage;
|
|
346
|
+
this.#vectors = {};
|
|
347
|
+
this.#mcpServers = {};
|
|
348
|
+
this.#tts = {};
|
|
349
|
+
this.#agents = {};
|
|
350
|
+
this.#scorers = {};
|
|
351
|
+
this.#tools = {};
|
|
352
|
+
this.#processors = {};
|
|
353
|
+
this.#workflows = {};
|
|
354
|
+
if (config?.tools) {
|
|
355
|
+
Object.entries(config.tools).forEach(([key, tool]) => {
|
|
356
|
+
this.addTool(tool, key);
|
|
357
|
+
});
|
|
368
358
|
}
|
|
369
|
-
if (
|
|
370
|
-
|
|
371
|
-
|
|
359
|
+
if (config?.processors) {
|
|
360
|
+
Object.entries(config.processors).forEach(([key, processor]) => {
|
|
361
|
+
this.addProcessor(processor, key);
|
|
372
362
|
});
|
|
373
|
-
this.#storage.__setTelemetry(this.#telemetry);
|
|
374
|
-
} else {
|
|
375
|
-
this.#storage = storage;
|
|
376
363
|
}
|
|
377
364
|
if (config?.vectors) {
|
|
378
|
-
let vectors = {};
|
|
379
365
|
Object.entries(config.vectors).forEach(([key, vector]) => {
|
|
380
|
-
|
|
381
|
-
vectors[key] = this.#telemetry.traceClass(vector, {
|
|
382
|
-
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
383
|
-
});
|
|
384
|
-
vectors[key].__setTelemetry(this.#telemetry);
|
|
385
|
-
} else {
|
|
386
|
-
vectors[key] = vector;
|
|
387
|
-
}
|
|
366
|
+
this.addVector(vector, key);
|
|
388
367
|
});
|
|
389
|
-
this.#vectors = vectors;
|
|
390
368
|
}
|
|
391
|
-
if (config?.
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
server.setId(key);
|
|
395
|
-
if (this.#telemetry) {
|
|
396
|
-
server.__setTelemetry(this.#telemetry);
|
|
397
|
-
}
|
|
398
|
-
server.__registerMastra(this);
|
|
399
|
-
server.__setLogger(this.getLogger());
|
|
369
|
+
if (config?.scorers) {
|
|
370
|
+
Object.entries(config.scorers).forEach(([key, scorer]) => {
|
|
371
|
+
this.addScorer(scorer, key);
|
|
400
372
|
});
|
|
401
373
|
}
|
|
402
|
-
if (config
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
domain: "MASTRA" /* MASTRA */,
|
|
406
|
-
category: "USER" /* USER */,
|
|
407
|
-
text: `
|
|
408
|
-
Memory should be added to Agents, not to Mastra.
|
|
409
|
-
|
|
410
|
-
Instead of:
|
|
411
|
-
new Mastra({ memory: new Memory() })
|
|
412
|
-
|
|
413
|
-
do:
|
|
414
|
-
new Agent({ memory: new Memory() })
|
|
415
|
-
`
|
|
374
|
+
if (config?.workflows) {
|
|
375
|
+
Object.entries(config.workflows).forEach(([key, workflow]) => {
|
|
376
|
+
this.addWorkflow(workflow, key);
|
|
416
377
|
});
|
|
417
|
-
this.#logger?.trackException(error);
|
|
418
|
-
throw error;
|
|
419
378
|
}
|
|
420
|
-
if (config?.
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
if (this.#tts?.[key]) {
|
|
424
|
-
if (this.#telemetry) {
|
|
425
|
-
this.#tts[key] = this.#telemetry.traceClass(ttsCl, {
|
|
426
|
-
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
427
|
-
});
|
|
428
|
-
this.#tts[key].__setTelemetry(this.#telemetry);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
379
|
+
if (config?.mcpServers) {
|
|
380
|
+
Object.entries(config.mcpServers).forEach(([key, server]) => {
|
|
381
|
+
this.addMCPServer(server, key);
|
|
431
382
|
});
|
|
432
383
|
}
|
|
433
|
-
const agents = {};
|
|
434
384
|
if (config?.agents) {
|
|
435
385
|
Object.entries(config.agents).forEach(([key, agent]) => {
|
|
436
|
-
|
|
437
|
-
const error = new chunk5NTO7S5I_cjs.MastraError({
|
|
438
|
-
id: "MASTRA_AGENT_REGISTRATION_DUPLICATE_ID",
|
|
439
|
-
domain: "MASTRA" /* MASTRA */,
|
|
440
|
-
category: "USER" /* USER */,
|
|
441
|
-
text: `Agent with name ID:${key} already exists`,
|
|
442
|
-
details: {
|
|
443
|
-
agentId: key
|
|
444
|
-
}
|
|
445
|
-
});
|
|
446
|
-
this.#logger?.trackException(error);
|
|
447
|
-
throw error;
|
|
448
|
-
}
|
|
449
|
-
agent.__registerMastra(this);
|
|
450
|
-
agent.__registerPrimitives({
|
|
451
|
-
logger: this.getLogger(),
|
|
452
|
-
telemetry: this.#telemetry,
|
|
453
|
-
storage: this.storage,
|
|
454
|
-
memory: this.memory,
|
|
455
|
-
agents,
|
|
456
|
-
tts: this.#tts,
|
|
457
|
-
vectors: this.#vectors
|
|
458
|
-
});
|
|
459
|
-
agents[key] = agent;
|
|
386
|
+
this.addAgent(agent, key);
|
|
460
387
|
});
|
|
461
388
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
Object.entries(config.scorers).forEach(([key, scorer]) => {
|
|
466
|
-
scorers[key] = scorer;
|
|
467
|
-
});
|
|
468
|
-
}
|
|
469
|
-
this.#scorers = scorers;
|
|
470
|
-
this.#legacy_workflows = {};
|
|
471
|
-
if (config?.legacy_workflows) {
|
|
472
|
-
Object.entries(config.legacy_workflows).forEach(([key, workflow]) => {
|
|
473
|
-
workflow.__registerMastra(this);
|
|
474
|
-
workflow.__registerPrimitives({
|
|
475
|
-
logger: this.getLogger(),
|
|
476
|
-
telemetry: this.#telemetry,
|
|
477
|
-
storage: this.storage,
|
|
478
|
-
memory: this.memory,
|
|
479
|
-
agents,
|
|
480
|
-
tts: this.#tts,
|
|
481
|
-
vectors: this.#vectors
|
|
482
|
-
});
|
|
483
|
-
this.#legacy_workflows[key] = workflow;
|
|
484
|
-
const workflowSteps = Object.values(workflow.steps).filter(step => !!step.workflowId && !!step.workflow);
|
|
485
|
-
if (workflowSteps.length > 0) {
|
|
486
|
-
workflowSteps.forEach(step => {
|
|
487
|
-
this.#legacy_workflows[step.workflowId] = step.workflow;
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
this.#workflows = {};
|
|
493
|
-
if (config?.workflows) {
|
|
494
|
-
Object.entries(config.workflows).forEach(([key, workflow]) => {
|
|
495
|
-
workflow.__registerMastra(this);
|
|
496
|
-
workflow.__registerPrimitives({
|
|
497
|
-
logger: this.getLogger(),
|
|
498
|
-
telemetry: this.#telemetry,
|
|
499
|
-
storage: this.storage,
|
|
500
|
-
memory: this.memory,
|
|
501
|
-
agents,
|
|
502
|
-
tts: this.#tts,
|
|
503
|
-
vectors: this.#vectors
|
|
504
|
-
});
|
|
505
|
-
this.#workflows[key] = workflow;
|
|
389
|
+
if (config?.tts) {
|
|
390
|
+
Object.entries(config.tts).forEach(([key, tts]) => {
|
|
391
|
+
this.#tts[key] = tts;
|
|
506
392
|
});
|
|
507
393
|
}
|
|
508
394
|
if (config?.server) {
|
|
509
395
|
this.#server = config.server;
|
|
510
396
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
this.initAITracingExporters();
|
|
515
|
-
}
|
|
516
|
-
this.setLogger({
|
|
517
|
-
logger
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
/**
|
|
521
|
-
* Register this Mastra instance with AI tracing exporters that need it
|
|
522
|
-
*/
|
|
523
|
-
registerAITracingExporters() {
|
|
524
|
-
const allTracingInstances = chunkP35FNLTQ_cjs.getAllAITracing();
|
|
525
|
-
allTracingInstances.forEach(tracing => {
|
|
526
|
-
const exporters = tracing.getExporters();
|
|
527
|
-
exporters.forEach(exporter => {
|
|
528
|
-
if ("__registerMastra" in exporter && typeof exporter.__registerMastra === "function") {
|
|
529
|
-
exporter.__registerMastra(this);
|
|
530
|
-
}
|
|
531
|
-
});
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
/**
|
|
535
|
-
* Initialize all AI tracing exporters after registration is complete
|
|
536
|
-
*/
|
|
537
|
-
initAITracingExporters() {
|
|
538
|
-
const allTracingInstances = chunkP35FNLTQ_cjs.getAllAITracing();
|
|
539
|
-
allTracingInstances.forEach(tracing => {
|
|
540
|
-
const config = tracing.getConfig();
|
|
541
|
-
const exporters = tracing.getExporters();
|
|
542
|
-
exporters.forEach(exporter => {
|
|
543
|
-
if ("init" in exporter && typeof exporter.init === "function") {
|
|
544
|
-
try {
|
|
545
|
-
exporter.init(config);
|
|
546
|
-
} catch (error) {
|
|
547
|
-
this.#logger?.warn("Failed to initialize AI tracing exporter", {
|
|
548
|
-
exporterName: exporter.name,
|
|
549
|
-
error: error instanceof Error ? error.message : String(error)
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
});
|
|
554
|
-
});
|
|
397
|
+
chunkMR7ZWBL6_cjs.registerHook("onScorerRun" /* ON_SCORER_RUN */, createOnScorerHook(this));
|
|
398
|
+
this.#observability.setMastraContext({ mastra: this });
|
|
399
|
+
this.setLogger({ logger });
|
|
555
400
|
}
|
|
556
401
|
/**
|
|
557
402
|
* Retrieves a registered agent by its name.
|
|
@@ -564,6 +409,7 @@ do:
|
|
|
564
409
|
* const mastra = new Mastra({
|
|
565
410
|
* agents: {
|
|
566
411
|
* weatherAgent: new Agent({
|
|
412
|
+
* id: 'weather-agent',
|
|
567
413
|
* name: 'weather-agent',
|
|
568
414
|
* instructions: 'You provide weather information',
|
|
569
415
|
* model: 'openai/gpt-5'
|
|
@@ -577,7 +423,7 @@ do:
|
|
|
577
423
|
getAgent(name) {
|
|
578
424
|
const agent = this.#agents?.[name];
|
|
579
425
|
if (!agent) {
|
|
580
|
-
const error = new
|
|
426
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
581
427
|
id: "MASTRA_GET_AGENT_BY_NAME_NOT_FOUND",
|
|
582
428
|
domain: "MASTRA" /* MASTRA */,
|
|
583
429
|
category: "USER" /* USER */,
|
|
@@ -598,7 +444,7 @@ do:
|
|
|
598
444
|
*
|
|
599
445
|
* This method searches for an agent using its internal ID property. If no agent
|
|
600
446
|
* is found with the given ID, it also attempts to find an agent using the ID as
|
|
601
|
-
* a name
|
|
447
|
+
* a name.
|
|
602
448
|
*
|
|
603
449
|
* @throws {MastraError} When no agent is found with the specified ID
|
|
604
450
|
*
|
|
@@ -607,6 +453,7 @@ do:
|
|
|
607
453
|
* const mastra = new Mastra({
|
|
608
454
|
* agents: {
|
|
609
455
|
* assistant: new Agent({
|
|
456
|
+
* id: 'assistant',
|
|
610
457
|
* name: 'assistant',
|
|
611
458
|
* instructions: 'You are a helpful assistant',
|
|
612
459
|
* model: 'openai/gpt-5'
|
|
@@ -619,14 +466,15 @@ do:
|
|
|
619
466
|
* ```
|
|
620
467
|
*/
|
|
621
468
|
getAgentById(id) {
|
|
622
|
-
let agent = Object.values(this.#agents).find(a => a.id === id);
|
|
469
|
+
let agent = Object.values(this.#agents).find((a) => a.id === id);
|
|
623
470
|
if (!agent) {
|
|
624
471
|
try {
|
|
625
472
|
agent = this.getAgent(id);
|
|
626
|
-
} catch {
|
|
473
|
+
} catch {
|
|
474
|
+
}
|
|
627
475
|
}
|
|
628
476
|
if (!agent) {
|
|
629
|
-
const error = new
|
|
477
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
630
478
|
id: "MASTRA_GET_AGENT_BY_AGENT_ID_NOT_FOUND",
|
|
631
479
|
domain: "MASTRA" /* MASTRA */,
|
|
632
480
|
category: "USER" /* USER */,
|
|
@@ -652,18 +500,58 @@ do:
|
|
|
652
500
|
* ```typescript
|
|
653
501
|
* const mastra = new Mastra({
|
|
654
502
|
* agents: {
|
|
655
|
-
* weatherAgent: new Agent({ name: 'weather', model: openai
|
|
656
|
-
* supportAgent: new Agent({ name: 'support', model: openai
|
|
503
|
+
* weatherAgent: new Agent({ id: 'weather-agent', name: 'weather', model: 'openai/gpt-4o' }),
|
|
504
|
+
* supportAgent: new Agent({ id: 'support-agent', name: 'support', model: 'openai/gpt-4o' })
|
|
657
505
|
* }
|
|
658
506
|
* });
|
|
659
507
|
*
|
|
660
|
-
* const allAgents = mastra.
|
|
508
|
+
* const allAgents = mastra.listAgents();
|
|
661
509
|
* console.log(Object.keys(allAgents)); // ['weatherAgent', 'supportAgent']
|
|
662
510
|
* ```
|
|
663
511
|
*/
|
|
664
|
-
|
|
512
|
+
listAgents() {
|
|
665
513
|
return this.#agents;
|
|
666
514
|
}
|
|
515
|
+
/**
|
|
516
|
+
* Adds a new agent to the Mastra instance.
|
|
517
|
+
*
|
|
518
|
+
* This method allows dynamic registration of agents after the Mastra instance
|
|
519
|
+
* has been created. The agent will be initialized with the current logger.
|
|
520
|
+
*
|
|
521
|
+
* @throws {MastraError} When an agent with the same key already exists
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* ```typescript
|
|
525
|
+
* const mastra = new Mastra();
|
|
526
|
+
* const newAgent = new Agent({
|
|
527
|
+
* id: 'chat-agent',
|
|
528
|
+
* name: 'Chat Assistant',
|
|
529
|
+
* model: 'openai/gpt-4o'
|
|
530
|
+
* });
|
|
531
|
+
* mastra.addAgent(newAgent); // Uses agent.id as key
|
|
532
|
+
* // or
|
|
533
|
+
* mastra.addAgent(newAgent, 'customKey'); // Uses custom key
|
|
534
|
+
* ```
|
|
535
|
+
*/
|
|
536
|
+
addAgent(agent, key) {
|
|
537
|
+
const agentKey = key || agent.id;
|
|
538
|
+
const agents = this.#agents;
|
|
539
|
+
if (agents[agentKey]) {
|
|
540
|
+
const logger = this.getLogger();
|
|
541
|
+
logger.debug(`Agent with key ${agentKey} already exists. Skipping addition.`);
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
agent.__setLogger(this.#logger);
|
|
545
|
+
agent.__registerMastra(this);
|
|
546
|
+
agent.__registerPrimitives({
|
|
547
|
+
logger: this.getLogger(),
|
|
548
|
+
storage: this.getStorage(),
|
|
549
|
+
agents,
|
|
550
|
+
tts: this.#tts,
|
|
551
|
+
vectors: this.#vectors
|
|
552
|
+
});
|
|
553
|
+
agents[agentKey] = agent;
|
|
554
|
+
}
|
|
667
555
|
/**
|
|
668
556
|
* Retrieves a registered vector store by its name.
|
|
669
557
|
*
|
|
@@ -705,7 +593,7 @@ do:
|
|
|
705
593
|
getVector(name) {
|
|
706
594
|
const vector = this.#vectors?.[name];
|
|
707
595
|
if (!vector) {
|
|
708
|
-
const error = new
|
|
596
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
709
597
|
id: "MASTRA_GET_VECTOR_BY_NAME_NOT_FOUND",
|
|
710
598
|
domain: "MASTRA" /* MASTRA */,
|
|
711
599
|
category: "USER" /* USER */,
|
|
@@ -721,6 +609,50 @@ do:
|
|
|
721
609
|
}
|
|
722
610
|
return vector;
|
|
723
611
|
}
|
|
612
|
+
/**
|
|
613
|
+
* Retrieves a specific vector store instance by its ID.
|
|
614
|
+
*
|
|
615
|
+
* This method searches for a vector store by its internal ID property.
|
|
616
|
+
* If not found by ID, it falls back to searching by registration key.
|
|
617
|
+
*
|
|
618
|
+
* @throws {MastraError} When the specified vector store is not found
|
|
619
|
+
*
|
|
620
|
+
* @example
|
|
621
|
+
* ```typescript
|
|
622
|
+
* const mastra = new Mastra({
|
|
623
|
+
* vectors: {
|
|
624
|
+
* embeddings: chromaVector
|
|
625
|
+
* }
|
|
626
|
+
* });
|
|
627
|
+
*
|
|
628
|
+
* const vectorStore = mastra.getVectorById('chroma-123');
|
|
629
|
+
* ```
|
|
630
|
+
*/
|
|
631
|
+
getVectorById(id) {
|
|
632
|
+
const allVectors = this.#vectors ?? {};
|
|
633
|
+
for (const vector of Object.values(allVectors)) {
|
|
634
|
+
if (vector.id === id) {
|
|
635
|
+
return vector;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
const vectorByKey = allVectors[id];
|
|
639
|
+
if (vectorByKey) {
|
|
640
|
+
return vectorByKey;
|
|
641
|
+
}
|
|
642
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
643
|
+
id: "MASTRA_GET_VECTOR_BY_ID_NOT_FOUND",
|
|
644
|
+
domain: "MASTRA" /* MASTRA */,
|
|
645
|
+
category: "USER" /* USER */,
|
|
646
|
+
text: `Vector store with id ${id} not found`,
|
|
647
|
+
details: {
|
|
648
|
+
status: 404,
|
|
649
|
+
vectorId: String(id),
|
|
650
|
+
vectors: Object.keys(allVectors).join(", ")
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
this.#logger?.trackException(error);
|
|
654
|
+
throw error;
|
|
655
|
+
}
|
|
724
656
|
/**
|
|
725
657
|
* Returns all registered vector stores as a record keyed by their names.
|
|
726
658
|
*
|
|
@@ -743,9 +675,44 @@ do:
|
|
|
743
675
|
* }
|
|
744
676
|
* ```
|
|
745
677
|
*/
|
|
746
|
-
|
|
678
|
+
listVectors() {
|
|
747
679
|
return this.#vectors;
|
|
748
680
|
}
|
|
681
|
+
/**
|
|
682
|
+
* Adds a new vector store to the Mastra instance.
|
|
683
|
+
*
|
|
684
|
+
* This method allows dynamic registration of vector stores after the Mastra instance
|
|
685
|
+
* has been created. The vector store will be initialized with the current logger.
|
|
686
|
+
*
|
|
687
|
+
* @throws {MastraError} When a vector store with the same key already exists
|
|
688
|
+
*
|
|
689
|
+
* @example
|
|
690
|
+
* ```typescript
|
|
691
|
+
* const mastra = new Mastra();
|
|
692
|
+
* const newVector = new ChromaVector({ id: 'chroma-embeddings' });
|
|
693
|
+
* mastra.addVector(newVector); // Uses vector.id as key
|
|
694
|
+
* // or
|
|
695
|
+
* mastra.addVector(newVector, 'customKey'); // Uses custom key
|
|
696
|
+
* ```
|
|
697
|
+
*/
|
|
698
|
+
addVector(vector, key) {
|
|
699
|
+
const vectorKey = key || vector.id;
|
|
700
|
+
const vectors = this.#vectors;
|
|
701
|
+
if (vectors[vectorKey]) {
|
|
702
|
+
const logger = this.getLogger();
|
|
703
|
+
logger.debug(`Vector with key ${vectorKey} already exists. Skipping addition.`);
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
vector.__setLogger(this.#logger || this.getLogger());
|
|
707
|
+
vectors[vectorKey] = vector;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* @deprecated Use listVectors() instead
|
|
711
|
+
*/
|
|
712
|
+
getVectors() {
|
|
713
|
+
console.warn("getVectors() is deprecated. Use listVectors() instead.");
|
|
714
|
+
return this.listVectors();
|
|
715
|
+
}
|
|
749
716
|
/**
|
|
750
717
|
* Gets the currently configured deployment provider.
|
|
751
718
|
*
|
|
@@ -770,55 +737,6 @@ do:
|
|
|
770
737
|
getDeployer() {
|
|
771
738
|
return this.#deployer;
|
|
772
739
|
}
|
|
773
|
-
/**
|
|
774
|
-
* Retrieves a registered legacy workflow by its ID.
|
|
775
|
-
*
|
|
776
|
-
* Legacy workflows are the previous generation of workflow system in Mastra,
|
|
777
|
-
* maintained for backward compatibility. For new implementations, use the
|
|
778
|
-
* modern workflow system accessed via `getWorkflow()`.
|
|
779
|
-
*
|
|
780
|
-
* @template TWorkflowId - The specific workflow ID type from the registered legacy workflows
|
|
781
|
-
* @throws {MastraError} When the legacy workflow with the specified ID is not found
|
|
782
|
-
* @deprecated Use `getWorkflow()` for new implementations
|
|
783
|
-
*
|
|
784
|
-
* @example Getting a legacy workflow
|
|
785
|
-
* ```typescript
|
|
786
|
-
* const mastra = new Mastra({
|
|
787
|
-
* legacy_workflows: {
|
|
788
|
-
* oldDataFlow: legacyWorkflowInstance
|
|
789
|
-
* }
|
|
790
|
-
* });
|
|
791
|
-
*
|
|
792
|
-
* const workflow = mastra.legacy_getWorkflow('oldDataFlow');
|
|
793
|
-
* const result = await workflow.execute({ input: 'data' });
|
|
794
|
-
* ```
|
|
795
|
-
*/
|
|
796
|
-
legacy_getWorkflow(id, {
|
|
797
|
-
serialized
|
|
798
|
-
} = {}) {
|
|
799
|
-
const workflow = this.#legacy_workflows?.[id];
|
|
800
|
-
if (!workflow) {
|
|
801
|
-
const error = new chunk5NTO7S5I_cjs.MastraError({
|
|
802
|
-
id: "MASTRA_GET_LEGACY_WORKFLOW_BY_ID_NOT_FOUND",
|
|
803
|
-
domain: "MASTRA" /* MASTRA */,
|
|
804
|
-
category: "USER" /* USER */,
|
|
805
|
-
text: `Workflow with ID ${String(id)} not found`,
|
|
806
|
-
details: {
|
|
807
|
-
status: 404,
|
|
808
|
-
workflowId: String(id),
|
|
809
|
-
workflows: Object.keys(this.#legacy_workflows ?? {}).join(", ")
|
|
810
|
-
}
|
|
811
|
-
});
|
|
812
|
-
this.#logger?.trackException(error);
|
|
813
|
-
throw error;
|
|
814
|
-
}
|
|
815
|
-
if (serialized) {
|
|
816
|
-
return {
|
|
817
|
-
name: workflow.name
|
|
818
|
-
};
|
|
819
|
-
}
|
|
820
|
-
return workflow;
|
|
821
|
-
}
|
|
822
740
|
/**
|
|
823
741
|
* Retrieves a registered workflow by its ID.
|
|
824
742
|
*
|
|
@@ -846,12 +764,10 @@ do:
|
|
|
846
764
|
* });
|
|
847
765
|
* ```
|
|
848
766
|
*/
|
|
849
|
-
getWorkflow(id, {
|
|
850
|
-
serialized
|
|
851
|
-
} = {}) {
|
|
767
|
+
getWorkflow(id, { serialized } = {}) {
|
|
852
768
|
const workflow = this.#workflows?.[id];
|
|
853
769
|
if (!workflow) {
|
|
854
|
-
const error = new
|
|
770
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
855
771
|
id: "MASTRA_GET_WORKFLOW_BY_ID_NOT_FOUND",
|
|
856
772
|
domain: "MASTRA" /* MASTRA */,
|
|
857
773
|
category: "USER" /* USER */,
|
|
@@ -866,27 +782,24 @@ do:
|
|
|
866
782
|
throw error;
|
|
867
783
|
}
|
|
868
784
|
if (serialized) {
|
|
869
|
-
return {
|
|
870
|
-
name: workflow.name
|
|
871
|
-
};
|
|
785
|
+
return { name: workflow.name };
|
|
872
786
|
}
|
|
873
787
|
return workflow;
|
|
874
788
|
}
|
|
875
789
|
__registerInternalWorkflow(workflow) {
|
|
876
790
|
workflow.__registerMastra(this);
|
|
877
791
|
workflow.__registerPrimitives({
|
|
878
|
-
logger: this.getLogger()
|
|
879
|
-
storage: this.storage
|
|
792
|
+
logger: this.getLogger()
|
|
880
793
|
});
|
|
881
794
|
this.#internalMastraWorkflows[workflow.id] = workflow;
|
|
882
795
|
}
|
|
883
796
|
__hasInternalWorkflow(id) {
|
|
884
|
-
return Object.values(this.#internalMastraWorkflows).some(workflow => workflow.id === id);
|
|
797
|
+
return Object.values(this.#internalMastraWorkflows).some((workflow) => workflow.id === id);
|
|
885
798
|
}
|
|
886
799
|
__getInternalWorkflow(id) {
|
|
887
|
-
const workflow = Object.values(this.#internalMastraWorkflows).find(a => a.id === id);
|
|
800
|
+
const workflow = Object.values(this.#internalMastraWorkflows).find((a) => a.id === id);
|
|
888
801
|
if (!workflow) {
|
|
889
|
-
throw new
|
|
802
|
+
throw new chunkTWH4PTDG_cjs.MastraError({
|
|
890
803
|
id: "MASTRA_GET_INTERNAL_WORKFLOW_BY_ID_NOT_FOUND",
|
|
891
804
|
domain: "MASTRA" /* MASTRA */,
|
|
892
805
|
category: "SYSTEM" /* SYSTEM */,
|
|
@@ -904,7 +817,7 @@ do:
|
|
|
904
817
|
*
|
|
905
818
|
* This method searches for a workflow using its internal ID property. If no workflow
|
|
906
819
|
* is found with the given ID, it also attempts to find a workflow using the ID as
|
|
907
|
-
* a name
|
|
820
|
+
* a name.
|
|
908
821
|
*
|
|
909
822
|
* @throws {MastraError} When no workflow is found with the specified ID
|
|
910
823
|
*
|
|
@@ -929,14 +842,15 @@ do:
|
|
|
929
842
|
* ```
|
|
930
843
|
*/
|
|
931
844
|
getWorkflowById(id) {
|
|
932
|
-
let workflow = Object.values(this.#workflows).find(a => a.id === id);
|
|
845
|
+
let workflow = Object.values(this.#workflows).find((a) => a.id === id);
|
|
933
846
|
if (!workflow) {
|
|
934
847
|
try {
|
|
935
848
|
workflow = this.getWorkflow(id);
|
|
936
|
-
} catch {
|
|
849
|
+
} catch {
|
|
850
|
+
}
|
|
937
851
|
}
|
|
938
852
|
if (!workflow) {
|
|
939
|
-
const error = new
|
|
853
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
940
854
|
id: "MASTRA_GET_WORKFLOW_BY_ID_NOT_FOUND",
|
|
941
855
|
domain: "MASTRA" /* MASTRA */,
|
|
942
856
|
category: "USER" /* USER */,
|
|
@@ -952,45 +866,6 @@ do:
|
|
|
952
866
|
}
|
|
953
867
|
return workflow;
|
|
954
868
|
}
|
|
955
|
-
/**
|
|
956
|
-
* Returns all registered legacy workflows as a record keyed by their IDs.
|
|
957
|
-
*
|
|
958
|
-
* Legacy workflows are the previous generation of workflow system in Mastra,
|
|
959
|
-
* maintained for backward compatibility. For new implementations, use `getWorkflows()`.
|
|
960
|
-
*
|
|
961
|
-
* @deprecated Use `getWorkflows()` for new implementations
|
|
962
|
-
*
|
|
963
|
-
* @example Listing all legacy workflows
|
|
964
|
-
* ```typescript
|
|
965
|
-
* const mastra = new Mastra({
|
|
966
|
-
* legacy_workflows: {
|
|
967
|
-
* oldFlow1: legacyWorkflow1,
|
|
968
|
-
* oldFlow2: legacyWorkflow2
|
|
969
|
-
* }
|
|
970
|
-
* });
|
|
971
|
-
*
|
|
972
|
-
* const allLegacyWorkflows = mastra.legacy_getWorkflows();
|
|
973
|
-
* console.log(Object.keys(allLegacyWorkflows)); // ['oldFlow1', 'oldFlow2']
|
|
974
|
-
*
|
|
975
|
-
* // Execute all legacy workflows
|
|
976
|
-
* for (const [id, workflow] of Object.entries(allLegacyWorkflows)) {
|
|
977
|
-
* console.log(`Legacy workflow ${id}:`, workflow.name);
|
|
978
|
-
* }
|
|
979
|
-
* ```
|
|
980
|
-
*/
|
|
981
|
-
legacy_getWorkflows(props = {}) {
|
|
982
|
-
if (props.serialized) {
|
|
983
|
-
return Object.entries(this.#legacy_workflows).reduce((acc, [k, v]) => {
|
|
984
|
-
return {
|
|
985
|
-
...acc,
|
|
986
|
-
[k]: {
|
|
987
|
-
name: v.name
|
|
988
|
-
}
|
|
989
|
-
};
|
|
990
|
-
}, {});
|
|
991
|
-
}
|
|
992
|
-
return this.#legacy_workflows;
|
|
993
|
-
}
|
|
994
869
|
/**
|
|
995
870
|
* Returns all registered scorers as a record keyed by their IDs.
|
|
996
871
|
*
|
|
@@ -1006,18 +881,48 @@ do:
|
|
|
1006
881
|
* }
|
|
1007
882
|
* });
|
|
1008
883
|
*
|
|
1009
|
-
* const allScorers = mastra.
|
|
884
|
+
* const allScorers = mastra.listScorers();
|
|
1010
885
|
* console.log(Object.keys(allScorers)); // ['helpfulness', 'accuracy', 'relevance']
|
|
1011
886
|
*
|
|
1012
887
|
* // Check scorer configurations
|
|
1013
888
|
* for (const [id, scorer] of Object.entries(allScorers)) {
|
|
1014
|
-
* console.log(`Scorer ${id}:`, scorer.name, scorer.description);
|
|
889
|
+
* console.log(`Scorer ${id}:`, scorer.id, scorer.name, scorer.description);
|
|
1015
890
|
* }
|
|
1016
891
|
* ```
|
|
1017
892
|
*/
|
|
1018
|
-
|
|
893
|
+
listScorers() {
|
|
1019
894
|
return this.#scorers;
|
|
1020
895
|
}
|
|
896
|
+
/**
|
|
897
|
+
* Adds a new scorer to the Mastra instance.
|
|
898
|
+
*
|
|
899
|
+
* This method allows dynamic registration of scorers after the Mastra instance
|
|
900
|
+
* has been created.
|
|
901
|
+
*
|
|
902
|
+
* @throws {MastraError} When a scorer with the same key already exists
|
|
903
|
+
*
|
|
904
|
+
* @example
|
|
905
|
+
* ```typescript
|
|
906
|
+
* const mastra = new Mastra();
|
|
907
|
+
* const newScorer = new MastraScorer({
|
|
908
|
+
* id: 'quality-scorer',
|
|
909
|
+
* name: 'Quality Scorer'
|
|
910
|
+
* });
|
|
911
|
+
* mastra.addScorer(newScorer); // Uses scorer.id as key
|
|
912
|
+
* // or
|
|
913
|
+
* mastra.addScorer(newScorer, 'customKey'); // Uses custom key
|
|
914
|
+
* ```
|
|
915
|
+
*/
|
|
916
|
+
addScorer(scorer, key) {
|
|
917
|
+
const scorerKey = key || scorer.id;
|
|
918
|
+
const scorers = this.#scorers;
|
|
919
|
+
if (scorers[scorerKey]) {
|
|
920
|
+
const logger = this.getLogger();
|
|
921
|
+
logger.debug(`Scorer with key ${scorerKey} already exists. Skipping addition.`);
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
924
|
+
scorers[scorerKey] = scorer;
|
|
925
|
+
}
|
|
1021
926
|
/**
|
|
1022
927
|
* Retrieves a registered scorer by its key.
|
|
1023
928
|
*
|
|
@@ -1031,7 +936,7 @@ do:
|
|
|
1031
936
|
* const mastra = new Mastra({
|
|
1032
937
|
* scorers: {
|
|
1033
938
|
* helpfulness: new HelpfulnessScorer({
|
|
1034
|
-
* model: openai
|
|
939
|
+
* model: 'openai/gpt-4o',
|
|
1035
940
|
* criteria: 'Rate how helpful this response is'
|
|
1036
941
|
* }),
|
|
1037
942
|
* accuracy: new AccuracyScorer({
|
|
@@ -1054,7 +959,7 @@ do:
|
|
|
1054
959
|
getScorer(key) {
|
|
1055
960
|
const scorer = this.#scorers?.[key];
|
|
1056
961
|
if (!scorer) {
|
|
1057
|
-
const error = new
|
|
962
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
1058
963
|
id: "MASTRA_GET_SCORER_NOT_FOUND",
|
|
1059
964
|
domain: "MASTRA" /* MASTRA */,
|
|
1060
965
|
category: "USER" /* USER */,
|
|
@@ -1088,28 +993,298 @@ do:
|
|
|
1088
993
|
* });
|
|
1089
994
|
*
|
|
1090
995
|
* // Find scorer by its internal name, not the registration key
|
|
1091
|
-
* const scorer = mastra.
|
|
996
|
+
* const scorer = mastra.getScorerById('helpfulness-evaluator');
|
|
1092
997
|
* const score = await scorer.score({
|
|
1093
998
|
* input: 'question',
|
|
1094
999
|
* output: 'answer'
|
|
1095
1000
|
* });
|
|
1096
1001
|
* ```
|
|
1097
1002
|
*/
|
|
1098
|
-
|
|
1003
|
+
getScorerById(id) {
|
|
1099
1004
|
for (const [_key, value] of Object.entries(this.#scorers ?? {})) {
|
|
1100
|
-
if (value.name ===
|
|
1005
|
+
if (value.id === id || value?.name === id) {
|
|
1101
1006
|
return value;
|
|
1102
1007
|
}
|
|
1103
1008
|
}
|
|
1104
|
-
const error = new
|
|
1105
|
-
id: "
|
|
1009
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
1010
|
+
id: "MASTRA_GET_SCORER_BY_ID_NOT_FOUND",
|
|
1106
1011
|
domain: "MASTRA" /* MASTRA */,
|
|
1107
1012
|
category: "USER" /* USER */,
|
|
1108
|
-
text: `Scorer with
|
|
1013
|
+
text: `Scorer with id ${String(id)} not found`
|
|
1109
1014
|
});
|
|
1110
1015
|
this.#logger?.trackException(error);
|
|
1111
1016
|
throw error;
|
|
1112
1017
|
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Retrieves a specific tool by registration key.
|
|
1020
|
+
*
|
|
1021
|
+
* @throws {MastraError} When the specified tool is not found
|
|
1022
|
+
*
|
|
1023
|
+
* @example
|
|
1024
|
+
* ```typescript
|
|
1025
|
+
* const mastra = new Mastra({
|
|
1026
|
+
* tools: {
|
|
1027
|
+
* calculator: calculatorTool,
|
|
1028
|
+
* weather: weatherTool
|
|
1029
|
+
* }
|
|
1030
|
+
* });
|
|
1031
|
+
*
|
|
1032
|
+
* const tool = mastra.getTool('calculator');
|
|
1033
|
+
* ```
|
|
1034
|
+
*/
|
|
1035
|
+
getTool(name) {
|
|
1036
|
+
if (!this.#tools || !this.#tools[name]) {
|
|
1037
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
1038
|
+
id: "MASTRA_GET_TOOL_BY_NAME_NOT_FOUND",
|
|
1039
|
+
domain: "MASTRA" /* MASTRA */,
|
|
1040
|
+
category: "USER" /* USER */,
|
|
1041
|
+
text: `Tool with name ${String(name)} not found`,
|
|
1042
|
+
details: {
|
|
1043
|
+
status: 404,
|
|
1044
|
+
toolName: String(name),
|
|
1045
|
+
tools: Object.keys(this.#tools ?? {}).join(", ")
|
|
1046
|
+
}
|
|
1047
|
+
});
|
|
1048
|
+
this.#logger?.trackException(error);
|
|
1049
|
+
throw error;
|
|
1050
|
+
}
|
|
1051
|
+
return this.#tools[name];
|
|
1052
|
+
}
|
|
1053
|
+
/**
|
|
1054
|
+
* Retrieves a specific tool by its ID.
|
|
1055
|
+
*
|
|
1056
|
+
* @throws {MastraError} When the specified tool is not found
|
|
1057
|
+
*
|
|
1058
|
+
* @example
|
|
1059
|
+
* ```typescript
|
|
1060
|
+
* const mastra = new Mastra({
|
|
1061
|
+
* tools: {
|
|
1062
|
+
* calculator: calculatorTool
|
|
1063
|
+
* }
|
|
1064
|
+
* });
|
|
1065
|
+
*
|
|
1066
|
+
* const tool = mastra.getToolById('calculator-tool-id');
|
|
1067
|
+
* ```
|
|
1068
|
+
*/
|
|
1069
|
+
getToolById(id) {
|
|
1070
|
+
const allTools = this.#tools;
|
|
1071
|
+
if (!allTools) {
|
|
1072
|
+
throw new chunkTWH4PTDG_cjs.MastraError({
|
|
1073
|
+
id: "MASTRA_GET_TOOL_BY_ID_NOT_FOUND",
|
|
1074
|
+
domain: "MASTRA" /* MASTRA */,
|
|
1075
|
+
category: "USER" /* USER */,
|
|
1076
|
+
text: `Tool with id ${id} not found`
|
|
1077
|
+
});
|
|
1078
|
+
}
|
|
1079
|
+
for (const tool of Object.values(allTools)) {
|
|
1080
|
+
if (tool.id === id) {
|
|
1081
|
+
return tool;
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
const toolByKey = allTools[id];
|
|
1085
|
+
if (toolByKey) {
|
|
1086
|
+
return toolByKey;
|
|
1087
|
+
}
|
|
1088
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
1089
|
+
id: "MASTRA_GET_TOOL_BY_ID_NOT_FOUND",
|
|
1090
|
+
domain: "MASTRA" /* MASTRA */,
|
|
1091
|
+
category: "USER" /* USER */,
|
|
1092
|
+
text: `Tool with id ${id} not found`,
|
|
1093
|
+
details: {
|
|
1094
|
+
status: 404,
|
|
1095
|
+
toolId: String(id),
|
|
1096
|
+
tools: Object.keys(allTools).join(", ")
|
|
1097
|
+
}
|
|
1098
|
+
});
|
|
1099
|
+
this.#logger?.trackException(error);
|
|
1100
|
+
throw error;
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* Lists all configured tools.
|
|
1104
|
+
*
|
|
1105
|
+
* @example
|
|
1106
|
+
* ```typescript
|
|
1107
|
+
* const mastra = new Mastra({
|
|
1108
|
+
* tools: {
|
|
1109
|
+
* calculator: calculatorTool,
|
|
1110
|
+
* weather: weatherTool
|
|
1111
|
+
* }
|
|
1112
|
+
* });
|
|
1113
|
+
*
|
|
1114
|
+
* const tools = mastra.listTools();
|
|
1115
|
+
* Object.entries(tools || {}).forEach(([name, tool]) => {
|
|
1116
|
+
* console.log(`Tool "${name}":`, tool.id);
|
|
1117
|
+
* });
|
|
1118
|
+
* ```
|
|
1119
|
+
*/
|
|
1120
|
+
listTools() {
|
|
1121
|
+
return this.#tools;
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* Adds a new tool to the Mastra instance.
|
|
1125
|
+
*
|
|
1126
|
+
* This method allows dynamic registration of tools after the Mastra instance
|
|
1127
|
+
* has been created.
|
|
1128
|
+
*
|
|
1129
|
+
* @throws {MastraError} When a tool with the same key already exists
|
|
1130
|
+
*
|
|
1131
|
+
* @example
|
|
1132
|
+
* ```typescript
|
|
1133
|
+
* const mastra = new Mastra();
|
|
1134
|
+
* const newTool = createTool({
|
|
1135
|
+
* id: 'calculator-tool',
|
|
1136
|
+
* description: 'Performs calculations'
|
|
1137
|
+
* });
|
|
1138
|
+
* mastra.addTool(newTool); // Uses tool.id as key
|
|
1139
|
+
* // or
|
|
1140
|
+
* mastra.addTool(newTool, 'customKey'); // Uses custom key
|
|
1141
|
+
* ```
|
|
1142
|
+
*/
|
|
1143
|
+
addTool(tool, key) {
|
|
1144
|
+
const toolKey = key || tool.id;
|
|
1145
|
+
const tools = this.#tools;
|
|
1146
|
+
if (tools[toolKey]) {
|
|
1147
|
+
const logger = this.getLogger();
|
|
1148
|
+
logger.debug(`Tool with key ${toolKey} already exists. Skipping addition.`);
|
|
1149
|
+
return;
|
|
1150
|
+
}
|
|
1151
|
+
tools[toolKey] = tool;
|
|
1152
|
+
}
|
|
1153
|
+
/**
|
|
1154
|
+
* Retrieves a specific processor by registration key.
|
|
1155
|
+
*
|
|
1156
|
+
* @throws {MastraError} When the specified processor is not found
|
|
1157
|
+
*
|
|
1158
|
+
* @example
|
|
1159
|
+
* ```typescript
|
|
1160
|
+
* const mastra = new Mastra({
|
|
1161
|
+
* processors: {
|
|
1162
|
+
* validator: validatorProcessor,
|
|
1163
|
+
* transformer: transformerProcessor
|
|
1164
|
+
* }
|
|
1165
|
+
* });
|
|
1166
|
+
*
|
|
1167
|
+
* const processor = mastra.getProcessor('validator');
|
|
1168
|
+
* ```
|
|
1169
|
+
*/
|
|
1170
|
+
getProcessor(name) {
|
|
1171
|
+
if (!this.#processors || !this.#processors[name]) {
|
|
1172
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
1173
|
+
id: "MASTRA_GET_PROCESSOR_BY_NAME_NOT_FOUND",
|
|
1174
|
+
domain: "MASTRA" /* MASTRA */,
|
|
1175
|
+
category: "USER" /* USER */,
|
|
1176
|
+
text: `Processor with name ${String(name)} not found`,
|
|
1177
|
+
details: {
|
|
1178
|
+
status: 404,
|
|
1179
|
+
processorName: String(name),
|
|
1180
|
+
processors: Object.keys(this.#processors ?? {}).join(", ")
|
|
1181
|
+
}
|
|
1182
|
+
});
|
|
1183
|
+
this.#logger?.trackException(error);
|
|
1184
|
+
throw error;
|
|
1185
|
+
}
|
|
1186
|
+
return this.#processors[name];
|
|
1187
|
+
}
|
|
1188
|
+
/**
|
|
1189
|
+
* Retrieves a specific processor by its ID.
|
|
1190
|
+
*
|
|
1191
|
+
* @throws {MastraError} When the specified processor is not found
|
|
1192
|
+
*
|
|
1193
|
+
* @example
|
|
1194
|
+
* ```typescript
|
|
1195
|
+
* const mastra = new Mastra({
|
|
1196
|
+
* processors: {
|
|
1197
|
+
* validator: validatorProcessor
|
|
1198
|
+
* }
|
|
1199
|
+
* });
|
|
1200
|
+
*
|
|
1201
|
+
* const processor = mastra.getProcessorById('validator-processor-id');
|
|
1202
|
+
* ```
|
|
1203
|
+
*/
|
|
1204
|
+
getProcessorById(id) {
|
|
1205
|
+
const allProcessors = this.#processors;
|
|
1206
|
+
if (!allProcessors) {
|
|
1207
|
+
throw new chunkTWH4PTDG_cjs.MastraError({
|
|
1208
|
+
id: "MASTRA_GET_PROCESSOR_BY_ID_NOT_FOUND",
|
|
1209
|
+
domain: "MASTRA" /* MASTRA */,
|
|
1210
|
+
category: "USER" /* USER */,
|
|
1211
|
+
text: `Processor with id ${id} not found`
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
for (const processor of Object.values(allProcessors)) {
|
|
1215
|
+
if (processor.id === id) {
|
|
1216
|
+
return processor;
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
const processorByKey = allProcessors[id];
|
|
1220
|
+
if (processorByKey) {
|
|
1221
|
+
return processorByKey;
|
|
1222
|
+
}
|
|
1223
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
1224
|
+
id: "MASTRA_GET_PROCESSOR_BY_ID_NOT_FOUND",
|
|
1225
|
+
domain: "MASTRA" /* MASTRA */,
|
|
1226
|
+
category: "USER" /* USER */,
|
|
1227
|
+
text: `Processor with id ${id} not found`,
|
|
1228
|
+
details: {
|
|
1229
|
+
status: 404,
|
|
1230
|
+
processorId: String(id),
|
|
1231
|
+
processors: Object.keys(allProcessors).join(", ")
|
|
1232
|
+
}
|
|
1233
|
+
});
|
|
1234
|
+
this.#logger?.trackException(error);
|
|
1235
|
+
throw error;
|
|
1236
|
+
}
|
|
1237
|
+
/**
|
|
1238
|
+
* Lists all configured processors.
|
|
1239
|
+
*
|
|
1240
|
+
* @example
|
|
1241
|
+
* ```typescript
|
|
1242
|
+
* const mastra = new Mastra({
|
|
1243
|
+
* processors: {
|
|
1244
|
+
* validator: validatorProcessor,
|
|
1245
|
+
* transformer: transformerProcessor
|
|
1246
|
+
* }
|
|
1247
|
+
* });
|
|
1248
|
+
*
|
|
1249
|
+
* const processors = mastra.listProcessors();
|
|
1250
|
+
* Object.entries(processors || {}).forEach(([name, processor]) => {
|
|
1251
|
+
* console.log(`Processor "${name}":`, processor.id);
|
|
1252
|
+
* });
|
|
1253
|
+
* ```
|
|
1254
|
+
*/
|
|
1255
|
+
listProcessors() {
|
|
1256
|
+
return this.#processors;
|
|
1257
|
+
}
|
|
1258
|
+
/**
|
|
1259
|
+
* Adds a new processor to the Mastra instance.
|
|
1260
|
+
*
|
|
1261
|
+
* This method allows dynamic registration of processors after the Mastra instance
|
|
1262
|
+
* has been created.
|
|
1263
|
+
*
|
|
1264
|
+
* @throws {MastraError} When a processor with the same key already exists
|
|
1265
|
+
*
|
|
1266
|
+
* @example
|
|
1267
|
+
* ```typescript
|
|
1268
|
+
* const mastra = new Mastra();
|
|
1269
|
+
* const newProcessor = {
|
|
1270
|
+
* id: 'text-processor',
|
|
1271
|
+
* processInput: async (messages) => messages
|
|
1272
|
+
* };
|
|
1273
|
+
* mastra.addProcessor(newProcessor); // Uses processor.id as key
|
|
1274
|
+
* // or
|
|
1275
|
+
* mastra.addProcessor(newProcessor, 'customKey'); // Uses custom key
|
|
1276
|
+
* ```
|
|
1277
|
+
*/
|
|
1278
|
+
addProcessor(processor, key) {
|
|
1279
|
+
const processorKey = key || processor.id;
|
|
1280
|
+
const processors = this.#processors;
|
|
1281
|
+
if (processors[processorKey]) {
|
|
1282
|
+
const logger = this.getLogger();
|
|
1283
|
+
logger.debug(`Processor with key ${processorKey} already exists. Skipping addition.`);
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
processors[processorKey] = processor;
|
|
1287
|
+
}
|
|
1113
1288
|
/**
|
|
1114
1289
|
* Returns all registered workflows as a record keyed by their IDs.
|
|
1115
1290
|
*
|
|
@@ -1123,7 +1298,7 @@ do:
|
|
|
1123
1298
|
* }
|
|
1124
1299
|
* });
|
|
1125
1300
|
*
|
|
1126
|
-
* const allWorkflows = mastra.
|
|
1301
|
+
* const allWorkflows = mastra.listWorkflows();
|
|
1127
1302
|
* console.log(Object.keys(allWorkflows)); // ['dataProcessor', 'emailSender', 'reportGenerator']
|
|
1128
1303
|
*
|
|
1129
1304
|
* // Execute all workflows with sample data
|
|
@@ -1133,19 +1308,52 @@ do:
|
|
|
1133
1308
|
* }
|
|
1134
1309
|
* ```
|
|
1135
1310
|
*/
|
|
1136
|
-
|
|
1311
|
+
listWorkflows(props = {}) {
|
|
1137
1312
|
if (props.serialized) {
|
|
1138
1313
|
return Object.entries(this.#workflows).reduce((acc, [k, v]) => {
|
|
1139
1314
|
return {
|
|
1140
1315
|
...acc,
|
|
1141
|
-
[k]: {
|
|
1142
|
-
name: v.name
|
|
1143
|
-
}
|
|
1316
|
+
[k]: { name: v.name }
|
|
1144
1317
|
};
|
|
1145
1318
|
}, {});
|
|
1146
1319
|
}
|
|
1147
1320
|
return this.#workflows;
|
|
1148
1321
|
}
|
|
1322
|
+
/**
|
|
1323
|
+
* Adds a new workflow to the Mastra instance.
|
|
1324
|
+
*
|
|
1325
|
+
* This method allows dynamic registration of workflows after the Mastra instance
|
|
1326
|
+
* has been created. The workflow will be initialized with Mastra and primitives.
|
|
1327
|
+
*
|
|
1328
|
+
* @throws {MastraError} When a workflow with the same key already exists
|
|
1329
|
+
*
|
|
1330
|
+
* @example
|
|
1331
|
+
* ```typescript
|
|
1332
|
+
* const mastra = new Mastra();
|
|
1333
|
+
* const newWorkflow = createWorkflow({
|
|
1334
|
+
* id: 'data-pipeline',
|
|
1335
|
+
* name: 'Data Pipeline'
|
|
1336
|
+
* }).commit();
|
|
1337
|
+
* mastra.addWorkflow(newWorkflow); // Uses workflow.id as key
|
|
1338
|
+
* // or
|
|
1339
|
+
* mastra.addWorkflow(newWorkflow, 'customKey'); // Uses custom key
|
|
1340
|
+
* ```
|
|
1341
|
+
*/
|
|
1342
|
+
addWorkflow(workflow, key) {
|
|
1343
|
+
const workflowKey = key || workflow.id;
|
|
1344
|
+
const workflows = this.#workflows;
|
|
1345
|
+
if (workflows[workflowKey]) {
|
|
1346
|
+
const logger = this.getLogger();
|
|
1347
|
+
logger.debug(`Workflow with key ${workflowKey} already exists. Skipping addition.`);
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1350
|
+
workflow.__registerMastra(this);
|
|
1351
|
+
workflow.__registerPrimitives({
|
|
1352
|
+
logger: this.getLogger(),
|
|
1353
|
+
storage: this.getStorage()
|
|
1354
|
+
});
|
|
1355
|
+
workflows[workflowKey] = workflow;
|
|
1356
|
+
}
|
|
1149
1357
|
/**
|
|
1150
1358
|
* Sets the storage provider for the Mastra instance.
|
|
1151
1359
|
*
|
|
@@ -1160,6 +1368,7 @@ do:
|
|
|
1160
1368
|
*
|
|
1161
1369
|
* // Now agents can use memory with the storage
|
|
1162
1370
|
* const agent = new Agent({
|
|
1371
|
+
* id: 'assistant',
|
|
1163
1372
|
* name: 'assistant',
|
|
1164
1373
|
* memory: new Memory({ storage: mastra.getStorage() })
|
|
1165
1374
|
* });
|
|
@@ -1168,23 +1377,18 @@ do:
|
|
|
1168
1377
|
setStorage(storage) {
|
|
1169
1378
|
this.#storage = chunkV3VLOOSW_cjs.augmentWithInit(storage);
|
|
1170
1379
|
}
|
|
1171
|
-
setLogger({
|
|
1172
|
-
logger
|
|
1173
|
-
}) {
|
|
1380
|
+
setLogger({ logger }) {
|
|
1174
1381
|
this.#logger = logger;
|
|
1175
1382
|
if (this.#agents) {
|
|
1176
|
-
Object.keys(this.#agents).forEach(key => {
|
|
1383
|
+
Object.keys(this.#agents).forEach((key) => {
|
|
1177
1384
|
this.#agents?.[key]?.__setLogger(this.#logger);
|
|
1178
1385
|
});
|
|
1179
1386
|
}
|
|
1180
|
-
if (this.#memory) {
|
|
1181
|
-
this.#memory.__setLogger(this.#logger);
|
|
1182
|
-
}
|
|
1183
1387
|
if (this.#deployer) {
|
|
1184
1388
|
this.#deployer.__setLogger(this.#logger);
|
|
1185
1389
|
}
|
|
1186
1390
|
if (this.#tts) {
|
|
1187
|
-
Object.keys(this.#tts).forEach(key => {
|
|
1391
|
+
Object.keys(this.#tts).forEach((key) => {
|
|
1188
1392
|
this.#tts?.[key]?.__setLogger(this.#logger);
|
|
1189
1393
|
});
|
|
1190
1394
|
}
|
|
@@ -1192,71 +1396,16 @@ do:
|
|
|
1192
1396
|
this.#storage.__setLogger(this.#logger);
|
|
1193
1397
|
}
|
|
1194
1398
|
if (this.#vectors) {
|
|
1195
|
-
Object.keys(this.#vectors).forEach(key => {
|
|
1399
|
+
Object.keys(this.#vectors).forEach((key) => {
|
|
1196
1400
|
this.#vectors?.[key]?.__setLogger(this.#logger);
|
|
1197
1401
|
});
|
|
1198
1402
|
}
|
|
1199
1403
|
if (this.#mcpServers) {
|
|
1200
|
-
Object.keys(this.#mcpServers).forEach(key => {
|
|
1404
|
+
Object.keys(this.#mcpServers).forEach((key) => {
|
|
1201
1405
|
this.#mcpServers?.[key]?.__setLogger(this.#logger);
|
|
1202
1406
|
});
|
|
1203
1407
|
}
|
|
1204
|
-
|
|
1205
|
-
allTracingInstances.forEach(instance => {
|
|
1206
|
-
instance.__setLogger(this.#logger);
|
|
1207
|
-
});
|
|
1208
|
-
}
|
|
1209
|
-
setTelemetry(telemetry) {
|
|
1210
|
-
this.#telemetry = chunkAQGLVU53_cjs.Telemetry.init(telemetry);
|
|
1211
|
-
if (this.#agents) {
|
|
1212
|
-
Object.keys(this.#agents).forEach(key => {
|
|
1213
|
-
if (this.#telemetry) {
|
|
1214
|
-
this.#agents?.[key]?.__setTelemetry(this.#telemetry);
|
|
1215
|
-
}
|
|
1216
|
-
});
|
|
1217
|
-
}
|
|
1218
|
-
if (this.#memory) {
|
|
1219
|
-
this.#memory = this.#telemetry.traceClass(this.#memory, {
|
|
1220
|
-
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
1221
|
-
});
|
|
1222
|
-
this.#memory.__setTelemetry(this.#telemetry);
|
|
1223
|
-
}
|
|
1224
|
-
if (this.#deployer) {
|
|
1225
|
-
this.#deployer = this.#telemetry.traceClass(this.#deployer, {
|
|
1226
|
-
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
1227
|
-
});
|
|
1228
|
-
this.#deployer.__setTelemetry(this.#telemetry);
|
|
1229
|
-
}
|
|
1230
|
-
if (this.#tts) {
|
|
1231
|
-
let tts = {};
|
|
1232
|
-
Object.entries(this.#tts).forEach(([key, ttsCl]) => {
|
|
1233
|
-
if (this.#telemetry) {
|
|
1234
|
-
tts[key] = this.#telemetry.traceClass(ttsCl, {
|
|
1235
|
-
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
1236
|
-
});
|
|
1237
|
-
tts[key].__setTelemetry(this.#telemetry);
|
|
1238
|
-
}
|
|
1239
|
-
});
|
|
1240
|
-
this.#tts = tts;
|
|
1241
|
-
}
|
|
1242
|
-
if (this.#storage) {
|
|
1243
|
-
this.#storage = this.#telemetry.traceClass(this.#storage, {
|
|
1244
|
-
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
1245
|
-
});
|
|
1246
|
-
this.#storage.__setTelemetry(this.#telemetry);
|
|
1247
|
-
}
|
|
1248
|
-
if (this.#vectors) {
|
|
1249
|
-
let vectors = {};
|
|
1250
|
-
Object.entries(this.#vectors).forEach(([key, vector]) => {
|
|
1251
|
-
if (this.#telemetry) {
|
|
1252
|
-
vectors[key] = this.#telemetry.traceClass(vector, {
|
|
1253
|
-
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
1254
|
-
});
|
|
1255
|
-
vectors[key].__setTelemetry(this.#telemetry);
|
|
1256
|
-
}
|
|
1257
|
-
});
|
|
1258
|
-
this.#vectors = vectors;
|
|
1259
|
-
}
|
|
1408
|
+
this.#observability.setLogger({ logger: this.#logger });
|
|
1260
1409
|
}
|
|
1261
1410
|
/**
|
|
1262
1411
|
* Gets all registered text-to-speech (TTS) providers.
|
|
@@ -1302,67 +1451,18 @@ do:
|
|
|
1302
1451
|
getLogger() {
|
|
1303
1452
|
return this.#logger;
|
|
1304
1453
|
}
|
|
1305
|
-
/**
|
|
1306
|
-
* Gets the currently configured telemetry instance.
|
|
1307
|
-
*
|
|
1308
|
-
* @example
|
|
1309
|
-
* ```typescript
|
|
1310
|
-
* const mastra = new Mastra({
|
|
1311
|
-
* telemetry: {
|
|
1312
|
-
* enabled: true,
|
|
1313
|
-
* serviceName: 'my-mastra-app'
|
|
1314
|
-
* }
|
|
1315
|
-
* });
|
|
1316
|
-
*
|
|
1317
|
-
* const telemetry = mastra.getTelemetry();
|
|
1318
|
-
* if (telemetry) {
|
|
1319
|
-
* const span = telemetry.startSpan('custom-operation');
|
|
1320
|
-
* span.setAttributes({ operation: 'data-processing' });
|
|
1321
|
-
* span.end();
|
|
1322
|
-
* }
|
|
1323
|
-
* ```
|
|
1324
|
-
*
|
|
1325
|
-
* @deprecated use {@link getAITracing()} instead
|
|
1326
|
-
*/
|
|
1327
|
-
getTelemetry() {
|
|
1328
|
-
return this.#telemetry;
|
|
1329
|
-
}
|
|
1330
|
-
/**
|
|
1331
|
-
* Gets the currently configured memory instance.
|
|
1332
|
-
*
|
|
1333
|
-
* @deprecated Memory should be configured directly on agents instead of on the Mastra instance.
|
|
1334
|
-
* Use `new Agent({ memory: new Memory() })` instead.
|
|
1335
|
-
*
|
|
1336
|
-
* @example Legacy memory usage (deprecated)
|
|
1337
|
-
* ```typescript
|
|
1338
|
-
* // This approach is deprecated
|
|
1339
|
-
* const mastra = new Mastra({
|
|
1340
|
-
* // memory: new Memory() // This is no longer supported
|
|
1341
|
-
* });
|
|
1342
|
-
*
|
|
1343
|
-
* // Use this instead:
|
|
1344
|
-
* const agent = new Agent({
|
|
1345
|
-
* name: 'assistant',
|
|
1346
|
-
* memory: new Memory({
|
|
1347
|
-
* storage: new LibSQLStore({ url: ':memory:' })
|
|
1348
|
-
* })
|
|
1349
|
-
* });
|
|
1350
|
-
* ```
|
|
1351
|
-
*/
|
|
1352
|
-
getMemory() {
|
|
1353
|
-
return this.#memory;
|
|
1354
|
-
}
|
|
1355
1454
|
/**
|
|
1356
1455
|
* Gets the currently configured storage provider.
|
|
1357
1456
|
*
|
|
1358
1457
|
* @example
|
|
1359
1458
|
* ```typescript
|
|
1360
1459
|
* const mastra = new Mastra({
|
|
1361
|
-
* storage: new LibSQLStore({ url: 'file:./data.db' })
|
|
1460
|
+
* storage: new LibSQLStore({ id: 'mastra-storage', url: 'file:./data.db' })
|
|
1362
1461
|
* });
|
|
1363
1462
|
*
|
|
1364
1463
|
* // Use the storage in agent memory
|
|
1365
1464
|
* const agent = new Agent({
|
|
1465
|
+
* id: 'assistant',
|
|
1366
1466
|
* name: 'assistant',
|
|
1367
1467
|
* memory: new Memory({
|
|
1368
1468
|
* storage: mastra.getStorage()
|
|
@@ -1373,6 +1473,9 @@ do:
|
|
|
1373
1473
|
getStorage() {
|
|
1374
1474
|
return this.#storage;
|
|
1375
1475
|
}
|
|
1476
|
+
get observability() {
|
|
1477
|
+
return this.#observability;
|
|
1478
|
+
}
|
|
1376
1479
|
getServerMiddleware() {
|
|
1377
1480
|
return this.#serverMiddleware;
|
|
1378
1481
|
}
|
|
@@ -1381,14 +1484,16 @@ do:
|
|
|
1381
1484
|
}
|
|
1382
1485
|
setServerMiddleware(serverMiddleware) {
|
|
1383
1486
|
if (typeof serverMiddleware === "function") {
|
|
1384
|
-
this.#serverMiddleware = [
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1487
|
+
this.#serverMiddleware = [
|
|
1488
|
+
{
|
|
1489
|
+
handler: serverMiddleware,
|
|
1490
|
+
path: "/api/*"
|
|
1491
|
+
}
|
|
1492
|
+
];
|
|
1388
1493
|
return;
|
|
1389
1494
|
}
|
|
1390
1495
|
if (!Array.isArray(serverMiddleware)) {
|
|
1391
|
-
const error = new
|
|
1496
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
1392
1497
|
id: "MASTRA_SET_SERVER_MIDDLEWARE_INVALID_TYPE",
|
|
1393
1498
|
domain: "MASTRA" /* MASTRA */,
|
|
1394
1499
|
category: "USER" /* USER */,
|
|
@@ -1397,7 +1502,7 @@ do:
|
|
|
1397
1502
|
this.#logger?.trackException(error);
|
|
1398
1503
|
throw error;
|
|
1399
1504
|
}
|
|
1400
|
-
this.#serverMiddleware = serverMiddleware.map(m => {
|
|
1505
|
+
this.#serverMiddleware = serverMiddleware.map((m) => {
|
|
1401
1506
|
if (typeof m === "function") {
|
|
1402
1507
|
return {
|
|
1403
1508
|
handler: m,
|
|
@@ -1416,7 +1521,7 @@ do:
|
|
|
1416
1521
|
getBundlerConfig() {
|
|
1417
1522
|
return this.#bundler;
|
|
1418
1523
|
}
|
|
1419
|
-
async
|
|
1524
|
+
async listLogsByRunId({
|
|
1420
1525
|
runId,
|
|
1421
1526
|
transportId,
|
|
1422
1527
|
fromDate,
|
|
@@ -1427,8 +1532,8 @@ do:
|
|
|
1427
1532
|
perPage
|
|
1428
1533
|
}) {
|
|
1429
1534
|
if (!transportId) {
|
|
1430
|
-
const error = new
|
|
1431
|
-
id: "
|
|
1535
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
1536
|
+
id: "MASTRA_LIST_LOGS_BY_RUN_ID_MISSING_TRANSPORT",
|
|
1432
1537
|
domain: "MASTRA" /* MASTRA */,
|
|
1433
1538
|
category: "USER" /* USER */,
|
|
1434
1539
|
text: "Transport ID is required",
|
|
@@ -1440,12 +1545,12 @@ do:
|
|
|
1440
1545
|
this.#logger?.trackException(error);
|
|
1441
1546
|
throw error;
|
|
1442
1547
|
}
|
|
1443
|
-
if (!this.#logger?.
|
|
1444
|
-
const error = new
|
|
1548
|
+
if (!this.#logger?.listLogsByRunId) {
|
|
1549
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
1445
1550
|
id: "MASTRA_GET_LOGS_BY_RUN_ID_LOGGER_NOT_CONFIGURED",
|
|
1446
1551
|
domain: "MASTRA" /* MASTRA */,
|
|
1447
1552
|
category: "SYSTEM" /* SYSTEM */,
|
|
1448
|
-
text: "Logger is not configured or does not support
|
|
1553
|
+
text: "Logger is not configured or does not support listLogsByRunId operation",
|
|
1449
1554
|
details: {
|
|
1450
1555
|
runId,
|
|
1451
1556
|
transportId
|
|
@@ -1454,7 +1559,7 @@ do:
|
|
|
1454
1559
|
this.#logger?.trackException(error);
|
|
1455
1560
|
throw error;
|
|
1456
1561
|
}
|
|
1457
|
-
return await this.#logger.
|
|
1562
|
+
return await this.#logger.listLogsByRunId({
|
|
1458
1563
|
runId,
|
|
1459
1564
|
transportId,
|
|
1460
1565
|
fromDate,
|
|
@@ -1465,9 +1570,9 @@ do:
|
|
|
1465
1570
|
perPage
|
|
1466
1571
|
});
|
|
1467
1572
|
}
|
|
1468
|
-
async
|
|
1573
|
+
async listLogs(transportId, params) {
|
|
1469
1574
|
if (!transportId) {
|
|
1470
|
-
const error = new
|
|
1575
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
1471
1576
|
id: "MASTRA_GET_LOGS_MISSING_TRANSPORT",
|
|
1472
1577
|
domain: "MASTRA" /* MASTRA */,
|
|
1473
1578
|
category: "USER" /* USER */,
|
|
@@ -1480,7 +1585,7 @@ do:
|
|
|
1480
1585
|
throw error;
|
|
1481
1586
|
}
|
|
1482
1587
|
if (!this.#logger) {
|
|
1483
|
-
const error = new
|
|
1588
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
1484
1589
|
id: "MASTRA_GET_LOGS_LOGGER_NOT_CONFIGURED",
|
|
1485
1590
|
domain: "MASTRA" /* MASTRA */,
|
|
1486
1591
|
category: "SYSTEM" /* SYSTEM */,
|
|
@@ -1491,7 +1596,7 @@ do:
|
|
|
1491
1596
|
});
|
|
1492
1597
|
throw error;
|
|
1493
1598
|
}
|
|
1494
|
-
return await this.#logger.
|
|
1599
|
+
return await this.#logger.listLogs(transportId, params);
|
|
1495
1600
|
}
|
|
1496
1601
|
/**
|
|
1497
1602
|
* Gets all registered Model Context Protocol (MCP) server instances.
|
|
@@ -1509,13 +1614,83 @@ do:
|
|
|
1509
1614
|
* const mcpServers = mastra.getMCPServers();
|
|
1510
1615
|
* if (mcpServers) {
|
|
1511
1616
|
* const fsServer = mcpServers.filesystem;
|
|
1512
|
-
* const tools = await fsServer.
|
|
1617
|
+
* const tools = await fsServer.listTools();
|
|
1513
1618
|
* }
|
|
1514
1619
|
* ```
|
|
1515
1620
|
*/
|
|
1516
|
-
|
|
1621
|
+
listMCPServers() {
|
|
1517
1622
|
return this.#mcpServers;
|
|
1518
1623
|
}
|
|
1624
|
+
/**
|
|
1625
|
+
* Adds a new MCP server to the Mastra instance.
|
|
1626
|
+
*
|
|
1627
|
+
* This method allows dynamic registration of MCP servers after the Mastra instance
|
|
1628
|
+
* has been created. The server will be initialized with ID, Mastra instance, and logger.
|
|
1629
|
+
*
|
|
1630
|
+
* @throws {MastraError} When an MCP server with the same key already exists
|
|
1631
|
+
*
|
|
1632
|
+
* @example
|
|
1633
|
+
* ```typescript
|
|
1634
|
+
* const mastra = new Mastra();
|
|
1635
|
+
* const newServer = new FileSystemMCPServer({
|
|
1636
|
+
* rootPath: '/data'
|
|
1637
|
+
* });
|
|
1638
|
+
* mastra.addMCPServer(newServer); // Uses server.id as key
|
|
1639
|
+
* // or
|
|
1640
|
+
* mastra.addMCPServer(newServer, 'customKey'); // Uses custom key
|
|
1641
|
+
* ```
|
|
1642
|
+
*/
|
|
1643
|
+
addMCPServer(server, key) {
|
|
1644
|
+
if (key) {
|
|
1645
|
+
server.setId(key);
|
|
1646
|
+
}
|
|
1647
|
+
const resolvedId = server.id;
|
|
1648
|
+
if (!resolvedId) {
|
|
1649
|
+
const error = new chunkTWH4PTDG_cjs.MastraError({
|
|
1650
|
+
id: "MASTRA_ADD_MCP_SERVER_MISSING_ID",
|
|
1651
|
+
domain: "MASTRA" /* MASTRA */,
|
|
1652
|
+
category: "USER" /* USER */,
|
|
1653
|
+
text: "MCP server must expose an id or be registered under one",
|
|
1654
|
+
details: { status: 400 }
|
|
1655
|
+
});
|
|
1656
|
+
this.#logger?.trackException(error);
|
|
1657
|
+
throw error;
|
|
1658
|
+
}
|
|
1659
|
+
const serverKey = key ?? resolvedId;
|
|
1660
|
+
const servers = this.#mcpServers;
|
|
1661
|
+
if (servers[serverKey]) {
|
|
1662
|
+
const logger = this.getLogger();
|
|
1663
|
+
logger.debug(`MCP server with key ${serverKey} already exists. Skipping addition.`);
|
|
1664
|
+
return;
|
|
1665
|
+
}
|
|
1666
|
+
server.__registerMastra(this);
|
|
1667
|
+
server.__setLogger(this.getLogger());
|
|
1668
|
+
servers[serverKey] = server;
|
|
1669
|
+
}
|
|
1670
|
+
/**
|
|
1671
|
+
* Retrieves a specific MCP server instance by registration key.
|
|
1672
|
+
*
|
|
1673
|
+
* @throws {MastraError} When the specified MCP server is not found
|
|
1674
|
+
*
|
|
1675
|
+
* @example
|
|
1676
|
+
* ```typescript
|
|
1677
|
+
* const mastra = new Mastra({
|
|
1678
|
+
* mcpServers: {
|
|
1679
|
+
* filesystem: new FileSystemMCPServer({...})
|
|
1680
|
+
* }
|
|
1681
|
+
* });
|
|
1682
|
+
*
|
|
1683
|
+
* const fsServer = mastra.getMCPServer('filesystem');
|
|
1684
|
+
* const tools = await fsServer.listTools();
|
|
1685
|
+
* ```
|
|
1686
|
+
*/
|
|
1687
|
+
getMCPServer(name) {
|
|
1688
|
+
if (!this.#mcpServers || !this.#mcpServers[name]) {
|
|
1689
|
+
this.#logger?.debug(`MCP server with name ${String(name)} not found`);
|
|
1690
|
+
return void 0;
|
|
1691
|
+
}
|
|
1692
|
+
return this.#mcpServers[name];
|
|
1693
|
+
}
|
|
1519
1694
|
/**
|
|
1520
1695
|
* Retrieves a specific Model Context Protocol (MCP) server instance by its logical ID.
|
|
1521
1696
|
*
|
|
@@ -1535,24 +1710,24 @@ do:
|
|
|
1535
1710
|
* }
|
|
1536
1711
|
* });
|
|
1537
1712
|
*
|
|
1538
|
-
* const fsServer = mastra.
|
|
1713
|
+
* const fsServer = mastra.getMCPServerById('fs-server');
|
|
1539
1714
|
* if (fsServer) {
|
|
1540
|
-
* const tools = await fsServer.
|
|
1715
|
+
* const tools = await fsServer.listTools();
|
|
1541
1716
|
* }
|
|
1542
1717
|
* ```
|
|
1543
1718
|
*/
|
|
1544
|
-
|
|
1719
|
+
getMCPServerById(serverId, version) {
|
|
1545
1720
|
if (!this.#mcpServers) {
|
|
1546
1721
|
return void 0;
|
|
1547
1722
|
}
|
|
1548
1723
|
const allRegisteredServers = Object.values(this.#mcpServers || {});
|
|
1549
|
-
const matchingLogicalIdServers = allRegisteredServers.filter(server => server.id === serverId);
|
|
1724
|
+
const matchingLogicalIdServers = allRegisteredServers.filter((server) => server.id === serverId);
|
|
1550
1725
|
if (matchingLogicalIdServers.length === 0) {
|
|
1551
1726
|
this.#logger?.debug(`No MCP servers found with logical ID: ${serverId}`);
|
|
1552
1727
|
return void 0;
|
|
1553
1728
|
}
|
|
1554
1729
|
if (version) {
|
|
1555
|
-
const specificVersionServer = matchingLogicalIdServers.find(server => server.version === version);
|
|
1730
|
+
const specificVersionServer = matchingLogicalIdServers.find((server) => server.version === version);
|
|
1556
1731
|
if (!specificVersionServer) {
|
|
1557
1732
|
this.#logger?.debug(`MCP server with logical ID '${serverId}' found, but not version '${version}'.`);
|
|
1558
1733
|
}
|
|
@@ -1575,7 +1750,9 @@ do:
|
|
|
1575
1750
|
return latestServer;
|
|
1576
1751
|
}
|
|
1577
1752
|
}
|
|
1578
|
-
this.#logger?.warn(
|
|
1753
|
+
this.#logger?.warn(
|
|
1754
|
+
`Could not determine the latest server for logical ID '${serverId}' due to invalid or missing release dates, or no servers left after filtering.`
|
|
1755
|
+
);
|
|
1579
1756
|
return void 0;
|
|
1580
1757
|
}
|
|
1581
1758
|
}
|
|
@@ -1612,7 +1789,7 @@ do:
|
|
|
1612
1789
|
* Gracefully shuts down the Mastra instance and cleans up all resources.
|
|
1613
1790
|
*
|
|
1614
1791
|
* This method performs a clean shutdown of all Mastra components, including:
|
|
1615
|
-
* -
|
|
1792
|
+
* - tracing registry and all tracing instances
|
|
1616
1793
|
* - Event engine and pub/sub system
|
|
1617
1794
|
* - All registered components and their resources
|
|
1618
1795
|
*
|
|
@@ -1634,8 +1811,8 @@ do:
|
|
|
1634
1811
|
* ```
|
|
1635
1812
|
*/
|
|
1636
1813
|
async shutdown() {
|
|
1637
|
-
await chunkP35FNLTQ_cjs.shutdownAITracingRegistry();
|
|
1638
1814
|
await this.stopEventEngine();
|
|
1815
|
+
await this.#observability.shutdown();
|
|
1639
1816
|
this.#logger?.info("Mastra shutdown completed");
|
|
1640
1817
|
}
|
|
1641
1818
|
// This method is only used internally for server hnadlers that require temporary persistence
|
|
@@ -1643,11 +1820,7 @@ do:
|
|
|
1643
1820
|
return this.#serverCache;
|
|
1644
1821
|
}
|
|
1645
1822
|
};
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
return exports.Mastra;
|
|
1651
|
-
})();
|
|
1652
|
-
//# sourceMappingURL=chunk-ABZOBBLL.cjs.map
|
|
1653
|
-
//# sourceMappingURL=chunk-ABZOBBLL.cjs.map
|
|
1823
|
+
|
|
1824
|
+
exports.Mastra = Mastra;
|
|
1825
|
+
//# sourceMappingURL=chunk-BXOL277H.cjs.map
|
|
1826
|
+
//# sourceMappingURL=chunk-BXOL277H.cjs.map
|