+
    Q(i                     >    R t ^ RIHtHt R R ltR R ltR R ltR# )	a  Task key management for SEP-1686 background tasks.

Task keys encode security scoping and metadata in the Docket key format:
    `{session_id}:{client_task_id}:{task_type}:{component_identifier}`

This format provides:
- Session-based security scoping (prevents cross-session access)
- Task type identification (tool/prompt/resource)
- Component identification (name or URI for result conversion)
)quoteunquotec          
      T    V ^8  d   QhR\         R\         R\         R\         R\         /# )   
session_idclient_task_id	task_typecomponent_identifierreturnstr)formats   "_/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/fastmcp/server/tasks/keys.py__annotate__r      sA     M MMM M 	M
 	M    c                6    \        VRR7      pV  RV RV RV 2# )a  Build Docket task key with embedded metadata.

Format: `{session_id}:{client_task_id}:{task_type}:{component_identifier}`

The component_identifier is URI-encoded to handle special characters (colons, slashes, etc.).

Args:
    session_id: Session ID for security scoping
    client_task_id: Client-provided task ID
    task_type: Type of task ("tool", "prompt", "resource")
    component_identifier: Tool name, prompt name, or resource URI

Returns:
    Encoded task key for Docket

Examples:
    >>> build_task_key("session123", "task456", "tool", "my_tool")
    'session123:task456:tool:my_tool'

    >>> build_task_key("session123", "task456", "resource", "file://data.txt")
    'session123:task456:resource:file%3A%2F%2Fdata.txt'
 )safe:)r   )r   r   r   r	   encoded_identifiers   &&&& r   build_task_keyr      s2    8 3"=\>*!I;a8J7KLLr   c                R    V ^8  d   QhR\         R\        \         \         3,          /# r   task_keyr
   )r   dict)r   s   "r   r   r   /   s"      S T#s(^ r   c                    V P                  R^4      p\        V4      ^8w  d   \        RV  R24      hRV^ ,          RV^,          RV^,          R\        V^,          4      /# )aE  Parse Docket task key to extract metadata.

Args:
    task_key: Encoded task key from Docket

Returns:
    Dict with keys: session_id, client_task_id, task_type, component_identifier

Examples:
    >>> parse_task_key("session123:task456:tool:my_tool")
    `{'session_id': 'session123', 'client_task_id': 'task456', 'task_type': 'tool', 'component_identifier': 'my_tool'}`

    >>> parse_task_key("session123:task456:resource:file%3A%2F%2Fdata.txt")
    `{'session_id': 'session123', 'client_task_id': 'task456', 'task_type': 'resource', 'component_identifier': 'file://data.txt'}`
r   zInvalid task key format: zL. Expected: {session_id}:{client_task_id}:{task_type}:{component_identifier}r   r   r   r	   )splitlen
ValueErrorr   )r   partss   & r   parse_task_keyr    /   st      NN3"E
5zQ'z 2a b
 	
 	eAh%(U1Xa 1	 r   c                0    V ^8  d   QhR\         R\         /# r   r   )r   s   "r   r   r   N   s     % %# %# %r   c                4    V P                  R^4      ^,          # )zExtract just the client task ID from a task key.

Args:
    task_key: Full encoded task key

Returns:
    Client-provided task ID (second segment)

Example:
    >>> get_client_task_id_from_key("session123:task456:tool:my_tool")
    'task456'
r   )r   )r   s   &r   get_client_task_id_from_keyr#   N   s     >>#q!!$$r   N)__doc__urllib.parser   r   r   r    r#    r   r   <module>r'      s    	 (M@>%r   