evolclaw 3.1.2 → 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.
Files changed (48) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +2 -6
  3. package/assets/.env.template +4 -0
  4. package/assets/config.json.template +6 -0
  5. package/assets/wechat-group-qr.jpeg +0 -0
  6. package/dist/agents/claude-runner.js +1 -1
  7. package/dist/agents/codex-runner.js +75 -19
  8. package/dist/agents/gemini-runner.js +0 -2
  9. package/dist/agents/kit-renderer.js +85 -22
  10. package/dist/aun/aid/agentmd.js +67 -74
  11. package/dist/aun/aid/client.js +22 -7
  12. package/dist/aun/aid/identity.js +314 -28
  13. package/dist/aun/aid/index.js +2 -2
  14. package/dist/aun/rpc/connection.js +8 -10
  15. package/dist/channels/aun.js +53 -41
  16. package/dist/cli/agent.js +28 -28
  17. package/dist/cli/bench.js +8 -14
  18. package/dist/cli/help.js +23 -0
  19. package/dist/cli/index.js +398 -73
  20. package/dist/cli/init-channel.js +2 -3
  21. package/dist/cli/init.js +13 -6
  22. package/dist/cli/link-rules.js +2 -1
  23. package/dist/cli/net-check.js +10 -11
  24. package/dist/core/command-handler.js +621 -541
  25. package/dist/core/evolagent.js +31 -0
  26. package/dist/core/message/im-renderer.js +10 -0
  27. package/dist/core/message/message-bridge.js +123 -24
  28. package/dist/core/message/message-processor.js +61 -31
  29. package/dist/core/relation/peer-identity.js +64 -21
  30. package/dist/core/session/session-manager.js +191 -44
  31. package/dist/core/trigger/manager.js +37 -0
  32. package/dist/index.js +4 -1
  33. package/dist/paths.js +87 -16
  34. package/dist/utils/npm-ops.js +18 -11
  35. package/kits/eck_manifest.json +9 -9
  36. package/kits/rules/02-navigation.md +1 -0
  37. package/kits/rules/05-venue.md +2 -2
  38. package/kits/rules/06-channel.md +2 -18
  39. package/kits/templates/system-fragments/baseagent.md +8 -2
  40. package/kits/templates/system-fragments/channel.md +20 -8
  41. package/kits/templates/system-fragments/identity.md +5 -6
  42. package/kits/templates/system-fragments/relation.md +10 -5
  43. package/kits/templates/system-fragments/session.md +20 -0
  44. package/kits/templates/system-fragments/venue.md +5 -3
  45. package/package.json +4 -2
  46. package/dist/net-check.js +0 -640
  47. package/dist/watch-msg.js +0 -544
  48. package/kits/templates/system-fragments/runtime.md +0 -19
@@ -8,9 +8,8 @@
8
8
  import fs from 'fs';
9
9
  import readline from 'readline';
10
10
  import path from 'path';
11
- import os from 'os';
12
11
  import crypto from 'crypto';
13
- import { aidLocalDir } from '../paths.js';
12
+ import { aidLocalDir, aunPath as defaultAunPath } from '../paths.js';
14
13
  import { selectInstance } from './init.js';
15
14
  import { npmInstallGlobal } from '../utils/npm-ops.js';
16
15
  import { loadAllAgents, loadAgent } from '../config-store.js';
@@ -442,7 +441,7 @@ export async function setupAunAid(rl, _config) {
442
441
  }
443
442
  }
444
443
  // Check if AID exists locally
445
- const aunPath = path.join(os.homedir(), '.aun');
444
+ const aunPath = defaultAunPath();
446
445
  const aidDir = path.join(aunPath, 'AIDs', aid);
447
446
  if (fs.existsSync(aidDir) && fs.existsSync(path.join(aidDir, 'private'))) {
448
447
  console.log(` ✓ AID ${aid} 已存在`);
package/dist/cli/init.js CHANGED
@@ -4,6 +4,7 @@ import { resolvePaths, ensureDataDirs } from '../paths.js';
4
4
  import { commandExists } from '../utils/cross-platform.js';
5
5
  import { scanInstances } from '../utils/instance-registry.js';
6
6
  import { saveDefaultsSafe, loadAllAgents } from '../config-store.js';
7
+ import { isCodexSdkAvailable } from '../agents/codex-runner.js';
7
8
  // ==================== Helpers ====================
8
9
  function ask(rl, question) {
9
10
  return new Promise(resolve => rl.question(question, resolve));
@@ -14,8 +15,13 @@ const BASEAGENT_ENV_KEY = {
14
15
  codex: 'OPENAI_API_KEY',
15
16
  gemini: 'GEMINI_API_KEY',
16
17
  };
18
+ function isBaseagentAvailable(baseagent) {
19
+ if (baseagent === 'codex')
20
+ return isCodexSdkAvailable();
21
+ return commandExists(baseagent);
22
+ }
17
23
  function detectAvailable() {
18
- return BASEAGENT_CANDIDATES.filter(b => commandExists(b));
24
+ return BASEAGENT_CANDIDATES.filter(isBaseagentAvailable);
19
25
  }
20
26
  function pickDefault(available) {
21
27
  return (available.includes('claude') ? 'claude' : available[0]);
@@ -45,9 +51,10 @@ export async function cmdInit(options) {
45
51
  // ── 2. 探测 baseagent ──
46
52
  const available = detectAvailable();
47
53
  if (available.length === 0) {
48
- console.log('❌ 未检测到任何 baseagent CLI,请先安装至少一款:');
49
- for (const b of BASEAGENT_CANDIDATES)
50
- console.log(` - ${b}`);
54
+ console.log('❌ 未检测到可用 baseagent。请安装至少一款:');
55
+ console.log(' - claude CLI');
56
+ console.log(' - gemini CLI');
57
+ console.log(' - optional dependency @openai/codex-sdk');
51
58
  console.log('\n安装后重新运行 evolclaw init');
52
59
  return;
53
60
  }
@@ -70,7 +77,7 @@ export async function cmdInit(options) {
70
77
  return;
71
78
  }
72
79
  if (!available.includes(options.baseagent)) {
73
- console.log(`❌ ${options.baseagent} 未在 PATH 中检测到(可用: ${available.join('/')})`);
80
+ console.log(`❌ ${options.baseagent} 当前环境不可用(可用: ${available.join('/')})`);
74
81
  return;
75
82
  }
76
83
  chosen = options.baseagent;
@@ -104,7 +111,7 @@ export async function cmdInit(options) {
104
111
  continue;
105
112
  }
106
113
  if (!available.includes(input)) {
107
- console.log(` ${input} 未在 PATH 中检测到(可用: ${available.join('/')})`);
114
+ console.log(` ${input} 当前环境不可用(可用: ${available.join('/')})`);
108
115
  continue;
109
116
  }
110
117
  chosen = input;
@@ -2,6 +2,7 @@ import fs from 'fs';
2
2
  import path from 'path';
3
3
  import { kitsRulesDir, resolvePaths } from '../paths.js';
4
4
  import { atomicWriteJson, atomicReadJson } from '../utils/atomic-write.js';
5
+ import { wantsHelp } from './help.js';
5
6
  const isWindows = process.platform === 'win32';
6
7
  const KNOWN_BASEAGENTS = ['cc', 'codex', 'gemini'];
7
8
  function statePath() {
@@ -196,7 +197,7 @@ function disconnect(ba) {
196
197
  }
197
198
  // ── 入口 ──
198
199
  export function cmdLinkRules(args) {
199
- if (args.includes('--help') || args.includes('-h')) {
200
+ if (wantsHelp(args)) {
200
201
  showHelp();
201
202
  return;
202
203
  }
@@ -1,12 +1,14 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
- import os from 'os';
4
3
  import net from 'net';
5
4
  import tls from 'tls';
6
5
  import dns from 'dns/promises';
7
6
  import https from 'https';
8
7
  // @ts-ignore
9
8
  import { WebSocket } from 'ws';
9
+ import { aunPath as defaultAunPath } from '../paths.js';
10
+ import { createAunClient } from '../aun/aid/client.js';
11
+ import { isHelpFlag } from './help.js';
10
12
  const GREEN = '\x1b[32m';
11
13
  const RED = '\x1b[31m';
12
14
  const YELLOW = '\x1b[33m';
@@ -217,10 +219,9 @@ async function runCheck(aid, formatJson) {
217
219
  let accessToken;
218
220
  try {
219
221
  const start = Date.now();
220
- const aunPath = process.env.AUN_HOME || path.join(os.homedir(), '.aun');
221
- const { AUNClient } = await import('@agentunion/fastaun');
222
+ const aunPath = process.env.AUN_HOME || defaultAunPath();
222
223
  const result = await suppressSdkOutput(async () => {
223
- const client = new AUNClient({ aun_path: aunPath, debug: false });
224
+ const client = await createAunClient({ aunPath });
224
225
  await client.auth.createAid({ aid });
225
226
  const authResult = await client.auth.authenticate({ aid });
226
227
  await client.close().catch(() => { });
@@ -268,10 +269,9 @@ async function runCheck(aid, formatJson) {
268
269
  // ── Step 9: RPC 调用 (meta.ping) ──
269
270
  try {
270
271
  const start = Date.now();
271
- const aunPath = process.env.AUN_HOME || path.join(os.homedir(), '.aun');
272
- const { AUNClient } = await import('@agentunion/fastaun');
272
+ const aunPath = process.env.AUN_HOME || defaultAunPath();
273
273
  const sendResult = await suppressSdkOutput(async () => {
274
- const client = new AUNClient({ aun_path: aunPath, debug: false });
274
+ const client = await createAunClient({ aunPath });
275
275
  await client.auth.createAid({ aid });
276
276
  const authResult = await client.auth.authenticate({ aid });
277
277
  const at = authResult?.access_token || client._access_token;
@@ -291,8 +291,7 @@ async function runCheck(aid, formatJson) {
291
291
  // CLI 模拟 app 发送 echo[nc],向多个目标测试链路
292
292
  try {
293
293
  const echoStart = Date.now();
294
- const aunPath = process.env.AUN_HOME || path.join(os.homedir(), '.aun');
295
- const { AUNClient } = await import('@agentunion/fastaun');
294
+ const aunPath = process.env.AUN_HOME || defaultAunPath();
296
295
  // 选择 6 个测试目标,按消息数量、域、有无证书均衡选择
297
296
  const allAids = await getAidList();
298
297
  const myDomain = aid.split('.').slice(1).join('.');
@@ -421,7 +420,7 @@ async function runCheck(aid, formatJson) {
421
420
  const label = targetLabel(target);
422
421
  try {
423
422
  const replyText = await suppressSdkOutput(async () => {
424
- const client = new AUNClient({ aun_path: aunPath, debug: false });
423
+ const client = await createAunClient({ aunPath });
425
424
  await client.auth.createAid({ aid });
426
425
  const authResult = await client.auth.authenticate({ aid });
427
426
  const at = authResult?.access_token || client._access_token;
@@ -564,7 +563,7 @@ function shuffle(arr) {
564
563
  export async function cmdNet(args) {
565
564
  const sub = args[0];
566
565
  const formatJson = args.includes('--format') && args.includes('json');
567
- if (sub === 'help' || sub === '--help' || sub === '-h') {
566
+ if (isHelpFlag(sub)) {
568
567
  console.log(`用法: evolclaw net check [<aid>] [--format json]
569
568
 
570
569
  检查 AUN 网络链路连通性(10 步逐层诊断)。