@aiyiran/myclaw 1.1.1 → 1.1.3
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/.claude/settings.local.json +2 -1
- package/gateway.js +11 -11
- package/index.js +112 -0
- package/injects/inject-controlui.js +45 -0
- package/package.json +1 -1
- package/patches/patch-manifest.json +5 -0
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
"permissions": {
|
|
3
3
|
"allow": [
|
|
4
4
|
"WebSearch",
|
|
5
|
-
"Bash(python3 -c \"import json,sys; d=json.load\\(sys.stdin\\); agents=d.get\\('agents',{}\\).get\\('list',[]\\); [print\\(a.get\\('id'\\), '|', a.get\\('workspace',''\\)\\) for a in agents if a]\")"
|
|
5
|
+
"Bash(python3 -c \"import json,sys; d=json.load\\(sys.stdin\\); agents=d.get\\('agents',{}\\).get\\('list',[]\\); [print\\(a.get\\('id'\\), '|', a.get\\('workspace',''\\)\\) for a in agents if a]\")",
|
|
6
|
+
"Bash(node *)"
|
|
6
7
|
]
|
|
7
8
|
}
|
|
8
9
|
}
|
package/gateway.js
CHANGED
|
@@ -143,23 +143,23 @@ function start() {
|
|
|
143
143
|
// 等待启动完成
|
|
144
144
|
execSync(isWin ? 'timeout /t 3 /nobreak >nul' : 'sleep 3', { stdio: 'ignore' });
|
|
145
145
|
|
|
146
|
+
// 注册 LaunchAgent 作为守卫(崩溃自动重启、开机自启)
|
|
147
|
+
// 放在健康检查之前:守卫注册只需写 plist 文件,不依赖 gateway 是否已就绪
|
|
148
|
+
if (!isWin) {
|
|
149
|
+
try {
|
|
150
|
+
execSync('openclaw gateway install', { stdio: 'pipe', timeout: 10000 });
|
|
151
|
+
console.log('[守卫] ' + colors.green + 'LaunchAgent 已注册,崩溃/重启会自动拉起' + colors.nc);
|
|
152
|
+
} catch (err) {
|
|
153
|
+
console.log('[守卫] ' + colors.yellow + '注册失败: ' + (err.message || err) + colors.nc);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
146
157
|
// 健康检查
|
|
147
158
|
try {
|
|
148
159
|
execSync('openclaw health', { stdio: 'pipe', timeout: 5000 });
|
|
149
160
|
console.log('[启动] ' + colors.green + 'Gateway 启动成功!' + colors.nc);
|
|
150
161
|
console.log('');
|
|
151
162
|
console.log('控制台: ' + colors.yellow + 'http://127.0.0.1:' + PORT + colors.nc);
|
|
152
|
-
|
|
153
|
-
// 重新注册 LaunchAgent 作为守卫(崩溃自动重启、开机自启)
|
|
154
|
-
if (!isWin) {
|
|
155
|
-
try {
|
|
156
|
-
execSync('openclaw gateway install', { stdio: 'pipe', timeout: 10000 });
|
|
157
|
-
console.log('[守卫] ' + colors.green + 'LaunchAgent 已注册,崩溃/重启会自动拉起' + colors.nc);
|
|
158
|
-
} catch {
|
|
159
|
-
// 注册失败不影响正常使用,静默忽略
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
163
|
return true;
|
|
164
164
|
} catch {
|
|
165
165
|
console.log('[启动] ' + colors.yellow + 'Gateway 正在启动中...' + colors.nc);
|
package/index.js
CHANGED
|
@@ -1064,6 +1064,106 @@ function runPatch() {
|
|
|
1064
1064
|
}
|
|
1065
1065
|
}
|
|
1066
1066
|
|
|
1067
|
+
function runNuke(cliArgs) {
|
|
1068
|
+
const bar = '════════════════════════════════════════';
|
|
1069
|
+
const hasDangerous = (cliArgs || []).includes('--dangerous');
|
|
1070
|
+
|
|
1071
|
+
if (!hasDangerous) {
|
|
1072
|
+
console.log('');
|
|
1073
|
+
console.log(colors.red + bar + colors.nc);
|
|
1074
|
+
console.log(colors.red + ' ⚠️ 危险操作:mc nuke' + colors.nc);
|
|
1075
|
+
console.log(colors.red + bar + colors.nc);
|
|
1076
|
+
console.log('');
|
|
1077
|
+
console.log(' 此命令将执行以下操作:');
|
|
1078
|
+
console.log(' 1. ' + colors.red + 'rm -rf /root/.openclaw' + colors.nc);
|
|
1079
|
+
console.log(' 2. ' + colors.red + 'rm -rf ~/.openclaw' + colors.nc);
|
|
1080
|
+
console.log(' 3. openclaw onboard --non-interactive --accept-risk');
|
|
1081
|
+
console.log(' 4. mc up');
|
|
1082
|
+
console.log(' 5. mc patch');
|
|
1083
|
+
console.log(' 6. mc restart');
|
|
1084
|
+
console.log('');
|
|
1085
|
+
console.log(' 必须加上 ' + colors.yellow + '--dangerous' + colors.nc + ' 参数才会真正执行:');
|
|
1086
|
+
console.log('');
|
|
1087
|
+
console.log(' ' + colors.yellow + 'mc nuke --dangerous' + colors.nc);
|
|
1088
|
+
console.log('');
|
|
1089
|
+
console.log(colors.red + bar + colors.nc);
|
|
1090
|
+
console.log('');
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
console.log('');
|
|
1095
|
+
console.log(colors.red + bar + colors.nc);
|
|
1096
|
+
console.log(colors.red + ' 💣 mc nuke --dangerous 开始执行' + colors.nc);
|
|
1097
|
+
console.log(colors.red + bar + colors.nc);
|
|
1098
|
+
console.log('');
|
|
1099
|
+
|
|
1100
|
+
// Step 1: rm -rf /root/.openclaw
|
|
1101
|
+
console.log('[1/6] ' + colors.red + 'rm -rf /root/.openclaw' + colors.nc);
|
|
1102
|
+
try {
|
|
1103
|
+
execSync('rm -rf /root/.openclaw', { stdio: 'inherit' });
|
|
1104
|
+
console.log(' ' + colors.green + '✓ 完成' + colors.nc);
|
|
1105
|
+
} catch (err) {
|
|
1106
|
+
console.log(' ' + colors.yellow + '⚠ 跳过: ' + err.message + colors.nc);
|
|
1107
|
+
}
|
|
1108
|
+
console.log('');
|
|
1109
|
+
|
|
1110
|
+
// Step 2: rm -rf ~/.openclaw
|
|
1111
|
+
console.log('[2/6] ' + colors.red + 'rm -rf ~/.openclaw' + colors.nc);
|
|
1112
|
+
try {
|
|
1113
|
+
execSync('rm -rf ' + os.homedir() + '/.openclaw', { stdio: 'inherit' });
|
|
1114
|
+
console.log(' ' + colors.green + '✓ 完成' + colors.nc);
|
|
1115
|
+
} catch (err) {
|
|
1116
|
+
console.log(' ' + colors.red + '✗ 失败: ' + err.message + colors.nc);
|
|
1117
|
+
process.exit(1);
|
|
1118
|
+
}
|
|
1119
|
+
console.log('');
|
|
1120
|
+
|
|
1121
|
+
// Step 3: openclaw onboard
|
|
1122
|
+
console.log('[3/6] openclaw onboard --non-interactive --accept-risk');
|
|
1123
|
+
try {
|
|
1124
|
+
execSync('openclaw onboard --non-interactive --accept-risk', { stdio: 'inherit' });
|
|
1125
|
+
console.log(' ' + colors.green + '✓ 完成' + colors.nc);
|
|
1126
|
+
} catch (err) {
|
|
1127
|
+
console.log(' ' + colors.red + '✗ 失败: ' + err.message + colors.nc);
|
|
1128
|
+
process.exit(1);
|
|
1129
|
+
}
|
|
1130
|
+
console.log('');
|
|
1131
|
+
|
|
1132
|
+
// Step 4: mc up
|
|
1133
|
+
console.log('[4/6] mc up (upgrade + patch)');
|
|
1134
|
+
try {
|
|
1135
|
+
runUpdate();
|
|
1136
|
+
console.log(' ' + colors.green + '✓ 升级完成' + colors.nc);
|
|
1137
|
+
} catch (err) {
|
|
1138
|
+
console.log(' ' + colors.yellow + '⚠ 升级跳过: ' + err.message + colors.nc);
|
|
1139
|
+
}
|
|
1140
|
+
console.log('');
|
|
1141
|
+
|
|
1142
|
+
// Step 5: mc patch
|
|
1143
|
+
console.log('[5/6] mc patch');
|
|
1144
|
+
try {
|
|
1145
|
+
runPatch();
|
|
1146
|
+
console.log(' ' + colors.green + '✓ 完成' + colors.nc);
|
|
1147
|
+
} catch (err) {
|
|
1148
|
+
console.log(' ' + colors.yellow + '⚠ patch 失败: ' + err.message + colors.nc);
|
|
1149
|
+
}
|
|
1150
|
+
console.log('');
|
|
1151
|
+
|
|
1152
|
+
// Step 6: mc restart
|
|
1153
|
+
console.log('[6/6] mc restart');
|
|
1154
|
+
try {
|
|
1155
|
+
runRestart();
|
|
1156
|
+
} catch (err) {
|
|
1157
|
+
console.log(' ' + colors.yellow + '⚠ 重启失败: ' + err.message + colors.nc);
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
console.log('');
|
|
1161
|
+
console.log(colors.green + bar + colors.nc);
|
|
1162
|
+
console.log(colors.green + ' ✅ nuke 完成!' + colors.nc);
|
|
1163
|
+
console.log(colors.green + bar + colors.nc);
|
|
1164
|
+
console.log('');
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1067
1167
|
function runUnpatch() {
|
|
1068
1168
|
const { unpatch } = require('./patches/patch');
|
|
1069
1169
|
const bar = '----------------------------------------';
|
|
@@ -1534,6 +1634,7 @@ const INJECT_MENU = [
|
|
|
1534
1634
|
{ key: '5', cmd: 'inject-token', desc: '设置 Gateway Token 为 aiyiran' },
|
|
1535
1635
|
{ key: '6', cmd: 'inject-workspaceAndSoul', desc: '替换默认 workspace 的 SOUL.md' },
|
|
1536
1636
|
{ key: '7', cmd: 'inject-tooldeny', desc: 'deny image_generate + music_generate 内置工具' },
|
|
1637
|
+
{ key: '8', cmd: 'inject-controlui', desc: '注入 controlUi 配置 (allowInsecureAuth + allowedOrigins + dangerouslyDisableDeviceAuth)' },
|
|
1537
1638
|
{ key: 'a', cmd: 'all', desc: '执行以上全部注入' },
|
|
1538
1639
|
];
|
|
1539
1640
|
|
|
@@ -1546,6 +1647,7 @@ function runInjectCommand(cmd, extraArgs) {
|
|
|
1546
1647
|
'inject-token': './inject-token',
|
|
1547
1648
|
'inject-workspaceAndSoul': './inject-workspaceAndSoul',
|
|
1548
1649
|
'inject-tooldeny': './inject-tooldeny',
|
|
1650
|
+
'inject-controlui': './inject-controlui',
|
|
1549
1651
|
};
|
|
1550
1652
|
const mod = require(modules[cmd]);
|
|
1551
1653
|
mod.run(extraArgs || []);
|
|
@@ -1832,7 +1934,9 @@ function showHelp() {
|
|
|
1832
1934
|
console.log(' inject-search 注入 Tavily 搜索插件配置');
|
|
1833
1935
|
console.log(' inject-workspaceAndSoul 替换默认 workspace 的 SOUL.md 提示词');
|
|
1834
1936
|
console.log(' inject-tooldeny deny image_generate + music_generate 内置工具');
|
|
1937
|
+
console.log(' inject-controlui 注入 controlUi 配置 (allowInsecureAuth + allowedOrigins)');
|
|
1835
1938
|
console.log(' restart 重启 OpenClaw Gateway');
|
|
1939
|
+
console.log(' nuke ⚠️ 核弹重置 (需加 --dangerous): 清除数据 + onboard + up + patch + restart');
|
|
1836
1940
|
console.log(' help 显示帮助信息');
|
|
1837
1941
|
console.log('');
|
|
1838
1942
|
console.log('示例:');
|
|
@@ -1962,6 +2066,14 @@ if (!command) {
|
|
|
1962
2066
|
console.log('🔄 正在重启 Gateway 使配置生效...');
|
|
1963
2067
|
console.log('');
|
|
1964
2068
|
runRestart();
|
|
2069
|
+
} else if (command === 'inject-controlui') {
|
|
2070
|
+
const controlui = require('./injects/inject-controlui');
|
|
2071
|
+
controlui.run(args.slice(1));
|
|
2072
|
+
console.log('🔄 正在重启 Gateway 使配置生效...');
|
|
2073
|
+
console.log('');
|
|
2074
|
+
runRestart();
|
|
2075
|
+
} else if (command === 'nuke') {
|
|
2076
|
+
runNuke(args.slice(1));
|
|
1965
2077
|
} else if (command === 'lock4.2') {
|
|
1966
2078
|
runLock42();
|
|
1967
2079
|
} else if (command === 'server') {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* inject-controlui.js
|
|
5
|
+
*
|
|
6
|
+
* 将 gateway.controlUi 配置设置为:
|
|
7
|
+
* allowInsecureAuth: true
|
|
8
|
+
* allowedOrigins: ["*"]
|
|
9
|
+
* dangerouslyDisableDeviceAuth: true
|
|
10
|
+
*
|
|
11
|
+
* 入口: myclaw inject-controlui
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const { readConfig, writeConfig } = require('../find-config');
|
|
15
|
+
|
|
16
|
+
function run(cliArgs) {
|
|
17
|
+
let configPath;
|
|
18
|
+
let config;
|
|
19
|
+
try {
|
|
20
|
+
({ config, configPath } = readConfig());
|
|
21
|
+
} catch (err) {
|
|
22
|
+
console.error('❌ ' + err.message);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
console.log('→ 找到配置: ' + configPath);
|
|
27
|
+
|
|
28
|
+
if (!config.gateway) config.gateway = {};
|
|
29
|
+
|
|
30
|
+
config.gateway.controlUi = {
|
|
31
|
+
allowInsecureAuth: true,
|
|
32
|
+
allowedOrigins: ['*'],
|
|
33
|
+
dangerouslyDisableDeviceAuth: true,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
writeConfig(config, configPath);
|
|
37
|
+
|
|
38
|
+
console.log('✅ gateway.controlUi 已设置:');
|
|
39
|
+
console.log(' allowInsecureAuth: true');
|
|
40
|
+
console.log(' allowedOrigins: ["*"]');
|
|
41
|
+
console.log(' dangerouslyDisableDeviceAuth: true');
|
|
42
|
+
console.log('');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = { run };
|
package/package.json
CHANGED
|
@@ -82,6 +82,11 @@
|
|
|
82
82
|
"module": "./injects/inject-tooldeny",
|
|
83
83
|
"strategy": "on",
|
|
84
84
|
"description": "deny image_generate + music_generate 内置工具"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"module": "./injects/inject-controlui",
|
|
88
|
+
"strategy": "on",
|
|
89
|
+
"description": "注入 controlUi 配置 (allowInsecureAuth + allowedOrigins)"
|
|
85
90
|
}
|
|
86
91
|
]
|
|
87
92
|
}
|