+
    jHàjÊ  ã                  óÖ   € R t ^ RIHt ^ RIt^ RIHt ^ RIHt ^ RIH	t	 0 R"mt
RR0tRtR	 R
 ltRRRRRR/R R lltR R ltRRRRRRRRRRRRR^
RR/R R lltRRRRRR/R  R! lltR# )#zBShared session-listing helpers for CLI and gateway slash surfaces.)ÚannotationsN)ÚPath)ÚAny)Úis_truthy_valueÚsearchÚfindÚsubagentc               ó    € V ^8„  d   QhRRRR/# )é   Úhermes_homeú
str | PathÚreturnÚbool© )Úformats   "Ú?/home/ubuntu/.hermes/hermes-agent/hermes_cli/session_listing.pyÚ__annotate__r      s   € ÷ bñ b¨
ð b°tñ bó    c                óF  € ^ RI Hp ^ RIHpHp V! \        V 4      4      p V! 4       P                  R4      ;'       g    / p T! T4       \        T\        4      ;'       d    \        TP                  R4      4      #   \         d     T! T4       R# i ; i  T! T4       i ; i)zø``sessions.show_subagents`` from *hermes_home*'s own config.yaml. One ``serve`` lists many
profiles' stores, so the store's home decides, never the process ``HERMES_HOME``. False when
the config cannot be read (the listing keeps its default shape).)Úload_config_readonly)Úreset_hermes_home_overrideÚset_hermes_home_overrideÚsessionsFÚshow_subagents)Úhermes_cli.configr   Úhermes_constantsr   r   ÚstrÚgetÚ	ExceptionÚ
isinstanceÚdictr   )r   r   r   r   ÚtokenÚsessions_cfgs   &     r   Úshow_subagent_sessionsr#      s�   € õ 7ßUá$¤S¨Ó%5Ó6€Eð*Ù+Ó-×1Ñ1°*Ó=×CÐCÀ‰ñ 	# 5Ô)Ü�l¤DÓ)×aÐa¬o¸l×>NÑ>NÐO_Ó>`Ó.aÐaøô	 ô Øá" 5Ö)ðûñ 	# 5Õ)ús#   ¡ A< Á<BÂB ÂBÂB Â
B ÚsourceÚsourcesÚexclude_sourcesc          
     ó,   € V ^8„  d   QhRRRRRRRRRR	/# )
r
   r   r   r$   ú
str | Noner%   úlist[str] | Noner&   r   ztuple[bool, list[str] | None]r   )r   s   "r   r   r   !   s=   € ÷ Gñ GØðGØ(2ðGØDTðGà%ðGð #ñGr   c               ó  € \        T;'       g    . 4      pV'       g   V'       g   V'       d   \        V9  d   RV3# \        V 4      '       g   RV3# RV Uu. uF  qU\        8w  g   K  VNK  	  up;'       g    R3# u upi )aÀ  ``(include_subagents, exclude_sources)`` for one human-facing session list (#97202).

With ``sessions.show_subagents`` on, delegate runs join a list that is not scoped to named
sources and either has no exclusions or excludes the ``subagent`` source itself (the desktop
recents shape); that exclusion is dropped so the runs actually land. A slice that excludes
other sources without ``subagent`` (the per-platform messaging lists) keeps its shape.
FTN)ÚlistÚSUBAGENT_SOURCEr#   )r   r$   r%   r&   ÚexcludedÚss   &$$$  r   Úsubagent_listing_scoper/   !   sq   € ô �O×)Ð) rÓ*€Hß—ŸX¬/ÀÔ*IØ�oÐ%Ð%Ü! +×.Ò.Ø�oÐ%Ð%Ø™XÓ>™X˜¬oÑ)=—!�!™XÑ>×FÐFÀ$ÐFÐFùÒ>s   ÁA<Á(A<c               ó    € V ^8„  d   QhRRRR/# )r
   Úraw_argsr   r   z"tuple[bool, bool, str, str | None]r   )r   s   "r   r   r   4   s   € ÷ Mñ M¨ð MÐ1Sñ Mr   c           	     ó*  € \         P                  ! T ;'       g    R4      pRRRR/p. p\        V4       F¬  w  rEVP                  4       P	                  4       pV'       gq   V\
        9   d   K8  VR	9   d   RW&P                  R4      &   KT  V\        9   d=   VR,          VR,          RRP                  W^,           R 4      P                  4       3u # VP                  V4       K®  	  VR,          VR,          RP                  V4      P                  4       R3# )
