Ë
    ïñþi;  ã                   ó@   — d Z ddlmZ ddlmZmZmZmZ  G d„ d«      Zy)zÿ
TaskContext - Pure task state management.

This module provides TaskContext, which manages task state without any
server/session dependencies. It can be used standalone for distributed
workers or wrapped by ServerTaskContext for full server integration.
é    )Ú	TaskStore)ÚTASK_STATUS_COMPLETEDÚTASK_STATUS_FAILEDÚResultÚTaskc                   óš   — e Zd ZdZdedefd„Zedefd„«       Z	edefd„«       Z
edefd„«       Zdd
„Zdedd	fd„Zdedd	fd„Zdedd	fd„Zy	)ÚTaskContexta—  
    Pure task state management - no session dependencies.

    This class handles:
    - Task state (status, result)
    - Cancellation tracking
    - Store interactions

    For server-integrated features (elicit, create_message, notifications),
    use ServerTaskContext from mcp.server.experimental.

    Example (distributed worker):
        async def worker_job(task_id: str):
            store = RedisTaskStore(redis_url)
            task = await store.get_task(task_id)
            ctx = TaskContext(task=task, store=store)

            await ctx.update_status("Working...")
            result = await do_work()
            await ctx.complete(result)
    ÚtaskÚstorec                 ó.   — || _         || _        d| _        y )NF)Ú_taskÚ_storeÚ
_cancelled)Úselfr
   r   s      úe/root/aria/mcps/aria-brain/venv/lib/python3.12/site-packages/mcp/shared/experimental/tasks/context.pyÚ__init__zTaskContext.__init__$   s   € ØˆŒ
ØˆŒØˆ�ó    Úreturnc                 ó.   — | j                   j                  S )zThe task identifier.)r   ÚtaskId©r   s    r   Útask_idzTaskContext.task_id)   s   € ð �z‰z× Ñ Ð r   c                 ó   — | j                   S )zThe current task state.)r   r   s    r   r
   zTaskContext.task.   s   € ð �z‰zÐr   c                 ó   — | j                   S )z(Whether cancellation has been requested.©r   r   s    r   Úis_cancelledzTaskContext.is_cancelled3   s   € ð �‰Ðr   Nc                 ó   — d| _         y)z§
        Request cancellation of this task.

        This sets is_cancelled=True. Task work should check this
        periodically and exit gracefully if set.
        TNr   r   s    r   Úrequest_cancellationz TaskContext.request_cancellation8   s   € ð ˆ�r   Úmessagec              ƒ   óx   K  — | j                   j                  | j                  |¬«      ƒ d{  –—† | _        y7 Œ
­w)zn
        Update the task's status message.

        Args:
            message: The new status message
        )Ústatus_messageN)r   Úupdate_taskr   r   )r   r   s     r   Úupdate_statuszTaskContext.update_statusA   s7   è ø€ ð  Ÿ;™;×2Ñ2Ø�L‰LØ"ð 3ó 
÷ 
ˆ�
ð 
ús   ‚+:­8®:Úresultc              ƒ   óà   K  — | j                   j                  | j                  |«      ƒ d{  –—†  | j                   j                  | j                  t        ¬«      ƒ d{  –—† | _        y7 Œ=7 Œ­w)zv
        Mark the task as completed with the given result.

        Args:
            result: The task result
        N)Ústatus)r   Ústore_resultr   r"   r   r   )r   r$   s     r   ÚcompletezTaskContext.completeM   s[   è ø€ ð �k‰k×&Ñ& t§|¡|°VÓ<×<Ð<ØŸ;™;×2Ñ2Ø�L‰LÜ(ð 3ó 
÷ 
ˆ�
ð 	=øð
ús!   ‚*A.¬A*­2A.ÁA,Á A.Á,A.Úerrorc              ƒ   ó‚   K  — | j                   j                  | j                  t        |¬«      ƒ d{  –—† | _        y7 Œ
­w)zt
        Mark the task as failed with an error message.

        Args:
            error: The error message
        )r&   r!   N)r   r"   r   r   r   )r   r)   s     r   ÚfailzTaskContext.failZ   s:   è ø€ ð  Ÿ;™;×2Ñ2Ø�L‰LÜ%Ø ð 3ó 
÷ 
ˆ�
ð 
ús   ‚0?²=³?)r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   ÚpropertyÚstrr   r
   Úboolr   r   r#   r   r(   r+   © r   r   r	   r	      s©   „ ñð, ˜Tð  ¨)ó  ð
 ð!˜ò !ó ð!ð ð�dò ó ðð ð˜dò ó ðóð

¨3ð 

°4ó 

ð
 Vð 
°ó 
ð
 ð 
¨ô 
r   r	   N)	r/   Ú#mcp.shared.experimental.tasks.storer   Ú	mcp.typesr   r   r   r   r	   r3   r   r   ú<module>r6      s!   ðñõ :ß MÓ M÷X
ò X
r   