Ë
    ³ŒjÜ½  ã                  ól  — d Z ddlmZ ddlZddlZddlZddlZddlmZm	Z	 ddl
mZmZmZ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mZmZmZmZmZ dd
lmZm Z m!Z!m"Z"m#Z# ddl$m%Z%m&Z&m'Z'm(Z(m)Z) ddl*m+Z+m,Z,m-Z-m.Z.m/Z/ ddl0m1Z1m2Z2 ddl3m4Z4 ddl5m6Z6 erddl7m8Z8 dd„Z9dd„Z:ee	e;e;f      Z< G d„ d«      Z=y)zFAsync SandboxClient class for interacting with the sandbox server API.é    )ÚannotationsN)ÚCallableÚMapping)ÚTYPE_CHECKINGÚAnyÚOptionalÚUnion)Úutils)ÚAsyncLangsmith)ÚAsyncSandbox)ÚSandboxClientÚ_box_urlÚ_make_docker_context_tarÚ_make_dockerfile_build_commandÚ_quote_path_segmentÚ_resolve_dockerfile_context)ÚResourceCreationErrorÚResourceNameConflictErrorÚResourceNotFoundErrorÚResourceTimeoutErrorÚSandboxAPIError)Úhandle_client_http_errorÚhandle_sandbox_creation_errorÚmerge_headersÚvalidate_service_paramsÚvalidate_ttl)ÚAsyncServiceURLÚDownloadContentDispositionÚDownloadURLÚResourceStatusÚSnapshot)ÚSandboxMountConfigÚ"validate_mount_config_proxy_config)ÚSandboxProxyConfig)ÚAsyncRetryTransport)ÚAsyncRegistriesResourcec                 óX   — t        j                  dd¬«      } | j                  d«      › d�S )z†Get the default sandbox API endpoint from environment.

    Derives the endpoint from LANGSMITH_ENDPOINT (or LANGCHAIN_ENDPOINT).
    ÚENDPOINTzhttps://api.smith.langchain.com)ÚdefaultÚ/ú/v2/sandboxes)Úls_utilsÚget_env_varÚrstrip)Úbases    úi/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langsmith/sandbox/_async_client.pyÚ_get_default_api_endpointr1   ;   s.   € ô
 ×Ñ 
Ð4UÔV€DØ�k‰k˜#ÓÐ˜}Ð-Ð-ó    c                 ó,   — t        j                  d«      S )z)Get the default API key from environment.ÚAPI_KEY)r,   r-   © r2   r0   Ú_get_default_api_keyr6   D   s   € ä×Ñ 	Ó*Ð*r2   c                  ó   — e Zd ZdZddddddœ	 	 	 	 	 	 	 	 	 d9d„Z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:d„Z	 dAddddddddddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dBd„Z	 dAdddddddddddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dCd„Zddœ	 	 	 	 	 dDd„Zddœ	 	 	 dEd„Zdddddœ	 	 	 	 	 	 	 	 	 	 	 dFd„Zddœ	 	 	 	 	 dGd„Zddœ	 	 	 	 	 dHd„Zdddœ	 	 	 	 	 	 	 	 	 dId „Zddddd!œ	 	 	 	 	 	 	 	 	 	 	 	 	 dJd"„Zd#d$dd%œ	 	 	 	 	 	 	 	 	 dKd&„Zd#dd'œ	 	 	 	 	 	 	 dLd(„ZddœdGd)„Zdd*dd+œ	 	 	 	 	 	 	 	 	 	 	 	 	 dMd,„Z	 dAd-dddddd*dd.œ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dNd/„Zddd*dd0œ	 	 	 	 	 	 	 	 	 	 	 	 	 dOd1„Zddœ	 	 	 	 	 dPd2„Zddddd3œ	 	 	 	 	 	 	 	 	 dQd4„Z ddœ	 	 	 	 	 dRd5„Z!d6d7dd%œ	 	 	 	 	 	 	 	 	 dSd8„Z"y)TÚAsyncSandboxClienta  Async client for interacting with the Sandbox Server API.

    This client provides an async interface for managing sandboxes and snapshots.

    Example:
        # Uses LANGSMITH_ENDPOINT and LANGSMITH_API_KEY from environment
        async with AsyncSandboxClient() as client:
            # Create a sandbox with the default runtime and run commands
            async with await client.sandbox() as sandbox:
                result = await sandbox.run("python --version")
                print(result.stdout)
    Ng      $@é   ©Úapi_endpointÚtimeoutÚapi_keyÚmax_retriesÚheadersc               ól  — |xs
 t        «       j                  d«      | _        |xs
 t        «       }|| _        || _        || _        |rt        |«      ni | _        i }|r||d<   | j                  rt        || j                  «      }t        |¬«      }t        j                  |||¬«      | _        d| _        y)a®  Initialize the AsyncSandboxClient.

        Args:
            api_endpoint: Full URL of the sandbox API endpoint. If not provided,
                          derived from LANGSMITH_ENDPOINT environment variable.
            timeout: Default HTTP timeout in seconds.
            api_key: API key for authentication. If not provided, uses
                     LANGSMITH_API_KEY environment variable.
            max_retries: Maximum number of retries for transient errors (502, 503,
                         504), rate limits (429), and connection failures. Set to 0
                         to disable retries. Default: 3.
            headers: Optional default headers attached to every request on this
                     client, including the data-plane ``/execute`` HTTP endpoint
                     and the ``/execute/ws`` WebSocket upgrade. Use this to pass
                     additional auth headers (e.g. ``X-Service-Key``).
        r*   z	X-Api-Key)r>   )Ú	transportr<   r?   N)r1   r.   Ú	_base_urlr6   Ú_api_keyÚ_timeoutÚ_max_retriesÚdictÚ_default_headersr   r%   ÚhttpxÚAsyncClientÚ_httpÚ_registries_client)	Úselfr;   r<   r=   r>   r?   Úresolved_api_keyÚclient_headersrA   s	            r0   Ú__init__zAsyncSandboxClient.__init__Z   s¯   € ð2 'ÒEÔ*CÓ*E×MÑMÈcÓRˆŒØ"Ò<Ô&:Ó&<ÐØ(ˆŒØˆŒØ'ˆÔÙAH´°W´ÈbˆÔØ)+ˆÙØ*:ˆN˜;Ñ'Ø× Ò Ü*¨>¸4×;PÑ;PÓQˆNÜ'°KÔ@ˆ	Ü×&Ñ&Ø¨¸.ô
ˆŒ
ð =AˆÕr2   c                ó†   — d}| j                   j                  |«      r| j                   dt        |«        S | j                   S )z>Return the API root URL, without the ``/v2/sandboxes`` suffix.r+   N)rB   ÚendswithÚlen)rL   Úsuffixs     r0   Ú	_api_rootzAsyncSandboxClient._api_root„   s:   € à ˆØ�>‰>×"Ñ" 6Ô*Ø—>‘> .¤S¨£[ LÐ1Ð1Ø�~‰~Ðr2   c                óÌ   — | j                   €9t        | j                  | j                  «       | j                  xs d¬«      | _         | j                   j
                  j                  S )aò  Manage sandbox image registries: create, list, retrieve, update, delete.

        A registry stores credentials for pulling private images. Create one,
        then pass its ``id`` as ``registry_id`` when building a snapshot.

        Example:
            registry = await client.registries.create(
                name="internal",
                url="registry.example.com",
                username="robot",
                password=os.environ["REGISTRY_PASSWORD"],
            )
            snapshot = await client.create_snapshot(
                "internal-python",
                docker_image="registry.example.com/internal/python:3.12",
                fs_capacity_bytes=2 * 1024**3,
                registry_id=registry.id,
            )
        N)r=   Úbase_urlÚdefault_headers)rK   r   rC   rT   rG   Ú	sandboxesÚ
