import { type BudgetExceededBehavior } from './build.js';
import { type CodeQuerySession } from './session.js';
import type { CodeChunk, CodeChunkOptions } from './chunk.js';
import type { CodebaseIndex, ContentMode, TypeScriptCheckerMode } from './types.js';
import type { TokenizerName } from '../tokens.js';
import type { OnProgress } from '../progress-event.js';
import { type CooperativeOption } from '../utils.js';
export { createFileTokenCountCache, type FileTokenCountCache, type FileTokenCountCacheOptions, type FileTokenCountRow, } from './token-count-cache.js';
export { resolveCodeIndexCacheDir } from './cache-paths.js';
export type StoreStrategy = 'prefer-cache' | 'ensure-fresh' | 'rebuild';
export interface CodeIndexStoreOptions {
    repoRoot: string;
    cacheDir: string;
    excludeDir?: string[];
    noGitignore?: boolean;
    ignorePatterns?: string[];
    overlayIgnorePatterns?: string[];
    contentMode?: ContentMode;
    maxFileSizeBytes?: number;
    maxLines?: number;
    skipMinified?: boolean;
    maxFiles?: number;
    maxBytes?: number;
    onBudgetExceeded?: BudgetExceededBehavior;
    parseConcurrency?: number;
    /** TypeScript semantic-resolution policy. Defaults to `preferred`. */
    typescriptChecker?: TypeScriptCheckerMode;
}
export interface StoreSessionOptions {
    strategy?: StoreStrategy;
    signal?: AbortSignal;
    onProgress?: OnProgress;
    cooperative?: CooperativeOption;
}
export interface StoreChunkIsolatedOptions extends Omit<CodeChunkOptions, 'countTokens'> {
    strategy?: StoreStrategy;
    signal?: AbortSignal;
    onProgress?: OnProgress;
    cooperative?: CooperativeOption;
    tokenizer?: TokenizerName;
}
type StoreOperationOptions = Omit<StoreSessionOptions, 'strategy'>;
export interface StoreMetadata {
    schemaVersion: number;
    occVersion: string;
    repoRoot: string;
    builtAt: string;
    fileCount: number;
    nodeCount: number;
    edgeCount: number;
    loadSource: 'cache' | 'build';
    /** How the most recent build was produced. Absent when loaded from cache. */
    updateKind?: 'full' | 'incremental';
    buildOptionFingerprint: string;
    contentMode: ContentMode;
}
export interface CodeIndexStore {
    getSession(options?: StoreSessionOptions): Promise<CodeQuerySession>;
    refresh(options?: StoreOperationOptions): Promise<CodeQuerySession>;
    /**
     * Incrementally reconcile the index with the working tree.
     *
     * Freshness is a stat heuristic: a cached file counts as unchanged when its
     * size and mtimeMs both match the manifest, so a content change that
     * preserves byte length within the filesystem's mtime granularity is missed
     * by the no-argument diff. Files explicitly listed in `changedFiles` are
     * always re-parsed regardless of the heuristic; refresh() is the
     * force-full-rebuild escape hatch when neither applies.
     */
    update(changedFiles?: string[], options?: StoreOperationOptions): Promise<CodeQuerySession>;
    exportIndex(options?: StoreSessionOptions): Promise<CodebaseIndex>;
    chunkIsolated(options?: StoreChunkIsolatedOptions): Promise<CodeChunk[]>;
    /**
     * Synchronously drops the in-memory session, metadata, and manifest. Does
     * not serialize against or interrupt in-flight operations — a concurrent
     * update/getSession keeps running and repopulates the state (and the
     * on-disk cache) when it settles. Use clearCache() to also remove the
     * on-disk cache with mutual exclusion against in-flight operations.
     */
    dispose(): void;
    clearCache(): Promise<void>;
    clear(): Promise<void>;
    getMetadata(): StoreMetadata | null;
    /**
     * Store metadata without deserializing the index: the in-memory state when
     * present, otherwise the on-disk cache entry. Resolves null when neither
     * exists or the on-disk entry belongs to different options, another repo,
     * or another occ version. Unlike getMetadata(), this is populated before
     * the first getSession() of a process when a persisted cache exists.
     */
    peekMetadata(): Promise<StoreMetadata | null>;
    /**
     * Manifest-only freshness probe: stat-diffs the working tree against the
     * persisted manifest without parsing or loading the index. Resolves null
     * when no usable manifest exists yet. Runs outside the store's operation
     * mutex so it stays cheap next to an in-flight build.
     */
    isFresh(options?: {
        signal?: AbortSignal;
    }): Promise<StoreFreshness | null>;
}
export interface StoreFreshness {
    fresh: boolean;
    added: number;
    modified: number;
    deleted: number;
}
export declare function buildOptionFingerprint(opts: CodeIndexStoreOptions): Promise<string>;
export declare function openCodeIndexStore(options: CodeIndexStoreOptions): CodeIndexStore;
export declare function openChunkCodeIndexStore(options: CodeIndexStoreOptions): CodeIndexStore;
export declare const openChunkStore: typeof openChunkCodeIndexStore;
