import type { ServeKind } from "./localServe.js"; export type MemorySnapshot = { available: number; total: number; }; /** The memory kept free when a model is loaded: the smaller of this and * `MEMORY_RESERVE_FRACTION` of the machine's memory. */ export declare const MEMORY_RESERVE_MAX_BYTES: number; export declare const MEMORY_RESERVE_FRACTION = 0.05; /** Memory a model needs beyond its size on disk, by kind. An image model * holds the intermediate pictures of every step; the others hold little * beyond their weights and a prompt cache. */ export declare const LOAD_HEADROOM_BYTES: Record; /** The bytes macOS could give a new process, from the text `vm_stat` * prints: the free, inactive, and speculative pages, times the page size * in the first line. */ export declare function parseVmStat(text: string): number; /** The bytes Linux could give a new process, from `/proc/meminfo`, which * states `MemAvailable` in kB. */ export declare function parseMeminfo(text: string): number; /** The memory available now, and the machine's total. On an error the * error is logged and `os.freemem()` stands in, which counts only pages * nothing has touched and so reads low. */ export declare function availableMemory(log: (line: string) => void): Promise; export declare function memoryReserve(memory: MemorySnapshot): number; /** What `estimatedNeed` reads of a planned model. */ export type SizedModel = { sizeBytes: number; kind: ServeKind; draft?: { sizeBytes: number; }; }; /** The memory loading a model is expected to take: its size on disk, its * draft's, and its kind's headroom. */ export declare function estimatedNeed(model: SizedModel): number; /** Whether a model that needs `needBytes` can load now and leave the * reserve free. */ export declare function fits(needBytes: number, memory: MemorySnapshot): boolean;