Husk
GitHub

Computers

Concepts

What a computer is, how one gets created, and the small interface every provider has to satisfy.

A computer is a disposable Linux machine an agent can drive. It has an id, a name, a provider, a state, a working directory, and a small set of things you can do to it.

The interface is deliberately narrow, and completeness matters more than surface area: if the shell tool behaved differently on Docker than on SSH, every husk.yaml would become provider-specific and the abstraction would be worth nothing.

The interface

Everything a caller can do to a machine:

interface Computer {
  readonly id: string;
  readonly info: ComputerInfo;
 
  refresh(): Promise<ComputerInfo>;
  exec(req: ExecRequest): Promise<ExecResult>;
 
  writeFile(path, content, opts?): Promise<void>;
  readFile(path, opts?: { maxBytes }): Promise<Uint8Array>;
  readTextFile(path, maxBytes?): Promise<string>;
  listDir(path): Promise<DirEntry[]>;
  stat(path): Promise<DirEntry | null>;
  remove(path, opts?): Promise<void>;
 
  upload(hostPath, targetPath): Promise<void>;
  download(path, hostPath): Promise<void>;
 
  exposePort(port): Promise<PortBinding>;
 
  stop(): Promise<void>;
  start(): Promise<void>;
  destroy(opts?: { erase }): Promise<void>;
 
  // Optional. Callers feature-detect rather than catching.
  spawn?(req): ComputerProcess;
  markUsed?(): void;
  snapshot?(name?): Promise<{ id: string; sizeBytes?: number }>;
  usage?(): Promise<ComputerUsage>;
  restore?(snapshotId): Promise<void>;
}

readFile refuses a file over maxBytes with E_QUOTA, and stops reading at the limit. destroy keeps what a chat's or a bot's computer persists for its next one, unless erase is set; see Lifetimes.

The optional methods are optional because not every backend can do them. spawn starts a process with its stdin held open, which the browser's long-lived driver needs: Docker, Podman and local. markUsed records use that did not go through exec, on every provider. snapshot, restore and usage (live CPU and memory) are implemented on the container providers, through the shared OciComputer base, and absent elsewhere. Feature-detect with if (computer.snapshot); a catch around a missing method is a bug waiting to be misread as a runtime failure.

States

creating, running, paused, stopped, destroyed, error.

husk ps shows running machines; husk ps --all includes stopped ones. A destroyed machine disappears from the list rather than lingering as a tombstone.

Creation is lazy

Nothing runs inside a machine until something needs it. husk up allocates the workspace or starts the container and writes the record; the first process starts on the first exec.

That matters most for MCP: adding the server to Claude Code has to cost nothing, or people uninstall it. @husk-ai/mcp creates no machine at startup and none on tools/list. The first tool call that needs a computer is what brings one up.

One conversation, one machine

ComputerManager.ensure(key, spec) maps a stable key to a machine:

const computer = await manager.ensure('mcp', { flavor: 'python' });

Call it again with the same key and you get the same machine, with the same filesystem and the same installed packages. That is what lets a Claude Code session keep its /work across forty tool calls without the caller tracking ids.

The mapping lives in ~/.husk/computers/bindings.json. Two concurrent ensure calls with the same key share one in-flight create rather than racing into two machines, and a binding whose machine has been destroyed is cleared and recreated.

The quota

Eight live machines, by default. Creating a ninth throws:

error already running 8 computers (limit 8)
hint:  destroy one with `husk rm <name>`, or raise maxComputers in ~/.husk/config.json

maxComputers in ~/.husk/config.json raises it. Only running and creating machines count.

The spec

Every field a computer can be created with. In a husk.yaml these live under computer:; see the full reference.

