+
    jHàjñ  ã            
      óÐ   a € 0 t $ R t^ RIHt ^ RIt^ RIHtHtHt Rt	R]
R&   RtR R	 l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RRR]	/R R lltRRRRRRRR/R R lltR# )uÞ  Gateway runtime-metadata footer (model Â· context % Â· cwd), off by default to keep replies
minimal. Config: ``display.runtime_footer: {enabled: bool, fields: [model, context_pct, cwd]}``
(order shown; drop any to hide), per-platform override ``display.platforms.<p>.runtime_footer``,
toggled by ``/footer on|off``. Fields: ``model`` (vendor prefix dropped), ``context_pct`` (last-call
occupancy), ``latency`` (turn wall-clock, opt-in â€” NOT in the default set so an unset ``fields``
renders exactly as before), ``served_model`` (opt-in, ``alias â†’ served``: the deployment a routing
proxy reported via ``x-litellm-model-id`` / ``x-litellm-model-api-base``, or Hermes' own fallback
route; skipped when the served model is the requested one), ``cwd`` (home-relative). ``gateway/run.py`` appends the footer to the
final response only (never to tool-progress or streaming partials); when streaming already
delivered the text, it goes out as a trailing message via ``send_trailing_footer()``.)ÚannotationsN)ÚAnyÚIterableÚOptionalÚcwdztuple[str, ...]Ú_DEFAULT_FIELDSu    Â· c               ó    € V ^8„  d   QhRRRR/# )é   r   ÚstrÚreturn© )Úformats   "Ú;/home/ubuntu/.hermes/hermes-agent/gateway/runtime_footer.pyÚ__annotate__r      s   € ÷ ñ ˜Cð  Cñ ó    c                ó\  € V '       g   R#  \         P                  P                  R4      p\         P                  P                  V 4      pV'       dH   W!8X  g-   VP	                  V\         P
                  ,           4      '       d   RV\        V4      R ,           # V#   \         d    T u # i ; i)zGReturn *cwd* with ``$HOME`` collapsed to ``~``.  Empty string if unset.Ú Ú~N)ÚosÚpathÚ
expanduserÚabspathÚ
startswithÚsepÚlenÚ	Exception)r   ÚhomeÚps   &  r   Ú_home_relative_cwdr      s~   € çÙðÜ�w‰w×!Ñ! #Ó&ˆÜ�G‰G�O‰O˜CÓ ˆß�Q”Y !§,¡,¨t´b·f±f­}×"=Ò"=Ø˜œ3˜t›9˜:˜Õ&Ð&ØˆøÜô ØŠ
ðús$   ŒAB Á1B ÂB ÂB ÂB+Â*B+c               ó    € V ^8„  d   QhRRRR/# )r	   ÚmodelúOptional[str]r   r
   r   )r   s   "r   r   r   #   s   € ÷ 5ñ 5˜ð 5¨#ñ 5r   c                óH   € V '       d   V P                  R^4      R,          # R# )u=   Drop ``vendor/`` prefix (``openai/gpt-5.4`` â†’ ``gpt-5.4``).Ú/r   éÿÿÿÿ)Úrsplit©r    s   &r   Ú_model_shortr'   #   s   € ç',ˆ5�<‰<˜˜QÓ Õ#Ð4°"Ð4r   c               ó   € V ^8„  d   QhRR/# ©r	   r   r
   r   )r   s   "r   r   r   (   s   € ÷ ,ñ ,�#ñ ,r   c                 ó„   €  ^ RI Hp  T ! RR4      #   \         d$    \        P                  P                  RR4      u # i ; i)é    ©Úterminal_envÚTERMINAL_CWDr   )Útools.terminal_scoper-   ÚImportErrorr   ÚenvironÚgetr,   s    r   Ú_env_cwdr3   (   s?   € ð2Ý5ñ ˜¨Ó+Ð+øô ô 2Ü�z‰z�~‰~˜n¨bÓ1Ò1ð2ús   ‚ ‘+?¾?c               ó$   € V ^8„  d   QhRRRRRR/# )r	   Úuser_configúdict[str, Any] | NoneÚplatform_keyú
