sandboxedjs 0.1.48 → 0.1.50
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/dist/agent.d.cts +2 -1
- package/dist/agent.d.ts +2 -1
- package/dist/{container-DyRF-bY0.d.cts → container-DBMPLbUu.d.ts} +103 -410
- package/dist/{container-DyRF-bY0.d.ts → container-Dg8NwBc7.d.cts} +103 -410
- package/dist/index.cjs +2483 -306
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -65
- package/dist/index.d.ts +20 -65
- package/dist/index.js +2479 -305
- package/dist/index.js.map +1 -1
- package/dist/memory-volume-CTOXNJ6n.d.ts +66 -0
- package/dist/memory-volume-DCzGZFJb.d.cts +66 -0
- package/dist/python/python.data +16021 -66
- package/dist/python/python.js +2 -0
- package/dist/python/python.wasm +0 -0
- package/dist/python/python.worker.js +87 -0
- package/dist/python/runtime.json +34 -0
- package/dist/python-abi.cjs +2892 -0
- package/dist/python-abi.cjs.map +1 -0
- package/dist/python-abi.d.cts +645 -0
- package/dist/python-abi.d.ts +645 -0
- package/dist/python-abi.js +2839 -0
- package/dist/python-abi.js.map +1 -0
- package/dist/python-worker.js +865 -0
- package/dist/python-worker.js.map +1 -0
- package/dist/rolldown-wasi-worker.js +5 -1
- package/dist/rolldown-wasi-worker.js.map +1 -1
- package/dist/vfs-DzEcPbMY.d.cts +427 -0
- package/dist/vfs-DzEcPbMY.d.ts +427 -0
- package/package.json +8 -3
|
@@ -1,411 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
interface ChildHandle {
|
|
3
|
-
pid: number;
|
|
4
|
-
state: "starting" | "running" | "exited";
|
|
5
|
-
exitCode: number | undefined;
|
|
6
|
-
on(event: "stdout" | "stderr" | "exit" | "rawmode", listener: (...args: any[]) => void): unknown;
|
|
7
|
-
exec(): void;
|
|
8
|
-
sendStdin(data: string): void;
|
|
9
|
-
/**
|
|
10
|
-
* Close the child's input.
|
|
11
|
-
*
|
|
12
|
-
* Without this a child that reads stdin to EOF — every filter, and every
|
|
13
|
-
* tool a library pipes into, `xsel` and `base64` alike — waits forever for
|
|
14
|
-
* an end that never comes, and the parent waits on its exit.
|
|
15
|
-
*/
|
|
16
|
-
endStdin?(): void;
|
|
17
|
-
kill(signal?: string): void;
|
|
18
|
-
}
|
|
19
|
-
interface ChildSpawnConfig {
|
|
20
|
-
command: string;
|
|
21
|
-
args?: string[];
|
|
22
|
-
cwd?: string;
|
|
23
|
-
env?: Record<string, string>;
|
|
24
|
-
parentPid?: number;
|
|
25
|
-
/**
|
|
26
|
-
* The child was given the parent's streams (`stdio: "inherit"`).
|
|
27
|
-
*
|
|
28
|
-
* Its input is then the parent's terminal rather than a pipe that will end,
|
|
29
|
-
* which is the difference between a program that waits for what the user
|
|
30
|
-
* types and one that reads to end-of-input and stops.
|
|
31
|
-
*/
|
|
32
|
-
inheritStdio?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* The child was told to ignore its input (`stdio: "ignore"`).
|
|
35
|
-
*
|
|
36
|
-
* It then has no input at all, so its stdin is closed at once rather than
|
|
37
|
-
* left open on a parent that will never write to it.
|
|
38
|
-
*/
|
|
39
|
-
stdinIgnored?: boolean;
|
|
40
|
-
}
|
|
41
|
-
type SpawnChild = (config: ChildSpawnConfig) => ChildHandle;
|
|
42
|
-
/**
|
|
43
|
-
* Run a child to completion without returning to the event loop.
|
|
44
|
-
*
|
|
45
|
-
* Supplied only by a pod that can actually block — one whose guest runs on its
|
|
46
|
-
* own thread. Where it is absent the synchronous entry points keep reporting
|
|
47
|
-
* that they are unavailable, which is the honest answer for an in-realm pod.
|
|
48
|
-
*/
|
|
49
|
-
type SyncSpawn = (request: {
|
|
50
|
-
command: string;
|
|
51
|
-
args: string[];
|
|
52
|
-
cwd: string;
|
|
53
|
-
env?: Record<string, string>;
|
|
54
|
-
input?: string;
|
|
55
|
-
inheritStdio?: boolean;
|
|
56
|
-
}) => {
|
|
57
|
-
status: number | null;
|
|
58
|
-
stdout: string;
|
|
59
|
-
stderr: string;
|
|
60
|
-
signal: string | null;
|
|
61
|
-
error?: {
|
|
62
|
-
code?: string;
|
|
63
|
-
message: string;
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
declare function createChildProcessModule(spawnChild: SpawnChild, defaultCwd: () => string, syncSpawn?: SyncSpawn, defaultEnv?: () => Record<string, string>): Record<string, unknown>;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Clean-room contracts between SandboxedJS and its JavaScript runtime.
|
|
70
|
-
*
|
|
71
|
-
* These deliberately describe only behavior SandboxedJS consumes. Runtime
|
|
72
|
-
* implementations may use Web Workers in browsers or worker_threads on Node.
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
interface VolumeStats {
|
|
76
|
-
totalBytes: number;
|
|
77
|
-
fileCount: number;
|
|
78
|
-
/** New runtime spelling. */
|
|
79
|
-
directoryCount?: number;
|
|
80
|
-
/** Compatibility spelling used by existing volume implementations. */
|
|
81
|
-
dirCount?: number;
|
|
82
|
-
}
|
|
83
|
-
interface VolumeStat {
|
|
84
|
-
mode: number;
|
|
85
|
-
size: number;
|
|
86
|
-
uid: number;
|
|
87
|
-
gid: number;
|
|
88
|
-
ino: number;
|
|
89
|
-
nlink: number;
|
|
90
|
-
atimeMs: number;
|
|
91
|
-
mtimeMs: number;
|
|
92
|
-
ctimeMs: number;
|
|
93
|
-
birthtimeMs: number;
|
|
94
|
-
isFile(): boolean;
|
|
95
|
-
isDirectory(): boolean;
|
|
96
|
-
isSymbolicLink(): boolean;
|
|
97
|
-
}
|
|
98
|
-
interface RuntimeVolume {
|
|
99
|
-
readFileSync(path: string): Uint8Array;
|
|
100
|
-
writeFileSync(path: string, data: string | Uint8Array): void;
|
|
101
|
-
appendFileSync(path: string, data: string | Uint8Array): void;
|
|
102
|
-
readdirSync(path: string): string[];
|
|
103
|
-
lstatSync(path: string): VolumeStat;
|
|
104
|
-
readlinkSync(path: string): string;
|
|
105
|
-
mkdirSync(path: string, options?: {
|
|
106
|
-
mode?: number;
|
|
107
|
-
}): void;
|
|
108
|
-
rmdirSync(path: string): void;
|
|
109
|
-
unlinkSync(path: string): void;
|
|
110
|
-
renameSync(from: string, to: string): void;
|
|
111
|
-
symlinkSync(target: string, path: string): void;
|
|
112
|
-
linkSync(existing: string, path: string): void;
|
|
113
|
-
truncateSync(path: string, length?: number): void;
|
|
114
|
-
chmodSync(path: string, mode: number): void;
|
|
115
|
-
lchmodSync(path: string, mode: number): void;
|
|
116
|
-
chownSync(path: string, uid: number, gid: number): void;
|
|
117
|
-
lchownSync(path: string, uid: number, gid: number): void;
|
|
118
|
-
utimesSync(path: string, atime: Date, mtime: Date): void;
|
|
119
|
-
getStats(): VolumeStats;
|
|
120
|
-
}
|
|
121
|
-
interface RuntimeProcessResult {
|
|
122
|
-
exitCode: number;
|
|
123
|
-
stdout: string;
|
|
124
|
-
stderr: string;
|
|
125
|
-
}
|
|
126
|
-
interface RuntimeProcess {
|
|
127
|
-
readonly completion: Promise<RuntimeProcessResult>;
|
|
128
|
-
/**
|
|
129
|
-
* `output` and `error` carry stdout and stderr; `exit` the code. `rawmode`
|
|
130
|
-
* reports the program turning terminal raw mode on or off, which a terminal
|
|
131
|
-
* needs so that it stops echoing input the program is drawing itself.
|
|
132
|
-
*/
|
|
133
|
-
on(event: "output" | "error" | "exit" | "rawmode", listener: (...args: any[]) => void): this;
|
|
134
|
-
write(data: string): void;
|
|
135
|
-
kill(signal?: string): void;
|
|
136
|
-
}
|
|
137
|
-
interface RuntimeHttpResponse {
|
|
138
|
-
statusCode?: number;
|
|
139
|
-
statusMessage?: string;
|
|
140
|
-
headers?: Record<string, string>;
|
|
141
|
-
body?: string | Uint8Array | ArrayBuffer;
|
|
142
|
-
}
|
|
143
|
-
interface RuntimePackageInstaller {
|
|
144
|
-
install(name: string, version?: string, options?: Record<string, unknown>): Promise<unknown>;
|
|
145
|
-
installFromManifest(path: string, options?: Record<string, unknown>): Promise<unknown>;
|
|
146
|
-
/** Create a view that installs into another project root. */
|
|
147
|
-
forCwd?(cwd: string): RuntimePackageInstaller;
|
|
148
|
-
}
|
|
149
|
-
/** Where bytes written by an upgraded server inside the container come out. */
|
|
150
|
-
interface RuntimeSocketPeer {
|
|
151
|
-
data(bytes: Uint8Array): void;
|
|
152
|
-
close(): void;
|
|
153
|
-
}
|
|
154
|
-
/** The caller's end of a connection opened with {@link RuntimePod.connect}. */
|
|
155
|
-
interface RuntimeConnection {
|
|
156
|
-
send(bytes: Uint8Array): void;
|
|
157
|
-
close(): void;
|
|
158
|
-
}
|
|
159
|
-
/** The process-manager protocol a container's kernel bridge substitutes for. */
|
|
160
|
-
interface RuntimeProcessManager {
|
|
161
|
-
spawn(config: ChildSpawnConfig): ChildHandle;
|
|
162
|
-
}
|
|
163
|
-
interface RuntimePod {
|
|
164
|
-
readonly volume: RuntimeVolume;
|
|
165
|
-
readonly packages: RuntimePackageInstaller;
|
|
166
|
-
readonly instanceId: string;
|
|
167
|
-
readonly processManager: RuntimeProcessManager;
|
|
168
|
-
readonly proxy: {
|
|
169
|
-
activePorts(instanceId?: string): number[];
|
|
170
|
-
};
|
|
171
|
-
spawn(command: string, args?: string[], options?: Record<string, unknown>): Promise<RuntimeProcess>;
|
|
172
|
-
request(port: number, init?: Record<string, unknown>): Promise<RuntimeHttpResponse>;
|
|
173
|
-
/**
|
|
174
|
-
* Open a connection that upgrades out of HTTP, or null if nothing takes one.
|
|
175
|
-
*
|
|
176
|
-
* Optional because a pod that only ever answers requests is still a usable
|
|
177
|
-
* pod — a caller treats the absence as "no WebSocket here" rather than as a
|
|
178
|
-
* broken implementation.
|
|
179
|
-
*/
|
|
180
|
-
connect?(port: number, init: Record<string, unknown>, peer: RuntimeSocketPeer): RuntimeConnection | null;
|
|
181
|
-
snapshot(options?: Record<string, unknown>): unknown;
|
|
182
|
-
restore(snapshot: unknown, options?: Record<string, unknown>): Promise<void>;
|
|
183
|
-
teardown(): void;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
type FileKind = "file" | "directory" | "symlink" | "chardev" | "blockdev" | "fifo" | "socket";
|
|
187
|
-
/** Render as `drwxr-xr-x`, honouring setuid/setgid/sticky. */
|
|
188
|
-
declare function formatMode(mode: number): string;
|
|
189
|
-
/** Zero-padded octal permissions, as `stat -c %a`/`%04a` would show. */
|
|
190
|
-
declare function octalMode(mode: number, width?: number): string;
|
|
191
|
-
/**
|
|
192
|
-
* Apply a `chmod` spec to an existing mode. Accepts octal (`755`, `0644`) and
|
|
193
|
-
* the symbolic grammar (`u+rwx,go-w`, `a=r`, `+X`, `u+s`, `o+t`).
|
|
194
|
-
*
|
|
195
|
-
* @param isDir whether the target is a directory — needed for the `X` flag.
|
|
196
|
-
*/
|
|
197
|
-
declare function applyChmod(spec: string, current: number, isDir: boolean, umask?: number): number;
|
|
198
|
-
/** Parse the `umask` builtin's argument. */
|
|
199
|
-
declare function parseUmask(spec: string): number;
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* The `Stats` object handed back by `Vfs.stat`. Shaped like `fs.Stats` so it
|
|
203
|
-
* feels familiar, but with a real `st_mode` that carries the file-type bits
|
|
204
|
-
* (which the underlying volume stores separately).
|
|
205
|
-
*/
|
|
206
|
-
|
|
207
|
-
interface StatInit {
|
|
208
|
-
mode: number;
|
|
209
|
-
size: number;
|
|
210
|
-
uid: number;
|
|
211
|
-
gid: number;
|
|
212
|
-
ino: number;
|
|
213
|
-
nlink: number;
|
|
214
|
-
atimeMs: number;
|
|
215
|
-
mtimeMs: number;
|
|
216
|
-
ctimeMs: number;
|
|
217
|
-
birthtimeMs?: number;
|
|
218
|
-
dev?: number;
|
|
219
|
-
rdev?: number;
|
|
220
|
-
blksize?: number;
|
|
221
|
-
}
|
|
222
|
-
declare class Stats {
|
|
223
|
-
readonly mode: number;
|
|
224
|
-
readonly size: number;
|
|
225
|
-
readonly uid: number;
|
|
226
|
-
readonly gid: number;
|
|
227
|
-
readonly ino: number;
|
|
228
|
-
readonly nlink: number;
|
|
229
|
-
readonly dev: number;
|
|
230
|
-
readonly rdev: number;
|
|
231
|
-
readonly blksize: number;
|
|
232
|
-
readonly atimeMs: number;
|
|
233
|
-
readonly mtimeMs: number;
|
|
234
|
-
readonly ctimeMs: number;
|
|
235
|
-
readonly birthtimeMs: number;
|
|
236
|
-
constructor(init: StatInit);
|
|
237
|
-
get blocks(): number;
|
|
238
|
-
get atime(): Date;
|
|
239
|
-
get mtime(): Date;
|
|
240
|
-
get ctime(): Date;
|
|
241
|
-
get birthtime(): Date;
|
|
242
|
-
get kind(): FileKind;
|
|
243
|
-
isFile(): boolean;
|
|
244
|
-
isDirectory(): boolean;
|
|
245
|
-
isSymbolicLink(): boolean;
|
|
246
|
-
isCharacterDevice(): boolean;
|
|
247
|
-
isBlockDevice(): boolean;
|
|
248
|
-
isFIFO(): boolean;
|
|
249
|
-
isSocket(): boolean;
|
|
250
|
-
/** Permission bits only, with the type bits masked off. */
|
|
251
|
-
get perms(): number;
|
|
252
|
-
}
|
|
253
|
-
interface DirEntry {
|
|
254
|
-
name: string;
|
|
255
|
-
kind: FileKind;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* The container's virtual filesystem.
|
|
260
|
-
*
|
|
261
|
-
* Real file content lives in the RuntimePod's `MemoryVolume`, deliberately the
|
|
262
|
-
* *same* volume the Node.js worker processes see — so a file written by `echo`
|
|
263
|
-
* is readable by `require('fs')` inside a spawned script, and vice versa.
|
|
264
|
-
*
|
|
265
|
-
* On top of that volume this layer adds the parts a Linux userland expects and
|
|
266
|
-
* the raw volume does not have: file-type bits in `st_mode`, permission and
|
|
267
|
-
* ownership checks, an `O_*` open/fd table, and pluggable *virtual providers*
|
|
268
|
-
* that synthesise `/proc`, `/sys` and `/dev` on demand.
|
|
269
|
-
*/
|
|
270
|
-
|
|
271
|
-
/** The identity a filesystem operation runs as. */
|
|
272
|
-
interface Cred {
|
|
273
|
-
uid: number;
|
|
274
|
-
gid: number;
|
|
275
|
-
groups: number[];
|
|
276
|
-
umask: number;
|
|
277
|
-
}
|
|
278
|
-
declare const ROOT_CRED: Cred;
|
|
279
|
-
declare function makeCred(uid: number, gid: number, groups?: number[], umask?: number): Cred;
|
|
280
|
-
/** A file that does not live in the volume — `/proc/uptime`, `/dev/null`, … */
|
|
281
|
-
interface VirtualNode {
|
|
282
|
-
kind: FileKind;
|
|
283
|
-
/** Permission bits only; the type bits are added from `kind`. */
|
|
284
|
-
mode: number;
|
|
285
|
-
uid?: number;
|
|
286
|
-
gid?: number;
|
|
287
|
-
size?: number;
|
|
288
|
-
mtimeMs?: number;
|
|
289
|
-
/** Symlink target, when `kind === "symlink"`. */
|
|
290
|
-
target?: string;
|
|
291
|
-
read?(): Uint8Array | string;
|
|
292
|
-
write?(data: Uint8Array, append: boolean): void;
|
|
293
|
-
/** Directory listing, when `kind === "directory"`. */
|
|
294
|
-
list?(): string[];
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Supplies a subtree of synthetic files. `resolve` receives the path *relative*
|
|
298
|
-
* to `root` ("" means the mount point itself) and returns null for misses.
|
|
299
|
-
*/
|
|
300
|
-
interface VirtualProvider {
|
|
301
|
-
root: string;
|
|
302
|
-
resolve(rel: string): VirtualNode | null;
|
|
303
|
-
/**
|
|
304
|
-
* When true (the default) the provider owns its whole subtree and a miss is
|
|
305
|
-
* `ENOENT` — that is what `/proc` wants, so a dead pid does not resolve to a
|
|
306
|
-
* stale on-disk file. `/dev` and `/sys` set this to false so that synthetic
|
|
307
|
-
* nodes overlay a real directory users can still write into.
|
|
308
|
-
*/
|
|
309
|
-
exclusive?: boolean;
|
|
310
|
-
}
|
|
311
|
-
interface WriteOptions {
|
|
312
|
-
mode?: number;
|
|
313
|
-
append?: boolean;
|
|
314
|
-
cred?: Cred;
|
|
315
|
-
/** Skip the permission check — used by kernel-internal writes. */
|
|
316
|
-
privileged?: boolean;
|
|
317
|
-
}
|
|
318
|
-
interface ResolveOptions {
|
|
319
|
-
cred?: Cred;
|
|
320
|
-
/** Follow a symlink in the final position. Off for `lstat`, `rm`, `chmod -h`. */
|
|
321
|
-
followFinal?: boolean;
|
|
322
|
-
}
|
|
323
|
-
declare class Vfs {
|
|
324
|
-
readonly volume: RuntimeVolume;
|
|
325
|
-
private readonly providers;
|
|
326
|
-
private nextVirtualIno;
|
|
327
|
-
private readonly virtualInos;
|
|
328
|
-
constructor(volume: RuntimeVolume);
|
|
329
|
-
addProvider(provider: VirtualProvider): void;
|
|
330
|
-
removeProvider(root: string): void;
|
|
331
|
-
/** The mount points currently served synthetically. */
|
|
332
|
-
get virtualRoots(): string[];
|
|
333
|
-
private lookupVirtual;
|
|
334
|
-
/** True when a miss at `abs` must be ENOENT rather than a volume lookup. */
|
|
335
|
-
private isUnderProvider;
|
|
336
|
-
/** Synthetic children a non-exclusive provider contributes to a directory. */
|
|
337
|
-
private virtualChildren;
|
|
338
|
-
private virtualIno;
|
|
339
|
-
/** True when `cred` may perform `mode` (R_OK/W_OK/X_OK) on a stat result. */
|
|
340
|
-
permitted(st: Stats, mode: number, cred: Cred): boolean;
|
|
341
|
-
private require;
|
|
342
|
-
/**
|
|
343
|
-
* Walk `abs` component by component, following symlinks and checking search
|
|
344
|
-
* (`+x`) permission on every directory along the way, exactly like `namei`.
|
|
345
|
-
*
|
|
346
|
-
* Returns the fully resolved absolute path. Does *not* require the final
|
|
347
|
-
* component to exist — callers decide whether a miss is fatal.
|
|
348
|
-
*/
|
|
349
|
-
resolvePath(abs: string, opts?: ResolveOptions): string;
|
|
350
|
-
/** lstat that returns null instead of throwing, for internal probing. */
|
|
351
|
-
private tryLstat;
|
|
352
|
-
private readlinkRaw;
|
|
353
|
-
/** stat(2) — follows symlinks. */
|
|
354
|
-
stat(abs: string, opts?: {
|
|
355
|
-
cred?: Cred;
|
|
356
|
-
}): Stats;
|
|
357
|
-
/** lstat(2) — does not follow a symlink in the final position. */
|
|
358
|
-
lstat(abs: string): Stats;
|
|
359
|
-
private statFromVirtual;
|
|
360
|
-
exists(abs: string, cred?: Cred): boolean;
|
|
361
|
-
lexists(abs: string): boolean;
|
|
362
|
-
access(abs: string, mode?: number, cred?: Cred): void;
|
|
363
|
-
realpath(abs: string, cred?: Cred): string;
|
|
364
|
-
readFile(abs: string, cred?: Cred): Uint8Array;
|
|
365
|
-
readText(abs: string, cred?: Cred): string;
|
|
366
|
-
readdir(abs: string, cred?: Cred): string[];
|
|
367
|
-
/** True when the volume itself has a real directory at `abs`. */
|
|
368
|
-
private volumeHasDir;
|
|
369
|
-
readdirWithTypes(abs: string, cred?: Cred): DirEntry[];
|
|
370
|
-
readlink(abs: string, cred?: Cred): string;
|
|
371
|
-
writeFile(abs: string, data: Uint8Array | string, opts?: WriteOptions): void;
|
|
372
|
-
appendFile(abs: string, data: Uint8Array | string, opts?: WriteOptions): void;
|
|
373
|
-
truncate(abs: string, len?: number, cred?: Cred): void;
|
|
374
|
-
mkdir(abs: string, opts?: {
|
|
375
|
-
mode?: number;
|
|
376
|
-
recursive?: boolean;
|
|
377
|
-
cred?: Cred;
|
|
378
|
-
}): void;
|
|
379
|
-
private mkdirOne;
|
|
380
|
-
rmdir(abs: string, cred?: Cred): void;
|
|
381
|
-
unlink(abs: string, cred?: Cred): void;
|
|
382
|
-
/** Recursive delete, the engine behind `rm -r`. */
|
|
383
|
-
rmrf(abs: string, cred?: Cred): void;
|
|
384
|
-
private requireParentWrite;
|
|
385
|
-
rename(from: string, to: string, cred?: Cred): void;
|
|
386
|
-
copyFile(from: string, to: string, cred?: Cred): void;
|
|
387
|
-
symlink(target: string, linkPath: string, cred?: Cred): void;
|
|
388
|
-
link(existing: string, newPath: string, cred?: Cred): void;
|
|
389
|
-
chmod(abs: string, mode: number, cred?: Cred, follow?: boolean): void;
|
|
390
|
-
chown(abs: string, uid: number, gid: number, cred?: Cred, follow?: boolean): void;
|
|
391
|
-
utimes(abs: string, atimeMs: number, mtimeMs: number, cred?: Cred): void;
|
|
392
|
-
/** `touch` semantics: create when missing, otherwise bump the timestamps. */
|
|
393
|
-
touch(abs: string, cred?: Cred, timeMs?: number): void;
|
|
394
|
-
/** Depth-first walk yielding absolute paths. Symlinks are not followed. */
|
|
395
|
-
walk(abs: string, opts?: {
|
|
396
|
-
includeSelf?: boolean;
|
|
397
|
-
cred?: Cred;
|
|
398
|
-
maxDepth?: number;
|
|
399
|
-
}): Generator<string>;
|
|
400
|
-
/** Recursive copy used by `cp -r` and the container's `copyIn` helper. */
|
|
401
|
-
copyTree(from: string, to: string, cred?: Cred): void;
|
|
402
|
-
/** Free/used byte accounting for `df` and `du`. */
|
|
403
|
-
usage(abs?: string): {
|
|
404
|
-
files: number;
|
|
405
|
-
dirs: number;
|
|
406
|
-
bytes: number;
|
|
407
|
-
};
|
|
408
|
-
}
|
|
1
|
+
import { V as Vfs, C as Cred, e as RuntimePod, D as DirEntry, o as Stats } from './vfs-DzEcPbMY.cjs';
|
|
409
2
|
|
|
410
3
|
/**
|
|
411
4
|
* Byte streams for stdin/stdout/stderr, pipelines and redirections.
|
|
@@ -1443,6 +1036,84 @@ declare class Shell {
|
|
|
1443
1036
|
reapJobs(): Job[];
|
|
1444
1037
|
}
|
|
1445
1038
|
|
|
1039
|
+
/**
|
|
1040
|
+
* What a Python runtime release says about itself.
|
|
1041
|
+
*
|
|
1042
|
+
* A manifest is how a host selects an interpreter build without guessing from
|
|
1043
|
+
* a URL. It names the exact artifact, the ABI it was compiled against, and the
|
|
1044
|
+
* capabilities it actually has — so a program that needs threads or native
|
|
1045
|
+
* extensions can be told "not in this profile" instead of failing somewhere
|
|
1046
|
+
* deep inside an import.
|
|
1047
|
+
*
|
|
1048
|
+
* The ABI identity is the part that must never be inferred. A build compiled
|
|
1049
|
+
* against `sbx_host_v1` cannot be loaded by a kernel that speaks a different
|
|
1050
|
+
* version, and finding that out at the first syscall rather than at load time
|
|
1051
|
+
* turns a clear error into a corrupted run.
|
|
1052
|
+
*/
|
|
1053
|
+
declare const MANIFEST_FORMAT = "sandboxedjs-python-runtime";
|
|
1054
|
+
declare const MANIFEST_SCHEMA_VERSION = 1;
|
|
1055
|
+
/** Build profiles, as defined in docs/python/architecture.md. */
|
|
1056
|
+
type PythonProfile = "core" | "threaded-fixed" | "threaded-dynamic";
|
|
1057
|
+
interface PythonCapabilities {
|
|
1058
|
+
/** Real Python threads. `core` builds have none, and must say so. */
|
|
1059
|
+
threads: boolean;
|
|
1060
|
+
/**
|
|
1061
|
+
* How native extensions may arrive:
|
|
1062
|
+
* `none` — no extension modules beyond the built-ins;
|
|
1063
|
+
* `fixed` — curated extensions linked into the image;
|
|
1064
|
+
* `dynamic` — side modules loaded at import time.
|
|
1065
|
+
*/
|
|
1066
|
+
nativeExtensions: "none" | "fixed" | "dynamic";
|
|
1067
|
+
/** `none`, `http` (kernel-controlled fetch), or `sockets` (virtual sockets). */
|
|
1068
|
+
networking: "none" | "http" | "sockets";
|
|
1069
|
+
/** `none`, or `spawn` — never `fork`, which cannot be honest here. */
|
|
1070
|
+
processes: "none" | "spawn";
|
|
1071
|
+
/** Where an environment survives: nowhere, memory only, or real storage. */
|
|
1072
|
+
persistence: "none" | "memory" | "durable";
|
|
1073
|
+
}
|
|
1074
|
+
interface PythonRuntimeManifest {
|
|
1075
|
+
format: typeof MANIFEST_FORMAT;
|
|
1076
|
+
schemaVersion: number;
|
|
1077
|
+
/** Stable identity of this build; also the cache key for its compiled module. */
|
|
1078
|
+
runtimeId: string;
|
|
1079
|
+
engine: "cpython-wasm";
|
|
1080
|
+
/** The interpreter's own version, e.g. "3.13.5". */
|
|
1081
|
+
pythonVersion: string;
|
|
1082
|
+
profile: PythonProfile;
|
|
1083
|
+
hostAbi: {
|
|
1084
|
+
name: string;
|
|
1085
|
+
version: number;
|
|
1086
|
+
};
|
|
1087
|
+
artifacts: {
|
|
1088
|
+
/** The Emscripten loader module. Its `.wasm` and `.data` sit beside it. */
|
|
1089
|
+
moduleUrl: string;
|
|
1090
|
+
/** Optional integrity hashes, keyed by file name. */
|
|
1091
|
+
hashes?: Record<string, string>;
|
|
1092
|
+
};
|
|
1093
|
+
capabilities: PythonCapabilities;
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* Check a manifest before anything is loaded from it.
|
|
1097
|
+
*
|
|
1098
|
+
* Every failure here is one that would otherwise surface much later and much
|
|
1099
|
+
* less clearly — a missing capability as an ImportError, a wrong ABI as a
|
|
1100
|
+
* corrupted syscall.
|
|
1101
|
+
*/
|
|
1102
|
+
declare function validateManifest(value: unknown): PythonRuntimeManifest;
|
|
1103
|
+
|
|
1104
|
+
/**
|
|
1105
|
+
* Which Python backend a container uses.
|
|
1106
|
+
*
|
|
1107
|
+
* The owned runtime is introduced behind an explicit choice rather than as a
|
|
1108
|
+
* silent replacement: the two backends have genuinely different process
|
|
1109
|
+
* semantics, and a container that switched between them on its own would
|
|
1110
|
+
* change whether `sys.modules` is shared, whether `os.getpid()` varies, and
|
|
1111
|
+
* what a failed import means. The old backend stays reachable until the parity
|
|
1112
|
+
* gates in docs/python/release-gates.md pass.
|
|
1113
|
+
*/
|
|
1114
|
+
|
|
1115
|
+
type PythonBackendName = "pyodide" | "sbx-cpython-wasm";
|
|
1116
|
+
|
|
1446
1117
|
/**
|
|
1447
1118
|
* The CPython runtime: Pyodide, wired to the container the same way
|
|
1448
1119
|
* the other runtimes are — filesystem, argv, environment and standard streams.
|
|
@@ -1477,7 +1148,20 @@ declare function configureCPython(options?: CPythonOptions): void;
|
|
|
1477
1148
|
/** True when this host can start CPython at all. */
|
|
1478
1149
|
declare function isCPythonAvailable(): Promise<boolean>;
|
|
1479
1150
|
|
|
1480
|
-
/**
|
|
1151
|
+
/**
|
|
1152
|
+
* The `python3` command.
|
|
1153
|
+
*
|
|
1154
|
+
* Two backends sit behind it. `pyodide` is the original integration: one
|
|
1155
|
+
* interpreter cached per container, with each program given fresh globals —
|
|
1156
|
+
* which is why `sys.modules` leaks between unrelated programs and every
|
|
1157
|
+
* program reports the same PID (see docs/python/baseline-inventory.md).
|
|
1158
|
+
* `sbx-cpython-wasm` is the owned distribution: CPython built from source, one
|
|
1159
|
+
* interpreter per process, everything reached through the `sbx_host_v1` kernel
|
|
1160
|
+
* ABI.
|
|
1161
|
+
*
|
|
1162
|
+
* The choice is explicit and per-container. The two have genuinely different
|
|
1163
|
+
* process semantics, so switching silently would change what a program means.
|
|
1164
|
+
*/
|
|
1481
1165
|
|
|
1482
1166
|
declare const PYTHON_VERSION = "3.13";
|
|
1483
1167
|
interface PythonOptions {
|
|
@@ -1485,6 +1169,15 @@ interface PythonOptions {
|
|
|
1485
1169
|
indexURL?: string;
|
|
1486
1170
|
/** URL of pyodide.mjs, for browsers without package resolution. */
|
|
1487
1171
|
pyodideURL?: string;
|
|
1172
|
+
/**
|
|
1173
|
+
* Which interpreter to run. Defaults to `pyodide` until the parity gates in
|
|
1174
|
+
* docs/python/release-gates.md pass.
|
|
1175
|
+
*/
|
|
1176
|
+
backend?: PythonBackendName;
|
|
1177
|
+
/** The owned runtime's release manifest. Required by `sbx-cpython-wasm`. */
|
|
1178
|
+
manifest?: PythonRuntimeManifest;
|
|
1179
|
+
/** Where the built process worker is served from, for hosts that must say. */
|
|
1180
|
+
workerUrl?: string;
|
|
1488
1181
|
}
|
|
1489
1182
|
declare function configurePython(options?: PythonOptions): void;
|
|
1490
1183
|
declare const isPythonAvailable: typeof isCPythonAvailable;
|
|
@@ -1859,4 +1552,4 @@ declare class Container {
|
|
|
1859
1552
|
/** Boot a container. The one function most callers need. */
|
|
1860
1553
|
declare function createContainer(opts?: ContainerOptions): Promise<Container>;
|
|
1861
1554
|
|
|
1862
|
-
export {
|
|
1555
|
+
export { type SessionResult as $, type ProcessKind as A, BufferSink as B, Container as C, type ProcessOptions as D, type ExecContext as E, type FileData as F, type GroupEntry as G, type HttpResponse as H, type InputStream as I, type Job as J, Kernel as K, type ListeningPort as L, MANIFEST_FORMAT as M, type Node as N, type OutputStream as O, PYTHON_VERSION as P, type ProcessState as Q, ProcessTable as R, Shell as S, type PythonCapabilities as T, type PythonOptions as U, type PythonProfile as V, type PythonRuntimeManifest as W, type ResolvedExecutable as X, type RunOptions as Y, type RunResult as Z, type SessionInit as _, type ShellIO as a, type SessionRunOptions as a0, ShellExit as a1, type ShellInit as a2, type ShellOptions as a3, type SpawnHandle as a4, type Stdio as a5, TeeOutput as a6, UserDatabase as a7, Variables as a8, braceExpand as a9, captureStdio as aa, configureCPython as ab, configurePython as ac, createContext as ad, defineCommand as ae, expandWord as af, expandWords as ag, isCPythonAvailable as ah, isPythonAvailable as ai, resetPidCounter as aj, shellQuote as ak, validateManifest as al, Session as b, type Command as c, createContainer as d, type CPythonOptions as e, CallbackSink as f, CommandRegistry as g, ContainerFs as h, type ContainerOptions as i, type ContextInit as j, type Env as k, type ExecOptions as l, type ExecResult as m, FileInput as n, FileOutput as o, type KernelOptions as p, MANIFEST_SCHEMA_VERSION as q, type MountEntry as r, type NetInterface as s, type NetworkOptions as t, NetworkStack as u, NullInput as v, NullOutput as w, type PasswdEntry as x, Pipe as y, Process as z };
|