@simonyea/holysheep-cli 1.7.107 → 1.7.109
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.
|
|
3
|
+
"version": "1.7.109",
|
|
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",
|
|
@@ -61,9 +61,13 @@ function isRetryableNodeLeaseError(err) {
|
|
|
61
61
|
'No available Claude accounts support the requested model',
|
|
62
62
|
'No available Claude accounts',
|
|
63
63
|
'Bad Gateway',
|
|
64
|
+
'HTTP 402',
|
|
65
|
+
'HTTP 403',
|
|
64
66
|
'HTTP 502',
|
|
65
67
|
'HTTP 503',
|
|
66
|
-
'HTTP 504'
|
|
68
|
+
'HTTP 504',
|
|
69
|
+
'client_validation_error',
|
|
70
|
+
'不可用'
|
|
67
71
|
].some((token) => message.includes(token))
|
|
68
72
|
}
|
|
69
73
|
|
|
@@ -148,7 +152,18 @@ function forwardViaNodeProxy({ nodeProxyUrl, targetUrl, clientReq, clientRes, ex
|
|
|
148
152
|
connection: 'close',
|
|
149
153
|
},
|
|
150
154
|
}, (forwardRes) => {
|
|
151
|
-
|
|
155
|
+
const status = forwardRes.statusCode || 502
|
|
156
|
+
if (status === 403 || status === 502 || status === 503) {
|
|
157
|
+
// 收集响应体用于错误消息,不透传给客户端
|
|
158
|
+
const chunks = []
|
|
159
|
+
forwardRes.on('data', (c) => chunks.push(c))
|
|
160
|
+
forwardRes.on('end', () => {
|
|
161
|
+
const body = Buffer.concat(chunks).toString('utf8')
|
|
162
|
+
reject(new Error(`HTTP ${status}: ${body.slice(0, 200)}`))
|
|
163
|
+
})
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
clientRes.writeHead(status, forwardRes.headers)
|
|
152
167
|
forwardRes.pipe(clientRes)
|
|
153
168
|
resolve()
|
|
154
169
|
})
|
|
@@ -182,6 +197,15 @@ function createConnectTunnel(proxyUrl, target, headers) {
|
|
|
182
197
|
}
|
|
183
198
|
|
|
184
199
|
function pipeWithCleanup(a, b) {
|
|
200
|
+
// TCP keepalive: 30秒探测一次,快速发现死连接
|
|
201
|
+
for (const sock of [a, b]) {
|
|
202
|
+
if (typeof sock.setKeepAlive === 'function') sock.setKeepAlive(true, 30000)
|
|
203
|
+
if (typeof sock.setTimeout === 'function') {
|
|
204
|
+
// 90秒无数据流动则判定为死连接
|
|
205
|
+
sock.setTimeout(90000, () => sock.destroy(new Error('idle timeout')))
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
185
209
|
a.pipe(b)
|
|
186
210
|
b.pipe(a)
|
|
187
211
|
const close = () => {
|