withruntime 0.3.1 → 0.5.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.
Files changed (105) hide show
  1. package/DAYTONA.md +129 -0
  2. package/E2B.md +146 -0
  3. package/README.md +84 -12
  4. package/VERCEL.md +127 -0
  5. package/dist/ai/index.d.ts +33 -0
  6. package/dist/ai/index.js +38 -0
  7. package/dist/claude-agent-sdk/index.d.ts +7 -0
  8. package/dist/claude-agent-sdk/index.js +65 -0
  9. package/dist/cli.d.ts +6 -0
  10. package/dist/cli.js +949 -105
  11. package/dist/client.d.ts +25 -2
  12. package/dist/client.js +14 -1
  13. package/dist/credentials.d.ts +10 -0
  14. package/dist/credentials.js +56 -1
  15. package/dist/daytona/client.d.ts +44 -0
  16. package/dist/daytona/client.js +40 -0
  17. package/dist/daytona/context.d.ts +26 -0
  18. package/dist/daytona/context.js +22 -0
  19. package/dist/daytona/daytona.d.ts +185 -0
  20. package/dist/daytona/daytona.js +416 -0
  21. package/dist/daytona/errors.d.ts +106 -0
  22. package/dist/daytona/errors.js +182 -0
  23. package/dist/daytona/filesystem.d.ts +84 -0
  24. package/dist/daytona/filesystem.js +206 -0
  25. package/dist/daytona/git.d.ts +33 -0
  26. package/dist/daytona/git.js +128 -0
  27. package/dist/daytona/image.d.ts +45 -0
  28. package/dist/daytona/image.js +140 -0
  29. package/dist/daytona/index.d.ts +50 -0
  30. package/dist/daytona/index.js +50 -0
  31. package/dist/daytona/process.d.ts +86 -0
  32. package/dist/daytona/process.js +339 -0
  33. package/dist/daytona/sandbox.d.ts +196 -0
  34. package/dist/daytona/sandbox.js +448 -0
  35. package/dist/e2b/client.d.ts +58 -0
  36. package/dist/e2b/client.js +66 -0
  37. package/dist/e2b/code-interpreter.d.ts +144 -0
  38. package/dist/e2b/code-interpreter.js +244 -0
  39. package/dist/e2b/commands.d.ts +100 -0
  40. package/dist/e2b/commands.js +268 -0
  41. package/dist/e2b/errors.d.ts +72 -0
  42. package/dist/e2b/errors.js +151 -0
  43. package/dist/e2b/filesystem.d.ts +82 -0
  44. package/dist/e2b/filesystem.js +143 -0
  45. package/dist/e2b/index.d.ts +28 -0
  46. package/dist/e2b/index.js +61 -0
  47. package/dist/e2b/sandbox.d.ts +203 -0
  48. package/dist/e2b/sandbox.js +490 -0
  49. package/dist/e2b/unsupported.d.ts +19 -0
  50. package/dist/e2b/unsupported.js +27 -0
  51. package/dist/errors.d.ts +10 -4
  52. package/dist/errors.js +26 -6
  53. package/dist/image-context.d.ts +39 -0
  54. package/dist/image-context.js +176 -0
  55. package/dist/index.d.ts +19 -2
  56. package/dist/index.js +17 -2
  57. package/dist/keys.d.ts +43 -0
  58. package/dist/keys.js +196 -0
  59. package/dist/login.js +27 -6
  60. package/dist/mcp.d.ts +2 -2
  61. package/dist/mcp.js +4 -3
  62. package/dist/openai-agents/index.d.ts +132 -0
  63. package/dist/openai-agents/index.js +791 -0
  64. package/dist/products/audit.d.ts +48 -0
  65. package/dist/products/audit.js +10 -0
  66. package/dist/products/images.d.ts +113 -7
  67. package/dist/products/images.js +186 -27
  68. package/dist/products/index.d.ts +11 -0
  69. package/dist/products/index.js +17 -1
  70. package/dist/products/observability.d.ts +186 -0
  71. package/dist/products/observability.js +117 -0
  72. package/dist/products/secrets.d.ts +40 -0
  73. package/dist/products/secrets.js +24 -0
  74. package/dist/products/switching.d.ts +89 -0
  75. package/dist/products/switching.js +25 -0
  76. package/dist/proxy.d.ts +30 -0
  77. package/dist/proxy.js +178 -0
  78. package/dist/sandbox.d.ts +30 -2
  79. package/dist/sandbox.js +101 -1
  80. package/dist/ssh.d.ts +21 -0
  81. package/dist/ssh.js +312 -0
  82. package/dist/tar.d.ts +1 -0
  83. package/dist/tar.js +4 -4
  84. package/dist/tools/index.d.ts +62 -0
  85. package/dist/tools/index.js +180 -0
  86. package/dist/transport.d.ts +12 -2
  87. package/dist/transport.js +76 -16
  88. package/dist/tunnel.d.ts +67 -0
  89. package/dist/tunnel.js +311 -0
  90. package/dist/types.d.ts +57 -1
  91. package/dist/vercel/client.d.ts +40 -0
  92. package/dist/vercel/client.js +39 -0
  93. package/dist/vercel/command.d.ts +70 -0
  94. package/dist/vercel/command.js +148 -0
  95. package/dist/vercel/errors.d.ts +53 -0
  96. package/dist/vercel/errors.js +113 -0
  97. package/dist/vercel/filesystem.d.ts +150 -0
  98. package/dist/vercel/filesystem.js +248 -0
  99. package/dist/vercel/index.d.ts +30 -0
  100. package/dist/vercel/index.js +38 -0
  101. package/dist/vercel/sandbox.d.ts +317 -0
  102. package/dist/vercel/sandbox.js +726 -0
  103. package/dist/vercel/snapshot.d.ts +93 -0
  104. package/dist/vercel/snapshot.js +123 -0
  105. package/package.json +69 -5
