@syengup/friday-channel-next 0.0.44 → 0.0.46
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 +94 -93
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { execSync } from "node:child_process";
|
|
3
|
-
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { existsSync, readFileSync, writeFileSync, rmSync } from "node:fs";
|
|
4
4
|
import { homedir, networkInterfaces } from "node:os";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
|
|
@@ -89,20 +89,26 @@ if (!hasOpenclaw()) {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
// --------------- install
|
|
92
|
+
// --------------- install plugin package ---------------
|
|
93
93
|
|
|
94
|
-
log("Installing Friday Next channel
|
|
94
|
+
log("Installing Friday Next channel plugin...");
|
|
95
95
|
let installed = false;
|
|
96
96
|
|
|
97
97
|
try {
|
|
98
|
-
// --dangerously-force-unsafe-install needed for child_process in device-approve / nodes-approve
|
|
99
98
|
const out = execSync(
|
|
100
|
-
`${openclawCmd} plugins install
|
|
99
|
+
`${openclawCmd} plugins install @syengup/friday-channel-next@latest`,
|
|
101
100
|
{ encoding: "utf8", stdio: "pipe", timeout: 120000 }
|
|
102
101
|
);
|
|
103
102
|
if (out.trim()) console.log(out.trim());
|
|
104
103
|
installed = true;
|
|
105
104
|
log("Plugin registered with install record — auto-upgrade enabled.");
|
|
105
|
+
|
|
106
|
+
// Remove old manual install to avoid "duplicate plugin id" warning.
|
|
107
|
+
const legacyDir = join(USER_HOME, ".openclaw", "extensions", "friday-channel-next");
|
|
108
|
+
if (existsSync(legacyDir)) {
|
|
109
|
+
try { rmSync(legacyDir, { recursive: true, force: true }); log("Removed legacy manual install."); }
|
|
110
|
+
catch { /* non-critical */ }
|
|
111
|
+
}
|
|
106
112
|
} catch (e) {
|
|
107
113
|
const msg = (e.stderr || e.stdout || e.message || "").toString();
|
|
108
114
|
warn("openclaw plugins install failed: " + msg.trim().split("\n").pop());
|
|
@@ -117,113 +123,109 @@ if (!installed) {
|
|
|
117
123
|
err("npm is required for manual install. Install Node.js first.");
|
|
118
124
|
process.exit(1);
|
|
119
125
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
126
|
+
warn("Manual install complete, but auto-upgrade is NOT available.");
|
|
127
|
+
warn("To enable auto-upgrade later, run: openclaw plugins install @syengup/friday-channel-next");
|
|
128
|
+
// Clean up legacy dir even in fallback to avoid duplicate warnings
|
|
129
|
+
if (existsSync(join(USER_HOME, ".openclaw", "extensions", "friday-channel-next"))) {
|
|
130
|
+
warn("Legacy install detected. Remove it to avoid duplicate warnings:");
|
|
131
|
+
warn(" rm -rf ~/.openclaw/extensions/friday-channel-next");
|
|
125
132
|
}
|
|
133
|
+
}
|
|
126
134
|
|
|
127
|
-
|
|
128
|
-
log("Configuring OpenClaw...");
|
|
135
|
+
// --------------- configure OpenClaw ---------------
|
|
129
136
|
|
|
130
|
-
|
|
131
|
-
try {
|
|
132
|
-
config = JSON.parse(readFileSync(OPENCLAW_CONFIG, "utf8"));
|
|
133
|
-
} catch {
|
|
134
|
-
err(`Failed to read ${OPENCLAW_CONFIG}.`);
|
|
135
|
-
process.exit(1);
|
|
136
|
-
}
|
|
137
|
+
log("Configuring OpenClaw...");
|
|
137
138
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
let config;
|
|
140
|
+
try {
|
|
141
|
+
config = JSON.parse(readFileSync(OPENCLAW_CONFIG, "utf8"));
|
|
142
|
+
} catch {
|
|
143
|
+
err(`Failed to read ${OPENCLAW_CONFIG}.`);
|
|
144
|
+
err("Make sure OpenClaw is installed and has been run at least once.");
|
|
145
|
+
process.exit(1);
|
|
146
|
+
}
|
|
144
147
|
|
|
145
|
-
|
|
146
|
-
if (!config.plugins.entries["friday-next"]) {
|
|
147
|
-
config.plugins.entries["friday-next"] = { enabled: true };
|
|
148
|
-
console.log(" + Added friday-next to plugins.entries (enabled)");
|
|
149
|
-
} else if (!config.plugins.entries["friday-next"].enabled) {
|
|
150
|
-
config.plugins.entries["friday-next"].enabled = true;
|
|
151
|
-
console.log(" + Enabled friday-next in plugins.entries");
|
|
152
|
-
}
|
|
148
|
+
let configChanged = false;
|
|
153
149
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
150
|
+
function setConfig(path, value) {
|
|
151
|
+
const keys = path.split(".");
|
|
152
|
+
let obj = config;
|
|
153
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
154
|
+
if (!obj[keys[i]] || typeof obj[keys[i]] !== "object" || Array.isArray(obj[keys[i]])) {
|
|
155
|
+
obj[keys[i]] = {};
|
|
156
|
+
}
|
|
157
|
+
obj = obj[keys[i]];
|
|
157
158
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
config.plugins.entries["canvas"].enabled = true;
|
|
163
|
-
console.log(" + Enabled canvas in plugins.entries");
|
|
159
|
+
const last = keys[keys.length - 1];
|
|
160
|
+
if (JSON.stringify(obj[last]) !== JSON.stringify(value)) {
|
|
161
|
+
obj[last] = value;
|
|
162
|
+
configChanged = true;
|
|
164
163
|
}
|
|
164
|
+
}
|
|
165
165
|
|
|
166
|
-
|
|
167
|
-
if (!
|
|
168
|
-
|
|
169
|
-
console.log(" + Added friday-next channel config");
|
|
170
|
-
} else {
|
|
171
|
-
if (!config.channels["friday-next"].enabled) {
|
|
172
|
-
config.channels["friday-next"].enabled = true;
|
|
173
|
-
console.log(" + Enabled friday-next channel");
|
|
174
|
-
}
|
|
175
|
-
if (!config.channels["friday-next"].transport) {
|
|
176
|
-
config.channels["friday-next"].transport = "http+sse";
|
|
177
|
-
console.log(" + Set friday-next transport to http+sse");
|
|
178
|
-
}
|
|
179
|
-
}
|
|
166
|
+
function ensureArrayContains(arr, item) {
|
|
167
|
+
if (!arr.includes(item)) { arr.push(item); configChanged = true; }
|
|
168
|
+
}
|
|
180
169
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (!config.gateway.nodes) config.gateway.nodes = {};
|
|
187
|
-
if (!Array.isArray(config.gateway.nodes.allowCommands)) config.gateway.nodes.allowCommands = [];
|
|
188
|
-
for (const cmd of [
|
|
189
|
-
"canvas.navigate", "canvas.present", "canvas.hide", "canvas.eval",
|
|
190
|
-
"canvas.snapshot", "canvas.a2ui.push", "canvas.a2ui.reset", "canvas.a2ui.pushJSONL",
|
|
191
|
-
]) {
|
|
192
|
-
if (!config.gateway.nodes.allowCommands.includes(cmd)) {
|
|
193
|
-
config.gateway.nodes.allowCommands.push(cmd);
|
|
194
|
-
console.log(" + Added " + cmd + " to gateway.nodes.allowCommands");
|
|
195
|
-
}
|
|
196
|
-
}
|
|
170
|
+
// Plugins
|
|
171
|
+
if (!config.plugins) config.plugins = {};
|
|
172
|
+
if (!Array.isArray(config.plugins.allow)) config.plugins.allow = [];
|
|
173
|
+
ensureArrayContains(config.plugins.allow, "friday-next");
|
|
174
|
+
ensureArrayContains(config.plugins.allow, "canvas");
|
|
197
175
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
if (!
|
|
202
|
-
|
|
203
|
-
|
|
176
|
+
if (!config.plugins.entries) config.plugins.entries = {};
|
|
177
|
+
for (const id of ["friday-next", "canvas"]) {
|
|
178
|
+
if (!config.plugins.entries[id]) { config.plugins.entries[id] = { enabled: true }; configChanged = true; }
|
|
179
|
+
else if (!config.plugins.entries[id].enabled) { config.plugins.entries[id].enabled = true; configChanged = true; }
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Channel
|
|
183
|
+
if (!config.channels) config.channels = {};
|
|
184
|
+
if (!config.channels["friday-next"]) { config.channels["friday-next"] = { enabled: true, transport: "http+sse" }; configChanged = true; }
|
|
185
|
+
else {
|
|
186
|
+
if (!config.channels["friday-next"].enabled) { config.channels["friday-next"].enabled = true; configChanged = true; }
|
|
187
|
+
if (!config.channels["friday-next"].transport) { config.channels["friday-next"].transport = "http+sse"; configChanged = true; }
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Gateway bind + nodes
|
|
191
|
+
if (!config.gateway) config.gateway = {};
|
|
192
|
+
if (config.gateway.bind !== "lan") { config.gateway.bind = "lan"; configChanged = true; }
|
|
193
|
+
if (!config.gateway.nodes) config.gateway.nodes = {};
|
|
194
|
+
if (!Array.isArray(config.gateway.nodes.allowCommands)) config.gateway.nodes.allowCommands = [];
|
|
195
|
+
for (const cmd of [
|
|
196
|
+
"canvas.navigate", "canvas.present", "canvas.hide", "canvas.eval",
|
|
197
|
+
"canvas.snapshot", "canvas.a2ui.push", "canvas.a2ui.reset", "canvas.a2ui.pushJSONL",
|
|
198
|
+
]) {
|
|
199
|
+
ensureArrayContains(config.gateway.nodes.allowCommands, cmd);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Agent tools
|
|
203
|
+
if (!config.agents) config.agents = {};
|
|
204
|
+
if (!Array.isArray(config.agents.list)) config.agents.list = [];
|
|
205
|
+
let mainAgent = config.agents.list.find((a) => a.id === "main");
|
|
206
|
+
if (!mainAgent) { mainAgent = { id: "main" }; config.agents.list.push(mainAgent); configChanged = true; }
|
|
207
|
+
if (!mainAgent.tools) mainAgent.tools = {};
|
|
208
|
+
if (!Array.isArray(mainAgent.tools.alsoAllow)) mainAgent.tools.alsoAllow = [];
|
|
209
|
+
for (const tool of ["canvas", "nodes"]) {
|
|
210
|
+
ensureArrayContains(mainAgent.tools.alsoAllow, tool);
|
|
211
|
+
}
|
|
212
|
+
if (Array.isArray(mainAgent.tools.deny)) {
|
|
204
213
|
for (const tool of ["canvas", "nodes"]) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
console.log(" + Added " + tool + " to agent 'main' tools.alsoAllow");
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
if (Array.isArray(mainAgent.tools.deny)) {
|
|
211
|
-
for (const tool of ["canvas", "nodes"]) {
|
|
212
|
-
const idx = mainAgent.tools.deny.indexOf(tool);
|
|
213
|
-
if (idx !== -1) { mainAgent.tools.deny.splice(idx, 1); console.log(" - Removed " + tool + " from agent 'main' tools.deny"); }
|
|
214
|
-
}
|
|
214
|
+
const idx = mainAgent.tools.deny.indexOf(tool);
|
|
215
|
+
if (idx !== -1) { mainAgent.tools.deny.splice(idx, 1); configChanged = true; }
|
|
215
216
|
}
|
|
217
|
+
}
|
|
216
218
|
|
|
219
|
+
if (configChanged) {
|
|
217
220
|
try {
|
|
218
221
|
writeFileSync(OPENCLAW_CONFIG, JSON.stringify(config, null, 2) + "\n", "utf8");
|
|
219
|
-
|
|
222
|
+
log("openclaw.json updated.");
|
|
220
223
|
} catch {
|
|
221
224
|
err(`Failed to write ${OPENCLAW_CONFIG}.`);
|
|
222
225
|
process.exit(1);
|
|
223
226
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
warn("To enable auto-upgrade, run: openclaw plugins install --dangerously-force-unsafe-install @syengup/friday-channel-next");
|
|
227
|
+
} else {
|
|
228
|
+
log("openclaw.json already configured.");
|
|
227
229
|
}
|
|
228
230
|
|
|
229
231
|
// --------------- restart gateway ---------------
|
|
@@ -250,7 +252,6 @@ function getLanIp() {
|
|
|
250
252
|
return "127.0.0.1";
|
|
251
253
|
}
|
|
252
254
|
|
|
253
|
-
let config;
|
|
254
255
|
try { config = JSON.parse(readFileSync(OPENCLAW_CONFIG, "utf8")); } catch { config = {}; }
|
|
255
256
|
|
|
256
257
|
const gatewayPort = config.gateway?.port || 18789;
|