The agreement ends weeks of lobbying by outside interests and negotiations among Democrats in the California Legislature and Gov. Gavin Newsom about how to handle a surge of income tax collected on stock market gains related to artificial intelligence.