withruntime 0.11.0 → 0.11.2
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 +8 -9
- package/DAYTONA.md +8 -9
- package/E2B.md +63 -21
- package/README.md +6 -5
- package/README.src.md +6 -5
- package/VERCEL.md +3 -2
- package/compatibility-lock.json +69 -14
- package/dist/api-defaults.d.ts +1 -1
- package/dist/api-defaults.js +1 -1
- package/dist/blaxel/errors.js +4 -4
- package/dist/blaxel/lookup.d.ts +2 -1
- package/dist/blaxel/lookup.js +2 -1
- package/dist/blaxel/sandbox.d.ts +8 -7
- package/dist/blaxel/sandbox.js +16 -12
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +99 -27
- package/dist/client.d.ts +16 -60
- package/dist/client.js +14 -103
- package/dist/compat/files.js +5 -1
- package/dist/compat/lease.d.ts +1 -0
- package/dist/compat/lease.js +14 -8
- package/dist/credentials.d.ts +9 -0
- package/dist/credentials.js +26 -4
- package/dist/daytona/daytona.d.ts +1 -2
- package/dist/daytona/daytona.js +30 -14
- package/dist/daytona/sandbox.d.ts +9 -4
- package/dist/daytona/sandbox.js +24 -5
- package/dist/e2b/client.d.ts +15 -2
- package/dist/e2b/client.js +61 -7
- package/dist/e2b/commands.d.ts +3 -0
- package/dist/e2b/commands.js +16 -5
- package/dist/e2b/errors.d.ts +26 -2
- package/dist/e2b/errors.js +38 -5
- package/dist/e2b/filesystem.d.ts +1 -1
- package/dist/e2b/filesystem.js +82 -16
- package/dist/e2b/index.d.ts +2 -2
- package/dist/e2b/index.js +2 -2
- package/dist/e2b/sandbox.d.ts +25 -12
- package/dist/e2b/sandbox.js +196 -165
- package/dist/e2b/unsupported.d.ts +19 -0
- package/dist/e2b/unsupported.js +21 -0
- package/dist/e2b/users.d.ts +9 -0
- package/dist/e2b/users.js +22 -0
- package/dist/errors.d.ts +10 -4
- package/dist/errors.js +18 -10
- package/dist/identity.js +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/machine.d.ts +180 -0
- package/dist/machine.js +504 -0
- package/dist/modal/index.js +6 -2
- package/dist/network-cli.js +7 -7
- package/dist/openai-agents/index.d.ts +1 -1
- package/dist/openai-agents/index.js +1 -1
- package/dist/products/browser.d.ts +2 -1
- package/dist/products/browser.js +9 -19
- package/dist/products/desktop.d.ts +2 -1
- package/dist/products/desktop.js +5 -30
- package/dist/products/jobs.d.ts +6 -5
- package/dist/products/jobs.js +6 -3
- package/dist/products/limits.d.ts +4 -10
- package/dist/products/mcp.d.ts +5 -1
- package/dist/products/mcp.js +29 -8
- package/dist/products/network-products.d.ts +1 -1
- package/dist/products/network-products.js +1 -1
- package/dist/products/network.d.ts +1 -1
- package/dist/products/observability.d.ts +1 -1
- package/dist/products/private-network.d.ts +1 -1
- package/dist/products/secrets.d.ts +3 -3
- package/dist/products/switching.d.ts +2 -3
- package/dist/runloop/index.js +6 -2
- package/dist/sandbox.d.ts +7 -84
- package/dist/sandbox.js +58 -345
- package/dist/tar.d.ts +2 -0
- package/dist/tar.js +74 -16
- package/dist/transport.d.ts +36 -8
- package/dist/transport.js +174 -37
- package/dist/types.d.ts +102 -12
- package/dist/vercel/filesystem.js +3 -1
- package/dist/vercel/sandbox.d.ts +18 -12
- package/dist/vercel/sandbox.js +27 -15
- package/dist/wait.d.ts +12 -0
- package/dist/wait.js +47 -0
- package/package.json +1 -1
package/dist/products/desktop.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { whileInstalling } from "../wait.js";
|
|
1
2
|
/** `sbx.desktop`: a Linux desktop in the sandbox, driven like a person would.
|
|
2
3
|
*
|
|
3
4
|
* const { streamUrl } = await sbx.desktop.start();
|
|
@@ -12,25 +13,10 @@ export function sandboxDesktop(t, sandbox) {
|
|
|
12
13
|
const act = (body, options) => t.json({ method: "POST", path: `${base()}:act`, body, ...options });
|
|
13
14
|
return {
|
|
14
15
|
/** Starts the desktop. The first start in a sandbox installs it, which
|
|
15
|
-
* takes a minute or two; this waits for that (up to 10 minutes
|
|
16
|
+
* takes a minute or two; this waits for that (up to 10 minutes, or the
|
|
17
|
+
* call's timeoutMs). */
|
|
16
18
|
async start(size = {}, options) {
|
|
17
|
-
|
|
18
|
-
for (;;) {
|
|
19
|
-
try {
|
|
20
|
-
return await t.json({
|
|
21
|
-
method: "POST",
|
|
22
|
-
path: `${base()}:start`,
|
|
23
|
-
body: size,
|
|
24
|
-
...options,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
const code = error.code;
|
|
29
|
-
if (code !== "desktop_installing" || Date.now() > deadline)
|
|
30
|
-
throw error;
|
|
31
|
-
await new Promise((resolve) => setTimeout(resolve, error.retryAfterMs ?? 10_000));
|
|
32
|
-
}
|
|
33
|
-
}
|
|
19
|
+
return whileInstalling(["desktop_installing"], options, (request) => t.json({ method: "POST", path: `${base()}:start`, body: size, ...request }));
|
|
34
20
|
},
|
|
35
21
|
stop: (options) => t.json({ method: "POST", path: `${base()}:stop`, ...options }),
|
|
36
22
|
/** PNG bytes, or JPEG with `format: "jpeg"`. */
|
|
@@ -53,18 +39,7 @@ export function sandboxDesktop(t, sandbox) {
|
|
|
53
39
|
/** Opens `url` in Chromium on the desktop. Right after a sandbox's first
|
|
54
40
|
* start, Chromium may still be installing; this waits for it. */
|
|
55
41
|
async open(url, options) {
|
|
56
|
-
|
|
57
|
-
for (;;) {
|
|
58
|
-
try {
|
|
59
|
-
return await act({ action: "open", url }, options);
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
const code = error.code;
|
|
63
|
-
if (code !== "desktop_installing" || Date.now() > deadline)
|
|
64
|
-
throw error;
|
|
65
|
-
await new Promise((resolve) => setTimeout(resolve, error.retryAfterMs ?? 10_000));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
42
|
+
return whileInstalling(["desktop_installing"], options, (request) => act({ action: "open", url }, request));
|
|
68
43
|
},
|
|
69
44
|
/** Starts a program on the desktop, detached. */
|
|
70
45
|
launch: (argv, options) => act({ action: "launch", argv }, options),
|
package/dist/products/jobs.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Page } from "../page.js";
|
|
2
2
|
import type { RequestOptions, Transport } from "../transport.js";
|
|
3
|
-
/** A run's sandbox. Every field has a default; a run is a
|
|
4
|
-
* size,
|
|
3
|
+
/** A run's sandbox. Every field has a default; a run is a sandbox of this
|
|
4
|
+
* size, on the included usage first and then on credit at the sandbox rates. */
|
|
5
5
|
export type JobCompute = {
|
|
6
6
|
region: string;
|
|
7
7
|
vcpu: number;
|
|
@@ -147,11 +147,12 @@ export declare const JOB_DEFAULTS: {
|
|
|
147
147
|
startSeconds: number;
|
|
148
148
|
};
|
|
149
149
|
/** A run is one sandbox: at most 16 vCPU and 64 GiB, a disk no smaller than
|
|
150
|
-
* the system image, and paid for at most an hour. */
|
|
150
|
+
* the system image and no larger than 400 GiB, and paid for at most an hour. */
|
|
151
151
|
export declare const JOB_LIMITS: {
|
|
152
152
|
maxVcpu: number;
|
|
153
153
|
maxMemoryMiB: number;
|
|
154
154
|
minDiskMiB: number;
|
|
155
|
+
maxDiskMiB: number;
|
|
155
156
|
maxDurationSeconds: number;
|
|
156
157
|
maxAttempts: number;
|
|
157
158
|
maxSecrets: number;
|
|
@@ -167,8 +168,8 @@ export declare function jobBody(input: CreateJob): Record<string, unknown>;
|
|
|
167
168
|
* request id, and says no retry will change it. */
|
|
168
169
|
export declare function switchedOff(product: string): (error: unknown) => never;
|
|
169
170
|
/** Scheduled jobs: a command run in a fresh sandbox, once or on a cron
|
|
170
|
-
* schedule. Each run is a
|
|
171
|
-
* the same holds and spending limits
|
|
171
|
+
* schedule. Each run is a sandbox, paid for as one: from the included usage first while the run fits the limits without credit, then from credit
|
|
172
|
+
* at the sandbox rates, through the same holds and spending limits.
|
|
172
173
|
*
|
|
173
174
|
* const job = await runtime.jobs.create({
|
|
174
175
|
* name: "nightly-report",
|
package/dist/products/jobs.js
CHANGED
|
@@ -15,11 +15,12 @@ export const JOB_DEFAULTS = {
|
|
|
15
15
|
startSeconds: JOB_START_SECONDS,
|
|
16
16
|
};
|
|
17
17
|
/** A run is one sandbox: at most 16 vCPU and 64 GiB, a disk no smaller than
|
|
18
|
-
* the system image, and paid for at most an hour. */
|
|
18
|
+
* the system image and no larger than 400 GiB, and paid for at most an hour. */
|
|
19
19
|
export const JOB_LIMITS = {
|
|
20
20
|
maxVcpu: 16,
|
|
21
21
|
maxMemoryMiB: 65_536,
|
|
22
22
|
minDiskMiB: 3072,
|
|
23
|
+
maxDiskMiB: 409_600,
|
|
23
24
|
maxDurationSeconds: 3600,
|
|
24
25
|
maxAttempts: 5,
|
|
25
26
|
maxSecrets: 16,
|
|
@@ -88,6 +89,8 @@ export function jobBody(input) {
|
|
|
88
89
|
throw invalid(`A run's sandbox is at most ${JOB_LIMITS.maxVcpu} vCPU and ${JOB_LIMITS.maxMemoryMiB / 1024} GiB of memory; asked for ${compute.vcpu} vCPU and ${compute.memoryMiB} MiB.`, compute.vcpu > JOB_LIMITS.maxVcpu ? "compute.vcpu" : "compute.memoryMiB");
|
|
89
90
|
if (compute.diskMiB < JOB_LIMITS.minDiskMiB)
|
|
90
91
|
throw invalid(`A run's disk is at least ${JOB_LIMITS.minDiskMiB} MiB, the size of the system image; asked for ${compute.diskMiB}.`, "compute.diskMiB");
|
|
92
|
+
if (compute.diskMiB > JOB_LIMITS.maxDiskMiB)
|
|
93
|
+
throw invalid(`A run's disk is at most ${JOB_LIMITS.maxDiskMiB} MiB (${JOB_LIMITS.maxDiskMiB / 1024} GiB); asked for ${compute.diskMiB}.`, "compute.diskMiB");
|
|
91
94
|
if (timeoutSeconds > compute.durationSeconds ||
|
|
92
95
|
compute.durationSeconds > JOB_LIMITS.maxDurationSeconds)
|
|
93
96
|
throw invalid(`timeoutSeconds (${timeoutSeconds}) must fit in the time a run is paid for (compute.durationSeconds ${compute.durationSeconds}), which is at most ${JOB_LIMITS.maxDurationSeconds} seconds.`, "timeoutSeconds");
|
|
@@ -125,8 +128,8 @@ export function switchedOff(product) {
|
|
|
125
128
|
};
|
|
126
129
|
}
|
|
127
130
|
/** Scheduled jobs: a command run in a fresh sandbox, once or on a cron
|
|
128
|
-
* schedule. Each run is a
|
|
129
|
-
* the same holds and spending limits
|
|
131
|
+
* schedule. Each run is a sandbox, paid for as one: from the included usage first while the run fits the limits without credit, then from credit
|
|
132
|
+
* at the sandbox rates, through the same holds and spending limits.
|
|
130
133
|
*
|
|
131
134
|
* const job = await runtime.jobs.create({
|
|
132
135
|
* name: "nightly-report",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Usage } from "../types.js";
|
|
1
2
|
import type { RequestOptions, Transport } from "../transport.js";
|
|
2
3
|
/** What this key may do, and the daily spending limit on its agent. Money is
|
|
3
4
|
* integer microdollars in strings (1,000,000 = $1). */
|
|
@@ -14,16 +15,9 @@ export type KeyLimits = {
|
|
|
14
15
|
remainingMicros: string | null;
|
|
15
16
|
window: "24h";
|
|
16
17
|
};
|
|
17
|
-
/**
|
|
18
|
-
* `usage.get()`, or null when
|
|
19
|
-
|
|
20
|
-
* `availableMs = totalMs - usedMs - reservedMs`. */
|
|
21
|
-
trial: {
|
|
22
|
-
totalMs: number;
|
|
23
|
-
usedMs: number;
|
|
24
|
-
reservedMs: number;
|
|
25
|
-
availableMs: number;
|
|
26
|
-
} | null;
|
|
18
|
+
/** Machine time the account can still run without credit, the same
|
|
19
|
+
* figures as `usage.get()`'s `trial`, or null when it has none. */
|
|
20
|
+
trial: Usage["trial"];
|
|
27
21
|
};
|
|
28
22
|
/** `runtime.limits.get()`: whether this key is read-only, and what its agent
|
|
29
23
|
* may still spend today. An owner sets the limit at
|
package/dist/products/mcp.d.ts
CHANGED
|
@@ -68,10 +68,14 @@ export declare function sandboxMcp(t: Transport, sandbox: Sandbox): {
|
|
|
68
68
|
}, options?: RequestOptions) => Promise<McpGateway>;
|
|
69
69
|
/** Their state, and fresh URLs. */
|
|
70
70
|
get: (options?: RequestOptions) => Promise<McpGateway>;
|
|
71
|
-
/** Wait until every server is ready (or one failed).
|
|
71
|
+
/** Wait until every server is ready (or one failed). Past `timeoutMs`
|
|
72
|
+
* (default ten minutes), the last state read; a status request still
|
|
73
|
+
* unanswered then is cut off at the deadline, and throws its timeout when
|
|
74
|
+
* no state was read at all. */
|
|
72
75
|
ready(input?: {
|
|
73
76
|
timeoutMs?: number;
|
|
74
77
|
intervalMs?: number;
|
|
78
|
+
signal?: AbortSignal;
|
|
75
79
|
}): Promise<McpGateway>;
|
|
76
80
|
stop: (options?: RequestOptions) => Promise<{
|
|
77
81
|
stopped: boolean;
|
package/dist/products/mcp.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { pause } from "../wait.js";
|
|
1
2
|
/** `runtime.mcp`: the catalog of MCP servers a sandbox can run. */
|
|
2
3
|
export function mcp(t) {
|
|
3
4
|
return {
|
|
@@ -20,16 +21,36 @@ export function sandboxMcp(t, sandbox) {
|
|
|
20
21
|
start: (servers, input = {}, options) => t.json({ method: "POST", path: path(), body: { servers, ...input }, ...options }),
|
|
21
22
|
/** Their state, and fresh URLs. */
|
|
22
23
|
get: (options) => t.json({ method: "GET", path: path(), ...options }),
|
|
23
|
-
/** Wait until every server is ready (or one failed).
|
|
24
|
+
/** Wait until every server is ready (or one failed). Past `timeoutMs`
|
|
25
|
+
* (default ten minutes), the last state read; a status request still
|
|
26
|
+
* unanswered then is cut off at the deadline, and throws its timeout when
|
|
27
|
+
* no state was read at all. */
|
|
24
28
|
async ready(input = {}) {
|
|
25
|
-
const deadline =
|
|
29
|
+
const deadline = performance.now() + (input.timeoutMs ?? 600_000);
|
|
30
|
+
let last;
|
|
26
31
|
for (;;) {
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
const left = Math.ceil(deadline - performance.now());
|
|
33
|
+
if (left <= 0 && last)
|
|
34
|
+
return last;
|
|
35
|
+
try {
|
|
36
|
+
last = await t.json({
|
|
37
|
+
method: "GET",
|
|
38
|
+
path: path(),
|
|
39
|
+
timeoutMs: Math.max(1, left),
|
|
40
|
+
...(input.signal ? { signal: input.signal } : {}),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
if (last && !input.signal?.aborted && error.code === "timeout")
|
|
45
|
+
return last;
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
if (!last.running || last.servers.every((server) => server.status !== "installing"))
|
|
49
|
+
return last;
|
|
50
|
+
const rest = deadline - performance.now();
|
|
51
|
+
if (rest <= 0)
|
|
52
|
+
return last;
|
|
53
|
+
await pause(Math.min(input.intervalMs ?? 2_000, rest), input.signal);
|
|
33
54
|
}
|
|
34
55
|
},
|
|
35
56
|
stop: (options) => t.json({ method: "DELETE", path: path(), ...options }),
|
|
@@ -193,7 +193,7 @@ export type SetUpstreamProxy = {
|
|
|
193
193
|
* `upstreamProxy`: after Runtime's own rules allow a connection, the host
|
|
194
194
|
* reaches it with CONNECT through your proxy, so your proxy's controls and
|
|
195
195
|
* logs apply. A proxy that refuses or cannot be reached fails the connection
|
|
196
|
-
* (upstream-proxy-failed); nothing goes around it.
|
|
196
|
+
* (upstream-proxy-failed); nothing goes around it. Needs a kept top-up. */
|
|
197
197
|
export declare function network(t: Transport): {
|
|
198
198
|
/** Your sandboxes reaching each other by name (`private-network.ts`). */
|
|
199
199
|
private: {
|
|
@@ -88,7 +88,7 @@ export function tunnel(t) {
|
|
|
88
88
|
* `upstreamProxy`: after Runtime's own rules allow a connection, the host
|
|
89
89
|
* reaches it with CONNECT through your proxy, so your proxy's controls and
|
|
90
90
|
* logs apply. A proxy that refuses or cannot be reached fails the connection
|
|
91
|
-
* (upstream-proxy-failed); nothing goes around it.
|
|
91
|
+
* (upstream-proxy-failed); nothing goes around it. Needs a kept top-up. */
|
|
92
92
|
export function network(t) {
|
|
93
93
|
const path = "/v1/network/upstream-proxy";
|
|
94
94
|
return {
|
|
@@ -24,7 +24,7 @@ export type NetworkPolicy = Required<NetworkRules> & {
|
|
|
24
24
|
/** Ports reachable without a connect entry. */
|
|
25
25
|
ports: number[];
|
|
26
26
|
connectAllowed: boolean;
|
|
27
|
-
/** paid, granted, not_paid, revoked, suspended, or trial (a
|
|
27
|
+
/** paid, granted, not_paid, revoked, suspended, or trial (a sandbox without credit reaches ports 80 and 443 only). */
|
|
28
28
|
connectReason: string;
|
|
29
29
|
forbiddenPorts: number[];
|
|
30
30
|
updatedAt: string | null;
|
|
@@ -35,7 +35,7 @@ export type SandboxMetrics = {
|
|
|
35
35
|
latest: MetricPoint | null;
|
|
36
36
|
points: MetricPoint[];
|
|
37
37
|
};
|
|
38
|
-
export type WebhookEventType = "sandbox.created" | "sandbox.running" | "sandbox.paused" | "sandbox.woken" | "sandbox.stopped" | "sandbox.start_failed" | "sandbox.wake_failed" | "snapshot.ready" | "snapshot.failed" | "snapshot.deleted" | "volume.ready" | "volume.failed" | "volume.deleted";
|
|
38
|
+
export type WebhookEventType = "sandbox.created" | "sandbox.running" | "sandbox.paused" | "sandbox.woken" | "sandbox.stopped" | "sandbox.start_failed" | "sandbox.wake_failed" | "sandbox.host_unreachable" | "sandbox.host_reachable" | "sandbox.recovered" | "sandbox.recovery_failed" | "snapshot.ready" | "snapshot.failed" | "snapshot.deleted" | "volume.ready" | "volume.failed" | "volume.deleted";
|
|
39
39
|
/** An event as /v1/events lists it and a webhook delivers it. */
|
|
40
40
|
export type RuntimeEvent = {
|
|
41
41
|
id: string;
|
|
@@ -4,7 +4,7 @@ export type PrivateNetwork = {
|
|
|
4
4
|
enabled: boolean;
|
|
5
5
|
/** `sandbox.internal`. */
|
|
6
6
|
suffix: string;
|
|
7
|
-
/** Whether this account may turn it on:
|
|
7
|
+
/** Whether this account may turn it on: it must have a kept top-up. */
|
|
8
8
|
allowed: boolean;
|
|
9
9
|
/** Why not, when `allowed` is false: `not_paid`, `revoked` or `suspended`. */
|
|
10
10
|
why: string | null;
|
|
@@ -4,7 +4,7 @@ import type { RequestOptions, Transport } from "../transport.js";
|
|
|
4
4
|
* absent) and `paths`, each exact (`/v1/chat/completions`) or a prefix ending
|
|
5
5
|
* in `/*` (`/repos/acme/*`), written canonically: starting with `/`, no `.` or
|
|
6
6
|
* `..` segments, no `;` or `\`, no encoded slash. A request whose path could be
|
|
7
|
-
* read two ways gets no secret that has rules.
|
|
7
|
+
* read two ways gets no secret that has rules. Needs credit on the account. */
|
|
8
8
|
export type SecretRule = {
|
|
9
9
|
methods?: string[];
|
|
10
10
|
paths: string[];
|
|
@@ -37,7 +37,7 @@ export type SetSecret = {
|
|
|
37
37
|
header?: string;
|
|
38
38
|
/** With `header`: its value, `{value}` where the secret goes. Default `{value}`. */
|
|
39
39
|
format?: string;
|
|
40
|
-
/** Only requests a rule allows carry the value.
|
|
40
|
+
/** Only requests a rule allows carry the value. Needs credit on the account. 1 to 16.
|
|
41
41
|
* Absent: every request to the hosts; replacing a secret without rules
|
|
42
42
|
* clears them. */
|
|
43
43
|
rules?: SecretRule[];
|
|
@@ -121,6 +121,6 @@ export declare function secrets(t: Transport): {
|
|
|
121
121
|
name: string;
|
|
122
122
|
deleted: true;
|
|
123
123
|
enforced: boolean;
|
|
124
|
-
from: ("
|
|
124
|
+
from: ("sandboxes" | "jobs")[];
|
|
125
125
|
}>;
|
|
126
126
|
};
|
|
@@ -52,14 +52,13 @@ export type UsageComparison = {
|
|
|
52
52
|
runSeconds: number;
|
|
53
53
|
activeCpuSeconds: number;
|
|
54
54
|
unpricedSandboxes: number;
|
|
55
|
-
/** Of `sandboxes`, how many
|
|
56
|
-
* time. The trial charged nothing for them; `runtimeMicros` prices them at
|
|
55
|
+
/** Of `sandboxes`, how many free usage paid for, and their running time. It charged nothing for them; `runtimeMicros` prices them at
|
|
57
56
|
* Runtime's standard rates, what the same work costs on paid credit. */
|
|
58
57
|
trialSandboxes: number;
|
|
59
58
|
trialRunSeconds: number;
|
|
60
59
|
};
|
|
61
60
|
/** What the usage costs on Runtime on paid credit: each paid sandbox at the
|
|
62
|
-
* rates it was quoted, a
|
|
61
|
+
* rates it was quoted, a sandbox free usage paid for at the standard rates. */
|
|
63
62
|
runtimeMicros: string;
|
|
64
63
|
rivalMicros: string;
|
|
65
64
|
/** Rival less Runtime: negative when the rival would cost less. */
|
package/dist/runloop/index.js
CHANGED
|
@@ -172,8 +172,12 @@ export class Devboxes {
|
|
|
172
172
|
vcpu: p.custom_cpu_cores ?? size?.[0],
|
|
173
173
|
memoryMiB: p.custom_gb_memory ? p.custom_gb_memory * 1024 : size?.[1],
|
|
174
174
|
diskMiB: p.custom_disk_size ? p.custom_disk_size * 1024 : size?.[2],
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
// keep_alive_time_seconds is the customer's limit, with no idle pause
|
|
176
|
+
// before it. None is no time limit (0300): it runs while it works and
|
|
177
|
+
// pauses when idle.
|
|
178
|
+
...(p.keep_alive_time_seconds === undefined || p.keep_alive_time_seconds === null
|
|
179
|
+
? {}
|
|
180
|
+
: { timeoutSeconds: p.keep_alive_time_seconds, idlePauseSeconds: 0 }),
|
|
177
181
|
onLeaseEnd: "stop",
|
|
178
182
|
}, input.environment_variables ?? undefined, async (sandbox) => {
|
|
179
183
|
for (const [path, content] of Object.entries(input.file_mounts ?? {})) {
|
package/dist/sandbox.d.ts
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
import { Page } from "./page.js";
|
|
1
|
+
import type { Page } from "./page.js";
|
|
2
2
|
import { type FileEvent, type WatchHandle, type WatchOptions } from "./products/watch.js";
|
|
3
3
|
import { Transport, type RequestOptions } from "./transport.js";
|
|
4
|
-
import type { CommandResult, DeletedSandbox, ExecOptions, FileEntry, OutputEvent, BinaryOutputEvent,
|
|
4
|
+
import type { CommandResult, DeletedSandbox, ExecOptions, FileEntry, OutputEvent, BinaryOutputEvent, ProcessInfo, SandboxInfo, SandboxSettings } from "./types.js";
|
|
5
5
|
import { type SandboxExtensions } from "./products/index.js";
|
|
6
|
-
import type { Snapshot, SnapshotOptions } from "./snapshots.js";
|
|
7
6
|
import { Tunnel, type PortForward } from "./tunnel.js";
|
|
8
7
|
import type { StreamUploadSource } from "./file-source.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export declare
|
|
8
|
+
import { Machine, type MachineProduct } from "./machine.js";
|
|
9
|
+
/** Sandboxes, as a product of the machine engine (machine.ts). */
|
|
10
|
+
export declare const SANDBOXES: MachineProduct;
|
|
12
11
|
/** A running (or stopped) sandbox. Every method is one API call or a short
|
|
13
12
|
* sequence of them; `await using sbx = await Sandbox.create()` stops it for
|
|
14
13
|
* you at the end of the block. */
|
|
15
14
|
export interface Sandbox extends SandboxExtensions {
|
|
16
15
|
}
|
|
17
|
-
export declare class Sandbox
|
|
16
|
+
export declare class Sandbox extends Machine<SandboxInfo, SandboxSettings, DeletedSandbox> {
|
|
18
17
|
#private;
|
|
19
18
|
readonly files: Files;
|
|
20
19
|
readonly processes: Processes;
|
|
21
20
|
/** Short-lived tokens that let a browser reach this sandbox directly. */
|
|
22
21
|
readonly sessions: SandboxSessions;
|
|
23
22
|
constructor(transport: Transport, info: SandboxInfo);
|
|
24
|
-
get id(): string;
|
|
25
23
|
/** A sandbox reached with a session token instead of an API key, for code in
|
|
26
24
|
* a browser: commands and their streams, processes, files and previews of
|
|
27
25
|
* this one sandbox. Makes no call; `info` holds only the id until
|
|
@@ -39,14 +37,6 @@ export declare class Sandbox implements AsyncDisposable {
|
|
|
39
37
|
apiUrl?: string;
|
|
40
38
|
fetch?: typeof fetch;
|
|
41
39
|
}): Sandbox;
|
|
42
|
-
/** What the API last said about this sandbox. `refresh()` asks again. */
|
|
43
|
-
get info(): SandboxInfo;
|
|
44
|
-
get state(): SandboxInfo["state"];
|
|
45
|
-
refresh(options?: RequestOptions): Promise<this>;
|
|
46
|
-
/** Waits (server-side, no polling) until the sandbox reaches `state`. */
|
|
47
|
-
waitFor(state: "running" | "paused" | "stopped", options?: {
|
|
48
|
-
timeoutSeconds?: number;
|
|
49
|
-
} & RequestOptions): Promise<this>;
|
|
50
40
|
/** Runs a command and returns its exit code and output. A string runs under
|
|
51
41
|
* `bash -c`; an array runs without a shell. With onStdout/onStderr the output
|
|
52
42
|
* streams as it happens. A timeout is a result (timedOut: true, the output so
|
|
@@ -94,68 +84,6 @@ export declare class Sandbox implements AsyncDisposable {
|
|
|
94
84
|
localPort?: number;
|
|
95
85
|
host?: string;
|
|
96
86
|
}): Promise<PortForward>;
|
|
97
|
-
stop(options?: RequestOptions & {
|
|
98
|
-
wait?: boolean;
|
|
99
|
-
}): Promise<this>;
|
|
100
|
-
pause(options?: RequestOptions & {
|
|
101
|
-
wait?: boolean;
|
|
102
|
-
}): Promise<this>;
|
|
103
|
-
/** Deletes it for good: stops it if it runs or is paused, deletes its disk
|
|
104
|
-
* and paused memory, revokes its previews and ports, and removes it from
|
|
105
|
-
* lists. Its snapshots, usage and audit entries stay. Deleting it again
|
|
106
|
-
* answers the same. */
|
|
107
|
-
delete(options?: RequestOptions): Promise<DeletedSandbox>;
|
|
108
|
-
/** Carries on a paused sandbox; `timeoutSeconds` is its new lease. */
|
|
109
|
-
wake(options?: RequestOptions & {
|
|
110
|
-
wait?: boolean;
|
|
111
|
-
timeoutSeconds?: number;
|
|
112
|
-
}): Promise<this>;
|
|
113
|
-
/** More time before the lease ends (at most an hour ahead of now). */
|
|
114
|
-
extend(seconds: number, options?: RequestOptions): Promise<this>;
|
|
115
|
-
/** Changes its name, labels, automatic wake, idle pause or persistence;
|
|
116
|
-
* fields left out stay as they are. `persistent: true` keeps it running
|
|
117
|
-
* while credit lasts (paid only). */
|
|
118
|
-
update(settings: SandboxSettings, options?: RequestOptions): Promise<this>;
|
|
119
|
-
/** Moves it to another image (id, name, name:tag or name@version), keeping
|
|
120
|
-
* its id, /workspace (its home: dotfiles, pip --user and npm -g installs),
|
|
121
|
-
* volumes, environment, name and previews. Its processes restart, and
|
|
122
|
-
* everything else on its old disk (sudo installs, apt packages, /etc) is
|
|
123
|
-
* lost, which `keep: "workspace"` says you know; snapshot it first to keep
|
|
124
|
-
* everything. A running sandbox is paused first. A switch that fails is
|
|
125
|
-
* undone (`switch_undone`), the sandbox on its old image with nothing lost.
|
|
126
|
-
* Charged as a wake. */
|
|
127
|
-
switchImage(image: string, options: RequestOptions & {
|
|
128
|
-
keep: "workspace";
|
|
129
|
-
}): Promise<this>;
|
|
130
|
-
/** Gives it more or fewer vCPUs or more or less memory by a restart: its id,
|
|
131
|
-
* whole disk, volumes, environment, name and previews stay, and its
|
|
132
|
-
* programs stop, which `restart: true` says you know (snapshot it first to
|
|
133
|
-
* keep its memory too). A running sandbox is paused, or stopped if it is
|
|
134
|
-
* persistent, and comes back running at the new size on the same server; a
|
|
135
|
-
* paused or stopped one is started. Memory bills on the new size from then.
|
|
136
|
-
* Refused, with nothing changed, when the server has no room
|
|
137
|
-
* (`no_capacity`), above your quota or the trial's 2 vCPU and 4 GiB, or
|
|
138
|
-
* while a snapshot or fork of it is being taken. */
|
|
139
|
-
resize(size: {
|
|
140
|
-
vcpu?: number;
|
|
141
|
-
memoryMiB?: number;
|
|
142
|
-
}, options: RequestOptions & {
|
|
143
|
-
restart: true;
|
|
144
|
-
}): Promise<this>;
|
|
145
|
-
/** Keeps a running sandbox's lease ahead of now, in the background, until
|
|
146
|
-
* stop() or the returned function ends it: every `everySeconds` (60) it
|
|
147
|
-
* extends the lease so that `marginSeconds` (600) remain, never more than
|
|
148
|
-
* the hour ahead the API allows. Running time is billed as it is used, as
|
|
149
|
-
* for any extension. A paused sandbox is left paused (a request wakes it,
|
|
150
|
-
* unless autoWake is off); a stopped one ends the loop. It does not keep a
|
|
151
|
-
* Node or Bun process alive by itself. */
|
|
152
|
-
keepAlive(options?: KeepAliveOptions): () => void;
|
|
153
|
-
/** Days a paused sandbox is kept before deletion (1 to 365). */
|
|
154
|
-
setRetention(days: number, options?: RequestOptions): Promise<this>;
|
|
155
|
-
/** Keeps this sandbox's whole machine (files, memory, running processes) as
|
|
156
|
-
* a snapshot to start new sandboxes from. A running sandbox is paused for
|
|
157
|
-
* the moment it takes, then woken; a paused one stays paused. */
|
|
158
|
-
snapshot(options?: SnapshotOptions & RequestOptions): Promise<Snapshot>;
|
|
159
87
|
/** Copies of this sandbox as it is now (files, memory, running processes),
|
|
160
88
|
* each its own sandbox, answered once they run. A running sandbox is paused
|
|
161
89
|
* for the moment its snapshot takes, then woken. One without `count`; an
|
|
@@ -174,12 +102,6 @@ export declare class Sandbox implements AsyncDisposable {
|
|
|
174
102
|
keepSnapshot?: boolean;
|
|
175
103
|
funding?: "trial" | "paid";
|
|
176
104
|
} & RequestOptions): Promise<Sandbox[]>;
|
|
177
|
-
/** Starts a stopped persistent sandbox again from its disk (memory is not kept). */
|
|
178
|
-
restart(options?: RequestOptions & {
|
|
179
|
-
wait?: boolean;
|
|
180
|
-
}): Promise<this>;
|
|
181
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
182
|
-
toJSON(): SandboxInfo;
|
|
183
105
|
}
|
|
184
106
|
/** A sandbox session, as the API answers it. `token` is set only in the
|
|
185
107
|
* answer to `create`. */
|
|
@@ -403,6 +325,7 @@ export declare class Files {
|
|
|
403
325
|
* the API's folder route. */
|
|
404
326
|
download(remotePath: string, localPath: string, options?: RequestOptions): Promise<void>;
|
|
405
327
|
}
|
|
328
|
+
/** One page of `runtime.sandboxes.list()`, and the pages after it. */
|
|
406
329
|
export declare function sandboxPage(t: Transport, body: {
|
|
407
330
|
data: SandboxInfo[];
|
|
408
331
|
nextCursor: string | null;
|