Ë
    ÂXÕi]  ã                  ó   — d Z ddlmZ ddlmZmZ ddlmZmZ ddl	m
Z
mZmZ ddlmZmZmZ e
rddlmZ ddlmZ dd	lmZmZ e G d
„ d«      «       Ze G d„ d«      «       Ze G d„ d«      «       Ze G d„ d«      «       Ze G d„ d«      «       Ze G d„ d«      «       Ze G d„ d«      «       Ze G d„ d«      «       Z G d„ d«      Z  G d„ d«      Z!y)z#Data models for the sandbox client.é    )Úannotations)ÚAsyncIteratorÚIterator)Ú	dataclassÚfield)ÚTYPE_CHECKINGÚAnyÚOptional)ÚSandboxConnectionErrorÚSandboxOperationErrorÚSandboxServerReloadError)ÚAsyncSandbox)ÚSandbox)Ú_AsyncWSStreamControlÚ_WSStreamControlc                  óB   — e Zd ZU dZded<   ded<   ded<   ed	d„«       Zy)
ÚExecutionResultz+Result of executing a command in a sandbox.ÚstrÚstdoutÚstderrÚintÚ	exit_codec                ó    — | j                   dk(  S )z.Return True if the command exited with code 0.r   )r   ©Úselfs    úe/root/rosshost/parking-map/parking-api/venv/lib/python3.12/site-packages/langsmith/sandbox/_models.pyÚsuccesszExecutionResult.success    s   € ð �~‰~ Ñ"Ð"ó    N)ÚreturnÚbool)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__Úpropertyr   © r   r   r   r      s&   … á5àƒKØƒKØƒNàò#ó ñ#r   r   c                  ó<   — e Zd ZU dZdZded<   dZded<   dZded	<   y)
ÚResourceSpecz%Resource specification for a sandbox.Ú500mr   ÚcpuÚ512MiÚmemoryNúOptional[str]Ústorage)r!   r"   r#   r$   r+   r%   r-   r/   r'   r   r   r)   r)   &   s#   … á/à€CˆÓØ€FˆCÓØ!€Gˆ]Ô!r   r)   c                  ól   — e Zd ZU dZded<   ded<   ded<   dZded<   dZded	<   dZded
<   edd„«       Z	y)ÚVolumea@  Represents a persistent volume.

    Volumes are persistent storage that can be mounted in sandboxes.

    Attributes:
        id: Unique identifier (UUID). Remains constant even if name changes.
            May be None for resources created before ID support was added.
        name: Display name (can be updated).
    r   ÚnameÚsizeÚstorage_classNr.   ÚidÚ
created_atÚ
updated_atc           
     óØ   —  | |j                  dd«      |j                  dd«      |j                  dd«      |j                  d«      |j                  d«      |j                  d	«      ¬
«      S )z'Create a Volume from API response dict.r2   Ú r3   Úunknownr4   Údefaultr5   r6   r7   )r2   r3   r4   r5   r6   r7   ©Úget©ÚclsÚdatas     r   Ú	from_dictzVolume.from_dictB   s^   € ñ Ø—‘˜& "Ó%Ø—‘˜& )Ó,ØŸ(™( ?°IÓ>Ø�x‰x˜‹~Ø—x‘x Ó-Ø—x‘x Ó-ô
ð 	
r   )r@   údict[str, Any]r   r1   ©
r!   r"   r#   r$   r%   r5   r6   r7   ÚclassmethodrA   r'   r   r   r1   r1   /   sI   … ñð ƒIØ
ƒIØÓØ€BˆÓØ $€J�Ó$Ø $€J�Ó$àò	
ó ñ	
r   r1   c                  ó&   — e Zd ZU dZded<   ded<   y)ÚVolumeMountSpecz:Specification for mounting a volume in a sandbox template.r   Úvolume_nameÚ
mount_pathN©r!   r"   r#   r$   r%   r'   r   r   rF   rF   O   s   … áDàÓØ„Or   rF   c                  óˆ   — e Zd ZU dZded<   ded<   ded<    ee¬«      Zded	<   d
Zded<   d
Z	ded<   d
Z
ded<   edd„«       Zy
)ÚSandboxTemplatea›  Represents a SandboxTemplate.

    Templates define the image, resource limits, and volume mounts for sandboxes.
    All other container details are handled by the server with secure defaults.

    Attributes:
        id: Unique identifier (UUID). Remains constant even if name changes.
            May be None for resources created before ID support was added.
        name: Display name (can be updated).
    r   r2   Úimager)   Ú	resources)Údefault_factoryzlist[VolumeMountSpec]Úvolume_mountsNr.   r5   r6   r7   c                óô  — |j                  di «      }|j                  dg «      } | |j                  dd«      |j                  dd«      t        |j                  dd«      |j                  d	d
