"""Command runner: dispatch by mime type to docx/xlsx/pptx engine. No fallback.""" import logging from typing import Any from app.engine.docx_editor import apply_commands_docx logger = logging.getLogger(__name__) DOCX_MIME = "application/vnd.openxmlformats-officedocument.wordprocessingml.document" XLSX_MIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" PPTX_MIME = "application/vnd.openxmlformats-officedocument.presentationml.presentation" def apply_commands(content: bytes, mime_type: str, commands: list[dict[str, Any]]) -> bytes: """ Apply commands to document content. Returns new content. Raises ValueError for unknown mime or command type. """ if mime_type == DOCX_MIME: return apply_commands_docx(content, commands) if mime_type == XLSX_MIME: raise ValueError("xlsx commands not implemented yet") if mime_type == PPTX_MIME: raise ValueError("pptx commands not implemented yet") raise ValueError(f"Unsupported mime type for commands: {mime_type}")