
    Ngz                         d dl Z d dlZd dlZd dlmZmZmZmZmZ d dl	m
Z
 d dlmZ d dlmZmZmZ  e j        e          Z G d de          Zdefd	Zdefd
Z G d de          ZdS )    N)AnyListOptionalTypeUnion)CallbackManagerForToolRun)BaseTool)	BaseModelFieldmodel_validatorc                       e Zd ZU dZ edd          Zeeee         f         e	d<   	  e
d          eded	efd
                        ZdS )
ShellInputz!Commands for the Bash Shell tool..z<List of shell commands to run. Deserialized using json.loads)descriptioncommandsbefore)modevaluesreturnc                     |                     d          }t          |t                    s|g|d<   t          j        d           |S )zValidate commands.r   zBThe shell tool has no safeguards by default. Use at your own risk.)get
isinstancelistwarningswarn)clsr   r   s      `/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain_community/tools/shell/tool.py_validate_commandszShellInput._validate_commands   sQ    
 ::j))(D)) 	,"*F:P	
 	
 	
     N)__name__
__module____qualname____doc__r   r   r   strr   __annotations__r   classmethoddictr   r    r   r   r   r      s         ++&+eR' ' 'HeCcN#    )_(###
 
 
 
 
 [ $#
 
 
r   r   r   c                  d    	 ddl m}  n# t          $ r t          d          w xY w | d          S )zGet default bash process.r   BashProcesszBashProcess has been moved to langchain experimental.To use this tool, install langchain-experimental with `pip install langchain-experimental`.T)return_err_output)$langchain_experimental.llm_bash.bashr*   ImportErrorr)   s    r   _get_default_bash_processr.   '   sc    
DDDDDDD 
 
 
9
 
 	

 ;....s   	 #c                  <    t          j                    } | dk    rdS | S )zGet platform.DarwinMacOS)platformsystem)r3   s    r   _get_platformr4   4   s$    _FwMr   c                       e Zd ZU dZ ee          Zeed<   	 dZ	e
ed<   	 d e             dZe
ed<   	 eZee         ed	<   	 d
Zeed<   	 	 ddee
ee
         f         dee         de
fdZdS )	ShellToolzTool to run shell commands.)default_factoryprocessterminalnamezRun shell commands on this z	 machine.r   args_schemaFask_human_inputNr   run_managerr   c                    t          d|            	 | j        r]t          d                                          }|dk    r| j                            |          S t                              d           dS | j                            |          S # t          $ r(}t          	                    d|            Y d}~dS d}~ww xY w)z%Run commands and return final output.zExecuting command:
 z'Proceed with command execution? (y/n): yz.Invalid input. User aborted command execution.Nz Error during command execution: )
printr<   inputlowerr8   runloggerinfo	Exceptionerror)selfr   r=   
user_inputes        r   _runzShellTool._runQ   s     	0h00111	# 2"#LMMSSUU
$$<++H555KK PQQQ4|''111 	 	 	LL?A??@@@44444	s$   AB B 8B 
CB??C)N)r   r    r!   r"   r   r.   r8   r   r$   r:   r#   r4   r   r   r;   r   r
   r<   boolr   r   r   r   rK   r'   r   r   r6   r6   <   s         %%5)BCCCGSCCC'D#O]]__OOOKOOO#-Ki---%!OT!!! <@ T#Y' 78 
	     r   r6   )loggingr2   r   typingr   r   r   r   r   langchain_core.callbacksr   langchain_core.toolsr	   pydanticr
   r   r   	getLoggerr   rD   r   r.   r#   r4   r6   r'   r   r   <module>rS      s@      3 3 3 3 3 3 3 3 3 3 3 3 3 3      * ) ) ) ) ) 6 6 6 6 6 6 6 6 6 6		8	$	$       0
/3 
/ 
/ 
/ 
/s    + + + + + + + + + +r   