sandbox.py 876 B

123456789101112131415161718192021222324252627282930313233
  1. import copy
  2. from abc import ABC, abstractmethod
  3. from opendevin.core.config import SandboxConfig
  4. from opendevin.core.schema import CancellableStream
  5. from opendevin.runtime.plugins.mixin import PluginMixin
  6. class Sandbox(ABC, PluginMixin):
  7. _env: dict[str, str] = {}
  8. is_initial_session: bool = True
  9. def __init__(self, config: SandboxConfig):
  10. self.config = copy.deepcopy(config)
  11. self.initialize_plugins: bool = config.initialize_plugins
  12. @abstractmethod
  13. def execute(
  14. self, cmd: str, stream: bool = False, timeout: int | None = None
  15. ) -> tuple[int, str | CancellableStream]:
  16. pass
  17. @abstractmethod
  18. def close(self):
  19. pass
  20. @abstractmethod
  21. def copy_to(self, host_src: str, sandbox_dest: str, recursive: bool = False):
  22. pass
  23. @abstractmethod
  24. def get_working_directory(self):
  25. pass