@aiyiran/myclaw 1.0.262 → 1.1.0

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.
@@ -3,75 +3,39 @@
3
3
  /**
4
4
  * inject-minimax.js
5
5
  *
6
- * 增量注入 MiniMax 模型配置到 openclaw.json,不影响已有的其他 provider
7
- * 图片模型会覆盖为 minimax/image-01(与 inject-image.js 互相覆盖,谁后执行谁生效)。
6
+ * 注入 MiniMax 模型配置到 openclaw.json。
8
7
  *
9
- * 流程:
10
- * 1. 先执行 openclaw onboard(设置 API Key)
11
- * 2. 清理 onboard 写入的 minimax/MiniMax-M2.7 残留条目
12
- * 3. 增量写入 minimax provider + 白名单 + 默认聊天模型
8
+ * 仅做以下事情:
9
+ * 1. 设置 minimax auth profile
10
+ * 2. 注册 minimax provider + 模型定义
11
+ * 3. 设置默认聊天模型为 MiniMax
12
+ * 4. 将 MiniMax 模型加入白名单
13
+ *
14
+ * 不触碰: 图片模型、其他 provider、onboard 流程
13
15
  *
14
16
  * 入口: myclaw minimax [--key sk-xxx]
15
17
  */
16
18
 
17
19
  const { readConfig, writeConfig } = require('../find-config');
18
20
 
19
- // ============================================================
20
- // 请在这里填写默认的 MiniMax API Key
21
- // ============================================================
22
21
  const DEFAULT_MINIMAX_KEY = "sk-cp-DC5lWd2Stt9CBFzLIT2awP4K-ZEn5AkYwjl3Cdj-mIBmgjxod518F2LaVF2L9c35Wv5-Eox0F1ctJD5vXtB9p3OmxoWLd9ge9zIUIMrCVuqBYdL_s6kb8Qs";
23
22
 
24
23
  function run(cliArgs) {
25
24
  // 解析参数
26
25
  let apiKey = null;
27
- let forceClean = false;
28
-
29
26
  for (let i = 0; i < cliArgs.length; i++) {
30
27
  if (cliArgs[i] === '--key' && cliArgs[i + 1]) {
31
28
  apiKey = cliArgs[i + 1];
32
29
  i++;
33
30
  }
34
- if (cliArgs[i] === '-f' || cliArgs[i] === '--force') {
35
- forceClean = true;
36
- }
37
31
  }
38
32
 
39
- // 如果没有传参数,并且配置了默认 Key,则使用默认 Key
40
- if (!apiKey && DEFAULT_MINIMAX_KEY && DEFAULT_MINIMAX_KEY !== "请在这里填入你的默认Key") {
33
+ if (!apiKey && DEFAULT_MINIMAX_KEY) {
41
34
  apiKey = DEFAULT_MINIMAX_KEY;
42
- console.log('💡 未传入 --key 参数,自动使用默认的 API Key');
35
+ console.log('💡 未传入 --key 参数,使用默认 API Key');
43
36
  }
44
37
 
45
- // 如果启用了强制清理模式
46
- if (forceClean) {
47
- console.log('');
48
- console.log('🧹 [强制清理] 清理其他大模型配置...');
49
- // 清理 zai provider
50
- if (config.models?.providers?.zai) {
51
- delete config.models.providers.zai;
52
- console.log(' ✓ 已删除 models.providers.zai');
53
- }
54
- // 清理 zai auth profile
55
- if (config.auth?.profiles?.['zai:default']) {
56
- delete config.auth.profiles['zai:default'];
57
- console.log(' ✓ 已删除 auth.profiles["zai:default"]');
58
- }
59
- // 清理 zai 白名单模型
60
- if (config.agents?.defaults?.models) {
61
- const zaiKeys = Object.keys(config.agents.defaults.models).filter(k => k.startsWith('zai/'));
62
- for (const key of zaiKeys) {
63
- delete config.agents.defaults.models[key];
64
- console.log(' ✓ 已删除 agents.defaults.models["' + key + '"]');
65
- }
66
- }
67
- // 如果默认模型是 zai,清除它
68
- if (config.agents?.defaults?.model?.primary?.startsWith('zai/')) {
69
- delete config.agents.defaults.model;
70
- console.log(' ✓ 已清除默认模型 (原为 zai)');
71
- }
72
- }
73
-
74
- // 查找配置
38
+ // 读取配置
75
39
  let configPath;
76
40
  try {
77
41
  ({ configPath } = readConfig());
@@ -81,55 +45,9 @@ function run(cliArgs) {
81
45
  }
82
46
 
83
47
  console.log('📍 找到配置: ' + configPath);
84
-
85
- // ============================================================
86
- // 第一步:先执行 onboard(它会覆盖 JSON,所以必须先跑)
87
- // ============================================================
88
-
89
- if (apiKey) {
90
- console.log('');
91
- console.log('🔑 [Step 1] 执行 openclaw onboard (设置 API Key)...');
92
- try {
93
- const { execSync } = require('child_process');
94
- execSync([
95
- 'openclaw onboard',
96
- '--non-interactive',
97
- '--accept-risk',
98
- '--skip-health',
99
- '--auth-choice minimax-cn-api',
100
- '--token "' + apiKey + '"',
101
- '--minimax-api-key "' + apiKey + '"',
102
- ].join(' '), { stdio: 'inherit' });
103
- console.log('✅ API Key 已通过 onboard 设置');
104
- } catch (err) {
105
- console.log('⚠️ onboard 失败 (继续注入 JSON): ' + err.message);
106
- }
107
- } else {
108
- console.log('');
109
- console.log('💡 未传入 --key,跳过 onboard');
110
- console.log(' 设置方法: myclaw minimax --key sk-xxx');
111
- }
112
-
113
- // ============================================================
114
- // 第二步:写入我们的 JSON 配置(覆盖 onboard 的修改)
115
- // ============================================================
116
-
117
- console.log('');
118
- console.log('📝 [Step 2] 清理 onboard 残留的 MiniMax-M2.7 条目...');
119
-
120
- // 重新读取(onboard 可能已改过)
121
48
  const { config } = readConfig();
122
49
 
123
- // onboard 会写入 minimax/MiniMax-M2.7(带 alias),清理掉避免干扰
124
- if (config.agents?.defaults?.models?.["minimax/MiniMax-M2.7"]) {
125
- delete config.agents.defaults.models["minimax/MiniMax-M2.7"];
126
- console.log(' 🧹 已删除 onboard 残留的 minimax/MiniMax-M2.7');
127
- }
128
-
129
- console.log('');
130
- console.log('📝 [Step 3] 注入 MiniMax 模型配置...');
131
-
132
- // auth profile: 增量合并,不覆盖已有 profile
50
+ // ─── 1. auth profile ───
133
51
  if (!config.auth) config.auth = {};
134
52
  if (!config.auth.profiles) config.auth.profiles = {};
135
53
  config.auth.profiles["minimax:cn"] = {
@@ -137,7 +55,7 @@ function run(cliArgs) {
137
55
  mode: "api_key"
138
56
  };
139
57
 
140
- // models provider: 只设置 minimax,保留其他 provider(如 openai/vveai 图片)
58
+ // ─── 2. minimax provider + 模型定义 ───
141
59
  if (!config.models) config.models = {};
142
60
  if (!config.models.mode) config.models.mode = "merge";
143
61
  if (!config.models.providers) config.models.providers = {};
@@ -164,34 +82,33 @@ function run(cliArgs) {
164
82
  ]
165
83
  };
166
84
 
85
+ // ─── 3. 默认聊天模型 ───
167
86
  if (!config.agents) config.agents = {};
168
87
  if (!config.agents.defaults) config.agents.defaults = {};
169
-
170
- // 默认聊天模型
171
88
  config.agents.defaults.model = {
172
89
  primary: "minimax/MiniMax-M2.7-highspeed"
173
90
  };
174
91
 
175
- // 图片模型: 覆盖注入(myclaw image 和 myclaw minimax 互相覆盖)
176
- config.agents.defaults.imageGenerationModel = {
177
- primary: "minimax/image-01"
178
- };
179
-
180
- // 白名单: 增量添加,不覆盖已有模型
92
+ // ─── 4. 白名单 ───
181
93
  if (!config.agents.defaults.models) config.agents.defaults.models = {};
182
94
  config.agents.defaults.models["minimax/MiniMax-M2.7-highspeed"] = {};
183
95
 
96
+ // 清理 onboard 可能写入的残留
97
+ if (config.agents.defaults.models["minimax/MiniMax-M2.7"]) {
98
+ delete config.agents.defaults.models["minimax/MiniMax-M2.7"];
99
+ }
100
+
101
+ // ─── 写入 ───
184
102
  writeConfig(config, configPath);
185
103
 
186
- // 验证写入
104
+ // 验证
187
105
  const verify = readConfig();
188
106
  const writtenModelId = verify.config.models?.providers?.minimax?.models?.[0]?.id || '???';
189
107
  const writtenDefault = verify.config.agents?.defaults?.model?.primary || '???';
190
108
 
191
- console.log('✅ 配置已注入');
192
- console.log(' [验证] model ID: ' + writtenModelId);
193
- console.log(' [验证] default: ' + writtenDefault);
194
-
109
+ console.log('✅ MiniMax 配置已注入');
110
+ console.log(' 模型: ' + writtenModelId);
111
+ console.log(' 默认: ' + writtenDefault);
195
112
  console.log('');
196
113
  }
197
114
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.0.262",
3
+ "version": "1.1.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {