@simonyea/holysheep-cli 1.7.78 → 1.7.79

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.78",
3
+ "version": "1.7.79",
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",
@@ -81,8 +81,9 @@ async function runClaude(args = []) {
81
81
  ...process.env,
82
82
  ANTHROPIC_API_KEY: undefined,
83
83
  ANTHROPIC_AUTH_TOKEN: apiKey,
84
- // Force Anthropic API traffic through the local process proxy instead of
85
- // relying on the Claude binary to honor HTTP(S)_PROXY on every code path.
84
+ // Route ALL Anthropic API traffic exclusively through ANTHROPIC_BASE_URL.
85
+ // HTTP(S)_PROXY must NOT be set: it causes Claude Code to open CONNECT
86
+ // tunnels to api.anthropic.com, bypassing CRS multi-account scheduling.
86
87
  ANTHROPIC_BASE_URL: proxyUrl,
87
88
  CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '1',
88
89
  HOLYSHEEP_CLAUDE_PROCESS_PROXY: '1',
@@ -90,10 +91,10 @@ async function runClaude(args = []) {
90
91
  HS_PROXY_URL: proxyUrl,
91
92
  HOLYSHEEP_CLAUDE_RUNTIME_KIND: runtime.kind || 'unknown',
92
93
  HOLYSHEEP_CLAUDE_LAUNCH_MODE: launchMode,
93
- HTTP_PROXY: proxyUrl,
94
- HTTPS_PROXY: proxyUrl,
95
- ALL_PROXY: proxyUrl,
96
- NO_PROXY: mergeNoProxy(process.env.NO_PROXY, ['127.0.0.1', 'localhost']),
94
+ HTTP_PROXY: undefined,
95
+ HTTPS_PROXY: undefined,
96
+ ALL_PROXY: undefined,
97
+ NO_PROXY: undefined,
97
98
  }
98
99
 
99
100
  // 不再写 settings.json — 只用 env 变量,避免 Claude Code 从两个来源
@@ -233,6 +233,10 @@ function createProcessProxyServer({ sessionId, configPath = CONFIG_PATH }) {
233
233
  }
234
234
  })
235
235
 
236
+ // Hosts that must NOT be tunneled directly — they must go through CRS via
237
+ // the HTTP path (ANTHROPIC_BASE_URL), not a CONNECT tunnel that bypasses it.
238
+ const BLOCKED_CONNECT = new Set(['api.anthropic.com'])
239
+
236
240
  server.on('connect', async (req, clientSocket, head) => {
237
241
  const target = String(req.url || '').trim()
238
242
  const [host, rawPort] = target.split(':')
@@ -242,6 +246,13 @@ function createProcessProxyServer({ sessionId, configPath = CONFIG_PATH }) {
242
246
  return clientSocket.destroy()
243
247
  }
244
248
 
249
+ if (BLOCKED_CONNECT.has(host)) {
250
+ // Block direct CONNECT tunnels to Anthropic — traffic must go through
251
+ // ANTHROPIC_BASE_URL so CRS can apply multi-account scheduling.
252
+ clientSocket.write('HTTP/1.1 403 Forbidden\r\ncontent-type: text/plain; charset=utf-8\r\n\r\nDirect tunnel to api.anthropic.com is blocked; use ANTHROPIC_BASE_URL path')
253
+ return clientSocket.destroy()
254
+ }
255
+
245
256
  const doConnect = async (lease) => {
246
257
  const upstreamSocket = await createConnectTunnel(
247
258
  deriveNodeProxyUrl(lease),