@@ -0,0 +1,143 @@
1
+ import { request } from "./client.js";
2
+ import { FileNotFoundError, guard, NotSupportedError } from "./errors.js";
3
+ export var FileType;
4
+ (function (FileType) {
5
+ FileType["FILE"] = "file";
6
+ FileType["DIR"] = "dir";
7
+ FileType["SYMLINK"] = "symlink";
8
+ })(FileType || (FileType = {}));
9
+ /** Runtime's home, where E2B's relative paths land. */
10
+ const HOME = "/workspace";
11
+ function absolute(path) {
12
+ return path.startsWith("/") ? path : `${HOME}/${path.replace(/^\.\//, "")}`;
13
+ }
14
+ function refuse(opts) {
15
+ if (opts.user !== undefined && opts.user !== "user")
16
+ throw new NotSupportedError(`File access as the user "${opts.user}"`, "Runtime's file calls act as the sandbox owner; use commands.run('sudo ...') for root-owned paths.");
17
+ if (opts.metadata && Object.keys(opts.metadata).length)
18
+ throw new NotSupportedError("File metadata (user.e2b.* extended attributes)", "Keep the metadata beside the file, for example in a JSON file.");
19
+ }
20
+ const PERMISSIONS = ["---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx"];
21
+ function entryInfo(entry) {
22
+ const mode = parseInt(entry.mode, 8) || 0;
23
+ const bits = mode & 0o777;
24
+ return {
25
+ name: entry.name,
26
+ path: entry.path,
27
+ ...(entry.type === "file"
28
+ ? { type: FileType.FILE }
29
+ : entry.type === "directory"
30
+ ? { type: FileType.DIR }
31
+ : entry.type === "symlink"
32
+ ? { type: FileType.SYMLINK }
33
+ : {}),
34
+ size: entry.size,
35
+ mode,
36
+ permissions: PERMISSIONS[(bits >> 6) & 7] + PERMISSIONS[(bits >> 3) & 7] + PERMISSIONS[bits & 7],
37
+ owner: "",
38
+ group: "",
39
+ modifiedTime: new Date(entry.modifiedAt),
40
+ };
41
+ }
42
+ async function bytesOf(data) {
43
+ if (typeof data === "string")
44
+ return new TextEncoder().encode(data);
45
+ if (data instanceof ArrayBuffer)
46
+ return new Uint8Array(data);
47
+ if (ArrayBuffer.isView(data)) {
48
+ const view = data;
49
+ return new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
50
+ }
51
+ if (typeof Blob !== "undefined" && data instanceof Blob)
52
+ return new Uint8Array(await data.arrayBuffer());
53
+ return new Uint8Array(await new Response(data).arrayBuffer());
54
+ }
55
+ const basename = (path) => path.split("/").filter(Boolean).pop() ?? path;
56
+ /** `sandbox.files`: E2B's filesystem module over Runtime's files API. Relative
57
+ * paths resolve against the home directory, as in E2B (Runtime's is
58
+ * /workspace). */
59
+ export class Filesystem {
60
+ #ctx;
61
+ constructor(ctx) {
62
+ this.#ctx = ctx;
63
+ }
64
+ get #files() {
65
+ return this.#ctx.runtime.files;
66
+ }
67
+ async #path(path, opts) {
68
+ refuse(opts);
69
+ await this.#ctx.ensureHome(path);
70
+ return absolute(path);
71
+ }
72
+ async read(path, opts = {}) {
73
+ const file = await this.#path(path, opts);
74
+ const bytes = await guard("file", () => this.#files.read(file, request(opts)));
75
+ switch (opts.format) {
76
+ case "bytes":
77
+ return bytes;
78
+ case "blob":
79
+ return new Blob([bytes]);
80
+ case "stream":
81
+ return new Blob([bytes]).stream();
82
+ default:
83
+ return new TextDecoder().decode(bytes);
84
+ }
85
+ }
86
+ async write(pathOrFiles, dataOrOpts, maybeOpts) {
87
+ if (Array.isArray(pathOrFiles))
88
+ return this.writeFiles(pathOrFiles, (dataOrOpts ?? {}));
89
+ return this.#writeOne(pathOrFiles, dataOrOpts, maybeOpts ?? {});
90
+ }
91
+ async writeFiles(files, opts = {}) {
92
+ const written = [];
93
+ for (const file of files)
94
+ written.push(await this.#writeOne(file.path, file.data, opts));
95
+ return written;
96
+ }
97
+ async #writeOne(path, data, opts) {
98
+ const file = await this.#path(path, opts);
99
+ const bytes = await bytesOf(data);
100
+ await guard("file", () => this.#files.write(file, bytes, request(opts)));
101
+ return { name: basename(file), type: FileType.FILE, path: file };
102
+ }
103
+ /** A directory's entries, hidden ones included; `depth` goes deeper. */
104
+ async list(path, opts = {}) {
105
+ const dir = await this.#path(path, opts);
106
+ const entries = await guard("file", () => this.#files.list(dir, { depth: opts.depth ?? 1, hidden: true }));
107
+ return entries.map(entryInfo);
108
+ }
109
+ /** Makes a directory and its parents. False when it already existed. */
110
+ async makeDir(path, opts = {}) {
111
+ const dir = await this.#path(path, opts);
112
+ if (await guard("file", () => this.#files.exists(dir)))
113
+ return false;
114
+ await guard("file", () => this.#files.mkdir(dir, { parents: true }));
115
+ return true;
116
+ }
117
+ /** Moves a file or directory, replacing a file at the new path, as E2B does. */
118
+ async rename(oldPath, newPath, opts = {}) {
119
+ const from = await this.#path(oldPath, opts);
120
+ const to = await this.#path(newPath, opts);
121
+ await guard("file", () => this.#files.rename(from, to, { overwrite: true }));
122
+ return this.getInfo(to, opts);
123
+ }
124
+ /** Removes a file, or a directory with everything in it. */
125
+ async remove(path, opts = {}) {
126
+ const target = await this.#path(path, opts);
127
+ await guard("file", () => this.#files.remove(target, { recursive: true }));
128
+ }
129
+ async exists(path, opts = {}) {
130
+ const target = await this.#path(path, opts);
131
+ return guard("file", () => this.#files.exists(target));
132
+ }
133
+ async getInfo(path, opts = {}) {
134
+ const target = await this.#path(path, opts);
135
+ const stat = await guard("file", () => this.#files.stat(target));
136
+ if (!stat.exists)
137
+ throw new FileNotFoundError(`${target} does not exist.`);
138
+ return entryInfo(stat);
139
+ }
140
+ watchDir() {
141
+ return Promise.reject(new NotSupportedError("Watching a directory (files.watchDir)", "Poll with files.list(path), or run your own watcher with commands.run(..., { background: true })."));
142
+ }
143
+ }
@@ -0,0 +1,28 @@
1
+ /** Code written for E2B's SDK, on Runtime Cloud. Change the import:
2
+ *
3
+ * import { Sandbox } from "withruntime/e2b"; // was: from "e2b"
4
+ *
5
+ * and set RUNTIME_API_KEY (or put a Runtime key in E2B_API_KEY). What Runtime
6
+ * cannot do the way E2B does throws NotSupportedError, naming what to use. */
7
+ import type { Runtime } from "../client.js";
8
+ import { type ConnectionOpts } from "./client.js";
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";
11
+ export { Commands, CommandHandle, pidOf, type CommandStartOpts, type CommandConnectOpts, type CommandRequestOpts, type ProcessInfo, type Username, } from "./commands.js";
12
+ export { Filesystem, FileType, type EntryInfo, type WriteInfo, type WriteEntry, type FilesystemRequestOpts, type FilesystemReadOpts, type FilesystemWriteOpts, type FilesystemListOpts, } from "./filesystem.js";
13
+ export { SandboxError, TimeoutError, InvalidArgumentError, NotEnoughSpaceError, NotFoundError, FileNotFoundError, SandboxNotFoundError, TemplateError, RateLimitError, AuthenticationError, ServiceBusyError, CommandExitError, NotSupportedError, type CommandResult, } from "./errors.js";
14
+ export type { ConnectionOpts, RuntimeOpts } from "./client.js";
15
+ export { Template, TemplateBase, Volume, Secret, waitForPort, waitForURL, waitForProcess, waitForFile, waitForTimeout, } from "./unsupported.js";
16
+ export default Sandbox;
17
+ /** E2B's client with bound options: `new E2B({ apiKey }).Sandbox.create()`. */
18
+ export declare class E2B {
19
+ readonly Sandbox: typeof Sandbox;
20
+ constructor(opts?: Omit<ConnectionOpts, "signal"> & {
21
+ client?: Runtime;
22
+ });
23
+ }
24
+ /** A subclass whose static calls use `opts`'s key or client unless a call
25
+ * names its own. */
26
+ export declare function bind<S extends typeof Sandbox>(Base: S, opts: Omit<ConnectionOpts, "signal"> & {
27
+ client?: Runtime;
28
+ }): S;
@@ -0,0 +1,61 @@
1
+ import { clientFor } from "./client.js";
2
+ import { Sandbox } from "./sandbox.js";
3
+ export { Sandbox, SandboxPaginator, DEFAULT_SHAPE, DEFAULT_TIMEOUT_MS, } from "./sandbox.js";
4
+ export { Commands, CommandHandle, pidOf, } from "./commands.js";
5
+ export { Filesystem, FileType, } from "./filesystem.js";
6
+ export { SandboxError, TimeoutError, InvalidArgumentError, NotEnoughSpaceError, NotFoundError, FileNotFoundError, SandboxNotFoundError, TemplateError, RateLimitError, AuthenticationError, ServiceBusyError, CommandExitError, NotSupportedError, } from "./errors.js";
7
+ export { Template, TemplateBase, Volume, Secret, waitForPort, waitForURL, waitForProcess, waitForFile, waitForTimeout, } from "./unsupported.js";
8
+ export default Sandbox;
9
+ /** E2B's client with bound options: `new E2B({ apiKey }).Sandbox.create()`. */
10
+ export class E2B {
11
+ Sandbox;
12
+ constructor(opts = {}) {
13
+ this.Sandbox = bind(Sandbox, opts);
14
+ }
15
+ }
16
+ /** A subclass whose static calls use `opts`'s key or client unless a call
17
+ * names its own. */
18
+ export function bind(Base, opts) {
19
+ const client = clientFor({
20
+ ...opts,
21
+ ...(opts.client ? { runtime: { client: opts.client } } : {}),
22
+ });
23
+ const withClient = (given) => ({
24
+ ...given,
25
+ runtime: { ...given?.runtime, client: given?.runtime?.client ?? client },
26
+ });
27
+ const Bound = class extends Base {
28
+ };
29
+ const create = Reflect.get(Base, "create");
30
+ const statics = {
31
+ create(first, second) {
32
+ return typeof first === "string"
33
+ ? create.call(this, first, withClient(second))
34
+ : create.call(this, withClient(first));
35
+ },
36
+ };
37
+ // The calls that take (id, opts) or (id, x, opts): the options come last.
38
+ for (const name of [
39
+ "connect",
40
+ "list",
41
+ "kill",
42
+ "getInfo",
43
+ "setTimeout",
44
+ "pause",
45
+ "betaPause",
46
+ "fork",
47
+ "createSnapshot",
48
+ "deleteSnapshot",
49
+ ]) {
50
+ const original = Reflect.get(Base, name);
51
+ const arity = name === "list" ? 1 : name === "setTimeout" ? 3 : 2;
52
+ statics[name] = function (...args) {
53
+ const padded = [...args];
54
+ padded[arity - 1] = withClient(padded[arity - 1]);
55
+ return original.apply(this, padded);
56
+ };
57
+ }
58
+ for (const [name, value] of Object.entries(statics))
59
+ Object.defineProperty(Bound, name, { value, writable: true, configurable: true });
60
+ return Bound;
61
+ }
@@ -0,0 +1,203 @@
1
+ import type { Runtime } from "../client.js";
2
+ import { type ConnectionOpts, type RuntimeOpts, type RuntimeSandbox } from "./client.js";
3
+ import { Commands } from "./commands.js";
4
+ import { Filesystem } from "./filesystem.js";
5
+ /** E2B's default machine: 2 vCPU and 512 MiB (docs.e2b.dev/billing, checked
6
+ * 23 September 2026). Pass `runtime: { create: { memoryMiB } }` for another. */
7
+ export declare const DEFAULT_SHAPE: {
8
+ readonly vcpu: 2;
9
+ readonly memoryMiB: 512;
10
+ };
11
+ /** E2B's default sandbox timeout, 300 s. */
12
+ export declare const DEFAULT_TIMEOUT_MS = 300000;
13
+ export type SandboxState = "running" | "paused";
14
+ export type SandboxOnTimeout = "pause" | "kill" | {
15
+ action: "pause" | "kill";
16
+ keepMemory?: boolean;
17
+ };
18
+ export type SandboxLifecycle = {
19
+ onTimeout: SandboxOnTimeout;
20
+ autoResume?: boolean;
21
+ };
22
+ export interface SandboxOpts extends ConnectionOpts {
23
+ /** An E2B template name. "base" (the default) is Runtime's stock image; any
24
+ * other name must be a ready Runtime image of that name, and a UUID a
25
+ * Runtime image or snapshot id. */
26
+ template?: string;
27
+ /** Stored as the sandbox's labels (at most 32, values up to 256 characters). */
28
+ metadata?: Record<string, string>;
29
+ /** Given to every command and code run through this object. */
30
+ envs?: Record<string, string>;
31
+ /** Default 300 000. Runtime's leases run 60 s to 1 hour; shorter rounds up
32
+ * to 60 s (with a warning), longer is refused. */
33
+ timeoutMs?: number;
34
+ /** Accepted and ignored, as E2B ignores it. */
35
+ secure?: boolean;
36
+ /** false: no network at all. */
37
+ allowInternetAccess?: boolean;
38
+ /** What happens when the timeout ends: "kill" (E2B's default, Runtime stops
39
+ * the sandbox) or "pause". */
40
+ lifecycle?: SandboxLifecycle;
41
+ mcp?: unknown;
42
+ network?: unknown;
43
+ iam?: unknown;
44
+ volumeMounts?: unknown;
45
+ /** Runtime-only: an explicit client, or fields for the create. */
46
+ runtime?: RuntimeOpts;
47
+ }
48
+ export type SandboxConnectOpts = ConnectionOpts & {
49
+ timeoutMs?: number;
50
+ onResume?: "restore" | "reboot";
51
+ runtime?: RuntimeOpts;
52
+ };
53
+ export type SandboxApiOpts = Pick<ConnectionOpts, "apiKey" | "requestTimeoutMs" | "signal"> & {
54
+ runtime?: RuntimeOpts;
55
+ };
56
+ export interface SandboxInfo {
57
+ sandboxId: string;
58
+ /** "base" for Runtime's stock image, else the image or snapshot id. */
59
+ templateId: string;
60
+ name?: string;
61
+ metadata: Record<string, string>;
62
+ startedAt: Date;
63
+ endAt: Date;
64
+ state: SandboxState;
65
+ cpuCount: number;
66
+ memoryMB: number;
67
+ /** Runtime has no envd: "runtime". */
68
+ envdVersion: string;
69
+ lifecycle?: {
70
+ onTimeout: "pause" | "kill";
71
+ autoResume: boolean;
72
+ };
73
+ }
74
+ export interface SnapshotInfo {
75
+ snapshotId: string;
76
+ names: string[];
77
+ }
78
+ export type SandboxListOpts = SandboxApiOpts & {
79
+ query?: {
80
+ metadata?: Record<string, string>;
81
+ state?: SandboxState[];
82
+ startedAfter?: Date;
83
+ template?: string;
84
+ };
85
+ order?: "asc" | "desc";
86
+ limit?: number;
87
+ nextToken?: string;
88
+ };
89
+ /** A sandbox, with E2B's methods. `sandbox.runtime` is the Runtime sandbox
90
+ * underneath, for anything E2B has no name for. */
91
+ export declare class Sandbox {
92
+ #private;
93
+ protected static readonly defaultTemplate: string;
94
+ readonly files: Filesystem;
95
+ readonly commands: Commands;
96
+ /** Use Sandbox.create or Sandbox.connect. */
97
+ constructor(runtime: RuntimeSandbox, client: Runtime, envs?: Record<string, string>);
98
+ get sandboxId(): string;
99
+ /** The Runtime sandbox underneath: previews, network, desktop, interpreter,
100
+ * processes, terminal and the rest of Runtime's SDK. */
101
+ get runtime(): RuntimeSandbox;
102
+ protected get client(): Runtime;
103
+ protected get envs(): Record<string, string>;
104
+ /** Creates a sandbox from `template` (default "base", Runtime's stock image)
105
+ * with E2B's default machine, 2 vCPU and 512 MiB, and waits until it runs.
106
+ * Funding is left to Runtime: the free trial while the account has trial
107
+ * time, then prepaid credit, exactly as withruntime's own create. */
108
+ static create<S extends typeof Sandbox>(this: S, opts?: SandboxOpts): Promise<InstanceType<S>>;
109
+ static create<S extends typeof Sandbox>(this: S, template: string, opts?: SandboxOpts): Promise<InstanceType<S>>;
110
+ /** Connects to a sandbox by id, waking it if it is paused, as E2B does. A
111
+ * `timeoutMs` moves a running sandbox's end later, never earlier. */
112
+ static connect<S extends typeof Sandbox>(this: S, sandboxId: string, opts?: SandboxConnectOpts): Promise<InstanceType<S>>;
113
+ /** Wakes this sandbox if it is paused. */
114
+ connect(opts?: SandboxConnectOpts): Promise<this>;
115
+ /** Running and paused sandboxes, a page at a time, as E2B's paginator. */
116
+ static list(opts?: SandboxListOpts): SandboxPaginator;
117
+ /** Stops the sandbox. False when it was not found or had already ended. */
118
+ static kill(sandboxId: string, opts?: SandboxApiOpts): Promise<boolean>;
119
+ kill(opts?: Pick<ConnectionOpts, "requestTimeoutMs" | "signal">): Promise<boolean>;
120
+ /** Sets the sandbox to end `timeoutMs` from now. Runtime leases only move
121
+ * later: a shorter timeout than the one it has is refused. */
122
+ static setTimeout(sandboxId: string, timeoutMs: number, opts?: SandboxApiOpts): Promise<void>;
123
+ setTimeout(timeoutMs: number, opts?: Pick<ConnectionOpts, "requestTimeoutMs" | "signal">): Promise<void>;
124
+ static getInfo(sandboxId: string, opts?: SandboxApiOpts): Promise<SandboxInfo>;
125
+ getInfo(opts?: Pick<ConnectionOpts, "requestTimeoutMs" | "signal">): Promise<SandboxInfo>;
126
+ isRunning(opts?: Pick<ConnectionOpts, "requestTimeoutMs" | "signal">): Promise<boolean>;
127
+ /** Pauses the sandbox, keeping memory and files. False when it was paused. */
128
+ static pause(sandboxId: string, opts?: SandboxApiOpts & {
129
+ keepMemory?: boolean;
130
+ }): Promise<boolean>;
131
+ static betaPause(sandboxId: string, opts?: SandboxApiOpts & {
132
+ keepMemory?: boolean;
133
+ }): Promise<boolean>;
134
+ pause(opts?: SandboxApiOpts & {
135
+ keepMemory?: boolean;
136
+ }): Promise<boolean>;
137
+ betaPause(opts?: SandboxApiOpts & {
138
+ keepMemory?: boolean;
139
+ }): Promise<boolean>;
140
+ /** Copies of this sandbox, memory and all. While Runtime's forks are
141
+ * switched off this throws NotSupportedError with Runtime's own words. */
142
+ static fork<S extends typeof Sandbox>(this: S, sandboxId: string, opts?: SandboxApiOpts & {
143
+ count?: number;
144
+ timeoutMs?: number;
145
+ }): Promise<Array<InstanceType<S> | Error>>;
146
+ fork(opts?: SandboxApiOpts & {
147
+ count?: number;
148
+ timeoutMs?: number;
149
+ }): Promise<Array<this | Error>>;
150
+ /** Keeps the sandbox's whole machine as a Runtime snapshot; start from it
151
+ * with Sandbox.create(snapshotId). */
152
+ createSnapshot(opts?: SandboxApiOpts & {
153
+ name?: string;
154
+ }): Promise<SnapshotInfo>;
155
+ static createSnapshot(sandboxId: string, opts?: SandboxApiOpts & {
156
+ name?: string;
157
+ }): Promise<SnapshotInfo>;
158
+ static deleteSnapshot(snapshotId: string, opts?: SandboxApiOpts): Promise<boolean>;
159
+ /** Refused: E2B answers getHost without a call, and a Runtime port becomes
160
+ * reachable only once it is shared. Use getPublicHost. */
161
+ getHost(port: number): string;
162
+ /** Shares `port` at a public HTTPS address (a Runtime preview) and returns
163
+ * its host, `<port>-<id>.<domain>`, like E2B's getHost. Anyone with the
164
+ * address can reach it; a browser sees a one-time page naming Runtime. */
165
+ getPublicHost(port: number): Promise<string>;
166
+ get pty(): never;
167
+ get git(): never;
168
+ /** E2B's metrics, from Runtime's measured readings (`sbx.metrics()`): CPU
169
+ * as a percent of the sandbox's vCPUs and resident memory, one entry per
170
+ * host reading (every minute by default) between `start` and `end`, kept
171
+ * 24 hours at that resolution. Disk use inside the sandbox is not measured:
172
+ * `diskUsed` is null and `diskTotal` is the disk's size. */
173
+ getMetrics(opts?: MetricsOpts): Promise<E2BSandboxMetrics[]>;
174
+ static getMetrics(sandboxId: string, opts?: MetricsOpts & SandboxApiOpts): Promise<E2BSandboxMetrics[]>;
175
+ updateNetwork(): Promise<never>;
176
+ uploadUrl(): Promise<never>;
177
+ downloadUrl(): Promise<never>;
178
+ getMcpUrl(): never;
179
+ getMcpToken(): Promise<never>;
180
+ }
181
+ /** E2B's paginator: `while (p.hasNext) items.push(...(await p.nextItems()))`. */
182
+ export declare class SandboxPaginator {
183
+ #private;
184
+ constructor(client: Runtime, opts: SandboxListOpts);
185
+ get hasNext(): boolean;
186
+ get nextToken(): string | undefined;
187
+ nextItems(): Promise<SandboxInfo[]>;
188
+ }
189
+ type MetricsOpts = {
190
+ start?: Date | number;
191
+ end?: Date | number;
192
+ };
193
+ export type E2BSandboxMetrics = {
194
+ timestamp: Date;
195
+ cpuUsedPct: number;
196
+ cpuCount: number;
197
+ memUsed: number;
198
+ memTotal: number;
199
+ /** Not measured by Runtime: null. */
200
+ diskUsed: number | null;
201
+ diskTotal: number;
202
+ };
203
+ export {};