mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
* Add errors for non-unicode file data or command return, trim excessively long command returns. * Fix lint issue. * Fix lint issue (try 2). * Realized that prompts were trimmed elsewhere and dropped the new addition.
37 lines
1004 B
Python
37 lines
1004 B
Python
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, Observation
|
|
|
|
|
|
@dataclass
|
|
class CmdRunAction(ExecutableAction):
|
|
command: str
|
|
background: bool = False
|
|
action: str = ActionType.RUN
|
|
|
|
async def run(self, controller: 'AgentController') -> 'Observation':
|
|
return controller.action_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
|
|
|
|
async def run(self, controller: 'AgentController') -> 'CmdOutputObservation':
|
|
return controller.action_manager.kill_command(self.id)
|
|
|
|
@property
|
|
def message(self) -> str:
|
|
return f'Killing command: {self.id}'
|