Skip to content

Local

minisweagent.environments.local

LocalEnvironmentConfig dataclass

LocalEnvironmentConfig(
    cwd: str = "",
    env: dict[str, str] = dict(),
    timeout: int = 30,
)

cwd class-attribute instance-attribute

cwd: str = ''

env class-attribute instance-attribute

env: dict[str, str] = field(default_factory=dict)

timeout class-attribute instance-attribute

timeout: int = 30

LocalEnvironment

LocalEnvironment(
    *, config_class: type = LocalEnvironmentConfig, **kwargs
)

This class executes bash commands directly on the local machine.

Source code in src/minisweagent/environments/local.py
14
15
16
def __init__(self, *, config_class: type = LocalEnvironmentConfig, **kwargs):
    """This class executes bash commands directly on the local machine."""
    self.config = config_class(**kwargs)

config instance-attribute

config = config_class(**kwargs)

execute

execute(command: str, cwd: str = '')

Execute a command in the local environment and return the result as a dict.

Source code in src/minisweagent/environments/local.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
def execute(self, command: str, cwd: str = ""):
    """Execute a command in the local environment and return the result as a dict."""
    cwd = cwd or self.config.cwd or os.getcwd()
    result = subprocess.run(
        command,
        shell=True,
        text=True,
        cwd=cwd,
        env=os.environ | self.config.env,
        timeout=self.config.timeout,
        encoding="utf-8",
        errors="replace",
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT,
    )
    return {"output": result.stdout, "returncode": result.returncode}