@simonyea/holysheep-cli 1.7.43 → 1.7.44
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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simonyea/holysheep-cli",
|
|
3
|
-
"version": "1.7.
|
|
4
|
-
"description": "Claude Code/Cursor/Cline API relay for China
|
|
3
|
+
"version": "1.7.44",
|
|
4
|
+
"description": "Claude Code/Cursor/Cline API relay for China \u2014 \u00a51=$1, WeChat/Alipay payment, no credit card, no VPN. One command setup for all AI coding tools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openai-china",
|
|
7
7
|
"claude-china",
|
package/src/commands/claude.js
CHANGED
|
@@ -44,16 +44,16 @@ async function runClaude(args = []) {
|
|
|
44
44
|
|
|
45
45
|
const env = {
|
|
46
46
|
...process.env,
|
|
47
|
-
ANTHROPIC_API_KEY: undefined,
|
|
47
|
+
ANTHROPIC_API_KEY: undefined,
|
|
48
48
|
ANTHROPIC_AUTH_TOKEN: apiKey,
|
|
49
|
-
ANTHROPIC_BASE_URL:
|
|
49
|
+
ANTHROPIC_BASE_URL: `http://127.0.0.1:${port}`,
|
|
50
50
|
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '1',
|
|
51
51
|
HOLYSHEEP_CLAUDE_PROCESS_PROXY: '1',
|
|
52
52
|
HOLYSHEEP_CLAUDE_SESSION_ID: sessionId,
|
|
53
|
-
HTTP_PROXY:
|
|
54
|
-
HTTPS_PROXY:
|
|
55
|
-
ALL_PROXY:
|
|
56
|
-
NO_PROXY:
|
|
53
|
+
HTTP_PROXY: undefined,
|
|
54
|
+
HTTPS_PROXY: undefined,
|
|
55
|
+
ALL_PROXY: undefined,
|
|
56
|
+
NO_PROXY: undefined,
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
const child = spawn('claude', args, {
|
|
@@ -152,8 +152,33 @@ function pipeWithCleanup(a, b) {
|
|
|
152
152
|
|
|
153
153
|
function createProcessProxyServer({ sessionId, configPath = CONFIG_PATH }) {
|
|
154
154
|
const server = http.createServer(async (clientReq, clientRes) => {
|
|
155
|
+
const isDirect = !clientReq.url.startsWith('http')
|
|
156
|
+
|
|
155
157
|
const doForward = async (lease) => {
|
|
156
158
|
const config = readConfig(configPath)
|
|
159
|
+
|
|
160
|
+
if (isDirect) {
|
|
161
|
+
const crsBase = config.baseUrlAnthropic || 'https://api.holysheep.ai'
|
|
162
|
+
const target = new URL(clientReq.url, crsBase)
|
|
163
|
+
const fwdHeaders = { ...clientReq.headers, ...buildAuthHeaders(config, lease), 'x-hs-node-proxied': '1', host: target.host }
|
|
164
|
+
const transport = target.protocol === 'https:' ? https : http
|
|
165
|
+
return new Promise((resolve, reject) => {
|
|
166
|
+
const fwd = transport.request({
|
|
167
|
+
hostname: target.hostname,
|
|
168
|
+
port: Number(target.port || (target.protocol === 'https:' ? 443 : 80)),
|
|
169
|
+
method: clientReq.method,
|
|
170
|
+
path: target.pathname + target.search,
|
|
171
|
+
headers: fwdHeaders,
|
|
172
|
+
}, (res) => {
|
|
173
|
+
clientRes.writeHead(res.statusCode || 502, res.headers)
|
|
174
|
+
res.pipe(clientRes)
|
|
175
|
+
resolve()
|
|
176
|
+
})
|
|
177
|
+
fwd.once('error', reject)
|
|
178
|
+
clientReq.pipe(fwd)
|
|
179
|
+
})
|
|
180
|
+
}
|
|
181
|
+
|
|
157
182
|
const nodeProxyUrl = deriveNodeProxyUrl(lease)
|
|
158
183
|
const headers = {
|
|
159
184
|
...buildAuthHeaders(config, lease),
|
|
@@ -180,7 +205,6 @@ function createProcessProxyServer({ sessionId, configPath = CONFIG_PATH }) {
|
|
|
180
205
|
try {
|
|
181
206
|
await doForward(getCachedLease(sessionId))
|
|
182
207
|
} catch {
|
|
183
|
-
// lease 失效,拿新 lease 重试一次
|
|
184
208
|
try {
|
|
185
209
|
const config = readConfig(configPath)
|
|
186
210
|
leaseCache.delete(sessionId)
|