Jarvis-Brain 0.1.8.5__py3-none-any.whl → 0.1.9.2__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.5.dist-info → jarvis_brain-0.1.9.2.dist-info}/METADATA +1 -1
- jarvis_brain-0.1.9.2.dist-info/RECORD +11 -0
- mcp_tools/dp_tools.py +51 -7
- mcp_tools/main.py +1 -0
- tools/browser_proxy.py +7 -4
- jarvis_brain-0.1.8.5.dist-info/RECORD +0 -11
- {jarvis_brain-0.1.8.5.dist-info → jarvis_brain-0.1.9.2.dist-info}/WHEEL +0 -0
- {jarvis_brain-0.1.8.5.dist-info → jarvis_brain-0.1.9.2.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
mcp_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
mcp_tools/dp_tools.py,sha256=BNpFOhHNhJ-CePzMf_RaUzbRVmZg21ihrUi4nwaAU1M,16241
|
|
3
|
+
mcp_tools/main.py,sha256=84sv39oOw9vqr2MPxKy9pFVrevJ9nQJWFffpfg0s6iA,1098
|
|
4
|
+
tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
tools/browser_manager.py,sha256=zeYcWuzxoohMdnYUoZbRH7axFC_VtV8MsncfN8y0yw0,2023
|
|
6
|
+
tools/browser_proxy.py,sha256=dXNG9g0wqyiLE-t8mSe_uLxZDxIl_HY8tY9znSj_k64,7718
|
|
7
|
+
tools/tools.py,sha256=TaWs-CNXy-py9BFmCnJrQ09ke938xXpImf-N2Qo_Rvc,4708
|
|
8
|
+
jarvis_brain-0.1.9.2.dist-info/METADATA,sha256=LSndFyZUD61amGNhFh381NRM6HNpFdlRFY45nYPqmso,241
|
|
9
|
+
jarvis_brain-0.1.9.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
10
|
+
jarvis_brain-0.1.9.2.dist-info/entry_points.txt,sha256=YFQT4xpkUqt5dM5wlKPQQOqcjMuFrT9iuRAzIpAyH7U,51
|
|
11
|
+
jarvis_brain-0.1.9.2.dist-info/RECORD,,
|
mcp_tools/dp_tools.py
CHANGED
|
@@ -53,19 +53,24 @@ def register_get_new_tab(mcp: FastMCP, browser_manager, client_manager: DPProxyC
|
|
|
53
53
|
def register_pop_first_packet(mcp: FastMCP, browser_manager, client_manager: DPProxyClientManager):
|
|
54
54
|
@mcp.tool(name="pop_first_packet",
|
|
55
55
|
description="每调用一次就会弹出传入的tab页所监听到的数据包中的第一个packet_message,当一个packet_message的response body过长时会被切分成多个包,具体一个请求是否还有下一个包,可以参考body_completed字段"
|
|
56
|
-
"
|
|
57
|
-
|
|
56
|
+
"如果想要以域名对packet进行过滤,可以传入想要过滤的域名列表。"
|
|
57
|
+
"如果想要以method对packet进行过滤,可以传入想要过滤的method列表,默认是:['GET', 'POST']")
|
|
58
|
+
async def pop_first_packet(browser_port: int, tab_id: str, domain_filter: list = None,
|
|
59
|
+
method: list = ["GET", "POST"]) -> dict[str, Any]:
|
|
58
60
|
_browser = browser_manager.get_browser(browser_port)
|
|
59
61
|
client = client_manager.get_client(tab_id)
|
|
60
|
-
packet_message = client.pop_first_packet(domain_filter)
|
|
62
|
+
current_queue_size, packet_message = client.pop_first_packet(domain_filter, method)
|
|
61
63
|
message = f"tab页:【{tab_id}】,暂时没有监听到XHR数据包"
|
|
62
64
|
if packet_message:
|
|
63
|
-
message = f"tab页:【{tab_id}】,监听到XHR
|
|
65
|
+
message = f"tab页:【{tab_id}】,监听到XHR数据包,当前数据包队列中还剩 {current_queue_size} 条数据"
|
|
66
|
+
if current_queue_size:
|
|
67
|
+
message = f"tab页:【{tab_id}】,当前弹出的第一个数据包不符合过滤条件,当前数据包队列中还剩 {current_queue_size} 条数据,请不要改变条件,继续弹出下一个数据包"
|
|
64
68
|
return dp_mcp_message_pack(
|
|
65
69
|
message,
|
|
66
70
|
browser_port=browser_port,
|
|
67
71
|
tab_id=tab_id,
|
|
68
|
-
packet_message=packet_message
|
|
72
|
+
packet_message=packet_message,
|
|
73
|
+
current_queue_size=current_queue_size,
|
|
69
74
|
)
|
|
70
75
|
|
|
71
76
|
|
|
@@ -231,9 +236,9 @@ def register_click_action(mcp: FastMCP, browser_manager):
|
|
|
231
236
|
click_success = True
|
|
232
237
|
except Exception as e:
|
|
233
238
|
click_success = False
|
|
234
|
-
message = f"
|
|
239
|
+
message = f"tab页:【{tab_id}】点击【{css_selector}】 {'成功' if click_success else '失败'} 了"
|
|
235
240
|
else:
|
|
236
|
-
message = f"
|
|
241
|
+
message = f"tab页:【{tab_id}】传入的css_selector找到了{len(target_eles)}个元素,请确保传入的css_selector可以找到唯一的一个元素"
|
|
237
242
|
return dp_mcp_message_pack(
|
|
238
243
|
message=message,
|
|
239
244
|
browser_port=browser_port,
|
|
@@ -243,3 +248,42 @@ def register_click_action(mcp: FastMCP, browser_manager):
|
|
|
243
248
|
click_success=click_success,
|
|
244
249
|
extra_message="点击成功,页面可能有更新,请重新获取页面html,并重新分析页面Selector" if click_success else ""
|
|
245
250
|
)
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def register_scroll_action(mcp: FastMCP, browser_manager):
|
|
254
|
+
@mcp.tool(name="scroll_action", description="尝试滚动tab页"
|
|
255
|
+
"forward参数是滚动的方向:down、up、left、right"
|
|
256
|
+
"pixel参数是滚动的像素值,默认为None。"
|
|
257
|
+
"当forward为down且pixel为None,则将页面滚动到垂直中间位置,水平位置不变"
|
|
258
|
+
"当forward为up且pixel为None,则将页面滚动到顶部,水平位置不变"
|
|
259
|
+
"当forward为left且pixel为None,则将页面滚动到最左边,垂直位置不变"
|
|
260
|
+
"当forward为right且pixel为None,则将页面滚动到最右边,垂直位置不变")
|
|
261
|
+
async def scroll_action(browser_port: int, tab_id: str, forward: str = "down", pixel: int = None) -> dict[str, Any]:
|
|
262
|
+
_browser = browser_manager.get_browser(browser_port)
|
|
263
|
+
target_tab = _browser.get_tab(tab_id)
|
|
264
|
+
if forward == "down":
|
|
265
|
+
if pixel is None:
|
|
266
|
+
target_tab.scroll.to_half()
|
|
267
|
+
target_tab.scroll.down(pixel)
|
|
268
|
+
elif forward == "up":
|
|
269
|
+
if pixel is None:
|
|
270
|
+
target_tab.scroll.to_top()
|
|
271
|
+
target_tab.scroll.up(pixel)
|
|
272
|
+
elif forward == "left":
|
|
273
|
+
if pixel is None:
|
|
274
|
+
target_tab.scroll.to_leftmost()
|
|
275
|
+
target_tab.scroll.left(pixel)
|
|
276
|
+
elif forward == "right":
|
|
277
|
+
if pixel is None:
|
|
278
|
+
target_tab.scroll.to_rightmost()
|
|
279
|
+
target_tab.scroll.right(pixel)
|
|
280
|
+
else:
|
|
281
|
+
if pixel is None:
|
|
282
|
+
target_tab.scroll.to_half()
|
|
283
|
+
target_tab.scroll.down()
|
|
284
|
+
message = f"已完成对tab页:【{tab_id}】forward={forward} 的滑动"
|
|
285
|
+
return dp_mcp_message_pack(
|
|
286
|
+
message=message,
|
|
287
|
+
browser_port=browser_port,
|
|
288
|
+
tab_id=tab_id,
|
|
289
|
+
)
|
mcp_tools/main.py
CHANGED
|
@@ -22,6 +22,7 @@ if "TeamNode-Dp" in enabled_modules:
|
|
|
22
22
|
register_pop_first_packet(mcp, browser_manager, client_manager)
|
|
23
23
|
# 页面交互
|
|
24
24
|
register_click_action(mcp, browser_manager)
|
|
25
|
+
register_scroll_action(mcp, browser_manager)
|
|
25
26
|
|
|
26
27
|
if "JarvisNode" in enabled_modules:
|
|
27
28
|
register_assert_waf(mcp, browser_manager)
|
tools/browser_proxy.py
CHANGED
|
@@ -40,20 +40,23 @@ class DPProxyClient:
|
|
|
40
40
|
pass
|
|
41
41
|
|
|
42
42
|
# 每次调用函数,都从队列的左端弹出一个数据包
|
|
43
|
-
def pop_first_packet(self, domain_filter: list):
|
|
43
|
+
def pop_first_packet(self, domain_filter: list, method: list = ["GET", "POST"]):
|
|
44
44
|
if self.packet_queue:
|
|
45
45
|
result = self.packet_queue.popleft()
|
|
46
|
+
current_queue_size = len(self.packet_queue)
|
|
46
47
|
packet_url = result["url"]
|
|
48
|
+
packet_method = result["method"]
|
|
47
49
|
packet_domain = urlparse(packet_url).netloc
|
|
48
50
|
# 留两个路径和params的口子,万一后续需要加入这两个的过滤器可以参考domain过滤器的方式
|
|
49
51
|
packet_path = urlparse(packet_url).path
|
|
50
52
|
packet_param = urlparse(packet_url).params
|
|
51
53
|
# 如果没有给domain_filter或者给了domain_filter且包的domain在domain_filter中,都正常返回
|
|
52
54
|
if domain_filter is None or (domain_filter and packet_domain in domain_filter):
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
if packet_method in method:
|
|
56
|
+
return current_queue_size, json.dumps(result, ensure_ascii=False)
|
|
57
|
+
return current_queue_size, None
|
|
55
58
|
else:
|
|
56
|
-
return None
|
|
59
|
+
return 0, None
|
|
57
60
|
|
|
58
61
|
|
|
59
62
|
class DPProxyClientManager:
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
mcp_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
mcp_tools/dp_tools.py,sha256=t6bIFL2aQffEi0-_LxQyQ85mmqjlL9dKQOkAsXrc8nk,13529
|
|
3
|
-
mcp_tools/main.py,sha256=1oM11IvEfwBvJ4bigIQzr2AigTISX-LIJ63oFtYnwFY,1049
|
|
4
|
-
tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
tools/browser_manager.py,sha256=zeYcWuzxoohMdnYUoZbRH7axFC_VtV8MsncfN8y0yw0,2023
|
|
6
|
-
tools/browser_proxy.py,sha256=FIAEK6SMYK6uv5rg7x9Mm4NhnIfh11IHQcrzL1YkuNQ,7494
|
|
7
|
-
tools/tools.py,sha256=TaWs-CNXy-py9BFmCnJrQ09ke938xXpImf-N2Qo_Rvc,4708
|
|
8
|
-
jarvis_brain-0.1.8.5.dist-info/METADATA,sha256=RSehOA3vVRnHO1fhZzPwn_o6OycSkT4l_FQCsRGrQ_4,241
|
|
9
|
-
jarvis_brain-0.1.8.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
10
|
-
jarvis_brain-0.1.8.5.dist-info/entry_points.txt,sha256=YFQT4xpkUqt5dM5wlKPQQOqcjMuFrT9iuRAzIpAyH7U,51
|
|
11
|
-
jarvis_brain-0.1.8.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|