@syengup/friday-channel-next 0.0.7 → 0.0.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/install.js +42 -15
- package/install.sh +58 -3
- package/package.json +1 -2
package/install.js
CHANGED
|
@@ -88,11 +88,7 @@ process.chdir(PLUGIN_DIR);
|
|
|
88
88
|
// --------------- install + build ---------------
|
|
89
89
|
|
|
90
90
|
log("Installing dependencies...");
|
|
91
|
-
|
|
92
|
-
execSync("pnpm install --frozen-lockfile", { stdio: "inherit" });
|
|
93
|
-
} catch {
|
|
94
|
-
execSync("pnpm install", { stdio: "inherit" });
|
|
95
|
-
}
|
|
91
|
+
execSync("pnpm install", { stdio: "inherit" });
|
|
96
92
|
|
|
97
93
|
log("Building TypeScript...");
|
|
98
94
|
execSync("pnpm build", { stdio: "inherit" });
|
|
@@ -148,15 +144,13 @@ console.log(" Config updated.");
|
|
|
148
144
|
log("Restarting OpenClaw gateway...");
|
|
149
145
|
execSync("openclaw gateway restart", { stdio: "inherit" });
|
|
150
146
|
|
|
151
|
-
// ---------------
|
|
147
|
+
// --------------- verify ---------------
|
|
152
148
|
|
|
153
149
|
function getLanIp() {
|
|
154
150
|
const nets = networkInterfaces();
|
|
155
151
|
for (const name of Object.keys(nets)) {
|
|
156
152
|
for (const net of nets[name]) {
|
|
157
|
-
if (net.family === "IPv4" && !net.internal)
|
|
158
|
-
return net.address;
|
|
159
|
-
}
|
|
153
|
+
if (net.family === "IPv4" && !net.internal) return net.address;
|
|
160
154
|
}
|
|
161
155
|
}
|
|
162
156
|
return "127.0.0.1";
|
|
@@ -166,14 +160,47 @@ const gatewayPort = config.gateway?.port || 18789;
|
|
|
166
160
|
const gatewayToken = config.gateway?.auth?.token || "(not set)";
|
|
167
161
|
const bindMode = config.gateway?.bind || "localhost";
|
|
168
162
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
+
const data = JSON.parse(res.body);
|
|
185
|
+
if (data.ok) {
|
|
186
|
+
log("Gateway verified OK (friday-next " + data.version + ", " + data.connections + " connections).");
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (i < retries) warn(`Gateway responded ${res.status}, retrying (${i}/${retries})...`);
|
|
191
|
+
} catch {
|
|
192
|
+
if (i < retries) warn(`Gateway not ready, retrying (${i}/${retries})...`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
warn("Gateway verification timed out — check 'openclaw gateway status' manually.");
|
|
196
|
+
return false;
|
|
175
197
|
}
|
|
176
198
|
|
|
199
|
+
log("Verifying gateway...");
|
|
200
|
+
await verifyGateway(gatewayUrl, gatewayToken);
|
|
201
|
+
|
|
202
|
+
// --------------- show connection info ---------------
|
|
203
|
+
|
|
177
204
|
const BOLD_YELLOW = (s) => `\x1b[1;33m${s}\x1b[0m`;
|
|
178
205
|
|
|
179
206
|
log("--------------------------------------------------");
|
package/install.sh
CHANGED
|
@@ -48,7 +48,7 @@ fi
|
|
|
48
48
|
cd "$PLUGIN_DIR"
|
|
49
49
|
|
|
50
50
|
log "Installing dependencies..."
|
|
51
|
-
pnpm install
|
|
51
|
+
pnpm install
|
|
52
52
|
|
|
53
53
|
log "Building TypeScript..."
|
|
54
54
|
pnpm build
|
|
@@ -109,6 +109,61 @@ 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
|
+
const data = JSON.parse(res.body);
|
|
152
|
+
if (data.ok) {
|
|
153
|
+
console.log(" Gateway verified OK (friday-next " + data.version + ", " + data.connections + " connections).");
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (i < 6) console.log(" ! Gateway responded " + res.status + ", retrying (" + i + "/6)...");
|
|
158
|
+
} catch {
|
|
159
|
+
if (i < 6) console.log(" ! Gateway not ready, retrying (" + i + "/6)...");
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
console.log(" ! Gateway verification timed out — check '\''openclaw gateway status'\'' manually.");
|
|
163
|
+
}
|
|
164
|
+
await verifyGateway();
|
|
165
|
+
' "$OPENCLAW_CONFIG"
|
|
166
|
+
|
|
112
167
|
# Show connection info
|
|
113
168
|
node --input-type=module -e '
|
|
114
169
|
import { readFileSync } from "node:fs";
|
|
@@ -131,7 +186,7 @@ const token = config.gateway?.auth?.token || "(not set)";
|
|
|
131
186
|
const bind = config.gateway?.bind || "localhost";
|
|
132
187
|
const host = bind === "lan" ? getLanIp() : "127.0.0.1";
|
|
133
188
|
|
|
134
|
-
const YB =
|
|
189
|
+
const YB = "\x1b[1;33m", N = "\x1b[0m";
|
|
135
190
|
const qrPayload = JSON.stringify({ url: "http://" + host + ":" + port, token: token });
|
|
136
191
|
let qrShown = false;
|
|
137
192
|
try {
|
|
@@ -143,7 +198,7 @@ try {
|
|
|
143
198
|
console.log("");
|
|
144
199
|
qrcode.generate(qrPayload, { small: true });
|
|
145
200
|
console.log("");
|
|
146
|
-
console.log("If QR scan
|
|
201
|
+
console.log("If QR scan does not work, enter manually:");
|
|
147
202
|
console.log("若二维码无法使用,请手动输入:");
|
|
148
203
|
qrShown = true;
|
|
149
204
|
} catch {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syengup/friday-channel-next",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "OpenClaw Friday Next Apple channel plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
"install.js",
|
|
10
10
|
"install.sh",
|
|
11
11
|
"tsconfig.json",
|
|
12
|
-
"pnpm-lock.yaml",
|
|
13
12
|
"openclaw.plugin.json"
|
|
14
13
|
],
|
|
15
14
|
"scripts": {
|