Expand description
A2A (Agent2Agent) 1.0 server, JSON-RPC binding (18.17.0, #65): other
agents discover this one by its Agent Card at
/.well-known/agent-card.json and talk to it with SendMessage,
GetTask, ListTasks, CancelTask.
use rust_web_server::a2a::{A2aReply, A2aServer, AgentCard, Artifact, Message, Skill};
let agent = A2aServer::new(
AgentCard::new("Echo agent", "Repeats what you say", "1.0.0")
.skill(Skill::new("echo", "Echo", "Repeats the message").tag("demo")),
)
.on_message(|ctx, message| {
if message.text().is_empty() {
return A2aReply::Message(Message::agent_text("Say something."));
}
A2aReply::Task(ctx.complete(vec![Artifact::text("echo", message.text())]))
});Mount it beside your routes with A2aServer::wrap; it answers the
card and POST at its path (default /a2a) and passes everything else
on.
Structs§
- A2aContext
- What a message handler sees besides the message.
- A2aServer
- The A2A server: an
Applicationserving the Agent Card and the JSON-RPC endpoint. - Agent
Card - The agent’s self-description, served at
AGENT_CARD_PATH. - Artifact
- An output of a task.
- Message
- A message between a client and an agent.
- Part
- One piece of a message or artifact: exactly one of text, raw bytes, a URL or structured data, with an optional media type and file name.
- Skill
- Something the agent can do, as listed on its card.
- Task
- A unit of work the agent tracks.
- Task
Handle - A task being worked on in the background: keep it (it’s
CloneandSend), report progress, and finish it. Updates after the task finished (or was canceled) are ignored. - Task
Status - A task’s state with an optional message and when it was set.
Enums§
- A2aReply
- A handler’s answer to a message.
- Part
Content - What a
Partholds. - Role
- Who sent a message.
- Task
State - A task’s state.
Constants§
- AGENT_
CARD_ PATH - Where the Agent Card is served.
- MAX_
BODY - Request bodies larger than this are refused.
- MAX_
TASKS - Tasks kept (oldest dropped first).
- PROTOCOL_
VERSION - The protocol version served (
A2A-Version).