squad-openclaw 2026.2.1809 → 2026.2.1811
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/dist/index.js +48 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1257,9 +1257,9 @@ var RelayClient = class {
|
|
|
1257
1257
|
const msg = innerMsg;
|
|
1258
1258
|
if (msg.type === "event" && typeof msg.event === "string" && msg.event.startsWith("relay.")) {
|
|
1259
1259
|
if (msg.event === "relay.user.connected") {
|
|
1260
|
-
console.log(`[relay-client] User ${userId} connected via relay \u2014 creating local WS`);
|
|
1261
1260
|
const existing = this.userConnections.get(userId);
|
|
1262
|
-
if (!existing || existing.localWs.readyState
|
|
1261
|
+
if (!existing || existing.localWs.readyState >= NodeWebSocket.CLOSING) {
|
|
1262
|
+
console.log(`[relay-client] User ${userId} connected via relay \u2014 creating local WS`);
|
|
1263
1263
|
this.createUserConnection(userId);
|
|
1264
1264
|
}
|
|
1265
1265
|
}
|
|
@@ -1272,31 +1272,24 @@ var RelayClient = class {
|
|
|
1272
1272
|
return;
|
|
1273
1273
|
}
|
|
1274
1274
|
let conn = this.userConnections.get(userId);
|
|
1275
|
-
if (!conn || conn.localWs.readyState
|
|
1275
|
+
if (!conn || conn.localWs.readyState >= NodeWebSocket.CLOSING) {
|
|
1276
1276
|
this.createUserConnection(userId);
|
|
1277
1277
|
conn = this.userConnections.get(userId);
|
|
1278
1278
|
if (!conn) return;
|
|
1279
1279
|
}
|
|
1280
1280
|
if (msg.type === "req" && msg.method === "connect") {
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1281
|
+
if (conn.connectHandshakeComplete) {
|
|
1282
|
+
console.log(`[relay-client] New connect from ${userId} \u2014 creating fresh local WS for handshake`);
|
|
1283
|
+
this.createUserConnection(userId);
|
|
1284
|
+
conn = this.userConnections.get(userId);
|
|
1285
|
+
if (!conn) return;
|
|
1284
1286
|
}
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
client.mode ?? "ui",
|
|
1292
|
-
role,
|
|
1293
|
-
scopes,
|
|
1294
|
-
this.config.operatorToken,
|
|
1295
|
-
conn.challengeNonce
|
|
1296
|
-
);
|
|
1297
|
-
msg.params = params;
|
|
1298
|
-
conn.connectHandshakeComplete = false;
|
|
1299
|
-
console.log(`[relay-client] Injected device identity for user ${userId}: ${this.deviceKeys.deviceId.substring(0, 12)}...`);
|
|
1287
|
+
if (!conn.challengeNonce) {
|
|
1288
|
+
console.log(`[relay-client] Connect request for ${userId} deferred \u2014 waiting for challenge nonce`);
|
|
1289
|
+
conn.pendingConnect = msg;
|
|
1290
|
+
return;
|
|
1291
|
+
}
|
|
1292
|
+
this.injectDeviceIdentity(conn, msg);
|
|
1300
1293
|
}
|
|
1301
1294
|
if (conn.localWs.readyState === NodeWebSocket.CONNECTING) {
|
|
1302
1295
|
conn.localWs.once("open", () => {
|
|
@@ -1306,6 +1299,28 @@ var RelayClient = class {
|
|
|
1306
1299
|
}
|
|
1307
1300
|
conn.localWs.send(JSON.stringify(msg));
|
|
1308
1301
|
}
|
|
1302
|
+
/** Inject auth token and device identity into a connect request */
|
|
1303
|
+
injectDeviceIdentity(conn, msg) {
|
|
1304
|
+
const params = msg.params ?? {};
|
|
1305
|
+
if (this.config.operatorToken) {
|
|
1306
|
+
params.auth = { token: this.config.operatorToken };
|
|
1307
|
+
}
|
|
1308
|
+
const client = params.client ?? {};
|
|
1309
|
+
const role = params.role ?? "operator";
|
|
1310
|
+
const scopes = params.scopes ?? [];
|
|
1311
|
+
params.device = signDeviceIdentity(
|
|
1312
|
+
this.deviceKeys,
|
|
1313
|
+
client.id ?? "cli",
|
|
1314
|
+
client.mode ?? "ui",
|
|
1315
|
+
role,
|
|
1316
|
+
scopes,
|
|
1317
|
+
this.config.operatorToken,
|
|
1318
|
+
conn.challengeNonce
|
|
1319
|
+
);
|
|
1320
|
+
msg.params = params;
|
|
1321
|
+
conn.connectHandshakeComplete = false;
|
|
1322
|
+
console.log(`[relay-client] Injected device identity for ${conn.userId}: nonce=${conn.challengeNonce?.substring(0, 12)}...`);
|
|
1323
|
+
}
|
|
1309
1324
|
/** Create a local WS connection to the gateway for a specific user */
|
|
1310
1325
|
createUserConnection(userId) {
|
|
1311
1326
|
const existing = this.userConnections.get(userId);
|
|
@@ -1323,7 +1338,8 @@ var RelayClient = class {
|
|
|
1323
1338
|
userId,
|
|
1324
1339
|
e2e: null,
|
|
1325
1340
|
connectHandshakeComplete: false,
|
|
1326
|
-
challengeNonce: null
|
|
1341
|
+
challengeNonce: null,
|
|
1342
|
+
pendingConnect: null
|
|
1327
1343
|
};
|
|
1328
1344
|
this.userConnections.set(userId, conn);
|
|
1329
1345
|
localWs.on("open", () => {
|
|
@@ -1362,7 +1378,16 @@ var RelayClient = class {
|
|
|
1362
1378
|
const payload = parsed.payload;
|
|
1363
1379
|
if (payload?.nonce) {
|
|
1364
1380
|
conn.challengeNonce = payload.nonce;
|
|
1365
|
-
console.log(`[relay-client] Captured challenge nonce for
|
|
1381
|
+
console.log(`[relay-client] Captured challenge nonce for ${userId}: ${conn.challengeNonce.substring(0, 12)}...`);
|
|
1382
|
+
if (conn.pendingConnect) {
|
|
1383
|
+
const pending = conn.pendingConnect;
|
|
1384
|
+
conn.pendingConnect = null;
|
|
1385
|
+
console.log(`[relay-client] Flushing deferred connect for ${userId}`);
|
|
1386
|
+
this.injectDeviceIdentity(conn, pending);
|
|
1387
|
+
if (conn.localWs.readyState === NodeWebSocket.OPEN) {
|
|
1388
|
+
conn.localWs.send(JSON.stringify(pending));
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1366
1391
|
}
|
|
1367
1392
|
}
|
|
1368
1393
|
if (parsed.type === "res" && parsed.id === "connect-1" && parsed.ok) {
|
package/package.json
CHANGED