@aiyiran/myclaw 1.1.211 → 1.1.212

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 (50) hide show
  1. package/index.js +3 -3
  2. package/injects/inject-minimax.js +154 -134
  3. package/package.json +1 -1
  4. package/skills/minimax-inject/SKILL.md +5 -22
  5. package/skills/minimax-inject/scripts/inject.js +12 -243
  6. package//345/234/260/344/270/213/345/237/216/345/244/247/345/206/222/351/231/251/1.html +0 -1756
  7. package//345/234/260/344/270/213/345/237/216/345/244/247/345/206/222/351/231/251/__demo__.html +0 -1756
  8. package//345/234/260/344/270/213/345/237/216/345/244/247/345/206/222/351/231/251/__student-view__.html +0 -77
  9. package//345/234/260/344/270/213/345/237/216/345/244/247/345/206/222/351/231/251/__student__.json +0 -60
  10. package//345/234/260/344/270/213/345/237/216/345/244/247/345/206/222/351/231/251/__teacher-view__.html +0 -52
  11. package//345/234/260/344/270/213/345/237/216/345/244/247/345/206/222/351/231/251/__teacher__.json +0 -45
  12. package//345/234/260/344/270/213/345/237/216/345/244/247/345/206/222/351/231/251/index.html +0 -150
  13. package//346/210/221/347/232/204/345/217/254/345/224/244/345/233/276/351/211/264/357/274/232/346/215/242/344/270/273/351/242/230/346/215/242/345/215/241/346/261/240/__demo__.html +0 -1531
  14. package//346/210/221/347/232/204/345/217/254/345/224/244/345/233/276/351/211/264/357/274/232/346/215/242/344/270/273/351/242/230/346/215/242/345/215/241/346/261/240/__student-view__.html +0 -77
  15. package//346/210/221/347/232/204/345/217/254/345/224/244/345/233/276/351/211/264/357/274/232/346/215/242/344/270/273/351/242/230/346/215/242/345/215/241/346/261/240/__student__.json +0 -60
  16. package//346/210/221/347/232/204/345/217/254/345/224/244/345/233/276/351/211/264/357/274/232/346/215/242/344/270/273/351/242/230/346/215/242/345/215/241/346/261/240/__teacher-view__.html +0 -52
  17. package//346/210/221/347/232/204/345/217/254/345/224/244/345/233/276/351/211/264/357/274/232/346/215/242/344/270/273/351/242/230/346/215/242/345/215/241/346/261/240/__teacher__.json +0 -45
  18. package//346/210/221/347/232/204/345/217/254/345/224/244/345/233/276/351/211/264/357/274/232/346/215/242/344/270/273/351/242/230/346/215/242/345/215/241/346/261/240/index.html +0 -150
  19. package//347/264/257/345/220/220/350/241/200/345/220/216/347/232/204/346/200/273/347/273/223.md +0 -196
  20. package//350/223/235/346/230/237/345/276/256/344/277/241/347/237/255/350/247/206/351/242/221/345/210/206/346/236/220/1.jpg +0 -0
  21. package//350/223/235/346/230/237/345/276/256/344/277/241/347/237/255/350/247/206/351/242/221/345/210/206/346/236/220/2.jpg +0 -0
  22. package//350/223/235/346/230/237/345/276/256/344/277/241/347/237/255/350/247/206/351/242/221/345/210/206/346/236/220/3.jpg +0 -0
  23. package//350/223/235/346/230/237/345/276/256/344/277/241/347/237/255/350/247/206/351/242/221/345/210/206/346/236/220/4.jpg +0 -0
  24. package//350/223/235/346/230/237/345/276/256/344/277/241/347/237/255/350/247/206/351/242/221/345/210/206/346/236/220/AI/344/270/215/347/224/250/347/234/213/347/232/204/345/216/237/345/247/213/346/217/220/347/244/272/350/257/215/344/272/272/347/261/273/347/234/213/__/351/200/211/351/242/230/345/274/225/346/223/216__.html +0 -589
  25. package//350/223/235/346/230/237/345/276/256/344/277/241/347/237/255/350/247/206/351/242/221/345/210/206/346/236/220/AI/344/270/215/347/224/250/347/234/213/347/232/204/345/216/237/345/247/213/346/217/220/347/244/272/350/257/215/344/272/272/347/261/273/347/234/213//345/216/237/345/247/213/346/217/220/347/244/272/350/257/215.md +0 -125
  26. package//350/223/235/346/230/237/345/276/256/344/277/241/347/237/255/350/247/206/351/242/221/345/210/206/346/236/220/AI/344/270/215/347/224/250/347/234/213/347/232/204/345/216/237/345/247/213/346/217/220/347/244/272/350/257/215/344/272/272/347/261/273/347/234/213//350/200/201/350/202/226/347/210/206/346/254/276/351/200/211/351/242/230/345/274/225/346/223/216.md +0 -179
  27. package//350/223/235/346/230/237/345/276/256/344/277/241/347/237/255/350/247/206/351/242/221/345/210/206/346/236/220/AI/344/270/215/347/224/250/347/234/213/347/232/204/345/216/237/345/247/213/346/217/220/347/244/272/350/257/215/344/272/272/347/261/273/347/234/213//350/200/201/350/202/226/351/207/221/345/217/245/345/272/223v1.md +0 -594
  28. package//350/223/235/346/230/237/345/276/256/344/277/241/347/237/255/350/247/206/351/242/221/345/210/206/346/236/220/__demo__.html +0 -588
  29. package//350/223/235/346/230/237/345/276/256/344/277/241/347/237/255/350/247/206/351/242/221/345/210/206/346/236/220/__student-view__.html +0 -77
  30. package//350/223/235/346/230/237/345/276/256/344/277/241/347/237/255/350/247/206/351/242/221/345/210/206/346/236/220/__student__.json +0 -54
  31. package//350/223/235/346/230/237/345/276/256/344/277/241/347/237/255/350/247/206/351/242/221/345/210/206/346/236/220/__teacher-view__.html +0 -52
  32. package//350/223/235/346/230/237/345/276/256/344/277/241/347/237/255/350/247/206/351/242/221/345/210/206/346/236/220/__teacher__.json +0 -46
  33. package//350/223/235/346/230/237/345/276/256/344/277/241/347/237/255/350/247/206/351/242/221/345/210/206/346/236/220/index.html +0 -148
  34. package//350/223/235/346/230/237/345/276/256/344/277/241/347/237/255/350/247/206/351/242/221/345/210/206/346/236/220//344/270/211/344/270/252/350/247/206/351/242/221/345/216/237/345/247/213/345/206/205/345/256/271/1-/344/273/200/344/271/210/346/230/257/344/274/230/347/247/200/347/232/204/345/255/251/345/255/220+/350/223/235/346/230/237/344/277/261/344/271/220/351/203/250/345/210/233/345/212/236+/347/210/266/346/257/215/345/244/251/350/201/214/357/274/210/351/200/220/345/255/227/347/250/277/357/274/211.md +0 -48
  35. package//350/223/235/346/230/237/345/276/256/344/277/241/347/237/255/350/247/206/351/242/221/345/210/206/346/236/220//344/270/211/344/270/252/350/247/206/351/242/221/345/216/237/345/247/213/345/206/205/345/256/271/2-/350/277/207/347/250/213/345/206/231/344/275/234/350/257/276/347/250/213/345/210/206/344/272/253/357/274/210/351/200/220/345/255/227/347/250/277/357/274/211.md +0 -27
  36. package//350/223/235/346/230/237/345/276/256/344/277/241/347/237/255/350/247/206/351/242/221/345/210/206/346/236/220//344/270/211/344/270/252/350/247/206/351/242/221/345/216/237/345/247/213/345/206/205/345/256/271/3-/350/202/262/345/204/277/345/273/272/350/256/256/357/274/232/345/242/236/351/207/217/344/277/241/346/201/257+/346/214/207/345/274/225vs/345/216/237/345/210/231+/345/210/206/344/272/253/347/224/237/346/264/273/347/273/206/350/212/202/357/274/210/351/200/220/345/255/227/347/250/277/357/274/211.md +0 -204
  37. package//350/223/235/346/230/237/345/276/256/344/277/241/347/237/255/350/247/206/351/242/221/345/210/206/346/236/220//344/270/211/344/270/252/350/247/206/351/242/221/345/216/237/345/247/213/345/206/205/345/256/271//346/213/206/345/210/206/345/211/215/345/275/225/351/237/263/346/226/207/346/234/254.md +0 -267
  38. package//350/223/235/346/230/237/345/276/256/344/277/241/347/237/255/350/247/206/351/242/221/345/210/206/346/236/220//350/264/242/345/212/241/345/210/206/346/236/220.html +0 -411
  39. package//350/264/246/345/215/225/345/210/206/346/236/220/345/212/251/346/211/213/__demo__.html +0 -411
  40. package//350/264/246/345/215/225/345/210/206/346/236/220/345/212/251/346/211/213/__student-view__.html +0 -77
  41. package//350/264/246/345/215/225/345/210/206/346/236/220/345/212/251/346/211/213/__student__.json +0 -54
  42. package//350/264/246/345/215/225/345/210/206/346/236/220/345/212/251/346/211/213/__teacher-view__.html +0 -52
  43. package//350/264/246/345/215/225/345/210/206/346/236/220/345/212/251/346/211/213/__teacher__.json +0 -50
  44. package//350/264/246/345/215/225/345/210/206/346/236/220/345/212/251/346/211/213/index.html +0 -148
  45. package//351/200/203/345/207/272/350/277/267/345/256/253/357/274/232/346/210/221/346/235/245/345/256/232/350/247/204/345/210/231/__demo__.html +0 -842
  46. package//351/200/203/345/207/272/350/277/267/345/256/253/357/274/232/346/210/221/346/235/245/345/256/232/350/247/204/345/210/231/__student-view__.html +0 -77
  47. package//351/200/203/345/207/272/350/277/267/345/256/253/357/274/232/346/210/221/346/235/245/345/256/232/350/247/204/345/210/231/__student__.json +0 -60
  48. package//351/200/203/345/207/272/350/277/267/345/256/253/357/274/232/346/210/221/346/235/245/345/256/232/350/247/204/345/210/231/__teacher-view__.html +0 -52
  49. package//351/200/203/345/207/272/350/277/267/345/256/253/357/274/232/346/210/221/346/235/245/345/256/232/350/247/204/345/210/231/__teacher__.json +0 -45
  50. package//351/200/203/345/207/272/350/277/267/345/256/253/357/274/232/346/210/221/346/235/245/345/256/232/350/247/204/345/210/231/index.html +0 -150
