+
    „WÝjh  ã                  óp  € R t ^ RIHt ^ RIt^ RIt^ RIHtHt ^RIH	t
 ^RIHt ]P                  ! ]4      tR R ltR R	 ltR
 R ltR R ltR R ltRR/R R llt]P,                  ! 4       t]
P0                  tR R ltR R ltR%R R lltR R ltRRRR/R R lltR R  ltRRR!RR"R/R# R$ llt R# )&a—  Call-site API for process-level shared-metrics facts.

Setup completion, slash commands, compression, model switches, fallbacks and extension installs
happen outside any single tool or model call, so their producers call these functions directly.
Every function takes RAW values (normalization lives in shared_metrics_fields), is a no-op unless
shared metrics are enabled, and never raises into the caller.
)ÚannotationsN)ÚAnyÚCallable)Úshared_metrics_contract)Úshared_metrics_fieldsc               ó(   € V ^8„  d   QhRRRRRRRR/# )	é   ÚmarkÚstrÚbuildz$Callable[..., dict[str, str] | None]Úrawr   ÚreturnÚNone© )Úformats   "ÚbC:\Users\johnn\AppData\Local\hermes\hermes-agent\hermes_cli\observability\shared_metrics_events.pyÚ__annotate__r      s0   € ÷ 
Lñ 
L�ð 
LÐ@ð 
LÈð 
LÐQUñ 
Ló    c                ó¶   €  ^RI HpHp V! 4       '       g   R# V! R/ VB pVe   V! W4       R# R#   \         d    \        P                  RT RR7        R# i ; i)é   )ÚenabledÚrecord_process_markNzShared-metrics %s not recordedT©Úexc_infor   )Úrelay_shared_metricsr   r   Ú	ExceptionÚloggerÚdebug)r	   r   r   r   r   Údatas   &&,   r   Ú_emitr      sW   € ð	LßFá�yŠyÙÙ‰|�s‰|ˆØÒÙ Ö+ñ øäô LÜ�‰Ð5°tÀdˆ×KðLús   ‚1 ™1 ±#AÁAc               ó    € V ^8„  d   QhRRRR/# )r   Úmarksz list[tuple[str, dict[str, str]]]r   Úintr   )r   s   "r   r   r   "   s   € ÷ 	ñ 	Ð6ð 	¸3ñ 	r   c                ó†   €  ^RI Hp V '       d	   V! V 4      # ^ #   \         d    \        P	                  RRR7        ^ # i ; i)z·``_emit`` for facts recovered from a file: how many rows are settled (saved, rejected, or
collection off), so the caller deletes the file only then. Blocks on the store: no hot paths.)Úrecord_process_marks_savedz*Shared-metrics recovered rows not recordedTr   )r   r$   r   r   r   )r!   r$   s   & r   Ú
emit_savedr%   "   s@   € ðÝDç49Ñ)¨%Ó0Ð@¸qÐ@øÜô Ü�‰ÐAÈDˆÔQÚðús   ‚ � ˜ š"A ¿A c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úsurfacer
   Úproviderú
