Skip to content

Commit 3ed20e8

Browse files
authored
feat: integrate Pong game scoreboard with silent updates and layout refinements (#1018)
* feat: integrate Pong game scoreboard with silent updates and layout refinements - Implement Pong game scoreboard with MCP-based score tracking and layout composition. - Add support for silent message processing in chat service and pong app score updates. - Update pong layout to a horizontal orientation with a sidebar scoreboard. - Apply refreshed styling, badges, and structural refinements to pong UI components. * fix: restrict postMessage origin to localhost and refactor unpauseGame to local scope
1 parent 92b4c2d commit 3ed20e8

File tree

10 files changed

+668
-111
lines changed

10 files changed

+668
-111
lines changed

samples/agent/adk/mcp_app_proxy/agent.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from google.adk.sessions import InMemorySessionService
2929
from google.genai import types
3030
from pydantic import PrivateAttr
31-
from tools import get_calculator_app, calculate_via_mcp, get_pong_app_a2ui_json
31+
from tools import get_calculator_app, calculate_via_mcp, get_pong_app_a2ui_json, score_update
3232
from agent_executor import get_a2ui_enabled, get_a2ui_catalog, get_a2ui_examples
3333

3434
logger = logging.getLogger(__name__)
@@ -160,6 +160,13 @@ def _build_agent_card(self) -> AgentCard:
160160
tags=["html", "app", "demo", "tool"],
161161
examples=["open pong", "show pong"],
162162
),
163+
AgentSkill(
164+
id="score_update",
165+
name="Score Update",
166+
description="Updates the score for Pong game.",
167+
tags=["pong", "score", "tool"],
168+
examples=[],
169+
),
163170
],
164171
)
165172

@@ -194,7 +201,12 @@ def _build_llm_agent(
194201
name=self._agent_name,
195202
description="An agent that provides access to MCP Apps.",
196203
instruction=instruction,
197-
tools=[get_calculator_app, calculate_via_mcp, get_pong_app_a2ui_json],
204+
tools=[
205+
get_calculator_app,
206+
calculate_via_mcp,
207+
get_pong_app_a2ui_json,
208+
score_update,
209+
],
198210
planner=BuiltInPlanner(
199211
thinking_config=types.ThinkingConfig(
200212
include_thoughts=True,

samples/agent/adk/mcp_app_proxy/catalogs/0.8/mcp_app_catalog.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,58 @@
4242
"required": [
4343
"content"
4444
]
45+
},
46+
"Column": {
47+
"type": "object",
48+
"additionalProperties": false,
49+
"properties": {
50+
"alignment": { "type": "string" },
51+
"distribution": { "type": "string" },
52+
"children": {
53+
"type": "array",
54+
"items": { "type": "object" }
55+
}
56+
}
57+
},
58+
"PongScoreBoard": {
59+
"type": "object",
60+
"additionalProperties": false,
61+
"properties": {
62+
"playerScore": {
63+
"type": "object",
64+
"description": "Player score value or path.",
65+
"additionalProperties": false,
66+
"properties": {
67+
"literalNumber": { "type": "number" },
68+
"literalString": { "type": "string" },
69+
"path": { "type": "string" }
70+
}
71+
},
72+
"cpuScore": {
73+
"type": "object",
74+
"description": "CPU score value or path.",
75+
"additionalProperties": false,
76+
"properties": {
77+
"literalNumber": { "type": "number" },
78+
"literalString": { "type": "string" },
79+
"path": { "type": "string" }
80+
}
81+
}
82+
}
83+
},
84+
"PongLayout": {
85+
"type": "object",
86+
"additionalProperties": false,
87+
"properties": {
88+
"mcpComponent": {
89+
"type": "object",
90+
"description": "McpApp component definition."
91+
},
92+
"scoreboardComponent": {
93+
"type": "object",
94+
"description": "PongScoreBoard component definition."
95+
}
96+
}
4597
}
4698
}
4799
}

samples/agent/adk/mcp_app_proxy/catalogs/0.9/mcp_app_catalog.json

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
11
{
22
"catalogId": "a2ui.org:a2ui/v0.9/mcp_app_catalog.json",
33
"components": {
4+
"Column": {
5+
"type": "object",
6+
"allOf": [
7+
{
8+
"$ref": "common_types.json#/$defs/ComponentCommon"
9+
},
10+
{
11+
"type": "object",
12+
"properties": {
13+
"component": {
14+
"const": "Column"
15+
},
16+
"alignment": {
17+
"type": "string"
18+
},
19+
"distribution": {
20+
"type": "string"
21+
},
22+
"children": {
23+
"type": "array",
24+
"items": {
25+
"$ref": "#/$defs/anyComponent"
26+
}
27+
}
28+
},
29+
"required": [
30+
"component"
31+
],
32+
"additionalProperties": false
33+
}
34+
]
35+
},
436
"McpApp": {
537
"type": "object",
638
"allOf": [
@@ -36,13 +68,76 @@
3668
"additionalProperties": false
3769
}
3870
]
71+
},
72+
"PongScoreBoard": {
73+
"type": "object",
74+
"allOf": [
75+
{
76+
"$ref": "common_types.json#/$defs/ComponentCommon"
77+
},
78+
{
79+
"type": "object",
80+
"properties": {
81+
"component": {
82+
"const": "PongScoreBoard"
83+
},
84+
"playerScore": {
85+
"$ref": "common_types.json#/$defs/DynamicNumber",
86+
"description": "Player score value or path."
87+
},
88+
"cpuScore": {
89+
"$ref": "common_types.json#/$defs/DynamicNumber",
90+
"description": "CPU score value or path."
91+
}
92+
},
93+
"required": [
94+
"component"
95+
],
96+
"additionalProperties": false
97+
}
98+
]
99+
},
100+
"PongLayout": {
101+
"type": "object",
102+
"allOf": [
103+
{
104+
"$ref": "common_types.json#/$defs/ComponentCommon"
105+
},
106+
{
107+
"type": "object",
108+
"properties": {
109+
"component": {
110+
"const": "PongLayout"
111+
},
112+
"mcpComponent": {
113+
"$ref": "#/$defs/McpApp"
114+
},
115+
"scoreboardComponent": {
116+
"$ref": "#/$defs/PongScoreBoard"
117+
}
118+
},
119+
"required": [
120+
"component"
121+
],
122+
"additionalProperties": false
123+
}
124+
]
39125
}
40126
},
41127
"$defs": {
42128
"anyComponent": {
43129
"oneOf": [
44130
{
45131
"$ref": "#/$defs/McpApp"
132+
},
133+
{
134+
"$ref": "#/$defs/PongScoreBoard"
135+
},
136+
{
137+
"$ref": "#/$defs/PongLayout"
138+
},
139+
{
140+
"$ref": "#/$defs/Column"
46141
}
47142
]
48143
}

0 commit comments

Comments
 (0)