Skip to content

Architecture overview

AgentMux is a desktop application built around a small set of long-running processes that exchange events over named pipes (Windows) / Unix domain sockets (Linux + macOS) and a local websocket. Understanding the topology is enough to navigate the rest of the docs.

AgentMux four-process architecture: agentmux-launcher (×1 per channel, single-instance lock) spawns agentmux-cef (×1 per launcher) and agentmux-srv (×1 per launcher, dynamic port). Host embeds Chromium via CEF (×1 main renderer + ×N per browser pane). The SolidJS frontend runs in the main renderer and talks to srv over WebSocket. Multiple AgentMux instances can run side-by-side, each with its own full stack keyed on data-dir channel.

ProcessRoleCrate
launcherResilience and lifecycle layer on all platforms: spawns the host; owns the sidecar lifecycle; durable event log; single-instance enforcement per (channel, version) — the I1 isolation invariant keys the IPC socket/pipe on hash(data_dir + version). On Windows: sets DLL search path; sets up the launcher side of WRR (Window Reality Reconciliation); the Win32 hooks that feed it live in the host (crates/cef/src/wrr/win_event.rs). On Linux: AppImage entry point; Unix-socket IPC server + full reducer + saga coordinator. task dev on all platforms runs through the launcher.agentmux-launcher
hostEmbeds Chromium via CEF; owns the windows (CEF Views top-level windows — browser_view_create + window_create_top_level, crates/cef/src/app/mod.rs), the browser panes, the JS bridge, and IPC fan-out to the renderer. New windows and tear-off floating panes are served from a hidden, pre-warmed pool (see below).agentmux-cef
sidecarApp-domain server: workspaces, tabs, blocks, layouts, agents, identity. Persists to SQLite. Spawned and supervised by the launcher (which owns its lifecycle); listens on a dynamic local port and serves the host + frontend over a WebSocket. Users never run it directly.agentmux-srv
rendererA Chromium renderer process. A window’s renderer runs the SolidJS frontend for that window, shared by all its tabs and non-browser panes. Not a singleton — every OS window gets its own renderer, and every browser pane inside a window adds another, running that pane’s web page. See Windows, tabs, panes and renderers. Stateless — projects what the sidecar/host expose, dispatches user actions back through them.frontend/

The Rust workspace has nine crates (Cargo.toml, [workspace] members). The three above, plus six that aren’t long-running processes of the instance:

CrateWhat it is
agentmux-srv-coreThe sidecar’s engine, as a library: the RPC handlers, SQLite storage and migrations, the reducer, agents, memory, identity and the jekt layer. agentmux-srv (the binary) starts it and serves HTTP and WebSocket.
agentmux-commonShared library: path resolution (DataPaths), runtime mode, the IPC Command/Event types the launcher and sidecar reducers share, jekt signing.
agentmux-mcpThe MCP server each agent’s CLI spawns over stdio. It advertises the MuxAPI tools and forwards each call to the sidecar.
agentmux-bashwrapThe streaming bash wrapper for agents’ shell calls. It is also the program Claude Code’s PreToolUse, PreCompact and SessionStart hooks run, and ssh’s askpass when AgentMux runs ssh for an agent.
agentmux-remoteThe helper AgentMux installs on an SSH host: it keeps durable terminal sessions running there, serves the remote file protocol, and lists processes for Tower.
agentmux-procstatsPer-process CPU and memory read without elevation, for Tower. Used by the sidecar and by agentmux-remote.

The four processes above plus the Chromium subprocesses that the host transparently spawns (GPU, network, storage, …) are collectively one instance — a process tree rooted at one launcher. A baseline single-window dev session runs as launcher + sidecar + host + 1 renderer = 4 processes; opening more windows or browser panes spawns additional renderers. Multiple instances (different versions, dev + portable) run side-by-side without colliding — see Multi-instance & dev mode.

