@aiyiran/myclaw 1.1.4 → 1.1.6
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/gateway.js +2 -7
- package/index.js +3 -3
- package/injects/inject-minimax.js +72 -23
- package/package.json +1 -1
package/gateway.js
CHANGED
|
@@ -143,8 +143,7 @@ function start() {
|
|
|
143
143
|
// 等待启动完成
|
|
144
144
|
execSync(isWin ? 'timeout /t 3 /nobreak >nul' : 'sleep 3', { stdio: 'ignore' });
|
|
145
145
|
|
|
146
|
-
//
|
|
147
|
-
// 放在健康检查之前:守卫注册只需写 plist 文件,不依赖 gateway 是否已就绪
|
|
146
|
+
// 注册守卫(崩溃自动重启、开机自启)
|
|
148
147
|
if (!isWin) {
|
|
149
148
|
try {
|
|
150
149
|
execSync('openclaw gateway install', { stdio: 'pipe', timeout: 10000 });
|
|
@@ -175,11 +174,7 @@ function start() {
|
|
|
175
174
|
function restart() {
|
|
176
175
|
stop();
|
|
177
176
|
console.log('');
|
|
178
|
-
|
|
179
|
-
try {
|
|
180
|
-
execSync('mc up', { stdio: 'inherit' });
|
|
181
|
-
} catch {}
|
|
182
|
-
return result;
|
|
177
|
+
return start();
|
|
183
178
|
}
|
|
184
179
|
|
|
185
180
|
module.exports = { stop, start, restart, PORT };
|
package/index.js
CHANGED
|
@@ -1077,7 +1077,7 @@ function runNuke(cliArgs) {
|
|
|
1077
1077
|
console.log(' 此命令将执行以下操作:');
|
|
1078
1078
|
console.log(' 1. ' + colors.red + 'rm -rf /root/.openclaw' + colors.nc);
|
|
1079
1079
|
console.log(' 2. ' + colors.red + 'rm -rf ~/.openclaw' + colors.nc);
|
|
1080
|
-
console.log(' 3. openclaw onboard --non-interactive --accept-risk --skip-health');
|
|
1080
|
+
console.log(' 3. openclaw onboard --non-interactive --accept-risk --skip-health --install-daemon');
|
|
1081
1081
|
console.log(' 4. mc up');
|
|
1082
1082
|
console.log(' 5. mc patch');
|
|
1083
1083
|
console.log(' 6. mc restart');
|
|
@@ -1119,9 +1119,9 @@ function runNuke(cliArgs) {
|
|
|
1119
1119
|
console.log('');
|
|
1120
1120
|
|
|
1121
1121
|
// Step 3: openclaw onboard
|
|
1122
|
-
console.log('[3/6] openclaw onboard --non-interactive --accept-risk --skip-health');
|
|
1122
|
+
console.log('[3/6] openclaw onboard --non-interactive --accept-risk --skip-health --install-daemon');
|
|
1123
1123
|
try {
|
|
1124
|
-
execSync('openclaw onboard --non-interactive --accept-risk --skip-health', { stdio: 'inherit' });
|
|
1124
|
+
execSync('openclaw onboard --non-interactive --accept-risk --skip-health --install-daemon', { stdio: 'inherit' });
|
|
1125
1125
|
console.log(' ' + colors.green + '✓ 完成' + colors.nc);
|
|
1126
1126
|
} catch (err) {
|
|
1127
1127
|
console.log(' ' + colors.red + '✗ 失败: ' + err.message + colors.nc);
|
|
@@ -2,20 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* inject-minimax.js
|
|
5
|
-
*
|
|
6
|
-
* 注入 MiniMax 模型配置到 openclaw.json。
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* 1. 设置 minimax auth profile
|
|
10
|
-
* 2. 注册 minimax provider + 模型定义
|
|
11
|
-
* 3. 设置默认聊天模型为 MiniMax
|
|
12
|
-
* 4. 将 MiniMax 模型加入白名单
|
|
13
|
-
*
|
|
5
|
+
*
|
|
6
|
+
* 注入 MiniMax 模型配置到 openclaw.json,并为所有 agent 写入 API Key。
|
|
7
|
+
*
|
|
8
|
+
* 做以下事情:
|
|
9
|
+
* 1. 设置 minimax auth profile (openclaw.json)
|
|
10
|
+
* 2. 注册 minimax provider + 模型定义 (openclaw.json)
|
|
11
|
+
* 3. 设置默认聊天模型为 MiniMax (openclaw.json)
|
|
12
|
+
* 4. 将 MiniMax 模型加入白名单 (openclaw.json)
|
|
13
|
+
* 5. 为所有 agent 写入 API Key (~/.openclaw/agents/<id>/agent/auth-profiles.json)
|
|
14
|
+
*
|
|
14
15
|
* 不触碰: 图片模型、其他 provider、onboard 流程
|
|
15
|
-
*
|
|
16
|
-
* 入口: myclaw minimax [--key sk-xxx]
|
|
16
|
+
*
|
|
17
|
+
* 入口: myclaw inject-minimax [--key sk-xxx]
|
|
17
18
|
*/
|
|
18
19
|
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
const path = require('path');
|
|
19
22
|
const { readConfig, writeConfig } = require('../find-config');
|
|
20
23
|
|
|
21
24
|
const DEFAULT_MINIMAX_KEY = "sk-cp-DC5lWd2Stt9CBFzLIT2awP4K-ZEn5AkYwjl3Cdj-mIBmgjxod518F2LaVF2L9c35Wv5-Eox0F1ctJD5vXtB9p3OmxoWLd9ge9zIUIMrCVuqBYdL_s6kb8Qs";
|
|
@@ -30,24 +33,23 @@ function run(cliArgs) {
|
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
if (!apiKey
|
|
36
|
+
if (!apiKey) {
|
|
34
37
|
apiKey = DEFAULT_MINIMAX_KEY;
|
|
35
38
|
console.log('💡 未传入 --key 参数,使用默认 API Key');
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
// 读取配置
|
|
39
|
-
let configPath;
|
|
42
|
+
let config, configPath;
|
|
40
43
|
try {
|
|
41
|
-
({ configPath } = readConfig());
|
|
44
|
+
({ config, configPath } = readConfig());
|
|
42
45
|
} catch (err) {
|
|
43
46
|
console.error('❌ ' + err.message);
|
|
44
47
|
process.exit(1);
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
console.log('📍 找到配置: ' + configPath);
|
|
48
|
-
const { config } = readConfig();
|
|
49
51
|
|
|
50
|
-
// ─── 1. auth profile ───
|
|
52
|
+
// ─── 1. auth profile (openclaw.json) ───
|
|
51
53
|
if (!config.auth) config.auth = {};
|
|
52
54
|
if (!config.auth.profiles) config.auth.profiles = {};
|
|
53
55
|
config.auth.profiles["minimax:cn"] = {
|
|
@@ -98,17 +100,64 @@ function run(cliArgs) {
|
|
|
98
100
|
delete config.agents.defaults.models["minimax/MiniMax-M2.7"];
|
|
99
101
|
}
|
|
100
102
|
|
|
101
|
-
// ─── 写入 ───
|
|
103
|
+
// ─── 写入 openclaw.json ───
|
|
102
104
|
writeConfig(config, configPath);
|
|
105
|
+
console.log('✅ openclaw.json 已更新');
|
|
106
|
+
|
|
107
|
+
// ─── 5. 为所有 agent 写入 auth-profiles.json ───
|
|
108
|
+
const agentList = (config.agents && config.agents.list) || [];
|
|
109
|
+
let okCount = 0;
|
|
110
|
+
let skipCount = 0;
|
|
111
|
+
|
|
112
|
+
for (const agent of agentList) {
|
|
113
|
+
const agentDir = agent.agentDir;
|
|
114
|
+
if (!agentDir) {
|
|
115
|
+
skipCount++;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const profilesPath = path.join(agentDir, 'auth-profiles.json');
|
|
120
|
+
|
|
121
|
+
// 读取现有文件(若存在),否则创建骨架
|
|
122
|
+
let profiles = { version: 1, profiles: {}, lastGood: {} };
|
|
123
|
+
if (fs.existsSync(profilesPath)) {
|
|
124
|
+
try {
|
|
125
|
+
profiles = JSON.parse(fs.readFileSync(profilesPath, 'utf8'));
|
|
126
|
+
if (!profiles.profiles) profiles.profiles = {};
|
|
127
|
+
if (!profiles.lastGood) profiles.lastGood = {};
|
|
128
|
+
} catch {
|
|
129
|
+
// 解析失败则重建
|
|
130
|
+
profiles = { version: 1, profiles: {}, lastGood: {} };
|
|
131
|
+
}
|
|
132
|
+
}
|
|
103
133
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
134
|
+
// 写入 minimax:cn,保留其他 profile 不动
|
|
135
|
+
profiles.profiles["minimax:cn"] = {
|
|
136
|
+
type: "api_key",
|
|
137
|
+
provider: "minimax",
|
|
138
|
+
key: apiKey
|
|
139
|
+
};
|
|
140
|
+
profiles.lastGood["minimax"] = "minimax:cn";
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
// 确保目录存在
|
|
144
|
+
if (!fs.existsSync(agentDir)) {
|
|
145
|
+
fs.mkdirSync(agentDir, { recursive: true });
|
|
146
|
+
}
|
|
147
|
+
fs.writeFileSync(profilesPath, JSON.stringify(profiles, null, 2) + '\n', 'utf8');
|
|
148
|
+
console.log(' ✅ ' + agent.id);
|
|
149
|
+
okCount++;
|
|
150
|
+
} catch (err) {
|
|
151
|
+
console.log(' ⚠ ' + agent.id + ': ' + err.message);
|
|
152
|
+
skipCount++;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
108
155
|
|
|
156
|
+
console.log('');
|
|
109
157
|
console.log('✅ MiniMax 配置已注入');
|
|
110
|
-
console.log(' 模型:
|
|
111
|
-
console.log(' 默认:
|
|
158
|
+
console.log(' 模型: MiniMax-M2.7-highspeed');
|
|
159
|
+
console.log(' 默认: minimax/MiniMax-M2.7-highspeed');
|
|
160
|
+
console.log(' Agent: ' + okCount + ' 个写入成功,' + skipCount + ' 个跳过');
|
|
112
161
|
console.log('');
|
|
113
162
|
}
|
|
114
163
|
|