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,
opts: Option<CreateSandboxOptions>,
) -> Result<SandboxInfo>
pub async fn create_sandbox( &self, name: &str, opts: Option<CreateSandboxOptions>, ) -> Result<SandboxInfo>
Create a new sandbox with optional configuration.
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],
opts: Option<ExecOptions>,
) -> Result<RunOutput>
pub async fn exec_in_sandbox( &self, name: &str, command: &[&str], opts: Option<ExecOptions>, ) -> Result<RunOutput>
Run a command in an existing sandbox.
Sourcepub async fn with_sandbox<F, Fut, T>(
&self,
name: &str,
opts: Option<CreateSandboxOptions>,
f: F,
) -> Result<T>
pub async fn with_sandbox<F, Fut, T>( &self, name: &str, opts: Option<CreateSandboxOptions>, 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 write_files(
&self,
name: &str,
files: HashMap<String, String>,
) -> Result<BatchFileWriteResponse>
pub async fn write_files( &self, name: &str, files: HashMap<String, String>, ) -> Result<BatchFileWriteResponse>
Write multiple files to a sandbox in one request.
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 exec_detached(
&self,
name: &str,
command: &[&str],
opts: Option<ExecOptions>,
) -> Result<DetachedCommand>
pub async fn exec_detached( &self, name: &str, command: &[&str], opts: Option<ExecOptions>, ) -> Result<DetachedCommand>
Start a detached (background) command in a sandbox.
Sourcepub async fn detached_status(
&self,
name: &str,
cmd_id: &str,
) -> Result<DetachedCommand>
pub async fn detached_status( &self, name: &str, cmd_id: &str, ) -> Result<DetachedCommand>
Get the status of a detached command.
Sourcepub async fn detached_logs(
&self,
name: &str,
cmd_id: &str,
stream: Option<&str>,
) -> Result<DetachedLogsResponse>
pub async fn detached_logs( &self, name: &str, cmd_id: &str, stream: Option<&str>, ) -> Result<DetachedLogsResponse>
Get logs from a detached command.
Sourcepub async fn detached_kill(&self, name: &str, cmd_id: &str) -> Result<String>
pub async fn detached_kill(&self, name: &str, cmd_id: &str) -> Result<String>
Kill a detached command.
Sourcepub async fn detached_list(&self, name: &str) -> Result<Vec<DetachedCommand>>
pub async fn detached_list(&self, name: &str) -> Result<Vec<DetachedCommand>>
List detached commands in 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
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more