use everruns::{Agent, Engine, Jev, Model};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let live = std::env::args().nth(1).is_some_and(|arg| arg == "--live");
let model = if live {
#[cfg(feature = "openai")]
{
println!("OpenAI gpt-5.6-terra, classifying through TypeSafe.\n");
Model::new("gpt-5.6-terra", everruns::OpenAI::from_env()?)
}
#[cfg(not(feature = "openai"))]
{
return Err("Live mode needs --features typesafe,openai".into());
}
} else {
println!("Offline simulator: the model does not really call the tool.\n");
Model::simulated("The subject line reads as high-pressure marketing.")
};
let key = std::env::var("TYPESAFE_API_KEY").unwrap_or_else(|_| "offline-placeholder".into());
let agent = Agent::builder()
.name("reviewer")
.instructions(
"You review copy. When asked how something reads, measure it with \
jev_evaluate and report the numbers rather than judging by eye.",
)
.model(model)
.capability(Jev::new(key))
.build()?;
let session = Engine::new().create(agent);
let turn = session
.run("Rate this subject line for pushiness: 'Act now before it is too late'")
.await?;
println!("{}", turn.response);
println!("\ntool calls: {}", turn.tool_calls);
Ok(())
}