str | Noner   zdict[str, Any]r   )r   s   "r   r   r   0   s#   € ÷ ñ Ð'<ð ÈJð Ðbpñ r   c                ó   € RRR\        \        4      /pT ;'       g    / P                  R4      ;'       g    / pV'       d+   VP                  R4      ;'       g    / P                  V4      MRpVP                  R4      \        V\        4      '       d   VP                  R4      MR.pV Fœ  p\        V\        4      '       g   K  RV9   d   \        VP                  R4      4      VR&   \        VP                  R4      \         4      '       g   Kf  VR,          '       g   Kw  VR,           Uu. uF  p\        V4      NK  	  upVR&   Kž  	  V# u upi )z�Resolve effective footer config: defaults (enabled=False) <
``display.runtime_footer`` < ``display.platforms.<platform_key>.runtime_footer``.ÚenabledFÚfieldsÚdisplayÚ	platformsNÚruntime_footer)Úlistr   r2   Ú
isinstanceÚdictÚboolr
   )r5   r7   ÚresolvedÚcfgÚplat_cfgÚsectionsÚsectionÚfs   &&      r   Úresolve_footer_configrI   0   s  € ð ˜5 (¬D´Ó,AÐB€HØ×Ð˜"×
!Ñ
! )Ó
,×
2Ð
2°€CßAM�—‘˜Ó$×*Ð*¨×/Ñ/°Ô=ÐSW€HØ—‘Ð(Ó)ÌZÐX`Ôbf×MgÒMg¨8¯<©<Ð8HÔ+IÐmqÐr€HÛˆÜ˜'¤4×(Ò(ÙØ˜ÔÜ"& w§{¡{°9Ó'=Ó">ˆH�YÑÜ�g—k‘k (Ó+¬T×2Ô2°w¸x×7HÖ7HØ29¸(Ö2CÓ!DÑ2C¨Q¤# a¦&Ñ2CÑ!DˆH�XÓñ ð €Oùò "Es   Ä+Ec               ó    € V ^8„  d   QhRRRR/# )r	   ÚsecondsÚfloatr   r
   r   )r   s   "r   r   r   A   s   € ÷ ñ ˜Uð  sñ r   c                óp   € V ^8  d   R# \        V 4      pV^<8  d   V R2# \        V^<4      w  r#V RVR R2# )z6Humanize a turn duration: ``<1s``, ``22s``, ``1m05s``.z<1sÚsÚmÚ02d)ÚroundÚdivmod)rK   ÚtotalrO   Úsecs   &   r   Ú_format_latencyrU   A   sK   € à�„{ÙÜ�'‹N€EØˆr„zØ�˜ˆ{ÐÜ�E˜2Ó�F€AØˆS��#�c�˜!ÐÐr   Úturn_secondsÚrequested_modelÚserved_modelr;   c               ó<   € V ^8„  d   QhRRRRRRRRRR	R
RRRRRRR/	# )r	   r    r!   Úcontext_tokensÚintÚcontext_lengthúOptional[int]r   rV   úOptional[float]rW   rX   r;   zIterable[str]r   r
   r   )r   s   "r   r   r   L   si   € ÷ dñ d Mð dÀ3ð dØ*7ðdØ>Kðdà(7ðdð ,9ðdð P]ðdð #0ð	dð GJñ	dr   c                ó²   a aaaaaaa
aa€ R VV3R llpR V VV3R llp	RV 3R lRV	RVR	V3R
 lRV3R l/o\         P                  V
VV3R lV 4       4      # )u³   Render the footer line, or "" if no fields have data. Fields whose data is missing (and
unknown field names) are skipped silently â€” a partial footer beats ``?%`` or empty slots.c               ó   € V ^8„  d   QhRR/# r)   r   )r   s   "r   r   Ú+format_runtime_footer.<locals>.__annotate__S   s   € ÷ ñ ˜ñ r   c            
     ó”   <€ S '       d?   S ^ 8”  d8   S^ 8¼  d1   \        ^ \        ^d\        SS ,          ^d,          4      4      4       R2# R# )r+   Ú%r   )ÚmaxÚminrQ   )r\   rZ   s   €€r   Úcontext_pctÚ*format_runtime_footer.<locals>.context_pctS   sD   ø€ ß˜n¨qÔ0°^ÀqÔ5HÜ˜!œS ¤e¨^¸nÕ-LÐPSÕ,SÓ&TÓUÓVÐWÐWXÐYÐYÙr   c               ó   € V ^8„  d   QhRR/# r)   r   )r   s   "r   r   ra   X   s   € ÷ ñ �Cñ r   c                 ód   <€ S;'       g    Sp \        V 4      pS'       d   SW39  d   V R S 2# R# )u    â†’ r   ©r'   )Ú	requestedÚaliasr    rW   rX   s     €€€r   ÚservedÚ%format_runtime_footer.<locals>.servedX   s;   ø€ Ø#×,Ð, uˆ	Ü˜YÓ'ˆß˜L°Ð0BÔBØ�W˜E , Ð0Ð0Ùr   r    c                 ó   <€ \        S 4      # ©Nrj   r&   s   €r   Ú<lambda>Ú'format_runtime_footer.<locals>.<lambda>`   s
   ø€ œ eÔ,r   rX   rf   Úlatencyc                 ó4   <€ S e   S ^ 8¼  d   \        S 4      # R# )Nr   )rU   )rV   s   €r   rq   rr   d   s!   ø€ ¸LÒ<TÐYeÐijÔYjœ?¨<Ó8ÐrÐprÐrr   r   c                 ó>   <€ \        S ;'       g    \        4       4      # rp   )r   r3   )r   s   €r   rq   rr   e   s   ø€ Ô)¨#×*;Ð*;´³Ô<r   c              3  ó€   <"  € T F3  pSP                  V4      ;o'       g   K  S! 4       ;o'       g   K/  Sx € K5  	  R # 5irp   )r2   )Ú.0ÚfieldÚrenderÚ	renderersÚvs   & €€€r   Ú	<genexpr>Ú(format_runtime_footer.<locals>.<genexpr>g   s7   øé € Ðc¡F˜5¸¿¹ÀuÓ9MÐ/M¨vÓ/M”QÑY_ÓYaÐTaÐTUÓTa—Q’Q£Fùs   ƒ>£>´
