modular_agent_core/lib.rs
1#![recursion_limit = "256"]
2//! # Modular Agent Core
3//!
4//! A Rust framework for building modular multi-agent orchestration systems.
5//!
6//! This crate provides tools and abstractions to create, configure, and run agents
7//! in a stream-based architecture. It supports defining agent behaviors, managing
8//! agent flows, and handling agent input/output through a channel-based messaging system.
9//!
10//! ## Core Concepts
11//!
12//! ### ModularAgent
13//!
14//! [`ModularAgent`] is the central orchestrator that manages agent lifecycle, connections,
15//! and message routing. It maintains agent instances, connection maps, and handles events.
16//!
17//! ### Agents
18//!
19//! Agents are processing units that receive messages via channels and process them
20//! asynchronously. Implement the [`AsAgent`] trait to create custom agents, or use the
21//! `#[modular_agent]` macro for declarative agent definitions.
22//!
23//! ### Presets
24//!
25//! Presets are collections of agents and their connections, defined in JSON format.
26//! They can be loaded from files and managed via [`ModularAgent`] methods.
27//!
28//! ## Quick Start
29//!
30//! See the [CLI example](https://github.com/modular-agent/modular-agent-core/blob/main/examples/cli.rs)
31//! for a complete working example of loading a preset and running agents from the command line.
32//!
33//! ## Feature Flags
34//!
35//! - `file` - File handling support (enabled by default)
36//! - `image` - Image processing with photon-rs (enabled by default)
37//! - `llm` - LLM integration with Message/ToolCall types (enabled by default)
38//! - `mcp` - Model Context Protocol integration (enabled by default)
39//! - `test-utils` - Testing utilities including TestProbeAgent
40
41mod agent;
42mod config;
43mod context;
44mod definition;
45mod error;
46mod external_agent;
47mod id;
48mod message;
49mod modular_agent;
50mod output;
51mod preset;
52mod registry;
53mod runtime;
54mod spec;
55mod value;
56
57#[cfg(feature = "llm")]
58pub mod llm;
59pub mod tool;
60
61#[cfg(feature = "mcp")]
62pub mod mcp;
63
64#[cfg(feature = "test-utils")]
65pub mod test_utils;
66
67// re-export async_trait
68pub use async_trait::async_trait;
69
70// re-export photon_rs
71#[cfg(feature = "image")]
72pub use photon_rs::{self, PhotonImage};
73
74// re-export im
75pub use im;
76
77// re-export inventory
78pub use inventory;
79
80// re-export FnvIndexMap
81pub use fnv;
82pub use indexmap;
83pub type FnvIndexMap<K, V> = indexmap::IndexMap<K, V, fnv::FnvBuildHasher>;
84pub type FnvIndexSet<T> = indexmap::IndexSet<T, fnv::FnvBuildHasher>;
85
86// Re-export the crate under its canonical name for proc-macros.
87pub extern crate self as modular_agent_core;
88
89// Re-exports modular_agent_macros
90pub use modular_agent_macros::modular_agent;
91
92pub use agent::{Agent, AgentData, AgentStatus, AsAgent, HasAgentData, new_agent_boxed};
93pub use config::{AgentConfigs, AgentConfigsMap};
94pub use context::AgentContext;
95pub use definition::{AgentConfigSpec, AgentConfigSpecs, AgentDefinition, AgentDefinitions};
96pub use error::AgentError;
97pub use llm::{Message, ToolCall, ToolCallFunction};
98pub use modular_agent::{ModularAgent, ModularAgentEvent};
99pub use output::AgentOutput;
100pub use preset::{Preset, PresetInfo};
101pub use registry::AgentRegistration;
102pub use spec::{AgentSpec, ConnectionSpec, PresetSpec, PresetSpecs};
103pub use value::{AgentValue, AgentValueMap};