@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.
- package/index.js +3 -3
- package/injects/inject-minimax.js +154 -134
- package/package.json +1 -1
- package/skills/minimax-inject/SKILL.md +5 -22
- package/skills/minimax-inject/scripts/inject.js +12 -243
- package//345/234/260/344/270/213/345/237/216/345/244/247/345/206/222/351/231/251/1.html +0 -1756
- package//345/234/260/344/270/213/345/237/216/345/244/247/345/206/222/351/231/251/__demo__.html +0 -1756
- package//345/234/260/344/270/213/345/237/216/345/244/247/345/206/222/351/231/251/__student-view__.html +0 -77
- package//345/234/260/344/270/213/345/237/216/345/244/247/345/206/222/351/231/251/__student__.json +0 -60
- package//345/234/260/344/270/213/345/237/216/345/244/247/345/206/222/351/231/251/__teacher-view__.html +0 -52
- package//345/234/260/344/270/213/345/237/216/345/244/247/345/206/222/351/231/251/__teacher__.json +0 -45
- package//345/234/260/344/270/213/345/237/216/345/244/247/345/206/222/351/231/251/index.html +0 -150
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package//350/264/246/345/215/225/345/210/206/346/236/220/345/212/251/346/211/213/__demo__.html +0 -411
- package//350/264/246/345/215/225/345/210/206/346/236/220/345/212/251/346/211/213/__student-view__.html +0 -77
- package//350/264/246/345/215/225/345/210/206/346/236/220/345/212/251/346/211/213/__student__.json +0 -54
- package//350/264/246/345/215/225/345/210/206/346/236/220/345/212/251/346/211/213/__teacher-view__.html +0 -52
- package//350/264/246/345/215/225/345/210/206/346/236/220/345/212/251/346/211/213/__teacher__.json +0 -50
- package//350/264/246/345/215/225/345/210/206/346/236/220/345/212/251/346/211/213/index.html +0 -148
- 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
- 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
- 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
- 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
- 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
- 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
package/index.js
CHANGED
|
@@ -1855,7 +1855,7 @@ const INJECT_MENU = [
|
|
|
1855
1855
|
|
|
1856
1856
|
function runInjectCommand(cmd, extraArgs) {
|
|
1857
1857
|
const modules = {
|
|
1858
|
-
'inject-minimax': './inject-minimax',
|
|
1858
|
+
'inject-minimax': './injects/inject-minimax',
|
|
1859
1859
|
'inject-zai': './inject-zai',
|
|
1860
1860
|
'inject-claude': './inject-claude',
|
|
1861
1861
|
'inject-image': './inject-image',
|
|
@@ -2629,7 +2629,7 @@ function showHelp() {
|
|
|
2629
2629
|
console.log(' patch 注入 MyClaw UI + 技能 + 智能体 + 配置');
|
|
2630
2630
|
console.log(' unpatch 回滚 UI 注入(恢复原版)');
|
|
2631
2631
|
console.log(' inject 交互选择要执行的注入脚本');
|
|
2632
|
-
console.log(' inject-minimax 注入 MiniMax
|
|
2632
|
+
console.log(' inject-minimax 注入 MiniMax M3.1 Flash(--default 替换为全局唯一聊天模型,思考深度 max)');
|
|
2633
2633
|
console.log(' inject-claude 注入 B.AI 多模型配置 (Claude/GPT/Gemini,仅追加)');
|
|
2634
2634
|
console.log(' inject-image 注入图像生成模型配置 (基于 vveai)');
|
|
2635
2635
|
console.log(' inject-token 设置 Gateway Token 为 aiyiran');
|
|
@@ -2843,7 +2843,7 @@ if (!command) {
|
|
|
2843
2843
|
console.log('[2/4] mc patch — 注入 UI + 技能');
|
|
2844
2844
|
runPatchFresh();
|
|
2845
2845
|
console.log('');
|
|
2846
|
-
console.log('[2.5/4] inject-minimax --default —
|
|
2846
|
+
console.log('[2.5/4] inject-minimax --default — 将 MiniMax 设为唯一聊天模型');
|
|
2847
2847
|
try {
|
|
2848
2848
|
const minimax = require('./injects/inject-minimax');
|
|
2849
2849
|
minimax.run(['--default']);
|
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
* inject-minimax.js
|
|
5
5
|
*
|
|
6
6
|
* 注入 MiniMax 模型配置到 openclaw.json,并为所有 agent 写入 API Key。
|
|
7
|
+
* 这是 myclaw 自己的部署配置。默认型号、生成预算、API 地址和内置备用凭据随插件版本维护,
|
|
8
|
+
* 运行时不读取开发者电脑的全局 MiniMax 接入标准。显式传入的密钥、环境变量或目标机器已有的
|
|
9
|
+
* 凭据按下面的逻辑优先使用。max 思考深度来自 MiniMax API 对 adaptive 请求的默认行为。
|
|
7
10
|
*
|
|
8
11
|
* 用法:
|
|
9
|
-
* myclaw inject-minimax #
|
|
10
|
-
* myclaw inject-minimax --default #
|
|
12
|
+
* myclaw inject-minimax # 更新 minimax provider,迁移旧 MiniMax 引用
|
|
13
|
+
* myclaw inject-minimax --default # 将 MiniMax-M3.1-Flash 设为唯一可选的聊天模型
|
|
11
14
|
* myclaw inject-minimax --only # 追加 + 设为默认 + 全部对话迁移 + 清掉所有其他 provider
|
|
12
15
|
* myclaw inject-minimax --beta # 6.X 模式: 仅 minimax,写 SQLite 鉴权,默认 minimax
|
|
13
16
|
* myclaw inject-minimax --key sk-xxx # 使用指定 API Key (仅 minimax)
|
|
@@ -15,7 +18,7 @@
|
|
|
15
18
|
* --beta 说明:
|
|
16
19
|
* - 适配 openclaw 6.X: 直接写 openclaw-agent.sqlite (6.X 运行时唯一鉴权源)
|
|
17
20
|
* - 去掉 minimax 的 authHeader
|
|
18
|
-
*
|
|
21
|
+
* - 独占清理时保留 minimax provider,默认模型仍为 minimax
|
|
19
22
|
*/
|
|
20
23
|
|
|
21
24
|
const fs = require('fs');
|
|
@@ -26,7 +29,31 @@ const { readConfig, writeConfig } = require('../find-config');
|
|
|
26
29
|
const DEFAULT_MINIMAX_KEY = "sk-cp-dZnzWB-ScLfjo8bO7DKTqSutkBXQsLWUmjhNDBRkgJd5e42qcE7z8J9i5m27V28eX-dYfo5Q7JNVG4XVsDi1zRxkIFZ4fT0DPGPJY7cHbqY5aBzJO1c6QVA";
|
|
27
30
|
|
|
28
31
|
const PROVIDER_ID = "minimax";
|
|
29
|
-
const
|
|
32
|
+
const MODEL_ID = "MiniMax-M3.1-Flash";
|
|
33
|
+
const DEFAULT_MODEL = PROVIDER_ID + '/' + MODEL_ID;
|
|
34
|
+
const OUTPUT_BUDGET = 131072;
|
|
35
|
+
|
|
36
|
+
function isMiniMaxModel(model, provider) {
|
|
37
|
+
return typeof model === 'string' && (
|
|
38
|
+
model.startsWith(PROVIDER_ID + '/') ||
|
|
39
|
+
(!model.includes('/') && (provider === PROVIDER_ID || model.startsWith('MiniMax-')))
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function migrateModelSelection(selection) {
|
|
44
|
+
if (typeof selection === 'string') {
|
|
45
|
+
return isMiniMaxModel(selection) ? DEFAULT_MODEL : selection;
|
|
46
|
+
}
|
|
47
|
+
if (!selection) return selection;
|
|
48
|
+
|
|
49
|
+
const primary = migrateModelSelection(selection.primary);
|
|
50
|
+
const updated = { ...selection, primary };
|
|
51
|
+
if (Array.isArray(selection.fallbacks)) {
|
|
52
|
+
updated.fallbacks = [...new Set(selection.fallbacks.map(migrateModelSelection))]
|
|
53
|
+
.filter((model) => model !== primary);
|
|
54
|
+
}
|
|
55
|
+
return updated;
|
|
56
|
+
}
|
|
30
57
|
|
|
31
58
|
function run(cliArgs) {
|
|
32
59
|
// ── 解析参数 ──
|
|
@@ -51,11 +78,6 @@ function run(cliArgs) {
|
|
|
51
78
|
}
|
|
52
79
|
}
|
|
53
80
|
|
|
54
|
-
if (!apiKey) {
|
|
55
|
-
apiKey = DEFAULT_MINIMAX_KEY;
|
|
56
|
-
console.log('💡 未传入 --key,使用默认 API Key');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
81
|
// ── 读取配置 ──
|
|
60
82
|
let config, configPath;
|
|
61
83
|
try {
|
|
@@ -65,6 +87,11 @@ function run(cliArgs) {
|
|
|
65
87
|
process.exit(1);
|
|
66
88
|
}
|
|
67
89
|
|
|
90
|
+
const configuredKey = config.models?.providers?.minimax?.apiKey;
|
|
91
|
+
const existingKey = typeof configuredKey === 'string' && !configuredKey.startsWith('$')
|
|
92
|
+
? configuredKey : undefined;
|
|
93
|
+
apiKey ||= process.env.MINIMAX_API_KEY || existingKey;
|
|
94
|
+
|
|
68
95
|
console.log('📍 找到配置: ' + configPath);
|
|
69
96
|
console.log('📌 模式: ' + (betaMode ? '--beta (独占+6.X兼容)' : onlyMode ? '--only (独占)' : setDefault ? '--default (设默认)' : '追加'));
|
|
70
97
|
|
|
@@ -119,87 +146,82 @@ function run(cliArgs) {
|
|
|
119
146
|
const minimaxProvider = {
|
|
120
147
|
baseUrl: "https://api.minimaxi.com/anthropic",
|
|
121
148
|
api: "anthropic-messages",
|
|
122
|
-
models: [
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
id: "MiniMax-M2.7-highspeed",
|
|
134
|
-
name: "MiniMax M2.7 Highspeed",
|
|
135
|
-
reasoning: true,
|
|
136
|
-
input: ["text"],
|
|
137
|
-
cost: { input: 0.3, output: 1.2, cacheRead: 0.06, cacheWrite: 0.375 },
|
|
138
|
-
contextWindow: 204800,
|
|
139
|
-
maxTokens: 131072
|
|
140
|
-
}
|
|
141
|
-
]
|
|
149
|
+
models: [{
|
|
150
|
+
id: MODEL_ID,
|
|
151
|
+
name: "MiniMax M3.1 Flash",
|
|
152
|
+
reasoning: true,
|
|
153
|
+
input: ["text", "image"],
|
|
154
|
+
cost: { input: 0.15, output: 0.60, cacheRead: 0.015, cacheWrite: 0 },
|
|
155
|
+
contextWindow: 1000000,
|
|
156
|
+
maxTokens: OUTPUT_BUDGET
|
|
157
|
+
}]
|
|
142
158
|
};
|
|
143
|
-
if (
|
|
159
|
+
if (existingKey) minimaxProvider.apiKey = apiKey;
|
|
160
|
+
if (!setDefault) minimaxProvider.authHeader = true;
|
|
144
161
|
config.models.providers.minimax = minimaxProvider;
|
|
145
162
|
|
|
146
163
|
if (!config.agents) config.agents = {};
|
|
147
164
|
if (!config.agents.defaults) config.agents.defaults = {};
|
|
148
165
|
if (!config.agents.defaults.models) config.agents.defaults.models = {};
|
|
149
166
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
167
|
+
const defaults = config.agents.defaults;
|
|
168
|
+
for (const model of Object.keys(defaults.models)) {
|
|
169
|
+
if (model !== DEFAULT_MODEL && (setDefault || isMiniMaxModel(model))) delete defaults.models[model];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// OpenClaw 2026.6.9 uses the MiniMax API's default max effort for adaptive thinking.
|
|
173
|
+
const modelConfig = defaults.models[DEFAULT_MODEL] || {};
|
|
174
|
+
defaults.models[DEFAULT_MODEL] = {
|
|
175
|
+
...modelConfig,
|
|
176
|
+
params: { ...modelConfig.params, thinking: 'adaptive', maxTokens: OUTPUT_BUDGET }
|
|
177
|
+
};
|
|
155
178
|
|
|
156
|
-
// ── Step 3:--default 设默认模型 ──
|
|
157
179
|
if (setDefault) {
|
|
158
|
-
|
|
180
|
+
defaults.model = { primary: DEFAULT_MODEL };
|
|
159
181
|
console.log('⚡ 默认模型 → ' + DEFAULT_MODEL);
|
|
160
|
-
} else {
|
|
161
|
-
|
|
182
|
+
} else if (defaults.model) {
|
|
183
|
+
defaults.model = migrateModelSelection(defaults.model);
|
|
162
184
|
}
|
|
163
185
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (agent.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
186
|
+
for (const agent of config.agents.list || []) {
|
|
187
|
+
if (setDefault) {
|
|
188
|
+
delete agent.model;
|
|
189
|
+
if (agent.subagents) delete agent.subagents.model;
|
|
190
|
+
if (agent.heartbeat) delete agent.heartbeat.model;
|
|
191
|
+
} else if (agent.model) {
|
|
192
|
+
agent.model = migrateModelSelection(agent.model);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (setDefault) {
|
|
196
|
+
for (const feature of [defaults.subagents, defaults.heartbeat, defaults.compaction]) {
|
|
197
|
+
if (feature) delete feature.model;
|
|
172
198
|
}
|
|
173
|
-
if (overrideCount > 0) console.log('🧹 --only: 已清除 ' + overrideCount + ' 个 agent 的独立 model 覆盖');
|
|
174
199
|
}
|
|
175
|
-
|
|
176
|
-
writeConfig(config, configPath);
|
|
177
|
-
console.log('✅ openclaw.json 已更新');
|
|
178
200
|
|
|
179
201
|
// ── Step 4:为所有 agent 写入 API Key ──
|
|
180
202
|
console.log('');
|
|
181
203
|
console.log('🔑 [Step 4] 写入 API Key 到所有 agent...');
|
|
182
204
|
|
|
183
|
-
const
|
|
205
|
+
const stateDir = process.env.OPENCLAW_STATE_DIR || path.dirname(configPath);
|
|
206
|
+
const DEFAULT_MAIN_DIR = path.join(stateDir, 'agents', 'main', 'agent');
|
|
184
207
|
const agentList = (config.agents && config.agents.list) || [];
|
|
185
208
|
|
|
186
209
|
const agentDirs = new Map();
|
|
187
210
|
agentDirs.set(DEFAULT_MAIN_DIR, 'main');
|
|
188
211
|
for (const agent of agentList) {
|
|
189
|
-
|
|
212
|
+
const directory = agent.agentDir?.replace(/^~\//, os.homedir() + '/') ||
|
|
213
|
+
path.join(stateDir, 'agents', agent.id, 'agent');
|
|
214
|
+
agentDirs.set(directory, agent.id);
|
|
190
215
|
}
|
|
191
216
|
|
|
192
|
-
//
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
// 6.X 运行时只从 SQLite 的 auth_profile_store 读 key,完全不读 auth-profiles.json,
|
|
196
|
-
// 因此 6.X 必须靠 --beta 写 SQLite 才能让 minimax 鉴权成功。
|
|
197
|
-
// 非 --beta 模式不碰 SQLite,避免覆盖其他 provider 已有的凭据。
|
|
198
|
-
let DatabaseSync = null;
|
|
199
|
-
if (betaMode) {
|
|
217
|
+
// 6.X loads agent credentials from SQLite. Legacy clients use auth-profiles.json.
|
|
218
|
+
let DatabaseSync;
|
|
219
|
+
if (setDefault) {
|
|
200
220
|
try {
|
|
201
221
|
({ DatabaseSync } = require('node:sqlite'));
|
|
202
|
-
} catch {
|
|
222
|
+
} catch (err) {
|
|
223
|
+
if (err.code !== 'ERR_UNKNOWN_BUILTIN_MODULE') throw err;
|
|
224
|
+
}
|
|
203
225
|
}
|
|
204
226
|
|
|
205
227
|
const SQLITE_SCHEMA = `
|
|
@@ -210,102 +232,100 @@ CREATE TABLE IF NOT EXISTS auth_profile_state (
|
|
|
210
232
|
state_key TEXT NOT NULL PRIMARY KEY, state_json TEXT NOT NULL, updated_at INTEGER NOT NULL
|
|
211
233
|
);`;
|
|
212
234
|
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
let okCount = 0, skipCount = 0;
|
|
235
|
+
let okCount = 0;
|
|
236
|
+
const profileId = 'minimax:cn';
|
|
217
237
|
|
|
218
238
|
for (const [agentDir, agentId] of agentDirs) {
|
|
219
|
-
|
|
220
|
-
try { fs.mkdirSync(agentDir, { recursive: true }); } catch { /* ignore */ }
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// ── 5.X:始终写 auth-profiles.json(兼容旧版) ──
|
|
239
|
+
fs.mkdirSync(agentDir, { recursive: true });
|
|
224
240
|
const profilesPath = path.join(agentDir, 'auth-profiles.json');
|
|
225
|
-
|
|
226
|
-
|
|
241
|
+
const profiles = fs.existsSync(profilesPath)
|
|
242
|
+
? JSON.parse(fs.readFileSync(profilesPath, 'utf8'))
|
|
243
|
+
: { version: 1, profiles: {}, lastGood: {} };
|
|
244
|
+
profiles.profiles ||= {};
|
|
245
|
+
profiles.lastGood ||= {};
|
|
246
|
+
let key = apiKey || profiles.profiles[profileId]?.key;
|
|
247
|
+
|
|
248
|
+
if (DatabaseSync) {
|
|
249
|
+
const db = new DatabaseSync(path.join(agentDir, 'openclaw-agent.sqlite'));
|
|
227
250
|
try {
|
|
228
|
-
|
|
229
|
-
if (parsed.profiles) profiles = parsed;
|
|
230
|
-
if (!profiles.lastGood) profiles.lastGood = {};
|
|
231
|
-
} catch { /* 解析失败用空骨架 */ }
|
|
232
|
-
}
|
|
233
|
-
profiles.profiles["minimax:cn"] = { type: "api_key", provider: "minimax", key: apiKey };
|
|
234
|
-
profiles.lastGood["minimax"] = "minimax:cn";
|
|
235
|
-
// 智谱已停用,移除旧版写入的鉴权。
|
|
236
|
-
for (const id of Object.keys(profiles.profiles)) {
|
|
237
|
-
if (profiles.profiles[id]?.provider === 'zai' || id.startsWith('zai:')) delete profiles.profiles[id];
|
|
238
|
-
}
|
|
239
|
-
delete profiles.lastGood.zai;
|
|
240
|
-
try { fs.writeFileSync(profilesPath, JSON.stringify(profiles, null, 2) + '\n', 'utf8'); } catch { /* ignore */ }
|
|
241
|
-
|
|
242
|
-
// ── 6.X (--beta):写入 openclaw-agent.sqlite(运行时唯一鉴权源)──
|
|
243
|
-
let sqliteOk = false;
|
|
244
|
-
if (DatabaseSync) { // 仅 betaMode 下 DatabaseSync 才被赋值
|
|
245
|
-
const dbPath = path.join(agentDir, 'openclaw-agent.sqlite');
|
|
246
|
-
try {
|
|
247
|
-
const db = new DatabaseSync(dbPath);
|
|
248
|
-
db.exec('PRAGMA journal_mode = WAL;');
|
|
251
|
+
db.exec('PRAGMA busy_timeout = 5000;');
|
|
249
252
|
db.exec(SQLITE_SCHEMA);
|
|
253
|
+
db.exec('BEGIN IMMEDIATE');
|
|
254
|
+
const storeRow = db.prepare('SELECT store_json FROM auth_profile_store WHERE store_key = ?').get('primary');
|
|
255
|
+
const stateRow = db.prepare('SELECT state_json FROM auth_profile_state WHERE state_key = ?').get('primary');
|
|
256
|
+
const store = storeRow ? JSON.parse(storeRow.store_json) : { version: 1, profiles: {} };
|
|
257
|
+
const state = stateRow ? JSON.parse(stateRow.state_json) : {};
|
|
258
|
+
store.profiles ||= {};
|
|
259
|
+
state.lastGood ||= {};
|
|
260
|
+
const prior = store.profiles[state.lastGood.minimax] || store.profiles[profileId];
|
|
261
|
+
key = apiKey || prior?.key || key || DEFAULT_MINIMAX_KEY;
|
|
262
|
+
store.profiles[profileId] = { type: 'api_key', provider: PROVIDER_ID, key };
|
|
263
|
+
state.lastGood.minimax = profileId;
|
|
250
264
|
const now = Date.now();
|
|
251
265
|
db.prepare('INSERT OR REPLACE INTO auth_profile_store (store_key, store_json, updated_at) VALUES (?,?,?)')
|
|
252
|
-
.run('primary', JSON.stringify(
|
|
266
|
+
.run('primary', JSON.stringify(store), now);
|
|
253
267
|
db.prepare('INSERT OR REPLACE INTO auth_profile_state (state_key, state_json, updated_at) VALUES (?,?,?)')
|
|
254
|
-
.run('primary', JSON.stringify(
|
|
268
|
+
.run('primary', JSON.stringify(state), now);
|
|
269
|
+
db.exec('COMMIT');
|
|
270
|
+
} finally {
|
|
255
271
|
db.close();
|
|
256
|
-
sqliteOk = true;
|
|
257
|
-
} catch (err) {
|
|
258
|
-
console.log(' ⚠ ' + agentId + ' (sqlite): ' + err.message);
|
|
259
272
|
}
|
|
260
273
|
}
|
|
261
274
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
skipCount++;
|
|
268
|
-
}
|
|
275
|
+
profiles.profiles[profileId] = { type: 'api_key', provider: PROVIDER_ID, key: key || DEFAULT_MINIMAX_KEY };
|
|
276
|
+
profiles.lastGood.minimax = profileId;
|
|
277
|
+
fs.writeFileSync(profilesPath, JSON.stringify(profiles, null, 2) + '\n', { mode: 0o600 });
|
|
278
|
+
console.log(' ✅ ' + agentId + (DatabaseSync ? ' (json+sqlite)' : ' (json)'));
|
|
279
|
+
okCount++;
|
|
269
280
|
}
|
|
270
281
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
console.log('');
|
|
274
|
-
console.log('🔄 [Step 5] 迁移全部对话 → ' + DEFAULT_MODEL + ' ...');
|
|
275
|
-
let sessionOk = 0, sessionSkip = 0, sessionChanged = 0;
|
|
282
|
+
writeConfig(config, configPath);
|
|
283
|
+
console.log('✅ openclaw.json 已更新');
|
|
276
284
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
285
|
+
// ── Step 5:迁移旧 MiniMax 会话,设默认模式沿用全部会话迁移 ──
|
|
286
|
+
let sessionOk = 0, sessionSkip = 0, sessionChanged = 0;
|
|
287
|
+
|
|
288
|
+
for (const [agentDir] of agentDirs) {
|
|
289
|
+
const sessionsPath = path.join(agentDir, '..', 'sessions', 'sessions.json');
|
|
290
|
+
if (!fs.existsSync(sessionsPath)) continue;
|
|
291
|
+
try {
|
|
292
|
+
const sessions = JSON.parse(fs.readFileSync(sessionsPath, 'utf8'));
|
|
293
|
+
let changed = 0;
|
|
294
|
+
for (const session of Object.values(sessions)) {
|
|
295
|
+
if (!session) continue;
|
|
296
|
+
let updated = false;
|
|
297
|
+
if (session.model && (setDefault || isMiniMaxModel(session.model, session.modelProvider)) &&
|
|
298
|
+
(session.model !== MODEL_ID || session.modelProvider !== PROVIDER_ID)) {
|
|
299
|
+
session.model = MODEL_ID;
|
|
300
|
+
session.modelProvider = PROVIDER_ID;
|
|
301
|
+
updated = true;
|
|
290
302
|
}
|
|
291
|
-
if (
|
|
292
|
-
|
|
293
|
-
|
|
303
|
+
if (session.modelOverride &&
|
|
304
|
+
(setDefault || isMiniMaxModel(session.modelOverride, session.providerOverride)) &&
|
|
305
|
+
(session.modelOverride !== MODEL_ID || session.providerOverride !== PROVIDER_ID)) {
|
|
306
|
+
session.modelOverride = MODEL_ID;
|
|
307
|
+
session.providerOverride = PROVIDER_ID;
|
|
308
|
+
updated = true;
|
|
294
309
|
}
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
|
|
310
|
+
if (updated) changed++;
|
|
311
|
+
}
|
|
312
|
+
if (changed > 0) {
|
|
313
|
+
fs.writeFileSync(sessionsPath, JSON.stringify(sessions, null, 2) + '\n', 'utf8');
|
|
314
|
+
sessionChanged += changed;
|
|
298
315
|
}
|
|
316
|
+
sessionOk++;
|
|
317
|
+
} catch {
|
|
318
|
+
sessionSkip++;
|
|
299
319
|
}
|
|
300
|
-
console.log(' 对话迁移: ' + sessionChanged + ' 条,文件: ' + sessionOk + ' 个,跳过: ' + sessionSkip + ' 个');
|
|
301
320
|
}
|
|
321
|
+
console.log(' 对话迁移: ' + sessionChanged + ' 条,文件: ' + sessionOk + ' 个,跳过: ' + sessionSkip + ' 个');
|
|
302
322
|
|
|
303
323
|
// ── 汇总 ──
|
|
304
324
|
console.log('');
|
|
305
325
|
console.log('✅ MiniMax 注入完成');
|
|
306
|
-
console.log('
|
|
307
|
-
console.log('
|
|
308
|
-
console.log(' Agent: ' + okCount + '
|
|
326
|
+
console.log(' MiniMax: ' + DEFAULT_MODEL + ' (adaptive / max)');
|
|
327
|
+
if (setDefault) console.log(' 全局唯一聊天模型: ' + DEFAULT_MODEL);
|
|
328
|
+
console.log(' Agent: ' + okCount + ' 个写入');
|
|
309
329
|
if (betaMode) console.log(' 其他 provider 已清除 (保留 minimax)');
|
|
310
330
|
else if (onlyMode) console.log(' 其他 provider 已清除');
|
|
311
331
|
console.log('');
|
package/package.json
CHANGED
|
@@ -1,33 +1,16 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: minimax-inject
|
|
3
|
-
description:
|
|
3
|
+
description: 通过 myclaw 注入 MiniMax M3.1 Flash。将 M3.1 Flash 设为全局唯一聊天模型,默认使用 max 思考深度。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# MiniMax 模型注入
|
|
7
7
|
|
|
8
|
-
将 OpenClaw 的模型配置清空,替换为唯一的 MiniMax M2.7 模型。
|
|
9
|
-
|
|
10
|
-
## 使用方法
|
|
11
|
-
|
|
12
8
|
```bash
|
|
13
|
-
|
|
14
|
-
node scripts/inject.js
|
|
15
|
-
|
|
16
|
-
# 注入模型 + 设置 API Key
|
|
17
|
-
node scripts/inject.js --key sk-你的key
|
|
9
|
+
myclaw inject-minimax --default
|
|
18
10
|
```
|
|
19
11
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
| 字段 | 值 |
|
|
23
|
-
|------|-----|
|
|
24
|
-
| auth.profiles | minimax:cn |
|
|
25
|
-
| models.providers | minimax (MiniMax-M2.7) |
|
|
26
|
-
| agents.defaults.model | minimax/MiniMax-M2.7-highspeed |
|
|
27
|
-
| imageGenerationModel | minimax/image-01 |
|
|
12
|
+
该命令将 OpenClaw 的唯一可选聊天模型及全局默认设为 `minimax/MiniMax-M3.1-Flash`,生成预算为 131072 token。OpenClaw 2026.6.9 使用 adaptive thinking,思考深度由 MiniMax API 默认设为 max。命令在注入后重启 Gateway。
|
|
28
13
|
|
|
29
|
-
|
|
14
|
+
模型、生成预算、API 地址和内置备用凭据由 myclaw 自己维护。插件运行不依赖开发者电脑的全局模型配置。可以在目标机器上复用已有凭据,也可以通过 `MINIMAX_API_KEY` 提供凭据。
|
|
30
15
|
|
|
31
|
-
|
|
32
|
-
- 自动重启 Gateway 使配置生效
|
|
33
|
-
- 如果传了 `--key`,会将 MINIMAX_API_KEY 写入 shell 配置文件
|
|
16
|
+
兼容入口 `node scripts/inject.js` 调用同一条命令。
|