Skip to main content

A2aClient

Struct A2aClient 

Source
pub struct A2aClient { /* private fields */ }
Expand description

A2A client for communicating with remote A2A agents

Implementations§

Source§

impl A2aClient

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

pub fn agent_card(&self) -> &AgentCard

Get the agent card

Source

pub async fn send_message(&self, message: Message) -> Result<JsonRpcResponse>

Send a message to the remote agent (blocking/non-streaming)

Source

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 A2aClient
where *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
where Arc<ClientRef>: Send, RawVecInner: Send, NonZero<i32>: Send, Utc: Send,

§

impl Sync for A2aClient
where Arc<ClientRef>: Sync, RawVecInner: Sync, NonZero<i32>: Sync, Utc: Sync,

§

impl Unpin for A2aClient
where Arc<ClientRef>: Unpin, *const u8 is !null: Unpin, NonZero<i32>: Unpin, Utc: Unpin,

§

impl UnsafeUnpin for A2aClient
where *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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more