import type { SessionId } from '../../types/ids/index.js'; import type { ChildSessionSummary, EvidenceHit, EvidenceSearchOptions, IndexedBatch, IndexedPendingDecision, IndexedSession, IndexedTurn, ListSessionsOptions } from './index.js'; import { type IndexSink, SessionIndexBase, type SessionRow } from './rebuild.js'; import type { ExternalRefKind, ExternalRefTarget } from './refs.js'; /** `PRAGMA user_version` of an index this module writes. Any other version is rebuilt, never migrated. */ export declare const SESSION_INDEX_VERSION = 1; /** Whether `node:sqlite` loads in this process, so {@link SqliteSessionIndex} can run. */ export declare function sqliteAvailable(): boolean; /** * How long a temporary file must go unmodified before a sweep may call it * abandoned. A live rebuild commits once per session log, so its file (or * its journal) is touched far more often than this. */ export declare const ABANDONED_REBUILD_AFTER_MS: number; export interface SqliteSessionIndexOptions { /** The index file, normally `$NAMZU_HOME/index.sqlite`. */ readonly path: string; /** The home whose logs the index describes. */ readonly home: string; } export interface RebuildSqliteSessionIndexOptions extends SqliteSessionIndexOptions { /** * Replace a current index too. Without it, a rebuild that finds a current * index already in place (another process finished first) discards its own. */ readonly force?: boolean; } /** * Build the index from every log under `home` into a temporary file beside * it (`index.sqlite.tmp--`), then rename that file over the * index. A reader therefore sees the old index or the complete new one, * never a partial one. When two processes rebuild at once both finish and * one complete index remains: a process that finds a current index already * renamed into place discards its temporary file. A temporary file left by * a process that died mid-rebuild is removed by a later rebuild or open, once * it has gone unmodified for {@link ABANDONED_REBUILD_AFTER_MS}. * * Returns whether this call's file became the index. */ export declare function rebuildSqliteSessionIndex(options: RebuildSqliteSessionIndexOptions): Promise; /** * The index in SQLite. Every write runs under `BEGIN IMMEDIATE`, so two * processes updating one index serialise; the rows are derived from the logs * alone, so the order they serialise in does not change the result. */ export declare class SqliteSessionIndex extends SessionIndexBase { #private; readonly backend: "sqlite"; /** Wraps an open database whose schema is current. Use {@link SqliteSessionIndex.open}. */ private constructor(); /** See {@link rebuildSqliteSessionIndex}. */ static rebuild(options: RebuildSqliteSessionIndexOptions): Promise; /** * Open the index at `path` for the logs under `home`. A missing index, or * one at another `user_version` (or not a database at all), is rebuilt, * never migrated; a current one is brought up to date with the logs. */ static open(options: SqliteSessionIndexOptions): Promise; protected transaction(work: (sink: IndexSink) => T): T; protected readSession(sessionId: SessionId): SessionRow | undefined; protected indexedSessionIds(): SessionId[]; listSessions(options?: ListSessionsOptions): Promise; listTurns(sessionId: SessionId): Promise; listChildren(sessionId: SessionId): Promise; listPendingDecisions(options?: { sessionId?: SessionId; }): Promise; resolveExternal(protocol: string, kind: ExternalRefKind, externalId: string): Promise; listExternalRefs(sessionId: SessionId): Promise; batches(options?: { sessionId?: SessionId; }): Promise; searchEvidence(options: EvidenceSearchOptions): Promise; close(): void; } //# sourceMappingURL=sqlite.d.ts.map