# generated by datamodel-codegen:
#   filename:  a2a.json

from __future__ import annotations

from dataclasses import dataclass, field
from enum import Enum
from typing import Any, Dict, List, Optional, Union

A2AProtocolSchema = Any


@dataclass
class AgentAuthentication:
    schemes: List[str]
    credentials: Optional[str] = None


@dataclass
class AgentCapabilities:
    streaming: Optional[bool] = False
    pushNotifications: Optional[bool] = False
    stateTransitionHistory: Optional[bool] = False


@dataclass
class AgentProvider:
    organization: str
    url: Optional[str] = None


@dataclass
class AgentSkill:
    id: str
    name: str
    description: Optional[str] = None
    tags: Optional[List[str]] = None
    examples: Optional[List[str]] = None
    inputModes: Optional[List[str]] = None
    outputModes: Optional[List[str]] = None


@dataclass
class AuthenticationInfo:
    schemes: List[str]
    credentials: Optional[str] = None


@dataclass
class PushNotificationNotSupportedError:
    code: int = -32003
    message: str = 'Push Notification is not supported'
    data: Any = None


@dataclass
class DataPart:
    data: Dict[str, Any]
    type: str = 'data'
    metadata: Optional[Dict[str, Any]] = None


@dataclass
class FileContent:
    name: Optional[str] = None
    mimeType: Optional[str] = None
    bytes: Optional[str] = None
    uri: Optional[str] = None


@dataclass
class FilePart:
    file: FileContent
    type: str = 'file'
    metadata: Optional[Dict[str, Any]] = None


@dataclass
class InternalError:
    code: int = -32603
    message: str = 'Internal error'
    data: Optional[Dict[str, Any]] = None


@dataclass
class InvalidParamsError:
    code: int = -32602
    message: str = 'Invalid parameters'
    data: Optional[Dict[str, Any]] = None


@dataclass
class InvalidRequestError:
    code: int = -32600
    message: str = 'Request payload validation error'
    data: Optional[Dict[str, Any]] = None


@dataclass
class JSONParseError:
    code: int = -32700
    message: str = 'Invalid JSON payload'
    data: Optional[Dict[str, Any]] = None


@dataclass
class JSONRPCError:
    code: int
    message: str
    data: Optional[Dict[str, Any]] = None


@dataclass
class JSONRPCMessage:
    jsonrpc: str = '2.0'
    id: Optional[Union[int, str]] = None


@dataclass
class JSONRPCRequest:
    method: str
    jsonrpc: str = '2.0'
    id: Optional[Union[int, str]] = None
    params: Optional[Dict[str, Any]] = None


@dataclass
class JSONRPCResponse:
    jsonrpc: str = '2.0'
    id: Optional[Union[int, str]] = None
    result: Optional[Dict[str, Any]] = None
    error: Optional[JSONRPCError] = None


class Role(Enum):
    user = 'user'
    agent = 'agent'


@dataclass
class MethodNotFoundError:
    code: int = -32601
    message: str = 'Method not found'
    data: Any = None


@dataclass
class PushNotificationConfig:
    url: str
    token: Optional[str] = None
    authentication: Optional[AuthenticationInfo] = None


@dataclass
class TaskPushNotificationConfig:
    id: str
    pushNotificationConfig: PushNotificationConfig


@dataclass
class TaskNotCancelableError:
    code: int = -32002
    message: str = 'Task cannot be canceled'
    data: Any = None


@dataclass
class TaskNotFoundError:
    code: int = -32001
    message: str = 'Task not found'
    data: Any = None


@dataclass
class TaskIdParams:
    id: str
    metadata: Optional[Dict[str, Any]] = None


@dataclass
class TaskQueryParams:
    id: str
    historyLength: Optional[int] = None
    metadata: Optional[Dict[str, Any]] = None


class TaskState(Enum):
    submitted = 'submitted'
    working = 'working'
    input_required = 'input-required'
    completed = 'completed'
    canceled = 'canceled'
    failed = 'failed'
    unknown = 'unknown'


@dataclass
class TaskResubscriptionRequest:
    params: TaskQueryParams
    jsonrpc: str = '2.0'
    id: Optional[Union[int, str]] = None
    method: str = 'tasks/resubscribe'


@dataclass
class TextPart:
    text: str
    type: str = 'text'
    metadata: Optional[Dict[str, Any]] = None


@dataclass
class UnsupportedOperationError:
    code: int = -32004
    message: str = 'This operation is not supported'
    data: Any = None


