+
    iHàjt  ã                  ó<  € R t ^ RIHt ^ RIt^ RIt^ RIHt ^ RIHt ^ RI	H
t
HtHt ^ RIHt ^xtRt ! R R	]]4      t]! ]P(                  ]P*                  ]P,                  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RRRR/R R llt ! R R4      tR# )a1  Shared session activity observation contract: timestamp + bounded description/provenance, observation
only (notification, timeout, kill and retry policy live elsewhere). Provenance is a small closed enum of
*noun* sources; the default agent clock stamps ``unknown`` unless a writer passes ``provenance=``.)ÚannotationsN)Úsuppress)ÚEnum)ÚAnyÚMappingÚOptional)Útg      N@c                  ó.   € ] tR t^tRtRtRtRtRtRt	Rt
R# )	ÚActivityProvenancez3Where a durable/in-memory activity stamp came from.Úunknownzagent.compressionzagent.compression_timeoutzagent.compression_cooldownzagent.compression_turnhold© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚUNKNOWNÚAGENT_COMPRESSIONÚAGENT_COMPRESSION_TIMEOUTÚAGENT_COMPRESSION_COOLDOWNÚAGENT_COMPRESSION_TURNHOLDÚ__static_attributes__r   ó    Ú;/home/ubuntu/.hermes/hermes-agent/agent/session_activity.pyr
   r
      s$   † Ù=à€Gð ,ÐØ ;ÐØ!=ÐØ!=Ôr   r
   c               ó    € V ^8„  d   QhRRRR/# )é   Ú
provenanceú"Optional[ActivityProvenance | str]ÚreturnÚboolr   )Úformats   "r   Ú__annotate__r!   7   s    € ÷ Yñ YÐ3Uð YÐZ^ñ Yr   c                ó&   € \        V 4      \        9   # )zUTrue when this stamp ends a compression phase and must bypass the persist rate limit.)Únormalize_activity_provenanceÚ TERMINAL_COMPRESSION_PROVENANCES©r   s   &r   Ú"is_terminal_compression_provenancer&   7   s   € ä(¨Ó4Ô8XÑXÐXr   c               ó    € V ^8„  d   QhRRRR/# )r   ÚdescriptionúOptional[str]r   Ústrr   )r    s   "r   r!   r!   <   s   € ÷ kñ k¨Mð k¸cñ kr   c                ó�   € T ;'       g    RP                  4       p\        V4      \        8:  d   V# VR\        ^,
           R,           # )z?Clamp free-form activity text to the shared description budget.Ú Nu   â€¦)ÚstripÚlenÚACTIVITY_DESCRIPTION_MAX)r(   Útexts   & r   Úbound_activity_descriptionr1   <   sD   € à×Ð˜2×$Ñ$Ó&€DÜ�t“9Ô 8Ô8ˆ4Ðj¸dÐCaÔE]Ð`aÕEaÐ>bÐejÕ>jÐjr   c               ó    € V ^8„  d   QhRRRR/# )r   r   r   r   r
   r   )r    s   "r   r!   r!   B   s   € ÷ *ñ *Ð.Pð *ÐUgñ *r   c                ó¼   € \        V \        4      '       d   V #  \        T ;'       g    RP                  4       4      #   \         d    \        P                  u # i ; i)zBReturn a known provenance, or ``UNKNOWN`` when unset/unrecognized.r,   )Ú
isinstancer
   r-   Ú
ValueErrorr   r%   s   &r   r#   r#   B   sR   € ä�*Ô0×1Ò1ØÐð*Ü! :×#3Ð#3°×":Ñ":Ó"<Ó=Ð=øÜô *Ü!×)Ñ)Ò)ð*ús   š= ¨= ½AÁAc               ó$   € V ^8„  d   QhRRRRRR/# )r   Úapi_call_countr   Úmax_iterationsr   r*   r   )r    s   "r   r!   r!   L   s&   € ÷ Nñ N¨cð NÀ3ð NÈ3ñ Nr   c                óÆ   €  \        V4      pV\        P                  8¼  d   \        RV R7      # \        RWR7      #   \        \        3 d    \        P                  p LRi ; i)a'  ``iteration N/M`` for user-facing status lines, or ``iteration N`` when the cap is unbounded.

``AIAgent.max_iterations`` defaults to ``sys.maxsize`` (unlimited), so printing the pair verbatim
shows ``iteration 3/9223372036854775807`` in busy acks, heartbeats and timeout diagnostics (#102806).
z$display.iteration_progress.unbounded)Únz"display.iteration_progress.bounded)r:   Úmax)ÚintÚ	TypeErrorr5   ÚsysÚmaxsizer   )r7   r8   Úcaps   && r   Úformat_iteration_progressrA   L   sZ   € ðÜ�.Ó!ˆð Œc�k‰kÔÜÐ7¸>ÔJÐJÜÐ1°^ÔMÐMøô	 ”zÐ"ô Ü�k‰kŠðús   ‚< ¼!A ÁA c               ó    € V ^8„  d   QhRRRR/# )r   Úagentr   r   ÚNoner   )r    s   "r   r!   r!   [   s   € ÷ 8ñ 8°ð 8¸ñ 8r   c                ó|   € \        \        4      ;_uu_ 4        RV n        RRR4       R#   + '       g   i     R# ; i)z€Clear the persist rate-limit so the next stamp writes through (terminal compression labels must not stick on mid-compress text).ç        N)r   Ú	ExceptionÚ#_session_activity_last_persist_mono)rC   s   &r   Ú%reset_session_activity_persist_windowrI   [   s$   € ä	”)×	Õ	Ø47ˆÔ1÷ 
×	×	Ò	ús   ˜*ª;	Úlast_activity_provenanceÚnowÚextrac               ó0   € V ^8„  d   QhRRRRRRRRRR	R
R/# )r   Úlast_activity_atzOptional[float]Úlast_activity_descriptionr)   rJ   r   rK   rL   zOptional[Mapping[str, Any]]r   zdict[str, Any]r   )r    s   "r   r!   r!   a   sG   € ÷ ñ à%ðð  -ðð Að	ð
 
