+
    jHàj{$  ã                  ó˜   € R t ^ RIHt ^ RIt^ RIt^ RIHt ]! R04      tR R lt	R R lt
R	 R
 ltR R ltR R ltR R ltR R ltR# )a‘  Main's TUI text for the session reads its sidecar answered itself: /status, /context.

On main the TUI's ``slash.exec`` never reached the messaging gateway's handlers: ``/status`` was
``session.status`` (``Hermes TUI Status``), ``/context`` was ``_format_live_context_output`` (the
conversation counts, then the desktop gauge's category table). A TUI session on the shared owner
gets the same lines here, read from the owner's live agent and stored row; every other surface keeps
the gateway's own handlers (``gateway/session_commands.py``). ``/cron``, the classic CLI's handler
that main's TUI ran in its slash worker, is gateway/session_cron_commands.py.
)ÚannotationsN)ÚCounterÚtuic               ó    € V ^8„  d   QhRRRR/# )é   ÚnameÚstrÚarg© )Úformats   "Ú>/home/ubuntu/.hermes/hermes-agent/gateway/session_tui_reads.pyÚ__annotate__r      s   € ÷ ñ ˜3ð  Sñ ó    c                óp   € V e   V P                   \        9  d   R# VR8X  d   \        # VR8X  d   \        # R# )zUThe renderer for a TUI session's read of *name*, or None to keep the gateway handler.NÚstatusÚcontext)ÚsourceÚ_TUI_SOURCESÚ_statusÚ_context)Úpolicyr   r	   s   &&&r   Útui_readr      s2   € à‚~˜Ÿ™¬lÔ:ÙØˆxÔÜˆØˆyÔÜˆÙr   c               ó   € V ^8„  d   QhRR/# ©r   Úreturnr   r
   )r   s   "r   r   r      s   € ÷ ñ  #ñ r   c                ó"  € \         P                  ! \        4      ;_uu_ 4        ^ RIHp V! V P
                  VP                  4      R,          R,          ;'       g    VP                  uuRRR4       #   + '       g   i     TP                  # ; i)é    )Úlocal_receiptÚentryÚ
session_idN)Ú
contextlibÚsuppressÚ	ExceptionÚhermes_state_localr   Údbr   )Ú	authorityÚrefr   s   && r   Ú
_stored_idr'      s\   € Ü	×	Ò	œY×	'Õ	'Ý4Ù˜YŸ\™\¨3¯>©>Ó:¸7ÕCÀLÕQ×cÐcÐUX×UcÑUc÷ 
(×	'×	'Ñ	'ð �>‰>Ðús   £AA3Á3B	c               ó   € V ^8„  d   QhRR/# r   r
   )r   s   "r   r   r   &   s   € ÷ iñ i¸ñ ir   c                óŽ  € ^ RI HpHp ^ RIHp \        W4      p	/ p
