withruntime 0.11.2 → 0.12.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 +9 -8
- package/README.src.md +8 -7
- package/VERCEL.md +43 -5
- package/compatibility-lock.json +58 -49
- package/dist/billing-cli.d.ts +1 -1
- package/dist/billing-cli.js +77 -1
- 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 +14 -5
- package/dist/blaxel/sandbox.js +63 -7
- 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/logs.test.d.ts +1 -0
- package/dist/cli/logs.test.js +272 -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 +5 -1
- package/dist/cli.js +405 -204
- 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/daytona/computer-use.d.ts +13 -4
- package/dist/daytona/computer-use.js +66 -8
- package/dist/daytona/daytona.d.ts +6 -0
- package/dist/daytona/daytona.js +30 -3
- 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 +27 -21
- package/dist/e2b/sandbox.js +34 -8
- package/dist/e2b/unsupported.js +1 -1
- package/dist/errors.d.ts +10 -1
- package/dist/errors.js +16 -4
- 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 +1 -0
- 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 +12 -3
- package/dist/machine.js +20 -3
- package/dist/mcp.js +1 -1
- 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/apps.d.ts +176 -0
- package/dist/products/apps.js +165 -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 +126 -0
- package/dist/products/builds.js +221 -0
- package/dist/products/index.d.ts +3 -16
- package/dist/products/index.js +3 -14
- package/dist/products/jobs.d.ts +17 -0
- package/dist/products/jobs.js +27 -10
- package/dist/products/logs.d.ts +245 -0
- package/dist/products/logs.js +274 -0
- package/dist/products/logs.test.d.ts +1 -0
- package/dist/products/logs.test.js +343 -0
- package/dist/products/network-products.d.ts +38 -7
- package/dist/products/network-products.js +31 -18
- package/dist/products/observability.d.ts +3 -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/secrets.d.ts +7 -3
- package/dist/products/secrets.js +39 -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 +3 -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 +3 -2
- package/dist/sandbox.js +14 -9
- 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 +15 -1
- package/dist/transport.js +56 -3
- package/dist/tunnel.js +1 -1
- package/dist/types.d.ts +63 -0
- package/dist/vercel/sandbox.js +5 -3
- package/dist/vercel/snapshot.js +10 -2
- package/dist/volumes/index.d.ts +9 -0
- package/dist/volumes/index.js +10 -0
- package/package.json +48 -2
package/dist/ssh.d.ts
CHANGED
|
@@ -16,6 +16,6 @@ export declare function sshKey(env: NodeJS.ProcessEnv): Promise<{
|
|
|
16
16
|
export declare function resolveSandbox(runtime: Runtime, target: string): Promise<Sandbox>;
|
|
17
17
|
export declare function sshConfig(env: NodeJS.ProcessEnv): Promise<string>;
|
|
18
18
|
export declare function sshCommand(argv: string[], env: NodeJS.ProcessEnv, out: Out, connect: () => Promise<Runtime>, me: string): Promise<number>;
|
|
19
|
-
/** `runtime
|
|
19
|
+
/** `runtime sandboxes port-forward <id> 5432 8080:3000 ...` */
|
|
20
20
|
export declare function portForwardCommand(argv: string[], out: Out, connect: () => Promise<Runtime>, me: string): Promise<number>;
|
|
21
21
|
export {};
|
package/dist/ssh.js
CHANGED
|
@@ -6,12 +6,12 @@ import { isAbsolute, join } from "node:path";
|
|
|
6
6
|
import { RuntimeError } from "./errors.js";
|
|
7
7
|
import { VERSION } from "./transport.js";
|
|
8
8
|
const UUID = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
|
|
9
|
-
export const SSH_HELP = (me) => `${me}
|
|
10
|
-
${me}
|
|
9
|
+
export const SSH_HELP = (me) => `${me} sandboxes ssh <id|name> [-- <command...>] Log in over SSH (an interactive shell, or run the command)
|
|
10
|
+
${me} sandboxes ssh config [--install] The ssh config for \`ssh <id|name>.runtime\`, also from
|
|
11
11
|
VS Code Remote-SSH and JetBrains Gateway; --install adds
|
|
12
12
|
it to ~/.ssh/config
|
|
13
|
-
${me}
|
|
14
|
-
${me}
|
|
13
|
+
${me} sandboxes ssh proxy <id|name>[.runtime] ProxyCommand mode: SSH on stdin and stdout
|
|
14
|
+
${me} sandboxes port-forward <id|name> <port|local:remote>... [--address 127.0.0.1]
|
|
15
15
|
Forward local ports to ports in the sandbox, until Ctrl-C
|
|
16
16
|
|
|
17
17
|
SSH and port forwarding go through Runtime's API with your key: the sandbox opens
|
|
@@ -63,7 +63,7 @@ export async function resolveSandbox(runtime, target) {
|
|
|
63
63
|
: `No live sandbox is named ${name}.`,
|
|
64
64
|
code: page.data.length ? "ambiguous_name" : "sandbox_not_found",
|
|
65
65
|
status: 0,
|
|
66
|
-
hint: "Use its id: runtime
|
|
66
|
+
hint: "Use its id: runtime sandboxes ls",
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
const quote = (text) => /^[A-Za-z0-9_./:@=-]+$/.test(text) ? text : `'${text.replace(/'/g, "'\\''")}'`;
|
|
@@ -193,7 +193,7 @@ export async function sshCommand(argv, env, out, connect, me) {
|
|
|
193
193
|
}
|
|
194
194
|
if (first === "proxy") {
|
|
195
195
|
if (!second)
|
|
196
|
-
throw usageError(`Give the host: ${me}
|
|
196
|
+
throw usageError(`Give the host: ${me} sandboxes ssh proxy <id>.runtime`, me);
|
|
197
197
|
return proxy(await connect(), second, await publicKey());
|
|
198
198
|
}
|
|
199
199
|
const runtime = await connect();
|
|
@@ -223,7 +223,7 @@ export async function sshCommand(argv, env, out, connect, me) {
|
|
|
223
223
|
message: `Could not run ssh: ${error.message}`,
|
|
224
224
|
code: "ssh_missing",
|
|
225
225
|
status: 0,
|
|
226
|
-
hint: "Install OpenSSH, or use `runtime
|
|
226
|
+
hint: "Install OpenSSH, or use `runtime sandboxes shell <id>`, which needs nothing.",
|
|
227
227
|
})));
|
|
228
228
|
child.on("exit", (code) => resolve(code ?? 255));
|
|
229
229
|
});
|
|
@@ -233,10 +233,10 @@ function usageError(message, me) {
|
|
|
233
233
|
message,
|
|
234
234
|
code: "usage",
|
|
235
235
|
status: 0,
|
|
236
|
-
hint: `Run \`${me}
|
|
236
|
+
hint: `Run \`${me} sandboxes ssh help\`.`,
|
|
237
237
|
});
|
|
238
238
|
}
|
|
239
|
-
/** `runtime
|
|
239
|
+
/** `runtime sandboxes port-forward <id> 5432 8080:3000 ...` */
|
|
240
240
|
export async function portForwardCommand(argv, out, connect, me) {
|
|
241
241
|
const at = argv.indexOf("--address");
|
|
242
242
|
const address = at === -1 ? "127.0.0.1" : argv[at + 1];
|
|
@@ -244,10 +244,10 @@ export async function portForwardCommand(argv, out, connect, me) {
|
|
|
244
244
|
const [target, ...specs] = positional;
|
|
245
245
|
if (!target || !specs.length || !address)
|
|
246
246
|
throw new RuntimeError({
|
|
247
|
-
message: `Give a sandbox and at least one port: ${me}
|
|
247
|
+
message: `Give a sandbox and at least one port: ${me} sandboxes port-forward <id> 5432 8080:3000`,
|
|
248
248
|
code: "usage",
|
|
249
249
|
status: 0,
|
|
250
|
-
hint: `Run \`${me}
|
|
250
|
+
hint: `Run \`${me} sandboxes ssh help\`.`,
|
|
251
251
|
});
|
|
252
252
|
const ports = specs.map((spec) => {
|
|
253
253
|
const match = /^(?:(\d{1,5}):)?(\d{1,5})$/.exec(spec);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text that came from someone else's program, made safe to print on a
|
|
3
|
+
* terminal: log lines, labels, anything a customer's code wrote. Printed raw,
|
|
4
|
+
* an escape sequence in it could clear or rewrite the screen, set the
|
|
5
|
+
* clipboard (OSC 52), forge a link (OSC 8) or reorder what is read (Unicode
|
|
6
|
+
* direction overrides). Each such character is shown as its \uXXXX escape
|
|
7
|
+
* instead, so nothing is hidden and nothing acts. Tab stays; a newline inside
|
|
8
|
+
* one value is escaped too, so a line on screen is always one value.
|
|
9
|
+
*
|
|
10
|
+
* Only for a terminal: a pipe or a file gets the bytes as they are.
|
|
11
|
+
*/
|
|
12
|
+
export declare function terminalSafe(text: string): string;
|
|
13
|
+
/** As {@link terminalSafe}, for a stream of lines: its newlines stay. */
|
|
14
|
+
export declare function terminalSafeLines(text: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Writes a log stream (a sandbox process's, an image build's, a job run's) to
|
|
17
|
+
* `to`: escaped on a terminal, as written to a pipe or a file, or with `raw`.
|
|
18
|
+
* Not for `exec` or an attached process, whose output is the customer's own
|
|
19
|
+
* terminal session.
|
|
20
|
+
*/
|
|
21
|
+
export declare function logStream(to: {
|
|
22
|
+
isTTY?: boolean;
|
|
23
|
+
write(text: string): unknown;
|
|
24
|
+
}, raw: boolean): (text: string) => void;
|
package/dist/terminal.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text that came from someone else's program, made safe to print on a
|
|
3
|
+
* terminal: log lines, labels, anything a customer's code wrote. Printed raw,
|
|
4
|
+
* an escape sequence in it could clear or rewrite the screen, set the
|
|
5
|
+
* clipboard (OSC 52), forge a link (OSC 8) or reorder what is read (Unicode
|
|
6
|
+
* direction overrides). Each such character is shown as its \uXXXX escape
|
|
7
|
+
* instead, so nothing is hidden and nothing acts. Tab stays; a newline inside
|
|
8
|
+
* one value is escaped too, so a line on screen is always one value.
|
|
9
|
+
*
|
|
10
|
+
* Only for a terminal: a pipe or a file gets the bytes as they are.
|
|
11
|
+
*/
|
|
12
|
+
export function terminalSafe(text) {
|
|
13
|
+
return text.replace(UNSAFE, escaped);
|
|
14
|
+
}
|
|
15
|
+
/** As {@link terminalSafe}, for a stream of lines: its newlines stay. */
|
|
16
|
+
export function terminalSafeLines(text) {
|
|
17
|
+
return text.replace(UNSAFE_BUT_NEWLINE, escaped);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Writes a log stream (a sandbox process's, an image build's, a job run's) to
|
|
21
|
+
* `to`: escaped on a terminal, as written to a pipe or a file, or with `raw`.
|
|
22
|
+
* Not for `exec` or an attached process, whose output is the customer's own
|
|
23
|
+
* terminal session.
|
|
24
|
+
*/
|
|
25
|
+
export function logStream(to, raw) {
|
|
26
|
+
return (text) => void to.write(to.isTTY && !raw ? terminalSafeLines(text) : text);
|
|
27
|
+
}
|
|
28
|
+
const escaped = (char) => `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`;
|
|
29
|
+
// C0 but tab, DEL, C1, and the Unicode marks and overrides that reorder text.
|
|
30
|
+
const CONTROLS = String.raw `\x00-\x08\x0b-\x1f\x7f-\x9f--`;
|
|
31
|
+
const UNSAFE = new RegExp(String.raw `[\n${CONTROLS}]`, "g");
|
|
32
|
+
const UNSAFE_BUT_NEWLINE = new RegExp(`[${CONTROLS}]`, "g");
|
package/dist/transport.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RuntimeError } from "./errors.js";
|
|
2
|
-
export declare const VERSION = "0.
|
|
2
|
+
export declare const VERSION = "0.12.0";
|
|
3
3
|
export declare const DEFAULT_BASE_URL = "https://api.withruntime.com";
|
|
4
4
|
/** Runtime's API as code inside a Runtime sandbox reaches it: the sandbox's
|
|
5
5
|
* own host sends each request on to DEFAULT_BASE_URL over HTTPS. The API runs
|
|
@@ -84,6 +84,13 @@ export declare const DEFAULT_MAX_CONNECTIONS = 48;
|
|
|
84
84
|
* served, and wait rather than fail. Streams (a command's output, a download,
|
|
85
85
|
* a watch) take at most `maxConnections` less KEPT_FOR_CALLS of them. A
|
|
86
86
|
* terminal or tunnel's WebSocket is not counted. */
|
|
87
|
+
/** AbortSignal.timeout in whole milliseconds, rounded up, never under 1.
|
|
88
|
+
* Node throws ERR_OUT_OF_RANGE on a fraction (Bun accepts one), so a
|
|
89
|
+
* customer's timeoutMs of 1500.5 would be a RangeError instead of a request;
|
|
90
|
+
* the live promise probe broke this way on 9 October 2026 (d3cd4bfbd). Every
|
|
91
|
+
* deadline the SDK makes from a customer's or a computed value goes through
|
|
92
|
+
* this. */
|
|
93
|
+
export declare function timeoutSignal(ms: number): AbortSignal;
|
|
87
94
|
export declare class Transport {
|
|
88
95
|
#private;
|
|
89
96
|
readonly baseUrl: string;
|
|
@@ -128,7 +135,14 @@ export declare class Transport {
|
|
|
128
135
|
/** A WebSocket to an API path, authenticated with the same key. */
|
|
129
136
|
websocket(path: string, query?: Query): Promise<WebSocket>;
|
|
130
137
|
}
|
|
138
|
+
/** CLOUD.md section 4: a call under a renamed product word is answered with a
|
|
139
|
+
* Warning naming the new word. It is printed once per process, to stderr, so
|
|
140
|
+
* a loop does not drown its own output and stdout stays the caller's. */
|
|
141
|
+
export declare function sayRenamed(header: string | null, say?: (line: string) => void): void;
|
|
131
142
|
/** A download that ended short of (or past) the length the API promised. */
|
|
132
143
|
export declare function incompleteDownload(got: number, expected: number): RuntimeError;
|
|
133
144
|
/** No key given, none in RUNTIME_API_KEY, and none saved by `runtime login`. */
|
|
134
145
|
export declare function missingKey(): RuntimeError;
|
|
146
|
+
/** Whether a fetch failure is a connection that never opened: its code, or
|
|
147
|
+
* one of its causes', says so. A timeout or a reset never counts. */
|
|
148
|
+
export declare function neverSent(cause: unknown): boolean;
|
package/dist/transport.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ConnectionError, DELIBERATE, errorFor, NOTHING_RAN, RuntimeError, WAITS_FOR_ROOM, } from "./errors.js";
|
|
2
2
|
import { describeRoute, envFetch, openWebSocket } from "./proxy.js";
|
|
3
|
-
|
|
3
|
+
import { warningText } from "./product-renames.js";
|
|
4
|
+
export const VERSION = "0.12.0";
|
|
4
5
|
export const DEFAULT_BASE_URL = "https://api.withruntime.com";
|
|
5
6
|
/** Runtime's API as code inside a Runtime sandbox reaches it: the sandbox's
|
|
6
7
|
* own host sends each request on to DEFAULT_BASE_URL over HTTPS. The API runs
|
|
@@ -172,6 +173,15 @@ const KEPT_FOR_CALLS = 8;
|
|
|
172
173
|
* served, and wait rather than fail. Streams (a command's output, a download,
|
|
173
174
|
* a watch) take at most `maxConnections` less KEPT_FOR_CALLS of them. A
|
|
174
175
|
* terminal or tunnel's WebSocket is not counted. */
|
|
176
|
+
/** AbortSignal.timeout in whole milliseconds, rounded up, never under 1.
|
|
177
|
+
* Node throws ERR_OUT_OF_RANGE on a fraction (Bun accepts one), so a
|
|
178
|
+
* customer's timeoutMs of 1500.5 would be a RangeError instead of a request;
|
|
179
|
+
* the live promise probe broke this way on 9 October 2026 (d3cd4bfbd). Every
|
|
180
|
+
* deadline the SDK makes from a customer's or a computed value goes through
|
|
181
|
+
* this. */
|
|
182
|
+
export function timeoutSignal(ms) {
|
|
183
|
+
return AbortSignal.timeout(Math.max(1, Math.ceil(ms)));
|
|
184
|
+
}
|
|
175
185
|
export class Transport {
|
|
176
186
|
baseUrl;
|
|
177
187
|
#apiKey;
|
|
@@ -245,7 +255,7 @@ export class Transport {
|
|
|
245
255
|
#prepare(call) {
|
|
246
256
|
const timeoutMs = call.timeoutMs ?? this.#timeoutMs;
|
|
247
257
|
const roomMs = Math.max(0, call.waitForCapacityMs ?? 0);
|
|
248
|
-
const deadline = timeoutMs === 0 ? undefined :
|
|
258
|
+
const deadline = timeoutMs === 0 ? undefined : timeoutSignal(timeoutMs + roomMs);
|
|
249
259
|
const signal = deadline
|
|
250
260
|
? call.signal
|
|
251
261
|
? AbortSignal.any([call.signal, deadline])
|
|
@@ -314,6 +324,8 @@ export class Transport {
|
|
|
314
324
|
// An answer that ran nothing is sent again until the call's deadline.
|
|
315
325
|
const idleUntil = call.deadlineAt ?? performance.now() + NOTHING_RAN_MS;
|
|
316
326
|
let idleAttempt = 0;
|
|
327
|
+
// The last try never left, and was sent again at once.
|
|
328
|
+
let resentAtOnce = false;
|
|
317
329
|
for (;;) {
|
|
318
330
|
let response;
|
|
319
331
|
let inCallback = false;
|
|
@@ -344,6 +356,7 @@ export class Transport {
|
|
|
344
356
|
await response.body?.cancel().catch(() => { });
|
|
345
357
|
throw new TypeError(`fetch failed: Runtime answered a redirect (${response.status}).`);
|
|
346
358
|
}
|
|
359
|
+
sayRenamed(response.headers.get("warning"));
|
|
347
360
|
/* An answer that took longer than the API holds its headers (90 s)
|
|
348
361
|
comes as a 200 sent early, and then its JSON: the answer, or
|
|
349
362
|
{"error": ...} when the work failed after the status went
|
|
@@ -439,7 +452,14 @@ export class Transport {
|
|
|
439
452
|
throw cause;
|
|
440
453
|
if (signal?.aborted || !retry || attempt >= this.#maxRetries)
|
|
441
454
|
throw this.#connectionError(call, cause);
|
|
442
|
-
|
|
455
|
+
// A connection that never opened sent no byte of the request, so
|
|
456
|
+
// the next try, which may reach another server, goes at once; once
|
|
457
|
+
// in a row, so an API that is down is not hammered. Anything that
|
|
458
|
+
// may have reached a server (a reset, a timeout, a cut answer)
|
|
459
|
+
// keeps the backoff and its key's rules.
|
|
460
|
+
const atOnce = response === undefined && neverSent(cause) && !resentAtOnce;
|
|
461
|
+
resentAtOnce = atOnce;
|
|
462
|
+
await this.#rest(atOnce ? Math.random() * 50 : backoff(attempt), signal, gate).catch((cause) => {
|
|
443
463
|
throw cause instanceof RuntimeError ? cause : this.#connectionError(call, cause);
|
|
444
464
|
});
|
|
445
465
|
}
|
|
@@ -628,6 +648,17 @@ export class Transport {
|
|
|
628
648
|
}
|
|
629
649
|
/** The status a late answer's body failed with, or undefined when it is an
|
|
630
650
|
* answer. The body is the error the API would have sent as its status. */
|
|
651
|
+
const said = new Set();
|
|
652
|
+
/** CLOUD.md section 4: a call under a renamed product word is answered with a
|
|
653
|
+
* Warning naming the new word. It is printed once per process, to stderr, so
|
|
654
|
+
* a loop does not drown its own output and stdout stays the caller's. */
|
|
655
|
+
export function sayRenamed(header, say = console.warn) {
|
|
656
|
+
const text = warningText(header);
|
|
657
|
+
if (text === undefined || said.has(text))
|
|
658
|
+
return;
|
|
659
|
+
said.add(text);
|
|
660
|
+
say(`Runtime: ${text}`);
|
|
661
|
+
}
|
|
631
662
|
function lateFailure(text) {
|
|
632
663
|
let body;
|
|
633
664
|
try {
|
|
@@ -688,6 +719,28 @@ export function missingKey() {
|
|
|
688
719
|
hint: "Run `npx -y withruntime login` (a browser approval; nothing to copy), set RUNTIME_API_KEY to a key from https://withruntime.com/account/keys, or pass { apiKey }.",
|
|
689
720
|
});
|
|
690
721
|
}
|
|
722
|
+
/** Error codes of a connection that never opened (Node's and Bun's), so no
|
|
723
|
+
* byte of the request left this machine. */
|
|
724
|
+
const NEVER_OPENED = new Set([
|
|
725
|
+
"ECONNREFUSED",
|
|
726
|
+
"ENOENT",
|
|
727
|
+
"EHOSTUNREACH",
|
|
728
|
+
"ENETUNREACH",
|
|
729
|
+
"EADDRNOTAVAIL",
|
|
730
|
+
"ConnectionRefused",
|
|
731
|
+
"FailedToOpenSocket",
|
|
732
|
+
]);
|
|
733
|
+
/** Whether a fetch failure is a connection that never opened: its code, or
|
|
734
|
+
* one of its causes', says so. A timeout or a reset never counts. */
|
|
735
|
+
export function neverSent(cause) {
|
|
736
|
+
for (let at = cause, depth = 0; at && depth < 5; depth++) {
|
|
737
|
+
const code = at.code;
|
|
738
|
+
if (typeof code === "string" && NEVER_OPENED.has(code))
|
|
739
|
+
return true;
|
|
740
|
+
at = at.cause;
|
|
741
|
+
}
|
|
742
|
+
return false;
|
|
743
|
+
}
|
|
691
744
|
function backoff(attempt) {
|
|
692
745
|
return Math.min(8000, 250 * 2 ** attempt) * (0.5 + Math.random());
|
|
693
746
|
}
|
package/dist/tunnel.js
CHANGED
|
@@ -222,7 +222,7 @@ export class Tunnel {
|
|
|
222
222
|
message: `Nothing is listening on port ${port} in the sandbox.`,
|
|
223
223
|
code: "port_closed",
|
|
224
224
|
status: 0,
|
|
225
|
-
hint: "Start the server with spawn (`runtime
|
|
225
|
+
hint: "Start the server with spawn (`runtime sandboxes spawn <id> -- <command>`, sbx.spawn()), which keeps it running: a process started by exec ends with its command. Let it listen on 127.0.0.1, ::1 or every address.",
|
|
226
226
|
})
|
|
227
227
|
: error.message === "reserved"
|
|
228
228
|
? new RuntimeError({
|
package/dist/types.d.ts
CHANGED
|
@@ -82,6 +82,10 @@ export type SandboxInfo = {
|
|
|
82
82
|
};
|
|
83
83
|
export type CreateSandbox = {
|
|
84
84
|
name?: string;
|
|
85
|
+
/** What the end of an `await using` block does to it. By default the
|
|
86
|
+
* block deletes it; `keep: true` stops it instead, which keeps its disk
|
|
87
|
+
* (billed while it is kept). Not sent to the API. */
|
|
88
|
+
keep?: boolean;
|
|
85
89
|
labels?: Record<string, string>;
|
|
86
90
|
/** Environment variables for every command, process, terminal, SSH session
|
|
87
91
|
* and the image's start command in this sandbox, under each command's own
|
|
@@ -153,6 +157,18 @@ export type CreateSandbox = {
|
|
|
153
157
|
tags?: string[];
|
|
154
158
|
};
|
|
155
159
|
};
|
|
160
|
+
/** Present on a command the sandbox's out-of-memory killer ended (the
|
|
161
|
+
* program, or anything it started): a bare exit -9, or 137 from a shell,
|
|
162
|
+
* does not say why. */
|
|
163
|
+
export type OutOfMemory = {
|
|
164
|
+
code: "out_of_memory";
|
|
165
|
+
processesKilled: number;
|
|
166
|
+
/** The sandbox's memory size; null if it could not be read. */
|
|
167
|
+
memoryMiB: number | null;
|
|
168
|
+
message: string;
|
|
169
|
+
/** What to do: a larger memoryMiB, or a program that uses less. */
|
|
170
|
+
hint: string;
|
|
171
|
+
};
|
|
156
172
|
export type CommandResult = {
|
|
157
173
|
exitCode: number | null;
|
|
158
174
|
stdout: string;
|
|
@@ -163,6 +179,7 @@ export type CommandResult = {
|
|
|
163
179
|
durationMs?: number | null;
|
|
164
180
|
processId?: string;
|
|
165
181
|
replayed?: boolean;
|
|
182
|
+
outOfMemory?: OutOfMemory;
|
|
166
183
|
};
|
|
167
184
|
export type ExecOptions = {
|
|
168
185
|
cwd?: string;
|
|
@@ -196,6 +213,7 @@ export type ProcessInfo = {
|
|
|
196
213
|
timeoutMs: number | null;
|
|
197
214
|
outputBytes: number;
|
|
198
215
|
firstOffset: number;
|
|
216
|
+
outOfMemory?: OutOfMemory;
|
|
199
217
|
};
|
|
200
218
|
export type OutputEvent = {
|
|
201
219
|
type: "start";
|
|
@@ -212,6 +230,7 @@ export type OutputEvent = {
|
|
|
212
230
|
state: string;
|
|
213
231
|
timedOut: boolean;
|
|
214
232
|
durationMs?: number;
|
|
233
|
+
outOfMemory?: OutOfMemory;
|
|
215
234
|
} | {
|
|
216
235
|
type: "truncated";
|
|
217
236
|
droppedBytes: number;
|
|
@@ -300,6 +319,50 @@ export type Usage = {
|
|
|
300
319
|
month: string;
|
|
301
320
|
renewsAt: string;
|
|
302
321
|
}>;
|
|
322
|
+
/** What Runtime for Startups includes (https://withruntime.com/startups).
|
|
323
|
+
* Startup hours are given once, used after this month's included usage
|
|
324
|
+
* and before credit, never renewed, and gone after 12 months. Storage is
|
|
325
|
+
* GB kept free each month for those 12 months. Empty unless the account
|
|
326
|
+
* was accepted to the program or given it; absent from an older API. */
|
|
327
|
+
startupIncluded?: Array<{
|
|
328
|
+
/** machine-cpu, machine-memory, saved-copies (snapshots, images and
|
|
329
|
+
* backups) or disks (volumes). */
|
|
330
|
+
pool: string;
|
|
331
|
+
/** vCPU-hour or GiB-hour for startup hours given `once`, GB for `month` storage. */
|
|
332
|
+
unit: string;
|
|
333
|
+
/** `once`: given once and used up by what runs. `month`: `quantity` GB
|
|
334
|
+
* added to each month's included storage until `expiresAt`, never used
|
|
335
|
+
* up; storage past it bills at the published rate. Absent from an API
|
|
336
|
+
* before startup storage (7 October 2026): `once`. */
|
|
337
|
+
period?: "once" | "month";
|
|
338
|
+
quantity: number;
|
|
339
|
+
/** Null for monthly storage. */
|
|
340
|
+
used: number | null;
|
|
341
|
+
/** Held for what is running now; given back unless used. Null for
|
|
342
|
+
* monthly storage. */
|
|
343
|
+
reserved: number | null;
|
|
344
|
+
/** Null for monthly storage. */
|
|
345
|
+
left: number | null;
|
|
346
|
+
/** Storage GB kept now; null for startup hours given `once`. */
|
|
347
|
+
keptGB?: number | null;
|
|
348
|
+
/** `startup`. */
|
|
349
|
+
source: string;
|
|
350
|
+
grantedAt: string;
|
|
351
|
+
/** 12 months after `grantedAt`: what is left then is gone. */
|
|
352
|
+
expiresAt?: string;
|
|
353
|
+
}>;
|
|
354
|
+
/** What Runtime for Startups includes at once for its 12 months:
|
|
355
|
+
* image builds, and sandboxes (past it, a create answers quota_exceeded).
|
|
356
|
+
* Null without one or after them, when the account's own limits apply;
|
|
357
|
+
* absent from an API older than 7 October 2026. */
|
|
358
|
+
startupLimits?: {
|
|
359
|
+
buildsAtOnce: number;
|
|
360
|
+
sandboxesAtOnce: number;
|
|
361
|
+
} | null;
|
|
362
|
+
/** @deprecated Renamed `startupIncluded`; works for 30 days after the rename, with a warning. */
|
|
363
|
+
readonly pot?: Usage["startupIncluded"];
|
|
364
|
+
/** @deprecated Renamed `startupLimits`; works for 30 days after the rename, with a warning. */
|
|
365
|
+
readonly potLimits?: Usage["startupLimits"];
|
|
303
366
|
/** Outbound traffic this calendar month, UTC: the first `allowanceBytes` an
|
|
304
367
|
* account sends are free, and the rest is charged at the rate in the pricing
|
|
305
368
|
* guide (https://withruntime.com/docs/pricing#network-products). */
|
package/dist/vercel/sandbox.js
CHANGED
|
@@ -2,7 +2,7 @@ import { extensionSeconds, LeaseKeeper, LEASE_MAX_SECONDS } from "../compat/leas
|
|
|
2
2
|
import { RuntimeError } from "../errors.js";
|
|
3
3
|
import { clientFor, signalOf, } from "./client.js";
|
|
4
4
|
import { Command, CommandFinished, exitCodeOf } from "./command.js";
|
|
5
|
-
import { APIError, guard, NotSupportedError, translate } from "./errors.js";
|
|
5
|
+
import { APIError, guard, NotSupportedError, StreamError, translate } from "./errors.js";
|
|
6
6
|
import { FileSystem } from "./filesystem.js";
|
|
7
7
|
import { rootOrThrow, SandboxUser, SandboxUserAlreadyExistsError, validateName, } from "./sandbox-user.js";
|
|
8
8
|
import { Snapshot } from "./snapshot.js";
|
|
@@ -105,7 +105,7 @@ async function resolveImage(client, params) {
|
|
|
105
105
|
const found = page.data[0];
|
|
106
106
|
if (found)
|
|
107
107
|
return { image: found.id };
|
|
108
|
-
throw new NotSupportedError(`The image ${image}, which is not a Runtime image`, `Build it as a Runtime image with that name and this call starts from it: \`npx withruntime
|
|
108
|
+
throw new NotSupportedError(`The image ${image}, which is not a Runtime image`, `Build it as a Runtime image with that name and this call starts from it: \`npx withruntime images build --dockerfile Dockerfile --name ${image}\`, or runtime.images.build({ name: "${image}", image: "<registry reference>" }).`);
|
|
109
109
|
}
|
|
110
110
|
/** Runtime's state as Vercel's status: a paused sandbox is a stopped
|
|
111
111
|
* persistent one. */
|
|
@@ -520,6 +520,8 @@ export class Sandbox {
|
|
|
520
520
|
onStdout: record("stdout", params.stdout),
|
|
521
521
|
onStderr: record("stderr", params.stderr),
|
|
522
522
|
}), params);
|
|
523
|
+
if (result.stdoutTruncated || result.stderrTruncated)
|
|
524
|
+
throw new StreamError("output_truncated", "Some command output is no longer available.", result.processId ?? this.#rt.id);
|
|
523
525
|
return new CommandFinished({
|
|
524
526
|
id: result.processId ?? `cmd_${startedAt}`,
|
|
525
527
|
cwd: vercelCwd,
|
|
@@ -775,7 +777,7 @@ export class Sandbox {
|
|
|
775
777
|
* Runtime's terminal opens with the account key, which must not leave the
|
|
776
778
|
* server. */
|
|
777
779
|
openInteractive() {
|
|
778
|
-
return Promise.reject(new NotSupportedError("Vercel's interactive shell (openInteractive)", "Use `await sandbox.withruntime.terminal({ cols, rows, onData })`, or `npx withruntime
|
|
780
|
+
return Promise.reject(new NotSupportedError("Vercel's interactive shell (openInteractive)", "Use `await sandbox.withruntime.terminal({ cols, rows, onData })`, or `npx withruntime sandboxes shell <id>`."));
|
|
779
781
|
}
|
|
780
782
|
/** The user commands run as, `runtime`, and its group. */
|
|
781
783
|
getDefaultUser(_opts = {}) {
|
package/dist/vercel/snapshot.js
CHANGED
|
@@ -7,6 +7,14 @@ function statusOf(state) {
|
|
|
7
7
|
return "deleted";
|
|
8
8
|
return "created";
|
|
9
9
|
}
|
|
10
|
+
/** Vercel's snapshots always expire. Runtime's has no end date while it is kept
|
|
11
|
+
* for as long as the account has credit; it is then taken at the longest a
|
|
12
|
+
* snapshot is kept, a year from when it was made. */
|
|
13
|
+
function expiresAtOf(snapshot) {
|
|
14
|
+
return snapshot.expiresAt === null
|
|
15
|
+
? Date.parse(snapshot.createdAt) + 365 * 86_400_000
|
|
16
|
+
: Date.parse(snapshot.expiresAt);
|
|
17
|
+
}
|
|
10
18
|
function metadataOf(snapshot) {
|
|
11
19
|
return {
|
|
12
20
|
id: snapshot.id,
|
|
@@ -17,7 +25,7 @@ function metadataOf(snapshot) {
|
|
|
17
25
|
sizeBytes: snapshot.storedBytes ?? 0,
|
|
18
26
|
createdAt: Date.parse(snapshot.createdAt),
|
|
19
27
|
updatedAt: Date.parse(snapshot.readyAt ?? snapshot.createdAt),
|
|
20
|
-
expiresAt:
|
|
28
|
+
expiresAt: expiresAtOf(snapshot),
|
|
21
29
|
};
|
|
22
30
|
}
|
|
23
31
|
/** A saved filesystem, as Vercel's Snapshot, over a Runtime disk snapshot.
|
|
@@ -52,7 +60,7 @@ export class Snapshot {
|
|
|
52
60
|
return new Date(this.#snapshot.readyAt ?? this.#snapshot.createdAt);
|
|
53
61
|
}
|
|
54
62
|
get expiresAt() {
|
|
55
|
-
return new Date(this.#snapshot
|
|
63
|
+
return new Date(expiresAtOf(this.#snapshot));
|
|
56
64
|
}
|
|
57
65
|
static async get(params) {
|
|
58
66
|
const client = clientFor(params);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** `withruntime/volumes`: Volumes alone. Persistent disks to attach to sandboxes.
|
|
2
|
+
*
|
|
3
|
+
* import { volumes } from "withruntime/volumes";
|
|
4
|
+
* const client = volumes(); // RUNTIME_API_KEY, or this machine's saved connection
|
|
5
|
+
*/
|
|
6
|
+
import { Runtime, type RuntimeOptions } from "../client.js";
|
|
7
|
+
export type * from "../products/volumes.js";
|
|
8
|
+
/** `runtime.volumes` of a client made with `options`. */
|
|
9
|
+
export declare function volumes(options?: RuntimeOptions): Runtime["volumes"];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** `withruntime/volumes`: Volumes alone. Persistent disks to attach to sandboxes.
|
|
2
|
+
*
|
|
3
|
+
* import { volumes } from "withruntime/volumes";
|
|
4
|
+
* const client = volumes(); // RUNTIME_API_KEY, or this machine's saved connection
|
|
5
|
+
*/
|
|
6
|
+
import { Runtime } from "../client.js";
|
|
7
|
+
/** `runtime.volumes` of a client made with `options`. */
|
|
8
|
+
export function volumes(options) {
|
|
9
|
+
return new Runtime(options).volumes;
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "withruntime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"mcpName": "com.withruntime/runtime",
|
|
6
6
|
"type": "module",
|
|
@@ -10,6 +10,51 @@
|
|
|
10
10
|
"import": "./dist/index.js",
|
|
11
11
|
"default": "./dist/index.js"
|
|
12
12
|
},
|
|
13
|
+
"./sandboxes": {
|
|
14
|
+
"types": "./dist/sandboxes/index.d.ts",
|
|
15
|
+
"import": "./dist/sandboxes/index.js",
|
|
16
|
+
"default": "./dist/sandboxes/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./snapshots": {
|
|
19
|
+
"types": "./dist/snapshots/index.d.ts",
|
|
20
|
+
"import": "./dist/snapshots/index.js",
|
|
21
|
+
"default": "./dist/snapshots/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./images": {
|
|
24
|
+
"types": "./dist/images/index.d.ts",
|
|
25
|
+
"import": "./dist/images/index.js",
|
|
26
|
+
"default": "./dist/images/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./volumes": {
|
|
29
|
+
"types": "./dist/volumes/index.d.ts",
|
|
30
|
+
"import": "./dist/volumes/index.js",
|
|
31
|
+
"default": "./dist/volumes/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./jobs": {
|
|
34
|
+
"types": "./dist/jobs/index.d.ts",
|
|
35
|
+
"import": "./dist/jobs/index.js",
|
|
36
|
+
"default": "./dist/jobs/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./domains": {
|
|
39
|
+
"types": "./dist/domains/index.d.ts",
|
|
40
|
+
"import": "./dist/domains/index.js",
|
|
41
|
+
"default": "./dist/domains/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./ports": {
|
|
44
|
+
"types": "./dist/ports/index.d.ts",
|
|
45
|
+
"import": "./dist/ports/index.js",
|
|
46
|
+
"default": "./dist/ports/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./ips": {
|
|
49
|
+
"types": "./dist/ips/index.d.ts",
|
|
50
|
+
"import": "./dist/ips/index.js",
|
|
51
|
+
"default": "./dist/ips/index.js"
|
|
52
|
+
},
|
|
53
|
+
"./networks": {
|
|
54
|
+
"types": "./dist/networks/index.d.ts",
|
|
55
|
+
"import": "./dist/networks/index.js",
|
|
56
|
+
"default": "./dist/networks/index.js"
|
|
57
|
+
},
|
|
13
58
|
"./e2b": {
|
|
14
59
|
"types": "./dist/e2b/index.d.ts",
|
|
15
60
|
"import": "./dist/e2b/index.js",
|
|
@@ -127,6 +172,7 @@
|
|
|
127
172
|
"compat:upstream": "bun scripts/check-upstream.ts",
|
|
128
173
|
"test:compat": "bun test tests/e2b tests/daytona tests/vercel tests/blaxel tests/compat tests/drop-in-isolation.test.ts tests/drop-in-paths.test.ts tests/process-input.test.ts tests/watch-reentrant.test.ts tests/upstream-check.test.ts tests/process-output.test.ts tests/prepare-compatibility.test.ts",
|
|
129
174
|
"compat:prepare": "bun scripts/prepare-compatibility.ts",
|
|
175
|
+
"compat:inventory": "bun scripts/compat-inventory.ts",
|
|
130
176
|
"compat:oracle": "bun oracle/check.mjs"
|
|
131
177
|
},
|
|
132
178
|
"devDependencies": {
|
|
@@ -137,7 +183,7 @@
|
|
|
137
183
|
"@google/genai": "2.24.0",
|
|
138
184
|
"@mastra/core": "1.71.0",
|
|
139
185
|
"@mistralai/mistralai": "2.7.0",
|
|
140
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
186
|
+
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
141
187
|
"@openai/agents": "0.18.0",
|
|
142
188
|
"@openai/agents-core": "0.18.0",
|
|
143
189
|
"@openrouter/sdk": "1.3.27",
|