@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,361 @@
|
|
|
1
1
|
# @mastra/core
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.22
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- Refactor workflow and tool types to remove Zod-specific constraints ([#11814](https://github.com/mastra-ai/mastra/pull/11814))
|
|
8
|
+
|
|
9
|
+
Removed Zod-specific type constraints across all workflow implementations and tool types, replacing them with generic types. This ensures type consistency across default, evented, and inngest workflows while preparing for Zod v4 migration.
|
|
10
|
+
|
|
11
|
+
**Workflow Changes:**
|
|
12
|
+
- Removed `z.ZodObject<any>` and `z.ZodType<any>` constraints from all workflow generic types
|
|
13
|
+
- Updated method signatures to use `TInput` and `TState` directly instead of `z.infer<TInput>` and `z.infer<TState>`
|
|
14
|
+
- Aligned conditional types across all workflow implementations using `TInput extends unknown` pattern
|
|
15
|
+
- Fixed `TSteps` generic to properly use `TEngineType` instead of `any`
|
|
16
|
+
|
|
17
|
+
**Tool Changes:**
|
|
18
|
+
- Removed Zod schema constraints from `ToolExecutionContext` and related interfaces
|
|
19
|
+
- Simplified type parameters from `TSuspendSchema extends ZodLikeSchema` to `TSuspend` and `TResume`
|
|
20
|
+
- Updated tool execution context types to use generic types
|
|
21
|
+
|
|
22
|
+
**Type Utilities:**
|
|
23
|
+
- Refactored type helpers to work with generic schemas instead of Zod-specific types
|
|
24
|
+
- Updated type extraction utilities for better compatibility
|
|
25
|
+
|
|
26
|
+
This change maintains backward compatibility while improving type consistency and preparing for Zod v4 support across all affected packages.
|
|
27
|
+
|
|
28
|
+
- **Breaking Change**: Convert OUTPUT generic from `OutputSchema` constraint to plain generic ([#11741](https://github.com/mastra-ai/mastra/pull/11741))
|
|
29
|
+
|
|
30
|
+
This change removes the direct dependency on Zod typings in the public API by converting all `OUTPUT extends OutputSchema` generic constraints to plain `OUTPUT` generics throughout the codebase. This is preparation for moving to a standard schema approach.
|
|
31
|
+
- All generic type parameters previously constrained to `OutputSchema` (e.g., `<OUTPUT extends OutputSchema = undefined>`) are now plain generics with defaults (e.g., `<OUTPUT = undefined>`)
|
|
32
|
+
- Affects all public APIs including `Agent`, `MastraModelOutput`, `AgentExecutionOptions`, and stream/generate methods
|
|
33
|
+
- `InferSchemaOutput<OUTPUT>` replaced with `OUTPUT` throughout
|
|
34
|
+
- `PartialSchemaOutput<OUTPUT>` replaced with `Partial<OUTPUT>`
|
|
35
|
+
- Schema fields now use `NonNullable<OutputSchema<OUTPUT>>` instead of `OUTPUT` directly
|
|
36
|
+
- Added `FullOutput<OUTPUT>` type representing complete output with all fields
|
|
37
|
+
- Added `AgentExecutionOptionsBase<OUTPUT>` type
|
|
38
|
+
- `getFullOutput()` method now returns `Promise<FullOutput<OUTPUT>>`
|
|
39
|
+
- `Agent` class now generic: `Agent<TAgentId, TTools, TOutput>`
|
|
40
|
+
- `agent.generate()` and `agent.stream()` methods have updated signatures
|
|
41
|
+
- `MastraModelOutput<OUTPUT>` no longer requires `OutputSchema` constraint
|
|
42
|
+
- Network route and streaming APIs updated to use plain OUTPUT generic
|
|
43
|
+
|
|
44
|
+
**Before:**
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
const output = await agent.generate<z.ZodType>({
|
|
48
|
+
messages: [...],
|
|
49
|
+
structuredOutput: { schema: mySchema }
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
**After:**
|
|
53
|
+
const output = await agent.generate<z.infer<typeof mySchema>>({
|
|
54
|
+
messages: [...],
|
|
55
|
+
structuredOutput: { schema: mySchema }
|
|
56
|
+
});
|
|
57
|
+
// Or rely on type inference:
|
|
58
|
+
const output = await agent.generate({
|
|
59
|
+
messages: [...],
|
|
60
|
+
structuredOutput: { schema: mySchema }
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Minor Changes
|
|
66
|
+
|
|
67
|
+
- Add context parameter to `idGenerator` to enable deterministic ID generation based on context. ([#10964](https://github.com/mastra-ai/mastra/pull/10964))
|
|
68
|
+
|
|
69
|
+
The `idGenerator` function now receives optional context about what type of ID is being generated and from which Mastra primitive. This allows generating IDs that can be shared with external databases.
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const mastra = new Mastra({
|
|
73
|
+
idGenerator: context => {
|
|
74
|
+
// context.idType: 'thread' | 'message' | 'run' | 'step' | 'generic'
|
|
75
|
+
// context.source: 'agent' | 'workflow' | 'memory'
|
|
76
|
+
// context.entityId: the agent/workflow id
|
|
77
|
+
// context.threadId, context.resourceId, context.role, context.stepType
|
|
78
|
+
|
|
79
|
+
if (context?.idType === 'message' && context?.threadId) {
|
|
80
|
+
return `msg-${context.threadId}-${Date.now()}`;
|
|
81
|
+
}
|
|
82
|
+
if (context?.idType === 'run' && context?.source === 'agent') {
|
|
83
|
+
return `run-${context.entityId}-${Date.now()}`;
|
|
84
|
+
}
|
|
85
|
+
return crypto.randomUUID();
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Existing `idGenerator` functions without parameters continue to work since the context is optional.
|
|
91
|
+
|
|
92
|
+
Fixes #8131
|
|
93
|
+
|
|
94
|
+
- Add `hideInput` and `hideOutput` options to `TracingOptions` for protecting sensitive data in traces. ([#11969](https://github.com/mastra-ai/mastra/pull/11969))
|
|
95
|
+
|
|
96
|
+
When set to `true`, these options hide input/output data from all spans in a trace, including child spans. This is useful for protecting sensitive information from being logged to observability platforms.
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
const agent = mastra.getAgent('myAgent');
|
|
100
|
+
await agent.generate('Process this sensitive data', {
|
|
101
|
+
tracingOptions: {
|
|
102
|
+
hideInput: true, // Input will be hidden from all spans
|
|
103
|
+
hideOutput: true, // Output will be hidden from all spans
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The options can be used independently (hide only input or only output) or together. The settings are propagated to all child spans via `TraceState`, ensuring consistent behavior across the entire trace.
|
|
109
|
+
|
|
110
|
+
Fixes #10888
|
|
111
|
+
|
|
112
|
+
- Removed the deprecated `AISDKV5OutputStream` class from the public API. ([#11845](https://github.com/mastra-ai/mastra/pull/11845))
|
|
113
|
+
|
|
114
|
+
**What changed:** The `AISDKV5OutputStream` class is no longer exported from `@mastra/core`. This class was previously used with the `format: 'aisdk'` option, which has already been removed from `.stream()` and `.generate()` methods.
|
|
115
|
+
|
|
116
|
+
**Who is affected:** Only users who were directly importing `AISDKV5OutputStream` from `@mastra/core`. If you were using the standard `.stream()` or `.generate()` methods without the `format` option, no changes are needed.
|
|
117
|
+
|
|
118
|
+
**Migration:** If you were importing this class directly, switch to using `MastraModelOutput` which provides the same streaming functionality:
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
// Before
|
|
122
|
+
import { AISDKV5OutputStream } from '@mastra/core';
|
|
123
|
+
|
|
124
|
+
// After
|
|
125
|
+
import { MastraModelOutput } from '@mastra/core';
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
- Changed JSON columns from TEXT to JSONB in `mastra_threads` and `mastra_workflow_snapshot` tables. ([#11853](https://github.com/mastra-ai/mastra/pull/11853))
|
|
129
|
+
|
|
130
|
+
**Why this change?**
|
|
131
|
+
|
|
132
|
+
These were the last remaining columns storing JSON as TEXT. This change aligns them with other tables that already use JSONB, enabling native JSON operators and improved performance. See [#8978](https://github.com/mastra-ai/mastra/issues/8978) for details.
|
|
133
|
+
|
|
134
|
+
**Columns Changed:**
|
|
135
|
+
- `mastra_threads.metadata` - Thread metadata
|
|
136
|
+
- `mastra_workflow_snapshot.snapshot` - Workflow run state
|
|
137
|
+
|
|
138
|
+
**PostgreSQL**
|
|
139
|
+
|
|
140
|
+
Migration Required - PostgreSQL enforces column types, so existing tables must be migrated. Note: Migration will fail if existing column values contain invalid JSON.
|
|
141
|
+
|
|
142
|
+
```sql
|
|
143
|
+
ALTER TABLE mastra_threads
|
|
144
|
+
ALTER COLUMN metadata TYPE jsonb
|
|
145
|
+
USING metadata::jsonb;
|
|
146
|
+
|
|
147
|
+
ALTER TABLE mastra_workflow_snapshot
|
|
148
|
+
ALTER COLUMN snapshot TYPE jsonb
|
|
149
|
+
USING snapshot::jsonb;
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**LibSQL**
|
|
153
|
+
|
|
154
|
+
No Migration Required - LibSQL now uses native SQLite JSONB format (added in SQLite 3.45) for ~3x performance improvement on JSON operations. The changes are fully backwards compatible:
|
|
155
|
+
- Existing TEXT JSON data continues to work
|
|
156
|
+
- New data is stored in binary JSONB format
|
|
157
|
+
- Both formats can coexist in the same table
|
|
158
|
+
- All JSON functions (`json_extract`, etc.) work on both formats
|
|
159
|
+
|
|
160
|
+
New installations automatically use JSONB. Existing applications continue to work without any changes.
|
|
161
|
+
|
|
162
|
+
- Added `TrackingExporter` base class with improved handling for: ([#11870](https://github.com/mastra-ai/mastra/pull/11870))
|
|
163
|
+
- **Out-of-order span processing**: Spans that arrive before their parents are now queued and processed once dependencies are available
|
|
164
|
+
- **Delayed cleanup**: Trace data is retained briefly after spans end to handle late-arriving updates
|
|
165
|
+
- **Memory management**: Configurable limits on pending and total traces to prevent memory leaks
|
|
166
|
+
|
|
167
|
+
New configuration options on `TrackingExporterConfig`:
|
|
168
|
+
- `earlyQueueMaxAttempts` - Max retry attempts for queued events (default: 5)
|
|
169
|
+
- `earlyQueueTTLMs` - TTL for queued events in ms (default: 30000)
|
|
170
|
+
- `traceCleanupDelayMs` - Delay before cleaning up completed traces (default: 30000)
|
|
171
|
+
- `maxPendingCleanupTraces` - Soft cap on traces awaiting cleanup (default: 100)
|
|
172
|
+
- `maxTotalTraces` - Hard cap on total traces (default: 500)
|
|
173
|
+
|
|
174
|
+
Updated @mastra/braintrust, @mastra/langfuse, @mastra/langsmith, @mastra/posthog to use the new TrackingExporter
|
|
175
|
+
|
|
176
|
+
- Add MCP tool annotations and metadata support to `ToolAction` and `Tool` ([#11841](https://github.com/mastra-ai/mastra/pull/11841))
|
|
177
|
+
|
|
178
|
+
Tools can now surface UI hints like `title`, `readOnlyHint`, `destructiveHint`, `idempotentHint`, and `openWorldHint` via the `mcp.annotations` field, and pass arbitrary metadata to MCP clients via `mcp._meta`. These MCP-specific properties are grouped under the `mcp` property to clearly indicate they only apply when tools are exposed via MCP.
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
import { createTool } from '@mastra/core/tools';
|
|
182
|
+
|
|
183
|
+
const myTool = createTool({
|
|
184
|
+
id: 'weather',
|
|
185
|
+
description: 'Get weather for a location',
|
|
186
|
+
mcp: {
|
|
187
|
+
annotations: {
|
|
188
|
+
title: 'Weather Lookup',
|
|
189
|
+
readOnlyHint: true,
|
|
190
|
+
destructiveHint: false,
|
|
191
|
+
},
|
|
192
|
+
_meta: { version: '1.0.0' },
|
|
193
|
+
},
|
|
194
|
+
execute: async ({ location }) => fetchWeather(location),
|
|
195
|
+
});
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Patch Changes
|
|
199
|
+
|
|
200
|
+
- Fix dimension mismatch error when switching embedders in SemanticRecall. The processor now properly validates vector index dimensions when an index already exists, preventing runtime errors when switching between embedders with different dimensions (e.g., fastembed 384 dims → OpenAI 1536 dims). ([#11893](https://github.com/mastra-ai/mastra/pull/11893))
|
|
201
|
+
|
|
202
|
+
- Removes the deprecated `threadId` and `resourceId` options from `AgentExecutionOptions`. These have been deprecated for months in favour of the `memory` option. ([#11897](https://github.com/mastra-ai/mastra/pull/11897))
|
|
203
|
+
|
|
204
|
+
### Breaking Changes
|
|
205
|
+
|
|
206
|
+
#### `@mastra/core`
|
|
207
|
+
|
|
208
|
+
The `threadId` and `resourceId` options have been removed from `agent.generate()` and `agent.stream()`. Use the `memory` option instead:
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
// Before
|
|
212
|
+
await agent.stream('Hello', {
|
|
213
|
+
threadId: 'thread-123',
|
|
214
|
+
resourceId: 'user-456',
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// After
|
|
218
|
+
await agent.stream('Hello', {
|
|
219
|
+
memory: {
|
|
220
|
+
thread: 'thread-123',
|
|
221
|
+
resource: 'user-456',
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
#### `@mastra/server`
|
|
227
|
+
|
|
228
|
+
The `threadId`, `resourceId`, and `resourceid` fields have been removed from the main agent execution body schema. The server now expects the `memory` option format in request bodies. Legacy routes (`/api/agents/:agentId/generate-legacy` and `/api/agents/:agentId/stream-legacy`) continue to support the deprecated fields.
|
|
229
|
+
|
|
230
|
+
#### `@mastra/react`
|
|
231
|
+
|
|
232
|
+
The `useChat` hook now internally converts `threadId` to the `memory` option format when making API calls. No changes needed in component code - the hook handles the conversion automatically.
|
|
233
|
+
|
|
234
|
+
#### `@mastra/client-js`
|
|
235
|
+
|
|
236
|
+
When using the client SDK agent methods, use the `memory` option instead of `threadId`/`resourceId`:
|
|
237
|
+
|
|
238
|
+
```ts
|
|
239
|
+
const agent = client.getAgent('my-agent');
|
|
240
|
+
|
|
241
|
+
// Before
|
|
242
|
+
await agent.generate({
|
|
243
|
+
messages: [...],
|
|
244
|
+
threadId: 'thread-123',
|
|
245
|
+
resourceId: 'user-456',
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// After
|
|
249
|
+
await agent.generate({
|
|
250
|
+
messages: [...],
|
|
251
|
+
memory: {
|
|
252
|
+
thread: 'thread-123',
|
|
253
|
+
resource: 'user-456',
|
|
254
|
+
},
|
|
255
|
+
});
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
- Add human-in-the-loop (HITL) support to agent networks ([#11678](https://github.com/mastra-ai/mastra/pull/11678))
|
|
259
|
+
- Add suspend/resume capabilities to agent network
|
|
260
|
+
- Enable auto-resume for suspended network execution via `autoResumeSuspendedTools`
|
|
261
|
+
|
|
262
|
+
`agent.resumeNetwork`, `agent.approveNetworkToolCall`, `agent.declineNetworkToolCall`
|
|
263
|
+
|
|
264
|
+
- Fixed AI SDK v6 provider tools (like `openai.tools.webSearch()`) not being invoked correctly. These tools are now properly recognized and executed instead of causing failures or hallucinated tool calls. ([#11946](https://github.com/mastra-ai/mastra/pull/11946))
|
|
265
|
+
|
|
266
|
+
Resolves `#11781`.
|
|
267
|
+
|
|
268
|
+
- Fixed `TokenLimiterProcessor` not filtering memory messages when limiting tokens. ([#11941](https://github.com/mastra-ai/mastra/pull/11941))
|
|
269
|
+
|
|
270
|
+
Previously, the processor only received the latest user input messages, missing the conversation history from memory. This meant token limiting couldn't filter historical messages to fit within the context window.
|
|
271
|
+
|
|
272
|
+
The processor now correctly:
|
|
273
|
+
- Accesses all messages (memory + input) when calculating token budgets
|
|
274
|
+
- Accounts for system messages in the token budget
|
|
275
|
+
- Filters older messages to prioritize recent conversation context
|
|
276
|
+
|
|
277
|
+
Fixes #11902
|
|
278
|
+
|
|
279
|
+
- Fix crash in `mastraDBMessageToAIV4UIMessage` when `content.parts` is undefined or null. ([#11550](https://github.com/mastra-ai/mastra/pull/11550))
|
|
280
|
+
|
|
281
|
+
This resolves an issue where `ModerationProcessor` (and other code paths using `MessageList.get.*.ui()`) would throw `TypeError: Cannot read properties of undefined (reading 'length')` when processing messages with missing `parts` array. This commonly occurred when using AI SDK v4 (LanguageModelV1) models with input/output processors.
|
|
282
|
+
|
|
283
|
+
The fix adds null coalescing (`?? []`) to safely handle undefined/null `parts` in the message conversion method.
|
|
284
|
+
|
|
285
|
+
- Improved TypeScript type inference for workflow steps. ([#11953](https://github.com/mastra-ai/mastra/pull/11953))
|
|
286
|
+
|
|
287
|
+
**What changed:**
|
|
288
|
+
- Step input/output type mismatches are now caught at compile time when chaining steps with `.then()`
|
|
289
|
+
- The `execute` function now properly infers types from `inputSchema`, `outputSchema`, `stateSchema`, and other schema parameters
|
|
290
|
+
- Clearer error messages when step types don't match workflow requirements
|
|
291
|
+
|
|
292
|
+
**Why:**
|
|
293
|
+
Previously, type errors in workflow step chains would only surface at runtime. Now TypeScript validates that each step's input requirements are satisfied by the previous step's output, helping you catch integration issues earlier in development.
|
|
294
|
+
|
|
295
|
+
- Add `response` to finish chunk payload for output processor metadata access ([#11549](https://github.com/mastra-ai/mastra/pull/11549))
|
|
296
|
+
|
|
297
|
+
When using output processors with streaming, metadata added via `processOutputResult` is now accessible in the finish chunk's `payload.response.uiMessages`. This allows clients consuming streams over HTTP (e.g., via `/stream/ui`) to access processor-added metadata.
|
|
298
|
+
|
|
299
|
+
```typescript
|
|
300
|
+
for await (const chunk of stream.fullStream) {
|
|
301
|
+
if (chunk.type === 'finish') {
|
|
302
|
+
const uiMessages = chunk.payload.response?.uiMessages;
|
|
303
|
+
const metadata = uiMessages?.find(m => m.role === 'assistant')?.metadata;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
Fixes #11454
|
|
309
|
+
|
|
310
|
+
- Fixed formatting of model_step, model_chunk, and tool_call spans in Arize Exporter. ([#11922](https://github.com/mastra-ai/mastra/pull/11922))
|
|
311
|
+
|
|
312
|
+
Also removed `tools` output from `model_step` spans for all exporters.
|
|
313
|
+
|
|
314
|
+
- Improved tracing by filtering infrastructure chunks from model streams and adding success attribute to tool spans. ([#11943](https://github.com/mastra-ai/mastra/pull/11943))
|
|
315
|
+
|
|
316
|
+
Added generic input/output attribute mapping for additional span types in Arize exporter.
|
|
317
|
+
|
|
318
|
+
- Fix generateTitle for pre-created threads ([#11771](https://github.com/mastra-ai/mastra/pull/11771))
|
|
319
|
+
- Title generation now works automatically for pre-created threads (via client SDK)
|
|
320
|
+
- When `generateTitle: true` is configured, titles are generated on the first user message
|
|
321
|
+
- Detection is based on message history: if no existing user messages in memory, it's the first message
|
|
322
|
+
- No metadata flags required - works seamlessly with optimistic UI patterns
|
|
323
|
+
|
|
324
|
+
Fixes #11757
|
|
325
|
+
|
|
326
|
+
- Real-time span export for Inngest workflow engine ([#11973](https://github.com/mastra-ai/mastra/pull/11973))
|
|
327
|
+
- Spans are now exported immediately when created and ended, instead of being batched at workflow completion
|
|
328
|
+
- Added durable span lifecycle hooks (`createStepSpan`, `endStepSpan`, `errorStepSpan`, `createChildSpan`, `endChildSpan`, `errorChildSpan`) that wrap span operations in Inngest's `step.run()` for memoization
|
|
329
|
+
- Added `rebuildSpan()` method to reconstruct span objects from exported data after Inngest replay
|
|
330
|
+
- Fixed nested workflow step spans missing output data
|
|
331
|
+
- Spans correctly maintain parent-child relationships across Inngest's durable execution boundaries using `tracingIds`
|
|
332
|
+
|
|
333
|
+
- Fixed sub-agents in `agent.network()` not receiving conversation history. ([#11825](https://github.com/mastra-ai/mastra/pull/11825))
|
|
334
|
+
|
|
335
|
+
Sub-agents now have access to previous user messages from the conversation, enabling them to understand context from earlier exchanges. This resolves the issue where sub-agents would respond without knowledge of prior conversation turns.
|
|
336
|
+
|
|
337
|
+
Fixes #11468
|
|
338
|
+
|
|
339
|
+
- Fix TypeScript type narrowing when iterating over typed RequestContext ([#10850](https://github.com/mastra-ai/mastra/pull/10850))
|
|
340
|
+
|
|
341
|
+
The `set()` and `get()` methods on a typed `RequestContext` already provide full type safety. However, when iterating with `entries()`, `keys()`, `values()`, or `forEach()`, TypeScript couldn't narrow the value type based on key checks.
|
|
342
|
+
|
|
343
|
+
Now it can:
|
|
344
|
+
|
|
345
|
+
```typescript
|
|
346
|
+
const ctx = new RequestContext<{ userId: string; maxTokens: number }>();
|
|
347
|
+
|
|
348
|
+
// Direct access:
|
|
349
|
+
const tokens = ctx.get('maxTokens'); // number
|
|
350
|
+
|
|
351
|
+
// Iteration now works too:
|
|
352
|
+
for (const [key, value] of ctx.entries()) {
|
|
353
|
+
if (key === 'maxTokens') {
|
|
354
|
+
value.toFixed(0); // TypeScript knows value is number
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
3
359
|
## 1.0.0-beta.21
|
|
4
360
|
|
|
5
361
|
### Minor Changes
|
package/dist/action/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import type { IMastraLogger } from '../logger/index.js';
|
|
|
3
3
|
import type { Mastra } from '../mastra/index.js';
|
|
4
4
|
import type { MastraMemory } from '../memory/index.js';
|
|
5
5
|
import type { MastraStorage } from '../storage/index.js';
|
|
6
|
+
import type { SchemaWithValidation } from '../stream/index.js';
|
|
6
7
|
import type { MastraTTS } from '../tts/index.js';
|
|
7
|
-
import type { ZodLikeSchema, InferZodLikeSchema } from '../types/zod-compat.js';
|
|
8
8
|
import type { MastraVector } from '../vector/index.js';
|
|
9
9
|
export type MastraPrimitives = {
|
|
10
10
|
logger?: IMastraLogger;
|
|
@@ -17,18 +17,18 @@ export type MastraPrimitives = {
|
|
|
17
17
|
export type MastraUnion = {
|
|
18
18
|
[K in keyof Mastra]: Mastra[K];
|
|
19
19
|
} & MastraPrimitives;
|
|
20
|
-
export interface IExecutionContext<
|
|
21
|
-
context:
|
|
20
|
+
export interface IExecutionContext<TInput> {
|
|
21
|
+
context: TInput;
|
|
22
22
|
runId?: string;
|
|
23
23
|
threadId?: string;
|
|
24
24
|
resourceId?: string;
|
|
25
25
|
memory?: MastraMemory;
|
|
26
26
|
}
|
|
27
|
-
export interface IAction<TId extends string,
|
|
27
|
+
export interface IAction<TId extends string, TInput, TOutput, TContext extends IExecutionContext<TInput>, TOptions = unknown> {
|
|
28
28
|
id: TId;
|
|
29
29
|
description?: string;
|
|
30
|
-
inputSchema?:
|
|
31
|
-
outputSchema?:
|
|
32
|
-
execute?: (context: TContext, options?: TOptions) => Promise<
|
|
30
|
+
inputSchema?: SchemaWithValidation<TInput>;
|
|
31
|
+
outputSchema?: SchemaWithValidation<TOutput>;
|
|
32
|
+
execute?: (context: TContext, options?: TOptions) => Promise<TOutput>;
|
|
33
33
|
}
|
|
34
34
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/action/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/action/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,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AS,EAC9D,mBAAmB,SAAS,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,EAE3E,QAAQ,EAAE,gBAAgB,EAC1B,aAAa,GAAE,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,CAAM,GAClE,OAAO,CACN,gBAAgB,CAAC,GAAG,EAAE,MAAM,SAAS,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,GAC3E,CAAC,kBAAkB,CAAC,MAAM,SAAS,SAAS,GAAG,MAAM,GAAG,KAAK,CAAC,GAAG,iBAAiB,CAAC,CACtF;CA8MF"}
|
package/dist/agent/agent.d.ts
CHANGED
|
@@ -14,15 +14,15 @@ import type { MastraMemory } from '../memory/memory.js';
|
|
|
14
14
|
import type { TracingContext, TracingProperties } from '../observability/index.js';
|
|
15
15
|
import type { InputProcessorOrWorkflow, OutputProcessorOrWorkflow, ProcessorWorkflow } from '../processors/index.js';
|
|
16
16
|
import { RequestContext } from '../request-context/index.js';
|
|
17
|
-
import type {
|
|
18
|
-
import type {
|
|
17
|
+
import type { MastraAgentNetworkStream } from '../stream/index.js';
|
|
18
|
+
import type { FullOutput, MastraModelOutput } from '../stream/base/output.js';
|
|
19
19
|
import type { DynamicArgument } from '../types/index.js';
|
|
20
20
|
import type { CompositeVoice } from '../voice/index.js';
|
|
21
21
|
import { DefaultVoice } from '../voice/index.js';
|
|
22
22
|
import type { Workflow } from '../workflows/index.js';
|
|
23
|
-
import type { AgentExecutionOptions, MultiPrimitiveExecutionOptions, NetworkOptions } from './agent.types.js';
|
|
23
|
+
import type { AgentExecutionOptions, AgentExecutionOptionsBase, MultiPrimitiveExecutionOptions, NetworkOptions } from './agent.types.js';
|
|
24
24
|
import type { MessageInput, MessageListInput, UIMessageWithMetadata } from './message-list/index.js';
|
|
25
|
-
import type { AgentConfig, AgentGenerateOptions, AgentStreamOptions, ToolsInput, AgentModelManagerConfig, AgentInstructions } from './types.js';
|
|
25
|
+
import type { AgentConfig, AgentGenerateOptions, AgentStreamOptions, ToolsInput, AgentModelManagerConfig, AgentInstructions, StructuredOutputOptions } from './types.js';
|
|
26
26
|
export type MastraLLM = MastraLLMV1 | MastraLLMVNext;
|
|
27
27
|
type ModelFallbacks = {
|
|
28
28
|
id: string;
|
|
@@ -51,7 +51,7 @@ type ModelFallbacks = {
|
|
|
51
51
|
* });
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
|
-
export declare class Agent<TAgentId extends string = string, TTools extends ToolsInput = ToolsInput> extends MastraBase {
|
|
54
|
+
export declare class Agent<TAgentId extends string = string, TTools extends ToolsInput = ToolsInput, TOutput = undefined> extends MastraBase {
|
|
55
55
|
#private;
|
|
56
56
|
id: TAgentId;
|
|
57
57
|
name: string;
|
|
@@ -77,8 +77,8 @@ export declare class Agent<TAgentId extends string = string, TTools extends Tool
|
|
|
77
77
|
* });
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
80
|
-
constructor(config: AgentConfig<TAgentId, TTools>);
|
|
81
|
-
getMastraInstance(): Mastra<Record<string, Agent<any, ToolsInput>>, Record<string, Workflow<any, any, any, any, any, any, any>>, Record<string, import("../vector").MastraVector<any>>, Record<string, import("../tts").MastraTTS>, import("../logger").IMastraLogger, Record<string, import("../mcp").MCPServerBase<any>>, Record<string, MastraScorer<any, any, any, any>>, Record<string, import("../tools").ToolAction<any, any, any, any, any, any>>, Record<string, import("../processors/index").Processor<any, unknown>>, Record<string, MastraMemory>> | undefined;
|
|
80
|
+
constructor(config: AgentConfig<TAgentId, TTools, TOutput>);
|
|
81
|
+
getMastraInstance(): Mastra<Record<string, Agent<any, ToolsInput, undefined>>, Record<string, Workflow<any, any, any, any, any, any, any>>, Record<string, import("../vector").MastraVector<any>>, Record<string, import("../tts").MastraTTS>, import("../logger").IMastraLogger, Record<string, import("../mcp").MCPServerBase<any>>, Record<string, MastraScorer<any, any, any, any>>, Record<string, import("../tools").ToolAction<any, any, any, any, any, any>>, Record<string, import("../processors/index").Processor<any, unknown>>, Record<string, MastraMemory>> | undefined;
|
|
82
82
|
/**
|
|
83
83
|
* Returns the agents configured for this agent, resolving function-based agents if necessary.
|
|
84
84
|
* Used in multi-agent collaboration scenarios where this agent can delegate to other agents.
|
|
@@ -91,7 +91,7 @@ export declare class Agent<TAgentId extends string = string, TTools extends Tool
|
|
|
91
91
|
*/
|
|
92
92
|
listAgents({ requestContext }?: {
|
|
93
93
|
requestContext?: RequestContext;
|
|
94
|
-
}): Record<string, Agent<string, ToolsInput>> | Promise<Record<string, Agent<string, ToolsInput>>>;
|
|
94
|
+
}): Record<string, Agent<string, ToolsInput, undefined>> | Promise<Record<string, Agent<string, ToolsInput, undefined>>>;
|
|
95
95
|
/**
|
|
96
96
|
* Creates and returns a ProcessorRunner with resolved input/output processors.
|
|
97
97
|
* @internal
|
|
@@ -169,7 +169,7 @@ export declare class Agent<TAgentId extends string = string, TTools extends Tool
|
|
|
169
169
|
*/
|
|
170
170
|
listWorkflows({ requestContext, }?: {
|
|
171
171
|
requestContext?: RequestContext;
|
|
172
|
-
}): Promise<Record<string, Workflow<any, any, any, any, any, any>>>;
|
|
172
|
+
}): Promise<Record<string, Workflow<any, any, any, any, any, any, any>>>;
|
|
173
173
|
listScorers({ requestContext, }?: {
|
|
174
174
|
requestContext?: RequestContext;
|
|
175
175
|
}): Promise<MastraScorers>;
|
|
@@ -250,9 +250,9 @@ export declare class Agent<TAgentId extends string = string, TTools extends Tool
|
|
|
250
250
|
* console.log(options.maxSteps); // 5
|
|
251
251
|
* ```
|
|
252
252
|
*/
|
|
253
|
-
getDefaultOptions
|
|
253
|
+
getDefaultOptions({ requestContext }?: {
|
|
254
254
|
requestContext?: RequestContext;
|
|
255
|
-
}): AgentExecutionOptions<
|
|
255
|
+
}): AgentExecutionOptions<TOutput> | Promise<AgentExecutionOptions<TOutput>>;
|
|
256
256
|
/**
|
|
257
257
|
* Gets the default NetworkOptions for this agent, resolving function-based options if necessary.
|
|
258
258
|
* These options are used as defaults when calling `network()` without explicit options.
|
|
@@ -484,9 +484,83 @@ export declare class Agent<TAgentId extends string = string, TTools extends Tool
|
|
|
484
484
|
* }
|
|
485
485
|
* ```
|
|
486
486
|
*/
|
|
487
|
-
network
|
|
488
|
-
|
|
489
|
-
|
|
487
|
+
network(messages: MessageListInput, options?: MultiPrimitiveExecutionOptions<undefined>): Promise<MastraAgentNetworkStream<undefined>>;
|
|
488
|
+
network<OUTPUT extends {}>(messages: MessageListInput, options?: MultiPrimitiveExecutionOptions<OUTPUT>): Promise<MastraAgentNetworkStream<OUTPUT>>;
|
|
489
|
+
/**
|
|
490
|
+
* Resumes a suspended network loop where multiple agents can collaborate to handle messages.
|
|
491
|
+
* The routing agent delegates tasks to appropriate sub-agents based on the conversation.
|
|
492
|
+
*
|
|
493
|
+
* @experimental
|
|
494
|
+
*
|
|
495
|
+
* @example
|
|
496
|
+
* ```typescript
|
|
497
|
+
* const result = await agent.resumeNetwork({ approved: true }, {
|
|
498
|
+
* runId: 'previous-run-id',
|
|
499
|
+
* memory: {
|
|
500
|
+
* thread: 'user-123',
|
|
501
|
+
* resource: 'my-app'
|
|
502
|
+
* },
|
|
503
|
+
* maxSteps: 10
|
|
504
|
+
* });
|
|
505
|
+
*
|
|
506
|
+
* for await (const chunk of result.stream) {
|
|
507
|
+
* console.log(chunk);
|
|
508
|
+
* }
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
511
|
+
resumeNetwork(resumeData: any, options: Omit<MultiPrimitiveExecutionOptions, 'runId'> & {
|
|
512
|
+
runId: string;
|
|
513
|
+
}): Promise<MastraAgentNetworkStream<undefined>>;
|
|
514
|
+
/**
|
|
515
|
+
* Approves a pending network tool call and resumes execution.
|
|
516
|
+
* Used when `tool.requireApproval` is enabled to allow the agent to proceed with a tool call.
|
|
517
|
+
*
|
|
518
|
+
* @example
|
|
519
|
+
* ```typescript
|
|
520
|
+
* const stream = await agent.approveNetworkToolCall({
|
|
521
|
+
* runId: 'pending-run-id'
|
|
522
|
+
* });
|
|
523
|
+
*
|
|
524
|
+
* for await (const chunk of stream) {
|
|
525
|
+
* console.log(chunk);
|
|
526
|
+
* }
|
|
527
|
+
* ```
|
|
528
|
+
*/
|
|
529
|
+
approveNetworkToolCall(options: Omit<MultiPrimitiveExecutionOptions, 'runId'> & {
|
|
530
|
+
runId: string;
|
|
531
|
+
}): Promise<MastraAgentNetworkStream<undefined>>;
|
|
532
|
+
/**
|
|
533
|
+
* Declines a pending network tool call and resumes execution.
|
|
534
|
+
* Used when `tool.requireApproval` is enabled to allow the agent to proceed with a tool call.
|
|
535
|
+
*
|
|
536
|
+
* @example
|
|
537
|
+
* ```typescript
|
|
538
|
+
* const stream = await agent.declineNetworkToolCall({
|
|
539
|
+
* runId: 'pending-run-id'
|
|
540
|
+
* });
|
|
541
|
+
*
|
|
542
|
+
* for await (const chunk of stream) {
|
|
543
|
+
* console.log(chunk);
|
|
544
|
+
* }
|
|
545
|
+
* ```
|
|
546
|
+
*/
|
|
547
|
+
declineNetworkToolCall(options: Omit<MultiPrimitiveExecutionOptions, 'runId'> & {
|
|
548
|
+
runId: string;
|
|
549
|
+
}): Promise<MastraAgentNetworkStream<undefined>>;
|
|
550
|
+
generate(messages: MessageListInput, options?: AgentExecutionOptions<TOutput>): Promise<FullOutput<TOutput>>;
|
|
551
|
+
generate<OUTPUT extends {}>(messages: MessageListInput, options: AgentExecutionOptionsBase<OUTPUT> & {
|
|
552
|
+
structuredOutput: StructuredOutputOptions<OUTPUT>;
|
|
553
|
+
}): Promise<FullOutput<OUTPUT>>;
|
|
554
|
+
generate<OUTPUT>(messages: MessageListInput, options?: AgentExecutionOptionsBase<any> & {
|
|
555
|
+
structuredOutput?: StructuredOutputOptions<any>;
|
|
556
|
+
}): Promise<FullOutput<OUTPUT>>;
|
|
557
|
+
stream<OUTPUT extends {}>(messages: MessageListInput, streamOptions: AgentExecutionOptionsBase<OUTPUT> & {
|
|
558
|
+
structuredOutput: StructuredOutputOptions<OUTPUT>;
|
|
559
|
+
}): Promise<MastraModelOutput<OUTPUT>>;
|
|
560
|
+
stream<OUTPUT>(messages: MessageListInput, streamOptions: AgentExecutionOptionsBase<any> & {
|
|
561
|
+
structuredOutput?: StructuredOutputOptions<any>;
|
|
562
|
+
}): Promise<MastraModelOutput<OUTPUT>>;
|
|
563
|
+
stream(messages: MessageListInput, streamOptions?: AgentExecutionOptions): Promise<MastraModelOutput>;
|
|
490
564
|
/**
|
|
491
565
|
* Resumes a previously suspended stream execution.
|
|
492
566
|
* Used to continue execution after a suspension point (e.g., tool approval, workflow suspend).
|
|
@@ -500,9 +574,17 @@ export declare class Agent<TAgentId extends string = string, TTools extends Tool
|
|
|
500
574
|
* );
|
|
501
575
|
* ```
|
|
502
576
|
*/
|
|
503
|
-
resumeStream<OUTPUT extends
|
|
577
|
+
resumeStream<OUTPUT extends {}>(resumeData: any, streamOptions: AgentExecutionOptionsBase<OUTPUT> & {
|
|
578
|
+
structuredOutput: StructuredOutputOptions<OUTPUT>;
|
|
504
579
|
toolCallId?: string;
|
|
505
580
|
}): Promise<MastraModelOutput<OUTPUT>>;
|
|
581
|
+
resumeStream<OUTPUT>(resumeData: any, streamOptions: AgentExecutionOptionsBase<any> & {
|
|
582
|
+
structuredOutput?: StructuredOutputOptions<any>;
|
|
583
|
+
toolCallId?: string;
|
|
584
|
+
}): Promise<MastraModelOutput<OUTPUT>>;
|
|
585
|
+
resumeStream(resumeData: any, streamOptions?: AgentExecutionOptions & {
|
|
586
|
+
toolCallId?: string;
|
|
587
|
+
}): Promise<MastraModelOutput>;
|
|
506
588
|
/**
|
|
507
589
|
* Resumes a previously suspended generate execution.
|
|
508
590
|
* Used to continue execution after a suspension point (e.g., tool approval, workflow suspend).
|
|
@@ -516,7 +598,7 @@ export declare class Agent<TAgentId extends string = string, TTools extends Tool
|
|
|
516
598
|
* );
|
|
517
599
|
* ```
|
|
518
600
|
*/
|
|
519
|
-
resumeGenerate<OUTPUT
|
|
601
|
+
resumeGenerate<OUTPUT = undefined>(resumeData: any, options?: AgentExecutionOptions<OUTPUT> & {
|
|
520
602
|
toolCallId?: string;
|
|
521
603
|
}): Promise<Awaited<ReturnType<MastraModelOutput<OUTPUT>['getFullOutput']>>>;
|
|
522
604
|
/**
|
|
@@ -534,7 +616,7 @@ export declare class Agent<TAgentId extends string = string, TTools extends Tool
|
|
|
534
616
|
* }
|
|
535
617
|
* ```
|
|
536
618
|
*/
|
|
537
|
-
approveToolCall<OUTPUT
|
|
619
|
+
approveToolCall<OUTPUT = undefined>(options: AgentExecutionOptions<OUTPUT> & {
|
|
538
620
|
runId: string;
|
|
539
621
|
toolCallId?: string;
|
|
540
622
|
}): Promise<MastraModelOutput<OUTPUT>>;
|
|
@@ -553,7 +635,7 @@ export declare class Agent<TAgentId extends string = string, TTools extends Tool
|
|
|
553
635
|
* }
|
|
554
636
|
* ```
|
|
555
637
|
*/
|
|
556
|
-
declineToolCall<OUTPUT
|
|
638
|
+
declineToolCall<OUTPUT = undefined>(options: AgentExecutionOptions<OUTPUT> & {
|
|
557
639
|
runId: string;
|
|
558
640
|
toolCallId?: string;
|
|
559
641
|
}): Promise<MastraModelOutput<OUTPUT>>;
|