diff --git a/surfkit/cli/main.py b/surfkit/cli/main.py index 933702a..e8967a5 100644 --- a/surfkit/cli/main.py +++ b/surfkit/cli/main.py @@ -859,7 +859,8 @@ def list_types(): @app.command("find") -def find(): +def find(help="Find an agent"): + """Find an agent""" list_types() @@ -1657,9 +1658,9 @@ def solve( vm = vms[0] if vm.provider and vm.provider.type == "qemu": - if agent_runtime != "process": + if agent_runtime != "process" and agent_runtime != "docker": raise ValueError( - "Qemu desktop can only be used with the agent 'process' runtime" + "Qemu desktop can only be used with the agent 'process' or 'docker' runtime" ) _device = Desktop.from_vm(vm) v1device = _device.to_v1() @@ -1818,7 +1819,7 @@ def solve( pass -@app.command("eval", help="Evaluate an agent on a benchmark") +# @app.command("eval", help="Evaluate an agent on a benchmark") # TODO def eval( benchmark: str = typer.Argument( help="Benchmark name", diff --git a/surfkit/runtime/agent/docker.py b/surfkit/runtime/agent/docker.py index de733cc..ed59246 100644 --- a/surfkit/runtime/agent/docker.py +++ b/surfkit/runtime/agent/docker.py @@ -257,6 +257,23 @@ def solve_task( raise ValueError(f"No instances found for name '{name}'") instance = instances[0] + # TODO: This is a hack to make the qemu desktops work with docker agents, should likely be reworked + if task.task.device and task.task.device.type.lower() == "desktop": + cfg = task.task.device.config + if hasattr(cfg, "agentd_url"): + agentd_url: str = cfg.agentd_url # type: ignore + if agentd_url.startswith("http://localhost"): + agentd_url = agentd_url.replace( + "http://localhost", "http://host.docker.internal" + ) + task.task.device.config.agentd_url = agentd_url # type: ignore + logging.debug(f"replaced agentd url: {task.task.device.config}") + + elif agentd_url.startswith("localhost"): + agentd_url = agentd_url.replace("localhost", "host.docker.internal") + task.task.device.config.agentd_url = agentd_url # type: ignore + logging.debug(f"replaced agentd url: {task.task.device.config}") + print(f"Container '{name}' found.") response = requests.post( f"http://localhost:{instance.port}/v1/tasks",