@simonyea/holysheep-cli 1.7.76 → 1.7.78
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/tools/claude-process-proxy.js +13 -34
- package/src/webui/server.js +8 -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.78",
|
|
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",
|
|
@@ -113,48 +113,27 @@ function deriveNodeProxyUrl(lease) {
|
|
|
113
113
|
return upstream.toString().replace(/\/+$/, '')
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
// 去掉模型 ID 中的 [1m] 后缀 — CRS 用标准模型 ID 做多账号调度
|
|
117
|
-
function stripModelSuffix(body) {
|
|
118
|
-
if (!body || !body.includes('"model"')) return body
|
|
119
|
-
return body.replace(/("model"\s*:\s*"claude-(?:sonnet|opus)-[\w.-]+)\[1m\](")/g, '$1$2')
|
|
120
|
-
}
|
|
121
|
-
|
|
122
116
|
function forwardViaNodeProxy({ nodeProxyUrl, targetUrl, clientReq, clientRes, extraHeaders = {} }) {
|
|
123
117
|
const upstream = new URL(nodeProxyUrl)
|
|
124
118
|
return new Promise((resolve, reject) => {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (isJson) {
|
|
132
|
-
body = Buffer.from(stripModelSuffix(body.toString('utf8')))
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const headers = {
|
|
119
|
+
const forwardReq = http.request({
|
|
120
|
+
host: upstream.hostname,
|
|
121
|
+
port: Number(upstream.port || 80),
|
|
122
|
+
method: clientReq.method,
|
|
123
|
+
path: targetUrl.toString(),
|
|
124
|
+
headers: {
|
|
136
125
|
...clientReq.headers,
|
|
137
126
|
...extraHeaders,
|
|
138
127
|
host: targetUrl.host,
|
|
139
|
-
'content-length': body.length,
|
|
140
128
|
connection: 'close',
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
method: clientReq.method,
|
|
147
|
-
path: targetUrl.toString(),
|
|
148
|
-
headers,
|
|
149
|
-
}, (forwardRes) => {
|
|
150
|
-
clientRes.writeHead(forwardRes.statusCode || 502, forwardRes.headers)
|
|
151
|
-
forwardRes.pipe(clientRes)
|
|
152
|
-
resolve()
|
|
153
|
-
})
|
|
154
|
-
forwardReq.once('error', reject)
|
|
155
|
-
forwardReq.end(body)
|
|
129
|
+
},
|
|
130
|
+
}, (forwardRes) => {
|
|
131
|
+
clientRes.writeHead(forwardRes.statusCode || 502, forwardRes.headers)
|
|
132
|
+
forwardRes.pipe(clientRes)
|
|
133
|
+
resolve()
|
|
156
134
|
})
|
|
157
|
-
|
|
135
|
+
forwardReq.once('error', reject)
|
|
136
|
+
clientReq.pipe(forwardReq)
|
|
158
137
|
})
|
|
159
138
|
}
|
|
160
139
|
|
package/src/webui/server.js
CHANGED
|
@@ -768,7 +768,14 @@ function startServer(port) {
|
|
|
768
768
|
if (err.code === 'EADDRINUSE') {
|
|
769
769
|
// Try to kill stale process and retry once
|
|
770
770
|
try {
|
|
771
|
-
|
|
771
|
+
if (process.platform === 'win32') {
|
|
772
|
+
// Windows: find PID by port and kill
|
|
773
|
+
const out = execSync(`netstat -ano | findstr :${port} | findstr LISTENING`, { stdio: 'pipe', encoding: 'utf8', shell: true })
|
|
774
|
+
const pids = [...new Set(out.match(/\d+\s*$/gm)?.map(s => s.trim()).filter(Boolean) || [])]
|
|
775
|
+
for (const pid of pids) { try { execSync(`taskkill /F /PID ${pid}`, { stdio: 'ignore' }) } catch {} }
|
|
776
|
+
} else {
|
|
777
|
+
execSync(`lsof -ti:${port} | xargs kill -9`, { stdio: 'ignore' })
|
|
778
|
+
}
|
|
772
779
|
} catch {}
|
|
773
780
|
setTimeout(() => {
|
|
774
781
|
const retry = http.createServer(handleRequest)
|