#pragma once #include "engine/framework/runtime/model.h" #include #include #include #include #include namespace engine::runtime { struct RegistryConfig { std::vector enabled_families; }; class ModelRegistry { public: void register_loader(std::shared_ptr loader); bool empty() const noexcept; size_t size() const noexcept; std::vector families() const; bool supports_family(const std::string & family) const noexcept; /** Path-free loader catalog for ``--list-loaders --json``. */ std::vector advertise_loaders() const; ModelInspection inspect(const ModelLoadRequest & request) const; ModelInspection inspect(const std::filesystem::path & model_path) const; std::unique_ptr load(const ModelLoadRequest & request) const; std::unique_ptr load(const std::filesystem::path & model_path) const; PackageLoadTarget resolve_package_load( const std::string & family, const assets::ModelPackage & package) const; /** * What the named family's session options ask for beyond weight files, from the loader that * owns the family (see IVoiceModelLoader::model_resources). A family with no loader registered * in this registry -- or one that reports nothing -- yields an empty plan. */ ModelResourcePlan model_resources( const std::string & family, const std::filesystem::path & model_path, const std::unordered_map & session_options) const; private: void validate_request(const ModelLoadRequest & request) const; const IVoiceModelLoader * find_loader(const ModelLoadRequest & request) const; std::vector> loaders_; }; RegistryConfig load_registry_config(const std::filesystem::path & path); ModelRegistry make_registry_from_config( const RegistryConfig & config, const std::vector> & available_loaders); ModelRegistry make_default_registry(const std::optional & config_path = std::nullopt); /** * Load a VAD model of any family built into this binary, for internal use such as ASR * VAD chunking. Only loaders that advertise offline VAD are considered; for a weight * file, the loader that uses exactly that file wins over a package in the same folder. * A path no VAD loader claims is loaded as Silero VAD, as before this helper existed. */ std::unique_ptr load_vad_model(const ModelLoadRequest & request); /** * Close the load-progress bracket opened by ModelRegistry::load: emit * ``runtime.load.phase loaded`` and the final upload_progress curve point. * Hosts call this once the task session is built — that is when the weight * stores have actually uploaded — not when the registry load returns. * Safe (no-op) when the load was never traced or was already closed. */ void finish_model_load_trace(); } // namespace engine::runtime