@simonyea/holysheep-cli 1.7.114 → 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.114",
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 {
@@ -82,7 +82,7 @@ const AUTO_INSTALL = {
82
82
  'codex': { cmd: 'npm install -g @openai/codex', mgr: 'npm' },
83
83
  'gemini-cli': { cmd: 'npm install -g @google/gemini-cli', mgr: 'npm' },
84
84
  'opencode': { cmd: 'npm install -g opencode-ai', mgr: 'npm' },
85
- 'openclaw': { cmd: 'npm install -g openclaw@latest --ignore-scripts', mgr: 'npm' },
85
+ 'openclaw': { cmd: 'npm install -g openclaw@latest', mgr: 'npm' },
86
86
  'aider': { cmd: 'pip install aider-chat', mgr: 'pip' },
87
87
  }
88
88
 
@@ -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
  // 未运行,启动它
@@ -120,7 +120,7 @@ const AUTO_INSTALL = {
120
120
  'codex': { cmd: 'npm install -g @openai/codex' },
121
121
  'gemini-cli': { cmd: 'npm install -g @google/gemini-cli' },
122
122
  'opencode': { cmd: 'npm install -g opencode-ai' },
123
- 'openclaw': { cmd: 'npm install -g openclaw@latest --ignore-scripts' },
123
+ 'openclaw': { cmd: 'npm install -g openclaw@latest' },
124
124
  'aider': { cmd: 'pip install aider-chat' },
125
125
  }
126
126
 
@@ -138,7 +138,7 @@ const UPGRADABLE_TOOLS = [
138
138
  { name: 'Codex CLI', id: 'codex', command: 'codex', versionCmd: 'codex --version', npmPkg: '@openai/codex', installCmd: 'npm install -g @openai/codex@latest' },
139
139
  { name: 'Droid CLI', id: 'droid', command: 'droid', versionCmd: 'droid --version', npmPkg: null, installCmd: process.platform === 'win32' ? 'winget upgrade --id Droid.Droid' : 'brew install --cask droid' },
140
140
  { name: 'OpenCode', id: 'opencode', command: 'opencode', versionCmd: 'opencode --version', npmPkg: 'opencode-ai', installCmd: 'npm install -g opencode-ai@latest' },
141
- { name: 'OpenClaw', id: 'openclaw', command: 'openclaw', versionCmd: 'openclaw --version', npmPkg: 'openclaw', installCmd: 'npm install -g openclaw@latest --ignore-scripts' },
141
+ { name: 'OpenClaw', id: 'openclaw', command: 'openclaw', versionCmd: 'openclaw --version', npmPkg: 'openclaw', installCmd: 'npm install -g openclaw@latest' },
142
142
  { name: 'Gemini CLI', id: 'gemini-cli', command: 'gemini', versionCmd: 'gemini --version', npmPkg: '@google/gemini-cli', installCmd: 'npm install -g @google/gemini-cli@latest' },
143
143
  ]
144
144
 
@@ -502,6 +502,14 @@ async function handleUpgrade(_req, res) {
502
502
  newVer = m ? m[1] : null
503
503
  } catch {}
504
504
 
505
+ // OpenClaw 升级后自动重启 Bridge + Gateway
506
+ if (ok && tool.id === 'openclaw') {
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 {}
510
+ try { execSync('openclaw daemon start', { stdio: 'ignore', timeout: 30000 }) } catch {}
511
+ }
512
+
505
513
  sseEmit(res, { type: 'tool', name: tool.name, status: ok ? 'ok' : 'error', localVer, newVer })
506
514
  }
507
515
 
@@ -653,6 +661,26 @@ async function handleToolUpgrade(req, res) {
653
661
 
654
662
  if (ok) {
655
663
  sseEmit(res, { type: 'progress', message: `✓ ${entry.name} 升级成功: ${localVer || '?'} → ${newVer || 'latest'}` })
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
+ }
677
+ try {
678
+ execSync('openclaw daemon start', { stdio: 'ignore', timeout: 30000 })
679
+ sseEmit(res, { type: 'progress', message: '✓ OpenClaw Gateway 已重启' })
680
+ } catch {
681
+ sseEmit(res, { type: 'progress', message: '⚠️ Gateway 重启失败,请手动运行: openclaw daemon start' })
682
+ }
683
+ }
656
684
  } else {
657
685
  sseEmit(res, { type: 'progress', message: `✗ ${entry.name} 升级失败` })
658
686
  }