@mastra/mcp-docs-server 1.1.8 → 1.1.9-alpha.0
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-memory.md +2 -2
- package/.docs/docs/agents/guardrails.md +3 -3
- package/.docs/docs/agents/network-approval.md +4 -1
- package/.docs/docs/agents/networks.md +1 -1
- package/.docs/docs/agents/overview.md +1 -1
- package/.docs/docs/agents/processors.md +35 -17
- package/.docs/docs/agents/structured-output.md +1 -1
- package/.docs/docs/agents/using-tools.md +2 -2
- package/.docs/docs/build-with-ai/mcp-docs-server.md +4 -4
- package/.docs/docs/build-with-ai/skills.md +1 -1
- package/.docs/docs/community/discord.md +1 -1
- package/.docs/docs/community/licensing.md +1 -1
- package/.docs/docs/deployment/mastra-server.md +1 -1
- package/.docs/docs/deployment/studio.md +2 -2
- package/.docs/docs/deployment/web-framework.md +1 -1
- package/.docs/docs/evals/overview.md +1 -1
- package/.docs/docs/getting-started/build-with-ai.md +1 -1
- package/.docs/docs/getting-started/project-structure.md +1 -1
- package/.docs/docs/index.md +62 -16
- package/.docs/docs/mastra-cloud/deployment.md +1 -1
- package/.docs/docs/mastra-cloud/studio.md +1 -1
- package/.docs/docs/mcp/publishing-mcp-server.md +1 -1
- package/.docs/docs/memory/memory-processors.md +1 -1
- package/.docs/docs/memory/message-history.md +2 -2
- package/.docs/docs/memory/observational-memory.md +6 -2
- package/.docs/docs/memory/semantic-recall.md +2 -2
- package/.docs/docs/memory/storage.md +1 -1
- package/.docs/docs/memory/working-memory.md +6 -6
- package/.docs/docs/observability/tracing/bridges/otel.md +2 -2
- package/.docs/docs/observability/tracing/exporters/default.md +1 -1
- package/.docs/docs/observability/tracing/overview.md +4 -4
- package/.docs/docs/observability/tracing/processors/sensitive-data-filter.md +2 -2
- package/.docs/docs/rag/chunking-and-embedding.md +1 -1
- package/.docs/docs/rag/vector-databases.md +2 -2
- package/.docs/docs/server/auth/auth0.md +1 -1
- package/.docs/docs/server/auth/firebase.md +1 -1
- package/.docs/docs/server/auth/simple-auth.md +1 -1
- package/.docs/docs/server/auth.md +1 -1
- package/.docs/docs/server/mastra-client.md +1 -1
- package/.docs/docs/server/mastra-server.md +1 -1
- package/.docs/docs/server/server-adapters.md +2 -2
- package/.docs/docs/streaming/events.md +1 -1
- package/.docs/docs/streaming/overview.md +1 -1
- package/.docs/docs/streaming/tool-streaming.md +44 -30
- package/.docs/docs/streaming/workflow-streaming.md +1 -1
- package/.docs/docs/workflows/control-flow.md +44 -2
- package/.docs/docs/workflows/error-handling.md +1 -1
- package/.docs/docs/workflows/overview.md +3 -3
- package/.docs/docs/workflows/snapshots.md +1 -1
- package/.docs/docs/workflows/time-travel.md +2 -2
- package/.docs/docs/workspace/filesystem.md +2 -2
- package/.docs/docs/workspace/overview.md +52 -7
- package/.docs/docs/workspace/sandbox.md +72 -13
- package/.docs/docs/workspace/skills.md +2 -2
- package/.docs/guides/build-your-ui/copilotkit.md +1 -1
- package/.docs/guides/deployment/inngest.md +4 -4
- package/.docs/guides/guide/ai-recruiter.md +1 -1
- package/.docs/guides/guide/github-actions-pr-description.md +2 -2
- package/.docs/guides/guide/notes-mcp-server.md +1 -1
- package/.docs/guides/guide/stock-agent.md +2 -2
- package/.docs/guides/migrations/agentnetwork.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/client.md +2 -2
- package/.docs/guides/migrations/upgrade-to-v1/deployment.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/memory.md +2 -2
- package/.docs/guides/migrations/upgrade-to-v1/storage.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/tools.md +2 -2
- package/.docs/guides/migrations/upgrade-to-v1/workflows.md +5 -5
- package/.docs/guides/migrations/vnext-to-standard-apis.md +2 -2
- package/.docs/models/gateways/netlify.md +1 -2
- package/.docs/models/gateways/openrouter.md +8 -1
- package/.docs/models/gateways/vercel.md +3 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/abacus.md +21 -11
- package/.docs/models/providers/aihubmix.md +7 -2
- package/.docs/models/providers/alibaba-cn.md +80 -71
- package/.docs/models/providers/alibaba-coding-plan-cn.md +78 -0
- package/.docs/models/providers/alibaba-coding-plan.md +78 -0
- package/.docs/models/providers/chutes.md +1 -1
- package/.docs/models/providers/clarifai.md +81 -0
- package/.docs/models/providers/cloudferro-sherlock.md +5 -4
- package/.docs/models/providers/cloudflare-workers-ai.md +3 -2
- package/.docs/models/providers/cortecs.md +7 -5
- package/.docs/models/providers/deepinfra.md +7 -2
- package/.docs/models/providers/deepseek.md +1 -1
- package/.docs/models/providers/drun.md +73 -0
- package/.docs/models/providers/firmware.md +28 -20
- package/.docs/models/providers/google.md +3 -1
- package/.docs/models/providers/inception.md +4 -2
- package/.docs/models/providers/kilo.md +3 -1
- package/.docs/models/providers/nano-gpt.md +519 -40
- package/.docs/models/providers/nebius.md +34 -34
- package/.docs/models/providers/nvidia.md +4 -2
- package/.docs/models/providers/ollama-cloud.md +1 -2
- package/.docs/models/providers/openai.md +3 -1
- package/.docs/models/providers/opencode.md +36 -33
- package/.docs/models/providers/poe.md +8 -2
- package/.docs/models/providers/qiniu-ai.md +20 -5
- package/.docs/models/providers/requesty.md +17 -1
- package/.docs/models/providers/siliconflow-cn.md +7 -1
- package/.docs/models/providers/togetherai.md +1 -3
- package/.docs/models/providers/xai.md +28 -25
- package/.docs/models/providers/xiaomi.md +1 -1
- package/.docs/models/providers/zenmux.md +3 -1
- package/.docs/models/providers.md +4 -0
- package/.docs/reference/agents/getDefaultGenerateOptions.md +1 -1
- package/.docs/reference/agents/getDefaultOptions.md +1 -1
- package/.docs/reference/agents/getDefaultStreamOptions.md +1 -1
- package/.docs/reference/agents/getDescription.md +1 -1
- package/.docs/reference/agents/network.md +3 -1
- package/.docs/reference/ai-sdk/handle-chat-stream.md +2 -0
- package/.docs/reference/ai-sdk/handle-network-stream.md +2 -0
- package/.docs/reference/ai-sdk/network-route.md +2 -0
- package/.docs/reference/ai-sdk/to-ai-sdk-v4-messages.md +1 -1
- package/.docs/reference/ai-sdk/to-ai-sdk-v5-messages.md +1 -1
- package/.docs/reference/auth/auth0.md +3 -3
- package/.docs/reference/auth/firebase.md +1 -1
- package/.docs/reference/auth/workos.md +2 -2
- package/.docs/reference/cli/mastra.md +4 -4
- package/.docs/reference/client-js/mastra-client.md +1 -1
- package/.docs/reference/configuration.md +62 -6
- package/.docs/reference/core/getDeployer.md +1 -1
- package/.docs/reference/core/getLogger.md +1 -1
- package/.docs/reference/core/getScorer.md +2 -2
- package/.docs/reference/core/getServer.md +1 -1
- package/.docs/reference/core/getStorage.md +1 -1
- package/.docs/reference/core/getStoredAgentById.md +1 -1
- package/.docs/reference/core/getTelemetry.md +1 -1
- package/.docs/reference/core/getWorkflow.md +1 -1
- package/.docs/reference/core/listAgents.md +1 -1
- package/.docs/reference/core/listMCPServers.md +1 -1
- package/.docs/reference/core/listStoredAgents.md +1 -1
- package/.docs/reference/core/listVectors.md +1 -1
- package/.docs/reference/core/mastra-class.md +1 -1
- package/.docs/reference/core/setLogger.md +1 -1
- package/.docs/reference/core/setStorage.md +1 -1
- package/.docs/reference/datasets/dataset.md +1 -1
- package/.docs/reference/datasets/datasets-manager.md +1 -1
- package/.docs/reference/datasets/get.md +2 -2
- package/.docs/reference/datasets/getDetails.md +1 -1
- package/.docs/reference/datasets/listItems.md +1 -1
- package/.docs/reference/deployer/vercel.md +1 -1
- package/.docs/reference/evals/answer-relevancy.md +1 -1
- package/.docs/reference/evals/completeness.md +1 -1
- package/.docs/reference/evals/context-precision.md +3 -3
- package/.docs/reference/evals/context-relevance.md +1 -1
- package/.docs/reference/evals/hallucination.md +3 -9
- package/.docs/reference/evals/keyword-coverage.md +1 -1
- package/.docs/reference/evals/mastra-scorer.md +1 -1
- package/.docs/reference/evals/noise-sensitivity.md +2 -2
- package/.docs/reference/evals/textual-difference.md +1 -1
- package/.docs/reference/evals/tone-consistency.md +1 -1
- package/.docs/reference/evals/tool-call-accuracy.md +1 -1
- package/.docs/reference/harness/harness-class.md +4 -2
- package/.docs/reference/index.md +2 -0
- package/.docs/reference/memory/cloneThread.md +1 -1
- package/.docs/reference/memory/observational-memory.md +7 -5
- package/.docs/reference/observability/tracing/bridges/otel.md +1 -1
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +1 -1
- package/.docs/reference/observability/tracing/spans.md +2 -0
- package/.docs/reference/processors/message-history-processor.md +1 -1
- package/.docs/reference/processors/processor-interface.md +6 -2
- package/.docs/reference/processors/token-limiter-processor.md +2 -2
- package/.docs/reference/rag/metadata-filters.md +10 -10
- package/.docs/reference/server/create-route.md +2 -0
- package/.docs/reference/server/koa-adapter.md +1 -1
- package/.docs/reference/server/register-api-route.md +2 -2
- package/.docs/reference/storage/cloudflare-d1.md +3 -3
- package/.docs/reference/storage/cloudflare.md +1 -1
- package/.docs/reference/storage/convex.md +1 -1
- package/.docs/reference/storage/dynamodb.md +2 -2
- package/.docs/reference/storage/lance.md +2 -2
- package/.docs/reference/storage/mongodb.md +1 -1
- package/.docs/reference/storage/mssql.md +1 -1
- package/.docs/reference/storage/postgresql.md +2 -2
- package/.docs/reference/storage/upstash.md +1 -1
- package/.docs/reference/streaming/workflows/observeStream.md +1 -1
- package/.docs/reference/templates/overview.md +1 -1
- package/.docs/reference/tools/create-tool.md +1 -1
- package/.docs/reference/tools/mcp-server.md +4 -4
- package/.docs/reference/vectors/chroma.md +2 -2
- package/.docs/reference/vectors/couchbase.md +6 -6
- package/.docs/reference/vectors/pg.md +2 -0
- package/.docs/reference/vectors/s3vectors.md +5 -5
- package/.docs/reference/voice/azure.md +4 -2
- package/.docs/reference/voice/cloudflare.md +4 -2
- package/.docs/reference/voice/elevenlabs.md +1 -1
- package/.docs/reference/voice/google-gemini-live.md +2 -2
- package/.docs/reference/voice/google.md +3 -3
- package/.docs/reference/voice/mastra-voice.md +1 -1
- package/.docs/reference/voice/murf.md +2 -2
- package/.docs/reference/voice/openai-realtime.md +3 -1
- package/.docs/reference/voice/openai.md +7 -3
- package/.docs/reference/voice/playai.md +4 -2
- package/.docs/reference/voice/sarvam.md +3 -1
- package/.docs/reference/voice/speechify.md +6 -4
- package/.docs/reference/voice/voice.addInstructions.md +2 -2
- package/.docs/reference/voice/voice.addTools.md +1 -1
- package/.docs/reference/voice/voice.close.md +2 -2
- package/.docs/reference/voice/voice.connect.md +4 -2
- package/.docs/reference/voice/voice.events.md +2 -2
- package/.docs/reference/voice/voice.getSpeakers.md +1 -1
- package/.docs/reference/voice/voice.listen.md +11 -5
- package/.docs/reference/voice/voice.off.md +2 -2
- package/.docs/reference/voice/voice.on.md +2 -2
- package/.docs/reference/voice/voice.speak.md +14 -4
- package/.docs/reference/voice/voice.updateConfig.md +1 -1
- package/.docs/reference/workflows/run-methods/timeTravel.md +1 -1
- package/.docs/reference/workspace/blaxel-sandbox.md +164 -0
- package/.docs/reference/workspace/daytona-sandbox.md +48 -139
- package/.docs/reference/workspace/e2b-sandbox.md +39 -75
- package/.docs/reference/workspace/filesystem.md +24 -10
- package/.docs/reference/workspace/gcs-filesystem.md +20 -0
- package/.docs/reference/workspace/local-filesystem.md +23 -9
- package/.docs/reference/workspace/local-sandbox.md +23 -98
- package/.docs/reference/workspace/process-manager.md +296 -0
- package/.docs/reference/workspace/s3-filesystem.md +20 -0
- package/.docs/reference/workspace/sandbox.md +9 -1
- package/.docs/reference/workspace/workspace-class.md +93 -25
- package/CHANGELOG.md +8 -0
- package/dist/tools/course.d.ts +7 -27
- package/dist/tools/course.d.ts.map +1 -1
- package/dist/tools/docs.d.ts +6 -18
- package/dist/tools/docs.d.ts.map +1 -1
- package/dist/tools/embedded-docs.d.ts +12 -112
- package/dist/tools/embedded-docs.d.ts.map +1 -1
- package/dist/tools/migration.d.ts +6 -26
- package/dist/tools/migration.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# BlaxelSandbox
|
|
2
|
+
|
|
3
|
+
Executes commands in isolated [Blaxel](https://blaxel.ai/) cloud sandboxes. Provides secure, isolated code execution environments with support for mounting cloud storage (S3, GCS) via FUSE.
|
|
4
|
+
|
|
5
|
+
> **Info:** For interface details, see [WorkspaceSandbox interface](https://mastra.ai/reference/workspace/sandbox).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
**npm**:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @mastra/blaxel
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**pnpm**:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @mastra/blaxel
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Yarn**:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
yarn add @mastra/blaxel
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Bun**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
bun add @mastra/blaxel
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
Add a `BlaxelSandbox` to a workspace and assign it to an agent:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { Agent } from '@mastra/core/agent'
|
|
39
|
+
import { Workspace } from '@mastra/core/workspace'
|
|
40
|
+
import { BlaxelSandbox } from '@mastra/blaxel'
|
|
41
|
+
|
|
42
|
+
const workspace = new Workspace({
|
|
43
|
+
sandbox: new BlaxelSandbox(),
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const agent = new Agent({
|
|
47
|
+
id: 'code-agent',
|
|
48
|
+
name: 'Code Agent',
|
|
49
|
+
instructions: 'You are a coding assistant working in this workspace.',
|
|
50
|
+
model: 'anthropic/claude-sonnet-4-6',
|
|
51
|
+
workspace,
|
|
52
|
+
})
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Custom image with resources
|
|
56
|
+
|
|
57
|
+
Use a custom Docker image with additional memory:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
const workspace = new Workspace({
|
|
61
|
+
sandbox: new BlaxelSandbox({
|
|
62
|
+
image: 'node:20-slim',
|
|
63
|
+
memory: 8192,
|
|
64
|
+
timeout: '10m',
|
|
65
|
+
}),
|
|
66
|
+
})
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Constructor parameters
|
|
70
|
+
|
|
71
|
+
**id** (`string`): Unique identifier for this sandbox instance. (Default: `Auto-generated`)
|
|
72
|
+
|
|
73
|
+
**image** (`string`): Docker image to use for the sandbox. Debian-based images support both S3 and GCS mounts. Alpine-based images support S3 mounts only. (Default: `'blaxel/ts-app:latest'`)
|
|
74
|
+
|
|
75
|
+
**memory** (`number`): Memory allocation in MB. (Default: `4096`)
|
|
76
|
+
|
|
77
|
+
**timeout** (`string`): Execution timeout as a duration string (e.g. '5m', '1h'). Maps to the Blaxel sandbox TTL.
|
|
78
|
+
|
|
79
|
+
**env** (`Record<string, string>`): Environment variables to set in the sandbox.
|
|
80
|
+
|
|
81
|
+
**labels** (`Record<string, string>`): Custom labels for the sandbox.
|
|
82
|
+
|
|
83
|
+
**runtimes** (`SandboxRuntime[]`): Supported runtimes. Valid values: 'node', 'python', 'bash', 'ruby', 'go', 'rust', 'java', 'cpp', 'r'. (Default: `['node', 'python', 'bash']`)
|
|
84
|
+
|
|
85
|
+
**ports** (`Array<{ name?: string; target: number; protocol?: 'HTTP' | 'TCP' | 'UDP' }>`): Ports to expose from the sandbox.
|
|
86
|
+
|
|
87
|
+
## Properties
|
|
88
|
+
|
|
89
|
+
**id** (`string`): Sandbox instance identifier.
|
|
90
|
+
|
|
91
|
+
**name** (`string`): 'BlaxelSandbox'
|
|
92
|
+
|
|
93
|
+
**provider** (`string`): 'blaxel'
|
|
94
|
+
|
|
95
|
+
**status** (`ProviderStatus`): 'pending' | 'initializing' | 'running' | 'stopped' | 'error'
|
|
96
|
+
|
|
97
|
+
**instance** (`SandboxInstance`): The underlying Blaxel SandboxInstance for direct access to Blaxel APIs. Throws SandboxNotReadyError if the sandbox has not been started.
|
|
98
|
+
|
|
99
|
+
**processes** (`BlaxelProcessManager`): Background process manager. See \[SandboxProcessManager reference]\(/reference/workspace/process-manager).
|
|
100
|
+
|
|
101
|
+
## Background processes
|
|
102
|
+
|
|
103
|
+
`BlaxelSandbox` includes a built-in process manager for spawning and managing background processes.
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
const sandbox = new BlaxelSandbox({ id: 'dev-sandbox' })
|
|
107
|
+
await sandbox.start()
|
|
108
|
+
|
|
109
|
+
// Spawn a background process
|
|
110
|
+
const handle = await sandbox.processes.spawn('node server.js', {
|
|
111
|
+
env: { PORT: '3000' },
|
|
112
|
+
onStdout: data => console.log(data),
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
// Interact with the process
|
|
116
|
+
console.log(handle.stdout)
|
|
117
|
+
await handle.kill()
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
> **Note:** Blaxel sandboxes don't support stdin. Calling `handle.sendStdin()` throws an error.
|
|
121
|
+
|
|
122
|
+
See [`SandboxProcessManager` reference](https://mastra.ai/reference/workspace/process-manager) for the full API.
|
|
123
|
+
|
|
124
|
+
## Mounting cloud storage
|
|
125
|
+
|
|
126
|
+
Blaxel sandboxes can mount S3 or GCS filesystems, making cloud storage accessible as a local directory inside the sandbox.
|
|
127
|
+
|
|
128
|
+
### S3
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { Workspace } from '@mastra/core/workspace'
|
|
132
|
+
import { S3Filesystem } from '@mastra/s3'
|
|
133
|
+
import { BlaxelSandbox } from '@mastra/blaxel'
|
|
134
|
+
|
|
135
|
+
const workspace = new Workspace({
|
|
136
|
+
mounts: {
|
|
137
|
+
'/data': new S3Filesystem({
|
|
138
|
+
bucket: 'my-bucket',
|
|
139
|
+
region: 'us-east-1',
|
|
140
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
141
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
142
|
+
}),
|
|
143
|
+
},
|
|
144
|
+
sandbox: new BlaxelSandbox(),
|
|
145
|
+
})
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### GCS
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import { Workspace } from '@mastra/core/workspace'
|
|
152
|
+
import { GCSFilesystem } from '@mastra/gcs'
|
|
153
|
+
import { BlaxelSandbox } from '@mastra/blaxel'
|
|
154
|
+
|
|
155
|
+
const workspace = new Workspace({
|
|
156
|
+
mounts: {
|
|
157
|
+
'/data': new GCSFilesystem({
|
|
158
|
+
bucket: 'my-bucket',
|
|
159
|
+
credentials: JSON.parse(process.env.GCS_SERVICE_ACCOUNT_KEY!),
|
|
160
|
+
}),
|
|
161
|
+
},
|
|
162
|
+
sandbox: new BlaxelSandbox(),
|
|
163
|
+
})
|
|
164
|
+
```
|
|
@@ -6,24 +6,47 @@ Executes commands in isolated [Daytona](https://www.daytona.io) cloud sandboxes.
|
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
|
+
**npm**:
|
|
10
|
+
|
|
9
11
|
```bash
|
|
10
12
|
npm install @mastra/daytona
|
|
11
13
|
```
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
**pnpm**:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @mastra/daytona
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Yarn**:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
yarn add @mastra/daytona
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Bun**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
bun add @mastra/daytona
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Set your Daytona API key in one of three ways.
|
|
34
|
+
|
|
35
|
+
**Shell export**:
|
|
14
36
|
|
|
15
37
|
```bash
|
|
16
|
-
# Shell export
|
|
17
38
|
export DAYTONA_API_KEY=your-api-key
|
|
18
39
|
```
|
|
19
40
|
|
|
41
|
+
**.env file**:
|
|
42
|
+
|
|
20
43
|
```bash
|
|
21
|
-
# .env file
|
|
22
44
|
DAYTONA_API_KEY=your-api-key
|
|
23
45
|
```
|
|
24
46
|
|
|
47
|
+
**Constructor**:
|
|
48
|
+
|
|
25
49
|
```typescript
|
|
26
|
-
// Passed directly as constructor argument
|
|
27
50
|
new DaytonaSandbox({ apiKey: 'your-api-key' })
|
|
28
51
|
```
|
|
29
52
|
|
|
@@ -36,13 +59,13 @@ import { Agent } from '@mastra/core/agent'
|
|
|
36
59
|
import { Workspace } from '@mastra/core/workspace'
|
|
37
60
|
import { DaytonaSandbox } from '@mastra/daytona'
|
|
38
61
|
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
62
|
+
const workspace = new Workspace({
|
|
63
|
+
sandbox: new DaytonaSandbox({
|
|
64
|
+
language: 'typescript',
|
|
65
|
+
timeout: 120_000,
|
|
66
|
+
}),
|
|
42
67
|
})
|
|
43
68
|
|
|
44
|
-
const workspace = new Workspace({ sandbox })
|
|
45
|
-
|
|
46
69
|
const agent = new Agent({
|
|
47
70
|
id: 'code-agent',
|
|
48
71
|
name: 'Code Agent',
|
|
@@ -138,7 +161,7 @@ const result = await sandbox2.executeCommand('cat', ['/tmp/state.txt'])
|
|
|
138
161
|
console.log(result.stdout) // "session 1"
|
|
139
162
|
```
|
|
140
163
|
|
|
141
|
-
If the sandbox is in a stopped or archived state, it
|
|
164
|
+
If the sandbox is in a stopped or archived state, it's restarted automatically. If it's in a dead state (destroyed, errored), a fresh sandbox is created instead.
|
|
142
165
|
|
|
143
166
|
### Filesystem mounting
|
|
144
167
|
|
|
@@ -296,144 +319,29 @@ const workspace = new Workspace({
|
|
|
296
319
|
|
|
297
320
|
**instance** (`Sandbox`): The underlying Daytona Sandbox instance. Throws SandboxNotReadyError if the sandbox has not been started.
|
|
298
321
|
|
|
299
|
-
|
|
322
|
+
**processes** (`DaytonaProcessManager`): Background process manager. See \[SandboxProcessManager reference]\(/reference/workspace/process-manager).
|
|
300
323
|
|
|
301
|
-
|
|
324
|
+
## Background processes
|
|
302
325
|
|
|
303
|
-
|
|
326
|
+
`DaytonaSandbox` includes a built-in process manager for spawning and managing background processes. Processes run in the Daytona cloud sandbox using session-based command execution.
|
|
304
327
|
|
|
305
328
|
```typescript
|
|
329
|
+
const sandbox = new DaytonaSandbox({ language: 'typescript' })
|
|
306
330
|
await sandbox.start()
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
Called automatically on first command execution or by `workspace.init()`.
|
|
310
|
-
|
|
311
|
-
### `stop()`
|
|
312
|
-
|
|
313
|
-
Stop the sandbox. The sandbox can be restarted later — files and state persist.
|
|
314
|
-
|
|
315
|
-
```typescript
|
|
316
|
-
await sandbox.stop()
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
### `destroy()`
|
|
320
|
-
|
|
321
|
-
Delete the sandbox and clean up all resources.
|
|
322
331
|
|
|
323
|
-
|
|
324
|
-
await sandbox.
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
### `executeCommand(command, args?, options?)`
|
|
328
|
-
|
|
329
|
-
Execute a shell command in the sandbox. Automatically starts the sandbox if not already running, and retries once if the sandbox has timed out.
|
|
330
|
-
|
|
331
|
-
```typescript
|
|
332
|
-
const result = await sandbox.executeCommand('node', ['-e', 'console.log("Hello!")'])
|
|
333
|
-
const output = await sandbox.executeCommand('pip', ['install', 'requests'], {
|
|
334
|
-
timeout: 60_000,
|
|
335
|
-
cwd: '/workspace',
|
|
336
|
-
})
|
|
337
|
-
|
|
338
|
-
// Stream output in real time
|
|
339
|
-
await sandbox.executeCommand('bash', ['-c', 'for i in 1 2 3; do echo "line $i"; sleep 1; done'], {
|
|
340
|
-
onStdout: chunk => process.stdout.write(chunk),
|
|
341
|
-
onStderr: chunk => process.stderr.write(chunk),
|
|
332
|
+
// Spawn a background process
|
|
333
|
+
const handle = await sandbox.processes.spawn('node server.js', {
|
|
334
|
+
env: { PORT: '3000' },
|
|
335
|
+
onStdout: data => console.log(data),
|
|
342
336
|
})
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
**Parameters:**
|
|
346
|
-
|
|
347
|
-
**command** (`string`): Command to execute.
|
|
348
|
-
|
|
349
|
-
**args** (`string[]`): Command arguments.
|
|
350
|
-
|
|
351
|
-
**options.timeout** (`number`): Execution timeout in milliseconds. Overrides the instance default.
|
|
352
|
-
|
|
353
|
-
**options.cwd** (`string`): Working directory for the command.
|
|
354
|
-
|
|
355
|
-
**options.env** (`Record<string, string>`): Additional environment variables for this command. Merged with instance-level env.
|
|
356
|
-
|
|
357
|
-
**options.onStdout** (`(data: string) => void`): Callback for stdout streaming.
|
|
358
337
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
Mount a filesystem at a path in the sandbox using FUSE tools (`s3fs` for S3, `gcsfuse` for GCS). FUSE tools are installed automatically if not present.
|
|
364
|
-
|
|
365
|
-
```typescript
|
|
366
|
-
import { S3Filesystem } from '@mastra/s3'
|
|
367
|
-
|
|
368
|
-
const result = await sandbox.mount(
|
|
369
|
-
new S3Filesystem({
|
|
370
|
-
bucket: process.env.S3_BUCKET!,
|
|
371
|
-
region: 'us-east-1',
|
|
372
|
-
accessKeyId: process.env.S3_ACCESS_KEY_ID,
|
|
373
|
-
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
|
|
374
|
-
}),
|
|
375
|
-
'/data',
|
|
376
|
-
)
|
|
377
|
-
// { success: true, mountPath: '/data' }
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
Returns a `MountResult`: `{ success: boolean; mountPath: string; error?: string }`.
|
|
381
|
-
|
|
382
|
-
### `unmount(mountPath)`
|
|
383
|
-
|
|
384
|
-
Unmount a filesystem from a path in the sandbox.
|
|
385
|
-
|
|
386
|
-
```typescript
|
|
387
|
-
await sandbox.unmount('/data')
|
|
338
|
+
// Interact with the process
|
|
339
|
+
console.log(handle.stdout)
|
|
340
|
+
await handle.sendStdin('input\n')
|
|
341
|
+
await handle.kill()
|
|
388
342
|
```
|
|
389
343
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
Get sandbox status and resource information.
|
|
393
|
-
|
|
394
|
-
```typescript
|
|
395
|
-
const info = await sandbox.getInfo()
|
|
396
|
-
// {
|
|
397
|
-
// id: 'daytona-sandbox-abc123',
|
|
398
|
-
// name: 'DaytonaSandbox',
|
|
399
|
-
// provider: 'daytona',
|
|
400
|
-
// status: 'running',
|
|
401
|
-
// createdAt: Date,
|
|
402
|
-
// mounts: [],
|
|
403
|
-
// resources: {
|
|
404
|
-
// cpuCores: 2, // vCPU count from the running sandbox
|
|
405
|
-
// memoryMB: 4096, // converted from GB (×1024)
|
|
406
|
-
// diskMB: 20480, // converted from GiB (×1024)
|
|
407
|
-
// },
|
|
408
|
-
// metadata: {
|
|
409
|
-
// language: 'typescript',
|
|
410
|
-
// ephemeral: false,
|
|
411
|
-
// snapshot: 'my-snapshot-id', // only when snapshot is set
|
|
412
|
-
// image: 'node:20-slim', // only when image is set
|
|
413
|
-
// target: 'us', // only when sandbox is running
|
|
414
|
-
// },
|
|
415
|
-
// }
|
|
416
|
-
```
|
|
417
|
-
|
|
418
|
-
### `getInstructions()`
|
|
419
|
-
|
|
420
|
-
Get a description of the sandbox environment. Used in tool descriptions so agents understand the execution context.
|
|
421
|
-
|
|
422
|
-
```typescript
|
|
423
|
-
// Default (no options)
|
|
424
|
-
new DaytonaSandbox().getInstructions()
|
|
425
|
-
// 'Cloud sandbox with isolated execution (typescript runtime). Default working directory: /home/daytona. Command timeout: 300s. Running as user: daytona.'
|
|
426
|
-
|
|
427
|
-
// All options set
|
|
428
|
-
new DaytonaSandbox({
|
|
429
|
-
language: 'python',
|
|
430
|
-
timeout: 60_000,
|
|
431
|
-
user: 'app',
|
|
432
|
-
volumes: [{ volumeId: 'vol-123', mountPath: '/data' }],
|
|
433
|
-
networkBlockAll: true,
|
|
434
|
-
}).getInstructions()
|
|
435
|
-
// 'Cloud sandbox with isolated execution (python runtime). Default working directory: /home/daytona. Command timeout: 60s. Running as user: app. 1 volume(s) attached. Network access is blocked.'
|
|
436
|
-
```
|
|
344
|
+
See [`SandboxProcessManager` reference](https://mastra.ai/reference/workspace/process-manager) for the full API.
|
|
437
345
|
|
|
438
346
|
## Mounting Cloud Storage
|
|
439
347
|
|
|
@@ -557,7 +465,7 @@ await daytonaSandbox.fs.uploadFile(Buffer.from('hello'), '/tmp/hello.txt')
|
|
|
557
465
|
await daytonaSandbox.git.clone('https://github.com/org/repo', '/workspace/repo')
|
|
558
466
|
```
|
|
559
467
|
|
|
560
|
-
The `instance` getter throws `SandboxNotReadyError` if the sandbox
|
|
468
|
+
The `instance` getter throws `SandboxNotReadyError` if the sandbox hasn't been started yet.
|
|
561
469
|
|
|
562
470
|
## Sandbox creation modes
|
|
563
471
|
|
|
@@ -573,6 +481,7 @@ Resources are only applied when `image` is set. Passing `resources` without `ima
|
|
|
573
481
|
|
|
574
482
|
## Related
|
|
575
483
|
|
|
484
|
+
- [SandboxProcessManager reference](https://mastra.ai/reference/workspace/process-manager)
|
|
576
485
|
- [WorkspaceSandbox interface](https://mastra.ai/reference/workspace/sandbox)
|
|
577
486
|
- [LocalSandbox reference](https://mastra.ai/reference/workspace/local-sandbox)
|
|
578
487
|
- [S3Filesystem reference](https://mastra.ai/reference/workspace/s3-filesystem)
|
|
@@ -6,10 +6,30 @@ Executes commands in isolated [E2B](https://e2b.dev) cloud sandboxes. Provides s
|
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
|
+
**npm**:
|
|
10
|
+
|
|
9
11
|
```bash
|
|
10
12
|
npm install @mastra/e2b
|
|
11
13
|
```
|
|
12
14
|
|
|
15
|
+
**pnpm**:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @mastra/e2b
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Yarn**:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
yarn add @mastra/e2b
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Bun**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
bun add @mastra/e2b
|
|
31
|
+
```
|
|
32
|
+
|
|
13
33
|
## Usage
|
|
14
34
|
|
|
15
35
|
Add an `E2BSandbox` to a workspace and assign it to an agent:
|
|
@@ -63,95 +83,38 @@ const agent = new Agent({
|
|
|
63
83
|
|
|
64
84
|
**supportsMounting** (`boolean`): Always true - E2B sandboxes support mounting cloud filesystems
|
|
65
85
|
|
|
66
|
-
|
|
86
|
+
**processes** (`E2BProcessManager`): Background process manager. See \[SandboxProcessManager reference]\(/reference/workspace/process-manager).
|
|
67
87
|
|
|
68
|
-
|
|
88
|
+
## Background processes
|
|
69
89
|
|
|
70
|
-
|
|
90
|
+
`E2BSandbox` includes a built-in process manager for spawning and managing background processes. Processes run in the E2B cloud sandbox using the E2B SDK's `commands.run()` with `background: true`.
|
|
71
91
|
|
|
72
92
|
```typescript
|
|
93
|
+
const sandbox = new E2BSandbox({ id: 'dev-sandbox' })
|
|
73
94
|
await sandbox.start()
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
Called automatically on first command execution or by `workspace.init()`.
|
|
77
|
-
|
|
78
|
-
### `stop()`
|
|
79
|
-
|
|
80
|
-
Stop the sandbox and release resources.
|
|
81
|
-
|
|
82
|
-
```typescript
|
|
83
|
-
await sandbox.stop()
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### `destroy()`
|
|
87
|
-
|
|
88
|
-
Clean up sandbox resources completely.
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
await sandbox.destroy()
|
|
92
|
-
```
|
|
93
95
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
const result = await sandbox.executeCommand('ls', ['-la'])
|
|
100
|
-
const npmResult = await sandbox.executeCommand('npm', ['install', 'lodash'], {
|
|
101
|
-
timeout: 60000,
|
|
102
|
-
cwd: '/app',
|
|
96
|
+
// Spawn a background process
|
|
97
|
+
const handle = await sandbox.processes.spawn('node server.js', {
|
|
98
|
+
env: { PORT: '3000' },
|
|
99
|
+
onStdout: data => console.log(data),
|
|
103
100
|
})
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
**Parameters:**
|
|
107
|
-
|
|
108
|
-
**command** (`string`): Command to execute
|
|
109
|
-
|
|
110
|
-
**args** (`string[]`): Command arguments
|
|
111
|
-
|
|
112
|
-
**options.timeout** (`number`): Execution timeout in milliseconds
|
|
113
|
-
|
|
114
|
-
**options.cwd** (`string`): Working directory for the command
|
|
115
|
-
|
|
116
|
-
**options.env** (`Record<string, string>`): Additional environment variables
|
|
117
|
-
|
|
118
|
-
**options.onStdout** (`(data: string) => void`): Callback for stdout streaming
|
|
119
|
-
|
|
120
|
-
**options.onStderr** (`(data: string) => void`): Callback for stderr streaming
|
|
121
|
-
|
|
122
|
-
### `canMount(filesystem)`
|
|
123
101
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
// true for S3Filesystem and GCSFilesystem
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### `mount(filesystem, mountPath)`
|
|
132
|
-
|
|
133
|
-
Mount a filesystem into the sandbox at the specified path.
|
|
134
|
-
|
|
135
|
-
```typescript
|
|
136
|
-
await sandbox.mount(s3Filesystem, '/mnt/data')
|
|
102
|
+
// Interact with the process
|
|
103
|
+
console.log(handle.stdout)
|
|
104
|
+
await handle.sendStdin('input\n')
|
|
105
|
+
await handle.kill()
|
|
137
106
|
```
|
|
138
107
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
Unmount a previously mounted filesystem.
|
|
108
|
+
The E2B process manager supports reconnecting to processes that were spawned externally or before a reconnection. Call `get(pid)` with a PID to connect to an existing process:
|
|
142
109
|
|
|
143
110
|
```typescript
|
|
144
|
-
await sandbox.
|
|
111
|
+
const handle = await sandbox.processes.get(existingPid)
|
|
112
|
+
if (handle) {
|
|
113
|
+
console.log(handle.stdout)
|
|
114
|
+
}
|
|
145
115
|
```
|
|
146
116
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
Get sandbox status and resource information.
|
|
150
|
-
|
|
151
|
-
```typescript
|
|
152
|
-
const info = await sandbox.getInfo()
|
|
153
|
-
// { id: '...', name: 'E2BSandbox', provider: 'e2b', status: 'ready', supportsMounting: true }
|
|
154
|
-
```
|
|
117
|
+
See [`SandboxProcessManager` reference](https://mastra.ai/reference/workspace/process-manager) for the full API.
|
|
155
118
|
|
|
156
119
|
## Mounting Cloud Storage
|
|
157
120
|
|
|
@@ -282,6 +245,7 @@ This is optional—`gcsfuse` is installed automatically at mount time if not pre
|
|
|
282
245
|
|
|
283
246
|
## Related
|
|
284
247
|
|
|
248
|
+
- [SandboxProcessManager reference](https://mastra.ai/reference/workspace/process-manager)
|
|
285
249
|
- [WorkspaceSandbox interface](https://mastra.ai/reference/workspace/sandbox)
|
|
286
250
|
- [LocalSandbox reference](https://mastra.ai/reference/workspace/local-sandbox)
|
|
287
251
|
- [S3Filesystem reference](https://mastra.ai/reference/workspace/s3-filesystem)
|
|
@@ -19,7 +19,9 @@ const buffer = await filesystem.readFile('/image.png', { encoding: 'binary' })
|
|
|
19
19
|
|
|
20
20
|
**path** (`string`): File path relative to basePath
|
|
21
21
|
|
|
22
|
-
**options
|
|
22
|
+
**options** (`Options`): readFile options.
|
|
23
|
+
|
|
24
|
+
**options.encoding** (`'utf-8' | 'binary'`): Text or binary encoding
|
|
23
25
|
|
|
24
26
|
**Returns:** `Promise<string | Buffer>`
|
|
25
27
|
|
|
@@ -38,9 +40,11 @@ await filesystem.writeFile('/nested/path/file.md', content, { recursive: true })
|
|
|
38
40
|
|
|
39
41
|
**content** (`string | Buffer`): File content
|
|
40
42
|
|
|
41
|
-
**options
|
|
43
|
+
**options** (`Options`): Configuration options.
|
|
44
|
+
|
|
45
|
+
**options.recursive** (`boolean`): Create parent directories if they don't exist
|
|
42
46
|
|
|
43
|
-
**options.overwrite** (`boolean`): Overwrite existing file
|
|
47
|
+
**options.overwrite** (`boolean`): Overwrite existing file
|
|
44
48
|
|
|
45
49
|
### `deleteFile(path, options?)`
|
|
46
50
|
|
|
@@ -55,11 +59,13 @@ await filesystem.deleteFile('/docs/maybe.md', { force: true }) // Don't throw if
|
|
|
55
59
|
|
|
56
60
|
**path** (`string`): File path
|
|
57
61
|
|
|
58
|
-
**options
|
|
62
|
+
**options** (`Options`): Configuration options.
|
|
63
|
+
|
|
64
|
+
**options.force** (`boolean`): Don't throw error if file doesn't exist
|
|
59
65
|
|
|
60
66
|
### `appendFile(path, content)`
|
|
61
67
|
|
|
62
|
-
Append content to a file, creating it if it
|
|
68
|
+
Append content to a file, creating it if it doesn't already exist. Parent directories are created automatically.
|
|
63
69
|
|
|
64
70
|
```typescript
|
|
65
71
|
await filesystem.appendFile('/logs/app.log', 'New log entry\n')
|
|
@@ -85,7 +91,9 @@ await filesystem.copyFile('/docs/template.md', '/docs/new-doc.md')
|
|
|
85
91
|
|
|
86
92
|
**dest** (`string`): Destination file path
|
|
87
93
|
|
|
88
|
-
**options
|
|
94
|
+
**options** (`Options`): Configuration options.
|
|
95
|
+
|
|
96
|
+
**options.overwrite** (`boolean`): Overwrite destination if it exists
|
|
89
97
|
|
|
90
98
|
### `moveFile(src, dest, options?)`
|
|
91
99
|
|
|
@@ -101,7 +109,9 @@ await filesystem.moveFile('/docs/draft.md', '/docs/final.md')
|
|
|
101
109
|
|
|
102
110
|
**dest** (`string`): Destination file path
|
|
103
111
|
|
|
104
|
-
**options
|
|
112
|
+
**options** (`Options`): Configuration options.
|
|
113
|
+
|
|
114
|
+
**options.overwrite** (`boolean`): Overwrite destination if it exists
|
|
105
115
|
|
|
106
116
|
### `readdir(path, options?)`
|
|
107
117
|
|
|
@@ -137,7 +147,9 @@ await filesystem.mkdir('/deeply/nested/path', { recursive: true })
|
|
|
137
147
|
|
|
138
148
|
**path** (`string`): Directory path
|
|
139
149
|
|
|
140
|
-
**options
|
|
150
|
+
**options** (`Options`): Configuration options.
|
|
151
|
+
|
|
152
|
+
**options.recursive** (`boolean`): Create parent directories
|
|
141
153
|
|
|
142
154
|
### `rmdir(path, options?)`
|
|
143
155
|
|
|
@@ -152,9 +164,11 @@ await filesystem.rmdir('/docs/nested', { recursive: true })
|
|
|
152
164
|
|
|
153
165
|
**path** (`string`): Directory path
|
|
154
166
|
|
|
155
|
-
**options
|
|
167
|
+
**options** (`Options`): Configuration options.
|
|
168
|
+
|
|
169
|
+
**options.recursive** (`boolean`): Remove contents recursively
|
|
156
170
|
|
|
157
|
-
**options.force** (`boolean`): Don't throw if directory doesn't exist
|
|
171
|
+
**options.force** (`boolean`): Don't throw if directory doesn't exist
|
|
158
172
|
|
|
159
173
|
### `exists(path)`
|
|
160
174
|
|
|
@@ -6,10 +6,30 @@ Stores files in Google Cloud Storage.
|
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
|
+
**npm**:
|
|
10
|
+
|
|
9
11
|
```bash
|
|
10
12
|
npm install @mastra/gcs
|
|
11
13
|
```
|
|
12
14
|
|
|
15
|
+
**pnpm**:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @mastra/gcs
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Yarn**:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
yarn add @mastra/gcs
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Bun**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
bun add @mastra/gcs
|
|
31
|
+
```
|
|
32
|
+
|
|
13
33
|
## Usage
|
|
14
34
|
|
|
15
35
|
Add a `GCSFilesystem` to a workspace and assign it to an agent:
|