|
|
|
@ -25,6 +25,24 @@ from swarms.utils.logger import logger
|
|
|
|
|
from swarms.utils.main import ANSI, Color, Style # test
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#helpers
|
|
|
|
|
PipeType = Union[Literal["stdout"], Literal["stderr"]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def verify(func):
|
|
|
|
|
def wrapper(*args, **kwargs):
|
|
|
|
|
try:
|
|
|
|
|
filepath = args[0].filepath
|
|
|
|
|
except AttributeError:
|
|
|
|
|
raise Exception("This tool doesn't have filepath. Please check your code.")
|
|
|
|
|
if not str(Path(filepath).resolve()).startswith(str(Path().resolve())):
|
|
|
|
|
return "You can't access file outside of playground."
|
|
|
|
|
return func(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
return wrapper
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SyscallTimeoutException(Exception):
|
|
|
|
|
def __init__(self, pid: int, *args) -> None:
|
|
|
|
|
super().__init__(f"deadline exceeded while waiting syscall for {pid}", *args)
|
|
|
|
@ -114,7 +132,6 @@ class SyscallTracer:
|
|
|
|
|
return exitcode, reason
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PipeType = Union[Literal["stdout"], Literal["stderr"]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class StdoutTracer:
|
|
|
|
@ -224,19 +241,6 @@ class Terminal(BaseToolSet):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def verify(func):
|
|
|
|
|
def wrapper(*args, **kwargs):
|
|
|
|
|
try:
|
|
|
|
|
filepath = args[0].filepath
|
|
|
|
|
except AttributeError:
|
|
|
|
|
raise Exception("This tool doesn't have filepath. Please check your code.")
|
|
|
|
|
if not str(Path(filepath).resolve()).startswith(str(Path().resolve())):
|
|
|
|
|
return "You can't access file outside of playground."
|
|
|
|
|
return func(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
return wrapper
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
write protocol:
|
|
|
|
|