Skip to main content

agentmux_srv/server/
mod.rs

1// Copyright 2025-2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4pub(crate) mod cli_handlers;
5mod keychain_probe;
6mod file_icons;
7pub(crate) mod hook_handlers;
8mod files;
9pub(crate) mod app_api;
10pub(crate) mod account_episodes;
11pub(crate) mod prep;
12// `pub` so `bootstrap::install_agent_turn_delivery` can reach `run_agent_turn`
13// to start a turn outside the RPC path.
14pub mod agent_resources;
15pub mod agent_handlers;
16mod agent_only;
17mod api_error;
18pub(crate) mod dispatch_guard;
19mod http_action;
20pub(crate) mod agent_move_here;
21pub(crate) mod lan_watch;
22pub(crate) mod quiet_remote;
23pub(crate) mod messaging_health;
24pub(crate) mod agent_takeover;
25mod pane_binding;
26mod pane_commands;
27mod agent_config_guard;
28mod editor_handlers;
29mod picker_config;
30mod fs_handlers;
31// Moved down to `identity/auth_dirs.rs` so the core does not reach up into `server`; the old path resolves.
32pub(crate) use crate::identity::auth_dirs as identity_auth_dirs;
33mod identity_auth_persist;
34mod identity_auth_spawn;
35pub(crate) mod held_input;
36pub(crate) mod identity_handlers;
37pub mod install_handlers;
38mod install_task;
39#[cfg(all(test, unix))]
40mod install_task_tests;
41mod lsp_handlers;
42pub(crate) mod mcp_folder_notice;
43mod system_install_handlers;
44mod uninstall_handlers;
45mod messagebus;
46// pub(crate): muxbus::cloud_subscriber (the WAN delivery path) calls
47// resolve_transcript_request_tier_fields directly — see that function's
48// own doc comment for why.
49mod hold_reason;
50pub(crate) mod reactive;
51mod name_resolution;
52pub(crate) mod caller;
53pub(crate) mod agent_self_keys;
54pub(crate) mod agent_folder_open;
55pub(crate) mod agent_media_files;
56pub(crate) mod link_file_check;
57pub(crate) mod container_pane_snapshot;
58pub(crate) mod streamed_browser;
59pub(crate) mod files_root;
60mod container_workspace;
61mod model_gateway_bedrock;
62mod model_gateway_handlers;
63mod model_gateway_key;
64pub(crate) mod compact_backstop;
65pub(crate) mod spend_watch;
66pub(crate) mod startup_refresh;
67mod container_tool_chunk;
68mod container_compaction_started;
69pub(crate) mod jekt_held;
70pub(crate) mod jekt_held_summary;
71pub(crate) mod jekt_hold;
72pub(crate) mod jekt_start;
73pub(crate) mod controller_backstop;
74pub(crate) mod agent_lifecycle;
75pub(crate) mod agent_wanted_running;
76pub(crate) mod restart_resume;
77pub(crate) mod availability_view;
78/// What each agent runs on and is doing now, for `Agents list`, `Agents status` and the Swarm.
79pub(crate) mod live_facts;
80pub(crate) mod agent_runtime;
81pub(crate) mod registry_reconcile;
82pub(crate) mod start_rate;
83pub(crate) mod jekt_cold;
84mod limit_probe;
85/// A person's words to an agent out of quota: kept, checked, sent when it can work (task #2648).
86mod person_hold;
87/// `Identity` action `check_limits`: look again now at the agents out of quota (task #2648).
88mod limit_check_api;
89pub(crate) mod jekt_files;
90pub(crate) mod jekt_ack;
91pub(crate) mod muxbus_hooks;
92pub(crate) mod jekt_cloud;
93pub(crate) use crate::backend::jekt_seal;
94mod jekt_echo;
95pub(crate) mod jekt_entry;
96pub(crate) mod actor;
97pub(crate) mod remote_ops;
98pub(crate) mod signin_notice;
99mod bus_frames;
100pub(crate) mod service;
101mod shell_handlers;
102mod tool_handlers;
103mod providers_handlers;
104mod voice;
105mod attachments;
106pub(crate) mod local_proof;
107pub(crate) mod confirm_peer;
108pub(crate) mod local_session;
109pub(crate) mod local_session_file;
110pub(crate) mod local_session_routes;
111pub(crate) mod peer_process;
112mod ui_cache;
113pub(crate) mod mux_obj_bridge;
114mod websocket;
115mod pane_caller;
116mod ws_register;
117mod cli_version;
118mod ws_resync;
119mod drone_agent;
120pub(crate) mod drone_approval_handlers;
121pub(crate) mod drone_access_handlers;
122pub(crate) mod drone_fire;
123pub(crate) mod drone_handlers;
124pub(crate) mod drone_payload;
125pub(crate) mod drone_replay;
126pub(crate) mod drone_resume;
127pub(crate) mod drone_turn_on;
128pub(crate) mod drone_template_handlers;
129pub(crate) mod cron;
130pub(crate) mod job_actions;
131pub(crate) mod job_caps;
132pub(crate) mod jobs_remote_stop;
133pub(crate) mod quit_question;
134pub(crate) mod work_queue;
135pub(crate) mod work_boards;
136mod work_media;
137pub(crate) mod work_tasks;
138// The Kanban's remote operations (tasks.enqueue, tasks.list), served through remote_ops.
139mod work_remote;
140mod work_delegate;
141mod work_act;
142mod sensitive_handlers;
143mod messaging_handlers;
144mod muxbus_handlers;
145mod muxspect_browsers;
146mod muxspect_handlers;
147mod muxspect_instances;
148pub(crate) mod muxspect_memory;
149pub(crate) mod transcript_tail;
150mod coord_channel_handlers;
151mod bulletin_handlers;
152mod quota_mode_handler;
153mod agent_status_handlers;
154mod work_claims_handlers;
155pub(crate) mod work_facts_handlers;
156mod containers_handler;
157mod message_flow_handler;
158mod message_stats_handler;
159mod pr_flow_handler;
160mod reviews_handler;
161mod task_flow_handler;
162mod task_flow_notes;
163pub(crate) mod memory_launch_cost;
164pub(crate) mod native_memory_diff;
165mod dreams_handlers;
166mod lan_firewall_handlers;
167mod native_memory_adopt_handlers;
168pub(crate) mod native_memory_handlers;
169pub(crate) mod native_memory_versions;
170pub(crate) mod memory_delivery_handlers;
171mod notify_handlers;
172pub(crate) mod browser_actions;
173pub(crate) mod browser_agent_calls;
174pub(crate) mod browser_allowlist;
175pub(crate) mod browser_agent_downloads;
176pub(crate) mod browser_attention;
177pub(crate) mod browser_bypass;
178pub(crate) mod browser_bypass_routes;
179pub(crate) mod browser_canvas_card;
180pub(crate) mod browser_close_route;
181pub(crate) mod browser_click_approval;
182pub(crate) mod browser_dialog;
183pub(crate) mod browser_permission;
184pub(crate) mod browser_find;
185pub(crate) mod browser_locate;
186pub(crate) mod browser_attached;
187pub(crate) mod browser_handoff_reason;
188pub(crate) mod browser_handoffs;
189pub(crate) mod browser_waiting;
190pub(crate) mod browser_hibernation;
191pub(crate) mod browser_host_sync;
192pub(crate) mod browser_identity;
193pub(crate) mod browser_owner;
194pub(crate) mod browser_same_site;
195pub(crate) mod browser_pane_gone;
196pub(crate) mod pane_openers;
197pub(crate) mod pane_measure;
198pub(crate) mod pane_place;
199pub(crate) mod pane_dock;
200pub(crate) mod pane_pin;
201pub(crate) mod browser_pane_records;
202pub(crate) mod browser_scroll;
203pub(crate) mod browser_zoom;
204pub(crate) mod browser_sessions;
205pub(crate) mod browser_session_close;
206pub(crate) mod browser_popup;
207pub(crate) mod browser_control;
208pub(crate) mod browser_retake;
209pub(crate) mod browser_powers;
210pub(crate) mod browser_pause_all;
211pub(crate) mod browser_site_permissions;
212pub(crate) mod browser_standing;
213pub(crate) mod browser_terminal;
214pub(crate) mod browser_chooser;
215pub(crate) mod browser_press;
216pub(crate) mod browser_terminal_line;
217pub(crate) mod browser_uploads;
218pub(crate) mod host_http;
219pub(crate) mod external_host;
220pub(crate) mod host_control;
221pub(crate) mod operator_proof;
222pub(crate) mod screenshot_redact;
223pub(crate) mod ui_handlers;
224pub(crate) mod ui_record;
225pub(crate) mod ui_shortcuts;
226pub(crate) mod zoom;
227pub(crate) mod zoom_browser;
228pub(crate) mod widget_access_handlers;
229pub(crate) mod widget_agent_handlers;
230pub(crate) mod vault_ask;
231pub(crate) mod drone_vault;
232pub(crate) mod needs_key;
233pub(crate) mod vault_handlers;
234pub(crate) mod vault_import;
235pub(crate) mod vault_import_batch;
236pub(crate) mod vault_inspect;
237pub(crate) mod vault_prompt_share;
238pub(crate) mod vault_rotate;
239mod vault_routes;
240pub(crate) mod vault_source;
241pub(crate) mod browser_capture;
242pub(crate) mod browser_capture_card;
243mod browser_capture_read;
244mod browser_capture_shape;
245pub(crate) mod browser_vault_fill;
246pub(crate) mod browser_signin_offer;
247pub(crate) mod browser_signin;
248pub(crate) mod browser_account;
249pub(crate) mod browser_change;
250pub(crate) mod browser_signin_fill;
251pub(crate) mod browser_signin_list;
252pub(crate) mod browser_signup;
253pub(crate) mod google_handlers;
254pub(crate) mod shell_secrets;
255pub(crate) mod widget_handlers;
256pub(crate) mod job_template_handlers;
257
258#[cfg(test)]
259pub(crate) mod tests;
260#[cfg(test)]
261#[path = "tests/sender_claims_tests.rs"]
262mod sender_claims_tests;
263#[cfg(test)]
264#[path = "tests/api_error_status_tests.rs"]
265mod api_error_status_tests;
266#[cfg(test)]
267#[path = "tests/agent_status_tests.rs"]
268mod agent_status_tests;
269#[cfg(test)]
270#[path = "tests/folder_overlap_tests.rs"]
271mod folder_overlap_tests;
272#[cfg(test)]
273#[path = "tests/model_gateway_tests.rs"]
274mod model_gateway_tests;
275#[cfg(test)]
276#[path = "tests/key_route_gateway_tests.rs"]
277mod key_route_gateway_tests;
278#[cfg(test)]
279#[path = "tests/bedrock_gateway_tests.rs"]
280mod bedrock_gateway_tests;
281#[cfg(test)]
282#[path = "tests/gateway_bound_peer_tests.rs"]
283mod gateway_bound_peer_tests;
284#[cfg(test)]
285#[path = "tests/http_skill_tests.rs"]
286mod http_skill_tests;
287#[cfg(test)]
288#[path = "tests/http_skill_error_tests.rs"]
289mod http_skill_error_tests;
290#[cfg(test)]
291#[path = "tests/peer_veto_tests.rs"]
292mod peer_veto_tests;
293#[cfg(test)]
294#[path = "tests/mcp_actor_tests.rs"]
295mod mcp_actor_tests;
296#[cfg(test)]
297#[path = "tests/mcp_origin_tests.rs"]
298mod mcp_origin_tests;
299#[cfg(test)]
300#[path = "tests/person_only_ws_tests.rs"]
301mod person_only_ws_tests;
302#[cfg(test)]
303#[path = "tests/quit_window_only_tests.rs"]
304mod quit_window_only_tests;
305#[cfg(test)]
306#[path = "tests/rpc_attribution_tests.rs"]
307mod rpc_attribution_tests;
308#[cfg(test)]
309#[path = "tests/http_action_tests.rs"]
310mod http_action_tests;
311#[cfg(test)]
312#[path = "tests/route_audience_tests.rs"]
313mod route_audience_tests;
314#[cfg(test)]
315mod rpc_schema_export;
316
317use std::sync::Arc;
318
319use axum::{
320    body::Body,
321    extract::{Extension, Query, Request, State},
322    http::{header, Method, StatusCode},
323    middleware::{self, Next},
324    response::{IntoResponse, Json, Response},
325    routing::{delete, get, patch, post},
326    Router,
327};
328use agentmux_common::secret_eq::secret_eq;
329use serde_json::json;
330use tower_http::cors::{Any, CorsLayer};
331
332use crate::backend::eventbus::EventBus;
333use crate::backend::lan::discovery::LanDiscoveryController;
334use crate::backend::lsp::LspSupervisor;
335use crate::backend::messagebus::MessageBus;
336use crate::backend::reactive::{Poller, ReactiveHandler};
337use crate::backend::storage::filestore::FileStore;
338use crate::backend::blockcontroller;
339use crate::backend::storage::store::Store;
340use crate::backend::history::HistoryService;
341use crate::backend::subagent_watcher::SubagentWatcher;
342use crate::backend::wconfig;
343use crate::backend::mps::Broker;
344use agentmux_common::api_types::{
345    PaneTitleRequest, PtyShellCreateRequest, PtyShellCreateResponse, PtyShellInputRequest,
346    PtyShellInputResponse, PtyShellReadRequest, PtyShellReadResponse, PtyShellResizeRequest,
347    PtyShellResizeResponse, PtyShellStatusRequest,
348    PtyShellStatusResponse, PtyShellStopRequest, PtyShellStopResponse, ShellCreateRequest,
349    ShellCreateResponse, ShellInputFailure, ShellInputRequest, ShellInputResponse,
350    ShellStatusRequest, ShellStatusResponse, ShellStopRequest, TabActivateRequest, TabNameRequest,
351    TabNewRequest, WindowFocusRequest, WindowNameRequest, WorkspaceNameRequest, WpsPublishRequest,
352};
353
354// ---- AppState ----
355
356mod state;
357mod route_table;
358mod routes;
359mod http_health;
360mod old_versions_handlers;
361mod http_fleet;
362mod http_viewer;
363mod http_viewer_attachments;
364mod http_viewer_computers;
365mod http_viewer_history;
366mod http_viewer_input;
367mod http_viewer_sysinfo;
368mod http_viewer_terminal;
369mod http_shell;
370mod http_pty_shell;
371mod http_open;
372pub(crate) mod capture_mask_route;
373pub(crate) mod deeplink_guard;
374pub(crate) mod deeplink_os;
375mod http_app_api;
376mod http_self;
377mod http_skill;
378mod http_naming;
379mod http_file_rename;
380mod http_layout;
381mod auth;
382pub use state::*;
383pub use routes::*;
384pub use http_viewer::build_viewer_router;
385use api_error::ApiError;
386use http_health::*;
387use http_fleet::*;
388pub(crate) use http_shell::*;
389use http_pty_shell::*;
390use http_open::*;
391use http_app_api::*;
392use http_self::*;
393use http_skill::*;
394use http_naming::*;
395use http_file_rename::*;
396use http_layout::*;
397pub(crate) use auth::*;