import resource import subprocess import time import llm TRICU_PATH = "/usr/local/bin/tricu" def tricubridge(input: str) -> str: try: result = subprocess.run( [TRICU_PATH, "eval", "+RTS", "-M250M", "-RTS"], input=input, capture_output=True, text=True, check=True, ) if len(result.stdout) > 2000: return "Output too large; limited to 2000 chars." else: return result.stdout.strip() except subprocess.CalledProcessError as e: return f"Error executing Tricu code: {e.stderr or str(e)}" except Exception as e: return f"Unexpected error: {str(e)}" @llm.hookimpl def register_tools(register): register(tricubridge)