# Terminalwire v0.1.0 - Table of Contents

> Terminalwire v2 server for Elixir — the layer between your WebSocket endpoint (Phoenix/Plug/Cowboy) and your CLI/terminal code. Stream a command-line app from your server with no web API.

## Pages

- [Terminalwire (Elixir)](readme.md)

## Modules

- [Terminalwire](Terminalwire.md): Terminalwire v2 server for Elixir.
- [Terminalwire.CLI](Terminalwire.CLI.md): A small command router so your CLI reads like the commands themselves — public
functions become commands, their parameters become arguments, and `@desc`
becomes help. It's the Elixir analog of Ruby's Thor `desc`/`def`.
- [Terminalwire.Codec](Terminalwire.Codec.md): Pure bytes <-> frame conversion. A frame is a map with string keys (the wire
shape). No I/O, no transport — the sans-IO seam the conformance corpus
exercises directly. Mirrors `Terminalwire::V2::Codec`.
- [Terminalwire.Frames](Terminalwire.Frames.md): Builders for each frame type — the wire shape defined in one place. Every
builder returns a map with string keys. Mirrors `Terminalwire::V2::Frames`.

- [Terminalwire.Negotiator](Terminalwire.Negotiator.md): Pure handshake negotiation: given what the client speaks and what the server
supports, decide the agreed protocol version and capability set. A function,
not a state machine — identical across languages (conformance/vectors/negotiate).
Mirrors `Terminalwire::V2::Negotiator`.

- [Terminalwire.Protocol](Terminalwire.Protocol.md): Wire-level constants for the Terminalwire v2 protocol. Mirrors the Ruby
`Terminalwire::V2::Protocol` and the language-neutral conformance corpus — see the
protocol spec. These values are part of the cross-language contract; do not
change them without a corpus vector to match.

- [Terminalwire.Protocol.ErrorCode](Terminalwire.Protocol.ErrorCode.md): Error codes carried on a failed `response`.
- [Terminalwire.Protocol.Signal](Terminalwire.Protocol.Signal.md): Names carried by a `signal` frame.
- [Terminalwire.Protocol.Type](Terminalwire.Protocol.Type.md): Frame type tokens (the `t` field).
- [Terminalwire.Server.Adapter](Terminalwire.Server.Adapter.md): The seam between a WebSocket endpoint and Terminalwire. Your transport
(Phoenix.Socket, Plug.Cowboy WebSock, raw Cowboy) implements this by forwarding
binary frames in and providing a way to push binary frames out.
- [Terminalwire.Server.Connection](Terminalwire.Server.Connection.md): The server-role protocol state machine. Sans-IO: feed it an incoming frame with
`receive_frame/2`, get back `{new_state, directives}`. A directive is one of
- [Terminalwire.Server.Context](Terminalwire.Server.Context.md): The server's handle on the client's terminal — the API your CLI code calls.
Output (`puts`/`print`/`warn`) is fire-and-forget; input and resource ops
(`gets`, `read_secret`, `file`/`env` reads) are synchronous request/response.
Mirrors `Terminalwire::V2::Server::Context`.
- [Terminalwire.Server.IO](Terminalwire.Server.IO.md): An Erlang I/O-protocol device backed by a Terminalwire session. Set as the CLI
handler's group leader (see `Terminalwire.Server.Session`), it routes the
*standard* IO — `IO.puts`/`IO.gets`/`IO.write`, `IO.ANSI`, `:io.columns`, and
any library built on them (e.g. Owl) — over the wire to the client's terminal,
with no `Context` threading. This mirrors the Ruby server's `Server.redirect`,
which points `$stdout`/`$stdin` at the client.
- [Terminalwire.Server.Session](Terminalwire.Server.Session.md): Drives a `Terminalwire.Server.Connection` over a real transport. This is the
process that sits between the WebSocket endpoint and your CLI code
- [Terminalwire.Server.Terminal](Terminalwire.Server.Terminal.md): The client's terminal, as seen by the server. A typed view over the raw
handshake `terminal` map so server code reads `t.cols` / `t.tty?` instead of
digging through string-keyed maps. Mirrors the Ruby server's Terminal accessor.

- [Terminalwire.WebSock](Terminalwire.WebSock.md): A ready-made [`WebSock`](https://hex.pm/packages/websock) handler that bridges a
WebSocket connection to a `Terminalwire.Server.Session`. WebSock is the common
interface spoken by Phoenix, Bandit, and Plug.Cowboy, so this one module wires
Terminalwire into all of them.
- [Terminalwire.Window](Terminalwire.Window.md): The flow-control credit rule as a pure ledger — no processes, no I/O. Mirrors
Ruby's `Terminalwire::V2::Window` and the Go `protocol.Window`, and is validated by
the shared `flow` conformance corpus. The blocking behaviour when credit runs
out is an implementation concern layered on top (the Session); this is just the
protocol arithmetic: how much output may be in flight and how `window_adjust`
extends it.

- Exceptions
  - [Terminalwire.ProtocolError](Terminalwire.ProtocolError.md): Raised when bytes off the wire are not a well-formed frame.
  - [Terminalwire.ResponseError](Terminalwire.ResponseError.md): Raised server-side when a `response` comes back with ok: false.

