Skip to main content

Crate agentmux_common

Crate agentmux_common 

Source
Expand description

Shared utilities for AgentMux crates.

Re-exports§

pub use data_paths::isolated_auth_enabled;
pub use data_paths::isolated_auth_reason;
pub use data_paths::isolated_muxbus_reconnect_enabled;
pub use data_paths::isolated_muxbus_reconnect_reason;
pub use data_paths::isolated_settings_enabled;
pub use data_paths::isolated_settings_reason;
pub use data_paths::DataPaths;
pub use data_paths::IsolatedAuthReason;
pub use data_paths::IsolatedMuxbusReconnectReason;
pub use data_paths::IsolatedSettingsReason;
pub use errors::AgentMuxError;
pub use errors::AmxCode;
pub use settings_path::settings_dir_for;
pub use settings_path::SETTINGS_FILE;
pub use pin::PinRecord;
pub use layout_intent::LayoutEdge;
pub use layout_intent::LayoutIntent;
pub use layout_intent::LayoutResizeOp;
pub use layout_intent::LayoutViewState;
pub use layout_types::FlexDirection;
pub use layout_types::LayoutClientSlices;
pub use layout_types::LayoutNode;
pub use layout_types::LayoutNodeData;
pub use layout_types::SplitPosition;
pub use layout_types::StackMovePosition;
pub use runtime_mode::is_dev_build_exe;
pub use runtime_mode::is_dev_self;
pub use runtime_mode::RuntimeMode;
pub use toolchain_path::refresh_login_path_cache;
pub use toolchain_path::enrich_current_process_path;
pub use toolchain_path::enrich_current_process_path_cached;
pub use toolchain_path::looks_like_launchd_default;
pub use toolchain_path::resolve_login_path;
pub use toolchain_path::EnrichOutcome;
pub use toolchain_path::EnrichedPath;
pub use toolchain_path::PathSource;

Modules§

