@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.
Files changed (2) hide show
  1. package/install.js +94 -93
  2. 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 via openclaw plugins ---------------
92
+ // --------------- install plugin package ---------------
93
93
 
94
- log("Installing Friday Next channel via openclaw plugins...");
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 --dangerously-force-unsafe-install @syengup/friday-channel-next@latest`,
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
- if (!existsSync(OPENCLAW_CONFIG)) {
122
- err(`OpenClaw config not found at ${OPENCLAW_CONFIG}`);
123
- err("Run openclaw at least once before installing plugins.");
124
- process.exit(1);
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
- // Configure OpenClaw
128
- log("Configuring OpenClaw...");
135
+ // --------------- configure OpenClaw ---------------
129
136
 
130
- let config;
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
- if (!config.plugins) config.plugins = {};
139
- if (!Array.isArray(config.plugins.allow)) config.plugins.allow = [];
140
- if (!config.plugins.allow.includes("friday-next")) {
141
- config.plugins.allow.push("friday-next");
142
- console.log(" + Added friday-next to plugins.allow");
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
- if (!config.plugins.entries) config.plugins.entries = {};
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
- if (!config.plugins.allow.includes("canvas")) {
155
- config.plugins.allow.push("canvas");
156
- console.log(" + Added canvas to plugins.allow");
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
- if (!config.plugins.entries["canvas"]) {
159
- config.plugins.entries["canvas"] = { enabled: true };
160
- console.log(" + Added canvas to plugins.entries (enabled)");
161
- } else if (!config.plugins.entries["canvas"].enabled) {
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
- if (!config.channels) config.channels = {};
167
- if (!config.channels["friday-next"]) {
168
- config.channels["friday-next"] = { enabled: true, transport: "http+sse" };
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
- if (!config.gateway) config.gateway = {};
182
- if (config.gateway.bind !== "lan") {
183
- config.gateway.bind = "lan";
184
- console.log(" + Set gateway.bind to lan");
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
- if (!config.agents) config.agents = {};
199
- if (!Array.isArray(config.agents.list)) config.agents.list = [];
200
- let mainAgent = config.agents.list.find((a) => a.id === "main");
201
- if (!mainAgent) { mainAgent = { id: "main" }; config.agents.list.push(mainAgent); }
202
- if (!mainAgent.tools) mainAgent.tools = {};
203
- if (!Array.isArray(mainAgent.tools.alsoAllow)) mainAgent.tools.alsoAllow = [];
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
- if (!mainAgent.tools.alsoAllow.includes(tool)) {
206
- mainAgent.tools.alsoAllow.push(tool);
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
- console.log(" Config updated.");
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
- warn("Manual install complete, but auto-upgrade is not available.");
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syengup/friday-channel-next",
3
- "version": "0.0.44",
3
+ "version": "0.0.46",
4
4
  "description": "OpenClaw Friday Next Apple channel plugin",
5
5
  "type": "module",
6
6
  "files": [