|
|
@@ -1,7 +1,7 @@
|
|
|
from typing import List
|
|
|
|
|
|
from opendevin import config
|
|
|
-from opendevin.observation import CmdOutputObservation
|
|
|
+from opendevin.observation import CmdOutputObservation, AgentErrorObservation
|
|
|
from opendevin.sandbox import DockerExecBox, DockerSSHBox, Sandbox, LocalBox, E2BBox
|
|
|
from opendevin.schema import ConfigType
|
|
|
from opendevin.action import (
|
|
|
@@ -54,17 +54,20 @@ class ActionManager:
|
|
|
observation = await action.run(agent_controller)
|
|
|
return observation
|
|
|
|
|
|
- def run_command(self, command: str, background=False) -> CmdOutputObservation:
|
|
|
+ def run_command(self, command: str, background=False) -> Observation:
|
|
|
if background:
|
|
|
return self._run_background(command)
|
|
|
else:
|
|
|
return self._run_immediately(command)
|
|
|
|
|
|
- def _run_immediately(self, command: str) -> CmdOutputObservation:
|
|
|
- exit_code, output = self.sandbox.execute(command)
|
|
|
- return CmdOutputObservation(
|
|
|
- command_id=-1, content=output, command=command, exit_code=exit_code
|
|
|
- )
|
|
|
+ def _run_immediately(self, command: str) -> Observation:
|
|
|
+ try:
|
|
|
+ exit_code, output = self.sandbox.execute(command)
|
|
|
+ return CmdOutputObservation(
|
|
|
+ command_id=-1, content=output, command=command, exit_code=exit_code
|
|
|
+ )
|
|
|
+ except UnicodeDecodeError:
|
|
|
+ return AgentErrorObservation('Command output could not be decoded as utf-8')
|
|
|
|
|
|
def _run_background(self, command: str) -> CmdOutputObservation:
|
|
|
bg_cmd = self.sandbox.execute_in_background(command)
|