yymaxapi 1.0.86 → 1.0.87

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 +21 -73
  2. package/package.json +1 -1
package/bin/yymaxapi.js CHANGED
@@ -2368,13 +2368,10 @@ function applyManagedYunyiOpenClawLayout(config, options = {}) {
2368
2368
 
2369
2369
  function printYunyiOpenClawSwitchHint(result = {}) {
2370
2370
  if (!result?.applied) return;
2371
- if (result.preservedMain && result.claudeAgentId === YYMAXAPI_OPENCLAW_ALT_CLAUDE_AGENT_ID) {
2372
- console.log(chalk.gray(' 已保留你现有的 main;Yunyi Claude 入口为 yunyi-claude'));
2373
- } else {
2374
- console.log(chalk.gray(' 默认主入口是 yunyi-claude'));
2375
- }
2376
- console.log(chalk.gray(' GPT 入口是 yunyi-gpt'));
2377
- console.log(chalk.yellow(' 提示: 当前 OpenClaw Web 顶部模型下拉跨 provider 切换可能报错,建议通过左侧会话/agent 切换 Claude 和 GPT'));
2371
+ const summary = result.preservedMain && result.claudeAgentId === YYMAXAPI_OPENCLAW_ALT_CLAUDE_AGENT_ID
2372
+ ? 'OpenClaw: main 已保留, Claude=yunyi-claude, GPT=yunyi-gpt'
2373
+ : 'OpenClaw: main=yunyi-claude, GPT=yunyi-gpt';
2374
+ console.log(chalk.cyan(` ${summary}`));
2378
2375
  }
2379
2376
 
2380
2377
  function pruneProvidersByPrefix(config, prefixBase, keepProviders = []) {
@@ -3948,17 +3945,13 @@ async function presetClaude(paths, args = {}) {
3948
3945
  updateAuthProfilesWithSync(paths, YYMAXAPI_OPENCLAW_CLAUDE_PROVIDER, apiKey);
3949
3946
  updateAuthProfilesWithSync(paths, YYMAXAPI_OPENCLAW_GPT_PROVIDER, apiKey);
3950
3947
  }
3951
- const extSynced = syncExternalTools('claude', baseUrl, apiKey, { claudeModelId: modelId, opencodeDefaultModelKey: `yunyi-claude/${modelId}` });
3948
+ syncExternalTools('claude', baseUrl, apiKey, { claudeModelId: modelId, opencodeDefaultModelKey: `yunyi-claude/${modelId}` });
3952
3949
  writeSpinner.succeed('配置写入完成');
3953
3950
 
3954
3951
  console.log(chalk.green('\n✅ Claude 节点配置完成!'));
3955
- const tag = setPrimary ? ' (主)' : '';
3956
- console.log(chalk.cyan(` ${providerName}${tag}: ${buildFullUrl(selectedEndpoint.url, 'claude')}`));
3957
- console.log(chalk.gray(` 模型: ${modelName}`));
3958
- console.log(chalk.gray(' API Key: 已设置'));
3959
- if (extSynced.length > 0) console.log(chalk.gray(` 同步: ${extSynced.join(', ')}`));
3952
+ console.log(chalk.cyan(` Claude: ${modelName}`));
3960
3953
  if (repairResult.renamedProviders.length > 0) {
3961
- console.log(chalk.gray(` 已保留并修复冲突 provider: ${repairResult.renamedProviders.map(item => `${item.from}→${item.to}`).join(', ')}`));
3954
+ console.log(chalk.cyan(` 已修复 provider 冲突: ${repairResult.renamedProviders.map(item => `${item.from}→${item.to}`).join(', ')}`));
3962
3955
  }
3963
3956
  printYunyiOpenClawSwitchHint(yunyiLayoutResult);
3964
3957
 
@@ -4135,17 +4128,13 @@ async function presetCodex(paths, args = {}) {
4135
4128
  updateAuthProfilesWithSync(paths, YYMAXAPI_OPENCLAW_CLAUDE_PROVIDER, apiKey);
4136
4129
  updateAuthProfilesWithSync(paths, YYMAXAPI_OPENCLAW_GPT_PROVIDER, apiKey);
4137
4130
  }
4138
- const extSynced2 = syncExternalTools('codex', baseUrl, apiKey, { modelId });
4131
+ syncExternalTools('codex', baseUrl, apiKey, { modelId });
4139
4132
  writeSpinner2.succeed('配置写入完成');
4140
4133
 
4141
4134
  console.log(chalk.green('\n✅ Codex 节点配置完成!'));
4142
- const tag = setPrimary ? ' (主)' : '';
4143
- console.log(chalk.cyan(` ${providerName}${tag}: ${baseUrl}`));
4144
- console.log(chalk.gray(` 模型: ${modelName}`));
4145
- console.log(chalk.gray(' API Key: 已设置'));
4146
- if (extSynced2.length > 0) console.log(chalk.gray(` 同步: ${extSynced2.join(', ')}`));
4135
+ console.log(chalk.cyan(` Codex: ${modelName}`));
4147
4136
  if (repairResult.renamedProviders.length > 0) {
4148
- console.log(chalk.gray(` 已保留并修复冲突 provider: ${repairResult.renamedProviders.map(item => `${item.from}→${item.to}`).join(', ')}`));
4137
+ console.log(chalk.cyan(` 已修复 provider 冲突: ${repairResult.renamedProviders.map(item => `${item.from}→${item.to}`).join(', ')}`));
4149
4138
  }
4150
4139
  printYunyiOpenClawSwitchHint(yunyiLayoutResult);
4151
4140
 
@@ -4330,22 +4319,15 @@ async function autoActivate(paths, args = {}) {
4330
4319
  writeConfigWithSync(paths, config);
4331
4320
  updateAuthProfilesWithSync(paths, claudeProviderName, apiKey);
4332
4321
  updateAuthProfilesWithSync(paths, codexProviderName, apiKey);
4333
- const extSynced = [];
4334
4322
  const opencodeDefaultModelKey = isClaudePrimary ? `yunyi-claude/${claudeModelId}` : `yunyi-codex/${codexModelId}`;
4335
- try { extSynced.push(...syncExternalTools('claude', claudeBaseUrl, apiKey, { codexBaseUrl, claudeModelId, opencodeDefaultModelKey })); } catch { /* ignore */ }
4336
- try { extSynced.push(...syncExternalTools('codex', codexBaseUrl, apiKey, { modelId: codexModelId })); } catch { /* ignore */ }
4323
+ try { syncExternalTools('claude', claudeBaseUrl, apiKey, { codexBaseUrl, claudeModelId, opencodeDefaultModelKey }); } catch { /* ignore */ }
4324
+ try { syncExternalTools('codex', codexBaseUrl, apiKey, { modelId: codexModelId }); } catch { /* ignore */ }
4337
4325
  writeSpinner.succeed('配置写入完成');
4338
4326
 
4339
4327
  // ---- 输出结果 ----
4340
- const primaryLabel = isClaudePrimary ? 'Claude' : 'GPT';
4341
4328
  const selectedModel = isClaudePrimary ? claudeModel : codexModel;
4342
4329
  console.log(chalk.green('\n✅ 配置完成!'));
4343
- console.log(chalk.cyan(` 外部工具默认: ${selectedModel.name} (${primaryLabel})`));
4344
- console.log(chalk.gray(` 节点: ${selectedEndpoint.url} (${selectedEndpoint.name})`));
4345
- console.log(chalk.gray(' API Key: 已设置'));
4346
- if (extSynced.length > 0) console.log(chalk.gray(` 同步: ${extSynced.join(', ')}`));
4347
- console.log(chalk.gray(' 若遇 certificate 报错,请新开终端或执行 source ~/.zshrc 后重试(已放宽 TLS 校验)'));
4348
- console.log(chalk.gray(` 使用 OpenCode 时可在界面中切换 ${getOpencodeSwitchHint()};Codex 仅支持 GPT`));
4330
+ console.log(chalk.cyan(` 外部工具默认: ${selectedModel.name}`));
4349
4331
  printYunyiOpenClawSwitchHint(yunyiLayoutResult);
4350
4332
 
4351
4333
  const gwPort = config.gateway?.port || 18789;
@@ -4790,12 +4772,8 @@ async function yycodeQuickSetup(paths) {
4790
4772
 
4791
4773
  // ---- 结果 ----
4792
4774
  console.log(chalk.green('\n✅ 配置完成!'));
4793
- console.log(chalk.cyan(` Claude Code: ${claudeBaseUrl}`));
4794
- console.log(chalk.gray(` 模型: ${claudeModel.name}`));
4795
- console.log(chalk.cyan(` Codex CLI: ${codexBaseUrl}`));
4796
- console.log(chalk.gray(` 模型: ${codexModel.name}`));
4797
- console.log(chalk.gray(' API Key: 已设置'));
4798
- console.log(chalk.gray(' 同步: Claude Code settings, Opencode config, Codex CLI config'));
4775
+ console.log(chalk.cyan(` Claude Code: ${claudeModel.name}`));
4776
+ console.log(chalk.cyan(` Codex CLI: ${codexModel.name}`));
4799
4777
  printYunyiOpenClawSwitchHint(yunyiLayoutResult);
4800
4778
  console.log('');
4801
4779
  }
@@ -5072,9 +5050,7 @@ async function selectNode(paths, type) {
5072
5050
  if (managedGptKey) updateAuthProfilesWithSync(paths, YYMAXAPI_OPENCLAW_GPT_PROVIDER, managedGptKey);
5073
5051
 
5074
5052
  console.log(chalk.green(`\n✅ ${typeLabel} 节点配置完成!`));
5075
- console.log(chalk.cyan(` 节点: ${selectedEndpoint.name} (${selectedEndpoint.url})`));
5076
- console.log(chalk.gray(` 模型: ${modelConfig.name} (主模型)`));
5077
- console.log(chalk.gray(` API Key: ${oldApiKey ? '已设置' : '未设置'}`));
5053
+ console.log(chalk.cyan(` ${typeLabel}: ${modelConfig.name}`));
5078
5054
  printYunyiOpenClawSwitchHint(yunyiLayoutResult);
5079
5055
  }
5080
5056
 
@@ -5129,9 +5105,7 @@ async function activate(paths, type) {
5129
5105
  writeAuthStore(paths.authProfiles, authStore);
5130
5106
 
5131
5107
  console.log(chalk.green(`\n✅ 已激活 ${typeLabel}`));
5132
- console.log(chalk.cyan(` 节点: ${provider.baseUrl}`));
5133
- console.log(chalk.gray(` 模型: ${modelConfig.name}`));
5134
- console.log(chalk.gray(` API Key: 已设置`));
5108
+ console.log(chalk.cyan(` ${typeLabel}: ${modelConfig.name}`));
5135
5109
  printYunyiOpenClawSwitchHint(yunyiLayoutResult);
5136
5110
  }
5137
5111
 
@@ -5438,16 +5412,11 @@ async function testConnection(paths, args = {}) {
5438
5412
  // 获取 Gateway 配置
5439
5413
  const gatewayPort = config.gateway?.port || 18789;
5440
5414
 
5441
- console.log(chalk.gray(`当前测试: ${typeLabel}`));
5415
+ console.log(chalk.cyan(`当前测试: ${typeLabel}`));
5442
5416
  if (testTarget.agentId) {
5443
- console.log(chalk.gray(`测试入口: ${testTarget.agentId}${testTarget.agentName ? ` (${testTarget.agentName})` : ''}`));
5444
- }
5445
- if (testTarget.agentId && testTarget.defaultPrimary && testTarget.defaultPrimary !== primary) {
5446
- console.log(chalk.gray(`默认主入口: ${testTarget.defaultPrimary}`));
5417
+ console.log(chalk.cyan(`测试入口: ${testTarget.agentId}${testTarget.agentName ? ` (${testTarget.agentName})` : ''}`));
5447
5418
  }
5448
- console.log(chalk.gray(`中转节点: ${provider.baseUrl}`));
5449
- console.log(chalk.gray(`模型: ${primary}`));
5450
- console.log(chalk.gray(`Gateway: http://127.0.0.1:${gatewayPort}\n`));
5419
+ console.log(chalk.cyan(`模型: ${primary}\n`));
5451
5420
  // 获取 Gateway token
5452
5421
  const gatewayToken = config.gateway?.auth?.token;
5453
5422
  if (!gatewayToken) {
@@ -5574,17 +5543,6 @@ async function testConnection(paths, args = {}) {
5574
5543
  console.log(chalk.cyan(` Provider: ${cliResult.provider}`));
5575
5544
  console.log(chalk.cyan(` Model: ${cliResult.model}`));
5576
5545
  }
5577
- if (cliResult.message) {
5578
- const reply = sanitizeModelReply(cliResult.message, {
5579
- provider: cliResult.provider,
5580
- model: cliResult.model,
5581
- modelKey: primary
5582
- });
5583
- console.log(chalk.yellow(` 模型回复: ${reply}`));
5584
- }
5585
- if (!isFallback) {
5586
- console.log(chalk.gray(' 将继续验证 Web 鉴权端点(避免"CLI 正常但网页 401")...'));
5587
- }
5588
5546
  }
5589
5547
  }
5590
5548
 
@@ -5615,7 +5573,6 @@ async function testConnection(paths, args = {}) {
5615
5573
  const primaryApi = config.models?.providers?.[primaryProvider]?.api || '';
5616
5574
  const isAnthropic = primaryApi.startsWith('anthropic');
5617
5575
  const testEndpoint = isAnthropic ? '/v1/messages' : '/v1/chat/completions';
5618
- console.log(chalk.gray(` 端点: http://127.0.0.1:${gatewayPort}${testEndpoint}`));
5619
5576
  const startTime = Date.now();
5620
5577
  let result = await testGatewayApi(gatewayPort, gatewayToken, primary, testEndpoint);
5621
5578
  const latency = Date.now() - startTime;
@@ -5623,26 +5580,17 @@ async function testConnection(paths, args = {}) {
5623
5580
  // 回退:如果首选端点返回 404/405,尝试另一个
5624
5581
  if (!result.success && result.reachable && [404, 405].includes(result.status)) {
5625
5582
  const fallbackEndpoint = isAnthropic ? '/v1/chat/completions' : '/v1/responses';
5626
- console.log(chalk.gray(` ${testEndpoint} 不支持,回退测试 ${fallbackEndpoint}...`));
5627
5583
  result = await testGatewayApi(gatewayPort, gatewayToken, primary, fallbackEndpoint);
5628
5584
  }
5629
5585
 
5630
5586
  // CLI 对话已成功 + Gateway 可达(404/405)= Dashboard 通过 WebSocket 工作,视为通过
5631
5587
  if (!result.success && cliPassed && result.reachable && [404, 405].includes(result.status)) {
5632
5588
  console.log(chalk.green(`\n✅ Gateway 测试通过`));
5633
- console.log(chalk.cyan(` CLI 对话正常,Gateway 可达`));
5634
- console.log(chalk.gray(` 注: Gateway Dashboard 通过 WebSocket 通信,REST 端点返回 405 属正常现象`));
5635
5589
  console.log(chalk.green(`\n🌐 Web Dashboard 访问地址:`));
5636
5590
  console.log(chalk.cyan(` http://127.0.0.1:${gatewayPort}/#token=${gatewayToken}`));
5637
5591
  } else if (result.success) {
5638
- console.log(chalk.green(`\n✅ Gateway 测试成功!Web Dashboard 可正常使用`));
5592
+ console.log(chalk.green(`\n✅ Gateway 测试通过`));
5639
5593
  console.log(chalk.cyan(` 响应时间: ${latency}ms`));
5640
- const reply = sanitizeModelReply(result.message, {
5641
- provider: providerName,
5642
- model: primary.includes('/') ? primary.split('/')[1] : '',
5643
- modelKey: primary
5644
- });
5645
- console.log(chalk.yellow(` 模型回复: ${reply}`));
5646
5594
  console.log(chalk.green(`\n🌐 Web Dashboard 访问地址:`));
5647
5595
  console.log(chalk.cyan(` http://127.0.0.1:${gatewayPort}/#token=${gatewayToken}`));
5648
5596
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yymaxapi",
3
- "version": "1.0.86",
3
+ "version": "1.0.87",
4
4
  "description": "跨平台 OpenClaw/Clawdbot 配置管理工具 - 管理中转地址、模型切换、API Keys、测速优化",
5
5
  "main": "bin/yymaxapi.js",
6
6
  "bin": {