export declare const REGISTRY_FILE: string; export interface Session { name: string; sessionId: string; projectId: string; channel: string; backend: string; kind: 'local' | 'scheduled'; createdAt: string; lastUsedAt: string; label: string | null; /** Profile name active when the session was created. Restored on !resume. */ profileName: string | null; } export type SessionRegistryData = Record; export declare class SessionRegistryRepo { private readonly _repo; /** name → sessionId index keeping lookupSession O(1). */ private _nameIndex; /** True once the name index has been fully rebuilt from the complete registry data. * Guards against the index being treated as authoritative when it only holds entries * added incrementally by registerSession() before any full build (which would make * lookupSession() miss every session created in a previous process lifetime). */ private _indexBuilt; /** Optional callback invoked when a session is pruned. Receives the sessionId. */ private _onPruneSession; constructor(filePath?: string); private _rebuildNameIndex; /** Read registry data, performing a one-time full rebuild of the name index. * Must NOT gate on _nameIndex.size: registerSession() populates the index * incrementally, so a non-empty-but-incomplete index would otherwise never be * fully rebuilt and lookups for pre-existing sessions would silently miss. */ private _readWithIndex; /** Rebuild the name index from the current cached data (zero I/O on cache hit). */ private _syncIndex; generateSessionName(): Promise; registerSession(name: string, opts: { sessionId: string; channel: string; backend: string; kind: 'local' | 'scheduled'; projectId?: string; label?: string | null; profileName?: string | null; }): Promise; updateSession(name: string, updates: Partial>): Promise; lookupSession(name: string): Promise; lookupBySessionId(sessionId: string): Promise; listRecentSessions(limit?: number): Promise; /** Return a session by sessionId, or null if not found. O(1) key lookup. */ getById(sessionId: string): Promise; /** List sessions belonging to a project, most recently used first. */ listByProject(projectId: string): Promise; /** List resumable (non-scheduled) sessions, optionally filtered by projectId. */ listResumable(projectId?: string): Promise; /** Touch the lastUsedAt timestamp of a session to now. No-op if sessionId not found. */ markUsed(sessionId: string): Promise; /** * Remove sessions whose lastUsedAt is older than maxAgeMs from now, * and are not referenced by any executionRepo or threadStore record. * Invokes the onPruneSession callback (if set) for each removed session. * Returns the number of removed sessions. */ pruneStale(maxAgeMs: number): Promise; /** Set a callback to invoke when a session is pruned (e.g. cleanup backup files). */ setOnPruneSession(fn: ((sessionId: string) => void) | null): void; getActiveSessionName(channel: string, backend: string): Promise; /** Drop the in-memory cache so the next read() fetches from disk. Test hook. */ invalidate(): void; /** Wait for any in-flight mutate() to complete. For graceful SIGTERM drain. */ flush(): Promise; } export declare const sessionStore: SessionRegistryRepo; /** @deprecated Use `sessionStore` instead. Alias for backward compatibility. */ export declare const sessionRegistryRepo: SessionRegistryRepo;