From 7be314c4561cffc89fd9c5bf1c0f504037167266 Mon Sep 17 00:00:00 2001 From: alt-glitch Date: Sun, 15 Mar 2026 02:26:39 +0530 Subject: [PATCH] pass configs to file_tools for r+w over ssh. pass TERM env. default to ~ to in local and ssh backends. ssh backend. --- tools/environments/persistent_shell.py | 1 + tools/environments/ssh.py | 2 +- tools/file_tools.py | 19 +++++++++++++++++++ tools/terminal_tool.py | 2 ++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/tools/environments/persistent_shell.py b/tools/environments/persistent_shell.py index 0ee99838..dd560a93 100644 --- a/tools/environments/persistent_shell.py +++ b/tools/environments/persistent_shell.py @@ -69,6 +69,7 @@ class PersistentShellMixin: self._drain_thread.start() init_script = ( + f"export TERM=${{TERM:-dumb}}\n" f"touch {self._pshell_stdout} {self._pshell_stderr} " f"{self._pshell_status} {self._pshell_cwd} {self._pshell_pid_file}\n" f"echo $$ > {self._pshell_pid_file}\n" diff --git a/tools/environments/ssh.py b/tools/environments/ssh.py index 7f7c7064..1bcc41ee 100644 --- a/tools/environments/ssh.py +++ b/tools/environments/ssh.py @@ -153,7 +153,7 @@ class SSHEnvironment(PersistentShellMixin, BaseEnvironment): effective_stdin = stdin_data cmd = self._build_ssh_command() - cmd.extend(["bash", "-c", wrapped]) + cmd.append(wrapped) try: kwargs = self._build_run_kwargs(timeout, effective_stdin) diff --git a/tools/file_tools.py b/tools/file_tools.py index 8ed019f0..6e9e7e37 100644 --- a/tools/file_tools.py +++ b/tools/file_tools.py @@ -101,12 +101,31 @@ def _get_file_ops(task_id: str = "default") -> ShellFileOperations: "container_persistent": config.get("container_persistent", True), "docker_volumes": config.get("docker_volumes", []), } + + ssh_config = None + if env_type == "ssh": + ssh_config = { + "host": config.get("ssh_host", ""), + "user": config.get("ssh_user", ""), + "port": config.get("ssh_port", 22), + "key": config.get("ssh_key", ""), + "persistent": config.get("ssh_persistent", False), + } + + local_config = None + if env_type == "local": + local_config = { + "persistent": config.get("local_persistent", False), + } + terminal_env = _create_environment( env_type=env_type, image=image, cwd=cwd, timeout=config["timeout"], + ssh_config=ssh_config, container_config=container_config, + local_config=local_config, task_id=task_id, ) diff --git a/tools/terminal_tool.py b/tools/terminal_tool.py index a5551d71..327e1221 100644 --- a/tools/terminal_tool.py +++ b/tools/terminal_tool.py @@ -471,6 +471,8 @@ def _get_env_config() -> Dict[str, Any]: # is running inside the container/remote). if env_type == "local": default_cwd = os.getcwd() + elif env_type == "ssh": + default_cwd = "~" else: default_cwd = "/root"