yymaxapi 1.0.3 → 1.0.4
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 +114 -24
- package/package.json +3 -4
package/bin/yymaxapi.js
CHANGED
|
@@ -56,44 +56,77 @@ function safeExec(cmd, options = {}) {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
// ============ 预设 (
|
|
59
|
+
// ============ 预设 (由 build.js 从 provider config 生成) ============
|
|
60
60
|
const DEFAULT_ENDPOINTS = [
|
|
61
|
-
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
{
|
|
62
|
+
"name": "国内主节点",
|
|
63
|
+
"url": "https://yunyi.rdzhvip.com"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "CF国外节点1",
|
|
67
|
+
"url": "https://yunyi.cfd"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "CF国外节点2",
|
|
71
|
+
"url": "https://cdn1.yunyi.cfd"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": "CF国外节点3",
|
|
75
|
+
"url": "https://cdn2.yunyi.cfd"
|
|
76
|
+
}
|
|
65
77
|
];
|
|
66
78
|
|
|
67
79
|
const FALLBACK_ENDPOINTS = [
|
|
68
|
-
{
|
|
69
|
-
|
|
80
|
+
{
|
|
81
|
+
"name": "备用节点1",
|
|
82
|
+
"url": "http://47.99.42.193"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"name": "备用节点2",
|
|
86
|
+
"url": "http://47.97.100.10"
|
|
87
|
+
}
|
|
70
88
|
];
|
|
71
89
|
|
|
72
90
|
const DEFAULT_CLAUDE_MODELS = [
|
|
73
|
-
{
|
|
74
|
-
|
|
75
|
-
|
|
91
|
+
{
|
|
92
|
+
"id": "claude-opus-4-6",
|
|
93
|
+
"name": "Claude Opus 4.6"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"id": "claude-sonnet-4-5",
|
|
97
|
+
"name": "Claude Sonnet 4.5"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"id": "claude-haiku-4-5",
|
|
101
|
+
"name": "Claude Haiku 4.5"
|
|
102
|
+
}
|
|
76
103
|
];
|
|
77
104
|
|
|
78
105
|
const DEFAULT_CODEX_MODELS = [
|
|
79
|
-
{
|
|
80
|
-
|
|
106
|
+
{
|
|
107
|
+
"id": "gpt-5.3-codex",
|
|
108
|
+
"name": "GPT 5.3 Codex"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"id": "gpt-5.2",
|
|
112
|
+
"name": "GPT 5.2"
|
|
113
|
+
}
|
|
81
114
|
];
|
|
82
115
|
|
|
83
116
|
const DEFAULT_API_CONFIG = {
|
|
84
|
-
claude: {
|
|
85
|
-
urlSuffix:
|
|
86
|
-
api:
|
|
87
|
-
contextWindow: 200000,
|
|
88
|
-
maxTokens: 8192,
|
|
89
|
-
providerName:
|
|
117
|
+
"claude": {
|
|
118
|
+
"urlSuffix": "/claude",
|
|
119
|
+
"api": "anthropic-messages",
|
|
120
|
+
"contextWindow": 200000,
|
|
121
|
+
"maxTokens": 8192,
|
|
122
|
+
"providerName": "claude-yunyi"
|
|
90
123
|
},
|
|
91
|
-
codex: {
|
|
92
|
-
urlSuffix:
|
|
93
|
-
api:
|
|
94
|
-
contextWindow: 128000,
|
|
95
|
-
maxTokens: 32768,
|
|
96
|
-
providerName:
|
|
124
|
+
"codex": {
|
|
125
|
+
"urlSuffix": "/codex",
|
|
126
|
+
"api": "openai-responses",
|
|
127
|
+
"contextWindow": 128000,
|
|
128
|
+
"maxTokens": 32768,
|
|
129
|
+
"providerName": "yunyi"
|
|
97
130
|
}
|
|
98
131
|
};
|
|
99
132
|
|
|
@@ -1891,6 +1924,8 @@ async function main() {
|
|
|
1891
1924
|
{ name: '→ 测试连接', value: 'test_connection' },
|
|
1892
1925
|
{ name: '→ 查看配置', value: 'view_config' },
|
|
1893
1926
|
{ name: '→ 恢复默认', value: 'restore' },
|
|
1927
|
+
new inquirer.Separator(chalk.gray('── 安装 ──')),
|
|
1928
|
+
{ name: '📦 安装/更新 OpenClaw', value: 'install_openclaw' },
|
|
1894
1929
|
new inquirer.Separator(''),
|
|
1895
1930
|
{ name: chalk.gray('退出'), value: 'exit' }
|
|
1896
1931
|
]
|
|
@@ -1920,6 +1955,9 @@ async function main() {
|
|
|
1920
1955
|
case 'restore':
|
|
1921
1956
|
await restore(paths);
|
|
1922
1957
|
break;
|
|
1958
|
+
case 'install_openclaw':
|
|
1959
|
+
await installOrUpdateOpenClaw();
|
|
1960
|
+
break;
|
|
1923
1961
|
}
|
|
1924
1962
|
} catch (error) {
|
|
1925
1963
|
console.log(chalk.red(`\n错误: ${error.message}\n`));
|
|
@@ -2760,6 +2798,58 @@ async function viewConfig(paths) {
|
|
|
2760
2798
|
console.log(` ${fs.existsSync(backupPath) ? chalk.green('✓ 已备份') : chalk.gray('未备份')}`);
|
|
2761
2799
|
}
|
|
2762
2800
|
|
|
2801
|
+
// ============ 安装/更新 OpenClaw ============
|
|
2802
|
+
async function installOrUpdateOpenClaw() {
|
|
2803
|
+
// 检测当前版本
|
|
2804
|
+
const { cliBinary } = getCliMeta();
|
|
2805
|
+
let currentVersion = null;
|
|
2806
|
+
if (cliBinary) {
|
|
2807
|
+
const vResult = safeExec(`"${cliBinary}" --version`);
|
|
2808
|
+
if (vResult.ok) currentVersion = vResult.output.trim();
|
|
2809
|
+
}
|
|
2810
|
+
|
|
2811
|
+
if (currentVersion) {
|
|
2812
|
+
console.log(chalk.cyan(`当前版本: ${currentVersion}`));
|
|
2813
|
+
} else {
|
|
2814
|
+
console.log(chalk.yellow('未检测到 OpenClaw 安装'));
|
|
2815
|
+
}
|
|
2816
|
+
|
|
2817
|
+
const actionLabel = currentVersion ? '更新到最新版' : '安装最新版';
|
|
2818
|
+
const { confirm } = await inquirer.prompt([{
|
|
2819
|
+
type: 'confirm',
|
|
2820
|
+
name: 'confirm',
|
|
2821
|
+
message: `${actionLabel} OpenClaw?`,
|
|
2822
|
+
default: true
|
|
2823
|
+
}]);
|
|
2824
|
+
|
|
2825
|
+
if (!confirm) {
|
|
2826
|
+
console.log(chalk.gray('已取消'));
|
|
2827
|
+
return;
|
|
2828
|
+
}
|
|
2829
|
+
|
|
2830
|
+
const spinner = ora({ text: `正在${actionLabel} OpenClaw...`, spinner: 'dots' }).start();
|
|
2831
|
+
|
|
2832
|
+
const isWin = process.platform === 'win32';
|
|
2833
|
+
const cmd = isWin
|
|
2834
|
+
? 'npm install -g openclaw@latest'
|
|
2835
|
+
: 'sudo npm install -g openclaw@latest 2>/dev/null || npm install -g openclaw@latest';
|
|
2836
|
+
|
|
2837
|
+
try {
|
|
2838
|
+
execSync(cmd, { stdio: 'pipe', timeout: 120000 });
|
|
2839
|
+
spinner.succeed(`OpenClaw ${actionLabel}完成`);
|
|
2840
|
+
|
|
2841
|
+
// 显示新版本
|
|
2842
|
+
const newV = safeExec(`${cliBinary || 'openclaw'} --version`);
|
|
2843
|
+
if (newV.ok) {
|
|
2844
|
+
console.log(chalk.green(` 版本: ${newV.output.trim()}`));
|
|
2845
|
+
}
|
|
2846
|
+
} catch (error) {
|
|
2847
|
+
spinner.fail(`${actionLabel}失败`);
|
|
2848
|
+
console.log(chalk.red(` 错误: ${error.message}`));
|
|
2849
|
+
console.log(chalk.gray(' 请手动运行: npm install -g openclaw@latest'));
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2763
2853
|
// ============ 恢复默认配置 ============
|
|
2764
2854
|
async function restore(paths) {
|
|
2765
2855
|
const backupPath = path.join(paths.configDir, BACKUP_FILENAME);
|
package/package.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yymaxapi",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "跨平台 OpenClaw/Clawdbot 配置管理工具 - 管理中转地址、模型切换、API Keys、测速优化",
|
|
5
5
|
"main": "bin/yymaxapi.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"yymaxapi": "bin/yymaxapi.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"start": "node
|
|
11
|
-
"test": "node bin/yymaxapi.js test"
|
|
12
|
-
"feishu:publish": "node scripts/feishu-docx-publish.js"
|
|
10
|
+
"start": "node bin/yymaxapi.js",
|
|
11
|
+
"test": "node bin/yymaxapi.js test"
|
|
13
12
|
},
|
|
14
13
|
"keywords": [
|
|
15
14
|
"openclaw",
|