pub struct PermissionRegistry { /* private fields */ }Expand description
Registry for managing permission requests and session-level grants.
This registry tracks tools that are blocked waiting for permission and provides methods for the UI to query and respond to these requests. It also caches session-level grants to avoid re-asking.
Implementations§
Source§impl PermissionRegistry
impl PermissionRegistry
Sourcepub fn new(event_tx: Sender<ControllerEvent>) -> Self
pub fn new(event_tx: Sender<ControllerEvent>) -> Self
Create a new PermissionRegistry.
§Arguments
event_tx- Channel to send events when permissions are requested.
Sourcepub async fn is_granted(
&self,
session_id: i64,
request: &PermissionRequest,
) -> bool
pub async fn is_granted( &self, session_id: i64, request: &PermissionRequest, ) -> bool
Sourcepub async fn register(
&self,
tool_use_id: String,
session_id: i64,
request: PermissionRequest,
turn_id: Option<TurnId>,
) -> Result<Receiver<PermissionResponse>, PermissionError>
pub async fn register( &self, tool_use_id: String, session_id: i64, request: PermissionRequest, turn_id: Option<TurnId>, ) -> Result<Receiver<PermissionResponse>, PermissionError>
Register a permission request and get a receiver to await on.
This is called by the AskForPermissionsTool 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 permission.request- The permission request details.turn_id- Optional turn ID for this request.
§Returns
A oneshot receiver that will receive the user’s response.
Sourcepub async fn respond(
&self,
tool_use_id: &str,
response: PermissionResponse,
) -> Result<(), PermissionError>
pub async fn respond( &self, tool_use_id: &str, response: PermissionResponse, ) -> Result<(), PermissionError>
Sourcepub async fn pending_for_session(
&self,
session_id: i64,
) -> Vec<PendingPermissionInfo>
pub async fn pending_for_session( &self, session_id: i64, ) -> Vec<PendingPermissionInfo>
Sourcepub async fn cancel_session(&self, session_id: i64)
pub async fn cancel_session(&self, session_id: i64)
Cancel all pending permission requests 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 clear_session(&self, session_id: i64)
pub async fn clear_session(&self, session_id: i64)
Clear all grants for a session.
This is called when a session ends or is reset.
§Arguments
session_id- Session ID to clear grants for.
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 permission requests.
Sourcepub async fn session_grants(&self, session_id: i64) -> HashSet<PermissionGrant>
pub async fn session_grants(&self, session_id: i64) -> HashSet<PermissionGrant>
Auto Trait Implementations§
impl !Freeze for PermissionRegistry
impl !RefUnwindSafe for PermissionRegistry
impl Send for PermissionRegistry
impl Sync for PermissionRegistry
impl Unpin for PermissionRegistry
impl !UnwindSafe for PermissionRegistry
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> 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 more