Jarvis-Brain 0.1.7.2__py3-none-any.whl → 0.1.7.5__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.2
3
+ Version: 0.1.7.5
4
4
  Summary: Jarvis brain mcp
5
5
  Requires-Python: >=3.10
6
6
  Requires-Dist: beautifulsoup4
@@ -0,0 +1,11 @@
1
+ mcp_tools/__init__.py,sha256=nqhlHRalTYQF8gU5RBfanOn-zSONLYON1mjPIvP-f4w,113
2
+ mcp_tools/dp_tools.py,sha256=OcZvuk_Ut0puHXVSH8PvA_BD0kfIGXy6MEmiwFb-tiI,10576
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.5.dist-info/METADATA,sha256=G2bIPs2Blz6NEb2y98dGociYlNrH9Vzm-6b-3y6-BT8,241
9
+ jarvis_brain-0.1.7.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
10
+ jarvis_brain-0.1.7.5.dist-info/entry_points.txt,sha256=YFQT4xpkUqt5dM5wlKPQQOqcjMuFrT9iuRAzIpAyH7U,51
11
+ jarvis_brain-0.1.7.5.dist-info/RECORD,,
mcp_tools/__init__.py CHANGED
@@ -0,0 +1,4 @@
1
+ a = ["a", "b", "c", "d", "e", "f", "g", "h"]
2
+ print(len(a))
3
+ for index, num in enumerate(a):
4
+ print(index, num)
mcp_tools/dp_tools.py CHANGED
@@ -15,7 +15,7 @@ waf_status_code_dict = {
15
15
  521: "加速乐"
16
16
  }
17
17
  # 一轮最大输入,以免单个html最大长度超过ai最大输入
18
- ont_turn_max_token = 25000
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 + ont_turn_max_token] for i in range(0, len(min_html), ont_turn_max_token)]
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"
@@ -129,7 +129,7 @@ def register_quit_browser(mcp: FastMCP, browser_manager, client_manager: DPProxy
129
129
 
130
130
  def register_pop_first_packet(mcp: FastMCP, browser_manager, client_manager: DPProxyClientManager):
131
131
  @mcp.tool(name="pop_first_packet",
132
- description="每调用一次就会弹出传入的tab页所监听到的数据包中的第一个packet_message")
132
+ description="每调用一次就会弹出传入的tab页所监听到的数据包中的第一个packet_message,当一个packet_message的response body过长时会被切分成多个包,具体一个请求是否还有下一个包,可以参考body_completed字段")
133
133
  async def pop_first_packet(browser_port: int, tab_id: str) -> dict[str, Any]:
134
134
  _browser = browser_manager.get_browser(browser_port)
135
135
  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,30 +136,36 @@ 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
- temp_dict = {
138
- "url": url,
139
- "method": method,
140
- "request_data": data,
141
- "request_headers": dict(packet.request.headers),
142
- "response_headers": dict(packet.response.headers),
143
- "response_body": body,
144
- }
145
- # print(temp_dict)
146
- client.packet_queue.append(temp_dict)
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()
150
158
 
151
- if __name__ == '__main__':
152
- co = ChromiumOptions().set_user_agent(
153
- "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Mobile Safari/537.36")
154
- tab = ChromiumPage(co).latest_tab
155
- client = DPProxyClient(tab, self_kill=False)
156
- # client = CaptchaClient(tab, self_kill=True)
157
- tab = client.get_driver(True)
158
- url = "https://api.toutiaoapi.com/feoffline/hotspot_and_local/html/hot_list/index.html?client_extra_params=%7B%22custom_log_pb%22%3A%22%7B%5C%22style_id%5C%22%3A%5C%2240030%5C%22%2C%5C%22entrance_hotspot%5C%22%3A%5C%22search%5C%22%2C%5C%22location%5C%22%3A%5C%22hot_board%5C%22%2C%5C%22category_name%5C%22%3A%5C%22hotboard_light%5C%22%7D%22%7D&count=50&log_pb=%7B%22style_id%22%3A%2240030%22%2C%22entrance_hotspot%22%3A%22search%22%2C%22location%22%3A%22hot_board%22%2C%22category_name%22%3A%22hotboard_light%22%7D&only_hot_list=1&tab_name=stream&enter_keyword=%23%E7%BE%8E%E5%9B%BD%E9%80%80%E5%87%BA66%E4%B8%AA%E5%9B%BD%E9%99%85%E7%BB%84%E7%BB%87%23"
159
- tab.get(url)
160
- for _ in range(5056):
161
- new_packet = client.pop_first_packet()
162
- print(new_packet, "23")
163
- time.sleep(1)
159
+ # if __name__ == '__main__':
160
+ # co = ChromiumOptions().set_user_agent(
161
+ # "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Mobile Safari/537.36")
162
+ # tab = ChromiumPage(co).latest_tab
163
+ # client = DPProxyClient(tab, self_kill=False)
164
+ # # client = CaptchaClient(tab, self_kill=True)
165
+ # tab = client.get_driver(True)
166
+ # url = "https://api.toutiaoapi.com/feoffline/hotspot_and_local/html/hot_list/index.html?client_extra_params=%7B%22custom_log_pb%22%3A%22%7B%5C%22style_id%5C%22%3A%5C%2240030%5C%22%2C%5C%22entrance_hotspot%5C%22%3A%5C%22search%5C%22%2C%5C%22location%5C%22%3A%5C%22hot_board%5C%22%2C%5C%22category_name%5C%22%3A%5C%22hotboard_light%5C%22%7D%22%7D&count=50&log_pb=%7B%22style_id%22%3A%2240030%22%2C%22entrance_hotspot%22%3A%22search%22%2C%22location%22%3A%22hot_board%22%2C%22category_name%22%3A%22hotboard_light%22%7D&only_hot_list=1&tab_name=stream&enter_keyword=%23%E7%BE%8E%E5%9B%BD%E9%80%80%E5%87%BA66%E4%B8%AA%E5%9B%BD%E9%99%85%E7%BB%84%E7%BB%87%23"
167
+ # tab.get(url)
168
+ # for _ in range(5056):
169
+ # new_packet = client.pop_first_packet()
170
+ # print(new_packet, "23")
171
+ # time.sleep(1)
@@ -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=yVTRpZA0IGLsL2Bl6zN_4hMdx2lX9UaMx5O6DPlrGRg,6333
7
- tools/tools.py,sha256=TaWs-CNXy-py9BFmCnJrQ09ke938xXpImf-N2Qo_Rvc,4708
8
- jarvis_brain-0.1.7.2.dist-info/METADATA,sha256=_j2fYANuNrAtnMwBnttjNSZ9z2vq7CDbjHS5LNnzKmQ,241
9
- jarvis_brain-0.1.7.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
10
- jarvis_brain-0.1.7.2.dist-info/entry_points.txt,sha256=YFQT4xpkUqt5dM5wlKPQQOqcjMuFrT9iuRAzIpAyH7U,51
11
- jarvis_brain-0.1.7.2.dist-info/RECORD,,