Files
agent-radar 1a3a4ccde1
Creator App Tests / PR Spam Gate (push) Skipped
Frontend Tests / PR Spam Gate (push) Skipped
NPM Format (website & console) / PR Spam Gate (push) Skipped
Pre-commit Checks / PR Spam Gate (push) Skipped
QwenPaw Creator Plugin Release / check-version (push) Canceled after 0s
QwenPaw Creator Plugin Release / upload-oss (push) Canceled after 0s
Tests / PR Spam Gate (push) Skipped
CodeQL / CodeQL (python) (push) Canceled after 0s
CodeQL / CodeQL (typescript) (push) Canceled after 0s
Creator App Tests / Creator Backend Tests (push) Canceled after 0s
Creator App Tests / Creator UI Build & Tests (push) Canceled after 0s
E2E Smoke Tests / Playwright UI Smoke (push) Canceled after 0s
Frontend Tests / Detect console changes (push) Canceled after 0s
NPM Format (website & console) / website format check (push) Canceled after 0s
NPM Format (website & console) / console format check (push) Canceled after 0s
Pre-commit Checks / Pre-commit (push) Canceled after 0s
QwenPaw Data Plugin Release / check-version (push) Canceled after 0s
Tests / Detect code changes (push) Canceled after 0s
Frontend Tests / Vitest Unit Tests (push) Canceled after 0s
Frontend Tests / Frontend Summary (push) Canceled after 0s
QwenPaw Data Plugin Release / upload-oss (push) Canceled after 0s
Tests / Maintainer Approval (push) Canceled after 0s
Tests / Unit Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - fallback (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p2 (push) Canceled after 0s
Tests / Coverage Report (push) Canceled after 0s
Tests / Test Summary (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:01:50 +08:00

84 lines
2.7 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""A2A list tool: list registered remote A2A agents for the current agent.
Reads the per-agent ``a2a_config.json`` and returns a summary of all
registered remote agents with their connection info and capabilities.
"""
import json
import logging
from agentscope.message import TextBlock
from agentscope.message import ToolResultState
from agentscope.tool import ToolChunk
logger = logging.getLogger("qwenpaw").getChild(
__name__.replace("plugin_cloudpaw.", ""),
)
async def a2a_list() -> ToolChunk:
"""列出当前智能体已注册的远程 A2A Agent。
无需参数。自动读取当前智能体的 A2A 配置,返回所有已注册的
远程 Agent 信息(别名、URL、认证类型、连接状态、技能列表等)。
Returns:
ToolChunk: 包含已注册 Agent 列表的 JSON:
- agents: Agent 列表,每个包含 alias, url, auth_type, name,
description, skills, capabilities, status 等字段
"""
from .a2a_config_helper import load_a2a_agents
from modules.a2a.client_manager import get_a2a_manager
agents_cfg = load_a2a_agents()
manager = get_a2a_manager()
agents_list = []
for alias, reg in agents_cfg.items():
url = reg.get("url", "")
entry: dict = {
"alias": alias,
"url": url,
"auth_type": reg.get("auth_type", ""),
}
card_info = await manager.get_card_info(url)
if not card_info:
try:
card_info = await manager.connect(
agent_url=url,
auth_type=reg.get("auth_type", ""),
auth_token=reg.get("auth_token", ""),
gateway_config=reg.get("gateway_config"),
)
except Exception as exc:
logger.debug("a2a_list: connect to %s failed: %s", url, exc)
entry["status"] = "error"
entry["error"] = str(exc)
agents_list.append(entry)
continue
if card_info:
entry["status"] = card_info.get("status", "connected")
entry["name"] = card_info.get("name", "")
entry["description"] = card_info.get("description", "")
entry["skills"] = card_info.get("skills", [])
entry["capabilities"] = card_info.get("capabilities", {})
else:
entry["status"] = "disconnected"
agents_list.append(entry)
result = json.dumps(
{"agents": agents_list, "count": len(agents_list)},
ensure_ascii=False,
indent=2,
)
logger.info("a2a_list: found %d registered agents", len(agents_list))
return ToolChunk(
state=ToolResultState.SUCCESS,
content=[TextBlock(type="text", text=result)],
)