sandboxedjs 0.2.18 → 0.2.20
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 +29 -10
- package/bin/sandboxedjs-pack.mjs +4 -0
- package/dist/index.cjs +625 -99
- package/dist/index.js +625 -99
- package/docs/agent/README.md +35 -60
- package/docs/vireo.md +58 -0
- package/package.json +11 -3
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
|
|
7
|
+
**A secure, Linux-like environment written in JavaScript, running entirely inside a browser tab or a Node process.**
|
|
8
8
|
|
|
9
|
-
|
|
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
|
[](https://www.npmjs.com/package/sandboxedjs)
|
|
13
12
|
[](./LICENSE)
|
|
@@ -42,14 +41,28 @@ touches your disk.
|
|
|
42
41
|
<a href="https://sandboxedjs.pages.dev">
|
|
43
42
|
<img src="https://cdn.jsdelivr.net/npm/sandboxedjs@latest/assets/demo.png" alt="SandboxedJS running a full-stack project in a browser" width="720" />
|
|
44
43
|
</a>
|
|
45
|
-
<p>
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
heavy, too slow, or
|
|
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` |
|
|
@@ -121,7 +140,7 @@ terminal.start();
|
|
|
121
140
|
|
|
122
141
|
## Running a full-stack project in a browser
|
|
123
142
|
|
|
124
|
-
This
|
|
143
|
+
This can be the case most people arrive for: a Vite frontend and a Python backend, in one container, in
|
|
125
144
|
a tab — the frontend calling `http://localhost:8000`, the backend calling a real API.
|
|
126
145
|
|
|
127
146
|
The frontend-to-backend hop and the backend-to-internet hop have different requirements.
|
package/bin/sandboxedjs-pack.mjs
CHANGED
|
@@ -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));
|