@simonyea/holysheep-cli 1.7.50 → 1.7.51

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/README.md CHANGED
@@ -225,6 +225,7 @@ A: OpenClaw 需要 Node.js 20+,运行 `node --version` 确认版本后重试
225
225
 
226
226
  ## Changelog
227
227
 
228
+ - **v1.7.51** — 修复 `hs claude` 在 Claude Code 独立二进制版本上的整进程代理:自动识别脚本入口 / 独立二进制并切换到 `NODE_OPTIONS` 注入或 `HTTP(S)_PROXY` 模式;同时增强 `hs doctor` 的 Claude 代理诊断
228
229
  - **v1.6.14** — OpenClaw 新增 `gpt-5.3-codex-spark` 模型,通过本地 bridge 路由到 HolySheep `/v1`
229
230
  - **v1.6.13** — Codex 配置改为直接写 `api_key` 到 config.toml,不再依赖环境变量,修复 Windows 上 setup 后无需重启终端即可使用;同时精简工具列表,只保留 Claude Code / Codex / Droid / OpenClaw
230
231
  - **v1.6.12** — 修复 OpenClaw Bridge 对 GPT-5.4 的流式响应转换,避免 `holysheep/gpt-5.4` 在 OpenClaw 中报错;同时增强 Dashboard URL 解析,减少安装后浏览器打开黑屏/空白页
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simonyea/holysheep-cli",
3
- "version": "1.7.50",
3
+ "version": "1.7.51",
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",
@@ -18,6 +18,24 @@ const claudeCodeTool = require('../tools/claude-code')
18
18
 
19
19
  const INJECT_PATH = path.resolve(__dirname, '../tools/process-proxy-inject.js')
20
20
 
