/*
 * Task.kt
 *
 * This code was generated by json-kotlin-schema-codegen - JSON Schema Code Generator
 * See https://github.com/pwall567/json-kotlin-schema-codegen
 *
 * It is not advisable to modify generated code as any modifications will be lost
 * when the generation process is re-run.
 *
 * This was generated from A2A Schema: https://raw.githubusercontent.com/google/A2A/refs/heads/main/specification/json/a2a.json
 */
package dev.mokksy.aimocks.a2a.model

import kotlinx.serialization.Contextual
import kotlinx.serialization.EncodeDefault
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
 * Represents a single, stateful operation or conversation between a client and an agent.
 *
 * A task encapsulates the entire interaction related to a specific goal or request.
 * Tasks progress through defined lifecycle states and cannot be restarted once they
 * reach a terminal state (completed, canceled, rejected, or failed).
 */
@Serializable
public data class Task(
    /**
     * A unique identifier for the task, generated by the server for a new task.
     */
    @SerialName("id")
    val id: String,

    /**
     * A server-generated identifier for maintaining context across multiple related tasks or interactions.
     */
    @SerialName("contextId")
    val contextId: String,

    /**
     * The current status of the task, including its state and a descriptive message.
     */
    @SerialName("status")
    val status: TaskStatus,

    /**
     * A collection of artifacts generated by the agent during the execution of the task.
     */
    @SerialName("artifacts")
    val artifacts: List<Artifact>? = null,

    /**
     * An array of messages exchanged during the task, representing the conversation history.
     */
    @SerialName("history")
    val history: List<Message>? = null,

    /**
     * The type of this object, used as a discriminator. Always 'task' for a Task.
     */
    @SerialName("kind")
    @EncodeDefault
    val kind: String = "task",

    /**
     * Optional metadata for extensions. The key is an extension-specific identifier.
     */
    @Contextual
    @SerialName("metadata")
    val metadata: Metadata? = null,
) {
    public companion object {
        /**
         * Creates a new Task using the DSL builder.
         *
         * @param init The lambda to configure the task.
         * @return A new Task instance.
         */
        @JvmStatic
        public fun build(init: TaskBuilder.() -> Unit): Task = TaskBuilder().apply(init).build()
    }
}
