} */ function aafm_missing_tools_data(): array { $full = aafm_get_abilities_registry_full(); $live = aafm_get_abilities_registry(); $omitted = get_option( 'aafm_omitted_abilities', array() ); // AAFM_OMITTED_ABILITIES_OPTION; the constant is invisible to PHPStan outside server.php. $omitted = is_array( $omitted ) ? $omitted : array(); $rows = array(); foreach ( aafm_get_stored_enabled_abilities_raw() as $name ) { $lock = isset( $live[ $name ] ) ? aafm_ability_lock_reason( $name ) : null; if ( ! isset( $full[ $name ] ) ) { $reason = 'unknown'; $text = __( 'This tool no longer exists in this version of the plugin.', 'agent-abilities-for-mcp' ); } elseif ( ! isset( $live[ $name ] ) ) { $reason = 'host_inactive'; $text = __( 'Its plugin is not active, or is older than this tool needs.', 'agent-abilities-for-mcp' ); } elseif ( null !== $lock ) { $reason = $lock; $text = aafm_ability_lock_note( $lock ); } elseif ( isset( $omitted[ $name ] ) ) { $reason = 'omitted'; $text = ucfirst( aafm_omitted_reason_label( (string) $omitted[ $name ] ) ) . '.'; } else { continue; } $rows[] = array( 'name' => $name, 'label' => (string) ( $full[ $name ]['label'] ?? $name ), 'reason' => $reason, 'reason_text' => $text, ); } return array( 'id' => 'missing-tools', 'title' => __( 'Why is my tool missing?', 'agent-abilities-for-mcp' ), 'rule' => __( 'These tools are switched on, but agents cannot see them right now. Each line says why.', 'agent-abilities-for-mcp' ), 'rows' => $rows, ); } /** * Print the card. Prints nothing when no enabled tool is missing. * * @param array{id:string,title:string,rule:string,rows:list} $data From aafm_missing_tools_data(). * @return void */ function aafm_render_missing_tools_card( array $data ): void { if ( array() === $data['rows'] ) { return; } $items = ''; foreach ( $data['rows'] as $row ) { $items .= sprintf( '
  • %1$s %2$s
    %3$s
  • ', esc_html( $row['label'] ), esc_html( $row['name'] ), esc_html( $row['reason_text'] ) ); } aafm_render_section( array( 'id' => 'aafm-' . $data['id'], 'title' => $data['title'], 'icon' => 'warning', 'description' => $data['rule'], 'body' => '', ) ); }