§
    ~Štj¿  ã                  ó¬  — 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ZddlZddl	m
Z
mZ ddlmZ ddlmZmZmZmZ ddlmZ ddl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* ddl+m,Z,m-Z- ddl.m/Z/ ddl0m1Z1 ddl2m3Z3 erddl4m5Z5 ddl6m7Z7 d.d„Z8d/d„Z9eee:e:f                  Z;d0d„Z<d1d„Z=d2d"„Z>d3d+„Z? G d,„ d-¦  «        Z@dS )4zEMain SandboxClient class for interacting with the sandbox server API.é    )ÚannotationsN)ÚCallableÚMapping)ÚPath)ÚTYPE_CHECKINGÚAnyÚOptionalÚUnion)Úquote)Úutils)Ú	Langsmith)ÚResourceCreationErrorÚResourceNameConflictErrorÚResourceNotFoundErrorÚResourceTimeoutErrorÚSandboxAPIError)Úhandle_client_http_errorÚhandle_sandbox_creation_errorÚmerge_headersÚvalidate_service_paramsÚvalidate_ttl)ÚResourceStatusÚ
ServiceURLÚSnapshot)ÚSandboxMountConfigÚ"validate_mount_config_proxy_config)ÚSandboxProxyConfig)ÚSandbox)ÚRetryTransport)ÚRegistriesResource©ÚAsyncSandboxClientÚ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    úW/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langsmith/sandbox/_client.pyÚ_get_default_api_endpointr/   6   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+   © r0   r.   Ú_get_default_api_keyr5   ?   s   € åÔ 	Ñ*Ô*Ð*r0   Úvaluec                óF   — | st          d¦  «        ‚t          | d¬¦  «        S )zCQuote a user-controlled value for use as a single URL path segment.z+URL path segment must be a non-empty stringÚ )Úsafe)Ú
ValueErrorr   )r6   s    r.   Ú_quote_path_segmentr;   G   s-   € àð HÝÐFÑGÔGÐGÝ�˜RÐ Ñ Ô Ð r0   Úcontext_pathr   Úbytesc                ó¨  — t          j        ¦   «         }t          j        |d¬¦  «        5 }t	          |                      d¦  «        ¦  «        D ]Z}|                     | ¦  «        }|j        r|j        d         dk    rŒ0|                     || 	                    ¦   «         d¬¦  «         Œ[	 d d d ¦  «         n# 1 swxY w Y   | 
                    ¦   «         S )NÚw)ÚfileobjÚmodeÚ*r   z.gitF)ÚarcnameÚ	recursive)ÚioÚBytesIOÚtarfileÚopenÚsortedÚrglobÚrelative_toÚpartsÚaddÚas_posixÚgetvalue)r<   ÚbufÚtarÚpathÚrels        r.   Ú_make_docker_context_tarrT   N   s  € Ý
Œ*‰,Œ,€CÝ	Œ˜c¨Ð	,Ñ	,Ô	,ð C°Ý˜<×-Ò-¨cÑ2Ô2Ñ3Ô3ð 	Cð 	CˆDØ×"Ò" <Ñ0Ô0ˆCØŒyð ˜SœY qœ\¨VÒ3Ð3ØØ�GŠG�D #§,¢,¡.¤.¸EˆGÑBÔBÐBÐBð		CðCð Cð Cñ Cô Cð Cð Cð Cð Cð Cð Cøøøð Cð Cð Cð Cð �<Š<‰>Œ>Ðs   ªA>B5Â5B9Â<B9Ú
dockerfileúUnion[str, os.PathLike[str]]Úcontextútuple[Path, str]c                ó:  — t          |¦  «                             ¦   «                              ¦   «         }t          | ¦  «                             ¦   «         }|                     ¦   «         s||z  }|                     ¦   «         }|                     ¦   «         st          d|› �¦  «        ‚|                     ¦   «         st          d|› �¦  «        ‚	 |                     |¦  «        }n"# t
          $ r}t          d¦  «        |‚d }~ww xY w||                     ¦   «         fS )Nzcontext must be a directory: zdockerfile must be a file: z!dockerfile must be inside context)	r   Ú
