Skip to content

CatalogLoader

Category: Catalog

Source: catalog_loader.dart

Merges the bundled model catalog with optional cached-remote and user-local overlays.

Merge order (later wins): bundled → cachedRemote → localOverrides.

Cached-remote is field-merged onto bundled per provider. Remote payloads pass through [sanitizeRemoteCatalogYaml] before they land in the cache, which strips base_url / request_headers and clamps auth to {api_key: none} as a defense against a hostile remote redirecting a known provider's traffic. Whole-ProviderDef replacement would then wipe out the bundled auth: env:XXX_API_KEY and base_url, breaking the provider every time the user runs glue catalog refresh. Field-merging preserves stripped fields from the bundled layer while still letting the remote layer refresh models, enabled, docs_url, and name.

Local overrides retain whole-ProviderDef replace semantics. Users writing ~/.glue/models.yaml redeclare a provider in full, and the local copy is self-contained — matching the long-standing documented contract.

Functions

`ModelCatalog loadCatalog({

required ModelCatalog bundled, ModelCatalog? cachedRemote, ModelCatalog? localOverrides, })`

Released under the MIT License.