Detail Apids · signals · pty
Real processes, signals, and PTYs
Every command runs in its own worker with a real PID, job ID, Linux signals, cooperative Wasm interrupt rewriting, guest PTYs, WASI threads, and shared-memory groups.
POSIX & WASI browser kernel · @waffle-os/runtime
Waffle gives WebAssembly programs a shared filesystem, real processes, pipes, Unix sockets, PTYs, and loopback TCP inside one browser tab. 18.7 KB gzipped core, zero CPU emulation.
Process table
Architecture
Compiling Linux to Wasm and emulating ARM64 on top takes a ~10 MB browser boot with Alpine and runs user code behind an interpreter or JIT. Waffle builds the kernel directly for WebAssembly so every tool executes on V8, SpiderMonkey, or JavaScriptCore at full engine speed.
| Approach | Kernel | User space | Download | Execution cost |
|---|---|---|---|---|
| Whole-machine emulators (v86, QEMU) | Linux, emulated | Unmodified x86/ARM, emulated | 10+ MB | Emulated kernel and user CPU |
| Linux-in-Wasm + CPU emulator (unkernel) | Linux, native Wasm | ARM64 binaries, emulated + JIT | ~10 MB (kernel + Alpine) | Fast syscalls, emulated user compute |
| Per-tool WASI shims | None | Isolated WASI modules | Per-tool shim only | Native Wasm, no shared OS state |
| Waffle | Native browser OS kernel | Native Wasm / WASI userland | 18.7 KB core (+151 KB VFS) | Native browser Wasm speed, zero CPU emulation |
Kernel subsystems
The page owns one runtime instance. Shells, language runtimes, and Unix utilities borrow its filesystem, process table, pipes, sockets, and network instead of shipping separate sandboxes.
Detail Apids · signals · pty
Every command runs in its own worker with a real PID, job ID, Linux signals, cooperative Wasm interrupt rewriting, guest PTYs, WASI threads, and shared-memory groups.
Detail Bsab · multi-tab · locks
Lazy 16 MiB shared segments backed by memory, IndexedDB, or internal OPFS, with multi-tab leader failover, durable write receipts, recursive watches, POSIX modes, lossless byte filenames, and flock/fcntl locks on exclusive backends.
Detail C64 kib rings · af_unix
64 KiB shared-memory pipe rings plus pathname and abstract AF_UNIX sockets. Guest workers block on Atomics.wait so unmodified Preview 1 programs using supported imports run without JSPI.
Detail Drust wasm · preview sw
A lazy Rust wasm32 TCP stack serves 127.0.0.1 inside the tab, a Service Worker preview router connects browser frames to guest servers, and @waffle-os/relay adds opt-in outbound TCP.
The API
Enable the Vite plugin for automatic COOP/COEP headers and WebKit-safe single-file workers, create one runtime, and run WASI commands with runtime.run(). Non-Vite bundlers import explicit worker entries from @waffle-os/runtime/workers/*.
bun add @waffle-os/runtime @waffle-os/baseimport { createRuntime } from "@waffle-os/runtime";
const runtime = createRuntime();
try {
await runtime.filesystem.writeFile("/hello.txt", "hello from Waffle");
const bytes = await runtime.filesystem.readFile("/hello.txt");
document.body.textContent = new TextDecoder().decode(bytes);
} finally {
await runtime.dispose();
}import { defineConfig } from "vite";
import { waffle } from "@waffle-os/runtime/vite";
// Adds COOP/COEP/CORP headers (including 304), excludes
// Waffle packages from optimizeDeps, and emits single-file
// workers for WebKit compatibility.
export default defineConfig({
plugins: [waffle()],
});import { createRuntime } from "@waffle-os/runtime";
import { listWorkspaceNames } from "@waffle-os/runtime/workspaces";
// Zero runtime.ts bytes loaded on landing pages
const saved = await listWorkspaceNames("fast");
const runtime = createRuntime({
filesystem: {
mode: "fast",
name: saved[0] ?? "workspace",
whenBusy: "attach", // Multi-tab Host/Peer with automatic failover
},
});
const receipt = await runtime.filesystem.writeFileDurable("/note.txt", "saved\n");
const watcher = runtime.filesystem.watch("/", {
recursive: true,
onEvents: (events) => console.log(events),
onResync: (reason) => console.log("resync:", reason),
});import { createRuntime } from "@waffle-os/runtime";
import { base } from "@waffle-os/base";
const runtime = createRuntime({
programs: { onDemand: [base] },
});
await runtime.filesystem.mkdirp("/src");
await runtime.filesystem.writeFile("/src/todo.txt", "TODO: ship release\n");
// Stream output and send POSIX signals to a live process
const proc = runtime.spawn("/usr/bin/rg", ["TODO", "/src"], {
stdout: {
limitBytes: 0,
onChunk(bytes) {
console.log(new TextDecoder().decode(bytes));
},
},
deadlineMs: 5_000,
});
const { exit } = await proc.result;Measured 2026-11-29 on Bun 1.4.4 (Linux x64); timings are in-process Bun microbenchmarks. Shared VFS worker is 151.5 KB gzip and preview service worker is 1.4 KB gzip; process supervisor (103.4 KB gzip), Rust network module (≤ 28 KB gzip), and GPU bridge (4.8 KB display gzip) load lazily on first use.
Upstream userland & ecosystem
@waffle-os/base bundles 35 permissive MIT and BSD utilities. Heavyweight runtimes and copyleft packages stay opt-in behind an automated SPDX and source-first provenance gate.
Status & roadmap
Waffle is pre-1.0 software published on npm. Every shipped capability below is backed by automated unit, conformance, or 3-engine Playwright tests.
Shipped today
Planned and upcoming