Caramelize the onions. Peel and thinly slice the onions. In a large pot, heat 4 tablespoons of olive oil over medium heat. Add the onions and toss to coat in the oil. Cook, stirring often, for 15 minutes until they have softened. Increase the heat to medium-high and cook, stirring every few minutes, until the onions start to brown, about 30 minutes. Sprinkle with sugar and salt and cook for another 10-15 minutes until caramelized.
Make the rest of the soup. Add the garlic and sauté for 1-2 more minutes, then stir in the flour. Pour in the wine to deglaze the pan. Use a wooden spoon or spatula to scrape any browned bits off the bottom of the pan. Add the broth, thyme leaves, bay leaf and black pepper. Stir well and bring to a boil, then reduce the heat and simmer for 15 minutes. Discard the bay leaf and add salt, to taste.
Toast the bread. Preheat the oven to 400 degrees F and slice the baguette. Line a large baking sheet with parchment paper and add the baguette. Place in the oven to toast for about 5-7 minutes, until the bread is a bit golden. Remove and set aside.
Prepare stretchy cheese topping. Soak the cashews in about 1 cup of boiling hot water for at least 5 minutes. Drain the cashews and add to a blender along with the fresh 1 1/2 cups water, lemon juice, salt and tapioca starch. Blend well. Pour into a small pot/pan and bring the heat to medium-high. Stir constantly until it thickens and then becomes a stretchy, gooey mass of cheese. Remove from heat immediately.
Finish the soup. Spoon a big scoop of cheese on each toasted baguette, on the parchment lined pan. Place the pan in the oven and broil for just a few minutes. To serve, ladle soup into bowls and transfer 1 or 2 cheesy toasts on top of each bowl. Alternatively, use oven-safe bowls and ladle the soup into the bowls, add a toast and a scoop of cheese, then place in the oven on a baking sheet and broil for a few minutes.