@ai-sdk/sandbox-vercel 0.0.0-6b196531-20260710185421

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 ADDED
@@ -0,0 +1,384 @@
1
+ # @ai-sdk/sandbox-vercel
2
+
3
+ ## 0.0.0-6b196531-20260710185421
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [036463b]
8
+ - Updated dependencies [9988975]
9
+ - @ai-sdk/provider-utils@0.0.0-6b196531-20260710185421
10
+ - @ai-sdk/harness@0.0.0-6b196531-20260710185421
11
+
12
+ ## 1.0.25
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [44e988a]
17
+ - @ai-sdk/harness@1.0.25
18
+
19
+ ## 1.0.24
20
+
21
+ ### Patch Changes
22
+
23
+ - @ai-sdk/harness@1.0.24
24
+
25
+ ## 1.0.23
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [39c8276]
30
+ - Updated dependencies [91fe6d8]
31
+ - Updated dependencies [0be5014]
32
+ - @ai-sdk/harness@1.0.23
33
+
34
+ ## 1.0.22
35
+
36
+ ### Patch Changes
37
+
38
+ - @ai-sdk/harness@1.0.22
39
+ - @ai-sdk/provider-utils@5.0.7
40
+
41
+ ## 1.0.21
42
+
43
+ ### Patch Changes
44
+
45
+ - Updated dependencies [ac306ed]
46
+ - @ai-sdk/provider-utils@5.0.6
47
+ - @ai-sdk/harness@1.0.21
48
+
49
+ ## 1.0.20
50
+
51
+ ### Patch Changes
52
+
53
+ - Updated dependencies [b7aa06a]
54
+ - @ai-sdk/harness@1.0.20
55
+
56
+ ## 1.0.19
57
+
58
+ ### Patch Changes
59
+
60
+ - @ai-sdk/harness@1.0.19
61
+
62
+ ## 1.0.18
63
+
64
+ ### Patch Changes
65
+
66
+ - @ai-sdk/harness@1.0.18
67
+
68
+ ## 1.0.17
69
+
70
+ ### Patch Changes
71
+
72
+ - Updated dependencies [5c5c0f5]
73
+ - @ai-sdk/provider-utils@5.0.5
74
+ - @ai-sdk/harness@1.0.17
75
+
76
+ ## 1.0.16
77
+
78
+ ### Patch Changes
79
+
80
+ - @ai-sdk/harness@1.0.16
81
+
82
+ ## 1.0.15
83
+
84
+ ### Patch Changes
85
+
86
+ - Updated dependencies [c6f5e62]
87
+ - @ai-sdk/provider-utils@5.0.4
88
+ - @ai-sdk/harness@1.0.15
89
+
90
+ ## 1.0.14
91
+
92
+ ### Patch Changes
93
+
94
+ - @ai-sdk/harness@1.0.14
95
+
96
+ ## 1.0.13
97
+
98
+ ### Patch Changes
99
+
100
+ - Updated dependencies [8c616f0]
101
+ - @ai-sdk/provider-utils@5.0.3
102
+ - @ai-sdk/harness@1.0.13
103
+
104
+ ## 1.0.12
105
+
106
+ ### Patch Changes
107
+
108
+ - Updated dependencies [7859cea]
109
+ - Updated dependencies [c857346]
110
+ - @ai-sdk/harness@1.0.12
111
+
112
+ ## 1.0.11
113
+
114
+ ### Patch Changes
115
+
116
+ - @ai-sdk/harness@1.0.11
117
+
118
+ ## 1.0.10
119
+
120
+ ### Patch Changes
121
+
122
+ - @ai-sdk/harness@1.0.10
123
+ - @ai-sdk/provider-utils@5.0.2
124
+
125
+ ## 1.0.9
126
+
127
+ ### Patch Changes
128
+
129
+ - @ai-sdk/harness@1.0.9
130
+
131
+ ## 1.0.8
132
+
133
+ ### Patch Changes
134
+
135
+ - @ai-sdk/harness@1.0.8
136
+
137
+ ## 1.0.7
138
+
139
+ ### Patch Changes
140
+
141
+ - @ai-sdk/harness@1.0.7
142
+
143
+ ## 1.0.6
144
+
145
+ ### Patch Changes
146
+
147
+ - Updated dependencies [6a436e3]
148
+ - @ai-sdk/provider-utils@5.0.1
149
+ - @ai-sdk/harness@1.0.6
150
+
151
+ ## 1.0.5
152
+
153
+ ### Patch Changes
154
+
155
+ - @ai-sdk/harness@1.0.5
156
+
157
+ ## 1.0.4
158
+
159
+ ### Patch Changes
160
+
161
+ - Updated dependencies [c493634]
162
+ - @ai-sdk/harness@1.0.4
163
+
164
+ ## 1.0.3
165
+
166
+ ### Patch Changes
167
+
168
+ - Updated dependencies [51d10a0]
169
+ - @ai-sdk/harness@1.0.3
170
+
171
+ ## 1.0.2
172
+
173
+ ### Patch Changes
174
+
175
+ - @ai-sdk/harness@1.0.2
176
+
177
+ ## 1.0.1
178
+
179
+ ### Patch Changes
180
+
181
+ - @ai-sdk/harness@1.0.1
182
+
183
+ ## 1.0.0
184
+
185
+ ### Major Changes
186
+
187
+ - 9d6dbe0: feat(harness): add sandbox specific expansion for harness abstraction, add `sandbox-just-bash` and `sandbox-vercel`
188
+
189
+ ### Patch Changes
190
+
191
+ - 6c7a3e5: Start the `1.0.0` canary release line for the experimental harness and sandbox packages. They were unintentionally published as `0.0.0-canary.*` because they were scaffolded with a `0.0.0-canary.0` premajor version, which semver could not advance past on a major bump.
192
+ - b8396f0: trigger initial beta release
193
+ - e551763: fix(harness): avoid using peer dependencies for underlying harness and sandbox SDKs
194
+
195
+ ## 1.0.0-beta.27
196
+
197
+ ### Patch Changes
198
+
199
+ - @ai-sdk/harness@1.0.0-beta.27
200
+
201
+ ## 1.0.0-beta.26
202
+
203
+ ### Patch Changes
204
+
205
+ - Updated dependencies [a83a367]
206
+ - @ai-sdk/harness@1.0.0-beta.26
207
+
208
+ ## 1.0.0-beta.25
209
+
210
+ ### Patch Changes
211
+
212
+ - @ai-sdk/harness@1.0.0-beta.25
213
+
214
+ ## 1.0.0-beta.24
215
+
216
+ ### Patch Changes
217
+
218
+ - @ai-sdk/harness@1.0.0-beta.24
219
+
220
+ ## 1.0.0-beta.23
221
+
222
+ ### Patch Changes
223
+
224
+ - Updated dependencies [57e0a59]
225
+ - @ai-sdk/harness@1.0.0-beta.23
226
+
227
+ ## 1.0.0-beta.22
228
+
229
+ ### Patch Changes
230
+
231
+ - @ai-sdk/harness@1.0.0-beta.22
232
+ - @ai-sdk/provider-utils@5.0.0-beta.50
233
+
234
+ ## 1.0.0-beta.21
235
+
236
+ ### Patch Changes
237
+
238
+ - @ai-sdk/harness@1.0.0-beta.21
239
+
240
+ ## 1.0.0-beta.20
241
+
242
+ ### Patch Changes
243
+
244
+ - Updated dependencies [e5d4a24]
245
+ - @ai-sdk/harness@1.0.0-beta.20
246
+
247
+ ## 1.0.0-beta.19
248
+
249
+ ### Patch Changes
250
+
251
+ - @ai-sdk/harness@1.0.0-beta.19
252
+
253
+ ## 1.0.0-beta.18
254
+
255
+ ### Patch Changes
256
+
257
+ - @ai-sdk/harness@1.0.0-beta.18
258
+
259
+ ## 1.0.0-beta.17
260
+
261
+ ### Patch Changes
262
+
263
+ - Updated dependencies [534dac6]
264
+ - @ai-sdk/harness@1.0.0-beta.17
265
+
266
+ ## 1.0.0-beta.16
267
+
268
+ ### Patch Changes
269
+
270
+ - @ai-sdk/harness@1.0.0-beta.16
271
+
272
+ ## 1.0.0-beta.15
273
+
274
+ ### Patch Changes
275
+
276
+ - @ai-sdk/harness@1.0.0-beta.15
277
+
278
+ ## 1.0.0-beta.14
279
+
280
+ ### Patch Changes
281
+
282
+ - b8396f0: trigger initial beta release
283
+ - Updated dependencies [b8396f0]
284
+ - @ai-sdk/harness@1.0.0-beta.14
285
+ - @ai-sdk/provider-utils@5.0.0-beta.49
286
+
287
+ ## 1.0.0-canary.13
288
+
289
+ ### Patch Changes
290
+
291
+ - @ai-sdk/harness@1.0.0-canary.13
292
+
293
+ ## 1.0.0-canary.12
294
+
295
+ ### Patch Changes
296
+
297
+ - @ai-sdk/harness@1.0.0-canary.12
298
+
299
+ ## 1.0.0-canary.11
300
+
301
+ ### Patch Changes
302
+
303
+ - Updated dependencies [be83911]
304
+ - @ai-sdk/harness@1.0.0-canary.11
305
+
306
+ ## 1.0.0-canary.10
307
+
308
+ ### Patch Changes
309
+
310
+ - @ai-sdk/harness@1.0.0-canary.10
311
+
312
+ ## 1.0.0-canary.9
313
+
314
+ ### Patch Changes
315
+
316
+ - @ai-sdk/harness@1.0.0-canary.9
317
+
318
+ ## 1.0.0-canary.8
319
+
320
+ ### Patch Changes
321
+
322
+ - Updated dependencies [aae0138]
323
+ - @ai-sdk/harness@1.0.0-canary.8
324
+
325
+ ## 1.0.0-canary.7
326
+
327
+ ### Patch Changes
328
+
329
+ - e551763: fix(harness): avoid using peer dependencies for underlying harness and sandbox SDKs
330
+ - Updated dependencies [3d87086]
331
+ - Updated dependencies [aeda373]
332
+ - Updated dependencies [1ea15a3]
333
+ - Updated dependencies [375fdd7]
334
+ - Updated dependencies [b4507d5]
335
+ - @ai-sdk/harness@1.0.0-canary.7
336
+ - @ai-sdk/provider-utils@5.0.0-canary.48
337
+
338
+ ## 1.0.0-canary.6
339
+
340
+ ### Patch Changes
341
+
342
+ - @ai-sdk/harness@1.0.0-canary.6
343
+
344
+ ## 1.0.0-canary.5
345
+
346
+ ### Patch Changes
347
+
348
+ - Updated dependencies [d77bed4]
349
+ - Updated dependencies [bae5e2b]
350
+ - @ai-sdk/harness@1.0.0-canary.5
351
+ - @ai-sdk/provider-utils@5.0.0-canary.47
352
+
353
+ ## 1.0.0-canary.4
354
+
355
+ ### Patch Changes
356
+
357
+ - Updated dependencies [3d9a50c]
358
+ - @ai-sdk/harness@1.0.0-canary.4
359
+
360
+ ## 1.0.0-canary.3
361
+
362
+ ### Patch Changes
363
+
364
+ - Updated dependencies [21d3d60]
365
+ - @ai-sdk/harness@1.0.0-canary.3
366
+
367
+ ## 1.0.0-canary.2
368
+
369
+ ### Patch Changes
370
+
371
+ - 6c7a3e5: Start the `1.0.0` canary release line for the experimental harness and sandbox packages. They were unintentionally published as `0.0.0-canary.*` because they were scaffolded with a `0.0.0-canary.0` premajor version, which semver could not advance past on a major bump.
372
+ - Updated dependencies [6c7a3e5]
373
+ - @ai-sdk/harness@1.0.0-canary.2
374
+
375
+ ## 0.0.0-canary.1
376
+
377
+ ### Major Changes
378
+
379
+ - 9d6dbe0: feat(harness): add sandbox specific expansion for harness abstraction, add `sandbox-just-bash` and `sandbox-vercel`
380
+
381
+ ### Patch Changes
382
+
383
+ - Updated dependencies [9d6dbe0]
384
+ - @ai-sdk/harness@0.0.0-canary.1
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023 Vercel, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # AI SDK - Vercel Sandbox
2
+
3
+ _This package is **experimental**._
4
+
5
+ `HarnessV1SandboxProvider` implementation for [Vercel Sandbox](https://vercel.com/docs/vercel-sandbox).
6
+
7
+ ## Setup
8
+
9
+ ```bash
10
+ npm i @ai-sdk/sandbox-vercel
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ The factory is synchronous. The returned provider is stable; the actual `@vercel/sandbox` `Sandbox` is created on demand inside `provider.createSession()`.
16
+
17
+ ```ts
18
+ import { createVercelSandbox } from '@ai-sdk/sandbox-vercel';
19
+
20
+ const vercelSandbox = createVercelSandbox({
21
+ runtime: 'node24',
22
+ ports: [3000],
23
+ });
24
+
25
+ const networkSandboxSession = await vercelSandbox.createSession();
26
+ const sandboxSession = networkSandboxSession.restricted();
27
+
28
+ await sandboxSession.writeTextFile({ path: 'hello.txt', content: 'hi' });
29
+
30
+ const { stdout } = await sandboxSession.run({
31
+ command: 'cat hello.txt',
32
+ });
33
+ console.log(stdout); // "hi"
34
+ await networkSandboxSession.stop();
35
+ ```
36
+
37
+ `networkSandboxSession.restricted()` is typed as `Experimental_SandboxSession`, so it's safe to pass to AI SDK tools that accept `experimental_sandbox`. The network sandbox session itself carries the infra surface (`ports`, `getPortUrl`, `setNetworkPolicy`, `stop`) that only the harness should reach for.
38
+
39
+ The flat-field settings are aliased directly from `@vercel/sandbox`'s `Sandbox.create` parameters, so every option Vercel supports — including its native `NetworkPolicy` — is available without re-declaration:
40
+
41
+ ```ts
42
+ const sandbox = createVercelSandbox({
43
+ runtime: 'node24',
44
+ ports: [3000],
45
+ timeout: 10 * 60 * 1000,
46
+ networkPolicy: {
47
+ allow: ['api.example.com'],
48
+ subnets: { deny: ['169.254.169.254/32'] },
49
+ },
50
+ });
51
+ ```
52
+
53
+ To wrap an already-created `@vercel/sandbox` `Sandbox` instead — e.g. when you need credentials or options outside the factory's settings, or you want to share one sandbox across multiple harness sessions — pass it via `sandbox`. Install `@vercel/sandbox` directly if your application imports `Sandbox`. The network sandbox session's `stop()` is a no-op in this case; the caller owns the lifecycle.
54
+
55
+ ```ts
56
+ import { createVercelSandbox } from '@ai-sdk/sandbox-vercel';
57
+ import { Sandbox } from '@vercel/sandbox';
58
+
59
+ const sandbox = createVercelSandbox({
60
+ sandbox: await Sandbox.create({ runtime: 'node24', ports: [3000] }),
61
+ });
62
+ ```
63
+
64
+ ### Mid-session network policy
65
+
66
+ Once the network sandbox session is alive, the host can update outbound network policy on the running sandbox:
67
+
68
+ ```ts
69
+ await networkSandboxSession.setNetworkPolicy?.({
70
+ mode: 'custom',
71
+ allowedHosts: ['api.example.com'],
72
+ deniedCIDRs: ['169.254.169.254/32'],
73
+ });
74
+ ```
75
+
76
+ `HarnessV1NetworkPolicy` is the harness-level abstraction used here. The provider translates it to `@vercel/sandbox`'s native `NetworkPolicy` for enforcement.
@@ -0,0 +1,77 @@
1
+ import { HarnessV1SandboxProvider, HarnessV1NetworkSandboxSession } from '@ai-sdk/harness';
2
+ import { Experimental_SandboxSession } from '@ai-sdk/provider-utils';
3
+ import { Sandbox } from '@vercel/sandbox';
4
+
5
+ /**
6
+ * Flattens an intersection of object types into a single object type so the
7
+ * resolved shape displays as its named properties rather than a chain of
8
+ * `A & B & C`.
9
+ */
10
+ type Prettify<T> = {
11
+ [K in keyof T]: T[K];
12
+ } & {};
13
+ /**
14
+ * Distributes `Omit` across each member of a union instead of collapsing the
15
+ * union to its common keys. `Sandbox.create`'s parameter is a union (a
16
+ * git/tarball/no-source create variant and a snapshot-source create variant),
17
+ * so a plain `Omit` would discard keys absent from any one member (e.g.
18
+ * `runtime`, which the snapshot variant lacks) and merge the `source` shapes.
19
+ * Applying `Omit` per-member preserves every variant intact; the `Prettify`
20
+ * wrapper collapses each member's intersections into a readable object shape.
21
+ */
22
+ type DistributiveOmit<T, K extends keyof any> = T extends unknown ? Prettify<Omit<T, K>> : never;
23
+ /**
24
+ * Parameters forwarded to `@vercel/sandbox`'s `Sandbox.create` when creating
25
+ * a sandbox from scratch. Aliased directly from the underlying SDK so the
26
+ * full surface — every option Vercel supports, including its native
27
+ * `NetworkPolicy` — is available without us re-declaring it.
28
+ */
29
+ type VercelSandboxCreateParams = DistributiveOmit<NonNullable<Parameters<typeof Sandbox.create>[0]>, 'onResume'>;
30
+ /**
31
+ * Settings for {@link createVercelSandbox}. Two mutually-exclusive shapes:
32
+ *
33
+ * - `{ sandbox }` — wrap an already-created `@vercel/sandbox` `Sandbox`. The
34
+ * caller owns its lifecycle; the provider's `stop()` and `destroy()` are
35
+ * no-ops. Optionally declare `bridgePorts` to give the harness a port pool to
36
+ * lease from for concurrent sessions on the same provided sandbox.
37
+ * - {@link VercelSandboxCreateParams} fields — provider creates the underlying
38
+ * sandbox. When the adapter declares a bootstrap recipe the provider uses
39
+ * `Sandbox.getOrCreate` to maintain a persistent named template snapshot
40
+ * keyed by the recipe identity, and forks an ephemeral sandbox per session
41
+ * from the snapshot. Use `name` to override the auto-derived template name.
42
+ */
43
+ type VercelSandboxSettings = {
44
+ sandbox: Sandbox;
45
+ bridgePorts?: ReadonlyArray<number>;
46
+ } | (VercelSandboxCreateParams & {
47
+ sandbox?: never;
48
+ name?: string;
49
+ });
50
+ declare function createVercelSandbox(settings?: VercelSandboxSettings): HarnessV1SandboxProvider;
51
+ /**
52
+ * `HarnessV1SandboxProvider` implementation backed by `@vercel/sandbox`.
53
+ * Construct one via {@link createVercelSandbox} at module scope and pass it
54
+ * to a `HarnessAgent` (or call `createSession()` directly if you want raw
55
+ * access to a network sandbox session).
56
+ */
57
+ declare class VercelSandboxProvider implements HarnessV1SandboxProvider {
58
+ private readonly settings;
59
+ readonly specificationVersion: "harness-sandbox-v1";
60
+ readonly providerId = "vercel-sandbox";
61
+ readonly bridgePorts?: ReadonlyArray<number>;
62
+ constructor(settings: VercelSandboxSettings);
63
+ createSession: (options?: {
64
+ sessionId?: string;
65
+ abortSignal?: AbortSignal;
66
+ identity?: string;
67
+ onFirstCreate?: (session: Experimental_SandboxSession, opts: {
68
+ abortSignal?: AbortSignal;
69
+ }) => Promise<void>;
70
+ }) => Promise<HarnessV1NetworkSandboxSession>;
71
+ resumeSession: (options: {
72
+ sessionId: string;
73
+ abortSignal?: AbortSignal;
74
+ }) => Promise<HarnessV1NetworkSandboxSession>;
75
+ }
76
+
77
+ export { VercelSandboxProvider, type VercelSandboxSettings, createVercelSandbox };