@mastra/core 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +236 -0
- package/dist/agent/agent.d.ts +6 -0
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/index.cjs +8 -8
- package/dist/agent/index.js +1 -1
- package/dist/{chunk-VJWRJWSC.cjs → chunk-2X66GWF5.cjs} +94 -16
- package/dist/chunk-2X66GWF5.cjs.map +1 -0
- package/dist/{chunk-YM6245EM.js → chunk-6OXW5E2O.js} +3 -3
- package/dist/{chunk-YM6245EM.js.map → chunk-6OXW5E2O.js.map} +1 -1
- package/dist/{chunk-XWZAKKFT.cjs → chunk-6QBN6MZY.cjs} +14 -14
- package/dist/{chunk-XWZAKKFT.cjs.map → chunk-6QBN6MZY.cjs.map} +1 -1
- package/dist/{chunk-AYHSPIT6.cjs → chunk-7UAJ6LMR.cjs} +820 -259
- package/dist/chunk-7UAJ6LMR.cjs.map +1 -0
- package/dist/{chunk-RZNHRIM7.cjs → chunk-A72NTLFT.cjs} +5 -5
- package/dist/{chunk-RZNHRIM7.cjs.map → chunk-A72NTLFT.cjs.map} +1 -1
- package/dist/{chunk-EEU5NHHU.js → chunk-DFCRXDVK.js} +3 -3
- package/dist/{chunk-EEU5NHHU.js.map → chunk-DFCRXDVK.js.map} +1 -1
- package/dist/{chunk-5K45E5VE.js → chunk-GPJGPARM.js} +3 -2
- package/dist/chunk-GPJGPARM.js.map +1 -0
- package/dist/{chunk-LNKS4TJ6.cjs → chunk-HB6T4554.cjs} +8 -7
- package/dist/chunk-HB6T4554.cjs.map +1 -0
- package/dist/{chunk-DGS2KGDI.js → chunk-KUXNBWN7.js} +6 -5
- package/dist/chunk-KUXNBWN7.js.map +1 -0
- package/dist/{chunk-IHDE4CJV.js → chunk-QSHV7GPT.js} +89 -12
- package/dist/chunk-QSHV7GPT.js.map +1 -0
- package/dist/{chunk-3U3XFMGJ.cjs → chunk-QTAS3HND.cjs} +13 -8
- package/dist/chunk-QTAS3HND.cjs.map +1 -0
- package/dist/{chunk-RHKNKJNM.js → chunk-QWTB53GS.js} +4 -4
- package/dist/{chunk-RHKNKJNM.js.map → chunk-QWTB53GS.js.map} +1 -1
- package/dist/{chunk-4WG5K4CK.js → chunk-R4N65TLG.js} +7 -7
- package/dist/{chunk-4WG5K4CK.js.map → chunk-R4N65TLG.js.map} +1 -1
- package/dist/{chunk-5VQPSWPG.cjs → chunk-RABITNTG.cjs} +48 -48
- package/dist/{chunk-5VQPSWPG.cjs.map → chunk-RABITNTG.cjs.map} +1 -1
- package/dist/{chunk-TVPANHLE.cjs → chunk-SBOHDNIZ.cjs} +3 -2
- package/dist/chunk-SBOHDNIZ.cjs.map +1 -0
- package/dist/{chunk-MWGGSA5Q.js → chunk-T6GAM3SQ.js} +10 -5
- package/dist/chunk-T6GAM3SQ.js.map +1 -0
- package/dist/{chunk-TL2TTA4X.cjs → chunk-YQG7NBPR.cjs} +9 -9
- package/dist/{chunk-TL2TTA4X.cjs.map → chunk-YQG7NBPR.cjs.map} +1 -1
- package/dist/{chunk-XB3DA67Q.js → chunk-ZSBM2SVU.js} +818 -259
- package/dist/chunk-ZSBM2SVU.js.map +1 -0
- package/dist/datasets/experiment/scorer.d.ts.map +1 -1
- package/dist/datasets/index.cjs +17 -17
- package/dist/datasets/index.js +2 -2
- package/dist/evals/index.cjs +20 -20
- package/dist/evals/index.js +3 -3
- package/dist/evals/scoreTraces/index.cjs +7 -6
- package/dist/evals/scoreTraces/index.cjs.map +1 -1
- package/dist/evals/scoreTraces/index.js +4 -3
- package/dist/evals/scoreTraces/index.js.map +1 -1
- package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts.map +1 -1
- package/dist/harness/harness.d.ts +21 -1
- package/dist/harness/harness.d.ts.map +1 -1
- package/dist/harness/index.cjs +422 -5
- package/dist/harness/index.cjs.map +1 -1
- package/dist/harness/index.d.ts +2 -1
- package/dist/harness/index.d.ts.map +1 -1
- package/dist/harness/index.js +418 -3
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/types.d.ts +151 -0
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/loop/index.cjs +12 -12
- package/dist/loop/index.js +1 -1
- package/dist/loop/test-utils/tools.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
- package/dist/mastra/hooks.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +14 -14
- package/dist/memory/index.js +1 -1
- package/dist/processor-provider/index.cjs +10 -10
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/index.cjs +45 -41
- package/dist/processors/index.js +1 -1
- package/dist/processors/processors/index.d.ts +1 -0
- package/dist/processors/processors/index.d.ts.map +1 -1
- package/dist/processors/processors/workspace-instructions.d.ts +50 -0
- package/dist/processors/processors/workspace-instructions.d.ts.map +1 -0
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/storage/constants.cjs +56 -56
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/index.cjs +160 -160
- package/dist/storage/index.js +2 -2
- package/dist/storage/types.d.ts +2 -0
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +8 -8
- package/dist/stream/index.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/vector/index.cjs +7 -7
- package/dist/vector/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +25 -25
- package/dist/workflows/index.js +1 -1
- package/dist/workspace/constants/index.d.ts +2 -0
- package/dist/workspace/constants/index.d.ts.map +1 -1
- package/dist/workspace/errors.d.ts +1 -1
- package/dist/workspace/errors.d.ts.map +1 -1
- package/dist/workspace/filesystem/composite-filesystem.d.ts +4 -1
- package/dist/workspace/filesystem/composite-filesystem.d.ts.map +1 -1
- package/dist/workspace/filesystem/file-write-lock.d.ts +35 -0
- package/dist/workspace/filesystem/file-write-lock.d.ts.map +1 -0
- package/dist/workspace/filesystem/filesystem.d.ts +5 -1
- package/dist/workspace/filesystem/filesystem.d.ts.map +1 -1
- package/dist/workspace/filesystem/index.d.ts +1 -0
- package/dist/workspace/filesystem/index.d.ts.map +1 -1
- package/dist/workspace/filesystem/local-filesystem.d.ts +17 -1
- package/dist/workspace/filesystem/local-filesystem.d.ts.map +1 -1
- package/dist/workspace/index.cjs +72 -64
- package/dist/workspace/index.d.ts +3 -2
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/lifecycle.d.ts +1 -9
- package/dist/workspace/lifecycle.d.ts.map +1 -1
- package/dist/workspace/sandbox/index.d.ts +2 -0
- package/dist/workspace/sandbox/index.d.ts.map +1 -1
- package/dist/workspace/sandbox/local-process-manager.d.ts +18 -0
- package/dist/workspace/sandbox/local-process-manager.d.ts.map +1 -0
- package/dist/workspace/sandbox/local-sandbox.d.ts +49 -35
- package/dist/workspace/sandbox/local-sandbox.d.ts.map +1 -1
- package/dist/workspace/sandbox/mastra-sandbox.d.ts +45 -11
- package/dist/workspace/sandbox/mastra-sandbox.d.ts.map +1 -1
- package/dist/workspace/sandbox/native-sandbox/bubblewrap.d.ts +2 -3
- package/dist/workspace/sandbox/native-sandbox/bubblewrap.d.ts.map +1 -1
- package/dist/workspace/sandbox/native-sandbox/seatbelt.d.ts +2 -3
- package/dist/workspace/sandbox/native-sandbox/seatbelt.d.ts.map +1 -1
- package/dist/workspace/sandbox/native-sandbox/wrapper.d.ts +4 -5
- package/dist/workspace/sandbox/native-sandbox/wrapper.d.ts.map +1 -1
- package/dist/workspace/sandbox/process-manager/index.d.ts +4 -0
- package/dist/workspace/sandbox/process-manager/index.d.ts.map +1 -0
- package/dist/workspace/sandbox/process-manager/process-handle.d.ts +107 -0
- package/dist/workspace/sandbox/process-manager/process-handle.d.ts.map +1 -0
- package/dist/workspace/sandbox/process-manager/process-manager.d.ts +59 -0
- package/dist/workspace/sandbox/process-manager/process-manager.d.ts.map +1 -0
- package/dist/workspace/sandbox/process-manager/types.d.ts +24 -0
- package/dist/workspace/sandbox/process-manager/types.d.ts.map +1 -0
- package/dist/workspace/sandbox/sandbox.d.ts +38 -2
- package/dist/workspace/sandbox/sandbox.d.ts.map +1 -1
- package/dist/workspace/sandbox/types.d.ts +9 -2
- package/dist/workspace/sandbox/types.d.ts.map +1 -1
- package/dist/workspace/sandbox/utils.d.ts +7 -0
- package/dist/workspace/sandbox/utils.d.ts.map +1 -0
- package/dist/workspace/tools/execute-command.d.ts +53 -2
- package/dist/workspace/tools/execute-command.d.ts.map +1 -1
- package/dist/workspace/tools/get-process-output.d.ts +6 -0
- package/dist/workspace/tools/get-process-output.d.ts.map +1 -0
- package/dist/workspace/tools/index.d.ts +4 -1
- package/dist/workspace/tools/index.d.ts.map +1 -1
- package/dist/workspace/tools/kill-process.d.ts +4 -0
- package/dist/workspace/tools/kill-process.d.ts.map +1 -0
- package/dist/workspace/tools/output-helpers.d.ts +21 -0
- package/dist/workspace/tools/output-helpers.d.ts.map +1 -0
- package/dist/workspace/tools/tools.d.ts.map +1 -1
- package/dist/workspace/types.d.ts +31 -0
- package/dist/workspace/types.d.ts.map +1 -1
- package/dist/workspace/utils.d.ts +11 -0
- package/dist/workspace/utils.d.ts.map +1 -0
- package/dist/workspace/workspace.d.ts +36 -0
- package/dist/workspace/workspace.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/chunk-3U3XFMGJ.cjs.map +0 -1
- package/dist/chunk-5K45E5VE.js.map +0 -1
- package/dist/chunk-AYHSPIT6.cjs.map +0 -1
- package/dist/chunk-DGS2KGDI.js.map +0 -1
- package/dist/chunk-IHDE4CJV.js.map +0 -1
- package/dist/chunk-LNKS4TJ6.cjs.map +0 -1
- package/dist/chunk-MWGGSA5Q.js.map +0 -1
- package/dist/chunk-TVPANHLE.cjs.map +0 -1
- package/dist/chunk-VJWRJWSC.cjs.map +0 -1
- package/dist/chunk-XB3DA67Q.js.map +0 -1
- package/dist/docs/SKILL.md +0 -301
- package/dist/docs/assets/SOURCE_MAP.json +0 -1413
- package/dist/docs/references/docs-agents-adding-voice.md +0 -353
- package/dist/docs/references/docs-agents-agent-approval.md +0 -377
- package/dist/docs/references/docs-agents-agent-memory.md +0 -212
- package/dist/docs/references/docs-agents-guardrails.md +0 -382
- package/dist/docs/references/docs-agents-network-approval.md +0 -275
- package/dist/docs/references/docs-agents-networks.md +0 -290
- package/dist/docs/references/docs-agents-overview.md +0 -309
- package/dist/docs/references/docs-agents-processors.md +0 -632
- package/dist/docs/references/docs-agents-structured-output.md +0 -271
- package/dist/docs/references/docs-agents-using-tools.md +0 -214
- package/dist/docs/references/docs-evals-custom-scorers.md +0 -519
- package/dist/docs/references/docs-evals-overview.md +0 -146
- package/dist/docs/references/docs-evals-running-in-ci.md +0 -106
- package/dist/docs/references/docs-mcp-overview.md +0 -370
- package/dist/docs/references/docs-mcp-publishing-mcp-server.md +0 -95
- package/dist/docs/references/docs-memory-memory-processors.md +0 -316
- package/dist/docs/references/docs-memory-observational-memory.md +0 -246
- package/dist/docs/references/docs-memory-overview.md +0 -45
- package/dist/docs/references/docs-memory-semantic-recall.md +0 -272
- package/dist/docs/references/docs-memory-storage.md +0 -261
- package/dist/docs/references/docs-memory-working-memory.md +0 -400
- package/dist/docs/references/docs-observability-datasets-overview.md +0 -188
- package/dist/docs/references/docs-observability-datasets-running-experiments.md +0 -266
- package/dist/docs/references/docs-observability-logging.md +0 -99
- package/dist/docs/references/docs-observability-overview.md +0 -70
- package/dist/docs/references/docs-observability-tracing-bridges-otel.md +0 -209
- package/dist/docs/references/docs-observability-tracing-exporters-arize.md +0 -274
- package/dist/docs/references/docs-observability-tracing-exporters-braintrust.md +0 -111
- package/dist/docs/references/docs-observability-tracing-exporters-cloud.md +0 -129
- package/dist/docs/references/docs-observability-tracing-exporters-datadog.md +0 -187
- package/dist/docs/references/docs-observability-tracing-exporters-default.md +0 -211
- package/dist/docs/references/docs-observability-tracing-exporters-laminar.md +0 -100
- package/dist/docs/references/docs-observability-tracing-exporters-langfuse.md +0 -217
- package/dist/docs/references/docs-observability-tracing-exporters-langsmith.md +0 -202
- package/dist/docs/references/docs-observability-tracing-exporters-otel.md +0 -479
- package/dist/docs/references/docs-observability-tracing-exporters-posthog.md +0 -148
- package/dist/docs/references/docs-observability-tracing-overview.md +0 -1114
- package/dist/docs/references/docs-rag-chunking-and-embedding.md +0 -183
- package/dist/docs/references/docs-rag-graph-rag.md +0 -215
- package/dist/docs/references/docs-rag-overview.md +0 -72
- package/dist/docs/references/docs-rag-retrieval.md +0 -521
- package/dist/docs/references/docs-rag-vector-databases.md +0 -648
- package/dist/docs/references/docs-server-auth-auth0.md +0 -222
- package/dist/docs/references/docs-server-auth-clerk.md +0 -132
- package/dist/docs/references/docs-server-auth-composite-auth.md +0 -234
- package/dist/docs/references/docs-server-auth-custom-auth-provider.md +0 -513
- package/dist/docs/references/docs-server-auth-firebase.md +0 -272
- package/dist/docs/references/docs-server-auth-jwt.md +0 -110
- package/dist/docs/references/docs-server-auth-simple-auth.md +0 -178
- package/dist/docs/references/docs-server-auth-supabase.md +0 -117
- package/dist/docs/references/docs-server-auth-workos.md +0 -190
- package/dist/docs/references/docs-server-custom-adapters.md +0 -374
- package/dist/docs/references/docs-server-custom-api-routes.md +0 -267
- package/dist/docs/references/docs-server-mastra-client.md +0 -243
- package/dist/docs/references/docs-server-mastra-server.md +0 -71
- package/dist/docs/references/docs-server-middleware.md +0 -228
- package/dist/docs/references/docs-server-request-context.md +0 -478
- package/dist/docs/references/docs-streaming-events.md +0 -247
- package/dist/docs/references/docs-streaming-tool-streaming.md +0 -178
- package/dist/docs/references/docs-streaming-workflow-streaming.md +0 -109
- package/dist/docs/references/docs-voice-overview.md +0 -979
- package/dist/docs/references/docs-voice-speech-to-speech.md +0 -103
- package/dist/docs/references/docs-voice-speech-to-text.md +0 -80
- package/dist/docs/references/docs-voice-text-to-speech.md +0 -84
- package/dist/docs/references/docs-workflows-agents-and-tools.md +0 -170
- package/dist/docs/references/docs-workflows-control-flow.md +0 -823
- package/dist/docs/references/docs-workflows-error-handling.md +0 -360
- package/dist/docs/references/docs-workflows-human-in-the-loop.md +0 -213
- package/dist/docs/references/docs-workflows-overview.md +0 -372
- package/dist/docs/references/docs-workflows-snapshots.md +0 -238
- package/dist/docs/references/docs-workflows-suspend-and-resume.md +0 -205
- package/dist/docs/references/docs-workflows-time-travel.md +0 -309
- package/dist/docs/references/docs-workflows-workflow-state.md +0 -181
- package/dist/docs/references/docs-workspace-filesystem.md +0 -162
- package/dist/docs/references/docs-workspace-overview.md +0 -239
- package/dist/docs/references/docs-workspace-sandbox.md +0 -63
- package/dist/docs/references/docs-workspace-search.md +0 -219
- package/dist/docs/references/docs-workspace-skills.md +0 -126
- package/dist/docs/references/guides-agent-frameworks-ai-sdk.md +0 -140
- package/dist/docs/references/reference-agents-agent.md +0 -142
- package/dist/docs/references/reference-agents-generate.md +0 -174
- package/dist/docs/references/reference-agents-generateLegacy.md +0 -176
- package/dist/docs/references/reference-agents-getDefaultGenerateOptions.md +0 -36
- package/dist/docs/references/reference-agents-getDefaultOptions.md +0 -34
- package/dist/docs/references/reference-agents-getDefaultStreamOptions.md +0 -36
- package/dist/docs/references/reference-agents-getDescription.md +0 -21
- package/dist/docs/references/reference-agents-getInstructions.md +0 -34
- package/dist/docs/references/reference-agents-getLLM.md +0 -37
- package/dist/docs/references/reference-agents-getMemory.md +0 -34
- package/dist/docs/references/reference-agents-getModel.md +0 -34
- package/dist/docs/references/reference-agents-getTools.md +0 -29
- package/dist/docs/references/reference-agents-getVoice.md +0 -34
- package/dist/docs/references/reference-agents-listAgents.md +0 -35
- package/dist/docs/references/reference-agents-listScorers.md +0 -34
- package/dist/docs/references/reference-agents-listTools.md +0 -34
- package/dist/docs/references/reference-agents-listWorkflows.md +0 -34
- package/dist/docs/references/reference-agents-network.md +0 -134
- package/dist/docs/references/reference-ai-sdk-chat-route.md +0 -82
- package/dist/docs/references/reference-ai-sdk-network-route.md +0 -74
- package/dist/docs/references/reference-ai-sdk-to-ai-sdk-stream.md +0 -232
- package/dist/docs/references/reference-ai-sdk-with-mastra.md +0 -59
- package/dist/docs/references/reference-ai-sdk-workflow-route.md +0 -79
- package/dist/docs/references/reference-auth-auth0.md +0 -73
- package/dist/docs/references/reference-auth-clerk.md +0 -36
- package/dist/docs/references/reference-auth-firebase.md +0 -80
- package/dist/docs/references/reference-auth-jwt.md +0 -26
- package/dist/docs/references/reference-auth-supabase.md +0 -33
- package/dist/docs/references/reference-auth-workos.md +0 -84
- package/dist/docs/references/reference-client-js-agents.md +0 -438
- package/dist/docs/references/reference-configuration.md +0 -749
- package/dist/docs/references/reference-core-addGateway.md +0 -42
- package/dist/docs/references/reference-core-getAgent.md +0 -21
- package/dist/docs/references/reference-core-getAgentById.md +0 -21
- package/dist/docs/references/reference-core-getDeployer.md +0 -22
- package/dist/docs/references/reference-core-getGateway.md +0 -38
- package/dist/docs/references/reference-core-getGatewayById.md +0 -41
- package/dist/docs/references/reference-core-getLogger.md +0 -22
- package/dist/docs/references/reference-core-getMCPServer.md +0 -45
- package/dist/docs/references/reference-core-getMCPServerById.md +0 -53
- package/dist/docs/references/reference-core-getMemory.md +0 -50
- package/dist/docs/references/reference-core-getScorer.md +0 -54
- package/dist/docs/references/reference-core-getScorerById.md +0 -54
- package/dist/docs/references/reference-core-getServer.md +0 -22
- package/dist/docs/references/reference-core-getStorage.md +0 -22
- package/dist/docs/references/reference-core-getStoredAgentById.md +0 -89
- package/dist/docs/references/reference-core-getTelemetry.md +0 -22
- package/dist/docs/references/reference-core-getVector.md +0 -22
- package/dist/docs/references/reference-core-getWorkflow.md +0 -40
- package/dist/docs/references/reference-core-listAgents.md +0 -21
- package/dist/docs/references/reference-core-listGateways.md +0 -40
- package/dist/docs/references/reference-core-listLogs.md +0 -38
- package/dist/docs/references/reference-core-listLogsByRunId.md +0 -36
- package/dist/docs/references/reference-core-listMCPServers.md +0 -51
- package/dist/docs/references/reference-core-listMemory.md +0 -56
- package/dist/docs/references/reference-core-listScorers.md +0 -29
- package/dist/docs/references/reference-core-listStoredAgents.md +0 -93
- package/dist/docs/references/reference-core-listVectors.md +0 -22
- package/dist/docs/references/reference-core-listWorkflows.md +0 -21
- package/dist/docs/references/reference-core-mastra-class.md +0 -66
- package/dist/docs/references/reference-core-mastra-model-gateway.md +0 -153
- package/dist/docs/references/reference-core-setLogger.md +0 -26
- package/dist/docs/references/reference-core-setStorage.md +0 -27
- package/dist/docs/references/reference-datasets-addItem.md +0 -35
- package/dist/docs/references/reference-datasets-addItems.md +0 -33
- package/dist/docs/references/reference-datasets-compareExperiments.md +0 -48
- package/dist/docs/references/reference-datasets-create.md +0 -49
- package/dist/docs/references/reference-datasets-dataset.md +0 -78
- package/dist/docs/references/reference-datasets-datasets-manager.md +0 -84
- package/dist/docs/references/reference-datasets-delete.md +0 -23
- package/dist/docs/references/reference-datasets-deleteExperiment.md +0 -25
- package/dist/docs/references/reference-datasets-deleteItem.md +0 -25
- package/dist/docs/references/reference-datasets-deleteItems.md +0 -27
- package/dist/docs/references/reference-datasets-get.md +0 -29
- package/dist/docs/references/reference-datasets-getDetails.md +0 -45
- package/dist/docs/references/reference-datasets-getExperiment.md +0 -28
- package/dist/docs/references/reference-datasets-getItem.md +0 -31
- package/dist/docs/references/reference-datasets-getItemHistory.md +0 -29
- package/dist/docs/references/reference-datasets-list.md +0 -29
- package/dist/docs/references/reference-datasets-listExperimentResults.md +0 -37
- package/dist/docs/references/reference-datasets-listExperiments.md +0 -31
- package/dist/docs/references/reference-datasets-listItems.md +0 -44
- package/dist/docs/references/reference-datasets-listVersions.md +0 -31
- package/dist/docs/references/reference-datasets-startExperiment.md +0 -60
- package/dist/docs/references/reference-datasets-startExperimentAsync.md +0 -41
- package/dist/docs/references/reference-datasets-update.md +0 -46
- package/dist/docs/references/reference-datasets-updateItem.md +0 -36
- package/dist/docs/references/reference-evals-answer-relevancy.md +0 -105
- package/dist/docs/references/reference-evals-answer-similarity.md +0 -99
- package/dist/docs/references/reference-evals-bias.md +0 -120
- package/dist/docs/references/reference-evals-completeness.md +0 -137
- package/dist/docs/references/reference-evals-content-similarity.md +0 -101
- package/dist/docs/references/reference-evals-context-precision.md +0 -196
- package/dist/docs/references/reference-evals-create-scorer.md +0 -270
- package/dist/docs/references/reference-evals-faithfulness.md +0 -114
- package/dist/docs/references/reference-evals-hallucination.md +0 -220
- package/dist/docs/references/reference-evals-keyword-coverage.md +0 -128
- package/dist/docs/references/reference-evals-mastra-scorer.md +0 -123
- package/dist/docs/references/reference-evals-run-evals.md +0 -138
- package/dist/docs/references/reference-evals-scorer-utils.md +0 -330
- package/dist/docs/references/reference-evals-textual-difference.md +0 -113
- package/dist/docs/references/reference-evals-tone-consistency.md +0 -119
- package/dist/docs/references/reference-evals-toxicity.md +0 -123
- package/dist/docs/references/reference-harness-harness-class.md +0 -645
- package/dist/docs/references/reference-logging-pino-logger.md +0 -117
- package/dist/docs/references/reference-memory-deleteMessages.md +0 -40
- package/dist/docs/references/reference-memory-memory-class.md +0 -147
- package/dist/docs/references/reference-memory-observational-memory.md +0 -565
- package/dist/docs/references/reference-observability-tracing-bridges-otel.md +0 -131
- package/dist/docs/references/reference-observability-tracing-configuration.md +0 -178
- package/dist/docs/references/reference-observability-tracing-exporters-console-exporter.md +0 -138
- package/dist/docs/references/reference-observability-tracing-exporters-datadog.md +0 -116
- package/dist/docs/references/reference-observability-tracing-instances.md +0 -109
- package/dist/docs/references/reference-observability-tracing-interfaces.md +0 -749
- package/dist/docs/references/reference-observability-tracing-processors-sensitive-data-filter.md +0 -144
- package/dist/docs/references/reference-observability-tracing-spans.md +0 -224
- package/dist/docs/references/reference-processors-batch-parts-processor.md +0 -61
- package/dist/docs/references/reference-processors-language-detector.md +0 -81
- package/dist/docs/references/reference-processors-message-history-processor.md +0 -85
- package/dist/docs/references/reference-processors-moderation-processor.md +0 -104
- package/dist/docs/references/reference-processors-pii-detector.md +0 -107
- package/dist/docs/references/reference-processors-processor-interface.md +0 -525
- package/dist/docs/references/reference-processors-prompt-injection-detector.md +0 -71
- package/dist/docs/references/reference-processors-semantic-recall-processor.md +0 -123
- package/dist/docs/references/reference-processors-system-prompt-scrubber.md +0 -80
- package/dist/docs/references/reference-processors-token-limiter-processor.md +0 -113
- package/dist/docs/references/reference-processors-tool-call-filter.md +0 -85
- package/dist/docs/references/reference-processors-tool-search-processor.md +0 -113
- package/dist/docs/references/reference-processors-unicode-normalizer.md +0 -62
- package/dist/docs/references/reference-processors-working-memory-processor.md +0 -154
- package/dist/docs/references/reference-rag-database-config.md +0 -264
- package/dist/docs/references/reference-rag-embeddings.md +0 -92
- package/dist/docs/references/reference-server-mastra-server.md +0 -298
- package/dist/docs/references/reference-server-register-api-route.md +0 -249
- package/dist/docs/references/reference-storage-cloudflare-d1.md +0 -218
- package/dist/docs/references/reference-storage-composite.md +0 -235
- package/dist/docs/references/reference-storage-lance.md +0 -131
- package/dist/docs/references/reference-storage-libsql.md +0 -135
- package/dist/docs/references/reference-storage-mongodb.md +0 -262
- package/dist/docs/references/reference-storage-mssql.md +0 -155
- package/dist/docs/references/reference-storage-overview.md +0 -121
- package/dist/docs/references/reference-storage-postgresql.md +0 -529
- package/dist/docs/references/reference-storage-upstash.md +0 -160
- package/dist/docs/references/reference-streaming-ChunkType.md +0 -292
- package/dist/docs/references/reference-streaming-agents-MastraModelOutput.md +0 -182
- package/dist/docs/references/reference-streaming-agents-streamLegacy.md +0 -142
- package/dist/docs/references/reference-streaming-workflows-observeStream.md +0 -42
- package/dist/docs/references/reference-streaming-workflows-resumeStream.md +0 -61
- package/dist/docs/references/reference-streaming-workflows-stream.md +0 -88
- package/dist/docs/references/reference-streaming-workflows-timeTravelStream.md +0 -142
- package/dist/docs/references/reference-templates-overview.md +0 -194
- package/dist/docs/references/reference-tools-create-tool.md +0 -237
- package/dist/docs/references/reference-tools-graph-rag-tool.md +0 -185
- package/dist/docs/references/reference-tools-mcp-client.md +0 -962
- package/dist/docs/references/reference-tools-mcp-server.md +0 -1275
- package/dist/docs/references/reference-tools-vector-query-tool.md +0 -459
- package/dist/docs/references/reference-vectors-libsql.md +0 -305
- package/dist/docs/references/reference-vectors-mongodb.md +0 -295
- package/dist/docs/references/reference-vectors-pg.md +0 -408
- package/dist/docs/references/reference-vectors-upstash.md +0 -294
- package/dist/docs/references/reference-voice-composite-voice.md +0 -121
- package/dist/docs/references/reference-voice-mastra-voice.md +0 -313
- package/dist/docs/references/reference-voice-voice.addInstructions.md +0 -56
- package/dist/docs/references/reference-voice-voice.addTools.md +0 -67
- package/dist/docs/references/reference-voice-voice.connect.md +0 -94
- package/dist/docs/references/reference-voice-voice.events.md +0 -37
- package/dist/docs/references/reference-voice-voice.listen.md +0 -164
- package/dist/docs/references/reference-voice-voice.on.md +0 -111
- package/dist/docs/references/reference-voice-voice.speak.md +0 -157
- package/dist/docs/references/reference-workflows-run-methods-cancel.md +0 -86
- package/dist/docs/references/reference-workflows-run-methods-restart.md +0 -33
- package/dist/docs/references/reference-workflows-run-methods-resume.md +0 -59
- package/dist/docs/references/reference-workflows-run-methods-start.md +0 -58
- package/dist/docs/references/reference-workflows-run-methods-startAsync.md +0 -67
- package/dist/docs/references/reference-workflows-run-methods-timeTravel.md +0 -142
- package/dist/docs/references/reference-workflows-run.md +0 -59
- package/dist/docs/references/reference-workflows-step.md +0 -119
- package/dist/docs/references/reference-workflows-workflow-methods-branch.md +0 -25
- package/dist/docs/references/reference-workflows-workflow-methods-commit.md +0 -17
- package/dist/docs/references/reference-workflows-workflow-methods-create-run.md +0 -63
- package/dist/docs/references/reference-workflows-workflow-methods-dountil.md +0 -25
- package/dist/docs/references/reference-workflows-workflow-methods-dowhile.md +0 -25
- package/dist/docs/references/reference-workflows-workflow-methods-foreach.md +0 -118
- package/dist/docs/references/reference-workflows-workflow-methods-map.md +0 -93
- package/dist/docs/references/reference-workflows-workflow-methods-parallel.md +0 -21
- package/dist/docs/references/reference-workflows-workflow-methods-sleep.md +0 -35
- package/dist/docs/references/reference-workflows-workflow-methods-sleepUntil.md +0 -35
- package/dist/docs/references/reference-workflows-workflow-methods-then.md +0 -21
- package/dist/docs/references/reference-workflows-workflow.md +0 -157
- package/dist/docs/references/reference-workspace-filesystem.md +0 -202
- package/dist/docs/references/reference-workspace-local-filesystem.md +0 -327
- package/dist/docs/references/reference-workspace-local-sandbox.md +0 -285
- package/dist/docs/references/reference-workspace-sandbox.md +0 -81
- package/dist/docs/references/reference-workspace-workspace-class.md +0 -226
- package/dist/docs/references/reference.md +0 -276
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
# Agent.network()
|
|
2
|
-
|
|
3
|
-
The `.network()` method enables multi-agent collaboration and routing. This method accepts messages and optional execution options.
|
|
4
|
-
|
|
5
|
-
## Usage example
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
import { Agent } from "@mastra/core/agent";
|
|
9
|
-
import { agent1, agent2 } from "./agents";
|
|
10
|
-
import { workflow1 } from "./workflows";
|
|
11
|
-
import { tool1, tool2 } from "./tools";
|
|
12
|
-
|
|
13
|
-
const agent = new Agent({
|
|
14
|
-
id: "network-agent",
|
|
15
|
-
name: "Network Agent",
|
|
16
|
-
instructions:
|
|
17
|
-
"You are a network agent that can help users with a variety of tasks.",
|
|
18
|
-
model: "openai/gpt-5.1",
|
|
19
|
-
agents: {
|
|
20
|
-
agent1,
|
|
21
|
-
agent2,
|
|
22
|
-
},
|
|
23
|
-
workflows: {
|
|
24
|
-
workflow1,
|
|
25
|
-
},
|
|
26
|
-
tools: {
|
|
27
|
-
tool1,
|
|
28
|
-
tool2,
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
await agent.network(`
|
|
33
|
-
Find me the weather in Tokyo.
|
|
34
|
-
Based on the weather, plan an activity for me.
|
|
35
|
-
`);
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Parameters
|
|
39
|
-
|
|
40
|
-
**messages:** (`string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[]`): The messages to send to the agent. Can be a single string, array of strings, or structured message objects.
|
|
41
|
-
|
|
42
|
-
**options?:** (`MultiPrimitiveExecutionOptions`): Optional configuration for the network process.
|
|
43
|
-
|
|
44
|
-
### Options
|
|
45
|
-
|
|
46
|
-
**maxSteps?:** (`number`): Maximum number of steps to run during execution.
|
|
47
|
-
|
|
48
|
-
**memory?:** (`object`): thread:string | { id: string; metadata?: Record\<string, any>, title?: string }The conversation thread, as a string ID or an object with an \`id\` and optional \`metadata\`.resource:stringIdentifier for the user or resource associated with the thread.options?:MemoryConfigConfiguration for memory behavior, like message history and semantic recall.
|
|
49
|
-
|
|
50
|
-
**tracingContext?:** (`TracingContext`): currentSpan?:SpanCurrent span for creating child spans and adding metadata. Use this to create custom child spans or update span attributes during execution.
|
|
51
|
-
|
|
52
|
-
**tracingOptions?:** (`TracingOptions`): metadata?:Record\<string, any>Metadata to add to the root trace span. Useful for adding custom attributes like user IDs, session IDs, or feature flags.requestContextKeys?:string\[]Additional RequestContext keys to extract as metadata for this trace. Supports dot notation for nested values (e.g., 'user.id').traceId?:stringTrace ID to use for this execution (1-32 hexadecimal characters). If provided, this trace will be part of the specified trace.parentSpanId?:stringParent span ID to use for this execution (1-16 hexadecimal characters). If provided, the root span will be created as a child of this span.tags?:string\[]Tags to apply to this trace. String labels for categorizing and filtering traces.
|
|
53
|
-
|
|
54
|
-
**telemetry?:** (`TelemetrySettings`): isEnabled?:booleanEnable or disable telemetry. Disabled by default while experimental.recordInputs?:booleanEnable or disable input recording. Enabled by default. You might want to disable input recording to avoid recording sensitive information.recordOutputs?:booleanEnable or disable output recording. Enabled by default. You might want to disable output recording to avoid recording sensitive information.functionId?:stringIdentifier for this function. Used to group telemetry data by function.
|
|
55
|
-
|
|
56
|
-
**modelSettings?:** (`CallSettings`): temperature?:numberControls randomness in generation (0-2). Higher values make output more random.maxOutputTokens?:numberMaximum number of tokens to generate in the response. Note: Use maxOutputTokens (not maxTokens) as per AI SDK v5 convention.maxRetries?:numberMaximum number of retry attempts for failed requests.topP?:numberNucleus sampling parameter (0-1). Controls diversity of generated text.topK?:numberTop-k sampling parameter. Limits vocabulary to k most likely tokens.presencePenalty?:numberPenalty for token presence (-2 to 2). Reduces repetition.frequencyPenalty?:numberPenalty for token frequency (-2 to 2). Reduces repetition of frequent tokens.stopSequences?:string\[]Stop sequences. If set, the model will stop generating text when one of the stop sequences is generated.
|
|
57
|
-
|
|
58
|
-
**structuredOutput?:** (`StructuredOutputOptions`): schema:ZodSchema | JSONSchema7The schema to validate the output against. Can be a Zod schema or JSON Schema.model?:MastraModelConfigModel to use for generating the structured output. Defaults to the agent's model.instructions?:stringCustom instructions for generating the structured output.
|
|
59
|
-
|
|
60
|
-
**runId?:** (`string`): Unique ID for this generation run. Useful for tracking and debugging purposes.
|
|
61
|
-
|
|
62
|
-
**requestContext?:** (`RequestContext`): Request Context for dependency injection and contextual information.
|
|
63
|
-
|
|
64
|
-
**traceId?:** (`string`): The trace ID associated with this execution when Tracing is enabled. Use this to correlate logs and debug execution flow.
|
|
65
|
-
|
|
66
|
-
## Returns
|
|
67
|
-
|
|
68
|
-
**stream:** (`MastraAgentNetworkStream<NetworkChunkType>`): A custom stream that extends ReadableStream\<NetworkChunkType> with additional network-specific properties
|
|
69
|
-
|
|
70
|
-
**status:** (`Promise<RunStatus>`): A promise that resolves to the current workflow run status
|
|
71
|
-
|
|
72
|
-
**result:** (`Promise<WorkflowResult<TState, TOutput, TSteps>>`): A promise that resolves to the final workflow result
|
|
73
|
-
|
|
74
|
-
**usage:** (`Promise<{ promptTokens: number; completionTokens: number; totalTokens: number }>`): A promise that resolves to token usage statistics
|
|
75
|
-
|
|
76
|
-
**object:** (`Promise<OUTPUT | undefined>`): A promise that resolves to the structured output object. Only available when structuredOutput option is provided. Resolves to undefined if no schema was specified.
|
|
77
|
-
|
|
78
|
-
**objectStream:** (`ReadableStream<Partial<OUTPUT>>`): A stream of partial objects during structured output generation. Useful for streaming partial results as they're being generated.
|
|
79
|
-
|
|
80
|
-
## Structured Output
|
|
81
|
-
|
|
82
|
-
When you need typed, validated results from your network, use the `structuredOutput` option. The network will generate a response matching your schema after task completion.
|
|
83
|
-
|
|
84
|
-
```typescript
|
|
85
|
-
import { z } from "zod";
|
|
86
|
-
|
|
87
|
-
const resultSchema = z.object({
|
|
88
|
-
summary: z.string().describe("A brief summary of the findings"),
|
|
89
|
-
recommendations: z.array(z.string()).describe("List of recommendations"),
|
|
90
|
-
confidence: z.number().min(0).max(1).describe("Confidence score"),
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
const stream = await agent.network("Research AI trends and summarize", {
|
|
94
|
-
structuredOutput: {
|
|
95
|
-
schema: resultSchema,
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// Consume the stream
|
|
100
|
-
for await (const chunk of stream) {
|
|
101
|
-
// Handle streaming events
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Get the typed result
|
|
105
|
-
const result = await stream.object;
|
|
106
|
-
// result is typed as { summary: string; recommendations: string[]; confidence: number }
|
|
107
|
-
console.log(result?.summary);
|
|
108
|
-
console.log(result?.recommendations);
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### Streaming Partial Objects
|
|
112
|
-
|
|
113
|
-
You can also stream partial objects as they're being generated:
|
|
114
|
-
|
|
115
|
-
```typescript
|
|
116
|
-
const stream = await agent.network("Analyze data", {
|
|
117
|
-
structuredOutput: { schema: resultSchema },
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
// Stream partial objects
|
|
121
|
-
for await (const partial of stream.objectStream) {
|
|
122
|
-
console.log("Partial result:", partial);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Get final result
|
|
126
|
-
const final = await stream.object;
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Chunk Types
|
|
130
|
-
|
|
131
|
-
When using structured output, additional chunk types are emitted:
|
|
132
|
-
|
|
133
|
-
- `network-object`: Emitted with partial objects during streaming
|
|
134
|
-
- `network-object-result`: Emitted with the final structured object
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
# chatRoute()
|
|
2
|
-
|
|
3
|
-
Creates a chat route handler for streaming agent conversations using the AI SDK format. This function registers an HTTP `POST` endpoint that accepts messages, executes an agent, and streams the response back to the client in AI SDK-compatible format. You have to use it inside a [custom API route](https://mastra.ai/docs/server/custom-api-routes).
|
|
4
|
-
|
|
5
|
-
Use [`handleChatStream()`](https://mastra.ai/reference/ai-sdk/handle-chat-stream) if you need a framework-agnostic handler.
|
|
6
|
-
|
|
7
|
-
## Usage example
|
|
8
|
-
|
|
9
|
-
This example shows how to set up a chat route at the `/chat` endpoint that uses an agent with the ID `weatherAgent`.
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
import { Mastra } from "@mastra/core";
|
|
13
|
-
import { chatRoute } from "@mastra/ai-sdk";
|
|
14
|
-
|
|
15
|
-
export const mastra = new Mastra({
|
|
16
|
-
server: {
|
|
17
|
-
apiRoutes: [
|
|
18
|
-
chatRoute({
|
|
19
|
-
path: "/chat",
|
|
20
|
-
agent: "weatherAgent",
|
|
21
|
-
}),
|
|
22
|
-
],
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
You can also use dynamic agent routing based on an `agentId`. The URL `/chat/weatherAgent` will resolve to the agent with the ID `weatherAgent`.
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
import { Mastra } from "@mastra/core";
|
|
31
|
-
import { chatRoute } from "@mastra/ai-sdk";
|
|
32
|
-
|
|
33
|
-
export const mastra = new Mastra({
|
|
34
|
-
server: {
|
|
35
|
-
apiRoutes: [
|
|
36
|
-
chatRoute({
|
|
37
|
-
path: "/chat/:agentId",
|
|
38
|
-
}),
|
|
39
|
-
],
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Parameters
|
|
45
|
-
|
|
46
|
-
**path:** (`string`): The route path (e.g., \`/chat\` or \`/chat/:agentId\`). Include \`:agentId\` for dynamic agent routing. (Default: `'/chat/:agentId'`)
|
|
47
|
-
|
|
48
|
-
**agent?:** (`string`): The ID of the agent to use for this chat route. Required if the path doesn't include \`:agentId\`.
|
|
49
|
-
|
|
50
|
-
**defaultOptions?:** (`AgentExecutionOptions`): Default options passed to agent execution. These can include instructions, memory configuration, maxSteps, and other execution settings.
|
|
51
|
-
|
|
52
|
-
**sendStart?:** (`boolean`): Whether to send start events in the stream. (Default: `true`)
|
|
53
|
-
|
|
54
|
-
**sendFinish?:** (`boolean`): Whether to send finish events in the stream. (Default: `true`)
|
|
55
|
-
|
|
56
|
-
**sendReasoning?:** (`boolean`): Whether to include reasoning steps in the stream. (Default: `false`)
|
|
57
|
-
|
|
58
|
-
**sendSources?:** (`boolean`): Whether to include source citations in the stream. (Default: `false`)
|
|
59
|
-
|
|
60
|
-
## Additional configuration
|
|
61
|
-
|
|
62
|
-
You can use [`prepareSendMessagesRequest`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat#transport.default-chat-transport.prepare-send-messages-request) to customize the request sent to the chat route, for example to pass additional configuration to the agent:
|
|
63
|
-
|
|
64
|
-
```typescript
|
|
65
|
-
const { error, status, sendMessage, messages, regenerate, stop } = useChat({
|
|
66
|
-
transport: new DefaultChatTransport({
|
|
67
|
-
api: "http://localhost:4111/chat",
|
|
68
|
-
prepareSendMessagesRequest({ messages }) {
|
|
69
|
-
return {
|
|
70
|
-
body: {
|
|
71
|
-
messages,
|
|
72
|
-
// Pass memory config
|
|
73
|
-
memory: {
|
|
74
|
-
thread: "user-1",
|
|
75
|
-
resource: "user-1",
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
},
|
|
80
|
-
}),
|
|
81
|
-
});
|
|
82
|
-
```
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# networkRoute()
|
|
2
|
-
|
|
3
|
-
Creates a network route handler for streaming network execution using the AI SDK format. This function registers an HTTP `POST` endpoint that accepts messages, executes an agent network, and streams the response back to the client in AI SDK-compatible format. Agent networks allow a routing agent to delegate tasks to other agents. You have to use it inside a [custom API route](https://mastra.ai/docs/server/custom-api-routes).
|
|
4
|
-
|
|
5
|
-
Use [`handleNetworkStream()`](https://mastra.ai/reference/ai-sdk/handle-network-stream) if you need a framework-agnostic handler.
|
|
6
|
-
|
|
7
|
-
## Usage example
|
|
8
|
-
|
|
9
|
-
This example shows how to set up a network route at the `/network` endpoint that uses an agent with the ID `weatherAgent`.
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
import { Mastra } from "@mastra/core";
|
|
13
|
-
import { networkRoute } from "@mastra/ai-sdk";
|
|
14
|
-
|
|
15
|
-
export const mastra = new Mastra({
|
|
16
|
-
server: {
|
|
17
|
-
apiRoutes: [
|
|
18
|
-
networkRoute({
|
|
19
|
-
path: "/network",
|
|
20
|
-
agent: "weatherAgent",
|
|
21
|
-
}),
|
|
22
|
-
],
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
You can also use dynamic agent routing based on an `agentId`. The URL `/network/weatherAgent` will resolve to the agent with the ID `weatherAgent`.
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
import { Mastra } from "@mastra/core";
|
|
31
|
-
import { networkRoute } from "@mastra/ai-sdk";
|
|
32
|
-
|
|
33
|
-
export const mastra = new Mastra({
|
|
34
|
-
server: {
|
|
35
|
-
apiRoutes: [
|
|
36
|
-
networkRoute({
|
|
37
|
-
path: "/network/:agentId",
|
|
38
|
-
}),
|
|
39
|
-
],
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Parameters
|
|
45
|
-
|
|
46
|
-
**path:** (`string`): The route path (e.g., \`/network\` or \`/network/:agentId\`). Include \`:agentId\` for dynamic agent routing. (Default: `'/network/:agentId'`)
|
|
47
|
-
|
|
48
|
-
**agent?:** (`string`): The ID of the routing agent to use for this network route. Required if the path doesn't include \`:agentId\`.
|
|
49
|
-
|
|
50
|
-
**defaultOptions?:** (`AgentExecutionOptions`): Default options passed to agent execution. These can include instructions, memory configuration, maxSteps, and other execution settings.
|
|
51
|
-
|
|
52
|
-
## Additional configuration
|
|
53
|
-
|
|
54
|
-
You can use [`prepareSendMessagesRequest`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat#transport.default-chat-transport.prepare-send-messages-request) to customize the request sent to the network route, for example to pass additional configuration to the agent:
|
|
55
|
-
|
|
56
|
-
```typescript
|
|
57
|
-
const { error, status, sendMessage, messages, regenerate, stop } = useChat({
|
|
58
|
-
transport: new DefaultChatTransport({
|
|
59
|
-
api: "http://localhost:4111/network",
|
|
60
|
-
prepareSendMessagesRequest({ messages }) {
|
|
61
|
-
return {
|
|
62
|
-
body: {
|
|
63
|
-
messages,
|
|
64
|
-
// Pass memory config
|
|
65
|
-
memory: {
|
|
66
|
-
thread: "user-1",
|
|
67
|
-
resource: "user-1",
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
}),
|
|
73
|
-
});
|
|
74
|
-
```
|
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
# toAISdkStream()
|
|
2
|
-
|
|
3
|
-
Converts Mastra streams (agent, network, or workflow) to AI SDK-compatible streams. Use this function when you need to manually transform Mastra streams for use with AI SDK's `createUIMessageStream()` and `createUIMessageStreamResponse()`.
|
|
4
|
-
|
|
5
|
-
This is useful when building custom streaming endpoints outside Mastra's provided route helpers such as [`chatRoute()`](https://mastra.ai/reference/ai-sdk/chat-route) or [`workflowRoute()`](https://mastra.ai/reference/ai-sdk/workflow-route).
|
|
6
|
-
|
|
7
|
-
## Usage example
|
|
8
|
-
|
|
9
|
-
Next.js App Router example:
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
import { mastra } from "../../mastra";
|
|
13
|
-
import { createUIMessageStream, createUIMessageStreamResponse } from "ai";
|
|
14
|
-
import { toAISdkStream } from "@mastra/ai-sdk";
|
|
15
|
-
|
|
16
|
-
export async function POST(req: Request) {
|
|
17
|
-
const { messages } = await req.json();
|
|
18
|
-
const myAgent = mastra.getAgent("weatherAgent");
|
|
19
|
-
const stream = await myAgent.stream(messages);
|
|
20
|
-
|
|
21
|
-
const uiMessageStream = createUIMessageStream({
|
|
22
|
-
originalMessages: messages,
|
|
23
|
-
execute: async ({ writer }) => {
|
|
24
|
-
for await (const part of toAISdkStream(stream, { from: "agent" })) {
|
|
25
|
-
await writer.write(part);
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
return createUIMessageStreamResponse({
|
|
31
|
-
stream: uiMessageStream,
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
> **Tip:** Pass `messages` to `originalMessages` in `createUIMessageStream()` to avoid duplicated assistant messages in the UI. See [Troubleshooting: Repeated Assistant Messages](https://ai-sdk.dev/docs/troubleshooting/repeated-assistant-messages) for details.
|
|
37
|
-
|
|
38
|
-
## Parameters
|
|
39
|
-
|
|
40
|
-
The first parameter is the Mastra stream to convert. It can be one of:
|
|
41
|
-
|
|
42
|
-
- `MastraModelOutput` - An agent stream from `agent.stream()`
|
|
43
|
-
- `MastraAgentNetworkStream` - A network stream from `agent.network()`
|
|
44
|
-
- `MastraWorkflowStream` or `WorkflowRunOutput` - A workflow stream
|
|
45
|
-
|
|
46
|
-
The second parameter is an options object:
|
|
47
|
-
|
|
48
|
-
**from:** (`'agent' | 'network' | 'workflow'`): The type of Mastra stream being converted. (Default: `'agent'`)
|
|
49
|
-
|
|
50
|
-
**lastMessageId?:** (`string`): (Agent only) The ID of the last message in the conversation.
|
|
51
|
-
|
|
52
|
-
**sendStart?:** (`boolean`): (Agent only) Whether to send start events in the stream. (Default: `true`)
|
|
53
|
-
|
|
54
|
-
**sendFinish?:** (`boolean`): (Agent only) Whether to send finish events in the stream. (Default: `true`)
|
|
55
|
-
|
|
56
|
-
**sendReasoning?:** (`boolean`): (Agent only) Whether to include reasoning-delta chunks in the stream. Set to true to stream reasoning content from models that support extended thinking. (Default: `false`)
|
|
57
|
-
|
|
58
|
-
**sendSources?:** (`boolean`): (Agent only) Whether to include source citations in the output. (Default: `false`)
|
|
59
|
-
|
|
60
|
-
**includeTextStreamParts?:** (`boolean`): (Workflow only) Whether to include text stream parts in the output. (Default: `true`)
|
|
61
|
-
|
|
62
|
-
**messageMetadata?:** (`(options: { part: UIMessageStreamPart }) => Record<string, unknown> | undefined`): (Agent only) A function that receives the current stream part and returns metadata to attach to start and finish chunks.
|
|
63
|
-
|
|
64
|
-
**onError?:** (`(error: unknown) => string`): (Agent only) A function to handle errors during stream conversion. Receives the error and should return a string representation.
|
|
65
|
-
|
|
66
|
-
## Examples
|
|
67
|
-
|
|
68
|
-
### Converting a workflow stream
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
import { mastra } from "../../mastra";
|
|
72
|
-
import { createUIMessageStream, createUIMessageStreamResponse } from "ai";
|
|
73
|
-
import { toAISdkStream } from "@mastra/ai-sdk";
|
|
74
|
-
|
|
75
|
-
export async function POST(req: Request) {
|
|
76
|
-
const { input } = await req.json();
|
|
77
|
-
const workflow = mastra.getWorkflow("myWorkflow");
|
|
78
|
-
const run = workflow.createRun();
|
|
79
|
-
const stream = await run.stream({ inputData: input });
|
|
80
|
-
|
|
81
|
-
const uiMessageStream = createUIMessageStream({
|
|
82
|
-
execute: async ({ writer }) => {
|
|
83
|
-
for await (const part of toAISdkStream(stream, { from: "workflow" })) {
|
|
84
|
-
await writer.write(part);
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
return createUIMessageStreamResponse({
|
|
90
|
-
stream: uiMessageStream,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Converting a network stream
|
|
96
|
-
|
|
97
|
-
```typescript
|
|
98
|
-
import { mastra } from "../../mastra";
|
|
99
|
-
import { createUIMessageStream, createUIMessageStreamResponse } from "ai";
|
|
100
|
-
import { toAISdkStream } from "@mastra/ai-sdk";
|
|
101
|
-
|
|
102
|
-
export async function POST(req: Request) {
|
|
103
|
-
const { messages } = await req.json();
|
|
104
|
-
const routingAgent = mastra.getAgent("routingAgent");
|
|
105
|
-
const stream = await routingAgent.network(messages);
|
|
106
|
-
|
|
107
|
-
const uiMessageStream = createUIMessageStream({
|
|
108
|
-
execute: async ({ writer }) => {
|
|
109
|
-
for await (const part of toAISdkStream(stream, { from: "network" })) {
|
|
110
|
-
await writer.write(part);
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
return createUIMessageStreamResponse({
|
|
116
|
-
stream: uiMessageStream,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
### Converting an agent stream with reasoning enabled
|
|
122
|
-
|
|
123
|
-
```typescript
|
|
124
|
-
import { mastra } from "../../mastra";
|
|
125
|
-
import { createUIMessageStream, createUIMessageStreamResponse } from "ai";
|
|
126
|
-
import { toAISdkStream } from "@mastra/ai-sdk";
|
|
127
|
-
|
|
128
|
-
export async function POST(req: Request) {
|
|
129
|
-
const { messages } = await req.json();
|
|
130
|
-
const reasoningAgent = mastra.getAgent("reasoningAgent");
|
|
131
|
-
const stream = await reasoningAgent.stream(messages, {
|
|
132
|
-
providerOptions: {
|
|
133
|
-
openai: { reasoningEffort: "high" },
|
|
134
|
-
},
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
const uiMessageStream = createUIMessageStream({
|
|
138
|
-
originalMessages: messages,
|
|
139
|
-
execute: async ({ writer }) => {
|
|
140
|
-
for await (const part of toAISdkStream(stream, {
|
|
141
|
-
from: "agent",
|
|
142
|
-
sendReasoning: true,
|
|
143
|
-
})) {
|
|
144
|
-
await writer.write(part);
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
return createUIMessageStreamResponse({
|
|
150
|
-
stream: uiMessageStream,
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
### Using messageMetadata
|
|
156
|
-
|
|
157
|
-
```typescript
|
|
158
|
-
import { mastra } from "../../mastra";
|
|
159
|
-
import { createUIMessageStream, createUIMessageStreamResponse } from "ai";
|
|
160
|
-
import { toAISdkStream } from "@mastra/ai-sdk";
|
|
161
|
-
|
|
162
|
-
export async function POST(req: Request) {
|
|
163
|
-
const { messages } = await req.json();
|
|
164
|
-
const myAgent = mastra.getAgent("weatherAgent");
|
|
165
|
-
const stream = await myAgent.stream(messages);
|
|
166
|
-
|
|
167
|
-
const uiMessageStream = createUIMessageStream({
|
|
168
|
-
originalMessages: messages,
|
|
169
|
-
execute: async ({ writer }) => {
|
|
170
|
-
for await (const part of toAISdkStream(stream, {
|
|
171
|
-
from: "agent",
|
|
172
|
-
messageMetadata: ({ part }) => ({
|
|
173
|
-
timestamp: Date.now(),
|
|
174
|
-
partType: part.type,
|
|
175
|
-
}),
|
|
176
|
-
})) {
|
|
177
|
-
await writer.write(part);
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
return createUIMessageStreamResponse({
|
|
183
|
-
stream: uiMessageStream,
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
### Client-side stream transformation
|
|
189
|
-
|
|
190
|
-
If you're using the Mastra client SDK (`@mastra/client-js`) on the client side and want to convert streams to AI SDK format:
|
|
191
|
-
|
|
192
|
-
```typescript
|
|
193
|
-
import { MastraClient } from "@mastra/client-js";
|
|
194
|
-
import { createUIMessageStream } from "ai";
|
|
195
|
-
import { toAISdkStream } from "@mastra/ai-sdk";
|
|
196
|
-
import type { ChunkType, MastraModelOutput } from "@mastra/core/stream";
|
|
197
|
-
|
|
198
|
-
const client = new MastraClient({
|
|
199
|
-
baseUrl: "http://localhost:4111",
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
const agent = client.getAgent("weatherAgent");
|
|
203
|
-
const response = await agent.stream("What is the weather in Tokyo?");
|
|
204
|
-
|
|
205
|
-
// Convert the client SDK stream to a ReadableStream<ChunkType>
|
|
206
|
-
const chunkStream = new ReadableStream<ChunkType>({
|
|
207
|
-
async start(controller) {
|
|
208
|
-
await response.processDataStream({
|
|
209
|
-
onChunk: async (chunk) => {
|
|
210
|
-
controller.enqueue(chunk);
|
|
211
|
-
},
|
|
212
|
-
});
|
|
213
|
-
controller.close();
|
|
214
|
-
},
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
// Transform to AI SDK format
|
|
218
|
-
const uiMessageStream = createUIMessageStream({
|
|
219
|
-
execute: async ({ writer }) => {
|
|
220
|
-
for await (const part of toAISdkStream(
|
|
221
|
-
chunkStream as unknown as MastraModelOutput,
|
|
222
|
-
{ from: "agent" }
|
|
223
|
-
)) {
|
|
224
|
-
await writer.write(part);
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
for await (const part of uiMessageStream) {
|
|
230
|
-
console.log(part);
|
|
231
|
-
}
|
|
232
|
-
```
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# withMastra()
|
|
2
|
-
|
|
3
|
-
Wraps an AI SDK model with Mastra processors and/or memory.
|
|
4
|
-
|
|
5
|
-
## Usage example
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
import { openai } from '@ai-sdk/openai';
|
|
9
|
-
import { generateText } from 'ai';
|
|
10
|
-
import { withMastra } from '@mastra/ai-sdk';
|
|
11
|
-
import type { Processor } from '@mastra/core/processors';
|
|
12
|
-
|
|
13
|
-
const loggingProcessor: Processor<'logger'> = {
|
|
14
|
-
id: 'logger',
|
|
15
|
-
async processInput({ messages }) {
|
|
16
|
-
console.log('Input:', messages.length, 'messages');
|
|
17
|
-
return messages;
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const model = withMastra(openai('gpt-4o'), {
|
|
22
|
-
inputProcessors: [loggingProcessor],
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const { text } = await generateText({
|
|
26
|
-
model,
|
|
27
|
-
prompt: 'What is 2 + 2?',
|
|
28
|
-
});
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Parameters
|
|
32
|
-
|
|
33
|
-
**model:** (`LanguageModelV2`): Any AI SDK language model (e.g., \`openai('gpt-4o')\`, \`anthropic('claude-3-opus')\`).
|
|
34
|
-
|
|
35
|
-
**options?:** (`WithMastraOptions`): Configuration object for processors and memory.
|
|
36
|
-
|
|
37
|
-
**options.inputProcessors?:** (`InputProcessor[]`): Input processors to run before the LLM call.
|
|
38
|
-
|
|
39
|
-
**options.outputProcessors?:** (`OutputProcessor[]`): Output processors to run on the LLM response.
|
|
40
|
-
|
|
41
|
-
**options.memory?:** (`WithMastraMemoryOptions`): Memory configuration - enables automatic message history persistence.
|
|
42
|
-
|
|
43
|
-
**options.memory.storage:** (`MemoryStorage`): Memory storage domain for message persistence. Get it from a composite store using \`await storage.getStore('memory')\`.
|
|
44
|
-
|
|
45
|
-
**options.memory.threadId:** (`string`): Thread ID for conversation persistence.
|
|
46
|
-
|
|
47
|
-
**options.memory.resourceId?:** (`string`): Resource ID (user/session identifier).
|
|
48
|
-
|
|
49
|
-
**options.memory.lastMessages?:** (`number | false`): Number of recent messages to retrieve, or false to disable.
|
|
50
|
-
|
|
51
|
-
**options.memory.semanticRecall?:** (`WithMastraSemanticRecallOptions`): Semantic recall configuration (RAG-based memory retrieval).
|
|
52
|
-
|
|
53
|
-
**options.memory.workingMemory?:** (`MemoryConfig['workingMemory']`): Working memory configuration (persistent user data).
|
|
54
|
-
|
|
55
|
-
**options.memory.readOnly?:** (`boolean`): Read-only mode - prevents saving new messages.
|
|
56
|
-
|
|
57
|
-
## Returns
|
|
58
|
-
|
|
59
|
-
A wrapped model compatible with `generateText`, `streamText`, `generateObject`, and `streamObject`.
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# workflowRoute()
|
|
2
|
-
|
|
3
|
-
Creates a workflow route handler for streaming workflow execution using the AI SDK format. This function registers an HTTP `POST` endpoint that accepts input data, executes a workflow, and streams the response back to the client in AI SDK-compatible format. You have to use it inside a [custom API route](https://mastra.ai/docs/server/custom-api-routes).
|
|
4
|
-
|
|
5
|
-
Use [`handleWorkflowStream()`](https://mastra.ai/reference/ai-sdk/handle-workflow-stream) if you need a framework-agnostic handler.
|
|
6
|
-
|
|
7
|
-
> **Agent streaming in workflows:** When a workflow step pipes an agent's stream to the workflow writer (e.g., `await response.fullStream.pipeTo(writer)`), the agent's text chunks and tool calls are forwarded to the UI stream in real time, even when the agent runs inside workflow steps.
|
|
8
|
-
>
|
|
9
|
-
> See [Workflow Streaming](https://mastra.ai/docs/streaming/workflow-streaming) for more details.
|
|
10
|
-
|
|
11
|
-
## Usage example
|
|
12
|
-
|
|
13
|
-
This example shows how to set up a workflow route at the `/workflow` endpoint that uses a workflow with the ID `weatherWorkflow`.
|
|
14
|
-
|
|
15
|
-
```typescript
|
|
16
|
-
import { Mastra } from "@mastra/core";
|
|
17
|
-
import { workflowRoute } from "@mastra/ai-sdk";
|
|
18
|
-
|
|
19
|
-
export const mastra = new Mastra({
|
|
20
|
-
server: {
|
|
21
|
-
apiRoutes: [
|
|
22
|
-
workflowRoute({
|
|
23
|
-
path: "/workflow",
|
|
24
|
-
workflow: "weatherWorkflow",
|
|
25
|
-
}),
|
|
26
|
-
],
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
You can also use dynamic workflow routing based on a `workflowId`. The URL `/workflow/weatherWorkflow` will resolve to the workflow with the ID `weatherWorkflow`.
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
import { Mastra } from "@mastra/core";
|
|
35
|
-
import { workflowRoute } from "@mastra/ai-sdk";
|
|
36
|
-
|
|
37
|
-
export const mastra = new Mastra({
|
|
38
|
-
server: {
|
|
39
|
-
apiRoutes: [
|
|
40
|
-
workflowRoute({
|
|
41
|
-
path: "/workflow/:workflowId",
|
|
42
|
-
}),
|
|
43
|
-
],
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## Parameters
|
|
49
|
-
|
|
50
|
-
**path?:** (`string`): The route path (e.g., \`/workflow\` or \`/workflow/:workflowId\`). Include \`:workflowId\` for dynamic workflow routing. (Default: `'/api/workflows/:workflowId/stream'`)
|
|
51
|
-
|
|
52
|
-
**workflow?:** (`string`): Fixed workflow ID when not using dynamic routing. (Default: `undefined`)
|
|
53
|
-
|
|
54
|
-
**includeTextStreamParts?:** (`boolean`): Whether to include text stream parts in the output. (Default: `true`)
|
|
55
|
-
|
|
56
|
-
## Additional configuration
|
|
57
|
-
|
|
58
|
-
You can use [`prepareSendMessagesRequest`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat#transport.default-chat-transport.prepare-send-messages-request) to customize the request sent to the workflow route, for example to pass additional configuration to the workflow:
|
|
59
|
-
|
|
60
|
-
```typescript
|
|
61
|
-
const { error, status, sendMessage, messages, regenerate, stop } = useChat({
|
|
62
|
-
transport: new DefaultChatTransport({
|
|
63
|
-
api: "http://localhost:4111/workflow",
|
|
64
|
-
prepareSendMessagesRequest({ messages }) {
|
|
65
|
-
return {
|
|
66
|
-
body: {
|
|
67
|
-
inputData: {
|
|
68
|
-
city: messages[messages.length - 1].parts[0].text,
|
|
69
|
-
},
|
|
70
|
-
// Or resumeData for resuming a suspended workflow
|
|
71
|
-
resumeData: {
|
|
72
|
-
confirmation: messages[messages.length - 1].parts[0].text
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
},
|
|
77
|
-
}),
|
|
78
|
-
});
|
|
79
|
-
```
|