ó
    üÞ jt{  ã                  ó<  • S r SSKJr  SSKrSSKrSSKJr  SSKJrJ	r	  SSK
JrJrJrJrJrJrJr  SSKJr  SSKJrJrJr  SS	KJr  SS
KJrJrJrJrJrJ r J!r!  SSK"J#r#  SSK$J%r%J&r&J'r'J(r(  \(       a  SSK)J*r*  SSK+J,r,  SSK-J.r.  \\\/\/4      r0\ " S S5      5       r1g)z0AsyncSandbox class for async sandbox operations.é    )ÚannotationsN)ÚMapping)Ú	dataclassÚfield)ÚTYPE_CHECKINGÚAnyÚCallableÚLiteralÚOptionalÚUnionÚoverload)Úhttpx)ÚDataplaneNotConfiguredErrorÚResourceNotFoundErrorÚSandboxRetryableConnectionError)Úhandle_sandbox_http_error)ÚAsyncCommandHandleÚAsyncServiceURLÚDownloadContentDispositionÚDownloadURLÚExecutionResultÚSnapshotÚ_StreamEndedBeforeStarted)ÚAsyncTunnel)ÚWEBSOCKETS_AVAILABLEÚ_retry_delayÚconnect_deadlineÚopen_timeout_for)ÚAsyncSandboxClient)ÚSandboxClient©ÚSandboxc                  ó`  • \ rS rSr% SrS\S'   SrS\S'   SrS\S'   S	rS\S
'   Sr	S\S'   Sr
S\S'   SrS\S'   SrS\S'   SrS\S'   SrS\S'   SrS\S'   SrS\S'   SrS\S'   SrS\S'   \" SSS9rS\S'   \" SSS9rS\S'   \ SD       SES jj5       rSS.SFS jjrSGS  jr        SHS! jrSIS" jr\S#S#S#S#S#S#S#S#S#S#S#S#S$.                           SJS% jj5       r\S#S#S#S#S#S#S#S#S#S#S#S&.                           SKS' jj5       rS(SSS)SSS*SS+SSSS$.                           SLS, jjrS*SS+SSS-.                           SMS. jjr              SNS/ jrS0S0SS1.         SOS2 jjr S(SS3.         SPS4 jjr!S(SS3.       SQS5 jjr"S0S6SS7.         SRS8 jjr#S+SS9.       SSS: jjr$SSSSS;.           STS< jjr%S=SS3.     SUS> jjr&SS?.SVS@ jjr'SS?.SVSA jjr(S(SS3.       SWSB jjr)SCr*g)XÚAsyncSandboxé,   a$  Represents an active sandbox for running commands and file operations async.

This class is typically obtained from AsyncSandboxClient.sandbox() and supports
the async context manager protocol for automatic cleanup.

Attributes:
    name: Display name (can be updated).
    dataplane_url: URL for data plane operations (file I/O, command execution).
        Only functional when status is "ready".
    id: Unique identifier (UUID). Remains constant even if name changes.
        May be None for resources created before ID support was added.
    status: Sandbox lifecycle status. One of "provisioning", "ready",
        "failed", "stopped".
    status_message: Human-readable details when status is "failed", None otherwise.
    created_at: Timestamp when the sandbox was created.
    updated_at: Timestamp when the sandbox was last updated.
    idle_ttl_seconds: Idle timeout TTL in seconds (``0`` means disabled).
        Newly-created sandboxes receive a server-side default of ``600``
        seconds (10 minutes) when the caller did not set ``idle_ttl_seconds``
        explicitly. The launcher stops the sandbox after this many idle
        seconds; deletion is anchored to ``stopped_at`` and controlled by
        ``delete_after_stop_seconds`` (see below).
    delete_after_stop_seconds: Seconds after a sandbox enters the
        ``stopped`` state before it (and its filesystem clone) are
        permanently deleted. ``0`` disables stop-anchored deletion;
        ``None`` falls back to the server default.
    stopped_at: Timestamp when the sandbox transitioned to ``stopped``,
        or ``None`` while running. The deletion deadline is
        ``stopped_at + delete_after_stop_seconds``.
    snapshot_id: Snapshot ID used to create this sandbox.
    vcpus: Number of vCPUs allocated.
    mem_bytes: Memory allocation in bytes.
    fs_capacity_bytes: Root filesystem capacity in bytes.

Example:
    async with await client.sandbox(
        snapshot_id="<snapshot-uuid>"
    ) as sandbox:
        result = await sandbox.run("python --version")
        print(result.stdout)
ÚstrÚnameNúOptional[str]Údataplane_urlÚidÚreadyÚstatusÚstatus_messageÚ
created_atÚ
updated_atúOptional[int]Úidle_ttl_secondsÚdelete_after_stop_secondsÚ
stopped_atÚsnapshot_idÚvcpusÚ	mem_bytesÚfs_capacity_bytesF)ÚreprÚdefaultr   Ú_clientTÚboolÚ_auto_deletec           	     ó  • U " S0 SUR                  SS5      _SUR                  S5      _SUR                  S5      _SUR                  SS5      _SUR                  S5      _SUR                  S5      _S	UR                  S	5      _S
UR                  S
5      _SUR                  S5      _SUR                  S5      _SUR                  S5      _SUR                  S5      _SUR                  S5      _SUR                  S5      _SU_SU_6$ )a  Create an AsyncSandbox from API response dict.

Args:
    data: API response dictionary containing sandbox data.
    client: Parent AsyncSandboxClient for operations.
    auto_delete: Whether to delete the sandbox on context exit.

Returns:
    AsyncSandbox instance.
r'   Ú r)   r*   r,   r+   r-   r.   r/   r1   r2   r3   r4   r5   r6   r7   r:   r<   © )Úget)ÚclsÚdataÚclientÚauto_deletes       ÚZ/var/www/html/gaurav/venv/lib/python3.13/site-packages/langsmith/sandbox/_async_sandbox.pyÚ	from_dictÚAsyncSandbox.from_dictl   s2  € ñ" ò 
Ø—‘˜& "Ô%ð
àŸ(™( ?Ô3ð
ð �x‰x˜Œ~ð
ð —8‘8˜H gÔ.ð	
ð
  Ÿ8™8Ð$4Ô5ð
ð —x‘x Ô-ð
ð —x‘x Ô-ð
ð "ŸX™XÐ&8Ô9ð
ð '+§h¡hÐ/JÔ&Kð
ð —x‘x Ô-ð
ð Ÿ™ Ô/ð
ð —(‘(˜7Ô#ð
ð —h‘h˜{Ô+ð
ð #Ÿh™hÐ':Ô;ð
ñ ð
ñ  %ð!
ð 	
ó    )rC   c               óÌ  • SSK Jn  U" S0 SU R                  _SU R                  _SU R                  _SU R
                  _SU R                  _SU R                  _S	U R                  _S
U R                  _SU R                  _SU R                  _SU R                  _SU R                  _SU R                  _SU R                  _SUb  UOU R                   R#                  5       _SS_6$ )aÆ  Create a Sandbox for the same underlying sandbox.

The returned instance has ``auto_delete`` disabled so the sandbox's
lifecycle stays tied to this instance; both refer to the same
server-side sandbox.

Args:
    client: SandboxClient to use for operations. If not provided,
        one is created with the same configuration as this sandbox's
        client (see :meth:`AsyncSandboxClient.to_sync`).

Returns:
    Sandbox referring to the same sandbox.
r   r!   r'   r)   r*   r,   r-   r.   r/   r1   r2   r3   r4   r5   r6   r7   r:   r<   Fr?   )Úlangsmith.sandbox._sandboxr"   r'   r)   r*   r,   r-   r.   r/   r1   r2   r3   r4   r5   r6   r7   r:   Úto_sync)ÚselfrC   r"   s      rE   rK   ÚAsyncSandbox.to_sync�   s	  € õ 	7áò 
Ø—’ð
à×,Ò,ð
ð �wŠwð
ð —;’;ð	
ð
  ×.Ò.ð
ð —’ð
ð —’ð
ð "×2Ò2ð
ð '+×&DÒ&Dð
ð —’ð
ð ×(Ò(ð
ð —*’*ð
ð —n’nð
ð #×4Ò4ð
ð %Ñ0‘F°d·l±l×6JÑ6JÓ6Løð
ñ  ð!
ð 	
rH   c              ƒ  ó   #   • U $ 7f)zEnter async context manager.r?   ©rL   s    rE   Ú
__aenter__ÚAsyncSandbox.__aenter__´   s
   é € àˆùs   ‚c              ƒ  ó°   #   • U R                   (       a/   U R                  R                  U R                  5      I Sh  v•N   gg N! [         a     gf = f7f)z<Exit async context manager, optionally deleting the sandbox.N)r<   r:   Údelete_sandboxr'   Ú	Exception)rL   Úexc_typeÚexc_valÚexc_tbs       rE   Ú	__aexit__ÚAsyncSandbox.__aexit__¸   sJ   é € ð ××ðØ—l‘l×1Ñ1°$·)±)Ó<×<Ñ<ð á<øÜó áðüs8   ‚A•(A ½A¾A ÁAÁA Á
AÁAÁAÁAc                ón   • U R                   (       d  [        SU R                   S35      eU R                   $ )a›  Return the dataplane URL.

The client does not gate on lifecycle status: a stopped sandbox is
resumed by the platform when the dataplane request arrives, so only the
presence of a URL is required here. A genuinely not-ready box surfaces
the server's ``SandboxNotReadyError`` from the request itself.

Returns:
    The dataplane URL.

Raises:
    DataplaneNotConfiguredError: If dataplane_url is not configured.
z	Sandbox 'zW' does not have a dataplane_url configured. Runtime operations require a dataplane URL.)r)   r   r'   rO   s    rE   Ú_require_dataplane_urlÚ#AsyncSandbox._require_dataplane_urlÆ   s=   € ð ×!×!Ü-Ø˜DŸI™I˜;ð '>ð >óð ð ×!Ñ!Ð!rH   .)ÚtimeoutÚenvÚcwdÚshellÚ	on_stdoutÚ	on_stderrÚidle_timeoutÚkill_on_disconnectÚttl_secondsÚptyÚheadersÚwaitc             ƒ  ó   #   • g 7f©Nr?   ©rL   Úcommandr]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   s                 rE   ÚrunÚAsyncSandbox.runÛ   s
   é € ð" ùó   ‚)r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   c             ƒ  ó   #   • g 7frj   r?   rk   s                 rE   rm   rn   î   s
   é € ð" !ùro   é<   z	/bin/bashi,  iX  c             ƒ  ó�  #   • U(       d  U(       d  U(       a  [        S5      eU R                  5         U(       + =(       d    U=(       d    UnU(       a#  U R                  UUUUUUUUUU	U
UUS9I Sh  v•N $ [        (       a#  U R                  UUUUUSSSUU	U
UUS9I Sh  v•N $ U R	                  UUUUUUS9I Sh  v•N $  NN N" N7f)a	  Execute a command in the sandbox asynchronously.

Args:
    command: Shell command to execute.
    timeout: Command timeout in seconds.
    env: Environment variables to set for the command.
    cwd: Working directory for command execution. If None, uses sandbox default.
    shell: Shell to use for command execution. Defaults to "/bin/bash".
    on_stdout: Callback invoked with each stdout chunk as it arrives.
        Blocks until the command completes and returns ExecutionResult.
        Cannot be combined with wait=False.
    on_stderr: Callback invoked with each stderr chunk as it arrives.
        Blocks until the command completes and returns ExecutionResult.
        Cannot be combined with wait=False.
    idle_timeout: Idle timeout in seconds. If the command has no
        connected clients for this duration, it is killed. Defaults
        to 300 (5 minutes). Set to -1 for no idle timeout.
        Only applies to WebSocket execution.
    kill_on_disconnect: If True, kill the command immediately when
        the last client disconnects. Defaults to False (command
        continues running and can be reconnected to).
    ttl_seconds: How long (in seconds) a finished command's session
        is kept for reconnection. Defaults to 600 (10 minutes).
        Set to -1 to keep indefinitely.
    pty: If True, allocate a pseudo-terminal for the command.
        Useful for commands that require a TTY (e.g., interactive
        programs, commands that use terminal control codes).
        Defaults to False.
    wait: If True (default), block until the command completes and
        return ExecutionResult. If False, return an
        AsyncCommandHandle immediately for streaming output,
        kill, stdin input, and reconnection. Cannot be combined
        with on_stdout/on_stderr callbacks.

Returns:
    ExecutionResult when wait=True (default).
    AsyncCommandHandle when wait=False.

Raises:
    ValueError: If wait=False is combined with callbacks.
    DataplaneNotConfiguredError: If dataplane_url is not configured.
    SandboxOperationError: If command execution fails.
    CommandTimeoutError: If command exceeds its timeout.
    SandboxConnectionError: If connection to sandbox fails after retries.
    SandboxNotReadyError: If sandbox is not ready.
    SandboxClientError: For other errors.
z}Cannot combine wait=False with on_stdout/on_stderr callbacks. Use wait=False and iterate the CommandHandle, or use callbacks.)r]   r^   r_   r`   rh   ra   rb   rc   rd   re   rf   rg   NT)r]   r^   r_   r`   rg   )Ú
ValueErrorr[   Ú_run_wsr   Ú	_run_http)rL   rl   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   Úuse_wss                  rE   rm   rn     s  é € ö@ ž¦iÜðRóð ð
 	×#Ñ#Ô%à”×3˜Y×3¨)ˆÞØŸ™ØØØØØØØ#Ø#Ø)Ø#5Ø'ØØð &ð ÷ ð ÷$  ÒØŸ™ØØØØØØØØØ)Ø#5Ø'ØØð &ð ÷ ð ð —^‘^ØØØØØØð $ð 
÷ 
ð 	
ñEñ&ñ
ùs6   ‚A/CÁ1C Á2-CÂCÂ CÂ;CÂ<CÃCÃC)rc   rd   re   rf   rg   c          
   ƒ  óž  #   • SSK nSSKJn  SSKJn  U R                  5       nU R                  R                  nU" 5       R                  nUUUUUU	U
UUS.	nU R                  R                  U5      nU(       a  UUS'   Sn[        5       n [        U5      US'   U" UUU40 UD6I Sh  v•N u  nn[        UUU UUS9n UR                  5       I Sh  v•N    U(       d  U$ UR2                  I Sh  v•N $  NK N$! [        [        4 a¿  nUS	-  nU[        R                   :”  a  e [#        [        R$                  S
US	-
  -  -  [        R&                  5      n[)        U[        5      (       a  [+        UU5      nUb+  U[,        R.                  " 5       -
  nUS::  a  e [#        UU5      nUR0                  " U5      I Sh  v•N     SnAOSnAff = fGMA   NÝ7f)z"Execute via WebSocket /execute/ws.r   N)Úrun_ws_stream_async)Úuuid7)	Ú
command_idr]   r^   r_   r`   rc   rd   re   rf   rg   Úopen_timeout)ra   rb   é   é   )ÚasyncioÚlangsmith.sandbox._ws_executerx   Úlangsmith.uuidry   r[   r:   Ú_api_keyÚhexÚ_ws_default_headersr   r   r   Ú_ensure_startedr   r   ÚMAX_AUTO_RECONNECTSÚminÚ_BACKOFF_BASEÚ_BACKOFF_MAXÚ
isinstancer   ÚtimeÚ	monotonicÚsleepÚresult)rL   rl   r]   r^   r_   r`   rh   ra   rb   rc   rd   re   rf   rg   r~   rx   ry   r)   Úapi_keyrz   Ú	ws_kwargsÚmergedÚattemptÚdeadlineÚ
msg_streamÚcontrolÚhandleÚexcÚbackoffÚ	remainings                                 rE   rt   ÚAsyncSandbox._run_wsv  så  é € ó$ 	åEÝ(à×3Ñ3Ó5ˆØ—,‘,×'Ñ'ˆñ “W—[‘[ˆ
ð %ØØØØØ(Ø"4Ø&Øñ
%
ˆ	ð —‘×1Ñ1°'Ó:ˆÞØ#)ˆI�iÑ àˆÜ#Ó%ˆØÜ(8¸Ó(BˆI�nÑ%Ù(;ØØØñ)ð ñ	)÷ #ÑˆJ˜ô (ØØØØ#Ø#ñˆFð-Ø×,Ñ,Ó.×.Ð.Øö. ØˆMà—]‘]×"Ð"ñS#ñ /øô *Ü/ðó -ð ˜1‘�ØÔ/×CÑCÓCØÜÜ&×4Ñ4¸¸gÈ¹kÑ8JÑKÜ&×3Ñ3ó�ô ˜cÔ#B×CÑCÜ*¨3°Ó8�GØÑ'Ø (¬4¯>ª>Ó+;Ñ ;�IØ  A“~ØÜ! '¨9Ó5�GØ—m’m GÓ,×,Ö,ûð)-úò% ñV #ùsg   ‚B$GÂ&C2Â'GÂ<C6 ÃC4ÃC6 ÃGÃ-GÃ.GÃ4C6 Ã6GÄB/G Æ5F8Æ6G Æ;GÇ GÇGc             ƒ  óü  #   • U R                  5       nU S3nUUUS.n	Ub  X9S'   Ub  XIS'    U R                  R                  R                  UU	US-   U R                  R	                  U5      S9I Sh  v•N n
U
R                  5         U
R                  5       n[        UR                  SS	5      UR                  S
S	5      UR                  SS5      S9$  N_! [        R                   a  n[        U5        e SnAff = f7f)z9Execute via HTTP POST /execute (existing implementation).z/execute)rl   r]   r`   Nr^   r_   é
   )Újsonr]   rg   Ústdoutr>   ÚstderrÚ	exit_codeéÿÿÿÿ)r�   rž   rŸ   )r[   r:   Ú_httpÚpostÚ_request_headersÚraise_for_statusrœ   r   r@   r   ÚHTTPStatusErrorr   )rL   rl   r]   r^   r_   r`   rg   r)   ÚurlÚpayloadÚresponserB   Úes                rE   ru   ÚAsyncSandbox._run_httpÔ  s
  é € ð ×3Ñ3Ó5ˆØ�˜xÐ(ˆàØØñ#
ˆð
 ‰?Ø �E‰NØ‰?Ø �E‰Nð	Ø!Ÿ\™\×/Ñ/×4Ñ4ØØØ "™ØŸ™×5Ñ5°gÓ>ð	 5ð ÷ ˆHð ×%Ñ%Ô'Ø—=‘=“?ˆDÜ"Ø—x‘x ¨"Ó-Ø—x‘x ¨"Ó-ØŸ(™( ;°Ó3ñð ñøô ×$Ñ$ó 	Ü% aÔ(Øûð	üs<   ‚*C<­AC Á2CÁ3AC ÃC<ÃC ÃC9Ã(C4Ã4C9Ã9C<r   )Ústdout_offsetÚstderr_offsetrg   c          	   ƒ  ó  #   • SSK Jn  U R                  5       nU R                  R                  nUUS.nU R                  R                  U5      n	U	(       a  X˜S'   U" UUU40 UD6I Sh  v•N u  p«[        U
UU UUUS9$  N7f)aY  Reconnect to a running or recently-finished command.

Resumes output from the given byte offsets. Any output produced while
the client was disconnected is replayed from the server's ring buffer.

Args:
    command_id: The command ID from handle.command_id.
    stdout_offset: Byte offset to resume stdout from (default: 0).
    stderr_offset: Byte offset to resume stderr from (default: 0).

Returns:
    An AsyncCommandHandle for the command.

Raises:
    SandboxOperationError: If command_id is not found or session expired.
    SandboxConnectionError: If connection to sandbox fails after retries.
r   )Úreconnect_ws_stream_async)r«   r¬   rg   N)rz   r«   r¬   )r   r®   r[   r:   r�   rƒ   r   )rL   rz   r«   r¬   rg   r®   r)   rŽ   Úreconnect_kwargsr�   r“   r”   s               rE   Ú	reconnectÚAsyncSandbox.reconnectý  s¤   é € õ2 	Là×3Ñ3Ó5ˆØ—,‘,×'Ñ'ˆð +Ø*ñ,
Ðð —‘×1Ñ1°'Ó:ˆÞØ*0˜YÑ'á$=ØØØñ%
ð ñ	%
÷ 
Ñˆ
ô "ØØØØ!Ø'Ø'ñ
ð 	
ñ
ùs   ‚A&A?Á(A=Á)A?©r]   rg   c          	   ƒ  ó   #   • U R                  5       nU S3n[        U[        5      (       a  UR                  S5      nSSU40n U R                  R
                  R                  USU0UUU R                  R                  U5      S9I Sh  v•N nUR                  5         g N! [        R                   a  n	[        U	5         Sn	A	gSn	A	ff = f7f)aá  Write content to a file in the sandbox asynchronously.

Args:
    path: Target file path in the sandbox.
    content: File content (str or bytes).
    timeout: Request timeout in seconds.

Raises:
    DataplaneNotConfiguredError: If dataplane_url is not configured.
    SandboxOperationError: If file write fails.
    SandboxConnectionError: If connection to sandbox fails after retries.
    SandboxNotReadyError: If sandbox is not ready.
    SandboxClientError: For other errors.
z/uploadzutf-8ÚfileÚpath)ÚparamsÚfilesr]   rg   N)r[   r‰   r&   Úencoder:   r¡   r¢   r£   r¤   r   r¥   r   )
rL   rµ   Úcontentr]   rg   r)   r¦   r·   r¨   r©   s
             rE   ÚwriteÚAsyncSandbox.write3  sÍ   é € ð, ×3Ñ3Ó5ˆØ�˜wÐ'ˆô �gœs×#Ñ#Ø—n‘n WÓ-ˆGà˜& 'Ð*Ð+ˆð
	)Ø!Ÿ\™\×/Ñ/×4Ñ4ØØ �~ØØØŸ™×5Ñ5°gÓ>ð 5ð ÷ ˆHð ×%Ñ%Õ'ñøô ×$Ñ$ó 	)Ü% a×(Ñ(ûð	)üsC   ‚ACÁAB" Â
B ÂB" ÂCÂ B" Â"CÂ6CÃCÃCÃCc             ƒ  óÀ  #   • U R                  5       nU S3n U R                  R                  R                  USU0UU R                  R	                  U5      S9I Sh  v•N nUR                  5         UR                  $  N ! [        R                   aG  nUR                  R                  S:X  a  [        SU SU R                   S3S	S
9Ue[        U5        e SnAff = f7f)ag  Read a file from the sandbox asynchronously.

Args:
    path: File path to read. Supports both absolute paths (e.g., /tmp/file.txt)
          and relative paths (resolved from /home/user/).
    timeout: Request timeout in seconds.

Returns:
    File contents as bytes.

Raises:
    DataplaneNotConfiguredError: If dataplane_url is not configured.
    ResourceNotFoundError: If the file doesn't exist.
    SandboxOperationError: If file read fails.
    SandboxConnectionError: If connection to sandbox fails after retries.
    SandboxNotReadyError: If sandbox is not ready.
    SandboxClientError: For other errors.
z	/downloadrµ   )r¶   r]   rg   Ni”  zFile 'z' not found in sandbox 'Ú'r´   )Úresource_type)r[   r:   r¡   r@   r£   r¤   r¹   r   r¥   r¨   Ústatus_coder   r'   r   )rL   rµ   r]   rg   r)   r¦   r¨   r©   s           rE   ÚreadÚAsyncSandbox.read^  sê   é € ð* ×3Ñ3Ó5ˆØ�˜yÐ)ˆð	Ø!Ÿ\™\×/Ñ/×3Ñ3ØØ �~ØØŸ™×5Ñ5°gÓ>ð	 4ð ÷ ˆHð ×%Ñ%Ô'Ø×#Ñ#Ð#ñøô ×$Ñ$ó 	Ø�z‰z×%Ñ%¨Ó,Ü+Ø˜T˜FÐ":¸4¿9¹9¸+ÀQÐGØ"(ñð ðô & aÔ(àûð	üs<   ‚C™AB  ÁA>ÁB  Á=CÁ>B  Â CÂACÃCÃCé   ©Ú
local_portÚmax_reconnectsrg   c          	   ƒ  ó†  #   • SUs=::  a  S::  d  O  [        SU S35      eU(       a  SUs=::  a  S::  d  O  [        SU S35      eU R                  5       nU R                  R                  n[	        UUUUUUS9n[
        R                  " 5       nUR                  SUR                  R                  5      I Sh  v•N   U$  N7f)aÃ  Open a TCP tunnel to a port inside the sandbox.

Creates a local TCP listener that forwards connections through a
yamux-multiplexed WebSocket to the specified port inside the sandbox.
Works with any TCP protocol (databases, Redis, HTTP, etc.).

Usage::

    async with await sandbox.tunnel(remote_port=5432) as t:
        conn = await asyncpg.connect(host="127.0.0.1", port=t.local_port)

Args:
    remote_port: TCP port inside the sandbox to tunnel to (1-65535).
    local_port: Local port to listen on. Defaults to mirroring
        remote_port. Use 0 to let the OS pick an available port.
    max_reconnects: Maximum number of automatic reconnect attempts
        when the WebSocket session drops. Set to 0 to disable.

Returns:
    An AsyncTunnel instance (async context manager).

Raises:
    ValueError: If port values are out of range.
    DataplaneNotConfiguredError: If dataplane_url is not configured.
    SandboxNotReadyError: If sandbox is not ready.
r|   iÿÿ  z-remote_port must be between 1 and 65535 (got Ú)z,local_port must be between 1 and 65535 (got rÃ   N)
rs   r[   r:   r�   r   r~   Úget_running_loopÚrun_in_executorÚ_tunnelÚ_start)	rL   Úremote_portrÄ   rÅ   rg   r)   rŽ   ÚtÚloops	            rE   ÚtunnelÚAsyncSandbox.tunnel‰  sÍ   é € ðD �KÕ( 5Õ(ÜØ?À¸}ÈAÐNóð ö ˜a :Õ6°Õ6ÜØ>¸z¸lÈ!ÐLóð ð ×3Ñ3Ó5ˆØ—,‘,×'Ñ'ˆÜØØØØ!Ø)Øñ
ˆô ×'Ò'Ó)ˆØ×"Ñ" 4¨¯©×)9Ñ)9Ó:×:Ð:Øˆñ 	;ùs   ‚B6CÂ8B?Â9C©Úexpires_in_secondsrg   c             ƒ  ój   #   • U R                   R                  U R                  UUUS9I Sh  v•N $  N7f)aa  Get an authenticated URL for a service running in this sandbox.

Returns an :class:`AsyncServiceURL` whose async accessors
auto-refresh the token transparently before it expires.

Args:
    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Ñ   N)r:   Úservicer'   )rL   ÚportrÒ   rg   s       rE   rÔ   ÚAsyncSandbox.serviceÁ  s=   é € ð2 —\‘\×)Ñ)Ø�I‰IØØ1Øð	 *ð 
÷ 
ð 	
ñ 
ùó   ‚*3¬1­3©rÒ   Úcontent_typeÚcontent_dispositionrg   c          	   ƒ  ón   #   • U R                   R                  U R                  UUUUUS9I Sh  v•N $  N7f)a  Create a link that downloads one file from this sandbox.

The link carries its own token, so anyone holding the URL can fetch
that one file without a LangSmith credential. Fetching wakes a
stopped sandbox.

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

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

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

Raises:
    ResourceNotFoundError: If sandbox not found.
    ValueError: If expires_in_seconds is not positive.
    SandboxClientError: For other errors.
rØ   N)r:   Úgenerate_download_urlr'   )rL   rµ   rÒ   rÙ   rÚ   rg   s         rE   rÜ   Ú"AsyncSandbox.generate_download_urlá  sD   é € ðL —\‘\×7Ñ7Ø�I‰IØØ1Ø%Ø 3Øð 8ð 
÷ 
ð 	
ñ 
ùs   ‚,5®3¯5éx   c             ƒ  ó¬   #   • U R                   R                  U R                  XS9I Sh  v•N nUR                  U l        UR                  U l        g N'7f)aÙ  Start a stopped sandbox and wait until ready.

After starting, the sandbox's status and dataplane_url are updated
in place.

Args:
    timeout: Timeout in seconds when waiting for ready.
    headers: Optional per-request header overrides.

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²   N)r:   Ústart_sandboxr'   r,   r)   )rL   r]   rg   Ú	refresheds       rE   ÚstartÚAsyncSandbox.start  sP   é € ð* Ÿ,™,×4Ñ4Ø�I‰I˜wð 5ð 
÷ 
ˆ	ð  ×&Ñ&ˆŒØ&×4Ñ4ˆÕñ	
ùs   ‚(AªA«(A©rg   c             ƒ  óv   #   • U R                   R                  U R                  US9I Sh  v•N   SU l        g N7f)zãStop a running sandbox (preserves sandbox files for later restart).

Args:
    headers: Optional per-request header overrides.

Raises:
    ResourceNotFoundError: If sandbox not found.
    SandboxClientError: For other errors.
rä   NÚstopped)r:   Ústop_sandboxr'   r,   ©rL   rg   s     rE   ÚstopÚAsyncSandbox.stop+  s7   é € ð �l‰l×'Ñ'¨¯	©	¸7Ð'ÐC×CÐCð  ˆ�ñ 	Dùs   ‚(9ª7«9c             ƒ  óh   #   • U R                   R                  U R                  US9I Sh  v•N   g N7f)z´Delete this sandbox.

Args:
    headers: Optional per-request header overrides.

Raises:
    ResourceNotFoundError: If sandbox not found.
    SandboxClientError: For other errors.
rä   N)r:   rS   r'   rè   s     rE   ÚdeleteÚAsyncSandbox.delete:  s(   é € ð �l‰l×)Ñ)¨$¯)©)¸WÐ)ÐE×EÓEùs   ‚(2ª0«2c             ƒ  ój   #   • U R                   R                  U R                  UUUS9I Sh  v•N $  N7f)aÁ  Capture a snapshot from this sandbox.

Args:
    name: Snapshot name.
    timeout: Timeout in seconds when waiting for ready.
    headers: Optional per-request header overrides.

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²   N)r:   Úcapture_snapshotr'   )rL   r'   r]   rg   s       rE   rï   ÚAsyncSandbox.capture_snapshotF  s=   é € ð. —\‘\×2Ñ2Ø�I‰IØØØð	 3ð 
÷ 
ð 	
ñ 
ùr×   )r)   r,   )T)rB   zdict[str, Any]rC   r   rD   r;   Úreturnr$   )rC   zOptional[SandboxClient]rñ   r"   )rñ   r$   )rU   zOptional[type]rV   zOptional[BaseException]rW   zOptional[Any]rñ   ÚNone)rñ   r&   )rl   r&   r]   Úintr^   úOptional[dict[str, str]]r_   r(   r`   r&   ra   úOptional[Callable[[str], Any]]rb   rõ   rc   ró   rd   r;   re   ró   rf   r;   rg   ÚRequestHeadersrh   zLiteral[True]rñ   r   )rl   r&   r]   ró   r^   rô   r_   r(   r`   r&   ra   rõ   rb   rõ   rc   ró   rd   r;   re   ró   rf   r;   rg   rö   rh   zLiteral[False]rñ   r   )rl   r&   r]   ró   r^   rô   r_   r(   r`   r&   ra   rõ   rb   rõ   rc   ró   rd   r;   re   ró   rf   r;   rg   rö   rh   r;   rñ   ú*Union[ExecutionResult, AsyncCommandHandle])rl   r&   r]   ró   r^   rô   r_   r(   r`   r&   rh   r;   ra   rõ   rb   rõ   rc   ró   rd   r;   re   ró   rf   r;   rg   rö   rñ   r÷   )rl   r&   r]   ró   r^   rô   r_   r(   r`   r&   rg   rö   rñ   r   )
rz   r&   r«   ró   r¬   ró   rg   rö   rñ   r   )
rµ   r&   r¹   zUnion[str, bytes]r]   ró   rg   rö   rñ   rò   )rµ   r&   r]   ró   rg   rö   rñ   Úbytes)
rÌ   ró   rÄ   ró   rÅ   ró   rg   rö   rñ   r   )rÕ   ró   rÒ   ró   rg   rö   rñ   r   )rµ   r&   rÒ   r0   rÙ   r(   rÚ   z$Optional[DownloadContentDisposition]rg   rö   rñ   r   )r]   ró   rg   rö   rñ   rò   )rg   rö   rñ   rò   )r'   r&   r]   ró   rg   rö   rñ   r   )+Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__r)   r*   r,   r-   r.   r/   r1   r2   r3   r4   r5   r6   r7   r   r:   r<   ÚclassmethodrF   rK   rP   rX   r[   r   rm   rt   ru   r°   rº   rÀ   rÏ   rÔ   rÜ   râ   ré   rì   rï   Ú__static_attributes__r?   rH   rE   r$   r$   ,   sd  ‡ ñ(ðV ƒIØ#'€M�=Ó'Ø€BˆÓØ€FˆCÓØ$(€N�MÓ(Ø $€J�Ó$Ø $€J�Ó$Ø&*Ð�mÓ*Ø/3Ð˜}Ó3Ø $€J�Ó$Ø!%€K�Ó%Ø€Eˆ=ÓØ#€Iˆ}Ó#Ø'+Ð�}Ó+ñ #(¨U¸DÑ"A€GÐÓAÙ E°4Ñ8€L�$Ó8àð
 !ð	!
