use async_trait::async_trait;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone)]
pub struct AiRequest {
pub system_prompt: String,
pub user_prompt: String,
pub json_schema: Option<String>,
pub working_dir: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AiUsage {
pub input_tokens: u64,
pub output_tokens: u64,
pub cost_usd: Option<f64>,
}
#[derive(Debug, Clone)]
pub struct AiResponse {
pub text: String,
pub usage: Option<AiUsage>,
}
#[derive(Debug, Clone)]
pub enum AiEvent {
ToolCall { tool: String, input: String },
}
#[async_trait]
pub trait AiProvider: Send + Sync {
fn name(&self) -> &str;
async fn is_available(&self) -> bool;
async fn request(
&self,
req: &AiRequest,
events: Option<tokio::sync::mpsc::UnboundedSender<AiEvent>>,
) -> anyhow::Result<AiResponse>;
}