
    c
i                        d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	Z	ddl
mZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZmZmZmZ  ej        e          ZdedddddZ  G d d          Z!dS )zAsync LangGraph client.    )annotationsN)Mapping)TracebackType)AssistantsClient)
CronClient)
HttpClient)
RunsClient)StoreClient)ThreadsClient)TimeoutTypes)NOT_PROVIDED_get_headers_registered_transportsget_asgi_transport)urlapi_keyheaderstimeoutr   
str | Noner   r   Mapping[str, str] | Noner   TimeoutTypes | NonereturnLangGraphClientc           
        d}| d} t           j                            d          dk    r. t                      dd          }t	          j        |           nz	 ddlm}  t                      |d	          }nY# t          $ rL t          
                    d
d            t                      dd          }t	          j        |           Y nw xY w|t          j        d          }t          j        | ||t          j        |          nt          j        dddd          t          ||                    }t!          |          S )a
  Create and configure a LangGraphClient.

    The client provides programmatic access to LangSmith Deployment. It supports
    both remote servers and local in-process connections (when running inside a LangGraph server).

    Args:
        url:
            Base URL of the LangGraph API.
            - If `None`, the client first attempts an in-process connection via ASGI transport.
              If that fails, it defers registration until after app initialization. This
              only works if the client is used from within the Agent server.
        api_key:
            API key for authentication. Can be:
              - A string: use this exact API key
              - `None`: explicitly skip loading from environment variables
              - Not provided (default): auto-load from environment in this order:
                1. `LANGGRAPH_API_KEY`
                2. `LANGSMITH_API_KEY`
                3. `LANGCHAIN_API_KEY`
        headers:
            Additional HTTP headers to include in requests. Merged with authentication headers.
        timeout:
            HTTP timeout configuration. May be:
              - `httpx.Timeout` instance
              - float (total seconds)
              - tuple `(connect, read, write, pool)` in seconds
            Defaults: connect=5, read=300, write=300, pool=5.

    Returns:
        LangGraphClient:
            A top-level client exposing sub-clients for assistants, threads,
            runs, and cron operations.

    ???+ example "Connect to a remote server:"

        ```python
        from langgraph_sdk import get_client

        # get top-level LangGraphClient
        client = get_client(url="http://localhost:8123")

        # example usage: client.<model>.<method_name>()
        assistants = await client.assistants.get(assistant_id="some_uuid")
        ```

    ???+ example "Connect in-process to a running LangGraph server:"

        ```python
        from langgraph_sdk import get_client

        client = get_client(url=None)

        async def my_node(...):
            subagent_result = await client.runs.wait(
                thread_id=None,
                assistant_id="agent",
                input={"messages": [{"role": "user", "content": "Foo"}]},
            )
        ```

    ???+ example "Skip auto-loading API key from environment:"

        ```python
        from langgraph_sdk import get_client

        # Don't load API key from environment variables
        client = get_client(
            url="http://localhost:8123",
            api_key=None
        )
        ```
    Nz
http://api$__LANGGRAPH_DEFER_LOOPBACK_TRANSPORTtruez/noauth)app	root_pathr   )r   )r   zJFailed to connect to in-process LangGraph server. Deferring configuration.T)exc_info   )retriesi,  )connectreadwritepool)base_url	transportr   r   )osenvirongetr   r   appendlanggraph_api.serverr   	ExceptionloggerdebughttpxAsyncHTTPTransportAsyncClientTimeoutr   r   )r   r   r   r   r'   r   clients          C:\Users\Dell Inspiron 16\Desktop\tws\AgrotaPowerBi\back-agrota-powerbi\mcp-client-agrota\venv\Lib\site-packages\langgraph_sdk/_async/client.py
get_clientr6      s   ` 26I
{:>>@AAVKK,*,,KKKI"))4444
94444440.00	JJJ		 9 9 9`!     1.00TYOOO	&-i888889 ,Q777	 " M'"""qs#AFFFWg..	 	 	F 6"""s   A9 9ACCc                  2    e Zd ZdZddZddZddZddZdS )r   a  Top-level client for LangGraph API.

    Attributes:
        assistants: Manages versioned configuration for your graphs.
        threads: Handles (potentially) multi-turn interactions, such as conversational threads.
        runs: Controls individual invocations of the graph.
        crons: Manages scheduled operations.
        store: Interfaces with persistent, shared data storage.
    r4   httpx.AsyncClientr   Nonec                (   t          |          | _        t          | j                  | _        t	          | j                  | _        t          | j                  | _        t          | j                  | _	        t          | j                  | _        d S )N)r   httpr   
assistantsr   threadsr	   runsr   cronsr
   store)selfr4   s     r5   __init__zLangGraphClient.__init__   sj    v&&	*4955$TY//ty))		**
 ++


    c                
   K   | S )z Enter the async context manager. rA   s    r5   
__aenter__zLangGraphClient.__aenter__   s      rC   exc_typetype[BaseException] | Noneexc_valBaseException | Noneexc_tbTracebackType | Nonec                >   K   |                                   d{V  dS )zExit the async context manager.N)aclose)rA   rH   rJ   rL   s       r5   	__aexit__zLangGraphClient.__aexit__   s.       kkmmrC   c                v   K   t          | d          r&| j        j                                         d{V  dS dS )z!Close the underlying HTTP client.r;   N)hasattrr;   r4   rO   rF   s    r5   rO   zLangGraphClient.aclose   sQ      4   	,)"))+++++++++++	, 	,rC   N)r4   r8   r   r9   )r   r   )rH   rI   rJ   rK   rL   rM   r   r9   )r   r9   )__name__
__module____qualname____doc__rB   rG   rP   rO   rE   rC   r5   r   r      sn         , , , ,      , , , , , ,rC   )
r   r   r   r   r   r   r   r   r   r   )"rV   
__future__r   loggingr(   collections.abcr   typesr   r0   langgraph_sdk._async.assistantsr   langgraph_sdk._async.cronr   langgraph_sdk._async.httpr   langgraph_sdk._async.runsr	   langgraph_sdk._async.storer
   langgraph_sdk._async.threadsr   langgraph_sdk._shared.typesr   langgraph_sdk._shared.utilitiesr   r   r   r   	getLoggerrS   r.   r6   r   rE   rC   r5   <module>rd      s     " " " " " "  				 # # # # # #        < < < < < < 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 2 2 2 2 6 6 6 6 6 6 4 4 4 4 4 4            
	8	$	$
 &(,#'o# o# o# o# o# o#d#, #, #, #, #, #, #, #, #, #,rC   