evolclaw 3.1.4 → 3.1.6

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 (99) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/agents/claude-runner.js +398 -161
  3. package/dist/agents/kit-renderer.js +191 -25
  4. package/dist/aun/aid/agentmd.js +75 -103
  5. package/dist/aun/aid/client.js +1 -29
  6. package/dist/aun/aid/identity.js +105 -64
  7. package/dist/aun/aid/index.js +2 -1
  8. package/dist/aun/aid/store.js +74 -0
  9. package/dist/aun/msg/group.js +2 -2
  10. package/dist/aun/msg/p2p.js +26 -2
  11. package/dist/aun/rpc/connection.js +23 -30
  12. package/dist/channels/aun.js +174 -99
  13. package/dist/channels/dingtalk.js +2 -1
  14. package/dist/channels/feishu.js +301 -199
  15. package/dist/channels/qqbot.js +2 -1
  16. package/dist/channels/wechat.js +2 -1
  17. package/dist/channels/wecom.js +2 -1
  18. package/dist/cli/agent.js +21 -16
  19. package/dist/cli/bench.js +41 -28
  20. package/dist/cli/help.js +8 -0
  21. package/dist/cli/index.js +176 -87
  22. package/dist/cli/init-channel.js +5 -1
  23. package/dist/cli/init.js +37 -21
  24. package/dist/cli/link-rules.js +1 -7
  25. package/dist/cli/model.js +549 -0
  26. package/dist/cli/net-check.js +133 -50
  27. package/dist/cli/watch-msg.js +7 -7
  28. package/dist/cli/watch-web/debug-log.js +18 -0
  29. package/dist/cli/watch-web/server.js +306 -0
  30. package/dist/cli/watch-web/sources/aid.js +63 -0
  31. package/dist/cli/watch-web/sources/msg.js +70 -0
  32. package/dist/cli/watch-web/sources/session.js +638 -0
  33. package/dist/cli/watch-web/sources/types.js +10 -0
  34. package/dist/cli/watch-web/static/app.js +546 -0
  35. package/dist/cli/watch-web/static/index.html +54 -0
  36. package/dist/cli/watch-web/static/style.css +247 -0
  37. package/dist/config-store.js +1 -22
  38. package/dist/core/channel-loader.js +7 -4
  39. package/dist/core/command-handler.js +261 -133
  40. package/dist/core/evolagent-registry.js +1 -1
  41. package/dist/core/evolagent.js +4 -22
  42. package/dist/core/interaction-router.js +59 -0
  43. package/dist/core/message/im-renderer.js +9 -20
  44. package/dist/core/message/message-bridge.js +13 -9
  45. package/dist/core/message/message-log.js +2 -2
  46. package/dist/core/message/message-processor.js +211 -123
  47. package/dist/core/message/stream-idle-monitor.js +21 -0
  48. package/dist/core/model/model-catalog.js +215 -0
  49. package/dist/core/model/model-scope.js +250 -0
  50. package/dist/core/relation/peer-identity.js +58 -55
  51. package/dist/core/relation/peer-key.js +16 -0
  52. package/dist/core/session/session-fs-store.js +34 -55
  53. package/dist/core/session/session-key.js +24 -0
  54. package/dist/core/session/session-manager.js +308 -251
  55. package/dist/core/session/session-mapper.js +9 -4
  56. package/dist/core/trigger/manager.js +3 -3
  57. package/dist/core/trigger/parser.js +4 -4
  58. package/dist/core/trigger/scheduler.js +22 -7
  59. package/dist/index.js +61 -7
  60. package/dist/ipc.js +23 -1
  61. package/dist/utils/error-utils.js +6 -0
  62. package/dist/utils/process-introspect.js +7 -5
  63. package/kits/docs/GUIDE.md +2 -2
  64. package/kits/docs/INDEX.md +8 -8
  65. package/kits/docs/channels/aun.md +56 -17
  66. package/kits/docs/channels/feishu.md +41 -12
  67. package/kits/docs/context-assembly.md +182 -0
  68. package/kits/docs/evolclaw/INDEX.md +43 -0
  69. package/kits/docs/evolclaw/agent.md +49 -0
  70. package/kits/docs/evolclaw/aid.md +49 -0
  71. package/kits/docs/evolclaw/ctl.md +46 -0
  72. package/kits/docs/evolclaw/group.md +89 -0
  73. package/kits/docs/evolclaw/model.md +51 -0
  74. package/kits/docs/evolclaw/msg.md +91 -0
  75. package/kits/docs/evolclaw/rpc.md +35 -0
  76. package/kits/docs/evolclaw/storage.md +49 -0
  77. package/kits/docs/venues/aun-group.md +10 -0
  78. package/kits/docs/venues/aun-private.md +10 -0
  79. package/kits/docs/venues/client-desktop.md +10 -0
  80. package/kits/docs/venues/client-mobile.md +10 -0
  81. package/kits/docs/venues/feishu-group.md +13 -0
  82. package/kits/docs/venues/feishu-private.md +9 -0
  83. package/kits/docs/venues/group.md +23 -0
  84. package/kits/docs/venues/private.md +10 -0
  85. package/kits/eck_manifest.json +81 -36
  86. package/kits/rules/01-overview.md +20 -10
  87. package/kits/rules/06-channel.md +34 -27
  88. package/kits/templates/system-fragments/baseagent.md +7 -1
  89. package/kits/templates/system-fragments/channel.md +7 -5
  90. package/kits/templates/system-fragments/commands.md +19 -0
  91. package/kits/templates/system-fragments/session.md +19 -3
  92. package/kits/templates/system-fragments/venue.md +24 -0
  93. package/package.json +10 -5
  94. package/dist/aun/aid/lifecycle-log.js +0 -33
  95. package/dist/utils/aid-lifecycle-log.js +0 -33
  96. package/kits/docs/evolclaw/AGENT_CMD.md +0 -31
  97. package/kits/docs/evolclaw/MSG_GROUP.md +0 -30
  98. package/kits/docs/evolclaw/MSG_PRIVATE.md +0 -72
  99. package/kits/docs/evolclaw/tools.md +0 -25
