@mastra/mcp-docs-server 1.2.13-alpha.6 → 1.2.13-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/agents/agent-approval.md +2 -2
- package/.docs/docs/deployment/workers.md +14 -14
- package/.docs/docs/evals/datasets/running-experiments.md +1 -1
- package/.docs/docs/index.md +1 -1
- package/.docs/docs/long-running-agents/durable-agents.md +2 -2
- package/.docs/docs/mastra-platform/overview.md +1 -1
- package/.docs/docs/mastra-platform/{workspace.md → workspaces.md} +48 -7
- package/.docs/docs/memory/observational-memory.md +5 -5
- package/.docs/docs/memory/overview.md +1 -1
- package/.docs/docs/server/auth/workers.md +7 -5
- package/.docs/docs/server/mastra-client.md +60 -0
- package/.docs/docs/server/pubsub.md +2 -2
- package/.docs/docs/what-is-mastra.md +10 -10
- package/.docs/docs/workflows/overview.md +1 -1
- package/.docs/docs/workflows/scheduled-workflows.md +1 -0
- package/.docs/guides/deployment/kubernetes.md +2 -0
- package/.docs/guides/deployment/mastra-workers.md +350 -6
- package/.docs/guides/deployment/vercel.md +2 -0
- package/.docs/models/gateways/openrouter.md +3 -6
- package/.docs/models/gateways/vercel.md +3 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/crossmodel.md +4 -3
- package/.docs/models/providers/hyper.md +7 -6
- package/.docs/models/providers/llmgateway.md +4 -3
- package/.docs/models/providers/openai.md +2 -2
- package/.docs/models/providers/opencode-go.md +2 -1
- package/.docs/models/providers/opencode.md +1 -1
- package/.docs/models/providers/zai-coding-plan.md +11 -13
- package/.docs/models/providers/zhipuai-coding-plan.md +12 -12
- package/.docs/reference/agents/durable-agent.md +3 -3
- package/.docs/reference/cli/mastra.md +30 -14
- package/.docs/reference/core/mastra-class.md +1 -1
- package/.docs/reference/evals/summarization.md +5 -5
- package/.docs/reference/processors/regex-filter-processor.md +1 -1
- package/.docs/reference/tools/isolated-vm-transport.md +1 -1
- package/.docs/reference/vectors/mongodb.md +13 -13
- package/.docs/reference/workers/overview.md +10 -8
- package/.docs/reference/workspace/platform-filesystem.md +5 -2
- package/.docs/reference/workspace/platform-sandbox.md +58 -4
- package/CHANGELOG.md +15 -0
- package/package.json +4 -4
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# OpenCode Go
|
|
4
4
|
|
|
5
|
-
Access
|
|
5
|
+
Access 23 OpenCode Go models through Mastra's model router. Authentication is handled automatically using the `OPENCODE_API_KEY` environment variable.
|
|
6
6
|
|
|
7
7
|
Learn more in the [OpenCode Go documentation](https://opencode.ai/docs/zen).
|
|
8
8
|
|
|
@@ -40,6 +40,7 @@ for await (const chunk of stream) {
|
|
|
40
40
|
| `opencode-go/deepseek-v4-pro` | 1.0M | | | | | | $0.43 | $0.87 |
|
|
41
41
|
| `opencode-go/glm-5.1` | 203K | | | | | | $1 | $4 |
|
|
42
42
|
| `opencode-go/glm-5.2` | 1.0M | | | | | | $1 | $4 |
|
|
43
|
+
| `opencode-go/gpt-5.6-luna` | 1.1M | | | | | | $0.10 | $0.60 |
|
|
43
44
|
| `opencode-go/grok-4.5` | 500K | | | | | | $2 | $6 |
|
|
44
45
|
| `opencode-go/hy3` | 256K | | | | | | $0.14 | $0.58 |
|
|
45
46
|
| `opencode-go/kimi-k2.6` | 262K | | | | | | $0.95 | $4 |
|
|
@@ -77,7 +77,7 @@ for await (const chunk of stream) {
|
|
|
77
77
|
| `opencode/gpt-5.4-pro` | 1.1M | | | | | | $30 | $180 |
|
|
78
78
|
| `opencode/gpt-5.5` | 1.1M | | | | | | $5 | $30 |
|
|
79
79
|
| `opencode/gpt-5.5-pro` | 1.1M | | | | | | $30 | $180 |
|
|
80
|
-
| `opencode/gpt-5.6-luna` | 1.1M | | | | | | $
|
|
80
|
+
| `opencode/gpt-5.6-luna` | 1.1M | | | | | | $0.20 | $1 |
|
|
81
81
|
| `opencode/gpt-5.6-sol` | 1.1M | | | | | | $5 | $30 |
|
|
82
82
|
| `opencode/gpt-5.6-terra` | 1.1M | | | | | | $3 | $15 |
|
|
83
83
|
| `opencode/grok-4.5` | 500K | | | | | | $2 | $6 |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Z.AI Coding Plan
|
|
4
4
|
|
|
5
|
-
Access
|
|
5
|
+
Access 4 Z.AI Coding Plan models through Mastra's model router. Authentication is handled automatically using the `ZHIPU_API_KEY` environment variable.
|
|
6
6
|
|
|
7
7
|
Learn more in the [Z.AI Coding Plan documentation](https://docs.z.ai/devpack/overview).
|
|
8
8
|
|
|
@@ -17,7 +17,7 @@ const agent = new Agent({
|
|
|
17
17
|
id: "my-agent",
|
|
18
18
|
name: "My Agent",
|
|
19
19
|
instructions: "You are a helpful assistant",
|
|
20
|
-
model: "zai-coding-plan/glm-4.
|
|
20
|
+
model: "zai-coding-plan/glm-4.7"
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
// Generate a response
|
|
@@ -34,14 +34,12 @@ for await (const chunk of stream) {
|
|
|
34
34
|
|
|
35
35
|
## Models
|
|
36
36
|
|
|
37
|
-
| Model
|
|
38
|
-
|
|
|
39
|
-
| `zai-coding-plan/glm-4.
|
|
40
|
-
| `zai-coding-plan/glm-
|
|
41
|
-
| `zai-coding-plan/glm-5
|
|
42
|
-
| `zai-coding-plan/glm-5.
|
|
43
|
-
| `zai-coding-plan/glm-5.2` | 1.0M | | | | | | — | — |
|
|
44
|
-
| `zai-coding-plan/glm-5v-turbo` | 200K | | | | | | — | — |
|
|
37
|
+
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
38
|
+
| --------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
39
|
+
| `zai-coding-plan/glm-4.7` | 205K | | | | | | — | — |
|
|
40
|
+
| `zai-coding-plan/glm-5-turbo` | 200K | | | | | | — | — |
|
|
41
|
+
| `zai-coding-plan/glm-5.2` | 1.0M | | | | | | — | — |
|
|
42
|
+
| `zai-coding-plan/glm-5.2-highspeed[1m]` | 1.0M | | | | | | — | — |
|
|
45
43
|
|
|
46
44
|
## Advanced configuration
|
|
47
45
|
|
|
@@ -53,7 +51,7 @@ const agent = new Agent({
|
|
|
53
51
|
name: "custom-agent",
|
|
54
52
|
model: {
|
|
55
53
|
url: "https://api.z.ai/api/coding/paas/v4",
|
|
56
|
-
id: "zai-coding-plan/glm-4.
|
|
54
|
+
id: "zai-coding-plan/glm-4.7",
|
|
57
55
|
apiKey: process.env.ZHIPU_API_KEY,
|
|
58
56
|
headers: {
|
|
59
57
|
"X-Custom-Header": "value"
|
|
@@ -71,8 +69,8 @@ const agent = new Agent({
|
|
|
71
69
|
model: ({ requestContext }) => {
|
|
72
70
|
const useAdvanced = requestContext.task === "complex";
|
|
73
71
|
return useAdvanced
|
|
74
|
-
? "zai-coding-plan/glm-
|
|
75
|
-
: "zai-coding-plan/glm-4.
|
|
72
|
+
? "zai-coding-plan/glm-5.2-highspeed[1m]"
|
|
73
|
+
: "zai-coding-plan/glm-4.7";
|
|
76
74
|
}
|
|
77
75
|
});
|
|
78
76
|
```
|
|
@@ -17,7 +17,7 @@ const agent = new Agent({
|
|
|
17
17
|
id: "my-agent",
|
|
18
18
|
name: "My Agent",
|
|
19
19
|
instructions: "You are a helpful assistant",
|
|
20
|
-
model: "zhipuai-coding-plan/glm-4.
|
|
20
|
+
model: "zhipuai-coding-plan/glm-4.6v"
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
// Generate a response
|
|
@@ -34,15 +34,15 @@ for await (const chunk of stream) {
|
|
|
34
34
|
|
|
35
35
|
## Models
|
|
36
36
|
|
|
37
|
-
| Model
|
|
38
|
-
|
|
|
39
|
-
| `zhipuai-coding-plan/glm-4.
|
|
40
|
-
| `zhipuai-coding-plan/glm-4.
|
|
41
|
-
| `zhipuai-coding-plan/glm-
|
|
42
|
-
| `zhipuai-coding-plan/glm-5
|
|
43
|
-
| `zhipuai-coding-plan/glm-5.
|
|
44
|
-
| `zhipuai-coding-plan/glm-5.2`
|
|
45
|
-
| `zhipuai-coding-plan/glm-5v-turbo`
|
|
37
|
+
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
38
|
+
| ------------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
39
|
+
| `zhipuai-coding-plan/glm-4.6v` | 128K | | | | | | $0.30 | $0.90 |
|
|
40
|
+
| `zhipuai-coding-plan/glm-4.7` | 205K | | | | | | — | — |
|
|
41
|
+
| `zhipuai-coding-plan/glm-5-turbo` | 200K | | | | | | — | — |
|
|
42
|
+
| `zhipuai-coding-plan/glm-5.1` | 200K | | | | | | — | — |
|
|
43
|
+
| `zhipuai-coding-plan/glm-5.2` | 1.0M | | | | | | — | — |
|
|
44
|
+
| `zhipuai-coding-plan/glm-5.2-highspeed[1m]` | 1.0M | | | | | | — | — |
|
|
45
|
+
| `zhipuai-coding-plan/glm-5v-turbo` | 200K | | | | | | — | — |
|
|
46
46
|
|
|
47
47
|
## Advanced configuration
|
|
48
48
|
|
|
@@ -54,7 +54,7 @@ const agent = new Agent({
|
|
|
54
54
|
name: "custom-agent",
|
|
55
55
|
model: {
|
|
56
56
|
url: "https://open.bigmodel.cn/api/coding/paas/v4",
|
|
57
|
-
id: "zhipuai-coding-plan/glm-4.
|
|
57
|
+
id: "zhipuai-coding-plan/glm-4.6v",
|
|
58
58
|
apiKey: process.env.ZHIPU_API_KEY,
|
|
59
59
|
headers: {
|
|
60
60
|
"X-Custom-Header": "value"
|
|
@@ -73,7 +73,7 @@ const agent = new Agent({
|
|
|
73
73
|
const useAdvanced = requestContext.task === "complex";
|
|
74
74
|
return useAdvanced
|
|
75
75
|
? "zhipuai-coding-plan/glm-5v-turbo"
|
|
76
|
-
: "zhipuai-coding-plan/glm-4.
|
|
76
|
+
: "zhipuai-coding-plan/glm-4.6v";
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
```
|
|
@@ -174,7 +174,7 @@ const { output, cleanup } = await durableAgent.observe(runId, {
|
|
|
174
174
|
await output.text
|
|
175
175
|
```
|
|
176
176
|
|
|
177
|
-
By default `observe()` waits indefinitely for events. If the process running the run stops unexpectedly, the run stops producing events but never emits a completion event, so the observed stream would wait forever. Pass `idleTimeoutMs` to bound that wait: after that many milliseconds of silence the stream ends. An optional `isAlive` check is consulted first
|
|
177
|
+
By default `observe()` waits indefinitely for events. If the process running the run stops unexpectedly, the run stops producing events but never emits a completion event, so the observed stream would wait forever. Pass `idleTimeoutMs` to bound that wait: after that many milliseconds of silence the stream ends. An optional `isAlive` check is consulted first. Return `true` while the run is still being worked on (for example a long-running tool call, or a run paused waiting for human input) to keep waiting. Returning `false`, or omitting `isAlive`, ends the stream with an error. A transient throw from `isAlive` is treated as "still alive", so a momentary check failure never ends a live stream.
|
|
178
178
|
|
|
179
179
|
```typescript
|
|
180
180
|
const { output } = await durableAgent.observe(runId, {
|
|
@@ -183,7 +183,7 @@ const { output } = await durableAgent.observe(runId, {
|
|
|
183
183
|
})
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
-
Ending a run on idle timeout runs the same cleanup as a run that errors (see the warning below), so its cached state is released rather than retained. Both options are opt-in
|
|
186
|
+
Ending a run on idle timeout runs the same cleanup as a run that errors (see the warning below), so its cached state is released rather than retained. Both options are opt-in. Omit them for the previous wait-indefinitely behavior.
|
|
187
187
|
|
|
188
188
|
Returns: `Promise<DurableAgentStreamResult>`
|
|
189
189
|
|
|
@@ -344,7 +344,7 @@ Returns: [`Promise<DurableAgentStreamResult>`](#durableagentstreamresult)
|
|
|
344
344
|
|
|
345
345
|
## DurableAgentStreamResult
|
|
346
346
|
|
|
347
|
-
The object returned by `stream()`, `resume()`, and `
|
|
347
|
+
The object returned by `stream()`, `resume()`, `observe()`, and `recover()`.
|
|
348
348
|
|
|
349
349
|
```typescript
|
|
350
350
|
interface DurableAgentStreamResult<OUTPUT = undefined> {
|
|
@@ -171,7 +171,7 @@ Comma-separated list of custom arguments to pass to the Node.js process, e.g. `-
|
|
|
171
171
|
|
|
172
172
|
## `mastra worker build`
|
|
173
173
|
|
|
174
|
-
Bundles your Mastra application for worker deployment. Produces the same output as `mastra build
|
|
174
|
+
Bundles your Mastra application for worker deployment. Produces the same output as `mastra build`: a self-contained `.mastra/output/` directory.
|
|
175
175
|
|
|
176
176
|
```bash
|
|
177
177
|
mastra worker build [options]
|
|
@@ -179,29 +179,45 @@ mastra worker build [options]
|
|
|
179
179
|
|
|
180
180
|
### Flags
|
|
181
181
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
182
|
+
#### `--dir`
|
|
183
|
+
|
|
184
|
+
Path to your Mastra source directory. Defaults to `src/mastra`.
|
|
185
|
+
|
|
186
|
+
#### `--root`
|
|
187
|
+
|
|
188
|
+
Project root directory. Defaults to the current directory.
|
|
189
|
+
|
|
190
|
+
#### `--tools`
|
|
191
|
+
|
|
192
|
+
Comma-separated tool paths to include in the bundle.
|
|
193
|
+
|
|
194
|
+
#### `--output-dir`
|
|
195
|
+
|
|
196
|
+
Custom output directory. Defaults to `.mastra/output`.
|
|
197
|
+
|
|
198
|
+
#### `--debug`
|
|
199
|
+
|
|
200
|
+
Enable debug logging during the build.
|
|
189
201
|
|
|
190
202
|
## `mastra worker start`
|
|
191
203
|
|
|
192
204
|
> **Info:** You need to run `mastra worker build` or `mastra build` before using `mastra worker start`.
|
|
193
205
|
|
|
194
|
-
Starts a worker process from a previously built bundle.
|
|
206
|
+
Starts a worker process from a previously built bundle. The optional `name` argument sets `MASTRA_WORKERS` in the spawned process, controlling which worker starts.
|
|
195
207
|
|
|
196
208
|
```bash
|
|
197
209
|
mastra worker start [name] [options]
|
|
198
210
|
```
|
|
199
211
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
212
|
+
### Flags
|
|
213
|
+
|
|
214
|
+
#### `--dir`
|
|
215
|
+
|
|
216
|
+
Path to the build output directory. Defaults to `.mastra/output`.
|
|
217
|
+
|
|
218
|
+
#### `--env`
|
|
219
|
+
|
|
220
|
+
Path to the environment file. Defaults to `.env.production`, falling back to `.env`.
|
|
205
221
|
|
|
206
222
|
### Examples
|
|
207
223
|
|
|
@@ -135,7 +135,7 @@ Visit the [Configuration reference](https://mastra.ai/reference/configuration) f
|
|
|
135
135
|
|
|
136
136
|
Re-drives every orphaned `running` durable-agent run across all registered durable agents. Called automatically on boot when `recovery.durableAgents` is `'auto'`. You can also call it directly for manual recovery or from a scheduled task.
|
|
137
137
|
|
|
138
|
-
Requires persistent storage
|
|
138
|
+
Requires persistent storage. With an in-memory store, there's nothing to recover after a process restart.
|
|
139
139
|
|
|
140
140
|
```typescript
|
|
141
141
|
const result = await mastra.recoverAllDurableAgents()
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Summarization scorer
|
|
4
4
|
|
|
5
|
-
The `createSummarizationScorer()` function creates a scorer that evaluates a summary on two axes: whether every claim it makes is supported by the source text, and whether it preserves the information the source states. The final score is the lower of the two, so a summary
|
|
5
|
+
The `createSummarizationScorer()` function creates a scorer that evaluates a summary on two axes: whether every claim it makes is supported by the source text, and whether it preserves the information the source states. The final score is the lower of the two, so a summary can't pass by being faithful but empty, or thorough but wrong.
|
|
6
6
|
|
|
7
7
|
The summary is the agent's last message that carries text, and the source text defaults to the first user message of the run input. Pass `source` or `sourceExtractor` when the text being summarized lives somewhere else, such as a tool result.
|
|
8
8
|
|
|
@@ -96,13 +96,13 @@ These ranges assume the default `scale` of 1. When using a custom scale, multipl
|
|
|
96
96
|
|
|
97
97
|
- **0.9-1.0**: Excellent summary, faithful to the source and covering its main points
|
|
98
98
|
- **0.7-0.8**: Good summary with a small omission or an unsupported detail
|
|
99
|
-
- **0.4-0.6**: Moderate summary, either missing
|
|
99
|
+
- **0.4-0.6**: Moderate summary, either missing important information or drifting from the source
|
|
100
100
|
- **0.1-0.3**: Poor summary, most of the source is lost or contradicted
|
|
101
|
-
- **0.0**: The summary
|
|
101
|
+
- **0.0**: The summary produced nothing to judge, or it failed to support any claims. A summary that answers no questions also receives this score
|
|
102
102
|
|
|
103
103
|
### Reading the two axes
|
|
104
104
|
|
|
105
|
-
Both axes leave their verdicts on the run result: the alignment verdicts on the preprocess step, and the coverage verdicts on the analyze step. Each verdict carries the claim or question it belongs to and the reason behind it.
|
|
105
|
+
Both axes leave their verdicts on the run result: the alignment verdicts on the preprocess step, and the coverage verdicts on the analyze step. Each verdict carries the claim or question it belongs to and the reason behind it. A low alignment score has a different meaning from a low coverage score:
|
|
106
106
|
|
|
107
107
|
- A low alignment score with high coverage means the summary invents or distorts detail
|
|
108
108
|
- A low coverage score with high alignment means the summary is accurate but leaves too much out
|
|
@@ -115,7 +115,7 @@ Length plays no part in the score. A summary that repeats the source word for wo
|
|
|
115
115
|
|
|
116
116
|
### Cost
|
|
117
117
|
|
|
118
|
-
Each evaluation makes three model calls. `maxQuestions` bounds the coverage half of the work, which otherwise grows with source length. Raise it for long documents where ten questions
|
|
118
|
+
Each evaluation makes three model calls. `maxQuestions` bounds the coverage half of the work, which otherwise grows with source length. Raise it for long documents where ten questions can't represent the content.
|
|
119
119
|
|
|
120
120
|
## Scorer configuration
|
|
121
121
|
|
|
@@ -125,7 +125,7 @@ A replacement string can reference capture groups with `$1` or `$&`. Those refer
|
|
|
125
125
|
|
|
126
126
|
## Redaction reporting
|
|
127
127
|
|
|
128
|
-
The `redact` strategy rewrites text in place, so nothing downstream can tell what changed. Assign `onViolation` to record it. The processor calls it once per redacted message, message part, or stream chunk, and offsets are relative to that piece of text. Async callbacks are awaited, and errors are caught so an unavailable audit sink
|
|
128
|
+
The `redact` strategy rewrites text in place, so nothing downstream can tell what changed. Assign `onViolation` to record it. The processor calls it once per redacted message, message part, or stream chunk, and offsets are relative to that piece of text. Async callbacks are awaited, and errors are caught so an unavailable audit sink can't fail the request.
|
|
129
129
|
|
|
130
130
|
```typescript
|
|
131
131
|
import { RegexFilterProcessor, type RegexRedactionDetail } from '@mastra/core/processors'
|
|
@@ -34,7 +34,7 @@ yarn add @mastra/isolated-vm
|
|
|
34
34
|
bun add @mastra/isolated-vm
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
`isolated-vm` is a native addon. It
|
|
37
|
+
`isolated-vm` is a native addon. It provides prebuilt binaries for common platforms, so installation usually needs no extra setup. A C++ toolchain is only needed on platforms without a matching prebuild, where it falls back to compiling from source.
|
|
38
38
|
|
|
39
39
|
On Node.js 20 and later, the host process must be started with the `--no-node-snapshot` flag, otherwise creating an isolate crashes the process. The constructor throws an error when the flag is missing. Pass the flag when starting your server, or set it through `NODE_OPTIONS`:
|
|
40
40
|
|
|
@@ -109,7 +109,7 @@ Waits for an index to become ready after creation. Useful when you need to ensur
|
|
|
109
109
|
|
|
110
110
|
### `upsert()`
|
|
111
111
|
|
|
112
|
-
Adds or updates vectors and their metadata in the collection. On a bring-your-own index this requires `allowWrites: true` at `createIndex()` time
|
|
112
|
+
Adds or updates vectors and their metadata in the collection. On a bring-your-own index, this requires `allowWrites: true` at `createIndex()` time because BYO collections are read-only by default.
|
|
113
113
|
|
|
114
114
|
**indexName** (`string`): Name of the collection to insert into
|
|
115
115
|
|
|
@@ -148,12 +148,12 @@ Provisions an Atlas Search (BM25/full-text) index on the collection backing an i
|
|
|
148
148
|
**Managed vs. bring-your-own collections:**
|
|
149
149
|
|
|
150
150
|
- For a **managed** index (created without `collectionName`), `createIndex()` already provisions a _dynamic_ full-text index named `${collectionName}_search_index` (covering all string fields). `createSearchIndex()` is therefore only needed when you want a **field-restricted** mapping or a **custom index name**.
|
|
151
|
-
- For a **bring-your-own** index (created with `collectionName`), `createIndex()`
|
|
151
|
+
- For a **bring-your-own** index (created with `collectionName`), `createIndex()` doesn't auto-create any full-text index. Enabling `textQuery()`/`hybridQuery()` on a caller-owned operational collection is opt-in. Call `createSearchIndex()` explicitly to provision the (billable) text index. Until you do, `textQuery()`/`hybridQuery()` throw a clear error rather than querying a non-existent index.
|
|
152
152
|
|
|
153
153
|
Naming:
|
|
154
154
|
|
|
155
|
-
- When `fields` is provided **without** an explicit `searchIndexName`, the field-mapped index is created under a **distinct** default name (`${collectionName}_${indexName}_search_fields_index`, unique per logical index) so it
|
|
156
|
-
- When `searchIndexName` is provided, that exact name is used and persisted. `textQuery()`/`hybridQuery()` resolve the persisted name automatically
|
|
155
|
+
- When `fields` is provided **without** an explicit `searchIndexName`, the field-mapped index is created under a **distinct** default name (`${collectionName}_${indexName}_search_fields_index`, unique per logical index) so it doesn't collide with a managed collection's auto-created dynamic index and get silently ignored. This distinct index is persisted as the text-search index, so `textQuery()`/`hybridQuery()` use the restricted mapping automatically.
|
|
156
|
+
- When `searchIndexName` is provided, that exact name is used and persisted. `textQuery()`/`hybridQuery()` resolve the persisted name automatically. You can also override the name per call via their `searchIndexName` / `textSearchIndexName` parameters.
|
|
157
157
|
|
|
158
158
|
**indexName** (`string`): Name of the Mastra index whose collection will have the search index
|
|
159
159
|
|
|
@@ -170,7 +170,7 @@ await store.createSearchIndex({
|
|
|
170
170
|
})
|
|
171
171
|
```
|
|
172
172
|
|
|
173
|
-
|
|
173
|
+
The field-mapped index name includes the logical `indexName`, so two logical indexes on the same collection get distinct text indexes. Recreating the _same_ logical index with different `fields` still requires dropping the existing index first (`IndexAlreadyExists`).
|
|
174
174
|
|
|
175
175
|
### `waitForSearchIndexReady()`
|
|
176
176
|
|
|
@@ -193,7 +193,7 @@ await store.waitForSearchIndexReady({ indexName: 'precedents' })
|
|
|
193
193
|
|
|
194
194
|
Runs a full-text (BM25) search against an Atlas Search index. By default it targets the text-search index recorded for this index (set by `createSearchIndex()`, or the dynamic `${collectionName}_search_index` auto-created by `createIndex()`). Pass `searchIndexName` to target a specific index for this call.
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
Metadata filters here (like `hybridQuery()`) are applied via a `$match` stage. For the vector branch of `hybridQuery()`, filters on fields not declared via `filterFields` at index creation are transparently materialised as candidate `_id`s (the same fallback `query()` uses), so undeclared-field filters don't error.
|
|
197
197
|
|
|
198
198
|
**indexName** (`string`): Name of the Mastra index to search
|
|
199
199
|
|
|
@@ -220,7 +220,7 @@ const results = await store.textQuery({
|
|
|
220
220
|
|
|
221
221
|
### `hybridQuery()`
|
|
222
222
|
|
|
223
|
-
Runs a hybrid search that fuses vector similarity and full-text results using MongoDB's server-side `$rankFusion
|
|
223
|
+
Runs a hybrid search that fuses vector similarity and full-text results using MongoDB's server-side `$rankFusion`. It requires MongoDB >= 8.0 and is generally available from 8.1. On 8.0.x, it may need a MongoDB support case to enable, and it runs where enabled, such as Atlas 8.0.x. A full-text search index must exist: it's auto-created for managed indexes, but for a bring-your-own collection you must call `createSearchIndex()` first (opt-in).
|
|
224
224
|
|
|
225
225
|
**indexName** (`string`): Name of the Mastra index to search
|
|
226
226
|
|
|
@@ -253,7 +253,7 @@ const results = await store.hybridQuery({
|
|
|
253
253
|
})
|
|
254
254
|
```
|
|
255
255
|
|
|
256
|
-
|
|
256
|
+
`hybridQuery()` requires MongoDB >= 8.0 for the `$rankFusion` stage. The stage is generally available from 8.1. On 8.0.x, it may need a MongoDB support case to enable and runs where enabled, such as Atlas 8.0.x. If you're running an older version, or `$rankFusion` isn't enabled on your 8.0.x deployment, use `query()` and `textQuery()` separately and merge the results client-side.
|
|
257
257
|
|
|
258
258
|
### `describeIndex()`
|
|
259
259
|
|
|
@@ -276,15 +276,15 @@ interface IndexStats {
|
|
|
276
276
|
Deletes a vector index. Behavior depends on how the index was created:
|
|
277
277
|
|
|
278
278
|
- **Managed index** (created without `collectionName`): drops the entire collection and all its data.
|
|
279
|
-
- **Bring-your-own index** (created with `collectionName`): drops the Atlas vectorSearch index
|
|
279
|
+
- **Bring-your-own index** (created with `collectionName`): drops the Atlas vectorSearch index and, if one was provisioned via `createSearchIndex()`, the companion full-text search index. The caller's operational collection and its documents are preserved. This store never drops a collection it didn't create.
|
|
280
280
|
|
|
281
|
-
The BYO classification is recorded durably when the index is created, so it
|
|
281
|
+
The BYO classification is recorded durably when the index is created, so it's applied correctly even by a different process (e.g. an index created by a setup job and later deleted by a long-lived service). Always pass the **logical index name** (the `indexName` used at `createIndex`), not the physical collection name.
|
|
282
282
|
|
|
283
283
|
**indexName** (`string`): Logical name of the index to delete
|
|
284
284
|
|
|
285
285
|
### `listIndexes()`
|
|
286
286
|
|
|
287
|
-
Lists the **logical** Mastra index names (the `indexName` values passed to `createIndex`), not physical collection names. For a bring-your-own index whose data lives in an operational collection, the logical index name is returned
|
|
287
|
+
Lists the **logical** Mastra index names (the `indexName` values passed to `createIndex`), not physical collection names. For a bring-your-own index whose data lives in an operational collection, the logical index name is returned instead of the physical collection name. The value can be passed straight back into `deleteIndex()` / `describeIndex()`. Managed indexes created before durable metadata was introduced are still discovered via their `${name}_vector_index` search index. The internal registry collection is never listed.
|
|
288
288
|
|
|
289
289
|
Returns: `Promise<string[]>`
|
|
290
290
|
|
|
@@ -408,12 +408,12 @@ await store.createSearchIndex({ indexName: 'precedents', fields: ['note'] })
|
|
|
408
408
|
|
|
409
409
|
- The collection must already exist and contain documents with an `embedding` field (or the custom `embeddingFieldPath` you configured)
|
|
410
410
|
- The collection is never created or dropped when using `collectionName`
|
|
411
|
-
- **A BYO index is read-only by default.** `upsert()`, `updateVector()`, `deleteVector()`, and `deleteVectors()` throw a clear error rather than mutating caller-owned operational documents. To let the store write embeddings into (or delete documents from) your collection, opt in explicitly with `createIndex({ ..., allowWrites: true })`. The policy is persisted and survives restarts
|
|
411
|
+
- **A BYO index is read-only by default.** `upsert()`, `updateVector()`, `deleteVector()`, and `deleteVectors()` throw a clear error rather than mutating caller-owned operational documents. To let the store write embeddings into (or delete documents from) your collection, opt in explicitly with `createIndex({ ..., allowWrites: true })`. The policy is persisted and survives restarts. Entries written by older versions without the flag are treated as read-only (fail closed).
|
|
412
412
|
- Use `metadataMode: 'document'` when querying to retrieve the full source document as `metadata`
|
|
413
413
|
- In `'document'` mode the embedding is omitted from `metadata` by default; pass `includeVector: true` to retain it (and also expose it as a top-level `vector`)
|
|
414
414
|
- **Filtering in `'document'` mode operates on root document fields**, not a nested `metadata.` subdocument. `filter: { lane: 'fraud' }` matches the top-level `lane` field of your operational documents (in the default `'field'` mode, bare fields are rewritten to `metadata.<field>` for managed collections). Both the pushdown and `$match` fallback paths honor this.
|
|
415
415
|
- **Native `ObjectId` `_id`s are supported.** Operational collections commonly key on `ObjectId`; query results coerce `_id` to a string (the `QueryResult.id` contract), and `deleteVector()`/`updateVector()`/`deleteVectors()` accept that string and match the underlying `ObjectId` document. Managed collections (string `_id`s) are unaffected.
|
|
416
|
-
- Full-text and hybrid search on a BYO collection are **opt-in**: no full-text index is auto-created, so call `createSearchIndex()` before `textQuery()`/`hybridQuery()`. The full-text index builds asynchronously
|
|
416
|
+
- Full-text and hybrid search on a BYO collection are **opt-in**: no full-text index is auto-created, so call `createSearchIndex()` before `textQuery()`/`hybridQuery()`. The full-text index builds asynchronously. Call `waitForSearchIndexReady()` (or pass `waitUntilReady: true`) before an immediate text/hybrid query.
|
|
417
417
|
- `deleteIndex()` on a BYO index drops the vector index (and the text index if one was created) but **preserves** the collection and its documents
|
|
418
418
|
|
|
419
419
|
## Best practices
|
|
@@ -10,14 +10,14 @@ For usage patterns and deployment topologies, see [Workers](https://mastra.ai/do
|
|
|
10
10
|
|
|
11
11
|
Controls which workers start in the current process.
|
|
12
12
|
|
|
13
|
-
| Value | Behavior
|
|
14
|
-
| --------------------------- |
|
|
15
|
-
| _(not set)_ | Default workers are auto-created based on configuration
|
|
16
|
-
| `"false"` | Disables
|
|
17
|
-
| `"orchestration"` | Only the orchestration worker starts
|
|
18
|
-
| `"scheduler"` | Only the scheduler worker starts
|
|
19
|
-
| `"backgroundTasks"` | Only the background task worker starts
|
|
20
|
-
| `"orchestration,scheduler"` | Multiple workers (comma-separated)
|
|
13
|
+
| Value | Behavior |
|
|
14
|
+
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
15
|
+
| _(not set)_ | Default workers are auto-created based on configuration |
|
|
16
|
+
| `"false"` | Disables worker event processing. The process serves HTTP requests and can still publish events to PubSub (e.g., workflow starts) without consuming them. |
|
|
17
|
+
| `"orchestration"` | Only the orchestration worker starts |
|
|
18
|
+
| `"scheduler"` | Only the scheduler worker starts |
|
|
19
|
+
| `"backgroundTasks"` | Only the background task worker starts |
|
|
20
|
+
| `"orchestration,scheduler"` | Multiple workers (comma-separated) |
|
|
21
21
|
|
|
22
22
|
Use this to run different worker types in separate containers from the same build artifact.
|
|
23
23
|
|
|
@@ -29,6 +29,8 @@ The base URL of the API server, used by the orchestration worker to execute work
|
|
|
29
29
|
MASTRA_STEP_EXECUTION_URL=http://api:4111/api
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
Use HTTPS URLs in production. See [Security recommendations](https://mastra.ai/docs/server/auth/workers).
|
|
33
|
+
|
|
32
34
|
The orchestration worker sends step execution requests to:
|
|
33
35
|
|
|
34
36
|
```text
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Stores files in a Mastra Platform workspace bucket. Each Mastra Platform environment can have one bucket, and `PlatformFilesystem` gives agents `read`, `write`, `list`, `delete`, and `move` operations against it.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Related providers: [`S3Filesystem`](https://mastra.ai/reference/workspace/s3-filesystem) for direct S3 access, [`LocalFilesystem`](https://mastra.ai/reference/workspace/local-filesystem) for local directories.
|
|
8
8
|
|
|
9
9
|
> **Info:** For interface details, see [WorkspaceFilesystem interface](https://mastra.ai/reference/workspace/filesystem).
|
|
10
10
|
|
|
@@ -157,7 +157,8 @@ Filesystem-specific errors match the standard workspace error types:
|
|
|
157
157
|
Other Platform API failures raise `PlatformApiError`. Structured `{ error: { message, type } }` responses are parsed into `.code` (machine-readable kind) and `.proxyMessage` (human string):
|
|
158
158
|
|
|
159
159
|
```typescript
|
|
160
|
-
import { FileNotFoundError
|
|
160
|
+
import { FileNotFoundError } from '@mastra/core/workspace'
|
|
161
|
+
import { PlatformApiError } from '@mastra/platform-workspace'
|
|
161
162
|
|
|
162
163
|
try {
|
|
163
164
|
await fs.readFile('/missing.txt')
|
|
@@ -173,6 +174,8 @@ try {
|
|
|
173
174
|
}
|
|
174
175
|
```
|
|
175
176
|
|
|
177
|
+
`FileNotFoundError`, `FileExistsError`, and `WorkspaceReadOnlyError` are re-exports of the standard workspace error types from `@mastra/core/workspace`. `PlatformApiError` is specific to `@mastra/platform-workspace`.
|
|
178
|
+
|
|
176
179
|
`code` and `proxyMessage` are `undefined` when the response body isn't JSON, for example an HTML 502 from a load balancer.
|
|
177
180
|
|
|
178
181
|
## Related
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
# PlatformSandbox
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Client for provisioning sandboxes in a Mastra Platform environment. Each `PlatformSandbox` instance owns one remote sandbox: `start()` provisions it, `executeCommand()` runs against it, and `destroy()` tears it down. Construct additional instances to own additional remote sandboxes; use `clone()` to derive them from a configured template (see [Cloning](#cloning-for-a-fleet-of-sandboxes)).
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Sandboxes boot from a pre-built recipe checkpoint with Python 3, Node 22, TypeScript, tsx, and common build tooling already installed. Pass a stable `id` to opt into [checkpoint recovery](#checkpoint-recovery) so a new sandbox boots from the previous one's filesystem.
|
|
8
|
+
|
|
9
|
+
Related providers: [`RailwaySandbox`](https://mastra.ai/reference/workspace/railway-sandbox) for self-hosted Railway sandboxes, [`LocalSandbox`](https://mastra.ai/reference/workspace/local-sandbox) for local sandboxes.
|
|
8
10
|
|
|
9
11
|
> **Info:** For interface details, see [WorkspaceSandbox interface](https://mastra.ai/reference/workspace/sandbox).
|
|
10
12
|
|
|
@@ -103,7 +105,7 @@ The default `ISOLATED` mode allows outbound internet access only, with no privat
|
|
|
103
105
|
|
|
104
106
|
### Reattaching to a running sandbox
|
|
105
107
|
|
|
106
|
-
Pass an existing `sandboxId` to reattach to a live sandbox instead of creating a new one
|
|
108
|
+
Pass an existing `sandboxId` to reattach to a live sandbox instead of creating a new one:
|
|
107
109
|
|
|
108
110
|
```typescript
|
|
109
111
|
const sandbox = new PlatformSandbox({
|
|
@@ -116,6 +118,42 @@ const result = await sandbox.executeCommand('cat', ['/workspace/state.json'])
|
|
|
116
118
|
|
|
117
119
|
When `sandboxId` is set, `environmentId` isn't required because the sandbox already exists.
|
|
118
120
|
|
|
121
|
+
### Checkpoint recovery
|
|
122
|
+
|
|
123
|
+
The constructor `id` (explicit or auto-generated) is sent to the platform on `POST /sandbox` as an advisory recovery key:
|
|
124
|
+
|
|
125
|
+
- If the platform recognises the `id` from a previous session, the new sandbox boots from the most recent checkpoint of that earlier sandbox's filesystem instead of the base recipe.
|
|
126
|
+
- If the `id` isn't recognised, the platform falls through to a fresh sandbox from the base recipe. Auto-generated ids never match, so omitting `id` disables checkpoint recovery.
|
|
127
|
+
|
|
128
|
+
Pass a stable `id` to preserve a sandbox's filesystem across sessions or across a `destroy()`/`start()` cycle:
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
const sandbox = new PlatformSandbox({
|
|
132
|
+
id: `project-${projectId}`,
|
|
133
|
+
})
|
|
134
|
+
await sandbox.start() // Boots from the most recent checkpoint for this id, or fresh if unknown
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Checkpoint recovery is coarser than `sandboxId` reattachment. Reattaching (via `sandboxId`) rejoins the exact live sandbox and its running processes. Checkpoint recovery constructs a brand new sandbox and restores its filesystem from the latest checkpoint the platform captured for the previous sandbox with that `id`. Running processes and any filesystem writes made after the last checkpoint aren't restored.
|
|
138
|
+
|
|
139
|
+
Each `id` maps to one independent filesystem. Reusing the same `id` across unrelated sandboxes causes the platform to boot them from each other's checkpoint.
|
|
140
|
+
|
|
141
|
+
### Cloning for a fleet of sandboxes
|
|
142
|
+
|
|
143
|
+
`clone()` returns an independent sibling `PlatformSandbox` that inherits credentials and defaults (access token, project, environment, network isolation, timeout, instructions, env, idle timeout) with per-instance overrides. The returned sandbox is unstarted and provisions on its own `start()`, so `clone()` performs no I/O:
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
const template = new PlatformSandbox({
|
|
147
|
+
networkIsolation: 'PRIVATE',
|
|
148
|
+
idleTimeoutMinutes: 30,
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
const perProject = template.clone({ id: `project-${projectId}` })
|
|
152
|
+
await perProject.start()
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Combine `clone()` with a stable `id` per clone to opt each clone into [checkpoint recovery](#checkpoint-recovery) independently.
|
|
156
|
+
|
|
119
157
|
### Executing commands
|
|
120
158
|
|
|
121
159
|
`executeCommand` runs a command on the remote sandbox and returns its output. Pass `args` to have arguments safely shell-quoted:
|
|
@@ -153,7 +191,7 @@ console.log(result.exitCode)
|
|
|
153
191
|
|
|
154
192
|
**instructions** (`string | ((opts: { defaultInstructions: string; requestContext?: RequestContext }) => string)`): Custom instructions returned by getInstructions(). A string fully replaces the defaults; a function receives the defaults and can extend or customize them per-request.
|
|
155
193
|
|
|
156
|
-
**id** (`string`): Unique identifier for this sandbox instance. (Default: `Auto-generated`)
|
|
194
|
+
**id** (`string`): Unique identifier for this sandbox instance. Sent to the platform as an advisory recovery key: if the platform recognizes the id from a previous sandbox, the new sandbox boots from that sandbox's most recent checkpoint instead of the base recipe. Unknown ids fall through to a fresh sandbox. Auto-generated when omitted, which disables checkpoint recovery. (Default: `Auto-generated`)
|
|
157
195
|
|
|
158
196
|
**fetch** (`typeof fetch`): Custom fetch implementation, mainly for testing.
|
|
159
197
|
|
|
@@ -169,6 +207,22 @@ console.log(result.exitCode)
|
|
|
169
207
|
|
|
170
208
|
**processes** (`PlatformProcessManager`): Background process manager. See SandboxProcessManager reference.
|
|
171
209
|
|
|
210
|
+
## Methods
|
|
211
|
+
|
|
212
|
+
**start** (`() => Promise<void>`): Provision the remote sandbox, or reattach when sandboxId was passed to the constructor. Idempotent once the sandbox is running. A destroyed reattach target falls through to a fresh provision.
|
|
213
|
+
|
|
214
|
+
**destroy** (`() => Promise<void>`): Tear down the remote sandbox and clear the cached exec lease. A subsequent start() provisions a fresh sandbox (or restores from checkpoint when a stable id is set).
|
|
215
|
+
|
|
216
|
+
**stop** (`() => Promise<void>`): Alias for destroy().
|
|
217
|
+
|
|
218
|
+
**executeCommand** (`(command: string, args?: string[], options?: ExecuteCommandOptions) => Promise<CommandResult>`): Run a command on the remote sandbox and return its stdout, stderr, exitCode, and executionTimeMs. command is a shell string, args are safely shell-quoted.
|
|
219
|
+
|
|
220
|
+
**clone** (`(options?: SandboxCloneOptions) => PlatformSandbox`): Construct an unstarted sibling PlatformSandbox that inherits credentials and defaults with per-instance overrides (id, sandboxId, env, idleTimeoutMinutes). Performs no I/O. Use to build a fleet of independent sandboxes from one configured template.
|
|
221
|
+
|
|
222
|
+
**getInfo** (`() => Promise<SandboxInfo>`): Return the sandbox's platform id, provider, status, createdAt, and metadata (sandboxId, providerResourceId, platformStatus).
|
|
223
|
+
|
|
224
|
+
**getInstructions** (`(opts?: { requestContext?: RequestContext }) => string`): Return the sandbox instructions the workspace surfaces in tool descriptions. Honors the instructions constructor option; otherwise returns platform-default instructions that include the current remote sandbox id when running.
|
|
225
|
+
|
|
172
226
|
## Errors
|
|
173
227
|
|
|
174
228
|
Platform API failures raise `PlatformApiError`. Structured `{ error: { message, type } }` responses are parsed into `.code` (machine-readable kind) and `.proxyMessage` (human string); the raw response body stays available on `.body`:
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.2.13-alpha.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`db4e6ff`](https://github.com/mastra-ai/mastra/commit/db4e6ff744503112eb64deeaf6c2b54bf26a54c7), [`6d19a65`](https://github.com/mastra-ai/mastra/commit/6d19a6517f5da3911023d446b7e2d5dad8adb1cb)]:
|
|
8
|
+
- @mastra/core@1.56.0-alpha.5
|
|
9
|
+
|
|
10
|
+
## 1.2.13-alpha.7
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`4844167`](https://github.com/mastra-ai/mastra/commit/4844167cff2d5ec5004e94edd34970833040fa3f), [`5faf93f`](https://github.com/mastra-ai/mastra/commit/5faf93f03e19daea394b9e2a923f2e4f833407f2), [`80ad891`](https://github.com/mastra-ai/mastra/commit/80ad891f8cd10379aa5b5af7510c763783b2ab56), [`c78aa4e`](https://github.com/mastra-ai/mastra/commit/c78aa4ecc422ba70476da73709c3e7d85edc71d6), [`a1cb98d`](https://github.com/mastra-ai/mastra/commit/a1cb98d11990b560b98482292a1f34aa1a2d9092), [`598ad82`](https://github.com/mastra-ai/mastra/commit/598ad82d41c41389a686338a1d0e50b7400e1938), [`1fd6aad`](https://github.com/mastra-ai/mastra/commit/1fd6aad1ea4a9d32f65efa832307c35e981a4c0a)]:
|
|
15
|
+
- @mastra/core@1.56.0-alpha.4
|
|
16
|
+
- @mastra/mcp@1.15.1-alpha.0
|
|
17
|
+
|
|
3
18
|
## 1.2.13-alpha.5
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|