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 agent_create_types;
7pub mod api_types;
8pub mod place_args;
9pub mod appimage_record;
10pub mod file_rename_types;
11pub mod ui_record_types;
12pub mod ui_screenshot_types;
13pub mod gateway_stamp;
14pub mod browser_control_types;
15pub mod build_kind;
16pub mod build_slot;
17pub mod checkout;
18pub mod client_events;
19mod cli;
20pub mod copy_into_dir;
21pub mod data_paths;
22pub mod deeplinks;
23pub mod dev_home_guard;
24mod data_home;
25pub mod disk_space;
26pub mod mcp_config_path;
27pub mod github_broker_shim;
28pub mod errors;
29pub mod event_log;
30pub mod ipc;
31pub mod jekt_files;
32pub mod jekt_sign;
33pub mod lan_firewall_rules;
34pub mod lan_install_binding;
35pub mod layout_intent;
36pub mod layout_types;
37pub mod pin;
38pub mod log_retention;
39pub mod muxbus_reconnect;
40pub mod incidents;
41pub mod login_pty;
42pub mod owner_only;
43pub mod pagefile;
44pub mod platform_name;
45pub mod agent_roots;
46pub mod allowed_origins;
47pub mod debug_privilege;
48pub mod popup_rules;
49pub mod url_guard;
50pub mod process;
51pub mod process_hardening;
52pub mod pii_mask;
53pub mod quit_question;
54pub mod record_events;
55pub mod redact;
56pub mod runtime_mode;
57pub mod test_offscreen;
58#[cfg(target_os = "macos")]
59mod test_offscreen_macos;
60pub mod capture_shape;
61pub mod secret_shape;
62pub mod typed_secrets;
63pub mod shown_once;
64pub mod shown_url;
65pub mod secret_eq;
66pub mod secret_env;
67pub mod system_certs;
68#[cfg(feature = "local-http")]
69pub mod local_http;
70pub mod settings_file;
71mod settings_patch;
72pub mod settings_jsonc;
73pub mod settings_path;
74pub mod shell_quote;
75pub mod slug;
76pub mod srv_binary;
77pub mod srv_estart_wait;
78pub mod srv_stderr;
79pub mod time;
80#[cfg(feature = "tls-provider")]
81pub mod tls_provider;
82pub mod tokens;
83pub mod toolchain_path;
84pub mod update_manifest;
85pub mod user_path;
86pub mod win32;
87#[cfg(target_os = "linux")]
88pub mod xauthority;
89
90pub use cli::{make_cli_cmd, resolve_cli_spawn_target};
91pub use data_paths::{
92    ensure_history_link, isolated_auth_enabled, isolated_auth_reason,
93    isolated_muxbus_reconnect_enabled, isolated_muxbus_reconnect_reason, isolated_settings_enabled,
94    isolated_settings_reason, DataPaths, IsolatedAuthReason, IsolatedMuxbusReconnectReason,
95    IsolatedSettingsReason,
96};
97pub use errors::{AgentMuxError, AmxCode};
98pub use settings_path::{settings_dir_for, SETTINGS_FILE};
99pub use pin::PinRecord;
100pub use layout_intent::{LayoutEdge, LayoutIntent, LayoutResizeOp, LayoutViewState};
101pub use layout_types::{
102    FlexDirection, LayoutClientSlices, LayoutNode, LayoutNodeData, SplitPosition,
103    StackMovePosition,
104};
105pub use runtime_mode::{is_dev_build_exe, is_dev_self, RuntimeMode};
106#[cfg(unix)]
107pub use toolchain_path::refresh_login_path_cache;
108pub use toolchain_path::{
109    enrich_current_process_path, enrich_current_process_path_cached, looks_like_launchd_default,
110    resolve_login_path, EnrichOutcome, EnrichedPath, PathSource,
111};
112
113/// The HTTP header that carries srv's instance auth key, on every route and
114/// on the `/ws` upgrade. srv checks it in `crates/srv/src/server/auth.rs`;
115/// every Rust client (mcp, cef, bashwrap, launcher, srv's own forwards)
116/// sends it under this name. The frontend's twin is `AUTH_KEY_HEADER` in
117/// `frontend/util/sharedconst.ts`. HTTP header names are case-insensitive,
118/// so this is the spelling we send, not the only one srv accepts.
119pub const AUTH_KEY_HEADER: &str = "X-AuthKey";
120
121/// Crate-wide test-only lock for env-var-touching tests. Both
122/// `runtime_mode::tests` and `data_paths::tests` mutate process-global
123/// env vars (`AGENTMUX_RUNTIME_MODE`, `AGENTMUX_HOME_OVERRIDE`, etc.);
124/// without a lock that's shared ACROSS modules, cargo's parallel test
125/// runner can race a setter in one module against a reader in the
126/// other. A per-module `static Mutex<()>` was insufficient — they
127/// need to share the same Mutex instance.
128#[cfg(test)]
129pub(crate) static TEST_ENV_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
130
131// This test binary must hold this checkout's code, not another clone's from
132// a shared target directory (`agentmux_common::checkout`).
133#[cfg(test)]
134crate::checkout_guard!();