cacp_agents/lib.rs
1//! An ACP agent as a program on this machine: find it in the catalog, and put
2//! it on disk.
3//!
4//! The registry is the protocol's own catalog, pinned to exact versions — so an
5//! agent's build never changes underfoot the way `npx <pkg>@latest` does.
6//! Agents install once into a data directory and run straight from there,
7//! keeping package managers out of the chat path.
8//!
9//! ```no_run
10//! # fn main() -> anyhow::Result<()> {
11//! # let (cache_dir, data_dir) = (std::path::Path::new("cache"), std::path::Path::new("data"));
12//! let catalog = cacp_agents::registry::catalog(cache_dir).expect("a catalog");
13//! let agent = &catalog.agents[0];
14//!
15//! let installed = match cacp_agents::Installed::find(data_dir, &agent.id) {
16//! Some(installed) => installed,
17//! None => agent.install(data_dir, |line| println!("{line}"))?,
18//! };
19//!
20//! println!("{} {}", installed.command, installed.args.join(" "));
21//! # Ok(()) }
22//! ```
23//!
24//! Hand that command to [`cacp::spawn`] with whatever working directory and
25//! stderr the caller wants. Everything here blocks — it reaches the network and
26//! runs `npm` — so call it off a worker rather than inside a turn.
27//!
28//! [`cacp::spawn`]: https://docs.rs/cacp
29
30#[cfg(feature = "install")]
31pub use install::Installed;
32pub use registry::{Agent, Distribution, Registry};
33pub use utils::{contained, package_name};
34
35pub mod mcp;
36pub mod registry;
37
38#[cfg(feature = "install")]
39mod install;
40mod utils;