@vercel/sandbox 1.9.0 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/README.md +8 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  3. package/dist/api-client/api-client.cjs +375 -0
  4. package/dist/api-client/api-client.cjs.map +1 -0
  5. package/dist/api-client/api-client.d.cts +403 -0
  6. package/dist/api-client/api-client.d.ts +397 -392
  7. package/dist/api-client/api-client.js +365 -405
  8. package/dist/api-client/api-client.js.map +1 -1
  9. package/dist/api-client/api-error.cjs +31 -0
  10. package/dist/api-client/api-error.cjs.map +1 -0
  11. package/dist/api-client/api-error.d.cts +27 -0
  12. package/dist/api-client/api-error.d.ts +19 -16
  13. package/dist/api-client/api-error.js +27 -32
  14. package/dist/api-client/api-error.js.map +1 -1
  15. package/dist/api-client/base-client.cjs +113 -0
  16. package/dist/api-client/base-client.cjs.map +1 -0
  17. package/dist/api-client/base-client.d.cts +38 -0
  18. package/dist/api-client/base-client.d.ts +31 -36
  19. package/dist/api-client/base-client.js +101 -118
  20. package/dist/api-client/base-client.js.map +1 -1
  21. package/dist/api-client/file-writer.cjs +62 -0
  22. package/dist/api-client/file-writer.cjs.map +1 -0
  23. package/dist/api-client/file-writer.d.cts +66 -0
  24. package/dist/api-client/file-writer.d.ts +56 -52
  25. package/dist/api-client/file-writer.js +57 -61
  26. package/dist/api-client/file-writer.js.map +1 -1
  27. package/dist/api-client/index.cjs +2 -0
  28. package/dist/api-client/index.d.ts +2 -2
  29. package/dist/api-client/index.js +4 -21
  30. package/dist/api-client/validators.cjs +149 -0
  31. package/dist/api-client/validators.cjs.map +1 -0
  32. package/dist/api-client/validators.d.cts +1677 -0
  33. package/dist/api-client/validators.d.ts +1501 -2412
  34. package/dist/api-client/validators.js +124 -154
  35. package/dist/api-client/validators.js.map +1 -1
  36. package/dist/api-client/with-retry.cjs +89 -0
  37. package/dist/api-client/with-retry.cjs.map +1 -0
  38. package/dist/api-client/with-retry.d.cts +10 -0
  39. package/dist/api-client/with-retry.d.ts +9 -13
  40. package/dist/api-client/with-retry.js +81 -102
  41. package/dist/api-client/with-retry.js.map +1 -1
  42. package/dist/auth/api.cjs +29 -0
  43. package/dist/auth/api.cjs.map +1 -0
  44. package/dist/auth/api.js +26 -25
  45. package/dist/auth/api.js.map +1 -1
  46. package/dist/auth/error.cjs +13 -0
  47. package/dist/auth/error.cjs.map +1 -0
  48. package/dist/auth/error.js +11 -11
  49. package/dist/auth/error.js.map +1 -1
  50. package/dist/auth/file.cjs +64 -0
  51. package/dist/auth/file.cjs.map +1 -0
  52. package/dist/auth/file.d.cts +26 -0
  53. package/dist/auth/file.d.ts +19 -15
  54. package/dist/auth/file.js +49 -64
  55. package/dist/auth/file.js.map +1 -1
  56. package/dist/auth/index.cjs +12 -0
  57. package/dist/auth/index.d.cts +5 -0
  58. package/dist/auth/index.d.ts +5 -6
  59. package/dist/auth/index.js +6 -27
  60. package/dist/auth/linked-project.cjs +38 -0
  61. package/dist/auth/linked-project.cjs.map +1 -0
  62. package/dist/auth/linked-project.js +30 -64
  63. package/dist/auth/linked-project.js.map +1 -1
  64. package/dist/auth/oauth.cjs +205 -0
  65. package/dist/auth/oauth.cjs.map +1 -0
  66. package/dist/auth/oauth.d.cts +135 -0
  67. package/dist/auth/oauth.d.ts +113 -109
  68. package/dist/auth/oauth.js +185 -252
  69. package/dist/auth/oauth.js.map +1 -1
  70. package/dist/auth/poll-for-token.cjs +82 -0
  71. package/dist/auth/poll-for-token.cjs.map +1 -0
  72. package/dist/auth/poll-for-token.d.cts +28 -0
  73. package/dist/auth/poll-for-token.d.ts +23 -15
  74. package/dist/auth/poll-for-token.js +79 -64
  75. package/dist/auth/poll-for-token.js.map +1 -1
  76. package/dist/auth/project.cjs +80 -0
  77. package/dist/auth/project.cjs.map +1 -0
  78. package/dist/auth/project.d.cts +44 -0
  79. package/dist/auth/project.d.ts +12 -8
  80. package/dist/auth/project.js +70 -72
  81. package/dist/auth/project.js.map +1 -1
  82. package/dist/auth/zod.cjs +22 -0
  83. package/dist/auth/zod.cjs.map +1 -0
  84. package/dist/auth/zod.js +18 -17
  85. package/dist/auth/zod.js.map +1 -1
  86. package/dist/command.cjs +326 -0
  87. package/dist/command.cjs.map +1 -0
  88. package/dist/command.d.cts +289 -0
  89. package/dist/command.d.ts +265 -171
  90. package/dist/command.js +321 -226
  91. package/dist/command.js.map +1 -1
  92. package/dist/constants.d.cts +5 -0
  93. package/dist/constants.d.ts +5 -1
  94. package/dist/index.cjs +11 -0
  95. package/dist/index.d.cts +6 -0
  96. package/dist/index.d.ts +6 -5
  97. package/dist/index.js +6 -15
  98. package/dist/network-policy.d.cts +100 -0
  99. package/dist/network-policy.d.ts +32 -28
  100. package/dist/sandbox.cjs +543 -0
  101. package/dist/sandbox.cjs.map +1 -0
  102. package/dist/sandbox.d.cts +538 -0
  103. package/dist/sandbox.d.ts +521 -479
  104. package/dist/sandbox.js +539 -512
  105. package/dist/sandbox.js.map +1 -1
  106. package/dist/snapshot.cjs +116 -0
  107. package/dist/snapshot.cjs.map +1 -0
  108. package/dist/snapshot.d.cts +109 -0
  109. package/dist/snapshot.d.ts +100 -92
  110. package/dist/snapshot.js +114 -114
  111. package/dist/snapshot.js.map +1 -1
  112. package/dist/utils/array.cjs +17 -0
  113. package/dist/utils/array.cjs.map +1 -0
  114. package/dist/utils/array.js +12 -15
  115. package/dist/utils/array.js.map +1 -1
  116. package/dist/utils/consume-readable.cjs +18 -0
  117. package/dist/utils/consume-readable.cjs.map +1 -0
  118. package/dist/utils/consume-readable.js +13 -12
  119. package/dist/utils/consume-readable.js.map +1 -1
  120. package/dist/utils/decode-base64-url.cjs +15 -0
  121. package/dist/utils/decode-base64-url.cjs.map +1 -0
  122. package/dist/utils/decode-base64-url.js +10 -9
  123. package/dist/utils/decode-base64-url.js.map +1 -1
  124. package/dist/utils/dev-credentials.cjs +142 -0
  125. package/dist/utils/dev-credentials.cjs.map +1 -0
  126. package/dist/utils/dev-credentials.js +126 -184
  127. package/dist/utils/dev-credentials.js.map +1 -1
  128. package/dist/utils/get-credentials.cjs +123 -0
  129. package/dist/utils/get-credentials.cjs.map +1 -0
  130. package/dist/utils/get-credentials.d.cts +21 -0
  131. package/dist/utils/get-credentials.d.ts +19 -61
  132. package/dist/utils/get-credentials.js +106 -140
  133. package/dist/utils/get-credentials.js.map +1 -1
  134. package/dist/utils/log.cjs +25 -0
  135. package/dist/utils/log.cjs.map +1 -0
  136. package/dist/utils/log.js +15 -17
  137. package/dist/utils/log.js.map +1 -1
  138. package/dist/utils/network-policy.cjs +65 -0
  139. package/dist/utils/network-policy.cjs.map +1 -0
  140. package/dist/utils/network-policy.js +58 -77
  141. package/dist/utils/network-policy.js.map +1 -1
  142. package/dist/utils/normalizePath.cjs +27 -0
  143. package/dist/utils/normalizePath.cjs.map +1 -0
  144. package/dist/utils/normalizePath.js +21 -28
  145. package/dist/utils/normalizePath.js.map +1 -1
  146. package/dist/utils/resolveSignal.cjs +20 -0
  147. package/dist/utils/resolveSignal.cjs.map +1 -0
  148. package/dist/utils/resolveSignal.d.cts +15 -0
  149. package/dist/utils/resolveSignal.d.ts +12 -10
  150. package/dist/utils/resolveSignal.js +14 -17
  151. package/dist/utils/resolveSignal.js.map +1 -1
  152. package/dist/utils/sandbox-snapshot.cjs +14 -0
  153. package/dist/utils/sandbox-snapshot.cjs.map +1 -0
  154. package/dist/utils/sandbox-snapshot.d.cts +10 -0
  155. package/dist/utils/sandbox-snapshot.d.ts +11 -0
  156. package/dist/utils/sandbox-snapshot.js +14 -0
  157. package/dist/utils/sandbox-snapshot.js.map +1 -0
  158. package/dist/utils/types.cjs +13 -0
  159. package/dist/utils/types.cjs.map +1 -0
  160. package/dist/utils/types.d.cts +11 -0
  161. package/dist/utils/types.d.ts +5 -7
  162. package/dist/utils/types.js +8 -8
  163. package/dist/utils/types.js.map +1 -1
  164. package/dist/version.cjs +7 -0
  165. package/dist/version.cjs.map +1 -0
  166. package/dist/version.js +5 -5
  167. package/dist/version.js.map +1 -1
  168. package/package.json +23 -3
  169. package/dist/api-client/index.js.map +0 -1
  170. package/dist/auth/api.d.ts +0 -6
  171. package/dist/auth/error.d.ts +0 -11
  172. package/dist/auth/index.js.map +0 -1
  173. package/dist/auth/linked-project.d.ts +0 -10
  174. package/dist/auth/zod.d.ts +0 -5
  175. package/dist/constants.js +0 -3
  176. package/dist/constants.js.map +0 -1
  177. package/dist/index.js.map +0 -1
  178. package/dist/network-policy.js +0 -3
  179. package/dist/network-policy.js.map +0 -1
  180. package/dist/utils/array.d.ts +0 -9
  181. package/dist/utils/consume-readable.d.ts +0 -5
  182. package/dist/utils/convert-sandbox.d.ts +0 -6
  183. package/dist/utils/convert-sandbox.js +0 -14
  184. package/dist/utils/convert-sandbox.js.map +0 -1
  185. package/dist/utils/decode-base64-url.d.ts +0 -7
  186. package/dist/utils/dev-credentials.d.ts +0 -37
  187. package/dist/utils/log.d.ts +0 -2
  188. package/dist/utils/network-policy.d.ts +0 -7
  189. package/dist/utils/normalizePath.d.ts +0 -17
  190. package/dist/version.d.ts +0 -1
