@aiyiran/myclaw 1.0.141 → 1.0.143
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/index.js +7 -0
- package/inject-minimax.js +12 -2
- package/inject-zai.js +268 -0
- package/package.json +1 -1
- package/skills/minimax-inject/scripts/inject.js +17 -3
package/index.js
CHANGED
|
@@ -987,6 +987,7 @@ function showHelp() {
|
|
|
987
987
|
console.log(' patch 注入 MyClaw UI + 技能 + 智能体 + 配置');
|
|
988
988
|
console.log(' unpatch 回滚 UI 注入(恢复原版)');
|
|
989
989
|
console.log(' minimax 注入 MiniMax 模型配置 (可选: --key sk-xxx)');
|
|
990
|
+
console.log(' zai 注入智谱 GLM 模型配置 (可选: --key xxx)');
|
|
990
991
|
console.log(' image 注入图像生成模型配置 (基于 vveai)');
|
|
991
992
|
console.log(' token 设置 Gateway Token 为 aiyiran');
|
|
992
993
|
console.log(' plus 增强功能 (子命令: search)');
|
|
@@ -1070,6 +1071,12 @@ if (!command || command === 'help' || command === '--help' || command === '-h')
|
|
|
1070
1071
|
console.log('🔄 正在重启 Gateway 使配置生效...');
|
|
1071
1072
|
console.log('');
|
|
1072
1073
|
runRestart();
|
|
1074
|
+
} else if (command === 'zai') {
|
|
1075
|
+
const zai = require('./inject-zai');
|
|
1076
|
+
zai.run(args.slice(1));
|
|
1077
|
+
console.log('🔄 正在重启 Gateway 使配置生效...');
|
|
1078
|
+
console.log('');
|
|
1079
|
+
runRestart();
|
|
1073
1080
|
} else if (command === 'image') {
|
|
1074
1081
|
const image = require('./inject-image');
|
|
1075
1082
|
image.run(args.slice(1));
|
package/inject-minimax.js
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
*
|
|
9
9
|
* 流程:
|
|
10
10
|
* 1. 先执行 openclaw onboard(设置 API Key)
|
|
11
|
-
* 2.
|
|
11
|
+
* 2. 清理 onboard 写入的 minimax/MiniMax-M2.7 残留条目
|
|
12
|
+
* 3. 增量写入 minimax provider + 白名单 + 默认聊天模型
|
|
12
13
|
*
|
|
13
14
|
* 入口: myclaw minimax [--key sk-xxx]
|
|
14
15
|
*/
|
|
@@ -80,11 +81,20 @@ function run(cliArgs) {
|
|
|
80
81
|
// ============================================================
|
|
81
82
|
|
|
82
83
|
console.log('');
|
|
83
|
-
console.log('📝 [Step 2]
|
|
84
|
+
console.log('📝 [Step 2] 清理 onboard 残留的 MiniMax-M2.7 条目...');
|
|
84
85
|
|
|
85
86
|
// 重新读取(onboard 可能已改过)
|
|
86
87
|
const { config } = readConfig();
|
|
87
88
|
|
|
89
|
+
// onboard 会写入 minimax/MiniMax-M2.7(带 alias),清理掉避免干扰
|
|
90
|
+
if (config.agents?.defaults?.models?.["minimax/MiniMax-M2.7"]) {
|
|
91
|
+
delete config.agents.defaults.models["minimax/MiniMax-M2.7"];
|
|
92
|
+
console.log(' 🧹 已删除 onboard 残留的 minimax/MiniMax-M2.7');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
console.log('');
|
|
96
|
+
console.log('📝 [Step 3] 注入 MiniMax 模型配置...');
|
|
97
|
+
|
|
88
98
|
// auth profile: 增量合并,不覆盖已有 profile
|
|
89
99
|
if (!config.auth) config.auth = {};
|
|
90
100
|
if (!config.auth.profiles) config.auth.profiles = {};
|
package/inject-zai.js
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* inject-zai.js
|
|
5
|
+
*
|
|
6
|
+
* 增量注入智谱 GLM 模型配置到 openclaw.json,不影响已有的其他 provider。
|
|
7
|
+
* 同时写入 API Key 到 auth-profiles.json。
|
|
8
|
+
*
|
|
9
|
+
* 流程:
|
|
10
|
+
* 1. 写入 API Key 到 auth-profiles.json
|
|
11
|
+
* 2. 增量写入 zai provider + 白名单 + 默认聊天模型
|
|
12
|
+
*
|
|
13
|
+
* 入口: myclaw zai [--key xxx]
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const { readConfig, writeConfig } = require('./find-config');
|
|
17
|
+
const fs = require('fs');
|
|
18
|
+
const path = require('path');
|
|
19
|
+
const os = require('os');
|
|
20
|
+
|
|
21
|
+
// ============================================================
|
|
22
|
+
// 默认智谱 API Key
|
|
23
|
+
// ============================================================
|
|
24
|
+
const DEFAULT_ZAI_KEY = "eceb83b3bbec493692fe4bb3329b0d40.AgZrq3ULMEL1ySgh";
|
|
25
|
+
|
|
26
|
+
// 智谱模型列表
|
|
27
|
+
const ZAI_MODELS = [
|
|
28
|
+
{
|
|
29
|
+
id: "glm-5.1",
|
|
30
|
+
name: "GLM-5.1",
|
|
31
|
+
reasoning: true,
|
|
32
|
+
input: ["text"],
|
|
33
|
+
cost: { input: 1.2, output: 4, cacheRead: 0.24, cacheWrite: 0 },
|
|
34
|
+
contextWindow: 202800,
|
|
35
|
+
maxTokens: 131100
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: "glm-5",
|
|
39
|
+
name: "GLM-5",
|
|
40
|
+
reasoning: true,
|
|
41
|
+
input: ["text"],
|
|
42
|
+
cost: { input: 1, output: 3.2, cacheRead: 0.2, cacheWrite: 0 },
|
|
43
|
+
contextWindow: 202800,
|
|
44
|
+
maxTokens: 131100
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: "glm-5-turbo",
|
|
48
|
+
name: "GLM-5 Turbo",
|
|
49
|
+
reasoning: true,
|
|
50
|
+
input: ["text"],
|
|
51
|
+
cost: { input: 1.2, output: 4, cacheRead: 0.24, cacheWrite: 0 },
|
|
52
|
+
contextWindow: 202800,
|
|
53
|
+
maxTokens: 131100
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: "glm-5v-turbo",
|
|
57
|
+
name: "GLM-5V Turbo",
|
|
58
|
+
reasoning: true,
|
|
59
|
+
input: ["text", "image"],
|
|
60
|
+
cost: { input: 1.2, output: 4, cacheRead: 0.24, cacheWrite: 0 },
|
|
61
|
+
contextWindow: 202800,
|
|
62
|
+
maxTokens: 131100
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "glm-4.7",
|
|
66
|
+
name: "GLM-4.7",
|
|
67
|
+
reasoning: true,
|
|
68
|
+
input: ["text"],
|
|
69
|
+
cost: { input: 0.6, output: 2.2, cacheRead: 0.11, cacheWrite: 0 },
|
|
70
|
+
contextWindow: 204800,
|
|
71
|
+
maxTokens: 131072
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: "glm-4.7-flash",
|
|
75
|
+
name: "GLM-4.7 Flash",
|
|
76
|
+
reasoning: true,
|
|
77
|
+
input: ["text"],
|
|
78
|
+
cost: { input: 0.07, output: 0.4, cacheRead: 0, cacheWrite: 0 },
|
|
79
|
+
contextWindow: 200000,
|
|
80
|
+
maxTokens: 131072
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: "glm-4.7-flashx",
|
|
84
|
+
name: "GLM-4.7 FlashX",
|
|
85
|
+
reasoning: true,
|
|
86
|
+
input: ["text"],
|
|
87
|
+
cost: { input: 0.06, output: 0.4, cacheRead: 0.01, cacheWrite: 0 },
|
|
88
|
+
contextWindow: 200000,
|
|
89
|
+
maxTokens: 128000
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: "glm-4.6",
|
|
93
|
+
name: "GLM-4.6",
|
|
94
|
+
reasoning: true,
|
|
95
|
+
input: ["text"],
|
|
96
|
+
cost: { input: 0.6, output: 2.2, cacheRead: 0.11, cacheWrite: 0 },
|
|
97
|
+
contextWindow: 204800,
|
|
98
|
+
maxTokens: 131072
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: "glm-4.6v",
|
|
102
|
+
name: "GLM-4.6V",
|
|
103
|
+
reasoning: true,
|
|
104
|
+
input: ["text", "image"],
|
|
105
|
+
cost: { input: 0.3, output: 0.9, cacheRead: 0, cacheWrite: 0 },
|
|
106
|
+
contextWindow: 128000,
|
|
107
|
+
maxTokens: 32768
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: "glm-4.5",
|
|
111
|
+
name: "GLM-4.5",
|
|
112
|
+
reasoning: true,
|
|
113
|
+
input: ["text"],
|
|
114
|
+
cost: { input: 0.6, output: 2.2, cacheRead: 0.11, cacheWrite: 0 },
|
|
115
|
+
contextWindow: 131072,
|
|
116
|
+
maxTokens: 98304
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: "glm-4.5-air",
|
|
120
|
+
name: "GLM-4.5 Air",
|
|
121
|
+
reasoning: true,
|
|
122
|
+
input: ["text"],
|
|
123
|
+
cost: { input: 0.2, output: 1.1, cacheRead: 0.03, cacheWrite: 0 },
|
|
124
|
+
contextWindow: 131072,
|
|
125
|
+
maxTokens: 98304
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
id: "glm-4.5-flash",
|
|
129
|
+
name: "GLM-4.5 Flash",
|
|
130
|
+
reasoning: true,
|
|
131
|
+
input: ["text"],
|
|
132
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
133
|
+
contextWindow: 131072,
|
|
134
|
+
maxTokens: 98304
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
id: "glm-4.5v",
|
|
138
|
+
name: "GLM-4.5V",
|
|
139
|
+
reasoning: true,
|
|
140
|
+
input: ["text", "image"],
|
|
141
|
+
cost: { input: 0.6, output: 1.8, cacheRead: 0, cacheWrite: 0 },
|
|
142
|
+
contextWindow: 64000,
|
|
143
|
+
maxTokens: 16384
|
|
144
|
+
}
|
|
145
|
+
];
|
|
146
|
+
|
|
147
|
+
function run(cliArgs) {
|
|
148
|
+
// 解析 --key 参数
|
|
149
|
+
let apiKey = null;
|
|
150
|
+
for (let i = 0; i < cliArgs.length; i++) {
|
|
151
|
+
if (cliArgs[i] === '--key' && cliArgs[i + 1]) {
|
|
152
|
+
apiKey = cliArgs[i + 1];
|
|
153
|
+
i++;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// 如果没有传参数,使用默认 Key
|
|
158
|
+
if (!apiKey && DEFAULT_ZAI_KEY) {
|
|
159
|
+
apiKey = DEFAULT_ZAI_KEY;
|
|
160
|
+
console.log('💡 未传入 --key 参数,自动使用默认的 API Key');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// 查找配置
|
|
164
|
+
let configPath;
|
|
165
|
+
try {
|
|
166
|
+
({ configPath } = readConfig());
|
|
167
|
+
} catch (err) {
|
|
168
|
+
console.error('❌ ' + err.message);
|
|
169
|
+
process.exit(1);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
console.log('📍 找到配置: ' + configPath);
|
|
173
|
+
|
|
174
|
+
// ============================================================
|
|
175
|
+
// 第一步:写入 API Key 到 auth-profiles.json
|
|
176
|
+
// ============================================================
|
|
177
|
+
|
|
178
|
+
console.log('');
|
|
179
|
+
console.log('🔑 [Step 1] 写入智谱 API Key 到 auth-profiles.json...');
|
|
180
|
+
|
|
181
|
+
const authProfilePath = path.join(os.homedir(), '.openclaw', 'agents', 'main', 'agent', 'auth-profiles.json');
|
|
182
|
+
let authProfiles = {};
|
|
183
|
+
|
|
184
|
+
if (fs.existsSync(authProfilePath)) {
|
|
185
|
+
try {
|
|
186
|
+
authProfiles = JSON.parse(fs.readFileSync(authProfilePath, 'utf8'));
|
|
187
|
+
} catch {
|
|
188
|
+
authProfiles = {};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (!authProfiles.profiles) authProfiles.profiles = {};
|
|
193
|
+
if (!authProfiles.lastGood) authProfiles.lastGood = {};
|
|
194
|
+
|
|
195
|
+
authProfiles.profiles["zai:default"] = {
|
|
196
|
+
type: "api_key",
|
|
197
|
+
provider: "zai",
|
|
198
|
+
key: apiKey
|
|
199
|
+
};
|
|
200
|
+
authProfiles.lastGood["zai"] = "zai:default";
|
|
201
|
+
|
|
202
|
+
// 确保目录存在
|
|
203
|
+
const authDir = path.dirname(authProfilePath);
|
|
204
|
+
if (!fs.existsSync(authDir)) {
|
|
205
|
+
fs.mkdirSync(authDir, { recursive: true });
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
fs.writeFileSync(authProfilePath, JSON.stringify(authProfiles, null, 2) + '\n', 'utf8');
|
|
209
|
+
console.log(' ✅ API Key 已写入');
|
|
210
|
+
|
|
211
|
+
// ============================================================
|
|
212
|
+
// 第二步:写入 openclaw.json 配置
|
|
213
|
+
// ============================================================
|
|
214
|
+
|
|
215
|
+
console.log('');
|
|
216
|
+
console.log('📝 [Step 2] 注入智谱模型配置...');
|
|
217
|
+
|
|
218
|
+
// 重新读取(以防 Step 1 期间有变化)
|
|
219
|
+
const { config } = readConfig();
|
|
220
|
+
|
|
221
|
+
// auth profile 声明
|
|
222
|
+
if (!config.auth) config.auth = {};
|
|
223
|
+
if (!config.auth.profiles) config.auth.profiles = {};
|
|
224
|
+
config.auth.profiles["zai:default"] = {
|
|
225
|
+
provider: "zai",
|
|
226
|
+
mode: "api_key"
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
// models provider
|
|
230
|
+
if (!config.models) config.models = {};
|
|
231
|
+
if (!config.models.mode) config.models.mode = "merge";
|
|
232
|
+
if (!config.models.providers) config.models.providers = {};
|
|
233
|
+
|
|
234
|
+
config.models.providers.zai = {
|
|
235
|
+
baseUrl: "https://open.bigmodel.cn/api/coding/paas/v4",
|
|
236
|
+
api: "openai-completions",
|
|
237
|
+
models: ZAI_MODELS
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
// agents 默认配置
|
|
241
|
+
if (!config.agents) config.agents = {};
|
|
242
|
+
if (!config.agents.defaults) config.agents.defaults = {};
|
|
243
|
+
|
|
244
|
+
// 默认聊天模型
|
|
245
|
+
config.agents.defaults.model = {
|
|
246
|
+
primary: "zai/glm-5"
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// 白名单: 增量添加,不覆盖已有模型
|
|
250
|
+
if (!config.agents.defaults.models) config.agents.defaults.models = {};
|
|
251
|
+
config.agents.defaults.models["zai/glm-5"] = {};
|
|
252
|
+
|
|
253
|
+
writeConfig(config, configPath);
|
|
254
|
+
|
|
255
|
+
// 验证写入
|
|
256
|
+
const verify = readConfig();
|
|
257
|
+
const writtenModelId = verify.config.models?.providers?.zai?.models?.[0]?.id || '???';
|
|
258
|
+
const writtenDefault = verify.config.agents?.defaults?.model?.primary || '???';
|
|
259
|
+
|
|
260
|
+
console.log('✅ 配置已注入');
|
|
261
|
+
console.log(' [验证] model ID: ' + writtenModelId);
|
|
262
|
+
console.log(' [验证] default: ' + writtenDefault);
|
|
263
|
+
console.log(' [验证] 模型数量: ' + verify.config.models?.providers?.zai?.models?.length);
|
|
264
|
+
|
|
265
|
+
console.log('');
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
module.exports = { run };
|
package/package.json
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
*
|
|
9
9
|
* 流程:
|
|
10
10
|
* 1. 先执行 openclaw onboard(设置 API Key,会覆盖 JSON)
|
|
11
|
-
* 2.
|
|
11
|
+
* 2. 清理 onboard 写入的 minimax/MiniMax-M2.7 残留条目
|
|
12
|
+
* 3. 再写入我们的 JSON 配置(覆盖回来)
|
|
12
13
|
*
|
|
13
14
|
* 用法:
|
|
14
15
|
* node inject.js # 只注入模型配置(不设 key)
|
|
@@ -83,14 +84,27 @@ if (apiKey) {
|
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
// ============================================================================
|
|
86
|
-
//
|
|
87
|
+
// 第二步:清理 onboard 残留的 MiniMax-M2.7 条目
|
|
87
88
|
// ============================================================================
|
|
88
89
|
|
|
89
90
|
console.log('');
|
|
90
|
-
console.log('📝 [Step 2]
|
|
91
|
+
console.log('📝 [Step 2] 清理 onboard 残留的 MiniMax-M2.7 条目...');
|
|
91
92
|
|
|
92
93
|
const config = JSON.parse(fs.readFileSync(targetPath, 'utf8'));
|
|
93
94
|
|
|
95
|
+
// onboard 会写入 minimax/MiniMax-M2.7(带 alias),清理掉避免干扰
|
|
96
|
+
if (config.agents?.defaults?.models?.["minimax/MiniMax-M2.7"]) {
|
|
97
|
+
delete config.agents.defaults.models["minimax/MiniMax-M2.7"];
|
|
98
|
+
console.log(' 🧹 已删除 onboard 残留的 minimax/MiniMax-M2.7');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ============================================================================
|
|
102
|
+
// 第三步:写入我们的 JSON 配置(覆盖 onboard 的修改)
|
|
103
|
+
// ============================================================================
|
|
104
|
+
|
|
105
|
+
console.log('');
|
|
106
|
+
console.log('📝 [Step 3] 注入 MiniMax 模型配置...');
|
|
107
|
+
|
|
94
108
|
// auth profile: 增量合并
|
|
95
109
|
if (!config.auth) config.auth = {};
|
|
96
110
|
if (!config.auth.profiles) config.auth.profiles = {};
|