§
    ~Štjo²  ã                  ót  — 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 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, ddl-m.Z.m/Z/ ddl0m1Z1 ddl2m3Z3 erddl4m5Z5 dd„Z6dd„Z7ee	e8e8f                  Z9 G d„ d¦  «        Z:dS )zFAsync SandboxClient class for interacting with the sandbox server API.é    )ÚannotationsN)ÚCallableÚMapping)ÚTYPE_CHECKINGÚAnyÚOptionalÚUnion)Úutils)ÚAsyncLangsmith)ÚAsyncSandbox)ÚSandboxClientÚ_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ÚResourceStatusÚSnapshot)ÚSandboxMountConfigÚ"validate_mount_config_proxy_config)ÚSandboxProxyConfig)ÚAsyncRetryTransport)ÚAsyncRegistriesResourceÚreturnÚstrc                 ó^   — t          j        dd¬¦  «        } |                      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    ú]/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langsmith/sandbox/_async_client.pyÚ_get_default_api_endpointr0   8   s5   € õ
 Ô 
Ð4UÐVÑVÔV€DØ�kŠk˜#ÑÔÐ-Ð-Ð-Ð-ó    úOptional[str]c                 ó*   — t          j        d¦  «        S )z)Get the default API key from environment.ÚAPI_KEY)r+   r,   © r1   r/   Ú_get_default_api_keyr6   A   s   € åÔ 	Ñ*Ô*Ð*r1   c                  óæ  — e Zd ZdZddddddœdsd„Zdtd„Zedud„¦   «         Zdvd„Zdvd„Z	dwd„Z
dxd„Zdxd„Zdyd„Zdzd%„Zdtd&„Z	 d{ddd'ddddddddd(œd|d7„Z	 d{ddd'd8ddddddddd9œd}d<„Zdd=œd~d>„Zdd=œdd@„ZdddddAœd€dC„Zdd=œd�dD„Zdd=œd‚dF„ZdGddHœdƒdL„ZdMdNddOœd„dQ„ZdMddRœd…dS„Zdd=œd�dT„ZddUddVœd†dZ„Zd[ddddddUdd\œd‡dd„ZdddUddeœdˆdg„Zdd=œd‰dh„ZdddddiœdŠdn„Zdd=œd‹do„Z dpdqddOœdŒdr„Z!dS )�Ú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Úheadersr;   r2   r<   Úfloatr=   r>   Úintr?   úOptional[Mapping[str, str]]c               ó€  — |pt          ¦   «                              d¦  «        | _        |pt          ¦   «         }|| _        || _        || _        |rt          |¦  «        ni | _        i }|r||d<   | j        rt          || j        ¦  «        }t          |¬¦  «        }t          j        |||¬¦  «        | _        d| _        dS )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)r0   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_headersrD   s	            r/   Ú__init__zAsyncSandboxClient.__init__W   sÚ   € ð2 'ÐEÕ*CÑ*EÔ*E×MÒMÈcÑRÔRˆŒØ"Ð<Õ&:Ñ&<Ô&<ÐØ(ˆŒØˆŒØ'ˆÔØAHÐ0Pµ°W±´°ÈbˆÔØ)+ˆØð 	;Ø*:ˆN˜;Ñ'ØÔ ð 	RÝ*¨>¸4Ô;PÑQÔQˆNÝ'°KÐ@Ñ@Ô@ˆ	ÝÔ&Ø¨¸.ð
ñ 
ô 
ˆŒ
ð =AˆÔÐÐr1   r$   r%   c                ó‚   — d}| j                              |¦  «        r| j         dt          |¦  «         …         S | j         S )z>Return the API root URL, without the ``/v2/sandboxes`` suffix.r*   N)rE   ÚendswithÚlen)rO   Úsuffixs     r/   Ú	_api_rootzAsyncSandboxClient._api_root�   s@   € à ˆØŒ>×"Ò" 6Ñ*Ô*ð 	2Ø”> .¥S¨¡[¤[ L .Ô1Ð1ØŒ~Ðr1   r#   c                óœ   — | j         €5t          | j        |                      ¦   «         | j        p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)rN   r   rF   rW   rJ   Ú	sandboxesÚ
registries©rO   s    r/   r\   zAsyncSandboxClient.registriesˆ   sR   € ð* Ô"Ð*Ý&4ØœØŸšÑ)Ô)Ø $Ô 5Ð =¸ð'ñ 'ô 'ˆDÔ#ð
 Ô&Ô0Ô;Ð;r1   ÚRequestHeadersúOptional[dict[str, str]]c                ó>   — |€dS t          | j        j        |¦  «        S )z8Merge default client headers with per-request overrides.N)r   rM   r?   ©rO   r?   s     r/   Ú_request_headersz#AsyncSandboxClient._request_headers¥   s!   € àˆ?Ø�4Ý˜TœZÔ/°Ñ9Ô9Ð9r1   c                óB   — | j         s|€dS 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)rJ   r   ra   s     r/   Ú_ws_default_headersz&AsyncSandboxClient._ws_default_headers«   s+   € ð Ô$ð 	¨¨Ø�4Ý˜TÔ2°GÑ<Ô<Ð<r1   r   c                ó`   — t          | j        | j        | j        | j        | j        p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   rE   rG   rF   rH   rJ   r]   s    r/   Úto_synczAsyncSandboxClient.to_syncµ   s;   € õ ØœØ”MØ”MØÔ)ØÔ)Ð1¨Tð
