pub struct UserInteractionRegistry { /* private fields */ }Expand description
Registry for managing pending user interactions.
This registry tracks tools that are blocked waiting for user input and provides methods for the UI to query and respond to these interactions.
Implementations§
Source§impl UserInteractionRegistry
impl UserInteractionRegistry
Sourcepub fn new(event_tx: Sender<ControllerEvent>) -> Self
pub fn new(event_tx: Sender<ControllerEvent>) -> Self
Create a new UserInteractionRegistry.
§Arguments
event_tx- Channel to send events when interactions are registered.
Sourcepub async fn register(
&self,
tool_use_id: String,
session_id: i64,
request: AskUserQuestionsRequest,
turn_id: Option<TurnId>,
) -> Result<Receiver<AskUserQuestionsResponse>, UserInteractionError>
pub async fn register( &self, tool_use_id: String, session_id: i64, request: AskUserQuestionsRequest, turn_id: Option<TurnId>, ) -> Result<Receiver<AskUserQuestionsResponse>, UserInteractionError>
Register a pending interaction and get a receiver to await on.
This is called by the AskUserQuestionsTool when it starts executing. The tool will await on the returned receiver until the UI responds.
§Arguments
tool_use_id- Unique ID for this tool use request.session_id- Session that requested the interaction.request- The questions to ask the user.turn_id- Optional turn ID for this interaction.
§Returns
A oneshot receiver that will receive the user’s response.
Sourcepub async fn respond(
&self,
tool_use_id: &str,
response: AskUserQuestionsResponse,
) -> Result<(), UserInteractionError>
pub async fn respond( &self, tool_use_id: &str, response: AskUserQuestionsResponse, ) -> Result<(), UserInteractionError>
Sourcepub async fn pending_for_session(
&self,
session_id: i64,
) -> Vec<PendingQuestionInfo>
pub async fn pending_for_session( &self, session_id: i64, ) -> Vec<PendingQuestionInfo>
Sourcepub async fn cancel_session(&self, session_id: i64)
pub async fn cancel_session(&self, session_id: i64)
Cancel all pending interactions for a session.
This is called when a session is destroyed. It drops the senders, which will cause the awaiting tools to receive a RecvError.
§Arguments
session_id- Session ID to cancel.
Sourcepub async fn has_pending(&self, session_id: i64) -> bool
pub async fn has_pending(&self, session_id: i64) -> bool
Sourcepub async fn pending_count(&self) -> usize
pub async fn pending_count(&self) -> usize
Get the count of pending interactions.
Auto Trait Implementations§
impl !Freeze for UserInteractionRegistry
impl !RefUnwindSafe for UserInteractionRegistry
impl Send for UserInteractionRegistry
impl Sync for UserInteractionRegistry
impl Unpin for UserInteractionRegistry
impl !UnwindSafe for UserInteractionRegistry
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
Mutably borrows from an owned value. Read more
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>
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 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>
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