pub enum State {
None,
Active(Arc<Rights>),
Unavailable(String),
}Expand description
The rights in force for one call.
Variants§
None
No session profile: the Instance’s own rules apply.
Active(Arc<Rights>)
A valid session profile.
A profile is configured but unusable: everything is refused.
Implementations§
Source§impl State
impl State
pub fn is_active(&self) -> bool
Sourcepub fn check_write(&self, target: &Path) -> Result<(), String>
pub fn check_write(&self, target: &Path) -> Result<(), String>
Whether this session may write target (absolute or relative to the
process’s working directory).
Sourcepub fn check_tool_as(&self, name: &str, canonical: &str) -> Result<(), String>
pub fn check_tool_as(&self, name: &str, canonical: &str) -> Result<(), String>
The refusal for calling tool name, if any. canonical is the name
of the handler an alias runs (the shell alias runs ctx_shell): a
denied tool stays denied under every name.
Sourcepub fn check_tool(&self, name: &str) -> Result<(), String>
pub fn check_tool(&self, name: &str) -> Result<(), String>
State::check_tool_as for a tool that is its own handler.
Sourcepub fn check_bash(
&self,
command: &str,
cwd: &Path,
env_keys: &[&str],
) -> Result<(), String>
pub fn check_bash( &self, command: &str, cwd: &Path, env_keys: &[&str], ) -> Result<(), String>
Whether a shell command may run: every write it names must pass the
write decision relative to cwd, and anything shell cannot
analyse is refused with its rule.
env_keys are the names the caller will add to the child’s
environment (ctx_shell’s env argument); they are judged like a
leading KEY=value assignment and seen by the git merge rule.
Sourcepub fn check_code(
&self,
language: &str,
code: &str,
cwd: &Path,
) -> Result<(), String>
pub fn check_code( &self, language: &str, code: &str, cwd: &Path, ) -> Result<(), String>
Whether code given to a LeanCTX runner (ctx_execute) may run: shell
code is analysed like a command line, any other language is refused
under a profile because what it writes cannot be seen.
Sourcepub fn check_native_tool(
&self,
tool: &str,
input: &Value,
cwd: &Path,
) -> Result<(), String>
pub fn check_native_tool( &self, tool: &str, input: &Value, cwd: &Path, ) -> Result<(), String>
The decision for a host’s native tool call (a PreToolUse hook):
Edit/Write/MultiEdit/NotebookEdit by their target path,
apply_patch by the files its patch names, Bash by its command line,
a known read-only tool passes, every other tool is refused.
cwd is the session’s working directory from the hook payload.
Trait Implementations§
Auto Trait Implementations§
impl Forget for State
impl Freeze for State
impl Move for State
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnsafeUnpin for State
impl UnwindSafe for State
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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