/** * Per-session index tables in history.db, keyed by session id: * * - `session_titles`: session id → display title, written whenever a title is * created or renamed ({@link SessionManager.setSessionName}) and backfilled by * the recent-session fallback scan and the resume picker's full scan. Lets the * welcome "Recent sessions" list resolve names from a stat + lookup, and the * resume picker show its rows before reading any session file, instead of * content-scanning every session file in the project directory (seconds on * dirs with thousands of sessions). A title has no life beyond its session; * `omp gc` drops rows of archived sessions. * - `session_recaps`: append-only journal of idle recaps * ({@link SessionManager.recordRecap}). Recaps are side-channel output that * never enters the session JSONL or LLM context; this table is their only * durable record. `omp gc` drops rows of archived sessions. * * Holds its own lazily-opened connection instead of {@link HistoryStorage}'s * path-pinned singleton: the db path is re-resolved on every call so * `setAgentDir`/profile switches (and test isolation) transparently reopen * against the right file. Never versions the db — `PRAGMA user_version` is * owned by HistoryStorage's rebuild pass, which drops only its own tables. */ import { Database } from "bun:sqlite"; /** * Record (or replace) the indexed title for a session id. Best-effort: index * failures must never break a rename, so errors are logged and swallowed. */ export declare function recordSessionTitle(sessionId: string, title: string): void; /** * Record (or replace) many indexed titles in one transaction, so a picker * scan backfilling thousands of sessions pays one commit instead of one per * row. Best-effort like {@link recordSessionTitle}. */ export declare function recordSessionTitles(titles: ReadonlyMap): void; /** * Every indexed title by session id, in one query: the resume picker * pre-populates its rows from it before any session file is read. Empty when * the index is unavailable or unreadable. */ export declare function listSessionTitles(): Map; /** Indexed title for a session id, or undefined when unindexed/unavailable. */ export declare function lookupSessionTitle(sessionId: string): string | undefined; /** * Append an idle recap to the session's recap journal. Best-effort: a journal * failure must never disturb the recap display, so errors are logged and swallowed. */ export declare function recordSessionRecap(sessionId: string, cwd: string, recap: string): void; /** One journaled idle recap. */ export interface SessionRecap { sessionId: string; /** Working directory of the session that produced the recap. */ cwd: string; recap: string; /** Unix seconds. */ createdAt: number; } /** Narrows {@link listSessionRecaps}; omitted fields match everything. */ export interface SessionRecapQuery { /** Recaps of these sessions only; empty matches nothing. */ sessionIds?: readonly string[]; /** Recaps produced in this exact working directory. */ cwd?: string; /** Maximum rows returned. */ limit?: number; } /** * Journaled recaps matching `query`, newest first. Best-effort like the * writers: an unavailable index or failed read yields an empty list. */ export declare function listSessionRecaps(query?: SessionRecapQuery): SessionRecap[]; /** Closes the cached connection; the next call reopens it. History recovery closes it so Windows can replace history.db. */ export declare function closeSessionIndex(): void; /** * Copies the readable titles and recaps of a quarantined history.db into the * replacement `target`. Runs once per quarantined store, so recaps append * as-is; a title already rewritten in the replacement keeps the newer value. */ export declare function salvageSessionIndex(source: Database, target: Database): { titles: number; recaps: number; };