@simonyea/holysheep-cli 1.7.47 → 1.7.48

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.47",
3
+ "version": "1.7.48",
4
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",
@@ -49,13 +49,12 @@ async function runClaude(args = []) {
49
49
  ...process.env,
50
50
  ANTHROPIC_API_KEY: undefined,
51
51
  ANTHROPIC_AUTH_TOKEN: apiKey,
52
- ANTHROPIC_BASE_URL: BASE_URL_ANTHROPIC,
52
+ ANTHROPIC_BASE_URL: `http://127.0.0.1:${port}`,
53
53
  CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '1',
54
54
  HOLYSHEEP_CLAUDE_PROCESS_PROXY: '1',
55
55
  HOLYSHEEP_CLAUDE_SESSION_ID: sessionId,
56
- // 进程级代理注入:强制所有 TCP 连接走本地 bridge CONNECT 隧道
57
- NODE_OPTIONS: `--require ${INJECT_PATH}`,
58
- HS_PROXY_URL: proxyUrl,
56
+ NODE_OPTIONS: undefined,
57
+ HS_PROXY_URL: undefined,
59
58
  HTTP_PROXY: undefined,
60
59
  HTTPS_PROXY: undefined,
61
60
  ALL_PROXY: undefined,
@@ -152,8 +152,42 @@ 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 = {
164
+ ...clientReq.headers,
165
+ ...buildAuthHeaders(config, lease),
166
+ 'x-hs-node-proxied': '1',
167
+ host: target.host,
168
+ }
169
+ const transport = target.protocol === 'https:' ? https : http
170
+ return new Promise((resolve, reject) => {
171
+ const fwd = transport.request({
172
+ hostname: target.hostname,
173
+ port: Number(target.port || (target.protocol === 'https:' ? 443 : 80)),
174
+ method: clientReq.method,
175
+ path: target.pathname + target.search,
176
+ headers: fwdHeaders,
177
+ }, (res) => {
178
+ if (res.statusCode === 401 || res.statusCode === 403) {
179
+ res.resume()
180
+ return reject(new Error(`Auth error ${res.statusCode}`))
181
+ }
182
+ clientRes.writeHead(res.statusCode || 502, res.headers)
183
+ res.pipe(clientRes)
184
+ resolve()
185
+ })
186
+ fwd.once('error', reject)
187
+ clientReq.pipe(fwd)
188
+ })
189
+ }
190
+
157
191
  const nodeProxyUrl = deriveNodeProxyUrl(lease)
158
192
  const headers = {
159
193
  ...buildAuthHeaders(config, lease),