§
    øžyj÷  ã            	       óÆ   — d Z ddlZddlmZmZ ddlmZmZ 	 	 	 ddee         dee         dee         de	fd	„Z
d
dddddœdddœdœdœdœZ ej        d
ded„ d¬¦  «         dS )u  Read the in-app terminal pane in the Hermes desktop GUI.

The embedded terminal's buffer lives in the desktop renderer (xterm.js), so this
tool round-trips through the gateway's blocking-prompt bridge â€” the same one
`clarify` uses: tui_gateway emits ``terminal.read.request``, the renderer answers
with ``terminal.read.respond``. This module is just schema + a thin dispatcher
over the platform-injected callback.

Lives in the ``desktop_ui`` toolset, which the GUI gateway enables only for
desktop-sourced sessions.
é    N)ÚCallableÚOptional)ÚregistryÚ
tool_errorÚ
start_lineÚcountÚcallbackÚreturnc                 óî  — |€t          d¦  «        S 	 d„ d| dfd|dffD ¦   «         }n&# t          t          f$ r t          d¦  «        cY S w xY w	  |di |¤Ž}n)# t          $ r}t          d	|› �¦  «        cY d}~S d}~ww xY w|st          d
¦  «        S 	 t	          j        t	          j        |¦  «        d¬¦  «        S # t          t          f$ r( t	          j        dt          |¦  «        id¬¦  «        cY S w xY w)zIReturn the in-app terminal's contents (+ line metadata) as a JSON string.Nz:read_terminal is only available in the Hermes desktop app.c           	      óV   — i | ]&\  }}}|®|t          |t          |¦  «        ¦  «        “Œ'S )N)ÚmaxÚint)Ú.0ÚkeyÚvalÚfloors       ú>/home/ragecks/.hermes/hermes-agent/tools/read_terminal_tool.pyú
<dictcomp>z&read_terminal_tool.<locals>.<dictcomp>   s=   € ð 
ð 
ð 
á��S˜%Øˆð •�U�C ™HœHÑ%Ô%àˆˆó    Ústartr   r   é   z&start_line and count must be integers.zFailed to read terminal: z2No in-app terminal is open, or the read timed out.F)Úensure_asciiÚtext© )r   Ú	TypeErrorÚ
ValueErrorÚ	ExceptionÚjsonÚdumpsÚloadsÚstr)r   r   r	   ÚwindowÚrawÚexcs         r   Úread_terminal_toolr%      su  € ð ÐÝÐVÑWÔWÐWðDð
ð 
à%,¨j¸!Ð$<¸wÈÈqÐ>QÐ#Rð
ñ 
ô 
ˆˆøõ
 •zÐ"ð Dð Dð DÝÐBÑCÔCÐCÐCÐCðDøøøð=ØˆhÐ Ð ˜Ð Ð ˆˆøÝð =ð =ð =ÝÐ;°cÐ;Ð;Ñ<Ô<Ð<Ð<Ð<Ð<Ð<Ð<øøøøð=øøøð ð PÝÐNÑOÔOÐOðBÝŒz�$œ* S™/œ/¸Ð>Ñ>Ô>Ð>øÝ•zÐ"ð Bð Bð BÝŒz˜6¥3 s¡8¤8Ð,¸5ÐAÑAÔAÐAÐAÐAðBøøøs?   “( ¨ AÁ
AÁA Á
A>Á"A9Á3A>Á9A>Â'B; Â;6C4Ã3C4Úread_terminala�  Read what's currently shown in the in-app terminal pane of the Hermes desktop GUI (the embedded shell beside this chat). Call with no arguments to get the visible screen plus the total line count (`total_lines`). To page through scrollback, pass `start_line` (0 = oldest line) and `count`; valid lines are [0, total_lines). Returns JSON: {total_lines, start, end, viewport_rows, cursor_row, text}.ÚobjectÚintegerz?0-indexed first line (0 = oldest). Omit for the visible screen.)ÚtypeÚdescriptionzALines to read from start_line. Defaults to the visible row count.)r   r   )r)   Ú
properties)Únamer*   Ú
parametersÚ
desktop_uic                 ó˜   — t          |                      d¦  «        |                      d¦  «        |                     d¦  «        ¬¦  «        S )Nr   r   r	   )r   r   r	   )r%   Úget)ÚargsÚkws     r   ú<lambda>r3   S   sC   € Õ1Ø—8’8˜LÑ)Ô)Ø�hŠh�wÑÔØ—’˜
Ñ#Ô#ð ñ  ô  € r   u   ðŸ–¥ï¸�)r,   ÚtoolsetÚschemaÚhandlerÚemoji)NNN)Ú__doc__r   Útypingr   r   Útools.registryr   r   r   r!   r%   ÚREAD_TERMINAL_SCHEMAÚregisterr   r   r   ú<module>r=      s>  ðð
ð 
ð €€€Ø %Ð %Ð %Ð %Ð %Ð %Ð %Ð %à /Ð /Ð /Ð /Ð /Ð /Ð /Ð /ð !%ØØ#'ðBð BØ˜”ðBà�CŒ=ðBð �xÔ ðBð 	ð	Bð Bð Bð BðD ð	Fð ð "Ø`ðð ð
 "Øbðð ð	
ð 	
ðð ðð Ð ð4 €Ô Ø	ØØðð ð
 ð
ñ 
ô 
ð 
ð 
ð 
r   