
    sjJ                         d Z ddlZddlmZ ddlmZmZ d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 )u1  Apply a layout preset in the Hermes desktop GUI.

Lives in the ``desktop_ui`` toolset (like ``focus_pane``), which the GUI
gateway enables only for desktop-sourced sessions. Emits ``layout.apply``
through the shared ``desktop_ui`` bridge; the renderer resolves the preset id
against its layouts registry (core presets, plugin presets, and user-saved
presets are all the same list) and applies the tree through the exact code
path the layout picker uses. Only the active window's session may act — a
background turn never rearranges the user's desktop.

Preset ids are free-form on purpose: plugins and users mint their own. The
renderer answers with the applied preset's id/title on success and the list
of available ids when the id is unknown, so the model can self-correct
without a second registry-listing tool.
    N)
desktop_ui)registry
tool_errorz9Layout apply is only available in the Hermes desktop app.presetreturnc                 8   | pd                                 }|st          d          S 	 t          j        dd|i          }n,# t          $ r}t          d| d|           cY d}~S d}~ww xY w|st          t
                    S t          j        d|d	d
          S )z6Ask the desktop GUI to apply layout preset ``preset``. uE   preset is required — a layout preset id, e.g. 'default' or 'focus'.zlayout.applyr   zFailed to apply layout 'z': NT)successr   F)ensure_ascii)stripr   r   emit	Exception_TIMEOUT_NOTEjsondumps)r   nameokexcs       ;/home/agent/.hermes/hermes-agent/tools/apply_layout_tool.pyapply_layout_toolr      s    Lb!!D cabbbE_^h-=>> E E ECTCCcCCDDDDDDDDE )-(((:$$77eLLLLs   A 
A*A%A*%A*apply_layoutu  Apply a saved layout preset to the Hermes desktop app when the user asks to rearrange the workspace — e.g. "set up my layout for coding", "give me a focused view", "put the terminal front and center". Built-in presets: default (chat + sidebars), focus (chat only), terminal-deck (terminal forward), quad (four zones). Plugin and user-saved presets are addressed by their id. To reveal a single pane without rearranging everything, use focus_pane instead.objectstringziLayout preset id to apply (e.g. 'default', 'focus', 'terminal-deck', 'quad', or a user/plugin preset id).)typedescription)r   
propertiesrequired)r   r   
parametersr   c                 J    t          |                     dd                    S )Nr   r	   )r   )r   get)argskws     r   <lambda>r#   H   s     028N8NOOO     u   🧱)r   toolsetschemahandleremoji)__doc__r   toolsr   tools.registryr   r   r   strr   APPLY_LAYOUT_SCHEMAregister r$   r   <module>r0      s             / / / / / / / / LMc Mc M M M M" 	    K 
 J	 	  0  	OO
     r$   