ghostterm 1.3.0 → 2.0.1
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/CHANGELOG.md +20 -101
- package/README.md +25 -267
- package/bin/ghostterm-p2p.js +312 -0
- package/lib/auth.js +152 -0
- package/lib/pty-manager.js +336 -0
- package/lib/webrtc-peer.js +193 -0
- package/package.json +23 -19
- package/bin/ghostterm.js +0 -726
package/CHANGELOG.md
CHANGED
|
@@ -1,108 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 2.0.0 (2026-03-17)
|
|
4
4
|
|
|
5
|
-
###
|
|
6
|
-
- **
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
- **Message queue** — queues up to 50 messages while disconnected, flushes on reconnect
|
|
10
|
-
- **Spawn error handling** — node-pty spawn failure no longer crashes companion
|
|
11
|
-
- **Create-session lock** — prevents duplicate session creation from rapid requests
|
|
12
|
-
- **Create-session cooldown** — 1 second minimum between creates
|
|
13
|
-
- **Input size limit** — rejects input payloads over 64KB
|
|
14
|
-
- **Standby timer dedup** — prevents multiple standby preparation timers
|
|
15
|
-
- **Login server cleanup** — closes HTTP server immediately on auth error
|
|
16
|
-
- **VBS launcher cleanup** — deletes temporary launcher.vbs after use
|
|
17
|
-
- **Send error handling** — ws.send wrapped in try-catch
|
|
18
|
-
- **Worker stdio fix** — Windows worker inherits stdin for node-pty console compatibility
|
|
19
|
-
|
|
20
|
-
### Relay Improvements (deployed separately)
|
|
21
|
-
- Graceful shutdown, email validation, dead pair code reuse, dual companion protection
|
|
22
|
-
- Sessions list caching for instant mobile reconnect
|
|
23
|
-
- Message forwarding validation, health endpoint hardened
|
|
24
|
-
|
|
25
|
-
## 1.2.3 (2026-03-17)
|
|
26
|
-
|
|
27
|
-
### Features (Frontend)
|
|
28
|
-
- **Long-press acceleration** — Backspace, arrow keys, Space, scroll buttons repeat with increasing speed (150ms → 30ms)
|
|
29
|
-
- **Tap feedback** — all buttons show scale + color animation on press
|
|
30
|
-
- **Paste button always visible** — shows "no file" when empty, glows on upload
|
|
31
|
-
- **iOS file picker fix** — transparent file input overlay (bypasses iOS trusted gesture restriction)
|
|
32
|
-
- **Service Worker removed** — fixes stale cache preventing updates
|
|
33
|
-
- **Landing page SEO** — Open Graph tags, Twitter cards, PWA meta
|
|
34
|
-
|
|
35
|
-
### Bug Fixes
|
|
36
|
-
- **Cloudflare deploy** — must use `--branch=main` for production (was deploying to Preview)
|
|
37
|
-
- **D-pad escape sequences** — `data-repeat` attribute now properly converts `\x1b` to ESC character
|
|
38
|
-
- **Removed debug console.log** — no longer leaks sessionId to browser console
|
|
39
|
-
|
|
40
|
-
## 1.2.2 (2026-03-17)
|
|
41
|
-
|
|
42
|
-
### Bug Fixes
|
|
43
|
-
- **Windows fully hidden** — use VBS launcher instead of `windowsHide` (which still showed in taskbar)
|
|
44
|
-
|
|
45
|
-
## 1.2.1 (2026-03-17)
|
|
46
|
-
|
|
47
|
-
### Bug Fixes
|
|
48
|
-
- **Windows background mode** — fixed node-pty crash in detached mode
|
|
49
|
-
- **Supervisor crash loop** — fixed `--supervisor` arg being caught by "already running" check
|
|
50
|
-
|
|
51
|
-
## 1.2.0 (2026-03-17)
|
|
5
|
+
### Breaking Changes
|
|
6
|
+
- **Complete rewrite**: P2P architecture replaces relay server
|
|
7
|
+
- Command changed from `npx ghostterm` to same — but now connects directly via WebRTC
|
|
8
|
+
- No more Tailscale/relay dependency — works over any network
|
|
52
9
|
|
|
53
10
|
### Features
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
- **Heartbeat ping/pong** — relay pings every 20s; mobile detects dead connections within 30s and auto-reconnects
|
|
66
|
-
- **Disconnect overlay** — clear full-screen prompt when companion goes offline
|
|
67
|
-
- **Session loading spinner** — visual feedback when switching sessions
|
|
68
|
-
- **Improved toast notifications** — slide-in animation
|
|
69
|
-
|
|
70
|
-
### Docs
|
|
71
|
-
- Updated README with new features, PM2 instructions, heartbeat details
|
|
72
|
-
- Added CHANGELOG
|
|
73
|
-
|
|
74
|
-
## 1.1.1 (2026-03-16)
|
|
75
|
-
|
|
76
|
-
### Security Hardening
|
|
77
|
-
- **Rate limiting** — 50 messages/second per WebSocket connection
|
|
78
|
-
- **IP connection limit** — max 5 concurrent connections per IP
|
|
79
|
-
- **Brute force protection** — pair code entry locked after 3 failed attempts (60s cooldown)
|
|
80
|
-
- **Origin verification** — only ghostterm.pages.dev allowed
|
|
81
|
-
- **Max payload** — 1MB limit per WebSocket message
|
|
82
|
-
- **Timing-safe HMAC** — prevents timing attacks on token verification
|
|
83
|
-
- **Upload validation** — 5MB size limit + extension whitelist
|
|
84
|
-
- **Pair code format validation** — must be exactly 6 digits
|
|
85
|
-
- **WSS enforcement** — prevents MITM downgrade attacks
|
|
86
|
-
- **Exponential backoff** — reconnection delay 1s → 30s max
|
|
11
|
+
- WebRTC P2P direct connection between phone and PC terminal
|
|
12
|
+
- 6-digit pair code + QR code for easy pairing
|
|
13
|
+
- Multi-session support (up to 4 concurrent terminals)
|
|
14
|
+
- End-to-end encrypted (DTLS) — terminal data never touches the server
|
|
15
|
+
- File upload from phone to PC via DataChannel
|
|
16
|
+
- Delta sync for reconnection recovery
|
|
17
|
+
- Automatic reconnect with exponential backoff
|
|
18
|
+
- Google Sign-In authentication
|
|
19
|
+
- DataChannel flow control (backpressure)
|
|
20
|
+
- PWA install support
|
|
21
|
+
- Latency monitoring (ping display)
|
|
87
22
|
|
|
88
23
|
### Bug Fixes
|
|
89
|
-
- Fixed
|
|
90
|
-
- Fixed
|
|
91
|
-
- Fixed
|
|
92
|
-
|
|
93
|
-
## 1.1.0 (2026-03-15)
|
|
94
|
-
|
|
95
|
-
### Features
|
|
96
|
-
- Google OAuth auto-pairing (sign in once, auto-reconnects)
|
|
97
|
-
- Long-lived token (30 days, no repeated Google sign-in)
|
|
98
|
-
- 4 simultaneous terminal sessions with ghost cell previews
|
|
99
|
-
- Pixel office mode
|
|
100
|
-
- File upload and screenshot support
|
|
101
|
-
- D-pad controls, quick keys (y/n/Tab/Shift+Tab)
|
|
102
|
-
- Copy mode for terminal text selection
|
|
103
|
-
|
|
104
|
-
## 1.0.0 (2026-03-14)
|
|
105
|
-
|
|
106
|
-
- Initial release
|
|
107
|
-
- Basic terminal relay via WebSocket
|
|
108
|
-
- Pair code pairing
|
|
24
|
+
- Fixed terminal rendering: use conpty (not winpty) for proper ANSI escape code support
|
|
25
|
+
- Fixed `bufferSeq` calculation to match byte-length tracking
|
|
26
|
+
- Fixed delta sync to send sliced buffer instead of full buffer
|
|
27
|
+
- Fixed `attach`/`close-session` sessionId passthrough from DataChannel message format
|
package/README.md
CHANGED
|
@@ -1,287 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
<img src="https://ghostterm.pages.dev/img/banner.png" width="500" alt="GhostTerm Banner">
|
|
3
|
-
</p>
|
|
1
|
+
# GhostTerm P2P
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
<p align="center">
|
|
7
|
-
<strong>A mobile terminal for Claude Code fans.</strong><br>
|
|
8
|
-
Control your PC from your phone — real CLI, not a toy.
|
|
9
|
-
</p>
|
|
10
|
-
<p align="center">
|
|
11
|
-
<a href="https://www.npmjs.com/package/ghostterm"><img src="https://img.shields.io/npm/v/ghostterm.svg" alt="npm version"></a>
|
|
12
|
-
<a href="https://www.npmjs.com/package/ghostterm"><img src="https://img.shields.io/npm/dm/ghostterm.svg" alt="npm downloads"></a>
|
|
13
|
-
<img src="https://img.shields.io/node/v/ghostterm" alt="node version">
|
|
14
|
-
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="license">
|
|
15
|
-
</p>
|
|
3
|
+
Control your PC terminal from your phone — direct P2P, no server in between.
|
|
16
4
|
|
|
17
|
-
|
|
5
|
+
## How it works
|
|
18
6
|
|
|
19
|
-
|
|
7
|
+
1. Run `npx ghostterm-p2p` on your PC
|
|
8
|
+
2. A 6-digit pair code appears (with a QR code)
|
|
9
|
+
3. Open the mobile site on your phone and enter the code
|
|
10
|
+
4. A direct WebRTC P2P connection is established
|
|
11
|
+
5. All terminal data flows directly between your phone and PC, encrypted end-to-end
|
|
12
|
+
6. The signaling server only helps with the initial pairing — it never sees your terminal data
|
|
20
13
|
|
|
21
|
-
##
|
|
22
|
-
|
|
23
|
-
GhostTerm lets you **control your PC terminal from your phone** over the internet. It's built specifically for [Claude Code](https://docs.anthropic.com/en/docs/claude-code) users who want to:
|
|
24
|
-
|
|
25
|
-
- Run `claude --dangerously-skip-permissions` and monitor everything from their phone
|
|
26
|
-
- Approve/deny tool calls from anywhere (bus, bed, coffee shop)
|
|
27
|
-
- Manage 4 terminal sessions simultaneously
|
|
28
|
-
|
|
29
|
-
No VPN. No Tailscale. No port forwarding. Just one command.
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## Quick Start
|
|
34
|
-
|
|
35
|
-
### 1. On your PC
|
|
14
|
+
## Install & Run
|
|
36
15
|
|
|
37
16
|
```bash
|
|
38
|
-
npx ghostterm
|
|
17
|
+
npx ghostterm-p2p
|
|
39
18
|
```
|
|
40
19
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
$ npx ghostterm
|
|
45
|
-
✅ GhostTerm running in background (PID: 12345)
|
|
46
|
-
📱 Open: ghostterm.pages.dev
|
|
47
|
-
🛑 Stop: npx ghostterm stop
|
|
48
|
-
📋 Logs: npx ghostterm logs
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Other commands:
|
|
20
|
+
Or install globally:
|
|
52
21
|
|
|
53
22
|
```bash
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
npx ghostterm logs # show recent logs
|
|
23
|
+
npm install -g ghostterm-p2p
|
|
24
|
+
ghostterm-p2p
|
|
57
25
|
```
|
|
58
26
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
Open **[ghostterm.pages.dev](https://ghostterm.pages.dev)** in any mobile browser. Sign in with the same Google account.
|
|
62
|
-
|
|
63
|
-
**That's it.** Your terminal appears on your phone.
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
## Screenshots
|
|
68
|
-
|
|
69
|
-
<p align="center">
|
|
70
|
-
<img src="https://ghostterm.pages.dev/img/office-busy.jpg" width="220" alt="Ghosts working">
|
|
71
|
-
<img src="https://ghostterm.pages.dev/img/pixel-office.jpg" width="220" alt="Pixel office">
|
|
72
|
-
<img src="https://ghostterm.pages.dev/img/claude-code.jpg" width="220" alt="Claude Code on phone">
|
|
73
|
-
</p>
|
|
74
|
-
<p align="center">
|
|
75
|
-
<em>Pixel ghost office · 4 terminal sessions · Claude Code on your phone</em>
|
|
76
|
-
</p>
|
|
77
|
-
|
|
78
|
-
---
|
|
79
|
-
|
|
80
|
-
## Features
|
|
81
|
-
|
|
82
|
-
### Terminal
|
|
83
|
-
|
|
84
|
-
- **Real xterm.js terminal** — full ANSI colors, 256-color, scrollback buffer
|
|
85
|
-
- **4 simultaneous sessions** — more than Anthropic's official mobile app
|
|
86
|
-
- **Auto-resize** — terminal adapts to your phone's screen size
|
|
87
|
-
- **Scrollback history** — scroll up to see previous output, page up/down buttons
|
|
88
|
-
|
|
89
|
-
### Controls
|
|
90
|
-
|
|
91
|
-
- **Quick keys** — one-tap `y`/`n` for Claude Code approvals
|
|
92
|
-
- **12345 numpad** — tap to pop up number selection for CLI surveys/prompts (raw keypress, no Enter)
|
|
93
|
-
- **D-pad** — arrow keys, Enter, Tab, Shift+Tab, Space
|
|
94
|
-
- **Long-press acceleration** — hold Backspace, arrow keys, Space, or scroll buttons to repeat with increasing speed
|
|
95
|
-
- **`claude` button** — quick-launch menu: new session, resume, continue, dangerous mode
|
|
96
|
-
- **Ctrl+C (Stop)** — interrupt running processes
|
|
97
|
-
- **Text input** — full keyboard input with Send button
|
|
98
|
-
- **Tap feedback** — all buttons show visual press animation
|
|
99
|
-
- **Copy mode** — select and copy terminal text
|
|
100
|
-
|
|
101
|
-
### File Transfer
|
|
102
|
-
|
|
103
|
-
- **Screen** — capture your terminal screen and send it to your PC as a file
|
|
104
|
-
- **File upload** — upload files directly from your phone to your desktop
|
|
105
|
-
- **Paste button** — always visible; glows for 5 seconds after upload with shortened filename; tap to paste the file path into the terminal
|
|
106
|
-
|
|
107
|
-
### Visual
|
|
108
|
-
|
|
109
|
-
- **Pixel office mode** — see all 4 terminals as cute ghost desks in a Halloween-themed pixel office
|
|
110
|
-
- **Ghost cell previews** — live miniature terminal previews in the header
|
|
111
|
-
- **Dark theme** — easy on the eyes, matches terminal aesthetics
|
|
112
|
-
|
|
113
|
-
### Connection
|
|
114
|
-
|
|
115
|
-
- **Google auto-pairing** — sign in once, auto-reconnects forever
|
|
116
|
-
- **Encrypted relay** — all traffic over WSS (WebSocket Secure)
|
|
117
|
-
- **Zero data stored** — the relay only forwards messages
|
|
118
|
-
- **Heartbeat** — relay pings every 20s; dead connections detected and auto-reconnected within 30s
|
|
119
|
-
- **Auto-reconnect** — exponential backoff (1s → 30s max), handles network drops gracefully
|
|
120
|
-
- **Session persistence** — refreshing the page restores your last active terminal session
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
## How It Works
|
|
27
|
+
## Options
|
|
125
28
|
|
|
126
29
|
```
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
zero data stored
|
|
30
|
+
-s, --signal <url> Signaling server URL
|
|
31
|
+
--site <url> Mobile site URL
|
|
32
|
+
-h, --help Show help
|
|
131
33
|
```
|
|
132
34
|
|
|
133
|
-
1. `npx ghostterm` starts a companion process on your PC that connects to the relay server
|
|
134
|
-
2. The companion spawns a real PTY (pseudo-terminal) using `node-pty`
|
|
135
|
-
3. Your phone connects to the same relay via WebSocket
|
|
136
|
-
4. The relay matches both sides by Google account and forwards messages
|
|
137
|
-
5. Terminal output streams to your phone; your input streams to the PTY
|
|
138
|
-
|
|
139
|
-
---
|
|
140
|
-
|
|
141
|
-
## Use Cases
|
|
142
|
-
|
|
143
|
-
### The "Dangerous" Workflow
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
claude --dangerously-skip-permissions
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
Let Claude Code run fully autonomous on your PC. Monitor everything from your phone. Intervene when needed. Go make coffee.
|
|
150
|
-
|
|
151
|
-
### Multi-Session Power
|
|
152
|
-
|
|
153
|
-
4 ghost cells = 4 terminals. Run Claude Code in one, `git log` in another, `npm test` in a third. Switch between them with a tap.
|
|
154
|
-
|
|
155
|
-
### On-the-Go Approval
|
|
156
|
-
|
|
157
|
-
Claude Code asking "May I edit server.js?" — tap `y` from the bus. No need to rush back to your desk.
|
|
158
|
-
|
|
159
|
-
---
|
|
160
|
-
|
|
161
|
-
## System Requirements
|
|
162
|
-
|
|
163
|
-
### PC (Companion)
|
|
164
|
-
|
|
165
|
-
- **Node.js** 18 or later
|
|
166
|
-
- **Operating System**: Windows, macOS, or Linux
|
|
167
|
-
- **Platform-specific build tools** (for `node-pty`):
|
|
168
|
-
- **Windows**: Visual Studio Build Tools or `npm install -g windows-build-tools`
|
|
169
|
-
- **macOS**: `xcode-select --install`
|
|
170
|
-
- **Linux**: `apt install build-essential` (Debian/Ubuntu) or equivalent
|
|
171
|
-
- **Google account** for pairing
|
|
172
|
-
|
|
173
|
-
### Phone (Client)
|
|
174
|
-
|
|
175
|
-
- Any modern browser (iOS Safari 15+, Chrome, Firefox, Edge)
|
|
176
|
-
- Internet connection
|
|
177
|
-
|
|
178
|
-
---
|
|
179
|
-
|
|
180
|
-
## Configuration
|
|
181
|
-
|
|
182
|
-
### Environment Variables
|
|
183
|
-
|
|
184
|
-
| Variable | Default | Description |
|
|
185
|
-
|---|---|---|
|
|
186
|
-
| `GHOSTTERM_RELAY` | `wss://ghostterm-relay.fly.dev` | Custom relay server URL |
|
|
187
|
-
|
|
188
|
-
### Custom Relay
|
|
189
|
-
|
|
190
|
-
If you want to self-host the relay:
|
|
191
|
-
|
|
192
|
-
```bash
|
|
193
|
-
GHOSTTERM_RELAY=wss://your-relay.example.com npx ghostterm
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
---
|
|
197
|
-
|
|
198
|
-
## Pricing
|
|
199
|
-
|
|
200
|
-
GhostTerm is currently **free** during early access. Pro plans coming soon.
|
|
201
|
-
|
|
202
|
-
---
|
|
203
|
-
|
|
204
|
-
## Troubleshooting
|
|
205
|
-
|
|
206
|
-
### "Failed to install node-pty" / build errors
|
|
207
|
-
|
|
208
|
-
`node-pty` requires native compilation. Make sure you have build tools installed:
|
|
209
|
-
|
|
210
|
-
```bash
|
|
211
|
-
# Windows (run as Administrator)
|
|
212
|
-
npm install -g windows-build-tools
|
|
213
|
-
|
|
214
|
-
# macOS
|
|
215
|
-
xcode-select --install
|
|
216
|
-
|
|
217
|
-
# Linux (Debian/Ubuntu)
|
|
218
|
-
sudo apt install build-essential python3
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
### "Google sign-in window doesn't open"
|
|
222
|
-
|
|
223
|
-
- Make sure your default browser isn't blocking pop-ups
|
|
224
|
-
- Try running `npx ghostterm` again — it retries automatically
|
|
225
|
-
- If behind a corporate proxy, ensure `accounts.google.com` is accessible
|
|
226
|
-
|
|
227
|
-
### "Phone can't connect" / "Waiting for companion..."
|
|
228
|
-
|
|
229
|
-
- Ensure the PC companion is still running (`npx ghostterm`)
|
|
230
|
-
- Both devices must use the **same Google account**
|
|
231
|
-
- Check your phone's internet connection
|
|
232
|
-
- Try refreshing the page on your phone
|
|
233
|
-
|
|
234
|
-
### "Terminal shows garbled text"
|
|
235
|
-
|
|
236
|
-
- Make sure your phone browser supports modern CSS/JS
|
|
237
|
-
- Try switching to a different terminal session (tap a ghost cell)
|
|
238
|
-
- Clear browser cache and reload
|
|
239
|
-
|
|
240
|
-
### "Session keeps disconnecting"
|
|
241
|
-
|
|
242
|
-
- Check your network stability on both PC and phone
|
|
243
|
-
- The relay auto-reconnects with exponential backoff
|
|
244
|
-
- If using a VPN, try disabling it (GhostTerm doesn't need one)
|
|
245
|
-
|
|
246
|
-
### node-pty on Apple Silicon (M1/M2/M3)
|
|
247
|
-
|
|
248
|
-
If you see architecture mismatch errors:
|
|
249
|
-
|
|
250
|
-
```bash
|
|
251
|
-
# Force rebuild for current architecture
|
|
252
|
-
npm rebuild node-pty
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
---
|
|
256
|
-
|
|
257
|
-
## Uninstall
|
|
258
|
-
|
|
259
|
-
GhostTerm stores a refresh token in `~/.ghostterm/` for auto-login. To fully remove:
|
|
260
|
-
|
|
261
|
-
```bash
|
|
262
|
-
rm -rf ~/.ghostterm
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
---
|
|
266
|
-
|
|
267
35
|
## Security
|
|
268
36
|
|
|
269
|
-
-
|
|
270
|
-
-
|
|
271
|
-
-
|
|
272
|
-
-
|
|
273
|
-
- Brute-force protection on pair code entry
|
|
274
|
-
- Rate limiting on all WebSocket connections
|
|
275
|
-
- Connection limits per IP address
|
|
276
|
-
|
|
277
|
-
---
|
|
278
|
-
|
|
279
|
-
## License
|
|
280
|
-
|
|
281
|
-
MIT
|
|
37
|
+
- **End-to-end encrypted**: WebRTC DTLS encryption protects all terminal data
|
|
38
|
+
- **No data on servers**: The signaling server only relays WebRTC connection setup messages
|
|
39
|
+
- **One-time pair codes**: Codes are deleted after use and expire in 5 minutes
|
|
40
|
+
- **Brute force protection**: 3 wrong codes = 60 second lockout
|
|
282
41
|
|
|
283
|
-
|
|
42
|
+
## Requirements
|
|
284
43
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
</p>
|
|
44
|
+
- Node.js >= 18
|
|
45
|
+
- Windows, macOS, or Linux
|