
    dhV                         S SK r S SKrS SKrS SKJrJrJrJrJr  S SK	J
r
  S SKJr  S SKJrJrJr  \ R"                  " \5      r " S S\5      rS\4S	 jrS\4S
 jr " S S\5      rg)    N)AnyListOptionalTypeUnion)CallbackManagerForToolRun)BaseTool)	BaseModelFieldmodel_validatorc                   r    \ rS rSr% Sr\" SSS9r\\\	\   4   \
S'    \" SS9\S	\S
\4S j5       5       rSrg)
ShellInput   z!Commands for the Bash Shell tool..z<List of shell commands to run. Deserialized using json.loads)descriptioncommandsbefore)modevaluesreturnc                     UR                  S5      n[        U[        5      (       d  U/US'   [        R                  " S5        U$ )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/shao/venv/lib/python3.13/site-packages/langchain_community/tools/shell/tool.py_validate_commandsShellInput._validate_commands   sA    
 ::j)(D))"*F:P	
      N)__name__
__module____qualname____firstlineno____doc__r   r   r   strr   __annotations__r   classmethoddictr   r   __static_attributes__r!   r    r   r   r      s[    +&+R'HeCcN#  )(#
 
 
  $
r    r   r   c                  N     SSK Jn   U " SS9$ ! [         a    [        S5      ef = f)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_processr2   '   s:    
D ..  
9
 	

s    $c                  >    [         R                  " 5       n U S:X  a  gU $ )zGet platform.DarwinMacOS)platformsystem)r7   s    r   _get_platformr8   4   s    __FMr    c                       \ rS rSr% Sr\" \S9r\\	S'    Sr
\\	S'    S\" 5        S3r\\	S	'    \r\\   \	S
'    Sr\\	S'     SS\\\\   4   S\\   S\4S jjrSrg)	ShellTool<   z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                 v   [        SU 35         U R                  (       aP  [        S5      R                  5       nUS:X  a  U R                  R                  U5      $ [        R                  S5        gU R                  R                  U5      $ ! [         a"  n[        R                  SU 35         SnAgSnAff = f)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: )
printrA   inputlowerr=   runloggerinfo	Exceptionerror)selfr   rB   
user_inputes        r   _runShellTool._runQ   s     	%hZ01	##"#LMSSU
$<<++H55KK PQ||''11 	LL;A3?@	s$   A
B B 1B 
B8B33B8r!   )N)r"   r#   r$   r%   r&   r   r2   r=   r   r(   r?   r'   r8   r   r   r@   r   r
   rA   boolr   r   r   r   rP   r+   r!   r    r   r:   r:   <   s    %)BCGSC'D#4]_4EYOKO#-Ki-%!OT! <@T#Y' 78 
	 r    r:   )loggingr6   r   typingr   r   r   r   r   langchain_core.callbacksr   langchain_core.toolsr	   pydanticr
   r   r   	getLoggerr"   rI   r   r2   r'   r8   r:   r!   r    r   <module>rY      sd       3 3 * 6 6			8	$ 0
/3 
/s + +r    