cli-tunnel 1.2.0-beta.8 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -40
- package/dist/index.js +227 -64
- package/dist/redact.d.ts +1 -0
- package/dist/redact.js +26 -0
- package/package.json +7 -5
- package/remote-ui/app.js +472 -26
- package/remote-ui/index.html +10 -10
- package/remote-ui/styles.css +169 -0
package/README.md
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
Tunnel any CLI app to your phone — see the exact terminal output in your browser and type back into it.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
npx cli-tunnel
|
|
7
|
-
npx cli-tunnel
|
|
8
|
-
npx cli-tunnel
|
|
6
|
+
npx cli-tunnel copilot --yolo
|
|
7
|
+
npx cli-tunnel python -i
|
|
8
|
+
npx cli-tunnel k9s
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+

|
|
12
|
+
|
|
11
13
|
## How It Works
|
|
12
14
|
|
|
13
15
|
1. Your command runs in a **PTY** (pseudo-terminal) — full TUI with colors, diffs, interactive prompts
|
|
@@ -22,53 +24,104 @@ npx cli-tunnel --tunnel htop
|
|
|
22
24
|
npm install -g cli-tunnel
|
|
23
25
|
```
|
|
24
26
|
|
|
25
|
-
Or use directly with npx:
|
|
27
|
+
Or use directly with npx (no install needed):
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx cli-tunnel <command> [args...]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If devtunnel isn't installed, cli-tunnel will offer to install it for you automatically.
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
26
36
|
|
|
27
37
|
```bash
|
|
28
|
-
|
|
38
|
+
# Run copilot and access it from your phone
|
|
39
|
+
cli-tunnel copilot --yolo
|
|
40
|
+
|
|
41
|
+
# A QR code appears — scan it with your phone
|
|
42
|
+
# Press any key to start the CLI tool
|
|
43
|
+
# Your phone now shows the exact same terminal!
|
|
29
44
|
```
|
|
30
45
|
|
|
31
46
|
## Usage
|
|
32
47
|
|
|
33
|
-
|
|
48
|
+
Devtunnel is enabled by default. All flags after the command name pass through to the underlying app — cli-tunnel doesn't interpret them.
|
|
34
49
|
|
|
35
50
|
```bash
|
|
36
|
-
#
|
|
37
|
-
cli-tunnel
|
|
51
|
+
# Run copilot with any flags
|
|
52
|
+
cli-tunnel copilot --yolo
|
|
53
|
+
cli-tunnel copilot --model claude-sonnet-4 --agent squad
|
|
38
54
|
|
|
39
|
-
#
|
|
40
|
-
cli-tunnel --
|
|
41
|
-
cli-tunnel --tunnel copilot --allow-all --resume
|
|
55
|
+
# Name your session (shows in the hub dashboard)
|
|
56
|
+
cli-tunnel --name wizard copilot --agent squad
|
|
42
57
|
|
|
43
|
-
#
|
|
44
|
-
cli-tunnel
|
|
58
|
+
# Works with any CLI app
|
|
59
|
+
cli-tunnel python -i
|
|
60
|
+
cli-tunnel vim myfile.txt
|
|
61
|
+
cli-tunnel htop
|
|
62
|
+
cli-tunnel k9s
|
|
63
|
+
cli-tunnel ssh user@server
|
|
45
64
|
|
|
46
65
|
# Specific port
|
|
47
|
-
cli-tunnel --
|
|
66
|
+
cli-tunnel --port 4000 copilot
|
|
48
67
|
|
|
49
|
-
#
|
|
50
|
-
cli-tunnel --
|
|
51
|
-
|
|
52
|
-
cli-tunnel --tunnel htop
|
|
53
|
-
cli-tunnel --tunnel ssh user@server
|
|
68
|
+
# Local only (no tunnel, localhost access only)
|
|
69
|
+
cli-tunnel --local copilot --yolo
|
|
70
|
+
```
|
|
54
71
|
|
|
55
|
-
|
|
56
|
-
|
|
72
|
+
**cli-tunnel's own flags** (`--local`, `--port`, `--name`, `--replay`) must come **before** the command.
|
|
73
|
+
|
|
74
|
+
## Hub Mode — Sessions Dashboard
|
|
75
|
+
|
|
76
|
+
Run `cli-tunnel` with no command to start **hub mode** — a dashboard that shows all your active sessions across machines.
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
cli-tunnel
|
|
57
80
|
```
|
|
58
81
|
|
|
59
|
-
|
|
82
|
+

