/** * Core lifecycle logic for Pi-managed Prism llama.cpp models, shared between the * `/models add` install pipeline (modes/interactive/local-model-commands.ts) and the router's * readiness gate (local-runtime-controller.ts). ONE place owns "ensure both GGUF files exist, then * serve" so a turn routed to a cold Bonsai-27B and a fresh `/models add` both go through the * identical self-healing path instead of two parallel, potentially-diverging implementations. * * Lives in core/models/ (not modes/) so the headless readiness gate — used by print/RPC/interactive * sessions and isolated/background lanes alike — never depends on the interactive-only UI layer; * mirrors the existing local-runtime.ts (mechanics) / local-runtime-controller.ts (gate) split. */ import type { PrismLlamaCppRuntime, PrismModelDescriptor } from "./llamacpp-runtime.ts"; export { PRISM_LLAMACPP_DESCRIPTORS } from "./local-execution-planner.ts"; export { probePrismLlamaCppServer } from "./prism-llamacpp-server-probe.ts"; /** * Curated Prism llama.cpp descriptors, keyed by repo id — the same catalog owns model-ref routing * and the id `registerPrismLlamaCppModel` writes to models.json. Future curated Prism models enter * through that one catalog rather than parallel identifier lists. * * Also the pi-managed-vs-user-owned discriminator (see {@link isPiManagedPrismLlamaCppModel}): a * `llama-cpp` provider model is gated/self-healed by pi ONLY when its id is a key here — a user's * own hand-configured entry (e.g. the built-in `llama-cpp/local` catalog model on port 8080, * pointing at a server the user runs themselves) is never touched. */ /** * True only for a `llama-cpp` provider model pi itself registered (id present in * {@link PRISM_LLAMACPP_DESCRIPTORS}) — never true for a user's own hand-configured llama-cpp * model, including the built-in `llama-cpp/local` catalog entry. This is the gate that must run * before ANY self-heal/serve action so pi never touches a server it doesn't own. */ export declare function isPiManagedPrismLlamaCppModel(model: { provider: string; id: string; }): boolean; /** * Fixed local port for pi's own managed prism llama.cpp server. Deliberately NOT the generic * built-in `llama-cpp/local` catalog model's conventional port 8080 (models.generated.ts) — that * port is the convention for a user's OWN manually started llama-server pi merely points at; pi's * managed instance must never collide with it. */ export declare const PRISM_LLAMACPP_SERVE_PORT = 8090; /** * Conservative RAM-only context cap for the pi-managed prism llama.cpp server, used at FIRST * install time only (`/models add`) — a later self-heal re-serve reuses the model's already * registered `contextWindow` instead (see the readiness gate in local-runtime-controller.ts), never * re-deriving from current RAM, so a served context size can't drift from what pi already told the * rest of the session (compaction, etc.) to expect. PrismLlamaCppRuntime has no `/api/show`- * equivalent GGUF metadata endpoint (unlike Ollama, which context-sizing.ts's * deriveLocalContextSizing depends on), so this is a coarse rung table mirroring * context-sizing.ts's CONTEXT_RUNGS, hard-capped at 32768 regardless of headroom: Bonsai-27B * advertises a 262K-class context, but that is not a realistic KV budget for a CPU-served model on * consumer hardware, and there is no larger validated rung to grow into yet. */ export declare function derivePrismLlamaCppNumCtx(totalMemBytes: number): number; export type EnsurePrismModelServedResult = { ok: true; baseUrl: string; } | { ok: false; stage: "model-download" | "mmproj-download" | "serve"; error: string; }; /** * The SOLE path allowed to call `runtime.serve()` for a prism llama.cpp model — no caller may spawn * llama-server without first passing through here (both `addPrismLlamaCppModel`'s install pipeline * and the readiness gate's self-heal path call this, never `runtime.serve()` directly). * Unconditionally re-verifies every required GGUF file via `runtime.downloadModel()` immediately before every * serve — that call is idempotent (skips a re-download when the local file already matches the * remote size, so the happy path costs one stat) and self-heals a file that went missing from disk * (deleted, a partial download from a prior crash, host cleanup, etc.) by re-fetching it instead of * ever starting llama-server without it. The vision projector is mandatory whenever the descriptor * declares one (the 27B descriptors do): a download failure on any required file means * llama-server is never spawned. There is no text-only fallback for a vision descriptor. */ export declare function ensurePrismModelFilesThenServe(runtime: PrismLlamaCppRuntime, descriptor: PrismModelDescriptor, args: { port: number; numCtx: number; }, onProgress: (message: string) => void): Promise; //# sourceMappingURL=prism-llamacpp-lifecycle.d.ts.map