using System.Text.Json.Serialization;

namespace ClawdDotNet.Core.Config;

public sealed class InstanceConfig
{
    [JsonPropertyName("instanceId")]
    public string InstanceId { get; set; } = Guid.NewGuid().ToString("N")[..8];

    [JsonPropertyName("instanceName")]
    public string InstanceName { get; set; } = "Default";

    [JsonPropertyName("openRouterApiKey")]
    public string OpenRouterApiKey { get; set; } = "";

    [JsonPropertyName("workingDirectory")]
    public string WorkingDirectory { get; set; } = "./data/";

    [JsonPropertyName("logDirectory")]
    public string LogDirectory { get; set; } = "./Logs";

    [JsonPropertyName("webServerPort")]
    public int WebServerPort { get; set; } = 8080;

    [JsonPropertyName("telegramClient")]
    public TelegramClientConfig? TelegramClient { get; set; }

    /// <summary>Anbindung an das Watchdog-Modul des Deploymentcenters (Instanz-Heartbeat).</summary>
    [JsonPropertyName("watchdog")]
    public WatchdogConfig Watchdog { get; set; } = new();

    /// <summary>Tagesgrenzen über alle Agenten der Instanz hinweg. 0 = keine Grenze.</summary>
    [JsonPropertyName("budget")]
    public InstanceBudget Budget { get; set; } = new();

    [JsonPropertyName("agents")]
    public List<AgentConfig> Agents { get; set; } = new();

    [JsonPropertyName("services")]
    public List<ServiceConfig> Services { get; set; } = new();
}

public sealed class TelegramClientConfig
{
    [JsonPropertyName("apiId")]
    public int ApiId { get; set; }

    [JsonPropertyName("apiHash")]
    public string ApiHash { get; set; } = "";

    [JsonPropertyName("phoneNumber")]
    public string PhoneNumber { get; set; } = "";

    [JsonPropertyName("password2FA")]
    public string? Password2FA { get; set; }
}
