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 hotkeys on uitars and openai provider

Dillon DuPont1df8194de137
diff --git a/libs/agent/agent/providers/openai/tools/computer.py b/libs/agent/agent/providers/openai/tools/computer.py
index 5ec9460af4..90ef593540 100644
--- a/libs/agent/agent/providers/openai/tools/computer.py
+++ b/libs/agent/agent/providers/openai/tools/computer.py
@@ -240,11 +240,7 @@ class ComputerTool(BaseComputerTool, BaseOpenAITool):
if len(mapped_keys) > 1:
# For key combinations (like Ctrl+C)
- for k in mapped_keys:
- await self.computer.interface.press_key(k)
- await asyncio.sleep(0.1)
- for k in reversed(mapped_keys):
- await self.computer.interface.press_key(k)
+ await self.computer.interface.hotkey(*mapped_keys)
else:
# Single key press
await self.computer.interface.press_key(mapped_keys[0])
diff --git a/libs/agent/agent/providers/uitars/tools/computer.py b/libs/agent/agent/providers/uitars/tools/computer.py
index 5cf7f67aad..4d5f2ce398 100644
--- a/libs/agent/agent/providers/uitars/tools/computer.py
+++ b/libs/agent/agent/providers/uitars/tools/computer.py
@@ -173,9 +173,13 @@ class ComputerTool(BaseComputerTool):
elif action == "hotkey":
if "keys" in kwargs:
keys = kwargs["keys"]
- for key in keys:
- await self.computer.interface.press_key(key)
+ if len(keys) > 1:
+ await self.computer.interface.hotkey(*keys)
+ else:
+ # Single key press
+ await self.computer.interface.press_key(keys[0])
+
# Wait for UI to update
await asyncio.sleep(0.3)
diff --git a/libs/computer/computer/interface/models.py b/libs/computer/computer/interface/models.py
index 9a90acb464..e8ec1b4710 100644
--- a/libs/computer/computer/interface/models.py
+++ b/libs/computer/computer/interface/models.py
@@ -8,7 +8,7 @@ NavigationKey = Literal['pagedown', 'pageup', 'home', 'end', 'left', 'right', 'u
SpecialKey = Literal['enter', 'esc', 'tab', 'space', 'backspace', 'del']
# Modifier key literals
-ModifierKey = Literal['ctrl', 'shift', 'win', 'command', 'option']
+ModifierKey = Literal['ctrl', 'alt', 'shift', 'win', 'command', 'option']
# Function key literals
FunctionKey = Literal['f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12']
@@ -39,6 +39,7 @@ class Key(Enum):
DELETE = 'del'
# Modifier keys
+ ALT = 'alt'
CTRL = 'ctrl'
SHIFT = 'shift'
WIN = 'win'
@@ -85,6 +86,7 @@ class Key(Enum):
'delete': cls.DELETE,
'del': cls.DELETE,
# Modifier key mappings
+ 'alt': cls.ALT,
'ctrl': cls.CTRL,
'control': cls.CTRL,
'shift': cls.SHIFT,
@@ -95,7 +97,6 @@ class Key(Enum):
'cmd': cls.COMMAND,
'⌘': cls.COMMAND,
'option': cls.OPTION,
- 'alt': cls.OPTION,
'⌥': cls.OPTION,
}