sandboxedjs 0.1.73 → 0.1.75
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/README.md +40 -2
- package/dist/agent.d.cts +2 -2
- package/dist/agent.d.ts +2 -2
- package/dist/{container-BxEoVOmX.d.cts → container-NoLUp_fd.d.cts} +98 -5
- package/dist/{container-B5X6stfx.d.ts → container-X8yZRFvW.d.ts} +98 -5
- package/dist/{contracts-CVgctitO.d.cts → contracts-C2_dTgk3.d.cts} +30 -1
- package/dist/{contracts-CVgctitO.d.ts → contracts-C2_dTgk3.d.ts} +30 -1
- package/dist/index.cjs +5264 -2852
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +175 -9
- package/dist/index.d.ts +175 -9
- package/dist/index.js +5252 -2854
- package/dist/index.js.map +1 -1
- package/dist/{memory-volume-CWuWScIs.d.ts → memory-volume-CG56p660.d.ts} +1 -1
- package/dist/{memory-volume-DlMSAh-K.d.cts → memory-volume-DqEWFo7t.d.cts} +1 -1
- package/dist/python-abi.cjs +13 -0
- package/dist/python-abi.cjs.map +1 -1
- package/dist/python-abi.d.cts +3 -3
- package/dist/python-abi.d.ts +3 -3
- package/dist/python-abi.js +13 -0
- package/dist/python-abi.js.map +1 -1
- package/dist/rolldown-wasi-worker.js +5 -1
- package/dist/rolldown-wasi-worker.js.map +1 -1
- package/dist/worker-entry.js +861 -55
- package/dist/worker-entry.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -165,6 +165,17 @@ await session.run("echo $TOKEN in $(pwd)"); // → abc in /app
|
|
|
165
165
|
|
|
166
166
|
### Long-running processes
|
|
167
167
|
|
|
168
|
+
A job put in the background with `&` keeps running after the command that started it returns,
|
|
169
|
+
even from a stateless `exec`, and stops with `kill %N` in a session or when the container is
|
|
170
|
+
disposed:
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
await box.exec("node server.js > /tmp/server.log 2>&1 &", { cwd: "/app" });
|
|
174
|
+
await box.waitForPort(3000);
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
To hold the process yourself, spawn it:
|
|
178
|
+
|
|
168
179
|
```ts
|
|
169
180
|
const proc = box.spawn("node server.js", { cwd: "/app" });
|
|
170
181
|
|
|
@@ -545,7 +556,10 @@ The container has no access to your filesystem, environment, or network unless y
|
|
|
545
556
|
- The filesystem is entirely in memory. Code inside cannot read or write a host path — there is
|
|
546
557
|
no `/Users`, no `/home/you`, no way to reach one.
|
|
547
558
|
- Outbound network access is **off by default**; `curl https://…` fails until you pass
|
|
548
|
-
`network: { allowOutbound: true }`, optionally narrowed with `allowedHosts`.
|
|
559
|
+
`network: { allowOutbound: true }`, optionally narrowed with `allowedHosts`. The same policy
|
|
560
|
+
binds a program's own `fetch`, `http`, `https` and `WebSocket`: a refused request fails with
|
|
561
|
+
`ENETUNREACH`. `localhost` and `127.0.0.1` always mean the container's own servers — never the
|
|
562
|
+
host's.
|
|
549
563
|
- Host files enter only through `files`, `mount()` or `copyIn()`, and leave only through
|
|
550
564
|
`copyOut()` or `fs.readFile()`.
|
|
551
565
|
- `timeoutMs` bounds runaway commands, and `exec` settles even when a process ignores its kill
|
|
@@ -1000,7 +1014,16 @@ Honest list of what does not work:
|
|
|
1000
1014
|
through is to answer **No** to a prompt like `npm create vite`'s "Install with npm and start
|
|
1001
1015
|
now?" and run `npm install && npm run dev` from the shell instead.
|
|
1002
1016
|
- **No `net`, `tls`, `worker_threads` or `vm`.** `http` and `https` are served by a virtual stack
|
|
1003
|
-
that `request()` talks to directly, so servers work; raw sockets do not.
|
|
1017
|
+
that `request()` talks to directly, so servers work; raw sockets do not. A program can reach
|
|
1018
|
+
servers anywhere in the container over HTTP (`http.get`, `fetch`), but not open a `WebSocket` to
|
|
1019
|
+
one.
|
|
1020
|
+
- **`node:test` covers what test files use** — `test`/`it`, `describe`, hooks, subtests, `skip`,
|
|
1021
|
+
`todo`, `only`, `mock.fn` and `mock.method`, with `spec` and `tap` reports — and `node --test`
|
|
1022
|
+
finds and runs test files as Node 22 does. `run()`, coverage and mock timers are not
|
|
1023
|
+
implemented. A test file exits when its tests finish, as under `--test-force-exit`.
|
|
1024
|
+
- **On the in-realm runtime, programs share one global object.** A global one program sets is
|
|
1025
|
+
visible to the next. The worker runtime (the default where shared memory is available) gives
|
|
1026
|
+
each program its own.
|
|
1004
1027
|
- **Python is source-built CPython/WASM.** Each program gets its own interpreter
|
|
1005
1028
|
process worker. Pure-Python wheels install normally; native extensions must
|
|
1006
1029
|
be linked or published for Emscripten. The bundled wheel index includes the
|
|
@@ -1091,3 +1114,18 @@ agent sandbox, and a browser terminal.
|
|
|
1091
1114
|
## License
|
|
1092
1115
|
|
|
1093
1116
|
MIT, with no dependency carrying a stricter licence.
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
### Optional developer tool packs
|
|
1120
|
+
|
|
1121
|
+
Host applications can add local Git operations through `createGitCommand`
|
|
1122
|
+
(isomorphic-git) and embedded PostgreSQL SQL through `createSqlCommand`
|
|
1123
|
+
(PGlite). These engines are optional and are not bundled into the core.
|
|
1124
|
+
`installWasmCommands` installs separately distributed, integrity-checked WASI
|
|
1125
|
+
commands. ELF files use registered compatibility, translation and emulation
|
|
1126
|
+
backends. Original experimental x86-64 engines are available as opt-in backends
|
|
1127
|
+
for a small freestanding instruction/syscall subset; see [Original engines](docs/original-x64.md).
|
|
1128
|
+
See [Developer tool packs](docs/developer-tool-packs.md) for examples and limits.
|
|
1129
|
+
`createFrontendPlaywright` adds Playwright-shaped, frontend-only automation of a
|
|
1130
|
+
same-origin iframe using the host browser; see
|
|
1131
|
+
[Frontend automation](docs/frontend-automation.md) for its supported subset.
|
package/dist/agent.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as Container } from './container-
|
|
2
|
-
import './contracts-
|
|
1
|
+
import { C as Container } from './container-NoLUp_fd.cjs';
|
|
2
|
+
import './contracts-C2_dTgk3.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Structural copies of the LangChain Deep Agents backend contract.
|
package/dist/agent.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { V as Vfs, C as Cred, f as RuntimePod, D as DirEntry, p as Stats } from './contracts-
|
|
1
|
+
import { V as Vfs, C as Cred, f as RuntimePod, O as OutboundPolicy, D as DirEntry, p as Stats } from './contracts-C2_dTgk3.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Byte streams for stdin/stdout/stderr, pipelines and redirections.
|
|
@@ -487,6 +487,8 @@ declare class NetworkStack {
|
|
|
487
487
|
timeoutMs?: number;
|
|
488
488
|
intervalMs?: number;
|
|
489
489
|
}): Promise<boolean>;
|
|
490
|
+
/** The policy every way out of the container applies, not only the shell's. */
|
|
491
|
+
get policy(): OutboundPolicy;
|
|
490
492
|
outboundAllowed(url: string): boolean;
|
|
491
493
|
procNetDev(): string;
|
|
492
494
|
procNetRoute(): string;
|
|
@@ -494,6 +496,83 @@ declare class NetworkStack {
|
|
|
494
496
|
countRx(bytes: number, iface?: string): void;
|
|
495
497
|
}
|
|
496
498
|
|
|
499
|
+
type ExecutionTier = "compatibility" | "translation" | "emulation";
|
|
500
|
+
interface BinaryInfo {
|
|
501
|
+
format: "elf";
|
|
502
|
+
bits: 32 | 64;
|
|
503
|
+
machine: number;
|
|
504
|
+
architecture: string;
|
|
505
|
+
littleEndian: boolean;
|
|
506
|
+
}
|
|
507
|
+
interface BinaryRequest {
|
|
508
|
+
path: string;
|
|
509
|
+
bytes: Uint8Array;
|
|
510
|
+
sha256: string;
|
|
511
|
+
info: BinaryInfo;
|
|
512
|
+
}
|
|
513
|
+
interface PreparedBinary {
|
|
514
|
+
/** Once execution begins, failure never retries another backend: effects may exist. */
|
|
515
|
+
run(ctx: ExecContext): Promise<number> | number;
|
|
516
|
+
}
|
|
517
|
+
type Preparation = {
|
|
518
|
+
supported: true;
|
|
519
|
+
program: PreparedBinary;
|
|
520
|
+
} | {
|
|
521
|
+
supported: false;
|
|
522
|
+
reason: string;
|
|
523
|
+
};
|
|
524
|
+
interface BinaryBackend {
|
|
525
|
+
id: string;
|
|
526
|
+
tier: ExecutionTier;
|
|
527
|
+
/** Host-supplied trusted code. Preparation must not execute the guest or mutate its files. */
|
|
528
|
+
prepare(request: BinaryRequest, signal: AbortSignal): Promise<Preparation> | Preparation;
|
|
529
|
+
}
|
|
530
|
+
interface ExecutionDecision {
|
|
531
|
+
path: string;
|
|
532
|
+
backend: string;
|
|
533
|
+
tier: ExecutionTier;
|
|
534
|
+
supported: boolean;
|
|
535
|
+
reason?: string;
|
|
536
|
+
}
|
|
537
|
+
declare function binaryDigest(bytes: Uint8Array): string;
|
|
538
|
+
declare function isElfBinary(bytes: Uint8Array): boolean;
|
|
539
|
+
declare function inspectElf(bytes: Uint8Array): BinaryInfo;
|
|
540
|
+
/** Per-container backend registry. No vendor packages or network services are built in. */
|
|
541
|
+
declare class BinaryExecutionRegistry {
|
|
542
|
+
private readonly onDecision?;
|
|
543
|
+
private backends;
|
|
544
|
+
constructor(onDecision?: ((decision: ExecutionDecision) => void) | undefined);
|
|
545
|
+
register(backend: BinaryBackend): () => void;
|
|
546
|
+
clear(): void;
|
|
547
|
+
list(): {
|
|
548
|
+
id: string;
|
|
549
|
+
tier: ExecutionTier;
|
|
550
|
+
}[];
|
|
551
|
+
run(ctx: ExecContext, path: string): Promise<number>;
|
|
552
|
+
}
|
|
553
|
+
interface WasmCommandArtifact {
|
|
554
|
+
name: string;
|
|
555
|
+
bytes: Uint8Array;
|
|
556
|
+
/** Exact SHA-256 hex digest from the package's trusted manifest. */
|
|
557
|
+
sha256: string;
|
|
558
|
+
}
|
|
559
|
+
/** Install a host-loaded pack of WASI commands. Nothing is fetched implicitly. */
|
|
560
|
+
declare function installWasmCommands(kernel: Kernel, artifacts: WasmCommandArtifact[]): void;
|
|
561
|
+
/** Match exact Linux artifacts to their independently built, ABI-compatible WASI ports. */
|
|
562
|
+
declare function createWasmCompatibilityBackend(id: string, entries: {
|
|
563
|
+
elfSha256: string;
|
|
564
|
+
wasm: WasmCommandArtifact;
|
|
565
|
+
}[]): BinaryBackend;
|
|
566
|
+
interface WasmTranslator {
|
|
567
|
+
/** Versioned compiler identity: change when flags, compiler or syscall ABI changes. */
|
|
568
|
+
id: string;
|
|
569
|
+
supports(info: BinaryInfo): boolean;
|
|
570
|
+
/** Supply a real compiler here. Null means unsupported, not a guest runtime failure. */
|
|
571
|
+
translate(request: BinaryRequest, signal: AbortSignal): Promise<Uint8Array | null>;
|
|
572
|
+
}
|
|
573
|
+
/** Bounded, content-addressed cache around a host-provided ELF → WASI translator. */
|
|
574
|
+
declare function createTranslationBackend(translator: WasmTranslator, maxCacheBytes?: number): BinaryBackend;
|
|
575
|
+
|
|
497
576
|
/**
|
|
498
577
|
* The kernel: the object that owns the filesystem, the process table, the user
|
|
499
578
|
* database and the executable namespace, and knows how to turn an `argv` into
|
|
@@ -540,7 +619,7 @@ interface RunResult {
|
|
|
540
619
|
signal: string | null;
|
|
541
620
|
timedOut: boolean;
|
|
542
621
|
}
|
|
543
|
-
type ExecutableKind = "builtin" | "script" | "unknown";
|
|
622
|
+
type ExecutableKind = "builtin" | "script" | "native" | "unknown";
|
|
544
623
|
interface ResolvedExecutable {
|
|
545
624
|
kind: ExecutableKind;
|
|
546
625
|
/** Absolute path of the file that was found. */
|
|
@@ -561,6 +640,7 @@ declare class Kernel {
|
|
|
561
640
|
readonly vfs: Vfs;
|
|
562
641
|
readonly procs: ProcessTable;
|
|
563
642
|
readonly commands: CommandRegistry;
|
|
643
|
+
readonly binaries: BinaryExecutionRegistry;
|
|
564
644
|
readonly users: UserDatabase;
|
|
565
645
|
readonly pod: RuntimePod;
|
|
566
646
|
readonly bootTime: number;
|
|
@@ -979,8 +1059,13 @@ declare class Shell {
|
|
|
979
1059
|
captureSubshell(command: string): Promise<string>;
|
|
980
1060
|
/** `<(cmd)` — run the command now and hand back a path holding its output. */
|
|
981
1061
|
private makeProcessSubstitution;
|
|
982
|
-
/**
|
|
983
|
-
|
|
1062
|
+
/**
|
|
1063
|
+
* A copy that shares nothing mutable with this shell.
|
|
1064
|
+
*
|
|
1065
|
+
* Subshells and pipeline stages run as part of this shell's process. A
|
|
1066
|
+
* background job passes a process of its own, the way fork(2) gives one.
|
|
1067
|
+
*/
|
|
1068
|
+
fork(proc?: Process): Shell;
|
|
984
1069
|
private currentIO;
|
|
985
1070
|
run(node: Node, io: ShellIO): Promise<number>;
|
|
986
1071
|
private runList;
|
|
@@ -1543,6 +1628,14 @@ declare class Container {
|
|
|
1543
1628
|
}): Session;
|
|
1544
1629
|
/** The container-wide session used by `shell()` shorthand helpers. */
|
|
1545
1630
|
get shell(): Session;
|
|
1631
|
+
/**
|
|
1632
|
+
* The streams one call collects into.
|
|
1633
|
+
*
|
|
1634
|
+
* They are detachable because a background job started by the command keeps
|
|
1635
|
+
* writing after the call has returned. Nothing reads the result any more by
|
|
1636
|
+
* then, so without `detach` a chatty server would grow the buffer for as long
|
|
1637
|
+
* as it ran; afterwards its output still reaches the container-wide taps.
|
|
1638
|
+
*/
|
|
1546
1639
|
private makeStdio;
|
|
1547
1640
|
/** Send an HTTP request to a server running inside the container. */
|
|
1548
1641
|
request(port: number, init?: {
|
|
@@ -1620,4 +1713,4 @@ declare class Container {
|
|
|
1620
1713
|
/** Boot a container. The one function most callers need. */
|
|
1621
1714
|
declare function createContainer(opts?: ContainerOptions): Promise<Container>;
|
|
1622
1715
|
|
|
1623
|
-
export { type
|
|
1716
|
+
export { type PythonCapabilities as $, NetworkStack as A, type BinaryBackend as B, Container as C, NullInput 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, NullOutput as P, PYTHON_VERSION as Q, type PasswdEntry as R, Shell as S, Pipe as T, type Preparation as U, type PreparedBinary as V, Process as W, type ProcessKind as X, type ProcessOptions as Y, type ProcessState as Z, ProcessTable as _, type ShellIO as a, type PythonOptions as a0, type PythonProfile as a1, type PythonRuntimeManifest as a2, type ResolvedExecutable as a3, type RunOptions as a4, type RunResult as a5, type SessionInit as a6, type SessionResult as a7, type SessionRunOptions as a8, ShellExit as a9, shellQuote as aA, validateManifest as aB, type ShellInit as aa, type ShellOptions as ab, type SpawnHandle as ac, type Stdio as ad, TeeOutput as ae, UserDatabase as af, Variables as ag, type WasmCommandArtifact as ah, type WasmTranslator as ai, binaryDigest as aj, braceExpand as ak, captureStdio as al, configureCPython as am, configurePython as an, createContext as ao, createTranslationBackend as ap, createWasmCompatibilityBackend as aq, defineCommand as ar, expandWord as as, expandWords as at, inspectElf as au, installWasmCommands as av, isCPythonAvailable as aw, isElfBinary as ax, isPythonAvailable as ay, resetPidCounter as az, Session as b, type Command as c, createContainer as d, BinaryExecutionRegistry as e, type BinaryInfo as f, type BinaryRequest as g, BufferSink as h, type CPythonOptions as i, CallbackSink as j, CommandRegistry as k, ContainerFs as l, type ContainerOptions as m, type ContextInit as n, type Env as o, type ExecOptions as p, type ExecResult as q, type ExecutionDecision as r, type ExecutionTier as s, FileInput as t, FileOutput as u, type KernelOptions as v, MANIFEST_SCHEMA_VERSION as w, type MountEntry as x, type NetInterface as y, type NetworkOptions as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { V as Vfs, C as Cred, f as RuntimePod, D as DirEntry, p as Stats } from './contracts-
|
|
1
|
+
import { V as Vfs, C as Cred, f as RuntimePod, O as OutboundPolicy, D as DirEntry, p as Stats } from './contracts-C2_dTgk3.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Byte streams for stdin/stdout/stderr, pipelines and redirections.
|
|
@@ -487,6 +487,8 @@ declare class NetworkStack {
|
|
|
487
487
|
timeoutMs?: number;
|
|
488
488
|
intervalMs?: number;
|
|
489
489
|
}): Promise<boolean>;
|
|
490
|
+
/** The policy every way out of the container applies, not only the shell's. */
|
|
491
|
+
get policy(): OutboundPolicy;
|
|
490
492
|
outboundAllowed(url: string): boolean;
|
|
491
493
|
procNetDev(): string;
|
|
492
494
|
procNetRoute(): string;
|
|
@@ -494,6 +496,83 @@ declare class NetworkStack {
|
|
|
494
496
|
countRx(bytes: number, iface?: string): void;
|
|
495
497
|
}
|
|
496
498
|
|
|
499
|
+
type ExecutionTier = "compatibility" | "translation" | "emulation";
|
|
500
|
+
interface BinaryInfo {
|
|
501
|
+
format: "elf";
|
|
502
|
+
bits: 32 | 64;
|
|
503
|
+
machine: number;
|
|
504
|
+
architecture: string;
|
|
505
|
+
littleEndian: boolean;
|
|
506
|
+
}
|
|
507
|
+
interface BinaryRequest {
|
|
508
|
+
path: string;
|
|
509
|
+
bytes: Uint8Array;
|
|
510
|
+
sha256: string;
|
|
511
|
+
info: BinaryInfo;
|
|
512
|
+
}
|
|
513
|
+
interface PreparedBinary {
|
|
514
|
+
/** Once execution begins, failure never retries another backend: effects may exist. */
|
|
515
|
+
run(ctx: ExecContext): Promise<number> | number;
|
|
516
|
+
}
|
|
517
|
+
type Preparation = {
|
|
518
|
+
supported: true;
|
|
519
|
+
program: PreparedBinary;
|
|
520
|
+
} | {
|
|
521
|
+
supported: false;
|
|
522
|
+
reason: string;
|
|
523
|
+
};
|
|
524
|
+
interface BinaryBackend {
|
|
525
|
+
id: string;
|
|
526
|
+
tier: ExecutionTier;
|
|
527
|
+
/** Host-supplied trusted code. Preparation must not execute the guest or mutate its files. */
|
|
528
|
+
prepare(request: BinaryRequest, signal: AbortSignal): Promise<Preparation> | Preparation;
|
|
529
|
+
}
|
|
530
|
+
interface ExecutionDecision {
|
|
531
|
+
path: string;
|
|
532
|
+
backend: string;
|
|
533
|
+
tier: ExecutionTier;
|
|
534
|
+
supported: boolean;
|
|
535
|
+
reason?: string;
|
|
536
|
+
}
|
|
537
|
+
declare function binaryDigest(bytes: Uint8Array): string;
|
|
538
|
+
declare function isElfBinary(bytes: Uint8Array): boolean;
|
|
539
|
+
declare function inspectElf(bytes: Uint8Array): BinaryInfo;
|
|
540
|
+
/** Per-container backend registry. No vendor packages or network services are built in. */
|
|
541
|
+
declare class BinaryExecutionRegistry {
|
|
542
|
+
private readonly onDecision?;
|
|
543
|
+
private backends;
|
|
544
|
+
constructor(onDecision?: ((decision: ExecutionDecision) => void) | undefined);
|
|
545
|
+
register(backend: BinaryBackend): () => void;
|
|
546
|
+
clear(): void;
|
|
547
|
+
list(): {
|
|
548
|
+
id: string;
|
|
549
|
+
tier: ExecutionTier;
|
|
550
|
+
}[];
|
|
551
|
+
run(ctx: ExecContext, path: string): Promise<number>;
|
|
552
|
+
}
|
|
553
|
+
interface WasmCommandArtifact {
|
|
554
|
+
name: string;
|
|
555
|
+
bytes: Uint8Array;
|
|
556
|
+
/** Exact SHA-256 hex digest from the package's trusted manifest. */
|
|
557
|
+
sha256: string;
|
|
558
|
+
}
|
|
559
|
+
/** Install a host-loaded pack of WASI commands. Nothing is fetched implicitly. */
|
|
560
|
+
declare function installWasmCommands(kernel: Kernel, artifacts: WasmCommandArtifact[]): void;
|
|
561
|
+
/** Match exact Linux artifacts to their independently built, ABI-compatible WASI ports. */
|
|
562
|
+
declare function createWasmCompatibilityBackend(id: string, entries: {
|
|
563
|
+
elfSha256: string;
|
|
564
|
+
wasm: WasmCommandArtifact;
|
|
565
|
+
}[]): BinaryBackend;
|
|
566
|
+
interface WasmTranslator {
|
|
567
|
+
/** Versioned compiler identity: change when flags, compiler or syscall ABI changes. */
|
|
568
|
+
id: string;
|
|
569
|
+
supports(info: BinaryInfo): boolean;
|
|
570
|
+
/** Supply a real compiler here. Null means unsupported, not a guest runtime failure. */
|
|
571
|
+
translate(request: BinaryRequest, signal: AbortSignal): Promise<Uint8Array | null>;
|
|
572
|
+
}
|
|
573
|
+
/** Bounded, content-addressed cache around a host-provided ELF → WASI translator. */
|
|
574
|
+
declare function createTranslationBackend(translator: WasmTranslator, maxCacheBytes?: number): BinaryBackend;
|
|
575
|
+
|
|
497
576
|
/**
|
|
498
577
|
* The kernel: the object that owns the filesystem, the process table, the user
|
|
499
578
|
* database and the executable namespace, and knows how to turn an `argv` into
|
|
@@ -540,7 +619,7 @@ interface RunResult {
|
|
|
540
619
|
signal: string | null;
|
|
541
620
|
timedOut: boolean;
|
|
542
621
|
}
|
|
543
|
-
type ExecutableKind = "builtin" | "script" | "unknown";
|
|
622
|
+
type ExecutableKind = "builtin" | "script" | "native" | "unknown";
|
|
544
623
|
interface ResolvedExecutable {
|
|
545
624
|
kind: ExecutableKind;
|
|
546
625
|
/** Absolute path of the file that was found. */
|
|
@@ -561,6 +640,7 @@ declare class Kernel {
|
|
|
561
640
|
readonly vfs: Vfs;
|
|
562
641
|
readonly procs: ProcessTable;
|
|
563
642
|
readonly commands: CommandRegistry;
|
|
643
|
+
readonly binaries: BinaryExecutionRegistry;
|
|
564
644
|
readonly users: UserDatabase;
|
|
565
645
|
readonly pod: RuntimePod;
|
|
566
646
|
readonly bootTime: number;
|
|
@@ -979,8 +1059,13 @@ declare class Shell {
|
|
|
979
1059
|
captureSubshell(command: string): Promise<string>;
|
|
980
1060
|
/** `<(cmd)` — run the command now and hand back a path holding its output. */
|
|
981
1061
|
private makeProcessSubstitution;
|
|
982
|
-
/**
|
|
983
|
-
|
|
1062
|
+
/**
|
|
1063
|
+
* A copy that shares nothing mutable with this shell.
|
|
1064
|
+
*
|
|
1065
|
+
* Subshells and pipeline stages run as part of this shell's process. A
|
|
1066
|
+
* background job passes a process of its own, the way fork(2) gives one.
|
|
1067
|
+
*/
|
|
1068
|
+
fork(proc?: Process): Shell;
|
|
984
1069
|
private currentIO;
|
|
985
1070
|
run(node: Node, io: ShellIO): Promise<number>;
|
|
986
1071
|
private runList;
|
|
@@ -1543,6 +1628,14 @@ declare class Container {
|
|
|
1543
1628
|
}): Session;
|
|
1544
1629
|
/** The container-wide session used by `shell()` shorthand helpers. */
|
|
1545
1630
|
get shell(): Session;
|
|
1631
|
+
/**
|
|
1632
|
+
* The streams one call collects into.
|
|
1633
|
+
*
|
|
1634
|
+
* They are detachable because a background job started by the command keeps
|
|
1635
|
+
* writing after the call has returned. Nothing reads the result any more by
|
|
1636
|
+
* then, so without `detach` a chatty server would grow the buffer for as long
|
|
1637
|
+
* as it ran; afterwards its output still reaches the container-wide taps.
|
|
1638
|
+
*/
|
|
1546
1639
|
private makeStdio;
|
|
1547
1640
|
/** Send an HTTP request to a server running inside the container. */
|
|
1548
1641
|
request(port: number, init?: {
|
|
@@ -1620,4 +1713,4 @@ declare class Container {
|
|
|
1620
1713
|
/** Boot a container. The one function most callers need. */
|
|
1621
1714
|
declare function createContainer(opts?: ContainerOptions): Promise<Container>;
|
|
1622
1715
|
|
|
1623
|
-
export { type
|
|
1716
|
+
export { type PythonCapabilities as $, NetworkStack as A, type BinaryBackend as B, Container as C, NullInput 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, NullOutput as P, PYTHON_VERSION as Q, type PasswdEntry as R, Shell as S, Pipe as T, type Preparation as U, type PreparedBinary as V, Process as W, type ProcessKind as X, type ProcessOptions as Y, type ProcessState as Z, ProcessTable as _, type ShellIO as a, type PythonOptions as a0, type PythonProfile as a1, type PythonRuntimeManifest as a2, type ResolvedExecutable as a3, type RunOptions as a4, type RunResult as a5, type SessionInit as a6, type SessionResult as a7, type SessionRunOptions as a8, ShellExit as a9, shellQuote as aA, validateManifest as aB, type ShellInit as aa, type ShellOptions as ab, type SpawnHandle as ac, type Stdio as ad, TeeOutput as ae, UserDatabase as af, Variables as ag, type WasmCommandArtifact as ah, type WasmTranslator as ai, binaryDigest as aj, braceExpand as ak, captureStdio as al, configureCPython as am, configurePython as an, createContext as ao, createTranslationBackend as ap, createWasmCompatibilityBackend as aq, defineCommand as ar, expandWord as as, expandWords as at, inspectElf as au, installWasmCommands as av, isCPythonAvailable as aw, isElfBinary as ax, isPythonAvailable as ay, resetPidCounter as az, Session as b, type Command as c, createContainer as d, BinaryExecutionRegistry as e, type BinaryInfo as f, type BinaryRequest as g, BufferSink as h, type CPythonOptions as i, CallbackSink as j, CommandRegistry as k, ContainerFs as l, type ContainerOptions as m, type ContextInit as n, type Env as o, type ExecOptions as p, type ExecResult as q, type ExecutionDecision as r, type ExecutionTier as s, FileInput as t, FileOutput as u, type KernelOptions as v, MANIFEST_SCHEMA_VERSION as w, type MountEntry as x, type NetInterface as y, type NetworkOptions as z };
|
|
@@ -347,6 +347,27 @@ declare class VirtualTcpNetwork {
|
|
|
347
347
|
closeAll(): void;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
+
/**
|
|
351
|
+
* The outbound network policy, as plain functions every client consults.
|
|
352
|
+
*
|
|
353
|
+
* The container has several ways out — `curl` and `wget` in the shell, `http`,
|
|
354
|
+
* `https`, `fetch` and `WebSocket` in a Node program, sockets in Python — and
|
|
355
|
+
* they used to decide separately. Only the shell asked: a Node program's
|
|
356
|
+
* `fetch("https://…")` reached the internet from a container booted with
|
|
357
|
+
* outbound access off. One policy, applied at each exit, is what makes
|
|
358
|
+
* `network: { allowOutbound: false }` mean what it says.
|
|
359
|
+
*
|
|
360
|
+
* Loopback is not "outbound" at all. `127.0.0.1` inside the container is the
|
|
361
|
+
* container, so those requests are routed to its own servers and never handed
|
|
362
|
+
* to the host's network stack, whatever the policy allows.
|
|
363
|
+
*/
|
|
364
|
+
interface OutboundPolicy {
|
|
365
|
+
/** Whether requests may leave the container at all. */
|
|
366
|
+
allowOutbound: boolean;
|
|
367
|
+
/** When outbound is on, the hosts it may reach (subdomains included). `null` means any. */
|
|
368
|
+
allowedHosts: string[] | null;
|
|
369
|
+
}
|
|
370
|
+
|
|
350
371
|
/**
|
|
351
372
|
* Clean-room contracts between SandboxedJS and its JavaScript runtime.
|
|
352
373
|
*
|
|
@@ -479,9 +500,17 @@ interface RuntimePod {
|
|
|
479
500
|
headers: Record<string, string>;
|
|
480
501
|
body: Uint8Array;
|
|
481
502
|
}) => Promise<RuntimeHttpResponse>): () => void;
|
|
503
|
+
/**
|
|
504
|
+
* Apply the container's outbound policy to programs this pod runs.
|
|
505
|
+
*
|
|
506
|
+
* Optional so a pod written elsewhere still satisfies the contract, but a pod
|
|
507
|
+
* without it cannot keep a program's own `fetch` inside the policy — only
|
|
508
|
+
* the shell's `curl` would honour it.
|
|
509
|
+
*/
|
|
510
|
+
setNetworkPolicy?(policy: OutboundPolicy): void;
|
|
482
511
|
snapshot(options?: Record<string, unknown>): unknown;
|
|
483
512
|
restore(snapshot: unknown, options?: Record<string, unknown>): Promise<void>;
|
|
484
513
|
teardown(): void;
|
|
485
514
|
}
|
|
486
515
|
|
|
487
|
-
export { type Cred as C, type DirEntry as D, type RuntimeVolume as R, type SpawnChild as S, Vfs as V, type WriteOptions as W, VirtualTcpNetwork as a, type RuntimeHttpResponse as b, type SyncSpawn as c, type VolumeStat as d, type VolumeStats as e, type RuntimePod as f, type RuntimePackageInstaller as g, type ChildSpawnConfig as h, type ChildHandle as i, type RuntimeProcess as j, type RuntimeSocketPeer as k, type RuntimeConnection as l, ROOT_CRED as m, type RuntimeProcessManager as n, type RuntimeProcessResult as o, Stats as p, type VirtualNode as q, type VirtualProvider as r, applyChmod as s, createChildProcessModule as t, formatMode as u, makeCred as v, octalMode as w, parseUmask as x };
|
|
516
|
+
export { type Cred as C, type DirEntry as D, type OutboundPolicy as O, type RuntimeVolume as R, type SpawnChild as S, Vfs as V, type WriteOptions as W, VirtualTcpNetwork as a, type RuntimeHttpResponse as b, type SyncSpawn as c, type VolumeStat as d, type VolumeStats as e, type RuntimePod as f, type RuntimePackageInstaller as g, type ChildSpawnConfig as h, type ChildHandle as i, type RuntimeProcess as j, type RuntimeSocketPeer as k, type RuntimeConnection as l, ROOT_CRED as m, type RuntimeProcessManager as n, type RuntimeProcessResult as o, Stats as p, type VirtualNode as q, type VirtualProvider as r, applyChmod as s, createChildProcessModule as t, formatMode as u, makeCred as v, octalMode as w, parseUmask as x };
|
|
@@ -347,6 +347,27 @@ declare class VirtualTcpNetwork {
|
|
|
347
347
|
closeAll(): void;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
+
/**
|
|
351
|
+
* The outbound network policy, as plain functions every client consults.
|
|
352
|
+
*
|
|
353
|
+
* The container has several ways out — `curl` and `wget` in the shell, `http`,
|
|
354
|
+
* `https`, `fetch` and `WebSocket` in a Node program, sockets in Python — and
|
|
355
|
+
* they used to decide separately. Only the shell asked: a Node program's
|
|
356
|
+
* `fetch("https://…")` reached the internet from a container booted with
|
|
357
|
+
* outbound access off. One policy, applied at each exit, is what makes
|
|
358
|
+
* `network: { allowOutbound: false }` mean what it says.
|
|
359
|
+
*
|
|
360
|
+
* Loopback is not "outbound" at all. `127.0.0.1` inside the container is the
|
|
361
|
+
* container, so those requests are routed to its own servers and never handed
|
|
362
|
+
* to the host's network stack, whatever the policy allows.
|
|
363
|
+
*/
|
|
364
|
+
interface OutboundPolicy {
|
|
365
|
+
/** Whether requests may leave the container at all. */
|
|
366
|
+
allowOutbound: boolean;
|
|
367
|
+
/** When outbound is on, the hosts it may reach (subdomains included). `null` means any. */
|
|
368
|
+
allowedHosts: string[] | null;
|
|
369
|
+
}
|
|
370
|
+
|
|
350
371
|
/**
|
|
351
372
|
* Clean-room contracts between SandboxedJS and its JavaScript runtime.
|
|
352
373
|
*
|
|
@@ -479,9 +500,17 @@ interface RuntimePod {
|
|
|
479
500
|
headers: Record<string, string>;
|
|
480
501
|
body: Uint8Array;
|
|
481
502
|
}) => Promise<RuntimeHttpResponse>): () => void;
|
|
503
|
+
/**
|
|
504
|
+
* Apply the container's outbound policy to programs this pod runs.
|
|
505
|
+
*
|
|
506
|
+
* Optional so a pod written elsewhere still satisfies the contract, but a pod
|
|
507
|
+
* without it cannot keep a program's own `fetch` inside the policy — only
|
|
508
|
+
* the shell's `curl` would honour it.
|
|
509
|
+
*/
|
|
510
|
+
setNetworkPolicy?(policy: OutboundPolicy): void;
|
|
482
511
|
snapshot(options?: Record<string, unknown>): unknown;
|
|
483
512
|
restore(snapshot: unknown, options?: Record<string, unknown>): Promise<void>;
|
|
484
513
|
teardown(): void;
|
|
485
514
|
}
|
|
486
515
|
|
|
487
|
-
export { type Cred as C, type DirEntry as D, type RuntimeVolume as R, type SpawnChild as S, Vfs as V, type WriteOptions as W, VirtualTcpNetwork as a, type RuntimeHttpResponse as b, type SyncSpawn as c, type VolumeStat as d, type VolumeStats as e, type RuntimePod as f, type RuntimePackageInstaller as g, type ChildSpawnConfig as h, type ChildHandle as i, type RuntimeProcess as j, type RuntimeSocketPeer as k, type RuntimeConnection as l, ROOT_CRED as m, type RuntimeProcessManager as n, type RuntimeProcessResult as o, Stats as p, type VirtualNode as q, type VirtualProvider as r, applyChmod as s, createChildProcessModule as t, formatMode as u, makeCred as v, octalMode as w, parseUmask as x };
|
|
516
|
+
export { type Cred as C, type DirEntry as D, type OutboundPolicy as O, type RuntimeVolume as R, type SpawnChild as S, Vfs as V, type WriteOptions as W, VirtualTcpNetwork as a, type RuntimeHttpResponse as b, type SyncSpawn as c, type VolumeStat as d, type VolumeStats as e, type RuntimePod as f, type RuntimePackageInstaller as g, type ChildSpawnConfig as h, type ChildHandle as i, type RuntimeProcess as j, type RuntimeSocketPeer as k, type RuntimeConnection as l, ROOT_CRED as m, type RuntimeProcessManager as n, type RuntimeProcessResult as o, Stats as p, type VirtualNode as q, type VirtualProvider as r, applyChmod as s, createChildProcessModule as t, formatMode as u, makeCred as v, octalMode as w, parseUmask as x };
|