aÃ  Parse `/sessions`-style args into ``(include_all_sources, include_unnamed, target, search_query)``.

``all`` widens source scope, ``full`` keeps unnamed sessions, ``search``/``find`` makes the rest
a query (``None`` = not requested, ``""`` = requested with no terms). Flags are honored only
before the first positional word so titles containing "all" aren't misparsed; anything else is
a target so `/sessions <id-or-title>` can delegate to `/resume`.
Ú ÚallFÚfullTÚ-Ú N>   r4   r5   ú--allú--full)
ÚshlexÚsplitÚ	enumerateÚstripÚlowerÚ_LIST_WORDSÚlstripÚ_SEARCH_WORDSÚjoinÚappend)r1   ÚpartsÚflagsÚtarget_partsÚiÚpartr>   s   &      r   Úparse_session_listing_argsrI   4   sí   € ô �KŠK˜Ÿ˜ BÓ'€EØ�E˜6 5Ð)€EØ €LÜ˜UÖ#‰ˆØ—
‘
“×"Ñ"Ó$ˆßØœÔ#ÙØÐ:Ô:Ø+/�—l‘l 3Ó'Ñ(ÙØœÔ%Ø˜U•| U¨6¥]°B¸¿¹ÀÈ1ÅuÀvÀÓ8O×8UÑ8UÓ8WÐWÒWØ×Ñ˜DÖ!ñ $ð ��<˜˜v�¨¯©°Ó(>×(DÑ(DÓ(FÈÐLÐLr   Úsession_keyÚcurrent_session_idÚinclude_current_sessionFÚinclude_all_sourcesÚinclude_unnamedÚsearch_queryÚlimitc               óD   € 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R/# )r
   Ú
session_dbr   r$   r(   rJ   rK   rL   r   rM   rN   rO   rP   Úintr&   r)   r   úlist[dict[str, Any]]r   )r   s   "r   r   r   M   sx   € ÷ (ñ (Øð(ð ð(ð ð	(ð
 #ð(ð "ð(ð ð(ð ð(ð ð(ð ð(ð &ð(ð ñ(r   c       	   
     ó  € T;'       g    RP                  4       p
T P                  V'       d   RMTTT	\        V^,          V4      T
;'       g    R\        V
4      R7      p. pV FŸ  p\        T;'       d    VP	                  R4      V8H  4      pV'       d	   V'       d0   V'       g*   VP	                  R4      '       g   V
'       g   V'       g   Kk  TP                  V'       d	   / VCRR/CMT4       \        V4      V8¼  g   Kž   V# 	  V# )aõ  Return session rows for interactive listing surfaces (shared CLI/gateway policy).

