Skip to main content

Crate cap_rs

Crate cap_rs 

Source
Expand description

§cap-rs — Rust reference implementation of the CAP (CLI Agent Protocol).

See https://cap-protocol.org for the protocol specification.

§Layout

  • core — protocol types (events, frames, capabilities, manifest). Always available, no IO dependencies.
  • driver — backends that drive an actual CLI agent. Each backend is gated behind a feature flag.

§Quick start

[dependencies]
cap-rs = { version = "0.1", features = ["stream-json"] }
use cap_rs::driver::stream_json::ClaudeCodeDriver;
use cap_rs::core::{ClientFrame, Content};

let mut driver = ClaudeCodeDriver::spawn(std::env::current_dir()?).await?;
driver.send(ClientFrame::Prompt {
    content: vec![Content::Text("What is 2 + 2?".into())],
}).await?;

while let Some(event) = driver.next_event().await {
    println!("{event:?}");
}

Modules§

core
Core protocol types — events, frames, content blocks, usage.
driver
Driver backends — concrete implementations that drive a CLI agent.

Constants§

CRATE_NAME
Crate name (build-time constant).
CRATE_VERSION
Crate version (build-time constant).
PROTOCOL_VERSION
CAP protocol version targeted by this crate.