21
+ function appendNodeRequire(existingValue, requirePath) {
22
+ const nextFlag = `--require ${requirePath}`
23
+ if (!existingValue) return nextFlag
24
+ return existingValue.includes(nextFlag) ? existingValue : `${existingValue} ${nextFlag}`.trim()
25
+ }
26
+
27
+ function mergeNoProxy(existingValue, extraHosts = []) {
28
+ const merged = new Set()
29
+ for (const chunk of String(existingValue || '').split(',')) {
30
+ const value = chunk.trim()
31
+ if (value) merged.add(value)
32
+ }
33
+ for (const host of extraHosts) {
34
+ if (host) merged.add(host)
35
+ }
36
+ return Array.from(merged).join(',')
37
+ }
38
+
21
39
  function ensureClaudeProxyConfig(apiKey) {
22
40
  const config = readConfig()
23
41
  const next = claudeCodeTool.buildBridgeConfig(apiKey, BASE_URL_ANTHROPIC, {
@@ -44,6 +62,9 @@ async function runClaude(args = []) {
44
62
 
45
63
  const { server, port, sessionId } = await startProcessProxy({})
46
64
  const proxyUrl = getLocalProxyUrl(port)
65
+ const runtime = typeof claudeCodeTool.detectClaudeRuntime === 'function'
66
+ ? claudeCodeTool.detectClaudeRuntime()
67
+ : { kind: 'unknown', launchMode: 'env-proxy' }
47
68
 
48
69
  const env = {
49
70
  ...process.env,
@@ -53,12 +74,18 @@ async function runClaude(args = []) {
53
74
  CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '1',
54
75
  HOLYSHEEP_CLAUDE_PROCESS_PROXY: '1',
55
76
  HOLYSHEEP_CLAUDE_SESSION_ID: sessionId,
56
- NODE_OPTIONS: `--require ${INJECT_PATH}`,
57
77
  HS_PROXY_URL: proxyUrl,
58
- HTTP_PROXY: undefined,
59
- HTTPS_PROXY: undefined,
60
- ALL_PROXY: undefined,
61
- NO_PROXY: undefined,
78
+ HOLYSHEEP_CLAUDE_RUNTIME_KIND: runtime.kind || 'unknown',
79
+ HOLYSHEEP_CLAUDE_LAUNCH_MODE: runtime.launchMode || 'env-proxy',
80
+ }
81
+
82
+ if (runtime.launchMode === 'node-inject') {
83
+ env.NODE_OPTIONS = appendNodeRequire(process.env.NODE_OPTIONS, INJECT_PATH)
84
+ } else {
85
+ env.HTTP_PROXY = proxyUrl
86
+ env.HTTPS_PROXY = proxyUrl
87
+ env.ALL_PROXY = proxyUrl
88
+ env.NO_PROXY = mergeNoProxy(process.env.NO_PROXY, ['127.0.0.1', 'localhost'])
62
89
  }
63
90
 
64
91
  const child = spawn('claude', args, {
@@ -202,6 +202,9 @@ function printOpenClawDetails(tool, installState, nodeMajor) {
202
202
 
203
203
  function printClaudeProcessProxyDetails(tool) {
204
204
  const proxyConfig = typeof tool.getProcessProxyConfig === 'function' ? tool.getProcessProxyConfig() : {}
205
+ const runtime = typeof tool.detectClaudeRuntime === 'function'
206
+ ? tool.detectClaudeRuntime()
207
+ : { display: '未知', kind: 'unknown', launchMode: 'unknown', path: null }
205
208
  const relayUrl = proxyConfig.controlPlaneUrl || proxyConfig.relayUrl || BASE_URL_CLAUDE_RELAY
206
209
  const mode = proxyConfig.proxyMode || 'unknown'
207
210
  const hasBridgeSecret = Boolean(proxyConfig.bridgeSecret)
@@ -209,10 +212,19 @@ function printClaudeProcessProxyDetails(tool) {
209
212
  const hasProcessPort = Boolean(proxyConfig.processProxyPort)
210
213
  console.log(` ${chalk.gray('↳')} ${chalk.gray(`Claude 启动方式:hs claude`)}`)
211
214
  console.log(` ${chalk.gray('↳')} ${chalk.gray(`Claude 代理模式:${mode}`)}`)
215
+ console.log(` ${chalk.gray('↳')} ${chalk.gray(`Claude 可执行类型:${runtime.display}`)}`)
216
+ console.log(` ${chalk.gray('↳')} ${chalk.gray(`Claude 启动代理路径:${runtime.launchMode}`)}`)
212
217
  console.log(` ${chalk.gray('↳')} ${chalk.gray(`Claude Relay: ${relayUrl || '未配置'}`)}`)
213
218
  console.log(` ${hasBridgeSecret ? chalk.green('↳') : chalk.yellow('↳')} ${hasBridgeSecret ? chalk.green('Bridge secret 已配置') : chalk.yellow('Bridge secret 缺失')}`)
214
219
  console.log(` ${hasBridgeIds ? chalk.green('↳') : chalk.yellow('↳')} ${hasBridgeIds ? chalk.green('Bridge ID / Device ID 已配置') : chalk.yellow('Bridge ID / Device ID 缺失')}`)
215
220
  console.log(` ${hasProcessPort ? chalk.green('↳') : chalk.yellow('↳')} ${hasProcessPort ? chalk.green(`Claude process proxy 端口:${proxyConfig.processProxyPort}`) : chalk.yellow('Claude process proxy 端口缺失')}`)
221
+ if (runtime.path) {
222
+ console.log(` ${chalk.gray('↳')} ${chalk.gray(`Claude 路径:${runtime.path}`)}`)
223
+ }
224
+ const nodeMajor = parseInt(process.version.slice(1), 10)
225
+ if (nodeMajor > 22) {
226
+ console.log(` ${chalk.yellow('↳')} ${chalk.yellow(`当前 hs 运行在 ${process.version};Claude 代理更建议使用 Node 20/22 LTS`)}`)
227
+ }
216
228
  }
217
229
 
218
230
  function maskKey(key) {
@@ -12,6 +12,7 @@ const fs = require('fs')
12
12
  const path = require('path')
13
13
  const os = require('os')
14
14
  const crypto = require('crypto')
15
+ const { execSync } = require('child_process')
15
16
  const {
16
17
  BASE_URL_ANTHROPIC,
17
18
  BASE_URL_CLAUDE_RELAY,
@@ -55,6 +56,83 @@ function writeSettings(data) {
55
56
  fs.writeFileSync(SETTINGS_FILE, JSON.stringify(data, null, 2), 'utf8')
56
57
  }
57
58
 
59
+ function resolveCommandPath(cmd) {
60
+ try {
61
+ if (process.platform === 'win32') {
62
+ const out = execSync(`where ${cmd}`, { stdio: 'pipe' }).toString().trim()
63
+ const first = out.split(/\r?\n/).find(Boolean)
64
+ return first ? fs.realpathSync(first) : null
65
+ }
66
+
67
+ const out = execSync(`which ${cmd}`, { stdio: 'pipe' }).toString().trim()
68
+ const first = out.split(/\r?\n/).find(Boolean)
69
+ return first ? fs.realpathSync(first) : null
70
+ } catch {
71
+ return null
72
+ }
73
+ }
74
+
75
+ function detectBinaryFormat(buffer) {
76
+ if (!buffer || buffer.length < 4) return null
77
+ if (buffer[0] === 0x23 && buffer[1] === 0x21) return 'script'
78
+
79
+ const magic = buffer.slice(0, 4).toString('hex')
80
+ if (magic === '7f454c46') return 'elf'
81
+ if (magic === 'feedface' || magic === 'feedfacf' || magic === 'cefaedfe' || magic === 'cffaedfe') return 'mach-o'
82
+ if (buffer[0] === 0x4d && buffer[1] === 0x5a) return 'pe'
83
+
84
+ return null
85
+ }
86
+
87
+ function detectClaudeRuntime() {
88
+ const executablePath = resolveCommandPath('claude')
89
+ if (!executablePath) {
90
+ return {
91
+ available: false,
92
+ path: null,
93
+ kind: 'missing',
94
+ launchMode: 'unknown',
95
+ display: '未找到 claude',
96
+ }
97
+ }
98
+
99
+ try {
100
+ const fd = fs.openSync(executablePath, 'r')
101
+ const buffer = Buffer.alloc(16)
102
+ fs.readSync(fd, buffer, 0, buffer.length, 0)
103
+ fs.closeSync(fd)
104
+
105
+ const format = detectBinaryFormat(buffer)
106
+ if (format === 'script') {
107
+ return {
108
+ available: true,
109
+ path: executablePath,
110
+ kind: 'script',
111
+ launchMode: 'node-inject',
112
+ display: '脚本入口(使用 NODE_OPTIONS 注入)',
113
+ }
114
+ }
115
+
116
+ if (format) {
117
+ return {
118
+ available: true,
119
+ path: executablePath,
120
+ kind: 'binary',
121
+ launchMode: 'env-proxy',
122
+ display: `独立二进制(${format},使用 HTTP(S)_PROXY)`,
123
+ }
124
+ }
125
+ } catch {}
126
+
127
+ return {
128
+ available: true,
129
+ path: executablePath,
130
+ kind: 'unknown',
131
+ launchMode: 'env-proxy',
132
+ display: '未知入口类型(默认使用 HTTP(S)_PROXY)',
133
+ }
134
+ }
135
+
58
136
  module.exports = {
59
137
  name: 'Claude Code',
60
138
  id: 'claude-code',
@@ -119,4 +197,5 @@ module.exports = {
119
197
  return readConfig()
120
198
  },
121
199
  buildBridgeConfig,
200
+ detectClaudeRuntime,
122
201
  }