+
    iHàj?	  ã                   óŽ   a € R t0 t R t^ RIt^ RIHt ^ RIHt ^ tR	t]P                  ! 4       t
]! 4       t] ^ k R R ltR R ltR# )
ab  Builder-declared stable prefixes for Anthropic prompt caching.

Skill/webhook/cron builders concatenate a large static scaffold with a small volatile
tail into one user-message string. Only the builder knows where the tail begins, so it
registers the stable prefix here and the cache planner places a breakpoint at that
boundary. Re-parsing marker strings at request time is deliberately avoided: markers
can legitimately appear inside skill bodies, and any delimiter heuristic then shrinks
the cached prefix or absorbs volatile bytes. Process-local by design: any miss falls
back to the whole-message policy.
N)ÚOrderedDict)ÚOptionalc                ó(   € V ^8„  d   QhR\         RR/# )é   ÚprefixÚreturnN)Ústr)Úformats   "Ú@/home/ubuntu/.hermes/hermes-agent/agent/prompt_cache_boundary.pyÚ__annotate__r      s   € ÷ 
*ñ 
*¤3ð 
*¨4ñ 
*ó    c                ó°  € V '       g   R# \         ;_uu_ 4        R\        V &   \        P                  V 4       \        \        4      \        8”  d   \        P                  RR7       K0  \        \        4      ^8”  d?   \        \        \        \        4      4      \        8”  d   \        P                  RR7       KR  RRR4       R#   + '       g   i     R# ; i)zARecord ``prefix`` as the stable scaffold of a just-built message.NF)Úlast)	Ú_lockÚ	_prefixesÚmove_to_endÚlenÚ_MAX_ENTRIESÚpopitemÚsumÚmapÚ
_MAX_CHARS)r   s   &r
   Úregister_stable_prefixr      s~   € çÙß	ŽØ Œ	�&ÑÜ×Ñ˜fÔ%Ü”)‹nœ|Ô+Ü×Ñ 5ÐÖ)Ü”)‹n˜qÔ ¤S¬¬S´)Ó)<Ó%=Ä
Ô%JÜ×Ñ 5ÐÖ)÷ 
��Šús   ™B!CÃC	c                óF   € V ^8„  d   QhR\         R\        \         ,          /# )r   Úcontentr   )r   r   )r	   s   "r
   r   r   '   s   € ÷ ñ ¤ð ¬´­ñ r   c                ól  € \         ;_uu_ 4        Rp\         Fa  pV P                  V4      '       g   K  V \        V4      R P	                  4       '       g   K@  Ve   \        V4      \        V4      8”  g   K_  TpKc  	  Ve   \        P                  V4       VuuRRR4       #   + '       g   i     R# ; i)aM  Longest registered *proper* prefix of ``content`` with a non-whitespace tail.

The tail must be non-whitespace so the split never yields an empty text
block (Anthropic rejects it with HTTP 400). A hit refreshes the entry's LRU
position so a scaffold fired every minute by cron is not evicted by a
burst of one-off skill invocations.
N)r   r   Ú
startswithr   Ústripr   )r   Úbestr   s   &  r
   Úfind_stable_prefixr   '   s�   € ÷ 
ŽØ"ˆßˆFà×"Ñ" 6×*Ô*ØœC ›K˜LÐ)×/Ñ/×1Ô1Ø’\¤S¨£[´3°t³9Ö%<à’ñ  ð ÒÜ×!Ñ! $Ô'Ø÷ 
��‹ús   � B"´B"ÁB"Á7 B"Â"B3	c                óZ   € V ^8„  d   Qh/ ^ \         9   d   \        \        R3,          ;R&   # )r   Nr   )Ú__conditional_annotations__r   r   )r	   s   "r
   r   r      s'   € ÷ 	ñ 	÷, 2Ò 1Œ;”s˜D�yÕ!Ñ 1ò-	r   i  @ )r!   Ú__doc__Ú	threadingÚcollectionsr   Útypingr   r   r   ÚLockr   r   r   r   r   )r!   s   @r
   Ú<module>r'      sD   øðö	ó Ý #Ý ð €ð €
à�ŠÓ€Ù$/£M€	Ó 1õ
*÷r   