@aiyiran/myclaw 1.1.5 → 1.1.7

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 CHANGED
@@ -143,9 +143,8 @@ function start() {
143
143
  // 等待启动完成
144
144
  execSync(isWin ? 'timeout /t 3 /nobreak >nul' : 'sleep 3', { stdio: 'ignore' });
145
145
 
146
- // 注册守卫(仅非 Docker 环境)
147
- const isDocker = require('fs').existsSync('/.dockerenv');
148
- if (!isWin && !isDocker) {
146
+ // 注册守卫(崩溃自动重启、开机自启)
147
+ if (!isWin) {
149
148
  try {
150
149
  execSync('openclaw gateway install', { stdio: 'pipe', timeout: 10000 });
151
150
  console.log('[守卫] ' + colors.green + 'LaunchAgent 已注册,崩溃/重启会自动拉起' + colors.nc);
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 --install-daemon');
1080
+ console.log(' 3. openclaw onboard --non-interactive --accept-risk --skip-health');
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 --install-daemon');
1122
+ console.log('[3/6] openclaw onboard --non-interactive --accept-risk --skip-health');
1123
1123
  try {
1124
- execSync('openclaw onboard --non-interactive --accept-risk --skip-health --install-daemon', { stdio: 'inherit' });
1124
+ execSync('openclaw onboard --non-interactive --accept-risk --skip-health', { 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 && DEFAULT_MINIMAX_KEY) {
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"] = {
@@ -64,6 +66,7 @@ function run(cliArgs) {
64
66
  baseUrl: "https://api.minimaxi.com/anthropic",
65
67
  api: "anthropic-messages",
66
68
  authHeader: true,
69
+ apiKey: apiKey,
67
70
  models: [
68
71
  {
69
72
  id: "MiniMax-M2.7-highspeed",
@@ -98,17 +101,64 @@ function run(cliArgs) {
98
101
  delete config.agents.defaults.models["minimax/MiniMax-M2.7"];
99
102
  }
100
103
 
101
- // ─── 写入 ───
104
+ // ─── 写入 openclaw.json ───
102
105
  writeConfig(config, configPath);
106
+ console.log('✅ openclaw.json 已更新');
107
+
108
+ // ─── 5. 为所有 agent 写入 auth-profiles.json ───
109
+ const agentList = (config.agents && config.agents.list) || [];
110
+ let okCount = 0;
111
+ let skipCount = 0;
112
+
113
+ for (const agent of agentList) {
114
+ const agentDir = agent.agentDir;
115
+ if (!agentDir) {
116
+ skipCount++;
117
+ continue;
118
+ }
119
+
120
+ const profilesPath = path.join(agentDir, 'auth-profiles.json');
121
+
122
+ // 读取现有文件(若存在),否则创建骨架
123
+ let profiles = { version: 1, profiles: {}, lastGood: {} };
124
+ if (fs.existsSync(profilesPath)) {
125
+ try {
126
+ profiles = JSON.parse(fs.readFileSync(profilesPath, 'utf8'));
127
+ if (!profiles.profiles) profiles.profiles = {};
128
+ if (!profiles.lastGood) profiles.lastGood = {};
129
+ } catch {
130
+ // 解析失败则重建
131
+ profiles = { version: 1, profiles: {}, lastGood: {} };
132
+ }
133
+ }
103
134
 
104
- // 验证
105
- const verify = readConfig();
106
- const writtenModelId = verify.config.models?.providers?.minimax?.models?.[0]?.id || '???';
107
- const writtenDefault = verify.config.agents?.defaults?.model?.primary || '???';
135
+ // 写入 minimax:cn,保留其他 profile 不动
136
+ profiles.profiles["minimax:cn"] = {
137
+ type: "api_key",
138
+ provider: "minimax",
139
+ key: apiKey
140
+ };
141
+ profiles.lastGood["minimax"] = "minimax:cn";
142
+
143
+ try {
144
+ // 确保目录存在
145
+ if (!fs.existsSync(agentDir)) {
146
+ fs.mkdirSync(agentDir, { recursive: true });
147
+ }
148
+ fs.writeFileSync(profilesPath, JSON.stringify(profiles, null, 2) + '\n', 'utf8');
149
+ console.log(' ✅ ' + agent.id);
150
+ okCount++;
151
+ } catch (err) {
152
+ console.log(' ⚠ ' + agent.id + ': ' + err.message);
153
+ skipCount++;
154
+ }
155
+ }
108
156
 
157
+ console.log('');
109
158
  console.log('✅ MiniMax 配置已注入');
110
- console.log(' 模型: ' + writtenModelId);
111
- console.log(' 默认: ' + writtenDefault);
159
+ console.log(' 模型: MiniMax-M2.7-highspeed');
160
+ console.log(' 默认: minimax/MiniMax-M2.7-highspeed');
161
+ console.log(' Agent: ' + okCount + ' 个写入成功,' + skipCount + ' 个跳过');
112
162
  console.log('');
113
163
  }
114
164
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {