evolclaw 2.8.3 → 3.1.0

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 (142) hide show
  1. package/README.md +21 -12
  2. package/bin/ec.js +29 -0
  3. package/dist/agents/baseagent-normalize.js +19 -0
  4. package/dist/agents/claude-runner.js +108 -46
  5. package/dist/agents/codex-runner.js +13 -14
  6. package/dist/agents/gemini-runner.js +15 -17
  7. package/dist/agents/kit-renderer.js +281 -0
  8. package/dist/agents/resolve.js +134 -0
  9. package/dist/aun/aid/agentmd.js +186 -0
  10. package/dist/aun/aid/client.js +134 -0
  11. package/dist/aun/aid/identity.js +159 -0
  12. package/dist/aun/aid/index.js +3 -0
  13. package/dist/aun/aid/lifecycle-log.js +33 -0
  14. package/dist/aun/aid/types.js +1 -0
  15. package/dist/aun/aid/validation.js +21 -0
  16. package/dist/aun/msg/group.js +293 -0
  17. package/dist/aun/msg/index.js +4 -0
  18. package/dist/aun/msg/p2p.js +147 -0
  19. package/dist/aun/msg/payload-type.js +27 -0
  20. package/dist/aun/msg/upload.js +98 -0
  21. package/dist/aun/outbox.js +138 -0
  22. package/dist/aun/rpc/caller.js +42 -0
  23. package/dist/aun/rpc/connection.js +34 -0
  24. package/dist/aun/rpc/index.js +2 -0
  25. package/dist/aun/storage/download.js +29 -0
  26. package/dist/aun/storage/index.js +3 -0
  27. package/dist/aun/storage/manage.js +10 -0
  28. package/dist/aun/storage/upload.js +35 -0
  29. package/dist/channels/aun.js +1340 -349
  30. package/dist/channels/dingtalk.js +59 -5
  31. package/dist/channels/feishu.js +381 -32
  32. package/dist/channels/qqbot.js +68 -12
  33. package/dist/channels/wechat.js +63 -4
  34. package/dist/channels/wecom.js +59 -5
  35. package/dist/cli/agent.js +800 -0
  36. package/dist/cli/bench.js +1219 -0
  37. package/dist/cli/index.js +4513 -0
  38. package/dist/{utils → cli}/init-channel.js +211 -621
  39. package/dist/cli/init.js +178 -0
  40. package/dist/cli/link-rules.js +245 -0
  41. package/dist/cli/net-check.js +640 -0
  42. package/dist/cli/watch-msg.js +589 -0
  43. package/dist/config-store.js +645 -0
  44. package/dist/core/{agent-loader.js → baseagent-loader.js} +6 -12
  45. package/dist/core/channel-loader.js +176 -12
  46. package/dist/core/command-handler.js +883 -848
  47. package/dist/core/evolagent-registry.js +191 -371
  48. package/dist/core/evolagent.js +202 -238
  49. package/dist/core/interaction-router.js +52 -5
  50. package/dist/core/message/im-renderer.js +486 -0
  51. package/dist/core/message/items-formatter.js +68 -0
  52. package/dist/core/message/message-bridge.js +109 -56
  53. package/dist/core/message/message-log.js +93 -0
  54. package/dist/core/message/message-processor.js +430 -212
  55. package/dist/core/message/message-queue.js +13 -6
  56. package/dist/core/permission.js +116 -11
  57. package/dist/core/session/adapters/codex-session-file-adapter.js +24 -2
  58. package/dist/core/session/session-fs-store.js +230 -0
  59. package/dist/core/session/session-manager.js +740 -777
  60. package/dist/core/session/session-mapper.js +87 -0
  61. package/dist/core/trigger/manager.js +122 -0
  62. package/dist/core/trigger/parser.js +128 -0
  63. package/dist/core/trigger/scheduler.js +224 -0
  64. package/dist/data/error-dict.json +118 -0
  65. package/dist/eck/baseagent-caps.js +18 -0
  66. package/dist/eck/detect.js +47 -0
  67. package/dist/eck/init.js +77 -0
  68. package/dist/eck/rules-loader.js +28 -0
  69. package/dist/index.js +560 -283
  70. package/dist/ipc.js +49 -0
  71. package/dist/net-check.js +640 -0
  72. package/dist/paths.js +73 -9
  73. package/dist/types.js +8 -2
  74. package/dist/utils/aid-lifecycle-log.js +33 -0
  75. package/dist/utils/atomic-write.js +89 -0
  76. package/dist/utils/channel-helpers.js +46 -0
  77. package/dist/utils/cross-platform.js +17 -26
  78. package/dist/utils/error-utils.js +10 -2
  79. package/dist/utils/instance-registry.js +434 -0
  80. package/dist/utils/log-writer.js +217 -0
  81. package/dist/utils/logger.js +34 -77
  82. package/dist/utils/media-cache.js +23 -0
  83. package/dist/utils/npm-ops.js +163 -0
  84. package/dist/utils/process-introspect.js +122 -0
  85. package/dist/utils/stats.js +192 -0
  86. package/dist/watch-msg.js +544 -0
  87. package/evolclaw-install-aun.md +127 -47
  88. package/kits/docs/GUIDE.md +20 -0
  89. package/kits/docs/INDEX.md +52 -0
  90. package/kits/docs/aun/CHEATSHEET.md +17 -0
  91. package/kits/docs/aun/SYNC_PROTOCOL.md +15 -0
  92. package/kits/docs/channels/aun.md +25 -0
  93. package/kits/docs/channels/feishu.md +27 -0
  94. package/kits/docs/eck_templates/GUIDE.template.md +22 -0
  95. package/kits/docs/eck_templates/INDEX.template.md +28 -0
  96. package/kits/docs/eck_templates/path-registry.template.md +33 -0
  97. package/kits/docs/eck_templates/runtime.template.md +19 -0
  98. package/kits/docs/evolclaw/AGENT_CMD.md +31 -0
  99. package/kits/docs/evolclaw/MSG_GROUP.md +30 -0
  100. package/kits/docs/evolclaw/MSG_PRIVATE.md +25 -0
  101. package/kits/docs/evolclaw/self-summary.md +29 -0
  102. package/kits/docs/evolclaw/tools.md +25 -0
  103. package/kits/docs/identity/AID_PROFILE_SPEC.md +27 -0
  104. package/kits/docs/identity/PATH_OPS.md +16 -0
  105. package/kits/docs/identity/ROLE_DETAIL.md +20 -0
  106. package/kits/docs/identity/identity-tools.md +26 -0
  107. package/kits/docs/path-registry.md +43 -0
  108. package/kits/eck_manifest.json +95 -0
  109. package/kits/rules/01-overview.md +120 -0
  110. package/kits/rules/02-navigation.md +75 -0
  111. package/kits/rules/03-identity.md +34 -0
  112. package/kits/rules/04-relation.md +49 -0
  113. package/kits/rules/05-venue.md +45 -0
  114. package/kits/rules/06-channel.md +43 -0
  115. package/kits/templates/system-fragments/baseagent.md +2 -0
  116. package/kits/templates/system-fragments/channel.md +10 -0
  117. package/kits/templates/system-fragments/identity.md +12 -0
  118. package/kits/templates/system-fragments/relation.md +9 -0
  119. package/kits/templates/system-fragments/runtime.md +19 -0
  120. package/kits/templates/system-fragments/venue.md +5 -0
  121. package/package.json +10 -6
  122. package/data/evolclaw.sample.json +0 -60
  123. package/dist/agents/templates.js +0 -122
  124. package/dist/channels/aun-ops.js +0 -275
  125. package/dist/cli.js +0 -2178
  126. package/dist/config.js +0 -591
  127. package/dist/core/agent-registry.js +0 -450
  128. package/dist/core/evolagent-schema.js +0 -72
  129. package/dist/core/message/stream-flusher.js +0 -238
  130. package/dist/core/message/thought-emitter.js +0 -162
  131. package/dist/core/reload-hooks.js +0 -87
  132. package/dist/prompts/templates.js +0 -122
  133. package/dist/templates/prompts.md +0 -104
  134. package/dist/templates/skills.md +0 -66
  135. package/dist/utils/channel-fingerprint.js +0 -59
  136. package/dist/utils/error-dict.js +0 -63
  137. package/dist/utils/format.js +0 -32
  138. package/dist/utils/init.js +0 -645
  139. package/dist/utils/migrate-project.js +0 -122
  140. package/dist/utils/reload-hooks.js +0 -87
  141. package/dist/utils/stats-collector.js +0 -99
  142. package/dist/utils/upgrade.js +0 -100
