
    sj                         d Z ddlZddlmZ ddlmZ ddlmZmZ dde	de	fd	Z
d
ddddddiddZ ej        d
ded d           dS )u  Close the Hermes desktop GUI's preview pane, or one of its tabs.

Lives in the ``desktop_ui`` toolset (same as ``open_preview``), which the GUI
gateway enables only for a session whose source is the desktop app. Emits
``preview.close`` through the shared ``desktop_ui`` bridge; the renderer drops
the matching tab — or the whole pane when no url is given — for the window
that asked and never steals a background session's view.
    N)
desktop_ui)_normalize_target)registry
tool_error urlreturnc                     t          | pd          }	 t          j        dd|i          }n)# t          $ r}t	          d|           cY d}~S d}~ww xY w|st	          d          S t          j        d|dd	
          S )zFAsk the desktop GUI to close the preview pane, or the tab for ``url``.r   zpreview.closer   z"Failed to close the preview pane: Nz=The preview pane is only available in the Hermes desktop app.T)successr   F)ensure_ascii)r   r   emit	Exceptionr   jsondumps)r   targetokexcs       </home/agent/.hermes/hermes-agent/tools/close_preview_tool.pyclose_preview_toolr      s    syb))FF__ufo>> F F FDsDDEEEEEEEEF [YZZZ:$v66UKKKKs   + 
AAAAclose_previewuu  Close the preview pane beside the chat in the Hermes desktop app, or one tab inside it. Use this when the user asks to close, hide, or dismiss the preview — e.g. "close the preview pane", "close cnn.com", "hide the preview". Omit url to close the whole pane (every tab). Pass a web URL, localhost address, or file path to close only that tab. Counterpart of open_preview.objectstringu   Optional. The tab to close: a web URL (https://… or a bare domain), a localhost URL, or a file path. Omit to close the whole preview pane.)typedescription)r   
properties)namer   
parametersr   c                 L    t          |                     d          pd          S )Nr   r   )r   )r   get)argskws     r   <lambda>r"   >   s!    1dhhuoo6KLLL     u   🖼️)r   toolsetschemahandleremoji)r   )__doc__r   toolsr   tools.open_preview_toolr   tools.registryr   r   strr   CLOSE_PREVIEW_SCHEMAregister r#   r   <module>r0      s            5 5 5 5 5 5 / / / / / / / /L LC L L L L L 	  * 	
   4  	LL
     r#   