@simonyea/holysheep-cli 2.1.65 → 2.1.67

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.
@@ -1147,7 +1147,34 @@ var require_claude_code = __commonJS({
1147
1147
  BASE_URL_CLAUDE_RELAY
1148
1148
  } = require_config();
1149
1149
  var { readConfig, writeConfig } = require_claude_process_proxy();
1150
- var SETTINGS_FILE = path.join(os.homedir(), ".claude", "settings.json");
1150
+ function resolveClaudeHomeDir() {
1151
+ const platform = process.env.HOLYSHEEP_TEST_PLATFORM || process.platform;
1152
+ if (platform === "win32") return process.env.USERPROFILE || process.env.HOME || os.homedir();
1153
+ return os.homedir();
1154
+ }
1155
+ __name(resolveClaudeHomeDir, "resolveClaudeHomeDir");
1156
+ function getSettingsFile() {
1157
+ return path.join(resolveClaudeHomeDir(), ".claude", "settings.json");
1158
+ }
1159
+ __name(getSettingsFile, "getSettingsFile");
1160
+ function isLocalProxyBaseUrl(value) {
1161
+ if (!value) return false;
1162
+ try {
1163
+ const url = new URL(String(value));
1164
+ return (url.hostname === "127.0.0.1" || url.hostname === "localhost") && (url.protocol === "http:" || url.protocol === "https:");
1165
+ } catch {
1166
+ return String(value).includes("127.0.0.1") || String(value).includes("localhost");
1167
+ }
1168
+ }
1169
+ __name(isLocalProxyBaseUrl, "isLocalProxyBaseUrl");
1170
+ function hasDaemonProxyMarker(env = {}) {
1171
+ return env.HOLYSHEEP_CLAUDE_LAUNCHER === "hs-claude-proxy" || env.HOLYSHEEP_CLAUDE_PROCESS_PROXY === "1";
1172
+ }
1173
+ __name(hasDaemonProxyMarker, "hasDaemonProxyMarker");
1174
+ function shouldPreserveDaemonProxyEnv(env = {}) {
1175
+ return hasDaemonProxyMarker(env) && isLocalProxyBaseUrl(env.ANTHROPIC_BASE_URL);
1176
+ }
1177
+ __name(shouldPreserveDaemonProxyEnv, "shouldPreserveDaemonProxyEnv");
1151
1178
  function buildBridgeConfig(apiKey, baseUrl, bridge = {}) {
1152
1179
  const relayUrl = bridge.relayUrl || BASE_URL_CLAUDE_RELAY || "";
1153
1180
  return {
@@ -1169,7 +1196,7 @@ var require_claude_code = __commonJS({
1169
1196
  __name(buildBridgeConfig, "buildBridgeConfig");
1170
1197
  function readSettings() {
1171
1198
  try {
1172
- const raw = fs.readFileSync(SETTINGS_FILE, "utf8");
1199
+ const raw = fs.readFileSync(getSettingsFile(), "utf8");
1173
1200
  return JSON.parse(raw.replace(/[\x00-\x1F\x7F]/g, " "));
1174
1201
  } catch {
1175
1202
  return {};
@@ -1177,9 +1204,10 @@ var require_claude_code = __commonJS({
1177
1204
  }
1178
1205
  __name(readSettings, "readSettings");
1179
1206
  function writeSettings(data) {
1180
- const dir = path.dirname(SETTINGS_FILE);
1207
+ const file = getSettingsFile();
1208
+ const dir = path.dirname(file);
1181
1209
  if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
1182
- fs.writeFileSync(SETTINGS_FILE, JSON.stringify(data, null, 2), "utf8");
1210
+ fs.writeFileSync(file, JSON.stringify(data, null, 2), "utf8");
1183
1211
  }
1184
1212
  __name(writeSettings, "writeSettings");
1185
1213
  function cloneSettings(data) {
@@ -1293,16 +1321,23 @@ var require_claude_code = __commonJS({
1293
1321
  writeConfig(bridgeConfig);
1294
1322
  const settings = readSettings();
1295
1323
  if (!settings.env) settings.env = {};
1324
+ const preserveDaemonProxy = shouldPreserveDaemonProxyEnv(settings.env);
1296
1325
  settings.env.ANTHROPIC_AUTH_TOKEN = apiKey;
1297
- delete settings.env.ANTHROPIC_BASE_URL;
1326
+ if (preserveDaemonProxy) {
1327
+ settings.env.HOLYSHEEP_CLAUDE_LAUNCHER = "hs-claude-proxy";
1328
+ settings.env.HOLYSHEEP_CLAUDE_PROCESS_PROXY = "1";
1329
+ } else {
1330
+ delete settings.env.ANTHROPIC_BASE_URL;
1331
+ settings.env.HOLYSHEEP_CLAUDE_LAUNCHER = "hs";
1332
+ delete settings.env.HOLYSHEEP_CLAUDE_PROCESS_PROXY;
1333
+ }
1298
1334
  settings.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1";
1299
- settings.env.HOLYSHEEP_CLAUDE_LAUNCHER = "hs";
1300
1335
  if (primaryModel) settings.model = primaryModel;
1301
1336
  delete settings.env.ANTHROPIC_API_KEY;
1302
1337
  delete settings.env.HOLYSHEEP_CLAUDE_BRIDGE;
1303
1338
  writeSettings(settings);
1304
1339
  return {
1305
- file: SETTINGS_FILE,
1340
+ file: getSettingsFile(),
1306
1341
  hot: true,
1307
1342
  extraFiles: ["~/.holysheep/claude-proxy.json"]
1308
1343
  };
@@ -1320,7 +1355,7 @@ var require_claude_code = __commonJS({
1320
1355
  writeSettings(settings);
1321
1356
  },
1322
1357
  getConfigPath() {
1323
- return SETTINGS_FILE;
1358
+ return getSettingsFile();
1324
1359
  },
1325
1360
  hint: "\u901A\u8FC7 hs claude \u4EE5\u6574\u8FDB\u7A0B\u4EE3\u7406\u65B9\u5F0F\u542F\u52A8 Claude Code",
1326
1361
  launchCmd: "hs claude",
@@ -1333,7 +1368,8 @@ var require_claude_code = __commonJS({
1333
1368
  detectClaudeRuntime,
1334
1369
  readSettings,
1335
1370
  writeSettings,
1336
- applyRuntimeSettingsOverride
1371
+ applyRuntimeSettingsOverride,
1372
+ _private: { getSettingsFile, resolveClaudeHomeDir, shouldPreserveDaemonProxyEnv, hasDaemonProxyMarker, isLocalProxyBaseUrl }
1337
1373
  };
1338
1374
  }
1339
1375
  });
@@ -4099,11 +4135,11 @@ var require_package = __commonJS({
4099
4135
  "package.json"(exports2, module2) {
4100
4136
  module2.exports = {
4101
4137
  name: "@simonyea/holysheep-cli",
4102
- version: "2.1.65",
4138
+ version: "2.1.67",
4103
4139
  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
4140
  scripts: {
4105
4141
  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",
4142
+ 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/claude-proxy-vscode-env.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 && node tests/claude-code-configure-preserve.test.js",
4107
4143
  prepublishOnly: "npm run build && npm test && node scripts/check-tarball-size.js"
4108
4144
  },
4109
4145
  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.65",
15
+ version: "2.1.67",
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/claude-proxy-vscode-env.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 && node tests/claude-code-configure-preserve.test.js",
20
20
  prepublishOnly: "npm run build && npm test && node scripts/check-tarball-size.js"
21
21
  },
22
22
  keywords: [
@@ -1693,7 +1693,34 @@ var require_claude_code = __commonJS({
1693
1693
  BASE_URL_CLAUDE_RELAY
1694
1694
  } = require_config();
1695
1695
  var { readConfig, writeConfig } = require_claude_process_proxy();
1696
- var SETTINGS_FILE = path.join(os.homedir(), ".claude", "settings.json");
1696
+ function resolveClaudeHomeDir() {
1697
+ const platform = process.env.HOLYSHEEP_TEST_PLATFORM || process.platform;
1698
+ if (platform === "win32") return process.env.USERPROFILE || process.env.HOME || os.homedir();
1699
+ return os.homedir();
1700
+ }
1701
+ __name(resolveClaudeHomeDir, "resolveClaudeHomeDir");
1702
+ function getSettingsFile() {
1703
+ return path.join(resolveClaudeHomeDir(), ".claude", "settings.json");
1704
+ }
1705
+ __name(getSettingsFile, "getSettingsFile");
1706
+ function isLocalProxyBaseUrl(value) {
1707
+ if (!value) return false;
1708
+ try {
1709
+ const url = new URL(String(value));
1710
+ return (url.hostname === "127.0.0.1" || url.hostname === "localhost") && (url.protocol === "http:" || url.protocol === "https:");
1711
+ } catch {
1712
+ return String(value).includes("127.0.0.1") || String(value).includes("localhost");
1713
+ }
1714
+ }
1715
+ __name(isLocalProxyBaseUrl, "isLocalProxyBaseUrl");
1716
+ function hasDaemonProxyMarker(env = {}) {
1717
+ return env.HOLYSHEEP_CLAUDE_LAUNCHER === "hs-claude-proxy" || env.HOLYSHEEP_CLAUDE_PROCESS_PROXY === "1";
1718
+ }
1719
+ __name(hasDaemonProxyMarker, "hasDaemonProxyMarker");
1720
+ function shouldPreserveDaemonProxyEnv(env = {}) {
1721
+ return hasDaemonProxyMarker(env) && isLocalProxyBaseUrl(env.ANTHROPIC_BASE_URL);
1722
+ }
1723
+ __name(shouldPreserveDaemonProxyEnv, "shouldPreserveDaemonProxyEnv");
1697
1724
  function buildBridgeConfig(apiKey, baseUrl, bridge = {}) {
1698
1725
  const relayUrl = bridge.relayUrl || BASE_URL_CLAUDE_RELAY || "";
1699
1726
  return {
@@ -1715,7 +1742,7 @@ var require_claude_code = __commonJS({
1715
1742
  __name(buildBridgeConfig, "buildBridgeConfig");
1716
1743
  function readSettings() {
1717
1744
  try {
1718
- const raw = fs.readFileSync(SETTINGS_FILE, "utf8");
1745
+ const raw = fs.readFileSync(getSettingsFile(), "utf8");
1719
1746
  return JSON.parse(raw.replace(/[\x00-\x1F\x7F]/g, " "));
1720
1747
  } catch {
1721
1748
  return {};
@@ -1723,9 +1750,10 @@ var require_claude_code = __commonJS({
1723
1750
  }
1724
1751
  __name(readSettings, "readSettings");
1725
1752
  function writeSettings(data) {
1726
- const dir = path.dirname(SETTINGS_FILE);
1753
+ const file = getSettingsFile();
1754
+ const dir = path.dirname(file);
1727
1755
  if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
1728
- fs.writeFileSync(SETTINGS_FILE, JSON.stringify(data, null, 2), "utf8");
1756
+ fs.writeFileSync(file, JSON.stringify(data, null, 2), "utf8");
1729
1757
  }
1730
1758
  __name(writeSettings, "writeSettings");
1731
1759
  function cloneSettings(data) {
@@ -1839,16 +1867,23 @@ var require_claude_code = __commonJS({
1839
1867
  writeConfig(bridgeConfig);
1840
1868
  const settings = readSettings();
1841
1869
  if (!settings.env) settings.env = {};
1870
+ const preserveDaemonProxy = shouldPreserveDaemonProxyEnv(settings.env);
1842
1871
  settings.env.ANTHROPIC_AUTH_TOKEN = apiKey;
1843
- delete settings.env.ANTHROPIC_BASE_URL;
1872
+ if (preserveDaemonProxy) {
1873
+ settings.env.HOLYSHEEP_CLAUDE_LAUNCHER = "hs-claude-proxy";
1874
+ settings.env.HOLYSHEEP_CLAUDE_PROCESS_PROXY = "1";
1875
+ } else {
1876
+ delete settings.env.ANTHROPIC_BASE_URL;
1877
+ settings.env.HOLYSHEEP_CLAUDE_LAUNCHER = "hs";
1878
+ delete settings.env.HOLYSHEEP_CLAUDE_PROCESS_PROXY;
1879
+ }
1844
1880
  settings.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1";
1845
- settings.env.HOLYSHEEP_CLAUDE_LAUNCHER = "hs";
1846
1881
  if (primaryModel) settings.model = primaryModel;
1847
1882
  delete settings.env.ANTHROPIC_API_KEY;
1848
1883
  delete settings.env.HOLYSHEEP_CLAUDE_BRIDGE;
1849
1884
  writeSettings(settings);
1850
1885
  return {
1851
- file: SETTINGS_FILE,
1886
+ file: getSettingsFile(),
1852
1887
  hot: true,
1853
1888
  extraFiles: ["~/.holysheep/claude-proxy.json"]
1854
1889
  };
@@ -1866,7 +1901,7 @@ var require_claude_code = __commonJS({
1866
1901
  writeSettings(settings);
1867
1902
  },
1868
1903
  getConfigPath() {
1869
- return SETTINGS_FILE;
1904
+ return getSettingsFile();
1870
1905
  },
1871
1906
  hint: "\u901A\u8FC7 hs claude \u4EE5\u6574\u8FDB\u7A0B\u4EE3\u7406\u65B9\u5F0F\u542F\u52A8 Claude Code",
1872
1907
  launchCmd: "hs claude",
@@ -1879,7 +1914,8 @@ var require_claude_code = __commonJS({
1879
1914
  detectClaudeRuntime,
1880
1915
  readSettings,
1881
1916
  writeSettings,
1882
- applyRuntimeSettingsOverride
1917
+ applyRuntimeSettingsOverride,
1918
+ _private: { getSettingsFile, resolveClaudeHomeDir, shouldPreserveDaemonProxyEnv, hasDaemonProxyMarker, isLocalProxyBaseUrl }
1883
1919
  };
1884
1920
  }
1885
1921
  });
@@ -7063,145 +7099,6 @@ var require_workspace_runtime = __commonJS({
7063
7099
  }
7064
7100
  });
7065
7101
 
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
7102
  // src/commands/claude-proxy.js
7206
7103
  var require_claude_proxy = __commonJS({
7207
7104
  "src/commands/claude-proxy.js"(exports2, module2) {
@@ -7231,6 +7128,18 @@ var require_claude_proxy = __commonJS({
7231
7128
  var DAEMON_READY_TIMEOUT_MS = Number(process.env.HS_CLAUDE_PROXY_DAEMON_READY_TIMEOUT_MS) || 12e3;
7232
7129
  var DAEMON_READY_INTERVAL_MS = Number(process.env.HS_CLAUDE_PROXY_DAEMON_READY_INTERVAL_MS) || 400;
7233
7130
  var DAEMON_TEST_CHILD_EXIT = process.env.HS_CLAUDE_PROXY_DAEMON_TEST_CHILD_EXIT === "1";
7131
+ var WINDOWS_ENV_KEYS = [
7132
+ "ANTHROPIC_BASE_URL",
7133
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC",
7134
+ "HOLYSHEEP_CLAUDE_LAUNCHER",
7135
+ "HOLYSHEEP_CLAUDE_PROCESS_PROXY"
7136
+ ];
7137
+ var platformOverride = null;
7138
+ var winUserEnvWriterOverride = null;
7139
+ function effectivePlatform() {
7140
+ return platformOverride || process.env.HS_CLAUDE_PROXY_TEST_PLATFORM || process.platform;
7141
+ }
7142
+ __name(effectivePlatform, "effectivePlatform");
7234
7143
  function readPid() {
7235
7144
  try {
7236
7145
  const content = fs.readFileSync(PID_FILE, "utf8").trim();
@@ -7328,22 +7237,108 @@ ${logTail}` : message);
7328
7237
  return err;
7329
7238
  }
7330
7239
  __name(makeDaemonError, "makeDaemonError");
7240
+ function getHolySheepApiKey() {
7241
+ const config = readConfig();
7242
+ return config.apiKey || getApiKey();
7243
+ }
7244
+ __name(getHolySheepApiKey, "getHolySheepApiKey");
7331
7245
  function writeBaseUrlToSettings(port) {
7332
7246
  const settings = claudeCodeTool.readSettings();
7333
7247
  if (!settings.env) settings.env = {};
7334
7248
  settings.env.ANTHROPIC_BASE_URL = getLocalProxyUrl(port);
7249
+ if (settings.env.ANTHROPIC_AUTH_TOKEN === void 0 || settings.env.ANTHROPIC_AUTH_TOKEN === null || settings.env.ANTHROPIC_AUTH_TOKEN === "") {
7250
+ const apiKey = getHolySheepApiKey();
7251
+ if (apiKey) settings.env.ANTHROPIC_AUTH_TOKEN = apiKey;
7252
+ }
7253
+ settings.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1";
7254
+ settings.env.HOLYSHEEP_CLAUDE_LAUNCHER = "hs-claude-proxy";
7255
+ settings.env.HOLYSHEEP_CLAUDE_PROCESS_PROXY = "1";
7335
7256
  claudeCodeTool.writeSettings(settings);
7336
7257
  }
7337
7258
  __name(writeBaseUrlToSettings, "writeBaseUrlToSettings");
7259
+ function quotePowerShellString(value) {
7260
+ return `'${String(value).replace(/'/g, "''")}'`;
7261
+ }
7262
+ __name(quotePowerShellString, "quotePowerShellString");
7263
+ function defaultWinUserEnvWriter(action, key, value) {
7264
+ if (process.env.HS_CLAUDE_PROXY_TEST_WIN_ENV_FILE) {
7265
+ const file = process.env.HS_CLAUDE_PROXY_TEST_WIN_ENV_FILE;
7266
+ let env = {};
7267
+ try {
7268
+ env = JSON.parse(fs.readFileSync(file, "utf8"));
7269
+ } catch {
7270
+ }
7271
+ if (action === "delete") delete env[key];
7272
+ else env[key] = value;
7273
+ fs.mkdirSync(path.dirname(file), { recursive: true });
7274
+ fs.writeFileSync(file, JSON.stringify(env, null, 2), "utf8");
7275
+ return;
7276
+ }
7277
+ if (effectivePlatform() !== "win32") return;
7278
+ if (!/^[A-Z0-9_]+$/i.test(String(key))) throw new Error(`Invalid env var name: ${key}`);
7279
+ const ps = action === "delete" ? `[Environment]::SetEnvironmentVariable(${quotePowerShellString(key)}, $null, 'User')` : `[Environment]::SetEnvironmentVariable(${quotePowerShellString(key)}, ${quotePowerShellString(value || "")}, 'User')`;
7280
+ execSync(`powershell.exe -NoProfile -ExecutionPolicy Bypass -Command ${quotePowerShellString(ps)}`, { stdio: "ignore", windowsHide: true });
7281
+ }
7282
+ __name(defaultWinUserEnvWriter, "defaultWinUserEnvWriter");
7283
+ function getWinUserEnvWriter() {
7284
+ if (winUserEnvWriterOverride) return winUserEnvWriterOverride;
7285
+ return defaultWinUserEnvWriter;
7286
+ }
7287
+ __name(getWinUserEnvWriter, "getWinUserEnvWriter");
7288
+ function writeWindowsUserProxyEnv(port) {
7289
+ if (effectivePlatform() !== "win32") return false;
7290
+ const apiKey = getHolySheepApiKey();
7291
+ const env = {
7292
+ ANTHROPIC_BASE_URL: getLocalProxyUrl(port),
7293
+ ...apiKey ? { ANTHROPIC_AUTH_TOKEN: apiKey } : {},
7294
+ CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1",
7295
+ HOLYSHEEP_CLAUDE_LAUNCHER: "hs-claude-proxy",
7296
+ HOLYSHEEP_CLAUDE_PROCESS_PROXY: "1"
7297
+ };
7298
+ const writer = getWinUserEnvWriter();
7299
+ for (const [key, value] of Object.entries(env)) writer("set", key, value);
7300
+ return true;
7301
+ }
7302
+ __name(writeWindowsUserProxyEnv, "writeWindowsUserProxyEnv");
7303
+ function persistVsCodeProxyEnvironment(port) {
7304
+ writeBaseUrlToSettings(port);
7305
+ const wroteWindowsEnv = writeWindowsUserProxyEnv(port);
7306
+ return { wroteWindowsEnv };
7307
+ }
7308
+ __name(persistVsCodeProxyEnvironment, "persistVsCodeProxyEnvironment");
7338
7309
  function clearBaseUrlFromSettings() {
7339
- var _a, _b;
7310
+ var _a;
7340
7311
  const settings = claudeCodeTool.readSettings();
7341
- if ((_b = (_a = settings.env) == null ? void 0 : _a.ANTHROPIC_BASE_URL) == null ? void 0 : _b.includes("127.0.0.1")) {
7312
+ if (isLocalProxyBaseUrl((_a = settings.env) == null ? void 0 : _a.ANTHROPIC_BASE_URL)) {
7342
7313
  delete settings.env.ANTHROPIC_BASE_URL;
7314
+ if (settings.env.HOLYSHEEP_CLAUDE_LAUNCHER === "hs-claude-proxy") delete settings.env.HOLYSHEEP_CLAUDE_LAUNCHER;
7315
+ if (settings.env.HOLYSHEEP_CLAUDE_PROCESS_PROXY === "1") delete settings.env.HOLYSHEEP_CLAUDE_PROCESS_PROXY;
7343
7316
  claudeCodeTool.writeSettings(settings);
7344
7317
  }
7345
7318
  }
7346
7319
  __name(clearBaseUrlFromSettings, "clearBaseUrlFromSettings");
7320
+ function clearWindowsUserProxyEnv() {
7321
+ if (effectivePlatform() !== "win32") return false;
7322
+ const writer = getWinUserEnvWriter();
7323
+ for (const key of WINDOWS_ENV_KEYS) writer("delete", key);
7324
+ return true;
7325
+ }
7326
+ __name(clearWindowsUserProxyEnv, "clearWindowsUserProxyEnv");
7327
+ function clearVsCodeProxyEnvironment() {
7328
+ clearBaseUrlFromSettings();
7329
+ clearWindowsUserProxyEnv();
7330
+ }
7331
+ __name(clearVsCodeProxyEnvironment, "clearVsCodeProxyEnvironment");
7332
+ function isLocalProxyBaseUrl(value) {
7333
+ if (!value) return false;
7334
+ try {
7335
+ const url = new URL(String(value));
7336
+ return (url.hostname === "127.0.0.1" || url.hostname === "localhost") && (url.protocol === "http:" || url.protocol === "https:");
7337
+ } catch {
7338
+ return String(value).includes("127.0.0.1") || String(value).includes("localhost");
7339
+ }
7340
+ }
7341
+ __name(isLocalProxyBaseUrl, "isLocalProxyBaseUrl");
7347
7342
  async function handleStop() {
7348
7343
  const info = readPid();
7349
7344
  if (!info) {
@@ -7366,7 +7361,7 @@ ${logTail}` : message);
7366
7361
  } else {
7367
7362
  console.log(chalk2.gray("\u4EE3\u7406\u8FDB\u7A0B\u5DF2\u4E0D\u5B58\u5728"));
7368
7363
  }
7369
- clearBaseUrlFromSettings();
7364
+ clearVsCodeProxyEnvironment();
7370
7365
  clearPid();
7371
7366
  }
7372
7367
  __name(handleStop, "handleStop");
@@ -7389,7 +7384,7 @@ ${logTail}` : message);
7389
7384
  } else {
7390
7385
  console.log(chalk2.yellow("\u4EE3\u7406\u8FDB\u7A0B\u5DF2\u9000\u51FA"));
7391
7386
  clearPid();
7392
- clearBaseUrlFromSettings();
7387
+ clearVsCodeProxyEnvironment();
7393
7388
  }
7394
7389
  }
7395
7390
  __name(handleStatus, "handleStatus");
@@ -7399,7 +7394,9 @@ ${logTail}` : message);
7399
7394
  }
7400
7395
  const info = readPid();
7401
7396
  if (info && isProcessAlive(info.pid) && await isProxyHealthy(info.port)) {
7397
+ const persisted = persistVsCodeProxyEnvironment(info.port);
7402
7398
  console.log(chalk2.green(`\u4EE3\u7406\u5DF2\u5728\u8FD0\u884C (PID ${info.pid}, \u7AEF\u53E3 ${info.port})`));
7399
+ if (persisted.wroteWindowsEnv) console.log(chalk2.cyan("Windows \u7528\u6237\uFF1A\u8BF7\u5B8C\u5168\u9000\u51FA\u5E76\u91CD\u5F00 VS Code\uFF0C\u8BA9\u7528\u6237\u7EA7\u73AF\u5883\u53D8\u91CF\u751F\u6548"));
7403
7400
  return;
7404
7401
  }
7405
7402
  const { selfEntrypoint } = require_paths();
@@ -7437,12 +7434,14 @@ ${logTail}` : message);
7437
7434
  }
7438
7435
  const latest = await readHealthyPid({ timeoutMs: 1e3 });
7439
7436
  if (latest) {
7437
+ const persisted = persistVsCodeProxyEnvironment(latest.port);
7440
7438
  console.log(chalk2.green(`\u4EE3\u7406\u5DF2\u5728\u540E\u53F0\u542F\u52A8`));
7441
7439
  console.log(chalk2.gray(` PID: ${latest.pid}`));
7442
7440
  console.log(chalk2.gray(` \u7AEF\u53E3: ${latest.port}`));
7443
7441
  console.log(chalk2.gray(` \u5730\u5740: ${getLocalProxyUrl(latest.port)}`));
7444
7442
  console.log(chalk2.gray(` \u65E5\u5FD7: ${LOG_FILE}`));
7445
7443
  console.log(chalk2.cyan("\n VS Code Claude \u6269\u5C55\u73B0\u5728\u53EF\u4EE5\u4F7F\u7528\u4E86"));
7444
+ if (persisted.wroteWindowsEnv) console.log(chalk2.cyan(" Windows \u7528\u6237\uFF1A\u8BF7\u5B8C\u5168\u9000\u51FA\u5E76\u91CD\u5F00 VS Code\uFF0C\u8BA9\u7528\u6237\u7EA7\u73AF\u5883\u53D8\u91CF\u751F\u6548"));
7446
7445
  return;
7447
7446
  }
7448
7447
  if (child.exitCode !== null) {
@@ -7468,16 +7467,14 @@ ${logTail}` : message);
7468
7467
  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
7468
  process.exit(1);
7470
7469
  }
7471
- const ensureClaudeProxyConfig = require_claude().ensureClaudeProxyConfig || (() => {
7472
- });
7473
7470
  try {
7474
- ensureClaudeProxyConfig(apiKey);
7471
+ claudeProxy.ensureClaudeProxyConfig(apiKey);
7475
7472
  } catch {
7476
7473
  }
7477
7474
  console.log(chalk2.gray("\u542F\u52A8 Claude \u4EE3\u7406..."));
7478
7475
  const { server, port, sessionId } = await startProcessProxy({});
7479
7476
  writePid(process.pid, port, sessionId);
7480
- writeBaseUrlToSettings(port);
7477
+ persistVsCodeProxyEnvironment(port);
7481
7478
  console.log(chalk2.green(`
7482
7479
  \u2713 Claude \u4EE3\u7406\u5DF2\u542F\u52A8`));
7483
7480
  console.log(chalk2.gray(` \u7AEF\u53E3: ${port}`));
@@ -7487,7 +7484,7 @@ ${logTail}` : message);
7487
7484
  console.log(chalk2.gray(" \u6309 Ctrl+C \u505C\u6B62\n"));
7488
7485
  const cleanup = /* @__PURE__ */ __name(async () => {
7489
7486
  console.log(chalk2.gray("\n\u6B63\u5728\u505C\u6B62..."));
7490
- clearBaseUrlFromSettings();
7487
+ clearVsCodeProxyEnvironment();
7491
7488
  clearPid();
7492
7489
  server.close();
7493
7490
  await closeSession(void 0, sessionId);
@@ -7514,8 +7511,8 @@ ${logTail}` : message);
7514
7511
  const claudeCodeTool2 = require_claude_code();
7515
7512
  const proxy = require_claude_process_proxy();
7516
7513
  const config = proxy.readConfig();
7517
- if (!config.apiKey || !config.bridgeSecret) {
7518
- const bridgeConfig = claudeCodeTool2.buildBridgeConfig(apiKey, void 0, config);
7514
+ const bridgeConfig = claudeCodeTool2.buildBridgeConfig(apiKey, void 0, config);
7515
+ if (JSON.stringify(bridgeConfig) !== JSON.stringify(config)) {
7519
7516
  proxy.writeConfig(bridgeConfig);
7520
7517
  }
7521
7518
  };
@@ -7523,7 +7520,17 @@ ${logTail}` : message);
7523
7520
  probeLocalProxy,
7524
7521
  readHealthyPid,
7525
7522
  daemonLogFile: /* @__PURE__ */ __name(() => LOG_FILE, "daemonLogFile"),
7526
- daemonPidFile: /* @__PURE__ */ __name(() => PID_FILE, "daemonPidFile")
7523
+ daemonPidFile: /* @__PURE__ */ __name(() => PID_FILE, "daemonPidFile"),
7524
+ persistVsCodeProxyEnvironment,
7525
+ writeWindowsUserProxyEnv,
7526
+ clearWindowsUserProxyEnv,
7527
+ defaultWinUserEnvWriter,
7528
+ setPlatformOverride(value) {
7529
+ platformOverride = value || null;
7530
+ },
7531
+ setWinUserEnvWriterForTest(writer) {
7532
+ winUserEnvWriterOverride = writer || null;
7533
+ }
7527
7534
  };
7528
7535
  module2.exports = claudeProxy;
7529
7536
  }
@@ -10359,6 +10366,7 @@ var require_aionui_wrapper = __commonJS({
10359
10366
  }
10360
10367
  __name(_startDetachedNpmUpgrade, "_startDetachedNpmUpgrade");
10361
10368
  function _ensureClaudeProxyConfig(apiKey) {
10369
+ var _a;
10362
10370
  const config = claudeProcessProxy.readConfig();
10363
10371
  const next = claudeCodeTool.buildBridgeConfig(apiKey, BASE_URL_ANTHROPIC, {
10364
10372
  ...config,
@@ -10372,14 +10380,21 @@ var require_aionui_wrapper = __commonJS({
10372
10380
  try {
10373
10381
  const existing = claudeCodeTool.readSettings();
10374
10382
  const hasToken = existing && existing.env && existing.env.ANTHROPIC_AUTH_TOKEN === apiKey;
10375
- const hasLauncherMark = existing && existing.env && existing.env.HOLYSHEEP_CLAUDE_LAUNCHER === "hs";
10383
+ const preserveDaemonProxy = typeof ((_a = claudeCodeTool._private) == null ? void 0 : _a.shouldPreserveDaemonProxyEnv) === "function" ? claudeCodeTool._private.shouldPreserveDaemonProxyEnv(existing && existing.env || {}) : false;
10384
+ const hasLauncherMark = existing && existing.env && existing.env.HOLYSHEEP_CLAUDE_LAUNCHER === (preserveDaemonProxy ? "hs-claude-proxy" : "hs");
10376
10385
  if (!hasToken || !hasLauncherMark) {
10377
10386
  const settings = existing || {};
10378
10387
  if (!settings.env) settings.env = {};
10379
10388
  settings.env.ANTHROPIC_AUTH_TOKEN = apiKey;
10380
- delete settings.env.ANTHROPIC_BASE_URL;
10389
+ if (preserveDaemonProxy) {
10390
+ settings.env.HOLYSHEEP_CLAUDE_LAUNCHER = "hs-claude-proxy";
10391
+ settings.env.HOLYSHEEP_CLAUDE_PROCESS_PROXY = "1";
10392
+ } else {
10393
+ delete settings.env.ANTHROPIC_BASE_URL;
10394
+ settings.env.HOLYSHEEP_CLAUDE_LAUNCHER = "hs";
10395
+ delete settings.env.HOLYSHEEP_CLAUDE_PROCESS_PROXY;
10396
+ }
10381
10397
  settings.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1";
10382
- settings.env.HOLYSHEEP_CLAUDE_LAUNCHER = "hs";
10383
10398
  delete settings.env.ANTHROPIC_API_KEY;
10384
10399
  delete settings.env.HOLYSHEEP_CLAUDE_BRIDGE;
10385
10400
  claudeCodeTool.writeSettings(settings);
@@ -11017,6 +11032,146 @@ var require_webui = __commonJS({
11017
11032
  }
11018
11033
  });
11019
11034
 
11035
+ // src/commands/claude.js
11036
+ var require_claude = __commonJS({
11037
+ "src/commands/claude.js"(exports2, module2) {
11038
+ "use strict";
11039
+ var path = require("path");
11040
+ var { spawn } = require("child_process");
11041
+ var {
11042
+ BASE_URL_ANTHROPIC,
11043
+ BASE_URL_CLAUDE_RELAY,
11044
+ getApiKey
11045
+ } = require_config();
11046
+ var {
11047
+ closeSession,
11048
+ getLocalProxyUrl,
11049
+ startProcessProxy,
11050
+ readConfig,
11051
+ writeConfig
11052
+ } = require_claude_process_proxy();
11053
+ var claudeCodeTool = require_claude_code();
11054
+ var { processProxyInjectPath } = require_paths();
11055
+ var INJECT_PATH = processProxyInjectPath();
11056
+ function appendNodeRequire(existingValue, requirePath) {
11057
+ const nextFlag = `--require ${requirePath}`;
11058
+ if (!existingValue) return nextFlag;
11059
+ return existingValue.includes(nextFlag) ? existingValue : `${existingValue} ${nextFlag}`.trim();
11060
+ }
11061
+ __name(appendNodeRequire, "appendNodeRequire");
11062
+ function mergeNoProxy(existingValue, extraHosts = []) {
11063
+ const merged = /* @__PURE__ */ new Set();
11064
+ for (const chunk of String(existingValue || "").split(",")) {
11065
+ const value = chunk.trim();
11066
+ if (value) merged.add(value);
11067
+ }
11068
+ for (const host of extraHosts) {
11069
+ if (host) merged.add(host);
11070
+ }
11071
+ return Array.from(merged).join(",");
11072
+ }
11073
+ __name(mergeNoProxy, "mergeNoProxy");
11074
+ function ensureClaudeProxyConfig(apiKey) {
11075
+ const config = readConfig();
11076
+ const next = claudeCodeTool.buildBridgeConfig(apiKey, BASE_URL_ANTHROPIC, {
11077
+ ...config,
11078
+ relayUrl: config.relayUrl || BASE_URL_CLAUDE_RELAY
11079
+ });
11080
+ const changed = JSON.stringify(next) !== JSON.stringify(config);
11081
+ if (changed) {
11082
+ writeConfig(next);
11083
+ return next;
11084
+ }
11085
+ return config;
11086
+ }
11087
+ __name(ensureClaudeProxyConfig, "ensureClaudeProxyConfig");
11088
+ async function runClaude(args = []) {
11089
+ var _a, _b;
11090
+ const config = readConfig();
11091
+ const apiKey = config.apiKey || getApiKey();
11092
+ if (!apiKey) {
11093
+ throw new Error("Missing API Key. Run hs setup first.");
11094
+ }
11095
+ try {
11096
+ const { scheduleUpgradeBannerCheck } = require_version_check();
11097
+ const pkg2 = require_package();
11098
+ scheduleUpgradeBannerCheck({ localVersion: pkg2.version });
11099
+ } catch {
11100
+ }
11101
+ ensureClaudeProxyConfig(apiKey);
11102
+ const runtime = typeof claudeCodeTool.detectClaudeRuntime === "function" ? claudeCodeTool.detectClaudeRuntime() : { kind: "unknown", launchMode: "env-proxy" };
11103
+ if (runtime.kind === "missing") {
11104
+ const installCmd = process.platform === "win32" ? "irm https://claude.ai/install.ps1 | iex" : "curl -fsSL https://claude.ai/install.sh | bash";
11105
+ const err = new Error(
11106
+ `\u672A\u627E\u5230 claude \u547D\u4EE4 \u2014 Claude Code \u5C1A\u672A\u5B89\u88C5\u3002
11107
+ \u8BF7\u5148\u8FD0\u884C: ${installCmd}
11108
+ \u5B89\u88C5\u540E\u91CD\u5F00\u7EC8\u7AEF\u518D\u6267\u884C hs claude\u3002`
11109
+ );
11110
+ err.code = "CLAUDE_NOT_INSTALLED";
11111
+ err.exitCode = 127;
11112
+ throw err;
11113
+ }
11114
+ const settings = claudeCodeTool.readSettings();
11115
+ const shouldPreserveDaemonProxy = typeof ((_a = claudeCodeTool._private) == null ? void 0 : _a.shouldPreserveDaemonProxyEnv) === "function" ? claudeCodeTool._private.shouldPreserveDaemonProxyEnv(settings.env || {}) : false;
11116
+ if (((_b = settings.env) == null ? void 0 : _b.ANTHROPIC_BASE_URL) && !shouldPreserveDaemonProxy) {
11117
+ delete settings.env.ANTHROPIC_BASE_URL;
11118
+ claudeCodeTool.writeSettings(settings);
11119
+ }
11120
+ const { server, port, sessionId } = await startProcessProxy({});
11121
+ const proxyUrl = getLocalProxyUrl(port);
11122
+ const launchMode = runtime.launchMode === "node-inject" ? "local-api + connect-fallback + node-inject" : "whole-process-proxy + local-api";
11123
+ const env = {
11124
+ ...process.env,
11125
+ ANTHROPIC_API_KEY: void 0,
11126
+ ANTHROPIC_AUTH_TOKEN: apiKey,
11127
+ ANTHROPIC_BASE_URL: proxyUrl,
11128
+ CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1",
11129
+ HOLYSHEEP_CLAUDE_PROCESS_PROXY: "1",
11130
+ HOLYSHEEP_CLAUDE_SESSION_ID: sessionId,
11131
+ HS_PROXY_URL: proxyUrl,
11132
+ HOLYSHEEP_CLAUDE_RUNTIME_KIND: runtime.kind || "unknown",
11133
+ HOLYSHEEP_CLAUDE_LAUNCH_MODE: launchMode,
11134
+ HTTP_PROXY: proxyUrl,
11135
+ HTTPS_PROXY: proxyUrl,
11136
+ ALL_PROXY: proxyUrl,
11137
+ NO_PROXY: mergeNoProxy(process.env.NO_PROXY, ["127.0.0.1", "localhost"]),
11138
+ ANTHROPIC_MAX_RETRIES: "0",
11139
+ MAX_RETRIES: "0"
11140
+ };
11141
+ if (runtime.launchMode === "node-inject") {
11142
+ env.NODE_OPTIONS = appendNodeRequire(process.env.NODE_OPTIONS, INJECT_PATH);
11143
+ }
11144
+ const child = spawn("claude", args, {
11145
+ stdio: "inherit",
11146
+ env,
11147
+ shell: process.platform === "win32"
11148
+ });
11149
+ const cleanup = /* @__PURE__ */ __name(async () => {
11150
+ try {
11151
+ server.close();
11152
+ } catch {
11153
+ }
11154
+ await closeSession(void 0, sessionId);
11155
+ }, "cleanup");
11156
+ process.on("SIGINT", () => child.kill("SIGINT"));
11157
+ process.on("SIGTERM", () => child.kill("SIGTERM"));
11158
+ return await new Promise((resolve, reject) => {
11159
+ child.once("error", async (error) => {
11160
+ await cleanup();
11161
+ reject(error);
11162
+ });
11163
+ child.once("exit", async (code, signal) => {
11164
+ await cleanup();
11165
+ if (signal) process.kill(process.pid, signal);
11166
+ resolve(code || 0);
11167
+ });
11168
+ });
11169
+ }
11170
+ __name(runClaude, "runClaude");
11171
+ module2.exports = runClaude;
11172
+ }
11173
+ });
11174
+
11020
11175
  // src/index.js
11021
11176
  var { program } = require("commander");
11022
11177
  var chalk = require("chalk");
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@simonyea/holysheep-cli",
3
- "version": "2.1.65",
3
+ "version": "2.1.67",
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/claude-proxy-vscode-env.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 && node tests/claude-code-configure-preserve.test.js",
8
8
  "prepublishOnly": "npm run build && npm test && node scripts/check-tarball-size.js"
9
9
  },
10
10
  "keywords": [