<?php

declare(strict_types=1);

namespace [namespace];

use NeuronAI\Workflow\Events\Event;
use NeuronAI\Workflow\Middleware\WorkflowMiddleware;
use NeuronAI\Workflow\NodeInterface;
use NeuronAI\Workflow\WorkflowState;

class [classname] implements WorkflowMiddleware
{
    /**
     * Execute before the node runs.
     *
     * This method is called before the node's __invoke method executes.
     * Use this for validation, logging, state preparation, etc.
     *
     * @param NodeInterface $node The node about to execute
     * @param Event $event The event being processed
     * @param WorkflowState $state The current workflow state
     */
    public function before(NodeInterface $node, Event $event, WorkflowState $state): void
    {
        // Implement before-node logic here
    }

    /**
     * Execute after the node runs.
     *
     * This method is called after the node's __invoke method completes.
     * For streaming nodes that return Generators, this is called after
     * the generator is fully consumed and the final Event is available.
     *
     * @param NodeInterface $node The node that executed
     * @param Event $result The final result event returned by the node
     * @param WorkflowState $state The current workflow state
     */
    public function after(NodeInterface $node, Event $result, WorkflowState $state): void
    {
        // Implement after-node logic here
    }
}
