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.

Fix remaining stale agent/core namespace references (#1325)

dduponte940238e9508
diff --git a/libs/cua-bench/cua_bench/agents/cua_agent.py b/libs/cua-bench/cua_bench/agents/cua_agent.py
index e4a783a4a3..01b28d1c14 100644
--- a/libs/cua-bench/cua_bench/agents/cua_agent.py
+++ b/libs/cua-bench/cua_bench/agents/cua_agent.py
@@ -202,7 +202,7 @@ class CuaAgent(BaseAgent):
AgentResult with token counts and failure mode
"""
try:
- from agent import ComputerAgent
+ from cua_agent import ComputerAgent
except ImportError as e:
raise RuntimeError(
"cua-agent requires the `cua-agent` package to be installed. "
diff --git a/libs/cua-bench/cua_bench/agents/opencua_agent.py b/libs/cua-bench/cua_bench/agents/opencua_agent.py
index eca1e9cd00..f03a99b57a 100644
--- a/libs/cua-bench/cua_bench/agents/opencua_agent.py
+++ b/libs/cua-bench/cua_bench/agents/opencua_agent.py
@@ -143,7 +143,7 @@ class OpenCUAAgent(BaseAgent):
) -> AgentResult:
"""Run the task using the OpenCUA model via the CUA Computer Agent SDK."""
try:
- from agent import ComputerAgent
+ from cua_agent import ComputerAgent
except ImportError as e:
raise RuntimeError(
"opencua-agent requires the `cua-agent` package to be installed. "
diff --git a/libs/python/agent/cua_agent/__init__.py b/libs/python/agent/cua_agent/__init__.py
index 124604583b..1943219ec0 100644
--- a/libs/python/agent/cua_agent/__init__.py
+++ b/libs/python/agent/cua_agent/__init__.py
@@ -20,7 +20,7 @@ logger = logging.getLogger(__name__)
# Initialize telemetry when the package is imported
try:
# Import from core telemetry for basic functions
- from core.telemetry import (
+ from cua_core.telemetry import (
is_telemetry_enabled,
record_event,
)
diff --git a/libs/python/agent/cua_agent/callbacks/otel.py b/libs/python/agent/cua_agent/callbacks/otel.py
index 2a3e0e156d..e2b53741a3 100644
--- a/libs/python/agent/cua_agent/callbacks/otel.py
+++ b/libs/python/agent/cua_agent/callbacks/otel.py
@@ -15,7 +15,7 @@ from .base import AsyncCallbackHandler
# Import OTEL functions - these are available when cua-core[telemetry] is installed
try:
- from core.telemetry import (
+ from cua_core.telemetry import (
create_span,
is_otel_enabled,
record_error,
diff --git a/libs/python/agent/cua_agent/callbacks/prompt_instructions.py b/libs/python/agent/cua_agent/callbacks/prompt_instructions.py
index e7cf67fc5b..6f1ec00298 100644
--- a/libs/python/agent/cua_agent/callbacks/prompt_instructions.py
+++ b/libs/python/agent/cua_agent/callbacks/prompt_instructions.py
@@ -6,7 +6,7 @@ instructions message to the start of the conversation before each LLM call.
Usage:
- from agent.callbacks import PromptInstructionsCallback
+ from cua_agent.callbacks import PromptInstructionsCallback
agent = ComputerAgent(
model="openai/computer-use-preview",
callbacks=[PromptInstructionsCallback("Follow these rules...")]
diff --git a/libs/python/agent/cua_agent/cli.py b/libs/python/agent/cua_agent/cli.py
index 72f011ed1f..9bdc25d5a4 100644
--- a/libs/python/agent/cua_agent/cli.py
+++ b/libs/python/agent/cua_agent/cli.py
@@ -358,7 +358,7 @@ Examples:
# Import here to avoid import errors if dependencies are missing
try:
- from agent import ComputerAgent
+ from cua_agent import ComputerAgent
from computer import Computer
except ImportError as e:
print_colored(f"❌ Import error: {e}", Colors.RED, bold=True)
diff --git a/libs/python/agent/cua_agent/loops/gemini.py b/libs/python/agent/cua_agent/loops/gemini.py
index 37c45dcad8..9ac5d66734 100644
--- a/libs/python/agent/cua_agent/loops/gemini.py
+++ b/libs/python/agent/cua_agent/loops/gemini.py
@@ -126,7 +126,7 @@ def _create_gemini_client(
http_options: Dict[str, Any] = {"base_url": f"{cua_base_url}/gemini"}
# Include CUA version headers if available
try:
- from core.http import cua_version_headers
+ from cua_core.http import cua_version_headers
hdrs = cua_version_headers()
if hdrs:
diff --git a/libs/python/agent/cua_agent/playground/server.py b/libs/python/agent/cua_agent/playground/server.py
index dd9bd28b4f..eb24058619 100644
--- a/libs/python/agent/cua_agent/playground/server.py
+++ b/libs/python/agent/cua_agent/playground/server.py
@@ -84,7 +84,7 @@ class PlaygroundServer:
"""
# Import here to avoid circular imports
try:
- from agent import ComputerAgent
+ from cua_agent import ComputerAgent
except ImportError:
raise HTTPException(status_code=501, detail="ComputerAgent not available")
diff --git a/libs/python/agent/cua_agent/ui/gradio/ui_components.py b/libs/python/agent/cua_agent/ui/gradio/ui_components.py
index eae5e44e07..31041edcd2 100644
--- a/libs/python/agent/cua_agent/ui/gradio/ui_components.py
+++ b/libs/python/agent/cua_agent/ui/gradio/ui_components.py
@@ -149,7 +149,7 @@ try:
from computer import Computer
except ImportError:
Computer = None # type: ignore[assignment,misc]
-from agent import ComputerAgent
+from cua_agent import ComputerAgent
async def main():
async with Computer{computer_args_str} as computer:
diff --git a/libs/python/core/cua_core/telemetry/otel.py b/libs/python/core/cua_core/telemetry/otel.py
index 2587bb458e..671e7e0f06 100644
--- a/libs/python/core/cua_core/telemetry/otel.py
+++ b/libs/python/core/cua_core/telemetry/otel.py
@@ -226,7 +226,7 @@ def _shutdown_otel() -> None:
def _get_sdk_version() -> str:
"""Get the CUA SDK version."""
try:
- from core import __version__
+ from cua_core import __version__
return __version__
except ImportError:
diff --git a/libs/python/core/cua_core/telemetry/posthog.py b/libs/python/core/cua_core/telemetry/posthog.py
index f560bbced3..35b509d860 100644
--- a/libs/python/core/cua_core/telemetry/posthog.py
+++ b/libs/python/core/cua_core/telemetry/posthog.py
@@ -10,7 +10,7 @@ from pathlib import Path
from typing import Any, Dict, List, Optional
import posthog
-from core import __version__
+from cua_core import __version__
logger = logging.getLogger("core.telemetry")
diff --git a/libs/python/cua-cli/cua_cli/main.py b/libs/python/cua-cli/cua_cli/main.py
index 5aabb711c1..03938b277b 100644
--- a/libs/python/cua-cli/cua_cli/main.py
+++ b/libs/python/cua-cli/cua_cli/main.py
@@ -62,7 +62,7 @@ def main() -> int:
# Suppress noisy INFO logs from dependencies (computer, core.telemetry, etc.)
# Must set on specific loggers since they configure their own handlers at import time
logging.basicConfig(level=logging.WARNING)
- for name in ("computer", "core", "core.telemetry", "httpx", "httpcore", "cua_sandbox"):
+ for name in ("computer", "cua_core", "cua_core.telemetry", "httpx", "httpcore", "cua_sandbox"):
logging.getLogger(name).setLevel(logging.WARNING)
parser = create_parser()
diff --git a/libs/python/cua/cua/__init__.py b/libs/python/cua/cua/__init__.py
index 40be5522d9..eeb35c7289 100644
--- a/libs/python/cua/cua/__init__.py
+++ b/libs/python/cua/cua/__init__.py
@@ -92,10 +92,10 @@ _INTERFACE_NAMES: dict[str, tuple[str, str]] = {
}
_AGENT_NAMES: dict[str, tuple[str, str]] = {
- "ComputerAgent": ("agent", "ComputerAgent"),
- "AgentResponse": ("agent", "AgentResponse"),
- "Messages": ("agent", "Messages"),
- "register_agent": ("agent", "register_agent"),
+ "ComputerAgent": ("cua_agent", "ComputerAgent"),
+ "AgentResponse": ("cua_agent", "AgentResponse"),
+ "Messages": ("cua_agent", "Messages"),
+ "register_agent": ("cua_agent", "register_agent"),
}
_LAZY: dict[str, tuple[str, str]] = {**_RUNTIME_NAMES, **_INTERFACE_NAMES, **_AGENT_NAMES}
diff --git a/tests/test_mcp_server_session_management.py b/tests/test_mcp_server_session_management.py
index 5a5c9fb37d..ef0f58e6d3 100644
--- a/tests/test_mcp_server_session_management.py
+++ b/tests/test_mcp_server_session_management.py
@@ -101,7 +101,7 @@ def server_module():
_install_stub_module("computer", computer_module, stubbed_modules)
# Stub agent module
- agent_module = types.ModuleType("agent")
+ agent_module = types.ModuleType("cua_agent")
class _StubComputerAgent:
def __init__(self, *args, **kwargs):
@@ -121,7 +121,7 @@ def server_module():
agent_module.ComputerAgent = _StubComputerAgent
- _install_stub_module("agent", agent_module, stubbed_modules)
+ _install_stub_module("cua_agent", agent_module, stubbed_modules)
# Stub session manager module
session_manager_module = types.ModuleType("mcp_server.session_manager")
diff --git a/tests/test_mcp_server_streaming.py b/tests/test_mcp_server_streaming.py
index 68aaa55586..cd6f05095d 100644
--- a/tests/test_mcp_server_streaming.py
+++ b/tests/test_mcp_server_streaming.py
@@ -98,7 +98,7 @@ def server_module():
_install_stub_module("computer", computer_module, stubbed_modules)
# Stub agent module so server can import ComputerAgent
- agent_module = types.ModuleType("agent")
+ agent_module = types.ModuleType("cua_agent")
class _StubComputerAgent:
def __init__(self, *args, **kwargs):
@@ -111,7 +111,7 @@ def server_module():
agent_module.ComputerAgent = _StubComputerAgent
- _install_stub_module("agent", agent_module, stubbed_modules)
+ _install_stub_module("cua_agent", agent_module, stubbed_modules)
module_name = "mcp_server_server_under_test"
module_path = Path("libs/python/mcp-server/mcp_server/server.py").resolve()