ó
    üÞ j)  ã                  ó&  • S r SSKJr  SSKJr  SSKJr   " S S\5      r " S S\5      r " S	 S
\5      r	 " S S\5      r
 " S S\
5      r " S S\5      r " S S\
5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S \5      r " S! S"\5      r " S# S$\5      r " S% S&\5      r " S' S(\5      r " S) S*\5      r " S+ S,\5      r " S- S.\5      r " S/ S0\5      r " S1 S2\5      rg3)4züCustom exceptions for the sandbox client.

All sandbox exceptions extend LangSmithError for unified error handling.
The exceptions are organized by error type rather than resource type,
with a resource_type attribute for specific handling when needed.
é    )Úannotations)ÚOptional)ÚLangSmithErrorc                  ó   • \ rS rSrSrSrg)ÚSandboxClientErroré   z)Base exception for sandbox client errors.© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r	   ó    ÚW/var/www/html/gaurav/venv/lib/python3.13/site-packages/langsmith/sandbox/_exceptions.pyr   r      s   † Ù3âr   r   c                  ó   • \ rS rSrSrSrg)ÚSandboxAPIErroré   znRaised when the API endpoint returns an unexpected error.

For example, this is raised for wrong URL or path.
r	   Nr
   r	   r   r   r   r      ó   † ñò
 	r   r   c                  ó   • \ rS rSrSrSrg)ÚSandboxAuthenticationErroré#   z>Raised when authentication fails (invalid or missing API key).r	   Nr
   r	   r   r   r   r   #   s   † ÙHâr   r   c                  ó   • \ rS rSrSrSrg)ÚSandboxConnectionErroré)   z3Raised when connection to the sandbox server fails.r	   Nr
   r	   r   r   r   r   )   s   † Ù=âr   r   c                  ó8   ^ • \ rS rSrSrSS.SU 4S jjjrSrU =r$ )ÚSandboxRetryableConnectionErroré/   a  Raised when a transient failure occurs before a command can start.

``run()`` retries this error with the same command ID, so the server can
deduplicate an attempt whose outcome is unknown.

Attributes:
    retry_after: Optional server-provided delay in seconds before retrying.
N)Úretry_afterc               ó0   >• [         TU ]  U5        X l        g©úInitialize the error.N)ÚsuperÚ__init__r    )ÚselfÚmessager    Ú	__class__s      €r   r%   Ú(SandboxRetryableConnectionError.__init__9   s   ø€ ä‰Ñ˜Ô!Ø&Õr   )r'   Ústrr    zOptional[float]©r   r   r   r   r   r%   r   Ú__classcell__©r(   s   @r   r   r   /   s   ø† ñð HL÷ '÷ 'ð 'r   r   c                  ó   • \ rS rSrSrSrg)ÚSandboxConnectTimeoutErroré?   z¬Raised when the socket fails or times out before the WebSocket handshake.

The execute frame was never sent, so re-issuing the same command ID cannot
double-run a command.
r	   Nr
   r	   r   r   r/   r/   ?   s   † ñò 	r   r/   c                  ó   • \ rS rSrSrSrg)ÚSandboxServerReloadErroréI   u3  Raised when the server sends a 1001 Going Away close frame.

This indicates a server hot-reload, not a true connection failure.
The command is still running on the server.

This is a subclass of SandboxConnectionError, so the auto-reconnect
logic in CommandHandle catches it along with all other
connection errors. The distinction matters for retry strategy:
SandboxServerReloadError triggers immediate reconnect (no backoff),
while other SandboxConnectionError triggers exponential backoff.

