@simonyea/holysheep-cli 2.1.44 → 2.1.46

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.
@@ -595,7 +595,9 @@ var require_claude_process_proxy = __commonJS({
595
595
  clientRes.writeHead(200, {
596
596
  "content-type": "application/json",
597
597
  [LOCAL_PING_HEADER]: LOCAL_PING_HEADER_VALUE,
598
- "cache-control": "no-store"
598
+ "cache-control": "no-store",
599
+ "content-length": String(Buffer.byteLength(body)),
600
+ "connection": "close"
599
601
  });
600
602
  clientRes.end(body);
601
603
  return;
@@ -3972,11 +3974,11 @@ var require_package = __commonJS({
3972
3974
  "package.json"(exports2, module2) {
3973
3975
  module2.exports = {
3974
3976
  name: "@simonyea/holysheep-cli",
3975
- version: "2.1.44",
3977
+ version: "2.1.46",
3976
3978
  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.",
3977
3979
  scripts: {
3978
3980
  build: "node scripts/build.mjs",
3979
- 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",
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 && node tests/aionui-wrapper-all-clis-autoconf.test.js",
3980
3982
  prepublishOnly: "npm run build && npm test && node scripts/check-tarball-size.js"
3981
3983
  },
3982
3984
  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.44",
15
+ version: "2.1.46",
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",
20
20
  prepublishOnly: "npm run build && npm test && node scripts/check-tarball-size.js"
21
21
  },
22
22
  keywords: [
@@ -1271,7 +1271,9 @@ var require_claude_process_proxy = __commonJS({
1271
1271
  clientRes.writeHead(200, {
1272
1272
  "content-type": "application/json",
1273
1273
  [LOCAL_PING_HEADER]: LOCAL_PING_HEADER_VALUE,
1274
- "cache-control": "no-store"
1274
+ "cache-control": "no-store",
1275
+ "content-length": String(Buffer.byteLength(body)),
1276
+ "connection": "close"
1275
1277
  });
1276
1278
  clientRes.end(body);
1277
1279
  return;
@@ -5869,9 +5871,9 @@ var require_aionui_runtime_fetcher = __commonJS({
5869
5871
  var http = require("http");
5870
5872
  var USER_CACHE_DIR = path.join(os.homedir(), ".holysheep", "aionui-runtime");
5871
5873
  var VENDOR_DIR = path.join(__dirname, "vendor", "aionui");
5872
- var DEFAULT_RUNTIME_URL = "https://mail.holysheep.ai/app/cli/aionui-runtime-v1.9.18-holysheep-hs28.tar.gz";
5873
- var DEFAULT_RUNTIME_SHA256 = "360568732da1b758fc8d1a32202d69fe03e9ac4dd8da3e3f92e8d0ec303ee8a4";
5874
- var DEFAULT_RUNTIME_VERSION = "1.9.18-holysheep-hs28";
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";
5875
5877
  function isValidRuntimeDir(dir) {
5876
5878
  if (!dir) return false;
5877
5879
  try {
@@ -6160,6 +6162,71 @@ This runtime cannot launch the WebUI. Check HOLYSHEEP_AIONUI_RUNTIME_URL or repo
6160
6162
  }
6161
6163
  });
6162
6164
 
6165
+ // src/tools/gemini-cli.js
6166
+ var require_gemini_cli = __commonJS({
6167
+ "src/tools/gemini-cli.js"(exports2, module2) {
6168
+ var fs = require("fs");
6169
+ var path = require("path");
6170
+ var os = require("os");
6171
+ var GEMINI_DIR = path.join(os.homedir(), ".gemini");
6172
+ var SETTINGS_FILE = path.join(GEMINI_DIR, "settings.json");
6173
+ function readSettings() {
6174
+ try {
6175
+ if (fs.existsSync(SETTINGS_FILE)) {
6176
+ return JSON.parse(fs.readFileSync(SETTINGS_FILE, "utf8"));
6177
+ }
6178
+ } catch {
6179
+ }
6180
+ return {};
6181
+ }
6182
+ __name(readSettings, "readSettings");
6183
+ function writeSettings(data) {
6184
+ if (!fs.existsSync(GEMINI_DIR)) fs.mkdirSync(GEMINI_DIR, { recursive: true });
6185
+ fs.writeFileSync(SETTINGS_FILE, JSON.stringify(data, null, 2), "utf8");
6186
+ }
6187
+ __name(writeSettings, "writeSettings");
6188
+ module2.exports = {
6189
+ name: "Gemini CLI",
6190
+ id: "gemini-cli",
6191
+ checkInstalled() {
6192
+ return require_which().commandExists("gemini");
6193
+ },
6194
+ isConfigured() {
6195
+ if (process.env.GEMINI_API_KEY) return true;
6196
+ const s = readSettings();
6197
+ return s.selectedAuthType === "gemini-api-key";
6198
+ },
6199
+ configure(apiKey, _baseUrlAnthropicNoV1, _baseUrlOpenAI) {
6200
+ const settings = readSettings();
6201
+ settings.selectedAuthType = "gemini-api-key";
6202
+ writeSettings(settings);
6203
+ return {
6204
+ file: SETTINGS_FILE,
6205
+ hot: false,
6206
+ // 不注入 GEMINI_API_KEY,因为 HolySheep key 对 Gemini CLI 无效
6207
+ // 用户需要手动设置真正的 Gemini API Key
6208
+ envVars: {},
6209
+ 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"'
6210
+ };
6211
+ },
6212
+ reset() {
6213
+ const settings = readSettings();
6214
+ delete settings.selectedAuthType;
6215
+ writeSettings(settings);
6216
+ },
6217
+ getConfigPath() {
6218
+ return SETTINGS_FILE;
6219
+ },
6220
+ hint: "Gemini CLI \u4E0D\u652F\u6301 HolySheep \u4E2D\u7EE7\uFF0C\u9700\u4F7F\u7528 Google \u5B98\u65B9 Gemini API Key",
6221
+ installCmd: "npm install -g @google/gemini-cli",
6222
+ docsUrl: "https://github.com/google-gemini/gemini-cli",
6223
+ envVarFormat: "gemini",
6224
+ unsupported: true
6225
+ // 标记为不支持中继
6226
+ };
6227
+ }
6228
+ });
6229
+
6163
6230
  // src/webui/workspace-store.js
6164
6231
  var require_workspace_store = __commonJS({
6165
6232
  "src/webui/workspace-store.js"(exports2, module2) {
@@ -8577,6 +8644,10 @@ var require_aionui_wrapper = __commonJS({
8577
8644
  } = require_config();
8578
8645
  var claudeProcessProxy = require_claude_process_proxy();
8579
8646
  var claudeCodeTool = require_claude_code();
8647
+ var geminiTool = require_gemini_cli();
8648
+ var codexTool = require_codex();
8649
+ var droidTool = require_droid();
8650
+ var hermesTool = require_hermes();
8580
8651
  var BRIDGE_DIR = path.join(os.homedir(), ".holysheep");
8581
8652
  var BRIDGE_CRED_FILE = path.join(BRIDGE_DIR, "aionui-bridge.json");
8582
8653
  var TOKEN_TTL_MS = 3e4;
@@ -9095,17 +9166,106 @@ var require_aionui_wrapper = __commonJS({
9095
9166
  });
9096
9167
  }
9097
9168
  __name(probeLocalPort, "probeLocalPort");
9169
+ function _ensureAllClisConfigured(apiKey) {
9170
+ if (!apiKey) {
9171
+ log("skipping auto-config for all CLI tools: no HolySheep apiKey available");
9172
+ return;
9173
+ }
9174
+ const summary = { configured: [], skipped: [], failed: [] };
9175
+ try {
9176
+ _ensureClaudeProxyConfig(apiKey);
9177
+ summary.configured.push("claude-code");
9178
+ } catch (e) {
9179
+ summary.failed.push({ tool: "claude-code", error: e && e.message ? e.message : String(e) });
9180
+ log("warn: auto-config claude-code failed: " + (e && e.message ? e.message : e));
9181
+ }
9182
+ const siblings = [
9183
+ {
9184
+ id: "codex",
9185
+ tool: codexTool,
9186
+ settingsHint: "~/.codex/config.toml + auth.json",
9187
+ configureArgs: [apiKey, BASE_URL_ANTHROPIC, BASE_URL_OPENAI]
9188
+ },
9189
+ {
9190
+ id: "droid",
9191
+ tool: droidTool,
9192
+ settingsHint: "~/.factory/settings.json",
9193
+ configureArgs: [apiKey, BASE_URL_ANTHROPIC, BASE_URL_OPENAI]
9194
+ },
9195
+ {
9196
+ id: "hermes",
9197
+ tool: hermesTool,
9198
+ settingsHint: "~/.hermes/config.{toml,yaml}",
9199
+ configureArgs: [apiKey, BASE_URL_ANTHROPIC, BASE_URL_OPENAI]
9200
+ },
9201
+ {
9202
+ id: "gemini-cli",
9203
+ tool: geminiTool,
9204
+ settingsHint: "~/.gemini/settings.json (selectedAuthType only \u2014 HolySheep key does not proxy Gemini)",
9205
+ configureArgs: [apiKey, BASE_URL_ANTHROPIC, BASE_URL_OPENAI]
9206
+ }
9207
+ ];
9208
+ for (const s of siblings) {
9209
+ try {
9210
+ let already = false;
9211
+ try {
9212
+ already = typeof s.tool.isConfigured === "function" ? Boolean(s.tool.isConfigured()) : false;
9213
+ } catch {
9214
+ already = false;
9215
+ }
9216
+ if (already) {
9217
+ summary.skipped.push(s.id);
9218
+ log(`${s.id} already configured (${s.settingsHint}) \u2014 skipping auto-config`);
9219
+ continue;
9220
+ }
9221
+ if (typeof s.tool.configure !== "function") {
9222
+ summary.skipped.push(s.id);
9223
+ log(`${s.id} has no configure() entry (env-only) \u2014 skipped`);
9224
+ continue;
9225
+ }
9226
+ s.tool.configure.apply(s.tool, s.configureArgs);
9227
+ summary.configured.push(s.id);
9228
+ log(`auto-configured ${s.id} settings (${s.settingsHint}) \u2014 first-ever hs web for this user`);
9229
+ } catch (err) {
9230
+ summary.failed.push({ tool: s.id, error: err && err.message ? err.message : String(err) });
9231
+ log(`warn: auto-config ${s.id} failed: ${err && err.message ? err.message : err}`);
9232
+ }
9233
+ }
9234
+ log(`CLI auto-config summary: configured=[${summary.configured.join(",")}] skipped=[${summary.skipped.join(",")}] failed=[${summary.failed.map((f) => f.tool).join(",")}]`);
9235
+ return summary;
9236
+ }
9237
+ __name(_ensureAllClisConfigured, "_ensureAllClisConfigured");
9098
9238
  function _ensureClaudeProxyConfig(apiKey) {
9099
9239
  const config = claudeProcessProxy.readConfig();
9100
9240
  const next = claudeCodeTool.buildBridgeConfig(apiKey, BASE_URL_ANTHROPIC, {
9101
9241
  ...config,
9102
9242
  relayUrl: config.relayUrl || BASE_URL_CLAUDE_RELAY
9103
9243
  });
9244
+ let proxyConfigUpdated = false;
9104
9245
  if (JSON.stringify(next) !== JSON.stringify(config)) {
9105
9246
  claudeProcessProxy.writeConfig(next);
9106
- return next;
9247
+ proxyConfigUpdated = true;
9107
9248
  }
9108
- return config;
9249
+ try {
9250
+ const existing = claudeCodeTool.readSettings();
9251
+ const hasToken = existing && existing.env && existing.env.ANTHROPIC_AUTH_TOKEN === apiKey;
9252
+ const hasLauncherMark = existing && existing.env && existing.env.HOLYSHEEP_CLAUDE_LAUNCHER === "hs";
9253
+ if (!hasToken || !hasLauncherMark) {
9254
+ const settings = existing || {};
9255
+ if (!settings.env) settings.env = {};
9256
+ settings.env.ANTHROPIC_AUTH_TOKEN = apiKey;
9257
+ delete settings.env.ANTHROPIC_BASE_URL;
9258
+ settings.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1";
9259
+ settings.env.HOLYSHEEP_CLAUDE_LAUNCHER = "hs";
9260
+ delete settings.env.ANTHROPIC_API_KEY;
9261
+ delete settings.env.HOLYSHEEP_CLAUDE_BRIDGE;
9262
+ claudeCodeTool.writeSettings(settings);
9263
+ log("auto-configured ~/.claude/settings.json with ANTHROPIC_AUTH_TOKEN (first-ever hs web for this user)");
9264
+ }
9265
+ } catch (e) {
9266
+ log("warn: failed to auto-configure ~/.claude/settings.json: " + (e && e.message ? e.message : e));
9267
+ }
9268
+ return proxyConfigUpdated ? next : config;
9109
9269
  }
9110
9270
  __name(_ensureClaudeProxyConfig, "_ensureClaudeProxyConfig");
9111
9271
  async function ensureClaudeProcessProxyRunning(opts = {}) {
@@ -9148,6 +9308,19 @@ var require_aionui_wrapper = __commonJS({
9148
9308
  }
9149
9309
  const internalPort = await pickInternalPort();
9150
9310
  log(`internal runtime port: ${internalPort}`);
9311
+ try {
9312
+ const __apiKeyForAutoConfig = (() => {
9313
+ try {
9314
+ return getApiKey();
9315
+ } catch {
9316
+ return null;
9317
+ }
9318
+ })();
9319
+ if (__apiKeyForAutoConfig) _ensureAllClisConfigured(__apiKeyForAutoConfig);
9320
+ else log("CLI auto-config skipped: no HolySheep apiKey (run `hs login`)");
9321
+ } catch (e) {
9322
+ log("warn: CLI auto-config error (continuing): " + (e && e.message ? e.message : e));
9323
+ }
9151
9324
  const claudeProxyHandle = await ensureClaudeProcessProxyRunning();
9152
9325
  const debug = process.env.HS_WEB_DEBUG === "1";
9153
9326
  const { PACKAGE_ROOT, cliVersion, ptyHermesWrapperPath } = require_paths();
@@ -9264,6 +9437,7 @@ ${tail.split(/\r?\n/).map((ln) => ` ${ln}`).join("\n")}
9264
9437
  __name(startWrapper, "startWrapper");
9265
9438
  module2.exports = {
9266
9439
  startWrapper,
9440
+ _ensureAllClisConfigured,
9267
9441
  // Exported for tests / inspection
9268
9442
  isLoopbackRequest,
9269
9443
  pruneExpiredTokens,
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@simonyea/holysheep-cli",
3
- "version": "2.1.44",
3
+ "version": "2.1.46",
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",
8
8
  "prepublishOnly": "npm run build && npm test && node scripts/check-tarball-size.js"
9
9
  },
10
10
  "keywords": [