/** * A Zen catalogue assembled at run time from the same sources, by the same * rules, as the bundled snapshot in `models.ts`. * * Nothing here reaches the network. `buildZenCatalogue` turns source TEXTS * into a catalogue; `fetch.ts` is the one place those texts are fetched, and * only when a caller asks. `parseZenCatalogue` re-admits a catalogue a host * stored earlier, with the same strictness a fresh derivation has: a document * that is not exactly a catalogue is refused whole, never read in part. */ import { type ZenModel, type ZenService } from '../models.js'; import { type ZenOmissions } from './derive.js'; /** The stored shape's version. A document carrying any other is refused. */ export declare const ZEN_CATALOGUE_VERSION = 1; /** * A complete Zen and Go roster. * * `unrouted` lists, per service, the ids the service's own `/models` answer * serves that this catalogue neither carries nor omits by review: no source * states a wire for them (or the rest of what carrying needs), so a driver * lists them as having no known wire format and calls one only when its host * names the protocol explicitly. */ export interface ZenCatalogue { readonly version: typeof ZEN_CATALOGUE_VERSION; /** When the sources were read, as an ISO 8601 timestamp. */ readonly fetchedAt: string; readonly zen: readonly ZenModel[]; readonly go: readonly ZenModel[]; readonly unrouted: Readonly>; } /** What a derivation found and did not carry. Informational: none of it fails a build. */ export interface ZenCatalogueReport { /** `service/id`: served by the service, documented on no page, omitted by nothing. */ readonly servedUndocumented: readonly string[]; /** `[service/id, why]`: documented, not carryable, omitted by nothing. */ readonly undecided: readonly (readonly [string, string])[]; /** `service/id`: omissions upstream neither documents nor serves any more. */ readonly stale: readonly string[]; /** `service: name`: price rows no route row names. */ readonly orphanPrices: readonly string[]; } /** The five upstream documents, as the texts they were served as. */ export interface ZenCatalogueSources { readonly docs: Readonly>; /** `https://models.dev/api.json`. */ readonly modelsDev: string; /** Each service's own `/models` answer. */ readonly served: Readonly>; } export interface BuildZenCatalogueOptions { /** * Reviewed omissions, as `service/id` keys or the review file's record. * Defaults to the decisions the bundled snapshot was generated under. */ readonly omissions?: ZenOmissions; /** * The roster a result is measured against for collapse: fewer than 80% of * its models on either service refuses the result. Defaults to the bundled * snapshot. */ readonly baseline?: Readonly>; /** Stamped as `fetchedAt`. Defaults to now. */ readonly fetchedAt?: Date; } export interface ZenCatalogueResult { readonly catalogue: ZenCatalogue; readonly report: ZenCatalogueReport; } /** * Derive a catalogue from upstream texts, or throw `ZenCatalogueSourceError`. * * All or nothing: a page that moved, a models.dev that changed shape, a served * answer with no ids or a roster that collapsed past the floor refuses the * whole result, so a caller holding an older catalogue keeps it rather than * receiving part of a new one. */ export declare function buildZenCatalogue(sources: ZenCatalogueSources, options?: BuildZenCatalogueOptions): ZenCatalogueResult; /** A stored catalogue that is not exactly a catalogue. */ export declare class ZenCatalogueFormatError extends Error { readonly name = "ZenCatalogueFormatError"; } /** * Re-admit a catalogue a host stored — the output of `JSON.parse` on what * `JSON.stringify(catalogue)` wrote — or throw `ZenCatalogueFormatError`. * * Every field is checked as strictly as a derivation checks its sources, and a * document with one bad field is refused whole: a cache someone edited, a * truncated write or a file from another version never becomes a partial * roster. */ export declare function parseZenCatalogue(value: unknown): ZenCatalogue; /** * Exact lookup with the runtime catalogue first and the bundled snapshot * second. `catalogue` undefined is the bundled snapshot alone. * * An id the runtime catalogue lists in `unrouted` is found in neither: the * newer sources say the service serves it and state no wire for it, and the * bundled snapshot's older entry is not allowed to answer for them. Falling * back would route the model on a wire nobody states any more, anonymously * too if the old entry said so, and without saying anything. */ export declare function findZenCatalogueModel(catalogue: ZenCatalogue | undefined, service: ZenService, id: string): ZenModel | undefined; /** Whether a runtime catalogue lists `id` as served with no known wire format. */ export declare function isUnroutedZenModel(catalogue: ZenCatalogue | undefined, service: ZenService, id: string): boolean; //# sourceMappingURL=catalogue.d.ts.map