Skip to main content

Crate koh

Crate koh 

Source
Expand description

§koh

mosh (the mobile shell), reimplemented in Rust over iroh p2p QUIC. A resilient peer-to-peer remote shell: instant local echo on laggy links, survival across suspend/resume and IP changes, transparent reconnect/reattach, and no head-of-line blocking.

This crate is both the library and the koh binary. It is a state-synchronization system whose payload happens to be a terminal — each side holds an authoritative object and the protocol brings the peer to the latest version of it, collapsing intermediate states.

§Module map

  • wire — SSP instruction envelope, postcard codec, fragmenter/reassembler.
  • ssp — the SyncState trait + generic Transport<Local, Remote> + send scheduler, with a deterministic lossy/reordering chaos sim harness (ssp::testkit).
  • terminal — TerminalScreen state (vt100-backed) + the ServerTerminal live emulator.
  • input — UserInput state: keystrokes + resize as an append-only synced log.
  • predict — local-echo prediction engine (overlays, epochs, adaptive engage).
  • transport_iroh — iroh endpoint setup, persistent identity, datagram channel, RTT, auth.
  • pty — PTY allocation, shell spawn, SIGWINCH, child reaping.
  • server — PTY + emulator + Transport<Screen, Input> over iroh, plus koh serve.
  • client — input + Transport<Input, Screen> + predictor + termina render, plus koh connect.

Dependency direction is strict: wire ← ssp ← {terminal, input}, with predict over {terminal, input}, transport_iroh over wire, and server/client on top. The entire protocol (ssp, terminal, input, predict, wire) is transport-agnostic — only transport_iroh, server, and client touch iroh.

Modules§

client
The koh client: the session loop, abstracted over a ClientTerminal.
input
koh-input — the UserInput SSP state
predict
koh-predict — the local-echo prediction engine
pty
koh-pty — PTY allocation, shell spawn, resize, reaping
server
The koh server: the per-connection session loop.
ssp
koh-ssp — State Synchronization Protocol
terminal
koh-terminal — the TerminalScreen SSP state
transport_iroh
koh-transport-iroh
wire
koh-wire