Ë
    ãß²j½  ã                   ó®  — d Z ddlZddlmZmZ ddlmZ ddlmZm	Z	 dZ
dZdZ	 	 	 	 d3d	ed
ee   dee   dee   dee   dee   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 ee«      ddœdœdœZdddd ee
«      d dœd ee«      d!dœdd"dœdd#dœdd$dœd ee«      d%dœd&ed'd(œd)d*dœd+œd	gd,œd-œZdefd.„Z ej*                  dd/eed0„ d1¬2«       y)4a:  Guided tour (highlight + narrate UI elements) in the Hermes desktop GUI: the agent discovers
targets (``action="targets"``), then highlights one step at a time (``show``) or hands over a
step list the user pages (``start``). Round-trips through the gateway blocking-prompt bridge
(``tour.request``/``tour.respond``) so the agent learns whether the selector matched. Registered in
``desktop_ui`` and hidden from the model when tours are off: a tour covers the whole screen, so "off"
must mean the model is never told the tool exists rather than offered a call that fails.é    N)ÚCallableÚOptional)Ú
desktop_ui)ÚregistryÚ
tool_error)ÚtargetsÚshowÚstartÚnextÚprevÚstop)ÚappÚpreview)ÚtopÚrightÚbottomÚleftÚactionÚsurfaceÚselectorÚtitleÚtextÚsideÚstepsÚ
step_indexÚcallbackÚreturnc	           	      ó¬  — |€t        d«      S | xs dj                  «       j                  «       }	|	t        vr"t        ddj	                  t        «      › d�«      S |xs dj                  «       j                  «       }
|
t
        vr"t        ddj	                  t
        «      › d�«      S |�*|t        vr"t        d	dj	                  t        «      › d�«      S |	d
k(  r|s|s|st        d«      S |	dk(  r—t        |t        «      r|st        d«      S t        |«      D ]l  \  }}t        |t        «      st        d|› d�«      c S |j                  d«      rŒ9|j                  d«      rŒK|j                  d«      rŒ]t        d|› d�«      c S  |	|
||||||dœ}	  ||j                  «       D ��ci c]  \  }}|€Œ	||“Œ c}}«      }|st        d«      S 	 t        j                  t        j                   |«      d¬«      S c c}}w # t        $ r}t        d|› �«      cY d}~S d}~ww xY w# t"        t$        f$ r% t        j                  dt'        |«      id¬«      cY S w xY w)zHDispatch one tour action to the desktop renderer and return its outcome.Nz1tour is only available in the Hermes desktop app.Ú zaction must be one of: z, ú.r   zsurface must be one of: zside must be one of: r	   z:show needs a selector (and/or title/text for the popover).r
   z$start needs a non-empty steps array.zsteps[z] must be an object.r   r   r   z%] needs a selector and/or title/text.©r   r   r   r   r   r   r   r   zTour action failed: zsThe tour request timed out, or no GUI window answered. For surface='preview' open a page in the preview pane first.F)Úensure_ascii)r   ÚstripÚlowerÚACTIONSÚjoinÚSURFACESÚSIDESÚ
isinstanceÚlistÚ	enumerateÚdictÚgetÚitemsÚ	ExceptionÚjsonÚdumpsÚloadsÚ	TypeErrorÚ
ValueErrorÚstr)r   r   r   r   r   r   r   r   r   ÚverbÚwhereÚiÚstepÚfieldsÚkeyÚvalÚrawÚexcs                     ú4/home/ubuntu/.hermes/hermes-agent/tools/tour_tool.pyÚ	tour_toolr@      sJ  € ð
 ÐÜÐMÓNÐNØŠL�b×ÑÓ!×'Ñ'Ó)€DØ”7ÑÜÐ3°D·I±I¼gÓ4FÐ3GÀqÐIÓJÐJØÒ˜×$Ñ$Ó&×,Ñ,Ó.€EØ”HÑÜÐ4°T·Y±Y¼xÓ5HÐ4IÈÐKÓLÐLØÐ˜D¬Ñ-ÜÐ1°$·)±)¼EÓ2BÐ1CÀ1ÐEÓFÐFàˆv‚~™x©5±DÜÐVÓWÐWØˆw‚Ü˜%¤Ô&©eÜÐDÓEÐEÜ  Ó'ò 	U‰GˆAˆtÜ˜d¤DÔ)Ü! F¨1¨#Ð-AÐ"BÓCÒCØ—H‘H˜ZÕ(¨D¯H©H°WÕ,=ÀÇÁÈ&ÕAQÜ! F¨1¨#Ð-RÐ"SÓTÒTð		Uð
 ¨¸HÈuØ D°5È
