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; embedBatch(texts: string[], options?: EmbedOptions): Promise<(EmbeddingResult | null)[]>; expandQuery(query: string, options?: { context?: string; includeLexical?: boolean; }): Promise; rerank(query: string, documents: RerankDocument[], options?: RerankOptions): Promise; 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; export interface LLM { embed(text: string, options?: EmbedOptions): Promise; embedBatch(texts: string[], options?: EmbedOptions): Promise<(EmbeddingResult | null)[]>; generate(prompt: string, options?: GenerateOptions): Promise; modelExists(modelUri: string): Promise; expandQuery(query: string, options?: { context?: string; includeLexical?: boolean; intent?: string; }): Promise; rerank(query: string, documents: RerankDocument[], options?: RerankOptions): Promise; dispose(): Promise; } 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; countTokens(_text: string): Promise; detokenize(_tokens: readonly number[]): Promise; embed(_text: string, _options?: EmbedOptions): Promise; embedBatch(_texts: string[], _options?: EmbedOptions): Promise<(EmbeddingResult | null)[]>; generate(_prompt: string, _options?: GenerateOptions): Promise; modelExists(modelUri: string): Promise; expandQuery(_query: string, _options?: { context?: string; includeLexical?: boolean; intent?: string; }): Promise; rerank(_query: string, _documents: RerankDocument[], _options?: RerankOptions): Promise; getDeviceInfo(): Promise<{ gpu: string | false; gpuOffloading: boolean; gpuDevices: string[]; vram?: { total: number; used: number; free: number; }; cpuCores: number; }>; unloadIdleResources(): Promise; dispose(): Promise; } 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; export declare function withLLMSession(fn: (session: ILLMSession) => Promise, options?: LLMSessionOptions): Promise; export declare function withLLMSessionForLlm(llm: LlamaCpp, fn: (session: ILLMSession) => Promise, options?: LLMSessionOptions): Promise; export declare function canUnloadLLM(): boolean;