@@ -452,6 +452,10 @@ final class ComputerActionService {
452452 case buttonNotHeld
453453 case eventCreationFailed
454454 case lifecycleChanged
455+ case invalidV2Request ( String )
456+ case staleObservation
457+ case unsupportedAction ( OpenClawComputerAction )
458+ case refused ( String )
455459
456460 var errorDescription : String ? {
457461 switch self {
@@ -491,6 +495,14 @@ final class ComputerActionService {
491495 " Failed to synthesize input event "
492496 case . lifecycleChanged :
493497 " Computer control lifecycle changed while the action was pending "
498+ case let . invalidV2Request ( message ) :
499+ " COMPUTER_INVALID_REQUEST: \( message ) "
500+ case . staleObservation :
501+ " COMPUTER_STALE_OBSERVATION: take a fresh observation and retry "
502+ case let . unsupportedAction ( action ) :
503+ " COMPUTER_UNSUPPORTED_ACTION: \( action . rawValue ) "
504+ case let . refused ( message ) :
505+ " COMPUTER_REFUSED_action_refused: \( message ) "
494506 }
495507 }
496508 }
@@ -500,6 +512,7 @@ final class ComputerActionService {
500512 private let mouseEventFactory : MouseEventFactory
501513 private let mouseEventPoster : MouseEventPoster
502514 private let textGraphemePoster : TextGraphemePoster
515+ private lazy var v2 = ComputerActionServiceV2 ( )
503516 /// Tracks whether a left_mouse_down is outstanding so mouse_move emits
504517 /// drag events (state persists across invokes on the shared instance).
505518 private var leftButtonDown = false
@@ -592,6 +605,27 @@ final class ComputerActionService {
592605 lifecycleGeneration : UInt64 ) async throws -> OpenClawComputerActResult
593606 {
594607 try self . executionQueue . checkExecutionAllowed ( lifecycleGeneration : lifecycleGeneration )
608+ if params . deliveryMode == . background ,
609+ params . windowRef == nil ,
610+ ! params . action . isComputerActV2Only
611+ {
612+ return OpenClawComputerActResult (
613+ ok : false ,
614+ effect : . suspectedNoop ,
615+ escalation : OpenClawComputerEscalation (
616+ recommended : " window-pixel " ,
617+ reasonCode : " no_window_target " ) )
618+ }
619+ if params . isV2Request {
620+ return try await self . v2 . perform (
621+ params ,
622+ lifecycleGeneration : lifecycleGeneration ,
623+ checkExecutionAllowed : { [ weak self ] in
624+ guard let self else { throw CancellationError ( ) }
625+ try self . executionQueue . checkExecutionAllowed (
626+ lifecycleGeneration : lifecycleGeneration )
627+ } )
628+ }
595629 try Self . validateInputPermissions ( ComputerControlPermissionSnapshot . probe ( ) )
596630 let display = try await resolveDisplay ( params : params )
597631 try executionQueue . checkExecutionAllowed ( lifecycleGeneration : lifecycleGeneration )
@@ -704,6 +738,8 @@ final class ComputerActionService {
704738 let keys = try requireKeys ( params . keys )
705739 let holdMs = min ( Self . maxHoldMs , max ( 0 , params . durationMs ?? 1000 ) )
706740 try await self . automation . hotkey ( keys : keys , holdDuration : holdMs )
741+ default :
742+ throw ComputerActionError . unsupportedAction ( params . action )
707743 }
708744 }
709745
0 commit comments