expanduserÚresolveÚis_absoluteÚis_dirr:   Úis_filerK   rN   )rU   rW   r<   Údockerfile_pathÚdockerfile_relÚexcs         r.   Ú_resolve_dockerfile_contextrb   Y   s-  € õ ˜‘=”=×+Ò+Ñ-Ô-×5Ò5Ñ7Ô7€LÝ˜:Ñ&Ô&×1Ò1Ñ3Ô3€OØ×&Ò&Ñ(Ô(ð 9Ø&¨Ñ8ˆØ%×-Ò-Ñ/Ô/€OØ×ÒÑ Ô ð IÝÐG¸ÐGÐGÑHÔHÐHØ×"Ò"Ñ$Ô$ð JÝÐH°ÐHÐHÑIÔIÐIðGØ(×4Ò4°\ÑBÔBˆˆøÝð Gð Gð GÝÐ<Ñ=Ô=À3ÐFøøøøðGøøøà˜×0Ò0Ñ2Ô2Ð2Ð2s   ÃC% Ã%
DÃ/C?Ã?DÚremote_contextr`   Ú	image_refÚbuildkit_rootÚbuildkit_runÚ
build_argsúOptional[Mapping[str, str]]Útargetc                ór  — t          j        | |¦  «        }t          j        |¦  «        }t          j        |¦  «        }	t          j        |d¦  «        }
ddd|
z   ddddd	d
| z   d	d|z   dd|	z   dd|z   g}|�|                     dd|z   g¦  «         t          |pi                      ¦   «         ¦  «        D ]"\  }}|                     dd|› d|› �g¦  «         Œ#dt          j        |¦  «        › dt          j        |¦  «        › dt          j        d|
z   ¦  «        › dt          j        |¦  «        › dt          j        |dz   ¦  «        › dt          j        d|
z   ¦  «        › dt          j        |dz   ¦  «        › dt          j        |dz   ¦  «        › dt          j        |¦  «        › dt          j        |¦  «        › d�S )Nzbuildkitd.sockÚbuildctlz--addrzunix://Úbuildz--progress=plainz
--frontendzdockerfile.v0z--localzcontext=zdockerfile=z--optz	filename=z--outputztype=docker,name=ztarget=z
build-arg:ú=zset -euo pipefail
mkdir -p ú z
buildkitd --addr z --root zq --oci-worker=true --containerd-worker=false --oci-worker-snapshotter=native --oci-worker-binary buildkit-runc > z/buildkitd.logz— 2>&1 &
buildkitd_pid=$!
cleanup() { kill "$buildkitd_pid" >/dev/null 2>&1 || true; }
trap cleanup EXIT
for i in $(seq 1 300); do
  if buildctl --addr zi debug workers >/dev/null 2>&1; then break; fi
  if ! kill -0 "$buildkitd_pid" >/dev/null 2>&1; then cat z+; exit 1; fi
  if [ "$i" = 300 ]; then cat z¬; exit 1; fi
  sleep 0.1
done
for i in $(seq 1 300); do
  if docker info >/dev/null 2>&1; then break; fi
  if [ "$i" = 300 ]; then docker info; exit 1; fi
  sleep 0.1
done
z | docker load
rm -rf z	 || true
)	Ú	posixpathÚjoinÚdirnameÚbasenameÚextendrI   ÚitemsÚshlexr   )rc   r`   rd   re   rf   rg   ri   Údockerfile_remoteÚdockerfile_dirÚdockerfile_nameÚsocket_pathrk   Úkeyr6   s                 r.   Ú_make_dockerfile_build_commandr{   m   s1  € õ "œ ~°~ÑFÔFÐÝÔ&Ð'8Ñ9Ô9€NÝÔ(Ð):Ñ;Ô;€OÝ”. Ð/?Ñ@Ô@€KàØØ�KÑØØØØØØ�^Ñ#ØØ˜Ñ&ØØ�oÑ%ØØ˜iÑ'ð€Hð" ÐØ�Š˜ )¨fÑ"4Ð5Ñ6Ô6Ð6Ý˜jÐ.¨B×5Ò5Ñ7Ô7Ñ8Ô8ð ?ð ?‰
ˆˆUØ�Š˜Ð"<¨sÐ"<Ð"<°UÐ"<Ð"<Ð=Ñ>Ô>Ð>Ð>ð	9Ý”K Ñ.Ô.ð	9ð 	9Ý16´¸\Ñ1JÔ1Jð	9ð 	9å!œK¨	°KÑ(?Ñ@Ô@ð	9ð 	9õ ”+˜mÑ,Ô,ð	9ð 	9õ Œ[˜Ð(8Ñ8Ñ9Ô9ð	9ð 	9õ !&¤¨I¸Ñ,CÑ DÔ Dð	9ð 	9õ Œ{˜<Ð*:Ñ:Ñ;Ô;ð	9ð 	9õ" Œ{˜<Ð*:Ñ:Ñ;Ô;ð#	9ð 	9õ2 Œ:�hÑÔð3	9ð 	9õ4 ”+˜mÑ,Ô,ð5	9ð 	9ð 	9ðr0   c                  óæ  — e Zd ZdZddddddœdtd„Zdud„Zedvd„¦   «         Zdwd„Zdwd„Z	dxd„Z
dyd„Zdyd„Zdzd„Zd{d%„Zdud&„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ˆde„ZdddUddfœd‰dh„Zdd=œdŠdi„Zdddddjœd‹do„Zdd=œdŒdp„Z dqdrddOœd�ds„Z!dS )ŽÚSandboxClientaŠ  Client for interacting with the Sandbox Server API.

    This client provides a simple interface for managing sandboxes and snapshots.

    Example:
        # Uses LANGSMITH_ENDPOINT and LANGSMITH_API_KEY from environment
        client = SandboxClient()

        # Or with explicit configuration
        client = SandboxClient(
            api_endpoint="https://api.smith.langchain.com/v2/sandboxes",
            api_key="your-api-key",
        )

        # Create a sandbox with the default runtime and run commands
        with client.sandbox() as sandbox:
            result = sandbox.run("python --version")
            print(result.stdout)
    Ng      $@é   ©Úapi_endpointÚtimeoutÚapi_keyÚmax_retriesÚheadersr€   r1   r�   Úfloatr‚   rƒ   Úintr„   úOptional[RequestHeaders]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 SandboxClient.

        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)r/   r,   Ú	_base_urlr5   Ú_api_keyÚ_timeoutÚ_max_retriesÚdictÚ_default_headersr   r   ÚhttpxÚClientÚ_httpÚ_registries_client)	Úselfr€   r�   r‚   rƒ   r„   Úresolved_api_keyÚclient_headersr‰   s	            r.   Ú__init__zSandboxClient.__init__Ä   sØ   € ð2 'ÐEÕ*CÑ*EÔ*E×MÒMÈcÑRÔRˆŒØ"Ð<Õ&:Ñ&<Ô&<ÐØ(ˆŒØˆŒØ'ˆÔØAHÐ0Pµ°W±´°ÈbˆÔØ)+ˆØð 	;Ø*:ˆN˜;Ñ'ØÔ ð 	RÝ*¨>¸4Ô;PÑQÔQˆNÝ"¨{Ð;Ñ;Ô;ˆ	Ý”\Ø¨¸.ð
ñ 
ô 
ˆŒ
ð 8<ˆÔÐÐr0   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)rŠ   ÚendswithÚlen)r”   Úsuffixs     r.   Ú	_api_rootzSandboxClient._api_rootî   s@   € à ˆØŒ>×"Ò" 6Ñ*Ô*ð 	2Ø”> .¥S¨¡[¤[ L .Ô1Ð1ØŒ~Ðr0   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 = client.registries.create(
                name="internal",
                url="registry.example.com",
                username="robot",
                password=os.environ["REGISTRY_PASSWORD"],
            )
            snapshot = 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)r“   r   r‹   rœ   r�   Ú	sandboxesÚ
registries©r”   s    r.   r¡   zSandboxClient.registriesõ   sR   € ð* Ô"Ð*Ý&/ØœØŸšÑ)Ô)Ø $Ô 5Ð =¸ð'ñ 'ô 'ˆDÔ#ð
 Ô&Ô0Ô;Ð;r0   ÚRequestHeadersúOptional[dict[str, str]]c                ó>   — |€dS t          | j        j        |¦  «        S )z8Merge default client headers with per-request overrides.N)r   r’   r„   ©r”   r„   s     r.   Ú_request_headerszSandboxClient._request_headers  s!   € àˆ?Ø�4Ý˜TœZÔ/°Ñ9Ô9Ð9r0   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)r�   r   r¦   s     r.   Ú_ws_default_headersz!SandboxClient._ws_default_headers  s+   € ð Ô$ð 	¨¨Ø�4Ý˜TÔ2°GÑ<Ô<Ð<r0   r"   c                ód   — ddl m}  || j        | j        | j        | j        | j        pd¬¦  «        S )a[  Create an AsyncSandboxClient with the same configuration.

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

        Returns:
            AsyncSandboxClient with the same endpoint, credentials, timeout,
            retry, and header configuration.
        r   r!   Nr   )Úlangsmith.sandbox._async_clientr"   rŠ   rŒ   r‹   r�   r�   )r”   r"   s     r.   Úto_asynczSandboxClient.to_async"  sQ   € ð 	GÐFÐFÐFÐFÐFà!Ð!ØœØ”MØ”MØÔ)ØÔ)Ð1¨Tð