ðð 'ðð ñr   c                ó  € V e   \        V 4      MRp\        Ve   TM\        P                  ! 4       4      p\        V4      p\        V4      P                  pRTRTRTRVe   \        We,
          ^4      MRRVRVRVR	V/T;'       g    / C# )
zABuild the shared activity snapshot (plus optional caller extras).NrN   rO   rJ   Úseconds_since_activityÚlast_activity_tsÚlast_activity_descr(   r   )ÚfloatÚtimer1   r#   ÚvalueÚround)	rN   rO   rJ   rK   rL   ÚwhenÚclockÚdescÚprovs	   $$$$$    r   Úbuild_activity_snapshotr\   a   s›   € ð '7Ò&BŒ5Ð!Ô"È€DÜ˜š‘#¬d¯iªi«kÓ:€EÜ%Ð&?Ó@€DÜ(Ð)AÓB×HÑH€Dà˜DØ# TØ" DØ ¸DÒ<L¤%¨­°aÔ"8ÐRVà˜DÐ"6¸¸mÈTÐS_Ðaeðð �;ˆ;�Bðð r   c                  ó2   € ] tR t^ytRtR R ltR R ltRtR# )ÚAwakeIdleMetera  Removes host sleep from a polling watchdog's idle readings.

Idle time is measured on the wall clock, which keeps running while the host sleeps, so a laptop
that sleeps 15 minutes mid-turn wakes up "idle" for 15 minutes and the first poll after resume
kills a turn that never had a chance to run. ``time.monotonic()`` pauses during sleep on macOS
(``mach_absolute_time``) and Linux (``CLOCK_MONOTONIC``), so the two clocks drift apart by the
time spent asleep. Call :meth:`measure` once per poll with the wall-clock idle seconds.
c               ó   € V ^8„  d   QhRR/# )r   r   rD   r   )r    s   "r   r!   ÚAwakeIdleMeter.__annotate__ƒ   s   € ÷ ñ ˜$ñ r   c                	ó~   € \         P                   ! 4       \         P                  ! 4       uV n        V n        R V n        R# )rF   N)rU   Ú	monotonicÚ_wallÚ_monoÚ	_asleep_s)Úselfs   &r   Ú__init__ÚAwakeIdleMeter.__init__ƒ   s&   € Ü!%§¢£¬d¯nªnÓ.>ÐˆŒ
�D”JØˆŽr   c               ó    € V ^8„  d   QhRRRR/# )r   Úidle_srT   r   r   )r    s   "r   r!   r`   ‡   s   € ÷ 1ñ 1˜eð 1¨ñ 1r   c                óÒ  € \         P                   ! 4       \         P                  ! 4       r2\        RW P                  ,
          W0P                  ,
          ,
          4      pWV P                  ,
          8  d   RV n        V ;P
                  V,          un        W#uV n        V n        \        R\        V P
                  W,           4      4      V n        \        RWP
                  ,
          4      # )zIReturn *idle_s* minus the sleep observed since the agent's last activity.rF   )rU   rb   r;   rc   rd   re   Úmin)rf   rj   ÚwallÚmonoÚslept_ss   &&   r   ÚmeasureÚAwakeIdleMeter.measure‡   s›   € ä—Y’Y“[¤$§.¢.Ó"2ˆdÜ�c˜D§:¡:Õ-°$¿¹Õ2CÕDÓEˆð ˜4Ÿ:™:Õ%Ô%Ø ˆDŒNØ�Š˜'Õ!�Ø!%ÐˆŒ
�D”Jô ˜S¤# d§n¡n°fÕ6FÓ"GÓHˆŒÜ�3˜§¡Õ/Ó0Ð0r   )re   rd   rc   N)r   r   r   r   r   rg   rp   r   r   r   r   r^   r^   y   s   † ñõ÷1ñ 1r   r^   )r   Ú
__future__r   r>   rU   Ú
contextlibr   Úenumr   Útypingr   r   r   Ú
agent.i18nr   r/   Ú/SESSION_ACTIVITY_HEARTBEAT_MIN_INTERVAL_SECONDSr*   r
   Ú	frozensetr   r   r   r$   r&   r1   r#   rA   rI   r\   r^   r   r   r   Ú<module>ry      s¹   ðñfõ #ã 
Û Ý Ý ß )Ñ )å àÐ ð 37Ð /ô	>˜˜dô 	>ñ, $-à×4Ñ4Ø×5Ñ5Ø×5Ñ5ðó$Ð  õYõ
kõ*õNõ8ðð DHð	ð
  ðð *.÷÷01ó 1r   