«      |j                  d«      ¬«      |D �cg c]/  }t        |j                  dd«      |j                  dd«      ¬«      ‘Œ1 c}|j                  d«      |j                  d«      |j                  d«      ¬«      S c c}w )z0Create a SandboxTemplate from API response dict.rM   rO   r2   r9   rL   r:   r+   r*   r-   r,   r/   )r+   r-   r/   rG   rH   )rG   rH   r5   r6   r7   )r2   rL   rM   rO   r5   r6   r7   )r=   r)   rF   )r?   r@   Úresources_dataÚvolume_mounts_dataÚvms        r   rA   zSandboxTemplate.from_dictl   sé   € ð Ÿ™ +¨rÓ2ˆØ!ŸX™X o°rÓ:ÐÙØ—‘˜& "Ó%Ø—(‘(˜7 IÓ.Ü"Ø"×&Ñ& u¨fÓ5Ø%×)Ñ)¨(°GÓ<Ø&×*Ñ*¨9Ó5ôð -öð
 ô	  Ø "§¡ }°bÓ 9Ø!Ÿv™v l°BÓ7öòð �x‰x˜‹~Ø—x‘x Ó-Ø—x‘x Ó-ô#
ð 	
ùòs   Â	4C5)r@   rB   r   rK   )r!   r"   r#   r$   r%   r   ÚlistrO   r5   r6   r7   rD   rA   r'   r   r   rK   rK   W   sY   … ñ	ð ƒIØƒJØÓÙ+0ÀÔ+F€MÐ(ÓFØ€BˆÓØ $€J�Ó$Ø $€J�Ó$àò
ó ñ
r   rK   c                  ó<   — e Zd ZU dZded<   dZded<   edd„«       Zy)	ÚResourceStatusa  Lightweight provisioning status for any async-created resource.

    Attributes:
        status: Resource lifecycle status. One of "provisioning", "ready", "failed".
        status_message: Human-readable details when status is "failed", None otherwise.
    r   ÚstatusNr.   Ústatus_messagec                óT   —  | |j                  dd«      |j                  d«      ¬«      S )z/Create a ResourceStatus from API response dict.rW   ÚprovisioningrX   )rW   rX   r<   r>   s     r   rA   zResourceStatus.from_dict’   s,   € ñ Ø—8‘8˜H nÓ5ØŸ8™8Ð$4Ó5ô
ð 	
r   )r@   rB   r   rV   )r!   r"   r#   r$   r%   rX   rD   rA   r'   r   r   rV   rV   †   s*   … ñð ƒKØ$(€N�MÓ(àò
ó ñ
r   rV   c                  ól   — e Zd ZU dZded<   ded<   ded<   dZded	<   dZded
<   dZded<   edd„«       Z	y)ÚPoola  Represents a Sandbox Pool for pre-provisioned sandboxes.

    Pools pre-provision sandboxes from a template for faster startup.
    Instead of waiting for a new sandbox to be created, sandboxes can
    be served from a pre-warmed pool.

    Note: Templates with volume mounts cannot be used in pools.

    Attributes:
        id: Unique identifier (UUID). Remains constant even if name changes.
            May be None for resources created before ID support was added.
        name: Display name (can be updated).
    r   r2   Útemplate_namer   ÚreplicasNr.   r5   r6   r7   c           
     óØ   —  | |j                  dd«      |j                  dd«      |j                  dd«      |j                  d«      |j                  d«      |j                  d«      ¬	«      S )
