Skip to content

System Architecture Overview

LibreChatTmuxBridge provides bidirectional communication between LibreChat interfaces and host terminal multiplexers. The system combines direct terminal stream execution with autonomous language model tool orchestration.

Dual-Mode Operational Paradigm

The bridge operates in two distinct operational modes:

DimensionMode 1: Direct Terminal DriverMode 2: Agentic Copilot
Backend ProtocolOpenAI compatible POST /v1/chat/completionsModel Context Protocol (/mcp/sse)
Token ConsumptionZero tokens (local execution)Standard language model generation tokens
Latency50 to 100 millisecondsModel inference duration (2 to 4 seconds)
Response FormatReal-time terminal output stream in MarkdownSynthesized natural language with tool calls
Primary FunctionDirect command execution, prompt approvalsMulti-session supervision, autonomous workflows

System Topology

Component Breakdown

  1. FastAPI Web Framework: Exposes asynchronous HTTP routes and Server-Sent Events (SSE) streams on port 8035.
  2. OpenAI Endpoint Router: Implements standard /v1/models and /v1/chat/completions specifications. LibreChat communicates with this router as a standard model provider.
  3. Terminal Streamer Engine: Captures terminal pane grids, computes line deltas, strips ANSI escape sequences, and monitors terminal quiescence.
  4. FastMCP Server: Exposes Model Context Protocol tools to enable external reasoning agents to control host sessions.
  5. Tmux Driver: Executes native tmux subprocess commands with non-blocking concurrency and error handling.
  6. Diagnostic Tap Buffer: Maintains an in-memory ring buffer of recent events, command inputs, and execution latencies for system observability.

Security and Network Boundaries

  • Host Port Assignment: The daemon listens on port 8035, matching the Pipeline Pattern decade conventions.
  • Network Isolation: The daemon binds to the local host address or internal Docker networks (net_mcp).
  • Authentication: Access is protected through reverse proxy authentication (PocketID and TinyAuth SSO).
  • Network Surface: The daemon does not expose external ports or relay traffic through third-party services.

Released under the MIT License.