@mastra/mcp-docs-server 1.3.6-alpha.14 → 1.3.6-alpha.18
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/deployment/mastra-server.md +2 -2
- package/.docs/docs/harness/durable-agents.md +45 -9
- package/.docs/docs/sandbox/overview.md +1 -0
- package/.docs/docs/server/pubsub.md +2 -0
- package/.docs/docs/workflows/overview.md +2 -0
- package/.docs/integrations/sandboxes/blaxel.md +3 -1
- package/.docs/integrations/sandboxes/e2b.md +32 -1
- package/.docs/integrations/sandboxes/railway.md +13 -0
- package/.docs/integrations/sandboxes/sprites.md +219 -0
- package/.docs/integrations.md +1 -0
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/302ai.md +3 -1
- package/.docs/models/providers/cloudflare-workers-ai.md +1 -2
- package/.docs/models/providers/coralbricks.md +2 -2
- package/.docs/models/providers/edenai.md +305 -308
- package/.docs/models/providers/kilo.md +10 -10
- package/.docs/models/providers/moark.md +17 -9
- package/.docs/models/providers/nano-gpt.md +9 -9
- package/.docs/models/providers/nearai.md +22 -3
- package/.docs/reference/agents/durable-agent.md +40 -4
- package/.docs/reference/client-js/agent-controller.md +1 -1
- package/.docs/reference/client-js/agents.md +2 -2
- package/.docs/reference/client-js/datasets.md +19 -0
- package/.docs/reference/core/mastra-class.md +12 -4
- package/.docs/reference/pubsub/lease-provider.md +2 -0
- package/.docs/reference/pubsub/valkey-streams.md +1 -1
- package/.docs/reference/server/routes.md +1 -0
- package/.docs/reference/storage/retention.md +21 -18
- package/.docs/reference/workspace/platform-sandbox.md +15 -2
- package/package.json +4 -4
|
@@ -42,12 +42,12 @@ for await (const chunk of stream) {
|
|
|
42
42
|
| `kilo/~anthropic/claude-haiku-latest` | 1.0M | | | | | | $0.10 | $0.50 |
|
|
43
43
|
| `kilo/~anthropic/claude-opus-latest` | 1.0M | | | | | | $4 | $20 |
|
|
44
44
|
| `kilo/~anthropic/claude-sonnet-latest` | 1.0M | | | | | | $2 | $10 |
|
|
45
|
-
| `kilo/~deepseek/deepseek-flash-latest` | 1.0M | | | | | | $0.
|
|
46
|
-
| `kilo/~deepseek/deepseek-pro-latest` | 1.0M | | | | | | $0.
|
|
47
|
-
| `kilo/~deepseek/deepseek-v4-flash-latest` | 1.0M | | | | | | $0.
|
|
45
|
+
| `kilo/~deepseek/deepseek-flash-latest` | 1.0M | | | | | | $0.03 | $0.14 |
|
|
46
|
+
| `kilo/~deepseek/deepseek-pro-latest` | 1.0M | | | | | | $0.22 | $0.66 |
|
|
47
|
+
| `kilo/~deepseek/deepseek-v4-flash-latest` | 1.0M | | | | | | $0.02 | $0.64 |
|
|
48
48
|
| `kilo/~google/gemini-flash-latest` | 1.0M | | | | | | $0.75 | $4 |
|
|
49
49
|
| `kilo/~google/gemini-pro-latest` | 1.0M | | | | | | $2 | $12 |
|
|
50
|
-
| `kilo/~moonshotai/kimi-latest` | 1.0M | | | | | | $0.
|
|
50
|
+
| `kilo/~moonshotai/kimi-latest` | 1.0M | | | | | | $0.75 | $15 |
|
|
51
51
|
| `kilo/~openai/gpt-astra-latest` | 1.1M | | | | | | $10 | $50 |
|
|
52
52
|
| `kilo/~openai/gpt-luna-latest` | 1.1M | | | | | | $0.10 | $0.50 |
|
|
53
53
|
| `kilo/~openai/gpt-mini-latest` | 400K | | | | | | $0.75 | $5 |
|
|
@@ -55,7 +55,7 @@ for await (const chunk of stream) {
|
|
|
55
55
|
| `kilo/~openai/gpt-terra-latest` | 1.1M | | | | | | $2 | $12 |
|
|
56
56
|
| `kilo/~x-ai/grok-latest` | 500K | | | | | | $2 | $6 |
|
|
57
57
|
| `kilo/~z-ai/glm-flash-latest` | 1.0M | | | | | | $0.04 | $0.50 |
|
|
58
|
-
| `kilo/~z-ai/glm-latest` | 1.0M | | | | | | $0.
|
|
58
|
+
| `kilo/~z-ai/glm-latest` | 1.0M | | | | | | $0.07 | $5 |
|
|
59
59
|
| `kilo/aion-labs/aion-2.0` | 131K | | | | | | $0.80 | $2 |
|
|
60
60
|
| `kilo/aion-labs/aion-3.0` | 131K | | | | | | $3 | $6 |
|
|
61
61
|
| `kilo/aion-labs/aion-3.0-mini` | 131K | | | | | | $0.70 | $1 |
|
|
@@ -107,7 +107,7 @@ for await (const chunk of stream) {
|
|
|
107
107
|
| `kilo/deepseek/deepseek-v3.1-terminus` | 164K | | | | | | $0.27 | $1 |
|
|
108
108
|
| `kilo/deepseek/deepseek-v3.2` | 164K | | | | | | $0.26 | $0.80 |
|
|
109
109
|
| `kilo/deepseek/deepseek-v3.2-exp` | 164K | | | | | | $0.27 | $0.41 |
|
|
110
|
-
| `kilo/deepseek/deepseek-v4-flash` | 1.0M | | | | | | $0.
|
|
110
|
+
| `kilo/deepseek/deepseek-v4-flash` | 1.0M | | | | | | $0.03 | $1 |
|
|
111
111
|
| `kilo/deepseek/deepseek-v4-flash-0731` | 1.0M | | | | | | $0.44 | $1 |
|
|
112
112
|
| `kilo/deepseek/deepseek-v4-flash-vision-exp` | 1.0M | | | | | | $0.22 | $0.65 |
|
|
113
113
|
| `kilo/deepseek/deepseek-v4-pro` | 1.0M | | | | | | $2 | $3 |
|
|
@@ -212,7 +212,7 @@ for await (const chunk of stream) {
|
|
|
212
212
|
| `kilo/moonshotai/kimi-k2-0905` | 262K | | | | | | $0.60 | $3 |
|
|
213
213
|
| `kilo/moonshotai/kimi-k2-thinking` | 262K | | | | | | $0.60 | $3 |
|
|
214
214
|
| `kilo/moonshotai/kimi-k2.5` | 262K | | | | | | $0.60 | $3 |
|
|
215
|
-
| `kilo/moonshotai/kimi-k2.6` | 262K | | | | | | $0.
|
|
215
|
+
| `kilo/moonshotai/kimi-k2.6` | 262K | | | | | | $0.65 | $3 |
|
|
216
216
|
| `kilo/moonshotai/kimi-k2.7-code` | 262K | | | | | | $0.67 | $3 |
|
|
217
217
|
| `kilo/moonshotai/kimi-k3` | 1.0M | | | | | | $3 | $15 |
|
|
218
218
|
| `kilo/morph/morph-v3-fast` | 82K | | | | | | $0.80 | $1 |
|
|
@@ -226,7 +226,7 @@ for await (const chunk of stream) {
|
|
|
226
226
|
| `kilo/nvidia/nemotron-3-nano-omni-30b-a3b-reasoning:free` | 256K | | | | | | — | — |
|
|
227
227
|
| `kilo/nvidia/nemotron-3-super-120b-a12b` | 262K | | | | | | $0.08 | $0.45 |
|
|
228
228
|
| `kilo/nvidia/nemotron-3-super-120b-a12b:free` | 262K | | | | | | — | — |
|
|
229
|
-
| `kilo/nvidia/nemotron-3-ultra-550b-a55b` |
|
|
229
|
+
| `kilo/nvidia/nemotron-3-ultra-550b-a55b` | 203K | | | | | | $0.50 | $2 |
|
|
230
230
|
| `kilo/nvidia/nemotron-3-ultra-550b-a55b:free` | 1.0M | | | | | | — | — |
|
|
231
231
|
| `kilo/nvidia/nemotron-3.5-content-safety` | 131K | | | | | | $0.20 | $0.20 |
|
|
232
232
|
| `kilo/nvidia/nemotron-3.5-content-safety:free` | 128K | | | | | | — | — |
|
|
@@ -343,14 +343,14 @@ for await (const chunk of stream) {
|
|
|
343
343
|
| `kilo/qwen/qwen3.5-plus-02-15` | 1.0M | | | | | | $0.26 | $2 |
|
|
344
344
|
| `kilo/qwen/qwen3.5-plus-20260420` | 1.0M | | | | | | $0.30 | $2 |
|
|
345
345
|
| `kilo/qwen/qwen3.6-27b` | 262K | | | | | | $0.45 | $3 |
|
|
346
|
-
| `kilo/qwen/qwen3.6-35b-a3b` | 262K | | | | | | $0.
|
|
346
|
+
| `kilo/qwen/qwen3.6-35b-a3b` | 262K | | | | | | $0.10 | $0.95 |
|
|
347
347
|
| `kilo/qwen/qwen3.6-flash` | 1.0M | | | | | | $0.19 | $1 |
|
|
348
348
|
| `kilo/qwen/qwen3.6-plus` | 1.0M | | | | | | $0.33 | $2 |
|
|
349
349
|
| `kilo/qwen/qwen3.7-flash` | 1.0M | | | | | | $0.03 | $0.13 |
|
|
350
350
|
| `kilo/qwen/qwen3.7-max` | 1.0M | | | | | | $1 | $4 |
|
|
351
351
|
| `kilo/qwen/qwen3.7-plus` | 1.0M | | | | | | $0.32 | $1 |
|
|
352
352
|
| `kilo/qwen/qwen3.8-2.4t-a95b` | 1.0M | | | | | | $2 | $6 |
|
|
353
|
-
| `kilo/qwen/qwen3.8-27b` |
|
|
353
|
+
| `kilo/qwen/qwen3.8-27b` | 262K | | | | | | $0.42 | $3 |
|
|
354
354
|
| `kilo/qwen/qwen3.8-flash` | 1.0M | | | | | | $0.15 | $0.47 |
|
|
355
355
|
| `kilo/qwen/qwen3.8-max-0902` | 1.0M | | | | | | $2 | $6 |
|
|
356
356
|
| `kilo/qwen/qwen3.8-max-prime` | 1.0M | | | | | | $4 | $12 |
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Moark
|
|
6
6
|
|
|
7
|
-
Access
|
|
7
|
+
Access 10 Moark models through Mastra's model router. Authentication is handled automatically using the `MOARK_API_KEY` environment variable.
|
|
8
8
|
|
|
9
9
|
Learn more in the [Moark documentation](https://moark.com).
|
|
10
10
|
|
|
@@ -19,7 +19,7 @@ const agent = new Agent({
|
|
|
19
19
|
id: "my-agent",
|
|
20
20
|
name: "My Agent",
|
|
21
21
|
instructions: "You are a helpful assistant",
|
|
22
|
-
model: "moark/
|
|
22
|
+
model: "moark/DeepSeek-V4-Flash"
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
// Generate a response
|
|
@@ -36,10 +36,18 @@ for await (const chunk of stream) {
|
|
|
36
36
|
|
|
37
37
|
## Models
|
|
38
38
|
|
|
39
|
-
| Model
|
|
40
|
-
|
|
|
41
|
-
| `moark/
|
|
42
|
-
| `moark/
|
|
39
|
+
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
40
|
+
| ------------------------------ | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
41
|
+
| `moark/DeepSeek-V4-Flash` | 1.0M | | | | | | $0.50 | $0.50 |
|
|
42
|
+
| `moark/deepseek-v4-flash-0731` | 1.0M | | | | | | $0.15 | $0.30 |
|
|
43
|
+
| `moark/DeepSeek-V4-Pro` | 1.0M | | | | | | $2 | $4 |
|
|
44
|
+
| `moark/GLM-4.7` | 205K | | | | | | $0.42 | $2 |
|
|
45
|
+
| `moark/GLM-5.3` | 1.0M | | | | | | $1 | $4 |
|
|
46
|
+
| `moark/Kimi-K2.6` | 262K | | | | | | $0.98 | $4 |
|
|
47
|
+
| `moark/kimi-k3` | 1.0M | | | | | | $3 | $15 |
|
|
48
|
+
| `moark/MiniMax-M2.1` | 205K | | | | | | $0.29 | $1 |
|
|
49
|
+
| `moark/MiniMax-M2.7` | 205K | | | | | | $0.29 | $1 |
|
|
50
|
+
| `moark/Qwen3.6-Flash` | 1.0M | | | | | | $0.18 | $1 |
|
|
43
51
|
|
|
44
52
|
Model availability, capabilities, context windows, and pricing are sourced from [models.dev](https://models.dev) and may change.
|
|
45
53
|
|
|
@@ -53,7 +61,7 @@ const agent = new Agent({
|
|
|
53
61
|
name: "custom-agent",
|
|
54
62
|
model: {
|
|
55
63
|
url: "https://moark.com/v1",
|
|
56
|
-
id: "moark/
|
|
64
|
+
id: "moark/DeepSeek-V4-Flash",
|
|
57
65
|
apiKey: process.env.MOARK_API_KEY,
|
|
58
66
|
headers: {
|
|
59
67
|
"X-Custom-Header": "value"
|
|
@@ -71,8 +79,8 @@ const agent = new Agent({
|
|
|
71
79
|
model: ({ requestContext }) => {
|
|
72
80
|
const useAdvanced = requestContext.task === "complex";
|
|
73
81
|
return useAdvanced
|
|
74
|
-
? "moark/
|
|
75
|
-
: "moark/
|
|
82
|
+
? "moark/kimi-k3"
|
|
83
|
+
: "moark/DeepSeek-V4-Flash";
|
|
76
84
|
}
|
|
77
85
|
});
|
|
78
86
|
```
|
|
@@ -109,9 +109,9 @@ for await (const chunk of stream) {
|
|
|
109
109
|
| `nano-gpt/bytedance/doubao-seed-2.1-turbo` | 256K | | | | | | $0.50 | $3 |
|
|
110
110
|
| `nano-gpt/bytedance/doubao-seed-character` | 128K | | | | | | $0.12 | $0.29 |
|
|
111
111
|
| `nano-gpt/celeris-1` | 8K | | | | | | $2 | $6 |
|
|
112
|
-
| `nano-gpt/claw-high` | 1.0M | | | | | | $0.60 | $
|
|
113
|
-
| `nano-gpt/claw-low` | 1.0M | | | | | | $0.60 | $
|
|
114
|
-
| `nano-gpt/claw-medium` | 1.0M | | | | | | $0.60 | $
|
|
112
|
+
| `nano-gpt/claw-high` | 1.0M | | | | | | $0.60 | $1 |
|
|
113
|
+
| `nano-gpt/claw-low` | 1.0M | | | | | | $0.60 | $1 |
|
|
114
|
+
| `nano-gpt/claw-medium` | 1.0M | | | | | | $0.60 | $1 |
|
|
115
115
|
| `nano-gpt/cohere/command-r-plus-08-2024` | 128K | | | | | | $3 | $14 |
|
|
116
116
|
| `nano-gpt/command-a-reasoning-08-2025` | 256K | | | | | | $3 | $10 |
|
|
117
117
|
| `nano-gpt/deepcogito/cogito-v1-preview-qwen-32B` | 128K | | | | | | $2 | $2 |
|
|
@@ -248,9 +248,9 @@ for await (const chunk of stream) {
|
|
|
248
248
|
| `nano-gpt/google/gemma4-31b-splituntied` | 262K | | | | | | $0.10 | $0.30 |
|
|
249
249
|
| `nano-gpt/Gryphe/MythoMax-L2-13b` | 4K | | | | | | $0.10 | $0.10 |
|
|
250
250
|
| `nano-gpt/heabsy/cyberheabsy` | 1.0M | | | | | | $2 | $5 |
|
|
251
|
-
| `nano-gpt/hermes-high` | 1.0M | | | | | | $0.60 | $
|
|
252
|
-
| `nano-gpt/hermes-low` | 1.0M | | | | | | $0.60 | $
|
|
253
|
-
| `nano-gpt/hermes-medium` | 1.0M | | | | | | $0.60 | $
|
|
251
|
+
| `nano-gpt/hermes-high` | 1.0M | | | | | | $0.60 | $1 |
|
|
252
|
+
| `nano-gpt/hermes-low` | 1.0M | | | | | | $0.60 | $1 |
|
|
253
|
+
| `nano-gpt/hermes-medium` | 1.0M | | | | | | $0.60 | $1 |
|
|
254
254
|
| `nano-gpt/holo3-35b-a3b` | 66K | | | | | | $0.25 | $2 |
|
|
255
255
|
| `nano-gpt/holo3-35b-a3b:thinking` | 66K | | | | | | $0.25 | $2 |
|
|
256
256
|
| `nano-gpt/huihui-ai/DeepSeek-R1-Distill-Llama-70B-abliterated` | 16K | | | | | | $0.70 | $0.70 |
|
|
@@ -638,17 +638,17 @@ for await (const chunk of stream) {
|
|
|
638
638
|
| `nano-gpt/z-ai/glm-5.1:thinking` | 200K | | | | | | $0.75 | $3 |
|
|
639
639
|
| `nano-gpt/z-ai/glm-5.2` | 1.0M | | | | | | $0.42 | $1 |
|
|
640
640
|
| `nano-gpt/z-ai/glm-5.2:thinking` | 1.0M | | | | | | $0.42 | $1 |
|
|
641
|
-
| `nano-gpt/z-ai/glm-5.3` | 1.0M | | | | | | $0.60 | $
|
|
641
|
+
| `nano-gpt/z-ai/glm-5.3` | 1.0M | | | | | | $0.60 | $1 |
|
|
642
642
|
| `nano-gpt/z-ai/glm-5.3-flash` | 1.0M | | | | | | $0.10 | $0.30 |
|
|
643
643
|
| `nano-gpt/z-ai/glm-5.3-flash-apex` | 1.0M | | | | | | $0.15 | $0.50 |
|
|
644
644
|
| `nano-gpt/z-ai/glm-5.3-flash-apex-abliterated` | 1.0M | | | | | | $0.15 | $0.50 |
|
|
645
645
|
| `nano-gpt/z-ai/glm-5.3-flash-cybersecurity` | 1.0M | | | | | | $0.15 | $0.50 |
|
|
646
646
|
| `nano-gpt/z-ai/glm-5.3-flash-uncensored` | 1.0M | | | | | | $0.20 | $0.80 |
|
|
647
647
|
| `nano-gpt/z-ai/glm-5.3-uncensored` | 1.0M | | | | | | $1 | $2 |
|
|
648
|
-
| `nano-gpt/z-ai/glm-5.3:thinking` | 1.0M | | | | | | $0.60 | $
|
|
648
|
+
| `nano-gpt/z-ai/glm-5.3:thinking` | 1.0M | | | | | | $0.60 | $1 |
|
|
649
649
|
| `nano-gpt/z-ai/glm-5v-turbo` | 203K | | | | | | $1 | $4 |
|
|
650
650
|
| `nano-gpt/z-ai/glm-5v-turbo:thinking` | 203K | | | | | | $1 | $4 |
|
|
651
|
-
| `nano-gpt/z-ai/glm-latest` | 1.0M | | | | | | $0.60 | $
|
|
651
|
+
| `nano-gpt/z-ai/glm-latest` | 1.0M | | | | | | $0.60 | $1 |
|
|
652
652
|
|
|
653
653
|
Model availability, capabilities, context windows, and pricing are sourced from [models.dev](https://models.dev) and may change.
|
|
654
654
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# NEAR AI Cloud
|
|
6
6
|
|
|
7
|
-
Access
|
|
7
|
+
Access 51 NEAR AI Cloud models through Mastra's model router. Authentication is handled automatically using the `NEARAI_API_KEY` environment variable.
|
|
8
8
|
|
|
9
9
|
Learn more in the [NEAR AI Cloud documentation](https://docs.near.ai/).
|
|
10
10
|
|
|
@@ -38,17 +38,26 @@ for await (const chunk of stream) {
|
|
|
38
38
|
|
|
39
39
|
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
40
40
|
| ------------------------------------------ | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
41
|
+
| `nearai/anthropic/claude-fable-5` | 1.0M | | | | | | $10 | $50 |
|
|
42
|
+
| `nearai/anthropic/claude-fable-5-1` | 1.0M | | | | | | $10 | $50 |
|
|
41
43
|
| `nearai/anthropic/claude-haiku-4-5` | 200K | | | | | | $1 | $5 |
|
|
42
44
|
| `nearai/anthropic/claude-opus-4-6` | 200K | | | | | | $5 | $25 |
|
|
43
45
|
| `nearai/anthropic/claude-opus-4-7` | 1.0M | | | | | | $5 | $25 |
|
|
46
|
+
| `nearai/anthropic/claude-opus-4-8` | 1.0M | | | | | | $5 | $25 |
|
|
47
|
+
| `nearai/anthropic/claude-opus-5` | 1.0M | | | | | | $5 | $25 |
|
|
44
48
|
| `nearai/anthropic/claude-sonnet-4-5` | 200K | | | | | | $3 | $15 |
|
|
45
49
|
| `nearai/anthropic/claude-sonnet-4-6` | 1.0M | | | | | | $3 | $15 |
|
|
50
|
+
| `nearai/anthropic/claude-sonnet-5` | 1.0M | | | | | | $2 | $10 |
|
|
46
51
|
| `nearai/black-forest-labs/FLUX.2-klein-4B` | 128K | | | | | | $1 | $1 |
|
|
52
|
+
| `nearai/deepseek/deepseek-v3.2` | 128K | | | | | | $1 | $1 |
|
|
47
53
|
| `nearai/google/gemini-2.5-flash` | 1.0M | | | | | | $0.30 | $3 |
|
|
48
54
|
| `nearai/google/gemini-2.5-flash-lite` | 1.0M | | | | | | $0.10 | $0.40 |
|
|
49
55
|
| `nearai/google/gemini-2.5-pro` | 1.0M | | | | | | $1 | $10 |
|
|
50
56
|
| `nearai/google/gemini-3.1-flash-lite` | 1.0M | | | | | | $0.25 | $2 |
|
|
51
57
|
| `nearai/google/gemini-3.5-flash` | 1.0M | | | | | | $2 | $9 |
|
|
58
|
+
| `nearai/google/gemini-3.8-flash` | 1.0M | | | | | | $0.75 | $4 |
|
|
59
|
+
| `nearai/moonshotai/kimi-k2.6` | 262K | | | | | | $0.81 | $4 |
|
|
60
|
+
| `nearai/moonshotai/kimi-k3` | 1.0M | | | | | | $3 | $17 |
|
|
52
61
|
| `nearai/openai/gpt-4.1` | 1.0M | | | | | | $2 | $8 |
|
|
53
62
|
| `nearai/openai/gpt-4.1-mini` | 1.0M | | | | | | $0.40 | $2 |
|
|
54
63
|
| `nearai/openai/gpt-4.1-nano` | 1.0M | | | | | | $0.10 | $0.40 |
|
|
@@ -61,6 +70,12 @@ for await (const chunk of stream) {
|
|
|
61
70
|
| `nearai/openai/gpt-5.4-mini` | 400K | | | | | | $0.75 | $5 |
|
|
62
71
|
| `nearai/openai/gpt-5.4-nano` | 400K | | | | | | $0.20 | $1 |
|
|
63
72
|
| `nearai/openai/gpt-5.5` | 1.1M | | | | | | $5 | $30 |
|
|
73
|
+
| `nearai/openai/gpt-5.6-luna` | 1.1M | | | | | | $0.20 | $1 |
|
|
74
|
+
| `nearai/openai/gpt-5.6-sol` | 1.1M | | | | | | $4 | $20 |
|
|
75
|
+
| `nearai/openai/gpt-6-astra` | 1.1M | | | | | | $10 | $50 |
|
|
76
|
+
| `nearai/openai/gpt-6-luna` | 1.1M | | | | | | $0.10 | $0.50 |
|
|
77
|
+
| `nearai/openai/gpt-6-sol` | 1.1M | | | | | | $2 | $10 |
|
|
78
|
+
| `nearai/openai/gpt-6.1-sol` | 1.1M | | | | | | $2 | $10 |
|
|
64
79
|
| `nearai/openai/o3` | 200K | | | | | | $2 | $8 |
|
|
65
80
|
| `nearai/openai/o3-mini` | 200K | | | | | | $1 | $4 |
|
|
66
81
|
| `nearai/openai/o4-mini` | 200K | | | | | | $1 | $4 |
|
|
@@ -68,8 +83,12 @@ for await (const chunk of stream) {
|
|
|
68
83
|
| `nearai/Qwen/Qwen3-Embedding-0.6B` | 33K | | | | | | $0.01 | $0.01 |
|
|
69
84
|
| `nearai/Qwen/Qwen3-Reranker-0.6B` | 41K | | | | | | $0.01 | $0.01 |
|
|
70
85
|
| `nearai/Qwen/Qwen3-VL-30B-A3B-Instruct` | 16K | | | | | | $0.15 | $0.55 |
|
|
86
|
+
| `nearai/qwen/qwen3.5-397b-a17b` | 262K | | | | | | $0.50 | $3 |
|
|
71
87
|
| `nearai/Qwen/Qwen3.6-35B-A3B-FP8` | 262K | | | | | | $0.17 | $1 |
|
|
72
|
-
| `nearai/
|
|
88
|
+
| `nearai/qwen/qwen3.7-max` | 1.0M | | | | | | $3 | $8 |
|
|
89
|
+
| `nearai/Qwen/Qwen3.8-27B` | 262K | | | | | | $0.04 | $1 |
|
|
90
|
+
| `nearai/x-ai/grok-4.6` | 500K | | | | | | $2 | $6 |
|
|
91
|
+
| `nearai/z-ai/glm-5.3-flash` | 1.0M | | | | | | $0.15 | $0.50 |
|
|
73
92
|
|
|
74
93
|
Model availability, capabilities, context windows, and pricing are sourced from [models.dev](https://models.dev) and may change.
|
|
75
94
|
|
|
@@ -101,7 +120,7 @@ const agent = new Agent({
|
|
|
101
120
|
model: ({ requestContext }) => {
|
|
102
121
|
const useAdvanced = requestContext.task === "complex";
|
|
103
122
|
return useAdvanced
|
|
104
|
-
? "nearai/
|
|
123
|
+
? "nearai/z-ai/glm-5.3-flash"
|
|
105
124
|
: "nearai/Qwen/Qwen3-Embedding-0.6B";
|
|
106
125
|
}
|
|
107
126
|
});
|
|
@@ -164,7 +164,7 @@ Returns: [`Promise<DurableAgentStreamResult>`](#durableagentstreamresult)
|
|
|
164
164
|
|
|
165
165
|
#### `resume(runId, resumeData, options?)`
|
|
166
166
|
|
|
167
|
-
Resumes a suspended run, for example after a tool approval. Pass the `runId` from the original stream and the data the run was waiting on. Throws if no registry entry exists for the run.
|
|
167
|
+
Resumes a suspended run, for example after a tool approval. Pass the `runId` from the original stream and the data the run was waiting on. Throws if no registry entry exists for the run. If another execution holds the run, `resume()` waits up to 5 seconds for it to finish, then throws `DURABLE_AGENT_EXECUTION_CONFLICT`. See [run ownership](https://mastra.ai/docs/harness/durable-agents).
|
|
168
168
|
|
|
169
169
|
```typescript
|
|
170
170
|
const { output, cleanup } = await durableAgent.resume(runId, {
|
|
@@ -324,11 +324,18 @@ interface DurableAgentListActiveRunsResult {
|
|
|
324
324
|
|
|
325
325
|
#### `recoverActiveRuns(options?)`
|
|
326
326
|
|
|
327
|
-
Discovers runs stuck in `running` status for this agent and re-drives them from the last persisted snapshot. Accepts the same filters and pagination as `listActiveRuns()`, plus `runId`. Returns
|
|
327
|
+
Discovers runs stuck in `running` status for this agent and re-drives them from the last persisted snapshot. Accepts the same filters and pagination as `listActiveRuns()`, plus `runId`. Returns the outcome for each run.
|
|
328
328
|
|
|
329
329
|
```typescript
|
|
330
330
|
const result = await durableAgent.recoverActiveRuns()
|
|
331
|
-
// {
|
|
331
|
+
// {
|
|
332
|
+
// recovered: [
|
|
333
|
+
// { runId: 'run-1', status: 'success' },
|
|
334
|
+
// { runId: 'run-2', status: 'skipped', reason: 'run-active', retryAt: 1760123456789 },
|
|
335
|
+
// ],
|
|
336
|
+
// succeeded: 1,
|
|
337
|
+
// failed: 0,
|
|
338
|
+
// }
|
|
332
339
|
```
|
|
333
340
|
|
|
334
341
|
Pass a `runId` to recover a single known run:
|
|
@@ -337,11 +344,26 @@ Pass a `runId` to recover a single known run:
|
|
|
337
344
|
await durableAgent.recoverActiveRuns({ runId: 'run-abc-123' })
|
|
338
345
|
```
|
|
339
346
|
|
|
347
|
+
A run that another execution still drives isn't taken over. Its entry has `status: 'skipped'` and a `reason`, and `recoverActiveRuns()` doesn't check it again. For a run held by another process, `retryAt` is the time after which that claim lapses unless renewed. Call `recoverActiveRuns({ runId })` after it to recover the run if its process crashed. [`mastra.recoverAllDurableAgents()`](https://mastra.ai/reference/core/mastra-class) schedules these re-checks itself.
|
|
348
|
+
|
|
349
|
+
| `reason` | Meaning |
|
|
350
|
+
| --------------------- | ------------------------------------------------------------------------------ |
|
|
351
|
+
| `run-active` | Another execution, possibly in another process, holds the run. Sets `retryAt`. |
|
|
352
|
+
| `run-active-locally` | This process is executing the run. |
|
|
353
|
+
| `already-in-progress` | This process is already recovering the run. |
|
|
354
|
+
|
|
340
355
|
Returns:
|
|
341
356
|
|
|
342
357
|
```typescript
|
|
343
358
|
interface DurableAgentRecoverActiveRunsResult {
|
|
344
|
-
recovered: Array<{
|
|
359
|
+
recovered: Array<{
|
|
360
|
+
runId: string
|
|
361
|
+
status: 'success' | 'failed' | 'skipped'
|
|
362
|
+
error?: Error
|
|
363
|
+
reason?: 'run-active' | 'run-active-locally' | 'already-in-progress'
|
|
364
|
+
// Epoch milliseconds
|
|
365
|
+
retryAt?: number
|
|
366
|
+
}>
|
|
345
367
|
succeeded: number
|
|
346
368
|
failed: number
|
|
347
369
|
}
|
|
@@ -363,6 +385,20 @@ await output.text
|
|
|
363
385
|
cleanup()
|
|
364
386
|
```
|
|
365
387
|
|
|
388
|
+
`recover()` throws instead of recovering a run that isn't orphaned:
|
|
389
|
+
|
|
390
|
+
| Error ID | Thrown when |
|
|
391
|
+
| ------------------------------------------- | -------------------------------------------------------------------- |
|
|
392
|
+
| `DURABLE_AGENT_RUN_ACTIVE` | Another execution holds the run, and `force` isn't set. |
|
|
393
|
+
| `DURABLE_AGENT_RECOVER_RUN_ACTIVE_LOCALLY` | This process is executing the run. `force` doesn't override this. |
|
|
394
|
+
| `DURABLE_AGENT_RECOVER_ALREADY_IN_PROGRESS` | This process is already recovering the run. |
|
|
395
|
+
| `DURABLE_AGENT_RECOVER_RUN_SUSPENDED` | The run is suspended. Continue it with `resume()`. |
|
|
396
|
+
| `DURABLE_AGENT_EXECUTION_CONFLICT` | With `force`, another execution claimed the run during the takeover. |
|
|
397
|
+
|
|
398
|
+
The server's `POST /agents/:agentId/recover` route returns these errors as `409 Conflict`.
|
|
399
|
+
|
|
400
|
+
**options.force** (`boolean`): Take the run over even while another execution holds it. That execution loses the run and stops, and streams for the run drop the events it still publishes. Its writes are rejected when the storage adapter supports run fencing. (Default: `false`)
|
|
401
|
+
|
|
366
402
|
Returns: [`Promise<DurableAgentStreamResult>`](#durableagentstreamresult)
|
|
367
403
|
|
|
368
404
|
## Stream options
|
|
@@ -109,7 +109,7 @@ Subscribes to the session's event stream over SSE. The promise resolves once the
|
|
|
109
109
|
|
|
110
110
|
**onReconnect** (`() => void`): Called each time the stream is re-established after a drop. The server does not replay events missed while disconnected, so re-sync from here with session.state() and, for the message gap, session.listMessages().
|
|
111
111
|
|
|
112
|
-
**reconnect** (`boolean | { maxRetries?: number; delayMs?: number; maxDelayMs?: number }`): Re-establishes the stream after an established stream drops. Retries back off exponentially from delayMs (default 1000) up to maxDelayMs (default 30000). maxRetries (default Infinity) bounds the attempts per outage and resets once a connection is re-established. When retries are exhausted, onError fires.
|
|
112
|
+
**reconnect** (`boolean | { maxRetries?: number; delayMs?: number; maxDelayMs?: number }`): Re-establishes the stream after an established stream drops. Retries back off exponentially from delayMs (default 1000) up to maxDelayMs (default 30000). maxRetries (default Infinity) bounds the attempts per outage and resets once a connection is re-established. When retries are exhausted, onError fires. A reconnect request that fails with a 4xx (other than 408 and 429) or 501 stops reconnecting immediately and passes that MastraClientError to onError.
|
|
113
113
|
|
|
114
114
|
Returns: `Promise<AgentControllerSubscription>`, an object with an `unsubscribe()` method that stops reading and releases the stream.
|
|
115
115
|
|
|
@@ -304,13 +304,13 @@ await subscription.processDataStream({
|
|
|
304
304
|
|
|
305
305
|
Pass `withInitialHistory: true` (or `{ perPage }`) to receive the stored messages as a first `thread-history` chunk instead of fetching history separately. Finished runs aren't replayed after it, so completed answers don't stream again on reconnect.
|
|
306
306
|
|
|
307
|
-
`subscribeToThread()` returns the underlying `Response` plus a `processDataStream()` helper. The helper reads the subscription stream until the connection closes or the request is aborted. Pass `reconnect: true` to resubscribe when the transport closes or a reconnect request fails, such as after a proxy idle timeout.
|
|
307
|
+
`subscribeToThread()` returns the underlying `Response` plus a `processDataStream()` helper. The helper reads the subscription stream until the connection closes or the request is aborted. Pass `reconnect: true` to resubscribe when the transport closes or a reconnect request fails, such as after a proxy idle timeout. If a reconnect request fails with a 4xx status (for example `401` or `403`) or `501`, `processDataStream()` stops reconnecting and rejects with the original `MastraClientError`. `408` and `429` are still retried.
|
|
308
308
|
|
|
309
309
|
**resourceId** (`string`): Resource ID for the memory thread.
|
|
310
310
|
|
|
311
311
|
**threadId** (`string`): Thread ID to subscribe to.
|
|
312
312
|
|
|
313
|
-
**processDataStream().reconnect** (`boolean | { maxRetries?: number; delayMs?: number }`): Reconnects the subscription stream after it closes or a reconnect request fails. true retries indefinitely with a one-second delay.
|
|
313
|
+
**processDataStream().reconnect** (`boolean | { maxRetries?: number; delayMs?: number }`): Reconnects the subscription stream after it closes or a reconnect request fails. true retries indefinitely with a one-second delay. A 4xx (other than 408 and 429) or 501 response stops reconnecting and rejects with that error.
|
|
314
314
|
|
|
315
315
|
The subscription also exposes `abort(options?)` and `unsubscribe()`. `await subscription.abort({ clearPendingSignals: true })` requests an abort and clears pending signals without closing the subscription. Omit the flag to preserve pending input. `unsubscribe()` closes the subscription without aborting the run.
|
|
316
316
|
|
|
@@ -159,6 +159,25 @@ await client.deleteDatasetExperiment('dataset-id', 'experiment-id', {
|
|
|
159
159
|
|
|
160
160
|
Returns `Promise<{ success: boolean }>`. A missing experiment, an experiment associated with another dataset, or a dataset outside the supplied tenancy returns a `404` response.
|
|
161
161
|
|
|
162
|
+
## getExperiment()
|
|
163
|
+
|
|
164
|
+
Gets an experiment by ID without requiring a dataset reference. The response includes the experiment's `datasetId`, which is `null` for experiments orphaned by dataset deletion.
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
const experiment = await client.getExperiment('experiment-id', {
|
|
168
|
+
organizationId: 'organization-id',
|
|
169
|
+
projectId: 'project-id',
|
|
170
|
+
})
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**experimentId** (`string`): ID of the experiment to get.
|
|
174
|
+
|
|
175
|
+
**options.organizationId** (`string`): Organization ID used to scope the lookup.
|
|
176
|
+
|
|
177
|
+
**options.projectId** (`string`): Project ID used to scope the lookup.
|
|
178
|
+
|
|
179
|
+
Returns the experiment. A missing experiment, or one outside the supplied tenancy, returns a `404` response.
|
|
180
|
+
|
|
162
181
|
## deleteExperiment()
|
|
163
182
|
|
|
164
183
|
Deletes an experiment by ID without requiring a dataset reference. Use this method for experiments orphaned by dataset deletion. The server deletes the experiment's observability traces and then deletes the experiment and its result records. Unsupported storage leaves the traces in place, and the server logs a warning. If trace deletion fails for any other reason, the promise rejects and Mastra keeps the experiment and its result records, although some traces may already have been removed.
|
|
@@ -131,10 +131,14 @@ Visit the [Configuration reference](https://mastra.ai/reference/configuration) f
|
|
|
131
131
|
|
|
132
132
|
**scheduler.enabled** (`boolean`): Explicitly enable or disable the scheduler.
|
|
133
133
|
|
|
134
|
-
**recovery** (`MastraRecoveryConfig`): Boot-time recovery behavior for orphaned agent and workflow runs. See Crash recovery. (Default: `{ durableAgents: 'off' }`)
|
|
134
|
+
**recovery** (`MastraRecoveryConfig`): Boot-time recovery behavior for orphaned agent and workflow runs. See Crash recovery. (Default: `{ durableAgents: 'off', workflows: 'auto', workflowConcurrency: 5 }`)
|
|
135
135
|
|
|
136
136
|
**recovery.durableAgents** (`'auto' | 'off'`): Set to 'auto' to automatically re-drive orphaned RUNNING durable agent runs on server boot. This also controls the default snapshot-persistence policy for durable agents: running checkpoints are only written when set to 'auto' (or when an agent sets a custom shouldPersistSnapshot that includes running). Recovery re-issues LLM calls and re-executes tool calls, so tools must be idempotent. See Crash recovery.
|
|
137
137
|
|
|
138
|
+
**recovery.workflows** (`'auto' | 'off'`): Set to 'off' to skip restarting active workflow runs on server boot. Individual workflows can also opt out with autoRestartActiveRuns: false.
|
|
139
|
+
|
|
140
|
+
**recovery.workflowConcurrency** (`number`): Maximum number of workflow runs restarted at the same time during boot recovery. Use Infinity for no limit. Workflow and durable agent recovery run in parallel.
|
|
141
|
+
|
|
138
142
|
## Methods
|
|
139
143
|
|
|
140
144
|
### `recoverAllDurableAgents()`
|
|
@@ -143,17 +147,21 @@ Re-drives every orphaned `running` durable-agent run across all registered durab
|
|
|
143
147
|
|
|
144
148
|
Requires persistent storage. With an in-memory store, there's nothing to recover after a process restart.
|
|
145
149
|
|
|
150
|
+
A run that another execution still drives isn't taken over. It's counted in `skipped` and checked again once that execution's claim could have lapsed, so a run whose process crashed is recovered without another call. `shutdown()` cancels pending re-checks. See [run ownership](https://mastra.ai/docs/harness/durable-agents).
|
|
151
|
+
|
|
146
152
|
```typescript
|
|
147
153
|
const result = await mastra.recoverAllDurableAgents()
|
|
148
|
-
// { agents: 2, recovered: 3, succeeded: 3, failed: 0 }
|
|
154
|
+
// { agents: 2, recovered: 3, succeeded: 3, failed: 0, skipped: 1 }
|
|
149
155
|
```
|
|
150
156
|
|
|
151
157
|
Returns:
|
|
152
158
|
|
|
153
159
|
**agents** (`number`): Number of durable agents scanned.
|
|
154
160
|
|
|
155
|
-
**recovered** (`number`): Total number of runs that were re-driven.
|
|
161
|
+
**recovered** (`number`): Total number of runs that were re-driven: succeeded plus failed.
|
|
156
162
|
|
|
157
163
|
**succeeded** (`number`): Runs that restarted successfully.
|
|
158
164
|
|
|
159
|
-
**failed** (`number`): Runs whose restart threw an error.
|
|
165
|
+
**failed** (`number`): Runs whose restart threw an error.
|
|
166
|
+
|
|
167
|
+
**skipped** (`number`): Runs that another execution still drives. Each is checked again later.
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
`LeaseProvider` is the distributed leasing contract, separate from event delivery ([`PubSub`](https://mastra.ai/reference/pubsub/base)). Mastra's [signals layer](https://mastra.ai/docs/harness/signals) uses it to elect a single owner across multiple processes (for example, serverless invocations) for a resource, most commonly a thread key. The owner is the process that wakes and runs the agent stream, so other processes route follow-up work to it instead of starting a competing run.
|
|
8
8
|
|
|
9
|
+
[Durable agents](https://mastra.ai/docs/harness/durable-agents) also claim each run through a lease when the workflows store doesn't support run fencing, so crash recovery can tell whether another process still drives the run.
|
|
10
|
+
|
|
9
11
|
Leasing is separate from pub/sub. A `LeaseProvider` implementation needs actual lock coordination, whether through an atomic Redis operation such as `SET` or Lua or through an in-memory map for a single process. For backends that omit leasing, the signals runtime preserves single-process behavior with a no-op provider.
|
|
10
12
|
|
|
11
13
|
The built-in [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams) implements `LeaseProvider`, which is what enables signals to coordinate across instances in distributed and serverless deployments.
|
|
@@ -49,7 +49,7 @@ export const mastra = new Mastra({
|
|
|
49
49
|
|
|
50
50
|
## Constructor parameters
|
|
51
51
|
|
|
52
|
-
**url** (`string`): Valkey connection URL. Falls back to valkeyOptions.url. (Default: `valkey://localhost:6379`)
|
|
52
|
+
**url** (`string`): Valkey connection URL. Falls back to valkeyOptions.url. rediss\:// and valkeys\:// URLs enable TLS unless valkeyOptions.useTLS is set. (Default: `valkey://localhost:6379`)
|
|
53
53
|
|
|
54
54
|
**valkeyOptions** (`ValkeyClientOptions`): GLIDE connection options, including native client configuration.
|
|
55
55
|
|
|
@@ -405,6 +405,7 @@ On authenticated servers, the read routes require the `stored-workflows:read` pe
|
|
|
405
405
|
| `POST` | `/api/datasets/:datasetId/items` | Add a dataset item |
|
|
406
406
|
| `DELETE` | `/api/datasets/:datasetId/items/:itemId/purge` | Permanently scrub an item's content from every dataset version and linked experiment result |
|
|
407
407
|
| `GET` | `/api/experiments` | List experiments across datasets |
|
|
408
|
+
| `GET` | `/api/experiments/:experimentId` | Get an experiment by ID without knowing its dataset |
|
|
408
409
|
| `DELETE` | `/api/experiments/:experimentId` | Delete an experiment, including one orphaned by dataset deletion |
|
|
409
410
|
| `GET` | `/api/datasets/:datasetId/experiments` | List experiments for a dataset |
|
|
410
411
|
| `POST` | `/api/datasets/:datasetId/experiments` | Trigger an experiment, or create one without starting it (`start: false`) |
|
|
@@ -95,29 +95,32 @@ Set the `retention` field on the store config.
|
|
|
95
95
|
|
|
96
96
|
Each domain specifies its age-prunable tables and the timestamp column that anchors comparison, chosen so `maxAge` matches the meaning of the data. Append-only logs use creation time, live state uses last activity, and jobs or runs use completion time so in-flight work isn't pruned.
|
|
97
97
|
|
|
98
|
-
| Domain | Table key | Anchor column | `maxAge` measures
|
|
99
|
-
| ----------------- | ------------------ | ---------------- |
|
|
100
|
-
| `memory` | `threads` | `createdAt` | Thread age
|
|
101
|
-
| `memory` | `messages` | `createdAt` | Message age
|
|
102
|
-
| `memory` | `resources` | `createdAt` | Resource age
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `observability` | `
|
|
106
|
-
| `observability` | `
|
|
107
|
-
| `observability` | `
|
|
108
|
-
| `observability` | `
|
|
109
|
-
| `
|
|
110
|
-
| `
|
|
111
|
-
| `
|
|
112
|
-
| `
|
|
113
|
-
| `
|
|
114
|
-
| `
|
|
115
|
-
| `
|
|
98
|
+
| Domain | Table key | Anchor column | `maxAge` measures |
|
|
99
|
+
| ----------------- | ------------------ | ---------------- | -------------------------------------------------------------------------------------------------------------------------------- |
|
|
100
|
+
| `memory` | `threads` | `createdAt` | Thread age |
|
|
101
|
+
| `memory` | `messages` | `createdAt` | Message age |
|
|
102
|
+
| `memory` | `resources` | `createdAt` | Resource age |
|
|
103
|
+
| `memory` | `runFences` | `retiredAt` | Time since the durable agent execution holding the fence settled. Fences of running executions (`NULL`) are never pruned |
|
|
104
|
+
| `threadState` | `threadState` | `updatedAt` | Inactivity: state for still-active threads survives |
|
|
105
|
+
| `observability` | `spans` | `startedAt` | Span age |
|
|
106
|
+
| `observability` | `metrics` | `timestamp` | Metric event age (vNext only) |
|
|
107
|
+
| `observability` | `logs` | `timestamp` | Log event age (vNext only) |
|
|
108
|
+
| `observability` | `scores` | `timestamp` | Score event age (vNext only) |
|
|
109
|
+
| `observability` | `feedback` | `timestamp` | Feedback event age (vNext only) |
|
|
110
|
+
| `scores` | `scorers` | `createdAt` | Score record age |
|
|
111
|
+
| `workflows` | `workflowSnapshot` | `updatedAt` | Inactivity, suspended or long-running workflows survive |
|
|
112
|
+
| `workflows` | `runOwnership` | `updatedAt` | Inactivity. A running durable agent execution renews its claim every 10 seconds, so keep `maxAge` well above its 30-second lease |
|
|
113
|
+
| `backgroundTasks` | `backgroundTasks` | `completedAt` | Time since completion, in-flight tasks (`NULL`) are never pruned |
|
|
114
|
+
| `experiments` | `experiments` | `completedAt` | Time since completion, running experiments are never pruned |
|
|
115
|
+
| `notifications` | `notifications` | `createdAt` | Notification age |
|
|
116
|
+
| `harness` | `sessions` | `createdAt` | Session record age |
|
|
117
|
+
| `schedules` | `triggers` | `actual_fire_at` | Fire-history age (epoch-ms column) |
|
|
116
118
|
|
|
117
119
|
> **Note:**
|
|
118
120
|
>
|
|
119
121
|
> - The memory `observational_memory` table has no timestamp anchor, so it can't be age-pruned and isn't a valid retention key.
|
|
120
122
|
> - Experiments prune as whole units: an aged experiment's result rows are deleted together with it (results cascade with their parent), so a run is never left partially deleted. Retention doesn't have a separate `results` key.
|
|
123
|
+
> - `runOwnership` and `runFences` hold the run fencing records of durable agents, one small record per run in each. If the `runOwnership` `maxAge` is too short, a running execution can lose its run, but an execution that lost a run still can't write. A fence is retired only when its execution settles, so the fence of a run that crashed and was never recovered is never pruned.
|
|
121
124
|
> - For `schedules`, the growth table is the fire history (`schedule_triggers`, one row per fire): schedule definitions are config and aren't pruned.
|
|
122
125
|
> - On PostgreSQL, timestamp anchors use the timezone-aware mirror columns (for example `createdAtZ`, `completedAtZ`).
|
|
123
126
|
> - DuckDB observability stores append-only events for all five signals. Its `spans` policy uses the event `timestamp` column rather than `startedAt`.
|
|
@@ -123,10 +123,21 @@ const result = await sandbox.executeCommand('cat', ['/workspace/state.json'])
|
|
|
123
123
|
|
|
124
124
|
When `sandboxId` is set, `environmentId` isn't required because the sandbox already exists.
|
|
125
125
|
|
|
126
|
-
Read the platform's id for the running sandbox from the `sandboxId` property after `start()` and persist it for the next reattach. The property is `undefined` until the sandbox has started in the current process. The option passed to the constructor is a hint for `start()`. Before `start()` runs, `getInfo()` answers from local state and doesn't ask the platform about the hint.
|
|
126
|
+
Read the platform's id for the running sandbox from the `sandboxId` property after `start()` and persist it for the next reattach. The property is `undefined` until the sandbox has started in the current process. The option passed to the constructor is a hint for `start()`. Before `start()` runs, `getInfo()` answers from local state and doesn't ask the platform about the hint. Under the default `reattach: 'best-effort'`, if the platform no longer knows the id, `start()` falls through to a fresh provision keyed by the sandbox's logical `id`. That fallback needs `environmentId` (or `MASTRA_ENVIRONMENT_ID`), so pass it whenever a hint might be stale; without it, `start()` throws `environmentId is required`.
|
|
127
127
|
|
|
128
128
|
`start()` reports `{ outcome: 'connected' }` on reattach and `{ outcome: 'created' }` on a fresh provision (including a checkpoint-recovered boot, which is a new VM even when its filesystem was restored). See [`start()`](https://mastra.ai/reference/workspace/sandbox) for the shared contract.
|
|
129
129
|
|
|
130
|
+
When a fresh sandbox would silently lose state your app depends on, set `reattach: 'required'`:
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
const sandbox = new PlatformSandbox({
|
|
134
|
+
sandboxId: 'sbx_abc123',
|
|
135
|
+
reattach: 'required',
|
|
136
|
+
})
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
With `reattach: 'required'`, a reattach target the platform reports as missing (404), gone (410), or destroyed rejects `start()` with a `SandboxError` whose `code` is `SANDBOX_REATTACH_FAILED`, and no sandbox is provisioned. The error's `details` include `provider`, `sandboxId`, `logicalId` (the sandbox's logical `id`), and `reason`. Other errors propagate unchanged. To start fresh, clear your persisted `sandboxId` and construct the sandbox without it. Clones inherit the `reattach` setting.
|
|
140
|
+
|
|
130
141
|
### Reusable templates
|
|
131
142
|
|
|
132
143
|
Pass a reusable template builder to `PlatformSandbox`. A fresh sandbox start sends the serialized definition to Platform, which content-addresses it and starts or reuses the provider build. Sandbox creation never blocks on a build. When the exact template isn't built yet, Platform boots the sandbox on the best available fallback and rebuilds the requested template in the background. The fallback is a same-lineage stale template with matching resources when one exists, otherwise the provider base template:
|
|
@@ -315,6 +326,8 @@ console.log(result.exitCode)
|
|
|
315
326
|
|
|
316
327
|
**sandboxId** (`string`): Existing sandbox ID to reattach to instead of creating a new sandbox. When set, environmentId is not required.
|
|
317
328
|
|
|
329
|
+
**reattach** (`'best-effort' | 'required'`): What start() does when sandboxId is set but the platform reports that sandbox as missing, gone, or destroyed. 'best-effort' provisions a fresh sandbox. 'required' throws a SandboxError with code SANDBOX\_REATTACH\_FAILED instead of provisioning. (Default: `'best-effort'`)
|
|
330
|
+
|
|
318
331
|
**seedCheckpointName** (`string`): Boot-only fallback checkpoint used when the primary recovery checkpoint for id has no stored state. Later snapshots continue writing to the checkpoint for id.
|
|
319
332
|
|
|
320
333
|
**template** (`SandboxTemplateBuilder | (() => SandboxTemplateBuilder | undefined | Promise<SandboxTemplateBuilder | undefined>)`): Reusable template builder or lazy resolver used during a fresh sandbox provision. Resolver and provider build failures fall back to the selected provider default.
|
|
@@ -351,7 +364,7 @@ console.log(result.exitCode)
|
|
|
351
364
|
|
|
352
365
|
## Methods
|
|
353
366
|
|
|
354
|
-
**start** (`() => Promise<SandboxStartResult>`): 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.
|
|
367
|
+
**start** (`() => Promise<SandboxStartResult>`): 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 under the default reattach: 'best-effort', and throws SANDBOX\_REATTACH\_FAILED under reattach: 'required'.
|
|
355
368
|
|
|
356
369
|
**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).
|
|
357
370
|
|