Jarvis-Brain 0.1.4__tar.gz → 0.1.4.1__tar.gz

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.4
3
+ Version: 0.1.4.1
4
4
  Summary: Jarvis brain
5
5
  Requires-Python: >=3.10
6
6
  Requires-Dist: beautifulsoup4
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "Jarvis_Brain" # 别人下载时用的名字,必须在 PyPI 上唯一
3
- version = "0.1.4"
3
+ version = "0.1.4.1"
4
4
  description = "Jarvis brain"
5
5
  dependencies = [
6
6
  "fastmcp",
@@ -24,4 +24,11 @@ build-backend = "hatchling.build"
24
24
  packages = ["mcp_tools", "tools"]
25
25
 
26
26
  [tool.hatch.build]
27
- exclude = ["venv", ".venv", "env", ".env", "*.pyc"]
27
+ exclude = [
28
+ "venv",
29
+ ".venv",
30
+ "env",
31
+ ".env",
32
+ "*.pyc",
33
+ "dp_test"
34
+ ]
@@ -1,26 +0,0 @@
1
- import time
2
-
3
- from DrissionPage import ChromiumPage
4
- from bs4 import BeautifulSoup
5
- page = ChromiumPage()
6
- tab = page.latest_tab
7
- # url = "https://www.baidu.com"
8
- # url = "https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=baidu&wd=asdf&fenlei=256&rsv_pq=0x9647d2090000e43c&rsv_t=09ffuUN39r6wv9%2FBqsAwZUuAJ1q9z1hppzLcl1EgmLa%2FnBOH4t5RzqAdbyDX&rqlang=en&rsv_dl=tb&rsv_enter=1&rsv_sug3=5&rsv_sug1=1&rsv_sug7=100&rsv_btype=i&prefixsug=asdf&rsp=0&inputT=894&rsv_sug4=895"
9
- url = "https://www.nxzgh.org.cn/#/newsCenter/index2/2"
10
- tab.get(url)
11
- li_eles = tab.eles("css:div.pointer")
12
- ul_ele = tab.ele("css:div.right-box")
13
- # for li in li_eles:
14
- # li.set.style('backgroundColor', 'rgba(255, 255, 0, 0.3)')
15
- ul_ele.set.style('backgroundColor', 'rgba(255, 255, 0, 0.3)')
16
- # tab.get_screenshot('screen_shot.png')
17
- rect_size = tab.rect.size
18
- print(rect_size)
19
- # tab.get_screenshot('screenshot_full.png', full_page=True, right_bottom=(1920, 1080))
20
- tab.get_screenshot('screenshot_full.png', right_bottom=(rect_size[0] / 2, rect_size[1] / 2))
21
- # time.sleep(50)
22
- # .xpath-highlight {
23
- # outline: 2px solid yellow !important;
24
- # outline-offset: 2px;
25
- # background-color: rgba(255, 255, 0, 0.2);
26
- # }
Binary file
@@ -1,128 +0,0 @@
1
- import asyncio
2
- import os.path
3
- from typing import Callable, List
4
- import json
5
-
6
- from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions
7
-
8
- base_cwd = "/Users/user/PycharmProjects/JARVIS"
9
-
10
-
11
- class SimpleTaskManager:
12
- def __init__(self, max_concurrent: int = 10):
13
- self.semaphore = asyncio.Semaphore(max_concurrent)
14
- self.results = []
15
-
16
- async def execute_task(self, task_id: int, coro_func: Callable, *args, **kwargs):
17
- """执行单个任务"""
18
- async with self.semaphore:
19
- try:
20
- result = await coro_func(*args, **kwargs)
21
- self.results.append((task_id, result))
22
- print(f"✅ 任务 {task_id} 完成")
23
- return result
24
- except Exception as e:
25
- error_msg = f"任务 {task_id} 失败: {e}"
26
- self.results.append((task_id, error_msg))
27
- print(f"❌ {error_msg}")
28
- return None
29
-
30
- async def process_all(self, tasks: List[tuple]):
31
- """
32
- 处理所有任务
33
- tasks: 列表,每个元素是 (coro_func, args, kwargs) 元组
34
- """
35
- print(f"🚀 开始处理 {len(tasks)} 个任务,最大并发数: {self.semaphore._value}")
36
-
37
- # 创建所有任务
38
- task_coroutines = []
39
- for i, (coro_func, args, kwargs) in enumerate(tasks):
40
- task_coroutines.append(self.execute_task(i, coro_func, *args, **kwargs))
41
-
42
- # 并发执行所有任务
43
- await asyncio.gather(*task_coroutines)
44
-
45
- print(f"🎉 所有任务完成!成功: {len([r for r in self.results if '失败' not in str(r[1])])}")
46
- return self.results
47
-
48
-
49
- options = ClaudeAgentOptions(
50
- permission_mode='bypassPermissions',
51
- cwd=base_cwd,
52
- mcp_servers={
53
- "JarvisNode": {
54
- "command": "uv",
55
- "args": [
56
- "run",
57
- "--directory",
58
- "/Users/user/PycharmProjects/JARVIS/mcp_tools",
59
- "main.py"
60
- ],
61
- "env": {
62
- "MCP_MODULES": "TeamNode-Dp,JarvisNode",
63
- "BASE_CWD": os.getcwd(),
64
- }
65
- },
66
- },
67
- # setting_sources=["project"],
68
- allowed_tools=[
69
- "mcp__JarvisNode__get_html",
70
- "mcp__JarvisNode__visit_url",
71
- "mcp__JarvisNode__get_new_tab",
72
- "mcp__JarvisNode__switch_tab",
73
- "mcp__JarvisNode__close_tab",
74
- "mcp__JarvisNode__check_selector",
75
- "mcp__JarvisNode__assert_waf", # 判断传入的url是否使用了瑞数,jsl等防火墙
76
- 'Read',
77
- 'Write',
78
- 'Edit',
79
- 'MultiEdit',
80
- 'Grep',
81
- 'Glob',
82
- 'TodoWrite'
83
- ]
84
- )
85
-
86
-
87
- # 使用自定义工具与 Claude
88
-
89
-
90
- async def run(url):
91
- from urllib.parse import urlparse
92
- print(f"开始任务:{url}")
93
- parser = urlparse(url)
94
- domain = parser.netloc
95
- analysis_file_path = os.path.join(base_cwd, f'{domain}.json')
96
- async with ClaudeSDKClient(options=options) as client:
97
- # prompt = f"请使用mcp工具打开网页:{url}"
98
- prompt = f"""
99
- 测试
100
- """
101
- # prompt = f"请列出所有你可以使用的mcp工具"
102
- await client.query(prompt)
103
-
104
- # 提取并打印响应
105
- async for msg in client.receive_response():
106
- print(msg)
107
-
108
-
109
- async def main():
110
- tasks = []
111
- # with open("/Users/user/Desktop/mapping_copy.json", "r", encoding="utf-8") as f:
112
- with open("/Users/user/Desktop/政务项目/map1_副本.json", "r", encoding="utf-8") as f:
113
- mapping = json.load(f)
114
- mapping = dict(list(mapping.items()))
115
- for key, value in mapping.items():
116
- tasks.append((run, (), { # 关键字参数字典
117
- "url": value,
118
- }))
119
- manager = SimpleTaskManager(max_concurrent=5)
120
- results = await manager.process_all(tasks)
121
- # 输出结果
122
- print("\n任务结果摘要:")
123
- for task_id, result in results[:5]: # 只显示前5个
124
- print(f" 任务 {task_id}: {result}")
125
-
126
-
127
- if __name__ == "__main__":
128
- asyncio.run(main())
File without changes
File without changes