z%Create a Pool from API response dict.r2   r9   r]   r^   r   r5   r6   r7   )r2   r]   r^   r5   r6   r7   r<   r>   s     r   rA   zPool.from_dict²   s^   € ñ Ø—‘˜& "Ó%ØŸ(™( ?°BÓ7Ø—X‘X˜j¨!Ó,Ø�x‰x˜‹~Ø—x‘x Ó-Ø—x‘x Ó-ô
ð 	
r   )r@   rB   r   r\   rC   r'   r   r   r\   r\   ›   sI   … ñð ƒIØÓØƒMØ€BˆÓØ $€J�Ó$Ø $€J�Ó$àò	
ó ñ	
r   r\   c                  ó0   — e Zd ZU dZded<   ded<   ded<   y)ÚOutputChunkaf  A single chunk of streaming output from command execution.

    Attributes:
        stream: Either "stdout" or "stderr".
        data: The text content of this chunk (valid UTF-8, server handles
            boundary splitting).
        offset: Byte offset within the stream. Used internally for
            reconnection; users typically don't need this.
    r   Ústreamr@   r   ÚoffsetNrI   r'   r   r   ra   ra   Ä   s   … ñð ƒKØ
ƒIØ„Kr   ra   c                  óÒ   — e Zd ZdZdZdZdZddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zdd	„Ze	dd
„«       Z
e	dd„«       Ze	dd„«       Zdd„Zdd„Zdd„Zdd„Ze	dd„«       Ze	dd„«       Zdd„Zy)ÚCommandHandleaE  Handle to a running command with streaming output and auto-reconnect.

    Iterable, yielding OutputChunk objects (stdout and stderr interleaved
    in arrival order). Access .result after iteration to get the full
    ExecutionResult.

    Auto-reconnect behavior:
    - Server hot-reload (1001 Going Away): reconnect immediately
    - Network error / unexpected close:    reconnect with exponential backoff
    - User called kill():                  do NOT reconnect (propagate error)

    The auto-reconnect is transparent -- the iterator reconnects and
    continues yielding chunks without any user intervention. If all
    reconnect attempts are exhausted, SandboxConnectionError is raised.

    Construction modes (controlled by ``command_id``):
    - **New execution** (``command_id=""``, the default): the constructor
      eagerly reads the server's ``"started"`` message to populate
      ``command_id`` and ``pid`` before returning.
    - **Reconnection** (``command_id`` set): skips the started-message
      read, since reconnect streams don't emit one.

    Example:
        handle = sandbox.run("make build", timeout=600, wait=False)

        for chunk in handle:          # auto-reconnects on transient errors
            print(chunk.data, end="")

        result = handle.result
        print(f"Exit code: {result.exit_code}")
    é   ç      à?ç       @r9   r   ©Ú
command_idÚstdout_offsetÚstderr_offsetc               óÒ   — || _         || _        || _        d | _        d | _        d | _        g | _        g | _        d| _        || _	        || _
        |r|| _        y | j                  «        y )NF)Ú_streamÚ_controlÚ_sandboxÚ_command_idÚ_pidÚ_resultÚ_stdout_partsÚ_stderr_partsÚ
_exhaustedÚ_last_stdout_offsetÚ_last_stderr_offsetÚ_consume_started©r   Úmessage_streamÚcontrolÚsandboxrj   rk   rl   s          r   Ú__init__zCommandHandle.__init__ú   so   € ð &ˆŒØˆŒØˆŒØ*.ˆÔØ#'ˆŒ	Ø26ˆŒØ(*ˆÔØ(*ˆÔØˆŒØ#0ˆÔ Ø#0ˆÔ ñ
 Ø)ˆDÕà×!Ñ!Õ#r   c                ó$  — 	 t        | j                  «      }|j	                  d«      dk7  r t        d|j	                  d«      › d�d¬«      ‚|j	                  d«      | _        |j	                  d	«      | _        y
