@simonyea/holysheep-cli 1.7.91 → 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 +16 -8
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')
|
|
@@ -96,7 +96,7 @@ function isConfiguredInToml() {
|
|
|
96
96
|
/**
|
|
97
97
|
* 写入 TOML config(合并方式:保留已有内容,只更新 holysheep 部分)
|
|
98
98
|
*/
|
|
99
|
-
function writeTomlConfig(
|
|
99
|
+
function writeTomlConfig(_apiKey, baseUrlOpenAI, model) {
|
|
100
100
|
if (!fs.existsSync(CONFIG_DIR)) {
|
|
101
101
|
fs.mkdirSync(CONFIG_DIR, { recursive: true })
|
|
102
102
|
}
|
|
@@ -113,7 +113,7 @@ function writeTomlConfig(apiKey, baseUrlOpenAI, model) {
|
|
|
113
113
|
`[model_providers.holysheep]`,
|
|
114
114
|
`name = "HolySheep"`,
|
|
115
115
|
`base_url = "${baseUrlOpenAI}"`,
|
|
116
|
-
`
|
|
116
|
+
`env_key = "HOLYSHEEP_API_KEY"`,
|
|
117
117
|
`wire_api = "responses"`,
|
|
118
118
|
'',
|
|
119
119
|
].join('\n')
|
|
@@ -185,20 +185,23 @@ module.exports = {
|
|
|
185
185
|
const model = 'gpt-5.4'
|
|
186
186
|
|
|
187
187
|
// 写入 TOML(Rust Codex v0.111+ 使用)
|
|
188
|
+
// Codex RS 不支持 api_key 字段,必须用 env_key 指向环境变量
|
|
188
189
|
writeTomlConfig(apiKey, baseUrlOpenAI, model)
|
|
189
190
|
|
|
190
191
|
// 同时写 JSON(兼容旧版 TypeScript Codex)
|
|
191
192
|
writeJsonConfigIfNeeded(apiKey, baseUrlOpenAI, model)
|
|
192
193
|
|
|
193
|
-
// 清除 auth.json 中的 ChatGPT OAuth
|
|
194
|
-
// Codex RS 在 auth_mode=chatgpt 时会用 OAuth JWT token 做 Authorization header,
|
|
195
|
-
// 即使 config.toml 里设置了自定义 model_provider 的 api_key 也会被覆盖,
|
|
196
|
-
// 导致 holysheep 收到非 cr_ 前缀的 token 返回 401。
|
|
194
|
+
// 清除 auth.json 中的 ChatGPT OAuth 认证,避免干扰
|
|
197
195
|
neutralizeAuthJson()
|
|
198
196
|
|
|
197
|
+
// 写入 HOLYSHEEP_API_KEY 环境变量(Codex RS 通过 env_key 读取)
|
|
198
|
+
const { writeEnvToShell } = require('../utils/shell')
|
|
199
|
+
writeEnvToShell({ HOLYSHEEP_API_KEY: apiKey })
|
|
200
|
+
|
|
199
201
|
return {
|
|
200
202
|
file: CONFIG_FILE,
|
|
201
203
|
hot: false,
|
|
204
|
+
envVars: { HOLYSHEEP_API_KEY: apiKey },
|
|
202
205
|
}
|
|
203
206
|
},
|
|
204
207
|
reset() {
|
|
@@ -224,6 +227,11 @@ module.exports = {
|
|
|
224
227
|
fs.writeFileSync(CONFIG_FILE_JSON, JSON.stringify(c, null, 2), 'utf8')
|
|
225
228
|
} catch {}
|
|
226
229
|
}
|
|
230
|
+
// 清理环境变量
|
|
231
|
+
try {
|
|
232
|
+
const { removeEnvFromShell } = require('../utils/shell')
|
|
233
|
+
removeEnvFromShell(['HOLYSHEEP_API_KEY'])
|
|
234
|
+
} catch {}
|
|
227
235
|
},
|
|
228
236
|
getConfigPath() { return CONFIG_FILE },
|
|
229
237
|
hint: '切换后重开终端生效;Rust Codex (v0.111+) 使用 config.toml',
|