ñ 
ô 
ð 	
r1   ÚNonec              ƒ  ó˜   K  — | j                              ¦   «         ƒ d{V —† | j        �!| j                             ¦   «         ƒ d{V —† dS dS )zClose the async HTTP client.N)rM   ÚacloserN   Úcloser]   s    r/   ri   zAsyncSandboxClient.acloseÇ   sj   è è € àŒj×ÒÑ!Ô!Ð!Ð!Ð!Ð!Ð!Ð!Ð!ØÔ"Ð.ØÔ)×/Ò/Ñ1Ô1Ð1Ð1Ð1Ð1Ð1Ð1Ð1Ð1Ð1ð /Ð.r1   c                ó
  — 	 | j         j        sd	 t          j        ¦   «         }|                     ¦   «         s)|                     |                      ¦   «         ¦  «         dS dS # t          $ r Y dS w xY wdS # t          $ r Y dS 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)rM   Ú	is_closedÚasyncioÚget_running_loopÚcreate_taskri   ÚRuntimeErrorÚ	Exception)rO   Úloops     r/   Ú__del__zAsyncSandboxClient.__del__Í   sµ   € ð		Ø”:Ô'ð ðÝ"Ô3Ñ5Ô5�DØŸ>š>Ñ+Ô+ð 8Ø×(Ò(¨¯ª©¬Ñ7Ô7Ð7Ð7Ð7ð8ð 8øå#ð ð ð Ø�D�Dðøøøðð øõ ð 	ð 	ð 	ØˆDˆDð	øøøs/   ‚A4 �AA! Á!
A/Á+A4 Á.A/Á/A4 Á4
BÂBc              ƒ  ó
   K  — | S )zEnter async context manager.r5   r]   s    r/   Ú
__aenter__zAsyncSandboxClient.__aenter__ß   s   è è € àˆr1   Úexc_typeúOptional[type]Úexc_valúOptional[BaseException]Úexc_tbúOptional[Any]c              ƒ  ó>   K  — |                       ¦   «         ƒ d{V —† dS )zExit async context manager.N)ri   )rO   rv   rx   rz   s       r/   Ú	__aexit__zAsyncSandboxClient.__aexit__ã   s.   è è € ð �kŠk‰mŒmÐÐÐÐÐÐÐÐÐr1   c                ó   — d| j         › d�S )z�Return a string representation of the instance.

        Returns:
            The string representation of the instance.
        zAsyncSandboxClient (API URL: ú))rE   r]   s    r/   Ú__repr__zAsyncSandboxClient.__repr__ì   s   € ð A¨t¬~Ð@Ð@Ð@Ð@r1   é   ©Úsnapshot_nameÚnamer<   Úidle_ttl_secondsÚdelete_after_stop_secondsÚvcpusÚ	mem_bytesÚfs_capacity_bytesÚmount_configÚproxy_configr?   Úsnapshot_idrƒ   r„   r…   úOptional[int]r†   r‡   rˆ   r‰   rŠ   úOptional[SandboxMountConfig]r‹   úOptional[SandboxProxyConfig]r   c             ƒ  óf   K  — |                       |||||||||	|
||¬¦  «        ƒ d{V —†}d|_        |S )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.
        r‚   NT)Úcreate_sandboxÚ_auto_delete)rO   rŒ   rƒ   r„   r<   r…   r†   r‡   rˆ   r‰   rŠ   r‹   r?   Úsbs                 r/   ÚsandboxzAsyncSandboxClient.sandboxø   ss   è è € ðZ ×&Ò&ØØ'ØØØ-Ø&?ØØØ/Ø%Ø%Øð 'ñ 
ô 
ð 
ð 
ð 
ð 
ð 
ð 
ˆð ˆŒØˆ	r1   T)rƒ   r„   r<   Úwait_for_readyr…   r†   r‡   rˆ   r‰   rŠ   r‹   r?   r•   Úboolc             ƒ  óŒ  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                             ||||                      |¦  «        ¬¦  «        ƒ d
{V —†}|                     ¦   «          t          j	        | 
                    ¦   «         | d¬¦  «        S # t          j        $ r}t          |¦  «         ‚ d
}~ww xY 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Œ   rƒ   r<   r„   Nr‡   rˆ   r‰   rŠ   r‹   r�   )Újsonr<   r?   F©ÚclientÚauto_delete)Ú
ValueErrorr   rE   r    rM   Úpostrb   Úraise_for_statusr   Ú	from_dictr™   rK   ÚHTTPStatusErrorr   )rO   rŒ   rƒ   r„   r<   r•   r…   r†   r‡   rˆ   r‰   rŠ   r‹   r?   ÚurlÚpayloadÚhttp_timeoutÚresponseÚes                      r/   r‘   z!AsyncSandboxClient.create_sandboxV  s  è è € ðR ð 	W˜=ð 	WÝÐUÑVÔVÐVÝÐ%Ð'9Ñ:Ô:Ð:ÝÐ.Ð0KÑLÔLÐLà”Ð'Ð'Ð'ˆð ˜nð#
ˆð ð 	1Ø%0ˆG�MÑ"Øð 	5Ø'4ˆG�OÑ$Øð 	)Ø!(ˆG�IÑØð 	#Ø"ˆG�F‰OØÐ'Ø*:ˆGÐ&Ñ'Ø$Ð0Ø3LˆGÐ/Ñ0ØÐØ$ˆG�GÑØÐ Ø#,ˆG�KÑ ØÐ(Ø+<ˆGÐ'Ñ(ØÐ#Ý.¨|¸\ÑJÔJÐJØ&2ˆG�NÑ#ØÐ#Ø&2ˆG�NÑ#à)7Ð?˜ "™˜¸Rˆð	Ø!œZŸ_š_ØØØ$Ø×-Ò-¨gÑ6Ô6ð	 -ñ ô ð ð ð ð ð ð ˆHð ×%Ò%Ñ'Ô'Ð'ÝÔ)Ø—’‘”¨¸%ðñ ô ð øõ Ô$ð 	ð 	ð 	Ý)¨!Ñ,Ô,Ð,Øøøøøð	øøøs   Â+A3D ÄEÄ.D>Ä>E©r?   c             ƒ  ó¸  K  — | j         › dt          |¦  «        › �}	 | j                             ||                      |¦  «        ¬¦  «        ƒ d{V —†}|                     ¦   «          t          j        |                     ¦   «         | d¬¦  «        S # t          j
        $ r;}|j        j        dk    rt          d|› d�d	¬
