@simonyea/holysheep-cli 1.7.113 → 1.7.115

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.113",
3
+ "version": "1.7.115",
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",
@@ -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
 
@@ -205,27 +205,30 @@ function pipeWithCleanup(a, b) {
205
205
  if (typeof sock.setKeepAlive === 'function') sock.setKeepAlive(true, 10000)
206
206
  }
207
207
 
208
- // 单向响应超时:a 发了数据给 b,但 b 那边 30 秒没回任何数据 → 断开
209
- // 解决 node proxy 进程挂了但 TCP ESTABLISHED 的问题
210
- // 不影响 extended thinking:thinking a(客户端)没发新数据,不触发计时
211
- let responseTimer = null
212
- let bHasResponded = false
208
+ // 双阶段超时:
209
+ // 1. 客户端发了数据,上游 30 秒没回第一个字节 断开(node proxy 挂了)
210
+ // 2. 上游在流数据突然停了 120 → 断开(stream 中断)
211
+ // 120 秒足够覆盖 extended thinking 的间歇(thinking 期间服务端仍会发心跳)
212
+ let timer = null
213
+ let streaming = false
214
+ const kill = (reason) => {
215
+ if (timer) clearTimeout(timer)
216
+ a.destroy(new Error(reason))
217
+ b.destroy(new Error(reason))
218
+ }
213
219
  a.on('data', () => {
214
- // 客户端发了数据(请求),开始等上游响应
215
- if (!bHasResponded) {
216
- if (responseTimer) clearTimeout(responseTimer)
217
- responseTimer = setTimeout(() => {
218
- if (!bHasResponded) {
219
- a.destroy(new Error('upstream response timeout'))
220
- b.destroy(new Error('upstream response timeout'))
221
- }
222
- }, 30000)
220
+ // 客户端发了数据(请求),等上游响应
221
+ if (!streaming) {
222
+ if (timer) clearTimeout(timer)
223
+ timer = setTimeout(() => kill('upstream response timeout'), 30000)
223
224
  }
224
225
  })
225
226
  b.on('data', () => {
226
- // 上游回数据了,清掉超时
227
- bHasResponded = true
228
- if (responseTimer) { clearTimeout(responseTimer); responseTimer = null }
227
+ // 上游回数据了,切换到 stream 模式
228
+ streaming = true
229
+ // 每次收到数据重置 120 秒超时
230
+ if (timer) clearTimeout(timer)
231
+ timer = setTimeout(() => kill('upstream stream stalled'), 120000)
229
232
  })
230
233
 
231
234
  a.pipe(b)
@@ -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,12 @@ 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')) {
507
+ try { execSync('openclaw daemon stop', { stdio: 'ignore', timeout: 10000 }) } catch {}
508
+ try { execSync('openclaw daemon start', { stdio: 'ignore', timeout: 30000 }) } catch {}
509
+ }
510
+
505
511
  sseEmit(res, { type: 'tool', name: tool.name, status: ok ? 'ok' : 'error', localVer, newVer })
506
512
  }
507
513
 
@@ -653,6 +659,19 @@ async function handleToolUpgrade(req, res) {
653
659
 
654
660
  if (ok) {
655
661
  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 {}
668
+ try {
669
+ execSync('openclaw daemon start', { stdio: 'ignore', timeout: 30000 })
670
+ sseEmit(res, { type: 'progress', message: '✓ OpenClaw 网关已重启' })
671
+ } catch {
672
+ sseEmit(res, { type: 'progress', message: '⚠️ 网关重启失败,请手动运行: openclaw daemon start' })
673
+ }
674
+ }
656
675
  } else {
657
676
  sseEmit(res, { type: 'progress', message: `✗ ${entry.name} 升级失败` })
658
677
  }