@maintainer-pro/ai-bridge 0.1.30 → 0.1.32
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/package.json +4 -3
- package/src/daemon.mjs +22 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maintainer-pro/ai-bridge",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.32",
|
|
4
4
|
"description": "Local bridge daemon that pairs a machine to Maintainer Pro and configures multiple client sandboxes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"maintainer-pro",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"node": ">=22"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@maintainer-pro/ai-cli": "^0.1.
|
|
32
|
-
"@maintainer-pro/ai-server": "^0.1.
|
|
31
|
+
"@maintainer-pro/ai-cli": "^0.1.17",
|
|
32
|
+
"@maintainer-pro/ai-server": "^0.1.9",
|
|
33
|
+
"ws": "^8.21.3"
|
|
33
34
|
}
|
|
34
35
|
}
|
package/src/daemon.mjs
CHANGED
|
@@ -43,9 +43,21 @@ import {
|
|
|
43
43
|
mergeCookieHeader,
|
|
44
44
|
storeCorsCookies,
|
|
45
45
|
} from "./cors-cookies.mjs";
|
|
46
|
+
import { WebSocket as WsWebSocket } from "ws";
|
|
46
47
|
|
|
47
48
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
48
49
|
const requireFromHere = createRequire(import.meta.url);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Node 22+ has a global WHATWG WebSocket. Node 20 (still common on partner
|
|
53
|
+
* machines) does not — `new WebSocket()` throws "WebSocket is not defined".
|
|
54
|
+
* Fall back to the `ws` package, which exposes the same addEventListener API.
|
|
55
|
+
*/
|
|
56
|
+
const WebSocketImpl =
|
|
57
|
+
typeof globalThis.WebSocket === "function"
|
|
58
|
+
? globalThis.WebSocket
|
|
59
|
+
: WsWebSocket;
|
|
60
|
+
const usingWsFallback = WebSocketImpl === WsWebSocket;
|
|
49
61
|
const PACKAGE_VERSION = readPackageVersion();
|
|
50
62
|
const PACKAGE_VERSIONS = readPackageVersions();
|
|
51
63
|
const HEARTBEAT_MS = 15_000;
|
|
@@ -3060,7 +3072,7 @@ function attachProxyLocalWs(id, socket) {
|
|
|
3060
3072
|
try {
|
|
3061
3073
|
socket.binaryType = "arraybuffer";
|
|
3062
3074
|
} catch {
|
|
3063
|
-
/* WHATWG WebSocket in Node 22 */
|
|
3075
|
+
/* WHATWG WebSocket in Node 22; `ws` fallback on Node 20 */
|
|
3064
3076
|
}
|
|
3065
3077
|
proxyLocalSockets.set(id, socket);
|
|
3066
3078
|
const announceOpen = () => {
|
|
@@ -3134,7 +3146,9 @@ function openProxyLocalWs(id, port, path, protocols) {
|
|
|
3134
3146
|
let socket;
|
|
3135
3147
|
try {
|
|
3136
3148
|
// Vite HMR only accepts upgrades with subprotocol `vite-hmr` / `vite-ping`.
|
|
3137
|
-
socket = proto.length
|
|
3149
|
+
socket = proto.length
|
|
3150
|
+
? new WebSocketImpl(url, proto)
|
|
3151
|
+
: new WebSocketImpl(url);
|
|
3138
3152
|
} catch (err) {
|
|
3139
3153
|
if (index + 1 < hosts.length) {
|
|
3140
3154
|
tryHost(index + 1);
|
|
@@ -5475,6 +5489,11 @@ async function main() {
|
|
|
5475
5489
|
{ versions: PACKAGE_VERSIONS },
|
|
5476
5490
|
`bridge v${PACKAGE_VERSION} starting (${formatPackageVersions()})`
|
|
5477
5491
|
);
|
|
5492
|
+
if (usingWsFallback) {
|
|
5493
|
+
log(
|
|
5494
|
+
`Node ${process.versions.node} has no global WebSocket; using the ws package`
|
|
5495
|
+
);
|
|
5496
|
+
}
|
|
5478
5497
|
void warnIfBridgeOutdated();
|
|
5479
5498
|
|
|
5480
5499
|
let cfg = loadConfig() || {};
|
|
@@ -5827,7 +5846,7 @@ async function main() {
|
|
|
5827
5846
|
/** @type {WebSocket} */
|
|
5828
5847
|
let ws;
|
|
5829
5848
|
try {
|
|
5830
|
-
ws = new
|
|
5849
|
+
ws = new WebSocketImpl(url);
|
|
5831
5850
|
} catch (err) {
|
|
5832
5851
|
warn(
|
|
5833
5852
|
`websocket connect failed: ${
|