beswarm 0.2.6__py3-none-any.whl → 0.2.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.
- beswarm/aient/setup.py +1 -1
- beswarm/aient/src/aient/core/request.py +3 -17
- beswarm/aient/src/aient/core/utils.py +1 -0
- beswarm/bemcp/bemcp/utils.py +3 -1
- beswarm/tools/worker.py +33 -18
- beswarm/utils.py +2 -2
- {beswarm-0.2.6.dist-info → beswarm-0.2.8.dist-info}/METADATA +1 -1
- {beswarm-0.2.6.dist-info → beswarm-0.2.8.dist-info}/RECORD +10 -10
- {beswarm-0.2.6.dist-info → beswarm-0.2.8.dist-info}/WHEEL +0 -0
- {beswarm-0.2.6.dist-info → beswarm-0.2.8.dist-info}/top_level.txt +0 -0
beswarm/aient/setup.py
CHANGED
@@ -4,7 +4,7 @@ from setuptools import setup, find_packages
|
|
4
4
|
|
5
5
|
setup(
|
6
6
|
name="aient",
|
7
|
-
version="1.1.
|
7
|
+
version="1.1.41",
|
8
8
|
description="Aient: The Awakening of Agent.",
|
9
9
|
long_description=Path.open(Path("README.md"), encoding="utf-8").read(),
|
10
10
|
long_description_content_type="text/markdown",
|
@@ -10,6 +10,7 @@ from .utils import (
|
|
10
10
|
c3o,
|
11
11
|
c3h,
|
12
12
|
c35s,
|
13
|
+
c4,
|
13
14
|
gemini1,
|
14
15
|
gemini2,
|
15
16
|
gemini2_5_pro_exp,
|
@@ -576,6 +577,8 @@ async def get_vertex_claude_payload(request, engine, provider, api_key=None):
|
|
576
577
|
location = c35s
|
577
578
|
elif "claude-3-opus" in original_model:
|
578
579
|
location = c3o
|
580
|
+
elif "claude-sonnet-4" in original_model or "claude-opus-4" in original_model:
|
581
|
+
location = c4
|
579
582
|
elif "claude-3-sonnet" in original_model:
|
580
583
|
location = c3s
|
581
584
|
elif "claude-3-haiku" in original_model:
|
@@ -798,23 +801,6 @@ async def get_aws_payload(request, engine, provider, api_key=None):
|
|
798
801
|
# url = f"{base_url}/model/{original_model}/invoke"
|
799
802
|
url = f"{base_url}/model/{original_model}/invoke-with-response-stream"
|
800
803
|
|
801
|
-
# if "claude-3-5-sonnet" in original_model or "claude-3-7-sonnet" in original_model:
|
802
|
-
# location = c35s
|
803
|
-
# elif "claude-3-opus" in original_model:
|
804
|
-
# location = c3o
|
805
|
-
# elif "claude-3-sonnet" in original_model:
|
806
|
-
# location = c3s
|
807
|
-
# elif "claude-3-haiku" in original_model:
|
808
|
-
# location = c3h
|
809
|
-
|
810
|
-
# claude_stream = "streamRawPredict"
|
811
|
-
# url = "https://{LOCATION}-aiplatform.googleapis.com/v1/projects/{PROJECT_ID}/locations/{LOCATION}/publishers/anthropic/models/{MODEL}:{stream}".format(
|
812
|
-
# LOCATION=await location.next(),
|
813
|
-
# PROJECT_ID=project_id,
|
814
|
-
# MODEL=original_model,
|
815
|
-
# stream=claude_stream
|
816
|
-
# )
|
817
|
-
|
818
804
|
messages = []
|
819
805
|
system_prompt = None
|
820
806
|
tool_id = None
|
@@ -436,6 +436,7 @@ provider_api_circular_list = defaultdict(ThreadSafeCircularList)
|
|
436
436
|
c35s = ThreadSafeCircularList(["us-east5", "europe-west1"])
|
437
437
|
c3s = ThreadSafeCircularList(["us-east5", "us-central1", "asia-southeast1"])
|
438
438
|
c3o = ThreadSafeCircularList(["us-east5"])
|
439
|
+
c4 = ThreadSafeCircularList(["us-east5", "us-central1", "europe-west4", "asia-southeast1"])
|
439
440
|
c3h = ThreadSafeCircularList(["us-east5", "us-central1", "europe-west1", "europe-west4"])
|
440
441
|
gemini1 = ThreadSafeCircularList(["us-central1", "us-east4", "us-west1", "us-west4", "europe-west1", "europe-west2"])
|
441
442
|
gemini2 = ThreadSafeCircularList(["us-central1"])
|
beswarm/bemcp/bemcp/utils.py
CHANGED
@@ -24,7 +24,9 @@ def convert_tool_format(tool: types.Tool) -> Dict[str, Any]:
|
|
24
24
|
"function": {
|
25
25
|
"name": tool.name,
|
26
26
|
"description": tool.description,
|
27
|
-
"parameters": tool.inputSchema
|
28
27
|
}
|
29
28
|
}
|
29
|
+
if getattr(tool, 'inputSchema', None) and getattr(tool.inputSchema, 'properties', None):
|
30
|
+
converted_tool["function"]["parameters"] = tool.inputSchema
|
31
|
+
|
30
32
|
return converted_tool
|
beswarm/tools/worker.py
CHANGED
@@ -2,6 +2,7 @@ import os
|
|
2
2
|
import re
|
3
3
|
import copy
|
4
4
|
import json
|
5
|
+
import difflib
|
5
6
|
import platform
|
6
7
|
from pathlib import Path
|
7
8
|
from datetime import datetime
|
@@ -34,6 +35,7 @@ async def worker(goal, tools, work_dir, cache_messages=None):
|
|
34
35
|
start_time = datetime.now()
|
35
36
|
os.chdir(Path(work_dir).absolute())
|
36
37
|
finish_flag = 0
|
38
|
+
goal_diff = None
|
37
39
|
|
38
40
|
mcp_list = [item for item in tools if isinstance(item, dict)]
|
39
41
|
if mcp_list:
|
@@ -75,6 +77,14 @@ async def worker(goal, tools, work_dir, cache_messages=None):
|
|
75
77
|
with cache_file_path.open("r", encoding="utf-8") as f:
|
76
78
|
cache_messages = json.load(f)
|
77
79
|
if cache_messages and isinstance(cache_messages, list) and len(cache_messages) > 1:
|
80
|
+
old_goal = extract_xml_content(cache_messages[1]["content"], "goal")
|
81
|
+
if old_goal.strip() != goal.strip():
|
82
|
+
diff_generator = difflib.ndiff(old_goal.splitlines(), goal.splitlines())
|
83
|
+
changed_lines = []
|
84
|
+
for line in diff_generator:
|
85
|
+
if (line.startswith('+ ') or line.startswith('- ')) and line[2:].strip():
|
86
|
+
changed_lines.append(line)
|
87
|
+
goal_diff = '\n'.join(changed_lines).strip()
|
78
88
|
first_user_message = replace_xml_content(cache_messages[1]["content"], "goal", goal)
|
79
89
|
work_agent_config["cache_messages"] = cache_messages[0:1] + [{"role": "user", "content": first_user_message}] + cache_messages[2:]
|
80
90
|
|
@@ -94,15 +104,13 @@ async def worker(goal, tools, work_dir, cache_messages=None):
|
|
94
104
|
async def instruction_agent_task():
|
95
105
|
last_instruction = None
|
96
106
|
while True:
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
根据以上对话历史和目标,请生成下一步指令。如果任务已完成,请回复"任务已完成"。
|
105
|
-
"""
|
107
|
+
instruction_prompt = "".join([
|
108
|
+
"</work_agent_conversation_end>\n\n",
|
109
|
+
f"任务目标: {goal}\n\n",
|
110
|
+
f"任务目标新变化:\n{goal_diff}\n\n" if goal_diff else "",
|
111
|
+
"在 tag <work_agent_conversation_start>...</work_agent_conversation_end> 之前的对话历史都是工作智能体的对话历史。\n\n",
|
112
|
+
"根据以上对话历史和目标,请生成下一步指令。如果任务已完成,请回复'任务已完成'。\n\n",
|
113
|
+
])
|
106
114
|
if last_instruction:
|
107
115
|
instruction_prompt = (
|
108
116
|
f"{instruction_prompt}\n\n"
|
@@ -222,6 +230,7 @@ async def worker_gen(goal, tools, work_dir, cache_messages=None):
|
|
222
230
|
start_time = datetime.now()
|
223
231
|
os.chdir(Path(work_dir).absolute())
|
224
232
|
finish_flag = 0
|
233
|
+
goal_diff = None
|
225
234
|
|
226
235
|
mcp_list = [item for item in tools if isinstance(item, dict)]
|
227
236
|
if mcp_list:
|
@@ -263,6 +272,14 @@ async def worker_gen(goal, tools, work_dir, cache_messages=None):
|
|
263
272
|
with cache_file_path.open("r", encoding="utf-8") as f:
|
264
273
|
cache_messages = json.load(f)
|
265
274
|
if cache_messages and isinstance(cache_messages, list) and len(cache_messages) > 1:
|
275
|
+
old_goal = extract_xml_content(cache_messages[1]["content"], "goal")
|
276
|
+
if old_goal.strip() != goal.strip():
|
277
|
+
diff_generator = difflib.ndiff(old_goal.splitlines(), goal.splitlines())
|
278
|
+
changed_lines = []
|
279
|
+
for line in diff_generator:
|
280
|
+
if (line.startswith('+ ') or line.startswith('- ')) and line[2:].strip():
|
281
|
+
changed_lines.append(line)
|
282
|
+
goal_diff = '\n'.join(changed_lines).strip()
|
266
283
|
first_user_message = replace_xml_content(cache_messages[1]["content"], "goal", goal)
|
267
284
|
work_agent_config["cache_messages"] = cache_messages[0:1] + [{"role": "user", "content": first_user_message}] + cache_messages[2:]
|
268
285
|
|
@@ -282,15 +299,13 @@ async def worker_gen(goal, tools, work_dir, cache_messages=None):
|
|
282
299
|
async def instruction_agent_task():
|
283
300
|
last_instruction = None
|
284
301
|
while True:
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
根据以上对话历史和目标,请生成下一步指令。如果任务已完成,请回复"任务已完成"。
|
293
|
-
"""
|
302
|
+
instruction_prompt = "".join([
|
303
|
+
"</work_agent_conversation_end>\n\n",
|
304
|
+
f"任务目标: {goal}\n\n",
|
305
|
+
f"任务目标新变化:\n{goal_diff}\n\n" if goal_diff else "",
|
306
|
+
"在 tag <work_agent_conversation_start>...</work_agent_conversation_end> 之前的对话历史都是工作智能体的对话历史。\n\n",
|
307
|
+
"根据以上对话历史和目标,请生成下一步指令。如果任务已完成,请回复'任务已完成'。\n\n",
|
308
|
+
])
|
294
309
|
if last_instruction:
|
295
310
|
instruction_prompt = (
|
296
311
|
f"{instruction_prompt}\n\n"
|
beswarm/utils.py
CHANGED
@@ -2,13 +2,13 @@ import re
|
|
2
2
|
|
3
3
|
def extract_xml_content(text, xml_tag):
|
4
4
|
result = ''
|
5
|
-
pattern = rf'^<{xml_tag}
|
5
|
+
pattern = rf'^<{xml_tag}>([\D\d\s]+?)<\/{xml_tag}>$'
|
6
6
|
match = re.search(pattern, text, re.MULTILINE)
|
7
7
|
if match:
|
8
8
|
result = match.group(1)
|
9
9
|
if not result:
|
10
10
|
return ''
|
11
|
-
return result
|
11
|
+
return result.strip()
|
12
12
|
|
13
13
|
def replace_xml_content(original_string: str, tag_name: str, replacement_content: str) -> str:
|
14
14
|
"""
|
@@ -1,15 +1,15 @@
|
|
1
1
|
beswarm/__init__.py,sha256=HZjUOJtZR5QhMuDbq-wukQQn1VrBusNWai_ysGo-VVI,20
|
2
2
|
beswarm/prompt.py,sha256=_hYKZ0MUiMRs3C-1PMlFKIVgTKFcp_irla3p3wQNF3c,32015
|
3
|
-
beswarm/utils.py,sha256=
|
3
|
+
beswarm/utils.py,sha256=xxbNifOPlfcVkKmF_qFzuEnZgF3MQg3mnOfz1EF0Qss,6697
|
4
4
|
beswarm/aient/main.py,sha256=SiYAIgQlLJqYusnTVEJOx1WNkSJKMImhgn5aWjfroxg,3814
|
5
|
-
beswarm/aient/setup.py,sha256=
|
5
|
+
beswarm/aient/setup.py,sha256=lttzm-VPC3ghnT8qQ8poVNP7evb0cTY1MnsWEBlmLKw,487
|
6
6
|
beswarm/aient/src/aient/__init__.py,sha256=SRfF7oDVlOOAi6nGKiJIUK6B_arqYLO9iSMp-2IZZps,21
|
7
7
|
beswarm/aient/src/aient/core/__init__.py,sha256=NxjebTlku35S4Dzr16rdSqSTWUvvwEeACe8KvHJnjPg,34
|
8
8
|
beswarm/aient/src/aient/core/log_config.py,sha256=kz2_yJv1p-o3lUQOwA3qh-LSc3wMHv13iCQclw44W9c,274
|
9
9
|
beswarm/aient/src/aient/core/models.py,sha256=d4MISNezTSe0ls0-fjuToI2SoT-sk5fWqAJuKVinIlo,7502
|
10
|
-
beswarm/aient/src/aient/core/request.py,sha256=
|
10
|
+
beswarm/aient/src/aient/core/request.py,sha256=1iY-GUgbGCt0gXpO91QDEERIfkptI_anCHg9ElDvVVc,71765
|
11
11
|
beswarm/aient/src/aient/core/response.py,sha256=mAVsCnNhWY09DXNe0lyPUJq-1ljtGjC67Az-Uh7ozIw,35166
|
12
|
-
beswarm/aient/src/aient/core/utils.py,sha256=
|
12
|
+
beswarm/aient/src/aient/core/utils.py,sha256=NcXdb8zBN0GE01OGaUzg8U34RaraoFf2MaLDDGFvvC4,27492
|
13
13
|
beswarm/aient/src/aient/core/test/test_base_api.py,sha256=pWnycRJbuPSXKKU9AQjWrMAX1wiLC_014Qc9hh5C2Pw,524
|
14
14
|
beswarm/aient/src/aient/core/test/test_geminimask.py,sha256=HFX8jDbNg_FjjgPNxfYaR-0-roUrOO-ND-FVsuxSoiw,13254
|
15
15
|
beswarm/aient/src/aient/core/test/test_image.py,sha256=_T4peNGdXKBHHxyQNx12u-NTyFE8TlYI6NvvagsG2LE,319
|
@@ -74,7 +74,7 @@ beswarm/aient/test/test_yjh.py,sha256=MsHuBLNOqi3fyX-uboBKmTevkZW_KVv12p-pkF5ir3
|
|
74
74
|
beswarm/bemcp/bemcp/__init__.py,sha256=Ss6bDXiZJgVIZS6KWytcGwXmIFu7SsagIXa5NpeWJ7c,140
|
75
75
|
beswarm/bemcp/bemcp/decorator.py,sha256=23bNgwLjuUkpod5VcRv-UqlJTf91_wfztf8ls7-Gg08,3218
|
76
76
|
beswarm/bemcp/bemcp/main.py,sha256=gtl3oyjAM_rwFw3kR-m-cUpS0FFTASnUOB8-fMrVT7g,8608
|
77
|
-
beswarm/bemcp/bemcp/utils.py,sha256=
|
77
|
+
beswarm/bemcp/bemcp/utils.py,sha256=AFpvNu4qMfi8VZhlHSn_Tche_IZ0cOTusjmnhxU7OJI,1070
|
78
78
|
beswarm/bemcp/test/client.py,sha256=j7PDg5Esyri-e2vz2ubZ4foDSAq5Iv8Yfl_xyzTDsFY,1593
|
79
79
|
beswarm/bemcp/test/server.py,sha256=XqSrk88FC-dk7AcEn-OyS_fR0W0V9OnL2ONpkNEKJKE,1159
|
80
80
|
beswarm/queries/tree-sitter-language-pack/README.md,sha256=ivZSEuWqYfUVLZl2AZZGRlm0bQsaG-VTBKBwACyM07k,291
|
@@ -133,8 +133,8 @@ beswarm/tools/repomap.py,sha256=YsTPq5MXfn_Ds5begcvHDnY_Xp2d4jH-xmWqNMHnNHY,4523
|
|
133
133
|
beswarm/tools/screenshot.py,sha256=u6t8FCgW5YHJ_Oc4coo8e0F3wTusWE_-H8dFh1rBq9Q,1011
|
134
134
|
beswarm/tools/search_arxiv.py,sha256=GpuIOYX8T0iRC-X-hmuR9AUJVn15WWZq864DaoC7BUc,8004
|
135
135
|
beswarm/tools/search_web.py,sha256=w0T0aCqOVlb6Of5hn_TtpnrGXo6bMtw2aKZdkrYjycI,12069
|
136
|
-
beswarm/tools/worker.py,sha256=
|
137
|
-
beswarm-0.2.
|
138
|
-
beswarm-0.2.
|
139
|
-
beswarm-0.2.
|
140
|
-
beswarm-0.2.
|
136
|
+
beswarm/tools/worker.py,sha256=oLsg-WO99sScDE1xZBGiQOPLdK71SDPIdrsSoLot_Ro,22659
|
137
|
+
beswarm-0.2.8.dist-info/METADATA,sha256=WCzNnkiSx_cEljs8fKxBd7nvHybrzOyW_IiOggtPLG8,3846
|
138
|
+
beswarm-0.2.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
139
|
+
beswarm-0.2.8.dist-info/top_level.txt,sha256=pJw4O87wvt5882smuSO6DfByJz7FJ8SxxT8h9fHCmpo,8
|
140
|
+
beswarm-0.2.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|