import { QmdSearchResult, QmdSearchExplain } from './types.js';
import { S as SearchBackend, a as SearchQueryOptions, b as SearchExecutionOptions } from './port-B6VEDIkC.js';
import './index-1qIcnbG1.js';

interface QmdClientOptions {
    slowLog?: {
        enabled: boolean;
        thresholdMs: number;
    };
    updateTimeoutMs?: number;
    updateMinIntervalMs?: number;
    qmdPath?: string;
    daemonUrl?: string;
    daemonRecheckIntervalMs?: number;
}
declare function parseQmdExplain(value: unknown): QmdSearchExplain | undefined;
declare class QmdClient implements SearchBackend {
    private readonly collection;
    private readonly maxResults;
    private available;
    private _lastUpdateFailAtMs;
    private lastEmbedFailAtMs;
    private lastUpdateRunAtMs;
    get lastUpdateFailedAtMs(): number | null;
    get lastUpdateRanAtMs(): number | null;
    resetUpdateThrottles(): void;
    private readonly updateTimeoutMs;
    private readonly updateMinIntervalMs;
    private readonly slowLog?;
    private readonly configuredQmdPath?;
    private qmdPathSource;
    private cliVersion;
    private lastCliProbeError;
    private daemonSession;
    private daemonAvailable;
    private daemonSessionPath;
    private lastDaemonCheckAtMs;
    private readonly daemonEnabled;
    private readonly daemonRecheckIntervalMs;
    /** Consecutive transient daemon failures before invalidating the session. */
    private daemonTransientFailures;
    private static readonly DAEMON_MAX_TRANSIENT_FAILURES;
    constructor(collection: string, maxResults: number, opts?: QmdClientOptions);
    private qmdPath;
    probe(): Promise<boolean>;
    private probeDaemon;
    private probeCli;
    private logCliProbeWarning;
    /** Re-probe daemon if it was down and recheck interval has elapsed. */
    private maybeProbeDaemon;
    isAvailable(): boolean;
    /** Debug string for troubleshooting availability issues. */
    debugStatus(): string;
    isDaemonMode(): boolean;
    dispose(): void;
    /**
     * Record a daemon search success — resets the transient failure counter.
     */
    private recordDaemonSuccess;
    /**
     * Handle a non-timeout, non-cancellation daemon error.
     * Tolerates up to DAEMON_MAX_TRANSIENT_FAILURES consecutive failures
     * before invalidating the session. This prevents a single transient
     * error from pushing all concurrent searches through the subprocess
     * mutex for the full recheck interval.
     */
    private handleDaemonTransientError;
    private runQmdCommand;
    private supportsIntentHints;
    private supportsExplainTraces;
    /**
     * QMD v2 (>= 2.0.0) uses a new MCP tool API:
     * - `search` and `vsearch` tools removed; only `query` tool exists
     * - `query` accepts `{ searches: [{ type, query }], collections?: string[] }`
     *   instead of `{ query: string, collection?: string }`
     * - `collection` (singular) → `collections` (plural array)
     */
    private isQmdV2;
    private resolveSearchOptions;
    resolveSupportedSearchOptions(options?: SearchQueryOptions): SearchQueryOptions | undefined;
    search(query: string, collection?: string, maxResults?: number, options?: SearchQueryOptions, execution?: SearchExecutionOptions): Promise<QmdSearchResult[]>;
    searchGlobal(query: string, maxResults?: number, execution?: SearchExecutionOptions): Promise<QmdSearchResult[]>;
    /**
     * BM25 keyword search (fast, ~0.3s). Uses `qmd search`.
     */
    bm25Search(query: string, collection?: string, maxResults?: number, execution?: SearchExecutionOptions): Promise<QmdSearchResult[]>;
    /**
     * Vector similarity search (~3-4s). Uses `qmd vsearch`.
     */
    vectorSearch(query: string, collection?: string, maxResults?: number, execution?: SearchExecutionOptions): Promise<QmdSearchResult[]>;
    /**
     * Hybrid search: runs BM25 + vector in parallel, merges/dedupes by path
     * keeping the best score and first non-empty snippet.
     */
    hybridSearch(query: string, collection?: string, maxResults?: number, execution?: SearchExecutionOptions): Promise<QmdSearchResult[]>;
    private searchViaDaemon;
    private bm25SearchViaDaemon;
    private vsearchViaDaemon;
    private searchViaSubprocess;
    private bm25SearchViaSubprocess;
    private vsearchViaSubprocess;
    private searchGlobalViaSubprocess;
    update(execution?: SearchExecutionOptions): Promise<void>;
    updateCollection(collection: string, execution?: SearchExecutionOptions): Promise<void>;
    updateCollectionStrict(collection: string, execution?: SearchExecutionOptions): Promise<void>;
    updatesAllCollections(): boolean;
    private runUpdateForCollection;
    embed(): Promise<void>;
    embedCollection(collection: string): Promise<void>;
    ensureCollection(memoryDir: string): Promise<"present" | "missing" | "unknown" | "skipped">;
}

export { QmdClient, type QmdClientOptions, parseQmdExplain };
