//! The SESSION HOST: the process that owns a coding agent's pseudo-terminal on //! this Mac. //! //! Cotton note "The Code tool — why a Mac holds the sessions" is the design; phase 2 is this crate alone. //! Three sentences say why it exists at all: //! //! 1. **It outlives the app.** CottonDB for Mac relaunches daily (Sparkle) and //! on a crash, and its quit path stops the server and closes the person's //! file. A pseudo-terminal parented by the app dies with the app. This is //! the process the terminals hang off — tmux's server to the app's client. //! 2. **It is not a server mode.** There is ONE `cotton-server` per data dir //! and it holds an OS lock; coupling a terminal's lifetime to a server //! restart is the failure this crate exists to avoid. //! 3. **No state is ever inferred from screen bytes.** What a session is doing //! comes from the agents' own hook systems, forwarded here by //! `cotton-session-host hook ` and `cotton-session-host statusline`. //! //! What it does NOT do, deliberately: it holds no credential, it reads no //! database, and it links neither `cotton-store` nor `cotton-server`. The only //! thing that crosses the socket is the person's own terminal and the agents' //! own events. //! //! **A restart of this daemon ENDS its children.** The pseudo-terminals are //! owned by this process; nothing re-parents them. `sessions/index.json` //! survives, so `list` still answers for an ended session and its scrollback //! is still readable — but the agent is gone and the session is `ended` with //! no exit code, because nobody was waiting on it. Written out in //! `PROTOCOL.md`, under "A restart ends the children". pub mod adopted; pub mod agents; pub mod binary; pub mod browser; pub mod browser_broker; pub mod browser_relay; pub mod browser_router; pub mod clock; pub mod data_dir; pub mod exit_reason; pub mod hook; pub mod index; pub mod log; pub mod launch_env; pub mod login_env; pub mod machine; pub mod processes; pub mod protocol; pub mod pty; pub mod restart; pub mod scrollback; pub mod serve; pub mod sessions; pub mod statusline; pub mod tasks; pub mod utility; /// **THIS HOST'S VERSION — THE APP'S, NOT THE CRATE'S.** /// /// `COTTON_HOST_VERSION` is set by the Mac's packaging lane /// (`apps/cotton/scripts/build-app.sh`) from the ONE source of truth the app /// itself uses, `CFBundleShortVersionString` in /// `apps/cotton/Packaging/Info.plist`. The helper ships inside the bundle and /// is replaced with it, so "which helper is this" and "which app is this" are /// the same question and must not have two answers. /// /// The crate's own `version` never moved off `0.1.0`, which is what every Mac /// reported through `read.agentAccounts` and `list_devices` until 2026-09-22 — /// a number that could not tell a three-day-old helper from a fresh one, on /// the day exactly that distinction was the bug /// (Cotton note "Repo landmines — why the build's rules exist"). /// /// A build nobody configured says so out loud rather than borrowing the app's /// number: `0.1.0-dev` is a helper from `cargo build`, and the `-dev` is there /// so a sample from a development machine is never mistaken for a shipped one. pub const HOST_VERSION: &str = match option_env!("COTTON_HOST_VERSION") { Some(version) => version, None => concat!(env!("CARGO_PKG_VERSION"), "-dev"), }; pub mod hardware;