str | Noner   r   r   )r   s   "r   r   r   .   s&   € ÷ mñ m sð m°jð mÀTñ mr   c                óZ   € \        \        P                  \        P                  WR 7       R# )©r'   r(   N)r   ÚcontractÚSETUP_COMPLETED_MARKÚfields_Úsetup_completed_fieldsr+   s   $$r   Úrecord_setup_completedr0   .   s   € Ü	Œ(×
'Ñ
'¬×)GÑ)GÐQX×lr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úcommandr
   r'   r   r   r   )r   s   "r   r   r   2   s&   € ÷ gñ g Sð g°3ð g¸4ñ gr   c                óZ   € \        \        P                  \        P                  WR 7       R# )©r2   r'   N)r   r,   ÚSLASH_COMMAND_MARKr.   Úslash_command_fieldsr4   s   $$r   Úrecord_slash_commandr7   2   s   € Ü	Œ(×
%Ñ
%¤w×'CÑ'CÈW×fr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   Úscoper
   Úhitsr"   Úoutcomer   r   r   )r   s   "r   r   r   6   s.   € ÷ bñ b ð b¨Cð b¸#ð bÀ$ñ br   c                óJ   € ^RI Hp \        \        P                  W0WR7       R# )r   )Útool_search_fields)r9   r:   r;   N)Úshared_metrics_connectorsr=   r   r,   ÚTOOL_SEARCH_MARK)r9   r:   r;   r=   s   $$$ r   Úrecord_tool_searchr@   6   s   € Ý=ä	Œ(×
#Ñ
#Ð%7È4×ar   Úfailure_classc               ó0   € V ^8„  d   QhRRRRRRRRRRR	R
/# )r   Útriggerr
   r;   Útokens_beforez
int | NoneÚcontext_lengthrA   r)   r   r   r   )r   s   "r   r   r   <   s>   € ÷ ñ ØðØ!ðØ2<ðØNXðàðð 
ñr   c           
     ó^   € \        \        P                  \        P                  WW#VR 7       R# )©rC   r;   rD   rE   rA   N)r   r,   ÚCOMPRESSION_MARKr.   Úcompression_fieldsrG   s   $$$$$r   Úrecord_compressionrJ   <   s%   € ô 
Ü×!Ñ!¤7×#=Ñ#=ÀwØ#ÐR_÷r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   rC   r
   rD   r   r   r   r   )r   s   "r   r   r   Q   s!   € ÷ <ñ < sð <¸3ð <À4ñ <r   c                ó   € W3\         n        R # ©N©Ú_compression_attemptÚpending)rC   rD   s   &&r   Úbegin_compression_attemptrQ   Q   s   € Ø$+Ð#;ÔÖ r   c               ó   € V ^8„  d   QhRR/# )r   r   r   r   )r   s   "r   r   r   U   s   € ÷ (ñ ( Tñ (r   c                 ó   € R\         n        R# )zFClear this thread's pending attempt without recording a shared metric.NrN   r   r   r   Údiscard_compression_attemptrT   U   s   € à#'ÔÖ r   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR	/# )
r   Úcommit_statusr
   rA   r)   rE   r   Úagentr   r   r   )r   s   "r   r   r   Z   s4   € ÷ 1ñ 1Øð1Ø'1ð1ØCFð1ØORð1à	ñ1r   c                óH  € \        \        RR4      Rup\        n        V'       g   R# V R8H  p\        P                  ! V'       d   RMRV4      pV'       d   RMV\
        9   d   RMRp\        V^ ,          Wt^,          VVR7       VR8X  d   Ve   ^RIHp V! VR	4       R# R# R# )
z]Count this thread's pending compression attempt once; a committed one broke the prompt cache.rP   NÚ	committedÚsuccessÚfailedÚskippedrG   )Úrecord_cache_breakÚcompression)	ÚgetattrrO   rP   r.   Úcompression_failure_classÚ_SKIPPED_COMPRESSION_CLASSESrJ   Úshared_metrics_efficiencyr]   )	rV   rA   rE   rW   rP   rY   Úreasonr;   r]   s	   &&&&     r   Úfinish_compression_attemptrd   Z   sš   € ô -4Ô4HÈ)ÐUYÓ,ZÐ\`Ð)€GÔ!Ô)ßÙà Ñ,€IÜ×.Ò.¿I©yÈ8ÐUbÓc€Fß$‰i°vÔA]Ô7]©)Ðck€GÜØ˜•
 GÀ1½:ÐVdØõð �)Ô Ò 1ÝAá˜5 -Ö0ñ !2Ñr   c               ó    € V ^8„  d   QhRRRR/# )r   Úeventr   r   r   r   )r   s   "r   r   r   o   s   € ÷ =ñ =¨ð =°ñ =r   c                óˆ   € V P                  4       pV'       d   \        V RR4      '       d   R# RV n        \        VRR7       R# )z’Count a user-typed gateway slash command once: a queued busy-path event re-enters
