unregister method

Future<void> unregister(
  1. String id
)

Remove id from the registry. Registration metadata only — id must already be unloaded and have no local artifacts.

Throws SDKException when id is unknown, still loaded, or still has local artifacts; call unload/delete first.

Implementation

Future<void> unregister(String id) async {
  final model = await get(id);
  if (model == null) {
    throw SDKException.modelNotFound(id);
  }
  for (final category in _loadableCategories) {
    final currentId = await ModelGate.currentId(category);
    if (currentId == id) {
      throw SDKException.invalidState(
        "Model '$id' is currently loaded. Call models.unload('$id') before unregister.",
      );
    }
  }
  final hasArtifacts = model.localPath.isNotEmpty;
  if (hasArtifacts) {
    throw SDKException.invalidState(
      "Model '$id' still has local artifacts. Call models.delete('$id') before unregister.",
    );
  }
  _registryDirty = true;
  await RunAnywhereModels.shared.remove(id);
}