export declare function isLocalLlmDisabled(_env?: NodeJS.ProcessEnv): boolean;
export declare function resolveLlamaGpuMode(_env?: NodeJS.ProcessEnv): "cpu" | "auto";
export declare function isQwen3EmbeddingModel(modelUri: string): boolean;
export declare function formatQueryForEmbedding(query: string, modelUri?: string): string;
export declare function formatDocForEmbedding(text: string, title?: string, modelUri?: string): string;
export type TokenLogProb = {
    token: string;
    logprob: number;
};
export type EmbeddingResult = {
    embedding: number[];
    model: string;
};
export type GenerateResult = {
    text: string;
    model: string;
    logprobs?: TokenLogProb[];
    done: boolean;
};
export type RerankDocumentResult = {
    file: string;
    score: number;
    index: number;
};
export type RerankResult = {
    results: RerankDocumentResult[];
    model: string;
};
export type ModelInfo = {
    name: string;
    exists: boolean;
    path?: string;
};
export type EmbedOptions = {
    model?: string;
    isQuery?: boolean;
    title?: string;
};
export type GenerateOptions = {
    model?: string;
    maxTokens?: number;
    temperature?: number;
};
export type RerankOptions = {
    model?: string;
};
export type LLMSessionOptions = {
    maxDuration?: number;
    signal?: AbortSignal;
    name?: string;
};
export type QueryType = "lex" | "vec" | "hyde";
export type Queryable = {
    type: QueryType;
    text: string;
};
export type RerankDocument = {
    file: string;
    text: string;
    title?: string;
};
export interface ILLMSession {
    embed(text: string, options?: EmbedOptions): Promise<EmbeddingResult | null>;
    embedBatch(texts: string[], options?: EmbedOptions): Promise<(EmbeddingResult | null)[]>;
    expandQuery(query: string, options?: {
        context?: string;
        includeLexical?: boolean;
    }): Promise<Queryable[]>;
    rerank(query: string, documents: RerankDocument[], options?: RerankOptions): Promise<RerankResult>;
    readonly isValid: boolean;
    readonly signal: AbortSignal;
}
export declare const LFM2_GENERATE_MODEL = "commercial-api-required";
export declare const LFM2_INSTRUCT_MODEL = "commercial-api-required";
export declare const DEFAULT_EMBED_MODEL_URI = "commercial-api:embedding-unconfigured";
export declare const DEFAULT_RERANK_MODEL_URI = "commercial-api:rerank-unconfigured";
export declare const DEFAULT_GENERATE_MODEL_URI = "commercial-api:generation-unconfigured";
export declare const DEFAULT_MODEL_CACHE_DIR = "commercial-api:no-local-cache";
export type PullResult = {
    model: string;
    path: string;
    sizeBytes: number;
    refreshed: boolean;
};
export declare function pullModels(_models: string[], _options?: {
    refresh?: boolean;
    cacheDir?: string;
}): Promise<PullResult[]>;
export interface LLM {
    embed(text: string, options?: EmbedOptions): Promise<EmbeddingResult | null>;
    embedBatch(texts: string[], options?: EmbedOptions): Promise<(EmbeddingResult | null)[]>;
    generate(prompt: string, options?: GenerateOptions): Promise<GenerateResult | null>;
    modelExists(modelUri: string): Promise<ModelInfo>;
    expandQuery(query: string, options?: {
        context?: string;
        includeLexical?: boolean;
        intent?: string;
    }): Promise<Queryable[]>;
    rerank(query: string, documents: RerankDocument[], options?: RerankOptions): Promise<RerankResult>;
    dispose(): Promise<void>;
}
export type LlamaCppConfig = {
    embedModel?: string;
    generateModel?: string;
    rerankModel?: string;
    modelCacheDir?: string;
    expandContextSize?: number;
    inactivityTimeoutMs?: number;
    disposeModelsOnInactivity?: boolean;
};
/** Historical SDK name retained as a fail-closed compatibility adapter. */
export declare class LlamaCpp implements LLM {
    static readonly EMBED_CONTEXT_SIZE = 2048;
    static readonly RERANK_CONTEXT_SIZE = 2048;
    static readonly RERANK_TARGET_DOCS_PER_CONTEXT = 32;
    static readonly RERANK_TEMPLATE_OVERHEAD = 32;
    readonly embedModelName: string;
    constructor(config?: LlamaCppConfig);
    tokenize(_text: string): Promise<readonly number[]>;
    countTokens(_text: string): Promise<number>;
    detokenize(_tokens: readonly number[]): Promise<string>;
    embed(_text: string, _options?: EmbedOptions): Promise<EmbeddingResult | null>;
    embedBatch(_texts: string[], _options?: EmbedOptions): Promise<(EmbeddingResult | null)[]>;
    generate(_prompt: string, _options?: GenerateOptions): Promise<GenerateResult | null>;
    modelExists(modelUri: string): Promise<ModelInfo>;
    expandQuery(_query: string, _options?: {
        context?: string;
        includeLexical?: boolean;
        intent?: string;
    }): Promise<Queryable[]>;
    rerank(_query: string, _documents: RerankDocument[], _options?: RerankOptions): Promise<RerankResult>;
    getDeviceInfo(): Promise<{
        gpu: string | false;
        gpuOffloading: boolean;
        gpuDevices: string[];
        vram?: {
            total: number;
            used: number;
            free: number;
        };
        cpuCores: number;
    }>;
    unloadIdleResources(): Promise<void>;
    dispose(): Promise<void>;
}
export declare class SessionReleasedError extends Error {
    constructor(message?: string);
}
export declare function getDefaultLlamaCpp(): LlamaCpp;
export declare function setDefaultLlamaCpp(llm: LlamaCpp | null): void;
export declare function disposeDefaultLlamaCpp(): Promise<void>;
export declare function withLLMSession<T>(fn: (session: ILLMSession) => Promise<T>, options?: LLMSessionOptions): Promise<T>;
export declare function withLLMSessionForLlm<T>(llm: LlamaCpp, fn: (session: ILLMSession) => Promise<T>, options?: LLMSessionOptions): Promise<T>;
export declare function canUnloadLLM(): boolean;
