use crate::signals::{ParsedSignal, SessionLog};
use async_trait::async_trait;
use evolve_core::agent_config::AgentConfig;
use evolve_core::ids::AdapterId;
use std::path::Path;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum AdapterError {
#[error("io: {0}")]
Io(#[from] std::io::Error),
#[error("json: {0}")]
Json(#[from] serde_json::Error),
#[error("adapter not applicable at {path}")]
NotApplicable {
path: String,
},
#[error("parse: {0}")]
Parse(String),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AdapterDetection {
Detected,
NotDetected,
}
#[async_trait]
pub trait Adapter: Send + Sync {
fn id(&self) -> AdapterId;
fn detect(&self, root: &Path) -> AdapterDetection;
async fn install(&self, root: &Path, config: &AgentConfig) -> Result<(), AdapterError>;
async fn apply_config(&self, root: &Path, config: &AgentConfig) -> Result<(), AdapterError>;
async fn parse_session(&self, log: SessionLog) -> Result<Vec<ParsedSignal>, AdapterError>;
async fn forget(&self, root: &Path) -> Result<(), AdapterError>;
}