Agent Zero AI framework
fix: restore RFC SSH defaults for dockerized dev sessions
linuztx7da508d1cd74
diff --git a/plugins/code_execution/default_config.yaml b/plugins/code_execution/default_config.yamlindex d4d8f0307..50968a9f1 100644--- a/plugins/code_execution/default_config.yaml+++ b/plugins/code_execution/default_config.yaml@@ -1,10 +1,13 @@-# Shell interface: false = local TTY, true = SSH-ssh_enabled: false+# Shell interface: auto = auto-detect (SSH when non-dockerized, local when dockerized),+# true = always SSH, false = always local TTY+ssh_enabled: auto-# SSH credentials (used when ssh_enabled is true)-ssh_addr: localhost-ssh_port: 22+# SSH credentials (used when ssh_enabled is true or auto-detected)+# ssh_addr: derived from rfc_url setting when empty+ssh_addr: ""+ssh_port: 55022ssh_user: root+# ssh_pass: uses root_password from RFC exchange when emptyssh_pass: ""# Timeouts for python/nodejs/terminal runtimes (seconds)diff --git a/plugins/code_execution/tools/code_execution_tool.py b/plugins/code_execution/tools/code_execution_tool.pyindex cae33a230..d44b80b38 100644--- a/plugins/code_execution/tools/code_execution_tool.py+++ b/plugins/code_execution/tools/code_execution_tool.py@@ -5,7 +5,7 @@ import shleximport timefrom helpers.tool import Tool, Response-from helpers import files, projects, runtime, settings+from helpers import files, rfc_exchange, projects, runtime, settingsfrom helpers.print_style import PrintStylefrom helpers.strings import truncate_text as truncate_text_stringfrom helpers.messages import truncate_text as truncate_text_agent@@ -15,15 +15,46 @@ from plugins.code_execution.helpers.shell_local import LocalInteractiveSessionfrom plugins.code_execution.helpers.shell_ssh import SSHInteractiveSession+def _resolve_ssh_enabled(raw_value) -> bool:+ """Resolve ssh_enabled: 'auto' detects based on dockerized state."""+ val = str(raw_value).strip().lower()+ if val == "auto":+ return not runtime.is_dockerized()+ return val in ("true", "1", "yes", "on")+++def _resolve_ssh_addr(cfg_addr: str) -> str:+ """Resolve SSH address: fall back to rfc_url from settings when empty."""+ if cfg_addr:+ return cfg_addr+ set = settings.get_settings()+ host = set.get("rfc_url", "localhost")+ # Strip protocol and port from URL+ if "//" in host:+ host = host.split("//")[1]+ if ":" in host:+ host = host.split(":")[0]+ if host.endswith("/"):+ host = host.rstrip("/")+ return host or "localhost"+++async def _resolve_ssh_pass(cfg_pass: str) -> str:+ """Resolve SSH password: fall back to root_password via RFC when empty."""+ if cfg_pass:+ return cfg_pass+ return await rfc_exchange.get_root_password()++def _get_config(agent) -> dict:cfg = plugins.get_plugin_config("code_execution", agent=agent) or {}- # SSH / TTY switch- ssh_enabled = bool(cfg.get("ssh_enabled", False))+ # SSH / TTY switch (supports auto/true/false)+ ssh_enabled = _resolve_ssh_enabled(cfg.get("ssh_enabled", "auto"))- # SSH credentials- ssh_addr = str(cfg.get("ssh_addr", "localhost"))- ssh_port = int(cfg.get("ssh_port", 22))+ # SSH credentials (with RFC fallbacks)+ ssh_addr = _resolve_ssh_addr(str(cfg.get("ssh_addr", "")))+ ssh_port = int(cfg.get("ssh_port", 55022))ssh_user = str(cfg.get("ssh_user", "root"))ssh_pass = str(cfg.get("ssh_pass", ""))@@ -186,12 +217,13 @@ class CodeExecution(Tool):if session is not None and session not in shells:cwd = await self.ensure_cwd()if ssh_enabled:+ ssh_pass = await _resolve_ssh_pass(cfg["ssh_pass"])shell = SSHInteractiveSession(self.agent.context.log,cfg["ssh_addr"],cfg["ssh_port"],cfg["ssh_user"],- cfg["ssh_pass"],+ ssh_pass,cwd=cwd,)else:diff --git a/plugins/code_execution/webui/config.html b/plugins/code_execution/webui/config.htmlindex 56fc69be4..f6ae0b362 100644--- a/plugins/code_execution/webui/config.html+++ b/plugins/code_execution/webui/config.html@@ -15,36 +15,38 @@<!-- Shell Interface --><div class="field"><div class="field-label">- <div class="field-title">Use SSH</div>+ <div class="field-title">Shell Interface</div><div class="field-description">- When enabled, code execution connects via SSH using the credentials below. When disabled, a local Python TTY is used.+ <b>Auto</b>: SSH when running outside Docker, local TTY when dockerized.+ <b>SSH</b>: always connect via SSH. <b>Local</b>: always use local PTY.</div></div><div class="field-control">- <label class="toggle">- <input type="checkbox" x-model="$store.pluginSettings.settings.ssh_enabled" />- <span class="toggler"></span>- </label>+ <select x-model="$store.pluginSettings.settings.ssh_enabled">+ <option value="auto">Auto</option>+ <option value="true">SSH</option>+ <option value="false">Local TTY</option>+ </select></div></div>- <!-- SSH credentials (shown only when SSH is enabled) -->- <template x-if="$store.pluginSettings.settings.ssh_enabled">+ <!-- SSH credentials (shown when SSH or Auto) -->+ <template x-if="$store.pluginSettings.settings.ssh_enabled !== 'false'"><div><div class="field"><div class="field-label"><div class="field-title">SSH Address</div>- <div class="field-description">Hostname or IP of the SSH target.</div>+ <div class="field-description">Hostname or IP of the SSH target. Leave empty to use the RFC URL from settings.</div></div><div class="field-control">- <input type="text" x-model="$store.pluginSettings.settings.ssh_addr" placeholder="localhost" />+ <input type="text" x-model="$store.pluginSettings.settings.ssh_addr" placeholder="(from RFC URL)" /></div></div><div class="field"><div class="field-label"><div class="field-title">SSH Port</div>- <div class="field-description">SSH port on the target host.</div>+ <div class="field-description">SSH port on the target host (default: 55022 for Docker RFC).</div></div><div class="field-control"><input type="number" min="1" max="65535" x-model.number="$store.pluginSettings.settings.ssh_port" />@@ -64,10 +66,10 @@<div class="field"><div class="field-label"><div class="field-title">SSH Password</div>- <div class="field-description">Password for SSH login.</div>+ <div class="field-description">Password for SSH login. Leave empty to use the dev root password (via RFC).</div></div><div class="field-control">- <input type="password" autocomplete="off" x-model="$store.pluginSettings.settings.ssh_pass" />+ <input type="password" autocomplete="off" x-model="$store.pluginSettings.settings.ssh_pass" placeholder="(from RFC)" /></div></div></div>