59 lines
2.2 KiB
Python
59 lines
2.2 KiB
Python
|
|
from rp.ui.colors import Colors
|
||
|
|
|
||
|
|
|
||
|
|
def display_tool_call(tool_name, arguments, status="running", result=None):
|
||
|
|
if status == "running":
|
||
|
|
return
|
||
|
|
args_str = ", ".join([f"{k}={str(v)[:20]}" for k, v in list(arguments.items())[:2]])
|
||
|
|
line = f"{tool_name}({args_str})"
|
||
|
|
if len(line) > 80:
|
||
|
|
line = line[:77] + "..."
|
||
|
|
print(f"{Colors.GRAY}{line}{Colors.RESET}")
|
||
|
|
|
||
|
|
|
||
|
|
def print_autonomous_header(task):
|
||
|
|
print(f"{Colors.BOLD}Task:{Colors.RESET} {task}")
|
||
|
|
print(f"{Colors.GRAY}r will work continuously until the task is complete.{Colors.RESET}")
|
||
|
|
print(f"{Colors.GRAY}Press Ctrl+C twice to interrupt.{Colors.RESET}\n")
|
||
|
|
print(f"{Colors.BOLD}{'═' * 80}{Colors.RESET}\n")
|
||
|
|
|
||
|
|
|
||
|
|
def display_multiplexer_status(sessions):
|
||
|
|
"""Display the status of background sessions."""
|
||
|
|
if not sessions:
|
||
|
|
print(f"{Colors.GRAY}No background sessions running{Colors.RESET}")
|
||
|
|
return
|
||
|
|
print(f"\n{Colors.BOLD}Background Sessions:{Colors.RESET}")
|
||
|
|
print(f"{Colors.GRAY}{'─' * 60}{Colors.RESET}")
|
||
|
|
for session_name, session_info in sessions.items():
|
||
|
|
status = session_info.get("status", "unknown")
|
||
|
|
pid = session_info.get("pid", "N/A")
|
||
|
|
command = session_info.get("command", "N/A")
|
||
|
|
status_color = {"running": Colors.GREEN, "stopped": Colors.RED, "error": Colors.RED}.get(
|
||
|
|
status, Colors.YELLOW
|
||
|
|
)
|
||
|
|
print(f" {Colors.CYAN}{session_name}{Colors.RESET}")
|
||
|
|
print(f" Status: {status_color}{status}{Colors.RESET}")
|
||
|
|
print(f" PID: {pid}")
|
||
|
|
print(f" Command: {command}")
|
||
|
|
if "start_time" in session_info:
|
||
|
|
import time
|
||
|
|
|
||
|
|
elapsed = time.time() - session_info["start_time"]
|
||
|
|
print(f" Running for: {elapsed:.1f}s")
|
||
|
|
print()
|
||
|
|
|
||
|
|
|
||
|
|
def display_background_event(event):
|
||
|
|
"""Display a background event."""
|
||
|
|
event.get("type", "unknown")
|
||
|
|
session_name = event.get("session_name", "unknown")
|
||
|
|
timestamp = event.get("timestamp", 0)
|
||
|
|
message = event.get("message", "")
|
||
|
|
import datetime
|
||
|
|
|
||
|
|
time_str = datetime.datetime.fromtimestamp(timestamp).strftime("%H:%M:%S")
|
||
|
|
print(
|
||
|
|
f"{Colors.GRAY}[{time_str}]{Colors.RESET} {Colors.CYAN}{session_name}{Colors.RESET}: {message}"
|
||
|
|
)
|