/** * Hugging Face → Ollama pull pipeline (pure helpers). * * The sidecar's `/hf/*` routes (app-sidecar.ts) use these to search the Hub, * pick a quantized GGUF variant, and stream `ollama pull hf.co/:` * progress to the app. Kept dependency-free and side-effect-free so the * parsing/selection rules are unit-testable. */ /** `org/repo` only — no tags, no traversal, no leading slashes. */ export declare function isValidHfRepoId(id: string): boolean; export interface HfSearchRow { id: string; downloads: number; likes: number; updatedAt: string | null; } /** * Map a Hub `/api/models?search=` result entry to what the dropdown shows. * Entries without parsed `gguf` metadata are dropped: the Hub tags plenty of * safetensors-only repos as GGUF-adjacent, and those can never be pulled. */ export declare function toHfSearchRow(entry: { id?: unknown; downloads?: unknown; likes?: unknown; lastModified?: unknown; gguf?: unknown; }): HfSearchRow | null; export interface GgufFile { /** Filename, e.g. `qwen3-coder-30b-q4_k_m.gguf`. */ path: string; sizeBytes: number; } export interface QuantChoice { /** Ollama tag for `hf.co/:` — `Q4_K_M`, or null to pull tagless. */ tag: string | null; file: GgufFile; } /** Quant token from a GGUF filename (`...-q4_k_m.gguf` → `Q4_K_M`), if any. */ export declare function quantFromFilename(path: string): string | null; /** * `...-00001-of-00009.gguf` — a shard of a split model. Ollama's registry * cannot pull sharded GGUF (ollama/ollama#5245), so these are never candidates. */ export declare function isGgufShard(path: string): boolean; /** * GGUF files in a model repo that are not the model: * * - `mmproj-*` / `*projector*` — vision projectors, loaded alongside weights. * - `imatrix*` — quantization calibration data. * - `mtp-*` / `dspark-*` / anything under `MTP/` — tiny speculative-decoding * draft models. * * All three would otherwise be installed *as* the model: projectors are the * smallest file (winning the size fallback) and drafts often carry a more * preferred quant tag than the real weights (`mtp-…-Q4_0.gguf` beside * `…-qat-UD-Q4_K_XL.gguf`). * * simplification: matched by name, since size does not separate them — across * the top GGUF repos, drafts run 6–23% of the largest file while legitimate * IQ1/IQ2 quants run 8–13%. Ceiling: a vendor inventing a new draft prefix is * missed until it is added here. Upgrade path: the Hub's per-file `gguf` * metadata exposes parameter counts, which separate drafts from quants exactly. */ export declare function isGgufCompanion(path: string): boolean; /** Every pullable GGUF in a repo tree: real models, no shards, no companions. */ export declare function ggufCandidates(files: readonly GgufFile[]): GgufFile[]; /** * Pick which GGUF file `ollama pull` should fetch. Deterministic: the first * entry of `QUANT_PREFERENCE` present, else the smallest file (multi-quant * repos list big quants first), else the only file — tagless when the repo * ships a single unnamed GGUF. */ export declare function pickGgufQuant(files: readonly GgufFile[]): QuantChoice | null; /** Shown when a repo only ships split GGUF shards — an Ollama limitation. */ export declare const SHARDED_MESSAGE = "That repo only ships split GGUF shards, which Ollama can't pull. Pick a repo with single-file quants (bartowski, lmstudio-community, or the non-split unsloth build)."; export type PullPhase = "preparing" | "downloading" | "verifying" | "success" | "error"; /** True when `next` is a real step forward from `current` (never backwards). */ export declare function advancesPhase(current: PullPhase, next: PullPhase): boolean; export interface PullProgress { phase: PullPhase; /** 0-100 while downloading; sticky afterwards. */ percent?: number; /** Display text, e.g. `161 MB / 18 GB · 11 MB/s · 26m8s`. */ detail?: string; } /** * Parse one non-TTY `ollama pull` line. The CLI prints status verbs plus * `: % / ` lines to stderr; any unrecognized line * is still surfaced as `downloading` with the raw text so the UI never stalls * silently behind a parser gap. */ export declare function parseOllamaPullLine(line: string): PullProgress | null; /** * Map a failed pull's stderr to the one action that fixes it. Ollama ≥0.32 has * a manifest-realm bug pulling `hf.co/…` and gated/auth-required repos need a * token — everything else is passed through with context. */ export declare function explainPullFailure(stderrTail: string): string; /** `12.4M` → `12.4M downloads`, `3,412` stays exact under 1000. */ export declare function formatCount(n: number): string; //# sourceMappingURL=hf-pull.d.ts.map