/**
 * Session Manager — groups web UI entity edits into edit sessions for clean git history.
 *
 * Each session is scoped to a (user, repo) pair. Edits extend the session's
 * idle timer. When a session goes idle for SESSION_IDLE_MS, a single commit
 * is made covering all entities touched during that session, and a
 * `session_commit` WebSocket event is broadcast.
 *
 * Persistence: the dirty set is mirrored to
 * `<workspace>/.studiograph/pending-commits.json` on every markDirty/flush.
 * On boot, recoverOnBoot() reads that file AND scans every repo for
 * uncommitted working-tree changes — anything found is committed under a
 * "system recovery" attribution. This guarantees no edit ever lives only in
 * memory: a crash, OOM, or hard restart leaves the working tree dirty but
 * recoverable on the next boot.
 */
import type { WorkspaceManager } from '../core/workspace-manager.js';
import type { GitUser } from '../services/git.js';
import type { WsHub } from './ws-hub.js';
export declare class SessionManager {
    private sessions;
    private timer;
    private workspaceManager;
    private wsHub;
    private pendingPath;
    constructor(workspaceManager: WorkspaceManager, wsHub?: WsHub);
    /**
     * On boot: load any persisted sessions from the previous process, then
     * walk every repo and commit anything in the working tree that wasn't
     * committed (a crash, OOM, or hard restart left it dirty). Always safe
     * to call — no-ops cleanly when there's nothing to recover.
     */
    recoverOnBoot(): Promise<{
        persistedRepos: number;
        sweptRepos: number;
        totalCommits: number;
    }>;
    /**
     * Record a disk write within a user's session for the given repo.
     * Resets the idle timer and accumulates entity + file path info.
     */
    markDirty(repoName: string, user: GitUser, entityType: string, entityId: string, filePath?: string): void;
    /**
     * Flush all sessions for a repo immediately.
     * Used by the /api/repos/:repo/commit route (CLI compatibility).
     * Returns true if anything was committed.
     */
    flush(repoName: string): Promise<boolean>;
    /**
     * Flush all open sessions (called on server shutdown via shutdown()).
     */
    flushAll(): Promise<void>;
    /**
     * Graceful shutdown — flushes pending sessions then tears down the timer.
     * Safe to call multiple times. Always prefer this over destroy().
     */
    shutdown(): Promise<void>;
    private flushStale;
    private commitSession;
    /**
     * Snapshot of current dirty state, exposed for the health endpoint.
     */
    getDirtySessions(): Array<{
        repo: string;
        user: string;
        entities: string[];
        lastActivityAt: number;
    }>;
    /**
     * Atomically write the current dirty set to disk. Best-effort: a
     * persistence failure logs and returns; it never throws into the request
     * path. The recovery sweep on next boot covers anything that didn't
     * persist.
     */
    private persist;
    private loadPersisted;
    /**
     * Tear down the timer + clear in-memory state. Does NOT commit pending
     * sessions — call shutdown() for graceful exit. Made private to prevent
     * accidental data loss; only flushAll() and shutdown() should reach it.
     */
    private destroy;
}
