bash.py 882 B

1234567891011121314151617181920212223242526272829303132
  1. from dataclasses import dataclass
  2. from typing import TYPE_CHECKING
  3. from .base import ExecutableAction
  4. if TYPE_CHECKING:
  5. from opendevin.controller import AgentController
  6. from opendevin.observation import CmdOutputObservation
  7. @dataclass
  8. class CmdRunAction(ExecutableAction):
  9. command: str
  10. background: bool = False
  11. def run(self, controller: "AgentController") -> "CmdOutputObservation":
  12. return controller.command_manager.run_command(self.command, self.background)
  13. @property
  14. def message(self) -> str:
  15. return f"Running command: {self.command}"
  16. @dataclass
  17. class CmdKillAction(ExecutableAction):
  18. id: int
  19. def run(self, controller: "AgentController") -> "CmdOutputObservation":
  20. return controller.command_manager.kill_command(self.id)
  21. @property
  22. def message(self) -> str:
  23. return f"Killing command: {self.id}"