+
    „WÝjF  ã                  ó  € R t ^ RIHt ^ RIt^ RIHtHtHtHtH	t	H
t
Ht ^ RIHtHtHtHtHt ^ RIHt ^ RIH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 R ltR R ltR R ltR R lt R R lt!R# )a*  Durable message-identity columns for SessionDB (schema v31): the codec between the live identity keys
(``agent.message_metadata``) and the ``message_uid`` / ``absorbed_message_uids`` / ``tool_call_uids`` /
``tool_call_uid`` columns, shared by the transcript writers, restore, and transcript repair.)ÚannotationsN)ÚAnyÚDictÚListÚMappingÚMutableMappingÚOptionalÚTuple)ÚABSORBED_MESSAGE_UIDSÚMESSAGE_UIDÚTOOL_CALL_UIDÚTOOL_CALL_UIDSÚuid_list©Úcoalesce_tool_call_id)Ú_json_orc               ó(   € V ^8„  d   QhRRRRRRRR/# )é   ÚmsgúMapping[str, Any]Úlive_keyÚstrÚcolumnÚreturnr   © )Úformats   "ÚIC:\Users\johnn\AppData\Local\hermes\hermes-agent\hermes_state_identity.pyÚ__annotate__r      s/   € ÷ Eñ EÐ*ð E°cð EÀ3ð EÈ3ñ Eó    c                óR   € W9   d   V P                  V4      # V P                  V4      # )zWFlushed dicts and batch rows carry the live key; import payloads carry the column name.)Úget)r   r   r   s   &&&r   Ú_live_or_columnr!      s"   € à (¤ˆ3�7‰7�8ÓÐD°S·W±W¸V³_ÐDr   c               ó    € V ^8„  d   QhRRRR/# )r   Úvaluer   r   z	list[str]r   )r   s   "r   r   r      s   € ÷ ñ �Sð ˜Yñ r   c                ó^   € \        V \        4      '       d   \        V . R4      p \        V 4      # )zŒNormalize a uid list (a live list, or the JSON text an export/import carries) to unique non-empty
strings in order; anything else is ``[]``.z<Failed to deserialize a message uid list, falling back to [])Ú
isinstancer   r   r   )r#   s   &r   Ú	_uid_listr&      s*   € ô �%œ×ÒÜ˜ Ð$bÓcˆÜ�E‹?Ðr   c               ó    € V ^8„  d   QhRRRR/# )r   r#   r   r   údict[str, Any]r   )r   s   "r   r   r      s   € ÷ 	qñ 	q�Cð 	q˜Nñ 	qr   c                ó  € \        V \        4      '       d   \        V / R4      p \        V \        4      '       g   / # V P	                  4        UUu/ uF¥  w  r\        V\        4      '       g   K  V'       g   K'  \        V\        4      '       d	   V'       g_   \        V\
        4      '       g   K]  V'       g   Kg  \        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       g   K£  WbK§  	  upp# u uppi )a  Normalize a ``{tool call id: uid}`` map (a live dict, or the JSON text an export/import carries): a
