use std::path::PathBuf;
use nucel_agent_sdk::{AgentExecutor, CodexExecutor, SpawnConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let working_dir: PathBuf = std::env::args()
.nth(1)
.map(PathBuf::from)
.unwrap_or_else(|| std::env::current_dir().expect("cwd"));
let executor = CodexExecutor::new();
if !executor.availability().available {
eprintln!("codex CLI not available — install it first.");
return Ok(());
}
let config = SpawnConfig {
model: Some("gpt-5-codex".into()),
budget_usd: Some(1.0),
..Default::default()
};
println!("spawn…");
let session = executor
.spawn(
&working_dir,
"What language is this project written in? Just the name, one line.",
&config,
)
.await?;
let session_id = session.session_id.clone();
println!("got session_id = {session_id}");
let first = session
.query("And what's the dependency manager?")
.await?;
println!("first.content = {}", first.content);
session.close().await?;
println!("\nresume…");
let resumed = executor
.resume(
&working_dir,
&session_id,
"Now tell me how to run the tests.",
&config,
)
.await?;
println!("resumed.session_id = {}", resumed.session_id);
let second = resumed.query("Any common gotchas?").await?;
println!("second.content = {}", second.content);
let cost = resumed.total_cost().await?;
println!("total spent: ${:.4}", cost.total_usd);
resumed.close().await?;
Ok(())
}