There's effectively nothing you can do about your metal income, besides acquiring more metal extractors. TEC and Vasari at least have refineries, but Advent doesn't have anything (technically you have "resource focus", but it sucks). Your best bet at this point in the game, if you can do it, is to raise your credit income with a better trade route and more trade ports, and pick up the slack on the black market.
Now, I don't know what difficulties we're talking about, but the AI on normal difficulty it doesn't surprise me that one of your AI allies is somewhat incompetent. The AI has a bad habit of getting large sums of money tied up in unnecessary expenses, and on lower difficulties (where it doesn't get a resource cheat) this can easily result in its basic needs going unmet. Not much you can do about that, either.
Diplomacy pirates are a bit of a nasty opponent, but you do have some good options. If your starbase is well-placed, you can upgrade it with either mass disorientation or meteor control. These abilities will do a lot to blunt the pirate attacks, and if this frees up enough of your fleet to continue your attack it should be sufficient, but a more permanent solution is to shut down the pirates entirely. Best way to do that is to play on the pirate's two big weaknesses: they have no strike craft, and no long-range units. Get some Iconus Guardians with repulsion to keep their frigates out of range while you rip them up with bombers, which they have no good counter to (just a few flaks). Snipe out the siege-type units first, then build a starbase. By the time you units run out of repulsion, the starbase should be complete and help you fight off the remaining pirates. The turrets are a bit of a challenge, but bombers will eventually whittle through them and then you can bombard the base and finish the pirates.
Now, I don't know what you're up against with the enemy AI, but generally the best solution in these late-game scenarios is big swarms of bombers. Leave a PJI when you go to attack, and if the enemy counter-attacks, you come back and you smash them with bombers. Even if they just retreat, you should kill a big chunk of their fleet while the PJI holds them up. Bombers are also great against starbases (including the mobile Vasari one, since your fleet can just keep moving away from it while the bombers pick it off). Complement this with a Halcyon Carrier for telekinetic push and a Rapture Battlecruiser for concentration aura and you're in business. To take on an enemy fleet, a Progenitor Mothership or two with shield restore backing up a fleet of iconus guardians, defense vessels, and destra crusaders is a great tanking force that will be very difficult for the enemy to bowl over, and should protect your carriers if you need that.