withruntime 0.11.2 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BLAXEL.md +2 -2
- package/COMPATIBILITY.md +74 -9
- package/DAYTONA.md +33 -5
- package/E2B.md +85 -24
- package/README.md +11 -10
- package/README.src.md +10 -9
- package/VERCEL.md +43 -5
- package/compatibility-lock.json +58 -49
- package/dist/billing-cli.d.ts +1 -1
- package/dist/billing-cli.js +85 -5
- package/dist/blaxel/errors.d.ts +14 -0
- package/dist/blaxel/errors.js +29 -0
- package/dist/blaxel/index.d.ts +2 -2
- package/dist/blaxel/index.js +4 -4
- package/dist/blaxel/interpreter.d.ts +2 -5
- package/dist/blaxel/sandbox.d.ts +15 -6
- package/dist/blaxel/sandbox.js +64 -8
- package/dist/blaxel/snapshot.d.ts +4 -0
- package/dist/blaxel/snapshot.js +4 -0
- package/dist/cli/logs.d.ts +21 -0
- package/dist/cli/logs.js +188 -0
- package/dist/cli-extras.d.ts +3 -3
- package/dist/cli-extras.js +17 -12
- package/dist/cli-words.d.ts +10 -1
- package/dist/cli-words.js +18 -0
- package/dist/cli.d.ts +22 -3
- package/dist/cli.js +647 -273
- package/dist/client.d.ts +2 -4
- package/dist/client.js +27 -11
- package/dist/cloudflare/errors.d.ts +143 -0
- package/dist/cloudflare/errors.js +167 -0
- package/dist/cloudflare/index.d.ts +175 -6
- package/dist/cloudflare/index.js +416 -26
- package/dist/cloudflare/interpreter.d.ts +119 -0
- package/dist/cloudflare/interpreter.js +223 -0
- package/dist/cloudflare/streams.d.ts +38 -0
- package/dist/cloudflare/streams.js +145 -0
- package/dist/cloudflare/watch.d.ts +9 -0
- package/dist/cloudflare/watch.js +24 -0
- package/dist/codesandbox/index.d.ts +216 -28
- package/dist/codesandbox/index.js +478 -78
- package/dist/compat/core.d.ts +18 -0
- package/dist/compat/core.js +29 -0
- package/dist/compat/files.d.ts +1 -0
- package/dist/compat/files.js +25 -5
- package/dist/credentials.d.ts +3 -0
- package/dist/credentials.js +15 -0
- package/dist/daytona/computer-use.d.ts +13 -4
- package/dist/daytona/computer-use.js +66 -8
- package/dist/daytona/daytona.d.ts +7 -1
- package/dist/daytona/daytona.js +31 -4
- package/dist/daytona/errors.d.ts +11 -0
- package/dist/daytona/errors.js +18 -0
- package/dist/daytona/filesystem.js +2 -1
- package/dist/daytona/image.d.ts +13 -9
- package/dist/daytona/image.js +18 -12
- package/dist/daytona/index.d.ts +1 -1
- package/dist/daytona/sandbox.d.ts +8 -2
- package/dist/daytona/sandbox.js +16 -2
- package/dist/domains/index.d.ts +9 -0
- package/dist/domains/index.js +10 -0
- package/dist/e2b/commands.d.ts +1 -1
- package/dist/e2b/commands.js +6 -7
- package/dist/e2b/errors.d.ts +17 -0
- package/dist/e2b/errors.js +40 -1
- package/dist/e2b/index.d.ts +2 -2
- package/dist/e2b/index.js +1 -1
- package/dist/e2b/sandbox.d.ts +28 -22
- package/dist/e2b/sandbox.js +34 -8
- package/dist/e2b/unsupported.js +1 -1
- package/dist/errors.d.ts +11 -2
- package/dist/errors.js +17 -5
- package/dist/freestyle/index.d.ts +285 -37
- package/dist/freestyle/index.js +656 -144
- package/dist/identity.d.ts +3 -0
- package/dist/identity.js +27 -0
- package/dist/images/index.d.ts +9 -0
- package/dist/images/index.js +10 -0
- package/dist/index.d.ts +3 -1
- package/dist/ips/index.d.ts +9 -0
- package/dist/ips/index.js +10 -0
- package/dist/jobs/index.d.ts +9 -0
- package/dist/jobs/index.js +10 -0
- package/dist/keys.js +2 -0
- package/dist/login.js +2 -0
- package/dist/machine.d.ts +27 -4
- package/dist/machine.js +46 -14
- package/dist/mcp.js +144 -20
- package/dist/modal/index.d.ts +339 -61
- package/dist/modal/index.js +781 -121
- package/dist/network-cli.d.ts +3 -1
- package/dist/network-cli.js +78 -36
- package/dist/networks/index.d.ts +11 -0
- package/dist/networks/index.js +10 -0
- package/dist/ports/index.d.ts +9 -0
- package/dist/ports/index.js +10 -0
- package/dist/product-names.d.ts +52 -0
- package/dist/product-names.js +164 -0
- package/dist/product-renames.d.ts +103 -0
- package/dist/product-renames.js +189 -0
- package/dist/products/api-keys.d.ts +73 -0
- package/dist/products/api-keys.js +23 -0
- package/dist/products/apps.d.ts +157 -0
- package/dist/products/apps.js +60 -0
- package/dist/products/balancers.d.ts +87 -0
- package/dist/products/balancers.js +8 -0
- package/dist/products/billing.d.ts +41 -0
- package/dist/products/billing.js +13 -0
- package/dist/products/browser.d.ts +10 -0
- package/dist/products/browsers.d.ts +71 -0
- package/dist/products/browsers.js +102 -0
- package/dist/products/builds.d.ts +156 -0
- package/dist/products/builds.js +227 -0
- package/dist/products/index.d.ts +5 -16
- package/dist/products/index.js +5 -14
- package/dist/products/jobs.d.ts +19 -2
- package/dist/products/jobs.js +28 -11
- package/dist/products/logs.d.ts +245 -0
- package/dist/products/logs.js +274 -0
- package/dist/products/network-products.d.ts +38 -7
- package/dist/products/network-products.js +31 -18
- package/dist/products/observability.d.ts +8 -2
- package/dist/products/private-network.js +1 -1
- package/dist/products/queues.d.ts +149 -0
- package/dist/products/queues.js +213 -0
- package/dist/products/referrals.d.ts +21 -7
- package/dist/products/referrals.js +3 -3
- package/dist/products/resources.d.ts +54 -0
- package/dist/products/resources.js +122 -0
- package/dist/products/secrets.d.ts +29 -3
- package/dist/products/secrets.js +47 -18
- package/dist/products/signed-requests.d.ts +21 -0
- package/dist/products/signed-requests.js +11 -0
- package/dist/products/streams.d.ts +73 -0
- package/dist/products/streams.js +17 -0
- package/dist/products/switching.d.ts +35 -7
- package/dist/products/switching.js +4 -3
- package/dist/products/volumes.d.ts +6 -0
- package/dist/record-cli.d.ts +23 -0
- package/dist/record-cli.js +308 -0
- package/dist/renamed-products.d.ts +38 -0
- package/dist/renamed-products.js +34 -0
- package/dist/runloop/index.d.ts +9 -2
- package/dist/runloop/index.js +29 -8
- package/dist/runloop/sdk.d.ts +131 -0
- package/dist/runloop/sdk.js +167 -0
- package/dist/sandbox.d.ts +7 -2
- package/dist/sandbox.js +41 -11
- package/dist/sandboxes/index.d.ts +11 -0
- package/dist/sandboxes/index.js +12 -0
- package/dist/snapshots/index.d.ts +9 -0
- package/dist/snapshots/index.js +11 -0
- package/dist/snapshots.d.ts +7 -4
- package/dist/sprites/index.d.ts +343 -31
- package/dist/sprites/index.js +866 -84
- package/dist/ssh.d.ts +1 -1
- package/dist/ssh.js +11 -11
- package/dist/terminal.d.ts +24 -0
- package/dist/terminal.js +32 -0
- package/dist/transport.d.ts +18 -1
- package/dist/transport.js +80 -6
- package/dist/tunnel.js +1 -1
- package/dist/types.d.ts +71 -4
- package/dist/vercel/sandbox.d.ts +1 -1
- package/dist/vercel/sandbox.js +6 -4
- package/dist/vercel/snapshot.js +10 -2
- package/dist/volumes/index.d.ts +9 -0
- package/dist/volumes/index.js +10 -0
- package/dist/wallet.d.ts +4 -1
- package/dist/wallet.js +2 -1
- package/package.json +48 -14
package/dist/daytona/sandbox.js
CHANGED
|
@@ -90,6 +90,7 @@ export class Sandbox {
|
|
|
90
90
|
git;
|
|
91
91
|
codeInterpreter;
|
|
92
92
|
env;
|
|
93
|
+
/** Whether its previews are public; setPublic changes it. */
|
|
93
94
|
public;
|
|
94
95
|
snapshot;
|
|
95
96
|
#rt;
|
|
@@ -349,8 +350,21 @@ export class Sandbox {
|
|
|
349
350
|
const runtime = await this.#live();
|
|
350
351
|
await guard("sandbox", () => runtime.network.set(rules ?? { internet: true }));
|
|
351
352
|
}
|
|
353
|
+
/** Makes every port it shares public, or private with a token, and the
|
|
354
|
+
* ports getPreviewLink shares from now on. A port already shared changes
|
|
355
|
+
* at once, keeping its address, as on Daytona. Without credit, public is
|
|
356
|
+
* refused (public_preview_not_allowed) and nothing changes. */
|
|
357
|
+
async setPublic(isPublic) {
|
|
358
|
+
const visibility = isPublic ? "public" : "private";
|
|
359
|
+
const runtime = await this.#live();
|
|
360
|
+
const shared = await guard("sandbox", () => runtime.previews.list());
|
|
361
|
+
for (const preview of shared)
|
|
362
|
+
if (preview.visibility !== visibility)
|
|
363
|
+
await guard("sandbox", () => runtime.previews.create(preview.port, { visibility }));
|
|
364
|
+
this.public = isPublic;
|
|
365
|
+
}
|
|
352
366
|
/** A preview address for `port`: public when the sandbox was created with
|
|
353
|
-
* `public: true
|
|
367
|
+
* `public: true` or setPublic(true) since, else private with a token. */
|
|
354
368
|
async getPreviewLink(port) {
|
|
355
369
|
const runtime = await this.#live();
|
|
356
370
|
const preview = await guard("sandbox", () => runtime.previews.create(port, { visibility: this.public ? "public" : "private" }));
|
|
@@ -440,7 +454,7 @@ export class Sandbox {
|
|
|
440
454
|
return refusal("Signed download URLs", "Use sandbox.fs.downloadFile(path).");
|
|
441
455
|
}
|
|
442
456
|
createSshAccess() {
|
|
443
|
-
return refusal("SSH access", "Use `npx withruntime
|
|
457
|
+
return refusal("SSH access", "Use `npx withruntime sandboxes ssh <id>` (also VS Code and JetBrains) or sandbox.withruntime.terminal().");
|
|
444
458
|
}
|
|
445
459
|
revokeSshAccess() {
|
|
446
460
|
return this.createSshAccess();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** `withruntime/domains`: Domains alone. Your own hostname for a sandbox's port, with HTTPS.
|
|
2
|
+
*
|
|
3
|
+
* import { domains } from "withruntime/domains";
|
|
4
|
+
* const client = domains(); // RUNTIME_API_KEY, or this machine's saved connection
|
|
5
|
+
*/
|
|
6
|
+
import { Runtime, type RuntimeOptions } from "../client.js";
|
|
7
|
+
export type { Domain, CheckedDomain, DnsRecord } from "../products/network-products.js";
|
|
8
|
+
/** `runtime.domains` of a client made with `options`. */
|
|
9
|
+
export declare function domains(options?: RuntimeOptions): Runtime["domains"];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** `withruntime/domains`: Domains alone. Your own hostname for a sandbox's port, with HTTPS.
|
|
2
|
+
*
|
|
3
|
+
* import { domains } from "withruntime/domains";
|
|
4
|
+
* const client = domains(); // RUNTIME_API_KEY, or this machine's saved connection
|
|
5
|
+
*/
|
|
6
|
+
import { Runtime } from "../client.js";
|
|
7
|
+
/** `runtime.domains` of a client made with `options`. */
|
|
8
|
+
export function domains(options) {
|
|
9
|
+
return new Runtime(options).domains;
|
|
10
|
+
}
|
package/dist/e2b/commands.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Process } from "../sandbox.js";
|
|
2
2
|
import type { OutputEvent, ProcessInfo as RuntimeProcessInfo } from "../types.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type RequestOptions } from "../transport.js";
|
|
4
4
|
import type { RuntimeSandbox } from "./client.js";
|
|
5
5
|
import { TimeoutError, type CommandResult } from "./errors.js";
|
|
6
6
|
export type { CommandResult };
|
package/dist/e2b/commands.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { timeoutSignal } from "../transport.js";
|
|
2
|
+
import { CommandExitError, guard, InvalidArgumentError, SandboxError, SandboxNotFoundError, SandboxNotRunningError, TimeoutError, translate, } from "./errors.js";
|
|
2
3
|
import { commandAs, listedAs, runAs } from "./users.js";
|
|
3
4
|
const DEFAULT_TIMEOUT_MS = 60_000;
|
|
4
5
|
/** How long a command may run on Runtime: a day, E2B's longest sandbox. E2B's
|
|
@@ -25,7 +26,7 @@ export function timeoutFor(timeoutMs) {
|
|
|
25
26
|
export function commandRequest(opts, defaultTimeoutMs = 60_000) {
|
|
26
27
|
opts.signal?.throwIfAborted();
|
|
27
28
|
const timeoutMs = timeoutFor(opts.requestTimeoutMs ?? defaultTimeoutMs);
|
|
28
|
-
const deadline = timeoutMs > 0 ?
|
|
29
|
+
const deadline = timeoutMs > 0 ? timeoutSignal(timeoutMs) : undefined;
|
|
29
30
|
const signal = opts.signal && deadline ? AbortSignal.any([opts.signal, deadline]) : (opts.signal ?? deadline);
|
|
30
31
|
return { timeoutMs: 0, ...(signal ? { signal } : {}) };
|
|
31
32
|
}
|
|
@@ -85,7 +86,7 @@ function toResult(result) {
|
|
|
85
86
|
export function connectionRequest(opts, defaultTimeoutMs) {
|
|
86
87
|
const timeoutMs = timeoutFor(opts.timeoutMs);
|
|
87
88
|
const deadline = timeoutMs > 0 ? performance.now() + timeoutMs : undefined;
|
|
88
|
-
const connectionTimeout = timeoutMs > 0 ?
|
|
89
|
+
const connectionTimeout = timeoutMs > 0 ? timeoutSignal(timeoutMs) : undefined;
|
|
89
90
|
const signal = connectionTimeout && opts.signal
|
|
90
91
|
? AbortSignal.any([connectionTimeout, opts.signal])
|
|
91
92
|
: (connectionTimeout ?? opts.signal);
|
|
@@ -243,11 +244,9 @@ function describe(info) {
|
|
|
243
244
|
cwd: info.cwd,
|
|
244
245
|
};
|
|
245
246
|
}
|
|
246
|
-
/**
|
|
247
|
-
* TimeoutError, which code written for E2B catches (5 October 2026: it was a
|
|
248
|
-
* SandboxNotFoundError). */
|
|
247
|
+
/** E2B 2.53's confirmed sandbox loss remains catchable as TimeoutError. */
|
|
249
248
|
function sandboxEnded(cause) {
|
|
250
|
-
const error = new
|
|
249
|
+
const error = new SandboxNotRunningError("The command ended before the stream completed: the sandbox was killed or reached its end of life.");
|
|
251
250
|
error.cause = cause;
|
|
252
251
|
return error;
|
|
253
252
|
}
|
package/dist/e2b/errors.d.ts
CHANGED
|
@@ -8,6 +8,14 @@ export declare class SandboxError extends Error {
|
|
|
8
8
|
}
|
|
9
9
|
export declare class TimeoutError extends SandboxError {
|
|
10
10
|
}
|
|
11
|
+
/** The sandbox is confirmed stopped or paused; create or resume one. */
|
|
12
|
+
export declare class SandboxNotRunningError extends TimeoutError {
|
|
13
|
+
constructor(message: string, options?: ErrorOptions);
|
|
14
|
+
}
|
|
15
|
+
/** The sandbox cannot be reached, without confirmation that it stopped. */
|
|
16
|
+
export declare class SandboxUnreachableError extends TimeoutError {
|
|
17
|
+
constructor(message: string, options?: ErrorOptions);
|
|
18
|
+
}
|
|
11
19
|
export declare class InvalidArgumentError extends SandboxError {
|
|
12
20
|
}
|
|
13
21
|
export declare class NotEnoughSpaceError extends SandboxError {
|
|
@@ -62,6 +70,15 @@ export declare class SecretError extends Error {
|
|
|
62
70
|
}
|
|
63
71
|
export declare class SecretNotFoundError extends SecretError {
|
|
64
72
|
}
|
|
73
|
+
/** E2B 2.55's Dockerfile parse error, from `@e2b/dockerfile-utils`: a plain
|
|
74
|
+
* Error, not a SandboxError, with the line it names. Runtime parses no
|
|
75
|
+
* Dockerfile here (templates are Runtime images, built by
|
|
76
|
+
* `npx withruntime images build`), so nothing throws it; it exists so that
|
|
77
|
+
* code importing it or catching it still loads. */
|
|
78
|
+
export declare class DockerfileSyntaxError extends Error {
|
|
79
|
+
readonly line: number | undefined;
|
|
80
|
+
constructor(message: string, line?: number);
|
|
81
|
+
}
|
|
65
82
|
/** A call that E2B supports and Runtime does not, or not in the same way.
|
|
66
83
|
* Thrown before anything is done, never after doing something different.
|
|
67
84
|
* `feature` names what was asked for; `alternative` says what to use on
|
package/dist/e2b/errors.js
CHANGED
|
@@ -23,6 +23,24 @@ export class SandboxError extends Error {
|
|
|
23
23
|
}
|
|
24
24
|
export class TimeoutError extends SandboxError {
|
|
25
25
|
}
|
|
26
|
+
/** The sandbox is confirmed stopped or paused; create or resume one. */
|
|
27
|
+
export class SandboxNotRunningError extends TimeoutError {
|
|
28
|
+
constructor(message, options) {
|
|
29
|
+
super(message);
|
|
30
|
+
this.name = "SandboxNotRunningError";
|
|
31
|
+
if (options?.cause !== undefined)
|
|
32
|
+
this.cause = options.cause;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** The sandbox cannot be reached, without confirmation that it stopped. */
|
|
36
|
+
export class SandboxUnreachableError extends TimeoutError {
|
|
37
|
+
constructor(message, options) {
|
|
38
|
+
super(message);
|
|
39
|
+
this.name = "SandboxUnreachableError";
|
|
40
|
+
if (options?.cause !== undefined)
|
|
41
|
+
this.cause = options.cause;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
26
44
|
export class InvalidArgumentError extends SandboxError {
|
|
27
45
|
}
|
|
28
46
|
export class NotEnoughSpaceError extends SandboxError {
|
|
@@ -92,6 +110,21 @@ export class SecretError extends Error {
|
|
|
92
110
|
}
|
|
93
111
|
export class SecretNotFoundError extends SecretError {
|
|
94
112
|
}
|
|
113
|
+
/** E2B 2.55's Dockerfile parse error, from `@e2b/dockerfile-utils`: a plain
|
|
114
|
+
* Error, not a SandboxError, with the line it names. Runtime parses no
|
|
115
|
+
* Dockerfile here (templates are Runtime images, built by
|
|
116
|
+
* `npx withruntime images build`), so nothing throws it; it exists so that
|
|
117
|
+
* code importing it or catching it still loads. */
|
|
118
|
+
export class DockerfileSyntaxError extends Error {
|
|
119
|
+
line;
|
|
120
|
+
constructor(message, line) {
|
|
121
|
+
super(line === undefined
|
|
122
|
+
? `Dockerfile parse error: ${message}`
|
|
123
|
+
: `Dockerfile parse error on line ${line}: ${message}`);
|
|
124
|
+
this.line = line;
|
|
125
|
+
this.name = "DockerfileSyntaxError";
|
|
126
|
+
}
|
|
127
|
+
}
|
|
95
128
|
/** A call that E2B supports and Runtime does not, or not in the same way.
|
|
96
129
|
* Thrown before anything is done, never after doing something different.
|
|
97
130
|
* `feature` names what was asked for; `alternative` says what to use on
|
|
@@ -159,7 +192,13 @@ export function translate(error, subject = "other") {
|
|
|
159
192
|
.filter(Boolean)
|
|
160
193
|
.join("\n");
|
|
161
194
|
let out;
|
|
162
|
-
|
|
195
|
+
// Runtime reports the sandbox state explicitly. A generic connection failure
|
|
196
|
+
// does not prove it stopped; never replay a command or write to classify it.
|
|
197
|
+
if (["sandbox_stopped", "sandbox_paused", "sandbox_not_running"].includes(error.code))
|
|
198
|
+
out = new SandboxNotRunningError(message);
|
|
199
|
+
else if (error.code === "sandbox_not_ready" || error.code === "host_unavailable")
|
|
200
|
+
out = new SandboxUnreachableError(message);
|
|
201
|
+
else if (error.status === 503 && error.code.endsWith("_unavailable"))
|
|
163
202
|
// A product switched off on purpose (forks, previews): Runtime's own words
|
|
164
203
|
// say what is off and what to use meanwhile.
|
|
165
204
|
out = new NotSupportedError(error.code.replace(/_unavailable$/, ""), error.hint ?? "", message);
|
package/dist/e2b/index.d.ts
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
import type { Runtime } from "../client.js";
|
|
8
8
|
import { type ConnectionOpts } from "./client.js";
|
|
9
9
|
import { Sandbox } from "./sandbox.js";
|
|
10
|
-
export { Sandbox, SandboxPaginator, DEFAULT_SHAPE, DEFAULT_TIMEOUT_MS, type SandboxOpts, type SandboxConnectOpts, type SandboxApiOpts, type SandboxInfo, type SandboxListOpts, type SandboxState, type SandboxLifecycle, type SandboxOnTimeout, type SnapshotInfo, } from "./sandbox.js";
|
|
10
|
+
export { Sandbox, SandboxPaginator, DEFAULT_SHAPE, DEFAULT_TIMEOUT_MS, type SandboxOpts, type SandboxConnectOpts, type SandboxApiOpts, type SandboxInfo, type SandboxListOpts, type SandboxState, type SandboxLifecycle, type SandboxOnTimeout, type SandboxPauseOpts, type CreateSnapshotOpts, type SnapshotMode, type SnapshotInfo, } from "./sandbox.js";
|
|
11
11
|
export { Commands, CommandHandle, pidOf, type CommandStartOpts, type CommandConnectOpts, type CommandRequestOpts, type ProcessInfo, type Username, } from "./commands.js";
|
|
12
12
|
export { Filesystem, FileType, type EntryInfo, type WriteInfo, type WriteEntry, type FilesystemRequestOpts, type FilesystemReadOpts, type FilesystemWriteOpts, type FilesystemListOpts, FilesystemEventType, type FilesystemEvent, type WatchOpts, type E2BWatchHandle as WatchHandle, } from "./filesystem.js";
|
|
13
|
-
export { SandboxError, TimeoutError, InvalidArgumentError, NotEnoughSpaceError, NotFoundError, FileNotFoundError, SandboxNotFoundError, TemplateError, RateLimitError, AuthenticationError, ServiceBusyError, CommandExitError, NotSupportedError, PublicPreviewNotAllowedError, GitAuthError, GitUpstreamError, BuildError, FileUploadError, VolumeError, VolumeNotFoundError, VolumePathNotFoundError, SecretError, SecretNotFoundError, type CommandResult, } from "./errors.js";
|
|
13
|
+
export { SandboxError, TimeoutError, InvalidArgumentError, NotEnoughSpaceError, NotFoundError, FileNotFoundError, SandboxNotFoundError, SandboxNotRunningError, SandboxUnreachableError, TemplateError, RateLimitError, AuthenticationError, ServiceBusyError, CommandExitError, NotSupportedError, PublicPreviewNotAllowedError, GitAuthError, GitUpstreamError, BuildError, FileUploadError, VolumeError, VolumeNotFoundError, VolumePathNotFoundError, SecretError, SecretNotFoundError, DockerfileSyntaxError, type CommandResult, } from "./errors.js";
|
|
14
14
|
export type { ConnectionOpts, HttpVersion, RuntimeOpts } from "./client.js";
|
|
15
15
|
export { Pty, type PtyCreateOpts, type PtyConnectOpts } from "./pty.js";
|
|
16
16
|
export { Template, TemplateBase, Volume, Secret, waitForPort, waitForURL, waitForProcess, waitForFile, waitForTimeout, SecretPaginator, Git, ReadyCmd, LogEntry, LogEntryStart, LogEntryEnd, defaultBuildLogger, ConnectionConfig, ApiClient, getSignature, ALL_TRAFFIC, VolumeFileType, } from "./unsupported.js";
|
package/dist/e2b/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Sandbox } from "./sandbox.js";
|
|
|
3
3
|
export { Sandbox, SandboxPaginator, DEFAULT_SHAPE, DEFAULT_TIMEOUT_MS, } from "./sandbox.js";
|
|
4
4
|
export { Commands, CommandHandle, pidOf, } from "./commands.js";
|
|
5
5
|
export { Filesystem, FileType, FilesystemEventType, } from "./filesystem.js";
|
|
6
|
-
export { SandboxError, TimeoutError, InvalidArgumentError, NotEnoughSpaceError, NotFoundError, FileNotFoundError, SandboxNotFoundError, TemplateError, RateLimitError, AuthenticationError, ServiceBusyError, CommandExitError, NotSupportedError, PublicPreviewNotAllowedError, GitAuthError, GitUpstreamError, BuildError, FileUploadError, VolumeError, VolumeNotFoundError, VolumePathNotFoundError, SecretError, SecretNotFoundError, } from "./errors.js";
|
|
6
|
+
export { SandboxError, TimeoutError, InvalidArgumentError, NotEnoughSpaceError, NotFoundError, FileNotFoundError, SandboxNotFoundError, SandboxNotRunningError, SandboxUnreachableError, TemplateError, RateLimitError, AuthenticationError, ServiceBusyError, CommandExitError, NotSupportedError, PublicPreviewNotAllowedError, GitAuthError, GitUpstreamError, BuildError, FileUploadError, VolumeError, VolumeNotFoundError, VolumePathNotFoundError, SecretError, SecretNotFoundError, DockerfileSyntaxError, } from "./errors.js";
|
|
7
7
|
export { Pty } from "./pty.js";
|
|
8
8
|
export { Template, TemplateBase, Volume, Secret, waitForPort, waitForURL, waitForProcess, waitForFile, waitForTimeout, SecretPaginator, Git, ReadyCmd, LogEntry, LogEntryStart, LogEntryEnd, defaultBuildLogger, ConnectionConfig, ApiClient, getSignature, ALL_TRAFFIC, VolumeFileType, } from "./unsupported.js";
|
|
9
9
|
export default Sandbox;
|
package/dist/e2b/sandbox.d.ts
CHANGED
|
@@ -18,9 +18,26 @@ export declare const DEFAULT_TIMEOUT_MS = 300000;
|
|
|
18
18
|
* and list name it whichever client asks; it is not shown in `metadata`. */
|
|
19
19
|
export declare const TEMPLATE_LABEL = "e2b-template";
|
|
20
20
|
export type SandboxState = "running" | "paused";
|
|
21
|
+
/** What a pause or snapshot keeps (E2B 2.55): `"full"` keeps memory and
|
|
22
|
+
* files, `"filesystem"` only files, so what starts from it boots afresh. */
|
|
23
|
+
export type SnapshotMode = "full" | "filesystem";
|
|
21
24
|
export type SandboxOnTimeout = "pause" | "kill" | {
|
|
22
|
-
action: "pause"
|
|
25
|
+
action: "pause";
|
|
26
|
+
mode?: SnapshotMode;
|
|
27
|
+
/** @deprecated E2B 2.55: use `mode`. */
|
|
23
28
|
keepMemory?: boolean;
|
|
29
|
+
} | {
|
|
30
|
+
action: "kill";
|
|
31
|
+
};
|
|
32
|
+
/** E2B's pause options: `mode`, or the deprecated `keepMemory`. */
|
|
33
|
+
export type SandboxPauseOpts = SandboxApiOpts & {
|
|
34
|
+
mode?: SnapshotMode;
|
|
35
|
+
/** @deprecated E2B 2.55: use `mode`. */
|
|
36
|
+
keepMemory?: boolean;
|
|
37
|
+
};
|
|
38
|
+
export type CreateSnapshotOpts = SandboxApiOpts & {
|
|
39
|
+
name?: string;
|
|
40
|
+
mode?: SnapshotMode;
|
|
24
41
|
};
|
|
25
42
|
export type SandboxLifecycle = {
|
|
26
43
|
onTimeout: SandboxOnTimeout;
|
|
@@ -116,7 +133,7 @@ export declare class Sandbox {
|
|
|
116
133
|
protected get client(): Runtime;
|
|
117
134
|
/** Creates a sandbox from `template` (default "base", Runtime's stock image)
|
|
118
135
|
* with E2B's default machine, 2 vCPU and 512 MiB, and waits until it runs.
|
|
119
|
-
* Funding is left to Runtime: the
|
|
136
|
+
* Funding is left to Runtime: the free usage first, then prepaid credit, exactly as withruntime's own create. */
|
|
120
137
|
static create<S extends typeof Sandbox>(this: S, opts?: SandboxOpts): Promise<InstanceType<S>>;
|
|
121
138
|
static create<S extends typeof Sandbox>(this: S, template: string, opts?: SandboxOpts): Promise<InstanceType<S>>;
|
|
122
139
|
/** Connects to a sandbox by id, waking it if it is paused, as E2B does. A
|
|
@@ -145,18 +162,10 @@ export declare class Sandbox {
|
|
|
145
162
|
* next call wakes it. False once paused on request, ended or deleted. */
|
|
146
163
|
isRunning(opts?: Pick<ConnectionOpts, "requestTimeoutMs" | "signal">): Promise<boolean>;
|
|
147
164
|
/** Pauses the sandbox, keeping memory and files. False when it was paused. */
|
|
148
|
-
static pause(sandboxId: string, opts?:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
keepMemory?: boolean;
|
|
153
|
-
}): Promise<boolean>;
|
|
154
|
-
pause(opts?: SandboxApiOpts & {
|
|
155
|
-
keepMemory?: boolean;
|
|
156
|
-
}): Promise<boolean>;
|
|
157
|
-
betaPause(opts?: SandboxApiOpts & {
|
|
158
|
-
keepMemory?: boolean;
|
|
159
|
-
}): Promise<boolean>;
|
|
165
|
+
static pause(sandboxId: string, opts?: SandboxPauseOpts): Promise<boolean>;
|
|
166
|
+
static betaPause(sandboxId: string, opts?: SandboxPauseOpts): Promise<boolean>;
|
|
167
|
+
pause(opts?: SandboxPauseOpts): Promise<boolean>;
|
|
168
|
+
betaPause(opts?: SandboxPauseOpts): Promise<boolean>;
|
|
160
169
|
/** Copies of this sandbox, memory and all. While Runtime's forks are
|
|
161
170
|
* switched off this throws NotSupportedError with Runtime's own words. */
|
|
162
171
|
static fork<S extends typeof Sandbox>(this: S, sandboxId: string, opts?: SandboxApiOpts & {
|
|
@@ -167,14 +176,11 @@ export declare class Sandbox {
|
|
|
167
176
|
count?: number;
|
|
168
177
|
timeoutMs?: number;
|
|
169
178
|
}): Promise<Array<this | Error>>;
|
|
170
|
-
/** Keeps the sandbox's whole machine as a Runtime snapshot
|
|
171
|
-
*
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
static createSnapshot(sandboxId: string, opts?: SandboxApiOpts & {
|
|
176
|
-
name?: string;
|
|
177
|
-
}): Promise<SnapshotInfo>;
|
|
179
|
+
/** Keeps the sandbox's whole machine as a Runtime snapshot, or with
|
|
180
|
+
* `mode: "filesystem"` its disk alone, from which a sandbox boots afresh;
|
|
181
|
+
* start from it with Sandbox.create(snapshotId). */
|
|
182
|
+
createSnapshot(opts?: CreateSnapshotOpts): Promise<SnapshotInfo>;
|
|
183
|
+
static createSnapshot(sandboxId: string, opts?: CreateSnapshotOpts): Promise<SnapshotInfo>;
|
|
178
184
|
static deleteSnapshot(snapshotId: string, opts?: SandboxApiOpts): Promise<boolean>;
|
|
179
185
|
/** E2B's getHost, answered at once as E2B answers it:
|
|
180
186
|
* `<port>-<id>.runtimehost.com`. A Runtime preview's address is made from
|
package/dist/e2b/sandbox.js
CHANGED
|
@@ -28,6 +28,7 @@ export const TEMPLATE_LABEL = "e2b-template";
|
|
|
28
28
|
/** E2B template names that mean "the stock environment": Runtime's default image. */
|
|
29
29
|
const STOCK_TEMPLATES = new Set(["base", "code-interpreter-v1", "code-interpreter"]);
|
|
30
30
|
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
31
|
+
const SNAPSHOT_MODES = ["full", "filesystem"];
|
|
31
32
|
let warnedShortLease = false;
|
|
32
33
|
/** E2B's own bound since 2.52.0: refused before anything happens. */
|
|
33
34
|
const MAX_FORK_COUNT = 20;
|
|
@@ -64,10 +65,28 @@ function onTimeout(lifecycle, timeoutAsked) {
|
|
|
64
65
|
if (!lifecycle)
|
|
65
66
|
return timeoutAsked ? "delete" : "pause";
|
|
66
67
|
const action = typeof lifecycle.onTimeout === "string" ? lifecycle.onTimeout : lifecycle.onTimeout.action;
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
// As E2B 2.55 checks: mode (or keepMemory) belongs to a pause alone.
|
|
69
|
+
const pauseOpts = (typeof lifecycle.onTimeout === "string" ? {} : lifecycle.onTimeout);
|
|
70
|
+
if (("mode" in pauseOpts || "keepMemory" in pauseOpts) && action !== "pause")
|
|
71
|
+
throw new InvalidArgumentError("onTimeout.mode is only allowed when action is 'pause'.");
|
|
72
|
+
if (snapshotMemory("onTimeout.mode", pauseOpts.mode, pauseOpts.keepMemory) === false)
|
|
73
|
+
throw filesOnlyPause();
|
|
69
74
|
return action === "pause" ? "pause" : "delete";
|
|
70
75
|
}
|
|
76
|
+
/** E2B 2.55's reading of `mode`, or the deprecated `keepMemory`: whether
|
|
77
|
+
* memory is kept, or undefined when neither was given. Both at once, or a
|
|
78
|
+
* mode E2B does not know, is E2B's InvalidArgumentError. */
|
|
79
|
+
function snapshotMemory(field, mode, keepMemory) {
|
|
80
|
+
if (mode != null && keepMemory != null)
|
|
81
|
+
throw new InvalidArgumentError(`Pass either ${field} or the deprecated keepMemory, not both.`);
|
|
82
|
+
if (mode == null)
|
|
83
|
+
return keepMemory ?? undefined;
|
|
84
|
+
if (!SNAPSHOT_MODES.includes(mode))
|
|
85
|
+
throw new InvalidArgumentError(`${field} must be one of: ${SNAPSHOT_MODES.join(", ")} (got ${JSON.stringify(mode)}).`);
|
|
86
|
+
return mode === "full";
|
|
87
|
+
}
|
|
88
|
+
const filesOnlyPause = () => new NotSupportedError("A files-only pause (mode: 'filesystem', or keepMemory: false)", "Runtime's pause keeps memory and files; leave mode out or pass mode: 'full'. " +
|
|
89
|
+
"For a copy of the files alone, use createSnapshot({ mode: 'filesystem' }).");
|
|
71
90
|
function refuseCreate(opts) {
|
|
72
91
|
const refusals = [
|
|
73
92
|
[
|
|
@@ -141,7 +160,7 @@ function templateMissing(template, cause, account) {
|
|
|
141
160
|
const name = imageNameFor(template).replace(/[:@].*$/, "");
|
|
142
161
|
const error = new TemplateError(`No Runtime image is named "${imageNameFor(template)}"${account ?? ""}. E2B templates do not run on Runtime; build the same ` +
|
|
143
162
|
`environment as a Runtime image with that name and this call starts from it: ` +
|
|
144
|
-
`\`npx withruntime
|
|
163
|
+
`\`npx withruntime images build --dockerfile e2b.Dockerfile --name ${name}\`, or ` +
|
|
145
164
|
`runtime.images.build({ name: "${name}", dockerfile }).`);
|
|
146
165
|
error.code = "template_not_found";
|
|
147
166
|
error.cause = cause;
|
|
@@ -466,10 +485,17 @@ export class Sandbox {
|
|
|
466
485
|
const Kind = this.constructor;
|
|
467
486
|
return copies.map((copy) => new Kind(copy, this.#client));
|
|
468
487
|
}
|
|
469
|
-
/** Keeps the sandbox's whole machine as a Runtime snapshot
|
|
470
|
-
*
|
|
488
|
+
/** Keeps the sandbox's whole machine as a Runtime snapshot, or with
|
|
489
|
+
* `mode: "filesystem"` its disk alone, from which a sandbox boots afresh;
|
|
490
|
+
* start from it with Sandbox.create(snapshotId). */
|
|
471
491
|
async createSnapshot(opts = {}) {
|
|
472
|
-
const
|
|
492
|
+
const memory = snapshotMemory("mode", opts.mode);
|
|
493
|
+
const mode = memory === undefined ? undefined : memory ? "memory" : "disk";
|
|
494
|
+
const snapshot = await guard("sandbox", () => this.#runtime.snapshot({
|
|
495
|
+
...(opts.name ? { name: opts.name } : {}),
|
|
496
|
+
...(mode ? { mode } : {}),
|
|
497
|
+
...request(opts),
|
|
498
|
+
}));
|
|
473
499
|
return { snapshotId: snapshot.id, names: snapshot.name ? [snapshot.name] : [] };
|
|
474
500
|
}
|
|
475
501
|
static async createSnapshot(sandboxId, opts = {}) {
|
|
@@ -601,8 +627,8 @@ async function extendTo(runtime, timeoutMs, opts) {
|
|
|
601
627
|
await guard("sandbox", () => runtime.extend(Math.ceil(later), request(opts)));
|
|
602
628
|
}
|
|
603
629
|
async function pause(runtime, opts) {
|
|
604
|
-
if (opts.keepMemory === false)
|
|
605
|
-
throw
|
|
630
|
+
if (snapshotMemory("mode", opts.mode, opts.keepMemory) === false)
|
|
631
|
+
throw filesOnlyPause();
|
|
606
632
|
const current = state(runtime);
|
|
607
633
|
if (current === "paused")
|
|
608
634
|
return false;
|
package/dist/e2b/unsupported.js
CHANGED
|
@@ -15,7 +15,7 @@ export function unsupportedExport(name, alternative) {
|
|
|
15
15
|
},
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
-
const TEMPLATES = "Build a Runtime image instead: `npx withruntime
|
|
18
|
+
const TEMPLATES = "Build a Runtime image instead: `npx withruntime images build --dockerfile e2b.Dockerfile --name <template>` or runtime.images.build({ name, dockerfile | recipe }), then Sandbox.create('<template>').";
|
|
19
19
|
export const Template = unsupportedExport("Template builder", TEMPLATES);
|
|
20
20
|
export const TemplateBase = unsupportedExport("TemplateBase", TEMPLATES);
|
|
21
21
|
export const waitForPort = unsupportedExport("waitForPort (a template ready check)", TEMPLATES);
|
package/dist/errors.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare const DELIBERATE: ReadonlySet<string>;
|
|
|
13
13
|
* minutes when it has none), however many retries it allows otherwise. */
|
|
14
14
|
export declare const NOTHING_RAN: ReadonlySet<string>;
|
|
15
15
|
/** Refusals of a create that clear when a sandbox stops or pauses, or a host
|
|
16
|
-
* frees room: an account without credit's
|
|
16
|
+
* frees room: an account without credit's four at once and its total, an
|
|
17
17
|
* email domain's, the account's quota and the region's capacity. `sandboxes.create` waits them out, retrying
|
|
18
18
|
* with the same key and input, for up to `waitForCapacityMs`. */
|
|
19
19
|
export declare const WAITS_FOR_ROOM: ReadonlySet<string>;
|
|
@@ -68,7 +68,9 @@ export declare class AccountBlockedError extends RuntimeError {
|
|
|
68
68
|
* same idempotencyKey (the SDK does, automatically) settles it safely. */
|
|
69
69
|
export declare class ConnectionError extends RuntimeError {
|
|
70
70
|
}
|
|
71
|
-
/** Raised by exec({ check: true }) when a command exits non-zero.
|
|
71
|
+
/** Raised by exec({ check: true }) when a command exits non-zero. Its code
|
|
72
|
+
* is `out_of_memory` when the sandbox's out-of-memory killer ended it, with
|
|
73
|
+
* the result's message and hint. */
|
|
72
74
|
export declare class CommandError extends RuntimeError {
|
|
73
75
|
readonly exitCode: number | null;
|
|
74
76
|
readonly stdout: string;
|
|
@@ -78,6 +80,13 @@ export declare class CommandError extends RuntimeError {
|
|
|
78
80
|
stdout: string;
|
|
79
81
|
stderr: string;
|
|
80
82
|
timedOut?: boolean;
|
|
83
|
+
outOfMemory?: {
|
|
84
|
+
code: string;
|
|
85
|
+
message: string;
|
|
86
|
+
hint: string;
|
|
87
|
+
};
|
|
81
88
|
});
|
|
89
|
+
/** The same command in the same sandbox runs out of memory again. */
|
|
90
|
+
get retryable(): boolean;
|
|
82
91
|
}
|
|
83
92
|
export declare function errorFor(status: number, body: unknown, idempotencyKey?: string): RuntimeError;
|
package/dist/errors.js
CHANGED
|
@@ -15,6 +15,7 @@ export const DELIBERATE = new Set([
|
|
|
15
15
|
"secrets_unavailable",
|
|
16
16
|
"identity_unavailable",
|
|
17
17
|
"env_unavailable",
|
|
18
|
+
"resize_unavailable",
|
|
18
19
|
]);
|
|
19
20
|
/** Refusals that guarantee nothing ran: a sandbox running as many commands
|
|
20
21
|
* as it can (`guest_busy`), and the API's own limits, which answer before any
|
|
@@ -26,7 +27,7 @@ export const NOTHING_RAN = new Set(["guest_busy", "busy", "rate_limited"]);
|
|
|
26
27
|
* account without credit stops. */
|
|
27
28
|
const PASSING = new Set(["no_capacity", "no_credit_running_limit", "no_credit_total_limit"]);
|
|
28
29
|
/** Refusals of a create that clear when a sandbox stops or pauses, or a host
|
|
29
|
-
* frees room: an account without credit's
|
|
30
|
+
* frees room: an account without credit's four at once and its total, an
|
|
30
31
|
* email domain's, the account's quota and the region's capacity. `sandboxes.create` waits them out, retrying
|
|
31
32
|
* with the same key and input, for up to `waitForCapacityMs`. */
|
|
32
33
|
export const WAITS_FOR_ROOM = new Set([
|
|
@@ -36,7 +37,8 @@ export const WAITS_FOR_ROOM = new Set([
|
|
|
36
37
|
"no_credit_capacity_full",
|
|
37
38
|
"quota_exceeded",
|
|
38
39
|
"no_capacity",
|
|
39
|
-
// A volume whose last sandbox is stopping: free
|
|
40
|
+
// A volume whose last sandbox is stopping: free once the stop lets go of
|
|
41
|
+
// its disk, up to about a minute (measured 50 to 60 s, 6 October 2026).
|
|
40
42
|
"volume_releasing",
|
|
41
43
|
]);
|
|
42
44
|
export class RuntimeError extends Error {
|
|
@@ -104,23 +106,33 @@ export class AccountBlockedError extends RuntimeError {
|
|
|
104
106
|
* same idempotencyKey (the SDK does, automatically) settles it safely. */
|
|
105
107
|
export class ConnectionError extends RuntimeError {
|
|
106
108
|
}
|
|
107
|
-
/** Raised by exec({ check: true }) when a command exits non-zero.
|
|
109
|
+
/** Raised by exec({ check: true }) when a command exits non-zero. Its code
|
|
110
|
+
* is `out_of_memory` when the sandbox's out-of-memory killer ended it, with
|
|
111
|
+
* the result's message and hint. */
|
|
108
112
|
export class CommandError extends RuntimeError {
|
|
109
113
|
exitCode;
|
|
110
114
|
stdout;
|
|
111
115
|
stderr;
|
|
112
116
|
constructor(result) {
|
|
117
|
+
const memory = result.outOfMemory;
|
|
113
118
|
super({
|
|
114
119
|
message: result.timedOut
|
|
115
120
|
? "Command timed out."
|
|
116
|
-
:
|
|
117
|
-
|
|
121
|
+
: memory
|
|
122
|
+
? `Command exited with ${result.exitCode}. ${memory.message}`
|
|
123
|
+
: `Command exited with ${result.exitCode}.${result.stderr ? ` ${result.stderr.trim().slice(-500)}` : ""}`,
|
|
124
|
+
code: result.timedOut ? "command_timeout" : memory ? memory.code : "command_failed",
|
|
118
125
|
status: 0,
|
|
126
|
+
...(memory && !result.timedOut ? { hint: memory.hint } : {}),
|
|
119
127
|
});
|
|
120
128
|
this.exitCode = result.exitCode;
|
|
121
129
|
this.stdout = result.stdout;
|
|
122
130
|
this.stderr = result.stderr;
|
|
123
131
|
}
|
|
132
|
+
/** The same command in the same sandbox runs out of memory again. */
|
|
133
|
+
get retryable() {
|
|
134
|
+
return this.code === "out_of_memory" ? false : super.retryable;
|
|
135
|
+
}
|
|
124
136
|
}
|
|
125
137
|
export function errorFor(status, body, idempotencyKey) {
|
|
126
138
|
const error = body?.error ?? {};
|