@simonyea/holysheep-cli 2.1.45 → 2.1.47

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.
@@ -292,6 +292,15 @@ var require_claude_process_proxy = __commonJS({
292
292
  host: target.host,
293
293
  connection: "close"
294
294
  };
295
+ if (process.env.HS_CLAUDE_DEBUG_HEADERS === "1") {
296
+ console.error(
297
+ `[DEBUG-HDRS forwardDirectHttps] ${JSON.stringify({
298
+ target: String(target),
299
+ ALL_outbound_headers: headers,
300
+ clientReqHeaders: clientReq.headers
301
+ })}`
302
+ );
303
+ }
295
304
  const upReq = https2.request({
296
305
  hostname: target.hostname,
297
306
  port: target.port || 443,
@@ -427,6 +436,16 @@ var require_claude_process_proxy = __commonJS({
427
436
  })}`
428
437
  );
429
438
  }
439
+ if (process.env.HS_CLAUDE_DEBUG_HEADERS === "1") {
440
+ console.error(
441
+ `[DEBUG-HDRS forwardViaNodeProxy] ${JSON.stringify({
442
+ target: String(targetUrl),
443
+ node: String(nodeProxyUrl),
444
+ ALL_outbound_headers: finalHeaders,
445
+ clientReqHeaders: clientReq.headers
446
+ })}`
447
+ );
448
+ }
430
449
  forwardReq = http.request({
431
450
  host: upstream.hostname,
432
451
  port: Number(upstream.port || 80),
@@ -3974,11 +3993,11 @@ var require_package = __commonJS({
3974
3993
  "package.json"(exports2, module2) {
3975
3994
  module2.exports = {
3976
3995
  name: "@simonyea/holysheep-cli",
3977
- version: "2.1.45",
3996
+ version: "2.1.47",
3978
3997
  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.",
3979
3998
  scripts: {
3980
3999
  build: "node scripts/build.mjs",
3981
- 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/opencode-default-model.test.js && node tests/paths-bundled.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",
4000
+ 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/opencode-default-model.test.js && node tests/paths-bundled.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",
3982
4001
  prepublishOnly: "npm run build && npm test && node scripts/check-tarball-size.js"
3983
4002
  },
3984
4003
  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.45",
15
+ version: "2.1.47",
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/opencode-default-model.test.js && node tests/paths-bundled.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",
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/opencode-default-model.test.js && node tests/paths-bundled.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",
20
20
  prepublishOnly: "npm run build && npm test && node scripts/check-tarball-size.js"
21
21
  },
22
22
  keywords: [
@@ -968,6 +968,15 @@ var require_claude_process_proxy = __commonJS({
968
968
  host: target.host,
969
969
  connection: "close"
970
970
  };
971
+ if (process.env.HS_CLAUDE_DEBUG_HEADERS === "1") {
972
+ console.error(
973
+ `[DEBUG-HDRS forwardDirectHttps] ${JSON.stringify({
974
+ target: String(target),
975
+ ALL_outbound_headers: headers,
976
+ clientReqHeaders: clientReq.headers
977
+ })}`
978
+ );
979
+ }
971
980
  const upReq = https2.request({
972
981
  hostname: target.hostname,
973
982
  port: target.port || 443,
@@ -1103,6 +1112,16 @@ var require_claude_process_proxy = __commonJS({
1103
1112
  })}`
1104
1113
  );
1105
1114
  }
