evolclaw 3.1.3 → 3.1.4
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/CHANGELOG.md +17 -0
- package/assets/.env.template +4 -0
- package/assets/config.json.template +6 -0
- package/assets/wechat-group-qr.jpeg +0 -0
- package/dist/agents/kit-renderer.js +35 -21
- package/dist/aun/aid/agentmd.js +25 -54
- package/dist/aun/aid/client.js +22 -7
- package/dist/aun/aid/identity.js +314 -28
- package/dist/aun/aid/index.js +1 -1
- package/dist/aun/rpc/connection.js +8 -13
- package/dist/channels/aun.js +31 -72
- package/dist/cli/agent.js +15 -22
- package/dist/cli/bench.js +8 -14
- package/dist/cli/help.js +23 -0
- package/dist/cli/index.js +371 -36
- package/dist/cli/init-channel.js +2 -3
- package/dist/cli/link-rules.js +2 -1
- package/dist/cli/net-check.js +10 -11
- package/dist/core/command-handler.js +6 -7
- package/dist/core/message/message-processor.js +19 -18
- package/dist/core/relation/peer-identity.js +64 -21
- package/dist/core/session/session-manager.js +6 -2
- package/dist/core/trigger/manager.js +37 -0
- package/dist/index.js +4 -1
- package/dist/paths.js +87 -16
- package/dist/utils/npm-ops.js +18 -11
- package/kits/eck_manifest.json +8 -8
- package/kits/rules/05-venue.md +2 -2
- package/kits/templates/system-fragments/baseagent.md +7 -1
- package/kits/templates/system-fragments/channel.md +4 -1
- package/kits/templates/system-fragments/identity.md +4 -4
- package/kits/templates/system-fragments/relation.md +8 -5
- package/kits/templates/system-fragments/session.md +20 -0
- package/kits/templates/system-fragments/venue.md +4 -1
- package/package.json +4 -2
- package/dist/net-check.js +0 -640
- package/dist/watch-msg.js +0 -544
- package/kits/templates/system-fragments/eckruntime.md +0 -14
package/dist/cli/agent.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import os from 'os';
|
|
4
4
|
import readline from 'readline';
|
|
5
|
-
import { resolvePaths } from '../paths.js';
|
|
5
|
+
import { resolvePaths, agentMdPath as getAgentMdPathFromPaths, aunPath as defaultAunPath } from '../paths.js';
|
|
6
6
|
import { loadDefaults, loadAllAgents, loadAgent, saveAgent, ensureAgentDirSkeleton } from '../config-store.js';
|
|
7
7
|
import { ipcQuery } from '../ipc.js';
|
|
8
8
|
import { CONFIG_SCHEMA_VERSION } from '../types.js';
|
|
@@ -46,12 +46,11 @@ function deriveAgentProjectPath(rootPath, aid) {
|
|
|
46
46
|
return `${candidate}~${i}`;
|
|
47
47
|
}
|
|
48
48
|
function readAgentMdIdentity(aid) {
|
|
49
|
-
const
|
|
50
|
-
const agentMdPath = path.join(aunPath, 'AIDs', aid, 'agent.md');
|
|
49
|
+
const agentMdFilePath = getAgentMdPathFromPaths(aid);
|
|
51
50
|
try {
|
|
52
|
-
if (!fs.existsSync(
|
|
51
|
+
if (!fs.existsSync(agentMdFilePath))
|
|
53
52
|
return { name: null, description: null };
|
|
54
|
-
const content = fs.readFileSync(
|
|
53
|
+
const content = fs.readFileSync(agentMdFilePath, 'utf-8');
|
|
55
54
|
const fmMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
|
56
55
|
if (!fmMatch)
|
|
57
56
|
return { name: null, description: null };
|
|
@@ -68,8 +67,7 @@ function readAgentMdIdentity(aid) {
|
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
function getAgentMdPath(aid) {
|
|
71
|
-
|
|
72
|
-
return path.join(aunPath, 'AIDs', aid, 'agent.md');
|
|
70
|
+
return getAgentMdPathFromPaths(aid);
|
|
73
71
|
}
|
|
74
72
|
function getNestedValue(obj, keyPath) {
|
|
75
73
|
const keys = keyPath.split('.');
|
|
@@ -391,10 +389,8 @@ export async function agentCreateInteractive(opts = {}) {
|
|
|
391
389
|
if (agentDescription) {
|
|
392
390
|
content = content.replace(/^description:\s*".*?"$/m, `description: "${agentDescription}"`);
|
|
393
391
|
}
|
|
394
|
-
const aunPath = process.env.AUN_HOME ||
|
|
395
|
-
|
|
396
|
-
fs.mkdirSync(path.dirname(agentMdPath), { recursive: true });
|
|
397
|
-
fs.writeFileSync(agentMdPath, content, 'utf-8');
|
|
392
|
+
const aunPath = process.env.AUN_HOME || defaultAunPath();
|
|
393
|
+
// agentmdPut 会写本地文件到 agentMdPath(aid) 并调用 publishAgentMd
|
|
398
394
|
// Upload with retry (3 attempts, 2s delay between retries)
|
|
399
395
|
const MAX_ATTEMPTS = 3;
|
|
400
396
|
const RETRY_DELAY_MS = 2000;
|
|
@@ -547,10 +543,8 @@ export async function agentCreateNonInteractive(opts) {
|
|
|
547
543
|
if (agentDescription) {
|
|
548
544
|
content = content.replace(/^description:\s*".*?"$/m, `description: "${agentDescription}"`);
|
|
549
545
|
}
|
|
550
|
-
const aunPath = process.env.AUN_HOME ||
|
|
551
|
-
|
|
552
|
-
fs.mkdirSync(path.dirname(agentMdPath), { recursive: true });
|
|
553
|
-
fs.writeFileSync(agentMdPath, content, 'utf-8');
|
|
546
|
+
const aunPath = process.env.AUN_HOME || defaultAunPath();
|
|
547
|
+
// agentmdPut 会写本地文件到 agentMdPath(aid) 并调用 publishAgentMd
|
|
554
548
|
const MAX_ATTEMPTS = 3;
|
|
555
549
|
const RETRY_DELAY_MS = 2000;
|
|
556
550
|
let lastError;
|
|
@@ -603,7 +597,7 @@ export async function agentCreateNonInteractive(opts) {
|
|
|
603
597
|
export async function agentSyncAids() {
|
|
604
598
|
const p = resolvePaths();
|
|
605
599
|
const { aidList } = await import('../aun/aid/index.js');
|
|
606
|
-
const aunPath = process.env.AUN_HOME ||
|
|
600
|
+
const aunPath = process.env.AUN_HOME || defaultAunPath();
|
|
607
601
|
const allAids = aidList(aunPath);
|
|
608
602
|
const localAids = allAids.filter(a => a.hasPrivateKey).map(a => a.aid);
|
|
609
603
|
if (localAids.length === 0) {
|
|
@@ -869,12 +863,12 @@ export async function agentDelete(aid, purge = false) {
|
|
|
869
863
|
}
|
|
870
864
|
// ==================== agentRename ====================
|
|
871
865
|
export async function agentRename(aid, newName) {
|
|
872
|
-
const aunPath = process.env.AUN_HOME ||
|
|
873
|
-
const
|
|
874
|
-
if (!fs.existsSync(
|
|
866
|
+
const aunPath = process.env.AUN_HOME || defaultAunPath();
|
|
867
|
+
const agentMdFilePath = getAgentMdPathFromPaths(aid);
|
|
868
|
+
if (!fs.existsSync(agentMdFilePath)) {
|
|
875
869
|
return { ok: false, error: `agent.md not found for ${aid}. Run: evolclaw aid agentmd put ${aid}` };
|
|
876
870
|
}
|
|
877
|
-
let content = fs.readFileSync(
|
|
871
|
+
let content = fs.readFileSync(agentMdFilePath, 'utf-8');
|
|
878
872
|
const fmMatch = content.match(/^(---\n)([\s\S]*?)(\n---)/);
|
|
879
873
|
if (!fmMatch) {
|
|
880
874
|
return { ok: false, error: `agent.md has no valid frontmatter for ${aid}` };
|
|
@@ -889,8 +883,7 @@ export async function agentRename(aid, newName) {
|
|
|
889
883
|
newFm = `name: "${newName}"\n${fm}`;
|
|
890
884
|
}
|
|
891
885
|
content = fmMatch[1] + newFm + fmMatch[3] + content.slice(fmMatch[0].length);
|
|
892
|
-
|
|
893
|
-
// Upload
|
|
886
|
+
// agentmdPut 会写本地文件并 publishAgentMd
|
|
894
887
|
let uploaded = false;
|
|
895
888
|
try {
|
|
896
889
|
const { agentmdPut } = await import('../aun/aid/index.js');
|
package/dist/cli/bench.js
CHANGED
|
@@ -6,7 +6,9 @@ import { execFile } from 'child_process';
|
|
|
6
6
|
import { promisify } from 'util';
|
|
7
7
|
import { aidList, aidCreate } from '../aun/aid/identity.js';
|
|
8
8
|
import { msgSend, msgPull } from '../aun/msg/index.js';
|
|
9
|
-
import { getPackageRoot } from '../paths.js';
|
|
9
|
+
import { getPackageRoot, aunPath as defaultAunPath } from '../paths.js';
|
|
10
|
+
import { createAunClient } from '../aun/aid/client.js';
|
|
11
|
+
import { isHelpFlag } from './help.js';
|
|
10
12
|
const execFileAsync = promisify(execFile);
|
|
11
13
|
// ==================== ANSI ====================
|
|
12
14
|
const GREEN = '\x1b[32m';
|
|
@@ -247,19 +249,11 @@ function filterBySize(results, received, cls, durationSec) {
|
|
|
247
249
|
return computeMetrics(results.filter(r => r.sizeClass === cls), received.filter(r => r.sizeClass === cls), durationSec);
|
|
248
250
|
}
|
|
249
251
|
async function benchAuth(aids, concurrency, aunPath, slotId) {
|
|
250
|
-
const
|
|
251
|
-
const path = (await import('path')).default;
|
|
252
|
-
const fs = (await import('fs')).default;
|
|
253
|
-
const os = (await import('os')).default;
|
|
254
|
-
const resolvedAunPath = aunPath ?? path.join(os.homedir(), '.aun');
|
|
255
|
-
const caCertPath = path.join(resolvedAunPath, 'CA', 'root', 'root.crt');
|
|
252
|
+
const resolvedAunPath = aunPath ?? defaultAunPath();
|
|
256
253
|
const tasks = aids.map(aid => async () => {
|
|
257
254
|
const start = Date.now();
|
|
258
255
|
try {
|
|
259
|
-
const
|
|
260
|
-
if (fs.existsSync(caCertPath))
|
|
261
|
-
clientOpts.root_ca_path = caCertPath;
|
|
262
|
-
const client = new AUNClient(clientOpts);
|
|
256
|
+
const client = await createAunClient({ aunPath: resolvedAunPath });
|
|
263
257
|
await client.auth.createAid({ aid });
|
|
264
258
|
const authResult = await client.auth.authenticate({ aid });
|
|
265
259
|
const accessToken = authResult?.access_token ?? client._access_token;
|
|
@@ -363,7 +357,7 @@ async function cliAuth(aid, slotId) {
|
|
|
363
357
|
}
|
|
364
358
|
// ==================== Main Command ====================
|
|
365
359
|
export async function cmdBench(args) {
|
|
366
|
-
if (args[0]
|
|
360
|
+
if (isHelpFlag(args[0])) {
|
|
367
361
|
console.log(`用法: evolclaw bench [options]
|
|
368
362
|
|
|
369
363
|
AUN 消息系统性能基准测试。使用多个本地 AID 并发互发消息,
|
|
@@ -411,14 +405,14 @@ Options:
|
|
|
411
405
|
const aids = [];
|
|
412
406
|
// AID is usable if: has private key + cert not expired + key/cert public key match
|
|
413
407
|
const { aidShow } = await import('../aun/aid/identity.js');
|
|
414
|
-
const resolvedAunPath = aunPath ??
|
|
408
|
+
const resolvedAunPath = aunPath ?? defaultAunPath();
|
|
415
409
|
const usableAids = [];
|
|
416
410
|
const skippedAids = [];
|
|
417
411
|
for (const a of allAids) {
|
|
418
412
|
if (!a.hasPrivateKey)
|
|
419
413
|
continue;
|
|
420
414
|
try {
|
|
421
|
-
const info = aidShow(a.aid, { aunPath });
|
|
415
|
+
const info = await aidShow(a.aid, { aunPath });
|
|
422
416
|
if (!info.certExpiresAt) {
|
|
423
417
|
skippedAids.push({ aid: a.aid, reason: '无证书' });
|
|
424
418
|
continue;
|
package/dist/cli/help.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI help 检测 helper。
|
|
3
|
+
*
|
|
4
|
+
* 把 7 种历史写法统一为两个语义清晰的函数:
|
|
5
|
+
* - isHelpFlag(token):单 token 是否是 help 标记('help' / '--help' / '-h')
|
|
6
|
+
* - wantsHelp(args):args 任意位置出现 help 标记
|
|
7
|
+
*
|
|
8
|
+
* 两套 API 服务于不同语义:
|
|
9
|
+
* - 顶层路由(如 cmdAid 看到第一个 token 是子命令名时)必须用 isHelpFlag(sub),
|
|
10
|
+
* 否则 `ec aid delete --help` 会被顶层吞掉,永远到不了 delete 自己的 help。
|
|
11
|
+
* - 单层命令(如 cmdLinkRules、cmdAid 的具体 sub 处理块内)用 wantsHelp(args)
|
|
12
|
+
* 更宽松,任意位置都识别。
|
|
13
|
+
*/
|
|
14
|
+
const HELP_TOKENS = new Set(['help', '--help', '-h']);
|
|
15
|
+
export function isHelpFlag(token) {
|
|
16
|
+
return token !== undefined && HELP_TOKENS.has(token);
|
|
17
|
+
}
|
|
18
|
+
export function wantsHelp(args) {
|
|
19
|
+
for (const a of args)
|
|
20
|
+
if (HELP_TOKENS.has(a))
|
|
21
|
+
return true;
|
|
22
|
+
return false;
|
|
23
|
+
}
|