withruntime 0.7.2 → 0.8.1
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 +221 -0
- package/README.md +18 -0
- package/dist/blaxel/client.d.ts +48 -0
- package/dist/blaxel/client.js +58 -0
- package/dist/blaxel/context.d.ts +59 -0
- package/dist/blaxel/context.js +162 -0
- package/dist/blaxel/errors.d.ts +51 -0
- package/dist/blaxel/errors.js +171 -0
- package/dist/blaxel/filesystem.d.ts +147 -0
- package/dist/blaxel/filesystem.js +585 -0
- package/dist/blaxel/index.d.ts +280 -0
- package/dist/blaxel/index.js +332 -0
- package/dist/blaxel/interpreter.d.ts +74 -0
- package/dist/blaxel/interpreter.js +256 -0
- package/dist/blaxel/lookup.d.ts +37 -0
- package/dist/blaxel/lookup.js +82 -0
- package/dist/blaxel/pagination.d.ts +39 -0
- package/dist/blaxel/pagination.js +60 -0
- package/dist/blaxel/preview.d.ts +110 -0
- package/dist/blaxel/preview.js +228 -0
- package/dist/blaxel/process.d.ts +126 -0
- package/dist/blaxel/process.js +526 -0
- package/dist/blaxel/sandbox.d.ts +180 -0
- package/dist/blaxel/sandbox.js +781 -0
- package/dist/blaxel/snapshot.d.ts +119 -0
- package/dist/blaxel/snapshot.js +197 -0
- package/dist/blaxel/types.d.ts +145 -0
- package/dist/blaxel/types.js +60 -0
- package/dist/blaxel/unsupported.d.ts +22 -0
- package/dist/blaxel/unsupported.js +34 -0
- package/dist/cli.js +10 -7
- package/dist/products/switching.d.ts +2 -2
- package/dist/transport.d.ts +1 -1
- package/dist/transport.js +1 -1
- package/package.json +10 -2
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type { Runtime } from "../client.js";
|
|
2
|
+
import { type RuntimeCreate, type RuntimeOptions, type RuntimeSandbox } from "./client.js";
|
|
3
|
+
import { SandboxFileSystem } from "./filesystem.js";
|
|
4
|
+
import { type PaginatedList } from "./pagination.js";
|
|
5
|
+
import { SandboxPreviews } from "./preview.js";
|
|
6
|
+
import { SandboxProcess } from "./process.js";
|
|
7
|
+
import { SandboxSnapshotsResource, type Env, type SandboxForkResponse, type SandboxRestoreResponse, type SandboxSnapshot } from "./snapshot.js";
|
|
8
|
+
import { type Metadata, type Sandbox as SandboxModel, type SandboxCreateConfiguration, type SandboxLifecycle, type SandboxNetwork, type SandboxSpec, type SandboxUpdateMetadata, type SandboxUpdateNetwork, type SessionWithToken, type Status, type VolumeAttachment } from "./types.js";
|
|
9
|
+
import { type UnsupportedPart } from "./unsupported.js";
|
|
10
|
+
/** Blaxel's defaults (checked 27 September 2026). */
|
|
11
|
+
export declare const DEFAULT_IMAGE = "blaxel/base-image:latest";
|
|
12
|
+
export declare const DEFAULT_MEMORY = 4096;
|
|
13
|
+
/** Blaxel gives a sandbox one vCPU per 2048 MB of memory. */
|
|
14
|
+
export declare const MEMORY_PER_VCPU = 2048;
|
|
15
|
+
export type SandboxListQuery = {
|
|
16
|
+
showTerminated?: boolean;
|
|
17
|
+
cursor?: string;
|
|
18
|
+
limit?: number;
|
|
19
|
+
sort?: "createdAt:desc" | "createdAt:asc" | "name:asc" | "name:desc";
|
|
20
|
+
q?: string;
|
|
21
|
+
anchor?: "end";
|
|
22
|
+
status?: string;
|
|
23
|
+
externalId?: string;
|
|
24
|
+
};
|
|
25
|
+
export type SandboxForkOptions = {
|
|
26
|
+
targetType?: "sandbox" | "application";
|
|
27
|
+
port?: number;
|
|
28
|
+
traffic?: number;
|
|
29
|
+
customDomain?: string;
|
|
30
|
+
prefix?: string;
|
|
31
|
+
/** A snapshot's id or, of this sandbox's snapshots, its name. */
|
|
32
|
+
snapshotId?: string;
|
|
33
|
+
envs?: Env[];
|
|
34
|
+
};
|
|
35
|
+
export type SandboxArchiveOptions = {
|
|
36
|
+
wait?: boolean;
|
|
37
|
+
maxWait?: number;
|
|
38
|
+
interval?: number;
|
|
39
|
+
};
|
|
40
|
+
/** What a create asked for that no label keeps: shown by `spec` in the
|
|
41
|
+
* client that created the sandbox. */
|
|
42
|
+
type Asked = {
|
|
43
|
+
envs?: Record<string, string>;
|
|
44
|
+
network?: SandboxNetwork;
|
|
45
|
+
volumes?: VolumeAttachment[];
|
|
46
|
+
};
|
|
47
|
+
/** The labels a new sandbox carries: the caller's, and under `blaxel/` what
|
|
48
|
+
* Blaxel keeps and Runtime has no field for, so any client (the Python
|
|
49
|
+
* adapter too) reads the same `spec`. */
|
|
50
|
+
export declare function labelsFor(config: SandboxCreateConfiguration, image: string): Record<string, string>;
|
|
51
|
+
type Resolved = {
|
|
52
|
+
runtime: RuntimeSandbox;
|
|
53
|
+
client: Runtime;
|
|
54
|
+
asked?: Asked;
|
|
55
|
+
};
|
|
56
|
+
/** A duration as Blaxel writes it ("30m", "24h", "7d", "1w", "1h30m"). */
|
|
57
|
+
export declare function durationMs(value: string): number;
|
|
58
|
+
/** The lease and the paused retention that honour Blaxel's TTL, expiry and
|
|
59
|
+
* lifecycle: never deleted before Blaxel would delete it. A fixed deadline
|
|
60
|
+
* within the hour is a lease that ends the sandbox; any other deadline keeps
|
|
61
|
+
* a paused sandbox that many days, rounded up; none keeps it 365 days. */
|
|
62
|
+
export declare function lifetimeOf(asked: {
|
|
63
|
+
ttl?: string | null;
|
|
64
|
+
expires?: Date;
|
|
65
|
+
lifecycle?: SandboxLifecycle | null;
|
|
66
|
+
}): {
|
|
67
|
+
timeoutSeconds: number;
|
|
68
|
+
onLeaseEnd: "pause" | "stop";
|
|
69
|
+
days: number;
|
|
70
|
+
};
|
|
71
|
+
/** Blaxel's network settings as Runtime's rules: allowed and forbidden
|
|
72
|
+
* domains, from the network itself or from its proxy (Blaxel's current
|
|
73
|
+
* place for them). Anything else of the proxy is refused. */
|
|
74
|
+
export declare function networkRules(network: SandboxNetwork): NonNullable<RuntimeCreate["network"]>;
|
|
75
|
+
/** A Blaxel image `ns/name:tag` as the Runtime image name and tag it maps to
|
|
76
|
+
* (Runtime names allow no "/"): every "/" becomes "-" (`ns-name`), and the
|
|
77
|
+
* tag is `latest` when none is given. The Python adapter maps the same way. */
|
|
78
|
+
export declare function imageRef(image: string): {
|
|
79
|
+
name: string;
|
|
80
|
+
tag: string;
|
|
81
|
+
};
|
|
82
|
+
/** A sandbox with Blaxel's methods. `sandbox.withruntime` is the Runtime
|
|
83
|
+
* sandbox underneath, for anything Blaxel has no name for. */
|
|
84
|
+
export declare class SandboxInstance {
|
|
85
|
+
#private;
|
|
86
|
+
readonly fs: SandboxFileSystem;
|
|
87
|
+
readonly network: {
|
|
88
|
+
fetch: (port: number, path?: string, init?: RequestInit) => Promise<Response>;
|
|
89
|
+
};
|
|
90
|
+
readonly process: SandboxProcess;
|
|
91
|
+
readonly previews: SandboxPreviews;
|
|
92
|
+
readonly snapshots: SandboxSnapshotsResource;
|
|
93
|
+
readonly sessions: UnsupportedPart;
|
|
94
|
+
readonly schedules: UnsupportedPart;
|
|
95
|
+
readonly codegen: UnsupportedPart;
|
|
96
|
+
readonly system: UnsupportedPart;
|
|
97
|
+
readonly drives: UnsupportedPart;
|
|
98
|
+
/** Blaxel's HTTP/2 session; Runtime's SDK keeps its own connections. */
|
|
99
|
+
h2Session: null;
|
|
100
|
+
/** Use SandboxInstance.create, createIfNotExists or get. */
|
|
101
|
+
constructor(resolved: Resolved);
|
|
102
|
+
/** The Runtime sandbox underneath: metrics, network rules, desktop,
|
|
103
|
+
* terminals and the rest of Runtime's SDK. */
|
|
104
|
+
get withruntime(): RuntimeSandbox;
|
|
105
|
+
/** The sandbox's name, or its Runtime id when it was made without one. */
|
|
106
|
+
get name(): string;
|
|
107
|
+
get metadata(): Metadata;
|
|
108
|
+
/** From the sandbox's labels, so every client sees the same; the envs,
|
|
109
|
+
* network and volumes only in the client that created it. */
|
|
110
|
+
get spec(): SandboxSpec;
|
|
111
|
+
get status(): Status;
|
|
112
|
+
/** RUNNING, or STANDBY for a paused sandbox. */
|
|
113
|
+
get state(): "RUNNING" | "STANDBY" | undefined;
|
|
114
|
+
get events(): [];
|
|
115
|
+
get errors(): [];
|
|
116
|
+
get lastUsedAt(): string | undefined;
|
|
117
|
+
get h2Domain(): null;
|
|
118
|
+
/** Seconds until Runtime deletes the sandbox: the end of a lease that ends
|
|
119
|
+
* it, or of a paused one's retention; undefined while not yet known. */
|
|
120
|
+
get expiresIn(): number | undefined;
|
|
121
|
+
/** Creates a sandbox and answers once it runs. Blaxel's defaults: the base
|
|
122
|
+
* image (Runtime's stock image) and 4096 MB, with vCPUs at one per 2048 MB.
|
|
123
|
+
* Funding is left to Runtime: the free trial while the account has trial
|
|
124
|
+
* time, then prepaid credit. A name another live sandbox holds is refused
|
|
125
|
+
* with a 409, as in Blaxel. */
|
|
126
|
+
static create<T extends typeof SandboxInstance>(this: T, sandbox?: SandboxCreateConfiguration | SandboxModel, { createIfNotExist }?: {
|
|
127
|
+
safe?: boolean;
|
|
128
|
+
createIfNotExist?: boolean;
|
|
129
|
+
}): Promise<InstanceType<T>>;
|
|
130
|
+
/** The named sandbox, or a new one when no live sandbox has the name.
|
|
131
|
+
* Runtime settles a race between two callers: both get the same sandbox. */
|
|
132
|
+
static createIfNotExists<T extends typeof SandboxInstance>(this: T, sandbox: SandboxCreateConfiguration | SandboxModel): Promise<InstanceType<T>>;
|
|
133
|
+
/** The live sandbox with this name (or Runtime id). It is not woken: the
|
|
134
|
+
* next call wakes it. */
|
|
135
|
+
static get<T extends typeof SandboxInstance>(this: T, sandboxName: string, options?: RuntimeOptions): Promise<InstanceType<T>>;
|
|
136
|
+
/** The newest live sandbox created with this externalId. */
|
|
137
|
+
static getByExternalId<T extends typeof SandboxInstance>(this: T, externalId: string, options?: RuntimeOptions): Promise<InstanceType<T>>;
|
|
138
|
+
/** Live sandboxes, oldest first, a page at a time; `for await` walks them
|
|
139
|
+
* all. `externalId` narrows; `showTerminated` adds ended ones. */
|
|
140
|
+
static list<T extends typeof SandboxInstance>(this: T, query?: SandboxListQuery, options?: RuntimeOptions): Promise<PaginatedList<InstanceType<T>>>;
|
|
141
|
+
/** Deletes the sandbox: it ends at once, its files and memory with it. */
|
|
142
|
+
static delete(sandboxName: string, options?: RuntimeOptions): Promise<SandboxModel>;
|
|
143
|
+
delete(): Promise<SandboxModel>;
|
|
144
|
+
/** Replaces the labels (when given), the display name and the externalId. */
|
|
145
|
+
static updateMetadata(sandboxName: string, metadata: SandboxUpdateMetadata, options?: RuntimeOptions): Promise<SandboxInstance>;
|
|
146
|
+
/** A new TTL (null: none): how long a paused sandbox is kept follows it, as
|
|
147
|
+
* at create. A running lease is not shortened. */
|
|
148
|
+
static updateTtl(sandboxName: string, ttl: string | null, options?: RuntimeOptions): Promise<SandboxInstance>;
|
|
149
|
+
/** A new lifecycle (null: none), as updateTtl. */
|
|
150
|
+
static updateLifecycle(sandboxName: string, lifecycle: SandboxLifecycle | null, options?: RuntimeOptions): Promise<SandboxInstance>;
|
|
151
|
+
/** Replaces the sandbox's network rules. */
|
|
152
|
+
static updateNetwork(sandboxName: string, network: SandboxUpdateNetwork, options?: RuntimeOptions): Promise<SandboxInstance>;
|
|
153
|
+
/** Deprecated in Blaxel: a sandbox is ready when create answers. */
|
|
154
|
+
wait(_options?: {
|
|
155
|
+
maxWait?: number;
|
|
156
|
+
interval?: number;
|
|
157
|
+
}): Promise<this>;
|
|
158
|
+
/** Archives the sandbox: on Runtime it pauses, keeping its files and also
|
|
159
|
+
* its memory and processes. The next call, or unarchive, wakes it. */
|
|
160
|
+
static archive(sandboxName: string, options?: SandboxArchiveOptions & RuntimeOptions): Promise<SandboxInstance>;
|
|
161
|
+
archive(options?: SandboxArchiveOptions): Promise<this>;
|
|
162
|
+
static unarchive(sandboxName: string, options?: SandboxArchiveOptions & RuntimeOptions): Promise<SandboxInstance>;
|
|
163
|
+
unarchive(options?: SandboxArchiveOptions): Promise<this>;
|
|
164
|
+
/** A request to a port inside the sandbox, through a private preview of
|
|
165
|
+
* that port (made on first use, then reused) and its token. */
|
|
166
|
+
fetch(port: number, path?: string, init?: RequestInit): Promise<Response>;
|
|
167
|
+
/** Deprecated in Blaxel: sandbox.snapshots.create(name). */
|
|
168
|
+
snapshot(name?: string): Promise<SandboxSnapshot>;
|
|
169
|
+
/** Deprecated in Blaxel: sandbox.snapshots.list(). */
|
|
170
|
+
listSnapshots(): Promise<SandboxSnapshot[]>;
|
|
171
|
+
/** Deprecated in Blaxel: sandbox.snapshots.delete(name). */
|
|
172
|
+
deleteSnapshot(snapshotId: string): Promise<void>;
|
|
173
|
+
restore(snapshotId: string): Promise<SandboxRestoreResponse>;
|
|
174
|
+
/** A new sandbox named `targetName`: a copy of this one as it is now
|
|
175
|
+
* (files, memory and running processes), or started from a snapshot with
|
|
176
|
+
* `snapshotId`. `envs` are added over this sandbox's. */
|
|
177
|
+
fork(targetName: string, options?: SandboxForkOptions): Promise<SandboxForkResponse>;
|
|
178
|
+
static fromSession(_session: SessionWithToken): Promise<never>;
|
|
179
|
+
}
|
|
180
|
+
export {};
|