@@ -1,248 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- /**
4
- * MiniMax 模型注入脚本
5
- *
6
- * 独立运行,不依赖 myclaw CLI。
7
- * OpenClaw agent 可直接调用此脚本。
8
- *
9
- * 流程:
10
- * 1. 先执行 openclaw onboard(设置 API Key,会覆盖 JSON)
11
- * 2. 清理 onboard 写入的 minimax/MiniMax-M2.7 残留条目
12
- * 3. 再写入我们的 JSON 配置(覆盖回来)
13
- *
14
- * 用法:
15
- * node inject.js # 只注入模型配置(不设 key)
16
- * node inject.js --key sk-xxx # 注入模型 + 通过 onboard 设置 key
17
- */
3
+ const { spawnSync } = require('node:child_process');
4
+ const fs = require('node:fs');
5
+ const path = require('node:path');
18
6
 
19
- const fs = require('fs');
20
- const path = require('path');
21
- const os = require('os');
22
- const { execSync } = require('child_process');
7
+ const localCli = path.join(__dirname, '../../../index.js');
8
+ const useLocalCli = fs.existsSync(path.join(__dirname, '../../../injects/inject-minimax.js'));
9
+ const command = useLocalCli ? process.execPath : 'myclaw';
10
+ const prefix = useLocalCli ? [localCli] : [];
11
+ const args = [...prefix, 'inject-minimax', '--default', ...process.argv.slice(2)];
12
+ const result = spawnSync(command, args, { stdio: 'inherit' });
23
13
 
