From allostatic agents to counterfactual cognisers: active inference, biological regulation, and the origins of cognition