machine-bridge-mcp 1.2.1 → 1.2.5
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 +37 -1
- package/README.md +2 -0
- package/SECURITY.md +1 -1
- package/browser-extension/manifest.json +2 -2
- package/docs/AGENT_CONTEXT.md +1 -1
- package/docs/ARCHITECTURE.md +14 -13
- package/docs/AUDIT.md +24 -0
- package/docs/ENGINEERING.md +1 -1
- package/docs/LOGGING.md +12 -8
- package/docs/OPERATIONS.md +10 -5
- package/docs/TESTING.md +3 -3
- package/docs/UPGRADING.md +5 -3
- package/package.json +1 -1
- package/src/local/call-registry.mjs +9 -3
- package/src/local/capability-ranking.mjs +3 -2
- package/src/local/log.mjs +10 -2
- package/src/local/relay-connection.mjs +99 -12
- package/src/local/runtime.mjs +86 -28
- package/src/local/tool-executor.mjs +3 -3
- package/src/worker/daemon-liveness.ts +63 -0
- package/src/worker/daemon-sockets.ts +107 -0
- package/src/worker/index.ts +210 -113
- package/src/worker/observability.ts +5 -2
- package/src/worker/pending-calls.ts +17 -0
- package/wrangler.jsonc +1 -1
|
@@ -5,8 +5,8 @@ const SENSITIVE_FIELD = /(?:authorization|cookie|credential|password|secret|toke
|
|
|
5
5
|
export class WorkerObservability {
|
|
6
6
|
private readonly startedAt = performance.now();
|
|
7
7
|
private readonly requests = { total: 0, successful: 0, client_error: 0, server_error: 0 };
|
|
8
|
-
private readonly calls = { started: 0, completed: 0, failed: 0, cancelled: 0, timed_out: 0 };
|
|
9
|
-
private readonly sockets = { candidates: 0, authenticated: 0, disconnected: 0, protocol_errors: 0 };
|
|
8
|
+
private readonly calls = { started: 0, completed: 0, failed: 0, cancelled: 0, timed_out: 0, unmatched_results: 0 };
|
|
9
|
+
private readonly sockets = { candidates: 0, authenticated: 0, ready: 0, disconnected: 0, protocol_errors: 0 };
|
|
10
10
|
private readonly errors = new Map<string, number>();
|
|
11
11
|
private readonly tools = new Map<string, { started: number; completed: number; failed: number; active: number }>();
|
|
12
12
|
|
|
@@ -39,8 +39,11 @@ export class WorkerObservability {
|
|
|
39
39
|
this.incrementError(code);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
unmatchedResult(): void { this.calls.unmatched_results += 1; }
|
|
43
|
+
|
|
42
44
|
socketCandidate(): void { this.sockets.candidates += 1; }
|
|
43
45
|
socketAuthenticated(): void { this.sockets.authenticated += 1; }
|
|
46
|
+
socketReady(): void { this.sockets.ready += 1; }
|
|
44
47
|
socketDisconnected(): void { this.sockets.disconnected += 1; }
|
|
45
48
|
socketProtocolError(code: string): void {
|
|
46
49
|
this.sockets.protocol_errors += 1;
|
|
@@ -19,6 +19,8 @@ export interface PendingCallRecord {
|
|
|
19
19
|
timeout: ReturnType<typeof setTimeout>;
|
|
20
20
|
resolve: (value: unknown) => void;
|
|
21
21
|
reject: (error: Error) => void;
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
abortHandler?: () => void;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
interface RegisterPendingCall {
|
|
@@ -28,6 +30,8 @@ interface RegisterPendingCall {
|
|
|
28
30
|
tool: string;
|
|
29
31
|
timeoutMs: number;
|
|
30
32
|
onTimeout: (record: PendingCallRecord) => Error;
|
|
33
|
+
signal?: AbortSignal;
|
|
34
|
+
onAbort?: (record: PendingCallRecord) => Error;
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
export class PendingCallRegistry {
|
|
@@ -63,6 +67,14 @@ export class PendingCallRegistry {
|
|
|
63
67
|
catch { error = new Error("pending daemon call timed out"); }
|
|
64
68
|
reject(error instanceof Error ? error : new Error("pending daemon call timed out"));
|
|
65
69
|
}, input.timeoutMs);
|
|
70
|
+
const abortHandler = () => {
|
|
71
|
+
const record = this.take(input.id);
|
|
72
|
+
if (!record) return;
|
|
73
|
+
let error: unknown;
|
|
74
|
+
try { error = input.onAbort?.(record); }
|
|
75
|
+
catch { error = new Error("pending daemon call was cancelled"); }
|
|
76
|
+
reject(error instanceof Error ? error : new Error("pending daemon call was cancelled"));
|
|
77
|
+
};
|
|
66
78
|
const record: PendingCallRecord = {
|
|
67
79
|
id: input.id,
|
|
68
80
|
socket: input.socket,
|
|
@@ -72,9 +84,13 @@ export class PendingCallRegistry {
|
|
|
72
84
|
timeout,
|
|
73
85
|
resolve,
|
|
74
86
|
reject,
|
|
87
|
+
signal: input.signal,
|
|
88
|
+
abortHandler: input.signal ? abortHandler : undefined,
|
|
75
89
|
};
|
|
76
90
|
this.byId.set(input.id, record);
|
|
77
91
|
if (input.clientRequestKey) this.byRequestKey.set(input.clientRequestKey, input.id);
|
|
92
|
+
if (input.signal?.aborted) abortHandler();
|
|
93
|
+
else input.signal?.addEventListener("abort", abortHandler, { once: true });
|
|
78
94
|
});
|
|
79
95
|
}
|
|
80
96
|
|
|
@@ -131,6 +147,7 @@ export class PendingCallRegistry {
|
|
|
131
147
|
const record = this.byId.get(id);
|
|
132
148
|
if (!record) return undefined;
|
|
133
149
|
clearTimeout(record.timeout);
|
|
150
|
+
if (record.signal && record.abortHandler) record.signal.removeEventListener("abort", record.abortHandler);
|
|
134
151
|
this.byId.delete(id);
|
|
135
152
|
if (record.clientRequestKey && this.byRequestKey.get(record.clientRequestKey) === id) {
|
|
136
153
|
this.byRequestKey.delete(record.clientRequestKey);
|
package/wrangler.jsonc
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "machine-bridge-mcp",
|
|
4
4
|
"main": "src/worker/index.ts",
|
|
5
5
|
"compatibility_date": "2026-07-11",
|
|
6
|
-
"compatibility_flags": ["nodejs_compat"],
|
|
6
|
+
"compatibility_flags": ["nodejs_compat", "enable_request_signal", "request_signal_passthrough"],
|
|
7
7
|
"workers_dev": true,
|
|
8
8
|
"durable_objects": {
|
|
9
9
|
"bindings": [
|