/** * Session tracking and cleanup module * * Manages session state, usage statistics, and memory cleanup * to prevent memory leaks in long-running agent instances. */ export interface SessionUsage { prompt: number; completion: number; total: number; } export interface SessionTrackerConfig { /** Max sessions to keep in memory */ maxSessions?: number; /** Session TTL in milliseconds */ sessionTtlMs?: number; /** Cleanup interval in milliseconds */ cleanupIntervalMs?: number; } export declare class SessionTracker { private sessionUsage; private sessionLastActivity; private sessionModels; private cleanupInterval?; private readonly maxSessions; private readonly sessionTtlMs; private readonly cleanupIntervalMs; constructor(config?: SessionTrackerConfig); /** * Start periodic cleanup of inactive sessions */ private startCleanupInterval; /** * Cleanup inactive sessions to prevent memory leak */ private cleanupInactiveSessions; /** * Update last activity timestamp for a session */ touchSession(sessionKey: string): void; /** * Get usage for a session */ getUsage(sessionKey: string): SessionUsage | undefined; /** * Update usage for a session */ updateUsage(sessionKey: string, usage: Partial): void; /** * Set model for a session */ setModel(sessionKey: string, modelId: string): void; /** * Get model for a session */ getModel(sessionKey: string): string | undefined; /** * Get all session keys */ getSessionKeys(): string[]; /** * Get total session count */ getSessionCount(): number; /** * Delete a session */ deleteSession(sessionKey: string): boolean; /** * Dispose resources (call on shutdown) */ dispose(): void; }