§
    ~Štj™'  ã                  ó–  — 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d1S )2zü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dS )ÚSandboxClientErrorz)Base exception for sandbox client errors.N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    ú[/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langsmith/sandbox/_exceptions.pyr   r      s   € € € € € Ø3Ð3à€Dr   r   c                  ó   — e Zd ZdZdS )Ú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      ó   € € € € € ðð ð
 	€Dr   r   c                  ó   — e Zd ZdZdS )ÚSandboxAuthenticationErrorz>Raised when authentication fails (invalid or missing API key).Nr   r   r   r   r   r   #   s   € € € € € ØHÐHà€Dr   r   c                  ó   — e Zd ZdZdS )ÚSandboxConnectionErrorz3Raised when connection to the sandbox server fails.Nr   r   r   r   r   r   )   s   € € € € € Ø=Ð=à€Dr   r   c                  ó   — e Zd ZdZdS )ÚSandboxConnectTimeoutErroray  Raised when the socket fails or times out before the WebSocket handshake.

    Distinct from its parent because it is safely retryable: the execute frame
    was never sent, so re-issuing the same command_id cannot double-run a
    command. run() retries this with backoff; a plain SandboxConnectionError
    (a rejected handshake) is permanent and propagates immediately.
    Nr   r   r   r   r   r   /   s   € € € € € ðð ð 	€Dr   r   c                  ó   — e Zd ZdZdS )Ú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   ;   s   € € € € € ðð ð 	€Dr   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).
    NÚmessageÚstrÚresource_typeúOptional[str]c                óX   •— t          ¦   «                              |¦  «         || _        dS ©úInitialize the error.N©ÚsuperÚ__init__r   ©Úselfr   r   Ú	__class__s      €r   r&   zResourceNotFoundError.__init__Y   ó)   ø€ å‰Œ×Ò˜Ñ!Ô!Ð!Ø*ˆÔÐÐr   ©N©r   r   r   r    ©r	   r
   r   r   r&   Ú__classcell__©r)   s   @r   r   r   R   óL   ø€ € € € € ðð ð+ð +ð +ð +ð +ð +ð +ð +ð +ð +ð +r   r   c                  ó6   ‡ — 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).
    Nr   r   r   r    Úlast_statusc                óf   •— t          ¦   «                              |¦  «         || _        || _        dS r"   )r%   r&   r   r3   )r(   r   r   r3   r)   s       €r   r&   zResourceTimeoutError.__init__g   s3   ø€ õ 	‰Œ×Ò˜Ñ!Ô!Ð!Ø*ˆÔØ&ˆÔÐÐr   Úreturnc                óp   •— t          ¦   «                              ¦   «         }| j        r|› d| j        › d�S |S )úReturn string representation.z (last_status: ú))r%   Ú__str__r3   )r(   Úbaser)   s     €r   r9   zResourceTimeoutError.__str__r   s@   ø€ å‰wŒw�ŠÑ Ô ˆØÔð 	?ØÐ>Ð>¨4Ô+;Ð>Ð>Ð>Ð>Øˆr   ©NN)r   r   r   r    r3   r    ©r5   r   ©r	   r
   r   r   r&   r9   r.   r/   s   @r   r2   r2   _   sr   ø€ € € € € ðð ð (,Ø%)ð		'ð 	'ð 	'ð 	'ð 	'ð 	'ð 	'ðð ð ð ð ð ð ð ð ð r   r2   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).
    Nr   r   r   r    c                óX   •— t          ¦   «                              |¦  «         || _        dS r"   r$   r'   s      €r   r&   zResourceInUseError.__init__�   r*   r   r+   r,   r-   r/   s   @r   r?   r?   z   r0   r   r?   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).
    Nr   r   r   r    c                óX   •— t          ¦   «                              |¦  «         || _        dS r"   r$   r'   s      €r   r&   z#ResourceAlreadyExistsError.__init__Ž   r*   r   r+   r,   r-   r/   s   @r   rB   rB   ‡   r0   r   rB   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).
    Nr   r   r   r    c                óX   •— t          ¦   «                              |¦  «         || _        dS r"   r$   r'   s      €r   r&   z"ResourceNameConflictError.__init__›   r*   r   r+   r,   r-   r/   s   @r   rE   rE   ”   r0   r   rE   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.
    Nr   r   Úfieldr    ÚdetailsúOptional[list[dict]]Ú
