§
    ~ŠtjNŒ  ã                  ó
  — d Z ddlmZ ddlZddlmZmZmZmZ ddl	m
Z
 ddlmZmZ ddlmZmZmZ ddl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j        e¦  «        Zd'd„Z  G d„ de¦  «        Z!e
 G d„ d¦  «        ¦   «         Z"e
 G d„ d¦  «        ¦   «         Z#e
 G d„ d¦  «        ¦   «         Z$dZ%dZ& G d„ d¦  «        Z' G d„ d ¦  «        Z(e
 G d!„ d"¦  «        ¦   «         Z) G d#„ d$¦  «        Z* G d%„ d&¦  «        Z+dS )(z#Data models for the sandbox client.é    )ÚannotationsN)ÚAsyncIteratorÚ	AwaitableÚCallableÚIterator)Ú	dataclass)ÚdatetimeÚtimezone)ÚTYPE_CHECKINGÚAnyÚOptional)ÚSandboxConnectionErrorÚSandboxOperationErrorÚSandboxServerReloadError)ÚAsyncSandbox)ÚSandbox)Ú_AsyncWSStreamControlÚ_WSStreamControlÚmsgÚdictÚ
command_idúOptional[str]ÚreturnÚboolc                óx   — |                       d¦  «        }||k    rdS t                               d||¦  «         dS )a×  Whether a 'started' frame proves *this* command was reattached to.

    A command and its WebSocket are separate things: the command keeps running on
    the server and the socket is only this client's attachment to it. The server
    acknowledges every successful reattachment with 'started', which for a
    command that produces no output is the only evidence it landed. One naming a
    different command is not evidence, and must not clear the reconnect budget.
    r   TzFIgnoring reconnect acknowledgement for command %r while attached to %rF)ÚgetÚloggerÚwarning)r   r   Úackeds      úW/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langsmith/sandbox/_models.pyÚ_acknowledges_reconnectr!      sK   € ð �GŠG�LÑ!Ô!€EØ�
ÒÐØˆtÝ
‡N‚NØPØØñô ð ð
 ˆ5ó    c                  ó   — e Zd ZdZdS )Ú_StreamEndedBeforeStartedaT  A command WebSocket closed before the guest sent its 'started' frame.

    Internal marker for the idempotently-retryable early close (the proxied
    tunnel was torn down gracefully mid-handshake), as distinct from a
    command-level failure. Subclasses SandboxOperationError so callers that
    catch the public type are unaffected.
    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r"   r    r$   r$   2   s   € € € € € ðð ð ð r"   r$   c                  óJ   — e Zd ZU dZded<   ded<   ded<   edd	„¦   «         Zd
