@simonyea/holysheep-cli 1.7.115 → 1.7.116

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simonyea/holysheep-cli",
3
- "version": "1.7.115",
3
+ "version": "1.7.116",
4
4
  "description": "Claude Code/Cursor/Cline API relay for China — ¥1=$1, WeChat/Alipay payment, no credit card, no VPN. One command setup for all AI coding tools.",
5
5
  "keywords": [
6
6
  "openai-china",
@@ -59,11 +59,12 @@ function isProcessAlive(pid) {
59
59
 
60
60
  function isProxyHealthy(port) {
61
61
  try {
62
+ // Windows: Invoke-WebRequest 遇到 500 会抛异常,改用 TCP 端口检查
62
63
  execSync(
63
64
  isWin
64
- ? `powershell -NonInteractive -Command "try{(Invoke-WebRequest -Uri http://127.0.0.1:${port}/ -TimeoutSec 1 -UseBasicParsing).StatusCode}catch{exit 1}"`
65
- : `curl -sf http://127.0.0.1:${port}/ -o /dev/null --max-time 1`,
66
- { stdio: 'ignore', timeout: 3000, windowsHide: true }
65
+ ? `powershell -NonInteractive -Command "if(Get-NetTCPConnection -LocalPort ${port} -State Listen -ErrorAction SilentlyContinue){exit 0}else{exit 1}"`
66
+ : `curl -so /dev/null --max-time 1 http://127.0.0.1:${port}/`,
67
+ { stdio: 'ignore', timeout: 5000, windowsHide: true }
67
68
  )
68
69
  return true
69
70
  } catch {
@@ -781,14 +781,12 @@ module.exports = {
781
781
  },
782
782
  ensureGatewayRunning(port) {
783
783
  port = port || getConfiguredGatewayPort()
784
- // 先检查是否已在运行
784
+ // 检查端口是否有进程在监听(不依赖 HTTP 状态码,500 也算运行中)
785
785
  try {
786
- execSync(
787
- isWin
788
- ? `powershell -NonInteractive -Command "try{(Invoke-WebRequest -Uri http://127.0.0.1:${port}/ -TimeoutSec 1 -UseBasicParsing).StatusCode}catch{exit 1}"`
789
- : `curl -sf http://127.0.0.1:${port}/ -o /dev/null --max-time 1`,
790
- { stdio: 'ignore', timeout: 3000 }
791
- )
786
+ const checkCmd = isWin
787
+ ? `powershell -NonInteractive -Command "if(Get-NetTCPConnection -LocalPort ${port} -State Listen -ErrorAction SilentlyContinue){exit 0}else{exit 1}"`
788
+ : `curl -so /dev/null --max-time 1 http://127.0.0.1:${port}/ || lsof -iTCP:${port} -sTCP:LISTEN -t >/dev/null 2>&1`
789
+ execSync(checkCmd, { stdio: 'ignore', timeout: 5000 })
792
790
  return true
793
791
  } catch {}
794
792
  // 未运行,启动它
@@ -502,9 +502,11 @@ async function handleUpgrade(_req, res) {
502
502
  newVer = m ? m[1] : null
503
503
  } catch {}
504
504
 
505
- // OpenClaw 升级后自动重启网关
506
- if (ok && tool.id === 'openclaw' && commandExists('openclaw')) {
505
+ // OpenClaw 升级后自动重启 Bridge + Gateway
506
+ if (ok && tool.id === 'openclaw') {
507
507
  try { execSync('openclaw daemon stop', { stdio: 'ignore', timeout: 10000 }) } catch {}
508
+ const openclawTool = TOOLS.find(t => t.id === 'openclaw')
509
+ try { openclawTool?.ensureBridgeRunning?.() } catch {}
508
510
  try { execSync('openclaw daemon start', { stdio: 'ignore', timeout: 30000 }) } catch {}
509
511
  }
510
512
 
@@ -659,17 +661,24 @@ async function handleToolUpgrade(req, res) {
659
661
 
660
662
  if (ok) {
661
663
  sseEmit(res, { type: 'progress', message: `✓ ${entry.name} 升级成功: ${localVer || '?'} → ${newVer || 'latest'}` })
662
- // OpenClaw 升级后自动重启网关,否则运行中的进程还是旧版本
663
- if (entry.id === 'openclaw' && commandExists('openclaw')) {
664
- sseEmit(res, { type: 'progress', message: '正在重启 OpenClaw 网关...' })
665
- try {
666
- execSync('openclaw daemon stop', { stdio: 'ignore', timeout: 10000 })
667
- } catch {}
664
+ // OpenClaw 升级后自动重启 Bridge + Gateway
665
+ if (entry.id === 'openclaw') {
666
+ const openclawTool = TOOLS.find(t => t.id === 'openclaw')
667
+ sseEmit(res, { type: 'progress', message: '正在重启 OpenClaw...' })
668
+ try { execSync('openclaw daemon stop', { stdio: 'ignore', timeout: 10000 }) } catch {}
669
+ if (openclawTool?.ensureBridgeRunning) {
670
+ try {
671
+ openclawTool.ensureBridgeRunning()
672
+ sseEmit(res, { type: 'progress', message: '✓ HolySheep Bridge 已启动' })
673
+ } catch {
674
+ sseEmit(res, { type: 'progress', message: '⚠️ Bridge 启动失败' })
675
+ }
676
+ }
668
677
  try {
669
678
  execSync('openclaw daemon start', { stdio: 'ignore', timeout: 30000 })
670
- sseEmit(res, { type: 'progress', message: '✓ OpenClaw 网关已重启' })
679
+ sseEmit(res, { type: 'progress', message: '✓ OpenClaw Gateway 已重启' })
671
680
  } catch {
672
- sseEmit(res, { type: 'progress', message: '⚠️ 网关重启失败,请手动运行: openclaw daemon start' })
681
+ sseEmit(res, { type: 'progress', message: '⚠️ Gateway 重启失败,请手动运行: openclaw daemon start' })
673
682
  }
674
683
  }
675
684
  } else {