fix : go interpreter error, hf provider import + feat : more logger

This commit is contained in:
martin legrand
2025-04-27 20:37:23 +02:00
parent f02f096356
commit 5517f53f8a
14 changed files with 84 additions and 34 deletions
+4 -3
View File
@@ -25,13 +25,13 @@ class BashInterpreter(Tools):
If so, return True, otherwise return False.
Code written by the AI will be executed automatically, so it should not use bash to run it.
"""
lang_interpreter = ["python3", "gcc", "g++", "mvn", "go", "javac", "rustc", "clang", "clang++", "rustc", "rustc++", "rustc++"]
lang_interpreter = ["python", "gcc", "g++", "mvn", "go", "java", "javac", "rustc", "clang", "clang++", "rustc", "rustc++", "rustc++"]
for word in command.split():
if word in lang_interpreter:
if any(word.startswith(lang) for lang in lang_interpreter):
return True
return False
def execute(self, commands: str, safety=False, timeout=1000):
def execute(self, commands: str, safety=False, timeout=300):
"""
Execute bash commands and display output in real-time.
"""
@@ -43,6 +43,7 @@ class BashInterpreter(Tools):
command = f"cd {self.work_dir} && {command}"
command = command.replace('\n', '')
if self.safe_mode and is_unsafe(commands):
print(f"Unsafe command rejected: {command}")
return "Unsafe command detected, execution aborted."
if self.language_bash_attempt(command) and self.allow_language_exec_bash == False:
continue
+4 -1
View File
@@ -33,12 +33,15 @@ class GoInterpreter(Tools):
f.write(code)
try:
env = os.environ.copy()
env["GO111MODULE"] = "off"
compile_command = ["go", "build", "-o", exec_file, source_file]
compile_result = subprocess.run(
compile_command,
capture_output=True,
text=True,
timeout=10
timeout=10,
env=env
)
if compile_result.returncode != 0:
+2
View File
@@ -93,6 +93,7 @@ class FileFinder(Tools):
return output
if action is None:
action = "info"
print("File finder: recursive search started...")
file_path = self.recursive_search(self.work_dir, filename)
if file_path is None:
output = f"File: {filename} - not found\n"
@@ -143,6 +144,7 @@ class FileFinder(Tools):
return feedback.strip()
if __name__ == "__main__":
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
tool = FileFinder()
result = tool.execute(["""
action=read
+1 -1
View File
@@ -10,7 +10,7 @@ else:
class MCP_finder(Tools):
"""
Tool
Tool to find MCPs server
"""
def __init__(self, api_key: str = None):
super().__init__()
+2 -1
View File
@@ -20,6 +20,7 @@ unsafe_commands_unix = [
"passwd", # Password changes
"useradd", # Add users
"userdel", # Delete users
"brew", # Homebrew package manager
"groupadd", # Add groups
"groupdel", # Delete groups
"visudo", # Edit sudoers file
@@ -30,7 +31,7 @@ unsafe_commands_unix = [
"route" # Routing table management
"--force", # Force flag for many commands
"rebase", # Rebase git repository
"git ." # Git commands, feel free to remove it but i dont want to risk agenticSeek pushing to its own repo lol (see 56b5db7)
"git ." # Git commands
]
unsafe_commands_windows = [
-2
View File
@@ -23,8 +23,6 @@ import configparser
from abc import abstractmethod
from sources.logger import Logger
sys.path.append('..')
class Tools():
"""
Abstract class for all tools.