System Overview
Key Components
PTY Sessions (node-pty)
Each terminal session spawns a real pseudo-terminal usingnode-pty. The agent process runs inside this PTY and behaves exactly as if it were in a normal terminal. Termix doesn’t inject any middleware between you and the agent.
Terminal output is buffered (up to 200KB per session) and sent to the browser over WebSocket. The browser renders it using xterm.js.
WebSocket Communication
A single WebSocket connection carries all messages between the browser and server. Messages are JSON-encoded with atype field for routing. The server broadcasts to all connected clients — you can have multiple browser tabs open.
OTLP Telemetry Receiver
The server runs an HTTP endpoint atPOST /v1/logs that accepts OpenTelemetry log data in JSON format. When an agent is launched, Termix sets environment variables that point the agent’s OTLP exporter to this local endpoint.
The receiver:
- Parses the OTLP resource logs
- Matches the log to the correct session (via
termix.session_idresource attribute) - Extracts the agent’s session ID from log record attributes
- Detects if telemetry is properly configured (triggers setup toast if not)
OpenCode Plugin Bridge
OpenCode uses a different integration path. A JavaScript plugin inside OpenCode sends HTTP events toPOST /opencode-events. The bridge maps these events to the correct Termix session by matching the working directory.
Activity Monitor
A 1-second polling loop measures I/O rates for each session:- Bytes in/out since last poll
- Burst duration — how long the current output burst has been going
- Resets after 2 seconds of silence
Transcript Store
Every session’s I/O is recorded as plain-text JSONL in~/.termix/transcripts/. ANSI codes are stripped, short lines filtered out. The transcript is used for sidebar search — a cache is built on startup and updated incrementally.
Data Flow: Agent Status
Data Flow: Session Resume
Local Only
Termix runs entirely on your machine. There’s no cloud service, no account, no external API calls. The Node.js server binds to127.0.0.1:4000 — it’s not accessible from other machines on your network.
If the Node.js server stops, all PTY processes stop too. This is intentional — Termix manages terminal sessions locally.