evolclaw 2.8.0 → 2.8.2

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.
@@ -7,23 +7,24 @@ export class StatsCollector {
7
7
  // 订阅相关事件
8
8
  eventBus.subscribe('message:received', (event) => {
9
9
  const e = event;
10
- this.recordEvent({ type: 'received', timestamp: e.timestamp || Date.now() });
10
+ this.recordEvent({ type: 'received', timestamp: e.timestamp || Date.now(), agentName: e.agentName });
11
11
  });
12
12
  eventBus.subscribe('message:completed', (event) => {
13
13
  const e = event;
14
- this.recordEvent({ type: 'completed', timestamp: e.timestamp || Date.now(), durationMs: e.durationMs });
14
+ this.recordEvent({ type: 'completed', timestamp: e.timestamp || Date.now(), durationMs: e.durationMs, agentName: e.agentName });
15
15
  });
16
16
  eventBus.subscribe('message:error', (event) => {
17
17
  const e = event;
18
- this.recordEvent({ type: 'error', timestamp: Date.now(), errorType: e.errorType });
18
+ this.recordEvent({ type: 'error', timestamp: Date.now(), errorType: e.errorType, agentName: e.agentName });
19
19
  });
20
- eventBus.subscribe('message:interrupted', (_event) => {
21
- this.recordEvent({ type: 'interrupted', timestamp: Date.now() });
20
+ eventBus.subscribe('message:interrupted', (event) => {
21
+ const e = event;
22
+ this.recordEvent({ type: 'interrupted', timestamp: Date.now(), agentName: e.agentName });
22
23
  });
23
24
  eventBus.subscribe('tool:result', (event) => {
24
25
  const e = event;
25
26
  if (e.isError) {
26
- this.recordEvent({ type: 'tool-error', timestamp: Date.now(), toolName: e.toolName });
27
+ this.recordEvent({ type: 'tool-error', timestamp: Date.now(), toolName: e.toolName, agentName: e.agentName });
27
28
  }
28
29
  });
29
30
  }
@@ -31,14 +32,18 @@ export class StatsCollector {
31
32
  this.events.push(record);
32
33
  }
33
34
  /**
34
- * 获取统计快照(自动裁剪 >1h 的事件)
35
+ * 获取统计快照。可选 agentName 过滤:未传则全局;传入则只统计该 agent。
36
+ * 自动裁剪 >1h 的事件。
35
37
  */
36
- getSnapshot() {
38
+ getSnapshot(agentName) {
37
39
  const now = Date.now();
38
40
  const cutoff = now - this.HOUR_MS;
39
41
  // 裁剪过期事件
40
42
  this.events = this.events.filter(e => e.timestamp >= cutoff);
41
- // 聚合统计
43
+ // 聚合统计(可按 agent 过滤)
44
+ const filtered = agentName === undefined
45
+ ? this.events
46
+ : this.events.filter(e => (e.agentName ?? '[default]') === agentName);
42
47
  let received = 0;
43
48
  let completed = 0;
44
49
  let errors = 0;
@@ -48,7 +53,7 @@ export class StatsCollector {
48
53
  let interrupts = 0;
49
54
  let totalDuration = 0;
50
55
  let durationCount = 0;
51
- for (const event of this.events) {
56
+ for (const event of filtered) {
52
57
  switch (event.type) {
53
58
  case 'received':
54
59
  received++;
@@ -46,23 +46,64 @@ export PATH=~/.npm-global/bin:$PATH
46
46
  npm install -g evolclaw
47
47
  ```
48
48
 
49
- ### 步骤 3:准备配置信息
49
+ ### 步骤 3:检查是否已在运行
50
+
51
+ npm 安装完成后,先检查是否有正在运行的 evolclaw 进程。升级或重装场景下,旧进程仍在使用旧版本代码,必须停止后才能让新版本生效。
52
+
53
+ ```bash
54
+ evolclaw status
55
+ ```
56
+
57
+ 判断逻辑:
58
+
59
+ - 输出包含 `running` / `PID` / `已启动` 等表明服务在运行 → **询问用户**是否停止:
60
+
61
+ > 检测到 evolclaw 正在运行(PID: xxx)。继续安装需要停止当前服务以应用新版本,是否停止?(y/N)
62
+
63
+ 用户确认后执行:
64
+
65
+ ```bash
66
+ evolclaw stop
67
+ ```
68
+
69
+ 用户拒绝则中止安装流程,提醒其手动 `evolclaw stop` 后重新发起。
70
+
71
+ - 输出表明未运行(`not running` / `stopped` / 无 PID)→ 直接进入下一步。
72
+
73
+ ### 步骤 4:准备配置信息
50
74
 
51
75
  | 参数 | 说明 | 示例 |
52
76
  |------|------|------|
53
77
  | `--aun-aid` | **必填**,Agent 自身的 AID,作为 bot 在 AUN 网络上的独立身份 | `mybot.agentid.pub` |
54
78
  | `--aun-owner` | **必填**,Owner 的 AID,用于接收欢迎消息和管理权限 | `alice.agentid.pub` |
55
- | `--default-path` | 默认项目路径(可选,默认当前目录) | `/home/user/myproject` |
79
+ | `--default-path` | 默认项目路径(bot 会话未显式 `/bind` 时使用的工作目录) | `/home/user/myproject` |
56
80
 
57
81
  **注意**:`--aun-aid` 和 `--aun-owner` 必须是不同的 AID。Agent 需要独立身份,不能与 Owner 相同。
58
82
 
59
83
  如果用户在触发安装时已提供 Owner AID(例如消息中包含"将 xxx 添加为 Owner ID"),直接使用该值,否则询问用户。Agent AID 必须单独询问用户,不能默认使用 Owner AID。
60
84
 
61
- ### 步骤 4:非交互式初始化
85
+ **默认项目路径必须询问用户,提供三个选项:**
86
+
87
+ 1. **推荐默认**:`~/projects/default`(EvolClaw 约定的默认工作区;若不存在会自动创建)
88
+ 2. **当前 Claude Code 运行目录**:即本次会话启动 `claude` 的工作目录(通过 `pwd` 获取)——适合希望 bot 直接在当前项目里工作的场景
89
+ 3. **自定义路径**:用户指定绝对路径(须是已存在的目录,或接受后自动创建)
90
+
91
+ 示例提问:
92
+
93
+ > 请选择默认项目目录(bot 未显式 `/bind` 时使用的工作目录):
94
+ > 1) `~/projects/default`(推荐,EvolClaw 默认工作区)
95
+ > 2) 当前目录:`<pwd 输出>`
96
+ > 3) 自定义路径(请提供绝对路径)
97
+
98
+ 用户未选择时,默认取选项 1。选项 3 需校验路径是绝对路径;目录不存在则 `mkdir -p` 创建。
99
+
100
+ ### 步骤 5:非交互式初始化
101
+
102
+ 将用户选择的目录作为 `--default-path` 传入:
62
103
 
63
104
  ```bash
64
105
  evolclaw init --non-interactive \
65
- --default-path "$PWD" \
106
+ --default-path <用户选择的绝对路径> \
66
107
  --channel aun \
67
108
  --aun-aid <AID> \
68
109
  --aun-owner <Owner AID>
@@ -76,7 +117,7 @@ evolclaw init --non-interactive \
76
117
  5. 写入初始 `agent.md`(`initialized: false`)
77
118
  6. 写入配置(含 owner 字段)
78
119
 
79
- ### 步骤 5:启动前验证
120
+ ### 步骤 6:启动前验证
80
121
 
81
122
  读取配置文件确认关键字段:
82
123
 
@@ -92,13 +133,13 @@ cat ~/.evolclaw/data/evolclaw.json
92
133
 
93
134
  如发现缺失或异常,向用户说明并提供修复方案。
94
135
 
95
- ### 步骤 6:启动服务
136
+ ### 步骤 7:启动服务
96
137
 
97
138
  ```bash
98
139
  evolclaw start
99
140
  ```
100
141
 
101
- ### 步骤 7:验证运行状态
142
+ ### 步骤 8:验证运行状态
102
143
 
103
144
  ```bash
104
145
  evolclaw status
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evolclaw",
3
- "version": "2.8.0",
3
+ "version": "2.8.2",
4
4
  "description": "Lightweight AI Agent gateway connecting Claude Agent SDK to messaging channels (Feishu, ACP) with multi-project session management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",