Files
soconnor 0da94715be
Build and test / macos (push) Canceled after 0s
Signed release / release (push) Canceled after 0s
Add advanced monitoring and release infrastructure
2026-08-15 18:23:35 -04:00

30 lines
1.2 KiB
Swift

import Foundation
public enum PuterHelperConstants {
public static let machServiceName = "dev.soconnor.puter.helper"
public static let daemonPlistName = "dev.soconnor.puter.helper.plist"
public static let protocolVersion = 1
}
public enum PuterFanTargetValidator {
public static let validFanIDs = 0...15
public static let validRPM = 500...20_000
public static func validate(_ targets: [NSNumber: NSNumber]) -> [(fan: Int, rpm: Int)]? {
let values = targets.compactMap { key, value -> (fan: Int, rpm: Int)? in
let fan = key.intValue
let rpm = value.intValue
guard validFanIDs.contains(fan), validRPM.contains(rpm) else { return nil }
return (fan, rpm)
}
guard values.count == targets.count, !values.isEmpty else { return nil }
return values.sorted { $0.fan < $1.fan }
}
}
@objc public protocol PuterPrivilegedHelperProtocol {
func version(withReply reply: @escaping (Int) -> Void)
func setFanTargets(_ targets: [NSNumber: NSNumber], withReply reply: @escaping (Bool, String?) -> Void)
func restoreAutomaticFanControl(withReply reply: @escaping (Bool, String?) -> Void)
}