Jarvis-Brain 0.1.7.7__py3-none-any.whl → 0.1.7.8__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Jarvis_Brain
3
- Version: 0.1.7.7
3
+ Version: 0.1.7.8
4
4
  Summary: Jarvis brain mcp
5
5
  Requires-Python: >=3.10
6
6
  Requires-Dist: beautifulsoup4
@@ -1,11 +1,11 @@
1
1
  mcp_tools/__init__.py,sha256=nqhlHRalTYQF8gU5RBfanOn-zSONLYON1mjPIvP-f4w,113
2
- mcp_tools/dp_tools.py,sha256=O51cz2ectsbJJ6fN9X1YarSC7JereXeUWFtehx71E3Q,10796
2
+ mcp_tools/dp_tools.py,sha256=LUnBMk6fjY-q30YUIy4sjwobAKeSmDOkZfAhToi2BT0,11485
3
3
  mcp_tools/main.py,sha256=Fdt2N3oKGwvruuno_ywnuWSlm1BexE9ZY669H2LTo9w,1056
4
4
  tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  tools/browser_manager.py,sha256=EXM7n-sDOtdQGpWkVTAZHWhepVU-7PAoUTDNgGF9_fQ,1938
6
6
  tools/browser_proxy.py,sha256=cdMRxcUYyaOqGU17lldltHOvt9rxXD5Dwh7hBXEBby4,6780
7
7
  tools/tools.py,sha256=TaWs-CNXy-py9BFmCnJrQ09ke938xXpImf-N2Qo_Rvc,4708
8
- jarvis_brain-0.1.7.7.dist-info/METADATA,sha256=u_pB128wsC-0P2-hKsYlgkZFaDZ45dCoM81ZdnZDRdU,241
9
- jarvis_brain-0.1.7.7.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
10
- jarvis_brain-0.1.7.7.dist-info/entry_points.txt,sha256=YFQT4xpkUqt5dM5wlKPQQOqcjMuFrT9iuRAzIpAyH7U,51
11
- jarvis_brain-0.1.7.7.dist-info/RECORD,,
8
+ jarvis_brain-0.1.7.8.dist-info/METADATA,sha256=1FAwCfT0kxBMKNUGmq1JnYH_4yzSfipZD81BOLe4-0Y,241
9
+ jarvis_brain-0.1.7.8.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
10
+ jarvis_brain-0.1.7.8.dist-info/entry_points.txt,sha256=YFQT4xpkUqt5dM5wlKPQQOqcjMuFrT9iuRAzIpAyH7U,51
11
+ jarvis_brain-0.1.7.8.dist-info/RECORD,,
mcp_tools/dp_tools.py CHANGED
@@ -88,8 +88,12 @@ def register_close_tab(mcp: FastMCP, browser_manager, client_manager: DPProxyCli
88
88
 
89
89
 
90
90
  def register_check_selector(mcp: FastMCP, browser_manager, client_manager: DPProxyClientManager):
91
- @mcp.tool(name="check_selector", description="查找tab页中是否包含元素,并返回元素attr_name所对应的值")
92
- async def check_selector(browser_port: int, tab_id: str, css_selector: str, attr_name: str = "text") -> dict[
91
+ @mcp.tool(name="check_selector",
92
+ description="查找tab页中是否包含元素,并返回元素attr_name所对应的值。"
93
+ "当要选择的元素包含过多元素时,需要传入offset和page_size来分批查看元素,一般不建议调整page_size,更推荐你调整offset"
94
+ "同时如果单个元素属性值太长,函数会进行截断。一般的单个元素的属性值超过300个字符的就会触发截断,截断后会在最后拼接'...'")
95
+ async def check_selector(browser_port: int, tab_id: str, css_selector: str, attr_name: str = "text",
96
+ offset: int = 0, page_size: int = 10) -> dict[
93
97
  str, Any]:
94
98
  _browser = browser_manager.get_browser(browser_port)
95
99
  target_tab = _browser.get_tab(tab_id)
@@ -105,13 +109,18 @@ def register_check_selector(mcp: FastMCP, browser_manager, client_manager: DPPro
105
109
  attr_output = "\n".join(ele_text_list)
106
110
  else:
107
111
  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]
112
+ if len(attr_output) > page_size:
113
+ attr_output = attr_output[offset:offset + page_size]
114
+ # 对attr_output逐个截断,截断的长度为:一轮最大token除以元素个数+3个点+两个引号和逗号
115
+ attr_output = [attr_str[:min(300, one_turn_max_token // (len(attr_str) + 6))] + "..."
116
+ for attr_str in attr_output]
110
117
  return dp_mcp_message_pack(
111
118
  f"已完成tab页:【{tab_id}】对:【{css_selector}】的检查",
112
119
  tab_id=tab_id,
113
120
  selector=css_selector,
114
121
  selector_ele_exist=exist_flag,
122
+ page_size=page_size,
123
+ offset=offset,
115
124
  attr_output=attr_output
116
125
  )
117
126