\        P                  ! \        4      ;_uu_ 4        V P                  P                  V	4      ;'       g    / p
RRR4       V P                  V4      P                  R8g  pT! Y”Y¤f   VP                  V 4      MRVf   VP                  MRVe   \        VR^ 4      MRW°P                   R7      pVP#                  VP$                  4      pRP'                  RR	.V! VR
R4      OV'       d   RVR,           2.M. OV! VRRRRRR4      O4      #   + '       g   i     LØ; i)zW``tui_gateway/methods_session.py`` ``session.status`` on main, for the owner's session.)Úbuild_status_fieldsÚstatus_lines)ÚserverNÚidleÚsession_total_tokens)ÚmodelÚproviderÚtokensÚagent_runningÚhomeÚ
zHermes TUI StatusÚ r   Úpathz	Project: r   Útitler/   ÚcreatedÚlast_activityr1   r2   )Úhermes_cli.status_reportr*   r+   Útui_gatewayr,   r'   r    r!   r"   r$   Úget_sessionÚ_handleÚexecution_stateÚcurrent_modelr0   ÚgetattrÚ
profile_idÚ_project_info_for_cwdÚcwdÚjoin)r%   r&   Úliver   Úagentr	   r*   r+   r,   ÚstoredÚrowÚrunningÚfieldsÚprojects   &&&&&&        r   r   r   &   s8  € çJÝ"Ü˜	Ó'€FØ
€CÜ	×	Ò	œY×	'Õ	'Ø�l‰l×&Ñ& vÓ.×4Ð4°"ˆ÷ 
(à×Ñ Ó$×4Ñ4¸Ñ>€GÙ Ø�sÂ] &×"6Ñ"6°yÔ"AÐX\Ø$)¢M�—’°tØ<AÒ<MŒw�uÐ4°aÔ8ÐSWØ×$8Ñ$8ô	:€Fð
 ×*Ñ*¨6¯:©:Ó6€GØ�9‰9Ø˜RðhÙ".¨v°|ÀVÓ"Lðhç-4ˆY�w˜v•Ð'Ð(Ñ
)¸"ðhñ 
�f˜g w°	¸?ÈHÐVeÓ	fðhó ið i÷ 
(×	'ús   ¾&D4Ä4E	c               ó   € V ^8„  d   QhRR/# r   r
   )r   s   "r   r   r   ;   s   € ÷ 'ñ '¸#ñ 'r   c           	     ó4  aa€ \        W4      p. p\        P                  ! \        4      ;_uu_ 4        V P                  P                  VRRR7      pRRR4       ^ RIHp V'       d   V! WpP                  4      M. p	. p
