Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix: 小艺channel贾维斯端插件问题

shenwei21faa84aab8f33
diff --git a/jiuwenclaw/agentserver/tools/xiaoyi_phone_tools/xiaoyi_gui_tool.py b/jiuwenclaw/agentserver/tools/xiaoyi_phone_tools/xiaoyi_gui_tool.py
index 9ab316417e..e0e133782b 100644
--- a/jiuwenclaw/agentserver/tools/xiaoyi_phone_tools/xiaoyi_gui_tool.py
+++ b/jiuwenclaw/agentserver/tools/xiaoyi_phone_tools/xiaoyi_gui_tool.py
@@ -17,6 +17,17 @@ from jiuwenclaw.channel.xiaoyi_channel import get_xiaoyi_channel
from .utils import ToolInputError, format_success_response
+def _get_gui_tool_async_lock(channel: Any) -> asyncio.Lock:
+ gl = getattr(channel, "gui_tool_lock", None)
+ if gl is not None:
+ return gl
+ inner = getattr(channel, "_gui_tool_lock", None)
+ if inner is None:
+ inner = asyncio.Lock()
+ setattr(channel, "_gui_tool_lock", inner)
+ return inner
+
+
def _payload_is_gui_final(payload: Dict[str, Any]) -> bool:
"""兼容设备 isFinal 为 bool / 1 / \"true\" 等."""
v = payload.get("isFinal")
@@ -110,7 +121,7 @@ async def xiaoyi_gui_agent(query: str) -> Dict[str, Any]:
done.set()
# 与 channel 层锁配合:同一时间仅一单 GUI,避免多 handler 共收同一 WS 帧
- async with channel.gui_tool_lock:
+ async with _get_gui_tool_async_lock(channel):
channel.register_gui_agent_handler(on_gui)
try:
command = {
diff --git a/jiuwenclaw/channel/xiaoyi_channel.py b/jiuwenclaw/channel/xiaoyi_channel.py
index 04ed53711b..9fd076dae8 100644
--- a/jiuwenclaw/channel/xiaoyi_channel.py
+++ b/jiuwenclaw/channel/xiaoyi_channel.py
@@ -32,7 +32,6 @@ from jiuwenclaw.channel.xiaoyi_utils.formatter import (
logger = logging.getLogger(__name__)
-
FILE_TYPE_TO_MIME_TYPE: dict[str, str] = {
"txt": "text/plain",
"html": "text/html",
@@ -623,6 +622,18 @@ class XiaoyiChannel(BaseChannel):
if msg_type == "heartbeat":
return
+ # 根级直连 A2A(jsonrpc 2.0)须含 params.sessionId,否则整帧丢弃
+ if message.get("jsonrpc") == "2.0":
+ params_root = message.get("params")
+ if not isinstance(params_root, dict):
+ params_root = {}
+ sid = params_root.get("sessionId")
+ if sid is None or (isinstance(sid, str) and not sid.strip()):
+ logger.warning(
+ "XiaoyiChannel 直连 A2A 缺少有效 params.sessionId,跳过本帧(与 xy_channel 一致)"
+ )
+ return
+
await self._dispatch_gui_agent_events(message)
# 检查是否是 data-only 消息(工具执行结果)
@@ -632,6 +643,10 @@ class XiaoyiChannel(BaseChannel):
await self._handle_data_event(data_event)
return
+ # GUI / UploadExeResult 等已在 _dispatch_gui_agent_events 与 _extract_data_event 中处理,勿再落 unknown method。
+ if msg_type == "data":
+ return
+
method = message.get("method")
if method == "message/stream":
await self._handle_message_stream(message)