cui-server
Version:
Web UI Agent Platform based on Claude Code
84 lines • 2.75 kB
TypeScript
import type { SessionInfo } from '../types/index.js';
/**
* SessionInfoService manages session information using custom JSON file manager
* Stores session metadata including custom names in ~/.cui/session-info.json
* Provides fast lookups and updates for session-specific data with race condition protection
*/
export declare class SessionInfoService {
private static instance;
private jsonManager;
private logger;
private dbPath;
private configDir;
private isInitialized;
constructor(customConfigDir?: string);
static getInstance(): SessionInfoService;
static resetInstance(): void;
/**
* Initialize file paths and JsonFileManager
* Separated to allow re-initialization during testing
*/
private initializePaths;
/**
* Initialize the database
* Creates database file if it doesn't exist
* Throws error if initialization fails
*/
initialize(): Promise<void>;
/**
* Get session information for a given session ID
* Creates entry with default values if session doesn't exist
*/
getSessionInfo(sessionId: string): Promise<SessionInfo>;
/**
* Update session information
* Creates session entry if it doesn't exist
* Supports partial updates - only provided fields will be updated
*/
updateSessionInfo(sessionId: string, updates: Partial<SessionInfo>): Promise<SessionInfo>;
/**
* Update custom name for a session (backward compatibility)
* @deprecated Use updateSessionInfo instead
*/
updateCustomName(sessionId: string, customName: string): Promise<void>;
/**
* Delete session information
*/
deleteSession(sessionId: string): Promise<void>;
/**
* Get all session information
* Returns mapping of sessionId -> SessionInfo
*/
getAllSessionInfo(): Promise<Record<string, SessionInfo>>;
/**
* Get database statistics
*/
getStats(): Promise<{
sessionCount: number;
dbSize: number;
lastUpdated: string;
}>;
/**
* Ensure metadata exists and is current
*/
private ensureMetadata;
/**
* Re-initialize paths and JsonFileManager (for testing)
* Call this after mocking os.homedir() to use test paths
*/
reinitializePaths(customConfigDir?: string): void;
/**
* Get current database path (for testing)
*/
getDbPath(): string;
/**
* Get current config directory path (for testing)
*/
getConfigDir(): string;
/**
* Archive all sessions that aren't already archived
* Returns the number of sessions that were archived
*/
archiveAllSessions(): Promise<number>;
}
//# sourceMappingURL=session-info-service.d.ts.map