evolclaw 2.1.1 → 2.1.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.
@@ -545,26 +545,12 @@ export class SessionManager {
545
545
  return this.rowToSession(rows[0]);
546
546
  }
547
547
  async importCliSession(channel, channelId, projectPath, agentSessionId) {
548
- // 检查是否已存在相同项目路径的会话
549
- const existingByPath = this.db.prepare(`
550
- SELECT * FROM sessions
551
- WHERE channel = ? AND channel_id = ? AND project_path = ?
552
- `).get(channel, channelId, projectPath);
553
- if (existingByPath) {
554
- // 更新 agent_session_id 并激活
555
- this.db.prepare(`
556
- UPDATE sessions SET is_active = 0, updated_at = ?
557
- WHERE channel = ? AND channel_id = ? AND is_active = 1 AND id != ?
558
- `).run(Date.now(), channel, channelId, existingByPath.id);
559
- this.db.prepare(`
560
- UPDATE sessions SET agent_session_id = ?, is_active = 1, updated_at = ?
561
- WHERE id = ?
562
- `).run(agentSessionId, Date.now(), existingByPath.id);
563
- return { ...this.rowToSession(existingByPath), agentSessionId, isActive: true, updatedAt: Date.now() };
564
- }
565
548
  // 取消当前活跃会话
566
549
  this.deactivateAll(channel, channelId);
567
- // 创建会话记录
550
+ // 从 CLI 会话文件读取标题
551
+ const fileInfo = this.getSessionFileInfo(projectPath, agentSessionId);
552
+ const name = fileInfo.title || `CLI会话-${new Date().toLocaleString('zh-CN', { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' })}`;
553
+ // 创建新会话记录
568
554
  const session = {
569
555
  id: `${channel}-${channelId}-${Date.now()}`,
570
556
  channel,
@@ -573,7 +559,7 @@ export class SessionManager {
573
559
  threadId: '',
574
560
  agentType: 'claude',
575
561
  agentSessionId,
576
- name: `CLI会话-${new Date().toLocaleString('zh-CN', { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' })}`,
562
+ name,
577
563
  isActive: true,
578
564
  createdAt: Date.now(),
579
565
  updatedAt: Date.now()
@@ -10,7 +10,8 @@ export var ErrorType;
10
10
  export function classifyError(error) {
11
11
  const msg = (error?.message || '').toLowerCase();
12
12
  if (msg.includes('上下文过长') || msg.includes('context too long')
13
- || msg.includes('context_length_exceeded') || msg.includes('context_compact_failed')) {
13
+ || msg.includes('context_length_exceeded') || msg.includes('context_compact_failed')
14
+ || msg.includes('prompt is too long') || msg.includes('context limit')) {
14
15
  return ErrorType.CONTEXT_TOO_LONG;
15
16
  }
16
17
  if (msg.includes('timeout') || msg.includes('etimedout')) {
@@ -32,7 +33,8 @@ export function getErrorMessage(error) {
32
33
  if (msg.includes('CONTEXT_COMPACT_FAILED')) {
33
34
  return '⚠️ 上下文过长,自动压缩失败,请手动输入 /compact 重试';
34
35
  }
35
- if (msg.includes('上下文过长') || msg.includes('context too long') || msg.includes('context_length_exceeded')) {
36
+ if (msg.includes('上下文过长') || msg.includes('context too long') || msg.includes('context_length_exceeded')
37
+ || msg.includes('Prompt is too long') || msg.includes('Context limit')) {
36
38
  return '⚠️ 上下文过长,自动压缩重试失败,请手动输入 /compact 重试';
37
39
  }
38
40
  if (msg.includes('API Error: 400')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evolclaw",
3
- "version": "2.1.1",
3
+ "version": "2.1.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",