Skip to main content

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
6pub mod api_types;
7pub mod client_events;
8mod cli;
9pub mod copy_into_dir;
10pub mod data_paths;
11pub mod errors;
12pub mod event_log;
13pub mod install_presence;
14pub mod ipc;
15pub mod jekt_sign;
16pub mod layout_types;
17pub mod log_retention;
18pub mod login_pty;
19pub mod pagefile;
20pub mod platform_name;
21pub mod allowed_origins;
22pub mod popup_rules;
23pub mod process;
24pub mod redact;
25pub mod runtime_mode;
26pub mod secret_eq;
27pub mod shell_quote;
28pub mod slug;
29pub mod srv_stderr;
30pub mod time;
31pub mod toolchain_path;
32pub mod transcript_request;
33pub mod win32;
34#[cfg(target_os = "linux")]
35pub mod xauthority;
36
37pub use cli::{make_cli_cmd, resolve_cli_spawn_target};
38pub use data_paths::{
39    ensure_history_link, isolated_auth_enabled, isolated_auth_reason,
40    isolated_muxbus_reconnect_enabled, isolated_muxbus_reconnect_reason, isolated_settings_enabled,
41    isolated_settings_reason, DataPaths, IsolatedAuthReason, IsolatedMuxbusReconnectReason,
42    IsolatedSettingsReason,
43};
44pub use errors::{AgentMuxError, AmxCode};
45pub use layout_types::{
46    FlexDirection, LayoutClientSlices, LayoutNode, LayoutNodeData, ResizeOp, SplitPosition,
47    StackMovePosition,
48};
49pub use runtime_mode::{is_dev_build_exe, is_dev_self, RuntimeMode};
50#[cfg(unix)]
51pub use toolchain_path::refresh_login_path_cache;
52pub use toolchain_path::{
53    enrich_current_process_path, enrich_current_process_path_cached, looks_like_launchd_default,
54    resolve_login_path, EnrichOutcome, EnrichedPath, PathSource,
55};
56
57/// The HTTP header that carries srv's instance auth key, on every route and
58/// on the `/ws` upgrade. srv checks it in `crates/srv/src/server/auth.rs`;
59/// every Rust client (mcp, cef, bashwrap, launcher, srv's own forwards)
60/// sends it under this name. The frontend's twin is `AUTH_KEY_HEADER` in
61/// `frontend/util/sharedconst.ts`. HTTP header names are case-insensitive,
62/// so this is the spelling we send, not the only one srv accepts.
63pub const AUTH_KEY_HEADER: &str = "X-AuthKey";
64
65/// Crate-wide test-only lock for env-var-touching tests. Both
66/// `runtime_mode::tests` and `data_paths::tests` mutate process-global
67/// env vars (`AGENTMUX_RUNTIME_MODE`, `AGENTMUX_HOME_OVERRIDE`, etc.);
68/// without a lock that's shared ACROSS modules, cargo's parallel test
69/// runner can race a setter in one module against a reader in the
70/// other. A per-module `static Mutex<()>` was insufficient — they
71/// need to share the same Mutex instance.
72#[cfg(test)]
73pub(crate) static TEST_ENV_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());