error_typec                óx   •— t          ¦   «                              |¦  «         || _        |pg | _        || _        dS r"   )r%   r&   rI   rJ   rL   )r(   r   rI   rJ   rL   r)   s        €r   r&   zValidationError.__init__´   s:   ø€ õ 	‰Œ×Ò˜Ñ!Ô!Ð!ØˆŒ
Ø�} "ˆŒØ$ˆŒˆˆr   )NNN)r   r   rI   r    rJ   rK   rL   r    r-   r/   s   @r   rH   rH   ¦   sW   ø€ € € € € ðð ð   $Ø(,Ø$(ð%ð %ð %ð %ð %ð %ð %ð %ð %ð %ð %r   rH   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").
    Nr   r   Ú
quota_typer    c                óX   •— t          ¦   «                              |¦  «         || _        dS r"   )r%   r&   rP   )r(   r   rP   r)   s      €r   r&   zQuotaExceededError.__init__Ì   s&   ø€ å‰Œ×Ò˜Ñ!Ô!Ð!Ø$ˆŒˆˆr   r+   )r   r   rP   r    r-   r/   s   @r   rO   rO   Â   sL   ø€ € € € € ðð ð%ð %ð %ð %ð %ð %ð %ð %ð %ð %ð %r   rO   c                  ó6   ‡ — 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).
    Nr   r   r   r    rL   c                óf   •— t          ¦   «                              |¦  «         || _        || _        dS r"   )r%   r&   r   rL   )r(   r   r   rL   r)   s       €r   r&   zResourceCreationError.__init__à   s0   ø€ õ 	‰Œ×Ò˜Ñ!Ô!Ð!Ø*ˆÔØ$ˆŒˆˆr   r5   c                ó¨   •— | j         r+t          ¦   «                              ¦   «         › d| j         › d�S t          ¦   «                              ¦   «         S ©r7   z [ú]©rL   r%   r9   ©r(   r)   s    €r   r9   zResourceCreationError.__str__ë   óH   ø€ àŒ?ð 	>Ý‘g”g—o’oÑ'Ô'Ð=Ð=¨4¬?Ð=Ð=Ð=Ð=Ý‰wŒw�ŠÑ Ô Ð r   r;   )r   r   r   r    rL   r    r<   r=   r/   s   @r   rS   rS   ×   sr   ø€ € € € € ðð ð (,Ø$(ð		%ð 	%ð 	%ð 	%ð 	%ð 	%ð 	%ð!ð !ð !ð !ð !ð !ð !ð !ð !ð !r   rS   c                  ó   — e Zd ZdZdS )Ú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dS )ÚSandboxNotReadyErrorzDRaised when attempting to interact with a sandbox that is not ready.Nr   r   r   r   r^   r^      s   € € € € € ØNÐNà€Dr   r^   c                  ó6   ‡ — 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.
    Nr   r   Ú	operationr    rL   c                óf   •— t          ¦   «                              |¦  «         || _        || _        dS r"   )r%   r&   ra   rL   )r(   r   ra   rL   r)   s       €r   r&   zSandboxOperationError.__init__  s/   ø€ õ 	‰Œ×Ò˜Ñ!Ô!Ð!Ø"ˆŒØ$ˆŒˆˆr   r5   c                ó¨   •— | j         r+t          ¦   «                              ¦   «         › d| j         › d�S t          ¦   «                              ¦   «         S rV   rX   rY   s    €r   r9   zSandboxOperationError.__str__  rZ   r   r;   )r   r   ra   r    rL   r    r<   r=   r/   s   @r   r`   r`     sr   ø€ € € € € ðð ð $(Ø$(ð		%ð 	%ð 	%ð 	%ð 	%ð 	%ð 	%ð!ð !ð !ð !ð !ð !ð !ð !ð !ð !r   r`   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.
    Nr   r   ÚtimeoutúOptional[int]c                ó^   •— t          ¦   «                              |dd¬¦  «         || _        dS )r#   ÚcommandÚCommandTimeout)ra   rL   N)r%   r&   rf   )r(   r   rf   r)   s      €r   r&   zCommandTimeoutError.__init__'  s.   ø€ å‰Œ×Ò˜¨IÐBRÐÑSÔSÐSØˆŒˆˆr   r+   )r   r   rf   rg   r-   r/   s   @r   re   re      sL   ø€ € € € € ðð ðð ð ð ð ð ð ð ð ð ð r   re   c                  ó   — e Zd ZdZdS )ÚTunnelErrorz%Base exception for TCP tunnel errors.Nr   r   r   r   rl   rl   2  s   € € € € € Ø/Ð/à€Dr   rl   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.
    r   r   ÚportÚintc               óX   •— t          ¦   «                              |¦  «         || _        dS r"   ©r%   r&   ro   ©r(   r   ro   r)   s      €r   r&   z"TunnelPortNotAllowedError.__init__?  ó&   ø€ å‰Œ×Ò˜Ñ!Ô!Ð!ØˆŒ	ˆ	ˆ	r   ©r   r   ro   rp   r-   r/   s   @r   rn   rn   8  óG   ø€ € € € € ðð ðð ð ð ð ð ð ð ð ð r   rn   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.
    r   r   ro   rp   c               óX   •— t          ¦   «                              |¦  «         || _        dS r"   rr   rs   s      €r   r&   z%TunnelConnectionRefusedError.__init__L  rt   r   ru   r-   r/   s   @r   rx   rx   E  rv   r   rx   c                  ó   — e Zd ZdZdS )ÚTunnelUnsupportedVersionErrorzCProtocol version mismatch between the tunnel client and the daemon.Nr   r   r   r   r{   r{   R  s   € € € € € ØMÐMà€Dr   r{   N)r   Ú
__future__r   Útypingr   Úlangsmith.utilsr   r   r   r   r   r   r   r   r2   r?   rB   rE   rH   rO   rS   r\   r^   r`   re   rl   rn   rx   r{   r   r   r   ú<module>r      s   ððð ð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð à *Ð *Ð *Ð *Ð *Ð *ð	ð 	ð 	ð 	ð 	˜ñ 	ô 	ð 	ð	ð 	ð 	ð 	ð 	Ð(ñ 	ô 	ð 	ð	ð 	ð 	ð 	ð 	Ð!3ñ 	ô 	ð 	ð	ð 	ð 	ð 	ð 	Ð/ñ 	ô 	ð 	ð		ð 		ð 		ð 		ð 		Ð!7ñ 		ô 		ð 		ð	ð 	ð 	ð 	ð 	Ð5ñ 	ô 	ð 	ð.
+ð 
+ð 
+ð 
+ð 
+Ð.ñ 
+ô 
+ð 
+ðð ð ð ð Ð-ñ ô ð ð6
+ð 
+ð 
+ð 
+ð 
+Ð+ñ 
+ô 
+ð 
+ð
+ð 
+ð 
+ð 
+ð 
+Ð!3ñ 
+ô 
+ð 
+ð
+ð 
+ð 
+ð 
+ð 
+Ð 2ñ 
+ô 
+ð 
+ð$%ð %ð %ð %ð %Ð(ñ %ô %ð %ð8%ð %ð %ð %ð %Ð+ñ %ô %ð %ð*!ð !ð !ð !ð !Ð.ñ !ô !ð !ð@	ð 	ð 	ð 	ð 	Ð"4ñ 	ô 	ð 	ð	ð 	ð 	ð 	ð 	Ð-ñ 	ô 	ð 	ð!ð !ð !ð !ð !Ð.ñ !ô !ð !ð4
ð 
ð 
ð 
ð 
Ð/ñ 
ô 
ð 
ð$	ð 	ð 	ð 	ð 	Ð$ñ 	ô 	ð 	ð
ð 
ð 
ð 
ð 
 ñ 
ô 
ð 
ð
ð 
ð 
ð 
ð 
 ;ñ 
ô 
ð 
ð	ð 	ð 	ð 	ð 	 Kñ 	ô 	ð 	ð 	ð 	r   