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 get_sandbox_by_uuid(&self, uuid: &str) -> Result<SandboxInfo>
pub async fn get_sandbox_by_uuid(&self, uuid: &str) -> Result<SandboxInfo>
Get info about a sandbox by UUID.
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 browser(
&self,
name: &str,
memory_mb: Option<u64>,
) -> Result<BrowserSession>
pub async fn browser( &self, name: &str, memory_mb: Option<u64>, ) -> Result<BrowserSession>
Create a browser sandbox with Playwright/Chromium pre-installed.
Returns a BrowserSession you can use to navigate pages, take
screenshots, and evaluate JavaScript expressions.
§Example
let client = agentkernel_sdk::AgentKernel::builder().build()?;
let mut browser = client.browser("my-browser", None).await?;
let page = browser.goto("https://example.com").await?;
println!("{}", page.title);
browser.remove().await?;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.
Sourcepub async fn list_orchestrations(&self) -> Result<Vec<Orchestration>>
pub async fn list_orchestrations(&self) -> Result<Vec<Orchestration>>
List all orchestrations.
Sourcepub async fn create_orchestration(
&self,
payload: OrchestrationCreateRequest,
) -> Result<Orchestration>
pub async fn create_orchestration( &self, payload: OrchestrationCreateRequest, ) -> Result<Orchestration>
Create a new orchestration.
Sourcepub async fn get_orchestration(&self, id: &str) -> Result<Orchestration>
pub async fn get_orchestration(&self, id: &str) -> Result<Orchestration>
Get a single orchestration by id.
Sourcepub async fn signal_orchestration(
&self,
id: &str,
payload: Value,
) -> Result<Orchestration>
pub async fn signal_orchestration( &self, id: &str, payload: Value, ) -> Result<Orchestration>
Raise an external event for an orchestration.
Sourcepub async fn terminate_orchestration(
&self,
id: &str,
payload: Option<Value>,
) -> Result<Orchestration>
pub async fn terminate_orchestration( &self, id: &str, payload: Option<Value>, ) -> Result<Orchestration>
Terminate an orchestration.
Sourcepub async fn list_orchestration_definitions(
&self,
) -> Result<Vec<OrchestrationDefinition>>
pub async fn list_orchestration_definitions( &self, ) -> Result<Vec<OrchestrationDefinition>>
List orchestration definitions.
Sourcepub async fn upsert_orchestration_definition(
&self,
payload: OrchestrationDefinition,
) -> Result<OrchestrationDefinition>
pub async fn upsert_orchestration_definition( &self, payload: OrchestrationDefinition, ) -> Result<OrchestrationDefinition>
Register or update an orchestration definition.
Sourcepub async fn get_orchestration_definition(
&self,
name: &str,
) -> Result<OrchestrationDefinition>
pub async fn get_orchestration_definition( &self, name: &str, ) -> Result<OrchestrationDefinition>
Get an orchestration definition by name.
Sourcepub async fn delete_orchestration_definition(
&self,
name: &str,
) -> Result<String>
pub async fn delete_orchestration_definition( &self, name: &str, ) -> Result<String>
Delete an orchestration definition by name.
Sourcepub async fn list_objects(&self) -> Result<Vec<DurableObject>>
pub async fn list_objects(&self) -> Result<Vec<DurableObject>>
List all objects.
Sourcepub async fn create_object(
&self,
payload: DurableObjectCreateRequest,
) -> Result<DurableObject>
pub async fn create_object( &self, payload: DurableObjectCreateRequest, ) -> Result<DurableObject>
Create a new object.
Sourcepub async fn get_object(&self, id: &str) -> Result<DurableObject>
pub async fn get_object(&self, id: &str) -> Result<DurableObject>
Get a single object by id.
Sourcepub async fn call_object(
&self,
class: &str,
object_id: &str,
method: &str,
args: Value,
) -> Result<Value>
pub async fn call_object( &self, class: &str, object_id: &str, method: &str, args: Value, ) -> Result<Value>
Call a method on a durable object (auto-creates/wakes if needed).
Sourcepub async fn delete_object(&self, id: &str) -> Result<String>
pub async fn delete_object(&self, id: &str) -> Result<String>
Delete a durable object by id.
Sourcepub async fn patch_object(
&self,
id: &str,
payload: Value,
) -> Result<DurableObject>
pub async fn patch_object( &self, id: &str, payload: Value, ) -> Result<DurableObject>
Partially update a durable object (storage and/or status).
Sourcepub async fn list_schedules(&self) -> Result<Vec<Schedule>>
pub async fn list_schedules(&self) -> Result<Vec<Schedule>>
List all schedules.
Sourcepub async fn create_schedule(
&self,
payload: ScheduleCreateRequest,
) -> Result<Schedule>
pub async fn create_schedule( &self, payload: ScheduleCreateRequest, ) -> Result<Schedule>
Create a new schedule.
Sourcepub async fn get_schedule(&self, id: &str) -> Result<Schedule>
pub async fn get_schedule(&self, id: &str) -> Result<Schedule>
Get a single schedule by id.
Sourcepub async fn delete_schedule(&self, id: &str) -> Result<String>
pub async fn delete_schedule(&self, id: &str) -> Result<String>
Delete a schedule by id.
Sourcepub async fn list_stores(&self) -> Result<Vec<DurableStore>>
pub async fn list_stores(&self) -> Result<Vec<DurableStore>>
List all durable stores.
Sourcepub async fn create_store(
&self,
payload: DurableStoreCreateRequest,
) -> Result<DurableStore>
pub async fn create_store( &self, payload: DurableStoreCreateRequest, ) -> Result<DurableStore>
Create a new durable store.
Sourcepub async fn get_store(&self, id: &str) -> Result<DurableStore>
pub async fn get_store(&self, id: &str) -> Result<DurableStore>
Get a durable store by id.
Sourcepub async fn delete_store(&self, id: &str) -> Result<String>
pub async fn delete_store(&self, id: &str) -> Result<String>
Delete a durable store by id.
Sourcepub async fn query_store(
&self,
id: &str,
payload: Value,
) -> Result<DurableStoreQueryResult>
pub async fn query_store( &self, id: &str, payload: Value, ) -> Result<DurableStoreQueryResult>
Run a read query against a durable store.
Sourcepub async fn execute_store(
&self,
id: &str,
payload: Value,
) -> Result<DurableStoreExecuteResult>
pub async fn execute_store( &self, id: &str, payload: Value, ) -> Result<DurableStoreExecuteResult>
Run a write statement against a durable store.
Sourcepub async fn command_store(
&self,
id: &str,
payload: Value,
) -> Result<DurableStoreCommandResult>
pub async fn command_store( &self, id: &str, payload: Value, ) -> Result<DurableStoreCommandResult>
Run a command against a durable store (Redis-style engines).
Sourcepub async fn extend_ttl(
&self,
name: &str,
by: &str,
) -> Result<ExtendTtlResponse>
pub async fn extend_ttl( &self, name: &str, by: &str, ) -> Result<ExtendTtlResponse>
Extend a sandbox’s time-to-live.
Sourcepub async fn list_snapshots(&self) -> Result<Vec<SnapshotMeta>>
pub async fn list_snapshots(&self) -> Result<Vec<SnapshotMeta>>
List all snapshots.
Sourcepub async fn take_snapshot(
&self,
opts: TakeSnapshotOptions,
) -> Result<SnapshotMeta>
pub async fn take_snapshot( &self, opts: TakeSnapshotOptions, ) -> Result<SnapshotMeta>
Take a snapshot of a sandbox.
Sourcepub async fn get_snapshot(&self, name: &str) -> Result<SnapshotMeta>
pub async fn get_snapshot(&self, name: &str) -> Result<SnapshotMeta>
Get info about a snapshot.
Sourcepub async fn delete_snapshot(&self, name: &str) -> Result<()>
pub async fn delete_snapshot(&self, name: &str) -> Result<()>
Delete a snapshot.
Sourcepub async fn restore_snapshot(&self, name: &str) -> Result<SandboxInfo>
pub async fn restore_snapshot(&self, name: &str) -> Result<SandboxInfo>
Restore a sandbox from a snapshot.
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