@aiyiran/myclaw 1.0.60 → 1.0.62
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/inject-minimax.js +43 -45
- package/package.json +1 -1
- package/skills/minimax-inject/scripts/inject.js +42 -31
package/inject-minimax.js
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
*
|
|
6
6
|
* 将 openclaw.json 中的模型配置清空,注入为唯一的 MiniMax 模型。
|
|
7
7
|
* 自动查找 ~/.openclaw/openclaw.json
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
|
+
* 流程:
|
|
10
|
+
* 1. 先执行 openclaw onboard(设置 API Key,会覆盖 JSON)
|
|
11
|
+
* 2. 再写入我们的 JSON 配置(覆盖回来)
|
|
9
12
|
*
|
|
10
13
|
* 入口: myclaw minimax [--key sk-xxx]
|
|
11
14
|
*/
|
|
@@ -37,10 +40,44 @@ function run(cliArgs) {
|
|
|
37
40
|
|
|
38
41
|
console.log('📍 找到配置: ' + targetPath);
|
|
39
42
|
|
|
40
|
-
//
|
|
43
|
+
// ============================================================
|
|
44
|
+
// 第一步:先执行 onboard(它会覆盖 JSON,所以必须先跑)
|
|
45
|
+
// ============================================================
|
|
46
|
+
|
|
47
|
+
if (apiKey) {
|
|
48
|
+
console.log('');
|
|
49
|
+
console.log('🔑 [Step 1] 执行 openclaw onboard (设置 API Key)...');
|
|
50
|
+
try {
|
|
51
|
+
const { execSync } = require('child_process');
|
|
52
|
+
execSync([
|
|
53
|
+
'openclaw onboard',
|
|
54
|
+
'--non-interactive',
|
|
55
|
+
'--accept-risk',
|
|
56
|
+
'--skip-health',
|
|
57
|
+
'--auth-choice minimax-cn-api',
|
|
58
|
+
'--token "' + apiKey + '"',
|
|
59
|
+
'--minimax-api-key "' + apiKey + '"',
|
|
60
|
+
].join(' '), { stdio: 'inherit' });
|
|
61
|
+
console.log('✅ API Key 已通过 onboard 设置');
|
|
62
|
+
} catch (err) {
|
|
63
|
+
console.log('⚠️ onboard 失败 (继续注入 JSON): ' + err.message);
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
console.log('');
|
|
67
|
+
console.log('💡 未传入 --key,跳过 onboard');
|
|
68
|
+
console.log(' 设置方法: myclaw minimax --key sk-xxx');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ============================================================
|
|
72
|
+
// 第二步:写入我们的 JSON 配置(覆盖 onboard 的修改)
|
|
73
|
+
// ============================================================
|
|
74
|
+
|
|
75
|
+
console.log('');
|
|
76
|
+
console.log('📝 [Step 2] 注入 MiniMax 模型配置...');
|
|
77
|
+
|
|
78
|
+
// 重新读取文件(onboard 可能已经改过了)
|
|
41
79
|
const config = JSON.parse(fs.readFileSync(targetPath, 'utf8'));
|
|
42
80
|
|
|
43
|
-
// 1. auth.profiles → 只保留 minimax
|
|
44
81
|
config.auth = {
|
|
45
82
|
profiles: {
|
|
46
83
|
"minimax:cn": {
|
|
@@ -50,7 +87,6 @@ function run(cliArgs) {
|
|
|
50
87
|
}
|
|
51
88
|
};
|
|
52
89
|
|
|
53
|
-
// 2. models.providers → 只保留 minimax(key 由 onboard 管理)
|
|
54
90
|
config.models = {
|
|
55
91
|
mode: "merge",
|
|
56
92
|
providers: {
|
|
@@ -78,7 +114,6 @@ function run(cliArgs) {
|
|
|
78
114
|
}
|
|
79
115
|
};
|
|
80
116
|
|
|
81
|
-
// 3. agents.defaults → 使用 minimax 模型
|
|
82
117
|
if (!config.agents) config.agents = {};
|
|
83
118
|
if (!config.agents.defaults) config.agents.defaults = {};
|
|
84
119
|
|
|
@@ -94,53 +129,16 @@ function run(cliArgs) {
|
|
|
94
129
|
"minimax/MiniMax-M2.7-highspeed": {}
|
|
95
130
|
};
|
|
96
131
|
|
|
97
|
-
// 写回文件
|
|
98
132
|
fs.writeFileSync(targetPath, JSON.stringify(config, null, 2) + '\n', 'utf8');
|
|
99
133
|
|
|
100
134
|
// 验证写入
|
|
101
135
|
const verify = JSON.parse(fs.readFileSync(targetPath, 'utf8'));
|
|
102
136
|
const writtenModelId = verify.models?.providers?.minimax?.models?.[0]?.id || '???';
|
|
103
137
|
const writtenDefault = verify.agents?.defaults?.model?.primary || '???';
|
|
104
|
-
|
|
105
|
-
console.log('✅ MiniMax 模型配置已注入');
|
|
106
|
-
console.log('');
|
|
107
|
-
console.log(' [验证] 写入的 model ID: ' + writtenModelId);
|
|
108
|
-
console.log(' [验证] 写入的 default: ' + writtenDefault);
|
|
109
|
-
console.log(' [验证] 文件路径: ' + targetPath);
|
|
110
138
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
console.log('🔑 执行 openclaw onboard (设置 API Key)...');
|
|
115
|
-
try {
|
|
116
|
-
const { execSync } = require('child_process');
|
|
117
|
-
execSync([
|
|
118
|
-
'openclaw onboard',
|
|
119
|
-
'--non-interactive',
|
|
120
|
-
'--accept-risk',
|
|
121
|
-
'--skip-health',
|
|
122
|
-
'--auth-choice minimax-cn-api',
|
|
123
|
-
'--token "' + apiKey + '"',
|
|
124
|
-
'--minimax-api-key "' + apiKey + '"',
|
|
125
|
-
].join(' '), { stdio: 'inherit' });
|
|
126
|
-
console.log('✅ API Key 已通过 onboard 设置');
|
|
127
|
-
|
|
128
|
-
// 再次验证
|
|
129
|
-
const reVerify = JSON.parse(fs.readFileSync(targetPath, 'utf8'));
|
|
130
|
-
const finalModelId = reVerify.models?.providers?.minimax?.models?.[0]?.id || '???';
|
|
131
|
-
const finalDefault = reVerify.agents?.defaults?.model?.primary || '???';
|
|
132
|
-
|
|
133
|
-
if (finalModelId !== "MiniMax-M2.7-highspeed") {
|
|
134
|
-
console.log('⚠️ [警告] onboard 命令覆盖了你配置的模型 ID: ' + finalModelId);
|
|
135
|
-
}
|
|
136
|
-
} catch (err) {
|
|
137
|
-
console.log('⚠️ onboard 失败: ' + err.message);
|
|
138
|
-
}
|
|
139
|
-
} else {
|
|
140
|
-
console.log('');
|
|
141
|
-
console.log('💡 未传入 --key,跳过 API Key 设置');
|
|
142
|
-
console.log(' 设置方法: myclaw minimax --key sk-xxx');
|
|
143
|
-
}
|
|
139
|
+
console.log('✅ 配置已注入');
|
|
140
|
+
console.log(' [验证] model ID: ' + writtenModelId);
|
|
141
|
+
console.log(' [验证] default: ' + writtenDefault);
|
|
144
142
|
|
|
145
143
|
console.log('');
|
|
146
144
|
}
|
package/package.json
CHANGED
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
* 独立运行,不依赖 myclaw CLI。
|
|
7
7
|
* OpenClaw agent 可直接调用此脚本。
|
|
8
8
|
*
|
|
9
|
+
* 流程:
|
|
10
|
+
* 1. 先执行 openclaw onboard(设置 API Key,会覆盖 JSON)
|
|
11
|
+
* 2. 再写入我们的 JSON 配置(覆盖回来)
|
|
12
|
+
*
|
|
9
13
|
* 用法:
|
|
10
14
|
* node inject.js # 只注入模型配置(不设 key)
|
|
11
15
|
* node inject.js --key sk-xxx # 注入模型 + 通过 onboard 设置 key
|
|
@@ -44,9 +48,39 @@ if (!fs.existsSync(targetPath)) {
|
|
|
44
48
|
console.log('📍 找到配置: ' + targetPath);
|
|
45
49
|
|
|
46
50
|
// ============================================================================
|
|
47
|
-
//
|
|
51
|
+
// 第一步:先执行 onboard(它会覆盖 JSON,所以必须先跑)
|
|
52
|
+
// ============================================================================
|
|
53
|
+
|
|
54
|
+
if (apiKey) {
|
|
55
|
+
console.log('');
|
|
56
|
+
console.log('🔑 [Step 1] 执行 openclaw onboard (设置 API Key)...');
|
|
57
|
+
try {
|
|
58
|
+
execSync([
|
|
59
|
+
'openclaw onboard',
|
|
60
|
+
'--non-interactive',
|
|
61
|
+
'--accept-risk',
|
|
62
|
+
'--skip-health',
|
|
63
|
+
'--auth-choice minimax-cn-api',
|
|
64
|
+
'--token "' + apiKey + '"',
|
|
65
|
+
'--minimax-api-key "' + apiKey + '"',
|
|
66
|
+
].join(' '), { stdio: 'inherit' });
|
|
67
|
+
console.log('✅ API Key 已通过 onboard 设置');
|
|
68
|
+
} catch (err) {
|
|
69
|
+
console.log('⚠️ onboard 失败 (继续注入 JSON): ' + err.message);
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
console.log('');
|
|
73
|
+
console.log('💡 未传入 --key,跳过 onboard');
|
|
74
|
+
console.log(' 设置方法: node inject.js --key sk-xxx');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ============================================================================
|
|
78
|
+
// 第二步:写入我们的 JSON 配置(覆盖 onboard 的修改)
|
|
48
79
|
// ============================================================================
|
|
49
80
|
|
|
81
|
+
console.log('');
|
|
82
|
+
console.log('📝 [Step 2] 注入 MiniMax 模型配置...');
|
|
83
|
+
|
|
50
84
|
const config = JSON.parse(fs.readFileSync(targetPath, 'utf8'));
|
|
51
85
|
|
|
52
86
|
config.auth = {
|
|
@@ -102,37 +136,14 @@ config.agents.defaults.models = {
|
|
|
102
136
|
|
|
103
137
|
fs.writeFileSync(targetPath, JSON.stringify(config, null, 2) + '\n', 'utf8');
|
|
104
138
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
// ============================================================================
|
|
111
|
-
// 通过 openclaw onboard 设置 API Key
|
|
112
|
-
// ============================================================================
|
|
139
|
+
// 验证写入
|
|
140
|
+
const verify = JSON.parse(fs.readFileSync(targetPath, 'utf8'));
|
|
141
|
+
const writtenModelId = verify.models?.providers?.minimax?.models?.[0]?.id || '???';
|
|
142
|
+
const writtenDefault = verify.agents?.defaults?.model?.primary || '???';
|
|
113
143
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
try {
|
|
118
|
-
execSync([
|
|
119
|
-
'openclaw onboard',
|
|
120
|
-
'--non-interactive',
|
|
121
|
-
'--accept-risk',
|
|
122
|
-
'--skip-health',
|
|
123
|
-
'--auth-choice minimax-cn-api',
|
|
124
|
-
'--token "' + apiKey + '"',
|
|
125
|
-
'--minimax-api-key "' + apiKey + '"',
|
|
126
|
-
].join(' '), { stdio: 'inherit' });
|
|
127
|
-
console.log('✅ API Key 已通过 onboard 设置');
|
|
128
|
-
} catch (err) {
|
|
129
|
-
console.log('⚠️ onboard 失败: ' + err.message);
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
console.log('');
|
|
133
|
-
console.log('💡 未传入 --key,跳过 API Key 设置');
|
|
134
|
-
console.log(' 设置方法: node inject.js --key sk-xxx');
|
|
135
|
-
}
|
|
144
|
+
console.log('✅ 配置已注入');
|
|
145
|
+
console.log(' [验证] model ID: ' + writtenModelId);
|
|
146
|
+
console.log(' [验证] default: ' + writtenDefault);
|
|
136
147
|
|
|
137
148
|
// ============================================================================
|
|
138
149
|
// 重启 Gateway
|