bash.py 1000 B

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