Spaces:
Running
Running
refactor: update gateway connection handshake parameters and scope permissions for health-server and wa-guardian
Browse files- health-server.js +9 -8
- wa-guardian.js +1 -1
health-server.js
CHANGED
|
@@ -7,7 +7,6 @@ const { randomUUID } = require("node:crypto");
|
|
| 7 |
const PORT = 7861;
|
| 8 |
const GATEWAY_PORT = 7860;
|
| 9 |
const GATEWAY_HOST = "127.0.0.1";
|
| 10 |
-
const GATEWAY_ORIGIN = `http://${GATEWAY_HOST}:${GATEWAY_PORT}`;
|
| 11 |
const startTime = Date.now();
|
| 12 |
const LLM_MODEL = process.env.LLM_MODEL || "Not Set";
|
| 13 |
const GATEWAY_TOKEN = process.env.GATEWAY_TOKEN || "";
|
|
@@ -86,12 +85,7 @@ function extractErrorMessage(msg) {
|
|
| 86 |
function createGatewayConnection() {
|
| 87 |
return new Promise((resolve, reject) => {
|
| 88 |
const { WebSocket } = require("/home/node/.openclaw/openclaw-app/node_modules/ws");
|
| 89 |
-
const ws = new WebSocket(
|
| 90 |
-
`ws://${GATEWAY_HOST}:${GATEWAY_PORT}/?token=${encodeURIComponent(GATEWAY_TOKEN)}`,
|
| 91 |
-
{
|
| 92 |
-
headers: { Origin: GATEWAY_ORIGIN },
|
| 93 |
-
},
|
| 94 |
-
);
|
| 95 |
let resolved = false;
|
| 96 |
|
| 97 |
ws.on("message", (data) => {
|
|
@@ -105,8 +99,15 @@ function createGatewayConnection() {
|
|
| 105 |
params: {
|
| 106 |
minProtocol: 3,
|
| 107 |
maxProtocol: 3,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
auth: { token: GATEWAY_TOKEN },
|
| 109 |
-
|
| 110 |
scopes: ["operator.read"],
|
| 111 |
},
|
| 112 |
}));
|
|
|
|
| 7 |
const PORT = 7861;
|
| 8 |
const GATEWAY_PORT = 7860;
|
| 9 |
const GATEWAY_HOST = "127.0.0.1";
|
|
|
|
| 10 |
const startTime = Date.now();
|
| 11 |
const LLM_MODEL = process.env.LLM_MODEL || "Not Set";
|
| 12 |
const GATEWAY_TOKEN = process.env.GATEWAY_TOKEN || "";
|
|
|
|
| 85 |
function createGatewayConnection() {
|
| 86 |
return new Promise((resolve, reject) => {
|
| 87 |
const { WebSocket } = require("/home/node/.openclaw/openclaw-app/node_modules/ws");
|
| 88 |
+
const ws = new WebSocket(`ws://${GATEWAY_HOST}:${GATEWAY_PORT}`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
let resolved = false;
|
| 90 |
|
| 91 |
ws.on("message", (data) => {
|
|
|
|
| 99 |
params: {
|
| 100 |
minProtocol: 3,
|
| 101 |
maxProtocol: 3,
|
| 102 |
+
client: {
|
| 103 |
+
id: "health-server",
|
| 104 |
+
version: "1.0.0",
|
| 105 |
+
platform: "linux",
|
| 106 |
+
mode: "backend",
|
| 107 |
+
},
|
| 108 |
+
caps: [],
|
| 109 |
auth: { token: GATEWAY_TOKEN },
|
| 110 |
+
role: "operator",
|
| 111 |
scopes: ["operator.read"],
|
| 112 |
},
|
| 113 |
}));
|
wa-guardian.js
CHANGED
|
@@ -71,7 +71,7 @@ async function createConnection() {
|
|
| 71 |
caps: [],
|
| 72 |
auth: { token: GATEWAY_TOKEN },
|
| 73 |
role: "operator",
|
| 74 |
-
scopes: ["operator.admin"],
|
| 75 |
},
|
| 76 |
}));
|
| 77 |
return;
|
|
|
|
| 71 |
caps: [],
|
| 72 |
auth: { token: GATEWAY_TOKEN },
|
| 73 |
role: "operator",
|
| 74 |
+
scopes: ["operator.read", "operator.write", "operator.admin", "operator.pairing"],
|
| 75 |
},
|
| 76 |
}));
|
| 77 |
return;
|