namespace ControlCenter.Api.Entities;

/// <summary>
/// Represents an agent's current state in the Control Center.
/// Each row tracks one agent session's status, task, and activity.
/// </summary>
public class Agent
{
    /// <summary>
    /// Primary key — UUID generated on insert.
    /// </summary>
    public Guid Id { get; set; }

    /// <summary>
    /// Current operational status of the agent.
    /// Stored as an enum in PostgreSQL via Npgsql.
    /// </summary>
    public AgentStatus Status { get; set; } = AgentStatus.Idle;

    /// <summary>
    /// Description of the agent's current task, if any.
    /// Nullable — not all agents have an active task.
    /// </summary>
    public string? Task { get; set; }

    /// <summary>
    /// Task progress percentage (0–100).
    /// Nullable — progress is only meaningful when an agent has a trackable task.
    /// </summary>
    public int? Progress { get; set; }

    /// <summary>
    /// Full session key, e.g. "agent:otto:telegram:direct:8787451565".
    /// Not null — every agent row must be associated with a session.
    /// </summary>
    public string SessionKey { get; set; } = string.Empty;

    /// <summary>
    /// Communication channel the agent is operating on, e.g. "telegram", "discord", "slack".
    /// Not null — every agent session operates on exactly one channel.
    /// </summary>
    public string Channel { get; set; } = string.Empty;

    /// <summary>
    /// Timestamp of the agent's last activity.
    /// Default: current UTC timestamp on insert.
    /// </summary>
    public DateTime LastActivity { get; set; } = DateTime.UtcNow;

    /// <summary>
    /// Row creation timestamp. Set automatically on insert.
    /// </summary>
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

    /// <summary>
    /// Row last-update timestamp. Updated automatically on any modification.
    /// </summary>
    public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
}