yymaxapi 1.0.0 → 1.0.1
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 +54 -8
- package/package.json +1 -1
package/bin/yymaxapi.js
CHANGED
|
@@ -1454,10 +1454,25 @@ async function presetClaude(paths, args = {}) {
|
|
|
1454
1454
|
console.log(chalk.cyan('📡 开始测速 Claude 节点...\n'));
|
|
1455
1455
|
const speedResult = await testAllEndpoints(ENDPOINTS, { autoFallback: true });
|
|
1456
1456
|
|
|
1457
|
-
|
|
1458
|
-
|
|
1457
|
+
const sorted = speedResult.ranked || [];
|
|
1458
|
+
if (sorted.length > 0) {
|
|
1459
|
+
const { selectedIndex } = await inquirer.prompt([{
|
|
1460
|
+
type: 'list',
|
|
1461
|
+
name: 'selectedIndex',
|
|
1462
|
+
message: '选择节点:',
|
|
1463
|
+
choices: [
|
|
1464
|
+
{ name: `🚀 使用推荐节点 (${sorted[0].name}, ${sorted[0].latency}ms, 评分:${sorted[0].score})`, value: -1 },
|
|
1465
|
+
new inquirer.Separator('--- 或手动选择 ---'),
|
|
1466
|
+
...sorted.map((e, i) => ({
|
|
1467
|
+
name: `${e.name} - ${e.latency}ms (评分:${e.score})`,
|
|
1468
|
+
value: i
|
|
1469
|
+
}))
|
|
1470
|
+
]
|
|
1471
|
+
}]);
|
|
1472
|
+
const primaryIndex = selectedIndex === -1 ? 0 : selectedIndex;
|
|
1473
|
+
selectedEndpoint = sorted[primaryIndex];
|
|
1459
1474
|
if (speedResult.usedFallback) {
|
|
1460
|
-
console.log(chalk.yellow(`\n⚠
|
|
1475
|
+
console.log(chalk.yellow(`\n⚠ 当前使用备用节点\n`));
|
|
1461
1476
|
}
|
|
1462
1477
|
} else {
|
|
1463
1478
|
console.log(chalk.red('\n⚠️ 所有节点(含备用)均不可达'));
|
|
@@ -1633,10 +1648,25 @@ async function presetCodex(paths, args = {}) {
|
|
|
1633
1648
|
console.log(chalk.cyan('📡 开始测速 Codex 节点...\n'));
|
|
1634
1649
|
const speedResult = await testAllEndpoints(ENDPOINTS, { autoFallback: true });
|
|
1635
1650
|
|
|
1636
|
-
|
|
1637
|
-
|
|
1651
|
+
const sorted = speedResult.ranked || [];
|
|
1652
|
+
if (sorted.length > 0) {
|
|
1653
|
+
const { selectedIndex } = await inquirer.prompt([{
|
|
1654
|
+
type: 'list',
|
|
1655
|
+
name: 'selectedIndex',
|
|
1656
|
+
message: '选择节点:',
|
|
1657
|
+
choices: [
|
|
1658
|
+
{ name: `🚀 使用推荐节点 (${sorted[0].name}, ${sorted[0].latency}ms, 评分:${sorted[0].score})`, value: -1 },
|
|
1659
|
+
new inquirer.Separator('--- 或手动选择 ---'),
|
|
1660
|
+
...sorted.map((e, i) => ({
|
|
1661
|
+
name: `${e.name} - ${e.latency}ms (评分:${e.score})`,
|
|
1662
|
+
value: i
|
|
1663
|
+
}))
|
|
1664
|
+
]
|
|
1665
|
+
}]);
|
|
1666
|
+
const primaryIndex = selectedIndex === -1 ? 0 : selectedIndex;
|
|
1667
|
+
selectedEndpoint = sorted[primaryIndex];
|
|
1638
1668
|
if (speedResult.usedFallback) {
|
|
1639
|
-
console.log(chalk.yellow(`\n⚠
|
|
1669
|
+
console.log(chalk.yellow(`\n⚠ 当前使用备用节点\n`));
|
|
1640
1670
|
}
|
|
1641
1671
|
} else {
|
|
1642
1672
|
console.log(chalk.red('\n⚠️ 所有节点(含备用)均不可达'));
|
|
@@ -2109,6 +2139,21 @@ async function testConnection(paths, args = {}) {
|
|
|
2109
2139
|
|
|
2110
2140
|
const allowAutoDaemon = !(args['no-daemon'] || args.noDaemon);
|
|
2111
2141
|
|
|
2142
|
+
// 步骤0: 清理可能挂死的 agent 进程
|
|
2143
|
+
try {
|
|
2144
|
+
const { execSync } = require('child_process');
|
|
2145
|
+
const platform = process.platform;
|
|
2146
|
+
if (platform === 'win32') {
|
|
2147
|
+
execSync('taskkill /F /FI "WINDOWTITLE eq openclaw*" /FI "STATUS eq Not Responding" 2>nul', { stdio: 'ignore' });
|
|
2148
|
+
} else {
|
|
2149
|
+
// 杀掉所有挂死的 openclaw agent 子进程(排除 gateway 主进程)
|
|
2150
|
+
execSync("pkill -f 'openclaw.*agent.*yymaxapi-test' 2>/dev/null || true", { stdio: 'ignore' });
|
|
2151
|
+
execSync("pkill -f 'clawdbot.*agent.*yymaxapi-test' 2>/dev/null || true", { stdio: 'ignore' });
|
|
2152
|
+
execSync("pkill -f 'moltbot.*agent.*yymaxapi-test' 2>/dev/null || true", { stdio: 'ignore' });
|
|
2153
|
+
}
|
|
2154
|
+
console.log(chalk.gray('🧹 已清理残留 agent 进程'));
|
|
2155
|
+
} catch { /* ignore */ }
|
|
2156
|
+
|
|
2112
2157
|
// 步骤1: 先重启 Gateway 使配置生效
|
|
2113
2158
|
console.log(chalk.cyan('步骤 1/2: 重启 Gateway 使配置生效...'));
|
|
2114
2159
|
await restartGateway();
|
|
@@ -2400,9 +2445,10 @@ function testGatewayViaAgent(model) {
|
|
|
2400
2445
|
delete env.OPENAI_API_KEY;
|
|
2401
2446
|
delete env.OPENCLAW_CODEX_KEY;
|
|
2402
2447
|
const useNode = nodeInfo && isNodeShebang(cliBinary);
|
|
2448
|
+
const sessionId = `yymaxapi-test-${Date.now()}`;
|
|
2403
2449
|
const cmd = useNode
|
|
2404
|
-
? `"${nodeInfo.path}" "${cliBinary}" agent --session-id
|
|
2405
|
-
: `"${cliBinary}" agent --session-id
|
|
2450
|
+
? `"${nodeInfo.path}" "${cliBinary}" agent --session-id ${sessionId} --message "请回复你的模型名称" --json --timeout 120`
|
|
2451
|
+
: `"${cliBinary}" agent --session-id ${sessionId} --message "请回复你的模型名称" --json --timeout 120`;
|
|
2406
2452
|
|
|
2407
2453
|
exec(cmd, { timeout: 120000, env }, (error, stdout, stderr) => {
|
|
2408
2454
|
// 过滤 stderr 中的 Node.js DeprecationWarning 噪音
|