pub struct ConfinedCommand { /* private fields */ }Expand description
Builder for a subprocess confined by a ToolContext.
Like std::process::Command, but: the environment starts empty (only
vars added with ConfinedCommand::env reach the child), and
ConfinedCommand::spawn admission-checks exec, applies the OS sandbox,
and fails closed when a restricted axis cannot meet its required
enforcement floor.
Implementations§
Source§impl ConfinedCommand
impl ConfinedCommand
Sourcepub fn new(program: impl Into<String>) -> ConfinedCommand
pub fn new(program: impl Into<String>) -> ConfinedCommand
Start building a confined spawn of program (no inherited environment).
Sourcepub fn sandbox_policy(self, policy: Arc<SandboxPolicy>) -> ConfinedCommand
pub fn sandbox_policy(self, policy: Arc<SandboxPolicy>) -> ConfinedCommand
Set the sandbox mechanism policy (read/exec allow-lists, ABI floors) the OS backend will enforce. The default is today’s built-in allow-lists.
Sourcepub fn arg(self, arg: impl AsRef<OsStr>) -> ConfinedCommand
pub fn arg(self, arg: impl AsRef<OsStr>) -> ConfinedCommand
Append a single argument.
Sourcepub fn args<I, S>(self, args: I) -> ConfinedCommand
pub fn args<I, S>(self, args: I) -> ConfinedCommand
Append several arguments.
Sourcepub fn env(
self,
key: impl AsRef<OsStr>,
val: impl AsRef<OsStr>,
) -> ConfinedCommand
pub fn env( self, key: impl AsRef<OsStr>, val: impl AsRef<OsStr>, ) -> ConfinedCommand
Grant one environment variable to the child. This is the only way an env var reaches the child — there is no ambient inheritance.
Sourcepub fn current_dir(self, dir: impl AsRef<Path>) -> ConfinedCommand
pub fn current_dir(self, dir: impl AsRef<Path>) -> ConfinedCommand
Set the child’s working directory.
Sourcepub fn stdin(self, cfg: Stdio) -> ConfinedCommand
pub fn stdin(self, cfg: Stdio) -> ConfinedCommand
Configure the child’s stdin (e.g. Stdio::piped for an MCP server).
Sourcepub fn stdout(self, cfg: Stdio) -> ConfinedCommand
pub fn stdout(self, cfg: Stdio) -> ConfinedCommand
Configure the child’s stdout.
Sourcepub fn stderr(self, cfg: Stdio) -> ConfinedCommand
pub fn stderr(self, cfg: Stdio) -> ConfinedCommand
Configure the child’s stderr.
Sourcepub fn new_process_group(self) -> ConfinedCommand
pub fn new_process_group(self) -> ConfinedCommand
Start the child as leader of a fresh process group.
This is used by trusted worker supervisors that must terminate the worker and every descendant together. It is currently effective on Unix; other platforms retain their native child-process behavior.
Sourcepub fn spawn(self, cx: &ToolContext) -> Result<ConfinedChild, ToolError>
pub fn spawn(self, cx: &ToolContext) -> Result<ConfinedChild, ToolError>
Admission-check, confine, and spawn the child.
Order: (1) cx.check_exec(program) — deny before doing anything; (2)
derive the backend’s per-axis enforcement and refuse if a restricted
axis cannot meet its floor; (3) apply the selected thread- or
wrapper-based sandbox, then spawn inside that boundary.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ConfinedCommand
impl RefUnwindSafe for ConfinedCommand
impl Send for ConfinedCommand
impl Sync for ConfinedCommand
impl Unpin for ConfinedCommand
impl UnsafeUnpin for ConfinedCommand
impl UnwindSafe for ConfinedCommand
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<F, T> ConvertInto<T> for Fwhere
T: ConvertFrom<F>,
impl<F, T> ConvertInto<T> for Fwhere
T: ConvertFrom<F>,
Source§fn convert_into(self) -> T
fn convert_into(self) -> T
Self to a value of type T.Source§impl<F, T> ConvertTryFrom<F> for Twhere
F: ConvertInto<T>,
impl<F, T> ConvertTryFrom<F> for Twhere
F: ConvertInto<T>,
Source§impl<F, T> ConvertTryInto<T> for Fwhere
T: ConvertTryFrom<F>,
impl<F, T> ConvertTryInto<T> for Fwhere
T: ConvertTryFrom<F>,
Source§type Error = <T as ConvertTryFrom<F>>::Error
type Error = <T as ConvertTryFrom<F>>::Error
Source§fn convert_try_into(self) -> Result<T, <T as ConvertTryFrom<F>>::Error>
fn convert_try_into(self) -> Result<T, <T as ConvertTryFrom<F>>::Error>
Self to a value of type T.impl<T> ErasedDestructor for Twhere
T: 'static,
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