Agent Zero AI framework
local TTY implementation
frdel97575a2d8b1b
diff --git a/agent.py b/agent.pyindex e806cc4e6..c16938d54 100644--- a/agent.py+++ b/agent.py@@ -221,18 +221,6 @@ class AgentConfig:profile: str = ""memory_subdir: str = ""knowledge_subdirs: list[str] = field(default_factory=lambda: ["default", "custom"])- code_exec_docker_enabled: bool = False- code_exec_docker_name: str = "A0-dev"- code_exec_docker_image: str = "agent0ai/agent-zero-run:development"- code_exec_docker_ports: dict[str, int] = field(- default_factory=lambda: {"22/tcp": 55022, "80/tcp": 55080}- )- code_exec_docker_volumes: dict[str, dict[str, str]] = field(- default_factory=lambda: {- files.get_base_dir(): {"bind": "/a0", "mode": "rw"},- files.get_abs_path("work_dir"): {"bind": "/root", "mode": "rw"},- }- )code_exec_ssh_enabled: bool = Truecode_exec_ssh_addr: str = "localhost"code_exec_ssh_port: int = 55022diff --git a/docker/run/fs/exe/run_A0.sh b/docker/run/fs/exe/run_A0.shindex b0d1fec50..16e4f115f 100644--- a/docker/run/fs/exe/run_A0.sh+++ b/docker/run/fs/exe/run_A0.sh@@ -10,9 +10,8 @@ echo "Starting A0..."exec python /a0/run_ui.py \--dockerized=true \--port=80 \- --host="0.0.0.0" \- --code_exec_docker_enabled=false \- --code_exec_ssh_enabled=true \+ --host="0.0.0.0"+ # --code_exec_ssh_enabled=true \# --code_exec_ssh_addr="localhost" \# --code_exec_ssh_port=22 \# --code_exec_ssh_user="root" \diff --git a/initialize.py b/initialize.pyindex 04fa0ea58..dd1441cfe 100644--- a/initialize.py+++ b/initialize.py@@ -79,19 +79,7 @@ def initialize_agent():memory_subdir=current_settings["agent_memory_subdir"],knowledge_subdirs=[current_settings["agent_knowledge_subdir"], "default"],mcp_servers=current_settings["mcp_servers"],- code_exec_docker_enabled=False,- # code_exec_docker_name = "A0-dev",- # code_exec_docker_image = "agent0ai/agent-zero:development",- # code_exec_docker_ports = { "22/tcp": 55022, "80/tcp": 55080 }- # code_exec_docker_volumes = {- # files.get_base_dir(): {"bind": "/a0", "mode": "rw"},- # files.get_abs_path("work_dir"): {"bind": "/root", "mode": "rw"},- # },- # code_exec_ssh_enabled = True,- # code_exec_ssh_addr = "localhost",- # code_exec_ssh_port = 55022,- # code_exec_ssh_user = "root",- # code_exec_ssh_pass = "",+ # code_exec params get initialized in _set_runtime_config# additional = {},)@@ -176,19 +164,3 @@ def _set_runtime_config(config: AgentConfig, set: settings.Settings):for key, value in ssh_conf.items():if hasattr(config, key):setattr(config, key, value)-- # if config.code_exec_docker_enabled:- # config.code_exec_docker_ports["22/tcp"] = ssh_conf["code_exec_ssh_port"]- # config.code_exec_docker_ports["80/tcp"] = ssh_conf["code_exec_http_port"]- # config.code_exec_docker_name = f"{config.code_exec_docker_name}-{ssh_conf['code_exec_ssh_port']}-{ssh_conf['code_exec_http_port']}"-- # dman = docker.DockerContainerManager(- # logger=log.Log(),- # name=config.code_exec_docker_name,- # image=config.code_exec_docker_image,- # ports=config.code_exec_docker_ports,- # volumes=config.code_exec_docker_volumes,- # )- # dman.start_container()-- # config.code_exec_ssh_pass = asyncio.run(rfc_exchange.get_root_password())diff --git a/python/api/rfc.py b/python/api/rfc.pyindex f2fa112d1..1faa0724f 100644--- a/python/api/rfc.py+++ b/python/api/rfc.py@@ -8,6 +8,10 @@ class RFC(ApiHandler):def requires_csrf(cls) -> bool:return False+ @classmethod+ def requires_auth(cls) -> bool:+ return False+async def process(self, input: dict, request: Request) -> dict | Response:result = await runtime.handle_rfc(input) # type: ignorereturn resultdiff --git a/python/helpers/settings.py b/python/helpers/settings.pyindex 421332952..8dbcbb4f8 100644--- a/python/helpers/settings.py+++ b/python/helpers/settings.py@@ -71,7 +71,6 @@ class Settings(TypedDict):memory_memorize_consolidation: boolmemory_memorize_replace_threshold: float-api_keys: dict[str, str]auth_login: str@@ -113,7 +112,15 @@ class SettingsField(TypedDict, total=False):title: strdescription: strtype: Literal[- "text", "number", "select", "range", "textarea", "password", "switch", "button", "html"+ "text",+ "number",+ "select",+ "range",+ "textarea",+ "password",+ "switch",+ "button",+ "html",]value: Anymin: float@@ -141,7 +148,6 @@ SETTINGS_FILE = files.get_abs_path("tmp/settings.json")_settings: Settings | None = None-def convert_out(settings: Settings) -> SettingsOutput:default_settings = get_default_settings()@@ -478,7 +484,7 @@ def convert_out(settings: Settings) -> SettingsOutput:"type": "number","value": settings["browser_model_rl_output"],}- )+ )browser_model_fields.append({@@ -498,7 +504,6 @@ def convert_out(settings: Settings) -> SettingsOutput:"tab": "agent",}-# basic auth sectionauth_fields: list[SettingsField] = []@@ -599,7 +604,8 @@ def convert_out(settings: Settings) -> SettingsOutput:"value": settings["agent_profile"],"options": [{"value": subdir, "label": subdir}- for subdir in files.get_subdirectories("agents") if subdir != "_example"+ for subdir in files.get_subdirectories("agents")+ if subdir != "_example"],})@@ -626,7 +632,6 @@ def convert_out(settings: Settings) -> SettingsOutput:"tab": "agent",}-memory_fields: list[SettingsField] = []memory_fields.append(@@ -856,6 +861,46 @@ def convert_out(settings: Settings) -> SettingsOutput:"tab": "developer",}+ # code_exec_fields: list[SettingsField] = []++ # code_exec_fields.append(+ # {+ # "id": "code_exec_ssh_enabled",+ # "title": "Use SSH for code execution",+ # "description": "Code execution will use SSH to connect to the terminal. When disabled, a local python terminal interface is used instead. SSH should only be used in development environment or when encountering issues with the local python terminal interface.",+ # "type": "switch",+ # "value": settings["code_exec_ssh_enabled"],+ # }+ # )++ # code_exec_fields.append(+ # {+ # "id": "code_exec_ssh_addr",+ # "title": "Code execution SSH address",+ # "description": "Address of the SSH server for code execution. Only applies when SSH is enabled.",+ # "type": "text",+ # "value": settings["code_exec_ssh_addr"],+ # }+ # )++ # code_exec_fields.append(+ # {+ # "id": "code_exec_ssh_port",+ # "title": "Code execution SSH port",+ # "description": "Port of the SSH server for code execution. Only applies when SSH is enabled.",+ # "type": "text",+ # "value": settings["code_exec_ssh_port"],+ # }+ # )++ # code_exec_section: SettingsSection = {+ # "id": "code_exec",+ # "title": "Code execution",+ # "description": "Configuration of code execution by the agent.",+ # "fields": code_exec_fields,+ # "tab": "developer",+ # }+# Speech to text sectionstt_fields: list[SettingsField] = []@@ -1085,6 +1130,7 @@ def convert_out(settings: Settings) -> SettingsOutput:mcp_server_section,backup_section,dev_section,+ # code_exec_section,]}return result@@ -1147,7 +1193,7 @@ def normalize_settings(settings: Settings) -> Settings:# adjust settings values to match current version if neededif "version" not in copy or copy["version"] != default["version"]:_adjust_to_version(copy, default)- copy["version"] = default["version"] # sync version+ copy["version"] = default["version"] # sync version# remove keys that are not in defaultkeys_to_remove = [key for key in copy if key not in default]@@ -1162,7 +1208,7 @@ def normalize_settings(settings: Settings) -> Settings:try:copy[key] = type(value)(copy[key]) # type: ignoreif isinstance(copy[key], str):- copy[key] = copy[key].strip() # strip strings+ copy[key] = copy[key].strip() # strip stringsexcept (ValueError, TypeError):copy[key] = value # make default instead@@ -1179,6 +1225,7 @@ def _adjust_to_version(settings: Settings, default: Settings):if "agent_profile" not in settings or settings["agent_profile"] == "default":settings["agent_profile"] = "agent0"+def _read_settings_file() -> Settings | None:if os.path.exists(SETTINGS_FILE):content = files.read_file(SETTINGS_FILE)@@ -1441,9 +1488,9 @@ def set_root_password(password: str):def get_runtime_config(set: Settings):if runtime.is_dockerized():return {+ "code_exec_ssh_enabled": False,"code_exec_ssh_addr": "localhost","code_exec_ssh_port": 22,- "code_exec_http_port": 80,"code_exec_ssh_user": "root",}else:@@ -1455,9 +1502,9 @@ def get_runtime_config(set: Settings):if host.endswith("/"):host = host[:-1]return {+ "code_exec_ssh_enabled": True,"code_exec_ssh_addr": host,"code_exec_ssh_port": set["rfc_port_ssh"],- "code_exec_http_port": set["rfc_port_http"],"code_exec_ssh_user": "root",}diff --git a/python/helpers/shell_local.py b/python/helpers/shell_local.pyindex e610e78ed..a43045c36 100644--- a/python/helpers/shell_local.py+++ b/python/helpers/shell_local.py@@ -3,70 +3,48 @@ import subprocessimport timeimport sysfrom typing import Optional, Tuple+from python.helpers import tty_session+from python.helpers.shell_ssh import clean_stringclass LocalInteractiveSession:def __init__(self):- self.process = None+ self.session: tty_session.TTYSession|None = Noneself.full_output = ''async def connect(self):- # Start a new subprocess with the appropriate shell for the OS- if sys.platform.startswith('win'):- # Windows- self.process = subprocess.Popen(- ['cmd.exe'],- stdin=subprocess.PIPE,- stdout=subprocess.PIPE,- stderr=subprocess.PIPE,- text=True,- bufsize=1- )- else:- # macOS and Linux- self.process = subprocess.Popen(- ['/bin/bash'],- stdin=subprocess.PIPE,- stdout=subprocess.PIPE,- stderr=subprocess.PIPE,- text=True,- bufsize=1- )+ self.session = tty_session.TTYSession("/bin/bash")+ await self.session.start()+ await self.session.read_full_until_idle(idle_timeout=1, total_timeout=1)- def close(self):- if self.process:- self.process.terminate()- self.process.wait()+ async def close(self):+ if self.session:+ self.session.kill()+ # self.session.wait()- def send_command(self, command: str):- if not self.process:+ async def send_command(self, command: str):+ if not self.session:raise Exception("Shell not connected")self.full_output = ""- self.process.stdin.write(command + '\n') # type: ignore- self.process.stdin.flush() # type: ignore+ await self.session.sendline(command)async def read_output(self, timeout: float = 0, reset_full_output: bool = False) -> Tuple[str, Optional[str]]:- if not self.process:+ if not self.session:raise Exception("Shell not connected")if reset_full_output:self.full_output = ""- partial_output = ''- start_time = time.time()-- while (timeout <= 0 or time.time() - start_time < timeout):- rlist, _, _ = select.select([self.process.stdout], [], [], 0.1)- if rlist:- line = self.process.stdout.readline() # type: ignore- if line:- partial_output += line- self.full_output += line- time.sleep(0.1)- else:- break # No more output- else:- break # No data available++ # get output from terminal+ partial_output = await self.session.read_full_until_idle(idle_timeout=0.01, total_timeout=timeout)+ self.full_output += partial_output++ # clean output+ partial_output = clean_string(partial_output)+ clean_full_output = clean_string(self.full_output)++ print("\n\n"+self.full_output.encode("unicode_escape").decode("ascii")+"\n\n")+if not partial_output:- return self.full_output, None-- return self.full_output, partial_output\ No newline at end of file+ return clean_full_output, None+ return clean_full_output, partial_output\ No newline at end of filediff --git a/python/helpers/shell_ssh.py b/python/helpers/shell_ssh.pyindex bdc5dfd51..4d4afe1c3 100644--- a/python/helpers/shell_ssh.py+++ b/python/helpers/shell_ssh.py@@ -28,11 +28,20 @@ class SSHInteractiveSession:self.last_command = b""self.trimmed_command_length = 0 # Initialize trimmed_command_length- async def connect(self):- # try 3 times with wait and then except+ async def connect(self, keepalive_interval: int = 5):+ """+ Establish the SSH connection and start an interactive shell.++ Parameters+ ----------+ keepalive_interval : int+ Interval in **seconds** between keep-alive packets sent by Paramiko.+ A value ≤ 0 disables Paramiko’s keep-alive feature.+ """errors = 0while True:try:+ # --- establish TCP/SSH session ---------------------------------self.client.connect(self.hostname,self.port,@@ -41,16 +50,25 @@ class SSHInteractiveSession:allow_agent=False,look_for_keys=False,)++ # --------- NEW: enable transport-level keep-alives -------------+ transport = self.client.get_transport()+ if transport and keepalive_interval > 0:+ # sends an SSH_MSG_IGNORE every <keepalive_interval> seconds+ transport.set_keepalive(keepalive_interval)+ # ----------------------------------------------------------------++ # invoke interactive shellself.shell = self.client.invoke_shell(width=100, height=50)- # self.shell.send(f'PS1="{SSHInteractiveSession.ps1_label}"'.encode())- # return- self.shell.send("stty -echo\n".encode()) # disable shell echo+ self.shell.send("stty -echo\n".encode()) # disable local echo- while True: # wait for end of initial output+ # wait for initial prompt/output to settle+ while True:full, part = await self.read_output()if full and not part:returntime.sleep(0.1)+except Exception as e:errors += 1if errors < 3:@@ -60,18 +78,17 @@ class SSHInteractiveSession:content=f"SSH Connection attempt {errors}...",temp=True,)-time.sleep(5)else:raise e- def close(self):+ async def close(self):if self.shell:self.shell.close()if self.client:self.client.close()- def send_command(self, command: str):+ async def send_command(self, command: str):if not self.shell:raise Exception("Shell not connected")self.full_output = b""@@ -137,8 +154,8 @@ class SSHInteractiveSession:decoded_partial_output = partial_output.decode("utf-8", errors="replace")decoded_full_output = self.full_output.decode("utf-8", errors="replace")- decoded_partial_output = self.clean_string(decoded_partial_output)- decoded_full_output = self.clean_string(decoded_full_output)+ decoded_partial_output = clean_string(decoded_partial_output)+ decoded_full_output = clean_string(decoded_full_output)return decoded_full_output, decoded_partial_output@@ -190,32 +207,34 @@ class SSHInteractiveSession:return data- def clean_string(self, input_string):- # Remove ANSI escape codes- ansi_escape = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])")- cleaned = ansi_escape.sub("", input_string)+def clean_string(input_string):+ # Remove ANSI escape codes+ ansi_escape = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])")+ cleaned = ansi_escape.sub("", input_string)- # remove null bytes- cleaned = cleaned.replace("\x00", "")+ # remove null bytes+ cleaned = cleaned.replace("\x00", "")- # remove ipython \r\r\n> sequences from the start- cleaned = re.sub(r'^[ \r]*(?:\r*\n>[ \r]*)*', '', cleaned)+ # remove ipython \r\r\n> sequences from the start+ cleaned = re.sub(r'^[ \r]*(?:\r*\n>[ \r]*)*', '', cleaned)+ # also remove any amount of '> ' sequences from the start+ cleaned = re.sub(r'^(>\s*)+', '', cleaned)- # Replace '\r\n' with '\n'- cleaned = cleaned.replace("\r\n", "\n")+ # Replace '\r\n' with '\n'+ cleaned = cleaned.replace("\r\n", "\n")- # remove leading \r and spaces- cleaned = cleaned.lstrip("\r ")+ # remove leading \r and spaces+ cleaned = cleaned.lstrip("\r ")- # Split the string by newline characters to process each segment separately- lines = cleaned.split("\n")+ # Split the string by newline characters to process each segment separately+ lines = cleaned.split("\n")- for i in range(len(lines)):- # Handle carriage returns '\r' by splitting and taking the last part- parts = [part for part in lines[i].split("\r") if part.strip()]- if parts:- lines[i] = parts[- -1- ].rstrip() # Overwrite with the last part after the last '\r'+ for i in range(len(lines)):+ # Handle carriage returns '\r' by splitting and taking the last part+ parts = [part for part in lines[i].split("\r") if part.strip()]+ if parts:+ lines[i] = parts[+ -1+ ].rstrip() # Overwrite with the last part after the last '\r'- return "\n".join(lines)+ return "\n".join(lines)diff --git a/python/helpers/tty_session.py b/python/helpers/tty_session.pyindex 48031501a..9a8bc3359 100644--- a/python/helpers/tty_session.py+++ b/python/helpers/tty_session.py@@ -15,9 +15,7 @@ sys.stdout.reconfigure(errors="replace") # type: ignoreclass TTYSession:- def __init__(- self, cmd, *, cwd=None, env=None, encoding="utf-8", echo=False- ): # ← NEW kw-arg `echo`+ def __init__(self, cmd, *, cwd=None, env=None, encoding="utf-8", echo=False):self.cmd = cmd if isinstance(cmd, str) else " ".join(cmd)self.cwd = cwdself.env = env or os.environ.copy()@@ -26,6 +24,17 @@ class TTYSession:self._proc = Noneself._buf = asyncio.Queue()+ def __del__(self):+ # Simple cleanup on object destruction+ import nest_asyncio++ nest_asyncio.apply()+ if hasattr(self, "close"):+ try:+ asyncio.run(self.close())+ except Exception:+ pass+# ── user-facing coroutines ────────────────────────────────────────async def start(self):if _IS_WIN:@@ -36,7 +45,22 @@ class TTYSession:self._proc = await _spawn_posix_pty(self.cmd, self.cwd, self.env, self.echo) # ← pass echo- asyncio.create_task(self._pump_stdout())+ self._pump_task = asyncio.create_task(self._pump_stdout())++ async def close(self):+ # Cancel the pump task if it exists+ if hasattr(self, "_pump_task") and self._pump_task:+ self._pump_task.cancel()+ try:+ await self._pump_task+ except asyncio.CancelledError:+ pass+ # Terminate the process if it exists+ if self._proc:+ self._proc.terminate()+ await self._proc.wait()+ self._proc = None+ self._pump_task = Noneasync def send(self, data: str | bytes):if self._proc is None:diff --git a/python/tools/code_execution_tool.py b/python/tools/code_execution_tool.pyindex b2487fd31..18d6f8c93 100644--- a/python/tools/code_execution_tool.py+++ b/python/tools/code_execution_tool.py@@ -16,7 +16,6 @@ import re@dataclassclass State:shells: dict[int, LocalInteractiveSession | SSHInteractiveSession]- docker: DockerContainerManager | Noneclass CodeExecution(Tool):@@ -25,10 +24,6 @@ class CodeExecution(Tool):await self.agent.handle_intervention() # wait for intervention and handle it, if paused- await self.prepare_state()-- # os.chdir(files.get_abs_path("./work_dir")) #change CWD to work_dir-runtime = self.args.get("runtime", "").lower().strip()session = int(self.args.get("session", 0))@@ -80,59 +75,48 @@ class CodeExecution(Tool):async def after_execution(self, response, **kwargs):self.agent.hist_add_tool_result(self.name, response.message)- async def prepare_state(self, reset=False, session=None):- self.state = self.agent.get_data("_cet_state")- if not self.state or reset:-- # initialize docker container if execution in docker is configured- if not self.state and self.agent.config.code_exec_docker_enabled:- docker = DockerContainerManager(- logger=self.agent.context.log,- name=self.agent.config.code_exec_docker_name,- image=self.agent.config.code_exec_docker_image,- ports=self.agent.config.code_exec_docker_ports,- volumes=self.agent.config.code_exec_docker_volumes,+ async def prepare_state(self, reset=False, session: int | None = None):+ self.state: State | None = self.agent.get_data("_cet_state")+ if not self.state:+ # initialize shells dictionary if not exists+ shells: dict[int, LocalInteractiveSession | SSHInteractiveSession] = {}+ else:+ shells = self.state.shells.copy()++ # Only reset the specified session if provided+ if reset and session is not None and session in shells:+ await shells[session].close()+ del shells[session]+ elif reset and not session:+ # Close all sessions if full reset requested+ for s in list(shells.keys()):+ await shells[s].close()+ shells = {}++ # initialize local or remote interactive shell interface for session 0 if needed+ if session is not None and session not in shells:+ if self.agent.config.code_exec_ssh_enabled:+ pswd = (+ self.agent.config.code_exec_ssh_pass+ if self.agent.config.code_exec_ssh_pass+ else await rfc_exchange.get_root_password()+ )+ shell = SSHInteractiveSession(+ self.agent.context.log,+ self.agent.config.code_exec_ssh_addr,+ self.agent.config.code_exec_ssh_port,+ self.agent.config.code_exec_ssh_user,+ pswd,)- docker.start_container()else:- docker = self.state.docker if self.state else None-- # initialize shells dictionary if not exists- shells = {} if not self.state else self.state.shells.copy()-- # Only reset the specified session if provided- if session is not None and session in shells:- shells[session].close()- del shells[session]- elif reset and not session:- # Close all sessions if full reset requested- for s in list(shells.keys()):- shells[s].close()- shells = {}-- # initialize local or remote interactive shell interface for session 0 if needed- if 0 not in shells:- if self.agent.config.code_exec_ssh_enabled:- pswd = (- self.agent.config.code_exec_ssh_pass- if self.agent.config.code_exec_ssh_pass- else await rfc_exchange.get_root_password()- )- shell = SSHInteractiveSession(- self.agent.context.log,- self.agent.config.code_exec_ssh_addr,- self.agent.config.code_exec_ssh_port,- self.agent.config.code_exec_ssh_user,- pswd,- )- else:- shell = LocalInteractiveSession()+ shell = LocalInteractiveSession()- shells[0] = shell- await shell.connect()+ shells[session] = shell+ await shell.connect()- self.state = State(shells=shells, docker=docker)+ self.state = State(shells=shells)self.agent.set_data("_cet_state", self.state)+ return self.stateasync def execute_python_code(self, session: int, code: str, reset: bool = False):escaped_code = shlex.quote(code)@@ -156,45 +140,35 @@ class CodeExecution(Tool):self, session: int, command: str, reset: bool = False, prefix: str = ""):+ self.state = await self.prepare_state(reset=reset, session=session)+await self.agent.handle_intervention() # wait for intervention and handle it, if paused# try again on lost connectionfor i in range(2):try:- if reset:- await self.reset_terminal()-- if session not in self.state.shells:- if self.agent.config.code_exec_ssh_enabled:- pswd = (- self.agent.config.code_exec_ssh_pass- if self.agent.config.code_exec_ssh_pass- else await rfc_exchange.get_root_password()- )- shell = SSHInteractiveSession(- self.agent.context.log,- self.agent.config.code_exec_ssh_addr,- self.agent.config.code_exec_ssh_port,- self.agent.config.code_exec_ssh_user,- pswd,- )- else:- shell = LocalInteractiveSession()- self.state.shells[session] = shell- await shell.connect()-- self.state.shells[session].send_command(command)+ await self.state.shells[session].send_command(command)++ locl = (+ " (local)"+ if isinstance(self.state.shells[session], LocalInteractiveSession)+ else (+ " (remote)"+ if isinstance(self.state.shells[session], SSHInteractiveSession)+ else " (unknown)"+ )+ )PrintStyle(background_color="white", font_color="#1B4F72", bold=True- ).print(f"{self.agent.agent_name} code execution output")+ ).print(f"{self.agent.agent_name} code execution output{locl}")return await self.get_terminal_output(session=session, prefix=prefix)except Exception as e:if i == 1:# try again on lost connectionPrintStyle.error(str(e))- await self.prepare_state(reset=True)+ await self.prepare_state(reset=True, session=session)continueelse:raise e@@ -221,6 +195,10 @@ class CodeExecution(Tool):sleep_time=0.1,prefix="",):++ # if not self.state:+ self.state = await self.prepare_state(session=session)+# Common shell prompt regex patterns (add more as needed)prompt_patterns = [re.compile(r"\\(venv\\).+[$#] ?$"), # (venv) ...$ or (venv) ...#diff --git a/webui/components/messages/action-buttons/simple-action-buttons.js b/webui/components/messages/action-buttons/simple-action-buttons.jsindex 2e26b993b..4aff4e56f 100644--- a/webui/components/messages/action-buttons/simple-action-buttons.js+++ b/webui/components/messages/action-buttons/simple-action-buttons.js@@ -9,6 +9,11 @@ function getTextContent(element) {for (const child of element.children) {// Skip action buttonsif (child.classList.contains("action-buttons")) continue;+ // If the child is an image, copy its src URL+ if (child.tagName && child.tagName.toLowerCase() === "img") {+ if (child.src) textParts.push(child.src);+ continue;+ }// Get text content from the childconst text = child.innerText || "";if (text.trim()) {diff --git a/webui/public/code_exec.svg b/webui/public/code_exec.svgnew file mode 100644index 000000000..b7410623f--- /dev/null+++ b/webui/public/code_exec.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e8eaed"><path d="M192-212q-26 0-43-17t-17-43v-416q0-26 17-43t43-17h576q26 0 43 17t17 43v416q0 26-17 43t-43 17H192Zm0-28h576q12 0 22-10t10-22v-368H160v368q0 12 10 22t22 10Zm108-77-19-19 103-104-104-104 20-19 123 123-123 123Zm206 11v-28h188v28H506Z"/></svg>\ No newline at end of file