pub struct PermissionRules {
pub autonomous: bool,
pub sandbox: SandboxLevel,
pub disallowed_tools: Vec<String>,
pub allowed_tools: Vec<String>,
pub allowed_edit_paths: Vec<PathBuf>,
pub deny_read_only: bool,
pub extra_writable_dirs: Vec<PathBuf>,
}Expand description
Unified permission rules that each agent translates into its native flags.
Instead of hardcoding --permission-mode bypassPermissions for Claude and
--sandbox workspace-write for Codex, we define a single set of rules and
let each AgentRunner format them for its CLI.
Fields§
§autonomous: boolWhether the agent runs fully autonomous (no user prompts).
sandbox: SandboxLevelSandbox level for filesystem access.
disallowed_tools: Vec<String>Tool patterns to disallow (e.g., ["Bash(rm *)", "Bash(rm -*)"]).
allowed_tools: Vec<String>Tools to allow (whitelist). Overrides disallowed_tools when non-empty.
Items are either agent-native tool names (e.g., “Edit”, “Write”, “Bash”)
or CLI command names (e.g., “git”, “npm”) which get translated to
agent-specific patterns (e.g., Bash(git*) for Claude).
allowed_edit_paths: Vec<PathBuf>Paths where the agent is allowed to edit files (worktree path). When set, Edit/Write tools are scoped to these paths only. Set dynamically per invocation (not from config).
deny_read_only: boolRestrict to orchestration-only operations — denies Read, Glob, Grep, and Bash commands for browsing/reading files (ls, cat, find, etc.). Agents translate this into their native permission model.
extra_writable_dirs: Vec<PathBuf>Additional directories that must be writable (e.g. the git common dir
when running inside a worktree whose .git metadata lives outside the
sandbox root). Codex translates these into --add-dir flags; other
agents ignore the field.
Implementations§
Source§impl PermissionRules
impl PermissionRules
Sourcepub fn from_config() -> Self
pub fn from_config() -> Self
Load permission rules from config, falling back to defaults.
Sourcepub fn deny_read_only() -> Self
pub fn deny_read_only() -> Self
Restriction preset for control sessions: denies Read, Glob, Grep, and Bash commands that read files or list directories (ls, cat, find, etc.).
The agent remains autonomous but is prevented from browsing or reading
arbitrary files on the host machine. Translation into agent-native flags
is handled by each AgentRunner::build_command() implementation.
Trait Implementations§
Source§impl Clone for PermissionRules
impl Clone for PermissionRules
Source§impl Debug for PermissionRules
impl Debug for PermissionRules
Auto Trait Implementations§
impl Freeze for PermissionRules
impl RefUnwindSafe for PermissionRules
impl Send for PermissionRules
impl Sync for PermissionRules
impl Unpin for PermissionRules
impl UnsafeUnpin for PermissionRules
impl UnwindSafe for PermissionRules
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,
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