# t        $ r t        dd¬«      ‚w xY w)aH  Eagerly read the 'started' message to populate command_id and pid.

        Blocks briefly until the server sends the started message (arrives
        near-instantly after connection). After this call, command_id and
        pid are available, and the WebSocket is bound to the control object
        (so kill() works).
        ú-Command stream ended before 'started' messageÚcommand©Ú	operationÚtypeÚstartedú!Expected 'started' message, got 'ú'rj   ÚpidN)Únextrn   ÚStopIterationr   r=   rq   rr   ©r   Ú	first_msgs     r   ry   zCommandHandle._consume_started  s•   € ð	Ü˜TŸ\™\Ó*ˆIð �=‰=˜Ó  IÒ-Ü'Ø3°I·M±MÀ&Ó4IÐ3JÈ!ÐLØ#ôð ð %Ÿ=™=¨Ó6ˆÔØ—M‘M %Ó(ˆ�	øô ò 	Ü'Ø?Ø#ôð ð	ús   ‚A8 Á8Bc                ó   — | j                   S )z=The server-assigned command ID. Available after construction.©rq   r   s    r   rj   zCommandHandle.command_id/  ó   € ð ×ÑÐr   c                ó   — | j                   S )z<The process ID on the sandbox. Available after construction.©rr   r   s    r   rˆ   zCommandHandle.pid4  ó   € ð �y‰yÐr   c                ór   — | j                   €| D ]  }Œ | j                   €t        dd¬«      ‚| j                   S )zßThe final execution result. Blocks until the command completes.

        Drains the remaining stream if not already exhausted, then returns
        the ExecutionResult with aggregated stdout, stderr, and exit_code.
        ú)Command stream ended without exit messager�   r‚   ©rs   r   ©r   Ú_s     r   ÚresultzCommandHandle.result9  sI   € ð �<‰<ÐØò �Øðà�<‰<ÐÜ'Ø;Ø#ôð ð �|‰|Ðr   c           	   #  óü  K  — | j                   ry| j                  D ]Õ  }|j                  d«      }|dv rht        ||d   |j                  dd«      ¬«      }|dk(  r| j                  j                  |d   «       n| j                  j                  |d   «       |–— Œ€|d	k(  sŒ†t        d
j                  | j                  «      d
j                  | j                  «      |d   ¬«      | _	        d| _          y d| _         y­w©zBIterate over output chunks from the current stream (no reconnect).Nr„   )r   r   r@   rc   r   )rb   r@   rc   r   Úexitr9   r   )r   r   r   T)
rv   rn   r=   ra   rt   Úappendru   r   Újoinrs   ©r   ÚmsgÚmsg_typeÚchunks       r   Ú_iter_streamzCommandHandle._iter_streamJ  sï   è ø€ à�?Š?ØØ—<‘<ò 	ˆCØ—w‘w˜v“ˆHØÐ/Ñ/Ü#Ø#Ø˜V™ØŸ7™7 8¨QÓ/ô�ð
 ˜xÒ'Ø×&Ñ&×-Ñ-¨c°&©kÕ:à×&Ñ&×-Ñ-¨c°&©kÔ:Ø“Ø˜VÓ#Ü.ØŸ7™7 4×#5Ñ#5Ó6ØŸ7™7 4×#5Ñ#5Ó6Ø! +Ñ.ô �”ð
 #'�”Ùð)	ð* ˆ�ùs   ‚BC<Â"AC<c              #  óˆ  K  — ddl }d}	 	 | j                  «       D ]„  }d}|j                  dk(  r7|j                  t	        |j
                  j                  d«      «      z   | _        n6|j                  t	        |j
                  j                  d«      «      z   | _        |–— Œ† y# t        $ �r}| j                  r| j                  j                  r‚ |dz  }|| j                  kD  rt        d|› d�«      |‚t        |t        «      }|s:t        | j                   d|dz
  z  z  | j"                  «      }|j%                  |«       | j&                  €J ‚| j(                  j+                  | j&                  | j                  | j                  ¬	«      }|j,                  | _        |j                  | _
        d
| _        Y d}~nd}~ww xY w�Œ¸­w)aE  Iterate over output chunks, auto-reconnecting on transient errors.

        Reconnect strategy:
        - 1001 Going Away (hot-reload): immediate reconnect, no delay
        - Other SandboxConnectionError:  exponential backoff (0.5s, 1s, 2s...)
        - After kill():                  no reconnect, error propagates
        r   Nr   úutf-8é   úLost connection ú times in succession, giving upé   ©rk   rl   F)Útimer¢   rb   rc   Úlenr@   Úencoderw   rx   r   ro   ÚkilledÚMAX_AUTO_RECONNECTSÚ
