@tencent-weixin/openclaw-weixin-cli 2.1.2 → 2.1.4
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/cli.mjs +84 -0
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -16,6 +16,15 @@ const CHANNEL_ID = "openclaw-weixin";
|
|
|
16
16
|
/** Only OpenClaw 2026.3.22–2026.3.23 need node_modules/openclaw symlink for jiti. */
|
|
17
17
|
const SYMLINK_OPENCLAW_MIN = "2026.3.22";
|
|
18
18
|
const SYMLINK_OPENCLAW_MAX = "2026.3.23";
|
|
19
|
+
/**
|
|
20
|
+
* OpenClaw 2026.5.2 到 2026.5.12 之前的版本里,channel-catalog-registry 调
|
|
21
|
+
* discoverOpenClawPlugins 时漏传 installRecords,导致 npm 装的第三方插件
|
|
22
|
+
* 不被 CLI catalog 收录(`channels add/login` 报 Unsupported channel)。
|
|
23
|
+
* 我们通过把 plugin 同时软链到 ~/.openclaw/extensions/<id> 让它走 global
|
|
24
|
+
* 发现路径,绕开 ledger。OpenClaw 2026.5.12 已修复 channel 识别问题。
|
|
25
|
+
*/
|
|
26
|
+
const EXT_SYMLINK_OPENCLAW_MIN = "2026.5.2";
|
|
27
|
+
const EXT_SYMLINK_OPENCLAW_MAX = "2026.5.12";
|
|
19
28
|
|
|
20
29
|
const LEGACY_TAG_ALIASES = {
|
|
21
30
|
legacy: "compat-host-gte2026.3.0-lt2026.3.22",
|
|
@@ -171,6 +180,76 @@ function ensureOpenclawSymlink(hostVersion) {
|
|
|
171
180
|
log(`已创建 symlink: node_modules/openclaw → ${hostRoot}`);
|
|
172
181
|
}
|
|
173
182
|
|
|
183
|
+
// ── extensions symlink (host 5.2 catalog bug workaround) ────────────────────
|
|
184
|
+
|
|
185
|
+
function hostVersionNeedsExtSymlink(hostVersion) {
|
|
186
|
+
if (!hostVersion) return false;
|
|
187
|
+
const geMin = compareVersions(hostVersion, EXT_SYMLINK_OPENCLAW_MIN);
|
|
188
|
+
const ltMax = compareVersions(hostVersion, EXT_SYMLINK_OPENCLAW_MAX);
|
|
189
|
+
return (
|
|
190
|
+
!Number.isNaN(geMin) &&
|
|
191
|
+
!Number.isNaN(ltMax) &&
|
|
192
|
+
geMin >= 0 &&
|
|
193
|
+
ltMax < 0
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function resolveNpmInstalledPluginRoot() {
|
|
198
|
+
const stateDir = process.env.OPENCLAW_STATE_DIR || path.join(os.homedir(), ".openclaw");
|
|
199
|
+
const dir = path.join(stateDir, "npm", "node_modules", PLUGIN_SPEC);
|
|
200
|
+
try {
|
|
201
|
+
if (fs.existsSync(path.join(dir, "package.json"))) return dir;
|
|
202
|
+
} catch {}
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Make ~/.openclaw/extensions/openclaw-weixin a symlink pointing to the
|
|
208
|
+
* npm-installed plugin root. This lets host 5.2's CLI catalog (which scans
|
|
209
|
+
* the global extensions root) discover the plugin even though
|
|
210
|
+
* channel-catalog-registry forgets to forward installRecords to discovery.
|
|
211
|
+
*/
|
|
212
|
+
function ensurePluginExtSymlink(hostVersion) {
|
|
213
|
+
if (!hostVersionNeedsExtSymlink(hostVersion)) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const npmRoot = resolveNpmInstalledPluginRoot();
|
|
218
|
+
if (!npmRoot) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const linkPath = resolvePluginExtDir();
|
|
223
|
+
let linkDirReal;
|
|
224
|
+
try {
|
|
225
|
+
linkDirReal = fs.realpathSync(npmRoot);
|
|
226
|
+
} catch {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Already correct?
|
|
231
|
+
try {
|
|
232
|
+
const stat = fs.lstatSync(linkPath);
|
|
233
|
+
if (stat.isSymbolicLink()) {
|
|
234
|
+
const existingReal = fs.realpathSync(linkPath);
|
|
235
|
+
if (existingReal === linkDirReal) return;
|
|
236
|
+
}
|
|
237
|
+
fs.rmSync(linkPath, { recursive: true, force: true });
|
|
238
|
+
} catch {
|
|
239
|
+
// doesn't exist — fine
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
fs.mkdirSync(path.dirname(linkPath), { recursive: true });
|
|
243
|
+
try {
|
|
244
|
+
fs.symlinkSync(npmRoot, linkPath, "dir");
|
|
245
|
+
log(`已创建 symlink: extensions/${CHANNEL_ID} → ${npmRoot}`);
|
|
246
|
+
} catch (err) {
|
|
247
|
+
error(
|
|
248
|
+
`创建 extensions symlink 失败 (${err?.message ?? err});CLI 可能仍会报 Unsupported channel。`,
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
174
253
|
// ── installed plugin detection ───────────────────────────────────────────────
|
|
175
254
|
|
|
176
255
|
/**
|
|
@@ -273,6 +352,11 @@ function install() {
|
|
|
273
352
|
// so jiti can resolve openclaw/plugin-sdk/* without a runtime dependency.
|
|
274
353
|
ensureOpenclawSymlink(hostVersion);
|
|
275
354
|
|
|
355
|
+
// 5b. Symlink npm-installed plugin into ~/.openclaw/extensions/<id>
|
|
356
|
+
// (>=2026.5.2 <2026.5.12) so the CLI catalog can discover this channel despite
|
|
357
|
+
// the channel-catalog-registry installRecords bug.
|
|
358
|
+
ensurePluginExtSymlink(hostVersion);
|
|
359
|
+
|
|
276
360
|
// 6. Login (interactive QR scan)
|
|
277
361
|
log("插件就绪,开始首次连接...");
|
|
278
362
|
try {
|