+
    iHàjó  ã                  ó&  € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIHtH	t	H
t
HtHt Rt^Èt]! 0 Rm4      t]! 0 Rm4      tR R ltR R ltRR	 R
 lltR R ltR R lt]P.                  3R R llt]P.                  3R R lltR R ltR R ltR# )a#  Who wrote the user side of a turn, carried from the dispatcher into the recipient's turn.

The dispatcher sets ``HERMES_TURN_AUTHOR`` on the recipient's one-shot subprocess only. A cached
gateway agent sees several authors over its lifetime, so the author is read per turn, never per agent.
)ÚannotationsN)ÚAnyÚDictÚMappingÚMutableMappingÚOptionalÚHERMES_TURN_AUTHORc               ó    € V ^8„  d   QhRRRR/# )é   Úvaluer   ÚreturnúOptional[str]© )Úformats   "Ú6/home/ubuntu/.hermes/hermes-agent/agent/turn_author.pyÚ__annotate__r      s   € ÷ !ñ !�sð !˜}ñ !ó    c                ó¤   € \        V \        4      '       g   R# RP                  R V  4       4      P                  4       pV'       g   R# VR\         # )zÁStrip whitespace, control and unassigned characters, then cap the length. None when nothing is left.
Format characters and non-breaking spaces stay so emoji sequences and display names survive.NÚ c              3  óh   "  € T F(  p\         P                  ! V4      \        9  g   K$  Vx € K*  	  R # 5i©N)ÚunicodedataÚcategoryÚ_DROPPED_CATEGORIES)Ú.0Úchs   & r   Ú	<genexpr>Ú_clean_text.<locals>.<genexpr>   s%   é € Ð]¡˜"¬×)=Ò)=¸bÓ)AÔI\Ñ)\—2’2£ùs   ‚!2¨
2)Ú
isinstanceÚstrÚjoinÚstripÚ_MAX_FIELD_LEN)r   Útexts   & r   Ú_clean_textr$      sD   € ô �eœS×!Ò!ÙØ�7‰7Ñ]¡Ó]Ó]×cÑcÓe€DßÙØ�”Ð Ð r   c               ó    € V ^8„  d   QhRRRR/# )r
   r   r   r   Úboolr   )r   s   "r   r   r   #   s   € ÷ :ñ :�Sð :˜Tñ :r   c                óÊ   € \        V \        4      '       d&   V P                  4       P                  4       \        9   # \        V \
        \        34      ;'       d    \        V 4      # r   )r   r   r!   ÚlowerÚ_TRUTHYr&   Úint)r   s   &r   Ú	_bot_flagr+   #   sF   € Ü�%œ×ÒØ�{‰{‹}×"Ñ"Ó$¬Ñ/Ð/Ü�eœd¤C˜[Ó)×9Ð9¬d°5«kÐ9r   c               ó$   € V ^8„  d   QhRRRRRR/# )r
   Úprofiler   Úoriginr   r   r   )r   s   "r   r   r   )   s&   € ÷ Eñ E˜3ð E¨ð EÀñ Er   c                ó`   € T;'       g    RP                  4       pV'       d	   RV RV  2# RV  2# )zÔ``bot:<profile>`` for a bot on the recipient's own install, ``bot:<origin>/<profile>`` for one on another
install. The origin is the Desktop's connection id on a relayed dm and the sender's hostname on a peer dm.r   úbot:Ú/)r!   )r-   r.   s   &&r   Úbot_author_idr2   )   s9   € ð �lˆl˜×!Ñ!Ó#€Fß(.ˆT�&�˜˜7˜)Ð$ÐD°d¸7¸)Ð4DÐDr   c               ó   € V ^8„  d   QhRR/# )r
   r   r   r   )r   s   "r   r   r   0   s   € ÷ 6ñ 6�cñ 6r   c                 óœ   €  \         P                  ! 4       p \        T 4      ;'       g    RP	                  RR4      #   \         d     R# i ; i)zbThis machine's hostname as an author-id origin, cleaned like any author field. Empty when unknown.r   r1   )ÚsocketÚgethostnameÚ	Exceptionr$   Úreplace)Úhosts    r   Úlocal_originr:   0   sK   € ðÜ×!Ò!Ó#ˆô ˜Ó×#Ð# ×,Ñ,¨S°"Ó5Ð5øô ô Úðús   ‚< ¼AÁ
Ac               ó    € V ^8„  d   QhRRRR/# )r
   Úrawr   r   úOptional[dict[str, Any]]r   )r   s   "r   r   r   :   s   € ÷ ñ ˜3ð Ð#;ñ r   c           
     ó   €  \        V \        \        34      '       d   \        P                  ! V 4      p \        V \
        4      '       g   R# R\        V P                  R4      4      R\        V P                  R4      4      R\        V P                  R4      4      /pVR,          f   VR,          f   R# \        V P                  R4      4      pV'       dg   VR,          '       dX   VR,          P                  R4      '       d:   RVR,          9  d,   \        \        VR,          \        R4      R V4      4      VR&   V#   \         d     R# i ; i)aÈ  Normalize a dict or JSON string into ``{"id", "name", "is_bot"}``; None for anything else or without id and name.
