
    3fi                    >   U d dl mZ d dlmZmZmZmZmZ d dlm	Z	m
Z
 d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ eeeeeeegZded<   eD  ci c]  }  e|       d   j>                  |  c} Z ded<    G d de
      Z!dgZ"yc c} w )    )annotations)AnyDictListOptionalType)BaseToolBaseToolkit)
get_fields)model_validator)CopyFileTool)DeleteFileTool)FileSearchTool)ListDirectoryTool)MoveFileTool)ReadFileTool)WriteFileToolzList[Type[BaseTool]]_FILE_TOOLSnamezDict[str, Type[BaseTool]]_FILE_TOOLS_MAPc                  d    e Zd ZU dZdZded<   	 dZded<   	  ed      edd	              Z	dd
Z
y)FileManagementToolkita;  Toolkit for interacting with local files.

    *Security Notice*: This toolkit provides methods to interact with local files.
        If providing this toolkit to an agent on an LLM, ensure you scope
        the agent's permissions to only include the necessary permissions
        to perform the desired operations.

        By **default** the agent will have access to all files within
        the root dir and will be able to Copy, Delete, Move, Read, Write
        and List files in that directory.

        Consider the following:
        - Limit access to particular directories using `root_dir`.
        - Use filesystem permissions to restrict access and permissions to only
          the files and directories required by the agent.
        - Limit the tools available to the agent to only the file operations
          necessary for the agent's intended use.
        - Sandbox the agent by running it in a container.

        See https://python.langchain.com/docs/security for more information.

    Parameters:
        root_dir: Optional. The root directory to perform file operations.
            If not provided, file operations are performed relative to the current
            working directory.
        selected_tools: Optional. The tools to include in the toolkit. If not
            provided, all tools are included.
    NzOptional[str]root_dirzOptional[List[str]]selected_toolsbefore)modec           	         |j                  d      xs g }|D ](  }|t        vst        d| dt        t                      |S )Nr   zFile Tool of name z! not supported. Permitted tools: )getr   
ValueErrorlist)clsvaluesr   	tool_names       x/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/langchain_community/agent_toolkits/file_management/toolkit.pyvalidate_toolsz$FileManagementToolkit.validate_toolsB   s`      $45;' 	I/ ( 4))-o)>(?A 	     c                    | j                   xs t        }g }|D ]-  }t        |   }|j                   || j                               / |S )zGet the tools in the toolkit.)r   )r   r   appendr   )selfallowed_toolstoolstooltool_clss        r$   	get_toolszFileManagementToolkit.get_toolsN   sL    ++> "! 	;D&t,HLL4==9:	; r&   )r"   dictreturnr   )r0   zList[BaseTool])__name__
__module____qualname____doc__r   __annotations__r   r   classmethodr%   r.    r&   r$   r   r      sH    : #Hm"J*.N'.H(#  $r&   r   N)#
__future__r   typingr   r   r   r   r   langchain_core.toolsr	   r
   langchain_core.utils.pydanticr   pydanticr   .langchain_community.tools.file_management.copyr   0langchain_community.tools.file_management.deleter   5langchain_community.tools.file_management.file_searchr   2langchain_community.tools.file_management.list_dirr   .langchain_community.tools.file_management.mover   .langchain_community.tools.file_management.readr   /langchain_community.tools.file_management.writer   r   r5   defaultr   r   __all__)r-   s   0r$   <module>rF      s    " 2 2 6 4 $ G K P P G G I %!  DO.7?Jx (((2.* 
6K 6r #
#}.s   &B