Skip to content

Commit eadd79a

Browse files
authored
Refactor: Update schema to use valueMap instead of valueList, clarify data model. (#83)
1 parent 5991256 commit eadd79a

File tree

17 files changed

+752
-247
lines changed

17 files changed

+752
-247
lines changed

a2a_samples/a2ui_contact_lookup/a2ui_examples.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,24 @@
3838
"surfaceId": "contact-list",
3939
"path": "/",
4040
"contents": [
41-
{ "key": "contacts", "valueList": [] }
41+
{{ "key": "contacts", "valueMap": [
42+
{{ "key": "contact1", "valueMap": [
43+
{{ "key": "name", "valueString": "Alice Wonderland" }},
44+
{{ "key": "phone", "valueString": "+1-555-123-4567" }},
45+
{{ "key": "email", "valueString": "[email protected]" }},
46+
{{ "key": "imageUrl", "valueString": "https://example.com/alice.jpg" }},
47+
{{ "key": "title", "valueString": "Mad Hatter" }},
48+
{{ "key": "department", "valueString": "Wonderland" }}
49+
] }},
50+
{{ "key": "contact2", "valueMap": [
51+
{{ "key": "name", "valueString": "Bob The Builder" }},
52+
{{ "key": "phone", "valueString": "+1-555-765-4321" }},
53+
{{ "key": "email", "valueString": "[email protected]" }},
54+
{{ "key": "imageUrl", "valueString": "https://example.com/bob.jpg" }},
55+
{{ "key": "title", "valueString": "Construction" }},
56+
{{ "key": "department", "valueString": "Building" }}
57+
] }}
58+
] }}
4259
]
4360
} }
4461
]

a2a_samples/a2ui_contact_lookup/a2ui_schema.py

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515

1616
# a2ui_schema.py
1717

