agentmux_common/lib.rs
1// Copyright 2025-2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Shared utilities for AgentMux crates.
5
6mod cli;
7pub mod data_paths;
8pub mod errors;
9pub mod ipc;
10pub mod layout_types;
11pub mod runtime_mode;
12
13pub use cli::make_cli_cmd;
14pub use data_paths::DataPaths;
15pub use errors::{AgentMuxError, AmxCode};
16pub use layout_types::{FlexDirection, LayoutNode, LayoutNodeData, ResizeOp, SplitPosition};
17pub use runtime_mode::{is_dev_build_exe, RuntimeMode};
18
19/// Crate-wide test-only lock for env-var-touching tests. Both
20/// `runtime_mode::tests` and `data_paths::tests` mutate process-global
21/// env vars (`AGENTMUX_RUNTIME_MODE`, `AGENTMUX_HOME_OVERRIDE`, etc.);
22/// without a lock that's shared ACROSS modules, cargo's parallel test
23/// runner can race a setter in one module against a reader in the
24/// other. A per-module `static Mutex<()>` was insufficient — they
25/// need to share the same Mutex instance.
26#[cfg(test)]
27pub(crate) static TEST_ENV_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());