lybic-guiagents 0.1.0__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.
Potentially problematic release.
This version of lybic-guiagents might be problematic. Click here for more details.
- desktop_env/__init__.py +1 -0
- desktop_env/actions.py +203 -0
- desktop_env/controllers/__init__.py +0 -0
- desktop_env/controllers/python.py +471 -0
- desktop_env/controllers/setup.py +882 -0
- desktop_env/desktop_env.py +509 -0
- desktop_env/evaluators/__init__.py +5 -0
- desktop_env/evaluators/getters/__init__.py +41 -0
- desktop_env/evaluators/getters/calc.py +15 -0
- desktop_env/evaluators/getters/chrome.py +1774 -0
- desktop_env/evaluators/getters/file.py +154 -0
- desktop_env/evaluators/getters/general.py +42 -0
- desktop_env/evaluators/getters/gimp.py +38 -0
- desktop_env/evaluators/getters/impress.py +126 -0
- desktop_env/evaluators/getters/info.py +24 -0
- desktop_env/evaluators/getters/misc.py +406 -0
- desktop_env/evaluators/getters/replay.py +20 -0
- desktop_env/evaluators/getters/vlc.py +86 -0
- desktop_env/evaluators/getters/vscode.py +35 -0
- desktop_env/evaluators/metrics/__init__.py +160 -0
- desktop_env/evaluators/metrics/basic_os.py +68 -0
- desktop_env/evaluators/metrics/chrome.py +493 -0
- desktop_env/evaluators/metrics/docs.py +1011 -0
- desktop_env/evaluators/metrics/general.py +665 -0
- desktop_env/evaluators/metrics/gimp.py +637 -0
- desktop_env/evaluators/metrics/libreoffice.py +28 -0
- desktop_env/evaluators/metrics/others.py +92 -0
- desktop_env/evaluators/metrics/pdf.py +31 -0
- desktop_env/evaluators/metrics/slides.py +957 -0
- desktop_env/evaluators/metrics/table.py +585 -0
- desktop_env/evaluators/metrics/thunderbird.py +176 -0
- desktop_env/evaluators/metrics/utils.py +719 -0
- desktop_env/evaluators/metrics/vlc.py +524 -0
- desktop_env/evaluators/metrics/vscode.py +283 -0
- desktop_env/providers/__init__.py +35 -0
- desktop_env/providers/aws/__init__.py +0 -0
- desktop_env/providers/aws/manager.py +278 -0
- desktop_env/providers/aws/provider.py +186 -0
- desktop_env/providers/aws/provider_with_proxy.py +315 -0
- desktop_env/providers/aws/proxy_pool.py +193 -0
- desktop_env/providers/azure/__init__.py +0 -0
- desktop_env/providers/azure/manager.py +87 -0
- desktop_env/providers/azure/provider.py +207 -0
- desktop_env/providers/base.py +97 -0
- desktop_env/providers/gcp/__init__.py +0 -0
- desktop_env/providers/gcp/manager.py +0 -0
- desktop_env/providers/gcp/provider.py +0 -0
- desktop_env/providers/virtualbox/__init__.py +0 -0
- desktop_env/providers/virtualbox/manager.py +463 -0
- desktop_env/providers/virtualbox/provider.py +124 -0
- desktop_env/providers/vmware/__init__.py +0 -0
- desktop_env/providers/vmware/manager.py +455 -0
- desktop_env/providers/vmware/provider.py +105 -0
- gui_agents/__init__.py +0 -0
- gui_agents/agents/Action.py +209 -0
- gui_agents/agents/__init__.py +0 -0
- gui_agents/agents/agent_s.py +832 -0
- gui_agents/agents/global_state.py +610 -0
- gui_agents/agents/grounding.py +651 -0
- gui_agents/agents/hardware_interface.py +129 -0
- gui_agents/agents/manager.py +568 -0
- gui_agents/agents/translator.py +132 -0
- gui_agents/agents/worker.py +355 -0
- gui_agents/cli_app.py +560 -0
- gui_agents/core/__init__.py +0 -0
- gui_agents/core/engine.py +1496 -0
- gui_agents/core/knowledge.py +449 -0
- gui_agents/core/mllm.py +555 -0
- gui_agents/tools/__init__.py +0 -0
- gui_agents/tools/tools.py +727 -0
- gui_agents/unit_test/__init__.py +0 -0
- gui_agents/unit_test/run_tests.py +65 -0
- gui_agents/unit_test/test_manager.py +330 -0
- gui_agents/unit_test/test_worker.py +269 -0
- gui_agents/utils/__init__.py +0 -0
- gui_agents/utils/analyze_display.py +301 -0
- gui_agents/utils/common_utils.py +263 -0
- gui_agents/utils/display_viewer.py +281 -0
- gui_agents/utils/embedding_manager.py +53 -0
- gui_agents/utils/image_axis_utils.py +27 -0
- lybic_guiagents-0.1.0.dist-info/METADATA +416 -0
- lybic_guiagents-0.1.0.dist-info/RECORD +85 -0
- lybic_guiagents-0.1.0.dist-info/WHEEL +5 -0
- lybic_guiagents-0.1.0.dist-info/licenses/LICENSE +201 -0
- lybic_guiagents-0.1.0.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
"""actions.py ▸ Unified Action primitives with helper registry
|
|
3
|
+
-------------------------------------------------------------------
|
|
4
|
+
This module defines *declarative* GUI/OS operations as tiny dataclasses
|
|
5
|
+
("Actions"). An **Action** describes *what* should be done — **not** *how* it
|
|
6
|
+
is executed. Concrete back‑ends (PyAutoGUI, ADB, cloud device API …) are free
|
|
7
|
+
to translate the intent into platform‑specific commands.
|
|
8
|
+
|
|
9
|
+
Key features
|
|
10
|
+
============
|
|
11
|
+
1. **Registry‑based reflection** – Every Action subclass registers itself in
|
|
12
|
+
`Action._registry` at import‑time.
|
|
13
|
+
2. **(De)serialisation** – Each Action can be converted to / from a plain
|
|
14
|
+
`dict` (JSON‑safe) via `to_dict()` / `from_dict()`.
|
|
15
|
+
3. **Type safety & docs** – `dataclass`+`Enum` give IDE hints & runtime checks.
|
|
16
|
+
|
|
17
|
+
Typical workflow
|
|
18
|
+
----------------
|
|
19
|
+
```python
|
|
20
|
+
>>> from actions import click, drag, action
|
|
21
|
+
>>> a1 = click(x = 200, y = 300)
|
|
22
|
+
>>> payload = a1.to_dict() # ➜ {"type": "click", "x": 200, "y": 300], ...}
|
|
23
|
+
>>> a2 = Action.from_dict(payload) # ➜ click(x=200, y=300, ...)
|
|
24
|
+
>>> assert a1 == a2
|
|
25
|
+
```
|
|
26
|
+
The registry makes the last line work without an if‑else chain.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
from abc import ABC
|
|
30
|
+
from dataclasses import dataclass, field, fields, asdict
|
|
31
|
+
from enum import Enum, auto
|
|
32
|
+
from typing import Any, Dict, List, Tuple, Type, TypeVar, ClassVar
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
"Action",
|
|
36
|
+
# concrete actions ↓
|
|
37
|
+
"Click",
|
|
38
|
+
"DoubleClick",
|
|
39
|
+
"Move",
|
|
40
|
+
"Scroll",
|
|
41
|
+
"Drag",
|
|
42
|
+
"TypeText",
|
|
43
|
+
"Hotkey",
|
|
44
|
+
"Wait",
|
|
45
|
+
"Done",
|
|
46
|
+
"Fail",
|
|
47
|
+
"Screenshot",
|
|
48
|
+
"Memorize",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
T_Action = TypeVar("T_Action", bound="Action")
|
|
52
|
+
|
|
53
|
+
# ---------------------------------------------------------------------------
|
|
54
|
+
# Action base‑class with helper registry
|
|
55
|
+
# ---------------------------------------------------------------------------
|
|
56
|
+
@dataclass(slots=True)
|
|
57
|
+
class Action(ABC):
|
|
58
|
+
"""Abstract base for every declarative GUI operation."""
|
|
59
|
+
|
|
60
|
+
# Global registry {"Click": Click, ...}
|
|
61
|
+
_registry: ClassVar[Dict[str, Type["Action"]]] = {}
|
|
62
|
+
|
|
63
|
+
# ---------------------------------------------------------------------
|
|
64
|
+
# Reflection helpers
|
|
65
|
+
# ---------------------------------------------------------------------
|
|
66
|
+
def __init_subclass__(cls, **kwargs): # noqa: D401 (docstring from base)
|
|
67
|
+
# super().__init_subclass__(**kwargs)
|
|
68
|
+
Action._registry[cls.__name__] = cls
|
|
69
|
+
|
|
70
|
+
# ------------------------------------------------------------------
|
|
71
|
+
# (de)serialisation utilities
|
|
72
|
+
# ------------------------------------------------------------------
|
|
73
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
74
|
+
"""Return a JSON‑serialisable dict with a "type" discriminator."""
|
|
75
|
+
data = {"type": self.__class__.__name__}
|
|
76
|
+
for f in fields(self):
|
|
77
|
+
val = getattr(self, f.name)
|
|
78
|
+
data[f.name] = _enum_to_name(val)
|
|
79
|
+
return data
|
|
80
|
+
|
|
81
|
+
@classmethod
|
|
82
|
+
def from_dict(cls: Type[T_Action], data: Dict[str, Any]) -> T_Action: # noqa: N802 (cls)
|
|
83
|
+
if "type" not in data:
|
|
84
|
+
raise ValueError("Missing 'type' key in action dict")
|
|
85
|
+
typ = data["type"]
|
|
86
|
+
if typ not in cls._registry:
|
|
87
|
+
raise ValueError(f"Unknown action type '{typ}' (registry size={len(cls._registry)})")
|
|
88
|
+
target_cls = cls._registry[typ]
|
|
89
|
+
|
|
90
|
+
# Convert strings back to Enum instances where needed
|
|
91
|
+
kwargs = {}
|
|
92
|
+
for f in fields(target_cls):
|
|
93
|
+
raw = data.get(f.name)
|
|
94
|
+
kwargs[f.name] = _name_to_enum(f.type, raw)
|
|
95
|
+
return target_cls(**kwargs) # type: ignore[arg-type]
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
# ---------------------------------------------------------------------------
|
|
99
|
+
# Helper functions for Enum <-> str
|
|
100
|
+
# ---------------------------------------------------------------------------
|
|
101
|
+
|
|
102
|
+
def _enum_to_name(val: Any) -> Any:
|
|
103
|
+
if isinstance(val, Enum):
|
|
104
|
+
return val.name
|
|
105
|
+
if isinstance(val, tuple):
|
|
106
|
+
return list(val) # json‑friendly
|
|
107
|
+
if isinstance(val, list):
|
|
108
|
+
return [_enum_to_name(v) for v in val]
|
|
109
|
+
return val
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _name_to_enum(expected_type: Any, raw: Any) -> Any:
|
|
113
|
+
"""Convert *raw* back to Enum or original type depending on *expected_type*."""
|
|
114
|
+
origin = getattr(expected_type, "__origin__", None)
|
|
115
|
+
if origin is list:
|
|
116
|
+
sub_type = expected_type.__args__[0]
|
|
117
|
+
return [_name_to_enum(sub_type, r) for r in raw] if isinstance(raw, list) else raw
|
|
118
|
+
|
|
119
|
+
if isinstance(expected_type, type) and issubclass(expected_type, Enum):
|
|
120
|
+
return expected_type[raw] if isinstance(raw, str) else raw
|
|
121
|
+
# Fallback – pass through unchanged
|
|
122
|
+
return raw
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
# ---------------------------------------------------------------------------
|
|
126
|
+
# Concrete Action subclasses
|
|
127
|
+
# ---------------------------------------------------------------------------
|
|
128
|
+
@dataclass(slots=True)
|
|
129
|
+
class Click(Action):
|
|
130
|
+
x: int
|
|
131
|
+
y: int
|
|
132
|
+
element_description: str
|
|
133
|
+
button: int = 0
|
|
134
|
+
holdKey: List[str] = field(default_factory=list)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@dataclass(slots=True)
|
|
138
|
+
class DoubleClick(Action):
|
|
139
|
+
x: int
|
|
140
|
+
y: int
|
|
141
|
+
element_description: str
|
|
142
|
+
button: int = 0
|
|
143
|
+
holdKey: List[str] = field(default_factory=list)
|
|
144
|
+
|
|
145
|
+
@dataclass(slots=True)
|
|
146
|
+
class Move(Action):
|
|
147
|
+
x: int
|
|
148
|
+
y: int
|
|
149
|
+
element_description: str
|
|
150
|
+
holdKey: List[str] = field(default_factory=list)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
@dataclass(slots=True)
|
|
154
|
+
class Scroll(Action):
|
|
155
|
+
x: int
|
|
156
|
+
y: int
|
|
157
|
+
element_description: str
|
|
158
|
+
stepVertical: int | None = None
|
|
159
|
+
stepHorizontal: int | None = None
|
|
160
|
+
holdKey: List[str] = field(default_factory=list)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
# TODO Drag是否需要区分左中右键
|
|
165
|
+
@dataclass(slots=True)
|
|
166
|
+
class Drag(Action):
|
|
167
|
+
startX: int
|
|
168
|
+
startY: int
|
|
169
|
+
endX: int
|
|
170
|
+
endY: int
|
|
171
|
+
holdKey: List[str]
|
|
172
|
+
starting_description: str
|
|
173
|
+
ending_description: str
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
@dataclass(slots=True)
|
|
177
|
+
class TypeText(Action):
|
|
178
|
+
text: str
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
@dataclass(slots=True)
|
|
182
|
+
class Hotkey(Action):
|
|
183
|
+
keys: List[str]
|
|
184
|
+
duration: int | None = None
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
@dataclass(slots=True)
|
|
188
|
+
class Wait(Action):
|
|
189
|
+
duration: int
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
@dataclass(slots=True)
|
|
193
|
+
class Done(Action):
|
|
194
|
+
return_value: Any | None = None
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
@dataclass(slots=True)
|
|
198
|
+
class Failed(Action):
|
|
199
|
+
message: str = ''
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
@dataclass(slots=True)
|
|
203
|
+
class Memorize(Action):
|
|
204
|
+
information: str
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
@dataclass(slots=True)
|
|
208
|
+
class Screenshot(Action):
|
|
209
|
+
pass
|
|
File without changes
|