from __future__ import annotations

from app.core.agent.processes.v1.workflow.flow_main.context import V1FlowContext
from app.core.agent.utils.workflow import WorkflowStep


class PrepareUserMessageStep(WorkflowStep[V1FlowContext]):
    step_id = "prepare_user_message"
    title = "Подготовка сообщения"

    async def run(self, context: V1FlowContext) -> V1FlowContext:
        context.prepared_message = context.runtime.request.message.strip()
        return context

    def trace_output(self, context: V1FlowContext) -> dict[str, object]:
        return {"prepared_message_length": len(context.prepared_message)}
