import type { DatabaseSync } from "node:sqlite";
import { type FSWatcher } from "chokidar";
import type { ResolvedMemorySearchConfig } from "../agents/memory-search.js";
import type { SymiConfig } from "../config/config.js";
import { type EmbeddingProvider, type GeminiEmbeddingClient, type OpenAiEmbeddingClient, type VoyageEmbeddingClient } from "./embeddings.js";
import { MemoryManagerEmbeddingOps } from "./manager-embedding-ops.js";
import type { MemoryEmbeddingProbeResult, MemoryPinResult, MemoryProviderStatus, MemorySearchManager, MemorySearchResult, MemorySource, MemorySyncProgressUpdate } from "./types.js";
export declare class MemoryIndexManager extends MemoryManagerEmbeddingOps implements MemorySearchManager {
    private readonly cacheKey;
    protected readonly cfg: SymiConfig;
    protected readonly agentId: string;
    protected readonly workspaceDir: string;
    protected readonly settings: ResolvedMemorySearchConfig;
    protected provider: EmbeddingProvider | null;
    private readonly requestedProvider;
    protected fallbackFrom?: "openai" | "local" | "gemini" | "voyage" | "ollama";
    protected fallbackReason?: string;
    private readonly providerUnavailableReason?;
    protected openAi?: OpenAiEmbeddingClient;
    protected gemini?: GeminiEmbeddingClient;
    protected voyage?: VoyageEmbeddingClient;
    protected batch: {
        enabled: boolean;
        wait: boolean;
        concurrency: number;
        pollIntervalMs: number;
        timeoutMs: number;
    };
    protected batchFailureCount: number;
    protected batchFailureLastError?: string;
    protected batchFailureLastProvider?: string;
    protected batchFailureLock: Promise<void>;
    protected db: DatabaseSync;
    protected readonly sources: Set<MemorySource>;
    protected providerKey: string;
    protected readonly cache: {
        enabled: boolean;
        maxEntries?: number;
    };
    protected readonly vector: {
        enabled: boolean;
        available: boolean | null;
        extensionPath?: string;
        loadError?: string;
        dims?: number;
    };
    protected readonly fts: {
        enabled: boolean;
        available: boolean;
        loadError?: string;
    };
    protected vectorReady: Promise<boolean> | null;
    protected watcher: FSWatcher | null;
    protected watchTimer: NodeJS.Timeout | null;
    protected sessionWatchTimer: NodeJS.Timeout | null;
    protected sessionUnsubscribe: (() => void) | null;
    protected intervalTimer: NodeJS.Timeout | null;
    protected closed: boolean;
    protected dirty: boolean;
    protected sessionsDirty: boolean;
    protected sessionsDirtyFiles: Set<string>;
    protected sessionPendingFiles: Set<string>;
    protected sessionDeltas: Map<string, {
        lastSize: number;
        pendingBytes: number;
        pendingMessages: number;
    }>;
    private sessionWarm;
    private syncing;
    static get(params: {
        cfg: SymiConfig;
        agentId: string;
        purpose?: "default" | "status";
    }): Promise<MemoryIndexManager | null>;
    private constructor();
    warmSession(sessionKey?: string): Promise<void>;
    search(query: string, opts?: {
        maxResults?: number;
        minScore?: number;
        sessionKey?: string;
    }): Promise<MemorySearchResult[]>;
    private incrementChunkWeights;
    private searchVector;
    private buildFtsQuery;
    private searchKeyword;
    private mergeHybridResults;
    sync(params?: {
        reason?: string;
        force?: boolean;
        progress?: (update: MemorySyncProgressUpdate) => void;
    }): Promise<void>;
    readFile(params: {
        relPath: string;
        from?: number;
        lines?: number;
    }): Promise<{
        text: string;
        path: string;
    }>;
    status(): MemoryProviderStatus;
    probeVectorAvailability(): Promise<boolean>;
    probeEmbeddingAvailability(): Promise<MemoryEmbeddingProbeResult>;
    /**
     * Pin the top search match for `query`, flipping its `pinned` column.
     * Pinned chunks are exempt from L3 decay + pruning and get a promotion
     * boost in the next consolidate cycle. Safe to call repeatedly on the
     * same query (idempotent).
     */
    pin(params: {
        query: string;
        minScore?: number;
    }): Promise<MemoryPinResult>;
    /** Inverse of `pin()`. Top match gets `pinned = 0`. */
    unpin(params: {
        query: string;
        minScore?: number;
    }): Promise<MemoryPinResult>;
    private setPinned;
    /**
     * Run the L3 long-term-memory cycle (decay → reinforce → propagate →
     * synthesize → promote → prune) against this manager's database.
     *
     * Guarded by a min-interval so rapid successive calls (multiple
     * post-flush triggers in quick succession) don't stack. Builds its
     * own synthesizer from this manager's cfg/agent context, so callers
     * don't need to know about runAgentTurn plumbing. Pass `force: true`
     * to bypass the min-interval guard (CLI use).
     */
    runL3CycleIfDue(params?: {
        minIntervalMs?: number;
        force?: boolean;
    }): Promise<import("./types.js").L3CycleResult>;
    close(): Promise<void>;
}