registries©rL   s    r0   rY   zAsyncSandboxClient.registries‹   sV   € ð* ×"Ñ"Ð*Ü&4ØŸ™ØŸ™Ó)Ø $× 5Ñ 5Ò =¸ô'ˆDÔ#ð
 ×&Ñ&×0Ñ0×;Ñ;Ð;r2   c                óH   — |€yt        | j                  j                  |«      S )z8Merge default client headers with per-request overrides.N)r   rJ   r?   ©rL   r?   s     r0   Ú_request_headersz#AsyncSandboxClient._request_headers¨   s!   € àˆ?ØÜ˜TŸZ™Z×/Ñ/°Ó9Ð9r2   c                óL   — | j                   s|€yt        | j                   |«      S )zÜMerge constructor-supplied default headers with per-request overrides.

        Used by the WebSocket exec path so headers like ``X-Service-Key``
        set on the client are attached to the WS upgrade request.
        N)rG   r   r\   s     r0   Ú_ws_default_headersz&AsyncSandboxClient._ws_default_headers®   s'   € ð ×$Ò$¨¨ØÜ˜T×2Ñ2°GÓ<Ð<r2   c                óŽ   — t        | j                  | j                  | j                  | j                  | j
                  xs d¬«      S )aC  Create a SandboxClient with the same configuration.

        The returned client has its own HTTP connection pool; close it
        independently (``client.close()`` or ``with``).

        Returns:
            SandboxClient with the same endpoint, credentials, timeout,
            retry, and header configuration.
        Nr:   )r   rB   rD   rC   rE   rG   rZ   s    r0   Úto_synczAsyncSandboxClient.to_sync¸   s=   € ô ØŸ™Ø—M‘MØ—M‘MØ×)Ñ)Ø×)Ñ)Ò1¨Tô
ð 	
r2   c              ƒ  ó¶   K  — | j                   j                  «       ƒ d{  –—†  | j                  �#| j                  j                  «       ƒ d{  –—†  yy7 Œ47 Œ­w)zClose the async HTTP client.N)rJ   ÚacloserK   ÚcloserZ   s    r0   rc   zAsyncSandboxClient.acloseÊ   sN   è ø€ à�j‰j×ÑÓ!×!Ð!Ø×"Ñ"Ð.Ø×)Ñ)×/Ñ/Ó1×1Ñ1ð /ð 	"øà1ús!   ‚A A¡-AÁAÁAÁAc                óú   — 	 | j                   j                  sF	 t        j                  «       }|j                  «       s |j	                  | j                  «       «       yyy# t        $ r Y yw xY w# t        $ r Y yw xY w)a$  Best-effort cleanup of the async HTTP client on garbage collection.

        If an event loop is running, schedules ``aclose()`` as a task.
        Otherwise the underlying sockets will be closed by the GC.
        For deterministic cleanup, use ``async with`` or ``await aclose()``.
        N)rJ   Ú	is_closedÚasyncioÚget_running_loopÚcreate_taskrc   ÚRuntimeErrorÚ	Exception)rL   Úloops     r0   Ú__del__zAsyncSandboxClient.__del__Ð   st   € ð		Ø—:‘:×'Ò'ðÜ"×3Ñ3Ó5�DØŸ>™>Ô+Ø×(Ñ(¨¯©«Õ7ð ,ð (øô
 $ò Ùðûäò 	Ùð	ús/   ‚A. ™AA Á	A+Á(A. Á*A+Á+A. Á.	A:Á9A:c              ƒ  ó   K  — | S ­w)zEnter async context manager.r5   rZ   s    r0   Ú
__aenter__zAsyncSandboxClient.__aenter__â   s   è ø€ àˆùs   ‚c              ƒ  ó@   K  — | j                  «       ƒ d{  –—†  y7 Œ­w)zExit async context manager.N)rc   )rL   Úexc_typeÚexc_valÚexc_tbs       r0   Ú	__aexit__zAsyncSandboxClient.__aexit__æ   s   è ø€ ð �k‰k‹m×Òús   ‚–—c                ó"   — d| j                   › d�S )z�Return a string representation of the instance.

        Returns:
            The string representation of the instance.
        zAsyncSandboxClient (API URL: Ú))rB   rZ   s    r0   Ú__repr__zAsyncSandboxClient.__repr__ï   s   € ð /¨t¯~©~Ð.>¸aÐ@Ð@r2   é   ©Úsnapshot_nameÚnamer<   Úidle_ttl_secondsÚdelete_after_stop_secondsÚvcpusÚ	mem_bytesÚfs_capacity_bytesÚmount_configÚproxy_configr?   c             ƒ  ój   K  — | j                  |||||||||	|
||¬«      ƒ d{  –—† }d|_        |S 7 Œ­w)aV  Create a sandbox and return an AsyncSandbox instance.

        This is the primary method for creating sandboxes. Use it as an
        async context manager for automatic cleanup:

            async with await client.sandbox(snapshot_id="<uuid>") as sandbox:
                result = await sandbox.run("echo hello")

            # Resolve by snapshot name instead of ID:
            async with await client.sandbox(snapshot_name="my-snap") as sandbox:
                result = await sandbox.run("echo hello")

        The sandbox is automatically deleted when exiting the context manager.
        For sandboxes with manual lifecycle management, use create_sandbox().

        Args:
            snapshot_id: Optional snapshot ID to boot from. Mutually exclusive
                with ``snapshot_name``.
            snapshot_name: Snapshot name to boot from. Resolved server-side to a
                snapshot owned by the caller's tenant. Mutually exclusive with
                ``snapshot_id``.
            name: Optional sandbox name (auto-generated if not provided).
            timeout: Timeout in seconds when waiting for ready.
            idle_ttl_seconds: Idle timeout in seconds. The launcher
                automatically stops the sandbox after this duration of
                inactivity. Must be a multiple of 60. ``0`` explicitly
                disables the idle stop. When omitted (``None``), the server
                applies a default of ``600`` seconds (10 minutes).
            delete_after_stop_seconds: Seconds after the sandbox enters the
                ``stopped`` state before it (and its filesystem clone) are
                permanently deleted. Must be a multiple of 60. ``0`` disables
                stop-anchored deletion (manual cleanup required). When
                omitted (``None``), the server applies its configured default.
            vcpus: Number of vCPUs.
            mem_bytes: Memory in bytes.
            fs_capacity_bytes: Root filesystem capacity in bytes.
            mount_config: Mount configuration forwarded to the server as
                ``mount_config``. The backend expands mount auth into runtime
                proxy rules. Explicit AWS/GCP proxy rules in ``proxy_config``
                conflict with mount auth for the same provider.
            proxy_config: Per-sandbox proxy configuration forwarded to the
                server as-is. Shape matches the backend `proxy_config` field:
                ``{"rules": [...], "no_proxy": [...], "access_control":
                {"allow_list": [...]}}`` or ``{"access_control":
                {"deny_list": [...]}}``. Use ``access_control.allow_list`` to
                restrict outbound HTTPS to a set of host patterns (exact
                domains, globs like ``*.example.com``, IPs, CIDRs, or
                ``~regex``). Use ``proxy_config`` with provider rule helpers
                such as ``aws_auth`` to let the proxy sign supported
                AWS HTTPS requests on the sandbox's behalf.

        Returns:
            AsyncSandbox instance.

        Raises:
            ResourceTimeoutError: If timeout waiting for sandbox to be ready.
            ResourceCreationError: If sandbox creation fails.
            SandboxClientError: For other errors.
            ValueError: If TTL values are invalid, or if both ``snapshot_id`` and
                ``snapshot_name`` are provided.
        ry   NT)Úcreate_sandboxÚ_auto_delete)rL   Úsnapshot_idrz   r{   r<   r|   r}   r~   r   r€   r�   r‚   r?   Úsbs                 r0   ÚsandboxzAsyncSandboxClient.sandboxû   sZ   è ø€ ðZ ×&Ñ&ØØ'ØØØ-Ø&?ØØØ/Ø%Ø%Øð 'ó 