¦  «        |‚t          |¦  «         ‚ d}~ww xY 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.
        ú/boxes/r§   NFrš   é”  ú	Sandbox 'ú' not foundr”   ©Úresource_type)rE   r   rM   Úgetrb   rŸ   r   r    r™   rK   r¡   r¥   Ústatus_coder   r   ©rO   r„   r?   r¢   r¥   r¦   s         r/   Úget_sandboxzAsyncSandboxClient.get_sandboxÒ  s  è è € ð" ”ÐCÐCÕ(;¸DÑ(AÔ(AÐCÐCˆð	Ø!œZŸ^š^¨C¸×9NÒ9NÈwÑ9WÔ9W˜^ÑXÔXÐXÐXÐXÐXÐXÐXˆHØ×%Ò%Ñ'Ô'Ð'ÝÔ)Ø—’‘”¨¸%ðñ ô ð øõ Ô$ð 	ð 	ð 	ØŒzÔ%¨Ò,Ð,Ý+Ø1 Ð1Ð1Ð1Àðñ ô àðõ % QÑ'Ô'Ð'Øøøøøð	øøøs   �A1B ÂCÂ6CÃCúlist[AsyncSandbox]c             ƒ  ó²  ‡ K  — ‰ j         › d�}	 ‰ j                             |‰                      |¦  «        ¬¦  «        ƒ d{V —†}|                     ¦   «          |                     ¦   «         }ˆ fd„|                     dg ¦  «        D ¦   «         S # t          j        $ r9}|j        j	        dk    rt          d|› d�¦  «        |‚t          |¦  «         ‚ d}~ww xY w)	zRList all Sandboxes.

        Returns:
            List of AsyncSandboxes.
        r˜   r§   Nc                ó>   •— g | ]}t          j        |‰d ¬¦  «        ‘ŒS )Frš   )r   r    )Ú.0ÚcrO   s     €r/   ú
