[package] name = "cotton-session-host" version = "0.1.0" edition.workspace = true license.workspace = true publish.workspace = true description = "The session host: the process that owns a coding agent's pseudo-terminal on this Mac, outlives the app, and answers one local socket." # A LIBRARY AND A BINARY, and the library is why the tests can be honest. # # Everything with a rule in it — the protocol, the scrollback ring, the session # index, the two adapters, the machine sample — is library code with no process # around it, so `tests/` links it directly. The binary is argument parsing and # four entry points. [lib] name = "cotton_session_host" path = "src/lib.rs" [[bin]] name = "cotton-session-host" path = "src/main.rs" [dependencies] serde.workspace = true serde_json.workspace = true thiserror.workspace = true # The daemon is one tokio runtime: an accept loop, a reader task per pseudo- # terminal, a broadcast of events, and a 5-minute sample timer. tokio.workspace = true # Terminal bytes are not text. They travel over a line-delimited JSON socket as # base64 (`{"t":"data","b":"…"}`), which was the first reason this crate encodes # anything at all. base64.workspace = true # THE BROWSER TOOL'S PACKAGE DIGEST. `chrome-devtools-mcp` is fetched by URL # and refused unless it hashes to the sha512 pinned in `browser.rs` — npm's # own `integrity` form, which is base64 as well. sha2.workspace = true # THE BROWSER BROKER. Chrome runs with `--remote-debugging-pipe` and no port; # the broker holds the pipe and serves DevTools clients as WebSocket over a # Unix socket (`browser_broker.rs`). `futures-util`'s `sink` is what splits one # socket into a reader and a writer task. tokio-tungstenite.workspace = true # THE RELAY'S TOKEN: 32 bytes from the OS generator (`OsRng`), as # cotton-server draws its own secrets — a crate reads nothing outside crates/, # /dev/urandom included (`rust-crate-local-reads.test.ts`). rand.workspace = true futures-util = { workspace = true, features = ["sink"] } # THE PSEUDO-TERMINAL. `openpty` + `login_tty` in the child, the controlling # terminal set, and `TIOCSWINSZ` behind `Pty::resize` — the three things this # crate would otherwise write by hand around `libc`, in unsafe blocks, twice # (macOS and the Linux CI lane). `async` is the tokio half: the master side is # `AsyncRead + AsyncWrite` and the child is a `tokio::process::Child`. pty-process = { version = "0.5", features = ["async"] } # FOUR CALLS, and no crate on crates.io is smaller than four calls: `getloadavg` # for load1, `statvfs` for free disk, `sysconf`/`sysctlbyname` for the memory # total, and `kill(pid, 0)` to ask whether the build lock's holder is alive. # `cotton-client` reaches for libc for `statvfs` alone, for the same reason. libc = "0.2" # THE ONE STAMP THIS CRATE WRITES: `started_at` / `ended_at` in the session # index, and `sampled_at` on a sample. Declared the way `cotton-client` # declares it — `default-features = false` plus the three features a UTC # timestamp needs — and reached from ONE place (`clock::SystemClock`), so # every other function in the crate takes the instant as an argument (R7). chrono = { version = "0.4", default-features = false, features = ["std", "clock", "alloc"] } [dev-dependencies] # The sample cadence test compares against the core's REPORT_INTERVAL_MINUTES # by name; a dev-only edge is never compiled into the XCFramework archive. cotton-core = { path = "../cotton-core" } tokio.workspace = true tempfile.workspace = true serde_json.workspace = true