+
    Q(i                        R t ^ RIHt ^ RIt^ RIHt ^ RIHt ^ RIH	t	 ^ RI
HtHt ]R,          t]	! ^R7      t]! ]P!                  4       R,          4      tR	t] ! R
 R4      4       t] ! R R4      4       tR# )zTaskConfig for MCP SEP-1686 background task execution modes.

This module defines the configuration for how tools, resources, and prompts
handle task-augmented execution as specified in SEP-1686.
)annotationsN)Callable)	dataclass)	timedelta)AnyLiteral)secondsi  i`  c                  8    ] tR t^t$ RtRtR]R&   RtR]R&   RtR# )TaskMetaaM  Metadata for task-augmented execution requests.

When passed to call_tool/read_resource/get_prompt, signals that
the operation should be submitted as a background task.

Attributes:
    ttl: Client-requested TTL in milliseconds. If None, uses server default.
    fn_key: Docket routing key. Auto-derived from component name if None.
Nz
int | Nonettlz
str | Nonefn_key )	__name__
__module____qualname____firstlineno____doc__r   __annotations__r   __static_attributes__r       a/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/fastmcp/server/tasks/config.pyr
   r
      s     CFJr   r
   c                  f    ] tR t^(t$ RtRtR]R&   ]tR]R&   ]	R R l4       t
R	 R
 ltR R ltRtR# )
TaskConfigam  Configuration for MCP background task execution (SEP-1686).

Controls how a component handles task-augmented requests:

- "forbidden": Component does not support task execution. Clients must not
  request task augmentation; server returns -32601 if they do.
- "optional": Component supports both synchronous and task execution.
  Client may request task augmentation or call normally.
- "required": Component requires task execution. Clients must request task
  augmentation; server returns -32601 if they don't.

Important:
    Task-enabled components must be available at server startup to be
    registered with all Docket workers. Components added dynamically after
    startup will not be registered for background execution.

Example:
    ```python
    from fastmcp import FastMCP
    from fastmcp.server.tasks import TaskConfig

    mcp = FastMCP("MyServer")

    # Background execution required
    @mcp.tool(task=TaskConfig(mode="required"))
    async def long_running_task(): ...

    # Supports both modes (default when task=True)
    @mcp.tool(task=TaskConfig(mode="optional"))
    async def flexible_task(): ...
    ```
optionalTaskModemoder   poll_intervalc                    V ^8  d   QhRRRR/# )   valueboolreturnr   r   )formats   "r   __annotate__TaskConfig.__annotate__O   s     	> 	>d 	>z 	>r   c                2    T ! V'       d   RR7      # RR7      # )zConvert boolean task flag to TaskConfig.

Args:
    value: True for "optional" mode, False for "forbidden" mode.

Returns:
    TaskConfig with appropriate mode.
r   	forbiddenr   r   )clsr   s   &&r   	from_boolTaskConfig.from_boolN   s     e
====r   c                   V ^8  d   QhRR/# )r   r!   r    r   )r"   s   "r   r#   r$   Z   s     ( ( (r   c                     V P                   R8g  # )zCheck if this component supports task execution.

Returns:
    True if mode is "optional" or "required", False if "forbidden".
r&   r'   )selfs   &r   supports_tasksTaskConfig.supports_tasksZ   s     yyK''r   c               $    V ^8  d   QhRRRRRR/# )r   fnzCallable[..., Any]namestrr!   Noner   )r"   s   "r   r#   r$   b   s"     & &$6 &c &d &r   c                j   V P                  4       '       g   R# ^ RIHp V! RV R24       Tp\        P                  ! V4      '       g   \        V4      '       d   VP                  p\        V\        4      '       d   VP                  p\        P                  ! V4      '       g   \        RV R24      hR# )a*  Validate that function is compatible with this task config.

Task execution requires:
1. fastmcp[tasks] to be installed (pydocket)
2. Async functions

Raises ImportError if mode is "optional" or "required" but pydocket
is not installed. Raises ValueError if function is synchronous.

Args:
    fn: The function to validate (handles callable classes and staticmethods).
    name: Name for error messages.

Raises:
    ImportError: If task execution is enabled but pydocket not installed.
    ValueError: If task execution is enabled but function is sync.
N)require_docketz`task=True` on function ''z`' uses a sync function but has task execution enabled. Background tasks require async functions.)r.   fastmcp.server.dependenciesr6   inspect	isroutinecallable__call__
isinstancestaticmethod__func__iscoroutinefunction
ValueError)r-   r1   r2   r6   fn_to_checks   &&&  r   validate_functionTaskConfig.validate_functionb   s    $ ""$$ 	?24&:;   $$"++Kk<00%..K**;77D6 < <  8r   r   N)r   r   r   r   r   r   r   DEFAULT_POLL_INTERVALr   classmethodr)   r.   rC   r   r   r   r   r   r   (   s?    B  D(4M94	> 	>(& &r   r   )r&   r   required)r   
__future__r   r9   collections.abcr   dataclassesr   datetimer   typingr   r   r   rE   inttotal_secondsDEFAULT_POLL_INTERVAL_MSDEFAULT_TTL_MSr
   r   r   r   r   <module>rQ      s    #  $ !   67 "!, 4BBDtKL     _ _ _r   