<?php
/**
 * Hello-world ability — proves the registrar + mcp-adapter wiring works
 * end-to-end without touching any post or user data.
 *
 * @package Ppok\AIToolkit
 * @license GPL-2.0-or-later
 */

namespace Ppok\AIToolkit\Abilities;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

final class System_Ping {

	public const SLUG = 'ppok/ping';

	public static function descriptor(): array {
		return array(
			'label'               => __( 'Ping the Ppok AI Toolkit', 'ppok-ai-toolkit' ),
			'description'         => __( 'Returns the site name and the plugin version. Read-only. Use to verify that the abilities surface is reachable.', 'ppok-ai-toolkit' ),
			'category'            => 'ppok',
			'input_schema'        => array(
				'type'       => 'object',
				'properties' => new \stdClass(),
			),
			'output_schema'       => array(
				'type'       => 'object',
				'required'   => array( 'site_name', 'plugin_version' ),
				'properties' => array(
					'site_name'      => array( 'type' => 'string' ),
					'plugin_version' => array( 'type' => 'string' ),
				),
			),
			'permission_callback' => array( __CLASS__, 'permission_callback' ),
			'execute_callback'    => array( __CLASS__, 'execute_callback' ),
			'meta'                => array(
				'show_in_rest' => true,
				'mcp'          => array( 'public' => true ),
				'ppok'         => array( 'write' => false ),
			),
		);
	}

	public static function example(): array {
		return array();
	}

	public static function permission_callback(): bool {
		return current_user_can( 'read' );
	}

	public static function execute_callback(): array {
		return array(
			'site_name'      => (string) get_bloginfo( 'name' ),
			'plugin_version' => defined( 'PPOK_AI_TOOLKIT_VERSION' ) ? PPOK_AI_TOOLKIT_VERSION : '0.0.0',
		);
	}
}
