Architecture
microagent is a Go library with a CLI adapter. The library packages own
workspace lifecycle, rootfs builds, kernel management, image cache management,
diagnostics, shared request/response types, and backend supervisor dispatch.
Each host OS uses one backend.
your orchestrator └─ microagent Go packages ├─ workspace lifecycle, artifacts, logs, network, supervision ├─ rootfs, kernel, image cache, diagnostics └─ vmkit supervisor dispatch └─ backend supervisor ├─ Firecracker supervisor (Linux, Go JSON exec) └─ Apple VF supervisor (macOS, Swift JSON exec)
OCI image ──► pkg/rootfs ──► ext4 disk ──► VMPieces
Section titled “Pieces”cmd/microagent— the CLI adapter. Parses flags, calls the Go packages, and renders structured or human-readable output.pkg/workspace— workspace lifecycle, manifests, state, results, artifacts, logs, network, file copy, clone, and optional supervision loop.pkg/kernel— default kernel manifest plus install, verify, and support checks.pkg/imagecache— reusable rootfs baseline cache and image index.pkg/diagnostics— host/backend preflight checks and support summaries.pkg/vmkit— request/response types and the supervisor interface. The shared shape both backends speak.pkg/rootfs— OCI image to ext4 rootfs builder. Pulls layers viaoras-go, writes a sized ext4 image withmke2fs.pkg/supervisors/firecracker— Go implementation of the Firecracker supervisor, importable directly on Linux when you’d rather not spawn a subprocess.cmd/microagent-firecracker-supervisor— Go executable supervisor for Linux Firecracker lifecycle work. Wrapspkg/supervisors/firecrackeras a JSON-in / JSON-out binary.supervisors/applevf— Swift executablemicroagent-applevf-supervisor. Reads one JSON request from stdin, talks to Apple Virtualization.framework, writes one JSON response to stdout.cmd/microagent-guestinit— small guest init that mounts attached disks and runs--setup/--exec.
Lifecycle of a microagent run
Section titled “Lifecycle of a microagent run”- The CLI parses flags into
pkg/workspaceoptions. pkg/workspaceprepares disks, builds the rootfs withpkg/rootfs, records verification, writes the manifest, and builds avmkit.Request.- The dispatcher selects the host backend.
- The backend supervisor executable handles VM lifecycle work.
- Guest init runs
--setupthen--exec. - State changes are emitted as JSON events. State files live under
--state-dir(default~/.microagent/...). - On
--keep, the workspace stays. Otherwise the workspace API cleans up local state.
Go callers can use the same package flow directly without invoking the CLI.
Why supervisors are separate executables
Section titled “Why supervisors are separate executables”Each backend’s supervisor ships as its own JSON-in / JSON-out binary. That’s deliberate: it keeps host-specific backend code out of the main CLI and lets anything that can spawn a subprocess and parse JSON drive the same protocol — Go, Python, Rust, Node, shell scripts. Apple VF also requires this boundary, because Virtualization.framework is Swift-only.
The shared protocol is documented at supervisor protocol. The Apple VF executable protocol is documented at Apple VF supervisor.