package/dist/sandbox.d.ts CHANGED
@@ -1,143 +1,154 @@
1
- import type { SandboxMetaData, SandboxRouteData } from "./api-client";
2
- import { type Writable } from "stream";
3
- import { APIClient } from "./api-client";
4
- import { Command, CommandFinished } from "./command";
5
- 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 };
1
+ import { Parsed } from "./api-client/base-client.js";
2
+ import { SandboxMetaData, SandboxRouteData } from "./api-client/validators.js";
3
+ import { NetworkPolicy, NetworkPolicyRule, NetworkTransformer } from "./network-policy.js";
4
+ import { WithPrivate } from "./utils/types.js";
5
+ import { RUNTIMES } from "./constants.js";
6
+ import { APIClient, WithFetchOptions } from "./api-client/api-client.js";
7
+ import "./api-client/index.js";
8
+ import { Command, CommandFinished } from "./command.js";
9
+ import { Credentials } from "./utils/get-credentials.js";
10
+ import { Snapshot } from "./snapshot.js";
11
+ import { SandboxSnapshot } from "./utils/sandbox-snapshot.js";
12
+ import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE } from "@workflow/serde";
13
+ import * as zod0 from "zod";
14
+ import { Writable } from "stream";
15
+
16
+ //#region src/sandbox.d.ts
13
17
  /** @inline */
