@mastra/mcp-docs-server 1.1.7-alpha.0 → 1.1.8-alpha.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/.docs/docs/agents/agent-approval.md +61 -31
- package/.docs/docs/agents/supervisor-agents.md +1 -1
- package/.docs/docs/getting-started/manual-install.md +1 -1
- package/.docs/docs/index.md +68 -24
- package/.docs/docs/mastra-cloud/setup.md +1 -1
- package/.docs/docs/memory/observational-memory.md +9 -0
- package/.docs/docs/memory/semantic-recall.md +17 -1
- package/.docs/docs/workspace/skills.md +7 -5
- package/.docs/guides/deployment/aws-lambda.md +76 -165
- package/.docs/guides/deployment/azure-app-services.md +38 -61
- package/.docs/guides/deployment/cloudflare.md +1 -1
- package/.docs/guides/deployment/netlify.md +1 -1
- package/.docs/guides/deployment/vercel.md +1 -1
- package/.docs/models/gateways/netlify.md +5 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/anthropic.md +9 -9
- package/.docs/models/providers/deepseek.md +1 -1
- package/.docs/models/providers/google.md +11 -11
- package/.docs/models/providers/openai.md +19 -19
- package/.docs/models/providers/opencode.md +33 -33
- package/.docs/models/providers/xai.md +3 -3
- package/.docs/reference/agents/agent.md +20 -20
- package/.docs/reference/agents/generate.md +200 -66
- package/.docs/reference/agents/generateLegacy.md +77 -35
- package/.docs/reference/agents/getDefaultGenerateOptions.md +4 -6
- package/.docs/reference/agents/getDefaultOptions.md +4 -6
- package/.docs/reference/agents/getDefaultStreamOptions.md +4 -6
- package/.docs/reference/agents/getDescription.md +1 -1
- package/.docs/reference/agents/getInstructions.md +4 -6
- package/.docs/reference/agents/getLLM.md +6 -8
- package/.docs/reference/agents/getMemory.md +4 -6
- package/.docs/reference/agents/getModel.md +4 -6
- package/.docs/reference/agents/getTools.md +5 -7
- package/.docs/reference/agents/getVoice.md +4 -6
- package/.docs/reference/agents/listAgents.md +4 -6
- package/.docs/reference/agents/listScorers.md +4 -6
- package/.docs/reference/agents/listTools.md +4 -6
- package/.docs/reference/agents/listWorkflows.md +4 -6
- package/.docs/reference/agents/network.md +69 -23
- package/.docs/reference/ai-sdk/chat-route.md +7 -7
- package/.docs/reference/ai-sdk/handle-chat-stream.md +12 -12
- package/.docs/reference/ai-sdk/handle-network-stream.md +4 -4
- package/.docs/reference/ai-sdk/handle-workflow-stream.md +11 -11
- package/.docs/reference/ai-sdk/network-route.md +3 -3
- package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +9 -9
- package/.docs/reference/ai-sdk/to-ai-sdk-v4-messages.md +9 -9
- package/.docs/reference/ai-sdk/to-ai-sdk-v5-messages.md +5 -5
- package/.docs/reference/ai-sdk/with-mastra.md +12 -12
- package/.docs/reference/ai-sdk/workflow-route.md +3 -3
- package/.docs/reference/auth/auth0.md +6 -6
- package/.docs/reference/auth/better-auth.md +5 -5
- package/.docs/reference/auth/clerk.md +5 -5
- package/.docs/reference/auth/firebase.md +7 -7
- package/.docs/reference/auth/jwt.md +1 -1
- package/.docs/reference/auth/supabase.md +4 -4
- package/.docs/reference/auth/workos.md +6 -6
- package/.docs/reference/cli/create-mastra.md +14 -14
- package/.docs/reference/client-js/mastra-client.md +23 -23
- package/.docs/reference/client-js/workflows.md +3 -3
- package/.docs/reference/core/addGateway.md +2 -2
- package/.docs/reference/core/getAgent.md +2 -2
- package/.docs/reference/core/getAgentById.md +2 -2
- package/.docs/reference/core/getDeployer.md +1 -1
- package/.docs/reference/core/getGateway.md +2 -2
- package/.docs/reference/core/getGatewayById.md +2 -2
- package/.docs/reference/core/getLogger.md +1 -1
- package/.docs/reference/core/getMCPServer.md +2 -2
- package/.docs/reference/core/getMCPServerById.md +3 -3
- package/.docs/reference/core/getMemory.md +2 -2
- package/.docs/reference/core/getScorer.md +2 -2
- package/.docs/reference/core/getScorerById.md +2 -2
- package/.docs/reference/core/getServer.md +1 -1
- package/.docs/reference/core/getStorage.md +1 -1
- package/.docs/reference/core/getStoredAgentById.md +18 -20
- package/.docs/reference/core/getTelemetry.md +1 -1
- package/.docs/reference/core/getVector.md +2 -2
- package/.docs/reference/core/getWorkflow.md +3 -3
- package/.docs/reference/core/listAgents.md +1 -1
- package/.docs/reference/core/listGateways.md +1 -1
- package/.docs/reference/core/listLogs.md +9 -11
- package/.docs/reference/core/listLogsByRunId.md +9 -9
- package/.docs/reference/core/listMCPServers.md +1 -1
- package/.docs/reference/core/listMemory.md +1 -1
- package/.docs/reference/core/listScorers.md +1 -1
- package/.docs/reference/core/listStoredAgents.md +9 -11
- package/.docs/reference/core/listVectors.md +1 -1
- package/.docs/reference/core/listWorkflows.md +2 -2
- package/.docs/reference/core/mastra-class.md +17 -17
- package/.docs/reference/core/mastra-model-gateway.md +15 -15
- package/.docs/reference/core/setLogger.md +2 -4
- package/.docs/reference/core/setStorage.md +1 -1
- package/.docs/reference/datasets/addItem.md +20 -4
- package/.docs/reference/datasets/addItems.md +8 -2
- package/.docs/reference/datasets/compareExperiments.md +15 -3
- package/.docs/reference/datasets/create.md +6 -6
- package/.docs/reference/datasets/dataset.md +1 -1
- package/.docs/reference/datasets/delete.md +2 -2
- package/.docs/reference/datasets/deleteExperiment.md +2 -2
- package/.docs/reference/datasets/deleteItem.md +2 -2
- package/.docs/reference/datasets/deleteItems.md +2 -2
- package/.docs/reference/datasets/get.md +2 -2
- package/.docs/reference/datasets/getDetails.md +9 -9
- package/.docs/reference/datasets/getExperiment.md +2 -2
- package/.docs/reference/datasets/getItem.md +3 -3
- package/.docs/reference/datasets/getItemHistory.md +22 -2
- package/.docs/reference/datasets/list.md +7 -3
- package/.docs/reference/datasets/listExperimentResults.md +34 -4
- package/.docs/reference/datasets/listExperiments.md +41 -3
- package/.docs/reference/datasets/listItems.md +18 -6
- package/.docs/reference/datasets/listVersions.md +23 -3
- package/.docs/reference/datasets/startExperiment.md +62 -12
- package/.docs/reference/datasets/startExperimentAsync.md +5 -1
- package/.docs/reference/datasets/update.md +6 -6
- package/.docs/reference/datasets/updateItem.md +5 -5
- package/.docs/reference/deployer.md +8 -8
- package/.docs/reference/evals/answer-relevancy.md +11 -11
- package/.docs/reference/evals/answer-similarity.md +17 -19
- package/.docs/reference/evals/bias.md +10 -10
- package/.docs/reference/evals/completeness.md +3 -3
- package/.docs/reference/evals/content-similarity.md +6 -6
- package/.docs/reference/evals/context-precision.md +4 -4
- package/.docs/reference/evals/context-relevance.md +4 -4
- package/.docs/reference/evals/create-scorer.md +47 -49
- package/.docs/reference/evals/faithfulness.md +11 -11
- package/.docs/reference/evals/hallucination.md +17 -21
- package/.docs/reference/evals/keyword-coverage.md +4 -4
- package/.docs/reference/evals/mastra-scorer.md +14 -14
- package/.docs/reference/evals/noise-sensitivity.md +4 -4
- package/.docs/reference/evals/prompt-alignment.md +4 -4
- package/.docs/reference/evals/run-evals.md +16 -16
- package/.docs/reference/evals/scorer-utils.md +3 -3
- package/.docs/reference/evals/textual-difference.md +3 -3
- package/.docs/reference/evals/tone-consistency.md +3 -3
- package/.docs/reference/evals/tool-call-accuracy.md +5 -5
- package/.docs/reference/evals/toxicity.md +8 -8
- package/.docs/reference/harness/harness-class.md +34 -42
- package/.docs/reference/logging/pino-logger.md +5 -5
- package/.docs/reference/memory/clone-utilities.md +5 -5
- package/.docs/reference/memory/cloneThread.md +17 -21
- package/.docs/reference/memory/createThread.md +10 -10
- package/.docs/reference/memory/deleteMessages.md +2 -2
- package/.docs/reference/memory/getThreadById.md +2 -2
- package/.docs/reference/memory/listThreads.md +5 -5
- package/.docs/reference/memory/memory-class.md +12 -14
- package/.docs/reference/memory/observational-memory.md +102 -94
- package/.docs/reference/memory/recall.md +14 -16
- package/.docs/reference/observability/tracing/configuration.md +27 -10
- package/.docs/reference/observability/tracing/exporters/console-exporter.md +4 -7
- package/.docs/reference/processors/batch-parts-processor.md +8 -10
- package/.docs/reference/processors/language-detector.md +14 -16
- package/.docs/reference/processors/message-history-processor.md +7 -9
- package/.docs/reference/processors/moderation-processor.md +13 -15
- package/.docs/reference/processors/pii-detector.md +14 -16
- package/.docs/reference/processors/processor-interface.md +62 -62
- package/.docs/reference/processors/prompt-injection-detector.md +11 -13
- package/.docs/reference/processors/semantic-recall-processor.md +14 -16
- package/.docs/reference/processors/system-prompt-scrubber.md +12 -14
- package/.docs/reference/processors/token-limiter-processor.md +11 -13
- package/.docs/reference/processors/tool-call-filter.md +5 -7
- package/.docs/reference/processors/tool-search-processor.md +9 -11
- package/.docs/reference/processors/unicode-normalizer.md +8 -10
- package/.docs/reference/processors/working-memory-processor.md +14 -18
- package/.docs/reference/rag/chunk.md +38 -38
- package/.docs/reference/rag/database-config.md +11 -7
- package/.docs/reference/rag/document.md +2 -2
- package/.docs/reference/rag/embeddings.md +12 -12
- package/.docs/reference/rag/extract-params.md +23 -23
- package/.docs/reference/rag/graph-rag.md +12 -12
- package/.docs/reference/rag/rerank.md +25 -17
- package/.docs/reference/rag/rerankWithScorer.md +25 -17
- package/.docs/reference/server/create-route.md +14 -14
- package/.docs/reference/server/express-adapter.md +10 -10
- package/.docs/reference/server/fastify-adapter.md +10 -10
- package/.docs/reference/server/hono-adapter.md +10 -10
- package/.docs/reference/server/koa-adapter.md +10 -10
- package/.docs/reference/server/mastra-server.md +10 -10
- package/.docs/reference/server/register-api-route.md +13 -13
- package/.docs/reference/storage/cloudflare-d1.md +5 -5
- package/.docs/reference/storage/cloudflare.md +6 -6
- package/.docs/reference/storage/composite.md +9 -9
- package/.docs/reference/storage/convex.md +3 -3
- package/.docs/reference/storage/dynamodb.md +9 -9
- package/.docs/reference/storage/lance.md +3 -3
- package/.docs/reference/storage/libsql.md +2 -2
- package/.docs/reference/storage/mongodb.md +5 -5
- package/.docs/reference/storage/mssql.md +2 -2
- package/.docs/reference/storage/postgresql.md +25 -25
- package/.docs/reference/storage/upstash.md +3 -3
- package/.docs/reference/streaming/ChunkType.md +251 -59
- package/.docs/reference/streaming/agents/MastraModelOutput.md +86 -16
- package/.docs/reference/streaming/agents/stream.md +155 -43
- package/.docs/reference/streaming/agents/streamLegacy.md +79 -39
- package/.docs/reference/streaming/workflows/resumeStream.md +18 -8
- package/.docs/reference/streaming/workflows/stream.md +21 -9
- package/.docs/reference/streaming/workflows/timeTravelStream.md +4 -4
- package/.docs/reference/tools/create-tool.md +25 -21
- package/.docs/reference/tools/document-chunker-tool.md +7 -7
- package/.docs/reference/tools/graph-rag-tool.md +16 -18
- package/.docs/reference/tools/mcp-client.md +38 -27
- package/.docs/reference/tools/mcp-server.md +45 -45
- package/.docs/reference/tools/vector-query-tool.md +34 -22
- package/.docs/reference/vectors/astra.md +22 -22
- package/.docs/reference/vectors/chroma.md +44 -44
- package/.docs/reference/vectors/convex.md +26 -26
- package/.docs/reference/vectors/couchbase.md +30 -30
- package/.docs/reference/vectors/duckdb.md +29 -29
- package/.docs/reference/vectors/elasticsearch.md +27 -27
- package/.docs/reference/vectors/lance.md +46 -38
- package/.docs/reference/vectors/libsql.md +31 -31
- package/.docs/reference/vectors/mongodb.md +32 -32
- package/.docs/reference/vectors/opensearch.md +27 -27
- package/.docs/reference/vectors/pg.md +60 -44
- package/.docs/reference/vectors/pinecone.md +38 -38
- package/.docs/reference/vectors/qdrant.md +36 -36
- package/.docs/reference/vectors/s3vectors.md +24 -24
- package/.docs/reference/vectors/turbopuffer.md +29 -29
- package/.docs/reference/vectors/upstash.md +25 -25
- package/.docs/reference/vectors/vectorize.md +27 -27
- package/.docs/reference/voice/azure.md +19 -15
- package/.docs/reference/voice/cloudflare.md +10 -12
- package/.docs/reference/voice/composite-voice.md +10 -10
- package/.docs/reference/voice/deepgram.md +20 -14
- package/.docs/reference/voice/elevenlabs.md +20 -22
- package/.docs/reference/voice/google-gemini-live.md +42 -44
- package/.docs/reference/voice/google.md +25 -21
- package/.docs/reference/voice/mastra-voice.md +20 -20
- package/.docs/reference/voice/murf.md +24 -28
- package/.docs/reference/voice/openai-realtime.md +26 -26
- package/.docs/reference/voice/openai.md +14 -12
- package/.docs/reference/voice/playai.md +13 -15
- package/.docs/reference/voice/sarvam.md +21 -25
- package/.docs/reference/voice/speechify.md +11 -13
- package/.docs/reference/voice/voice.addInstructions.md +1 -1
- package/.docs/reference/voice/voice.addTools.md +1 -1
- package/.docs/reference/voice/voice.answer.md +1 -1
- package/.docs/reference/voice/voice.connect.md +3 -3
- package/.docs/reference/voice/voice.events.md +11 -11
- package/.docs/reference/voice/voice.getSpeakers.md +30 -30
- package/.docs/reference/voice/voice.listen.md +9 -9
- package/.docs/reference/voice/voice.off.md +2 -2
- package/.docs/reference/voice/voice.on.md +2 -2
- package/.docs/reference/voice/voice.send.md +1 -1
- package/.docs/reference/voice/voice.speak.md +11 -11
- package/.docs/reference/voice/voice.updateConfig.md +3 -3
- package/.docs/reference/workflows/run-methods/cancel.md +2 -2
- package/.docs/reference/workflows/run-methods/restart.md +17 -5
- package/.docs/reference/workflows/run-methods/resume.md +23 -9
- package/.docs/reference/workflows/run-methods/start.md +22 -8
- package/.docs/reference/workflows/run-methods/startAsync.md +12 -6
- package/.docs/reference/workflows/run-methods/timeTravel.md +29 -13
- package/.docs/reference/workflows/run.md +12 -12
- package/.docs/reference/workflows/step.md +24 -26
- package/.docs/reference/workflows/workflow-methods/branch.md +2 -2
- package/.docs/reference/workflows/workflow-methods/commit.md +1 -1
- package/.docs/reference/workflows/workflow-methods/create-run.md +4 -4
- package/.docs/reference/workflows/workflow-methods/dountil.md +3 -3
- package/.docs/reference/workflows/workflow-methods/dowhile.md +3 -3
- package/.docs/reference/workflows/workflow-methods/foreach.md +9 -9
- package/.docs/reference/workflows/workflow-methods/map.md +2 -2
- package/.docs/reference/workflows/workflow-methods/parallel.md +2 -2
- package/.docs/reference/workflows/workflow-methods/sleep.md +2 -2
- package/.docs/reference/workflows/workflow-methods/sleepUntil.md +2 -2
- package/.docs/reference/workflows/workflow-methods/then.md +2 -2
- package/.docs/reference/workflows/workflow.md +40 -50
- package/.docs/reference/workspace/daytona-sandbox.md +33 -33
- package/.docs/reference/workspace/e2b-sandbox.md +20 -20
- package/.docs/reference/workspace/filesystem.md +22 -22
- package/.docs/reference/workspace/gcs-filesystem.md +15 -15
- package/.docs/reference/workspace/local-filesystem.md +35 -35
- package/.docs/reference/workspace/local-sandbox.md +26 -26
- package/.docs/reference/workspace/s3-filesystem.md +18 -18
- package/.docs/reference/workspace/sandbox.md +8 -8
- package/.docs/reference/workspace/workspace-class.md +30 -34
- package/CHANGELOG.md +16 -0
- package/package.json +6 -6
- package/.docs/docs/getting-started/start.md +0 -28
|
@@ -13,45 +13,115 @@ For setup and basic usage, see the [.stream()](https://mastra.ai/reference/strea
|
|
|
13
13
|
|
|
14
14
|
These properties provide real-time access to model outputs as they're generated:
|
|
15
15
|
|
|
16
|
-
**fullStream
|
|
16
|
+
**fullStream** (`ReadableStream<ChunkType<OUTPUT>>`): Complete stream of all chunk types including text, tool calls, reasoning, metadata, and control chunks. Provides granular access to every aspect of the model's response.
|
|
17
17
|
|
|
18
|
-
**
|
|
18
|
+
**fullStream.ChunkType** (`ChunkType<OUTPUT>`): All possible chunk types that can be emitted during streaming
|
|
19
19
|
|
|
20
|
-
**
|
|
20
|
+
**textStream** (`ReadableStream<string>`): Stream of incremental text content only. Filters out all metadata, tool calls, and control chunks to provide just the text being generated.
|
|
21
21
|
|
|
22
|
-
**
|
|
22
|
+
**objectStream** (`ReadableStream<Partial<OUTPUT>>`): Stream of progressive structured object updates when using output schemas. Emits partial objects as they're built up, allowing real-time visualization of structured data generation.
|
|
23
|
+
|
|
24
|
+
**objectStream.PartialSchemaOutput** (`Partial<OUTPUT>`): Partially completed object matching the defined schema
|
|
25
|
+
|
|
26
|
+
**elementStream** (`ReadableStream<OUTPUT extends (infer T)[] ? T : never>`): Stream of individual array elements when the output schema defines an array type. Each element is emitted as it's completed rather than waiting for the entire array.
|
|
23
27
|
|
|
24
28
|
## Promise-based Properties
|
|
25
29
|
|
|
26
30
|
These properties resolve to final values after the stream completes:
|
|
27
31
|
|
|
28
|
-
**text
|
|
32
|
+
**text** (`Promise<string>`): The complete concatenated text response from the model. Resolves when text generation is finished.
|
|
33
|
+
|
|
34
|
+
**object** (`Promise<OUTPUT>`): The complete structured object response when using output schemas. Validated against the schema before resolving. Rejects if validation fails.
|
|
35
|
+
|
|
36
|
+
**object.InferSchemaOutput** (`OUTPUT`): Fully typed object matching the exact schema definition
|
|
37
|
+
|
|
38
|
+
**reasoning** (`Promise<string>`): Complete reasoning text for models that support reasoning (like OpenAI's o1 series). Returns empty string for models without reasoning capability.
|
|
39
|
+
|
|
40
|
+
**reasoningText** (`Promise<string | undefined>`): Alternative access to reasoning content. May be undefined for models that don't support reasoning, while 'reasoning' returns empty string.
|
|
41
|
+
|
|
42
|
+
**toolCalls** (`Promise<ToolCallChunk[]>`): Array of all tool call chunks made during execution. Each chunk contains tool metadata and execution details.
|
|
43
|
+
|
|
44
|
+
**toolCalls.type** (`'tool-call'`): Chunk type identifier
|
|
45
|
+
|
|
46
|
+
**toolCalls.runId** (`string`): Execution run identifier
|
|
47
|
+
|
|
48
|
+
**toolCalls.from** (`ChunkFrom`): Source of the chunk (AGENT, WORKFLOW, etc.)
|
|
49
|
+
|
|
50
|
+
**toolCalls.payload** (`ToolCallPayload`): Tool call data including toolCallId, toolName, args, and execution details
|
|
51
|
+
|
|
52
|
+
**toolResults** (`Promise<ToolResultChunk[]>`): Array of all tool result chunks corresponding to the tool calls. Contains execution results and error information.
|
|
53
|
+
|
|
54
|
+
**toolResults.type** (`'tool-result'`): Chunk type identifier
|
|
55
|
+
|
|
56
|
+
**toolResults.runId** (`string`): Execution run identifier
|
|
57
|
+
|
|
58
|
+
**toolResults.from** (`ChunkFrom`): Source of the chunk (AGENT, WORKFLOW, etc.)
|
|
59
|
+
|
|
60
|
+
**toolResults.payload** (`ToolResultPayload`): Tool result data including toolCallId, toolName, result, and error status
|
|
61
|
+
|
|
62
|
+
**usage** (`Promise<LanguageModelUsage>`): Token usage statistics including input tokens, output tokens, total tokens, and reasoning tokens (for reasoning models).
|
|
63
|
+
|
|
64
|
+
**usage.inputTokens** (`number`): Tokens consumed by the input prompt
|
|
29
65
|
|
|
30
|
-
**
|
|
66
|
+
**usage.outputTokens** (`number`): Tokens generated in the response
|
|
31
67
|
|
|
32
|
-
**
|
|
68
|
+
**usage.totalTokens** (`number`): Sum of input and output tokens
|
|
33
69
|
|
|
34
|
-
**
|
|
70
|
+
**usage.reasoningTokens** (`number`): Hidden reasoning tokens (for reasoning models)
|
|
35
71
|
|
|
36
|
-
**
|
|
72
|
+
**usage.cachedInputTokens** (`number`): Number of input tokens that were a cache hit
|
|
37
73
|
|
|
38
|
-
**
|
|
74
|
+
**finishReason** (`Promise<string | undefined>`): Reason why generation stopped (e.g., 'stop', 'length', 'tool\_calls', 'content\_filter'). Undefined if the stream hasn't finished.
|
|
39
75
|
|
|
40
|
-
**
|
|
76
|
+
**finishReason.stop** (`'stop'`): Model finished naturally
|
|
41
77
|
|
|
42
|
-
**finishReason
|
|
78
|
+
**finishReason.length** (`'length'`): Hit maximum token limit
|
|
43
79
|
|
|
44
|
-
**
|
|
80
|
+
**finishReason.tool\_calls** (`'tool_calls'`): Model called tools
|
|
81
|
+
|
|
82
|
+
**finishReason.content\_filter** (`'content_filter'`): Content was filtered
|
|
83
|
+
|
|
84
|
+
**response** (`Promise<Response>`): Response metadata and messages from the model provider.
|
|
85
|
+
|
|
86
|
+
**response.id** (`string`): Response ID from the model provider
|
|
87
|
+
|
|
88
|
+
**response.timestamp** (`Date`): Response timestamp
|
|
89
|
+
|
|
90
|
+
**response.modelId** (`string`): Model identifier used for this response
|
|
91
|
+
|
|
92
|
+
**response.headers** (`Record<string, string>`): Response headers from the model provider
|
|
93
|
+
|
|
94
|
+
**response.messages** (`ResponseMessage[]`): Response messages in model format
|
|
95
|
+
|
|
96
|
+
**response.uiMessages** (`UIMessage[]`): Response messages in UI format, includes any metadata added by output processors
|
|
45
97
|
|
|
46
98
|
## Error Properties
|
|
47
99
|
|
|
48
|
-
**error
|
|
100
|
+
**error** (`string | Error | { message: string; stack: string; } | undefined`): Error information if the stream encountered an error. Undefined if no errors occurred. Can be a string message, Error object, or serialized error with stack trace.
|
|
49
101
|
|
|
50
102
|
## Methods
|
|
51
103
|
|
|
52
|
-
**getFullOutput
|
|
104
|
+
**getFullOutput** (`() => Promise<FullOutput>`): Returns a comprehensive output object containing all results: text, structured object, tool calls, usage statistics, reasoning, and metadata. Convenient single method to access all stream results.
|
|
105
|
+
|
|
106
|
+
**getFullOutput.text** (`string`): Complete text response
|
|
107
|
+
|
|
108
|
+
**getFullOutput.object** (`OUTPUT`): Structured output if schema was provided
|
|
109
|
+
|
|
110
|
+
**getFullOutput.toolCalls** (`ToolCallChunk[]`): All tool call chunks made
|
|
111
|
+
|
|
112
|
+
**getFullOutput.toolResults** (`ToolResultChunk[]`): All tool result chunks
|
|
113
|
+
|
|
114
|
+
**getFullOutput.usage** (`Record<string, number>`): Token usage statistics
|
|
115
|
+
|
|
116
|
+
**getFullOutput.reasoning** (`string`): Reasoning text if available
|
|
117
|
+
|
|
118
|
+
**getFullOutput.finishReason** (`string`): Why generation finished
|
|
119
|
+
|
|
120
|
+
**getFullOutput.response** (`Response`): Response metadata and messages from the model provider
|
|
121
|
+
|
|
122
|
+
**consumeStream** (`(options?: ConsumeStreamOptions) => Promise<void>`): Manually consume the entire stream without processing chunks. Useful when you only need the final promise-based results and want to trigger stream consumption.
|
|
53
123
|
|
|
54
|
-
**consumeStream
|
|
124
|
+
**consumeStream.onError** (`(error: Error) => void`): Callback for handling stream errors
|
|
55
125
|
|
|
56
126
|
## Usage Examples
|
|
57
127
|
|
|
@@ -12,93 +12,205 @@ const stream = await agent.stream('message for agent')
|
|
|
12
12
|
|
|
13
13
|
## Parameters
|
|
14
14
|
|
|
15
|
-
**messages
|
|
15
|
+
**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.
|
|
16
16
|
|
|
17
|
-
**options
|
|
17
|
+
**options** (`AgentExecutionOptions<Output, Format>`): Optional configuration for the streaming process.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
**options.maxSteps** (`number`): Maximum number of steps to run during execution.
|
|
20
20
|
|
|
21
|
-
**
|
|
21
|
+
**options.scorers** (`MastraScorers | Record<string, { scorer: MastraScorer['name']; sampling?: ScoringSamplingConfig }>`): Evaluation scorers to run on the execution results.
|
|
22
22
|
|
|
23
|
-
**scorers
|
|
23
|
+
**options.scorers.scorer** (`string`): Name of the scorer to use.
|
|
24
24
|
|
|
25
|
-
**
|
|
25
|
+
**options.scorers.sampling** (`ScoringSamplingConfig`): Sampling configuration for the scorer.
|
|
26
26
|
|
|
27
|
-
**
|
|
27
|
+
**options.scorers.sampling.type** (`'none' | 'ratio'`): Type of sampling strategy. Use 'none' to disable sampling or 'ratio' for percentage-based sampling.
|
|
28
28
|
|
|
29
|
-
**
|
|
29
|
+
**options.scorers.sampling.rate** (`number`): Sampling rate (0-1). Required when type is 'ratio'.
|
|
30
30
|
|
|
31
|
-
**
|
|
31
|
+
**options.onIterationComplete** (`(context: IterationCompleteContext) => { continue?: boolean; feedback?: string } | void | Promise<{ continue?: boolean; feedback?: string } | void>`): Callback function called after each iteration completes. Use this to monitor progress, provide feedback to guide the agent, or stop execution early. The callback receives context about the iteration including the current text, tool calls, and finish reason.
|
|
32
32
|
|
|
33
|
-
**
|
|
33
|
+
**options.onIterationComplete.context.iteration** (`number`): Current iteration number (1-based).
|
|
34
34
|
|
|
35
|
-
**
|
|
35
|
+
**options.onIterationComplete.context.maxIterations** (`number | undefined`): Maximum iterations allowed (if set).
|
|
36
36
|
|
|
37
|
-
**
|
|
37
|
+
**options.onIterationComplete.context.text** (`string`): The text response from this iteration.
|
|
38
38
|
|
|
39
|
-
**
|
|
39
|
+
**options.onIterationComplete.context.isFinal** (`boolean`): Whether this is the final iteration.
|
|
40
40
|
|
|
41
|
-
**
|
|
41
|
+
**options.onIterationComplete.context.finishReason** (`string`): Reason why this iteration finished (e.g., 'stop', 'length', 'tool-calls').
|
|
42
42
|
|
|
43
|
-
**
|
|
43
|
+
**options.onIterationComplete.context.toolCalls** (`ToolCall[]`): Tool calls made in this iteration.
|
|
44
44
|
|
|
45
|
-
**
|
|
45
|
+
**options.onIterationComplete.context.messages** (`MastraDBMessage[]`): All messages accumulated so far.
|
|
46
46
|
|
|
47
|
-
**
|
|
47
|
+
**options.onIterationComplete.return.continue** (`boolean`): Set to false to stop execution early.
|
|
48
48
|
|
|
49
|
-
**
|
|
49
|
+
**options.onIterationComplete.return.feedback** (`string`): Feedback message to guide the agent's next iteration.
|
|
50
50
|
|
|
51
|
-
**
|
|
51
|
+
**options.isTaskComplete** (`IsTaskCompleteConfig`): Task completion scoring configuration that validates whether the task is complete. Uses Mastra's evaluation scorers to automatically check if the agent's response satisfies the completion criteria.
|
|
52
52
|
|
|
53
|
-
**
|
|
53
|
+
**options.isTaskComplete.scorers** (`MastraScorer[]`): Array of scorers that evaluate task completion. Each scorer returns 0 (failed) or 1 (passed).
|
|
54
54
|
|
|
55
|
-
**
|
|
55
|
+
**options.isTaskComplete.strategy** (`'all' | 'any'`): Strategy for combining scorer results. 'all' requires all scorers to pass, 'any' requires at least one.
|
|
56
56
|
|
|
57
|
-
**
|
|
57
|
+
**options.isTaskComplete.onComplete** (`(result: IsTaskCompleteRunResult) => void | Promise<void>`): Callback called when the task completion check finishes. Receives the result with individual scorer scores.
|
|
58
58
|
|
|
59
|
-
**
|
|
59
|
+
**options.isTaskComplete.parallel** (`boolean`): Whether to run scorers in parallel.
|
|
60
60
|
|
|
61
|
-
**
|
|
61
|
+
**options.isTaskComplete.timeout** (`number`): Maximum time in milliseconds to wait for all scorers to complete.
|
|
62
62
|
|
|
63
|
-
**
|
|
63
|
+
**options.delegation** (`DelegationConfig`): Configuration for subagent delegation. Use this to control and monitor when the agent delegates tasks to other agents, including the ability to modify, reject delegations, and provide feedback to guide the supervisor.
|
|
64
64
|
|
|
65
|
-
**
|
|
65
|
+
**options.delegation.onDelegationStart** (`(context: DelegationStartContext) => DelegationStartResult | void | Promise<DelegationStartResult | void>`): Called before delegating to a subagent. Use this to modify the delegation parameters or reject the delegation entirely.
|
|
66
66
|
|
|
67
|
-
**
|
|
67
|
+
**options.delegation.onDelegationComplete** (`(context: DelegationCompleteContext) => { feedback?: string } | void | Promise<{ feedback?: string } | void>`): Called after a subagent delegation completes. The context includes a \`bail()\` method to stop further execution, and you can return \`{ feedback }\` to guide the supervisor's next action. Feedback is saved to supervisor memory as an assistant message.
|
|
68
68
|
|
|
69
|
-
**
|
|
69
|
+
**options.delegation.messageFilter** (`(context: MessageFilterContext) => MastraDBMessage[] | Promise<MastraDBMessage[]>`): Callback function called before delegating to a subagent. Use this to filter the messages that are passed to the subagent.
|
|
70
70
|
|
|
71
|
-
**
|
|
71
|
+
**options.tracingContext** (`TracingContext`): Tracing context for span hierarchy and metadata.
|
|
72
72
|
|
|
73
|
-
**
|
|
73
|
+
**options.returnScorerData** (`boolean`): Whether to return detailed scoring data in the response.
|
|
74
74
|
|
|
75
|
-
**
|
|
75
|
+
**options.onChunk** (`(chunk: ChunkType) => Promise<void> | void`): Callback function called for each chunk during streaming.
|
|
76
76
|
|
|
77
|
-
**
|
|
77
|
+
**options.onError** (`({ error }: { error: Error | string }) => Promise<void> | void`): Callback function called when an error occurs during streaming.
|
|
78
78
|
|
|
79
|
-
**
|
|
79
|
+
**options.onAbort** (`(event: any) => Promise<void> | void`): Callback function called when the stream is aborted.
|
|
80
80
|
|
|
81
|
-
**
|
|
81
|
+
**options.abortSignal** (`AbortSignal`): Signal object that allows you to abort the agent's execution. When the signal is aborted, all ongoing operations will be terminated.
|
|
82
82
|
|
|
83
|
-
**
|
|
83
|
+
**options.activeTools** (`Array<keyof ToolSet> | undefined`): Array of active tool names that can be used during execution.
|
|
84
84
|
|
|
85
|
-
**
|
|
85
|
+
**options.prepareStep** (`PrepareStepFunction<any>`): Callback function called before each step of multi-step execution.
|
|
86
86
|
|
|
87
|
-
**
|
|
87
|
+
**options.context** (`ModelMessage[]`): Additional context messages to provide to the agent.
|
|
88
88
|
|
|
89
|
-
**
|
|
89
|
+
**options.structuredOutput** (`StructuredOutputOptions<S extends ZodTypeAny = ZodTypeAny>`): Options to fine tune your structured output generation.
|
|
90
90
|
|
|
91
|
-
**
|
|
91
|
+
**options.structuredOutput.schema** (`z.ZodSchema<S>`): Zod schema defining the expected output structure.
|
|
92
92
|
|
|
93
|
-
**
|
|
93
|
+
**options.structuredOutput.model** (`MastraLanguageModel`): Language model to use for structured output generation. If provided, enables the agent to respond in multi step with tool calls, text, and structured output
|
|
94
94
|
|
|
95
|
-
**
|
|
95
|
+
**options.structuredOutput.errorStrategy** (`'strict' | 'warn' | 'fallback'`): Strategy for handling schema validation errors. 'strict' throws errors, 'warn' logs warnings, 'fallback' uses fallback values.
|
|
96
|
+
|
|
97
|
+
**options.structuredOutput.fallbackValue** (`<S extends ZodTypeAny>`): Fallback value to use when schema validation fails and errorStrategy is 'fallback'.
|
|
98
|
+
|
|
99
|
+
**options.structuredOutput.instructions** (`string`): Additional instructions for the structured output model.
|
|
100
|
+
|
|
101
|
+
**options.structuredOutput.jsonPromptInjection** (`boolean`): Injects system prompt into the main agent instructing it to return structured output, useful for when a model does not natively support structured outputs.
|
|
102
|
+
|
|
103
|
+
**options.structuredOutput.providerOptions** (`ProviderOptions`): Provider-specific options passed to the internal structuring agent. Use this to control model behavior like reasoning effort for thinking models (e.g., \`{ openai: { reasoningEffort: 'low' } }\`).
|
|
104
|
+
|
|
105
|
+
**options.outputProcessors** (`Processor[]`): Overrides the output processors set on the agent. Output processors that can modify or validate messages from the agent before they are returned to the user. Must implement either (or both) of the \`processOutputResult\` and \`processOutputStream\` functions.
|
|
106
|
+
|
|
107
|
+
**options.includeRawChunks** (`boolean`): Whether to include raw chunks in the stream output (not available on all model providers).
|
|
108
|
+
|
|
109
|
+
**options.inputProcessors** (`Processor[]`): Overrides the input processors set on the agent. Input processors that can modify or validate messages before they are processed by the agent. Must implement the \`processInput\` function.
|
|
110
|
+
|
|
111
|
+
**options.instructions** (`string`): Custom instructions that override the agent's default instructions for this specific generation. Useful for dynamically modifying agent behavior without creating a new agent instance.
|
|
112
|
+
|
|
113
|
+
**options.system** (`string | string[] | CoreSystemMessage | SystemModelMessage | CoreSystemMessage[] | SystemModelMessage[]`): Custom system message(s) to include in the prompt. Can be a single string, message object, or array of either. System messages provide additional context or behavior instructions that supplement the agent's main instructions.
|
|
114
|
+
|
|
115
|
+
**options.output** (`Zod schema | JsonSchema7`): \*\*Deprecated.\*\* Use structuredOutput without a model to achieve the same thing. Defines the expected structure of the output. Can be a JSON Schema object or a Zod schema.
|
|
116
|
+
|
|
117
|
+
**options.memory** (`object`): Configuration for memory. This is the preferred way to manage memory.
|
|
118
|
+
|
|
119
|
+
**options.memory.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\`.
|
|
120
|
+
|
|
121
|
+
**options.memory.resource** (`string`): Identifier for the user or resource associated with the thread.
|
|
122
|
+
|
|
123
|
+
**options.memory.options** (`MemoryConfig`): Configuration for memory behavior including lastMessages, readOnly, semanticRecall, and workingMemory.
|
|
124
|
+
|
|
125
|
+
**options.onFinish** (`StreamTextOnFinishCallback<any> | StreamObjectOnFinishCallback<OUTPUT>`): Callback function called when streaming completes. Receives the final result.
|
|
126
|
+
|
|
127
|
+
**options.onStepFinish** (`StreamTextOnStepFinishCallback<any> | never`): Callback function called after each execution step. Receives step details as a JSON string. Unavailable for structured output
|
|
128
|
+
|
|
129
|
+
**options.telemetry** (`TelemetrySettings`): Settings for OTLP telemetry collection during streaming (not Tracing).
|
|
130
|
+
|
|
131
|
+
**options.telemetry.isEnabled** (`boolean`): Enable or disable telemetry. Disabled by default while experimental.
|
|
132
|
+
|
|
133
|
+
**options.telemetry.recordInputs** (`boolean`): Enable or disable input recording. Enabled by default. You might want to disable input recording to avoid recording sensitive information.
|
|
134
|
+
|
|
135
|
+
**options.telemetry.recordOutputs** (`boolean`): Enable or disable output recording. Enabled by default. You might want to disable output recording to avoid recording sensitive information.
|
|
136
|
+
|
|
137
|
+
**options.telemetry.functionId** (`string`): Identifier for this function. Used to group telemetry data by function.
|
|
138
|
+
|
|
139
|
+
**options.modelSettings** (`CallSettings`): Model-specific settings like temperature, maxOutputTokens, topP, etc. These settings control how the language model generates responses.
|
|
140
|
+
|
|
141
|
+
**options.modelSettings.temperature** (`number`): Controls randomness in generation (0-2). Higher values make output more random.
|
|
142
|
+
|
|
143
|
+
**options.modelSettings.maxOutputTokens** (`number`): Maximum number of tokens to generate in the response. Note: Use maxOutputTokens (not maxTokens) as per AI SDK v5 convention.
|
|
144
|
+
|
|
145
|
+
**options.modelSettings.maxRetries** (`number`): Maximum number of retry attempts for failed requests.
|
|
146
|
+
|
|
147
|
+
**options.modelSettings.topP** (`number`): Nucleus sampling parameter (0-1). Controls diversity of generated text.
|
|
148
|
+
|
|
149
|
+
**options.modelSettings.topK** (`number`): Top-k sampling parameter. Limits vocabulary to k most likely tokens.
|
|
150
|
+
|
|
151
|
+
**options.modelSettings.presencePenalty** (`number`): Penalty for token presence (-2 to 2). Reduces repetition.
|
|
152
|
+
|
|
153
|
+
**options.modelSettings.frequencyPenalty** (`number`): Penalty for token frequency (-2 to 2). Reduces repetition of frequent tokens.
|
|
154
|
+
|
|
155
|
+
**options.modelSettings.stopSequences** (`string[]`): Stop sequences. If set, the model will stop generating text when one of the stop sequences is generated.
|
|
156
|
+
|
|
157
|
+
**options.toolChoice** (`'auto' | 'none' | 'required' | { type: 'tool'; toolName: string }`): Controls how the agent uses tools during streaming.
|
|
158
|
+
|
|
159
|
+
**options.toolChoice.'auto'** (`string`): Let the model decide whether to use tools (default).
|
|
160
|
+
|
|
161
|
+
**options.toolChoice.'none'** (`string`): Do not use any tools.
|
|
162
|
+
|
|
163
|
+
**options.toolChoice.'required'** (`string`): Require the model to use at least one tool.
|
|
164
|
+
|
|
165
|
+
**options.toolChoice.{ type: 'tool'; toolName: string }** (`object`): Require the model to use a specific tool by name.
|
|
166
|
+
|
|
167
|
+
**options.toolsets** (`ToolsetsInput`): Additional toolsets to make available to the agent during streaming.
|
|
168
|
+
|
|
169
|
+
**options.clientTools** (`ToolsInput`): Tools that are executed on the 'client' side of the request. These tools do not have execute functions in the definition.
|
|
170
|
+
|
|
171
|
+
**options.savePerStep** (`boolean`): Save messages incrementally after each stream step completes (default: false).
|
|
172
|
+
|
|
173
|
+
**options.requireToolApproval** (`boolean`): When true, all tool calls require explicit approval before execution. The stream will emit \`tool-call-approval\` chunks and pause until \`approveToolCall()\` or \`declineToolCall()\` is called.
|
|
174
|
+
|
|
175
|
+
**options.autoResumeSuspendedTools** (`boolean`): When true, automatically resumes suspended tools when the user sends a new message on the same thread. The agent extracts \`resumeData\` from the user's message based on the tool's \`resumeSchema\`. Requires memory to be configured.
|
|
176
|
+
|
|
177
|
+
**options.toolCallConcurrency** (`number`): Maximum number of tool calls to execute concurrently. Defaults to 1 when approval may be required, otherwise 10.
|
|
178
|
+
|
|
179
|
+
**options.providerOptions** (`Record<string, Record<string, JSONValue>>`): Additional provider-specific options that are passed through to the underlying LLM provider. The structure is \`{ providerName: { optionKey: value } }\`. For example: \`{ openai: { reasoningEffort: 'high' }, anthropic: { maxTokens: 1000 } }\`.
|
|
180
|
+
|
|
181
|
+
**options.providerOptions.openai** (`Record<string, JSONValue>`): OpenAI-specific options. Example: \`{ reasoningEffort: 'high' }\`
|
|
182
|
+
|
|
183
|
+
**options.providerOptions.anthropic** (`Record<string, JSONValue>`): Anthropic-specific options. Example: \`{ maxTokens: 1000 }\`
|
|
184
|
+
|
|
185
|
+
**options.providerOptions.google** (`Record<string, JSONValue>`): Google-specific options. Example: \`{ safetySettings: \[...] }\`
|
|
186
|
+
|
|
187
|
+
**options.providerOptions.\[providerName]** (`Record<string, JSONValue>`): Other provider-specific options. The key is the provider name and the value is a record of provider-specific options.
|
|
188
|
+
|
|
189
|
+
**options.runId** (`string`): Unique ID for this generation run. Useful for tracking and debugging purposes.
|
|
190
|
+
|
|
191
|
+
**options.requestContext** (`RequestContext`): Request Context for dependency injection and contextual information.
|
|
192
|
+
|
|
193
|
+
**options.tracingContext** (`TracingContext`): Tracing context for creating child spans and adding metadata. Automatically injected when using Mastra's tracing system.
|
|
194
|
+
|
|
195
|
+
**options.tracingContext.currentSpan** (`Span`): Current span for creating child spans and adding metadata. Use this to create custom child spans or update span attributes during execution.
|
|
196
|
+
|
|
197
|
+
**options.tracingOptions** (`TracingOptions`): Options for Tracing configuration.
|
|
198
|
+
|
|
199
|
+
**options.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.
|
|
200
|
+
|
|
201
|
+
**options.tracingOptions.requestContextKeys** (`string[]`): Additional RequestContext keys to extract as metadata for this trace. Supports dot notation for nested values (e.g., 'user.id').
|
|
202
|
+
|
|
203
|
+
**options.tracingOptions.traceId** (`string`): Trace ID to use for this execution (1-32 hexadecimal characters). If provided, this trace will be part of the specified trace.
|
|
204
|
+
|
|
205
|
+
**options.tracingOptions.parentSpanId** (`string`): Parent 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.
|
|
206
|
+
|
|
207
|
+
**options.tracingOptions.tags** (`string[]`): Tags to apply to this trace. String labels for categorizing and filtering traces.
|
|
96
208
|
|
|
97
209
|
## Returns
|
|
98
210
|
|
|
99
|
-
**stream
|
|
211
|
+
**stream** (`MastraModelOutput<Output>`): Returns a MastraModelOutput instance that provides access to the streaming output.
|
|
100
212
|
|
|
101
|
-
**traceId
|
|
213
|
+
**traceId** (`string`): The trace ID associated with this execution when Tracing is enabled. Use this to correlate logs and debug execution flow.
|
|
102
214
|
|
|
103
215
|
## Extended usage example
|
|
104
216
|
|