÷ 
ˆð ˆŒØˆ	ð
ús   ‚!3£1¤3T)rz   r{   r<   Úwait_for_readyr|   r}   r~   r   r€   r�   r‚   r?   c             ƒ  ón  K  — |r|rt        d«      ‚t        |d«       t        |d«       | j                  › d�}d|i}|r||d<   |r||d<   |r||d<   |r||d	<   |�||d<   |�||d<   |�||d<   |	�|	|d<   |
�|
|d<   |�t        ||«       ||d<   |�||d<   |r|dz   nd}	 | j                  j                  |||| j                  |«      ¬«      ƒ d
{  –—† }|j                  «        t        j                  |j                  «       | d¬«      S 7 Œ:# t        j                  $ r}t        |«       ‚ d
}~ww xY w­w)a  Create a new Sandbox.

        The sandbox is NOT automatically deleted. Use delete_sandbox() for cleanup,
        or use sandbox() for automatic cleanup with a context manager.

        Args:
            snapshot_id: Optional snapshot ID to boot from. Mutually exclusive
                with ``snapshot_name``.
            snapshot_name: Snapshot name to boot from. Resolved server-side to a
                snapshot owned by the caller's tenant. Mutually exclusive with
                ``snapshot_id``.
            name: Optional sandbox name (auto-generated if not provided).
            timeout: Timeout in seconds when waiting for ready (only used when
                wait_for_ready=True).
            wait_for_ready: If True (default), block until sandbox is ready.
                If False, return immediately with status "provisioning". Use
                get_sandbox_status() or wait_for_sandbox() to poll for readiness.
            idle_ttl_seconds: Idle timeout in seconds. The launcher
                automatically stops the sandbox after this duration of
                inactivity. Must be a multiple of 60. ``0`` explicitly
                disables the idle stop. When omitted (``None``), the server
                applies a default of ``600`` seconds (10 minutes).
            delete_after_stop_seconds: Seconds after the sandbox enters the
                ``stopped`` state before it (and its filesystem clone) are
                permanently deleted. Must be a multiple of 60. ``0`` disables
                stop-anchored deletion (manual cleanup required). When
                omitted (``None``), the server applies its configured default.
            vcpus: Number of vCPUs.
            mem_bytes: Memory in bytes.
            fs_capacity_bytes: Root filesystem capacity in bytes.
            mount_config: Mount configuration forwarded to the server as
                ``mount_config``. The backend expands mount auth into runtime
                proxy rules. Explicit AWS/GCP proxy rules in ``proxy_config``
                conflict with mount auth for the same provider.
            proxy_config: Per-sandbox proxy configuration forwarded to the
                server as-is. Shape matches the backend `proxy_config` field:
                ``{"rules": [...], "no_proxy": [...], "access_control":
                {"allow_list": [...]}}`` or ``{"access_control":
                {"deny_list": [...]}}``. Use ``access_control.allow_list`` to
                restrict outbound HTTPS to a set of host patterns (exact
                domains, globs like ``*.example.com``, IPs, CIDRs, or
                ``~regex``). Use ``proxy_config`` with provider rule helpers
                such as ``aws_auth`` to let the proxy sign supported
                AWS HTTPS requests on the sandbox's behalf.

        Returns:
            Created AsyncSandbox. When wait_for_ready=False, the sandbox will have
            status="provisioning" and cannot be used for operations until ready.

        Raises:
            ResourceTimeoutError: If timeout waiting for sandbox to be ready.
            ResourceCreationError: If sandbox creation fails.
            SandboxClientError: For other errors.
            ValueError: If TTL values are invalid, or if both ``snapshot_id`` and
                ``snapshot_name`` are provided.
        z6At most one of snapshot_id or snapshot_name may be setr|   r}   ú/boxesr‰   r†   rz   r<   r{   Nr~   r   r€   r�   r‚   rx   )Újsonr<   r?   F©ÚclientÚauto_delete)Ú
ValueErrorr   rB   r#   rJ   Úpostr]   Úraise_for_statusr   Ú	from_dictrŒ   rH   ÚHTTPStatusErrorr   )rL   r†   rz   r{   r<   r‰   r|   r}   r~   r   r€   r�   r‚   r?   ÚurlÚpayloadÚhttp_timeoutÚresponseÚes                      r0   r„   z!AsyncSandboxClient.create_sandboxY  s�  è ø€ ñR ™=ÜÐUÓVÐVÜÐ%Ð'9Ô:ÜÐ.Ð0KÔLà—‘Ð  Ð'ˆð ˜nð#
ˆñ Ø%0ˆG�MÑ"ÙØ'4ˆG�OÑ$ÙØ!(ˆG�IÑÙØ"ˆG�F‰OØÐ'Ø*:ˆGÐ&Ñ'Ø$Ð0Ø3LˆGÐ/Ñ0ØÐØ$ˆG�GÑØÐ Ø#,ˆG�KÑ ØÐ(Ø+<ˆGÐ'Ñ(ØÐ#Ü.¨|¸\ÔJØ&2ˆG�NÑ#ØÐ#Ø&2ˆG�NÑ#á)7˜ "š¸Rˆð	Ø!ŸZ™ZŸ_™_ØØØ$Ø×-Ñ-¨gÓ6ð	 -ó ÷ ˆHð ×%Ñ%Ô'Ü×)Ñ)Ø—‘“¨¸%ôð ðùô ×$Ñ$ò 	Ü)¨!Ô,Øûð	üs<   ‚BD5Â 1D ÃDÃ9D ÄD5ÄD ÄD2Ä!D-Ä-D2Ä2D5©r?   c             ƒ  ó´  K  — t        | j                  |«      }	 | j                  j                  || j	                  |«      ¬«      ƒ d{  –—† }|j                  «        t        j                  |j                  «       | d¬«      S 7 Œ:# t        j                  $ r<}|j                  j                  dk(  rt        d|› d�d¬	«      |‚t        |«       ‚ d}~ww xY w­w)
aK  Get a Sandbox by name.

        The sandbox is NOT automatically deleted. Use delete_sandbox() for cleanup.

        Args:
            name: Sandbox name.

        Returns:
            AsyncSandbox.

        Raises:
            ResourceNotFoundError: If sandbox not found.
            SandboxClientError: For other errors.
        rš   NFr�   é”  ú	Sandbox 'ú' not foundrˆ   ©Úresource_type)r   rB   rJ   Úgetr]   r’   r   r“   rŒ   rH   r”   r˜   Ústatus_coder   r   ©rL   r{   r?   r•   r˜   r™   s         r0   Úget_sandboxzAsyncSandboxClient.get_sandboxÕ  sÇ   è ø€ ô" �t—~‘~ tÓ,ˆð	Ø!ŸZ™ZŸ^™^¨C¸×9NÑ9NÈwÓ9W˜^ÓX×XˆHØ×%Ñ%Ô'Ü×)Ñ)Ø—‘“¨¸%ôð ð Yùô
 ×$Ñ$ò 	Ø�z‰z×%Ñ%¨Ò,Ü+Ø ˜v [Ð1Àôàðô % QÔ'Øûð	üs:   ‚Cš/B Á	BÁ
9B ÂCÂB ÂCÂ7CÃCÃCc             ƒ  óì  K  — | j                   › d�}	 | j                  j                  || j                  |«      ¬«      ƒ d{  –—† }|j	                  «        |j                  «       }|j                  dg «      D �cg c]  }t        j                  || d¬«      ‘Œ c}S 7 ŒZc c}w # t        j                  $ r:}|j                  j                  dk(  rt        d|› d	�«      |‚t        |«       ‚ d}~ww xY w­w)
zRList all Sandboxes.

        Returns:
            List of AsyncSandboxes.
        r‹   rš   NrX   Fr�   rœ   úAPI endpoint not found: ú%. Check that api_endpoint is correct.)rB   rJ   r¡   r]   r’   rŒ   r   r“   rH   r”   r˜   r¢   r   r   )rL   r?   r•   r˜   ÚdataÚcr™   s          r0   Úlist_sandboxesz!AsyncSandboxClient.list_sandboxesö  sù   è ø€ ð —‘Ð  Ð'ˆð	Ø!ŸZ™ZŸ^™^¨C¸×9NÑ9NÈwÓ9W˜^ÓX×XˆHØ×%Ñ%Ô'Ø—=‘=“?ˆDð Ÿ™ +¨rÔ2óá2�Aô ×&Ñ& q°À5ÖIØ2ñð ð Yúòøô ×$Ñ$ò 	Ø�z‰z×%Ñ%¨Ò,Ü%Ø.¨s¨eð 4:ð ;óð ðô % QÔ'Øûð	üsL   ‚C4“/B$ ÁBÁ8B$ Á;BÂB$ ÂC4ÂB$ ÂB$ Â$C1Â75C,Ã,C1Ã1C4)Únew_namer|   r}   r?   c             ƒ  ój  K  — t        |d«       t        |d«       t        | j                  |«      }i }|�||d<   |�||d<   |�||d<   	 | j                  j	                  ||| j                  |«      ¬«      ƒ d{  –—† }|j                  «        t        j                  |j                  «       | d¬«      S 7 Œ:# t        j                  $ rg}	|	j                  j                  dk(  rt        d	|› d
