@simonyea/holysheep-cli 1.7.70 → 1.7.71
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.71",
|
|
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",
|
|
@@ -209,18 +209,26 @@ function createProcessProxyServer({ sessionId, configPath = CONFIG_PATH }) {
|
|
|
209
209
|
|
|
210
210
|
try {
|
|
211
211
|
await doForward(getCachedLease(sessionId))
|
|
212
|
-
} catch {
|
|
213
|
-
if (clientRes.headersSent) return
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
212
|
+
} catch (err) {
|
|
213
|
+
if (clientRes.headersSent) return
|
|
214
|
+
// 只在没有 lease 缓存时重试(首次连接或 lease 过期)
|
|
215
|
+
// 网络超时/连接错误不重试 — 让 Claude Code 自己处理重试,避免重复 API 请求
|
|
216
|
+
const noLease = !leaseCache.has(sessionId) || (err && err.message && err.message.includes('No session lease'))
|
|
217
|
+
if (noLease) {
|
|
218
|
+
try {
|
|
219
|
+
const config = readConfig(configPath)
|
|
220
|
+
leaseCache.delete(sessionId)
|
|
221
|
+
const freshLease = await fetchFreshLease(config, sessionId)
|
|
222
|
+
await doForward(freshLease)
|
|
223
|
+
} catch (retryError) {
|
|
224
|
+
if (!clientRes.headersSent) {
|
|
225
|
+
clientRes.writeHead(502, { 'content-type': 'text/plain; charset=utf-8' })
|
|
226
|
+
clientRes.end(retryError.message || 'Proxy error')
|
|
227
|
+
}
|
|
223
228
|
}
|
|
229
|
+
} else {
|
|
230
|
+
clientRes.writeHead(502, { 'content-type': 'text/plain; charset=utf-8' })
|
|
231
|
+
clientRes.end(err?.message || 'Proxy error')
|
|
224
232
|
}
|
|
225
233
|
}
|
|
226
234
|
})
|
|
@@ -247,15 +255,20 @@ function createProcessProxyServer({ sessionId, configPath = CONFIG_PATH }) {
|
|
|
247
255
|
|
|
248
256
|
try {
|
|
249
257
|
await doConnect(getCachedLease(sessionId))
|
|
250
|
-
} catch {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
258
|
+
} catch (err) {
|
|
259
|
+
const noLease = !leaseCache.has(sessionId) || (err && err.message && err.message.includes('No session lease'))
|
|
260
|
+
if (noLease) {
|
|
261
|
+
try {
|
|
262
|
+
const config = readConfig(configPath)
|
|
263
|
+
leaseCache.delete(sessionId)
|
|
264
|
+
const freshLease = await fetchFreshLease(config, sessionId)
|
|
265
|
+
await doConnect(freshLease)
|
|
266
|
+
} catch (retryError) {
|
|
267
|
+
clientSocket.write(`HTTP/1.1 502 Bad Gateway\r\ncontent-type: text/plain; charset=utf-8\r\n\r\n${retryError.message}`)
|
|
268
|
+
clientSocket.destroy()
|
|
269
|
+
}
|
|
270
|
+
} else {
|
|
271
|
+
clientSocket.write(`HTTP/1.1 502 Bad Gateway\r\ncontent-type: text/plain; charset=utf-8\r\n\r\n${err?.message || 'Proxy error'}`)
|
|
259
272
|
clientSocket.destroy()
|
|
260
273
|
}
|
|
261
274
|
}
|