agentmux_launcher\ipc/
mod.rs

1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3//
4// Phase B.2: launcher-owned named-pipe IPC server.
5//
6// Per `specs/SPEC_WINDOW_PROCESS_STATE_MACHINE_2026_04_27.md` §3.2 and §5,
7// the launcher hosts the canonical state machine and exposes it over a
8// pipe per data-dir-scoped namespace. Each subscriber (host, eventually
9// frontend renderers, srv) connects, sends `Command` messages, and
10// receives `Event` messages back.
11//
12// B.2 scope (this module): just the wire — types + accept loop +
13// per-connection read/write tasks. No reducer, no events emitted yet
14// (B.3 wires the reducer; B.4 pipes events back). This commit makes
15// the host able to register itself with the launcher and the launcher
16// to log incoming Commands. Foundation for everything else in Phase B.
17
18pub mod server;
19
20// Wire types live in agentmux-common::ipc so the host (client) and
21// launcher (server) compile against one definition. Phase F.7
22// cleanup audit: the prior `pub use {Command, Event}` re-exports
23// from this module had no consumers — every reference uses the
24// canonical `agentmux_common::ipc` path directly. Removed to keep
25// the launcher's public surface honest.
26pub use server::run_ipc_server;
27
28/// Construct the named-pipe path for a given data-dir hash.
29/// Format: `\\.\pipe\agentmux-{hash16}\command`.
30///
31/// Per-data-dir scoping preserves multi-instance support per
32/// `CLAUDE.md`: different portable folders / installed versions
33/// → different data dirs → different hashes → distinct pipes.
34/// Two launchers pointing at the SAME data dir will collide on
35/// the pipe name, which is also the single-instance signal
36/// Phase B.6 relies on.
37pub fn pipe_name(data_dir_hash16: &str) -> String {
38    format!("\\\\.\\pipe\\agentmux-{}\\command", data_dir_hash16)
39}
40
41/// Phase E.1b — srv-side pipe path. Same data-dir hash as the
42/// launcher pipe (multi-instance scoping is identical), different
43/// leaf name. Both pipes coexist; subscribers connect to whichever
44/// reducer they need.
45pub fn srv_pipe_name(data_dir_hash16: &str) -> String {
46    format!("\\\\.\\pipe\\agentmux-{}\\srv-command", data_dir_hash16)
47}