Each process owns one concern, end-to-end:

  • The launcher is the resilience and lifecycle layer. It is the only process that survives an unexpected OS-level event (a window minimize, a monitor disconnection, a focus theft). On Windows, its WRR layer reconciles AgentMux’s own model against what Win32 actually reports. The host observes Win32 (SetWinEventHook and the window procedure) and reports to the launcher. On Linux, the launcher is the AppImage entry point and runs the full reducer + saga coordinator over Unix-domain-socket IPC. WRR is Windows-only by design (not a roadmap gap — see WRR); on macOS/Linux the cross-platform safety net for orphaned/crashed windows is the host’s orphan reconciler.
  • The host is the only process with a CEF context. Windows are CEF Views top-level windows: the host calls browser_view_create + window_create_top_level and lets CEF Views handle resize, snap, and the frameless title bar natively. On Win32 the Views window_handle() can come back NULL, so window operations resolve the real HWND by enumeration. Browser panes, drag/drop, OS focus, and renderer crashes all live or die in the host. Crashing the host kills the user-facing window; the launcher restarts it.
  • The sidecar is the only process that owns durable state. The launcher spawns it (so its lifecycle survives a host crash); closing the host doesn’t lose data — when the host comes back, it reads from the sidecar.
  • The renderer is intentionally state-poor. It’s the projection of what the other processes hold; restarting the renderer (e.g. on hot reload) doesn’t lose anything.

This split is what makes multi-instance work cleanly: each instance has its own host, sidecar, dynamic backend port, process-isolation container (Job Object on Windows / process group on Linux + macOS), and process tree. What instances share on disk depends on whether they’re the same release: two portables of the same (channel, version) share the version-scoped runtime dir (SQLite, CEF cache, host logs) as well as the channel-wide agents/settings; two portables of different versions on the same channel share only the channel-wide agents/settings; two portables on different channels share nothing channel-scoped at all. Every instance also touches account-wide state (sidecar log, dictionaries, launcher config). See Multi-instance & dev mode → What’s per-instance vs per-version vs per-channel for the full matrix.

New windows and tear-off floating panes don’t pay full CEF startup cost on demand. At app start the host spawns a hidden, pre-warmed pool of CEF windows — window-pool-* browsers back new tabs/windows, floating-pool-* browsers back floating panes (init_pool in crates/cef/src/commands/window_pool.rs, init_pane_pool in crates/cef/src/commands/pane_pool.rs). Opening a new window or tearing off a pane promotes a pooled browser: the host repositions and shows it, so the operation is near-instant rather than a cold spawn. Pool windows are kept hidden (not merely off-screen-but-visible) to avoid a Windows blank-window bug. Pool browsers don’t count as user windows — they’re excluded by type from the live-window count that keeps the instance alive (see below).

Closing the last user window quits the instance cleanly. count_live_user_windows() counts only top-level, non-pool browsers (crates/cef/src/reducer/quit.rs); when it reaches zero the host closes the pool browsers, calls quit_message_loop → exit(0), and the launcher’s Job Object (crates/launcher/src/job_object.rs, kill on close) reaps the rest of the process tree — no orphaned trees, no spurious relaunch.

Two CEF Views quirks shape this. First, Views recycles windows on close rather than destroying them, so on_before_close does not fire; close_window therefore calls report_window_closed explicitly (crates/cef/src/commands/window/lifecycle.rs) and emits a WindowClosed event so the status-bar window count stays accurate. Second, to stay correct even if an event is dropped, the frontend detects gaps in the launcher event stream and reconciles from an authoritative snapshot via ReconcileFromSnapshot (frontend/app/store/launcher-event/reducer.ts). On macOS, re-activating a still-running app (Finder double-click, open, or a Dock click) raises a reopen event that the launcher forwards to the host to open a fresh window.

EdgeMechanismWhat flows
launcher ↔ hostNamed pipe (Windows) / Unix domain socket (Linux + macOS)OS-level facts (window position, monitor topology, lifecycle)
host ↔ sidecarLocal websocket (dynamic port)RPC commands, event subscriptions, shell-integration env passing
host ↔ rendererCEF JS bridgePer-frame UI events (clicks, focus, resizes), pane lifecycle
renderer ↔ sidecarLocal websocket (re-uses host’s connection)Frontend dispatches reach the sidecar through the host’s bridge

