<?php

declare(strict_types=1);

namespace Blax\WebRtc\Realtime;

/**
 * The result of one realtime AI turn: the spoken reply as raw PCM16 (mono 24kHz,
 * the provider's wire format), its transcript, an error if the turn failed, and a
 * per-event-type tally for diagnostics.
 */
final class RealtimeTurn
{
    /** @param array<string,int> $events event type => count */
    public function __construct(
        public readonly string $pcm = '',
        public readonly string $transcript = '',
        public readonly ?string $error = null,
        public readonly array $events = [],
    ) {}

    public function ok(): bool
    {
        return $this->error === null && $this->pcm !== '';
    }
}