FieldTypeDefaultWhat it does
enabledbooleantruehusk.yaml only. false gives the husk no computer at all
namestringgenerated idHuman label, and the container name when unique
providerstringbest availabledocker, podman, local, ssh, fly
imagestringfrom flavorExplicit image reference. Overrides flavor
flavorenumbase; full for a chat's computerbase, python, node, full. The rendered browser needs full — see below
browserenumbrowser in ~/.husk/config.json, else chromechrome or lightpanda — see The browser
cpusnumber2; 1 on FlyCPU allocation
memoryMbnumber2048; 1024 on FlyMemory ceiling
diskMbnumber2048Size of the writable /work layer
idleTimeoutSecnumber900 in a husk.yaml; none for husk up, the API or a chatDestroy after this long with no exec. 0 disables
maxLifetimeSecnumber0Hard ceiling regardless of activity. 0 disables
networkobject{ mode: 'egress' }See Networking
envrecord{}Variables passed in explicitly
mountsarray[]Host paths. Read-only unless readonly: false
workdirstring/workDefault working directory
userstring1000:1000The unprivileged user inside the machine
persistbooleanfalse; true for a chat's computerKeep the filesystem across restarts
packagesarray[]Installed by the flavor's package manager before the computer starts: see below
setupstring—A shell snippet run once after creation
labelsrecord—Free-form metadata, carried on the machine

Flavors

A flavor picks the image. Each one resolves to a single public image maintained by the people who already keep that language or that browser patched. Husk publishes none of its own, and that is a decision rather than an unfinished task: an image you publish is an operating system you have promised to patch, and a stale one carrying known CVEs that people pull because your README told them to is worse than no image at all.

FlavorImageWhat you get
basedebian:bookworm-slimA Debian 12 userland and apt. Add anything else with packages
pythonpython:3.12-slimPython 3.12 and pip, on that same Debian 12
nodenode:22-slimNode 22 and npm, on that same Debian 12
fullmcr.microsoft.com/playwright:v1.59.1-nobleUbuntu 24.04, Node 22, and the shared libraries Chromium needs

full is the only flavor that can run the rendered browser, and that is why it is Playwright's image and not a fatter Debian. @husk-ai/browser downloads Chromium at runtime, but the binary links against roughly twenty shared libraries the slim images do not carry — and a container computer mounts its root filesystem read-only on purpose, so they cannot be installed afterwards. Playwright's image already carries exactly that set, on glibc, maintained by people who track Chromium's dependencies for a living. It is heavier than the rest. That is the trade: full is the flavor you ask for when you want everything, and the browser is part of everything.

HUSK_REGISTRY points a flavor at a mirror instead — <registry>/husk-<flavor>:<tag>, with the public image still there to fall back on if that pull fails, and HUSK_IMAGE_TAG sets the tag. Left unset there is nothing to fall back from, because the public image is the image. The Dockerfiles in sandbox/ are what you build if you want to host that mirror yourself. Fly pulls the image itself and never uses the mirror: a Fly computer runs the public image, or computer.image.

These are upstream images, so what is in them is not husk's to promise: no huskinfo, and no locked root account. A container still runs as uid 1000, because -u 1000:1000 is passed whatever the image says, unless computer.user names another user.

Package installation is per-flavor:

  • base and full: apt-get install -y --no-install-recommends $PKGS
  • python: uv pip install --system $PKGS when uv is present, pip install otherwise
  • node: npm install -g $PKGS

uv rather than bare pip because an agent installing a package should wait two seconds, not forty.

On Docker and Podman a computer cannot install anything itself: its root filesystem is read-only and it holds no capabilities. So packages are installed in a build FROM the computer's image, with an empty context, before the computer exists. The result is tagged husk-packages:<hash> of the image and the list, and reused by every computer that asks for the same list. The computer runs that image, as hardened as any other. The build reaches the package mirror with the engine's own network, before the computer's network policy applies. docker image ls husk-packages shows what was built.

A package is a name with a version if you like (curl, requests==2.32, @scope/tool@1). A name with a space, a quote, $, a backtick or a backslash is refused.

On local, Python and npm packages install with uv, pip or npm. ssh and fly computers refuse packages: on SSH the host is yours to install on, and on Fly use a computer.image that has them.

The browser

A computer's rendered browser is Chrome, unless it asks for Lightpanda, a lighter browser made for automation.

ChromeLightpanda
Downloaded once per computerabout 95–111 MBabout 75 MB, checked against its published SHA-256 before it runs
Draws the pageyesno: no screenshots and no live screen
Tabsas many as a page opensone
Downloads from a linkyesno
Sees what covers a buttonyesno
Providersany that runs Linux: not local on macOS, or on Windows without WSLdocker, podman, and local on Linux
SandboxChrome's own, outside a containernone of its own: on docker and podman the container is its sandbox

