use async_trait::async_trait;
#[derive(Debug)]
pub struct QueryResponse {
pub query_id: String,
pub response: String,
pub usage: Option<crate::TokenUsage>,
}
#[async_trait]
pub trait EngineApi: Send + Sync {
async fn run(
&self,
code: Option<String>,
code_file: Option<String>,
ctx: Option<serde_json::Value>,
project_root: Option<String>,
) -> Result<String, String>;
async fn advice(
&self,
strategy: &str,
task: Option<String>,
opts: Option<serde_json::Value>,
project_root: Option<String>,
) -> Result<String, String>;
async fn continue_single(
&self,
session_id: &str,
response: String,
query_id: Option<&str>,
usage: Option<crate::TokenUsage>,
) -> Result<String, String>;
async fn continue_batch(
&self,
session_id: &str,
responses: Vec<QueryResponse>,
) -> Result<String, String>;
async fn status(&self, session_id: Option<&str>) -> Result<String, String>;
async fn eval(
&self,
scenario: Option<String>,
scenario_file: Option<String>,
scenario_name: Option<String>,
strategy: &str,
strategy_opts: Option<serde_json::Value>,
auto_card: bool,
) -> Result<String, String>;
async fn eval_history(&self, strategy: Option<&str>, limit: usize) -> Result<String, String>;
async fn eval_detail(&self, eval_id: &str) -> Result<String, String>;
async fn eval_compare(&self, eval_id_a: &str, eval_id_b: &str) -> Result<String, String>;
async fn scenario_list(&self) -> Result<String, String>;
async fn scenario_show(&self, name: &str) -> Result<String, String>;
async fn scenario_install(&self, url: String) -> Result<String, String>;
async fn pkg_link(
&self,
path: String,
name: Option<String>,
force: Option<bool>,
) -> Result<String, String>;
async fn pkg_list(&self, project_root: Option<String>) -> Result<String, String>;
async fn pkg_install(&self, url: String, name: Option<String>) -> Result<String, String>;
async fn pkg_unlink(&self, name: String) -> Result<String, String>;
async fn pkg_remove(
&self,
name: &str,
project_root: Option<String>,
version: Option<String>,
) -> Result<String, String>;
async fn add_note(
&self,
session_id: &str,
content: &str,
title: Option<&str>,
) -> Result<String, String>;
async fn log_view(
&self,
session_id: Option<&str>,
limit: Option<usize>,
max_chars: Option<usize>,
) -> Result<String, String>;
async fn stats(
&self,
strategy_filter: Option<&str>,
days: Option<u64>,
) -> Result<String, String>;
async fn init(&self, project_root: Option<String>) -> Result<String, String>;
async fn update(&self, project_root: Option<String>) -> Result<String, String>;
async fn migrate(&self, project_root: Option<String>) -> Result<String, String>;
async fn card_list(&self, pkg: Option<String>) -> Result<String, String>;
async fn card_get(&self, card_id: &str) -> Result<String, String>;
async fn card_find(
&self,
pkg: Option<String>,
scenario: Option<String>,
model: Option<String>,
sort: Option<String>,
limit: Option<usize>,
min_pass_rate: Option<f64>,
) -> Result<String, String>;
async fn card_alias_list(&self, pkg: Option<String>) -> Result<String, String>;
async fn card_get_by_alias(&self, name: &str) -> Result<String, String>;
async fn card_alias_set(
&self,
name: &str,
card_id: &str,
pkg: Option<String>,
note: Option<String>,
) -> Result<String, String>;
async fn card_append(
&self,
card_id: &str,
fields: serde_json::Value,
) -> Result<String, String>;
async fn card_samples(
&self,
card_id: &str,
offset: Option<usize>,
limit: Option<usize>,
) -> Result<String, String>;
async fn info(&self) -> String;
}