<?php

declare(strict_types=1);

namespace App\Eval;

use App\Eval\Dto\EvalCase;
use App\Eval\Dto\EvalResult;

final readonly class AgentEvalRunner
{
    public function __construct(
        private RetrievalDebugRunner $retrievalDebugRunner,
    ) {
    }

    public function run(EvalCase $case): EvalResult
    {
        if ($case->isRetrievalCase()) {
            return $this->retrievalDebugRunner->run($case);
        }

        throw new \InvalidArgumentException(sprintf(
            'Unsupported eval case type: %s',
            $case->type
        ));
    }

    /**
     * @param array<int, EvalCase> $cases
     * @return array<int, EvalResult>
     */
    public function runAll(array $cases): array
    {
        $results = [];

        foreach ($cases as $case) {
            $results[] = $this->run($case);
        }

        return $results;
    }
}