myagent-ai 1.47.35 → 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 +12 -10
- 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
|
|
|
@@ -183,7 +184,8 @@ class ToolDispatcher:
|
|
|
183
184
|
|
|
184
185
|
async def _exec_command(self, params: Dict, timeout: int, task_id: str,
|
|
185
186
|
stream_callback: Optional[Callable] = None,
|
|
186
|
-
sent_files: Optional[List[Dict[str, Any]]] = None
|
|
187
|
+
sent_files: Optional[List[Dict[str, Any]]] = None,
|
|
188
|
+
agent_id: Optional[str] = None) -> Dict:
|
|
187
189
|
"""执行 shell 命令"""
|
|
188
190
|
code_text = params.get("command", "")
|
|
189
191
|
if not code_text:
|
|
@@ -227,13 +229,13 @@ class ToolDispatcher:
|
|
|
227
229
|
_to_name = _match[1].strip()
|
|
228
230
|
_content = _match[2].strip()
|
|
229
231
|
|
|
230
|
-
# 获取当前 agent
|
|
231
|
-
|
|
232
|
-
_from_name = "
|
|
232
|
+
# 获取当前 agent 的 ID
|
|
233
|
+
_from_id = agent_id if agent_id else "unknown"
|
|
234
|
+
_from_name = _from_id if _from_id else "未知"
|
|
233
235
|
|
|
234
236
|
_gm.add_agent_chat(
|
|
235
237
|
group_id="",
|
|
236
|
-
from_agent=
|
|
238
|
+
from_agent=_from_id,
|
|
237
239
|
from_name=_from_name,
|
|
238
240
|
to_agent=_to_path,
|
|
239
241
|
to_name=_to_name,
|
|
@@ -285,13 +287,13 @@ class ToolDispatcher:
|
|
|
285
287
|
_to_name = _match[1].strip()
|
|
286
288
|
_content = _match[2].strip()
|
|
287
289
|
|
|
288
|
-
# 获取当前 agent
|
|
289
|
-
|
|
290
|
-
_from_name = "
|
|
290
|
+
# 获取当前 agent 的 ID
|
|
291
|
+
_from_id = agent_id if agent_id else "unknown"
|
|
292
|
+
_from_name = _from_id if _from_id else "未知"
|
|
291
293
|
|
|
292
294
|
_gm.add_agent_chat(
|
|
293
295
|
group_id="",
|
|
294
|
-
from_agent=
|
|
296
|
+
from_agent=_from_id,
|
|
295
297
|
from_name=_from_name,
|
|
296
298
|
to_agent=_to_path,
|
|
297
299
|
to_name=_to_name,
|