mcp-ssh-manager 4.0.0 → 4.0.2
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/.gitattributes +3 -3
- package/CHANGELOG.md +109 -0
- package/CLAUDE.md +4 -0
- package/CODE_OF_CONDUCT.md +18 -0
- package/CONTRIBUTING.md +30 -0
- package/Formula/ssh-manager.rb +2 -2
- package/README.md +50 -8
- package/brand/README.md +1 -0
- package/desktop/electron/electron-builder.yml +1 -0
- package/desktop/electron/local-shell.mjs +41 -0
- package/desktop/electron/main.js +115 -24
- package/desktop/electron/package-lock.json +2 -2
- package/desktop/electron/package.json +1 -1
- package/desktop/electron/prepare-engine.mjs +5 -3
- package/desktop/electron/smoke-test.mjs +12 -0
- package/dist/ui/app.css +1 -1
- package/dist/ui/app.js +124 -109
- package/docs/DISTRIBUTION.md +2 -2
- package/docs/MIGRATION.md +1 -1
- package/docs/TESTING-V4.md +6 -4
- package/package.json +33 -30
- package/scripts/build-interface.mjs +73 -0
- package/scripts/render-social-preview.mjs +36 -0
- package/scripts/requirements-dev.in +12 -0
- package/scripts/requirements-dev.txt +424 -0
- package/scripts/setup-hooks.sh +7 -13
- package/server.json +3 -3
- package/src/config-loader.js +2 -1
- package/src/control-plane.js +78 -4
- package/src/desktop-install.js +8 -0
- package/src/index.js +13 -5
- package/src/shell-quote.js +35 -2
package/src/desktop-install.js
CHANGED
|
@@ -47,6 +47,9 @@ export const RELEASES_PAGE = 'https://github.com/bvisible/mcp-ssh-manager/releas
|
|
|
47
47
|
/** Release assets live under `<this>/v<version>/<file>`. */
|
|
48
48
|
const RELEASE_BASE_URL = `${RELEASES_PAGE}/download`;
|
|
49
49
|
|
|
50
|
+
/** A version this project releases: 4.0.0, 4.0.0-beta.3. Nothing else reaches a URL. */
|
|
51
|
+
const RELEASE_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*)?$/;
|
|
52
|
+
|
|
50
53
|
/** The Developer ID team of bVisible Sarl, which signs and notarizes the macOS build. */
|
|
51
54
|
const TEAM_ID = 'BT249938WK';
|
|
52
55
|
|
|
@@ -645,6 +648,11 @@ export async function installDesktop({
|
|
|
645
648
|
if (root.protocol !== 'https:' && !allowLoopbackHttp) {
|
|
646
649
|
throw desktopError('DOWNLOAD', `Refusing to download from ${root.origin}: HTTPS only`);
|
|
647
650
|
}
|
|
651
|
+
// The version comes from a file (the engine's own package.json) and becomes
|
|
652
|
+
// part of the download URL and of the file name: only a release version may.
|
|
653
|
+
if (!RELEASE_VERSION.test(version)) {
|
|
654
|
+
throw desktopError('NOT_FOUND', `Not a release version: ${JSON.stringify(version)}. See ${RELEASES_PAGE}`);
|
|
655
|
+
}
|
|
648
656
|
const base = new URL(`v${encodeURIComponent(version)}/`, root);
|
|
649
657
|
const name = `${ARTIFACT_PREFIX}-${version}-${target.suffix}`;
|
|
650
658
|
|
package/src/index.js
CHANGED
|
@@ -151,7 +151,7 @@ import {
|
|
|
151
151
|
import { loadToolConfig, isToolEnabled } from './tool-config-manager.js';
|
|
152
152
|
import { evaluatePolicy } from './policy.js';
|
|
153
153
|
import { needsApproval, isControlPlaneListening, requestDecision, buildRequest, isApprovalExempt, isReadOnlyAction, HANDLER_GATED_TOOLS } from './approval.js';
|
|
154
|
-
import { shellQuote, shellPath, safeInteger } from './shell-quote.js';
|
|
154
|
+
import { shellQuote, shellPath, safeInteger, withRemoteTimeout } from './shell-quote.js';
|
|
155
155
|
import { openStream } from './live-stream.js';
|
|
156
156
|
import { auditLog, sanitize } from './audit.js';
|
|
157
157
|
|
|
@@ -163,7 +163,8 @@ const envFilePath = envChoice.path;
|
|
|
163
163
|
// Said at startup and repeated wherever a missing server would otherwise be
|
|
164
164
|
// the only clue: an empty configuration used to fail without a word (#90).
|
|
165
165
|
const envProblem = envFileProblem(envChoice);
|
|
166
|
-
|
|
166
|
+
// quiet: since dotenv 17 every load is announced on the log otherwise.
|
|
167
|
+
const envFile = dotenv.config({ path: envFilePath, processEnv: {}, quiet: true });
|
|
167
168
|
const envFileValues = envFile.parsed || {};
|
|
168
169
|
|
|
169
170
|
function getRuntimeEnv(name) {
|
|
@@ -365,9 +366,10 @@ async function execCommandWithTimeout(ssh, command, options = {}, timeoutMs = 30
|
|
|
365
366
|
const useSystemTimeout = timeoutMs > 0 && timeoutMs < 300000 && !rawCommand; // Max 5 minutes, not for raw commands
|
|
366
367
|
|
|
367
368
|
if (useSystemTimeout) {
|
|
368
|
-
//
|
|
369
|
-
|
|
370
|
-
|
|
369
|
+
// The remote host's own `timeout` (or Homebrew's `gtimeout`), found on the
|
|
370
|
+
// target rather than assumed: a stock Mac has neither, and every wrapped
|
|
371
|
+
// command failed there with exit 127 (#115). See withRemoteTimeout.
|
|
372
|
+
const wrappedCommand = withRemoteTimeout(command, Math.ceil(timeoutMs / 1000));
|
|
371
373
|
|
|
372
374
|
try {
|
|
373
375
|
const result = await ssh.execCommand(wrappedCommand, {
|
|
@@ -399,6 +401,12 @@ async function execCommandWithTimeout(ssh, command, options = {}, timeoutMs = 30
|
|
|
399
401
|
}
|
|
400
402
|
}
|
|
401
403
|
}
|
|
404
|
+
// On a target with no timeout binary (a stock Mac) it is the client-side
|
|
405
|
+
// limit that stops the command, and its message would name the wrapper and
|
|
406
|
+
// the grace period: say what the caller sent and the limit they asked for.
|
|
407
|
+
if (error.message.startsWith('Command timeout after')) {
|
|
408
|
+
throw new Error(`Command timeout after ${timeoutMs}ms: ${command.substring(0, 100)}...`);
|
|
409
|
+
}
|
|
402
410
|
throw error;
|
|
403
411
|
}
|
|
404
412
|
} else {
|
package/src/shell-quote.js
CHANGED
|
@@ -36,6 +36,32 @@ export function shellPath(value) {
|
|
|
36
36
|
return shellQuote(text);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
// Finds the timeout binary on the target, then runs the command under it. Run by
|
|
40
|
+
// `sh` with the seconds as $1 and the command as $2, so neither is ever spliced
|
|
41
|
+
// into this text. Stock Linux has `timeout`; macOS has neither unless Homebrew's
|
|
42
|
+
// coreutils adds `gtimeout`; with neither, the command still runs (the local SSH
|
|
43
|
+
// exec timeout bounds it) instead of failing with exit 127 (#115).
|
|
44
|
+
const REMOTE_TIMEOUT_SCRIPT = 'if t=$(command -v timeout 2>/dev/null || command -v gtimeout 2>/dev/null);'
|
|
45
|
+
+ ' then exec "$t" "$1" sh -c "$2"; else exec sh -c "$2"; fi';
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Wrap a command so the remote host kills it after `seconds`.
|
|
49
|
+
*
|
|
50
|
+
* The result is a single simple command made only of single-quoted words
|
|
51
|
+
* (`sh -c '<script>' sh <seconds> '<command>'`), because the SSH server hands it
|
|
52
|
+
* to the account's login shell, which is not always a POSIX one: csh and tcsh
|
|
53
|
+
* (FreeBSD's root, some old accounts) reject `$(...)` and `if ... fi` written at
|
|
54
|
+
* the top level, and a wrapper that resolves the binary there failed on them
|
|
55
|
+
* where the old bare `timeout ...` worked. The probing happens inside `sh`.
|
|
56
|
+
*
|
|
57
|
+
* @param {string} command - The command as the user wrote it, run by `sh -c`
|
|
58
|
+
* @param {number} seconds - Whole seconds before the remote side kills it
|
|
59
|
+
* @returns {string} The wrapped command
|
|
60
|
+
*/
|
|
61
|
+
export function withRemoteTimeout(command, seconds) {
|
|
62
|
+
return `sh -c ${shellQuote(REMOTE_TIMEOUT_SCRIPT)} sh ${safeInteger(seconds, 1)} ${shellQuote(command)}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
39
65
|
/**
|
|
40
66
|
* Coerce a value to a safe non-negative integer for use in a command.
|
|
41
67
|
*
|
|
@@ -48,7 +74,14 @@ export function shellPath(value) {
|
|
|
48
74
|
* @returns {number} A non-negative integer
|
|
49
75
|
*/
|
|
50
76
|
export function safeInteger(value, fallback) {
|
|
51
|
-
|
|
77
|
+
let n;
|
|
78
|
+
try {
|
|
79
|
+
n = Number(value);
|
|
80
|
+
} catch {
|
|
81
|
+
return fallback; // an object that cannot become a number at all (found by the property test)
|
|
82
|
+
}
|
|
52
83
|
if (!Number.isFinite(n)) return fallback;
|
|
53
|
-
|
|
84
|
+
// Capped: above 2^53 a number is no longer exact, and from 1e21 up it prints
|
|
85
|
+
// as "1e+21", which no command reads as a count (found by the property test).
|
|
86
|
+
return Math.min(Number.MAX_SAFE_INTEGER, Math.max(0, Math.trunc(n)));
|
|
54
87
|
}
|