Expand description
§cli-agents
Build agentic apps on top of your users’ existing AI subscriptions.
Instead of requiring API keys or managing token costs, cli-agents spawns
the AI CLI tools users already have installed — Claude Code, Codex, or
Gemini CLI — and provides a unified interface for streaming events,
tool calls, cancellation, and structured results.
§Quick start
use cli_agents::{run, RunOptions, StreamEvent, CliName};
use std::sync::Arc;
#[tokio::main]
async fn main() {
let opts = RunOptions {
cli: Some(CliName::Claude),
task: "What is 2+2?".into(),
skip_permissions: true,
..Default::default()
};
let handle = run(opts, Some(Arc::new(|event: StreamEvent| {
match &event {
StreamEvent::TextDelta { text } => print!("{text}"),
StreamEvent::Done { result } => println!("\n\nDone: {:?}", result.success),
_ => {}
}
})));
let result = handle.result.await.unwrap().unwrap();
println!("Success: {}", result.success);
}Re-exports§
pub use error::Error;pub use error::Result;pub use events::Severity;pub use events::StreamEvent;pub use runner::RunHandle;pub use runner::run;pub use types::ClaudeOptions;pub use types::CliName;pub use types::CodexOptions;pub use types::GeminiOptions;pub use types::McpServer;pub use types::McpTransport;pub use types::ProviderOptions;pub use types::RunOptions;pub use types::RunResult;pub use types::RunStats;
Modules§
Constants§
- DEFAULT_
MAX_ OUTPUT_ BYTES - Default max stdout buffer size: 10 MB.