pub struct A2aClient { /* private fields */ }Expand description
A2A client for communicating with remote A2A agents
Implementations§
Source§impl A2aClient
impl A2aClient
Sourcepub fn new(agent_card: AgentCard) -> Self
pub fn new(agent_card: AgentCard) -> Self
Create a new A2A client from an agent card.
The card is trusted as given: its endpoint is not checked. Resolve cards from a
URL with resolve_agent_card or
from_url, which check it.
Sourcepub fn with_credential(self, token: ScopedToken) -> Self
pub fn with_credential(self, token: ScopedToken) -> Self
Sends token as a bearer credential on every message request.
A request goes out only when its URL is inside the token’s audience
(ScopedToken::authorize_for); a request
to any other URL fails with credential.audience_mismatch and is not sent.
Agent card discovery stays unauthenticated.
Sourcepub async fn resolve_agent_card(base_url: &str) -> Result<AgentCard>
pub async fn resolve_agent_card(base_url: &str) -> Result<AgentCard>
Resolves an agent card from a base URL.
Fetches /.well-known/agent-card.json, the path A2A 0.3.0 and later define. Falls
back to /.well-known/agent.json when that path returns 404, so servers that
predate A2A 0.3.0 still resolve. It also falls back when that path holds a card
that is not a 0.3 card, such as the v1 card a server that speaks both versions
serves there; adk-server’s with_a2a keeps its
0.3 card at agent.json.
The card’s endpoint must be on base_url’s origin; see check_card_endpoint.
§Errors
Returns an error when the request fails, when a card path answers with a
non-success status other than the 404 that triggers the fallback, when neither
path holds a 0.3 agent card, or when the card names an endpoint on another origin
(a2a.card_endpoint_refused).
Sourcepub async fn resolve_agent_card_allowing(
base_url: &str,
allowed_origins: &[String],
) -> Result<AgentCard>
pub async fn resolve_agent_card_allowing( base_url: &str, allowed_origins: &[String], ) -> Result<AgentCard>
Resolves an agent card from a base URL, accepting an endpoint on any origin in
allowed_origins as well as on base_url’s own; see check_card_endpoint.
§Example
let card = A2aClient::resolve_agent_card_allowing(
"https://agents.example.com",
&["https://rpc.example.com".to_string()],
)
.await?;§Errors
See resolve_agent_card.
Sourcepub async fn from_url(base_url: &str) -> Result<Self>
pub async fn from_url(base_url: &str) -> Result<Self>
Create a client by resolving an agent card from a URL; see
resolve_agent_card.
Sourcepub fn agent_card(&self) -> &AgentCard
pub fn agent_card(&self) -> &AgentCard
Get the agent card
Sourcepub async fn send_message(&self, message: Message) -> Result<JsonRpcResponse>
pub async fn send_message(&self, message: Message) -> Result<JsonRpcResponse>
Send a message to the remote agent (blocking/non-streaming)
Sourcepub async fn send_streaming_message(
&self,
message: Message,
) -> Result<Pin<Box<dyn Stream<Item = Result<UpdateEvent>> + Send>>>
pub async fn send_streaming_message( &self, message: Message, ) -> Result<Pin<Box<dyn Stream<Item = Result<UpdateEvent>> + Send>>>
Send a message and receive streaming events via SSE
Auto Trait Implementations§
impl !RefUnwindSafe for A2aClient
impl !UnwindSafe for A2aClient
impl Forget for A2aClient
impl Freeze for A2aClientwhere
*const ArcInner<ClientRef> is !null: Freeze,
PhantomData<ArcInner<ClientRef>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<String>: Freeze,
PhantomData<AgentSkill>: Freeze,
NonZero<i32>: Freeze,
Utc: Freeze,
impl Move for A2aClient
impl Send for A2aClient
impl Sync for A2aClient
impl Unpin for A2aClient
impl UnsafeUnpin for A2aClientwhere
*const ArcInner<ClientRef> is !null: UnsafeUnpin,
PhantomData<ArcInner<ClientRef>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<AgentSkill>: UnsafeUnpin,
NonZeroI32Inner: UnsafeUnpin,
Utc: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more