from sinapsis_core.data_containers.data_packet import DataContainer

from sinapsis_chat_history.templates.chat_history_base import ChatHistoryBase


class ChatHistoryReset(ChatHistoryBase):
    """Reset chat history storage by dropping and recreating the table.

    Warning: This is a destructive operation that permanently erases all chat
    history for the configured backend table.

    Usage example:
    agent:
      name: my_test_agent
    templates:
    - template_name: InputTemplate
      class_name: InputTemplate
      attributes: {}
    - template_name: ChatHistoryReset
      class_name: ChatHistoryReset
      template_input: InputTemplate
      attributes:
        provider: sqlite
        db_config:
          db_path: "chat_history.sqlite3"
          table: "chat"
    """

    def execute(self, container: DataContainer) -> DataContainer:
        """Reset the configured chat history table.

        Args:
            container (DataContainer): Incoming container, unused by the reset
                logic.

        Returns:
            DataContainer: The same container passed in, unmodified.
        """
        self.db.reset()
        return container
