termbeam 0.0.7 โ 0.0.9
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 +53 -115
- package/package.json +3 -1
- package/src/cli.js +71 -15
package/README.md
CHANGED
|
@@ -1,40 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
# TermBeam
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
**Beam your terminal to any device**
|
|
3
|
+
**Beam your terminal to any device.**
|
|
6
4
|
|
|
7
5
|
[](https://www.npmjs.com/package/termbeam)
|
|
8
6
|
[](https://github.com/dorlugasigal/TermBeam/actions/workflows/ci.yml)
|
|
7
|
+
[](https://github.com/dorlugasigal/TermBeam/actions/workflows/ci.yml)
|
|
9
8
|
[](https://opensource.org/licenses/MIT)
|
|
10
|
-
[](https://nodejs.org)
|
|
11
|
-
|
|
12
|
-
Access your terminal from your phone, tablet, or any browser.
|
|
13
|
-
Multi-session, mobile-optimized, with touch controls.
|
|
14
9
|
|
|
15
|
-
|
|
10
|
+
TermBeam lets you access your terminal from a phone, tablet, or any browser โ no SSH, no port forwarding, no config files. Run one command and scan the QR code.
|
|
16
11
|
|
|
17
|
-
|
|
12
|
+
I built this because I kept needing to run quick commands on my dev machine while away from my desk, and SSH on a phone is painful. TermBeam gives you a real terminal with a touch-friendly UI that actually works on small screens.
|
|
18
13
|
|
|
19
|
-
|
|
14
|
+
[Full documentation](https://dorlugasigal.github.io/TermBeam/)
|
|
20
15
|
|
|
21
16
|
https://github.com/user-attachments/assets/c91ca15d-0c84-400f-bbfa-3d58d1be07ee
|
|
22
17
|
|
|
23
|
-
##
|
|
24
|
-
|
|
25
|
-
- ๐ฑ **Mobile-first UI** โ Touch-friendly interface designed for phones and tablets
|
|
26
|
-
- ๐ฅ๏ธ **Multi-session** โ Run multiple terminal sessions simultaneously
|
|
27
|
-
- ๐ **Password auth** โ Token-based authentication with rate limiting
|
|
28
|
-
- ๐ **Folder browser** โ Visual directory picker with breadcrumb navigation
|
|
29
|
-
- ๐ **Touch controls** โ Arrow keys, Ctrl shortcuts, Tab, Esc via on-screen touch bar
|
|
30
|
-
- ๐ค **Nerd Font support** โ Full glyph rendering with JetBrains Mono Nerd Font
|
|
31
|
-
- ๐ฒ **QR code** โ Scan to connect instantly from your phone
|
|
32
|
-
- ๐ **DevTunnel** โ Optional public URL for remote access from anywhere
|
|
33
|
-
- ๐ **Adjustable font size** โ Pinch or button zoom for any screen
|
|
34
|
-
- โ๏ธ **Swipe to delete** โ iOS-style session management
|
|
35
|
-
- ๐ **Smart versioning** โ Shows git hash in dev, clean version from npm
|
|
36
|
-
|
|
37
|
-
## ๐ Quick Start
|
|
18
|
+
## Quick Start
|
|
38
19
|
|
|
39
20
|
```bash
|
|
40
21
|
npx termbeam
|
|
@@ -47,124 +28,81 @@ npm install -g termbeam
|
|
|
47
28
|
termbeam
|
|
48
29
|
```
|
|
49
30
|
|
|
50
|
-
|
|
31
|
+
Scan the QR code printed in your terminal, or open the URL on any device.
|
|
51
32
|
|
|
52
|
-
###
|
|
33
|
+
### Password protection (recommended)
|
|
53
34
|
|
|
54
35
|
```bash
|
|
55
|
-
# Auto-generate a secure password
|
|
56
36
|
termbeam --generate-password
|
|
57
37
|
|
|
58
|
-
#
|
|
38
|
+
# or set your own
|
|
59
39
|
termbeam --password mysecret
|
|
60
40
|
```
|
|
61
41
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
termbeam --tunnel --generate-password
|
|
66
|
-
```
|
|
42
|
+
## Features
|
|
67
43
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
44
|
+
- **Mobile-first UI** with on-screen touch bar (arrow keys, Tab, Ctrl shortcuts, Esc) and swipe-to-delete session management
|
|
45
|
+
- **Multiple sessions** running simultaneously, managed from a single hub page โ shows connected client count per session
|
|
46
|
+
- **Password auth** with token-based cookies and rate-limited login
|
|
47
|
+
- **Folder browser** to pick working directories without typing paths
|
|
48
|
+
- **Initial command** โ optionally launch a session straight into `htop`, `vim`, or any command
|
|
49
|
+
- **Shell detection** โ auto-detects your shell on all platforms (PowerShell, cmd, bash, zsh, Git Bash, WSL)
|
|
50
|
+
- **QR code on startup** for instant phone connection
|
|
51
|
+
- **Light/dark theme** with persistent preference
|
|
52
|
+
- **Adjustable font size** via status bar controls, saved across sessions
|
|
53
|
+
- **Remote access via [DevTunnel](#remote-access)** โ ephemeral or persisted public URLs
|
|
73
54
|
|
|
74
|
-
##
|
|
55
|
+
## Remote Access
|
|
75
56
|
|
|
76
57
|
```bash
|
|
77
|
-
#
|
|
78
|
-
termbeam
|
|
79
|
-
|
|
80
|
-
# Use a specific shell
|
|
81
|
-
termbeam /bin/bash
|
|
82
|
-
|
|
83
|
-
# Custom port and listen on all interfaces (LAN access)
|
|
84
|
-
termbeam --port 8080 --host 0.0.0.0
|
|
85
|
-
|
|
86
|
-
# Public tunnel + password (access from anywhere)
|
|
58
|
+
# One-off tunnel (deleted on shutdown)
|
|
87
59
|
termbeam --tunnel --generate-password
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### CLI Options
|
|
91
|
-
|
|
92
|
-
| Flag | Description | Default |
|
|
93
|
-
| --------------------- | ------------------------------- | ----------- |
|
|
94
|
-
| `--password <pw>` | Set access password | None |
|
|
95
|
-
| `--generate-password` | Auto-generate a secure password | โ |
|
|
96
|
-
| `--tunnel` | Create a public devtunnel URL | Off |
|
|
97
|
-
| `--port <port>` | Server port | `3456` |
|
|
98
|
-
| `--host <addr>` | Bind address | `127.0.0.1` |
|
|
99
|
-
| `-h, --help` | Show help | โ |
|
|
100
|
-
| `-v, --version` | Show version | โ |
|
|
101
60
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
| ------------------- | ------------------------------- |
|
|
106
|
-
| `PORT` | Server port (overrides default) |
|
|
107
|
-
| `TERMBEAM_PASSWORD` | Access password |
|
|
108
|
-
| `TERMBEAM_CWD` | Default working directory |
|
|
109
|
-
|
|
110
|
-
## ๐ Security
|
|
61
|
+
# Persisted tunnel (stable URL you can bookmark, reused across restarts, 30-day expiry)
|
|
62
|
+
termbeam --persisted-tunnel --generate-password
|
|
63
|
+
```
|
|
111
64
|
|
|
112
|
-
|
|
65
|
+
Requires the [Dev Tunnels CLI](https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/get-started):
|
|
113
66
|
|
|
114
|
-
-
|
|
115
|
-
-
|
|
116
|
-
-
|
|
117
|
-
- ๐ **Localhost by default** โ requires explicit `--host 0.0.0.0` for LAN access
|
|
67
|
+
- **Windows:** `winget install Microsoft.devtunnel`
|
|
68
|
+
- **macOS:** `brew install --cask devtunnel`
|
|
69
|
+
- **Linux:** `curl -sL https://aka.ms/DevTunnelCliInstall | bash`
|
|
118
70
|
|
|
119
|
-
|
|
71
|
+
Persisted tunnels save a tunnel ID to `~/.termbeam/tunnel.json` so the URL stays the same between sessions.
|
|
120
72
|
|
|
121
|
-
##
|
|
73
|
+
## CLI Reference
|
|
122
74
|
|
|
123
|
-
```
|
|
124
|
-
termbeam
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
โ โโโ server.js # Main orchestrator
|
|
128
|
-
โ โโโ cli.js # Argument parsing & help
|
|
129
|
-
โ โโโ auth.js # Authentication & rate limiting
|
|
130
|
-
โ โโโ sessions.js # PTY session lifecycle
|
|
131
|
-
โ โโโ routes.js # Express HTTP routes
|
|
132
|
-
โ โโโ websocket.js # WebSocket terminal I/O
|
|
133
|
-
โ โโโ tunnel.js # DevTunnel integration
|
|
134
|
-
โ โโโ version.js # Smart version detection
|
|
135
|
-
โโโ public/
|
|
136
|
-
โ โโโ index.html # Session manager UI (mobile)
|
|
137
|
-
โ โโโ terminal.html # Terminal UI (xterm.js)
|
|
138
|
-
โโโ test/ # Unit tests (node:test)
|
|
139
|
-
โโโ docs/ # MkDocs documentation
|
|
140
|
-
โโโ .github/workflows/ # CI, Release, Docs deployment
|
|
75
|
+
```bash
|
|
76
|
+
termbeam [shell] [args...] # start with a specific shell (default: auto-detect)
|
|
77
|
+
termbeam --port 8080 # custom port (default: 3456)
|
|
78
|
+
termbeam --host 127.0.0.1 # restrict to localhost (default: 0.0.0.0)
|
|
141
79
|
```
|
|
142
80
|
|
|
143
|
-
|
|
81
|
+
| Flag | Description | Default |
|
|
82
|
+
| --------------------- | ---------------------------------------- | ----------- |
|
|
83
|
+
| `--password <pw>` | Set access password | None |
|
|
84
|
+
| `--generate-password` | Auto-generate a secure password | โ |
|
|
85
|
+
| `--tunnel` | Create an ephemeral devtunnel URL | Off |
|
|
86
|
+
| `--persisted-tunnel` | Create a reusable devtunnel URL | Off |
|
|
87
|
+
| `--port <port>` | Server port | `3456` |
|
|
88
|
+
| `--host <addr>` | Bind address | `0.0.0.0` |
|
|
144
89
|
|
|
145
|
-
|
|
90
|
+
Environment variables: `PORT`, `TERMBEAM_PASSWORD`, `TERMBEAM_CWD` (see [Configuration docs](https://dorlugasigal.github.io/TermBeam/configuration/)).
|
|
146
91
|
|
|
147
|
-
|
|
92
|
+
## Security
|
|
148
93
|
|
|
149
|
-
|
|
150
|
-
- [Configuration](https://dorlugasigal.github.io/TermBeam/configuration/)
|
|
151
|
-
- [Security](https://dorlugasigal.github.io/TermBeam/security/)
|
|
152
|
-
- [API Reference](https://dorlugasigal.github.io/TermBeam/api/)
|
|
153
|
-
- [Architecture](https://dorlugasigal.github.io/TermBeam/architecture/)
|
|
94
|
+
TermBeam binds to all interfaces (`0.0.0.0`) by default, so it's accessible on your local network out of the box. **Always set a password** when running on a shared network, or pass `--host 127.0.0.1` to restrict access to your machine only.
|
|
154
95
|
|
|
155
|
-
|
|
96
|
+
Auth uses secure httpOnly cookies with 24-hour expiry, login is rate-limited to 5 attempts per minute, and security headers (X-Frame-Options, X-Content-Type-Options, etc.) are set on all responses. API clients that can't use cookies can authenticate with an `Authorization: Bearer <password>` header. See the [Security Guide](https://dorlugasigal.github.io/TermBeam/security/) for more.
|
|
156
97
|
|
|
157
|
-
|
|
98
|
+
## Contributing
|
|
158
99
|
|
|
159
|
-
|
|
160
|
-
- Testing guide (Node.js built-in test runner)
|
|
161
|
-
- Commit conventions and PR process
|
|
162
|
-
- Release process (maintainers)
|
|
100
|
+
Contributions welcome โ see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
163
101
|
|
|
164
|
-
##
|
|
102
|
+
## License
|
|
165
103
|
|
|
166
|
-
[MIT](LICENSE)
|
|
104
|
+
[MIT](LICENSE)
|
|
167
105
|
|
|
168
|
-
##
|
|
106
|
+
## Acknowledgments
|
|
169
107
|
|
|
170
108
|
Special thanks to [@tamirdresher](https://github.com/tamirdresher) for the [blog post](https://www.tamirdresher.com/blog/2026/02/26/squad-remote-control) that inspired the solution idea for this project, and for his [cli-tunnel](https://github.com/tamirdresher/cli-tunnel) implementation.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "termbeam",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Beam your terminal to any device โ mobile-optimized web terminal with multi-session support",
|
|
5
5
|
"main": "src/server.js",
|
|
6
6
|
"bin": {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"start": "node bin/termbeam.js",
|
|
11
11
|
"dev": "node bin/termbeam.js --generate-password",
|
|
12
12
|
"test": "node --test test/*.test.js",
|
|
13
|
+
"test:coverage": "c8 --reporter=text --reporter=lcov --reporter=json-summary --reporter=json node --test --test-reporter=spec --test-reporter-destination=stdout test/*.test.js",
|
|
13
14
|
"prepare": "husky",
|
|
14
15
|
"format": "prettier --write .",
|
|
15
16
|
"lint": "node --check src/*.js bin/*.js",
|
|
@@ -62,6 +63,7 @@
|
|
|
62
63
|
"ws": "^8.19.0"
|
|
63
64
|
},
|
|
64
65
|
"devDependencies": {
|
|
66
|
+
"c8": "^11.0.0",
|
|
65
67
|
"husky": "^9.1.7",
|
|
66
68
|
"lint-staged": "^16.2.7",
|
|
67
69
|
"prettier": "^3.8.1"
|
package/src/cli.js
CHANGED
|
@@ -33,28 +33,84 @@ Environment:
|
|
|
33
33
|
`);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Get ancestor process names on Windows by walking up the process tree.
|
|
38
|
+
* Fetches all processes in a single wmic call, then walks the tree in memory.
|
|
39
|
+
*/
|
|
40
|
+
function getWindowsAncestors(startPid, maxDepth = 4) {
|
|
41
|
+
const { execFileSync } = require('child_process');
|
|
42
|
+
const names = [];
|
|
43
|
+
const safePid = parseInt(startPid, 10);
|
|
44
|
+
if (!Number.isFinite(safePid) || safePid <= 0) return names;
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
const result = execFileSync(
|
|
48
|
+
'wmic',
|
|
49
|
+
['process', 'get', 'Name,ParentProcessId,ProcessId', '/format:csv'],
|
|
50
|
+
{ stdio: ['pipe', 'pipe', 'ignore'], encoding: 'utf8', timeout: 5000 },
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
// Parse CSV output โ first non-empty line is the header
|
|
54
|
+
const lines = result.split(/\r?\n/).filter((l) => l.trim());
|
|
55
|
+
if (lines.length === 0) return names;
|
|
56
|
+
|
|
57
|
+
const header = lines[0].split(',').map((h) => h.trim());
|
|
58
|
+
const nameIdx = header.indexOf('Name');
|
|
59
|
+
const pidIdx = header.indexOf('ProcessId');
|
|
60
|
+
const ppidIdx = header.indexOf('ParentProcessId');
|
|
61
|
+
if (nameIdx === -1 || pidIdx === -1 || ppidIdx === -1) return names;
|
|
62
|
+
|
|
63
|
+
const processes = new Map();
|
|
64
|
+
for (let i = 1; i < lines.length; i++) {
|
|
65
|
+
const cols = lines[i].split(',');
|
|
66
|
+
if (cols.length <= Math.max(nameIdx, pidIdx, ppidIdx)) continue;
|
|
67
|
+
const pid = parseInt(cols[pidIdx], 10);
|
|
68
|
+
if (Number.isFinite(pid)) {
|
|
69
|
+
processes.set(pid, { name: cols[nameIdx].trim().toLowerCase(), ppid: parseInt(cols[ppidIdx], 10) });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Walk up the tree in memory โ no more subprocess calls
|
|
74
|
+
let currentPid = safePid;
|
|
75
|
+
for (let i = 0; i < maxDepth; i++) {
|
|
76
|
+
const proc = processes.get(currentPid);
|
|
77
|
+
if (!proc) break;
|
|
78
|
+
console.log(`[termbeam] Process tree: ${proc.name}`);
|
|
79
|
+
names.push(proc.name);
|
|
80
|
+
if (!Number.isFinite(proc.ppid) || proc.ppid === 0 || proc.ppid === currentPid) break;
|
|
81
|
+
currentPid = proc.ppid;
|
|
82
|
+
}
|
|
83
|
+
} catch (err) {
|
|
84
|
+
console.log(`[termbeam] Could not query process tree: ${err.message}`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return names;
|
|
88
|
+
}
|
|
89
|
+
|
|
36
90
|
function getDefaultShell() {
|
|
37
91
|
const { execFileSync } = require('child_process');
|
|
38
92
|
const ppid = process.ppid;
|
|
39
93
|
console.log(`[termbeam] Detecting shell (parent PID: ${ppid}, platform: ${os.platform()})`);
|
|
40
94
|
|
|
41
95
|
if (os.platform() === 'win32') {
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (name === 'pwsh.exe') return 'pwsh.exe';
|
|
54
|
-
if (name === 'powershell.exe') return 'powershell.exe';
|
|
96
|
+
// Walk up the process tree (up to 4 ancestors) to find the real user shell.
|
|
97
|
+
// npx/npm on Windows spawns cmd.exe as intermediary, so the immediate
|
|
98
|
+
// parent is often cmd.exe or node.exe rather than the user's actual shell.
|
|
99
|
+
const ancestors = getWindowsAncestors(ppid);
|
|
100
|
+
const preferredShells = ['pwsh.exe', 'powershell.exe'];
|
|
101
|
+
|
|
102
|
+
let foundCmd = false;
|
|
103
|
+
for (const name of ancestors) {
|
|
104
|
+
if (preferredShells.includes(name)) {
|
|
105
|
+
console.log(`[termbeam] Found shell in process tree: ${name}`);
|
|
106
|
+
return name;
|
|
55
107
|
}
|
|
56
|
-
|
|
57
|
-
|
|
108
|
+
if (name === 'cmd.exe') foundCmd = true;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (foundCmd) {
|
|
112
|
+
console.log(`[termbeam] Using detected shell: cmd.exe`);
|
|
113
|
+
return 'cmd.exe';
|
|
58
114
|
}
|
|
59
115
|
const fallback = process.env.COMSPEC || 'cmd.exe';
|
|
60
116
|
console.log(`[termbeam] Falling back to: ${fallback}`);
|