/** * Active Sessions Registry (GIT-19) * * CRUD operations for .gitmem/active-sessions.json — the multi-session * registry that tracks all running MCP server sessions. * * Key design decisions: * - Atomic writes (write-temp-rename) because multiple processes may * register/unregister concurrently. * - Sync I/O to match codebase convention (fs.writeFileSync etc). * - Graceful degradation: corrupted registry = start fresh. */ import type { ActiveSessionEntry } from "../types/index.js"; /** * Register a new session in the active-sessions registry. * Idempotent: re-registering the same session_id replaces the entry. * Returns session IDs that were displaced (different session_id, same hostname+pid). */ export declare function registerSession(entry: ActiveSessionEntry): string[]; /** * Unregister a session from the active-sessions registry. * Returns true if the session was found and removed. */ export declare function unregisterSession(sessionId: string): boolean; /** * List all active sessions from the registry. */ export declare function listActiveSessions(): ActiveSessionEntry[]; /** * Find a session by hostname and PID. * Used by session_start to detect if this process already has a registered session. */ export declare function findSessionByHostPid(hostname: string, pid: number): ActiveSessionEntry | null; /** * Find a session by session_id. */ export declare function findSessionById(sessionId: string): ActiveSessionEntry | null; /** * Prune stale sessions from the registry (GIT-22 enhanced). * * A session is stale if: * 1. Its started_at is older than 24 hours, OR * 2. Its PID no longer exists on this hostname (process died without cleanup), OR * 3. Its per-session directory/session.json is missing (orphaned registry entry) * * Also cleans up per-session directories for pruned sessions, * and removes orphaned session directories with no registry entry. * Returns the number of sessions pruned. */ export declare function pruneStale(): number; /** * GIT-23: Migrate from old active-session.json (singular) to new multi-session format. * * Runs once per process. If old file exists and new registry does not: * 1. Read old file * 2. Create per-session directory with session.json * 3. Create active-sessions.json registry with single entry * 4. Rename old file to active-session.json.migrated (backup) * * Idempotent: skips if new registry already exists or old file is absent. */ export declare function migrateFromLegacy(): boolean; /** * Reset migration flag (for testing only). */ export declare function resetMigrationFlag(): void; //# sourceMappingURL=active-sessions.d.ts.map