@vercel/sandbox 1.7.1 → 2.0.0-beta.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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SnapshotResponse = exports.CreateSnapshotResponse = exports.UpdateNetworkPolicyResponse = exports.ExtendTimeoutResponse = exports.SnapshotsResponse = exports.SandboxesResponse = exports.LogLine = exports.LogError = exports.LogLineStderr = exports.LogLineStdout = exports.EmptyResponse = exports.CommandFinishedResponse = exports.CommandResponse = exports.SandboxAndRoutesResponse = exports.SandboxResponse = exports.Command = exports.Pagination = exports.Snapshot = exports.SandboxRoute = exports.Sandbox = exports.NetworkPolicyValidator = exports.InjectionRuleValidator = void 0;
3
+ exports.UpdateNamedSandboxResponse = exports.NamedSandboxesPaginationResponse = exports.CursorPagination = exports.NamedSandboxAndSessionResponse = exports.NamedSandbox = exports.SnapshotResponse = exports.CreateSnapshotResponse = exports.UpdateNetworkPolicyResponse = exports.ExtendTimeoutResponse = exports.SnapshotsResponse = exports.SandboxesResponse = exports.LogLine = exports.LogError = exports.LogLineStderr = exports.LogLineStdout = exports.EmptyResponse = exports.CommandFinishedResponse = exports.CommandResponse = exports.SandboxAndRoutesResponse = exports.SandboxResponse = exports.Command = exports.Pagination = exports.Snapshot = exports.SandboxRoute = exports.Sandbox = exports.NetworkPolicyValidator = exports.InjectionRuleValidator = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.InjectionRuleValidator = zod_1.z.object({
6
6
  domain: zod_1.z.string(),
@@ -154,4 +154,40 @@ exports.CreateSnapshotResponse = zod_1.z.object({
154
154
  exports.SnapshotResponse = zod_1.z.object({
155
155
  snapshot: exports.Snapshot,
156
156
  });
157
+ exports.NamedSandbox = zod_1.z.object({
158
+ name: zod_1.z.string(),
159
+ snapshotOnShutdown: zod_1.z.boolean(),
160
+ region: zod_1.z.string(),
161
+ vcpus: zod_1.z.number(),
162
+ memory: zod_1.z.number(),
163
+ runtime: zod_1.z.string(),
164
+ timeout: zod_1.z.number(),
165
+ networkPolicy: exports.NetworkPolicyValidator.optional(),
166
+ totalEgressBytes: zod_1.z.number().optional(),
167
+ totalIngressBytes: zod_1.z.number().optional(),
168
+ totalActiveCpuDurationMs: zod_1.z.number().optional(),
169
+ totalDurationMs: zod_1.z.number().optional(),
170
+ createdAt: zod_1.z.number(),
171
+ updatedAt: zod_1.z.number(),
172
+ currentSandboxId: zod_1.z.string(),
173
+ currentSnapshotId: zod_1.z.string().optional(),
174
+ status: exports.Sandbox.shape.status,
175
+ });
176
+ exports.NamedSandboxAndSessionResponse = zod_1.z.object({
177
+ namedSandbox: exports.NamedSandbox,
178
+ sandbox: exports.Sandbox,
179
+ routes: zod_1.z.array(exports.SandboxRoute),
180
+ });
181
+ exports.CursorPagination = zod_1.z.object({
182
+ count: zod_1.z.number(),
183
+ next: zod_1.z.string().nullable(),
184
+ total: zod_1.z.number(),
185
+ });
186
+ exports.NamedSandboxesPaginationResponse = zod_1.z.object({
187
+ namedSandboxes: zod_1.z.array(exports.NamedSandbox),
188
+ pagination: exports.CursorPagination,
189
+ });
190
+ exports.UpdateNamedSandboxResponse = zod_1.z.object({
191
+ namedSandbox: exports.NamedSandbox,
192
+ });
157
193
  //# sourceMappingURL=validators.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/api-client/validators.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAIX,QAAA,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC7C,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;IAClB,oCAAoC;IACpC,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACxC,wCAAwC;IACxC,WAAW,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QA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E,eAAO,CAAC,KAAK,CAAC,MAAM;CAC7B,CAAC,CAAC;AAIU,QAAA,8BAA8B,GAAG,OAAC,CAAC,MAAM,CAAC;IACrD,YAAY,EAAE,oBAAY;IAC1B,OAAO,EAAE,eAAO;IAChB,MAAM,EAAE,OAAC,CAAC,KAAK,CAAC,oBAAY,CAAC;CAC9B,CAAC,CAAC;AAEU,QAAA,gBAAgB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;CAClB,CAAC,CAAC;AAEU,QAAA,gCAAgC,GAAG,OAAC,CAAC,MAAM,CAAC;IACvD,cAAc,EAAE,OAAC,CAAC,KAAK,CAAC,oBAAY,CAAC;IACrC,UAAU,EAAE,wBAAgB;CAC7B,CAAC,CAAC;AAEU,QAAA,0BAA0B,GAAG,OAAC,CAAC,MAAM,CAAC;IACjD,YAAY,EAAE,oBAAY;CAC3B,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export { Sandbox, type NetworkPolicy, type NetworkPolicyRule, type NetworkTransformer, } from "./sandbox";
1
+ export { type NetworkPolicy, Sandbox, } from "./sandbox";
2
+ export { Session, type NetworkPolicyRule, type NetworkTransformer, } from "./session";
2
3
  export { Snapshot } from "./snapshot";
3
4
  export { Command, CommandFinished } from "./command";
4
5
  export { StreamError } from "./api-client/api-error";
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.APIError = exports.StreamError = exports.CommandFinished = exports.Command = exports.Snapshot = exports.Sandbox = void 0;
3
+ exports.APIError = exports.StreamError = exports.CommandFinished = exports.Command = exports.Snapshot = exports.Session = exports.Sandbox = void 0;
4
4
  var sandbox_1 = require("./sandbox");
5
5
  Object.defineProperty(exports, "Sandbox", { enumerable: true, get: function () { return sandbox_1.Sandbox; } });
6
+ var session_1 = require("./session");
7
+ Object.defineProperty(exports, "Session", { enumerable: true, get: function () { return session_1.Session; } });
6
8
  var snapshot_1 = require("./snapshot");
7
9
  Object.defineProperty(exports, "Snapshot", { enumerable: true, get: function () { return snapshot_1.Snapshot; } });
8
10
  var command_1 = require("./command");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qCAKmB;AAJjB,kGAAA,OAAO,OAAA;AAKT,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,qCAAqD;AAA5C,kGAAA,OAAO,OAAA;AAAE,0GAAA,eAAe,OAAA;AACjC,oDAAqD;AAA5C,wGAAA,WAAW,OAAA;AACpB,oDAAkD;AAAzC,qGAAA,QAAQ,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qCAGmB;AADjB,kGAAA,OAAO,OAAA;AAET,qCAImB;AAHjB,kGAAA,OAAO,OAAA;AAIT,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,qCAAqD;AAA5C,kGAAA,OAAO,OAAA;AAAE,0GAAA,eAAe,OAAA;AACjC,oDAAqD;AAA5C,wGAAA,WAAW,OAAA;AACpB,oDAAkD;AAAzC,qGAAA,QAAQ,OAAA"}
package/dist/sandbox.d.ts CHANGED
@@ -1,17 +1,21 @@
1
- import type { SandboxMetaData, SandboxRouteData } from "./api-client";
2
- import { type Writable } from "stream";
1
+ import type { SandboxMetaData, SandboxRouteData, NamedSandboxMetaData } from "./api-client";
3
2
  import { APIClient } from "./api-client";
4
- import { Command, CommandFinished } from "./command";
5
3
  import { type Credentials } from "./utils/get-credentials";
6
- import { WithPrivate } from "./utils/types";
7
- import { WithFetchOptions } from "./api-client/api-client";
8
- import { RUNTIMES } from "./constants";
9
- import { Snapshot } from "./snapshot";
10
- import { type NetworkPolicy, type NetworkPolicyRule, type NetworkTransformer } from "./network-policy";
11
- import { type ConvertedSandbox } from "./utils/convert-sandbox";
12
- export type { NetworkPolicy, NetworkPolicyRule, NetworkTransformer };
4
+ import { type WithPrivate } from "./utils/types";
5
+ import type { WithFetchOptions } from "./api-client/api-client";
6
+ import type { RUNTIMES } from "./constants";
7
+ import { Session, type RunCommandParams } from "./session";
8
+ import type { Command, CommandFinished } from "./command";
9
+ import type { Snapshot } from "./snapshot";
10
+ import type { ConvertedSandbox } from "./utils/convert-sandbox";
11
+ import type { NetworkPolicy } from "./network-policy";
12
+ export type { NetworkPolicy };
13
13
  /** @inline */
14
14
  export interface BaseCreateSandboxParams {
15
+ /**
16
+ * The name of the sandbox. If omitted, a random name will be generated.
17
+ */
18
+ name?: string;
15
19
  /**
16
20
  * The source of the sandbox.
17
21
  *
@@ -65,10 +69,27 @@ export interface BaseCreateSandboxParams {
65
69
  * Defaults to full internet access if not specified.
66
70
  */
67
71
  networkPolicy?: NetworkPolicy;
72
+ /**
73
+ * Default environment variables for the sandbox.
74
+ * These are inherited by all commands unless overridden with
75
+ * the `env` option in `runCommand`.
76
+ *
77
+ * @example
78
+ * const sandbox = await Sandbox.create({
79
+ * env: { NODE_ENV: "production", API_KEY: "secret" },
80
+ * });
81
+ * // All commands will have NODE_ENV and API_KEY set
82
+ * await sandbox.runCommand("node", ["app.js"]);
83
+ */
84
+ env?: Record<string, string>;
68
85
  /**
69
86
  * An AbortSignal to cancel sandbox creation.
70
87
  */
71
88
  signal?: AbortSignal;
89
+ /**
90
+ * Whether to enable snapshots on shutdown. Defaults to true.
91
+ */
92
+ snapshotOnShutdown?: boolean;
72
93
  }
73
94
  export type CreateSandboxParams = BaseCreateSandboxParams | (Omit<BaseCreateSandboxParams, "runtime" | "source"> & {
74
95
  source: {
@@ -79,167 +100,177 @@ export type CreateSandboxParams = BaseCreateSandboxParams | (Omit<BaseCreateSand
79
100
  /** @inline */
80
101
  interface GetSandboxParams {
81
102
  /**
82
- * Unique identifier of the sandbox.
103
+ * The name of the sandbox.
83
104
  */
84
- sandboxId: string;
105
+ name: string;
106
+ /**
107
+ * Whether to resume an existing session. Defaults to true.
108
+ */
109
+ resume?: boolean;
85
110
  /**
86
111
  * An AbortSignal to cancel the operation.
87
112
  */
88
113
  signal?: AbortSignal;
89
114
  }
90
- /** @inline */
91
- interface RunCommandParams {
115
+ /**
116
+ * A Sandbox is a persistent, isolated Linux MicroVMs to run commands in.
117
+ * Use {@link Sandbox.create} or {@link Sandbox.get} to construct.
118
+ * @hideconstructor
119
+ */
120
+ export declare class Sandbox {
121
+ private readonly client;
122
+ private readonly projectId;
92
123
  /**
93
- * The command to execute
124
+ * Internal Session instance for the current VM.
94
125
  */
95
- cmd: string;
126
+ private session;
96
127
  /**
97
- * Arguments to pass to the command
128
+ * Internal metadata about the named sandbox.
98
129
  */
99
- args?: string[];
130
+ private namedSandbox;
100
131
  /**
101
- * Working directory to execute the command in
132
+ * The name of this sandbox.
102
133
  */
103
- cwd?: string;
134
+ get name(): string;
104
135
  /**
105
- * Environment variables to set for this command
136
+ * Routes from ports to subdomains.
137
+ * @hidden
106
138
  */
107
- env?: Record<string, string>;
139
+ get routes(): SandboxRouteData[];
108
140
  /**
109
- * If true, execute this command with root privileges. Defaults to false.
141
+ * Whether this sandbox snapshots on shutdown.
110
142
  */
111
- sudo?: boolean;
143
+ get snapshotOnShutdown(): boolean;
112
144
  /**
113
- * If true, the command will return without waiting for `exitCode`
145
+ * The region this sandbox runs in.
114
146
  */
115
- detached?: boolean;
147
+ get region(): string;
116
148
  /**
117
- * A `Writable` stream where `stdout` from the command will be piped
149
+ * Number of virtual CPUs allocated.
118
150
  */
119
- stdout?: Writable;
151
+ get vcpus(): number;
120
152
  /**
121
- * A `Writable` stream where `stderr` from the command will be piped
153
+ * Memory allocated in MB.
122
154
  */
123
- stderr?: Writable;
155
+ get memory(): number;
156
+ /** Runtime identifier (e.g. "node24", "python3.13"). */
157
+ get runtime(): string;
124
158
  /**
125
- * An AbortSignal to cancel the command execution
159
+ * Cumulative egress bytes across all sessions.
126
160
  */
127
- signal?: AbortSignal;
128
- }
129
- /**
130
- * A Sandbox is an isolated Linux MicroVM to run commands in.
131
- *
132
- * Use {@link Sandbox.create} or {@link Sandbox.get} to construct.
133
- * @hideconstructor
134
- */
135
- export declare class Sandbox {
136
- private readonly client;
161
+ get totalEgressBytes(): number | undefined;
137
162
  /**
138
- * Routes from ports to subdomains.
139
- /* @hidden
163
+ * Cumulative ingress bytes across all sessions.
140
164
  */
141
- readonly routes: SandboxRouteData[];
165
+ get totalIngressBytes(): number | undefined;
142
166
  /**
143
- * Unique ID of this sandbox.
167
+ * Cumulative active CPU duration in milliseconds across all sessions.
144
168
  */
145
- get sandboxId(): string;
146
- get interactivePort(): number | undefined;
169
+ get totalActiveCpuDurationMs(): number | undefined;
147
170
  /**
148
- * The status of the sandbox.
171
+ * Cumulative wall-clock duration in milliseconds across all sessions.
149
172
  */
150
- get status(): SandboxMetaData["status"];
173
+ get totalDurationMs(): number | undefined;
151
174
  /**
152
- * The creation date of the sandbox.
175
+ * When this sandbox was last updated.
176
+ */
177
+ get updatedAt(): Date;
178
+ /**
179
+ * When this sandbox was created.
153
180
  */
154
181
  get createdAt(): Date;
155
182
  /**
156
- * The timeout of the sandbox in milliseconds.
183
+ * Interactive port.
184
+ */
185
+ get interactivePort(): number | undefined;
186
+ /**
187
+ * The status of the current session.
188
+ */
189
+ get status(): SandboxMetaData["status"];
190
+ /**
191
+ * The default timeout of this sandbox in milliseconds.
157
192
  */
158
193
  get timeout(): number;
159
194
  /**
160
- * The network policy of the sandbox.
195
+ * The default network policy of this sandbox.
161
196
  */
162
197
  get networkPolicy(): NetworkPolicy | undefined;
163
198
  /**
164
- * If the sandbox was created from a snapshot, the ID of that snapshot.
199
+ * If the session was created from a snapshot, the ID of that snapshot.
165
200
  */
166
201
  get sourceSnapshotId(): string | undefined;
167
202
  /**
168
- * The amount of CPU used by the sandbox. Only reported once the VM is stopped.
203
+ * The current snapshot ID of this sandbox, if any.
204
+ */
205
+ get currentSnapshotId(): string | undefined;
206
+ /**
207
+ * The amount of CPU used by the session. Only reported once the VM is stopped.
169
208
  */
170
209
  get activeCpuUsageMs(): number | undefined;
171
210
  /**
172
- * The amount of network data used by the sandbox. Only reported once the VM is stopped.
211
+ * The amount of network data used by the session. Only reported once the VM is stopped.
173
212
  */
174
213
  get networkTransfer(): {
175
214
  ingress: number;
176
215
  egress: number;
177
216
  } | undefined;
178
- /**
179
- * Internal metadata about this sandbox.
180
- */
181
- private sandbox;
182
217
  /**
183
218
  * Allow to get a list of sandboxes for a team narrowed to the given params.
184
219
  * It returns both the sandboxes and the pagination metadata to allow getting
185
220
  * the next page of results.
186
221
  */
187
- static list(params?: Partial<Parameters<APIClient["listSandboxes"]>[0]> & Partial<Credentials> & WithFetchOptions): Promise<import("./api-client/base-client").Parsed<{
188
- sandboxes: {
189
- id: string;
190
- memory: number;
191
- vcpus: number;
192
- region: string;
193
- runtime: string;
194
- timeout: number;
195
- status: "aborted" | "pending" | "running" | "stopping" | "stopped" | "failed" | "snapshotting";
196
- requestedAt: number;
197
- createdAt: number;
198
- cwd: string;
199
- updatedAt: number;
200
- startedAt?: number | undefined;
201
- requestedStopAt?: number | undefined;
202
- stoppedAt?: number | undefined;
203
- abortedAt?: number | undefined;
204
- duration?: number | undefined;
205
- sourceSnapshotId?: string | undefined;
206
- snapshottedAt?: number | undefined;
207
- interactivePort?: number | undefined;
208
- networkPolicy?: import("zod").objectInputType<{
209
- mode: import("zod").ZodLiteral<"allow-all">;
210
- }, import("zod").ZodTypeAny, "passthrough"> | import("zod").objectInputType<{
211
- mode: import("zod").ZodLiteral<"deny-all">;
212
- }, import("zod").ZodTypeAny, "passthrough"> | import("zod").objectInputType<{
213
- mode: import("zod").ZodLiteral<"custom">;
214
- allowedDomains: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
215
- allowedCIDRs: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
216
- deniedCIDRs: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
217
- injectionRules: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
218
- domain: import("zod").ZodString;
219
- headers: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
220
- headerNames: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
221
- }, "strip", import("zod").ZodTypeAny, {
222
- domain: string;
223
- headers?: Record<string, string> | undefined;
224
- headerNames?: string[] | undefined;
225
- }, {
226
- domain: string;
227
- headers?: Record<string, string> | undefined;
228
- headerNames?: string[] | undefined;
229
- }>, "many">>;
230
- }, import("zod").ZodTypeAny, "passthrough"> | undefined;
231
- activeCpuDurationMs?: number | undefined;
232
- networkTransfer?: {
233
- ingress: number;
234
- egress: number;
235
- } | undefined;
236
- }[];
237
- pagination: {
238
- count: number;
239
- next: number | null;
240
- prev: number | null;
222
+ static list(params?: Partial<Parameters<APIClient["listNamedSandboxes"]>[0]> & Partial<Credentials> & WithFetchOptions): Promise<{
223
+ json: {
224
+ sandboxes: {
225
+ memory: number;
226
+ vcpus: number;
227
+ region: string;
228
+ runtime: string;
229
+ timeout: number;
230
+ status: "aborted" | "pending" | "running" | "stopping" | "stopped" | "failed" | "snapshotting";
231
+ createdAt: number;
232
+ updatedAt: number;
233
+ name: string;
234
+ snapshotOnShutdown: boolean;
235
+ currentSandboxId: string;
236
+ networkPolicy?: import("zod").objectInputType<{
237
+ mode: import("zod").ZodLiteral<"allow-all">;
238
+ }, import("zod").ZodTypeAny, "passthrough"> | import("zod").objectInputType<{
239
+ mode: import("zod").ZodLiteral<"deny-all">;
240
+ }, import("zod").ZodTypeAny, "passthrough"> | import("zod").objectInputType<{
241
+ mode: import("zod").ZodLiteral<"custom">;
242
+ allowedDomains: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
243
+ allowedCIDRs: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
244
+ deniedCIDRs: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
245
+ injectionRules: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
246
+ domain: import("zod").ZodString;
247
+ headers: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
248
+ headerNames: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
249
+ }, "strip", import("zod").ZodTypeAny, {
250
+ domain: string;
251
+ headers?: Record<string, string> | undefined;
252
+ headerNames?: string[] | undefined;
253
+ }, {
254
+ domain: string;
255
+ headers?: Record<string, string> | undefined;
256
+ headerNames?: string[] | undefined;
257
+ }>, "many">>;
258
+ }, import("zod").ZodTypeAny, "passthrough"> | undefined;
259
+ totalEgressBytes?: number | undefined;
260
+ totalIngressBytes?: number | undefined;
261
+ totalActiveCpuDurationMs?: number | undefined;
262
+ totalDurationMs?: number | undefined;
263
+ currentSnapshotId?: string | undefined;
264
+ }[];
265
+ pagination: {
266
+ count: number;
267
+ next: string | null;
268
+ total: number;
269
+ };
241
270
  };
242
- }>>;
271
+ response: Response;
272
+ text: string;
273
+ }>;
243
274
  /**
244
275
  * Create a new sandbox.
245
276
  *
@@ -254,28 +285,37 @@ export declare class Sandbox {
254
285
  */
255
286
  static create(params?: WithPrivate<CreateSandboxParams | (CreateSandboxParams & Credentials)> & WithFetchOptions): Promise<Sandbox & AsyncDisposable>;
256
287
  /**
257
- * Retrieve an existing sandbox.
288
+ * Retrieve an existing sandbox and resume its session.
258
289
  *
259
290
  * @param params - Get parameters and optional credentials.
260
291
  * @returns A promise resolving to the {@link Sandbox}.
261
292
  */
262
293
  static get(params: WithPrivate<GetSandboxParams | (GetSandboxParams & Credentials)> & WithFetchOptions): Promise<Sandbox>;
263
- constructor({ client, routes, sandbox, }: {
294
+ constructor({ client, routes, session, namedSandbox, projectId, }: {
264
295
  client: APIClient;
265
296
  routes: SandboxRouteData[];
266
- sandbox: SandboxMetaData;
297
+ session: SandboxMetaData;
298
+ namedSandbox: NamedSandboxMetaData;
299
+ projectId: string;
267
300
  });
268
301
  /**
269
- * Get a previously run command by its ID.
302
+ * Get the current session (the running VM) for this sandbox.
270
303
  *
271
- * @param cmdId - ID of the command to retrieve
272
- * @param opts - Optional parameters.
273
- * @param opts.signal - An AbortSignal to cancel the operation.
274
- * @returns A {@link Command} instance representing the command
304
+ * @returns The {@link Session} instance.
275
305
  */
276
- getCommand(cmdId: string, opts?: {
277
- signal?: AbortSignal;
278
- }): Promise<Command>;
306
+ currentSession(): Session;
307
+ /**
308
+ * Resume this sandbox by creating a new session via `getNamedSandbox`.
309
+ */
310
+ private resume;
311
+ /**
312
+ * Poll until the current session reaches a terminal state, then resume.
313
+ */
314
+ private waitForStopAndResume;
315
+ /**
316
+ * Execute `fn`, and if the session is stopped/stopping, resume and retry.
317
+ */
318
+ private withResume;
279
319
  /**
280
320
  * Start executing a command in this sandbox.
281
321
  *
@@ -311,7 +351,9 @@ export declare class Sandbox {
311
351
  * @returns A {@link Command} or {@link CommandFinished}, depending on `detached`.
312
352
  * @internal
313
353
  */
314
- _runCommand(params: RunCommandParams): Promise<Command>;
354
+ getCommand(cmdId: string, opts?: {
355
+ signal?: AbortSignal;
356
+ }): Promise<Command>;
315
357
  /**
316
358
  * Create a directory in the filesystem of this sandbox.
317
359
  *
@@ -474,4 +516,126 @@ export declare class Sandbox {
474
516
  expiration?: number;
475
517
  signal?: AbortSignal;
476
518
  }): Promise<Snapshot>;
519
+ /**
520
+ * Update the named sandbox configuration. Only provided fields are modified.
521
+ *
522
+ * @param params - Fields to update.
523
+ * @param opts - Optional abort signal.
524
+ */
525
+ update(params: {
526
+ resources?: {
527
+ vcpus?: number;
528
+ memory?: number;
529
+ };
530
+ runtime?: RUNTIMES | (string & {});
531
+ timeout?: number;
532
+ networkPolicy?: NetworkPolicy;
533
+ }, opts?: {
534
+ signal?: AbortSignal;
535
+ }): Promise<void>;
536
+ /**
537
+ * Delete this named sandbox.
538
+ *
539
+ * After deletion the instance becomes inert — all further API calls will
540
+ * throw immediately.
541
+ */
542
+ delete(opts?: {
543
+ preserveSnapshots?: boolean;
544
+ signal?: AbortSignal;
545
+ }): Promise<void>;
546
+ /**
547
+ * List sessions (VMs) that have been created for this named sandbox.
548
+ *
549
+ * @param params - Optional pagination parameters.
550
+ * @returns The list of sessions and pagination metadata.
551
+ */
552
+ listSessions(params?: {
553
+ limit?: number;
554
+ since?: number | Date;
555
+ until?: number | Date;
556
+ signal?: AbortSignal;
557
+ }): Promise<import("./api-client/base-client").Parsed<{
558
+ sandboxes: {
559
+ id: string;
560
+ memory: number;
561
+ vcpus: number;
562
+ region: string;
563
+ runtime: string;
564
+ timeout: number;
565
+ status: "aborted" | "pending" | "running" | "stopping" | "stopped" | "failed" | "snapshotting";
566
+ requestedAt: number;
567
+ createdAt: number;
568
+ cwd: string;
569
+ updatedAt: number;
570
+ startedAt?: number | undefined;
571
+ requestedStopAt?: number | undefined;
572
+ stoppedAt?: number | undefined;
573
+ abortedAt?: number | undefined;
574
+ duration?: number | undefined;
575
+ sourceSnapshotId?: string | undefined;
576
+ snapshottedAt?: number | undefined;
577
+ interactivePort?: number | undefined;
578
+ networkPolicy?: import("zod").objectInputType<{
579
+ mode: import("zod").ZodLiteral<"allow-all">;
580
+ }, import("zod").ZodTypeAny, "passthrough"> | import("zod").objectInputType<{
581
+ mode: import("zod").ZodLiteral<"deny-all">;
582
+ }, import("zod").ZodTypeAny, "passthrough"> | import("zod").objectInputType<{
583
+ mode: import("zod").ZodLiteral<"custom">;
584
+ allowedDomains: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
585
+ allowedCIDRs: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
586
+ deniedCIDRs: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
587
+ injectionRules: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
588
+ domain: import("zod").ZodString;
589
+ headers: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
590
+ headerNames: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
591
+ }, "strip", import("zod").ZodTypeAny, {
592
+ domain: string;
593
+ headers?: Record<string, string> | undefined;
594
+ headerNames?: string[] | undefined;
595
+ }, {
596
+ domain: string;
597
+ headers?: Record<string, string> | undefined;
598
+ headerNames?: string[] | undefined;
599
+ }>, "many">>;
600
+ }, import("zod").ZodTypeAny, "passthrough"> | undefined;
601
+ activeCpuDurationMs?: number | undefined;
602
+ networkTransfer?: {
603
+ ingress: number;
604
+ egress: number;
605
+ } | undefined;
606
+ }[];
607
+ pagination: {
608
+ count: number;
609
+ next: number | null;
610
+ prev: number | null;
611
+ };
612
+ }>>;
613
+ /**
614
+ * List snapshots that belong to this named sandbox.
615
+ *
616
+ * @param params - Optional pagination parameters.
617
+ * @returns The list of snapshots and pagination metadata.
618
+ */
619
+ listSnapshots(params?: {
620
+ limit?: number;
621
+ since?: number | Date;
622
+ until?: number | Date;
623
+ signal?: AbortSignal;
624
+ }): Promise<import("./api-client/base-client").Parsed<{
625
+ pagination: {
626
+ count: number;
627
+ next: number | null;
628
+ prev: number | null;
629
+ };
630
+ snapshots: {
631
+ id: string;
632
+ region: string;
633
+ status: "failed" | "created" | "deleted";
634
+ createdAt: number;
635
+ updatedAt: number;
636
+ sourceSandboxId: string;
637
+ sizeBytes: number;
638
+ expiresAt?: number | undefined;
639
+ }[];
640
+ }>>;
477
641
  }