
    Rmj(                       d Z ddlmZ ddlmZmZmZmZ ddlm	Z	m
Z
mZ ddlmZmZmZ e	d         Z G d de
          Zd)dZd*dZ ed           G d d                      Z ed           G d d                      Z ed           G d d                      Z ed           G d d                      ZeZ ed           G d d                      Z ed           G d d                      Z ed           G d d                      Z ed           G d  d!                      Z ed           G d" d#                      Zd$Z ed           G d% d&                      Zg d'Z d(S )+z+Observability plugin configuration helpers.    )annotations)	dataclassfieldfieldsis_dataclass)LiteralProtocolcast)Json
JsonObjectUnsupportedBehavior)inheriteventtoolc                      e Zd ZddZdS )_SupportsToDictreturnr   c                    d S N selfs    `/home/thesage/.hermes/hermes-agent/venv/lib/python3.11/site-packages/nemo_relay/observability.pyto_dictz_SupportsToDict.to_dict   s          Nr   r   )__name__
__module____qualname__r   r   r   r   r   r      s        ((((((r   r   valueobjectr   r   c                    t           d          r't          t                                                     S t	                     r1t           t                    s fdt                     D             S t           t                    rd  D             S t           t                    rd  
                                D             S t          t                     S )Nr   c                h    i | ].}t          |j                  x|j        t                    /S r   )getattrname
_normalize).0
field_infofield_valuer    s     r   
<dictcomp>z_normalize.<locals>.<dictcomp>   sF     
 
 
&ujo>>>K OZ44KKKr   c                ,    g | ]}t          |          S r   )r&   )r'   items     r   
<listcomp>z_normalize.<locals>.<listcomp>   s     333T
4  333r   c                ^    i | ]*\  }}|t          t          |          t          |          +S r   )r
   strr&   )r'   keyvals      r   r*   z_normalize.<locals>.<dictcomp>    s2    aaaHCQTQ`S#
3Q`Q`Q`r   )hasattrr
   r   r   r   
isinstancetyper   listdictitemsr   )r    r)   s   `@r   r&   r&      s    ui   6OU++33555E 
:eT#:#: 

 
 
 
 
$Umm
 
 
 	

 % 433U3333% baaaaaaer   r   c                F    t          t          t          |                     S r   )r
   r   r&   )r    s    r   _normalize_objectr9   $   s    
Ju--...r   T)slotsc                  F    e Zd ZU dZdZded<   dZded<   dZded<   dd
ZdS )ConfigPolicyz3Policy for unsupported observability configuration.warnr   unknown_componentunknown_fielderrorunsupported_valuer   r   c                ,    | j         | j        | j        dS )z9Serialize this policy to the canonical JSON object shape.r>   r?   rA   rC   r   s    r   r   zConfigPolicy.to_dict0   s%     "&!7!/!%!7
 
 	
r   Nr   )	r   r   r   __doc__r>   __annotations__r?   rA   r   r   r   r   r<   r<   (   se         ==-33333)/M////-44444
 
 
 
 
 
r   r<   c                      e Zd ZU dZded<   dZded<    ee          Zded	<    ee          Z	ded
<   dZ
ded<   dZded<   dZded<   ddZdS )AtofStreamSinkConfigz Stream sink for raw ATOF events.r/   url	http_postz+Literal['http_post', 'websocket', 'ndjson']	transportdefault_factorydict[str, str]headers
header_env  inttimeout_millispreservez#Literal['preserve', 'replace_dots']field_name_policyN
str | Noner%   r   r   c                x    t          d| j        | j        | j        | j        | j        | j        | j        d          S )zCSerialize this ATOF stream sink to the canonical JSON object shape.stream)r4   r%   rH   rJ   rN   rO   rR   rT   )r9   r%   rH   rJ   rN   rO   rR   rT   r   s    r   r   zAtofStreamSinkConfig.to_dictE   sF      	x!^<"o"&"5%)%;	 	
 
 	
r   r   )r   r   r   rD   rE   rJ   r   r6   rN   rO   rR   rT   r%   r   r   r   r   rG   rG   9   s         **HHH=HIHHHH#eD999G9999!&t!<!<!<J<<<<N=GGGGGD
 
 
 
 
 
