收敛微信 sidecar 到官方单链路并同步文档与回归测试。

移除 weixin 安装与启动脚本中的 legacy/localSource 分支,只保留 official_runner 路径,统一开源安装命令并更新 RUNBOOK/Quickstart/README,确保脚本行为与测试预期一致。

Made-with: Cursor
This commit is contained in:
oliver 2026-04-29 01:10:25 +08:00
parent 3122b8a16c
commit 853dc1812f
7 changed files with 43 additions and 116 deletions

View file

@ -1,7 +1,5 @@
param(
[string]$ChannelId = "oclaw-weixin",
[string]$LocalSourcePath = "",
[switch]$UseOpenclawCli = $false
[string]$ChannelId = "oclaw-weixin"
)
$ErrorActionPreference = "Stop"
@ -16,6 +14,16 @@ $oclawRoot = Resolve-RepoRoot
$sidecarRoot = Join-Path $oclawRoot "data\\channel_sidecar\\$ChannelId"
$stateDir = Join-Path $sidecarRoot "state"
$pluginRoot = Join-Path $env:USERPROFILE ".openclaw\\extensions\\openclaw-weixin"
function Sync-WeixinBridgeRunners {
$bridgeSrc = Join-Path $oclawRoot "runtime\\operations\\weixin_bridge"
foreach ($name in @("official_runner.ts", "login.ts")) {
$srcPath = Join-Path $bridgeSrc $name
if (-not (Test-Path $srcPath)) {
throw "missing bridge source file: $srcPath"
}
Copy-Item -Path $srcPath -Destination (Join-Path $sidecarRoot $name) -Force
}
}
New-Item -ItemType Directory -Force -Path $sidecarRoot | Out-Null
New-Item -ItemType Directory -Force -Path (Join-Path $sidecarRoot "logs") | Out-Null
@ -36,52 +44,6 @@ function Ensure-OfficialPluginRuntimeDeps {
}
}
if ($UseOpenclawCli) {
# Do not require a globally-installed openclaw CLI.
# We install openclaw into the sidecar runtime and put node_modules/.bin on PATH
# so the official installer can run `openclaw ...` commands.
Push-Location $sidecarRoot
try {
if (-not (Test-Path (Join-Path $sidecarRoot "package.json"))) {
npm.cmd init -y | Out-Null
if ($LASTEXITCODE -ne 0) {
throw "npm init failed with exit code $LASTEXITCODE"
}
}
npm.cmd install openclaw@latest --save
if ($LASTEXITCODE -ne 0) {
throw "npm install openclaw failed with exit code $LASTEXITCODE"
}
$env:PATH = (Join-Path $sidecarRoot "node_modules\\.bin") + ";" + $env:PATH
npx.cmd -y @tencent-weixin/openclaw-weixin-cli@latest install
if ($LASTEXITCODE -ne 0) {
throw "openclaw-weixin-cli install failed with exit code $LASTEXITCODE"
}
} finally {
Pop-Location
}
Ensure-OfficialPluginRuntimeDeps
Push-Location $sidecarRoot
try {
npm.cmd install openclaw@latest --save tsx@4.21.0 typescript@6.0.3
if ($LASTEXITCODE -ne 0) {
throw "npm install bridge runtime deps failed with exit code $LASTEXITCODE"
}
$bridgeSrc = Join-Path $oclawRoot "runtime\\operations\\weixin_bridge"
Copy-Item -Path (Join-Path $bridgeSrc "runner.ts") -Destination (Join-Path $sidecarRoot "runner.ts") -Force
Copy-Item -Path (Join-Path $bridgeSrc "official_runner.ts") -Destination (Join-Path $sidecarRoot "official_runner.ts") -Force
Copy-Item -Path (Join-Path $bridgeSrc "login.ts") -Destination (Join-Path $sidecarRoot "login.ts") -Force
} finally {
Pop-Location
}
Write-Host "[ok] installed official openclaw-weixin plugin + native/fallback sidecar runtime"
exit 0
}
if (-not $LocalSourcePath) {
throw "LocalSourcePath is required in sidecar mode. Example: .\\scripts\\weixin_install.ps1 -LocalSourcePath D:\\path\\to\\your-weixin-module"
}
Push-Location $sidecarRoot
try {
if (-not (Test-Path (Join-Path $sidecarRoot "package.json"))) {
@ -90,21 +52,18 @@ try {
throw "npm init failed with exit code $LASTEXITCODE"
}
}
$src = (Resolve-Path $LocalSourcePath).Path
npm.cmd install --save-exact $src tsx@4.21.0 typescript@6.0.3
npx.cmd -y @tencent-weixin/openclaw-weixin-cli@latest install
if ($LASTEXITCODE -ne 0) {
throw "npm install local source failed with exit code $LASTEXITCODE"
throw "openclaw-weixin-cli install failed with exit code $LASTEXITCODE"
}
if (-not (Test-Path (Join-Path $sidecarRoot "runner.ts"))) {
throw "install completed but runner.ts is missing (invalid sidecar package/source)"
npm.cmd install openclaw@latest --save tsx@4.21.0 typescript@6.0.3
if ($LASTEXITCODE -ne 0) {
throw "npm install bridge runtime deps failed with exit code $LASTEXITCODE"
}
if (-not (Test-Path (Join-Path $sidecarRoot "login.ts"))) {
throw "install completed but login.ts is missing (invalid sidecar package/source)"
}
Write-Host "[ok] installed local weixin sidecar into $sidecarRoot"
} finally {
Pop-Location
}
Ensure-OfficialPluginRuntimeDeps
Sync-WeixinBridgeRunners
Write-Host "[ok] installed official openclaw-weixin plugin sidecar runtime into $sidecarRoot"