@simonyea/holysheep-cli 2.1.66 → 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.66",
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/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",
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.66",
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/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",
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
  });
@@ -7092,6 +7128,18 @@ var require_claude_proxy = __commonJS({
7092
7128
  var DAEMON_READY_TIMEOUT_MS = Number(process.env.HS_CLAUDE_PROXY_DAEMON_READY_TIMEOUT_MS) || 12e3;
7093
7129
  var DAEMON_READY_INTERVAL_MS = Number(process.env.HS_CLAUDE_PROXY_DAEMON_READY_INTERVAL_MS) || 400;
7094
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");
7095
7143
  function readPid() {
7096
7144
  try {
7097
7145
  const content = fs.readFileSync(PID_FILE, "utf8").trim();
@@ -7189,13 +7237,17 @@ ${logTail}` : message);
7189
7237
  return err;
7190
7238
  }
7191
7239
  __name(makeDaemonError, "makeDaemonError");
7240
+ function getHolySheepApiKey() {
7241
+ const config = readConfig();
7242
+ return config.apiKey || getApiKey();
7243
+ }
7244
+ __name(getHolySheepApiKey, "getHolySheepApiKey");
7192
7245
  function writeBaseUrlToSettings(port) {
7193
7246
  const settings = claudeCodeTool.readSettings();
7194
7247
  if (!settings.env) settings.env = {};
7195
7248
  settings.env.ANTHROPIC_BASE_URL = getLocalProxyUrl(port);
7196
7249
  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();
7250
+ const apiKey = getHolySheepApiKey();
7199
7251
  if (apiKey) settings.env.ANTHROPIC_AUTH_TOKEN = apiKey;
7200
7252
  }
7201
7253
  settings.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1";
@@ -7204,15 +7256,79 @@ ${logTail}` : message);
7204
7256
  claudeCodeTool.writeSettings(settings);
7205
7257
  }
7206
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");
7207
7309
  function clearBaseUrlFromSettings() {
7208
7310
  var _a;
7209
7311
  const settings = claudeCodeTool.readSettings();
7210
7312
  if (isLocalProxyBaseUrl((_a = settings.env) == null ? void 0 : _a.ANTHROPIC_BASE_URL)) {
7211
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;
7212
7316
  claudeCodeTool.writeSettings(settings);
7213
7317
  }
7214
7318
  }
7215
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");
7216
7332
  function isLocalProxyBaseUrl(value) {
7217
7333
  if (!value) return false;
7218
7334
  try {
@@ -7245,7 +7361,7 @@ ${logTail}` : message);
7245
7361
  } else {
7246
7362
  console.log(chalk2.gray("\u4EE3\u7406\u8FDB\u7A0B\u5DF2\u4E0D\u5B58\u5728"));
7247
7363
  }
7248
- clearBaseUrlFromSettings();
7364
+ clearVsCodeProxyEnvironment();
7249
7365
  clearPid();
7250
7366
  }
7251
7367
  __name(handleStop, "handleStop");
@@ -7268,7 +7384,7 @@ ${logTail}` : message);
7268
7384
  } else {
7269
7385
  console.log(chalk2.yellow("\u4EE3\u7406\u8FDB\u7A0B\u5DF2\u9000\u51FA"));
7270
7386
  clearPid();
7271
- clearBaseUrlFromSettings();
7387
+ clearVsCodeProxyEnvironment();
7272
7388
  }
7273
7389
  }
7274
7390
  __name(handleStatus, "handleStatus");
@@ -7278,8 +7394,9 @@ ${logTail}` : message);
7278
7394
  }
7279
7395
  const info = readPid();
7280
7396
  if (info && isProcessAlive(info.pid) && await isProxyHealthy(info.port)) {
7281
- writeBaseUrlToSettings(info.port);
7397
+ const persisted = persistVsCodeProxyEnvironment(info.port);
7282
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"));
7283
7400
  return;
7284
7401
  }
7285
7402
  const { selfEntrypoint } = require_paths();
@@ -7317,13 +7434,14 @@ ${logTail}` : message);
7317
7434
  }
7318
7435
  const latest = await readHealthyPid({ timeoutMs: 1e3 });
7319
7436
  if (latest) {
7320
- writeBaseUrlToSettings(latest.port);
7437
+ const persisted = persistVsCodeProxyEnvironment(latest.port);
7321
7438
  console.log(chalk2.green(`\u4EE3\u7406\u5DF2\u5728\u540E\u53F0\u542F\u52A8`));
7322
7439
  console.log(chalk2.gray(` PID: ${latest.pid}`));
7323
7440
  console.log(chalk2.gray(` \u7AEF\u53E3: ${latest.port}`));
7324
7441
  console.log(chalk2.gray(` \u5730\u5740: ${getLocalProxyUrl(latest.port)}`));
7325
7442
  console.log(chalk2.gray(` \u65E5\u5FD7: ${LOG_FILE}`));
7326
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"));
7327
7445
  return;
7328
7446
  }
