@simonyea/holysheep-cli 1.7.50 → 1.7.52
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 +2 -0
- package/package.json +1 -1
- package/src/commands/claude.js +37 -6
- package/src/commands/doctor.js +18 -0
- package/src/tools/claude-code.js +79 -0
package/README.md
CHANGED
|
@@ -225,6 +225,8 @@ A: OpenClaw 需要 Node.js 20+,运行 `node --version` 确认版本后重试
|
|
|
225
225
|
|
|
226
226
|
## Changelog
|
|
227
227
|
|
|
228
|
+
- **v1.7.52** — 将 `hs claude` 重构为本地 API 入口 + CONNECT 兜底代理:Claude Anthropic 请求默认先进入本地 process proxy,再补齐 HolySheep 会话头后转发,降低独立二进制 Claude Code 漏代理导致的 403
|
|
229
|
+
- **v1.7.51** — 修复 `hs claude` 在 Claude Code 独立二进制版本上的整进程代理:自动识别脚本入口 / 独立二进制并切换到 `NODE_OPTIONS` 注入或 `HTTP(S)_PROXY` 模式;同时增强 `hs doctor` 的 Claude 代理诊断
|
|
228
230
|
- **v1.6.14** — OpenClaw 新增 `gpt-5.3-codex-spark` 模型,通过本地 bridge 路由到 HolySheep `/v1`
|
|
229
231
|
- **v1.6.13** — Codex 配置改为直接写 `api_key` 到 config.toml,不再依赖环境变量,修复 Windows 上 setup 后无需重启终端即可使用;同时精简工具列表,只保留 Claude Code / Codex / Droid / OpenClaw
|
|
230
232
|
- **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.
|
|
3
|
+
"version": "1.7.52",
|
|
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",
|
package/src/commands/claude.js
CHANGED
|
@@ -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,21 +62,34 @@ 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' }
|
|
68
|
+
const launchMode = runtime.launchMode === 'node-inject'
|
|
69
|
+
? 'local-api + connect-fallback + node-inject'
|
|
70
|
+
: 'local-api + connect-fallback'
|
|
47
71
|
|
|
48
72
|
const env = {
|
|
49
73
|
...process.env,
|
|
50
74
|
ANTHROPIC_API_KEY: undefined,
|
|
51
75
|
ANTHROPIC_AUTH_TOKEN: apiKey,
|
|
52
|
-
|
|
76
|
+
// Force Anthropic API traffic through the local process proxy instead of
|
|
77
|
+
// relying on the Claude binary to honor HTTP(S)_PROXY on every code path.
|
|
78
|
+
ANTHROPIC_BASE_URL: proxyUrl,
|
|
53
79
|
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '1',
|
|
54
80
|
HOLYSHEEP_CLAUDE_PROCESS_PROXY: '1',
|
|
55
81
|
HOLYSHEEP_CLAUDE_SESSION_ID: sessionId,
|
|
56
|
-
NODE_OPTIONS: `--require ${INJECT_PATH}`,
|
|
57
82
|
HS_PROXY_URL: proxyUrl,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
83
|
+
HOLYSHEEP_CLAUDE_RUNTIME_KIND: runtime.kind || 'unknown',
|
|
84
|
+
HOLYSHEEP_CLAUDE_LAUNCH_MODE: launchMode,
|
|
85
|
+
HTTP_PROXY: proxyUrl,
|
|
86
|
+
HTTPS_PROXY: proxyUrl,
|
|
87
|
+
ALL_PROXY: proxyUrl,
|
|
88
|
+
NO_PROXY: mergeNoProxy(process.env.NO_PROXY, ['127.0.0.1', 'localhost']),
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (runtime.launchMode === 'node-inject') {
|
|
92
|
+
env.NODE_OPTIONS = appendNodeRequire(process.env.NODE_OPTIONS, INJECT_PATH)
|
|
62
93
|
}
|
|
63
94
|
|
|
64
95
|
const child = spawn('claude', args, {
|
package/src/commands/doctor.js
CHANGED
|
@@ -202,17 +202,35 @@ 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)
|
|
208
211
|
const hasBridgeIds = Boolean(proxyConfig.bridgeId && proxyConfig.deviceId)
|
|
209
212
|
const hasProcessPort = Boolean(proxyConfig.processProxyPort)
|
|
213
|
+
const launchPath = runtime.launchMode === 'node-inject'
|
|
214
|
+
? 'local-api + connect-fallback + node-inject'
|
|
215
|
+
: 'local-api + connect-fallback'
|
|
210
216
|
console.log(` ${chalk.gray('↳')} ${chalk.gray(`Claude 启动方式:hs claude`)}`)
|
|
211
217
|
console.log(` ${chalk.gray('↳')} ${chalk.gray(`Claude 代理模式:${mode}`)}`)
|
|
218
|
+
console.log(` ${chalk.gray('↳')} ${chalk.gray(`Claude 可执行类型:${runtime.display}`)}`)
|
|
219
|
+
console.log(` ${chalk.gray('↳')} ${chalk.gray(`Claude 启动代理路径:${launchPath}`)}`)
|
|
212
220
|
console.log(` ${chalk.gray('↳')} ${chalk.gray(`Claude Relay: ${relayUrl || '未配置'}`)}`)
|
|
213
221
|
console.log(` ${hasBridgeSecret ? chalk.green('↳') : chalk.yellow('↳')} ${hasBridgeSecret ? chalk.green('Bridge secret 已配置') : chalk.yellow('Bridge secret 缺失')}`)
|
|
214
222
|
console.log(` ${hasBridgeIds ? chalk.green('↳') : chalk.yellow('↳')} ${hasBridgeIds ? chalk.green('Bridge ID / Device ID 已配置') : chalk.yellow('Bridge ID / Device ID 缺失')}`)
|
|
215
223
|
console.log(` ${hasProcessPort ? chalk.green('↳') : chalk.yellow('↳')} ${hasProcessPort ? chalk.green(`Claude process proxy 端口:${proxyConfig.processProxyPort}`) : chalk.yellow('Claude process proxy 端口缺失')}`)
|
|
224
|
+
if (hasProcessPort) {
|
|
225
|
+
console.log(` ${chalk.gray('↳')} ${chalk.gray(`Claude 本地 API 入口:http://127.0.0.1:${proxyConfig.processProxyPort}`)}`)
|
|
226
|
+
}
|
|
227
|
+
if (runtime.path) {
|
|
228
|
+
console.log(` ${chalk.gray('↳')} ${chalk.gray(`Claude 路径:${runtime.path}`)}`)
|
|
229
|
+
}
|
|
230
|
+
const nodeMajor = parseInt(process.version.slice(1), 10)
|
|
231
|
+
if (nodeMajor > 22) {
|
|
232
|
+
console.log(` ${chalk.yellow('↳')} ${chalk.yellow(`当前 hs 运行在 ${process.version};Claude 代理更建议使用 Node 20/22 LTS`)}`)
|
|
233
|
+
}
|
|
216
234
|
}
|
|
217
235
|
|
|
218
236
|
function maskKey(key) {
|
package/src/tools/claude-code.js
CHANGED
|
@@ -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
|
}
|