@simonyea/holysheep-cli 1.7.38 → 1.7.39

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.38",
3
+ "version": "1.7.39",
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",
@@ -63,6 +63,22 @@ function killPortListeners(port) {
63
63
  return killed
64
64
  }
65
65
 
66
+ // 在 bridge 启动前调用:清空 gatewayStartedAt,让 watchdog 以 bridgeStartedAt(进程刚启动)
67
+ // 为基准,并把宽限期延长到 60s,确保 gateway 有足够时间启动。
68
+ function prepareForRestart(gatewayPort) {
69
+ const { BRIDGE_CONFIG_FILE } = require('../tools/openclaw-bridge')
70
+ const fs = require('fs')
71
+ try {
72
+ const raw = JSON.parse(fs.readFileSync(BRIDGE_CONFIG_FILE, 'utf8'))
73
+ raw.gatewayStartedAt = null // watchdog fallback 到 bridgeStartedAt(始终是刚启动的时间)
74
+ raw.gatewayPort = gatewayPort
75
+ if (!raw.watchdog) raw.watchdog = {}
76
+ raw.watchdog.startupGraceMs = 60000 // 给 bridge+gateway 全套重启留出 60s
77
+ fs.writeFileSync(BRIDGE_CONFIG_FILE, JSON.stringify(raw, null, 2), 'utf8')
78
+ } catch {}
79
+ }
80
+
81
+ // 在 gateway 确认就绪后调用:写入真实 gatewayStartedAt,恢复正常 30s 宽限期。
66
82
  function refreshGatewayStartedAt(gatewayPort) {
67
83
  const { BRIDGE_CONFIG_FILE } = require('../tools/openclaw-bridge')
68
84
  const fs = require('fs')
@@ -72,6 +88,7 @@ function refreshGatewayStartedAt(gatewayPort) {
72
88
  raw.gatewayPort = gatewayPort
73
89
  raw.gatewayPid = null
74
90
  raw.gatewayLaunchMode = 'direct-process'
91
+ if (raw.watchdog) raw.watchdog.startupGraceMs = 30000
75
92
  fs.writeFileSync(BRIDGE_CONFIG_FILE, JSON.stringify(raw, null, 2), 'utf8')
76
93
  } catch {}
77
94
  }
@@ -148,6 +165,10 @@ async function openclaw() {
148
165
  const bridgePort = openclawTool.getBridgePort()
149
166
  const gatewayPort = openclawTool.getGatewayPort()
150
167
 
168
+ // 在所有 spawn 之前写好 config:清空 gatewayStartedAt + 延长宽限期到 60s
169
+ // 这样新 bridge 的 watchdog 第一次 tick 读到的就是新鲜的基准时间,不会立即过期
170
+ prepareForRestart(gatewayPort)
171
+
151
172
  // 先杀掉旧 Bridge,再启动新的
152
173
  const existingBridgeListeners = openclawTool.getPortListeners(bridgePort)
153
174
  if (existingBridgeListeners.length > 0) {