@aiyiran/myclaw 1.1.1 → 1.1.2
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 +9 -0
- package/injects/inject-controlui.js +45 -0
- package/package.json +1 -1
|
@@ -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
|
@@ -1534,6 +1534,7 @@ const INJECT_MENU = [
|
|
|
1534
1534
|
{ key: '5', cmd: 'inject-token', desc: '设置 Gateway Token 为 aiyiran' },
|
|
1535
1535
|
{ key: '6', cmd: 'inject-workspaceAndSoul', desc: '替换默认 workspace 的 SOUL.md' },
|
|
1536
1536
|
{ key: '7', cmd: 'inject-tooldeny', desc: 'deny image_generate + music_generate 内置工具' },
|
|
1537
|
+
{ key: '8', cmd: 'inject-controlui', desc: '注入 controlUi 配置 (allowInsecureAuth + allowedOrigins + dangerouslyDisableDeviceAuth)' },
|
|
1537
1538
|
{ key: 'a', cmd: 'all', desc: '执行以上全部注入' },
|
|
1538
1539
|
];
|
|
1539
1540
|
|
|
@@ -1546,6 +1547,7 @@ function runInjectCommand(cmd, extraArgs) {
|
|
|
1546
1547
|
'inject-token': './inject-token',
|
|
1547
1548
|
'inject-workspaceAndSoul': './inject-workspaceAndSoul',
|
|
1548
1549
|
'inject-tooldeny': './inject-tooldeny',
|
|
1550
|
+
'inject-controlui': './inject-controlui',
|
|
1549
1551
|
};
|
|
1550
1552
|
const mod = require(modules[cmd]);
|
|
1551
1553
|
mod.run(extraArgs || []);
|
|
@@ -1832,6 +1834,7 @@ function showHelp() {
|
|
|
1832
1834
|
console.log(' inject-search 注入 Tavily 搜索插件配置');
|
|
1833
1835
|
console.log(' inject-workspaceAndSoul 替换默认 workspace 的 SOUL.md 提示词');
|
|
1834
1836
|
console.log(' inject-tooldeny deny image_generate + music_generate 内置工具');
|
|
1837
|
+
console.log(' inject-controlui 注入 controlUi 配置 (allowInsecureAuth + allowedOrigins)');
|
|
1835
1838
|
console.log(' restart 重启 OpenClaw Gateway');
|
|
1836
1839
|
console.log(' help 显示帮助信息');
|
|
1837
1840
|
console.log('');
|
|
@@ -1962,6 +1965,12 @@ if (!command) {
|
|
|
1962
1965
|
console.log('🔄 正在重启 Gateway 使配置生效...');
|
|
1963
1966
|
console.log('');
|
|
1964
1967
|
runRestart();
|
|
1968
|
+
} else if (command === 'inject-controlui') {
|
|
1969
|
+
const controlui = require('./injects/inject-controlui');
|
|
1970
|
+
controlui.run(args.slice(1));
|
|
1971
|
+
console.log('🔄 正在重启 Gateway 使配置生效...');
|
|
1972
|
+
console.log('');
|
|
1973
|
+
runRestart();
|
|
1965
1974
|
} else if (command === 'lock4.2') {
|
|
1966
1975
|
runLock42();
|
|
1967
1976
|
} 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 };
|