aihezu 1.7.0 → 1.7.1
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/README.md +3 -1
- package/bin/aihezu.js +1 -0
- package/bin/ccinstall.js +54 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
- `ccinstall` / `install`:交互式配置 Claude(默认)或 Codex
|
|
18
18
|
- Claude:默认 `https://cc.aihezu.dev/api`,企业可用 `--api` / `--api-url` 指定独立域名
|
|
19
|
-
- Codex
|
|
19
|
+
- Codex:默认 `https://cc.aihezu.dev/openai`,企业可用 `--api` / `--api-url` 指定独立域名;写入 `~/.codex/config.toml` 和 `auth.json`,使用 `AIHEZU_OAI_KEY`
|
|
20
20
|
- `ccclear`:清理 Claude Code 缓存和配置
|
|
21
21
|
|
|
22
22
|
## 清理内容
|
|
@@ -65,6 +65,8 @@ sudo ccinstall --api your-company.aihezu.dev
|
|
|
65
65
|
|
|
66
66
|
```bash
|
|
67
67
|
sudo npx aihezu install --provider codex
|
|
68
|
+
# Codex 企业独立域名(自动补全为 /openai)
|
|
69
|
+
sudo npx aihezu install --provider codex --api your-org.aihezu.dev
|
|
68
70
|
```
|
|
69
71
|
|
|
70
72
|
### 清理 Claude Code(ccclear)
|
package/bin/aihezu.js
CHANGED
|
@@ -21,6 +21,7 @@ function showHelp() {
|
|
|
21
21
|
console.log(' npx aihezu ccinstall # 配置 API Key (默认 Claude)');
|
|
22
22
|
console.log(' npx aihezu install --api your-org.aihezu.dev # 企业用户自定义域名');
|
|
23
23
|
console.log(' npx aihezu install --provider codex # 直接配置 Codex');
|
|
24
|
+
console.log(' npx aihezu install --provider codex --api your-org.aihezu.dev # Codex 企业域名');
|
|
24
25
|
console.log(' npx aihezu ccclear # 清理缓存');
|
|
25
26
|
}
|
|
26
27
|
|
package/bin/ccinstall.js
CHANGED
|
@@ -61,7 +61,7 @@ function parseApiBaseInput(argv) {
|
|
|
61
61
|
return apiBaseInput.trim();
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
function
|
|
64
|
+
function normalizeClaudeApiBaseUrl(input) {
|
|
65
65
|
if (!input) return DEFAULT_CLAUDE_API_BASE;
|
|
66
66
|
|
|
67
67
|
let normalized = input;
|
|
@@ -89,6 +89,34 @@ function normalizeApiBaseUrl(input) {
|
|
|
89
89
|
return `${url.origin}${url.pathname}`;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
function normalizeCodexBaseUrl(input) {
|
|
93
|
+
if (!input) return DEFAULT_CODEX_BASE_URL;
|
|
94
|
+
|
|
95
|
+
let normalized = input;
|
|
96
|
+
|
|
97
|
+
if (!/^https?:\/\//i.test(normalized)) {
|
|
98
|
+
normalized = `https://${normalized}`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let url;
|
|
102
|
+
try {
|
|
103
|
+
url = new URL(normalized);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
throw new Error('无效的域名或 URL,请输入类似 your-org.aihezu.dev 或 https://your-org.aihezu.dev');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let pathname = url.pathname.replace(/\/+$/, '');
|
|
109
|
+
if (!pathname || pathname === '/') {
|
|
110
|
+
pathname = '/openai';
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
url.pathname = pathname;
|
|
114
|
+
url.search = '';
|
|
115
|
+
url.hash = '';
|
|
116
|
+
|
|
117
|
+
return `${url.origin}${url.pathname}`;
|
|
118
|
+
}
|
|
119
|
+
|
|
92
120
|
function resolveProvider(input) {
|
|
93
121
|
const value = (input || '').toLowerCase();
|
|
94
122
|
if (['2', 'codex', 'c'].includes(value)) return PROVIDERS.CODEX;
|
|
@@ -144,7 +172,7 @@ function writeClaudeSettings(apiKey, apiBaseUrl) {
|
|
|
144
172
|
console.log(' ANTHROPIC_BASE_URL:', apiBaseUrl);
|
|
145
173
|
}
|
|
146
174
|
|
|
147
|
-
function writeCodexConfig(apiKey) {
|
|
175
|
+
function writeCodexConfig(apiKey, codexBaseUrl) {
|
|
148
176
|
if (!fs.existsSync(codexDir)) {
|
|
149
177
|
console.log('📁 创建 ~/.codex 目录...');
|
|
150
178
|
fs.mkdirSync(codexDir, { recursive: true });
|
|
@@ -164,7 +192,7 @@ function writeCodexConfig(apiKey) {
|
|
|
164
192
|
'',
|
|
165
193
|
'[model_providers.aihezu]',
|
|
166
194
|
'name = "aihezu"',
|
|
167
|
-
`base_url = "${
|
|
195
|
+
`base_url = "${codexBaseUrl}"`,
|
|
168
196
|
'wire_api = "responses"',
|
|
169
197
|
'requires_openai_auth = true',
|
|
170
198
|
'env_key = "AIHEZU_OAI_KEY"',
|
|
@@ -197,7 +225,7 @@ function writeCodexConfig(apiKey) {
|
|
|
197
225
|
console.log(' -', codexAuthPath);
|
|
198
226
|
console.log('\n配置内容:');
|
|
199
227
|
console.log(' AIHEZU_OAI_KEY:', apiKey);
|
|
200
|
-
console.log(' base_url:',
|
|
228
|
+
console.log(' base_url:', codexBaseUrl);
|
|
201
229
|
console.log('\n💡 已在 auth.json 中写入密钥,并在 config.toml 中指定 env_key = "AIHEZU_OAI_KEY"');
|
|
202
230
|
console.log(' 如需在 shell 中直接使用,可运行: export AIHEZU_OAI_KEY="<你的密钥>"');
|
|
203
231
|
}
|
|
@@ -221,10 +249,20 @@ async function main() {
|
|
|
221
249
|
}
|
|
222
250
|
|
|
223
251
|
const apiBaseInput = provider === PROVIDERS.CLAUDE ? parseApiBaseInput(cliArgs) : '';
|
|
252
|
+
const codexBaseInput = provider === PROVIDERS.CODEX ? parseApiBaseInput(cliArgs) : '';
|
|
253
|
+
|
|
224
254
|
let apiBaseUrl = DEFAULT_CLAUDE_API_BASE;
|
|
255
|
+
let codexBaseUrl = DEFAULT_CODEX_BASE_URL;
|
|
225
256
|
if (provider === PROVIDERS.CLAUDE) {
|
|
226
257
|
try {
|
|
227
|
-
apiBaseUrl =
|
|
258
|
+
apiBaseUrl = normalizeClaudeApiBaseUrl(apiBaseInput);
|
|
259
|
+
} catch (error) {
|
|
260
|
+
console.error(`❌ ${error.message}`);
|
|
261
|
+
process.exit(1);
|
|
262
|
+
}
|
|
263
|
+
} else {
|
|
264
|
+
try {
|
|
265
|
+
codexBaseUrl = normalizeCodexBaseUrl(codexBaseInput);
|
|
228
266
|
} catch (error) {
|
|
229
267
|
console.error(`❌ ${error.message}`);
|
|
230
268
|
process.exit(1);
|
|
@@ -232,6 +270,7 @@ async function main() {
|
|
|
232
270
|
}
|
|
233
271
|
|
|
234
272
|
const usingCustomDomain = provider === PROVIDERS.CLAUDE && !!apiBaseInput;
|
|
273
|
+
const usingCustomCodexDomain = provider === PROVIDERS.CODEX && !!codexBaseInput;
|
|
235
274
|
|
|
236
275
|
if (provider === PROVIDERS.CLAUDE) {
|
|
237
276
|
if (usingCustomDomain) {
|
|
@@ -242,7 +281,13 @@ async function main() {
|
|
|
242
281
|
console.log(' sudo npx aihezu install --api your-org.aihezu.dev\n');
|
|
243
282
|
}
|
|
244
283
|
} else {
|
|
245
|
-
|
|
284
|
+
if (usingCustomCodexDomain) {
|
|
285
|
+
console.log(`🏢 Codex 已使用企业域名: ${codexBaseUrl}\n`);
|
|
286
|
+
} else {
|
|
287
|
+
console.log(`🤖 已选择 Codex,默认网关: ${DEFAULT_CODEX_BASE_URL}`);
|
|
288
|
+
console.log(' 企业用户可用 --api 或 --api-url 指定独立域名,例如:');
|
|
289
|
+
console.log(' npx aihezu install --provider codex --api your-org.aihezu.dev\n');
|
|
290
|
+
}
|
|
246
291
|
}
|
|
247
292
|
|
|
248
293
|
const needCleanAnswer = await askQuestion(
|
|
@@ -272,12 +317,14 @@ async function main() {
|
|
|
272
317
|
if (provider === PROVIDERS.CLAUDE) {
|
|
273
318
|
writeClaudeSettings(apiKey.trim(), apiBaseUrl);
|
|
274
319
|
} else {
|
|
275
|
-
writeCodexConfig(apiKey.trim());
|
|
320
|
+
writeCodexConfig(apiKey.trim(), codexBaseUrl);
|
|
276
321
|
}
|
|
277
322
|
|
|
278
323
|
if (provider === PROVIDERS.CLAUDE) {
|
|
279
324
|
console.log('\n=== 修改 hosts 文件 ===\n');
|
|
280
325
|
modifyHostsFile();
|
|
326
|
+
} else {
|
|
327
|
+
console.log('\n=== Codex 不需要修改 hosts,已跳过 ===');
|
|
281
328
|
}
|
|
282
329
|
|
|
283
330
|
console.log('\n=== 全部完成 ===');
|