@aiyiran/myclaw 1.0.53 → 1.0.54

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/inject-minimax.js CHANGED
@@ -5,6 +5,7 @@
5
5
  *
6
6
  * 将 openclaw.json 中的模型配置清空,注入为唯一的 MiniMax 模型。
7
7
  * 自动查找 ~/.openclaw/openclaw.json
8
+ * API Key 通过 openclaw onboard 管理,不写环境变量。
8
9
  *
9
10
  * 入口: myclaw minimax [--key sk-xxx]
10
11
  */
@@ -49,7 +50,7 @@ function run(cliArgs) {
49
50
  }
50
51
  };
51
52
 
52
- // 2. models.providers → 只保留 minimax
53
+ // 2. models.providers → 只保留 minimax(key 由 onboard 管理)
53
54
  config.models = {
54
55
  mode: "merge",
55
56
  providers: {
@@ -57,9 +58,6 @@ function run(cliArgs) {
57
58
  baseUrl: "https://api.minimaxi.com/anthropic",
58
59
  api: "anthropic-messages",
59
60
  authHeader: true,
60
- headers: {
61
- "Authorization": "Bearer ${env:MINIMAX_API_KEY}"
62
- },
63
61
  models: [
64
62
  {
65
63
  id: "MiniMax-M2.7",
@@ -97,8 +95,7 @@ function run(cliArgs) {
97
95
  };
98
96
 
99
97
  // 写回文件
100
- const output = JSON.stringify(config, null, 2) + '\n';
101
- fs.writeFileSync(targetPath, output, 'utf8');
98
+ fs.writeFileSync(targetPath, JSON.stringify(config, null, 2) + '\n', 'utf8');
102
99
 
103
100
  console.log('✅ MiniMax 模型配置已注入');
104
101
  console.log('');
@@ -106,10 +103,10 @@ function run(cliArgs) {
106
103
  console.log(' models.providers → minimax (MiniMax-M2.7)');
107
104
  console.log(' agents.defaults → minimax/MiniMax-M2.7-highspeed');
108
105
 
109
- // 4. 通过 openclaw onboard 原生命令确认配置
106
+ // 4. 通过 openclaw onboard 设置 API Key
110
107
  if (apiKey) {
111
108
  console.log('');
112
- console.log('🔧 执行 openclaw onboard (非交互)...');
109
+ console.log('🔑 执行 openclaw onboard (设置 API Key)...');
113
110
  try {
114
111
  const { execSync } = require('child_process');
115
112
  execSync([
@@ -121,62 +118,13 @@ function run(cliArgs) {
121
118
  '--token "' + apiKey + '"',
122
119
  '--minimax-api-key "' + apiKey + '"',
123
120
  ].join(' '), { stdio: 'inherit' });
124
- console.log('✅ openclaw onboard 完成');
121
+ console.log('✅ API Key 已通过 onboard 设置');
125
122
  } catch (err) {
126
- console.log('⚠️ openclaw onboard 失败 (非致命): ' + err.message);
127
- }
128
- }
129
-
130
- // 5. 如果传了 --key,写入环境变量
131
- if (apiKey) {
132
- console.log('');
133
- console.log('🔑 设置 MINIMAX_API_KEY 环境变量...');
134
-
135
- const platform = os.platform();
136
-
137
- if (platform === 'win32') {
138
- try {
139
- const { execSync } = require('child_process');
140
- execSync('setx MINIMAX_API_KEY "' + apiKey + '"', { stdio: 'pipe' });
141
- console.log(' ✅ 已通过 setx 写入 Windows 用户环境变量');
142
- } catch (err) {
143
- console.log(' ❌ setx 写入失败: ' + err.message);
144
- }
145
- } else {
146
- const shell = process.env.SHELL || '/bin/bash';
147
- let rcFiles = [];
148
- if (shell.includes('zsh')) {
149
- rcFiles = [path.join(os.homedir(), '.zshrc')];
150
- } else {
151
- rcFiles = [path.join(os.homedir(), '.bashrc')];
152
- }
153
- const profilePath = path.join(os.homedir(), '.profile');
154
- if (fs.existsSync(profilePath) && !rcFiles.includes(profilePath)) {
155
- rcFiles.push(profilePath);
156
- }
157
-
158
- const exportLine = 'export MINIMAX_API_KEY="' + apiKey + '"';
159
-
160
- for (const rcFile of rcFiles) {
161
- let content = '';
162
- try { content = fs.readFileSync(rcFile, 'utf8'); } catch {}
163
-
164
- if (content.includes('MINIMAX_API_KEY')) {
165
- content = content.replace(/^export MINIMAX_API_KEY=.*$/m, exportLine);
166
- fs.writeFileSync(rcFile, content, 'utf8');
167
- console.log(' ✅ 已更新: ' + rcFile);
168
- } else {
169
- fs.appendFileSync(rcFile, '\n# MiniMax API Key (by myclaw minimax)\n' + exportLine + '\n');
170
- console.log(' ✅ 已追加: ' + rcFile);
171
- }
172
- }
173
-
174
- process.env.MINIMAX_API_KEY = apiKey;
175
- console.log(' ✅ 当前进程已设置 MINIMAX_API_KEY');
123
+ console.log('⚠️ onboard 失败: ' + err.message);
176
124
  }
177
125
  } else {
178
126
  console.log('');
179
- console.log('💡 未传入 --keyAPI Key 将使用环境变量 MINIMAX_API_KEY');
127
+ console.log('💡 未传入 --key,跳过 API Key 设置');
180
128
  console.log(' 设置方法: myclaw minimax --key sk-xxx');
181
129
  }
182
130
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.0.53",
3
+ "version": "1.0.54",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -7,8 +7,8 @@
7
7
  * OpenClaw agent 可直接调用此脚本。
8
8
  *
9
9
  * 用法:
10
- * node inject.js # 注入模型配置
11
- * node inject.js --key sk-xxx # 注入模型 + 设置 API Key
10
+ * node inject.js # 只注入模型配置(不设 key)
11
+ * node inject.js --key sk-xxx # 注入模型 + 通过 onboard 设置 key
12
12
  */
13
13
 
14
14
  const fs = require('fs');
@@ -65,9 +65,6 @@ config.models = {
65
65
  baseUrl: "https://api.minimaxi.com/anthropic",
66
66
  api: "anthropic-messages",
67
67
  authHeader: true,
68
- headers: {
69
- "Authorization": "Bearer ${env:MINIMAX_API_KEY}"
70
- },
71
68
  models: [
72
69
  {
73
70
  id: "MiniMax-M2.7",
@@ -111,12 +108,12 @@ console.log(' models.providers → minimax (MiniMax-M2.7)');
111
108
  console.log(' agents.defaults → minimax/MiniMax-M2.7-highspeed');
112
109
 
113
110
  // ============================================================================
114
- // 通过 openclaw onboard 原生命令确认配置
111
+ // 通过 openclaw onboard 设置 API Key
115
112
  // ============================================================================
116
113
 
117
114
  if (apiKey) {
118
115
  console.log('');
119
- console.log('🔧 执行 openclaw onboard (非交互)...');
116
+ console.log('🔑 执行 openclaw onboard (设置 API Key)...');
120
117
  try {
121
118
  execSync([
122
119
  'openclaw onboard',
@@ -127,57 +124,18 @@ if (apiKey) {
127
124
  '--token "' + apiKey + '"',
128
125
  '--minimax-api-key "' + apiKey + '"',
129
126
  ].join(' '), { stdio: 'inherit' });
130
- console.log('✅ openclaw onboard 完成');
127
+ console.log('✅ API Key 已通过 onboard 设置');
131
128
  } catch (err) {
132
- console.log('⚠️ openclaw onboard 失败 (非致命,JSON 已手动注入): ' + err.message);
133
- }
134
- }
135
-
136
- // ============================================================================
137
- // 设置 API Key(如果传了 --key)
138
- // ============================================================================
139
-
140
- if (apiKey) {
141
- console.log('');
142
- console.log('🔑 设置 MINIMAX_API_KEY...');
143
-
144
- if (os.platform() === 'win32') {
145
- try {
146
- execSync('setx MINIMAX_API_KEY "' + apiKey + '"', { stdio: 'pipe' });
147
- console.log(' ✅ 已写入 Windows 用户环境变量');
148
- } catch (err) {
149
- console.log(' ❌ setx 失败: ' + err.message);
150
- }
151
- } else {
152
- const shell = process.env.SHELL || '/bin/bash';
153
- const rcFile = shell.includes('zsh')
154
- ? path.join(os.homedir(), '.zshrc')
155
- : path.join(os.homedir(), '.bashrc');
156
-
157
- const exportLine = 'export MINIMAX_API_KEY="' + apiKey + '"';
158
- let content = '';
159
- try { content = fs.readFileSync(rcFile, 'utf8'); } catch {}
160
-
161
- if (content.includes('MINIMAX_API_KEY')) {
162
- content = content.replace(/^export MINIMAX_API_KEY=.*$/m, exportLine);
163
- fs.writeFileSync(rcFile, content, 'utf8');
164
- console.log(' ✅ 已更新: ' + rcFile);
165
- } else {
166
- fs.appendFileSync(rcFile, '\n# MiniMax API Key\n' + exportLine + '\n');
167
- console.log(' ✅ 已追加: ' + rcFile);
168
- }
169
-
170
- // 同时设到当前进程,确保重启的 gateway 能继承
171
- process.env.MINIMAX_API_KEY = apiKey;
172
- console.log(' ✅ 当前进程已设置');
129
+ console.log('⚠️ onboard 失败: ' + err.message);
173
130
  }
174
131
  } else {
175
132
  console.log('');
176
- console.log('💡 未传入 --key,将使用环境变量 MINIMAX_API_KEY');
133
+ console.log('💡 未传入 --key,跳过 API Key 设置');
134
+ console.log(' 设置方法: node inject.js --key sk-xxx');
177
135
  }
178
136
 
179
137
  // ============================================================================
180
- // 重启 Gateway(不依赖 myclaw)
138
+ // 重启 Gateway
181
139
  // ============================================================================
182
140
 
183
141
  console.log('');