24
- // ============================================================================
25
- // 解析参数
26
- // ============================================================================
27
-
28
- const DEFAULT_MINIMAX_KEY = "sk-cp-hZrI2mmHl_bQxHGSwRkDJvIrroe6xebBaKyhUhdnH1s4TABiJ4j_RcP85i44fGSbrhxv6yGij-mM0a0EXvMaLkcL2UhjtW6YAm3TF-2SuRGAemg3LC8F4xM";
29
-
30
- let apiKey = null;
31
- const args = process.argv.slice(2);
32
- for (let i = 0; i < args.length; i++) {
33
- if (args[i] === '--key' && args[i + 1]) {
34
- apiKey = args[i + 1];
35
- i++;
36
- }
37
- }
38
-
39
- // 如果没有传参数,并且配置了默认 Key,则使用默认 Key
40
- if (!apiKey && DEFAULT_MINIMAX_KEY && DEFAULT_MINIMAX_KEY !== "请在这里填入你的默认Key") {
41
- apiKey = DEFAULT_MINIMAX_KEY;
42
- console.log('💡 未传入 --key 参数,自动使用默认的 API Key');
43
- }
44
-
45
- // ============================================================================
46
- // 查找 openclaw.json
47
- // ============================================================================
48
-
49
- const openclawDir = path.join(os.homedir(), '.openclaw');
50
- const targetPath = path.join(openclawDir, 'openclaw.json');
51
-
52
- if (!fs.existsSync(targetPath)) {
53
- console.error('❌ 未找到 openclaw.json: ' + targetPath);
54
- process.exit(1);
55
- }
56
-
57
- console.log('📍 找到配置: ' + targetPath);
58
-
59
- // ============================================================================
60
- // 第一步:先执行 onboard(它会覆盖 JSON,所以必须先跑)
61
- // ============================================================================
62
-
63
- if (apiKey) {
64
- console.log('');
65
- console.log('🔑 [Step 1] 执行 openclaw onboard (设置 API Key)...');
66
- try {
67
- execSync([
68
- 'openclaw onboard',
69
- '--non-interactive',
70
- '--accept-risk',
71
- '--skip-health',
72
- '--auth-choice minimax-cn-api',
73
- '--token "' + apiKey + '"',
74
- '--minimax-api-key "' + apiKey + '"',
75
- ].join(' '), { stdio: 'inherit' });
76
- console.log('✅ API Key 已通过 onboard 设置');
77
- } catch (err) {
78
- console.log('⚠️ onboard 失败 (继续注入 JSON): ' + err.message);
79
- }
80
- } else {
81
- console.log('');
82
- console.log('💡 未传入 --key,跳过 onboard');
83
- console.log(' 设置方法: node inject.js --key sk-xxx');
84
- }
85
-
86
- // ============================================================================
87
- // 第二步:清理 onboard 残留的 MiniMax-M2.7 条目
88
- // ============================================================================
89
-
90
- console.log('');
91
- console.log('📝 [Step 2] 清理 onboard 残留的 MiniMax-M2.7 条目...');
92
-
93
- const config = JSON.parse(fs.readFileSync(targetPath, 'utf8'));
94
-
95
- // onboard 会写入 minimax/MiniMax-M2.7(无 -highspeed 的 alias),清理掉避免干扰
96
- // 注意:MiniMax-M2.7-highspeed 保留为备选模型,不删除
97
- if (config.agents?.defaults?.models?.["minimax/MiniMax-M2.7"]) {
98
- delete config.agents.defaults.models["minimax/MiniMax-M2.7"];
99
- console.log(' 🧹 已删除 onboard 残留的 minimax/MiniMax-M2.7');
100
- }
101
-
102
- // ============================================================================
103
- // 第三步:写入我们的 JSON 配置(覆盖 onboard 的修改)
104
- // ============================================================================
105
-
106
- console.log('');
107
- console.log('📝 [Step 3] 注入 MiniMax 模型配置...');
108
-
109
- // auth profile: 增量合并
110
- if (!config.auth) config.auth = {};
111
- if (!config.auth.profiles) config.auth.profiles = {};
112
- config.auth.profiles["minimax:cn"] = {
113
- provider: "minimax",
114
- mode: "api_key"
115
- };
116
-
117
- // models provider: 只设置 minimax,保留其他 provider
118
- if (!config.models) config.models = {};
119
- if (!config.models.mode) config.models.mode = "merge";
120
- if (!config.models.providers) config.models.providers = {};
121
-
122
- config.models.providers.minimax = {
123
- baseUrl: "https://api.minimaxi.com/anthropic",
124
- api: "anthropic-messages",
125
- authHeader: true,
126
- models: [
127
- {
128
- id: "MiniMax-M3",
129
- name: "MiniMax M3",
130
- reasoning: true,
131
- input: ["text"],
132
- cost: {
133
- input: 0.3,
134
- output: 1.2,
135
- cacheRead: 0.06,
136
- cacheWrite: 0.375
137
- },
138
- contextWindow: 204800,
139
- maxTokens: 131072
140
- },
141
- {
142
- id: "MiniMax-M2.7-highspeed",
143
- name: "MiniMax M2.7 Highspeed",
144
- reasoning: true,
145
- input: ["text"],
146
- cost: {
147
- input: 0.3,
148
- output: 1.2,
149
- cacheRead: 0.06,
150
- cacheWrite: 0.375
151
- },
152
- contextWindow: 204800,
153
- maxTokens: 131072
154
- }
155
- ]
156
- };
157
-
158
- if (!config.agents) config.agents = {};
159
- if (!config.agents.defaults) config.agents.defaults = {};
160
-
161
- // 默认聊天模型
162
- config.agents.defaults.model = {
163
- primary: "minimax/MiniMax-M3"
164
- };
165
-
166
- // 白名单: M3(默认) + M2.7-highspeed(备选)
167
- if (!config.agents.defaults.models) config.agents.defaults.models = {};
168
- config.agents.defaults.models["minimax/MiniMax-M3"] = {};
169
- config.agents.defaults.models["minimax/MiniMax-M2.7-highspeed"] = {};
170
-
171
- fs.writeFileSync(targetPath, JSON.stringify(config, null, 2) + '\n', 'utf8');
172
-
173
- // 验证写入
174
- const verify = JSON.parse(fs.readFileSync(targetPath, 'utf8'));
175
- const writtenModelId = verify.models?.providers?.minimax?.models?.[0]?.id || '???';
176
- const writtenDefault = verify.agents?.defaults?.model?.primary || '???';
177
-
178
- console.log('✅ 配置已注入');
179
- console.log(' [验证] model ID: ' + writtenModelId);
180
- console.log(' [验证] default: ' + writtenDefault);
181
-
182
- // ============================================================================
183
- // 第四步:升级老对话 sessions.json:MiniMax-M2.7-highspeed → MiniMax-M3
184
- // ============================================================================
185
-
186
- console.log('');
187
- console.log('📝 [Step 4] 升级老对话模型 (MiniMax-M2.7-highspeed → MiniMax-M3)...');
188
-
189
- const agentsDir = path.join(openclawDir, 'agents');
190
- let sessionOk = 0, sessionSkip = 0;
191
-
192
- if (fs.existsSync(agentsDir)) {
193
- for (const agentName of fs.readdirSync(agentsDir)) {
194
- const sessionsPath = path.join(agentsDir, agentName, 'sessions', 'sessions.json');
195
- if (!fs.existsSync(sessionsPath)) continue;
196
- try {
197
- const sessions = JSON.parse(fs.readFileSync(sessionsPath, 'utf8'));
198
- let changed = false;
199
- for (const key of Object.keys(sessions)) {
200
- if (sessions[key]?.model === 'MiniMax-M2.7-highspeed') {
201
- sessions[key].model = 'MiniMax-M3';
202
- changed = true;
203
- }
204
- }
205
- if (changed) {
206
- fs.writeFileSync(sessionsPath, JSON.stringify(sessions, null, 2) + '\n', 'utf8');
207
- sessionOk++;
208
- }
209
- } catch {
210
- sessionSkip++;
211
- }
212
- }
213
- }
214
-
215
- console.log(' sessions.json 更新: ' + sessionOk + ' 个,跳过: ' + sessionSkip + ' 个');
216
-
217
- // ============================================================================
218
- // 重启 Gateway
219
- // ============================================================================
220
-
221
- console.log('');
222
- console.log('🔄 重启 Gateway...');
223
-
224
- try {
225
- execSync('openclaw gateway stop', { stdio: 'pipe', timeout: 10000 });
226
- console.log(' Gateway 已停止');
227
- } catch {
228
- console.log(' Gateway 未在运行');
14
+ if (result.error) {
15
+ console.error('无法运行 myclaw,请确认 CLI 已安装。');
229
16
  }
230
-
231
- try {
232
- execSync('nohup openclaw gateway > /tmp/openclaw-gateway.log 2>&1 &', {
233
- stdio: 'ignore',
234
- shell: true,
235
- });
236
- execSync('sleep 2', { stdio: 'ignore' });
237
-
238
- try {
239
- execSync('openclaw health', { stdio: 'pipe', timeout: 5000 });
240
- console.log(' ✅ Gateway 启动成功');
241
- } catch {
242
- console.log(' ⏳ Gateway 启动中...');
243
- }
244
- } catch (err) {
245
- console.error(' ❌ 启动失败: ' + err.message);
246
- }
247
-
248
- console.log('');
17
+ process.exitCode = result.status ?? 1;