* Removes a session: deletes the database record and the associated JSONL file. * @param sessionId - The session identifier. * @throws SessionNotFoundError if the session does not exist.
(sessionId: string)
| 250 | * @throws SessionNotFoundError if the session does not exist. |
| 251 | */ |
| 252 | removeSession(sessionId: string): void { |
| 253 | if (!this.existsSession(sessionId)) { |
| 254 | throw new SessionNotFoundError(sessionId); |
| 255 | } |
| 256 | this._db.delete(sessions).where(eq(sessions.id, sessionId)).run(); |
| 257 | const filePath = config.paths.resolveSessionFilePath(sessionId); |
| 258 | if (existsSync(filePath)) { |
| 259 | unlinkSync(filePath); |
| 260 | } |
| 261 | this._logger.info(`Removed session: ${sessionId}`); |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * Updates the `last_message_created_at` and `updated_at` timestamps for a session. |
no test coverage detected