@simonyea/holysheep-cli 1.7.41 → 1.7.42
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.42",
|
|
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",
|
|
@@ -67,24 +67,32 @@ async function requestSessionLease(config, sessionId) {
|
|
|
67
67
|
const controlPlaneUrl = getControlPlaneUrl(config)
|
|
68
68
|
if (!controlPlaneUrl) throw new Error('Claude relay control plane is not configured')
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
70
|
+
try {
|
|
71
|
+
const response = await fetch(`${controlPlaneUrl}/session/open`, {
|
|
72
|
+
method: 'POST',
|
|
73
|
+
headers: { 'content-type': 'application/json' },
|
|
74
|
+
body: JSON.stringify({
|
|
75
|
+
sessionId,
|
|
76
|
+
bridgeId: config.bridgeId || 'local-bridge',
|
|
77
|
+
deviceId: config.deviceId || '',
|
|
78
|
+
installSource: config.installSource || 'holysheep-cli',
|
|
79
|
+
proxyMode: 'claude-process',
|
|
80
|
+
}),
|
|
81
|
+
})
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
const payload = await response.json().catch(() => null)
|
|
84
|
+
if (!response.ok || !payload?.success || !payload?.data?.ticket) {
|
|
85
|
+
throw new Error(payload?.error?.message || `Failed to open Claude session (HTTP ${response.status})`)
|
|
86
|
+
}
|
|
87
|
+
leaseCache.set(sessionId, payload.data)
|
|
88
|
+
return payload.data
|
|
89
|
+
} catch (error) {
|
|
90
|
+
// 续约失败时,只要旧 lease 还没真正过期就继续用,避免网络抖动导致 session 中断
|
|
91
|
+
if (cached?.expiresAt && new Date(cached.expiresAt).getTime() > Date.now()) {
|
|
92
|
+
return cached
|
|
93
|
+
}
|
|
94
|
+
throw error
|
|
85
95
|
}
|
|
86
|
-
leaseCache.set(sessionId, payload.data)
|
|
87
|
-
return payload.data
|
|
88
96
|
}
|
|
89
97
|
|
|
90
98
|
function buildAuthHeaders(config, lease) {
|