<listcomp>z5AsyncSandboxClient.list_sandboxes.<locals>.<listcomp>  s;   ø€ ð ð ð àõ Ô& q°À5ÐIÑIÔIðð ð r1   r[   rª   úAPI endpoint not found: ú%. Check that api_endpoint is correct.©rE   rM   r¯   rb   rŸ   r™   rK   r¡   r¥   r°   r   r   )rO   r?   r¢   r¥   Údatar¦   s   `     r/   Úlist_sandboxesz!AsyncSandboxClient.list_sandboxesó  s!  øè è € ð ”Ð'Ð'Ð'ˆð	Ø!œZŸ^š^¨C¸×9NÒ9NÈwÑ9WÔ9W˜^ÑXÔXÐXÐXÐXÐXÐXÐXˆHØ×%Ò%Ñ'Ô'Ð'Ø—=’=‘?”?ˆDðð ð ð àŸš +¨rÑ2Ô2ðñ ô ð øõ Ô$ð 	ð 	ð 	ØŒzÔ%¨Ò,Ð,Ý%ð;¨sð ;ð ;ð ;ñô ð ðõ % QÑ'Ô'Ð'Øøøøøð	øøøs   �A>B ÂCÂ4CÃC)Únew_namer…   r†   r?   r¾   c             ƒ  ót  K  — t          |d¦  «         t          |d¦  «         | j        › dt          |¦  «        › �}i }|�||d<   |�||d<   |�||d<   	 | j                             |||                      |¦  «        ¬¦  «        ƒ d{V —†}|                     ¦   «          t          j        | 	                    ¦   «         | d¬¦  «        S # t          j        $ ra}	|	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)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†   r©   Nr„   ©r™   r?   Frš   rª   r«   r¬   r”   r­   i™  zSandbox name 'z' already in use)r   rE   r   rM   Úpatchrb   rŸ   r   r    r™   rK   r¡   r¥   r°   r   r   r   )
rO   r„   r¾   r…   r†   r?   r¢   r£   r¥   r¦   s
             r/   Úupdate_sandboxz!AsyncSandboxClient.update_sandbox  sÁ  è è € õ> 	Ð%Ð'9Ñ:Ô:Ð:ÝÐ.Ð0KÑLÔLÐLà”ÐCÐCÕ(;¸DÑ(AÔ(AÐCÐCˆØ"$ˆØÐØ&ˆG�F‰OØÐ'Ø*:ˆGÐ&Ñ'Ø$Ð0Ø3LˆGÐ/Ñ0ð	Ø!œZ×-Ò-Ø˜'¨4×+@Ò+@ÀÑ+IÔ+Ið .ñ ô ð ð ð ð ð ð ˆHð ×%Ò%Ñ'Ô'Ð'ÝÔ)Ø—’‘”¨¸%ðñ ô ð øõ Ô$ð 	ð 	ð 	ØŒzÔ%¨Ò,Ð,Ý+Ø1 Ð1Ð1Ð1Àðñ ô àðð ŒzÔ%¨Ò,Ð,Ý/Ø? XÐ?Ð?Ð?Ø"+ðñ ô ð ðõ % QÑ'Ô'Ð'Øøøøøð	øøøs   ÁA2C ÃD7ÃAD2Ä2D7c             ƒ  ót  K  — | j         › dt          |¦  «        › �}	 | j                             ||                      |¦  «        ¬¦  «        ƒ d{V —†}|                     ¦   «          dS # t          j        $ r@}|j        j	        dk    rt          d|› d�d¬¦  «        |‚t          |¦  «         Y d}~dS d}~ww xY w)	zÅDelete a Sandbox.

        Args:
            name: Sandbox name.

        Raises:
            ResourceNotFoundError: If sandbox not found.
            SandboxClientError: For other errors.
        r©   r§   Nrª   r«   r¬   r”   r­   ©rE   r   rM   Údeleterb   rŸ   rK   r¡   r¥   r°   r   r   r±   s         r/   Údelete_sandboxz!AsyncSandboxClient.delete_sandboxN  s  è è € ð ”ÐCÐCÕ(;¸DÑ(AÔ(AÐCÐCˆð
	(Ø!œZ×.Ò.Ø˜T×2Ò2°7Ñ;Ô;ð /ñ ô ð ð ð ð ð ð ˆHð ×%Ò%Ñ'Ô'Ð'Ð'Ð'øÝÔ$ð 	(ð 	(ð 	(ØŒzÔ%¨Ò,Ð,Ý+Ø1 Ð1Ð1Ð1Àðñ ô àðõ % QÑ'Ô'Ð'Ð'Ð'Ð'Ð'Ð'Ð'øøøøð	(øøøó   �A	A( Á(B7Á75B2Â2B7r   c             ƒ  ó´  K  — | j         › dt          |¦  «        › d�}	 | j                             ||                      |¦  «        ¬¦  «        ƒ d{V —†}|                     ¦   «          t          j        |                     ¦   «         ¦  «        S # t          j
        $ r;}|j        j        dk    rt          d|› d�d¬	¦  «        |‚t          |¦  «         ‚ d}~ww xY 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.
        r©   z/statusr§   Nrª   r«   r¬   r”   r­   )rE   r   rM   r¯   rb   rŸ   r   r    r™   rK   r¡   r¥   r°   r   r   r±   s         r/   Úget_sandbox_statusz%AsyncSandboxClient.get_sandbox_statush  sÿ   è è € ð& ”ÐJÐJÕ(;¸DÑ(AÔ(AÐJÐJÐJˆð
	Ø!œZŸ^š^¨C¸×9NÒ9NÈwÑ9WÔ9W˜^ÑXÔXÐXÐXÐXÐXÐXÐXˆHØ×%Ò%Ñ'Ô'Ð'Ý!Ô+¨H¯MªM©O¬OÑ<Ô<Ð<øÝÔ$ð 	ð 	ð 	ØŒzÔ%¨Ò,Ð,Ý+Ø1 Ð1Ð1Ð1Àðñ ô àðõ % QÑ'Ô'Ð'Øøøøøð	øøøs   žA.B ÂCÂ6CÃCiX  ©Úexpires_in_secondsr?   ÚportrË   r   c             ƒ  ó  ‡ ‡‡‡‡K  — t          ‰‰¦  «         ‰ j        › dt          ‰¦  «        › d�}‰‰dœ}dˆˆˆˆˆ fd„}	 ‰ j                             ||‰                      ‰¦  «        ¬¦  «        ƒ d{V —†}|                     ¦   «          t          j        | 	                    ¦   «         |¬	¦  «        S # t          j        $ r;}	|	j        j        d
k    rt          d‰› d�d¬¦  «        |	‚t          |	¦  «         ‚ d}	~	ww xY 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.
        r©   z/service-url)rÌ   rË   r$   r   c               “  óF   •K  — ‰                      ‰‰‰ ‰¬¦  «        ƒ d {V —†S )NrÊ   )Úservice)rË   r?   r„   rÌ   rO   s   €€€€€r/   Ú
_refresherz.AsyncSandboxClient.service.<locals>._refresher«  sL   øè è € ØŸšØØØ#5Øð	 &ñ ô ð ð ð ð ð ð ð r1   rÀ   N)rÐ   rª   r«   r¬   r”   r­   )r$   r   )r   rE   r   rM   rž   rb   rŸ   r   r    r™   rK   r¡   r¥   r°   r   r   )
rO   r„   rÌ   rË   r?   r¢   r£   rÐ   r¥   r¦   s
   `````     r/   rÏ   zAsyncSandboxClient.service‰  sr  øøøøøè è € õ< 	  Ð&8Ñ9Ô9Ð9Ø”ÐOÐOÕ(;¸DÑ(AÔ(AÐOÐOÐOˆØÐ7IÐJÐJˆð	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð	Ø!œZŸ_š_Ø˜'¨4×+@Ò+@ÀÑ+IÔ+Ið -ñ ô ð ð ð ð ð ð ˆHð ×%Ò%Ñ'Ô'Ð'Ý"Ô,¨X¯]ª]©_¬_ÈÐTÑTÔTÐTøÝÔ$ð 	ð 	ð 	ØŒzÔ%¨Ò,Ð,Ý+Ø1 Ð1Ð1Ð1Àðñ ô àðõ % QÑ'Ô'Ð'Øøøøøð	øøøs   ÁA1B4 Â4C>Ã6C9Ã9C>éx   g      ð?)r<   Úpoll_intervalr?   rÒ   c             ƒ  óÖ  K  — ddl }|                     ¦   «         |z   }	 |                      ||¬¦  «        ƒ d{V —†}|j        dk    r|                      ||¬¦  «        ƒ d{V —†S |j        dk    rt          |j        pdd¬	¦  «        ‚||                     ¦   «         z
  }|dk    rt          d
|› d|› d�d|j        ¬¦  «        ‚t          j	        t          ||¦  «        ¦  «        ƒ d{V —† ŒÌ)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   NTr§   ÚreadyÚfailedzSandbox provisioning failedr”   r­   r«   ú' not ready after Ús©r®   Úlast_status)ÚtimeÚ	monotonicrÉ   Ústatusr²   r   Ústatus_messager   rm   ÚsleepÚmin)	rO   r„   r<   rÒ   r?   rÚ   ÚdeadlinerÜ   Ú	remainings	            r/   Úwait_for_sandboxz#AsyncSandboxClient.wait_for_sandboxÁ  sF  è è € ð6 	ˆˆˆà—>’>Ñ#Ô# gÑ-ˆð	?Ø×2Ò2°4ÀÐ2ÑIÔIÐIÐIÐIÐIÐIÐIˆFØŒ} Ò'Ð'Ø!×-Ò-¨d¸GÐ-ÑDÔDÐDÐDÐDÐDÐDÐDÐDØŒ} Ò(Ð(Ý+ØÔ)ÐJÐ-JØ"+ðñ ô ð ð ! 4§>¢>Ñ#3Ô#3Ñ3ˆIØ˜AŠ~ˆ~Ý*ØB ÐBÐB¸ÐBÐBÐBØ"+Ø &¤ðñ ô ð õ
 ”-¥ M°9Ñ =Ô =Ñ>Ô>Ð>Ð>Ð>Ð>Ð>Ð>Ð>ð!	?r1   ©r<   r?   c             ƒ  ó°  K  — | j         › dt          |¦  «        › d�}	 | j                             |i |                      |¦  «        ¬¦  «        ƒ d{V —†}|                     ¦   «          nQ# t          j        $ r?}|j        j	        dk    rt          d|› d�d¬	¦  «        |‚t          |¦  «         Y d}~nd}~ww xY w|                      |||¬
¦  «        ƒ d{V —†S )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.
        r©   z/startrÀ   Nrª   r«   r¬   r”   r­   rã   )rE   r   rM   rž   rb   rŸ   rK   r¡   r¥   r°   r   r   râ   )rO   r„   r<   r?   r¢   r¥   r¦   s          r/   Ústart_sandboxz AsyncSandboxClient.start_sandboxñ  s<  è è € ð, ”ÐIÐIÕ(;¸DÑ(AÔ(AÐIÐIÐIˆð
	(Ø!œZŸ_š_Ø˜" d×&;Ò&;¸GÑ&DÔ&Dð -ñ ô ð ð ð ð ð ð ˆHð ×%Ò%Ñ'Ô'Ð'Ð'øÝÔ$ð 	(ð 	(ð 	(ØŒzÔ%¨Ò,Ð,Ý+Ø1 Ð1Ð1Ð1Àðñ ô àðõ % QÑ'Ô'Ð'Ð'Ð'Ð'Ð'Ð'øøøøð	(øøøð ×*Ò*¨4¸È'Ð*ÑRÔRÐRÐRÐRÐRÐRÐRÐRs   žA
A) Á)B7Á85B2Â2B7c             ƒ  óx  K  — | j         › dt          |¦  «        › d�}	 | j                             |i |                      |¦  «        ¬¦  «        ƒ d{V —†}|                     ¦   «          dS # t          j        $ r@}|j        j	        dk    rt          d|› d�d¬	¦  «        |‚t          |¦  «         Y d}~dS d}~ww xY 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.
        r©   z/stoprÀ   Nrª   r«   r¬   r”   r­   )rE   r   rM   rž   rb   rŸ   rK   r¡   r¥   r°   r   r   r±   s         r/   Ústop_sandboxzAsyncSandboxClient.stop_sandbox  s  è è € ð ”ÐHÐHÕ(;¸DÑ(AÔ(AÐHÐHÐHˆð
	(Ø!œZŸ_š_Ø˜" d×&;Ò&;¸GÑ&DÔ&Dð -ñ ô ð ð ð ð ð ð ˆHð ×%Ò%Ñ'Ô'Ð'Ð'Ð'øÝÔ$ð 	(ð 	(ð 	(ØŒzÔ%¨Ò,Ð,Ý+Ø1 Ð1Ð1Ð1Àðñ ô àðõ % QÑ'Ô'Ð'Ð'Ð'Ð'Ð'Ð'Ð'øøøøð	(øøøs   žA
A* Á*B9Á95B4Â4B9é<   )Úregistry_idr<   r?   Údocker_imageré   r   c             ƒ  ó¬  K  — | j         › d�}|||dœ}|�||d<   	 | j                             |||                      |¦  «        ¬¦  «        ƒ d{V —†}	|	                     ¦   «          t          j        |	                     ¦   «         ¦  «        }
n'# t          j	        $ r}t          |¦  «         ‚ d}~ww xY w|                      |
j        ||¬¦  «        ƒ d{V —†S )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„   rê   r‰   Nré   rÀ   rã   )rE   rM   rž   rb   rŸ   r   r    r™   rK   r¡   r   Úwait_for_snapshotÚid)rO   r„   rê   r‰   ré   r<   r?   r¢   r£   r¥   Úsnapshotr¦   s               r/   Úcreate_snapshotz"AsyncSandboxClient.create_snapshot3  s:  è è € ð: ”Ð+Ð+Ð+ˆð Ø(Ø!2ð#
ð #
ˆð
 Ð"Ø%0ˆG�MÑ"ð	Ø!œZŸ_š_Ø˜'¨4×+@Ò+@ÀÑ+IÔ+Ið -ñ ô ð ð ð ð ð ð ˆHð ×%Ò%Ñ'Ô'Ð'ÝÔ)¨(¯-ª-©/¬/Ñ:Ô:ˆHˆHøÝÔ$ð 	ð 	ð 	Ý$ QÑ'Ô'Ð'Øøøøøð	øøøð ×+Ò+ØŒK °'ð ,ñ 
ô 
ð 
ð 
ð 
ð 
ð 
ð 
ð 	
s   ›A0B ÂB0ÂB+Â+B0ú.)ÚcontextÚ
build_argsÚtargetÚon_build_logr‡   rˆ   r<   r?   Ú
dockerfileúUnion[str, os.PathLike[str]]rò   ró   rô   rõ   úOptional[Callable[[str], Any]]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	¦  «        }|                      ||
||	||¬
¦  «        ƒ d{V —†4 ƒd{V —†	 }|                     |t          j	        t          |¦  «        ƒ d{V —†|
|¬¦  «        ƒ d{V —† |                     d|z   dz   |z   dz   |z   dz   |z   |
|¬¦  «        ƒ d{V —† |                     t          |||||||¬¦  «        |
|||¬¦  «        ƒ d{V —†}|j        dk    rt          dd¬¦  «        ‚|                      |j        ||||
|¬¦  «        ƒ d{V —†cddd¦  «        ƒd{V —† S # 1 ƒd{V —†swxY w Y   dS )ai  Build a snapshot from a local Dockerfile context.

        ``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”   Úwriterm   Ú	to_threadr   Úrunr   Ú	exit_coder   Úcapture_snapshotr„   )rO   r„   rö   r‰   rò   ró   rô   rõ   r‡   rˆ   r<   r?   Úcontext_pathrü   Úbuilder_nameÚ
build_rootrû   Ú
remote_tarrý   rþ   rÿ   r”   Úresults                          r/   Úcreate_snapshot_from_dockerfilez2AsyncSandboxClient.create_snapshot_from_dockerfileh  s˜  è è € õ, (CÀ:ÈwÑ'WÔ'WÑ$ˆ�nàB­4¬:©<¬<Ô+;¸C¸R¸CÔ+@ÐBÐBˆð Iµ´±´Ô1AÀ#À2À#Ô1FÐHÐHˆ
Ý"œ¨
°IÑ>Ô>ˆÝ”^ J°Ñ>Ô>ˆ
ØBµ´
±´Ô0@ÐBÐBˆ	Ý!œ z°?ÑCÔCˆÝ ”~ j°.ÑAÔAˆàŸšØØØØØ/Øð &ñ 
ô 
ð 
ð 
ð 
ð 
ð 
ð 
ð 6	ð 6	ð 6	ð 6	ð 6	ð 6	ð 6	ð 6	ð Ø—-’-ØÝÔ'Õ(@À,ÑOÔOÐOÐOÐOÐOÐOÐOØØð	  ñ ô ð ð ð ð ð ð ð ð —+’+ØØ ñ!à!ñ"ð !ñ!ð !ñ	!ð
 ñð ñð !ñ!ð  Øð ñ ô ð ð ð ð ð ð ð ð #Ÿ;š;Ý.Ø#1Ø#1Ø'Ø"/Ø!-Ø)Ø!ðñ ô ð  Ø&Ø&Øð 'ñ ô ð ð ð ð ð ð ˆFð Ô 1Ò$Ð$Ý+Ø6Ø",ðñ ô ð ð ×.Ò.Ø”ØØ&Ø"3ØØð /ñ ô ð ð ð ð ð ð ð_6	ð 6	ð 6	ð 6	ñ 6	ô 6	ð 6	ð 6	ð 6	ð 6	ð 6	ð 6	ð 6	ð 6	ð 6	ð 6	ð 6	ð 6	ð 6	ð 6	ð 6	ð 6	ð 6	ð 6	øøøð 6	ð 6	ð 6	ð 6	ð 6	ð 6	s   Ã3C&G,Ç,
G6Ç9G6r  Úsandbox_namec             ƒ  ó"  K  — | j         › dt          |¦  «        › d�}d|i}|�||d<   |�||d<   	 | j                             |||                      |¦  «        ¬¦  «        ƒ d{V —†}	|	                     ¦   «          t          j        |	                     ¦   «         ¦  «        }
nM# t          j
        $ r;}|j        j        dk    rt          d	|› d
�d¬¦  «        |‚t          |¦  «         ‚ d}~ww xY w|                      |
j        ||¬¦  «        ƒ d{V —†S )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©   z	/snapshotr„   Nrê   r‰   rÀ   rª   r«   r¬   r”   r­   rã   )rE   r   rM   rž   rb   rŸ   r   r    r™   rK   r¡   r¥   r°   r   r   rí   rî   )rO   r  r„   rê   r‰   r<   r?   r¢   r£   r¥   rï   r¦   s               r/   r  z#AsyncSandboxClient.capture_snapshotÅ  sˆ  è è € ð8 ”ÐTÐTÕ(;¸LÑ(IÔ(IÐTÐTÐTˆà#)¨4 .ˆØÐ#Ø&2ˆG�NÑ#ØÐ(Ø+<ˆGÐ'Ñ(ð	Ø!œZŸ_š_Ø˜'¨4×+@Ò+@ÀÑ+IÔ+Ið -ñ ô ð ð ð ð ð ð ˆHð ×%Ò%Ñ'Ô'Ð'ÝÔ)¨(¯-ª-©/¬/Ñ:Ô:ˆHˆHøÝÔ$ð 	ð 	ð 	ØŒzÔ%¨Ò,Ð,Ý+Ø9 Ð9Ð9Ð9Èðñ ô àðõ % QÑ'Ô'Ð'Øøøøøð	øøøð ×+Ò+ØŒK °'ð ,ñ 
ô 
ð 
ð 
ð 
ð 
ð 
ð 
ð 	
s   °A0B! Â!C+Â06C&Ã&C+c             ƒ  ó²  K  — | j         › dt          |¦  «        › �}	 | j                             ||                      |¦  «        ¬¦  «        ƒ d{V —†}|                     ¦   «          t          j        |                     ¦   «         ¦  «        S # t          j
        $ r;}|j        j        dk    rt          d|› d�d¬¦  «        |‚t          |¦  «         ‚ d}~ww xY 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­   )rE   r   rM   r¯   rb   rŸ   r   r    r™   rK   r¡   r¥   r°   r   r   ©rO   rŒ   r?   r¢   r¥   r¦   s         r/   Úget_snapshotzAsyncSandboxClient.get_snapshotû  sü   è è € ð ”ÐNÐNÕ,?ÀÑ,LÔ,LÐNÐNˆð
	Ø!œZŸ^š^¨C¸×9NÒ9NÈwÑ9WÔ9W˜^ÑXÔXÐXÐXÐXÐXÐXÐXˆHØ×%Ò%Ñ'Ô'Ð'ÝÔ% h§m¢m¡o¤oÑ6Ô6Ð6øÝÔ$ð 	ð 	ð 	ØŒzÔ%¨Ò,Ð,Ý+Ø9 Ð9Ð9Ð9Èðñ ô àðõ % QÑ'Ô'Ð'Øøøøøð	øøøs   �A.B ÂCÂ6CÃC)Úname_containsÚlimitÚoffsetr?   r  r  r  úlist[Snapshot]c             ƒ  óà  K  — | j         › d�}i }|�||d<   |�||d<   |�||d<   	 | j                             ||pd|                      |¦  «        ¬¦  «        ƒ d{V —†}|                     ¦   «          |                     ¦   «         }d„ |                     dg ¦  «        D ¦   «         S # t          j        $ r9}	|	j        j	        d	k    rt          d