@dataclass
class AgentCard:
    name: str
    url: str
    version: str
    capabilities: AgentCapabilities
    skills: List[AgentSkill]
    description: Optional[str] = None
    provider: Optional[AgentProvider] = None
    documentationUrl: Optional[str] = None
    authentication: Optional[AgentAuthentication] = None
    defaultInputModes: Optional[List[str]] = field(default_factory=lambda: ['text'])
    defaultOutputModes: Optional[List[str]] = field(default_factory=lambda: ['text'])


@dataclass
class CancelTaskRequest:
    params: TaskIdParams
    jsonrpc: str = '2.0'
    id: Optional[Union[int, str]] = None
    method: str = 'tasks/cancel'


@dataclass
class GetTaskPushNotificationRequest:
    params: TaskIdParams
    jsonrpc: str = '2.0'
    id: Optional[Union[int, str]] = None
    method: str = 'tasks/pushNotification/get'


@dataclass
class GetTaskPushNotificationResponse:
    jsonrpc: str = '2.0'
    id: Optional[Union[int, str]] = None
    result: Optional[TaskPushNotificationConfig] = None
    error: Optional[JSONRPCError] = None


@dataclass
class GetTaskRequest:
    params: TaskQueryParams
    jsonrpc: str = '2.0'
    id: Optional[Union[int, str]] = None
    method: str = 'tasks/get'


Part = Union[TextPart, FilePart, DataPart]


@dataclass
class SetTaskPushNotificationRequest:
    params: TaskPushNotificationConfig
    jsonrpc: str = '2.0'
    id: Optional[Union[int, str]] = None
    method: str = 'tasks/pushNotification/set'


@dataclass
class SetTaskPushNotificationResponse:
    jsonrpc: str = '2.0'
    id: Optional[Union[int, str]] = None
    result: Optional[TaskPushNotificationConfig] = None
    error: Optional[JSONRPCError] = None


@dataclass
class Artifact:
    parts: List[Part]
    name: Optional[str] = None
    description: Optional[str] = None
    index: Optional[int] = 0
    append: Optional[bool] = None
    lastChunk: Optional[bool] = None
    metadata: Optional[Dict[str, Any]] = None


@dataclass
class Message:
    role: Role
    parts: List[Part]
    metadata: Optional[Dict[str, Any]] = None


@dataclass
class TaskSendParams:
    id: str
    message: Message
    sessionId: Optional[str] = None
    pushNotification: Optional[PushNotificationConfig] = None
    historyLength: Optional[int] = None
    metadata: Optional[Dict[str, Any]] = None


@dataclass
class TaskStatus:
    state: TaskState
    message: Optional[Message] = None
    timestamp: Optional[str] = None


@dataclass
class TaskStatusUpdateEvent:
    id: str
    status: TaskStatus
    final: Optional[bool] = False
    metadata: Optional[Dict[str, Any]] = None


@dataclass
class TaskArtifactUpdateEvent:
    id: str
    artifact: Artifact
    metadata: Optional[Dict[str, Any]] = None


@dataclass
class SendTaskRequest:
    params: TaskSendParams
    jsonrpc: str = '2.0'
    id: Optional[Union[int, str]] = None
    method: str = 'tasks/send'


@dataclass
class SendTaskStreamingRequest:
    params: TaskSendParams
    jsonrpc: str = '2.0'
    id: Optional[Union[int, str]] = None
    method: str = 'tasks/sendSubscribe'


@dataclass
class SendTaskStreamingResponse:
    jsonrpc: str = '2.0'
    id: Optional[Union[int, str]] = None
    result: Optional[Union[TaskStatusUpdateEvent, TaskArtifactUpdateEvent]] = None
    error: Optional[JSONRPCError] = None


@dataclass
class Task:
    id: str
    status: TaskStatus
    sessionId: Optional[str] = None
    artifacts: Optional[List[Artifact]] = None
    history: Optional[List[Message]] = None
    metadata: Optional[Dict[str, Any]] = None


A2ARequest = Union[
    SendTaskRequest,
    GetTaskRequest,
    CancelTaskRequest,
    SetTaskPushNotificationRequest,
    GetTaskPushNotificationRequest,
    TaskResubscriptionRequest,
]


@dataclass
class CancelTaskResponse:
    jsonrpc: str = '2.0'
    id: Optional[Union[int, str]] = None
    result: Optional[Task] = None
    error: Optional[JSONRPCError] = None


@dataclass
class GetTaskResponse:
    jsonrpc: str = '2.0'
    id: Optional[Union[int, str]] = None
    result: Optional[Task] = None
    error: Optional[JSONRPCError] = None


@dataclass
class SendTaskResponse:
    jsonrpc: str = '2.0'
    id: Optional[Union[int, str]] = None
    result: Optional[Task] = None
    error: Optional[JSONRPCError] = None
