@mastra/mcp-docs-server 1.2.5-alpha.1 → 1.2.5-alpha.5
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 +1 -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/nvidia.md +3 -2
- package/.docs/models/providers/tencent-token-plan.md +7 -7
- package/.docs/models/providers/tencent-tokenhub.md +5 -4
- package/.docs/models/providers.md +1 -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 +4 -4
- 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
|
@@ -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
|
|
|
@@ -34,11 +34,11 @@ await agent.generateLegacy('message for agent')
|
|
|
34
34
|
|
|
35
35
|
**options.structuredOutput.instructions** (`string`): Custom instructions for the structuring agent.
|
|
36
36
|
|
|
37
|
-
**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
|
|
37
|
+
**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.
|
|
38
38
|
|
|
39
|
-
**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
|
|
39
|
+
**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.
|
|
40
40
|
|
|
41
|
-
**options.experimental\_output** (`Zod schema | JsonSchema7`): Note, the preferred route is to use the
|
|
41
|
+
**options.experimental\_output** (`Zod schema | JsonSchema7`): Note, the preferred route is to use the structuredOutput property. Enables structured output generation alongside text generation and tool calls. The model will generate responses that conform to the provided schema.
|
|
42
42
|
|
|
43
43
|
**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.
|
|
44
44
|
|
|
@@ -46,11 +46,11 @@ await agent.generateLegacy('message for agent')
|
|
|
46
46
|
|
|
47
47
|
**options.memory** (`object`): Configuration for memory. This is the preferred way to manage memory.
|
|
48
48
|
|
|
49
|
-
**options.memory.thread** (`string | { id: string; metadata?: Record<string, any>, title?: string }`): The conversation thread, as a string ID or an object with an
|
|
49
|
+
**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.
|
|
50
50
|
|
|
51
51
|
**options.memory.resource** (`string`): Identifier for the user or resource associated with the thread.
|
|
52
52
|
|
|
53
|
-
**options.memory.options** (`MemoryConfig`): Configuration for memory behavior, like message history and semantic recall. See
|
|
53
|
+
**options.memory.options** (`MemoryConfig`): Configuration for memory behavior, like message history and semantic recall. See MemoryConfig below.
|
|
54
54
|
|
|
55
55
|
**options.maxSteps** (`number`): Maximum number of execution steps allowed.
|
|
56
56
|
|
|
@@ -86,17 +86,17 @@ await agent.generateLegacy('message for agent')
|
|
|
86
86
|
|
|
87
87
|
**options.clientTools** (`ToolsInput`): Tools that are executed on the 'client' side of the request. These tools do not have execute functions in the definition.
|
|
88
88
|
|
|
89
|
-
**options.hooks** (`ToolHooks`): Per-execution hooks that run before and after tool calls. Overrides matching agent-level hooks for this execution.
|
|
89
|
+
**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.
|
|
90
90
|
|
|
91
91
|
**options.savePerStep** (`boolean`): Save messages incrementally after each generation step completes (default: false). Disabled internally when observational memory is enabled.
|
|
92
92
|
|
|
93
|
-
**options.providerOptions** (`Record<string, Record<string, JSONValue>>`): Additional provider-specific options that are passed through to the underlying LLM provider. The structure is
|
|
93
|
+
**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 } }. Since Mastra extends AI SDK, see the AI SDK documentation for complete provider options.
|
|
94
94
|
|
|
95
|
-
**options.providerOptions.openai** (`Record<string, JSONValue>`): OpenAI-specific options. Example:
|
|
95
|
+
**options.providerOptions.openai** (`Record<string, JSONValue>`): OpenAI-specific options. Example: { reasoningEffort: 'high' }
|
|
96
96
|
|
|
97
|
-
**options.providerOptions.anthropic** (`Record<string, JSONValue>`): Anthropic-specific options. Example:
|
|
97
|
+
**options.providerOptions.anthropic** (`Record<string, JSONValue>`): Anthropic-specific options. Example: { maxTokens: 1000 }
|
|
98
98
|
|
|
99
|
-
**options.providerOptions.google** (`Record<string, JSONValue>`): Google-specific options. Example:
|
|
99
|
+
**options.providerOptions.google** (`Record<string, JSONValue>`): Google-specific options. Example: { safetySettings: \[...] }
|
|
100
100
|
|
|
101
101
|
**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.
|
|
102
102
|
|
|
@@ -104,7 +104,7 @@ await agent.generateLegacy('message for agent')
|
|
|
104
104
|
|
|
105
105
|
**options.maxTokens** (`number`): Maximum number of tokens to generate.
|
|
106
106
|
|
|
107
|
-
**options.topP** (`number`): Nucleus sampling. This is a number between 0 and 1. It is recommended to set either
|
|
107
|
+
**options.topP** (`number`): Nucleus sampling. This is a number between 0 and 1. It is recommended to set either temperature or topP, but not both.
|
|
108
108
|
|
|
109
109
|
**options.topK** (`number`): Only sample from the top K options for each subsequent token. Used to remove 'long tail' low probability responses.
|
|
110
110
|
|
|
@@ -122,7 +122,7 @@ await agent.generateLegacy('message for agent')
|
|
|
122
122
|
|
|
123
123
|
**text** (`string`): The generated text response. Present when output is 'text' (no schema provided).
|
|
124
124
|
|
|
125
|
-
**object** (`object`): The generated structured response. Present when a schema is provided via
|
|
125
|
+
**object** (`object`): The generated structured response. Present when a schema is provided via output, structuredOutput, or experimental\_output.
|
|
126
126
|
|
|
127
127
|
**toolCalls** (`Array<ToolCall>`): The tool calls made during the generation process. Present in both text and object modes.
|
|
128
128
|
|
|
@@ -18,7 +18,7 @@ await agent.getMetadata()
|
|
|
18
18
|
|
|
19
19
|
## Returns
|
|
20
20
|
|
|
21
|
-
**metadata** (`Record<string, unknown> | Promise<Record<string, unknown>>`): The metadata configured for the agent, or
|
|
21
|
+
**metadata** (`Record<string, unknown> | Promise<Record<string, unknown>>`): The metadata configured for the agent, or undefined if no metadata was configured. Returns either directly or as a promise that resolves to the metadata when defined as a function.
|
|
22
22
|
|
|
23
23
|
## Extended usage example
|
|
24
24
|
|
|
@@ -65,7 +65,7 @@ Returns: [`InngestAgent`](#inngestagent-interface)
|
|
|
65
65
|
|
|
66
66
|
### Parameters
|
|
67
67
|
|
|
68
|
-
**agent** (`Agent`): The Agent to wrap with Inngest durable execution. Agent methods (e.g.,
|
|
68
|
+
**agent** (`Agent`): The Agent to wrap with Inngest durable execution. Agent methods (e.g., generate(), listTools(), getMemory()) delegate to this agent via a Proxy.
|
|
69
69
|
|
|
70
70
|
**inngest** (`Inngest`): The Inngest client instance. Used to send workflow events and, in SDK v4, publish realtime stream events.
|
|
71
71
|
|
|
@@ -73,9 +73,9 @@ Returns: [`InngestAgent`](#inngestagent-interface)
|
|
|
73
73
|
|
|
74
74
|
**name** (`string`): Name override. (Default: `agent.name`)
|
|
75
75
|
|
|
76
|
-
**pubsub** (`PubSub`): PubSub instance for streaming events. The default
|
|
76
|
+
**pubsub** (`PubSub`): PubSub instance for streaming events. The default InngestPubSub uses Inngest Realtime, which works across processes. (Default: `InngestPubSub`)
|
|
77
77
|
|
|
78
|
-
**cache** (`MastraServerCache`): Cache for stored stream events, which enables resumable streams. When provided, the PubSub is automatically wrapped with
|
|
78
|
+
**cache** (`MastraServerCache`): Cache for stored stream events, which enables resumable streams. When provided, the PubSub is automatically wrapped with CachingPubSub. If omitted, the agent inherits the cache from the Mastra instance.
|
|
79
79
|
|
|
80
80
|
**mastra** (`Mastra`): Mastra instance for observability. Set automatically when the agent is registered with Mastra.
|
|
81
81
|
|
|
@@ -216,7 +216,7 @@ Returns: `boolean`
|
|
|
216
216
|
|
|
217
217
|
`stream()` accepts an `InngestAgentStreamOptions` object. It supports the same agent execution options as [`DurableAgent.stream()`](https://mastra.ai/reference/agents/durable-agent), plus lifecycle callbacks.
|
|
218
218
|
|
|
219
|
-
**runId** (`string`): Unique identifier for this run. Use it later with
|
|
219
|
+
**runId** (`string`): Unique identifier for this run. Use it later with resume() or observe().
|
|
220
220
|
|
|
221
221
|
**instructions** (`AgentExecutionOptions['instructions']`): Overrides the agent's default instructions for this run.
|
|
222
222
|
|
|
@@ -238,7 +238,7 @@ Returns: `boolean`
|
|
|
238
238
|
|
|
239
239
|
**requireToolApproval** (`boolean`): Require approval for all tool calls, which suspends the run until resumed.
|
|
240
240
|
|
|
241
|
-
**autoResumeSuspendedTools** (`boolean`): Automatically resume tools that suspended, instead of waiting for an external
|
|
241
|
+
**autoResumeSuspendedTools** (`boolean`): Automatically resume tools that suspended, instead of waiting for an external resume() call.
|
|
242
242
|
|
|
243
243
|
**toolCallConcurrency** (`number`): Maximum number of tool calls to execute concurrently.
|
|
244
244
|
|
|
@@ -246,7 +246,7 @@ Returns: `boolean`
|
|
|
246
246
|
|
|
247
247
|
**maxProcessorRetries** (`number`): Maximum number of processor retries per generation.
|
|
248
248
|
|
|
249
|
-
**untilIdle** (`boolean | { maxIdleMs?: number }`): When set, keeps the stream open across background-task continuations until the agent is idle. Pass
|
|
249
|
+
**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.
|
|
250
250
|
|
|
251
251
|
**onChunk** (`(chunk: ChunkType) => void | Promise<void>`): Called for each streamed chunk.
|
|
252
252
|
|
|
@@ -275,11 +275,11 @@ interface InngestAgentStreamResult<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
|
|
|
@@ -52,7 +52,7 @@ await agent.network(`
|
|
|
52
52
|
|
|
53
53
|
**options.memory** (`object`): Configuration for memory. This is the preferred way to manage memory.
|
|
54
54
|
|
|
55
|
-
**options.memory.thread** (`string | { id: string; metadata?: Record<string, any>, title?: string }`): The conversation thread, as a string ID or an object with an
|
|
55
|
+
**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.
|
|
56
56
|
|
|
57
57
|
**options.memory.resource** (`string`): Identifier for the user or resource associated with the thread.
|
|
58
58
|
|
|
@@ -51,13 +51,13 @@ export const mastra = new Mastra({
|
|
|
51
51
|
|
|
52
52
|
## Parameters
|
|
53
53
|
|
|
54
|
-
**version** (`'v5' | 'v6'`): Selects the AI SDK stream contract to emit. Omit it or pass
|
|
54
|
+
**version** (`'v5' | 'v6'`): Selects the AI SDK stream contract to emit. Omit it or pass 'v5' for the existing default behavior. Pass 'v6' when your app is typed against AI SDK v6 response helpers. (Default: `'v5'`)
|
|
55
55
|
|
|
56
|
-
**path** (`string`): The route path (e.g.,
|
|
56
|
+
**path** (`string`): The route path (e.g., /chat or /chat/:agentId). Include :agentId for dynamic agent routing. (Default: `'/chat/:agentId'`)
|
|
57
57
|
|
|
58
|
-
**agent** (`string`): The ID of the agent to use for this chat route. Required if the path doesn't include
|
|
58
|
+
**agent** (`string`): The ID of the agent to use for this chat route. Required if the path doesn't include :agentId.
|
|
59
59
|
|
|
60
|
-
**agentVersion** (`{ versionId: string } | { status?: 'draft' | 'published' }`): Selects a specific agent version. Pass
|
|
60
|
+
**agentVersion** (`{ versionId: string } | { status?: 'draft' | 'published' }`): Selects a specific agent version. Pass { versionId: '\<id>' } to target an exact version, or { status: 'draft' } / { status: 'published' } to resolve by status. When the route is called, query parameters ?versionId=\<id> or ?status=draft|published take precedence over this static value. Requires the Editor to be configured.
|
|
61
61
|
|
|
62
62
|
**defaultOptions** (`AgentExecutionOptions`): Default options passed to agent execution. These can include instructions, memory configuration, maxSteps, and other execution settings.
|
|
63
63
|
|
|
@@ -50,23 +50,23 @@ export async function POST(req: Request) {
|
|
|
50
50
|
|
|
51
51
|
## Parameters
|
|
52
52
|
|
|
53
|
-
**version** (`'v5' | 'v6'`): Selects the AI SDK stream contract to emit. Omit it or pass
|
|
53
|
+
**version** (`'v5' | 'v6'`): Selects the AI SDK stream contract to emit. Omit it or pass 'v5' for the existing default behavior. Pass 'v6' when your app is typed against AI SDK v6 response helpers. (Default: `'v5'`)
|
|
54
54
|
|
|
55
55
|
**mastra** (`Mastra`): The Mastra instance containing registered agents.
|
|
56
56
|
|
|
57
57
|
**agentId** (`string`): The ID of the agent to use for chat.
|
|
58
58
|
|
|
59
|
-
**agentVersion** (`{ versionId: string } | { status?: 'draft' | 'published' }`): Selects a specific agent version. Pass
|
|
59
|
+
**agentVersion** (`{ versionId: string } | { status?: 'draft' | 'published' }`): Selects a specific agent version. Pass { versionId: '\<id>' } to target an exact version, or { status: 'draft' } / { status: 'published' } to resolve by status. Requires the Editor to be configured.
|
|
60
60
|
|
|
61
61
|
**params** (`ChatStreamHandlerParams`): Parameters for the chat stream, including messages and optional resume data.
|
|
62
62
|
|
|
63
63
|
**params.messages** (`UIMessage[]`): Array of messages in the conversation.
|
|
64
64
|
|
|
65
|
-
**params.resumeData** (`Record<string, any>`): Data for resuming a suspended agent execution. Requires
|
|
65
|
+
**params.resumeData** (`Record<string, any>`): Data for resuming a suspended agent execution. Requires runId to be set.
|
|
66
66
|
|
|
67
|
-
**params.runId** (`string`): The run ID. Required when
|
|
67
|
+
**params.runId** (`string`): The run ID. Required when resumeData is provided.
|
|
68
68
|
|
|
69
|
-
**params.providerOptions** (`Record<string, Record<string, unknown>>`): Provider-specific options passed to the language model (e.g.
|
|
69
|
+
**params.providerOptions** (`Record<string, Record<string, unknown>>`): Provider-specific options passed to the language model (e.g. { openai: { reasoningEffort: "high" } }). Merged with defaultOptions.providerOptions, with params taking precedence.
|
|
70
70
|
|
|
71
71
|
**params.requestContext** (`RequestContext`): Request context to pass to the agent execution.
|
|
72
72
|
|
|
@@ -82,4 +82,4 @@ export async function POST(req: Request) {
|
|
|
82
82
|
|
|
83
83
|
**onError** (`(error: unknown) => string`): Called when the stream encounters an error. Return the string that will be sent to the client as the error message. Use this to sanitize errors before they reach the client — for example, to prevent internal infrastructure details from leaking to end users.
|
|
84
84
|
|
|
85
|
-
**messageMetadata** (`(options: { part: UIMessageStreamPart }) => Record<string, unknown> | undefined`): A function that receives the current stream part and returns metadata to attach to start and finish chunks. See the
|
|
85
|
+
**messageMetadata** (`(options: { part: UIMessageStreamPart }) => Record<string, unknown> | undefined`): A function that receives the current stream part and returns metadata to attach to start and finish chunks. See the AI SDK message metadata docs for details.
|
|
@@ -34,14 +34,14 @@ export async function POST(req: Request) {
|
|
|
34
34
|
|
|
35
35
|
## Parameters
|
|
36
36
|
|
|
37
|
-
**version** (`'v5' | 'v6'`): Selects the AI SDK stream contract to emit. Omit it or pass
|
|
37
|
+
**version** (`'v5' | 'v6'`): Selects the AI SDK stream contract to emit. Omit it or pass 'v5' for the existing default behavior. Pass 'v6' when your app is typed against AI SDK v6 response helpers. (Default: `'v5'`)
|
|
38
38
|
|
|
39
39
|
**mastra** (`Mastra`): The Mastra instance to use for agent lookup and execution.
|
|
40
40
|
|
|
41
41
|
**agentId** (`string`): The ID of the routing agent to execute as a network.
|
|
42
42
|
|
|
43
|
-
**agentVersion** (`{ versionId: string } | { status?: 'draft' | 'published' }`): Selects a specific agent version. Pass
|
|
43
|
+
**agentVersion** (`{ versionId: string } | { status?: 'draft' | 'published' }`): Selects a specific agent version. Pass { versionId: '\<id>' } to target an exact version, or { status: 'draft' } / { status: 'published' } to resolve by status. Requires the Editor to be configured.
|
|
44
44
|
|
|
45
|
-
**params** (`NetworkStreamHandlerParams`): The request parameters containing messages and execution options. Includes
|
|
45
|
+
**params** (`NetworkStreamHandlerParams`): The request parameters containing messages and execution options. Includes messages (required) and any AgentExecutionOptions like memory, maxSteps, runId, etc.
|
|
46
46
|
|
|
47
47
|
**defaultOptions** (`AgentExecutionOptions`): Default options passed to agent execution. These are merged with params, with params taking precedence.
|
|
@@ -36,7 +36,7 @@ export async function POST(req: Request) {
|
|
|
36
36
|
|
|
37
37
|
## Parameters
|
|
38
38
|
|
|
39
|
-
**version** (`'v5' | 'v6'`): Selects the AI SDK stream contract to emit. Omit it or pass
|
|
39
|
+
**version** (`'v5' | 'v6'`): Selects the AI SDK stream contract to emit. Omit it or pass 'v5' for the existing default behavior. Pass 'v6' when your app is typed against AI SDK v6 response helpers. (Default: `'v5'`)
|
|
40
40
|
|
|
41
41
|
**mastra** (`Mastra`): The Mastra instance containing registered workflows.
|
|
42
42
|
|