@monotykamary/localterm-server 0.0.15
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 +21 -0
- package/dist/constants.d.ts +44 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +80 -0
- package/dist/constants.js.map +1 -0
- package/dist/default-shell.d.ts +2 -0
- package/dist/default-shell.d.ts.map +1 -0
- package/dist/default-shell.js +44 -0
- package/dist/default-shell.js.map +1 -0
- package/dist/ensure-spawn-helper-executable.d.ts +2 -0
- package/dist/ensure-spawn-helper-executable.d.ts.map +1 -0
- package/dist/ensure-spawn-helper-executable.js +34 -0
- package/dist/ensure-spawn-helper-executable.js.map +1 -0
- package/dist/errors.d.ts +64 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +84 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +369 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +5 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +3 -0
- package/dist/protocol.js.map +1 -0
- package/dist/schemas.d.ts +36 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +73 -0
- package/dist/schemas.js.map +1 -0
- package/dist/security.d.ts +5 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +60 -0
- package/dist/security.js.map +1 -0
- package/dist/session-registry.d.ts +9 -0
- package/dist/session-registry.d.ts.map +1 -0
- package/dist/session-registry.js +19 -0
- package/dist/session-registry.js.map +1 -0
- package/dist/session.d.ts +61 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +245 -0
- package/dist/session.js.map +1 -0
- package/dist/static-resolver.d.ts +7 -0
- package/dist/static-resolver.d.ts.map +1 -0
- package/dist/static-resolver.js +64 -0
- package/dist/static-resolver.js.map +1 -0
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/format-working-directory-title.d.ts +2 -0
- package/dist/utils/format-working-directory-title.d.ts.map +1 -0
- package/dist/utils/format-working-directory-title.js +28 -0
- package/dist/utils/format-working-directory-title.js.map +1 -0
- package/dist/utils/parse-osc7.d.ts +2 -0
- package/dist/utils/parse-osc7.d.ts.map +1 -0
- package/dist/utils/parse-osc7.js +50 -0
- package/dist/utils/parse-osc7.js.map +1 -0
- package/dist/utils/resolve-cwd-for-pid.d.ts +2 -0
- package/dist/utils/resolve-cwd-for-pid.d.ts.map +1 -0
- package/dist/utils/resolve-cwd-for-pid.js +29 -0
- package/dist/utils/resolve-cwd-for-pid.js.map +1 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aiden Bai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare const DEFAULT_PORT = 3417;
|
|
2
|
+
export declare const DEFAULT_HOST = "0.0.0.0";
|
|
3
|
+
export declare const DEFAULT_COLS = 120;
|
|
4
|
+
export declare const DEFAULT_ROWS = 32;
|
|
5
|
+
export declare const DEFAULT_SHELL_FALLBACK = "/bin/sh";
|
|
6
|
+
export declare const TERM_TYPE = "xterm-256color";
|
|
7
|
+
export declare const COLORTERM_VALUE = "truecolor";
|
|
8
|
+
export declare const TITLE_POLL_INTERVAL_MS = 500;
|
|
9
|
+
export declare const CWD_RESOLVE_TIMEOUT_MS = 250;
|
|
10
|
+
export declare const CWD_RESOLVE_BACKOFF_MS = 30000;
|
|
11
|
+
export declare const CWD_RESOLVE_COOLDOWN_MS = 5000;
|
|
12
|
+
export declare const TITLE_MAX_PATH_SEGMENTS = 3;
|
|
13
|
+
export declare const TITLE_TRUNCATION_PREFIX = "\u2026";
|
|
14
|
+
/**
|
|
15
|
+
* Strip terminal-emulator identity env vars inherited from the daemon's parent.
|
|
16
|
+
* If we leak e.g. TERM_PROGRAM=ghostty, modern Ink-based TUIs (Cursor Agent,
|
|
17
|
+
* Claude Code) will probe for that terminal's protocol (kitty keyboard,
|
|
18
|
+
* XTQVERSION, XTGETTCAP, OSC 1337, etc.) and — when xterm.js doesn't answer —
|
|
19
|
+
* fall back to a degraded inline-plain rendering instead of the full boxed
|
|
20
|
+
* TUI. Removing these lets the TUI treat us as a generic xterm-256color and
|
|
21
|
+
* render normally.
|
|
22
|
+
*/
|
|
23
|
+
export declare const PTY_ENV_DENYLIST: string[];
|
|
24
|
+
export declare const MAX_INPUT_BYTES: number;
|
|
25
|
+
export declare const MAX_OUTPUT_BYTES: number;
|
|
26
|
+
export declare const MAX_FOREGROUND_LENGTH = 256;
|
|
27
|
+
export declare const MAX_TITLE_LENGTH: number;
|
|
28
|
+
export declare const MAX_COLS = 1000;
|
|
29
|
+
export declare const MAX_ROWS = 1000;
|
|
30
|
+
export declare const MAX_CONCURRENT_SESSIONS = 64;
|
|
31
|
+
export declare const WS_OUTBOUND_PAUSE_HIGH_WATER_BYTES: number;
|
|
32
|
+
export declare const WS_OUTBOUND_RESUME_LOW_WATER_BYTES: number;
|
|
33
|
+
export declare const WS_OUTBOUND_DRAIN_POLL_MS = 50;
|
|
34
|
+
export declare const WS_BACKPRESSURE_THRESHOLD_BYTES: number;
|
|
35
|
+
export declare const WS_HEARTBEAT_INTERVAL_MS = 20000;
|
|
36
|
+
export declare const WS_HEARTBEAT_TIMEOUT_MS = 60000;
|
|
37
|
+
export declare const SERVER_STOP_GRACE_MS = 1500;
|
|
38
|
+
export declare const LOOPBACK_HOSTS: Set<string>;
|
|
39
|
+
export declare const HTTP_STATUS_NOT_FOUND = 404;
|
|
40
|
+
export declare const WS_READY_STATE_OPEN = 1;
|
|
41
|
+
export declare const WS_CLOSE_POLICY_VIOLATION = 1008;
|
|
42
|
+
export declare const WS_CLOSE_BACKPRESSURE = 4429;
|
|
43
|
+
export declare const WS_CLOSE_CAPACITY_REACHED = 4503;
|
|
44
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,OAAO,CAAC;AACjC,eAAO,MAAM,YAAY,YAAY,CAAC;AACtC,eAAO,MAAM,YAAY,MAAM,CAAC;AAChC,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,eAAO,MAAM,sBAAsB,YAAY,CAAC;AAEhD,eAAO,MAAM,SAAS,mBAAmB,CAAC;AAC1C,eAAO,MAAM,eAAe,cAAc,CAAC;AAE3C,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAC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ELL_FALLBACK = "/bin/sh";
|
|
6
|
+
export const TERM_TYPE = "xterm-256color";
|
|
7
|
+
export const COLORTERM_VALUE = "truecolor";
|
|
8
|
+
export const TITLE_POLL_INTERVAL_MS = 500;
|
|
9
|
+
export const CWD_RESOLVE_TIMEOUT_MS = 250;
|
|
10
|
+
export const CWD_RESOLVE_BACKOFF_MS = 30_000;
|
|
11
|
+
export const CWD_RESOLVE_COOLDOWN_MS = 5_000;
|
|
12
|
+
export const TITLE_MAX_PATH_SEGMENTS = 3;
|
|
13
|
+
export const TITLE_TRUNCATION_PREFIX = "…";
|
|
14
|
+
/**
|
|
15
|
+
* Strip terminal-emulator identity env vars inherited from the daemon's parent.
|
|
16
|
+
* If we leak e.g. TERM_PROGRAM=ghostty, modern Ink-based TUIs (Cursor Agent,
|
|
17
|
+
* Claude Code) will probe for that terminal's protocol (kitty keyboard,
|
|
18
|
+
* XTQVERSION, XTGETTCAP, OSC 1337, etc.) and — when xterm.js doesn't answer —
|
|
19
|
+
* fall back to a degraded inline-plain rendering instead of the full boxed
|
|
20
|
+
* TUI. Removing these lets the TUI treat us as a generic xterm-256color and
|
|
21
|
+
* render normally.
|
|
22
|
+
*/
|
|
23
|
+
export const PTY_ENV_DENYLIST = [
|
|
24
|
+
"LOCALTERM_DAEMON_CHILD",
|
|
25
|
+
"TERM_PROGRAM",
|
|
26
|
+
"TERM_PROGRAM_VERSION",
|
|
27
|
+
"TERM_SESSION_ID",
|
|
28
|
+
"ITERM_SESSION_ID",
|
|
29
|
+
"ITERM_PROFILE",
|
|
30
|
+
"KITTY_WINDOW_ID",
|
|
31
|
+
"KITTY_PID",
|
|
32
|
+
"WT_SESSION",
|
|
33
|
+
"WT_PROFILE_ID",
|
|
34
|
+
"GHOSTTY_RESOURCES_DIR",
|
|
35
|
+
"GHOSTTY_BIN_DIR",
|
|
36
|
+
"VSCODE_INJECTION",
|
|
37
|
+
"VSCODE_GIT_IPC_HANDLE",
|
|
38
|
+
];
|
|
39
|
+
export const MAX_INPUT_BYTES = 64 * 1024;
|
|
40
|
+
export const MAX_OUTPUT_BYTES = 1 * 1024 * 1024;
|
|
41
|
+
export const MAX_FOREGROUND_LENGTH = 256;
|
|
42
|
+
export const MAX_TITLE_LENGTH = 4 * 1024;
|
|
43
|
+
export const MAX_COLS = 1000;
|
|
44
|
+
export const MAX_ROWS = 1000;
|
|
45
|
+
export const MAX_CONCURRENT_SESSIONS = 64;
|
|
46
|
+
// High/low water marks gate the PTY -> WS pipe instead of killing the socket.
|
|
47
|
+
// Crossing the high water mark pauses the PTY so the OS pipe absorbs further
|
|
48
|
+
// child output until the WS drains below the low water mark, at which point
|
|
49
|
+
// we resume. Anything past WS_BACKPRESSURE_THRESHOLD_BYTES is treated as a
|
|
50
|
+
// runaway: the WS *did* drain below low water at some point, the receiver is
|
|
51
|
+
// genuinely stuck, and we'd rather drop the connection than balloon memory.
|
|
52
|
+
export const WS_OUTBOUND_PAUSE_HIGH_WATER_BYTES = 4 * 1024 * 1024;
|
|
53
|
+
export const WS_OUTBOUND_RESUME_LOW_WATER_BYTES = 1 * 1024 * 1024;
|
|
54
|
+
export const WS_OUTBOUND_DRAIN_POLL_MS = 50;
|
|
55
|
+
export const WS_BACKPRESSURE_THRESHOLD_BYTES = 64 * 1024 * 1024;
|
|
56
|
+
// Heartbeat: send a WS ping every N ms; if no pong arrives within the timeout
|
|
57
|
+
// we tear down the socket. Without this, half-open connections (laptop sleep,
|
|
58
|
+
// VPN dropout, kernel‑side TCP keepalives at 2h+) wedge the session — the
|
|
59
|
+
// server keeps a dead PTY tied to a phantom client and the browser eventually
|
|
60
|
+
// trips its own write error and shows "Shell ended" with no idea why.
|
|
61
|
+
export const WS_HEARTBEAT_INTERVAL_MS = 20_000;
|
|
62
|
+
export const WS_HEARTBEAT_TIMEOUT_MS = 60_000;
|
|
63
|
+
// Hard ceiling for server.stop() — clients get terminated, then the http
|
|
64
|
+
// server is given this long to actually close before we resolve anyway. Keeps
|
|
65
|
+
// the daemon's SIGTERM path bounded so the CLI's force-exit fallback never
|
|
66
|
+
// fires for normal shutdowns.
|
|
67
|
+
export const SERVER_STOP_GRACE_MS = 1_500;
|
|
68
|
+
export const LOOPBACK_HOSTS = new Set([
|
|
69
|
+
"127.0.0.1",
|
|
70
|
+
"localhost",
|
|
71
|
+
"::1",
|
|
72
|
+
"[::1]",
|
|
73
|
+
"0:0:0:0:0:0:0:1",
|
|
74
|
+
]);
|
|
75
|
+
export const HTTP_STATUS_NOT_FOUND = 404;
|
|
76
|
+
export const WS_READY_STATE_OPEN = 1;
|
|
77
|
+
export const WS_CLOSE_POLICY_VIOLATION = 1008;
|
|
78
|
+
export const WS_CLOSE_BACKPRESSURE = 4429;
|
|
79
|
+
export const WS_CLOSE_CAPACITY_REACHED = 4503;
|
|
80
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AACjC,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC;AACtC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAChC,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAC/B,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAEhD,MAAM,CAAC,MAAM,SAAS,GAAG,gBAAgB,CAAC;AAC1C,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC;AAE3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAC1C,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAC1C,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAC7C,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAC7C,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AACzC,MAAM,CAAC,MAA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AAC;AAC9C,yEAAyE;AACzE,8EAA8E;AAC9E,2EAA2E;AAC3E,8BAA8B;AAC9B,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAE1C,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IACpC,WAAW;IACX,WAAW;IACX,KAAK;IACL,OAAO;IACP,iBAAiB;CAClB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAEzC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AACrC,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAC9C,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAC1C,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-shell.d.ts","sourceRoot":"","sources":["../src/default-shell.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,eAAe,QAAO,MAyBlC,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { accessSync, constants as fsConstants } from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import { DEFAULT_SHELL_FALLBACK } from "./constants.js";
|
|
4
|
+
const isExecutable = (binaryPath) => {
|
|
5
|
+
try {
|
|
6
|
+
accessSync(binaryPath, fsConstants.X_OK);
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export const getDefaultShell = () => {
|
|
14
|
+
if (process.platform === "win32") {
|
|
15
|
+
return process.env.COMSPEC ?? "cmd.exe";
|
|
16
|
+
}
|
|
17
|
+
// Priority order (matches VS Code, Hyper, and Warp):
|
|
18
|
+
// 1. LOCALTERM_SHELL — explicit user override
|
|
19
|
+
// 2. os.userInfo().shell — the user's persistent login shell from passwd / DSCL
|
|
20
|
+
// 3. process.env.SHELL — only as a fallback; this leaks the parent process's
|
|
21
|
+
// shell (often zsh from launchd / a Cursor terminal) and is wrong when the
|
|
22
|
+
// user has changed their default with `chsh`
|
|
23
|
+
// 4. DEFAULT_SHELL_FALLBACK
|
|
24
|
+
const candidates = [];
|
|
25
|
+
if (process.env.LOCALTERM_SHELL)
|
|
26
|
+
candidates.push(process.env.LOCALTERM_SHELL);
|
|
27
|
+
try {
|
|
28
|
+
const userInfo = os.userInfo();
|
|
29
|
+
if (userInfo.shell)
|
|
30
|
+
candidates.push(userInfo.shell);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
/* os.userInfo throws on systems without /etc/passwd entry for the uid */
|
|
34
|
+
}
|
|
35
|
+
if (process.env.SHELL)
|
|
36
|
+
candidates.push(process.env.SHELL);
|
|
37
|
+
candidates.push(DEFAULT_SHELL_FALLBACK);
|
|
38
|
+
for (const candidate of candidates) {
|
|
39
|
+
if (isExecutable(candidate))
|
|
40
|
+
return candidate;
|
|
41
|
+
}
|
|
42
|
+
return DEFAULT_SHELL_FALLBACK;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=default-shell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-shell.js","sourceRoot":"","sources":["../src/default-shell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD,MAAM,YAAY,GAAG,CAAC,UAAkB,EAAW,EAAE;IACnD,IAAI,CAAC;QACH,UAAU,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAW,EAAE;IAC1C,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,SAAS,CAAC;IAC1C,CAAC;IACD,qDAAqD;IACrD,gDAAgD;IAChD,kFAAkF;IAClF,+EAA+E;IAC/E,gFAAgF;IAChF,kDAAkD;IAClD,8BAA8B;IAC9B,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe;QAAE,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC9E,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;QAC/B,IAAI,QAAQ,CAAC,KAAK;YAAE,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC;IAAC,MAAM,CAAC;QACP,yEAAyE;IAC3E,CAAC;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK;QAAE,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC1D,UAAU,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACxC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,YAAY,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;IAChD,CAAC;IACD,OAAO,sBAAsB,CAAC;AAChC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-spawn-helper-executable.d.ts","sourceRoot":"","sources":["../src/ensure-spawn-helper-executable.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,2BAA2B,QAAO,IAkB9C,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { chmodSync, existsSync } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
const requireCjs = createRequire(import.meta.url);
|
|
5
|
+
const SPAWN_HELPER_MODE = 0o755;
|
|
6
|
+
let alreadyEnsured = false;
|
|
7
|
+
const candidateSpawnHelperPaths = (nodePtyDir) => [
|
|
8
|
+
path.join(nodePtyDir, "build", "Release", "spawn-helper"),
|
|
9
|
+
path.join(nodePtyDir, "prebuilds", `${process.platform}-${process.arch}`, "spawn-helper"),
|
|
10
|
+
];
|
|
11
|
+
export const ensureSpawnHelperExecutable = () => {
|
|
12
|
+
if (alreadyEnsured)
|
|
13
|
+
return;
|
|
14
|
+
alreadyEnsured = true;
|
|
15
|
+
let nodePtyDir;
|
|
16
|
+
try {
|
|
17
|
+
const ptyEntry = requireCjs.resolve("node-pty");
|
|
18
|
+
nodePtyDir = path.dirname(path.dirname(ptyEntry));
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
for (const candidate of candidateSpawnHelperPaths(nodePtyDir)) {
|
|
24
|
+
if (!existsSync(candidate))
|
|
25
|
+
continue;
|
|
26
|
+
try {
|
|
27
|
+
chmodSync(candidate, SPAWN_HELPER_MODE);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
/* helper already executable, or filesystem refused chmod (e.g. read-only mount) */
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=ensure-spawn-helper-executable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-spawn-helper-executable.js","sourceRoot":"","sources":["../src/ensure-spawn-helper-executable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,C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ostError {
|
|
3
|
+
kind: "non-loopback-host";
|
|
4
|
+
code: "E_LT_SERVER_NON_LOOPBACK_HOST";
|
|
5
|
+
host: string;
|
|
6
|
+
}
|
|
7
|
+
interface ListenFailedError {
|
|
8
|
+
kind: "listen-failed";
|
|
9
|
+
code: "E_LT_SERVER_LISTEN_FAILED";
|
|
10
|
+
host: string;
|
|
11
|
+
port: number;
|
|
12
|
+
cause: Error;
|
|
13
|
+
}
|
|
14
|
+
interface LoopbackDeniedError {
|
|
15
|
+
kind: "loopback-denied";
|
|
16
|
+
code: "E_LT_SERVER_LOOPBACK_DENIED";
|
|
17
|
+
reason: "host" | "origin";
|
|
18
|
+
observed: string | null;
|
|
19
|
+
wsCloseCode: typeof WS_CLOSE_POLICY_VIOLATION;
|
|
20
|
+
}
|
|
21
|
+
interface BackpressureError {
|
|
22
|
+
kind: "backpressure";
|
|
23
|
+
code: "E_LT_SERVER_BACKPRESSURE";
|
|
24
|
+
bufferedBytes: number;
|
|
25
|
+
thresholdBytes: typeof WS_BACKPRESSURE_THRESHOLD_BYTES;
|
|
26
|
+
wsCloseCode: typeof WS_CLOSE_BACKPRESSURE;
|
|
27
|
+
}
|
|
28
|
+
interface SessionCapacityError {
|
|
29
|
+
kind: "session-capacity";
|
|
30
|
+
code: "E_LT_SERVER_SESSION_CAPACITY";
|
|
31
|
+
limit: number;
|
|
32
|
+
wsCloseCode: typeof WS_CLOSE_CAPACITY_REACHED;
|
|
33
|
+
}
|
|
34
|
+
interface FrameRejectedError {
|
|
35
|
+
kind: "frame-rejected";
|
|
36
|
+
code: "E_LT_SERVER_FRAME_REJECTED";
|
|
37
|
+
direction: "inbound" | "outbound";
|
|
38
|
+
reason: string;
|
|
39
|
+
}
|
|
40
|
+
interface PathTraversalError {
|
|
41
|
+
kind: "path-traversal";
|
|
42
|
+
code: "E_LT_SERVER_PATH_TRAVERSAL";
|
|
43
|
+
requested: string;
|
|
44
|
+
}
|
|
45
|
+
export type ServerError = NonLoopbackHostError | ListenFailedError | LoopbackDeniedError | BackpressureError | SessionCapacityError | FrameRejectedError | PathTraversalError;
|
|
46
|
+
export type ServerErrorCode = ServerError["code"];
|
|
47
|
+
export type ServerErrorKind = ServerError["kind"];
|
|
48
|
+
export declare const serverError: {
|
|
49
|
+
nonLoopbackHost: (host: string) => NonLoopbackHostError;
|
|
50
|
+
listenFailed: (host: string, port: number, cause: Error) => ListenFailedError;
|
|
51
|
+
loopbackDenied: (reason: "host" | "origin", observed: string | null) => LoopbackDeniedError;
|
|
52
|
+
backpressure: (bufferedBytes: number) => BackpressureError;
|
|
53
|
+
sessionCapacity: (limit: number) => SessionCapacityError;
|
|
54
|
+
frameRejected: (direction: "inbound" | "outbound", reason: string) => FrameRejectedError;
|
|
55
|
+
pathTraversal: (requested: string) => PathTraversalError;
|
|
56
|
+
};
|
|
57
|
+
export declare const formatServerError: (error: ServerError) => string;
|
|
58
|
+
export declare class ServerErrorException extends Error {
|
|
59
|
+
readonly error: ServerError;
|
|
60
|
+
constructor(error: ServerError);
|
|
61
|
+
}
|
|
62
|
+
export declare const isServerErrorException: (value: unknown) => value is ServerErrorException;
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAC/B,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,EAC1B,MAAM,gBAAgB,CAAC;AAExB,UAAU,oBAAoB;IAC5B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,IAAI,EAAE,+BAA+B,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,iBAAiB;IACzB,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,2BAA2B,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CA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,MAAM,GAAG,QAAQ,YAAY,MAAM,GAAG,IAAI,KAAG,mBAAmB;kCAO3D,MAAM,KAAG,iBAAiB;6BAO/B,MAAM,KAAG,oBAAoB;+BAM3B,SAAS,GAAG,UAAU,UAAU,MAAM,KAAG,kBAAkB;+BAM3D,MAAM,KAAG,kBAAkB;CAKvD,CAAC;AAMF,eAAO,MAAM,iBAAiB,GAAI,OAAO,WAAW,KAAG,MAsBtD,CAAC;AAEF,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;gBAChB,KAAK,EAAE,WAAW;CAO/B;AAED,eAAO,MAAM,sBAAsB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,oBAC1B,CAAC"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { WS_BACKPRESSURE_THRESHOLD_BYTES, WS_CLOSE_BACKPRESSURE, WS_CLOSE_CAPACITY_REACHED, WS_CLOSE_POLICY_VIOLATION, } from "./constants.js";
|
|
2
|
+
export const serverError = {
|
|
3
|
+
nonLoopbackHost: (host) => ({
|
|
4
|
+
kind: "non-loopback-host",
|
|
5
|
+
code: "E_LT_SERVER_NON_LOOPBACK_HOST",
|
|
6
|
+
host,
|
|
7
|
+
}),
|
|
8
|
+
listenFailed: (host, port, cause) => ({
|
|
9
|
+
kind: "listen-failed",
|
|
10
|
+
code: "E_LT_SERVER_LISTEN_FAILED",
|
|
11
|
+
host,
|
|
12
|
+
port,
|
|
13
|
+
cause,
|
|
14
|
+
}),
|
|
15
|
+
loopbackDenied: (reason, observed) => ({
|
|
16
|
+
kind: "loopback-denied",
|
|
17
|
+
code: "E_LT_SERVER_LOOPBACK_DENIED",
|
|
18
|
+
reason,
|
|
19
|
+
observed,
|
|
20
|
+
wsCloseCode: WS_CLOSE_POLICY_VIOLATION,
|
|
21
|
+
}),
|
|
22
|
+
backpressure: (bufferedBytes) => ({
|
|
23
|
+
kind: "backpressure",
|
|
24
|
+
code: "E_LT_SERVER_BACKPRESSURE",
|
|
25
|
+
bufferedBytes,
|
|
26
|
+
thresholdBytes: WS_BACKPRESSURE_THRESHOLD_BYTES,
|
|
27
|
+
wsCloseCode: WS_CLOSE_BACKPRESSURE,
|
|
28
|
+
}),
|
|
29
|
+
sessionCapacity: (limit) => ({
|
|
30
|
+
kind: "session-capacity",
|
|
31
|
+
code: "E_LT_SERVER_SESSION_CAPACITY",
|
|
32
|
+
limit,
|
|
33
|
+
wsCloseCode: WS_CLOSE_CAPACITY_REACHED,
|
|
34
|
+
}),
|
|
35
|
+
frameRejected: (direction, reason) => ({
|
|
36
|
+
kind: "frame-rejected",
|
|
37
|
+
code: "E_LT_SERVER_FRAME_REJECTED",
|
|
38
|
+
direction,
|
|
39
|
+
reason,
|
|
40
|
+
}),
|
|
41
|
+
pathTraversal: (requested) => ({
|
|
42
|
+
kind: "path-traversal",
|
|
43
|
+
code: "E_LT_SERVER_PATH_TRAVERSAL",
|
|
44
|
+
requested,
|
|
45
|
+
}),
|
|
46
|
+
};
|
|
47
|
+
const exhaustivenessGuard = (impossible) => {
|
|
48
|
+
throw new Error(`unhandled ServerError variant: ${JSON.stringify(impossible)}`);
|
|
49
|
+
};
|
|
50
|
+
export const formatServerError = (error) => {
|
|
51
|
+
switch (error.kind) {
|
|
52
|
+
case "non-loopback-host":
|
|
53
|
+
return `refusing to bind non-loopback host '${error.host}': pass 127.0.0.1 or localhost`;
|
|
54
|
+
case "listen-failed":
|
|
55
|
+
return `failed to listen on ${error.host}:${error.port}: ${error.cause.message}`;
|
|
56
|
+
case "loopback-denied": {
|
|
57
|
+
const where = error.reason === "host" ? "Host header" : "Origin header";
|
|
58
|
+
const seen = error.observed ? ` (saw '${error.observed}')` : "";
|
|
59
|
+
return `forbidden: non-loopback ${where}${seen}`;
|
|
60
|
+
}
|
|
61
|
+
case "backpressure":
|
|
62
|
+
return `closing socket: outbound buffered ${error.bufferedBytes}B exceeds ${error.thresholdBytes}B threshold`;
|
|
63
|
+
case "session-capacity":
|
|
64
|
+
return `refusing new session: at capacity (${error.limit} concurrent sessions)`;
|
|
65
|
+
case "frame-rejected":
|
|
66
|
+
return `dropping malformed ${error.direction} frame: ${error.reason}`;
|
|
67
|
+
case "path-traversal":
|
|
68
|
+
return `refusing path-traversal request: '${error.requested}'`;
|
|
69
|
+
default:
|
|
70
|
+
return exhaustivenessGuard(error);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
export class ServerErrorException extends Error {
|
|
74
|
+
error;
|
|
75
|
+
constructor(error) {
|
|
76
|
+
super(formatServerError(error), {
|
|
77
|
+
cause: "cause" in error ? error.cause : undefined,
|
|
78
|
+
});
|
|
79
|
+
this.name = "ServerErrorException";
|
|
80
|
+
this.error = error;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export const isServerErrorException = (value) => value instanceof ServerErrorException;
|
|
84
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAC/B,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AAgExB,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,eAAe,EAAE,CAAC,IAAY,EAAwB,EAAE,CAAC,CAAC;QACxD,IAAI,EAAE,mBAAmB;QACzB,IAAI,EAAE,+BAA+B;QACrC,IAAI;KACL,CAAC;IACF,YAAY,EAAE,CAAC,IAAY,EAAE,IAAY,EAAE,KAAY,EAAqB,EAAE,CAAC,CAAC;QAC9E,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,2BAA2B;QACjC,IAAI;QACJ,IAAI;QACJ,KAAK;KACN,CAAC;IACF,cAAc,EAAE,CAAC,MAAyB,EAAE,QAAuB,EAAuB,EAAE,CAAC,CAAC;QAC5F,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE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export interface ServerOptions {
|
|
3
|
+
port?: number;
|
|
4
|
+
host?: string;
|
|
5
|
+
staticRoot?: string | null;
|
|
6
|
+
}
|
|
7
|
+
export interface RunningServer {
|
|
8
|
+
port: number;
|
|
9
|
+
host: string;
|
|
10
|
+
registry: SessionRegistry;
|
|
11
|
+
stop: () => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare const createServer: (options?: ServerOptions) => Promise<RunningServer>;
|
|
14
|
+
export type { Session } from "./session.js";
|
|
15
|
+
export type { SessionRegistry } from "./session-registry.js";
|
|
16
|
+
export type * from "./types.js";
|
|
17
|
+
export { DEFAULT_HOST, DEFAULT_PORT, WS_CLOSE_BACKPRESSURE } from "./constants.js";
|
|
18
|
+
export { isLoopbackHost } from "./security.js";
|
|
19
|
+
export { healthSchema } from "./schemas.js";
|
|
20
|
+
export { ServerErrorException, formatServerError, isServerErrorException, serverError, } from "./errors.js";
|
|
21
|
+
export type { ServerError, ServerErrorCode, ServerErrorKind } from "./errors.js";
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIxD,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAuDD,eAAO,MAAM,YAAY,GAAU,UAAS,aAAkB,KAAG,OAAO,CAAC,aAAa,CAiUrF,CAAC;AAEF,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,mBAAmB,YAAY,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
|