openclaw-channel-dmwork 0.5.21 → 0.6.0-dev.172c0942
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/dist/cli/bind.d.ts +12 -0
- package/dist/cli/bind.js +104 -0
- package/dist/cli/bind.js.map +1 -0
- package/dist/cli/doctor.js +48 -30
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +53 -22
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/install.d.ts +17 -7
- package/dist/cli/install.js +216 -127
- package/dist/cli/install.js.map +1 -1
- package/dist/cli/openclaw-cli.d.ts +82 -0
- package/dist/cli/openclaw-cli.js +556 -33
- package/dist/cli/openclaw-cli.js.map +1 -1
- package/dist/cli/quickstart.d.ts +17 -0
- package/dist/cli/quickstart.js +254 -0
- package/dist/cli/quickstart.js.map +1 -0
- package/dist/cli/update.d.ts +3 -4
- package/dist/cli/update.js +7 -82
- package/dist/cli/update.js.map +1 -1
- package/dist/cli/utils.d.ts +3 -3
- package/dist/cli/utils.js +4 -5
- package/dist/cli/utils.js.map +1 -1
- package/dist/package.json +4 -3
- package/dist/src/api-fetch.d.ts +6 -1
- package/dist/src/api-fetch.js +37 -3
- package/dist/src/api-fetch.js.map +1 -1
- package/dist/src/channel.js +30 -17
- package/dist/src/channel.js.map +1 -1
- package/dist/src/inbound.js +12 -67
- package/dist/src/inbound.js.map +1 -1
- package/dist/src/version.d.ts +1 -0
- package/dist/src/version.js +3 -0
- package/dist/src/version.js.map +1 -0
- package/openclaw.plugin.json +3 -0
- package/package.json +4 -3
- package/skills/dmwork-bot-api/SKILL.md +982 -0
package/dist/cli/install.js
CHANGED
|
@@ -1,156 +1,245 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* install command: install
|
|
2
|
+
* install command: install or update the DMWork plugin.
|
|
3
|
+
* Pure plugin management — does NOT configure bots or bindings.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* Handles 5 scenarios:
|
|
6
|
+
* 1. Legacy migration (dmwork → openclaw-channel-dmwork)
|
|
7
|
+
* 2. Normal update (check version, update if needed)
|
|
8
|
+
* 3. Fresh install (nothing installed)
|
|
9
|
+
* 4. Deadlock repair (channels.dmwork exists but no plugin)
|
|
10
|
+
* 5. Broken install cleanup
|
|
6
11
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
// 2. Plugin install (delegate to official CLI)
|
|
19
|
-
const inspect = pluginsInspect(PLUGIN_ID);
|
|
20
|
-
if (inspect?.plugin && !opts.force) {
|
|
21
|
-
console.log(`DMWork plugin is already installed (v${inspect.plugin.version}). Skipping install.`);
|
|
12
|
+
import { copyFileSync, existsSync, rmSync } from "node:fs";
|
|
13
|
+
import { execFileSync } from "node:child_process";
|
|
14
|
+
import { cleanupBrokenInstall, deleteLegacyBackup, detectScenario, ensurePluginsAllow, gatewayRestart, getConfigFilePathSafe, isHealthyInstall, pluginsInspect, pluginsInstall, readConfigFromFile, removeLegacyFromConfig, renameLegacyDir, restoreChannelConfigFromDisk, restoreLegacyDir, saveChannelConfigToDisk, removeChannelConfigFromFile, } from "./openclaw-cli.js";
|
|
15
|
+
import { PLUGIN_ID, ensureOpenClawCompat, } from "./utils.js";
|
|
16
|
+
function getLatestNpmVersion(tag) {
|
|
17
|
+
try {
|
|
18
|
+
return execFileSync("npm", ["view", `${PLUGIN_ID}@${tag}`, "version"], {
|
|
19
|
+
encoding: "utf-8",
|
|
20
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
21
|
+
}).trim();
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
console.log(`Installing DMWork plugin${opts.dev ? " (dev)" : ""}...`);
|
|
26
|
-
pluginsInstall(spec, false, opts.force);
|
|
27
|
-
console.log("Plugin installed successfully.");
|
|
23
|
+
catch {
|
|
24
|
+
return null;
|
|
28
25
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* install command: install or update the DMWork plugin.
|
|
29
|
+
* Pure plugin management — does NOT configure bots or bindings.
|
|
30
|
+
* Use `bind` or `quickstart` for bot configuration after install.
|
|
31
|
+
*/
|
|
32
|
+
export async function runInstall(opts) {
|
|
33
|
+
ensureOpenClawCompat();
|
|
34
|
+
const scenario = detectScenario();
|
|
35
|
+
const tag = opts.dev ? "dev" : "latest";
|
|
36
|
+
const spec = opts.dev ? `${PLUGIN_ID}@dev` : PLUGIN_ID;
|
|
37
|
+
const quiet = false;
|
|
38
|
+
let didChange = false;
|
|
39
|
+
switch (scenario) {
|
|
40
|
+
case "legacy":
|
|
41
|
+
runLegacyMigration(spec, quiet, opts.force);
|
|
42
|
+
didChange = true;
|
|
43
|
+
break;
|
|
44
|
+
case "update": {
|
|
45
|
+
// Already installed — compare against target version
|
|
46
|
+
const inspect = pluginsInspect(PLUGIN_ID);
|
|
47
|
+
const currentVersion = inspect?.plugin?.version ?? "unknown";
|
|
48
|
+
if (opts.force) {
|
|
49
|
+
// --force: skip version check, always install target spec
|
|
50
|
+
console.log(`Force installing DMWork plugin${opts.dev ? " (dev)" : ""}...`);
|
|
51
|
+
pluginsInstall(spec, quiet, true);
|
|
52
|
+
console.log("Plugin installed successfully.");
|
|
53
|
+
didChange = true;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
const targetVersion = getLatestNpmVersion(tag);
|
|
57
|
+
if (!targetVersion) {
|
|
58
|
+
// Cannot determine target — skip install and restart
|
|
59
|
+
console.log(`Cannot reach npm registry to check ${tag} version.`);
|
|
60
|
+
console.log(`Current version: v${currentVersion}`);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (currentVersion === targetVersion) {
|
|
64
|
+
console.log(`DMWork plugin v${currentVersion} is already the target version${opts.dev ? " (dev)" : ""}. No update needed.`);
|
|
65
|
+
return; // Nothing changed — skip gateway restart
|
|
66
|
+
}
|
|
67
|
+
console.log(`Updating DMWork plugin: v${currentVersion} → v${targetVersion}${opts.dev ? " (dev)" : ""}...`);
|
|
68
|
+
pluginsInstall(spec, quiet, true); // Always use spec with tag so @dev is respected
|
|
69
|
+
console.log(`DMWork plugin updated from v${currentVersion} to v${targetVersion}${opts.dev ? " (dev)" : ""}.`);
|
|
70
|
+
didChange = true;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case "broken": {
|
|
74
|
+
console.log("Detected broken plugin install. Cleaning up...");
|
|
75
|
+
const actions = cleanupBrokenInstall();
|
|
76
|
+
actions.forEach((a) => console.log(` ${a}`));
|
|
77
|
+
console.log(`Installing DMWork plugin${opts.dev ? " (dev)" : ""}...`);
|
|
78
|
+
pluginsInstall(spec, quiet, opts.force);
|
|
79
|
+
console.log("Plugin installed successfully.");
|
|
80
|
+
didChange = true;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
case "deadlock":
|
|
84
|
+
runDeadlockRepair(spec, quiet);
|
|
85
|
+
didChange = true;
|
|
86
|
+
break;
|
|
87
|
+
case "fresh":
|
|
88
|
+
console.log(`Installing DMWork plugin${opts.dev ? " (dev)" : ""}...`);
|
|
89
|
+
pluginsInstall(spec, quiet, opts.force);
|
|
90
|
+
console.log("Plugin installed successfully.");
|
|
91
|
+
didChange = true;
|
|
92
|
+
break;
|
|
33
93
|
}
|
|
34
|
-
|
|
94
|
+
if (!didChange)
|
|
95
|
+
return;
|
|
96
|
+
// Gateway restart (plugin lifecycle requires restart)
|
|
35
97
|
console.log("Restarting gateway...");
|
|
36
98
|
if (!gatewayRestart()) {
|
|
37
99
|
console.log("Warning: Gateway restart failed. Run 'openclaw gateway restart' manually.");
|
|
38
100
|
}
|
|
39
|
-
|
|
40
|
-
console.log("\nDMWork plugin setup complete!");
|
|
101
|
+
console.log("\nDMWork plugin ready! Use BotFather /newbot or /quickstart to configure bots.");
|
|
41
102
|
}
|
|
42
103
|
// ---------------------------------------------------------------------------
|
|
43
|
-
// Legacy
|
|
104
|
+
// Scenario 1: Legacy migration (dmwork → openclaw-channel-dmwork)
|
|
44
105
|
// ---------------------------------------------------------------------------
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
// Remove top-level botToken (keep apiUrl as shared default)
|
|
59
|
-
configUnset("channels.dmwork.botToken");
|
|
60
|
-
console.log("Migrated legacy config to accounts.default.");
|
|
106
|
+
function runLegacyMigration(spec, quiet, force) {
|
|
107
|
+
console.log("Detected legacy DMWork plugin (dmwork). Starting migration...");
|
|
108
|
+
// 1. Backup everything to disk
|
|
109
|
+
const configPath = getConfigFilePathSafe();
|
|
110
|
+
const backupPath = configPath + ".dmwork-upgrade-backup";
|
|
111
|
+
copyFileSync(configPath, backupPath);
|
|
112
|
+
saveChannelConfigToDisk();
|
|
113
|
+
console.log(" Backed up config and channels.dmwork to disk.");
|
|
114
|
+
// 2. Clean up any broken new plugin install from a previous failed attempt
|
|
115
|
+
const brokenActions = cleanupBrokenInstall();
|
|
116
|
+
if (brokenActions.length > 0) {
|
|
117
|
+
console.log(" Cleaned up broken previous install:");
|
|
118
|
+
brokenActions.forEach((a) => console.log(` ${a}`));
|
|
61
119
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
120
|
+
// 3. Remove legacy from config FIRST (breaks deadlock)
|
|
121
|
+
removeLegacyFromConfig();
|
|
122
|
+
console.log(" Removed legacy config entries.");
|
|
123
|
+
// 4. Rename legacy directory (not delete!)
|
|
124
|
+
const legacyDirExists = existsSync(getConfigFilePathSafe().replace(/openclaw\.json$/, "extensions/dmwork"));
|
|
125
|
+
let renamed = false;
|
|
126
|
+
if (legacyDirExists) {
|
|
127
|
+
renamed = renameLegacyDir();
|
|
128
|
+
if (renamed) {
|
|
129
|
+
console.log(" Renamed extensions/dmwork → .dmwork-backup.");
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
// Cannot isolate old directory — abort to prevent conflict
|
|
133
|
+
console.error(" Failed to rename extensions/dmwork. Aborting migration.");
|
|
134
|
+
try {
|
|
135
|
+
copyFileSync(backupPath, configPath);
|
|
136
|
+
}
|
|
137
|
+
catch { /* best effort */ }
|
|
138
|
+
throw new Error("Legacy migration aborted: could not rename extensions/dmwork");
|
|
74
139
|
}
|
|
75
140
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
141
|
+
// 5. Install new plugin
|
|
142
|
+
try {
|
|
143
|
+
console.log(" Installing openclaw-channel-dmwork...");
|
|
144
|
+
pluginsInstall(spec, quiet, force);
|
|
79
145
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
else if (opts.botToken || opts.apiUrl) {
|
|
88
|
-
console.error(`Error: Account "${accountId}" already exists. Provide both --bot-token and --api-url to overwrite.`);
|
|
89
|
-
process.exit(1);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
console.log(`Account "${accountId}" already configured. Keeping existing config.`);
|
|
93
|
-
ensureDmScope();
|
|
94
|
-
printAgentHint(accountId);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
146
|
+
catch (installErr) {
|
|
147
|
+
// FAIL: restore everything
|
|
148
|
+
console.error(" Install failed! Restoring previous state...");
|
|
149
|
+
if (renamed)
|
|
150
|
+
restoreLegacyDir();
|
|
151
|
+
try {
|
|
152
|
+
copyFileSync(backupPath, configPath);
|
|
97
153
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
154
|
+
catch { /* best effort */ }
|
|
155
|
+
console.error(" Previous state restored. Legacy plugin should still work.");
|
|
156
|
+
throw installErr;
|
|
157
|
+
}
|
|
158
|
+
// 6. Verify healthy install
|
|
159
|
+
if (!isHealthyInstall()) {
|
|
160
|
+
console.error(" Install completed but verification failed. Restoring...");
|
|
161
|
+
if (renamed)
|
|
162
|
+
restoreLegacyDir();
|
|
163
|
+
try {
|
|
164
|
+
copyFileSync(backupPath, configPath);
|
|
165
|
+
}
|
|
166
|
+
catch { /* best effort */ }
|
|
167
|
+
console.error(" Previous state restored.");
|
|
168
|
+
throw new Error("Legacy migration failed: post-install verification did not pass");
|
|
169
|
+
}
|
|
170
|
+
// 7. Success: restore channels.dmwork + cleanup
|
|
171
|
+
ensurePluginsAllow();
|
|
172
|
+
restoreChannelConfigFromDisk();
|
|
173
|
+
// Verify config was actually restored before deleting backups
|
|
174
|
+
const restoredCfg = readConfigFromFile();
|
|
175
|
+
if (restoredCfg?.channels?.dmwork) {
|
|
176
|
+
// Config restore succeeded — safe to delete backups
|
|
177
|
+
deleteLegacyBackup();
|
|
178
|
+
try {
|
|
179
|
+
rmSync(backupPath, { force: true });
|
|
106
180
|
}
|
|
181
|
+
catch { /* best effort */ }
|
|
107
182
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
if (!botToken?.startsWith("bf_")) {
|
|
114
|
-
console.error("Error: Bot token must start with 'bf_'.");
|
|
115
|
-
process.exit(1);
|
|
116
|
-
}
|
|
117
|
-
// Collect apiUrl
|
|
118
|
-
let apiUrl = opts.apiUrl;
|
|
119
|
-
if (!apiUrl) {
|
|
120
|
-
apiUrl = await prompt("Enter API server URL:");
|
|
121
|
-
}
|
|
122
|
-
if (!apiUrl) {
|
|
123
|
-
console.error("Error: API URL is required.");
|
|
124
|
-
process.exit(1);
|
|
125
|
-
}
|
|
126
|
-
// Write account config
|
|
127
|
-
configSet(`channels.dmwork.accounts.${accountId}.botToken`, botToken);
|
|
128
|
-
configSet(`channels.dmwork.accounts.${accountId}.apiUrl`, apiUrl);
|
|
129
|
-
console.log(`Configured bot account: ${accountId}`);
|
|
130
|
-
console.log(` API: ${apiUrl}`);
|
|
131
|
-
ensureDmScope();
|
|
132
|
-
printAgentHint(accountId);
|
|
183
|
+
else {
|
|
184
|
+
console.log(" Warning: channels.dmwork restore may not have succeeded. Keeping backups for safety.");
|
|
185
|
+
}
|
|
186
|
+
console.log(" Legacy migration complete!");
|
|
133
187
|
}
|
|
134
188
|
// ---------------------------------------------------------------------------
|
|
135
|
-
//
|
|
189
|
+
// Scenario 4: Deadlock repair
|
|
136
190
|
// ---------------------------------------------------------------------------
|
|
137
|
-
function
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
191
|
+
function runDeadlockRepair(spec, quiet) {
|
|
192
|
+
console.log("Detected config deadlock (channels.dmwork exists but no plugin).");
|
|
193
|
+
// 1. Backup
|
|
194
|
+
const configPath = getConfigFilePathSafe();
|
|
195
|
+
const backupPath = configPath + ".dmwork-upgrade-backup";
|
|
196
|
+
copyFileSync(configPath, backupPath);
|
|
197
|
+
saveChannelConfigToDisk();
|
|
198
|
+
// 2. Remove channels.dmwork
|
|
199
|
+
removeChannelConfigFromFile();
|
|
200
|
+
console.log(" Temporarily removed channels.dmwork.");
|
|
201
|
+
// 3. Install
|
|
202
|
+
try {
|
|
203
|
+
console.log(" Installing openclaw-channel-dmwork...");
|
|
204
|
+
pluginsInstall(spec, quiet);
|
|
205
|
+
}
|
|
206
|
+
catch (installErr) {
|
|
207
|
+
console.error(" Install failed! Restoring config...");
|
|
208
|
+
try {
|
|
209
|
+
copyFileSync(backupPath, configPath);
|
|
210
|
+
}
|
|
211
|
+
catch { /* best effort */ }
|
|
212
|
+
throw installErr;
|
|
213
|
+
}
|
|
214
|
+
// 4. Verify
|
|
215
|
+
if (!isHealthyInstall()) {
|
|
216
|
+
console.error(" Install completed but verification failed. Restoring config...");
|
|
217
|
+
try {
|
|
218
|
+
copyFileSync(backupPath, configPath);
|
|
219
|
+
}
|
|
220
|
+
catch { /* best effort */ }
|
|
221
|
+
throw new Error("Deadlock repair failed: post-install verification did not pass");
|
|
141
222
|
}
|
|
142
|
-
|
|
143
|
-
|
|
223
|
+
// 5. Success
|
|
224
|
+
ensurePluginsAllow();
|
|
225
|
+
restoreChannelConfigFromDisk();
|
|
226
|
+
// Verify config was restored before deleting backup
|
|
227
|
+
const restoredCfg = readConfigFromFile();
|
|
228
|
+
if (restoredCfg?.channels?.dmwork) {
|
|
229
|
+
try {
|
|
230
|
+
rmSync(backupPath, { force: true });
|
|
231
|
+
}
|
|
232
|
+
catch { /* best effort */ }
|
|
233
|
+
console.log(" Deadlock repaired!");
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
// Config restore failed — plugin is installed but bot config is missing
|
|
237
|
+
throw new Error("Deadlock repair incomplete: plugin installed but channels.dmwork could not be restored. Backup kept at " + backupPath);
|
|
144
238
|
}
|
|
145
239
|
}
|
|
146
240
|
// ---------------------------------------------------------------------------
|
|
147
|
-
//
|
|
241
|
+
// Exported for update.ts and doctor.ts to reuse
|
|
148
242
|
// ---------------------------------------------------------------------------
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
console.log(`
|
|
152
|
-
To create an independent agent for this bot (optional):
|
|
153
|
-
openclaw agents add ${agentName}
|
|
154
|
-
openclaw agents bind ${agentName} dmwork ${accountId}`);
|
|
155
|
-
}
|
|
243
|
+
export { runLegacyMigration as runLegacyMigrationForUpdate };
|
|
244
|
+
export { runDeadlockRepair as runDeadlockRepairForUpdate };
|
|
156
245
|
//# sourceMappingURL=install.js.map
|
package/dist/cli/install.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../cli/install.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../cli/install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,4BAA4B,EAC5B,gBAAgB,EAChB,uBAAuB,EACvB,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,SAAS,EACT,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,SAAS,mBAAmB,CAAC,GAAW;IACtC,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,GAAG,SAAS,IAAI,GAAG,EAAE,EAAE,SAAS,CAAC,EAAE;YACrE,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;SAChC,CAAC,CAAC,IAAI,EAAE,CAAC;IACZ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAOD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAoB;IACnD,oBAAoB,EAAE,CAAC;IAEvB,MAAM,QAAQ,GAAG,cAAc,EAAE,CAAC;IAClC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;IACxC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,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AA8E;AAE9E,OAAO,EAAE,kBAAkB,IAAI,2BAA2B,EAAE,CAAC;AAC7D,OAAO,EAAE,iBAAiB,IAAI,0BAA0B,EAAE,CAAC"}
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* All openclaw invocations go through this module using execFileSync with
|
|
4
4
|
* argument arrays to avoid shell-quoting issues.
|
|
5
5
|
*/
|
|
6
|
+
/** Get the resolved openclaw binary path */
|
|
7
|
+
export declare function getOpenClawBin(): string;
|
|
6
8
|
export declare function getConfigFilePath(): string;
|
|
7
9
|
export declare function configGet(path: string): string | null;
|
|
8
10
|
export declare function configGetJson(path: string): any;
|
|
@@ -28,7 +30,41 @@ export interface PluginInspectResult {
|
|
|
28
30
|
installPath: string;
|
|
29
31
|
};
|
|
30
32
|
}
|
|
33
|
+
export type InspectFailReason = "unsupported" | "not_found" | "error";
|
|
34
|
+
export interface PluginsInspectOutcome {
|
|
35
|
+
ok: boolean;
|
|
36
|
+
data: PluginInspectResult | null;
|
|
37
|
+
failReason: InspectFailReason | null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Inspect a plugin. Returns structured outcome distinguishing:
|
|
41
|
+
* - ok + data: inspect succeeded
|
|
42
|
+
* - unsupported: old OpenClaw without `plugins inspect`
|
|
43
|
+
* - not_found: plugin genuinely not found
|
|
44
|
+
* - error: other failure (config corruption, plugin load crash, etc.)
|
|
45
|
+
*/
|
|
46
|
+
export declare function pluginsInspectDetailed(id: string): PluginsInspectOutcome;
|
|
47
|
+
/** Backward-compatible wrapper: returns data or null. */
|
|
31
48
|
export declare function pluginsInspect(id: string): PluginInspectResult | null;
|
|
49
|
+
export interface PluginResolvedState {
|
|
50
|
+
installed: boolean;
|
|
51
|
+
enabled: boolean | null;
|
|
52
|
+
version: string | null;
|
|
53
|
+
installPath: string | null;
|
|
54
|
+
source: "inspect" | "fallback";
|
|
55
|
+
/** Why inspect failed. null when source === "inspect". */
|
|
56
|
+
inspectFailReason: InspectFailReason | null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Resolve plugin install state. Uses `plugins inspect` when available,
|
|
60
|
+
* falls back to config entries + directory + package.json for old OpenClaw
|
|
61
|
+
* versions that don't support `plugins inspect`.
|
|
62
|
+
*
|
|
63
|
+
* Fallback installed = all 3 artifacts present (entries + installs + dir),
|
|
64
|
+
* matching detectScenario()'s healthy definition. Partial presence is NOT
|
|
65
|
+
* considered installed — that's a broken state for doctor --fix to handle.
|
|
66
|
+
*/
|
|
67
|
+
export declare function resolvePluginState(id: string): PluginResolvedState;
|
|
32
68
|
export declare function gatewayStatus(): {
|
|
33
69
|
running: boolean;
|
|
34
70
|
};
|
|
@@ -45,6 +81,17 @@ export declare function saveChannelConfigFromFile(): Record<string, unknown> | n
|
|
|
45
81
|
* Creates a .bak backup before writing.
|
|
46
82
|
*/
|
|
47
83
|
export declare function restoreChannelConfigToFile(dmworkConfig: Record<string, unknown>): void;
|
|
84
|
+
/**
|
|
85
|
+
* Remove channels.dmwork directly from the JSON file.
|
|
86
|
+
* Used before uninstall to avoid config validation errors
|
|
87
|
+
* (openclaw config unset also fails when the channel id is unknown).
|
|
88
|
+
*/
|
|
89
|
+
/**
|
|
90
|
+
* Get the openclaw config file path without calling the CLI.
|
|
91
|
+
* Falls back to the standard default when CLI is unavailable
|
|
92
|
+
* (e.g. during uninstall when config validation fails).
|
|
93
|
+
*/
|
|
94
|
+
export declare function getConfigFilePathSafe(): string;
|
|
48
95
|
export declare function removeChannelConfigFromFile(): void;
|
|
49
96
|
/**
|
|
50
97
|
* Read the full config object directly from file (for doctor phase-1 checks).
|
|
@@ -67,3 +114,38 @@ export declare function removeOrphanedBindingsFromFile(channel: string, validAcc
|
|
|
67
114
|
* Returns a list of actions taken (for logging).
|
|
68
115
|
*/
|
|
69
116
|
export declare function cleanupLegacyPlugin(): string[];
|
|
117
|
+
/**
|
|
118
|
+
* Clean up stale openclaw-channel-dmwork directory that is not registered
|
|
119
|
+
* in plugins.installs (orphaned from a failed previous install).
|
|
120
|
+
*
|
|
121
|
+
* Only removes the directory if ALL of these are true:
|
|
122
|
+
* 1. The directory exists
|
|
123
|
+
* 2. pluginsInspect returns null (openclaw doesn't recognize it)
|
|
124
|
+
* 3. plugins.installs has no record for openclaw-channel-dmwork
|
|
125
|
+
*/
|
|
126
|
+
export declare function cleanupStalePluginDir(): string[];
|
|
127
|
+
/**
|
|
128
|
+
* Clean up stale openclaw-install-stage directories that belong to DMWork.
|
|
129
|
+
* Only removes directories that:
|
|
130
|
+
* 1. Match .openclaw-install-stage-* pattern
|
|
131
|
+
* 2. Are older than 10 minutes (not a current installation)
|
|
132
|
+
* 3. Contain a package.json with name "openclaw-channel-dmwork"
|
|
133
|
+
*/
|
|
134
|
+
export declare function cleanupStaleStageDirectories(): string[];
|
|
135
|
+
/**
|
|
136
|
+
* Write openclaw.json atomically: write to .tmp then rename.
|
|
137
|
+
* Prevents gateway watcher from reading half-written/truncated JSON.
|
|
138
|
+
*/
|
|
139
|
+
export declare function writeConfigAtomic(cfg: Record<string, any>): void;
|
|
140
|
+
export type UpgradeScenario = "legacy" | "update" | "fresh" | "deadlock" | "broken";
|
|
141
|
+
export declare function detectScenario(): UpgradeScenario;
|
|
142
|
+
export declare function isHealthyInstall(): boolean;
|
|
143
|
+
export declare function ensurePluginsAllow(): void;
|
|
144
|
+
export declare function pluginsUpdateCompat(id: string, tag: string, quiet?: boolean): void;
|
|
145
|
+
export declare function renameLegacyDir(): boolean;
|
|
146
|
+
export declare function restoreLegacyDir(): void;
|
|
147
|
+
export declare function deleteLegacyBackup(): void;
|
|
148
|
+
export declare function removeLegacyFromConfig(): void;
|
|
149
|
+
export declare function saveChannelConfigToDisk(): void;
|
|
150
|
+
export declare function restoreChannelConfigFromDisk(): void;
|
|
151
|
+
export declare function cleanupBrokenInstall(): string[];
|