evolclaw 2.5.6 → 2.5.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/dist/cli.js +1 -1
- package/dist/ipc.js +19 -11
- package/dist/paths.js +10 -1
- package/dist/utils/init-channel.js +13 -1
- package/dist/utils/init.js +12 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1307,7 +1307,7 @@ export async function main(args) {
|
|
|
1307
1307
|
else if (args[1] === 'wecom') {
|
|
1308
1308
|
await cmdInitWecom();
|
|
1309
1309
|
}
|
|
1310
|
-
else if (args[1]) {
|
|
1310
|
+
else if (args[1] && !args[1].startsWith('-')) {
|
|
1311
1311
|
const supported = ['feishu', 'wechat', 'aun', 'dingtalk', 'qqbot', 'wecom'];
|
|
1312
1312
|
console.error(`❌ 不支持的渠道: ${args[1]}`);
|
|
1313
1313
|
console.error(` 支持的渠道: ${supported.join(', ')}`);
|
package/dist/ipc.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import net from 'net';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { logger } from './utils/logger.js';
|
|
4
|
+
const isWindows = process.platform === 'win32';
|
|
5
|
+
const isNamedPipe = (p) => isWindows && p.startsWith('\\\\.\\pipe\\');
|
|
4
6
|
export class IpcServer {
|
|
5
7
|
socketPath;
|
|
6
8
|
getStatus;
|
|
@@ -12,11 +14,13 @@ export class IpcServer {
|
|
|
12
14
|
this.commandExecutor = commandExecutor;
|
|
13
15
|
}
|
|
14
16
|
start() {
|
|
15
|
-
// Remove stale socket file
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
// Remove stale socket file (Unix only — named pipes auto-cleanup on process exit)
|
|
18
|
+
if (!isNamedPipe(this.socketPath)) {
|
|
19
|
+
try {
|
|
20
|
+
fs.unlinkSync(this.socketPath);
|
|
21
|
+
}
|
|
22
|
+
catch { }
|
|
18
23
|
}
|
|
19
|
-
catch { }
|
|
20
24
|
this.server = net.createServer((conn) => {
|
|
21
25
|
let buf = '';
|
|
22
26
|
conn.on('data', async (data) => {
|
|
@@ -42,11 +46,13 @@ export class IpcServer {
|
|
|
42
46
|
logger.error('[IPC] Server error:', err);
|
|
43
47
|
});
|
|
44
48
|
this.server.listen(this.socketPath, () => {
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
// Restrict to current user (Unix only — named pipes use Windows ACLs)
|
|
50
|
+
if (!isNamedPipe(this.socketPath)) {
|
|
51
|
+
try {
|
|
52
|
+
fs.chmodSync(this.socketPath, 0o600);
|
|
53
|
+
}
|
|
54
|
+
catch { }
|
|
48
55
|
}
|
|
49
|
-
catch { }
|
|
50
56
|
logger.info(`[IPC] Listening on ${this.socketPath}`);
|
|
51
57
|
});
|
|
52
58
|
}
|
|
@@ -55,10 +61,12 @@ export class IpcServer {
|
|
|
55
61
|
this.server.close();
|
|
56
62
|
this.server = null;
|
|
57
63
|
}
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
if (!isNamedPipe(this.socketPath)) {
|
|
65
|
+
try {
|
|
66
|
+
fs.unlinkSync(this.socketPath);
|
|
67
|
+
}
|
|
68
|
+
catch { }
|
|
60
69
|
}
|
|
61
|
-
catch { }
|
|
62
70
|
}
|
|
63
71
|
async handleCommand(cmd) {
|
|
64
72
|
switch (cmd.type) {
|
package/dist/paths.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import os from 'os';
|
|
4
|
+
import crypto from 'crypto';
|
|
5
|
+
const isWindows = process.platform === 'win32';
|
|
4
6
|
let _root = null;
|
|
5
7
|
export function resolveRoot() {
|
|
6
8
|
if (_root)
|
|
@@ -33,9 +35,16 @@ export function resolvePaths() {
|
|
|
33
35
|
lineStats: path.join(root, 'logs', 'line-stats.log'),
|
|
34
36
|
readySignal: path.join(root, 'logs', 'ready.signal'),
|
|
35
37
|
selfHealLog: path.join(root, 'logs', 'self-heal.md'),
|
|
36
|
-
socket:
|
|
38
|
+
socket: resolveSocketPath(root),
|
|
37
39
|
};
|
|
38
40
|
}
|
|
41
|
+
function resolveSocketPath(root) {
|
|
42
|
+
if (isWindows) {
|
|
43
|
+
const hash = crypto.createHash('sha1').update(root).digest('hex').slice(0, 12);
|
|
44
|
+
return `\\\\.\\pipe\\evolclaw-${hash}`;
|
|
45
|
+
}
|
|
46
|
+
return path.join(root, 'logs', 'evolclaw.sock');
|
|
47
|
+
}
|
|
39
48
|
export function ensureDataDirs() {
|
|
40
49
|
const p = resolvePaths();
|
|
41
50
|
fs.mkdirSync(p.dataDir, { recursive: true });
|
|
@@ -754,14 +754,26 @@ export async function setupAunAid(rl, _config) {
|
|
|
754
754
|
const agentType = typeInput === 'human' ? 'human' : 'ai';
|
|
755
755
|
const agentName = aid.split('.')[0];
|
|
756
756
|
const agentMdContent = `---\naid: "${aid}"\nname: "${agentName}"\ntype: "${agentType}"\nversion: "1.0.0"\ndescription: ""\ntags:\n - evolclaw\ninitialized: false\n---\n`;
|
|
757
|
+
const agentMdPath = path.join(aidDir, 'agent.md');
|
|
757
758
|
try {
|
|
758
759
|
await client.auth.uploadAgentMd(agentMdContent);
|
|
759
760
|
console.log(' ✓ agent.md 已发布');
|
|
760
|
-
fs.writeFileSync(path.join(aidDir, 'agent.md'), agentMdContent, 'utf-8');
|
|
761
761
|
}
|
|
762
762
|
catch (e) {
|
|
763
763
|
console.log(` ⚠ agent.md 发布失败(可稍后用 /agentmd put 重试): ${String(e.message || e).slice(0, 100)}`);
|
|
764
764
|
}
|
|
765
|
+
fs.writeFileSync(agentMdPath, agentMdContent, 'utf-8');
|
|
766
|
+
if (!fs.existsSync(agentMdPath)) {
|
|
767
|
+
try {
|
|
768
|
+
await client.close();
|
|
769
|
+
}
|
|
770
|
+
catch { /* ignore */ }
|
|
771
|
+
console.log(` ✗ agent.md 本地写入校验失败: ${agentMdPath}`);
|
|
772
|
+
failed = true;
|
|
773
|
+
}
|
|
774
|
+
else {
|
|
775
|
+
console.log(' ✓ agent.md 已写入本地');
|
|
776
|
+
}
|
|
765
777
|
try {
|
|
766
778
|
await client.close();
|
|
767
779
|
}
|
package/dist/utils/init.js
CHANGED
|
@@ -445,11 +445,21 @@ export async function cmdInit(options) {
|
|
|
445
445
|
// 写入初始 agent.md(initialized: false)
|
|
446
446
|
const agentName = options.aunAid.split('.')[0];
|
|
447
447
|
const agentMd = `---\naid: "${options.aunAid}"\nname: "${agentName}"\ntype: "ai"\nversion: "1.0.0"\ndescription: ""\ntags:\n - evolclaw\ninitialized: false\n---\n`;
|
|
448
|
+
const agentMdPath = path.join(aidDir, 'agent.md');
|
|
448
449
|
try {
|
|
449
450
|
await client.auth.uploadAgentMd(agentMd);
|
|
450
|
-
fs.writeFileSync(path.join(aidDir, 'agent.md'), agentMd, 'utf-8');
|
|
451
451
|
}
|
|
452
|
-
catch {
|
|
452
|
+
catch (e) {
|
|
453
|
+
console.warn(`⚠ agent.md 网络发布失败(可稍后重试): ${String(e?.message || e).slice(0, 100)}`);
|
|
454
|
+
}
|
|
455
|
+
fs.writeFileSync(agentMdPath, agentMd, 'utf-8');
|
|
456
|
+
if (!fs.existsSync(agentMdPath)) {
|
|
457
|
+
try {
|
|
458
|
+
await client.close();
|
|
459
|
+
}
|
|
460
|
+
catch { }
|
|
461
|
+
throw new Error(`agent.md 写入校验失败: ${agentMdPath}`);
|
|
462
|
+
}
|
|
453
463
|
try {
|
|
454
464
|
await client.close();
|
|
455
465
|
}
|
package/package.json
CHANGED