use agentor::prelude::*;
use tracing_subscriber::EnvFilter;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt()
.with_env_filter(
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")),
)
.init();
println!("=== Agentor: Agent-native Actor Runtime ===\n");
let env = Environment::new();
env.set_config("model", "gpt-4");
env.set_secret("OPENAI_API_KEY", "sk-demo-key");
let mut system = ActorSystem::with_environment("agentor", env);
println!("[system] ActorSystem '{}' created", system.name());
let agent = AgentActor::new("planner-agent");
let agent_ref = system.spawn_default(Box::new(agent));
println!("[system] Agent spawned: {}", agent_ref.id());
agent_ref
.tell(AgentMessage::UserPrompt(
"Help me plan a trip to Tokyo".to_string(),
))
.await?;
println!("[main] sent UserPrompt to agent");
agent_ref
.tell(AgentMessage::ToolResult {
tool_name: "weather_api".to_string(),
output: "Tokyo: 22°C, sunny".to_string(),
})
.await?;
println!("[main] sent ToolResult to agent");
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
system.shutdown().await;
println!("\n[system] shutdown complete");
Ok(())
}