mirror of
https://github.com/myronblair/jarvis
synced 2026-06-30 17:50:23 -05:00
agent: v3.0 — fix cfg scope bug in execute_command (update + shell commands)
self_update(cfg) and shell allow_shell_commands check both referenced cfg from run() scope, but execute_command() is a standalone function. Fixed by calling load_config() locally in each branch that needs it.
This commit is contained in:
@@ -525,12 +525,14 @@ def execute_command(cmd: dict) -> dict:
|
||||
return {"success": r.returncode == 0, "output": r.stdout}
|
||||
|
||||
elif cmd_type == "update":
|
||||
updated = self_update(cfg)
|
||||
_cfg = load_config()
|
||||
updated = self_update(_cfg)
|
||||
return {"success": True, "updated": updated}
|
||||
|
||||
elif cmd_type == "shell":
|
||||
# Guard reads LOCAL config, not the server-supplied payload
|
||||
if not cfg.get("allow_shell_commands", False):
|
||||
_cfg = load_config()
|
||||
if not _cfg.get("allow_shell_commands", False):
|
||||
return {"success": False, "error": "Shell commands not enabled in agent config"}
|
||||
cmd_str = cmd_data.get("command", "")
|
||||
r = subprocess.run(cmd_str, shell=True, capture_output=True, text=True, timeout=30)
|
||||
|
||||
Reference in New Issue
Block a user