r   rG   c                  8    e Zd ZU dZdZded<   dZded<   dd
ZdS )
AtofConfigz$Multi-sink raw ATOF export settings.FboolenabledNz6list[AtofFileSinkConfig | AtofStreamSinkConfig] | Nonesinksr   r   c                :    t          | j        | j        d          S )z>Serialize this ATOF config to the canonical JSON object shape.)r[   r\   )r9   r[   r\   r   s    r   r   zAtofConfig.to_dict\   s(     < 
 
 	
r   r   )r   r   r   rD   r[   rE   r\   r   r   r   r   rY   rY   U   sR         ..GDHEHHHH
 
 
 
 
 
r   rY   c                  F    e Zd ZU dZdZded<   dZded<   dZded<   ddZdS )AtofFileSinkConfigz1Filesystem destination for raw ATOF JSONL events.NrU   output_directoryfilenameappendzLiteral['append', 'overwrite']moder   r   c                H    t          d| j        | j        | j        d          S )Nfile)r4   r`   ra   rc   )r9   r`   ra   rc   r   s    r   r   zAtofFileSinkConfig.to_dictn   s1     $($9 M		 
 
 	
r   r   )	r   r   r   rD   r`   rE   ra   rc   r   r   r   r   r_   r_   f   sd         ;;#'''''H+3D3333
 
 
 
 
 
r   r_   c                      e Zd ZU dZdZded<   dZded<   dZded<   dZded	<   dZ	ded
<   dZ
ded<   dZded<   dZded<   ddZdS )S3StorageConfiga  S3-compatible remote storage settings for ATIF trajectory upload.

    Every connection field is optional. Unset fields fall back to the matching
    ``AWS_*`` environment variable. Secret credentials are referenced by env
    var *name* (the ``_var`` suffix), validated at plugin initialization time,
    so multiple destinations can each carry their own credentials without
    leaking secret material into the config.
     r/   bucketNrU   
key_prefixaccess_key_idsecret_access_key_varsession_token_varregionendpoint_urlzbool | None
allow_httpr   r   c                    t          d| j        | j        | j        | j        | j        | j        | j        | j        d	          S )zDSerialize this S3 storage config to the canonical JSON object shape.s3)	r4   ri   rj   rk   rl   rm   rn   ro   rp   )	r9   ri   rj   rk   rl   rm   rn   ro   rp   r   s    r   r   zS3StorageConfig.to_dict   sM     +"o!%!3)-)C%)%;+ $ 1"o
 

 
 	
r   r   )r   r   r   rD   ri   rE   rj   rk   rl   rm   rn   ro   rp   r   r   r   r   rg   rg   }   s           F!J!!!! $M$$$$(,,,,,$(((((F#L####"J""""
 
 
 
 
 
r   rg   c                  |    e Zd ZU dZdZded<    ee          Zded<    ee          Z	ded<   d	Z
d
ed<   ddZdS )HttpStorageConfigz2HTTP endpoint settings for ATIF trajectory upload.rh   r/   endpointrK   rM   rN   rO   rP   rQ   rR   r   r   c                T    t          d| j        | j        | j        | j        d          S )zFSerialize this HTTP storage config to the canonical JSON object shape.http)r4   ru   rN   rO   rR   )r9   ru   rN   rO   rR   r   s    r   r   zHttpStorageConfig.to_dict   s6      M<"o"&"5 
 
 	
r   Nr   )r   r   r   rD   ru   rE   r   r6   rN   rO   rR   r   r   r   r   rt   rt      s         <<H#eD999G9999!&t!<!<!<J<<<<N

 

 

 

 

 

r   rt   c                      e Zd ZU dZdZded<   dZded<   dZd	ed
<   dZded<   dZ	ded<   dZ
ded<   dZd	ed<   dZded<   dZded<   ddZdS )
AtifConfigz.Per-top-level-agent ATIF file export settings.FrZ   r[   z
NeMo Relayr/   
agent_nameNrU   agent_versionunknown
model_namezlist[JsonObject] | Nonetool_definitionszJsonObject | Noneextrar`   z!nemo-relay-atif-{session_id}.jsonfilename_templatez0list[S3StorageConfig | HttpStorageConfig] | Nonestorager   r   c           
         | j         | j        | j        | j        | j        | j        | j        | j        | j        d	}|d         |	                    d           t          |          S )z>Serialize this ATIF config to the canonical JSON object shape.)	r[   rz   r{   r}   r~   r   r`   r   r   r{   )r[   rz   r{   r}   r~   r   r`   r   r   popr9   )r   r    s     r   r   zAtifConfig.to_dict   sn     |/!// $ 5Z $ 5!%!7|

 

 !)IIo&&& '''r   r   )r   r   r   rD   r[   rE   rz   r{   r}   r~   r   r`   r   r   r   r   r   r   ry   ry      s         88G"J"""" $M$$$$J044444#E#####'''''@@@@@@DGDDDD( ( ( ( ( (r   ry   c                  $   e Zd ZU dZdZded<   dZded<    ed 	          Zd
ed<   dZ	ded<   dZ
ded<    ee	          Zded<    ee	          Zded<   dZded<   dZded<   dZded<   dZded<   dZded<    ee	          Zded<   d#d"ZdS )$
OtlpConfigz8Shared OpenTelemetry/OpenInference OTLP export settings.FrZ   r[   r   MarkProjectionmark_projectionc                     dgS )Nz	llm.chunkr   r   r   r   <lambda>zOtlpConfig.<lambda>   s    ;- r   rK   z	list[str]mark_exclude_nameshttp_binaryzLiteral['http_binary', 'grpc']rJ   NrU   ru   rM   rN   resource_attributesz
nemo-relayr/   service_nameservice_namespaceservice_versioninstrumentation_scoperP   rQ   rR   zlist[dict[str, str]]attribute_mappingsr   r   c                    t          | j        | j        | j        | j        | j        | j        | j        | j        | j	        | j
        | j        | j        | j        d          S )z>Serialize this OTLP config to the canonical JSON object shape.)r[   r   r   r   rJ   ru   rN   r   r   r   r   r   rR   )r9   r[   r   r   r   rJ   ru   rN   r   r   r   r   r   rR   r   s    r   r   zOtlpConfig.to_dict   sh     <#'#7&*&=&*&=!^ M<'+'? $ 1%)%;#'#7)-)C"&"5 
 
 	
r   r   )r   r   r   rD   r[   rE   r   r   r   rJ   ru   r6   rN   r   r   r   r   r   rR   r5   r   r   r   r   r   r   r      sJ        BBG&/O////$)E:O:O$P$P$PPPPP0=I====H#eD999G9999*/%*E*E*EEEEE$L$$$$$((((("&O&&&&(,,,,,N/4uT/J/J/JJJJJ
 
 
 
 
 
r   r   c                      e Zd ZU dZdZded<   dZded<   dZded	<   dZd
ed<   dZ	d
ed<    e
e          Zded<   ddZdS )ObservabilityConfigzDCanonical config document for the top-level observability component.   rQ   versionNzAtofConfig | NoneatofzAtifConfig | NoneatifzOtlpConfig | NoneopentelemetryopeninferencerK   r<   policyr   r   c           	     j    t          | j        | j        | j        | j        | j        | j        d          S )zGSerialize this observability config to the canonical JSON object shape.)r   r   r   r   r   r   )r9   r   r   r   r   r   r   r   s    r   r   zObservabilityConfig.to_dict
  s>     <		!%!3!%!3+ 	
 	
 		
r   r   )r   r   r   rD   r   rE   r   r   r   r   r   r<   r   r   r   r   r   r   r      s         NNG"D"""""D""""'+M++++'+M++++ 5>>>F>>>>
 
 
 
 
 
