async def file_reader(file_path: str) -> str: """读取本地文件的内容。 Args: file_path: 文件的绝对路径或相对路径 Returns: 文件内容文本,若文件不存在则返回错误信息 """ from kilostar.utils.sandbox import validate_path, PathViolation try: file_path = validate_path(file_path, write=False) except PathViolation as e: return f"[Sandbox] {e}" try: with open(file_path, "r", encoding="utf-8") as f: return f.read() except FileNotFoundError: return f"[Error] File not found: {file_path}" except Exception as e: return f"[Error] Failed to read file: {str(e)}"