|
|
83
|
+
|
|
84
|
+
The hub discovers sessions via devtunnel labels. Sessions on the same machine are directly connectable — tap a session card to open it. Remote sessions (other machines) are visible but shown with a 🔒 icon.
|
|
85
|
+
|
|
86
|
+
## Grid View — Monitor All Sessions
|
|
87
|
+
|
|
88
|
+
When the hub has 2+ connectable sessions, a **⊞ Grid** button appears. Click it to see all sessions as live terminals — like tmux in your browser.
|
|
89
|
+
|
|
90
|
+
Four layout modes, switchable without reconnecting:
|
|
91
|
+
|
|
92
|
+
### ⊞ Tiles — Overview
|
|
93
|
+
Scaled-down terminal previews in a card grid, like Windows Task View. Click any tile to go fullscreen.
|
|
94
|
+
|
|
95
|
+

|
|
96
|
+
|
|
97
|
+
### ⊟ Tmux — Split Panels
|
|
98
|
+
Equal split panels with layout presets: **Equal**, **Main+Side**, and **Stacked**.
|
|
99
|
+
|
|
100
|
+

|
|
101
|
+
|
|
102
|
+
### ◉ Focus — Presentation Mode
|
|
103
|
+
One terminal takes the full screen. Other sessions shown as clickable strips at the bottom — tap to swap.
|
|
104
|
+
|
|
105
|
+

|
|
106
|
+
|
|
107
|
+
### ⊡ Fullscreen
|
|
108
|
+
Single terminal with key bar for mobile input. "← Grid" button to go back.
|
|
109
|
+
|
|
110
|
+

