{"slug": "show-hn-bunshin-a-custom-microvm-engine-giving-ai-agents-desktops-in-100ms", "title": "Show HN: Bunshin – A custom MicroVM engine giving AI agents desktops in ~100ms", "summary": "Developer JustVugg released Bunshin version 0.1, an open-source MicroVM engine that creates sandboxed Linux desktops for AI agents in about 0.1 seconds by forking a single pre-booted template VM that shares memory and disk with each copy. Bunshin exposes 15 MCP tools (create, screenshot, click, type, press keys, scroll, drag, run commands) and a live browser console for watching and taking over desktops, with paused desktops resumable from a saved file in 0.4 seconds. The engine is roughly 2,000 lines of C with the rest in Go's standard library, requires Linux x86-64 with KVM, and has been tested only on one Intel x86-64 machine running WSL2 on kernel 6.18.", "body_md": "**Linux desktops for AI agents, on the computer you already own.**\n\n  A new desktop in a tenth of a second. Tools over MCP. A console to watch and take over.\n\n[Italiano](https://github.com/JustVugg/bunshin/blob/main/README.it.md) ·\n  [Quick start](#quick-start) ·\n  [How it works](#how-it-works) ·\n  [Numbers](#numbers) ·\n  [Design notes](https://github.com/JustVugg/bunshin/blob/main/docs/design.md)\n\nbunshin runs many sandboxed Linux desktops on one ordinary computer, gives any agent the tools to use them, and lets you watch every one of them live. Each desktop is a virtual machine with a browser at 1280x800. It is infrastructure only: bring your own agent.\n\nPlain C where it matters, no dependencies, hardware you already have. The engine, the agent inside the machines and everything around them are written for this project, from the first line.\n\nA desktop is never booted. One template boots once, with its windows open, and every\ndesktop is a **live copy** of it: the engine forks the running machine. The copy shares\nmemory and disk with the template and pays only for what it changes.\n\n**Status: early.** Version 0.1, developed and tested on one computer (Intel x86-64, WSL2,\nkernel 6.18). It works end to end there, with an integration test that proves it, but it\nhas not met other machines yet. See [what is missing](#what-is-missing).\n\n| **Desktops in a blink** | about 0.1 s to create one with Firefox open; a paused one wakes at once | \n| **Fifteen MCP tools** | create, screenshot, click, type, press keys, scroll, drag, run commands | \n| **A live console** | every desktop on one page; amber while an agent acts; take control with your own mouse and keyboard | \n| **One click to open an agent** | Claude Code, Codex, pi, Hermes and others start in a terminal with the tools already given | \n| **Stop and keep** | a desktop saved to a file comes back in 0.4 s with every window where it was, even after a reboot | \n| **Memory given back** | what a desktop frees returns to the computer at once; idle desktops are paused | \n| **Network by name** | you choose the sites desktops may reach; your computer and local network stay closed | \n| **Images without root** | the desktop image is built from inside a machine: no Docker, no administrator rights | \n| **No dependencies** | the engine is about 2,000 lines of C; the rest is Go with its standard library | \n\n- Linux on x86-64 with KVM: bare metal, a cloud machine with nested virtualization, or\nWSL2 on Windows 11. Your user must be able to open `/dev/kvm` (`sudo usermod -aG kvm $USER` , then a new session).\n- `gcc` ,`make` , Go 1.24 or newer, and`mke2fs` (package`e2fsprogs` ).\n- A guest kernel. On WSL2 the kernel that ships with WSL is found and used by itself.\nAnywhere else see [docs/kernel.md](https://github.com/JustVugg/bunshin/blob/main/docs/kernel.md) .\n\n```\ngit clone https://github.com/JustVugg/bunshin\ncd bunshin\nmake                       # build/bunshin-vmm (the engine) and build/bunshin\nmake install               # copies both to ~/.local/bin\n\nbunshin doctor          # checks KVM, the kernel, the engine and the image\nbunshin init            # builds the desktop image once, then starts the template\nbunshin create a b      # two running desktops\nbunshin key a ctrl+l && bunshin type a \"example.com\" && bunshin key a Return\nbunshin screenshot a    # writes a.png\nbunshin console         # watch them live in your browser\nbunshin rm a b\n```\n\nNothing is downloaded to build. `init` builds the desktop image the first time: it\ndownloads the Debian base system and the desktop packages (Xvfb, openbox, tint2, Firefox\nESR), a few hundred MB, in about ten minutes.\n\nWithout building: each [release](https://github.com/JustVugg/bunshin/releases) has an\narchive with both programs, statically linked for x86-64 Linux. Unpack it, copy `bunshin`\nand `bunshin-vmm` into the same directory on your `PATH`, and start from `bunshin doctor`.\n\n**From the console.** At the bottom of the console there is a dock with the logo of each\nagent installed on the computer: Claude Code, Codex, pi, Hermes, OpenClaw, OpenCode, Gemini\nCLI. Click one and a terminal opens with that agent running, already given the bunshin\ntools. Under WSL the terminal is a Windows Terminal tab.\n\n**From a terminal.**\n\n```\nbunshin connect                 # the agents found here and their state\nbunshin connect codex pi skill  # connect these\nbunshin disconnect codex\n```\n\n`connect` writes the entry each agent expects in its own configuration file, after keeping\na copy of it. It knows Claude Code, Codex (the CLI, the app and the IDE extension share one\nfile), pi, OpenCode, Claude Desktop, Cursor, Gemini CLI and Windsurf. Under WSL it also\nfinds Claude Desktop and the Codex and Cursor apps installed on Windows and connects them\nthrough `wsl.exe`.\n\n**By hand**, for any MCP client:\n\n```\n{ \"mcpServers\": { \"bunshin\": { \"command\": \"/absolute/path/to/bunshin\", \"args\": [\"mcp\"] } } }\n```\n\n`bunshin mcp` serves fifteen tools: `create_desktop`, `list_desktops`, `delete_desktop`,\n`start_desktop`, `pause_desktop`, `fleet_status`, `screenshot`, `click`, `move_mouse`,\n`drag`, `scroll`, `type_text`, `press_key`, `cursor_position` and `run_command`. Actions\nreturn a screenshot of the result, and an action on a paused or stopped desktop wakes it.\n\nA skill that teaches an agent to use the fleet well (split work across desktops, stay within\nthe computer's limits, hand logins and payments to you, clean up) is in\n[`skills/bunshin-desktops`](https://github.com/JustVugg/bunshin/blob/main/skills/bunshin-desktops/SKILL.md); `bunshin skill`\nprints it.\n\nRemote clients can use streamable HTTP with a bearer token:\n\n```\nBUNSHIN_MCP_TOKEN=change-me bunshin mcp --http 127.0.0.1:7400   # endpoint: http://127.0.0.1:7400/mcp\nbunshin console\n```\n\nPrints a link to a local page with every desktop live, its CPU and memory, and the latest\nagent action. A desktop's border turns amber while an agent acts on it. Click a desktop to\nwatch it closely and follow its activity, or press **Take control** to use your own mouse\nand keyboard on it; while you are in control, agents can look but their input is refused.\nThat is how logins, captchas and payments are meant to be done.\n\nThe page is served on 127.0.0.1 only, the link carries a token, and requests from other sites open in the same browser are refused.\n\nThe engine, `bunshin-vmm`, is a small virtual machine monitor on KVM: about 2,000 lines of\nC, one process per machine. Four decisions do most of the work.\n\n**A copy is a fork().** Guest memory is a private mapping of the engine process. To copy a\nrunning machine the engine stops its virtual CPUs for two or three milliseconds, reads\ntheir state from KVM, and forks. The child process is the new machine: it inherits memory\nand device state as they are, rebuilds only what lives in the host kernel, and resumes from\nthe same instruction. Pages are shared until one side writes them. Every machine can be\ncopied at any time, and a copy of a copy is just another fork: no snapshot files, no chain\nto compact.\n\n**The disk is shared memory.** The disk image is mapped into the guest as persistent memory\n(virtio-pmem) and mounted with DAX. Program files are read straight from the host page\ncache, once for the whole fleet, with no second copy inside each guest. What a desktop\nwrites lands in its own private pages. Copies get this for free from the same fork.\n\n**No network card.** Programs inside a desktop use an HTTP proxy on its loopback; the agent\ncarries each connection to the host, where the daemon serves it. Every request names its\ndestination, so the policy is by site name, checked again on the address the name resolves\nto. This computer and its local network are closed to desktops unless you open them.\n\n**The agent speaks X11.** The first process of every machine is a static agent built into\nthe engine, so its version always matches. It runs commands, moves files, and takes\nscreenshots and sends input by talking to the X server directly, in one process: nothing to\ninstall in the image, nothing to start for every click.\n\nMore in [docs/design.md](https://github.com/JustVugg/bunshin/blob/main/docs/design.md) and [docs/protocol.md](https://github.com/JustVugg/bunshin/blob/main/docs/protocol.md).\n\nMeasured on a laptop (Intel i7-1355U, 12 threads, 25 GB, WSL2, kernel 6.18).\n\n**The Firefox desktop** (the default image; template with 2 GB and 2 CPUs):\n\n|  | Measured | \n|---|---|\n| Create a desktop, as seen by the caller | 60 to 110 ms; up to 330 ms each when several are made in a row | \n| Memory of its own, right after creation | 16 to 38 MB | \n| Memory of its own, after a minute of sitting idle | 110 to 150 MB (Firefox keeps working in the background) | \n| Its share of the memory common to the fleet | about 220 MB | \n| Pause a desktop, wake it and run a command | 137 ms, three command line starts included | \n| Stop a desktop to disk | 3.3 s (2.5 s of it waiting for the desktop to hand back free memory); a file of 530 to 620 MB | \n| Start it again from disk and run a command | 0.4 s | \n| Boot the template, to a settled screen (once) | 17 s | \n| Build the image (once; mostly downloading and unpacking packages) | about 11 minutes | \n\n**The minimal test image** (an X server and one window, 512 MB, 2 CPUs), which shows what\nthe engine itself costs:\n\n|  | Measured | \n|---|---|\n| Create a desktop | 32 to 39 ms | \n| Running machine stopped during a copy | 2 to 3 ms | \n| Memory of a fresh copy | about 1 MB of its own | \n| Wake a paused desktop and run a command | 13 to 16 ms | \n| Save a machine to a file, and start it again | 45 ms and 37 ms | \n\n`bunshin status` shows free memory, desktops by state, the limits and how many more\ndesktops fit. Agents get the same from `fleet_status`. A new or waking desktop is refused,\nwith advice, when it would leave the computer short of memory. A fresh copy uses almost\nnothing and grows as it works, so the room is computed from what desktops may still grow\ninto, not only from what they use today.\n\nDesktops with no activity for 10 minutes are paused; the next action resumes them. Watching a desktop in the console is not activity.\n\n**Memory comes back.** Each machine tells the engine which blocks of its memory are free,\nand the engine returns them to the host at once. Before an idle desktop is paused it also\ndrops its file cache and gathers its free memory. In the test, a desktop that filled 119 MB\nand deleted the file went back to 9 MB.\n\n**Stop keeps everything on disk.** `bunshin stop NAME` saves a desktop to a file and\nturns it off: no memory, no CPU, and it survives a restart of the computer. `start`, or\nsimply the next action, brings it back with every window where it was. Set\n`BUNSHIN_IDLE_STOP` to have idle desktops stopped by themselves. One thing to know: a\ndesktop started from disk no longer shares memory with the template, so it costs its full\nsize in memory (about 600 MB for the Firefox desktop) until it is deleted.\n\n| Variable | Default | Meaning | \n|---|---|---|\n| `BUNSHIN_RESERVE_MB` | 2048 | memory always kept free for the computer itself | \n| `BUNSHIN_DESKTOP_MB` | 512 | memory budgeted per desktop | \n| `BUNSHIN_MAX_DESKTOPS` | none | hard cap on running desktops | \n| `BUNSHIN_IDLE_PAUSE` | 10m | pause desktops idle this long; `0` turns it off | \n| `BUNSHIN_IDLE_STOP` | off | save to disk and stop desktops idle this long, for example `2h` | \n| `BUNSHIN_ALLOW` | everything | comma-separated sites desktops may reach (subdomains included) | \n| `BUNSHIN_DENY` | nothing | sites that are always refused | \n| `BUNSHIN_PRIVATE` | unset | `1` lets desktops reach this computer and private networks | \n| `BUNSHIN_OFFLINE` | unset | `1` refuses every connection | \n| `BUNSHIN_PORTS` | 80,443 | ports tunnels may reach; `*` for any | \n| `BUNSHIN_NET` | open | `ask` : a site not on the allow list is refused and waits for your approval in the console (or`bunshin allow SITE` ) | \n| `BUNSHIN_SAVE_KEY` | none | passphrase: stopped desktops are encrypted on disk | \n| `BUNSHIN_ALLOW_SECRETS` | unset | `1` lets agents type things shaped like API keys into desktops | \n| `BUNSHIN_KERNEL` | found | guest kernel (a Linux bzImage) | \n| `BUNSHIN_HOME` | `~/.local/state/bunshin` | where machines, images and logs live | \n| `BUNSHIN_MCP_TOKEN` | none | bearer token for `mcp --http` | \n| `BUNSHIN_CUA_TOKEN` | made up | token for `cua-server` (required on an address other than 127.0.0.1) | \n| `BUNSHIN_SANDBOX` | on | `off` runs the engine unconfined, to find out whether a problem comes from the confinement;`partial` accepts a kernel without Landlock | \n\nThe variables are read by the daemon when it starts. To change them:\n`bunshin daemon stop`, then run any command with the new values. Machines keep running\nacross a daemon restart.\n\nThe desktop image is an ext4 file. `bunshin image build` makes it with no root, no\nDocker and no loop devices: it formats an empty file with `mke2fs`, boots a builder machine\nwith that file as its writable disk, sends the base system into it file by file (the agent\ninside creates them as root), then runs a setup script there.\n\n```\nbunshin image build                       # Debian trixie with the desktop, the default\nbunshin image build --tar rootfs.tar.gz   # start from your own root filesystem archive\nbunshin image build --tar rootfs.tar --setup my-setup.sh -o my.ext4\nbunshin init --image my.ext4\n```\n\nAn image only has to do one thing: start an X server on display `:1` from\n`/etc/bunshin/boot`, a shell script the agent runs at boot. The built-in script and setup\nare in [`internal/image/files`](https://github.com/JustVugg/bunshin/blob/main/internal/image/files).\n\n`bunshin cua-server` serves the desktops through the API of Cua's computer-server, so\ncode written for Cua Cloud runs after changing environment variables:\n\n```\nbunshin cua-server      # serves http://127.0.0.1:8000 and prints a token and the variables to set\n```\n\nServed: `POST /cmd` (screenshots as PNG or JPEG, clicks, mouse down and up, drags,\nscrolling, typing, keys and hotkeys, `run_command` with a timeout, the file commands) and\n`/v1/vms` to create, list, start, stop, suspend, restart and delete. Requests name their\ndesktop with `X-Container-Name` or a `/d/NAME/` base URL. Not served: the WebSocket API,\nclipboard, window management, terminals and `/playwright_exec`.\n\nA desktop is a hardware virtual machine: what runs in it, including a browser on a hostile page, stays in it. The short version of how:\n\n- **The engine confines itself** before the machine starts. A system call filter leaves it\nunable to start a program, connect to anything or open a network socket; Landlock leaves\nit able to open only the directory of running machines and`/dev/kvm` . A flaw in the\nengine would leave a guest with that, not with your account.\n- **The network** leaves only through the proxy, to web ports, never to this computer or\nto private and overlay networks. With`BUNSHIN_NET=ask` , a site you have not approved\nis refused and waits for you in the console.\n- **The console** is for this computer only; its links work once.\n- **Every desktop is sealed** into its own directory, and gets cores and randomness of its\nown. Nobody acts on the template.\n- **Secrets stay out:** agents cannot type things shaped like keys into a desktop, typed\ntext is never logged, and stopped desktops can be encrypted (`BUNSHIN_SAVE_KEY` ).\n- **The fleet pauses the largest desktop** before the computer runs short of memory.\n\nWhat the virtual machine does not solve is the agent itself reading a page that tells it\nwhat to do. Every screenshot comes with a reminder that the screen is not an instruction,\nbut the firm limits are yours to set: `BUNSHIN_NET=ask` or `BUNSHIN_ALLOW` for the\nsites, and **Take control** for logins and payments.\n\nThe full review, with what is still open, is in [docs/security.md](https://github.com/JustVugg/bunshin/blob/main/docs/security.md). The\nengine's code is new and has been read by its author and by machines (`make fuzz`), not\nyet by an outside reviewer.\n\nHonest list, most important first.\n\n- **Other computers.** Only one host has run this. Other CPUs (AMD in particular), other\nkernels and bare-metal Linux are untested.\n- **Things not tried for real.** The Cua server was checked with plain HTTP requests, not\nwith the cua-computer and cua-sandbox packages. Of the agent connections, the tests cover\nCodex, pi and the skill; the others follow each agent's documented format and have not\nbeen tried against the program itself.\n- **macOS and arm64.** The engine is KVM on x86-64 only.\n- **Memory of a working browser.** Free memory goes back to the host, but an idle Firefox\ndesktop still holds 110 to 150 MB of its own.\n- **Sharing after a start from disk.** A desktop started again from its file is a machine\nof its own: it no longer shares memory with the template.\n- **Non-HTTP network.** Only programs that use an HTTP proxy reach the outside. That covers\nbrowsers,`curl` ,`apt` and most tools, not raw TCP or UDP.\n- **Prebuilt images to download.** The image is built on your computer the first time.\n- **Boot time of the template** is dominated by the kernel unpacking itself (about 0.8 s);\nloading an uncompressed kernel would remove it. Copies are unaffected.\n\n```\nmake test                 # unit tests\nmake test-integration     # boots real machines: needs KVM, a guest kernel and Xvfb\nmake fuzz                 # hostile input against the device code and the agent port, under sanitizers\n```\n\nThe integration test downloads nothing. It builds a small image out of programs already on the computer, starts a template, copies it, and checks copies, input, screenshots, pause, the network policy, memory given back, stop and start from disk, MCP, the Cua server, connecting agents and the console.\n\n- `vmm/` : the engine (`bunshin-vmm` ): KVM, boot, ACPI, virtio devices, live copy, save to file,\nconfinement\n- `guest/` : the agent that runs inside every machine, and its X11 client\n- `cmd/bunshin` ,`internal/` : the command line tool, daemon, fleet, MCP server, proxy,\nimage builder, console, Cua-compatible server and agent connections\n- `skills/` : the skill for agents\n- `site/` : the project page (one self-contained file);`web/` : the sources of the site, the\nconsole page and the logo (`make pages` rebuilds them;`web/trace-logo.py` turns the artwork into outlines)\n- `assets/` : logo and icon;`docs/` : design notes, wire protocol, kernel requirements\n- `tests/` : the integration test and its helpers\n\nApache-2.0 (see `LICENSE`). The agents' logos shown in the console belong to their owners:\nsee `THIRD_PARTY_NOTICES.md`.", "url": "https://wpnews.pro/news/show-hn-bunshin-a-custom-microvm-engine-giving-ai-agents-desktops-in-100ms", "canonical_source": "https://github.com/JustVugg/bunshin", "published_at": "2026-11-30 11:52:48+00:00", "updated_at": "2026-11-30 12:16:27.565944+00:00", "lang": "en", "topics": ["ai-agents", "agent-protocols", "ai-tools", "developer-tools", "artificial-intelligence"], "entities": ["Bunshin", "JustVugg", "Claude Code", "Codex", "Firefox ESR", "WSL2", "MCP", "Debian"], "also_reported_by": [], "takeaway": "Bunshin forks a single booted template VM so each agent desktop starts in about 0.1 seconds while sharing memory and disk with the template, and exposes 15 MCP tools for screenshot, click, type and command control.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/show-hn-bunshin-a-custom-microvm-engine-giving-ai-agents-desktops-in-100ms", "markdown": "https://wpnews.pro/news/show-hn-bunshin-a-custom-microvm-engine-giving-ai-agents-desktops-in-100ms.md", "text": "https://wpnews.pro/news/show-hn-bunshin-a-custom-microvm-engine-giving-ai-agents-desktops-in-100ms.txt", "jsonld": "https://wpnews.pro/news/show-hn-bunshin-a-custom-microvm-engine-giving-ai-agents-desktops-in-100ms.jsonld"}}