Skip to main content

paladin/
lib.rs

1//! # Paladin - Enterprise Multi-Agent Orchestration Framework
2//!
3//! Paladin is a Rust-based enterprise multi-agent orchestration framework built with
4//! **Hexagonal Architecture** (Ports & Adapters) and **Domain-Driven Design** principles.
5//! It enables the creation, coordination, and scaling of intelligent AI agents (Paladins)
6//! through configurable orchestration patterns with comprehensive LLM integration.
7//!
8//! ## Core Concepts
9//!
10//! - **Paladin**: Autonomous AI agent capable of reasoning and action
11//! - **Battalion**: Multi-agent coordination patterns (Formation, Phalanx, Campaign, Chain of Command)
12//! - **Garrison**: Conversation memory and context storage
13//! - **Arsenal**: External tool execution via MCP (Model Context Protocol)
14//! - **Sanctum**: Vector storage for semantic search and RAG
15//! - **Citadel**: State persistence and recovery
16//!
17//! ## Architecture
18//!
19//! The framework follows hexagonal architecture with three layers:
20//!
21//! - **Core Layer** (`core`): Pure business logic with zero external dependencies
22//! - **Application Layer** (`application`): Application services and coordination logic
23//! - **Infrastructure Layer** (`infrastructure`): Adapter implementations for external systems
24//!
25//! ## Facade Crate Role
26//!
27//! The `paladin` crate is the **application assembly point and composition root** for the
28//! Paladin workspace. It wires together all leaf crates into a runnable application.
29//!
30//! ### What this crate contains
31//!
32//! - **`ServiceRunner`** — the composition root that assembles and starts all services
33//! - **Application services** (`src/application/services/`) — coordination logic for
34//!   agents, battalions, arsenals, orchestration, herald, sanctum, and more
35//! - **Configuration** (`src/config/`) — settings types and multi-source config loading
36//! - **CLI modules** (`src/application/cli/`) — command implementations (requires
37//!   `cli` feature flag)
38//! - **Binary entry points** — `main.rs` (default binary) and `bin/paladin-cli.rs`
39//!   (requires `cli` feature flag)
40//!
41//! ### What this crate does NOT contain
42//!
43//! Business logic, port trait definitions, and infrastructure adapter implementations
44//! live exclusively in the leaf crates. The facade only assembles them.
45//!
46//! ### Leaf crates
47//!
48//! | Crate | Capability |
49//! |-------|------------|
50//! | `paladin-core` | Domain entities, base types, pure business logic |
51//! | `paladin-ports` | Port trait definitions (output and input ports) |
52//! | `paladin-battalion` | Multi-agent coordination patterns |
53//! | `paladin-llm` | LLM provider adapters (OpenAI, Anthropic, DeepSeek) |
54//! | `paladin-memory` | Garrison memory adapters (in-memory, SQLite, vector) |
55//! | `paladin-notifications` | Notification channel adapters |
56//! | `paladin-storage` | Storage adapters (SQLite, MySQL, MinIO/S3) |
57//! | `paladin-content` | Content processing and ingestion |
58//! | `paladin-web` | Web API adapter (Axum-based REST server) |
59//!
60//! **Dependency direction:** facade → leaf crates (one direction only). Leaf crates
61//! must never import from the facade.
62//!
63//! ## Stable Public API
64//!
65//! This library exports a **curated stable public API** defined in [STABLE_API.md](https://github.com/DF3NDR/paladin-dev-env/blob/main/STABLE_API.md).
66//! The API follows **semantic versioning** with strong backwards compatibility guarantees:
67//!
68//! - **Port Traits**: Primary extension points for integrating external systems
69//! - **Domain Entities**: Core business types (Paladin, Battalion, etc.)
70//! - **Builders**: Fluent construction patterns
71//! - **Configuration**: Application settings types
72//! - **Errors**: Comprehensive error enums
73//! - **Base Types**: Generic framework primitives
74//!
75//! ## Quick Start
76//!
77//! ```rust,ignore
78//! use paladin::{PaladinBuilder, LlmPort};
79//! use std::sync::Arc;
80//!
81//! # async fn example(llm_port: Arc<dyn LlmPort>) -> Result<(), Box<dyn std::error::Error>> {
82//! // Create a Paladin agent
83//! let paladin = PaladinBuilder::new(llm_port)
84//!     .name("ResearchAgent")
85//!     .system_prompt("You are a helpful research assistant.")
86//!     .max_loops(5)
87//!     .build()?;
88//!
89//! // Execute the agent
90//! let result = paladin_service.execute(&paladin, "Analyze the market trends").await?;
91//! println!("Response: {}", result.output);
92//! # Ok(())
93//! # }
94//! ```
95//!
96//! ## Feature Flags
97//!
98//! - `redis-queue` (default): Redis-based async queue support
99//! - `s3-storage` (default): MinIO/S3 file storage support
100//! - `mysql-backend`: MySQL database backend
101//! - `sqlite-backend`: SQLite database backend
102//!
103//! ## Documentation
104//!
105//! - [API Reference](https://docs.rs/paladin)
106//! - [User Guides](https://github.com/DF3NDR/paladin-dev-env/tree/main/docs)
107//! - [Examples](https://github.com/DF3NDR/paladin-dev-env/tree/main/examples)
108//! - [Stable API Contract](https://github.com/DF3NDR/paladin-dev-env/blob/main/STABLE_API.md)
109//!
110//! ## Stability Guarantee
111//!
112//! All types exported from this module are part of the stable public API and follow
113//! semantic versioning. Breaking changes will only occur in major version bumps.
114//! See [STABLE_API.md](https://github.com/DF3NDR/paladin-dev-env/blob/main/STABLE_API.md) for details.
115
116#![warn(missing_docs)]
117#![allow(rustdoc::broken_intra_doc_links)]
118#![allow(rustdoc::redundant_explicit_links)]
119#![allow(rustdoc::invalid_html_tags)]
120#![doc(html_root_url = "https://docs.rs/paladin/0.1.0")]
121
122// ============================================================================
123// Module Declarations
124// ============================================================================
125//
126// Modules are public to support tests, examples, and advanced use cases,
127// but the **curated exports below** define the stable public API.
128// Users should prefer the root-level re-exports over direct module access.
129
130/// Application layer: Use cases and port trait definitions
131pub mod application;
132
133/// Configuration management
134pub mod config;
135
136/// Core domain layer: Pure business logic
137pub mod core;
138
139/// Infrastructure layer: Adapter implementations
140pub mod infrastructure;
141
142/// Prelude: convenient re-exports of the most commonly used types.
143pub mod prelude;
144
145// ============================================================================
146// CLI Module (Internal/Testing Support)
147// ============================================================================
148//
149// Re-export CLI module for testing and internal tooling.
150// Only available when the `cli` feature is enabled.
151// This is NOT part of the stable public API.
152
153/// CLI module for internal tooling (not part of stable API).
154/// Requires the `cli` feature flag.
155#[cfg(feature = "cli")]
156pub use application::cli;
157
158// ============================================================================
159// Stable Public API — Short-path Aliases
160// ============================================================================
161//
162// Only exports with confirmed workspace consumers are listed here.
163// All other types should be accessed via their full crate paths
164// (e.g. `paladin_ports::`, `paladin_memory::`, `paladin_battalion::`, etc.).
165
166// LLM adapter implementations (from paladin-llm crate)
167pub use paladin_llm::provider_factory::LlmProviderFactory;
168
169#[cfg(feature = "llm-openai")]
170pub use paladin_llm::openai::{OpenAIAdapter, OpenAIConfig};
171
172#[cfg(feature = "openai-embeddings")]
173pub use paladin_llm::openai::embedding::{OpenAIEmbeddingAdapter, OpenAIEmbeddingConfig};
174
175#[cfg(feature = "llm-anthropic")]
176pub use paladin_llm::anthropic::{AnthropicAdapter, AnthropicConfig};
177
178#[cfg(feature = "llm-deepseek")]
179pub use paladin_llm::deepseek::{DeepSeekAdapter, DeepSeekConfig};
180
181pub use paladin_llm::mock::{MockLlmAdapter, MultiStepMockLlmPort};
182
183// Paladin (Agent) Types
184pub use core::platform::container::paladin::{Paladin, PaladinData, PaladinStatus};
185pub use core::platform::container::paladin_config::PaladinConfig;
186
187// Battalion (Multi-Agent) Types
188pub use core::platform::container::battalion::{BattalionConfig, BattalionError};