use crate::{agent::ADVISOR_AGENT_ID, config::InternalAgentModelConfig};
use super::{model_names::ModelNames, RuntimeModelView};
#[derive(Clone, Debug, PartialEq, Eq)]
pub(super) enum AdvisorStatus {
Off,
Reviewing {
model: String,
},
MissingModel,
}
impl AdvisorStatus {
pub(super) fn new(
advisor_mode: bool,
model: Option<&InternalAgentModelConfig>,
names: ModelNames<'_>,
) -> Self {
Self::of(advisor_mode, model.map(|model| names.internal_agent(model)))
}
pub(super) fn of(advisor_mode: bool, model: Option<String>) -> Self {
match (advisor_mode, model) {
(false, _) => Self::Off,
(true, Some(model)) => Self::Reviewing { model },
(true, None) => Self::MissingModel,
}
}
pub(super) fn from_runtime(info: &RuntimeModelView, names: ModelNames<'_>) -> Self {
Self::new(
info.advisor_mode,
info.internal_agents.get(ADVISOR_AGENT_ID),
names,
)
}
pub(super) fn divider_labels(&self) -> Vec<String> {
match self {
Self::Off => Vec::new(),
Self::Reviewing { model } => vec![format!("advisor: {model}"), "advisor".into()],
Self::MissingModel => vec!["advisor: no model".into(), "advisor".into()],
}
}
pub(super) fn detail(&self) -> String {
match self {
Self::Off => "off".into(),
Self::Reviewing { model } => format!("on, {model} reviews the session"),
Self::MissingModel => "on, but no advisor model is selected".into(),
}
}
pub(super) fn needs_model(&self) -> bool {
matches!(self, Self::MissingModel)
}
}
#[cfg(test)]
#[path = "advisor_status_tests.rs"]
mod tests;