machine-bridge-mcp 1.2.5 → 1.2.7
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/CHANGELOG.md +18 -0
- package/README.md +2 -2
- package/SECURITY.md +3 -3
- package/browser-extension/manifest.json +2 -2
- package/docs/ARCHITECTURE.md +6 -6
- package/docs/AUDIT.md +24 -0
- package/docs/OPERATIONS.md +5 -3
- package/docs/TESTING.md +3 -3
- package/docs/UPGRADING.md +3 -3
- package/package.json +1 -1
- package/src/local/browser-bridge.mjs +67 -22
- package/src/local/cli-local-admin.mjs +2 -3
- package/src/local/daemon-process.mjs +50 -8
- package/src/local/execution-limits.mjs +36 -0
- package/src/local/job-runner.mjs +5 -8
- package/src/local/loopback-health.mjs +67 -0
- package/src/local/managed-jobs.mjs +22 -9
- package/src/local/process-contract.mjs +19 -0
- package/src/local/process-execution.mjs +11 -10
- package/src/local/process-sessions.mjs +25 -50
- package/src/local/process-tracker.mjs +1 -1
- package/src/local/process-tree.mjs +53 -0
- package/src/local/relay-connection.mjs +11 -1
- package/src/local/runtime-reporting.mjs +3 -1
- package/src/local/runtime.mjs +8 -8
- package/src/local/shell.mjs +2 -19
- package/src/worker/index.ts +1 -1
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
allToolNames, isCanonicalFullPolicy, MCP_PROTOCOL_VERSION, MCP_SUPPORTED_PROTOCOL_VERSIONS,
|
|
4
4
|
POLICY_PROFILES, SERVER_NAME,
|
|
5
5
|
} from "./tools.mjs";
|
|
6
|
+
import { executionGuardrailsSnapshot } from "./execution-limits.mjs";
|
|
6
7
|
|
|
7
8
|
export function buildRuntimeInfo({
|
|
8
9
|
workspace,
|
|
@@ -47,7 +48,7 @@ export function buildRuntimeInfo({
|
|
|
47
48
|
},
|
|
48
49
|
tools: ["server_info", ...toolNames],
|
|
49
50
|
observability: {
|
|
50
|
-
relay_readiness: "
|
|
51
|
+
relay_readiness: "end-to-end-relay-probe-verified",
|
|
51
52
|
brief_relay_interruptions: "debug-only",
|
|
52
53
|
raw_transport_details: "debug-only",
|
|
53
54
|
per_tool_events: "structured-debug-events",
|
|
@@ -63,6 +64,7 @@ export function buildRuntimeInfo({
|
|
|
63
64
|
relay: relayStatus(),
|
|
64
65
|
runtime_dir: policy.exposeAbsolutePaths ? runtimeDir : "<private-runtime-dir>",
|
|
65
66
|
processes: processTracker.snapshot(),
|
|
67
|
+
execution_guardrails: executionGuardrailsSnapshot(),
|
|
66
68
|
process_sessions: processSessionManager.status(),
|
|
67
69
|
managed_jobs: managedJobManager.status(),
|
|
68
70
|
local_resources: managedJobManager.resourceInfo(),
|
package/src/local/runtime.mjs
CHANGED
|
@@ -2,9 +2,10 @@ import { mkdirSync, mkdtempSync, realpathSync, rmSync } from "node:fs";
|
|
|
2
2
|
import { lstat, realpath, stat } from "node:fs/promises";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
5
|
-
import { RelayConnection } from "./relay-connection.mjs";
|
|
5
|
+
import { isRelayReadyContext, RelayConnection } from "./relay-connection.mjs";
|
|
6
6
|
import { ProcessSessionManager } from "./process-sessions.mjs";
|
|
7
|
-
|
|
7
|
+
import { MAX_CONCURRENT_TOOL_CALLS } from "./execution-limits.mjs";
|
|
8
|
+
export { MAX_COMMAND_BYTES } from "./process-contract.mjs";
|
|
8
9
|
import { MCP_SUPPORTED_PROTOCOL_VERSIONS, normalizePolicy, PolicyGate, SERVER_NAME } from "./tools.mjs";
|
|
9
10
|
import { publicError } from "./errors.mjs";
|
|
10
11
|
import { ProcessTracker } from "./process-tracker.mjs";
|
|
@@ -36,7 +37,6 @@ import {
|
|
|
36
37
|
} from "./runtime-capabilities.mjs";
|
|
37
38
|
|
|
38
39
|
const MAX_WS_MESSAGE_BYTES = 8 * 1024 * 1024;
|
|
39
|
-
const MAX_CONCURRENT_TOOL_CALLS = 16;
|
|
40
40
|
const SLOW_TOOL_CALL_MS = 30_000;
|
|
41
41
|
|
|
42
42
|
const RUNTIME_TOOL_HANDLERS = Object.freeze({
|
|
@@ -212,6 +212,7 @@ export class LocalRuntime {
|
|
|
212
212
|
readResourceText,
|
|
213
213
|
readResourceBinary,
|
|
214
214
|
throwIfCancelled: (context) => this.throwIfCancelled(context),
|
|
215
|
+
logger: this.logger,
|
|
215
216
|
});
|
|
216
217
|
this.toolExecutor = new ToolExecutor({
|
|
217
218
|
handlers: Object.fromEntries(Object.entries(RUNTIME_TOOL_HANDLERS).map(([name, handler]) => [
|
|
@@ -234,9 +235,7 @@ export class LocalRuntime {
|
|
|
234
235
|
});
|
|
235
236
|
}
|
|
236
237
|
|
|
237
|
-
tools() {
|
|
238
|
-
return this.policyGate.names().filter((name) => name !== "server_info");
|
|
239
|
-
}
|
|
238
|
+
tools() { return this.policyGate.names().filter((name) => name !== "server_info"); }
|
|
240
239
|
|
|
241
240
|
runtimeInfo() {
|
|
242
241
|
return buildRuntimeInfo({
|
|
@@ -303,12 +302,12 @@ export class LocalRuntime {
|
|
|
303
302
|
}
|
|
304
303
|
if (this.handleRelayControlMessage(message)) return;
|
|
305
304
|
if (message.type === "relay_probe") {
|
|
306
|
-
if (relayContext.
|
|
305
|
+
if (isRelayReadyContext(relayContext, this.relay)) return this.handleRelayProtocolViolation("unexpected_relay_probe");
|
|
307
306
|
this.handleRelayProbe(message, relayContext);
|
|
308
307
|
return;
|
|
309
308
|
}
|
|
310
309
|
if (message.type !== "tool_call") return this.handleRelayProtocolViolation("unexpected_server_message_type");
|
|
311
|
-
if (relayContext.
|
|
310
|
+
if (!isRelayReadyContext(relayContext, this.relay)) return this.handleRelayProtocolViolation("tool_call_before_ready");
|
|
312
311
|
await this.handleRelayToolCall(message, relayContext);
|
|
313
312
|
}
|
|
314
313
|
|
|
@@ -742,6 +741,7 @@ function createRelayConnection(runtime, { workerUrl, secret, expectedVersion, on
|
|
|
742
741
|
});
|
|
743
742
|
}
|
|
744
743
|
|
|
744
|
+
|
|
745
745
|
function handleRelayData(runtime, data, relayContext = {}) {
|
|
746
746
|
const raw = typeof data === "string" ? data : Buffer.from(data).toString("utf8");
|
|
747
747
|
if (Buffer.byteLength(raw) > MAX_WS_MESSAGE_BYTES) {
|
package/src/local/shell.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { existsSync } from "node:fs";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { packageRoot } from "./state.mjs";
|
|
5
5
|
import { BoundedOutput } from "./bounded-output.mjs";
|
|
6
|
+
import { terminateProcessTreeWithEscalation } from "./process-tree.mjs";
|
|
6
7
|
|
|
7
8
|
export function runExecutable(command, args = [], options = {}) {
|
|
8
9
|
const executable = validateExecutable(command);
|
|
@@ -28,8 +29,7 @@ export function runExecutable(command, args = [], options = {}) {
|
|
|
28
29
|
if (Number.isFinite(timeoutMs) && timeoutMs > 0) {
|
|
29
30
|
timer = setTimeout(() => {
|
|
30
31
|
timedOut = true;
|
|
31
|
-
|
|
32
|
-
killTimer = setTimeout(() => terminateCommandTree(child, true), 2000);
|
|
32
|
+
killTimer = terminateProcessTreeWithEscalation(child);
|
|
33
33
|
}, timeoutMs);
|
|
34
34
|
timer.unref?.();
|
|
35
35
|
}
|
|
@@ -84,23 +84,6 @@ function validateExecutableArgs(value) {
|
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
function terminateCommandTree(child, force) {
|
|
88
|
-
if (!child?.pid) return;
|
|
89
|
-
if (process.platform === "win32") {
|
|
90
|
-
try {
|
|
91
|
-
const killer = spawn("taskkill.exe", ["/PID", String(child.pid), "/T", ...(force ? ["/F"] : [])], {
|
|
92
|
-
stdio: "ignore",
|
|
93
|
-
windowsHide: true,
|
|
94
|
-
});
|
|
95
|
-
killer.unref();
|
|
96
|
-
return;
|
|
97
|
-
} catch {}
|
|
98
|
-
}
|
|
99
|
-
const signal = force ? "SIGKILL" : "SIGTERM";
|
|
100
|
-
try { process.kill(-child.pid, signal); } catch {
|
|
101
|
-
try { child.kill(signal); } catch {}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
87
|
|
|
105
88
|
function capturedResult(code, stdout, stderr, extraStderr = "") {
|
|
106
89
|
const stderrText = [stderr.text(), extraStderr].filter(Boolean).join("\n");
|
package/src/worker/index.ts
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
} from "./http.ts";
|
|
28
28
|
|
|
29
29
|
const SERVER_NAME = String(serverMetadata.name);
|
|
30
|
-
const SERVER_VERSION = "1.2.
|
|
30
|
+
const SERVER_VERSION = "1.2.7";
|
|
31
31
|
const MCP_PROTOCOL_VERSION = String(serverMetadata.protocolVersion);
|
|
32
32
|
const MCP_SUPPORTED_PROTOCOL_VERSIONS = serverMetadata.supportedProtocolVersions.map((value) => String(value));
|
|
33
33
|
const JSONRPC_VERSION = "2.0";
|