pub struct PermissionGate { /* private fields */ }Expand description
A registry of pending permission requests.
Each in-flight turn holds a shared Arc<PermissionGate>:
- The main loop registers a waiter and awaits via
Self::wait - The ACP bridge layer calls
Self::resolveafter receiving the client response
Implementations§
Source§impl PermissionGate
impl PermissionGate
pub fn new() -> Self
Sourcepub async fn wait(
&self,
id: ToolCallId,
cancel: CancellationToken,
) -> PermissionResolution
pub async fn wait( &self, id: ToolCallId, cancel: CancellationToken, ) -> PermissionResolution
Register a waiter and await until Self::resolve is called or cancel fires.
When cancel fires, returns PermissionResolution::Cancelled — the main loop
handles this as “User cancelled”.
If a waiter already exists for the same id, the old sender is dropped (the old
wait receives PermissionResolution::Cancelled, avoiding a hang). This path
should theoretically never be hit — the main loop only calls wait once per
tool_use.
Sourcepub fn resolve(&self, id: &ToolCallId, outcome: PermissionResolution)
pub fn resolve(&self, id: &ToolCallId, outcome: PermissionResolution)
Deliver the outcome to the waiter. If id has no waiter (already removed by
cancel, or the main loop hasn’t called wait yet), silently no-op — the ACP bridge
layer is unaware of main-loop timing, and duplicate or late resolves must not
corrupt the turn.