tring-chat 0.1.5 → 0.1.6
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
CHANGED
|
@@ -98,7 +98,8 @@ npm i -g ./packages/server # install this checkout as `tring`
|
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
Flags: `--port` (7331), `--host` (127.0.0.1), `--token`, `--scrollback` (5000),
|
|
101
|
-
`--idle-ms` (3000), `--shell`, `--
|
|
101
|
+
`--idle-ms` (3000), `--shell`, `--fs-root`, `--allow-origin`, `--insecure-no-token`,
|
|
102
|
+
`--no-open`, `--no-update-check`, `--version`.
|
|
102
103
|
|
|
103
104
|
## On a phone
|
|
104
105
|
|
|
@@ -111,11 +112,45 @@ The daemon only listens on `127.0.0.1` by default. To reach it from a phone, bin
|
|
|
111
112
|
the network and require a token:
|
|
112
113
|
|
|
113
114
|
```
|
|
114
|
-
tring --host 0.0.0.0 --token
|
|
115
|
+
tring --host 0.0.0.0 --token "$(openssl rand -hex 32)"
|
|
115
116
|
```
|
|
116
117
|
|
|
117
118
|
then open `http://<your-machine>:7331/?token=some-long-secret` on the phone. A private
|
|
118
119
|
network such as Tailscale is the safer way to do this than opening the port on a LAN.
|
|
120
|
+
|
|
121
|
+
Binding off localhost without a token is refused at startup rather than warned about: the
|
|
122
|
+
daemon spawns shells, and off loopback the token is the only thing in front of them.
|
|
123
|
+
`--insecure-no-token` overrides that if the network is already trusted that far.
|
|
124
|
+
|
|
125
|
+
The token is remembered on that first visit and then taken back off the address bar, but
|
|
126
|
+
a secret that has travelled in a URL is only as private as the URL: it has already been
|
|
127
|
+
through your history, any proxy log on the way, and whatever chat app you sent the link
|
|
128
|
+
in. Treat the link as the secret, and rotate with a new `--token` rather than assuming an
|
|
129
|
+
old link has expired.
|
|
130
|
+
|
|
131
|
+
## Who can reach the daemon
|
|
132
|
+
|
|
133
|
+
The daemon spawns shells, so it only answers requests from the page it serves itself.
|
|
134
|
+
That check matters more than the bind address: the same-origin policy does not cover
|
|
135
|
+
WebSockets, so without it any website you happened to have open could open a socket to
|
|
136
|
+
`ws://127.0.0.1:7331` and type into your terminals. Binding to loopback keeps other
|
|
137
|
+
machines out, not other websites.
|
|
138
|
+
|
|
139
|
+
- A browser page from another origin is refused at the handshake. So is a domain rebound
|
|
140
|
+
to 127.0.0.1, while the daemon is on loopback.
|
|
141
|
+
- Non-browser clients send no `Origin` and are unaffected — the Claude Code hooks, curl
|
|
142
|
+
and `/api/sessions` scripts keep working exactly as before.
|
|
143
|
+
- `--allow-origin <origin>` adds one, for a front end you serve yourself. `npm run dev`
|
|
144
|
+
sets it for the Vite server on :5173.
|
|
145
|
+
- `--token` is what gates access once you bind past loopback, and is compared in constant
|
|
146
|
+
time. The origin check cannot cover for it there: the hostname is then your own and
|
|
147
|
+
unguessable to the daemon, so `Host` goes unpinned and a rebound name matches it. That
|
|
148
|
+
is why a token is required rather than recommended off loopback.
|
|
149
|
+
- The directory picker (`/api/fs`) browses your home directory and the roots of projects
|
|
150
|
+
you have already created. `--fs-root <path>` adds another — useful if your projects
|
|
151
|
+
live somewhere like `D:\work`. Paths are resolved through symlinks before the check, so
|
|
152
|
+
a link inside a root is not a way back out of it.
|
|
153
|
+
|
|
119
154
|
## Install it as an app
|
|
120
155
|
|
|
121
156
|
tring is a progressive web app. Once it is open in a browser, install it and it gets its
|
|
@@ -174,18 +209,9 @@ Browsers reserve `Ctrl+1`–`Ctrl+8` for tab switching, so `Shift+digit` is the
|
|
|
174
209
|
fallback that always works in an ordinary tab. Clicking a thumbnail also focuses it,
|
|
175
210
|
and right-clicking one opens the same dialog `r` does.
|
|
176
211
|
|
|
177
|
-
Those are picker keys. Everything else you type goes to the focused session, with one
|
|
178
|
-
exception: **`Ctrl+Enter` and `Shift+Enter` insert a newline** instead of submitting.
|
|
179
|
-
A terminal has no modifier bits for Enter — every variant is a bare `\r` on the wire —
|
|
180
|
-
so tring sends `ESC`+`CR` for those two chords, which is what Claude Code and other
|
|
181
|
-
agent CLIs read as "break the line". Native terminals need `/terminal-setup` to do the
|
|
182
|
-
same thing; here it works out of the box.
|
|
183
|
-
|
|
184
212
|
## Naming and colouring tiles
|
|
185
213
|
|
|
186
214
|
Right-click a tile — or press `r` in the picker — to give it a name and a colour.
|
|
187
|
-
The same dialog has a **Delete** button, which kills the session and frees the slot
|
|
188
|
-
back to empty; `x` in the picker does the same thing.
|
|
189
215
|
|
|
190
216
|
The colour is a ring *outside* the status border, never instead of it, so a tile you
|
|
191
217
|
have tinted still reports whether it is busy, finished or dead. Twenty-four choices:
|
package/dist/tring.js
CHANGED
|
@@ -12,10 +12,10 @@ var DEFAULT_PORT = 7331;
|
|
|
12
12
|
var DEFAULT_HOST = "127.0.0.1";
|
|
13
13
|
var DEFAULT_SCROLLBACK = 5e3;
|
|
14
14
|
function encodeOutput(id, data) {
|
|
15
|
-
const
|
|
16
|
-
const out = new Uint8Array(
|
|
17
|
-
out.set(
|
|
18
|
-
out.set(data,
|
|
15
|
+
const head2 = new TextEncoder().encode(id + "\0");
|
|
16
|
+
const out = new Uint8Array(head2.length + data.length);
|
|
17
|
+
out.set(head2, 0);
|
|
18
|
+
out.set(data, head2.length);
|
|
19
19
|
return out;
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -148,14 +148,14 @@ function snapshot(term) {
|
|
|
148
148
|
const cell = line.getCell(x);
|
|
149
149
|
if (!cell) break;
|
|
150
150
|
if (cell.getWidth() === 0) continue;
|
|
151
|
-
const
|
|
151
|
+
const text2 = cell.getChars() || " ";
|
|
152
152
|
const fg = cell.isFgDefault() ? -1 : cell.getFgColor();
|
|
153
153
|
const bg = cell.isBgDefault() ? -1 : cell.getBgColor();
|
|
154
154
|
const bold = cell.isBold() !== 0;
|
|
155
155
|
if (run && run.fg === fg && run.bg === bg && run.bold === bold) {
|
|
156
|
-
run.text +=
|
|
156
|
+
run.text += text2;
|
|
157
157
|
} else {
|
|
158
|
-
run = { text, fg, bg, bold };
|
|
158
|
+
run = { text: text2, fg, bg, bold };
|
|
159
159
|
out.push(run);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
@@ -732,10 +732,80 @@ var ProjectManager = class _ProjectManager {
|
|
|
732
732
|
|
|
733
733
|
// src/http.ts
|
|
734
734
|
import { createReadStream } from "node:fs";
|
|
735
|
-
import {
|
|
735
|
+
import { readdir as readdir2, realpath, stat as stat2 } from "node:fs/promises";
|
|
736
736
|
import os3 from "node:os";
|
|
737
737
|
import path3 from "node:path";
|
|
738
738
|
|
|
739
|
+
// src/security.ts
|
|
740
|
+
import { createHash, timingSafeEqual } from "node:crypto";
|
|
741
|
+
var LOOPBACK = /^(localhost|127(?:\.\d{1,3}){3}|\[::1\]|::1)$/i;
|
|
742
|
+
function hostname(host) {
|
|
743
|
+
return (/^(\[[^\]]*\]|[^:]*)/.exec(host)?.[1] ?? host).toLowerCase();
|
|
744
|
+
}
|
|
745
|
+
function isLoopbackBind(host) {
|
|
746
|
+
return !host || LOOPBACK.test(host);
|
|
747
|
+
}
|
|
748
|
+
function bindNeedsToken(host, token) {
|
|
749
|
+
return !isLoopbackBind(host) && !token;
|
|
750
|
+
}
|
|
751
|
+
function originHost(origin) {
|
|
752
|
+
try {
|
|
753
|
+
const u = new URL(origin);
|
|
754
|
+
return u.protocol === "http:" || u.protocol === "https:" ? u.host.toLowerCase() : null;
|
|
755
|
+
} catch {
|
|
756
|
+
return null;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
function createOriginCheck(opts = {}) {
|
|
760
|
+
const allow = new Set(
|
|
761
|
+
(opts.allow ?? []).map((o) => originHost(o.trim())).filter((o) => o !== null)
|
|
762
|
+
);
|
|
763
|
+
const pinned = isLoopbackBind(opts.host);
|
|
764
|
+
return function sameOrigin(req) {
|
|
765
|
+
const host = req.headers.host?.toLowerCase();
|
|
766
|
+
if (pinned && (!host || !LOOPBACK.test(hostname(host)))) return false;
|
|
767
|
+
const origin = req.headers.origin;
|
|
768
|
+
if (!origin) return true;
|
|
769
|
+
const from = originHost(origin);
|
|
770
|
+
return from !== null && (from === host || allow.has(from));
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
var upgradeGuard = (check) => ({ req }) => check(req);
|
|
774
|
+
function secretEquals(a, b) {
|
|
775
|
+
if (typeof a !== "string" || typeof b !== "string") return false;
|
|
776
|
+
const digest = (s) => createHash("sha256").update(s, "utf8").digest();
|
|
777
|
+
return timingSafeEqual(digest(a), digest(b));
|
|
778
|
+
}
|
|
779
|
+
function bearerEquals(token, header) {
|
|
780
|
+
const match = header ? /^bearer +(.*)$/i.exec(header) : null;
|
|
781
|
+
return secretEquals(token, match?.[1] ?? null);
|
|
782
|
+
}
|
|
783
|
+
var SECURITY_HEADERS = Object.freeze({
|
|
784
|
+
"content-security-policy": [
|
|
785
|
+
"default-src 'self'",
|
|
786
|
+
"script-src 'self'",
|
|
787
|
+
// xterm writes a <style> element of its own for terminal metrics.
|
|
788
|
+
"style-src 'self' 'unsafe-inline'",
|
|
789
|
+
"img-src 'self' data:",
|
|
790
|
+
// the favicon is an inline SVG
|
|
791
|
+
"font-src 'self'",
|
|
792
|
+
"connect-src 'self'",
|
|
793
|
+
// ws:// to this same host is 'self' under CSP 3
|
|
794
|
+
"worker-src 'self'",
|
|
795
|
+
// the PWA service worker
|
|
796
|
+
"manifest-src 'self'",
|
|
797
|
+
"base-uri 'none'",
|
|
798
|
+
"object-src 'none'",
|
|
799
|
+
"form-action 'none'",
|
|
800
|
+
"frame-ancestors 'none'"
|
|
801
|
+
].join("; "),
|
|
802
|
+
"x-content-type-options": "nosniff",
|
|
803
|
+
"x-frame-options": "DENY",
|
|
804
|
+
"referrer-policy": "no-referrer",
|
|
805
|
+
"cross-origin-opener-policy": "same-origin",
|
|
806
|
+
"cross-origin-resource-policy": "same-origin"
|
|
807
|
+
});
|
|
808
|
+
|
|
739
809
|
// src/usage.ts
|
|
740
810
|
import { spawn as spawn2 } from "node:child_process";
|
|
741
811
|
import { readdir, readFile as readFile2, stat } from "node:fs/promises";
|
|
@@ -771,13 +841,13 @@ async function scanUsage(dir, now) {
|
|
|
771
841
|
const entries = [];
|
|
772
842
|
const weekAgo = now - WEEK_MS;
|
|
773
843
|
for (const file of await transcripts(dir, weekAgo)) {
|
|
774
|
-
let
|
|
844
|
+
let text2;
|
|
775
845
|
try {
|
|
776
|
-
|
|
846
|
+
text2 = await readFile2(file, "utf8");
|
|
777
847
|
} catch {
|
|
778
848
|
continue;
|
|
779
849
|
}
|
|
780
|
-
for (const line of
|
|
850
|
+
for (const line of text2.split("\n")) {
|
|
781
851
|
if (!line.includes('"usage"')) continue;
|
|
782
852
|
let rec;
|
|
783
853
|
try {
|
|
@@ -870,9 +940,9 @@ async function transcripts(dir, since) {
|
|
|
870
940
|
return out;
|
|
871
941
|
}
|
|
872
942
|
var LIMIT_LINE = /^Current ([^:]+):\s*(\d+)%\s*used(?:\s*·\s*resets\s*(.+?))?\s*$/;
|
|
873
|
-
function parseLimits(
|
|
943
|
+
function parseLimits(text2) {
|
|
874
944
|
const out = [];
|
|
875
|
-
for (const line of
|
|
945
|
+
for (const line of text2.split("\n")) {
|
|
876
946
|
const m = LIMIT_LINE.exec(line.trim());
|
|
877
947
|
if (!m) continue;
|
|
878
948
|
const label = m[1].trim();
|
|
@@ -952,10 +1022,16 @@ var MIME = {
|
|
|
952
1022
|
// Browsers refuse to install a PWA whose manifest is served as anything else.
|
|
953
1023
|
".webmanifest": "application/manifest+json"
|
|
954
1024
|
};
|
|
1025
|
+
var head = (res, code, type) => {
|
|
1026
|
+
res.writeHead(code, { ...SECURITY_HEADERS, "content-type": type });
|
|
1027
|
+
};
|
|
955
1028
|
var json = (res, code, body) => {
|
|
956
|
-
|
|
957
|
-
res.
|
|
958
|
-
|
|
1029
|
+
head(res, code, "application/json; charset=utf-8");
|
|
1030
|
+
res.end(JSON.stringify(body));
|
|
1031
|
+
};
|
|
1032
|
+
var text = (res, code, body) => {
|
|
1033
|
+
head(res, code, "text/plain; charset=utf-8");
|
|
1034
|
+
res.end(body);
|
|
959
1035
|
};
|
|
960
1036
|
var readBody = (req) => new Promise((resolve) => {
|
|
961
1037
|
let data = "";
|
|
@@ -965,30 +1041,33 @@ var readBody = (req) => new Promise((resolve) => {
|
|
|
965
1041
|
});
|
|
966
1042
|
req.on("end", () => resolve(data));
|
|
967
1043
|
});
|
|
968
|
-
var DROP_MAX = 25e6;
|
|
969
|
-
var readRaw = (req, cap) => new Promise((resolve, reject) => {
|
|
970
|
-
const parts = [];
|
|
971
|
-
let size = 0;
|
|
972
|
-
req.on("data", (c) => {
|
|
973
|
-
size += c.length;
|
|
974
|
-
if (size > cap) {
|
|
975
|
-
req.destroy();
|
|
976
|
-
reject(new Error("too large"));
|
|
977
|
-
return;
|
|
978
|
-
}
|
|
979
|
-
parts.push(c);
|
|
980
|
-
});
|
|
981
|
-
req.on("end", () => resolve(Buffer.concat(parts)));
|
|
982
|
-
req.on("error", reject);
|
|
983
|
-
});
|
|
984
1044
|
var USAGE_CACHE_MS = 3e4;
|
|
985
1045
|
function createHandler(opts) {
|
|
986
1046
|
const { pm, webRoot, token } = opts;
|
|
1047
|
+
const sameOrigin = opts.sameOrigin ?? createOriginCheck();
|
|
987
1048
|
let usage = null;
|
|
1049
|
+
const homeDir = () => process.env["HOME"] ?? os3.homedir();
|
|
1050
|
+
const within = (root, dir) => {
|
|
1051
|
+
const rel = path3.relative(path3.resolve(root), dir);
|
|
1052
|
+
return rel === "" || !rel.startsWith("..") && !path3.isAbsolute(rel);
|
|
1053
|
+
};
|
|
1054
|
+
const real = async (p) => {
|
|
1055
|
+
try {
|
|
1056
|
+
return await realpath(p);
|
|
1057
|
+
} catch {
|
|
1058
|
+
return path3.resolve(p);
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
const browsable = async (dir) => {
|
|
1062
|
+
const roots = [homeDir(), ...pm.list().map((p) => p.root), ...opts.fsRoots ?? []];
|
|
1063
|
+
const [target, ...resolved] = await Promise.all([dir, ...roots].map(real));
|
|
1064
|
+
return resolved.some((root) => within(root, target));
|
|
1065
|
+
};
|
|
988
1066
|
return async function handle(req, res) {
|
|
989
1067
|
const url = new URL(req.url ?? "/", "http://localhost");
|
|
1068
|
+
if (!sameOrigin(req)) return text(res, 403, "forbidden origin");
|
|
990
1069
|
if (url.pathname.startsWith("/api/")) {
|
|
991
|
-
if (token && req.headers.authorization
|
|
1070
|
+
if (token && !bearerEquals(token, req.headers.authorization)) {
|
|
992
1071
|
return json(res, 401, { error: "unauthorized" });
|
|
993
1072
|
}
|
|
994
1073
|
return await api(req, res, url);
|
|
@@ -1020,12 +1099,14 @@ function createHandler(opts) {
|
|
|
1020
1099
|
}
|
|
1021
1100
|
if (url.pathname === "/api/fs" && req.method === "GET") {
|
|
1022
1101
|
const raw = url.searchParams.get("path")?.trim();
|
|
1023
|
-
const dir = raw ? path3.resolve(raw) :
|
|
1102
|
+
const dir = raw ? path3.resolve(raw) : homeDir();
|
|
1103
|
+
if (!await browsable(dir)) return json(res, 403, { error: "outside the browsable roots" });
|
|
1024
1104
|
try {
|
|
1025
1105
|
const found = await readdir2(dir, { withFileTypes: true });
|
|
1026
1106
|
const entries = found.filter((e) => (e.isDirectory() || e.isSymbolicLink()) && !e.name.startsWith(".")).map((e) => ({ name: e.name, path: path3.join(dir, e.name) })).sort((a, b) => a.name.localeCompare(b.name));
|
|
1027
1107
|
const parent = path3.dirname(dir);
|
|
1028
|
-
|
|
1108
|
+
const up = parent !== dir && await browsable(parent) ? parent : null;
|
|
1109
|
+
return json(res, 200, { path: dir, parent: up, entries });
|
|
1029
1110
|
} catch {
|
|
1030
1111
|
return json(res, 400, { error: `cannot read ${dir}` });
|
|
1031
1112
|
}
|
|
@@ -1042,24 +1123,6 @@ function createHandler(opts) {
|
|
|
1042
1123
|
return json(res, 500, { error: "cannot read Claude Code transcripts" });
|
|
1043
1124
|
}
|
|
1044
1125
|
}
|
|
1045
|
-
if (url.pathname === "/api/drop" && req.method === "POST") {
|
|
1046
|
-
const safe = (url.searchParams.get("name") ?? "").replace(/[^\w.-]+/g, "_").slice(0, 80);
|
|
1047
|
-
const dir = path3.join(os3.tmpdir(), "tring-drops");
|
|
1048
|
-
if (Number(req.headers["content-length"] ?? 0) > DROP_MAX) {
|
|
1049
|
-
json(res, 413, { error: `file is bigger than ${DROP_MAX / 1e6}MB` });
|
|
1050
|
-
req.resume();
|
|
1051
|
-
return;
|
|
1052
|
-
}
|
|
1053
|
-
try {
|
|
1054
|
-
const bytes = await readRaw(req, DROP_MAX);
|
|
1055
|
-
await mkdir2(dir, { recursive: true });
|
|
1056
|
-
const file = path3.join(dir, `${Date.now().toString(36)}-${safe || "file"}`);
|
|
1057
|
-
await writeFile2(file, bytes);
|
|
1058
|
-
return json(res, 200, { path: file });
|
|
1059
|
-
} catch {
|
|
1060
|
-
return json(res, 413, { error: `file is bigger than ${DROP_MAX / 1e6}MB` });
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
1126
|
if (url.pathname === "/api/sessions" && req.method === "GET") {
|
|
1064
1127
|
const sessions = pm.list().flatMap(
|
|
1065
1128
|
(p) => p.sessions.map((s) => ({ ...s, project: p.name }))
|
|
@@ -1072,21 +1135,21 @@ function createHandler(opts) {
|
|
|
1072
1135
|
const rel = pathname === "/" ? "index.html" : pathname.replace(/^\/+/, "");
|
|
1073
1136
|
const file = path3.resolve(webRoot, rel);
|
|
1074
1137
|
if (file !== webRoot && !file.startsWith(webRoot + path3.sep)) {
|
|
1075
|
-
res
|
|
1138
|
+
text(res, 403, "forbidden");
|
|
1076
1139
|
return;
|
|
1077
1140
|
}
|
|
1078
1141
|
try {
|
|
1079
1142
|
const info = await stat2(file);
|
|
1080
1143
|
if (!info.isFile()) throw new Error("not a file");
|
|
1081
|
-
res
|
|
1144
|
+
head(res, 200, MIME[path3.extname(file)] ?? "application/octet-stream");
|
|
1082
1145
|
createReadStream(file).pipe(res);
|
|
1083
1146
|
} catch {
|
|
1084
1147
|
if (rel === "index.html") {
|
|
1085
|
-
res
|
|
1148
|
+
head(res, 200, MIME[".html"]);
|
|
1086
1149
|
res.end('<!doctype html><meta charset="utf-8"><title>tring</title><body style="font:14px ui-monospace,monospace;background:#040c0a;color:#dceee7;padding:2rem"><p>Daemon is running. The web bundle is not built yet.</p><p style="color:#8aa79d">Run <code>npm run build -w @tring/web</code>.</p>');
|
|
1087
1150
|
return;
|
|
1088
1151
|
}
|
|
1089
|
-
res
|
|
1152
|
+
text(res, 404, "not found");
|
|
1090
1153
|
}
|
|
1091
1154
|
}
|
|
1092
1155
|
}
|
|
@@ -1145,7 +1208,7 @@ var Hub = class {
|
|
|
1145
1208
|
handle(c, msg) {
|
|
1146
1209
|
const pm = this.opts.pm;
|
|
1147
1210
|
if (msg.type === "hello") {
|
|
1148
|
-
if (this.opts.token &&
|
|
1211
|
+
if (this.opts.token && !secretEquals(this.opts.token, msg.token)) {
|
|
1149
1212
|
this.send(c, { type: "error", message: "unauthorized" });
|
|
1150
1213
|
c.ws.close();
|
|
1151
1214
|
return;
|
|
@@ -1371,7 +1434,7 @@ function describeFallback(url) {
|
|
|
1371
1434
|
|
|
1372
1435
|
// src/update-check.ts
|
|
1373
1436
|
import { createRequire as createRequire2 } from "node:module";
|
|
1374
|
-
import { mkdir as
|
|
1437
|
+
import { mkdir as mkdir2, readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
|
|
1375
1438
|
import path4 from "node:path";
|
|
1376
1439
|
var require3 = createRequire2(import.meta.url);
|
|
1377
1440
|
function currentVersion() {
|
|
@@ -1417,14 +1480,15 @@ async function checkForUpdate(cachePath) {
|
|
|
1417
1480
|
return null;
|
|
1418
1481
|
}
|
|
1419
1482
|
try {
|
|
1420
|
-
await
|
|
1421
|
-
await
|
|
1483
|
+
await mkdir2(path4.dirname(cachePath), { recursive: true });
|
|
1484
|
+
await writeFile2(cachePath, JSON.stringify({ checkedAt: Date.now(), latest }), "utf8");
|
|
1422
1485
|
} catch {
|
|
1423
1486
|
}
|
|
1424
1487
|
return isNewer(latest, current) ? latest : null;
|
|
1425
1488
|
}
|
|
1426
1489
|
|
|
1427
1490
|
// src/index.ts
|
|
1491
|
+
var listOf = (value) => (value ?? "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
1428
1492
|
function parseArgs(argv) {
|
|
1429
1493
|
const args = {
|
|
1430
1494
|
port: Number(process.env["TRING_PORT"] ?? DEFAULT_PORT),
|
|
@@ -1434,7 +1498,10 @@ function parseArgs(argv) {
|
|
|
1434
1498
|
idleMs: DEFAULT_IDLE_MS,
|
|
1435
1499
|
open: !process.env["TRING_NO_OPEN"],
|
|
1436
1500
|
shell: process.env["TRING_SHELL"] ?? null,
|
|
1437
|
-
updateCheck: !process.env["TRING_NO_UPDATE_CHECK"]
|
|
1501
|
+
updateCheck: !process.env["TRING_NO_UPDATE_CHECK"],
|
|
1502
|
+
allowOrigin: listOf(process.env["TRING_ALLOW_ORIGIN"]),
|
|
1503
|
+
fsRoot: listOf(process.env["TRING_FS_ROOT"]),
|
|
1504
|
+
insecureNoToken: !!process.env["TRING_INSECURE_NO_TOKEN"]
|
|
1438
1505
|
};
|
|
1439
1506
|
for (let i = 0; i < argv.length; i++) {
|
|
1440
1507
|
const [flag, inline] = argv[i].split("=", 2);
|
|
@@ -1458,6 +1525,16 @@ function parseArgs(argv) {
|
|
|
1458
1525
|
case "--shell":
|
|
1459
1526
|
args.shell = String(value);
|
|
1460
1527
|
break;
|
|
1528
|
+
case "--allow-origin":
|
|
1529
|
+
args.allowOrigin.push(...listOf(String(value)));
|
|
1530
|
+
break;
|
|
1531
|
+
case "--fs-root":
|
|
1532
|
+
args.fsRoot.push(...listOf(String(value)));
|
|
1533
|
+
break;
|
|
1534
|
+
case "--insecure-no-token":
|
|
1535
|
+
args.insecureNoToken = true;
|
|
1536
|
+
i--;
|
|
1537
|
+
break;
|
|
1461
1538
|
case "--no-open":
|
|
1462
1539
|
args.open = false;
|
|
1463
1540
|
i--;
|
|
@@ -1479,6 +1556,17 @@ function parseArgs(argv) {
|
|
|
1479
1556
|
--idle-ms <n> quiet period before a session is done, default ${DEFAULT_IDLE_MS}
|
|
1480
1557
|
--shell <path> shell to spawn; default $SHELL, or powershell.exe on
|
|
1481
1558
|
Windows. Use --shell wsl.exe for WSL shells from Windows
|
|
1559
|
+
--fs-root <path> extra directory the project picker may browse; repeatable.
|
|
1560
|
+
Home and existing project roots are always browsable
|
|
1561
|
+
--allow-origin <o> extra browser origin allowed to reach the daemon;
|
|
1562
|
+
repeatable. Only the page the daemon serves is allowed by
|
|
1563
|
+
default, which is what stops any website you visit from
|
|
1564
|
+
opening a socket to it
|
|
1565
|
+
--insecure-no-token
|
|
1566
|
+
bind off localhost with no --token anyway. The daemon
|
|
1567
|
+
spawns shells, so this hands one to everything that can
|
|
1568
|
+
reach the port, and to any site that can rebind a name
|
|
1569
|
+
to it. Only for a network you already trust that far
|
|
1482
1570
|
--no-open do not launch a browser window
|
|
1483
1571
|
--no-update-check do not ask npm whether a newer tring exists
|
|
1484
1572
|
--version print the version and exit`);
|
|
@@ -1489,6 +1577,17 @@ function parseArgs(argv) {
|
|
|
1489
1577
|
}
|
|
1490
1578
|
async function main() {
|
|
1491
1579
|
const args = parseArgs(process.argv.slice(2));
|
|
1580
|
+
if (bindNeedsToken(args.host, args.token) && !args.insecureNoToken) {
|
|
1581
|
+
console.error(`refusing to bind ${args.host} without --token.
|
|
1582
|
+
|
|
1583
|
+
The daemon spawns shells, so off localhost the token is the only thing
|
|
1584
|
+
between the port and a shell on this machine.
|
|
1585
|
+
|
|
1586
|
+
tring --host ${args.host} --token "$(openssl rand -hex 32)"
|
|
1587
|
+
|
|
1588
|
+
Pass --insecure-no-token if the network is already trusted that far.`);
|
|
1589
|
+
process.exit(1);
|
|
1590
|
+
}
|
|
1492
1591
|
const url = `http://${args.host}:${args.port}`;
|
|
1493
1592
|
const here = path5.dirname(fileURLToPath(import.meta.url));
|
|
1494
1593
|
const webRoot = [
|
|
@@ -1501,19 +1600,26 @@ async function main() {
|
|
|
1501
1600
|
idleMs: args.idleMs,
|
|
1502
1601
|
...args.shell ? { shell: args.shell } : {}
|
|
1503
1602
|
});
|
|
1504
|
-
const
|
|
1603
|
+
const sameOrigin = createOriginCheck({ host: args.host, allow: args.allowOrigin });
|
|
1604
|
+
const handle = createHandler({
|
|
1605
|
+
pm,
|
|
1606
|
+
webRoot,
|
|
1607
|
+
token: args.token,
|
|
1608
|
+
sameOrigin,
|
|
1609
|
+
fsRoots: args.fsRoot
|
|
1610
|
+
});
|
|
1505
1611
|
const server = createServer((req, res) => {
|
|
1506
1612
|
void handle(req, res).catch(() => {
|
|
1507
|
-
if (!res.headersSent) res.writeHead(500).end("internal error");
|
|
1613
|
+
if (!res.headersSent) res.writeHead(500, SECURITY_HEADERS).end("internal error");
|
|
1508
1614
|
});
|
|
1509
1615
|
});
|
|
1510
|
-
const wss = new WebSocketServer({ server });
|
|
1616
|
+
const wss = new WebSocketServer({ server, verifyClient: upgradeGuard(sameOrigin) });
|
|
1511
1617
|
const hub = new Hub({ pm, token: args.token });
|
|
1512
1618
|
hub.attach(wss);
|
|
1513
1619
|
server.listen(args.port, args.host, () => {
|
|
1514
1620
|
console.log(`tring listening on ${url}`);
|
|
1515
|
-
if (
|
|
1516
|
-
console.warn(
|
|
1621
|
+
if (bindNeedsToken(args.host, args.token)) {
|
|
1622
|
+
console.warn(`warning: bound off localhost with no token \u2014 anything that can reach ${args.host}:${args.port} can open a shell here`);
|
|
1517
1623
|
}
|
|
1518
1624
|
if (args.updateCheck) {
|
|
1519
1625
|
void checkForUpdate(path5.join(path5.dirname(pm.statePath), "update-check.json")).then((latest) => {
|
|
@@ -29,4 +29,4 @@
|
|
|
29
29
|
* The original design remains. The terminal itself
|
|
30
30
|
* has been extended to include xterm CSI codes, among
|
|
31
31
|
* other features.
|
|
32
|
-
*/.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm .xterm-scroll-area{visibility:hidden}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{-webkit-user-select:text;user-select:text;white-space:pre}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}:root{--bg: #040c0a;--bg-2: #071411;--panel: rgba(255, 255, 255, .028);--panel-2: rgba(255, 255, 255, .05);--line: rgba(110, 240, 195, .11);--line-2: rgba(110, 240, 195, .2);--text: #dceee7;--muted: #8aa79d;--dim: #5d7a71;--mint: #3ee9a4;--emerald: #0fae7c;--deep: #0a3a2e;--amber: #f5b642;--red: #f2545b;--mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;--sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;--bar-h: 36px;color-scheme:dark}.st-idle{--status: var(--dim)}.st-busy{--status: var(--amber)}.st-done{--status: var(--mint)}.st-exited{--status: var(--red)}*{box-sizing:border-box}[hidden]{display:none!important}html,body,#app{height:100%;margin:0}body{background:var(--bg);color:var(--text);font-family:var(--sans);font-size:13px;overflow:hidden}#app{display:flex;flex-direction:column}#bar{height:var(--bar-h);flex:0 0 var(--bar-h);display:flex;align-items:stretch;gap:4px;padding:0 8px;background:var(--bg-2);border-bottom:1px solid var(--line);overflow-x:auto;overflow-y:hidden;scrollbar-width:thin}.logo{display:grid;grid-template:repeat(3,5px) / repeat(3,5px);gap:2px;width:19px;height:19px;flex:0 0 19px;align-self:center;margin-right:8px}.logo i{background:var(--deep);border-radius:1px}.logo i:nth-child(5){background:var(--mint);box-shadow:0 0 6px #3ee9a499}.tab{display:flex;align-items:center;gap:7px;padding:0 12px;min-width:92px;max-width:220px;border:none;border-bottom:2px solid transparent;background:transparent;color:var(--muted);font:inherit;white-space:nowrap;cursor:pointer}.tab:hover{color:var(--text);background:var(--panel)}.tab.active{color:var(--text);border-bottom-color:var(--emerald)}.tab .nm{overflow:hidden;text-overflow:ellipsis}.badge{flex:0 0 auto;min-width:17px;padding:1px 5px;border-radius:9px;background:var(--mint);color:#04231a;font:600 10px/1.5 var(--mono);text-align:center}.add{flex:0 0 28px;border:none;background:transparent;color:var(--dim);font-size:18px;cursor:pointer}.add:hover{color:var(--mint)}#ring{flex:1;min-height:0;display:grid;grid-template-columns:repeat(5,1fr);grid-template-rows:repeat(5,1fr);gap:6px;padding:6px}.focus-cell{grid-area:2 / 2 / 5 / 5;min-width:0;min-height:0;border:1px solid var(--line-2);border-radius:6px;background:var(--bg);overflow:hidden;padding:4px}.focus-cell .xterm{height:100%}.tile{position:relative;min-width:0;min-height:0;container-type:size;border:2px solid var(--status, var(--line));border-radius:5px;background:var(--bg-2);overflow:hidden;cursor:pointer;padding:0;font:inherit;color:inherit;text-align:left}.tile canvas{display:block;width:100%;height:100%;transition:opacity .3s,filter .3s}.tile .label{position:absolute;top:0;right:0;bottom:0;left:0;display:grid;place-content:center;justify-items:center;gap:4px;padding:0 8%;pointer-events:none;text-align:center}.tile .big-nm{font:600 clamp(12px,9cqw,34px)/1.15 var(--sans);color:var(--text);opacity:.6;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-shadow:0 1px 4px rgba(4,12,10,.9);transition:opacity .3s,filter .3s}.tile .slot-badge{display:none;width:clamp(26px,22cqh,64px);aspect-ratio:1;border-radius:50%;place-items:center;background:var(--mint);color:var(--bg);font:700 clamp(13px,11cqh,32px)/1 var(--mono);box-shadow:0 0 0 3px #040c0ad9,0 0 18px #3ee9a473}.tile.st-done .slot-badge{display:grid}.tile.st-busy canvas,.tile.st-busy .big-nm{opacity:.35;filter:grayscale(.8)}.tile.empty{border-style:dashed;border-color:var(--line);color:var(--dim);display:grid;place-items:center;font-size:11px}.tile.empty:hover{border-color:var(--emerald);color:var(--muted)}.tile.viewing{box-shadow:inset 0 0 0 1px var(--emerald)}.tile.st-busy{animation:pulse 1.4s ease-in-out infinite}@keyframes pulse{50%{border-color:#f5b64259}}.tile .meta{position:absolute;inset:auto 0 0 0;z-index:1;display:flex;gap:6px;align-items:baseline;padding:2px 5px;background:linear-gradient(transparent,#040c0aeb 45%);font:10px/1.4 var(--mono);pointer-events:none}.tile .key{color:var(--status, var(--dim));font-weight:700}.tile .nm{color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tile .cwd{color:var(--dim);margin-left:auto}#overlay{position:fixed;top:0;right:0;bottom:0;left:0;display:grid;place-items:center;background:#040c0ab8;-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);z-index:10}.panel{width:min(560px,92vw);max-height:82vh;overflow:auto;padding:16px;border:1px solid var(--line-2);border-radius:10px;background:var(--bg-2);box-shadow:0 24px 70px #0009}.panel h2{margin:0 0 4px;font-size:14px;font-weight:600}.panel .hint{margin:0 0 14px;color:var(--muted);font-size:11.5px}.rows{display:grid;gap:3px}.row{display:flex;gap:9px;align-items:baseline;padding:5px 8px;border-radius:5px;border-left:2px solid var(--status, transparent);background:var(--panel);font:12px/1.5 var(--mono);cursor:pointer}.row:hover{background:var(--panel-2)}.row.dim{opacity:.45}.row .key{color:var(--emerald);font-weight:700;min-width:76px}.row .nm{color:var(--text)}.row .tag{margin-left:auto;color:var(--status, var(--dim));font-size:11px}.field{display:block;margin-bottom:10px}.field span{display:block;margin-bottom:4px;color:var(--muted);font-size:11.5px}.field input{width:100%;padding:8px 10px;border:1px solid var(--line-2);border-radius:6px;background:var(--bg);color:var(--text);font:12.5px var(--mono)}.field input:focus{outline:none;border-color:var(--emerald)}.actions{display:flex;gap:8px;justify-content:flex-end;margin-top:14px}.btn{padding:7px 14px;border:1px solid var(--line-2);border-radius:6px;background:transparent;color:var(--text);font:inherit;cursor:pointer}.btn:hover{border-color:var(--emerald)}.btn.primary{background:var(--emerald);border-color:var(--emerald);color:#04231a;font-weight:600}.btn.primary:hover{background:var(--mint);border-color:var(--mint)}.legend{margin-top:14px;padding-top:10px;border-top:1px solid var(--line);color:var(--dim);font:11px/1.7 var(--mono)}.legend b{color:var(--muted);font-weight:600}#toast{position:fixed;left:50%;bottom:18px;transform:translate(-50%);padding:7px 14px;border:1px solid var(--red);border-radius:6px;background:var(--bg-2);color:var(--text);font:12px var(--mono);z-index:20}.browser{margin:-4px 0 12px;border:1px solid var(--line);border-radius:6px;background:var(--bg);overflow:hidden}.crumb{display:flex;padding:5px 8px;border-bottom:1px solid var(--line);font:11px var(--mono);color:var(--dim)}.crumb .up{border:none;background:transparent;color:var(--emerald);font:inherit;cursor:pointer;padding:0;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.crumb .up:hover{color:var(--mint)}.dirlist{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:1px;max-height:168px;overflow-y:auto;padding:5px}.dirlist button{border:none;border-radius:4px;background:transparent;color:var(--text);font:11.5px/1.9 var(--mono);text-align:left;padding:1px 7px;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dirlist button:before{content:"▸ ";color:var(--dim)}.dirlist button:hover{background:var(--panel-2);color:var(--mint)}.dirnote{padding:4px 7px;color:var(--dim);font:11px var(--mono)}.tile-action{position:absolute;top:4px;right:4px;width:20px;height:20px;display:grid;place-items:center;border:1px solid var(--status, var(--line-2));border-radius:4px;background:#040c0ad1;color:var(--status, var(--text));font:12px/1 var(--mono);cursor:pointer;opacity:0;transition:opacity .12s}.tile:hover .tile-action,.tile:focus-within .tile-action{opacity:1}.tile.st-exited .tile-action{opacity:1}.tile-action:hover{background:var(--deep);color:var(--mint);border-color:var(--mint)}.btn.danger{border-color:#f2545b80;color:var(--red)}.btn.danger:hover{background:#f2545b1f;border-color:var(--red)}.update{align-self:center;margin-left:auto;flex:0 0 auto;padding:3px 10px;border:1px solid var(--line-2);border-radius:10px;background:transparent;color:var(--muted);font:11px var(--mono);white-space:nowrap;cursor:pointer}.update:hover{border-color:var(--emerald);color:var(--text)}.cmd{margin:0 0 12px;padding:9px 11px;border:1px solid var(--line-2);border-radius:6px;background:var(--bg);color:var(--text);font:12.5px var(--mono);-webkit-user-select:all;user-select:all}.iconbtn{align-self:center;flex:0 0 auto;display:grid;place-items:center;width:26px;height:22px;margin-right:2px;border:1px solid transparent;border-radius:5px;background:transparent;color:var(--dim);cursor:pointer}.iconbtn:hover{color:var(--text);border-color:var(--line-2)}.iconbtn.on{color:var(--emerald)}.iconbtn.on:hover{color:var(--mint)}.choices{display:flex;gap:6px}.choice{flex:1;display:grid;gap:1px;padding:8px 4px;border:1px solid var(--line-2);border-radius:6px;background:transparent;color:var(--muted);font:inherit;cursor:pointer}.choice b{color:var(--text);font:700 15px/1.2 var(--mono)}.choice span{font-size:10.5px;color:var(--dim)}.choice:hover{border-color:var(--emerald);color:var(--text)}.choice.active{border-color:var(--emerald);background:var(--panel-2)}.choice.active b{color:var(--emerald)}.tile{outline:2px solid var(--tint, transparent)}.swatches{display:grid;grid-template-columns:repeat(auto-fill,24px);gap:6px}.swatch{width:24px;height:24px;padding:0;border:2px solid transparent;border-radius:50%;background:var(--tint, transparent);cursor:pointer;outline-offset:2px}.swatch.none{background:transparent;border-color:var(--line-2);position:relative}.swatch.none:after{content:"";position:absolute;top:3px;right:9px;bottom:3px;left:9px;border-top:1px solid var(--dim);transform:rotate(-45deg);transform-origin:center}.swatch:hover{outline:1px solid var(--line-2)}.swatch.active{outline:2px solid var(--text)}#usage{flex:1;min-height:0;overflow-y:auto;padding:18px;display:grid;place-items:start center}.usage{width:min(620px,100%);padding:18px 20px 16px;border:1px solid var(--line-2);border-radius:10px;background:var(--bg-2)}.usage h2{margin:0 0 4px;font-size:14px;font-weight:600}.usage h3{margin:20px 0 8px;font:600 11px/1.4 var(--sans);letter-spacing:.06em;text-transform:uppercase;color:var(--muted)}.usage .hint{margin:14px 0 0;color:var(--dim);font-size:11.5px}.usage .source{margin:12px 0 0;padding-top:10px;border-top:1px solid var(--line);color:var(--dim);font:11px var(--mono)}.urow+.urow{margin-top:16px}.uhead{display:flex;align-items:baseline;gap:8px}.ulabel{color:var(--text);font-size:12.5px}.upct{margin-left:auto;font:700 15px/1 var(--mono);color:var(--text)}.ufoot{display:flex;gap:8px;margin-top:4px;font:11px var(--mono);color:var(--muted)}.unote{margin-left:auto;color:var(--dim);font-style:normal}.meter{height:8px;margin-top:6px;border-radius:4px;background:var(--panel-2);overflow:hidden}.meter i{display:block;height:100%;background:var(--emerald)}.meter i.warm{background:var(--amber)}.meter i.hot{background:var(--red)}.utotals{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:1px;margin-top:20px;border:1px solid var(--line);border-radius:8px;overflow:hidden;background:var(--line)}.ucell{display:grid;gap:2px;padding:10px 12px;background:var(--bg-2)}.ucell b{font:700 15px/1.2 var(--mono);color:var(--text)}.ucell span{font-size:10.5px;color:var(--dim)}.uprojects{display:grid;gap:7px}.uproject{display:grid;grid-template-columns:128px 1fr 56px;gap:10px;align-items:center;font:11.5px var(--mono)}.uproject .nm{color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.uproject .meter{margin-top:0;height:6px}.uproject .tag{color:var(--text);text-align:right}.tab.pinned{min-width:0;color:var(--dim)}.tab.pinned.active{color:var(--text);border-bottom-color:var(--emerald)}.field.toggle{display:flex;align-items:center;gap:8px;margin:18px 0 10px;padding-top:14px;border-top:1px solid var(--line);cursor:pointer}.field.toggle span{margin:0;color:var(--text);font-size:12.5px}.field.toggle input{width:15px;height:15px;accent-color:var(--emerald)}#switcher{flex:0 0 auto;display:flex;gap:6px;padding:6px;background:var(--bg-2);border-bottom:1px solid var(--line)}#switcher button{height:44px;border:1px solid var(--line-2);border-radius:6px;background:var(--bg);color:var(--text);font:13px/1 var(--mono);cursor:pointer}#switcher .current{flex:1 1 auto;min-width:0;display:flex;align-items:center;gap:10px;padding:0 12px;border-left:3px solid var(--status, var(--line-2));text-align:left}#switcher .current .key{color:var(--emerald);font-weight:700}#switcher .current .nm{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#switcher .current .tag{color:var(--status, var(--dim));font-size:11px}#switcher .current .chev{display:grid;color:var(--muted)}#switcher .next{flex:0 0 64px;display:flex;align-items:center;justify-content:center;gap:6px;color:var(--muted)}#switcher .next:disabled{color:var(--dim);opacity:.5;cursor:default}#switcher .next svg{display:block}.picker-actions{display:none}@media (max-width: 720px){#ring{display:flex;flex-direction:column;padding:6px}#ring .tile{display:none}.focus-cell{flex:1 1 auto}#overlay{place-items:end stretch}.panel{width:100%;max-height:78vh;border-bottom:none;border-radius:10px 10px 0 0;padding-bottom:max(24px,env(safe-area-inset-bottom))}.panel.picker{display:flex;flex-direction:column}.panel.picker .rows{flex:1 1 auto;min-height:0;overflow:hidden auto}.row{min-height:44px;align-items:center;padding:0 12px;font-size:13px}.row .key{min-width:20px}.row .nm{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.row .tag{flex:0 0 auto}.btn:disabled{opacity:.45;cursor:default}.picker-actions{display:flex;gap:8px;margin-top:14px;padding-top:12px;border-top:1px solid var(--line)}.picker-actions .btn{flex:1 1 auto;height:44px}.legend,.ring-size{display:none}}body.dropping .focus-cell{border-color:var(--mint);box-shadow:inset 0 0 0 1px var(--mint)}
|
|
32
|
+
*/.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm .xterm-scroll-area{visibility:hidden}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{-webkit-user-select:text;user-select:text;white-space:pre}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}:root{--bg: #040c0a;--bg-2: #071411;--panel: rgba(255, 255, 255, .028);--panel-2: rgba(255, 255, 255, .05);--line: rgba(110, 240, 195, .11);--line-2: rgba(110, 240, 195, .2);--text: #dceee7;--muted: #8aa79d;--dim: #5d7a71;--mint: #3ee9a4;--emerald: #0fae7c;--deep: #0a3a2e;--amber: #f5b642;--red: #f2545b;--mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;--sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;--bar-h: 36px;color-scheme:dark}.st-idle{--status: var(--dim)}.st-busy{--status: var(--amber)}.st-done{--status: var(--mint)}.st-exited{--status: var(--red)}*{box-sizing:border-box}[hidden]{display:none!important}html,body,#app{height:100%;margin:0}body{background:var(--bg);color:var(--text);font-family:var(--sans);font-size:13px;overflow:hidden}#app{display:flex;flex-direction:column}#bar{height:var(--bar-h);flex:0 0 var(--bar-h);display:flex;align-items:stretch;gap:4px;padding:0 8px;background:var(--bg-2);border-bottom:1px solid var(--line);overflow-x:auto;overflow-y:hidden;scrollbar-width:thin}.logo{display:grid;grid-template:repeat(3,5px) / repeat(3,5px);gap:2px;width:19px;height:19px;flex:0 0 19px;align-self:center;margin-right:8px}.logo i{background:var(--deep);border-radius:1px}.logo i:nth-child(5){background:var(--mint);box-shadow:0 0 6px #3ee9a499}.tab{display:flex;align-items:center;gap:7px;padding:0 12px;min-width:92px;max-width:220px;border:none;border-bottom:2px solid transparent;background:transparent;color:var(--muted);font:inherit;white-space:nowrap;cursor:pointer}.tab:hover{color:var(--text);background:var(--panel)}.tab.active{color:var(--text);border-bottom-color:var(--emerald)}.tab .nm{overflow:hidden;text-overflow:ellipsis}.badge{flex:0 0 auto;min-width:17px;padding:1px 5px;border-radius:9px;background:var(--mint);color:#04231a;font:600 10px/1.5 var(--mono);text-align:center}.add{flex:0 0 28px;border:none;background:transparent;color:var(--dim);font-size:18px;cursor:pointer}.add:hover{color:var(--mint)}#ring{flex:1;min-height:0;display:grid;grid-template-columns:repeat(5,1fr);grid-template-rows:repeat(5,1fr);gap:6px;padding:6px}.focus-cell{grid-area:2 / 2 / 5 / 5;min-width:0;min-height:0;border:1px solid var(--line-2);border-radius:6px;background:var(--bg);overflow:hidden;padding:4px}.focus-cell .xterm{height:100%}.tile{position:relative;min-width:0;min-height:0;container-type:size;border:2px solid var(--status, var(--line));border-radius:5px;background:var(--bg-2);overflow:hidden;cursor:pointer;padding:0;font:inherit;color:inherit;text-align:left}.tile canvas{display:block;width:100%;height:100%;transition:opacity .3s,filter .3s}.tile .label{position:absolute;top:0;right:0;bottom:0;left:0;display:grid;place-content:center;justify-items:center;gap:4px;padding:0 8%;pointer-events:none;text-align:center}.tile .big-nm{font:600 clamp(12px,9cqw,34px)/1.15 var(--sans);color:var(--text);opacity:.6;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-shadow:0 1px 4px rgba(4,12,10,.9);transition:opacity .3s,filter .3s}.tile .slot-badge{display:none;width:clamp(26px,22cqh,64px);aspect-ratio:1;border-radius:50%;place-items:center;background:var(--mint);color:var(--bg);font:700 clamp(13px,11cqh,32px)/1 var(--mono);box-shadow:0 0 0 3px #040c0ad9,0 0 18px #3ee9a473}.tile.st-done .slot-badge{display:grid}.tile.st-busy canvas,.tile.st-busy .big-nm{opacity:.35;filter:grayscale(.8)}.tile.empty{border-style:dashed;border-color:var(--line);color:var(--dim);display:grid;place-items:center;font-size:11px}.tile.empty:hover{border-color:var(--emerald);color:var(--muted)}.tile.viewing{box-shadow:inset 0 0 0 1px var(--emerald)}.tile.st-busy{animation:pulse 1.4s ease-in-out infinite}@keyframes pulse{50%{border-color:#f5b64259}}.tile .meta{position:absolute;inset:auto 0 0 0;z-index:1;display:flex;gap:6px;align-items:baseline;padding:2px 5px;background:linear-gradient(transparent,#040c0aeb 45%);font:10px/1.4 var(--mono);pointer-events:none}.tile .key{color:var(--status, var(--dim));font-weight:700}.tile .nm{color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tile .cwd{color:var(--dim);margin-left:auto}#overlay{position:fixed;top:0;right:0;bottom:0;left:0;display:grid;place-items:center;background:#040c0ab8;-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);z-index:10}.panel{width:min(560px,92vw);max-height:82vh;overflow:auto;padding:16px;border:1px solid var(--line-2);border-radius:10px;background:var(--bg-2);box-shadow:0 24px 70px #0009}.panel h2{margin:0 0 4px;font-size:14px;font-weight:600}.panel .hint{margin:0 0 14px;color:var(--muted);font-size:11.5px}.rows{display:grid;gap:3px}.row{display:flex;gap:9px;align-items:baseline;padding:5px 8px;border-radius:5px;border-left:2px solid var(--status, transparent);background:var(--panel);font:12px/1.5 var(--mono);cursor:pointer}.row:hover{background:var(--panel-2)}.row.dim{opacity:.45}.row .key{color:var(--emerald);font-weight:700;min-width:76px}.row .nm{color:var(--text)}.row .tag{margin-left:auto;color:var(--status, var(--dim));font-size:11px}.field{display:block;margin-bottom:10px}.field span{display:block;margin-bottom:4px;color:var(--muted);font-size:11.5px}.field input{width:100%;padding:8px 10px;border:1px solid var(--line-2);border-radius:6px;background:var(--bg);color:var(--text);font:12.5px var(--mono)}.field input:focus{outline:none;border-color:var(--emerald)}.actions{display:flex;gap:8px;justify-content:flex-end;margin-top:14px}.btn{padding:7px 14px;border:1px solid var(--line-2);border-radius:6px;background:transparent;color:var(--text);font:inherit;cursor:pointer}.btn:hover{border-color:var(--emerald)}.btn.primary{background:var(--emerald);border-color:var(--emerald);color:#04231a;font-weight:600}.btn.primary:hover{background:var(--mint);border-color:var(--mint)}.legend{margin-top:14px;padding-top:10px;border-top:1px solid var(--line);color:var(--dim);font:11px/1.7 var(--mono)}.legend b{color:var(--muted);font-weight:600}#toast{position:fixed;left:50%;bottom:18px;transform:translate(-50%);padding:7px 14px;border:1px solid var(--red);border-radius:6px;background:var(--bg-2);color:var(--text);font:12px var(--mono);z-index:20}.browser{margin:-4px 0 12px;border:1px solid var(--line);border-radius:6px;background:var(--bg);overflow:hidden}.crumb{display:flex;padding:5px 8px;border-bottom:1px solid var(--line);font:11px var(--mono);color:var(--dim)}.crumb .up{border:none;background:transparent;color:var(--emerald);font:inherit;cursor:pointer;padding:0;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.crumb .up:hover{color:var(--mint)}.dirlist{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:1px;max-height:168px;overflow-y:auto;padding:5px}.dirlist button{border:none;border-radius:4px;background:transparent;color:var(--text);font:11.5px/1.9 var(--mono);text-align:left;padding:1px 7px;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dirlist button:before{content:"▸ ";color:var(--dim)}.dirlist button:hover{background:var(--panel-2);color:var(--mint)}.dirnote{padding:4px 7px;color:var(--dim);font:11px var(--mono)}.tile-action{position:absolute;top:4px;right:4px;width:20px;height:20px;display:grid;place-items:center;border:1px solid var(--status, var(--line-2));border-radius:4px;background:#040c0ad1;color:var(--status, var(--text));font:12px/1 var(--mono);cursor:pointer;opacity:0;transition:opacity .12s}.tile:hover .tile-action,.tile:focus-within .tile-action{opacity:1}.tile.st-exited .tile-action{opacity:1}.tile-action:hover{background:var(--deep);color:var(--mint);border-color:var(--mint)}.btn.danger{border-color:#f2545b80;color:var(--red)}.btn.danger:hover{background:#f2545b1f;border-color:var(--red)}.update{align-self:center;margin-left:auto;flex:0 0 auto;padding:3px 10px;border:1px solid var(--line-2);border-radius:10px;background:transparent;color:var(--muted);font:11px var(--mono);white-space:nowrap;cursor:pointer}.update:hover{border-color:var(--emerald);color:var(--text)}.cmd{margin:0 0 12px;padding:9px 11px;border:1px solid var(--line-2);border-radius:6px;background:var(--bg);color:var(--text);font:12.5px var(--mono);-webkit-user-select:all;user-select:all}.iconbtn{align-self:center;flex:0 0 auto;display:grid;place-items:center;width:26px;height:22px;margin-right:2px;border:1px solid transparent;border-radius:5px;background:transparent;color:var(--dim);cursor:pointer}.iconbtn:hover{color:var(--text);border-color:var(--line-2)}.iconbtn.on{color:var(--emerald)}.iconbtn.on:hover{color:var(--mint)}.choices{display:flex;gap:6px}.choice{flex:1;display:grid;gap:1px;padding:8px 4px;border:1px solid var(--line-2);border-radius:6px;background:transparent;color:var(--muted);font:inherit;cursor:pointer}.choice b{color:var(--text);font:700 15px/1.2 var(--mono)}.choice span{font-size:10.5px;color:var(--dim)}.choice:hover{border-color:var(--emerald);color:var(--text)}.choice.active{border-color:var(--emerald);background:var(--panel-2)}.choice.active b{color:var(--emerald)}.tile{outline:2px solid var(--tint, transparent)}.swatches{display:grid;grid-template-columns:repeat(auto-fill,24px);gap:6px}.swatch{width:24px;height:24px;padding:0;border:2px solid transparent;border-radius:50%;background:var(--tint, transparent);cursor:pointer;outline-offset:2px}.swatch.none{background:transparent;border-color:var(--line-2);position:relative}.swatch.none:after{content:"";position:absolute;top:3px;right:9px;bottom:3px;left:9px;border-top:1px solid var(--dim);transform:rotate(-45deg);transform-origin:center}.swatch:hover{outline:1px solid var(--line-2)}.swatch.active{outline:2px solid var(--text)}#usage{flex:1;min-height:0;overflow-y:auto;padding:18px;display:grid;place-items:start center}.usage{width:min(620px,100%);padding:18px 20px 16px;border:1px solid var(--line-2);border-radius:10px;background:var(--bg-2)}.usage h2{margin:0 0 4px;font-size:14px;font-weight:600}.usage h3{margin:20px 0 8px;font:600 11px/1.4 var(--sans);letter-spacing:.06em;text-transform:uppercase;color:var(--muted)}.usage .hint{margin:14px 0 0;color:var(--dim);font-size:11.5px}.usage .source{margin:12px 0 0;padding-top:10px;border-top:1px solid var(--line);color:var(--dim);font:11px var(--mono)}.urow+.urow{margin-top:16px}.uhead{display:flex;align-items:baseline;gap:8px}.ulabel{color:var(--text);font-size:12.5px}.upct{margin-left:auto;font:700 15px/1 var(--mono);color:var(--text)}.ufoot{display:flex;gap:8px;margin-top:4px;font:11px var(--mono);color:var(--muted)}.unote{margin-left:auto;color:var(--dim);font-style:normal}.meter{height:8px;margin-top:6px;border-radius:4px;background:var(--panel-2);overflow:hidden}.meter i{display:block;height:100%;background:var(--emerald)}.meter i.warm{background:var(--amber)}.meter i.hot{background:var(--red)}.utotals{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:1px;margin-top:20px;border:1px solid var(--line);border-radius:8px;overflow:hidden;background:var(--line)}.ucell{display:grid;gap:2px;padding:10px 12px;background:var(--bg-2)}.ucell b{font:700 15px/1.2 var(--mono);color:var(--text)}.ucell span{font-size:10.5px;color:var(--dim)}.uprojects{display:grid;gap:7px}.uproject{display:grid;grid-template-columns:128px 1fr 56px;gap:10px;align-items:center;font:11.5px var(--mono)}.uproject .nm{color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.uproject .meter{margin-top:0;height:6px}.uproject .tag{color:var(--text);text-align:right}.tab.pinned{min-width:0;color:var(--dim)}.tab.pinned.active{color:var(--text);border-bottom-color:var(--emerald)}.field.toggle{display:flex;align-items:center;gap:8px;margin:18px 0 10px;padding-top:14px;border-top:1px solid var(--line);cursor:pointer}.field.toggle span{margin:0;color:var(--text);font-size:12.5px}.field.toggle input{width:15px;height:15px;accent-color:var(--emerald)}#switcher{flex:0 0 auto;display:flex;gap:6px;padding:6px;background:var(--bg-2);border-bottom:1px solid var(--line)}#switcher button{height:44px;border:1px solid var(--line-2);border-radius:6px;background:var(--bg);color:var(--text);font:13px/1 var(--mono);cursor:pointer}#switcher .current{flex:1 1 auto;min-width:0;display:flex;align-items:center;gap:10px;padding:0 12px;border-left:3px solid var(--status, var(--line-2));text-align:left}#switcher .current .key{color:var(--emerald);font-weight:700}#switcher .current .nm{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#switcher .current .tag{color:var(--status, var(--dim));font-size:11px}#switcher .current .chev{display:grid;color:var(--muted)}#switcher .next{flex:0 0 64px;display:flex;align-items:center;justify-content:center;gap:6px;color:var(--muted)}#switcher .next:disabled{color:var(--dim);opacity:.5;cursor:default}#switcher .next svg{display:block}.picker-actions{display:none}@media (max-width: 720px){#ring{display:flex;flex-direction:column;padding:6px}#ring .tile{display:none}.focus-cell{flex:1 1 auto}#overlay{place-items:end stretch}.panel{width:100%;max-height:78vh;border-bottom:none;border-radius:10px 10px 0 0;padding-bottom:max(24px,env(safe-area-inset-bottom))}.panel.picker{display:flex;flex-direction:column}.panel.picker .rows{flex:1 1 auto;min-height:0;overflow:hidden auto}.row{min-height:44px;align-items:center;padding:0 12px;font-size:13px}.row .key{min-width:20px}.row .nm{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.row .tag{flex:0 0 auto}.btn:disabled{opacity:.45;cursor:default}.picker-actions{display:flex;gap:8px;margin-top:14px;padding-top:12px;border-top:1px solid var(--line)}.picker-actions .btn{flex:1 1 auto;height:44px}.legend,.ring-size{display:none}}
|