pub struct Sandbox { /* private fields */ }Expand description
Approval-owning boundary around one execution backend.
Implementations§
Source§impl Sandbox
impl Sandbox
Sourcepub fn new(backend: Arc<dyn SandboxBackend>, policy: ApprovalPolicy) -> Self
pub fn new(backend: Arc<dyn SandboxBackend>, policy: ApprovalPolicy) -> Self
Creates a sandbox with its initial approval policy.
Sourcepub fn isolated_execution(&self) -> Result<Self>
pub fn isolated_execution(&self) -> Result<Self>
Creates a child execution boundary with independent temporary files and workers.
§Errors
Returns an error if validation or an operation required by this function fails.
Sourcepub fn attached_folders(self, primary: PathBuf, attached: Vec<PathBuf>) -> Self
pub fn attached_folders(self, primary: PathBuf, attached: Vec<PathBuf>) -> Self
Adds the primary workspace and attached folder paths to the model prompt.
Sourcepub fn read<'a>(
&'a self,
path: &'a str,
permissions: &'a ToolPermissions,
) -> BoxFuture<'a, Result<String>>
pub fn read<'a>( &'a self, path: &'a str, permissions: &'a ToolPermissions, ) -> BoxFuture<'a, Result<String>>
Reads a UTF-8 file.
Sourcepub fn read_bytes<'a>(
&'a self,
path: &'a str,
max_bytes: usize,
permissions: &'a ToolPermissions,
) -> BoxFuture<'a, Result<Vec<u8>>>
pub fn read_bytes<'a>( &'a self, path: &'a str, max_bytes: usize, permissions: &'a ToolPermissions, ) -> BoxFuture<'a, Result<Vec<u8>>>
Reads one bounded binary file.
Sourcepub fn write<'a>(
&'a self,
path: &'a str,
content: &'a str,
permissions: &'a ToolPermissions,
) -> BoxFuture<'a, Result<()>>
pub fn write<'a>( &'a self, path: &'a str, content: &'a str, permissions: &'a ToolPermissions, ) -> BoxFuture<'a, Result<()>>
Writes a UTF-8 file when this call has mutation authority.
Sourcepub fn execute<'a>(
&'a self,
command: &'a str,
permissions: &'a ToolPermissions,
) -> BoxFuture<'a, Result<CommandOutput>>
pub fn execute<'a>( &'a self, command: &'a str, permissions: &'a ToolPermissions, ) -> BoxFuture<'a, Result<CommandOutput>>
Runs a command when this call has mutation authority.
Sourcepub async fn evaluate_worker(
&self,
command: &WorkerCommand,
permissions: &ToolPermissions,
request: &[u8],
timeout: Duration,
reset: bool,
) -> Result<Vec<u8>>
pub async fn evaluate_worker( &self, command: &WorkerCommand, permissions: &ToolPermissions, request: &[u8], timeout: Duration, reset: bool, ) -> Result<Vec<u8>>
Evaluates one authorized request, preserving runtime state until explicit reset or loss.
§Errors
Returns an error if validation or an operation required by this function fails.
Sourcepub async fn browser_page(
&self,
permissions: &ToolPermissions,
) -> Option<String>
pub async fn browser_page( &self, permissions: &ToolPermissions, ) -> Option<String>
The page a call’s chat may drive in a browser outside the sandbox, as a DevTools endpoint. That browser reaches the network from outside the sandbox, so only calls allowed network access are lent one.