Expand description
Rust client for a hosted boxxkite control-plane – create sandboxes,
run commands, edit files, stream the audit log, take over a session’s
shell, over HTTP/WebSocket. Not the boxxkite package itself (the
self-hosted Python core that embeds SandboxManager against your own
Kubernetes cluster) – use this to talk to someone else’s running
control-plane, hosted or self-hosted, over its /v1/* REST API. See
docs/API.md in the boxxkite repository
for the full route/schema reference this crate wraps.
§Quickstart
use boxxkite_client::{Client, CreateSandboxOptions, ExecOptions};
let client = Client::new("https://your-control-plane.example.com", "bxk_live_...")?;
let sandbox = client
.create_sandbox(CreateSandboxOptions::new().label("demo"))
.await?;
let result = client.exec(&sandbox.id, "python3 -c 'print(1 + 1)'", ExecOptions::new()).await?;
println!("{}", result.stdout); // "2\n"
client.destroy_sandbox(&sandbox.id).await?;§Error handling
Every fallible call returns Result<T, BoxxkiteError>. A non-2xx
response becomes BoxxkiteError::Api (.status()/.code()); a
transport-level failure becomes BoxxkiteError::Connection. See
BoxxkiteError for the full set of variants.
§Scope
This crate wraps the same /v1/* API surface sdk-python/sdk-js/
sdk-go wrap: sandbox lifecycle, exec/file operations, the
http_request secrets-broker proxy, background processes
(start_process/list_processes/get_process_output/
send_process_input/stop_process), the audit log (get_log/watch),
human/desktop takeover, network-ingress preview URLs
(create_preview_url/revoke_preview_url), agent-invokable LSP
completions (lsp_start/lsp_open/lsp_completion/lsp_stop),
account/usage introspection, dashboard auth-flow helpers (password
reset/verify/resend/refresh/logout), the per-account command allowlist
(get_allowed_commands/set_allowed_commands/clear_allowed_commands),
the SandboxSession/Client::with_sandbox convenience helper, and
CRUD for images/volumes/outbound-MCP connections/webhooks/secrets.
Deliberately not included (see sdk-rust/README.md’s “Scope”
section for the full disclosure): a LangChain-style tool-factory wrapper
(no dominant Rust agent-framework tool-spec convention exists yet to
mirror), a synchronous/blocking client variant (this crate is
async-first via tokio, matching Rust’s ecosystem convention), and the
control-plane’s filesystem-snapshot routes (a real endpoint, but not
wrapped by sdk-python/sdk-js/sdk-go either as of this writing).
§Retries
Automatic retry with exponential backoff + jitter is opt-in via
ClientBuilder::max_retries/ClientBuilder::retry; see
RetryConfig for exactly which failures are retried (and which never
are). Off by default.
Structs§
- Account
- The account identity for the API key in use (
GET /v1/account). - Allowed
Command Rule - One account-level command-allowlist rule – either a bare command name
(
args_allow/args_denyboth empty) or a command name plus argument allow/deny regex lists. - Allowed
Commands Response - Body shape shared by
Client::get_allowed_commands/Client::set_allowed_commands. An emptyrulesmeans unrestricted – the default for every account. - Audit
LogEntry - One row of
GET /v1/sandboxes/{id}/log’s audit trail – one exec/file operation, whether issued by the agent (source: "agent") or by a human during atakeoversession (source: "human_takeover"). - Audit
LogResponse GET /v1/sandboxes/{id}/log’s response.- Client
- A client for a hosted boxxkite control-plane’s
/v1/*REST API. - Client
Builder - Builder for
Client.base_urlandapi_keyare required; everything else has a sensible default. - Create
Image Options - Builder for
POST /v1/images’s optional fields. - Create
Sandbox Options - Builder for
POST /v1/sandboxes’s optional fields. All fields are unset (server defaults apply) unless set via the chained setters. - Create
Secret Options - Builder for
POST /v1/secrets’s optional fields. - Create
Volume Options - Builder for
POST /v1/volumes’s optional fields. - Create
Webhook Options - Builder for
POST /v1/webhooks’s optional fields. - Exec
Options - Optional
execparameters. - Exec
Result POST /v1/sandboxes/{id}/exec’s response.- File
Create Result POST /v1/sandboxes/{id}/files’s response.- File
Options - A single optional
descriptionfield shared by every file-op request – a caller-supplied annotation surfaced later inget_log’s audit trail. - GetLog
Options - Optional
get_logpagination parameters. - Glob
Options - Optional
globparameters. - Glob
Result POST /v1/sandboxes/{id}/files/glob’s response.- Grep
Options - Optional
grepparameters. - Grep
Result POST /v1/sandboxes/{id}/files/grep’s response.- Http
Request Options - Optional
http_requestparameters. - Http
Request Result POST /v1/sandboxes/{id}/http-request’s response.- Image
- A custom sandbox image (
SandboxImageOut/SandboxImageBuildAccepted).Client::create_image’s response only ever populatesid/label/status/created_at– the rest fill in once you pollClient::get_imageand the build reaches a terminal state. - Ingest
Memory Options - Builder for
Client::ingest_memory’s optional fields. - List
Memories Options - Options for
Client::list_memories. - List
Webhook Deliveries Options - Optional
list_webhook_deliveriespagination parameters. - LsOptions
- Optional
lsparameters. - LsResult
POST /v1/sandboxes/{id}/files/ls’s response. Each entry’s shape isn’t pinned by the API contract (list[dict]server-side), so entries are left as raw JSON rather than an over-fitted struct.- LspCompletion
Result POST /v1/sandboxes/{id}/lsp/{lsp_id}/completion’s response. Each item is a raw LSPCompletionItemobject – left as raw JSON rather than an over-fitted struct, since the shape is the language server’s, not this API’s (matching howls/globleave their entries untyped).- LspOpen
Result POST /v1/sandboxes/{id}/lsp/{lsp_id}/open’s response.- LspStart
Result POST /v1/sandboxes/{id}/lsp/start’s response.lsp_idis an opaque handle to pass to the other LSP calls.- LspStop
Result POST /v1/sandboxes/{id}/lsp/{lsp_id}/stop’s response.- McpConnection
- A granted outbound-MCP connection (
McpConnectionOut). - Memory
- One durable, account-scoped memory (
POST/GET /v1/memory). - Memory
Ingest Response - Response from
Client::ingest_memoryandClient::import_memories. - Memory
Profile Response - Response from
Client::memory_profile– stable, long-lived memories separated from recently-touched ones. - Memory
Relation - One edge from
Client::memory_relations. - Memory
Relations Response - Response from
Client::memory_relations(GET /v1/memory/{id}/relations). - Memory
Search Hit - A memory returned from
Client::recall, with its retrieval score. - Memory
Search Response - Response from
Client::recall(GET /v1/memory/search). - Message
Response - A generic ack body (e.g. a password-reset request, which returns the same message whether or not the email is registered).
- Preview
Revoke Result POST /v1/sandboxes/{id}/preview/{port}/revoke’s response.- Preview
Url - A signed, time-limited preview URL (
POST /v1/sandboxes/{id}/preview/{port}’s response). The URL carries its own authorization – no API key is needed to use it, only to mint it. - Process
Info - One tracked background process (
SandboxProcessInfo), as returned byClient::list_processes. - Process
Input Result POST /v1/sandboxes/{id}/processes/{process_id}/input’s response.- Process
List Result GET /v1/sandboxes/{id}/processes’s response.- Process
Output Result GET /v1/sandboxes/{id}/processes/{process_id}/output’s response.- Process
Start Result POST /v1/sandboxes/{id}/processes’s response.- Process
Stop Result POST /v1/sandboxes/{id}/processes/{process_id}/stop’s response.- Remember
Options - Builder for
Client::remember’s optional fields. - Retry
Config - Automatic-retry policy for a
Client, set viaClientBuilder::retry. - Sandbox
- A sandbox session (
SandboxSessionOut/SandboxCreatedResponse).usageis only present onClient::create_sandbox’s response, not onClient::get_sandbox/Client::list_sandboxes. - Sandbox
Connect Info - How to reach the sandbox session – an opaque handle for operators with
cluster access; external callers operate on the session through this
client’s own
exec/file-op methods instead (seedocs/API.md). - Sandbox
Session - A
Clientbound to one sandbox session id – obtained fromClient::with_sandbox. Holds a cheap clone of the underlyingClient(seeClient’s own note on cloning), so it isCloneand can outlive the borrow that produced it. - Secret
- A secret’s metadata (
SecretOut/SecretCreatedResponse). The raw value is never included here or anywhere else after creation. - Start
Process Options - Builder for
POST /v1/sandboxes/{id}/processes’s optional fields. - StrReplace
Options - Optional
str_replaceparameters. - StrReplace
Result POST /v1/sandboxes/{id}/files/str-replace’s response.- Token
Pair - A fresh
access_token+refresh_tokenpair plus the account identity, returned byClient::refresh_token. - Usage
Summary - Usage against this account’s fair-use limits, included on
Client::create_sandbox’s response. - View
Options - Optional
viewparameters. - View
Result POST /v1/sandboxes/{id}/files/view’s response.- Volume
- An independent, PVC-backed storage volume (
VolumeOut/VolumeAccepted).Client::create_volume’s response only ever populatesid/label/status/created_at– pollClient::get_volumeforstatusto reach"ready"(or"failed") before mounting it viacrate::CreateSandboxOptions::volume_mounts. - Webhook
- A webhook subscription (
WebhookOut/WebhookCreatedResponse).secretis only ever populated onClient::create_webhook’s response – the raw signing secret, shown exactly once; it cannot be retrieved again. - Webhook
Delivery - One delivery attempt for a webhook subscription
(
GET /v1/webhooks/{id}/deliveries’sWebhookDeliveryOut).
Enums§
- Boxxkite
Error - Everything this crate’s
Result<T, BoxxkiteError>can fail with. - Image
Base - Pre-approved base image for
Client::create_image. Each variant is itself a separate, boxxkite-maintained hardened image – never a caller-supplied arbitrary base OS. - McpCatalog
Id - A curated outbound-MCP catalog entry – restricted to boxxkite’s own reviewed allowlist, never a caller-supplied hostname.
- Process
Stream Event - One event from
GET /v1/sandboxes/{id}/processes/{process_id}/stream: anOutputper new stdout chunk, then a terminalExitonce the process finishes. - Sandbox
Size - CPU/memory size preset for a sandbox. Capped per-account by the
deployment’s
BOXXKITE_MAX_SANDBOX_SIZE– requesting a larger size than the account is allowed returns429. - Webhook
Event Type - Event types a webhook subscription can receive. See
docs/WEBHOOKS-DESIGN.mdfor the full event catalog.
Type Aliases§
- Desktop
Stream - The duplex byte stream returned by
Client::desktop_takeover. Send and receive raw bytes on it exactly as you would over a local terminal – there is no separate message envelope. - Takeover
Stream - The duplex byte stream returned by
Client::takeover. Send and receive raw bytes on it exactly as you would over a local terminal – there is no separate message envelope.