Source-scoped unless global is requested; unnamed hidden unless a full listing is asked for;
current session hidden unless requested (then marked ``is_current_session``); ``session_key``
restricts gateway callers to one lane before the DB limit applies. With ``search_query`` rows
are filtered by title/id in SQL, ordered by recent activity, and unnamed sessions stay visible
since an id match may be the only handle.
r3   N)r$   rJ   r&   rP   rO   Úorder_by_last_activeÚidÚtitleÚis_current_sessionT)r=   Úlist_sessions_richÚmaxr   r   rC   Úlen)rR   r$   rJ   rK   rL   rM   rN   rO   rP   r&   r   ÚrowsÚresultÚrowÚ
is_currents   &$$$$$$$$$     r   Úquery_session_listingra   M   sä   € ð* × Ð ˜b×'Ñ'Ó)€FØ×(Ñ(ß*‰t°ØØ'Ü�%˜!•)˜UÓ#Ø—^�^˜tÜ! &›\ð )ó €Dð $&€FÛˆÜÐ,×TÐT°·±¸³ÐBTÑ1TÓUˆ
ß×6ß¨¯©°×(8Ò(8Ç×PZáØ�‰¿ZÐ9˜Ð9Ð2°DÒ9ÈSÔQÜˆv‹;˜%ÖØØ€Mñ ð €Mr   Úinclude_sourcerX   ÚSessionsÚnoticec          
     ó,   € V ^8„  d   QhRRRRRRRRR	R/# )
r
   r]   rT   rb   r   rX   r   rd   r(   r   r   )r   s   "r   r   r   x   s<   € ÷ "ñ "Ø
ð"ð ð"ð ð	"ð
 ð"ð 	ñ"r   c               ó¬  € V '       g%   RP                  R.V'       d	   V.O4      # . O4      # RV R2R.p\        V ^R7       Fê  w  rVVP                  R4      '       d   RMRp\        VP                  R	4      ;'       g    R4      R
,          p\        VP                  R4      ;'       g    R4      p	V'       d   V	'       d   RV	 R2MRp
V'       d   RV R2MRpTP	                  T RVP                  R4      ;'       g    R RT T
 RVP                  R4      ;'       g    R RV 2
4       Kì  	  RP                  . VORNV'       d   V.M. ORNRN4      # )uö   Render a compact Markdown-ish session list for gateway messengers.

``notice`` adds an explanatory line above the footer â€” e.g. when a requested scope widening
(``all``) was declined, so the caller isn't left guessing why sessions are missing.
Ú
znNo sessions found.
Use `/title My Session` to name this chat, or `/sessions full` to include unnamed sessions.u   ðŸ“‹ **z**r3   )ÚstartrY   z
 (current)Úpreview:Né(   Nr$   z `Ú`u    â€” _Ú_z. **rX   u   â€”u    â€” `rW   zDResume: `/resume <session id>` or `/resume <number>` from `/resume`.zDMore: `/sessions all`, `/sessions full`, `/sessions search <query>`.)rB   r<   r   r   rC   )r]   rb   rX   rd   ÚlinesÚidxr_   Úcurrent_partri   r$   Úsource_partÚpreview_parts   &$$$        r   Úformat_gateway_session_listingrr   x   s�  € ÷ Ø�y‰yð+ð
÷ !ˆvˆhð	
ó ð 	ð ')ð	
ó ð 	ð �u�g˜RÐ  "Ð%€EÜ˜d¨!×,‰ˆØ'*§w¡wÐ/C×'DÒ'D‘|È"ˆÜ�c—g‘g˜iÓ(×.Ð.¨BÓ/°Õ4ˆÜ�S—W‘W˜XÓ&×,Ð,¨"Ó-ˆß(6¿6˜˜6˜( !‘nÀrˆß.5˜ ˜y¨Ñ*¸2ˆØ�‰Øˆe�4˜Ÿ™ Ó(×1Ð1¨EÐ2°"°\°NÀ;À-Ø�S—W‘W˜T“]×(Ð( bÐ)¨¨<¨.ð:ö	
ñ -ð �9‰9ð Ø	ðØðß"(�v‘h¨bðàNðð 	Oðó ð r   >   Úlsr+   Úbrowse)Ú__doc__Ú
__future__r   r:   Úpathlibr   Útypingr   Úutilsr   r?   rA   r,   r#   r/   rI   ra   rr   r   r   r   Ú<module>rz      sÖ   ðÙ Hå "ã Ý Ý å !â&€Ø˜6Ð"€Ø€õbð"GØ59ðGØW[ðGà(,÷Gõ&Mð2(ð #ð	(ð
 &*ð(ð %*ð(ð !&ð(ð "ð(ð  $ð(ð ð(ð )-÷(ðV"ð !ð"ð ð	"ð
 ÷"ñ "r   