@mastra/vercel 1.5.0-alpha.0 → 1.5.0-alpha.1
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/README.md +12 -179
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -4,199 +4,32 @@ Vercel workspace sandbox providers for Mastra.
|
|
|
4
4
|
|
|
5
5
|
This package exposes two Vercel-backed sandbox implementations:
|
|
6
6
|
|
|
7
|
-
- `VercelSandbox` runs commands in a Vercel Sandbox (MicroVM).
|
|
8
|
-
- `VercelServerlessSandbox` runs commands as stateless Vercel Functions.
|
|
9
|
-
|
|
10
|
-
Use `VercelSandbox` when you need a Linux environment with a filesystem, exposed ports, or background processes. Use `VercelServerlessSandbox` when you need short-lived, stateless command execution backed by Vercel Functions.
|
|
11
|
-
|
|
12
7
|
## Installation
|
|
13
8
|
|
|
14
9
|
```bash
|
|
15
10
|
npm install @mastra/vercel
|
|
16
11
|
```
|
|
17
12
|
|
|
18
|
-
##
|
|
19
|
-
|
|
20
|
-
`VercelSandbox` executes commands inside [Vercel Sandbox](https://vercel.com/docs/sandbox), an ephemeral Firecracker MicroVM running Amazon Linux 2023.
|
|
21
|
-
|
|
22
|
-
Use it when your agent or workflow needs:
|
|
23
|
-
|
|
24
|
-
- a Linux filesystem for the sandbox session
|
|
25
|
-
- `sudo` access
|
|
26
|
-
- exposed ports for preview servers
|
|
27
|
-
- background processes
|
|
28
|
-
- command execution with streamed output
|
|
29
|
-
|
|
30
|
-
```typescript
|
|
31
|
-
import { Workspace } from '@mastra/core/workspace';
|
|
32
|
-
import { VercelSandbox } from '@mastra/vercel';
|
|
33
|
-
|
|
34
|
-
const workspace = new Workspace({
|
|
35
|
-
sandbox: new VercelSandbox({
|
|
36
|
-
runtime: 'node24',
|
|
37
|
-
timeout: 600_000,
|
|
38
|
-
}),
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const result = await workspace.sandbox.executeCommand('node', ['--version']);
|
|
42
|
-
console.log(result.stdout);
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### Authentication
|
|
46
|
-
|
|
47
|
-
When Vercel OIDC is available, `VercelSandbox` can authenticate automatically. Outside an OIDC environment, provide Vercel credentials directly or through environment variables:
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
export VERCEL_TOKEN="..."
|
|
51
|
-
export VERCEL_TEAM_ID="team_..."
|
|
52
|
-
export VERCEL_PROJECT_ID="prj_..."
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
const sandbox = new VercelSandbox({
|
|
57
|
-
token: process.env.VERCEL_TOKEN,
|
|
58
|
-
teamId: process.env.VERCEL_TEAM_ID,
|
|
59
|
-
projectId: process.env.VERCEL_PROJECT_ID,
|
|
60
|
-
});
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### Resources and exposed ports
|
|
64
|
-
|
|
65
|
-
Use `resources.vcpus` to request CPU capacity and `ports` to expose services from the sandbox.
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
const sandbox = new VercelSandbox({
|
|
69
|
-
resources: { vcpus: 4 },
|
|
70
|
-
ports: [3000],
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
await sandbox.start();
|
|
74
|
-
await sandbox.executeCommand('npm', ['run', 'dev'], { background: true });
|
|
75
|
-
|
|
76
|
-
const info = await sandbox.getInfo();
|
|
77
|
-
console.log(info.metadata.domains);
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Vercel supports up to 32 vCPUs and up to 15 exposed ports per sandbox. Memory is allocated at 2048 MB per vCPU.
|
|
81
|
-
|
|
82
|
-
### Streaming command output
|
|
83
|
-
|
|
84
|
-
```typescript
|
|
85
|
-
const result = await sandbox.executeCommand('npm', ['test'], {
|
|
86
|
-
onStdout: chunk => process.stdout.write(chunk),
|
|
87
|
-
onStderr: chunk => process.stderr.write(chunk),
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
console.log(result.exitCode);
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### Background processes
|
|
94
|
-
|
|
95
|
-
`VercelSandbox` includes `VercelSandboxProcessManager`, so you can start and manage background processes.
|
|
13
|
+
## Usage
|
|
96
14
|
|
|
97
15
|
```typescript
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
console.log(process.pid);
|
|
101
|
-
|
|
102
|
-
await process.kill();
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### Options
|
|
106
|
-
|
|
107
|
-
| Option | Type | Default | Description |
|
|
108
|
-
| -------------- | -------------------------------------------------- | -------------------- | ------------------------------------------------------------- |
|
|
109
|
-
| `id` | `string` | generated | Unique identifier for this sandbox instance. |
|
|
110
|
-
| `sandboxName` | `string` | generated by Vercel | Optional sandbox name passed to the Vercel API. |
|
|
111
|
-
| `token` | `string` | `VERCEL_TOKEN` | Vercel API token. Omit when OIDC authentication is available. |
|
|
112
|
-
| `teamId` | `string` | `VERCEL_TEAM_ID` | Vercel team ID. |
|
|
113
|
-
| `projectId` | `string` | `VERCEL_PROJECT_ID` | Vercel project ID. |
|
|
114
|
-
| `runtime` | `'node24' \| 'node22' \| 'node26' \| 'python3.13'` | `'node24'` | Sandbox runtime. |
|
|
115
|
-
| `timeout` | `number` | `300_000` | Timeout in milliseconds before the sandbox auto-terminates. |
|
|
116
|
-
| `resources` | `{ vcpus?: number }` | `undefined` | Resources to allocate. |
|
|
117
|
-
| `ports` | `number[]` | `undefined` | Ports to expose from the sandbox. |
|
|
118
|
-
| `env` | `Record<string, string>` | `{}` | Default environment variables inherited by all commands. |
|
|
119
|
-
| `metadata` | `Record<string, unknown>` | `{}` | Custom metadata surfaced by `getInfo()`. |
|
|
120
|
-
| `instructions` | `string \| (opts) => string` | default instructions | Custom instructions returned by `getInstructions()`. |
|
|
121
|
-
|
|
122
|
-
## VercelServerlessSandbox
|
|
123
|
-
|
|
124
|
-
`VercelServerlessSandbox` executes commands as Vercel serverless Functions. It deploys an executor function and invokes it over HTTP.
|
|
125
|
-
|
|
126
|
-
Use it when you want short-lived command execution without managing infrastructure.
|
|
127
|
-
|
|
128
|
-
```typescript
|
|
129
|
-
import { Workspace } from '@mastra/core/workspace';
|
|
130
|
-
import { VercelServerlessSandbox } from '@mastra/vercel';
|
|
131
|
-
|
|
132
|
-
const workspace = new Workspace({
|
|
133
|
-
sandbox: new VercelServerlessSandbox({
|
|
134
|
-
token: process.env.VERCEL_TOKEN,
|
|
135
|
-
teamId: process.env.VERCEL_TEAM_ID,
|
|
136
|
-
regions: ['iad1'],
|
|
137
|
-
maxDuration: 60,
|
|
138
|
-
memory: 1024,
|
|
139
|
-
}),
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
const result = await workspace.sandbox.executeCommand('node', ['--version']);
|
|
143
|
-
console.log(result.stdout);
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
### Authentication
|
|
147
|
-
|
|
148
|
-
`VercelServerlessSandbox` requires a Vercel API token. Pass `token` or set `VERCEL_TOKEN`.
|
|
149
|
-
|
|
150
|
-
```bash
|
|
151
|
-
export VERCEL_TOKEN="..."
|
|
152
|
-
```
|
|
16
|
+
import { MastraEditor } from '@mastra/core/editor';
|
|
17
|
+
import { vercelSandboxProvider, vercelServerlessSandboxProvider } from '@mastra/vercel';
|
|
153
18
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
token: process.env.VERCEL_TOKEN,
|
|
157
|
-
teamId: process.env.VERCEL_TEAM_ID,
|
|
19
|
+
const editor = new MastraEditor({
|
|
20
|
+
sandboxes: [vercelSandboxProvider, vercelServerlessSandboxProvider],
|
|
158
21
|
});
|
|
159
22
|
```
|
|
160
23
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
| Option | Type | Default | Description |
|
|
164
|
-
| ---------------- | ---------------------------- | -------------------- | -------------------------------------------------------- |
|
|
165
|
-
| `token` | `string` | `VERCEL_TOKEN` | Vercel API token. |
|
|
166
|
-
| `teamId` | `string` | `undefined` | Vercel team ID for team-scoped deployments. |
|
|
167
|
-
| `projectName` | `string` | generated | Existing Vercel project name. Auto-generated if omitted. |
|
|
168
|
-
| `regions` | `string[]` | `['iad1']` | Deployment regions. |
|
|
169
|
-
| `maxDuration` | `number` | `60` | Function max duration in seconds. |
|
|
170
|
-
| `memory` | `number` | `1024` | Function memory in MB. |
|
|
171
|
-
| `env` | `Record<string, string>` | `{}` | Environment variables baked into the deployed function. |
|
|
172
|
-
| `commandTimeout` | `number` | `55_000` | Per-invocation command timeout in milliseconds. |
|
|
173
|
-
| `instructions` | `string \| (opts) => string` | default instructions | Custom instructions returned by `getInstructions()`. |
|
|
174
|
-
|
|
175
|
-
### Limitations
|
|
176
|
-
|
|
177
|
-
`VercelServerlessSandbox` is stateless. It doesn't provide:
|
|
24
|
+
## Documentation
|
|
178
25
|
|
|
179
|
-
-
|
|
180
|
-
-
|
|
181
|
-
- long-running background processes
|
|
182
|
-
- mounted directories
|
|
26
|
+
- [Vercel Sandbox integration guide](https://mastra.ai/integrations/sandboxes/vercel)
|
|
27
|
+
- [Workspace documentation](https://mastra.ai/docs/mastra-platform/workspaces)
|
|
183
28
|
|
|
184
|
-
|
|
29
|
+
## Changelog
|
|
185
30
|
|
|
186
|
-
|
|
31
|
+
See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/workspaces/vercel/CHANGELOG.md) for version history and release notes.
|
|
187
32
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
```typescript
|
|
191
|
-
import { MastraEditor } from '@mastra/core/editor';
|
|
192
|
-
import { vercelSandboxProvider, vercelServerlessSandboxProvider } from '@mastra/vercel';
|
|
193
|
-
|
|
194
|
-
const editor = new MastraEditor({
|
|
195
|
-
sandboxes: [vercelSandboxProvider, vercelServerlessSandboxProvider],
|
|
196
|
-
});
|
|
197
|
-
```
|
|
33
|
+
## Support
|
|
198
34
|
|
|
199
|
-
|
|
200
|
-
| --------------------------------- | ------------------- | ------------------------- |
|
|
201
|
-
| `vercelSandboxProvider` | `vercel-sandbox` | `VercelSandbox` |
|
|
202
|
-
| `vercelServerlessSandboxProvider` | `vercel-serverless` | `VercelServerlessSandbox` |
|
|
35
|
+
We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/vercel",
|
|
3
|
-
"version": "1.5.0-alpha.
|
|
3
|
+
"version": "1.5.0-alpha.1",
|
|
4
4
|
"description": "Vercel serverless sandbox provider for Mastra workspaces",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"tsdown": "0.22.9",
|
|
32
32
|
"typescript": "^7.0.2",
|
|
33
33
|
"vitest": "4.1.10",
|
|
34
|
-
"@internal/lint": "0.0.129",
|
|
35
34
|
"@internal/types-builder": "0.0.104",
|
|
36
|
-
"@
|
|
35
|
+
"@internal/lint": "0.0.129",
|
|
36
|
+
"@mastra/core": "1.64.0-alpha.7"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@mastra/core": ">=1.12.0-0 <2.0.0-0"
|