import Foundation /// One model returned by `GET /api/tags`. public struct InstalledModel: Sendable, Equatable, Decodable { /// The user-facing tag, e.g. `hf.co/tencent/Hy-MT3-7B-GGUF:Q4_K_M`. public let name: String /// The tag as Ollama reports it (normally identical to `name`). public let model: String /// The ISO-8601 modification time, when present. public let modifiedAt: String? /// The model size in bytes, when present. public let size: Int64? /// The full sha256 digest. public let digest: String /// The optional family/quantization details. public let details: ModelDetailsInfo? /// Creates a model value. public init( name: String, model: String, modifiedAt: String? = nil, size: Int64? = nil, digest: String, details: ModelDetailsInfo? = nil ) { self.name = name self.model = model self.modifiedAt = modifiedAt self.size = size self.digest = digest self.details = details } /// True when the tag or model name contains `hy-mt3`, case-insensitively. /// /// Temporary for the M1 CLI filter; the adapter registry (T2.1) owns family matching in M2. public var isHyMT3: Bool { name.localizedCaseInsensitiveContains("hy-mt3") || model.localizedCaseInsensitiveContains("hy-mt3") } /// `name` with a trailing `:latest` removed. public var normalizedName: String { Self.normalizedName(name) } /// Removes only a trailing `:latest`; other tags are preserved. public static func normalizedName(_ name: String) -> String { name.hasSuffix(":latest") ? String(name.dropLast(":latest".count)) : name } private enum CodingKeys: String, CodingKey { case name case model case modifiedAt = "modified_at" case size case digest case details } }