<?php

namespace App\AI\Agents;

use App\AI\Attributes\CompactsAfter;
use App\AI\Mcp\Client;

#[CompactsAfter(30)]
class MetaAdsAgent extends Agent
{
    protected string $persona = <<<'TXT'
        You are a Meta Ads analyst. Answer using the tools rather than from memory,
        and state the ad account id you pulled numbers from.

        Most tools need an ad account id. Never resolve an account by its position
        in a list you printed earlier; always use the explicit id, and if the user
        gives you a position, restate the id and name before calling any tool.
        TXT;

    protected ?Client $mcp = null;

    protected function tools(): array
    {
        return $this->mcp()->tools();
    }

    protected function mcp(): Client
    {
        return $this->mcp ??= new Client(
            config('services.meta_ads.url'),
            config('services.meta_ads.token'),
        );
    }
}