Ve¾   \        P                  ! \        4      ;_uu_ 4        ^ RI	H
pHpHp V P                  P                  VRR7      pV! WN4      pRpVP                  4       P                  4       R 9   d4   \        P                  ! \        4      ;_uu_ 4        V! V4      pRRR4       V! VVRR7      p
RRR4       V	'       d   R	\        V	4       R
2MR.p\!        R V	 4       4      oVP#                  RRP%                  V3R lR! 4       4      ,           4       Ve   \'        VRR4      MR;'       g    VP)                  V 4      ;p'       d   VP#                  RV 24       VP#                  R4       V
'       d   RP%                  . VORNV
O4      # Ve   \'        VRR4      MRoV3R lR" 4       w  ppV'       d6   V'       d.   VP#                  RVR RVR RVV,          ^d,          R R24       MV'       d   VP#                  RVR R24       \+        \'        SR^ 4      ;'       g    ^ 4      ;p'       d   VP#                  RVR 24       RP%                  V4      #   + '       g   i     EL–; i  + '       g   i     ELØ; i  + '       g   i     ELÙ; i)#z»Main's ``_format_live_context_output``: counts by role, model/provider, then the category
table off the live agent (``render_context_breakdown_lines(grid=False)``), else the stored usage.T)Úinclude_ancestorsÚinclude_row_idsN)Údisplay_projection)Úcompute_context_detailsÚ!compute_session_context_breakdownÚrender_context_breakdown_lines©rN   F)ÚdetailsÚgridzConversation: z	 messagesz(Conversation is empty (no messages yet).c              3  ój   "  € T F)  p\        VP                  R 4      ;'       g    R4      x € K+  	  R# 5i)ÚroleÚunknownN)r   Úget)Ú.0Úmsgs   & r   Ú	<genexpr>Ú_context.<locals>.<genexpr>Q   s(   é € ÐJÁ¸#”C˜Ÿ™ ›×4Ð4¨9×5Ð5Ãùs   ‚!3¤3z  z, c              3  óP   <"  € T F  q R SP                  V^ 4       2x € K  	  R# 5i)z: N)rZ   )r[   ÚrÚroless   & €r   r]   r^   R   s'   øé € Ð!mÑElÀ C r¨%¯)©)°A°q«/Ð):Õ";ÓElùs   ƒ#&r/   r5   zModel: zProvider: autor4   Úcontext_compressorc              3  ód   <"  € T F%  p\        \        SV^ 4      ;'       g    ^ 4      x € K'  	  R# 5i)r   N)Úintr@   )r[   r   Ú
compressors   & €r   r]   r^   [   s,   øé € ÐqÑHpÀ”Sœ ¨T°1Ó5×:Ð:¸×;Ð;ÓHpùs   ƒ0¡0zContext usage: Ú,z / z	 tokens (z.1fz%)z tokensÚcompression_countzCompressions: >   ÚallÚfullrU   )ÚuserÚ	assistantÚtoolÚsystem)Úlast_prompt_tokensÚcontext_length)r'   r    r!   r"   r$   Úget_messages_as_conversationÚgateway.session_controlsrP   rA   Úagent.context_breakdownrQ   rR   rS   ÚstripÚlowerÚlenr   ÚappendrD   r@   r?   rd   )r%   r&   rE   r   rF   r	   rG   ÚrowsrP   ÚmessagesÚ	breakdownrQ   rR   rS   ÚconversationÚpayloadrU   Úlinesr/   ÚusedÚmaximumÚcountre   ra   s   &&&&&&                @@r   r   r   ;   s¡  ù€ ô ˜	Ó'€FØ€DÜ	×	Ò	œY×	'Õ	'Ø�|‰|×8Ñ8¸ÐSWÐimÐ8Ónˆ÷ 
(å;ßAEÑ! $×(<Ñ(<Ô=È2€HØ€IØÒÜ× Ò ¤×+Õ+÷lñ là$Ÿ<™<×DÑDÀVÐ_cÐDÓdˆLÙ7¸ÓLˆGØˆGØ�y‰y‹{× Ñ Ó"Ð&@Ô@Ü×(Ò(¬×3Õ3Ù5°eÓ<�G÷ 4á6°wÈÐV[Ô\ˆI÷ ,÷ ;Cˆ~œc (›m˜_¨IÑ6ÐHrÐs€EÜÑJÁÓJÓJ€EØ	‡L�L�˜Ÿ	™	Ô!mÑElÓ!mÓmÕmÔnØ05Ò0A”˜ ¨Ô,Àr×mÐmÈf×NbÑNbÐclÓNmÐm€uÖmØ�‰�w˜u˜gÐ&Ô'ð 
‡L�LÐ!Ô"ßØ�y‰yÐ1˜5Ð1 "Ð1 yÐ1Ó2Ð2Ø?DÒ?P”˜Ð 4°dÔ;ÐVZ€JÜqÑHpÓq�M€Dˆ'ß—Ø�‰� t¨A h¨c°'¸!°¸IÀdÈWÅnÐWZÕFZÐ[^ÐE_Ð_aÐbÕcß	Ø�‰� t¨A h¨gÐ6Ô7Ü”G˜JÐ(;¸QÓ?×DÐDÀ1ÓEÐE€uÖEØ�‰�~ e¨A YÐ/Ô0Ø�9‰9�UÓÐ÷E 
(×	'Ð	'ú÷ 4×3Ð3ú÷ ,×+Ð+ús0   ²KÂ#A7LÄ	K2	Ä#LËK/	Ë2LË=	LÌL	c               ó   € V ^8„  d   QhRR/# ©r   r   Údictr
   )r   s   "r   r   r   e   s   € ÷ 	Fñ 	FÀTñ 	Fr   c           	   ƒ  óº   a aaaaaaaa	"  € ^ RI Ho	 ^ RIHo S P	                  S4      oVVVV VV	VVV3	R lpRRR\
        P                  ! V4      G Rj  x€L
 /#  L5i)zQRender off the owner loop, inside the owning profile and the session's workspace.©Úowner_scope©Ú_session_workspacec                 ó  <	€ S! S4      ;_uu_ 4        S ! SP                   SP                  4      ;_uu_ 4        S! SSSSSS4      uuR R R 4       uuR R R 4       #   + '       g   i     M; iR R R 4       R #   + '       g   i     R # ; i©N)Úrunnerr   )	r‡   rF   r	   r%   rE   r…   r   r&   Úrenders	   €€€€€€€€€r   ÚbuildÚrun_tui_read.<locals>.buildk   sZ   ø€ Ù˜×#Õ#Ñ%7¸	×8HÑ8HÈ$Ï+É+×%VÕ%VÙ˜) S¨$°¸¸sÓC÷ &WÑ%V×#Ò#×%V×%Vú×#×#×#Ò#ús"   ’&A7¸A	Á
A7ÁA*Á%A7Á7B	ÚtypeÚexecÚoutputN)Úgateway.session_authoritiesr…   Úgateway.session_commandsr‡   rF   ÚasyncioÚ	to_thread)
r%   r&   rE   r   r‹   r	   rŒ   r‡   rF   r…   s
   ffffff @@@r   Úrun_tui_readr•   e   sI   ÿøé € å7Ý;Ø�O‰O˜CÓ €E÷Dõ Dð �F˜H¬G×,=Ò,=¸eÓ,D×&DÐEÐEÑ&Dùs   ‹AAÁA
ÁAc               ó   € V ^8„  d   QhRR/# r�   r
   )r   s   "r   r   r   q   s   € ÷ -*ñ -*¸ñ -*r   c              ƒ  ó|  aa	a
aaa"  € ^ RI Hp ^ RIHp \	        V4      RR0,
          '       g3   \        VP                  \        4      '       d   VP                  '       g	   V! R4      hV! WVR4       V P                  o
S
P                  P                  VP                  4      oSf	   V! R4      hS
P                  V4      o	S	Ef1   ^ R	IHp V! WRVP                  /4      G Rj  x€L
 p\        VP                  R
4      \        4      '       d   VP                  R
4      MTpR. R\        VP                  R4      ;'       g    ^ 4      R\        VP                  R4      ;'       g    ^ 4      R\        VP                  R4      ;'       g    ^ 4      R^ R\!        VP                  RR4      4      R\        VP                  R4      ;'       g    R4      R\        VP                  R4      ;'       g    R4      /# ^ RIHo ^ RIHo \+        S
V4      oVV	V
VVV3R lp\,        P.                  ! V4      G Rj  x€L
 #  ELS L5i)aO  ``session.context_breakdown`` on the owner: the category estimate (``compute_session_context_
breakdown``) and context-file manifest of this session's resident agent over its stored
transcript, built in the session's workspace. Before the agent exists: empty categories plus the
session's stored usage (the contract's pre-build shape).)Ú	authorize)ÚRuntimeStoreErrorr   ÚprofileÚinvalid_paramszsession:readNÚ	not_found)ÚstatsÚusageÚ
categoriesÚcontext_maxÚcontext_percentÚcontext_usedÚestimated_totalÚcontext_estimatedFÚcontext_sourceÚprovider_usager/   r5   r„   r†   c                 óˆ  <€ ^ RI Hp  ^ RIHp S
! S4      ;_uu_ 4        S! SP                  S	P
                  4      ;_uu_ 4        \        S4      \        S4      SP                  P                  SRR7      3pS	P                  pVe5   V^ ,          V8X  d'   \        V^,          4      uuRRR4       uuRRR4       # SP                  P                  SRR7      pV ! SV4      pV! S4      VR&   W%3S	n
        \        V4      uuRRR4       uuRRR4       #   + '       g   i     M; iRRR4       R#   + '       g   i     R# ; i)r   )rR   )Úcontext_file_sources_for_agentTrT   NÚcontext_files)rr   rR   Úagent.context_file_sourcesr¨   rŠ   r   ÚidÚ_agent_context_marksr$   Úconversation_revisionÚcontext_breakdownr‚   rp   )rR   r¨   ÚkeyÚcachedrz   r{   r‡   rF   r%   rE   r…   rG   s         €€€€€€r   rŒ   Ú context_breakdown.<locals>.buildŽ   sý   ø€ ÝMÝMÙ˜×#Õ#Ñ%7¸	×8HÑ8HÈ$Ï+É+×%VÕ%Vô �e“9Ô2°5Ó9Ø—<‘<×5Ñ5°fÐPTÐ5ÓUðWˆCà×+Ñ+ˆFØÒ! f¨Q¥i°3Ô&6Ü˜F 1�I“÷ &WÑ%V×#Ò#ð %Ÿ<™<×DÑDÀVÐ_cÐDÓdˆLÙ7¸¸|ÓLˆGÙ'EÀeÓ'LˆG�OÑ$Ø&) ^ˆDÔ"Ü˜“=÷ &WÑ%V×#Ò#×%V×%Vú×#×#×#Ò#ús1   ž&D0ÁA"D	Â&
