forked from All-Hands-AI/OpenHands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash.py
36 lines (26 loc) · 990 Bytes
/
bash.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from dataclasses import dataclass
from typing import TYPE_CHECKING
from .base import ExecutableAction
from opendevin.schema import ActionType
if TYPE_CHECKING:
from opendevin.controller import AgentController
from opendevin.observation import CmdOutputObservation
@dataclass
class CmdRunAction(ExecutableAction):
command: str
background: bool = False
action: str = ActionType.RUN
def run(self, controller: "AgentController") -> "CmdOutputObservation":
return controller.command_manager.run_command(self.command, self.background)
@property
def message(self) -> str:
return f"Running command: {self.command}"
@dataclass
class CmdKillAction(ExecutableAction):
id: int
action: str = ActionType.KILL
def run(self, controller: "AgentController") -> "CmdOutputObservation":
return controller.command_manager.kill_command(self.id)
@property
def message(self) -> str:
return f"Killing command: {self.id}"