openclaw-bridge 0.4.7 → 0.4.9
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 +16 -2
- package/dist/index.js +18 -7
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -823,14 +823,28 @@ function checkAndFixBridgeConfig() {
|
|
|
823
823
|
changed = true;
|
|
824
824
|
fixes++;
|
|
825
825
|
}
|
|
826
|
-
// Fix 3:
|
|
826
|
+
// Fix 3: Ensure gateway.auth is configured (needed for callGatewayAPI)
|
|
827
|
+
if (!config.gateway?.auth?.token) {
|
|
828
|
+
config.gateway = config.gateway || {};
|
|
829
|
+
config.gateway.auth = config.gateway.auth || {};
|
|
830
|
+
if (!config.gateway.auth.mode)
|
|
831
|
+
config.gateway.auth.mode = "token";
|
|
832
|
+
if (!config.gateway.auth.token) {
|
|
833
|
+
const token = `bridge-${bridgeConfig.agentId || "agent"}-${Date.now().toString(36)}`;
|
|
834
|
+
config.gateway.auth.token = token;
|
|
835
|
+
console.log(` [${configPath}] Added gateway.auth.token`);
|
|
836
|
+
changed = true;
|
|
837
|
+
fixes++;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
// Fix 4: Check required fields
|
|
827
841
|
const required = ["role", "agentId", "agentName"];
|
|
828
842
|
for (const field of required) {
|
|
829
843
|
if (!bridgeConfig[field]) {
|
|
830
844
|
console.log(` [${configPath}] WARNING: missing required field "${field}" in bridge config`);
|
|
831
845
|
}
|
|
832
846
|
}
|
|
833
|
-
// Fix
|
|
847
|
+
// Fix 5: Check fileRelay and registry baseUrls aren't pointing to localhost in remote setup
|
|
834
848
|
if (bridgeConfig.registry?.baseUrl && bridgeConfig.fileRelay?.baseUrl) {
|
|
835
849
|
const regUrl = bridgeConfig.registry.baseUrl;
|
|
836
850
|
const relayUrl = bridgeConfig.fileRelay.baseUrl;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync } from "node:fs";
|
|
1
|
+
import { readFileSync, writeFileSync, existsSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
2
4
|
import { Type } from "@sinclair/typebox";
|
|
3
5
|
import { parseConfig, getMachineId } from "./config.js";
|
|
4
6
|
import { BridgeRegistry } from "./registry.js";
|
|
@@ -254,14 +256,23 @@ ${nameMapping}
|
|
|
254
256
|
}
|
|
255
257
|
// Helper: call local gateway chat completions API
|
|
256
258
|
async function callGatewayAPI(payload) {
|
|
257
|
-
const configPath = process.env.OPENCLAW_CONFIG_PATH
|
|
258
|
-
|| `${process.env.OPENCLAW_HOME || ''}/openclaw.json`;
|
|
259
259
|
let gatewayToken = '';
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
260
|
+
const configCandidates = [
|
|
261
|
+
process.env.OPENCLAW_CONFIG_PATH,
|
|
262
|
+
process.env.OPENCLAW_HOME ? `${process.env.OPENCLAW_HOME}/openclaw.json` : '',
|
|
263
|
+
join(homedir(), '.openclaw', 'openclaw.json'),
|
|
264
|
+
].filter(Boolean);
|
|
265
|
+
for (const cp of configCandidates) {
|
|
266
|
+
try {
|
|
267
|
+
if (!existsSync(cp))
|
|
268
|
+
continue;
|
|
269
|
+
const raw = JSON.parse(readFileSync(cp, 'utf-8'));
|
|
270
|
+
gatewayToken = raw.gateway?.auth?.token || '';
|
|
271
|
+
if (gatewayToken)
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
catch { /* try next */ }
|
|
263
275
|
}
|
|
264
|
-
catch { /* no token */ }
|
|
265
276
|
// Check if payload is multimodal JSON (from Hub chat with image)
|
|
266
277
|
let messages;
|
|
267
278
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openclaw-bridge",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
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",
|