|› d�¦  «        |	‚t          |	¦  «         ‚ d}	~	ww xY 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?   c                ó6   — g | ]}t          j        |¦  «        ‘ŒS r5   )r   r    )r¶   r×   s     r/   r¸   z5AsyncSandboxClient.list_snapshots.<locals>.<listcomp>H  s#   € ÐMÐMÐM¨a•HÔ& qÑ)Ô)ÐMÐMÐMr1   Ú	snapshotsrª   r¹   rº   r»   )
rO   r  r  r  r?   r¢   r  r¥   r¼   r¦   s
             r/   Úlist_snapshotsz!AsyncSandboxClient.list_snapshots  sY  è è € ð< ”Ð+Ð+Ð+ˆà!#ˆØÐ$Ø&3ˆF�?Ñ#ØÐØ#ˆF�7‰OØÐØ%ˆF�8Ñð	Ø!œZŸ^š^ØØ�~ Ø×-Ò-¨gÑ6Ô6ð ,ñ ô ð ð ð ð ð ð ˆHð
 ×%Ò%Ñ'Ô'Ð'Ø—=’=‘?”?ˆDØMÐM°4·8²8¸KÈÑ3LÔ3LÐMÑMÔMÐMøÝÔ$ð 	ð 	ð 	ØŒzÔ%¨Ò,Ð,Ý%ð;¨sð ;ð ;ð ;ñô ð ðõ % QÑ'Ô'Ð'Øøøøøð	øøøs   ¥A?B% Â%C-Â44C(Ã(C-c             ƒ  ót  K  — | j         › dt          |¦  «        › �}	 | j                             ||                      |¦  «        ¬¦  «        ƒ d{V —†}|                     ¦   «          dS # t          j        $ r@}|j        j	        dk    rt          d|› d�d¬¦  «        |‚t          |¦  «         Y d}~dS d}~ww xY 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­   rÄ   r  s         r/   Údelete_snapshotz"AsyncSandboxClient.delete_snapshotR  s  è è € ð ”ÐNÐNÕ,?ÀÑ,LÔ,LÐNÐNˆð
	(Ø!œZ×.Ò.Ø˜T×2Ò2°7Ñ;Ô;ð /ñ ô ð ð ð ð ð ð ˆHð ×%Ò%Ñ'Ô'Ð'Ð'Ð'øÝÔ$ð 	(ð 	(ð 	(ØŒzÔ%¨Ò,Ð,Ý+Ø9 Ð9Ð9Ð9Èðñ ô àðõ % QÑ'Ô'Ð'Ð'Ð'Ð'Ð'Ð'Ð'øøøøð	(øøørÇ   i,  g       @c             ƒ  ó   K  — ddl }|                     ¦   «         |z   }	 |                      ||¬¦  «        ƒ d{V —†}|j        dk    r|S |j        dk    rt	          |j        pdd¬	¦  «        ‚||                     ¦   «         z
  }|dk    rt          d