ñ 
ô 
ð 	
r0   ÚNonec                ó|   — | j                              ¦   «          | j        �| j                             ¦   «          dS dS )zClose the HTTP client.N)r’   Úcloser“   r¢   s    r.   r¯   zSandboxClient.close6  sB   € àŒ
×ÒÑÔÐØÔ"Ð.ØÔ#×)Ò)Ñ+Ô+Ð+Ð+Ð+ð /Ð.r0   c                ó¸   — 	 | j         j        s| j                              ¦   «          | j        �| j                             ¦   «          dS dS # t          $ r Y dS w xY w)z,Close the HTTP client on garbage collection.N)r’   Ú	is_closedr¯   r“   Ú	Exceptionr¢   s    r.   Ú__del__zSandboxClient.__del__<  sv   € ð	Ø”:Ô'ð #Ø”
× Ò Ñ"Ô"Ð"ØÔ&Ð2ØÔ'×-Ò-Ñ/Ô/Ð/Ð/Ð/ð 3Ð2øåð 	ð 	ð 	ØˆDˆDð	øøøs   ‚AA Á
AÁAc                ó   — | S )zEnter context manager.r4   r¢   s    r.   Ú	__enter__zSandboxClient.__enter__F  s   € àˆr0   Úexc_typeúOptional[type]Úexc_valúOptional[BaseException]Úexc_tbúOptional[Any]c                ó.   — |                       ¦   «          dS )zExit context manager.N)r¯   )r”   r¶   r¸   rº   s       r.   Ú__exit__zSandboxClient.__exit__J  s   € ð 	�
Š
‰Œˆˆˆr0   c                ó   — d| j         › d�S )z�Return a string representation of the instance.

        Returns:
            The string representation of the instance.
        zSandboxClient (API URL: ú))rŠ   r¢   s    r.   Ú__repr__zSandboxClient.__repr__S  s   € ð <¨$¬.Ð;Ð;Ð;Ð;r0   é   ©Ú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               óV   — |                       |||||||||	|
||¬¦  «        }d|_        |S )a   Create a sandbox and return a Sandbox instance.

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

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

            # Resolve by snapshot name instead of ID:
            with client.sandbox(snapshot_name="my-snap") as sandbox:
                result = 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:
            Sandbox 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Â   T)Úcreate_sandboxÚ_auto_delete)r”   rÌ   rÃ   rÄ   r�   rÅ   rÆ   rÇ   rÈ   rÉ   rÊ   rË   r„   Úsbs                 r.   ÚsandboxzSandboxClient.sandbox_  sQ   € ðZ × Ò ØØ'ØØØ-Ø&?ØØØ/Ø%Ø%Øð !ñ 
