Basic setup
With no options, the driver provides a filesystem with a read-onlynode_modules overlay and no network or child process access.
Configuring capabilities
Pass options to enable and configure specific host capabilities.All options
| Option | Type | Description |
|---|---|---|
filesystem | VirtualFileSystem | Custom filesystem implementation. Falls back to the built-in ModuleAccessFileSystem. |
moduleAccess | ModuleAccessOptions | Configure the node_modules overlay (see Module access). |
networkAdapter | NetworkAdapter | Custom network adapter. |
commandExecutor | CommandExecutor | Custom command executor for child processes (see Child processes). |
permissions | Permissions | Permission callbacks for fs, network, child process, and env access. |
useDefaultNetwork | boolean | Use the built-in network adapter (fetch, DNS, HTTP client, loopback HTTP server). |
processConfig | ProcessConfig | Values for process.cwd(), process.env, etc. inside the sandbox. |
osConfig | OSConfig | Values for os.platform(), os.arch(), etc. inside the sandbox. |
Permissions
Permissions are deny-by-default. Each capability (filesystem, network, child process, env) is controlled by a function that receives a request object and returns aPermissionDecision.
Function-based permissions
Each permission callback receives a typed request and returns{ allow: boolean, reason?: string }.
Request types
| Permission | Request fields |
|---|---|
fs | op ("read", "write", "mkdir", "stat", "rm", "rename", …), path |
network | op ("fetch", "http", "dns", "listen"), url?, method?, hostname? |
childProcess | command, args, cwd?, env? |
env | op ("read", "write"), key, value? |
Allow-all helpers
For development or trusted environments, use the built-in helpers.Filesystem
By default, the driver usesModuleAccessFileSystem, which provides a read-only overlay of the host’s node_modules. You can supply a custom VirtualFileSystem implementation or use the built-in in-memory filesystem.
Module access
ThemoduleAccess option configures which host node_modules directory is projected into the sandbox as a read-only overlay. By default it uses process.cwd() to locate node_modules.
| Option | Type | Description |
|---|---|---|
cwd | string | Absolute path used to resolve node_modules. Defaults to process.cwd(). |
/root/node_modules/... and are read-only. Write operations to the overlay throw EACCES. Native .node addons are rejected.
Child processes
Provide aCommandExecutor to allow sandboxed code to spawn processes. This is gated behind the childProcess permission.
CommandExecutor interface
Custom executor example
Process and OS configuration
UseprocessConfig and osConfig to control what the sandbox sees for process.cwd(), process.env, os.platform(), and similar APIs.