Ë
    ñÏj)  ã                  ó&  — d Z ddlmZ ddlmZ ddlmZ  G d„ de«      Z G d„ de«      Z G d	„ d
e«      Z	 G d„ de«      Z
 G d„ de
«      Z G d„ de«      Z G d„ de
«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ d e«      Z G d!„ d"e«      Z G d#„ d$e«      Z G d%„ d&e«      Z G d'„ d(e«      Z G d)„ d*e«      Z G d+„ d,e«      Z G d-„ d.e«      Z G d/„ d0e«      Z G d1„ d2e«      Zy3)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                  ó   — e Zd ZdZy)ÚSandboxClientErrorz)Base exception for sandbox client errors.N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úZ/var/www/html/gaurav-v2/venv/lib/python3.12/site-packages/langsmith/sandbox/_exceptions.pyr   r      s   „ Ù3àr   r   c                  ó   — e Zd ZdZy)ÚSandboxAPIErrorzvRaised when the API endpoint returns an unexpected error.

    For example, this is raised for wrong URL or path.
    Nr   r   r   r   r   r      ó   „ ñð
 	r   r   c                  ó   — e Zd ZdZy)ÚSandboxAuthenticationErrorz>Raised when authentication fails (invalid or missing API key).Nr   r   r   r   r   r   #   s   „ ÙHàr   r   c                  ó   — e Zd ZdZy)ÚSandboxConnectionErrorz3Raised when connection to the sandbox server fails.Nr   r   r   r   r   r   )   s   „ Ù=àr   r   c                  ó*   ‡ — e Zd ZdZddœdˆ fd„Zˆ xZS )ÚSandboxRetryableConnectionErrora+  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               ó2   •— t         ‰| �  |«       || _        y©úInitialize the error.N)ÚsuperÚ__init__r   )ÚselfÚmessager   Ú	__class__s      €r   r   z(SandboxRetryableConnectionError.__init__9   s   ø€ ä‰Ñ˜Ô!Ø&ˆÕr   )r    Ústrr   zOptional[float]©r	   r
   r   r   r   Ú__classcell__©r!   s   @r   r   r   /   s   ø„ ñð HL÷ 'ó 'r   r   c                  ó   — e Zd ZdZy)ÚSandboxConnectTimeoutErrorz¸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.
    Nr   r   r   r   r'   r'   ?   s   „ ñð 	r   r'   c                  ó   — e Zd ZdZy)ÚSandboxServerReloadErroruW  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.
    Nr   r   r   r   r)   r)   I   s   „ ñð 	r   r)   c                  ó&   ‡ — e Zd ZdZddˆ fd„Zˆ xZS )ÚResourceNotFoundErrorz}Raised when a resource is not found.

    Attributes:
        resource_type: Type of resource (sandbox, snapshot, file).
    c                ó2   •— t         ‰| �  |«       || _        yr   ©r   r   Úresource_type©r   r    r.   r!   s      €r   r   zResourceNotFoundError.__init__g   ó   ø€ ä‰Ñ˜Ô!Ø*ˆÕr   ©N©r    r"   r.   úOptional[str]r#   r%   s   @r   r+   r+   `   ó   ø„ ñ÷+ò +r   r+   c                  ó@   ‡ — e Zd ZdZ	 	 d	 	 	 	 	 dˆ fd„Zdˆ fd„Zˆ xZS )ÚResourceTimeoutErrorzÁ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         ‰| �  |«       || _        || _        yr   )r   r   r.   Úlast_status)r   r    r.   r8   r!   s       €r   r   zResourceTimeoutError.__init__u   s"   ø€ ô 	‰Ñ˜Ô!Ø*ˆÔØ&ˆÕr   c                ó`   •— t         ‰| �  «       }| j                  r|› d| j                  › d�S |S )úReturn string representation.z (last_status: Ú))r   Ú__str__r8   )r   Úbaser!   s     €r   r<   zResourceTimeoutError.__str__€   s7   ø€ ä‰w‰Ó ˆØ×ÒØ�V˜?¨4×+;Ñ+;Ð*<¸AÐ>Ð>Øˆr   ©NN)r    r"   r.   r3   r8   r3   ©Úreturnr"   ©r	   r
   r   r   r   r<   r$   r%   s   @r   r6   r6   m   s;   ø„ ñð (,Ø%)ð		'àð	'ð %ð	'ð #õ		'÷ñ r   r6   c                  ó&   ‡ — e Zd ZdZddˆ fd„Zˆ xZS )ÚResourceInUseErrorzRaised when deleting a resource that is still in use.

    Attributes:
        resource_type: Type of resource (snapshot).
    c                ó2   •— t         ‰| �  |«       || _        yr   r-   r/   s      €r   r   zResourceInUseError.__init__�   r0   r   r1   r2   r#   r%   s   @r   rC   rC   ˆ   r4   r   rC   c                  ó&   ‡ — e Zd ZdZddˆ fd„Zˆ xZS )ÚResourceAlreadyExistsErrorz„Raised when creating a resource that already exists.

    Attributes:
        resource_type: Type of resource (e.g., snapshot).
    c                ó2   •— t         ‰| �  |«       || _        yr   r-   r/   s      €r   r   z#ResourceAlreadyExistsError.__init__œ   r0   r   r1   r2   r#   r%   s   @r   rF   rF   •   r4   r   rF   c                  ó&   ‡ — e Zd ZdZddˆ fd„Zˆ xZS )ÚResourceNameConflictErrorz“Raised when updating a resource name to one that already exists.

    Attributes:
        resource_type: Type of resource (sandbox, snapshot).
    c                ó2   •— t         ‰| �  |«       || _        yr   r-   r/   s      €r   r   z"ResourceNameConflictError.__init__©   r0   r   r1   r2   r#   r%   s   @r   rI   rI   ¢   r4   r   rI   c                  ó:   ‡ — e Zd ZdZ	 	 	 d	 	 	 	 	 	 	 dˆ fd„Zˆ xZS )ÚValidationErrora›  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                óV   •— t         ‰| �  |«       || _        |xs g | _        || _        yr   )r   r   ÚfieldÚdetailsÚ
error_type)r   r    rN   rO   rP   r!   s        €r   r   zValidationError.__init__Â   s+   ø€ ô 	‰Ñ˜Ô!ØˆŒ
Ø’} "ˆŒØ$ˆ�r   )NNN)r    r"   rN   r3   rO   zOptional[list[dict]]rP   r3   r#   r%   s   @r   rL   rL   ´   sC   ø„ ñð   $Ø(,Ø$(ð%àð%ð ð%ð &ð	%ð
 "÷%ñ %r   rL   c                  ó&   ‡ — e Zd ZdZddˆ fd„Zˆ xZS )ÚQuotaExceededErrora  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                ó2   •— t         ‰| �  |«       || _        yr   )r   r   Ú
quota_type)r   r    rT   r!   s      €r   r   zQuotaExceededError.__init__Ú   s   ø€ ä‰Ñ˜Ô!Ø$ˆ�r   r1   )r    r"   rT   r3   r#   r%   s   @r   rR   rR   Ð   s   ø„ ñ÷%ò %r   rR   c                  ó@   ‡ — e Zd ZdZ	 	 d	 	 	 	 	 dˆ fd„Zdˆ fd„Zˆ xZS )ÚResourceCreationErrorzí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         ‰| �  |«       || _        || _        yr   )r   r   r.   rP   )r   r    r.   rP   r!   s       €r   r   zResourceCreationError.__init__î   s!   ø€ ô 	‰Ñ˜Ô!Ø*ˆÔØ$ˆ�r   c                ót   •— | j                   rt        ‰| �	  «       › d| j                   › d�S t        ‰| �	  «       S ©r:   z [Ú]©rP   r   r<   ©r   r!   s    €r   r<   zResourceCreationError.__str__ù   ó7   ø€ à�?Š?Ü‘g‘oÓ'Ð(¨¨4¯?©?Ð*;¸1Ð=Ð=Ü‰w‰Ó Ð r   r>   )r    r"   r.   r3   rP   r3   r?   rA   r%   s   @r   rV   rV   å   s;   ø„ ñð (,Ø$(ð		%àð	%ð %ð	%ð "õ		%÷!ñ !r   rV   c                  ó   — e Zd ZdZy)ÚDataplaneNotConfiguredErrorz�Raised when dataplane_url is not available for the sandbox.

    This occurs when the sandbox-router URL is not configured for the cluster.
    Nr   r   r   r   r_   r_     r   r   r_   c                  ó   — e Zd ZdZy)ÚSandboxNotReadyErrorzDRaised when attempting to interact with a sandbox that is not ready.Nr   r   r   r   ra   ra     s   „ ÙNàr   ra   c                  ó@   ‡ — e Zd ZdZ	 	 d	 	 	 	 	 dˆ fd„Zdˆ fd„Zˆ xZS )ÚSandboxOperationErrorzÒ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         ‰| �  |«       || _        || _        yr   )r   r   Ú	operationrP   )r   r    re   rP   r!   s       €r   r   zSandboxOperationError.__init__  s    ø€ ô 	‰Ñ˜Ô!Ø"ˆŒØ$ˆ�r   c                ót   •— | j                   rt        ‰| �	  «       › d| j                   › d�S t        ‰| �	  «       S rY   r[   r\   s    €r   r<   zSandboxOperationError.__str__'  r]   r   r>   )r    r"   re   r3   rP   r3   r?   rA   r%   s   @r   rc   rc     s;   ø„ ñð $(Ø$(ð		%àð	%ð !ð	%ð "õ		%÷!ñ !r   rc   c                  ó&   ‡ — e Zd ZdZddˆ fd„Zˆ xZS )ÚCommandTimeoutErrorz�Raised when a command exceeds its timeout.

    Attributes:
        timeout: The timeout value in seconds that was exceeded.
    c                ó8   •— t         ‰| �  |dd¬«       || _        y)r   ÚcommandÚCommandTimeout)re   rP   N)r   r   Útimeout)r   r    rl   r!   s      €r   r   zCommandTimeoutError.__init__5  s   ø€ ä‰Ñ˜¨IÐBRÐÔSØˆ�r   r1   )r    r"   rl   zOptional[int]r#   r%   s   @r   rh   rh   .  s   ø„ ñ÷ò r   rh   c                  ó   — e Zd ZdZy)ÚTunnelErrorz%Base exception for TCP tunnel errors.Nr   r   r   r   rn   rn   @  s   „ Ù/àr   rn   c                  ó$   ‡ — e Zd ZdZdˆ fd„Zˆ xZS )ÚTunnelPortNotAllowedErrorzlThe daemon rejected the port as not allowed.

    Attributes:
        port: The port that was rejected.
    c               ó2   •— t         ‰| �  |«       || _        yr   ©r   r   Úport©r   r    rs   r!   s      €r   r   z"TunnelPortNotAllowedError.__init__M  ó   ø€ ä‰Ñ˜Ô!Øˆ�	r   ©r    r"   rs   Úintr#   r%   s   @r   rp   rp   F  ó   ø„ ñ÷ñ r   rp   c                  ó$   ‡ — e Zd ZdZdˆ fd„Zˆ xZS )ÚTunnelConnectionRefusedErrorzƒNothing is listening on the target port inside the sandbox.

    Attributes:
        port: The port that could not be reached.
    c               ó2   •— t         ‰| �  |«       || _        yr   rr   rt   s      €r   r   z%TunnelConnectionRefusedError.__init__Z  ru   r   rv   r#   r%   s   @r   rz   rz   S  rx   r   rz   c                  ó   — e Zd ZdZy)ÚTunnelUnsupportedVersionErrorzCProtocol version mismatch between the tunnel client and the daemon.Nr   r   r   r   r}   r}   `  s   „ ÙMàr   r}   N)r   Ú
__future__r   Útypingr   Úlangsmith.utilsr   r   r   r   r   r   r'   r)   r+   r6   rC   rF   rI   rL   rR   rV   r_   ra   rc   rh   rn   rp   rz   r}   r   r   r   Ú<module>r�      s=  ðñõ #å å *ô	˜ô 	ô	Ð(ô 	ô	Ð!3ô 	ô	Ð/ô 	ô'Ð&<ô 'ô 	Ð!@ô 	ô	Ð5ô 	ô.
+Ð.ô 
+ôÐ-ô ô6
+Ð+ô 
+ô
+Ð!3ô 
+ô
+Ð 2ô 
+ô$%Ð(ô %ô8%Ð+ô %ô*!Ð.ô !ô@	Ð"4ô 	ô	Ð-ô 	ô!Ð.ô !ô4
Ð/ô 
ô$	Ð$ô 	ô
 ô 
ô
 ;ô 
ô	 Kõ 	r   