Jarvis-Brain 0.1.7.3__py3-none-any.whl → 0.1.7.6__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.
- {jarvis_brain-0.1.7.3.dist-info → jarvis_brain-0.1.7.6.dist-info}/METADATA +1 -1
- jarvis_brain-0.1.7.6.dist-info/RECORD +11 -0
- mcp_tools/__init__.py +4 -0
- mcp_tools/dp_tools.py +5 -3
- tools/browser_proxy.py +18 -10
- jarvis_brain-0.1.7.3.dist-info/RECORD +0 -11
- {jarvis_brain-0.1.7.3.dist-info → jarvis_brain-0.1.7.6.dist-info}/WHEEL +0 -0
- {jarvis_brain-0.1.7.3.dist-info → jarvis_brain-0.1.7.6.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
mcp_tools/__init__.py,sha256=nqhlHRalTYQF8gU5RBfanOn-zSONLYON1mjPIvP-f4w,113
|
|
2
|
+
mcp_tools/dp_tools.py,sha256=KVeIEGSTMLhBsGXRA9n01zH2WSBVuRl3nzgJ-R1GTgk,10796
|
|
3
|
+
mcp_tools/main.py,sha256=Fdt2N3oKGwvruuno_ywnuWSlm1BexE9ZY669H2LTo9w,1056
|
|
4
|
+
tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
tools/browser_manager.py,sha256=EXM7n-sDOtdQGpWkVTAZHWhepVU-7PAoUTDNgGF9_fQ,1938
|
|
6
|
+
tools/browser_proxy.py,sha256=cdMRxcUYyaOqGU17lldltHOvt9rxXD5Dwh7hBXEBby4,6780
|
|
7
|
+
tools/tools.py,sha256=TaWs-CNXy-py9BFmCnJrQ09ke938xXpImf-N2Qo_Rvc,4708
|
|
8
|
+
jarvis_brain-0.1.7.6.dist-info/METADATA,sha256=rsmZj5uJPcxFZh52xRxwf3TPjyFMMq3ppwV4fGwUGQA,241
|
|
9
|
+
jarvis_brain-0.1.7.6.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
10
|
+
jarvis_brain-0.1.7.6.dist-info/entry_points.txt,sha256=YFQT4xpkUqt5dM5wlKPQQOqcjMuFrT9iuRAzIpAyH7U,51
|
|
11
|
+
jarvis_brain-0.1.7.6.dist-info/RECORD,,
|
mcp_tools/__init__.py
CHANGED
mcp_tools/dp_tools.py
CHANGED
|
@@ -15,7 +15,7 @@ waf_status_code_dict = {
|
|
|
15
15
|
521: "加速乐"
|
|
16
16
|
}
|
|
17
17
|
# 一轮最大输入,以免单个html最大长度超过ai最大输入
|
|
18
|
-
|
|
18
|
+
one_turn_max_token = 25000
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
def register_visit_url(mcp: FastMCP, browser_manager: BrowserManager, client_manager: DPProxyClientManager):
|
|
@@ -46,7 +46,7 @@ def register_get_html(mcp: FastMCP, browser_manager, client_manager: DPProxyClie
|
|
|
46
46
|
if not os.path.exists(html_source_code_local_save_path):
|
|
47
47
|
os.makedirs(html_source_code_local_save_path)
|
|
48
48
|
min_html, compress_rate = compress_html(tab.html)
|
|
49
|
-
html_str_list = [min_html[i:i +
|
|
49
|
+
html_str_list = [min_html[i:i + one_turn_max_token] for i in range(0, len(min_html), one_turn_max_token)]
|
|
50
50
|
html_file_list = []
|
|
51
51
|
for index, html_str in enumerate(html_str_list):
|
|
52
52
|
file_name = file_name_prefix + f"_{tab_id}_segment{index}.html"
|
|
@@ -105,6 +105,8 @@ def register_check_selector(mcp: FastMCP, browser_manager, client_manager: DPPro
|
|
|
105
105
|
attr_output = "\n".join(ele_text_list)
|
|
106
106
|
else:
|
|
107
107
|
attr_output = json.dumps([i.attr(attr_name) for i in target_eles])
|
|
108
|
+
# 对attr_output逐个截断,截断的长度为:一轮最大token除以元素个数+6个点
|
|
109
|
+
attr_output = [attr_str[:one_turn_max_token // (len(attr_str) + 6)] + "......" for attr_str in attr_output]
|
|
108
110
|
return dp_mcp_message_pack(
|
|
109
111
|
f"已完成tab页:【{tab_id}】对:【{css_selector}】的检查",
|
|
110
112
|
tab_id=tab_id,
|
|
@@ -129,7 +131,7 @@ def register_quit_browser(mcp: FastMCP, browser_manager, client_manager: DPProxy
|
|
|
129
131
|
|
|
130
132
|
def register_pop_first_packet(mcp: FastMCP, browser_manager, client_manager: DPProxyClientManager):
|
|
131
133
|
@mcp.tool(name="pop_first_packet",
|
|
132
|
-
description="每调用一次就会弹出传入的tab页所监听到的数据包中的第一个packet_message")
|
|
134
|
+
description="每调用一次就会弹出传入的tab页所监听到的数据包中的第一个packet_message,当一个packet_message的response body过长时会被切分成多个包,具体一个请求是否还有下一个包,可以参考body_completed字段")
|
|
133
135
|
async def pop_first_packet(browser_port: int, tab_id: str) -> dict[str, Any]:
|
|
134
136
|
_browser = browser_manager.get_browser(browser_port)
|
|
135
137
|
client = client_manager.get_client(tab_id)
|
tools/browser_proxy.py
CHANGED
|
@@ -7,6 +7,8 @@ from DrissionPage._units.listener import DataPacket
|
|
|
7
7
|
from typing import Tuple, Optional
|
|
8
8
|
import json
|
|
9
9
|
|
|
10
|
+
one_turn_max_token = 20000
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
class DPProxyClient:
|
|
12
14
|
def __init__(self, driver: ChromiumTab, self_kill=False):
|
|
@@ -134,16 +136,22 @@ def check_data_packet(packet: DataPacket, client: DPProxyClient):
|
|
|
134
136
|
if packet.request.hasPostData:
|
|
135
137
|
data = packet.request.postData
|
|
136
138
|
body = packet.response.body
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
139
|
+
body_str = json.dumps(body, ensure_ascii=False)
|
|
140
|
+
body_str_list = [body_str[i:i + one_turn_max_token] for i in range(0, len(body_str), one_turn_max_token)]
|
|
141
|
+
body_completed = True
|
|
142
|
+
for index, body_str in enumerate(body_str_list):
|
|
143
|
+
if (index + 1) != len(body_str_list):
|
|
144
|
+
body_completed = False
|
|
145
|
+
temp_dict = {
|
|
146
|
+
"url": url,
|
|
147
|
+
"body_completed": body_completed,
|
|
148
|
+
"method": method,
|
|
149
|
+
"request_data": data,
|
|
150
|
+
"request_headers": dict(packet.request.headers),
|
|
151
|
+
"response_headers": dict(packet.response.headers),
|
|
152
|
+
"response_body_segment": body_str,
|
|
153
|
+
}
|
|
154
|
+
client.packet_queue.append(temp_dict)
|
|
147
155
|
|
|
148
156
|
|
|
149
157
|
client_manager = DPProxyClientManager()
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
mcp_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
mcp_tools/dp_tools.py,sha256=LT2x9edWmmDqNoy66zPgwjUSLpYbMPUPluvDoAXs0FU,10421
|
|
3
|
-
mcp_tools/main.py,sha256=Fdt2N3oKGwvruuno_ywnuWSlm1BexE9ZY669H2LTo9w,1056
|
|
4
|
-
tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
tools/browser_manager.py,sha256=EXM7n-sDOtdQGpWkVTAZHWhepVU-7PAoUTDNgGF9_fQ,1938
|
|
6
|
-
tools/browser_proxy.py,sha256=ii4GCKOU-R6Uoj1I3k4RMqtuLOiddd4WAjG5WGc51F8,6359
|
|
7
|
-
tools/tools.py,sha256=TaWs-CNXy-py9BFmCnJrQ09ke938xXpImf-N2Qo_Rvc,4708
|
|
8
|
-
jarvis_brain-0.1.7.3.dist-info/METADATA,sha256=62mF8nqQZcrtOJtlTzUODlHGpUvpg9FcuisQDAtnwIs,241
|
|
9
|
-
jarvis_brain-0.1.7.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
10
|
-
jarvis_brain-0.1.7.3.dist-info/entry_points.txt,sha256=YFQT4xpkUqt5dM5wlKPQQOqcjMuFrT9iuRAzIpAyH7U,51
|
|
11
|
-
jarvis_brain-0.1.7.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|