mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-15 11:56:01 +00:00
* feat(nodes): route alerts by active computer * fix(ci): allowlist node presence mobile coverage * test(prompts): refresh node presence snapshots * fix(macos): await presence reporter actor hop * fix(macos): type presence test delivery state * docs(nodes): add active presence guide * docs(nodes): format presence troubleshooting
27 lines
793 B
Swift
27 lines
793 B
Swift
import CoreGraphics
|
|
import Foundation
|
|
import OpenClawKit
|
|
|
|
enum SystemPresenceInfo {
|
|
static func lastInputSeconds() -> Int? {
|
|
self.lastInputSeconds(state: .combinedSessionState)
|
|
}
|
|
|
|
static func lastHardwareInputSeconds() -> Int? {
|
|
self.lastInputSeconds(state: .hidSystemState)
|
|
}
|
|
|
|
private static func lastInputSeconds(state: CGEventSourceStateID) -> Int? {
|
|
let anyEvent = CGEventType(rawValue: UInt32.max) ?? .null
|
|
let seconds = CGEventSource.secondsSinceLastEventType(state, eventType: anyEvent)
|
|
if seconds.isNaN || seconds.isInfinite || seconds < 0 {
|
|
return nil
|
|
}
|
|
return Int(seconds.rounded())
|
|
}
|
|
|
|
static func primaryIPv4Address() -> String? {
|
|
NetworkInterfaces.primaryIPv4Address()
|
|
}
|
|
}
|