18-
A2UI_SCHEMA = """
18+
A2UI_SCHEMA = r'''
1919
{
2020
"title": "A2UI Message Schema",
21-
"description": "Describes a JSON payload for an A2UI message, which is used to dynamically construct and update user interfaces. A message MUST contain exactly ONE of the action properties: 'beginRendering', 'surfaceUpdate', 'dataModelUpdate', or 'deleteSurface'.",
21+
"description": "Describes a JSON payload for an A2UI (Agent to UI) message, which is used to dynamically construct and update user interfaces. A message MUST contain exactly ONE of the action properties: 'beginRendering', 'surfaceUpdate', 'dataModelUpdate', or 'deleteSurface'.",
2222
"type": "object",
2323
"properties": {
2424
"beginRendering": {
@@ -84,7 +84,7 @@
8484
"properties": {
8585
"text": {
8686
"type": "object",
87-
"description": "The text content for the heading. This can be a literal string or a reference to a value in the data model ('path', e.g. 'doc.title').",
87+
"description": "The text content for the heading. This can be a literal string or a reference to a value in the data model ('path', e.g. '/doc/title').",
8888
"properties": {
8989
"literalString": {
9090
"type": "string"
@@ -107,7 +107,7 @@
107107
"properties": {
108108
"text": {
109109
"type": "object",
110-
"description": "The text content to display. This can be a literal string or a reference to a value in the data model ('path', e.g. 'hotel.description').",
110+
"description": "The text content to display. This can be a literal string or a reference to a value in the data model ('path', e.g. '/hotel/description').",
111111
"properties": {
112112
"literalString": {
113113
"type": "string"
@@ -125,7 +125,7 @@
125125
"properties": {
126126
"url": {
127127
"type": "object",
128-
"description": "The URL of the image to display. This can be a literal string ('literal') or a reference to a value in the data model ('path', e.g. 'thumbnail.url').",
128+
"description": "The URL of the image to display. This can be a literal string ('literal') or a reference to a value in the data model ('path', e.g. '/thumbnail/url').",
129129
"properties": {
130130
"literalString": {
131131
"type": "string"
@@ -154,7 +154,7 @@
154154
"properties": {
155155
"name": {
156156
"type": "object",
157-
"description": "The name of the icon to display. This can be a literal string ('literal') or a reference to a value in the data model ('path', e.g. 'icon.name').",
157+
"description": "The name of the icon to display. This can be a literal string ('literal') or a reference to a value in the data model ('path', e.g. '/icon/name').",
158158
"properties": {
159159
"literalString": {
160160
"type": "string"
@@ -172,7 +172,7 @@
172172
"properties": {
173173
"url": {
174174
"type": "object",
175-
"description": "The URL of the video to display. This can be a literal string or a reference to a value in the data model ('path', e.g. 'video.url').",
175+
"description": "The URL of the video to display. This can be a literal string or a reference to a value in the data model ('path', e.g. '/video/url').",
176176
"properties": {
177177
"literalString": {
178178
"type": "string"
@@ -190,7 +190,7 @@
190190
"properties": {
191191
"url": {
192192
"type": "object",
193-
"description": "The URL of the audio to be played. This can be a literal string ('literal') or a reference to a value in the data model ('path', e.g. 'song.url').",
193+
"description": "The URL of the audio to be played. This can be a literal string ('literal') or a reference to a value in the data model ('path', e.g. '/song/url').",
194194
"properties": {
195195
"literalString": {
196196
"type": "string"
@@ -202,7 +202,7 @@
202202
},
203203
"description": {
204204
"type": "object",
205-
"description": "A description of the audio, such as a title or summary. This can be a literal string or a reference to a value in the data model ('path', e.g. 'song.title').",
205+
"description": "A description of the audio, such as a title or summary. This can be a literal string or a reference to a value in the data model ('path', e.g. '/song/title').",
206206
"properties": {
207207
"literalString": {
208208
"type": "string"
@@ -230,7 +230,7 @@
230230
},
231231
"template": {
232232
"type": "object",
233-
"description": "A template for generating a dynamic list of children from a data model list. `componentId` is the component to use as a template, and `dataBinding` is the path to the list in the data model.",
233+
"description": "A template for generating a dynamic list of children from a data model list. `componentId` is the component to use as a template, and `dataBinding` is the path to the map of components in the data model. Values in the map will define the list of children.",
234234
"properties": {
235235
"componentId": {
236236
"type": "string"
@@ -278,7 +278,7 @@
278278
},
279279
"template": {
280280
"type": "object",
281-
"description": "A template for generating a dynamic list of children from a data model list. `componentId` is the component to use as a template, and `dataBinding` is the path to the list in the data model.",
281+
"description": "A template for generating a dynamic list of children from a data model list. `componentId` is the component to use as a template, and `dataBinding` is the path to the map of components in the data model. Values in the map will define the list of children.",
282282
"properties": {
283283
"componentId": {
284284
"type": "string"
@@ -326,7 +326,7 @@
326326
},
327327
"template": {
328328
"type": "object",
329-
"description": "A template for generating a dynamic list of children from a data model list. `componentId` is the component to use as a template, and `dataBinding` is the path to the list in the data model.",
329+
"description": "A template for generating a dynamic list of children from a data model list. `componentId` is the component to use as a template, and `dataBinding` is the path to the map of components in the data model. Values in the map will define the list of children.",
330330
"properties": {
331331
"componentId": {
332332
"type": "string"
@@ -373,7 +373,7 @@
373373
"properties": {
374374
"title": {
375375
"type": "object",
376-
"description": "The tab title. Defines the value as either a literal value or a path to data model value (e.g. 'options.title').",
376+
"description": "The tab title. Defines the value as either a literal value or a path to data model value (e.g. '/options/title').",
377377
"properties": {
378378
"literalString": {
379379
"type": "string"
@@ -441,7 +441,7 @@
441441
},
442442
"value": {
443443
"type": "object",
444-
"description": "Defines the value to be included in the context as either a literal value or a path to a data model value (e.g. 'user.name').",
444+
"description": "Defines the value to be included in the context as either a literal value or a path to a data model value (e.g. '/user/name').",
445445
"properties": {
446446
"path": {
447447
"type": "string"
@@ -472,7 +472,7 @@
472472
"properties": {
473473
"label": {
474474
"type": "object",
475-
"description": "The text to display next to the checkbox. Defines the value as either a literal value or a path to data model ('path', e.g. 'option.label').",
475+
"description": "The text to display next to the checkbox. Defines the value as either a literal value or a path to data model ('path', e.g. '/option/label').",
476476
"properties": {
477477
"literalString": {
478478
"type": "string"
@@ -484,7 +484,7 @@
484484
},
485485
"value": {
486486
"type": "object",
487-
"description": "The current state of the checkbox (true for checked, false for unchecked). This can be a literal boolean ('literalBoolean') or a reference to a value in the data model ('path', e.g. 'filter.open').",
487+
"description": "The current state of the checkbox (true for checked, false for unchecked). This can be a literal boolean ('literalBoolean') or a reference to a value in the data model ('path', e.g. '/filter/open').",
488488
"properties": {
489489
"literalBoolean": {
490490
"type": "boolean"
@@ -502,7 +502,7 @@
502502
"properties": {
503503
"label": {
504504
"type": "object",
505-
"description": "The text label for the input field. This can be a literal string or a reference to a value in the data model ('path, e.g. 'user.name').",
505+
"description": "The text label for the input field. This can be a literal string or a reference to a value in the data model ('path, e.g. '/user/name').",
506506
"properties": {
507507
"literalString": {
508508
"type": "string"
@@ -514,7 +514,7 @@
514514
},
515515
"text": {
516516
"type": "object",
517-
"description": "The value of the text field. This can be a literal string or a reference to a value in the data model ('path', e.g. 'user.name').",
517+
"description": "The value of the text field. This can be a literal string or a reference to a value in the data model ('path', e.g. '/user/name').",
518518
"properties": {
519519
"literalString": {
520520
"type": "string"
@@ -547,7 +547,7 @@
547547
"properties": {
548548
"value": {
549549
"type": "object",
550-
"description": "The selected date and/or time value. This can be a literal string ('literalString') or a reference to a value in the data model ('path', e.g. 'user.dob').",
550+
"description": "The selected date and/or time value. This can be a literal string ('literalString') or a reference to a value in the data model ('path', e.g. '/user/dob').",
551551
"properties": {
552552
"literalString": {
553553
"type": "string"
@@ -577,7 +577,7 @@
577577
"properties": {
578578
"selections": {
579579
"type": "object",
580-
"description": "The currently selected values for the component. This can be a literal array of strings or a path to an array in the data model('path', e.g. 'hotel.options').",
580+
"description": "The currently selected values for the component. This can be a literal array of strings or a path to an array in the data model('path', e.g. '/hotel/options').",
581581
"properties": {
582582
"literalArray": {
583583
"type": "array",
@@ -598,7 +598,7 @@
598598
"properties": {
599599
"label": {
600600
"type": "object",
601-
"description": "The text to display for this option. This can be a literal string or a reference to a value in the data model (e.g. 'option.label').",
601+
"description": "The text to display for this option. This can be a literal string or a reference to a value in the data model (e.g. '/option/label').",
602602
"properties": {
603603
"literalString": {
604604
"type": "string"
@@ -628,7 +628,7 @@
628628
"properties": {
629629
"value": {
630630
"type": "object",
631-
"description": "The current value of the slider. This can be a literal number ('literalNumber') or a reference to a value in the data model ('path', e.g. 'restaurant.cost').",
631+
"description": "The current value of the slider. This can be a literal number ('literalNumber') or a reference to a value in the data model ('path', e.g. '/restaurant/cost').",
632632
"properties": {
633633
"literalNumber": {
634634
"type": "number"
@@ -668,7 +668,7 @@
668668
},
669669
"path": {
670670
"type": "string",
671-
"description": "An optional path to a location within the data model (e.g., 'user.name'). If omitted, the entire data model will be replaced."
671+
"description": "An optional path to a location within the data model (e.g., '/user/name'). If omitted, or set to '/', the entire data model will be replaced."
672672
},
673673
"contents": {
674674
"type": "array",
@@ -690,11 +690,16 @@
690690
"valueBoolean": {
691691
"type": "boolean"
692692
},
693-
"valueList": {
693+
"valueMap": {
694+
"description": "Represents a map as an adjacency list.",
694695
"type": "array",
695696
"items": {
696697
"type": "object",
698+
"description": "One entry in the map. Exactly one 'value*' property should be provided alongside the key.",
697699
"properties": {
700+
"key": {
701+
"type": "string"
702+
},
698703
"valueString": {
699704
"type": "string"
700705
},
@@ -704,7 +709,8 @@
704709
"valueBoolean": {
705710
"type": "boolean"
706711
}
707-
}
712+
},
713+
"required": ["key"]
708714
}
709715
}
710716
},
@@ -727,4 +733,4 @@
727733
}
728734
}
729735
}
730-
"""
736+
'''

0 commit comments

Comments
 (0)