Bridging the gap between general probabilistic theories and the device-independent framework for nonlocality and contextuality