@wps365/openclaw-wpsxiezuo 1.6.1 → 1.6.3

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/bin/cli.mjs +44 -16
  2. package/package.json +2 -2
package/bin/cli.mjs CHANGED
@@ -444,30 +444,58 @@ function writeChannelConfig({ appId, appSecret, baseUrl }) {
444
444
  log.info(`已写入 channels.${CHANNEL_ID} + plugins.allow + bindings`);
445
445
  }
446
446
 
447
- function verifyInstall({ requirePluginRegistered = true } = {}) {
447
+ async function verifyInstall({ requirePluginRegistered = true } = {}) {
448
448
  const cfg = readJsonSafe(OPENCLAW_JSON);
449
449
  if (!cfg?.channels?.[CHANNEL_ID]?.enabled) {
450
450
  log.error(`安装验证失败:channels.${CHANNEL_ID} 未写入或未启用`);
451
451
  process.exit(1);
452
452
  }
453
453
 
454
- // 仅在要求插件已注册时,再跑一次 `openclaw plugins list` 兜底验证。
455
- // 说明:不同 OpenClaw 版本的 list 输出格式不尽相同,我们只做"是否出现 channel id"
456
- // 级别的宽松匹配,避免在少见输出上误报。
457
454
  if (!requirePluginRegistered) return;
458
455
 
459
- const list = runOpenclaw(["plugins", "list"], { capture: true });
460
- if (list.status !== 0) {
461
- log.warn(`openclaw plugins list 执行失败(exit=${list.status}),跳过运行时验证`);
462
- return;
463
- }
464
- const output = `${list.stdout}\n${list.stderr}`;
465
- if (!output.includes(CHANNEL_ID)) {
466
- log.error(`安装验证失败:openclaw plugins list 输出未包含 "${CHANNEL_ID}"`);
467
- log.error("这通常表示插件虽被 `plugins install` 接受,但未被网关识别。");
468
- log.error("请手动执行 `openclaw plugins list` 排查,或升级 OpenClaw 后重试。");
469
- process.exit(1);
456
+ // 兼容不同 OpenClaw 版本的输出格式:可能显示 channel id、npm 包名或其片段
457
+ const knownIds = [CHANNEL_ID, "openclaw-wpsxiezuo", "@wps365/openclaw-wpsxiezuo"];
458
+ const RETRIES = 3;
459
+ const INTERVAL_MS = 5000;
460
+
461
+ console.log(`
462
+ ${c.green}${c.bold}✅ 插件安装已完成,正在自动校验注册结果...${c.reset}
463
+
464
+ ${c.cyan}提示:${c.reset}如果不想等待自动校验,可 ${c.bold}Ctrl+C${c.reset} 中止,然后手动执行以下命令确认:
465
+ ${c.cyan}openclaw plugins list${c.reset} 查看已注册插件列表
466
+ ${c.cyan}openclaw gateway restart${c.reset} 重启网关加载插件
467
+ `);
468
+
469
+ for (let attempt = 1; attempt <= RETRIES; attempt++) {
470
+ if (attempt > 1) {
471
+ const secs = INTERVAL_MS / 1000;
472
+ for (let remaining = secs; remaining > 0; remaining--) {
473
+ process.stdout.write(`\r${c.cyan}[INFO]${c.reset} 等待重试(第 ${attempt}/${RETRIES} 次):${remaining}s ... `);
474
+ await new Promise((r) => setTimeout(r, 1000));
475
+ }
476
+ process.stdout.write("\r" + " ".repeat(60) + "\r"); // 清除倒计时行
477
+ }
478
+
479
+ const list = runOpenclaw(["plugins", "list"], { capture: true });
480
+ if (list.status !== 0) {
481
+ log.warn(`openclaw plugins list 执行失败(exit=${list.status},第 ${attempt}/${RETRIES} 次)`);
482
+ continue;
483
+ }
484
+
485
+ const output = `${list.stdout}\n${list.stderr}`;
486
+ const found = knownIds.some((id) => output.includes(id));
487
+ if (found) {
488
+ log.info("插件已在 openclaw plugins list 中确认注册");
489
+ return;
490
+ }
491
+
492
+ log.info(`第 ${attempt}/${RETRIES} 次未在 plugins list 中找到插件,稍后重试...`);
470
493
  }
494
+
495
+ // 三次均未匹配,降级为警告(install 和 config 写入均已成功,可能是输出格式差异)
496
+ log.warn(`重试 ${RETRIES} 次后,openclaw plugins list 仍未包含已知标识(${knownIds.join(" / ")})`);
497
+ log.warn("插件注册命令已成功执行,此警告可能是 OpenClaw 版本的输出格式差异导致。");
498
+ log.warn(`请重启网关后手动确认:openclaw gateway restart && openclaw plugins list`);
471
499
  }
472
500
 
473
501
  // ── install 子命令 ──────────────────────────────────────────────────────────
@@ -552,7 +580,7 @@ async function cmdInstall(flags) {
552
580
  runOpenclaw(["doctor", "--fix"], { silent: true });
553
581
 
554
582
  log.step("验证安装");
555
- verifyInstall({ requirePluginRegistered: reg.ok });
583
+ await verifyInstall({ requirePluginRegistered: reg.ok });
556
584
 
557
585
  const successNote = reg.ok
558
586
  ? `${c.green}${c.bold}✅ @wps365/openclaw-wpsxiezuo 安装成功${c.reset}`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wps365/openclaw-wpsxiezuo",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "description": "WPS Xiezuo OpenClaw plugin - connect OpenClaw Agent to the WPS Open Platform enterprise robot",
5
5
  "keywords": [
6
6
  "openclaw",
@@ -13,7 +13,7 @@
13
13
  "main": "dist/index.js",
14
14
  "types": "dist/index.d.ts",
15
15
  "bin": {
16
- "openclaw-wps-xiezuo": "./bin/cli.mjs"
16
+ "openclaw-wps-xiezuo": "bin/cli.mjs"
17
17
  },
18
18
  "files": [
19
19
  "bin/",