ô 
ˆð ˆŒØˆ	r0   T)rÃ   rÄ   r�   Úwait_for_readyrÅ   rÆ   rÇ   rÈ   rÉ   rÊ   rË   r„   rÕ   Úboolc               ó|  — |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                             ||||                      |¦  «        ¬¦  «        }|                     ¦   «          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 Sandbox. 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)r:   r   rŠ   r   r’   Úpostr§   Úraise_for_statusr   Ú	from_dictrÙ   r�   ÚHTTPStatusErrorr   )r”   rÌ   rÃ   rÄ   r�   rÕ   rÅ   rÆ   rÇ   rÈ   rÉ   rÊ   rË   r„   ÚurlÚpayloadÚhttp_timeoutÚresponseÚes                      r.   rÑ   zSandboxClient.create_sandbox½  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ð ×%Ò%Ñ'Ô'Ð'ÝÔ$ X§]¢]¡_¤_¸TÈuÐUÑUÔUÐUøÝÔ$ð 	ð 	ð 	Ý)¨!Ñ,Ô,Ð,Øøøøøð	øøøs   Â)A-D ÄD;Ä&D6Ä6D;©r„   c               ó¨  — | j         › dt          |¦  «        › �}	 | j                             ||                      |¦  «        ¬¦  «        }|                     ¦   «          t          j        |                     ¦   «         | d¬¦  «        S # t          j
        $ r;}|j        j        dk    rt          d|› d�d¬	¦  «        |‚t          |¦  «         ‚ d
}~ww xY w)aF  Get a Sandbox by name.

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

        Args:
            name: Sandbox name.

        Returns:
            Sandbox.

        Raises:
            ResourceNotFoundError: If sandbox not found.
            SandboxClientError: For other errors.
        ú/boxes/ræ   FrÚ   é”  ú	Sandbox 'ú' not foundrÔ   ©Úresource_typeN)rŠ   r;   r’   Úgetr§   rÞ   r   rß   rÙ   r�   rà   rä   Ústatus_coder   r   ©r”   rÄ   r„   rá   rä   rå   s         r.   Úget_sandboxzSandboxClient.get_sandbox7  sí   € ð ”ÐCÐCÕ(;¸DÑ(AÔ(AÐCÐCˆð
	Ø”z—~’~ c°4×3HÒ3HÈÑ3QÔ3Q�~ÑRÔRˆHØ×%Ò%Ñ'Ô'Ð'ÝÔ$ X§]¢]¡_¤_¸TÈuÐUÑUÔUÐUøÝÔ$ð 	ð 	ð 	ØŒzÔ%¨Ò,Ð,Ý+Ø1 Ð1Ð1Ð1Àðñ ô àðõ % QÑ'Ô'Ð'Øøøøøð	øøøs   ›A+B ÂCÂ6CÃCúlist[Sandbox]c               ó¢  ‡ — ‰ j         › d�}	 ‰ j                             |‰                      |¦  «        ¬¦  «        }|                     ¦   «          |                     ¦   «         }ˆ fd„|                     dg ¦  «        D ¦   «         S # t          j        $ r9}|j        j	        dk    rt          d|› d�¦  «        |‚t          |¦  «         ‚ d}~ww xY w)	zMList all Sandboxes.

        Returns:
            List of Sandboxes.
        rØ   ræ   c                ó>   •— g | ]}t          j        |‰d ¬¦  «        ‘ŒS )FrÚ   )r   rß   )Ú.0Úcr”   s     €r.   ú
<listcomp>z0SandboxClient.list_sandboxes.<locals>.<listcomp>`  s;   ø€ ð ð ð àõ Ô! !¨D¸eÐDÑDÔDðð ð r0   r    ré   úAPI endpoint not found: ú%. Check that api_endpoint is correct.N©rŠ   r’   rî   r§   rÞ   rÙ   r�   rà   rä   rï   r   r   )r”   r„   rá   rä   Údatarå   s   `     r.   Úlist_sandboxeszSandboxClient.list_sandboxesT  s  ø€ ð ”Ð'Ð'Ð'ˆð	Ø”z—~’~ c°4×3HÒ3HÈÑ3QÔ3Q�~ÑRÔRˆHØ×%Ò%Ñ'Ô'Ð'Ø—=’=‘?”?ˆDðð ð ð àŸš +¨rÑ2Ô2ðñ ô ð øõ Ô$ð 	ð 	ð 	ØŒzÔ%¨Ò,Ð,Ý%ð;¨sð ;ð ;ð ;ñô ð ðõ % QÑ'Ô'Ð'Øøøøøð	øøøs   �A8B ÂCÂ4C	Ã	C)Únew_namerÅ   rÆ   r„   rý   c               ód  — t          |d¦  «         t          |d¦  «         | j        › dt          |¦  «        › �}i }|�||d<   |�||d<   |�||d<   	 | j                             |||                      |¦  «        ¬¦  «        }|                     ¦   «          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)a]  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 Sandbox.

        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   rŠ   r;   r’   Úpatchr§   rÞ   r   rß   rÙ   r�   rà   rä   rï   r   r   r   )
