@mastra/mcp-docs-server 1.2.4 → 1.2.5-alpha.3
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/agent-builder/deploying.md +1 -1
- package/.docs/docs/agent-controller/overview.md +1 -1
- package/.docs/docs/agent-controller/session.md +1 -1
- package/.docs/docs/agents/overview.md +1 -1
- package/.docs/docs/agents/processors.md +1 -1
- package/.docs/docs/agents/supervisor-agents.md +3 -3
- package/.docs/docs/agents/using-tools.md +1 -1
- package/.docs/docs/{agents → long-running-agents}/background-tasks.md +2 -2
- package/.docs/docs/{agents → long-running-agents}/durable-agents.md +2 -2
- package/.docs/docs/{agents → long-running-agents}/goals.md +1 -1
- package/.docs/docs/{agents → long-running-agents}/heartbeats.md +5 -5
- package/.docs/docs/{agents → long-running-agents}/signal-providers.md +4 -4
- package/.docs/docs/memory/working-memory.md +1 -1
- package/.docs/docs/observability/config.md +1 -2
- package/.docs/docs/server/pubsub.md +2 -2
- package/.docs/docs/voice/overview.md +3 -3
- package/.docs/docs/voice/speech-to-speech.md +81 -1
- package/.docs/docs/voice/speech-to-text.md +19 -1
- package/.docs/docs/voice/text-to-speech.md +21 -1
- package/.docs/docs/workflows/control-flow.md +1 -1
- package/.docs/docs/workflows/error-handling.md +1 -1
- package/.docs/docs/workflows/human-in-the-loop.md +1 -1
- package/.docs/docs/workflows/overview.md +1 -1
- package/.docs/docs/workflows/snapshots.md +1 -1
- package/.docs/docs/workflows/suspend-and-resume.md +1 -1
- package/.docs/docs/workflows/time-travel.md +1 -1
- package/.docs/docs/workflows/workflow-state.md +1 -1
- package/.docs/guides/build-your-ui/copilotkit/channels.md +76 -0
- package/.docs/guides/build-your-ui/copilotkit/generative-ui.md +174 -0
- package/.docs/guides/build-your-ui/copilotkit/overview.md +411 -0
- package/.docs/guides/concepts/streaming.md +1 -1
- package/.docs/guides/deployment/vercel.md +1 -2
- package/.docs/guides/guide/signal-provider.md +5 -5
- package/.docs/models/environment-variables.md +2 -0
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/alibaba-cn.md +2 -1
- package/.docs/models/providers/friendli.md +1 -2
- package/.docs/models/providers/kenari.md +95 -0
- package/.docs/models/providers/nvidia.md +2 -3
- package/.docs/models/providers/tencent-token-plan.md +7 -7
- package/.docs/models/providers/tencent-tokenhub.md +5 -4
- package/.docs/models/providers.md +2 -0
- package/.docs/reference/acp/acp-agent.md +5 -5
- package/.docs/reference/acp/create-acp-tool.md +5 -5
- package/.docs/reference/agent-controller/agent-controller-class.md +27 -27
- package/.docs/reference/agents/agent.md +34 -34
- package/.docs/reference/agents/channels.md +19 -19
- package/.docs/reference/agents/createSkill.md +2 -2
- package/.docs/reference/agents/durable-agent.md +22 -22
- package/.docs/reference/agents/generate.md +10 -10
- package/.docs/reference/agents/generateLegacy.md +12 -12
- package/.docs/reference/agents/getMetadata.md +1 -1
- package/.docs/reference/agents/getVoice.md +1 -1
- package/.docs/reference/agents/inngest-agent.md +9 -9
- package/.docs/reference/agents/network.md +1 -1
- package/.docs/reference/ai-sdk/chat-route.md +4 -4
- package/.docs/reference/ai-sdk/handle-chat-stream.md +6 -6
- package/.docs/reference/ai-sdk/handle-network-stream.md +3 -3
- package/.docs/reference/ai-sdk/handle-workflow-stream.md +1 -1
- package/.docs/reference/ai-sdk/network-route.md +4 -4
- package/.docs/reference/ai-sdk/to-ai-sdk-messages.md +1 -1
- package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +1 -1
- package/.docs/reference/ai-sdk/with-mastra.md +2 -2
- package/.docs/reference/ai-sdk/workflow-route.md +2 -2
- package/.docs/reference/ai-sdk/workflow-snapshot-to-stream.md +1 -1
- package/.docs/reference/auth/google.md +10 -10
- package/.docs/reference/auth/okta.md +11 -11
- package/.docs/reference/auth/workos.md +3 -3
- package/.docs/reference/channels/slack-provider.md +15 -15
- package/.docs/reference/cli/mastra.md +145 -0
- package/.docs/reference/client-js/agents.md +9 -9
- package/.docs/reference/client-js/mastra-client.md +5 -5
- package/.docs/reference/client-js/responses.md +3 -3
- package/.docs/reference/configuration.md +1 -1
- package/.docs/reference/core/getAgentById.md +3 -3
- package/.docs/reference/core/getWorkflow.md +1 -1
- package/.docs/reference/core/listWorkflows.md +1 -1
- package/.docs/reference/core/mastra-class.md +3 -3
- package/.docs/reference/core/removeWorkspace.md +2 -2
- package/.docs/reference/datasets/compareExperiments.md +1 -1
- package/.docs/reference/datasets/getItemHistory.md +1 -1
- package/.docs/reference/datasets/list.md +5 -5
- package/.docs/reference/datasets/listExperimentResults.md +4 -4
- package/.docs/reference/datasets/listExperiments.md +4 -4
- package/.docs/reference/datasets/listItems.md +5 -5
- package/.docs/reference/datasets/listVersions.md +3 -3
- package/.docs/reference/datasets/startExperiment.md +8 -8
- package/.docs/reference/datasets/startExperimentAsync.md +1 -1
- package/.docs/reference/editor/agent-builder/agent-builder-options.md +4 -4
- package/.docs/reference/editor/agent-builder/builder-agent-defaults.md +7 -7
- package/.docs/reference/editor/agent-builder/builder-models.md +4 -4
- package/.docs/reference/editor/blob-store-provider.md +2 -2
- package/.docs/reference/editor/browser-provider.md +2 -2
- package/.docs/reference/editor/filesystem-provider.md +2 -2
- package/.docs/reference/editor/mastra-editor.md +2 -2
- package/.docs/reference/editor/processor-provider.md +4 -4
- package/.docs/reference/editor/sandbox-provider.md +2 -2
- package/.docs/reference/editor/storage-browser-ref.md +2 -2
- package/.docs/reference/editor/storage-workspace-ref.md +7 -7
- package/.docs/reference/evals/create-scorer.md +8 -8
- package/.docs/reference/evals/rubric.md +1 -1
- package/.docs/reference/evals/run-evals.md +7 -7
- package/.docs/reference/evals/trajectory-accuracy.md +1 -1
- package/.docs/reference/index.md +2 -2
- package/.docs/reference/logging/pino-logger.md +4 -4
- package/.docs/reference/memory/cloneThread.md +35 -4
- package/.docs/reference/memory/memory-class.md +5 -5
- package/.docs/reference/memory/observational-memory.md +43 -43
- package/.docs/reference/memory/recall.md +4 -4
- package/.docs/reference/memory/serialized-memory-config.md +6 -6
- package/.docs/reference/observability/tracing/configuration.md +4 -4
- package/.docs/reference/processors/language-detector.md +1 -1
- package/.docs/reference/processors/moderation-processor.md +1 -1
- package/.docs/reference/processors/pii-detector.md +1 -1
- package/.docs/reference/processors/processor-interface.md +20 -20
- package/.docs/reference/processors/prompt-injection-detector.md +1 -1
- package/.docs/reference/processors/response-cache.md +6 -6
- package/.docs/reference/processors/unicode-normalizer.md +1 -1
- package/.docs/reference/pubsub/base.md +7 -7
- package/.docs/reference/pubsub/caching-pubsub.md +1 -1
- package/.docs/reference/pubsub/event-emitter.md +2 -2
- package/.docs/reference/pubsub/google-cloud-pubsub.md +1 -1
- package/.docs/reference/pubsub/lease-provider.md +3 -3
- package/.docs/reference/pubsub/redis-streams.md +6 -6
- package/.docs/reference/pubsub/unix-socket-pubsub.md +1 -1
- package/.docs/reference/rag/chunk.md +2 -2
- package/.docs/reference/server/create-route.md +3 -3
- package/.docs/reference/server/express-adapter.md +4 -4
- package/.docs/reference/server/fastify-adapter.md +4 -4
- package/.docs/reference/server/hono-adapter.md +4 -4
- package/.docs/reference/server/koa-adapter.md +4 -4
- package/.docs/reference/server/mastra-server.md +1 -1
- package/.docs/reference/server/nestjs-adapter.md +3 -3
- package/.docs/reference/server/register-api-route.md +3 -3
- package/.docs/reference/signals/create-notification-inbox-tool.md +3 -3
- package/.docs/reference/signals/signal-provider.md +7 -7
- package/.docs/reference/signals/webhook-signal-provider.md +2 -2
- package/.docs/reference/storage/clickhouse.md +7 -7
- package/.docs/reference/storage/composite.md +2 -2
- package/.docs/reference/storage/duckdb.md +1 -1
- package/.docs/reference/storage/dynamodb.md +1 -1
- package/.docs/reference/storage/libsql.md +1 -1
- package/.docs/reference/storage/postgresql.md +2 -2
- package/.docs/reference/storage/redis.md +2 -2
- package/.docs/reference/storage/retention.md +5 -5
- package/.docs/reference/storage/spanner.md +6 -6
- package/.docs/reference/streaming/ChunkType.md +3 -3
- package/.docs/reference/streaming/agents/stream.md +14 -14
- package/.docs/reference/streaming/agents/streamLegacy.md +10 -10
- package/.docs/reference/streaming/agents/streamUntilIdle.md +1 -1
- package/.docs/reference/streaming/workflows/resumeStream.md +1 -1
- package/.docs/reference/templates/overview.md +1 -140
- package/.docs/reference/tools/brightdata.md +4 -4
- package/.docs/reference/tools/create-code-mode.md +5 -5
- package/.docs/reference/tools/create-tool.md +15 -15
- package/.docs/reference/tools/graph-rag-tool.md +1 -1
- package/.docs/reference/tools/mcp-client.md +2 -2
- package/.docs/reference/tools/mcp-server.md +12 -12
- package/.docs/reference/tools/perplexity.md +3 -3
- package/.docs/reference/tools/tavily.md +1 -1
- package/.docs/reference/tools/vector-query-tool.md +1 -1
- package/.docs/reference/vectors/chroma.md +1 -1
- package/.docs/reference/vectors/mongodb.md +1 -1
- package/.docs/reference/vectors/pg.md +1 -1
- package/.docs/reference/vectors/s3vectors.md +4 -4
- package/.docs/reference/voice/google-gemini-live.md +3 -3
- package/.docs/reference/voice/inworld-realtime.md +12 -12
- package/.docs/reference/voice/inworld.md +2 -2
- package/.docs/reference/voice/voice.on.md +1 -1
- package/.docs/reference/workflows/run-methods/resume.md +1 -1
- package/.docs/reference/workflows/run-methods/timeTravel.md +1 -1
- package/.docs/reference/workspace/agentcore-runtime-sandbox.md +4 -4
- package/.docs/reference/workspace/agentfs-filesystem.md +1 -1
- package/.docs/reference/workspace/apple-container-sandbox.md +5 -5
- package/.docs/reference/workspace/archil-filesystem.md +5 -5
- package/.docs/reference/workspace/blaxel-sandbox.md +1 -1
- package/.docs/reference/workspace/daytona-sandbox.md +1 -1
- package/.docs/reference/workspace/docker-sandbox.md +2 -2
- package/.docs/reference/workspace/e2b-sandbox.md +2 -2
- package/.docs/reference/workspace/files-sdk-filesystem.md +1 -1
- package/.docs/reference/workspace/filesystem.md +1 -1
- package/.docs/reference/workspace/local-filesystem.md +3 -3
- package/.docs/reference/workspace/local-sandbox.md +1 -1
- package/.docs/reference/workspace/mesa-filesystem.md +3 -3
- package/.docs/reference/workspace/modal-sandbox.md +1 -1
- package/.docs/reference/workspace/railway-sandbox.md +1 -1
- package/.docs/reference/workspace/s3-filesystem.md +4 -4
- package/.docs/reference/workspace/sandbox.md +1 -1
- package/.docs/reference/workspace/{vercel-microvm-sandbox.md → vercel-sandbox.md} +21 -15
- package/.docs/reference/workspace/{vercel.md → vercel-serverless.md} +21 -14
- package/.docs/reference/workspace/workspace-class.md +15 -15
- package/CHANGELOG.md +15 -0
- package/package.json +5 -5
- package/.docs/docs/agents/adding-voice.md +0 -383
- package/.docs/docs/community/contributing-templates.md +0 -5
- package/.docs/docs/community/discord.md +0 -11
- package/.docs/guides/build-your-ui/copilotkit.md +0 -291
- package/LICENSE.md +0 -30
- /package/.docs/docs/{community/licensing.md → license.md} +0 -0
- /package/.docs/docs/{agents → long-running-agents}/signals.md +0 -0
|
@@ -178,27 +178,27 @@ The UI sees the message contents and can also read `attributes` and `metadata` o
|
|
|
178
178
|
|
|
179
179
|
Sends a user message to an active run or memory thread. Use this when the active agent should receive the message immediately.
|
|
180
180
|
|
|
181
|
-
**message** (`string | Array<TextPart | FilePart> | { contents: string | Array<TextPart | FilePart>; attributes?: Record<string, JSONValue>; metadata?: Record<string, unknown>; providerOptions?: ProviderMetadata }`): User-authored input. Bare strings and parts without attributes are sent to the model as normal user input. When
|
|
181
|
+
**message** (`string | Array<TextPart | FilePart> | { contents: string | Array<TextPart | FilePart>; attributes?: Record<string, JSONValue>; metadata?: Record<string, unknown>; providerOptions?: ProviderMetadata }`): User-authored input. Bare strings and parts without attributes are sent to the model as normal user input. When attributes are present, Mastra renders the message as a \<user> XML element with the attributes included.
|
|
182
182
|
|
|
183
183
|
**options** (`object`): Targeting and delivery behavior for the message.
|
|
184
184
|
|
|
185
185
|
**options.runId** (`string`): Run ID to target directly. Use this when you already know the active run ID.
|
|
186
186
|
|
|
187
|
-
**options.resourceId** (`string`): Resource ID for the memory thread. Required with
|
|
187
|
+
**options.resourceId** (`string`): Resource ID for the memory thread. Required with threadId for thread-targeted messages.
|
|
188
188
|
|
|
189
|
-
**options.threadId** (`string`): Thread ID to target. Required with
|
|
189
|
+
**options.threadId** (`string`): Thread ID to target. Required with resourceId for thread-targeted messages.
|
|
190
190
|
|
|
191
191
|
**options.ifActive** (`object`): Controls what happens when the target thread is active.
|
|
192
192
|
|
|
193
|
-
**options.ifActive.behavior** (`'deliver' | 'persist' | 'discard'`): Controls what happens when the target thread is active. Defaults to
|
|
193
|
+
**options.ifActive.behavior** (`'deliver' | 'persist' | 'discard'`): Controls what happens when the target thread is active. Defaults to deliver.
|
|
194
194
|
|
|
195
195
|
**options.ifActive.attributes** (`Record<string, string | number | boolean>`): Attributes merged into the message when Mastra accepts it while the target thread is active.
|
|
196
196
|
|
|
197
197
|
**options.ifIdle** (`object`): Controls what happens when the target thread is idle.
|
|
198
198
|
|
|
199
|
-
**options.ifIdle.behavior** (`'wake' | 'persist' | 'discard'`): Controls what happens when the target thread is idle. Defaults to
|
|
199
|
+
**options.ifIdle.behavior** (`'wake' | 'persist' | 'discard'`): Controls what happens when the target thread is idle. Defaults to wake.
|
|
200
200
|
|
|
201
|
-
**options.ifIdle.streamOptions** (`AgentExecutionOptions`): Options for the stream that starts when
|
|
201
|
+
**options.ifIdle.streamOptions** (`AgentExecutionOptions`): Options for the stream that starts when ifIdle.behavior is wake. Mastra uses the top-level resourceId and threadId for memory context.
|
|
202
202
|
|
|
203
203
|
**options.ifIdle.attributes** (`Record<string, string | number | boolean>`): Attributes merged into the message when Mastra accepts it while the target thread is idle.
|
|
204
204
|
|
|
@@ -236,27 +236,27 @@ agent.queueMessage('Also check whether the tests need updates.', {
|
|
|
236
236
|
|
|
237
237
|
Sends a signal to an active run or memory thread.
|
|
238
238
|
|
|
239
|
-
**signal** (`{ type: 'user' | 'state' | 'reactive' | 'notification' | 'user-message' | 'system-reminder'; tagName?: string; contents: string | Array<TextPart | FilePart>; attributes?: Record<string, JSONValue>; metadata?: Record<string, unknown>; providerOptions?: ProviderMetadata }`): Signal context to send to the thread.
|
|
239
|
+
**signal** (`{ type: 'user' | 'state' | 'reactive' | 'notification' | 'user-message' | 'system-reminder'; tagName?: string; contents: string | Array<TextPart | FilePart>; attributes?: Record<string, JSONValue>; metadata?: Record<string, unknown>; providerOptions?: ProviderMetadata }`): Signal context to send to the thread. type is the semantic signal category. tagName controls the XML tag the model sees. For example, { type: 'notification', tagName: 'github-review' } renders as \<github-review>...\</github-review>. Legacy user-message and system-reminder payloads are still accepted and normalized. Unknown type values are rejected; use tagName for custom XML tags.
|
|
240
240
|
|
|
241
241
|
**options** (`object`): Targeting and delivery behavior for the signal.
|
|
242
242
|
|
|
243
243
|
**options.runId** (`string`): Run ID to target directly. Use this when you already know the active run ID.
|
|
244
244
|
|
|
245
|
-
**options.resourceId** (`string`): Resource ID for the memory thread. Required with
|
|
245
|
+
**options.resourceId** (`string`): Resource ID for the memory thread. Required with threadId for thread-targeted signals.
|
|
246
246
|
|
|
247
|
-
**options.threadId** (`string`): Thread ID to target. Required with
|
|
247
|
+
**options.threadId** (`string`): Thread ID to target. Required with resourceId for thread-targeted signals.
|
|
248
248
|
|
|
249
249
|
**options.ifActive** (`object`): Controls what happens when the target thread is active.
|
|
250
250
|
|
|
251
|
-
**options.ifActive.behavior** (`'deliver' | 'persist' | 'discard'`): Controls what happens when the target thread is active. Defaults to
|
|
251
|
+
**options.ifActive.behavior** (`'deliver' | 'persist' | 'discard'`): Controls what happens when the target thread is active. Defaults to deliver.
|
|
252
252
|
|
|
253
253
|
**options.ifActive.attributes** (`Record<string, string | number | boolean>`): Attributes merged into the signal when Mastra accepts it while the target thread is active.
|
|
254
254
|
|
|
255
255
|
**options.ifIdle** (`object`): Controls what happens when the target thread is idle.
|
|
256
256
|
|
|
257
|
-
**options.ifIdle.behavior** (`'wake' | 'persist' | 'discard'`): Controls what happens when the target thread is idle. Defaults to
|
|
257
|
+
**options.ifIdle.behavior** (`'wake' | 'persist' | 'discard'`): Controls what happens when the target thread is idle. Defaults to wake.
|
|
258
258
|
|
|
259
|
-
**options.ifIdle.streamOptions** (`AgentExecutionOptions`): Options for the stream that starts when
|
|
259
|
+
**options.ifIdle.streamOptions** (`AgentExecutionOptions`): Options for the stream that starts when ifIdle.behavior is wake. Mastra uses the top-level resourceId and threadId for memory context.
|
|
260
260
|
|
|
261
261
|
**options.ifIdle.attributes** (`Record<string, string | number | boolean>`): Attributes merged into the signal when Mastra accepts it while the target thread is idle.
|
|
262
262
|
|
|
@@ -301,25 +301,25 @@ const result = await agent.sendStateSignal(
|
|
|
301
301
|
|
|
302
302
|
**state** (`object`): State signal to send to the thread.
|
|
303
303
|
|
|
304
|
-
**state.id** (`string`): State lane name, such as
|
|
304
|
+
**state.id** (`string`): State lane name, such as browser or editor.
|
|
305
305
|
|
|
306
306
|
**state.cacheKey** (`string`): Producer-owned key Mastra uses to skip duplicate state for the same lane and mode.
|
|
307
307
|
|
|
308
308
|
**state.contents** (`string | Array<TextPart | FilePart>`): LLM-facing representation of the state.
|
|
309
309
|
|
|
310
|
-
**state.mode** (`'snapshot' | 'delta'`): Whether the state is an authoritative snapshot or a change event. Defaults to
|
|
310
|
+
**state.mode** (`'snapshot' | 'delta'`): Whether the state is an authoritative snapshot or a change event. Defaults to snapshot.
|
|
311
311
|
|
|
312
|
-
**state.value** (`unknown`): Structured snapshot value for
|
|
312
|
+
**state.value** (`unknown`): Structured snapshot value for mode: 'snapshot'.
|
|
313
313
|
|
|
314
|
-
**state.delta** (`unknown`): Structured change value for
|
|
314
|
+
**state.delta** (`unknown`): Structured change value for mode: 'delta'.
|
|
315
315
|
|
|
316
316
|
**state.attributes** (`Record<string, string | number | boolean>`): Attributes rendered on the state signal tag.
|
|
317
317
|
|
|
318
318
|
**state.metadata** (`Record<string, unknown>`): Application metadata stored with the state signal.
|
|
319
319
|
|
|
320
|
-
**state.tagName** (`string`): XML tag name shown to the model. Defaults to
|
|
320
|
+
**state.tagName** (`string`): XML tag name shown to the model. Defaults to state.
|
|
321
321
|
|
|
322
|
-
**options** (`object`): Targeting and delivery behavior for the state signal. Accepts the same options as
|
|
322
|
+
**options** (`object`): Targeting and delivery behavior for the state signal. Accepts the same options as sendSignal().
|
|
323
323
|
|
|
324
324
|
Returns `{ accepted: Promise<SendAgentSignalAccepted>, signal: CreatedAgentSignal, persisted?: Promise<void>, skipped?: false }` when Mastra accepts new state. Returns `{ skipped: true, reason: 'unchanged' }` when the same `cacheKey` and mode are already current for the state lane. `accepted` resolves at decision-time, once Mastra decides what to do with the signal: `{ action: 'wake', runId, output }` when this process runs the agent (it started or won the lease to start the run), `{ action: 'deliver', runId }` when the signal is forwarded onto an existing run (including when this process loses a cross-process wake race), or `{ action: 'persist' }` / `{ action: 'discard' }` when nothing ran. `runId` is the authoritative id of the run that handled the signal and is present only on `wake` and `deliver`; for `persist`/`discard` use `result.signal.id` to correlate the stored signal. On the `wake` action, `output` is the agent stream for in-process consumption.
|
|
325
325
|
|
|
@@ -345,13 +345,13 @@ const result = await agent.sendNotificationSignal(
|
|
|
345
345
|
|
|
346
346
|
**notification** (`object`): Notification inbox record to create or coalesce.
|
|
347
347
|
|
|
348
|
-
**notification.source** (`string`): External system that produced the notification, such as
|
|
348
|
+
**notification.source** (`string`): External system that produced the notification, such as github, slack, or email.
|
|
349
349
|
|
|
350
|
-
**notification.kind** (`string`): Notification kind within the source, such as
|
|
350
|
+
**notification.kind** (`string`): Notification kind within the source, such as ci-status, mention, or direct-message.
|
|
351
351
|
|
|
352
352
|
**notification.summary** (`string`): LLM-facing summary used as the notification signal contents.
|
|
353
353
|
|
|
354
|
-
**notification.priority** (`'low' | 'medium' | 'high' | 'urgent'`): Priority used by the notification delivery policy. Defaults to
|
|
354
|
+
**notification.priority** (`'low' | 'medium' | 'high' | 'urgent'`): Priority used by the notification delivery policy. Defaults to medium.
|
|
355
355
|
|
|
356
356
|
**notification.payload** (`unknown`): Structured payload stored on the inbox record for tools or application code.
|
|
357
357
|
|
|
@@ -375,7 +375,7 @@ const result = await agent.sendNotificationSignal(
|
|
|
375
375
|
|
|
376
376
|
Returns `{ record: NotificationRecord, decision: NotificationDeliveryDecision, runId?: string, signal?: CreatedAgentSignal, persisted?: Promise<void>, accepted?: Promise<SendAgentSignalAccepted> }`. `record` is the stored inbox record. `decision` is the delivery-policy result. `signal` and `runId` are present when ingress emits a signal immediately, including the immediate summary emitted for active high-priority notifications. `persisted` is present when the emitted signal is persisted without waking an idle thread. `accepted` is present when a signal is emitted and resolves at decision-time, once Mastra decides what to do with it: `{ action: 'wake', runId, output }` when this process runs the agent (it started or won the lease to start the run), `{ action: 'deliver', runId }` when the signal is forwarded onto an existing run, or `{ action: 'persist' }` / `{ action: 'discard' }` when nothing ran. `runId` on the accepted result is present only on `wake` and `deliver`. On the `wake` action, `output` is the agent stream for in-process consumption.
|
|
377
377
|
|
|
378
|
-
Default delivery is priority-aware. `urgent` notifications deliver immediately. `high` notifications deliver immediately when the thread is idle; when the thread is active, Mastra emits a summary immediately and keeps `deliverAt` for later full delivery when the thread is idle. `medium` notifications deliver immediately when idle and batch into summaries when active. `low` notifications batch into summaries in both active and idle threads; idle low-priority summaries reach subscribers without waking the model loop. For the full flow, visit [Signals](https://mastra.ai/docs/agents/signals).
|
|
378
|
+
Default delivery is priority-aware. `urgent` notifications deliver immediately. `high` notifications deliver immediately when the thread is idle; when the thread is active, Mastra emits a summary immediately and keeps `deliverAt` for later full delivery when the thread is idle. `medium` notifications deliver immediately when idle and batch into summaries when active. `low` notifications batch into summaries in both active and idle threads; idle low-priority summaries reach subscribers without waking the model loop. For the full flow, visit [Signals](https://mastra.ai/docs/long-running-agents/signals).
|
|
379
379
|
|
|
380
380
|
Configure `notifications.deliveryPolicy` on the agent when some notifications should wait for a different dispatch window or summary rollup:
|
|
381
381
|
|
|
@@ -417,9 +417,9 @@ Returns an `AgentThreadSubscription` object with these members:
|
|
|
417
417
|
|
|
418
418
|
**stream** (`AsyncIterable<AgentChunkType>`): Raw agent stream chunks for the subscribed thread.
|
|
419
419
|
|
|
420
|
-
**activeRunId** (`() => string | null`): Returns the active run ID for the thread, or
|
|
420
|
+
**activeRunId** (`() => string | null`): Returns the active run ID for the thread, or null when no run is active.
|
|
421
421
|
|
|
422
|
-
**abort** (`() => boolean`): Aborts the active run for the thread. Returns
|
|
422
|
+
**abort** (`() => boolean`): Aborts the active run for the thread. Returns true when a run was aborted.
|
|
423
423
|
|
|
424
424
|
**unsubscribe** (`() => void`): Stops the subscription without aborting the active run.
|
|
425
425
|
|
|
@@ -441,21 +441,21 @@ Returns an `AgentThreadSubscription` object with these members:
|
|
|
441
441
|
|
|
442
442
|
**tools** (`ToolsInput | ({ requestContext: RequestContext }) => ToolsInput | Promise<ToolsInput>`): Tools that the agent can access. Can be provided statically or resolved dynamically.
|
|
443
443
|
|
|
444
|
-
**hooks** (`ToolHooks`): Hooks that run before and after every tool call made by this agent. Per-execution hooks passed to
|
|
444
|
+
**hooks** (`ToolHooks`): Hooks that run before and after every tool call made by this agent. Per-execution hooks passed to generate() or stream() override matching hooks set here. See Tool hooks below.
|
|
445
445
|
|
|
446
|
-
**hooks.beforeToolCall** (`(context: ToolHookContext) => void | ToolBeforeHookResult | Promise<void | ToolBeforeHookResult>`): Runs before a tool executes. Receives
|
|
446
|
+
**hooks.beforeToolCall** (`(context: ToolHookContext) => void | ToolBeforeHookResult | Promise<void | ToolBeforeHookResult>`): Runs before a tool executes. Receives { toolName, input, context, metadata }. Return { proceed: false, output } to skip the tool call and use output as its result.
|
|
447
447
|
|
|
448
|
-
**hooks.afterToolCall** (`(context: ToolAfterHookContext) => void | Promise<void>`): Runs after a tool executes. Receives
|
|
448
|
+
**hooks.afterToolCall** (`(context: ToolAfterHookContext) => void | Promise<void>`): Runs after a tool executes. Receives { toolName, input, context, metadata, output, error }. output is undefined when the tool throws, and error is set instead.
|
|
449
449
|
|
|
450
|
-
**transform** (`ToolPayloadTransformPolicy`): Shared policy for transforming tool payloads before display streams or user-visible transcript messages receive them. Use per-tool
|
|
450
|
+
**transform** (`ToolPayloadTransformPolicy`): Shared policy for transforming tool payloads before display streams or user-visible transcript messages receive them. Use per-tool transform on createTool() for tool-local rules.
|
|
451
451
|
|
|
452
452
|
**workflows** (`Record<string, Workflow> | ({ requestContext: RequestContext }) => Record<string, Workflow> | Promise<Record<string, Workflow>>`): Workflows that the agent can execute. Can be static or dynamically resolved.
|
|
453
453
|
|
|
454
|
-
**defaultOptions** (`AgentExecutionOptions | ({ requestContext: RequestContext }) => AgentExecutionOptions | Promise<AgentExecutionOptions>`): Default options used when calling
|
|
454
|
+
**defaultOptions** (`AgentExecutionOptions | ({ requestContext: RequestContext }) => AgentExecutionOptions | Promise<AgentExecutionOptions>`): Default options used when calling stream() and generate().
|
|
455
455
|
|
|
456
|
-
**defaultGenerateOptionsLegacy** (`AgentGenerateOptions | ({ requestContext: RequestContext }) => AgentGenerateOptions | Promise<AgentGenerateOptions>`): Default options used when calling
|
|
456
|
+
**defaultGenerateOptionsLegacy** (`AgentGenerateOptions | ({ requestContext: RequestContext }) => AgentGenerateOptions | Promise<AgentGenerateOptions>`): Default options used when calling generateLegacy().
|
|
457
457
|
|
|
458
|
-
**defaultStreamOptionsLegacy** (`AgentStreamOptions | ({ requestContext: RequestContext }) => AgentStreamOptions | Promise<AgentStreamOptions>`): Default options used when calling
|
|
458
|
+
**defaultStreamOptionsLegacy** (`AgentStreamOptions | ({ requestContext: RequestContext }) => AgentStreamOptions | Promise<AgentStreamOptions>`): Default options used when calling streamLegacy().
|
|
459
459
|
|
|
460
460
|
**mastra** (`Mastra`): Reference to the Mastra runtime instance (injected automatically).
|
|
461
461
|
|
|
@@ -465,11 +465,11 @@ Returns an `AgentThreadSubscription` object with these members:
|
|
|
465
465
|
|
|
466
466
|
**notifications** (`object`): Notification delivery configuration for durable notification signals.
|
|
467
467
|
|
|
468
|
-
**notifications.deliveryPolicy** (`NotificationDeliveryPolicyConfig`): Controls how notification records are delivered. Configure a default decision, per-priority decisions, per-source decisions, or a custom
|
|
468
|
+
**notifications.deliveryPolicy** (`NotificationDeliveryPolicyConfig`): Controls how notification records are delivered. Configure a default decision, per-priority decisions, per-source decisions, or a custom decide() function.
|
|
469
469
|
|
|
470
470
|
**voice** (`CompositeVoice`): Voice settings for speech input and output.
|
|
471
471
|
|
|
472
|
-
**inputProcessors** (`(Processor | ProcessorWorkflow)[] | ({ requestContext: RequestContext }) => (Processor | ProcessorWorkflow)[] | Promise<(Processor | ProcessorWorkflow)[]>`): Input processors that can modify or validate messages before they are processed by the agent. Can be individual Processor objects or workflows created with
|
|
472
|
+
**inputProcessors** (`(Processor | ProcessorWorkflow)[] | ({ requestContext: RequestContext }) => (Processor | ProcessorWorkflow)[] | Promise<(Processor | ProcessorWorkflow)[]>`): Input processors that can modify or validate messages before they are processed by the agent. Can be individual Processor objects or workflows created with createWorkflow() using ProcessorStepSchema.
|
|
473
473
|
|
|
474
474
|
**outputProcessors** (`(Processor | ProcessorWorkflow)[] | ({ requestContext: RequestContext }) => (Processor | ProcessorWorkflow)[] | Promise<(Processor | ProcessorWorkflow)[]>`): Output processors that can modify or validate messages from the agent before they are sent to the client. Can be individual Processor objects or workflows.
|
|
475
475
|
|
|
@@ -550,7 +550,7 @@ The hook context `metadata` includes `agentId` and `agentName`. Per-execution ho
|
|
|
550
550
|
|
|
551
551
|
When you register the [`MastraEditor`](https://mastra.ai/reference/editor/mastra-editor), the `editor` field controls which parts of a code-defined agent can be changed through the editor. Fields owned by code are read-only in Studio and are stripped from saved overrides.
|
|
552
552
|
|
|
553
|
-
**editor** (`false | { instructions?: boolean; tools?: boolean | { description?: boolean } }`): Omit to allow editing instructions and tools. Set to
|
|
553
|
+
**editor** (`false | { instructions?: boolean; tools?: boolean | { description?: boolean } }`): Omit to allow editing instructions and tools. Set to false to lock the agent. Set instructions: true to allow instruction edits. Set tools: true to allow tool membership and description edits, or tools: { description: true } to allow only description edits.
|
|
554
554
|
|
|
555
555
|
The agent's `id`, `name`, and `model` always come from code and can't be overridden through the editor. See the [Editor overview](https://mastra.ai/docs/editor/overview) for usage.
|
|
556
556
|
|
|
@@ -31,7 +31,7 @@ export const supportAgent = new Agent({
|
|
|
31
31
|
|
|
32
32
|
The `channels` property accepts a `ChannelConfig` object with the following fields:
|
|
33
33
|
|
|
34
|
-
**adapters** (`Record<string, Adapter | ChannelAdapterConfig>`): Platform adapters keyed by name (e.g.
|
|
34
|
+
**adapters** (`Record<string, Adapter | ChannelAdapterConfig>`): Platform adapters keyed by name (e.g. slack, discord). Pass an Adapter directly for defaults, or a ChannelAdapterConfig object to customize per-adapter options.
|
|
35
35
|
|
|
36
36
|
**handlers** (`ChannelHandlers`): Override default message handlers for DMs, mentions, and subscribed threads.
|
|
37
37
|
|
|
@@ -39,21 +39,21 @@ The `channels` property accepts a `ChannelConfig` object with the following fiel
|
|
|
39
39
|
|
|
40
40
|
**inlineLinks** (`InlineLinkEntry[]`): Promote URLs found in message text to file parts so the model can process linked content. Each entry matches a domain. Disabled by default.
|
|
41
41
|
|
|
42
|
-
**tools** (`boolean`): Include channel-specific tools (
|
|
42
|
+
**tools** (`boolean`): Include channel-specific tools (add\_reaction, remove\_reaction). Set to false for models that do not support function calling. (Default: `true`)
|
|
43
43
|
|
|
44
|
-
**state** (`StateAdapter`): State adapter for subscriptions and deduplication. Defaults to
|
|
44
|
+
**state** (`StateAdapter`): State adapter for subscriptions and deduplication. Defaults to MastraStateAdapter backed by the Mastra instance storage. Channels require storage to be configured. (Default: `MastraStateAdapter (from Mastra storage)`)
|
|
45
45
|
|
|
46
|
-
**userName** (`string`): Bot display name shown in platform messages. Defaults to the agent's
|
|
46
|
+
**userName** (`string`): Bot display name shown in platform messages. Defaults to the agent's name, or 'Mastra' if no name is set. (Default: `` agent's `name` ``)
|
|
47
47
|
|
|
48
|
-
**threadContext** (`{ maxMessages?: number; addSystemMessage?: boolean }`): How the agent picks up context about the current thread.
|
|
48
|
+
**threadContext** (`{ maxMessages?: number; addSystemMessage?: boolean }`): How the agent picks up context about the current thread. maxMessages controls how many recent platform messages are fetched on first mention (set to 0 to disable; only applies to non-DM threads). addSystemMessage: false skips the built-in system message that tells the agent which channel/platform a request came from. (Default: `{ maxMessages: 10, addSystemMessage: true }`)
|
|
49
49
|
|
|
50
|
-
**chatOptions** (`Omit<ChatConfig, 'adapters' | 'state' | 'userName'>`): Additional options passed directly to the
|
|
50
|
+
**chatOptions** (`Omit<ChatConfig, 'adapters' | 'state' | 'userName'>`): Additional options passed directly to the Chat SDK. Use for advanced configuration such as dedupeTtlMs, fallbackStreamingPlaceholderText, lockScope, and messageHistory.
|
|
51
51
|
|
|
52
|
-
**resolveResourceId** (`(ctx: ResolveResourceIdContext) => string | Promise<string>`): Decide which
|
|
52
|
+
**resolveResourceId** (`(ctx: ResolveResourceIdContext) => string | Promise<string>`): Decide which resourceId owns resource-level memory for a channel thread, separately from who sent the message. Runs only when a new thread is created; reused threads keep their stored owner and never call the hook. Return ctx.defaultResourceId (${platform}:${message.author.userId}) to keep the built-in behavior.
|
|
53
53
|
|
|
54
|
-
**waitUntil** (`(promise: Promise<unknown>) => void`): Platform
|
|
54
|
+
**waitUntil** (`(promise: Promise<unknown>) => void`): Platform waitUntil function. Required on Vercel so background agent runs survive after the webhook returns 200. On Vercel pass waitUntil from @vercel/functions. Cloudflare Workers and Netlify Functions are detected automatically from the request context. AWS Lambda does not need waitUntil because it waits for the event loop to drain naturally.
|
|
55
55
|
|
|
56
|
-
**resolveWaitUntil** (`(c: Context) => ((promise: Promise<unknown>) => void) | undefined`): Resolver for runtimes where
|
|
56
|
+
**resolveWaitUntil** (`(c: Context) => ((promise: Promise<unknown>) => void) | undefined`): Resolver for runtimes where waitUntil lives on the Hono request context but is not covered by the built-in helper. Resolution order: bare waitUntil → resolveWaitUntil(c) → default (Cloudflare Workers, Netlify).
|
|
57
57
|
|
|
58
58
|
## Per-adapter options
|
|
59
59
|
|
|
@@ -88,21 +88,21 @@ const agent = new Agent({
|
|
|
88
88
|
|
|
89
89
|
**adapter** (`Adapter`): The Chat SDK adapter instance for this platform.
|
|
90
90
|
|
|
91
|
-
**gateway** (`boolean`): Start a persistent Gateway WebSocket listener for receiving DMs, @mentions, and reactions. Set to
|
|
91
|
+
**gateway** (`boolean`): Start a persistent Gateway WebSocket listener for receiving DMs, @mentions, and reactions. Set to false for serverless deployments that only need webhook-based interactions. (Default: `true`)
|
|
92
92
|
|
|
93
|
-
**cards** (`boolean`): \*\*Deprecated\*\* — use
|
|
93
|
+
**cards** (`boolean`): \*\*Deprecated\*\* — use toolDisplay instead. When toolDisplay is not set, cards: true maps to toolDisplay: "cards" and cards: false maps to toolDisplay: "text". IDEs flag the field with a strikethrough; runtime behavior is preserved.
|
|
94
94
|
|
|
95
95
|
**cors** (`CorsOptions`): CORS configuration for this adapter webhook route. Use this for browser-based channel adapters that need cross-origin credentials.
|
|
96
96
|
|
|
97
97
|
**formatError** (`(error: Error) => PostableMessage`): Override how errors are rendered in the chat. Return a user-friendly message instead of exposing the raw error. (Default: `"❌ Error: <error.message>"`)
|
|
98
98
|
|
|
99
|
-
**formatToolCall** (`(args: { toolName: string; args: unknown; result: unknown; isError: boolean }) => PostableMessage | null`): \*\*Deprecated\*\* — use
|
|
99
|
+
**formatToolCall** (`(args: { toolName: string; args: unknown; result: unknown; isError: boolean }) => PostableMessage | null`): \*\*Deprecated\*\* — use toolDisplay (function form) instead. When set, runs as a ToolDisplayFn that only fires on result/error events; running and approval events fall through to no render. Mutually exclusive with toolDisplay at the type level.
|
|
100
100
|
|
|
101
|
-
**streaming** (`boolean | { updateIntervalMs?: number }`): Stream agent text deltas to the channel as the agent generates them instead of buffering and posting once per step. Requires the underlying adapter to support post-and-edit streaming. Slack defaults to
|
|
101
|
+
**streaming** (`boolean | { updateIntervalMs?: number }`): Stream agent text deltas to the channel as the agent generates them instead of buffering and posting once per step. Requires the underlying adapter to support post-and-edit streaming. Slack defaults to true; other adapters default to false. (Default: `false (true for Slack)`)
|
|
102
102
|
|
|
103
|
-
**toolDisplay** (`'cards' | 'text' | 'timeline' | 'grouped' | 'hidden' | ToolDisplayFn`): How tool calls are rendered in the channel.
|
|
103
|
+
**toolDisplay** (`'cards' | 'text' | 'timeline' | 'grouped' | 'hidden' | ToolDisplayFn`): How tool calls are rendered in the channel. "cards" posts per-tool running/result cards as rich Block Kit. "text" posts the same lifecycle as plain text (no Block Kit). "timeline" and "grouped" stream tool state as inline task\_update chunks (requires streaming: true; Slack only today — other adapters may render a placeholder). "hidden" executes tools silently. Pass a function to render tool events yourself; return { kind: "post", message } for a discrete post/edit, { kind: "stream", chunk } to push into the active streaming widget, or undefined to skip rendering that event. Approve/deny prompts always render as a separate card regardless of mode. (Default: `'cards' ('grouped' for Slack)`)
|
|
104
104
|
|
|
105
|
-
**typingStatus** (`boolean | ((chunk: AgentChunkType, ctx: TypingStatusContext) => string | false | null | undefined | void)`): Control the platform typing indicator.
|
|
105
|
+
**typingStatus** (`boolean | ((chunk: AgentChunkType, ctx: TypingStatusContext) => string | false | null | undefined | void)`): Control the platform typing indicator. true uses built-in defaults (is typing… on text, is calling {tool}… on tool-call, is waiting for approval… on tool-call-approval). false suppresses typing entirely — useful when a live streaming widget (e.g. toolDisplay: "grouped" in Slack) already conveys progress. Pass a function to set custom status copy per chunk; return a string to set the status, or false/null/undefined to leave it unchanged. Compose with defaultTypingStatus (exported from @mastra/core/channels) to fall back to defaults for chunks you don't handle. (Default: `true`)
|
|
106
106
|
|
|
107
107
|
## Tool display modes
|
|
108
108
|
|
|
@@ -250,13 +250,13 @@ const agent = new Agent({
|
|
|
250
250
|
|
|
251
251
|
The `ResolveResourceIdContext` passed to the function:
|
|
252
252
|
|
|
253
|
-
**platform** (`string`): Platform name (e.g.
|
|
253
|
+
**platform** (`string`): Platform name (e.g. slack, discord).
|
|
254
254
|
|
|
255
|
-
**thread** (`Thread`): The channel thread the message arrived on. Use
|
|
255
|
+
**thread** (`Thread`): The channel thread the message arrived on. Use thread.isDM to tell DMs apart from group/channel threads.
|
|
256
256
|
|
|
257
|
-
**message** (`Message`): The incoming message.
|
|
257
|
+
**message** (`Message`): The incoming message. message.author.userId is the actor/sender, not necessarily the memory owner.
|
|
258
258
|
|
|
259
|
-
**defaultResourceId** (`string`): The built-in default (
|
|
259
|
+
**defaultResourceId** (`string`): The built-in default (${platform}:${message.author.userId}). Return this to keep the current behavior.
|
|
260
260
|
|
|
261
261
|
## Inline media
|
|
262
262
|
|
|
@@ -34,13 +34,13 @@ const reviewSkill = createSkill({
|
|
|
34
34
|
|
|
35
35
|
**instructions** (`string`): The full skill instructions in markdown. Loaded into the conversation when the agent activates the skill.
|
|
36
36
|
|
|
37
|
-
**references** (`Record<string, string>`): Supporting documents the agent can read with the
|
|
37
|
+
**references** (`Record<string, string>`): Supporting documents the agent can read with the skill\_read tool. Keys are filenames, values are file contents.
|
|
38
38
|
|
|
39
39
|
**license** (`string`): SPDX license identifier for the skill.
|
|
40
40
|
|
|
41
41
|
**compatibility** (`unknown`): Compatibility requirements. The Agent Skills spec leaves this flexible — can be a string array, object, or any structure your tooling expects.
|
|
42
42
|
|
|
43
|
-
**user-invocable** (`boolean`): Whether end users can invoke this skill directly. Defaults to
|
|
43
|
+
**user-invocable** (`boolean`): Whether end users can invoke this skill directly. Defaults to undefined (agent decides).
|
|
44
44
|
|
|
45
45
|
**metadata** (`Record<string, unknown>`): Arbitrary metadata attached to the skill.
|
|
46
46
|
|
|
@@ -57,7 +57,7 @@ Returns: `DurableAgent`
|
|
|
57
57
|
|
|
58
58
|
**name** (`string`): Name override. (Default: `agent.name`)
|
|
59
59
|
|
|
60
|
-
**cache** (`MastraServerCache | false`): Cache for stored stream events, which enables resumable streams. If omitted, the agent inherits the cache from the Mastra instance, or uses an InMemoryServerCache. Set to
|
|
60
|
+
**cache** (`MastraServerCache | false`): Cache for stored stream events, which enables resumable streams. If omitted, the agent inherits the cache from the Mastra instance, or uses an InMemoryServerCache. Set to false to disable caching, which makes streams non-resumable.
|
|
61
61
|
|
|
62
62
|
**pubsub** (`PubSub`): PubSub instance for streaming events. (Default: `EventEmitterPubSub`)
|
|
63
63
|
|
|
@@ -79,7 +79,7 @@ Returns: `EventedAgent` (a subclass of `DurableAgent`)
|
|
|
79
79
|
|
|
80
80
|
**agent** (`Agent`): The Agent to wrap with evented durable execution capabilities.
|
|
81
81
|
|
|
82
|
-
**cache** (`MastraServerCache | false`): Cache for stored stream events, which enables resumable streams. If omitted, the agent inherits the cache from the Mastra instance, or uses an InMemoryServerCache. Set to
|
|
82
|
+
**cache** (`MastraServerCache | false`): Cache for stored stream events, which enables resumable streams. If omitted, the agent inherits the cache from the Mastra instance, or uses an InMemoryServerCache. Set to false to disable caching.
|
|
83
83
|
|
|
84
84
|
**pubsub** (`PubSub`): PubSub instance for streaming events. (Default: `EventEmitterPubSub`)
|
|
85
85
|
|
|
@@ -95,13 +95,13 @@ The `DurableAgent` class accepts the same options as `createDurableAgent`, plus
|
|
|
95
95
|
|
|
96
96
|
**name** (`string`): Name override. (Default: `agent.name`)
|
|
97
97
|
|
|
98
|
-
**cache** (`MastraServerCache | false`): Cache for stored stream events. If omitted, inherits from the Mastra instance or uses an InMemoryServerCache. Set to
|
|
98
|
+
**cache** (`MastraServerCache | false`): Cache for stored stream events. If omitted, inherits from the Mastra instance or uses an InMemoryServerCache. Set to false to disable caching.
|
|
99
99
|
|
|
100
100
|
**pubsub** (`PubSub`): PubSub instance for streaming events. (Default: `EventEmitterPubSub`)
|
|
101
101
|
|
|
102
102
|
**maxSteps** (`number`): Maximum number of steps for the agentic loop.
|
|
103
103
|
|
|
104
|
-
**cleanupTimeoutMs** (`number`): Grace period in milliseconds before registry entries are cleaned up automatically after a stream finishes or errors. Set to 0 to disable auto-cleanup and require a manual
|
|
104
|
+
**cleanupTimeoutMs** (`number`): Grace period in milliseconds before registry entries are cleaned up automatically after a stream finishes or errors. Set to 0 to disable auto-cleanup and require a manual cleanup() call. Auto-cleanup does not fire on suspended events. (Default: `30000`)
|
|
105
105
|
|
|
106
106
|
## Methods
|
|
107
107
|
|
|
@@ -185,7 +185,7 @@ interface PrepareResult {
|
|
|
185
185
|
|
|
186
186
|
`stream()` accepts a `DurableAgentStreamOptions` object. It supports the agent execution options below, plus lifecycle callbacks.
|
|
187
187
|
|
|
188
|
-
**runId** (`string`): Unique identifier for this run. Use it later with
|
|
188
|
+
**runId** (`string`): Unique identifier for this run. Use it later with resume() or observe().
|
|
189
189
|
|
|
190
190
|
**instructions** (`AgentExecutionOptions['instructions']`): Overrides the agent's default instructions for this run. Accepts a static string or the same dynamic instructions value the agent supports.
|
|
191
191
|
|
|
@@ -205,15 +205,15 @@ interface PrepareResult {
|
|
|
205
205
|
|
|
206
206
|
**activeTools** (`string[]`): Restricts execution to the named subset of the agent's tools.
|
|
207
207
|
|
|
208
|
-
**modelSettings** (`object`): Model-specific settings such as temperature. Credential-bearing headers (
|
|
208
|
+
**modelSettings** (`object`): Model-specific settings such as temperature. Credential-bearing headers (Authorization, X-Api-Key, and similar) are stripped from the serialized snapshot before it crosses process boundaries.
|
|
209
209
|
|
|
210
|
-
**stopWhen** (`AgentExecutionOptions['stopWhen']`): Predicate or composition that ends the agentic loop early. The closure rides on the in-process run registry; cross-process resumes degrade to
|
|
210
|
+
**stopWhen** (`AgentExecutionOptions['stopWhen']`): Predicate or composition that ends the agentic loop early. The closure rides on the in-process run registry; cross-process resumes degrade to maxSteps only.
|
|
211
211
|
|
|
212
212
|
**system** (`string | string[]`): Additional system message appended after the agent instructions and before user messages.
|
|
213
213
|
|
|
214
|
-
**requireToolApproval** (`boolean | ((args: { toolName: string; args: unknown; requestContext: RequestContext; workspace?: string }) => boolean | Promise<boolean>)`): Require approval for tool calls. Pass
|
|
214
|
+
**requireToolApproval** (`boolean | ((args: { toolName: string; args: unknown; requestContext: RequestContext; workspace?: string }) => boolean | Promise<boolean>)`): Require approval for tool calls. Pass true or false to gate all or none, or a function for per-call policy. Function-form policies live on the in-process run registry; cross-process resumes fall back to a true shadow.
|
|
215
215
|
|
|
216
|
-
**autoResumeSuspendedTools** (`boolean`): Automatically resume tools that suspended, instead of waiting for an external
|
|
216
|
+
**autoResumeSuspendedTools** (`boolean`): Automatically resume tools that suspended, instead of waiting for an external resume() call.
|
|
217
217
|
|
|
218
218
|
**toolCallConcurrency** (`number`): Maximum number of tool calls to execute concurrently.
|
|
219
219
|
|
|
@@ -223,25 +223,25 @@ interface PrepareResult {
|
|
|
223
223
|
|
|
224
224
|
**structuredOutput** (`object`): Structured output configuration.
|
|
225
225
|
|
|
226
|
-
**untilIdle** (`boolean | { maxIdleMs?: number }`): When set, keeps the stream open across background-task continuations until the agent is idle. Pass
|
|
226
|
+
**untilIdle** (`boolean | { maxIdleMs?: number }`): When set, keeps the stream open across background-task continuations until the agent is idle. Pass true for the default 5-minute idle timeout, or { maxIdleMs } to customise. Equivalent to the deprecated streamUntilIdle() method. Also supported on resume().
|
|
227
227
|
|
|
228
228
|
**disableBackgroundTasks** (`boolean`): Disable background-task dispatch for this run. Background-eligible tools execute inline instead.
|
|
229
229
|
|
|
230
|
-
**tracingOptions** (`AgentExecutionOptions['tracingOptions']`): Tracing metadata, tags, trace ID, parent span ID, and
|
|
230
|
+
**tracingOptions** (`AgentExecutionOptions['tracingOptions']`): Tracing metadata, tags, trace ID, parent span ID, and requestContextKeys forwarded to the agent and model spans. Fully JSON-serializable.
|
|
231
231
|
|
|
232
232
|
**actor** (`AgentExecutionOptions['actor']`): Per-call actor signal forwarded to FGA checks and tool execution.
|
|
233
233
|
|
|
234
|
-
**transform** (`AgentExecutionOptions['transform']`): Per-invocation tool payload transform policy. The
|
|
234
|
+
**transform** (`AgentExecutionOptions['transform']`): Per-invocation tool payload transform policy. The transformToolPayload closure lives on the in-process run registry; only the JSON-safe targets shadow is serialized.
|
|
235
235
|
|
|
236
|
-
**prepareStep** (`AgentExecutionOptions['prepareStep']`): Per-step preparation hook invoked as a
|
|
236
|
+
**prepareStep** (`AgentExecutionOptions['prepareStep']`): Per-step preparation hook invoked as a PrepareStepProcessor at the start of every iteration. Closure-only — stored on the in-process run registry. Cross-process resumes lose the hook.
|
|
237
237
|
|
|
238
|
-
**isTaskComplete** (`AgentExecutionOptions['isTaskComplete']`): Per-call completion policy. Scorer instances and
|
|
238
|
+
**isTaskComplete** (`AgentExecutionOptions['isTaskComplete']`): Per-call completion policy. Scorer instances and onComplete live on the in-process run registry; the JSON-safe primitives (strategy, timeout, parallel, suppressFeedback, scorerNames) are serialized for cross-process observability.
|
|
239
239
|
|
|
240
|
-
**delegation** (`AgentExecutionOptions['delegation']`): Sub-agent delegation hooks (
|
|
240
|
+
**delegation** (`AgentExecutionOptions['delegation']`): Sub-agent delegation hooks (onDelegationStart, onDelegationComplete, messageFilter). Callbacks are baked into the sub-agent tool wrappers at prepare time. Cross-process resumes lose the callbacks.
|
|
241
241
|
|
|
242
242
|
**versions** (`object`): Version overrides for sub-agent delegation.
|
|
243
243
|
|
|
244
|
-
**abortSignal** (`AbortSignal`): External abort signal. Forwarded to the durable run's internal
|
|
244
|
+
**abortSignal** (`AbortSignal`): External abort signal. Forwarded to the durable run's internal AbortController, so either source can cancel the run. Cross-process resumes cannot recover the signal — pass a fresh one to resume() if you need post-resume abortability.
|
|
245
245
|
|
|
246
246
|
**onChunk** (`(chunk: ChunkType) => void | Promise<void>`): Called for each streamed chunk.
|
|
247
247
|
|
|
@@ -253,9 +253,9 @@ interface PrepareResult {
|
|
|
253
253
|
|
|
254
254
|
**onSuspended** (`(data: AgentSuspendedEventData) => void | Promise<void>`): Called when the run suspends, for example for tool approval.
|
|
255
255
|
|
|
256
|
-
**onAbort** (`AgentExecutionOptions['onAbort']`): Called when the run is aborted via
|
|
256
|
+
**onAbort** (`AgentExecutionOptions['onAbort']`): Called when the run is aborted via abortSignal or result.abort().
|
|
257
257
|
|
|
258
|
-
**onIterationComplete** (`AgentExecutionOptions['onIterationComplete']`): Called after every agentic-loop iteration with the latest
|
|
258
|
+
**onIterationComplete** (`AgentExecutionOptions['onIterationComplete']`): Called after every agentic-loop iteration with the latest messageList, finishReason, and isFinal flag. Observation-only on durable agents: returning continue: false or feedback does not influence the loop.
|
|
259
259
|
|
|
260
260
|
`resume()` and `observe()` accept the same lifecycle callbacks (`onChunk`, `onStepFinish`, `onFinish`, `onError`, `onSuspended`). `observe()` also accepts an `offset` to control where replay starts.
|
|
261
261
|
|
|
@@ -275,11 +275,11 @@ interface DurableAgentStreamResult<OUTPUT = undefined> {
|
|
|
275
275
|
}
|
|
276
276
|
```
|
|
277
277
|
|
|
278
|
-
**output** (`MastraModelOutput`): The streaming output. Await
|
|
278
|
+
**output** (`MastraModelOutput`): The streaming output. Await output.text for the full text, or consume output.fullStream.
|
|
279
279
|
|
|
280
|
-
**fullStream** (`ReadableStream`): The full event stream, delegating to
|
|
280
|
+
**fullStream** (`ReadableStream`): The full event stream, delegating to output.fullStream.
|
|
281
281
|
|
|
282
|
-
**runId** (`string`): The unique run ID. Pass it to
|
|
282
|
+
**runId** (`string`): The unique run ID. Pass it to resume() or observe() to reconnect.
|
|
283
283
|
|
|
284
284
|
**threadId** (`string`): Thread ID when using memory.
|
|
285
285
|
|
|
@@ -287,7 +287,7 @@ interface DurableAgentStreamResult<OUTPUT = undefined> {
|
|
|
287
287
|
|
|
288
288
|
**cleanup** (`() => void`): Unsubscribes from PubSub and clears registry entries for the run. Call it when done with the run.
|
|
289
289
|
|
|
290
|
-
**abort** (`() => void`): Aborts the run by flipping the internal
|
|
290
|
+
**abort** (`() => void`): Aborts the run by flipping the internal AbortController. Surfaces as an AbortError inside the durable LLM-execution step and fires the onAbort callback. Safe to call after the run has finished — a no-op in that case.
|
|
291
291
|
|
|
292
292
|
## Related
|
|
293
293
|
|
|
@@ -58,7 +58,7 @@ const result = await agent.generate('message for agent')
|
|
|
58
58
|
|
|
59
59
|
**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.
|
|
60
60
|
|
|
61
|
-
**options.delegation.onDelegationComplete** (`(context: DelegationCompleteContext) => { feedback?: string } | void | Promise<{ feedback?: string } | void>`): Called after a subagent delegation completes. The context includes a
|
|
61
|
+
**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.
|
|
62
62
|
|
|
63
63
|
**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.
|
|
64
64
|
|
|
@@ -86,9 +86,9 @@ const result = await agent.generate('message for agent')
|
|
|
86
86
|
|
|
87
87
|
**options.prepareStep** (`PrepareStepFunction`): Callback function called before each step of multi-step execution.
|
|
88
88
|
|
|
89
|
-
**options.requireToolApproval** (`boolean`): When true, all tool calls require explicit approval before execution. The generate() method will return with
|
|
89
|
+
**options.requireToolApproval** (`boolean`): When true, all tool calls require explicit approval before execution. The generate() method will return with finishReason: 'suspended' and include a suspendPayload with tool call details (toolCallId, toolName, args). Use approveToolCallGenerate() or declineToolCallGenerate() to proceed. See Agent Approval for details.
|
|
90
90
|
|
|
91
|
-
**options.autoResumeSuspendedTools** (`boolean`): When true, automatically resumes suspended tools when the user sends a new message on the same thread. The agent extracts
|
|
91
|
+
**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.
|
|
92
92
|
|
|
93
93
|
**options.toolCallConcurrency** (`number`): Maximum number of tool calls to execute concurrently. Defaults to 1 when approval may be required, otherwise 10.
|
|
94
94
|
|
|
@@ -110,7 +110,7 @@ const result = await agent.generate('message for agent')
|
|
|
110
110
|
|
|
111
111
|
**options.structuredOutput.logger** (`IMastraLogger`): Optional logger instance for structured logging during output generation.
|
|
112
112
|
|
|
113
|
-
**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.,
|
|
113
|
+
**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' } }).
|
|
114
114
|
|
|
115
115
|
**options.outputProcessors** (`OutputProcessorOrWorkflow[]`): Output processors to use for this execution (overrides agent's default).
|
|
116
116
|
|
|
@@ -178,7 +178,7 @@ const result = await agent.generate('message for agent')
|
|
|
178
178
|
|
|
179
179
|
**options.clientTools** (`ToolsInput`): Client-side tools available during execution.
|
|
180
180
|
|
|
181
|
-
**options.hooks** (`ToolHooks`): Per-execution hooks that run before and after tool calls. Overrides matching agent-level hooks for this execution.
|
|
181
|
+
**options.hooks** (`ToolHooks`): Per-execution hooks that run before and after tool calls. Overrides matching agent-level hooks for this execution. beforeToolCall can return { proceed: false, output } to skip the tool call.
|
|
182
182
|
|
|
183
183
|
**options.savePerStep** (`boolean`): Save messages incrementally after each generation step completes (default: false). Disabled internally when observational memory is enabled.
|
|
184
184
|
|
|
@@ -212,7 +212,7 @@ const result = await agent.generate('message for agent')
|
|
|
212
212
|
|
|
213
213
|
**options.tracingOptions.tags** (`string[]`): Tags to apply to this trace. String labels for categorizing and filtering traces.
|
|
214
214
|
|
|
215
|
-
**options.versions** (`VersionOverrides`): Per-invocation version overrides for sub-agent delegation. Merged on top of Mastra instance-level versions and propagated automatically through sub-agent calls via requestContext. Requires the editor package. See
|
|
215
|
+
**options.versions** (`VersionOverrides`): Per-invocation version overrides for sub-agent delegation. Merged on top of Mastra instance-level versions and propagated automatically through sub-agent calls via requestContext. Requires the editor package. See Sub-agent versioning.
|
|
216
216
|
|
|
217
217
|
**options.versions.agents** (`Record<string, VersionSelector>`): A map of agent IDs to their version selectors.
|
|
218
218
|
|
|
@@ -322,7 +322,7 @@ For the streaming version of the same chunk shape, see the [ChunkType reference]
|
|
|
322
322
|
|
|
323
323
|
**response.modelId** (`string`): Model identifier used for this response.
|
|
324
324
|
|
|
325
|
-
**response.headers** (`Record<string, string>`): HTTP response headers from the model provider. Contains rate limit information (e.g.,
|
|
325
|
+
**response.headers** (`Record<string, string>`): HTTP response headers from the model provider. Contains rate limit information (e.g., anthropic-ratelimit-requests-remaining, x-ratelimit-remaining-tokens) and other provider-specific metadata.
|
|
326
326
|
|
|
327
327
|
**response.messages** (`ResponseMessage[]`): Response messages in model format.
|
|
328
328
|
|
|
@@ -344,7 +344,7 @@ For the streaming version of the same chunk shape, see the [ChunkType reference]
|
|
|
344
344
|
|
|
345
345
|
**files** (`FileChunk[]`): Files generated by the model.
|
|
346
346
|
|
|
347
|
-
**suspendPayload** (`object`): Present when
|
|
347
|
+
**suspendPayload** (`object`): Present when finishReason is 'suspended'. Contains tool call details needed to approve or decline the pending tool call.
|
|
348
348
|
|
|
349
349
|
**suspendPayload.toolCallId** (`string`): Unique identifier for the pending tool call.
|
|
350
350
|
|
|
@@ -352,7 +352,7 @@ For the streaming version of the same chunk shape, see the [ChunkType reference]
|
|
|
352
352
|
|
|
353
353
|
**suspendPayload.args** (`Record<string, any>`): Arguments that will be passed to the tool.
|
|
354
354
|
|
|
355
|
-
**runId** (`string`): Unique identifier for this execution run. Required when calling
|
|
355
|
+
**runId** (`string`): Unique identifier for this execution run. Required when calling approveToolCallGenerate() or declineToolCallGenerate() to resume a suspended execution.
|
|
356
356
|
|
|
357
357
|
**traceId** (`string`): The trace ID associated with this execution when Tracing is enabled. Use this to correlate logs and debug execution flow.
|
|
358
358
|
|
|
@@ -366,7 +366,7 @@ For the streaming version of the same chunk shape, see the [ChunkType reference]
|
|
|
366
366
|
|
|
367
367
|
**tripwire** (`StepTripwireData`): Tripwire data if content was blocked by a processor.
|
|
368
368
|
|
|
369
|
-
**scoringData** (`object`): Scoring data for evals when
|
|
369
|
+
**scoringData** (`object`): Scoring data for evals when returnScorerData is enabled.
|
|
370
370
|
|
|
371
371
|
## More examples
|
|
372
372
|
|