S )ÚExecutionResultz+Result of executing a command in a sandbox.ÚstrÚstdoutÚstderrÚintÚ	exit_coder   r   c                ó   — | j         dk    S )z.Return True if the command exited with code 0.r   )r0   ©Úselfs    r    ÚsuccesszExecutionResult.successD   s   € ð Œ~ Ò"Ð"r"   N©r   r   )r%   r&   r'   r(   Ú__annotations__Úpropertyr4   r)   r"   r    r+   r+   <   sU   € € € € € € à5Ð5à€K€K�KØ€K€K�KØ€N€N�Nàð#ð #ð #ñ „Xð#ð #ð #r"   r+   c                  óD   — e Zd ZU dZded<   dZded<   edd
„¦   «         ZdS )Ú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_messageÚdataúdict[str, Any]r   c                ój   —  | |                      dd¦  «        |                      d¦  «        ¬¦  «        S )z/Create a ResourceStatus from API response dict.r:   Úprovisioningr;   )r:   r;   ©r   ©Úclsr<   s     r    Ú	from_dictzResourceStatus.from_dictV   s>   € ð ˆsØ—8’8˜H nÑ5Ô5ØŸ8š8Ð$4Ñ5Ô5ð
ñ 
ô 
ð 	
r"   )r<   r=   r   r9   )r%   r&   r'   r(   r6   r;   ÚclassmethodrC   r)   r"   r    r9   r9   J   sZ   € € € € € € ðð ð €K€K�KØ$(€NÐ(Ð(Ð(Ñ(àð
ð 
ð 
ñ „[ð
ð 
ð 
r"   r9   c                  óÒ   — e Zd ZU dZded<   ded<   ded<   ded<   dZd	ed
<   dZd	ed<   dZd	ed<   dZd	ed<   dZ	ded<   dZ
d	ed<   dZd	ed<   dZd	ed<   dZd	ed<   edd„¦   «         ZdS )ÚSnapshota£  Represents a sandbox snapshot.

    Snapshots are built from Docker images or captured from running sandboxes.
    They are used to create new sandboxes.

    Attributes:
        id: Unique identifier (UUID).
        name: Display name.
        status: Build status. One of "building", "ready", "failed".
        fs_capacity_bytes: Filesystem capacity in bytes.
        docker_image: Source Docker image (for build snapshots).
        image_digest: Docker image digest after pull.
        source_sandbox_id: Source sandbox (for capture snapshots).
        status_message: Human-readable details when status is "failed".
        fs_used_bytes: Actual bytes used on the filesystem.
        created_by: User or service that created the snapshot.
        registry_id: Private registry ID, if applicable.
        created_at: Timestamp when the snapshot was created.
        updated_at: Timestamp when the snapshot was last updated.
    r,   ÚidÚnamer:   r/   Úfs_capacity_bytesNr   Údocker_imageÚimage_digestÚsource_sandbox_idr;   úOptional[int]Úfs_used_bytesÚ
created_byÚregistry_idÚ
created_atÚ
updated_atr<   r=   r   c                ó(  —  | |                      dd¦  «        |                      dd¦  «        |                      dd¦  «        |                      dd¦  «        |                      d¦  «        |                      d	¦  «        |                      d
¦  «        |                      d¦  «        |                      d¦  «        |                      d¦  «        |                      d¦  «        |                      d¦  «        |                      d¦  «        ¬¦  «        S )z)Create a Snapshot from API response dict.rG   Ú rH   r:   ÚbuildingrI   r   rJ   rK   rL   r;   rN   rO   rP   rQ   rR   )rG   rH   r:   rI   rJ   rK   rL   r;   rN   rO   rP   rQ   rR   r@   rA   s     r    rC   zSnapshot.from_dict„   së   € ð ˆsØ�xŠx˜˜bÑ!Ô!Ø—’˜& "Ñ%Ô%Ø—8’8˜H jÑ1Ô1Ø"ŸhšhÐ':¸AÑ>Ô>ØŸš .Ñ1Ô1ØŸš .Ñ1Ô1Ø"ŸhšhÐ':Ñ;Ô;ØŸ8š8Ð$4Ñ5Ô5ØŸ(š( ?Ñ3Ô3Ø—x’x Ñ-Ô-ØŸš Ñ/Ô/Ø—x’x Ñ-Ô-Ø—x’x Ñ-Ô-ð
ñ 
ô 
ð 	
r"   )r<   r=   r   rF   )r%   r&   r'   r(   r6   rJ   rK   rL   r;   rN   rO   rP   rQ   rR   rD   rC   r)   r"   r    rF   rF   _   s  € € € € € € ðð ð* €G€G�GØ€I€I�IØ€K€K�KØÐÐÑØ"&€LÐ&Ð&Ð&Ñ&Ø"&€LÐ&Ð&Ð&Ñ&Ø'+ÐÐ+Ð+Ð+Ñ+Ø$(€NÐ(Ð(Ð(Ñ(Ø#'€MÐ'Ð'Ð'Ñ'Ø $€JÐ$Ð$Ð$Ñ$Ø!%€KÐ%Ð%Ð%Ñ%Ø $€JÐ$Ð$Ð$Ñ$Ø $€JÐ$Ð$Ð$Ñ$àð
ð 
ð 
ñ „[ð
ð 
ð 
r"   rF   z!X-Langsmith-Sandbox-Service-Tokené   c                  óò   — e Zd ZdZddœd%d„Zd&d„Zd'd„Zed(d„¦   «         Zed(d„¦   «         Z	ed(d„¦   «         Z
ed(d„¦   «         Zd)d*d„Zd)d+d„Zd)d+d„Zd)d+d„Zd)d+d„Zd)d+d „Zeddœd,d#„¦   «         Zd(d$„ZdS )-Ú
ServiceURLar  Authenticated URL for accessing an HTTP service running in a sandbox.

    Properties auto-refresh the token transparently when it nears expiry.
    HTTP helper methods (``.get``, ``.post``, etc.) inject the auth header
    automatically.

    When constructed by :meth:`SandboxClient.service` or
    :meth:`Sandbox.service`, the object holds an internal refresher that
    re-calls the API to obtain a fresh token before the current one expires.

    Example::

        svc = sb.service(port=3000)

        resp = svc.get("/api/data")  # token injected + auto-refreshed
        print(svc.browser_url)  # always-fresh URL
    N©Ú
_refresherÚbrowser_urlr,   Úservice_urlÚtokenÚ
expires_atrZ   ú"Optional[Callable[[], ServiceURL]]r   ÚNonec               óL   — || _         || _        || _        || _        || _        d S ©N©Ú_browser_urlÚ_service_urlÚ_tokenÚ_expires_atrZ   ©r3   r[   r\   r]   r^   rZ   s         r    Ú__init__zServiceURL.__init__³   ó.   € ð (ˆÔØ'ˆÔØˆŒØ%ˆÔØ$ˆŒˆˆr"   r   c                ó<  — | j         €dS | j                             dd¦  «        }t          j        |¦  «        }|j        € |                     t          j        ¬¦  «        }|t          j        t          j        ¦  «        z
   	                    ¦   «         }|t          k    S ©NFÚZz+00:00)Útzinfo©rZ   rg   Úreplacer	   Úfromisoformatrn   r
   ÚutcÚnowÚtotal_secondsÚ_REFRESH_MARGIN_SECONDS©r3   ÚrawÚexpiresÚ	remainings       r    Ú_should_refreshzServiceURL._should_refreshÄ   ó‚   € ØŒ?Ð"Ø�5ØÔ×&Ò& s¨HÑ5Ô5ˆÝÔ(¨Ñ-Ô-ˆØŒ>Ð!Ø—o’o­X¬\�oÑ:Ô:ˆGØ�xœ|­H¬LÑ9Ô9Ñ9×HÒHÑJÔJˆ	ØÕ3Ò3Ð3r"   c                óº   — |                       ¦   «         rF|                      ¦   «         }|j        | _        |j        | _        |j        | _        |j        | _        d S d S rb   ©rz   rZ   rd   re   rf   rg   ©r3   Úfreshs     r    Ú_maybe_refreshzServiceURL._maybe_refreshÎ   s_   € Ø×ÒÑ!Ô!ð 	1Ø—O’OÑ%Ô%ˆEØ %Ô 2ˆDÔØ %Ô 2ˆDÔØœ,ˆDŒKØ$Ô0ˆDÔÐÐð	1ð 	1r"   c                ó8   — |                       ¦   «          | j        S )ú.Return the raw JWT, refreshing if near expiry.©r€   rf   r2   s    r    r]   zServiceURL.tokenØ   s   € ð 	×ÒÑÔÐØŒ{Ðr"   c                ó8   — |                       ¦   «          | j        S )ú/Return the base URL, refreshing if near expiry.©r€   re   r2   s    r    r\   zServiceURL.service_urlÞ   ó   € ð 	×ÒÑÔÐØÔ Ð r"   c                ó8   — |                       ¦   «          | j        S )ú7Return the browser auth URL, refreshing if near expiry.©r€   rd   r2   s    r    r[   zServiceURL.browser_urlä   r‡   r"   c                ó8   — |                       ¦   «          | j        S )ú:Return the ISO 8601 expiration, refreshing if near expiry.©r€   rg   r2   s    r    r^   zServiceURL.expires_atê   s   € ð 	×ÒÑÔÐØÔÐr"   ú/ÚmethodÚpathÚkwargsr   úhttpx.Responsec                óú   — | j                              d¦  «        dz   |                     d¦  «        z   }t          |                     dd¦  «        pi ¦  «        }| j        |t          <   t          j        ||fd|i|¤ŽS )a"  Make an HTTP request to the service, injecting the auth header.

        Args:
            method: HTTP method (GET, POST, etc.).
            path: Path relative to the service URL.
            **kwargs: Forwarded to ``httpx.request``.

        Returns:
            httpx.Response.
        rŽ   ÚheadersN)	r\   ÚrstripÚlstripr   Úpopr]   Ú_AUTH_HEADERÚhttpxÚrequest)r3   r�   r�   r‘   Úurlr”   s         r    rš   zServiceURL.requestò   s{   € ð Ô×%Ò% cÑ*Ô*¨SÑ0°4·;²;¸sÑ3CÔ3CÑCˆÝ�v—z’z )¨TÑ2Ô2Ð8°bÑ9Ô9ˆØ $¤