ñT€Fð8Ù°·±³×S¡X S¨#À3Á?˜˜S™ÓSÓTˆñ Üð Yó Zð 	ZðBÜ�z‰zœ$Ÿ*™* S›/¸Ô>Ð>ùó TøÜò 8ÜÐ0°°Ð6Ó7Õ7ûð8ûô ”zÐ"ò BÜ�z‰z˜6¤3 s£8Ð,¸5ÔAÒAðBúsH   ÆG; Æ%
G5
Æ0G5
Æ5G; Ç)H Ç5G; Ç;	HÈHÈHÈHÈ1IÉIÚobjectÚstringz0Element to highlight; omit = centered narration.)ÚtypeÚdescriptionzPopover title.zPopover body.z!Popover side; omit to auto-place.)rC   ÚenumrD   )r   r   r   r   )rC   Ú
propertiesÚgui_touruE  Guided tour in the desktop GUI: dim the screen, highlight an element, attach a titled popover. Surfaces: 'app' (Hermes itself) or 'preview' (the page in the preview pane). ALWAYS call action='targets' first â€” prefer targets marked stable:true (their selectors survive re-renders); re-scan if one stops matching. Then narrate with action='show' (one highlight per call, replaces the last â€” pair each with a chat message) or hand over with action='start' + steps (user gets Next/Prev; 'next'/'prev' also page it). 'stop' clears. Use for how-does-X-work / where-is-Y walkthroughs.z/targets first; show narrates; start hands over.z'app' (default) or 'preview'.zGshow: selector from targets (prefer stable). Omit = centered narration.zshow: popover title.zshow: popover body.z'show: popover side; omit to auto-place.Úarrayzstart: ordered steps.)rC   r.   rD   Úintegerzstart: 0-indexed first step.r!   )rC   rF   Úrequired)ÚnamerD   Ú
parametersc                  ó0   — t        j                  dd¬«      S )uH   The user's Settings â†’ Appearance switch. On unless they turned it off.Úin_app_toursT)Údefault)r   Úuser_enabled© ó    r?   Úcheck_tours_enabledrS   †   s   € ä×"Ñ" >¸4Ô@Ð@rR   r   c                 ó¢   — t        d| j                  dd«      |j                  d«      dœdD �ci c]  }|| j                  |«      “Œ c}¤ŽS c c}w )Nr   r   r   )r   r   )r   r   r   r   r   r   r   rQ   )r@   r-   )ÚargsÚkwÚks      r?   ú<lambda>rX   �   sS   € œyð  4Ø�x‰x˜ "Ó%°·±°zÓ0Bñ 4ð$2ö 3˜aˆ1ˆd�h‰h�q‹k‰>ò 3ñ 4€ ùò3s   ®Au   ðŸ§­)rK   ÚtoolsetÚschemaÚcheck_fnÚhandlerÚemoji)	r   NNNNNNNN)Ú__doc__r0   Útypingr   r   Útoolsr   Útools.registryr   r   r%   r'   r(   r5   r*   Úintr@   Ú_STEP_SCHEMAÚTOUR_SCHEMAÚboolrS   ÚregisterrQ   rR   r?   ú<module>rg      sÖ  ðñ\ó ß %å ß /à
>€Ø€Ø*€ð Z^Ø]aØHLØ-1ñ'B�cð 'B¨°#©ð 'BÈÐRUÉð 'BØ˜c‘]ð'BØ19¸#±ð'BØMUÐVYÉ]ð'Bà˜d‘^ð'Bà8@À¹ð'Bð ! Ñ*ð'Bð 7:ó'BðV ð ØMñ
ð #Ð3CÑDØ!°/ÑBàÙ˜“KØ>ñ
ññ€ð$ ð
		ð ð !Ù˜W›ØPñð !Ù˜X›Ø>ñð !Øhñð 'Ð7MÑNØ%Ð6KÑLà Ù˜U›ØHñð  Ø%Ø6ñð "Ø=ññ7
ð@ �JñE#ñ#5€ðpA˜Tó Að
 €× Ñ Ø	˜\°+ÐH[ñ4ð örR   