From 3f0f13d793c24dc0fe1a59bfbeb72570df6c0983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E5=A4=A9?= Date: Thu, 26 Mar 2026 03:59:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BE=AE=E4=BF=A1=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=A3=80=E6=B5=8B=20OpenClaw=20=E7=89=88?= =?UTF-8?q?=E6=9C=AC=EF=BC=8C=E6=97=A7=E7=89=88=E8=87=AA=E5=8A=A8=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=85=BC=E5=AE=B9=E7=9A=84=20v1.0.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - messaging.rs: run_channel_action weixin install 检测 OpenClaw 版本 - OpenClaw < 2026.3.22 → 自动用 @tencent-weixin/openclaw-weixin-cli@1.0.3 - OpenClaw >= 2026.3.22 → 用 @latest --- src-tauri/src/commands/messaging.rs | 32 ++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/commands/messaging.rs b/src-tauri/src/commands/messaging.rs index 854917c..d6e2b54 100644 --- a/src-tauri/src/commands/messaging.rs +++ b/src-tauri/src/commands/messaging.rs @@ -1173,9 +1173,35 @@ pub async fn run_channel_action( // weixin install 走 npx 而非 openclaw CLI if platform == "weixin" && action == "install" { - let weixin_spec = match &version { - Some(v) if !v.is_empty() => format!("@tencent-weixin/openclaw-weixin-cli@{}", v), - _ => "@tencent-weixin/openclaw-weixin-cli@latest".to_string(), + // 微信 CLI 版本号独立于 OpenClaw(1.0.x / 2.0.x),不能用 OpenClaw 版本号 pin + // v2.0.1 需要 OpenClaw >= 2026.3.22 的 SDK,旧版用 v1.0.3(最后兼容版) + let weixin_spec = if version.as_deref().map_or(false, |v| !v.is_empty()) { + format!( + "@tencent-weixin/openclaw-weixin-cli@{}", + version.as_deref().unwrap() + ) + } else { + // 检测 OpenClaw 版本,决定装哪个 + let oc_ver = crate::utils::resolve_openclaw_cli_path() + .and_then(|_| { + let out = crate::utils::openclaw_command() + .arg("--version") + .output() + .ok()?; + let raw = String::from_utf8_lossy(&out.stdout).trim().to_string(); + raw.split_whitespace().last().map(String::from) + }) + .unwrap_or_default(); + let oc_nums: Vec = oc_ver + .split(|c: char| !c.is_ascii_digit()) + .filter_map(|s| s.parse().ok()) + .collect(); + let needs_legacy = oc_nums < vec![2026, 3, 22]; + if needs_legacy { + "@tencent-weixin/openclaw-weixin-cli@1.0.3".to_string() + } else { + "@tencent-weixin/openclaw-weixin-cli@latest".to_string() + } }; let _ = app.emit( "channel-action-log",