ˆ•ÑÝŒ}˜V SÐDÐD°'ÐD¸VÐDÐDÐDr"   c                ó    —  | j         d|fi |¤ŽS )zHTTP GET to the service.ÚGET©rš   ©r3   r�   r‘   s      r    r   zServiceURL.get  ó   € àˆtŒ|˜E 4Ð2Ð2¨6Ð2Ð2Ð2r"   c                ó    —  | j         d|fi |¤ŽS )zHTTP POST to the service.ÚPOSTrž   rŸ   s      r    ÚpostzServiceURL.post  s   € àˆtŒ|˜F DÐ3Ð3¨FÐ3Ð3Ð3r"   c                ó    —  | j         d|fi |¤ŽS )zHTTP PUT to the service.ÚPUTrž   rŸ   s      r    ÚputzServiceURL.put
  r    r"   c                ó    —  | j         d|fi |¤ŽS )zHTTP PATCH to the service.ÚPATCHrž   rŸ   s      r    ÚpatchzServiceURL.patch  s   € àˆtŒ|˜G TÐ4Ð4¨VÐ4Ð4Ð4r"   c                ó    —  | j         d|fi |¤ŽS )zHTTP DELETE to the service.ÚDELETErž   rŸ   s      r    ÚdeletezServiceURL.delete  s   € àˆtŒ|˜H dÐ5Ð5¨fÐ5Ð5Ð5r"   r<   r=   c               óR   —  | |d         |d         |d         |d         |¬¦  «        S )z+Create a ServiceURL from API response dict.r[   r\   r]   r^   ©r[   r\   r]   r^   rZ   r)   ©rB   r<   rZ   s      r    rC   zServiceURL.from_dict  ó?   € ð ˆsØ˜]Ô+Ø˜]Ô+Ø�w”-Ø˜LÔ)Ø!ð
ñ 
ô 
ð 	
r"   c                ó(   — d| j         ›d| j        ›d�S )NzServiceURL(service_url=ú, expires_at=ú)©re   rg   r2   s    r    Ú__repr__zServiceURL.__repr__(  s0   € ð0 dÔ&7ð 0ð 0ØÔ*ð0ð 0ð 0ð	
r"   )r[   r,   r\   r,   r]   r,   r^   r,   rZ   r_   r   r`   r5   ©r   r`   ©r   r,   ©rŽ   ©r�   r,   r�   r,   r‘   r   r   r’   ©r�   r,   r‘   r   r   r’   )r<   r=   rZ   r_   r   rX   )r%   r&   r'   r(   ri   rz   r€   r7   r]   r\   r[   r^   rš   r   r£   r¦   r©   r¬   rD   rC   rµ   r)   r"   r    rX   rX       sÇ  € € € € € ðð ð2 :>ð%ð %ð %ð %ð %ð %ð"4ð 4ð 4ð 4ð1ð 1ð 1ð 1ð ðð ð ñ „Xðð
 ð!ð !ð !ñ „Xð!ð
 ð!ð !ð !ñ „Xð!ð
 ð ð  ð  ñ „Xð ðEð Eð Eð Eð Eð 3ð 3ð 3ð 3ð 3ð4ð 4ð 4ð 4ð 4ð3ð 3ð 3ð 3ð 3ð5ð 5ð 5ð 5ð 5ð6ð 6ð 6ð 6ð 6ð ð
 :>ð	