Users typically never see this exception â€” it's handled internally.
r	   Nr
   r	   r   r   r2   r2   I   s   † ñò 	r   r2   c                  ó4   ^ • \ rS rSrSrSSU 4S jjjrSrU =r$ )ÚResourceNotFoundErroré`   zqRaised when a resource is not found.

Attributes:
    resource_type: Type of resource (sandbox, snapshot, file).
c                ó0   >• [         TU ]  U5        X l        gr"   ©r$   r%   Úresource_type©r&   r'   r9   r(   s      €r   r%   ÚResourceNotFoundError.__init__g   ó   ø€ ä‰Ñ˜Ô!Ø*Õr   ©r9   ©N©r'   r*   r9   úOptional[str]r+   r-   s   @r   r5   r5   `   ó   ø† ñ÷+÷ +r   r5   c                  óR   ^ • \ rS rSrSr  S     SU 4S jjjrSU 4S jjrSrU =r$ )	ÚResourceTimeoutErrorém   z±Raised when an operation times out.

Attributes:
    resource_type: Type of resource (sandbox, snapshot).
    last_status: The last known status before timeout (for sandboxes).
c                ó<   >• [         TU ]  U5        X l        X0l        gr"   )r$   r%   r9   Úlast_status)r&   r'   r9   rF   r(   s       €r   r%   ÚResourceTimeoutError.__init__u   s   ø€ ô 	‰Ñ˜Ô!Ø*ÔØ&Õr   c                ój   >• [         TU ]  5       nU R                  (       a  U SU R                   S3$ U$ )úReturn string representation.z (last_status: Ú))r$   Ú__str__rF   )r&   Úbaser(   s     €r   rK   ÚResourceTimeoutError.__str__€   s7   ø€ ä‰w‰Ó ˆØ××Ø�V˜?¨4×+;Ñ+;Ð*<¸AÐ>Ð>Øˆr   )rF   r9   ©NN)r'   r*   r9   r@   rF   r@   ©Úreturnr*   ©	r   r   r   r   r   r%   rK   r   r,   r-   s   @r   rC   rC   m   s@   ø† ñð (,Ø%)ð		'àð	'ð %ð	'ð #÷		'ð 	'÷õ r   rC   c                  ó4   ^ • \ rS rSrSrSSU 4S jjjrSrU =r$ )ÚResourceInUseErroréˆ   zsRaised when deleting a resource that is still in use.

Attributes:
    resource_type: Type of resource (snapshot).
c                ó0   >• [         TU ]  U5        X l        gr"   r8   r:   s      €r   r%   ÚResourceInUseError.__init__�   r<   r   r=   r>   r?   r+   r-   s   @r   rS   rS   ˆ   rA   r   rS   c                  ó4   ^ • \ rS rSrSrSSU 4S jjjrSrU =r$ )ÚResourceAlreadyExistsErroré•   zxRaised when creating a resource that already exists.

Attributes:
    resource_type: Type of resource (e.g., snapshot).
c                ó0   >• [         TU ]  U5        X l        gr"   r8   r:   s      €r   r%   Ú#ResourceAlreadyExistsError.__init__œ   r<   r   r=   r>   r?   r+   r-   s   @r   rX   rX   •   rA   r   rX   c                  ó4   ^ • \ rS rSrSrSSU 4S jjjrSrU =r$ )ÚResourceNameConflictErroré¢   z‡Raised when updating a resource name to one that already exists.

Attributes:
    resource_type: Type of resource (sandbox, snapshot).
c                ó0   >• [         TU ]  U5        X l        gr"   r8   r:   s      €r   r%   Ú"ResourceNameConflictError.__init__©   r<   r   r=   r>   r?   r+   r-   s   @r   r]   r]   ¢   rA   r   r]   c                  óH   ^ • \ rS rSrSr   S       SU 4S jjjrSrU =r$ )ÚValidationErroré´   aw  Raised when request validation fails.

This includes:
- Resource values exceeding server-defined limits (CPU, memory, storage)
- Invalid resource units
- Invalid name formats

Attributes:
    field: The field that failed validation (e.g., "cpu", "memory").
    details: List of validation error details from the API.
    error_type: Machine-readable error type from the API.
