sandboxedjs 0.2.19 → 0.2.21

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 CHANGED
@@ -2,12 +2,11 @@
2
2
 
3
3
  <img src="https://cdn.jsdelivr.net/npm/sandboxedjs@latest/assets/logo.png" alt="SandboxedJS" width="140" />
4
4
 
5
- # SandboxedJS
5
+ # SandboxedJS: The Zero-Infra Sandbox for AI Agents & Code Playgrounds
6
6
 
7
- **A Linux-like operating system of its own — written in JavaScript, running inside a browser tab or a Node process.**
7
+ **A secure, Linux-like environment written in JavaScript, running entirely inside a browser tab or a Node process.**
8
8
 
9
- Not a Linux kernel, not a VM, not Docker, not WebContainers. Its own filesystem, shell, process
10
- table, package installer and network stack, all in memory, booting in about 100 ms.
9
+ The ideal alternative to WebContainers and NodePod for those who need a full POSIX shell, Node.js, and Python runtimes without the infrastructure overhead. Boots in ~100 ms, all in memory.
11
10
 
12
11
  [![npm](https://img.shields.io/npm/v/sandboxedjs?color=cb0000&label=npm)](https://www.npmjs.com/package/sandboxedjs)
13
12
  [![license](https://img.shields.io/badge/license-MIT-black)](./LICENSE)
@@ -45,11 +44,25 @@ touches your disk.
45
44
  <p>Above: a full-stack project running inside a static site deployed on Cloudflare Pages. The site is a CLI for interacting with the sandbox — and just as it runs a full-stack project, so can yours. <a href="https://sandboxedjs.pages.dev">Try the live demo →</a></p>
46
45
  </div>
47
46
 
48
- ## Why
47
+ ## Why SandboxedJS?
49
48
 
50
- Run untrusted or AI-generated code. Give an agent a real shell. Build a browser IDE that actually
51
- installs packages and starts servers. Teach Unix without handing out VMs. A real container is too
52
- heavy, too slow, or simply unavailable — in a browser tab, in a serverless function, in CI.
49
+ Looking for a **WebContainer alternative** that works in both Node.js and the browser without the infrastructure overhead?
50
+
51
+ SandboxedJS is designed for cases where a real container is too heavy, too slow, or unavailable — like in a browser tab, a serverless function, or a CI pipeline.
52
+
53
+ ### Best For:
54
+ - **AI Agents**: Give your LLM a real POSIX shell to manage files, run scripts, and install packages safely.
55
+ - **Code Sandboxes**: Build a browser-based IDE or interactive tutorial that boots in 100ms with zero server-side setup.
56
+ - **Secure JS Sandboxing**: Run untrusted JavaScript and Python code in an isolated environment without native module risks.
57
+
58
+ ### SandboxedJS vs. The World
59
+
60
+ | Feature | SandboxedJS | WebContainers / NodePod | Traditional VMs/Docker |
61
+ | :--- | :--- | :--- | :--- |
62
+ | **Infrastructure** | Zero (Pure JS/WASM) | Medium (Browser/Host) | High (Server/Hypervisor) |
63
+ | **Boot Time** | ~100ms | Seconds | Minutes |
64
+ | **Environment** | Node + Browser | Browser-only / Server | Server-only |
65
+ | **Setup** | `npm install` | Cloud Provisioning | Complex Orchestration |
53
66
 
54
67
  ## Install
55
68
 
@@ -61,6 +74,12 @@ Node 18.17+. Pure JavaScript and WebAssembly — no build step, no native module
61
74
 
62
75
  ## What's inside
63
76
 
77
+ Browser automation uses the separately distributed **Vireo** Rust/WebAssembly
78
+ document engine. Node and Python Playwright discover the built-in Chromium
79
+ compatibility command; its first launch securely installs Vireo from the
80
+ SandboxedJs application registry. See [the Vireo architecture and current
81
+ compatibility](docs/vireo.md).
82
+
64
83
  | | |
65
84
  | --------------- | ------------------------------------------------------------------------------------------------------------------ |
66
85
  | **Filesystem** | A full FHS tree in memory (`/etc`, `/usr`, `/var`, `/home`), permissions, ownership, symlinks, hard links, `umask` |
@@ -105,6 +105,9 @@ async function build() {
105
105
  throw new Error(`app.json declares the command ${binary.name} at ${binary.path}, which is not in ${directory}`);
106
106
  }
107
107
  }
108
+ if (app.browserEngine?.wasm && !files.includes(app.browserEngine.wasm)) {
109
+ throw new Error(`app.json declares a browser engine at ${app.browserEngine.wasm}, which is not in ${directory}`);
110
+ }
108
111
 
109
112
  const digests = {};
110
113
  const contents = new Map();
@@ -218,6 +221,7 @@ async function inspect() {
218
221
  function collect(root, prefix = "") {
219
222
  const out = [];
220
223
  for (const entry of readdirSync(join(root, prefix), { withFileTypes: true })) {
224
+ if ([".git", "target"].includes(entry.name)) continue;
221
225
  const path = prefix ? `${prefix}/${entry.name}` : entry.name;
222
226
  if (entry.isDirectory()) {
223
227
  out.push(...collect(root, path));