ð 
ð 
ð 
ð 
ñ „[ð
ð
ð 
ð 
ð 
ð 
ð 
r"   rX   c                  ó  — e Zd ZdZddœd)d„Zd*d„Zd+d„Zd,d„Zd,d„Zd,d„Z	d,d„Z
ed,d„¦   «         Zed,d„¦   «         Zed,d„¦   «         Zed,d„¦   «         Z	 d-d.d„Zd-d/d „Zd-d/d!„Zd-d/d"„Zd-d/d#„Zd-d/d$„Zeddœd0d'„¦   «         Zd,d(„ZdS )1ÚAsyncServiceURLaR  Async variant of :class:`ServiceURL` with auto-refreshing token.

    Properties and HTTP helpers are async. Use with
    :meth:`AsyncSandboxClient.service` or :meth:`AsyncSandbox.service`.

    Example::

        svc = await sb.service(port=3000)

        resp = await svc.get("/api/data")
        print(await svc.get_browser_url())
    NrY   r[   r,   r\   r]   r^   rZ   ú2Optional[Callable[[], Awaitable[AsyncServiceURL]]]r   r`   c               óL   — || _         || _        || _        || _        || _        d S rb   rc   rh   s         r    ri   zAsyncServiceURL.__init__=  rj   r"   r   c                ó<  — | j         €dS | j                             dd¦  «        }t          j        |¦  «        }|j        € |                     t          j        ¬¦  «        }|t          j        t          j        ¦  «        z
   	                    ¦   «         }|t          k    S rl   ro   rv   s       r    rz   zAsyncServiceURL._should_refreshN  r{   r"   c              ƒ  óÊ   K  — |                       ¦   «         rL|                      ¦   «         ƒ d {V —†}|j        | _        |j        | _        |j        | _        |j        | _        d S d S rb   r}   r~   s     r    r€   zAsyncServiceURL._maybe_refreshX  su   è è € Ø×ÒÑ!Ô!ð 	1ØŸ/š/Ñ+Ô+Ð+Ð+Ð+Ð+Ð+Ð+ˆEØ %Ô 2ˆDÔØ %Ô 2ˆDÔØœ,ˆDŒKØ$Ô0ˆDÔÐÐð	1ð 	1r"   c              ƒ  óH   K  — |                       ¦   «         ƒ d{V —† | j        S )r‚   Nrƒ   r2   s    r    Ú	get_tokenzAsyncServiceURL.get_tokenb  s2   è è € à×!Ò!Ñ#Ô#Ð#Ð#Ð#Ð#Ð#Ð#Ð#ØŒ{Ðr"   c              ƒ  óH   K  — |                       ¦   «         ƒ d{V —† | j        S )r…   Nr†   r2   s    r    Úget_service_urlzAsyncServiceURL.get_service_urlg  ó3   è è € à×!Ò!Ñ#Ô#Ð#Ð#Ð#Ð#Ð#Ð#Ð#ØÔ Ð r"   c              ƒ  óH   K  — |                       ¦   «         ƒ d{V —† | j        S )r‰   NrŠ   r2   s    r    Úget_browser_urlzAsyncServiceURL.get_browser_urll  rÅ   r"   c              ƒ  óH   K  — |                       ¦   «         ƒ d{V —† | j        S )rŒ   Nr�   r2   s    r    Úget_expires_atzAsyncServiceURL.get_expires_atq  s3   è è € à×!Ò!Ñ#Ô#Ð#Ð#Ð#Ð#Ð#Ð#Ð#ØÔÐr"   c                ó   — | j         S )z&Return the raw JWT without refreshing.)rf   r2   s    r    r]   zAsyncServiceURL.tokenx  s   € ð Œ{Ðr"   c                ó   — | j         S )z'Return the base URL without refreshing.)re   r2   s    r    r\   zAsyncServiceURL.service_url}  ó   € ð Ô Ð r"   c                ó   — | j         S )z/Return the browser auth URL without refreshing.)rd   r2   s    r    r[   zAsyncServiceURL.browser_url‚  rÌ   r"   c                ó   — | j         S )z3Return the expiration timestamp without refreshing.)rg   r2   s    r    r^   zAsyncServiceURL.expires_at‡  ó   € ð ÔÐr"   rŽ   r�   r�   r‘   r   r’   c              ‹  óÌ  K  — |                       ¦   «         ƒ d{V —†                     d¦  «        dz   |                     d¦  «        z   }t          |                     dd¦  «        pi ¦  «        }|                      ¦   «         ƒ d{V —†|t          <   t          j        ¦   «         4 ƒd{V —†} |j	        ||fd|i|¤Žƒ d{V —†cddd¦  «        ƒd{V —† S # 1 ƒd{V —†swxY w Y   dS )a4  Make an async HTTP request to the service, injecting the auth header.

        Args:
            method: HTTP method (GET, POST, etc.).
            path: Path relative to the service URL.
            **kwargs: Forwarded to ``httpx.AsyncClient.request``.

        Returns:
            httpx.Response.
        NrŽ   r”   )
rÄ   r•   r–   r   r—   rÂ   r˜   r™   ÚAsyncClientrš   )r3   r�   r�   r‘   r›   r”   Úclients          r    rš   zAsyncServiceURL.requestŽ  s´  è è € ð ×)Ò)Ñ+Ô+Ð+Ð+Ð+Ð+Ð+Ð+×3Ò3°CÑ8Ô8¸3Ñ>ÀÇÂÈSÑAQÔAQÑQˆÝ�v—z’z )¨TÑ2Ô2Ð8°bÑ9Ô9ˆØ&*§n¢nÑ&6Ô&6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6ˆ•ÑÝÔ$Ñ&Ô&ð 	Pð 	Pð 	Pð 	Pð 	Pð 	Pð 	P¨&Ø'˜œ¨°ÐOÐO¸WÐOÈÐOÐOÐOÐOÐOÐOÐOÐOð	Pð 	Pð 	Pð 	Pñ 	Pô 	Pð 	Pð 	Pð 	Pð 	Pð 	Pð 	Pð 	Pð 	Pð 	Pð 	Pð 	Pð 	Pð 	Pð 	Pð 	Pð 	Pð 	Pð 	Pøøøð 	Pð 	Pð 	Pð 	Pð 	Pð 	Ps   Â)CÃ
CÃ Cc              ‹  ó0   K  —  | j         d|fi |¤Žƒ d{V —†S )zAsync HTTP GET to the service.r�   Nrž   rŸ   s      r    r   zAsyncServiceURL.get¡  ó4   è è € à!�T”\ %¨Ð8Ð8°Ð8Ð8Ð8Ð8Ð8Ð8Ð8Ð8Ð8r"   c              ‹  ó0   K  —  | j         d|fi |¤Žƒ d{V —†S )zAsync HTTP POST to the service.r¢   Nrž   rŸ   s      r    r£   zAsyncServiceURL.post¥  s4   è è € à!�T”\ &¨$Ð9Ð9°&Ð9Ð9Ð9Ð9Ð9Ð9Ð9Ð9Ð9r"   c              ‹  ó0   K  —  | j         d|fi |¤Žƒ d{V —†S )zAsync HTTP PUT to the service.r¥   Nrž   rŸ   s      r    r¦   zAsyncServiceURL.put©  rÔ   r"   c              ‹  ó0   K  —  | j         d|fi |¤Žƒ d{V —†S )z Async HTTP PATCH to the service.r¨   Nrž   rŸ   s      r    r©   zAsyncServiceURL.patch­  s4   è è € à!�T”\ '¨4Ð:Ð:°6Ð:Ð:Ð:Ð:Ð:Ð:Ð:Ð:Ð:r"   c              ‹  ó0   K  —  | j         d|fi |¤Žƒ d{V —†S )z!Async HTTP DELETE to the service.r«   Nrž   rŸ   s      r    r¬   zAsyncServiceURL.delete±  s4   è è € à!�T”\ (¨DÐ;Ð;°FÐ;Ð;Ð;Ð;Ð;Ð;Ð;Ð;Ð;r"   r<   r=   c               óR   —  | |d         |d         |d         |d         |¬¦  «        S )z1Create an AsyncServiceURL from API response dict.r[   r\   r]   r^   r®   r)   r¯   s      r    rC   zAsyncServiceURL.from_dict·  r°   r"   c                ó(   — d| j         ›d| j        ›d�S )NzAsyncServiceURL(service_url=r²   r³   r´   r2   s    r    rµ   zAsyncServiceURL.__repr__Ç  s0   € ð0¨4Ô+<ð 0ð 0ØÔ*ð0ð 0ð 0ð	
r"   )r[   r,   r\   r,   r]   r,   r^   r,   rZ   r½   r   r`   r5   r¶   r·   r¸   r¹   rº   )r<   r=   rZ   r½   r   r¼   )r%   r&   r'   r(   ri   rz   r€   rÂ   rÄ   rÇ   rÉ   r7   r]   r\   r[   r^   rš   r   r£   r¦   r©   r¬   rD   rC   rµ   r)   r"   r    r¼   r¼   /  s   € € € € € ðð ð( JNð%ð %ð %ð %ð %ð %ð"4ð 4ð 4ð 4ð1ð 1ð 1ð 1ðð ð ð ð
!ð !ð !ð !ð
!ð !ð !ð !ð
 ð  ð  ð  ð ðð ð ñ „Xðð ð!ð !ð !ñ „Xð!ð ð!ð !ð !ñ „Xð!ð ð ð  ð  ñ „Xð ð (+ðPð Pð Pð Pð Pð&9ð 9ð 9ð 9ð 9ð:ð :ð :ð :ð :ð9ð 9ð 9ð 9ð 9ð;ð ;ð ;ð ;ð ;ð<ð <ð <ð <ð <ð ð
 JNð	
ð 
ð 
ð 
ð 
ñ „[ð
ð
ð 
ð 
ð 
ð 
ð 
r"   r¼   c                  ó2   — e Zd ZU dZded<   ded<   ded<   dS )Ú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/   ÚoffsetN)r%   r&   r'   r(   r6   r)   r"   r    rÜ   rÜ   Ó  s7   € € € € € € ðð ð €K€K�KØ€I€I�IØ€K€K�K€K€Kr"   rÜ   c                  óÜ   — e Zd ZdZdZdZdZdd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d0d&„Ze	d1d'„¦   «         Ze	d1d(„¦   «         Zd2d)„ZdS )3ÚCommandHandleu  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. A reconnect stream's ``"started"`` message is the server's
      acknowledgement that the reattachment landed, consumed while iterating to
      clear the reconnect budget â€” the only such signal for a command that
      emits no output.

    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}")
    é   ç      à?ç       @rT   r   N©r   Ústdout_offsetÚstderr_offsetÚ	on_stdoutÚ	on_stderrÚmessage_streamúIterator[dict]ÚcontrolúOptional[_WSStreamControl]Úsandboxr   r   r,   rå   r/   ræ   rç   úOptional[Callable[[str], Any]]rè   r   r`   c               ó  — || _         || _        || _        || _        || _        d | _        d | _        d | _        g | _        g | _	        d| _
        || _        || _        d| _        |r	|| _        d S |                      ¦   «          d S )NFr   )Ú_streamÚ_controlÚ_sandboxÚ
_on_stdoutÚ
_on_stderrÚ_command_idÚ_pidÚ_resultÚ_stdout_partsÚ_stderr_partsÚ
_exhaustedÚ_last_stdout_offsetÚ_last_stderr_offsetÚ_reconnect_attemptsÚ_consume_started©	r3   ré   rë   rí   r   rå   ræ   rç   rè   s	            r    ri   zCommandHandle.__init__  sœ   € ð &ˆŒØˆŒØˆŒØ#ˆŒØ#ˆŒØ*.ˆÔØ#'ˆŒ	Ø26ˆŒØ(*ˆÔØ(*ˆÔØˆŒØ#0ˆÔ Ø#0ˆÔ Ø#$ˆÔ ð
 ð 	$Ø)ˆDÔÐÐà×!Ò!Ñ#Ô#Ð#Ð#Ð#r"   c                óZ  — 	 t          | j        ¦  «        }n# t          $ r t          dd¬¦  «        ‚w xY w|                     d¦  «        dk    r(t          d|                     d¦  «        › d�d¬¦  «        ‚|                     d¦  «        | _        |                     d	¦  «        | _        d
S )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 'ú'r   ÚpidN)Únextrð   ÚStopIterationr$   r   r   rõ   rö   ©r3   Ú	first_msgs     r    rþ   zCommandHandle._consume_started/  sÊ   € ð	Ý˜Tœ\Ñ*Ô*ˆIˆIøÝð 	ð 	ð 	Ý+Ø?Ø#ðñ ô ð ð	øøøð
 �=Š=˜Ñ Ô  IÒ-Ð-Ý'ØL°I·M²MÀ&Ñ4IÔ4IÐLÐLÐLØ#ðñ ô ð ð %Ÿ=š=¨Ñ6Ô6ˆÔØ—M’M %Ñ(Ô(ˆŒ	ˆ	ˆ	s   ‚ —3r   c                ó   — | j         S )z=The server-assigned command ID. Available after construction.©rõ   r2   s    r    r   zCommandHandle.command_idF  rÏ   r"   rM   c                ó   — | j         S )z<The process ID on the sandbox. Available after construction.©rö   r2   s    r    r	  zCommandHandle.pidK  ó   € ð ŒyÐr"   r+   c                óX   — | 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.
        Nú)Command stream ended without exit messager  r  ©r÷   r   ©r3   Ú_s     r    ÚresultzCommandHandle.resultP  sM   € ð Œ<ÐØð ð �ØØŒ<ÐÝ'Ø;Ø#ðñ ô ð ð Œ|Ðr"   úIterator[OutputChunk]c           	   #  óp  K  — | j         rdS | j        D �]}|                     d¦  «        }|dk    rt          || j        ¦  «        rd| _        Œ;|dv rxt          ||d         |                     dd¦  «        ¬¦  «        }|d	k    r!| j                             |d         ¦  «         n | j	                             |d         ¦  «         |V — Œ·|d
k    rWt          d                     | j        ¦  «        d                     | j	        ¦  «        |d         ¬¦  «        | _        d| _          dS �Œt          d¦  «        ‚©zBIterate over output chunks from the current stream (no reconnect).Nr  r  r   )r-   r.   r<   rÞ   )rÝ   r<   rÞ   r-   ÚexitrT   r0   )r-   r.   r0   Tr  )rú   rð   r   r!   rõ   rý   rÜ   rø   Úappendrù   r+   Újoinr÷   r   ©r3   r   Úmsg_typeÚchunks       r    Ú_iter_streamzCommandHandle._iter_streama  s]  è è € àŒ?ð 	ØˆFØ”<ð 	ñ 	ˆCØ—w’w˜v‘”ˆHØ˜9Ò$Ð$Ý*¨3°Ô0@ÑAÔAð 1Ø/0�DÔ,øØÐ1Ð1Ð1Ý#Ø#Ø˜VœØŸ7š7 8¨QÑ/Ô/ðñ ô �ð
 ˜xÒ'Ð'ØÔ&×-Ò-¨c°&¬kÑ:Ô:Ð:Ð:àÔ&×-Ò-¨c°&¬kÑ:Ô:Ð:Ø����Ø˜VÒ#Ð#Ý.ØŸ7š7 4Ô#5Ñ6Ô6ØŸ7š7 4Ô#5Ñ6Ô6Ø! +Ô.ð ñ  ô  �”ð
 #'�”Ø��ñ $õ %Ð%PÑQÔQÐQr"   c              #  óð  K  — ddl }d| _        	 	 |                      ¦   «         D ]Ã}d| _        |j        dk    rV|j        t          |j                             d¦  «        ¦  «        z   | _        | j	        �|  	                    |j        ¦  «         nU|j        t          |j                             d¦  «        ¦  «        z   | _
        | j        �|                      |j        ¦  «         |V — ŒÄdS # t          $ rÿ}| j        r| j        j        r‚ | xj        dz  c_        | j        | j        k    rt          d| j        › d�¦  «        |‚t!          |t"          ¦  «        }|s=t%          | j        d	| j        dz
  z  z  | j        ¦  «        }|                     |¦  «         | j        €J ‚| j                             | j        | j        | j
        ¬
¦  «        }|j        | _        |j        | _        d| _        Y d}~nd}~ww xY 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   NTr-   úutf-8é   ú"Failed to reattach to the command ú times in succession, giving upé   ©rå   ræ   F)Útimerý   r"  rÝ   rÞ   Úlenr<   Úencoderû   ró   rü   rô   r   rñ   ÚkilledÚMAX_AUTO_RECONNECTSÚ
isinstancer   ÚminÚ_BACKOFF_BASEÚ_BACKOFF_MAXÚsleeprõ   rò   Ú	reconnectrð   rú   )r3   r*  r!  ÚeÚis_hot_reloadÚdelayÚ
new_handles          r    Ú__iter__zCommandHandle.__iter__  sR  è è € ð 	ˆˆˆà#$ˆÔ ð/	(ð.(Ø!×.Ò.Ñ0Ô0ð  ð  �EØ/0�DÔ,Ø”| xÒ/Ð/Ø38´<Å#Ø!œJ×-Ò-¨gÑ6Ô6ñCô Cñ 4˜Ô0ð  œ?Ð6Ø ŸOšO¨E¬JÑ7Ô7Ð7øà38´<Å#Ø!œJ×-Ò-¨gÑ6Ô6ñCô Cñ 4˜Ô0ð  œ?Ð6Ø ŸOšO¨E¬JÑ7Ô7Ð7Ø�K�K�K�KØ�øå)ð (ð (ð (Ø”=ð  T¤]Ô%9ð ØàÐ(Ô(¨AÑ-Ð(Ô(ØÔ+¨dÔ.FÒFÐFÝ0ð%ØÔ3ð%ð %ð %ñô ð ð	õ !+¨1Õ.FÑ GÔ G�Ø$ð &ÝØÔ*¨a°DÔ4LÈqÑ4PÑ.QÑRØÔ)ñô �Eð —J’J˜uÑ%Ô%Ð%àÔ'Ð3Ð3Ð3Ø!œ]×4Ò4ØÔ$Ø"&Ô":Ø"&Ô":ð 5ñ ô �
ð
  *Ô1�”Ø *Ô 3�”Ø"'�”�����øøøøð9(øøøñ'/	(s   �CC* Ã*
G3Ã4C5G.Ç.G3c                óJ   — | j         r| j                              ¦   «          dS dS )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©rñ   Ú	send_killr2   s    r    ÚkillzCommandHandle.kill»  s2   € ð Œ=ð 	&ØŒM×#Ò#Ñ%Ô%Ð%Ð%Ð%ð	&ð 	&r"   r<   c                óL   — | j         r| j                              |¦  «         dS dS )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©rñ   Ú
send_input©r3   r<   s     r    r@  zCommandHandle.send_inputÇ  s4   € ð Œ=ð 	+ØŒM×$Ò$ TÑ*Ô*Ð*Ð*Ð*ð	+ð 	+r"   c                ó   — | j         S ©z8Last known stdout byte offset (for manual reconnection).©rû   r2   s    r    Úlast_stdout_offsetz CommandHandle.last_stdout_offsetÓ  ó   € ð Ô'Ð'r"   c                ó   — | j         S ©z8Last known stderr byte offset (for manual reconnection).©rü   r2   s    r    Úlast_stderr_offsetz CommandHandle.last_stderr_offsetØ  rF  r"   c                ól   — | 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.
        Nr)  ©rõ   rò   r4  rû   rü   r2   s    r    r4  zCommandHandle.reconnectÝ  sD   € ð ÔÐ+Ð+Ð+ØŒ}×&Ò&ØÔØÔ2ØÔ2ð 'ñ 
ô 
ð 	
r"   )ré   rê   rë   rì   rí   r   r   r,   rå   r/   ræ   r/   rç   rî   rè   rî   r   r`   r¶   ©r   r   ©r   rM   ©r   r+   )r   r  ©r<   r,   r   r`   ©r   r/   )r   rà   )r%   r&   r'   r(   r.  r1  r2  ri   rþ   r7   r   r	  r  r"  r9  r=  r@  rE  rJ  r4  r)   r"   r    rà   rà   ä  s~  € € € € € ð!ð !ðF ÐØ€MØ€Lð ØØØ48Ø48ð!$ð !$ð !$ð !$ð !$ð !$ðF)ð )ð )ð )ð. ð ð  ð  ñ „Xð ð ðð ð ñ „Xðð ðð ð ñ „Xðð Rð Rð Rð Rð<:(ð :(ð :(ð :(ðx
&ð 
&ð 
&ð 
&ð
+ð 
+ð 
+ð 
+ð ð(ð (ð (ñ „Xð(ð ð(ð (ð (ñ „Xð(ð
ð 
ð 
ð 
ð 
ð 
r"   rà   c                  óÜ   — e Zd ZdZdZdZdZdd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d0d&„Ze	d1d'„¦   «         Ze	d1d(„¦   «         Zd2d)„ZdS )3ÚAsyncCommandHandleue  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. A reconnect stream's ``"started"`` message is the server's
      acknowledgement that the reattachment landed, consumed while iterating to
      clear the reconnect budget â€” the only such signal for a command that
      emits no output.

    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}")
    rá   râ   rã   rT   r   Nrä   ré   úAsyncIterator[dict]rë   úOptional[_AsyncWSStreamControl]rí   r   r   r,   rå   r/   ræ   rç   rî   rè   r   r`   c               óü   — || _         || _        || _        || _        || _        d | _        d | _        d | _        g | _        g | _	        d| _
        || _        || _        d| _        |r|| _        d| _        d S d| _        d S )NFr   T)rð   rñ   rò   ró   rô   rõ   rö   r÷   rø   rù   rú   rû   rü   rý   Ú_startedrÿ   s	            r    ri   zAsyncCommandHandle.__init__  s”   € ð &ˆŒØˆŒØˆŒØ#ˆŒØ#ˆŒØ*.ˆÔØ#'ˆŒ	Ø26ˆŒØ(*ˆÔØ(*ˆÔØˆŒØ#0ˆÔ Ø#0ˆÔ Ø#$ˆÔ ð
 ð 	"Ø)ˆDÔØ ˆDŒMˆMˆMà!ˆDŒMˆMˆMr"   c              ƒ  ó”  K  — | j         rdS 	 | j                             ¦   «         ƒ d{V —†}n# t          $ r t	          dd¬¦  «        ‚w xY w|                     d¦  «        dk    r(t          d|                     d¦  «        › d�d¬¦  «        ‚|                     d	¦  «        | _        |                     d
