Israel and Hamas have agreed a Gaza ceasefire and hostage release deal following 15 months of war, mediators Qatar and the US say.