* 删除会话数据
(sessionId: string)
| 145 | * 删除会话数据 |
| 146 | */ |
| 147 | async deleteSession(sessionId: string): Promise<void> { |
| 148 | try { |
| 149 | const sessionPath = path.join(this.storagePath, 'sessions', `${sessionId}.json`); |
| 150 | const conversationPath = path.join(this.storagePath, 'conversations', `${sessionId}.json`); |
| 151 | |
| 152 | await Promise.all([ |
| 153 | fs.unlink(sessionPath).catch(() => {}), |
| 154 | fs.unlink(conversationPath).catch(() => {}), |
| 155 | ]); |
| 156 | } catch (error) { |
| 157 | console.warn(`警告:无法删除会话 ${sessionId}:`, error); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * 清理旧会话(保持最近的N个会话) |
no test coverage detected