+
    jHàj>  ã                   ó¸   € R t ^ RIHt ^ RIHt ^ RIHt ]! RR04      tRt	Rt
]! RRR	7      tR
 tR tR tR tR tR]R]/tRR lt]R 4       tR tR tRR ltR# )aÁ  Per-turn client surface (floating HUD, live voice) carried through canonical admission.

A surface is a fact about ONE turn, never about the session: the same session alternates
between the app window, the HUD and a spoken delegation. It is committed with the admission
row and reaches the model as a note on the user message (api_content sidecar), so the
persisted user row stays the words the user typed and the frozen system prefix is untouched.
)Úcontextmanager)Ú
ContextVar)ÚRuntimeStoreErrorÚhudú
voice-liveip  Úsurface_turnN)Údefaultc                óV   € \          Uu/ uF  qV 9   g   K  WV,          bK  	  up# u upi )zWThe raw per-turn surface fields of a ``prompt.submit`` request, forwarded to admission.)Ú_SUBMIT_FIELDS)ÚparamsÚkeys   & Ú</home/ubuntu/.hermes/hermes-agent/gateway/session_surface.pyÚsubmit_surface_fieldsr      s(   € å(6ÓH© À¹-ÔˆC˜•Ò©ÑHÐHùÒHs   ‰&–&c                óØ  a € V 3R l\          4       w  rr4Ve   V\        9  d   \        R4      hVe)   VR8w  g   \        V\        4      '       g   \        R4      h\
        ;QJ d    R W43 4       F  '       g   K   RM	  RM! R W43 4       4      '       d   \        R4      h/ pV'       d   WR&   V'       d   VR\         VR	&   V'       d   RVR
&   V'       d   RVR&   V'       d   RV/# / # )zÍWire ``surface`` / ``voice_context`` / ``interrupted`` / ``voice_turn`` -> committed ``surface_v1``
(``{}`` when absent). ``voice_turn`` marks a spoken voice-mode turn: it runs on ``auxiliary.voice_chat``.c              3   óF   <"  € T F  pSP                  V4      x € K  	  R # 5i©N)Úget)Ú.0r   r   s   & €r   Ú	<genexpr>Ú admit_surface.<locals>.<genexpr>   s   øé € Ð0[ÉNÀS°·±¸C·°ËNùs   ƒ!NÚinvalid_paramsr   c              3   óZ   "  € T F!  qR J;'       d    \        V4      \        Jx € K#  	  R # 5ir   )ÚtypeÚbool)r   Úflags   & r   r   r   "   s)   é € Ð
]ÑC\¸4�tÐ×6Ð6¤ T£
´$Ð 6Ô6ÓC\ùs   ‚+‘+TFÚsurfaceÚvoice_contextÚinterruptedÚ
voice_turnÚ
surface_v1)r
   ÚSURFACESr   Ú
isinstanceÚstrÚanyÚ_VOICE_CONTEXT_LIMIT)r   r   Úcontextr   r   Ú	committeds   f     r   Úadmit_surfacer'      sÛ   ø€ ô 1\ÍNÓ0[Ñ-€G�kØÒ˜w¬hÔ6ÜÐ 0Ó1Ð1ð Ò ¨<Ô 7¼zÈ'ÔSV×?WÒ?WÜÐ 0Ó1Ð1ß
ƒsÑ
]ÀKÑC\Ó
]‡s‡s‚sÑ
]ÀKÑC\Ó
]×]Ò]ÜÐ 0Ó1Ð1Ø€IßØ&�)ÑßØ%,Ð-BÔ.BÐ%Cˆ	�/Ñ"ßØ#'ˆ	�-Ñ ßØ"&ˆ	�,Ñß(1ˆL˜)Ð$Ð9°rÐ9ó    c                óâ   € \        V \        4      '       dN   V '       dF   \        V 4      \        \        4      ,
          '       g!   \	        V 4      P                  R/ 4      V 8w  d   \        R4      hV # )z¸A committed ``surface_v1`` arriving across a process boundary (managed worker), re-checked by
