feat(tui): implement status bar with connection and turn state indicators feat(tui): create workflow panel for agent status and progress visualization feat(web): introduce web frontend interface with static file serving feat(ws): add WebSocket interface for real-time communication and session management
158 lines
5.9 KiB
Rust
158 lines
5.9 KiB
Rust
//! Command types for CMS domain operations.
|
|
//!
|
|
//! Following the `NewXxx` / `XxxPatch` pattern from clean architecture,
|
|
//! these types encapsulate the input data for create/update operations
|
|
//! on domain entities. They decouple presentation DTOs from the entity
|
|
//! mutation surface and provide a clear boundary for validation.
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use super::settings::InternetMode;
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Settings
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/// Partial update command for `Settings`.
|
|
///
|
|
/// Every field is `Option`al — only non-`None` fields are applied to the
|
|
/// existing settings instance. Use `apply_to()` to merge into a `Settings`
|
|
/// value.
|
|
#[derive(Debug, Clone, Default)]
|
|
pub struct SettingsPatch {
|
|
/// Override the internet access mode.
|
|
pub internet_mode: Option<String>,
|
|
/// Override the active provider name.
|
|
pub provider: Option<String>,
|
|
/// Override the active model name.
|
|
pub model: Option<String>,
|
|
/// Replace the entire API-keys map.
|
|
pub api_keys: Option<HashMap<String, String>>,
|
|
/// Override the max tokens for completions.
|
|
pub max_tokens: Option<Option<u32>>,
|
|
/// Override the temperature for completions.
|
|
pub temperature: Option<Option<f32>>,
|
|
/// Override the review max lessons per run.
|
|
pub review_max_lessons_per_run: Option<usize>,
|
|
/// Override the adaptive review max skip count.
|
|
pub adaptive_review_max_skip: Option<u32>,
|
|
/// Override the verify shell command.
|
|
pub verify_command: Option<Option<String>>,
|
|
/// Override the verify timeout in milliseconds.
|
|
pub verify_timeout_ms: Option<u64>,
|
|
/// Override the max concurrency for workflow execution.
|
|
pub workflow_max_concurrency: Option<usize>,
|
|
/// Override the review-enabled flag.
|
|
pub review_enabled: Option<bool>,
|
|
/// Override the session-archive-enabled flag.
|
|
pub session_archive_enabled: Option<bool>,
|
|
/// Override the LSP auto-provision flag.
|
|
pub lsp_auto_provision: Option<bool>,
|
|
/// Override the list of LSP-managed languages.
|
|
pub lsp_languages: Option<Vec<String>>,
|
|
/// Override the hive-mind node timeout in milliseconds.
|
|
pub hive_mind_node_timeout_ms: Option<u64>,
|
|
}
|
|
|
|
impl SettingsPatch {
|
|
/// Merge this patch into `settings`, overwriting each non-`None` field.
|
|
///
|
|
/// Flow: for each optional field, if `Some`, assign it to the target.
|
|
///
|
|
/// ## Errors
|
|
/// Returns `Err` with a message if `internet_mode` is set to an
|
|
/// unrecognised value.
|
|
pub fn apply_to(&self, settings: &mut super::settings::Settings) -> Result<(), String> {
|
|
if let Some(ref val) = self.internet_mode {
|
|
settings.internet_mode = match val.as_str() {
|
|
"Off" => InternetMode::Off,
|
|
"ReadOnly" => InternetMode::ReadOnly,
|
|
"Full" => InternetMode::Full,
|
|
_ => {
|
|
return Err(format!(
|
|
"invalid internet_mode '{val}'; expected Off, ReadOnly, or Full"
|
|
))
|
|
}
|
|
};
|
|
}
|
|
if let Some(ref val) = self.provider {
|
|
settings.provider = val.clone();
|
|
}
|
|
if let Some(ref val) = self.model {
|
|
settings.model = val.clone();
|
|
}
|
|
if let Some(ref val) = self.api_keys {
|
|
settings.api_keys = val.clone();
|
|
}
|
|
if let Some(val) = self.max_tokens {
|
|
settings.max_tokens = val;
|
|
}
|
|
if let Some(val) = self.temperature {
|
|
settings.temperature = val;
|
|
}
|
|
if let Some(val) = self.review_max_lessons_per_run {
|
|
settings.review_max_lessons_per_run = val;
|
|
}
|
|
if let Some(val) = self.adaptive_review_max_skip {
|
|
settings.adaptive_review_max_skip = val;
|
|
}
|
|
if let Some(ref val) = self.verify_command {
|
|
settings.verify_command = val.clone();
|
|
}
|
|
if let Some(val) = self.verify_timeout_ms {
|
|
settings.verify_timeout_ms = val;
|
|
}
|
|
if let Some(val) = self.workflow_max_concurrency {
|
|
settings.workflow_max_concurrency = val;
|
|
}
|
|
if let Some(val) = self.review_enabled {
|
|
settings.flags.review_enabled = val;
|
|
}
|
|
if let Some(val) = self.session_archive_enabled {
|
|
settings.flags.session_archive_enabled = val;
|
|
}
|
|
if let Some(val) = self.lsp_auto_provision {
|
|
settings.flags.lsp_auto_provision = val;
|
|
}
|
|
if let Some(ref val) = self.lsp_languages {
|
|
settings.lsp_languages = val.clone();
|
|
}
|
|
if let Some(val) = self.hive_mind_node_timeout_ms {
|
|
settings.hive_mind_node_timeout_ms = val;
|
|
}
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Memory
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/// Command to create a new memory entry.
|
|
///
|
|
/// All required fields are non-optional; optional fields use `Option`
|
|
/// and default to sensible values (empty or the service default).
|
|
#[derive(Debug, Clone)]
|
|
pub struct NewMemory {
|
|
/// Unique name / slug for the memory.
|
|
pub name: String,
|
|
/// One-line summary of what the memory captures.
|
|
pub description: String,
|
|
/// The full memory content.
|
|
pub content: String,
|
|
/// Category kind (defaults to "reference" in the handler).
|
|
pub kind: Option<String>,
|
|
/// Outcome of the remembered action.
|
|
pub outcome: Option<String>,
|
|
/// Lifecycle stage (defaults to "new" in the handler).
|
|
pub lifecycle: Option<String>,
|
|
/// Scope context for the memory.
|
|
pub scope: Option<String>,
|
|
/// Code snippet captured before the action.
|
|
pub before_snippet: Option<String>,
|
|
/// Code snippet captured after the action.
|
|
pub after_snippet: Option<String>,
|
|
/// Source provenances (files, conversations, etc.).
|
|
pub provenances: Option<Vec<String>>,
|
|
}
|