+
    jHàj¤  ã                   óŽ   € R t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHt ]P                  ! ]
4      tRR/R ltR tR	 tR
 tR tR tR# )aç  ``@`` references of one turn: expanded once, in the session's workspace, on the text the model reads.

The inbound prepare step, the classic CLI's API-only text (``cli_turn_v1.api_text``: voice prefix,
model-switch and skills notes) and managed workers (``--safe-mode`` / ``--ignore-user-config``,
which never pass the inbound step) all expand here. A local session's refusal is the turn's reply:
its adapter delivers through settlement, so a side ``send`` would never reach the viewer.
N)Úsuppress)Úpartial)ÚPlatformÚpluginsTc             ƒ  ó´  "  € ^ RI Hp  ^ RIHp \	        WQW!R7      pV'       d	   V! V 4      M	V! V RR7      G Rj  x€L
 pTP                  '       d.   T R
P                  TP                  4      ;'       g	    T! R4      3# TP                  '       d   TP                  R3# T R3#  Lg  \
         d'   p\        P                  RTRR	7       T R3u Rp?# Rp?ii ; i5i)zƒ``(text, refusal)``: the expanded text, or the refusal when the injection was refused. A failed
expansion leaves the text as typed.)Út)Ú#preprocess_context_references_async)ÚcwdÚcontext_lengthÚallowed_rootF)r   Nú(@ context reference expansion failed: %sT©Úexc_infoÚ
z(gateway.notify.context_injection_refused)Ú
agent.i18nr   Úagent.context_referencesr   r   Ú	ExceptionÚloggerÚwarningÚblockedÚjoinÚwarningsÚexpandedÚmessage)	Útextr	   r
   r   r   r   ÚexpandÚresultÚexcs	   &$$$     ÚA/home/ubuntu/.hermes/hermes-agent/gateway/session_context_refs.pyÚexpand_referencesr      s¼   é € õ ðÝPÜÐ<ÐVdÔwˆß(/™˜tœ±V¸DÈ%Ô5P×Qˆð ‡~‡~€~Ø�T—Y‘Y˜vŸ™Ó/×`Ð`±1Ð5_Ó3`Ð`Ð`Ø$ŸoŸo˜oˆF�N‰N¸$Ð>Ð>°4¸$Ð>Ð>ñ RøÜô Ü�‰ÐAÀ3ÐQUˆÔVØ�TˆzÕûðüsU   ‚CŠ0B$ ºB"»B$ ¿CÁ"CÁ4CÂCÂ"B$ Â$CÂ/CÃ
CÃCÃCÃCc                 óî   € ^ RI Hp  ^ RIHp V! W4      ;pe   VP                  # V! R\
        P                  P                  R4      4      #   \         d    \
        P                  P                  p Lei ; i)é    )Úpolicy_for_source)Úterminal_envÚTERMINAL_CWDÚ~)Úgateway.session_policyr"   Útools.terminal_scoper#   ÚImportErrorÚosÚenvironÚgetr	   ÚpathÚ
expanduser)ÚrunnerÚsourcer"   r#   Úpolicys   &&   r   Ú_inbound_cwdr1   "   sc   € Ý8ð&Ý5ñ
 $ FÓ3Ð3ˆÒ@Ø�z‰zÐÙ˜¬¯©×(:Ñ(:¸3Ó(?Ó@Ð@øô ô &Ü—z‘z—~‘~Šð&ús   ˆA Á%A4Á3A4c              ƒ  óî   "  €  \        W4      pV P                  W4      G Rj  x€L
 p\        Y4TR7      G Rj  x€L
 #  L  \         d'   p\        P	                  RTRR7       TR3u Rp?# Rp?ii ; i L:5i)z_``expand_references`` for an inbound turn: a local session's policy cwd, else the terminal cwd.Nr   Tr   )r	   r
   )r1   Ú_inbound_model_context_lengthr   r   r   r   )r.   r/   Úsession_keyr   r	   r
   r   s   &&&&   r   Úinbound_referencesr5   /   ss   é € ðÜ˜6Ó*ˆØ%×CÑCÀFÓX×Xˆô # 4ÀÔP×PÐPñ	 YøÜô Ü�‰ÐAÀ3ÐQUˆÔVØ�TˆzÕûðúñ QùsG   ‚A5„? £=¤? ¨A5¸A3¹A5½? ¿A0Á
A+Á%A0Á&A5Á+A0Á0A5c              ƒ  ó&  "  € ^ RI HpHp V! VP                  4      P	                  R4      pVf   TMTpRV9  d   V# VP
                  \        P                  8X  d$   \        WW84      G Rj  x€L
 w  ršV
e	   W¡n	        R# M V P                  W#V4      G Rj  x€L
 ;p	f   R# Vf   V	# V! VP                  V	4       VP                  4       pV	P                  V4      '       d   V	\        V4      R MRpV'       d   V V 2P                  4       # T#  L¡ Lz5i)a  An inbound turn's text with the references of the text the model reads expanded; None when
refused. The classic CLI's committed ``api_text`` replaces ``text`` at the turn
(``TurnRunner._prepare_turn_message``), so ITS references are expanded and rebound for this
execution, and the returned text, the stored user row, is ``text`` with the same attached
context, as a typed turn stores it: later turns still read the content. A refused local turn
leaves its refusal on ``event`` for the prepare step to answer with.)Úcli_turnÚrebind_api_textÚapi_textNÚ@Ú )Úgateway.session_cli_turnr7   r8   Ú
message_idr+   Úplatformr   ÚLOCALr5   Ú_gateway_turn_refusalÚ"_expand_inbound_context_referencesÚlstripÚ
startswithÚlenÚstrip)r.   Úeventr/   r4   r   r7   r8   r9   Útargetr   ÚrefusalÚheadÚtails   &&&&&        r   Úturn_referencesrK   :   s	  é € ÷ CÙ˜×(Ñ(Ó)×-Ñ-¨jÓ9€HØÒ%‰T¨8€FØ
�&ÔØˆØ‡�œ(Ÿ.™.Ô(Ü"4°VÀ[Ó"Y×YÑˆØÒØ*1Ô'Ùð ð #×EÑEÀfÐ[aÓb×bÐ
bˆ(Ò	kÙØÒØˆÙ�E×$Ñ$ hÔ/à�?‰?Ó€DØ#+×#6Ñ#6°t×#<Ò#<ˆ8”C˜“I�JÑÀ"€Dß&*ˆdˆV�D�6ˆ?× Ñ Ó"Ð4°Ð4ñ Zñ cùs1   ‚A)DÁ+DÁ,(DÂDÂA	DÃDÃ7DÄDc           
   ƒ  óŒ  "  € VP                  R4      ;'       g    / P                  R4      p\        V\        4      '       d   RV9  d   R#  ^ RIHp VP                  V 4      P                  R4      ;'       g    / p\        V\        4      '       d   VP                  R4      MRp\        \        \        4      ;_uu_ 4        Ve   \        V4      MRpRRR4       T! VP                  V 4      ;'       g    RVP                  ;'       g    RRVP                  ;'       g    R\        V\        4      '       d   TMRR	7      G Rj  x€L
 p\#        Y2P$                  TTP&                  '       * R7      G Rj  x€L
 #   + '       g   i     L­; i LF  \         d'   p\        P!                  R
TRR7       TR3u Rp?# Rp?ii ; i LM5i)a;  ``(text, refusal)`` for a managed worker's admitted text, expanded against the session's
workspace. Built-in kinds only for a bypass session, which loads no plugins; the context length
is the frozen policy's, never the profile file a bypass session must not read. ``None`` text means
the admitted text as committed.Úpayloadr   r:   N)Úget_model_context_length_asyncÚmodelr
   r;   )Úbase_urlÚapi_keyÚproviderÚconfig_context_lengthr   Tr   )r	   r
   r   )NN)r+   Ú
isinstanceÚstrÚagent.model_metadatarN   ÚconfigÚdictr   Ú	TypeErrorÚ
ValueErrorÚintÚcurrent_modelrP   rR   r   r   r   r   r	   Úignore_user_config)	Ú	authorityÚrowr0   r   rN   Úmodel_configÚpinnedr
   r   s	   &&&      r   Úmanaged_turn_textrb   V   sw  é € ð
 �G‰G�IÓ×$Ð$ "×)Ñ)¨&Ó1€DÜ�dœC× Ò  C¨t¤OØÐðÝGØ—}‘} YÓ/×3Ñ3°GÓ<×BÐBÀˆÜ7AÀ,ÔPT×7UÒ7U�×!Ñ!Ð"2Ô3Ð[_ˆÜ”i¤×,Õ,Ø$*Ò$6”S˜”[¸DˆF÷ -á=Ø× Ñ  Ó+×1Ð1¨r¸F¿O¹O×<QÐ<QÈrÐ[]Ø—_‘_×*Ð*¨ÌJÐW]Ô_b×LcÒLcÁ&Ðimô o÷ oˆô # 4¯Z©ZÈØ/5×/HÑ/HÔ+HôJ÷ Jð J÷ -×,úñoøô ô Ü�‰ÐAÀ3ÐQUˆÔVØ�TˆzÕûðúñJùs   ‚A
GÁ,F Á:AF ÃE9Ã!F Ã6F ÄF Ä!$F ÅFÅF Å
*GÅ4GÅ5GÅ9F		Æ	F ÆF?ÆF:Æ4F?Æ5GÆ:F?Æ?Gc           
     ó^   € V R,          P                  R4      RJ d   RRR. RRRR	R
V/# RVR. /# )zºA turn that never ran because its references were refused: the refusal is its answer, and a
finite (``chat -q`` / ``-z``) prompt fails with it, as ``execute_admission`` settles a notice.rM   ÚfiniteTÚfinal_responser;   ÚmessagesÚfailedÚ	completedFÚerror)r+   )r_   rH   s   &&r   Úrefused_turn_resultrj   n   sH   € ð ˆ9…~×Ñ˜(Ó# tÓ+Ø  " j°"°hÀÀkÐSXÐZaÐcjÐkÐkØ˜g z°2Ð6Ð6ó    )Ú__doc__Úloggingr)   Ú
contextlibr   Ú	functoolsr   Úgateway.configr   Ú	getLoggerÚ__name__r   r   r1   r5   rK   rb   rj   © rk   r   Ú<module>rt      sS   ðñó Û 	Ý Ý å #à	×	Ò	˜8Ó	$€ð?À$ô ?ò 
AòQò5ò8Jô07rk   