Ë
    ãß²j  ã                   óŒ   — d Z ddlZddlmZ ddlmZ dedefd„Zdded	edefd
„Zddl	Z	ddddddœdddœdœdgdœdœZ
ddiZd„ Zy)aX  Open a URL, dev server, or file in the Hermes desktop GUI's preview pane.

Registration lives in the `desktop_preview` tool (``tools.preview_tool``); this module keeps
the normalizer + open action. Emits ``preview.open`` via ``desktop_ui``: the renderer opens
the pane for the window that asked and never steals focus for a background session.
é    N)Ú
desktop_ui)Ú
tool_errorÚrawÚreturnc                 ó:  — | j                  «       j                  d«      j                  «       }|rd|v s|j                  d«      r|S t        j                  d|t        j                  «      rd|z   S t        j                  d|t        j                  «      rd|z   S |S )a	  Coax a bare host/domain into a fetchable URL; leave paths + schemes alone.

    ``www.cnn.com`` -> ``https://www.cnn.com``; ``localhost:3000`` -> ``http://localhost:3000``.
    File paths and explicit schemes pass through for the renderer's preview normalizer.
    ú`z://)ú/z./z../Ú~zfile:z8^(localhost|127\.0\.0\.1|0\.0\.0\.0|\[::1\])(:\d+)?(/|$)zhttp://z!^[\w.-]+\.[a-z]{2,}(:\d+)?(/.*)?$zhttps://)ÚstripÚ
startswithÚreÚmatchÚI)r   Úvs     ú</home/ubuntu/.hermes/hermes-agent/tools/open_preview_tool.pyÚ_normalize_targetr      sƒ   € ð 	�	‰	‹×Ñ˜#Ó×$Ñ$Ó&€AÙ�˜‘
˜aŸl™lÐ+KÔLØˆÜ	‡x�xÐKÈQÔPR×PTÑPTÔUØ˜1‰}ÐÜ	‡x�xÐ4°a¼¿¹Ô>Ø˜A‰~ÐØ€Hó    ÚurlÚlabelc           
      ó¢   — t        | xs d«      }|st        d«      S |xs dj                  «       }t        j                  d||dœddd||dœ«      S )	zHAsk the desktop GUI to show ``url`` in the preview pane beside the chat.Ú up   url is required â€” a web URL (https://â€¦), a localhost dev server, or a file path to show in the preview pane.zpreview.open©r   r   z!Failed to open the preview pane: z=The preview pane is only available in the Hermes desktop app.T)Úsuccessr   r   )r   r   r   r   Úemit_or_error)r   r   Útargets      r   Úopen_preview_toolr      sg   € ä˜sšy bÓ)€FÙÜð5ó6ð 	6ð Š[�b×ÑÓ!€EÜ×#Ñ#ØØ Ñ'Ø+ØGØ °%Ñ8ó:ð :r   Úopen_previewuá  Open something in the preview pane beside the chat in the Hermes desktop app. Use this when the user asks to see a page, dev server, or file in the preview pane â€” e.g. "open cnn.com in the preview pane" or "preview localhost:3000". Accepts a web URL (a bare domain like www.cnn.com is fine), a localhost dev-server URL, or a file path (HTML renders live; other files show their contents). The pane opens for the current window only. To close the pane or a tab, use close_preview.ÚobjectÚstringul   What to preview: a web URL (https://â€¦ or a bare domain), a localhost URL (localhost:3000), or a file path.)ÚtypeÚdescriptionz2Optional tab label; defaults to the target's name.r   )r    Ú
propertiesÚrequired)Únamer!   Ú
parametersÚregistry)ztools.registryr&   c                 óÌ   — t         j                  | «      }|€t        dt        ›d| ›�«      ‚dd l}ddlm}  |t        | g|¢­Ž  t        |j                  |d   «      |d   «      S )Nzmodule z has no attribute r   )Ú	warn_onceé   )	Ú_PLUGIN_COMPAT_LAZYÚgetÚAttributeErrorÚ__name__Ú	importlibÚhermes_cli.plugin_compatr(   ÚgetattrÚimport_module)r$   r   r.   r(   s       r   Ú__getattr__r2   Y   se   € Ü ×$Ñ$ TÓ*€FØ€~Ü˜w¤x lÐ2DÀTÀHÐMÓNÐNÛÝ2ÙŒh˜Ð&˜vÓ&Ü�9×*Ñ*¨6°!©9Ó5°v¸a±yÓAÐAr   )r   )Ú__doc__r   Útoolsr   Útools.registryr   Ústrr   r   ÚjsonÚOPEN_PREVIEW_SCHEMAr*   r2   © r   r   ú<module>r:      s£   ðñó 
å Ý %ð˜3ð  3ó ñ :˜3ð : sð :°Có :ó( ð ð	0ð ð !ðFñð !ØSññ
ð �GññÐ ð@ Ð.ðÐ ó
Br   