@simonyea/holysheep-cli 2.1.65 → 2.1.66
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/dist/configure-worker.js +2 -2
- package/dist/index.js +166 -148
- package/package.json +2 -2
package/dist/configure-worker.js
CHANGED
|
@@ -4099,11 +4099,11 @@ var require_package = __commonJS({
|
|
|
4099
4099
|
"package.json"(exports2, module2) {
|
|
4100
4100
|
module2.exports = {
|
|
4101
4101
|
name: "@simonyea/holysheep-cli",
|
|
4102
|
-
version: "2.1.
|
|
4102
|
+
version: "2.1.66",
|
|
4103
4103
|
description: "Claude Code/Cursor/Cline API relay for China \u2014 \xA51=$1, WeChat/Alipay payment, no credit card, no VPN. One command setup for all AI coding tools.",
|
|
4104
4104
|
scripts: {
|
|
4105
4105
|
build: "node scripts/build.mjs",
|
|
4106
|
-
test: "node tests/droid.test.js && node tests/workspace-store.test.js && node tests/runtime-stale-upgrade.test.js && node tests/hermes.test.js && node tests/preflight.test.js && node tests/opencode-auth-purge.test.js && node tests/shell-winpath.test.js && node tests/openclaw-atomic-write.test.js && node tests/openclaw-disable-auth-direct.test.js && node tests/opencode-default-model.test.js && node tests/paths-bundled.test.js && node tests/aionui-runtime-resources.test.js && node tests/aionui-wrapper-claude-proxy.test.js && node tests/aionui-wrapper-probe.test.js && node tests/aionui-wrapper-proxy-integration.test.js && node tests/aionui-wrapper-all-clis-autoconf.test.js && node tests/aionui-wrapper-env-signal.test.js && node tests/aionui-wrapper-csp-rewrite.test.js && node tests/aionui-wrapper-version-status.test.js && node tests/claude-proxy-daemon.test.js && node tests/acptypes-patch.test.js && node tests/codex-approval-policy.test.js && node tests/version-check.test.js && node tests/runclaude-missing-binary.test.js",
|
|
4106
|
+
test: "node tests/droid.test.js && node tests/workspace-store.test.js && node tests/runtime-stale-upgrade.test.js && node tests/hermes.test.js && node tests/preflight.test.js && node tests/opencode-auth-purge.test.js && node tests/shell-winpath.test.js && node tests/openclaw-atomic-write.test.js && node tests/openclaw-disable-auth-direct.test.js && node tests/opencode-default-model.test.js && node tests/paths-bundled.test.js && node tests/aionui-runtime-resources.test.js && node tests/aionui-wrapper-claude-proxy.test.js && node tests/aionui-wrapper-probe.test.js && node tests/aionui-wrapper-proxy-integration.test.js && node tests/aionui-wrapper-all-clis-autoconf.test.js && node tests/aionui-wrapper-env-signal.test.js && node tests/aionui-wrapper-csp-rewrite.test.js && node tests/aionui-wrapper-version-status.test.js && node tests/claude-proxy-daemon.test.js && node tests/claude-proxy-vscode-settings.test.js && node tests/acptypes-patch.test.js && node tests/codex-approval-policy.test.js && node tests/version-check.test.js && node tests/runclaude-missing-binary.test.js",
|
|
4107
4107
|
prepublishOnly: "npm run build && npm test && node scripts/check-tarball-size.js"
|
|
4108
4108
|
},
|
|
4109
4109
|
keywords: [
|
package/dist/index.js
CHANGED
|
@@ -12,11 +12,11 @@ var require_package = __commonJS({
|
|
|
12
12
|
"package.json"(exports2, module2) {
|
|
13
13
|
module2.exports = {
|
|
14
14
|
name: "@simonyea/holysheep-cli",
|
|
15
|
-
version: "2.1.
|
|
15
|
+
version: "2.1.66",
|
|
16
16
|
description: "Claude Code/Cursor/Cline API relay for China \u2014 \xA51=$1, WeChat/Alipay payment, no credit card, no VPN. One command setup for all AI coding tools.",
|
|
17
17
|
scripts: {
|
|
18
18
|
build: "node scripts/build.mjs",
|
|
19
|
-
test: "node tests/droid.test.js && node tests/workspace-store.test.js && node tests/runtime-stale-upgrade.test.js && node tests/hermes.test.js && node tests/preflight.test.js && node tests/opencode-auth-purge.test.js && node tests/shell-winpath.test.js && node tests/openclaw-atomic-write.test.js && node tests/openclaw-disable-auth-direct.test.js && node tests/opencode-default-model.test.js && node tests/paths-bundled.test.js && node tests/aionui-runtime-resources.test.js && node tests/aionui-wrapper-claude-proxy.test.js && node tests/aionui-wrapper-probe.test.js && node tests/aionui-wrapper-proxy-integration.test.js && node tests/aionui-wrapper-all-clis-autoconf.test.js && node tests/aionui-wrapper-env-signal.test.js && node tests/aionui-wrapper-csp-rewrite.test.js && node tests/aionui-wrapper-version-status.test.js && node tests/claude-proxy-daemon.test.js && node tests/acptypes-patch.test.js && node tests/codex-approval-policy.test.js && node tests/version-check.test.js && node tests/runclaude-missing-binary.test.js",
|
|
19
|
+
test: "node tests/droid.test.js && node tests/workspace-store.test.js && node tests/runtime-stale-upgrade.test.js && node tests/hermes.test.js && node tests/preflight.test.js && node tests/opencode-auth-purge.test.js && node tests/shell-winpath.test.js && node tests/openclaw-atomic-write.test.js && node tests/openclaw-disable-auth-direct.test.js && node tests/opencode-default-model.test.js && node tests/paths-bundled.test.js && node tests/aionui-runtime-resources.test.js && node tests/aionui-wrapper-claude-proxy.test.js && node tests/aionui-wrapper-probe.test.js && node tests/aionui-wrapper-proxy-integration.test.js && node tests/aionui-wrapper-all-clis-autoconf.test.js && node tests/aionui-wrapper-env-signal.test.js && node tests/aionui-wrapper-csp-rewrite.test.js && node tests/aionui-wrapper-version-status.test.js && node tests/claude-proxy-daemon.test.js && node tests/claude-proxy-vscode-settings.test.js && node tests/acptypes-patch.test.js && node tests/codex-approval-policy.test.js && node tests/version-check.test.js && node tests/runclaude-missing-binary.test.js",
|
|
20
20
|
prepublishOnly: "npm run build && npm test && node scripts/check-tarball-size.js"
|
|
21
21
|
},
|
|
22
22
|
keywords: [
|
|
@@ -7063,145 +7063,6 @@ var require_workspace_runtime = __commonJS({
|
|
|
7063
7063
|
}
|
|
7064
7064
|
});
|
|
7065
7065
|
|
|
7066
|
-
// src/commands/claude.js
|
|
7067
|
-
var require_claude = __commonJS({
|
|
7068
|
-
"src/commands/claude.js"(exports2, module2) {
|
|
7069
|
-
"use strict";
|
|
7070
|
-
var path = require("path");
|
|
7071
|
-
var { spawn } = require("child_process");
|
|
7072
|
-
var {
|
|
7073
|
-
BASE_URL_ANTHROPIC,
|
|
7074
|
-
BASE_URL_CLAUDE_RELAY,
|
|
7075
|
-
getApiKey
|
|
7076
|
-
} = require_config();
|
|
7077
|
-
var {
|
|
7078
|
-
closeSession,
|
|
7079
|
-
getLocalProxyUrl,
|
|
7080
|
-
startProcessProxy,
|
|
7081
|
-
readConfig,
|
|
7082
|
-
writeConfig
|
|
7083
|
-
} = require_claude_process_proxy();
|
|
7084
|
-
var claudeCodeTool = require_claude_code();
|
|
7085
|
-
var { processProxyInjectPath } = require_paths();
|
|
7086
|
-
var INJECT_PATH = processProxyInjectPath();
|
|
7087
|
-
function appendNodeRequire(existingValue, requirePath) {
|
|
7088
|
-
const nextFlag = `--require ${requirePath}`;
|
|
7089
|
-
if (!existingValue) return nextFlag;
|
|
7090
|
-
return existingValue.includes(nextFlag) ? existingValue : `${existingValue} ${nextFlag}`.trim();
|
|
7091
|
-
}
|
|
7092
|
-
__name(appendNodeRequire, "appendNodeRequire");
|
|
7093
|
-
function mergeNoProxy(existingValue, extraHosts = []) {
|
|
7094
|
-
const merged = /* @__PURE__ */ new Set();
|
|
7095
|
-
for (const chunk of String(existingValue || "").split(",")) {
|
|
7096
|
-
const value = chunk.trim();
|
|
7097
|
-
if (value) merged.add(value);
|
|
7098
|
-
}
|
|
7099
|
-
for (const host of extraHosts) {
|
|
7100
|
-
if (host) merged.add(host);
|
|
7101
|
-
}
|
|
7102
|
-
return Array.from(merged).join(",");
|
|
7103
|
-
}
|
|
7104
|
-
__name(mergeNoProxy, "mergeNoProxy");
|
|
7105
|
-
function ensureClaudeProxyConfig(apiKey) {
|
|
7106
|
-
const config = readConfig();
|
|
7107
|
-
const next = claudeCodeTool.buildBridgeConfig(apiKey, BASE_URL_ANTHROPIC, {
|
|
7108
|
-
...config,
|
|
7109
|
-
relayUrl: config.relayUrl || BASE_URL_CLAUDE_RELAY
|
|
7110
|
-
});
|
|
7111
|
-
const changed = JSON.stringify(next) !== JSON.stringify(config);
|
|
7112
|
-
if (changed) {
|
|
7113
|
-
writeConfig(next);
|
|
7114
|
-
return next;
|
|
7115
|
-
}
|
|
7116
|
-
return config;
|
|
7117
|
-
}
|
|
7118
|
-
__name(ensureClaudeProxyConfig, "ensureClaudeProxyConfig");
|
|
7119
|
-
async function runClaude(args = []) {
|
|
7120
|
-
var _a;
|
|
7121
|
-
const config = readConfig();
|
|
7122
|
-
const apiKey = config.apiKey || getApiKey();
|
|
7123
|
-
if (!apiKey) {
|
|
7124
|
-
throw new Error("Missing API Key. Run hs setup first.");
|
|
7125
|
-
}
|
|
7126
|
-
try {
|
|
7127
|
-
const { scheduleUpgradeBannerCheck } = require_version_check();
|
|
7128
|
-
const pkg2 = require_package();
|
|
7129
|
-
scheduleUpgradeBannerCheck({ localVersion: pkg2.version });
|
|
7130
|
-
} catch {
|
|
7131
|
-
}
|
|
7132
|
-
ensureClaudeProxyConfig(apiKey);
|
|
7133
|
-
const runtime = typeof claudeCodeTool.detectClaudeRuntime === "function" ? claudeCodeTool.detectClaudeRuntime() : { kind: "unknown", launchMode: "env-proxy" };
|
|
7134
|
-
if (runtime.kind === "missing") {
|
|
7135
|
-
const installCmd = process.platform === "win32" ? "irm https://claude.ai/install.ps1 | iex" : "curl -fsSL https://claude.ai/install.sh | bash";
|
|
7136
|
-
const err = new Error(
|
|
7137
|
-
`\u672A\u627E\u5230 claude \u547D\u4EE4 \u2014 Claude Code \u5C1A\u672A\u5B89\u88C5\u3002
|
|
7138
|
-
\u8BF7\u5148\u8FD0\u884C: ${installCmd}
|
|
7139
|
-
\u5B89\u88C5\u540E\u91CD\u5F00\u7EC8\u7AEF\u518D\u6267\u884C hs claude\u3002`
|
|
7140
|
-
);
|
|
7141
|
-
err.code = "CLAUDE_NOT_INSTALLED";
|
|
7142
|
-
err.exitCode = 127;
|
|
7143
|
-
throw err;
|
|
7144
|
-
}
|
|
7145
|
-
const settings = claudeCodeTool.readSettings();
|
|
7146
|
-
if ((_a = settings.env) == null ? void 0 : _a.ANTHROPIC_BASE_URL) {
|
|
7147
|
-
delete settings.env.ANTHROPIC_BASE_URL;
|
|
7148
|
-
claudeCodeTool.writeSettings(settings);
|
|
7149
|
-
}
|
|
7150
|
-
const { server, port, sessionId } = await startProcessProxy({});
|
|
7151
|
-
const proxyUrl = getLocalProxyUrl(port);
|
|
7152
|
-
const launchMode = runtime.launchMode === "node-inject" ? "local-api + connect-fallback + node-inject" : "whole-process-proxy + local-api";
|
|
7153
|
-
const env = {
|
|
7154
|
-
...process.env,
|
|
7155
|
-
ANTHROPIC_API_KEY: void 0,
|
|
7156
|
-
ANTHROPIC_AUTH_TOKEN: apiKey,
|
|
7157
|
-
ANTHROPIC_BASE_URL: proxyUrl,
|
|
7158
|
-
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1",
|
|
7159
|
-
HOLYSHEEP_CLAUDE_PROCESS_PROXY: "1",
|
|
7160
|
-
HOLYSHEEP_CLAUDE_SESSION_ID: sessionId,
|
|
7161
|
-
HS_PROXY_URL: proxyUrl,
|
|
7162
|
-
HOLYSHEEP_CLAUDE_RUNTIME_KIND: runtime.kind || "unknown",
|
|
7163
|
-
HOLYSHEEP_CLAUDE_LAUNCH_MODE: launchMode,
|
|
7164
|
-
HTTP_PROXY: proxyUrl,
|
|
7165
|
-
HTTPS_PROXY: proxyUrl,
|
|
7166
|
-
ALL_PROXY: proxyUrl,
|
|
7167
|
-
NO_PROXY: mergeNoProxy(process.env.NO_PROXY, ["127.0.0.1", "localhost"]),
|
|
7168
|
-
ANTHROPIC_MAX_RETRIES: "0",
|
|
7169
|
-
MAX_RETRIES: "0"
|
|
7170
|
-
};
|
|
7171
|
-
if (runtime.launchMode === "node-inject") {
|
|
7172
|
-
env.NODE_OPTIONS = appendNodeRequire(process.env.NODE_OPTIONS, INJECT_PATH);
|
|
7173
|
-
}
|
|
7174
|
-
const child = spawn("claude", args, {
|
|
7175
|
-
stdio: "inherit",
|
|
7176
|
-
env,
|
|
7177
|
-
shell: process.platform === "win32"
|
|
7178
|
-
});
|
|
7179
|
-
const cleanup = /* @__PURE__ */ __name(async () => {
|
|
7180
|
-
try {
|
|
7181
|
-
server.close();
|
|
7182
|
-
} catch {
|
|
7183
|
-
}
|
|
7184
|
-
await closeSession(void 0, sessionId);
|
|
7185
|
-
}, "cleanup");
|
|
7186
|
-
process.on("SIGINT", () => child.kill("SIGINT"));
|
|
7187
|
-
process.on("SIGTERM", () => child.kill("SIGTERM"));
|
|
7188
|
-
return await new Promise((resolve, reject) => {
|
|
7189
|
-
child.once("error", async (error) => {
|
|
7190
|
-
await cleanup();
|
|
7191
|
-
reject(error);
|
|
7192
|
-
});
|
|
7193
|
-
child.once("exit", async (code, signal) => {
|
|
7194
|
-
await cleanup();
|
|
7195
|
-
if (signal) process.kill(process.pid, signal);
|
|
7196
|
-
resolve(code || 0);
|
|
7197
|
-
});
|
|
7198
|
-
});
|
|
7199
|
-
}
|
|
7200
|
-
__name(runClaude, "runClaude");
|
|
7201
|
-
module2.exports = runClaude;
|
|
7202
|
-
}
|
|
7203
|
-
});
|
|
7204
|
-
|
|
7205
7066
|
// src/commands/claude-proxy.js
|
|
7206
7067
|
var require_claude_proxy = __commonJS({
|
|
7207
7068
|
"src/commands/claude-proxy.js"(exports2, module2) {
|
|
@@ -7332,18 +7193,36 @@ ${logTail}` : message);
|
|
|
7332
7193
|
const settings = claudeCodeTool.readSettings();
|
|
7333
7194
|
if (!settings.env) settings.env = {};
|
|
7334
7195
|
settings.env.ANTHROPIC_BASE_URL = getLocalProxyUrl(port);
|
|
7196
|
+
if (settings.env.ANTHROPIC_AUTH_TOKEN === void 0 || settings.env.ANTHROPIC_AUTH_TOKEN === null || settings.env.ANTHROPIC_AUTH_TOKEN === "") {
|
|
7197
|
+
const config = readConfig();
|
|
7198
|
+
const apiKey = config.apiKey || getApiKey();
|
|
7199
|
+
if (apiKey) settings.env.ANTHROPIC_AUTH_TOKEN = apiKey;
|
|
7200
|
+
}
|
|
7201
|
+
settings.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1";
|
|
7202
|
+
settings.env.HOLYSHEEP_CLAUDE_LAUNCHER = "hs-claude-proxy";
|
|
7203
|
+
settings.env.HOLYSHEEP_CLAUDE_PROCESS_PROXY = "1";
|
|
7335
7204
|
claudeCodeTool.writeSettings(settings);
|
|
7336
7205
|
}
|
|
7337
7206
|
__name(writeBaseUrlToSettings, "writeBaseUrlToSettings");
|
|
7338
7207
|
function clearBaseUrlFromSettings() {
|
|
7339
|
-
var _a
|
|
7208
|
+
var _a;
|
|
7340
7209
|
const settings = claudeCodeTool.readSettings();
|
|
7341
|
-
if ((
|
|
7210
|
+
if (isLocalProxyBaseUrl((_a = settings.env) == null ? void 0 : _a.ANTHROPIC_BASE_URL)) {
|
|
7342
7211
|
delete settings.env.ANTHROPIC_BASE_URL;
|
|
7343
7212
|
claudeCodeTool.writeSettings(settings);
|
|
7344
7213
|
}
|
|
7345
7214
|
}
|
|
7346
7215
|
__name(clearBaseUrlFromSettings, "clearBaseUrlFromSettings");
|
|
7216
|
+
function isLocalProxyBaseUrl(value) {
|
|
7217
|
+
if (!value) return false;
|
|
7218
|
+
try {
|
|
7219
|
+
const url = new URL(String(value));
|
|
7220
|
+
return (url.hostname === "127.0.0.1" || url.hostname === "localhost") && (url.protocol === "http:" || url.protocol === "https:");
|
|
7221
|
+
} catch {
|
|
7222
|
+
return String(value).includes("127.0.0.1") || String(value).includes("localhost");
|
|
7223
|
+
}
|
|
7224
|
+
}
|
|
7225
|
+
__name(isLocalProxyBaseUrl, "isLocalProxyBaseUrl");
|
|
7347
7226
|
async function handleStop() {
|
|
7348
7227
|
const info = readPid();
|
|
7349
7228
|
if (!info) {
|
|
@@ -7399,6 +7278,7 @@ ${logTail}` : message);
|
|
|
7399
7278
|
}
|
|
7400
7279
|
const info = readPid();
|
|
7401
7280
|
if (info && isProcessAlive(info.pid) && await isProxyHealthy(info.port)) {
|
|
7281
|
+
writeBaseUrlToSettings(info.port);
|
|
7402
7282
|
console.log(chalk2.green(`\u4EE3\u7406\u5DF2\u5728\u8FD0\u884C (PID ${info.pid}, \u7AEF\u53E3 ${info.port})`));
|
|
7403
7283
|
return;
|
|
7404
7284
|
}
|
|
@@ -7437,6 +7317,7 @@ ${logTail}` : message);
|
|
|
7437
7317
|
}
|
|
7438
7318
|
const latest = await readHealthyPid({ timeoutMs: 1e3 });
|
|
7439
7319
|
if (latest) {
|
|
7320
|
+
writeBaseUrlToSettings(latest.port);
|
|
7440
7321
|
console.log(chalk2.green(`\u4EE3\u7406\u5DF2\u5728\u540E\u53F0\u542F\u52A8`));
|
|
7441
7322
|
console.log(chalk2.gray(` PID: ${latest.pid}`));
|
|
7442
7323
|
console.log(chalk2.gray(` \u7AEF\u53E3: ${latest.port}`));
|
|
@@ -7468,10 +7349,8 @@ ${logTail}` : message);
|
|
|
7468
7349
|
console.log(chalk2.yellow(`\u4EE3\u7406\u5DF2\u5728\u8FD0\u884C (PID ${existing.pid}, \u7AEF\u53E3 ${existing.port})\uFF0C\u5148\u505C\u6B62: hs claude-proxy --stop`));
|
|
7469
7350
|
process.exit(1);
|
|
7470
7351
|
}
|
|
7471
|
-
const ensureClaudeProxyConfig = require_claude().ensureClaudeProxyConfig || (() => {
|
|
7472
|
-
});
|
|
7473
7352
|
try {
|
|
7474
|
-
ensureClaudeProxyConfig(apiKey);
|
|
7353
|
+
claudeProxy.ensureClaudeProxyConfig(apiKey);
|
|
7475
7354
|
} catch {
|
|
7476
7355
|
}
|
|
7477
7356
|
console.log(chalk2.gray("\u542F\u52A8 Claude \u4EE3\u7406..."));
|
|
@@ -7514,8 +7393,8 @@ ${logTail}` : message);
|
|
|
7514
7393
|
const claudeCodeTool2 = require_claude_code();
|
|
7515
7394
|
const proxy = require_claude_process_proxy();
|
|
7516
7395
|
const config = proxy.readConfig();
|
|
7517
|
-
|
|
7518
|
-
|
|
7396
|
+
const bridgeConfig = claudeCodeTool2.buildBridgeConfig(apiKey, void 0, config);
|
|
7397
|
+
if (JSON.stringify(bridgeConfig) !== JSON.stringify(config)) {
|
|
7519
7398
|
proxy.writeConfig(bridgeConfig);
|
|
7520
7399
|
}
|
|
7521
7400
|
};
|
|
@@ -11017,6 +10896,145 @@ var require_webui = __commonJS({
|
|
|
11017
10896
|
}
|
|
11018
10897
|
});
|
|
11019
10898
|
|
|
10899
|
+
// src/commands/claude.js
|
|
10900
|
+
var require_claude = __commonJS({
|
|
10901
|
+
"src/commands/claude.js"(exports2, module2) {
|
|
10902
|
+
"use strict";
|
|
10903
|
+
var path = require("path");
|
|
10904
|
+
var { spawn } = require("child_process");
|
|
10905
|
+
var {
|
|
10906
|
+
BASE_URL_ANTHROPIC,
|
|
10907
|
+
BASE_URL_CLAUDE_RELAY,
|
|
10908
|
+
getApiKey
|
|
10909
|
+
} = require_config();
|
|
10910
|
+
var {
|
|
10911
|
+
closeSession,
|
|
10912
|
+
getLocalProxyUrl,
|
|
10913
|
+
startProcessProxy,
|
|
10914
|
+
readConfig,
|
|
10915
|
+
writeConfig
|
|
10916
|
+
} = require_claude_process_proxy();
|
|
10917
|
+
var claudeCodeTool = require_claude_code();
|
|
10918
|
+
var { processProxyInjectPath } = require_paths();
|
|
10919
|
+
var INJECT_PATH = processProxyInjectPath();
|
|
10920
|
+
function appendNodeRequire(existingValue, requirePath) {
|
|
10921
|
+
const nextFlag = `--require ${requirePath}`;
|
|
10922
|
+
if (!existingValue) return nextFlag;
|
|
10923
|
+
return existingValue.includes(nextFlag) ? existingValue : `${existingValue} ${nextFlag}`.trim();
|
|
10924
|
+
}
|
|
10925
|
+
__name(appendNodeRequire, "appendNodeRequire");
|
|
10926
|
+
function mergeNoProxy(existingValue, extraHosts = []) {
|
|
10927
|
+
const merged = /* @__PURE__ */ new Set();
|
|
10928
|
+
for (const chunk of String(existingValue || "").split(",")) {
|
|
10929
|
+
const value = chunk.trim();
|
|
10930
|
+
if (value) merged.add(value);
|
|
10931
|
+
}
|
|
10932
|
+
for (const host of extraHosts) {
|
|
10933
|
+
if (host) merged.add(host);
|
|
10934
|
+
}
|
|
10935
|
+
return Array.from(merged).join(",");
|
|
10936
|
+
}
|
|
10937
|
+
__name(mergeNoProxy, "mergeNoProxy");
|
|
10938
|
+
function ensureClaudeProxyConfig(apiKey) {
|
|
10939
|
+
const config = readConfig();
|
|
10940
|
+
const next = claudeCodeTool.buildBridgeConfig(apiKey, BASE_URL_ANTHROPIC, {
|
|
10941
|
+
...config,
|
|
10942
|
+
relayUrl: config.relayUrl || BASE_URL_CLAUDE_RELAY
|
|
10943
|
+
});
|
|
10944
|
+
const changed = JSON.stringify(next) !== JSON.stringify(config);
|
|
10945
|
+
if (changed) {
|
|
10946
|
+
writeConfig(next);
|
|
10947
|
+
return next;
|
|
10948
|
+
}
|
|
10949
|
+
return config;
|
|
10950
|
+
}
|
|
10951
|
+
__name(ensureClaudeProxyConfig, "ensureClaudeProxyConfig");
|
|
10952
|
+
async function runClaude(args = []) {
|
|
10953
|
+
var _a;
|
|
10954
|
+
const config = readConfig();
|
|
10955
|
+
const apiKey = config.apiKey || getApiKey();
|
|
10956
|
+
if (!apiKey) {
|
|
10957
|
+
throw new Error("Missing API Key. Run hs setup first.");
|
|
10958
|
+
}
|
|
10959
|
+
try {
|
|
10960
|
+
const { scheduleUpgradeBannerCheck } = require_version_check();
|
|
10961
|
+
const pkg2 = require_package();
|
|
10962
|
+
scheduleUpgradeBannerCheck({ localVersion: pkg2.version });
|
|
10963
|
+
} catch {
|
|
10964
|
+
}
|
|
10965
|
+
ensureClaudeProxyConfig(apiKey);
|
|
10966
|
+
const runtime = typeof claudeCodeTool.detectClaudeRuntime === "function" ? claudeCodeTool.detectClaudeRuntime() : { kind: "unknown", launchMode: "env-proxy" };
|
|
10967
|
+
if (runtime.kind === "missing") {
|
|
10968
|
+
const installCmd = process.platform === "win32" ? "irm https://claude.ai/install.ps1 | iex" : "curl -fsSL https://claude.ai/install.sh | bash";
|
|
10969
|
+
const err = new Error(
|
|
10970
|
+
`\u672A\u627E\u5230 claude \u547D\u4EE4 \u2014 Claude Code \u5C1A\u672A\u5B89\u88C5\u3002
|
|
10971
|
+
\u8BF7\u5148\u8FD0\u884C: ${installCmd}
|
|
10972
|
+
\u5B89\u88C5\u540E\u91CD\u5F00\u7EC8\u7AEF\u518D\u6267\u884C hs claude\u3002`
|
|
10973
|
+
);
|
|
10974
|
+
err.code = "CLAUDE_NOT_INSTALLED";
|
|
10975
|
+
err.exitCode = 127;
|
|
10976
|
+
throw err;
|
|
10977
|
+
}
|
|
10978
|
+
const settings = claudeCodeTool.readSettings();
|
|
10979
|
+
if ((_a = settings.env) == null ? void 0 : _a.ANTHROPIC_BASE_URL) {
|
|
10980
|
+
delete settings.env.ANTHROPIC_BASE_URL;
|
|
10981
|
+
claudeCodeTool.writeSettings(settings);
|
|
10982
|
+
}
|
|
10983
|
+
const { server, port, sessionId } = await startProcessProxy({});
|
|
10984
|
+
const proxyUrl = getLocalProxyUrl(port);
|
|
10985
|
+
const launchMode = runtime.launchMode === "node-inject" ? "local-api + connect-fallback + node-inject" : "whole-process-proxy + local-api";
|
|
10986
|
+
const env = {
|
|
10987
|
+
...process.env,
|
|
10988
|
+
ANTHROPIC_API_KEY: void 0,
|
|
10989
|
+
ANTHROPIC_AUTH_TOKEN: apiKey,
|
|
10990
|
+
ANTHROPIC_BASE_URL: proxyUrl,
|
|
10991
|
+
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1",
|
|
10992
|
+
HOLYSHEEP_CLAUDE_PROCESS_PROXY: "1",
|
|
10993
|
+
HOLYSHEEP_CLAUDE_SESSION_ID: sessionId,
|
|
10994
|
+
HS_PROXY_URL: proxyUrl,
|
|
10995
|
+
HOLYSHEEP_CLAUDE_RUNTIME_KIND: runtime.kind || "unknown",
|
|
10996
|
+
HOLYSHEEP_CLAUDE_LAUNCH_MODE: launchMode,
|
|
10997
|
+
HTTP_PROXY: proxyUrl,
|
|
10998
|
+
HTTPS_PROXY: proxyUrl,
|
|
10999
|
+
ALL_PROXY: proxyUrl,
|
|
11000
|
+
NO_PROXY: mergeNoProxy(process.env.NO_PROXY, ["127.0.0.1", "localhost"]),
|
|
11001
|
+
ANTHROPIC_MAX_RETRIES: "0",
|
|
11002
|
+
MAX_RETRIES: "0"
|
|
11003
|
+
};
|
|
11004
|
+
if (runtime.launchMode === "node-inject") {
|
|
11005
|
+
env.NODE_OPTIONS = appendNodeRequire(process.env.NODE_OPTIONS, INJECT_PATH);
|
|
11006
|
+
}
|
|
11007
|
+
const child = spawn("claude", args, {
|
|
11008
|
+
stdio: "inherit",
|
|
11009
|
+
env,
|
|
11010
|
+
shell: process.platform === "win32"
|
|
11011
|
+
});
|
|
11012
|
+
const cleanup = /* @__PURE__ */ __name(async () => {
|
|
11013
|
+
try {
|
|
11014
|
+
server.close();
|
|
11015
|
+
} catch {
|
|
11016
|
+
}
|
|
11017
|
+
await closeSession(void 0, sessionId);
|
|
11018
|
+
}, "cleanup");
|
|
11019
|
+
process.on("SIGINT", () => child.kill("SIGINT"));
|
|
11020
|
+
process.on("SIGTERM", () => child.kill("SIGTERM"));
|
|
11021
|
+
return await new Promise((resolve, reject) => {
|
|
11022
|
+
child.once("error", async (error) => {
|
|
11023
|
+
await cleanup();
|
|
11024
|
+
reject(error);
|
|
11025
|
+
});
|
|
11026
|
+
child.once("exit", async (code, signal) => {
|
|
11027
|
+
await cleanup();
|
|
11028
|
+
if (signal) process.kill(process.pid, signal);
|
|
11029
|
+
resolve(code || 0);
|
|
11030
|
+
});
|
|
11031
|
+
});
|
|
11032
|
+
}
|
|
11033
|
+
__name(runClaude, "runClaude");
|
|
11034
|
+
module2.exports = runClaude;
|
|
11035
|
+
}
|
|
11036
|
+
});
|
|
11037
|
+
|
|
11020
11038
|
// src/index.js
|
|
11021
11039
|
var { program } = require("commander");
|
|
11022
11040
|
var chalk = require("chalk");
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simonyea/holysheep-cli",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.66",
|
|
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
|
"scripts": {
|
|
6
6
|
"build": "node scripts/build.mjs",
|
|
7
|
-
"test": "node tests/droid.test.js && node tests/workspace-store.test.js && node tests/runtime-stale-upgrade.test.js && node tests/hermes.test.js && node tests/preflight.test.js && node tests/opencode-auth-purge.test.js && node tests/shell-winpath.test.js && node tests/openclaw-atomic-write.test.js && node tests/openclaw-disable-auth-direct.test.js && node tests/opencode-default-model.test.js && node tests/paths-bundled.test.js && node tests/aionui-runtime-resources.test.js && node tests/aionui-wrapper-claude-proxy.test.js && node tests/aionui-wrapper-probe.test.js && node tests/aionui-wrapper-proxy-integration.test.js && node tests/aionui-wrapper-all-clis-autoconf.test.js && node tests/aionui-wrapper-env-signal.test.js && node tests/aionui-wrapper-csp-rewrite.test.js && node tests/aionui-wrapper-version-status.test.js && node tests/claude-proxy-daemon.test.js && node tests/acptypes-patch.test.js && node tests/codex-approval-policy.test.js && node tests/version-check.test.js && node tests/runclaude-missing-binary.test.js",
|
|
7
|
+
"test": "node tests/droid.test.js && node tests/workspace-store.test.js && node tests/runtime-stale-upgrade.test.js && node tests/hermes.test.js && node tests/preflight.test.js && node tests/opencode-auth-purge.test.js && node tests/shell-winpath.test.js && node tests/openclaw-atomic-write.test.js && node tests/openclaw-disable-auth-direct.test.js && node tests/opencode-default-model.test.js && node tests/paths-bundled.test.js && node tests/aionui-runtime-resources.test.js && node tests/aionui-wrapper-claude-proxy.test.js && node tests/aionui-wrapper-probe.test.js && node tests/aionui-wrapper-proxy-integration.test.js && node tests/aionui-wrapper-all-clis-autoconf.test.js && node tests/aionui-wrapper-env-signal.test.js && node tests/aionui-wrapper-csp-rewrite.test.js && node tests/aionui-wrapper-version-status.test.js && node tests/claude-proxy-daemon.test.js && node tests/claude-proxy-vscode-settings.test.js && node tests/acptypes-patch.test.js && node tests/codex-approval-policy.test.js && node tests/version-check.test.js && node tests/runclaude-missing-binary.test.js",
|
|
8
8
|
"prepublishOnly": "npm run build && npm test && node scripts/check-tarball-size.js"
|
|
9
9
|
},
|
|
10
10
|
"keywords": [
|