r”   rÄ   rý   rÅ   rÆ   r„   rá   râ   rä   rå   s
             r.   Úupdate_sandboxzSandboxClient.update_sandboxm  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ð ×%Ò%Ñ'Ô'Ð'ÝÔ$ X§]¢]¡_¤_¸TÈuÐUÑUÔUÐUøÝÔ$ð 	ð 	ð 	ØŒzÔ%¨Ò,Ð,Ý+Ø1 Ð1Ð1Ð1Àðñ ô àðð ŒzÔ%¨Ò,Ð,Ý/Ø? XÐ?Ð?Ð?Ø"+ðñ ô ð ðõ % QÑ'Ô'Ð'Øøøøøð	øøøs   ÁA,B? Â?D/ÃAD*Ä*D/c               ód  — | j         › dt          |¦  «        › �}	 | j                             ||                      |¦  «        ¬¦  «        }|                     ¦   «          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æ   ré   rê   rë   rÔ   rì   N©rŠ   r;   r’   Údeleter§   rÞ   r�   rà   rä   rï   r   r   rð   s         r.   Údelete_sandboxzSandboxClient.delete_sandbox«  så   € ð ”ÐCÐCÕ(;¸DÑ(AÔ(AÐCÐCˆð	(Ø”z×(Ò(¨°d×6KÒ6KÈGÑ6TÔ6TÐ(ÑUÔUˆHØ×%Ò%Ñ'Ô'Ð'Ð'Ð'øÝÔ$ð 	(ð 	(ð 	(ØŒzÔ%¨Ò,Ð,Ý+Ø1 Ð1Ð1Ð1Àðñ ô àðõ % QÑ'Ô'Ð'Ð'Ð'Ð'Ð'Ð'Ð'øøøøð	(øøøó   ›AA  Á B/Á/5B*Â*B/r   c               ó¤  — | j         › dt          |¦  «        › d�}	 | j                             ||                      |¦  «        ¬¦  «        }|                     ¦   «          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æ   ré   rê   rë   rÔ   rì   N)rŠ   r;   r’   rî   r§   rÞ   r   rß   rÙ   r�   rà   rä   rï   r   r   rð   s         r.   Úget_sandbox_statusz SandboxClient.get_sandbox_statusÁ  sé   € ð& ”ÐJÐJÕ(;¸DÑ(AÔ(AÐJÐJÐJˆð
	Ø”z—~’~ c°4×3HÒ3HÈÑ3QÔ3Q�~ÑRÔRˆ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               óò  ‡ ‡‡‡‡— t          ‰‰¦  «         ‰ j        › dt          ‰¦  «        › d�}‰‰dœ}dˆˆˆˆˆ fd„}	 ‰ j                             ||‰                      ‰¦  «        ¬¦  «        }|                     ¦   «          t          j        | 	                    ¦   «         |¬¦  «        S # t          j        $ r;}	|	j        j        d	k    rt          d
‰› d�d¬¦  «        |	‚t          |	¦  «         ‚ d}	~	ww xY w)ai  Get an authenticated URL for a service running inside a sandbox.

        Returns a :class:`ServiceURL` whose properties auto-refresh the
        token transparently before it expires.  The object also provides
        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:
            ServiceURL 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                 ó6   •— ‰                      ‰‰‰ ‰¬¦  «        S )Nr	  )Úservice)r
  r„   rÄ   r  r”   s   €€€€€r.   Ú
