stubb/lib.rs
1//! Embed coding agents in your application.
2//!
3//! Stubb drives coding agents through their native protocols and exposes them
4//! through one provider-neutral interface, [`Provider`]. A [`Session`] is a
5//! conversation with an agent: [`subscribe`](Session::subscribe) to its
6//! events, then [`send`](Session::send) messages.
7//!
8//! # Layout
9//!
10//! - [`providers`]: the agents Stubb integrates. Codex, Claude Code and Pi are
11//! driven natively, and any agent that speaks the Agent Client Protocol
12//! through [`providers::acp`]. Each sits behind a Cargo feature of the same
13//! name, all enabled by default.
14//! - [`session`], [`turn`], [`catalog`], [`request`], [`permission`] and
15//! [`usage`]: the shared concepts every provider speaks, from models and
16//! their settings to the questions an agent asks during a turn.
17//! - [`observation`]: optional contracts for attributed activity across a
18//! session, such as subagent trees and native tasks. Providers without this
19//! support return [`Error::Unsupported`] rather than empty results.
20//! - [`discovery`]: finding, describing and updating the agents installed on
21//! this computer, without starting them.
22//! - [`process`]: how Stubb starts agent processes and what they inherit.
23//!
24//! Provider-specific behavior stays visible: each provider reports its
25//! [`capabilities`](Provider::capabilities), and unsupported operations
26//! return [`Error::Unsupported`].
27//!
28//! # Example
29//!
30//! ```no_run
31//! # #[cfg(feature = "claude")]
32//! # async fn demo() -> stubb::Result<()> {
33//! use stubb::providers::claude::{Claude, ClaudeConfig};
34//! use stubb::{session, turn};
35//!
36//! let provider = Claude::new(ClaudeConfig::default());
37//! let live = provider
38//! .start_session(session::Spec {
39//! cwd: std::env::current_dir()?,
40//! settings: session::Settings::default(),
41//! })
42//! .await?;
43//! let mut events = live.subscribe();
44//! live.send(turn::Input::text("Summarize this repository.")).await?;
45//! while let Ok(event) = events.recv().await {
46//! println!("{event:?}");
47//! }
48//! # Ok(())
49//! # }
50//! ```
51//!
52//! The `examples` directory has runnable programs for each step: `quickstart`,
53//! `models`, `sessions`, `chat`, and more.
54
55#![cfg_attr(docsrs, feature(doc_cfg))]
56// Shared helpers exist for the providers; with some compiled out, a few go
57// unused. The full build (every provider) still checks for dead code.
58#![cfg_attr(
59 not(all(feature = "claude", feature = "codex", feature = "pi", feature = "acp")),
60 allow(dead_code)
61)]
62
63mod core;
64pub mod providers;
65
66pub use core::catalog::Catalog;
67pub use core::discovery;
68pub use core::error::{Error, Result};
69pub use core::observation;
70pub use core::provider::{BoxFuture, Provider};
71pub use core::runtime::process;
72pub use core::session::Session;
73pub use core::{catalog, permission, provider, request, session, turn, usage};