@mastra/mcp-docs-server 1.1.35-alpha.5 → 1.1.35-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/agents/processors.md +26 -2
- package/.docs/guides/guide/web-search.md +7 -7
- package/.docs/models/gateways/azure-openai.md +94 -23
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/kiro.md +110 -0
- package/.docs/models/providers/llmgateway.md +1 -1
- package/.docs/models/providers/opencode-go.md +1 -3
- package/.docs/models/providers/qiniu-ai.md +2 -2
- package/.docs/models/providers/xiaomi.md +2 -2
- package/.docs/models/providers/zenmux.md +1 -1
- package/.docs/models/providers.md +1 -0
- package/.docs/reference/cli/mastra.md +464 -0
- package/.docs/reference/index.md +1 -0
- package/.docs/reference/processors/processor-interface.md +74 -12
- package/.docs/reference/processors/provider-history-compat.md +132 -0
- package/.docs/reference/streaming/agents/stream.md +18 -2
- package/CHANGELOG.md +14 -0
- package/package.json +3 -3
|
@@ -211,6 +211,22 @@ The method receives the current `stepNumber`, `model`, `tools`, `toolChoice`, `m
|
|
|
211
211
|
|
|
212
212
|
See the [`Processor` reference](https://mastra.ai/reference/processors/processor-interface) for all available arguments and return types.
|
|
213
213
|
|
|
214
|
+
### Rewrite the LLM request before the provider call
|
|
215
|
+
|
|
216
|
+
Use `processLLMRequest()` when you need to rewrite the final prompt that Mastra sends to the model. This hook runs after Mastra converts the `MessageList` into the provider-facing prompt format (`LanguageModelV2Prompt`) and immediately before the provider call.
|
|
217
|
+
|
|
218
|
+
Use the message-based hooks for conversation changes:
|
|
219
|
+
|
|
220
|
+
- `processInput()`: Change the conversation once before the agentic loop starts.
|
|
221
|
+
- `processInputStep()`: Change messages or step configuration before each LLM call.
|
|
222
|
+
- `processLLMRequest()`: Change only the outbound prompt for the current provider call.
|
|
223
|
+
|
|
224
|
+
Changes returned from `processLLMRequest()` are transient. They don't persist back to `MessageList`, memory, UI history, or future provider calls. This makes the hook a good fit for provider compatibility rewrites, role/content normalization, or other model-specific prompt changes that shouldn't alter stored conversation history.
|
|
225
|
+
|
|
226
|
+
The method receives `prompt`, `model`, `stepNumber`, `steps`, `state`, and the shared processor context. Calling `abort()` from `processLLMRequest()` emits the normal tripwire response and stops the call.
|
|
227
|
+
|
|
228
|
+
See the [`Processor` reference](https://mastra.ai/reference/processors/processor-interface) for all available arguments and return types.
|
|
229
|
+
|
|
214
230
|
### Use the `prepareStep()` callback
|
|
215
231
|
|
|
216
232
|
The `prepareStep()` callback on `generate()` or `stream()` is a shorthand for `processInputStep()`. Internally, Mastra wraps it in a processor that calls your function at each step. It accepts the same arguments and return type as `processInputStep()`, but doesn't require creating a class:
|
|
@@ -317,7 +333,7 @@ For more on retry behavior, see [Retry mechanism](#retry-mechanism) in Advanced
|
|
|
317
333
|
|
|
318
334
|
### Persist data across chunks and steps
|
|
319
335
|
|
|
320
|
-
Output methods receive a `state` object that persists for the lifetime of one request. State is keyed by the processor's `id`, so each processor sees only its own data, and it
|
|
336
|
+
Output methods receive a `state` object that persists for the lifetime of one request. State is keyed by the processor's `id`, so each processor sees only its own data, and it's shared between `processOutputStream`, `processOutputStep`, and `processOutputResult`. A new state object is created for every new `agent.generate()` or `agent.stream()` call.
|
|
321
337
|
|
|
322
338
|
```typescript
|
|
323
339
|
import type { Processor } from '@mastra/core/processors'
|
|
@@ -383,6 +399,14 @@ Enables dynamic tool discovery for agents with large tool libraries. Instead of
|
|
|
383
399
|
|
|
384
400
|
See the [`ToolSearchProcessor` reference](https://mastra.ai/reference/processors/tool-search-processor) for configuration options and usage examples.
|
|
385
401
|
|
|
402
|
+
### `ProviderHistoryCompat`
|
|
403
|
+
|
|
404
|
+
Handles provider-specific history incompatibilities when agents reuse messages across model providers. It can rewrite the outbound LLM request before the provider call, or recover from known provider API errors and retry.
|
|
405
|
+
|
|
406
|
+
Add `ProviderHistoryCompat` explicitly when you need provider history compatibility rules, reactive API error recovery, custom compatibility rules, or predictable processor ordering.
|
|
407
|
+
|
|
408
|
+
See the [`ProviderHistoryCompat` reference](https://mastra.ai/reference/processors/provider-history-compat) for setup, built-in rules, and custom rule options.
|
|
409
|
+
|
|
386
410
|
## Advanced patterns
|
|
387
411
|
|
|
388
412
|
### Ensure a final response with `maxSteps`
|
|
@@ -494,7 +518,7 @@ for await (const chunk of stream.fullStream) {
|
|
|
494
518
|
|
|
495
519
|
Custom chunk types must use the `data-` prefix (e.g., `data-moderation-update`, `data-status`).
|
|
496
520
|
|
|
497
|
-
By default, `processOutputStream()` skips `data-*` chunks so it
|
|
521
|
+
By default, `processOutputStream()` skips `data-*` chunks so it doesn't accidentally operate on tool telemetry or other processors' output. To inspect, modify, or block these chunks in a processor, set `processDataParts = true` on that processor:
|
|
498
522
|
|
|
499
523
|
```typescript
|
|
500
524
|
class ModerationCollector implements Processor {
|
|
@@ -17,7 +17,7 @@ Some LLM providers include built-in web search capabilities that can be used dir
|
|
|
17
17
|
|
|
18
18
|
1. Install dependencies
|
|
19
19
|
|
|
20
|
-
**
|
|
20
|
+
**OpenAI**:
|
|
21
21
|
|
|
22
22
|
**npm**:
|
|
23
23
|
|
|
@@ -119,7 +119,7 @@ Some LLM providers include built-in web search capabilities that can be used dir
|
|
|
119
119
|
|
|
120
120
|
2. Create a new file `src/mastra/agents/searchAgent.ts` and define your agent:
|
|
121
121
|
|
|
122
|
-
**
|
|
122
|
+
**OpenAI**:
|
|
123
123
|
|
|
124
124
|
```ts
|
|
125
125
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -128,7 +128,7 @@ Some LLM providers include built-in web search capabilities that can be used dir
|
|
|
128
128
|
id: 'search-agent',
|
|
129
129
|
name: 'Search Agent',
|
|
130
130
|
instructions: 'You are a search agent that can search the web for information.',
|
|
131
|
-
model: 'openai/gpt-5.
|
|
131
|
+
model: 'openai/gpt-5.5',
|
|
132
132
|
})
|
|
133
133
|
```
|
|
134
134
|
|
|
@@ -147,7 +147,7 @@ Some LLM providers include built-in web search capabilities that can be used dir
|
|
|
147
147
|
|
|
148
148
|
3. Setup the tool:
|
|
149
149
|
|
|
150
|
-
**
|
|
150
|
+
**OpenAI**:
|
|
151
151
|
|
|
152
152
|
```ts
|
|
153
153
|
import { openai } from '@ai-sdk/openai'
|
|
@@ -157,7 +157,7 @@ Some LLM providers include built-in web search capabilities that can be used dir
|
|
|
157
157
|
id: 'search-agent',
|
|
158
158
|
name: 'Search Agent',
|
|
159
159
|
instructions: 'You are a search agent that can search the web for information.',
|
|
160
|
-
model: 'openai/gpt-5.
|
|
160
|
+
model: 'openai/gpt-5.5',
|
|
161
161
|
tools: {
|
|
162
162
|
webSearch: openai.tools.webSearch(),
|
|
163
163
|
},
|
|
@@ -241,7 +241,7 @@ For more control over search behavior, you can integrate external search APIs as
|
|
|
241
241
|
id: 'search-agent',
|
|
242
242
|
name: 'Search Agent',
|
|
243
243
|
instructions: 'You are a search agent that can search the web for information.',
|
|
244
|
-
model: 'openai/gpt-5.
|
|
244
|
+
model: 'openai/gpt-5.5',
|
|
245
245
|
})
|
|
246
246
|
```
|
|
247
247
|
|
|
@@ -293,7 +293,7 @@ For more control over search behavior, you can integrate external search APIs as
|
|
|
293
293
|
id: 'search-agent',
|
|
294
294
|
name: 'Search Agent',
|
|
295
295
|
instructions: 'You are a search agent that can search the web for information.',
|
|
296
|
-
model: 'openai/gpt-5.
|
|
296
|
+
model: 'openai/gpt-5.5',
|
|
297
297
|
tools: {
|
|
298
298
|
webSearch,
|
|
299
299
|
},
|
|
@@ -13,7 +13,7 @@ const agent = new Agent({
|
|
|
13
13
|
id: "my-agent",
|
|
14
14
|
name: "My Agent",
|
|
15
15
|
instructions: "You are a helpful assistant",
|
|
16
|
-
model: "azure-openai/my-
|
|
16
|
+
model: "azure-openai/my-gpt-5-4-deployment" // Use your Azure deployment name (autocompleted in dev mode)
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
// Generate a response
|
|
@@ -34,9 +34,9 @@ Azure model IDs follow this pattern: `azure-openai/your-deployment-name`
|
|
|
34
34
|
|
|
35
35
|
The deployment name is **specific to your Azure account** and chosen when you create a deployment in Azure Portal. Common examples:
|
|
36
36
|
|
|
37
|
-
- `azure-openai/my-
|
|
38
|
-
- `azure-openai/production-gpt-
|
|
39
|
-
- `azure-openai/staging-gpt-
|
|
37
|
+
- `azure-openai/my-gpt-5-4-deployment`
|
|
38
|
+
- `azure-openai/production-gpt-5-4`
|
|
39
|
+
- `azure-openai/staging-gpt-5-4-mini`
|
|
40
40
|
|
|
41
41
|
## Setup
|
|
42
42
|
|
|
@@ -44,7 +44,7 @@ Create deployments in [Azure OpenAI Studio](https://oai.azure.com/). The resourc
|
|
|
44
44
|
|
|
45
45
|
## Configuration
|
|
46
46
|
|
|
47
|
-
Instantiate the gateway and pass it to Mastra.
|
|
47
|
+
Instantiate the gateway and pass it to Mastra. The common configuration modes are shown below.
|
|
48
48
|
|
|
49
49
|
### Static Deployments
|
|
50
50
|
|
|
@@ -59,7 +59,7 @@ export const mastra = new Mastra({
|
|
|
59
59
|
new AzureOpenAIGateway({
|
|
60
60
|
resourceName: "my-openai-resource",
|
|
61
61
|
apiKey: process.env.AZURE_API_KEY!,
|
|
62
|
-
deployments: ["gpt-4-prod", "gpt-
|
|
62
|
+
deployments: ["gpt-5-4-prod", "gpt-5-4-mini-dev"],
|
|
63
63
|
}),
|
|
64
64
|
],
|
|
65
65
|
});
|
|
@@ -111,7 +111,7 @@ export const mastra = new Mastra({
|
|
|
111
111
|
type: "entraId",
|
|
112
112
|
credential: new DefaultAzureCredential(),
|
|
113
113
|
},
|
|
114
|
-
deployments: ["gpt-4-prod", "gpt-
|
|
114
|
+
deployments: ["gpt-5-4-prod", "gpt-5-4-mini-dev"],
|
|
115
115
|
}),
|
|
116
116
|
],
|
|
117
117
|
});
|
|
@@ -145,23 +145,94 @@ export const mastra = new Mastra({
|
|
|
145
145
|
});
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
+
### Azure Responses API
|
|
149
|
+
|
|
150
|
+
Azure OpenAI supports the Responses API through the `v1` API path used by the AI SDK Azure provider. Set `useResponsesAPI: true` when your Azure resource and deployment support that route. The gateway then uses `apiVersion: "v1"` and `useDeploymentBasedUrls: false` by default.
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
import { Mastra } from "@mastra/core";
|
|
154
|
+
import { AzureOpenAIGateway } from "@mastra/core/llm";
|
|
155
|
+
|
|
156
|
+
export const mastra = new Mastra({
|
|
157
|
+
gateways: [
|
|
158
|
+
new AzureOpenAIGateway({
|
|
159
|
+
resourceName: "my-openai-resource",
|
|
160
|
+
apiKey: process.env.AZURE_API_KEY!,
|
|
161
|
+
useResponsesAPI: true,
|
|
162
|
+
deployments: ["my-gpt-5-4-deployment"],
|
|
163
|
+
}),
|
|
164
|
+
],
|
|
165
|
+
});
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Keep `useResponsesAPI` omitted or set it to `false` for the existing Azure chat completions route. That path keeps `apiVersion: "2024-04-01-preview"` and deployment-based URLs by default for compatibility.
|
|
169
|
+
|
|
170
|
+
You can still configure `apiVersion` and `useDeploymentBasedUrls` directly. For example, set `useDeploymentBasedUrls: false` to use the Azure `v1` URL shape with the chat model constructor; the gateway defaults `apiVersion` to `"v1"` for that route. Passing `apiVersion: "v1"` by itself keeps the existing deployment-based URL default for compatibility.
|
|
171
|
+
|
|
172
|
+
Do not combine `useResponsesAPI: true` with `useDeploymentBasedUrls: true`; the gateway rejects that configuration because Responses API support uses the Azure `v1` route.
|
|
173
|
+
|
|
174
|
+
Use `apiVersion: "v1"` for the GA `v1` route. Microsoft currently exposes preview `v1` features through feature-specific headers, such as `"aoai-evals": "preview"`, or through preview/alpha API paths. The gateway still accepts `apiVersion: "preview"` with `useDeploymentBasedUrls: false` for Azure provider configurations that require the preview query value. Date-based API versions are only for the legacy deployment-based route, so the gateway rejects them when `useResponsesAPI` is `true` or `useDeploymentBasedUrls` is `false`.
|
|
175
|
+
|
|
176
|
+
The same API key and Microsoft Entra ID authentication modes work with the `v1` route.
|
|
177
|
+
|
|
178
|
+
### Azure Responses WebSocket transport
|
|
179
|
+
|
|
180
|
+
Azure OpenAI also supports WebSocket mode on the Responses API. Use it for agent or tool loops with many model-tool round trips. Keep the standard HTTP transport for single-shot requests and short conversations.
|
|
181
|
+
|
|
182
|
+
WebSocket transport requires `useResponsesAPI: true`, because Azure exposes it on the `v1` Responses path. Then opt in per stream request with `providerOptions.azure.transport: "websocket"`.
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
import { Agent } from "@mastra/core/agent";
|
|
186
|
+
|
|
187
|
+
const agent = new Agent({
|
|
188
|
+
id: "azure-ws-agent",
|
|
189
|
+
name: "Azure WebSocket Agent",
|
|
190
|
+
instructions: "Use tools when they are useful.",
|
|
191
|
+
model: "azure-openai/my-gpt-5-4-deployment",
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const stream = await agent.stream("Find and improve the slow function.", {
|
|
195
|
+
providerOptions: {
|
|
196
|
+
azure: {
|
|
197
|
+
transport: "websocket",
|
|
198
|
+
store: false,
|
|
199
|
+
websocket: {
|
|
200
|
+
closeOnFinish: false,
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
for await (const chunk of stream.textStream) {
|
|
207
|
+
process.stdout.write(chunk);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
stream.transport?.close();
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Set `closeOnFinish: false` when you want to keep the socket open across follow-up turns. Azure keeps one response chain in connection-local memory, so continuing from the most recent `previous_response_id` can reduce continuation latency. The connection runs one response at a time and does not multiplex parallel runs.
|
|
214
|
+
|
|
215
|
+
Do not send overlapping follow-up requests with `previous_response_id` on the same WebSocket transport. Mastra rejects overlapping continuation requests because Azure only keeps one in-flight response per connection. Wait for the active stream to finish before continuing the response chain.
|
|
216
|
+
|
|
148
217
|
## Configuration Reference
|
|
149
218
|
|
|
150
|
-
| Option | Type | Required | Description
|
|
151
|
-
| --------------------------- | ----------------- | -------- |
|
|
152
|
-
| `resourceName` | `string` | Yes | Azure OpenAI resource name
|
|
153
|
-
| `apiKey` | `string` | Yes\* | API key from "Keys and Endpoint"
|
|
154
|
-
| `authentication` | `object` | No | Microsoft Entra ID authentication
|
|
155
|
-
| `authentication.type` | `"entraId"` | Yes\* | Authentication mode
|
|
156
|
-
| `authentication.credential` | `TokenCredential` | Yes\* | Azure SDK-compatible credential for `entraId` authentication mode
|
|
157
|
-
| `authentication.scope` | `string` | No | Token scope (default: `https://cognitiveservices.azure.com/.default`)
|
|
158
|
-
| `apiVersion` | `string` | No | API version (default: `2024-04-01-preview`)
|
|
159
|
-
| `
|
|
160
|
-
| `
|
|
161
|
-
| `
|
|
162
|
-
| `management
|
|
163
|
-
| `management.
|
|
164
|
-
| `management.
|
|
165
|
-
| `management.
|
|
219
|
+
| Option | Type | Required | Description |
|
|
220
|
+
| --------------------------- | ----------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
221
|
+
| `resourceName` | `string` | Yes | Azure OpenAI resource name |
|
|
222
|
+
| `apiKey` | `string` | Yes\* | API key from "Keys and Endpoint" |
|
|
223
|
+
| `authentication` | `object` | No | Microsoft Entra ID authentication |
|
|
224
|
+
| `authentication.type` | `"entraId"` | Yes\* | Authentication mode |
|
|
225
|
+
| `authentication.credential` | `TokenCredential` | Yes\* | Azure SDK-compatible credential for `entraId` authentication mode |
|
|
226
|
+
| `authentication.scope` | `string` | No | Token scope (default: `https://cognitiveservices.azure.com/.default`) |
|
|
227
|
+
| `apiVersion` | `string` | No | API version (default: `2024-04-01-preview`, or `v1` when `useResponsesAPI` is `true` or `useDeploymentBasedUrls` is `false`) |
|
|
228
|
+
| `useResponsesAPI` | `boolean` | No | Resolve deployments through the Azure OpenAI Responses API (default: `false`) |
|
|
229
|
+
| `useDeploymentBasedUrls` | `boolean` | No | Use Azure deployment-based URLs (default: `true`, or `false` when `useResponsesAPI` is `true`) |
|
|
230
|
+
| `deployments` | `string[]` | No | Deployment names for static mode |
|
|
231
|
+
| `management` | `object` | No | Management API credentials |
|
|
232
|
+
| `management.tenantId` | `string` | Yes\* | Azure AD tenant ID |
|
|
233
|
+
| `management.clientId` | `string` | Yes\* | Service Principal client ID |
|
|
234
|
+
| `management.clientSecret` | `string` | Yes\* | Service Principal secret |
|
|
235
|
+
| `management.subscriptionId` | `string` | Yes\* | Azure subscription ID |
|
|
236
|
+
| `management.resourceGroup` | `string` | Yes\* | Resource group name |
|
|
166
237
|
|
|
167
238
|
\* Provide either `apiKey` or `authentication.type: "entraId"`. Management fields are required if `management` is provided.
|
package/.docs/models/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Model Providers
|
|
2
2
|
|
|
3
|
-
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to
|
|
3
|
+
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to 3889 models from 108 providers through a single API.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Kiro
|
|
2
|
+
|
|
3
|
+
Access 12 Kiro models through Mastra's model router. Authentication is handled automatically using the `KIRO_API_KEY` environment variable.
|
|
4
|
+
|
|
5
|
+
Learn more in the [Kiro documentation](https://kiro.dev).
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
KIRO_API_KEY=your-api-key
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { Agent } from "@mastra/core/agent";
|
|
13
|
+
|
|
14
|
+
const agent = new Agent({
|
|
15
|
+
id: "my-agent",
|
|
16
|
+
name: "My Agent",
|
|
17
|
+
instructions: "You are a helpful assistant",
|
|
18
|
+
model: "kiro/auto"
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Generate a response
|
|
22
|
+
const response = await agent.generate("Hello!");
|
|
23
|
+
|
|
24
|
+
// Stream a response
|
|
25
|
+
const stream = await agent.stream("Tell me a story");
|
|
26
|
+
for await (const chunk of stream) {
|
|
27
|
+
console.log(chunk);
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
> **Info:** Mastra uses the OpenAI-compatible `/chat/completions` endpoint. Some provider-specific features may not be available. Check the [Kiro documentation](https://kiro.dev) for details.
|
|
32
|
+
|
|
33
|
+
## Models
|
|
34
|
+
|
|
35
|
+
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
36
|
+
| ------------------------ | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
37
|
+
| `kiro/auto` | 1.0M | | | | | | — | — |
|
|
38
|
+
| `kiro/claude-haiku-4.5` | 200K | | | | | | — | — |
|
|
39
|
+
| `kiro/claude-opus-4.5` | 200K | | | | | | — | — |
|
|
40
|
+
| `kiro/claude-opus-4.6` | 1.0M | | | | | | — | — |
|
|
41
|
+
| `kiro/claude-opus-4.7` | 1.0M | | | | | | — | — |
|
|
42
|
+
| `kiro/claude-sonnet-4` | 200K | | | | | | — | — |
|
|
43
|
+
| `kiro/claude-sonnet-4.5` | 200K | | | | | | — | — |
|
|
44
|
+
| `kiro/claude-sonnet-4.6` | 1.0M | | | | | | — | — |
|
|
45
|
+
| `kiro/deepseek-3.2` | 164K | | | | | | — | — |
|
|
46
|
+
| `kiro/minimax-m2.1` | 196K | | | | | | — | — |
|
|
47
|
+
| `kiro/minimax-m2.5` | 196K | | | | | | — | — |
|
|
48
|
+
| `kiro/qwen3-coder-next` | 256K | | | | | | — | — |
|
|
49
|
+
|
|
50
|
+
## Advanced configuration
|
|
51
|
+
|
|
52
|
+
### Custom headers
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
const agent = new Agent({
|
|
56
|
+
id: "custom-agent",
|
|
57
|
+
name: "custom-agent",
|
|
58
|
+
model: {
|
|
59
|
+
url: "https://q.us-east-1.amazonaws.com",
|
|
60
|
+
id: "kiro/auto",
|
|
61
|
+
apiKey: process.env.KIRO_API_KEY,
|
|
62
|
+
headers: {
|
|
63
|
+
"X-Custom-Header": "value"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Dynamic model selection
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const agent = new Agent({
|
|
73
|
+
id: "dynamic-agent",
|
|
74
|
+
name: "Dynamic Agent",
|
|
75
|
+
model: ({ requestContext }) => {
|
|
76
|
+
const useAdvanced = requestContext.task === "complex";
|
|
77
|
+
return useAdvanced
|
|
78
|
+
? "kiro/qwen3-coder-next"
|
|
79
|
+
: "kiro/auto";
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Direct provider installation
|
|
85
|
+
|
|
86
|
+
This provider can also be installed directly as a standalone package, which can be used instead of the Mastra model router string. View the [package documentation](https://www.npmjs.com/package/kiro-acp-ai-provider) for more details.
|
|
87
|
+
|
|
88
|
+
**npm**:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm install kiro-acp-ai-provider
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**pnpm**:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
pnpm add kiro-acp-ai-provider
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Yarn**:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
yarn add kiro-acp-ai-provider
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Bun**:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
bun add kiro-acp-ai-provider
|
|
110
|
+
```
|
|
@@ -153,7 +153,7 @@ for await (const chunk of stream) {
|
|
|
153
153
|
| `llmgateway/llama-4-maverick-17b-instruct` | 8K | | | | | | $0.24 | $0.97 |
|
|
154
154
|
| `llmgateway/llama-4-scout` | 33K | | | | | | $0.18 | $0.59 |
|
|
155
155
|
| `llmgateway/llama-4-scout-17b-instruct` | 8K | | | | | | $0.17 | $0.66 |
|
|
156
|
-
| `llmgateway/mimo-v2-flash` |
|
|
156
|
+
| `llmgateway/mimo-v2-flash` | 262K | | | | | | $0.10 | $0.30 |
|
|
157
157
|
| `llmgateway/minimax-m2` | 197K | | | | | | $0.30 | $1 |
|
|
158
158
|
| `llmgateway/minimax-m2.1` | 205K | | | | | | $0.30 | $1 |
|
|
159
159
|
| `llmgateway/minimax-m2.1-lightning` | 197K | | | | | | $0.12 | $0.48 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenCode Go
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 12 OpenCode Go models through Mastra's model router. Authentication is handled automatically using the `OPENCODE_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [OpenCode Go documentation](https://opencode.ai/docs/zen).
|
|
6
6
|
|
|
@@ -40,8 +40,6 @@ for await (const chunk of stream) {
|
|
|
40
40
|
| `opencode-go/glm-5.1` | 203K | | | | | | $1 | $4 |
|
|
41
41
|
| `opencode-go/kimi-k2.5` | 262K | | | | | | $0.60 | $3 |
|
|
42
42
|
| `opencode-go/kimi-k2.6` | 262K | | | | | | $0.95 | $4 |
|
|
43
|
-
| `opencode-go/mimo-v2-omni` | 262K | | | | | | $0.40 | $2 |
|
|
44
|
-
| `opencode-go/mimo-v2-pro` | 1.0M | | | | | | $1 | $3 |
|
|
45
43
|
| `opencode-go/mimo-v2.5` | 1.0M | | | | | | $0.40 | $2 |
|
|
46
44
|
| `opencode-go/mimo-v2.5-pro` | 1.0M | | | | | | $1 | $3 |
|
|
47
45
|
| `opencode-go/minimax-m2.5` | 205K | | | | | | $0.30 | $1 |
|
|
@@ -81,7 +81,7 @@ for await (const chunk of stream) {
|
|
|
81
81
|
| `qiniu-ai/kling-v2-6` | 100.0M | | | | | | — | — |
|
|
82
82
|
| `qiniu-ai/meituan/longcat-flash-chat` | 131K | | | | | | — | — |
|
|
83
83
|
| `qiniu-ai/meituan/longcat-flash-lite` | 256K | | | | | | — | — |
|
|
84
|
-
| `qiniu-ai/mimo-v2-flash` | 256K | | | | | |
|
|
84
|
+
| `qiniu-ai/mimo-v2-flash` | 256K | | | | | | $0.10 | $0.30 |
|
|
85
85
|
| `qiniu-ai/MiniMax-M1` | 1.0M | | | | | | — | — |
|
|
86
86
|
| `qiniu-ai/minimax/minimax-m2` | 200K | | | | | | — | — |
|
|
87
87
|
| `qiniu-ai/minimax/minimax-m2.1` | 205K | | | | | | — | — |
|
|
@@ -120,7 +120,7 @@ for await (const chunk of stream) {
|
|
|
120
120
|
| `qiniu-ai/x-ai/grok-4.1-fast-non-reasoning` | 2.0M | | | | | | — | — |
|
|
121
121
|
| `qiniu-ai/x-ai/grok-4.1-fast-reasoning` | 20.0M | | | | | | — | — |
|
|
122
122
|
| `qiniu-ai/x-ai/grok-code-fast-1` | 256K | | | | | | — | — |
|
|
123
|
-
| `qiniu-ai/xiaomi/mimo-v2-flash` | 256K | | | | | |
|
|
123
|
+
| `qiniu-ai/xiaomi/mimo-v2-flash` | 256K | | | | | | $0.10 | $0.30 |
|
|
124
124
|
| `qiniu-ai/z-ai/autoglm-phone-9b` | 13K | | | | | | — | — |
|
|
125
125
|
| `qiniu-ai/z-ai/glm-4.6` | 200K | | | | | | — | — |
|
|
126
126
|
| `qiniu-ai/z-ai/glm-4.7` | 200K | | | | | | — | — |
|
|
@@ -34,8 +34,8 @@ for await (const chunk of stream) {
|
|
|
34
34
|
|
|
35
35
|
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
36
36
|
| ---------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
37
|
-
| `xiaomi/mimo-v2-flash` |
|
|
38
|
-
| `xiaomi/mimo-v2-omni` |
|
|
37
|
+
| `xiaomi/mimo-v2-flash` | 262K | | | | | | $0.10 | $0.30 |
|
|
38
|
+
| `xiaomi/mimo-v2-omni` | 262K | | | | | | $0.40 | $2 |
|
|
39
39
|
| `xiaomi/mimo-v2-pro` | 1.0M | | | | | | $1 | $3 |
|
|
40
40
|
| `xiaomi/mimo-v2.5` | 1.0M | | | | | | $0.40 | $2 |
|
|
41
41
|
| `xiaomi/mimo-v2.5-pro` | 1.0M | | | | | | $1 | $3 |
|
|
@@ -114,7 +114,7 @@ for await (const chunk of stream) {
|
|
|
114
114
|
| `zenmux/x-ai/grok-code-fast-1` | 256K | | | | | | $0.20 | $2 |
|
|
115
115
|
| `zenmux/xiaomi/mimo-v2-flash` | 262K | | | | | | $0.10 | $0.30 |
|
|
116
116
|
| `zenmux/xiaomi/mimo-v2-omni` | 265K | | | | | | $0.40 | $2 |
|
|
117
|
-
| `zenmux/xiaomi/mimo-v2-pro` | 1.0M | | | | | | $
|
|
117
|
+
| `zenmux/xiaomi/mimo-v2-pro` | 1.0M | | | | | | $1 | $3 |
|
|
118
118
|
| `zenmux/xiaomi/mimo-v2.5` | 1.0M | | | | | | $0.40 | $2 |
|
|
119
119
|
| `zenmux/xiaomi/mimo-v2.5-pro` | 1.0M | | | | | | $1 | $3 |
|
|
120
120
|
| `zenmux/z-ai/glm-4.5` | 128K | | | | | | $0.35 | $2 |
|
|
@@ -45,6 +45,7 @@ Direct access to individual AI model providers. Each provider offers unique mode
|
|
|
45
45
|
- [Jiekou.AI](https://mastra.ai/models/providers/jiekou)
|
|
46
46
|
- [Kilo Gateway](https://mastra.ai/models/providers/kilo)
|
|
47
47
|
- [Kimi For Coding](https://mastra.ai/models/providers/kimi-for-coding)
|
|
48
|
+
- [Kiro](https://mastra.ai/models/providers/kiro)
|
|
48
49
|
- [KUAE Cloud Coding Plan](https://mastra.ai/models/providers/kuae-cloud-coding-plan)
|
|
49
50
|
- [Llama](https://mastra.ai/models/providers/llama)
|
|
50
51
|
- [LLM Gateway](https://mastra.ai/models/providers/llmgateway)
|
|
@@ -550,6 +550,470 @@ See the [Storage migration guide](https://mastra.ai/guides/migrations/upgrade-to
|
|
|
550
550
|
|
|
551
551
|
It accepts [common flags](#common-flags).
|
|
552
552
|
|
|
553
|
+
## `mastra api`
|
|
554
|
+
|
|
555
|
+
Calls a Mastra runtime server with JSON input and JSON output. Use it for local development servers, deployed Mastra Platform projects, or self-hosted Mastra servers.
|
|
556
|
+
|
|
557
|
+
```bash
|
|
558
|
+
mastra api agent list --pretty
|
|
559
|
+
mastra api agent run weather-agent '{"messages":"What is the weather in London?"}'
|
|
560
|
+
mastra api tool execute get-weather '{"location":"San Francisco"}'
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
Use `mastra api <resource> <action> --help` to see examples for a command.
|
|
564
|
+
|
|
565
|
+
### Output
|
|
566
|
+
|
|
567
|
+
Success responses are written to `stdout` as JSON. Single-resource commands return:
|
|
568
|
+
|
|
569
|
+
```json
|
|
570
|
+
{ "data": {} }
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
List commands return a `data` array and pagination metadata:
|
|
574
|
+
|
|
575
|
+
```json
|
|
576
|
+
{ "data": [], "page": { "total": 0, "page": 0, "perPage": 0, "hasMore": false } }
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
Errors are written to `stderr` as JSON and return a non-zero exit code:
|
|
580
|
+
|
|
581
|
+
```json
|
|
582
|
+
{
|
|
583
|
+
"error": {
|
|
584
|
+
"code": "SERVER_UNREACHABLE",
|
|
585
|
+
"message": "Could not connect to target server",
|
|
586
|
+
"details": {}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
### Target resolution
|
|
592
|
+
|
|
593
|
+
The command resolves the target server in this order:
|
|
594
|
+
|
|
595
|
+
1. `--url <url>` for an explicit remote or self-hosted server.
|
|
596
|
+
2. `http://localhost:4111` for a local `mastra dev` server.
|
|
597
|
+
3. `.mastra-project.json` for a Mastra Platform project.
|
|
598
|
+
|
|
599
|
+
Automatic platform auth is only used when the CLI resolves a Mastra Platform target from `.mastra-project.json`. Localhost targets and explicit `--url` targets do not receive automatic credentials. Headers passed with `--header` are sent to any target, including localhost.
|
|
600
|
+
|
|
601
|
+
### Flags
|
|
602
|
+
|
|
603
|
+
#### `--url <url>`
|
|
604
|
+
|
|
605
|
+
Target a specific Mastra server URL.
|
|
606
|
+
|
|
607
|
+
```bash
|
|
608
|
+
mastra api --url https://example.com agent list
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
#### `--header <"Key: Value">`
|
|
612
|
+
|
|
613
|
+
Send a custom HTTP header. Repeat the flag to send multiple headers.
|
|
614
|
+
|
|
615
|
+
```bash
|
|
616
|
+
mastra api --url https://example.com --header "Authorization: Bearer $TOKEN" agent list
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
#### `--timeout <ms>`
|
|
620
|
+
|
|
621
|
+
Set the request timeout in milliseconds. Defaults to `30000`. Workflow run start and resume commands default to `120000`.
|
|
622
|
+
|
|
623
|
+
#### `--pretty`
|
|
624
|
+
|
|
625
|
+
Pretty-print JSON output. Defaults to `false`.
|
|
626
|
+
|
|
627
|
+
#### `--schema`
|
|
628
|
+
|
|
629
|
+
Print the CLI-oriented request schema for a command that accepts JSON input. The schema comes from the target server's route contracts and includes the command shape, positionals, examples, request schemas, and response shape.
|
|
630
|
+
|
|
631
|
+
`--schema` is available on leaf commands that accept JSON input. It is not available as a top-level `mastra api` flag.
|
|
632
|
+
|
|
633
|
+
```bash
|
|
634
|
+
mastra api agent run --schema
|
|
635
|
+
mastra api tool execute --schema
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
### Input model
|
|
639
|
+
|
|
640
|
+
Commands that accept input take one inline JSON argument. Do not pass file paths or stdin.
|
|
641
|
+
|
|
642
|
+
```bash
|
|
643
|
+
mastra api workflow run start data-pipeline '{"inputData":{"source":"s3://bucket/data.csv"}}'
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
Use positional arguments for stable IDs and JSON for filters or payloads. For routes that require both query parameters and a request body, pass one JSON object. The CLI splits the input according to the server route schema.
|
|
647
|
+
|
|
648
|
+
```bash
|
|
649
|
+
mastra api thread create '{"agentId":"weather-agent","resourceId":"user_123","threadId":"thread_abc123","title":"Support conversation"}'
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
List commands accept `page` and `perPage` in the JSON input when the target route supports pagination:
|
|
653
|
+
|
|
654
|
+
```bash
|
|
655
|
+
mastra api score list '{"page":0,"perPage":50}'
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
### Get command-specific help
|
|
659
|
+
|
|
660
|
+
Each `mastra api` leaf command includes command-specific examples in its help output. Use `--help` on the exact command you want to call:
|
|
661
|
+
|
|
662
|
+
```bash
|
|
663
|
+
mastra api agent run --help
|
|
664
|
+
mastra api tool execute --help
|
|
665
|
+
mastra api memory current update --help
|
|
666
|
+
mastra api workflow run resume --help
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
Use `--schema` on commands that accept JSON input to inspect the request shape returned by the target server:
|
|
670
|
+
|
|
671
|
+
```bash
|
|
672
|
+
mastra api agent run --schema
|
|
673
|
+
mastra api thread create --schema
|
|
674
|
+
mastra api score create --schema
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
Some commands have important runtime requirements. For example, `mastra api memory current update` requires working memory to be enabled for the memory instance, and `mastra api workflow run resume` only works for suspended workflow runs.
|
|
678
|
+
|
|
679
|
+
### Commands
|
|
680
|
+
|
|
681
|
+
#### `mastra api agent list`
|
|
682
|
+
|
|
683
|
+
Lists the agents registered on the target server. Pass optional JSON input for route-supported filters.
|
|
684
|
+
|
|
685
|
+
```bash
|
|
686
|
+
mastra api agent list [input]
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
#### `mastra api agent get`
|
|
690
|
+
|
|
691
|
+
Gets metadata for one registered agent.
|
|
692
|
+
|
|
693
|
+
```bash
|
|
694
|
+
mastra api agent get <agentId>
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
#### `mastra api agent run`
|
|
698
|
+
|
|
699
|
+
Runs an agent with JSON input. Use command help to see examples for text prompts, chat messages, and memory thread options.
|
|
700
|
+
|
|
701
|
+
```bash
|
|
702
|
+
mastra api agent run <agentId> <input>
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
#### `mastra api workflow list`
|
|
706
|
+
|
|
707
|
+
Lists workflows registered on the target server. Pass optional JSON input for route-supported filters.
|
|
708
|
+
|
|
709
|
+
```bash
|
|
710
|
+
mastra api workflow list [input]
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
#### `mastra api workflow get`
|
|
714
|
+
|
|
715
|
+
Gets metadata for one registered workflow.
|
|
716
|
+
|
|
717
|
+
```bash
|
|
718
|
+
mastra api workflow get <workflowId>
|
|
719
|
+
```
|
|
720
|
+
|
|
721
|
+
#### `mastra api workflow run start`
|
|
722
|
+
|
|
723
|
+
Starts a workflow run with JSON input. Workflow start commands use a longer default timeout than most commands because runs can take longer to complete.
|
|
724
|
+
|
|
725
|
+
```bash
|
|
726
|
+
mastra api workflow run start <workflowId> <input>
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
#### `mastra api workflow run list`
|
|
730
|
+
|
|
731
|
+
Lists runs for a workflow. Pass optional JSON input for route-supported filters or pagination.
|
|
732
|
+
|
|
733
|
+
```bash
|
|
734
|
+
mastra api workflow run list <workflowId> [input]
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
#### `mastra api workflow run get`
|
|
738
|
+
|
|
739
|
+
Gets one workflow run by ID.
|
|
740
|
+
|
|
741
|
+
```bash
|
|
742
|
+
mastra api workflow run get <workflowId> <runId>
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
#### `mastra api workflow run resume`
|
|
746
|
+
|
|
747
|
+
Resumes a suspended workflow run with JSON input. The run must be in a suspended state.
|
|
748
|
+
|
|
749
|
+
```bash
|
|
750
|
+
mastra api workflow run resume <workflowId> <runId> <input>
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
#### `mastra api workflow run cancel`
|
|
754
|
+
|
|
755
|
+
Cancels a workflow run.
|
|
756
|
+
|
|
757
|
+
```bash
|
|
758
|
+
mastra api workflow run cancel <workflowId> <runId>
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
#### `mastra api tool list`
|
|
762
|
+
|
|
763
|
+
Lists tools registered on the target server. Pass optional JSON input for route-supported filters.
|
|
764
|
+
|
|
765
|
+
```bash
|
|
766
|
+
mastra api tool list [input]
|
|
767
|
+
```
|
|
768
|
+
|
|
769
|
+
#### `mastra api tool get`
|
|
770
|
+
|
|
771
|
+
Gets metadata and schemas for one tool.
|
|
772
|
+
|
|
773
|
+
```bash
|
|
774
|
+
mastra api tool get <toolId>
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
#### `mastra api tool execute`
|
|
778
|
+
|
|
779
|
+
Executes a tool with JSON input. Raw tool input is wrapped as the route `data` field unless you pass an explicit `data` object.
|
|
780
|
+
|
|
781
|
+
```bash
|
|
782
|
+
mastra api tool execute <toolId> <input>
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
#### `mastra api mcp list`
|
|
786
|
+
|
|
787
|
+
Lists Model Context Protocol (MCP) servers registered on the target server. Pass optional JSON input for route-supported filters.
|
|
788
|
+
|
|
789
|
+
```bash
|
|
790
|
+
mastra api mcp list [input]
|
|
791
|
+
```
|
|
792
|
+
|
|
793
|
+
#### `mastra api mcp get`
|
|
794
|
+
|
|
795
|
+
Gets metadata for one MCP server.
|
|
796
|
+
|
|
797
|
+
```bash
|
|
798
|
+
mastra api mcp get <id>
|
|
799
|
+
```
|
|
800
|
+
|
|
801
|
+
#### `mastra api mcp tool list`
|
|
802
|
+
|
|
803
|
+
Lists tools exposed by an MCP server. Pass optional JSON input for route-supported filters.
|
|
804
|
+
|
|
805
|
+
```bash
|
|
806
|
+
mastra api mcp tool list <serverId> [input]
|
|
807
|
+
```
|
|
808
|
+
|
|
809
|
+
#### `mastra api mcp tool get`
|
|
810
|
+
|
|
811
|
+
Gets metadata and schemas for one MCP tool.
|
|
812
|
+
|
|
813
|
+
```bash
|
|
814
|
+
mastra api mcp tool get <serverId> <toolId>
|
|
815
|
+
```
|
|
816
|
+
|
|
817
|
+
#### `mastra api mcp tool execute`
|
|
818
|
+
|
|
819
|
+
Executes an MCP tool with JSON input. Raw tool input is wrapped as the route `data` field unless you pass an explicit `data` object.
|
|
820
|
+
|
|
821
|
+
```bash
|
|
822
|
+
mastra api mcp tool execute <serverId> <toolId> <input>
|
|
823
|
+
```
|
|
824
|
+
|
|
825
|
+
#### `mastra api thread list`
|
|
826
|
+
|
|
827
|
+
Lists memory threads. Pass optional JSON input for route-supported filters.
|
|
828
|
+
|
|
829
|
+
```bash
|
|
830
|
+
mastra api thread list [input]
|
|
831
|
+
```
|
|
832
|
+
|
|
833
|
+
#### `mastra api thread get`
|
|
834
|
+
|
|
835
|
+
Gets one memory thread by ID.
|
|
836
|
+
|
|
837
|
+
```bash
|
|
838
|
+
mastra api thread get <threadId>
|
|
839
|
+
```
|
|
840
|
+
|
|
841
|
+
#### `mastra api thread create`
|
|
842
|
+
|
|
843
|
+
Creates a memory thread. Pass one JSON input object; the CLI splits fields such as `agentId` into query parameters when required by the server route.
|
|
844
|
+
|
|
845
|
+
```bash
|
|
846
|
+
mastra api thread create <input>
|
|
847
|
+
```
|
|
848
|
+
|
|
849
|
+
#### `mastra api thread update`
|
|
850
|
+
|
|
851
|
+
Updates a memory thread. Pass one JSON input object for fields such as `agentId`, `resourceId`, `title`, or `metadata`.
|
|
852
|
+
|
|
853
|
+
```bash
|
|
854
|
+
mastra api thread update <threadId> <input>
|
|
855
|
+
```
|
|
856
|
+
|
|
857
|
+
#### `mastra api thread delete`
|
|
858
|
+
|
|
859
|
+
Deletes a memory thread. Pass JSON input for route-required query parameters such as `agentId` and `resourceId`.
|
|
860
|
+
|
|
861
|
+
```bash
|
|
862
|
+
mastra api thread delete <threadId> <input>
|
|
863
|
+
```
|
|
864
|
+
|
|
865
|
+
#### `mastra api thread messages`
|
|
866
|
+
|
|
867
|
+
Lists messages for a memory thread. Pass optional JSON input for route-supported filters or pagination.
|
|
868
|
+
|
|
869
|
+
```bash
|
|
870
|
+
mastra api thread messages <threadId> [input]
|
|
871
|
+
```
|
|
872
|
+
|
|
873
|
+
#### `mastra api memory search`
|
|
874
|
+
|
|
875
|
+
Searches long-term memory. Use `--help` or `--schema` to inspect required fields such as `agentId`, `resourceId`, and `searchQuery`.
|
|
876
|
+
|
|
877
|
+
```bash
|
|
878
|
+
mastra api memory search <input>
|
|
879
|
+
```
|
|
880
|
+
|
|
881
|
+
#### `mastra api memory current get`
|
|
882
|
+
|
|
883
|
+
Reads current working memory for a thread.
|
|
884
|
+
|
|
885
|
+
```bash
|
|
886
|
+
mastra api memory current get <input>
|
|
887
|
+
```
|
|
888
|
+
|
|
889
|
+
#### `mastra api memory current update`
|
|
890
|
+
|
|
891
|
+
Updates current working memory for a thread. Working memory must be enabled for the memory instance.
|
|
892
|
+
|
|
893
|
+
```bash
|
|
894
|
+
mastra api memory current update <input>
|
|
895
|
+
```
|
|
896
|
+
|
|
897
|
+
#### `mastra api memory status`
|
|
898
|
+
|
|
899
|
+
Gets memory status for an agent and optional thread or resource context.
|
|
900
|
+
|
|
901
|
+
```bash
|
|
902
|
+
mastra api memory status <input>
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
#### `mastra api trace list`
|
|
906
|
+
|
|
907
|
+
Lists observability traces. Pass optional JSON input for route-supported filters or pagination.
|
|
908
|
+
|
|
909
|
+
```bash
|
|
910
|
+
mastra api trace list [input]
|
|
911
|
+
```
|
|
912
|
+
|
|
913
|
+
#### `mastra api trace get`
|
|
914
|
+
|
|
915
|
+
Gets one observability trace by ID.
|
|
916
|
+
|
|
917
|
+
```bash
|
|
918
|
+
mastra api trace get <traceId>
|
|
919
|
+
```
|
|
920
|
+
|
|
921
|
+
#### `mastra api log list`
|
|
922
|
+
|
|
923
|
+
Lists observability logs. Pass optional JSON input for route-supported filters or pagination.
|
|
924
|
+
|
|
925
|
+
```bash
|
|
926
|
+
mastra api log list [input]
|
|
927
|
+
```
|
|
928
|
+
|
|
929
|
+
#### `mastra api score create`
|
|
930
|
+
|
|
931
|
+
Creates an observability score. The input uses the server score body shape; inspect it with `--schema`.
|
|
932
|
+
|
|
933
|
+
```bash
|
|
934
|
+
mastra api score create <input>
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
#### `mastra api score list`
|
|
938
|
+
|
|
939
|
+
Lists observability scores. Pass optional JSON input for filters such as run ID or pagination.
|
|
940
|
+
|
|
941
|
+
```bash
|
|
942
|
+
mastra api score list [input]
|
|
943
|
+
```
|
|
944
|
+
|
|
945
|
+
#### `mastra api score get`
|
|
946
|
+
|
|
947
|
+
Gets one observability score by ID.
|
|
948
|
+
|
|
949
|
+
```bash
|
|
950
|
+
mastra api score get <scoreId>
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
#### `mastra api dataset list`
|
|
954
|
+
|
|
955
|
+
Lists datasets. Pass optional JSON input for route-supported filters or pagination.
|
|
956
|
+
|
|
957
|
+
```bash
|
|
958
|
+
mastra api dataset list [input]
|
|
959
|
+
```
|
|
960
|
+
|
|
961
|
+
#### `mastra api dataset get`
|
|
962
|
+
|
|
963
|
+
Gets one dataset by ID.
|
|
964
|
+
|
|
965
|
+
```bash
|
|
966
|
+
mastra api dataset get <datasetId>
|
|
967
|
+
```
|
|
968
|
+
|
|
969
|
+
#### `mastra api dataset create`
|
|
970
|
+
|
|
971
|
+
Creates a dataset with JSON input.
|
|
972
|
+
|
|
973
|
+
```bash
|
|
974
|
+
mastra api dataset create <input>
|
|
975
|
+
```
|
|
976
|
+
|
|
977
|
+
#### `mastra api dataset items`
|
|
978
|
+
|
|
979
|
+
Lists items in a dataset. Pass optional JSON input for route-supported filters or pagination.
|
|
980
|
+
|
|
981
|
+
```bash
|
|
982
|
+
mastra api dataset items <datasetId> [input]
|
|
983
|
+
```
|
|
984
|
+
|
|
985
|
+
#### `mastra api experiment list`
|
|
986
|
+
|
|
987
|
+
Lists experiments for a dataset. Pass optional JSON input for route-supported filters or pagination.
|
|
988
|
+
|
|
989
|
+
```bash
|
|
990
|
+
mastra api experiment list <datasetId> [input]
|
|
991
|
+
```
|
|
992
|
+
|
|
993
|
+
#### `mastra api experiment get`
|
|
994
|
+
|
|
995
|
+
Gets one experiment by ID.
|
|
996
|
+
|
|
997
|
+
```bash
|
|
998
|
+
mastra api experiment get <datasetId> <experimentId>
|
|
999
|
+
```
|
|
1000
|
+
|
|
1001
|
+
#### `mastra api experiment run`
|
|
1002
|
+
|
|
1003
|
+
Starts an experiment for a dataset with JSON input.
|
|
1004
|
+
|
|
1005
|
+
```bash
|
|
1006
|
+
mastra api experiment run <datasetId> <input>
|
|
1007
|
+
```
|
|
1008
|
+
|
|
1009
|
+
#### `mastra api experiment results`
|
|
1010
|
+
|
|
1011
|
+
Lists results for an experiment. Pass optional JSON input for route-supported filters or pagination.
|
|
1012
|
+
|
|
1013
|
+
```bash
|
|
1014
|
+
mastra api experiment results <datasetId> <experimentId> [input]
|
|
1015
|
+
```
|
|
1016
|
+
|
|
553
1017
|
## Common flags
|
|
554
1018
|
|
|
555
1019
|
### `--dir`
|
package/.docs/reference/index.md
CHANGED
|
@@ -168,6 +168,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
168
168
|
- [PrefillErrorHandler](https://mastra.ai/reference/processors/prefill-error-handler)
|
|
169
169
|
- [Processor Interface](https://mastra.ai/reference/processors/processor-interface)
|
|
170
170
|
- [PromptInjectionDetector](https://mastra.ai/reference/processors/prompt-injection-detector)
|
|
171
|
+
- [ProviderHistoryCompat](https://mastra.ai/reference/processors/provider-history-compat)
|
|
171
172
|
- [RegexFilterProcessor](https://mastra.ai/reference/processors/regex-filter-processor)
|
|
172
173
|
- [SemanticRecall](https://mastra.ai/reference/processors/semantic-recall-processor)
|
|
173
174
|
- [SkillSearchProcessor](https://mastra.ai/reference/processors/skill-search-processor)
|
|
@@ -4,7 +4,7 @@ The `Processor` interface defines the contract for all processors in Mastra. Pro
|
|
|
4
4
|
|
|
5
5
|
## When processor methods run
|
|
6
6
|
|
|
7
|
-
The
|
|
7
|
+
The seven processor methods run at different points in the agent execution lifecycle:
|
|
8
8
|
|
|
9
9
|
```text
|
|
10
10
|
┌─────────────────────────────────────────────────────────────────┐
|
|
@@ -26,6 +26,11 @@ The six processor methods run at different points in the agent execution lifecyc
|
|
|
26
26
|
│ │ └──────────┬──────────┘ │ │
|
|
27
27
|
│ │ │ │ │
|
|
28
28
|
│ │ ▼ │ │
|
|
29
|
+
│ │ ┌─────────────────────┐ │ │
|
|
30
|
+
│ │ │ processLLMRequest │ ← Runs before provider call │ │
|
|
31
|
+
│ │ └──────────┬──────────┘ │ │
|
|
32
|
+
│ │ │ │ │
|
|
33
|
+
│ │ ▼ │ │
|
|
29
34
|
│ │ LLM Execution ──── API Error? ──┐ │ │
|
|
30
35
|
│ │ │ │ │ │
|
|
31
36
|
│ │ │ ┌───────────────────┐ │ │
|
|
@@ -59,14 +64,15 @@ The six processor methods run at different points in the agent execution lifecyc
|
|
|
59
64
|
└─────────────────────────────────────────────────────────────────┘
|
|
60
65
|
```
|
|
61
66
|
|
|
62
|
-
| Method | When it runs | Use case
|
|
63
|
-
| --------------------- | ------------------------------------------------------ |
|
|
64
|
-
| `processInput` | Once at the start, before the agentic loop | Validate/transform initial user input, add context
|
|
65
|
-
| `processInputStep` | At each step of the agentic loop, before each LLM call | Transform messages between steps, handle tool results
|
|
66
|
-
| `
|
|
67
|
-
| `
|
|
68
|
-
| `
|
|
69
|
-
| `
|
|
67
|
+
| Method | When it runs | Use case |
|
|
68
|
+
| --------------------- | ------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
|
|
69
|
+
| `processInput` | Once at the start, before the agentic loop | Validate/transform initial user input, add context |
|
|
70
|
+
| `processInputStep` | At each step of the agentic loop, before each LLM call | Transform messages between steps, handle tool results |
|
|
71
|
+
| `processLLMRequest` | After LLM request conversion, before the provider call | Rewrite the outbound `LanguageModelV2Prompt` for the current call without persisting changes |
|
|
72
|
+
| `processAPIError` | When an LLM API call fails | Inspect API rejections, optionally mutate state/messages, and request a retry |
|
|
73
|
+
| `processOutputStream` | On each streaming chunk during LLM response | Filter/modify streaming content, detect patterns in real-time |
|
|
74
|
+
| `processOutputStep` | After each LLM response, before tool execution | Validate output quality, implement guardrails with retry |
|
|
75
|
+
| `processOutputResult` | Once after generation completes | Post-process final response, log results |
|
|
70
76
|
|
|
71
77
|
## Interface definition
|
|
72
78
|
|
|
@@ -97,6 +103,10 @@ interface Processor<TId extends string = string, TTripwireMetadata = unknown> {
|
|
|
97
103
|
| void
|
|
98
104
|
| undefined
|
|
99
105
|
|
|
106
|
+
processLLMRequest?(
|
|
107
|
+
args: ProcessLLMRequestArgs<TTripwireMetadata>,
|
|
108
|
+
): Promise<ProcessLLMRequestResult> | ProcessLLMRequestResult
|
|
109
|
+
|
|
100
110
|
processAPIError?(
|
|
101
111
|
args: ProcessAPIErrorArgs<TTripwireMetadata>,
|
|
102
112
|
): Promise<ProcessAPIErrorResult | void> | ProcessAPIErrorResult | void
|
|
@@ -243,9 +253,10 @@ processInputStep?<TTripwireMetadata = unknown>(
|
|
|
243
253
|
1. `processInput` (once at start)
|
|
244
254
|
2. `processInputStep` from inputProcessors (at each step, before LLM call)
|
|
245
255
|
3. `prepareStep` callback (runs as part of the processInputStep pipeline, after inputProcessors)
|
|
246
|
-
4.
|
|
247
|
-
5.
|
|
248
|
-
6.
|
|
256
|
+
4. `processLLMRequest` from inputProcessors (after prompt conversion, before the provider call)
|
|
257
|
+
5. LLM execution
|
|
258
|
+
6. Tool execution (if needed)
|
|
259
|
+
7. Repeat from step 2 if tools were called
|
|
249
260
|
|
|
250
261
|
#### `ProcessInputStepArgs`
|
|
251
262
|
|
|
@@ -339,6 +350,57 @@ System messages are **reset to their original values** at the start of each step
|
|
|
339
350
|
|
|
340
351
|
***
|
|
341
352
|
|
|
353
|
+
### `processLLMRequest`
|
|
354
|
+
|
|
355
|
+
Processes the final LLM request after Mastra converts the `MessageList` into `LanguageModelV2Prompt` and before the provider call. Use this method for transient, model-aware rewrites that should affect only the current outbound request.
|
|
356
|
+
|
|
357
|
+
Returned prompt changes are forwarded to the model for the current call only. They are not persisted back to `MessageList`, memory, UI history, or later provider calls.
|
|
358
|
+
|
|
359
|
+
```typescript
|
|
360
|
+
processLLMRequest?(
|
|
361
|
+
args: ProcessLLMRequestArgs,
|
|
362
|
+
): Promise<ProcessLLMRequestResult> | ProcessLLMRequestResult;
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
#### `ProcessLLMRequestArgs`
|
|
366
|
+
|
|
367
|
+
**prompt** (`LanguageModelV2Prompt`): The LLM request prompt that will be sent to the provider for this call.
|
|
368
|
+
|
|
369
|
+
**model** (`MastraLanguageModel`): The resolved model that will receive the prompt. Use this to scope provider-specific rewrites.
|
|
370
|
+
|
|
371
|
+
**stepNumber** (`number`): Current step number (0-indexed). Step 0 is the initial LLM call.
|
|
372
|
+
|
|
373
|
+
**steps** (`StepResult[]`): Results from previous steps, including text, toolCalls, and toolResults.
|
|
374
|
+
|
|
375
|
+
**state** (`Record<string, unknown>`): Per-processor state that persists across all method calls within this request.
|
|
376
|
+
|
|
377
|
+
**abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort processing. Throws a TripWire error that stops execution and emits a \`tripwire\` chunk.
|
|
378
|
+
|
|
379
|
+
**retryCount** (`number`): Current retry attempt count from \`ProcessorContext\`. Starts at \`0\`; use to cap processor-triggered retries.
|
|
380
|
+
|
|
381
|
+
**requestContext** (`RequestContext`): Request-scoped context with execution metadata.
|
|
382
|
+
|
|
383
|
+
**tracingContext** (`TracingContext`): Tracing context for observability.
|
|
384
|
+
|
|
385
|
+
**writer** (`ProcessorStreamWriter`): Stream writer for emitting custom data chunks during streaming. Use \`writer.custom()\` to send transient UI signals.
|
|
386
|
+
|
|
387
|
+
**abortSignal** (`AbortSignal`): Signal for cancelling the operation.
|
|
388
|
+
|
|
389
|
+
#### Return value
|
|
390
|
+
|
|
391
|
+
`processLLMRequest` returns `ProcessLLMRequestResult`, which is `{ prompt?: LanguageModelV2Prompt } | undefined | void`.
|
|
392
|
+
|
|
393
|
+
- Return `{ prompt }` to replace the outbound prompt for the current provider call.
|
|
394
|
+
- Return `undefined` or `void` to forward the original prompt unchanged.
|
|
395
|
+
|
|
396
|
+
#### Use cases
|
|
397
|
+
|
|
398
|
+
- Removing or reshaping provider-specific prompt parts before a model call
|
|
399
|
+
- Normalizing roles or content to match a provider's input requirements
|
|
400
|
+
- Adapting tool result formats when switching providers mid-loop
|
|
401
|
+
|
|
402
|
+
***
|
|
403
|
+
|
|
342
404
|
### `processAPIError`
|
|
343
405
|
|
|
344
406
|
Handles LLM API rejection errors before they surface as final errors. This runs when the API call fails with a non-retryable error (such as a 400 or 422 status code). Unlike `processOutputStep` which runs after successful responses, this runs when the API rejects the request.
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# ProviderHistoryCompat
|
|
2
|
+
|
|
3
|
+
The `ProviderHistoryCompat` processor handles provider-specific history incompatibilities. It can rewrite the outbound language model prompt before a provider call, or react to API errors and retry with repaired message history.
|
|
4
|
+
|
|
5
|
+
Use it when an agent may switch between model providers, reuse message history across providers, or call a provider that rejects fields emitted by another provider.
|
|
6
|
+
|
|
7
|
+
## Usage example
|
|
8
|
+
|
|
9
|
+
Add `ProviderHistoryCompat` to `inputProcessors` when you want all built-in compatibility rules available for an agent:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { Agent } from '@mastra/core/agent'
|
|
13
|
+
import { ProviderHistoryCompat } from '@mastra/core/processors'
|
|
14
|
+
|
|
15
|
+
export const agent = new Agent({
|
|
16
|
+
name: 'my-agent',
|
|
17
|
+
instructions: 'You are a helpful assistant.',
|
|
18
|
+
model: 'anthropic/claude-sonnet-4-5',
|
|
19
|
+
inputProcessors: [new ProviderHistoryCompat()],
|
|
20
|
+
})
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Mastra agents don't add this processor automatically. Add it explicitly when you need provider history compatibility rules, reactive API error recovery, custom rules, or predictable processor ordering.
|
|
24
|
+
|
|
25
|
+
## Constructor parameters
|
|
26
|
+
|
|
27
|
+
**opts** (`{ additionalRules?: CompatRule[] }`): Configuration options for provider history compatibility rules.
|
|
28
|
+
|
|
29
|
+
**opts.additionalRules** (`CompatRule[]`): Custom compatibility rules to run after the built-in rules. Rules can rewrite the outbound prompt or repair persisted messages after matching an API error.
|
|
30
|
+
|
|
31
|
+
## Properties
|
|
32
|
+
|
|
33
|
+
**id** (`'provider-history-compat'`): Processor identifier.
|
|
34
|
+
|
|
35
|
+
**name** (`'Provider History Compat'`): Processor display name.
|
|
36
|
+
|
|
37
|
+
**processLLMRequest** (`(args: ProcessLLMRequestArgs) => ProcessLLMRequestResult`): Runs preemptive compatibility rules against the converted LanguageModelV2Prompt immediately before the provider call. Returned prompt changes are transient and are not persisted to memory or message history.
|
|
38
|
+
|
|
39
|
+
**processAPIError** (`(args: ProcessAPIErrorArgs) => Promise<ProcessAPIErrorResult | void>`): Runs reactive compatibility rules when a provider rejects the request. Matching rules can mutate the message list and return retry: true on the first retry attempt.
|
|
40
|
+
|
|
41
|
+
## Built-in rules
|
|
42
|
+
|
|
43
|
+
`ProviderHistoryCompat` includes these built-in compatibility rules:
|
|
44
|
+
|
|
45
|
+
| Rule | Provider | Timing | Behavior |
|
|
46
|
+
| ------------------------------------------- | --------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
|
|
47
|
+
| `anthropic-tool-id-format` | Anthropic | Reactive API error recovery | Rewrites tool call IDs that contain characters outside `[a-zA-Z0-9_-]` and retries the request. |
|
|
48
|
+
| `cerebras-strip-reasoning-content` | Cerebras | Preemptive prompt rewrite | Removes assistant `reasoning` parts from the outbound prompt so they're not serialized as unsupported `reasoning_content` fields. |
|
|
49
|
+
| `anthropic-strip-foreign-reasoning-content` | Anthropic | Preemptive prompt rewrite | Removes non-Anthropic assistant `reasoning` parts from the outbound prompt. Anthropic-native thinking history is preserved. |
|
|
50
|
+
|
|
51
|
+
Preemptive rules run through `processLLMRequest` after Mastra converts messages to the model prompt format and before the prompt is sent to the provider. These rewrites affect only the current provider call.
|
|
52
|
+
|
|
53
|
+
Reactive rules run through `processAPIError` after a provider rejection. They can update the persisted `messageList` and request a retry.
|
|
54
|
+
|
|
55
|
+
## `CompatRule`
|
|
56
|
+
|
|
57
|
+
A `CompatRule` defines one provider history compatibility fix:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import type { CompatRule } from '@mastra/core/processors'
|
|
61
|
+
|
|
62
|
+
const removeUnsupportedPromptParts: CompatRule = {
|
|
63
|
+
name: 'remove-unsupported-prompt-parts',
|
|
64
|
+
applyToPrompt({ prompt, model }) {
|
|
65
|
+
// Return a modified LanguageModelV2Prompt, or undefined to leave it unchanged.
|
|
66
|
+
return undefined
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**name** (`string`): Human-readable rule identifier for logs and debugging.
|
|
72
|
+
|
|
73
|
+
**errorPatterns** (`RegExp[]`): Patterns matched against provider API error messages and response bodies. Required for reactive rules that implement fix.
|
|
74
|
+
|
|
75
|
+
**fix** (`(messages: MastraDBMessage[]) => boolean`): Reactive fix that mutates persisted database messages after a matching API error. Return true when the rule changed messages and the request should retry.
|
|
76
|
+
|
|
77
|
+
**applyToPrompt** (`(args: { prompt: LanguageModelV2Prompt; model: unknown }) => LanguageModelV2Prompt | undefined`): Preemptive fix that rewrites the outbound prompt for the current provider call. Return undefined when no prompt change is needed.
|
|
78
|
+
|
|
79
|
+
## Custom rules
|
|
80
|
+
|
|
81
|
+
Pass custom rules through `additionalRules`. Custom rules run after the built-in rules:
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { Agent } from '@mastra/core/agent'
|
|
85
|
+
import { ProviderHistoryCompat, type CompatRule } from '@mastra/core/processors'
|
|
86
|
+
|
|
87
|
+
const stripUnsupportedAssistantMetadata: CompatRule = {
|
|
88
|
+
name: 'strip-unsupported-assistant-metadata',
|
|
89
|
+
applyToPrompt({ prompt, model }) {
|
|
90
|
+
if (typeof model !== 'string' || !model.startsWith('example-provider/')) {
|
|
91
|
+
return undefined
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
let changed = false
|
|
95
|
+
const nextPrompt = prompt.map(message => {
|
|
96
|
+
if (message.role !== 'assistant' || typeof message.content === 'string') {
|
|
97
|
+
return message
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const nextContent = message.content.map(part => {
|
|
101
|
+
if (!('providerOptions' in part)) return part
|
|
102
|
+
changed = true
|
|
103
|
+
const { providerOptions: _providerOptions, ...rest } = part
|
|
104
|
+
return rest
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
return { ...message, content: nextContent }
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
return changed ? nextPrompt : undefined
|
|
111
|
+
},
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export const agent = new Agent({
|
|
115
|
+
name: 'custom-provider-agent',
|
|
116
|
+
instructions: 'You are a helpful assistant.',
|
|
117
|
+
model: 'example-provider/model',
|
|
118
|
+
inputProcessors: [
|
|
119
|
+
new ProviderHistoryCompat({
|
|
120
|
+
additionalRules: [stripUnsupportedAssistantMetadata],
|
|
121
|
+
}),
|
|
122
|
+
],
|
|
123
|
+
})
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Use `applyToPrompt` for provider-specific rewrites that shouldn't be saved to memory. Use `fix` with `errorPatterns` when the provider rejects persisted message history and the repaired history should be reused on future turns.
|
|
127
|
+
|
|
128
|
+
## Related
|
|
129
|
+
|
|
130
|
+
- [Processor interface](https://mastra.ai/reference/processors/processor-interface)
|
|
131
|
+
- [Processors](https://mastra.ai/docs/agents/processors)
|
|
132
|
+
- [PrefillErrorHandler](https://mastra.ai/reference/processors/prefill-error-handler)
|
|
@@ -333,9 +333,9 @@ await agent.stream('message for agent', {
|
|
|
333
333
|
})
|
|
334
334
|
```
|
|
335
335
|
|
|
336
|
-
##
|
|
336
|
+
## Responses WebSocket transport
|
|
337
337
|
|
|
338
|
-
Opt into
|
|
338
|
+
Opt into Responses WebSocket streaming with provider options. This only applies to streaming calls and is supported for direct OpenAI models and Azure OpenAI Responses deployments. If WebSocket streaming is unavailable, Mastra falls back to HTTP streaming. By default, Mastra closes the WebSocket when the stream finishes.
|
|
339
339
|
|
|
340
340
|
```ts
|
|
341
341
|
const stream = await agent.stream('Hello', {
|
|
@@ -351,6 +351,20 @@ const stream = await agent.stream('Hello', {
|
|
|
351
351
|
})
|
|
352
352
|
```
|
|
353
353
|
|
|
354
|
+
For Azure OpenAI, configure the gateway with `useResponsesAPI: true`, then use `providerOptions.azure.transport`.
|
|
355
|
+
|
|
356
|
+
```ts
|
|
357
|
+
const stream = await agent.stream('Hello', {
|
|
358
|
+
providerOptions: {
|
|
359
|
+
azure: {
|
|
360
|
+
transport: 'websocket',
|
|
361
|
+
store: false,
|
|
362
|
+
websocket: { closeOnFinish: true },
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
})
|
|
366
|
+
```
|
|
367
|
+
|
|
354
368
|
To keep the connection open after the stream finishes, set `closeOnFinish: false` and close it manually.
|
|
355
369
|
|
|
356
370
|
```ts
|
|
@@ -367,6 +381,8 @@ const stream = await agent.stream('Hello', {
|
|
|
367
381
|
stream.transport?.close()
|
|
368
382
|
```
|
|
369
383
|
|
|
384
|
+
Responses WebSocket connections run one response at a time. Mastra rejects overlapping continuation requests that include `previous_response_id` on the same WebSocket transport. Wait for the active stream to finish before sending the next turn in the response chain.
|
|
385
|
+
|
|
370
386
|
## Related
|
|
371
387
|
|
|
372
388
|
- [Generating responses](https://mastra.ai/docs/agents/overview)
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.1.35-alpha.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`087e413`](https://github.com/mastra-ai/mastra/commit/087e4133e5d6efa36619e9556c16750e4179c047), [`087e413`](https://github.com/mastra-ai/mastra/commit/087e4133e5d6efa36619e9556c16750e4179c047), [`087e413`](https://github.com/mastra-ai/mastra/commit/087e4133e5d6efa36619e9556c16750e4179c047)]:
|
|
8
|
+
- @mastra/core@1.33.0-alpha.3
|
|
9
|
+
|
|
10
|
+
## 1.1.35-alpha.6
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`d1fdbd0`](https://github.com/mastra-ai/mastra/commit/d1fdbd012add5623cb7e6b7f882b605ab358bbb4), [`d91ebe2`](https://github.com/mastra-ai/mastra/commit/d91ebe28ee065d8f2ed6df741c3c07f58d359529)]:
|
|
15
|
+
- @mastra/core@1.33.0-alpha.2
|
|
16
|
+
|
|
3
17
|
## 1.1.35-alpha.4
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.1.35-alpha.
|
|
3
|
+
"version": "1.1.35-alpha.8",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"jsdom": "^26.1.0",
|
|
30
30
|
"local-pkg": "^1.1.2",
|
|
31
31
|
"zod": "^4.3.6",
|
|
32
|
-
"@mastra/core": "1.33.0-alpha.
|
|
32
|
+
"@mastra/core": "1.33.0-alpha.3",
|
|
33
33
|
"@mastra/mcp": "^1.7.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"vitest": "4.1.5",
|
|
49
49
|
"@internal/lint": "0.0.92",
|
|
50
50
|
"@internal/types-builder": "0.0.67",
|
|
51
|
-
"@mastra/core": "1.33.0-alpha.
|
|
51
|
+
"@mastra/core": "1.33.0-alpha.3"
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://mastra.ai",
|
|
54
54
|
"repository": {
|