pynydus.standards.a2a

A2A Agent Card standard: validate, extract, generate.

Passthrough-first: if the source project already contains agent-card.json, Nydus copies it verbatim. Otherwise, Nydus generates a card from egg data.

Module Contents

Functions

validate

Validate the egg’s A2A agent card against the spec schema.

extract

Extract the A2A agent card from the egg.

generate

Generate an A2A agent card from egg contents.

_build_deterministic_card

Build an agent card using only deterministic data from the egg.

API

pynydus.standards.a2a.validate(egg: pynydus.api.schemas.Egg, schema: dict[str, Any] | None = None) list[pynydus.api.schemas.ValidationIssue]

Validate the egg’s A2A agent card against the spec schema.

Args: egg: The Egg to validate. schema: Optional JSON Schema dict. When None, the schema is loaded from the bundled a2a spec.

Returns: List of validation issues (empty if valid or if the egg has no agent card).

pynydus.standards.a2a.extract(egg: pynydus.api.schemas.Egg) dict[str, str]

Extract the A2A agent card from the egg.

Args: egg: The Egg that may contain a passthrough A2A agent card.

Returns: {"agent-card.json": <content>} or empty dict if absent.

pynydus.standards.a2a.generate(egg: pynydus.api.schemas.Egg, *, llm_fn: Any = None) dict[str, str]

Generate an A2A agent card from egg contents.

If the egg already has a passthrough card, returns it unchanged. Otherwise builds one deterministically, with optional LLM enhancement.

Args: egg: Source egg. llm_fn: Optional callable (card_draft: dict) -> dict that enhances name, description, and skill descriptions via LLM. When None, deterministic fallbacks are used.

Returns: {"agent-card.json": <content>}.

pynydus.standards.a2a._build_deterministic_card(egg: pynydus.api.schemas.Egg) dict[str, Any]

Build an agent card using only deterministic data from the egg.