@mastra/core 1.0.0-beta.21 → 1.0.0-beta.22
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 +356 -0
- package/dist/action/index.d.ts +7 -7
- package/dist/action/index.d.ts.map +1 -1
- package/dist/agent/agent-legacy.d.ts.map +1 -1
- package/dist/agent/agent.d.ts +100 -18
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.types.d.ts +22 -18
- package/dist/agent/agent.types.d.ts.map +1 -1
- package/dist/agent/index.cjs +13 -13
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/adapters/AIV4Adapter.d.ts.map +1 -1
- package/dist/agent/message-list/index.cjs +18 -18
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/message-list/message-list.d.ts +2 -1
- package/dist/agent/message-list/message-list.d.ts.map +1 -1
- package/dist/agent/trip-wire.d.ts +1 -2
- package/dist/agent/trip-wire.d.ts.map +1 -1
- package/dist/agent/types.d.ts +9 -10
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/utils.d.ts +7 -42
- package/dist/agent/utils.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts +6 -118
- package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts +7 -11
- 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 +4 -68
- 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 +3 -45
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/schema.d.ts +10 -10
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts +2 -8
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts.map +1 -1
- package/dist/{chunk-HJXEZSNI.js → chunk-3XY64RAM.js} +5 -5
- package/dist/{chunk-HJXEZSNI.js.map → chunk-3XY64RAM.js.map} +1 -1
- package/dist/{chunk-XSJNTLM7.js → chunk-453NPBJ7.js} +479 -47
- package/dist/chunk-453NPBJ7.js.map +1 -0
- package/dist/{chunk-3CZ42NBZ.js → chunk-5UVSKF5L.js} +17 -14
- package/dist/chunk-5UVSKF5L.js.map +1 -0
- package/dist/{chunk-XKDVT3ZH.cjs → chunk-67ZKOPA4.cjs} +480 -48
- package/dist/chunk-67ZKOPA4.cjs.map +1 -0
- package/dist/{chunk-YLP5IWH2.js → chunk-7IYWOBLG.js} +4 -4
- package/dist/{chunk-YLP5IWH2.js.map → chunk-7IYWOBLG.js.map} +1 -1
- package/dist/{chunk-3RCMDLCG.cjs → chunk-ALQFYWAR.cjs} +12 -12
- package/dist/{chunk-3RCMDLCG.cjs.map → chunk-ALQFYWAR.cjs.map} +1 -1
- package/dist/{chunk-PC3FBUWH.js → chunk-C4CIC3LZ.js} +2 -2
- package/dist/chunk-C4CIC3LZ.js.map +1 -0
- package/dist/{chunk-7JGQWNV5.js → chunk-CPLRD2VP.js} +3 -3
- package/dist/{chunk-7JGQWNV5.js.map → chunk-CPLRD2VP.js.map} +1 -1
- package/dist/{chunk-AHN7K3VE.js → chunk-CQ2E577C.js} +5 -5
- package/dist/chunk-CQ2E577C.js.map +1 -0
- package/dist/{chunk-A4MCHA5L.cjs → chunk-CVLIEFWM.cjs} +100 -819
- package/dist/chunk-CVLIEFWM.cjs.map +1 -0
- package/dist/{chunk-XBZWAUZ3.js → chunk-IFPQ2MLB.js} +25 -12
- package/dist/chunk-IFPQ2MLB.js.map +1 -0
- package/dist/{chunk-DVJZZAZA.cjs → chunk-IHD36QFA.cjs} +7 -7
- package/dist/{chunk-DVJZZAZA.cjs.map → chunk-IHD36QFA.cjs.map} +1 -1
- package/dist/{chunk-WMJEP45F.cjs → chunk-J4KVR4DZ.cjs} +25 -18
- package/dist/chunk-J4KVR4DZ.cjs.map +1 -0
- package/dist/{chunk-3RFSIHFR.js → chunk-K2LPTKSY.js} +4 -720
- package/dist/chunk-K2LPTKSY.js.map +1 -0
- package/dist/{chunk-FY3PYSMK.cjs → chunk-KHO4KFXW.cjs} +5 -5
- package/dist/{chunk-FY3PYSMK.cjs.map → chunk-KHO4KFXW.cjs.map} +1 -1
- package/dist/{chunk-W7R7GPNN.cjs → chunk-MGPIVG2O.cjs} +9 -9
- package/dist/chunk-MGPIVG2O.cjs.map +1 -0
- package/dist/{chunk-KGE3KAM7.js → chunk-N3PAHTKU.js} +23 -3
- package/dist/chunk-N3PAHTKU.js.map +1 -0
- package/dist/{chunk-O4H44CMA.js → chunk-N7TDP7ZE.js} +586 -117
- package/dist/chunk-N7TDP7ZE.js.map +1 -0
- package/dist/{chunk-I5GMA5UM.cjs → chunk-NPIYNC5A.cjs} +9 -9
- package/dist/{chunk-I5GMA5UM.cjs.map → chunk-NPIYNC5A.cjs.map} +1 -1
- package/dist/{chunk-AW7FISLD.cjs → chunk-OZ75PBBK.cjs} +27 -7
- package/dist/chunk-OZ75PBBK.cjs.map +1 -0
- package/dist/{chunk-JMAPJWVG.cjs → chunk-OZCUIZRA.cjs} +2021 -1426
- package/dist/chunk-OZCUIZRA.cjs.map +1 -0
- package/dist/{chunk-6OPEMI2Q.cjs → chunk-PM3UIIBK.cjs} +2 -3
- package/dist/{chunk-6OPEMI2Q.cjs.map → chunk-PM3UIIBK.cjs.map} +1 -1
- package/dist/{chunk-CISH55FP.js → chunk-PSIJ6OSV.js} +16 -9
- package/dist/chunk-PSIJ6OSV.js.map +1 -0
- package/dist/{chunk-UOZ3GJY2.cjs → chunk-PTK74KG4.cjs} +2 -2
- package/dist/chunk-PTK74KG4.cjs.map +1 -0
- package/dist/{chunk-O5IPTMEH.cjs → chunk-Q5QQDMSD.cjs} +32 -29
- package/dist/chunk-Q5QQDMSD.cjs.map +1 -0
- package/dist/{chunk-UVHSM2GU.cjs → chunk-SMM2C4KH.cjs} +6 -4
- package/dist/chunk-SMM2C4KH.cjs.map +1 -0
- package/dist/{chunk-UXLQEGIN.cjs → chunk-SVPXZEU7.cjs} +35 -22
- package/dist/chunk-SVPXZEU7.cjs.map +1 -0
- package/dist/{chunk-SOSXN7X4.cjs → chunk-TU6MNGBB.cjs} +619 -151
- package/dist/chunk-TU6MNGBB.cjs.map +1 -0
- package/dist/{chunk-EK7E4ETB.js → chunk-TX5GUG5Q.js} +3 -3
- package/dist/{chunk-EK7E4ETB.js.map → chunk-TX5GUG5Q.js.map} +1 -1
- package/dist/{chunk-SQ7T6FWC.cjs → chunk-UAH236P2.cjs} +13 -13
- package/dist/{chunk-SQ7T6FWC.cjs.map → chunk-UAH236P2.cjs.map} +1 -1
- package/dist/{chunk-AIJ6HPJG.js → chunk-UL7TJCKA.js} +4 -4
- package/dist/{chunk-AIJ6HPJG.js.map → chunk-UL7TJCKA.js.map} +1 -1
- package/dist/{chunk-IC2MIQBW.js → chunk-UVOQLIWL.js} +1922 -1326
- package/dist/chunk-UVOQLIWL.js.map +1 -0
- package/dist/{chunk-IMLORTHO.js → chunk-WANKWENG.js} +5 -5
- package/dist/{chunk-IMLORTHO.js.map → chunk-WANKWENG.js.map} +1 -1
- package/dist/{chunk-ICU4Z5MO.cjs → chunk-X7DR353F.cjs} +8 -8
- package/dist/{chunk-ICU4Z5MO.cjs.map → chunk-X7DR353F.cjs.map} +1 -1
- package/dist/{chunk-6TBWJV35.js → chunk-Y22QMA7S.js} +6 -4
- package/dist/chunk-Y22QMA7S.js.map +1 -0
- package/dist/{chunk-FT7DFPAL.js → chunk-YYNZEEOO.js} +5 -5
- package/dist/{chunk-FT7DFPAL.js.map → chunk-YYNZEEOO.js.map} +1 -1
- package/dist/di/index.cjs +4 -4
- package/dist/di/index.js +1 -1
- package/dist/docs/README.md +6 -5
- package/dist/docs/SKILL.md +6 -5
- package/dist/docs/SOURCE_MAP.json +288 -293
- package/dist/docs/agents/01-overview.md +2 -2
- package/dist/docs/agents/02-using-tools.md +5 -0
- package/dist/docs/agents/04-structured-output.md +24 -4
- package/dist/docs/agents/06-processors.md +65 -1
- package/dist/docs/agents/08-agent-approval.md +5 -6
- package/dist/docs/agents/09-network-approval.md +274 -0
- package/dist/docs/agents/{10-reference.md → 11-reference.md} +1 -1
- package/dist/docs/ai-sdk/01-reference.md +1 -1
- package/dist/docs/cli/01-reference.md +1 -1
- package/dist/docs/client-js/01-reference.md +10 -5
- package/dist/docs/configuration.mdx/01-reference.md +750 -0
- package/dist/docs/core/01-reference.md +9 -35
- package/dist/docs/deployer/01-reference.md +19 -6
- package/dist/docs/evals/01-overview.md +5 -5
- package/dist/docs/evals/02-custom-scorers.md +49 -6
- package/dist/docs/evals/04-reference.md +10 -4
- package/dist/docs/mcp/01-overview.md +26 -16
- package/dist/docs/mcp/02-publishing-mcp-server.md +2 -2
- package/dist/docs/memory/01-overview.md +2 -2
- package/dist/docs/memory/02-storage.md +59 -25
- package/dist/docs/memory/03-working-memory.md +10 -6
- package/dist/docs/memory/04-semantic-recall.md +2 -4
- package/dist/docs/memory/05-memory-processors.md +2 -3
- package/dist/docs/memory/06-reference.md +2 -4
- package/dist/docs/observability/01-overview.md +1 -1
- package/dist/docs/observability/02-logging.md +4 -5
- package/dist/docs/observability/03-overview.md +69 -13
- package/dist/docs/observability/09-datadog.md +169 -0
- package/dist/docs/observability/10-laminar.md +95 -0
- package/dist/docs/observability/{11-otel.md → 13-otel.md} +12 -7
- package/dist/docs/observability/{13-reference.md → 15-reference.md} +125 -1
- package/dist/docs/processors/01-reference.md +23 -0
- package/dist/docs/rag/01-overview.md +1 -1
- package/dist/docs/rag/02-chunking-and-embedding.md +0 -1
- package/dist/docs/rag/03-vector-databases.md +10 -5
- package/dist/docs/rag/04-retrieval.md +5 -6
- package/dist/docs/rag/06-reference.md +4 -5
- package/dist/docs/server/01-mastra-server.md +32 -49
- package/dist/docs/server/02-custom-adapters.md +5 -2
- package/dist/docs/server/04-request-context.md +50 -11
- package/dist/docs/server/05-custom-api-routes.md +1 -1
- package/dist/docs/server/06-mastra-client.md +2 -2
- package/dist/docs/storage/01-reference.md +99 -23
- package/dist/docs/streaming/04-reference.md +6 -1
- package/dist/docs/tools/01-reference.md +380 -25
- package/dist/docs/tools-mcp/01-mcp-overview.md +10 -2
- package/dist/docs/tools-mcp/02-overview.md +4 -4
- package/dist/docs/vectors/01-reference.md +24 -11
- package/dist/docs/voice/01-overview.md +2 -2
- package/dist/docs/voice/05-reference.md +2 -2
- package/dist/docs/workflows/01-overview.md +5 -5
- package/dist/docs/workflows/04-agents-and-tools.md +4 -6
- package/dist/docs/workflows/06-suspend-and-resume.md +5 -7
- package/dist/docs/workflows/11-reference.md +1 -91
- package/dist/evals/base.d.ts.map +1 -1
- package/dist/evals/index.cjs +20 -20
- package/dist/evals/index.js +3 -3
- package/dist/evals/scoreTraces/index.cjs +5 -5
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts +4 -67
- package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/integration/index.cjs +2 -2
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.cjs +9 -9
- package/dist/llm/index.js +2 -2
- package/dist/llm/model/model.loop.d.ts +1 -2
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/llm/model/model.loop.types.d.ts +1 -2
- package/dist/llm/model/model.loop.types.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +224 -18
- package/dist/loop/index.cjs +12 -12
- package/dist/loop/index.js +1 -1
- package/dist/loop/loop.d.ts +1 -2
- package/dist/loop/loop.d.ts.map +1 -1
- package/dist/loop/network/index.d.ts +21 -80
- package/dist/loop/network/index.d.ts.map +1 -1
- package/dist/loop/network/run-command-tool.d.ts +14 -11
- package/dist/loop/network/run-command-tool.d.ts.map +1 -1
- package/dist/loop/network/validation.d.ts +3 -4
- package/dist/loop/network/validation.d.ts.map +1 -1
- package/dist/loop/test-utils/options.d.ts.map +1 -1
- package/dist/loop/types.d.ts +4 -5
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +31 -804
- package/dist/loop/workflows/agentic-execution/index.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +22 -539
- 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 +13 -294
- 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 -41
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts +32 -805
- package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
- package/dist/loop/workflows/schema.d.ts +90 -91
- package/dist/loop/workflows/schema.d.ts.map +1 -1
- package/dist/loop/workflows/stream.d.ts +1 -2
- package/dist/loop/workflows/stream.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +28 -9
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +11 -11
- package/dist/memory/index.js +1 -1
- package/dist/memory/memory.d.ts +4 -2
- package/dist/memory/memory.d.ts.map +1 -1
- package/dist/observability/index.cjs +11 -11
- package/dist/observability/index.js +1 -1
- package/dist/observability/types/tracing.d.ts +45 -7
- package/dist/observability/types/tracing.d.ts.map +1 -1
- package/dist/processors/index.cjs +38 -38
- package/dist/processors/index.d.ts +3 -3
- package/dist/processors/index.d.ts.map +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/memory/semantic-recall.d.ts +2 -0
- package/dist/processors/memory/semantic-recall.d.ts.map +1 -1
- package/dist/processors/processors/structured-output.d.ts +2 -2
- package/dist/processors/processors/structured-output.d.ts.map +1 -1
- package/dist/processors/processors/token-limiter.d.ts +16 -10
- package/dist/processors/processors/token-limiter.d.ts.map +1 -1
- package/dist/processors/runner.d.ts +4 -4
- package/dist/processors/runner.d.ts.map +1 -1
- package/dist/processors/step-schema.d.ts +66 -67
- package/dist/processors/step-schema.d.ts.map +1 -1
- package/dist/provider-registry-C3IAGLLU.js +3 -0
- package/dist/{provider-registry-6DWM3X3I.js.map → provider-registry-C3IAGLLU.js.map} +1 -1
- package/dist/provider-registry-YH4FCTT2.cjs +40 -0
- package/dist/{provider-registry-DCECMUCQ.cjs.map → provider-registry-YH4FCTT2.cjs.map} +1 -1
- package/dist/provider-registry.json +477 -45
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/request-context/index.cjs +4 -4
- package/dist/request-context/index.d.ts +10 -9
- package/dist/request-context/index.d.ts.map +1 -1
- package/dist/request-context/index.js +1 -1
- package/dist/server/types.d.ts +1 -1
- package/dist/storage/constants.cjs +14 -14
- package/dist/storage/constants.d.ts +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/observability/types.d.ts +90 -90
- package/dist/storage/domains/workflows/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +93 -93
- package/dist/storage/index.js +2 -2
- package/dist/stream/MastraAgentNetworkStream.d.ts +8 -12
- package/dist/stream/MastraAgentNetworkStream.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/execute.d.ts +2 -3
- package/dist/stream/aisdk/v5/execute.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/transform.d.ts +2 -3
- package/dist/stream/aisdk/v5/transform.d.ts.map +1 -1
- package/dist/stream/base/output-format-handlers.d.ts +2 -2
- package/dist/stream/base/output-format-handlers.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts +76 -50
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/base/schema.d.ts +7 -2
- package/dist/stream/base/schema.d.ts.map +1 -1
- package/dist/stream/index.cjs +11 -15
- package/dist/stream/index.d.ts +2 -2
- package/dist/stream/index.d.ts.map +1 -1
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +72 -26
- package/dist/stream/types.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.cjs +4 -4
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.d.ts +1 -1
- package/dist/tool-loop-agent/index.d.ts.map +1 -1
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/tool-loop-agent/tool-loop-processor.d.ts +1 -2
- package/dist/tool-loop-agent/tool-loop-processor.d.ts.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.map +1 -1
- package/dist/tools/tool.d.ts +27 -14
- package/dist/tools/tool.d.ts.map +1 -1
- package/dist/tools/types.d.ts +76 -20
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/ui-types.d.ts +3 -4
- package/dist/tools/ui-types.d.ts.map +1 -1
- package/dist/tools/validation.d.ts +4 -4
- package/dist/tools/validation.d.ts.map +1 -1
- package/dist/types/dynamic-argument.d.ts +61 -1
- package/dist/types/dynamic-argument.d.ts.map +1 -1
- package/dist/types/zod-compat.d.ts +3 -11
- package/dist/types/zod-compat.d.ts.map +1 -1
- package/dist/utils.cjs +22 -22
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/vector/index.cjs +2 -2
- package/dist/vector/index.js +1 -1
- package/dist/voice/index.cjs +6 -6
- package/dist/voice/index.js +1 -1
- package/dist/workflows/default.d.ts +114 -2
- package/dist/workflows/default.d.ts.map +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/step-executor.d.ts +1 -1
- package/dist/workflows/evented/step-executor.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/utils.d.ts +1 -1
- package/dist/workflows/evented/workflow.d.ts +74 -21
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/handlers/control-flow.d.ts +2 -2
- package/dist/workflows/handlers/control-flow.d.ts.map +1 -1
- package/dist/workflows/handlers/sleep.d.ts.map +1 -1
- package/dist/workflows/handlers/step.d.ts +1 -1
- package/dist/workflows/handlers/step.d.ts.map +1 -1
- package/dist/workflows/index.cjs +23 -23
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/step.d.ts +28 -24
- package/dist/workflows/step.d.ts.map +1 -1
- package/dist/workflows/types.d.ts +91 -54
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts +165 -118
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/llm/model/provider-types.generated.d.ts +224 -18
- package/dist/chunk-3CZ42NBZ.js.map +0 -1
- package/dist/chunk-3RFSIHFR.js.map +0 -1
- package/dist/chunk-6TBWJV35.js.map +0 -1
- package/dist/chunk-A4MCHA5L.cjs.map +0 -1
- package/dist/chunk-AHN7K3VE.js.map +0 -1
- package/dist/chunk-AW7FISLD.cjs.map +0 -1
- package/dist/chunk-CISH55FP.js.map +0 -1
- package/dist/chunk-IC2MIQBW.js.map +0 -1
- package/dist/chunk-JMAPJWVG.cjs.map +0 -1
- package/dist/chunk-KGE3KAM7.js.map +0 -1
- package/dist/chunk-O4H44CMA.js.map +0 -1
- package/dist/chunk-O5IPTMEH.cjs.map +0 -1
- package/dist/chunk-PC3FBUWH.js.map +0 -1
- package/dist/chunk-SOSXN7X4.cjs.map +0 -1
- package/dist/chunk-UOZ3GJY2.cjs.map +0 -1
- package/dist/chunk-UVHSM2GU.cjs.map +0 -1
- package/dist/chunk-UXLQEGIN.cjs.map +0 -1
- package/dist/chunk-W7R7GPNN.cjs.map +0 -1
- package/dist/chunk-WMJEP45F.cjs.map +0 -1
- package/dist/chunk-XBZWAUZ3.js.map +0 -1
- package/dist/chunk-XKDVT3ZH.cjs.map +0 -1
- package/dist/chunk-XSJNTLM7.js.map +0 -1
- package/dist/provider-registry-6DWM3X3I.js +0 -3
- package/dist/provider-registry-DCECMUCQ.cjs +0 -40
- package/dist/stream/aisdk/v5/output.d.ts +0 -121
- package/dist/stream/aisdk/v5/output.d.ts.map +0 -1
- /package/dist/docs/agents/{09-adding-voice.md → 10-adding-voice.md} +0 -0
- /package/dist/docs/observability/{09-langfuse.md → 11-langfuse.md} +0 -0
- /package/dist/docs/observability/{10-langsmith.md → 12-langsmith.md} +0 -0
- /package/dist/docs/observability/{12-posthog.md → 14-posthog.md} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Core API Reference
|
|
2
2
|
|
|
3
|
-
> API reference for core -
|
|
3
|
+
> API reference for core - 32 entries
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
---
|
|
@@ -9,12 +9,9 @@
|
|
|
9
9
|
|
|
10
10
|
> Documentation for the `Mastra` class in Mastra, the core entry point for managing agents, workflows, MCP servers, and server endpoints.
|
|
11
11
|
|
|
12
|
-
The `Mastra` class is the central orchestrator in any Mastra application, managing agents, workflows, storage, logging,
|
|
12
|
+
The `Mastra` class is the central orchestrator in any Mastra application, managing agents, workflows, storage, logging, observability, and more. Typically, you create a single instance of `Mastra` to coordinate your application.
|
|
13
13
|
|
|
14
|
-
Think of `Mastra` as a top-level registry
|
|
15
|
-
|
|
16
|
-
- Registering **integrations** makes them accessible to **agents**, **workflows**, and **tools** alike.
|
|
17
|
-
- **tools** aren’t registered on `Mastra` directly but are associated with agents and discovered automatically.
|
|
14
|
+
Think of `Mastra` as a top-level registry where you register agents, workflows, tools, and other components that need to be accessible throughout your application.
|
|
18
15
|
|
|
19
16
|
## Usage example
|
|
20
17
|
|
|
@@ -41,6 +38,8 @@ export const mastra = new Mastra({
|
|
|
41
38
|
|
|
42
39
|
## Constructor parameters
|
|
43
40
|
|
|
41
|
+
Visit the [Configuration reference](https://mastra.ai/reference/v1/configuration) for detailed documentation on all available configuration options.
|
|
42
|
+
|
|
44
43
|
---
|
|
45
44
|
|
|
46
45
|
## Reference: MastraModelGateway
|
|
@@ -516,7 +515,7 @@ import { Memory } from "@mastra/memory";
|
|
|
516
515
|
import { LibSQLStore } from "@mastra/libsql";
|
|
517
516
|
|
|
518
517
|
const conversationMemory = new Memory({
|
|
519
|
-
storage: new LibSQLStore({ url: ":memory:" }),
|
|
518
|
+
storage: new LibSQLStore({ id: 'conversation-store', url: ":memory:" }),
|
|
520
519
|
});
|
|
521
520
|
|
|
522
521
|
const mastra = new Mastra({
|
|
@@ -1025,12 +1024,12 @@ import { LibSQLStore } from "@mastra/libsql";
|
|
|
1025
1024
|
|
|
1026
1025
|
const conversationMemory = new Memory({
|
|
1027
1026
|
id: "conversation-memory",
|
|
1028
|
-
storage: new LibSQLStore({ url: ":memory:" }),
|
|
1027
|
+
storage: new LibSQLStore({ id: 'conversation-store', url: ":memory:" }),
|
|
1029
1028
|
});
|
|
1030
1029
|
|
|
1031
1030
|
const analyticsMemory = new Memory({
|
|
1032
1031
|
id: "analytics-memory",
|
|
1033
|
-
storage: new LibSQLStore({ url: ":memory:" }),
|
|
1032
|
+
storage: new LibSQLStore({ id: 'analytics-store', url: ":memory:" }),
|
|
1034
1033
|
});
|
|
1035
1034
|
|
|
1036
1035
|
const mastra = new Mastra({
|
|
@@ -1265,29 +1264,4 @@ This method does not return a value.
|
|
|
1265
1264
|
## Related
|
|
1266
1265
|
|
|
1267
1266
|
- [Storage overview](https://mastra.ai/reference/v1/storage/overview)
|
|
1268
|
-
- [Storage reference](https://mastra.ai/reference/v1/storage/libsql)
|
|
1269
|
-
|
|
1270
|
-
---
|
|
1271
|
-
|
|
1272
|
-
## Reference: Mastra.setTelemetry()
|
|
1273
|
-
|
|
1274
|
-
> Documentation for the `Mastra.setTelemetry()` method in Mastra, which sets the telemetry configuration for all components.
|
|
1275
|
-
|
|
1276
|
-
The `.setTelemetry()` method is used to set the telemetry configuration for all components in the Mastra instance. This method accepts a single telemetry configuration object.
|
|
1277
|
-
|
|
1278
|
-
## Usage example
|
|
1279
|
-
|
|
1280
|
-
```typescript
|
|
1281
|
-
mastra.setTelemetry({ export: { type: "console" } });
|
|
1282
|
-
```
|
|
1283
|
-
|
|
1284
|
-
## Parameters
|
|
1285
|
-
|
|
1286
|
-
## Returns
|
|
1287
|
-
|
|
1288
|
-
This method does not return a value.
|
|
1289
|
-
|
|
1290
|
-
## Related
|
|
1291
|
-
|
|
1292
|
-
- [Logging](https://mastra.ai/docs/v1/observability/logging)
|
|
1293
|
-
- [PinoLogger](https://mastra.ai/reference/v1/logging/pino-logger)
|
|
1267
|
+
- [Storage reference](https://mastra.ai/reference/v1/storage/libsql)
|
|
@@ -19,7 +19,7 @@ import { CloudflareDeployer } from "@mastra/deployer-cloudflare";
|
|
|
19
19
|
|
|
20
20
|
export const mastra = new Mastra({
|
|
21
21
|
deployer: new CloudflareDeployer({
|
|
22
|
-
|
|
22
|
+
name: "hello-mastra",
|
|
23
23
|
routes: [
|
|
24
24
|
{
|
|
25
25
|
pattern: "example.com/*",
|
|
@@ -27,12 +27,11 @@ export const mastra = new Mastra({
|
|
|
27
27
|
custom_domain: true
|
|
28
28
|
}
|
|
29
29
|
],
|
|
30
|
-
|
|
31
|
-
env: {
|
|
30
|
+
vars: {
|
|
32
31
|
NODE_ENV: "production",
|
|
33
32
|
API_KEY: "<api-key>"
|
|
34
33
|
},
|
|
35
|
-
|
|
34
|
+
d1_databases: [
|
|
36
35
|
{
|
|
37
36
|
binding: "DB",
|
|
38
37
|
database_name: "my-database",
|
|
@@ -40,16 +39,30 @@ export const mastra = new Mastra({
|
|
|
40
39
|
preview_database_id: "your-preview-database-id"
|
|
41
40
|
}
|
|
42
41
|
],
|
|
43
|
-
|
|
42
|
+
kv_namespaces: [
|
|
44
43
|
{
|
|
45
44
|
binding: "CACHE",
|
|
46
45
|
id: "kv-namespace-id"
|
|
47
46
|
}
|
|
48
47
|
]
|
|
48
|
+
})
|
|
49
49
|
});
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
##
|
|
52
|
+
## Constructor options
|
|
53
|
+
|
|
54
|
+
The `CloudflareDeployer` constructor accepts the same configuration options as `wrangler.json`. See the [Wrangler configuration documentation](https://developers.cloudflare.com/workers/wrangler/configuration/) for all available options.
|
|
55
|
+
|
|
56
|
+
### Migrating from earlier versions
|
|
57
|
+
|
|
58
|
+
The following fields are deprecated and should be replaced with their standard `wrangler.json` equivalents:
|
|
59
|
+
|
|
60
|
+
| Deprecated | Use instead |
|
|
61
|
+
|------------|-------------|
|
|
62
|
+
| `projectName` | `name` |
|
|
63
|
+
| `d1Databases` | `d1_databases` |
|
|
64
|
+
| `kvNamespaces` | `kv_namespaces` |
|
|
65
|
+
| `workerNamespace` | *(removed, no longer used)* |
|
|
53
66
|
|
|
54
67
|
---
|
|
55
68
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
> Overview of scorers in Mastra, detailing their capabilities for evaluating AI outputs and measuring performance.
|
|
2
2
|
|
|
3
3
|
> **Code References:**
|
|
4
|
-
- `Agent`: dist/agent/agent.d.ts → dist/chunk-
|
|
5
|
-
- `createWorkflow`: dist/workflows/index.d.ts → dist/chunk-
|
|
6
|
-
- `createStep`: dist/workflows/index.d.ts → dist/chunk-
|
|
7
|
-
- `Workflow`: dist/workflows/workflow.d.ts → dist/chunk-
|
|
8
|
-
- `Mastra`: dist/mastra/index.d.ts → dist/chunk-
|
|
4
|
+
- `Agent`: dist/agent/agent.d.ts → dist/chunk-UVOQLIWL.js:16630
|
|
5
|
+
- `createWorkflow`: dist/workflows/index.d.ts → dist/chunk-UVOQLIWL.js:8230
|
|
6
|
+
- `createStep`: dist/workflows/index.d.ts → dist/chunk-UVOQLIWL.js:7570
|
|
7
|
+
- `Workflow`: dist/workflows/workflow.d.ts → dist/chunk-UVOQLIWL.js:8246
|
|
8
|
+
- `Mastra`: dist/mastra/index.d.ts → dist/chunk-IFPQ2MLB.js:24
|
|
9
9
|
|
|
10
10
|
# Scorers overview
|
|
11
11
|
|
|
@@ -29,17 +29,19 @@ Each step can use either **functions** or **prompt objects** (LLM-based evaluati
|
|
|
29
29
|
- Natural language understanding tasks
|
|
30
30
|
- Nuanced context evaluation
|
|
31
31
|
|
|
32
|
+
**What “prompt object” means:** Instead of a function, the step is an object with `description` + `createPrompt` (and `outputSchema` for `preprocess`/`analyze`). That object tells Mastra to run the judge LLM for the step and store the structured output in `results.<step>StepResult`.
|
|
33
|
+
|
|
32
34
|
You can mix and match approaches within a single scorer - for example, use a function for preprocessing data and an LLM for analyzing quality.
|
|
33
35
|
|
|
34
36
|
### Initializing a Scorer
|
|
35
37
|
|
|
36
|
-
Every scorer starts with the `createScorer` factory function, which requires
|
|
38
|
+
Every scorer starts with the `createScorer` factory function, which requires an id and description, and optionally accepts a type specification and judge configuration.
|
|
37
39
|
|
|
38
40
|
```typescript
|
|
39
41
|
import { createScorer } from '@mastra/core/evals';
|
|
40
42
|
|
|
41
43
|
const glutenCheckerScorer = createScorer({
|
|
42
|
-
|
|
44
|
+
id: 'gluten-checker',
|
|
43
45
|
description: 'Check if recipes contain gluten ingredients',
|
|
44
46
|
judge: { // Optional: for prompt object steps
|
|
45
47
|
model: 'openai/gpt-5.1',
|
|
@@ -55,6 +57,49 @@ const glutenCheckerScorer = createScorer({
|
|
|
55
57
|
|
|
56
58
|
The judge configuration is only needed if you plan to use prompt objects in any step. Individual steps can override this default configuration with their own judge settings.
|
|
57
59
|
|
|
60
|
+
If all steps are function-based, the judge is never called and there is no judge output. To see LLM output, define at least one step as a prompt object and read the corresponding step result (for example, `results.analyzeStepResult`).
|
|
61
|
+
|
|
62
|
+
#### Minimal judge example (prompt object)
|
|
63
|
+
|
|
64
|
+
This example uses a prompt object in `analyze`, so the judge runs and its structured output is available as `results.analyzeStepResult`.
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import { createScorer } from "@mastra/core/evals";
|
|
68
|
+
import { z } from "zod";
|
|
69
|
+
|
|
70
|
+
const quoteSourcesScorer = createScorer({
|
|
71
|
+
id: "quote-sources",
|
|
72
|
+
description: "Check if the response includes sources",
|
|
73
|
+
judge: {
|
|
74
|
+
model: "openai/gpt-4.1-nano",
|
|
75
|
+
instructions: "You are a strict evaluator.",
|
|
76
|
+
},
|
|
77
|
+
})
|
|
78
|
+
.analyze({
|
|
79
|
+
description: "Detect whether sources are present",
|
|
80
|
+
outputSchema: z.object({
|
|
81
|
+
hasSources: z.boolean(),
|
|
82
|
+
sources: z.array(z.string()),
|
|
83
|
+
}),
|
|
84
|
+
createPrompt: ({ run }) => `
|
|
85
|
+
Does the response contain sources? Extract them as a list.
|
|
86
|
+
|
|
87
|
+
Response:
|
|
88
|
+
${run.output}
|
|
89
|
+
`,
|
|
90
|
+
})
|
|
91
|
+
.generateScore(({ results }) => (results.analyzeStepResult.hasSources ? 1 : 0));
|
|
92
|
+
|
|
93
|
+
// Run the scorer and inspect judge output
|
|
94
|
+
const result = await quoteSourcesScorer.run({
|
|
95
|
+
input: "What is the capital of France?",
|
|
96
|
+
output: "Paris is the capital of France [1]. Source: [1] Wikipedia",
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
console.log(result.score); // 1
|
|
100
|
+
console.log(result.analyzeStepResult); // { hasSources: true, sources: ["Wikipedia"] }
|
|
101
|
+
```
|
|
102
|
+
|
|
58
103
|
#### Agent Type for Agent Evaluation
|
|
59
104
|
|
|
60
105
|
For type safety and compatibility with both live agent scoring and trace scoring, use `type: 'agent'` when creating scorers for agent evaluation. This allows you to use the same scorer for an agent and also use it to score traces:
|
|
@@ -295,7 +340,7 @@ Return your response in this format:
|
|
|
295
340
|
"This recipe is [gluten-free/contains gluten] because [explanation]"`;
|
|
296
341
|
|
|
297
342
|
export const glutenCheckerScorer = createScorer({
|
|
298
|
-
|
|
343
|
+
id: "gluten-checker",
|
|
299
344
|
description: "Check if the output contains any gluten",
|
|
300
345
|
judge: {
|
|
301
346
|
model: "openai/gpt-4.1-nano",
|
|
@@ -392,8 +437,6 @@ Provides human-readable explanations for the score using another LLM call.
|
|
|
392
437
|
|
|
393
438
|
The reason generation step creates explanations that help users understand why a particular score was assigned, using both the boolean result and the specific gluten sources identified by the analysis step.
|
|
394
439
|
|
|
395
|
-
````
|
|
396
|
-
|
|
397
440
|
## High gluten-free example
|
|
398
441
|
|
|
399
442
|
```typescript title="src/example-high-gluten-free.ts"
|
|
@@ -405,7 +448,7 @@ const result = await glutenCheckerScorer.run({
|
|
|
405
448
|
console.log('Score:', result.score);
|
|
406
449
|
console.log('Gluten sources:', result.analyzeStepResult.glutenSources);
|
|
407
450
|
console.log('Reason:', result.reason);
|
|
408
|
-
|
|
451
|
+
```
|
|
409
452
|
|
|
410
453
|
### High gluten-free output
|
|
411
454
|
|
|
@@ -688,6 +688,8 @@ Mastra provides a unified `createScorer` factory that allows you to define custo
|
|
|
688
688
|
|
|
689
689
|
Use the `createScorer` factory to define your scorer with a name, description, and optional judge configuration. Then chain step methods to build your evaluation pipeline. You must provide at least a `generateScore` step.
|
|
690
690
|
|
|
691
|
+
**Prompt object steps** are step configurations expressed as objects with `description` + `createPrompt` (and `outputSchema` for `preprocess`/`analyze`). These steps invoke the judge LLM. **Function steps** are plain functions and never call the judge.
|
|
692
|
+
|
|
691
693
|
```typescript
|
|
692
694
|
import { createScorer } from "@mastra/core/evals";
|
|
693
695
|
|
|
@@ -721,6 +723,10 @@ This function returns a scorer builder that you can chain step methods onto. See
|
|
|
721
723
|
|
|
722
724
|
## Judge Object
|
|
723
725
|
|
|
726
|
+
The judge only runs for steps defined as **prompt objects** (`preprocess`, `analyze`, `generateScore`, `generateReason` in prompt mode). If you use function steps only, the judge is never called and there is no LLM output to inspect. In that case, any score/reason must be produced by your functions.
|
|
727
|
+
|
|
728
|
+
When a prompt-object step runs, its structured LLM output is stored in the corresponding result field (`preprocessStepResult`, `analyzeStepResult`, or the value consumed by `calculateScore` in `generateScore`).
|
|
729
|
+
|
|
724
730
|
## Type Safety
|
|
725
731
|
|
|
726
732
|
You can specify input/output types when creating scorers for better type inference and IntelliSense support:
|
|
@@ -734,7 +740,7 @@ import { createScorer } from "@mastra/core/evals";
|
|
|
734
740
|
|
|
735
741
|
// Agent scorer with automatic typing
|
|
736
742
|
const agentScorer = createScorer({
|
|
737
|
-
|
|
743
|
+
id: "agent-response-quality",
|
|
738
744
|
description: "Evaluates agent responses",
|
|
739
745
|
type: "agent", // Automatically provides ScorerRunInputForAgent/ScorerRunOutputForAgent
|
|
740
746
|
})
|
|
@@ -761,7 +767,7 @@ type CustomInput = { query: string; context: string[] };
|
|
|
761
767
|
type CustomOutput = { answer: string; confidence: number };
|
|
762
768
|
|
|
763
769
|
const customScorer = createScorer<CustomInput, CustomOutput>({
|
|
764
|
-
|
|
770
|
+
id: "custom-scorer",
|
|
765
771
|
description: "Evaluates custom data",
|
|
766
772
|
}).generateScore(({ run }) => {
|
|
767
773
|
// run.input is typed as CustomInput
|
|
@@ -783,7 +789,7 @@ When you use `type: 'agent'`, your scorer is compatible for both adding directly
|
|
|
783
789
|
|
|
784
790
|
```typescript
|
|
785
791
|
const agentTraceScorer = createScorer({
|
|
786
|
-
|
|
792
|
+
id: "agent-trace-length",
|
|
787
793
|
description: "Evaluates agent response length",
|
|
788
794
|
type: "agent",
|
|
789
795
|
}).generateScore(({ run }) => {
|
|
@@ -1330,7 +1336,7 @@ For workflows, you can specify scorers at different levels using `WorkflowScorer
|
|
|
1330
1336
|
import { createScorer, runEvals } from "@mastra/core/evals";
|
|
1331
1337
|
|
|
1332
1338
|
const myScorer = createScorer({
|
|
1333
|
-
|
|
1339
|
+
id: "my-scorer",
|
|
1334
1340
|
description: "Check if Agent's response contains ground truth",
|
|
1335
1341
|
type: "agent",
|
|
1336
1342
|
}).generateScore(({ run }) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
> Learn about the Model Context Protocol (MCP), how to use third-party tools via MCPClient, connect to registries, and share your own tools using MCPServer.
|
|
2
2
|
|
|
3
3
|
> **Code References:**
|
|
4
|
-
- `Agent`: dist/agent/agent.d.ts → dist/chunk-
|
|
5
|
-
- `Mastra`: dist/mastra/index.d.ts → dist/chunk-
|
|
4
|
+
- `Agent`: dist/agent/agent.d.ts → dist/chunk-UVOQLIWL.js:16630
|
|
5
|
+
- `Mastra`: dist/mastra/index.d.ts → dist/chunk-IFPQ2MLB.js:24
|
|
6
6
|
|
|
7
7
|
# MCP Overview
|
|
8
8
|
|
|
@@ -50,9 +50,13 @@ export const testMcpClient = new MCPClient({
|
|
|
50
50
|
|
|
51
51
|
Visit [MCPClient](https://mastra.ai/reference/v1/tools/mcp-client) for a full list of configuration options.
|
|
52
52
|
|
|
53
|
+
> **Note:** Authentication
|
|
54
|
+
|
|
55
|
+
For connecting to OAuth-protected MCP servers, see the [OAuth Authentication](https://mastra.ai/reference/v1/tools/mcp-client#oauth-authentication) section.
|
|
56
|
+
|
|
53
57
|
## Using `MCPClient` with an agent
|
|
54
58
|
|
|
55
|
-
To use tools from an MCP server in an agent, import your `MCPClient` and call `.
|
|
59
|
+
To use tools from an MCP server in an agent, import your `MCPClient` and call `.listTools()` in the `tools` parameter. This loads from the defined MCP servers, making them available to the agent.
|
|
56
60
|
|
|
57
61
|
```typescript {3,15} title="src/mastra/agents/test-agent.ts"
|
|
58
62
|
import { Agent } from "@mastra/core/agent";
|
|
@@ -60,6 +64,7 @@ import { Agent } from "@mastra/core/agent";
|
|
|
60
64
|
import { testMcpClient } from "../mcp/test-mcp-client";
|
|
61
65
|
|
|
62
66
|
export const testAgent = new Agent({
|
|
67
|
+
id: "test-agent",
|
|
63
68
|
name: "Test Agent",
|
|
64
69
|
description: "You are a helpful AI assistant",
|
|
65
70
|
instructions: `
|
|
@@ -69,7 +74,7 @@ export const testAgent = new Agent({
|
|
|
69
74
|
|
|
70
75
|
Answer questions using the information you find using the MCP Servers.`,
|
|
71
76
|
model: "openai/gpt-5.1",
|
|
72
|
-
tools: await testMcpClient.
|
|
77
|
+
tools: await testMcpClient.listTools(),
|
|
73
78
|
});
|
|
74
79
|
```
|
|
75
80
|
|
|
@@ -102,6 +107,10 @@ export const testMcpServer = new MCPServer({
|
|
|
102
107
|
|
|
103
108
|
Visit [MCPServer](https://mastra.ai/reference/v1/tools/mcp-server) for a full list of configuration options.
|
|
104
109
|
|
|
110
|
+
> **Note:** Authentication
|
|
111
|
+
|
|
112
|
+
To protect your MCP server with OAuth, see the [OAuth Protection](https://mastra.ai/reference/v1/tools/mcp-server#oauth-protection) section.
|
|
113
|
+
|
|
105
114
|
## Registering an `MCPServer`
|
|
106
115
|
|
|
107
116
|
To make an MCP server available to other systems or agents that support the protocol, register it in the main `Mastra` instance using `mcpServers`.
|
|
@@ -120,20 +129,20 @@ export const mastra = new Mastra({
|
|
|
120
129
|
|
|
121
130
|
`MCPClient` offers two approaches to retrieving tools from connected servers, suitable for different application architectures:
|
|
122
131
|
|
|
123
|
-
| Feature | Static Configuration (`await mcp.
|
|
124
|
-
| :---------------- |
|
|
125
|
-
| **Use Case** | Single-user, static config (e.g., CLI tool)
|
|
126
|
-
| **Configuration** | Fixed at agent initialization
|
|
127
|
-
| **Credentials** | Shared across all uses
|
|
128
|
-
| **Agent Setup** | Tools added in `Agent` constructor
|
|
132
|
+
| Feature | Static Configuration (`await mcp.listTools()`) | Dynamic Configuration (`await mcp.listToolsets()`) |
|
|
133
|
+
| :---------------- | :--------------------------------------------- | :--------------------------------------------------- |
|
|
134
|
+
| **Use Case** | Single-user, static config (e.g., CLI tool) | Multi-user, dynamic config (e.g., SaaS app) |
|
|
135
|
+
| **Configuration** | Fixed at agent initialization | Per-request, dynamic |
|
|
136
|
+
| **Credentials** | Shared across all uses | Can vary per user/request |
|
|
137
|
+
| **Agent Setup** | Tools added in `Agent` constructor | Tools passed in `.generate()` or `.stream()` options |
|
|
129
138
|
|
|
130
139
|
### Static tools
|
|
131
140
|
|
|
132
|
-
Use the `.
|
|
141
|
+
Use the `.listTools()` method to fetch tools from all configured MCP servers. This is suitable when configuration (such as API keys) is static and consistent across users or requests. Call it once and pass the result to the `tools` property when defining your agent.
|
|
133
142
|
|
|
134
143
|
> **Note:**
|
|
135
144
|
|
|
136
|
-
Visit [
|
|
145
|
+
Visit [listTools()](https://mastra.ai/reference/v1/tools/mcp-client#listtools) for more information.
|
|
137
146
|
|
|
138
147
|
```typescript {6} title="src/mastra/agents/test-agent.ts"
|
|
139
148
|
import { Agent } from "@mastra/core/agent";
|
|
@@ -141,13 +150,14 @@ import { Agent } from "@mastra/core/agent";
|
|
|
141
150
|
import { testMcpClient } from "../mcp/test-mcp-client";
|
|
142
151
|
|
|
143
152
|
export const testAgent = new Agent({
|
|
144
|
-
|
|
153
|
+
id: "test-agent",
|
|
154
|
+
tools: await testMcpClient.listTools(),
|
|
145
155
|
});
|
|
146
156
|
```
|
|
147
157
|
|
|
148
158
|
### Dynamic tools
|
|
149
159
|
|
|
150
|
-
Use the `.
|
|
160
|
+
Use the `.listToolsets()` method when tool configuration may vary by request or user, such as in a multi-tenant system where each user provides their own API key. This method returns toolsets that can be passed to the `toolsets` option in the agent's `.generate()` or `.stream()` calls.
|
|
151
161
|
|
|
152
162
|
```typescript {5-16,21}
|
|
153
163
|
import { MCPClient } from "@mastra/mcp";
|
|
@@ -170,7 +180,7 @@ async function handleRequest(userPrompt: string, userApiKey: string) {
|
|
|
170
180
|
const agent = mastra.getAgent("testAgent");
|
|
171
181
|
|
|
172
182
|
const response = await agent.generate(userPrompt, {
|
|
173
|
-
toolsets: await userMcp.
|
|
183
|
+
toolsets: await userMcp.listToolsets(),
|
|
174
184
|
});
|
|
175
185
|
|
|
176
186
|
await userMcp.disconnect();
|
|
@@ -183,7 +193,7 @@ async function handleRequest(userPrompt: string, userApiKey: string) {
|
|
|
183
193
|
|
|
184
194
|
> **Note:**
|
|
185
195
|
|
|
186
|
-
Visit [
|
|
196
|
+
Visit [listToolsets()](https://mastra.ai/reference/v1/tools/mcp-client#listtoolsets) for more information.
|
|
187
197
|
|
|
188
198
|
## Connecting to an MCP registry
|
|
189
199
|
|
|
@@ -104,8 +104,8 @@ const mcp = new MCPClient({
|
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
// You can then get tools or toolsets from this configuration to use in your agent
|
|
107
|
-
const tools = await mcp.
|
|
108
|
-
const toolsets = await mcp.
|
|
107
|
+
const tools = await mcp.listTools();
|
|
108
|
+
const toolsets = await mcp.listToolsets();
|
|
109
109
|
```
|
|
110
110
|
|
|
111
111
|
Note: If you published without an organization scope, the `args` might just be `["-y", "your-package-name@latest"]`.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
> Learn how Mastra
|
|
2
2
|
|
|
3
3
|
> **Code References:**
|
|
4
|
-
- `Mastra`: dist/mastra/index.d.ts → dist/chunk-
|
|
5
|
-
- `Agent`: dist/agent/agent.d.ts → dist/chunk-
|
|
4
|
+
- `Mastra`: dist/mastra/index.d.ts → dist/chunk-IFPQ2MLB.js:24
|
|
5
|
+
- `Agent`: dist/agent/agent.d.ts → dist/chunk-UVOQLIWL.js:16630
|
|
6
6
|
|
|
7
7
|
# Memory
|
|
8
8
|
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
For Mastra to remember previous interactions, you must configure a storage adapter. Mastra is designed to work with your preferred database provider - choose from the [supported providers](#supported-providers) and pass it to your Mastra instance.
|
|
6
6
|
|
|
7
|
-
```typescript
|
|
7
|
+
```typescript title="src/mastra/index.ts"
|
|
8
8
|
import { Mastra } from "@mastra/core";
|
|
9
9
|
import { LibSQLStore } from "@mastra/libsql";
|
|
10
10
|
|
|
11
|
-
const mastra = new Mastra({
|
|
11
|
+
export const mastra = new Mastra({
|
|
12
12
|
storage: new LibSQLStore({
|
|
13
13
|
id: 'mastra-storage',
|
|
14
14
|
url: "file:./mastra.db",
|
|
@@ -17,7 +17,7 @@ const mastra = new Mastra({
|
|
|
17
17
|
```
|
|
18
18
|
On first interaction, Mastra automatically creates the necessary tables following the [core schema](https://mastra.ai/reference/v1/storage/overview#core-schema). This includes tables for messages, threads, resources, workflows, traces, and evaluation datasets.
|
|
19
19
|
|
|
20
|
-
## Supported
|
|
20
|
+
## Supported providers
|
|
21
21
|
|
|
22
22
|
Each provider page includes installation instructions, configuration parameters, and usage examples:
|
|
23
23
|
|
|
@@ -35,19 +35,19 @@ Each provider page includes installation instructions, configuration parameters,
|
|
|
35
35
|
> **Note:**
|
|
36
36
|
libSQL is the easiest way to get started because it doesn’t require running a separate database server
|
|
37
37
|
|
|
38
|
-
## Configuration
|
|
38
|
+
## Configuration scope
|
|
39
39
|
|
|
40
40
|
You can configure storage at two different scopes:
|
|
41
41
|
|
|
42
42
|
### Instance-level storage
|
|
43
43
|
|
|
44
|
-
Add storage to your Mastra instance so all agents share the same memory provider:
|
|
44
|
+
Add storage to your Mastra instance so all agents, workflows, observability traces and scores share the same memory provider:
|
|
45
45
|
|
|
46
|
-
```typescript
|
|
46
|
+
```typescript
|
|
47
47
|
import { Mastra } from "@mastra/core";
|
|
48
48
|
import { PostgresStore } from "@mastra/pg";
|
|
49
49
|
|
|
50
|
-
const mastra = new Mastra({
|
|
50
|
+
export const mastra = new Mastra({
|
|
51
51
|
storage: new PostgresStore({
|
|
52
52
|
id: 'mastra-storage',
|
|
53
53
|
connectionString: process.env.DATABASE_URL,
|
|
@@ -55,20 +55,55 @@ const mastra = new Mastra({
|
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
// All agents automatically use this storage
|
|
58
|
-
const agent1 = new Agent({ memory: new Memory() });
|
|
59
|
-
const agent2 = new Agent({ memory: new Memory() });
|
|
58
|
+
const agent1 = new Agent({ id: "agent-1", memory: new Memory() });
|
|
59
|
+
const agent2 = new Agent({ id: "agent-2", memory: new Memory() });
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This is useful when all primitives share the same storage backend and have similar performance, scaling, and operational requirements.
|
|
63
|
+
|
|
64
|
+
#### Composite storage
|
|
65
|
+
|
|
66
|
+
Add storage to your Mastra instance using `MastraStorage` and configure individual storage domains to use different storage providers.
|
|
67
|
+
|
|
68
|
+
```typescript title="src/mastra/index.ts"
|
|
69
|
+
import { Mastra } from "@mastra/core";
|
|
70
|
+
import { MastraStorage } from "@mastra/core/storage";
|
|
71
|
+
import { MemoryLibSQL } from "@mastra/libsql";
|
|
72
|
+
import { WorkflowsPG } from "@mastra/pg";
|
|
73
|
+
import { ObservabilityStorageClickhouse } from "@mastra/clickhouse";
|
|
74
|
+
|
|
75
|
+
export const mastra = new Mastra({
|
|
76
|
+
storage: new MastraStorage({
|
|
77
|
+
id: "composite",
|
|
78
|
+
domains: {
|
|
79
|
+
memory: new MemoryLibSQL({ url: "file:./memory.db" }),
|
|
80
|
+
workflows: new WorkflowsPG({ connectionString: process.env.DATABASE_URL }),
|
|
81
|
+
observability: new ObservabilityStorageClickhouse({
|
|
82
|
+
url: process.env.CLICKHOUSE_URL,
|
|
83
|
+
username: process.env.CLICKHOUSE_USERNAME,
|
|
84
|
+
password: process.env.CLICKHOUSE_PASSWORD,
|
|
85
|
+
}),
|
|
86
|
+
},
|
|
87
|
+
}),
|
|
88
|
+
});
|
|
60
89
|
```
|
|
61
90
|
|
|
91
|
+
This is useful when different types of data have different performance or operational requirements, such as low-latency storage for memory, durable storage for workflows, and high-throughput storage for observability.
|
|
92
|
+
|
|
93
|
+
> **Note:**
|
|
94
|
+
See [Storage Domains](https://mastra.ai/reference/v1/storage/composite#storage-domains) for more information.
|
|
95
|
+
|
|
62
96
|
### Agent-level storage
|
|
63
97
|
|
|
64
|
-
Add storage to a specific agent when you need data boundaries or compliance requirements:
|
|
98
|
+
Agent-level storage overrides storage configured at the instance-level. Add storage to a specific agent when you need data boundaries or compliance requirements:
|
|
65
99
|
|
|
66
|
-
```typescript
|
|
100
|
+
```typescript title="src/mastra/agents/memory-agent.ts"
|
|
67
101
|
import { Agent } from "@mastra/core/agent";
|
|
68
102
|
import { Memory } from "@mastra/memory";
|
|
69
103
|
import { PostgresStore } from "@mastra/pg";
|
|
70
104
|
|
|
71
|
-
const agent = new Agent({
|
|
105
|
+
export const agent = new Agent({
|
|
106
|
+
id: "agent",
|
|
72
107
|
memory: new Memory({
|
|
73
108
|
storage: new PostgresStore({
|
|
74
109
|
id: 'agent-storage',
|
|
@@ -80,7 +115,7 @@ const agent = new Agent({
|
|
|
80
115
|
|
|
81
116
|
This is useful when different agents need to store data in separate databases for security, compliance, or organizational reasons.
|
|
82
117
|
|
|
83
|
-
## Threads and
|
|
118
|
+
## Threads and resources
|
|
84
119
|
|
|
85
120
|
Mastra organizes memory into threads using two identifiers:
|
|
86
121
|
|
|
@@ -89,7 +124,7 @@ Mastra organizes memory into threads using two identifiers:
|
|
|
89
124
|
|
|
90
125
|
Both identifiers are required for agents to store and recall information:
|
|
91
126
|
|
|
92
|
-
```typescript
|
|
127
|
+
```typescript
|
|
93
128
|
const stream = await agent.stream("message for agent", {
|
|
94
129
|
memory: {
|
|
95
130
|
thread: "convo_123",
|
|
@@ -107,8 +142,9 @@ Mastra can automatically generate descriptive thread titles based on the user's
|
|
|
107
142
|
|
|
108
143
|
Use this option when implementing a ChatGPT-style chat interface to render a title alongside each thread in the conversation list (for example, in a sidebar) derived from the thread’s initial user message.
|
|
109
144
|
|
|
110
|
-
```typescript
|
|
145
|
+
```typescript
|
|
111
146
|
export const testAgent = new Agent({
|
|
147
|
+
id: "test-agent",
|
|
112
148
|
memory: new Memory({
|
|
113
149
|
options: {
|
|
114
150
|
generateTitle: true,
|
|
@@ -123,13 +159,12 @@ To optimize cost or behavior, provide a smaller `model` and custom `instructions
|
|
|
123
159
|
|
|
124
160
|
```typescript
|
|
125
161
|
export const testAgent = new Agent({
|
|
162
|
+
id: "test-agent",
|
|
126
163
|
memory: new Memory({
|
|
127
164
|
options: {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
instructions: "Generate a concise title based on the user's first message",
|
|
132
|
-
},
|
|
165
|
+
generateTitle: {
|
|
166
|
+
model: "openai/gpt-4o-mini",
|
|
167
|
+
instructions: "Generate a concise title based on the user's first message",
|
|
133
168
|
},
|
|
134
169
|
},
|
|
135
170
|
}),
|
|
@@ -142,7 +177,7 @@ Semantic recall uses vector embeddings to retrieve relevant past messages based
|
|
|
142
177
|
|
|
143
178
|
The vector database doesn't have to be the same as your storage provider. For example, you might use PostgreSQL for storage and Pinecone for vectors:
|
|
144
179
|
|
|
145
|
-
```typescript
|
|
180
|
+
```typescript
|
|
146
181
|
import { Mastra } from "@mastra/core";
|
|
147
182
|
import { Agent } from "@mastra/core/agent";
|
|
148
183
|
import { Memory } from "@mastra/memory";
|
|
@@ -150,7 +185,7 @@ import { PostgresStore } from "@mastra/pg";
|
|
|
150
185
|
import { PineconeVector } from "@mastra/pinecone";
|
|
151
186
|
|
|
152
187
|
// Instance-level vector configuration
|
|
153
|
-
const mastra = new Mastra({
|
|
188
|
+
export const mastra = new Mastra({
|
|
154
189
|
storage: new PostgresStore({
|
|
155
190
|
id: 'mastra-storage',
|
|
156
191
|
connectionString: process.env.DATABASE_URL,
|
|
@@ -158,13 +193,12 @@ const mastra = new Mastra({
|
|
|
158
193
|
});
|
|
159
194
|
|
|
160
195
|
// Agent-level vector configuration
|
|
161
|
-
const agent = new Agent({
|
|
196
|
+
export const agent = new Agent({
|
|
197
|
+
id: "agent",
|
|
162
198
|
memory: new Memory({
|
|
163
199
|
vector: new PineconeVector({
|
|
164
200
|
id: 'agent-vector',
|
|
165
201
|
apiKey: process.env.PINECONE_API_KEY,
|
|
166
|
-
environment: process.env.PINECONE_ENVIRONMENT,
|
|
167
|
-
indexName: 'agent-embeddings',
|
|
168
202
|
}),
|
|
169
203
|
options: {
|
|
170
204
|
semanticRecall: {
|