import { type TreeSitterTree } from './tree-sitter.js';
import type { StructuralLanguage } from './structural.js';
/**
 * The vendored ast-grep WASM matching engine.
 *
 * The engine ships no grammars and no native code: it delegates parsing to the
 * same web-tree-sitter module instance and vendored grammar wasm files OCC
 * already uses, so an ast-grep match and a tsquery capture describe the same
 * parse tree. The artifact under vendor/ast-grep/ is self-built from a pinned
 * upstream tag (see vendor/ast-grep/README.md) and is content-addressed here:
 * both files are re-hashed before the engine is instantiated, and a mismatch
 * refuses to run rather than executing unpinned code.
 */
export declare const AST_GREP_ENGINE: {
    readonly name: "ast-grep";
    readonly version: "0.45.1";
};
declare const ENGINE_ASSETS: readonly [{
    readonly fileName: "wasm.js";
    readonly sha256: "5bd8bd4e999dd2f566c3f0b328ee61871918925820728411c2fac612084b50cb";
}, {
    readonly fileName: "wasm_bg.wasm";
    readonly sha256: "532c5fb8f1a5e41de6041edd12236db5f6f202361da47a462834585b5b3b5995";
}];
type EngineAssetName = (typeof ENGINE_ASSETS)[number]['fileName'];
/** A vendored engine artifact failed its content-addressed integrity check. */
export declare class AstGrepIntegrityError extends Error {
    readonly code: "ast-grep-integrity-failed";
    constructor(message: string);
}
/**
 * Positions reported by the engine. `index` passes through the underlying
 * web-tree-sitter node indices, which for string-backed parses count UTF-16
 * code units (verified against astral characters; upstream documents the
 * field as a generic "character offset"). Matching semantics — metavariable
 * back-references, `regex` clauses, and `text()` — are correct regardless:
 * the engine delegates node text to the web-tree-sitter node itself. The one
 * verified encoding fault is the edit path (`replace`/`commitEdits`), which
 * splices UTF-16 ranges into a code-point buffer and corrupts output after
 * astral characters — OCC deliberately exposes no rewriting, so that path is
 * never reached. OCC still slices the original source itself (see rules.ts)
 * so every reported coordinate shares one provenance.
 */
export interface AstGrepPos {
    /** 0-based line. */
    line: number;
    /** 0-based column. */
    column: number;
    /** UTF-16 offset into the source. */
    index: number;
}
export interface AstGrepRange {
    start: AstGrepPos;
    end: AstGrepPos;
}
/** The rule-object subset the engine accepts (SerializableRuleCore). */
export interface AstGrepRuleConfig {
    rule: Record<string, unknown>;
    constraints?: Record<string, unknown>;
    utils?: Record<string, unknown>;
    language?: string;
}
export interface AstGrepNode {
    free(): void;
    range(): AstGrepRange;
    kind(): string;
    text(): string;
    isNamed(): boolean;
    findAll(matcher: AstGrepRuleConfig): AstGrepNode[];
    getMatch(name: string): AstGrepNode | undefined;
    getMultipleMatches(name: string): AstGrepNode[];
}
export interface AstGrepRoot {
    free(): void;
    root(): AstGrepNode;
    /** The underlying web-tree-sitter tree. Owned by the engine; read, never delete-while-borrowed. */
    getInnerTree(): TreeSitterTree;
}
export declare function resolveAstGrepAsset(fileName: string): string | null;
/** The engine artifact is present on disk. Says nothing about digest validity. */
export declare function astGrepAssetsPresent(): boolean;
/** Verify bytes before they can reach either the JS or WASM evaluator. */
export declare function verifyAstGrepAssetBytes(fileName: EngineAssetName, bytes: Uint8Array): void;
/**
 * Parse one source text with the ast-grep engine.
 *
 * The returned handle owns WASM-side memory in two runtimes: the caller must
 * `free()` every SgNode it obtained, then `free()` the root, and finally
 * `delete()` the inner web-tree-sitter tree — web-tree-sitter 0.26 has no
 * finalizer, so a skipped delete leaks the parse for the process lifetime.
 */
export declare function parseWithAstGrep(language: StructuralLanguage, source: string): Promise<AstGrepRoot>;
export {};
