+
    lHàj‹  ã                   ó’   € R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHtHt ^ RI	H
t
 ]P                  ! ]4      tR R lt ! R R4      tR# )z’Shared per-tool debug session: records tool calls to a JSON log when a
tool-specific env var (e.g. WEB_TOOLS_DEBUG=true) is set; no-ops otherwise.N)ÚAnyÚDict)Úget_hermes_homec                ó$   € V ^8„  d   QhR\         /# ©é   Úreturn©Ústr)Úformats   "Ú8/home/ubuntu/.hermes/hermes-agent/tools/debug_helpers.pyÚ__annotate__r      s   € ÷ /ñ /Œcñ /ó    c                  óZ   € \         P                   P                  4       P                  4       # ©N)ÚdatetimeÚnowÚ	isoformat© r   r   Ú_nowr      s    € Ü×Ñ× Ñ Ó"×,Ñ,Ó.Ð.r   c                   óv   a € ] tR t^t o RtV 3R lR lt]V 3R lR l4       tV 3R lR ltV 3R lR	 lt	R
t
V tR# )ÚDebugSessionzBPer-tool debug session that records tool calls to a JSON log file.c                ó*   <€ V ^8„  d   QhRS[ RS[ RR/# )r   Ú	tool_nameÚenv_varr   Nr	   )r   Ú__classdict__s   "€r   r   ÚDebugSession.__annotate__   s'   ø€ ÷ 	_ñ 	_¡#ð 	_±3ð 	_¸4ñ 	_r   c               óü  € Wn         \        P                  ! VR 4      P                  4       R8H  V n        V P                  '       d   \        \        P                  ! 4       4      MRV n        \        4       R,          V n
        . V n        V P                  '       d   \        4       MRV n        V P                  '       d@   V P                  P                  RRR7       \        P!                  RWP                  4       R# R# )ÚfalseÚtrueÚ ÚlogsT)ÚparentsÚexist_okz&%s debug mode enabled - Session ID: %sN)r   ÚosÚgetenvÚlowerÚenabledr
   ÚuuidÚuuid4Ú
session_idr   Úlog_dirÚ_callsr   Ú_start_timeÚmkdirÚloggerÚdebug)Úselfr   r   s   &&$r   Ú__init__ÚDebugSession.__init__   s¥   € Ø"ŒÜ—y’y ¨'Ó2×8Ñ8Ó:¸fÑDˆŒØ/3¯|¯|¨|œ#œdŸjšj›lÔ+ÀˆŒÜ&Ó(¨6Õ1ˆŒØ,.ˆŒØ%)§\§\ \œ4œ6°rˆÔØ�<�<ˆ<Ø�L‰L×Ñ t°dÐÔ;Ü�L‰LÐAÀ9ÏoÉoÖ^ñ r   c                ó    <€ V ^8„  d   QhRS[ /# r   )Úbool)r   r   s   "€r   r   r   #   s   ø€ ÷ ñ ™ñ r   c                ó   € V P                   # r   )r'   )r1   s   &r   ÚactiveÚDebugSession.active"   s   € à�|‰|Ðr   c                ó@   <€ V ^8„  d   QhRS[ RS[S[ S[3,          RR/# )r   Ú	call_nameÚ	call_datar   N)r
   Údictr   )r   r   s   "€r   r   r   &   s/   ø€ ÷ [ñ [¡#ð [±$±s¹C°xµ.ð [ÀTñ [r   c                ó€   € V P                   '       d,   V P                  P                  R\        4       RV/VC4       R# R# )z.Append a tool-call entry to the in-memory log.Ú	timestampr   N)r'   r,   Úappendr   )r1   r:   r;   s   &&&r   Úlog_callÚDebugSession.log_call&   s2   € à�<�<ˆ<Ø�K‰K×Ñ ¬T«V°[À)ÐYÈyÐYÖZñ r   c                ó   <€ V ^8„  d   QhRR/# )r   r   Nr   )r   r   s   "€r   r   r   +   s   ø€ ÷ Mñ M�dñ Mr   c                ód  € V P                   '       g   R#  V P                  V P                   RV P                   R2,          pRV P                  RV P                  R\        4       RRR	\        V P                  4      R
V P                  /p\        VRRR7      ;_uu_ 4       p\        P                  ! W#^RR7       RRR4       \        P                  RV P                  V4       R#   + '       g   i     L3; i  \         d-   p\        P                  RT P                  T4        Rp?R# Rp?ii ; i)z=Flush the in-memory log to a JSON file in the logs directory.NÚ_debug_z.jsonr*   Ú
start_timeÚend_timeÚdebug_enabledTÚtotal_callsÚ
tool_callsÚwzutf-8)ÚencodingF)ÚindentÚensure_asciiz%s debug log saved: %szError saving %s debug log: %s)r'   r+   r   r*   r-   r   Úlenr,   ÚopenÚjsonÚdumpr/   r0   Ú	ExceptionÚerror)r1   ÚfilepathÚpayloadÚfÚes   &    r   ÚsaveÚDebugSession.save+   së   € à�|�|ˆ|Ùð		MØ—|‘|¨¯©Ð(8¸ÀÇÁÐ?PÐPUÐ&VÕVˆHà˜dŸo™o¨|¸T×=MÑ=MÈzÔ[_Ó[aØ  }´c¸$¿+¹+Ó6FÈÐVZ×VaÑVaðcˆGô �h ¨g×6Õ6¸!Ü—	’	˜'¨Q¸UÕC÷ 7ä�L‰LÐ1°4·>±>À8ÖL÷ 7×6ûô ô 	MÜ�L‰LÐ8¸$¿.¹.È!×LÒLûð	Mús0   –B
C8 Â C%Â:)C8 Ã%C5	Ã0C8 Ã8D/Ä!D*Ä*D/)r,   r-   r'   r+   r*   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r2   Úpropertyr7   r@   rX   Ú__static_attributes__Ú__classdictcell__)r   s   @r   r   r      s@   ø‡ € ÙL÷	_ð 	_ð ÷ó ð÷[ð [÷
Mö Mr   r   )r^   r   rP   Úloggingr$   r(   Útypingr   r   Úhermes_constantsr   Ú	getLoggerrZ   r/   r   r   r   r   r   Ú<module>rf      sC   ðñOó Û Û Û 	Û ß å ,à	×	Ò	˜8Ó	$€õ/÷$Mó $Mr   