§
    éŽ’jô
  ã                   óH   — d Z ddlmZ ddlmZ  G d„ dej        ¦  «        ZdS )u:  Conversation-aware context for custom tools.

ToolContext is the Layer 2 counterpart to TriggerContext. It wraps a
Conversation and exposes conversation capabilities â€” identity and a
per-conversation key-value store â€” to tools that opt in by declaring
a ``ToolContext``-typed parameter.

Tools that do not declare a ``ToolContext`` parameter are unaffected.
The ToolRunner handles detection at registration time and injection at
execution time; schema generation automatically hides the ``ToolContext``
parameter from the model.

Example::

    from google.antigravity.tools.tool_context import ToolContext

    def my_tool(query: str, ctx: ToolContext) -> str:
        \"\"\"Searches and records the query in conversation state.\"\"\"
        ctx.set_state("last_query", query)
        return f"Searching for {query}..."
é    )Úconversation)Ústatec                   ó^   ‡ — e Zd ZdZdej        ddfˆ fd„Zedefd„¦   «         Z	dˆ fd„Z
ˆ xZS )	ÚToolContexta/  Conversation-aware context injected into tools that request it.

  Modeled after ``TriggerContext``, this handle wraps a ``Conversation``
  and provides a curated set of conversation capabilities. One
  ``ToolContext`` is created per session and shared across all tools.

  Per-conversation state (``get_state`` / ``set_state``) persists for
  the lifetime of the ``ToolContext`` instance (i.e., the session).
  State access methods (``get_state``, ``set_state``, ``update_state``)
  are thread-safe and protected by a reentrant lock (``threading.RLock``).
  r   ÚreturnNc                 óZ   •— t          ¦   «                              d¬¦  «         || _        dS )zaInitializes the ToolContext.

    Args:
      conversation: The active conversation session.
    N)Úparent)ÚsuperÚ__init__Ú_conversation)Úselfr   Ú	__class__s     €úSC:\Projects\DSCons\.venv\Lib\site-packages\google\antigravity\tools\tool_context.pyr   zToolContext.__init__6   s.   ø€ õ 
�G„G×Ò˜DÐÑ!Ô!Ð!Ø%€DÔÐÐó    c                 ó   — | j         j        S )z$Returns the conversation identifier.)r   Úconversation_id)r   s    r   r   zToolContext.conversation_idB   s   € ð ÔÔ-Ð-r   c                 óH   •— t          ¦   «                              ¦   «          | S )z8Acquires the context lock for use in a `with` statement.)r
   Ú	__enter__)r   r   s    €r   r   zToolContext.__enter__G   s   ø€ å	�G„G×ÒÑÔÐØ€Kr   )r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úconversation_moduleÚConversationr   ÚpropertyÚstrr   r   Ú__classcell__)r   s   @r   r   r   )   s¡   ø€ € € € € ð
ð 
ð
&à'Ô4ð
&ð ð
&ð 
&ð 
&ð 
&ð 
&ð 
&ð ð.˜sð .ð .ð .ñ „8ð.ðð ð ð ð ð ð ð ð ð r   r   N)	r   Úgoogle.antigravity.conversationr   r   Úgoogle.antigravity.utilsr   Ústate_moduleÚ
StateStorer   © r   r   ú<module>r#      sm   ððð ð, PÐ OÐ OÐ OÐ OÐ OØ :Ð :Ð :Ð :Ð :Ð :ð!ð !ð !ð !ð !�,Ô)ñ !ô !ð !ð !ð !r   