pub enum RuntimeMode {
Installed,
Portable,
Dev {
branch: String,
clone_id: Option<String>,
},
}Expand description
Where this AgentMux binary is running from. Determines data path
layout (see crate::DataPaths).
Variants§
Installed
Installed via the platform installer (msi/dmg/deb). State lives
in ~/.agentmux/versions/<v>/.
Portable
Running from an extracted portable ZIP. State STILL lives in
~/.agentmux/versions/<v>/ (not under the portable folder) —
portable binaries are stateless on disk.
Dev
Running from a source-tree build. State lives in
~/.agentmux/dev/<branch>/<clone_id>/ so different branches
AND different clones of the same branch don’t share state.
clone_id is a 16-char hex hash of the clone’s workspace-root
path, derived by derive_clone_id when the launcher detects
Dev mode. None is permitted for backward compatibility with
callers that construct RuntimeMode::Dev directly (tests, the
dev:branch env-string parser that pre-dates this field): in
that case path resolution falls back to the old two-level
dev/<branch>/ layout. See
docs/analysis/ANALYSIS_MULTI_CLONE_TASK_DEV_ISOLATION_2026-05-26.md.
Implementations§
Source§impl RuntimeMode
impl RuntimeMode
Sourcepub fn current(exe_dir: &Path) -> Self
pub fn current(exe_dir: &Path) -> Self
Detect runtime mode from the launcher’s vantage point. Call
ONCE at process startup. Subsequent processes read the
AGENTMUX_RUNTIME_MODE env var via Self::from_env.
exe_dir should be current_exe().parent() of the binary
doing the detection (typically the launcher).
Sourcepub fn from_env() -> Option<Self>
pub fn from_env() -> Option<Self>
Read mode from the AGENTMUX_RUNTIME_MODE env var the launcher
set. Used by host + srv to consume the launcher’s decision
without re-detecting (which would re-introduce the desync risk
the legacy code had).
Sourcepub fn current_path_only(exe_dir: &Path) -> Self
pub fn current_path_only(exe_dir: &Path) -> Self
Path-only detection — skips the AGENTMUX_RUNTIME_MODE env step.
Use when the env can’t be trusted (e.g., the binary was launched
as a child of a different AgentMux process that set its own
AGENTMUX_* vars). Mirrors the rest of Self::current’s
priority order (portable marker → dev exe path → installed).
Sourcepub fn to_env_string(&self) -> String
pub fn to_env_string(&self) -> String
Encode for the AGENTMUX_RUNTIME_MODE env var. Round-trips
with [parse_mode_string].
Sourcepub fn dir_slug(&self) -> String
pub fn dir_slug(&self) -> String
Slug used inside ~/.agentmux/ to separate state by mode.
Stable across releases of the same major mode + branch.
Sourcepub fn from_env_with_clone() -> Option<Self>
pub fn from_env_with_clone() -> Option<Self>
Read the runtime mode AND clone_id from the env vars exported
by the parent process. Pairs AGENTMUX_RUNTIME_MODE (variant +
branch) with AGENTMUX_CLONE_ID (Dev-only clone discriminator).
This is the version every child process (host, srv) should
call — Self::from_env is the legacy single-var form kept
for callers that don’t care about clone isolation.
Trait Implementations§
Source§impl Clone for RuntimeMode
impl Clone for RuntimeMode
Source§fn clone(&self) -> RuntimeMode
fn clone(&self) -> RuntimeMode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more