Live Multi-user Execution Shell
Real-time, low-latency collaborative terminal streaming and pair programming over secure WebSockets.
Overview • Installation • CLI Usage • Key Capabilities • System Architecture • Self-Hosting • Security Model
LMESH functions like tmux or tmate modernised for the web. A host starts a session from their local terminal, and remote teammates can join instantly via an encrypted URL in any modern browser without installing software, configuring SSH keys, or opening inbound firewall ports.
LMESH ensures strict host sovereignty through a single-token write mutex: remote users can watch in real time with 60 FPS WebGL terminal rendering, while control handover requires host permission and can be preempted immediately by the host's physical keyboard.
- Zero Inbound Port Configuration: Uses outbound-only TLS 1.3 WebSocket pipes (
wss://). Traverses NATs, corporate firewalls, and VPNs seamlessly. - Single-Token Concurrency Mutex: Strict token gating ensures only one participant holds write access at any time, eliminating keystroke race conditions.
- Physical Host Preemption Guard: The host retains root authority. Any local physical keystroke immediately revokes remote write tokens.
- Dual Terminal Synchronization: Synchronizes raw PTY buffer dimensions and
SIGWINCHresize signals between OS pseudo-terminals (ConPTYon Windows,POSIX OpenPTYon Linux/macOS) and remotexterm.jsviewports. - Private Mode (Ctrl+S): In-session hotkey that dynamically redacts sensitive environment variables, passwords, and API credentials from the persistent audit trail.
- Horizontal Relay Scalability: Redis Pub/Sub cluster layer handles cross-instance broadcast and multi-node relay synchronization with instance deduplication.
- GitHub Device Authorization: Secure login via GitHub OAuth Device Flow on the CLI and standard OAuth 2.0 on the web interface.
Install the LMESH CLI globally from the npm registry:
# Global installation via npm
npm install -g lmesh-cli
# Or using pnpm / yarn
pnpm add -g lmesh-cli
yarn global add lmesh-cliNote: Global installation exposes both
lmeshandlmesh-clicommands in your system PATH.
You can also run commands on-the-fly without global installation:
# Authenticate via GitHub
npx lmesh-cli login
# Start sharing your terminal
npx lmesh-cli shareThe CLI automatically connects to the hosted LMESH relay network (wss://lmesh.onrender.com) and pairs with the web viewer at lmesh.vercel.app. Zero server configuration or inbound port forwarding is required.
lmesh loginThe CLI displays an 8-character verification code and opens GitHub Device Authorization. Once approved, verify your profile:
lmesh whoamilmesh shareSpawns your local shell (powershell.exe / bash / zsh) inside a virtual pseudo-terminal (PTY) and streams it live over secure WebSockets:
Authenticated as @yourusername
Connecting to relay server at wss://lmesh.onrender.com...
Session created successfully!
Host: @yourusername
Share this link with collaborators:
https://lmesh.vercel.app/x7k2m9p
(Type 'exit' or press Ctrl+] to end session • Ctrl+S for Private Mode)
Collaborators open the link in any modern web browser to view your terminal in 60 FPS WebGL or request keyboard write control.
# Share with password protection
lmesh share -w mySecretPassword
# Force read-only mode (collaborators cannot request control)
lmesh share --readonly
# Connect to a custom self-hosted relay
lmesh share -u ws://localhost:3001| Flag | Shorthand | Description |
|---|---|---|
--password <string> |
-w |
Protects session access behind a password |
--readonly |
-r |
Forces view-only mode (disables control requests) |
--url <wss_url> |
-u |
Specifies custom relay WebSocket endpoint |
--help |
-h |
Displays command options and flags |
| Hotkey | Action | Description |
|---|---|---|
Ctrl+] or exit |
Terminate Session | Instantly closes the session and disconnects all collaborators. |
Ctrl+S |
Private Mode | Toggles audit-log redaction for passwords, API tokens, and secrets. |
y / n |
Control Approval | Responds to incoming remote write-token handover requests. |
| Any physical key | Host Preemption | Immediately revokes collaborator input and restores exclusive host control. |
LMESH is divided into three tiers: Host Environment (packages/cli), Edge Relay Cluster (packages/server), and Collaborator Viewport (packages/web).
flowchart TD
classDef host fill:#101726,stroke:#3b82f6,stroke-width:1.5px,color:#f8fafc;
classDef daemon fill:#0f2038,stroke:#60a5fa,stroke-width:1.5px,color:#f8fafc;
classDef relay fill:#1a1429,stroke:#a855f7,stroke-width:1.5px,color:#f8fafc;
classDef storage fill:#261221,stroke:#ec4899,stroke-width:1.5px,color:#f8fafc;
classDef client fill:#0c221a,stroke:#10b981,stroke-width:1.5px,color:#f8fafc;
classDef active fill:#1e293b,stroke:#f59e0b,stroke-width:2px,color:#f8fafc;
subgraph HOST ["Host Environment (packages/cli)"]
direction TB
HostShell["Host Shell<br/><code>bash / zsh / pwsh</code>"]:::host
PtyEngine["Virtual PTY Engine<br/><code>node-pty (ConPTY / OpenPTY)</code>"]:::host
CliDaemon["LMESH CLI Daemon<br/><code>Outbound WSS Client</code>"]:::daemon
PreemptLock["Preemption Guard<br/><code>Physical Keypress Priority</code>"]:::daemon
HostShell <-->|"Raw IO / SIGWINCH"| PtyEngine
PtyEngine <-->|"stdio byte stream"| CliDaemon
PreemptLock -.->|"Preempts remote token"| PtyEngine
end
subgraph RELAY ["LMESH Relay Cluster (packages/server)"]
direction TB
IngressGw["Ingress Gateway<br/><code>Port 443 • TLS 1.3 WSS</code>"]:::relay
TokenMutex["Single-Token Mutex<br/><code>Write Lock Engine</code>"]:::relay
SessionCoord["Session Coordinator<br/><code>JWT Auth & Participant State</code>"]:::relay
subgraph BACKEND ["State & Clustering Layer"]
direction LR
RedisPubSub[("Redis Pub/Sub<br/><code>lmesh:session:* Fanout</code>")]:::storage
PostgresDB[("PostgreSQL<br/><code>Redacted Audit Logs</code>")]:::storage
end
IngressGw <-->|"Control Frames"| TokenMutex
IngressGw <-->|"Session State"| SessionCoord
SessionCoord <-->|"Multi-Node Broadcast"| RedisPubSub
SessionCoord -.->|"Async Persist"| PostgresDB
end
subgraph CLIENTS ["Collaborator Viewports (packages/web)"]
direction TB
ViewerA["Collaborator A (Viewer)<br/><code>xterm.js WebGL Canvas</code>"]:::client
ViewerB["Collaborator B (Controller)<br/><code>Active Write Token Holder</code>"]:::active
WebClient["Browser WebSocket Client<br/><code>Reconnect & Frame Multiplexer</code>"]:::client
WebClient -->|"Fanout Output"| ViewerA
WebClient <-->|"Token-Gated Stdin"| ViewerB
end
CliDaemon <==>|"Outbound TLS 1.3 WSS<br/>(Zero Inbound NAT Ports)"| IngressGw
IngressGw <==>|"Multiplexed WSS<br/>(Binary Chunks & Control)"| WebClient
sequenceDiagram
autonumber
actor Host as Host (Terminal & CLI)
participant Relay as LMESH Relay Server
participant Redis as Redis Pub/Sub
actor Viewer as Collaborator (Web)
Note over Host,Relay: 1. Session Initialization
Host->>Relay: session_create (JWT auth, password, read-only flag)
Relay-->>Host: session_created (session ID & secure viewer URL)
Note over Relay,Viewer: 2. Collaborator Handshake
Viewer->>Relay: session_join (session ID, optional password)
Relay-->>Viewer: session_joined + session_update (initial viewport state)
Note over Host,Viewer: 3. Real-Time Terminal Streaming & Fanout
Host->>Relay: terminal_data (PTY stdout escape sequences)
Relay->>Redis: Publish frame (lmesh:session:id)
Redis-->>Relay: Multi-node cluster fanout
Relay-->>Viewer: terminal_data (rendered via xterm.js WebGL)
Note over Host,Viewer: 4. Token-Gated Control Delegation
Viewer->>Relay: control_request
Relay->>Host: control_request (CLI prompts host: y/n)
Host->>Relay: control_grant
Relay-->>Viewer: session_update (write token granted)
Viewer->>Relay: terminal_data (collaborator stdin)
Relay->>Host: terminal_data (injected into host virtual PTY)
Host->>Relay: terminal_data (command output stream)
Relay-->>Viewer: terminal_data (terminal canvas update)
Note over Host,Viewer: 5. Host Sovereignty & Hardware Preemption
Host->>Relay: control_revoke (physical keypress detected on host)
Relay-->>Viewer: session_update (control reclaimed by host)
Note over Host,Viewer: 6. Graceful Teardown
Host->>Relay: session_terminate (hotkey Ctrl+])
Relay-->>Viewer: session_terminated (session closed)
lmesh/
├── packages/
│ ├── cli/ # Host CLI Daemon (node-pty, Commander.js, WebSocket client)
│ ├── server/ # WebSocket Relay Cluster (Express, ws, Redis Pub/Sub, PostgreSQL)
│ └── web/ # Next.js 16 Client (xterm.js WebGL, Tailwind CSS, Auth UI)
└── package.json # Root workspace orchestration
packages/cli: Hooks into the local terminal vianode-pty, buffers raw stdout escape sequences, monitors physical input for preemption and hotkeys, and streams frames over an outbound TLS WebSocket.packages/server: Stateful relay cluster. Manages active WebSocket connections, enforces password protection, coordinates the single-token write mutex, persists audit logs, and handles multi-server fanout via Redis Pub/Sub.packages/web: Next.js client interface. Renders terminal output through WebGL-acceleratedxterm.js, provides a host dashboard, and handles GitHub OAuth authorization.
For developers contributing to LMESH or self-hosting the complete relay infrastructure:
- Node.js:
v20.xor higher - npm:
v10.xor higher - PostgreSQL: PostgreSQL database (e.g. Neon serverless or local)
- Redis: Redis instance (required for multi-node clustering)
- GitHub OAuth App: Client ID & Client Secret (Device Flow + Web OAuth)
git clone https://github.com/theblag/lmesh.git
cd lmeshcd packages/server
npm install
cp .env.example .envConfigure .env:
PORT=3001
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
JWT_SECRET=your_super_secret_jwt_key
DATABASE_URL=postgresql://user:password@host/neondb?sslmode=require
REDIS_URL=redis://default:password@host:port
WEB_CLIENT_URL=http://localhost:3000Start the relay server:
npm run devIn a separate terminal:
cd packages/web
npm install
npm run devThe web dashboard is now accessible at http://localhost:3000.
In a separate terminal:
cd packages/cli
npm install
npm run build
npm link- Outbound-Only Connectivity: The CLI never opens an inbound listening socket. Attacks targeting local open ports are completely bypassed.
- Strict Single-Token Concurrency: The relay server enforces token-gated input. Unapproved keystrokes sent from unauthorized web sockets are rejected.
- Physical Host Sovereignty: The host retains ultimate authority over their shell. Remote participants can never lock out the host.
- Audit Trail Redaction: When Private Mode (
Ctrl+S) is active, commands executed in the session are redacted before being persisted to the database. - Anti-Nesting Lock: Recursive
lmesh shareexecution inside an active session is detected and blocked via environment guards (LMESH_SESSION).
- Import repository on Vercel and set the Root Directory to
packages/web. - Add environment variable:
NEXT_PUBLIC_SERVER_URL:https://relay.yourdomain.com
Deploy packages/server as a persistent container or Node.js web service (stateless HTTP serverless is not compatible with stateful WebSockets). Ensure port 443 is SSL-terminated.
Distributed under the MIT License. See LICENSE for details.
