withruntime 0.8.4 → 0.10.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 +4 -4
- package/COMPATIBILITY.md +145 -0
- package/DAYTONA.md +13 -7
- package/E2B.md +34 -20
- package/README.md +22 -11
- package/README.src.md +22 -11
- package/VERCEL.md +13 -3
- package/compatibility-lock.json +357 -0
- package/dist/ai-harness/index.js +2 -2
- package/dist/api-defaults.d.ts +17 -0
- package/dist/api-defaults.js +22 -0
- package/dist/blaxel/errors.js +1 -1
- package/dist/blaxel/lookup.d.ts +3 -2
- package/dist/blaxel/lookup.js +3 -2
- package/dist/blaxel/pagination.d.ts +2 -2
- package/dist/blaxel/pagination.js +45 -17
- package/dist/blaxel/preview.d.ts +3 -2
- package/dist/blaxel/preview.js +16 -14
- package/dist/blaxel/process.d.ts +1 -1
- package/dist/blaxel/process.js +66 -11
- package/dist/blaxel/sandbox.d.ts +2 -0
- package/dist/blaxel/sandbox.js +2 -0
- package/dist/blaxel/snapshot.js +3 -5
- package/dist/cli-words.d.ts +27 -0
- package/dist/cli-words.js +135 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +351 -85
- package/dist/client.d.ts +33 -4
- package/dist/client.js +47 -12
- package/dist/cloudflare/identity.d.ts +7 -0
- package/dist/cloudflare/identity.js +13 -0
- package/dist/cloudflare/index.d.ts +303 -0
- package/dist/cloudflare/index.js +592 -0
- package/dist/cloudflare/worker.d.ts +419 -0
- package/dist/cloudflare/worker.js +447 -0
- package/dist/codesandbox/guest-service.d.ts +31 -0
- package/dist/codesandbox/guest-service.js +490 -0
- package/dist/codesandbox/index.d.ts +386 -0
- package/dist/codesandbox/index.js +1347 -0
- package/dist/compat/core.d.ts +40 -0
- package/dist/compat/core.js +238 -0
- package/dist/compat/files.d.ts +26 -0
- package/dist/compat/files.js +133 -0
- package/dist/compat/shell.d.ts +4 -0
- package/dist/compat/shell.js +165 -0
- package/dist/credentials.d.ts +6 -1
- package/dist/credentials.js +107 -38
- package/dist/daytona/context.js +2 -1
- package/dist/daytona/daytona.js +11 -4
- package/dist/daytona/filesystem.d.ts +17 -4
- package/dist/daytona/filesystem.js +121 -38
- package/dist/daytona/index.d.ts +1 -1
- package/dist/daytona/process.d.ts +1 -1
- package/dist/daytona/process.js +27 -4
- package/dist/daytona/sandbox.d.ts +1 -1
- package/dist/daytona/sandbox.js +16 -7
- package/dist/e2b/client.js +1 -1
- package/dist/e2b/code-interpreter.d.ts +4 -5
- package/dist/e2b/code-interpreter.js +54 -56
- package/dist/e2b/commands.d.ts +35 -12
- package/dist/e2b/commands.js +169 -73
- package/dist/e2b/errors.js +1 -1
- package/dist/e2b/filesystem.d.ts +8 -6
- package/dist/e2b/filesystem.js +127 -28
- package/dist/e2b/index.d.ts +1 -0
- package/dist/e2b/index.js +1 -0
- package/dist/e2b/pty.d.ts +24 -0
- package/dist/e2b/pty.js +80 -0
- package/dist/e2b/sandbox.d.ts +6 -4
- package/dist/e2b/sandbox.js +59 -25
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +15 -2
- package/dist/file-source.d.ts +16 -0
- package/dist/file-source.js +162 -0
- package/dist/freestyle/index.d.ts +309 -0
- package/dist/freestyle/index.js +343 -0
- package/dist/index.d.ts +3 -1
- package/dist/login.js +16 -10
- package/dist/mcp.js +2 -2
- package/dist/modal/index.d.ts +205 -0
- package/dist/modal/index.js +486 -0
- package/dist/network-cli.js +112 -44
- package/dist/openai-agents/index.js +18 -71
- package/dist/page.d.ts +1 -1
- package/dist/page.js +2 -2
- package/dist/products/audit.d.ts +3 -0
- package/dist/products/index.d.ts +14 -0
- package/dist/products/index.js +12 -0
- package/dist/products/interpreter.d.ts +11 -4
- package/dist/products/interpreter.js +33 -9
- package/dist/products/jobs.js +3 -2
- package/dist/products/limits.d.ts +10 -0
- package/dist/products/observability.d.ts +44 -0
- package/dist/products/observability.js +6 -0
- package/dist/products/previews.d.ts +18 -4
- package/dist/products/previews.js +14 -5
- package/dist/products/tailscale.d.ts +57 -0
- package/dist/products/tailscale.js +17 -0
- package/dist/products/volumes.d.ts +42 -0
- package/dist/products/volumes.js +36 -0
- package/dist/products/watch.d.ts +25 -4
- package/dist/products/watch.js +132 -18
- package/dist/proxy.js +3 -1
- package/dist/runloop/index.d.ts +326 -0
- package/dist/runloop/index.js +535 -0
- package/dist/runloop/pagination.d.ts +46 -0
- package/dist/runloop/pagination.js +82 -0
- package/dist/runloop/snapshots.d.ts +52 -0
- package/dist/runloop/snapshots.js +244 -0
- package/dist/sandbox.d.ts +76 -16
- package/dist/sandbox.js +696 -135
- package/dist/snapshots.d.ts +20 -5
- package/dist/snapshots.js +11 -1
- package/dist/sprites/index.d.ts +251 -0
- package/dist/sprites/index.js +588 -0
- package/dist/tar.d.ts +10 -1
- package/dist/tar.js +311 -35
- package/dist/tools/index.js +2 -1
- package/dist/transport.d.ts +23 -8
- package/dist/transport.js +247 -127
- package/dist/types.d.ts +52 -3
- package/dist/vercel/command.d.ts +1 -1
- package/dist/vercel/command.js +15 -3
- package/dist/vercel/errors.d.ts +2 -2
- package/dist/vercel/errors.js +19 -2
- package/dist/vercel/filesystem.d.ts +21 -18
- package/dist/vercel/filesystem.js +95 -48
- package/dist/vercel/sandbox.d.ts +8 -8
- package/dist/vercel/sandbox.js +159 -64
- package/dist/vercel/snapshot.d.ts +3 -2
- package/dist/vercel/snapshot.js +9 -5
- package/package.json +46 -3
package/dist/errors.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
/** Every failure the SDK raises. `code` is stable and machine-readable,
|
|
2
2
|
* `hint` says what to do next, and `requestId` is what to quote in a report
|
|
3
3
|
* (runtime.feedback.submit, `runtime feedback`, or support). */
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/** A product switched off on this deployment, or paused on purpose: the API
|
|
5
|
+
* answers these 503s in fixed words (`serverFault` "off" in
|
|
6
|
+
* packages/cloud/src/api/respond.ts) and retrying cannot change them.
|
|
7
|
+
* host_unavailable and busy pass, and are retried. */
|
|
8
|
+
export const DELIBERATE = new Set([
|
|
9
|
+
"unavailable",
|
|
10
|
+
"unsupported",
|
|
11
|
+
"fork_unavailable",
|
|
12
|
+
"previews_unavailable",
|
|
13
|
+
"network_unavailable",
|
|
14
|
+
"network_rules_unavailable",
|
|
15
|
+
"secrets_unavailable",
|
|
16
|
+
"identity_unavailable",
|
|
17
|
+
"env_unavailable",
|
|
18
|
+
]);
|
|
6
19
|
/** Refusals that pass on their own: a host frees room, a trial slot frees. */
|
|
7
20
|
const PASSING = new Set(["no_capacity", "trial_busy"]);
|
|
8
21
|
/** Refusals of a create that clear when a sandbox stops or pauses, or a host
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type StreamUploadSource = string | Blob | AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>;
|
|
2
|
+
export type UploadScope = {
|
|
3
|
+
signal?: AbortSignal;
|
|
4
|
+
check(): void;
|
|
5
|
+
wait<T>(pending: Promise<T>): Promise<T>;
|
|
6
|
+
};
|
|
7
|
+
export type PreparedFileSource = {
|
|
8
|
+
size: number;
|
|
9
|
+
sha256: string;
|
|
10
|
+
chunkAt(offset: number, length: number): Promise<Uint8Array>;
|
|
11
|
+
close(): Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
/** ARCHITECTURE.md section 10, Folders over HTTP: unknown-length inputs use
|
|
14
|
+
* bounded private disk staging; known files and Blobs remain repeatable inputs.
|
|
15
|
+
* Size and digest are established before the remote upload can begin. */
|
|
16
|
+
export declare function prepareFileSource(input: StreamUploadSource, scope: UploadScope): Promise<PreparedFileSource>;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { RuntimeError } from "./errors.js";
|
|
2
|
+
const CHUNK = 1_048_576;
|
|
3
|
+
function failure(message, code, cause) {
|
|
4
|
+
return new RuntimeError({ message, code, status: 0, ...(cause === undefined ? {} : { cause }) });
|
|
5
|
+
}
|
|
6
|
+
async function exact(handle, offset, length) {
|
|
7
|
+
const data = new Uint8Array(length);
|
|
8
|
+
let held = 0;
|
|
9
|
+
while (held < length) {
|
|
10
|
+
const read = await handle.read(data, held, length - held, offset + held);
|
|
11
|
+
if (read.bytesRead === 0)
|
|
12
|
+
throw failure("The local upload source changed or ended before its declared size.", "source_changed");
|
|
13
|
+
held += read.bytesRead;
|
|
14
|
+
}
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
/** ARCHITECTURE.md section 10, Folders over HTTP: unknown-length inputs use
|
|
18
|
+
* bounded private disk staging; known files and Blobs remain repeatable inputs.
|
|
19
|
+
* Size and digest are established before the remote upload can begin. */
|
|
20
|
+
export async function prepareFileSource(input, scope) {
|
|
21
|
+
const fs = await import("node:fs/promises");
|
|
22
|
+
const { createHash } = await import("node:crypto");
|
|
23
|
+
const { Readable } = await import("node:stream");
|
|
24
|
+
scope.check();
|
|
25
|
+
const hash = createHash("sha256");
|
|
26
|
+
let size = 0;
|
|
27
|
+
let handle;
|
|
28
|
+
let staging;
|
|
29
|
+
let iterator;
|
|
30
|
+
// What is used of a reader, so the code compiles against Node's stream types
|
|
31
|
+
// as well as the DOM's (packages/cloud compiles this file without DOM).
|
|
32
|
+
let reader;
|
|
33
|
+
const cleanup = async () => {
|
|
34
|
+
try {
|
|
35
|
+
await handle?.close();
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
if (staging)
|
|
39
|
+
await fs.rm(staging, { recursive: true, force: true });
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
try {
|
|
43
|
+
if (typeof input === "string") {
|
|
44
|
+
handle = await fs.open(input, "r");
|
|
45
|
+
const info = await handle.stat();
|
|
46
|
+
if (!info.isFile() || !Number.isSafeInteger(info.size))
|
|
47
|
+
throw failure("A streamed file upload requires a regular local file.", "invalid_upload_source");
|
|
48
|
+
size = info.size;
|
|
49
|
+
for (let offset = 0; offset < size; offset += CHUNK) {
|
|
50
|
+
scope.check();
|
|
51
|
+
hash.update(await scope.wait(exact(handle, offset, Math.min(CHUNK, size - offset))));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else if (input instanceof Blob) {
|
|
55
|
+
// Bun's types leave out Blob.slice when the DOM library is off, as it is
|
|
56
|
+
// where packages/cloud compiles this file; every runtime has it.
|
|
57
|
+
const blob = input;
|
|
58
|
+
size = blob.size;
|
|
59
|
+
for (let offset = 0; offset < size; offset += CHUNK) {
|
|
60
|
+
scope.check();
|
|
61
|
+
hash.update(new Uint8Array(await scope.wait(blob.slice(offset, offset + CHUNK).arrayBuffer())));
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
size,
|
|
65
|
+
sha256: hash.digest("hex"),
|
|
66
|
+
chunkAt: async (offset, length) => new Uint8Array(await blob.slice(offset, offset + length).arrayBuffer()),
|
|
67
|
+
close: async () => undefined,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
if (!input ||
|
|
72
|
+
(typeof input.getReader !== "function" &&
|
|
73
|
+
typeof input[Symbol.asyncIterator] !== "function"))
|
|
74
|
+
throw failure("A streamed upload requires a byte stream or local file.", "invalid_upload_source");
|
|
75
|
+
const { tmpdir } = await import("node:os");
|
|
76
|
+
const path = await import("node:path");
|
|
77
|
+
staging = await fs.mkdtemp(path.join(tmpdir(), "runtime-upload-"));
|
|
78
|
+
await fs.chmod(staging, 0o700);
|
|
79
|
+
handle = await fs.open(path.join(staging, "source"), "wx+", 0o600);
|
|
80
|
+
const space = await fs.statfs(staging, { bigint: true });
|
|
81
|
+
const available = space.bavail * space.bsize;
|
|
82
|
+
if ("getReader" in input)
|
|
83
|
+
reader = input.getReader();
|
|
84
|
+
else
|
|
85
|
+
iterator = input[Symbol.asyncIterator]();
|
|
86
|
+
for (;;) {
|
|
87
|
+
scope.check();
|
|
88
|
+
const next = await scope.wait(reader ? reader.read() : iterator.next());
|
|
89
|
+
if (next.done)
|
|
90
|
+
break;
|
|
91
|
+
if (!(next.value instanceof Uint8Array))
|
|
92
|
+
throw failure("A streamed upload must produce byte chunks.", "invalid_upload_source");
|
|
93
|
+
for (let offset = 0; offset < next.value.length; offset += CHUNK) {
|
|
94
|
+
scope.check();
|
|
95
|
+
const part = next.value.subarray(offset, offset + CHUNK);
|
|
96
|
+
if (!Number.isSafeInteger(size + part.length))
|
|
97
|
+
throw failure("The streamed upload exceeds the native file size range.", "upload_too_large");
|
|
98
|
+
if (BigInt(size + part.length) > available)
|
|
99
|
+
throw failure("There is not enough local temporary disk space to stage the streamed upload.", "local_disk_full");
|
|
100
|
+
let written = 0;
|
|
101
|
+
while (written < part.length) {
|
|
102
|
+
scope.check();
|
|
103
|
+
const result = await handle.write(part, written, part.length - written, size + written);
|
|
104
|
+
if (result.bytesWritten === 0)
|
|
105
|
+
throw failure("The local temporary file accepted no upload bytes.", "local_disk_full");
|
|
106
|
+
written += result.bytesWritten;
|
|
107
|
+
}
|
|
108
|
+
size += part.length;
|
|
109
|
+
hash.update(part);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
scope.check();
|
|
114
|
+
const owned = handle;
|
|
115
|
+
if (!owned)
|
|
116
|
+
throw failure("The local upload file did not open.", "invalid_upload_source");
|
|
117
|
+
return {
|
|
118
|
+
size,
|
|
119
|
+
sha256: hash.digest("hex"),
|
|
120
|
+
chunkAt: (offset, length) => exact(owned, offset, length),
|
|
121
|
+
close: cleanup,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
// Calling return/cancel can itself throw synchronously. Cleanup still owns
|
|
126
|
+
// the file and directory, and must preserve the original source failure.
|
|
127
|
+
let timer;
|
|
128
|
+
try {
|
|
129
|
+
// Node's pending next() must settle before iterator.return() can finish.
|
|
130
|
+
// Web readers own cancellation directly; arbitrary iterators may not.
|
|
131
|
+
if (input instanceof Readable)
|
|
132
|
+
input.destroy();
|
|
133
|
+
const closing = reader ? reader.cancel(scope.signal?.reason) : iterator?.return?.();
|
|
134
|
+
if (closing)
|
|
135
|
+
await Promise.race([
|
|
136
|
+
closing,
|
|
137
|
+
new Promise((resolve) => {
|
|
138
|
+
timer = setTimeout(resolve, 1000);
|
|
139
|
+
}),
|
|
140
|
+
]);
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
/* Preserve the caller's original failure. */
|
|
144
|
+
}
|
|
145
|
+
finally {
|
|
146
|
+
if (timer)
|
|
147
|
+
clearTimeout(timer);
|
|
148
|
+
await cleanup().catch(() => undefined);
|
|
149
|
+
}
|
|
150
|
+
if (error?.code === "ENOSPC")
|
|
151
|
+
throw failure("There is not enough local temporary disk space to stage the streamed upload.", "local_disk_full", error);
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
finally {
|
|
155
|
+
try {
|
|
156
|
+
reader?.releaseLock();
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
/* Cancellation may leave a pending caller-owned read. */
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import type { Runtime } from "../client.js";
|
|
2
|
+
import type { Sandbox } from "../sandbox.js";
|
|
3
|
+
import { CompatibilityError, type ClientOptions } from "../compat/core.js";
|
|
4
|
+
export { CompatibilityError };
|
|
5
|
+
export type VmState = "starting" | "running" | "pausing" | "paused" | "stopped";
|
|
6
|
+
export interface FirewallRule {
|
|
7
|
+
action: "allow";
|
|
8
|
+
source: Record<string, never>;
|
|
9
|
+
destination: {
|
|
10
|
+
public: true;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface CreateVmOptions {
|
|
14
|
+
snapshotId?: string | null;
|
|
15
|
+
slug?: string | null;
|
|
16
|
+
displayName?: string | null;
|
|
17
|
+
idleTimeoutSeconds?: number | null;
|
|
18
|
+
metadata?: Record<string, string>;
|
|
19
|
+
firewall: {
|
|
20
|
+
rules: FirewallRule[];
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface ExecOptions {
|
|
24
|
+
command: string;
|
|
25
|
+
linuxUser?: string;
|
|
26
|
+
timeoutMs?: number;
|
|
27
|
+
env?: Record<string, string>;
|
|
28
|
+
stdin?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare class Freestyle {
|
|
31
|
+
readonly vms: VmsNamespace;
|
|
32
|
+
constructor(options?: ClientOptions);
|
|
33
|
+
}
|
|
34
|
+
export declare class VmsNamespace {
|
|
35
|
+
private readonly runtime;
|
|
36
|
+
readonly snapshots: {
|
|
37
|
+
get: (id: string) => Promise<{
|
|
38
|
+
id: string;
|
|
39
|
+
sourceVmId: string;
|
|
40
|
+
slug: string | null;
|
|
41
|
+
displayName: string | null;
|
|
42
|
+
public: boolean;
|
|
43
|
+
createdAt: string;
|
|
44
|
+
updatedAt: string;
|
|
45
|
+
ttlSeconds: number;
|
|
46
|
+
}>;
|
|
47
|
+
delete: (id: string) => Promise<void>;
|
|
48
|
+
list: (options?: {
|
|
49
|
+
sourceVmId?: string;
|
|
50
|
+
limit?: number;
|
|
51
|
+
offset?: number;
|
|
52
|
+
}) => Promise<{
|
|
53
|
+
snapshots: {
|
|
54
|
+
id: string;
|
|
55
|
+
sourceVmId: string;
|
|
56
|
+
slug: string | null;
|
|
57
|
+
displayName: string | null;
|
|
58
|
+
public: boolean;
|
|
59
|
+
createdAt: string;
|
|
60
|
+
updatedAt: string;
|
|
61
|
+
ttlSeconds: number;
|
|
62
|
+
}[];
|
|
63
|
+
totalCount: number;
|
|
64
|
+
}>;
|
|
65
|
+
};
|
|
66
|
+
constructor(runtime: Runtime);
|
|
67
|
+
private resolveSnapshot;
|
|
68
|
+
create(options: CreateVmOptions): Promise<{
|
|
69
|
+
vm: Vm;
|
|
70
|
+
vmId: string;
|
|
71
|
+
data: {
|
|
72
|
+
id: string;
|
|
73
|
+
state: "paused" | "stopped" | "stopping" | "starting" | "running" | "pausing" | "resuming";
|
|
74
|
+
slug: string | null;
|
|
75
|
+
displayName: string | null;
|
|
76
|
+
resources: {
|
|
77
|
+
cpu: number;
|
|
78
|
+
memory: number;
|
|
79
|
+
storage: number;
|
|
80
|
+
};
|
|
81
|
+
metadata: {
|
|
82
|
+
[k: string]: string;
|
|
83
|
+
};
|
|
84
|
+
idleTimeoutSeconds: number | undefined;
|
|
85
|
+
vpcs: never[];
|
|
86
|
+
networks: never[];
|
|
87
|
+
createdAt: string;
|
|
88
|
+
updatedAt: string;
|
|
89
|
+
};
|
|
90
|
+
firewallRules: {
|
|
91
|
+
id: string;
|
|
92
|
+
source: {
|
|
93
|
+
vmId: string;
|
|
94
|
+
};
|
|
95
|
+
action: "allow";
|
|
96
|
+
destination: {
|
|
97
|
+
public: true;
|
|
98
|
+
};
|
|
99
|
+
}[];
|
|
100
|
+
tlsRules: never[];
|
|
101
|
+
}>;
|
|
102
|
+
ref(id: string): Vm;
|
|
103
|
+
get(id: string): Promise<{
|
|
104
|
+
id: string;
|
|
105
|
+
state: "paused" | "stopped" | "stopping" | "starting" | "running" | "pausing" | "resuming";
|
|
106
|
+
slug: string | null;
|
|
107
|
+
displayName: string | null;
|
|
108
|
+
resources: {
|
|
109
|
+
cpu: number;
|
|
110
|
+
memory: number;
|
|
111
|
+
storage: number;
|
|
112
|
+
};
|
|
113
|
+
metadata: {
|
|
114
|
+
[k: string]: string;
|
|
115
|
+
};
|
|
116
|
+
idleTimeoutSeconds: number | undefined;
|
|
117
|
+
vpcs: never[];
|
|
118
|
+
networks: never[];
|
|
119
|
+
createdAt: string;
|
|
120
|
+
updatedAt: string;
|
|
121
|
+
}>;
|
|
122
|
+
delete(id: string): Promise<void>;
|
|
123
|
+
list(options?: {
|
|
124
|
+
state?: string;
|
|
125
|
+
slug?: string;
|
|
126
|
+
metadata?: string;
|
|
127
|
+
limit?: number;
|
|
128
|
+
offset?: number;
|
|
129
|
+
}): Promise<{
|
|
130
|
+
vms: {
|
|
131
|
+
id: string;
|
|
132
|
+
state: "paused" | "stopped" | "stopping" | "starting" | "running" | "pausing" | "resuming";
|
|
133
|
+
slug: string | null;
|
|
134
|
+
displayName: string | null;
|
|
135
|
+
resources: {
|
|
136
|
+
cpu: number;
|
|
137
|
+
memory: number;
|
|
138
|
+
storage: number;
|
|
139
|
+
};
|
|
140
|
+
metadata: {
|
|
141
|
+
[k: string]: string;
|
|
142
|
+
};
|
|
143
|
+
idleTimeoutSeconds: number | undefined;
|
|
144
|
+
vpcs: never[];
|
|
145
|
+
networks: never[];
|
|
146
|
+
createdAt: string;
|
|
147
|
+
updatedAt: string;
|
|
148
|
+
}[];
|
|
149
|
+
totalCount: number;
|
|
150
|
+
runningCount: number;
|
|
151
|
+
startingCount: number;
|
|
152
|
+
pausingCount: number;
|
|
153
|
+
pausedCount: number;
|
|
154
|
+
stoppedCount: number;
|
|
155
|
+
}>;
|
|
156
|
+
}
|
|
157
|
+
export interface ReadFileOptions {
|
|
158
|
+
offset?: number;
|
|
159
|
+
length?: number;
|
|
160
|
+
signal?: AbortSignal;
|
|
161
|
+
}
|
|
162
|
+
export interface WriteFileOptions {
|
|
163
|
+
mode?: number;
|
|
164
|
+
signal?: AbortSignal;
|
|
165
|
+
chunkSize?: number;
|
|
166
|
+
maxAttempts?: number;
|
|
167
|
+
onProgress?: (progress: {
|
|
168
|
+
completedBytes: number;
|
|
169
|
+
totalBytes: number;
|
|
170
|
+
}) => void;
|
|
171
|
+
}
|
|
172
|
+
export declare class VmFilesystem {
|
|
173
|
+
private readonly get;
|
|
174
|
+
private readonly files;
|
|
175
|
+
constructor(get: () => Promise<Sandbox>);
|
|
176
|
+
readFile(path: string, options?: ReadFileOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
177
|
+
readTextFile(path: string, options?: ReadFileOptions): Promise<string>;
|
|
178
|
+
readFileStream(path: string, options?: ReadFileOptions): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
|
|
179
|
+
writeFile(path: string, content: string | Uint8Array | Blob, options?: WriteFileOptions): Promise<void>;
|
|
180
|
+
writeTextFile(path: string, content: string, options?: WriteFileOptions): Promise<void>;
|
|
181
|
+
mkdir(path: string): Promise<void>;
|
|
182
|
+
remove(path: string): Promise<void>;
|
|
183
|
+
exists(path: string): Promise<boolean>;
|
|
184
|
+
readDir(path: string): Promise<{
|
|
185
|
+
name: string;
|
|
186
|
+
kind: "file" | "directory" | "symlink" | "other";
|
|
187
|
+
}[]>;
|
|
188
|
+
stat(path: string): Promise<{
|
|
189
|
+
size: number;
|
|
190
|
+
isFile: boolean;
|
|
191
|
+
isDirectory: boolean;
|
|
192
|
+
isSymlink: boolean;
|
|
193
|
+
permissions: string;
|
|
194
|
+
owner: string;
|
|
195
|
+
group: string;
|
|
196
|
+
modified: string;
|
|
197
|
+
}>;
|
|
198
|
+
}
|
|
199
|
+
export declare class Vm {
|
|
200
|
+
private readonly runtime;
|
|
201
|
+
readonly id: string;
|
|
202
|
+
readonly fs: VmFilesystem;
|
|
203
|
+
constructor(runtime: Runtime, id: string);
|
|
204
|
+
data(): Promise<{
|
|
205
|
+
id: string;
|
|
206
|
+
state: "paused" | "stopped" | "stopping" | "starting" | "running" | "pausing" | "resuming";
|
|
207
|
+
slug: string | null;
|
|
208
|
+
displayName: string | null;
|
|
209
|
+
resources: {
|
|
210
|
+
cpu: number;
|
|
211
|
+
memory: number;
|
|
212
|
+
storage: number;
|
|
213
|
+
};
|
|
214
|
+
metadata: {
|
|
215
|
+
[k: string]: string;
|
|
216
|
+
};
|
|
217
|
+
idleTimeoutSeconds: number | undefined;
|
|
218
|
+
vpcs: never[];
|
|
219
|
+
networks: never[];
|
|
220
|
+
createdAt: string;
|
|
221
|
+
updatedAt: string;
|
|
222
|
+
}>;
|
|
223
|
+
start(): Promise<{
|
|
224
|
+
id: string;
|
|
225
|
+
state: "paused" | "stopped" | "stopping" | "starting" | "running" | "pausing" | "resuming";
|
|
226
|
+
slug: string | null;
|
|
227
|
+
displayName: string | null;
|
|
228
|
+
resources: {
|
|
229
|
+
cpu: number;
|
|
230
|
+
memory: number;
|
|
231
|
+
storage: number;
|
|
232
|
+
};
|
|
233
|
+
metadata: {
|
|
234
|
+
[k: string]: string;
|
|
235
|
+
};
|
|
236
|
+
idleTimeoutSeconds: number | undefined;
|
|
237
|
+
vpcs: never[];
|
|
238
|
+
networks: never[];
|
|
239
|
+
createdAt: string;
|
|
240
|
+
updatedAt: string;
|
|
241
|
+
}>;
|
|
242
|
+
pause(): Promise<{
|
|
243
|
+
id: string;
|
|
244
|
+
state: "paused" | "stopped" | "stopping" | "starting" | "running" | "pausing" | "resuming";
|
|
245
|
+
slug: string | null;
|
|
246
|
+
displayName: string | null;
|
|
247
|
+
resources: {
|
|
248
|
+
cpu: number;
|
|
249
|
+
memory: number;
|
|
250
|
+
storage: number;
|
|
251
|
+
};
|
|
252
|
+
metadata: {
|
|
253
|
+
[k: string]: string;
|
|
254
|
+
};
|
|
255
|
+
idleTimeoutSeconds: number | undefined;
|
|
256
|
+
vpcs: never[];
|
|
257
|
+
networks: never[];
|
|
258
|
+
createdAt: string;
|
|
259
|
+
updatedAt: string;
|
|
260
|
+
}>;
|
|
261
|
+
delete(): Promise<void>;
|
|
262
|
+
update(options: {
|
|
263
|
+
slug?: string;
|
|
264
|
+
displayName?: string;
|
|
265
|
+
idleTimeoutSeconds?: number;
|
|
266
|
+
metadata?: Record<string, string>;
|
|
267
|
+
}): Promise<{
|
|
268
|
+
id: string;
|
|
269
|
+
state: "paused" | "stopped" | "stopping" | "starting" | "running" | "pausing" | "resuming";
|
|
270
|
+
slug: string | null;
|
|
271
|
+
displayName: string | null;
|
|
272
|
+
resources: {
|
|
273
|
+
cpu: number;
|
|
274
|
+
memory: number;
|
|
275
|
+
storage: number;
|
|
276
|
+
};
|
|
277
|
+
metadata: {
|
|
278
|
+
[k: string]: string;
|
|
279
|
+
};
|
|
280
|
+
idleTimeoutSeconds: number | undefined;
|
|
281
|
+
vpcs: never[];
|
|
282
|
+
networks: never[];
|
|
283
|
+
createdAt: string;
|
|
284
|
+
updatedAt: string;
|
|
285
|
+
}>;
|
|
286
|
+
exec(options: string | ExecOptions): Promise<{
|
|
287
|
+
stdout: string;
|
|
288
|
+
stderr: string;
|
|
289
|
+
statusCode: number | null;
|
|
290
|
+
}>;
|
|
291
|
+
snapshot(options?: {
|
|
292
|
+
slug?: string;
|
|
293
|
+
displayName?: string;
|
|
294
|
+
ttlSeconds?: number;
|
|
295
|
+
}): Promise<{
|
|
296
|
+
snapshotId: string;
|
|
297
|
+
sourceVmId: string;
|
|
298
|
+
snapshot: {
|
|
299
|
+
id: string;
|
|
300
|
+
sourceVmId: string;
|
|
301
|
+
slug: string | null;
|
|
302
|
+
displayName: string | null;
|
|
303
|
+
public: boolean;
|
|
304
|
+
createdAt: string;
|
|
305
|
+
updatedAt: string;
|
|
306
|
+
ttlSeconds: number;
|
|
307
|
+
};
|
|
308
|
+
}>;
|
|
309
|
+
}
|