Spaces:
Running

linko / app.py
linko10's picture
Upload 3 files
24ddcb9 verified
Raw History Blame Contribute Delete
2.28 kB
import gradio as gr
import subprocess
import os
import threading
import spaces
@spaces.GPU
def run_command(cmd):
try:
cmd_str = cmd.strip()
# أمر خاص لعرض السجلات الحية خلف الكواليس
if cmd_str == "logs":
if os.path.exists("hunter_output.log"):
with open("hunter_output.log", "r") as f:
lines = f.readlines()
return "".join(lines[-30:]) # آخر 30 سطر
else:
return "[-] No logs found yet. Make sure the hunter script is running."
# أمر لعرض العمليات النشطة
if cmd_str == "status":
result = subprocess.run("ps aux | grep python", shell=True, capture_output=True, text=True)
return f"Active Python Processes:\n{result.stdout}"
if "run_hunter_cloud.py" in cmd_str or "python" in cmd_str:
process = subprocess.Popen(cmd_str, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
return f"[+] Background hunting engine launched successfully! (PID: {process.pid})\nType 'logs' in command box to see real-time progress."
result = subprocess.run(cmd_str, shell=True, capture_output=True, text=True, timeout=15)
return f"STDOUT:\n{result.stdout}\nSTDERR:\n{result.stderr}"
except Exception as e:
return f"Error: {str(e)}"
def start_background_task():
os.system("echo '[*] Linko Sovereign Agent Online' > agent_log.txt")
threading.Thread(target=start_background_task, daemon=True).start()
def agent_interface(command):
if not command.strip():
return "Linko Sovereign Agent is ACTIVE. Type 'logs' or 'status' to monitor background workers."
return run_command(command)
demo = gr.Interface(
fn=agent_interface,
inputs=gr.Textbox(label="Remote Command (Bash / Python / logs / status)", placeholder="e.g. logs"),
outputs=gr.Textbox(label="Execution Output"),
title="🤖 Linko Sovereign Cloud Agent",
description="Remote execution node controlled by Linko Sovereign core. Type 'logs' to see live hunting speed."
)
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0", server_port=7860)