Skip to main content

Module permission

Module permission 

Source
Expand description

Permission-policy helpers that wrap an existing handler::SessionHandler. Permission-policy helpers that compose with an existing SessionHandler.

These wrap an inner handler and override only permission requests, forwarding every other event (tool calls, user input, elicitation, session events) to the inner handler. Use them when you have a custom tool handler — typically a ToolHandlerRouter — but want a one-line policy for permission prompts.

For a full handler that approves or denies everything, see ApproveAllHandler and DenyAllHandler.

§Example

let router = ToolHandlerRouter::new(vec![], Arc::new(ApproveAllHandler));
// Inherit the router's tool dispatch but auto-approve all permission prompts:
let handler = permission::approve_all(Arc::new(router));

Functions§

approve_all
Wrap inner so that every HandlerEvent::PermissionRequest is auto-approved. All other events are forwarded to inner.
approve_if
Wrap inner with a closure-based policy: predicate is called for each permission request; true approves, false denies. All other events are forwarded to inner.
deny_all
Wrap inner so that every HandlerEvent::PermissionRequest is auto-denied. All other events are forwarded to inner.