retro_core/analysis/backend.rs
1use crate::errors::CoreError;
2
3/// Response from an AI backend call.
4pub struct BackendResponse {
5 /// The AI's response text (inner result extracted from wrapper).
6 pub text: String,
7 /// Input tokens consumed.
8 pub input_tokens: u64,
9 /// Output tokens produced.
10 pub output_tokens: u64,
11}
12
13/// Trait for AI analysis backends. Sync only — no async.
14pub trait AnalysisBackend {
15 /// Execute a prompt and return the response text and cost.
16 /// When `json_schema` is provided, the backend passes it to `--json-schema`
17 /// for constrained decoding (guaranteed valid JSON matching the schema).
18 fn execute(&self, prompt: &str, json_schema: Option<&str>) -> Result<BackendResponse, CoreError>;
19}