Which one to pick

Measured by the e2e run's lightpanda job on GitHub's ubuntu-latest, the same calls on the same page in two Docker computers, one run on 31 October 2026:

ChromeLightpanda
The first page, with the download and the start4.3 s1.9 s
Each call after that (open, read, wait)61–78 ms60–66 ms
Three actions in one browser_run382 ms370 ms
Memory the browser holds548 MB28 MB

Lightpanda's gain is memory and the first start, not each call: past the first page, a call costs the same in both, because the time goes to Husk and the driver rather than to the browser. So:

  • Pick Lightpanda for a bot that runs on its own, on docker or podman, to read pages or fill in forms on sites that welcome it. Several of those fit where one Chrome would, and each starts in about half the time.
  • Stay on Chrome for a chat; for a bot you want to watch in the console; for anything that needs a picture of the page, a login, a download, or a click that must not land under a cookie banner; and for sites that block automated browsers. A computer on Lightpanda moves to Chrome by itself for a picture, a second tab or a person, but not for the rest.

To choose it:

  • for one husk, computer.browser: lightpanda in its husk.yaml;
  • for every computer on this machine that does not say, "browser": "lightpanda" in ~/.husk/config.json;
  • for one chat app, --browser lightpanda on its npx -y @husk-ai/mcp line, or on husk mcp.

A computer's own setting wins over config.json, and with neither it is Chrome. husk doctor says which one this machine uses, and browser_status says which one a computer uses.

When it moves to Chrome. Lightpanda draws nothing, so a computer on it moves to Chrome when something needs a picture or a person: a screenshot, a second tab, a chat's hand_off, or you taking the computer over. The page's address and cookies go with it; whatever the page held only in memory does not. The computer then stays on Chrome, so a login you make there is kept, as on any Chrome computer. Until it moves, its live screen in the console says that Lightpanda draws no screen.

Links that open a new tab, or download. Lightpanda opens no second tab, so a click on a link meant for one is refused with the link's address: browser_goto opens it in the same tab, and browser_tabs open opens it in a new one, which moves the computer to Chrome. It downloads only a file a page's own load sends as one, so a click on a link marked to download is refused too, saying that browser_tabs open moves the computer to Chrome, where the same click downloads it.

What covers a button. Before a click, Husk checks that nothing covers the element. Lightpanda's hit test does not see an element drawn over another, a cookie banner over a button for one, so on Lightpanda that check passes, and the click reaches the button where in Chrome it would be refused, naming the banner.

Where it does not run. Husk keeps Lightpanda's page alive through one long-lived driver, and on ssh and fly there is none, so those computers use Chrome and say why. On local, nothing sandboxes Lightpanda: use docker or podman for pages you do not trust. It needs Linux with glibc, and on arm64 a kernel with 4 KB pages (lightpanda-io/browser#1370).

Telemetry and licence. Lightpanda sends usage telemetry unless told not to, and Husk always starts it with LIGHTPANDA_DISABLE_TELEMETRY=true. It is AGPL-3.0: Husk downloads the unmodified release from GitHub when a computer first needs it, and runs it as a program of its own.

huskinfo

The images in sandbox/ ship a huskinfo script, so an agent on one of those can learn where it is in one call instead of five:

huskinfo

The computer_info tool runs huskinfo when it exists and reconstructs what it can when it does not — which is the default path, since the public images do not carry it. The reconstruction reads /etc/os-release, uname, id and df, and takes CPUs and memory from the cgroup's limits where they are smaller than nproc and /proc/meminfo say, because a container's /proc describes the machine under it. It is close, not equal: husk's own version and flavor are not discoverable from inside the machine, so a computer on a public image knows slightly less about itself than one built from sandbox/.

Where the records live

ProviderWhere "what exists" is stored
docker, podmanContainer labels. The engine is the registry, and ~/.husk/computers/<id>.used holds the last use, which the engine does not record
local, ssh, flyJSON files under ~/.husk/computers/, one per machine

The JSON files are written with write-then-rename, so husk ps works from another process and a crash mid-write cannot corrupt the registry. A corrupt entry is skipped rather than crashing the listing.