isinstancer   ÚminÚ_BACKOFF_BASEÚ_BACKOFF_MAXÚsleeprq   rp   Ú	reconnectrn   rv   )r   rª   Úreconnect_attemptsr¡   ÚeÚis_hot_reloadÚdelayÚ
new_handles           r   Ú__iter__zCommandHandle.__iter__e  sÇ  è ø€ ó 	àÐØð)(Ø!×.Ñ.Ó0ò 
 �EØ)*Ð&Ø—|‘| xÒ/Ø38·<±<Ä#Ø!ŸJ™J×-Ñ-¨gÓ6óCñ 4˜Õ0ð 49·<±<Ä#Ø!ŸJ™J×-Ñ-¨gÓ6óCñ 4˜Ô0ð  “Kð
 ð øä)ó (Ø—=’= T§]¡]×%9Ò%9Øà" aÑ'Ð"Ø%¨×(@Ñ(@Ò@Ü0Ø*Ð+=Ð*>ð ?0ð 1óð ðô
 !+¨1Ô.FÓ G�Ù$ÜØ×*Ñ*¨aÐ4FÈÑ4JÑ.KÑLØ×)Ñ)ó�Eð —J‘J˜uÔ%à×'Ñ'Ð3Ð3Ð3Ø!Ÿ]™]×4Ñ4Ø×$Ñ$Ø"&×":Ñ":Ø"&×":Ñ":ð 5ó �
ð
  *×1Ñ1�”Ø *× 3Ñ 3�”Ø"'�—‘ûð7(úñ ùs0   ‚G‹BB# Â"GÂ#
F=Â-DF8Æ3GÆ8F=Æ=Gc                óR   — | j                   r| j                   j                  «        yy)a/  Send a kill signal to the running command (SIGKILL).

        The server kills the entire process group. The stream will
        subsequently yield an exit message with a non-zero exit code.

        Has no effect if the command has already exited or the
        WebSocket connection is closed.
        N©ro   Ú	send_killr   s    r   ÚkillzCommandHandle.killœ  s    € ð �=Š=Ø�M‰M×#Ñ#Õ%ð r   c                óT   — | j                   r| j                   j                  |«       yy)zÓWrite data to the command's stdin.

        Args:
            data: String data to write to stdin.

        Has no effect if the command has already exited or the
        WebSocket connection is closed.
        N©ro   Ú
send_input©r   r@   s     r   rÁ   zCommandHandle.send_input¨  s"   € ð �=Š=Ø�M‰M×$Ñ$ TÕ*ð r   c                ó   — | j                   S ©z8Last known stdout byte offset (for manual reconnection).©rw   r   s    r   Úlast_stdout_offsetz CommandHandle.last_stdout_offset´  ó   € ð ×'Ñ'Ð'r   c                ó   — | j                   S ©z8Last known stderr byte offset (for manual reconnection).©rx   r   s    r   Úlast_stderr_offsetz CommandHandle.last_stderr_offset¹  rÇ   r   c                ó–   — | j                   €J ‚| j                  j                  | j                   | j                  | j                  ¬«      S )aÛ  Reconnect to this command from the last known offsets.

        Returns a new handle that resumes output from where this one
        left off. Any output produced while disconnected is replayed
        from the server's ring buffer.

        Returns:
            A new CommandHandle.

        Raises:
            SandboxOperationError: If command_id is not found or
                session expired.
            SandboxConnectionError: If connection to sandbox fails.
        r©   ©rq   rp   r´   rw   rx   r   s    r   r´   zCommandHandle.reconnect¾  sM   € ð ×ÑÐ+Ð+Ð+Ø�}‰}×&Ñ&Ø×ÑØ×2Ñ2Ø×2Ñ2ð 'ó 
