Skip to content

Commit 3fa1d69

Browse files
authored
chore: 🤖 Auto-update A2A types from google-a2a/A2A (#126)
* chore: 🤖 Auto-update A2A types from a2aproject/A2A@628380e
1 parent ebc6822 commit 3fa1d69

File tree

2 files changed

+93
-26
lines changed

2 files changed

+93
-26
lines changed

src/a2a/types.py

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,9 @@ class JSONRPCRequest(BaseModel):
464464
"""
465465

466466

467-
class JSONRPCResult(BaseModel):
467+
class JSONRPCSuccessResponse(BaseModel):
468468
"""
469-
Represents a JSON-RPC 2.0 Result object.
469+
Represents a JSON-RPC 2.0 Success Response object.
470470
"""
471471

472472
id: str | int | None = None
@@ -712,7 +712,7 @@ class TaskResubscriptionRequest(BaseModel):
712712
JSON-RPC request model for the 'tasks/resubscribe' method.
713713
"""
714714

715-
id: str | int | None = None
715+
id: str | int
716716
"""
717717
An identifier established by the Client that MUST contain a String, Number.
718718
Numbers SHOULD NOT contain fractional parts.
@@ -821,7 +821,7 @@ class CancelTaskRequest(BaseModel):
821821
JSON-RPC request model for the 'tasks/cancel' method.
822822
"""
823823

824-
id: str | int | None = None
824+
id: str | int
825825
"""
826826
An identifier established by the Client that MUST contain a String, Number.
827827
Numbers SHOULD NOT contain fractional parts.
@@ -864,7 +864,7 @@ class GetTaskPushNotificationConfigRequest(BaseModel):
864864
JSON-RPC request model for the 'tasks/pushNotificationConfig/get' method.
865865
"""
866866

867-
id: str | int | None = None
867+
id: str | int
868868
"""
869869
An identifier established by the Client that MUST contain a String, Number.
870870
Numbers SHOULD NOT contain fractional parts.
@@ -910,7 +910,7 @@ class GetTaskRequest(BaseModel):
910910
JSON-RPC request model for the 'tasks/get' method.
911911
"""
912912

913-
id: str | int | None = None
913+
id: str | int
914914
"""
915915
An identifier established by the Client that MUST contain a String, Number.
916916
Numbers SHOULD NOT contain fractional parts.
@@ -1017,7 +1017,7 @@ class SetTaskPushNotificationConfigRequest(BaseModel):
10171017
JSON-RPC request model for the 'tasks/pushNotificationConfig/set' method.
10181018
"""
10191019

1020-
id: str | int | None = None
1020+
id: str | int
10211021
"""
10221022
An identifier established by the Client that MUST contain a String, Number.
10231023
Numbers SHOULD NOT contain fractional parts.
@@ -1086,9 +1086,7 @@ class Artifact(BaseModel):
10861086

10871087

10881088
class GetTaskPushNotificationConfigResponse(
1089-
RootModel[
1090-
JSONRPCErrorResponse | GetTaskPushNotificationConfigSuccessResponse
1091-
]
1089+
RootModel[JSONRPCErrorResponse | GetTaskPushNotificationConfigSuccessResponse]
10921090
):
10931091
root: JSONRPCErrorResponse | GetTaskPushNotificationConfigSuccessResponse
10941092
"""
@@ -1195,7 +1193,7 @@ class SendMessageRequest(BaseModel):
11951193
JSON-RPC request model for the 'message/send' method.
11961194
"""
11971195

1198-
id: str | int | None = None
1196+
id: str | int
11991197
"""
12001198
An identifier established by the Client that MUST contain a String, Number.
12011199
Numbers SHOULD NOT contain fractional parts.
@@ -1219,7 +1217,7 @@ class SendStreamingMessageRequest(BaseModel):
12191217
JSON-RPC request model for the 'message/stream' method.
12201218
"""
12211219

1222-
id: str | int | None = None
1220+
id: str | int
12231221
"""
12241222
An identifier established by the Client that MUST contain a String, Number.
12251223
Numbers SHOULD NOT contain fractional parts.
@@ -1239,9 +1237,7 @@ class SendStreamingMessageRequest(BaseModel):
12391237

12401238

12411239
class SetTaskPushNotificationConfigResponse(
1242-
RootModel[
1243-
JSONRPCErrorResponse | SetTaskPushNotificationConfigSuccessResponse
1244-
]
1240+
RootModel[JSONRPCErrorResponse | SetTaskPushNotificationConfigSuccessResponse]
12451241
):
12461242
root: JSONRPCErrorResponse | SetTaskPushNotificationConfigSuccessResponse
12471243
"""
@@ -1420,10 +1416,6 @@ class AgentCard(BaseModel):
14201416
"""
14211417
The version of the agent - format is up to the provider.
14221418
"""
1423-
supportsAuthenticatedExtendedCard: bool | None = Field(default=None)
1424-
"""
1425-
Optional field indicating there is an extended card available post authentication at the /agent/authenticatedExtendedCard endpoint.
1426-
"""
14271419

14281420

14291421
class Task(BaseModel):
@@ -1534,9 +1526,7 @@ class SendStreamingMessageSuccessResponse(BaseModel):
15341526
"""
15351527

15361528

1537-
class CancelTaskResponse(
1538-
RootModel[JSONRPCErrorResponse | CancelTaskSuccessResponse]
1539-
):
1529+
class CancelTaskResponse(RootModel[JSONRPCErrorResponse | CancelTaskSuccessResponse]):
15401530
root: JSONRPCErrorResponse | CancelTaskSuccessResponse
15411531
"""
15421532
JSON-RPC response for the 'tasks/cancel' method.
@@ -1546,7 +1536,7 @@ class CancelTaskResponse(
15461536
class GetTaskResponse(RootModel[JSONRPCErrorResponse | GetTaskSuccessResponse]):
15471537
root: JSONRPCErrorResponse | GetTaskSuccessResponse
15481538
"""
1549-
JSON-RPC success response for the 'tasks/get' method.
1539+
JSON-RPC response for the 'tasks/get' method.
15501540
"""
15511541

15521542

@@ -1575,9 +1565,7 @@ class JSONRPCResponse(
15751565
"""
15761566

15771567

1578-
class SendMessageResponse(
1579-
RootModel[JSONRPCErrorResponse | SendMessageSuccessResponse]
1580-
):
1568+
class SendMessageResponse(RootModel[JSONRPCErrorResponse | SendMessageSuccessResponse]):
15811569
root: JSONRPCErrorResponse | SendMessageSuccessResponse
15821570
"""
15831571
JSON-RPC response model for the 'message/send' method.

tests/test_types.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ def test_a2a_request_root_model() -> None:
913913
),
914914
)
915915
set_push_notif_req_data: dict[str, Any] = {
916+
'id': 1,
916917
'jsonrpc': '2.0',
917918
'method': 'tasks/pushNotificationConfig/set',
918919
'params': task_push_config.model_dump(),
@@ -932,6 +933,7 @@ def test_a2a_request_root_model() -> None:
932933
# GetTaskPushNotificationConfigRequest
933934
id_params = TaskIdParams(id='t2')
934935
get_push_notif_req_data: dict[str, Any] = {
936+
'id': 1,
935937
'jsonrpc': '2.0',
936938
'method': 'tasks/pushNotificationConfig/get',
937939
'params': id_params.model_dump(),
@@ -973,6 +975,83 @@ def test_a2a_request_root_model() -> None:
973975
A2ARequest.model_validate(invalid_req_data)
974976

975977

978+
def test_a2a_request_root_model_id_validation() -> None:
979+
# SendMessageRequest case
980+
send_params = MessageSendParams(message=Message(**MINIMAL_MESSAGE_USER))
981+
send_req_data: dict[str, Any] = {
982+
'jsonrpc': '2.0',
983+
'method': 'message/send',
984+
'params': send_params.model_dump(),
985+
}
986+
with pytest.raises(ValidationError):
987+
A2ARequest.model_validate(send_req_data) # missing id
988+
989+
# SendStreamingMessageRequest case
990+
send_subs_req_data: dict[str, Any] = {
991+
'jsonrpc': '2.0',
992+
'method': 'message/stream',
993+
'params': send_params.model_dump(),
994+
}
995+
with pytest.raises(ValidationError):
996+
A2ARequest.model_validate(send_subs_req_data) # missing id
997+
998+
# GetTaskRequest case
999+
get_params = TaskQueryParams(id='t2')
1000+
get_req_data: dict[str, Any] = {
1001+
'jsonrpc': '2.0',
1002+
'method': 'tasks/get',
1003+
'params': get_params.model_dump(),
1004+
}
1005+
with pytest.raises(ValidationError):
1006+
A2ARequest.model_validate(get_req_data) # missing id
1007+
1008+
# CancelTaskRequest case
1009+
id_params = TaskIdParams(id='t2')
1010+
cancel_req_data: dict[str, Any] = {
1011+
'jsonrpc': '2.0',
1012+
'method': 'tasks/cancel',
1013+
'params': id_params.model_dump(),
1014+
}
1015+
with pytest.raises(ValidationError):
1016+
A2ARequest.model_validate(cancel_req_data) # missing id
1017+
1018+
# SetTaskPushNotificationConfigRequest
1019+
task_push_config = TaskPushNotificationConfig(
1020+
taskId='t2',
1021+
pushNotificationConfig=PushNotificationConfig(
1022+
url='https://example.com', token='token'
1023+
),
1024+
)
1025+
set_push_notif_req_data: dict[str, Any] = {
1026+
'jsonrpc': '2.0',
1027+
'method': 'tasks/pushNotificationConfig/set',
1028+
'params': task_push_config.model_dump(),
1029+
'taskId': 2,
1030+
}
1031+
with pytest.raises(ValidationError):
1032+
A2ARequest.model_validate(set_push_notif_req_data) # missing id
1033+
1034+
# GetTaskPushNotificationConfigRequest
1035+
id_params = TaskIdParams(id='t2')
1036+
get_push_notif_req_data: dict[str, Any] = {
1037+
'jsonrpc': '2.0',
1038+
'method': 'tasks/pushNotificationConfig/get',
1039+
'params': id_params.model_dump(),
1040+
'taskId': 2,
1041+
}
1042+
with pytest.raises(ValidationError):
1043+
A2ARequest.model_validate(get_push_notif_req_data)
1044+
1045+
# TaskResubscriptionRequest
1046+
task_resubscribe_req_data: dict[str, Any] = {
1047+
'jsonrpc': '2.0',
1048+
'method': 'tasks/resubscribe',
1049+
'params': id_params.model_dump(),
1050+
}
1051+
with pytest.raises(ValidationError):
1052+
A2ARequest.model_validate(task_resubscribe_req_data)
1053+
1054+
9761055
def test_content_type_not_supported_error():
9771056
# Test ContentTypeNotSupportedError
9781057
err = ContentTypeNotSupportedError(

0 commit comments

Comments
 (0)