D0Â;AD	Ã>
D0ÄD#ÄD0Ä0E	)Úgateway.session_busy_controlsr˜   Úhermes_state_runtimer™   ÚsetÚ
isinstancer   r   r%   ÚsessionsrZ   rF   Úgateway.session_usager�   r‚   rd   Úboolr‘   r…   r’   r‡   r'   r“   r”   )Ú
connectionr&   Úparamsr˜   r™   r�   rž   rŒ   r‡   rF   r%   rE   r…   rG   s   &&&     @@@@@@r   r®   r®   q   sÔ  ýé € õ
 8Ý6Ü
ˆ6ƒ{�l IÐ.×.Ô.´jÀÇÁÔQT×6UÒ6UÐ]`×]k×]kÐ]kÙÐ 0Ó1Ð1Ùˆj˜v ~Ô6Ø×$Ñ$€IØ×Ñ×!Ñ! #§.¡.Ó1€DØ‚|Ù Ó,Ð,Ø�O‰O˜CÓ €EØƒ}Ý/Ù˜J¨l¸C¿N¹NÐ-KÓL×LˆÜ&0°·±¸7Ó1CÄT×&JÒ&J�—	‘	˜'Ô"ÐPUˆØ˜b -´°U·Y±Y¸}Ó5M×5RÐ5RÐQRÓ1SØ!¤3 u§y¡yÐ1BÓ'C×'HÐ'HÀqÓ#IØ¤ E§I¡I¨nÓ$=×$BÐ$BÀÓ CÐEVÐXYØ#¤T¨%¯)©)Ð4GÈÓ*OÓ%PØ ¤# e§i¡iÐ0@Ó&A×&UÐ&UÐEUÓ"VØœ˜UŸY™Y wÓ/×5Ð5°2Ó6ð8ð 	8õ 8Ý;Ü˜	 3Ó'€F÷!ò !ô  ×"Ò" 5Ó)×)Ð)ò9 Mñ8 *ùsL   ˆAH<Á!BH<Ã$H7Ã%AH<Å#H<Å%#H<Æ	A H<Ç
#H<Ç.AH<È2H:È3H<È:H<c               ó   € V ^8„  d   QhRR/# )r   r   Útupler
   )r   s   "r   r   r   ¡   s   € ÷ pñ p 5ñ pr   c           	     ó  a€ \        V RR4      o\        V RR4      \        V RR4      \        \        V RR4      ;'       g    R	4      .V3R lR
 4       O\        \        V RR4      4      N\        \        V RR4      4      N5# )z—What the breakdown reads off the agent besides the transcript: model, toolset size, window,
measured prompt tokens, compressions and the usage anchors.rb   Nr/   r0   Útoolsc              3  ó>   <"  € T F  p\        SVR 4      x € K  	  R # 5ir‰   )r@   )r[   r   Úcomps   & €r   r]   Ú'_agent_context_marks.<locals>.<genexpr>¦   s   øé € ÐrÑ4q¨DŒg�d˜D $×'Ð'Ó4qùs   ƒÚ_turn_base_usage_anchorÚ_usage_anchorr
   )ro   rn   rg   )r@   ru   Úrepr)rF   rÀ   s   &@r   r¬   r¬   ¡   s•   ø€ ô �5Ð.°Ó5€DÜ�E˜7 DÓ)¬7°5¸*ÀdÓ+KÌSÔQXÐY^Ð`gÐimÓQn×QtÐQtÐrtÓMuð pÜrÑ4qÓrðpä”˜Ð 9¸4Ó@ÓAðpäCGÌÐPUÐWfÐhlÓHmÓCnñpð pr   )Ú__doc__Ú
__future__r   r“   r    Úcollectionsr   Ú	frozensetr   r   r'   r   r   r•   r®   r¬   r
   r   r   Ú<module>rÉ      sN   ðñõ #ã Û Ý ñ ˜%˜Ó!€õõõiõ*'õT	Fõ-*÷`pr   