@simonyea/holysheep-cli 2.1.41 → 2.1.43

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.
@@ -1810,7 +1810,26 @@ var require_opencode = __commonJS({
1810
1810
  apiKey
1811
1811
  }
1812
1812
  };
1813
- config.model = "openai/gpt-5.4";
1813
+ const DEFAULT_MODEL = "openai/gpt-5.4";
1814
+ const MODEL_WHITELIST = /^(openai\/)?gpt-[\w][\w.\-]*$/i;
1815
+ let resolvedModel = DEFAULT_MODEL;
1816
+ const envOverride = (process.env.HOLYSHEEP_OPENCODE_MODEL || "").trim();
1817
+ if (envOverride) {
1818
+ if (MODEL_WHITELIST.test(envOverride)) {
1819
+ resolvedModel = /^openai\//i.test(envOverride) ? envOverride : `openai/${envOverride}`;
1820
+ } else {
1821
+ console.error(
1822
+ `[opencode] HOLYSHEEP_OPENCODE_MODEL="${envOverride}" rejected \u2014 must match openai/gpt-* or gpt-* (non-empty suffix). falling back to ${DEFAULT_MODEL}.`
1823
+ );
1824
+ }
1825
+ }
1826
+ const previousModel = typeof config.model === "string" ? config.model : "";
1827
+ if (previousModel && /^(anthropic\/|claude-)/i.test(previousModel) && previousModel !== resolvedModel) {
1828
+ console.error(
1829
+ `[opencode] migrated ${previousModel} \u2192 ${resolvedModel} (hs28 body-size fix: claude-* trips 40KB plan-limit via relay)`
1830
+ );
1831
+ }
1832
+ config.model = resolvedModel;
1814
1833
  void primaryModel;
