yymaxapi 1.0.46 → 1.0.47

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.
Files changed (2) hide show
  1. package/bin/yymaxapi.js +34 -17
  2. package/package.json +1 -1
package/bin/yymaxapi.js CHANGED
@@ -3217,30 +3217,31 @@ 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 parts = [];
3222
-
3223
- // 检查 Claude
3224
- const hasClaude = providers.some(p => p.includes('claude') || p.includes('yunyi-claude'));
3225
- if (hasClaude) {
3226
- const isActive = primary.includes('claude');
3227
- parts.push(isActive ? chalk.green('Claude ✓') : chalk.yellow('Claude ○'));
3228
- }
3222
+ const PROVIDER_LABELS = {
3223
+ 'claude-yunyi': 'Claude(包月)',
3224
+ 'yunyi': 'Codex(包月)',
3225
+ 'heibai': 'MAXAPI(按量)',
3226
+ };
3229
3227
 
3230
- // 检查 Codex/GPT
3231
- const hasCodex = providers.some(p => p.includes('codex') || p.includes('gpt') || p.includes('yunyi-codex'));
3232
- if (hasCodex) {
3233
- const isActive = primary.includes('codex') || primary.includes('gpt');
3234
- parts.push(isActive ? chalk.green('Codex ✓') : chalk.yellow('Codex ○'));
3228
+ const parts = [];
3229
+ for (const p of providers) {
3230
+ const label = PROVIDER_LABELS[p] || p;
3231
+ const isActive = p === primaryProvider;
3232
+ parts.push(isActive ? chalk.green(`${label} ✓`) : chalk.yellow(`${label} ○`));
3235
3233
  }
3236
3234
 
3237
3235
  if (parts.length === 0) {
3238
3236
  return chalk.gray('当前状态: 未配置任何模型');
3239
3237
  }
3240
3238
 
3239
+ const primaryModelId = primary.split('/')[1] || '';
3240
+ const modelTag = primaryModelId ? chalk.cyan(` [模型: ${primaryModelId}]`) : '';
3241
+
3241
3242
  const gwEnv = detectGatewayEnv();
3242
3243
  const envTag = gwEnv === 'wsl' ? chalk.cyan(' [WSL]') : '';
3243
- return chalk.gray('当前状态: ') + parts.join(' ') + chalk.gray(' (✓ 主模型 ○ 已配置)') + envTag;
3244
+ return chalk.gray('当前状态: ') + parts.join(' ') + chalk.gray(' (✓ 主模型 ○ 已配置)') + modelTag + envTag;
3244
3245
  } catch {
3245
3246
  return null;
3246
3247
  }
@@ -3501,10 +3502,26 @@ async function testConnection(paths, args = {}) {
3501
3502
  }
3502
3503
 
3503
3504
  // 检查当前激活的是哪个
3504
- const primary = config.agents?.defaults?.model?.primary || '';
3505
+ let primary = config.agents?.defaults?.model?.primary || '';
3505
3506
  if (!primary.includes('/')) {
3506
- console.log(chalk.yellow('⚠️ 请先设置主模型'));
3507
- return;
3507
+ // primary 未设置,尝试从已有 provider 自动选择
3508
+ const providers = config.models?.providers || {};
3509
+ const providerNames = Object.keys(providers);
3510
+ if (providerNames.length === 0) {
3511
+ console.log(chalk.yellow('⚠️ 请先设置主模型'));
3512
+ return;
3513
+ }
3514
+ // 优先选 claude provider
3515
+ const claudeP = providerNames.find(n => n.includes('claude'));
3516
+ const firstP = claudeP || providerNames[0];
3517
+ const firstModels = providers[firstP]?.models || [];
3518
+ if (firstModels.length > 0) {
3519
+ primary = `${firstP}/${firstModels[0].id}`;
3520
+ console.log(chalk.yellow(`⚠️ 主模型未设置,自动使用: ${primary}`));
3521
+ } else {
3522
+ console.log(chalk.yellow('⚠️ 请先设置主模型'));
3523
+ return;
3524
+ }
3508
3525
  }
3509
3526
 
3510
3527
  const providerName = primary.split('/')[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yymaxapi",
3
- "version": "1.0.46",
3
+ "version": "1.0.47",
4
4
  "description": "跨平台 OpenClaw/Clawdbot 配置管理工具 - 管理中转地址、模型切换、API Keys、测速优化",
5
5
  "main": "bin/yymaxapi.js",
6
6
  "bin": {