(bool) preg_match( '/^\d{4}-\d{2}-\d{2}$/D', $version ) && ! empty( $ucp['services'] ) && is_array( $ucp['services'] ) && ! empty( $ucp['capabilities'] ) && is_array( $ucp['capabilities'] ), 'version' => preg_match( '/^\d{4}-\d{2}-\d{2}$/D', $version ) ? $version : '', ); } public function run() { $deps = Dependencies::inspect(); $checks = array(); $add = static function ( $name, $status, $detail ) use ( &$checks ) { $checks[] = array( 'name' => $name, 'status' => $status, 'detail' => $detail ); }; $add( 'WooCommerce', $deps['woocommerce'] ? 'pass' : 'fail', $deps['woocommerce'] ? 'Active: ' . $deps['wc_version'] : 'Install and activate WooCommerce.' ); $add( 'WooCommerce AI (optional)', $deps['ai']['active'] ? 'pass' : 'review', $deps['ai']['active'] ? 'Active: ' . $deps['ai']['version'] : 'Not active. The built-in shopper interface works with WooCommerce alone. Optional upstream UCP integration requires separate access.' ); $shop = Shopping\Api::available(); $add( 'Built-in shopper interface', $shop === true ? 'pass' : 'review', $shop === true ? 'Custom REST shopping and customer-confirmed checkout handoff are enabled. Payment remains in WooCommerce checkout.' : $shop->get_error_message() ); $native = Commerce\NativeStore::available(); $add( 'Native agent checkout tools', 'review', $native === true ? 'Enabled. Native WooCommerce gateways process payment; verify loopback connectivity, gateway-specific credentials and an actual staging purchase. Enabled does not mean all gateways are headless-compatible.' : $native->get_error_message() ); $add( 'Shopping storage', get_option( 'wacc_schema' ) === Shopping\Storage::SCHEMA ? 'pass' : 'fail', get_option( 'wacc_schema' ) === Shopping\Storage::SCHEMA ? 'Private cart and throttle tables are installed.' : 'Shopping tables are not ready; check database permissions and reload WordPress admin.' ); $https = wp_parse_url( home_url( '/' ), PHP_URL_SCHEME ) === 'https'; $add( 'Public HTTPS', $https ? 'pass' : 'fail', $https ? 'The configured home URL uses HTTPS.' : 'Configure HTTPS before accepting agent purchases.' ); $add( 'Permalinks', get_option( 'permalink_structure' ) ? 'pass' : 'fail', get_option( 'permalink_structure' ) ? 'Pretty permalinks are configured.' : 'Select a non-Plain permalink structure in Settings > Permalinks.' ); $routes = rest_get_server()->get_routes(); $has_checkout = isset( $routes['/wc/ucp/v1/checkout-sessions'] ); $add( 'Optional local UCP checkout route', $has_checkout ? 'pass' : 'review', $has_checkout ? 'The documented optional checkout-session route is registered; authentication and payment are not tested.' : 'Optional route absent. This does not prevent built-in shopper API use.' ); $status = 0; if ( $https ) { // One fixed-origin, bounded GET. Never follow profile-supplied endpoints. $response = wp_safe_remote_get( self::discovery_url(), array( 'timeout' => 8, 'redirection' => 0, 'limit_response_size' => 131072, 'headers' => array( 'Accept' => 'application/json', 'Cache-Control' => 'no-cache' ), 'cookies' => array(), ) ); if ( is_wp_error( $response ) ) { $add( 'Public UCP discovery', 'review', 'The safe HTTP request failed. Check DNS, TLS, firewall and loopback restrictions. Private local addresses may be rejected. No response body was logged.' ); } else { $status = (int) wp_remote_retrieve_response_code( $response ); $summary = self::profile_summary( json_decode( wp_remote_retrieve_body( $response ), true ) ); $ok = $status === 200 && $summary['valid']; $add( 'Public UCP discovery', $ok ? 'pass' : 'fail', $ok ? 'HTTP 200; UCP version ' . $summary['version'] . ', services and capabilities found. This is a shape check, not schema conformance or checkout verification.' : 'HTTP ' . $status . '; expected a JSON UCP profile with version, services and capabilities. Redirects are not followed. Check the domain-root discovery URL.' ); } } else { $add( 'Public UCP discovery', 'review', 'Not requested over HTTP. Configure HTTPS and rerun.' ); } if ( $deps['woocommerce'] && function_exists( 'WC' ) && WC()->payment_gateways() ) { $enabled = array_filter( WC()->payment_gateways()->payment_gateways(), static function ( $gateway ) { return $gateway->enabled === 'yes'; } ); $add( 'Payment configuration', empty( $enabled ) ? 'fail' : 'review', count( $enabled ) . ' enabled gateway(s). Native carts return methods available for that customer and cart. Verify the selected gateway’s payment_data, scripts, authentication and redirects on staging.' ); } else { $add( 'Payment configuration', 'review', 'Payment gateways could not be inspected.' ); } $add( 'Optional shopping-service onboarding', 'review', 'External shopping marketplaces and optional WooCommerce AI services have separate onboarding. Connecting a customer agent directly to this plugin’s MCP endpoint does not require WooCommerce AI or WordPress.com.' ); $add( 'Delivered total and paid checkout', 'review', 'Use the Purchase verification tab to verify an address-specific shipping quote and an agent-originated paid order.' ); $shopping_status = Settings::status(); $messages = array( 'off' => 'Off: Agentomise shopping access is disabled.', 'browse' => 'Browse only: product discovery is available; new carts, cart changes and purchases are blocked.', 'shopping' => 'Shopping enabled: complete a staging checkout test before accepting customers.' ); $add( 'Agent shopping status', 'review', $messages[$shopping_status] ); $report = array( 'time' => time(), 'checks' => $checks ); update_option( self::OPTION, $report, false ); EventLog::record( 'readiness_checked', array( 'checks' => count( $checks ), 'http_status' => $status ) ); return $report; } }