squad-openclaw 2026.2.2022 → 2026.2.2201

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.
Files changed (2) hide show
  1. package/dist/index.js +61 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -215,6 +215,7 @@ var RelayClient = class {
215
215
  localConnectAttempts = /* @__PURE__ */ new Map();
216
216
  reconnectAttempts = 0;
217
217
  maxReconnectAttempts = 100;
218
+ autoConnectCounter = 0;
218
219
  reconnectTimer = null;
219
220
  shouldReconnect = true;
220
221
  destroyed = false;
@@ -440,9 +441,28 @@ var RelayClient = class {
440
441
  }
441
442
  }
442
443
  if (msg.type === "req" && msg.method === "connect") {
444
+ const connectRequestId = typeof msg.id === "string" ? msg.id : null;
443
445
  if (conn.connectHandshakeComplete) {
446
+ if (connectRequestId && conn.lastSuccessfulConnectRequestId === connectRequestId) {
447
+ console.log(`[relay-client] Duplicate connect id for ${userId} (${connectRequestId}) \u2014 reusing existing session`);
448
+ this.sendToRelay({
449
+ type: "relay.forward",
450
+ userId,
451
+ inner: {
452
+ type: "res",
453
+ id: connectRequestId,
454
+ ok: true,
455
+ payload: { protocol: 3 }
456
+ }
457
+ });
458
+ return;
459
+ }
444
460
  console.log(`[relay-client] New connect from ${userId} \u2014 creating fresh local WS for handshake`);
445
- this.createUserConnection(userId);
461
+ this.createUserConnection(userId, {
462
+ pendingConnect: null,
463
+ pendingMessages: conn.pendingMessages,
464
+ e2e: conn.e2e
465
+ });
446
466
  conn = this.userConnections.get(userId);
447
467
  if (!conn) return;
448
468
  }
@@ -463,6 +483,21 @@ var RelayClient = class {
463
483
  }
464
484
  if (!conn.connectHandshakeComplete) {
465
485
  conn.pendingMessages.push(msg);
486
+ if (!conn.pendingConnect) {
487
+ const autoConnect = this.buildAutoConnectRequest();
488
+ conn.pendingConnect = autoConnect;
489
+ console.log(`[relay-client] Auto-starting local connect handshake for ${userId} (${String(autoConnect.id)})`);
490
+ if (conn.challengeNonce) {
491
+ const pending = conn.pendingConnect;
492
+ conn.pendingConnect = null;
493
+ if (pending) {
494
+ this.injectDeviceIdentity(conn, pending);
495
+ if (conn.localWs.readyState === NodeWebSocket.OPEN) {
496
+ conn.localWs.send(JSON.stringify(pending));
497
+ }
498
+ }
499
+ }
500
+ }
466
501
  return;
467
502
  }
468
503
  if (conn.localWs.readyState === NodeWebSocket.CONNECTING) {
@@ -473,6 +508,26 @@ var RelayClient = class {
473
508
  }
474
509
  conn.localWs.send(JSON.stringify(msg));
475
510
  }
511
+ buildAutoConnectRequest() {
512
+ return {
513
+ type: "req",
514
+ id: `connect-auto-${++this.autoConnectCounter}`,
515
+ method: "connect",
516
+ params: {
517
+ minProtocol: 3,
518
+ maxProtocol: 3,
519
+ client: {
520
+ id: "cli",
521
+ version: "relay-client-auto",
522
+ platform: "gateway",
523
+ mode: "ui"
524
+ },
525
+ role: "operator",
526
+ scopes: ["operator.admin", "operator.read", "operator.write"],
527
+ auth: {}
528
+ }
529
+ };
530
+ }
476
531
  /**
477
532
  * Inject auth token and device identity into a connect request.
478
533
  *
@@ -523,7 +578,8 @@ var RelayClient = class {
523
578
  connectHandshakeComplete: false,
524
579
  challengeNonce: null,
525
580
  pendingConnect: carry?.pendingConnect ?? null,
526
- pendingMessages: carry?.pendingMessages ?? []
581
+ pendingMessages: carry?.pendingMessages ?? [],
582
+ lastSuccessfulConnectRequestId: null
527
583
  };
528
584
  this.userConnections.set(userId, conn);
529
585
  localWs.on("open", () => {
@@ -609,8 +665,9 @@ Device ID: ${this.deviceKeys.deviceId}`
609
665
  }
610
666
  }
611
667
  }
612
- if (parsed.type === "res" && parsed.id === "connect-1" && parsed.ok) {
668
+ if (parsed.type === "res" && typeof parsed.id === "string" && parsed.id.startsWith("connect-") && parsed.ok) {
613
669
  conn.connectHandshakeComplete = true;
670
+ conn.lastSuccessfulConnectRequestId = parsed.id;
614
671
  if (conn.pendingMessages.length > 0) {
615
672
  console.log(`[relay-client] Flushing ${conn.pendingMessages.length} buffered messages for ${userId}`);
616
673
  for (const queued of conn.pendingMessages) {
@@ -1256,8 +1313,7 @@ function resolveGatewayLayout() {
1256
1313
  }
1257
1314
  }
1258
1315
  const resolvedWorkspaces = Array.from(deduped.values());
1259
- const mainWorkspace = resolvedWorkspaces.find((ws) => ws.agentId === "main");
1260
- const defaultFileBrowserRoot = mainWorkspace?.path ?? stateDir;
1316
+ const defaultFileBrowserRoot = stateDir;
1261
1317
  return {
1262
1318
  stateDir,
1263
1319
  configPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squad-openclaw",
3
- "version": "2026.2.2022",
3
+ "version": "2026.2.2201",
4
4
  "description": "Entity registry, filesystem tools, and version management plugin for OpenClaw gateway",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",