Every cross-process edge has its own event format, its own ack semantics, and its own persistence strategy. None of them are “just” a function call.

This is where the reducer stack lives. Briefly:

  • Layer 1 — launcher reducer (crates/launcher/src/reducer/) owns process, window-mirror, pool, monitor and instance-registry state. Single-writer; durable JSONL event log.
  • Layer 2 — host reducer (crates/cef/src/reducer/) owns CEF-side coordination: pending window creations, browser panes, the browser map, drag, both warm pools, quit and window opacity — 35 host-internal commands.
  • Layer 3 — srv reducer (crates/srv-core/src/reducer.rs and crates/srv-core/src/reducer/) owns the app domain: workspaces, tabs, blocks, layouts.
  • Layer 4 — frontend slices project the above into per-pane Solid signals via per-slice reducer modules.

Multi-step work runs as sagas, on two separate frameworks: the launcher’s coordinator (crates/launcher/src/saga/) and srv’s async-function sagas (crates/srv/src/sagas/). The reducer stack page explains the difference.

The full layout, slice list, and migration plan are in the reducer stack page.

Outside this reducer stack sits one more piece of cross-process coordination: a file-per-session session-ownership lease (LeaseStore, crates/srv-core/src/registry/leases.rs) that guards which single process may currently drive turns for a given agent instance_id — relevant in host-mode, where more than one process could otherwise reach the same agent. Each lease is <registry_root>/leases/<instance_id>.lease.json, TTL-based (renewed every 5s on the same tick as the per-turn health watchdog; reclaimable once ~3 renewals are missed) and scoped to a boot_id, and the claim/renew/release sequence is guarded by a real OS advisory lock (flock / LockFileEx) rather than the atomic-rename-only pattern the rest of the registry uses, so two processes can never both believe they hold the same session. See Persistence for where the lease files live on disk.

Every running instance resolves its paths through agentmux-common::DataPaths (source). Resolution happens once in the launcher and is propagated to host + sidecar via the AGENTMUX_*_DIR env vars, so all three processes always agree.

ModeChannel rootRuntime dirs
Installed~/.agentmux/channels/<channel>/ (default stable)~/.agentmux/channels/<channel>/versions/<v>/ — per-version runtime DB, cache, logs, IPC
Portable (released .7z)Same as installedSame as installed
Portable (local task package)~/.agentmux/channels/local-<branch>/No version sub-dir — local builds aren’t versioned releases.
Dev (task dev)n/a~/.agentmux/dev/<branch>/<clone-id>/ — one dir per (branch × clone) pair.

Inside each channel dir, state is split into channel-wide and version-scoped paths:

  • Channel-wide (channels/<channel>/): config/ (settings). These survive version upgrades; agent definitions, accounts and provider auth dirs are machine-wide, under shared/.
  • Version-scoped (channels/<channel>/versions/<v>/): data/ (SQLite + launcher event log), logs/ (host and sidecar logs), cef-cache/ (cookies, IndexedDB, JS cache), runtime/ (the single-instance lock and IPC files). These are isolated per release so concurrent versions on the same channel don’t share session state or caches; the machine-wide stores under shared/ are opened by every version.

See Data layout, SPEC_DATA_CHANNELS_2026_05_24, and SPEC_VERSION_ISOLATION_2026_06_01 for the design.

Account-wide state lives outside channels/: the shared databases and agent registries under ~/.agentmux/shared/, agent working folders under ~/.agentmux/agents/, and the launcher’s ~/.agentmux/logs/agentmux-launcher.log. Pre-migration snapshots auto-save in each version’s data/snapshots/<channel>-pre-v<ver>-<iso>.bak/ (newest 5 kept). See Data structure for the full map.

See Multi-instance & dev mode for the full layout, log discovery story, and per-instance vs shared boundary.

If you’re new, read in this order:

  1. You’re here. This page.
  2. Multi-instance & dev mode — gets you to a running AgentMux you can poke at.
  3. Reducer stack — explains how state actually flows through the four processes.
  4. Pane Types — the user-visible building blocks.
  5. The MuxAPI reference when you’re ready to drive AgentMux from an agent.