47 lines
1.8 KiB
Python
Raw Normal View History

2025-11-04 05:17:27 +01:00
import json
from typing import Dict, Any
from pr.ui.colors import Colors
def display_tool_call(tool_name, arguments, status="running", result=None):
status_icons = {
"running": ("", Colors.YELLOW),
"success": ("", Colors.GREEN),
"error": ("", Colors.RED)
}
icon, color = status_icons.get(status, ("", Colors.WHITE))
print(f"\n{Colors.BOLD}{'' * 80}{Colors.RESET}")
print(f"{color}{icon} {Colors.BOLD}{Colors.CYAN}TOOL: {tool_name}{Colors.RESET}")
print(f"{Colors.BOLD}{'' * 80}{Colors.RESET}")
if arguments:
print(f"{Colors.YELLOW}Parameters:{Colors.RESET}")
for key, value in arguments.items():
value_str = str(value)
if len(value_str) > 100:
value_str = value_str[:100] + "..."
print(f" {Colors.CYAN}{key}:{Colors.RESET} {value_str}")
if result is not None and status != "running":
print(f"\n{Colors.YELLOW}Result:{Colors.RESET}")
result_str = json.dumps(result, indent=2) if isinstance(result, dict) else str(result)
if len(result_str) > 500:
result_str = result_str[:500] + f"\n{Colors.GRAY}... (truncated){Colors.RESET}"
if status == "success":
print(f"{Colors.GREEN}{result_str}{Colors.RESET}")
elif status == "error":
print(f"{Colors.RED}{result_str}{Colors.RESET}")
else:
print(result_str)
print(f"{Colors.BOLD}{'' * 80}{Colors.RESET}\n")
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")