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/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { S as Shell, a as ShellIO, b as Session, N as Node, c as Command, K as Kernel, E as ExecContext, O as OutputStream, C as Container, d as createContainer } from './container-BxEoVOmX.cjs';
2
- export { B as BufferSink, e as CPythonOptions, f as CallbackSink, g as CommandRegistry, h as ContainerFs, i as ContainerOptions, j as ContextInit, k as Env, l as ExecOptions, m as ExecResult, F as FileData, n as FileInput, o as FileOutput, G as GroupEntry, H as HttpResponse, I as InputStream, J as Job, p as KernelOptions, L as ListeningPort, M as MANIFEST_FORMAT, q as MANIFEST_SCHEMA_VERSION, r as MountEntry, s as NetInterface, t as NetworkOptions, u as NetworkStack, v as NullInput, w as NullOutput, P as PYTHON_VERSION, x as PasswdEntry, y as Pipe, z as Process, A as ProcessKind, D as ProcessOptions, Q as ProcessState, R as ProcessTable, T as PythonCapabilities, U as PythonOptions, V as PythonProfile, W as PythonRuntimeManifest, X as ResolvedExecutable, Y as RunOptions, Z as RunResult, _ as SessionInit, $ as SessionResult, a0 as SessionRunOptions, a1 as ShellExit, a2 as ShellInit, a3 as ShellOptions, a4 as SpawnHandle, a5 as Stdio, a6 as TeeOutput, a7 as UserDatabase, a8 as Variables, a9 as braceExpand, aa as captureStdio, ab as configureCPython, ac as configurePython, ad as createContext, ae as defineCommand, af as expandWord, ag as expandWords, ah as isCPythonAvailable, ai as isPythonAvailable, aj as resetPidCounter, ak as shellQuote, al as validateManifest } from './container-BxEoVOmX.cjs';
3
- import { V as Vfs, C as Cred, R as RuntimeVolume, a as VirtualTcpNetwork, b as RuntimeHttpResponse, S as SpawnChild, c as SyncSpawn, d as VolumeStat, e as VolumeStats, f as RuntimePod, g as RuntimePackageInstaller, h as ChildSpawnConfig, i as ChildHandle, j as RuntimeProcess, k as RuntimeSocketPeer, l as RuntimeConnection } from './contracts-CVgctitO.cjs';
4
- export { D as DirEntry, m as ROOT_CRED, n as RuntimeProcessManager, o as RuntimeProcessResult, p as Stats, q as VirtualNode, r as VirtualProvider, W as WriteOptions, s as applyChmod, t as createChildProcessModule, u as formatMode, v as makeCred, w as octalMode, x as parseUmask } from './contracts-CVgctitO.cjs';
5
- import { M as MemoryVolume, a as MemoryVolumeSnapshotEntry } from './memory-volume-DlMSAh-K.cjs';
1
+ import { S as Shell, a as ShellIO, b as Session, N as Node, c as Command, K as Kernel, E as ExecContext, O as OutputStream, C as Container, B as BinaryBackend, d as createContainer } from './container-NoLUp_fd.cjs';
2
+ export { e as BinaryExecutionRegistry, f as BinaryInfo, g as BinaryRequest, h as BufferSink, i as CPythonOptions, j as CallbackSink, k as CommandRegistry, l as ContainerFs, m as ContainerOptions, n as ContextInit, o as Env, p as ExecOptions, q as ExecResult, r as ExecutionDecision, s as ExecutionTier, F as FileData, t as FileInput, u as FileOutput, G as GroupEntry, H as HttpResponse, I as InputStream, J as Job, v as KernelOptions, L as ListeningPort, M as MANIFEST_FORMAT, w as MANIFEST_SCHEMA_VERSION, x as MountEntry, y as NetInterface, z as NetworkOptions, A as NetworkStack, D as NullInput, P as NullOutput, Q as PYTHON_VERSION, R as PasswdEntry, T as Pipe, U as Preparation, V as PreparedBinary, W as Process, X as ProcessKind, Y as ProcessOptions, Z as ProcessState, _ as ProcessTable, $ as PythonCapabilities, a0 as PythonOptions, a1 as PythonProfile, a2 as PythonRuntimeManifest, a3 as ResolvedExecutable, a4 as RunOptions, a5 as RunResult, a6 as SessionInit, a7 as SessionResult, a8 as SessionRunOptions, a9 as ShellExit, aa as ShellInit, ab as ShellOptions, ac as SpawnHandle, ad as Stdio, ae as TeeOutput, af as UserDatabase, ag as Variables, ah as WasmCommandArtifact, ai as WasmTranslator, aj as binaryDigest, ak as braceExpand, al as captureStdio, am as configureCPython, an as configurePython, ao as createContext, ap as createTranslationBackend, aq as createWasmCompatibilityBackend, ar as defineCommand, as as expandWord, at as expandWords, au as inspectElf, av as installWasmCommands, aw as isCPythonAvailable, ax as isElfBinary, ay as isPythonAvailable, az as resetPidCounter, aA as shellQuote, aB as validateManifest } from './container-NoLUp_fd.cjs';
3
+ import { V as Vfs, C as Cred, R as RuntimeVolume, a as VirtualTcpNetwork, b as RuntimeHttpResponse, O as OutboundPolicy, S as SpawnChild, c as SyncSpawn, d as VolumeStat, e as VolumeStats, f as RuntimePod, g as RuntimePackageInstaller, h as ChildSpawnConfig, i as ChildHandle, j as RuntimeProcess, k as RuntimeSocketPeer, l as RuntimeConnection } from './contracts-C2_dTgk3.cjs';
4
+ export { D as DirEntry, m as ROOT_CRED, n as RuntimeProcessManager, o as RuntimeProcessResult, p as Stats, q as VirtualNode, r as VirtualProvider, W as WriteOptions, s as applyChmod, t as createChildProcessModule, u as formatMode, v as makeCred, w as octalMode, x as parseUmask } from './contracts-C2_dTgk3.cjs';
5
+ import { M as MemoryVolume, a as MemoryVolumeSnapshotEntry } from './memory-volume-DqEWFo7t.cjs';
6
6
  import EventEmitter from 'events/events.js';