ð 	
r   N)r{   zIterator[dict]r|   zOptional[_WSStreamControl]r}   r   rj   r   rk   r   rl   r   r   ÚNone©r   rÎ   ©r   r.   ©r   zOptional[int]©r   r   )r   zIterator[OutputChunk]©r@   r   r   rÎ   ©r   r   )r   re   )r!   r"   r#   r$   r®   r±   r²   r~   ry   r&   rj   rˆ   r˜   r¢   rº   r¾   rÁ   rÆ   rË   r´   r'   r   r   re   re   Õ   sñ   „ ñð@ ÐØ€MØ€Lð ØØñ$à&ð$ð ,ð$ð ð	$ð ð$ð ð$ð ð$ð 
ó$ó<)ð. ò ó ð ð òó ðð òó ðó ó65(ón
&ó
+ð ò(ó ð(ð ò(ó ð(ô
r   re   c                  óÒ   — e Zd ZdZdZdZdZddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zdd	„Ze	dd
„«       Z
e	dd„«       Ze	dd„«       Zdd„Zdd„Zdd„Zdd„Ze	dd„«       Ze	dd„«       Zdd„Zy)ÚAsyncCommandHandleaž  Async handle to a running command with streaming output and auto-reconnect.

    Async iterable, yielding OutputChunk objects (stdout and stderr interleaved
    in arrival order). Access .result after iteration to get the full
    ExecutionResult.

    Auto-reconnect behavior:
    - Server hot-reload (1001 Going Away): reconnect immediately
    - Network error / unexpected close:    reconnect with exponential backoff
    - User called kill():                  do NOT reconnect (propagate error)

    Construction modes (controlled by ``command_id``):
    - **New execution** (``command_id=""``, the default): call
      ``await handle._ensure_started()`` after construction to read the
      server's ``"started"`` message and populate ``command_id`` / ``pid``.
    - **Reconnection** (``command_id`` set): skips the started-message
      read, since reconnect streams don't emit one.

    Example:
        handle = await sandbox.run("make build", timeout=600, wait=False)

        async for chunk in handle:    # auto-reconnects on transient errors
            print(chunk.data, end="")

        result = await handle.result
        print(f"Exit code: {result.exit_code}")
    rf   rg   rh   r9   r   ri   c               óÎ   — || _         || _        || _        d | _        d | _        d | _        g | _        g | _        d| _        || _	        || _
        |r|| _        d| _        y d| _        y )NFT)rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   Ú_startedrz   s          r   r~   zAsyncCommandHandle.__init__ö  sq   € ð &ˆŒØˆŒØˆŒØ*.ˆÔØ#'ˆŒ	Ø26ˆŒØ(*ˆÔØ(*ˆÔØˆŒØ#0ˆÔ Ø#0ˆÔ ñ
 Ø)ˆDÔØ ˆD�Mà!ˆD�Mr   c              ƒ  ór  K  — | j                   ry	 | j                  j                  «       ƒ d{  –—† }|j                  d«      dk7  r t	        d|j                  d«      › d�d¬«      ‚|j                  d	«      | _        |j                  d
«      | _        d| _         y7 Œl# t        $ r t	        dd¬«      ‚w xY w­w)z:Read the 'started' message to populate command_id and pid.Nr€   r�   r‚   r„   r…   r†   r‡   rj   rˆ   T)rØ   rn   Ú	__anext__ÚStopAsyncIterationr   r=   rq   rr   r‹   s     r   Ú_ensure_startedz"AsyncCommandHandle._ensure_started  s³   è ø€ à�=Š=Øð	Ø"Ÿl™l×4Ñ4Ó6×6ˆIð �=‰=˜Ó  IÒ-Ü'Ø3°I·M±MÀ&Ó4IÐ3JÈ!ÐLØ#ôð ð %Ÿ=™=¨Ó6ˆÔØ—M‘M %Ó(ˆŒ	Øˆ�ð 7ùÜ!ò 	Ü'Ø?Ø#ôð ð	üs,   ‚B7‘B ®B¯B ³A(B7ÂB ÂB4Â4B7c                ó   — | j                   S )z@The server-assigned command ID. Available after _ensure_started.rŽ   r   s    r   rj   zAsyncCommandHandle.command_id)  r�   r   c                ó   — | j                   S )z?The process ID on the sandbox. Available after _ensure_started.r‘   r   s    r   rˆ   zAsyncCommandHandle.pid.  r’   r   c              ƒ  óŒ   K  — | j                   €| 2 3 d{  –—† }Œ
| j                   €t        dd¬«      ‚| j                   S 7 Œ*6 Œ)­w)z&The final execution result. Awaitable.Nr”   r�   r‚   r•   r–   s     r   r˜   zAsyncCommandHandle.result3  sU   è ø€ ð �<‰<ÐØ÷ ð �aØØ�<‰<ÐÜ'Ø;Ø#ôð ð �|‰|Ððø˜4ús%   ‚A‘A•A –A™'AÁ AÁAc           	    óB  K  — | j                  «       ƒ d{  –—†  | j                  ry| j                  2 3 d{  –—† }|j                  d«      }|dv rit	        ||d   |j                  dd«      ¬«      }|dk(  r| j
                  j                  |d   «       n| j                  j                  |d   «       |­–— Œ‡|d	k(  sŒ�t        d
j                  | j
                  «      d
j                  | j                  «      |d   ¬«      | _
        d| _         y7 Œû7 ŒÛ6 d| _        y­wrš   )rÜ   rv   rn   r=   ra   rt   rœ   ru   r   r�   rs   rž   s       r   Ú_aiter_streamz AsyncCommandHandle._aiter_stream@  s  è ø€ à×"Ñ"Ó$×$Ð$Ø�?Š?ØØŸ™÷ 	ð 	�#Ø—w‘w˜v“ˆHØÐ/Ñ/Ü#Ø#Ø˜V™ØŸ7™7 8¨QÓ/ô�ð
 ˜xÒ'Ø×&Ñ&×-Ñ-¨c°&©kÕ:à×&Ñ&×-Ñ-¨c°&©kÔ:Ø”Ø˜VÓ#Ü.ØŸ7™7 4×#5Ñ#5Ó6ØŸ7™7 4×#5Ñ#5Ó6Ø! +Ñ.ô �”ð
 #'�”Ùð/ 	%øð	ø˜ð* ˆ�ùs7   ‚D–D—D´D¸D¹D¼BDÃADÄDÄ	Dc               ó¾  K  — ddl }d}	 	 | j                  «       2 3 d{  –—† }d}|j                  dk(  r7|j                  t	        |j
                  j                  d«      «      z   | _        n6|j                  t	        |j
                  j                  d«      «      z   | _        |­–— Œ�7 Œˆ6 y# t        $ �r"}| j                  r| j                  j                  r‚ |dz  }|| j                  kD  rt        d|› d�«      |‚t        |t        «      }|sCt        | j                   d|dz
  z  z  | j"                  «      }|j%                  |«      ƒ d{  –—†7   | j&                  €J ‚| j(                  j+                  | j&                  | j                  | j                  ¬	«      ƒ d{  –—†7  }|j,                  | _        |j                  | _
        d
| _        Y d}~nd}~ww xY w�ŒÓ­w)z6Async iterate with auto-reconnect on transient errors.r   Nr   r¤   r¥   r¦   r§   r¨   r©   F)Úasynciorá   rb   rc   r«   r@   r¬   rw   rx   r   ro   r­   r®   r¯   r   r°   r±   r²   r³   rq   rp   r´   rn   rv   )r   rã   rµ   r¡   r¶   r·   r¸   r¹   s           r   Ú	__aiter__zAsyncCommandHandle.__aiter__\  sÞ  è ø€ ãàÐØð)(Ø#'×#5Ñ#5Ó#7÷ 
 ð 
 ˜%Ø)*Ð&Ø—|‘| xÒ/Ø38·<±<Ä#Ø!ŸJ™J×-Ñ-¨gÓ6óCñ 4˜Õ0ð 49·<±<Ä#Ø!ŸJ™J×-Ñ-¨gÓ6óCñ 4˜Ô0ð  ”Kð
 øÐ#7ð øä)ó (Ø—=’= T§]¡]×%9Ò%9Øà" aÑ'Ð"Ø%¨×(@Ñ(@Ò@Ü0Ø*Ð+=Ð*>ð ?3ð 4óð ðô
 !+¨1Ô.FÓ G�Ù$ÜØ×*Ñ*¨aÐ4FÈÑ4JÑ.KÑLØ×)Ñ)ó�Eð "Ÿ-™-¨Ó.×.Ñ.à×'Ñ'Ð3Ð3Ð3Ø#'§=¡=×#:Ñ#:Ø×$Ñ$Ø"&×":Ñ":Ø"&×":Ñ":ð $;ó $÷ ð �
