Bayang: a discardable agent runtime in your browser

Bayang runs a real Linux VM and coding agent inside a browser tab with no server, using WebAssembly, IndexedDB or OPFS, and optional on-device WebGPU.

5 min read
On this page

A browser window hosting a sandboxed terminal and virtual machine cube

Most coding agents assume a real machine: a container, a VPS, or your own laptop. If you want to try something quick or let an agent run untrusted commands, you either risk your own environment or spin up a sandbox somewhere.

I built Bayang to see what happens when you put the whole thing in a browser tab instead. It boots an ARM64 Linux virtual machine in WebAssembly, runs a coding agent (kelir) inside it, and stores the guest disk in your browser. There is no backend server.

The source is on GitHub.

What it is

When you open bayang.adhikasp.id, the page downloads a 28.8 MB Linux root filesystem (image.erofs) and boots it with unkernel. Inside that guest, kelir runs as a static aarch64 binary alongside bash, git, curl, and Python 3.14.

Every message you send spawns kelir run --json inside the Linux guest. The agent plans, runs shell commands, edits files, and streams its events back to the chat UI. When the turn finishes, the guest disk syncs to browser storage.

Because the whole machine lives in browser storage, you can treat it as discardable. You can create multiple named machines under Settings, each with its own disk, RAM (512 to 3072 MiB), CPU count (1 to 4), and provider settings. If an agent messes up a workspace, you can reset that machine’s disk or delete it and start over.

How it works

Inside a Bayang browser tab

1. The Linux guest

The guest image is built from unkernel’s stock Alpine EROFS image, repacked with zstd compression and the tools an agent actually needs: bash, git, curl, python3, and kelir.

Because the guest is a real aarch64 Linux environment, normal shell workflows work. Python’s standard library is there, and if you need third-party packages you can create a venv (python3 -m venv ~/venv).

2. Three ways to connect to an LLM

A browser tab cannot open raw TCP sockets on its own, so Bayang gives you three ways to run inference:

  • Direct (fetch): The default mode. A custom NetBackend intercepts plain HTTP requests from the guest to openrouter.ai and replays them through the browser’s fetch() API. Your API key stays in localStorage and only goes to OpenRouter. Boot takes about 1.1 seconds, and the guest cannot reach any other host on the internet.
  • Wisp (local or custom): If you want curl or git clone inside the guest to reach the wider internet, you can switch to a Wisp WebSocket proxy. You can point it at a custom Wisp URL, or run one locally on your own machine with npx -y @mercuryworkshop/wisp-js@0.5.4 -L NONE. In Wisp mode, the kernel runs in a Web Worker with an OPFS disk and supports multiple virtual CPUs.
  • On-device (WebGPU): For a completely offline, keyless setup, Bayang can download LFM3-1.7B (Q2_K, ~750 MB) into Cache Storage and run it inside the tab via wllama (llama.cpp compiled to WebAssembly with ggml-webgpu). The guest talks to http://local.llm/v1, which the page answers locally. On an AMD iGPU in Chrome, prefill runs at ~35 tok/s, taking around 55 seconds for a single tool-call turn.

3. Browser-native persistence and sharing

Bayang is a static site, but it uses a few browser APIs to make the workspace practical:

  • Multiple conversations: Each chat maps to a named kelir session on the guest disk. Reloading the page replays the session’s events.jsonl log.
  • Export and import: You can export /home/user as a .tar.gz archive and import it into another machine or browser.
  • PWA and file drops: A service worker handles Cross-Origin Isolation headers (needed for SharedArrayBuffer in worker mode) and lets you install the app, paste or drop files into /home/user/uploads/, or share content into a draft on Android.

Limits

Running Linux and an agent in WebAssembly has clear trade-offs:

  • Local Wisp is Chromium-only: Reaching ws://127.0.0.1:5001 from a public HTTPS origin requires Chrome’s Local Network Access permission. Firefox and Safari block it.
  • On-device models are slow on prefill: A 1.7B model in WebGPU works for simple shell tasks, but a ~1.7k-token agent system prompt takes ~49 seconds to prefill before the first token appears.
  • Guest memory and disk are bounded by the tab: Heavy builds or large repositories will hit browser memory limits much sooner than a native container.

Still, for quick experiments, testing prompts, or giving someone a link to a working agent sandbox with zero setup, a browser tab turns out to be enough.


An AI agent helped me draft this post.