$settings['company_name'] . ' AI Assistant', 'description' => sprintf( 'AI assistant for %s. %s', $settings['company_name'], $settings['company_desc'] ), 'url' => home_url(), 'version' => AIREWP_VERSION, 'protocol_version' => '0.3.0', 'capabilities' => [ 'streaming' => false, 'pushNotifications' => false, 'stateTransitionHistory' => false, ], 'defaultInputModes' => [ 'text/plain' ], 'defaultOutputModes' => [ 'text/plain', 'application/json' ], 'skills' => $skills, 'provider' => [ 'organization' => $settings['company_name'], 'url' => home_url(), ], 'security' => [ 'authentication' => 'none', 'cors' => true, ], 'extensions' => self::build_extensions( $settings ), 'metadata' => [ 'generated_by' => 'AI-Ready WP ' . AIREWP_VERSION, 'generated_at' => gmdate( 'c' ), ], ]; return apply_filters( 'airewp_agent_card', $agent_card, $settings ); } /** * Build extensions block with discovery links. */ private static function build_extensions( array $settings ): array { // No builtBy/promo block: the agent card is the site owner's public // document — tool credits in it read as self-promotion. $ext = []; // llms.txt reference. On a site where WP_Filesystem cannot connect the // global stays null, and calling ->exists() on it was a fatal error. $fs = AI_Ready_WP::filesystem(); if ( null !== $fs && ! empty( $settings['enable_llms_txt'] ) && $fs->exists( AIREWP_ROOT_PATH . 'llms.txt' ) ) { $ext['llmsTxt'] = home_url( '/llms.txt' ); } // Industry metadata if ( ! empty( $settings['industry'] ) && 'general' !== $settings['industry'] ) { $ext['industry'] = $settings['industry']; } // WordPress platform $ext['platform'] = [ 'name' => 'WordPress', 'version' => get_bloginfo( 'version' ), ]; return $ext; } /** * Build skills array based on site capabilities. */ private static function build_skills( array $settings ): array { $name = $settings['company_name']; $skills = []; // Core skills always present $skills[] = [ 'id' => 'business-info', 'name' => 'Business Information', 'description' => "Provide information about {$name} — who we are, what we do, and how to reach us.", 'tags' => [ 'info', 'contact', 'about' ], 'examples' => [ "What does {$name} do?", "How can I contact {$name}?", "What services does {$name} offer?", ], ]; $skills[] = [ 'id' => 'content-search', 'name' => 'Content Search', 'description' => "Search and retrieve content from the {$name} website.", 'tags' => [ 'search', 'content', 'pages' ], 'examples' => [ 'Find articles about web design', 'What pages are available?', ], ]; // Services skill if ( ! empty( $settings['services'] ) ) { $services_list = implode( ', ', array_map( 'trim', explode( ',', $settings['services'] ) ) ); $skills[] = [ 'id' => 'service-info', 'name' => 'Service Information', 'description' => "Provide details about services offered by {$name}: {$services_list}.", 'tags' => [ 'services', 'pricing', 'offerings' ], 'examples' => [ "What services does {$name} offer?", 'Tell me about your pricing', 'Do you offer consulting?', ], ]; } // Contact skill $skills[] = [ 'id' => 'contact', 'name' => 'Contact & Inquiries', 'description' => "Handle contact requests and inquiries for {$name}.", 'tags' => [ 'contact', 'inquiry', 'support' ], 'examples' => [ 'I want to get in touch', 'How do I request a quote?', 'Schedule a consultation', ], ]; // WooCommerce skills if ( class_exists( 'WooCommerce' ) ) { $skills[] = [ 'id' => 'product-catalog', 'name' => 'Product Catalog', 'description' => "Browse and search products available at {$name}.", 'tags' => [ 'products', 'shop', 'catalog', 'ecommerce' ], 'examples' => [ 'Show me your products', 'What items do you sell?', 'Search for a specific product', ], ]; } // Industry-specific skills $industry_skills = self::get_industry_skills( $settings['industry'], $name ); $skills = array_merge( $skills, $industry_skills ); return $skills; } /** * Get industry-specific skills. */ private static function get_industry_skills( string $industry, string $name ): array { $skills = []; switch ( $industry ) { case 'restaurant': $skills[] = [ 'id' => 'menu', 'name' => 'Menu & Reservations', 'description' => "View the menu and make reservations at {$name}.", 'tags' => [ 'menu', 'reservation', 'food', 'dining' ], 'examples' => [ 'Show me the menu', 'Make a reservation' ], ]; break; case 'real-estate': $skills[] = [ 'id' => 'properties', 'name' => 'Property Listings', 'description' => "Browse property listings from {$name}.", 'tags' => [ 'properties', 'listings', 'real-estate' ], 'examples' => [ 'Show available properties', 'Search for apartments' ], ]; break; case 'hotel': $skills[] = [ 'id' => 'rooms', 'name' => 'Room Availability', 'description' => "Check room availability and rates at {$name}.", 'tags' => [ 'rooms', 'booking', 'availability' ], 'examples' => [ 'Check room availability', 'What rooms are available?' ], ]; break; case 'medical': $skills[] = [ 'id' => 'appointments', 'name' => 'Appointment Scheduling', 'description' => "Schedule appointments at {$name}.", 'tags' => [ 'appointment', 'schedule', 'health' ], 'examples' => [ 'Book an appointment', 'What services are available?' ], ]; break; case 'legal': $skills[] = [ 'id' => 'consultation', 'name' => 'Legal Consultation', 'description' => "Request a legal consultation from {$name}.", 'tags' => [ 'consultation', 'legal', 'lawyer' ], 'examples' => [ 'Schedule a consultation', 'What areas of law do you practice?' ], ]; break; } return $skills; } }