@mastra/vercel 1.1.1 → 1.2.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/CHANGELOG.md +108 -0
- package/README.md +202 -0
- package/dist/index.cjs +30 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -38
- package/dist/index.js.map +1 -1
- package/dist/microvm/index.d.ts +12 -14
- package/dist/microvm/index.d.ts.map +1 -1
- package/dist/microvm/process-manager.d.ts +3 -3
- package/dist/microvm/process-manager.d.ts.map +1 -1
- package/dist/microvm-provider.d.ts +5 -5
- package/dist/microvm-provider.d.ts.map +1 -1
- package/dist/{sandbox → serverless}/index.d.ts +6 -9
- package/dist/serverless/index.d.ts.map +1 -0
- package/dist/{provider.d.ts → serverless-provider.d.ts} +6 -6
- package/dist/serverless-provider.d.ts.map +1 -0
- package/package.json +4 -4
- package/dist/provider.d.ts.map +0 -1
- package/dist/sandbox/index.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,113 @@
|
|
|
1
1
|
# @mastra/vercel
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- **Breaking change:** Renamed the Vercel sandbox exports to make the MicroVM and serverless implementations explicit. `VercelSandbox` now refers to the MicroVM-backed Vercel Sandbox product. The serverless implementation is now exported as `VercelServerlessSandbox`. ([#18667](https://github.com/mastra-ai/mastra/pull/18667))
|
|
8
|
+
- If you have been using `VercelSandbox` in your code, you should update your imports to use `VercelServerlessSandbox` instead.
|
|
9
|
+
|
|
10
|
+
```diff
|
|
11
|
+
-import { VercelSandbox } from '@mastra/vercel';
|
|
12
|
+
-import type { VercelSandboxOptions } from '@mastra/vercel';
|
|
13
|
+
+import { VercelServerlessSandbox } from '@mastra/vercel';
|
|
14
|
+
+import type { VercelServerlessSandboxOptions } from '@mastra/vercel';
|
|
15
|
+
|
|
16
|
+
-const sandbox = new VercelSandbox({
|
|
17
|
+
+const sandbox = new VercelServerlessSandbox({
|
|
18
|
+
token: process.env.VERCEL_TOKEN,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
-const options: VercelSandboxOptions = {
|
|
22
|
+
+const options: VercelServerlessSandboxOptions = {
|
|
23
|
+
token: process.env.VERCEL_TOKEN,
|
|
24
|
+
};
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- If you have been using `VercelMicroVMSandbox` in your code, you should update your imports to use `VercelSandbox` instead.
|
|
28
|
+
|
|
29
|
+
```diff
|
|
30
|
+
-import { VercelMicroVMSandbox } from '@mastra/vercel';
|
|
31
|
+
+import { VercelSandbox } from '@mastra/vercel';
|
|
32
|
+
-import type { VercelMicroVMSandboxOptions } from '@mastra/vercel';
|
|
33
|
+
+import type { VercelSandboxOptions } from '@mastra/vercel';
|
|
34
|
+
|
|
35
|
+
-const sandbox = new VercelMicroVMSandbox();
|
|
36
|
+
+const sandbox = new VercelSandbox();
|
|
37
|
+
|
|
38
|
+
-const options: VercelMicroVMSandboxOptions = {
|
|
39
|
+
+const options: VercelSandboxOptions = {
|
|
40
|
+
runtime: 'node24',
|
|
41
|
+
};
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- Provider descriptors are also split by runtime:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { vercelSandboxProvider, vercelServerlessSandboxProvider } from '@mastra/vercel';
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Use `vercelSandboxProvider` for MicroVM-backed Vercel Sandbox instances and `vercelServerlessSandboxProvider` for Vercel Functions-backed serverless instances.
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- Updated dependencies [[`b9a2961`](https://github.com/mastra-ai/mastra/commit/b9a2961c1be81e3639c0879e58588c26dd0ae866), [`b33c77d`](https://github.com/mastra-ai/mastra/commit/b33c77d5293f14a794f3ec38dc947a6676de2764), [`1274eb3`](https://github.com/mastra-ai/mastra/commit/1274eb3a9508f579ceb3187fbce34408222d4b71), [`cdd5f93`](https://github.com/mastra-ai/mastra/commit/cdd5f939cefa67390629704dce92563ccbf492b2), [`1274eb3`](https://github.com/mastra-ai/mastra/commit/1274eb3a9508f579ceb3187fbce34408222d4b71), [`0ac14ce`](https://github.com/mastra-ai/mastra/commit/0ac14cea48e1b0a7857782153c78f7242fdf7e1a), [`9566d27`](https://github.com/mastra-ai/mastra/commit/9566d27ead3d95bdbe5a69e5a082a68222829cf2), [`8be63b0`](https://github.com/mastra-ai/mastra/commit/8be63b015fb8d72cea1220f05e7dc3bb997cc249), [`1009f77`](https://github.com/mastra-ai/mastra/commit/1009f772aa40016b49267c8566d0c29f6a16aa3c), [`1b8728a`](https://github.com/mastra-ai/mastra/commit/1b8728a57fd844205a452b0b4216d20ff60c784a), [`23c31de`](https://github.com/mastra-ai/mastra/commit/23c31de96ed8153402dcf092ac84b27a0c3638c1), [`0368766`](https://github.com/mastra-ai/mastra/commit/0368766744c7ea3df4d6059e2cc15f7bdf55f5a6), [`6f578ac`](https://github.com/mastra-ai/mastra/commit/6f578acba84930b406b2a0700b17cfdfaf5aae56), [`345eecc`](https://github.com/mastra-ai/mastra/commit/345eecce6ba519b5d987f0e10b5de4c8e5734580), [`1917c53`](https://github.com/mastra-ai/mastra/commit/1917c53b19dac43926f29c496893b0686462dca4), [`c01012f`](https://github.com/mastra-ai/mastra/commit/c01012f50368d29eb3fc3764df42d48291973d23), [`705ba98`](https://github.com/mastra-ai/mastra/commit/705ba98726d388a596e896225f237907ca6807a9), [`95857bc`](https://github.com/mastra-ai/mastra/commit/95857bcd6669da7193f503e803f0d72a2bd66be6), [`e62c108`](https://github.com/mastra-ai/mastra/commit/e62c108409dfd6a6cac0a48ec39c5cc81d24fd52), [`2866f04`](https://github.com/mastra-ai/mastra/commit/2866f04953edb78c1637fa45cc53abe24122edcb), [`ee14cae`](https://github.com/mastra-ai/mastra/commit/ee14cae244805783bde518a6142de28b744b169c), [`e84e791`](https://github.com/mastra-ai/mastra/commit/e84e79174031d7bc8793ca6c805eb38b06e7cfb1), [`c2f0b7f`](https://github.com/mastra-ai/mastra/commit/c2f0b7f1370f4428d165f51f0d1d9a48331cc257), [`213feb8`](https://github.com/mastra-ai/mastra/commit/213feb87bfdd1d8ec00ea660e218f9bcfcb34e7b), [`58e287b`](https://github.com/mastra-ai/mastra/commit/58e287b1edaf978b13745a1795989cad3826e82b), [`e420b3c`](https://github.com/mastra-ai/mastra/commit/e420b3c3ffc98bbc5b791897ea390bb47af99696), [`be875ed`](https://github.com/mastra-ai/mastra/commit/be875ed43f856742ce58529f531b5ea0ae6911f3), [`9eefdc0`](https://github.com/mastra-ai/mastra/commit/9eefdc0ac03f989718c6d835334940a977938895), [`bfbbb01`](https://github.com/mastra-ai/mastra/commit/bfbbb01bd845ba54cdc0c678c277d08a7cb847e4), [`7d112ca`](https://github.com/mastra-ai/mastra/commit/7d112ca17078479b2659b88ba1c85b936cfc111c)]:
|
|
55
|
+
- @mastra/core@1.48.0
|
|
56
|
+
|
|
57
|
+
## 1.2.0-alpha.0
|
|
58
|
+
|
|
59
|
+
### Minor Changes
|
|
60
|
+
|
|
61
|
+
- **Breaking change:** Renamed the Vercel sandbox exports to make the MicroVM and serverless implementations explicit. `VercelSandbox` now refers to the MicroVM-backed Vercel Sandbox product. The serverless implementation is now exported as `VercelServerlessSandbox`. ([#18667](https://github.com/mastra-ai/mastra/pull/18667))
|
|
62
|
+
- If you have been using `VercelSandbox` in your code, you should update your imports to use `VercelServerlessSandbox` instead.
|
|
63
|
+
|
|
64
|
+
```diff
|
|
65
|
+
-import { VercelSandbox } from '@mastra/vercel';
|
|
66
|
+
-import type { VercelSandboxOptions } from '@mastra/vercel';
|
|
67
|
+
+import { VercelServerlessSandbox } from '@mastra/vercel';
|
|
68
|
+
+import type { VercelServerlessSandboxOptions } from '@mastra/vercel';
|
|
69
|
+
|
|
70
|
+
-const sandbox = new VercelSandbox({
|
|
71
|
+
+const sandbox = new VercelServerlessSandbox({
|
|
72
|
+
token: process.env.VERCEL_TOKEN,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
-const options: VercelSandboxOptions = {
|
|
76
|
+
+const options: VercelServerlessSandboxOptions = {
|
|
77
|
+
token: process.env.VERCEL_TOKEN,
|
|
78
|
+
};
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
- If you have been using `VercelMicroVMSandbox` in your code, you should update your imports to use `VercelSandbox` instead.
|
|
82
|
+
|
|
83
|
+
```diff
|
|
84
|
+
-import { VercelMicroVMSandbox } from '@mastra/vercel';
|
|
85
|
+
+import { VercelSandbox } from '@mastra/vercel';
|
|
86
|
+
-import type { VercelMicroVMSandboxOptions } from '@mastra/vercel';
|
|
87
|
+
+import type { VercelSandboxOptions } from '@mastra/vercel';
|
|
88
|
+
|
|
89
|
+
-const sandbox = new VercelMicroVMSandbox();
|
|
90
|
+
+const sandbox = new VercelSandbox();
|
|
91
|
+
|
|
92
|
+
-const options: VercelMicroVMSandboxOptions = {
|
|
93
|
+
+const options: VercelSandboxOptions = {
|
|
94
|
+
runtime: 'node24',
|
|
95
|
+
};
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
- Provider descriptors are also split by runtime:
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
import { vercelSandboxProvider, vercelServerlessSandboxProvider } from '@mastra/vercel';
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Use `vercelSandboxProvider` for MicroVM-backed Vercel Sandbox instances and `vercelServerlessSandboxProvider` for Vercel Functions-backed serverless instances.
|
|
105
|
+
|
|
106
|
+
### Patch Changes
|
|
107
|
+
|
|
108
|
+
- Updated dependencies [[`b33c77d`](https://github.com/mastra-ai/mastra/commit/b33c77d5293f14a794f3ec38dc947a6676de2764), [`1009f77`](https://github.com/mastra-ai/mastra/commit/1009f772aa40016b49267c8566d0c29f6a16aa3c), [`23c31de`](https://github.com/mastra-ai/mastra/commit/23c31de96ed8153402dcf092ac84b27a0c3638c1), [`0368766`](https://github.com/mastra-ai/mastra/commit/0368766744c7ea3df4d6059e2cc15f7bdf55f5a6), [`2866f04`](https://github.com/mastra-ai/mastra/commit/2866f04953edb78c1637fa45cc53abe24122edcb)]:
|
|
109
|
+
- @mastra/core@1.48.0-alpha.6
|
|
110
|
+
|
|
3
111
|
## 1.1.1
|
|
4
112
|
|
|
5
113
|
### Patch Changes
|
package/README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# @mastra/vercel
|
|
2
|
+
|
|
3
|
+
Vercel workspace sandbox providers for Mastra.
|
|
4
|
+
|
|
5
|
+
This package exposes two Vercel-backed sandbox implementations:
|
|
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
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @mastra/vercel
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## VercelSandbox
|
|
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 8 vCPUs and up to 4 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.
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
const process = await sandbox.processes.spawn('npm run dev');
|
|
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
|
+
```
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
const sandbox = new VercelServerlessSandbox({
|
|
156
|
+
token: process.env.VERCEL_TOKEN,
|
|
157
|
+
teamId: process.env.VERCEL_TEAM_ID,
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Options
|
|
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:
|
|
178
|
+
|
|
179
|
+
- a persistent filesystem
|
|
180
|
+
- an interactive shell
|
|
181
|
+
- long-running background processes
|
|
182
|
+
- mounted directories
|
|
183
|
+
|
|
184
|
+
Only `/tmp` is writable during a function invocation.
|
|
185
|
+
|
|
186
|
+
## Editor provider descriptors
|
|
187
|
+
|
|
188
|
+
Use the provider descriptors when registering Vercel sandboxes with the Mastra editor.
|
|
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
|
+
```
|
|
198
|
+
|
|
199
|
+
| Provider | ID | Creates |
|
|
200
|
+
| --------------------------------- | ------------------- | ------------------------- |
|
|
201
|
+
| `vercelSandboxProvider` | `vercel-sandbox` | `VercelSandbox` |
|
|
202
|
+
| `vercelServerlessSandboxProvider` | `vercel-serverless` | `VercelServerlessSandbox` |
|
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var workspace = require('@mastra/core/workspace');
|
|
4
4
|
var sandbox = require('@vercel/sandbox');
|
|
5
5
|
|
|
6
|
-
// src/
|
|
6
|
+
// src/serverless/index.ts
|
|
7
7
|
|
|
8
8
|
// src/executor/index.ts
|
|
9
9
|
function getExecutorSource(secret, env) {
|
|
@@ -82,18 +82,17 @@ module.exports = async (req, res) => {
|
|
|
82
82
|
`;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
// src/
|
|
86
|
-
var LOG_PREFIX = "[
|
|
87
|
-
var deprecatedNameWarned = false;
|
|
85
|
+
// src/serverless/index.ts
|
|
86
|
+
var LOG_PREFIX = "[VercelServerlessSandbox]";
|
|
88
87
|
var VERCEL_API_BASE = "https://api.vercel.com";
|
|
89
88
|
function shellQuote(arg) {
|
|
90
89
|
if (/^[a-zA-Z0-9._\-\/=:@]+$/.test(arg)) return arg;
|
|
91
90
|
return `'${arg.replace(/'/g, "'\\''")}'`;
|
|
92
91
|
}
|
|
93
|
-
var
|
|
92
|
+
var VercelServerlessSandbox = class extends workspace.MastraSandbox {
|
|
94
93
|
id;
|
|
95
|
-
name = "
|
|
96
|
-
provider = "vercel";
|
|
94
|
+
name = "VercelServerlessSandbox";
|
|
95
|
+
provider = "vercel-serverless";
|
|
97
96
|
status = "pending";
|
|
98
97
|
_token;
|
|
99
98
|
_teamId;
|
|
@@ -110,12 +109,8 @@ var VercelSandbox = class extends workspace.MastraSandbox {
|
|
|
110
109
|
_protectionBypass = null;
|
|
111
110
|
_createdAt = null;
|
|
112
111
|
constructor(options = {}) {
|
|
113
|
-
super({ name: "
|
|
114
|
-
|
|
115
|
-
deprecatedNameWarned = true;
|
|
116
|
-
console.warn("VercelSandbox will be renamed to VercelServerlessSandbox in a future release.");
|
|
117
|
-
}
|
|
118
|
-
this.id = `vercel-sandbox-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
112
|
+
super({ name: "VercelServerlessSandbox" });
|
|
113
|
+
this.id = `vercel-serverless-sandbox-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
119
114
|
this._token = options.token || process.env.VERCEL_TOKEN || "";
|
|
120
115
|
this._teamId = options.teamId;
|
|
121
116
|
this._projectName = options.projectName;
|
|
@@ -423,10 +418,10 @@ var VercelSandbox = class extends workspace.MastraSandbox {
|
|
|
423
418
|
}
|
|
424
419
|
};
|
|
425
420
|
|
|
426
|
-
// src/provider.ts
|
|
427
|
-
var
|
|
428
|
-
id: "vercel",
|
|
429
|
-
name: "Vercel Sandbox",
|
|
421
|
+
// src/serverless-provider.ts
|
|
422
|
+
var vercelServerlessSandboxProvider = {
|
|
423
|
+
id: "vercel-serverless",
|
|
424
|
+
name: "Vercel Sandbox (Serverless)",
|
|
430
425
|
description: "Serverless sandbox powered by Vercel Functions",
|
|
431
426
|
configSchema: {
|
|
432
427
|
type: "object",
|
|
@@ -450,9 +445,9 @@ var vercelSandboxProvider = {
|
|
|
450
445
|
commandTimeout: { type: "number", description: "Per-invocation timeout in ms", default: 55e3 }
|
|
451
446
|
}
|
|
452
447
|
},
|
|
453
|
-
createSandbox: (config) => new
|
|
448
|
+
createSandbox: (config) => new VercelServerlessSandbox(config)
|
|
454
449
|
};
|
|
455
|
-
var
|
|
450
|
+
var VercelSandboxProcessHandle = class extends workspace.ProcessHandle {
|
|
456
451
|
pid;
|
|
457
452
|
_command;
|
|
458
453
|
_startTime;
|
|
@@ -544,10 +539,10 @@ var VercelMicroVMProcessHandle = class extends workspace.ProcessHandle {
|
|
|
544
539
|
return true;
|
|
545
540
|
}
|
|
546
541
|
async sendStdin(_data) {
|
|
547
|
-
throw new Error("
|
|
542
|
+
throw new Error("VercelSandbox does not support sending stdin to running processes.");
|
|
548
543
|
}
|
|
549
544
|
};
|
|
550
|
-
var
|
|
545
|
+
var VercelSandboxProcessManager = class extends workspace.SandboxProcessManager {
|
|
551
546
|
async spawn(command, options = {}) {
|
|
552
547
|
const mergedEnv = { ...this.env, ...options.env };
|
|
553
548
|
const env = Object.fromEntries(
|
|
@@ -560,7 +555,7 @@ var VercelMicroVMProcessManager = class extends workspace.SandboxProcessManager
|
|
|
560
555
|
...Object.keys(env).length ? { env } : {},
|
|
561
556
|
detached: true
|
|
562
557
|
});
|
|
563
|
-
const handle = new
|
|
558
|
+
const handle = new VercelSandboxProcessHandle(cmd, Date.now(), options);
|
|
564
559
|
const streamingPromise = (async () => {
|
|
565
560
|
for await (const log of cmd.logs()) {
|
|
566
561
|
if (log.stream === "stdout") handle.emitStdout(log.data);
|
|
@@ -587,12 +582,11 @@ var VercelMicroVMProcessManager = class extends workspace.SandboxProcessManager
|
|
|
587
582
|
};
|
|
588
583
|
|
|
589
584
|
// src/microvm/index.ts
|
|
590
|
-
var LOG_PREFIX2 = "[
|
|
591
|
-
var
|
|
592
|
-
var VercelMicroVMSandbox = class extends workspace.MastraSandbox {
|
|
585
|
+
var LOG_PREFIX2 = "[VercelSandbox]";
|
|
586
|
+
var VercelSandbox = class extends workspace.MastraSandbox {
|
|
593
587
|
id;
|
|
594
|
-
name = "
|
|
595
|
-
provider = "vercel-
|
|
588
|
+
name = "VercelSandbox";
|
|
589
|
+
provider = "vercel-sandbox";
|
|
596
590
|
status = "pending";
|
|
597
591
|
_sandbox = null;
|
|
598
592
|
_createdAt = null;
|
|
@@ -610,14 +604,10 @@ var VercelMicroVMSandbox = class extends workspace.MastraSandbox {
|
|
|
610
604
|
constructor(options = {}) {
|
|
611
605
|
super({
|
|
612
606
|
...options,
|
|
613
|
-
name: "
|
|
614
|
-
processes: new
|
|
607
|
+
name: "VercelSandbox",
|
|
608
|
+
processes: new VercelSandboxProcessManager({ env: options.env ?? {} })
|
|
615
609
|
});
|
|
616
|
-
|
|
617
|
-
deprecatedNameWarned2 = true;
|
|
618
|
-
console.warn("VercelMicroVMSandbox will be renamed to VercelSandbox in a future release.");
|
|
619
|
-
}
|
|
620
|
-
this.id = options.id ?? `vercel-microvm-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
610
|
+
this.id = options.id ?? `vercel-sandbox-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
621
611
|
this._sandboxName = options.sandboxName;
|
|
622
612
|
this._token = options.token ?? process.env.VERCEL_TOKEN;
|
|
623
613
|
this._teamId = options.teamId ?? process.env.VERCEL_TEAM_ID;
|
|
@@ -796,8 +786,8 @@ var VercelMicroVMSandbox = class extends workspace.MastraSandbox {
|
|
|
796
786
|
};
|
|
797
787
|
|
|
798
788
|
// src/microvm-provider.ts
|
|
799
|
-
var
|
|
800
|
-
id: "vercel-
|
|
789
|
+
var vercelSandboxProvider = {
|
|
790
|
+
id: "vercel-sandbox",
|
|
801
791
|
name: "Vercel Sandbox (MicroVM)",
|
|
802
792
|
description: "Ephemeral Firecracker MicroVM sandbox powered by Vercel Sandbox",
|
|
803
793
|
configSchema: {
|
|
@@ -826,7 +816,7 @@ var vercelMicroVMSandboxProvider = {
|
|
|
826
816
|
}
|
|
827
817
|
}
|
|
828
818
|
},
|
|
829
|
-
createSandbox: (config) => new
|
|
819
|
+
createSandbox: (config) => new VercelSandbox({
|
|
830
820
|
token: config.token,
|
|
831
821
|
teamId: config.teamId,
|
|
832
822
|
projectId: config.projectId,
|
|
@@ -838,10 +828,10 @@ var vercelMicroVMSandboxProvider = {
|
|
|
838
828
|
})
|
|
839
829
|
};
|
|
840
830
|
|
|
841
|
-
exports.VercelMicroVMProcessManager = VercelMicroVMProcessManager;
|
|
842
|
-
exports.VercelMicroVMSandbox = VercelMicroVMSandbox;
|
|
843
831
|
exports.VercelSandbox = VercelSandbox;
|
|
844
|
-
exports.
|
|
832
|
+
exports.VercelSandboxProcessManager = VercelSandboxProcessManager;
|
|
833
|
+
exports.VercelServerlessSandbox = VercelServerlessSandbox;
|
|
845
834
|
exports.vercelSandboxProvider = vercelSandboxProvider;
|
|
835
|
+
exports.vercelServerlessSandboxProvider = vercelServerlessSandboxProvider;
|
|
846
836
|
//# sourceMappingURL=index.cjs.map
|
|
847
837
|
//# sourceMappingURL=index.cjs.map
|