c                ó\   >• [         TU ]  U5        X l        U=(       d    / U l        X@l        gr"   )r$   r%   ÚfieldÚdetailsÚ
error_type)r&   r'   re   rf   rg   r(   s        €r   r%   ÚValidationError.__init__Â   s'   ø€ ô 	‰Ñ˜Ô!ØŒ
Ø—} "ˆŒØ$�r   )rf   rg   re   )NNN)r'   r*   re   r@   rf   zOptional[list[dict]]rg   r@   r+   r-   s   @r   rb   rb   ´   sC   ø† ñð   $Ø(,Ø$(ð%àð%ð ð%ð &ð	%ð
 "÷%ö %r   rb   c                  ó4   ^ • \ rS rSrSrSSU 4S jjjrSrU =r$ )ÚQuotaExceededErroréÐ   zûRaised when organization quota limits are exceeded.

Users should contact technical support via our Support Portal
(https://support.langchain.com) to increase quotas.

Attributes:
    quota_type: Type of quota exceeded (e.g., "sandbox_count", "cpu").
c                ó0   >• [         TU ]  U5        X l        gr"   )r$   r%   Ú
quota_type)r&   r'   rm   r(   s      €r   r%   ÚQuotaExceededError.__init__Ú   s   ø€ ä‰Ñ˜Ô!Ø$�r   )rm   r>   )r'   r*   rm   r@   r+   r-   s   @r   rj   rj   Ð   s   ø† ñ÷%÷ %r   rj   c                  óR   ^ • \ rS rSrSr  S     SU 4S jjjrSU 4S jjrSrU =r$ )	ÚResourceCreationErroréå   zÙRaised when resource provisioning fails.

Attributes:
    resource_type: Type of resource (sandbox, snapshot).
    error_type: Machine-readable error type (ImagePull, CrashLoop,
        SandboxConfig, Unschedulable).
c                ó<   >• [         TU ]  U5        X l        X0l        gr"   )r$   r%   r9   rg   )r&   r'   r9   rg   r(   s       €r   r%   ÚResourceCreationError.__init__î   s   ø€ ô 	‰Ñ˜Ô!Ø*ÔØ$�r   c                ó~   >• U R                   (       a  [        TU ]	  5        SU R                    S3$ [        TU ]	  5       $ ©rI   z [Ú]©rg   r$   rK   ©r&   r(   s    €r   rK   ÚResourceCreationError.__str__ù   ó7   ø€ à�?�?Ü‘g‘oÓ'Ð(¨¨4¯?©?Ð*;¸1Ð=Ð=Ü‰w‰Ó Ð r   )rg   r9   rN   )r'   r*   r9   r@   rg   r@   rO   rQ   r-   s   @r   rp   rp   å   s@   ø† ñð (,Ø$(ð		%àð	%ð %ð	%ð "÷		%ð 	%÷!õ !r   rp   c                  ó   • \ rS rSrSrSrg)ÚDataplaneNotConfiguredErrori  zˆRaised when dataplane_url is not available for the sandbox.

This occurs when the sandbox-router URL is not configured for the cluster.
r	   Nr
   r	   r   r   r|   r|     r   r   r|   c                  ó   • \ rS rSrSrSrg)ÚSandboxNotReadyErrori  zDRaised when attempting to interact with a sandbox that is not ready.r	   Nr
   r	   r   r   r~   r~     s   † ÙNâr   r~   c                  óR   ^ • \ rS rSrSr  S     SU 4S jjjrSU 4S jjrSrU =r$ )	ÚSandboxOperationErrori  zÂRaised when a sandbox operation fails (run, read, write).

Attributes:
    operation: The operation that failed (command, read, write).
    error_type: Machine-readable error type from the API.