@@ -0,0 +1,47 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { BASEAGENT_CAPS } from './baseagent-caps.js';
4
+ const MAX_DEPTH = 5;
5
+ export function resolveEckInjection(agentConfig, projectPath, kitsRulesPath) {
6
+ const caps = BASEAGENT_CAPS[agentConfig.baseAgent]
7
+ ?? { autoLoadsRules: false, supportsSystemPrompt: true };
8
+ if (!caps.autoLoadsRules) {
9
+ return { shouldInject: true, reason: 'baseagent-no-autoload' };
10
+ }
11
+ const symlinkActive = detectEckSymlink(projectPath, kitsRulesPath);
12
+ if (symlinkActive) {
13
+ return { shouldInject: false, reason: 'symlink-active' };
14
+ }
15
+ return { shouldInject: true, reason: 'symlink-not-found' };
16
+ }
17
+ export function detectEckSymlink(projectPath, kitsRulesPath) {
18
+ let dir = projectPath;
19
+ let depth = 0;
20
+ while (depth < MAX_DEPTH) {
21
+ const eckDir = path.join(dir, '.claude', 'rules', 'eck');
22
+ if (fs.existsSync(eckDir)) {
23
+ try {
24
+ const realPath = fs.realpathSync(eckDir);
25
+ const kitsRulesReal = fs.realpathSync(kitsRulesPath);
26
+ if (pathEquals(realPath, kitsRulesReal)) {
27
+ return true;
28
+ }
29
+ }
30
+ catch {
31
+ // detection failure → conservatively assume not loaded
32
+ }
33
+ }
34
+ const parent = path.dirname(dir);
35
+ if (parent === dir)
36
+ break;
37
+ dir = parent;
38
+ depth++;
39
+ }
40
+ return false;
41
+ }
42
+ function pathEquals(a, b) {
43
+ if (process.platform === 'win32') {
44
+ return path.resolve(a).toLowerCase() === path.resolve(b).toLowerCase();
45
+ }
46
+ return path.resolve(a) === path.resolve(b);
47
+ }
@@ -0,0 +1,77 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { resolvePaths, kitsDocsDir, agentDir, getPackageRoot } from '../paths.js';
4
+ import { atomicWriteText } from '../utils/atomic-write.js';
5
+ import { logger } from '../utils/logger.js';
6
+ export function initEck() {
7
+ const p = resolvePaths();
8
+ const eckDir = p.eckDir;
9
+ fs.mkdirSync(eckDir, { recursive: true });
10
+ initEckRuntime(eckDir);
11
+ initEckPathRegistry(eckDir);
12
+ }
13
+ export function initAgentIndex(aid) {
14
+ const indexDir = path.join(agentDir(aid), 'index');
15
+ fs.mkdirSync(indexDir, { recursive: true });
16
+ const indexFile = path.join(indexDir, 'INDEX.md');
17
+ const guideFile = path.join(indexDir, 'GUIDE.md');
18
+ if (!fs.existsSync(indexFile)) {
19
+ const template = loadTemplate('INDEX.template.md');
20
+ if (template) {
21
+ atomicWriteText(indexFile, renderTemplate(template, { AID: aid }));
22
+ logger.info(`[eck] Created ${indexFile}`);
23
+ }
24
+ }
25
+ if (!fs.existsSync(guideFile)) {
26
+ const template = loadTemplate('GUIDE.template.md');
27
+ if (template) {
28
+ atomicWriteText(guideFile, renderTemplate(template, { AID: aid }));
29
+ logger.info(`[eck] Created ${guideFile}`);
30
+ }
31
+ }
32
+ }
33
+ function initEckRuntime(eckDir) {
34
+ const runtimeFile = path.join(eckDir, 'runtime.md');
35
+ if (fs.existsSync(runtimeFile))
36
+ return;
37
+ const template = loadTemplate('runtime.template.md');
38
+ if (!template)
39
+ return;
40
+ const vars = {
41
+ EVOLCLAW_HOME: resolvePaths().root,
42
+ PACKAGE_ROOT: getPackageRoot(),
43
+ };
44
+ atomicWriteText(runtimeFile, renderTemplate(template, vars));
45
+ logger.info(`[eck] Created ${runtimeFile}`);
46
+ }
47
+ function initEckPathRegistry(eckDir) {
48
+ const registryFile = path.join(eckDir, 'path-registry.md');
49
+ if (fs.existsSync(registryFile))
50
+ return;
51
+ const template = loadTemplate('path-registry.template.md');
52
+ if (!template)
53
+ return;
54
+ const vars = {
55
+ EVOLCLAW_HOME: resolvePaths().root,
56
+ PACKAGE_ROOT: getPackageRoot(),
57
+ };
58
+ atomicWriteText(registryFile, renderTemplate(template, vars));
59
+ logger.info(`[eck] Created ${registryFile}`);
60
+ }
61
+ function loadTemplate(filename) {
62
+ const templatePath = path.join(kitsDocsDir(), 'eck_templates', filename);
63
+ try {
64
+ return fs.readFileSync(templatePath, 'utf-8');
65
+ }
66
+ catch {
67
+ logger.warn(`[eck] Template not found: ${templatePath}`);
68
+ return null;
69
+ }
70
+ }
71
+ function renderTemplate(template, vars) {
72
+ let result = template;
73
+ for (const [key, value] of Object.entries(vars)) {
74
+ result = result.replaceAll(`{{${key}}}`, value);
75
+ }
76
+ return result;
77
+ }
@@ -0,0 +1,28 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { kitsRulesDir } from '../paths.js';
4
+ let _cachedRules = null;
5
+ export function loadRulesForInjection() {
6
+ if (_cachedRules !== null)
7
+ return _cachedRules;
8
+ const rulesDir = kitsRulesDir();
9
+ if (!fs.existsSync(rulesDir)) {
10
+ _cachedRules = '';
11
+ return '';
12
+ }
13
+ const files = fs.readdirSync(rulesDir)
14
+ .filter(f => f.endsWith('.md'))
15
+ .sort();
16
+ const parts = [];
17
+ for (const file of files) {
18
+ try {
19
+ parts.push(fs.readFileSync(path.join(rulesDir, file), 'utf-8'));
20
+ }
21
+ catch { /* skip unreadable files */ }
22
+ }
23
+ _cachedRules = parts.join('\n\n');
24
+ return _cachedRules;
25
+ }
26
+ export function invalidateRulesCache() {
27
+ _cachedRules = null;
28
+ }