openclaw-telegram-manager 1.0.1 → 1.1.1
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/README.md +10 -0
- package/dist/setup.js +214 -163
- package/dist/setup.js.map +1 -1
- package/openclaw.plugin.json +6 -3
- package/package.json +1 -1
- package/src/setup.ts +235 -190
package/README.md
CHANGED
|
@@ -25,6 +25,8 @@ npx openclaw-telegram-manager setup
|
|
|
25
25
|
|
|
26
26
|
That's it. The setup script installs the plugin, patches your config, creates the workspace, and restarts the OpenClaw gateway. It's idempotent — running it twice won't break anything.
|
|
27
27
|
|
|
28
|
+
**Security warnings during install:** OpenClaw's automatic scanner may flag `child_process` and `process.env` usage. These are expected — the setup script calls `openclaw --version`, `openclaw plugins install`, and `openclaw gateway restart`, and reads `process.env` for config directory detection. No data is sent externally.
|
|
29
|
+
|
|
28
30
|
Once that's done, head to your Telegram group:
|
|
29
31
|
|
|
30
32
|
1. Open any topic
|
|
@@ -92,6 +94,14 @@ The first person to run `/topic init` automatically becomes admin.
|
|
|
92
94
|
|
|
93
95
|
See [SECURITY.md](SECURITY.md) for reporting vulnerabilities.
|
|
94
96
|
|
|
97
|
+
## Uninstalling
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
npx openclaw-telegram-manager uninstall
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
This removes the plugin extension files, the `$include` reference from `openclaw.json`, and the generated include file, then restarts the gateway. Workspace data (your topic capsules) is kept — the command prints the path if you want to remove it manually.
|
|
104
|
+
|
|
95
105
|
## Contributing
|
|
96
106
|
|
|
97
107
|
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
package/dist/setup.js
CHANGED
|
@@ -3,97 +3,143 @@ import * as fs from 'node:fs';
|
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import * as crypto from 'node:crypto';
|
|
5
5
|
import { execSync } from 'node:child_process';
|
|
6
|
-
import * as readline from 'node:readline';
|
|
7
6
|
// ── Constants ──────────────────────────────────────────────────────────
|
|
7
|
+
const PLUGIN_NAME = 'openclaw-telegram-manager';
|
|
8
|
+
const PLUGIN_VERSION = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf-8')).version;
|
|
8
9
|
const MIN_OPENCLAW_VERSION = '2026.1.0';
|
|
9
10
|
const INCLUDE_FILENAME = 'telegram-manager.generated.groups.json5';
|
|
10
11
|
const REGISTRY_FILENAME = 'topics.json';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const PLUGIN_FILES = ['openclaw.plugin.json', 'src', 'skills', 'package.json'];
|
|
13
|
+
// ── Colors (zero dependencies, respects NO_COLOR / non-TTY) ──────────
|
|
14
|
+
const useColor = process.stdout.isTTY === true &&
|
|
15
|
+
!process.env['NO_COLOR'] &&
|
|
16
|
+
process.env['TERM'] !== 'dumb';
|
|
17
|
+
const c = {
|
|
18
|
+
reset: useColor ? '\x1b[0m' : '',
|
|
19
|
+
bold: useColor ? '\x1b[1m' : '',
|
|
20
|
+
dim: useColor ? '\x1b[2m' : '',
|
|
21
|
+
green: useColor ? '\x1b[32m' : '',
|
|
22
|
+
yellow: useColor ? '\x1b[33m' : '',
|
|
23
|
+
red: useColor ? '\x1b[31m' : '',
|
|
24
|
+
cyan: useColor ? '\x1b[36m' : '',
|
|
25
|
+
magenta: useColor ? '\x1b[35m' : '',
|
|
26
|
+
};
|
|
27
|
+
// ── Logging helpers ───────────────────────────────────────────────────
|
|
28
|
+
function ok(msg) {
|
|
29
|
+
console.log(` ${c.green}✓${c.reset} ${msg}`);
|
|
30
|
+
}
|
|
31
|
+
function warn(msg) {
|
|
32
|
+
console.warn(` ${c.yellow}⚠${c.reset} ${c.yellow}${msg}${c.reset}`);
|
|
33
|
+
}
|
|
34
|
+
function fail(msg) {
|
|
35
|
+
console.error(` ${c.red}✗${c.reset} ${c.red}${msg}${c.reset}`);
|
|
36
|
+
}
|
|
37
|
+
function info(msg) {
|
|
38
|
+
console.log(` ${c.dim}${msg}${c.reset}`);
|
|
39
|
+
}
|
|
40
|
+
function banner(title, subtitle) {
|
|
41
|
+
console.log('');
|
|
42
|
+
console.log(` ${c.cyan}◆${c.reset} ${c.bold}${title}${c.reset}${subtitle ? ` ${c.dim}${subtitle}${c.reset}` : ''}`);
|
|
43
|
+
console.log(` ${c.dim}│${c.reset}`);
|
|
44
|
+
}
|
|
45
|
+
function footer(msg) {
|
|
46
|
+
console.log(` ${c.dim}│${c.reset}`);
|
|
47
|
+
console.log(` ${c.green}◆${c.reset} ${c.bold}${msg}${c.reset}`);
|
|
48
|
+
console.log('');
|
|
49
|
+
}
|
|
50
|
+
// ── Entry point ───────────────────────────────────────────────────────
|
|
51
|
+
const command = process.argv[2] ?? 'setup';
|
|
52
|
+
if (command === 'setup') {
|
|
53
|
+
runSetup().catch((err) => {
|
|
54
|
+
console.error('Setup failed:', err instanceof Error ? err.message : String(err));
|
|
55
|
+
process.exit(1);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else if (command === 'uninstall') {
|
|
59
|
+
runUninstall().catch((err) => {
|
|
60
|
+
console.error('Uninstall failed:', err instanceof Error ? err.message : String(err));
|
|
61
|
+
process.exit(1);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
console.error(`Unknown command: ${command}`);
|
|
66
|
+
console.error(`Usage: ${PLUGIN_NAME} [setup|uninstall]`);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
// ── Setup ─────────────────────────────────────────────────────────────
|
|
70
|
+
async function runSetup() {
|
|
71
|
+
banner(PLUGIN_NAME, `v${PLUGIN_VERSION}`);
|
|
16
72
|
const version = checkOpenClawVersion();
|
|
17
|
-
|
|
18
|
-
// Step 2: Locate config directory
|
|
73
|
+
ok(`OpenClaw ${c.dim}${version}${c.reset}`);
|
|
19
74
|
const configDir = locateConfigDir();
|
|
20
|
-
console.log(`[2/11] Config directory: ${configDir}`);
|
|
21
|
-
// Step 3: Check directory permissions
|
|
22
75
|
checkDirPermissions(configDir);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
installPlugin();
|
|
26
|
-
console.log('[4/11] Plugin installation checked');
|
|
27
|
-
// Step 5: Patch openclaw.json with $include reference
|
|
76
|
+
ok(`Config ${c.dim}${configDir}${c.reset}`);
|
|
77
|
+
installPlugin(configDir);
|
|
28
78
|
patchConfig(configDir);
|
|
29
|
-
|
|
30
|
-
// Step 6: Create workspace directory structure
|
|
31
|
-
const workspaceDir = path.join(configDir, 'workspace');
|
|
32
|
-
const projectsDir = path.join(workspaceDir, 'projects');
|
|
79
|
+
const projectsDir = path.join(configDir, 'workspace', 'projects');
|
|
33
80
|
ensureDir(projectsDir);
|
|
34
|
-
console.log(`[6/11] Workspace directory: ${projectsDir}`);
|
|
35
|
-
// Step 7: Initialize empty registry
|
|
36
81
|
initRegistry(projectsDir);
|
|
37
|
-
console.log('[7/11] Registry initialized');
|
|
38
|
-
// Step 8: Create empty generated include
|
|
39
82
|
createEmptyInclude(configDir);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
83
|
+
ok('Workspace ready');
|
|
84
|
+
triggerRestart();
|
|
85
|
+
ok('Gateway restarted');
|
|
86
|
+
footer('Setup complete');
|
|
87
|
+
console.log(` ${c.dim}Next steps:${c.reset}`);
|
|
88
|
+
console.log(` ${c.dim}1.${c.reset} Open any Telegram forum topic`);
|
|
89
|
+
console.log(` ${c.dim}2.${c.reset} Type ${c.cyan}/topic init${c.reset}`);
|
|
90
|
+
console.log(` ${c.dim}3.${c.reset} The topic will be registered and a capsule created`);
|
|
91
|
+
console.log('');
|
|
92
|
+
}
|
|
93
|
+
// ── Uninstall ─────────────────────────────────────────────────────────
|
|
94
|
+
async function runUninstall() {
|
|
95
|
+
banner(PLUGIN_NAME, 'uninstall');
|
|
96
|
+
const configDir = locateConfigDir();
|
|
97
|
+
ok(`Config ${c.dim}${configDir}${c.reset}`);
|
|
98
|
+
unpatchConfig(configDir);
|
|
99
|
+
removeFile(path.join(configDir, INCLUDE_FILENAME));
|
|
100
|
+
removePluginDir(configDir);
|
|
101
|
+
ok('Plugin files removed');
|
|
102
|
+
triggerRestart();
|
|
103
|
+
ok('Gateway restarted');
|
|
104
|
+
const projectsDir = path.join(configDir, 'workspace', 'projects');
|
|
105
|
+
if (fs.existsSync(projectsDir)) {
|
|
106
|
+
info('Workspace data kept: ' + projectsDir);
|
|
107
|
+
info('To remove: rm -rf ' + projectsDir);
|
|
50
108
|
}
|
|
51
|
-
|
|
52
|
-
console.log('[9/11] Skipped cron setup');
|
|
53
|
-
}
|
|
54
|
-
// Step 10: Trigger gateway restart
|
|
55
|
-
triggerRestart(configDir);
|
|
56
|
-
console.log('[10/11] Gateway restart triggered');
|
|
57
|
-
// Step 11: Print summary
|
|
58
|
-
printSummary(configDir, projectsDir);
|
|
59
|
-
console.log('[11/11] Setup complete!\n');
|
|
109
|
+
footer('Uninstall complete');
|
|
60
110
|
}
|
|
61
|
-
// ──
|
|
111
|
+
// ── Setup step implementations ────────────────────────────────────────
|
|
62
112
|
function checkOpenClawVersion() {
|
|
63
113
|
let version;
|
|
64
114
|
try {
|
|
65
115
|
version = execSync('openclaw --version', { encoding: 'utf-8' }).trim();
|
|
66
116
|
}
|
|
67
117
|
catch {
|
|
68
|
-
|
|
118
|
+
fail('OpenClaw not found. Install OpenClaw (>=2026.1.0) first.');
|
|
69
119
|
process.exit(1);
|
|
70
120
|
}
|
|
71
|
-
// Extract version number (e.g., "openclaw 2026.2.0" -> "2026.2.0")
|
|
72
121
|
const match = version.match(/(\d+\.\d+\.\d+)/);
|
|
73
122
|
if (!match) {
|
|
74
|
-
|
|
123
|
+
warn(`Could not parse version from "${version}". Proceeding anyway.`);
|
|
75
124
|
return version;
|
|
76
125
|
}
|
|
77
126
|
const versionStr = match[1];
|
|
78
127
|
if (compareVersions(versionStr, MIN_OPENCLAW_VERSION) < 0) {
|
|
79
|
-
|
|
128
|
+
fail(`OpenClaw ${versionStr} found, requires >=${MIN_OPENCLAW_VERSION}. Please upgrade.`);
|
|
80
129
|
process.exit(1);
|
|
81
130
|
}
|
|
82
131
|
return versionStr;
|
|
83
132
|
}
|
|
84
133
|
function locateConfigDir() {
|
|
85
|
-
// Check environment variable
|
|
86
134
|
const envDir = process.env['OPENCLAW_CONFIG_DIR'];
|
|
87
135
|
if (envDir && fs.existsSync(envDir)) {
|
|
88
136
|
return path.resolve(envDir);
|
|
89
137
|
}
|
|
90
|
-
// Check default location
|
|
91
138
|
const homeDir = process.env['HOME'] ?? process.env['USERPROFILE'] ?? '';
|
|
92
139
|
const defaultDir = path.join(homeDir, '.openclaw');
|
|
93
140
|
if (fs.existsSync(defaultDir)) {
|
|
94
141
|
return defaultDir;
|
|
95
142
|
}
|
|
96
|
-
// Walk up from cwd looking for openclaw.json
|
|
97
143
|
let dir = process.cwd();
|
|
98
144
|
while (dir !== path.dirname(dir)) {
|
|
99
145
|
if (fs.existsSync(path.join(dir, 'openclaw.json'))) {
|
|
@@ -101,7 +147,7 @@ function locateConfigDir() {
|
|
|
101
147
|
}
|
|
102
148
|
dir = path.dirname(dir);
|
|
103
149
|
}
|
|
104
|
-
|
|
150
|
+
fail('Could not find OpenClaw config directory. Set $OPENCLAW_CONFIG_DIR or ensure ~/.openclaw/ exists.');
|
|
105
151
|
process.exit(1);
|
|
106
152
|
}
|
|
107
153
|
function checkDirPermissions(dir) {
|
|
@@ -109,94 +155,90 @@ function checkDirPermissions(dir) {
|
|
|
109
155
|
const stat = fs.statSync(dir);
|
|
110
156
|
const mode = stat.mode;
|
|
111
157
|
const permissions = (mode & 0o777).toString(8);
|
|
112
|
-
// Check for world-writable or group-writable
|
|
113
158
|
if (mode & 0o002) {
|
|
114
|
-
|
|
159
|
+
warn(`${dir} is world-writable (${permissions}). Consider chmod 700.`);
|
|
115
160
|
}
|
|
116
161
|
else if (mode & 0o020) {
|
|
117
|
-
|
|
162
|
+
warn(`${dir} is group-writable (${permissions}). Consider chmod 700.`);
|
|
118
163
|
}
|
|
119
164
|
}
|
|
120
165
|
catch {
|
|
121
|
-
|
|
166
|
+
warn(`Could not check permissions for ${dir}.`);
|
|
122
167
|
}
|
|
123
168
|
}
|
|
124
|
-
function installPlugin() {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
console.log(' Plugin already installed, skipping.');
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
169
|
+
function installPlugin(configDir) {
|
|
170
|
+
const extDir = path.join(configDir, 'extensions', PLUGIN_NAME);
|
|
171
|
+
if (fs.existsSync(path.join(extDir, 'openclaw.plugin.json'))) {
|
|
172
|
+
ok('Plugin already installed');
|
|
173
|
+
return;
|
|
132
174
|
}
|
|
133
|
-
|
|
134
|
-
|
|
175
|
+
const pkgRoot = findPackageRoot();
|
|
176
|
+
if (pkgRoot) {
|
|
177
|
+
fs.mkdirSync(extDir, { recursive: true });
|
|
178
|
+
for (const entry of PLUGIN_FILES) {
|
|
179
|
+
const src = path.join(pkgRoot, entry);
|
|
180
|
+
if (!fs.existsSync(src))
|
|
181
|
+
continue;
|
|
182
|
+
copyRecursive(src, path.join(extDir, entry));
|
|
183
|
+
}
|
|
184
|
+
installDeps(extDir);
|
|
185
|
+
ok('Plugin installed');
|
|
186
|
+
return;
|
|
135
187
|
}
|
|
136
188
|
try {
|
|
137
|
-
execSync(
|
|
189
|
+
execSync(`openclaw plugins install ${PLUGIN_NAME}`, {
|
|
138
190
|
encoding: 'utf-8',
|
|
139
191
|
stdio: 'inherit',
|
|
140
192
|
});
|
|
193
|
+
ok('Plugin installed');
|
|
141
194
|
}
|
|
142
195
|
catch {
|
|
143
|
-
|
|
196
|
+
warn('Could not install plugin. You may need to install manually.');
|
|
144
197
|
}
|
|
145
198
|
}
|
|
146
199
|
function patchConfig(configDir) {
|
|
147
200
|
const configPath = path.join(configDir, 'openclaw.json');
|
|
148
201
|
if (!fs.existsSync(configPath)) {
|
|
149
|
-
|
|
202
|
+
warn(`${configPath} not found. Skipping config patch.`);
|
|
150
203
|
return;
|
|
151
204
|
}
|
|
152
205
|
let content;
|
|
153
206
|
try {
|
|
154
207
|
content = fs.readFileSync(configPath, 'utf-8');
|
|
155
208
|
}
|
|
156
|
-
catch
|
|
157
|
-
|
|
209
|
+
catch {
|
|
210
|
+
warn(`Could not read ${configPath}. Skipping config patch.`);
|
|
158
211
|
return;
|
|
159
212
|
}
|
|
160
|
-
// Check if $include reference already exists
|
|
161
213
|
if (content.includes(INCLUDE_FILENAME)) {
|
|
162
|
-
|
|
214
|
+
ok('Config already patched');
|
|
163
215
|
return;
|
|
164
216
|
}
|
|
165
|
-
// Parse as JSON (OpenClaw config may be JSON or JSON5)
|
|
166
217
|
let config;
|
|
167
218
|
try {
|
|
168
219
|
config = JSON.parse(content);
|
|
169
220
|
}
|
|
170
221
|
catch {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
console.warn(` Add to channels.telegram.groups: { "$include": "./${INCLUDE_FILENAME}" }`);
|
|
222
|
+
warn('Could not parse openclaw.json. Please manually add the $include reference.');
|
|
223
|
+
info(`Add to channels.telegram.groups: { "$include": "./${INCLUDE_FILENAME}" }`);
|
|
174
224
|
return;
|
|
175
225
|
}
|
|
176
|
-
// Ensure path exists: channels.telegram.groups
|
|
177
226
|
if (!config['channels'])
|
|
178
227
|
config['channels'] = {};
|
|
179
228
|
const channels = config['channels'];
|
|
180
229
|
if (!channels['telegram'])
|
|
181
230
|
channels['telegram'] = {};
|
|
182
231
|
const telegram = channels['telegram'];
|
|
183
|
-
// Set groups to $include
|
|
184
232
|
telegram['groups'] = { $include: `./${INCLUDE_FILENAME}` };
|
|
185
|
-
// Backup and write
|
|
186
233
|
const bakPath = configPath + '.bak';
|
|
187
234
|
fs.copyFileSync(configPath, bakPath);
|
|
188
235
|
const newContent = JSON.stringify(config, null, 2) + '\n';
|
|
189
236
|
fs.writeFileSync(configPath, newContent, { mode: 0o600 });
|
|
190
|
-
|
|
191
|
-
function ensureDir(dir) {
|
|
192
|
-
if (!fs.existsSync(dir)) {
|
|
193
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
194
|
-
}
|
|
237
|
+
ok('Config patched');
|
|
195
238
|
}
|
|
196
239
|
function initRegistry(projectsDir) {
|
|
197
240
|
const registryPath = path.join(projectsDir, REGISTRY_FILENAME);
|
|
198
241
|
if (fs.existsSync(registryPath)) {
|
|
199
|
-
console.log(' Registry already exists, skipping initialization.');
|
|
200
242
|
return;
|
|
201
243
|
}
|
|
202
244
|
const callbackSecret = crypto.randomBytes(32).toString('hex');
|
|
@@ -215,7 +257,6 @@ function initRegistry(projectsDir) {
|
|
|
215
257
|
function createEmptyInclude(configDir) {
|
|
216
258
|
const includePath = path.join(configDir, INCLUDE_FILENAME);
|
|
217
259
|
if (fs.existsSync(includePath)) {
|
|
218
|
-
console.log(' Include file already exists, skipping.');
|
|
219
260
|
return;
|
|
220
261
|
}
|
|
221
262
|
const content = [
|
|
@@ -225,45 +266,60 @@ function createEmptyInclude(configDir) {
|
|
|
225
266
|
].join('\n');
|
|
226
267
|
fs.writeFileSync(includePath, content, { mode: 0o600 });
|
|
227
268
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const
|
|
232
|
-
if (fs.existsSync(
|
|
233
|
-
console.log(' Cron job already exists, skipping.');
|
|
269
|
+
// ── Uninstall step implementations ────────────────────────────────────
|
|
270
|
+
function unpatchConfig(configDir) {
|
|
271
|
+
const configPath = path.join(configDir, 'openclaw.json');
|
|
272
|
+
const bakPath = configPath + '.bak';
|
|
273
|
+
if (!fs.existsSync(configPath)) {
|
|
234
274
|
return;
|
|
235
275
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
276
|
+
let content;
|
|
277
|
+
try {
|
|
278
|
+
content = fs.readFileSync(configPath, 'utf-8');
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
warn(`Could not read ${configPath}.`);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (!content.includes(INCLUDE_FILENAME)) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
let config;
|
|
288
|
+
try {
|
|
289
|
+
config = JSON.parse(content);
|
|
290
|
+
}
|
|
291
|
+
catch {
|
|
292
|
+
warn('Could not parse openclaw.json. Please manually remove the $include reference.');
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
const channels = config['channels'];
|
|
296
|
+
const telegram = channels?.['telegram'];
|
|
297
|
+
if (telegram) {
|
|
298
|
+
delete telegram['groups'];
|
|
299
|
+
if (Object.keys(telegram).length === 0)
|
|
300
|
+
delete channels['telegram'];
|
|
301
|
+
if (Object.keys(channels).length === 0)
|
|
302
|
+
delete config['channels'];
|
|
303
|
+
}
|
|
304
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n', { mode: 0o600 });
|
|
305
|
+
// Clean up stale backup from install time
|
|
306
|
+
if (fs.existsSync(bakPath)) {
|
|
307
|
+
fs.unlinkSync(bakPath);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
function removeFile(filePath) {
|
|
311
|
+
if (fs.existsSync(filePath)) {
|
|
312
|
+
fs.unlinkSync(filePath);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function removePluginDir(configDir) {
|
|
316
|
+
const extDir = path.join(configDir, 'extensions', PLUGIN_NAME);
|
|
317
|
+
if (fs.existsSync(extDir)) {
|
|
318
|
+
fs.rmSync(extDir, { recursive: true });
|
|
264
319
|
}
|
|
265
320
|
}
|
|
266
|
-
|
|
321
|
+
// ── Shared helpers ────────────────────────────────────────────────────
|
|
322
|
+
function triggerRestart() {
|
|
267
323
|
try {
|
|
268
324
|
execSync('openclaw gateway restart', {
|
|
269
325
|
encoding: 'utf-8',
|
|
@@ -271,24 +327,14 @@ function triggerRestart(configDir) {
|
|
|
271
327
|
});
|
|
272
328
|
}
|
|
273
329
|
catch {
|
|
274
|
-
|
|
330
|
+
warn('Could not restart gateway. Run `openclaw gateway restart` manually.');
|
|
275
331
|
}
|
|
276
332
|
}
|
|
277
|
-
function
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
console.log(` - Config directory: ${configDir}`);
|
|
282
|
-
console.log(` - Projects directory: ${projectsDir}`);
|
|
283
|
-
console.log(` - Registry: ${path.join(projectsDir, REGISTRY_FILENAME)}`);
|
|
284
|
-
console.log(` - Include: ${path.join(configDir, INCLUDE_FILENAME)}`);
|
|
285
|
-
console.log('\nNext steps:');
|
|
286
|
-
console.log(' 1. Go to any Telegram forum topic');
|
|
287
|
-
console.log(' 2. Type /topic init');
|
|
288
|
-
console.log(' 3. The topic will be registered and a capsule created');
|
|
289
|
-
console.log('\nFor help: /topic help');
|
|
333
|
+
function ensureDir(dir) {
|
|
334
|
+
if (!fs.existsSync(dir)) {
|
|
335
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
336
|
+
}
|
|
290
337
|
}
|
|
291
|
-
// ── Helpers ───────────────────────────────────────────────────────────
|
|
292
338
|
function compareVersions(a, b) {
|
|
293
339
|
const aParts = a.split('.').map(Number);
|
|
294
340
|
const bParts = b.split('.').map(Number);
|
|
@@ -300,34 +346,39 @@ function compareVersions(a, b) {
|
|
|
300
346
|
}
|
|
301
347
|
return 0;
|
|
302
348
|
}
|
|
303
|
-
function
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
rl.close();
|
|
311
|
-
const normalized = answer.trim().toLowerCase();
|
|
312
|
-
resolve(normalized === '' || normalized === 'y' || normalized === 'yes');
|
|
349
|
+
function installDeps(dir) {
|
|
350
|
+
try {
|
|
351
|
+
execSync('npm install --production --ignore-scripts', {
|
|
352
|
+
cwd: dir,
|
|
353
|
+
encoding: 'utf-8',
|
|
354
|
+
stdio: 'pipe',
|
|
355
|
+
timeout: 60_000,
|
|
313
356
|
});
|
|
314
|
-
}
|
|
357
|
+
}
|
|
358
|
+
catch {
|
|
359
|
+
warn('Could not install dependencies. Run `npm install --production` in ' + dir);
|
|
360
|
+
}
|
|
315
361
|
}
|
|
316
|
-
function
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
362
|
+
function findPackageRoot() {
|
|
363
|
+
let dir = path.dirname(new URL(import.meta.url).pathname);
|
|
364
|
+
for (let i = 0; i < 5; i++) {
|
|
365
|
+
if (fs.existsSync(path.join(dir, 'openclaw.plugin.json'))) {
|
|
366
|
+
return dir;
|
|
367
|
+
}
|
|
368
|
+
dir = path.dirname(dir);
|
|
369
|
+
}
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
function copyRecursive(src, dest) {
|
|
373
|
+
const stat = fs.statSync(src);
|
|
374
|
+
if (stat.isDirectory()) {
|
|
375
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
376
|
+
for (const entry of fs.readdirSync(src)) {
|
|
377
|
+
copyRecursive(path.join(src, entry), path.join(dest, entry));
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
fs.copyFileSync(src, dest);
|
|
382
|
+
}
|
|
327
383
|
}
|
|
328
|
-
// ── Entry point ───────────────────────────────────────────────────────
|
|
329
|
-
main().catch((err) => {
|
|
330
|
-
console.error('Setup failed:', err instanceof Error ? err.message : String(err));
|
|
331
|
-
process.exit(1);
|
|
332
|
-
});
|
|
333
384
|
//# sourceMappingURL=setup.js.map
|
package/dist/setup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAE1C,0EAA0E;AAE1E,MAAM,oBAAoB,GAAG,UAAU,CAAC;AACxC,MAAM,gBAAgB,GAAG,yCAAyC,CAAC;AACnE,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAExC,yEAAyE;AAEzE,KAAK,UAAU,IAAI;IACjB,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;IAElD,iCAAiC;IACjC,MAAM,OAAO,GAAG,oBAAoB,EAAE,CAAC;IACvC,OAAO,CAAC,GAAG,CAAC,4BAA4B,OAAO,EAAE,CAAC,CAAC;IAEnD,kCAAkC;IAClC,MAAM,SAAS,GAAG,eAAe,EAAE,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,4BAA4B,SAAS,EAAE,CAAC,CAAC;IAErD,sCAAsC;IACtC,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC/B,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;IAEpD,yBAAyB;IACzB,aAAa,EAAE,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;IAElD,sDAAsD;IACtD,WAAW,CAAC,SAAS,CAAC,CAAC;IACvB,OAA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json
CHANGED
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
"name": "Telegram Topic Manager",
|
|
4
4
|
"version": "1.0.0",
|
|
5
5
|
"description": "Deterministic Telegram forum topic management for OpenClaw",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
"configSchema": {
|
|
7
|
+
"type": "object",
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {}
|
|
10
|
+
},
|
|
11
|
+
"skills": ["./skills"]
|
|
9
12
|
}
|
package/package.json
CHANGED
package/src/setup.ts
CHANGED
|
@@ -4,101 +4,161 @@ import * as fs from 'node:fs';
|
|
|
4
4
|
import * as path from 'node:path';
|
|
5
5
|
import * as crypto from 'node:crypto';
|
|
6
6
|
import { execSync } from 'node:child_process';
|
|
7
|
-
import * as readline from 'node:readline';
|
|
8
7
|
|
|
9
8
|
// ── Constants ──────────────────────────────────────────────────────────
|
|
10
9
|
|
|
10
|
+
const PLUGIN_NAME = 'openclaw-telegram-manager';
|
|
11
|
+
const PLUGIN_VERSION: string = JSON.parse(
|
|
12
|
+
fs.readFileSync(new URL('../package.json', import.meta.url), 'utf-8'),
|
|
13
|
+
).version;
|
|
11
14
|
const MIN_OPENCLAW_VERSION = '2026.1.0';
|
|
12
15
|
const INCLUDE_FILENAME = 'telegram-manager.generated.groups.json5';
|
|
13
16
|
const REGISTRY_FILENAME = 'topics.json';
|
|
17
|
+
const PLUGIN_FILES = ['openclaw.plugin.json', 'src', 'skills', 'package.json'];
|
|
18
|
+
|
|
19
|
+
// ── Colors (zero dependencies, respects NO_COLOR / non-TTY) ──────────
|
|
20
|
+
|
|
21
|
+
const useColor =
|
|
22
|
+
process.stdout.isTTY === true &&
|
|
23
|
+
!process.env['NO_COLOR'] &&
|
|
24
|
+
process.env['TERM'] !== 'dumb';
|
|
25
|
+
|
|
26
|
+
const c = {
|
|
27
|
+
reset: useColor ? '\x1b[0m' : '',
|
|
28
|
+
bold: useColor ? '\x1b[1m' : '',
|
|
29
|
+
dim: useColor ? '\x1b[2m' : '',
|
|
30
|
+
green: useColor ? '\x1b[32m' : '',
|
|
31
|
+
yellow: useColor ? '\x1b[33m' : '',
|
|
32
|
+
red: useColor ? '\x1b[31m' : '',
|
|
33
|
+
cyan: useColor ? '\x1b[36m' : '',
|
|
34
|
+
magenta: useColor ? '\x1b[35m' : '',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// ── Logging helpers ───────────────────────────────────────────────────
|
|
38
|
+
|
|
39
|
+
function ok(msg: string): void {
|
|
40
|
+
console.log(` ${c.green}✓${c.reset} ${msg}`);
|
|
41
|
+
}
|
|
42
|
+
function warn(msg: string): void {
|
|
43
|
+
console.warn(` ${c.yellow}⚠${c.reset} ${c.yellow}${msg}${c.reset}`);
|
|
44
|
+
}
|
|
45
|
+
function fail(msg: string): void {
|
|
46
|
+
console.error(` ${c.red}✗${c.reset} ${c.red}${msg}${c.reset}`);
|
|
47
|
+
}
|
|
48
|
+
function info(msg: string): void {
|
|
49
|
+
console.log(` ${c.dim}${msg}${c.reset}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function banner(title: string, subtitle?: string): void {
|
|
53
|
+
console.log('');
|
|
54
|
+
console.log(` ${c.cyan}◆${c.reset} ${c.bold}${title}${c.reset}${subtitle ? ` ${c.dim}${subtitle}${c.reset}` : ''}`);
|
|
55
|
+
console.log(` ${c.dim}│${c.reset}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function footer(msg: string): void {
|
|
59
|
+
console.log(` ${c.dim}│${c.reset}`);
|
|
60
|
+
console.log(` ${c.green}◆${c.reset} ${c.bold}${msg}${c.reset}`);
|
|
61
|
+
console.log('');
|
|
62
|
+
}
|
|
14
63
|
|
|
15
|
-
// ──
|
|
64
|
+
// ── Entry point ───────────────────────────────────────────────────────
|
|
16
65
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
66
|
+
const command = process.argv[2] ?? 'setup';
|
|
67
|
+
|
|
68
|
+
if (command === 'setup') {
|
|
69
|
+
runSetup().catch((err) => {
|
|
70
|
+
console.error('Setup failed:', err instanceof Error ? err.message : String(err));
|
|
71
|
+
process.exit(1);
|
|
72
|
+
});
|
|
73
|
+
} else if (command === 'uninstall') {
|
|
74
|
+
runUninstall().catch((err) => {
|
|
75
|
+
console.error('Uninstall failed:', err instanceof Error ? err.message : String(err));
|
|
76
|
+
process.exit(1);
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
console.error(`Unknown command: ${command}`);
|
|
80
|
+
console.error(`Usage: ${PLUGIN_NAME} [setup|uninstall]`);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// ── Setup ─────────────────────────────────────────────────────────────
|
|
85
|
+
|
|
86
|
+
async function runSetup(): Promise<void> {
|
|
87
|
+
banner(PLUGIN_NAME, `v${PLUGIN_VERSION}`);
|
|
20
88
|
|
|
21
|
-
// Step 1: Check OpenClaw version
|
|
22
89
|
const version = checkOpenClawVersion();
|
|
23
|
-
|
|
90
|
+
ok(`OpenClaw ${c.dim}${version}${c.reset}`);
|
|
24
91
|
|
|
25
|
-
// Step 2: Locate config directory
|
|
26
92
|
const configDir = locateConfigDir();
|
|
27
|
-
console.log(`[2/11] Config directory: ${configDir}`);
|
|
28
|
-
|
|
29
|
-
// Step 3: Check directory permissions
|
|
30
93
|
checkDirPermissions(configDir);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// Step 4: Install plugin
|
|
34
|
-
installPlugin();
|
|
35
|
-
console.log('[4/11] Plugin installation checked');
|
|
94
|
+
ok(`Config ${c.dim}${configDir}${c.reset}`);
|
|
36
95
|
|
|
37
|
-
|
|
96
|
+
installPlugin(configDir);
|
|
38
97
|
patchConfig(configDir);
|
|
39
|
-
console.log('[5/11] Config patched with $include reference');
|
|
40
98
|
|
|
41
|
-
|
|
42
|
-
const workspaceDir = path.join(configDir, 'workspace');
|
|
43
|
-
const projectsDir = path.join(workspaceDir, 'projects');
|
|
99
|
+
const projectsDir = path.join(configDir, 'workspace', 'projects');
|
|
44
100
|
ensureDir(projectsDir);
|
|
45
|
-
console.log(`[6/11] Workspace directory: ${projectsDir}`);
|
|
46
|
-
|
|
47
|
-
// Step 7: Initialize empty registry
|
|
48
101
|
initRegistry(projectsDir);
|
|
49
|
-
console.log('[7/11] Registry initialized');
|
|
50
|
-
|
|
51
|
-
// Step 8: Create empty generated include
|
|
52
102
|
createEmptyInclude(configDir);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// Step 9: Optional cron setup
|
|
56
|
-
const isInteractive = process.stdin.isTTY === true;
|
|
57
|
-
const setupCron = isInteractive ? await promptYesNo('Set up daily doctor cron job? [Y/n] ') : true;
|
|
58
|
-
if (setupCron) {
|
|
59
|
-
const groupId = isInteractive
|
|
60
|
-
? await promptInput('Enter your Telegram group ID (e.g., -1003731538650): ')
|
|
61
|
-
: '';
|
|
62
|
-
setupDoctorCron(configDir, groupId);
|
|
63
|
-
console.log('[9/11] Doctor cron job configured');
|
|
64
|
-
} else {
|
|
65
|
-
console.log('[9/11] Skipped cron setup');
|
|
66
|
-
}
|
|
103
|
+
ok('Workspace ready');
|
|
67
104
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
console.log('[10/11] Gateway restart triggered');
|
|
105
|
+
triggerRestart();
|
|
106
|
+
ok('Gateway restarted');
|
|
71
107
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
console.log(
|
|
108
|
+
footer('Setup complete');
|
|
109
|
+
|
|
110
|
+
console.log(` ${c.dim}Next steps:${c.reset}`);
|
|
111
|
+
console.log(` ${c.dim}1.${c.reset} Open any Telegram forum topic`);
|
|
112
|
+
console.log(` ${c.dim}2.${c.reset} Type ${c.cyan}/topic init${c.reset}`);
|
|
113
|
+
console.log(` ${c.dim}3.${c.reset} The topic will be registered and a capsule created`);
|
|
114
|
+
console.log('');
|
|
75
115
|
}
|
|
76
116
|
|
|
77
|
-
// ──
|
|
117
|
+
// ── Uninstall ─────────────────────────────────────────────────────────
|
|
118
|
+
|
|
119
|
+
async function runUninstall(): Promise<void> {
|
|
120
|
+
banner(PLUGIN_NAME, 'uninstall');
|
|
121
|
+
|
|
122
|
+
const configDir = locateConfigDir();
|
|
123
|
+
ok(`Config ${c.dim}${configDir}${c.reset}`);
|
|
124
|
+
|
|
125
|
+
unpatchConfig(configDir);
|
|
126
|
+
removeFile(path.join(configDir, INCLUDE_FILENAME));
|
|
127
|
+
removePluginDir(configDir);
|
|
128
|
+
ok('Plugin files removed');
|
|
129
|
+
|
|
130
|
+
triggerRestart();
|
|
131
|
+
ok('Gateway restarted');
|
|
132
|
+
|
|
133
|
+
const projectsDir = path.join(configDir, 'workspace', 'projects');
|
|
134
|
+
if (fs.existsSync(projectsDir)) {
|
|
135
|
+
info('Workspace data kept: ' + projectsDir);
|
|
136
|
+
info('To remove: rm -rf ' + projectsDir);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
footer('Uninstall complete');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// ── Setup step implementations ────────────────────────────────────────
|
|
78
143
|
|
|
79
144
|
function checkOpenClawVersion(): string {
|
|
80
145
|
let version: string;
|
|
81
146
|
try {
|
|
82
147
|
version = execSync('openclaw --version', { encoding: 'utf-8' }).trim();
|
|
83
148
|
} catch {
|
|
84
|
-
|
|
85
|
-
'Error: OpenClaw not found. Please install OpenClaw (>=2026.1.0) first.',
|
|
86
|
-
);
|
|
149
|
+
fail('OpenClaw not found. Install OpenClaw (>=2026.1.0) first.');
|
|
87
150
|
process.exit(1);
|
|
88
151
|
}
|
|
89
152
|
|
|
90
|
-
// Extract version number (e.g., "openclaw 2026.2.0" -> "2026.2.0")
|
|
91
153
|
const match = version.match(/(\d+\.\d+\.\d+)/);
|
|
92
154
|
if (!match) {
|
|
93
|
-
|
|
155
|
+
warn(`Could not parse version from "${version}". Proceeding anyway.`);
|
|
94
156
|
return version;
|
|
95
157
|
}
|
|
96
158
|
|
|
97
159
|
const versionStr = match[1]!;
|
|
98
160
|
if (compareVersions(versionStr, MIN_OPENCLAW_VERSION) < 0) {
|
|
99
|
-
|
|
100
|
-
`Error: OpenClaw ${versionStr} found, but openclaw-telegram-manager requires >=${MIN_OPENCLAW_VERSION}. Please upgrade.`,
|
|
101
|
-
);
|
|
161
|
+
fail(`OpenClaw ${versionStr} found, requires >=${MIN_OPENCLAW_VERSION}. Please upgrade.`);
|
|
102
162
|
process.exit(1);
|
|
103
163
|
}
|
|
104
164
|
|
|
@@ -106,20 +166,17 @@ function checkOpenClawVersion(): string {
|
|
|
106
166
|
}
|
|
107
167
|
|
|
108
168
|
function locateConfigDir(): string {
|
|
109
|
-
// Check environment variable
|
|
110
169
|
const envDir = process.env['OPENCLAW_CONFIG_DIR'];
|
|
111
170
|
if (envDir && fs.existsSync(envDir)) {
|
|
112
171
|
return path.resolve(envDir);
|
|
113
172
|
}
|
|
114
173
|
|
|
115
|
-
// Check default location
|
|
116
174
|
const homeDir = process.env['HOME'] ?? process.env['USERPROFILE'] ?? '';
|
|
117
175
|
const defaultDir = path.join(homeDir, '.openclaw');
|
|
118
176
|
if (fs.existsSync(defaultDir)) {
|
|
119
177
|
return defaultDir;
|
|
120
178
|
}
|
|
121
179
|
|
|
122
|
-
// Walk up from cwd looking for openclaw.json
|
|
123
180
|
let dir = process.cwd();
|
|
124
181
|
while (dir !== path.dirname(dir)) {
|
|
125
182
|
if (fs.existsSync(path.join(dir, 'openclaw.json'))) {
|
|
@@ -128,9 +185,7 @@ function locateConfigDir(): string {
|
|
|
128
185
|
dir = path.dirname(dir);
|
|
129
186
|
}
|
|
130
187
|
|
|
131
|
-
|
|
132
|
-
'Error: Could not find OpenClaw config directory. Set $OPENCLAW_CONFIG_DIR or ensure ~/.openclaw/ exists.',
|
|
133
|
-
);
|
|
188
|
+
fail('Could not find OpenClaw config directory. Set $OPENCLAW_CONFIG_DIR or ensure ~/.openclaw/ exists.');
|
|
134
189
|
process.exit(1);
|
|
135
190
|
}
|
|
136
191
|
|
|
@@ -140,42 +195,45 @@ function checkDirPermissions(dir: string): void {
|
|
|
140
195
|
const mode = stat.mode;
|
|
141
196
|
const permissions = (mode & 0o777).toString(8);
|
|
142
197
|
|
|
143
|
-
// Check for world-writable or group-writable
|
|
144
198
|
if (mode & 0o002) {
|
|
145
|
-
|
|
146
|
-
`Warning: ${dir} is world-writable (${permissions}). Consider restricting to owner-only (chmod 700).`,
|
|
147
|
-
);
|
|
199
|
+
warn(`${dir} is world-writable (${permissions}). Consider chmod 700.`);
|
|
148
200
|
} else if (mode & 0o020) {
|
|
149
|
-
|
|
150
|
-
`Warning: ${dir} is group-writable (${permissions}). Consider restricting to owner-only (chmod 700).`,
|
|
151
|
-
);
|
|
201
|
+
warn(`${dir} is group-writable (${permissions}). Consider chmod 700.`);
|
|
152
202
|
}
|
|
153
203
|
} catch {
|
|
154
|
-
|
|
204
|
+
warn(`Could not check permissions for ${dir}.`);
|
|
155
205
|
}
|
|
156
206
|
}
|
|
157
207
|
|
|
158
|
-
function installPlugin(): void {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
208
|
+
function installPlugin(configDir: string): void {
|
|
209
|
+
const extDir = path.join(configDir, 'extensions', PLUGIN_NAME);
|
|
210
|
+
|
|
211
|
+
if (fs.existsSync(path.join(extDir, 'openclaw.plugin.json'))) {
|
|
212
|
+
ok('Plugin already installed');
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const pkgRoot = findPackageRoot();
|
|
217
|
+
if (pkgRoot) {
|
|
218
|
+
fs.mkdirSync(extDir, { recursive: true });
|
|
219
|
+
for (const entry of PLUGIN_FILES) {
|
|
220
|
+
const src = path.join(pkgRoot, entry);
|
|
221
|
+
if (!fs.existsSync(src)) continue;
|
|
222
|
+
copyRecursive(src, path.join(extDir, entry));
|
|
165
223
|
}
|
|
166
|
-
|
|
167
|
-
|
|
224
|
+
installDeps(extDir);
|
|
225
|
+
ok('Plugin installed');
|
|
226
|
+
return;
|
|
168
227
|
}
|
|
169
228
|
|
|
170
229
|
try {
|
|
171
|
-
execSync(
|
|
230
|
+
execSync(`openclaw plugins install ${PLUGIN_NAME}`, {
|
|
172
231
|
encoding: 'utf-8',
|
|
173
232
|
stdio: 'inherit',
|
|
174
233
|
});
|
|
234
|
+
ok('Plugin installed');
|
|
175
235
|
} catch {
|
|
176
|
-
|
|
177
|
-
' Warning: Could not install plugin via `openclaw plugins install`. You may need to install manually.',
|
|
178
|
-
);
|
|
236
|
+
warn('Could not install plugin. You may need to install manually.');
|
|
179
237
|
}
|
|
180
238
|
}
|
|
181
239
|
|
|
@@ -183,66 +241,52 @@ function patchConfig(configDir: string): void {
|
|
|
183
241
|
const configPath = path.join(configDir, 'openclaw.json');
|
|
184
242
|
|
|
185
243
|
if (!fs.existsSync(configPath)) {
|
|
186
|
-
|
|
244
|
+
warn(`${configPath} not found. Skipping config patch.`);
|
|
187
245
|
return;
|
|
188
246
|
}
|
|
189
247
|
|
|
190
248
|
let content: string;
|
|
191
249
|
try {
|
|
192
250
|
content = fs.readFileSync(configPath, 'utf-8');
|
|
193
|
-
} catch
|
|
194
|
-
|
|
251
|
+
} catch {
|
|
252
|
+
warn(`Could not read ${configPath}. Skipping config patch.`);
|
|
195
253
|
return;
|
|
196
254
|
}
|
|
197
255
|
|
|
198
|
-
// Check if $include reference already exists
|
|
199
256
|
if (content.includes(INCLUDE_FILENAME)) {
|
|
200
|
-
|
|
257
|
+
ok('Config already patched');
|
|
201
258
|
return;
|
|
202
259
|
}
|
|
203
260
|
|
|
204
|
-
// Parse as JSON (OpenClaw config may be JSON or JSON5)
|
|
205
261
|
let config: Record<string, unknown>;
|
|
206
262
|
try {
|
|
207
263
|
config = JSON.parse(content) as Record<string, unknown>;
|
|
208
264
|
} catch {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
' Warning: Could not parse openclaw.json as JSON. Please manually add the $include reference.',
|
|
212
|
-
);
|
|
213
|
-
console.warn(` Add to channels.telegram.groups: { "$include": "./${INCLUDE_FILENAME}" }`);
|
|
265
|
+
warn('Could not parse openclaw.json. Please manually add the $include reference.');
|
|
266
|
+
info(`Add to channels.telegram.groups: { "$include": "./${INCLUDE_FILENAME}" }`);
|
|
214
267
|
return;
|
|
215
268
|
}
|
|
216
269
|
|
|
217
|
-
// Ensure path exists: channels.telegram.groups
|
|
218
270
|
if (!config['channels']) config['channels'] = {};
|
|
219
271
|
const channels = config['channels'] as Record<string, unknown>;
|
|
220
272
|
|
|
221
273
|
if (!channels['telegram']) channels['telegram'] = {};
|
|
222
274
|
const telegram = channels['telegram'] as Record<string, unknown>;
|
|
223
275
|
|
|
224
|
-
// Set groups to $include
|
|
225
276
|
telegram['groups'] = { $include: `./${INCLUDE_FILENAME}` };
|
|
226
277
|
|
|
227
|
-
// Backup and write
|
|
228
278
|
const bakPath = configPath + '.bak';
|
|
229
279
|
fs.copyFileSync(configPath, bakPath);
|
|
230
280
|
|
|
231
281
|
const newContent = JSON.stringify(config, null, 2) + '\n';
|
|
232
282
|
fs.writeFileSync(configPath, newContent, { mode: 0o600 });
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
function ensureDir(dir: string): void {
|
|
236
|
-
if (!fs.existsSync(dir)) {
|
|
237
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
238
|
-
}
|
|
283
|
+
ok('Config patched');
|
|
239
284
|
}
|
|
240
285
|
|
|
241
286
|
function initRegistry(projectsDir: string): void {
|
|
242
287
|
const registryPath = path.join(projectsDir, REGISTRY_FILENAME);
|
|
243
288
|
|
|
244
289
|
if (fs.existsSync(registryPath)) {
|
|
245
|
-
console.log(' Registry already exists, skipping initialization.');
|
|
246
290
|
return;
|
|
247
291
|
}
|
|
248
292
|
|
|
@@ -265,7 +309,6 @@ function createEmptyInclude(configDir: string): void {
|
|
|
265
309
|
const includePath = path.join(configDir, INCLUDE_FILENAME);
|
|
266
310
|
|
|
267
311
|
if (fs.existsSync(includePath)) {
|
|
268
|
-
console.log(' Include file already exists, skipping.');
|
|
269
312
|
return;
|
|
270
313
|
}
|
|
271
314
|
|
|
@@ -278,84 +321,84 @@ function createEmptyInclude(configDir: string): void {
|
|
|
278
321
|
fs.writeFileSync(includePath, content, { mode: 0o600 });
|
|
279
322
|
}
|
|
280
323
|
|
|
281
|
-
|
|
282
|
-
const cronDir = path.join(configDir, 'cron');
|
|
283
|
-
ensureDir(cronDir);
|
|
324
|
+
// ── Uninstall step implementations ────────────────────────────────────
|
|
284
325
|
|
|
285
|
-
|
|
326
|
+
function unpatchConfig(configDir: string): void {
|
|
327
|
+
const configPath = path.join(configDir, 'openclaw.json');
|
|
328
|
+
const bakPath = configPath + '.bak';
|
|
286
329
|
|
|
287
|
-
if (fs.existsSync(
|
|
288
|
-
console.log(' Cron job already exists, skipping.');
|
|
330
|
+
if (!fs.existsSync(configPath)) {
|
|
289
331
|
return;
|
|
290
332
|
}
|
|
291
333
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
sessionTarget: 'isolated',
|
|
300
|
-
payload: {
|
|
301
|
-
kind: 'agentTurn',
|
|
302
|
-
message:
|
|
303
|
-
'Run topic doctor health checks on all registered topics. Check the registry at projects/topics.json and evaluate each eligible topic. Post per-topic reports with inline keyboards. If any topic\'s thread returns an API error (deleted/migrated), log it and continue to the next topic.',
|
|
304
|
-
timeoutSeconds: 300,
|
|
305
|
-
},
|
|
306
|
-
delivery: {
|
|
307
|
-
mode: 'announce',
|
|
308
|
-
channel: 'telegram',
|
|
309
|
-
to: target,
|
|
310
|
-
bestEffort: true,
|
|
311
|
-
},
|
|
312
|
-
enabled: true,
|
|
313
|
-
deleteAfterRun: false,
|
|
314
|
-
};
|
|
334
|
+
let content: string;
|
|
335
|
+
try {
|
|
336
|
+
content = fs.readFileSync(configPath, 'utf-8');
|
|
337
|
+
} catch {
|
|
338
|
+
warn(`Could not read ${configPath}.`);
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
315
341
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
342
|
+
if (!content.includes(INCLUDE_FILENAME)) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
let config: Record<string, unknown>;
|
|
347
|
+
try {
|
|
348
|
+
config = JSON.parse(content) as Record<string, unknown>;
|
|
349
|
+
} catch {
|
|
350
|
+
warn('Could not parse openclaw.json. Please manually remove the $include reference.');
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const channels = config['channels'] as Record<string, unknown> | undefined;
|
|
355
|
+
const telegram = channels?.['telegram'] as Record<string, unknown> | undefined;
|
|
356
|
+
if (telegram) {
|
|
357
|
+
delete telegram['groups'];
|
|
358
|
+
if (Object.keys(telegram).length === 0) delete channels!['telegram'];
|
|
359
|
+
if (Object.keys(channels!).length === 0) delete config['channels'];
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n', { mode: 0o600 });
|
|
363
|
+
|
|
364
|
+
// Clean up stale backup from install time
|
|
365
|
+
if (fs.existsSync(bakPath)) {
|
|
366
|
+
fs.unlinkSync(bakPath);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function removeFile(filePath: string): void {
|
|
371
|
+
if (fs.existsSync(filePath)) {
|
|
372
|
+
fs.unlinkSync(filePath);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
319
375
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
);
|
|
324
|
-
console.warn(` ${cronJobPath}`);
|
|
325
|
-
console.warn(' Replace -100XXXXXXXXXX with your actual group ID.');
|
|
376
|
+
function removePluginDir(configDir: string): void {
|
|
377
|
+
const extDir = path.join(configDir, 'extensions', PLUGIN_NAME);
|
|
378
|
+
if (fs.existsSync(extDir)) {
|
|
379
|
+
fs.rmSync(extDir, { recursive: true });
|
|
326
380
|
}
|
|
327
381
|
}
|
|
328
382
|
|
|
329
|
-
|
|
383
|
+
// ── Shared helpers ────────────────────────────────────────────────────
|
|
384
|
+
|
|
385
|
+
function triggerRestart(): void {
|
|
330
386
|
try {
|
|
331
387
|
execSync('openclaw gateway restart', {
|
|
332
388
|
encoding: 'utf-8',
|
|
333
389
|
timeout: 10_000,
|
|
334
390
|
});
|
|
335
391
|
} catch {
|
|
336
|
-
|
|
337
|
-
' Warning: Could not restart gateway. Run `openclaw gateway restart` manually.',
|
|
338
|
-
);
|
|
392
|
+
warn('Could not restart gateway. Run `openclaw gateway restart` manually.');
|
|
339
393
|
}
|
|
340
394
|
}
|
|
341
395
|
|
|
342
|
-
function
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
console.log(` - Config directory: ${configDir}`);
|
|
347
|
-
console.log(` - Projects directory: ${projectsDir}`);
|
|
348
|
-
console.log(` - Registry: ${path.join(projectsDir, REGISTRY_FILENAME)}`);
|
|
349
|
-
console.log(` - Include: ${path.join(configDir, INCLUDE_FILENAME)}`);
|
|
350
|
-
console.log('\nNext steps:');
|
|
351
|
-
console.log(' 1. Go to any Telegram forum topic');
|
|
352
|
-
console.log(' 2. Type /topic init');
|
|
353
|
-
console.log(' 3. The topic will be registered and a capsule created');
|
|
354
|
-
console.log('\nFor help: /topic help');
|
|
396
|
+
function ensureDir(dir: string): void {
|
|
397
|
+
if (!fs.existsSync(dir)) {
|
|
398
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
399
|
+
}
|
|
355
400
|
}
|
|
356
401
|
|
|
357
|
-
// ── Helpers ───────────────────────────────────────────────────────────
|
|
358
|
-
|
|
359
402
|
function compareVersions(a: string, b: string): number {
|
|
360
403
|
const aParts = a.split('.').map(Number);
|
|
361
404
|
const bParts = b.split('.').map(Number);
|
|
@@ -367,36 +410,38 @@ function compareVersions(a: string, b: string): number {
|
|
|
367
410
|
return 0;
|
|
368
411
|
}
|
|
369
412
|
|
|
370
|
-
function
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
rl.close();
|
|
378
|
-
const normalized = answer.trim().toLowerCase();
|
|
379
|
-
resolve(normalized === '' || normalized === 'y' || normalized === 'yes');
|
|
413
|
+
function installDeps(dir: string): void {
|
|
414
|
+
try {
|
|
415
|
+
execSync('npm install --production --ignore-scripts', {
|
|
416
|
+
cwd: dir,
|
|
417
|
+
encoding: 'utf-8',
|
|
418
|
+
stdio: 'pipe',
|
|
419
|
+
timeout: 60_000,
|
|
380
420
|
});
|
|
381
|
-
}
|
|
421
|
+
} catch {
|
|
422
|
+
warn('Could not install dependencies. Run `npm install --production` in ' + dir);
|
|
423
|
+
}
|
|
382
424
|
}
|
|
383
425
|
|
|
384
|
-
function
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
});
|
|
394
|
-
});
|
|
426
|
+
function findPackageRoot(): string | null {
|
|
427
|
+
let dir = path.dirname(new URL(import.meta.url).pathname);
|
|
428
|
+
for (let i = 0; i < 5; i++) {
|
|
429
|
+
if (fs.existsSync(path.join(dir, 'openclaw.plugin.json'))) {
|
|
430
|
+
return dir;
|
|
431
|
+
}
|
|
432
|
+
dir = path.dirname(dir);
|
|
433
|
+
}
|
|
434
|
+
return null;
|
|
395
435
|
}
|
|
396
436
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
437
|
+
function copyRecursive(src: string, dest: string): void {
|
|
438
|
+
const stat = fs.statSync(src);
|
|
439
|
+
if (stat.isDirectory()) {
|
|
440
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
441
|
+
for (const entry of fs.readdirSync(src)) {
|
|
442
|
+
copyRecursive(path.join(src, entry), path.join(dest, entry));
|
|
443
|
+
}
|
|
444
|
+
} else {
|
|
445
|
+
fs.copyFileSync(src, dest);
|
|
446
|
+
}
|
|
447
|
+
}
|