/**
 * `SearchService` — per-project facade over the FlexSearch-backed
 * lexical search stack.
 *
 * Wraps `FlexSearchStore`, `Indexer`, and four core `IndexSource`s
 * behind the same public surface the legacy `SearchIndex` exposed
 * (open/close/rebuildFromStores/indexX/removeX/search) so the rest of
 * the codebase migrates 1:1.
 *
 * State machine (design §10.3):
 *   "initializing" -- open() kicked off, not ready
 *   "ready"        -- FlexSearchStore open
 *   "disabled"     -- store failed to open (rare — dir unwritable)
 *   "closed"       -- close() called
 */
import type { PersistedGoal, GoalStore } from "../agent/goal-store.js";
import type { PersistedSession, SessionStore } from "../agent/session-store.js";
import type { PersistedStaff, StaffStore } from "../agent/staff-store.js";
import type { IndexSource, SearchResults } from "./types.js";
import { FlexSearchStore } from "./flex-store.js";
import { type ProgressBus } from "./progress-bus.js";
export type SearchServiceState = "initializing" | "ready" | "disabled" | "closed";
export interface SearchServiceOptions {
    stateDir: string;
    projectId: string;
    /** Override progress bus (tests). Defaults to the shared singleton. */
    progressBus?: ProgressBus;
    /** Override staff store for rebuilds. Optional — can also be supplied to rebuildFromStores. */
    staffStore?: StaffStore;
}
export declare class SearchService {
    readonly stateDir: string;
    readonly projectId: string;
    readonly dataDir: string;
    private readonly progressBus;
    private _state;
    private _store;
    private _indexer;
    /** Optional staff store for rebuilds. */
    staffStore?: StaffStore;
    private _openPromise;
    private readonly _goalSource;
    private readonly _sessionSource;
    private readonly _messageSource;
    private readonly _staffSource;
    constructor(opts: SearchServiceOptions);
    getState(): SearchServiceState;
    /** Internal access for admin/maintenance REST endpoints. */
    getStore(): FlexSearchStore | null;
    /** Engine identity for stats endpoint. */
    getEngineInfo(): {
        engine: string;
        engineVersion: string;
    };
    getStats(): Promise<{
        state: SearchServiceState;
        engine: string;
        engineVersion: string;
        lastRebuildAt: number | null;
        rowCountsBySource: {
            goals: number;
            sessions: number;
            messages: number;
            staff: number;
            files: number;
        };
        datasetBytes: number;
    }>;
    /** No-op compaction (kept for facade compatibility). */
    compact(): Promise<void>;
    open(context?: {
        goalStore?: GoalStore;
        sessionStore?: SessionStore;
        staffStore?: StaffStore;
    }): void;
    whenReady(): Promise<void>;
    needsRebuild(): boolean;
    close(): Promise<void>;
    indexGoal(goal: PersistedGoal, projectId?: string): void;
    removeGoal(goalId: string): void;
    indexSession(session: PersistedSession, goalTitle?: string, projectId?: string): void;
    removeSession(sessionId: string): void;
    removeMessagesForSession(sessionId: string): void;
    indexMessage(arg: {
        sessionId: string;
        sessionTitle: string;
        message: unknown;
        timestamp: number;
        projectId?: string;
        msgIdx?: number;
        goalId?: string;
    }): void;
    indexMessage(sessionId: string, sessionTitle: string, text: string, toolNames: string[], timestamp: number, projectId?: string): void;
    indexStaff(staff: PersistedStaff, projectId?: string): void;
    removeStaff(staffId: string): void;
    search(query: string, opts?: {
        type?: "all" | "goals" | "sessions" | "messages" | "staff";
        limit?: number;
        offset?: number;
        projectId?: string;
        projectNames?: Map<string, string>;
        includeArchived?: boolean;
    }): SearchResults | Promise<SearchResults>;
    rebuildFromStores(goalStore: GoalStore, sessionStore: SessionStore, _sessionsDir?: string, staffStore?: StaffStore): Promise<void>;
    rebuildFromSources(goalStore: GoalStore, sessionStore: SessionStore, staffStore: StaffStore, sources?: IndexSource[]): Promise<void>;
    private _doOpen;
}
//# sourceMappingURL=search-service.d.ts.map