¦  «        | _        d| _         dS )z:Read the 'started' message to populate command_id and pid.Nr  r  r  r  r  r  r  r   r	  T)	rW  rð   Ú	__anext__ÚStopAsyncIterationr$   r   r   rõ   rö   r  s     r    Ú_ensure_startedz"AsyncCommandHandle._ensure_started<  sú   è è € àŒ=ð 	ØˆFð	Ø"œl×4Ò4Ñ6Ô6Ð6Ð6Ð6Ð6Ð6Ð6ˆIˆIøÝ!ð 	ð 	ð 	Ý+Ø?Ø#ðñ ô ð ð	øøøð
 �=Š=˜Ñ Ô  IÒ-Ð-Ý'ØL°I·M²MÀ&Ñ4IÔ4IÐLÐLÐLØ#ðñ ô ð ð %Ÿ=š=¨Ñ6Ô6ˆÔØ—M’M %Ñ(Ô(ˆŒ	ØˆŒˆˆs	   �- ­A	r   c                ó   — | j         S )z@The server-assigned command ID. Available after _ensure_started.r  r2   s    r    r   zAsyncCommandHandle.command_idP  rÏ   r"   rM   c                ó   — | j         S )z?The process ID on the sandbox. Available after _ensure_started.r  r2   s    r    r	  zAsyncCommandHandle.pidU  r  r"   r+   c              ƒ  óh   K  — | j         €| 2 3 d{V —†}Œ6 | j         €t          dd¬¦  «        ‚| j         S )z&The final execution result. Awaitable.Nr  r  r  r  r  s     r    r  zAsyncCommandHandle.resultZ  so   è è € ð Œ<ÐØð ð ð ð ð ð ð �aØð  àŒ<ÐÝ'Ø;Ø#ðñ ô ð ð Œ|Ðs   ŒúAsyncIterator[OutputChunk]c           	    ó°  K  — |                       ¦   «         ƒ d{V —† | j        rdS | j        2 3 d{V —†}|                     d¦  «        }|dk    rt	          || j        ¦  «        rd| _        Œ?|dv ryt          ||d         |                     dd¦  «        ¬¦  «        }|d	k    r!| j         	                    |d         ¦  «         n | j
         	                    |d         ¦  «         |W V — Œ¼|d