�d¬«      |	‚|	j                  j                  dk(  rt        d|› d�d¬«      |	‚t!        |	«       ‚ d}	~	ww xY w­w)ab  Update a sandbox's properties.

        Args:
            name: Current sandbox name.
            new_name: New display name.
            idle_ttl_seconds: Idle timeout in seconds. Must be a multiple of
                60. ``0`` disables idle-stop. ``None`` leaves the existing
                value unchanged.
            delete_after_stop_seconds: Seconds after entering ``stopped``
                before deletion. Must be a multiple of 60. ``0`` disables
                stop-anchored deletion. ``None`` leaves the existing value
                unchanged.

        Returns:
            Updated AsyncSandbox.

        Raises:
            ResourceNotFoundError: If sandbox not found.
            ResourceNameConflictError: If new_name is already in use.
            SandboxClientError: For other errors.
            ValueError: If TTL values are invalid.
        r|   r}   Nr{   ©rŒ   r?   Fr�   rœ   r�   rž   rˆ   rŸ   i™  zSandbox name 'z' already in use)r   r   rB   rJ   Úpatchr]   r’   r   r“   rŒ   rH   r”   r˜   r¢   r   r   r   )
rL   r{   r«   r|   r}   r?   r•   r–   r˜   r™   s
             r0   Úupdate_sandboxz!AsyncSandboxClient.update_sandbox  sX  è ø€ ô> 	Ð%Ð'9Ô:ÜÐ.Ð0KÔLä�t—~‘~ tÓ,ˆØ"$ˆØÐØ&ˆG�F‰OØÐ'Ø*:ˆGÐ&Ñ'Ø$Ð0Ø3LˆGÐ/Ñ0ð	Ø!ŸZ™Z×-Ñ-Ø˜'¨4×+@Ñ+@ÀÓ+Ið .ó ÷ ˆHð ×%Ñ%Ô'Ü×)Ñ)Ø—‘“¨¸%ôð ð	ùô ×$Ñ$ò 	Ø�z‰z×%Ñ%¨Ò,Ü+Ø ˜v [Ð1Àôàðð �z‰z×%Ñ%¨Ò,Ü/Ø$ X JÐ.>Ð?Ø"+ôð ðô % QÔ'Øûð	üs=   ‚AD3Á	0B6 Á9B4Á:9B6 Â3D3Â4B6 Â6D0Ã	A"D+Ä+D0Ä0D3c             ƒ  ór  K  — t        | j                  |«      }	 | j                  j                  || j	                  |«      ¬«      ƒ d{  –—† }|j                  «        y7 Œ# t        j                  $ r@}|j                  j                  dk(  rt        d|› d�d¬«      |‚t        |«       Y d}~yd}~ww xY w­w)zÅDelete a Sandbox.

        Args:
            name: Sandbox name.

        Raises:
            ResourceNotFoundError: If sandbox not found.
            SandboxClientError: For other errors.
        rš   Nrœ   r�   rž   rˆ   rŸ   )r   rB   rJ   Údeleter]   r’   rH   r”   r˜   r¢   r   r   r£   s         r0   Údelete_sandboxz!AsyncSandboxClient.delete_sandboxQ  s²   è ø€ ô �t—~‘~ tÓ,ˆð
	(Ø!ŸZ™Z×.Ñ.Ø˜T×2Ñ2°7Ó;ð /ó ÷ ˆHð ×%Ñ%Õ'ðùô ×$Ñ$ò 	(Ø�z‰z×%Ñ%¨Ò,Ü+Ø ˜v [Ð1Àôàðô % Q×'Ñ'ûð	(üs@   ‚B7š/A! Á	AÁ
A! ÁB7ÁA! Á!B4Á46B/Â*B7Â/B4Â4B7c             ƒ  ó°  K  — t        | j                  |d«      }	 | j                  j                  || j	                  |«      ¬«      ƒ d{  –—† }|j                  «        t        j                  |j                  «       «      S 7 Œ7# t        j                  $ r<}|j                  j                  dk(  rt        d|› d�d¬«      |‚t        |«       ‚ d}~ww xY w­w)	aà  Get the provisioning status of a sandbox.

        This is a lightweight endpoint designed for high-frequency polling
        during sandbox provisioning. It returns only the status fields
        without full sandbox data.

        Args:
            name: Sandbox name.

        Returns:
            ResourceStatus with status and status_message.

        Raises:
            ResourceNotFoundError: If sandbox not found.
            SandboxClientError: For other errors.
        Ústatusrš   Nrœ   r�   rž   rˆ   rŸ   )r   rB   rJ   r¡   r]   r’   r    r“   rŒ   rH   r”   r˜   r¢   r   r   r£   s         r0   Úget_sandbox_statusz%AsyncSandboxClient.get_sandbox_statusk  sÀ   è ø€ ô& �t—~‘~ t¨XÓ6ˆð
	Ø!ŸZ™ZŸ^™^¨C¸×9NÑ9NÈwÓ9W˜^ÓX×XˆHØ×%Ñ%Ô'Ü!×+Ñ+¨H¯M©M«OÓ<Ð<ð Yùô ×$Ñ$ò 	Ø�z‰z×%Ñ%¨Ò,Ü+Ø ˜v [Ð1Àôàðô % QÔ'Øûð	üs:   ‚C›/B Á
