Fixed Runaway Agent Supervisor Event

This commit is contained in:
2025-09-04 15:30:27 -06:00
parent f905a50501
commit ee7c6f3062
4 changed files with 233 additions and 11 deletions

View File

@@ -1065,6 +1065,8 @@ async def _run_powershell_via_user_task(content: str):
ps = "powershell.exe"
else:
return -999, '', 'Windows only'
path = None
out_path = None
try:
temp_dir = os.path.join(os.path.dirname(__file__), '..', '..', 'Temp')
temp_dir = os.path.abspath(temp_dir)
@@ -1110,6 +1112,18 @@ Get-ScheduledTask -TaskName $task | Out-Null
return 0, out_data or '', ''
except Exception as e:
return -999, '', str(e)
finally:
# Best-effort cleanup of temp script and output files
try:
if path and os.path.isfile(path):
os.remove(path)
except Exception:
pass
try:
if out_path and os.path.isfile(out_path):
os.remove(out_path)
except Exception:
pass
# ---------------- Dummy Qt Widget to Prevent Exit ----------------
class PersistentWindow(QtWidgets.QWidget):