Skip to main content

V1Executor

Struct V1Executor 

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

Task lifecycle management for A2A v1.0.0.

Wraps a TaskStore and validates every state transition against the A2A state machine. Every change to a task is made under that task’s lock, so concurrent requests and a running agent never overwrite each other’s updates. Each status and artifact update is sent, in order and without loss, to the task’s subscribers, and to its push notification configs when a push sender is set.

Implementations§

Source§

impl V1Executor

Source

pub fn new(task_store: Arc<dyn TaskStore>) -> Self

Creates a new executor backed by the given task store.

Source

pub fn set_push_sender(&self, sender: Arc<dyn PushNotificationSender>)

Delivers every status and artifact update of a task with push notification configs through sender, in order. A failed delivery is logged, not fatal.

Source

pub fn subscribe(&self, task_id: &str) -> UnboundedReceiver<StreamResponse>

Receives every update to task_id from now on, in order, until the task ends (the channel closes after a terminal status). The receiver never misses an update.

Source

pub fn publish(&self, task_id: &str, update: StreamResponse)

Sends update to the subscribers and push notification configs of task_id.

Source

pub async fn create_task( &self, task_id: &str, context_id: &str, ) -> Result<TaskStoreEntry, A2aError>

Creates a new task in Submitted state.

§Errors

Returns an error if the task store fails to persist the task.

Source

pub async fn create_task_for( &self, task_id: &str, context_id: &str, owner: Option<&str>, ) -> Result<TaskStoreEntry, A2aError>

Creates a new task in Submitted state, owned by owner when one is given.

§Errors

Returns an error if the task store fails to persist the task.

Source

pub async fn create_task_with_metadata( &self, task_id: &str, context_id: &str, owner: Option<&str>, metadata: HashMap<String, Value>, ) -> Result<TaskStoreEntry, A2aError>

Creates a new task in Submitted state with metadata, owned by owner when one is given.

§Errors

Returns an error if the task store fails to persist the task.

Source

pub async fn transition_state( &self, task_id: &str, context_id: &str, new_state: TaskState, message: Option<String>, ) -> Result<TaskStatusUpdateEvent, A2aError>

Transitions a task to a new state, with message as its status text.

§Errors

Returns A2aError::InvalidStateTransition if the transition is not allowed, A2aError::TaskNotFound if the task does not exist, or a store error.

Source

pub async fn transition_state_with_parts( &self, task_id: &str, context_id: &str, new_state: TaskState, parts: Vec<Part>, ) -> Result<TaskStatusUpdateEvent, A2aError>

Transitions a task to a new state, with parts (if any) as its status message.

§Errors

Returns A2aError::InvalidStateTransition if the transition is not allowed, A2aError::TaskNotFound if the task does not exist, or a store error.

Source

pub async fn update_status( &self, task_id: &str, context_id: &str, new_state: TaskState, parts: Vec<Part>, metadata: Option<Map<String, Value>>, ) -> Result<TaskStatusUpdateEvent, A2aError>

Transitions a task to new_state with parts (if any) as its status message, and sends the update with metadata, or the task’s own metadata when None.

The previous status message moves into the task’s history, and metadata joins the task’s own, as A2A task managers do. A task an ADK agent runs marks the update with the ADK extension.

§Errors

Returns A2aError::InvalidStateTransition if the transition is not allowed, A2aError::TaskNotFound if the task does not exist, or a store error.

Source

pub async fn record_artifact( &self, task_id: &str, context_id: &str, artifact: Artifact, ) -> Result<TaskArtifactUpdateEvent, A2aError>

Records an artifact for a task and sends it to the task’s subscribers.

Persists the artifact to the task store, sends it to the task’s subscribers, and returns the corresponding TaskArtifactUpdateEvent.

§Errors

Returns A2aError::TaskNotFound if the task does not exist, or a store error.

Source

pub async fn persist_artifact( &self, task_id: &str, context_id: &str, artifact: Artifact, ) -> Result<TaskArtifactUpdateEvent, A2aError>

Records an artifact for a task without sending it to the task’s subscribers.

§Errors

Returns A2aError::TaskNotFound if the task does not exist, or a store error.

Source

pub async fn save_push_config( &self, task_id: &str, config: TaskPushNotificationConfig, ) -> Result<TaskPushNotificationConfig, A2aError>

Saves config on the task, replacing a config with the same ID.

§Errors

Returns A2aError::TaskNotFound if the task does not exist, or a store error.

Source

pub async fn delete_push_config( &self, task_id: &str, config_id: &str, ) -> Result<(), A2aError>

Removes the push config config_id from the task. Removing a config the task does not have succeeds, as A2A config stores do.

§Errors

Returns A2aError::TaskNotFound if the task does not exist, or a store error.

Source

pub async fn add_history_message( &self, task_id: &str, message: Message, ) -> Result<(), A2aError>

Appends message to the task’s history.

§Errors

Returns A2aError::TaskNotFound if the task does not exist, or a store error.

Source

pub async fn claim_waiting_task( &self, task_id: &str, message: Message, ) -> Result<TaskStoreEntry, A2aError>

Takes a task that waits on its caller for a run: moves it from INPUT_REQUIRED or AUTH_REQUIRED back to SUBMITTED and records message, all under the task’s lock, so a second message that races this one finds the task taken.

§Errors

Returns A2aError::UnsupportedOperation when the task does not wait on its caller, A2aError::TaskNotFound if the task does not exist, or a store error.

Source

pub async fn ask_again( &self, task_id: &str, message: Message, missing: &str, ) -> Result<TaskStatusUpdateEvent, A2aError>

Asks a waiting task’s caller again for the call missing that message left unanswered, as adk-go does: records message, keeps the task INPUT_REQUIRED, and sends a status whose message repeats the pending calls and adds no input provided for function call ID "<missing>", marked validation_error.

§Errors

Returns A2aError::TaskNotFound if the task does not exist, or a store error.

Source

pub async fn fail_task( &self, task_id: &str, context_id: &str, error_message: &str, ) -> Result<TaskStatusUpdateEvent, A2aError>

Transitions a task to Failed with an error message.

§Errors

Returns A2aError::InvalidStateTransition if the task is already in a terminal state, or a store error.

Source

pub fn task_store(&self) -> &Arc<dyn TaskStore> ⓘ

Returns a reference to the underlying task store.

Auto Trait Implementations§

§

impl !Freeze for V1Executor

§

impl !RefUnwindSafe for V1Executor

§

impl !UnwindSafe for V1Executor

§

impl Forget for V1Executor

§

impl Move for V1Executor

§

impl Send for V1Executor

§

impl Sync for V1Executor

§

impl Unpin for V1Executor
where Arc<dyn TaskStore>: Unpin, Align4<u32>: Unpin, Align1<u8>: Unpin, *const u8 is !null: Unpin, Arc<Chan<StreamResponse, Semaphore>>: Unpin, Arc<Mutex<()>>: Unpin, Arc<dyn PushNotificationSender>: Unpin,

§

impl UnsafeUnpin for V1Executor

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