pub struct ToolAskRule {
pub tool: String,
pub command: Option<String>,
pub command_exact: bool,
pub path: Option<String>,
pub workspace: Option<String>,
pub action: PermissionAction,
}Expand description
Typed rule that controls whether a tool invocation is denied, allowed, or requires approval.
The action field governs what happens when this rule matches:
"deny"— the tool call is blocked outright (highest priority)."ask"— the approval prompt is forced (default, backward compatible)."allow"— the tool call proceeds without asking.
Inside one ruleset layer, deny wins over ask, which wins over allow.
Higher-priority layers are selected before action and specificity.
Command-prefix-based deny and allow rules loaded from permissions.toml
are also promoted into the execution-policy engine’s denied_prefixes /
trusted_prefixes for arity-aware matching; path-only rules are evaluated
separately.
Fields§
§tool: StringName of the tool this rule applies to (e.g. "exec_shell", "edit_file").
command: Option<String>Optional command prefix to match against (uses arity-aware matching).
command_exact: boolMatch command as the complete invocation instead of as a prefix.
Approval-card remembered grants set this so approving one safe command cannot silently authorize a later invocation with extra arguments.
path: Option<String>Optional workspace-relative file path matched exactly after normalization.
workspace: Option<String>Optional absolute workspace root that limits this rule to one repo.
Rules authored without a workspace retain the historical global scope.
action: PermissionActionAction when this rule matches. Default: "ask" (backward compatible).
Implementations§
Source§impl ToolAskRule
impl ToolAskRule
Sourcepub fn new(tool: impl Into<String>) -> ToolAskRule
pub fn new(tool: impl Into<String>) -> ToolAskRule
Creates a new ask rule matching any invocation of the given tool.
Sourcepub fn exec_shell(command: impl Into<String>) -> ToolAskRule
pub fn exec_shell(command: impl Into<String>) -> ToolAskRule
Creates an ask rule for exec_shell matching a specific command prefix.
Sourcepub fn file_path(
tool: impl Into<String>,
path: impl Into<String>,
) -> ToolAskRule
pub fn file_path( tool: impl Into<String>, path: impl Into<String>, ) -> ToolAskRule
Creates an ask rule for a file-tool matching a specific path pattern.
Sourcepub fn into_exact_workspace_allow(
self,
workspace: impl Into<String>,
) -> ToolAskRule
pub fn into_exact_workspace_allow( self, workspace: impl Into<String>, ) -> ToolAskRule
Convert an exact rule candidate into a repo-scoped persistent allow.
Trait Implementations§
Source§impl Clone for ToolAskRule
impl Clone for ToolAskRule
Source§fn clone(&self) -> ToolAskRule
fn clone(&self) -> ToolAskRule
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ToolAskRule
impl Debug for ToolAskRule
Source§impl<'de> Deserialize<'de> for ToolAskRule
impl<'de> Deserialize<'de> for ToolAskRule
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolAskRule, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolAskRule, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for ToolAskRule
Source§impl PartialEq for ToolAskRule
impl PartialEq for ToolAskRule
Source§impl Serialize for ToolAskRule
impl Serialize for ToolAskRule
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for ToolAskRule
Auto Trait Implementations§
impl Freeze for ToolAskRule
impl RefUnwindSafe for ToolAskRule
impl Send for ToolAskRule
impl Sync for ToolAskRule
impl Unpin for ToolAskRule
impl UnsafeUnpin for ToolAskRule
impl UnwindSafe for ToolAskRule
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.