c                ó<   >• [         TU ]  U5        X l        X0l        gr"   )r$   r%   Ú	operationrg   )r&   r'   r‚   rg   r(   s       €r   r%   ÚSandboxOperationError.__init__  s   ø€ ô 	‰Ñ˜Ô!Ø"ŒØ$�r   c                ó~   >• U R                   (       a  [        TU ]	  5        SU R                    S3$ [        TU ]	  5       $ ru   rw   rx   s    €r   rK   ÚSandboxOperationError.__str__'  rz   r   )rg   r‚   rN   )r'   r*   r‚   r@   rg   r@   rO   rQ   r-   s   @r   r€   r€     s@   ø† ñð $(Ø$(ð		%àð	%ð !ð	%ð "÷		%ð 	%÷!õ !r   r€   c                  ó4   ^ • \ rS rSrSrSSU 4S jjjrSrU =r$ )ÚCommandTimeoutErrori.  zuRaised when a command exceeds its timeout.

Attributes:
    timeout: The timeout value in seconds that was exceeded.
c                ó0   >• [         TU ]  USSS9  X l        g)r#   ÚcommandÚCommandTimeout)r‚   rg   N)r$   r%   Útimeout)r&   r'   r‹   r(   s      €r   r%   ÚCommandTimeoutError.__init__5  s   ø€ ä‰Ñ˜¨IÐBRÐÑSØ�r   )r‹   r>   )r'   r*   r‹   zOptional[int]r+   r-   s   @r   r‡   r‡   .  s   ø† ñ÷÷ r   r‡   c                  ó   • \ rS rSrSrSrg)ÚTunnelErrori@  z%Base exception for TCP tunnel errors.r	   Nr
   r	   r   r   rŽ   rŽ   @  s   † Ù/âr   rŽ   c                  ó0   ^ • \ rS rSrSrSU 4S jjrSrU =r$ )ÚTunnelPortNotAllowedErroriF  z`The daemon rejected the port as not allowed.

Attributes:
    port: The port that was rejected.
c               ó0   >• [         TU ]  U5        X l        gr"   ©r$   r%   Úport©r&   r'   r“   r(   s      €r   r%   Ú"TunnelPortNotAllowedError.__init__M  ó   ø€ ä‰Ñ˜Ô!Ø�	r   ©r“   ©r'   r*   r“   Úintr+   r-   s   @r   r�   r�   F  ó   ø† ñ÷õ r   r�   c                  ó0   ^ • \ rS rSrSrSU 4S jjrSrU =r$ )ÚTunnelConnectionRefusedErroriS  zwNothing is listening on the target port inside the sandbox.

Attributes:
    port: The port that could not be reached.
c               ó0   >• [         TU ]  U5        X l        gr"   r’   r”   s      €r   r%   Ú%TunnelConnectionRefusedError.__init__Z  r–   r   r—   r˜   r+   r-   s   @r   rœ   rœ   S  rš   r   rœ   c                  ó   • \ rS rSrSrSrg)ÚTunnelUnsupportedVersionErrori`  zCProtocol version mismatch between the tunnel client and the daemon.r	   Nr
   r	   r   r   r    r    `  s   † ÙMâr   r    N)r   Ú
__future__r   Útypingr   Úlangsmith.utilsr   r   r   r   r   r   r/   r2   r5   rC   rS   rX   r]   rb   rj   rp   r|   r~   r€   r‡   rŽ   r�   rœ   r    r	   r   r   Ú<module>r¤      s=  ðñõ #å å *ô	˜ô 	ô	Ð(ô 	ô	Ð!3ô 	ô	Ð/ô 	ô'Ð&<ô 'ô 	Ð!@ô 	ô	Ð5ô 	ô.
+Ð.ô 
+ôÐ-ô ô6
+Ð+ô 
+ô
+Ð!3ô 
+ô
+Ð 2ô 
+ô$%Ð(ô %ô8%Ð+ô %ô*!Ð.ô !ô@	Ð"4ô 	ô	Ð-ô 	ô!Ð.ô !ô4
Ð/ô 
ô$	Ð$ô 	ô
 ô 
ô
 ;ô 
ô	 Kõ 	r   