1815
1834
  if (!process.env.HOLYSHEEP_OPENCODE_KEEP_ALL_TOOLS) {
1816
1835
  const tools = { ...config.tools || {} };
@@ -3912,11 +3931,11 @@ var require_package = __commonJS({
3912
3931
  "package.json"(exports2, module2) {
3913
3932
  module2.exports = {
3914
3933
  name: "@simonyea/holysheep-cli",
3915
- version: "2.1.41",
3934
+ version: "2.1.43",
3916
3935
  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.",
3917
3936
  scripts: {
3918
3937
  build: "node scripts/build.mjs",
3919
- 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",
3938
+ 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",
3920
3939
  prepublishOnly: "npm run build && npm test && node scripts/check-tarball-size.js"
3921
3940
  },
3922
3941
  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.41",
15
+ version: "2.1.43",
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",
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",
20
20
  prepublishOnly: "npm run build && npm test && node scripts/check-tarball-size.js"
21
21
  },
22
22
  keywords: [
@@ -2355,7 +2355,26 @@ var require_opencode = __commonJS({
2355
2355
  apiKey
2356
2356
  }
2357
2357
  };
2358
- config.model = "openai/gpt-5.4";
2358
+ const DEFAULT_MODEL = "openai/gpt-5.4";
2359
+ const MODEL_WHITELIST = /^(openai\/)?gpt-[\w][\w.\-]*$/i;
2360
+ let resolvedModel = DEFAULT_MODEL;
2361
+ const envOverride = (process.env.HOLYSHEEP_OPENCODE_MODEL || "").trim();
2362
+ if (envOverride) {
2363
+ if (MODEL_WHITELIST.test(envOverride)) {
2364
+ resolvedModel = /^openai\//i.test(envOverride) ? envOverride : `openai/${envOverride}`;
2365
+ } else {
2366
+ console.error(
2367
+ `[opencode] HOLYSHEEP_OPENCODE_MODEL="${envOverride}" rejected \u2014 must match openai/gpt-* or gpt-* (non-empty suffix). falling back to ${DEFAULT_MODEL}.`
2368
+ );
2369
+ }
2370
+ }
2371
+ const previousModel = typeof config.model === "string" ? config.model : "";
2372
+ if (previousModel && /^(anthropic\/|claude-)/i.test(previousModel) && previousModel !== resolvedModel) {
2373
+ console.error(
2374
+ `[opencode] migrated ${previousModel} \u2192 ${resolvedModel} (hs28 body-size fix: claude-* trips 40KB plan-limit via relay)`
2375
+ );
2376
+ }
2377
+ config.model = resolvedModel;
2359
2378
  void primaryModel;
2360
2379
  if (!process.env.HOLYSHEEP_OPENCODE_KEEP_ALL_TOOLS) {
2361
2380
  const tools = { ...config.tools || {} };
@@ -8511,8 +8530,12 @@ var require_aionui_wrapper = __commonJS({
8511
8530
  getApiKey,
8512
8531
  loadConfig,
8513
8532
  saveConfig,
8514
- BASE_URL_OPENAI
8533
+ BASE_URL_OPENAI,
8534
+ BASE_URL_ANTHROPIC,
8535
+ BASE_URL_CLAUDE_RELAY
8515
8536
  } = require_config();
8537
+ var claudeProcessProxy = require_claude_process_proxy();
8538
+ var claudeCodeTool = require_claude_code();
8516
8539
  var BRIDGE_DIR = path.join(os.homedir(), ".holysheep");
8517
8540
  var BRIDGE_CRED_FILE = path.join(BRIDGE_DIR, "aionui-bridge.json");
8518
8541
  var TOKEN_TTL_MS = 3e4;
@@ -8965,6 +8988,76 @@ var require_aionui_wrapper = __commonJS({
8965
8988
  }, "onRequest");
8966
8989
  }
8967
8990
  __name(buildRouter, "buildRouter");
8991
+ function probeLocalPort(port, timeoutMs = 500) {
8992
+ return new Promise((resolve) => {
8993
+ const socket = net.createConnection({ host: "127.0.0.1", port });
8994
+ const timer = setTimeout(() => {
8995
+ try {
8996
+ socket.destroy();
8997
+ } catch {
8998
+ }
8999
+ resolve(false);
9000
+ }, timeoutMs);
9001
+ socket.once("connect", () => {
9002
+ clearTimeout(timer);
9003
+ try {
9004
+ socket.end();
9005
+ } catch {
9006
+ }
9007
+ resolve(true);
9008
+ });
9009
+ socket.once("error", () => {
9010
+ clearTimeout(timer);
9011
+ resolve(false);
9012
+ });
9013
+ });
9014
+ }
9015
+ __name(probeLocalPort, "probeLocalPort");
9016
+ function _ensureClaudeProxyConfig(apiKey) {
9017
+ const config = claudeProcessProxy.readConfig();
9018
+ const next = claudeCodeTool.buildBridgeConfig(apiKey, BASE_URL_ANTHROPIC, {
9019
+ ...config,
9020
+ relayUrl: config.relayUrl || BASE_URL_CLAUDE_RELAY
9021
+ });
9022
+ if (JSON.stringify(next) !== JSON.stringify(config)) {
9023
+ claudeProcessProxy.writeConfig(next);
9024
+ return next;
9025
+ }
9026
+ return config;
9027
+ }
9028
+ __name(_ensureClaudeProxyConfig, "_ensureClaudeProxyConfig");
9029
+ async function ensureClaudeProcessProxyRunning(opts = {}) {
9030
+ const proxyModule = opts.proxyModule || claudeProcessProxy;
9031
+ const probe = opts.probe || probeLocalPort;
9032
+ const apiKeyGetter = opts.apiKeyGetter || getApiKey;
9033
+ const ensureConfig = opts.ensureConfig || _ensureClaudeProxyConfig;
9034
+ const port = proxyModule.getProcessProxyPort(proxyModule.readConfig());
9035
+ const listening = await probe(port, 500);
9036
+ if (listening) {
9037
+ log(`claude process proxy already listening on 127.0.0.1:${port} (reusing; likely started by \`hs claude\` or another hs web)`);
9038
+ return { reused: true, port };
9039
+ }
9040
+ let apiKey;
9041
+ try {
9042
+ apiKey = apiKeyGetter();
9043
+ } catch {
9044
+ apiKey = null;
9045
+ }
9046
+ if (!apiKey) {
9047
+ log(`claude process proxy pre-start skipped: no HolySheep API key found (run \`hs login\` to enable Claude Code). Non-Claude backends unaffected.`);
9048
+ return { skipped: true, reason: "no-api-key", port };
9049
+ }
9050
+ try {
9051
+ ensureConfig(apiKey);
9052
+ const result = await proxyModule.startProcessProxy({});
9053
+ log(`claude process proxy listening on 127.0.0.1:${result.port} (sessionId=${String(result.sessionId).slice(0, 8)})`);
9054
+ return { reused: false, port: result.port, sessionId: result.sessionId, server: result.server };
9055
+ } catch (err) {
9056
+ log(`claude process proxy pre-start failed (continuing without it): ${err && err.message ? err.message : err}`);
9057
+ return { skipped: true, reason: "start-failed", port, error: err };
9058
+ }
9059
+ }
9060
+ __name(ensureClaudeProcessProxyRunning, "ensureClaudeProcessProxyRunning");
8968
9061
  async function startWrapper({ port, runtimeDir, runtimeVersion, runtimeSource, bunPath }) {
8969
9062
  const hsNative = detectHolySheepAionUi(runtimeDir);
8970
9063
  log(`/login mode: ${hsNative ? "holysheep-native (apiKey)" : "legacy (username/password bridge)"}`);
@@ -8973,6 +9066,7 @@ var require_aionui_wrapper = __commonJS({
8973
9066
  }
8974
9067
  const internalPort = await pickInternalPort();
8975
9068
  log(`internal runtime port: ${internalPort}`);
9069
+ const claudeProxyHandle = await ensureClaudeProcessProxyRunning();
8976
9070
  const debug = process.env.HS_WEB_DEBUG === "1";
8977
9071
  const { PACKAGE_ROOT, cliVersion, ptyHermesWrapperPath } = require_paths();
8978
9072
  const cliRoot = PACKAGE_ROOT;
@@ -9016,10 +9110,33 @@ var require_aionui_wrapper = __commonJS({
9016
9110
  }, "appendLog");
9017
9111
  aionui.stdout.on("data", (d) => appendLog("out", d));
9018
9112
  aionui.stderr.on("data", (d) => appendLog("err", d));
9113
+ let claudeProxyCleanedUp = false;
9114
+ const cleanupClaudeProxy = /* @__PURE__ */ __name(() => {
9115
+ if (claudeProxyCleanedUp) return;
9116
+ claudeProxyCleanedUp = true;
9117
+ if (!claudeProxyHandle || claudeProxyHandle.skipped || claudeProxyHandle.reused) return;
9118
+ try {
9119
+ if (claudeProxyHandle.server && typeof claudeProxyHandle.server.close === "function") {
9120
+ claudeProxyHandle.server.close();
9121
+ }
9122
+ } catch {
9123
+ }
9124
+ if (claudeProxyHandle.sessionId) {
9125
+ Promise.resolve(claudeProcessProxy.closeSession(void 0, claudeProxyHandle.sessionId)).catch(() => {
9126
+ });
9127
+ }
9128
+ }, "cleanupClaudeProxy");
9019
9129
  aionui.on("exit", (code) => {
9020
9130
  log(`runtime upstream exited (code=${code})`);
9131
+ cleanupClaudeProxy();
9021
9132
  process.exit(code || 1);
9022
9133
  });
9134
+ const _onSignal = /* @__PURE__ */ __name(() => {
9135
+ cleanupClaudeProxy();
9136
+ }, "_onSignal");
9137
+ process.once("SIGINT", _onSignal);
9138
+ process.once("SIGTERM", _onSignal);
9139
+ process.once("exit", cleanupClaudeProxy);
9023
9140
  try {
9024
9141
  await waitForUpstreamReady(internalPort);
9025
9142
  } catch (e) {
@@ -9070,7 +9187,10 @@ ${tail.split(/\r?\n/).map((ln) => ` ${ln}`).join("\n")}
9070
9187
  pruneExpiredTokens,
9071
9188
  _tokens: bootstrapTokens,
9072
9189
  TOKEN_TTL_MS,
9073
- BRIDGE_CRED_FILE
9190
+ BRIDGE_CRED_FILE,
9191
+ // [HolySheep v2.1.43] Exported for aionui-wrapper-claude-proxy.test.js
9192
+ ensureClaudeProcessProxyRunning,
9193
+ probeLocalPort
9074
9194
  };
9075
9195
  }
9076
9196
  });
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@simonyea/holysheep-cli",
3
- "version": "2.1.41",
4
- "description": "Claude Code/Cursor/Cline API relay for China \u2014 \u00a51=$1, WeChat/Alipay payment, no credit card, no VPN. One command setup for all AI coding tools.",
3
+ "version": "2.1.43",
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",
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",
8
8
  "prepublishOnly": "npm run build && npm test && node scripts/check-tarball-size.js"
9
9
  },
10
10
  "keywords": [