Module: Terminalwire::V2::Protocol

Defined in:
lib/terminalwire/v2/protocol.rb

Overview

Wire-level constants for the v2 protocol. See ../../PROTOCOL.md.

Defined Under Namespace

Modules: ErrorCode, Mode, Signal, Stream, Type

Constant Summary collapse

VERSION =

Frame protocol version this implementation speaks.

2
MIN_VERSION =

Range of protocol versions this implementation can negotiate.

2
MAX_VERSION =
2
CONTROL_SID =

The reserved control stream id.

0
CAPABILITIES =

Capabilities advertised by a fully-featured client/server. Negotiation intersects the two sides' sets, so a peer only uses a feature the other advertises. ADD a capability here when you add an optional feature; that is the additive-change path (old peers simply won't list it, and the feature stays dormant for them).

NOTE: negotiation records the intersection, but the server does NOT currently refuse a request() for a capability the client didn't advertise — Context issues file/directory/browser/env/terminal-query requests regardless, and the CLIENT is the enforcement point (it rejects an un-granted or un-negotiated op). Don't rely on this list as a server-side gate; it isn't one yet.

%w[
  stdio file directory browser env
  signal flow raw-input terminal-query
].freeze
DEFAULT_WINDOW =

Default initial per-output-stream flow-control window (bytes) the client grants the server. Must be >= the server's output chunk size so a single chunk can never exceed an empty window and deadlock.

256 * 1024
MAX_WINDOW =

Hard ceiling on a flow window (bytes). A window can never grow past this no matter what a peer offers or grants — the credit ledger clamps to it (see Window). This bounds how much output a server may buffer ahead of a slow or hostile client: without it, a client could offer/grant an enormous window and dissolve backpressure entirely, ballooning the server's transport buffers. 64× the default offer — ample for any terminal stream, far below a memory hazard.

16 * 1024 * 1024