§
    ™Štjî  ã                  óX   — d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	  G d„ d¦  «        Z
dS )	u]  In-process handle for a single tool call's streaming execution.

Mirrors the shape of `ChatModelStream` from langchain-core but simpler â€”
a tool has one output channel, no content-block multiplexing. Populated
by `ToolCallTransformer` as `tool-started` / `tool-output-delta` /
`tool-finished` / `tool-error` events flow in on the `tools` channel.
é    )Úannotations)ÚAsyncIteratorÚIterator)ÚAny)ÚStreamChannelc                  ón   — e Zd ZdZ	 ddd
„Zedd„¦   «         Zdd„Zd d„Zd!d„Z	d"d„Z
d#d„Zd$d„Zd%d„ZdS )&ÚToolCallStreamuL  Scoped view of a single tool call's lifecycle.

    Yielded on `run.tool_calls` once per `tool-started` event. Fields
    are populated as events arrive:

    - `tool_call_id`, `tool_name`, `input`: stable from the start event.
    - `output_deltas`: a `StreamChannel` of delta chunks. Iterate (sync or
      async) to consume partial output in arrival order.
    - `output`: terminal payload from `tool-finished`, or `None` if the
      call failed or is still in flight.
    - `error`: terminal error string from `tool-error`, or `None` if the
      call succeeded or is still in flight.
    - `completed`: True once a terminal event (`tool-finished` or
      `tool-error`) has been observed.

    `ToolCallStream` is not meant to be constructed by end users â€” it's
    produced by `ToolCallTransformer` as events flow through the mux.
    NÚtool_call_idÚstrÚ	tool_nameÚinputúdict[str, Any] | NoneÚreturnÚNonec                ó€   — || _         || _        || _        t          ¦   «         | _        d| _        d| _        d| _        dS )a,  Initialize a fresh handle for a tool call.

        Args:
            tool_call_id: The `tool_call_id` from the AIMessage.
            tool_name: The tool's name.
            input: The tool's input arguments (as reported by
                `on_tool_start`), or `None` if none were captured.
        NF)r
   r   r   r   Ú_output_deltasÚoutputÚerrorÚ	completed)Úselfr
   r   r   s       úb/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langgraph/prebuilt/_tool_call_stream.pyÚ__init__zToolCallStream.__init__%   s?   € ð )ˆÔØ"ˆŒØˆŒ
Ý2?±/´/ˆÔØˆŒØ!%ˆŒ
ØˆŒˆˆó    úStreamChannel[Any]c                ó   — | j         S )zñThe channel of streamed `tool-output-delta` payloads.

        Iterate (sync or async depending on how the run was started)
        to consume partial output in arrival order. The log closes when
        the tool finishes or errors.
        )r   ©r   s    r   Úoutput_deltaszToolCallStream.output_deltas;   s   € ð Ô"Ð"r   Úis_asyncÚboolc               ó<   — | j                              |¬¦  «         dS )z´Bind the deltas log to sync or async iteration.

        Called by `ToolCallTransformer` when constructing this handle so
        the log matches the enclosing mux's mode.
        )r   N)r   Ú_bind)r   r   s     r   r!   zToolCallStream._bindE   s$   € ð 	Ô×!Ò!¨8Ð!Ñ4Ô4Ð4Ð4Ð4r   Údeltar   c                ó:   — | j                              |¦  «         d S ©N)r   Úpush)r   r"   s     r   Ú_push_deltazToolCallStream._push_deltaM   s   € ØÔ× Ò  Ñ'Ô'Ð'Ð'Ð'r   r   c                óT   — || _         d| _        | j                             ¦   «          d S ©NT)r   r   r   Úclose)r   r   s     r   Ú_finishzToolCallStream._finishP   s+   € ØˆŒØˆŒØÔ×!Ò!Ñ#Ô#Ð#Ð#Ð#r   Úmessagec                óT   — || _         d| _        | j                             ¦   «          d S r(   )r   r   r   r)   )r   r+   s     r   Ú_failzToolCallStream._failU   s+   € ØˆŒ
ØˆŒØÔ×!Ò!Ñ#Ô#Ð#Ð#Ð#r   úIterator[Any]c                ó*   — t          | j        ¦  «        S )z¨Iterate delta chunks synchronously.

        Equivalent to `iter(self.output_deltas)`. Raises `TypeError` if
        the underlying log is bound to async mode.
        )Úiterr   r   s    r   Ú__iter__zToolCallStream.__iter__Z   s   € õ �DÔ'Ñ(Ô(Ð(r   úAsyncIterator[Any]c                ó4   — | j                              ¦   «         S )z©Iterate delta chunks asynchronously.

        Equivalent to `aiter(self.output_deltas)`. Raises `TypeError`
        if the underlying log is bound to sync mode.
        )r   Ú	__aiter__r   s    r   r4   zToolCallStream.__aiter__b   s   € ð Ô"×,Ò,Ñ.Ô.Ð.r   c                ód   — | j         r	| j        €dn
| j         rdnd}d| j        ›d| j        ›d|› d�S )Nr   ÚfailedÚrunningzToolCallStream(tool_call_id=z, tool_name=z	, status=ú))r   r   r
   r   )r   Ústatuss     r   Ú__repr__zToolCallStream.__repr__j   so   € ð Œ~ðØ"&¤*Ð"4ð ˆKð Œ~ð��àð 	ð>¨4Ô+<ð >ð >Øœð>ð >Ø4:ð>ð >ð >ð	
r   r$   )r
   r   r   r   r   r   r   r   )r   r   )r   r   r   r   )r"   r   r   r   )r   r   r   r   )r+   r   r   r   )r   r.   )r   r2   )r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   r!   r&   r*   r-   r1   r4   r:   © r   r   r	   r	      sè   € € € € € ðð ð. (,ð	ð ð ð ð ð, ð#ð #ð #ñ „Xð#ð5ð 5ð 5ð 5ð(ð (ð (ð (ð$ð $ð $ð $ð
$ð $ð $ð $ð
)ð )ð )ð )ð/ð /ð /ð /ð
ð 
ð 
ð 
ð 
ð 
r   r	   N)r>   Ú
__future__r   Úcollections.abcr   r   Útypingr   Úlanggraph.stream.stream_channelr   r	   r@   r   r   ú<module>rE      s›   ððð ð #Ð "Ð "Ð "Ð "Ð "à 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø Ð Ð Ð Ð Ð à 9Ð 9Ð 9Ð 9Ð 9Ð 9ðd
ð d
ð d
ð d
ð d
ñ d
ô d
ð d
ð d
ð d
r   