pub struct AgentKernel { /* private fields */ }Expand description
Client for the agentkernel HTTP API.
§Example
let client = agentkernel_sdk::AgentKernel::builder().build()?;
let output = client.run(&["echo", "hello"], None).await?;
println!("{}", output.output);Implementations§
Source§impl AgentKernel
impl AgentKernel
Sourcepub fn builder() -> AgentKernelBuilder
pub fn builder() -> AgentKernelBuilder
Create a new builder with defaults resolved from env vars.
Sourcepub async fn run(
&self,
command: &[&str],
opts: Option<RunOptions>,
) -> Result<RunOutput>
pub async fn run( &self, command: &[&str], opts: Option<RunOptions>, ) -> Result<RunOutput>
Run a command in a temporary sandbox.
Sourcepub async fn list_sandboxes(&self) -> Result<Vec<SandboxInfo>>
pub async fn list_sandboxes(&self) -> Result<Vec<SandboxInfo>>
List all sandboxes.
Sourcepub async fn create_sandbox(
&self,
name: &str,
image: Option<&str>,
vcpus: Option<u32>,
memory_mb: Option<u64>,
profile: Option<SecurityProfile>,
) -> Result<SandboxInfo>
pub async fn create_sandbox( &self, name: &str, image: Option<&str>, vcpus: Option<u32>, memory_mb: Option<u64>, profile: Option<SecurityProfile>, ) -> Result<SandboxInfo>
Create a new sandbox with optional resource limits.
Sourcepub async fn get_sandbox(&self, name: &str) -> Result<SandboxInfo>
pub async fn get_sandbox(&self, name: &str) -> Result<SandboxInfo>
Get info about a sandbox.
Sourcepub async fn remove_sandbox(&self, name: &str) -> Result<()>
pub async fn remove_sandbox(&self, name: &str) -> Result<()>
Remove a sandbox.
Sourcepub async fn exec_in_sandbox(
&self,
name: &str,
command: &[&str],
) -> Result<RunOutput>
pub async fn exec_in_sandbox( &self, name: &str, command: &[&str], ) -> Result<RunOutput>
Run a command in an existing sandbox.
Sourcepub async fn with_sandbox<F, Fut, T>(
&self,
name: &str,
image: Option<&str>,
f: F,
) -> Result<T>
pub async fn with_sandbox<F, Fut, T>( &self, name: &str, image: Option<&str>, f: F, ) -> Result<T>
Create a sandbox and return a guard that removes it on drop.
Use with_sandbox for guaranteed cleanup via a closure.
Sourcepub async fn read_file(
&self,
name: &str,
path: &str,
) -> Result<FileReadResponse>
pub async fn read_file( &self, name: &str, path: &str, ) -> Result<FileReadResponse>
Read a file from a sandbox.
Sourcepub async fn write_file(
&self,
name: &str,
path: &str,
content: &str,
encoding: Option<&str>,
) -> Result<String>
pub async fn write_file( &self, name: &str, path: &str, content: &str, encoding: Option<&str>, ) -> Result<String>
Write a file to a sandbox.
Sourcepub async fn delete_file(&self, name: &str, path: &str) -> Result<String>
pub async fn delete_file(&self, name: &str, path: &str) -> Result<String>
Delete a file from a sandbox.
Sourcepub async fn get_sandbox_logs(&self, name: &str) -> Result<Vec<Value>>
pub async fn get_sandbox_logs(&self, name: &str) -> Result<Vec<Value>>
Get audit log entries for a sandbox.
Sourcepub async fn batch_run(
&self,
commands: Vec<BatchCommand>,
) -> Result<BatchRunResponse>
pub async fn batch_run( &self, commands: Vec<BatchCommand>, ) -> Result<BatchRunResponse>
Run multiple commands in parallel.
Trait Implementations§
Source§impl Clone for AgentKernel
impl Clone for AgentKernel
Source§fn clone(&self) -> AgentKernel
fn clone(&self) -> AgentKernel
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AgentKernel
impl !RefUnwindSafe for AgentKernel
impl Send for AgentKernel
impl Sync for AgentKernel
impl Unpin for AgentKernel
impl !UnwindSafe for AgentKernel
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