use enki_runtime::config::MeshConfig;
use enki_runtime::core::agent::AgentContext;
use enki_runtime::core::error::Result;
use enki_runtime::core::mesh::Mesh;
use enki_runtime::llm::LlmAgent;
use enki_runtime::local::LocalMesh;
use enki_runtime::LlmAgentFromConfig; use std::time::Duration;
#[tokio::main]
async fn main() -> Result<()> {
println!("=== Enki Runtime - TOML Agent Configuration Example ===\n");
let config_path = concat!(env!("CARGO_MANIFEST_DIR"), "/examples/agents.toml");
println!("Loading configuration from: {}\n", config_path);
let mesh_config = MeshConfig::from_file(config_path)?;
println!("Mesh name: {}", mesh_config.name);
println!("Number of agents: {}\n", mesh_config.agents.len());
let mesh = LocalMesh::new(&mesh_config.name);
for agent_config in &mesh_config.agents {
println!("Creating agent: {}", agent_config.name);
println!(" Model: {}", agent_config.model);
println!(" Temperature: {:?}", agent_config.temperature);
println!(" Max tokens: {:?}", agent_config.max_tokens);
let agent = LlmAgent::from_config(agent_config.clone())?;
mesh.add_agent(Box::new(agent)).await?;
}
println!("\n✓ All agents created successfully from TOML configuration\n");
println!("Testing the researcher agent with a query...\n");
if let Some(researcher_config) = mesh_config.get_agent("researcher") {
let mut test_agent = LlmAgent::from_config(researcher_config.clone())?;
let mut ctx = AgentContext::new(mesh_config.name.clone(), None);
let response = test_agent
.send_message_and_get_response(
"What are the main benefits of using Rust for systems programming? Keep it brief.",
&mut ctx,
)
.await?;
println!("========================================");
println!(" RESEARCHER RESPONSE");
println!("========================================\n");
println!("{}", response);
println!("\n========================================\n");
}
println!("Starting mesh with all configured agents...");
mesh.start().await?;
tokio::time::sleep(Duration::from_millis(500)).await;
mesh.stop().await?;
println!("Mesh stopped.\n");
println!("=== Example completed successfully ===");
Ok(())
}