k    rWt          d                     | j        ¦  «        d                     | j
        ¦  «        |d         ¬¦  «        | _        d| _         dS �Œ6 t          d¦  «        ‚r  )r[  rú   rð   r   r!   rõ   rý   rÜ   rø   r  rù   r+   r  r÷   r   r  s       r    Ú_aiter_streamz AsyncCommandHandle._aiter_streamg  s¡  è è € à×"Ò"Ñ$Ô$Ð$Ð$Ð$Ð$Ð$Ð$Ð$ØŒ?ð 	ØˆFØœð 	ð 	ð 	ð 	ð 	ð 	ð 	�#Ø—w’w˜v‘”ˆHØ˜9Ò$Ð$Ý*¨3°Ô0@ÑAÔAð 1Ø/0�DÔ,øØÐ1Ð1Ð1Ý#Ø#Ø˜VœØŸ7š7 8¨QÑ/Ô/ðñ ô �ð
 ˜xÒ'Ð'ØÔ&×-Ò-¨c°&¬kÑ:Ô:Ð:Ð:àÔ&×-Ò-¨c°&¬kÑ:Ô:Ð:Ø�����Ø˜VÒ#Ð#Ý.ØŸ7š7 4Ô#5Ñ6Ô6ØŸ7š7 4Ô#5Ñ6Ô6Ø! +Ô.ð ñ  ô  �”ð
 #'�”Ø��ñ $ð! &õ0 %Ð%PÑQÔQÐQs   ­Ec               ó  K  — ddl }d| _        	 	 |                      ¦   «         2 3 d{V —†}d| _        |j        dk    rV|j        t          |j                             d¦  «        ¦  «        z   | _        | j	        �|  	                    |j        ¦  «         nU|j        t          |j                             d¦  «        ¦  «        z   | _
        | j        �|                      |j        ¦  «         |W V — ŒÊ6 dS # t          $ �r}| j        r| j        j        r‚ | xj        dz  c_        | j        | j        k    rt          d| j        › d�¦  «        |‚t!          |t"          ¦  «        }|sCt%          | j        d	| j        dz
  z  z  | j        ¦  «        }|                     |¦  «        ƒ d{V —† | j        €J ‚| j                             | j        | j        | j
        ¬
¦  «        ƒ d{V —†}|j        | _        |j        | _        d| _        Y d}~nd}~ww xY w�Œý)z6Async iterate with auto-reconnect on transient errors.r   NTr-   r$  r%  r&  r'  r(  r)  F)Úasynciorý   ra  rÝ   rÞ   r+  r<   r,  rû   ró   rü   rô   r   rñ   r-  r.  r/  r   r0  r1  r2  r3  rõ   rò   r4  rð   rú   )r3   rc  r!  r5  r6  r7  r8  s          r    Ú	__aiter__zAsyncCommandHandle.__aiter__†  s¢  è è € àˆˆˆà#$ˆÔ ð/	(ð.(Ø#'×#5Ò#5Ñ#7Ô#7ð  ð  ð  ð  ð  ð  ð  ˜%Ø/0�DÔ,Ø”| xÒ/Ð/Ø38´<Å#Ø!œJ×-Ò-¨gÑ6Ô6ñCô Cñ 4˜Ô0ð  œ?Ð6Ø ŸOšO¨E¬JÑ7Ô7Ð7øà38´<Å#Ø!œJ×-Ò-¨gÑ6Ô6ñCô Cñ 4˜Ô0ð  œ?Ð6Ø ŸOšO¨E¬JÑ7Ô7Ð7Ø�K�K�K�K�Kð $8ð �øå)ð (ñ (ð (Ø”=ð  T¤]Ô%9ð ØàÐ(Ô(¨AÑ-Ð(Ô(ØÔ+¨dÔ.FÒFÐFÝ0ð%ØÔ3ð%ð %ð %ñô ð ð	õ !+¨1Õ.FÑ GÔ G�Ø$ð /ÝØÔ*¨a°DÔ4LÈqÑ4PÑ.QÑRØÔ)ñô �Eð "Ÿ-š-¨Ñ.Ô.Ð.Ð.Ð.Ð.Ð.Ð.Ð.àÔ'Ð3Ð3Ð3Ø#'¤=×#:Ò#:ØÔ$Ø"&Ô":Ø"&Ô":ð $;ñ $ô $ð ð ð ð ð ð �
ð
  *Ô1�”Ø *Ô 3�”Ø"'�”�����øøøøð9(øøøñ'/	(s#   �C1 ¤C.ªCC1 Ã1HÃ<DHÈHc              ƒ  óZ   K  — | j         r!| j                              ¦   «         ƒ d{V —† dS dS )z*Send a kill signal to the running command.Nr;  r2   s    r    r=  zAsyncCommandHandle.kill¼  sF   è è € àŒ=ð 	,Ø”-×)Ò)Ñ+Ô+Ð+Ð+Ð+Ð+Ð+Ð+Ð+Ð+Ð+ð	,ð 	,r"   r<   c              ƒ  ó\   K  — | j         r"| j                              |¦  «        ƒ d{V —† dS dS )z"Write data to the command's stdin.Nr?  rA  s     r    r@  zAsyncCommandHandle.send_inputÁ  sH   è è € àŒ=ð 	1Ø”-×*Ò*¨4Ñ0Ô0Ð0Ð0Ð0Ð0Ð0Ð0Ð0Ð0Ð0ð	1ð 	1r"   c                ó   — | j         S rC  rD  r2   s    r    rE  z%AsyncCommandHandle.last_stdout_offsetÆ  rF  r"   c                ó   — | j         S rH  rI  r2   s    r    rJ  z%AsyncCommandHandle.last_stderr_offsetË  rF  r"   c              ƒ  ó|   K  — | j         €J ‚| j                             | j         | j        | j        ¬¦  «        ƒ d{V —†S )z6Reconnect to this command from the last known offsets.Nr)  rL  r2   s    r    r4  zAsyncCommandHandle.reconnectÐ  sd   è è € àÔÐ+Ð+Ð+Ø”]×,Ò,ØÔØÔ2ØÔ2ð -ñ 
