cua-computer 0.3.6__py3-none-any.whl → 0.3.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,7 +28,7 @@ class GenericComputerInterface(BaseComputerInterface):
28
28
  self._max_reconnect_delay = 30 # Maximum delay between reconnection attempts
29
29
  self._log_connection_attempts = True # Flag to control connection attempt logging
30
30
  self._authenticated = False # Track authentication status
31
- self._command_lock = asyncio.Lock() # Lock to ensure only one command at a time
31
+ self._recv_lock = asyncio.Lock() # Lock to ensure only one recv at a time
32
32
 
33
33
  # Set logger name for the interface
34
34
  self.logger = Logger(logger_name, LogLevel.NORMAL)
@@ -245,7 +245,7 @@ class GenericComputerInterface(BaseComputerInterface):
245
245
  """
246
246
  result = await self._send_command("screenshot")
247
247
  if not result.get("image_data"):
248
- raise RuntimeError("Failed to take screenshot")
248
+ raise RuntimeError("Failed to take screenshot, no image data received from server")
249
249
 
250
250
  screenshot = decode_base64_image(result["image_data"])
251
251
 
@@ -578,7 +578,8 @@ class GenericComputerInterface(BaseComputerInterface):
578
578
  await self._ws.send(json.dumps(auth_message))
579
579
 
580
580
  # Wait for authentication response
581
- auth_response = await asyncio.wait_for(self._ws.recv(), timeout=10)
581
+ async with self._recv_lock:
582
+ auth_response = await asyncio.wait_for(self._ws.recv(), timeout=10)
582
583
  auth_result = json.loads(auth_response)
583
584
 
584
585
  if not auth_result.get("success"):
@@ -696,38 +697,38 @@ class GenericComputerInterface(BaseComputerInterface):
696
697
  last_error = None
697
698
 
698
699
  # Acquire lock to ensure only one command is processed at a time
699
- async with self._command_lock:
700
- self.logger.debug(f"Acquired lock for command: {command}")
701
- while retry_count < max_retries:
702
- try:
703
- await self._ensure_connection()
704
- if not self._ws:
705
- raise ConnectionError("WebSocket connection is not established")
700
+ self.logger.debug(f"Acquired lock for command: {command}")
701
+ while retry_count < max_retries:
702
+ try:
703
+ await self._ensure_connection()
704
+ if not self._ws:
705
+ raise ConnectionError("WebSocket connection is not established")
706
706
 
707
- message = {"command": command, "params": params or {}}
708
- await self._ws.send(json.dumps(message))
707
+ message = {"command": command, "params": params or {}}
708
+ await self._ws.send(json.dumps(message))
709
+ async with self._recv_lock:
709
710
  response = await asyncio.wait_for(self._ws.recv(), timeout=120)
710
- self.logger.debug(f"Completed command: {command}")
711
- return json.loads(response)
712
- except Exception as e:
713
- last_error = e
714
- retry_count += 1
715
- if retry_count < max_retries:
716
- # Only log at debug level for intermediate retries
717
- self.logger.debug(
718
- f"Command '{command}' failed (attempt {retry_count}/{max_retries}): {e}"
719
- )
720
- await asyncio.sleep(1)
721
- continue
722
- else:
723
- # Only log at error level for the final failure
724
- self.logger.error(
725
- f"Failed to send command '{command}' after {max_retries} retries"
726
- )
727
- self.logger.debug(f"Command failure details: {e}")
728
- raise
711
+ self.logger.debug(f"Completed command: {command}")
712
+ return json.loads(response)
713
+ except Exception as e:
714
+ last_error = e
715
+ retry_count += 1
716
+ if retry_count < max_retries:
717
+ # Only log at debug level for intermediate retries
718
+ self.logger.debug(
719
+ f"Command '{command}' failed (attempt {retry_count}/{max_retries}): {e}"
720
+ )
721
+ await asyncio.sleep(1)
722
+ continue
723
+ else:
724
+ # Only log at error level for the final failure
725
+ self.logger.error(
726
+ f"Failed to send command '{command}' after {max_retries} retries"
727
+ )
728
+ self.logger.debug(f"Command failure details: {e}")
729
+ raise
729
730
 
730
- raise last_error if last_error else RuntimeError("Failed to send command")
731
+ raise last_error if last_error else RuntimeError("Failed to send command")
731
732
 
732
733
  async def _send_command_rest(self, command: str, params: Optional[Dict] = None) -> Dict[str, Any]:
733
734
  """Send command through REST API without retries or connection management."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cua-computer
3
- Version: 0.3.6
3
+ Version: 0.3.7
4
4
  Summary: Computer-Use Interface (CUI) framework powering Cua
5
5
  Author-Email: TryCua <gh@trycua.com>
6
6
  Requires-Python: >=3.11
@@ -5,7 +5,7 @@ computer/helpers.py,sha256=iHkO2WhuCLc15g67kfMnpQWxfNRlz2YeJNEvYaL9jlM,1826
5
5
  computer/interface/__init__.py,sha256=xQvYjq5PMn9ZJOmRR5mWtONTl_0HVd8ACvW6AQnzDdw,262
6
6
  computer/interface/base.py,sha256=1beR4T0z5anb9NaNgKJrMJTF0BFIKyiHlokMLesOV5Q,15131
7
7
  computer/interface/factory.py,sha256=Eas5u9sOZ8FegwX51dP9M37oZBjy2EiVcmhTPc98L3Y,1639
8
- computer/interface/generic.py,sha256=gSy-99kq3dhOuNfKDLEKpWpRHTLQgSX3VXpvPKlJTYY,43058
8
+ computer/interface/generic.py,sha256=XV6TmAyUK075JteCDt1FM57nTSbvrJEZId2BvTLZthI,43041
9
9
  computer/interface/linux.py,sha256=fDm2OwqfeeO72HwctboPEE5AwPTo2XBRDyYkwQxMyt0,417
10
10
  computer/interface/macos.py,sha256=m1aRn3BCbA95gPoO-WSP9NPwruT4BT5DZzxY10UuBI0,675
11
11
  computer/interface/models.py,sha256=kPpmoO-TSxSr95f5ELuTpobY-SckG1Sn9pE8zz1t008,3605
@@ -31,7 +31,7 @@ computer/ui/__main__.py,sha256=Jwy2oC_mGZLN0fX7WLqpjaQkbXMeM3ISrUc8WSRUG0c,284
31
31
  computer/ui/gradio/__init__.py,sha256=5_KimixM48-X74FCsLw7LbSt39MQfUMEL8-M9amK3Cw,117
32
32
  computer/ui/gradio/app.py,sha256=5_AG2dQR9RtFrGQNonScAw64rlswclKW26tYlFBdXtM,70396
33
33
  computer/utils.py,sha256=zY50NXB7r51GNLQ6l7lhG_qv0_ufpQ8n0-SDhCei8m4,2838
34
- cua_computer-0.3.6.dist-info/METADATA,sha256=GEXmO2WaZ-QIiekgu4AD7NLWaIdVhiv8v3B-duoJoGI,5802
35
- cua_computer-0.3.6.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
36
- cua_computer-0.3.6.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
37
- cua_computer-0.3.6.dist-info/RECORD,,
34
+ cua_computer-0.3.7.dist-info/METADATA,sha256=rQMBHkhy4HsHzWgZ_1kH81IHmtvERSH3690tWrLgX_0,5802
35
+ cua_computer-0.3.7.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
36
+ cua_computer-0.3.7.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
37
+ cua_computer-0.3.7.dist-info/RECORD,,