the admission validator: only an object admission itself could have committed is accepted.r   r   )r!   ÚdictÚsetr
   r'   r   r   )r&   s   &r   Úrestore_surfacer,   0   sS   € ô �y¤$×'Ò'¯y¼CÀ	»NÌSÔQ_ÓM`×<`Ô<`Ü˜YÓ'×+Ñ+¨L¸"Ó=ÀÔJÜÐ 0Ó1Ð1ØÐr(   c                 ó   € ^ RI Hp V! V4      # )é    )Úhud_surface_note)Úagent.prompt_builderr/   )r&   Úvalid_tool_namesr/   s   && r   Ú	_hud_noter2   9   s   € Ý5ÙÐ,Ó-Ð-r(   c                 óP   € ^ RI Hp T! V P                  R4      ;'       g    R4      # )r.   )Úvoice_live_turn_noter   Ú )Útools.voice_liver4   r   )r&   r1   r4   s   && r   Ú_voice_live_noter7   >   s!   € Ý5Ù 	§¡¨oÓ >× DÐ DÀ"ÓEÐEr(   c                ó  € . pV P                  R4      '       d   ^ RIHp VP                  V4       \        P                  V P                  R4      4      pVe   VP                  V! W4      4       RP                  R V 4       4      # )z«The model-bound note for a committed surface (``""`` for the plain app window): barge-in
first, then the HUD read-the-window-below prior or the spoken-delegation contract.r   )ÚSPEECH_INTERRUPTED_NOTEr   ú

c              3   ó8   "  € T F  q'       g   K  Vx € K  	  R # 5ir   © ©r   Únotes   & r   r   Úsurface_note.<locals>.<genexpr>P   s   é € Ð6© ³—t’t«ùó   ‚	�
)r   Útools.tts_streamingr9   ÚappendÚ_SURFACE_NOTESÚjoin)r&   r1   Únotesr9   Úrenders   &&   r   Úsurface_noterG   F   sm   € ð €EØ‡}�}�]×#Ò#Ý?Ø�‰Ð,Ô-Ü×Ñ 	§¡¨iÓ 8Ó9€FØÒØ�‰‘V˜IÓ8Ô9Ø�;‰;Ñ6©Ó6Ó6Ð6r(   c              #   ó    "  € \         P                  V 4      p R x € \         P                  V4       R #   \         P                  T4       i ; i5ir   )Ú_surface_turnr+   Úreset)r&   Útokens   & r   Úsurface_turn_scoperL   S   s9   é € ä×Ñ˜iÓ(€Eð#Ûä×Ñ˜EÖ"øŒ×Ñ˜EÕ"üs   ‚A™4 �A´AÁAc                 ón   € \        \        P                  4       ;'       g    / P                  R4      4      # )zXWhether the executing admission is a spoken voice turn (``auxiliary.voice_chat`` route).r   )r   rI   r   r<   r(   r   Úsurface_voice_turnrN   \   s)   € ä”×"Ñ"Ó$×*Ð*¨×/Ñ/°Ó=Ó>Ð>r(   c                ól   € \         P                  4       pV'       g   R# \        V\        V RR4      4      # )zSThe executing admission's surface note, gated on the tools this agent actually has.r5   r1   N)rI   r   rG   Úgetattr)Úagentr&   s   & r   Úsurface_turn_noterR   a   s-   € ä×!Ñ!Ó#€IßÙÜ˜	¤7¨5Ð2DÀdÓ#KÓLÐLr(   c                óž   € \        V4      ;'       g    \        4       V n        RP                  R . VO\	        V 4      N 4       4      V n        R# )aI  Project the executing admission's surface onto the agent's one-turn inputs, the same way in
process and in a managed worker: the ``auxiliary.voice_chat`` marker and the must-deliver notes
that ride the current user message (never the system prompt). Assigned unconditionally so a
reused agent never replays a stale note or route.r:   c              3   ó8   "  € T F  q'       g   K  Vx € K  	  R # 5ir   r<   r=   s   & r   r   Ú#arm_surface_turn.<locals>.<genexpr>o   s   é € ð 4EÙ;�»t�ŠÓ;ùr@   N)r   rN   Ú_voice_turn_pendingrD   rR   Ú_gateway_turn_context_notes)rQ   rE   r   s   &&&r   Úarm_surface_turnrX   i   sN   € ô
 !% ZÓ 0× HÐ HÔ4FÓ4H€EÔØ(.¯©ñ 4EØ;˜5Ð;Ô"3°EÓ":Ñ;ó4Eó )E€EÖ%r(   )r   r   r   r   r   )r<   F)Ú__doc__Ú
contextlibr   Úcontextvarsr   Úhermes_state_runtimer   Ú	frozensetr    r$   r
   rI   r   r'   r,   r2   r7   rC   rG   rL   rN   rR   rX   r<   r(   r   Ú<module>r^      s‘   ðñõ &Ý "å 2á�e˜\Ð*Ó+€ØÐ ØJ€Ù˜>°4Ô8€òIò
:ò0ò.ò
Fð
 ˜ LÐ2BÐC€ô
7ð ñ#ó ð#ò?ò
MöEr(   