ð
  *×1Ñ1�”Ø *× 3Ñ 3�”Ø"'�—‘ûð7(úñ ùsi   ‚G‹B, ›B*ŸB( B*£BB, Â(B*Â*B, Â+GÂ,
GÂ6BGÅEÅAGÆF"Æ .GÇGÇGÇGc              ƒ  ón   K  — | j                   r#| j                   j                  «       ƒ d{  –—†  yy7 Œ­w)z*Send a kill signal to the running command.Nr¼   r   s    r   r¾   zAsyncCommandHandle.kill�  s+   è ø€ à�=Š=Ø—-‘-×)Ñ)Ó+×+Ñ+ð Ø+ús   ‚*5¬3­5c              ƒ  óp   K  — | j                   r$| j                   j                  |«      ƒ d{  –—†  yy7 Œ­w)z"Write data to the command's stdin.NrÀ   rÂ   s     r   rÁ   zAsyncCommandHandle.send_input’  s-   è ø€ à�=Š=Ø—-‘-×*Ñ*¨4Ó0×0Ñ0ð Ø0ús   ‚+6­4®6c                ó   — | j                   S rÄ   rÅ   r   s    r   rÆ   z%AsyncCommandHandle.last_stdout_offset—  rÇ   r   c                ó   — | j                   S rÉ   rÊ   r   s    r   rË   z%AsyncCommandHandle.last_stderr_offsetœ  rÇ   r   c              ƒ  ó²   K  — | j                   €J ‚| j                  j                  | j                   | j                  | j                  ¬«      ƒ d{  –—† S 7 Œ­w)z6Reconnect to this command from the last known offsets.Nr©   rÍ   r   s    r   r´   zAsyncCommandHandle.reconnect¡  sY   è ø€ à×ÑÐ+Ð+Ð+Ø—]‘]×,Ñ,Ø×ÑØ×2Ñ2Ø×2Ñ2ð -ó 
÷ 
ð 	
ð 
ús   ‚AAÁAÁAN)r{   zAsyncIterator[dict]r|   zOptional[_AsyncWSStreamControl]r}   r   rj   r   rk   r   rl   r   r   rÎ   rÏ   rÐ   rÑ   rÒ   )r   zAsyncIterator[OutputChunk]rÓ   rÔ   )r   rÖ   )r!   r"   r#   r$   r®   r±   r²   r~   rÜ   r&   rj   rˆ   r˜   rá   rä   r¾   rÁ   rÆ   rË   r´   r'   r   r   rÖ   rÖ   Õ  sð   „ ñð8 ÐØ€MØ€Lð ØØñ"à+ð"ð 1ð"ð ð	"ð ð"ð ð"ð ð"ð 
ó"ó>ð( ò ó ð ð òó ðð ò
ó ð
óó8/(ób,ó
1ð
 ò(ó ð(ð ò(ó ð(ô
r   rÖ   N)"r$   Ú
__future__r   Úcollections.abcr   r   Údataclassesr   r   Útypingr   r	   r
   Úlangsmith.sandbox._exceptionsr   r   r   Ú langsmith.sandbox._async_sandboxr   Úlangsmith.sandbox._sandboxr   Úlangsmith.sandbox._ws_executer   r   r   r)   r1   rF   rK   rV   r\   ra   re   rÖ   r'   r   r   ú<module>rò      s  ðÙ )å "ç 3ß (ß /Ñ /÷ñ ñ Ý=Ý2÷ð ÷
#ð 
#ó ð
#ð ÷"ð "ó ð"ð ÷
ð 
ó ð
ð> ÷ð ó ðð ÷+
ð +
ó ð+
ð\ ÷
ð 
ó ð
ð( ÷ 
ð  
ó ð 
ðP ÷ð ó ð÷ }
ñ }
÷@S
ò S
r   