@tencent-connect/openclaw-qqbot 1.6.5-alpha.6 → 1.6.5-alpha.7

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.
@@ -87,6 +87,22 @@ export async function startGateway(ctx) {
87
87
  log?.info(`[qqbot:${account.accountId}] ${w}`);
88
88
  }
89
89
  }
90
+ // 预检 openclaw runtime 模块是否可正常解析(兼容性诊断)
91
+ // openclaw 3.23+ 存在 plugin-sdk/root-alias.cjs 回归 bug,
92
+ // 内置插件(qwen-portal-auth 等)全部加载失败,导致 AI agent 调用返回
93
+ // "Unable to resolve plugin runtime module"。提前检测并告警。
94
+ try {
95
+ const pluginRuntime = getQQBotRuntime();
96
+ if (pluginRuntime?.channel?.reply?.dispatchReplyWithBufferedBlockDispatcher) {
97
+ log?.info(`[qqbot:${account.accountId}] Runtime module preflight: OK`);
98
+ }
99
+ else {
100
+ log?.error(`[qqbot:${account.accountId}] ⚠️ Runtime preflight: dispatchReply API 不可用,AI 消息处理可能失败。请检查 openclaw 版本兼容性`);
101
+ }
102
+ }
103
+ catch (preflightErr) {
104
+ log?.error(`[qqbot:${account.accountId}] ⚠️ Runtime preflight failed: ${preflightErr}. AI 消息处理可能失败`);
105
+ }
90
106
  // 后台版本检查(供 /bot-version、/bot-upgrade 指令被动查询)
91
107
  triggerUpdateCheck(log);
92
108
  // 初始化 API 配置(markdown 支持)
@@ -883,8 +899,13 @@ export async function startGateway(ctx) {
883
899
  clearTimeout(timeoutId);
884
900
  timeoutId = null;
885
901
  }
886
- // 发送错误提示给用户,显示完整错误信息
887
902
  const errMsg = String(err);
903
+ // 兼容 openclaw 3.23+ 的 plugin-sdk/root-alias.cjs 模块解析失败
904
+ if (errMsg.includes("Unable to resolve plugin runtime module") || errMsg.includes("root-alias.cjs")) {
905
+ log?.error(`[qqbot:${account.accountId}] ⚠️ openclaw 框架 runtime 模块解析失败,可能是 openclaw 版本与 plugin-sdk 不兼容。请尝试: npm install -g openclaw@latest && openclaw gateway restart`);
906
+ await sendErrorMessage("⚠️ AI 服务暂时不可用:openclaw 框架运行时模块加载失败。\n\n请管理员执行:\nnpm install -g openclaw@latest\nopenclaw gateway restart\n\n斜杠命令(如 /bot-ping)不受影响。");
907
+ return;
908
+ }
888
909
  if (errMsg.includes("401") || errMsg.includes("key") || errMsg.includes("auth")) {
889
910
  log?.error(`[qqbot:${account.accountId}] AI auth error: ${errMsg}`);
890
911
  }
@@ -929,7 +950,15 @@ export async function startGateway(ctx) {
929
950
  }
930
951
  }
931
952
  catch (err) {
953
+ const errStr = String(err);
932
954
  log?.error(`[qqbot:${account.accountId}] Message processing failed: ${err}`);
955
+ // 兼容 openclaw 3.23+ runtime 模块解析失败:给用户发可操作的提示
956
+ if (errStr.includes("Unable to resolve plugin runtime module") || errStr.includes("root-alias.cjs")) {
957
+ try {
958
+ await sendErrorMessage("⚠️ AI 服务暂时不可用:openclaw 框架运行时模块加载失败。\n\n请管理员执行:\nnpm install -g openclaw@latest\nopenclaw gateway restart\n\n斜杠命令(如 /bot-ping)不受影响。");
959
+ }
960
+ catch { /* best-effort */ }
961
+ }
933
962
  }
