myagent-ai 1.47.36 → 1.47.37
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.
- package/agents/main_agent.py +1 -0
- package/core/tool_dispatcher.py +11 -18
- package/package.json +1 -1
package/agents/main_agent.py
CHANGED
package/core/tool_dispatcher.py
CHANGED
|
@@ -102,6 +102,7 @@ class ToolDispatcher:
|
|
|
102
102
|
stream_callback: Optional[Callable] = None,
|
|
103
103
|
sent_files: Optional[List[Dict[str, Any]]] = None,
|
|
104
104
|
agent_path: Optional[str] = None,
|
|
105
|
+
agent_id: Optional[str] = None,
|
|
105
106
|
) -> Dict[str, Any]:
|
|
106
107
|
"""
|
|
107
108
|
统一工具分发入口。
|
|
@@ -120,7 +121,7 @@ class ToolDispatcher:
|
|
|
120
121
|
"""
|
|
121
122
|
# ── 内置平台工具 (LLM 直接调用) ──
|
|
122
123
|
if tool_name == "command":
|
|
123
|
-
return await self._exec_command(params, timeout, task_id, stream_callback, sent_files,
|
|
124
|
+
return await self._exec_command(params, timeout, task_id, stream_callback, sent_files, agent_id)
|
|
124
125
|
elif tool_name == "web_control":
|
|
125
126
|
return await self._exec_web_control(params, task_id, stream_callback)
|
|
126
127
|
|
|
@@ -184,7 +185,7 @@ class ToolDispatcher:
|
|
|
184
185
|
async def _exec_command(self, params: Dict, timeout: int, task_id: str,
|
|
185
186
|
stream_callback: Optional[Callable] = None,
|
|
186
187
|
sent_files: Optional[List[Dict[str, Any]]] = None,
|
|
187
|
-
|
|
188
|
+
agent_id: Optional[str] = None) -> Dict:
|
|
188
189
|
"""执行 shell 命令"""
|
|
189
190
|
code_text = params.get("command", "")
|
|
190
191
|
if not code_text:
|
|
@@ -228,17 +229,13 @@ class ToolDispatcher:
|
|
|
228
229
|
_to_name = _match[1].strip()
|
|
229
230
|
_content = _match[2].strip()
|
|
230
231
|
|
|
231
|
-
# 获取当前 agent
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
if _from_path and _from_path.startswith("agents/"):
|
|
235
|
-
_from_name = _from_path.replace("agents/", "").split("/")[-1]
|
|
236
|
-
else:
|
|
237
|
-
_from_name = _from_path if _from_path else "未知"
|
|
232
|
+
# 获取当前 agent 的 ID
|
|
233
|
+
_from_id = agent_id if agent_id else "unknown"
|
|
234
|
+
_from_name = _from_id if _from_id else "未知"
|
|
238
235
|
|
|
239
236
|
_gm.add_agent_chat(
|
|
240
237
|
group_id="",
|
|
241
|
-
from_agent=
|
|
238
|
+
from_agent=_from_id,
|
|
242
239
|
from_name=_from_name,
|
|
243
240
|
to_agent=_to_path,
|
|
244
241
|
to_name=_to_name,
|
|
@@ -290,17 +287,13 @@ class ToolDispatcher:
|
|
|
290
287
|
_to_name = _match[1].strip()
|
|
291
288
|
_content = _match[2].strip()
|
|
292
289
|
|
|
293
|
-
# 获取当前 agent
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
if _from_path and _from_path.startswith("agents/"):
|
|
297
|
-
_from_name = _from_path.replace("agents/", "").split("/")[-1]
|
|
298
|
-
else:
|
|
299
|
-
_from_name = _from_path if _from_path else "未知"
|
|
290
|
+
# 获取当前 agent 的 ID
|
|
291
|
+
_from_id = agent_id if agent_id else "unknown"
|
|
292
|
+
_from_name = _from_id if _from_id else "未知"
|
|
300
293
|
|
|
301
294
|
_gm.add_agent_chat(
|
|
302
295
|
group_id="",
|
|
303
|
-
from_agent=
|
|
296
|
+
from_agent=_from_id,
|
|
304
297
|
from_name=_from_name,
|
|
305
298
|
to_agent=_to_path,
|
|
306
299
|
to_name=_to_name,
|