ô 
ð 
ð 
ð 
ð 
ð 
ð 
ð 	
r"   )ré   rT  rë   rU  rí   r   r   r,   rå   r/   ræ   r/   rç   rî   rè   rî   r   r`   r¶   rM  rN  rO  )r   r_  rP  rQ  )r   rS  )r%   r&   r'   r(   r.  r1  r2  ri   r[  r7   r   r	  r  ra  rd  r=  r@  rE  rJ  r4  r)   r"   r    rS  rS  ô  s}  € € € € € ðð ð> ÐØ€MØ€Lð ØØØ48Ø48ð""ð ""ð ""ð ""ð ""ð ""ðHð ð ð ð( ð ð  ð  ñ „Xð ð ðð ð ñ „Xðð ð
ð 
ð 
ñ „Xð
ðRð Rð Rð Rð>4(ð 4(ð 4(ð 4(ðl,ð ,ð ,ð ,ð
1ð 1ð 1ð 1ð
 ð(ð (ð (ñ „Xð(ð ð(ð (ð (ñ „Xð(ð
ð 
ð 
ð 
ð 
ð 
r"   rS  )r   r   r   r   r   r   ),r(   Ú
__future__r   ÚloggingÚcollections.abcr   r   r   r   Údataclassesr   r	   r
   Útypingr   r   r   r™   Úlangsmith.sandbox._exceptionsr   r   r   Ú langsmith.sandbox._async_sandboxr   Úlangsmith.sandbox._sandboxr   Úlangsmith.sandbox._ws_executer   r   Ú	getLoggerr%   r   r!   r$   r+   r9   rF   r˜   ru   rX   r¼   rÜ   rà   rS  r)   r"   r    ú<module>rt     s#  ðØ )Ð )à "Ð "Ð "Ð "Ð "Ð "à €€€Ø HÐ HÐ HÐ HÐ HÐ HÐ HÐ HÐ HÐ HÐ HÐ HØ !Ð !Ð !Ð !Ð !Ð !Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /à €€€ðð ð ð ð ð ð ð ð ð ð ð Ø=Ð=Ð=Ð=Ð=Ð=Ø2Ð2Ð2Ð2Ð2Ð2ðð ð ð ð ð ð ð ð
 
ˆÔ	˜8Ñ	$Ô	$€ðð ð ð ð(ð ð ð ð Ð 5ñ ô ð ð ð
#ð 
#ð 
#ð 
#ð 
#ñ 
#ô 
#ñ „ð
#ð ð
ð 
ð 
ð 
ð 
ñ 
ô 
ñ „ð
ð( ð5
ð 5
ð 5
ð 5
ð 5
ñ 5
ô 5
ñ „ð5
ðx 3€ØÐ ðL
ð L
ð L
ð L
ð L
ñ L
ô L
ð L
ð^\
ð \
ð \
ð \
ð \
ñ \
ô \
ð \
ðH ðð ð ð ð ñ ô ñ „ðð M
ð M
ð M
ð M
ð M
ñ M
ô M
ð M
ð`c
ð c
ð c
ð c
ð c
ñ c
ô c
ð c
ð c
ð c
r"   