mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-10 11:06:29 +08:00
* feat(nodes): add computer use (computer.act) on macOS nodes via Peekaboo * fix(nodes): release held computer.act input on node disconnect/stop/disable * fix(nodes): release held computer.act input armed after a lifecycle release * fix(nodes): scope computer.act lifecycle catch-up release to the arming action * chore(nodes): register computer tool display metadata, sync native i18n, doc-comment constants * fix(nodes): preserve caught-error cause in computer tool resolver; regen docs map
95 lines
3.0 KiB
Swift
95 lines
3.0 KiB
Swift
import CoreLocation
|
|
import Foundation
|
|
import OpenClawKit
|
|
|
|
@MainActor
|
|
protocol MacNodeRuntimeMainActorServices: Sendable {
|
|
func snapshotScreen(
|
|
screenIndex: Int?,
|
|
maxWidth: Int?,
|
|
quality: Double?,
|
|
format: OpenClawScreenSnapshotFormat?) async throws
|
|
-> (data: Data, format: OpenClawScreenSnapshotFormat, width: Int, height: Int)
|
|
|
|
func recordScreen(
|
|
screenIndex: Int?,
|
|
durationMs: Int?,
|
|
fps: Double?,
|
|
includeAudio: Bool?,
|
|
outPath: String?) async throws -> (path: String, hasAudio: Bool)
|
|
|
|
func locationAuthorizationStatus() -> CLAuthorizationStatus
|
|
func locationAccuracyAuthorization() -> CLAccuracyAuthorization
|
|
func currentLocation(
|
|
desiredAccuracy: OpenClawLocationAccuracy,
|
|
maxAgeMs: Int?,
|
|
timeoutMs: Int?) async throws -> CLLocation
|
|
|
|
func performComputerAct(_ params: OpenClawComputerActParams) async throws -> OpenClawComputerActResult
|
|
func releaseHeldInput()
|
|
}
|
|
|
|
@MainActor
|
|
final class LiveMacNodeRuntimeMainActorServices: MacNodeRuntimeMainActorServices, @unchecked Sendable {
|
|
private let screenSnapshotter = ScreenSnapshotService()
|
|
private let screenRecorder = ScreenRecordService()
|
|
private let locationService = MacNodeLocationService()
|
|
private let computerAction = ComputerActionService()
|
|
|
|
func snapshotScreen(
|
|
screenIndex: Int?,
|
|
maxWidth: Int?,
|
|
quality: Double?,
|
|
format: OpenClawScreenSnapshotFormat?) async throws
|
|
-> (data: Data, format: OpenClawScreenSnapshotFormat, width: Int, height: Int)
|
|
{
|
|
try await self.screenSnapshotter.snapshot(
|
|
screenIndex: screenIndex,
|
|
maxWidth: maxWidth,
|
|
quality: quality,
|
|
format: format)
|
|
}
|
|
|
|
func recordScreen(
|
|
screenIndex: Int?,
|
|
durationMs: Int?,
|
|
fps: Double?,
|
|
includeAudio: Bool?,
|
|
outPath: String?) async throws -> (path: String, hasAudio: Bool)
|
|
{
|
|
try await self.screenRecorder.record(
|
|
screenIndex: screenIndex,
|
|
durationMs: durationMs,
|
|
fps: fps,
|
|
includeAudio: includeAudio,
|
|
outPath: outPath)
|
|
}
|
|
|
|
func locationAuthorizationStatus() -> CLAuthorizationStatus {
|
|
self.locationService.authorizationStatus()
|
|
}
|
|
|
|
func locationAccuracyAuthorization() -> CLAccuracyAuthorization {
|
|
self.locationService.accuracyAuthorization()
|
|
}
|
|
|
|
func currentLocation(
|
|
desiredAccuracy: OpenClawLocationAccuracy,
|
|
maxAgeMs: Int?,
|
|
timeoutMs: Int?) async throws -> CLLocation
|
|
{
|
|
try await self.locationService.currentLocation(
|
|
desiredAccuracy: desiredAccuracy,
|
|
maxAgeMs: maxAgeMs,
|
|
timeoutMs: timeoutMs)
|
|
}
|
|
|
|
func performComputerAct(_ params: OpenClawComputerActParams) async throws -> OpenClawComputerActResult {
|
|
try await self.computerAction.perform(params)
|
|
}
|
|
|
|
func releaseHeldInput() {
|
|
self.computerAction.releaseHeldInput()
|
|
}
|
|
}
|