headless browser linux & webmcp custom ui
Why this matters
Compiling a real Linux 7.x kernel to WebAssembly via Unkernel and WebAssembly JSPI lets a static web page execute standard POSIX binaries locally—yet most demos stop at an xterm.js terminal window. Terminals force both people and language models to parse unstructured text, ANSI sequences, and fragile column spacing. This lab tests running Linux 7.x headlessly inside a Dedicated Worker behind purpose-built web cards and typed WebMCP tools.
What this opens up
Static browser apps that run real Linux utilities (awk, grep, loopback HTTP servers, and kernel memory checkpoints) over an in-memory 9p workspace (/work) with zero server compute, zero external guest network sockets, and deterministic JSON tool surfaces for browser agents.
How the tests work
- Wait for auto-boot (or click Boot / Reboot Linux 7.x VM) to load
unkernel.wasminsidepublic/vm-worker.js(memoryMiB: 112,jit: true, externalnetomitted) and mount a reactive 9pMemoryFsat/work. - Edit
sales-q4.csv,notes.md,config.json, orsite/index.htmlin the Reactive 9p File Explorer and watchmem.onChange()events update the workspace while real BusyBoxawkandgrepcards recalculate locally. - Click Start & Fetch Loopback Site to run a BusyBox loopback HTTP server on guest port
8080serving/work/siteand fetchhttp://localhost:8080/over vsock (vm.fetch()) with zero external sockets. - Click Run Side-by-Side Comparison to measure exact wire bytes, parse stability, and real
vm.exec()latency between structured WebMCP JSON and raw shell table stdout, then run Checkpoint -> Mutate -> Restore to verifyvm.snapshot()kernel RAM rollback. - Invoke any of the five registered WebMCP tools directly or connect an optional client-side LLM via Port Authority AI Router (
https://llmchannel.dev/router.js), Chrome Built-inLanguageModel, or local Ollama.
Hypothesis
Running a full Linux 7.x kernel headlessly inside a Dedicated Worker behind a reactive 9p
MemoryFsand typed WebMCP JSON tools removes terminal scraping fragility while keeping real POSIX execution latency in the tens of milliseconds with zero external network exposure.
What confirms it: BusyBox awk, grep, vsock loopback vm.fetch("http://localhost:8080/"), mem.onChange() live file sync, and vm.snapshot() / createKernel({ restore }) all execute cleanly inside the browser worker while returning schema-validated JSON with zero banner or column-parsing noise.
What bounds or disproves it: Dedicated Worker boot time, 12.2 MiB unkernel.wasm delivery, or JSPI browser support limitations prevent the headless UI from responding faster and more reliably than a terminal wrapper or server-backed API.
Under the hood
Headless Browser Linux & WebMCP Custom UI (GitHub) boots unkernel@0.3.0-261202-b033dc7 inside a module Dedicated Worker (public/vm-worker.js) importing /vendor/unkernel/0.3.0-261202-b033dc7/web.mjs with memoryMiB: 112, jit: true, and no external network device (net omitted). The 12.2 MiB unkernel.wasm binary is copied at build time by scripts/copy-unkernel.mjs into public/vendor/ (gitignored) and served directly by Cloudflare Static Assets with Cache-Control: public, max-age=31536000, immutable.
Instead of presenting a terminal emulator, the worker mounts an in-memory 9p MemoryFs at /work seeded with sales-q4.csv, notes.md, site/index.html, and config.json, subscribes to mem.onChange() to push live guest write notifications to the main thread, and exposes structured RPC methods backed by real BusyBox utilities (vm.exec("awk", ...), vm.exec("grep", ...), loopback HTTP fetched via vm.fetch("http://localhost:8080/"), and vm.snapshot() / createKernel({ restore })). The main thread (public/app.js) registers five typed tools (list_workspace_files, analyze_csv_with_awk, search_project, preview_guest_http, and checkpoint_and_restore) via navigator.modelContext?.registerTool with an automatic local fallback registry, lets users inspect real Linux uname -a output in an optional collapsible console peek, and compares WebMCP JSON payloads directly against human-formatted shell stdout on the same query.
Key terms & further reading
- Unkernel (Linux 7.x in WebAssembly) ↗
- A Linux 7.x kernel compiled to WebAssembly with an embedded BusyBox initramfs, vsock transport, 9p host file mounts, and live memory snapshots.
- WebAssembly JSPI (JavaScript Promise Integration) ↗
- Standard WebAssembly extension (
WebAssembly.Suspending) that allows compiled kernel code to suspend on async host operations and resume cleanly. - WebMCP (navigator.modelContext) ↗
- Browser specification for registering typed JSON-schema tools (
registerTool) on a web page so agents invoke structured capabilities instead of scraping UI or terminal text. - 9p MemoryFs & Dedicated Worker ↗
- Runs the Linux VM off the main UI thread while mounting a host JavaScript file tree at
/workwith liveonChange()callbacks whenever the guest modifies files. - Port Authority AI Router ↗
- Optional client-side
MessagePortrouter (https://llmchannel.dev/router.js) allowing users to connect their own LLM provider to drive WebMCP tools with zero server-held keys.
Open questions
- How does
unkernel.wasmcold-start latency scale when paired with persistent OPFS block overlays across repeat page visits? - Which subset of POSIX utilities should remain hidden behind typed WebMCP tools versus exposed directly when an agent hits an unanticipated edge case?
Iteration log
- — Initial deployment on
unkernel@0.3.0-261202-b033dc7(Linux 7.3.4+): headless Dedicated Worker runtime, reactive/work9pMemoryFsexplorer, BusyBoxawkCSV analytics, BusyBoxgrepproject search, vsock loopback HTTP preview viavm.fetch(), 5-tool WebMCP surface with optional Port Authority / Chrome Built-in AI / Ollama runner, structured-vs-raw comparator, andvm.snapshot()checkpoint/restore.
Primitives tested: Unkernel (Linux 7.x WASM), WebAssembly JSPI, Dedicated Worker, 9p MemoryFs, Vsock Loopback vm.fetch(), WebMCP (navigator.modelContext), Kernel Snapshot & Restore.
This is an active lab under /labs/ and stays off the main RSS feed until graduated into a full essay.