@simonyea/holysheep-cli 1.7.34 → 1.7.35
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 +1 -1
- package/src/commands/openclaw.js +50 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simonyea/holysheep-cli",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.35",
|
|
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",
|
package/src/commands/openclaw.js
CHANGED
|
@@ -45,6 +45,33 @@ function waitForPort(checkFn, maxTries, intervalMs) {
|
|
|
45
45
|
return false
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
function killBridge(port) {
|
|
49
|
+
const listeners = openclawTool.getPortListeners(port)
|
|
50
|
+
let killed = 0
|
|
51
|
+
for (const item of listeners) {
|
|
52
|
+
const pid = parseInt(item.pid, 10)
|
|
53
|
+
if (!pid) continue
|
|
54
|
+
try {
|
|
55
|
+
if (isWin) {
|
|
56
|
+
spawnSync('taskkill', ['/PID', String(pid), '/F'], { stdio: 'ignore', shell: true })
|
|
57
|
+
} else {
|
|
58
|
+
process.kill(pid, 'SIGTERM')
|
|
59
|
+
}
|
|
60
|
+
killed++
|
|
61
|
+
} catch {}
|
|
62
|
+
}
|
|
63
|
+
return killed
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function waitPortFree(port, maxTries, intervalMs) {
|
|
67
|
+
for (let i = 0; i < maxTries; i++) {
|
|
68
|
+
if (openclawTool.getPortListeners(port).length === 0) return true
|
|
69
|
+
const t0 = Date.now()
|
|
70
|
+
while (Date.now() - t0 < intervalMs) {}
|
|
71
|
+
}
|
|
72
|
+
return openclawTool.getPortListeners(port).length === 0
|
|
73
|
+
}
|
|
74
|
+
|
|
48
75
|
function openBrowser(url) {
|
|
49
76
|
const cmd = isWin ? 'start' : process.platform === 'darwin' ? 'open' : 'xdg-open'
|
|
50
77
|
try {
|
|
@@ -79,28 +106,32 @@ async function openclaw() {
|
|
|
79
106
|
const bridgePort = openclawTool.getBridgePort()
|
|
80
107
|
const gatewayPort = openclawTool.getGatewayPort()
|
|
81
108
|
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
|
|
109
|
+
// 先杀掉旧 Bridge,再启动新的
|
|
110
|
+
const existingListeners = openclawTool.getPortListeners(bridgePort)
|
|
111
|
+
if (existingListeners.length > 0) {
|
|
112
|
+
process.stdout.write(chalk.gray(` 正在重启 Bridge (端口 ${bridgePort})... `))
|
|
113
|
+
killBridge(bridgePort)
|
|
114
|
+
waitPortFree(bridgePort, 10, 200)
|
|
85
115
|
} else {
|
|
86
116
|
process.stdout.write(chalk.gray(` 正在启动 Bridge (端口 ${bridgePort})... `))
|
|
87
|
-
|
|
88
|
-
const spawnCmd = isWin ? 'node' : process.execPath
|
|
89
|
-
const child = spawn(spawnCmd, [scriptPath, 'openclaw-bridge', '--port', String(bridgePort)], {
|
|
90
|
-
detached: true,
|
|
91
|
-
stdio: 'ignore',
|
|
92
|
-
windowsHide: true,
|
|
93
|
-
})
|
|
94
|
-
child.unref()
|
|
117
|
+
}
|
|
95
118
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
119
|
+
const scriptPath = path.join(__dirname, '..', 'index.js')
|
|
120
|
+
const spawnCmd = isWin ? 'node' : process.execPath
|
|
121
|
+
const child = spawn(spawnCmd, [scriptPath, 'openclaw-bridge', '--port', String(bridgePort)], {
|
|
122
|
+
detached: true,
|
|
123
|
+
stdio: 'ignore',
|
|
124
|
+
windowsHide: true,
|
|
125
|
+
})
|
|
126
|
+
child.unref()
|
|
127
|
+
|
|
128
|
+
const bridgeReady = waitForPort(() => checkBridgeHealth(bridgePort), 10, 1000)
|
|
129
|
+
if (bridgeReady) {
|
|
130
|
+
console.log(chalk.green('✓'))
|
|
131
|
+
} else {
|
|
132
|
+
console.log(chalk.red('✗'))
|
|
133
|
+
console.log(chalk.red(` Bridge 启动失败,请手动运行: hs openclaw-bridge --port ${bridgePort}`))
|
|
134
|
+
process.exit(1)
|
|
104
135
|
}
|
|
105
136
|
|
|
106
137
|
// 确保 Gateway 运行
|