Files
the-nexus/nexus/a2a/__init__.py

99 lines
2.2 KiB
Python
Raw Normal View History

"""
A2A Protocol for Fleet-Wizard Delegation
Implements Google's Agent2Agent (A2A) protocol v1.0 for the Timmy
Foundation fleet. Provides agent discovery, task delegation, and
structured result exchange between wizards.
Components:
types.py A2A data types (Agent Card, Task, Message, Part)
card.py Agent Card generation from YAML config
client.py Async client for sending tasks to remote agents
server.py FastAPI server for receiving A2A tasks
registry.py Fleet agent discovery (local file + Gitea backends)
"""
from nexus.a2a.types import (
AgentCard,
AgentCapabilities,
AgentInterface,
AgentSkill,
Artifact,
DataPart,
FilePart,
JSONRPCError,
JSONRPCRequest,
JSONRPCResponse,
Message,
Part,
Role,
Task,
TaskState,
TaskStatus,
TextPart,
part_from_dict,
part_to_dict,
)
from nexus.a2a.card import (
AgentCard,
build_card,
get_auth_headers,
load_agent_card,
load_card_config,
)
from nexus.a2a.registry import (
GiteaRegistry,
LocalFileRegistry,
discover_agents,
)
__all__ = [
"A2AClient",
"A2AClientConfig",
"A2AServer",
"AgentCard",
"AgentCapabilities",
"AgentInterface",
"AgentSkill",
"Artifact",
"DataPart",
"FilePart",
"GiteaRegistry",
"JSONRPCError",
"JSONRPCRequest",
"JSONRPCResponse",
"LocalFileRegistry",
"Message",
"Part",
"Role",
"Task",
"TaskState",
"TaskStatus",
"TextPart",
"build_card",
"discover_agents",
"echo_handler",
"get_auth_headers",
"load_agent_card",
"load_card_config",
"part_from_dict",
"part_to_dict",
]
# Lazy imports for optional deps
def get_client(**kwargs):
"""Get A2AClient (avoids aiohttp import at module level)."""
from nexus.a2a.client import A2AClient, A2AClientConfig
config = kwargs.pop("config", None)
if config is None:
config = A2AClientConfig(**kwargs)
return A2AClient(config=config)
def get_server(card: AgentCard, **kwargs):
"""Get A2AServer (avoids fastapi import at module level)."""
from nexus.a2a.server import A2AServer, echo_handler
return A2AServer(card=card, **kwargs)