namespace AIRuntime.Runtime.Models
{
    using System.Collections.Generic;

    /// <summary>
    /// Provider tool-call data that could not be normalized into AIRuntime's
    /// capability contract. Keeping this data typed allows the conversation
    /// layer to ask the model for one bounded correction without pretending a
    /// malformed model response was a transient transport failure.
    /// </summary>
    public sealed class RejectedToolCall
    {
        public int Index { get; set; }

        public string Id { get; set; } = string.Empty;

        public string Name { get; set; } = string.Empty;

        public string Arguments { get; set; } = string.Empty;

        public string Reason { get; set; } = string.Empty;
    }


    /// <summary>
    /// The normalized response returned by any provider.
    /// </summary>
    public sealed class ChatCompletion
    {
        /// <summary>
        /// The assistant's message, if any.
        /// </summary>
        public string Content { get; set; } = string.Empty;

        /// <summary>
        /// Tool calls requested by the model.
        /// Empty if no tools were requested.
        /// </summary>
        public List<ToolCall> ToolCalls { get; } = new();

        /// <summary>
        /// Structurally invalid provider tool calls. These are never executed.
        /// </summary>
        public List<RejectedToolCall> RejectedToolCalls { get; } = new();

        /// <summary>
        /// Deterministic provider-compatibility normalizations applied before
        /// capability execution. These notes are observable run metadata; they
        /// are never sent back as tool results and do not authorize execution.
        /// </summary>
        public List<string> NormalizationMessages { get; } = new();

        /// <summary>
        /// True if at least one tool call was requested.
        /// </summary>
        public bool HasToolCalls => ToolCalls.Count > 0;

        public bool HasRejectedToolCalls => RejectedToolCalls.Count > 0;

        public bool HasNormalizationMessages =>
            NormalizationMessages.Count > 0;
    }
}
