openclaw-bridge 0.4.2 → 0.4.6

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/cli.js CHANGED
@@ -676,18 +676,26 @@ async function cmdUpgrade() {
676
676
  // 1. Try installing/upgrading as OpenClaw plugin
677
677
  console.log("Checking OpenClaw plugin installation...");
678
678
  try {
679
- // First attempt: just try to install
680
- const installResult = run("openclaw plugins install openclaw-bridge 2>&1", { silent: true });
681
- if (installResult.includes("openclaw-bridge")) {
679
+ // Use execSync directly to capture both stdout and error output
680
+ let installOutput = "";
681
+ let installFailed = false;
682
+ try {
683
+ installOutput = execSync("openclaw plugins install openclaw-bridge 2>&1", {
684
+ encoding: "utf-8",
685
+ stdio: ["pipe", "pipe", "pipe"],
686
+ }).trim();
687
+ }
688
+ catch (execErr) {
689
+ installOutput = String(execErr?.stdout || "") + String(execErr?.stderr || "") + String(execErr?.message || "");
690
+ installFailed = true;
691
+ }
692
+ if (!installFailed && installOutput) {
682
693
  updatedPlugin = true;
683
694
  console.log(" Plugin installed/updated.");
684
695
  }
685
- }
686
- catch (installErr) {
687
- const errMsg = String(installErr?.stdout || installErr?.message || installErr || "");
688
- if (errMsg.includes("plugin already exists") || errMsg.includes("already exists")) {
696
+ else if (installOutput.includes("already exists")) {
689
697
  // Parse the existing path from error: "plugin already exists: /path/to/openclaw-bridge (delete it first)"
690
- const pathMatch = errMsg.match(/already exists:\s*(.+?)\s*\(/);
698
+ const pathMatch = installOutput.match(/already exists:\s*(.+?)\s*\(/);
691
699
  const existingPath = pathMatch?.[1]?.trim();
692
700
  if (existingPath && existsSync(existingPath)) {
693
701
  console.log(` Old plugin found at ${existingPath}. Removing...`);
@@ -716,14 +724,18 @@ async function cmdUpgrade() {
716
724
  console.log(" Plugin updated.");
717
725
  }
718
726
  catch {
719
- console.log(" Plugin install failed after removing old version. Try manually:");
727
+ console.log(" Plugin install failed. Try manually:");
720
728
  console.log(" openclaw plugins install openclaw-bridge");
721
729
  }
722
730
  }
723
731
  else {
724
- console.log(" openclaw CLI not found or plugins command failed. Skipping plugin check.");
732
+ // Install failed for unknown reason show the output for debugging
733
+ console.log(` Plugin install failed: ${installOutput.slice(0, 200)}`);
725
734
  }
726
735
  }
736
+ catch {
737
+ console.log(" openclaw CLI not found. Skipping plugin check.");
738
+ }
727
739
  // 2. Check if installed as global npm package
728
740
  console.log("\nChecking global npm installation...");
729
741
  try {
package/dist/index.js CHANGED
@@ -216,7 +216,12 @@ ${nameMapping}
216
216
  relayClient = new MessageRelayClient(config.agentId, config.messageRelay, api.logger, machineId);
217
217
  relayClient.setAgentName(config.agentName);
218
218
  relayClient.setOnConflictRename((newAgentId, newAgentName) => {
219
- api.logger.info(`[bridge] Conflict rename: ${entry.agentId} → ${newAgentId}, ${entry.agentName} → ${newAgentName}`);
219
+ const oldAgentId = entry.agentId;
220
+ api.logger.info(`[bridge] Conflict rename: ${oldAgentId} → ${newAgentId}, ${entry.agentName} → ${newAgentName}`);
221
+ // Deregister old agentId from Hub registry before switching
222
+ registry.deregister(oldAgentId).catch((err) => {
223
+ api.logger.warn(`[bridge] Failed to deregister old agentId "${oldAgentId}": ${err.message}`);
224
+ });
220
225
  entry.agentId = newAgentId;
221
226
  entry.agentName = newAgentName;
222
227
  // Persist the renamed agentId to openclaw.json so it survives restarts
@@ -1,4 +1,14 @@
1
1
  import WebSocket from 'ws';
2
+ import { readFileSync } from 'node:fs';
3
+ import { join, dirname } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ // Read version from package.json at module load time
6
+ let BRIDGE_VERSION = 'unknown';
7
+ try {
8
+ const pkgPath = join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json');
9
+ BRIDGE_VERSION = JSON.parse(readFileSync(pkgPath, 'utf-8')).version;
10
+ }
11
+ catch { }
2
12
  export class MessageRelayClient {
3
13
  ws = null;
4
14
  agentId;
@@ -69,6 +79,7 @@ export class MessageRelayClient {
69
79
  agentId: this.agentId,
70
80
  apiKey: this.config.apiKey,
71
81
  machineId: this.machineId,
82
+ bridgeVersion: BRIDGE_VERSION,
72
83
  }));
73
84
  });
74
85
  this.ws.on('message', (data) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-bridge",
3
- "version": "0.4.2",
3
+ "version": "0.4.6",
4
4
  "author": "Bill Zhao (https://www.linkedin.com/in/billzhaodi/)",
5
5
  "description": "OpenClaw plugin for cross-gateway communication — agent discovery, file transfer, real-time messaging, session handoff, and local process management. Install as plugin: openclaw plugins install openclaw-bridge",
6
6
  "type": "module",