Skip to main content

Crate cacp_agents

Crate cacp_agents 

Source
Expand description

An ACP agent as a program on this machine: find it in the catalog, and put it on disk.

The registry is the protocol’s own catalog, pinned to exact versions — so an agent’s build never changes underfoot the way npx <pkg>@latest does. Agents install once into a data directory and run straight from there, keeping package managers out of the chat path.

let catalog = cacp_agents::registry::catalog(cache_dir).expect("a catalog");
let agent = &catalog.agents[0];

let installed = match cacp_agents::Installed::find(data_dir, &agent.id) {
    Some(installed) => installed,
    None => agent.install(data_dir, |line| println!("{line}"))?,
};

println!("{} {}", installed.command, installed.args.join(" "));

Hand that command to cacp::spawn with whatever working directory and stderr the caller wants. Everything here blocks — it reaches the network and runs npm — so call it off a worker rather than inside a turn.

Re-exports§

pub use registry::Agent;
pub use registry::Distribution;
pub use registry::Registry;

Modules§

mcp
The official MCP registry: search it, and install what it lists.
registry
The protocol’s catalog of ACP agents, pinned to exact versions.

Structs§

Installed
A local installation: the command to spawn, its arguments, and anything the agent needs in its environment to speak ACP at all.

Functions§

contained
dir joined with a relative path the registry supplied — at least one component, every one a plain name. An id or a cmd that climbs out, or an empty one naming dir itself, would aim an install — or the remove_dir_all that undoes one — somewhere it was never given.
package_name
The package name in a spec like @scope/name@1.2.3 — the version separator is the last @ that isn’t the scope’s leading one.