yymaxapi 1.0.74 → 1.0.76
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
CHANGED
|
@@ -1775,6 +1775,36 @@ function findCompatibleNode(minMajor = 22) {
|
|
|
1775
1775
|
return null;
|
|
1776
1776
|
}
|
|
1777
1777
|
|
|
1778
|
+
// 启动时自动修复已知的配置问题
|
|
1779
|
+
function autoFixConfig(paths) {
|
|
1780
|
+
try {
|
|
1781
|
+
const config = readConfig(paths.openclawConfig);
|
|
1782
|
+
if (!config?.models?.providers) return;
|
|
1783
|
+
|
|
1784
|
+
let changed = false;
|
|
1785
|
+
const codexProviderName = API_CONFIG.codex?.providerName;
|
|
1786
|
+
const codexProvider = codexProviderName && config.models.providers[codexProviderName];
|
|
1787
|
+
|
|
1788
|
+
// 修复: openai-responses → openai-completions(云翼服务器不支持 /v1/responses)
|
|
1789
|
+
if (codexProvider && codexProvider.api === 'openai-responses') {
|
|
1790
|
+
codexProvider.api = 'openai-completions';
|
|
1791
|
+
changed = true;
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
// 修复: codex provider 缺少 authHeader
|
|
1795
|
+
if (codexProvider && codexProvider.authHeader === undefined && codexProvider.api?.startsWith('openai')) {
|
|
1796
|
+
codexProvider.authHeader = true;
|
|
1797
|
+
changed = true;
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
if (changed) {
|
|
1801
|
+
writeConfig(paths.openclawConfig, config);
|
|
1802
|
+
console.log(chalk.green('✓ 已自动修复配置(openai-responses → openai-completions)'));
|
|
1803
|
+
}
|
|
1804
|
+
} catch { /* ignore */ }
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
|
|
1778
1808
|
function ensureGatewaySettings(config) {
|
|
1779
1809
|
if (!config.gateway) config.gateway = {};
|
|
1780
1810
|
const gateway = config.gateway;
|
|
@@ -3366,6 +3396,10 @@ async function main() {
|
|
|
3366
3396
|
console.log(chalk.green('✓ 已备份原始配置\n'));
|
|
3367
3397
|
}
|
|
3368
3398
|
|
|
3399
|
+
// 自动修复:检测并纠正已知的配置问题
|
|
3400
|
+
autoFixConfig(paths);
|
|
3401
|
+
|
|
3402
|
+
|
|
3369
3403
|
const args = parseArgs(process.argv.slice(2));
|
|
3370
3404
|
if (args.quick || args._.includes('quick')) {
|
|
3371
3405
|
await quickSetup(paths, args);
|
|
@@ -4042,8 +4076,32 @@ async function testConnection(paths, args = {}) {
|
|
|
4042
4076
|
console.log(chalk.red(` 回复内容: ${cliResult.message}`));
|
|
4043
4077
|
console.log(chalk.gray(` 这通常表示中转节点连接失败,请检查节点配置和网络`));
|
|
4044
4078
|
} else {
|
|
4045
|
-
|
|
4046
|
-
|
|
4079
|
+
// 检查实际响应模型是否与请求的主模型一致(检测 fallback)
|
|
4080
|
+
const actualModelKey = (cliResult.provider && cliResult.model)
|
|
4081
|
+
? `${cliResult.provider}/${cliResult.model}` : '';
|
|
4082
|
+
const isFallback = actualModelKey && actualModelKey !== primary;
|
|
4083
|
+
|
|
4084
|
+
if (isFallback) {
|
|
4085
|
+
console.log(chalk.yellow(`\n⚠️ 主模型测试失败,Gateway 自动回退到备选模型`));
|
|
4086
|
+
console.log(chalk.red(` 期望: ${primary}`));
|
|
4087
|
+
console.log(chalk.cyan(` 实际: ${actualModelKey}`));
|
|
4088
|
+
console.log(chalk.gray(` 这意味着 ${primary} 无法正常工作,请检查该模型的中转配置`));
|
|
4089
|
+
// 检查是否可能是 api 字段错误导致的 502
|
|
4090
|
+
const expectedProvider = primary.split('/')[0];
|
|
4091
|
+
const providerCfg = config.models?.providers?.[expectedProvider];
|
|
4092
|
+
if (providerCfg) {
|
|
4093
|
+
const apiField = providerCfg.api || '';
|
|
4094
|
+
console.log(chalk.gray(` 当前 api 字段: ${apiField}`));
|
|
4095
|
+
if (apiField === 'openai-responses') {
|
|
4096
|
+
console.log(chalk.yellow(` 💡 提示: api 字段为 "openai-responses",部分中转服务器不支持该格式`));
|
|
4097
|
+
console.log(chalk.yellow(` 建议重新运行 npx yymaxapi@latest 更新配置`));
|
|
4098
|
+
}
|
|
4099
|
+
}
|
|
4100
|
+
} else {
|
|
4101
|
+
cliPassed = true;
|
|
4102
|
+
console.log(chalk.green(`\n✅ CLI 对话测试成功`));
|
|
4103
|
+
}
|
|
4104
|
+
|
|
4047
4105
|
if (cliResult.provider && cliResult.model) {
|
|
4048
4106
|
console.log(chalk.cyan(` Provider: ${cliResult.provider}`));
|
|
4049
4107
|
console.log(chalk.cyan(` Model: ${cliResult.model}`));
|
|
@@ -4056,7 +4114,9 @@ async function testConnection(paths, args = {}) {
|
|
|
4056
4114
|
});
|
|
4057
4115
|
console.log(chalk.yellow(` 模型回复: ${reply}`));
|
|
4058
4116
|
}
|
|
4059
|
-
|
|
4117
|
+
if (!isFallback) {
|
|
4118
|
+
console.log(chalk.gray(' 将继续验证 Web 鉴权端点(避免"CLI 正常但网页 401")...'));
|
|
4119
|
+
}
|
|
4060
4120
|
}
|
|
4061
4121
|
}
|
|
4062
4122
|
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"codex": {
|
|
44
44
|
"urlSuffix": "/codex",
|
|
45
|
-
"api": "openai-
|
|
45
|
+
"api": "openai-completions",
|
|
46
46
|
"contextWindow": 1050000,
|
|
47
47
|
"maxTokens": 128000,
|
|
48
48
|
"providerName": "yunyi"
|
|
@@ -92,7 +92,7 @@ npx yymaxapi@latest
|
|
|
92
92
|
{
|
|
93
93
|
"provider": "openai",
|
|
94
94
|
"base_url": "https://yunyi.rdzhvip.com/codex",
|
|
95
|
-
"api": "openai-
|
|
95
|
+
"api": "openai-completions",
|
|
96
96
|
"api_key": "<你的云翼 API Key>",
|
|
97
97
|
"model": {
|
|
98
98
|
"id": "gpt-5.4",
|
|
@@ -137,7 +137,7 @@ npx yymaxapi@latest
|
|
|
137
137
|
{
|
|
138
138
|
"provider": "openai",
|
|
139
139
|
"base_url": "https://yunyi.rdzhvip.com/codex",
|
|
140
|
-
"api": "openai-
|
|
140
|
+
"api": "openai-completions",
|
|
141
141
|
"api_key": "<你的云翼 API Key>",
|
|
142
142
|
"model": {
|
|
143
143
|
"id": "gpt-5.4",
|