use std::path::PathBuf;
use std::sync::Arc;
use rhema_agent_tools::{ShellTools, Skill};
use rhema_core::ToolResolver;
use rhema_core::request::ThinkingEffort;
pub trait Steering: Send + Sync {
fn drain(&self) -> Vec<String>;
}
pub type SubagentProviders =
Arc<dyn Fn(&str) -> Option<Arc<dyn rhema_core::ModelProvider>> + Send + Sync>;
#[derive(Clone)]
pub struct CodingAgentConfig {
pub model: String,
pub system: Option<String>,
pub base_system: Option<String>,
pub workspace: PathBuf,
pub skills: Option<Vec<Skill>>,
pub disabled_skills: std::collections::BTreeSet<String>,
pub max_turn_steps: u32,
pub thinking: ThinkingEffort,
pub tools: Option<Arc<ShellTools>>,
pub extra_resolver: Option<Arc<dyn ToolResolver>>,
pub transcript: Option<rhema_transcript::TranscriptSettings>,
pub summary_worker: Option<Arc<dyn rhema_transcript::Summarizer>>,
pub shell_env: std::collections::BTreeMap<String, String>,
pub steering: Option<Arc<dyn Steering>>,
pub mcp_servers: Vec<rhema_agent_tools::prompt::McpServerLine>,
pub disabled_mcp_servers: std::collections::BTreeSet<String>,
pub disabled_subagents: std::collections::BTreeSet<String>,
pub subagent_providers: Option<SubagentProviders>,
pub environment: Option<String>,
pub user_preferences: Option<String>,
pub vision: Option<String>,
pub home: Option<rhema_config::Home>,
}
impl std::fmt::Debug for CodingAgentConfig {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("CodingAgentConfig")
.field("model", &self.model)
.field("system", &self.system)
.field("base_system", &self.base_system)
.field("workspace", &self.workspace)
.field("skills", &self.skills.is_some())
.field("max_turn_steps", &self.max_turn_steps)
.field("thinking", &self.thinking)
.field("tools", &self.tools.is_some())
.field("extra_resolver", &self.extra_resolver.is_some())
.field("transcript", &self.transcript.is_some())
.field("summary_worker", &self.summary_worker.is_some())
.field("steering", &self.steering.is_some())
.field("shell_env", &self.shell_env.len())
.field("environment", &self.environment.is_some())
.field("user_preferences", &self.user_preferences.is_some())
.field("home", &self.home.is_some())
.finish()
}
}
impl CodingAgentConfig {
pub const DEFAULT_MAX_TURN_STEPS: u32 = 2048;
pub fn new(model: impl Into<String>, workspace: impl Into<PathBuf>) -> Self {
Self {
model: model.into(),
system: None,
base_system: None,
workspace: workspace.into(),
skills: None,
disabled_skills: std::collections::BTreeSet::new(),
max_turn_steps: Self::DEFAULT_MAX_TURN_STEPS,
thinking: ThinkingEffort::Default,
tools: None,
extra_resolver: None,
transcript: Some(rhema_transcript::TranscriptSettings::default()),
summary_worker: None,
steering: None,
shell_env: std::collections::BTreeMap::new(),
mcp_servers: Vec::new(),
disabled_mcp_servers: std::collections::BTreeSet::new(),
disabled_subagents: std::collections::BTreeSet::new(),
subagent_providers: None,
environment: None,
user_preferences: None,
vision: None,
home: None,
}
}
}