@ihasq/reterm 0.1.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/LICENSE +13 -0
- package/README.md +40 -0
- package/dist/cli.js +100 -0
- package/dist/cli.js.map +1 -0
- package/dist/public/assets/index-D6xc7zta.js +9 -0
- package/dist/public/assets/index-Dgf5qVEq.css +1 -0
- package/dist/public/index.html +13 -0
- package/dist/server.js +287 -0
- package/dist/server.js.map +1 -0
- package/dist/shared/protocol.js +20 -0
- package/dist/shared/protocol.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2026 ihasq
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# ReTerm
|
|
2
|
+
|
|
3
|
+
ReTerm is a local web terminal multiplexer based on
|
|
4
|
+
[vercel-labs/wterm](https://github.com/vercel-labs/wterm). It uses the wterm
|
|
5
|
+
DOM/React terminal renderer in the browser, a local `node-pty` backend, and a
|
|
6
|
+
Dockview workspace for draggable dock panels, tabs, floating groups, and splits.
|
|
7
|
+
|
|
8
|
+
## Run
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npx @ihasq/reterm
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The command starts an HTTP server bound to `127.0.0.1` by default and prints a
|
|
15
|
+
URL containing a one-time access token.
|
|
16
|
+
|
|
17
|
+
## CLI
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
reterm [--host 127.0.0.1] [--port 8787] [--cwd /path/to/workdir] [--shell /bin/zsh] [--no-token]
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- `--host`: interface to bind. Defaults to `127.0.0.1`.
|
|
24
|
+
- `--port`: preferred port. Defaults to `8787`; if busy, ReTerm tries the next
|
|
25
|
+
few ports. Use `0` to request a random free port.
|
|
26
|
+
- `--cwd`: working directory for new terminal panes. Defaults to the current
|
|
27
|
+
command directory.
|
|
28
|
+
- `--shell`: shell executable for new terminal panes. Defaults to `$SHELL` on
|
|
29
|
+
Unix and PowerShell/CMD on Windows.
|
|
30
|
+
- `--no-token`: disables the local access token. Use only on trusted networks.
|
|
31
|
+
|
|
32
|
+
## Development
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install
|
|
36
|
+
npm run build
|
|
37
|
+
node dist/cli.js
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The packaged CLI serves the Vite-built client from `dist/public`.
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import crypto from "node:crypto";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
import { startReTermServer } from "./server.js";
|
|
6
|
+
const VERSION = "0.1.0";
|
|
7
|
+
main().catch((error) => {
|
|
8
|
+
console.error(error instanceof Error ? error.message : error);
|
|
9
|
+
process.exitCode = 1;
|
|
10
|
+
});
|
|
11
|
+
async function main() {
|
|
12
|
+
const options = parseArgs(process.argv.slice(2));
|
|
13
|
+
const server = await startReTermServer(options);
|
|
14
|
+
console.log(`ReTerm ${VERSION}`);
|
|
15
|
+
console.log(`URL: ${server.url}`);
|
|
16
|
+
console.log(`CWD: ${server.cwd}`);
|
|
17
|
+
console.log(`Shell: ${server.shell}`);
|
|
18
|
+
console.log("Press Ctrl-C to stop.");
|
|
19
|
+
const shutdown = async () => {
|
|
20
|
+
await server.close();
|
|
21
|
+
process.exit(0);
|
|
22
|
+
};
|
|
23
|
+
process.once("SIGINT", shutdown);
|
|
24
|
+
process.once("SIGTERM", shutdown);
|
|
25
|
+
}
|
|
26
|
+
function parseArgs(args) {
|
|
27
|
+
const options = {
|
|
28
|
+
host: process.env.RETERM_HOST ?? "127.0.0.1",
|
|
29
|
+
port: Number(process.env.RETERM_PORT ?? 8787),
|
|
30
|
+
strictPort: false,
|
|
31
|
+
cwd: process.cwd(),
|
|
32
|
+
authToken: crypto.randomBytes(16).toString("hex")
|
|
33
|
+
};
|
|
34
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
35
|
+
const arg = args[index];
|
|
36
|
+
switch (arg) {
|
|
37
|
+
case "--help":
|
|
38
|
+
case "-h":
|
|
39
|
+
printHelp();
|
|
40
|
+
process.exit(0);
|
|
41
|
+
case "--version":
|
|
42
|
+
case "-v":
|
|
43
|
+
console.log(VERSION);
|
|
44
|
+
process.exit(0);
|
|
45
|
+
case "--host":
|
|
46
|
+
options.host = readValue(args, ++index, "--host");
|
|
47
|
+
break;
|
|
48
|
+
case "--port":
|
|
49
|
+
options.port = parsePort(readValue(args, ++index, "--port"));
|
|
50
|
+
options.strictPort = true;
|
|
51
|
+
break;
|
|
52
|
+
case "--cwd":
|
|
53
|
+
options.cwd = path.resolve(readValue(args, ++index, "--cwd"));
|
|
54
|
+
break;
|
|
55
|
+
case "--shell":
|
|
56
|
+
options.shell = readValue(args, ++index, "--shell");
|
|
57
|
+
break;
|
|
58
|
+
case "--no-token":
|
|
59
|
+
options.authToken = undefined;
|
|
60
|
+
break;
|
|
61
|
+
default:
|
|
62
|
+
throw new Error(`Unknown argument: ${arg}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (!Number.isInteger(options.port) || options.port < 0 || options.port > 65535) {
|
|
66
|
+
throw new Error(`Invalid port: ${options.port}`);
|
|
67
|
+
}
|
|
68
|
+
return options;
|
|
69
|
+
}
|
|
70
|
+
function readValue(args, index, flag) {
|
|
71
|
+
const value = args[index];
|
|
72
|
+
if (!value || value.startsWith("-")) {
|
|
73
|
+
throw new Error(`Missing value for ${flag}`);
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
function parsePort(value) {
|
|
78
|
+
const port = Number(value);
|
|
79
|
+
if (!Number.isInteger(port) || port < 0 || port > 65535) {
|
|
80
|
+
throw new Error(`Invalid port: ${value}`);
|
|
81
|
+
}
|
|
82
|
+
return port;
|
|
83
|
+
}
|
|
84
|
+
function printHelp() {
|
|
85
|
+
console.log(`ReTerm ${VERSION}
|
|
86
|
+
|
|
87
|
+
Usage:
|
|
88
|
+
reterm [options]
|
|
89
|
+
|
|
90
|
+
Options:
|
|
91
|
+
--host <host> Host to bind (default: 127.0.0.1)
|
|
92
|
+
--port <port> Port to bind (default: 8787, tries next free port)
|
|
93
|
+
--cwd <path> Working directory for new terminal panes
|
|
94
|
+
--shell <path> Shell executable for new terminal panes
|
|
95
|
+
--no-token Disable local access token
|
|
96
|
+
-v, --version Print version
|
|
97
|
+
-h, --help Print help
|
|
98
|
+
`);
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAWhD,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,K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