``_handle_message`` when drained, so the event carries the mark.Ú_slash_command_countedFNTÚgatewayr4   )Úget_commandr_   rh   r7   )rf   r2   s   & r   Úrecord_gateway_slash_commandrk   o   s9   € ð ×ÑÓ!€Gß”g˜eÐ%=¸u×EÒEÙØ#'€EÔ Ü °)×<r   Ú
from_modelÚ
session_idc               ó0   € V ^8„  d   QhRRRRRRRRRRRR	/# )
r   Úfrom_providerr)   Úto_providerr'   r
   rl   rm   r   r   r   )r   s   "r   r   r   y   sF   € ÷ Zñ ZØ ðZØ/9ðZØDGðZØU_ðZàðZð 
ñZr   c                ó"  € \        \        P                  \        P                  WVR7       V'       d   ^RIHp V! RWR7       V'       d    ^RIHp V! \        V4      4       R	# R	#   \         d    \        P                  RRR7        R	# i ; i)
z¬``from_model`` also counts the switch as friction against the model the user left;
``session_id`` (the switched session) also counts how many turns that model served first.)ro   rp   r'   )Úrecord_model_frictionÚswitch_away)r(   Úmodel)Úrecord_model_switch_afterz.Shared-metrics model_switch_after not recordedTr   N)r   r,   ÚMODEL_SWITCH_MARKr.   Úmodel_switch_fieldsÚshared_metrics_modelrr   r   ru   r
   r   r   r   )ro   rp   r'   rl   rm   rr   ru   s   $$$$$  r   Úrecord_model_switchry   y   sv   € ô 
Ü×"Ñ"¤G×$?Ñ$?Ø#Àgõ÷ Ý?á˜m°mÕVßð	ZÝGá%¤c¨*£oÖ6ñ	 øô
 ô 	ZÜ�L‰LÐIÐTXˆL×Yð	Zús   ÁA( Á("BÂBc               ó(   € V ^8„  d   QhRRRRRRRR/# )r   ro   r)   rp   rc   r   r   r   r   )r   s   "r   r   r   �   s*   € ÷ ñ  jð ¸zð ÐSVð Ð[_ñ r   c                ó\   € \        \        P                  \        P                  WVR 7       R# )©ro   rp   rc   N)r   r,   ÚFALLBACK_MARKr.   Úfallback_fieldsr|   s   $$$r   Úrecord_fallbackr   �   s    € Ü	Ü×Ñ¤× 7Ñ 7Ø#ÀV÷r   ÚregistryÚerrorc               ó8   € V ^8„  d   QhRRRRRRRRRRRRR	R
RR/# )r   Úkindr
   ÚsourceÚnamer)   r;   rA   r€   r�   zBaseException | Noner   r   r   )r   s   "r   r   r   —   sV   € ÷ ñ ØðØðØ%/ðØ:=ðð ðð 1;ðð K_ðð
 
ñr   c                ó`   € \        \        P                  \        P                  WW#WEVR7	       R# )zõ``failure_class`` names why a failed install stopped (the kind's closed set); a raised
``error`` is classified by its tagged class or type instead, inside the metrics guard.
``registry`` is the skills-hub adapter id that resolved/served a skill.©rƒ   r„   r…   r;   rA   r€   r�   N)r   r,   ÚEXTENSION_INSTALL_MARKr.   Úextension_install_fieldsr‡   s   $$$$$$$r   Úrecord_extension_installrŠ   —   s'   € ô 
Ü×'Ñ'¬×)IÑ)IØ tØ#¸e÷r   rM   )!Ú__doc__Ú
__future__r   ÚloggingÚ	threadingÚtypingr   r   Ú r   r,   r   r.   Ú	getLoggerÚ__name__r   r   r%   r0   r7   r@   rJ   ÚlocalrO   ÚCOMPRESSION_SKIP_CLASSESra   rQ   rT   rd   rk   ry   r   rŠ   r   r   r   Ú<module>r•      sÑ   ðñõ #ã Û ß  å 1Ý .à	×	Ò	˜8Ó	$€õ
Lõ	õmõgõbðà $÷ð !—’Ó(Ð ð
  (×@Ñ@Ð õ<õ(÷
1õ*=ðZØbfðZà!÷Zõ.ðð !%ðð >Bðð bf÷ñ r   