@simonyea/holysheep-cli 1.7.52 → 1.7.54
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 +1 -0
- package/package.json +1 -1
- package/src/commands/claude.js +10 -0
- package/src/commands/webui.js +49 -0
- package/src/index.js +12 -0
- package/src/tools/claude-code.js +27 -0
- package/src/tools/claude-process-proxy.js +37 -41
- package/src/webui/index.html +873 -0
- package/src/webui/server.js +506 -0
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.53** — 修复 `hs claude` 在绝对 URL 代理路径下未透传 `x-hs-node-proxied` 的问题,避免同一会话里部分 Claude 请求被后端误判为非可信代理请求并随机触发 403
|
|
228
229
|
- **v1.7.52** — 将 `hs claude` 重构为本地 API 入口 + CONNECT 兜底代理:Claude Anthropic 请求默认先进入本地 process proxy,再补齐 HolySheep 会话头后转发,降低独立二进制 Claude Code 漏代理导致的 403
|
|
229
230
|
- **v1.7.51** — 修复 `hs claude` 在 Claude Code 独立二进制版本上的整进程代理:自动识别脚本入口 / 独立二进制并切换到 `NODE_OPTIONS` 注入或 `HTTP(S)_PROXY` 模式;同时增强 `hs doctor` 的 Claude 代理诊断
|
|
230
231
|
- **v1.6.14** — OpenClaw 新增 `gpt-5.3-codex-spark` 模型,通过本地 bridge 路由到 HolySheep `/v1`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simonyea/holysheep-cli",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.54",
|
|
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
|
@@ -88,6 +88,15 @@ async function runClaude(args = []) {
|
|
|
88
88
|
NO_PROXY: mergeNoProxy(process.env.NO_PROXY, ['127.0.0.1', 'localhost']),
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
const restoreSettings = typeof claudeCodeTool.applyRuntimeSettingsOverride === 'function'
|
|
92
|
+
? claudeCodeTool.applyRuntimeSettingsOverride({
|
|
93
|
+
ANTHROPIC_AUTH_TOKEN: apiKey,
|
|
94
|
+
ANTHROPIC_BASE_URL: proxyUrl,
|
|
95
|
+
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '1',
|
|
96
|
+
HOLYSHEEP_CLAUDE_LAUNCHER: 'hs',
|
|
97
|
+
})
|
|
98
|
+
: () => {}
|
|
99
|
+
|
|
91
100
|
if (runtime.launchMode === 'node-inject') {
|
|
92
101
|
env.NODE_OPTIONS = appendNodeRequire(process.env.NODE_OPTIONS, INJECT_PATH)
|
|
93
102
|
}
|
|
@@ -99,6 +108,7 @@ async function runClaude(args = []) {
|
|
|
99
108
|
})
|
|
100
109
|
|
|
101
110
|
const cleanup = async () => {
|
|
111
|
+
restoreSettings()
|
|
102
112
|
try {
|
|
103
113
|
server.close()
|
|
104
114
|
} catch {}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hs webui — 启动 WebUI 本地管理面板
|
|
3
|
+
*/
|
|
4
|
+
'use strict'
|
|
5
|
+
|
|
6
|
+
const chalk = require('chalk')
|
|
7
|
+
const { execSync } = require('child_process')
|
|
8
|
+
|
|
9
|
+
async function webui(opts) {
|
|
10
|
+
const port = Number(opts.port) || 9876
|
|
11
|
+
const { startServer } = require('../webui/server')
|
|
12
|
+
|
|
13
|
+
console.log()
|
|
14
|
+
console.log(chalk.bold('🌐 HolySheep WebUI'))
|
|
15
|
+
console.log(chalk.gray('━'.repeat(50)))
|
|
16
|
+
console.log()
|
|
17
|
+
|
|
18
|
+
const server = startServer(port)
|
|
19
|
+
|
|
20
|
+
server.on('listening', () => {
|
|
21
|
+
const url = `http://127.0.0.1:${port}`
|
|
22
|
+
console.log(chalk.green(`✓ WebUI 已启动: ${chalk.cyan.bold(url)}`))
|
|
23
|
+
console.log(chalk.gray(' 按 Ctrl+C 停止'))
|
|
24
|
+
console.log()
|
|
25
|
+
|
|
26
|
+
if (opts.open !== false) {
|
|
27
|
+
try {
|
|
28
|
+
const platform = process.platform
|
|
29
|
+
if (platform === 'darwin') execSync(`open "${url}"`)
|
|
30
|
+
else if (platform === 'win32') execSync(`start "" "${url}"`)
|
|
31
|
+
else execSync(`xdg-open "${url}"`)
|
|
32
|
+
} catch {}
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
server.on('error', (err) => {
|
|
37
|
+
if (err.code === 'EADDRINUSE') {
|
|
38
|
+
console.log(chalk.red(`✗ 端口 ${port} 已被占用,请使用 --port 指定其他端口`))
|
|
39
|
+
} else {
|
|
40
|
+
console.log(chalk.red(`✗ 启动失败: ${err.message}`))
|
|
41
|
+
}
|
|
42
|
+
process.exit(1)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
// Keep alive
|
|
46
|
+
await new Promise(() => {})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = webui
|
package/src/index.js
CHANGED
|
@@ -170,6 +170,18 @@ program
|
|
|
170
170
|
})
|
|
171
171
|
})
|
|
172
172
|
|
|
173
|
+
// ── webui ──────────────────────────────────────────────────────────────────
|
|
174
|
+
program
|
|
175
|
+
.command('webui')
|
|
176
|
+
.alias('web')
|
|
177
|
+
.description('启动 WebUI 本地管理面板')
|
|
178
|
+
.option('-p, --port <port>', '指定端口', '9876')
|
|
179
|
+
.option('--no-open', '不自动打开浏览器')
|
|
180
|
+
.action(async (opts) => {
|
|
181
|
+
printBanner()
|
|
182
|
+
await require('./commands/webui')(opts)
|
|
183
|
+
})
|
|
184
|
+
|
|
173
185
|
// ── claude ──────────────────────────────────────────────────────────────────
|
|
174
186
|
program
|
|
175
187
|
.command('claude [args...]')
|
package/src/tools/claude-code.js
CHANGED
|
@@ -56,6 +56,30 @@ function writeSettings(data) {
|
|
|
56
56
|
fs.writeFileSync(SETTINGS_FILE, JSON.stringify(data, null, 2), 'utf8')
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
function cloneSettings(data) {
|
|
60
|
+
return JSON.parse(JSON.stringify(data || {}))
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function applyRuntimeSettingsOverride(overrides = {}) {
|
|
64
|
+
const previous = readSettings()
|
|
65
|
+
const next = cloneSettings(previous)
|
|
66
|
+
next.env = { ...(next.env || {}) }
|
|
67
|
+
|
|
68
|
+
for (const [key, value] of Object.entries(overrides)) {
|
|
69
|
+
if (value === undefined || value === null) {
|
|
70
|
+
delete next.env[key]
|
|
71
|
+
continue
|
|
72
|
+
}
|
|
73
|
+
next.env[key] = value
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
writeSettings(next)
|
|
77
|
+
|
|
78
|
+
return () => {
|
|
79
|
+
writeSettings(previous)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
59
83
|
function resolveCommandPath(cmd) {
|
|
60
84
|
try {
|
|
61
85
|
if (process.platform === 'win32') {
|
|
@@ -198,4 +222,7 @@ module.exports = {
|
|
|
198
222
|
},
|
|
199
223
|
buildBridgeConfig,
|
|
200
224
|
detectClaudeRuntime,
|
|
225
|
+
readSettings,
|
|
226
|
+
writeSettings,
|
|
227
|
+
applyRuntimeSettingsOverride,
|
|
201
228
|
}
|
|
@@ -113,6 +113,30 @@ function deriveNodeProxyUrl(lease) {
|
|
|
113
113
|
return upstream.toString().replace(/\/+$/, '')
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
function forwardViaNodeProxy({ nodeProxyUrl, targetUrl, clientReq, clientRes, extraHeaders = {} }) {
|
|
117
|
+
const upstream = new URL(nodeProxyUrl)
|
|
118
|
+
return new Promise((resolve, reject) => {
|
|
119
|
+
const forwardReq = http.request({
|
|
120
|
+
host: upstream.hostname,
|
|
121
|
+
port: Number(upstream.port || 80),
|
|
122
|
+
method: clientReq.method,
|
|
123
|
+
path: targetUrl.toString(),
|
|
124
|
+
headers: {
|
|
125
|
+
...clientReq.headers,
|
|
126
|
+
...extraHeaders,
|
|
127
|
+
host: targetUrl.host,
|
|
128
|
+
connection: 'close',
|
|
129
|
+
},
|
|
130
|
+
}, (forwardRes) => {
|
|
131
|
+
clientRes.writeHead(forwardRes.statusCode || 502, forwardRes.headers)
|
|
132
|
+
forwardRes.pipe(clientRes)
|
|
133
|
+
resolve()
|
|
134
|
+
})
|
|
135
|
+
forwardReq.once('error', reject)
|
|
136
|
+
clientReq.pipe(forwardReq)
|
|
137
|
+
})
|
|
138
|
+
}
|
|
139
|
+
|
|
116
140
|
function createConnectTunnel(proxyUrl, target, headers) {
|
|
117
141
|
return new Promise((resolve, reject) => {
|
|
118
142
|
const upstream = new URL(proxyUrl)
|
|
@@ -156,58 +180,30 @@ function createProcessProxyServer({ sessionId, configPath = CONFIG_PATH }) {
|
|
|
156
180
|
|
|
157
181
|
const doForward = async (lease) => {
|
|
158
182
|
const config = readConfig(configPath)
|
|
183
|
+
const nodeProxyUrl = deriveNodeProxyUrl(lease)
|
|
159
184
|
|
|
160
185
|
if (isDirect) {
|
|
161
186
|
const crsBase = config.baseUrlAnthropic || 'https://api.holysheep.ai'
|
|
162
187
|
const target = new URL(clientReq.url, crsBase)
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
+
return forwardViaNodeProxy({
|
|
189
|
+
nodeProxyUrl,
|
|
190
|
+
targetUrl: target,
|
|
191
|
+
clientReq,
|
|
192
|
+
clientRes,
|
|
193
|
+
extraHeaders: buildAuthHeaders(config, lease),
|
|
188
194
|
})
|
|
189
195
|
}
|
|
190
196
|
|
|
191
|
-
const nodeProxyUrl = deriveNodeProxyUrl(lease)
|
|
192
197
|
const headers = {
|
|
193
198
|
...buildAuthHeaders(config, lease),
|
|
194
199
|
host: new URL(clientReq.url).host,
|
|
195
200
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
path: clientReq.url,
|
|
203
|
-
headers: { ...clientReq.headers, ...headers, connection: 'close' },
|
|
204
|
-
}, (forwardRes) => {
|
|
205
|
-
clientRes.writeHead(forwardRes.statusCode || 502, forwardRes.headers)
|
|
206
|
-
forwardRes.pipe(clientRes)
|
|
207
|
-
resolve()
|
|
208
|
-
})
|
|
209
|
-
forwardReq.once('error', reject)
|
|
210
|
-
clientReq.pipe(forwardReq)
|
|
201
|
+
return forwardViaNodeProxy({
|
|
202
|
+
nodeProxyUrl,
|
|
203
|
+
targetUrl: new URL(clientReq.url),
|
|
204
|
+
clientReq,
|
|
205
|
+
clientRes,
|
|
206
|
+
extraHeaders: headers,
|
|
211
207
|
})
|
|
212
208
|
}
|
|
213
209
|
|