squad-openclaw 2026.2.196 → 2026.2.197
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 +14 -34
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -972,38 +972,21 @@ function readOperatorToken() {
|
|
|
972
972
|
return null;
|
|
973
973
|
}
|
|
974
974
|
}
|
|
975
|
-
|
|
976
|
-
|
|
975
|
+
var RELAY_STATE_PATH = path5.join(os.homedir(), ".squad", "relay.json");
|
|
976
|
+
function readRelayState() {
|
|
977
977
|
try {
|
|
978
|
-
const
|
|
979
|
-
return
|
|
980
|
-
} catch {
|
|
981
|
-
return null;
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
function deleteClaimToken() {
|
|
985
|
-
const tokenPath = path5.join(os.homedir(), ".squad", "claim-token");
|
|
986
|
-
try {
|
|
987
|
-
fs5.unlinkSync(tokenPath);
|
|
978
|
+
const raw = fs5.readFileSync(RELAY_STATE_PATH, "utf-8");
|
|
979
|
+
return JSON.parse(raw);
|
|
988
980
|
} catch {
|
|
981
|
+
return {};
|
|
989
982
|
}
|
|
990
983
|
}
|
|
991
|
-
function
|
|
992
|
-
const
|
|
993
|
-
try {
|
|
994
|
-
const id = fs5.readFileSync(roomPath, "utf-8").trim();
|
|
995
|
-
return id || null;
|
|
996
|
-
} catch {
|
|
997
|
-
return null;
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
function writeRoomId(roomId) {
|
|
1001
|
-
const roomPath = path5.join(os.homedir(), ".squad", "relay-room-id");
|
|
1002
|
-
const dir = path5.dirname(roomPath);
|
|
984
|
+
function writeRelayState(state) {
|
|
985
|
+
const dir = path5.dirname(RELAY_STATE_PATH);
|
|
1003
986
|
if (!fs5.existsSync(dir)) {
|
|
1004
987
|
fs5.mkdirSync(dir, { recursive: true });
|
|
1005
988
|
}
|
|
1006
|
-
fs5.writeFileSync(
|
|
989
|
+
fs5.writeFileSync(RELAY_STATE_PATH, JSON.stringify(state, null, 2), { mode: 384 });
|
|
1007
990
|
}
|
|
1008
991
|
function toBase64Url(buf) {
|
|
1009
992
|
return buf.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
@@ -1064,14 +1047,15 @@ var RelayClient = class {
|
|
|
1064
1047
|
/** Device keys for authenticating local WS connections to the gateway */
|
|
1065
1048
|
deviceKeys;
|
|
1066
1049
|
constructor(config) {
|
|
1050
|
+
const state = readRelayState();
|
|
1067
1051
|
this.config = {
|
|
1068
1052
|
relayUrl: config.relayUrl,
|
|
1069
1053
|
localGatewayPort: config.localGatewayPort ?? 18789,
|
|
1070
1054
|
operatorToken: config.operatorToken ?? readOperatorToken(),
|
|
1071
|
-
claimToken: config.claimToken ?? null,
|
|
1072
|
-
roomId: config.roomId ??
|
|
1055
|
+
claimToken: config.claimToken ?? state.claimToken ?? null,
|
|
1056
|
+
roomId: config.roomId ?? state.roomId ?? null
|
|
1073
1057
|
};
|
|
1074
|
-
this.pendingClaimToken = this.config.claimToken
|
|
1058
|
+
this.pendingClaimToken = this.config.claimToken;
|
|
1075
1059
|
this.deviceKeys = loadOrCreateDeviceKeys();
|
|
1076
1060
|
}
|
|
1077
1061
|
/** Start connecting to the relay */
|
|
@@ -1216,12 +1200,8 @@ var RelayClient = class {
|
|
|
1216
1200
|
if (msg.roomId) {
|
|
1217
1201
|
console.log(`[relay-client] Received room ID: ${msg.roomId.substring(0, 8)}...`);
|
|
1218
1202
|
this.config.roomId = msg.roomId;
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
console.log("[relay-client] Claim token consumed, clearing");
|
|
1222
|
-
this.pendingClaimToken = null;
|
|
1223
|
-
deleteClaimToken();
|
|
1224
|
-
}
|
|
1203
|
+
this.pendingClaimToken = null;
|
|
1204
|
+
writeRelayState({ roomId: msg.roomId });
|
|
1225
1205
|
}
|
|
1226
1206
|
}
|
|
1227
1207
|
/** Route a message from the relay to the appropriate user's local WS */
|