Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/release-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Verify spawnbox crate release

# Dry-run verification of the `spawnbox` crate before a local `cargo publish`.
on:
workflow_dispatch:

permissions:
contents: read

jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1

- name: Install Rust toolchain
run: rustup toolchain install

- name: Check formatting, lints, and tests
run: |
cargo fmt --all -- --check
cargo clippy -p spawnbox --all-targets --locked -- -D warnings
cargo test -p spawnbox --locked

- name: Dry-run package verification
run: cargo publish --dry-run -p spawnbox --locked
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["crates/spawn-api","crates/spawn-bench","crates/spawn-egress","crates/spawn-guest","crates/spawn-node","crates/spawn-proto","crates/spawnbox-cli"]
members = ["crates/spawn-api","crates/spawn-bench","crates/spawn-egress","crates/spawn-guest","crates/spawn-node","crates/spawn-proto","crates/spawnbox","crates/spawnbox-cli"]
resolver = "3"

[workspace.package]
Expand Down
14 changes: 14 additions & 0 deletions crates/spawnbox/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Changelog

All notable changes to `spawnbox` are documented in this file.

The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this crate adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.0] - 2026-11-30

### Added
- `SpawnboxClient` async HTTP client for the Spawnbox control plane (`/v1`) with validated base URLs, bearer token authentication, typed `SpawnboxError`, automatic retries on `429`/`502`/`503`/`504` (`Retry-After` and jittered exponential backoff), and `404` -> `Ok(None)` lookups.
- High-level helpers for tenants (`ensure_tenant`), secrets (`upsert_secret`), templates (`ensure_template`), sandboxes (`create_sandbox`, `get_sandbox`, `list_sandboxes`, `delete_sandbox`), and command execution (`exec`).
- `ForwardClient` for streaming HTTP/SSE proxying through Spawnbox's app-forward listener with `x-spawnbox-target` and optional shared-secret headers.
- `encode_path_segment` helper for safe URL path construction.
30 changes: 30 additions & 0 deletions crates/spawnbox/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "spawnbox"
version = "0.1.0"
edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true
documentation = "https://docs.rs/spawnbox"
readme = "README.md"
description = "Async Rust HTTP client SDK for the self-hosted Spawnbox sandbox runtime"
keywords = ["spawnbox", "sandbox", "microvm", "firecracker", "sdk"]
categories = ["api-bindings", "asynchronous"]

[lints]
workspace = true

[dependencies]
bytes = "1"
rand = "0.10.3"
reqwest = { version = "0.13.5", default-features = false, features = ["rustls-no-provider", "json", "stream", "http2"] }
rustls = { version = "0.23.46", default-features = false, features = ["ring", "std", "tls12"] }
serde = { version = "1.0.229", features = ["derive"] }
serde_json = "1.0.154"
thiserror = "2.0.21"
tokio = { version = "1.54.1", features = ["time"] }
url = "2.5.8"

[dev-dependencies]
futures-util = "0.3.34"
tokio = { version = "1.54.1", features = ["rt-multi-thread", "macros", "net", "io-util", "time"] }
47 changes: 47 additions & 0 deletions crates/spawnbox/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# spawnbox

Async Rust HTTP client SDK for the self-hosted Spawnbox sandbox runtime.

## Quickstart

```rust,no_run
use std::time::Duration;
use serde_json::json;
use spawnbox::{ForwardClient, Method, SpawnboxClient};

#[tokio::main]
async fn main() -> spawnbox::Result<()> {
let client = SpawnboxClient::new("http://127.0.0.1:8080", "sbx_api_key")?;

client.ensure_tenant("default", None).await?;
client
.ensure_template(
"python-dev",
&json!({ "name": "python-dev", "base": "base" }),
Duration::from_secs(2),
60,
)
.await?;

let sandbox = client
.create_sandbox(&json!({ "template": "python-dev" }))
.await?;
let sandbox_id = sandbox["id"].as_str().unwrap();

let exec_result = client
.exec(sandbox_id, &json!({ "cmd": ["python3", "--version"] }))
.await?;
println!("{exec_result}");

let forward = ForwardClient::new("http://127.0.0.1:8082", Some("fwd_key".into()))?;
let resp = forward
.request(Method::GET, sandbox_id, 8000, "/events")
.header("Accept", "text/event-stream")
.send()
.await?;
println!("forward status: {}", resp.status());

client.delete_sandbox(sandbox_id).await?;
Ok(())
}
```
Loading
Loading