__( 'Preview a Content Template Run', 'ai-product-tools' ), 'description' => __( 'Shows which content template writes each selected product, the affected count and any plan limits, before anything is written. Never calls AI and never writes to a product. Returns a confirm_token to pass to confirm-content-run.', 'ai-product-tools' ), 'category' => self::CATEGORY, 'input_schema' => ContentRunAbilitySchemas::previewInput(), 'output_schema' => ContentRunAbilitySchemas::previewOutput(), 'execute_callback' => array( __CLASS__, 'executePreview' ), 'permission_callback' => array( __CLASS__, 'check_permissions' ), 'meta' => array( 'show_in_rest' => true, 'mcp' => array( 'public' => true, 'type' => 'tool' ), 'annotations' => array( 'readonly' => true, 'destructive' => false, 'idempotent' => false ), ), ) ); } /** * @return void */ private static function registerConfirm(): void { WordPressRuntimeDetector::registerAbility( self::PREFIX . 'confirm-content-run', array( 'label' => __( 'Confirm a Content Template Run', 'ai-product-tools' ), 'description' => __( 'Spends a preview-content-run confirm_token exactly once: generates and writes content for up to a small number of products directly, or queues an Automation job / returns a deep link for a larger run. Results that need review are held back and never applied.', 'ai-product-tools' ), 'category' => self::CATEGORY, 'input_schema' => ContentRunAbilitySchemas::confirmInput(), 'output_schema' => ContentRunAbilitySchemas::confirmOutput(), 'execute_callback' => array( __CLASS__, 'executeConfirm' ), 'permission_callback' => array( __CLASS__, 'check_permissions' ), 'meta' => array( 'show_in_rest' => true, 'mcp' => array( 'public' => true, 'type' => 'tool' ), 'annotations' => array( 'readonly' => false, 'destructive' => true, 'idempotent' => false ), ), ) ); } /** * @param array $input Validated preview-content-run input. * @return array|\WP_Error */ public static function executePreview( array $input ) { return ( new PreviewContentRunService() )->preview( $input, get_current_user_id() ); } /** * @param array $input Validated confirm-content-run input. * @return array|\WP_Error */ public static function executeConfirm( array $input ) { return ( new ConfirmContentRunService() )->confirm( $input, get_current_user_id() ); } /** * Same capability as the five existing Abilities. * * @return bool */ public static function check_permissions(): bool { return current_user_can( 'manage_woocommerce' ); } }