/**
 * SessionDB — SQLite + FTS5 unified session index for pie-lab.
 *
 * Covers three JSONL sources:
 *   - TUI sessions:              ~/.pie/agent/sessions/<cwd>/*.jsonl
 *   - Gateway reasoning sessions:~/.pie/agent/gateway/sessions/<key>/*.jsonl
 *   - Gateway chat transcripts:  ~/.pie/agent/chat/accounts/ACCOUNT/channels/CHANNEL/channel.jsonl
 *
 * Uses node:sqlite (Node 22+, experimental) with FTS5 trigram tokenizer for
 * Korean / CJK substring search.
 *
 * All DB writes are synchronous (DatabaseSync); reads are async-friendly via
 * wrappers that call into the sync API.
 */
type SessionSource = "tui" | "gateway-reasoning" | "gateway-chat";
export interface SessionSearchHit {
    sessionId: string;
    source: SessionSource;
    service?: string;
    channelKey?: string;
    name?: string;
    createdAt?: string;
    modifiedAt?: string;
    /** FTS5-highlighted snippet around the match. */
    snippet: string;
    /** First few messages for context (goal/kickoff). */
    bookendStart: string[];
    /** Last few messages for context (resolution). */
    bookendEnd: string[];
    /** Messages ±window around the matching entry. */
    window: Array<{
        role: string;
        speaker: string;
        text: string;
        timestamp: string;
    }>;
}
export interface SessionBrowseItem {
    sessionId: string;
    source: SessionSource;
    service?: string;
    channelKey?: string;
    name?: string;
    createdAt?: string;
    modifiedAt?: string;
    messageCount: number;
    preview: string;
}
export declare class SessionDB {
    private readonly db;
    private readonly agentDir;
    constructor(dbPath?: string, agentDir?: string);
    close(): void;
    /** Incrementally re-index all three JSONL sources. Returns stats. */
    ingest(): {
        indexed: number;
        skipped: number;
        errors: number;
    };
    private discoverTuiFiles;
    private discoverGatewayReasoningFiles;
    private discoverGatewayChatFiles;
    private indexFile;
    private indexAgentSessionFile;
    private indexChatTranscriptFile;
    /** Full-text search across all indexed sessions. */
    search(query: string, options?: {
        limit?: number;
        sources?: SessionSource[];
    }): SessionSearchHit[];
    /** Browse recent sessions without a query. */
    browse(options?: {
        limit?: number;
        sources?: SessionSource[];
    }): SessionBrowseItem[];
    /** Get a ±window slice of messages around the first FTS hit in a session. */
    private getWindowAroundMatch;
    private getSessionMessages;
    private upsertSession;
    private getSessionRowid;
}
export declare function getSessionDB(agentDir?: string): SessionDB;
/** Ensure the DB directory exists and run incremental ingest in the background. */
export declare function ensureSessionDBIndexed(agentDir?: string): Promise<void>;
export {};
//# sourceMappingURL=session-db.d.ts.map