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,176 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import logging
|
|
3
|
+
import re
|
|
4
|
+
from typing import List, Pattern, Dict, Match
|
|
5
|
+
from typing import Union, Any, TypeVar, Callable
|
|
6
|
+
|
|
7
|
+
from .utils import _match_record
|
|
8
|
+
from .utils import _match_value_to_rule as _match_pref
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger("desktopenv.metric.thunderbird")
|
|
11
|
+
|
|
12
|
+
V = TypeVar("Value")
|
|
13
|
+
|
|
14
|
+
_pref_pattern: Pattern[str] = re.compile(r'^user_pref\("(?P<key>(?:[^"]|\\")+)\", (?P<val>.+)\);$');
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def check_thunderbird_prefs(result: str, rule: Dict[str, Dict[str, Dict[str, Any]]]):
|
|
18
|
+
"""
|
|
19
|
+
Args:
|
|
20
|
+
result (str): path to result file
|
|
21
|
+
rule (Dict[str, Dict[str, Dict[str, Any]]]): dict like
|
|
22
|
+
{
|
|
23
|
+
"expect": {
|
|
24
|
+
str: {
|
|
25
|
+
"method": str
|
|
26
|
+
"ref": something
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
"unexpect": {
|
|
30
|
+
str: {
|
|
31
|
+
"method": str
|
|
32
|
+
"ref": something
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
float
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
if result is None:
|
|
42
|
+
return 0.
|
|
43
|
+
|
|
44
|
+
expect_rules = rule.get("expect", {})
|
|
45
|
+
unexpect_rules = rule.get("unexpect", {})
|
|
46
|
+
|
|
47
|
+
expect_metrics = {k: False for k in expect_rules}
|
|
48
|
+
unexpect_metric = True
|
|
49
|
+
with open(result) as f:
|
|
50
|
+
for l in f:
|
|
51
|
+
match_: Match[str] = _pref_pattern.match(l.strip())
|
|
52
|
+
if match_ is None:
|
|
53
|
+
continue
|
|
54
|
+
|
|
55
|
+
key: str = match_.group("key")
|
|
56
|
+
# value: str = match_.group("val")
|
|
57
|
+
# if value in {"true", "false"}:
|
|
58
|
+
# value = value.title()
|
|
59
|
+
# value: V = eval(value)
|
|
60
|
+
value = json.loads(match_.group("val"))
|
|
61
|
+
if key in expect_rules:
|
|
62
|
+
logger.debug("K: %s, V: %s", key, repr(value))
|
|
63
|
+
expect_metrics[key] = _match_pref(value, expect_rules[key])
|
|
64
|
+
elif key in unexpect_rules:
|
|
65
|
+
unexpect_metric = unexpect_metric and not _match_pref(value, unexpect_rules[key])
|
|
66
|
+
|
|
67
|
+
return float(all(expect_metrics.values()) and unexpect_metric)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
_value_processor: Callable[[str], str] = lambda val: val.replace("\\\"", "\"").replace("\\\\", "\\")
|
|
71
|
+
# _condition_pattern: Pattern[str] = re.compile(r'(?P<type>AND|OR) \((?P<key>[\w ]+),(?P<rel>[\w ' + '\'' + r']+),(?:"(?P<val2>(?:[^"]|\")+)"|(?P<val1>[^)]+))\)')
|
|
72
|
+
_condition_pattern: Pattern[str] = re.compile(
|
|
73
|
+
r'\b(?:AND|OR) \((?:[\w ]+),(?:[\w ' + '\'' + r']+),(?:"(?:(?:[^"]|\")+)"|(?:[^)]+))\)|\bALL\b')
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def check_thunderbird_filter(result: str, rules: Dict[str, List[Dict[str, str]]]) -> float:
|
|
77
|
+
"""
|
|
78
|
+
Args:
|
|
79
|
+
result (str): path to filter def file
|
|
80
|
+
rules (Dict[str, List[Dict[str, str]]]): dict like
|
|
81
|
+
{
|
|
82
|
+
"expect": [{key: value}]
|
|
83
|
+
"unexpect": [{key: value}]
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
float
|
|
88
|
+
"""
|
|
89
|
+
|
|
90
|
+
if result is None:
|
|
91
|
+
return 0.
|
|
92
|
+
|
|
93
|
+
# read filter def file
|
|
94
|
+
# a filter:
|
|
95
|
+
# {
|
|
96
|
+
# "name": "Name",
|
|
97
|
+
# "enabled": "yes" | "no",
|
|
98
|
+
# "type": "17",
|
|
99
|
+
# "action": "Move to folder" | ...,
|
|
100
|
+
# "actionValue": ...,
|
|
101
|
+
# "condition": [...]
|
|
102
|
+
# }
|
|
103
|
+
filters: List[Dict[str, Union[str, List[str]]]] = []
|
|
104
|
+
with open(result) as f:
|
|
105
|
+
for l in f:
|
|
106
|
+
if l.startswith("name="):
|
|
107
|
+
filter_: Dict[str, Union[str, List[str]]] = {}
|
|
108
|
+
filter_["name"] = _value_processor(l[6:-2])
|
|
109
|
+
elif l.startswith("enabled="):
|
|
110
|
+
filter_["enabled"] = _value_processor(l[9:-2])
|
|
111
|
+
elif l.startswith("type="):
|
|
112
|
+
filter_["type"] = _value_processor(l[6:-2])
|
|
113
|
+
elif l.startswith("action="):
|
|
114
|
+
filter_["action"] = _value_processor(l[8:-2])
|
|
115
|
+
elif l.startswith("actionValue="):
|
|
116
|
+
filter_["actionValue"] = _value_processor(l[13:-2])
|
|
117
|
+
elif l.startswith("condition="):
|
|
118
|
+
condition_str: str = _value_processor(l[11:-2])
|
|
119
|
+
logger.debug("FILTER CONDITION: %s", condition_str)
|
|
120
|
+
|
|
121
|
+
conditions: List[str] = \
|
|
122
|
+
_condition_pattern.findall(condition_str)
|
|
123
|
+
logger.debug("FILTER CONDITIONS: %s", repr(conditions))
|
|
124
|
+
|
|
125
|
+
filter_["condition"] = conditions
|
|
126
|
+
logger.debug("FILTER %s", repr(filter_))
|
|
127
|
+
filters.append(filter_)
|
|
128
|
+
|
|
129
|
+
expect_metrics = [False] * len(rules.get("expect", []))
|
|
130
|
+
unexpect_metric = True
|
|
131
|
+
for flt in filters:
|
|
132
|
+
for i, r in enumerate(rules.get("expect", [])):
|
|
133
|
+
expect_metrics[i] = expect_metrics[i] or _match_record(r, flt)
|
|
134
|
+
unexpect_metric = unexpect_metric and not any(_match_record(r, flt) for r in rules.get("unexpect", []))
|
|
135
|
+
return float(all(expect_metrics) and unexpect_metric)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def check_thunderbird_folder(result: Union[str, List[str]], reference: Union[str, List[str]], **kwargs) -> float:
|
|
139
|
+
"""
|
|
140
|
+
Check the file or file_list that each text file contains all messages in a folder in Thunderbird. Each message is started with `FROM - `.
|
|
141
|
+
**kwargs:
|
|
142
|
+
ignore_status (bool): for comparison, ignore the status (X-Mozilla-Status: 0000) of each message. default: False
|
|
143
|
+
ignore_keys (bool): for comparison, ignore the keys (X-Mozilla-Keys: label) of each message. default: False
|
|
144
|
+
remove_deleted (bool): ignore deleted messages which has status code 0008 or 0009. default: True
|
|
145
|
+
remove_duplicate (bool): remove duplicate messages. default: True
|
|
146
|
+
"""
|
|
147
|
+
|
|
148
|
+
def normalize_msg(msg, options):
|
|
149
|
+
ignore_status = options.get('ignore_status', False)
|
|
150
|
+
ignore_keys = options.get('ignore_keys', False)
|
|
151
|
+
if ignore_status:
|
|
152
|
+
msg = re.sub(r'X-Mozilla-Status\d?:[\s\d]+', '', msg)
|
|
153
|
+
if ignore_keys:
|
|
154
|
+
msg = re.sub(r'(X-Mozilla-Keys:[^\n]*?)\n(MIME-Version)', r'\2', msg)
|
|
155
|
+
return msg.strip()
|
|
156
|
+
|
|
157
|
+
def read_thunderbird_folder_file(path: str) -> str:
|
|
158
|
+
with open(path, 'r') as inf:
|
|
159
|
+
data = inf.read().strip()
|
|
160
|
+
messages = []
|
|
161
|
+
for mail in data.split('FROM - '):
|
|
162
|
+
if mail.strip(): continue
|
|
163
|
+
if kwargs.get('remove_deleted', True) and re.search(r'X-Mozilla-Status: 000[89]', mail): continue
|
|
164
|
+
messages.append('FROM - ' + normalize_msg(mail, kwargs))
|
|
165
|
+
if kwargs.get('remove_duplicate', True):
|
|
166
|
+
messages = set(messages)
|
|
167
|
+
return '\n'.join(sorted(messages))
|
|
168
|
+
|
|
169
|
+
if type(reference) != list:
|
|
170
|
+
result, reference = [result], [reference]
|
|
171
|
+
for pred, gold in zip(result, reference):
|
|
172
|
+
if pred is None: return .0
|
|
173
|
+
mail1 = read_thunderbird_folder_file(pred)
|
|
174
|
+
mail2 = read_thunderbird_folder_file(gold)
|
|
175
|
+
if mail1 != mail2: return .0
|
|
176
|
+
return 1.0
|