Expand description
Runtime mode detection — single source of truth.
The launcher computes RuntimeMode::current once at startup and
propagates the result to host + srv via the AGENTMUX_RUNTIME_MODE
environment variable. No binary should call [current] more than
once per process; downstream binaries read the env var via
[from_env] instead.
Replaces the legacy mix of cfg!(debug_assertions), env::var ("AGENTMUX_DEV").is_ok(), and == Ok("1") checks across launcher,
host, and sidecar — which were each correct in isolation but
desynchronized in combination (see docs/specs/
SPEC_DATA_DIR_UNIFICATION_2026-05-05.md §2.1).
§Detection priority
AGENTMUX_RUNTIME_MODEenv override (testing, CI).- Marker-based portable detection: an
agentmux-portable.markerfile written byscripts/package-portable.sh. Looked for next to the detecting exe, one level down inruntime/(the packaging puts it there to keep the extract root clean; the launcher is at the root and the host/srv run fromruntime/), and two levels up for macOS .app bundles. - Path-based dev detection: exe is under a known dev-build dir
(
dist/cef-dev*/,target/debug/,target/release/). AGENTMUX_DEV_BRANCHenv override (CI override for dev mode).- Default:
Installed.
Enums§
- Runtime
Mode - Where this AgentMux binary is running from. Determines data path
layout (see
crate::DataPaths).
Constants§
- RECORDED_
CHANNEL_ FILE - The file in a portable’s
runtime/that names its data channel, when an upgrade carried one over (srvupdate/download.rs): a local build’slocal-…channel, kept by the release it upgraded to, so the upgrade continues with that build’s windows, agents and settings.
Functions§
- app_
bundle_ of - The
.appbundle the binary atpath(or itsContents/MacOSfolder) belongs to, by the bundle layout rather than by name: the innermost*.appwhoseContents/MacOSholdspath, and, for a helper app nested in another app’sContents/HelpersorContents/Frameworks(srv, the CEF helpers), the app above it. A folder that merely ends in.apparound the install is never taken for it. - appimage_
channel_ file - Where an upgrade records the data channel of an AppImage: beside it, as
<file>.agentmux-channel, since the AppImage itself can’t be written. - derive_
clone_ id - Walk up from
exe_dirlooking for a workspace-root marker, then hash that absolute (canonical) path with FNV-1a and return a 16-char hex string. Used as the per-clone discriminator in~/.agentmux/dev/<branch>/<clone_id>/. ReturnsNoneif no marker is found (extreme edge case —task devalways runs from inside a clone with.git/Cargo.toml/Taskfile.yml). - exe_
dir_ is_ dev - Whether the binary in
exe_diris a source-tree build: whatRuntimeMode::current_path_onlyanswersDevfor, without building the mode. Building it finds the branch, which startsgitand waits for it. A caller that only needs the yes or no must not pay for a process: the host asked throughcurrent_path_onlyon its UI thread at every page load, and a dev build froze for as long asgittook to start (task #47585). - fnv1a_
64 - folder_
others_ can_ change - Why an account other than this user, root or the
admingroup (whose members can become root anyway) could change the entries of the folder that holds an app, orNonewhen none can. An in-place upgrade creates, checks and renames entries there, so anyone else who can rename them could swap a checked bundle for another. macOS also checks every folder above it, since renaming one of those moves the whole path. - git_
branch_ lookups - How many times the calling thread has started
gitto find a branch. For tests that a path stays free of process starts; per thread, so tests that run side by side do not count each other. - inside_
appimage - Whether
exeis under one of the AppImageroots($APPDIR, the extraction). - is_
dev_ build_ exe - True when this binary is running from one of our known dev-build
output directories (
dist/cef-dev*/,target/debug/,target/release/). Walks ancestors to handle nested cases (CEF subprocesses run from aruntime/subdir even in dev). Path-only — does not read env. - is_
dev_ self - True iff THIS binary is a source-tree /
task devbuild, determined from the binary’s path + portable marker viaRuntimeMode::current_path_only— NOT fromAGENTMUX_RUNTIME_MODE. A runningtask devAgentMux exportsAGENTMUX_RUNTIME_MODE=dev:<branch>into its environment, which every descendant process inherits; a packaged build launched from a terminal / agent pane inside a dev instance would otherwise mis-identify as Dev (e.g. the “DEV” status-bar badge on a release build). Build identity is a property of the binary on disk, not of whoever launched it. - mac_
app_ channel_ file - Where a macOS upgrade records the data channel of an
.app: beside it, hidden, as.<name>.app.agentmux-channel, since writing inside the bundle would break its code signature. - portable_
build_ label - The ephemeral build label of a local portable, from the marker
scripts/package-portable.shwrites intoruntime/:AgentMux portable build <label>, e.g.0.59.16+g2a5424fe2.20261008T234046.81801. Read at runtime, not baked, because it changes every build and a binary that wasn’t rebuilt would carry a stale one.exe_diris the running binary’s directory: the marker sits next to the host and srv (both inruntime/), or one level up for older portables.Nonefor released, installed and dev builds. - recorded_
channel - The data channel the running binary’s install records: beside the AppImage
it runs from, beside its
.appon macOS, else in its portable folder (recorded_channel_in). - recorded_
channel_ in - The data channel the portable folder at or above
exe_dirrecords: next to the host and srv (Windows: both inruntime/), inruntime/below the launcher, or at the top of a Linux portable (AgentMux/, two levels above the binaries’usr/bin/). - running_
appimage - The AppImage the binary at
exeruns from:$APPIMAGE, whenexeis inside that AppImage’s mount ($APPDIR) or the folder AppRun extracted it to ($AGENTMUX_EXTRACTED_RUN).APPIMAGEalone isn’t enough: any other build started from an AppImage instance’s pane inherits it.