Skip to main content

A2aHttpClient

Struct A2aHttpClient 

pub struct A2aHttpClient { /* private fields */ }
Expand description

Outbound A2A HTTP client. Holds only the reqwest client and the live config handle — no peer list copy. Constructed once, shared by all a2a_* tools behind an Arc.

SSRF posture: peer base_urls are operator-declared (static allowlist), and each call is guarded against private/loopback/metadata hosts via helpers::domain_guard (the same policy http_request uses), with no redirects followed.

Implementations§

Source§

impl A2aHttpClient

Source

pub fn new( config: LiveConfigHandle, request_timeout_secs: u64, zeroclaw_dir: Option<PathBuf>, secrets_encrypt: bool, route_cache: RouteCache, ) -> Result<Self>

Build the client. The reqwest client is built once (timeout + no-redirect policy); peers resolve from live config per call, so nothing about peers is eagerly validated here. zeroclaw_dir + secrets_encrypt enable decrypting encrypted peer tokens via the canonical SecretStore (the same path http_request uses).

Source§

impl A2aHttpClient

Source

pub async fn send_message( &self, peer: &str, agent: &str, message: &str, context_id: Option<String>, task_id: Option<String>, return_immediately: bool, ) -> Result<(Task, bool)>

SendMessage (spec §9.4.1): delegate a task to a peer agent and block for the returned payload. The response is a SendMessageResponse oneof: a Task (terminal/non-terminal) or a Message reply. Returns the task and a flag: true for a genuine Task branch, false for a Message reply folded into a synthetic task (retains the peer-provided messageId as the task id). Non-terminal task states are returned as-is for the tool layer to poll.

Source

pub async fn get_task( &self, peer: &str, task_id: &str, agent: Option<&str>, ) -> Result<Task>

GetTask (spec §9.4.3): retrieve the current state and artifacts of an in-flight task. Reuses the route cached by the originating SendMessage (same peer/rpc_url/tenant) so the poll lands on the same endpoint that created the task; falls back to interface selection if the route is not cached (daemon restart, evicted entry).

Source

pub async fn cancel( &self, peer: &str, task_id: &str, agent: Option<&str>, ) -> Result<Task>

CancelTask (spec §9.4.5): request cancellation of an in-flight task. Reuses the route cached by the originating SendMessage; falls back to interface selection if not cached.

Source

pub async fn get_card(&self, peer: &str) -> Result<AgentCard>

GET /.well-known/agent-card.json (spec §14.3 discovery surface): fetch a peer’s public Agent Card from the origin root. The well-known card is unauthenticated. Cached by base_url (derived data): a repeat discover/send reuses the cached card; an endpoint change is a different cache key, so the prior entry is naturally invalidated.

Auto Trait Implementations§

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
§

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

§

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.

§

impl<T> Instrument for T

§

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

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

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
§

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

§

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
§

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
§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

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

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