Rust SDK
Systems services, ML infra, Rust CLIs.
Blocking Rust client. `chirp::track` is a synchronous wrapper that opens an activity, runs your closure, and closes on return. Outcome is inferred from the closure's `Result` - `Ok(_)` is green, `Err(_)` is red with the error message. Pure-blocking design (`reqwest::blocking`) keeps the API simple.
If you're in async Rust (tokio, async-std), call from `tokio::task::spawn_blocking` so the HTTP calls don't block the runtime. Most use cases - CLIs, build scripts, ML training loops - are sync, so the blocking client is the right default.
Prerequisites
- Rust 1.70+ (cargo edition 2021).
- A Chirp account.
Setup
- 1
Add chirp to Cargo.toml
cargo add chirpworks, or add manually:shell[dependencies] chirp = "0.5" anyhow = "1.0" # for the example below - 2
Pair your laptop
Run
chirp loginonce. The SDK reads~/.chirp/credentials.shellchirp login - 3
Wrap your work with chirp::track
Closure-based API. The SDK propagates anything that implements
std::error::Error; pair withanyhowfor ergonomic error context.main.rsuse chirp::{track, AgentOptions}; use anyhow::Result; fn main() -> Result<()> { track(AgentOptions::new("train") .schema("@training") .theme("#22c55e"), |agent| { for epoch in 1..=10 { agent.update(format!("epoch {epoch}/10"))?; train_one_epoch(epoch)?; } Ok(()) })?; Ok(()) } - 4
(Optional) From async code
If you're in tokio, wrap with
spawn_blockingso the HTTP calls don't stall the runtime. The closure'sResultis what the activity outcome reads from.shelltokio::task::spawn_blocking(|| { chirp::track(AgentOptions::new("ingest"), |agent| { agent.update("processing batch")?; process_batch()?; Ok::<_, anyhow::Error>(()) }) }).await??;
What you’ll see
Card header: Rust crab logo + "Rust · WORKING" + agent name. Action line shows the latest `update()` argument. Closes green on `Ok`, red on `Err` with the Display impl of the error chain. Panics also close the card red (with the panic message) - the SDK installs a panic-catch so you don't lose the card on unwind.
Troubleshooting
- Compile error about reqwest features.
- Chirp's reqwest dependency uses default features (rustls). If you have a project-wide reqwest with
default-features = false, you may need to enablerustls-tlsexplicitly. Runcargo tree -i reqwestto find conflicts. - Activity doesn't open when running from a CI matrix.
- Most CI matrices run with
RUST_LOG=warnor similar - the SDK's first call logs an info-level startup message, but if the network call itself fails (proxy / firewall) the SDK silently swallows the error to avoid breaking your build. SetCHIRP_DEBUG=1to surface failures. - I want to update from multiple threads.
- The
Agenthandle inside the closure isSend + Sync. Clone it viaagent.clone()(it's anArcunder the hood) and move into worker threads.