@simonyea/holysheep-cli 1.7.119 → 1.7.120
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/webui.js +6 -0
- package/src/webui/server.js +64 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simonyea/holysheep-cli",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.120",
|
|
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/webui.js
CHANGED
|
@@ -31,6 +31,12 @@ async function webui(opts) {
|
|
|
31
31
|
} catch {}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
// 后台拉起 OpenClaw Bridge + Claude Proxy
|
|
35
|
+
const { bootstrapBackgroundServices } = require('../webui/server')
|
|
36
|
+
bootstrapBackgroundServices().then(() => {
|
|
37
|
+
console.log(chalk.gray(' 后台服务已就绪'))
|
|
38
|
+
}).catch(() => {})
|
|
39
|
+
|
|
34
40
|
// Keep alive
|
|
35
41
|
await new Promise(() => {})
|
|
36
42
|
} catch (err) {
|
package/src/webui/server.js
CHANGED
|
@@ -1132,4 +1132,67 @@ function startServer(port) {
|
|
|
1132
1132
|
})
|
|
1133
1133
|
}
|
|
1134
1134
|
|
|
1135
|
-
|
|
1135
|
+
// ── 后台服务自动拉起 ─────────────────────────────────────────────────────────
|
|
1136
|
+
|
|
1137
|
+
async function bootstrapBackgroundServices() {
|
|
1138
|
+
const { getApiKey } = require('../utils/config')
|
|
1139
|
+
const apiKey = getApiKey()
|
|
1140
|
+
if (!apiKey) return // 未登录,跳过
|
|
1141
|
+
|
|
1142
|
+
// 1. OpenClaw Bridge
|
|
1143
|
+
try {
|
|
1144
|
+
const openclawTool = TOOLS.find(t => t.id === 'openclaw')
|
|
1145
|
+
if (openclawTool?.checkInstalled() && openclawTool?.isConfigured()) {
|
|
1146
|
+
const bridgePort = openclawTool.getBridgePort?.() || 18788
|
|
1147
|
+
// 检查是否已在运行
|
|
1148
|
+
let bridgeAlive = false
|
|
1149
|
+
try {
|
|
1150
|
+
const http = require('http')
|
|
1151
|
+
await new Promise((resolve, reject) => {
|
|
1152
|
+
const req = http.get({ hostname: '127.0.0.1', port: bridgePort, path: '/health', family: 4 }, resolve)
|
|
1153
|
+
req.setTimeout(2000, () => { req.destroy(); reject() })
|
|
1154
|
+
req.on('error', reject)
|
|
1155
|
+
})
|
|
1156
|
+
bridgeAlive = true
|
|
1157
|
+
} catch {}
|
|
1158
|
+
|
|
1159
|
+
if (!bridgeAlive) {
|
|
1160
|
+
// 先确保 gateway PID 在 bridge config 里是最新的
|
|
1161
|
+
const gatewayPort = openclawTool.getGatewayPort?.() || 18789
|
|
1162
|
+
try {
|
|
1163
|
+
let gPid = null
|
|
1164
|
+
if (process.platform === 'win32') {
|
|
1165
|
+
const o = execSync(`powershell -NonInteractive -Command "(Get-NetTCPConnection -LocalPort ${gatewayPort} -State Listen -ErrorAction SilentlyContinue).OwningProcess"`, { stdio: 'pipe', timeout: 5000 }).toString().trim()
|
|
1166
|
+
gPid = Number(o.split(/\r?\n/)[0]) || null
|
|
1167
|
+
} else {
|
|
1168
|
+
const o = execSync(`lsof -iTCP:${gatewayPort} -sTCP:LISTEN -t 2>/dev/null | head -1`, { stdio: 'pipe', timeout: 5000 }).toString().trim()
|
|
1169
|
+
gPid = Number(o) || null
|
|
1170
|
+
}
|
|
1171
|
+
if (gPid) {
|
|
1172
|
+
const bridgeMod = require('../tools/openclaw-bridge')
|
|
1173
|
+
const bc = bridgeMod.readBridgeConfig()
|
|
1174
|
+
if (bc.gatewayPid !== gPid) {
|
|
1175
|
+
bc.gatewayPid = gPid
|
|
1176
|
+
bc.gatewayStartedAt = new Date().toISOString()
|
|
1177
|
+
fs.writeFileSync(bridgeMod.BRIDGE_CONFIG_FILE, JSON.stringify(bc, null, 2), 'utf8')
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
} catch {}
|
|
1181
|
+
openclawTool.ensureBridgeRunning?.(bridgePort)
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
} catch {}
|
|
1185
|
+
|
|
1186
|
+
// 2. Claude Proxy
|
|
1187
|
+
try {
|
|
1188
|
+
const claudeTool = TOOLS.find(t => t.id === 'claude-code')
|
|
1189
|
+
if (claudeTool?.checkInstalled() && claudeTool?.isConfigured()) {
|
|
1190
|
+
if (!isClaudeProxyRunning().running) {
|
|
1191
|
+
const claudeProxy = require('../commands/claude-proxy')
|
|
1192
|
+
await claudeProxy(['--daemon'])
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
} catch {}
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
module.exports = { startServer, bootstrapBackgroundServices }
|