BAF: A Bio-Inspired Agent Framework for Distributed Pervasive Applications