|
|
111
|
+
|
|
112
|
+
All modes share the same WebSocket connections — switching is instant, no reconnection needed.
|
|
60
113
|
|
|
61
114
|
## What You See on Your Phone
|
|
62
115
|
|
|
63
116
|
- **Full terminal** rendered by xterm.js — exact same output as your local terminal
|
|
64
117
|
- **Key bar** with ↑ ↓ → ← Tab Enter Esc Ctrl+C for mobile navigation
|
|
65
|
-
- **Sessions
|
|
66
|
-
- **
|
|
118
|
+
- **Sessions button** — switch between terminal and sessions dashboard
|
|
119
|
+
- **QR code** — scan from your phone to connect instantly
|
|
67
120
|
|
|
68
121
|
## Prerequisites
|
|
69
122
|
|
|
70
|
-
- [Node.js](https://nodejs.org/) 22+
|
|
71
|
-
- [Microsoft Dev Tunnels CLI](https://aka.ms/devtunnels/doc)
|
|
123
|
+
- [Node.js](https://nodejs.org/) 22+ (Node 20 works too; Node 23 may need the latest beta)
|
|
124
|
+
- [Microsoft Dev Tunnels CLI](https://aka.ms/devtunnels/doc) — cli-tunnel offers to install it if missing
|
|
72
125
|
```bash
|
|
73
126
|
winget install Microsoft.devtunnel # Windows
|
|
74
127
|
brew install --cask devtunnel # macOS
|
|
@@ -81,23 +134,25 @@ cli-tunnel uses a layered security model:
|
|
|
81
134
|
|
|
82
135
|
**Network layer** — Microsoft Dev Tunnels are private by default. Only the Microsoft or GitHub account that created the tunnel can connect. TLS encryption is handled by Microsoft's relay infrastructure. No inbound ports are opened on your machine.
|
|
83
136
|
|
|
84
|
-
**Session authentication** — Each session generates a unique token (cryptographic random UUID). All HTTP API and WebSocket connections require this token. The token is embedded in the URL you receive at startup
|
|
137
|
+
**Session authentication** — Each session generates a unique token (cryptographic random UUID). All HTTP API and WebSocket connections require this token. The token is embedded in the URL you receive at startup.
|
|
85
138
|
|
|
86
|
-
**WebSocket auth** —
|
|
139
|
+
**Ticket-based WebSocket auth** — The browser exchanges the session token for a single-use, short-lived ticket (60 seconds) to establish the WebSocket connection. This avoids keeping the long-lived token in WebSocket upgrade logs.
|
|
87
140
|
|
|
88
|
-
**
|
|
141
|
+
**Rate limiting** — Per-IP rate limits on all endpoints (30 requests/minute for HTTP, 10/minute for ticket minting). Returns 429 Too Many Requests when exceeded.
|
|
89
142
|
|
|
90
|
-
**
|
|
143
|
+
**Input validation** — Only structured JSON messages are accepted over WebSocket. Raw text is rejected and logged. Terminal resize commands are bounds-checked (1–500 cols, 1–200 rows).
|
|
91
144
|
|
|
92
|
-
**
|
|
145
|
+
**Environment isolation** — The child process receives filtered environment variables. Dangerous variables (NODE_OPTIONS, BASH_ENV, LD_PRELOAD, etc.) and secrets (tokens, keys, passwords) are stripped.
|
|
93
146
|
|
|
94
|
-
**
|
|
147
|
+
**Audit logging** — All remote keyboard input is logged to `~/.cli-tunnel/audit/` in JSONL format with timestamps and source addresses. Secrets are automatically redacted (OpenAI, GitHub, AWS, JWT, Slack, npm, PEM, Bearer tokens).
|
|
95
148
|
|
|
96
|
-
|
|
149
|
+
**Connection limits** — Maximum 5 concurrent WebSocket connections (2 per IP). Ping/pong heartbeat every 30 seconds cleans stale connections. Sessions expire after 4 hours.
|
|
97
150
|
|
|
98
|
-
|
|
151
|
+
**Security headers** — CSP (no unsafe-inline for scripts), HSTS, X-Frame-Options: DENY, X-Content-Type-Options: nosniff, Referrer-Policy: no-referrer, Cache-Control: no-store.
|
|
99
152
|
|
|
100
|
-
|
|
153
|
+
## Terminal Size Behavior
|
|
154
|
+
|
|
155
|
+
cli-tunnel uses a single PTY shared between your local terminal and all remote viewers. When a phone connects, the PTY resizes to match the remote device's screen dimensions — the CLI app renders correctly on the device you're actively using.
|
|
101
156
|
|
|
102
157
|
**Tips for the best experience:**
|
|
103
158
|
- Rotate your phone to landscape for a wider terminal
|
|
@@ -107,7 +162,7 @@ Because the PTY can only have one size at a time, the local terminal on your mac
|
|
|
107
162
|
## FAQ
|
|
108
163
|
|
|
109
164
|
**Can multiple devices connect to the same session?**
|
|
110
|
-
Yes, up to 5 devices simultaneously. All viewers see the same terminal output in real time. Input from any device goes to the same CLI session.
|
|
165
|
+
Yes, up to 5 devices simultaneously (2 per IP). All viewers see the same terminal output in real time. Input from any device goes to the same CLI session.
|
|
111
166
|
|
|
112
167
|
**What happens if my phone disconnects?**
|
|
113
168
|
The CLI session keeps running on your machine. When you reconnect, you'll see live output from that point forward. Use `--replay` to enable history replay so reconnecting devices catch up on what they missed.
|
|
@@ -119,18 +174,21 @@ Yes. Any command that runs in a terminal works — copilot, vim, htop, python, s
|
|
|
119
174
|
No. cli-tunnel runs entirely on your machine. Microsoft Dev Tunnels provides the relay infrastructure, but no third-party server sees your terminal content.
|
|
120
175
|
|
|
121
176
|
**What about the anti-phishing page?**
|
|
122
|
-
The first time you open a devtunnel URL, Microsoft shows an interstitial warning page. This is a devtunnel security feature
|
|
177
|
+
The first time you open a devtunnel URL, Microsoft shows an interstitial warning page. This is a devtunnel security feature. You only see it once per tunnel.
|
|
123
178
|
|
|
124
179
|
**Does the tool work without devtunnel?**
|
|
125
|
-
Yes. Use `--local` to skip tunnel creation. The terminal is available at `http://127.0.0.1:<port>` on
|
|
180
|
+
Yes. Use `--local` to skip tunnel creation. The terminal is available at `http://127.0.0.1:<port>` on localhost only.
|
|
126
181
|
|
|
127
182
|
**What's hub mode?**
|
|
128
|
-
Run `cli-tunnel` with no command to start hub mode — a sessions dashboard that shows all active cli-tunnel sessions
|
|
183
|
+
Run `cli-tunnel` with no command to start hub mode — a sessions dashboard that shows all active cli-tunnel sessions. Tap any session to connect, or use Grid view to monitor all sessions simultaneously.
|
|
184
|
+
|
|
185
|
+
**How does the Grid view connect to sessions?**
|
|
186
|
+
The hub reads session tokens from `~/.cli-tunnel/sessions/` (files with owner-only permissions). It proxies ticket requests to each session's local port — no tokens are exposed to the browser client.
|
|
129
187
|
|
|
130
188
|
## How It's Built
|
|
131
189
|
|
|
132
190
|
- **[node-pty](https://github.com/microsoft/node-pty)** — spawns the command in a pseudo-terminal
|
|
133
|
-
- **[xterm.js](https://xtermjs.org/)** — terminal emulator in the browser (loaded from CDN)
|
|
191
|
+
- **[xterm.js](https://xtermjs.org/)** — terminal emulator in the browser (loaded from CDN with SRI hashes)
|
|
134
192
|
- **[ws](https://github.com/websockets/ws)** — WebSocket server for real-time streaming
|
|
135
193
|
- **[Dev Tunnels](https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/)** — authenticated HTTPS relay
|
|
136
194
|
|