use ditto_os::DittoServer;
use tracing::{error, info};
use tracing_subscriber::fmt;

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
    // Initialize logging
    fmt::init();

    info!("Starting Ditto - Self-hostable Browser for AI Agents");

    // Create server with default config
    let server = DittoServer::new(ditto_os::ServerConfig::default());

    // Initialize the server
    if let Err(e) = server.initialize().await {
        error!("Failed to initialize server: {}", e);
        return Err(e);
    }

    info!("Ditto server initialized successfully");
    info!("Starting web server on http://0.0.0.0:8080");
    info!("API Documentation: http://0.0.0.0:8080/api/v1/system/health");
    info!("Default Admin API Key: sk-ditto-admin-2024");

    // Start the server
    if let Err(e) = server.start().await {
        error!("Server failed: {}", e);
        return Err(e);
    }

    Ok(())
}