non-empty string uid, or a list of them for a provider id repeated inside one row (one per occurrence,
see ``merge_tool_call_uids``); anything else is dropped, and a non-map is ``{}``.z=Failed to deserialize a tool-call uid map, falling back to {}c              3  óV   "  € T F  p\        V\        4      ;'       d    Tx € K!  	  R # 5i©N)r%   r   )Ú.0Úus   & r   Ú	<genexpr>Ú_uid_map.<locals>.<genexpr>%   s(   é € ÐHmÑklÐfgÌÐTUÔWZÓI[×IaÐIaÐ`aÔIaÓklùs   ‚)ž)FT)r%   r   r   ÚdictÚitemsÚlistÚall)r#   ÚkÚvs   &  r   Ú_uid_mapr6      s¹   € ô �%œ×ÒÜ˜ Ð$cÓdˆÜ�eœT×"Ò"Øˆ	Ø"Ÿ[™[œ]ô q™]‘T�Q¬j¸¼C×.@ŒDÄQŒDÜ	�A”s×	Ò	§¤z°!´T×':ô Ü?@ô ßEHÃSÑHmÑklÓHmÇSÇSÂSÑHmÑklÓHm×Emô ˆAŠD™]ò qð qùó qs6   ÁC>Á.C>Á8C>ÂC>Â.C>Â8
C>ÃC>ÃC>Ã4C>c               ó    € V ^8„  d   QhRRRR/# )r   r   r   r   r(   r   )r   s   "r   r   r   (   s   € ÷ Lñ LÐ-ð L°.ñ Lr   c                ó6   € \        \        V \        R 4      4      # )Útool_call_uids)r6   r!   r   )r   s   &r   Ú_tool_call_uid_mapr:   (   s   € Ü”O C¬Ð9IÓJÓKÐKr   c               ó    € V ^8„  d   QhRRRR/# ©r   r   r   r   zOptional[str]r   )r   s   "r   r   r   ,   s   € ÷ .ñ .Ð.ð .°=ñ .r   c                óv   € \        \        V \        R 4      4      pV'       d   \        P                  ! V4      # R# )Úabsorbed_message_uidsN)r&   r!   r
   ÚjsonÚdumps©r   Úuidss   & r   Ú_absorbed_uids_jsonrC   ,   s-   € Ü”_ SÔ*?ÐAXÓYÓZ€Dß#Œ4�:Š:�dÓÐ-¨Ð-r   c               ó    € V ^8„  d   QhRRRR/# r<   r   )r   s   "r   r   r   1   s   € ÷ >ñ >Ð/ð >°Mñ >r   c                ó\   € \        V 4      pV'       d   \        P                  ! VR R7      # R# )T)Ú	sort_keysN)r:   r?   r@   rA   s   & r   Ú_tool_call_uids_jsonrG   1   s$   € Ü˜cÓ"€Dß/3Œ4�:Š:�d dÔ+Ð=¸Ð=r   c               ó    € V ^8„  d   QhRRRR/# r<   r   )r   s   "r   r   r   6   s   € ÷ 9ñ 9Ð 1ð 9°mñ 9r   c                óh   € \        V \        R 4      p\        V\        4      '       d   V'       d   V# R# )Útool_call_uidN)r!   r   r%   r   )r   Úuids   & r   Ú_tool_call_uid_or_nonerL   6   s)   € Ü
˜#œ}¨oÓ
>€CÜ˜S¤#×&Ò&¯3ˆ3Ð8°DÐ8r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úlive_uidr   Ú
stored_uidr   Úboolr   )r   s   "r   r   r   ;   s&   € ÷ Kñ K˜Cð K¨Sð K°Tñ Kr   c                óŠ   € \        V\        4      '       d   TMV.p\        V \        4      ;'       d    V R\        V4       V8H  # )zdA live per-occurrence list that starts with every stored occurrence: a fold's union not yet written.N)r%   r2   Úlen)rN   rO   Ústoreds   && r   Ú_live_extendsrT   ;   s<   € ä% j´$×7Ò7‰Z¸j¸\€FÜ�h¤Ó%×JÐJ¨(°<´C¸³KÐ*@ÀFÑ*JÐJr   c               ó$   € V ^8„  d   QhRRRRRR/# ©r   Úrowr   r   zMutableMapping[str, Any]r   ÚNoner   )r   s   "r   r   r   A   s"   € ÷ 	2ñ 	2 cð 	2Ð0Hð 	2ÈTñ 	2r   c                óÔ  € V R,          '       d(   \        VP                  R4      ;p\        4      '       g   R# VP                  \        4      p\        V\        4      '       d   TM/ pV Uu0 uF  p\        V4      kK  	  pp\        V R,          4      P                  4        UUu/ uF  w  rgWe9   g   K  Wc9  g   K  WgbK  	  upp;p'       d   / VCVCV\        &   R# R# u upi u uppi )zÄBefore a row-addressed rewrite serializes *msg*: stored uids for calls it still names but whose uid it
lost (a clone), so the rewrite does not null them. A call the live dict dropped keeps no uid.r9   Ú
tool_callsN)r%   r    r2   r   r0   r   r6   r1   )	rW   r   ÚcallsÚliveÚtcÚnamedr4   r5   Úmissings	   &&       r   Ú_fill_missing_tool_call_uidsr`   A   sÍ   € ð Ð× Ô ¬
¸C¿G¹GÀLÓ<QÐ3Q°5ÔSW×(XÒ(XÙØ�7‰7”>Ó"€DÜ˜d¤D×)Ò)‰4¨r€DÙ16Ó7±¨2Ô" 2Ö&±€EÐ7Ü$,¨SÐ1AÕ-BÓ$C×$IÑ$IÔ$KÔlÑ$K™D˜AÈqÉz”4Ð^_Ñ^k”4�1’4Ñ$KÒlÐl€wÖlØ1 Ð1¨Ð1ˆŒNÓñ mùò 8ùÛls   Á,CÂ%
C$Â4C$Â<C$c               ó$   € V ^8„  d   QhRRRRRR/# rV   r   )r   s   "r   r   r   M   s"   € ÷ 2ñ 2˜sð 2Ð)Að 2Àdñ 2r   c           
     óö  € V \         ,          '       d   V \         ,          V\         &   V R,          '       dœ   \        V R,          4      ;p'       d‚   VP                  \        4      p\	        V\
        4      '       d   TM/ p/ VCVP                  4        UUu/ uF*  w  rE\        VP                  V4      V4      '       d   K(  WEbK,  	  uppCV\        &   V R,          '       d   V R,          V\        &   R# R# u uppi )a#  A stored row's uid and tool-call uids onto its live dict (the stored value wins). A live per-occurrence
list that already holds the stored uid is kept: it is a fold's union the row has not been rewritten
with yet, and replacing it with the stored single uid would strip the later occurrence.r9   rJ   N)	r   r6   r    r   r%   r0   r1   rT   r   )rW   r   rS   r\   Úcall_idrK   s   &&    r   Ú_restore_row_identityrd   M   sÚ   € ð Œ;×ÔØœ{Õ+ˆŒKÑØ
Ð×Ô¬H°SÐ9IÕ5JÓ,KÐ"K &Ö"KØ�w‰w”~Ó&ˆÜ! $¬×-Ò-‰t°2ˆðY ð YÈ6Ï<É<Ì>ô *XÉ>¹<¸7Ü1>¸t¿x¹xÈÓ?PÐRU×1Vô +7¨'ª,É>ò *Xð YˆŒNÑà
ˆ?×ÔØ  Õ1ˆŒMÓñ ùó*Xs   Â%C5Ã C5c               ó$   € V ^8„  d   QhRRRRRR/# rV   r   )r   s   "r   r   r   \   s"   € ÷ .ñ . 3ð .Ð-Eð .È$ñ .r   c                ó†   € \        W4       V R,          '       d'   \        V R,          4      ;p'       d   W!\        &   R# R# R# )z`The stored identity columns onto a restored dict under their live keys (NULL/empty add nothing).r>   N)rd   r&   r
   )rW   r   Úabsorbeds   && r   Ú_restore_identity_columnsrh   \   s=   € ä˜#Ô#Ø