>)Ú_SEPÚjoin)r    rZ   r\   r   rV   rW   rX   r;   rf   rm   ry   rz   r{   s   ddddddd$  @@@r   Úformat_runtime_footerr€   L   sT   ÿù€ ÷ñ ÷
ò ð 	Ô,Ø˜Ø�{àÔrØÔ<ð€Iô �9‰9Öc¡FÓcÓcÐcr   c               ó@   € V ^8„  d   QhRRRRRRRRR	R
RRRRRRRRRR/
# )r	   r5   r6   r7   r8   r    r!   rZ   r[   r\   r]   r   rV   r^   rW   rX   r   r
   r   )r   s   "r   r   r   j   sq   € ÷ Nñ NÐ&;ð NÈ:ð NØ*ðNØ<?ðNØQ^ðNà(ðNà?NðNð (5ðNð LYðNð ehñNr   c        	        ó¤   € \        W4      p	V	P                  R4      '       g   R# \        Y#YETYxV	P                  R4      ;'       g    \        R7      # )a   Entry point for gateway/run.py: footer text, or "" when disabled / no data. Callers append it
to the final response themselves, preserving a single blank line of separation.
``turn_seconds`` is the caller-measured (``time.monotonic()``) run duration; ``None`` skips the
``latency`` field.r:   r   r;   )r    rZ   r\   r   rV   rW   rX   r;   )rI   r2   r€   r   )
r5   r7   r    rZ   r\   r   rV   rW   rX   rD   s
   $$$$$$$$$ r   Úbuild_footer_linerƒ   j   sN   € ô   Ó
:€CØ�7‰7�9×ÒÙÜ  uØ0>ÐVbØ1@Ø(+¯©°Ó(9×(LÐ(L¼_ôNð Nr   )r    rf   r   rp   )Ú__conditional_annotations__Ú__doc__Ú
__future__r   r   Útypingr   r   r   r   Ú__annotations__r~   r   r'   r3   rI   rU   r€   rƒ   )r„   s   @r   Ú<module>r‰      sµ   øðô	Yõ #ã 	ß *Ñ *à#B€�Ó BØ€õõ5õ
,÷õ"ðdØNRðdà:>ðdð <@ðdð `dðdð 3B÷	dð<Nà+/ðNàQUðNð 8<ðNð \`÷Nñ Nr   