The id is whatever the transport knows the sender by: ``bot:<profile>`` on a bot-mode delivery inside one
install, ``bot:<connection>/<profile>`` when the Desktop relayed it from another machine,
``bot:<hostname>/<profile>`` on a peer dm, the platform user id elsewhere.
An ``origin`` field qualifies a bare ``bot:<profile>`` id the same way.NÚidÚnameÚis_botr.   r0   r1   )r   r   ÚbytesÚjsonÚloadsr   r$   Úgetr+   Ú
startswithr2   Úlenr7   )r<   Úauthorr.   s   &  r   Úparse_turn_authorrI   :   s  € ðÜ�cœC¤˜<×(Ò(Ü—*’*˜S“/ˆCÜ˜#œw×'Ò'Ùà”+˜cŸg™g d›mÓ,Ø”K §¡¨£Ó0Ø”i §¡¨Ó 1Ó2ð
ˆð
 �$�<Ò F¨6¥NÒ$:ÙÜ˜SŸW™W XÓ.Ó/ˆß�f˜T—l”l v¨d¥|×'>Ñ'>¸v×'FÒ'FÈ3ÐV\Ð]aÕVbÔKbÜ&¤}°V¸Dµ\Ä#ÀfÃ+À,Ð5OÐQWÓ'XÓYˆF�4‰LØˆøÜô Úðús+   ‚AD> ÁA&D> Â40D> Ã%D> Ä:D> Ä>EÅEc               ó    € V ^8„  d   QhRRRR/# )r
   ÚenvironzMapping[str, str]r   r=   r   )r   s   "r   r   r   T   s   € ÷ ;ñ ;Ð"3ð ;ÐE]ñ ;r   c                ó>   € \        V P                  \        4      4      # )zDThe author the dispatcher placed in ``HERMES_TURN_AUTHOR``, or None.)rI   rE   ÚTURN_AUTHOR_ENV©rK   s   &r   Úturn_author_from_envrO   T   s   € ä˜WŸ[™[¬Ó9Ó:Ð:r   c               ó    € V ^8„  d   QhRRRR/# )r
   rK   zMutableMapping[str, str]r   r=   r   )r   s   "r   r   r   Y   s    € ÷ Añ AÐ'?ð AÐQiñ Ar   c                ó@   € \        V P                  \        R4      4      # )zaRead and remove ``HERMES_TURN_AUTHOR`` so subprocesses started during the turn do not inherit it.N)rI   ÚpoprM   rN   s   &r   Útake_turn_author_from_envrS   Y   s   € ä˜WŸ[™[¬¸$Ó?Ó@Ð@r   c               ó    € V ^8„  d   QhRRRR/# )r
   rH   zdict[str, Any]r   zdict[str, str]r   )r   s   "r   r   r   ^   s   € ÷ Hñ H˜Nð H¨~ñ Hr   c                ó>   € \         \        P                  ! V RR7      /# )z=The environment entry a dispatcher merges into a child's env.)Ú
separators)Ú,Ú:)rM   rC   Údumps©rH   s   &r   Úturn_author_envr[   ^   s   € äœTŸZšZ¨¸:ÔFÐGÐGr   c               ó    € V ^8„  d   QhRRRR/# )r
   rH   r=   r   r   r   )r   s   "r   r   r   c   s   € ÷ !ñ !Ð,ð !°ñ !r   c                ó¦   € \        V \        4      '       d/   V P                  R4      '       d   V P                  R4      '       g   R# RV R,           2# )z_``a2a:<bot id>``, the shared name for a bot author's turns. None for a human or an id-less bot.rA   r?   Nza2a:)r   ÚdictrE   rZ   s   &r   Úa2a_keyr_   c   s@   € ä�fœd×#Ò#¨6¯:©:°h×+?Ò+?ÀvÇzÁzÐRV×GWÒGWÙØ�&˜•,�Ð Ð r   >   ÚCcÚCnÚCoÚCs>   Ú1ÚyesÚtruer   )Ú__doc__Ú
__future__r   rC   Úosr5   r   Útypingr   r   r   r   r   rM   r"   Ú	frozensetr   r)   r$   r+   r2   r:   rI   rK   rO   rS   r[   r_   r   r   r   Ú<module>rl      sˆ   ðñõ #ã Û 	Û Û ß ?Õ ?à&€à€ñ  Ò 8Ó9Ð Ù
Ò(Ó
)€õ!õ:÷Eõ6õð4 79·j±j÷ ;ð
 CEÇ*Á*÷ Aõ
H÷
!r   