Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

removed api calls from client

Dillon DuPont59b1cab65782
diff --git a/libs/computer-server/computer_server/main.py b/libs/computer-server/computer_server/main.py
index ac09cc787c..93653034d3 100644
--- a/libs/computer-server/computer_server/main.py
+++ b/libs/computer-server/computer_server/main.py
@@ -98,10 +98,13 @@ async def websocket_endpoint(websocket: WebSocket):
# Validate with TryCUA API
try:
async with aiohttp.ClientSession() as session:
- headers = {"Authorization": f"Bearer {client_api_key}"}
+ headers = {
+ "Authorization": f"Bearer {client_api_key}",
+ "Origin": f"https://{vm_name}.containers.cloud.trycua.com",
+ }
async with session.get(
- f"https://www.trycua.com/api/vm-host?vm_name={vm_name}",
+ f"https://www.trycua.com/api/vm/auth",
headers=headers,
) as resp:
if resp.status != 200:
diff --git a/libs/computer/computer/providers/cloud/provider.py b/libs/computer/computer/providers/cloud/provider.py
index 64fba31555..f030bb506b 100644
--- a/libs/computer/computer/providers/cloud/provider.py
+++ b/libs/computer/computer/providers/cloud/provider.py
@@ -16,7 +16,7 @@ import aiohttp
from urllib.parse import urlparse
class CloudProvider(BaseVMProvider):
- """Cloud VM Provider implementation using /api/vm-host endpoint."""
+ """Cloud VM Provider implementation."""
def __init__(
self,
api_key: str,
@@ -45,29 +45,13 @@ class CloudProvider(BaseVMProvider):
async def get_vm(self, name: str, storage: Optional[str] = None) -> Dict[str, Any]:
"""Get VM VNC URL by name using the cloud API."""
- headers = {"Authorization": f"Bearer {self.api_key}"}
- async with aiohttp.ClientSession() as session:
- async with session.get(f"https://www.trycua.com/api/vm-host?vm_name={name}", headers=headers) as resp:
- if resp.status == 200:
- vnc_url = (await resp.text()).strip()
- parsed = urlparse(vnc_url)
- hostname = parsed.hostname or ""
- return {"name": name, "status": "available", "vnc_url": vnc_url, "hostname": hostname}
- else:
- try:
- error = await resp.json()
- except Exception:
- error = {"error": await resp.text()}
- return {"name": name, "status": "error", **error}
+ return {"name": name, "hostname": f"{name}.containers.cloud.trycua.com"}
async def list_vms(self) -> List[Dict[str, Any]]:
logger.warning("CloudProvider.list_vms is not implemented")
return []
async def run_vm(self, image: str, name: str, run_opts: Dict[str, Any], storage: Optional[str] = None) -> Dict[str, Any]:
- vm = await self.get_vm(name=name)
- if vm["status"] == "available":
- return vm
logger.warning("CloudProvider.run_vm is not implemented")
return {"name": name, "status": "unavailable", "message": "CloudProvider is not implemented"}
@@ -81,22 +65,11 @@ class CloudProvider(BaseVMProvider):
async def get_ip(self, name: Optional[str] = None, storage: Optional[str] = None, retry_delay: int = 2) -> str:
"""
- Return the VM's IP address as '{vm_name}.us.vms.trycua.com'.
+ Return the VM's IP address as '{vm_name}.containers.cloud.trycua.com'.
Uses the provided 'name' argument (the VM name requested by the caller),
falling back to self.name only if 'name' is None.
Retries up to 3 times with retry_delay seconds if hostname is not available.
"""
if name is None:
raise ValueError("VM name is required for CloudProvider.get_ip")
-
- attempts = 3
- last_error = None
- for attempt in range(attempts):
- result = await self.get_vm(name=name, storage=storage)
- hostname = result.get("hostname")
- if hostname:
- return hostname
- last_error = result.get("error") or result
- if attempt < attempts - 1:
- await asyncio.sleep(retry_delay)
- raise RuntimeError(f"Failed to get VM hostname after {attempts} attempts: {last_error}")
+ return f"{name}.containers.cloud.trycua.com"