@simonyea/holysheep-cli 1.7.113 → 1.7.114
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.114",
|
|
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",
|
|
@@ -205,27 +205,30 @@ function pipeWithCleanup(a, b) {
|
|
|
205
205
|
if (typeof sock.setKeepAlive === 'function') sock.setKeepAlive(true, 10000)
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
//
|
|
209
|
-
//
|
|
210
|
-
//
|
|
211
|
-
|
|
212
|
-
let
|
|
208
|
+
// 双阶段超时:
|
|
209
|
+
// 1. 客户端发了数据,上游 30 秒没回第一个字节 → 断开(node proxy 挂了)
|
|
210
|
+
// 2. 上游在流数据突然停了 120 秒 → 断开(stream 中断)
|
|
211
|
+
// 120 秒足够覆盖 extended thinking 的间歇(thinking 期间服务端仍会发心跳)
|
|
212
|
+
let timer = null
|
|
213
|
+
let streaming = false
|
|
214
|
+
const kill = (reason) => {
|
|
215
|
+
if (timer) clearTimeout(timer)
|
|
216
|
+
a.destroy(new Error(reason))
|
|
217
|
+
b.destroy(new Error(reason))
|
|
218
|
+
}
|
|
213
219
|
a.on('data', () => {
|
|
214
|
-
//
|
|
215
|
-
if (!
|
|
216
|
-
if (
|
|
217
|
-
|
|
218
|
-
if (!bHasResponded) {
|
|
219
|
-
a.destroy(new Error('upstream response timeout'))
|
|
220
|
-
b.destroy(new Error('upstream response timeout'))
|
|
221
|
-
}
|
|
222
|
-
}, 30000)
|
|
220
|
+
// 客户端发了数据(请求),等上游响应
|
|
221
|
+
if (!streaming) {
|
|
222
|
+
if (timer) clearTimeout(timer)
|
|
223
|
+
timer = setTimeout(() => kill('upstream response timeout'), 30000)
|
|
223
224
|
}
|
|
224
225
|
})
|
|
225
226
|
b.on('data', () => {
|
|
226
|
-
//
|
|
227
|
-
|
|
228
|
-
|
|
227
|
+
// 上游回数据了,切换到 stream 模式
|
|
228
|
+
streaming = true
|
|
229
|
+
// 每次收到数据重置 120 秒超时
|
|
230
|
+
if (timer) clearTimeout(timer)
|
|
231
|
+
timer = setTimeout(() => kill('upstream stream stalled'), 120000)
|
|
229
232
|
})
|
|
230
233
|
|
|
231
234
|
a.pipe(b)
|