Skip to content

Commit be0d708

Browse files
committed
Rename itemType to kind
1 parent 5419b70 commit be0d708

File tree

10 files changed

+32
-32
lines changed

10 files changed

+32
-32
lines changed

examples/helloworld/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ async def main() -> None:
1818
'message': {
1919
'role': 'user',
2020
'parts': [
21-
{'itemType': 'text', 'text': 'how much is 10 USD in INR?'}
21+
{'kind': 'text', 'text': 'how much is 10 USD in INR?'}
2222
],
2323
'messageId': uuid4().hex,
2424
},

examples/langgraph/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def create_send_message_payload(
2626
payload: dict[str, Any] = {
2727
'message': {
2828
'role': 'user',
29-
'parts': [{'itemType': 'text', 'text': text}],
29+
'parts': [{'kind': 'text', 'text': text}],
3030
'messageId': uuid4().hex,
3131
},
3232
}

src/a2a/types.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class DataPart(BaseModel):
133133
"""
134134
Structured data content
135135
"""
136-
itemType: Literal['data'] = 'data'
136+
kind: Literal['data'] = 'data'
137137
"""
138138
Part type - data for DataParts
139139
"""
@@ -590,7 +590,7 @@ class TextPart(BaseModel):
590590
Represents a text segment within parts.
591591
"""
592592

593-
itemType: Literal['text'] = 'text'
593+
kind: Literal['text'] = 'text'
594594
"""
595595
Part type - text for TextParts
596596
"""
@@ -745,7 +745,7 @@ class FilePart(BaseModel):
745745
"""
746746
File content either as url or bytes
747747
"""
748-
itemType: Literal['file'] = 'file'
748+
kind: Literal['file'] = 'file'
749749
"""
750750
Part type - file for FileParts
751751
"""
@@ -976,7 +976,7 @@ class Message(BaseModel):
976976
"""
977977
the context the message is associated with
978978
"""
979-
itemType: Literal['message'] = 'message'
979+
kind: Literal['message'] = 'message'
980980
"""
981981
event type
982982
"""
@@ -1095,7 +1095,7 @@ class TaskArtifactUpdateEvent(BaseModel):
10951095
"""
10961096
the context the task is associated with
10971097
"""
1098-
itemType: Literal['artifact-update'] = 'artifact-update'
1098+
kind: Literal['artifact-update'] = 'artifact-update'
10991099
"""
11001100
event type
11011101
"""
@@ -1142,7 +1142,7 @@ class TaskStatusUpdateEvent(BaseModel):
11421142
"""
11431143
indicates the end of the event stream
11441144
"""
1145-
itemType: Literal['status-update'] = 'status-update'
1145+
kind: Literal['status-update'] = 'status-update'
11461146
"""
11471147
event type
11481148
"""
@@ -1199,7 +1199,7 @@ class Task(BaseModel):
11991199
"""
12001200
unique identifier for the task
12011201
"""
1202-
itemType: Literal['task'] = 'task'
1202+
kind: Literal['task'] = 'task'
12031203
"""
12041204
event type
12051205
"""

tests/client/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@
6363
'id': 'task-abc',
6464
'contextId': 'session-xyz',
6565
'status': {'state': 'working'},
66-
'itemType': 'task',
66+
'kind': 'task',
6767
}
6868

6969
MINIMAL_CANCELLED_TASK: dict[str, Any] = {
7070
'id': 'task-abc',
7171
'contextId': 'session-xyz',
7272
'status': {'state': 'canceled'},
73-
'itemType': 'task',
73+
'kind': 'task',
7474
}
7575

7676

tests/server/events/test_event_consumer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
'id': '123',
2929
'contextId': 'session-xyz',
3030
'status': {'state': 'submitted'},
31-
'itemType': 'task',
31+
'kind': 'task',
3232
}
3333

3434
MESSAGE_PAYLOAD: dict[str, Any] = {

tests/server/events/test_event_queue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
'id': '123',
2222
'contextId': 'session-xyz',
2323
'status': {'state': 'submitted'},
24-
'itemType': 'task',
24+
'kind': 'task',
2525
}
2626
MESSAGE_PAYLOAD: dict[str, Any] = {
2727
'role': 'agent',

tests/server/request_handlers/test_jsonrpc_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
'id': 'task_123',
6363
'contextId': 'session-xyz',
6464
'status': {'state': 'submitted'},
65-
'itemType': 'task',
65+
'kind': 'task',
6666
}
6767
MESSAGE_PAYLOAD: dict[str, Any] = {
6868
'role': 'agent',

tests/server/tasks/test_inmemory_task_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'id': 'task-abc',
1111
'contextId': 'session-xyz',
1212
'status': {'state': 'submitted'},
13-
'itemType': 'task',
13+
'kind': 'task',
1414
}
1515

1616

tests/server/tasks/test_task_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
'id': 'task-abc',
2323
'contextId': 'session-xyz',
2424
'status': {'state': 'submitted'},
25-
'itemType': 'task',
25+
'kind': 'task',
2626
}
2727

2828

@@ -205,7 +205,7 @@ async def test_save_task_event_new_task_no_task_id(
205205
'id': 'new-task-id',
206206
'contextId': 'some-context',
207207
'status': {'state': 'working'},
208-
'itemType': 'task',
208+
'kind': 'task',
209209
}
210210
task = Task(**task_data)
211211
await task_manager_without_id.save_task_event(task)

tests/test_types.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,22 @@
106106
'version': '1.0',
107107
}
108108

109-
TEXT_PART_DATA: dict[str, Any] = {'itemType': 'text', 'text': 'Hello'}
109+
TEXT_PART_DATA: dict[str, Any] = {'kind': 'text', 'text': 'Hello'}
110110
FILE_URI_PART_DATA: dict[str, Any] = {
111-
'itemType': 'file',
111+
'kind': 'file',
112112
'file': {'uri': 'file:///path/to/file.txt', 'mimeType': 'text/plain'},
113113
}
114114
FILE_BYTES_PART_DATA: dict[str, Any] = {
115-
'itemType': 'file',
115+
'kind': 'file',
116116
'file': {'bytes': 'aGVsbG8=', 'name': 'hello.txt'}, # base64 for "hello"
117117
}
118-
DATA_PART_DATA: dict[str, Any] = {'itemType': 'data', 'data': {'key': 'value'}}
118+
DATA_PART_DATA: dict[str, Any] = {'kind': 'data', 'data': {'key': 'value'}}
119119

120120
MINIMAL_MESSAGE_USER: dict[str, Any] = {
121121
'role': 'user',
122122
'parts': [TEXT_PART_DATA],
123123
'messageId': 'msg-123',
124-
'itemType': 'message',
124+
'kind': 'message',
125125
}
126126

127127
AGENT_MESSAGE_WITH_FILE: dict[str, Any] = {
@@ -142,7 +142,7 @@
142142
'id': 'task-abc',
143143
'contextId': 'session-xyz',
144144
'status': MINIMAL_TASK_STATUS,
145-
'itemType': 'task',
145+
'kind': 'task',
146146
}
147147
FULL_TASK: dict[str, Any] = {
148148
'id': 'task-abc',
@@ -157,7 +157,7 @@
157157
}
158158
],
159159
'metadata': {'priority': 'high'},
160-
'itemType': 'task',
160+
'kind': 'task',
161161
}
162162

163163
MINIMAL_TASK_ID_PARAMS: dict[str, Any] = {'id': 'task-123'}
@@ -269,15 +269,15 @@ def test_agent_card_invalid():
269269

270270
def test_text_part():
271271
part = TextPart(**TEXT_PART_DATA)
272-
assert part.itemType == 'text'
272+
assert part.kind == 'text'
273273
assert part.text == 'Hello'
274274
assert part.metadata is None
275275

276276
with pytest.raises(ValidationError):
277277
TextPart(type='text') # Missing text # type: ignore
278278
with pytest.raises(ValidationError):
279279
TextPart(
280-
itemType='file', # type: ignore
280+
kind='file', # type: ignore
281281
text='hello',
282282
) # Wrong type literal
283283

@@ -287,15 +287,15 @@ def test_file_part_variants():
287287
file_uri = FileWithUri(
288288
uri='file:///path/to/file.txt', mimeType='text/plain'
289289
)
290-
part_uri = FilePart(itemType='file', file=file_uri)
290+
part_uri = FilePart(kind='file', file=file_uri)
291291
assert isinstance(part_uri.file, FileWithUri)
292292
assert part_uri.file.uri == 'file:///path/to/file.txt'
293293
assert part_uri.file.mimeType == 'text/plain'
294294
assert not hasattr(part_uri.file, 'bytes')
295295

296296
# Bytes variant
297297
file_bytes = FileWithBytes(bytes='aGVsbG8=', name='hello.txt')
298-
part_bytes = FilePart(itemType='file', file=file_bytes)
298+
part_bytes = FilePart(kind='file', file=file_bytes)
299299
assert isinstance(part_bytes.file, FileWithBytes)
300300
assert part_bytes.file.bytes == 'aGVsbG8='
301301
assert part_bytes.file.name == 'hello.txt'
@@ -312,14 +312,14 @@ def test_file_part_variants():
312312

313313
# Invalid - wrong type literal
314314
with pytest.raises(ValidationError):
315-
FilePart(itemType='text', file=file_uri) # type: ignore
315+
FilePart(kind='text', file=file_uri) # type: ignore
316316

317317
FilePart(**FILE_URI_PART_DATA, extra='extra') # type: ignore
318318

319319

320320
def test_data_part():
321321
part = DataPart(**DATA_PART_DATA)
322-
assert part.itemType == 'data'
322+
assert part.kind == 'data'
323323
assert part.data == {'key': 'value'}
324324

325325
with pytest.raises(ValidationError):
@@ -656,7 +656,7 @@ def test_send_message_streaming_status_update_response() -> None:
656656
'taskId': '1',
657657
'contextId': '2',
658658
'final': False,
659-
'itemType': 'status-update',
659+
'kind': 'status-update',
660660
}
661661

662662
event_data: dict[str, Any] = {
@@ -716,7 +716,7 @@ def test_send_message_streaming_artifact_update_response() -> None:
716716
'contextId': '2',
717717
'append': False,
718718
'lastChunk': True,
719-
'itemType': 'artifact-update',
719+
'kind': 'artifact-update',
720720
}
721721
event_data: dict[str, Any] = {
722722
'jsonrpc': '2.0',

0 commit comments

Comments
 (0)