7
7
  import streamModule from 'stream-browserify';
8
8
 
@@ -213,6 +213,7 @@ declare const ERRNO: {
213
213
  readonly ECONNRESET: 104;
214
214
  readonly ENOTCONN: 107;
215
215
  readonly ETIMEDOUT: 110;
216
+ readonly ENETUNREACH: 101;
216
217
  readonly ECONNREFUSED: 111;
217
218
  readonly EHOSTUNREACH: 113;
218
219
  readonly ENOTSUP: 95;
@@ -735,6 +736,24 @@ interface VirtualConnection {
735
736
  /** The far end went away. */
736
737
  close(): void;
737
738
  }
739
+ /** A loopback request, as it crosses from a program to whoever holds the port. */
740
+ interface LoopbackRequest {
741
+ method: string;
742
+ path: string;
743
+ headers: Record<string, string>;
744
+ body: Uint8Array | null;
745
+ }
746
+ interface LoopbackResponse {
747
+ statusCode?: number;
748
+ statusMessage?: string;
749
+ headers?: Record<string, string>;
750
+ body?: string | ArrayBuffer | Uint8Array | null;
751
+ }
752
+ /**
753
+ * Reaches a server in this container that is not on this thread's router.
754
+ * Resolves `null` when nothing in the container listens on the port.
755
+ */
756
+ type LoopbackTransport = (port: number, request: LoopbackRequest) => Promise<LoopbackResponse | null>;
738
757
 
739
758
  interface CoreModulesOptions {
740
759
  volume: RuntimeVolume;
@@ -748,6 +767,13 @@ interface CoreModulesOptions {
748
767
  router: VirtualHttpRouter;
749
768
  owner: string;
750
769
  fetch?: typeof globalThis.fetch;
770
+ /** Servers in other processes, for a router that holds only this thread's. */
771
+ loopback?: LoopbackTransport;
772
+ /**
773
+ * The container's outbound policy, applied to `fetch`, `http`, `https` and
774
+ * `WebSocket`. Omitted, requests leave the way the host's own would.
775
+ */
776
+ policy?: OutboundPolicy;
751
777
  };
752
778
  /** Backs `child_process`; without it the module reports as unavailable. */
753
779
  spawnChild?: SpawnChild;
@@ -813,6 +839,14 @@ declare function createCoreModules(options: CoreModulesOptions): {
813
839
  * exiting in the gap between `http.get` and its response callback.
814
840
  */
815
841
  pendingRequests(): number;
842
+ /** An error that escaped the program's callbacks: listeners, or print and exit 1. */
843
+ reportUncaught(error: unknown): void;
844
+ /** A rejection nobody handled, under the same rule. */
845
+ reportUnhandledRejection(reason: unknown): void;
846
+ /** The status a program ends with: `process.exit`'s code, else `process.exitCode`. */
847
+ exitStatus(): number;
848
+ /** Run `process.on("exit")` listeners once, for a program that ended by itself. */
849
+ emitExit(status: number): void;
816
850
  };
817
851
 
818
852
  interface EsmTransformResult {
@@ -996,6 +1030,12 @@ interface LocalRuntimeOptions {
996
1030
  files?: Record<string, string | Uint8Array>;
997
1031
  registry?: string;
998
1032
  fetch?: typeof globalThis.fetch;
1033
+ /**
1034
+ * The outbound policy for guest `fetch`, `http`, `https` and `WebSocket`.
1035
+ * Omitted, guest requests leave the way the host's would; `createContainer`
1036
+ * always supplies one, closed unless the caller opens it.
1037
+ */
1038
+ network?: OutboundPolicy;
999
1039
  /** Invoked when a program inside the runtime starts listening on a port. */
1000
1040
  onServerReady?: (port: number, url: string) => void;
1001
1041
  /** Extra package substitutions, merged over {@link WASM_ALIASES}. */
@@ -1067,8 +1107,12 @@ declare class LocalRuntimePod implements RuntimePod {
1067
1107
  private rolldownBinding;
1068
1108
  /** Backs outbound `http`/`https` client requests from inside the sandbox. */
1069
1109
  private readonly fetch;
1110
+ /** What guest programs may reach outside the container. */
1111
+ protected networkPolicy: OutboundPolicy | undefined;
1070
1112
  protected constructor(options: LocalRuntimeOptions);
1071
1113
  static boot(options?: LocalRuntimeOptions): Promise<LocalRuntimePod>;
1114
+ /** Apply a container's outbound policy to programs started from now on. */
1115
+ setNetworkPolicy(policy: OutboundPolicy): void;
1072
1116
  spawn(command: string, args?: string[], options?: Record<string, unknown>): Promise<RuntimeProcess>;
1073
1117
  /**
1074
1118
  * Rolldown's JavaScript API synchronously requires its compiled binding.
@@ -1164,6 +1208,15 @@ declare class WorkerRuntimePod extends LocalRuntimePod {
1164
1208
  * the two directions together across the Worker boundary.
1165
1209
  */
1166
1210
  private upgrade;
1211
+ /**
1212
+ * Answer a program that is calling a server in this container.
1213
+ *
1214
+ * A guest's router holds only the servers on its own thread, so a request to
1215
+ * a port some other process opened comes here, where every server in the
1216
+ * container is registered. `null` means nothing listens, which the guest
1217
+ * reports as a refused connection.
1218
+ */
1219
+ private answerLoopback;
1167
1220
  private settleProxied;
1168
1221
  private closeProxies;
1169
1222
  teardown(): void;
@@ -1204,10 +1257,10 @@ declare class CleanPackageInstaller implements RuntimePackageInstaller {
1204
1257
  readonly options: CleanInstallerOptions;
1205
1258
  private readonly registry;
1206
1259
  private readonly fetcher;
1207
- private readonly metadata;
1208
- private readonly tarballs;
1260
+ private metadata;
1261
+ private tarballs;
1209
1262
  /** Single-version manifests, for the fields the packument omits. */
1210
- private readonly details;
1263
+ private details;
1211
1264
  constructor(volume: RuntimeVolume, options?: CleanInstallerOptions);
1212
1265
  forCwd(cwd: string): CleanPackageInstaller;
1213
1266
  install(name: string, version?: string, options?: InstallOptions): Promise<RegistryManifest>;
@@ -1228,6 +1281,8 @@ declare class CleanPackageInstaller implements RuntimePackageInstaller {
1228
1281
  * being right and strictly more than refusing to install.
1229
1282
  */
1230
1283
  private platformDetail;
1284
+ /** Overlap up to six sibling downloads; filesystem writes remain ordered. */
1285
+ private prefetch;
1231
1286
  private getMetadata;
1232
1287
  private getTarball;
1233
1288
  private createBinLinks;
@@ -1621,6 +1676,117 @@ declare function renderInto(box: Container, element: HTMLElement, options?: {
1621
1676
  path?: string;
1622
1677
  }): Promise<HTMLIFrameElement>;
1623
1678
 
1679
+ /** Structural contracts keep optional engines out of the core dependency graph. */
1680
+ interface SqlDatabase {
1681
+ exec(sql: string): Promise<{
1682
+ rows: unknown[];
1683
+ }[]>;
1684
+ }
1685
+ /** A deliberately small SQL CLI, not a PostgreSQL daemon or psql emulation. */
1686
+ declare function createSqlCommand(database: SqlDatabase, name?: string): Command;
1687
+ interface GitEngine {
1688
+ init(options: any): Promise<any>;
1689
+ add(options: any): Promise<any>;
1690
+ commit(options: any): Promise<string>;
1691
+ log(options: any): Promise<any[]>;
1692
+ statusMatrix(options: any): Promise<[string, number, number, number][]>;
1693
+ }
1694
+ /** Local Git subset. No implicit network, credentials, proxy, or external service. */
1695
+ declare function createGitCommand(git: GitEngine): Command;
1696
+
1697
+ /** Original experimental x86-64 ELF engine. No third-party CPU/compiler code. */
1698
+
1699
+ interface OriginalX64Options {
1700
+ maxInstructions?: number;
1701
+ }
1702
+ /** Experimental original engines: only static freestanding programs using documented opcodes. */
1703
+ declare function createOriginalX64Backends(options?: OriginalX64Options): BinaryBackend[];
1704
+
1705
+ /** Frontend-only DOM automation. Uses the host browser; does not bundle Chromium. */
1706
+ interface FrontendAutomationOptions {
1707
+ /** Trusted host-owned mount for visible test frames. Defaults to document.body. */
1708
+ mount?: HTMLElement;
1709
+ /** Map a virtual server URL to a same-origin preview URL. */
1710
+ resolveUrl?: (url: string) => string | Promise<string>;
1711
+ timeoutMs?: number;
1712
+ }
1713
+ declare class FrontendAutomationUnsupported extends Error {
1714
+ readonly code = "ERR_FRONTEND_AUTOMATION_UNSUPPORTED";
1715
+ }
1716
+ declare class FrontendLocator {
1717
+ private readonly query;
1718
+ private readonly timeout;
1719
+ constructor(query: () => Element[], timeout: () => number);
1720
+ first(): FrontendLocator;
1721
+ nth(index: number): FrontendLocator;
1722
+ locator(selector: string): FrontendLocator;
1723
+ count(): Promise<number>;
1724
+ isVisible(): Promise<boolean>;
1725
+ private element;
1726
+ textContent(): Promise<string | null>;
1727
+ innerText(): Promise<string>;
1728
+ inputValue(): Promise<string>;
1729
+ getAttribute(name: string): Promise<string | null>;
1730
+ click(): Promise<void>;
1731
+ fill(value: string): Promise<void>;
1732
+ waitFor(options?: {
1733
+ state?: "visible" | "hidden" | "attached" | "detached";
1734
+ timeout?: number;
1735
+ }): Promise<void>;
1736
+ }
1737
+ declare class FrontendPage {
1738
+ private readonly options;
1739
+ private readonly frame;
1740
+ private timeout;
1741
+ private closed;
1742
+ constructor(options: FrontendAutomationOptions);
1743
+ private doc;
1744
+ setDefaultTimeout(ms: number): void;
1745
+ locator(selector: string): FrontendLocator;
1746
+ getByTestId(value: string): FrontendLocator;
1747
+ getByText(text: string, options?: {
1748
+ exact?: boolean;
1749
+ }): FrontendLocator;
1750
+ getByRole(role: string, options?: {
1751
+ name?: string;
1752
+ }): FrontendLocator;
1753
+ private navigate;
1754
+ setContent(html: string): Promise<void>;
1755
+ goto(url: string): Promise<null>;
1756
+ title(): Promise<string>;
1757
+ content(): Promise<string>;
1758
+ evaluate<T, A = undefined>(fn: ((arg: A) => T) | string, arg?: A): Promise<T>;
1759
+ screenshot(): Promise<never>;
1760
+ route(): Promise<never>;
1761
+ close(): Promise<void>;
1762
+ }
1763
+ declare function createFrontendPlaywright(options?: FrontendAutomationOptions): {
1764
+ capabilities: Readonly<{
1765
+ engine: "host-browser";
1766
+ fullPlaywright: false;
1767
+ screenshots: false;
1768
+ crossOrigin: false;
1769
+ trustedEvents: false;
1770
+ }>;
1771
+ chromium: {
1772
+ launch: (launchOptions?: Record<string, unknown>) => Promise<{
1773
+ newPage(): Promise<FrontendPage>;
1774
+ close(): Promise<void>;
1775
+ }>;
1776
+ };
1777
+ firefox: {
1778
+ launch: () => Promise<never>;
1779
+ };
1780
+ webkit: {
1781
+ launch: () => Promise<never>;
1782
+ };
1783
+ dispose(): Promise<void>;
1784
+ expect(locator: FrontendLocator): {
1785
+ toBeVisible(): Promise<void>;
1786
+ toHaveText(text: string): Promise<void>;
1787
+ };
1788
+ };
1789
+
1624
1790
  /**
1625
1791
  * sandboxedjs — a Linux-like container that runs entirely inside Node.js.
1626
1792
  *
@@ -1639,4 +1805,4 @@ declare function renderInto(box: Container, element: HTMLElement, options?: {
1639
1805
  * ```
1640
1806
  */
1641
1807
 
1642
- export { ArithError, ChildHandle, ChildSpawnConfig, type CleanInstallerOptions, CleanPackageInstaller, Command, CommonJsEngine, type CommonJsEngineOptions, type CommonJsModule, Container, type ContainerTarget, type CoreModulesOptions, Cred, ERRNO, type ErrnoCode, type EsmTransformResult, ExecContext, IncompleteInputError, type InstallOptions, KERNEL_NAME, KERNEL_RELEASE, Kernel, type LocalRuntimeOptions, LocalRuntimePod, MemoryVolume, NODE_VERSION, NPM_VERSION, OS_RELEASE, OutputStream, type Preview, type PreviewOptions, type RootfsOptions, type RunWasiOptions, RuntimePackageInstaller, RuntimePod, RuntimeProcess, RuntimeVolume, SIGNALS, SIGNAL_NAMES, Session, Shell, ShellIO, Lexer as ShellLexer, ShellSyntaxError, SpawnChild, SysError, Terminal, type TerminalOptions, Vfs, VirtualHttpRouter, VirtualHttpServer, VirtualIncomingMessage, VirtualServerResponse, WASM_ALIASES, WasiError, WasiExit, WasiHost, type WasiHostOptions, type WasiStdin, type WorkerRuntimeOptions, WorkerRuntimePod, allCommands, buildRootfs, builtinNames, containerTarget, createContainer, createCoreModules, createPreview, createContainer as default, evalArith, exitCodeForSignal, expandPrompt, extractNpmTarball, fnmatch, getBuiltin, glob, globToRegex, hasMagic, installUserland, isBuiltinName, isSysError, isWasmBinary, looksLikeEsm, normalizeSignal, parse as parseShell, path as posixPath, renderInto, runWasi, startRuntimeWorker, strerror, syncChannelSupported, transformEsm, unameInfo, wasi as wasiCommand };
1808
+ export { ArithError, BinaryBackend, ChildHandle, ChildSpawnConfig, type CleanInstallerOptions, CleanPackageInstaller, Command, CommonJsEngine, type CommonJsEngineOptions, type CommonJsModule, Container, type ContainerTarget, type CoreModulesOptions, Cred, ERRNO, type ErrnoCode, type EsmTransformResult, ExecContext, type FrontendAutomationOptions, FrontendAutomationUnsupported, FrontendLocator, FrontendPage, type GitEngine, IncompleteInputError, type InstallOptions, KERNEL_NAME, KERNEL_RELEASE, Kernel, type LocalRuntimeOptions, LocalRuntimePod, MemoryVolume, NODE_VERSION, NPM_VERSION, OS_RELEASE, type OriginalX64Options, OutputStream, type Preview, type PreviewOptions, type RootfsOptions, type RunWasiOptions, RuntimePackageInstaller, RuntimePod, RuntimeProcess, RuntimeVolume, SIGNALS, SIGNAL_NAMES, Session, Shell, ShellIO, Lexer as ShellLexer, ShellSyntaxError, SpawnChild, type SqlDatabase, SysError, Terminal, type TerminalOptions, Vfs, VirtualHttpRouter, VirtualHttpServer, VirtualIncomingMessage, VirtualServerResponse, WASM_ALIASES, WasiError, WasiExit, WasiHost, type WasiHostOptions, type WasiStdin, type WorkerRuntimeOptions, WorkerRuntimePod, allCommands, buildRootfs, builtinNames, containerTarget, createContainer, createCoreModules, createFrontendPlaywright, createGitCommand, createOriginalX64Backends, createPreview, createSqlCommand, createContainer as default, evalArith, exitCodeForSignal, expandPrompt, extractNpmTarball, fnmatch, getBuiltin, glob, globToRegex, hasMagic, installUserland, isBuiltinName, isSysError, isWasmBinary, looksLikeEsm, normalizeSignal, parse as parseShell, path as posixPath, renderInto, runWasi, startRuntimeWorker, strerror, syncChannelSupported, transformEsm, unameInfo, wasi as wasiCommand };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { S as Shell, a as ShellIO, b as Session, N as Node, c as Command, K as Kernel, E as ExecContext, O as OutputStream, C as Container, d as createContainer } from './container-B5X6stfx.js';
2
- export { B as BufferSink, e as CPythonOptions, f as CallbackSink, g as CommandRegistry, h as ContainerFs, i as ContainerOptions, j as ContextInit, k as Env, l as ExecOptions, m as ExecResult, F as FileData, n as FileInput, o as FileOutput, G as GroupEntry, H as HttpResponse, I as InputStream, J as Job, p as KernelOptions, L as ListeningPort, M as MANIFEST_FORMAT, q as MANIFEST_SCHEMA_VERSION, r as MountEntry, s as NetInterface, t as NetworkOptions, u as NetworkStack, v as NullInput, w as NullOutput, P as PYTHON_VERSION, x as PasswdEntry, y as Pipe, z as Process, A as ProcessKind, D as ProcessOptions, Q as ProcessState, R as ProcessTable, T as PythonCapabilities, U as PythonOptions, V as PythonProfile, W as PythonRuntimeManifest, X as ResolvedExecutable, Y as RunOptions, Z as RunResult, _ as SessionInit, $ as SessionResult, a0 as SessionRunOptions, a1 as ShellExit, a2 as ShellInit, a3 as ShellOptions, a4 as SpawnHandle, a5 as Stdio, a6 as TeeOutput, a7 as UserDatabase, a8 as Variables, a9 as braceExpand, aa as captureStdio, ab as configureCPython, ac as configurePython, ad as createContext, ae as defineCommand, af as expandWord, ag as expandWords, ah as isCPythonAvailable, ai as isPythonAvailable, aj as resetPidCounter, ak as shellQuote, al as validateManifest } from './container-B5X6stfx.js';
3
- import { V as Vfs, C as Cred, R as RuntimeVolume, a as VirtualTcpNetwork, b as RuntimeHttpResponse, S as SpawnChild, c as SyncSpawn, d as VolumeStat, e as VolumeStats, f as RuntimePod, g as RuntimePackageInstaller, h as ChildSpawnConfig, i as ChildHandle, j as RuntimeProcess, k as RuntimeSocketPeer, l as RuntimeConnection } from './contracts-CVgctitO.js';
4
- export { D as DirEntry, m as ROOT_CRED, n as RuntimeProcessManager, o as RuntimeProcessResult, p as Stats, q as VirtualNode, r as VirtualProvider, W as WriteOptions, s as applyChmod, t as createChildProcessModule, u as formatMode, v as makeCred, w as octalMode, x as parseUmask } from './contracts-CVgctitO.js';
5
- import { M as MemoryVolume, a as MemoryVolumeSnapshotEntry } from './memory-volume-CWuWScIs.js';
1
+ import { S as Shell, a as ShellIO, b as Session, N as Node, c as Command, K as Kernel, E as ExecContext, O as OutputStream, C as Container, B as BinaryBackend, d as createContainer } from './container-X8yZRFvW.js';
2
+ export { e as BinaryExecutionRegistry, f as BinaryInfo, g as BinaryRequest, h as BufferSink, i as CPythonOptions, j as CallbackSink, k as CommandRegistry, l as ContainerFs, m as ContainerOptions, n as ContextInit, o as Env, p as ExecOptions, q as ExecResult, r as ExecutionDecision, s as ExecutionTier, F as FileData, t as FileInput, u as FileOutput, G as GroupEntry, H as HttpResponse, I as InputStream, J as Job, v as KernelOptions, L as ListeningPort, M as MANIFEST_FORMAT, w as MANIFEST_SCHEMA_VERSION, x as MountEntry, y as NetInterface, z as NetworkOptions, A as NetworkStack, D as NullInput, P as NullOutput, Q as PYTHON_VERSION, R as PasswdEntry, T as Pipe, U as Preparation, V as PreparedBinary, W as Process, X as ProcessKind, Y as ProcessOptions, Z as ProcessState, _ as ProcessTable, $ as PythonCapabilities, a0 as PythonOptions, a1 as PythonProfile, a2 as PythonRuntimeManifest, a3 as ResolvedExecutable, a4 as RunOptions, a5 as RunResult, a6 as SessionInit, a7 as SessionResult, a8 as SessionRunOptions, a9 as ShellExit, aa as ShellInit, ab as ShellOptions, ac as SpawnHandle, ad as Stdio, ae as TeeOutput, af as UserDatabase, ag as Variables, ah as WasmCommandArtifact, ai as WasmTranslator, aj as binaryDigest, ak as braceExpand, al as captureStdio, am as configureCPython, an as configurePython, ao as createContext, ap as createTranslationBackend, aq as createWasmCompatibilityBackend, ar as defineCommand, as as expandWord, at as expandWords, au as inspectElf, av as installWasmCommands, aw as isCPythonAvailable, ax as isElfBinary, ay as isPythonAvailable, az as resetPidCounter, aA as shellQuote, aB as validateManifest } from './container-X8yZRFvW.js';
3
+ import { V as Vfs, C as Cred, R as RuntimeVolume, a as VirtualTcpNetwork, b as RuntimeHttpResponse, O as OutboundPolicy, S as SpawnChild, c as SyncSpawn, d as VolumeStat, e as VolumeStats, f as RuntimePod, g as RuntimePackageInstaller, h as ChildSpawnConfig, i as ChildHandle, j as RuntimeProcess, k as RuntimeSocketPeer, l as RuntimeConnection } from './contracts-C2_dTgk3.js';
4
+ export { D as DirEntry, m as ROOT_CRED, n as RuntimeProcessManager, o as RuntimeProcessResult, p as Stats, q as VirtualNode, r as VirtualProvider, W as WriteOptions, s as applyChmod, t as createChildProcessModule, u as formatMode, v as makeCred, w as octalMode, x as parseUmask } from './contracts-C2_dTgk3.js';
5
+ import { M as MemoryVolume, a as MemoryVolumeSnapshotEntry } from './memory-volume-CG56p660.js';
6
6
  import EventEmitter from 'events/events.js';
7
7
  import streamModule from 'stream-browserify';
8
8
 
@@ -213,6 +213,7 @@ declare const ERRNO: {
213
213
  readonly ECONNRESET: 104;
214
214
  readonly ENOTCONN: 107;
215
215
  readonly ETIMEDOUT: 110;
216
+ readonly ENETUNREACH: 101;
216
217
  readonly ECONNREFUSED: 111;
217
218
  readonly EHOSTUNREACH: 113;
218
219
  readonly ENOTSUP: 95;
@@ -735,6 +736,24 @@ interface VirtualConnection {
735
736
  /** The far end went away. */
736
737
  close(): void;
737
738
  }
739
+ /** A loopback request, as it crosses from a program to whoever holds the port. */
740
+ interface LoopbackRequest {
741
+ method: string;
742
+ path: string;
743
+ headers: Record<string, string>;
744
+ body: Uint8Array | null;
745
+ }
746
+ interface LoopbackResponse {
747
+ statusCode?: number;
748
+ statusMessage?: string;
749
+ headers?: Record<string, string>;
750
+ body?: string | ArrayBuffer | Uint8Array | null;
751
+ }
752
+ /**
753
+ * Reaches a server in this container that is not on this thread's router.
754
+ * Resolves `null` when nothing in the container listens on the port.
755
+ */
756
+ type LoopbackTransport = (port: number, request: LoopbackRequest) => Promise<LoopbackResponse | null>;
738
757
 
739
758
  interface CoreModulesOptions {
740
759
  volume: RuntimeVolume;
@@ -748,6 +767,13 @@ interface CoreModulesOptions {
748
767
  router: VirtualHttpRouter;
749
768
  owner: string;
750
769
  fetch?: typeof globalThis.fetch;
770
+ /** Servers in other processes, for a router that holds only this thread's. */
771
+ loopback?: LoopbackTransport;
772
+ /**
773
+ * The container's outbound policy, applied to `fetch`, `http`, `https` and
774
+ * `WebSocket`. Omitted, requests leave the way the host's own would.
775
+ */
776
+ policy?: OutboundPolicy;
751
777
  };
752
778
  /** Backs `child_process`; without it the module reports as unavailable. */
753
779
  spawnChild?: SpawnChild;
@@ -813,6 +839,14 @@ declare function createCoreModules(options: CoreModulesOptions): {
813
839
  * exiting in the gap between `http.get` and its response callback.
814
840
  */
815
841
  pendingRequests(): number;
842
+ /** An error that escaped the program's callbacks: listeners, or print and exit 1. */
843
+ reportUncaught(error: unknown): void;
844
+ /** A rejection nobody handled, under the same rule. */
845
+ reportUnhandledRejection(reason: unknown): void;
846
+ /** The status a program ends with: `process.exit`'s code, else `process.exitCode`. */
847
+ exitStatus(): number;
848
+ /** Run `process.on("exit")` listeners once, for a program that ended by itself. */
849
+ emitExit(status: number): void;
816
850
  };
817
851
 
818
852
  interface EsmTransformResult {
@@ -996,6 +1030,12 @@ interface LocalRuntimeOptions {
996
1030
  files?: Record<string, string | Uint8Array>;
997
1031
  registry?: string;
998
1032
  fetch?: typeof globalThis.fetch;
1033
+ /**
1034
+ * The outbound policy for guest `fetch`, `http`, `https` and `WebSocket`.
1035
+ * Omitted, guest requests leave the way the host's would; `createContainer`
1036
+ * always supplies one, closed unless the caller opens it.
1037
+ */
1038
+ network?: OutboundPolicy;
999
1039
  /** Invoked when a program inside the runtime starts listening on a port. */
1000
1040
  onServerReady?: (port: number, url: string) => void;
1001
1041
  /** Extra package substitutions, merged over {@link WASM_ALIASES}. */
@@ -1067,8 +1107,12 @@ declare class LocalRuntimePod implements RuntimePod {
1067
1107
  private rolldownBinding;
1068
1108
  /** Backs outbound `http`/`https` client requests from inside the sandbox. */
1069
1109
  private readonly fetch;
1110
+ /** What guest programs may reach outside the container. */
1111
+ protected networkPolicy: OutboundPolicy | undefined;
1070
1112
  protected constructor(options: LocalRuntimeOptions);
1071
1113
  static boot(options?: LocalRuntimeOptions): Promise<LocalRuntimePod>;
1114
+ /** Apply a container's outbound policy to programs started from now on. */
1115
+ setNetworkPolicy(policy: OutboundPolicy): void;
1072
1116
  spawn(command: string, args?: string[], options?: Record<string, unknown>): Promise<RuntimeProcess>;
1073
1117
  /**
1074
1118
  * Rolldown's JavaScript API synchronously requires its compiled binding.
@@ -1164,6 +1208,15 @@ declare class WorkerRuntimePod extends LocalRuntimePod {
1164
1208
  * the two directions together across the Worker boundary.
1165
1209
  */
1166
1210
  private upgrade;
1211
+ /**
1212
+ * Answer a program that is calling a server in this container.
1213
+ *
1214
+ * A guest's router holds only the servers on its own thread, so a request to
1215
+ * a port some other process opened comes here, where every server in the
1216
+ * container is registered. `null` means nothing listens, which the guest
1217
+ * reports as a refused connection.
1218
+ */
1219
+ private answerLoopback;
1167
1220
  private settleProxied;
1168
1221
  private closeProxies;
1169
1222
  teardown(): void;
@@ -1204,10 +1257,10 @@ declare class CleanPackageInstaller implements RuntimePackageInstaller {
1204
1257
  readonly options: CleanInstallerOptions;
1205
1258
  private readonly registry;
1206
1259
  private readonly fetcher;
1207
- private readonly metadata;
1208
- private readonly tarballs;
1260
+ private metadata;
1261
+ private tarballs;
1209
1262
  /** Single-version manifests, for the fields the packument omits. */
1210
- private readonly details;
1263
+ private details;
1211
1264
  constructor(volume: RuntimeVolume, options?: CleanInstallerOptions);
1212
1265
  forCwd(cwd: string): CleanPackageInstaller;
1213
1266
  install(name: string, version?: string, options?: InstallOptions): Promise<RegistryManifest>;
@@ -1228,6 +1281,8 @@ declare class CleanPackageInstaller implements RuntimePackageInstaller {
1228
1281
  * being right and strictly more than refusing to install.
1229
1282
  */
1230
1283
  private platformDetail;
1284
+ /** Overlap up to six sibling downloads; filesystem writes remain ordered. */
1285
+ private prefetch;
1231
1286
  private getMetadata;
1232
1287
  private getTarball;
1233
1288
  private createBinLinks;
@@ -1621,6 +1676,117 @@ declare function renderInto(box: Container, element: HTMLElement, options?: {
1621
1676
  path?: string;
1622
1677
  }): Promise<HTMLIFrameElement>;
1623
1678
 
1679
+ /** Structural contracts keep optional engines out of the core dependency graph. */
1680
+ interface SqlDatabase {
1681
+ exec(sql: string): Promise<{
1682
+ rows: unknown[];
1683
+ }[]>;
1684
+ }
1685
+ /** A deliberately small SQL CLI, not a PostgreSQL daemon or psql emulation. */
1686
+ declare function createSqlCommand(database: SqlDatabase, name?: string): Command;
1687
+ interface GitEngine {
1688
+ init(options: any): Promise<any>;
1689
+ add(options: any): Promise<any>;
1690
+ commit(options: any): Promise<string>;
1691
+ log(options: any): Promise<any[]>;
1692
+ statusMatrix(options: any): Promise<[string, number, number, number][]>;
1693
+ }
1694
+ /** Local Git subset. No implicit network, credentials, proxy, or external service. */
1695
+ declare function createGitCommand(git: GitEngine): Command;
1696
+
1697
+ /** Original experimental x86-64 ELF engine. No third-party CPU/compiler code. */
1698
+
1699
+ interface OriginalX64Options {
1700
+ maxInstructions?: number;
1701
+ }
1702
+ /** Experimental original engines: only static freestanding programs using documented opcodes. */
1703
+ declare function createOriginalX64Backends(options?: OriginalX64Options): BinaryBackend[];
1704
+
1705
+ /** Frontend-only DOM automation. Uses the host browser; does not bundle Chromium. */
1706
+ interface FrontendAutomationOptions {
1707
+ /** Trusted host-owned mount for visible test frames. Defaults to document.body. */
1708
+ mount?: HTMLElement;
1709
+ /** Map a virtual server URL to a same-origin preview URL. */
1710
+ resolveUrl?: (url: string) => string | Promise<string>;
1711
+ timeoutMs?: number;
1712
+ }
1713
+ declare class FrontendAutomationUnsupported extends Error {
1714
+ readonly code = "ERR_FRONTEND_AUTOMATION_UNSUPPORTED";
1715
+ }
1716
+ declare class FrontendLocator {
1717
+ private readonly query;
1718
+ private readonly timeout;
1719
+ constructor(query: () => Element[], timeout: () => number);
1720
+ first(): FrontendLocator;
1721
+ nth(index: number): FrontendLocator;
1722
+ locator(selector: string): FrontendLocator;
1723
+ count(): Promise<number>;
1724
+ isVisible(): Promise<boolean>;
1725
+ private element;
1726
+ textContent(): Promise<string | null>;
1727
+ innerText(): Promise<string>;
1728
+ inputValue(): Promise<string>;
1729
+ getAttribute(name: string): Promise<string | null>;
1730
+ click(): Promise<void>;
1731
+ fill(value: string): Promise<void>;
1732
+ waitFor(options?: {
1733
+ state?: "visible" | "hidden" | "attached" | "detached";
1734
+ timeout?: number;
1735
+ }): Promise<void>;
1736
+ }
1737
+ declare class FrontendPage {
1738
+ private readonly options;
1739
+ private readonly frame;
1740
+ private timeout;
1741
+ private closed;
1742
+ constructor(options: FrontendAutomationOptions);
1743
+ private doc;
1744
+ setDefaultTimeout(ms: number): void;
1745
+ locator(selector: string): FrontendLocator;
1746
+ getByTestId(value: string): FrontendLocator;
1747
+ getByText(text: string, options?: {
1748
+ exact?: boolean;
1749
+ }): FrontendLocator;
1750
+ getByRole(role: string, options?: {
1751
+ name?: string;
1752
+ }): FrontendLocator;
1753
+ private navigate;
1754
+ setContent(html: string): Promise<void>;
1755
+ goto(url: string): Promise<null>;
1756
+ title(): Promise<string>;
1757
+ content(): Promise<string>;
1758
+ evaluate<T, A = undefined>(fn: ((arg: A) => T) | string, arg?: A): Promise<T>;
1759
+ screenshot(): Promise<never>;
1760
+ route(): Promise<never>;
1761
+ close(): Promise<void>;
1762
+ }
1763
+ declare function createFrontendPlaywright(options?: FrontendAutomationOptions): {
1764
+ capabilities: Readonly<{
1765
+ engine: "host-browser";
1766
+ fullPlaywright: false;
1767
+ screenshots: false;
1768
+ crossOrigin: false;
1769
+ trustedEvents: false;
1770
+ }>;
1771
+ chromium: {
1772
+ launch: (launchOptions?: Record<string, unknown>) => Promise<{
1773
+ newPage(): Promise<FrontendPage>;
1774
+ close(): Promise<void>;
1775
+ }>;
1776
+ };
1777
+ firefox: {
1778
+ launch: () => Promise<never>;
1779
+ };
1780
+ webkit: {
1781
+ launch: () => Promise<never>;
1782
+ };
1783
+ dispose(): Promise<void>;
1784
+ expect(locator: FrontendLocator): {
1785
+ toBeVisible(): Promise<void>;
1786
+ toHaveText(text: string): Promise<void>;
1787
+ };
1788
+ };
1789
+
1624
1790
  /**
1625
1791
  * sandboxedjs — a Linux-like container that runs entirely inside Node.js.
1626
1792
  *
@@ -1639,4 +1805,4 @@ declare function renderInto(box: Container, element: HTMLElement, options?: {
1639
1805
  * ```
1640
1806
  */
1641
1807
 
1642
- export { ArithError, ChildHandle, ChildSpawnConfig, type CleanInstallerOptions, CleanPackageInstaller, Command, CommonJsEngine, type CommonJsEngineOptions, type CommonJsModule, Container, type ContainerTarget, type CoreModulesOptions, Cred, ERRNO, type ErrnoCode, type EsmTransformResult, ExecContext, IncompleteInputError, type InstallOptions, KERNEL_NAME, KERNEL_RELEASE, Kernel, type LocalRuntimeOptions, LocalRuntimePod, MemoryVolume, NODE_VERSION, NPM_VERSION, OS_RELEASE, OutputStream, type Preview, type PreviewOptions, type RootfsOptions, type RunWasiOptions, RuntimePackageInstaller, RuntimePod, RuntimeProcess, RuntimeVolume, SIGNALS, SIGNAL_NAMES, Session, Shell, ShellIO, Lexer as ShellLexer, ShellSyntaxError, SpawnChild, SysError, Terminal, type TerminalOptions, Vfs, VirtualHttpRouter, VirtualHttpServer, VirtualIncomingMessage, VirtualServerResponse, WASM_ALIASES, WasiError, WasiExit, WasiHost, type WasiHostOptions, type WasiStdin, type WorkerRuntimeOptions, WorkerRuntimePod, allCommands, buildRootfs, builtinNames, containerTarget, createContainer, createCoreModules, createPreview, createContainer as default, evalArith, exitCodeForSignal, expandPrompt, extractNpmTarball, fnmatch, getBuiltin, glob, globToRegex, hasMagic, installUserland, isBuiltinName, isSysError, isWasmBinary, looksLikeEsm, normalizeSignal, parse as parseShell, path as posixPath, renderInto, runWasi, startRuntimeWorker, strerror, syncChannelSupported, transformEsm, unameInfo, wasi as wasiCommand };
1808
+ export { ArithError, BinaryBackend, ChildHandle, ChildSpawnConfig, type CleanInstallerOptions, CleanPackageInstaller, Command, CommonJsEngine, type CommonJsEngineOptions, type CommonJsModule, Container, type ContainerTarget, type CoreModulesOptions, Cred, ERRNO, type ErrnoCode, type EsmTransformResult, ExecContext, type FrontendAutomationOptions, FrontendAutomationUnsupported, FrontendLocator, FrontendPage, type GitEngine, IncompleteInputError, type InstallOptions, KERNEL_NAME, KERNEL_RELEASE, Kernel, type LocalRuntimeOptions, LocalRuntimePod, MemoryVolume, NODE_VERSION, NPM_VERSION, OS_RELEASE, type OriginalX64Options, OutputStream, type Preview, type PreviewOptions, type RootfsOptions, type RunWasiOptions, RuntimePackageInstaller, RuntimePod, RuntimeProcess, RuntimeVolume, SIGNALS, SIGNAL_NAMES, Session, Shell, ShellIO, Lexer as ShellLexer, ShellSyntaxError, SpawnChild, type SqlDatabase, SysError, Terminal, type TerminalOptions, Vfs, VirtualHttpRouter, VirtualHttpServer, VirtualIncomingMessage, VirtualServerResponse, WASM_ALIASES, WasiError, WasiExit, WasiHost, type WasiHostOptions, type WasiStdin, type WorkerRuntimeOptions, WorkerRuntimePod, allCommands, buildRootfs, builtinNames, containerTarget, createContainer, createCoreModules, createFrontendPlaywright, createGitCommand, createOriginalX64Backends, createPreview, createSqlCommand, createContainer as default, evalArith, exitCodeForSignal, expandPrompt, extractNpmTarball, fnmatch, getBuiltin, glob, globToRegex, hasMagic, installUserland, isBuiltinName, isSysError, isWasmBinary, looksLikeEsm, normalizeSignal, parse as parseShell, path as posixPath, renderInto, runWasi, startRuntimeWorker, strerror, syncChannelSupported, transformEsm, unameInfo, wasi as wasiCommand };