@simonyea/holysheep-cli 1.7.90 → 1.7.92
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 +1 -1
- package/src/tools/codex.js +41 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simonyea/holysheep-cli",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.92",
|
|
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",
|
package/src/tools/codex.js
CHANGED
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
* [model_providers.holysheep]
|
|
13
13
|
* name = "HolySheep"
|
|
14
14
|
* base_url = "https://api.holysheep.ai/v1"
|
|
15
|
-
*
|
|
15
|
+
* env_key = "HOLYSHEEP_API_KEY"
|
|
16
16
|
* wire_api = "responses"
|
|
17
17
|
*
|
|
18
|
+
* 注意:Codex RS 不支持 api_key 字段!必须用 env_key 指向环境变量。
|
|
18
19
|
* 注意:旧的 config.json 会被 Rust Codex 忽略!
|
|
19
|
-
* 注意:api_key 直接写入配置文件,不再写入 shell 环境变量。
|
|
20
20
|
*/
|
|
21
21
|
const fs = require('fs')
|
|
22
22
|
const path = require('path')
|
|
@@ -26,6 +26,7 @@ const CONFIG_DIR = path.join(os.homedir(), '.codex')
|
|
|
26
26
|
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.toml')
|
|
27
27
|
// 保留 JSON 兼容性(老版本 TypeScript Codex 用)
|
|
28
28
|
const CONFIG_FILE_JSON = path.join(CONFIG_DIR, 'config.json')
|
|
29
|
+
const AUTH_FILE = path.join(CONFIG_DIR, 'auth.json')
|
|
29
30
|
|
|
30
31
|
function normalizeToml(content) {
|
|
31
32
|
return String(content || '').replace(/\r\n/g, '\n')
|
|
@@ -95,7 +96,7 @@ function isConfiguredInToml() {
|
|
|
95
96
|
/**
|
|
96
97
|
* 写入 TOML config(合并方式:保留已有内容,只更新 holysheep 部分)
|
|
97
98
|
*/
|
|
98
|
-
function writeTomlConfig(
|
|
99
|
+
function writeTomlConfig(_apiKey, baseUrlOpenAI, model) {
|
|
99
100
|
if (!fs.existsSync(CONFIG_DIR)) {
|
|
100
101
|
fs.mkdirSync(CONFIG_DIR, { recursive: true })
|
|
101
102
|
}
|
|
@@ -112,7 +113,7 @@ function writeTomlConfig(apiKey, baseUrlOpenAI, model) {
|
|
|
112
113
|
`[model_providers.holysheep]`,
|
|
113
114
|
`name = "HolySheep"`,
|
|
114
115
|
`base_url = "${baseUrlOpenAI}"`,
|
|
115
|
-
`
|
|
116
|
+
`env_key = "HOLYSHEEP_API_KEY"`,
|
|
116
117
|
`wire_api = "responses"`,
|
|
117
118
|
'',
|
|
118
119
|
].join('\n')
|
|
@@ -149,6 +150,28 @@ function writeJsonConfigIfNeeded(apiKey, baseUrlOpenAI, model) {
|
|
|
149
150
|
} catch {}
|
|
150
151
|
}
|
|
151
152
|
|
|
153
|
+
/**
|
|
154
|
+
* 清除 auth.json 中的 ChatGPT OAuth 认证,避免干扰 holysheep provider
|
|
155
|
+
* Codex RS bug: auth_mode=chatgpt 时 OAuth token 会覆盖自定义 provider 的 api_key
|
|
156
|
+
*/
|
|
157
|
+
function neutralizeAuthJson() {
|
|
158
|
+
try {
|
|
159
|
+
if (!fs.existsSync(AUTH_FILE)) return
|
|
160
|
+
|
|
161
|
+
const auth = JSON.parse(fs.readFileSync(AUTH_FILE, 'utf8'))
|
|
162
|
+
|
|
163
|
+
// 只在 chatgpt 模式时处理
|
|
164
|
+
if (auth.auth_mode !== 'chatgpt') return
|
|
165
|
+
|
|
166
|
+
// 切换为 api-key 模式,清除 OAuth tokens
|
|
167
|
+
auth.auth_mode = 'api-key'
|
|
168
|
+
auth.OPENAI_API_KEY = null
|
|
169
|
+
delete auth.tokens
|
|
170
|
+
|
|
171
|
+
fs.writeFileSync(AUTH_FILE, JSON.stringify(auth, null, 2), 'utf8')
|
|
172
|
+
} catch {}
|
|
173
|
+
}
|
|
174
|
+
|
|
152
175
|
module.exports = {
|
|
153
176
|
name: 'Codex CLI',
|
|
154
177
|
id: 'codex',
|
|
@@ -162,14 +185,23 @@ module.exports = {
|
|
|
162
185
|
const model = 'gpt-5.4'
|
|
163
186
|
|
|
164
187
|
// 写入 TOML(Rust Codex v0.111+ 使用)
|
|
188
|
+
// Codex RS 不支持 api_key 字段,必须用 env_key 指向环境变量
|
|
165
189
|
writeTomlConfig(apiKey, baseUrlOpenAI, model)
|
|
166
190
|
|
|
167
191
|
// 同时写 JSON(兼容旧版 TypeScript Codex)
|
|
168
192
|
writeJsonConfigIfNeeded(apiKey, baseUrlOpenAI, model)
|
|
169
193
|
|
|
194
|
+
// 清除 auth.json 中的 ChatGPT OAuth 认证,避免干扰
|
|
195
|
+
neutralizeAuthJson()
|
|
196
|
+
|
|
197
|
+
// 写入 HOLYSHEEP_API_KEY 环境变量(Codex RS 通过 env_key 读取)
|
|
198
|
+
const { writeEnvToShell } = require('../utils/shell')
|
|
199
|
+
writeEnvToShell({ HOLYSHEEP_API_KEY: apiKey })
|
|
200
|
+
|
|
170
201
|
return {
|
|
171
202
|
file: CONFIG_FILE,
|
|
172
203
|
hot: false,
|
|
204
|
+
envVars: { HOLYSHEEP_API_KEY: apiKey },
|
|
173
205
|
}
|
|
174
206
|
},
|
|
175
207
|
reset() {
|
|
@@ -195,6 +227,11 @@ module.exports = {
|
|
|
195
227
|
fs.writeFileSync(CONFIG_FILE_JSON, JSON.stringify(c, null, 2), 'utf8')
|
|
196
228
|
} catch {}
|
|
197
229
|
}
|
|
230
|
+
// 清理环境变量
|
|
231
|
+
try {
|
|
232
|
+
const { removeEnvFromShell } = require('../utils/shell')
|
|
233
|
+
removeEnvFromShell(['HOLYSHEEP_API_KEY'])
|
|
234
|
+
} catch {}
|
|
198
235
|
},
|
|
199
236
|
getConfigPath() { return CONFIG_FILE },
|
|
200
237
|
hint: '切换后重开终端生效;Rust Codex (v0.111+) 使用 config.toml',
|