|› d|› d�d|j        ¬¦  «        ‚t          j        t          ||¦  «        ¦  «        ƒ d{V —† Œ±)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   NTr§   rÔ   rÕ   zSnapshot build failedrï   r­   r  rÖ   r×   rØ   )
rÚ   rÛ   r  rÜ   r   rÝ   r   rm   rÞ   rß   )	rO   rŒ   r<   rÒ   r?   rÚ   rà   rï   rá   s	            r/   rí   z$AsyncSandboxClient.wait_for_snapshotl  s   è è € ð0 	ˆˆˆà—>’>Ñ#Ô# gÑ-ˆð	?Ø!×.Ò.¨{ÀGÐ.ÑLÔLÐLÐLÐLÐLÐLÐLˆHØŒ 'Ò)Ð)Ø�ØŒ (Ò*Ð*Ý+ØÔ+ÐFÐ/FØ",ðñ ô ð ð ! 4§>¢>Ñ#3Ô#3Ñ3ˆIØ˜AŠ~ˆ~Ý*ØJ ÐJÐJÀÐJÐJÐJØ",Ø (¤ðñ ô ð õ
 ”-¥ M°9Ñ =Ô =Ñ>Ô>Ð>Ð>Ð>Ð>Ð>Ð>Ð>ð!	?r1   )