r   r   observabilityc                  4    e Zd ZU dZded<   dZded<   dd	Zd
S )ComponentSpecz*Top-level observability component wrapper.z ObservabilityConfig | JsonObjectconfigTrZ   r[   r   r   c                F    t           | j        t          | j                  dS )z7Serialize this component to the canonical plugin shape.)kindr[   r   )OBSERVABILITY_PLUGIN_KINDr[   r9   r   r   s    r   r   zComponentSpec.to_dict"  s(     .|'44
 
 	
r   Nr   )r   r   r   rD   rE   r[   r   r   r   r   r   r     sM         44,,,,G
 
 
 
 
 
r   r   )r<   AtofEndpointConfigr_   rG   rY   ry   rt   r   rg   r   r   r   r   N)r    r!   r   r   )r    r!   r   r   )!rD   
__future__r   dataclassesr   r   r   r   typingr   r	   r
   
nemo_relayr   r   r   r   r   r&   r9   r<   rG   rY   r_   r   rg   rt   ry   r   r   r   r   __all__r   r   r   <module>r      s   2 1 " " " " " " > > > > > > > > > > > > * * * * * * * * * * < < < < < < < < < <34) ) ) ) )h ) ) )    / / / / 
 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
6 
 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
& *  !
 !
 !
 !
 !
 !
 !
 !
H 
 
 
 
 
 
 
 
* ( ( ( ( ( ( ( (> #
 #
 #
 #
 #
 #
 #
 #
L 
 
 
 
 
 
 
 
0 ,  
 
 
 
 
 
 
 
  r   