use serde::{Deserialize, Serialize};

/// Full specification for deploying a domain-optimized agent.
///
/// Produced by [`vapora_capabilities::CapabilityRegistry::activate`] and
/// consumed by [`vapora_agents::registry::AgentMetadata`] construction.
/// Kept in `vapora-shared` so both crates can reference it without a
/// circular dependency.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentDefinition {
    /// Agent role name used for task routing (e.g., `"code_reviewer"`).
    pub role: String,
    /// Human-readable description shown in UIs and logs.
    pub description: String,
    /// Preferred LLM provider name (e.g., `"claude"`).
    pub llm_provider: String,
    /// Preferred model within the provider (e.g., `"claude-opus-4-6"`).
    pub llm_model: String,
    /// Whether multiple instances may run concurrently.
    #[serde(default)]
    pub parallelizable: bool,
    /// Assignment priority 0–100.
    #[serde(default = "default_priority")]
    pub priority: u32,
    /// Task-type strings used by the coordinator for capability-based routing.
    #[serde(default)]
    pub capabilities: Vec<String>,
    /// Domain-optimized system prompt injected before every task.
    /// `None` falls back to the agent's generic prompt.
    #[serde(default)]
    pub system_prompt: Option<String>,
}

fn default_priority() -> u32 {
    50
}

impl AgentDefinition {
    /// Builder: attach a domain-optimized system prompt.
    pub fn with_system_prompt(mut self, prompt: impl Into<String>) -> Self {
        self.system_prompt = Some(prompt.into());
        self
    }
}
