(agentId: string)
| 367 | } |
| 368 | |
| 369 | public async endSession(agentId: string): Promise<void> { |
| 370 | const sessionId = this.currentSessions.get(agentId); |
| 371 | if (sessionId) { |
| 372 | // Save current session to persistent storage |
| 373 | await this.saveSessionToIndexedDB(agentId, sessionId); |
| 374 | |
| 375 | // Clean up current session data |
| 376 | this.currentSessions.delete(agentId); |
| 377 | this.sessionIterationCounts.delete(sessionId); |
| 378 | |
| 379 | // Remove iterations from memory (they're now persisted) |
| 380 | const iterationsToRemove = Array.from(this.iterations.values()) |
| 381 | .filter(iteration => iteration.sessionId === sessionId); |
| 382 | |
| 383 | iterationsToRemove.forEach(iteration => { |
| 384 | this.iterations.delete(iteration.id); |
| 385 | }); |
| 386 | |
| 387 | await this.saveToIndexedDB(); |
| 388 | |
| 389 | Logger.info('IterationStore', `Ended session ${sessionId} for agent ${agentId}`); |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | public getIterationsForAgent(agentId: string): IterationData[] { |
| 394 | // Only return current session iterations (from memory) |
no test coverage detected