àð!
ð #ð!
ð ð	!
ð
 
ô!
ó ð!
ðF <@÷ "
ôHðà ðð )ðð ð	ð
 
ôô"ð* ð
 Ø(+Ø ØØ47Ø47ØØ#&ØØØ"%Ø!ñàðð ð	ð
 &ðð ðð ðð 2ðð 2ðð ðð !ðð ðð ðð  ðð ðð  
ô!ó ðð$ ð
 Ø(+Ø ØØ47Ø47ØØ#&ØØØ"%ñ!àð!ð ð	!ð
 &ð!ð ð!ð ð!ð 2ð!ð 2ð!ð ð!ð !ð!ð ð!ð ð!ð  ð!ð ð!ð  
ô!!ó ð!ð, Ø(,Ø!Ø Ø48Ø48ØØ#(ØØØ"&Øñs
àðs
ð ð	s
ð
 &ðs
ð ðs
ð ðs
ð 2ðs
ð 2ðs
ð ðs
ð !ðs
ð ðs
ð ðs
ð  ðs
ð ðs
ð  
4õ!s
ð@  Ø#(ØØØ"&ñ\#àð\#ð ð	\#ð
 &ð\#ð ð\#ð ð\#ð ð\#ð 2ð\#ð 2ð\#ð ð\#ð !ð\#ð ð\#ð ð\#ð  ð\#ð  
4õ!\#ð|'àð'ð ð	'ð
 &ð'ð ð'ð ð'ð  ð'ð 
ô'ðZ ØØ"&ñ4
àð4
ð ð	4
ð
 ð4
ð  ð4
ð 
õ4
ðv Ø"&ñ))àð))ð #ð))ð
 ð))ð  ð))ð 
