
    yj                        d Z ddlZddlmZmZ ddlmZ  G d de          Ze G d de                      Z	e G d	 d
e                      Z
e G d de                      Ze G d de                      Ze G d de                      Ze G d de                      Ze G d de                      Ze G d de                      Ze G d de                      Ze G d de                      Ze G d de                      Ze G d de                      Ze G d d e                      Ze G d! d"e                      Z G d# d$e          ZdS )%z/
Custom exceptions for the Honcho application.
    N)Anyfinal)settingsc                   X     e Zd ZU dZdZeed<   dZeed<   ddedz  dedz  f fdZ	 xZ
S )	HonchoExceptionz.Base exception for all Honcho-specific errors.  status_codezAn unexpected error occurreddetailNc                     |p| j         | _         |p| j        | _        t                                          | j                    d S )N)r
   r	   super__init__)selfr
   r	   	__class__s      6/DATA/AppData/hermes/projects/honcho/src/exceptions.pyr   zHonchoException.__init__   sA    +&:$*:%%%%%    )NN)__name__
__module____qualname____doc__r	   int__annotations__r
   strr   __classcell__r   s   @r   r   r      s         88K0FC000& &sTz &sTz & & & & & & & & & &r   r   c                       e Zd ZdZdZdZdS )ResourceNotFoundExceptionz8Exception raised when a requested resource is not found.i  zResource not foundNr   r   r   r   r	   r
    r   r   r   r      s        BBK!FFFr   r   c                   0     e Zd ZdZdZdedef fdZ xZS )ObserverExceptionzLException raised when a request tries to add too many observers to a sessioni  session_nameextra_countc                     d| d| ddt           j         dz   dz   | _        t                                          | j                   d S )NzCannot create session z with z observers. zMaximum allowed is z observers per session. z6Observers are peers with 'observe_others' set to true.)r   SESSION_OBSERVERS_LIMITr
   r   r   )r   r!   r"   r   s      r   r   zObserverException.__init__%   sb    R\RRRRR^H$D^^^_FG 	
 	%%%%%r   )	r   r   r   r   r	   r   r   r   r   r   s   @r   r    r       sV        VVK&S &s & & & & & & & & & &r   r    c                       e Zd ZdZdZdZdS )ValidationExceptionz'Exception raised when validation fails.  zValidation errorNr   r   r   r   r&   r&   .   s        11KFFFr   r&   c                       e Zd ZdZdZdZdS )ConflictExceptionz2Exception raised when there's a resource conflict.i  zResource conflictNr   r   r   r   r)   r)   6   s        <<K FFFr   r)   c                       e Zd ZdZdZdZdS )AuthenticationExceptionz+Exception raised when authentication fails.i  zAuthentication failedNr   r   r   r   r+   r+   >   s        55K$FFFr   r+   c                       e Zd ZdZdZdZdS )AuthorizationExceptionz*Exception raised when authorization fails.i  z&Not authorized to access this resourceNr   r   r   r   r-   r-   F   s        44K5FFFr   r-   c                       e Zd ZdZdZdZdS )DisabledExceptionz,Exception raised when a feature is disabled.i  zFeature is disabledNr   r   r   r   r/   r/   N   s        66K"FFFr   r/   c                       e Zd ZdZdZdZdS )FilterErrorz;Exception raised when a filter is misconfigured or invalid.r'   zInvalid filter configurationNr   r   r   r   r1   r1   V   s        EEK+FFFr   r1   c                       e Zd ZdZdZdS )UnsupportedFileTypeErrori  zUnsupported file typeNr   r   r   r	   r
   r   r   r   r3   r3   ^           K$FFFr   r3   c                       e Zd ZdZdZdS )FileTooLargeErrori  zFile too largeNr4   r   r   r   r7   r7   d   s        KFFFr   r7   c                       e Zd ZdZdZdS )FileProcessingErrorr   zFile processing errorNr4   r   r   r   r9   r9   j   r5   r   r9   c                       e Zd ZdZdZdZdS )SurprisalErrorzDException raised when surprisal sampling fails during a dream cycle.r   zSurprisal sampling failedNr   r   r   r   r;   r;   p   s        NNK(FFFr   r;   c                       e Zd ZdZdZdZdS )SpecialistExecutionErrorzDException raised when a specialist fails during dream orchestration.r   zSpecialist execution failedNr   r   r   r   r=   r=   x   s        NNK*FFFr   r=   c                       e Zd ZdZdZdZdS )VectorStoreErrorz5Exception raised when a vector store operation fails.r   zVector store operation failedNr   r   r   r   r?   r?      s        ??K,FFFr   r?   c                        e Zd ZU dZeeef         ed<   dededdf fdZe	dedefd	            Z
deeef         fd
Z xZS )LLMErrora  Exception raised when an LLM call fails.

    Accepts arbitrary positional and keyword inputs, normalizes them into a
    JSON-serializable object, and uses the resulting JSON string as the
    exception message. The normalized object is available via ``to_dict()``
    and the ``data`` attribute.

    Positional and keyword inputs are represented as a JSON object. If a
    single positional argument is a mapping and there are no keyword
    arguments, that mapping is used as the root object; otherwise the shape is
    ``{"args": [...], "kwargs": {...}}``. Values that are not natively
    serializable are converted using ``repr``.
    dataargskwargsreturnNc                     t          |          |d}t          j        || j        d          }|| _        t                                          |           d S )N)rC   rD   F)defaultensure_ascii)listjsondumps_json_fallbackrB   r   r   )r   rC   rD   
normalizedmessager   s        r   r   zLLMError.__init__   s]    "4jjF;;
* 3%
 
 
 	!!!!!r   valuec                      t          |           S )zGFallback serializer that returns ``repr(value)`` for unsupported types.)repr)rO   s    r   rL   zLLMError._json_fallback   s     E{{r   c                     | j         S )z:Return the normalized JSON object for programmatic access.)rB   )r   s    r   to_dictzLLMError.to_dict   s
    yr   )r   r   r   r   dictr   r   r   r   staticmethodrL   rS   r   r   s   @r   rA   rA      s           sCx."c "S "T " " " " " " c c    \c3h        r   rA   )r   rJ   typingr   r   
src.configr   	Exceptionr   r   r    r&   r)   r+   r-   r/   r1   r3   r7   r9   r;   r=   r?   rA   r   r   r   <module>rY      s                  	& 	& 	& 	& 	&i 	& 	& 	& " " " " " " " " & & & & & & & &          /       ! ! ! ! ! ! ! ! % % % % %o % % % 6 6 6 6 6_ 6 6 6 # # # # # # # # , , , , ,/ , , , % % % % % % % %
        
 % % % % %/ % % %
 ) ) ) ) )_ ) ) ) + + + + + + + + - - - - - - - -         y          r   