pub struct SandboxTool<S: CodeSandbox> { /* private fields */ }Expand description
A BaseTool that executes code in a sandboxed environment.
Disabled by default. Call SandboxTool::with_dangerously_allow to enable
execution. See the module docs for the security model.
Implementations§
Source§impl<S: CodeSandbox> SandboxTool<S>
impl<S: CodeSandbox> SandboxTool<S>
Sourcepub fn new(sandbox: S, language: Language) -> Self
pub fn new(sandbox: S, language: Language) -> Self
Create a new sandbox tool with the given backend and default language.
Execution is disabled until
with_dangerously_allow is called.
Sourcepub fn with_timeout(self, ms: u64) -> Self
pub fn with_timeout(self, ms: u64) -> Self
Set the execution timeout in milliseconds.
Sourcepub fn with_dangerously_allow(self, allow: bool) -> Self
pub fn with_dangerously_allow(self, allow: bool) -> Self
Explicitly enables code execution (disabled by default).
Trait Implementations§
Source§impl<S: CodeSandbox + 'static> BaseTool for SandboxTool<S>
impl<S: CodeSandbox + 'static> BaseTool for SandboxTool<S>
Source§fn description(&self) -> &str
fn description(&self) -> &str
Returns the tool description. Read more
Source§fn run<'life0, 'async_trait>(
&'life0 self,
input: String,
) -> Pin<Box<dyn Future<Output = Result<String, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn run<'life0, 'async_trait>(
&'life0 self,
input: String,
) -> Pin<Box<dyn Future<Output = Result<String, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the tool (string version). Read more
Source§fn return_direct(&self) -> bool
fn return_direct(&self) -> bool
Whether to return result directly to user. Read more
Source§fn risk(&self) -> ToolRiskProfile
fn risk(&self) -> ToolRiskProfile
Declared Rule-of-Two risk profile (A2, v0.22.1). Read more
Auto Trait Implementations§
impl<S> Freeze for SandboxTool<S>where
S: Freeze,
impl<S> RefUnwindSafe for SandboxTool<S>where
S: RefUnwindSafe,
impl<S> Send for SandboxTool<S>
impl<S> Sync for SandboxTool<S>
impl<S> Unpin for SandboxTool<S>where
S: Unpin,
impl<S> UnsafeUnpin for SandboxTool<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for SandboxTool<S>where
S: UnwindSafe,
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
Mutably borrows from an owned value. Read more