pub struct A2AProtocol { /* private fields */ }Expand description
A2A Protocol handler for inter-agent communication.
Implementations§
Source§impl A2AProtocol
impl A2AProtocol
Sourcepub async fn set_delegation_handler(&self, handler: DelegationHandler)
pub async fn set_delegation_handler(&self, handler: DelegationHandler)
Register a handler that executes delegated tasks.
When a TaskDelegation message arrives and a handler is set,
the protocol spawns a background task to execute it and sends
the result back as a ResultSharing message.
Sourcepub fn registry(&self) -> &AgentCardRegistry
pub fn registry(&self) -> &AgentCardRegistry
Returns the agent card registry.
Sourcepub async fn execute_delegation(
&self,
from: AgentId,
to: AgentId,
task: TaskSpec,
) -> Option<Result<Value>>
pub async fn execute_delegation( &self, from: AgentId, to: AgentId, task: TaskSpec, ) -> Option<Result<Value>>
Execute a delegated task through the registered handler (blocking).
Also enqueues the delegation message and publishes events for audit trail purposes, then calls the handler directly and waits.
Returns None if no handler is registered.
Sourcepub async fn send_message(
&self,
from: AgentId,
to: AgentId,
message: A2AMessage,
) -> Result<Uuid>
pub async fn send_message( &self, from: AgentId, to: AgentId, message: A2AMessage, ) -> Result<Uuid>
Sends a message from one agent to another.
Sourcepub async fn delegate_task(
&self,
from: AgentId,
to: AgentId,
task: TaskSpec,
) -> Result<Uuid>
pub async fn delegate_task( &self, from: AgentId, to: AgentId, task: TaskSpec, ) -> Result<Uuid>
Delegates a task from one agent to another.
Sourcepub async fn send_status_update(
&self,
from: AgentId,
to: AgentId,
task_id: Uuid,
progress: u8,
message: String,
) -> Result<Uuid>
pub async fn send_status_update( &self, from: AgentId, to: AgentId, task_id: Uuid, progress: u8, message: String, ) -> Result<Uuid>
Sends a status update from one agent to another.
Shares a result from one agent to another.
Sourcepub async fn query_capabilities(
&self,
capability: &str,
) -> Result<Vec<AgentCard>>
pub async fn query_capabilities( &self, capability: &str, ) -> Result<Vec<AgentCard>>
Queries the registry for agents that can perform a capability.
Sourcepub async fn send_handshake(&self, from: AgentId, to: AgentId) -> Result<Uuid>
pub async fn send_handshake(&self, from: AgentId, to: AgentId) -> Result<Uuid>
Initiates a handshake with another agent.
Sourcepub async fn receive_messages(&self, agent_id: AgentId) -> Vec<A2ARequest>
pub async fn receive_messages(&self, agent_id: AgentId) -> Vec<A2ARequest>
Receives all pending messages for an agent, draining the queue.
Sourcepub async fn pending_count(&self, agent_id: AgentId) -> usize
pub async fn pending_count(&self, agent_id: AgentId) -> usize
Returns the number of pending messages for an agent.
Sourcepub async fn has_messages(&self, agent_id: AgentId) -> bool
pub async fn has_messages(&self, agent_id: AgentId) -> bool
Returns true if the agent has any pending messages.
Sourcepub async fn deliver_pending_messages(
&self,
agent_id: AgentId,
) -> Result<Vec<A2ARequest>>
pub async fn deliver_pending_messages( &self, agent_id: AgentId, ) -> Result<Vec<A2ARequest>>
Deliver all pending messages to an agent.
Unlike receive_messages (which drains the queue silently),
this method does NOT re-publish MessageReceived events since
they were already published when the messages were originally sent.
Sourcepub async fn send_and_wait(
&self,
from: AgentId,
to: AgentId,
message: A2AMessage,
timeout: Duration,
) -> Result<A2AResponse>
pub async fn send_and_wait( &self, from: AgentId, to: AgentId, message: A2AMessage, timeout: Duration, ) -> Result<A2AResponse>
Send a message and wait for a response within a timeout.
Uses tokio::select! with Notify instead of polling.
Matches ResultSharing messages by checking if task_id equals the
delegated task’s ID (not the envelope request_id). This works because
delegate_task creates a TaskDelegation { task_id: task.task_id, ... }
message, and the handler responds with ResultSharing { task_id: task.task_id }.
Trait Implementations§
Source§impl Clone for A2AProtocol
impl Clone for A2AProtocol
Source§fn clone(&self) -> A2AProtocol
fn clone(&self) -> A2AProtocol
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for A2AProtocol
impl !RefUnwindSafe for A2AProtocol
impl Send for A2AProtocol
impl Sync for A2AProtocol
impl Unpin for A2AProtocol
impl UnsafeUnpin for A2AProtocol
impl !UnwindSafe for A2AProtocol
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.