How to control the non-isolated bidirectional buck-boost converter?
Your diagram is missing any way to sense, and therefore control, current. As drawn, it a voltage source, which is not good, strung as it is between two low impedance batteries.
While which battery gets charged would be determined by energy state of the batteries, and which mode of buck or boost would be selected by which side has higher voltage, the actual charge process then ought to instruct the charger to send X amps from donor to recipient battery. This cannot be done.
In order to protect that H bridge, given that all components shown are low impedance, as a minimum the current sense ought to be in series with the inductor, to directly control the timing of the switches, and make the bridge a current source rather than a voltage source.
You could relate the inductor current to the charging current by dead reckoning, knowing the battery voltages, as no great precision is required. You could put current sense resistors into one or both supply lines as well if you wanted to sense the charge current directly.