agent_create_types
The request types of Agents create and of the runtime choice Agents spawn shares with it. Re-exported by api_types, where the rest of the agent requests are.
agent_roots
The agent CLIs srv is running, kept on disk for the launcher.
allowed_origins
The sites an agent’s browser pane may go to, when the agent limited it with OpenBrowser({allowed_origins}) (docs/specs/SPEC_BROWSER_PANE_ALLOWED_ORIGINS_2026_10_09.md §2).
api_types
Canonical HTTP request/response DTOs shared between agentmux-srv, agentmux-mcp, and agentmux-bashwrap. Every struct here is the single source of truth for the corresponding wire shape; the three crates all import rather than redeclare these types.
appimage_record
Which data channel an AppImage runs in, kept so that moving or renaming the file doesn’t lose it (#47873).
browser_control_types
The request types of the Browser actions that take back, take, give up and report on control of a pane (retake, take_control, release, handoff_status), zoom a pane (zoom) and find what is at a point of a screenshot (locate). Re-exported by api_types, where the rest of the browser requests are.
build_kind
What kind of build this binary is: a published release, a local package build, or a source-tree dev build.
build_slot
Puts the build slot where agents’ shells find it, so only one heavy build or test runs at a time on a machine: docs/specs/SPEC_BUILD_SLOT_ENFORCEMENT_2026_10_20.md.
capture_shape
The shape a Browser capture can ask a value to have (#47629).
checkout
Is a test binary running the code of the checkout that runs it?
client_events
Payloads of the broker events agentmux-bashwrap publishes through srv’s POST /agentmux/wps/publish. srv declares the same types for these events (backend::mps_events), refuses a publish whose data isn’t one of them, and generates them for the frontend, so the three can’t drift (docs/specs/SPEC_CODEGEN_REMAINING_GAPS_2026_10_13.md, step 2).
copy_into_dir
The one “copy a file or folder into a directory” used by drag and drop, paste, and the attachment store’s copy-to-workdir. docs/specs/SPEC_DRAG_AND_DROP_CONSOLIDATION_2026_09_27.md §5.5.
data_paths
Unified data-path resolution for AgentMux.
debug_privilege
Whether this process holds SeDebugPrivilege enabled.
deeplinks
Deep links: one address for every place AgentMux can show (docs/specs/SPEC_DEEP_LINKS_ONE_FRAMEWORK_2026_11_20.md). The registry of destinations (crates/common/deeplinks/destinations.json) is generated into registry.rs; parse reads a link against it. srv’s guard and the Pane tool read both; the app has the same pair in frontend/app/deeplinks/.
dev_home_guard
A dev build started by hand must not run on the real AgentMux home.
disk_space
Free and total space of the volume that holds a path, on every platform.
errors
Cross-process error catalog.
event_log
Reducer event log: an in-memory ring buffer of recent Events for replay, plus an optional append-only JSON-lines disk stream for crash forensics.
file_rename_types
The request of POST /api/v1/file/rename, which agentmux-mcp’s Pane (rename with target file) sends to srv. Kept out of api_types.rs, which re-exports it, for that file’s size.
gateway_stamp
The stamp the container agents’ gateway forwarder puts on a model-gateway request, and what srv checks.
github_broker_shim
The gh and git shell functions of an agent whose GitHub access goes through AgentMux Cloud.
incidents
The incident record: what went wrong and what AgentMux did about it, kept for the user (docs/specs/SPEC_RECOVERY_NOTICES_AND_TOASTS_2026_10_16.md §4.1). The host writes the cases it handles (agentmux-cef commands::incidents), the launcher the ones only it sees (a restart); the frontend shows each one the user hasn’t closed.
ipc
Phase B.2 IPC wire protocol — shared between agentmux-launcher (server) and agentmux-cef (client). One source of truth so the Command / Event shapes can’t drift between binaries on a version-skew release.
jekt_files
Files sent with a jekt: the manifest, its digest, and how the msgid binds it (docs/specs/SPEC_JEKT_FILE_TRANSFER_2026_10_05.md §3.2–§3.3).
jekt_sign
Jekt sender signing/verification: five schemes, each over its own material:
lan_firewall_rules
The Windows Firewall rules that let LAN peers reach AgentMux, and what to change to get from the rules a machine has to those rules (docs/specs/SPEC_LAN_FIREWALL_SETUP_2026_10_01.md 4.1). Pure: it reads and writes nothing. The elevated helper in the launcher reads the machine’s rules into Existing, asks plan what to do and applies the answer; running it twice changes nothing the second time.
lan_install_binding
An agent’s own statement of which install hosts it, for a LAN peer’s pin (docs/specs/SPEC_LAN_KEY_CONTINUITY_2026_10_29.md). A certificate shows only that some trusted install wrapped the agent’s public key in one, which any install of the account can do for a key it has seen. This statement is signed with the agent’s own LAN key, so only the host that holds the private half can make it.
layout_intent
Layout intents: the frontend’s layout-tree actions, sent to srv instead of the tree they produce. Each variant is one LayoutTreeActionType of frontend/layout/lib/types.ts, with the same type tag and field names, so the frontend sends what its own reducer applied. docs/specs/SPEC_STRONG_REDUCER_AUTHORITY_LAYOUT_2026_06_30.md §4.
layout_types
Shared layout tree types used in both the srv wire protocol (ipc.rs Command/Event variants) and the srv object store (obj.rs LayoutState).
local_http
The HTTP client of a program that only talks to the local AgentMux server (the MCP server, bashwrap, the desktop host’s credential broker): plain http on the loopback, never https.
log_retention
Log-file retention, shared by srv and the CEF host (each rotates its own logs into its own directory).
login_pty
Shared pieces for running a provider CLI’s login under a PTY and reading its OAuth URL out of the output: used by the desktop host (agentmux-cef commands/cli_login.rs) and by srv’s auth.* (agentmux-srv server/identity_auth_spawn.rs, identity/auth_patterns.rs). docs/specs/SPEC_PROVIDER_LOGIN_THROUGH_SRV_2026_10_09.md.
mcp_config_path
Where an agent’s MCP config lives (#3680), shared by srv and agentmux-mcp doctor.
muxbus_reconnect
Whether srv reconnects to MuxBus at launch with the stored sign-in, or waits for the user to sign in (moved out of data_paths.rs, which holds the auth and settings isolation flags this one deliberately stays apart from).
owner_only
Files and folders only their own user may open: the place AgentMux Headless keeps its data and the key file that signs a browser in. On Linux and macOS that is a file mode (0700, 0600). Windows has access lists instead, and a profile folder can have been changed so that others are in them; this module reads a folder’s list, says who besides the user, the system and the administrators is given access, and sets a list that gives it to the user and the system only.
pagefile
Windows page-file volume tracking, shared between agentmux-srv (backend/sysinfo.rs’s StatusBar telemetry) and agentmux-cef (memory_heartbeat.rs’s low-memory banner). Extracted from sysinfo.rs by docs/specs/SPEC_RAM_PAGEFILE_PRESSURE_SPLIT_2026_08_07.md §4 so the two processes can’t independently drift on “what counts as system-managed” the way the commit-ratio classifier and the StatusBar gauge once did (issue #2218) — one implementation, two callers.
pii_mask
Hides what looks like a payment card, an ID number or a one-time code in text an agent is about to read from a web page (the Browser tool’s snapshot, find, wait, log and every other answer).
pin
A pane pinned to its window: it stays on screen, at the place it has in its own tab, in every window tab (docs/specs/SPEC_PIN_TRANSFORM_FACILITY_2026_12_02.md §9). A pin is a flag: the pane’s block stays in its tab and in that tab’s layout, so pinning and unpinning in that tab change no layout at all. Where the pane sits is read from that layout, the one place its size is kept; the workspace holds only the list of pinned blocks.
place_args
platform_name
The OS name the frontend uses (Node’s process.platform values), from Rust’s std::env::consts::OS.
popup_rules
Which new windows a browser pane’s page may open inside AgentMux (docs/specs/SPEC_BROWSER_PANE_POPUPS_ADOPTED_2026_10_08.md §3.1, docs/specs/SPEC_BROWSER_PANE_NATIVE_POPUPS_AGENT_DRIVEN_2026_10_08.md §3).
process
Best-effort child-process termination, by PID.
process_hardening
Keeping other processes of the same user out of srv’s and the host’s memory.
quit_question
The question asked before a quit that would stop agents in the middle of a turn.
record_events
Events for the record AgentMux keeps on this computer (docs/specs/SPEC_LONG_RUNNING_ZERO_DEGRADATION_2026_11_16.md §6, task #47820): a stall of the host’s UI thread or of srv’s runtime, written as one JSON line in a file for its month, events-YYYY-MM.jsonl, next to the record’s days. srv reads them back (backend::record); the window host, a process of its own, writes the ones it sees from here, so the writer is in this crate.
redact
Shape-based, best-effort secret redaction — the one Rust implementation SPEC_ERROR_COPY_EVERYWHERE_2026_09_24.md §4.5 asks every formatter that puts error/log text on the clipboard to share, instead of each inventing its own. Moved here from crates/srv-core/src/backend/continuity.rs, which only recognized credential-prefixed tokens and PEM private keys — enough for a continuation packet, not enough for raw stderr and request details (Codex P1 on #3689).
runtime_mode
Runtime mode detection — single source of truth.
secret_env
Taking a secret out of the process environment for good.
secret_eq
Constant-time comparison for secrets presented by a caller.
secret_shape
The shape of a secret in text a page held, for the places that hand page text to an agent (#47628, #47656).
settings_file
Writing settings.json without losing what the person put in it (docs/specs/SPEC_SETTINGS_JSON_EVERY_KEY_ONE_TO_ONE_2026_11_01.md §3, §5.4).
settings_jsonc
Reading settings.json the way srv does: JSONC, so // and /* */ comments and trailing commas are allowed. The seeded template has both, so a reader that parses strict JSON gets nothing from a seeded file (#1903).
settings_path
Where a channel’s settings.json lives: one answer for srv, the host and the launcher (#1903).
shell_quote
POSIX shell quoting, shared by srv and the CEF host. (bashwrap’s hook.rs has its own platform-aware variant that also leaves safe strings bare; it is deliberately different.)
shown_once
A secret a web page shows once: a new OAuth client secret, an app registration’s client secret, a key next to a Copy button (docs/specs/SPEC_VAULT_GENERATE_CAPTURE_AND_BROWSER_SIGNINS_2026_10_28.md §15.1).
shown_url
How a page address is shown to an agent (in an action’s answer, a wait, a snapshot header, the action log).
slug
Name → slug / id / path-component rules, one named function per rule.
srv_binary
Where the srv binary may be, for the launcher and the CEF host. Each anchors its own folders; the file names and the order within a folder are the same.
srv_estart_wait
Waiting for srv’s readiness line (AGENTMUXSRV-ESTART), shared by the launcher and the CEF host.
srv_stderr
The stderr line protocol agentmux-srv uses to talk to whichever process supervises it — the launcher in packaged builds and task dev (crates/launcher/src/srv_spawner.rs), or the CEF host in task dev:standalone (crates/cef/src/sidecar.rs).
system_certs
What is said when a Linux machine has no system certificates, in one place so that agentmux doctor, the server’s log and the error a failed https request carries all use the same words.
test_offscreen
A test build that never shows a window on a real display.
time
Wall-clock “now” helpers.
tls_provider
The TLS crypto provider every reqwest client needs.
tokens
The token estimate every AgentMux surface shows, labelled “~N tok (est.)”: ⌈Unicode scalar values ÷ 4⌉. The frontend’s estimateTokenCount (frontend/util/format-count.ts) counts the same way, and both test the same vector, so the Memory pane, the context delivery card and the reinjection card agree to the token (SPEC_MEMORY_PANE_TOKENS_2026_10_15.md §4.1).
toolchain_path
GUI-launch PATH enrichment.
typed_secrets
What was typed into a page from the Vault, kept as a keyed digest so a read can leave it out wherever it shows (docs/specs/SPEC_VAULT_AGENTS_ENTER_CREDENTIALS_WHEREVER_ASKED_2026_11_16.md, G4).
ui_record_types
The request and response of POST /api/v1/ui/record (the UIRecord tool). Re-exported by api_types, where the rest of the UI requests are.
ui_screenshot_types
The request and response of POST /api/v1/ui/screenshot (the UI tool’s screenshot). Re-exported by api_types, where the rest of the UI requests are.
update_manifest
The signed manifest of a release’s files (docs/specs/SPEC_SIGNED_UPDATE_CHECKSUMS_2026_10_25.md).
url_guard
The origin of an address, asked through one guard.
user_path
The person’s own PATH on Windows (HKEY_CURRENT_USER\Environment, value Path): what install.ps1 -Headless adds one entry to, and agentmux uninstall takes that entry back out of. Only the person’s own list is read or written, never the machine’s, and only entries inside the install folder are removed; the rest of the value is kept as it is. The text work is plain code that is tested on every platform.
win32
Win32 process-creation flags shared by every crate that spawns a child on Windows.
xauthority

Macros§

checkout_guard
Runs [guard] for the invoking crate when its test binary starts, from the platform’s initializer section (as the ctor crate does). Invoke it once per test binary: at a crate’s root, behind #[cfg(test)] where the crate has agentmux-common only as a dev-dependency, and at the top of each file under tests/. Pass the CHECKOUT_DIR of each other workspace library the binary links (agentmux_common’s is always checked).

Constants§

AUTH_KEY_HEADER
The HTTP header that carries srv’s instance auth key, on every route and on the /ws upgrade. srv checks it in crates/srv/src/server/auth.rs; every Rust client (mcp, cef, bashwrap, launcher, srv’s own forwards) sends it under this name. The frontend’s twin is AUTH_KEY_HEADER in frontend/util/sharedconst.ts. HTTP header names are case-insensitive, so this is the spelling we send, not the only one srv accepts.

Functions§

make_cli_cmd
Create a Command for a CLI binary.
resolve_cli_spawn_target
Resolve cli_path to the actual (program, args) spawn target — the .cmd/.bat shim parsing on Windows, factored out of build_cli_cmd so non-tokio::process::Command spawners (e.g. portable_pty::CommandBuilder, which run_cli_login_pty uses) can reuse the same resolution instead of spawning the raw shim path directly. Spawning a .cmd file straight through CommandBuilder forces Windows through cmd.exe /c, and that layer hangs indefinitely under a real ConPTY (confirmed live: 0% CPU, zero output, target dir never created) — this is the fix for that class of bug, not just a refactor for its own sake.