_refresherz)SandboxClient.service.<locals>._refresher  s*   ø€ Ø—<’<ØØØ#5Øð	  ñ ô ð r0   rÿ   )r  ré   rê   rë   rÔ   rì   N)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å   s
   `````     r.   r  zSandboxClient.serviceâ  sP  øøøøø€ õ: 	  Ð&8Ñ9Ô9Ð9Ø”ÐOÐOÕ(;¸DÑ(AÔ(AÐOÐOÐOˆØÐ7IÐJÐJˆð	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð	Ø”z—’Ø˜'¨4×+@Ò+@ÀÑ+IÔ+Ið 'ñ ô ˆHð ×%Ò%Ñ'Ô'Ð'ÝÔ'¨¯ª©¬ÀJÐOÑOÔOÐOøÝÔ$ð 	ð 	ð 	ØŒzÔ%¨Ò,Ð,Ý+Ø1 Ð1Ð1Ð1Àðñ ô àðõ % QÑ'Ô'Ð'Øøøøøð	øøøs   Á A+B, Â,C6Â;6C1Ã1C6éx   g      ð?)r�   Úpoll_intervalr„   r  c               ó°  — ddl }|                     ¦   «         |z   }	 |                      ||¬¦  «        }|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          ||¦  «        ¦  «         Œ»)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:
            Sandbox 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   ÚsleepÚmin)	r”   rÄ   r�   r  r„   r  Údeadliner  Ú	remainings	            r.   Úwait_for_sandboxzSandboxClient.wait_for_sandbox  s  € ð6 	ˆˆˆà—>’>Ñ#Ô# gÑ-ˆð	6Ø×,Ò,¨T¸7Ð,ÑCÔCˆFØŒ} Ò'Ð'Ø×'Ò'¨°gÐ'Ñ>Ô>Ð>ØŒ} Ò(Ð(Ý+ØÔ)ÐJÐ-JØ"+ðñ ô ð ð ! 4§>¢>Ñ#3Ô#3Ñ3ˆIØ˜AŠ~ˆ~Ý*ØB ÐBÐB¸ÐBÐBÐBØ"+Ø &¤ðñ ô ð ð
 �JŠJ•s˜=¨)Ñ4Ô4Ñ5Ô5Ð5ð!	6r0   ©r�   r„   c               ó”  — | j         › dt          |¦  «        › d�}	 | j                             |i |                      |¦  «        ¬¦  «        }|                     ¦   «          nQ# t          j        $ r?}|j        j	        dk    rt          d|› d�d¬¦  «        |‚t          |¦  «         Y d	}~nd	}~ww xY w|                      |||¬
¦  «        S )að  Start a stopped sandbox and wait until ready.

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

        Returns:
            Sandbox 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ÿ   ré   rê   rë   rÔ   rì   Nr"  )rŠ   r;   r’   rÝ   r§   rÞ   r�   rà   rä   rï   r   r   r!  )r”   rÄ   r�   r„   rá   rä   rå   s          r.   Ústart_sandboxzSandboxClient.start_sandboxI  s  € ð, ”ÐIÐIÕ(;¸DÑ(AÔ(AÐIÐIÐIˆð
	(Ø”z—’Ø˜" d×&;Ò&;¸GÑ&DÔ&Dð 'ñ ô ˆHð ×%Ò%Ñ'Ô'Ð'Ð'øÝÔ$ð 	(ð 	(ð 	(ØŒzÔ%¨Ò,Ð,Ý+Ø1 Ð1Ð1Ð1Àðñ ô àðõ % QÑ'Ô'Ð'Ð'Ð'Ð'Ð'Ð'øøøøð	(øøøð ×$Ò$ T°7ÀGÐ$ÑLÔLÐLs   œAA! Á!B/Á05B*Â*B/c               óh  — | j         › dt          |¦  «        › d�}	 | j                             |i |                      |¦  «        ¬¦  «        }|                     ¦   «          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ÿ   ré   rê   rë   rÔ   rì   N)rŠ   r;   r’   rÝ   r§   rÞ   r�   rà   rä   rï   r   r   rð   s         r.   Ústop_sandboxzSandboxClient.stop_sandboxo  sñ   € ð ”ÐHÐHÕ(;¸DÑ(AÔ(AÐHÐHÐHˆð
	(Ø”z—’Ø˜" d×&;Ò&;¸GÑ&DÔ&Dð 'ñ ô ˆHð ×%Ò%Ñ'Ô'Ð'Ð'Ð'øÝÔ$ð 	(ð 	(ð 	(ØŒzÔ%¨Ò,Ð,Ý+Ø1 Ð1Ð1Ð1Àðñ ô àðõ % QÑ'Ô'Ð'Ð'Ð'Ð'Ð'Ð'Ð'øøøøð	(øøøs   œAA" Á"B1Á15B,Â,B1é<   )Úregistry_idr�   r„   Údocker_imager(  r   c               ó�  — | j         › d�}|||dœ}|�||d<   	 | j                             |||                      |¦  «        ¬¦  «        }	|	                     ¦   «          t          j        |	                     ¦   «         ¦  «        }
n'# t          j	        $ r}t          |¦  «         ‚ d}~ww xY w|                      |
j        ||¬¦  «        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"  )rŠ   r’   rÝ   r§   rÞ   r   rß   rÙ   r�   rà   r   Úwait_for_snapshotÚid)r”   rÄ   r)  rÉ   r(  r�   r„   rá   râ   rä   Úsnapshotrå   s               r.   Úcreate_snapshotzSandboxClient.create_snapshot‹  sñ   € ð: ”Ð+Ð+Ð+ˆð Ø(Ø!2ð#
ð #
ˆð
 Ð"Ø%0ˆG�MÑ"ð	Ø”z—’Ø˜'¨4×+@Ò+@ÀÑ+IÔ+Ið 'ñ ô ˆHð ×%Ò%Ñ'Ô'Ð'ÝÔ)¨(¯-ª-©/¬/Ñ:Ô:ˆHˆHøÝÔ$ð 	ð 	ð 	Ý$ QÑ'Ô'Ð'Øøøøøð	øøøð ×%Ò% h¤k¸7ÈGÐ%ÑTÔTÐTs   ™A*B ÂB(ÂB#Â#B(ú.)rW   rg   ri   Úon_build_logrÇ   rÈ   r�   r„   rU   rV   rW   rg   rh   ri   r1  úOptional[Callable[[str], Any]]c               ó  — 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	¦  «        }|                      ||
||	||¬
¦  «        5 }|                     |t          |¦  «        |
|¬¦  «         | 	                    dt          j        |¦  «        z   dz   t          j        |¦  «        z   dz   t          j        |¦  «        z   dz   t          j        |¦  «        z   |
|¬¦  «         | 	                    t          |||||||¬¦  «        |
|||¬¦  «        }|j        dk    rt          dd¬¦  «        ‚|                      |j        ||||
|¬¦  «        cddd¦  «         S # 1 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/rW   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 )rc   r`   rd   re   rf   rg   ri   )r�   Ú	on_stdoutÚ	on_stderrr„   r   z Dockerfile snapshot build failedr.  rì   ©r)  rÉ   r�   r„   )rb   ÚuuidÚuuid4Úhexro   rp   rÔ   ÚwriterT   Úrunru   r   r{   Ú	exit_coder   Úcapture_snapshotrÄ   )r”   rÄ   rU   rÉ   rW   rg   ri   r1  rÇ   rÈ   r�   r„   r<   r`   Úbuilder_nameÚ
build_rootrc   Ú
remote_tarrd   re   rf   rÔ   Úresults                          r.   Úcreate_snapshot_from_dockerfilez-SandboxClient.create_snapshot_from_dockerfile¾  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	ð Ø�MŠMØÝ(¨Ñ6Ô6ØØð	 ñ ô ð ð �KŠKØÝ”+˜nÑ-Ô-ñ.à!ñ"õ ”+˜nÑ-Ô-ñ.ð !ñ	!õ
 ”+˜jÑ)Ô)ñ*ð ñõ ”+˜nÑ-Ô-ñ.ð  Øð ñ ô ð ð —[’[Ý.Ø#1Ø#1Ø'Ø"/Ø!-Ø)Ø!ðñ ô ð  Ø&Ø&Øð !ñ ô ˆFð Ô 1Ò$Ð$Ý+Ø6Ø",ðñ ô ð ð ×(Ò(Ø”ØØ&Ø"3ØØð )ñ ô ð_6	ð 6	ð 6	ð 6	ñ 6	ô 6	ð 6	ð 6	ð 6	ð 6	ð 6	ð 6	øøøð 6	ð 6	ð 6	ð 6	ð 6	ð 6	s   Ã$DG6Ç6G:Ç=G:r7  Úsandbox_namec               ó  — | j         › dt          |¦  «        › d�}d|i}|�||d<   |�||d<   	 | j                             |||                      |¦  «        ¬¦  «        }	|	                     ¦   «          t          j        |	                     ¦   «         ¦  «        }
nM# t          j
        $ r;}|j        j        dk    rt          d	|› d
�d¬¦  «        |‚t          |¦  «         ‚ d}~ww xY w|                      |
j        ||¬¦  «        S )af  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.
            docker_image: Optional Docker image tag inside the sandbox to export
                into the snapshot instead of capturing the live root filesystem.
            fs_capacity_bytes: Filesystem capacity in bytes for Docker image export.
            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"  )rŠ   r;   r’   rÝ   r§   rÞ   r   rß   rÙ   r�   rà   rä   rï   r   r   r,  r-  )r”   rD  rÄ   r)  rÉ   r�   r„   rá   râ   rä   r.  rå   s               r.   r>  zSandboxClient.capture_snapshot  s?  € ð> ”Ð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Ñ'Ô'Ð'Øøøøøð	øøøð ×%Ò% h¤k¸7ÈGÐ%ÑTÔTÐTs   ®A*B ÂC#Â(6CÃC#c               ó¢  — | j         › dt          |¦  «        › �}	 | j                             ||                      |¦  «        ¬¦  «        }|                     ¦   «          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æ   ré   ú
Snapshot 'rë   r.  rì   N)rŠ   r;   r’   rî   r§   rÞ   r   rß   rÙ   r�   rà   rä   rï   r   r   ©r”   rÌ   r„   rá   rä   rå   s         r.   Úget_snapshotzSandboxClient.get_snapshotR  sæ   € ð ”ÐNÐNÕ,?ÀÑ,LÔ,LÐNÐNˆð
	Ø”z—~’~ c°4×3HÒ3HÈÑ3QÔ3Q�~ÑRÔRˆ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„   rK  rL  rM  úlist[Snapshot]c               óÐ  — | j         › d�}i }|�||d<   |�||d<   |�||d<   	 | j                             ||pd|                      |¦  «        ¬¦  «        }|                     ¦   «          |                     ¦   «         }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+  NrK  rL  rM  )Úparamsr„   c                ó6   — g | ]}t          j        |¦  «        ‘ŒS r4   )r   rß   )rõ   r  s     r.   r÷   z0SandboxClient.list_snapshots.<locals>.<listcomp>Ÿ  s#   € ÐMÐMÐM¨a•HÔ& qÑ)Ô)ÐMÐMÐMr0   Ú	snapshotsré   rø   rù   rú   )
r”   rK  rL  rM  r„   rá   rP  rä   rû   rå   s
             r.   Úlist_snapshotszSandboxClient.list_snapshotso  s7  € ð< ”Ð+Ð+Ð+ˆà!#ˆØÐ$Ø&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   £A9B ÂC%Â,4C Ã C%c               ód  — | j         › dt          |¦  «        › �}	 | j                             ||                      |¦  «        ¬¦  «        }|                     ¦   «          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.
        rG  ræ   ré   rH  rë   r.  rì   Nr  rI  s         r.   Údelete_snapshotzSandboxClient.delete_snapshot©  så   € ð ”ÐNÐNÕ,?ÀÑ,LÔ,LÐNÐNˆð	(Ø”z×(Ò(¨°d×6KÒ6KÈGÑ6TÔ6TÐ(ÑUÔUˆHØ×%Ò%Ñ'Ô'Ð'Ð'Ð'øÝÔ$ð 	(ð 	(ð 	(ØŒzÔ%¨Ò,Ð,Ý+Ø9 Ð9Ð9Ð9Èðñ ô àðõ % QÑ'Ô'Ð'Ð'Ð'Ð'Ð'Ð'Ð'øøøøð	(øøør  i,  g       @c               ó†  — ddl }|                     ¦   «         |z   }	 |                      ||¬¦  «        }|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          ||¦  «        ¦  «         Œ¦)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ì   rH  r  r  r  )	r  r  rJ  r  r   r  r   r  r  )	r”   rÌ   r�   r  r„   r  r  r.  r   s	            r.   r,  zSandboxClient.wait_for_snapshotÁ  sú   € ð0 	ˆˆˆà—>’>Ñ#Ô# gÑ-ˆð	6Ø×(Ò(¨¸gÐ(ÑFÔFˆHØŒ 'Ò)Ð)Ø�ØŒ (Ò*Ð*Ý+ØÔ+ÐFÐ/FØ",ðñ ô ð ð ! 4§>¢>Ñ#3Ô#3Ñ3ˆIØ˜AŠ~ˆ~Ý*ØJ ÐJÐJÀÐJÐJÐJØ",Ø (¤ðñ ô ð ð
 �JŠJ•s˜=¨)Ñ4Ô4Ñ5Ô5Ð5ð!	6r0   )
r€   r1   r�   r…   r‚   r1   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­   )N)rÌ   r1   rÃ   r1   rÄ   r1   r�   r†   rÅ   rÍ   rÆ   rÍ   rÇ   rÍ   rÈ   rÍ   rÉ   rÍ   rÊ   rÎ   rË   rÏ   r„   r£   r#   r   )rÌ   r1   rÃ   r1   rÄ   r1   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ý   r1   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�   r†   r„   r£   r#   r   )rÄ   r$   r)  r$   rÉ   r†   r(  r1   r�   r†   r„   r£   r#   r   )rÄ   r$   rU   rV   rÉ   r†   rW   rV   rg   rh   ri   r1   r1  r2  rÇ   rÍ   rÈ   rÍ   r�   r†   r„   r£   r#   r   )rD  r$   rÄ   r$   r)  r1   rÉ   rÍ   r�   r†   r„   r£   r#   r   )rÌ   r$   r„   r£   r#   r   )
rK  r1   rL  rÍ   rM  rÍ   r„   r£   r#   rN  )rÌ   r$   r„   r£   r#   r­   )
rÌ   r$   r�   r†   r  r…   r„   r£   r#   r   )"Ú__name__Ú
__module__Ú__qualname__Ú__doc__r—   rœ   Úpropertyr¡   r§   r©   r¬   r¯   r³   rµ   r½   rÀ   rÔ   rÑ   rñ   rü   r  r  r  r  r!  r$  r&  r/  rC  r>  rJ  rS  rU  r,  r4   r0   r.   r}   r}   ¯   sn  € € € € € ðð ð. '+ØØ!%ØØ,0ð(<ð (<ð (<ð (<ð (<ð (<ðTð ð ð ð ð<ð <ð <ñ „Xð<ð8:ð :ð :ð :ð=ð =ð =ð =ð
ð 
ð 
ð 
ð(,ð ,ð ,ð ,ðð ð ð ðð ð ð ðð ð ð ð<ð <ð <ð <ð &*ð\ð (,Ø"ØØ*.Ø37Ø#Ø#'Ø+/Ø59Ø59Ø"&ð\ð \ð \ð \ð \ð \ð@ &*ðxð (,Ø"ØØ#Ø*.Ø37Ø#Ø#'Ø+/Ø59Ø59Ø"&ðxð xð xð xð xð xðt CGð ð ð ð ð ð ð: ;?ð ð ð ð ð ð ð: #'Ø*.Ø37Ø"&ð<ð <ð <ð <ð <ð <ð| FJð (ð (ð (ð (ð (ð (ð. 7;ðð ð ð ð ð ðL #&Ø"&ð5ð 5ð 5ð 5ð 5ð 5ðv Ø"Ø"&ð.6ð .6ð .6ð .6ð .6ð .6ðh Ø"&ð$Mð $Mð $Mð $Mð $Mð $MðL DHð (ð (ð (ð (ð (ð (ðD &*ØØ"&ð1Uð 1Uð 1Uð 1Uð 1Uð 1Uðr 14Ø26Ø $Ø7;Ø#Ø#'ØØ"&ð[ð [ð [ð [ð [ð [ðD '+Ø+/ØØ"&ð5Uð 5Uð 5Uð 5Uð 5Uð 5Uðp >Bðð ð ð ð ð ð@ (,Ø#Ø $Ø"&ð8ð 8ð 8ð 8ð 8ð 8ðv >Bð(ð (ð (ð (ð (ð (ð8 Ø"Ø"&ð+6ð +6ð +6ð +6ð +6ð +6ð +6ð +6r0   r}   rW  )r#   r1   )r6   r$   r#   r$   )r<   r   r#   r=   )rU   rV   rW   rV   r#   rX   )rc   r$   r`   r$   rd   r$   re   r$   rf   r$   rg   rh   ri   r1   r#   r$   )Ar[  Ú
__future__r   rE   Úosro   ru   rG   r8  Úcollections.abcr   r   Úpathlibr   Útypingr   r   r	   r
   Úurllib.parser   r�   Ú	langsmithr   r*   Úlangsmith._openapi_clientr   Ú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._sandboxr   Úlangsmith.sandbox._transportr   Ú8langsmith._openapi_client.resources.sandboxes.registriesr    r«   r"   r/   r5   r$   r£   r;   rT   rb   r{   r}   r4   r0   r.   ú<module>rm     s  ðØ KÐ Kà "Ð "Ð "Ð "Ð "Ð "à 	€	€	€	Ø 	€	€	€	Ø Ð Ð Ð Ø €€€Ø €€€Ø €€€Ø -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ø Ð Ð Ð Ð Ð Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø Ð Ð Ð Ð Ð à €€€à 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø /Ð /Ð /Ð /Ð /Ð /ðð ð ð ð ð ð ð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð
ð ð ð ð ð ð ð ð ?Ð >Ð >Ð >Ð >Ð >Ø .Ð .Ð .Ð .Ð .Ð .Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7àð Cðð ð ð ð ð ð CÐBÐBÐBÐBÐBð.ð .ð .ð .ð+ð +ð +ð +ð
 ˜' # s (Ô+Ô,€ð!ð !ð !ð !ðð ð ð ð3ð 3ð 3ð 3ð(?ð ?ð ?ð ?ðD}6ð }6ð }6ð }6ð }6ñ }6ô }6ð }6ð }6ð }6r0   