yymaxapi 1.0.46 → 1.0.48
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 +46 -16
- package/package.json +1 -1
package/bin/yymaxapi.js
CHANGED
|
@@ -3217,30 +3217,43 @@ function getConfigStatusLine(paths) {
|
|
|
3217
3217
|
|
|
3218
3218
|
const providers = Object.keys(config.models.providers);
|
|
3219
3219
|
const primary = config?.agents?.defaults?.model?.primary || '';
|
|
3220
|
+
const primaryProvider = primary.split('/')[0] || '';
|
|
3220
3221
|
|
|
3221
|
-
const
|
|
3222
|
+
const KNOWN_PROVIDERS = {
|
|
3223
|
+
'claude-yunyi': 'Claude(包月)',
|
|
3224
|
+
'yunyi': 'Codex(包月)',
|
|
3225
|
+
'heibai': 'MAXAPI(按量)',
|
|
3226
|
+
};
|
|
3222
3227
|
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
+
const parts = [];
|
|
3229
|
+
let otherCount = 0;
|
|
3230
|
+
for (const p of providers) {
|
|
3231
|
+
if (KNOWN_PROVIDERS[p]) {
|
|
3232
|
+
const label = KNOWN_PROVIDERS[p];
|
|
3233
|
+
const isActive = p === primaryProvider;
|
|
3234
|
+
parts.push(isActive ? chalk.green(`${label} ✓`) : chalk.yellow(`${label} ○`));
|
|
3235
|
+
} else if (p === primaryProvider) {
|
|
3236
|
+
// 未知 provider 但是当前主力,显示名称
|
|
3237
|
+
parts.push(chalk.green(`${p} ✓`));
|
|
3238
|
+
} else {
|
|
3239
|
+
otherCount++;
|
|
3240
|
+
}
|
|
3228
3241
|
}
|
|
3229
3242
|
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
if (hasCodex) {
|
|
3233
|
-
const isActive = primary.includes('codex') || primary.includes('gpt');
|
|
3234
|
-
parts.push(isActive ? chalk.green('Codex ✓') : chalk.yellow('Codex ○'));
|
|
3243
|
+
if (otherCount > 0) {
|
|
3244
|
+
parts.push(chalk.gray(`+${otherCount} 其他`));
|
|
3235
3245
|
}
|
|
3236
3246
|
|
|
3237
|
-
if (parts.length === 0) {
|
|
3247
|
+
if (parts.length === 0 && otherCount === 0) {
|
|
3238
3248
|
return chalk.gray('当前状态: 未配置任何模型');
|
|
3239
3249
|
}
|
|
3240
3250
|
|
|
3251
|
+
const primaryModelId = primary.split('/')[1] || '';
|
|
3252
|
+
const modelTag = primaryModelId ? chalk.cyan(` [模型: ${primaryModelId}]`) : '';
|
|
3253
|
+
|
|
3241
3254
|
const gwEnv = detectGatewayEnv();
|
|
3242
3255
|
const envTag = gwEnv === 'wsl' ? chalk.cyan(' [WSL]') : '';
|
|
3243
|
-
return chalk.gray('当前状态: ') + parts.join(' ') + chalk.gray(' (✓ 主模型 ○ 已配置)') + envTag;
|
|
3256
|
+
return chalk.gray('当前状态: ') + parts.join(' ') + chalk.gray(' (✓ 主模型 ○ 已配置)') + modelTag + envTag;
|
|
3244
3257
|
} catch {
|
|
3245
3258
|
return null;
|
|
3246
3259
|
}
|
|
@@ -3501,10 +3514,27 @@ async function testConnection(paths, args = {}) {
|
|
|
3501
3514
|
}
|
|
3502
3515
|
|
|
3503
3516
|
// 检查当前激活的是哪个
|
|
3504
|
-
|
|
3517
|
+
let primary = config.agents?.defaults?.model?.primary || '';
|
|
3505
3518
|
if (!primary.includes('/')) {
|
|
3506
|
-
|
|
3507
|
-
|
|
3519
|
+
// primary 未设置,尝试从已有 provider 自动选择
|
|
3520
|
+
const providers = config.models?.providers || {};
|
|
3521
|
+
const providerNames = Object.keys(providers);
|
|
3522
|
+
if (providerNames.length === 0) {
|
|
3523
|
+
console.log(chalk.yellow('⚠️ 请先设置主模型'));
|
|
3524
|
+
return;
|
|
3525
|
+
}
|
|
3526
|
+
// 优先选云翼/maxapi provider
|
|
3527
|
+
const preferOrder = ['claude-yunyi', 'yunyi', 'heibai'];
|
|
3528
|
+
const preferred = preferOrder.find(n => providerNames.includes(n));
|
|
3529
|
+
const firstP = preferred || providerNames.find(n => n.includes('claude')) || providerNames[0];
|
|
3530
|
+
const firstModels = providers[firstP]?.models || [];
|
|
3531
|
+
if (firstModels.length > 0) {
|
|
3532
|
+
primary = `${firstP}/${firstModels[0].id}`;
|
|
3533
|
+
console.log(chalk.yellow(`⚠️ 主模型未设置,自动使用: ${primary}`));
|
|
3534
|
+
} else {
|
|
3535
|
+
console.log(chalk.yellow('⚠️ 请先设置主模型'));
|
|
3536
|
+
return;
|
|
3537
|
+
}
|
|
3508
3538
|
}
|
|
3509
3539
|
|
|
3510
3540
|
const providerName = primary.split('/')[0];
|