yymaxapi 1.0.70 → 1.0.72
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/bin/yymaxapi.js +23 -5
- package/package.json +1 -1
package/bin/yymaxapi.js
CHANGED
|
@@ -1795,6 +1795,20 @@ function ensureGatewaySettings(config) {
|
|
|
1795
1795
|
|
|
1796
1796
|
}
|
|
1797
1797
|
|
|
1798
|
+
// 只清理 yunyi 相关的 env.vars;其他服务商的不动
|
|
1799
|
+
function cleanupConflictingEnvVars(config, codexBaseUrl, apiKey) {
|
|
1800
|
+
if (!config.env?.vars) return;
|
|
1801
|
+
const vars = config.env.vars;
|
|
1802
|
+
// 只处理指向 yunyi 的 env vars(过时的 yunyi 配置)
|
|
1803
|
+
const isYunyiUrl = vars.OPENAI_BASE_URL && vars.OPENAI_BASE_URL.includes('yunyi');
|
|
1804
|
+
if (isYunyiUrl) {
|
|
1805
|
+
// yunyi 的 base url 存在,更新为正确值
|
|
1806
|
+
if (codexBaseUrl) vars.OPENAI_BASE_URL = codexBaseUrl;
|
|
1807
|
+
if (vars.OPENAI_API_KEY !== apiKey) vars.OPENAI_API_KEY = apiKey;
|
|
1808
|
+
}
|
|
1809
|
+
// 其他服务商的 OPENAI_API_KEY / OPENAI_BASE_URL 不动
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1798
1812
|
function isPortOpen(port, host = '127.0.0.1', timeoutMs = 800) {
|
|
1799
1813
|
return new Promise((resolve) => {
|
|
1800
1814
|
const socket = new net.Socket();
|
|
@@ -2284,7 +2298,7 @@ async function quickSetup(paths, args = {}) {
|
|
|
2284
2298
|
auth: DEFAULT_AUTH_MODE,
|
|
2285
2299
|
api: apiConfig.api,
|
|
2286
2300
|
headers: {},
|
|
2287
|
-
authHeader:
|
|
2301
|
+
authHeader: apiConfig.api.startsWith('openai'),
|
|
2288
2302
|
apiKey: apiKey.trim(),
|
|
2289
2303
|
models: [
|
|
2290
2304
|
{
|
|
@@ -2312,6 +2326,7 @@ async function quickSetup(paths, args = {}) {
|
|
|
2312
2326
|
const ws = ora({ text: '正在写入配置...', spinner: 'dots' }).start();
|
|
2313
2327
|
createTimestampedBackup(paths.openclawConfig, paths.configDir, 'quick-setup');
|
|
2314
2328
|
ensureGatewaySettings(config);
|
|
2329
|
+
if (apiConfig.api.startsWith('openai')) cleanupConflictingEnvVars(config, normalizedBaseUrl, apiKey);
|
|
2315
2330
|
writeConfigWithSync(paths, config);
|
|
2316
2331
|
updateAuthProfiles(paths.authProfiles, providerName, apiKey);
|
|
2317
2332
|
ws.succeed('配置写入完成');
|
|
@@ -2469,7 +2484,7 @@ async function presetClaude(paths, args = {}) {
|
|
|
2469
2484
|
auth: DEFAULT_AUTH_MODE,
|
|
2470
2485
|
api: apiConfig.api,
|
|
2471
2486
|
headers: {},
|
|
2472
|
-
authHeader:
|
|
2487
|
+
authHeader: apiConfig.api.startsWith('openai'),
|
|
2473
2488
|
apiKey: apiKey.trim(),
|
|
2474
2489
|
models: [
|
|
2475
2490
|
{
|
|
@@ -2662,7 +2677,7 @@ async function presetCodex(paths, args = {}) {
|
|
|
2662
2677
|
auth: DEFAULT_AUTH_MODE,
|
|
2663
2678
|
api: apiConfig.api,
|
|
2664
2679
|
headers: {},
|
|
2665
|
-
authHeader:
|
|
2680
|
+
authHeader: apiConfig.api.startsWith('openai'),
|
|
2666
2681
|
apiKey: apiKey.trim(),
|
|
2667
2682
|
models: [
|
|
2668
2683
|
{
|
|
@@ -2689,6 +2704,7 @@ async function presetCodex(paths, args = {}) {
|
|
|
2689
2704
|
const writeSpinner2 = ora({ text: '正在写入配置...', spinner: 'dots' }).start();
|
|
2690
2705
|
createTimestampedBackup(paths.openclawConfig, paths.configDir, 'codex');
|
|
2691
2706
|
ensureGatewaySettings(config);
|
|
2707
|
+
cleanupConflictingEnvVars(config, baseUrl, apiKey);
|
|
2692
2708
|
writeConfigWithSync(paths, config);
|
|
2693
2709
|
updateAuthProfiles(paths.authProfiles, providerName, apiKey);
|
|
2694
2710
|
const extSynced2 = syncExternalTools('codex', baseUrl, apiKey);
|
|
@@ -2850,7 +2866,7 @@ async function autoActivate(paths, args = {}) {
|
|
|
2850
2866
|
auth: DEFAULT_AUTH_MODE,
|
|
2851
2867
|
api: codexApiConfig.api,
|
|
2852
2868
|
headers: {},
|
|
2853
|
-
authHeader:
|
|
2869
|
+
authHeader: codexApiConfig.api.startsWith('openai'),
|
|
2854
2870
|
apiKey: apiKey.trim(),
|
|
2855
2871
|
models: [{
|
|
2856
2872
|
id: codexModel.id,
|
|
@@ -2872,6 +2888,7 @@ async function autoActivate(paths, args = {}) {
|
|
|
2872
2888
|
const writeSpinner = ora({ text: '正在写入配置...', spinner: 'dots' }).start();
|
|
2873
2889
|
createTimestampedBackup(paths.openclawConfig, paths.configDir, 'unified');
|
|
2874
2890
|
ensureGatewaySettings(config);
|
|
2891
|
+
cleanupConflictingEnvVars(config, codexBaseUrl, apiKey);
|
|
2875
2892
|
writeConfigWithSync(paths, config);
|
|
2876
2893
|
updateAuthProfiles(paths.authProfiles, claudeProviderName, apiKey);
|
|
2877
2894
|
updateAuthProfiles(paths.authProfiles, codexProviderName, apiKey);
|
|
@@ -3291,7 +3308,7 @@ async function yycodeQuickSetup(paths) {
|
|
|
3291
3308
|
auth: DEFAULT_AUTH_MODE,
|
|
3292
3309
|
api: codexApiConfig.api,
|
|
3293
3310
|
headers: {},
|
|
3294
|
-
authHeader:
|
|
3311
|
+
authHeader: codexApiConfig.api.startsWith('openai'),
|
|
3295
3312
|
apiKey: apiKey.trim(),
|
|
3296
3313
|
models: [{ id: codexModel.id, name: codexModel.name, contextWindow: codexApiConfig.contextWindow, maxTokens: codexApiConfig.maxTokens }]
|
|
3297
3314
|
};
|
|
@@ -3306,6 +3323,7 @@ async function yycodeQuickSetup(paths) {
|
|
|
3306
3323
|
const writeSpinner = ora({ text: '正在写入配置...', spinner: 'dots' }).start();
|
|
3307
3324
|
createTimestampedBackup(paths.openclawConfig, paths.configDir, 'yycode');
|
|
3308
3325
|
ensureGatewaySettings(config);
|
|
3326
|
+
cleanupConflictingEnvVars(config, codexBaseUrl, apiKey);
|
|
3309
3327
|
writeConfigWithSync(paths, config);
|
|
3310
3328
|
updateAuthProfiles(paths.authProfiles, claudeProviderName, apiKey);
|
|
3311
3329
|
updateAuthProfiles(paths.authProfiles, codexProviderName, apiKey);
|