@@ -51,18 +51,18 @@ def build(self, request: Request) -> ServerCallContext:
5151
5252
5353class JSONRPCApplication (ABC ):
54- """Base class for A2A applications.
54+ """Base class for A2A JSONRPC applications.
5555
56- Args:
57- agent_card: The AgentCard describing the agent's capabilities.
58- http_handler: The handler instance responsible for processing A2A
59- requests via http.
56+ Handles incoming JSON-RPC requests, routes them to the appropriate
57+ handler methods, and manages response generation including Server-Sent Events
58+ (SSE).
6059 """
6160
6261 def __init__ (
6362 self ,
6463 agent_card : AgentCard ,
6564 http_handler : RequestHandler ,
65+ extended_agent_card : AgentCard | None = None ,
6666 context_builder : CallContextBuilder | None = None ,
6767 ):
6868 """Initializes the A2AStarletteApplication.
@@ -71,14 +71,24 @@ def __init__(
7171 agent_card: The AgentCard describing the agent's capabilities.
7272 http_handler: The handler instance responsible for processing A2A
7373 requests via http.
74+ extended_agent_card: An optional, distinct AgentCard to be served
75+ at the authenticated extended card endpoint.
7476 context_builder: The CallContextBuilder used to construct the
7577 ServerCallContext passed to the http_handler. If None, no
7678 ServerCallContext is passed.
7779 """
7880 self .agent_card = agent_card
81+ self .extended_agent_card = extended_agent_card
7982 self .handler = JSONRPCHandler (
8083 agent_card = agent_card , request_handler = http_handler
8184 )
85+ if (
86+ self .agent_card .supportsAuthenticatedExtendedCard
87+ and self .extended_agent_card is None
88+ ):
89+ logger .error (
90+ 'AgentCard.supportsAuthenticatedExtendedCard is True, but no extended_agent_card was provided. The /agent/authenticatedExtendedCard endpoint will return 404.'
91+ )
8292 self ._context_builder = context_builder
8393
8494 def _generate_error_response (
@@ -321,10 +331,37 @@ async def _handle_get_agent_card(self, request: Request) -> JSONResponse:
321331 Returns:
322332 A JSONResponse containing the agent card data.
323333 """
334+ # The public agent card is a direct serialization of the agent_card
335+ # provided at initialization.
324336 return JSONResponse (
325337 self .agent_card .model_dump (mode = 'json' , exclude_none = True )
326338 )
327339
340+ async def _handle_get_authenticated_extended_agent_card (
341+ self , request : Request
342+ ) -> JSONResponse :
343+ """Handles GET requests for the authenticated extended agent card."""
344+ if not self .agent_card .supportsAuthenticatedExtendedCard :
345+ return JSONResponse (
346+ {'error' : 'Extended agent card not supported or not enabled.' },
347+ status_code = 404 ,
348+ )
349+
350+ # If an explicit extended_agent_card is provided, serve that.
351+ if self .extended_agent_card :
352+ return JSONResponse (
353+ self .extended_agent_card .model_dump (
354+ mode = 'json' , exclude_none = True
355+ )
356+ )
357+ # If supportsAuthenticatedExtendedCard is true, but no specific
358+ # extended_agent_card was provided during server initialization,
359+ # return a 404
360+ return JSONResponse (
361+ {'error' : 'Authenticated extended agent card is supported but not configured on the server.' },
362+ status_code = 404 ,
363+ )
364+
328365 @abstractmethod
329366 def build (
330367 self ,
0 commit comments