934
963
  finally {
935
964
  // 无论成功/失败/超时,都停止输入状态续期
@@ -726,7 +726,11 @@ function fireHotUpgrade(targetVersion) {
726
726
  /**
727
727
  * /bot-upgrade — 统一升级入口
728
728
  *
729
- * 产品流程:
729
+ * upgradeMode 开关:
730
+ * - "doc"(默认):只展示升级指引文档,不执行热更新
731
+ * - "hot-reload":执行 npm 升级脚本进行热更新
732
+ *
733
+ * 热更新模式下的产品流程:
730
734
  * /bot-upgrade — 展示版本信息+确认按钮(不直接升级)
731
735
  * /bot-upgrade --latest — 确认升级到最新版本
732
736
  * /bot-upgrade --version X — 升级到指定版本
@@ -735,21 +739,49 @@ function fireHotUpgrade(targetVersion) {
735
739
  let _upgrading = false; // 升级锁
736
740
  registerCommand({
737
741
  name: "bot-upgrade",
738
- description: "检查更新并自动热更",
742
+ description: "检查更新并查看升级指引",
739
743
  usage: [
740
- `/bot-upgrade 检查是否有新版本(展示信息+确认按钮)`,
741
- `/bot-upgrade --latest 确认升级到最新版本`,
742
- `/bot-upgrade --version X 升级到指定版本(如 1.6.5)`,
743
- `/bot-upgrade --force 强制重新安装当前版本`,
744
- ``,
745
- `⚠️ 仅在私聊中可用。升级过程约 30~60 秒,期间服务短暂不可用。`,
746
- ``,
747
- `环境要求:`,
748
- ` - 操作系统:macOS / Linux / Windows`,
749
- ` - OpenClaw 框架版本 ≥ ${UPGRADE_REQUIREMENTS.minFrameworkVersion}`,
750
- ` - Node.js ≥ v${UPGRADE_REQUIREMENTS.minNodeVersion}`,
744
+ `/bot-upgrade 检查是否有新版本`,
745
+ `/bot-upgrade --latest 确认升级到最新版本(需 upgradeMode=hot-reload)`,
746
+ `/bot-upgrade --version X 升级到指定版本(需 upgradeMode=hot-reload)`,
747
+ `/bot-upgrade --force 强制重新安装当前版本(需 upgradeMode=hot-reload)`,
751
748
  ].join("\n"),
752
749
  handler: async (ctx) => {
750
+ const url = ctx.accountConfig?.upgradeUrl || DEFAULT_UPGRADE_URL;
751
+ const upgradeMode = ctx.accountConfig?.upgradeMode || "doc";
752
+ const args = ctx.args.trim();
753
+ const info = await getUpdateInfo();
754
+ const GITHUB_URL = "https://github.com/tencent-connect/openclaw-qqbot/";
755
+ // ── doc 模式(默认):只展示升级指引,不执行热更新 ──
756
+ if (upgradeMode !== "hot-reload") {
757
+ if (info.checkedAt === 0) {
758
+ return `⏳ 版本检查中,请稍后再试`;
759
+ }
760
+ if (info.error) {
761
+ return [
762
+ `❌ 主机网络访问异常,无法检查更新`,
763
+ ``,
764
+ `查看升级指引:[点击查看](${url})`,
765
+ ].join("\n");
766
+ }
767
+ if (!info.hasUpdate) {
768
+ return [
769
+ `✅ 当前已是最新版本 v${PLUGIN_VERSION}`,
770
+ ``,
771
+ `项目地址:[GitHub](${GITHUB_URL})`,
772
+ ].join("\n");
773
+ }
774
+ return [
775
+ `🆕 发现新版本`,
776
+ ``,
777
+ `当前版本:**v${PLUGIN_VERSION}**`,
778
+ `最新版本:**v${info.latest}**`,
779
+ ``,
780
+ `📖 升级指引:[点击查看](${url})`,
781
+ `🌟 官方 GitHub 仓库:[点击前往](${GITHUB_URL})`,
782
+ ].join("\n");
783
+ }
784
+ // ── hot-reload 模式:执行热更新 ──
753
785
  // 升级相关指令仅在私聊中可用
754
786
  if (ctx.type !== "c2c") {
755
787
  return `💡 请在私聊中使用此指令`;
@@ -758,9 +790,6 @@ registerCommand({
758
790
  if (_upgrading) {
759
791
  return `⏳ 正在升级中,请稍候...`;
760
792
  }
761
- const url = ctx.accountConfig?.upgradeUrl || DEFAULT_UPGRADE_URL;
762
- const args = ctx.args.trim();
763
- const info = await getUpdateInfo();
764
793
  let isForce = false;
765
794
  let isLatest = false;
766
795
  let versionArg;
@@ -797,7 +826,6 @@ registerCommand({
797
826
  continue;
798
827
  }
799
828
  }
800
- const GITHUB_URL = "https://github.com/tencent-connect/openclaw-qqbot/";
801
829
  // ── 无参数(也没有 --latest / --version / --force):只展示信息+确认按钮 ──
802
830
  if (!versionArg && !isLatest && !isForce) {
803
831
  if (info.checkedAt === 0) {
@@ -818,7 +846,7 @@ registerCommand({
818
846
  ];
819
847
  return lines.join("\n");
820
848
  }
821
- // 有新版本:展示信息 + 确认按钮(同通道:alpha 只展示 alpha,正式版只展示正式版)
849
+ // 有新版本:展示信息 + 确认按钮
822
850
  return [
823
851
  `🆕 发现新版本`,
824
852
  ``,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tencent-connect/openclaw-qqbot",
3
- "version": "1.6.5-alpha.6",
3
+ "version": "1.6.5-alpha.7",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/gateway.ts CHANGED
@@ -112,6 +112,21 @@ export async function startGateway(ctx: GatewayContext): Promise<void> {
112
112
  }
113
113
  }
114
114
 
115
+ // 预检 openclaw runtime 模块是否可正常解析(兼容性诊断)
116
+ // openclaw 3.23+ 存在 plugin-sdk/root-alias.cjs 回归 bug,
117
+ // 内置插件(qwen-portal-auth 等)全部加载失败,导致 AI agent 调用返回
118
+ // "Unable to resolve plugin runtime module"。提前检测并告警。
119
+ try {
120
+ const pluginRuntime = getQQBotRuntime();
121
+ if (pluginRuntime?.channel?.reply?.dispatchReplyWithBufferedBlockDispatcher) {
122
+ log?.info(`[qqbot:${account.accountId}] Runtime module preflight: OK`);
123
+ } else {
124
+ log?.error(`[qqbot:${account.accountId}] ⚠️ Runtime preflight: dispatchReply API 不可用,AI 消息处理可能失败。请检查 openclaw 版本兼容性`);
125
+ }
126
+ } catch (preflightErr) {
127
+ log?.error(`[qqbot:${account.accountId}] ⚠️ Runtime preflight failed: ${preflightErr}. AI 消息处理可能失败`);
128
+ }
129
+
115
130
  // 后台版本检查(供 /bot-version、/bot-upgrade 指令被动查询)
116
131
  triggerUpdateCheck(log);
117
132
 
@@ -1019,8 +1034,15 @@ export async function startGateway(ctx: GatewayContext): Promise<void> {
1019
1034
  timeoutId = null;
1020
1035
  }
1021
1036
 
1022
- // 发送错误提示给用户,显示完整错误信息
1023
1037
  const errMsg = String(err);
1038
+
1039
+ // 兼容 openclaw 3.23+ 的 plugin-sdk/root-alias.cjs 模块解析失败
1040
+ if (errMsg.includes("Unable to resolve plugin runtime module") || errMsg.includes("root-alias.cjs")) {
1041
+ log?.error(`[qqbot:${account.accountId}] ⚠️ openclaw 框架 runtime 模块解析失败,可能是 openclaw 版本与 plugin-sdk 不兼容。请尝试: npm install -g openclaw@latest && openclaw gateway restart`);
1042
+ await sendErrorMessage("⚠️ AI 服务暂时不可用:openclaw 框架运行时模块加载失败。\n\n请管理员执行:\nnpm install -g openclaw@latest\nopenclaw gateway restart\n\n斜杠命令(如 /bot-ping)不受影响。");
1043
+ return;
1044
+ }
1045
+
1024
1046
  if (errMsg.includes("401") || errMsg.includes("key") || errMsg.includes("auth")) {
1025
1047
  log?.error(`[qqbot:${account.accountId}] AI auth error: ${errMsg}`);
1026
1048
  } else {
@@ -1062,7 +1084,14 @@ export async function startGateway(ctx: GatewayContext): Promise<void> {
1062
1084
  }
1063
1085
  }
1064
1086
  } catch (err) {
1087
+ const errStr = String(err);
1065
1088
  log?.error(`[qqbot:${account.accountId}] Message processing failed: ${err}`);
1089
+ // 兼容 openclaw 3.23+ runtime 模块解析失败:给用户发可操作的提示
1090
+ if (errStr.includes("Unable to resolve plugin runtime module") || errStr.includes("root-alias.cjs")) {
1091
+ try {
1092
+ await sendErrorMessage("⚠️ AI 服务暂时不可用:openclaw 框架运行时模块加载失败。\n\n请管理员执行:\nnpm install -g openclaw@latest\nopenclaw gateway restart\n\n斜杠命令(如 /bot-ping)不受影响。");
1093
+ } catch { /* best-effort */ }
1094
+ }
1066
1095
  } finally {
1067
1096
  // 无论成功/失败/超时,都停止输入状态续期
1068
1097
  typing.keepAlive?.stop();
@@ -830,7 +830,11 @@ function fireHotUpgrade(targetVersion?: string): HotUpgradeStartResult {
830
830
  /**
831
831
  * /bot-upgrade — 统一升级入口
832
832
  *
833
- * 产品流程:
833
+ * upgradeMode 开关:
834
+ * - "doc"(默认):只展示升级指引文档,不执行热更新
835
+ * - "hot-reload":执行 npm 升级脚本进行热更新
836
+ *
837
+ * 热更新模式下的产品流程:
834
838
  * /bot-upgrade — 展示版本信息+确认按钮(不直接升级)
835
839
  * /bot-upgrade --latest — 确认升级到最新版本
836
840
  * /bot-upgrade --version X — 升级到指定版本
@@ -840,21 +844,54 @@ let _upgrading = false; // 升级锁
840
844
 
841
845
  registerCommand({
842
846
  name: "bot-upgrade",
843
- description: "检查更新并自动热更",
847
+ description: "检查更新并查看升级指引",
844
848
  usage: [
845
- `/bot-upgrade 检查是否有新版本(展示信息+确认按钮)`,
846
- `/bot-upgrade --latest 确认升级到最新版本`,
847
- `/bot-upgrade --version X 升级到指定版本(如 1.6.5)`,
848
- `/bot-upgrade --force 强制重新安装当前版本`,
849
- ``,
850
- `⚠️ 仅在私聊中可用。升级过程约 30~60 秒,期间服务短暂不可用。`,
851
- ``,
852
- `环境要求:`,
853
- ` - 操作系统:macOS / Linux / Windows`,
854
- ` - OpenClaw 框架版本 ≥ ${UPGRADE_REQUIREMENTS.minFrameworkVersion}`,
855
- ` - Node.js ≥ v${UPGRADE_REQUIREMENTS.minNodeVersion}`,
849
+ `/bot-upgrade 检查是否有新版本`,
850
+ `/bot-upgrade --latest 确认升级到最新版本(需 upgradeMode=hot-reload)`,
851
+ `/bot-upgrade --version X 升级到指定版本(需 upgradeMode=hot-reload)`,
852
+ `/bot-upgrade --force 强制重新安装当前版本(需 upgradeMode=hot-reload)`,
856
853
  ].join("\n"),
857
854
  handler: async (ctx) => {
855
+ const url = ctx.accountConfig?.upgradeUrl || DEFAULT_UPGRADE_URL;
856
+ const upgradeMode = ctx.accountConfig?.upgradeMode || "doc";
857
+ const args = ctx.args.trim();
858
+ const info = await getUpdateInfo();
859
+
860
+ const GITHUB_URL = "https://github.com/tencent-connect/openclaw-qqbot/";
861
+
862
+ // ── doc 模式(默认):只展示升级指引,不执行热更新 ──
863
+ if (upgradeMode !== "hot-reload") {
864
+ if (info.checkedAt === 0) {
865
+ return `⏳ 版本检查中,请稍后再试`;
866
+ }
867
+ if (info.error) {
868
+ return [
869
+ `❌ 主机网络访问异常,无法检查更新`,
870
+ ``,
871
+ `查看升级指引:[点击查看](${url})`,
872
+ ].join("\n");
873
+ }
874
+ if (!info.hasUpdate) {
875
+ return [
876
+ `✅ 当前已是最新版本 v${PLUGIN_VERSION}`,
877
+ ``,
878
+ `项目地址:[GitHub](${GITHUB_URL})`,
879
+ ].join("\n");
880
+ }
881
+
882
+ return [
883
+ `🆕 发现新版本`,
884
+ ``,
885
+ `当前版本:**v${PLUGIN_VERSION}**`,
886
+ `最新版本:**v${info.latest}**`,
887
+ ``,
888
+ `📖 升级指引:[点击查看](${url})`,
889
+ `🌟 官方 GitHub 仓库:[点击前往](${GITHUB_URL})`,
890
+ ].join("\n");
891
+ }
892
+
893
+ // ── hot-reload 模式:执行热更新 ──
894
+
858
895
  // 升级相关指令仅在私聊中可用
859
896
  if (ctx.type !== "c2c") {
860
897
  return `💡 请在私聊中使用此指令`;
@@ -865,10 +902,6 @@ registerCommand({
865
902
  return `⏳ 正在升级中,请稍候...`;
866
903
  }
867
904
 
868
- const url = ctx.accountConfig?.upgradeUrl || DEFAULT_UPGRADE_URL;
869
- const args = ctx.args.trim();
870
- const info = await getUpdateInfo();
871
-
872
905
  let isForce = false;
873
906
  let isLatest = false;
874
907
  let versionArg: string | undefined;
@@ -906,8 +939,6 @@ registerCommand({
906
939
  }
907
940
  }
908
941
 
909
- const GITHUB_URL = "https://github.com/tencent-connect/openclaw-qqbot/";
910
-
911
942
  // ── 无参数(也没有 --latest / --version / --force):只展示信息+确认按钮 ──
912
943
  if (!versionArg && !isLatest && !isForce) {
913
944
  if (info.checkedAt === 0) {
@@ -929,7 +960,7 @@ registerCommand({
929
960
  return lines.join("\n");
930
961
  }
931
962
 
932
- // 有新版本:展示信息 + 确认按钮(同通道:alpha 只展示 alpha,正式版只展示正式版)
963
+ // 有新版本:展示信息 + 确认按钮
933
964
  return [
934
965
  `🆕 发现新版本`,
935
966
  ``,