@vfarcic/dot-ai
Version:
AI-powered development productivity platform that enhances software development workflows through intelligent automation and AI-driven assistance
72 lines • 2.12 kB
TypeScript
/**
* Generic Session Manager
*
* Reusable file-based session management for MCP tools
* Provides CRUD operations with persistent storage
*
* Usage:
* const manager = new GenericSessionManager<MySessionData>('myprefix', args);
* const session = manager.createSession({ myData: 'value' });
*/
/**
* Generic session structure
* T is the type of data stored in the session
*/
export interface GenericSession<T = unknown> {
sessionId: string;
createdAt: string;
updatedAt: string;
data: T;
}
/**
* Generic session manager with file-based storage
*/
export declare class GenericSessionManager<T = unknown> {
private prefix;
private sessionDir;
private sessionsPath;
/**
* Create a new session manager
* @param prefix - Prefix for session IDs and directory (e.g., 'proj', 'pattern', 'test')
*/
constructor(prefix: string);
/**
* Create a new session
* Pattern: {prefix}-{timestamp}-{uuid}
*/
createSession(initialData?: T): GenericSession<T>;
/**
* Get an existing session
*/
getSession(sessionId: string): GenericSession<T> | null;
/**
* Update session data (merges with existing data)
*/
updateSession(sessionId: string, newData: Partial<T>): GenericSession<T> | null;
/**
* Replace session data entirely
*/
replaceSession(sessionId: string, newData: T): GenericSession<T> | null;
/**
* Delete a session
*/
deleteSession(sessionId: string): boolean;
/**
* List all sessions (returns session IDs)
*/
listSessions(): string[];
/**
* Clear all sessions (useful for testing)
*/
clearAllSessions(): void;
/**
* Save session to file
*
* Note: Uses a custom replacer to convert undefined values to null.
* This is critical because JSON.stringify drops undefined values entirely,
* which would cause data loss in toolCallsExecuted arrays where tool
* outputs may have undefined fields. (PRD #320 Milestone 2.5)
*/
private saveSession;
}
//# sourceMappingURL=generic-session-manager.d.ts.map