@syengup/friday-channel-next 0.0.8 → 0.0.10
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/install.js +64 -10
- package/install.sh +78 -2
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -144,15 +144,13 @@ console.log(" Config updated.");
|
|
|
144
144
|
log("Restarting OpenClaw gateway...");
|
|
145
145
|
execSync("openclaw gateway restart", { stdio: "inherit" });
|
|
146
146
|
|
|
147
|
-
// ---------------
|
|
147
|
+
// --------------- verify ---------------
|
|
148
148
|
|
|
149
149
|
function getLanIp() {
|
|
150
150
|
const nets = networkInterfaces();
|
|
151
151
|
for (const name of Object.keys(nets)) {
|
|
152
152
|
for (const net of nets[name]) {
|
|
153
|
-
if (net.family === "IPv4" && !net.internal)
|
|
154
|
-
return net.address;
|
|
155
|
-
}
|
|
153
|
+
if (net.family === "IPv4" && !net.internal) return net.address;
|
|
156
154
|
}
|
|
157
155
|
}
|
|
158
156
|
return "127.0.0.1";
|
|
@@ -162,14 +160,70 @@ const gatewayPort = config.gateway?.port || 18789;
|
|
|
162
160
|
const gatewayToken = config.gateway?.auth?.token || "(not set)";
|
|
163
161
|
const bindMode = config.gateway?.bind || "localhost";
|
|
164
162
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
163
|
+
const gatewayUrl = bindMode === "lan"
|
|
164
|
+
? `http://${getLanIp()}:${gatewayPort}`
|
|
165
|
+
: `http://127.0.0.1:${gatewayPort}`;
|
|
166
|
+
|
|
167
|
+
async function verifyGateway(url, token, retries = 6) {
|
|
168
|
+
const http = await import("node:http");
|
|
169
|
+
const { hostname, port } = new URL(url);
|
|
170
|
+
for (let i = 1; i <= retries; i++) {
|
|
171
|
+
await new Promise((r) => setTimeout(r, 1000));
|
|
172
|
+
try {
|
|
173
|
+
const res = await new Promise((resolve, reject) => {
|
|
174
|
+
const req = http.request(
|
|
175
|
+
{ hostname, port, path: "/friday-next/status", method: "GET",
|
|
176
|
+
headers: { authorization: `Bearer ${token}` }, timeout: 5000 },
|
|
177
|
+
(res) => { let body = ""; res.on("data", (c) => body += c); res.on("end", () => resolve({ status: res.statusCode, body })); },
|
|
178
|
+
);
|
|
179
|
+
req.on("error", reject);
|
|
180
|
+
req.on("timeout", () => { req.destroy(); reject(new Error("timeout")); });
|
|
181
|
+
req.end();
|
|
182
|
+
});
|
|
183
|
+
if (res.status === 200) {
|
|
184
|
+
try {
|
|
185
|
+
const data = JSON.parse(res.body);
|
|
186
|
+
if (data.ok) {
|
|
187
|
+
log("Gateway verified OK (friday-next " + data.version + ", " + data.connections + " connections).");
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
warn("Plugin responded but ok=false — " + JSON.stringify(data));
|
|
191
|
+
return false;
|
|
192
|
+
} catch {
|
|
193
|
+
// body is not JSON (e.g. HTML control panel) — plugin route not registered yet
|
|
194
|
+
if (i < 3) {
|
|
195
|
+
warn(`Plugin routes not registered yet, retrying (${i}/${retries})...`);
|
|
196
|
+
} else if (i < retries) {
|
|
197
|
+
warn(`Gateway is up but plugin routes missing — may need config reload, retrying (${i}/${retries})...`);
|
|
198
|
+
} else {
|
|
199
|
+
warn("Gateway is running but plugin routes were not loaded. Check plugin config in openclaw.json.");
|
|
200
|
+
}
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (res.status === 401) {
|
|
205
|
+
warn("Auth token mismatch — check gateway.auth.token in openclaw.json.");
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
if (res.status === 404) {
|
|
209
|
+
warn("Route /friday-next/status not found — plugin may not be loaded.");
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
if (i < retries) warn(`Gateway responded ${res.status}, retrying (${i}/${retries})...`);
|
|
213
|
+
} catch {
|
|
214
|
+
// Connection refused / timeout — gateway not running yet
|
|
215
|
+
if (i < retries) warn(`Gateway not reachable, retrying (${i}/${retries})...`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
warn("Gateway verification timed out — check 'openclaw gateway status' manually.");
|
|
219
|
+
return false;
|
|
171
220
|
}
|
|
172
221
|
|
|
222
|
+
log("Verifying gateway...");
|
|
223
|
+
await verifyGateway(gatewayUrl, gatewayToken);
|
|
224
|
+
|
|
225
|
+
// --------------- show connection info ---------------
|
|
226
|
+
|
|
173
227
|
const BOLD_YELLOW = (s) => `\x1b[1;33m${s}\x1b[0m`;
|
|
174
228
|
|
|
175
229
|
log("--------------------------------------------------");
|
package/install.sh
CHANGED
|
@@ -109,6 +109,82 @@ console.log(" Config updated.");
|
|
|
109
109
|
log "Restarting OpenClaw gateway..."
|
|
110
110
|
openclaw gateway restart
|
|
111
111
|
|
|
112
|
+
# Verify gateway is up
|
|
113
|
+
log "Verifying gateway..."
|
|
114
|
+
node --input-type=module -e '
|
|
115
|
+
import { readFileSync } from "node:fs";
|
|
116
|
+
import { networkInterfaces } from "node:os";
|
|
117
|
+
import http from "node:http";
|
|
118
|
+
|
|
119
|
+
const config = JSON.parse(readFileSync(process.argv[1], "utf8"));
|
|
120
|
+
|
|
121
|
+
function getLanIp() {
|
|
122
|
+
const nets = networkInterfaces();
|
|
123
|
+
for (const name of Object.keys(nets)) {
|
|
124
|
+
for (const net of nets[name]) {
|
|
125
|
+
if (net.family === "IPv4" && !net.internal) return net.address;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return "127.0.0.1";
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const port = config.gateway?.port || 18789;
|
|
132
|
+
const token = config.gateway?.auth?.token || "";
|
|
133
|
+
const bind = config.gateway?.bind || "localhost";
|
|
134
|
+
const host = bind === "lan" ? getLanIp() : "127.0.0.1";
|
|
135
|
+
|
|
136
|
+
async function verifyGateway() {
|
|
137
|
+
for (let i = 1; i <= 6; i++) {
|
|
138
|
+
await new Promise((r) => setTimeout(r, 1000));
|
|
139
|
+
try {
|
|
140
|
+
const res = await new Promise((resolve, reject) => {
|
|
141
|
+
const req = http.request(
|
|
142
|
+
{ hostname: host, port, path: "/friday-next/status", method: "GET",
|
|
143
|
+
headers: { authorization: "Bearer " + token }, timeout: 5000 },
|
|
144
|
+
(res) => { let body = ""; res.on("data", (c) => body += c); res.on("end", () => resolve({ status: res.statusCode, body })); },
|
|
145
|
+
);
|
|
146
|
+
req.on("error", reject);
|
|
147
|
+
req.on("timeout", () => { req.destroy(); reject(new Error("timeout")); });
|
|
148
|
+
req.end();
|
|
149
|
+
});
|
|
150
|
+
if (res.status === 200) {
|
|
151
|
+
try {
|
|
152
|
+
const data = JSON.parse(res.body);
|
|
153
|
+
if (data.ok) {
|
|
154
|
+
console.log(" Gateway verified OK (friday-next " + data.version + ", " + data.connections + " connections).");
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
console.log(" ! Plugin responded but ok=false — " + JSON.stringify(data));
|
|
158
|
+
return;
|
|
159
|
+
} catch {
|
|
160
|
+
if (i < 3) {
|
|
161
|
+
console.log(" ! Plugin routes not registered yet, retrying (" + i + "/6)...");
|
|
162
|
+
} else if (i < 6) {
|
|
163
|
+
console.log(" ! Gateway is up but plugin routes missing — may need config reload, retrying (" + i + "/6)...");
|
|
164
|
+
} else {
|
|
165
|
+
console.log(" ! Gateway is running but plugin routes were not loaded. Check plugin config in openclaw.json.");
|
|
166
|
+
}
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (res.status === 401) {
|
|
171
|
+
console.log(" ! Auth token mismatch — check gateway.auth.token in openclaw.json.");
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (res.status === 404) {
|
|
175
|
+
console.log(" ! Route /friday-next/status not found — plugin may not be loaded.");
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (i < 6) console.log(" ! Gateway responded " + res.status + ", retrying (" + i + "/6)...");
|
|
179
|
+
} catch {
|
|
180
|
+
if (i < 6) console.log(" ! Gateway not reachable, retrying (" + i + "/6)...");
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
console.log(" ! Gateway verification timed out — check '\''openclaw gateway status'\'' manually.");
|
|
184
|
+
}
|
|
185
|
+
await verifyGateway();
|
|
186
|
+
' "$OPENCLAW_CONFIG"
|
|
187
|
+
|
|
112
188
|
# Show connection info
|
|
113
189
|
node --input-type=module -e '
|
|
114
190
|
import { readFileSync } from "node:fs";
|
|
@@ -131,7 +207,7 @@ const token = config.gateway?.auth?.token || "(not set)";
|
|
|
131
207
|
const bind = config.gateway?.bind || "localhost";
|
|
132
208
|
const host = bind === "lan" ? getLanIp() : "127.0.0.1";
|
|
133
209
|
|
|
134
|
-
const YB =
|
|
210
|
+
const YB = "\x1b[1;33m", N = "\x1b[0m";
|
|
135
211
|
const qrPayload = JSON.stringify({ url: "http://" + host + ":" + port, token: token });
|
|
136
212
|
let qrShown = false;
|
|
137
213
|
try {
|
|
@@ -143,7 +219,7 @@ try {
|
|
|
143
219
|
console.log("");
|
|
144
220
|
qrcode.generate(qrPayload, { small: true });
|
|
145
221
|
console.log("");
|
|
146
|
-
console.log("If QR scan
|
|
222
|
+
console.log("If QR scan does not work, enter manually:");
|
|
147
223
|
console.log("若二维码无法使用,请手动输入:");
|
|
148
224
|
qrShown = true;
|
|
149
225
|
} catch {}
|