@simonyea/holysheep-cli 1.7.23 → 1.7.24

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simonyea/holysheep-cli",
3
- "version": "1.7.23",
3
+ "version": "1.7.24",
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
  "keywords": [
6
6
  "openai-china",
@@ -1,8 +1,10 @@
1
1
  'use strict'
2
2
 
3
3
  const { spawn } = require('child_process')
4
+ const crypto = require('crypto')
4
5
  const {
5
6
  BASE_URL_ANTHROPIC,
7
+ BASE_URL_CLAUDE_RELAY,
6
8
  getApiKey,
7
9
  } = require('../utils/config')
8
10
  const {
@@ -10,8 +12,62 @@ const {
10
12
  getLocalProxyUrl,
11
13
  startProcessProxy,
12
14
  readConfig,
15
+ writeConfig,
13
16
  } = require('../tools/claude-process-proxy')
14
17
 
18
+ function ensureClaudeProxyConfig(apiKey) {
19
+ const config = readConfig()
20
+ const next = { ...config }
21
+ let changed = false
22
+
23
+ if (!next.apiKey && apiKey) {
24
+ next.apiKey = apiKey
25
+ changed = true
26
+ }
27
+ if (!next.baseUrlAnthropic) {
28
+ next.baseUrlAnthropic = BASE_URL_ANTHROPIC
29
+ changed = true
30
+ }
31
+ if (!next.controlPlaneUrl) {
32
+ next.controlPlaneUrl = next.relayUrl || BASE_URL_CLAUDE_RELAY
33
+ changed = true
34
+ }
35
+ if (!next.relayUrl) {
36
+ next.relayUrl = BASE_URL_CLAUDE_RELAY
37
+ changed = true
38
+ }
39
+ if (!next.bridgeId) {
40
+ next.bridgeId = crypto.randomUUID()
41
+ changed = true
42
+ }
43
+ if (!next.deviceId) {
44
+ next.deviceId = crypto.randomUUID()
45
+ changed = true
46
+ }
47
+ if (!next.bridgeSecret) {
48
+ next.bridgeSecret = crypto.randomBytes(32).toString('hex')
49
+ changed = true
50
+ }
51
+ if (!next.installSource) {
52
+ next.installSource = 'holysheep-cli'
53
+ changed = true
54
+ }
55
+ if (!next.proxyMode) {
56
+ next.proxyMode = 'claude-process'
57
+ changed = true
58
+ }
59
+ if (!next.processProxyPort) {
60
+ next.processProxyPort = config.processProxyPort || 14556
61
+ changed = true
62
+ }
63
+
64
+ if (changed) {
65
+ writeConfig(next)
66
+ return next
67
+ }
68
+ return config
69
+ }
70
+
15
71
  async function runClaude(args = []) {
16
72
  const config = readConfig()
17
73
  const apiKey = config.apiKey || getApiKey()
@@ -19,6 +75,8 @@ async function runClaude(args = []) {
19
75
  throw new Error('Missing API Key. Run hs setup first.')
20
76
  }
21
77
 
78
+ ensureClaudeProxyConfig(apiKey)
79
+
22
80
  const { server, port, sessionId } = startProcessProxy({})
23
81
  const proxyUrl = getLocalProxyUrl(port)
24
82