collet 0.1.0

Relentless agentic coding orchestrator with zero-drop agent loops
Documentation
use serde::{Deserialize, Serialize};

use crate::agent::swarm::config::{CollaborationSection, ConflictResolution, SwarmStrategy};

use super::provider::AgentsSection;
use super::provider::{ModelOverride, ProviderEntry};
use super::rag::RagSection;
use super::remote::{
    ChannelMappingEntry, DiscordSection, RemoteSection, SlackSection, TelegramSection, WebSection,
};
use super::sections::{
    AgentSection, ApiSection, BenchSection, ContextSection, DebugSection, EvolutionSection,
    HooksSection, PathsSection, SecuritySection, SoulSection, TelemetrySection, UiSection,
};

/// Root of `~/.config/collet/config.toml`.
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct ConfigFile {
    #[serde(default, rename = "default", alias = "api")]
    pub api: ApiSection,
    #[serde(default)]
    pub agent: AgentSection,
    #[serde(default)]
    pub agents: AgentsSection,
    #[serde(default)]
    pub context: ContextSection,
    #[serde(default)]
    pub hooks: HooksSection,
    #[serde(default)]
    pub ui: UiSection,
    #[serde(default)]
    pub bench: BenchSection,
    #[serde(default)]
    pub collaboration: CollaborationSection,
    #[serde(default)]
    pub debug: DebugSection,
    #[serde(default)]
    pub paths: PathsSection,
    #[serde(default)]
    pub web: WebSection,
    #[serde(default)]
    pub security: SecuritySection,
    #[serde(default)]
    pub rag: RagSection,
    #[serde(default)]
    pub soul: SoulSection,
    #[serde(default)]
    pub evolution: EvolutionSection,
    #[serde(default)]
    pub telemetry: TelemetrySection,

    // ── Remote control ──
    #[serde(default)]
    pub remote: RemoteSection,
    #[serde(default)]
    pub telegram: TelegramSection,
    #[serde(default)]
    pub slack: SlackSection,
    #[serde(default)]
    pub discord: DiscordSection,
    #[serde(default)]
    pub channel_map: Vec<ChannelMappingEntry>,

    // ── Proxy headers (optional security proxy integration) ──
    #[serde(default)]
    pub proxy_headers: std::collections::HashMap<String, String>,

    // ── Legacy sections (deprecated — auto-migrated to [collaboration]) ──
    /// Deprecated: use `[collaboration] mode = "fork"` instead.
    #[serde(default)]
    pub fork: Option<LegacyForkSection>,
    /// Deprecated: use `[collaboration] mode = "hive"` instead.
    #[serde(default)]
    pub hive: Option<LegacyHiveSection>,

    /// Per-model overrides (global < model < agent).
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub models: Vec<ModelOverride>,

    /// Registered provider credentials.
    #[serde(default)]
    pub providers: Vec<ProviderEntry>,
}

/// Deprecated `[fork]` section — kept for backward-compatible migration.
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct LegacyForkSection {
    pub enabled: Option<bool>,
    pub max_agents: Option<usize>,
    pub worker_model: Option<String>,
    pub worktree: Option<bool>,
    pub auto_suggest: Option<bool>,
}

/// Deprecated `[hive]` section — kept for backward-compatible migration.
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct LegacyHiveSection {
    pub enabled: Option<bool>,
    pub max_agents: Option<usize>,
    pub strategy: Option<SwarmStrategy>,
    pub coordinator_model: Option<String>,
    pub worker_model: Option<String>,
    pub require_consensus: Option<bool>,
    pub conflict_resolution: Option<ConflictResolution>,
    pub auto_suggest: Option<bool>,
}