1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! # Cerebro Swarm Module
//!
//! Multi-agent swarming orchestration powered by Cerebro's three-tier memory engine.
//! Agents collaborate through Working Memory (KV), Episodic Memory (conversation logs),
//! and Semantic Memory (vector search) to solve complex tasks.
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use cerebro::prelude::*;
//! use cerebro::swarm::prelude::*;
//! use std::sync::Arc;
//!
//! #[tokio::main]
//! async fn main() {
//! // Build Cerebro memory components
//! let chunker = Arc::new(RecursiveCharacterChunker::new(512, 50));
//! let embedder = Arc::new(MockEmbedder::new(8));
//! let store = Arc::new(MemoryVectorStore::new());
//! let engine = Arc::new(MemoryEngine::new(chunker, embedder, store));
//! let kv = Arc::new(MemoryKVStore::new());
//!
//! // Create the memory bus
//! let memory = Arc::new(CerebroMemoryBus::new(engine, kv));
//!
//! // Build the orchestrator and register agents
//! let mut orchestrator = SwarmOrchestrator::new(memory);
//! orchestrator.register_agent(AgentConfig {
//! id: "researcher".into(),
//! name: "Research Agent".into(),
//! system_prompt: "You research topics thoroughly.".into(),
//! model: LlmProvider::Ollama {
//! model: "llama3".into(),
//! base_url: "http://localhost:11434".into(),
//! },
//! tools: vec![],
//! handoff_targets: vec![],
//! max_steps: 10,
//! });
//!
//! // Execute a swarm
//! let result = orchestrator.execute(
//! SwarmPattern::Sequential { agent_order: vec!["researcher".into()] },
//! "Explain Rust's ownership model",
//! ).await.unwrap();
//!
//! println!("{}", result.final_output);
//! }
//! ```
/// Convenience prelude for the swarm module.