loom.ai.a2a¶
Pure A2A projection of a compiled agent.
Holds the card projection and the event projection, both derived from the
compiled AgentPlan alone (R-005). Neither imports an
A2A SDK nor a web framework, so importing this package on a base installation
succeeds and the redaction guarantee (FR-038, SC-009) is unit-testable. The
transport server lives behind the ai-a2a extra and is not re-exported here.
- class loom.ai.a2a.A2AEventProjector(*, task_id, context_id, max_steps)[source]¶
Bases:
objectProjects one run’s agent events onto A2A streaming events.
A projector belongs to a single run: it holds the correlation ids of that run and the tool-call counter backing the opaque ordinal, so it is neither shared between runs nor safe to reuse across them.
- Parameters:
Example:
projector = A2AEventProjector(task_id=task, context_id=ctx, max_steps=12) for event in events: frames = projector.project(event)
- project(event)[source]¶
Project one agent event onto the A2A events it maps to.
- Parameters:
event (TextDeltaEvent | ToolCallEvent | ToolResultEvent | ErrorEvent | FinalEvent) – Agent event to project.
- Returns:
The projected A2A events, in emission order;
finalis the only member producing more than one.- Raises:
KeyError – When the event is not one of the five contract members — widening the union without widening this map is a contract break, not a silent pass-through.
- Return type:
- loom.ai.a2a.agent_url(base_url, name, *, prefix=DEFAULT_A2A_PREFIX)[source]¶
Build the public endpoint of one agent.
- Parameters:
- Returns:
The absolute URL clients send A2A requests to.
- Return type:
Example:
agent_url("https://api.example.com", "market") # .../a2a/market
- loom.ai.a2a.build_agent_card(plan, config, *, mechanism, prefix=DEFAULT_A2A_PREFIX)[source]¶
Project a compiled agent into its public A2A agent card.
Only the agent’s identity, its endpoint, the modes actually served and the security scheme in use are published. Instructions, model binding, region, credentials, policies, metadata and capability wiring are never projected (FR-038, SC-009).
- Parameters:
plan (AgentPlan) – Compiled agent to describe.
config (A2AConfig) – A2A exposure settings supplying the deployment’s base URL.
mechanism (str | None) – Authentication mechanism the endpoint enforces;
None, or one with no A2A representation, publishes no security scheme.prefix (str) – Path prefix the A2A surface is mounted under.
- Returns:
The agent card, ready to be serialised as JSON.
- Return type:
Example:
card = build_agent_card(plan, config, mechanism="jwt")