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
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Runloop, type DevboxAsyncExecutionDetailView, type DevboxCreateParams, type DevboxExecuteParams, type RequestOptions } from "./index.js";
|
|
2
|
+
export declare class RunloopError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
/** The high-level command handles share the low-level adapter's validation,
|
|
6
|
+
* cancellation and process input path; they never send a provider request. */
|
|
7
|
+
export declare class RunloopSDK {
|
|
8
|
+
readonly api: Runloop;
|
|
9
|
+
readonly devbox: {
|
|
10
|
+
fromId: (id: string) => Devbox;
|
|
11
|
+
create: (params?: DevboxCreateParams, request?: RequestOptions) => Promise<Devbox>;
|
|
12
|
+
};
|
|
13
|
+
constructor(options?: ConstructorParameters<typeof Runloop>[0]);
|
|
14
|
+
get secret(): never;
|
|
15
|
+
get storageObject(): never;
|
|
16
|
+
get axon(): never;
|
|
17
|
+
get gatewayConfig(): never;
|
|
18
|
+
get mcpConfig(): never;
|
|
19
|
+
get networkPolicy(): never;
|
|
20
|
+
}
|
|
21
|
+
export declare class Devbox {
|
|
22
|
+
private readonly client;
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly cmd: {
|
|
25
|
+
execAsync: (command: string, params?: Omit<DevboxExecuteParams, "command">, options?: RequestOptions) => Promise<Execution>;
|
|
26
|
+
exec: (command: string, params?: Omit<DevboxExecuteParams, "command">, options?: RequestOptions) => Promise<ExecutionResult>;
|
|
27
|
+
};
|
|
28
|
+
constructor(client: Runloop, id: string);
|
|
29
|
+
getInfo(options?: RequestOptions): Promise<{
|
|
30
|
+
id: string;
|
|
31
|
+
name: string | null;
|
|
32
|
+
metadata: {
|
|
33
|
+
[k: string]: string;
|
|
34
|
+
};
|
|
35
|
+
status: string;
|
|
36
|
+
create_time_ms: number;
|
|
37
|
+
end_time_ms: number | null;
|
|
38
|
+
capabilities: never[];
|
|
39
|
+
state_transitions: never[];
|
|
40
|
+
launch_parameters: {
|
|
41
|
+
custom_cpu_cores: number;
|
|
42
|
+
custom_gb_memory: number;
|
|
43
|
+
custom_disk_size: number;
|
|
44
|
+
keep_alive_time_seconds: number;
|
|
45
|
+
resource_size_request: "CUSTOM_SIZE";
|
|
46
|
+
};
|
|
47
|
+
}>;
|
|
48
|
+
shutdown(options?: RequestOptions): Promise<{
|
|
49
|
+
id: string;
|
|
50
|
+
name: string | null;
|
|
51
|
+
metadata: {
|
|
52
|
+
[k: string]: string;
|
|
53
|
+
};
|
|
54
|
+
status: string;
|
|
55
|
+
create_time_ms: number;
|
|
56
|
+
end_time_ms: number | null;
|
|
57
|
+
capabilities: never[];
|
|
58
|
+
state_transitions: never[];
|
|
59
|
+
launch_parameters: {
|
|
60
|
+
custom_cpu_cores: number;
|
|
61
|
+
custom_gb_memory: number;
|
|
62
|
+
custom_disk_size: number;
|
|
63
|
+
keep_alive_time_seconds: number;
|
|
64
|
+
resource_size_request: "CUSTOM_SIZE";
|
|
65
|
+
};
|
|
66
|
+
}>;
|
|
67
|
+
suspend(options?: RequestOptions): Promise<{
|
|
68
|
+
id: string;
|
|
69
|
+
name: string | null;
|
|
70
|
+
metadata: {
|
|
71
|
+
[k: string]: string;
|
|
72
|
+
};
|
|
73
|
+
status: string;
|
|
74
|
+
create_time_ms: number;
|
|
75
|
+
end_time_ms: number | null;
|
|
76
|
+
capabilities: never[];
|
|
77
|
+
state_transitions: never[];
|
|
78
|
+
launch_parameters: {
|
|
79
|
+
custom_cpu_cores: number;
|
|
80
|
+
custom_gb_memory: number;
|
|
81
|
+
custom_disk_size: number;
|
|
82
|
+
keep_alive_time_seconds: number;
|
|
83
|
+
resource_size_request: "CUSTOM_SIZE";
|
|
84
|
+
};
|
|
85
|
+
}>;
|
|
86
|
+
resume(options?: RequestOptions): Promise<{
|
|
87
|
+
id: string;
|
|
88
|
+
name: string | null;
|
|
89
|
+
metadata: {
|
|
90
|
+
[k: string]: string;
|
|
91
|
+
};
|
|
92
|
+
status: string;
|
|
93
|
+
create_time_ms: number;
|
|
94
|
+
end_time_ms: number | null;
|
|
95
|
+
capabilities: never[];
|
|
96
|
+
state_transitions: never[];
|
|
97
|
+
launch_parameters: {
|
|
98
|
+
custom_cpu_cores: number;
|
|
99
|
+
custom_gb_memory: number;
|
|
100
|
+
custom_disk_size: number;
|
|
101
|
+
keep_alive_time_seconds: number;
|
|
102
|
+
resource_size_request: "CUSTOM_SIZE";
|
|
103
|
+
};
|
|
104
|
+
}>;
|
|
105
|
+
}
|
|
106
|
+
export declare class Execution {
|
|
107
|
+
private readonly client;
|
|
108
|
+
readonly devboxId: string;
|
|
109
|
+
readonly executionId: string;
|
|
110
|
+
private readonly streamingPromise?;
|
|
111
|
+
constructor(client: Runloop, devboxId: string, executionId: string, _initialResult: DevboxAsyncExecutionDetailView, streamingPromise?: Promise<void> | undefined);
|
|
112
|
+
sendStdIn(input: string, options?: RequestOptions): Promise<void>;
|
|
113
|
+
closeStdIn(options?: RequestOptions): Promise<void>;
|
|
114
|
+
private input;
|
|
115
|
+
getState(options?: RequestOptions): Promise<DevboxAsyncExecutionDetailView>;
|
|
116
|
+
kill(options?: RequestOptions): Promise<void>;
|
|
117
|
+
result(options?: RequestOptions): Promise<ExecutionResult>;
|
|
118
|
+
}
|
|
119
|
+
export declare class ExecutionResult {
|
|
120
|
+
private readonly client;
|
|
121
|
+
private readonly devboxId;
|
|
122
|
+
readonly executionId: string;
|
|
123
|
+
readonly result: DevboxAsyncExecutionDetailView;
|
|
124
|
+
constructor(client: Runloop, devboxId: string, executionId: string, result: DevboxAsyncExecutionDetailView);
|
|
125
|
+
get exitCode(): number | null;
|
|
126
|
+
get success(): boolean;
|
|
127
|
+
get failed(): boolean;
|
|
128
|
+
stdout(numLines?: number): Promise<string>;
|
|
129
|
+
stderr(numLines?: number): Promise<string>;
|
|
130
|
+
private output;
|
|
131
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { Runloop, } from "./index.js";
|
|
2
|
+
import { only } from "../compat/core.js";
|
|
3
|
+
export class RunloopError extends Error {
|
|
4
|
+
constructor(message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = "RunloopError";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/** The high-level command handles share the low-level adapter's validation,
|
|
10
|
+
* cancellation and process input path; they never send a provider request. */
|
|
11
|
+
export class RunloopSDK {
|
|
12
|
+
api;
|
|
13
|
+
devbox;
|
|
14
|
+
constructor(options = {}) {
|
|
15
|
+
this.api = new Runloop(options);
|
|
16
|
+
this.devbox = {
|
|
17
|
+
fromId: (id) => new Devbox(this.api, id),
|
|
18
|
+
create: async (params = {}, request) => {
|
|
19
|
+
const info = await this.api.devboxes.createAndAwaitRunning(params, request);
|
|
20
|
+
return new Devbox(this.api, info.id);
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
get secret() {
|
|
25
|
+
return this.api.secrets;
|
|
26
|
+
}
|
|
27
|
+
get storageObject() {
|
|
28
|
+
return this.api.objects;
|
|
29
|
+
}
|
|
30
|
+
get axon() {
|
|
31
|
+
return this.api.axons;
|
|
32
|
+
}
|
|
33
|
+
get gatewayConfig() {
|
|
34
|
+
return this.api.gatewayConfigs;
|
|
35
|
+
}
|
|
36
|
+
get mcpConfig() {
|
|
37
|
+
return this.api.mcpConfigs;
|
|
38
|
+
}
|
|
39
|
+
get networkPolicy() {
|
|
40
|
+
return this.api.networkPolicies;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export class Devbox {
|
|
44
|
+
client;
|
|
45
|
+
id;
|
|
46
|
+
cmd;
|
|
47
|
+
constructor(client, id) {
|
|
48
|
+
this.client = client;
|
|
49
|
+
this.id = id;
|
|
50
|
+
const start = async (command, params = {}, options) => {
|
|
51
|
+
only("Runloop command; use devboxes.executions streams for output callbacks", params, [
|
|
52
|
+
"shell_name",
|
|
53
|
+
"attach_stdin",
|
|
54
|
+
]);
|
|
55
|
+
const initial = await client.devboxes.executeAsync(id, { command, ...params }, options);
|
|
56
|
+
return new Execution(client, id, initial.execution_id, initial);
|
|
57
|
+
};
|
|
58
|
+
this.cmd = {
|
|
59
|
+
execAsync: start,
|
|
60
|
+
exec: async (command, params = {}, options) => {
|
|
61
|
+
if (params.attach_stdin)
|
|
62
|
+
throw new TypeError("attach_stdin requires cmd.execAsync");
|
|
63
|
+
return (await start(command, params, options)).result(options);
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
getInfo(options) {
|
|
68
|
+
return this.client.devboxes.retrieve(this.id, options);
|
|
69
|
+
}
|
|
70
|
+
shutdown(options) {
|
|
71
|
+
return this.client.devboxes.shutdown(this.id, {}, options);
|
|
72
|
+
}
|
|
73
|
+
suspend(options) {
|
|
74
|
+
return this.client.devboxes.suspend(this.id, options);
|
|
75
|
+
}
|
|
76
|
+
resume(options) {
|
|
77
|
+
return this.client.devboxes.resume(this.id, options);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export class Execution {
|
|
81
|
+
client;
|
|
82
|
+
devboxId;
|
|
83
|
+
executionId;
|
|
84
|
+
streamingPromise;
|
|
85
|
+
constructor(client, devboxId, executionId, _initialResult, streamingPromise) {
|
|
86
|
+
this.client = client;
|
|
87
|
+
this.devboxId = devboxId;
|
|
88
|
+
this.executionId = executionId;
|
|
89
|
+
this.streamingPromise = streamingPromise;
|
|
90
|
+
}
|
|
91
|
+
async sendStdIn(input, options) {
|
|
92
|
+
await this.input({ text: input }, options);
|
|
93
|
+
}
|
|
94
|
+
async closeStdIn(options) {
|
|
95
|
+
await this.input({ signal: "EOF" }, options);
|
|
96
|
+
}
|
|
97
|
+
async input(body, options) {
|
|
98
|
+
const response = await this.client.devboxes.executions.sendStdIn(this.devboxId, this.executionId, body, options);
|
|
99
|
+
if (!response.success)
|
|
100
|
+
throw new RunloopError(`Failed to send stdin to execution ${this.executionId}`);
|
|
101
|
+
}
|
|
102
|
+
getState(options) {
|
|
103
|
+
return this.client.devboxes.executions.retrieve(this.devboxId, this.executionId, {}, options);
|
|
104
|
+
}
|
|
105
|
+
async kill(options) {
|
|
106
|
+
await this.client.devboxes.executions.kill(this.devboxId, this.executionId, {}, options);
|
|
107
|
+
}
|
|
108
|
+
async result(options = {}) {
|
|
109
|
+
only("Runloop execution result; use Runtime process waits for other wait options", options, [
|
|
110
|
+
"signal",
|
|
111
|
+
"timeout",
|
|
112
|
+
"idempotencyKey",
|
|
113
|
+
]);
|
|
114
|
+
const [command] = await Promise.allSettled([
|
|
115
|
+
this.client.devboxes.executions.awaitCompleted(this.devboxId, this.executionId, options),
|
|
116
|
+
this.streamingPromise,
|
|
117
|
+
]);
|
|
118
|
+
if (command.status === "rejected")
|
|
119
|
+
throw command.reason;
|
|
120
|
+
return new ExecutionResult(this.client, this.devboxId, this.executionId, command.value);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export class ExecutionResult {
|
|
124
|
+
client;
|
|
125
|
+
devboxId;
|
|
126
|
+
executionId;
|
|
127
|
+
result;
|
|
128
|
+
constructor(client, devboxId, executionId, result) {
|
|
129
|
+
this.client = client;
|
|
130
|
+
this.devboxId = devboxId;
|
|
131
|
+
this.executionId = executionId;
|
|
132
|
+
this.result = result;
|
|
133
|
+
}
|
|
134
|
+
get exitCode() {
|
|
135
|
+
return this.result.exit_status ?? null;
|
|
136
|
+
}
|
|
137
|
+
get success() {
|
|
138
|
+
return this.exitCode === 0;
|
|
139
|
+
}
|
|
140
|
+
get failed() {
|
|
141
|
+
return this.exitCode !== null && this.exitCode !== 0;
|
|
142
|
+
}
|
|
143
|
+
stdout(numLines) {
|
|
144
|
+
return this.output("stdout", numLines);
|
|
145
|
+
}
|
|
146
|
+
stderr(numLines) {
|
|
147
|
+
return this.output("stderr", numLines);
|
|
148
|
+
}
|
|
149
|
+
async output(channel, numLines) {
|
|
150
|
+
let output = this.result[channel] ?? "";
|
|
151
|
+
if (this.result[`${channel}_truncated`] &&
|
|
152
|
+
(numLines === undefined || output.split("\n").filter(Boolean).length < numLines)) {
|
|
153
|
+
output = "";
|
|
154
|
+
const executions = this.client.devboxes.executions;
|
|
155
|
+
const stream = channel === "stdout"
|
|
156
|
+
? executions.streamStdoutUpdates(this.devboxId, this.executionId)
|
|
157
|
+
: executions.streamStderrUpdates(this.devboxId, this.executionId);
|
|
158
|
+
for await (const chunk of stream)
|
|
159
|
+
output += chunk.output;
|
|
160
|
+
}
|
|
161
|
+
if (numLines === undefined)
|
|
162
|
+
return output;
|
|
163
|
+
if (numLines <= 0)
|
|
164
|
+
return "";
|
|
165
|
+
return output.replace(/\n+$/, "").split("\n").slice(-numLines).join("\n");
|
|
166
|
+
}
|
|
167
|
+
}
|
package/dist/sandbox.d.ts
CHANGED
|
@@ -9,8 +9,9 @@ import { Machine, type MachineProduct } from "./machine.js";
|
|
|
9
9
|
/** Sandboxes, as a product of the machine engine (machine.ts). */
|
|
10
10
|
export declare const SANDBOXES: MachineProduct;
|
|
11
11
|
/** A running (or stopped) sandbox. Every method is one API call or a short
|
|
12
|
-
* sequence of them; `await using sbx = await Sandbox.create()`
|
|
13
|
-
*
|
|
12
|
+
* sequence of them; `await using sbx = await Sandbox.create()` deletes it at
|
|
13
|
+
* the end of the block, or stops it, keeping its disk, if created with
|
|
14
|
+
* `keep: true`. */
|
|
14
15
|
export interface Sandbox extends SandboxExtensions {
|
|
15
16
|
}
|
|
16
17
|
export declare class Sandbox extends Machine<SandboxInfo, SandboxSettings, DeletedSandbox> {
|
package/dist/sandbox.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { STREAMED_EXEC_TIMEOUT_MS } from "./api-defaults.js";
|
|
2
2
|
import { CommandError, ConnectionError, DELIBERATE, errorFor, NotFoundError, RateLimitError, RuntimeError, ServiceUnavailableError, } from "./errors.js";
|
|
3
3
|
import { sandboxWatches, watchDirectory, } from "./products/watch.js";
|
|
4
|
-
import { Transport } from "./transport.js";
|
|
4
|
+
import { Transport, timeoutSignal } from "./transport.js";
|
|
5
5
|
import { sandboxFactories } from "./products/index.js";
|
|
6
6
|
import { Tunnel } from "./tunnel.js";
|
|
7
7
|
import { pause } from "./wait.js";
|
|
@@ -20,7 +20,7 @@ const enc = (id) => encodeURIComponent(id);
|
|
|
20
20
|
function requestScope(options) {
|
|
21
21
|
const deadline = options.timeoutMs === undefined || options.timeoutMs === 0
|
|
22
22
|
? undefined
|
|
23
|
-
:
|
|
23
|
+
: timeoutSignal(options.timeoutMs);
|
|
24
24
|
const signal = deadline && options.signal
|
|
25
25
|
? AbortSignal.any([deadline, options.signal])
|
|
26
26
|
: (deadline ?? options.signal);
|
|
@@ -171,6 +171,7 @@ export class Sandbox extends Machine {
|
|
|
171
171
|
...truncation(dropped),
|
|
172
172
|
...(exit?.durationMs === undefined ? {} : { durationMs: exit.durationMs }),
|
|
173
173
|
...(processId ? { processId } : {}),
|
|
174
|
+
...(exit?.outOfMemory ? { outOfMemory: exit.outOfMemory } : {}),
|
|
174
175
|
};
|
|
175
176
|
}
|
|
176
177
|
if (options.check && (result.exitCode !== 0 || result.timedOut))
|
|
@@ -196,8 +197,8 @@ export class Sandbox extends Machine {
|
|
|
196
197
|
code: "cancelled",
|
|
197
198
|
status: 0,
|
|
198
199
|
hint: stopped
|
|
199
|
-
? `See what it printed: runtime
|
|
200
|
-
: `Stop it: runtime
|
|
200
|
+
? `See what it printed: runtime sandboxes logs ${id}`
|
|
201
|
+
: `Stop it: runtime sandboxes kill ${id}, or sandbox.processes.get("${processId}") and kill().`,
|
|
201
202
|
details: { sandboxId: this.id, processId, stopped },
|
|
202
203
|
cause: error,
|
|
203
204
|
});
|
|
@@ -208,7 +209,7 @@ export class Sandbox extends Machine {
|
|
|
208
209
|
message: `Lost the output of process ${processId}; the command may still be running.`,
|
|
209
210
|
code: "connection_error",
|
|
210
211
|
status: 0,
|
|
211
|
-
hint: `Follow it: runtime
|
|
212
|
+
hint: `Follow it: runtime sandboxes logs ${id} -f (sandbox.processes.get("${processId}")), or stop it: runtime sandboxes kill ${id}.`,
|
|
212
213
|
details: { sandboxId: this.id, processId },
|
|
213
214
|
cause: error,
|
|
214
215
|
});
|
|
@@ -544,7 +545,7 @@ export class Processes {
|
|
|
544
545
|
message: `Lost the output stream of process ${processId} for ${FOLLOW_OUTAGE_MS / 60_000} minutes; the command may still be running.`,
|
|
545
546
|
code: "connection_error",
|
|
546
547
|
status: 0,
|
|
547
|
-
hint: `Follow it again: runtime
|
|
548
|
+
hint: `Follow it again: runtime sandboxes logs ${this.sandboxId} ${processId} -f`,
|
|
548
549
|
details: { sandboxId: this.sandboxId, processId },
|
|
549
550
|
cause: failure,
|
|
550
551
|
});
|
|
@@ -555,7 +556,7 @@ export class Processes {
|
|
|
555
556
|
message: `The output stream of process ${processId} keeps closing before it ends.`,
|
|
556
557
|
code: "connection_error",
|
|
557
558
|
status: 0,
|
|
558
|
-
hint: `Read what it printed so far: runtime
|
|
559
|
+
hint: `Read what it printed so far: runtime sandboxes logs ${this.sandboxId} ${processId}`,
|
|
559
560
|
details: { sandboxId: this.sandboxId, processId },
|
|
560
561
|
});
|
|
561
562
|
}
|
|
@@ -647,6 +648,7 @@ export class Process {
|
|
|
647
648
|
...this.info,
|
|
648
649
|
state: exit.state,
|
|
649
650
|
exitCode: exit.exitCode,
|
|
651
|
+
...(exit.outOfMemory ? { outOfMemory: exit.outOfMemory } : {}),
|
|
650
652
|
};
|
|
651
653
|
return {
|
|
652
654
|
exitCode: exit?.exitCode ?? null,
|
|
@@ -654,6 +656,7 @@ export class Process {
|
|
|
654
656
|
timedOut: exit?.timedOut ?? false,
|
|
655
657
|
...truncation(dropped),
|
|
656
658
|
processId: this.id,
|
|
659
|
+
...(exit?.outOfMemory ? { outOfMemory: exit.outOfMemory } : {}),
|
|
657
660
|
};
|
|
658
661
|
}
|
|
659
662
|
/** Sends input. Offsets protect transport retries; signal and timeoutMs cover
|
|
@@ -1268,9 +1271,11 @@ export class Files {
|
|
|
1268
1271
|
const data = await readFile(localPath);
|
|
1269
1272
|
const mode = info.mode & 0o777;
|
|
1270
1273
|
await this.write(remotePath, data, { mode }).catch(async (error) => {
|
|
1271
|
-
//
|
|
1274
|
+
// Make a missing parent, but keep errors about the sandbox or upload.
|
|
1272
1275
|
const parent = remotePath.slice(0, remotePath.lastIndexOf("/"));
|
|
1273
|
-
if (!(error instanceof NotFoundError) ||
|
|
1276
|
+
if (!(error instanceof NotFoundError) ||
|
|
1277
|
+
(error.code !== "file_not_found" && error.code !== "path_not_found") ||
|
|
1278
|
+
!parent)
|
|
1274
1279
|
throw error;
|
|
1275
1280
|
await this.mkdir(parent, { parents: true });
|
|
1276
1281
|
await this.write(remotePath, data, { mode });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** `withruntime/sandboxes`: Sandboxes alone. Linux microVMs: create, find and list sandboxes.
|
|
2
|
+
*
|
|
3
|
+
* import { sandboxes } from "withruntime/sandboxes";
|
|
4
|
+
* const client = sandboxes(); // RUNTIME_API_KEY, or this machine's saved connection
|
|
5
|
+
*/
|
|
6
|
+
import { Runtime, type RuntimeOptions } from "../client.js";
|
|
7
|
+
export { Sandbox } from "../index.js";
|
|
8
|
+
export { Sandboxes } from "../client.js";
|
|
9
|
+
export type * from "../types.js";
|
|
10
|
+
/** `runtime.sandboxes` of a client made with `options`. */
|
|
11
|
+
export declare function sandboxes(options?: RuntimeOptions): Runtime["sandboxes"];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** `withruntime/sandboxes`: Sandboxes alone. Linux microVMs: create, find and list sandboxes.
|
|
2
|
+
*
|
|
3
|
+
* import { sandboxes } from "withruntime/sandboxes";
|
|
4
|
+
* const client = sandboxes(); // RUNTIME_API_KEY, or this machine's saved connection
|
|
5
|
+
*/
|
|
6
|
+
import { Runtime } from "../client.js";
|
|
7
|
+
export { Sandbox } from "../index.js";
|
|
8
|
+
export { Sandboxes } from "../client.js";
|
|
9
|
+
/** `runtime.sandboxes` of a client made with `options`. */
|
|
10
|
+
export function sandboxes(options) {
|
|
11
|
+
return new Runtime(options).sandboxes;
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** `withruntime/snapshots`: Snapshots alone. Saved sandboxes, disk and memory, to start or fork from.
|
|
2
|
+
*
|
|
3
|
+
* import { snapshots } from "withruntime/snapshots";
|
|
4
|
+
* const client = snapshots(); // RUNTIME_API_KEY, or this machine's saved connection
|
|
5
|
+
*/
|
|
6
|
+
import { Runtime, type RuntimeOptions } from "../client.js";
|
|
7
|
+
export { Snapshots, type Snapshot, type SnapshotOptions } from "../snapshots.js";
|
|
8
|
+
/** `runtime.snapshots` of a client made with `options`. */
|
|
9
|
+
export declare function snapshots(options?: RuntimeOptions): Runtime["snapshots"];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** `withruntime/snapshots`: Snapshots alone. Saved sandboxes, disk and memory, to start or fork from.
|
|
2
|
+
*
|
|
3
|
+
* import { snapshots } from "withruntime/snapshots";
|
|
4
|
+
* const client = snapshots(); // RUNTIME_API_KEY, or this machine's saved connection
|
|
5
|
+
*/
|
|
6
|
+
import { Runtime } from "../client.js";
|
|
7
|
+
export { Snapshots } from "../snapshots.js";
|
|
8
|
+
/** `runtime.snapshots` of a client made with `options`. */
|
|
9
|
+
export function snapshots(options) {
|
|
10
|
+
return new Runtime(options).snapshots;
|
|
11
|
+
}
|
package/dist/snapshots.d.ts
CHANGED
|
@@ -17,7 +17,8 @@ export type Snapshot = {
|
|
|
17
17
|
diskMiB: number;
|
|
18
18
|
memoryGuarantee: string;
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
/** Null: kept while your account has credit, up to a year from when it was taken. */
|
|
21
|
+
retentionDays: number | null;
|
|
21
22
|
/** True while raw fork memory awaits verified compression. The snapshot
|
|
22
23
|
* remains ready for starts on its current host, with no storage charge or
|
|
23
24
|
* off-host copy until final publication. Absent on older servers. */
|
|
@@ -39,7 +40,8 @@ export type Snapshot = {
|
|
|
39
40
|
error: string | null;
|
|
40
41
|
createdAt: string;
|
|
41
42
|
readyAt: string | null;
|
|
42
|
-
|
|
43
|
+
/** Null while it is kept as long as your account has credit. */
|
|
44
|
+
expiresAt: string | null;
|
|
43
45
|
[key: string]: unknown;
|
|
44
46
|
};
|
|
45
47
|
export type SnapshotOptions = {
|
|
@@ -47,7 +49,8 @@ export type SnapshotOptions = {
|
|
|
47
49
|
mode?: "memory" | "disk";
|
|
48
50
|
name?: string;
|
|
49
51
|
labels?: Record<string, string>;
|
|
50
|
-
|
|
52
|
+
/** Days, or null to keep it while your account has credit. */
|
|
53
|
+
retentionDays?: number | null;
|
|
51
54
|
};
|
|
52
55
|
/** `runtime.snapshots`. Take one with `sbx.snapshot()`, start from one with
|
|
53
56
|
* `runtime.sandboxes.create({ snapshot: id })`, or do both with `sbx.fork()`. */
|
|
@@ -71,5 +74,5 @@ export declare class Snapshots {
|
|
|
71
74
|
ifLabels?: Record<string, string>;
|
|
72
75
|
}, options?: RequestOptions): Promise<Snapshot>;
|
|
73
76
|
delete(id: string, options?: RequestOptions): Promise<void>;
|
|
74
|
-
extend(id: string, retentionDays: number, options?: RequestOptions): Promise<Snapshot>;
|
|
77
|
+
extend(id: string, retentionDays: number | null, options?: RequestOptions): Promise<Snapshot>;
|
|
75
78
|
}
|