squad-openclaw 2026.2.1807 → 2026.2.1809
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 +51 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1041,9 +1041,9 @@ function ensureDevicePaired(keys, operatorToken) {
|
|
|
1041
1041
|
console.log(`[relay-client] Device pairing entry created in paired.json`);
|
|
1042
1042
|
return true;
|
|
1043
1043
|
}
|
|
1044
|
-
function signDeviceIdentity(keys, clientId, clientMode, role, scopes, token) {
|
|
1044
|
+
function signDeviceIdentity(keys, clientId, clientMode, role, scopes, token, challengeNonce) {
|
|
1045
1045
|
const signedAtMs = Date.now();
|
|
1046
|
-
const nonce = crypto2.randomBytes(16).toString("hex");
|
|
1046
|
+
const nonce = challengeNonce || crypto2.randomBytes(16).toString("hex");
|
|
1047
1047
|
const scopeStr = scopes.join(",");
|
|
1048
1048
|
const payload = `v2|${keys.deviceId}|${clientId}|${clientMode}|${role}|${scopeStr}|${signedAtMs}|${token ?? ""}|${nonce}`;
|
|
1049
1049
|
const privateKey = crypto2.createPrivateKey(keys.privateKeyPem);
|
|
@@ -1078,7 +1078,7 @@ var RelayClient = class {
|
|
|
1078
1078
|
claimToken: config.claimToken ?? state.claimToken ?? null,
|
|
1079
1079
|
roomId: config.roomId ?? state.roomId ?? null
|
|
1080
1080
|
};
|
|
1081
|
-
this.pendingClaimToken = this.config.claimToken;
|
|
1081
|
+
this.pendingClaimToken = this.config.roomId ? null : this.config.claimToken;
|
|
1082
1082
|
this.deviceKeys = loadOrCreateRelayDeviceKeys();
|
|
1083
1083
|
const newEntry = ensureDevicePaired(this.deviceKeys, this.config.operatorToken);
|
|
1084
1084
|
if (newEntry) {
|
|
@@ -1265,6 +1265,12 @@ var RelayClient = class {
|
|
|
1265
1265
|
}
|
|
1266
1266
|
return;
|
|
1267
1267
|
}
|
|
1268
|
+
if (typeof msg.type === "string" && msg.type.startsWith("relay.")) {
|
|
1269
|
+
if (msg.type === "relay.e2e.exchange" && msg.publicKey) {
|
|
1270
|
+
this.handleE2EExchange(userId, msg.publicKey);
|
|
1271
|
+
}
|
|
1272
|
+
return;
|
|
1273
|
+
}
|
|
1268
1274
|
let conn = this.userConnections.get(userId);
|
|
1269
1275
|
if (!conn || conn.localWs.readyState !== NodeWebSocket.OPEN) {
|
|
1270
1276
|
this.createUserConnection(userId);
|
|
@@ -1285,7 +1291,8 @@ var RelayClient = class {
|
|
|
1285
1291
|
client.mode ?? "ui",
|
|
1286
1292
|
role,
|
|
1287
1293
|
scopes,
|
|
1288
|
-
this.config.operatorToken
|
|
1294
|
+
this.config.operatorToken,
|
|
1295
|
+
conn.challengeNonce
|
|
1289
1296
|
);
|
|
1290
1297
|
msg.params = params;
|
|
1291
1298
|
conn.connectHandshakeComplete = false;
|
|
@@ -1315,7 +1322,8 @@ var RelayClient = class {
|
|
|
1315
1322
|
localWs,
|
|
1316
1323
|
userId,
|
|
1317
1324
|
e2e: null,
|
|
1318
|
-
connectHandshakeComplete: false
|
|
1325
|
+
connectHandshakeComplete: false,
|
|
1326
|
+
challengeNonce: null
|
|
1319
1327
|
};
|
|
1320
1328
|
this.userConnections.set(userId, conn);
|
|
1321
1329
|
localWs.on("open", () => {
|
|
@@ -1350,6 +1358,13 @@ var RelayClient = class {
|
|
|
1350
1358
|
const conn = this.userConnections.get(userId);
|
|
1351
1359
|
if (!conn) return;
|
|
1352
1360
|
const parsed = msg;
|
|
1361
|
+
if (parsed.type === "event" && parsed.event === "connect.challenge") {
|
|
1362
|
+
const payload = parsed.payload;
|
|
1363
|
+
if (payload?.nonce) {
|
|
1364
|
+
conn.challengeNonce = payload.nonce;
|
|
1365
|
+
console.log(`[relay-client] Captured challenge nonce for user ${userId}`);
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1353
1368
|
if (parsed.type === "res" && parsed.id === "connect-1" && parsed.ok) {
|
|
1354
1369
|
conn.connectHandshakeComplete = true;
|
|
1355
1370
|
}
|
|
@@ -1439,9 +1454,40 @@ function startRelayClient(api, relayUrl) {
|
|
|
1439
1454
|
|
|
1440
1455
|
// src/index.ts
|
|
1441
1456
|
function squadAppPlugin(api) {
|
|
1457
|
+
const toolExecutors = /* @__PURE__ */ new Map();
|
|
1458
|
+
const origRegisterTool = api.registerTool.bind(api);
|
|
1459
|
+
api.registerTool = (toolDef) => {
|
|
1460
|
+
if (toolDef.name && typeof toolDef.execute === "function") {
|
|
1461
|
+
toolExecutors.set(toolDef.name, toolDef.execute);
|
|
1462
|
+
}
|
|
1463
|
+
return origRegisterTool(toolDef);
|
|
1464
|
+
};
|
|
1442
1465
|
registerEntityTools(api);
|
|
1443
1466
|
registerFilesystemTools(api);
|
|
1444
1467
|
registerVersionMethods(api);
|
|
1468
|
+
api.registerGatewayMethod(
|
|
1469
|
+
"tools.invoke",
|
|
1470
|
+
async ({ params, respond }) => {
|
|
1471
|
+
const tool = params?.tool;
|
|
1472
|
+
const args = params?.args ?? {};
|
|
1473
|
+
if (!tool) {
|
|
1474
|
+
respond(false, { errorMessage: "Missing 'tool' parameter" });
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
const executeFn = toolExecutors.get(tool);
|
|
1478
|
+
if (!executeFn) {
|
|
1479
|
+
respond(false, { errorMessage: `Unknown tool: ${tool}` });
|
|
1480
|
+
return;
|
|
1481
|
+
}
|
|
1482
|
+
try {
|
|
1483
|
+
const result = await executeFn(`ws-${Date.now()}`, args);
|
|
1484
|
+
respond(true, result);
|
|
1485
|
+
} catch (err2) {
|
|
1486
|
+
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
1487
|
+
respond(false, { errorMessage: msg });
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
);
|
|
1445
1491
|
const relayEnabled = api.pluginConfig?.["relay.enabled"] ?? true;
|
|
1446
1492
|
if (relayEnabled) {
|
|
1447
1493
|
const relayUrl = api.pluginConfig?.["relay.url"] || "wss://relay.squad.ceo";
|
package/package.json
CHANGED