@mastra/mcp-docs-server 1.1.41 → 1.1.42-alpha.11
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/access-control.md +97 -0
- package/.docs/docs/agent-builder/browser.md +61 -0
- package/.docs/docs/agent-builder/channels.md +76 -0
- package/.docs/docs/agent-builder/configuration.md +147 -0
- package/.docs/docs/agent-builder/deploying.md +121 -0
- package/.docs/docs/agent-builder/memory.md +65 -0
- package/.docs/docs/agent-builder/model-policy.md +48 -0
- package/.docs/docs/agent-builder/overview.md +97 -0
- package/.docs/docs/agent-builder/skill-registries.md +31 -0
- package/.docs/docs/agent-builder/workspace.md +60 -0
- package/.docs/docs/agents/a2a.md +1 -1
- package/.docs/docs/agents/acp.md +4 -4
- package/.docs/docs/agents/adding-voice.md +37 -6
- package/.docs/docs/agents/agent-approval.md +15 -1
- package/.docs/docs/agents/background-tasks.md +2 -2
- package/.docs/docs/agents/channels.md +3 -1
- package/.docs/docs/agents/code-mode.md +163 -0
- package/.docs/docs/agents/guardrails.md +2 -2
- package/.docs/docs/agents/networks.md +1 -1
- package/.docs/docs/agents/overview.md +1 -1
- package/.docs/docs/agents/processors.md +3 -3
- package/.docs/docs/agents/response-caching.md +1 -1
- package/.docs/docs/agents/sdk-agents.md +261 -0
- package/.docs/docs/agents/signals.md +150 -73
- package/.docs/docs/agents/structured-output.md +5 -5
- package/.docs/docs/agents/supervisor-agents.md +2 -2
- package/.docs/docs/agents/using-tools.md +5 -5
- package/.docs/docs/browser/agent-browser.md +1 -1
- package/.docs/docs/browser/browser-viewer.md +1 -1
- package/.docs/docs/browser/overview.md +1 -1
- package/.docs/docs/browser/stagehand.md +5 -5
- package/.docs/docs/editor/overview.md +70 -8
- package/.docs/docs/evals/custom-scorers.md +1 -1
- package/.docs/docs/evals/datasets/running-experiments.md +1 -1
- package/.docs/docs/evals/overview.md +2 -2
- package/.docs/docs/getting-started/manual-install.md +1 -1
- package/.docs/docs/mcp/mcp-apps.md +3 -3
- package/.docs/docs/mcp/overview.md +1 -1
- package/.docs/docs/memory/memory-processors.md +6 -6
- package/.docs/docs/memory/multi-user-threads.md +1 -1
- package/.docs/docs/memory/observational-memory.md +19 -0
- package/.docs/docs/memory/semantic-recall.md +2 -2
- package/.docs/docs/memory/storage.md +2 -1
- package/.docs/docs/memory/working-memory.md +1 -1
- package/.docs/docs/observability/metrics/overview.md +1 -0
- package/.docs/docs/observability/metrics/querying.md +292 -0
- package/.docs/docs/observability/tracing/exporters/langfuse.md +1 -1
- package/.docs/docs/observability/tracing/exporters/langsmith.md +2 -2
- package/.docs/docs/rag/graph-rag.md +2 -2
- package/.docs/docs/rag/retrieval.md +12 -12
- package/.docs/docs/server/auth/fga.md +4 -0
- package/.docs/docs/server/mastra-client.md +1 -1
- package/.docs/docs/server/request-context.md +3 -3
- package/.docs/docs/streaming/overview.md +1 -1
- package/.docs/docs/streaming/tool-streaming.md +1 -1
- package/.docs/docs/voice/overview.md +86 -24
- package/.docs/docs/voice/speech-to-speech.md +55 -4
- package/.docs/docs/voice/speech-to-text.md +1 -1
- package/.docs/docs/voice/text-to-speech.md +1 -1
- package/.docs/docs/workspace/filesystem.md +2 -2
- package/.docs/docs/workspace/overview.md +1 -1
- package/.docs/docs/workspace/sandbox.md +5 -3
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +1 -1
- package/.docs/guides/deployment/inngest.md +69 -0
- package/.docs/guides/guide/ai-recruiter.md +1 -1
- package/.docs/guides/guide/chef-michel.md +1 -1
- package/.docs/guides/guide/code-review-bot.md +1 -1
- package/.docs/guides/guide/dev-assistant.md +1 -1
- package/.docs/guides/guide/docs-manager.md +1 -1
- package/.docs/guides/guide/firecrawl.md +6 -6
- package/.docs/guides/guide/github-actions-pr-description.md +1 -1
- package/.docs/guides/guide/research-assistant.md +1 -1
- package/.docs/guides/guide/research-coordinator.md +2 -2
- package/.docs/guides/guide/slack-assistant.md +1 -1
- package/.docs/guides/guide/stock-agent.md +2 -2
- package/.docs/guides/guide/whatsapp-chat-bot.md +2 -2
- package/.docs/guides/migrations/agentnetwork.md +4 -4
- package/.docs/guides/migrations/upgrade-to-v1/agent.md +1 -1
- package/.docs/guides/migrations/vnext-to-standard-apis.md +2 -2
- package/.docs/models/embeddings.md +2 -2
- package/.docs/reference/agents/agent.md +60 -21
- package/.docs/reference/agents/channels.md +48 -6
- package/.docs/reference/agents/generateLegacy.md +1 -1
- package/.docs/reference/agents/getLLM.md +2 -2
- package/.docs/reference/agents/getMetadata.md +2 -2
- package/.docs/reference/agents/network.md +1 -1
- package/.docs/reference/browser/agent-browser.md +1 -1
- package/.docs/reference/browser/browser-viewer.md +1 -1
- package/.docs/reference/browser/mastra-browser.md +1 -1
- package/.docs/reference/browser/stagehand-browser.md +5 -5
- package/.docs/reference/client-js/agent-builder.md +161 -0
- package/.docs/reference/client-js/agents.md +19 -2
- package/.docs/reference/client-js/mastra-client.md +4 -0
- package/.docs/reference/configuration.md +1 -1
- package/.docs/reference/editor/agent-builder/agent-builder-options.md +74 -0
- package/.docs/reference/editor/agent-builder/builder-agent-defaults.md +77 -0
- package/.docs/reference/editor/agent-builder/builder-models.md +64 -0
- package/.docs/reference/editor/blob-store-provider.md +59 -0
- package/.docs/reference/editor/browser-provider.md +75 -0
- package/.docs/reference/editor/filesystem-provider.md +62 -0
- package/.docs/reference/editor/mastra-editor.md +61 -1
- package/.docs/reference/editor/processor-provider.md +64 -0
- package/.docs/reference/editor/sandbox-provider.md +61 -0
- package/.docs/reference/editor/storage-browser-ref.md +80 -0
- package/.docs/reference/editor/storage-workspace-ref.md +93 -0
- package/.docs/reference/evals/answer-relevancy.md +1 -1
- package/.docs/reference/evals/answer-similarity.md +1 -1
- package/.docs/reference/evals/bias.md +1 -1
- package/.docs/reference/evals/context-precision.md +3 -3
- package/.docs/reference/evals/context-relevance.md +11 -11
- package/.docs/reference/evals/create-scorer.md +2 -0
- package/.docs/reference/evals/faithfulness.md +1 -1
- package/.docs/reference/evals/hallucination.md +5 -5
- package/.docs/reference/evals/noise-sensitivity.md +11 -11
- package/.docs/reference/evals/prompt-alignment.md +15 -15
- package/.docs/reference/evals/tool-call-accuracy.md +3 -3
- package/.docs/reference/evals/toxicity.md +1 -1
- package/.docs/reference/index.md +15 -0
- package/.docs/reference/memory/memory-class.md +3 -3
- package/.docs/reference/memory/observational-memory.md +6 -4
- package/.docs/reference/memory/serialized-memory-config.md +72 -0
- package/.docs/reference/observability/metrics/automatic-metrics.md +7 -1
- package/.docs/reference/observability/tracing/exporters/langfuse.md +1 -1
- package/.docs/reference/processors/batch-parts-processor.md +1 -1
- package/.docs/reference/processors/cost-guard-processor.md +1 -1
- package/.docs/reference/processors/language-detector.md +1 -1
- package/.docs/reference/processors/message-history-processor.md +1 -1
- package/.docs/reference/processors/moderation-processor.md +2 -2
- package/.docs/reference/processors/pii-detector.md +2 -2
- package/.docs/reference/processors/prefill-error-handler.md +2 -2
- package/.docs/reference/processors/processor-interface.md +2 -2
- package/.docs/reference/processors/prompt-injection-detector.md +1 -1
- package/.docs/reference/processors/regex-filter-processor.md +1 -1
- package/.docs/reference/processors/semantic-recall-processor.md +1 -1
- package/.docs/reference/processors/skill-search-processor.md +1 -1
- package/.docs/reference/processors/system-prompt-scrubber.md +1 -1
- package/.docs/reference/processors/token-limiter-processor.md +3 -3
- package/.docs/reference/processors/tool-call-filter.md +2 -2
- package/.docs/reference/processors/tool-search-processor.md +33 -2
- package/.docs/reference/processors/unicode-normalizer.md +1 -1
- package/.docs/reference/processors/working-memory-processor.md +1 -1
- package/.docs/reference/rag/rerank.md +1 -1
- package/.docs/reference/server/nestjs-adapter.md +1 -1
- package/.docs/reference/server/routes.md +108 -9
- package/.docs/reference/storage/dsql.md +1 -1
- package/.docs/reference/storage/mongodb.md +1 -1
- package/.docs/reference/storage/postgresql.md +1 -1
- package/.docs/reference/storage/redis.md +1 -1
- package/.docs/reference/storage/spanner.md +5 -0
- package/.docs/reference/storage/upstash.md +1 -1
- package/.docs/reference/streaming/agents/stream.md +1 -1
- package/.docs/reference/templates/overview.md +3 -3
- package/.docs/reference/tools/mcp-client.md +53 -2
- package/.docs/reference/tools/mcp-server.md +33 -1
- package/.docs/reference/tools/vector-query-tool.md +1 -1
- package/.docs/reference/vectors/libsql.md +1 -1
- package/.docs/reference/vectors/mongodb.md +1 -1
- package/.docs/reference/vectors/pg.md +3 -1
- package/.docs/reference/vectors/upstash.md +1 -1
- package/.docs/reference/voice/google-gemini-live.md +15 -2
- package/.docs/reference/voice/inworld-realtime.md +353 -0
- package/.docs/reference/voice/inworld.md +2 -0
- package/.docs/reference/voice/voice.addInstructions.md +1 -1
- package/.docs/reference/workspace/agentcore-runtime-sandbox.md +202 -0
- package/.docs/reference/workspace/agentfs-filesystem.md +1 -1
- package/.docs/reference/workspace/azure-blob-filesystem.md +1 -1
- package/.docs/reference/workspace/blaxel-sandbox.md +3 -0
- package/.docs/reference/workspace/docker-sandbox.md +4 -2
- package/.docs/reference/workspace/e2b-sandbox.md +9 -5
- package/.docs/reference/workspace/files-sdk-filesystem.md +1 -1
- package/.docs/reference/workspace/gcs-filesystem.md +1 -1
- package/.docs/reference/workspace/google-drive-filesystem.md +1 -1
- package/.docs/reference/workspace/local-filesystem.md +1 -1
- package/.docs/reference/workspace/local-sandbox.md +1 -1
- package/.docs/reference/workspace/modal-sandbox.md +1 -1
- package/.docs/reference/workspace/s3-filesystem.md +1 -1
- package/.docs/reference/workspace/vercel-microvm-sandbox.md +199 -0
- package/.docs/reference/workspace/vercel.md +2 -0
- package/CHANGELOG.md +72 -0
- package/package.json +8 -6
|
@@ -48,7 +48,7 @@ export const slackAgent = new Agent({
|
|
|
48
48
|
name: 'Slack Agent',
|
|
49
49
|
instructions:
|
|
50
50
|
'You are a helpful assistant. Answer questions, help with tasks, and have natural conversations.',
|
|
51
|
-
model: 'anthropic/claude-opus-4-
|
|
51
|
+
model: 'anthropic/claude-opus-4-7',
|
|
52
52
|
channels: {
|
|
53
53
|
adapters: {
|
|
54
54
|
slack: createSlackAdapter(),
|
|
@@ -24,7 +24,7 @@ To create an agent in Mastra use the `Agent` class to define it and then registe
|
|
|
24
24
|
name: 'Stock Agent',
|
|
25
25
|
instructions:
|
|
26
26
|
'You are a helpful assistant that provides current stock prices. When asked about a stock, use the stock price tool to fetch the stock price.',
|
|
27
|
-
model: 'openai/gpt-5.
|
|
27
|
+
model: 'openai/gpt-5.5',
|
|
28
28
|
})
|
|
29
29
|
```
|
|
30
30
|
|
|
@@ -83,7 +83,7 @@ The Stock Agent doesn't yet know anything about current stock prices. To change
|
|
|
83
83
|
name: 'Stock Agent',
|
|
84
84
|
instructions:
|
|
85
85
|
'You are a helpful assistant that provides current stock prices. When asked about a stock, use the stock price tool to fetch the stock price.',
|
|
86
|
-
model: 'openai/gpt-5.
|
|
86
|
+
model: 'openai/gpt-5.5',
|
|
87
87
|
tools: {
|
|
88
88
|
stockPrices,
|
|
89
89
|
},
|
|
@@ -117,7 +117,7 @@ export const chatAgent = new Agent({
|
|
|
117
117
|
|
|
118
118
|
Always aim to be helpful while maintaining a friendly, approachable conversation style.
|
|
119
119
|
`,
|
|
120
|
-
model: 'openai/gpt-5.
|
|
120
|
+
model: 'openai/gpt-5.5',
|
|
121
121
|
memory: new Memory({
|
|
122
122
|
storage: new LibSQLStore({
|
|
123
123
|
id: 'agent-storage',
|
|
@@ -155,7 +155,7 @@ export const textMessageAgent = new Agent({
|
|
|
155
155
|
|
|
156
156
|
Always return exactly 5-8 messages in the messages array.
|
|
157
157
|
`,
|
|
158
|
-
model: 'openai/gpt-5.
|
|
158
|
+
model: 'openai/gpt-5.5',
|
|
159
159
|
memory: new Memory({
|
|
160
160
|
storage: new LibSQLStore({
|
|
161
161
|
id: 'agent-storage',
|
|
@@ -27,7 +27,7 @@ const agent = new AgentNetwork({
|
|
|
27
27
|
name: 'agent-network',
|
|
28
28
|
agents: [agent1, agent2],
|
|
29
29
|
tools: { tool1, tool2 },
|
|
30
|
-
model: 'openai/gpt-5.
|
|
30
|
+
model: 'openai/gpt-5.5',
|
|
31
31
|
instructions: 'You are a network agent that can help users with a variety of tasks.',
|
|
32
32
|
})
|
|
33
33
|
|
|
@@ -47,7 +47,7 @@ const agent = new Agent({
|
|
|
47
47
|
name: 'agent-network',
|
|
48
48
|
agents: { agent1, agent2 },
|
|
49
49
|
tools: { tool1, tool2 },
|
|
50
|
-
model: 'openai/gpt-5.
|
|
50
|
+
model: 'openai/gpt-5.5',
|
|
51
51
|
instructions: 'You are a network agent that can help users with a variety of tasks.',
|
|
52
52
|
memory,
|
|
53
53
|
})
|
|
@@ -68,7 +68,7 @@ const agent = new NewAgentNetwork({
|
|
|
68
68
|
agents: { agent1, agent2 },
|
|
69
69
|
workflows: { workflow1 },
|
|
70
70
|
tools: { tool1, tool2 },
|
|
71
|
-
model: 'openai/gpt-5.
|
|
71
|
+
model: 'openai/gpt-5.5',
|
|
72
72
|
instructions: 'You are a network agent that can help users with a variety of tasks.',
|
|
73
73
|
})
|
|
74
74
|
|
|
@@ -88,7 +88,7 @@ const agent = new Agent({
|
|
|
88
88
|
agents: { agent1, agent2 },
|
|
89
89
|
workflows: { workflow1 },
|
|
90
90
|
tools: { tool1, tool2 },
|
|
91
|
-
model: 'openai/gpt-5.
|
|
91
|
+
model: 'openai/gpt-5.5',
|
|
92
92
|
instructions: 'You are a network agent that can help users with a variety of tasks.',
|
|
93
93
|
memory,
|
|
94
94
|
})
|
|
@@ -159,7 +159,7 @@ The following options are available in the standard `.stream()` and `generate()`
|
|
|
159
159
|
name: z.string(),
|
|
160
160
|
age: z.number(),
|
|
161
161
|
}),
|
|
162
|
-
model: 'openai/gpt-5.
|
|
162
|
+
model: 'openai/gpt-5.5', // Optional model override for structuring
|
|
163
163
|
errorStrategy: 'fallback',
|
|
164
164
|
fallbackValue: { name: 'unknown', age: 0 },
|
|
165
165
|
instructions: 'Extract user information', // Override default structuring instructions
|
|
@@ -299,7 +299,7 @@ The following options are available in the standard `.stream()` and `generate()`
|
|
|
299
299
|
schema: z.object({
|
|
300
300
|
summary: z.string(),
|
|
301
301
|
}),
|
|
302
|
-
model: 'openai/gpt-5.
|
|
302
|
+
model: 'openai/gpt-5.5',
|
|
303
303
|
},
|
|
304
304
|
})
|
|
305
305
|
```
|
|
@@ -40,12 +40,12 @@ const embedder = new ModelRouterEmbeddingModel("google/gemini-embedding-001");
|
|
|
40
40
|
The model router automatically detects API keys from environment variables:
|
|
41
41
|
|
|
42
42
|
- **OpenAI**: `OPENAI_API_KEY`
|
|
43
|
-
- **Google**: `GOOGLE_GENERATIVE_AI_API_KEY`
|
|
43
|
+
- **Google**: `GOOGLE_API_KEY` (falls back to `GOOGLE_GENERATIVE_AI_API_KEY`)
|
|
44
44
|
|
|
45
45
|
```bash
|
|
46
46
|
# .env
|
|
47
47
|
OPENAI_API_KEY=sk-...
|
|
48
|
-
|
|
48
|
+
GOOGLE_API_KEY=...
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
## Custom Providers
|
|
@@ -16,7 +16,7 @@ export const agent = new Agent({
|
|
|
16
16
|
id: 'test-agent',
|
|
17
17
|
name: 'Test Agent',
|
|
18
18
|
instructions: 'You are a helpful assistant that provides concise answers.',
|
|
19
|
-
model: 'openai/gpt-5.
|
|
19
|
+
model: 'openai/gpt-5.5',
|
|
20
20
|
})
|
|
21
21
|
|
|
22
22
|
// System message object
|
|
@@ -27,7 +27,7 @@ export const agent2 = new Agent({
|
|
|
27
27
|
role: 'system',
|
|
28
28
|
content: 'You are an expert programmer',
|
|
29
29
|
},
|
|
30
|
-
model: 'openai/gpt-5.
|
|
30
|
+
model: 'openai/gpt-5.5',
|
|
31
31
|
})
|
|
32
32
|
|
|
33
33
|
// Array of system messages
|
|
@@ -38,7 +38,7 @@ export const agent3 = new Agent({
|
|
|
38
38
|
{ role: 'system', content: 'You are a helpful assistant' },
|
|
39
39
|
{ role: 'system', content: 'You have expertise in TypeScript' },
|
|
40
40
|
],
|
|
41
|
-
model: 'openai/gpt-5.
|
|
41
|
+
model: 'openai/gpt-5.5',
|
|
42
42
|
})
|
|
43
43
|
```
|
|
44
44
|
|
|
@@ -61,7 +61,7 @@ export const agent = new Agent({
|
|
|
61
61
|
},
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
|
-
model: 'openai/gpt-5.
|
|
64
|
+
model: 'openai/gpt-5.5',
|
|
65
65
|
})
|
|
66
66
|
```
|
|
67
67
|
|
|
@@ -96,9 +96,9 @@ export const agent = new Agent({
|
|
|
96
96
|
|
|
97
97
|
## Thread signals
|
|
98
98
|
|
|
99
|
-
Use Agent signals to send real-time context into a memory thread.
|
|
99
|
+
Use Agent signals to send real-time input and context into a memory thread. Message APIs are for user-authored input. `sendSignal()` is the lower-level API for system-generated context.
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
When the target thread is running, `sendMessage()` delivers the message into the active agent loop. When the thread is idle, Mastra starts a stream with the message as the first input by default.
|
|
102
102
|
|
|
103
103
|
```typescript
|
|
104
104
|
const subscription = await agent.subscribeToThread({
|
|
@@ -112,26 +112,22 @@ void (async () => {
|
|
|
112
112
|
}
|
|
113
113
|
})()
|
|
114
114
|
|
|
115
|
-
agent.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
streamOptions: {
|
|
122
|
-
maxSteps: 3,
|
|
123
|
-
},
|
|
115
|
+
agent.sendMessage('Use the latest customer note too.', {
|
|
116
|
+
resourceId: 'user-123',
|
|
117
|
+
threadId: 'thread-abc',
|
|
118
|
+
ifIdle: {
|
|
119
|
+
streamOptions: {
|
|
120
|
+
maxSteps: 3,
|
|
124
121
|
},
|
|
125
122
|
},
|
|
126
|
-
)
|
|
123
|
+
})
|
|
127
124
|
```
|
|
128
125
|
|
|
129
|
-
Use `attributes` to identify different users in a shared thread. The
|
|
126
|
+
Use `attributes` to identify different users in a shared thread. The attributes are rendered as XML so the model can distinguish who said what:
|
|
130
127
|
|
|
131
128
|
```typescript
|
|
132
|
-
agent.
|
|
129
|
+
agent.sendMessage(
|
|
133
130
|
{
|
|
134
|
-
type: 'user',
|
|
135
131
|
contents: 'Can we simplify the API surface?',
|
|
136
132
|
attributes: { name: 'Devin', from: 'slack' },
|
|
137
133
|
},
|
|
@@ -147,11 +143,44 @@ The model receives this as:
|
|
|
147
143
|
|
|
148
144
|
The UI sees just the message contents but can also read `attributes` and `metadata` off the signal message for custom rendering (e.g. showing user names, avatars, or platform badges).
|
|
149
145
|
|
|
146
|
+
### `sendMessage(message, options)`
|
|
147
|
+
|
|
148
|
+
Sends a user message to an active run or memory thread. Use this when the active agent should receive the message immediately.
|
|
149
|
+
|
|
150
|
+
**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.
|
|
151
|
+
|
|
152
|
+
**options.runId** (`string`): Run ID to target directly. Use this when you already know the active run ID.
|
|
153
|
+
|
|
154
|
+
**options.resourceId** (`string`): Resource ID for the memory thread. Required with \`threadId\` for thread-targeted messages.
|
|
155
|
+
|
|
156
|
+
**options.threadId** (`string`): Thread ID to target. Required with \`resourceId\` for thread-targeted messages.
|
|
157
|
+
|
|
158
|
+
**options.ifActive.behavior** (`'deliver' | 'persist' | 'discard'`): Controls what happens when the target thread is active. Defaults to \`deliver\`.
|
|
159
|
+
|
|
160
|
+
**options.ifIdle.behavior** (`'wake' | 'persist' | 'discard'`): Controls what happens when the target thread is idle. Defaults to \`wake\`.
|
|
161
|
+
|
|
162
|
+
**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.
|
|
163
|
+
|
|
164
|
+
Returns `{ accepted: true, runId: string, signal: CreatedAgentSignal, persisted?: Promise<void> }`. `persisted` is only present for `persist` behavior and resolves when Mastra finishes writing the message to memory.
|
|
165
|
+
|
|
166
|
+
### `queueMessage(message, options)`
|
|
167
|
+
|
|
168
|
+
Queues a user message for the next turn on a thread. If the thread is active, Mastra waits for the active run to finish, then starts a new run with the queued message. If the thread is idle, Mastra starts a run immediately.
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
agent.queueMessage('Also check whether the tests need updates.', {
|
|
172
|
+
resourceId: 'user-123',
|
|
173
|
+
threadId: 'thread-abc',
|
|
174
|
+
})
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
`queueMessage()` accepts the same `message` and `options` shape as `sendMessage()` and returns `{ accepted: true, runId: string, signal: CreatedAgentSignal, persisted?: Promise<void> }`.
|
|
178
|
+
|
|
150
179
|
### `sendSignal(signal, options)`
|
|
151
180
|
|
|
152
181
|
Sends a signal to an active run or memory thread.
|
|
153
182
|
|
|
154
|
-
**signal** (`{ type: 'user-message' | 'system-reminder'
|
|
183
|
+
**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.
|
|
155
184
|
|
|
156
185
|
**options.runId** (`string`): Run ID to target directly. Use this when you already know the active run ID.
|
|
157
186
|
|
|
@@ -169,7 +198,7 @@ Returns `{ accepted: true, runId: string, signal: CreatedAgentSignal, persisted?
|
|
|
169
198
|
|
|
170
199
|
### `subscribeToThread(options)`
|
|
171
200
|
|
|
172
|
-
Subscribes to raw stream chunks for a memory thread. Use this before calling `sendSignal()` when you need to render stream output, observe signal echoes, or abort the active run.
|
|
201
|
+
Subscribes to raw stream chunks for a memory thread. Use this before calling `sendMessage()`, `queueMessage()`, or `sendSignal()` when you need to render stream output, observe signal echoes, or abort the active run.
|
|
173
202
|
|
|
174
203
|
**options.resourceId** (`string`): Resource ID for the memory thread.
|
|
175
204
|
|
|
@@ -229,6 +258,16 @@ Returns an `AgentThreadSubscription` object with these members:
|
|
|
229
258
|
|
|
230
259
|
**requestContextSchema** (`StandardJSONSchemaV1`): Standard JSON Schema for validating request context values. When provided, the context is validated at the start of generate() or stream(), throwing a MastraError if validation fails.
|
|
231
260
|
|
|
261
|
+
**editor** (`false | { instructions?: boolean; tools?: boolean | { description?: boolean } }`): Controls which fields the editor can override for this code-defined agent. Omit to allow editing instructions and tools. See Editor overrides below.
|
|
262
|
+
|
|
263
|
+
## Editor overrides
|
|
264
|
+
|
|
265
|
+
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.
|
|
266
|
+
|
|
267
|
+
**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.
|
|
268
|
+
|
|
269
|
+
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.
|
|
270
|
+
|
|
232
271
|
## Returns
|
|
233
272
|
|
|
234
273
|
**agent** (`Agent<TAgentId, TTools>`): A new Agent instance with the specified configuration.
|
|
@@ -15,7 +15,7 @@ export const supportAgent = new Agent({
|
|
|
15
15
|
id: 'support-agent',
|
|
16
16
|
name: 'Support Agent',
|
|
17
17
|
instructions: 'You are a helpful support assistant.',
|
|
18
|
-
model: 'openai/gpt-5.
|
|
18
|
+
model: 'openai/gpt-5.5',
|
|
19
19
|
channels: {
|
|
20
20
|
adapters: {
|
|
21
21
|
slack: createSlackAdapter(),
|
|
@@ -41,10 +41,12 @@ export const supportAgent = new Agent({
|
|
|
41
41
|
|
|
42
42
|
**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` ``)
|
|
43
43
|
|
|
44
|
-
**threadContext** (`{ maxMessages?: number }`):
|
|
44
|
+
**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 }`)
|
|
45
45
|
|
|
46
46
|
**chatOptions** (`Omit<ChatConfig, 'adapters' | 'state' | 'userName'>`): Additional options passed directly to the \[Chat SDK]\(https\://chat-sdk.dev/docs/usage). Use for advanced configuration such as \`dedupeTtlMs\`, \`fallbackStreamingPlaceholderText\`, \`lockScope\`, and \`messageHistory\`.
|
|
47
47
|
|
|
48
|
+
**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.
|
|
49
|
+
|
|
48
50
|
## Per-adapter options
|
|
49
51
|
|
|
50
52
|
Wrap an adapter in a `ChannelAdapterConfig` object to set per-adapter options:
|
|
@@ -57,7 +59,7 @@ import { createSlackAdapter } from '@chat-adapter/slack'
|
|
|
57
59
|
const agent = new Agent({
|
|
58
60
|
name: 'Example',
|
|
59
61
|
instructions: '...',
|
|
60
|
-
model: 'openai/gpt-5.
|
|
62
|
+
model: 'openai/gpt-5.5',
|
|
61
63
|
channels: {
|
|
62
64
|
adapters: {
|
|
63
65
|
discord: {
|
|
@@ -112,7 +114,7 @@ import { createSlackAdapter } from '@chat-adapter/slack'
|
|
|
112
114
|
const agent = new Agent({
|
|
113
115
|
name: 'Streaming Agent',
|
|
114
116
|
instructions: '...',
|
|
115
|
-
model: 'openai/gpt-5.
|
|
117
|
+
model: 'openai/gpt-5.5',
|
|
116
118
|
channels: {
|
|
117
119
|
adapters: {
|
|
118
120
|
slack: {
|
|
@@ -139,7 +141,7 @@ import { createDiscordAdapter } from '@chat-adapter/discord'
|
|
|
139
141
|
const agent = new Agent({
|
|
140
142
|
name: 'Custom Typing Agent',
|
|
141
143
|
instructions: '...',
|
|
142
|
-
model: 'openai/gpt-5.
|
|
144
|
+
model: 'openai/gpt-5.5',
|
|
143
145
|
channels: {
|
|
144
146
|
adapters: {
|
|
145
147
|
discord: {
|
|
@@ -171,7 +173,7 @@ import { createSlackAdapter } from '@chat-adapter/slack'
|
|
|
171
173
|
const agent = new Agent({
|
|
172
174
|
name: 'Custom Handler Agent',
|
|
173
175
|
instructions: '...',
|
|
174
|
-
model: 'openai/gpt-5.
|
|
176
|
+
model: 'openai/gpt-5.5',
|
|
175
177
|
channels: {
|
|
176
178
|
adapters: {
|
|
177
179
|
slack: createSlackAdapter(),
|
|
@@ -203,6 +205,46 @@ type ChannelHandler = (
|
|
|
203
205
|
) => Promise<void>
|
|
204
206
|
```
|
|
205
207
|
|
|
208
|
+
## Resource ID resolution
|
|
209
|
+
|
|
210
|
+
By default a channel thread's memory `resourceId` is `${platform}:${message.author.userId}`. The sender owns the memory, scoped per platform. For apps with a shared identity, such as single sign-on (SSO), this splits memory: the same user gets `feishu:user_123` in a Feishu DM but `user_123` on the web.
|
|
211
|
+
|
|
212
|
+
Pass `resolveResourceId` to decide memory ownership separately from the sender. It runs only when a new thread is created. Reused threads keep their stored `resourceId` and never call the hook, so existing conversations don't depend on the resolver being available. Return `ctx.defaultResourceId` to fall back to the built-in behavior.
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
import { Agent } from '@mastra/core/agent'
|
|
216
|
+
import { createSlackAdapter } from '@chat-adapter/slack'
|
|
217
|
+
|
|
218
|
+
const agent = new Agent({
|
|
219
|
+
name: 'SSO Agent',
|
|
220
|
+
instructions: '...',
|
|
221
|
+
model: 'openai/gpt-5.5',
|
|
222
|
+
channels: {
|
|
223
|
+
adapters: {
|
|
224
|
+
slack: createSlackAdapter(),
|
|
225
|
+
},
|
|
226
|
+
resolveResourceId: async ({ thread, message }) => {
|
|
227
|
+
// DM: share resource-level memory with the web app by using the bare SSO id
|
|
228
|
+
if (thread.isDM) {
|
|
229
|
+
return await resolveSsoUserId(message)
|
|
230
|
+
}
|
|
231
|
+
// Group chat: the conversation owns the memory; the sender stays the actor
|
|
232
|
+
return thread.channelId
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
})
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
The `ResolveResourceIdContext` passed to the function:
|
|
239
|
+
|
|
240
|
+
**platform** (`string`): Platform name (e.g. \`slack\`, \`discord\`).
|
|
241
|
+
|
|
242
|
+
**thread** (`Thread`): The channel thread the message arrived on. Use \`thread.isDM\` to tell DMs apart from group/channel threads.
|
|
243
|
+
|
|
244
|
+
**message** (`Message`): The incoming message. \`message.author.userId\` is the actor/sender, not necessarily the memory owner.
|
|
245
|
+
|
|
246
|
+
**defaultResourceId** (`string`): The built-in default (\`${platform}:${message.author.userId}\`). Return this to keep the current behavior.
|
|
247
|
+
|
|
206
248
|
## Inline media
|
|
207
249
|
|
|
208
250
|
Controls which attachment types (images, video, PDFs, etc.) are sent as file parts to the model. Types that do not match are described as text summaries so the agent knows about the file without crashing models that reject unsupported types.
|
|
@@ -195,7 +195,7 @@ await agent.generateLegacy(
|
|
|
195
195
|
sentiment: z.enum(['positive', 'negative', 'neutral']),
|
|
196
196
|
confidence: z.number(),
|
|
197
197
|
}),
|
|
198
|
-
model: 'openai/gpt-5.
|
|
198
|
+
model: 'openai/gpt-5.5',
|
|
199
199
|
errorStrategy: 'warn',
|
|
200
200
|
},
|
|
201
201
|
// Output processors for response validation
|
|
@@ -10,7 +10,7 @@ await agent.getLLM()
|
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
12
|
await agent.getLLM({
|
|
13
|
-
model: 'openai/gpt-5.
|
|
13
|
+
model: 'openai/gpt-5.5',
|
|
14
14
|
})
|
|
15
15
|
```
|
|
16
16
|
|
|
@@ -31,7 +31,7 @@ await agent.getLLM({
|
|
|
31
31
|
```typescript
|
|
32
32
|
await agent.getLLM({
|
|
33
33
|
requestContext: new RequestContext(),
|
|
34
|
-
model: 'openai/gpt-5.
|
|
34
|
+
model: 'openai/gpt-5.5',
|
|
35
35
|
})
|
|
36
36
|
```
|
|
37
37
|
|
|
@@ -29,7 +29,7 @@ export const supportAgent = new Agent({
|
|
|
29
29
|
id: 'support-agent',
|
|
30
30
|
name: 'Support Agent',
|
|
31
31
|
instructions: 'You help customers with support requests.',
|
|
32
|
-
model: 'openai/gpt-5.
|
|
32
|
+
model: 'openai/gpt-5.5',
|
|
33
33
|
metadata: { type: 'support' },
|
|
34
34
|
})
|
|
35
35
|
|
|
@@ -45,7 +45,7 @@ export const supportAgent = new Agent({
|
|
|
45
45
|
id: 'support-agent',
|
|
46
46
|
name: 'Support Agent',
|
|
47
47
|
instructions: 'You help customers with support requests.',
|
|
48
|
-
model: 'openai/gpt-5.
|
|
48
|
+
model: 'openai/gpt-5.5',
|
|
49
49
|
metadata: ({ requestContext }) => ({
|
|
50
50
|
type: 'support',
|
|
51
51
|
tenant: requestContext.get('tenant'),
|
|
@@ -21,7 +21,7 @@ export const browserAgent = new Agent({
|
|
|
21
21
|
name: 'Browser Agent',
|
|
22
22
|
instructions: `You can browse the web. Use browser_snapshot to see the page structure,
|
|
23
23
|
then interact with elements using their refs (e.g., @e5).`,
|
|
24
|
-
model: 'openai/gpt-5.
|
|
24
|
+
model: 'openai/gpt-5.5',
|
|
25
25
|
browser,
|
|
26
26
|
})
|
|
27
27
|
```
|
|
@@ -12,7 +12,7 @@ import { StagehandBrowser } from '@mastra/stagehand'
|
|
|
12
12
|
|
|
13
13
|
const browser = new StagehandBrowser({
|
|
14
14
|
headless: true,
|
|
15
|
-
model: 'openai/gpt-5.
|
|
15
|
+
model: 'openai/gpt-5.5',
|
|
16
16
|
selfHeal: true,
|
|
17
17
|
})
|
|
18
18
|
|
|
@@ -22,7 +22,7 @@ export const browserAgent = new Agent({
|
|
|
22
22
|
instructions: `You can browse the web using natural language.
|
|
23
23
|
Use stagehand_act to perform actions like "click the login button".
|
|
24
24
|
Use stagehand_extract to get data from pages.`,
|
|
25
|
-
model: 'openai/gpt-5.
|
|
25
|
+
model: 'openai/gpt-5.5',
|
|
26
26
|
browser,
|
|
27
27
|
})
|
|
28
28
|
```
|
|
@@ -39,7 +39,7 @@ Use stagehand_extract to get data from pages.`,
|
|
|
39
39
|
|
|
40
40
|
**projectId** (`string`): Browserbase project ID. Required when env is 'BROWSERBASE'.
|
|
41
41
|
|
|
42
|
-
**model** (`string | ModelConfiguration`): Model configuration for AI operations. Can be a string like '
|
|
42
|
+
**model** (`string | ModelConfiguration`): Model configuration for AI operations. Can be a string like 'openai/gpt-5.5' or an object with modelName, apiKey, and baseURL. (Default: `'openai/gpt-5.5'`)
|
|
43
43
|
|
|
44
44
|
**selfHeal** (`boolean`): Enable self-healing selectors. When enabled, Stagehand uses AI to find elements even when initial selectors fail. (Default: `true`)
|
|
45
45
|
|
|
@@ -268,7 +268,7 @@ const browser = new StagehandBrowser({
|
|
|
268
268
|
env: 'BROWSERBASE',
|
|
269
269
|
apiKey: process.env.BROWSERBASE_API_KEY,
|
|
270
270
|
projectId: process.env.BROWSERBASE_PROJECT_ID,
|
|
271
|
-
model: 'openai/gpt-5.
|
|
271
|
+
model: 'openai/gpt-5.5',
|
|
272
272
|
})
|
|
273
273
|
```
|
|
274
274
|
|
|
@@ -279,7 +279,7 @@ Configure the AI model for Stagehand operations:
|
|
|
279
279
|
```typescript
|
|
280
280
|
// String format: "provider/model"
|
|
281
281
|
const browser = new StagehandBrowser({
|
|
282
|
-
model: 'openai/gpt-5.
|
|
282
|
+
model: 'openai/gpt-5.5',
|
|
283
283
|
})
|
|
284
284
|
|
|
285
285
|
// Object format for custom configuration
|