Bridges over 2 structures using a flat surface

Hi all,

I have two solidified structures that are distant by few millimeters. I have to bridge over these with an optimal tangency with both surfaces (upper faces). their topologies are not rectilinear. Look at the picture.


I have thought about using nurbs from one side to the second. Then deforming a flat surface or a shinkwrap modifier. But I did not manage to produce something good.
Have you got an idea?

Additional challenge: if possible, could be great if I could script this.

Thanks !