<?php

declare(strict_types=1);

namespace Drupal\flowdrop\Service\Reasoning;

use Drupal\flowdrop\DTO\Reason\ModelChoices;
use Drupal\flowdrop\DTO\Reason\ReasonRequest;
use Drupal\flowdrop\DTO\Reason\ReasonResult;

/**
 * The default reasoner when no AI backend is installed.
 *
 * Keeps core self-contained: a Reason node can be placed, validated and
 * type-checked with no AI provider present. Installing a backend module (e.g.
 * the `drupal/ai` binding) overrides `flowdrop.chat_reasoner` with a working
 * implementation. Attempting to actually reason without one is a clear, loud
 * error rather than a fatal on a missing service.
 */
final class NullChatReasoner implements ChatReasonerInterface {

  /**
   * {@inheritdoc}
   */
  public function reason(ReasonRequest $request): ReasonResult {
    throw new \RuntimeException('No AI backend is available to reason. Install and configure an AI provider module that supplies a flowdrop.chat_reasoner implementation.');
  }

  /**
   * {@inheritdoc}
   */
  public function getModelChoices(string $operationType = 'chat'): ModelChoices {
    return new ModelChoices();
  }

}
