
    xj	                         d Z ddlZddlmZ ddlmZmZ dedefdZdd	d
ddddidgddZ	 ej
        dde	d d           dS )u  Close a read-only agent terminal tab in the Hermes desktop GUI.

Each ``terminal(background=true)`` process is mirrored as a read-only tab in the
desktop's terminal pane. This tool lets the agent drop a tab it no longer needs
to show — WITHOUT killing the process (use ``process(action='kill')`` for that).
The output keeps buffering and the user can reopen the tab from the status stack.

It routes through the process registry's ``on_close`` sink, which the desktop
gateway wires to emit a ``terminal.close`` event the renderer handles. Like
``read_terminal`` it lives in the ``desktop_ui`` toolset, which the GUI gateway
enables only for desktop-sourced sessions, so it never appears outside the GUI.
    N)process_registry)registry
tool_error
process_idreturnc                     | pd                                 }|st          d          S t          j        t	          j        |          d          S )zBAsk the desktop GUI to close a background process's read-only tab. zCprocess_id is required (the background process whose tab to close).F)ensure_ascii)stripr   jsondumpsr   request_close_terminal)r   pids     =/home/agent/.hermes/hermes-agent/tools/close_terminal_tool.pyclose_terminal_toolr      sR    
"
"
$
$C a_```:&=cBBQVWWWW    close_terminalu  Close the read-only terminal tab for one of your background processes in the Hermes desktop GUI (the tabs mirroring terminal(background=true) runs). This does NOT kill the process — it only drops the tab/view; the output keeps buffering and the user can reopen it from the status stack. Use it to tidy up when a background process's live terminal is no longer worth showing. To actually stop the process, use process(action='kill') instead.objectstringzThe background process's session id (from terminal(background=true) output or process(action='list')) whose tab should be closed.)typedescription)r   
propertiesrequired)namer   
parameters
desktop_uic                 J    t          |                     dd                    S )Nr   r	   )r   )r   get)argskws     r   <lambda>r!   <   s!    2dhh|UW>X>XYYY r   u   🖥️)r   toolsetschemahandleremoji)__doc__r   tools.process_registryr   tools.registryr   r   strr   CLOSE_TERMINAL_SCHEMAregister r   r   <module>r-      s      3 3 3 3 3 3 / / / / / / / /XC XC X X X X 	U  T 
 "N   4  	 YY
     r   