Ð"×#Ô#´Y¸sÐCZÕ?[Ó5\Ð)\¨Ö)\Ø%-Ô!Ó"ñ *]Ñ#r   c               ó    € V ^8„  d   QhRRRR/# )r   rW   r   r   zOptional[tuple[Any, ...]]r   )r   s   "r   r   r   c   s   € ÷ ñ ˜#ð Ð";ñ r   c                óL  € V R,          R8w  d   R# \        V R,          ;'       g    R. R4      p\        ;QJ d    . R T;'       g    R 4       F  NK  	  5M! R T;'       g    R 4       4      pV'       d.   \        V4      '       d   RRV R,          V R	,          W R
,          3# R# )a  Display-dedupe key of a tool-calling assistant row built from its stable call ids instead of the arguments a
prune rewrites (#117750: a pruned carried-forward copy must collapse with its durable original). ``None`` for
every other row and for an incomplete id set, so the caller keeps the full content key: a tool RESULT row keeps
its payload in the key, because folding the archived full output into its pruned stub would drop the original
from compacted history and transcript exports, and distinct id-less calls never merge.ÚroleÚ	assistantNrZ   z[]z4Failed to deserialize tool_calls, falling back to []c              3  ó8   "  € T F  p\        V4      x € K  	  R # 5ir+   r   )r,   r]   s   & r   r.   Ú#_stable_tool_key.<locals>.<genexpr>l   s   é € ÐE¹°2Ô*¨2×.Ð.»ùs   ‚Ú	timestampÚtool_call_idÚ	tool_namer   )r   Útupler3   )rW   r[   Úcall_idss   &  r   Ú_stable_tool_keyrt   c   sŒ   € ð ˆ6…{�kÔ!ÙÜ�S˜Õ&×.Ð.¨$°Ð4jÓk€EßŒuÑE¸¿¸À"¸ÓE�u‰uÑE¸¿¸À"¸ÓEÓE€Hß”C˜—M’MØ˜T 3 {Õ#3°S¸Õ5HÈ(ÐXcÕTdÐeÐeÙr   )"Ú__doc__Ú
__future__r   r?   Útypingr   r   r   r   r   r   r	   Úagent.message_metadatar
   r   r   r   r   Úagent.message_sanitizationr   Úhermes_state_commonr   r!   r&   r6   r:   rC   rG   rL   rT   r`   rd   rh   rt   r   r   r   Ú<module>r{      sh   ðñ`õ #ã ß L× LÑ Lç nÕ nÝ <Ý (õEõ
õ	qõLõ.õ
>õ
9õ
Kõ	2õ2õ.÷r   