õ))ðX ,.Èñ)Øð)Ø%(ð)Ø8Fð)à	õ)ð^ ØØ"&ñ6àð6ð ð	6ð
 ð6ð  ð6ð 
õ6ðx #&Ø"&ñ
àð
ð  ð	
ð
  ð
ð 
õ
ðH -1Ø&*ØDHØ"&ñ-
àð-
ð *ð	-
ð
 $ð-
ð Bð-
ð  ð-
ð 
õ-
ðd Ø"&ñ	5ð ð5ð  ð	5ð
 
õ5ð6 7;÷  ð 9=÷ 
Fð  Ø"&ñ
àð
ð ð	
ð
  ð
ð 
÷
ð 
rH   r$   )2rý   Ú
__future__r   r~   rŠ   Úcollections.abcr   Údataclassesr   r   Útypingr   r   r	   r
   r   r   r   Ú langsmith._openapi_client._httpxr   Úlangsmith.sandbox._exceptionsr   r   r   Úlangsmith.sandbox._helpersr   Úlangsmith.sandbox._modelsr   r   r   r   r   r   r   Úlangsmith.sandbox._tunnelr   r   r   r   r   r   Úlangsmith.sandbox._async_clientr   Úlangsmith.sandbox._clientr    rJ   r"   r&   rö   r$   r?   rH   rE   Ú<module>r     s�   ðÙ 6å "ã Û Ý #ß (ß S× SÑ Så 2÷ñ õ
 A÷÷ ñ õ 2÷ó ö ÝBÝ7Ý2ð ˜' # s (Ñ+Ñ,€ð ÷u
ð u
ó ñu
rH   