Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 85 additions & 5 deletions src/a2a/types.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# generated by datamodel-codegen:
# filename: https://raw.githubusercontent.com/a2aproject/A2A/refs/heads/main/specification/json/a2a.json
# filename: https://raw.githubusercontent.com/a2aproject/A2A/refs/heads/jsdoc-strings/specification/json/a2a.json

from __future__ import annotations

from enum import Enum
from typing import Any, Literal

from pydantic import Field, RootModel
from pydantic import AnyUrl, Field, RootModel

from a2a._base import A2ABaseModel

Expand Down Expand Up @@ -125,7 +125,7 @@ class AgentProvider(A2ABaseModel):
"""
The name of the agent provider's organization.
"""
url: str
url: AnyUrl
"""
A URL for the agent provider's website or relevant documentation.
"""
Expand Down Expand Up @@ -172,6 +172,26 @@ class AgentSkill(A2ABaseModel):
"""


class AuthenticatedExtendedCardNotConfiguredError(A2ABaseModel):
"""
An A2A-specific error indicating that the agent does not have an Authenticated Extended Card configured
"""

code: Literal[-32007] = -32007
"""
The error code for when an authenticated extended card is not configured.
"""
data: Any | None = None
"""
A primitive or structured value containing additional information about the error.
This may be omitted.
"""
message: str | None = 'Authenticated Extended Card is not configured'
"""
The error message.
"""


class AuthorizationCodeOAuthFlow(A2ABaseModel):
"""
Defines configuration details for the OAuth 2.0 Authorization Code flow.
Expand Down Expand Up @@ -375,6 +395,27 @@ class FileWithUri(A2ABaseModel):
"""


class GetAuthenticatedExtendedCardRequest(A2ABaseModel):
"""
Represents a JSON-RPC request for the `agent/getAuthenticatedExtendedCard` method.
"""

id: str | int
"""
The identifier for this request.
"""
jsonrpc: Literal['2.0'] = '2.0'
"""
The version of the JSON-RPC protocol. MUST be exactly "2.0".
"""
method: Literal['agent/getAuthenticatedExtendedCard'] = (
'agent/getAuthenticatedExtendedCard'
)
"""
The method name. Must be 'agent/getAuthenticatedExtendedCard'.
"""


class GetTaskPushNotificationConfigParams(A2ABaseModel):
"""
Defines parameters for fetching a specific push notification configuration for a task.
Expand Down Expand Up @@ -999,6 +1040,7 @@ class A2AError(
| UnsupportedOperationError
| ContentTypeNotSupportedError
| InvalidAgentResponseError
| AuthenticatedExtendedCardNotConfiguredError
]
):
root: (
Expand All @@ -1013,6 +1055,7 @@ class A2AError(
| UnsupportedOperationError
| ContentTypeNotSupportedError
| InvalidAgentResponseError
| AuthenticatedExtendedCardNotConfiguredError
)
"""
A discriminated union of all standard JSON-RPC and A2A-specific error types.
Expand Down Expand Up @@ -1170,6 +1213,7 @@ class JSONRPCErrorResponse(A2ABaseModel):
| UnsupportedOperationError
| ContentTypeNotSupportedError
| InvalidAgentResponseError
| AuthenticatedExtendedCardNotConfiguredError
)
"""
An object describing the error that occurred.
Expand Down Expand Up @@ -1575,7 +1619,9 @@ class TaskStatus(A2ABaseModel):
The current state of the task's lifecycle.
"""
timestamp: str | None = Field(
default=None, examples=['2023-10-27T10:00:00Z']
default=None,
examples=['2023-10-27T10:00:00Z'],
pattern='^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])T([01]\\d|2[0-3]):([0-5]\\d):([0-5]\\d)(\\.\\d+)?(Z|[+-](?:[01]\\d|2[0-3])(?::?[0-5]\\d)?)?$',
)
"""
An ISO 8601 datetime string indicating when this status was recorded.
Expand Down Expand Up @@ -1625,6 +1671,7 @@ class A2ARequest(
| TaskResubscriptionRequest
| ListTaskPushNotificationConfigRequest
| DeleteTaskPushNotificationConfigRequest
| GetAuthenticatedExtendedCardRequest
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This change adds GetAuthenticatedExtendedCardRequest to the A2ARequest discriminated union. It seems the corresponding server-side logic to handle this new request type is missing. Without a handler, any request of this new type will result in an UnsupportedOperationError.

Please ensure that the server-side implementation is added, or clarify if it's intended for a future PR.

]
):
root: (
Expand All @@ -1637,6 +1684,7 @@ class A2ARequest(
| TaskResubscriptionRequest
| ListTaskPushNotificationConfigRequest
| DeleteTaskPushNotificationConfigRequest
| GetAuthenticatedExtendedCardRequest
)
"""
A discriminated union representing all possible JSON-RPC 2.0 requests supported by the A2A specification.
Expand Down Expand Up @@ -1750,6 +1798,25 @@ class AgentCard(A2ABaseModel):
"""


class GetAuthenticatedExtendedCardSuccessResponse(A2ABaseModel):
"""
Represents a successful JSON-RPC response for the `agent/getAuthenticatedExtendedCard` method.
"""

id: str | int | None = None
"""
The identifier established by the client.
"""
jsonrpc: Literal['2.0'] = '2.0'
"""
The version of the JSON-RPC protocol. MUST be exactly "2.0".
"""
result: AgentCard
"""
The result is an Agent Card object.
"""


class Task(A2ABaseModel):
"""
Represents a single, stateful operation or conversation between a client and an agent.
Expand All @@ -1769,7 +1836,7 @@ class Task(A2ABaseModel):
"""
id: str
"""
A unique identifier for the task, generated by the client for a new task or provided by the agent.
A unique identifier for the task, generated by the server for a new task.
"""
kind: Literal['task'] = 'task'
"""
Expand Down Expand Up @@ -1804,6 +1871,17 @@ class CancelTaskSuccessResponse(A2ABaseModel):
"""


class GetAuthenticatedExtendedCardResponse(
RootModel[
JSONRPCErrorResponse | GetAuthenticatedExtendedCardSuccessResponse
]
):
root: JSONRPCErrorResponse | GetAuthenticatedExtendedCardSuccessResponse
"""
Represents a JSON-RPC response for the `agent/getAuthenticatedExtendedCard` method.
"""


class GetTaskSuccessResponse(A2ABaseModel):
"""
Represents a successful JSON-RPC response for the `tasks/get` method.
Expand Down Expand Up @@ -1889,6 +1967,7 @@ class JSONRPCResponse(
| GetTaskPushNotificationConfigSuccessResponse
| ListTaskPushNotificationConfigSuccessResponse
| DeleteTaskPushNotificationConfigSuccessResponse
| GetAuthenticatedExtendedCardSuccessResponse
]
):
root: (
Expand All @@ -1901,6 +1980,7 @@ class JSONRPCResponse(
| GetTaskPushNotificationConfigSuccessResponse
| ListTaskPushNotificationConfigSuccessResponse
| DeleteTaskPushNotificationConfigSuccessResponse
| GetAuthenticatedExtendedCardSuccessResponse
)
"""
A discriminated union representing all possible JSON-RPC 2.0 responses
Expand Down
Loading