refreshModelRegistry method

Future<void> refreshModelRegistry({
  1. bool rescanLocal = true,
  2. bool includeRemoteCatalog = false,
  3. bool pruneOrphans = false,
})

Refresh the model registry. Routes through the commons C ABI rac_model_registry_refresh_proto.

Matches Swift RunAnywhere.refreshModelRegistry(rescanLocal:includeRemoteCatalog:pruneOrphans:) (RunAnywhere+ModelRegistry.swift:46) — each flag is caller-controlled with Swift's defaults.

Implementation

Future<void> refreshModelRegistry({
  bool rescanLocal = true,
  bool includeRemoteCatalog = false,
  bool pruneOrphans = false,
}) async {
  if (!DartBridge.isInitialized) return;

  final logger = SDKLogger('RunAnywhere.Discovery');

  if (rescanLocal) {
    final result = await DartBridgeModelRegistry.instance
        .discoverDownloadedModels();
    if (result.discoveredModels.isNotEmpty) {
      logger.info(
        'Discovery found ${result.discoveredModels.length} downloaded models',
      );
    }
  }

  final ok = await DartBridgeModelRegistry.instance.refresh(
    rescanLocal: rescanLocal,
    includeRemoteCatalog: includeRemoteCatalog,
    pruneOrphans: pruneOrphans,
  );
  if (!ok) {
    logger.warning('rac_model_registry_refresh_proto reported failure');
  }
}