import type { CodebaseIndex } from './types.js';
export type TreeSitterModule = typeof import('web-tree-sitter');
export type TreeSitterLanguage = import('web-tree-sitter').Language;
export type TreeSitterQuery = import('web-tree-sitter').Query;
export type TreeSitterQueryOptions = import('web-tree-sitter').QueryOptions;
export type TreeSitterNode = import('web-tree-sitter').Node;
export type TreeSitterTree = import('web-tree-sitter').Tree;
export interface TreeSitterErrorNode {
    type: string;
    text: string;
    line: number;
    column: number;
}
export interface CollectTreeSitterErrorOptions {
    signal?: AbortSignal;
    /** Maximum nodes inspected while looking for parser recovery. */
    maxNodes?: number;
    /** Maximum diagnostics copied out of the WASM tree. */
    maxDiagnostics?: number;
}
export interface TreeSitterTagCapture {
    name: string;
    node: TreeSitterNode;
}
export type TreeSitterParser = import('web-tree-sitter').Parser;
export interface TreeSitterQueryLease {
    query: TreeSitterQuery;
    release(): void;
}
export interface TreeSitterParseCacheOptions {
    maxEntries?: number;
    maxSourceBytes?: number;
}
export interface TreeSitterParseCacheStats {
    entries: number;
    sourceBytes: number;
    evictions: number;
    treesDeleted: number;
}
export interface TreeSitterParseTreeLease {
    tree: TreeSitterTree;
    release(): void;
}
export interface TreeSitterParseCacheScope {
    acquire(grammar: string, content: string, signal?: AbortSignal): Promise<TreeSitterParseTreeLease | null>;
    /** Transfer an already-parsed tree into this invocation's bounded cache. */
    adopt(grammar: string, content: string, tree: TreeSitterTree): Promise<TreeSitterParseTreeLease>;
    stats(): TreeSitterParseCacheStats;
    close(): void;
}
/**
 * Open one invocation-scoped parse-tree cache for a CodebaseIndex.
 *
 * Concurrent scopes on the same index share trees and borrower counts. The
 * last scope to close evicts every entry, so a resident index does not retain
 * WASM trees across commands. Eviction is lease-aware: `tree.delete()` is
 * deferred until no borrower can still observe that tree.
 */
export declare function openTreeSitterParseCache(index: CodebaseIndex, options?: TreeSitterParseCacheOptions): TreeSitterParseCacheScope;
/**
 * Complete web-tree-sitter's one-time runtime initialization.
 *
 * Exposed for co-resident consumers of the same module instance (the ast-grep
 * engine): sequencing their init after this one avoids racing the Emscripten
 * module bring-up, which web-tree-sitter caches but does not lock.
 */
export declare function initializeTreeSitterRuntime(): Promise<void>;
export declare function resolveTreeSitterAsset(grammar: string, fileName: string): string | null;
export declare function loadTreeSitterLanguage(grammar: string): Promise<TreeSitterLanguage | null>;
/**
 * Borrow one compiled caller-supplied query from a bounded LRU.
 *
 * Query text is unbounded user input, so the cache is deliberately capped.
 * Eviction explicitly deletes the WASM handle once the last borrower releases
 * it; an in-flight query is never deleted underneath its caller.
 */
export declare function acquireTreeSitterQuery(grammar: string, source: string): Promise<TreeSitterQueryLease | null>;
/** @internal Observable only so the bounded/disposal contract can be regression-tested. */
export declare function treeSitterQueryCacheSize(): number;
export declare function parseTreeSitterContent(grammar: string, content: string, signal?: AbortSignal): Promise<TreeSitterTree | null>;
export declare function collectTreeSitterTagCaptures(grammar: string, root: TreeSitterNode): Promise<TreeSitterTagCapture[] | null>;
export declare function collectTreeSitterErrorNodes(root: TreeSitterNode, options?: CollectTreeSitterErrorOptions): TreeSitterErrorNode[];