14
- export interface BaseCreateSandboxParams {
15
- /**
16
- * The source of the sandbox.
17
- *
18
- * Omit this parameter start a sandbox without a source.
19
- *
20
- * For git sources:
21
- * - `depth`: Creates shallow clones with limited commit history (minimum: 1)
22
- * - `revision`: Clones and checks out a specific commit, branch, or tag
23
- */
24
- source?: {
25
- type: "git";
26
- url: string;
27
- depth?: number;
28
- revision?: string;
29
- } | {
30
- type: "git";
31
- url: string;
32
- username: string;
33
- password: string;
34
- depth?: number;
35
- revision?: string;
36
- } | {
37
- type: "tarball";
38
- url: string;
39
- };
40
- /**
41
- * Array of port numbers to expose from the sandbox. Sandboxes can
42
- * expose up to 4 ports.
43
- */
44
- ports?: number[];
45
- /**
46
- * Timeout in milliseconds before the sandbox auto-terminates.
47
- */
48
- timeout?: number;
49
- /**
50
- * Resources to allocate to the sandbox.
51
- *
52
- * Your sandbox will get the amount of vCPUs you specify here and
53
- * 2048 MB of memory per vCPU.
54
- */
55
- resources?: {
56
- vcpus: number;
57
- };
58
- /**
59
- * The runtime of the sandbox, currently only `node24`, `node22` and `python3.13` are supported.
60
- * If not specified, the default runtime `node24` will be used.
61
- */
62
- runtime?: RUNTIMES | (string & {});
63
- /**
64
- * Network policy to define network restrictions for the sandbox.
65
- * Defaults to full internet access if not specified.
66
- */
67
- networkPolicy?: NetworkPolicy;
68
- /**
69
- * Default environment variables for the sandbox.
70
- * These are inherited by all commands unless overridden with
71
- * the `env` option in `runCommand`.
72
- *
73
- * @example
74
- * const sandbox = await Sandbox.create({
75
- * env: { NODE_ENV: "production", API_KEY: "secret" },
76
- * });
77
- * // All commands will have NODE_ENV and API_KEY set
78
- * await sandbox.runCommand("node", ["app.js"]);
79
- */
80
- env?: Record<string, string>;
81
- /**
82
- * An AbortSignal to cancel sandbox creation.
83
- */
84
- signal?: AbortSignal;
18
+ interface BaseCreateSandboxParams {
19
+ /**
20
+ * The source of the sandbox.
21
+ *
22
+ * Omit this parameter start a sandbox without a source.
23
+ *
24
+ * For git sources:
25
+ * - `depth`: Creates shallow clones with limited commit history (minimum: 1)
26
+ * - `revision`: Clones and checks out a specific commit, branch, or tag
27
+ */
28
+ source?: {
29
+ type: "git";
30
+ url: string;
31
+ depth?: number;
32
+ revision?: string;
33
+ } | {
34
+ type: "git";
35
+ url: string;
36
+ username: string;
37
+ password: string;
38
+ depth?: number;
39
+ revision?: string;
40
+ } | {
41
+ type: "tarball";
42
+ url: string;
43
+ };
44
+ /**
45
+ * Array of port numbers to expose from the sandbox. Sandboxes can
46
+ * expose up to 4 ports.
47
+ */
48
+ ports?: number[];
49
+ /**
50
+ * Timeout in milliseconds before the sandbox auto-terminates.
51
+ */
52
+ timeout?: number;
53
+ /**
54
+ * Resources to allocate to the sandbox.
55
+ *
56
+ * Your sandbox will get the amount of vCPUs you specify here and
57
+ * 2048 MB of memory per vCPU.
58
+ */
59
+ resources?: {
60
+ vcpus: number;
61
+ };
62
+ /**
63
+ * The runtime of the sandbox, currently only `node24`, `node22` and `python3.13` are supported.
64
+ * If not specified, the default runtime `node24` will be used.
65
+ */
66
+ runtime?: RUNTIMES | (string & {});
67
+ /**
68
+ * Network policy to define network restrictions for the sandbox.
69
+ * Defaults to full internet access if not specified.
70
+ */
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>;
85
+ /**
86
+ * An AbortSignal to cancel sandbox creation.
87
+ */
88
+ signal?: AbortSignal;
85
89
  }
86
- export type CreateSandboxParams = BaseCreateSandboxParams | (Omit<BaseCreateSandboxParams, "runtime" | "source"> & {
87
- source: {
88
- type: "snapshot";
89
- snapshotId: string;
90
- };
90
+ type CreateSandboxParams = BaseCreateSandboxParams | (Omit<BaseCreateSandboxParams, "runtime" | "source"> & {
91
+ source: {
92
+ type: "snapshot";
93
+ snapshotId: string;
94
+ };
91
95
  });
92
96
  /** @inline */
93
97
  interface GetSandboxParams {
94
- /**
95
- * Unique identifier of the sandbox.
96
- */
97
- sandboxId: string;
98
- /**
99
- * An AbortSignal to cancel the operation.
100
- */
101
- signal?: AbortSignal;
98
+ /**
99
+ * Unique identifier of the sandbox.
100
+ */
101
+ sandboxId: string;
102
+ /**
103
+ * An AbortSignal to cancel the operation.
104
+ */
105
+ signal?: AbortSignal;
106
+ }
107
+ /**
108
+ * Serialized representation of a Sandbox for @workflow/serde.
109
+ */
110
+ interface SerializedSandbox {
111
+ metadata: SandboxSnapshot;
112
+ routes: SandboxRouteData[];
102
113
  }
103
114
  /** @inline */
104
115
  interface RunCommandParams {
105
- /**
106
- * The command to execute
107
- */
108
- cmd: string;
109
- /**
110
- * Arguments to pass to the command
111
- */
112
- args?: string[];
113
- /**
114
- * Working directory to execute the command in
115
- */
116
- cwd?: string;
117
- /**
118
- * Environment variables to set for this command
119
- */
120
- env?: Record<string, string>;
121
- /**
122
- * If true, execute this command with root privileges. Defaults to false.
123
- */
124
- sudo?: boolean;
125
- /**
126
- * If true, the command will return without waiting for `exitCode`
127
- */
128
- detached?: boolean;
129
- /**
130
- * A `Writable` stream where `stdout` from the command will be piped
131
- */
132
- stdout?: Writable;
133
- /**
134
- * A `Writable` stream where `stderr` from the command will be piped
135
- */
136
- stderr?: Writable;
137
- /**
138
- * An AbortSignal to cancel the command execution
139
- */
140
- signal?: AbortSignal;
116
+ /**
117
+ * The command to execute
118
+ */
119
+ cmd: string;
120
+ /**
121
+ * Arguments to pass to the command
122
+ */
123
+ args?: string[];
124
+ /**
125
+ * Working directory to execute the command in
126
+ */
127
+ cwd?: string;
128
+ /**
129
+ * Environment variables to set for this command
130
+ */
131
+ env?: Record<string, string>;
132
+ /**
133
+ * If true, execute this command with root privileges. Defaults to false.
134
+ */
135
+ sudo?: boolean;
136
+ /**
137
+ * If true, the command will return without waiting for `exitCode`
138
+ */
139
+ detached?: boolean;
140
+ /**
141
+ * A `Writable` stream where `stdout` from the command will be piped
142
+ */
143
+ stdout?: Writable;
144
+ /**
145
+ * A `Writable` stream where `stderr` from the command will be piped
146
+ */
147
+ stderr?: Writable;
148
+ /**
149
+ * An AbortSignal to cancel the command execution
150
+ */
151
+ signal?: AbortSignal;
141
152
  }
142
153
  /**
143
154
  * A Sandbox is an isolated Linux MicroVM to run commands in.
@@ -145,353 +156,384 @@ interface RunCommandParams {
145
156
  * Use {@link Sandbox.create} or {@link Sandbox.get} to construct.
146
157
  * @hideconstructor
147
158
  */
148
- export declare class Sandbox {
149
- private readonly client;
150
- /**
151
- * Routes from ports to subdomains.
152
- /* @hidden
153
- */
154
- readonly routes: SandboxRouteData[];
155
- /**
156
- * Unique ID of this sandbox.
157
- */
158
- get sandboxId(): string;
159
- get interactivePort(): number | undefined;
160
- /**
161
- * The status of the sandbox.
162
- */
163
- get status(): SandboxMetaData["status"];
164
- /**
165
- * The creation date of the sandbox.
166
- */
167
- get createdAt(): Date;
168
- /**
169
- * The timeout of the sandbox in milliseconds.
170
- */
171
- get timeout(): number;
172
- /**
173
- * The network policy of the sandbox.
174
- */
175
- get networkPolicy(): NetworkPolicy | undefined;
176
- /**
177
- * If the sandbox was created from a snapshot, the ID of that snapshot.
178
- */
179
- get sourceSnapshotId(): string | undefined;
180
- /**
181
- * The amount of CPU used by the sandbox. Only reported once the VM is stopped.
182
- */
183
- get activeCpuUsageMs(): number | undefined;
184
- /**
185
- * The amount of network data used by the sandbox. Only reported once the VM is stopped.
186
- */
187
- get networkTransfer(): {
159
+ declare class Sandbox {
160
+ private _client;
161
+ /**
162
+ * Lazily resolve credentials and construct an API client.
163
+ * This is used in step contexts where the Sandbox was deserialized
164
+ * without a client (e.g. when crossing workflow/step boundaries).
165
+ * Uses getCredentials() which resolves from OIDC or env vars.
166
+ * @internal
167
+ */
168
+ private ensureClient;
169
+ /**
170
+ * Routes from ports to subdomains.
171
+ /* @hidden
172
+ */
173
+ readonly routes: SandboxRouteData[];
174
+ /**
175
+ * Unique ID of this sandbox.
176
+ */
177
+ get sandboxId(): string;
178
+ get interactivePort(): number | undefined;
179
+ /**
180
+ * The status of the sandbox.
181
+ */
182
+ get status(): SandboxMetaData["status"];
183
+ /**
184
+ * The creation date of the sandbox.
185
+ */
186
+ get createdAt(): Date;
187
+ /**
188
+ * The timeout of the sandbox in milliseconds.
189
+ */
190
+ get timeout(): number;
191
+ /**
192
+ * The network policy of the sandbox.
193
+ */
194
+ get networkPolicy(): NetworkPolicy | undefined;
195
+ /**
196
+ * If the sandbox was created from a snapshot, the ID of that snapshot.
197
+ */
198
+ get sourceSnapshotId(): string | undefined;
199
+ /**
200
+ * The amount of CPU used by the sandbox. Only reported once the VM is stopped.
201
+ */
202
+ get activeCpuUsageMs(): number | undefined;
203
+ /**
204
+ * The amount of network data used by the sandbox. Only reported once the VM is stopped.
205
+ */
206
+ get networkTransfer(): {
207
+ ingress: number;
208
+ egress: number;
209
+ } | undefined;
210
+ /**
211
+ * Internal metadata about this sandbox.
212
+ */
213
+ private sandbox;
214
+ /**
215
+ * Allow to get a list of sandboxes for a team narrowed to the given params.
216
+ * It returns both the sandboxes and the pagination metadata to allow getting
217
+ * the next page of results.
218
+ */
219
+ static list(params?: Partial<Parameters<APIClient["listSandboxes"]>[0]> & Partial<Credentials> & WithFetchOptions): Promise<Parsed<{
220
+ sandboxes: {
221
+ status: "aborted" | "pending" | "running" | "stopping" | "stopped" | "failed" | "snapshotting";
222
+ id: string;
223
+ memory: number;
224
+ vcpus: number;
225
+ region: string;
226
+ runtime: string;
227
+ timeout: number;
228
+ requestedAt: number;
229
+ createdAt: number;
230
+ cwd: string;
231
+ updatedAt: number;
232
+ startedAt?: number | undefined;
233
+ requestedStopAt?: number | undefined;
234
+ stoppedAt?: number | undefined;
235
+ abortedAt?: number | undefined;
236
+ duration?: number | undefined;
237
+ sourceSnapshotId?: string | undefined;
238
+ snapshottedAt?: number | undefined;
239
+ interactivePort?: number | undefined;
240
+ networkPolicy?: zod0.objectInputType<{
241
+ mode: zod0.ZodLiteral<"allow-all">;
242
+ }, zod0.ZodTypeAny, "passthrough"> | zod0.objectInputType<{
243
+ mode: zod0.ZodLiteral<"deny-all">;
244
+ }, zod0.ZodTypeAny, "passthrough"> | zod0.objectInputType<{
245
+ mode: zod0.ZodLiteral<"custom">;
246
+ allowedDomains: zod0.ZodOptional<zod0.ZodArray<zod0.ZodString, "many">>;
247
+ allowedCIDRs: zod0.ZodOptional<zod0.ZodArray<zod0.ZodString, "many">>;
248
+ deniedCIDRs: zod0.ZodOptional<zod0.ZodArray<zod0.ZodString, "many">>;
249
+ injectionRules: zod0.ZodOptional<zod0.ZodArray<zod0.ZodObject<{
250
+ domain: zod0.ZodString;
251
+ headers: zod0.ZodOptional<zod0.ZodRecord<zod0.ZodString, zod0.ZodString>>;
252
+ headerNames: zod0.ZodOptional<zod0.ZodArray<zod0.ZodString, "many">>;
253
+ }, "strip", zod0.ZodTypeAny, {
254
+ domain: string;
255
+ headers?: Record<string, string> | undefined;
256
+ headerNames?: string[] | undefined;
257
+ }, {
258
+ domain: string;
259
+ headers?: Record<string, string> | undefined;
260
+ headerNames?: string[] | undefined;
261
+ }>, "many">>;
262
+ }, zod0.ZodTypeAny, "passthrough"> | undefined;
263
+ activeCpuDurationMs?: number | undefined;
264
+ networkTransfer?: {
188
265
  ingress: number;
189
266
  egress: number;
190
- } | undefined;
191
- /**
192
- * Internal metadata about this sandbox.
193
- */
194
- private sandbox;
195
- /**
196
- * Allow to get a list of sandboxes for a team narrowed to the given params.
197
- * It returns both the sandboxes and the pagination metadata to allow getting
198
- * the next page of results.
199
- */
200
- static list(params?: Partial<Parameters<APIClient["listSandboxes"]>[0]> & Partial<Credentials> & WithFetchOptions): Promise<import("./api-client/base-client").Parsed<{
201
- sandboxes: {
202
- id: string;
203
- memory: number;
204
- vcpus: number;
205
- region: string;
206
- runtime: string;
207
- timeout: number;
208
- status: "aborted" | "pending" | "running" | "stopping" | "stopped" | "failed" | "snapshotting";
209
- requestedAt: number;
210
- createdAt: number;
211
- cwd: string;
212
- updatedAt: number;
213
- startedAt?: number | undefined;
214
- requestedStopAt?: number | undefined;
215
- stoppedAt?: number | undefined;
216
- abortedAt?: number | undefined;
217
- duration?: number | undefined;
218
- sourceSnapshotId?: string | undefined;
219
- snapshottedAt?: number | undefined;
220
- interactivePort?: number | undefined;
221
- networkPolicy?: import("zod").objectInputType<{
222
- mode: import("zod").ZodLiteral<"allow-all">;
223
- }, import("zod").ZodTypeAny, "passthrough"> | import("zod").objectInputType<{
224
- mode: import("zod").ZodLiteral<"deny-all">;
225
- }, import("zod").ZodTypeAny, "passthrough"> | import("zod").objectInputType<{
226
- mode: import("zod").ZodLiteral<"custom">;
227
- allowedDomains: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
228
- allowedCIDRs: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
229
- deniedCIDRs: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
230
- injectionRules: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
231
- domain: import("zod").ZodString;
232
- headers: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
233
- headerNames: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
234
- }, "strip", import("zod").ZodTypeAny, {
235
- domain: string;
236
- headers?: Record<string, string> | undefined;
237
- headerNames?: string[] | undefined;
238
- }, {
239
- domain: string;
240
- headers?: Record<string, string> | undefined;
241
- headerNames?: string[] | undefined;
242
- }>, "many">>;
243
- }, import("zod").ZodTypeAny, "passthrough"> | undefined;
244
- activeCpuDurationMs?: number | undefined;
245
- networkTransfer?: {
246
- ingress: number;
247
- egress: number;
248
- } | undefined;
249
- }[];
250
- pagination: {
251
- count: number;
252
- next: number | null;
253
- prev: number | null;
254
- };
255
- }>>;
256
- /**
257
- * Create a new sandbox.
258
- *
259
- * @param params - Creation parameters and optional credentials.
260
- * @returns A promise resolving to the created {@link Sandbox}.
261
- * @example
262
- * <caption>Create a sandbox and drop it in the end of the block</caption>
263
- * async function fn() {
264
- * await using const sandbox = await Sandbox.create();
265
- * // Sandbox automatically stopped at the end of the lexical scope
266
- * }
267
- */
268
- static create(params?: WithPrivate<CreateSandboxParams | (CreateSandboxParams & Credentials)> & WithFetchOptions): Promise<Sandbox & AsyncDisposable>;
269
- /**
270
- * Retrieve an existing sandbox.
271
- *
272
- * @param params - Get parameters and optional credentials.
273
- * @returns A promise resolving to the {@link Sandbox}.
274
- */
275
- static get(params: WithPrivate<GetSandboxParams | (GetSandboxParams & Credentials)> & WithFetchOptions): Promise<Sandbox>;
276
- constructor({ client, routes, sandbox, }: {
277
- client: APIClient;
278
- routes: SandboxRouteData[];
279
- sandbox: SandboxMetaData;
280
- });
281
- /**
282
- * Get a previously run command by its ID.
283
- *
284
- * @param cmdId - ID of the command to retrieve
285
- * @param opts - Optional parameters.
286
- * @param opts.signal - An AbortSignal to cancel the operation.
287
- * @returns A {@link Command} instance representing the command
288
- */
289
- getCommand(cmdId: string, opts?: {
290
- signal?: AbortSignal;
291
- }): Promise<Command>;
292
- /**
293
- * Start executing a command in this sandbox.
294
- *
295
- * @param command - The command to execute.
296
- * @param args - Arguments to pass to the command.
297
- * @param opts - Optional parameters.
298
- * @param opts.signal - An AbortSignal to cancel the command execution.
299
- * @returns A {@link CommandFinished} result once execution is done.
300
- */
301
- runCommand(command: string, args?: string[], opts?: {
302
- signal?: AbortSignal;
303
- }): Promise<CommandFinished>;
304
- /**
305
- * Start executing a command in detached mode.
306
- *
307
- * @param params - The command parameters.
308
- * @returns A {@link Command} instance for the running command.
309
- */
310
- runCommand(params: RunCommandParams & {
311
- detached: true;
312
- }): Promise<Command>;
313
- /**
314
- * Start executing a command in this sandbox.
315
- *
316
- * @param params - The command parameters.
317
- * @returns A {@link CommandFinished} result once execution is done.
318
- */
319
- runCommand(params: RunCommandParams): Promise<CommandFinished>;
320
- /**
321
- * Internal helper to start a command in the sandbox.
322
- *
323
- * @param params - Command execution parameters.
324
- * @returns A {@link Command} or {@link CommandFinished}, depending on `detached`.
325
- * @internal
326
- */
327
- _runCommand(params: RunCommandParams): Promise<Command>;
328
- /**
329
- * Create a directory in the filesystem of this sandbox.
330
- *
331
- * @param path - Path of the directory to create
332
- * @param opts - Optional parameters.
333
- * @param opts.signal - An AbortSignal to cancel the operation.
334
- */
335
- mkDir(path: string, opts?: {
336
- signal?: AbortSignal;
337
- }): Promise<void>;
338
- /**
339
- * Read a file from the filesystem of this sandbox as a stream.
340
- *
341
- * @param file - File to read, with path and optional cwd
342
- * @param opts - Optional parameters.
343
- * @param opts.signal - An AbortSignal to cancel the operation.
344
- * @returns A promise that resolves to a ReadableStream containing the file contents, or null if file not found
345
- */
346
- readFile(file: {
347
- path: string;
348
- cwd?: string;
349
- }, opts?: {
350
- signal?: AbortSignal;
351
- }): Promise<NodeJS.ReadableStream | null>;
352
- /**
353
- * Read a file from the filesystem of this sandbox as a Buffer.
354
- *
355
- * @param file - File to read, with path and optional cwd
356
- * @param opts - Optional parameters.
357
- * @param opts.signal - An AbortSignal to cancel the operation.
358
- * @returns A promise that resolves to the file contents as a Buffer, or null if file not found
359
- */
360
- readFileToBuffer(file: {
361
- path: string;
362
- cwd?: string;
363
- }, opts?: {
364
- signal?: AbortSignal;
365
- }): Promise<Buffer | null>;
366
- /**
367
- * Download a file from the sandbox to the local filesystem.
368
- *
369
- * @param src - Source file on the sandbox, with path and optional cwd
370
- * @param dst - Destination file on the local machine, with path and optional cwd
371
- * @param opts - Optional parameters.
372
- * @param opts.mkdirRecursive - If true, create parent directories for the destination if they don't exist.
373
- * @param opts.signal - An AbortSignal to cancel the operation.
374
- * @returns The absolute path to the written file, or null if the source file was not found
375
- */
376
- downloadFile(src: {
377
- path: string;
378
- cwd?: string;
379
- }, dst: {
380
- path: string;
381
- cwd?: string;
382
- }, opts?: {
383
- mkdirRecursive?: boolean;
384
- signal?: AbortSignal;
385
- }): Promise<string | null>;
386
- /**
387
- * Write files to the filesystem of this sandbox.
388
- * Defaults to writing to /vercel/sandbox unless an absolute path is specified.
389
- * Writes files using the `vercel-sandbox` user.
390
- *
391
- * @param files - Array of files with path, content, and optional mode (permissions)
392
- * @param opts - Optional parameters.
393
- * @param opts.signal - An AbortSignal to cancel the operation.
394
- * @returns A promise that resolves when the files are written
395
- *
396
- * @example
397
- * // Write an executable script
398
- * await sandbox.writeFiles([
399
- * { path: "/usr/local/bin/myscript", content: Buffer.from("#!/bin/bash\necho hello"), mode: 0o755 }
400
- * ]);
401
- */
402
- writeFiles(files: {
403
- path: string;
404
- content: Buffer;
405
- mode?: number;
406
- }[], opts?: {
407
- signal?: AbortSignal;
408
- }): Promise<void>;
409
- /**
410
- * Get the public domain of a port of this sandbox.
411
- *
412
- * @param p - Port number to resolve
413
- * @returns A full domain (e.g. `https://subdomain.vercel.run`)
414
- * @throws If the port has no associated route
415
- */
416
- domain(p: number): string;
417
- /**
418
- * Stop the sandbox.
419
- *
420
- * @param opts - Optional parameters.
421
- * @param opts.signal - An AbortSignal to cancel the operation.
422
- * @param opts.blocking - If true, poll until the sandbox has fully stopped and return the final state.
423
- * @returns The sandbox metadata at the time the stop was acknowledged, or after fully stopped if `blocking` is true.
424
- */
425
- stop(opts?: {
426
- signal?: AbortSignal;
427
- blocking?: boolean;
428
- }): Promise<ConvertedSandbox>;
429
- /**
430
- * Update the network policy for this sandbox.
431
- *
432
- * @param networkPolicy - The new network policy to apply.
433
- * @param opts - Optional parameters.
434
- * @param opts.signal - An AbortSignal to cancel the operation.
435
- * @returns A promise that resolves when the network policy is updated.
436
- *
437
- * @example
438
- * // Restrict to specific domains
439
- * await sandbox.updateNetworkPolicy({
440
- * allow: ["*.npmjs.org", "github.com"],
441
- * });
442
- *
443
- * @example
444
- * // Inject credentials with per-domain transformers
445
- * await sandbox.updateNetworkPolicy({
446
- * allow: {
447
- * "ai-gateway.vercel.sh": [{
448
- * transform: [{
449
- * headers: { authorization: "Bearer ..." }
450
- * }]
451
- * }],
452
- * "*": []
453
- * }
454
- * });
455
- *
456
- * @example
457
- * // Deny all network access
458
- * await sandbox.updateNetworkPolicy("deny-all");
459
- */
460
- updateNetworkPolicy(networkPolicy: NetworkPolicy, opts?: {
461
- signal?: AbortSignal;
462
- }): Promise<NetworkPolicy>;
463
- /**
464
- * Extend the timeout of the sandbox by the specified duration.
465
- *
466
- * This allows you to extend the lifetime of a sandbox up until the maximum
467
- * execution timeout for your plan.
468
- *
469
- * @param duration - The duration in milliseconds to extend the timeout by
470
- * @param opts - Optional parameters.
471
- * @param opts.signal - An AbortSignal to cancel the operation.
472
- * @returns A promise that resolves when the timeout is extended
473
- *
474
- * @example
475
- * const sandbox = await Sandbox.create({ timeout: ms('10m') });
476
- * // Extends timeout by 5 minutes, to a total of 15 minutes.
477
- * await sandbox.extendTimeout(ms('5m'));
478
- */
479
- extendTimeout(duration: number, opts?: {
480
- signal?: AbortSignal;
481
- }): Promise<void>;
482
- /**
483
- * Create a snapshot from this currently running sandbox. New sandboxes can
484
- * then be created from this snapshot using {@link Sandbox.createFromSnapshot}.
485
- *
486
- * Note: this sandbox will be stopped as part of the snapshot creation process.
487
- *
488
- * @param opts - Optional parameters.
489
- * @param opts.expiration - Optional expiration time in milliseconds. Use 0 for no expiration at all.
490
- * @param opts.signal - An AbortSignal to cancel the operation.
491
- * @returns A promise that resolves to the Snapshot instance
492
- */
493
- snapshot(opts?: {
494
- expiration?: number;
495
- signal?: AbortSignal;
496
- }): Promise<Snapshot>;
267
+ } | undefined;
268
+ }[];
269
+ pagination: {
270
+ count: number;
271
+ next: number | null;
272
+ prev: number | null;
273
+ };
274
+ }>>;
275
+ /**
276
+ * Serialize a Sandbox instance to plain data for @workflow/serde.
277
+ *
278
+ * @param instance - The Sandbox instance to serialize
279
+ * @returns A plain object containing sandbox metadata and routes
280
+ */
281
+ static [WORKFLOW_SERIALIZE](instance: Sandbox): SerializedSandbox;
282
+ /**
283
+ * Deserialize a Sandbox from serialized snapshot data.
284
+ *
285
+ * The deserialized instance uses the serialized metadata synchronously and
286
+ * lazily creates an API client only when methods perform API requests.
287
+ *
288
+ * @param data - The serialized sandbox data
289
+ * @returns The reconstructed Sandbox instance
290
+ */
291
+ static [WORKFLOW_DESERIALIZE](data: SerializedSandbox): Sandbox;
292
+ /**
293
+ * Create a new sandbox.
294
+ *
295
+ * @param params - Creation parameters and optional credentials.
296
+ * @returns A promise resolving to the created {@link Sandbox}.
297
+ * @example
298
+ * <caption>Create a sandbox and drop it in the end of the block</caption>
299
+ * async function fn() {
300
+ * await using const sandbox = await Sandbox.create();
301
+ * // Sandbox automatically stopped at the end of the lexical scope
302
+ * }
303
+ */
304
+ static create(params?: WithPrivate<CreateSandboxParams | (CreateSandboxParams & Credentials)> & WithFetchOptions): Promise<Sandbox & AsyncDisposable>;
305
+ /**
306
+ * Retrieve an existing sandbox.
307
+ *
308
+ * @param params - Get parameters and optional credentials.
309
+ * @returns A promise resolving to the {@link Sandbox}.
310
+ */
311
+ static get(params: WithPrivate<GetSandboxParams | (GetSandboxParams & Credentials)> & WithFetchOptions): Promise<Sandbox>;
312
+ /**
313
+ * Create a new Sandbox instance.
314
+ *
315
+ * @param params.client - Optional API client. If not provided, will be lazily created using global credentials.
316
+ * @param params.routes - Port-to-subdomain mappings for exposed ports
317
+ * @param params.sandbox - Sandbox snapshot metadata
318
+ */
319
+ constructor({
320
+ client,
321
+ routes,
322
+ sandbox
323
+ }: {
324
+ client?: APIClient;
325
+ routes: SandboxRouteData[];
326
+ sandbox: SandboxSnapshot;
327
+ });
328
+ /**
329
+ * Get a previously run command by its ID.
330
+ *
331
+ * @param cmdId - ID of the command to retrieve
332
+ * @param opts - Optional parameters.
333
+ * @param opts.signal - An AbortSignal to cancel the operation.
334
+ * @returns A {@link Command} instance representing the command
335
+ */
336
+ getCommand(cmdId: string, opts?: {
337
+ signal?: AbortSignal;
338
+ }): Promise<Command>;
339
+ /**
340
+ * Start executing a command in this sandbox.
341
+ *
342
+ * @param command - The command to execute.
343
+ * @param args - Arguments to pass to the command.
344
+ * @param opts - Optional parameters.
345
+ * @param opts.signal - An AbortSignal to cancel the command execution.
346
+ * @returns A {@link CommandFinished} result once execution is done.
347
+ */
348
+ runCommand(command: string, args?: string[], opts?: {
349
+ signal?: AbortSignal;
350
+ }): Promise<CommandFinished>;
351
+ /**
352
+ * Start executing a command in detached mode.
353
+ *
354
+ * @param params - The command parameters.
355
+ * @returns A {@link Command} instance for the running command.
356
+ */
357
+ runCommand(params: RunCommandParams & {
358
+ detached: true;
359
+ }): Promise<Command>;
360
+ /**
361
+ * Start executing a command in this sandbox.
362
+ *
363
+ * @param params - The command parameters.
364
+ * @returns A {@link CommandFinished} result once execution is done.
365
+ */
366
+ runCommand(params: RunCommandParams): Promise<CommandFinished>;
367
+ /**
368
+ * Create a directory in the filesystem of this sandbox.
369
+ *
370
+ * @param path - Path of the directory to create
371
+ * @param opts - Optional parameters.
372
+ * @param opts.signal - An AbortSignal to cancel the operation.
373
+ */
374
+ mkDir(path: string, opts?: {
375
+ signal?: AbortSignal;
376
+ }): Promise<void>;
377
+ /**
378
+ * Read a file from the filesystem of this sandbox as a stream.
379
+ *
380
+ * @param file - File to read, with path and optional cwd
381
+ * @param opts - Optional parameters.
382
+ * @param opts.signal - An AbortSignal to cancel the operation.
383
+ * @returns A promise that resolves to a ReadableStream containing the file contents, or null if file not found
384
+ */
385
+ readFile(file: {
386
+ path: string;
387
+ cwd?: string;
388
+ }, opts?: {
389
+ signal?: AbortSignal;
390
+ }): Promise<NodeJS.ReadableStream | null>;
391
+ /**
392
+ * Read a file from the filesystem of this sandbox as a Buffer.
393
+ *
394
+ * @param file - File to read, with path and optional cwd
395
+ * @param opts - Optional parameters.
396
+ * @param opts.signal - An AbortSignal to cancel the operation.
397
+ * @returns A promise that resolves to the file contents as a Buffer, or null if file not found
398
+ */
399
+ readFileToBuffer(file: {
400
+ path: string;
401
+ cwd?: string;
402
+ }, opts?: {
403
+ signal?: AbortSignal;
404
+ }): Promise<Buffer | null>;
405
+ /**
406
+ * Download a file from the sandbox to the local filesystem.
407
+ *
408
+ * @param src - Source file on the sandbox, with path and optional cwd
409
+ * @param dst - Destination file on the local machine, with path and optional cwd
410
+ * @param opts - Optional parameters.
411
+ * @param opts.mkdirRecursive - If true, create parent directories for the destination if they don't exist.
412
+ * @param opts.signal - An AbortSignal to cancel the operation.
413
+ * @returns The absolute path to the written file, or null if the source file was not found
414
+ */
415
+ downloadFile(src: {
416
+ path: string;
417
+ cwd?: string;
418
+ }, dst: {
419
+ path: string;
420
+ cwd?: string;
421
+ }, opts?: {
422
+ mkdirRecursive?: boolean;
423
+ signal?: AbortSignal;
424
+ }): Promise<string | null>;
425
+ /**
426
+ * Write files to the filesystem of this sandbox.
427
+ * Defaults to writing to /vercel/sandbox unless an absolute path is specified.
428
+ * Writes files using the `vercel-sandbox` user.
429
+ *
430
+ * @param files - Array of files with path, content, and optional mode (permissions)
431
+ * @param opts - Optional parameters.
432
+ * @param opts.signal - An AbortSignal to cancel the operation.
433
+ * @returns A promise that resolves when the files are written
434
+ *
435
+ * @example
436
+ * // Write an executable script
437
+ * await sandbox.writeFiles([
438
+ * { path: "/usr/local/bin/myscript", content: "#!/bin/bash\necho hello", mode: 0o755 }
439
+ * ]);
440
+ */
441
+ writeFiles(files: {
442
+ path: string;
443
+ content: string | Uint8Array;
444
+ mode?: number;
445
+ }[], opts?: {
446
+ signal?: AbortSignal;
447
+ }): Promise<void>;
448
+ /**
449
+ * Get the public domain of a port of this sandbox.
450
+ *
451
+ * @param p - Port number to resolve
452
+ * @returns A full domain (e.g. `https://subdomain.vercel.run`)
453
+ * @throws If the port has no associated route
454
+ */
455
+ domain(p: number): string;
456
+ /**
457
+ * Stop the sandbox.
458
+ *
459
+ * @param opts - Optional parameters.
460
+ * @param opts.signal - An AbortSignal to cancel the operation.
461
+ * @param opts.blocking - If true, poll until the sandbox has fully stopped and return the final state.
462
+ * @returns The sandbox metadata at the time the stop was acknowledged, or after fully stopped if `blocking` is true.
463
+ */
464
+ stop(opts?: {
465
+ signal?: AbortSignal;
466
+ blocking?: boolean;
467
+ }): Promise<SandboxSnapshot>;
468
+ /**
469
+ * Update the network policy for this sandbox.
470
+ *
471
+ * @param networkPolicy - The new network policy to apply.
472
+ * @param opts - Optional parameters.
473
+ * @param opts.signal - An AbortSignal to cancel the operation.
474
+ * @returns A promise that resolves when the network policy is updated.
475
+ *
476
+ * @example
477
+ * // Restrict to specific domains
478
+ * await sandbox.updateNetworkPolicy({
479
+ * allow: ["*.npmjs.org", "github.com"],
480
+ * });
481
+ *
482
+ * @example
483
+ * // Inject credentials with per-domain transformers
484
+ * await sandbox.updateNetworkPolicy({
485
+ * allow: {
486
+ * "ai-gateway.vercel.sh": [{
487
+ * transform: [{
488
+ * headers: { authorization: "Bearer ..." }
489
+ * }]
490
+ * }],
491
+ * "*": []
492
+ * }
493
+ * });
494
+ *
495
+ * @example
496
+ * // Deny all network access
497
+ * await sandbox.updateNetworkPolicy("deny-all");
498
+ */
499
+ updateNetworkPolicy(networkPolicy: NetworkPolicy, opts?: {
500
+ signal?: AbortSignal;
501
+ }): Promise<NetworkPolicy>;
502
+ /**
503
+ * Extend the timeout of the sandbox by the specified duration.
504
+ *
505
+ * This allows you to extend the lifetime of a sandbox up until the maximum
506
+ * execution timeout for your plan.
507
+ *
508
+ * @param duration - The duration in milliseconds to extend the timeout by
509
+ * @param opts - Optional parameters.
510
+ * @param opts.signal - An AbortSignal to cancel the operation.
511
+ * @returns A promise that resolves when the timeout is extended
512
+ *
513
+ * @example
514
+ * const sandbox = await Sandbox.create({ timeout: ms('10m') });
515
+ * // Extends timeout by 5 minutes, to a total of 15 minutes.
516
+ * await sandbox.extendTimeout(ms('5m'));
517
+ */
518
+ extendTimeout(duration: number, opts?: {
519
+ signal?: AbortSignal;
520
+ }): Promise<void>;
521
+ /**
522
+ * Create a snapshot from this currently running sandbox. New sandboxes can
523
+ * then be created from this snapshot using {@link Sandbox.createFromSnapshot}.
524
+ *
525
+ * Note: this sandbox will be stopped as part of the snapshot creation process.
526
+ *
527
+ * @param opts - Optional parameters.
528
+ * @param opts.expiration - Optional expiration time in milliseconds. Use 0 for no expiration at all.
529
+ * @param opts.signal - An AbortSignal to cancel the operation.
530
+ * @returns A promise that resolves to the Snapshot instance
531
+ */
532
+ snapshot(opts?: {
533
+ expiration?: number;
534
+ signal?: AbortSignal;
535
+ }): Promise<Snapshot>;
497
536
  }
537
+ //#endregion
538
+ export { Sandbox, SerializedSandbox };
539
+ //# sourceMappingURL=sandbox.d.ts.map