r;   r2   r<   r@   r=   r2   r>   rA   r?   rB   ©r$   r%   )r$   r#   )r?   r^   r$   r_   )r$   r   )r$   rg   )r$   r8   )rv   rw   rx   ry   rz   r{   r$   rg   )N)rŒ   r2   rƒ   r2   r„   r2   r<   rA   r…   r�   r†   r�   r‡   r�   rˆ   r�   r‰   r�   rŠ   rŽ   r‹   r�   r?   r^   r$   r   )rŒ   r2   rƒ   r2   r„   r2   r<   rA   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¾   r2   r…   r�   r†   r�   r?   r^   r$   r   )r„   r%   r?   r^   r$   rg   )r„   r%   r?   r^   r$   r   )
r„   r%   rÌ   rA   rË   rA   r?   r^   r$   r   )
r„   r%   r<   rA   rÒ   r@   r?   r^   r$   r   )r„   r%   r<   rA   r?   r^   r$   r   )r„   r%   rê   r%   r‰   rA   ré   r2   r<   rA   r?   r^   r$   r   )r„   r%   rö   r÷   r‰   rA   rò   r÷   ró   rB   rô   r2   rõ   rø   r‡   r�   rˆ   r�   r<   rA   r?   r^   r$   r   )r  r%   r„   r%   rê   r2   r‰   r�   r<   rA   r?   r^   r$   r   )rŒ   r%   r?   r^   r$   r   )
r  r2   r  r�   r  r�   r?   r^   r$   r  )rŒ   r%   r?   r^   r$   rg   )
rŒ   r%   r<   rA   rÒ   r@   r?   r^   r$   r   )"Ú__name__Ú
__module__Ú__qualname__Ú__doc__rR   rW   Úpropertyr\   rb   rd   rf   ri   rs   ru   r}   r€   r”   r‘   r²   r½   rÂ   rÆ   rÉ   rÏ   râ   rå   rç   rð   r  r  r  r"  r$  rí   r5   r1   r/   r8   r8   I   si  € € € € € ðð ð  '+ØØ!%ØØ/3ð(Að (Að (Að (Að (Að (AðTð ð ð ð ð<ð <ð <ñ „Xð<ð8:ð :ð :ð :ð=ð =ð =ð =ð
ð 
ð 
ð 
ð$2ð 2ð 2ð 2ðð ð ð ð$ð ð ð ðð ð ð ðAð Að Að Að &*ð\ð (,Ø"ØØ*.Ø37Ø#Ø#'Ø+/Ø59Ø59Ø"&ð\ð \ð \ð \ð \ð \ð@ &*ðzð (,Ø"ØØ#Ø*.Ø37Ø#Ø#'Ø+/Ø59Ø59Ø"&ðzð zð zð zð zð zðz 7;ðð ð ð ð ð ðD ,0ðð ð ð ð ð ð> #'Ø*.Ø37Ø"&ð>ð >ð >ð >ð >ð >ðB 7;ð(ð (ð (ð (ð (ð (ð6 7;ðð ð ð ð ð ðL #&Ø"&ð6ð 6ð 6ð 6ð 6ð 6ðx Ø"Ø"&ð.?ð .?ð .?ð .?ð .?ð .?ðh Ø"&ð$Sð $Sð $Sð $Sð $Sð $SðL JNð (ð (ð (ð (ð (ð (ðD &*ØØ"&ð3
ð 3
ð 3
ð 3
ð 3
ð 3
ðv 14Ø26Ø $Ø7;Ø#Ø#'ØØ"&ð[ð [ð [ð [ð [ð [ðD '+Ø+/ØØ"&ð4
ð 4
ð 4
ð 4
ð 4
ð 4
ðn >Bðð ð ð ð ð ð@ (,Ø#Ø $Ø"&ð8ð 8ð 8ð 8ð 8ð 8ðv >Bð(ð (ð (ð (ð (ð (ð< Ø"Ø"&ð+?ð +?ð +?ð +?ð +?ð +?ð +?ð +?r1   r8   r&  )r$   r2   );r*  Ú
__future__r   rm   Úosr  r  Úcollections.abcr   r   Útypingr   r   r   r	   rK   Ú	langsmithr
   r+   Úlangsmith._openapi_clientr   Ú langsmith.sandbox._async_sandboxr   Úlangsmith.sandbox._clientr   r   r   r   r   Úlangsmith.sandbox._exceptionsr   r   r   r   r   Úlangsmith.sandbox._helpersr   r   r   r   r   Úlangsmith.sandbox._modelsr   r   r   Úlangsmith.sandbox._mountsr   r    Úlangsmith.sandbox._proxy_configr!   Úlangsmith.sandbox._transportr"   Ú8langsmith._openapi_client.resources.sandboxes.registriesr#   r0   r6   r%   r^   r8   r5   r1   r/   ú<module>r;     s°  ðØ LÐ Là "Ð "Ð "Ð "Ð "Ð "à €€€Ø 	€	€	€	Ø Ð Ð Ð Ø €€€Ø -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6à €€€à 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9ðð ð ð ð ð ð ð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð
ð ð ð ð ð ð ð ð ?Ð >Ð >Ð >Ð >Ð >Ø <Ð <Ð <Ð <Ð <Ð <àð ðð ð ð ð ð ð
.ð .ð .ð .ð+ð +ð +ð +ð
 ˜' # s (Ô+Ô,€ðN?ð N?ð N?ð N?ð N?ñ N?ô N?ð N?ð N?ð N?r1   