@@ -0,0 +1,63 @@
1
+ /**
2
+ * AID 数据源 — 复用 daemon 的 IPC socket(与 `watch aid` 同源)。
3
+ *
4
+ * daemon 运行时:拉 aun-aids / aun-aid-stats / status。
5
+ * daemon 未运行时:降级到 instance-registry 的 scanInstances()。
6
+ * IPC 无推送能力,故用 1s 轮询 + JSON diff,仅在变化时 push。
7
+ */
8
+ import { resolvePaths } from '../../../paths.js';
9
+ import { ipcQuery } from '../../../ipc.js';
10
+ import { scanInstances } from '../../../utils/instance-registry.js';
11
+ async function buildSnapshot() {
12
+ const p = resolvePaths();
13
+ const [aidsResp, statsResp, statusResp, agentsResp] = await Promise.all([
14
+ ipcQuery(p.socket, { type: 'aun-aids' }),
15
+ ipcQuery(p.socket, { type: 'aun-aid-stats' }),
16
+ ipcQuery(p.socket, { type: 'status' }),
17
+ ipcQuery(p.socket, { type: 'evolagent.list' }),
18
+ ]);
19
+ const daemonRunning = aidsResp !== null || statusResp !== null;
20
+ if (!daemonRunning) {
21
+ // 降级:读 instance-registry,标注 daemon 未运行
22
+ const inst = scanInstances();
23
+ const aids = Array.from(inst.aidLastActivity.entries()).map(([aid, info]) => ({
24
+ aid,
25
+ status: info.event === 'disconnected' ? 'disconnected' : 'offline',
26
+ lastActivity: info.ts,
27
+ lastEvent: info.event,
28
+ }));
29
+ return { daemonRunning: false, aids, stats: [], agents: [] };
30
+ }
31
+ return {
32
+ daemonRunning: true,
33
+ aids: aidsResp?.aids ?? [],
34
+ stats: statsResp?.stats ?? [],
35
+ status: statusResp ?? null,
36
+ agents: agentsResp?.agents ?? [],
37
+ };
38
+ }
39
+ export const aidSource = {
40
+ kind: 'aid',
41
+ async snapshot() {
42
+ return buildSnapshot();
43
+ },
44
+ subscribe(_params, push) {
45
+ let lastJson = '';
46
+ let stopped = false;
47
+ const tick = async () => {
48
+ if (stopped)
49
+ return;
50
+ try {
51
+ const snap = await buildSnapshot();
52
+ const json = JSON.stringify(snap);
53
+ if (json !== lastJson) {
54
+ lastJson = json;
55
+ push(snap);
56
+ }
57
+ }
58
+ catch { /* ignore transient IPC errors */ }
59
+ };
60
+ const timer = setInterval(tick, 1000);
61
+ return () => { stopped = true; clearInterval(timer); };
62
+ },
63
+ };
@@ -0,0 +1,70 @@
1
+ /**
2
+ * 消息数据源 — 复用 watch-msg.ts 的数据层函数 + fs.watch 文件监听。
3
+ *
4
+ * snapshot:
5
+ * - 无 aid: 返回本地 AID 列表(含收发统计)
6
+ * - 有 aid 无 peer: 返回该 AID 的对端列表 + 全部消息
7
+ * - 有 aid 有 peer: 返回该对端的消息
8
+ * subscribe: fs.watch(sessions/aun, recursive),messages.jsonl 变化时防抖 150ms 后重推。
9
+ */
10
+ import fs from 'fs';
11
+ import { getSessionsAunDir, listLocalAids, loadAidInfo, loadPeerInfos, loadAllMessages, readMessages, } from '../../watch-msg.js';
12
+ function buildSnapshot(params) {
13
+ const aunDir = getSessionsAunDir();
14
+ if (!fs.existsSync(aunDir)) {
15
+ return { aids: [], peers: [], messages: [], aid: null, peer: null };
16
+ }
17
+ const aid = params.aid || null;
18
+ const peer = params.peer || null;
19
+ const aids = listLocalAids(aunDir)
20
+ .map(a => loadAidInfo(aunDir, a))
21
+ .sort((a, b) => (b.totalIn + b.totalOut) - (a.totalIn + a.totalOut));
22
+ if (!aid) {
23
+ return { aids, peers: [], messages: [], aid: null, peer: null };
24
+ }
25
+ const peers = loadPeerInfos(aunDir, aid);
26
+ let messages;
27
+ if (peer) {
28
+ messages = readMessages(aunDir, aid, peer);
29
+ if (messages.length > 1000)
30
+ messages = messages.slice(-1000);
31
+ }
32
+ else {
33
+ messages = loadAllMessages(aunDir, aid);
34
+ }
35
+ return { aids, peers, messages, aid, peer };
36
+ }
37
+ export const msgSource = {
38
+ kind: 'msg',
39
+ async snapshot(params = {}) {
40
+ return buildSnapshot(params);
41
+ },
42
+ subscribe(params, push) {
43
+ const aunDir = getSessionsAunDir();
44
+ let watcher = null;
45
+ let debounce = null;
46
+ const fire = () => {
47
+ if (debounce)
48
+ clearTimeout(debounce);
49
+ debounce = setTimeout(() => {
50
+ try {
51
+ push(buildSnapshot(params));
52
+ }
53
+ catch { /* ignore */ }
54
+ }, 150);
55
+ };
56
+ try {
57
+ watcher = fs.watch(aunDir, { recursive: true }, (_evt, filename) => {
58
+ if (filename && String(filename).endsWith('messages.jsonl'))
59
+ fire();
60
+ });
61
+ }
62
+ catch { /* aunDir may not exist yet */ }
63
+ return () => {
64
+ if (watcher)
65
+ watcher.close();
66
+ if (debounce)
67
+ clearTimeout(debounce);
68
+ };
69
+ },
70
+ };