use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum HarnessState {
Starting,
Idle,
Working,
Paused,
Error,
Stopped,
}
#[derive(Debug, Clone)]
pub struct DetectionResult {
pub matched: bool,
pub confidence: f32,
pub pattern: Option<&'static str>,
}
impl DetectionResult {
pub fn no_match() -> Self {
Self {
matched: false,
confidence: 0.0,
pattern: None,
}
}
pub fn matched(confidence: f32, pattern: &'static str) -> Self {
Self {
matched: true,
confidence,
pattern: Some(pattern),
}
}
}
#[derive(Debug, Clone)]
pub struct HarnessObservation {
pub state: HarnessState,
pub confidence: f32,
pub errors: Vec<String>,
}
#[derive(Debug, Clone)]
pub struct AdapterInfo {
pub id: &'static str,
pub name: &'static str,
pub description: &'static str,
pub command: &'static str,
pub default_args: &'static [&'static str],
}
pub trait HarnessAdapter: Send + Sync {
fn info(&self) -> &AdapterInfo;
fn detect(&self, pane_output: &str) -> DetectionResult;
fn observe(&self, pane_output: &str) -> HarnessObservation;
fn pause_command(&self) -> Option<&'static str>;
fn resume_command(&self) -> Option<&'static str>;
fn can_pause(&self) -> bool {
self.pause_command().is_some()
}
fn can_resume(&self) -> bool {
self.resume_command().is_some()
}
fn format_message(&self, message: &str) -> String {
message.to_string()
}
fn idle_patterns(&self) -> &[&'static str];
fn error_patterns(&self) -> &[&'static str] {
&[]
}
fn working_patterns(&self) -> &[&'static str] {
&[]
}
fn brand_patterns(&self) -> &[&'static str];
}