
    .cj                         U d Z ddlmZmZ ddlmZ daeeeeegdf                  e	d<   deeeeegdf                  ddfdZ
defd	Zd
ededefdZdS )a  Bridge desktop-only tools to Hermes-desktop renderer events.

The preview pane, pane focus, and friends live in the desktop renderer, so
desktop-gated tools reach them through an emitter the desktop ``tui_gateway``
installs at session start via :func:`set_emitter`. Everywhere else it stays
``None`` and the tools report "desktop only". Routing keys off
``HERMES_UI_SESSION_ID`` so the event lands on the window that owns the turn
(``_emit``/``write_json`` is ``_stdout_lock``-guarded, so emitting from the
tool's thread is safe).
    )CallableOptional)get_session_envN_emitfnreturnc                 
    | a dS )zJInstall (or clear) the renderer-event sink. Called by the desktop gateway.Nr   )r   s    2/home/ice/.hermes/hermes-agent/tools/desktop_ui.pyset_emitterr      s     EEE    c                      t           duS )z>True when running under the desktop app (an emitter is wired).Nr
    r   r   	availabler      s    r   eventpayloadc                 R    t           }|dS  |t          dd          | |           dS )zRoute ``event`` to the window that owns the current turn.

    Returns ``False`` when no emitter is wired (i.e. not the desktop app).NFHERMES_UI_SESSION_ID T)r   r   )r   r   r   s      r   emitr       s7     
B	zuB-r22E7CCC4r   )__doc__typingr   r   gateway.session_contextr   r   strdict__annotations__r   boolr   r   r   r   r   <module>r      s   	 	 	 & % % % % % % % 3 3 3 3 3 3 59x#sD)4/01 8 8 8HXsC&6&<=> 4    4    
 d t      r   