BÁ6B ÂCÂB ÂCÂ7CÃCÃCiX  ©Úexpires_in_secondsr?   c             ƒ  óö  ‡ ‡‡‡‡K  — t        ‰‰«       t        ‰ j                  ‰d«      }‰‰dœ}dˆˆˆˆˆ fd„}	 ‰ j                  j	                  ||‰ j                  ‰«      ¬«      ƒ d{  –—† }|j                  «        t        j                  |j                  «       |¬«      S 7 Œ9# t        j                  $ r<}	|	j                  j                  dk(  rt        d‰› d	�d
¬«      |	‚t        |	«       ‚ d}	~	ww xY w­w)a‡  Get an authenticated URL for a service running inside a sandbox.

        Returns an :class:`AsyncServiceURL` whose async accessors
        auto-refresh the token transparently before it expires.  The
        object also provides async HTTP helper methods (``.get``,
        ``.post``, etc.) that inject the authentication header
        automatically.

        Args:
            name: Sandbox name.
            port: Port the service is listening on inside the sandbox.
            expires_in_seconds: Token TTL in seconds (1--86400, default 600).
            headers: Optional per-request header overrides.

        Returns:
            AsyncServiceURL with auto-refreshing token and HTTP helpers.

        Raises:
            ResourceNotFoundError: If sandbox not found.
            ValueError: If port or expires_in_seconds is out of range.
            SandboxClientError: For other errors.
        zservice-url)Úportr·   c               “  óJ   •K  — ‰j                  ‰‰‰ ‰¬«      ƒ d {  –—† S 7 Œ­w)Nr¶   )Úservice)r·   r?   r{   r¹   rL   s   €€€€€r0   Ú
_refresherz.AsyncSandboxClient.service.<locals>._refresher®  s3   øè ø€ ØŸ™ØØØ#5Øð	 &ó ÷ ð ð ús   ƒ#œ!�#r­   N)r¼   rœ   r�   rž   rˆ   rŸ   )Úreturnr   )r   r   rB   rJ   r‘   r]   r’   r   r“   rŒ   rH   r”   r˜   r¢   r   r   )
rL   r{   r¹   r·   r?   r•   r–   r¼   r˜   r™   s
   `````     r0   r»   zAsyncSandboxClient.serviceŒ  sî   üè ø€ ô< 	  Ð&8Ô9Ü�t—~‘~ t¨]Ó;ˆØÐ7IÑJˆ÷	ñ 	ð	Ø!ŸZ™ZŸ_™_Ø˜'¨4×+@Ñ+@ÀÓ+Ið -ó ÷ ˆHð ×%Ñ%Ô'Ü"×,Ñ,¨X¯]©]«_ÈÔTÐTð	ùô
 ×$Ñ$ò 	Ø�z‰z×%Ñ%¨Ò,Ü+Ø ˜v [Ð1Àôàðô % QÔ'Øûð	üs:   ‡3C9»0B' Á+B%Á,8B' Â$C9Â%B' Â'C6Â:7C1Ã1C6Ã6C9)r·   Úcontent_typeÚcontent_dispositionr?   c             ƒ  ó  K  — |�|dk  rt        d|› d�«      ‚t        | j                  |d«      }d|i}|�||d<   |�||d<   |�||d	<   	 | j                  j	                  ||| j                  |«      ¬
«      ƒ d{  –—† }	|	j                  «        t        j                  |	j                  «       «      S 7 Œ7# t        j                  $ r<}
|
j                  j                  dk(  rt        d|› d�d¬«      |
‚t        |
«       ‚ d}
~
ww xY w­w)aM  Create a link that downloads one file from a sandbox.

        The link carries its own token, so anyone holding the URL can fetch
        that one file without a LangSmith credential. It is pinned to the
        sandbox and the exact path and cannot be repointed at another file.
        Fetching wakes a stopped sandbox.

        Do not modify the file after minting a link for it. The link is
        pinned to a path, not to a snapshot of the contents, so a later
        write to that path may or may not be reflected in what the link
        serves. Write a new file and mint a new link when the contents
        change.

        Args:
            name: Sandbox name.
            path: File path inside the sandbox.
            expires_in_seconds: Link TTL in seconds. Omit for a link that
                never expires.
            content_type: Content-Type to serve the file as.
            content_disposition: Content-Disposition to serve the file with,
                either ``"attachment"`` or ``"inline"``.
            headers: Optional per-request header overrides.

        Returns:
            DownloadURL with the link and its expiry, if any.

        Raises:
            ResourceNotFoundError: If sandbox not found.
            ValueError: If expires_in_seconds is not positive.
            SandboxClientError: For other errors.
        Né   z/expires_in_seconds must be greater than 0 (got z(); omit it for a link that never expireszdownload-urlÚpathr·   r¾   r¿   r­   rœ   r�   rž   rˆ   rŸ   )r�   r   rB   rJ   r‘   r]   r’   r   r“   rŒ   rH   r”   r˜   r¢   r   r   )rL   r{   rÂ   r·   r¾   r¿   r?   r•   r–   r˜   r™   s              r0   Úgenerate_download_urlz(AsyncSandboxClient.generate_download_urlÄ  s8  è ø€ ðR Ð)Ð.@À1Ò.DÜðØ*Ð+Ð+SðUóð ô �t—~‘~ t¨^Ó<ˆØ#)¨4 .ˆØÐ)Ø,>ˆGÐ(Ñ)ØÐ#Ø&2ˆG�NÑ#ØÐ*Ø-@ˆGÐ)Ñ*ð	Ø!ŸZ™ZŸ_™_Ø˜'¨4×+@Ñ+@ÀÓ+Ið -ó ÷ ˆHð ×%Ñ%Ô'Ü×(Ñ(¨¯©«Ó9Ð9ð	ùô
 ×$Ñ$ò 	Ø�z‰z×%Ñ%¨Ò,Ü+Ø ˜v [Ð1Àôàðô % QÔ'Øûð	üs<   ‚ADÁ
0B4 Á:B2Á;6B4 Â1DÂ2B4 Â4DÃ7C>Ã>DÄDéx   g      ð?)r<   Úpoll_intervalr?   c             ƒ  óâ  K  — ddl }|j                  «       |z   }	 | j                  ||¬«      ƒ d{  –—† }|j                  dk(  r| j	                  ||¬«      ƒ d{  –—† S |j                  dk(  rt        |j                  xs dd¬«      ‚||j                  «       z
  }|dk  rt        d	|› d
|› d�d|j                  ¬«      ‚t        j                  t        ||«      «      ƒ d{  –—†  ŒÎ7 Œ·7 Œ�7 Œ	­w)a¬  Poll until a sandbox reaches "ready" or "failed" status.

        Uses the lightweight status endpoint for polling, then fetches the
        full sandbox data once ready.

        Args:
            name: Sandbox name.
            timeout: Maximum time to wait in seconds.
            poll_interval: Time between status checks in seconds.

        Returns:
            AsyncSandbox in "ready" status.

        Raises:
            ResourceCreationError: If sandbox status becomes "failed".
            ResourceTimeoutError: If timeout expires while still "provisioning".
            ResourceNotFoundError: If sandbox not found.
            SandboxClientError: For other errors.
        r   Nrš   ÚreadyÚfailedzSandbox provisioning failedrˆ   rŸ   r�   ú' not ready after Ús©r    Úlast_status)ÚtimeÚ	monotonicrµ   r´   r¤   r   Ústatus_messager   rg   ÚsleepÚmin)	rL   r{   r<   rÅ   r?   rÍ   Údeadliner´   Ú	remainings	            r0   Úwait_for_sandboxz#AsyncSandboxClient.wait_for_sandbox	  sø   è ø€ ó6 	à—>‘>Ó# gÑ-ˆØØ×2Ñ2°4ÀÐ2ÓI×IˆFØ�}‰} Ò'Ø!×-Ñ-¨d¸GÐ-ÓD×DÐDØ�}‰} Ò(Ü+Ø×)Ñ)ÒJÐ-JØ"+ôð ð ! 4§>¡>Ó#3Ñ3ˆIØ˜AŠ~Ü*Ø ˜vÐ%7¸°yÀÐBØ"+Ø &§¡ôð ô
 —-‘-¤ M°9Ó =Ó>×>Ð>ð! ØIøàDøð ?ús4   ‚/C/±C)²)C/ÁC+ÁBC/Ã#C-Ã$C/Ã+C/Ã-C/©r<   r?   c             ƒ  ó°  K  — t        | j                  |d«      }	 | j                  j                  |i | j	                  |«      ¬«      ƒ d{  –—† }|j                  «        | j                  |||¬	«      ƒ d{  –—† S 7 Œ0# t        j                  $ r@}|j                  j                  dk(  rt        d|› d�d¬«      |‚t        |«       Y d}~Œld}~ww xY w7 Œ\­w)
aõ  Start a stopped sandbox and wait until ready.

        Args:
            name: Sandbox name.
            timeout: Timeout in seconds when waiting for ready.

        Returns:
            AsyncSandbox in "ready" status.

        Raises:
            ResourceNotFoundError: If sandbox not found.
            ResourceCreationError: If sandbox fails during startup.
            ResourceTimeoutError: If sandbox doesn't become ready within timeout.
            SandboxClientError: For other errors.
        Ústartr­   Nrœ   r�   rž   rˆ   rŸ   rÕ   )r   rB   rJ   r‘   r]   r’   rH   r”   r˜   r¢   r   r   rÔ   )rL   r{   r<   r?   r•   r˜   r™   s          r0   Ústart_sandboxz AsyncSandboxClient.start_sandbox9  sØ   è ø€ ô, �t—~‘~ t¨WÓ5ˆð
	(Ø!ŸZ™ZŸ_™_Ø˜" d×&;Ñ&;¸GÓ&Dð -ó ÷ ˆHð ×%Ñ%Ô'ð ×*Ñ*¨4¸È'Ð*ÓR×RÐRðùô ×$Ñ$ò 	(Ø�z‰z×%Ñ%¨Ò,Ü+Ø ˜v [Ð1Àôàðô % Q×'Ñ'ûð	(úð SúsL   ‚C›0A> ÁA<ÁA> Á CÁ7CÁ8CÁ<A> Á>CÂ6CÃCÃCÃCc             ƒ  óv  K  — t        | j                  |d«      }	 | j                  j                  |i | j	                  |«      ¬«      ƒ d{  –—† }|j                  «        y7 Œ# t        j                  $ r@}|j                  j                  dk(  rt        d|› d�d¬«      |‚t        |«       Y d}~yd}~ww xY w­w)	z÷Stop a running sandbox (preserves sandbox files for later restart).

        Args:
            name: Sandbox name.

        Raises:
            ResourceNotFoundError: If sandbox not found.
            SandboxClientError: For other errors.
        Ústopr­   Nrœ   r�   rž   rˆ   rŸ   )r   rB   rJ   r‘   r]   r’   rH   r”   r˜   r¢   r   r   r£   s         r0   Ústop_sandboxzAsyncSandboxClient.stop_sandbox_  s´   è ø€ ô �t—~‘~ t¨VÓ4ˆð
	(Ø!ŸZ™ZŸ_™_Ø˜" d×&;Ñ&;¸GÓ&Dð -ó ÷ ˆHð ×%Ñ%Õ'ðùô ×$Ñ$ò 	(Ø�z‰z×%Ñ%¨Ò,Ü+Ø ˜v [Ð1Àôàðô % Q×'Ñ'ûð	(üs@   ‚B9›0A# ÁA!ÁA# Á B9Á!A# Á#B6Á66B1Â,B9Â1B6Â6B9é<   )Úregistry_idr<   r?   c             ƒ  ó¶  K  — | j                   › d�}|||dœ}|�||d<   	 | j                  j                  ||| j                  |«      ¬«      ƒ d{  –—† }	|	j	                  «        t        j                  |	j                  «       «      }
| j                  |
j                  ||¬«      ƒ d{  –—† S 7 Œ]# t        j                  $ r}t        |«       ‚ d}~ww xY w7 Œ-­w)a¬  Build a snapshot from a Docker image.

        Blocks until the snapshot is ready (polls with 2s interval).

        Args:
            name: Snapshot name.
            docker_image: Docker image to build from (e.g., "python:3.12-slim").
            fs_capacity_bytes: Filesystem capacity in bytes.
            registry_id: Private registry ID.
            timeout: Timeout in seconds when waiting for ready.

        Returns:
            Snapshot in "ready" status.

        Raises:
            ResourceTimeoutError: If snapshot doesn't become ready within timeout.
            ResourceCreationError: If snapshot build fails.
            SandboxClientError: For other errors.
        ú
/snapshots)r{   Údocker_imager€   NrÝ   r­   rÕ   )rB   rJ   r‘   r]   r’   r!   r“   rŒ   rH   r”   r   Úwait_for_snapshotÚid)rL   r{   rà   r€   rÝ   r<   r?   r•   r–   r˜   Úsnapshotr™   s               r0   Úcreate_snapshotz"AsyncSandboxClient.create_snapshot{  së   è ø€ ð: —‘Ð  
Ð+ˆð Ø(Ø!2ñ#
ˆð
 Ð"Ø%0ˆG�MÑ"ð	Ø!ŸZ™ZŸ_™_Ø˜'¨4×+@Ñ+@ÀÓ+Ið -ó ÷ ˆHð ×%Ñ%Ô'Ü×)Ñ)¨(¯-©-«/Ó:ˆHð
 ×+Ñ+Ø�K‰K °'ð ,ó 
÷ 
ð 	
ðùô
 ×$Ñ$ò 	Ü$ QÔ'Øûð	úð
úsF   ‚C 0B0 ÁB.Á7B0 Â!CÂ)CÂ*CÂ.B0 Â0CÃCÃCÃCÚ.)ÚcontextÚ
build_argsÚtargetÚon_build_logr~   r   r<   r?   c             ƒ  ó(  K  — t        ||«      \  }}dt        j                  «       j                  dd › �}dt        j                  «       j                  dd › �}t	        j
                  |d«      }t	        j
                  |d«      }dt        j                  «       j                  › �}t	        j
                  |d«      }t	        j
                  |d	«      }| j                  ||
||	||¬
«      ƒ d{  –—† 4 ƒd{  –—† }|j                  |t        j                  t        |«      ƒ d{  –—† |
|¬«      ƒ d{  –—†  |j                  d|z   dz   |z   dz   |z   dz   |z   |
|¬«      ƒ d{  –—†  |j                  t        |||||||¬«      |
|||¬«      ƒ d{  –—† }|j                  dk7  rt        dd¬«      ‚| j                  |j                   ||||
|¬«      ƒ d{  –—† cddd«      ƒd{  –—†  S 7 Œÿ7 Œø7 ŒÌ7 Œ¿7 Œ�7 Œd7 Œ!7 Œ# 1 ƒd{  –—†7  sw Y   yxY w­w)a¸  Build a snapshot from a local Dockerfile context.

        When ``fs_capacity_bytes`` is omitted, the server applies its default.
        ``vcpus`` and ``mem_bytes`` size the temporary builder sandbox. The
        build runs BuildKit plus the native snapshotter's layer copies inside
        it, which contend for a single core by default, so giving the builder
        an extra vCPU can cut a cold build's wall time substantially.
        zsnapshot-builder-Né   z/var/lib/langsmith-build/ræ   zcontext.tarzlangsmith-snapshot-build:zbuildkit-rootzbuildkit-run)r{   r<   r~   r   r€   r?   rÕ   zrm -rf z && mkdir -p z && tar -xf z -C )Úremote_contextÚdockerfile_relÚ	image_refÚbuildkit_rootÚbuildkit_runrç   rè   )r<   Ú	on_stdoutÚ	on_stderrr?   r   z Dockerfile snapshot build failedrã   rŸ   ©rà   r€   r<   r?   )r   ÚuuidÚuuid4ÚhexÚ	posixpathÚjoinrˆ   Úwriterg   Ú	to_threadr   Úrunr   Ú	exit_coder   Úcapture_snapshotr{   )rL   r{   Ú
dockerfiler€   ræ   rç   rè   ré   r~   r   r<   r?   Úcontext_pathrí   Úbuilder_nameÚ
build_rootrì   Ú
remote_tarrî   rï   rð   rˆ   Úresults                          r0   Úcreate_snapshot_from_dockerfilez2AsyncSandboxClient.create_snapshot_from_dockerfile°  sr  è ø€ ô. (CÀ:ÈwÓ'WÑ$ˆ�nà*¬4¯:©:«<×+;Ñ+;¸C¸RÐ+@Ð*AÐBˆð 1´·±³×1AÑ1AÀ#À2Ð1FÐ0GÐHˆ
Ü"Ÿ™¨
°IÓ>ˆÜ—^‘^ J°Ó>ˆ
Ø/´·
±
³×0@Ñ0@Ð/AÐBˆ	Ü!Ÿ™ z°?ÓCˆÜ —~‘~ j°.ÓAˆàŸ™ØØØØØ/Øð &ó 
÷ 
÷ 
ð 
ð Ø—-‘-ØÜ×'Ñ'Ô(@À,ÓO×OØØð	  ó ÷ ð ð —+‘+ØØ ñ!à!ñ"ð !ñ!ð !ñ	!ð
 ñð ñð !ñ!ð  Øð ó ÷ ð ð #Ÿ;™;Ü.Ø#1Ø#1Ø'Ø"/Ø!-Ø)Ø!ôð  Ø&Ø&Øð 'ó ÷ ˆFð ×Ñ 1Ò$Ü+Ø6Ø",ôð ð ×.Ñ.Ø—‘ØØ&Ø"3ØØð /ó ÷ ÷_
÷ 
ò 
øð 
øð Pøðøðøðøð(øð_
ø÷ 
÷ 
ñ 
üsµ   ‚C+HÃ-G-Ã.HÃ6G/Ã7HÃ:*G=Ä$G1Ä%G=Ä3G3Ä40G=Å$G5Å%-G=ÆG7ÆAG=ÇG9ÇG=ÇHÇ'G;Ç(HÇ/HÇ1G=Ç3G=Ç5G=Ç7G=Ç9G=Ç;HÇ=HÈHÈHÈHró   c             ƒ  ó&  K  — t        | j                  |d«      }d|i}|�||d<   |�||d<   	 | j                  j                  ||| j	                  |«      ¬«      ƒ d{  –—† }	|	j                  «        t        j                  |	j                  «       «      }
| j                  |
j                   ||¬«      ƒ d{  –—† S 7 Œ]# t        j                  $ r<}|j                  j                  dk(  rt        d|› d	�d
¬«      |‚t        |«       ‚ d}~ww xY w7 ŒX­w)ao  Capture a snapshot from a running sandbox.

        Blocks until the snapshot is ready (polls with 2s interval).

        Args:
            sandbox_name: Name of the sandbox to capture from.
            name: Snapshot name.
            timeout: Timeout in seconds when waiting for ready.

        Returns:
            Snapshot in "ready" status.

        Raises:
            ResourceNotFoundError: If sandbox not found.
            ResourceTimeoutError: If snapshot doesn't become ready within timeout.
            ResourceCreationError: If snapshot capture fails.
            SandboxClientError: For other errors.
        rã   r{   Nrà   r€   r­   rœ   r�   rž   rˆ   rŸ   rÕ   )r   rB   rJ   r‘   r]   r’   r!   r“   rŒ   rH   r”   r˜   r¢   r   r   rá   râ   )rL   Úsandbox_namer{   rà   r€   r<   r?   r•   r–   r˜   rã   r™   s               r0   rý   z#AsyncSandboxClient.capture_snapshot  s$  è ø€ ô8 �t—~‘~ |°ZÓ@ˆà#)¨4 .ˆØÐ#Ø&2ˆG�NÑ#ØÐ(Ø+<ˆGÐ'Ñ(ð	Ø!ŸZ™ZŸ_™_Ø˜'¨4×+@Ñ+@ÀÓ+Ið -ó ÷ ˆHð ×%Ñ%Ô'Ü×)Ñ)¨(¯-©-«/Ó:ˆHð ×+Ñ+Ø�K‰K °'ð ,ó 
÷ 
ð 	
ðùô
 ×$Ñ$ò 	Ø�z‰z×%Ñ%¨Ò,Ü+Ø ˜~¨[Ð9Èôàðô % QÔ'Øûð	úð
úsF   ‚*D­0B= ÁB;Á7B= Â!DÂ6DÂ7DÂ;B= Â=DÃ7DÄDÄDc             ƒ  ó¶  K  — | j                   › dt        |«      › �}	 | j                  j                  || j	                  |«      ¬«      ƒ d{  –—† }|j                  «        t        j                  |j                  «       «      S 7 Œ7# t        j                  $ r<}|j                  j                  dk(  rt        d|› d�d¬«      |‚t        |«       ‚ d}~ww xY w­w)	zúGet a snapshot by ID.

        Args:
            snapshot_id: Snapshot UUID.

        Returns:
            Snapshot.

        Raises:
            ResourceNotFoundError: If snapshot not found.
            SandboxClientError: For other errors.
        ú/snapshots/rš   Nrœ   ú
Snapshot 'rž   rã   rŸ   )rB   r   rJ   r¡   r]   r’   r!   r“   rŒ   rH   r”   r˜   r¢   r   r   ©rL   r†   r?   r•   r˜   r™   s         r0   Úget_snapshotzAsyncSandboxClient.get_snapshotD  sÊ   è ø€ ð —‘Ð  Ô,?ÀÓ,LÐ+MÐNˆð
	Ø!ŸZ™ZŸ^™^¨C¸×9NÑ9NÈwÓ9W˜^ÓX×XˆHØ×%Ñ%Ô'Ü×%Ñ% h§m¡m£oÓ6Ð6ð Yùô ×$Ñ$ò 	Ø�z‰z×%Ñ%¨Ò,Ü+Ø   ¨[Ð9Èôàðô % QÔ'Øûð	üs:   ‚Cž/B ÁBÁ6B ÂCÂB ÂCÂ7CÃCÃC)Úname_containsÚlimitÚoffsetr?   c             ƒ  ó  K  — | j                   › d�}i }|�||d<   |�||d<   |�||d<   	 | j                  j                  ||xs d| j                  |«      ¬«      ƒ d{  –—† }|j	                  «        |j                  «       }|j                  dg «      D �	cg c]  }	t        j                  |	«      ‘Œ c}	S 7 ŒWc c}	w # t        j                  $ r:}
|
j                  j                  dk(  rt        d	|› d
�«      |
‚t        |
«       ‚ d}
~
ww xY w­w)aV  List snapshots.

        The backend always paginates this endpoint. When ``limit`` is omitted
        the server applies a default page size (currently 50), so a single
        call is not guaranteed to return every snapshot. To iterate through
        all results, repeat the call with increasing ``offset`` values (or an
        explicit ``limit``) until fewer than ``limit`` snapshots come back.

        Args:
            name_contains: Optional case-insensitive substring filter applied
                to snapshot names server-side.
            limit: Optional maximum number of snapshots to return for a single
                request. Must be between 1 and 500 (inclusive); the server
                rejects values outside that range. Defaults to 50 server-side
                when omitted.
            offset: Optional number of snapshots to skip before returning
                results. Must be ``>= 0``. Useful for paginating through
                large result sets in combination with ``limit``.

        Returns:
            A single page of Snapshots matching the provided filters.
        rß   Nr  r  r  )Úparamsr?   Ú	snapshotsrœ   r¦   r§   )rB   rJ   r¡   r]   r’   rŒ   r!   r“   rH   r”   r˜   r¢   r   r   )rL   r  r  r  r?   r•   r  r˜   r¨   rÊ   r™   s              r0   Úlist_snapshotsz!AsyncSandboxClient.list_snapshotsa  s.  è ø€ ð< —‘Ð  
Ð+ˆà!#ˆØÐ$Ø&3ˆF�?Ñ#ØÐØ#ˆF�7‰OØÐØ%ˆF�8Ñð	Ø!ŸZ™ZŸ^™^ØØ’~ Ø×-Ñ-¨gÓ6ð ,ó ÷ ˆHð
 ×%Ñ%Ô'Ø—=‘=“?ˆDØ37·8±8¸KÈÔ3LÓMÑ3L¨a”H×&Ñ& qÕ)Ð3LÑMÐMðúò NøÜ×$Ñ$ò 	Ø�z‰z×%Ñ%¨Ò,Ü%Ø.¨s¨eð 4:ð ;óð ðô % QÔ'Øûð	üsL   ‚'Dª4B= ÁB6Á8B= ÂB8Â3B= Â5DÂ6B= Â8B= Â=D
Ã5DÄD
Ä
Dc             ƒ  óz  K  — | j                   › dt        |«      › �}	 | j                  j                  || j	                  |«      ¬«      ƒ d{  –—† }|j                  «        y7 Œ# t        j                  $ r@}|j                  j                  dk(  rt        d|› d�d¬«      |‚t        |«       Y d}~yd}~ww xY w­w)	zÏDelete a snapshot.

        Args:
            snapshot_id: Snapshot UUID.

        Raises:
            ResourceNotFoundError: If snapshot not found.
            SandboxClientError: For other errors.
        r  rš   Nrœ   r	  rž   rã   rŸ   )rB   r   rJ   r±   r]   r’   rH   r”   r˜   r¢   r   r   r
  s         r0   Údelete_snapshotz"AsyncSandboxClient.delete_snapshot›  s¾   è ø€ ð —‘Ð  Ô,?ÀÓ,LÐ+MÐNˆð
	(Ø!ŸZ™Z×.Ñ.Ø˜T×2Ñ2°7Ó;ð /ó ÷ ˆHð ×%Ñ%Õ'ðùô ×$Ñ$ò 	(Ø�z‰z×%Ñ%¨Ò,Ü+Ø   ¨[Ð9Èôàðô % Q×'Ñ'ûð	(üs@   ‚B;ž/A% ÁA#ÁA% Á"B;Á#A% Á%B8Á86B3Â.B;Â3B8Â8B;i,  g       @c             ƒ  ó¬  K  — ddl }|j                  «       |z   }	 | j                  ||¬«      ƒ d{  –—† }|j                  dk(  r|S |j                  dk(  rt	        |j
                  xs dd¬«      ‚||j                  «       z
  }|dk  rt        d	|› d
|› d�d|j                  ¬«      ‚t        j                  t        ||«      «      ƒ d{  –—†  Œµ7 Œž7 Œ­w)a&  Poll until a snapshot reaches "ready" or "failed" status.

        Args:
            snapshot_id: Snapshot UUID.
            timeout: Maximum time to wait in seconds.
            poll_interval: Time between status checks in seconds.

        Returns:
            Snapshot in "ready" status.

        Raises:
            ResourceCreationError: If snapshot status becomes "failed".
            ResourceTimeoutError: If timeout expires.
            ResourceNotFoundError: If snapshot not found.
            SandboxClientError: For other errors.
        r   Nrš   rÇ   rÈ   zSnapshot build failedrã   rŸ   r	  rÉ   rÊ   rË   )
rÍ   rÎ   r  r´   r   rÏ   r   rg   rÐ   rÑ   )	rL   r†   r<   rÅ   r?   rÍ   rÒ   rã   rÓ   s	            r0   rá   z$AsyncSandboxClient.wait_for_snapshotµ  sà   è ø€ ó0 	à—>‘>Ó# gÑ-ˆØØ!×.Ñ.¨{ÀGÐ.ÓL×LˆHØ�‰ 'Ò)Ø�Ø�‰ (Ò*Ü+Ø×+Ñ+ÒFÐ/FØ",ôð ð ! 4§>¡>Ó#3Ñ3ˆIØ˜AŠ~Ü*Ø   Ð-?À¸yÈÐJØ",Ø (§¡ôð ô
 —-‘-¤ M°9Ó =Ó>×>Ð>ð! ØLøð ?ús"   ‚/C±C²BCÃ
CÃCÃC)
r;   úOptional[str]r<   Úfloatr=   r  r>   Úintr?   úOptional[Mapping[str, str]]©r½   Ústr)r½   r&   )r?   ÚRequestHeadersr½   zOptional[dict[str, str]])r½   r   )r½   ÚNone)r½   r8   )rq   zOptional[type]rr   zOptional[BaseException]rs   zOptional[Any]r½   r  )N)r†   r  rz   r  r{   r  r<   r  r|   úOptional[int]r}   r  r~   r  r   r  r€   r  r�   úOptional[SandboxMountConfig]r‚   úOptional[SandboxProxyConfig]r?   r  r½   r   )r†   r  rz   r  r{   r  r<   r  r‰   Úboolr|   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½   zlist[AsyncSandbox])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?   r  r½   r   )r{   r  rÂ   r  r·   r  r¾   r  r¿   z$Optional[DownloadContentDisposition]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<   r  r?   r  r½   r!   )r{   r  rþ   úUnion[str, os.PathLike[str]]r€   r  ræ   r"  rç   r  rè   r  ré   zOptional[Callable[[str], Any]]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  r  r  r  r  r  r?   r  r½   zlist[Snapshot])r†   r  r?   r  r½   r  )
r†   r  r<   r  rÅ   r  r?   r  r½   r!   )#Ú__name__Ú
__module__Ú__qualname__Ú__doc__rO   rT   ÚpropertyrY   r]   r_   ra   rc   rm   ro   rt   rw   rˆ   r„   r¤   rª   r¯   r²   rµ   r»   rÃ   rÔ   rØ   rÛ   rä   r  rý   r  r  r  rá   r5   r2   r0   r8   r8   L   sn  „ ñð  '+ØØ!%ØØ/3ñ(Að $ð(Að ð	(Að
 ð(Að ð(Að -ó(AóTð ò<ó ð<ó8:ó=ó
ó$2óó$ðà ðð )ðð ð	ð
 
óóAð &*ð\ð (,Ø"ØØ*.Ø37Ø#Ø#'Ø+/Ø59Ø59Ø"&ñ\à"ð\ð %ð	\ð
 ð\ð ð\ð (ð\ð $1ð\ð ð\ð !ð\ð )ð\ð 3ð\ð 3ð\ð  ð\ð 
ó\ð@ &*ðzð (,Ø"ØØ#Ø*.Ø37Ø#Ø#'Ø+/Ø59Ø59Ø"&ñzà"ðzð %ð	zð
 ðzð ðzð ðzð (ðzð $1ðzð ðzð !ðzð )ðzð 3ðzð 3ðzð  ðzð  
ó!zðz 7;ñØðØ%3ðà	óðD ,0ñØ(ðà	óð> #'Ø*.Ø37Ø"&ñ>àð>ð  ð	>ð
 (ð>ð $1ð>ð  ð>ð 
ó>ðB 7;ñ(Øð(Ø%3ð(à	ó(ð6 7;ñØðØ%3ðà	óðL #&Ø"&ñ6àð6ð ð6ð
  ð6ð  ð6ð 
ó6ðz -1Ø&*ØDHØ"&ñCàðCð ðCð
 *ðCð $ðCð BðCð  ðCð 
óCðR Ø"Ø"&ñ.?àð.?ð ð	.?ð
 ð.?ð  ð.?ð 
ó.?ðh Ø"&ñ$Sàð$Sð ð	$Sð
  ð$Sð 
ó$SðL JNõ (ðD &*ØØ"&ñ3
àð3
ð ð3
ð ð	3
ð #ð3
ð ð3
ð  ð3
ð 
ó3
ðr ,0ð	\ð 14Ø26Ø $Ø7;Ø#Ø#'ØØ"&ñ\àð\ð 1ð\ð )ð	\ð .ð\ð 0ð\ð ð\ð 5ð\ð ð\ð !ð\ð ð\ð  ð\ð 
ó\ðF '+Ø+/ØØ"&ñ4
àð4
ð ð4
ð
 $ð4
ð )ð4
ð ð4
ð  ð4
ð 
ó4
ðn >BñØðØ,:ðà	óð@ (,Ø#Ø $Ø"&ñ8ð %ð8ð ð	8ð
 ð8ð  ð8ð 
ó8ðv >Bñ(Øð(Ø,:ð(à	ó(ð< Ø"Ø"&ñ+?àð+?ð ð	+?ð
 ð+?ð  ð+?ð 
ô+?r2   r8   r  )r½   r  )>r&  Ú
__future__r   rg   Úosr÷   rô   Úcollections.abcr   r   Útypingr   r   r   r	   rH   Ú	langsmithr
   r,   Úlangsmith._openapi_clientr   Ú langsmith.sandbox._async_sandboxr   Úlangsmith.sandbox._clientr   r   r   r   r   r   Úlangsmith.sandbox._exceptionsr   r   r   r   r   Úlangsmith.sandbox._helpersr   r   r   r   r   Úlangsmith.sandbox._modelsr   r   r   r    r!   Úlangsmith.sandbox._mountsr"   r#   Úlangsmith.sandbox._proxy_configr$   Úlangsmith.sandbox._transportr%   Ú8langsmith._openapi_client.resources.sandboxes.registriesr&   r1   r6   r  r  r8   r5   r2   r0   Ú<module>r7     s”   ðÙ Lå "ã Û 	Û Û ß -ß 6Ó 6ã å 'Ý 4Ý 9÷÷ ÷õ ÷õ ÷õ ÷õ ?Ý <áõó
.ó+ð
 ˜' # s (Ñ+Ñ,€÷T?ò T?r2   