@vercel/sandbox 2.0.0-beta.4 → 2.0.0-beta.7
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 +40 -1
- package/dist/api-client/api-client.d.ts +210 -146
- package/dist/api-client/api-client.js +58 -56
- package/dist/api-client/api-client.js.map +1 -1
- package/dist/api-client/api-error.d.ts +6 -4
- package/dist/api-client/api-error.js +4 -3
- package/dist/api-client/api-error.js.map +1 -1
- package/dist/api-client/base-client.js +24 -9
- package/dist/api-client/base-client.js.map +1 -1
- package/dist/api-client/validators.d.ts +1333 -1275
- package/dist/api-client/validators.js +28 -32
- package/dist/api-client/validators.js.map +1 -1
- package/dist/command.d.ts +9 -9
- package/dist/command.js +10 -10
- package/dist/sandbox.d.ts +167 -105
- package/dist/sandbox.js +71 -47
- package/dist/sandbox.js.map +1 -1
- package/dist/session.d.ts +7 -7
- package/dist/session.js +53 -47
- package/dist/session.js.map +1 -1
- package/dist/snapshot.d.ts +5 -5
- package/dist/snapshot.js +5 -4
- package/dist/snapshot.js.map +1 -1
- package/dist/utils/convert-sandbox.d.ts +3 -3
- package/dist/utils/convert-sandbox.js +3 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,7 +52,9 @@ async function main() {
|
|
|
52
52
|
resources: { vcpus: 4 },
|
|
53
53
|
ports: [3000],
|
|
54
54
|
runtime: "node24",
|
|
55
|
+
name: "vercel-sandbox-example",
|
|
55
56
|
});
|
|
57
|
+
console.log(`Sandbox ${sandbox.name} created`);
|
|
56
58
|
|
|
57
59
|
console.log(`Installing dependencies...`);
|
|
58
60
|
const install = await sandbox.runCommand({
|
|
@@ -62,7 +64,7 @@ async function main() {
|
|
|
62
64
|
stdout: process.stdout,
|
|
63
65
|
});
|
|
64
66
|
|
|
65
|
-
if (install.exitCode
|
|
67
|
+
if (install.exitCode !== 0) {
|
|
66
68
|
console.log("installing packages failed");
|
|
67
69
|
process.exit(1);
|
|
68
70
|
}
|
|
@@ -98,6 +100,43 @@ This will:
|
|
|
98
100
|
|
|
99
101
|
All while streaming logs to your local terminal.
|
|
100
102
|
|
|
103
|
+
Sandboxes are persistent by default. To resume a sandbox with its previous state:
|
|
104
|
+
|
|
105
|
+
Create a `resume.mts` file:
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
import { Sandbox } from "@vercel/sandbox";
|
|
109
|
+
import { setTimeout } from "timers/promises";
|
|
110
|
+
import { spawn } from "child_process";
|
|
111
|
+
|
|
112
|
+
async function main() {
|
|
113
|
+
const sandbox = await Sandbox.get({
|
|
114
|
+
name: "vercel-sandbox-example",
|
|
115
|
+
});
|
|
116
|
+
console.log(`Sandbox ${sandbox.name} resumed`);
|
|
117
|
+
|
|
118
|
+
console.log(`Starting the development server...`);
|
|
119
|
+
await sandbox.runCommand({
|
|
120
|
+
cmd: "npm",
|
|
121
|
+
args: ["run", "dev"],
|
|
122
|
+
stderr: process.stderr,
|
|
123
|
+
stdout: process.stdout,
|
|
124
|
+
detached: true,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
await setTimeout(500);
|
|
128
|
+
spawn("open", [sandbox.domain(3000)]);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
main().catch(console.error);
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Run it:
|
|
135
|
+
|
|
136
|
+
```sh
|
|
137
|
+
node --experimental-strip-types --env-file .env.local resume.mts
|
|
138
|
+
```
|
|
139
|
+
|
|
101
140
|
## Authentication
|
|
102
141
|
|
|
103
142
|
### Vercel OIDC token
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseClient, type Parsed, type RequestParams } from "./base-client";
|
|
2
|
-
import { type CommandFinishedData,
|
|
2
|
+
import { type CommandFinishedData, SessionResponse, CommandResponse, CommandFinishedResponse, type LogLineStdout, type LogLineStderr, SnapshotResponse, CreateSnapshotResponse, type CommandData } from "./validators";
|
|
3
3
|
import { FileWriter } from "./file-writer";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { Readable } from "stream";
|
|
@@ -21,11 +21,11 @@ export declare class APIClient extends BaseClient {
|
|
|
21
21
|
});
|
|
22
22
|
private ensureValidToken;
|
|
23
23
|
protected request(path: string, params?: RequestParams): Promise<Response>;
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
getSession(params: WithPrivate<{
|
|
25
|
+
sessionId: string;
|
|
26
26
|
signal?: AbortSignal;
|
|
27
27
|
}>): Promise<Parsed<{
|
|
28
|
-
|
|
28
|
+
session: {
|
|
29
29
|
id: string;
|
|
30
30
|
memory: number;
|
|
31
31
|
vcpus: number;
|
|
@@ -73,6 +73,8 @@ export declare class APIClient extends BaseClient {
|
|
|
73
73
|
ingress: number;
|
|
74
74
|
egress: number;
|
|
75
75
|
} | undefined;
|
|
76
|
+
} & {
|
|
77
|
+
[k: string]: unknown;
|
|
76
78
|
};
|
|
77
79
|
routes: {
|
|
78
80
|
url: string;
|
|
@@ -106,9 +108,10 @@ export declare class APIClient extends BaseClient {
|
|
|
106
108
|
runtime?: RUNTIMES | (string & {});
|
|
107
109
|
networkPolicy?: NetworkPolicy;
|
|
108
110
|
env?: Record<string, string>;
|
|
111
|
+
tags?: Record<string, string>;
|
|
109
112
|
signal?: AbortSignal;
|
|
110
113
|
}>): Promise<Parsed<{
|
|
111
|
-
|
|
114
|
+
session: {
|
|
112
115
|
id: string;
|
|
113
116
|
memory: number;
|
|
114
117
|
vcpus: number;
|
|
@@ -156,24 +159,27 @@ export declare class APIClient extends BaseClient {
|
|
|
156
159
|
ingress: number;
|
|
157
160
|
egress: number;
|
|
158
161
|
} | undefined;
|
|
162
|
+
} & {
|
|
163
|
+
[k: string]: unknown;
|
|
159
164
|
};
|
|
160
165
|
routes: {
|
|
161
166
|
url: string;
|
|
162
167
|
subdomain: string;
|
|
163
168
|
port: number;
|
|
164
169
|
}[];
|
|
165
|
-
|
|
166
|
-
memory: number;
|
|
167
|
-
vcpus: number;
|
|
168
|
-
region: string;
|
|
169
|
-
runtime: string;
|
|
170
|
-
timeout: number;
|
|
170
|
+
sandbox: {
|
|
171
171
|
status: "aborted" | "pending" | "running" | "stopping" | "stopped" | "failed" | "snapshotting";
|
|
172
172
|
createdAt: number;
|
|
173
173
|
updatedAt: number;
|
|
174
174
|
name: string;
|
|
175
175
|
persistent: boolean;
|
|
176
|
-
|
|
176
|
+
currentSessionId: string;
|
|
177
|
+
memory?: number | undefined;
|
|
178
|
+
vcpus?: number | undefined;
|
|
179
|
+
region?: string | undefined;
|
|
180
|
+
runtime?: string | undefined;
|
|
181
|
+
timeout?: number | undefined;
|
|
182
|
+
cwd?: string | undefined;
|
|
177
183
|
networkPolicy?: z.objectInputType<{
|
|
178
184
|
mode: z.ZodLiteral<"allow-all">;
|
|
179
185
|
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
@@ -202,10 +208,11 @@ export declare class APIClient extends BaseClient {
|
|
|
202
208
|
totalActiveCpuDurationMs?: number | undefined;
|
|
203
209
|
totalDurationMs?: number | undefined;
|
|
204
210
|
currentSnapshotId?: string | undefined;
|
|
211
|
+
tags?: Record<string, string> | undefined;
|
|
205
212
|
};
|
|
206
213
|
}>>;
|
|
207
214
|
runCommand(params: {
|
|
208
|
-
|
|
215
|
+
sessionId: string;
|
|
209
216
|
cwd?: string;
|
|
210
217
|
command: string;
|
|
211
218
|
args: string[];
|
|
@@ -218,7 +225,7 @@ export declare class APIClient extends BaseClient {
|
|
|
218
225
|
finished: Promise<CommandFinishedData>;
|
|
219
226
|
}>;
|
|
220
227
|
runCommand(params: {
|
|
221
|
-
|
|
228
|
+
sessionId: string;
|
|
222
229
|
cwd?: string;
|
|
223
230
|
command: string;
|
|
224
231
|
args: string[];
|
|
@@ -228,83 +235,91 @@ export declare class APIClient extends BaseClient {
|
|
|
228
235
|
signal?: AbortSignal;
|
|
229
236
|
}): Promise<Parsed<z.infer<typeof CommandResponse>>>;
|
|
230
237
|
getCommand(params: {
|
|
231
|
-
|
|
238
|
+
sessionId: string;
|
|
232
239
|
cmdId: string;
|
|
233
240
|
wait: true;
|
|
234
241
|
signal?: AbortSignal;
|
|
235
242
|
}): Promise<Parsed<z.infer<typeof CommandFinishedResponse>>>;
|
|
236
243
|
getCommand(params: {
|
|
237
|
-
|
|
244
|
+
sessionId: string;
|
|
238
245
|
cmdId: string;
|
|
239
246
|
wait?: boolean;
|
|
240
247
|
signal?: AbortSignal;
|
|
241
248
|
}): Promise<Parsed<z.infer<typeof CommandResponse>>>;
|
|
242
249
|
mkDir(params: {
|
|
243
|
-
|
|
250
|
+
sessionId: string;
|
|
244
251
|
path: string;
|
|
245
252
|
cwd?: string;
|
|
246
253
|
signal?: AbortSignal;
|
|
247
254
|
}): Promise<Parsed<{}>>;
|
|
248
255
|
getFileWriter(params: {
|
|
249
|
-
|
|
256
|
+
sessionId: string;
|
|
250
257
|
extractDir: string;
|
|
251
258
|
signal?: AbortSignal;
|
|
252
259
|
}): {
|
|
253
260
|
response: Promise<Response>;
|
|
254
261
|
writer: FileWriter;
|
|
255
262
|
};
|
|
256
|
-
|
|
263
|
+
listSessions(params: {
|
|
257
264
|
/**
|
|
258
|
-
* The ID or name of the project to which the
|
|
265
|
+
* The ID or name of the project to which the sessions belong.
|
|
259
266
|
* @example "my-project"
|
|
260
267
|
*/
|
|
261
268
|
projectId: string;
|
|
262
269
|
/**
|
|
263
|
-
* Filter
|
|
270
|
+
* Filter sessions by sandbox name.
|
|
264
271
|
*/
|
|
265
272
|
name?: string;
|
|
266
273
|
/**
|
|
267
|
-
* Maximum number of
|
|
274
|
+
* Maximum number of sessions to list from a request.
|
|
268
275
|
* @example 10
|
|
269
276
|
*/
|
|
270
277
|
limit?: number;
|
|
271
278
|
/**
|
|
272
|
-
* Get
|
|
279
|
+
* Get sessions created after this JavaScript timestamp.
|
|
273
280
|
* @example 1540095775941
|
|
274
281
|
*/
|
|
275
282
|
since?: number | Date;
|
|
276
283
|
/**
|
|
277
|
-
* Get
|
|
284
|
+
* Get sessions created before this JavaScript timestamp.
|
|
278
285
|
* @example 1540095775951
|
|
279
286
|
*/
|
|
280
287
|
until?: number | Date;
|
|
281
288
|
signal?: AbortSignal;
|
|
282
289
|
}): Promise<Parsed<{
|
|
283
|
-
|
|
284
|
-
id:
|
|
285
|
-
memory:
|
|
286
|
-
vcpus:
|
|
287
|
-
region:
|
|
288
|
-
runtime:
|
|
289
|
-
timeout:
|
|
290
|
-
status: "
|
|
291
|
-
requestedAt:
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
interactivePort
|
|
303
|
-
networkPolicy
|
|
290
|
+
sessions: z.objectInputType<{
|
|
291
|
+
id: z.ZodString;
|
|
292
|
+
memory: z.ZodNumber;
|
|
293
|
+
vcpus: z.ZodNumber;
|
|
294
|
+
region: z.ZodString;
|
|
295
|
+
runtime: z.ZodString;
|
|
296
|
+
timeout: z.ZodNumber;
|
|
297
|
+
status: z.ZodEnum<["pending", "running", "stopping", "stopped", "failed", "aborted", "snapshotting"]>;
|
|
298
|
+
requestedAt: z.ZodNumber;
|
|
299
|
+
startedAt: z.ZodOptional<z.ZodNumber>;
|
|
300
|
+
requestedStopAt: z.ZodOptional<z.ZodNumber>;
|
|
301
|
+
stoppedAt: z.ZodOptional<z.ZodNumber>;
|
|
302
|
+
abortedAt: z.ZodOptional<z.ZodNumber>;
|
|
303
|
+
duration: z.ZodOptional<z.ZodNumber>;
|
|
304
|
+
sourceSnapshotId: z.ZodOptional<z.ZodString>;
|
|
305
|
+
snapshottedAt: z.ZodOptional<z.ZodNumber>;
|
|
306
|
+
createdAt: z.ZodNumber;
|
|
307
|
+
cwd: z.ZodString;
|
|
308
|
+
updatedAt: z.ZodNumber;
|
|
309
|
+
interactivePort: z.ZodOptional<z.ZodNumber>;
|
|
310
|
+
networkPolicy: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
304
311
|
mode: z.ZodLiteral<"allow-all">;
|
|
305
|
-
}, z.ZodTypeAny,
|
|
312
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
313
|
+
mode: z.ZodLiteral<"allow-all">;
|
|
314
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
315
|
+
mode: z.ZodLiteral<"allow-all">;
|
|
316
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
|
306
317
|
mode: z.ZodLiteral<"deny-all">;
|
|
307
|
-
}, z.ZodTypeAny,
|
|
318
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
319
|
+
mode: z.ZodLiteral<"deny-all">;
|
|
320
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
321
|
+
mode: z.ZodLiteral<"deny-all">;
|
|
322
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
|
308
323
|
mode: z.ZodLiteral<"custom">;
|
|
309
324
|
allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
310
325
|
allowedCIDRs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -322,13 +337,55 @@ export declare class APIClient extends BaseClient {
|
|
|
322
337
|
headers?: Record<string, string> | undefined;
|
|
323
338
|
headerNames?: string[] | undefined;
|
|
324
339
|
}>, "many">>;
|
|
325
|
-
}, z.ZodTypeAny,
|
|
326
|
-
|
|
327
|
-
|
|
340
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
341
|
+
mode: z.ZodLiteral<"custom">;
|
|
342
|
+
allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
343
|
+
allowedCIDRs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
344
|
+
deniedCIDRs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
345
|
+
injectionRules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
346
|
+
domain: z.ZodString;
|
|
347
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
348
|
+
headerNames: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
349
|
+
}, "strip", z.ZodTypeAny, {
|
|
350
|
+
domain: string;
|
|
351
|
+
headers?: Record<string, string> | undefined;
|
|
352
|
+
headerNames?: string[] | undefined;
|
|
353
|
+
}, {
|
|
354
|
+
domain: string;
|
|
355
|
+
headers?: Record<string, string> | undefined;
|
|
356
|
+
headerNames?: string[] | undefined;
|
|
357
|
+
}>, "many">>;
|
|
358
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
359
|
+
mode: z.ZodLiteral<"custom">;
|
|
360
|
+
allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
361
|
+
allowedCIDRs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
362
|
+
deniedCIDRs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
363
|
+
injectionRules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
364
|
+
domain: z.ZodString;
|
|
365
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
366
|
+
headerNames: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
367
|
+
}, "strip", z.ZodTypeAny, {
|
|
368
|
+
domain: string;
|
|
369
|
+
headers?: Record<string, string> | undefined;
|
|
370
|
+
headerNames?: string[] | undefined;
|
|
371
|
+
}, {
|
|
372
|
+
domain: string;
|
|
373
|
+
headers?: Record<string, string> | undefined;
|
|
374
|
+
headerNames?: string[] | undefined;
|
|
375
|
+
}>, "many">>;
|
|
376
|
+
}, z.ZodTypeAny, "passthrough">>]>>;
|
|
377
|
+
activeCpuDurationMs: z.ZodOptional<z.ZodNumber>;
|
|
378
|
+
networkTransfer: z.ZodOptional<z.ZodObject<{
|
|
379
|
+
ingress: z.ZodNumber;
|
|
380
|
+
egress: z.ZodNumber;
|
|
381
|
+
}, "strip", z.ZodTypeAny, {
|
|
328
382
|
ingress: number;
|
|
329
383
|
egress: number;
|
|
330
|
-
}
|
|
331
|
-
|
|
384
|
+
}, {
|
|
385
|
+
ingress: number;
|
|
386
|
+
egress: number;
|
|
387
|
+
}>>;
|
|
388
|
+
}, z.ZodTypeAny, "passthrough">[];
|
|
332
389
|
pagination: {
|
|
333
390
|
count: number;
|
|
334
391
|
next: number | null;
|
|
@@ -342,7 +399,7 @@ export declare class APIClient extends BaseClient {
|
|
|
342
399
|
*/
|
|
343
400
|
projectId: string;
|
|
344
401
|
/**
|
|
345
|
-
* Filter snapshots by
|
|
402
|
+
* Filter snapshots by sandbox name.
|
|
346
403
|
*/
|
|
347
404
|
name?: string;
|
|
348
405
|
/**
|
|
@@ -373,13 +430,13 @@ export declare class APIClient extends BaseClient {
|
|
|
373
430
|
status: "failed" | "created" | "deleted";
|
|
374
431
|
createdAt: number;
|
|
375
432
|
updatedAt: number;
|
|
376
|
-
|
|
433
|
+
sourceSessionId: string;
|
|
377
434
|
sizeBytes: number;
|
|
378
435
|
expiresAt?: number | undefined;
|
|
379
436
|
}[];
|
|
380
437
|
}>>;
|
|
381
438
|
writeFiles(params: {
|
|
382
|
-
|
|
439
|
+
sessionId: string;
|
|
383
440
|
cwd: string;
|
|
384
441
|
files: {
|
|
385
442
|
path: string;
|
|
@@ -389,19 +446,19 @@ export declare class APIClient extends BaseClient {
|
|
|
389
446
|
signal?: AbortSignal;
|
|
390
447
|
}): Promise<void>;
|
|
391
448
|
readFile(params: {
|
|
392
|
-
|
|
449
|
+
sessionId: string;
|
|
393
450
|
path: string;
|
|
394
451
|
cwd?: string;
|
|
395
452
|
signal?: AbortSignal;
|
|
396
453
|
}): Promise<Readable | null>;
|
|
397
454
|
killCommand(params: {
|
|
398
|
-
|
|
455
|
+
sessionId: string;
|
|
399
456
|
commandId: string;
|
|
400
457
|
signal: number;
|
|
401
458
|
abortSignal?: AbortSignal;
|
|
402
459
|
}): Promise<Parsed<{
|
|
403
460
|
command: {
|
|
404
|
-
|
|
461
|
+
sessionId: string;
|
|
405
462
|
id: string;
|
|
406
463
|
startedAt: number;
|
|
407
464
|
cwd: string;
|
|
@@ -411,29 +468,29 @@ export declare class APIClient extends BaseClient {
|
|
|
411
468
|
};
|
|
412
469
|
}>>;
|
|
413
470
|
getLogs(params: {
|
|
414
|
-
|
|
471
|
+
sessionId: string;
|
|
415
472
|
cmdId: string;
|
|
416
473
|
signal?: AbortSignal;
|
|
417
474
|
}): AsyncGenerator<z.infer<typeof LogLineStdout> | z.infer<typeof LogLineStderr>, void, void> & Disposable & {
|
|
418
475
|
close(): void;
|
|
419
476
|
};
|
|
420
|
-
|
|
421
|
-
|
|
477
|
+
stopSession(params: {
|
|
478
|
+
sessionId: string;
|
|
422
479
|
signal?: AbortSignal;
|
|
423
480
|
blocking?: boolean;
|
|
424
|
-
}): Promise<Parsed<z.infer<typeof
|
|
481
|
+
}): Promise<Parsed<z.infer<typeof SessionResponse>>>;
|
|
425
482
|
updateNetworkPolicy(params: {
|
|
426
|
-
|
|
483
|
+
sessionId: string;
|
|
427
484
|
networkPolicy: NetworkPolicy;
|
|
428
485
|
signal?: AbortSignal;
|
|
429
|
-
}): Promise<Parsed<z.infer<typeof
|
|
486
|
+
}): Promise<Parsed<z.infer<typeof SessionResponse>>>;
|
|
430
487
|
extendTimeout(params: {
|
|
431
|
-
|
|
488
|
+
sessionId: string;
|
|
432
489
|
duration: number;
|
|
433
490
|
signal?: AbortSignal;
|
|
434
|
-
}): Promise<Parsed<z.infer<typeof
|
|
491
|
+
}): Promise<Parsed<z.infer<typeof SessionResponse>>>;
|
|
435
492
|
createSnapshot(params: {
|
|
436
|
-
|
|
493
|
+
sessionId: string;
|
|
437
494
|
expiration?: number;
|
|
438
495
|
signal?: AbortSignal;
|
|
439
496
|
}): Promise<Parsed<z.infer<typeof CreateSnapshotResponse>>>;
|
|
@@ -445,13 +502,13 @@ export declare class APIClient extends BaseClient {
|
|
|
445
502
|
snapshotId: string;
|
|
446
503
|
signal?: AbortSignal;
|
|
447
504
|
}): Promise<Parsed<z.infer<typeof SnapshotResponse>>>;
|
|
448
|
-
|
|
505
|
+
getSandbox(params: WithPrivate<{
|
|
449
506
|
name: string;
|
|
450
507
|
projectId: string;
|
|
451
508
|
resume?: boolean;
|
|
452
509
|
signal?: AbortSignal;
|
|
453
|
-
}): Promise<Parsed<{
|
|
454
|
-
|
|
510
|
+
}>): Promise<Parsed<{
|
|
511
|
+
session: {
|
|
455
512
|
id: string;
|
|
456
513
|
memory: number;
|
|
457
514
|
vcpus: number;
|
|
@@ -499,24 +556,27 @@ export declare class APIClient extends BaseClient {
|
|
|
499
556
|
ingress: number;
|
|
500
557
|
egress: number;
|
|
501
558
|
} | undefined;
|
|
559
|
+
} & {
|
|
560
|
+
[k: string]: unknown;
|
|
502
561
|
};
|
|
503
562
|
routes: {
|
|
504
563
|
url: string;
|
|
505
564
|
subdomain: string;
|
|
506
565
|
port: number;
|
|
507
566
|
}[];
|
|
508
|
-
|
|
509
|
-
memory: number;
|
|
510
|
-
vcpus: number;
|
|
511
|
-
region: string;
|
|
512
|
-
runtime: string;
|
|
513
|
-
timeout: number;
|
|
567
|
+
sandbox: {
|
|
514
568
|
status: "aborted" | "pending" | "running" | "stopping" | "stopped" | "failed" | "snapshotting";
|
|
515
569
|
createdAt: number;
|
|
516
570
|
updatedAt: number;
|
|
517
571
|
name: string;
|
|
518
572
|
persistent: boolean;
|
|
519
|
-
|
|
573
|
+
currentSessionId: string;
|
|
574
|
+
memory?: number | undefined;
|
|
575
|
+
vcpus?: number | undefined;
|
|
576
|
+
region?: string | undefined;
|
|
577
|
+
runtime?: string | undefined;
|
|
578
|
+
timeout?: number | undefined;
|
|
579
|
+
cwd?: string | undefined;
|
|
520
580
|
networkPolicy?: z.objectInputType<{
|
|
521
581
|
mode: z.ZodLiteral<"allow-all">;
|
|
522
582
|
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
@@ -545,68 +605,68 @@ export declare class APIClient extends BaseClient {
|
|
|
545
605
|
totalActiveCpuDurationMs?: number | undefined;
|
|
546
606
|
totalDurationMs?: number | undefined;
|
|
547
607
|
currentSnapshotId?: string | undefined;
|
|
608
|
+
tags?: Record<string, string> | undefined;
|
|
548
609
|
};
|
|
549
610
|
}>>;
|
|
550
|
-
|
|
611
|
+
listSandboxes(params: {
|
|
551
612
|
projectId: string;
|
|
552
613
|
limit?: number;
|
|
553
614
|
sortBy?: "createdAt" | "name";
|
|
554
615
|
namePrefix?: string;
|
|
555
616
|
cursor?: string;
|
|
617
|
+
tags?: Record<string, string>;
|
|
556
618
|
signal?: AbortSignal;
|
|
557
|
-
}): Promise<{
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
region: string;
|
|
563
|
-
runtime: string;
|
|
564
|
-
timeout: number;
|
|
565
|
-
status: "aborted" | "pending" | "running" | "stopping" | "stopped" | "failed" | "snapshotting";
|
|
566
|
-
createdAt: number;
|
|
567
|
-
updatedAt: number;
|
|
568
|
-
name: string;
|
|
569
|
-
persistent: boolean;
|
|
570
|
-
currentSandboxId: string;
|
|
571
|
-
networkPolicy?: z.objectInputType<{
|
|
572
|
-
mode: z.ZodLiteral<"allow-all">;
|
|
573
|
-
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
574
|
-
mode: z.ZodLiteral<"deny-all">;
|
|
575
|
-
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
576
|
-
mode: z.ZodLiteral<"custom">;
|
|
577
|
-
allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
578
|
-
allowedCIDRs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
579
|
-
deniedCIDRs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
580
|
-
injectionRules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
581
|
-
domain: z.ZodString;
|
|
582
|
-
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
583
|
-
headerNames: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
584
|
-
}, "strip", z.ZodTypeAny, {
|
|
585
|
-
domain: string;
|
|
586
|
-
headers?: Record<string, string> | undefined;
|
|
587
|
-
headerNames?: string[] | undefined;
|
|
588
|
-
}, {
|
|
589
|
-
domain: string;
|
|
590
|
-
headers?: Record<string, string> | undefined;
|
|
591
|
-
headerNames?: string[] | undefined;
|
|
592
|
-
}>, "many">>;
|
|
593
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
594
|
-
totalEgressBytes?: number | undefined;
|
|
595
|
-
totalIngressBytes?: number | undefined;
|
|
596
|
-
totalActiveCpuDurationMs?: number | undefined;
|
|
597
|
-
totalDurationMs?: number | undefined;
|
|
598
|
-
currentSnapshotId?: string | undefined;
|
|
599
|
-
}[];
|
|
600
|
-
pagination: {
|
|
601
|
-
count: number;
|
|
602
|
-
next: string | null;
|
|
603
|
-
total: number;
|
|
604
|
-
};
|
|
619
|
+
}): Promise<Parsed<{
|
|
620
|
+
pagination: {
|
|
621
|
+
count: number;
|
|
622
|
+
next: string | null;
|
|
623
|
+
total: number;
|
|
605
624
|
};
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
625
|
+
sandboxes: {
|
|
626
|
+
status: "aborted" | "pending" | "running" | "stopping" | "stopped" | "failed" | "snapshotting";
|
|
627
|
+
createdAt: number;
|
|
628
|
+
updatedAt: number;
|
|
629
|
+
name: string;
|
|
630
|
+
persistent: boolean;
|
|
631
|
+
currentSessionId: string;
|
|
632
|
+
memory?: number | undefined;
|
|
633
|
+
vcpus?: number | undefined;
|
|
634
|
+
region?: string | undefined;
|
|
635
|
+
runtime?: string | undefined;
|
|
636
|
+
timeout?: number | undefined;
|
|
637
|
+
cwd?: string | undefined;
|
|
638
|
+
networkPolicy?: z.objectInputType<{
|
|
639
|
+
mode: z.ZodLiteral<"allow-all">;
|
|
640
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
641
|
+
mode: z.ZodLiteral<"deny-all">;
|
|
642
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
643
|
+
mode: z.ZodLiteral<"custom">;
|
|
644
|
+
allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
645
|
+
allowedCIDRs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
646
|
+
deniedCIDRs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
647
|
+
injectionRules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
648
|
+
domain: z.ZodString;
|
|
649
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
650
|
+
headerNames: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
651
|
+
}, "strip", z.ZodTypeAny, {
|
|
652
|
+
domain: string;
|
|
653
|
+
headers?: Record<string, string> | undefined;
|
|
654
|
+
headerNames?: string[] | undefined;
|
|
655
|
+
}, {
|
|
656
|
+
domain: string;
|
|
657
|
+
headers?: Record<string, string> | undefined;
|
|
658
|
+
headerNames?: string[] | undefined;
|
|
659
|
+
}>, "many">>;
|
|
660
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
661
|
+
totalEgressBytes?: number | undefined;
|
|
662
|
+
totalIngressBytes?: number | undefined;
|
|
663
|
+
totalActiveCpuDurationMs?: number | undefined;
|
|
664
|
+
totalDurationMs?: number | undefined;
|
|
665
|
+
currentSnapshotId?: string | undefined;
|
|
666
|
+
tags?: Record<string, string> | undefined;
|
|
667
|
+
}[];
|
|
668
|
+
}>>;
|
|
669
|
+
updateSandbox(params: {
|
|
610
670
|
name: string;
|
|
611
671
|
projectId: string;
|
|
612
672
|
persistent?: boolean;
|
|
@@ -617,20 +677,22 @@ export declare class APIClient extends BaseClient {
|
|
|
617
677
|
runtime?: RUNTIMES | (string & {});
|
|
618
678
|
timeout?: number;
|
|
619
679
|
networkPolicy?: NetworkPolicy;
|
|
680
|
+
tags?: Record<string, string>;
|
|
620
681
|
signal?: AbortSignal;
|
|
621
682
|
}): Promise<Parsed<{
|
|
622
|
-
|
|
623
|
-
memory: number;
|
|
624
|
-
vcpus: number;
|
|
625
|
-
region: string;
|
|
626
|
-
runtime: string;
|
|
627
|
-
timeout: number;
|
|
683
|
+
sandbox: {
|
|
628
684
|
status: "aborted" | "pending" | "running" | "stopping" | "stopped" | "failed" | "snapshotting";
|
|
629
685
|
createdAt: number;
|
|
630
686
|
updatedAt: number;
|
|
631
687
|
name: string;
|
|
632
688
|
persistent: boolean;
|
|
633
|
-
|
|
689
|
+
currentSessionId: string;
|
|
690
|
+
memory?: number | undefined;
|
|
691
|
+
vcpus?: number | undefined;
|
|
692
|
+
region?: string | undefined;
|
|
693
|
+
runtime?: string | undefined;
|
|
694
|
+
timeout?: number | undefined;
|
|
695
|
+
cwd?: string | undefined;
|
|
634
696
|
networkPolicy?: z.objectInputType<{
|
|
635
697
|
mode: z.ZodLiteral<"allow-all">;
|
|
636
698
|
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
@@ -659,26 +721,27 @@ export declare class APIClient extends BaseClient {
|
|
|
659
721
|
totalActiveCpuDurationMs?: number | undefined;
|
|
660
722
|
totalDurationMs?: number | undefined;
|
|
661
723
|
currentSnapshotId?: string | undefined;
|
|
724
|
+
tags?: Record<string, string> | undefined;
|
|
662
725
|
};
|
|
663
726
|
}>>;
|
|
664
|
-
|
|
727
|
+
deleteSandbox(params: {
|
|
665
728
|
name: string;
|
|
666
729
|
projectId: string;
|
|
667
|
-
preserveSnapshots?: boolean;
|
|
668
730
|
signal?: AbortSignal;
|
|
669
731
|
}): Promise<Parsed<{
|
|
670
|
-
|
|
671
|
-
memory: number;
|
|
672
|
-
vcpus: number;
|
|
673
|
-
region: string;
|
|
674
|
-
runtime: string;
|
|
675
|
-
timeout: number;
|
|
732
|
+
sandbox: {
|
|
676
733
|
status: "aborted" | "pending" | "running" | "stopping" | "stopped" | "failed" | "snapshotting";
|
|
677
734
|
createdAt: number;
|
|
678
735
|
updatedAt: number;
|
|
679
736
|
name: string;
|
|
680
737
|
persistent: boolean;
|
|
681
|
-
|
|
738
|
+
currentSessionId: string;
|
|
739
|
+
memory?: number | undefined;
|
|
740
|
+
vcpus?: number | undefined;
|
|
741
|
+
region?: string | undefined;
|
|
742
|
+
runtime?: string | undefined;
|
|
743
|
+
timeout?: number | undefined;
|
|
744
|
+
cwd?: string | undefined;
|
|
682
745
|
networkPolicy?: z.objectInputType<{
|
|
683
746
|
mode: z.ZodLiteral<"allow-all">;
|
|
684
747
|
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
@@ -707,6 +770,7 @@ export declare class APIClient extends BaseClient {
|
|
|
707
770
|
totalActiveCpuDurationMs?: number | undefined;
|
|
708
771
|
totalDurationMs?: number | undefined;
|
|
709
772
|
currentSnapshotId?: string | undefined;
|
|
773
|
+
tags?: Record<string, string> | undefined;
|
|
710
774
|
};
|
|
711
775
|
}>>;
|
|
712
776
|
}
|