π OpenHands: AI-Driven Development
Ruff: use I rule for isort (#1410)
Jirka Borovec0c2ebfd6e11c
diff --git a/agenthub/SWE_agent/__init__.py b/agenthub/SWE_agent/__init__.pyindex 8f0f418a72..58e5f72038 100644--- a/agenthub/SWE_agent/__init__.py+++ b/agenthub/SWE_agent/__init__.py@@ -1,4 +1,5 @@from opendevin.agent import Agent+from .agent import SWEAgentAgent.register('SWEAgent', SWEAgent)diff --git a/agenthub/SWE_agent/agent.py b/agenthub/SWE_agent/agent.pyindex 80e443f98b..808063eaff 100644--- a/agenthub/SWE_agent/agent.py+++ b/agenthub/SWE_agent/agent.py@@ -1,23 +1,23 @@from typing import List-from opendevin.agent import Agent-from opendevin.llm.llm import LLM-from opendevin.state import State+from opendevin.action import (Action,AgentThinkAction,FileReadAction,FileWriteAction,)+from opendevin.agent import Agent+from opendevin.llm.llm import LLMfrom opendevin.observation import Observation+from opendevin.state import Statefrom .parser import parse_command-from .prompts import (- SYSTEM_MESSAGE,- STEP_PROMPT,+ CONTEXT_PROMPT,MEMORY_FORMAT,NO_ACTION,- CONTEXT_PROMPT+ STEP_PROMPT,+ SYSTEM_MESSAGE,)diff --git a/agenthub/SWE_agent/parser.py b/agenthub/SWE_agent/parser.pyindex 3a8ca180b5..d4600291ef 100644--- a/agenthub/SWE_agent/parser.py+++ b/agenthub/SWE_agent/parser.py@@ -1,17 +1,17 @@+import re+from opendevin.action import (Action,+ AgentEchoAction,AgentFinishAction,+ AgentThinkAction,+ BrowseURLAction,CmdRunAction,FileReadAction,FileWriteAction,- BrowseURLAction,- AgentEchoAction,- AgentThinkAction,)-import re--from .prompts import CUSTOM_DOCS, COMMAND_USAGE+from .prompts import COMMAND_USAGE, CUSTOM_DOCS# commands: exit, read, write, browse, kill, search_file, search_dirdiff --git a/agenthub/__init__.py b/agenthub/__init__.pyindex c39cfa3b6f..74b457793d 100644--- a/agenthub/__init__.py+++ b/agenthub/__init__.py@@ -1,17 +1,21 @@-from .micro.registry import all_microagents-from .micro.agent import MicroAgent+from dotenv import load_dotenv+from opendevin.agent import Agent-from dotenv import load_dotenv+from .micro.agent import MicroAgent+from .micro.registry import all_microagents+load_dotenv()# Import agents after environment variables are loaded-from . import monologue_agent # noqa: E402-from . import codeact_agent # noqa: E402-from . import planner_agent # noqa: E402-from . import SWE_agent # noqa: E402-from . import delegator_agent # noqa: E402+from . import ( # noqa: E402+ SWE_agent,+ codeact_agent,+ delegator_agent,+ monologue_agent,+ planner_agent,+)__all__ = ['monologue_agent', 'codeact_agent','planner_agent', 'SWE_agent', 'delegator_agent']diff --git a/agenthub/codeact_agent/__init__.py b/agenthub/codeact_agent/__init__.pyindex a07c920950..c8d08d364d 100644--- a/agenthub/codeact_agent/__init__.py+++ b/agenthub/codeact_agent/__init__.py@@ -1,4 +1,5 @@from opendevin.agent import Agent+from .codeact_agent import CodeActAgentAgent.register('CodeActAgent', CodeActAgent)diff --git a/agenthub/codeact_agent/codeact_agent.py b/agenthub/codeact_agent/codeact_agent.pyindex 9ff503f3bd..576e060bfa 100644--- a/agenthub/codeact_agent/codeact_agent.py+++ b/agenthub/codeact_agent/codeact_agent.py@@ -13,8 +13,8 @@ from opendevin.observation import (AgentMessageObservation,CmdOutputObservation,)+from opendevin.sandbox.plugins import JupyterRequirement, PluginRequirementfrom opendevin.state import State-from opendevin.sandbox.plugins import PluginRequirement, JupyterRequirementSYSTEM_MESSAGE = """You are a helpful assistant. You will be provided access (as root) to a bash shell to complete user-provided tasks.You will be able to execute commands in the bash shell, interact with the file system, install packages, and receive the output of your commands.diff --git a/agenthub/delegator_agent/__init__.py b/agenthub/delegator_agent/__init__.pyindex ffc2af8b24..d25d295e3a 100644--- a/agenthub/delegator_agent/__init__.py+++ b/agenthub/delegator_agent/__init__.py@@ -1,4 +1,5 @@from opendevin.agent import Agent+from .agent import DelegatorAgentAgent.register('DelegatorAgent', DelegatorAgent)diff --git a/agenthub/delegator_agent/agent.py b/agenthub/delegator_agent/agent.pyindex 8481d17d31..57ecd7bcd4 100644--- a/agenthub/delegator_agent/agent.py+++ b/agenthub/delegator_agent/agent.py@@ -1,11 +1,10 @@from typing import List+from opendevin.action import Action, AgentDelegateAction, AgentFinishActionfrom opendevin.agent import Agent-from opendevin.action import AgentFinishAction, AgentDelegateAction-from opendevin.observation import AgentDelegateObservationfrom opendevin.llm.llm import LLM+from opendevin.observation import AgentDelegateObservationfrom opendevin.state import State-from opendevin.action import Actionclass DelegatorAgent(Agent):diff --git a/agenthub/dummy_agent/agent.py b/agenthub/dummy_agent/agent.pyindex f1cd85cb3c..c0908ddeb3 100644--- a/agenthub/dummy_agent/agent.py+++ b/agenthub/dummy_agent/agent.py@@ -1,12 +1,14 @@"""Module for a Dummy agent."""-from opendevin.action.base import NullAction-from opendevin.state import State-from opendevin.action import Actionfrom typing import List++from opendevin.action import Action+from opendevin.action.base import NullActionfrom opendevin.agent import Agentfrom opendevin.controller.agent_controller import AgentControllerfrom opendevin.observation.base import NullObservation, Observation+from opendevin.state import State+class DummyAgent(Agent):"""A dummy agent that does nothing but can be used in testing."""diff --git a/agenthub/micro/agent.py b/agenthub/micro/agent.pyindex 4445221d25..a0f6de3795 100644--- a/agenthub/micro/agent.py+++ b/agenthub/micro/agent.py@@ -1,13 +1,13 @@import json-from typing import List, Dict+from typing import Dict, List-from jinja2 import Environment, BaseLoader+from jinja2 import BaseLoader, Environment+from opendevin.action import Action, action_from_dictfrom opendevin.agent import Agent+from opendevin.exceptions import LLMOutputErrorfrom opendevin.llm.llm import LLMfrom opendevin.state import State-from opendevin.action import Action, action_from_dict-from opendevin.exceptions import LLMOutputErrorfrom .instructions import instructionsfrom .registry import all_microagentsdiff --git a/agenthub/micro/instructions.py b/agenthub/micro/instructions.pyindex 856c78024a..022e08511b 100644--- a/agenthub/micro/instructions.py+++ b/agenthub/micro/instructions.py@@ -1,5 +1,5 @@-from typing import Dictimport os+from typing import Dictinstructions: Dict = {}diff --git a/agenthub/micro/registry.py b/agenthub/micro/registry.pyindex fd52cc8a7a..2fc4060dc4 100644--- a/agenthub/micro/registry.py+++ b/agenthub/micro/registry.py@@ -1,4 +1,5 @@import os+import yamlall_microagents = {}diff --git a/agenthub/monologue_agent/__init__.py b/agenthub/monologue_agent/__init__.pyindex 1cfef46f11..b60cb48bb5 100644--- a/agenthub/monologue_agent/__init__.py+++ b/agenthub/monologue_agent/__init__.py@@ -1,4 +1,5 @@from opendevin.agent import Agent+from .agent import MonologueAgentAgent.register('MonologueAgent', MonologueAgent)diff --git a/agenthub/monologue_agent/agent.py b/agenthub/monologue_agent/agent.pyindex 2be6c26039..7f7d8dd4eb 100644--- a/agenthub/monologue_agent/agent.py+++ b/agenthub/monologue_agent/agent.py@@ -1,35 +1,34 @@from typing import List-from opendevin.agent import Agent-from opendevin.state import State-from opendevin.llm.llm import LLM-from opendevin.schema import ActionType-from opendevin.exceptions import AgentNoInstructionError-from opendevin.schema.config import ConfigType-from opendevin import config+import agenthub.monologue_agent.utils.prompts as prompts+from agenthub.monologue_agent.utils.monologue import Monologue+from opendevin import configfrom opendevin.action import (Action,- NullAction,- CmdRunAction,- FileWriteAction,- FileReadAction,AgentRecallAction,+ AgentThinkAction,BrowseURLAction,+ CmdRunAction,+ FileReadAction,+ FileWriteAction,GitHubPushAction,- AgentThinkAction,+ NullAction,)-+from opendevin.agent import Agent+from opendevin.exceptions import AgentNoInstructionError+from opendevin.llm.llm import LLMfrom opendevin.observation import (- Observation,- NullObservation,- CmdOutputObservation,- FileReadObservation,AgentRecallObservation,BrowserOutputObservation,+ CmdOutputObservation,+ FileReadObservation,+ NullObservation,+ Observation,)+from opendevin.schema import ActionType+from opendevin.schema.config import ConfigType+from opendevin.state import State-import agenthub.monologue_agent.utils.prompts as prompts-from agenthub.monologue_agent.utils.monologue import Monologueif config.get(ConfigType.AGENT_MEMORY_ENABLED):from agenthub.monologue_agent.utils.memory import LongTermMemorydiff --git a/agenthub/monologue_agent/utils/json.py b/agenthub/monologue_agent/utils/json.pyindex 455a42ee0b..13b7416086 100644--- a/agenthub/monologue_agent/utils/json.py+++ b/agenthub/monologue_agent/utils/json.py@@ -1,4 +1,5 @@import json+from json_repair import repair_jsondiff --git a/agenthub/monologue_agent/utils/memory.py b/agenthub/monologue_agent/utils/memory.pyindex 9500d78287..30cff89bd7 100644--- a/agenthub/monologue_agent/utils/memory.py+++ b/agenthub/monologue_agent/utils/memory.py@@ -1,17 +1,22 @@-import llama_index.embeddings.openai.base as llama_openaiimport threadingimport chromadb-from llama_index.core import Document+import llama_index.embeddings.openai.base as llama_openai+from llama_index.core import Document, VectorStoreIndexfrom llama_index.core.retrievers import VectorIndexRetriever-from llama_index.core import VectorStoreIndexfrom llama_index.vector_stores.chroma import ChromaVectorStore-from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_random_exponential-from openai._exceptions import APIConnectionError, RateLimitError, InternalServerError+from openai._exceptions import APIConnectionError, InternalServerError, RateLimitError+from tenacity import (+ retry,+ retry_if_exception_type,+ stop_after_attempt,+ wait_random_exponential,+)from opendevin import configfrom opendevin.logger import opendevin_logger as loggerfrom opendevin.schema.config import ConfigType+from . import jsonnum_retries = config.get(ConfigType.LLM_NUM_RETRIES)diff --git a/agenthub/monologue_agent/utils/monologue.py b/agenthub/monologue_agent/utils/monologue.pyindex 410b49c17a..545498d7b5 100644--- a/agenthub/monologue_agent/utils/monologue.py+++ b/agenthub/monologue_agent/utils/monologue.py@@ -1,8 +1,8 @@-from opendevin.llm.llm import LLM-from opendevin.exceptions import AgentEventTypeErrorimport agenthub.monologue_agent.utils.json as jsonimport agenthub.monologue_agent.utils.prompts as prompts+from opendevin.exceptions import AgentEventTypeError+from opendevin.llm.llm import LLMfrom opendevin.logger import opendevin_logger as loggerdiff --git a/agenthub/monologue_agent/utils/prompts.py b/agenthub/monologue_agent/utils/prompts.pyindex 4bf0e78931..8767aecaa3 100644--- a/agenthub/monologue_agent/utils/prompts.py+++ b/agenthub/monologue_agent/utils/prompts.py@@ -1,21 +1,20 @@-from typing import List--from . import json-from json import JSONDecodeError-import re+from json import JSONDecodeError+from typing import List+from opendevin import configfrom opendevin.action import (- action_from_dict,Action,+ action_from_dict,)+from opendevin.exceptions import LLMOutputErrorfrom opendevin.observation import (CmdOutputObservation,)-from opendevin.exceptions import LLMOutputError-from opendevin import configfrom opendevin.schema.config import ConfigType+from . import json+ACTION_PROMPT = """You're a thoughtful robot. Your main task is this:%(task)sdiff --git a/agenthub/planner_agent/__init__.py b/agenthub/planner_agent/__init__.pyindex 77bed3e686..d81ba6cc26 100644--- a/agenthub/planner_agent/__init__.py+++ b/agenthub/planner_agent/__init__.py@@ -1,4 +1,5 @@from opendevin.agent import Agent+from .agent import PlannerAgentAgent.register('PlannerAgent', PlannerAgent)diff --git a/agenthub/planner_agent/agent.py b/agenthub/planner_agent/agent.pyindex de0672ef57..44413dfeea 100644--- a/agenthub/planner_agent/agent.py+++ b/agenthub/planner_agent/agent.py@@ -1,11 +1,11 @@from typing import List-from .prompt import get_prompt, parse_response+from opendevin.action import Action, AgentFinishActionfrom opendevin.agent import Agent-from opendevin.action import AgentFinishActionfrom opendevin.llm.llm import LLMfrom opendevin.state import State-from opendevin.action import Action++from .prompt import get_prompt, parse_responseclass PlannerAgent(Agent):diff --git a/agenthub/planner_agent/prompt.py b/agenthub/planner_agent/prompt.pyindex 2b97b88348..234b958590 100644--- a/agenthub/planner_agent/prompt.py+++ b/agenthub/planner_agent/prompt.py@@ -1,29 +1,29 @@import json-from typing import List, Tuple, Dict, Type-from opendevin.plan import Plan-from opendevin.action import Action, action_from_dict-from opendevin.observation import Observation-from opendevin.schema import ActionType-from opendevin.logger import opendevin_logger as logger+from typing import Dict, List, Tuple, Typefrom opendevin.action import (- NullAction,- CmdRunAction,- CmdKillAction,+ Action,+ AddTaskAction,+ AgentFinishAction,+ AgentRecallAction,+ AgentSummarizeAction,+ AgentThinkAction,BrowseURLAction,+ CmdKillAction,+ CmdRunAction,FileReadAction,FileWriteAction,- AgentRecallAction,- AgentThinkAction,- AgentFinishAction,- AgentSummarizeAction,- AddTaskAction,ModifyTaskAction,+ NullAction,+ action_from_dict,)-+from opendevin.logger import opendevin_logger as loggerfrom opendevin.observation import (NullObservation,+ Observation,)+from opendevin.plan import Plan+from opendevin.schema import ActionTypeACTION_TYPE_TO_CLASS: Dict[str, Type[Action]] = {ActionType.RUN: CmdRunAction,diff --git a/dev_config/python/ruff.toml b/dev_config/python/ruff.tomlindex 06ba2d3ace..4efe096a30 100644--- a/dev_config/python/ruff.toml+++ b/dev_config/python/ruff.toml@@ -7,6 +7,7 @@ select = ["E","W","F",+ "I","Q",]diff --git a/evaluation/SWE-bench/notebooks/devin_eval_analysis.ipynb b/evaluation/SWE-bench/notebooks/devin_eval_analysis.ipynbindex b6633aac7c..3cc21c912a 100644--- a/evaluation/SWE-bench/notebooks/devin_eval_analysis.ipynb+++ b/evaluation/SWE-bench/notebooks/devin_eval_analysis.ipynb@@ -11,12 +11,12 @@},"outputs": [],"source": [- "import requests\n",+ "import matplotlib.pyplot as plt\n","import pandas as pd\n",- "from tqdm import tqdm\n",- "from datasets import load_dataset\n",+ "import requests\n","import seaborn as sns\n",- "import matplotlib.pyplot as plt"+ "from datasets import load_dataset\n",+ "from tqdm import tqdm"]},{diff --git a/evaluation/SWE-bench/scripts/prepare_devin_outputs_for_evaluation.py b/evaluation/SWE-bench/scripts/prepare_devin_outputs_for_evaluation.pyindex 829e25faf2..428f1061ca 100644--- a/evaluation/SWE-bench/scripts/prepare_devin_outputs_for_evaluation.py+++ b/evaluation/SWE-bench/scripts/prepare_devin_outputs_for_evaluation.py@@ -11,9 +11,10 @@ Outputs:'''# fetch devin's outputs into a json file for evaluation+import jsonimport osimport sys-import json+import requestsfrom tqdm import tqdmdiff --git a/evaluation/regression/cases/hello-world/test_hello_world.py b/evaluation/regression/cases/hello-world/test_hello_world.pyindex ed33cb45f1..bb6110f934 100644--- a/evaluation/regression/cases/hello-world/test_hello_world.py+++ b/evaluation/regression/cases/hello-world/test_hello_world.py@@ -1,4 +1,5 @@import os+import pytestfrom conftest import agentsdiff --git a/evaluation/regression/conftest.py b/evaluation/regression/conftest.pyindex f1bf1f6443..977fc7f559 100644--- a/evaluation/regression/conftest.py+++ b/evaluation/regression/conftest.py@@ -1,9 +1,10 @@-import os-import pytest-import subprocess+import datetimeimport logging+import osimport shutil-import datetime+import subprocess++import pytestSCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))CASES_DIR = os.path.join(SCRIPT_DIR, 'cases')diff --git a/evaluation/regression/run_tests.py b/evaluation/regression/run_tests.pyindex bfb7185ed3..2887b44507 100644--- a/evaluation/regression/run_tests.py+++ b/evaluation/regression/run_tests.py@@ -1,4 +1,5 @@import argparse+import pytestfrom opendevin import configdiff --git a/opendevin/action/__init__.py b/opendevin/action/__init__.pyindex 782400319f..be79bbfe82 100644--- a/opendevin/action/__init__.py+++ b/opendevin/action/__init__.py@@ -1,18 +1,18 @@-from .base import Action, NullAction-from .bash import CmdRunAction, CmdKillAction-from .browse import BrowseURLAction-from .fileop import FileReadAction, FileWriteAction-from .github import GitHubPushAction+from ..exceptions import AgentMalformedActionErrorfrom .agent import (- AgentRecallAction,- AgentThinkAction,- AgentFinishAction,+ AgentDelegateAction,AgentEchoAction,+ AgentFinishAction,+ AgentRecallAction,AgentSummarizeAction,- AgentDelegateAction,+ AgentThinkAction,)+from .base import Action, NullAction+from .bash import CmdKillAction, CmdRunAction+from .browse import BrowseURLAction+from .fileop import FileReadAction, FileWriteAction+from .github import GitHubPushActionfrom .tasks import AddTaskAction, ModifyTaskAction-from ..exceptions import AgentMalformedActionErroractions = (CmdKillAction,diff --git a/opendevin/action/agent.py b/opendevin/action/agent.pyindex 1cb0b8cdf2..11461f6f82 100644--- a/opendevin/action/agent.py+++ b/opendevin/action/agent.py@@ -2,12 +2,13 @@ from dataclasses import dataclass, fieldfrom typing import TYPE_CHECKING, Dictfrom opendevin.observation import (- AgentRecallObservation,AgentMessageObservation,+ AgentRecallObservation,NullObservation,Observation,)from opendevin.schema import ActionType+from .base import ExecutableAction, NotExecutableActionif TYPE_CHECKING:diff --git a/opendevin/action/base.py b/opendevin/action/base.pyindex f3273011aa..d459713f3f 100644--- a/opendevin/action/base.py+++ b/opendevin/action/base.py@@ -1,5 +1,6 @@-from dataclasses import dataclass, asdict+from dataclasses import asdict, dataclassfrom typing import TYPE_CHECKING+from opendevin.schema import ActionTypeif TYPE_CHECKING:diff --git a/opendevin/action/bash.py b/opendevin/action/bash.pyindex 1757c7ea3c..7dc2c4ff27 100644--- a/opendevin/action/bash.py+++ b/opendevin/action/bash.py@@ -1,9 +1,10 @@from dataclasses import dataclassfrom typing import TYPE_CHECKING-from .base import ExecutableActionfrom opendevin.schema import ActionType+from .base import ExecutableAction+if TYPE_CHECKING:from opendevin.controller import AgentControllerfrom opendevin.observation import CmdOutputObservation, Observationdiff --git a/opendevin/action/browse.py b/opendevin/action/browse.pyindex 58639e984e..3c24e04bf2 100644--- a/opendevin/action/browse.py+++ b/opendevin/action/browse.py@@ -1,11 +1,13 @@-import osimport base64+import osfrom dataclasses import dataclass-from opendevin.observation import BrowserOutputObservation-from opendevin.schema import ActionTypefrom typing import TYPE_CHECKING+from playwright.async_api import async_playwright+from opendevin.observation import BrowserOutputObservation+from opendevin.schema import ActionType+from .base import ExecutableActionif TYPE_CHECKING:diff --git a/opendevin/action/fileop.py b/opendevin/action/fileop.pyindex b1da4b240b..343a154e9f 100644--- a/opendevin/action/fileop.py+++ b/opendevin/action/fileop.py@@ -1,18 +1,16 @@import os-from dataclasses import dataclassfrom pathlib import Path+from opendevin import configfrom opendevin.observation import (- Observation,+ AgentErrorObservation,FileReadObservation,FileWriteObservation,- AgentErrorObservation,+ Observation,)--from opendevin.schema import ActionTypefrom opendevin.sandbox import E2BBox-from opendevin import config+from opendevin.schema import ActionTypefrom opendevin.schema.config import ConfigTypefrom .base import ExecutableActiondiff --git a/opendevin/action/github.py b/opendevin/action/github.pyindex 738adb0680..78dd81fba2 100644--- a/opendevin/action/github.py+++ b/opendevin/action/github.py@@ -1,14 +1,15 @@+import random+import stringfrom dataclasses import dataclass-from opendevin.observation import Observation, AgentErrorObservation-from opendevin.observation.message import AgentMessageObservation-from opendevin.observation.run import CmdOutputObservation-from opendevin.schema import ActionType-from opendevin import configfrom typing import TYPE_CHECKING+import requests-import random-import string+from opendevin import config+from opendevin.observation import AgentErrorObservation, Observation+from opendevin.observation.message import AgentMessageObservation+from opendevin.observation.run import CmdOutputObservation+from opendevin.schema import ActionTypefrom opendevin.schema.config import ConfigTypefrom .base import ExecutableActiondiff --git a/opendevin/action/tasks.py b/opendevin/action/tasks.pyindex 96c6fb8f53..f102340300 100644--- a/opendevin/action/tasks.py+++ b/opendevin/action/tasks.py@@ -1,10 +1,11 @@from dataclasses import dataclass, field+from typing import TYPE_CHECKING-from .base import ExecutableAction, NotExecutableAction-from opendevin.schema import ActionTypefrom opendevin.observation import NullObservation+from opendevin.schema import ActionType++from .base import ExecutableAction, NotExecutableAction-from typing import TYPE_CHECKINGif TYPE_CHECKING:from opendevin.controller import AgentControllerdiff --git a/opendevin/agent.py b/opendevin/agent.pyindex 855d50ff7f..a51a214bd5 100644--- a/opendevin/agent.py+++ b/opendevin/agent.py@@ -1,11 +1,11 @@from abc import ABC, abstractmethod-from typing import List, Dict, Type, TYPE_CHECKING+from typing import TYPE_CHECKING, Dict, List, Typeif TYPE_CHECKING:from opendevin.action import Actionfrom opendevin.state import State-from opendevin.llm.llm import LLMfrom opendevin.exceptions import AgentAlreadyRegisteredError, AgentNotRegisteredError+from opendevin.llm.llm import LLMfrom opendevin.sandbox.plugins import PluginRequirementdiff --git a/opendevin/config.py b/opendevin/config.pyindex 4f7482cac5..ec095561b8 100644--- a/opendevin/config.py+++ b/opendevin/config.py@@ -1,12 +1,13 @@-import osimport argparse-import toml+import logging+import osimport pathlibimport platform++import tomlfrom dotenv import load_dotenvfrom opendevin.schema import ConfigType-import logginglogger = logging.getLogger(__name__)diff --git a/opendevin/controller/__init__.py b/opendevin/controller/__init__.pyindex 2f6d436e01..005df25448 100644--- a/opendevin/controller/__init__.py+++ b/opendevin/controller/__init__.py@@ -1,5 +1,5 @@-from .agent_controller import AgentControllerfrom .action_manager import ActionManager+from .agent_controller import AgentController__all__ = ['AgentController',diff --git a/opendevin/controller/action_manager.py b/opendevin/controller/action_manager.pyindex d9c91a2c76..ea5e0404f9 100644--- a/opendevin/controller/action_manager.py+++ b/opendevin/controller/action_manager.py@@ -1,17 +1,18 @@from typing import Listfrom opendevin import config-from opendevin.observation import CmdOutputObservation, AgentErrorObservation-from opendevin.sandbox import DockerExecBox, DockerSSHBox, Sandbox, LocalBox, E2BBox-from opendevin.schema import ConfigTypefrom opendevin.action import (Action,)from opendevin.observation import (- Observation,+ AgentErrorObservation,+ CmdOutputObservation,NullObservation,+ Observation,)+from opendevin.sandbox import DockerExecBox, DockerSSHBox, E2BBox, LocalBox, Sandboxfrom opendevin.sandbox.plugins import PluginRequirement+from opendevin.schema import ConfigTypeclass ActionManager:diff --git a/opendevin/controller/agent_controller.py b/opendevin/controller/agent_controller.pyindex 7e1da1e246..dff0eb0d50 100644--- a/opendevin/controller/agent_controller.py+++ b/opendevin/controller/agent_controller.py@@ -1,30 +1,33 @@import asynciofrom typing import Callable, List, Type-from opendevin import config-from opendevin.schema.config import ConfigTypefrom opendevin.action import (Action,- AgentFinishAction,AgentDelegateAction,+ AgentFinishAction,NullAction,)+from opendevin.action.tasks import TaskStateChangedAction+from opendevin.agent import Agent+from opendevin.controller.action_manager import ActionManager+from opendevin.exceptions import (+ AgentMalformedActionError,+ AgentNoActionError,+ LLMOutputError,+ MaxCharsExceedError,+)+from opendevin.logger import opendevin_logger as loggerfrom opendevin.observation import (- Observation,- AgentErrorObservation,AgentDelegateObservation,+ AgentErrorObservation,NullObservation,+ Observation,)-from opendevin.agent import Agent-from opendevin.exceptions import AgentMalformedActionError, AgentNoActionError, MaxCharsExceedError, LLMOutputError-from opendevin.logger import opendevin_logger as loggerfrom opendevin.plan import Plan-from opendevin.state import State--from opendevin.action.tasks import TaskStateChangedActionfrom opendevin.schema import TaskState-from opendevin.controller.action_manager import ActionManager+from opendevin.schema.config import ConfigType+from opendevin.state import StateMAX_ITERATIONS = config.get(ConfigType.MAX_ITERATIONS)MAX_CHARS = config.get(ConfigType.MAX_CHARS)diff --git a/opendevin/logger.py b/opendevin/logger.pyindex 1e90f14577..709dcd2dc0 100644--- a/opendevin/logger.py+++ b/opendevin/logger.py@@ -3,10 +3,11 @@ import osimport sysimport tracebackfrom datetime import datetime-from opendevin import configfrom typing import Literal, Mapping+from termcolor import colored+from opendevin import configfrom opendevin.schema.config import ConfigTypeDISABLE_COLOR_PRINTING = (diff --git a/opendevin/main.py b/opendevin/main.pyindex 686174e575..a97ab14477 100644--- a/opendevin/main.py+++ b/opendevin/main.py@@ -3,8 +3,8 @@ import sysfrom typing import Typeimport agenthub # noqa F401 (we import this to get the agents registered)-from opendevin.config import argsfrom opendevin.agent import Agent+from opendevin.config import argsfrom opendevin.controller import AgentControllerfrom opendevin.llm.llm import LLMdiff --git a/opendevin/observation/__init__.py b/opendevin/observation/__init__.pyindex 2c4c29e5a9..2a4dc83dca 100644--- a/opendevin/observation/__init__.py+++ b/opendevin/observation/__init__.py@@ -1,11 +1,11 @@-from .base import Observation, NullObservation-from .run import CmdOutputObservation+from .base import NullObservation, Observationfrom .browse import BrowserOutputObservation-from .files import FileReadObservation, FileWriteObservation-from .message import UserMessageObservation, AgentMessageObservation-from .recall import AgentRecallObservationfrom .delegate import AgentDelegateObservationfrom .error import AgentErrorObservation+from .files import FileReadObservation, FileWriteObservation+from .message import AgentMessageObservation, UserMessageObservation+from .recall import AgentRecallObservation+from .run import CmdOutputObservationobservations = (CmdOutputObservation,diff --git a/opendevin/observation/base.py b/opendevin/observation/base.pyindex b1622848cf..078f5b289d 100644--- a/opendevin/observation/base.py+++ b/opendevin/observation/base.py@@ -1,5 +1,6 @@import copyfrom dataclasses import dataclass+from opendevin.schema import ObservationTypediff --git a/opendevin/observation/browse.py b/opendevin/observation/browse.pyindex 81e7010e4f..4c7c21ec25 100644--- a/opendevin/observation/browse.py+++ b/opendevin/observation/browse.py@@ -1,8 +1,9 @@from dataclasses import dataclass-from .base import Observationfrom opendevin.schema import ObservationType+from .base import Observation+@dataclassclass BrowserOutputObservation(Observation):diff --git a/opendevin/observation/delegate.py b/opendevin/observation/delegate.pyindex 5465fb5e2c..3b7b586320 100644--- a/opendevin/observation/delegate.py+++ b/opendevin/observation/delegate.py@@ -1,8 +1,9 @@from dataclasses import dataclass-from .base import Observationfrom opendevin.schema import ObservationType+from .base import Observation+@dataclassclass AgentDelegateObservation(Observation):diff --git a/opendevin/observation/error.py b/opendevin/observation/error.pyindex 1b500dd8f3..ac47b4eafd 100644--- a/opendevin/observation/error.py+++ b/opendevin/observation/error.py@@ -1,8 +1,9 @@from dataclasses import dataclass-from .base import Observationfrom opendevin.schema import ObservationType+from .base import Observation+@dataclassclass AgentErrorObservation(Observation):diff --git a/opendevin/observation/files.py b/opendevin/observation/files.pyindex c15ad5f08c..60112b8ef8 100644--- a/opendevin/observation/files.py+++ b/opendevin/observation/files.py@@ -1,8 +1,9 @@from dataclasses import dataclass-from .base import Observationfrom opendevin.schema import ObservationType+from .base import Observation+@dataclassclass FileReadObservation(Observation):diff --git a/opendevin/observation/message.py b/opendevin/observation/message.pyindex 2848affbcc..3d82166caa 100644--- a/opendevin/observation/message.py+++ b/opendevin/observation/message.py@@ -1,8 +1,9 @@from dataclasses import dataclass-from .base import Observationfrom opendevin.schema import ObservationType+from .base import Observation+@dataclassclass UserMessageObservation(Observation):diff --git a/opendevin/observation/recall.py b/opendevin/observation/recall.pyindex 126aee82e7..7fffbcdffc 100644--- a/opendevin/observation/recall.py+++ b/opendevin/observation/recall.py@@ -1,9 +1,10 @@from dataclasses import dataclassfrom typing import List-from .base import Observationfrom opendevin.schema import ObservationType+from .base import Observation+@dataclassclass AgentRecallObservation(Observation):diff --git a/opendevin/observation/run.py b/opendevin/observation/run.pyindex 09293b848f..aaf5476e87 100644--- a/opendevin/observation/run.py+++ b/opendevin/observation/run.py@@ -1,8 +1,9 @@from dataclasses import dataclass-from .base import Observationfrom opendevin.schema import ObservationType+from .base import Observation+@dataclassclass CmdOutputObservation(Observation):diff --git a/opendevin/plan.py b/opendevin/plan.pyindex efdd3566c0..7c722a8acd 100644--- a/opendevin/plan.py+++ b/opendevin/plan.py@@ -1,7 +1,7 @@from typing import List-from opendevin.logger import opendevin_logger as loggerfrom opendevin.exceptions import PlanInvalidStateError+from opendevin.logger import opendevin_logger as loggerOPEN_STATE = 'open'COMPLETED_STATE = 'completed'diff --git a/opendevin/sandbox/__init__.py b/opendevin/sandbox/__init__.pyindex 41611bb7e4..feedc6436d 100644--- a/opendevin/sandbox/__init__.py+++ b/opendevin/sandbox/__init__.py@@ -1,8 +1,8 @@-from .sandbox import Sandbox-from .docker.ssh_box import DockerSSHBoxfrom .docker.exec_box import DockerExecBoxfrom .docker.local_box import LocalBox+from .docker.ssh_box import DockerSSHBoxfrom .e2b.sandbox import E2BBox+from .sandbox import Sandbox__all__ = ['Sandbox',diff --git a/opendevin/sandbox/docker/exec_box.py b/opendevin/sandbox/docker/exec_box.pyindex fa48071a3d..c53c7d76db 100644--- a/opendevin/sandbox/docker/exec_box.py+++ b/opendevin/sandbox/docker/exec_box.py@@ -2,22 +2,22 @@ import atexitimport concurrent.futuresimport osimport sys+import tarfileimport timeimport uuid-import tarfile-from glob import globfrom collections import namedtuple+from glob import globfrom typing import Dict, List, Tupleimport dockerfrom opendevin import config+from opendevin.exceptions import SandboxInvalidBackgroundCommandErrorfrom opendevin.logger import opendevin_logger as logger-from opendevin.sandbox.sandbox import Sandbox-from opendevin.sandbox.process import Processfrom opendevin.sandbox.docker.process import DockerProcess+from opendevin.sandbox.process import Process+from opendevin.sandbox.sandbox import Sandboxfrom opendevin.schema import ConfigType-from opendevin.exceptions import SandboxInvalidBackgroundCommandErrorInputType = namedtuple('InputType', ['content'])OutputType = namedtuple('OutputType', ['content'])diff --git a/opendevin/sandbox/docker/local_box.py b/opendevin/sandbox/docker/local_box.pyindex 44fa3e2b6f..2dcf1e923c 100644--- a/opendevin/sandbox/docker/local_box.py+++ b/opendevin/sandbox/docker/local_box.py@@ -1,13 +1,14 @@-import subprocessimport atexitimport os+import subprocessimport sys-from typing import Tuple, Dict-from opendevin.sandbox.sandbox import Sandbox-from opendevin.sandbox.process import Process-from opendevin.sandbox.docker.process import DockerProcess-from opendevin.logger import opendevin_logger as logger+from typing import Dict, Tuple+from opendevin import config+from opendevin.logger import opendevin_logger as logger+from opendevin.sandbox.docker.process import DockerProcess+from opendevin.sandbox.process import Process+from opendevin.sandbox.sandbox import Sandboxfrom opendevin.schema.config import ConfigType# ===============================================================================diff --git a/opendevin/sandbox/docker/ssh_box.py b/opendevin/sandbox/docker/ssh_box.pyindex 8a6063cd40..7982c12844 100644--- a/opendevin/sandbox/docker/ssh_box.py+++ b/opendevin/sandbox/docker/ssh_box.py@@ -1,25 +1,25 @@import atexitimport osimport sys+import tarfileimport timeimport uuid-import tarfile-from glob import globfrom collections import namedtuple+from glob import globfrom typing import Dict, List, Tuple, Unionimport dockerfrom pexpect import pxsshfrom opendevin import config+from opendevin.exceptions import SandboxInvalidBackgroundCommandErrorfrom opendevin.logger import opendevin_logger as logger-from opendevin.sandbox.sandbox import Sandbox-from opendevin.sandbox.process import Processfrom opendevin.sandbox.docker.process import DockerProcessfrom opendevin.sandbox.plugins import JupyterRequirement, SWEAgentCommandsRequirement+from opendevin.sandbox.process import Process+from opendevin.sandbox.sandbox import Sandboxfrom opendevin.schema import ConfigTypefrom opendevin.utils import find_available_tcp_port-from opendevin.exceptions import SandboxInvalidBackgroundCommandErrorInputType = namedtuple('InputType', ['content'])OutputType = namedtuple('OutputType', ['content'])diff --git a/opendevin/sandbox/e2b/sandbox.py b/opendevin/sandbox/e2b/sandbox.pyindex ef7d53beb2..d95e1f6548 100644--- a/opendevin/sandbox/e2b/sandbox.py+++ b/opendevin/sandbox/e2b/sandbox.py@@ -2,17 +2,18 @@ import osimport tarfilefrom glob import globfrom typing import Dict, Tuple+from e2b import Sandbox as E2BSandboxfrom e2b.sandbox.exception import (TimeoutException,)from opendevin import config-from opendevin.schema.config import ConfigTypefrom opendevin.logger import opendevin_logger as logger-from opendevin.sandbox.sandbox import Sandboxfrom opendevin.sandbox.e2b.process import E2BProcessfrom opendevin.sandbox.process import Process+from opendevin.sandbox.sandbox import Sandbox+from opendevin.schema.config import ConfigTypeclass E2BBox(Sandbox):diff --git a/opendevin/sandbox/plugins/__init__.py b/opendevin/sandbox/plugins/__init__.pyindex 15053253a5..5ea90bd9ff 100644--- a/opendevin/sandbox/plugins/__init__.py+++ b/opendevin/sandbox/plugins/__init__.py@@ -1,8 +1,7 @@-from .mixin import PluginMixin-from .requirement import PluginRequirement-# Requirementsfrom .jupyter import JupyterRequirement+from .mixin import PluginMixin+from .requirement import PluginRequirementfrom .swe_agent_commands import SWEAgentCommandsRequirement__all__ = ['PluginMixin', 'PluginRequirement', 'JupyterRequirement', 'SWEAgentCommandsRequirement']diff --git a/opendevin/sandbox/plugins/jupyter/__init__.py b/opendevin/sandbox/plugins/jupyter/__init__.pyindex a9c3214cf2..abedf467fe 100644--- a/opendevin/sandbox/plugins/jupyter/__init__.py+++ b/opendevin/sandbox/plugins/jupyter/__init__.py@@ -1,5 +1,6 @@import osfrom dataclasses import dataclass+from opendevin.sandbox.plugins.requirement import PluginRequirementdiff --git a/opendevin/sandbox/plugins/jupyter/execute_cli b/opendevin/sandbox/plugins/jupyter/execute_cliindex 3fca4c534f..0d697c1100 100755--- a/opendevin/sandbox/plugins/jupyter/execute_cli+++ b/opendevin/sandbox/plugins/jupyter/execute_cli@@ -2,6 +2,7 @@import osimport sysimport time+import requests# Read the Python code from STDINdiff --git a/opendevin/sandbox/plugins/jupyter/execute_server b/opendevin/sandbox/plugins/jupyter/execute_serverindex e5af086ea7..3362b9cc02 100755--- a/opendevin/sandbox/plugins/jupyter/execute_server+++ b/opendevin/sandbox/plugins/jupyter/execute_server@@ -1,16 +1,16 @@#!/usr/bin/env python3-import os-import reimport asyncio-import tornadoimport logging+import os+import re+from uuid import uuid4-from tornado.escape import json_encode, json_decode, url_escape-from tornado.websocket import websocket_connect-from tornado.ioloop import PeriodicCallback+import tornado+from tornado.escape import json_decode, json_encode, url_escapefrom tornado.httpclient import AsyncHTTPClient, HTTPRequest-from uuid import uuid4+from tornado.ioloop import PeriodicCallback+from tornado.websocket import websocket_connectlogging.basicConfig(level=logging.INFO)diff --git a/opendevin/sandbox/plugins/mixin.py b/opendevin/sandbox/plugins/mixin.pyindex af9f269727..9ca0b467df 100644--- a/opendevin/sandbox/plugins/mixin.py+++ b/opendevin/sandbox/plugins/mixin.py@@ -1,5 +1,6 @@import osfrom typing import List, Protocol, Tuple+from opendevin.logger import opendevin_logger as loggerfrom opendevin.sandbox.plugins.requirement import PluginRequirementdiff --git a/opendevin/sandbox/plugins/swe_agent_commands/__init__.py b/opendevin/sandbox/plugins/swe_agent_commands/__init__.pyindex 7bf4117384..465edf636a 100644--- a/opendevin/sandbox/plugins/swe_agent_commands/__init__.py+++ b/opendevin/sandbox/plugins/swe_agent_commands/__init__.py@@ -1,8 +1,11 @@import os-from typing import Listfrom dataclasses import dataclass, field+from typing import List+from opendevin.sandbox.plugins.requirement import PluginRequirement-from opendevin.sandbox.plugins.swe_agent_commands.parse_commands import parse_command_file+from opendevin.sandbox.plugins.swe_agent_commands.parse_commands import (+ parse_command_file,+)def _resolve_to_cur_dir(filename):diff --git a/opendevin/sandbox/sandbox.py b/opendevin/sandbox/sandbox.pyindex fcbcfc5ab2..cf5e56432a 100644--- a/opendevin/sandbox/sandbox.py+++ b/opendevin/sandbox/sandbox.py@@ -1,9 +1,8 @@from abc import ABC, abstractmethod-from typing import Dict-from typing import Tuple+from typing import Dict, Tuple-from opendevin.sandbox.process import Processfrom opendevin.sandbox.plugins.mixin import PluginMixin+from opendevin.sandbox.process import Processclass Sandbox(ABC, PluginMixin):diff --git a/opendevin/server/agent/manager.py b/opendevin/server/agent/manager.pyindex 5584035587..5ae0fd6e21 100644--- a/opendevin/server/agent/manager.py+++ b/opendevin/server/agent/manager.py@@ -1,7 +1,8 @@import atexit-from opendevin.server.session import session_managerfrom opendevin.logger import opendevin_logger as logger+from opendevin.server.session import session_manager+from .agent import AgentUnitdiff --git a/opendevin/server/auth/auth.py b/opendevin/server/auth/auth.pyindex 81b73cec1f..6429743be7 100644--- a/opendevin/server/auth/auth.py+++ b/opendevin/server/auth/auth.py@@ -1,9 +1,11 @@import os-import jwtfrom typing import Dict-from opendevin.logger import opendevin_logger as logger++import jwtfrom jwt.exceptions import InvalidTokenError+from opendevin.logger import opendevin_logger as logger+JWT_SECRET = os.getenv('JWT_SECRET', '5ecRe7')diff --git a/opendevin/server/listen.py b/opendevin/server/listen.pyindex 68d831138e..7a0cee9e47 100644--- a/opendevin/server/listen.py+++ b/opendevin/server/listen.py@@ -11,9 +11,9 @@ from fastapi.staticfiles import StaticFilesimport agenthub # noqa F401 (we import this to get the agents registered)from opendevin import config, files-from opendevin.schema.config import ConfigTypefrom opendevin.agent import Agentfrom opendevin.logger import opendevin_logger as logger+from opendevin.schema.config import ConfigTypefrom opendevin.server.agent import agent_managerfrom opendevin.server.auth import get_sid_from_token, sign_tokenfrom opendevin.server.session import message_stack, session_managerdiff --git a/opendevin/server/session/manager.py b/opendevin/server/session/manager.pyindex 1301cc0e94..09525edbd4 100644--- a/opendevin/server/session/manager.py+++ b/opendevin/server/session/manager.py@@ -1,11 +1,12 @@import atexitimport jsonimport os-from typing import Dict, Callable+from typing import Callable, Dictfrom fastapi import WebSocketfrom opendevin.logger import opendevin_logger as logger+from .msg_stack import message_stackfrom .session import Sessiondiff --git a/opendevin/server/session/msg_stack.py b/opendevin/server/session/msg_stack.pyindex 22d2c6e45d..d362022a5e 100644--- a/opendevin/server/session/msg_stack.py+++ b/opendevin/server/session/msg_stack.py@@ -1,12 +1,11 @@-import os-import jsonimport atexit+import json+import osimport uuidfrom typing import Dict, List-from opendevin.schema.action import ActionTypefrom opendevin.logger import opendevin_logger as logger-+from opendevin.schema.action import ActionTypeCACHE_DIR = os.getenv('CACHE_DIR', 'cache')MSG_CACHE_FILE = os.path.join(CACHE_DIR, 'messages.json')diff --git a/opendevin/server/session/session.py b/opendevin/server/session/session.pyindex 3f880dc063..19130e7815 100644--- a/opendevin/server/session/session.py+++ b/opendevin/server/session/session.py@@ -1,9 +1,10 @@import time-from typing import Dict, Callable+from typing import Callable, Dictfrom fastapi import WebSocket, WebSocketDisconnectfrom opendevin.logger import opendevin_logger as logger+from .msg_stack import message_stackDEL_DELT_SEC = 60 * 60 * 5diff --git a/opendevin/state.py b/opendevin/state.pyindex 7aa1e834cd..c3d02c9c72 100644--- a/opendevin/state.py+++ b/opendevin/state.py@@ -1,15 +1,14 @@from dataclasses import dataclass, field-from typing import List, Tuple, Dict--from opendevin.plan import Plan+from typing import Dict, List, Tuplefrom opendevin.action import (Action,)from opendevin.observation import (- Observation,CmdOutputObservation,+ Observation,)+from opendevin.plan import Plan@dataclassdiff --git a/tests/integration/conftest.py b/tests/integration/conftest.pyindex 228b421e08..92042f27fb 100644--- a/tests/integration/conftest.py+++ b/tests/integration/conftest.py@@ -1,5 +1,5 @@-import reimport os+import refrom functools import partialimport pytestdiff --git a/tests/integration/test_agent.py b/tests/integration/test_agent.pyindex 137425f18e..d1f55e9eaa 100644--- a/tests/integration/test_agent.py+++ b/tests/integration/test_agent.py@@ -1,5 +1,5 @@-import osimport asyncio+import osimport subprocessimport pytestdiff --git a/tests/test_fileops.py b/tests/test_fileops.pyindex e657ac7dc8..3f22422a66 100644--- a/tests/test_fileops.py+++ b/tests/test_fileops.py@@ -1,9 +1,10 @@-from opendevin import config-from opendevin.schema import ConfigType-from opendevin.action import fileopfrom pathlib import Path+import pytest+from opendevin import config+from opendevin.action import fileop+from opendevin.schema import ConfigTypedef test_resolve_path():diff --git a/tests/unit/test_action_github.py b/tests/unit/test_action_github.pyindex 570613ec51..bb26f5d660 100644--- a/tests/unit/test_action_github.py+++ b/tests/unit/test_action_github.py@@ -1,16 +1,17 @@-from opendevin import config+from unittest.mock import MagicMock, call, patch++import pytest+from agenthub.dummy_agent.agent import DummyAgent+from opendevin import configfrom opendevin.action.github import GitHubPushAction, GitHubSendPRActionfrom opendevin.controller.agent_controller import AgentControllerfrom opendevin.llm.llm import LLMfrom opendevin.observation.error import AgentErrorObservationfrom opendevin.observation.message import AgentMessageObservationfrom opendevin.observation.run import CmdOutputObservation-from opendevin.schema.config import ConfigType-import pytest-from unittest.mock import MagicMock, call, patch@pytest.fixturediff --git a/tests/unit/test_action_serialization.py b/tests/unit/test_action_serialization.pyindex 05d383a399..4f7f733ca5 100644--- a/tests/unit/test_action_serialization.py+++ b/tests/unit/test_action_serialization.py@@ -1,17 +1,17 @@from opendevin.action import (- action_from_dict,Action,+ AddTaskAction,+ AgentFinishAction,+ AgentRecallAction,AgentThinkAction,+ BrowseURLAction,CmdKillAction,CmdRunAction,- BrowseURLAction,- GitHubPushAction,FileReadAction,FileWriteAction,- AgentRecallAction,- AgentFinishAction,- AddTaskAction,+ GitHubPushAction,ModifyTaskAction,+ action_from_dict,)diff --git a/tests/unit/test_arg_parser.py b/tests/unit/test_arg_parser.pyindex 6c140f795a..73e8e811b6 100644--- a/tests/unit/test_arg_parser.py+++ b/tests/unit/test_arg_parser.py@@ -1,7 +1,7 @@-from opendevin.config import get_parser-import pytest+from opendevin.config import get_parser+def test_help_message(capsys):parser = get_parser()diff --git a/tests/unit/test_observation_serialization.py b/tests/unit/test_observation_serialization.pyindex e75efc0a14..e7870f88bf 100644--- a/tests/unit/test_observation_serialization.py+++ b/tests/unit/test_observation_serialization.py@@ -1,4 +1,8 @@-from opendevin.observation import observation_from_dict, Observation, CmdOutputObservation+from opendevin.observation import (+ CmdOutputObservation,+ Observation,+ observation_from_dict,+)def test_observation_serialization_deserialization():