7329
7447
  if (child.exitCode !== null) {
@@ -7356,7 +7474,7 @@ ${logTail}` : message);
7356
7474
  console.log(chalk2.gray("\u542F\u52A8 Claude \u4EE3\u7406..."));
7357
7475
  const { server, port, sessionId } = await startProcessProxy({});
7358
7476
  writePid(process.pid, port, sessionId);
7359
- writeBaseUrlToSettings(port);
7477
+ persistVsCodeProxyEnvironment(port);
7360
7478
  console.log(chalk2.green(`
7361
7479
  \u2713 Claude \u4EE3\u7406\u5DF2\u542F\u52A8`));
7362
7480
  console.log(chalk2.gray(` \u7AEF\u53E3: ${port}`));
@@ -7366,7 +7484,7 @@ ${logTail}` : message);
7366
7484
  console.log(chalk2.gray(" \u6309 Ctrl+C \u505C\u6B62\n"));
7367
7485
  const cleanup = /* @__PURE__ */ __name(async () => {
7368
7486
  console.log(chalk2.gray("\n\u6B63\u5728\u505C\u6B62..."));
7369
- clearBaseUrlFromSettings();
7487
+ clearVsCodeProxyEnvironment();
7370
7488
  clearPid();
7371
7489
  server.close();
7372
7490
  await closeSession(void 0, sessionId);
@@ -7402,7 +7520,17 @@ ${logTail}` : message);
7402
7520
  probeLocalProxy,
7403
7521
  readHealthyPid,
7404
7522
  daemonLogFile: /* @__PURE__ */ __name(() => LOG_FILE, "daemonLogFile"),
7405
- 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
+ }
7406
7534
  };
7407
7535
  module2.exports = claudeProxy;
7408
7536
  }
@@ -10238,6 +10366,7 @@ var require_aionui_wrapper = __commonJS({
10238
10366
  }
10239
10367
  __name(_startDetachedNpmUpgrade, "_startDetachedNpmUpgrade");
10240
10368
  function _ensureClaudeProxyConfig(apiKey) {
10369
+ var _a;
10241
10370
  const config = claudeProcessProxy.readConfig();
10242
10371
  const next = claudeCodeTool.buildBridgeConfig(apiKey, BASE_URL_ANTHROPIC, {
10243
10372
  ...config,
@@ -10251,14 +10380,21 @@ var require_aionui_wrapper = __commonJS({
10251
10380
  try {
10252
10381
  const existing = claudeCodeTool.readSettings();
10253
10382
  const hasToken = existing && existing.env && existing.env.ANTHROPIC_AUTH_TOKEN === apiKey;
10254
- 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");
10255
10385
  if (!hasToken || !hasLauncherMark) {
10256
10386
  const settings = existing || {};
10257
10387
  if (!settings.env) settings.env = {};
10258
10388
  settings.env.ANTHROPIC_AUTH_TOKEN = apiKey;
10259
- 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
+ }
10260
10397
  settings.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1";
10261
- settings.env.HOLYSHEEP_CLAUDE_LAUNCHER = "hs";
10262
10398
  delete settings.env.ANTHROPIC_API_KEY;
10263
10399
  delete settings.env.HOLYSHEEP_CLAUDE_BRIDGE;
10264
10400
  claudeCodeTool.writeSettings(settings);
@@ -10950,7 +11086,7 @@ var require_claude = __commonJS({
10950
11086
  }
10951
11087
  __name(ensureClaudeProxyConfig, "ensureClaudeProxyConfig");
10952
11088
  async function runClaude(args = []) {
10953
- var _a;
11089
+ var _a, _b;
10954
11090
  const config = readConfig();
10955
11091
  const apiKey = config.apiKey || getApiKey();
10956
11092
  if (!apiKey) {
@@ -10976,7 +11112,8 @@ var require_claude = __commonJS({
10976
11112
  throw err;
10977
11113
  }
10978
11114
  const settings = claudeCodeTool.readSettings();
10979
- if ((_a = settings.env) == null ? void 0 : _a.ANTHROPIC_BASE_URL) {
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) {
10980
11117
  delete settings.env.ANTHROPIC_BASE_URL;
10981
11118
  claudeCodeTool.writeSettings(settings);
10982
11119
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@simonyea/holysheep-cli",
3
- "version": "2.1.66",
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/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",
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": [