Jarvis-Brain 0.1.8.2__py3-none-any.whl → 0.1.8.4__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.8.2.dist-info → jarvis_brain-0.1.8.4.dist-info}/METADATA +1 -1
- {jarvis_brain-0.1.8.2.dist-info → jarvis_brain-0.1.8.4.dist-info}/RECORD +6 -6
- mcp_tools/dp_tools.py +4 -3
- tools/browser_proxy.py +12 -3
- {jarvis_brain-0.1.8.2.dist-info → jarvis_brain-0.1.8.4.dist-info}/WHEEL +0 -0
- {jarvis_brain-0.1.8.2.dist-info → jarvis_brain-0.1.8.4.dist-info}/entry_points.txt +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
mcp_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
mcp_tools/dp_tools.py,sha256=
|
|
2
|
+
mcp_tools/dp_tools.py,sha256=t6bIFL2aQffEi0-_LxQyQ85mmqjlL9dKQOkAsXrc8nk,13529
|
|
3
3
|
mcp_tools/main.py,sha256=1oM11IvEfwBvJ4bigIQzr2AigTISX-LIJ63oFtYnwFY,1049
|
|
4
4
|
tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
tools/browser_manager.py,sha256=zeYcWuzxoohMdnYUoZbRH7axFC_VtV8MsncfN8y0yw0,2023
|
|
6
|
-
tools/browser_proxy.py,sha256=
|
|
6
|
+
tools/browser_proxy.py,sha256=IParxZihWU7IJP9AGJN8tFX_Iy9yI3aEAd0Blfq_oRM,7438
|
|
7
7
|
tools/tools.py,sha256=TaWs-CNXy-py9BFmCnJrQ09ke938xXpImf-N2Qo_Rvc,4708
|
|
8
|
-
jarvis_brain-0.1.8.
|
|
9
|
-
jarvis_brain-0.1.8.
|
|
10
|
-
jarvis_brain-0.1.8.
|
|
11
|
-
jarvis_brain-0.1.8.
|
|
8
|
+
jarvis_brain-0.1.8.4.dist-info/METADATA,sha256=xkJzI314AzlUuappXsbRgBzGj8zythhwKi4cEEVid6Y,241
|
|
9
|
+
jarvis_brain-0.1.8.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
10
|
+
jarvis_brain-0.1.8.4.dist-info/entry_points.txt,sha256=YFQT4xpkUqt5dM5wlKPQQOqcjMuFrT9iuRAzIpAyH7U,51
|
|
11
|
+
jarvis_brain-0.1.8.4.dist-info/RECORD,,
|
mcp_tools/dp_tools.py
CHANGED
|
@@ -52,11 +52,12 @@ def register_get_new_tab(mcp: FastMCP, browser_manager, client_manager: DPProxyC
|
|
|
52
52
|
|
|
53
53
|
def register_pop_first_packet(mcp: FastMCP, browser_manager, client_manager: DPProxyClientManager):
|
|
54
54
|
@mcp.tool(name="pop_first_packet",
|
|
55
|
-
description="每调用一次就会弹出传入的tab页所监听到的数据包中的第一个packet_message,当一个packet_message的response body过长时会被切分成多个包,具体一个请求是否还有下一个包,可以参考body_completed字段"
|
|
56
|
-
|
|
55
|
+
description="每调用一次就会弹出传入的tab页所监听到的数据包中的第一个packet_message,当一个packet_message的response body过长时会被切分成多个包,具体一个请求是否还有下一个包,可以参考body_completed字段"
|
|
56
|
+
"同时如果想要以域名对packet进行过滤,可以传入想要过滤的域名列表。")
|
|
57
|
+
async def pop_first_packet(browser_port: int, tab_id: str, domain_filter: list = None) -> dict[str, Any]:
|
|
57
58
|
_browser = browser_manager.get_browser(browser_port)
|
|
58
59
|
client = client_manager.get_client(tab_id)
|
|
59
|
-
packet_message = client.pop_first_packet()
|
|
60
|
+
packet_message = client.pop_first_packet(domain_filter)
|
|
60
61
|
message = f"tab页:【{tab_id}】,暂时没有监听到XHR数据包"
|
|
61
62
|
if packet_message:
|
|
62
63
|
message = f"tab页:【{tab_id}】,监听到XHR数据包",
|
tools/browser_proxy.py
CHANGED
|
@@ -6,6 +6,7 @@ from DrissionPage._pages.chromium_tab import ChromiumTab
|
|
|
6
6
|
from DrissionPage._units.listener import DataPacket
|
|
7
7
|
from typing import Tuple, Optional
|
|
8
8
|
import json
|
|
9
|
+
from urllib.parse import urlparse, urlunparse
|
|
9
10
|
|
|
10
11
|
one_turn_max_token = 20000
|
|
11
12
|
|
|
@@ -39,10 +40,18 @@ class DPProxyClient:
|
|
|
39
40
|
pass
|
|
40
41
|
|
|
41
42
|
# 每次调用函数,都从队列的左端弹出一个数据包
|
|
42
|
-
def pop_first_packet(self):
|
|
43
|
+
def pop_first_packet(self, domain_filter: list):
|
|
43
44
|
if self.packet_queue:
|
|
44
45
|
result = self.packet_queue.popleft()
|
|
45
|
-
|
|
46
|
+
packet_url = result["url"]
|
|
47
|
+
packet_domain = urlparse(packet_url).netloc
|
|
48
|
+
# 留两个路径和params的口子,万一后续需要加入这两个的过滤器可以参考domain过滤器的方式
|
|
49
|
+
packet_path = urlparse(packet_url).path
|
|
50
|
+
packet_param = urlparse(packet_url).params
|
|
51
|
+
# 如果没有给domain_filter或者给了domain_filter且包的domain在domain_filter中,都正常返回
|
|
52
|
+
if domain_filter is None or (domain_filter and packet_domain in domain_filter):
|
|
53
|
+
return json.dumps(result, ensure_ascii=False)
|
|
54
|
+
return None
|
|
46
55
|
else:
|
|
47
56
|
return None
|
|
48
57
|
|
|
@@ -60,7 +69,7 @@ class DPProxyClientManager:
|
|
|
60
69
|
def create_client(self, tab: ChromiumTab, self_kill=False) -> Tuple[str, DPProxyClient, ChromiumTab]:
|
|
61
70
|
"""创建新的tab页面代理实例"""
|
|
62
71
|
client = DPProxyClient(tab, self_kill=self_kill)
|
|
63
|
-
tab = client.get_driver(True)
|
|
72
|
+
tab = client.get_driver(True, timeout=60 * 10)
|
|
64
73
|
tab_id = tab.tab_id
|
|
65
74
|
self.tab_pool[tab_id] = {"client": client, "driver": tab}
|
|
66
75
|
return tab_id, client, tab
|
|
File without changes
|
|
File without changes
|