+
    iHàj
  ã                   óš   € R t ^ RIt^ RIt^ RIt^ RIHt ^ RIHtHtHt ]P                  ! ]
4      tR R ltR R ltR R	 ltRR
 R lltR# )u€   Trajectory saving + scratchpad helpers (``_convert_to_trajectory_format`` stays an AIAgent method â€” batch_runner.py calls it).N)Údatetime)ÚAnyÚDictÚListc                ó0   € V ^8„  d   QhR\         R\         /# ©é   ÚcontentÚreturn)Ústr)Úformats   "Ú5/home/ubuntu/.hermes/hermes-agent/agent/trajectory.pyÚ__annotate__r      s   € ÷ oñ o¬ð o´ñ oó    c                óh   € V '       d   RV 9  d   V # V P                  RR4      P                  RR4      # )z4Convert <REASONING_SCRATCHPAD> tags to <think> tags.ú<REASONING_SCRATCHPAD>z<think>ú</REASONING_SCRATCHPAD>z</think>)Úreplace©r	   s   &r   Úconvert_scratchpad_to_thinkr      s3   € çÐ.°gÔ=ØˆØ�?‰?Ð3°YÓ?×GÑGÐHaÐcmÓnÐnr   c                ó0   € V ^8„  d   QhR\         R\        /# r   )r   Úbool)r   s   "r   r   r      s   € ÷ nñ n¤sð n¬tñ nr   c                óL   € \        V 4      ;'       d    RV 9   ;'       d    RV 9  # )zLWhether content has an opening <REASONING_SCRATCHPAD> without a closing tag.r   r   ©r   r   s   &r   Úhas_incomplete_scratchpadr      s)   € ä�‹=×mÐmÐ5¸Ñ@×mÐmÐE^ÐfmÑEmÐmr   c                ó(   € V ^8„  d   QhR\         RR/# )r   Úacquirer
   Nr   )r   s   "r   r   r      s   € ÷ 
Mñ 
M¤Dð 
M¨Tñ 
Mr   c                ó   € \         P                  R8X  dw   ^ RIpV P                  ^ 4       TP	                  V P                  4       V'       d   VP                  MVP                  ^4       V P                  ^ \         P                  4       R# ^ RI	pTP                  V P                  4       V'       d   VP                  MVP                  4       R# )z¤Exclusive whole-file lock on an append handle: ``flock`` on POSIX, a 1-byte
``msvcrt.locking`` range at offset 0 on Windows (append position is restored by the OS).ÚntN)ÚosÚnameÚmsvcrtÚseekÚlockingÚfilenoÚLK_LOCKÚLK_UNLCKÚSEEK_ENDÚfcntlÚflockÚLOCK_EXÚLOCK_UN)Úfr   r!   r(   s   &&  r   Ú_lock_append_handler-      su   € ô 
‡w�w�$„ÛØ	�‰ˆqŒ	Ø�‰�q—x‘x“z·W 6§>¢>À&Ç/Á/ÐSTÔUØ	�‰ˆq”"—+‘+ÖãØ�‰�A—H‘H“J· §¢¸e¿m¹mÖLr   c          	      óŽ   € V ^8„  d   QhR\         \        \        \        3,          ,          R\        R\        R\        R,          /# )r   Ú
trajectoryÚmodelÚ	completedÚfilenameN)ÚlistÚdictr   r   r   )r   s   "r   r   r   %   s<   € ÷ ;ñ ;¤¤T¬#¬s¨(¥^Õ 4ð ;¼Sð ;ÌTð ;Ô]`ÐcgÕ]gñ ;r   c                óB  € Vf   V'       d   RMRpRV R\         P                  ! 4       P                  4       RVRV/p \        P                  ! VRR	7      R
,           p\        VRRR7      ;_uu_ 4       p\        VR4        VP                  V4       VP                  4        \        VR4        RRR4       \        P                  RV4       R#   \        TR4       i ; i  + '       g   i     L9; i  \         d"   p\        P                  RT4        Rp?R# Rp?ii ; i)zAppend a ShareGPT-format entry to a JSONL file (default trajectory_samples.jsonl / failed_trajectories.jsonl by ``completed``).Nztrajectory_samples.jsonlzfailed_trajectories.jsonlÚconversationsÚ	timestampr0   r1   F)Úensure_asciiÚ
Úazutf-8)ÚencodingTzTrajectory saved to %szFailed to save trajectory: %s)r   ÚnowÚ	isoformatÚjsonÚdumpsÚopenr-   ÚwriteÚflushÚloggerÚinfoÚ	ExceptionÚwarning)r/   r0   r1   r2   ÚentryÚliner,   Úes   &&&&    r   Úsave_trajectoryrJ   %   sæ   € àÒß1:Ñ-Ð@[ˆØ˜j¨+´x·|²|³~×7OÑ7OÓ7QÐSZÐ\aÐcnÐpyÐz€Eð;Ü�zŠz˜%¨eÔ4°tÕ;ˆÜ�(˜C¨'×2Õ2°aô    4Ô(ð.Ø—‘˜”Ø—‘”	ä# A uÕ-÷ 3ô 	�‰Ð,¨hÖ7øô $ A uÕ-ú÷ 3×2ûô ô ;Ü�‰Ð6¸×:Ò:ûð;úsG   ½5C2 Á2CÂ !CÂ!CÂ.C2 ÃCÃCÃC/	Ã*C2 Ã2DÃ=DÄD)N)Ú__doc__r>   Úloggingr   r   Útypingr   r   r   Ú	getLoggerÚ__name__rC   r   r   r-   rJ   © r   r   Ú<module>rQ      sI   ðñ Gã Û Û 	Ý ß "Ñ "à	×	Ò	˜8Ó	$€õoõnõ

M÷;ñ ;r   