This page is for contributors. It describes how abx is put together so you can find where a behavior lives before you change it. For the user’s view of the same behavior, start with Boxes and the CLI reference.
abx is one native executable built from apps/cli and fourteen workspace packages. scriptc compiles the TypeScript, together with the C layer in apps/cli/native, into a single binary.
Packages
- apps
- cli (the
abxexecutable)
- cli (the
- packages
- host-platform
- guest
- smolvm
- network
- agent-api
- agent-claude
- agent-codex
- agent-opencode
- agent-pi
- agent-agy
- agent-cursor
- auth
- git
- images
| Package | Role | Workspace dependencies |
|---|---|---|
host-platform |
Host target detection, Linux trust checks for executables and state directories | none |
guest |
The CLI installed inside every VM at /usr/local/libexec/abx-guest |
none |
smolvm |
Wrapper around the pinned smolvm engine | host-platform |
network |
Network policy | smolvm |
agent-api |
The adapter contract every agent implements | guest |
agent-claude, agent-codex, agent-opencode |
Agent adapters | agent-api, guest |
agent-pi, agent-agy, agent-cursor |
Agent adapters | agent-api |
auth |
Credential providers and host logins | agent-api, host-platform, network |
git |
Review and landing of Git work | host-platform |
images |
Base image builder | agent-api, guest, host-platform, network, smolvm |
apps/cli |
The abx executable |
every package above |
Packages never import apps/cli, and they never print abx command names. They throw errors with a code (GitError, ImageError, AuthError). apps/cli/src/output/errors.ts adds the CLI’s advice and passes those codes into the JSON error envelope next to the CLI’s own. See Error codes for the user-facing list.
Each package has a README on GitHub: smolvm, network, agent-api, auth, git and images.
Platform layer
Host policy, trust and layout for macOS and Linux live in these places:
packages/host-platformdetects the host target (darwinorlinux,arm64orx64, mapped to the guest’sarm64oramd64) and enforces the Linux unprivileged-user requirement. It resolves the account through libc NSS and owns the Linux trust checks for executables (system tools, secret providers, host-login clients, smolvm) and state directories (localext4, no group or other writers).packages/smolvm/src/host-layout.tsandlinux-install.tsmap per-OS engine paths, scrub the childPATH, setLANG=C.UTF-8, and verify the Linux smolvm 1.38.2 install (wrapper checksum, binaries and libraries) before executing even--version.apps/cli/src/platformenforces per-command prerequisites, inspects/dev/kvmand itskvmgroup, builds install hints from/etc/os-release, and locates trusted host-login binaries.packages/gitsupports Git 2.39 and later.
The user-facing side of these checks is on Linux hosts.
CLI layout
apps/cli/src has three layers and a few shared leaves. Imports go from the top down:
commands/ parse options, call into boxes/, print results
boxes/ box lifecycle: state, creation plan, launch, stop, removal, landing, credentials/
auth/ config file, host logins, credential verificationplatform/, sessions/ (terminal handoff, terminfo, dtach sessions), status/ (the readiness behind abx status and the wizard) and output/ (styling, step progress, the JSON error envelope) sit beside them. boxes/ uses sessions/ and auth/. Nothing in boxes/ imports commands/, nothing in auth/ imports boxes/ or commands/, and nothing in sessions/ imports boxes/, auth/ or commands/. workspaces/ (marker, registry, link) uses boxes/. agents.ts, guest.ts, home.ts, lock.ts, policy.ts and private-files.ts are leaves any layer may import.
Each command is a Command value in its own file under commands/, with its name, usage, options, notes, examples and a run function. commands/registry.ts lists them. The same list produces abx help, abx help --json and the dispatcher, so a command that is not in the registry does not exist. commands/flags.ts is the single option parser, and it produces the usage errors and exit status 2.
native-main.ts and main.ts declare the C functions from native/ and pass them to runCli as services: process replacement, file locks, descriptor hygiene, Linux account lookup, renewal worker spawning, the wizard and TUI terminal, and progress rendering. Help and parsing never open smolvm, so they work before it is installed.
The life of a box
-
Plan.
planBoxreads the template, the agents requested, the saved auth selections and connector settings from$ABX_HOME/config.toml, and the--access,--auth-profile,--connectorsand--no-connectorsoptions. It selects credential bindings, collects the allowed hosts and builds the network policy. The result is aBoxrecord. See Network policy. -
Create. The box directory and its
transcripts/directory are created, thenbox.jsonis written withready: false, thensmolvm.createmakes the machine from the template with the policy, bindings and labels. The machine mounts one read-write share,transcripts/. For a Git box the base bundle is imported and the branchagent/<box>is created. Last, the ready label is set andbox.jsonis rewritten withready: true. An interrupted creation is resumed on the next launch. -
Open. Every launch inspects the machine and compares its labels, network settings, credential bindings and mounts with
box.jsonbefore running anything. A mismatch stops the launch withpolicy-mismatch. -
Launch. Credentials are resolved on the host just before the VM starts.
sessions/prepares terminfo and a nameddtachsession in the guest, then runssmolvm machine exec. An interactive launch replaces theabxprocess, so the exit status of the guest command is the exit status ofabx. A one-shot launch spawns the command and waits instead, soabxcan report its own failures with exit status 125. See Sessions and Headless mode. -
Renew. A box with a renewable host login (or a masked
pass://binding on Linux) gets a detachedabxworker on the host that refreshes the credential in the machine and records delivery observations forabx auth status --box NAME. -
Stop.
stopchecks for active guest processes and verifies the policy, returns any checked-out guest profile, and stops the machine.--forceskips the process check. -
Land.
diffandlandrun on the host against the staging repository. See Review and land. -
Remove.
rmdeletes the machine and the staging repository, then moves the box directory to the workspace’sarchive/in one rename, in that order, so an interrupted removal can be retried.
State and locks
All host state is under $ABX_HOME (~/.abx). home.ts owns the layout: openHome creates the home and writes layout.json, checkHome is the read-only check that creates nothing, and both refuse a home of another layout before reading anything else. On Linux, both ABX_HOME and the smolvm state root must live on local ext4. config.toml is the only human-edited file and the only TOML file. abx writes the rest as JSON.
A workspace is a Git repository or a scratch folder. Its id is a UUID in a marker file (<git common dir>/abx/workspace.json or <folder>/.abx/workspace.json). workspaces/registry.ts keeps one directory per workspace, workspaces/<name>-<id8>/, with a workspace.json that records the id, kind, name, folder and last use. It finds a workspace by id and never by parsing the directory name. A box is a directory under boxes/<name>-<id8>/ with box.json, staging.git/ and transcripts/. It is live while box.json is there, and rm moves the directory to archive/. See Workspaces.
transcripts/ is the only directory a machine mounts. Its path is stored in box.json and must equal transcripts/ under the canonical path of the box’s own directory, so an edited record cannot mount another host directory. The guest controls what is inside it, so the host never creates, writes or follows anything below it.
Locks are flock descriptors taken through the C layer and wrapped by withLock in lock.ts. Most live under locks/ in the home: user config, workspace registry writes, the image build, credential-bound starts per template, verification receipts, host and guest login profiles, each box and each renewal worker. Two locks guard files in the user’s folders and stay outside the home, because they must hold across different ABX_HOME directories: the marker lock next to each marker, and <git common dir>/abx/land.lock, which serializes landing into one repository. When an operation needs both, it takes the marker lock first, and both are taken outside the box lock. Files that hold credentials or state are read and written through private-files.ts, which refuses symlinks, wrong owners and loose modes.
Image build
abx image build calls buildImage in packages/images with the recipe for the host architecture. See Images for the user’s view.
-
Take the build lock. Unless
--rebuildwas passed, return the current template if it matches the host guest architecture, agent selection andartifactDigest. The same agents with different pins fail withimage-changedinstead of rebuilding; a different agent selection builds a new template. -
Create a disposable builder machine, restricted to build hosts, with no mounts or credential bindings. Before any guest command, and after every state or network transition,
verifyImageMachinechecks the builder’s policy. A mismatch throwspolicy-mismatchand deletes the builder. -
Prepare the base OS, install the
@agent-box/guesthelpers, and install each selected agent from pinned versions. -
Seal the builder: stop it, reset the allow list, switch to no network, and verify the machine at each step.
-
Pack the builder into a template and restore it twice as offline clones. Each clone must report the expected architecture, user, disk, network, helper digests and agent versions. The first clone writes a marker file and the second must not see it.
-
Publish the template as
images/template-<id>/base.smolmachine, read-only, and write the metadata (guestArch,artifactDigest, pack SHA-256) tocurrent.json. Remove the builder and clones.
Creating a box, or resuming an interrupted creation, reads the template through readVerifiedImage, which checks the guest architecture and the recipe (artifactDigest and agent selection) and hashes the pack again. An existing box keeps the template it was created from. A template contains no credentials and is not reused across architectures, pins or modified bytes. artifactDigest includes the digests of the embedded guest bundles, so a change to packages/guest invalidates older templates. See Embedded scripts.
Auth verification
abx auth verify <agent> starts a short-lived box from the active template with the real binding, asks the agent for one bounded model turn, and writes a versioned receipt in the template’s directory. The receipt binds a hash of the local machine identity, host OS, CPU architecture, smolvm version, network backend, template ID, image digest and the policy fingerprint (agent and pinned version, provider, mode, credential binding, hosts, guest arguments and probe). The machine identity is the platform UUID on macOS and /etc/machine-id on Linux. abx auth status and credential selection read these receipts to decide whether a masked credential may be released. Copying $ABX_HOME to another host leaves agents unverified until they are verified there. The code is in apps/cli/src/auth/verification/. For the user’s view, see Verification.