import type { DatabaseSync } from "node:sqlite";
import { FSWatcher } from "chokidar";
import { type KaijiBotConfig, type ResolvedMemorySearchConfig } from "kaijibot/plugin-sdk/memory-core-host-engine-foundation";
import { type SessionFileEntry } from "kaijibot/plugin-sdk/memory-core-host-engine-qmd";
import { type MemoryFileEntry, type MemorySource, type MemorySyncProgressUpdate } from "kaijibot/plugin-sdk/memory-core-host-engine-storage";
import { type EmbeddingProvider, type EmbeddingProviderId, type EmbeddingProviderRuntime } from "./embeddings.js";
import { type MemoryIndexMeta } from "./manager-reindex-state.js";
export declare function runDetachedMemorySync(sync: () => Promise<void>, reason: "interval" | "watch"): void;
export declare abstract class MemoryManagerSyncOps {
    protected abstract readonly cfg: KaijiBotConfig;
    protected abstract readonly agentId: string;
    protected abstract readonly workspaceDir: string;
    protected abstract readonly settings: ResolvedMemorySearchConfig;
    protected provider: EmbeddingProvider | null;
    protected fallbackFrom?: EmbeddingProviderId;
    protected providerRuntime?: EmbeddingProviderRuntime;
    protected abstract batch: {
        enabled: boolean;
        wait: boolean;
        concurrency: number;
        pollIntervalMs: number;
        timeoutMs: number;
    };
    protected readonly sources: Set<MemorySource>;
    protected providerKey: string | null;
    protected abstract 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 fallbackReason?: string;
    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 lastMetaSerialized;
    protected abstract readonly cache: {
        enabled: boolean;
        maxEntries?: number;
    };
    protected abstract db: DatabaseSync;
    protected abstract computeProviderKey(): string;
    protected abstract sync(params?: {
        reason?: string;
        force?: boolean;
        forceSessions?: boolean;
        sessionFile?: string;
        progress?: (update: MemorySyncProgressUpdate) => void;
    }): Promise<void>;
    protected abstract withTimeout<T>(promise: Promise<T>, timeoutMs: number, message: string): Promise<T>;
    protected abstract getIndexConcurrency(): number;
    protected abstract pruneEmbeddingCacheIfNeeded(): void;
    protected abstract indexFile(entry: MemoryFileEntry | SessionFileEntry, options: {
        source: MemorySource;
        content?: string;
    }): Promise<void>;
    protected ensureVectorReady(dimensions?: number): Promise<boolean>;
    private loadVectorExtension;
    private ensureVectorTable;
    private dropVectorTable;
    protected buildSourceFilter(alias?: string): {
        sql: string;
        params: MemorySource[];
    };
    protected openDatabase(): DatabaseSync;
    private seedEmbeddingCache;
    protected ensureSchema(): void;
    protected ensureWatcher(): void;
    protected ensureSessionListener(): void;
    private scheduleSessionDirty;
    private processSessionDeltaBatch;
    private updateSessionDelta;
    private countNewlines;
    private resetSessionDelta;
    private isSessionFileForAgent;
    private normalizeTargetSessionFiles;
    protected ensureIntervalSync(): void;
    private scheduleWatchSync;
    private shouldSyncSessions;
    private syncMemoryFiles;
    private syncSessionFiles;
    private createSyncProgress;
    protected runSync(params?: {
        reason?: string;
        force?: boolean;
        sessionFiles?: string[];
        progress?: (update: MemorySyncProgressUpdate) => void;
    }): Promise<void>;
    private shouldFallbackOnError;
    protected resolveBatchConfig(): {
        enabled: boolean;
        wait: boolean;
        concurrency: number;
        pollIntervalMs: number;
        timeoutMs: number;
    };
    private activateFallbackProvider;
    private runSafeReindex;
    private runUnsafeReindex;
    private resetIndex;
    protected readMeta(): MemoryIndexMeta | null;
    protected writeMeta(meta: MemoryIndexMeta): void;
}
