
    Ng                        d dl mZ d dlmZmZ d dlmZ d dlmZm	Z	 d dl
mZmZmZ d dlmZ d dlmZmZ  G d d	e          Z G d
 de          ZdS )    )annotations)OptionalType)urlparse)AsyncCallbackManagerForToolRunCallbackManagerForToolRun)	BaseModelFieldmodel_validator)BaseBrowserTool)aget_current_pageget_current_pagec                  t    e Zd ZU dZ edd          Zded<    ed          edd                        Z	dS )NavigateToolInputzInput for NavigateToolInput..zurl to navigate to)descriptionstrurlbefore)modevaluesdictreturnc                ~    |                     d          }t          |          }|j        dvrt          d          |S )z#Check that the URL scheme is valid.r   )httphttpsz$URL scheme must be 'http' or 'https')getr   scheme
ValueError)clsr   r   
parsed_urls       i/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain_community/tools/playwright/navigate.pyvalidate_url_schemez%NavigateToolInput.validate_url_scheme   sC     jjc]]
$555CDDD    N)r   r   r   r   )
__name__
__module____qualname____doc__r
   r   __annotations__r   classmethodr"    r#   r!   r   r      ss         &&uS&:;;;C;;;;_(###   [ $#  r#   r   c                  V    e Zd ZU dZdZded<   dZded<   eZded<   	 dddZ		 dddZ
d	S )NavigateToola  Tool for navigating a browser to a URL.

    **Security Note**: This tool provides code to control web-browser navigation.

        This tool can navigate to any URL, including internal network URLs, and
        URLs exposed on the server itself.

        However, if exposing this tool to end-users, consider limiting network
        access to the server that hosts the agent.

        By default, the URL scheme has been limited to 'http' and 'https' to
        prevent navigation to local file system URLs (or other schemes).

        If access to the local file system is required, consider creating a custom
        tool or providing a custom args_schema that allows the desired URL schemes.

        See https://python.langchain.com/docs/security for more information.
    navigate_browserr   namez'Navigate a browser to the specified URLr   zType[BaseModel]args_schemaNr   run_manager#Optional[CallbackManagerForToolRun]r   c                    | j         t          d| j                   t          | j                   }|                    |          }|r|j        nd}d| d| S )Use the tool.Nz$Synchronous browser not provided to unknownNavigating to  returned status code )sync_browserr   r.   r   gotostatusselfr   r0   pageresponser9   s         r!   _runzNavigateTool._run;   sk     $ODIOOPPP 12299S>>$,;)CCC6CCCr#   (Optional[AsyncCallbackManagerForToolRun]c                   K   | j         t          d| j                   t          | j                    d{V }|                    |           d{V }|r|j        nd}d| d| S )r3   Nz%Asynchronous browser not provided to r4   r5   r6   )async_browserr   r.   r   r8   r9   r:   s         r!   _arunzNavigateTool._arunH   s       %PTYPPQQQ&t'9::::::::3''''''$,;)CCC6CCCr#   )N)r   r   r0   r1   r   r   )r   r   r0   r?   r   r   )r$   r%   r&   r'   r.   r(   r   r   r/   r>   rB   r*   r#   r!   r,   r,   #   s          & #D""""@K@@@@#4K4444
 <@D D D D D  AED D D D D D Dr#   r,   N)
__future__r   typingr   r   urllib.parser   langchain_core.callbacksr   r   pydanticr	   r
   r   )langchain_community.tools.playwright.baser   *langchain_community.tools.playwright.utilsr   r   r   r,   r*   r#   r!   <module>rJ      s+   " " " " " " ! ! ! ! ! ! ! ! ! ! ! ! ! !        7 6 6 6 6 6 6 6 6 6 E E E E E E           	    0D 0D 0D 0D 0D? 0D 0D 0D 0D 0Dr#   