bash.py 930 B

12345678910111213141516171819202122232425262728293031323334
  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. action: str = "run"
  12. def run(self, controller: "AgentController") -> "CmdOutputObservation":
  13. return controller.command_manager.run_command(self.command, self.background)
  14. @property
  15. def message(self) -> str:
  16. return f"Running command: {self.command}"
  17. @dataclass
  18. class CmdKillAction(ExecutableAction):
  19. id: int
  20. action: str = "kill"
  21. def run(self, controller: "AgentController") -> "CmdOutputObservation":
  22. return controller.command_manager.kill_command(self.id)
  23. @property
  24. def message(self) -> str:
  25. return f"Killing command: {self.id}"