§
    öŽ’j:  ã                   óF   — d Z ddlmZmZ ddlmZmZ  G d„ de¦  «        ZdS )a:  
ResponseRouter - Protocol for pluggable response routing.

This module defines a protocol for routing JSON-RPC responses to alternative
handlers before falling back to the default response stream mechanism.

The primary use case is task-augmented requests: when a TaskSession enqueues
a request (like elicitation), the response needs to be routed back to the
waiting resolver instead of the normal response stream.

Design:
- Protocol-based for testability and flexibility
- Returns bool to indicate if response was handled
- Supports both success responses and errors
é    )ÚAnyÚProtocol)Ú	ErrorDataÚ	RequestIdc                   óJ   — e Zd ZdZdedeeef         defd„Z	dede
defd„ZdS )	ÚResponseRoutera  
    Protocol for routing responses to alternative handlers.

    Implementations check if they have a pending request for the given ID
    and deliver the response/error to the appropriate handler.

    Example:
        class TaskResultHandler(ResponseRouter):
            def route_response(self, request_id, response):
                resolver = self._pending_requests.pop(request_id, None)
                if resolver:
                    resolver.set_result(response)
                    return True
                return False
    Ú
request_idÚresponseÚreturnc                 ó   — dS )a  
        Try to route a response to a pending request handler.

        Args:
            request_id: The JSON-RPC request ID from the response
            response: The response result data

        Returns:
            True if the response was handled, False otherwise
        N© )Úselfr	   r
   s      úHC:\Projects\DSCons\.venv\Lib\site-packages\mcp\shared\response_router.pyÚroute_responsezResponseRouter.route_response'   ó	   € ð 	ˆó    Úerrorc                 ó   — dS )a  
        Try to route an error to a pending request handler.

        Args:
            request_id: The JSON-RPC request ID from the error response
            error: The error data

        Returns:
            True if the error was handled, False otherwise
        Nr   )r   r	   r   s      r   Úroute_errorzResponseRouter.route_error4   r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚdictÚstrr   Úboolr   r   r   r   r   r   r   r      sy   € € € € € ðð ð ¨ð ¸dÀ3ÈÀ8¼nð ÐQUð ð ð ð ð ið ¸	ð Àdð ð ð ð ð ð r   r   N)r   Útypingr   r   Ú	mcp.typesr   r   r   r   r   r   ú<module>r      su   ððð ð  !Ð  Ð  Ð  Ð  Ð  Ð  Ð  à *Ð *Ð *Ð *Ð *Ð *Ð *Ð *ð)ð )ð )ð )ð )�Xñ )ô )ð )ð )ð )r   