1115
+ if (process.env.HS_CLAUDE_DEBUG_HEADERS === "1") {
1116
+ console.error(
1117
+ `[DEBUG-HDRS forwardViaNodeProxy] ${JSON.stringify({
1118
+ target: String(targetUrl),
1119
+ node: String(nodeProxyUrl),
1120
+ ALL_outbound_headers: finalHeaders,
1121
+ clientReqHeaders: clientReq.headers
1122
+ })}`
1123
+ );
1124
+ }
1106
1125
  forwardReq = http.request({
1107
1126
  host: upstream.hostname,
1108
1127
  port: Number(upstream.port || 80),
@@ -5871,9 +5890,9 @@ var require_aionui_runtime_fetcher = __commonJS({
5871
5890
  var http = require("http");
5872
5891
  var USER_CACHE_DIR = path.join(os.homedir(), ".holysheep", "aionui-runtime");
5873
5892
  var VENDOR_DIR = path.join(__dirname, "vendor", "aionui");
5874
- var DEFAULT_RUNTIME_URL = "https://mail.holysheep.ai/app/cli/aionui-runtime-v1.9.18-holysheep-hs32.tar.gz";
5875
- var DEFAULT_RUNTIME_SHA256 = "7efafb298109f75a7e804fa1425a52cabe0d46ee39760fc54be14e80938f27c2";
5876
- var DEFAULT_RUNTIME_VERSION = "1.9.18-holysheep-hs32";
5893
+ var DEFAULT_RUNTIME_URL = "https://mail.holysheep.ai/app/cli/aionui-runtime-v1.9.18-holysheep-hs34.tar.gz";
5894
+ var DEFAULT_RUNTIME_SHA256 = "5f656f6c049c935a26b76a70539147e7af17325817fe539a65ca46315590ecb1";
5895
+ var DEFAULT_RUNTIME_VERSION = "1.9.18-holysheep-hs34";
5877
5896
  function isValidRuntimeDir(dir) {
5878
5897
  if (!dir) return false;
5879
5898
  try {
@@ -6162,6 +6181,71 @@ This runtime cannot launch the WebUI. Check HOLYSHEEP_AIONUI_RUNTIME_URL or repo
6162
6181
  }
6163
6182
  });
6164
6183
 
6184
+ // src/tools/gemini-cli.js
6185
+ var require_gemini_cli = __commonJS({
6186
+ "src/tools/gemini-cli.js"(exports2, module2) {
6187
+ var fs = require("fs");
6188
+ var path = require("path");
6189
+ var os = require("os");
6190
+ var GEMINI_DIR = path.join(os.homedir(), ".gemini");
6191
+ var SETTINGS_FILE = path.join(GEMINI_DIR, "settings.json");
6192
+ function readSettings() {
6193
+ try {
6194
+ if (fs.existsSync(SETTINGS_FILE)) {
6195
+ return JSON.parse(fs.readFileSync(SETTINGS_FILE, "utf8"));
6196
+ }
6197
+ } catch {
6198
+ }
6199
+ return {};
6200
+ }
6201
+ __name(readSettings, "readSettings");
6202
+ function writeSettings(data) {
6203
+ if (!fs.existsSync(GEMINI_DIR)) fs.mkdirSync(GEMINI_DIR, { recursive: true });
6204
+ fs.writeFileSync(SETTINGS_FILE, JSON.stringify(data, null, 2), "utf8");
6205
+ }
6206
+ __name(writeSettings, "writeSettings");
6207
+ module2.exports = {
6208
+ name: "Gemini CLI",
6209
+ id: "gemini-cli",
6210
+ checkInstalled() {
6211
+ return require_which().commandExists("gemini");
6212
+ },
6213
+ isConfigured() {
6214
+ if (process.env.GEMINI_API_KEY) return true;
6215
+ const s = readSettings();
6216
+ return s.selectedAuthType === "gemini-api-key";
6217
+ },
6218
+ configure(apiKey, _baseUrlAnthropicNoV1, _baseUrlOpenAI) {
6219
+ const settings = readSettings();
6220
+ settings.selectedAuthType = "gemini-api-key";
6221
+ writeSettings(settings);
6222
+ return {
6223
+ file: SETTINGS_FILE,
6224
+ hot: false,
6225
+ // 不注入 GEMINI_API_KEY,因为 HolySheep key 对 Gemini CLI 无效
6226
+ // 用户需要手动设置真正的 Gemini API Key
6227
+ envVars: {},
6228
+ warning: 'Gemini CLI \u9700\u8981 Google \u5B98\u65B9 Gemini API Key\uFF0C\u65E0\u6CD5\u4F7F\u7528 HolySheep \u4E2D\u7EE7\u3002\n\u8BF7\u4ECE https://aistudio.google.com/apikey \u83B7\u53D6 API Key \u540E\u8BBE\u7F6E\u73AF\u5883\u53D8\u91CF\uFF1A\n export GEMINI_API_KEY="your-google-api-key"'
6229
+ };
6230
+ },
6231
+ reset() {
6232
+ const settings = readSettings();
6233
+ delete settings.selectedAuthType;
6234
+ writeSettings(settings);
6235
+ },
6236
+ getConfigPath() {
6237
+ return SETTINGS_FILE;
6238
+ },
6239
+ hint: "Gemini CLI \u4E0D\u652F\u6301 HolySheep \u4E2D\u7EE7\uFF0C\u9700\u4F7F\u7528 Google \u5B98\u65B9 Gemini API Key",
6240
+ installCmd: "npm install -g @google/gemini-cli",
6241
+ docsUrl: "https://github.com/google-gemini/gemini-cli",
6242
+ envVarFormat: "gemini",
6243
+ unsupported: true
6244
+ // 标记为不支持中继
6245
+ };
6246
+ }
6247
+ });
6248
+
6165
6249
  // src/webui/workspace-store.js
6166
6250
  var require_workspace_store = __commonJS({
6167
6251
  "src/webui/workspace-store.js"(exports2, module2) {
@@ -8579,6 +8663,10 @@ var require_aionui_wrapper = __commonJS({
8579
8663
  } = require_config();
8580
8664
  var claudeProcessProxy = require_claude_process_proxy();
8581
8665
  var claudeCodeTool = require_claude_code();
8666
+ var geminiTool = require_gemini_cli();
8667
+ var codexTool = require_codex();
8668
+ var droidTool = require_droid();
8669
+ var hermesTool = require_hermes();
8582
8670
  var BRIDGE_DIR = path.join(os.homedir(), ".holysheep");
8583
8671
  var BRIDGE_CRED_FILE = path.join(BRIDGE_DIR, "aionui-bridge.json");
8584
8672
  var TOKEN_TTL_MS = 3e4;
@@ -9097,6 +9185,75 @@ var require_aionui_wrapper = __commonJS({
9097
9185
  });
9098
9186
  }
9099
9187
  __name(probeLocalPort, "probeLocalPort");
9188
+ function _ensureAllClisConfigured(apiKey) {
9189
+ if (!apiKey) {
9190
+ log("skipping auto-config for all CLI tools: no HolySheep apiKey available");
9191
+ return;
9192
+ }
9193
+ const summary = { configured: [], skipped: [], failed: [] };
9194
+ try {
9195
+ _ensureClaudeProxyConfig(apiKey);
9196
+ summary.configured.push("claude-code");
9197
+ } catch (e) {
9198
+ summary.failed.push({ tool: "claude-code", error: e && e.message ? e.message : String(e) });
9199
+ log("warn: auto-config claude-code failed: " + (e && e.message ? e.message : e));
9200
+ }
9201
+ const siblings = [
9202
+ {
9203
+ id: "codex",
9204
+ tool: codexTool,
9205
+ settingsHint: "~/.codex/config.toml + auth.json",
9206
+ configureArgs: [apiKey, BASE_URL_ANTHROPIC, BASE_URL_OPENAI]
9207
+ },
9208
+ {
9209
+ id: "droid",
9210
+ tool: droidTool,
9211
+ settingsHint: "~/.factory/settings.json",
9212
+ configureArgs: [apiKey, BASE_URL_ANTHROPIC, BASE_URL_OPENAI]
9213
+ },
9214
+ {
9215
+ id: "hermes",
9216
+ tool: hermesTool,
9217
+ settingsHint: "~/.hermes/config.{toml,yaml}",
9218
+ configureArgs: [apiKey, BASE_URL_ANTHROPIC, BASE_URL_OPENAI]
9219
+ },
9220
+ {
9221
+ id: "gemini-cli",
9222
+ tool: geminiTool,
9223
+ settingsHint: "~/.gemini/settings.json (selectedAuthType only \u2014 HolySheep key does not proxy Gemini)",
9224
+ configureArgs: [apiKey, BASE_URL_ANTHROPIC, BASE_URL_OPENAI]
9225
+ }
9226
+ ];
9227
+ for (const s of siblings) {
9228
+ try {
9229
+ let already = false;
9230
+ try {
9231
+ already = typeof s.tool.isConfigured === "function" ? Boolean(s.tool.isConfigured()) : false;
9232
+ } catch {
9233
+ already = false;
9234
+ }
9235
+ if (already) {
9236
+ summary.skipped.push(s.id);
9237
+ log(`${s.id} already configured (${s.settingsHint}) \u2014 skipping auto-config`);
9238
+ continue;
9239
+ }
9240
+ if (typeof s.tool.configure !== "function") {
9241
+ summary.skipped.push(s.id);
9242
+ log(`${s.id} has no configure() entry (env-only) \u2014 skipped`);
9243
+ continue;
9244
+ }
9245
+ s.tool.configure.apply(s.tool, s.configureArgs);
9246
+ summary.configured.push(s.id);
9247
+ log(`auto-configured ${s.id} settings (${s.settingsHint}) \u2014 first-ever hs web for this user`);
9248
+ } catch (err) {
9249
+ summary.failed.push({ tool: s.id, error: err && err.message ? err.message : String(err) });
9250
+ log(`warn: auto-config ${s.id} failed: ${err && err.message ? err.message : err}`);
9251
+ }
9252
+ }
9253
+ log(`CLI auto-config summary: configured=[${summary.configured.join(",")}] skipped=[${summary.skipped.join(",")}] failed=[${summary.failed.map((f) => f.tool).join(",")}]`);
9254
+ return summary;
9255
+ }
9256
+ __name(_ensureAllClisConfigured, "_ensureAllClisConfigured");
9100
9257
  function _ensureClaudeProxyConfig(apiKey) {
9101
9258
  const config = claudeProcessProxy.readConfig();
9102
9259
  const next = claudeCodeTool.buildBridgeConfig(apiKey, BASE_URL_ANTHROPIC, {
@@ -9170,6 +9327,19 @@ var require_aionui_wrapper = __commonJS({
9170
9327
  }
9171
9328
  const internalPort = await pickInternalPort();
9172
9329
  log(`internal runtime port: ${internalPort}`);
9330
+ try {
9331
+ const __apiKeyForAutoConfig = (() => {
9332
+ try {
9333
+ return getApiKey();
9334
+ } catch {
9335
+ return null;
9336
+ }
9337
+ })();
9338
+ if (__apiKeyForAutoConfig) _ensureAllClisConfigured(__apiKeyForAutoConfig);
9339
+ else log("CLI auto-config skipped: no HolySheep apiKey (run `hs login`)");
9340
+ } catch (e) {
9341
+ log("warn: CLI auto-config error (continuing): " + (e && e.message ? e.message : e));
9342
+ }
9173
9343
  const claudeProxyHandle = await ensureClaudeProcessProxyRunning();
9174
9344
  const debug = process.env.HS_WEB_DEBUG === "1";
9175
9345
  const { PACKAGE_ROOT, cliVersion, ptyHermesWrapperPath } = require_paths();
@@ -9185,6 +9355,28 @@ var require_aionui_wrapper = __commonJS({
9185
9355
  }
9186
9356
  const sanitizedParentEnv = { ...process.env };
9187
9357
  delete sanitizedParentEnv.HOLYSHEEP_API_KEY;
9358
+ delete sanitizedParentEnv.HOLYSHEEP_CLAUDE_PROXY_PORT;
9359
+ let signalledProxyPort = "";
9360
+ try {
9361
+ if (claudeProxyHandle && !claudeProxyHandle.skipped) {
9362
+ if (claudeProxyHandle.reused && claudeProxyHandle.port) {
9363
+ signalledProxyPort = String(claudeProxyHandle.port);
9364
+ } else if (!claudeProxyHandle.reused && claudeProxyHandle.server) {
9365
+ const addr = claudeProxyHandle.server.address && claudeProxyHandle.server.address();
9366
+ if (addr && typeof addr === "object" && addr.port) {
9367
+ signalledProxyPort = String(addr.port);
9368
+ }
9369
+ }
9370
+ }
9371
+ if (!signalledProxyPort) {
9372
+ const cfg = claudeProcessProxy.readConfig();
9373
+ if (cfg && cfg.processProxyPort) signalledProxyPort = String(cfg.processProxyPort);
9374
+ }
9375
+ } catch {
9376
+ }
9377
+ if (signalledProxyPort) {
9378
+ log(`exporting HOLYSHEEP_CLAUDE_PROXY_PORT=${signalledProxyPort} to aionui (authoritative proxy port \u2014 fork will skip HTTP probe)`);
9379
+ }
9188
9380
  const aionui = spawn(bunPath, ["dist-server/server.mjs"], {
9189
9381
  cwd: runtimeDir,
9190
9382
  env: {
@@ -9196,7 +9388,8 @@ var require_aionui_wrapper = __commonJS({
9196
9388
  HOLYSHEEP_CLI_ROOT: cliRoot,
9197
9389
  HOLYSHEEP_CLI_VERSION: wrapperVersion,
9198
9390
  HOLYSHEEP_CONFIG_PATH: credPath,
9199
- HOLYSHEEP_PTY_HERMES_WRAPPER: ptyWrapperAbs
9391
+ HOLYSHEEP_PTY_HERMES_WRAPPER: ptyWrapperAbs,
9392
+ ...signalledProxyPort ? { HOLYSHEEP_CLAUDE_PROXY_PORT: signalledProxyPort } : {}
9200
9393
  },
9201
9394
  stdio: ["ignore", "pipe", "pipe"]
9202
9395
  });
@@ -9286,6 +9479,7 @@ ${tail.split(/\r?\n/).map((ln) => ` ${ln}`).join("\n")}
9286
9479
  __name(startWrapper, "startWrapper");
9287
9480
  module2.exports = {
9288
9481
  startWrapper,
9482
+ _ensureAllClisConfigured,
9289
9483
  // Exported for tests / inspection
9290
9484
  isLoopbackRequest,
9291
9485
  pruneExpiredTokens,
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@simonyea/holysheep-cli",
3
- "version": "2.1.45",
3
+ "version": "2.1.47",
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/opencode-default-model.test.js && node tests/paths-bundled.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",
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/opencode-default-model.test.js && node tests/paths-bundled.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",
8
8
  "prepublishOnly": "npm run build && npm test && node scripts/check-tarball-size.js"
9
9
  },
10
10
  "keywords": [